import{r as u,k as I,a5 as f,d as L,as as V,c as $,e as C,f as B,g as y,B as R,az as E,l as W,v as H,m as P}from"./CQ5rtXCu.js";const N=t=>{const a=t.lensRatio??.4,h=u(null),g=u(null),o=u(!1),v=u({}),b=u({});return I(()=>f(t.imageSrc),()=>{o.value=!1}),{boxRef:h,imageRef:g,zoomVisible:o,lensStyle:v,paneStyle:b,handleMouseMove:m=>{const n=h.value,l=g.value;if(!n||!l||!l.naturalWidth||!l.naturalHeight){o.value=!1;return}const r=n.getBoundingClientRect(),s=l.getBoundingClientRect(),c=Math.min(s.width/l.naturalWidth,s.height/l.naturalHeight),e=l.naturalWidth*c,d=l.naturalHeight*c,w=s.left-r.left+(s.width-e)/2,x=s.top-r.top+(s.height-d)/2,i=Math.min(e,d)*a;if(i<=0){o.value=!1;return}const Y=m.clientX-r.left,A=m.clientY-r.top,k=Math.min(Math.max(Y-i/2,w),w+e-i),z=Math.min(Math.max(A-i/2,x),x+d-i);v.value={left:`${k}px`,top:`${z}px`,width:`${i}px`,height:`${i}px`};const p=r.width/i;b.value={backgroundImage:`url("${f(t.imageSrc)}")`,backgroundSize:`${e*p}px ${d*p}px`,backgroundPosition:`${-(k-w)*p}px ${-(z-x)*p}px`},o.value=!0},handleMouseLeave:()=>{o.value=!1}}},j={class:"relative"},q=["src","alt","title"],X=12,G=L({__name:"ImageMagnifier",props:{src:{default:""},alt:{default:""},boxClass:{default:"aspect-square w-full"},imgClass:{default:""},lensRatio:{},placement:{default:"auto"},disabled:{type:Boolean,default:!1}},setup(t){const a=t,{boxRef:h,imageRef:g,zoomVisible:o,lensStyle:v,paneStyle:b,handleMouseMove:S,handleMouseLeave:M}=N({imageSrc:V(a,"src"),lensRatio:a.lensRatio}),m=u({}),n=u("right");function l(c){if(a.disabled||!a.src)return;S(c);const e=h.value?.getBoundingClientRect();if(e?.width){if(m.value={width:`${e.width}px`,height:`${e.height}px`},a.placement!=="auto"){n.value=a.placement;return}e.right+X+e.width<=window.innerWidth?n.value="right":e.left-X-e.width>=0?n.value="left":n.value="overlay"}}const r=$(()=>n.value==="overlay"?"left-0":n.value==="left"?"right-full mr-3":"left-full ml-3"),s=$(()=>o.value&&!!a.src&&!a.disabled);return(c,e)=>(C(),B("div",j,[y("div",{ref_key:"boxRef",ref:h,class:R(["relative overflow-hidden",t.boxClass]),onMousemove:l,onMouseleave:e[0]||(e[0]=(...d)=>f(M)&&f(M)(...d))},[t.src?(C(),B("img",{key:0,ref_key:"imageRef",ref:g,src:t.src,alt:t.alt,title:t.alt||void 0,class:R(["block h-full w-full object-contain",t.imgClass]),draggable:"false",loading:"lazy"},null,10,q)):E(c.$slots,"default",{key:1}),W(y("div",{class:"pointer-events-none absolute z-10 hidden border border-[var(--theme-primary-color,#1890ff)] bg-white/30 md:block",style:P(f(v))},null,4),[[H,s.value]])],34),W(y("div",{class:R(["pointer-events-none absolute top-0 z-30 hidden border border-gray-200 bg-white bg-no-repeat shadow-lg md:block",r.value]),style:P([m.value,f(b)])},null,6),[[H,s.value]])]))}});export{G as _};
