import"./rolldown-runtime-DIIn1E2Q.js";import{A as e,D as t,F as n,G as r,Ht as i,I as a,O as o,R as s,Ut as c,_t as l,et as u,j as d,kt as f,pt as p,rt as m,ut as h}from"./vendor-vue-core-DO0afONr.js";import"./vendor-other-CiPV8GBG.js";import{O as g}from"./vendor-vueuse-DUMtJaL2.js";import"./vendor-reka-ui-B53kLmAc.js";import{t as _}from"./Button-Ca3rDegY.js";var v={key:0,class:`flex items-center gap-1`},y={class:`mr-1 text-muted-foreground`},b={"data-testid":`batch-counter`},x=s({__name:`BatchNavigation`,props:r({count:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:[`update:modelValue`],setup(t){let n=h(t,`modelValue`);return(t,r)=>t.count>1?(u(),d(`div`,v,[o(`span`,y,[m(t.$slots,`label`)]),a(_,{variant:`muted-textonly`,size:`icon-sm`,disabled:n.value===0,"data-testid":`batch-prev`,onClick:r[0]||=e=>n.value--},{default:l(()=>r[2]||=[o(`i`,{class:`icon-[lucide--chevron-left]`},null,-1)]),_:1},8,[`disabled`]),o(`span`,b,c(t.$t(`batch.index`,{current:n.value+1,total:t.count})),1),a(_,{variant:`muted-textonly`,size:`icon-sm`,disabled:n.value===t.count-1,"data-testid":`batch-next`,onClick:r[1]||=e=>n.value++},{default:l(()=>r[3]||=[o(`i`,{class:`icon-[lucide--chevron-right]`},null,-1)]),_:1},8,[`disabled`])])):e(``,!0)}}),S={class:`flex size-full min-h-32 flex-col overflow-hidden`},C={key:0,class:`flex shrink-0 justify-between px-2 py-1 text-xs`,"data-testid":`batch-nav`},w={key:0},T=[`src`,`alt`],E=[`src`,`alt`],D={key:2,class:`flex min-h-0 flex-1 items-center justify-center`},O=s({__name:`WidgetImageCompare`,props:{widget:{}},setup(r){let o=r,s=f(null),m=f(50),h=f(0),_=f(0),{elementX:v,elementWidth:y,isOutside:b}=g(s);p([v,y,b],([e,t,n])=>{!n&&t>0&&(m.value=Math.max(0,Math.min(100,e/t*100)))});function isSingleImage(e){return typeof e==`string`}let O=t(()=>{let e=o.widget.value;return isSingleImage(e)?null:e}),k=t(()=>O.value?.beforeImages?.length??0),A=t(()=>O.value?.afterImages?.length??0),j=t(()=>k.value>1||A.value>1);p(()=>O.value?.beforeImages,()=>{h.value=0}),p(()=>O.value?.afterImages,()=>{_.value=0});let M=t(()=>{let e=o.widget.value;return isSingleImage(e)?e:e?.beforeImages?.[h.value]??``}),N=t(()=>{let e=o.widget.value;return isSingleImage(e)?``:e?.afterImages?.[_.value]??``}),P=t(()=>!!(M.value&&N.value)),F=t(()=>{let e=o.widget.value;return!isSingleImage(e)&&e?.beforeAlt?e.beforeAlt:`Before image`}),I=t(()=>{let e=o.widget.value;return!isSingleImage(e)&&e?.afterAlt?e.afterAlt:`After image`});return(t,r)=>(u(),d(`div`,S,[j.value?(u(),d(`div`,C,[a(x,{modelValue:h.value,"onUpdate:modelValue":r[0]||=e=>h.value=e,count:k.value,"data-testid":`before-batch`},{label:l(()=>[n(c(t.$t(`imageCompare.batchLabelA`)),1)]),_:1},8,[`modelValue`,`count`]),k.value<=1?(u(),d(`div`,w)):e(``,!0),a(x,{modelValue:_.value,"onUpdate:modelValue":r[1]||=e=>_.value=e,count:A.value,"data-testid":`after-batch`},{label:l(()=>[n(c(t.$t(`imageCompare.batchLabelB`)),1)]),_:1},8,[`modelValue`,`count`])])):e(``,!0),M.value||N.value?(u(),d(`div`,{key:1,ref_key:`containerRef`,ref:s,class:`relative min-h-0 flex-1 overflow-hidden rounded-lg bg-node-component-surface py-4`},[N.value?(u(),d(`img`,{key:0,src:N.value,alt:I.value,draggable:`false`,class:`absolute inset-0 size-full object-contain`},null,8,T)):e(``,!0),M.value?(u(),d(`img`,{key:1,src:M.value,alt:F.value,draggable:`false`,class:`absolute inset-0 size-full object-contain`,style:i(P.value?{clipPath:`inset(0 ${100-m.value}% 0 0)`}:void 0)},null,12,E)):e(``,!0),P.value?(u(),d(`div`,{key:2,class:`pointer-events-none absolute top-1/2 z-10 size-6 -translate-1/2 rounded-full border-2 border-white bg-white/30 shadow-lg backdrop-blur-sm`,style:i({left:`${m.value}%`}),role:`presentation`},null,4)):e(``,!0)],512)):(u(),d(`div`,D,c(t.$t(`imageCompare.noImages`)),1))]))}});export{O as default};
//# sourceMappingURL=WidgetImageCompare-D4HWMTq5.js.map