@wyxos/vibe 2.1.17 → 2.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,7 +6,6 @@ type Props = {
|
|
|
6
6
|
remove?: () => void;
|
|
7
7
|
loaderSlotFn?: Slot<MasonryItemLoaderSlotProps>;
|
|
8
8
|
errorSlotFn?: Slot<MasonryItemErrorSlotProps>;
|
|
9
|
-
timeoutSeconds?: number;
|
|
10
9
|
hovered?: boolean;
|
|
11
10
|
};
|
|
12
11
|
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
@@ -22,7 +21,6 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {},
|
|
|
22
21
|
error: unknown;
|
|
23
22
|
}) => any) | undefined;
|
|
24
23
|
}>, {
|
|
25
|
-
timeoutSeconds: number;
|
|
26
24
|
hovered: boolean;
|
|
27
25
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
28
26
|
declare const _default: typeof __VLS_export;
|
|
@@ -7,7 +7,6 @@ export type MasonryItemSlotProps = {
|
|
|
7
7
|
export type MasonryItemLoaderSlotProps = MasonryItemSlotProps;
|
|
8
8
|
export type MasonryItemErrorSlotProps = MasonryItemSlotProps & {
|
|
9
9
|
error: unknown;
|
|
10
|
-
retry: () => void;
|
|
11
10
|
};
|
|
12
11
|
export type MasonryItemDefinition = {
|
|
13
12
|
header?: Slot<MasonryItemSlotProps>;
|
package/lib/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),xt={mode:"default",pageSize:20,backfillRequestDelayMs:2e3,enterStaggerMs:40,page:1,itemWidth:300,prefetchThresholdPx:200,gapX:16,gapY:16,headerHeight:0,footerHeight:0,overscanPx:600},jt=["aria-label","aria-valuemax","aria-valuenow"],We=e.defineComponent({__name:"MasonryVideoControls",props:{currentTime:{},duration:{},ariaLabel:{default:"Seek"},step:{default:.1},keyboardStep:{default:5}},emits:["seek"],setup(r,{expose:x,emit:u}){const i=r,d=u,b=e.ref(null),k=e.ref(null),c=e.ref(null),y=e.ref(!1),v=e.computed(()=>Number.isFinite(i.step)?Math.max(0,i.step):0),g=e.computed(()=>Number.isFinite(i.duration)?Math.max(0,i.duration):0),S=e.computed(()=>{const h=Number.isFinite(i.currentTime)?i.currentTime:0;return T(h,0,g.value)}),B=e.computed(()=>g.value>0?S.value/g.value:0);function T(h,E,N){return Math.min(N,Math.max(E,h))}function M(h){return v.value<=0?h:Math.round(h/v.value)*v.value}function P(h){const E=T(h,0,g.value);d("seek",M(E))}function F(h){const E=k.value;if(!E)return;const N=E.getBoundingClientRect();if(!N.width)return;const Y=T((h-N.left)/N.width,0,1);P(Y*g.value)}function Z(h){const E=k.value;E&&(y.value=!0,E.setPointerCapture&&E.setPointerCapture(h.pointerId),F(h.clientX))}function $(h){y.value&&F(h.clientX)}function H(h){if(!y.value)return;y.value=!1;const E=k.value;E?.releasePointerCapture&&E.releasePointerCapture(h.pointerId)}function j(h){if(g.value<=0)return;const E=Number.isFinite(i.keyboardStep)?i.keyboardStep:1;let N=S.value;switch(h.key){case"ArrowLeft":case"ArrowDown":N-=E;break;case"ArrowRight":case"ArrowUp":N+=E;break;case"Home":N=0;break;case"End":N=g.value;break;default:return}h.preventDefault(),P(N)}function U(){b.value?.focus()}return x({focus:U,seekTo:P,percent:B,currentValue:S,maxValue:g,isDragging:y,rootEl:b,trackEl:k,thumbEl:c}),(h,E)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootEl",ref:b,class:"w-full select-none",role:"slider",tabindex:"0","aria-label":i.ariaLabel,"aria-valuemin":0,"aria-valuemax":g.value,"aria-valuenow":S.value,onKeydown:j},[e.createElementVNode("div",{ref_key:"trackEl",ref:k,class:"relative h-2 w-full cursor-pointer rounded-full bg-slate-200",onPointerdown:Z,onPointermove:$,onPointerup:H,onPointercancel:H,onPointerleave:H},[e.createElementVNode("div",{class:"absolute inset-y-0 left-0 rounded-full bg-slate-500",style:e.normalizeStyle({width:`${B.value*100}%`})},null,4),e.createElementVNode("div",{ref_key:"thumbEl",ref:c,class:"absolute top-1/2 h-3 w-3 -translate-x-1/2 -translate-y-1/2 rounded-full bg-slate-700 shadow",style:e.normalizeStyle({left:`${B.value*100}%`}),"aria-hidden":"true"},null,4)],544)],40,jt))}}),Ut={key:0,"data-testid":"masonry-loader-spinner",class:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-1"},Wt={key:1,class:"h-5 w-5 animate-spin text-slate-500",viewBox:"0 0 24 24","aria-hidden":"true"},Gt={key:2,"data-testid":"masonry-loader-retry-status",class:"text-xs font-medium text-slate-600"},Kt={key:1,"data-testid":"masonry-loader-error",class:"absolute inset-0 z-20 grid place-items-center p-3 pointer-events-none"},Jt={class:"pointer-events-auto flex flex-col items-center justify-center gap-2"},Qt={class:"text-center text-xs font-medium text-red-700"},Zt=["src","width","height","alt"],en=["poster"],tn=["src"],nn={key:4,class:"pointer-events-none absolute inset-x-0 bottom-0 z-20 px-2 pb-2 opacity-0 transition-opacity duration-200 group-hover:pointer-events-auto group-hover:opacity-100"},ht=3,pt=e.defineComponent({__name:"MasonryLoader",props:{item:{},remove:{},loaderSlotFn:{},errorSlotFn:{},timeoutSeconds:{default:15},hovered:{type:Boolean,default:!1}},emits:["success","error"],setup(r,{emit:x}){const u=r,i=x,d=e.defineComponent({name:"SlotRenderer",props:{slotFn:{type:Function,required:!1},slotProps:{type:Object,required:!0}},setup(a){return()=>{const f=a.slotFn;return f?f(a.slotProps):null}}}),b=e.ref(null),k=e.ref(null),c=e.ref(null),y=e.ref(null),v=e.ref(!1),g=e.ref(!1),S=e.ref(!1),B=e.ref(!1),T=e.ref(0),M=e.ref(0),P=e.ref(null),F=e.computed(()=>u.item?.type==="video"),Z=e.computed(()=>{if(!F.value)return;const a=u.item?.preview,f=u.item?.original;if(!(typeof a!="string"||!a)&&!(typeof f=="string"&&a===f)&&!/\.(mp4|webm)(\?|#|$)/i.test(a))return a}),$=e.computed(()=>{if(!F.value)return;const a=u.item?.preview;if(typeof a=="string"&&a&&/\.(mp4|webm)(\?|#|$)/i.test(a))return a;const f=u.item?.original;if(typeof f=="string"&&f)return f}),H=e.ref(!1),j=e.computed(()=>!!u.hovered),U=e.ref(0),h=e.ref(0),E=e.computed(()=>{const a=u.item?.timeoutSeconds;return typeof a=="number"&&Number.isFinite(a)?a:typeof u.timeoutSeconds=="number"&&Number.isFinite(u.timeoutSeconds)?u.timeoutSeconds:0});function N(){u.remove?.()}const Y=e.computed(()=>{const a=u.item?.width,f=u.item?.height;return{aspectRatio:`${a} / ${f}`}}),ke=e.computed(()=>u.item?.type==="image"),W=e.computed(()=>B.value?`Retrying ${M.value}/${ht}`:"");let X=null,ee=null,D=null,L=null;function G(){D!=null&&(window.clearTimeout(D),D=null)}function te(){L!=null&&(window.clearTimeout(L),L=null)}function ce(){G();const a=E.value;if(a<=0)return;const f=a*1e3;D=window.setTimeout(()=>{v.value&&(g.value||S.value||(be(),he(new Error("timeout"))))},f)}function be(){const a=k.value;a&&(a.removeAttribute("src"),a.src="");const f=c.value;if(!f)return;f.pause();const z=y.value;z&&z.removeAttribute("src"),f.removeAttribute("src"),f.load()}function Be(){if(!v.value)return;if(M.value>=ht){B.value=!1;return}te();const a=M.value+1;M.value=a,B.value=!0;const f=(a-1)*1e3;L=window.setTimeout(()=>{L=null,v.value&&xe({resetAutoRetry:!1})},f)}function fe(){v.value||(v.value=!0,g.value=!1,S.value=!1,ce())}function de(a){U.value=Number.isFinite(a.duration)?a.duration:0,h.value=Number.isFinite(a.currentTime)?a.currentTime:0}async function ve(){if(!F.value||!j.value||!v.value||!g.value||!H.value)return;const a=c.value;if(a)try{a.muted=!0,await a.play()}catch{}}function Ee(){const a=c.value;a&&(a.paused||a.pause())}function Ie(){const a=c.value;a&&(a.paused||a.pause())}e.watch(()=>u.hovered,a=>{if(a){fe(),ve();return}Ee()});function ne(a){const f=c.value;f&&Number.isFinite(a)&&(f.currentTime=Math.max(0,Math.min(a,Number.isFinite(f.duration)?f.duration:a)),de(f))}e.onMounted(()=>{if(typeof IntersectionObserver>"u"){fe();return}if(X=new IntersectionObserver(a=>{for(const f of a)if(f.isIntersecting&&!((f.intersectionRatio??0)<.5)){fe(),X?.disconnect(),X=null;return}},{threshold:[0,.5,1]}),b.value&&X.observe(b.value),F.value&&b.value){const a=b.value.closest('[data-testid="items-scroll-container"]');ee=new IntersectionObserver(f=>{for(const z of f){const ze=z.intersectionRatio??0,Fe=!!z.isIntersecting&&ze>=.5;H.value=Fe,Fe?j.value&&ve():Ie()}},{root:a??void 0,threshold:[0,.25,.5,.75,1]}),ee.observe(b.value)}}),e.onUnmounted(()=>{X?.disconnect(),X=null,ee?.disconnect(),ee=null,G(),te()});function me(){g.value||(g.value=!0,S.value=!1,P.value=null,G(),te(),B.value=!1,M.value=0,i("success",u.item))}function he(a){S.value||(g.value=!1,S.value=!0,P.value=a,G(),i("error",{item:u.item,error:a}),Be())}function xe({resetAutoRetry:a}){v.value&&(g.value=!1,S.value=!1,P.value=null,T.value+=1,a&&(te(),B.value=!1,M.value=0),ce())}function oe(){xe({resetAutoRetry:!0})}function Ce(){me();const a=c.value;a&&de(a),ve()}function q(){const a=c.value;a&&de(a)}return(a,f)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootEl",ref:b,class:"relative bg-slate-100",style:e.normalizeStyle(Y.value)},[v.value&&!g.value&&(!S.value||B.value)?(e.openBlock(),e.createElementBlock("div",Ut,[u.loaderSlotFn?(e.openBlock(),e.createBlock(e.unref(d),{key:0,"slot-fn":u.loaderSlotFn,"slot-props":{item:u.item,remove:N}},null,8,["slot-fn","slot-props"])):(e.openBlock(),e.createElementBlock("svg",Wt,f[2]||(f[2]=[e.createElementVNode("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",fill:"none",stroke:"currentColor","stroke-width":"4"},null,-1),e.createElementVNode("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 0 1 8-8v4a4 4 0 0 0-4 4H4z"},null,-1)]))),B.value?(e.openBlock(),e.createElementBlock("p",Gt,e.toDisplayString(W.value),1)):e.createCommentVNode("",!0)])):v.value&&S.value&&!B.value?(e.openBlock(),e.createElementBlock("div",Kt,[e.createElementVNode("div",Jt,[u.errorSlotFn?(e.openBlock(),e.createBlock(e.unref(d),{key:0,"slot-fn":u.errorSlotFn,"slot-props":{item:u.item,remove:N,error:P.value,retry:oe}},null,8,["slot-fn","slot-props"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("p",Qt,"Error "+e.toDisplayString(P.value),1),e.createElementVNode("button",{type:"button","data-testid":"masonry-loader-retry",class:"inline-flex items-center rounded-md border border-slate-200 bg-white px-2 py-1 text-xs font-medium text-slate-700",onClick:oe}," Retry ")],64))])])):e.createCommentVNode("",!0),v.value&&ke.value&&!S.value?(e.openBlock(),e.createElementBlock("img",{key:u.item.id+":img:"+T.value,ref_key:"imgEl",ref:k,class:e.normalizeClass(["h-full w-full object-cover transition-opacity duration-300",g.value?"opacity-100":"opacity-0"]),src:u.item.preview,width:u.item.width,height:u.item.height,loading:"lazy",alt:u.item.id,onLoad:me,onError:f[0]||(f[0]=z=>he(z))},null,42,Zt)):v.value&&!S.value?(e.openBlock(),e.createElementBlock("video",{key:u.item.id+":vid:"+T.value,class:e.normalizeClass(["h-full w-full object-cover transition-opacity duration-300",g.value?"opacity-100":"opacity-0"]),poster:Z.value,ref_key:"videoEl",ref:c,playsinline:"",loop:"",preload:"metadata",onLoadedmetadata:Ce,onTimeupdate:q,onDurationchange:q,onLoadeddata:q,onError:f[1]||(f[1]=z=>he(z))},[e.createElementVNode("source",{ref_key:"videoSourceEl",ref:y,src:$.value,type:"video/mp4"},null,8,tn)],42,en)):e.createCommentVNode("",!0),v.value&&F.value&&!S.value?(e.openBlock(),e.createElementBlock("div",nn,[e.createVNode(We,{duration:U.value,"current-time":h.value,onSeek:ne},null,8,["duration","current-time"])])):e.createCommentVNode("",!0)],4))}}),St=Symbol("masonryItemRegistry");function on(r,x){return!r||r<=0||!x||x<=0?1:Math.max(1,Math.floor(r/x))}function ln(r,x,u,i=0){if(!r||r<=0||!x||x<=0)return u;const d=typeof i=="number"&&i>0?i:0,b=Math.max(0,x-1)*d,k=r-b;return!k||k<=0?u:k/x}function rn(r,x){const u=r?.width,i=r?.height;return typeof u=="number"&&typeof i=="number"&&u>0&&i>0?i/u*x:x}function Mt(r){return Number.isFinite(r)&&r>0?Math.floor(r):1}function Ue(r){return Number.isFinite(r)&&r>0?Math.floor(r):0}function an(r){async function x(i){const d=Ue(i);if(d<=0)return;r.stats.value={...r.stats.value,cooldownMsTotal:d,cooldownMsRemaining:d};const b=Date.now(),k=100;await new Promise(c=>{const y=setInterval(()=>{const v=Date.now()-b,g=Math.max(0,d-v);r.stats.value={...r.stats.value,cooldownMsTotal:d,cooldownMsRemaining:g},g<=0&&(clearInterval(y),c())},k)})}async function u(i){const d=Mt(r.getPageSize()),b=r.isEnabled(),k=Ue(r.getRequestDelayMs()),c=[];let y=0;r.buffer.value.length&&(y=r.buffer.value.length,c.push(...r.buffer.value),r.buffer.value=[]),r.stats.value={...r.stats.value,enabled:b,isBackfillActive:!1,isRequestInFlight:!1,requestPage:null,cooldownMsTotal:k,cooldownMsRemaining:0,progress:{collected:0,target:0},pageSize:d,bufferSize:0};const v=[];let g=i,S=0,B=!1;for(;c.length<d&&g!=null;){const P=g;B&&(r.stats.value={...r.stats.value,enabled:b,isBackfillActive:!0,isRequestInFlight:!0,requestPage:P,progress:{collected:Math.min(c.length,d),target:d},cooldownMsTotal:k,cooldownMsRemaining:0,pageSize:d});const F=await r.getContent(P);v.push(P),B&&(r.stats.value={...r.stats.value,enabled:b,isBackfillActive:!0,isRequestInFlight:!1,requestPage:null}),S+=F.items.length,r.markEnterFromLeft(F.items),c.push(...F.items),g=F.nextPage,!B&&c.length<d&&g!=null?(B=!0,r.stats.value={...r.stats.value,enabled:b,isBackfillActive:!0,isRequestInFlight:!1,requestPage:null,progress:{collected:Math.min(c.length,d),target:d},cooldownMsTotal:k,cooldownMsRemaining:0,pageSize:d}):B&&(r.stats.value={...r.stats.value,enabled:b,isBackfillActive:!0,progress:{collected:Math.min(c.length,d),target:d}}),B&&c.length<d&&g!=null&&await x(k)}const T=c.slice(0,d),M=c.slice(d);return r.buffer.value=M,r.stats.value={...r.stats.value,enabled:b,isBackfillActive:!1,isRequestInFlight:!1,requestPage:null,progress:{collected:0,target:0},cooldownMsTotal:k,cooldownMsRemaining:0,pageSize:d,bufferSize:M.length,lastBatch:{startPage:i,pages:v,usedFromBuffer:y,fetchedFromNetwork:S,collectedTotal:c.length,emitted:T.length,carried:M.length},totals:{pagesFetched:r.stats.value.totals.pagesFetched+v.length,itemsFetchedFromNetwork:r.stats.value.totals.itemsFetchedFromNetwork+S}},{batchItems:T,pages:v,nextPage:g}}return{loadBackfillBatch:u}}function sn(r){const x=r.columnCount,u=r.columnWidth,i=r.gapX,d=r.gapY,b=r.headerHeight,k=r.footerHeight,c=r.bucketPx,y=Array.from({length:x},()=>0),v=new Array(r.items.length),g=new Array(r.items.length),S=new Map,B=new Map;let T=0;for(let M=0;M<r.items.length;M+=1){const P=r.items[M];P?.id&&B.set(P.id,M);let F=0;for(let h=1;h<y.length;h+=1)y[h]<y[F]&&(F=h);const Z=F*(u+i),$=y[F],H=rn(P,u)+b+k;v[M]={x:Z,y:$},g[M]=H,y[F]=$+H+d,T=Math.max(T,$+H);const j=Math.floor($/c),U=Math.floor(($+H)/c);for(let h=j;h<=U;h+=1){const E=S.get(h);E?E.push(M):S.set(h,[M])}}return{positions:v,heights:g,buckets:S,contentHeight:T,indexById:B}}function un(r){const x=r.itemCount;if(!x)return[];if(r.viewportHeight<=0)return Array.from({length:x},(y,v)=>v);const u=Math.max(0,r.scrollTop-r.overscanPx),i=r.scrollTop+r.viewportHeight+r.overscanPx,d=Math.floor(u/r.bucketPx),b=Math.floor(i/r.bucketPx),k=new Set;for(let y=d;y<=b;y+=1){const v=r.buckets.get(y);if(v)for(const g of v)k.add(g)}const c=Array.from(k);return c.sort((y,v)=>y-v),c}const cn={class:"hidden"},fn={key:0,class:"flex h-full items-center justify-center"},dn={key:1,class:"text-sm font-medium text-red-700"},vn=["onMouseenter","onMouseleave"],mn={key:0,class:"pointer-events-auto absolute inset-0 z-10"},hn={class:"relative"},pn={key:0,class:"pointer-events-auto absolute inset-0 z-10"},gn={class:"mt-4 pb-2 text-center text-xs text-slate-600"},yn={key:0,class:"inline-flex items-center justify-center gap-2"},wn={key:1},kn={key:2},gt=100,bn=200,yt=600,wt=300,kt=600,bt=600,xn=400,Sn=5,Mn=1e3,Bt=e.defineComponent({inheritAttrs:!1,__name:"Masonry",props:e.mergeDefaults({getContent:{},mode:{},pageSize:{},backfillRequestDelayMs:{},enterStaggerMs:{},items:{},page:{},restoredPages:{},itemWidth:{},prefetchThresholdPx:{},gapX:{},gapY:{},headerHeight:{},footerHeight:{},overscanPx:{}},xt),emits:["update:items","preloaded","failures"],setup(r,{expose:x,emit:u}){const i=r,d=u,b=e.useAttrs(),k=e.defineComponent({name:"SlotRenderer",props:{slotFn:{type:Function,required:!1},slotProps:{type:Object,required:!0}},setup(t){return()=>{const o=t.slotFn;return o?o(t.slotProps):null}}}),c=e.shallowRef(null),y=e.ref(null);function v(t){y.value=t}function g(t){y.value===t&&(y.value=null)}e.provide(St,t=>{c.value||(c.value=t)});const S=[],B=[];let T=null,M=null;function P(){if(!S.length)return;const t=S.splice(0,S.length);d("preloaded",t)}function F(){if(!B.length)return;const t=B.splice(0,B.length);d("failures",t)}function Z(){T||(T=setTimeout(()=>{T=null,P()},gt))}function $(){M||(M=setTimeout(()=>{M=null,F()},gt))}function H(t){c.value?.onPreloaded?.(t),S.push(t),Z()}function j(t){c.value?.onFailed?.(t),B.push(t),$()}e.onMounted(()=>{if(!c.value)throw new Error("[Masonry] Missing <MasonryItem> definition. Add <MasonryItem> as a child of <Masonry>.")});const U=e.computed(()=>{const{class:t,...o}=b;return o}),h=e.ref(null),E=e.ref(0),N=e.ref(0),Y=e.ref(0);let ke;const W=e.computed(()=>i.gapX),X=e.computed(()=>i.gapY);function ee(t){if(!t)return 0;const o=Math.max(0,W.value);return Math.max(0,t.clientWidth-o)}const D=e.computed(()=>i.headerHeight),L=e.computed(()=>i.footerHeight),G=e.computed(()=>c.value?.header),te=e.computed(()=>c.value?.loader),ce=e.computed(()=>c.value?.footer),be=e.computed(()=>c.value?.overlay),Be=e.computed(()=>c.value?.error),fe=e.computed(()=>!!G.value),de=e.computed(()=>!!ce.value),ve=e.computed(()=>!!be.value),Ee=e.computed(()=>{if(D.value>0)return{height:`${D.value}px`}}),Ie=e.computed(()=>{if(L.value>0)return{height:`${L.value}px`}}),ne=e.ref([]),me=e.ref([]),he=e.ref(new Map),xe=e.ref(0),oe=e.ref(new Map);function Ce(t){const o=typeof t=="number"&&Number.isFinite(t)?t:0;return Y.value+N.value+Math.max(0,o)}const q=e.ref(new Set),a=e.ref(new Set),f=new Set,z=e.ref(new Map);function ze(t){return Number.isFinite(t)?Math.max(0,Math.min(250,t)):0}function Fe(t){if(!a.value.has(t))return;const o=z.value.get(t)??0;if(!(o<=0))return`${o}ms`}const _e=e.ref(new Map),K=e.ref(new Set),J=e.ref([]);function It(t){const o=_e.value.get(t);return o||{dx:0,dy:0}}function Ft(t){if(a.value.has(t))return`transform ${kt}ms ease-out`;if(K.value.has(t))return`transform ${wt}ms ease-out`}function _t(t){const n=p.value[t]?.id,l=ne.value[t]??{x:0,y:0},s=me.value[t]??0,m=s>0?s:Me.value,w=l.x,_=n&&q.value.has(n)?Ce(m):l.y,R=n?It(n):{dx:0,dy:0};return`translate3d(${w+R.dx}px,${_+R.dy}px,0)`}function pe(t){(typeof requestAnimationFrame=="function"?requestAnimationFrame:n=>setTimeout(()=>n(0),0))(()=>t())}function Tt(t){pe(()=>pe(t))}const Ge=new Set;function Ke(t){return typeof t=="number"&&Number.isFinite(t)&&t>0}function Te(t){if(!Array.isArray(t)||t.length===0)return;const o=new Set(q.value);let n=!1;for(const l of t){const s=l?.id;if(s){if(!Ge.has(s)){const m=l?.width,w=l?.height;(!Ke(m)||!Ke(w))&&(Ge.add(s),console.warn(`[Masonry] Item "${s}" has invalid dimensions (width=${String(m)}, height=${String(w)}); layout expects { id, width, height }.`))}o.has(s)||(o.add(s),n=!0)}}n&&(q.value=o)}function Je(){const t=new Map;for(const o of Ye.value){const l=p.value[o]?.id;if(!l)continue;const s=ne.value[o];s&&t.set(l,{x:s.x,y:s.y})}return t}function Qe(t,o){if(!t.size)return;const n=new Map,l=[];for(const[m,w]of t.entries()){if(o?.has(m))continue;const _=oe.value.get(m);if(_==null)continue;const R=ne.value[_];if(!R)continue;const V=w.x-R.x,I=w.y-R.y;(V||I)&&(n.set(m,{dx:V,dy:I}),l.push(m))}if(!n.size)return;_e.value=n;const s=new Set(K.value);for(const m of l)s.delete(m);K.value=s,pe(()=>{K.value=new Set([...K.value,...l]),pe(()=>{_e.value=new Map})}),setTimeout(()=>{const m=new Set(K.value);for(const w of l)m.delete(w);K.value=m},wt)}const le=e.ref(!0),re=e.ref(!1),ge=e.ref("");let C=0,He=0,Le=0;function Ze(t){return t instanceof Error&&t.name==="AbortError"}function et(){const t=new Error("aborted");return t.name="AbortError",t}function Nt(t){return new Promise(o=>setTimeout(o,t))}async function tt(t,o){let n=0;for(;;){if(o!==C)throw et();try{return await i.getContent(t)}catch(l){if(o!==C)throw et();if(n>=Sn)throw l;n+=1,await Nt(n*Mn)}}}const O=e.ref([]),nt=e.ref([]),$e=e.ref([]),A=e.ref(i.page),Ne=e.ref([]);let ae=null,se=null,Pe=0;function Pt(t){let o=-1;for(const n of t){const l=n?.originalIndex;Se(l)&&l>o&&(o=l)}Pe=o+1}function ye(t){for(const o of t)!o||typeof o!="object"||o.id&&o.originalIndex==null&&(o.originalIndex=Pe,Pe+=1)}const ie=new Map,ue=[];function Se(t){return typeof t=="number"&&Number.isFinite(t)}function Vt(t,o){if(!o.length)return t;const n=new Set;for(const w of t){const _=w?.id;_&&n.add(_)}const l=[];for(const w of o){const _=w?.id;_&&(n.has(_)||(l.push(w),n.add(_)))}if(!l.length)return t;const s=l.slice().sort((w,_)=>{const R=Se(w.originalIndex)?w.originalIndex:Number.POSITIVE_INFINITY,V=Se(_.originalIndex)?_.originalIndex:Number.POSITIVE_INFINITY;return R-V}),m=t.slice();for(const w of s){const _=w.originalIndex;if(!Se(_)){m.push(w);continue}let R=0,V=m.length;for(;R<V;){const I=R+V>>1,Q=m[I]?.originalIndex;(Se(Q)?Q:Number.POSITIVE_INFINITY)<=_?R=I+1:V=I}m.splice(R,0,w)}return m}async function ot(t){if(!t.length)return;Te(t);const o=Je();p.value=Vt(p.value,t),await e.nextTick(),Qe(o)}async function Rt(t){const n=(Array.isArray(t)?t:[t]).map(Oe).filter(Boolean);if(!n.length)return;const l=[];for(const s of n){const m=ie.get(s);m&&l.push(m)}if(l.length){await ot(l);for(const s of l)s?.id&&ie.delete(s.id)}}async function At(){const t=ue.pop();if(!t?.length)return;const o=[];for(const n of t){const l=ie.get(n);l&&o.push(l)}if(o.length){await ot(o);for(const n of o)n?.id&&ie.delete(n.id)}}function Ct(t){const n=(Array.isArray(t)?t:[t]).map(Oe).filter(Boolean);if(!n.length)return;const l=new Set(n);for(const s of l)ie.delete(s);for(let s=ue.length-1;s>=0;s-=1){const w=ue[s].filter(_=>!l.has(_));w.length?ue[s]=w:ue.splice(s,1)}}const De=e.shallowRef({enabled:!1,isBackfillActive:!1,isRequestInFlight:!1,requestPage:null,progress:{collected:0,target:0},cooldownMsRemaining:0,cooldownMsTotal:2e3,pageSize:20,bufferSize:0,lastBatch:null,totals:{pagesFetched:0,itemsFetchedFromNetwork:0}}),lt=an({getContent:t=>tt(t,C),markEnterFromLeft:Te,buffer:Ne,stats:De,isEnabled:()=>i.mode==="backfill",getPageSize:()=>i.pageSize,getRequestDelayMs:()=>i.backfillRequestDelayMs}),Ve=e.computed(()=>i.items!==void 0);e.watch(()=>i.items,t=>{Ve.value&&($e.value=Array.isArray(t)?t:[])},{immediate:!0});const p=e.computed({get(){return Ve.value?$e.value:nt.value},set(t){Ve.value?($e.value=t,d("update:items",t)):nt.value=t}}),we=e.ref(!1),qe=e.ref(!1);async function rt(t){const o=await tt(t,C);return ye(o.items),Te(o.items),{items:o.items,nextPage:o.nextPage}}function Oe(t){return t?typeof t=="string"?t:t?.id:null}async function at(t){const n=(Array.isArray(t)?t:[t]).map(Oe).filter(Boolean);if(!n.length)return;const l=new Set(n),s=[];for(const V of l){const I=oe.value.get(V);if(I==null)continue;const Q=p.value[I];Q&&(ie.set(V,Q),s.push(V))}s.length&&ue.push(s);const m=Je(),w=Me.value,_=Y.value+N.value,R=[];for(const V of l){const I=oe.value.get(V);if(I==null)continue;const Q=p.value[I];if(!Q)continue;const Ae=ne.value[I]??{x:0,y:0},mt=me.value[I]??w,Xt=Math.max(Ae.y,_);R.push({id:V,item:Q,fromX:Ae.x,fromY:Ae.y,toY:Xt+Math.max(0,mt),width:w,height:mt,leaving:!0})}if(R.length&&(J.value=[...J.value,...R]),p.value=p.value.filter(V=>{const I=V?.id;return!I||!l.has(I)}),await e.nextTick(),Qe(m,l),R.length){const V=new Set(R.map(I=>I.id));pe(()=>{J.value=J.value.map(I=>V.has(I.id)?{...I,leaving:!1}:I),setTimeout(()=>{J.value=J.value.filter(I=>!V.has(I.id))},bt)})}}async function Re(t){return at(t)}function zt(){C+=1,ae=null,se=null,le.value=!1,re.value=!1}x({remove:at,restore:Rt,undo:At,forget:Ct,loadNextPage:it,cancel:zt,get pagesLoaded(){return O.value},set pagesLoaded(t){O.value=t},get nextPage(){return A.value},set nextPage(t){A.value=t},get isLoading(){return le.value||re.value},get hasReachedEnd(){return i.mode!=="backfill"?A.value==null:A.value==null&&Ne.value.length===0},get backfillStats(){return De.value}});function st(){const t=sn({items:p.value,columnCount:je.value,columnWidth:Me.value,gapX:W.value,gapY:X.value,headerHeight:D.value,footerHeight:L.value,bucketPx:yt});ne.value=t.positions,me.value=t.heights,he.value=t.buckets,xe.value=t.contentHeight,oe.value=t.indexById}const Ht=e.computed(()=>Math.max(xe.value,N.value)+bn),Ye=e.computed(()=>un({itemCount:p.value.length,viewportHeight:N.value,scrollTop:Y.value,overscanPx:i.overscanPx,bucketPx:yt,buckets:he.value}));e.watch(Ye,t=>{if(!t?.length)return;if(we.value&&!qe.value){const l=[];for(const s of t){const m=p.value[s];m&&l.push(m)}l.length&&Te(l),qe.value=!0}const o=[];for(const l of t){const s=p.value[l]?.id;s&&q.value.has(s)&&(f.has(s)||(f.add(s),o.push(s)))}if(!o.length)return;const n=o.length>1?ze(i.enterStaggerMs):0;if(n>0){const l=new Map(z.value);for(let s=0;s<o.length;s+=1){const m=o[s],w=Math.min(s*n,xn);l.set(m,w)}z.value=l}pe(()=>{const l=new Set(a.value);for(const s of o)l.add(s);a.value=l}),Tt(()=>{const l=new Set(q.value);for(const s of o)l.delete(s);q.value=l,setTimeout(()=>{const s=new Set(a.value),m=new Map(z.value);for(const w of o)s.delete(w),f.delete(w),m.delete(w);a.value=s,z.value=m},kt)})},{flush:"post"});async function it(){if(ae)return ae;if(le.value||re.value||i.mode!=="backfill"&&A.value==null||i.mode==="backfill"&&A.value==null&&Ne.value.length===0)return;const t=C;let o=null;return o=(async()=>{try{if(re.value=!0,ge.value="",i.mode==="backfill"){const s=await lt.loadBackfillBatch(A.value);if(t!==C)return;s.pages.length&&(O.value=[...O.value,...s.pages]),ye(s.batchItems),p.value=[...p.value,...s.batchItems],A.value=s.nextPage;return}const n=A.value;if(n==null)return;const l=await rt(n);if(t!==C)return;O.value=[...O.value,n],ye(l.items),p.value=[...p.value,...l.items],A.value=l.nextPage}catch(n){if(t!==C||Ze(n))return;ge.value=n instanceof Error?n.message:String(n)}finally{t===C&&(re.value=!1),ae===o&&(ae=null)}})(),ae=o,o}function Lt(){const t=h.value;if(!t)return;const o=t.scrollTop,n=t.clientHeight,l=t.scrollHeight;Y.value=o,N.value=n;const s=He,m=Le,w=m>0&&l<m;if(He=o,Le=l,w&&o<=s)return;l-(o+n)<=i.prefetchThresholdPx&&it()}function ut(){return h.value}function ct(t){E.value=ee(t),N.value=t.clientHeight}function $t(){typeof ResizeObserver>"u"||(ke=new ResizeObserver(()=>{const t=ut();t&&ct(t)}))}function Dt(){return{enabled:i.mode==="backfill",isBackfillActive:!1,isRequestInFlight:!1,requestPage:null,progress:{collected:0,target:0},cooldownMsRemaining:0,cooldownMsTotal:Ue(i.backfillRequestDelayMs),pageSize:Mt(i.pageSize),bufferSize:0,lastBatch:null,totals:{pagesFetched:0,itemsFetchedFromNetwork:0}}}function ft(){C+=1,ae=null,se=null,He=0,Le=0,Pe=0,ie.clear(),ue.length=0,q.value=new Set,a.value=new Set,f.clear(),_e.value=new Map,K.value=new Set,J.value=[],O.value=[],A.value=null,Ne.value=[],De.value=Dt(),le.value=!0,re.value=!1,ge.value="",qe.value=!1}function dt(t){ft(),p.value=[],A.value=t}function qt(t){const o=Array.isArray(t)?t:[t],n=[],l=new Set;for(const s of o){if(s==null)continue;const m=typeof s=="string"?`s:${s}`:`n:${String(s)}`;l.has(m)||(l.add(m),n.push(s))}return n}function Xe(t){ft(),O.value=t?qt(t):[],A.value=i.page,le.value=!1,Pt(p.value),ye(p.value)}async function vt(t){if(se)return se;const o=C;let n=null;return n=(async()=>{try{if(i.mode==="backfill"){const l=await lt.loadBackfillBatch(t);if(o!==C)return;O.value=l.pages.length?l.pages:[t],ye(l.batchItems),p.value=l.batchItems,A.value=l.nextPage}else{const l=await rt(t);if(o!==C)return;O.value=[t],ye(l.items),p.value=l.items,A.value=l.nextPage}}catch(l){if(o!==C||Ze(l))return;ge.value=l instanceof Error?l.message:String(l)}finally{o===C&&(le.value=!1),se===n&&(se=null)}})(),se=n,n}function Ot(){const t=ut();t&&(ct(t),Y.value=t.scrollTop,ke?.observe(t))}e.onMounted(async()=>{if($t(),Ot(),i.restoredPages!=null){we.value=!0,Xe(i.restoredPages);return}if(Ve.value&&p.value.length>0){we.value=!0,Xe();return}we.value=!1,dt(i.page),await vt(i.page)}),e.onUnmounted(()=>{ke?.disconnect(),T&&(clearTimeout(T),T=null),M&&(clearTimeout(M),M=null),P(),F()}),e.watch(()=>i.page,async t=>{if(we.value){A.value=t;return}dt(t),await vt(t)}),e.watch(()=>i.restoredPages,t=>{t&&(we.value=!0,Xe(t))}),e.watch(W,()=>{const t=h.value;t&&(E.value=ee(t))},{immediate:!1});const je=e.computed(()=>on(E.value,i.itemWidth)),Me=e.computed(()=>ln(E.value,je.value,i.itemWidth,W.value));e.watch([je,Me,W,X,D,L],()=>{st()},{immediate:!0}),e.watch(()=>[p.value,p.value.length],()=>st(),{immediate:!0});const Yt=e.computed(()=>["mt-8 flex min-h-0 flex-1 flex-col rounded-2xl border border-slate-200/70 bg-white/70 p-5 shadow-sm backdrop-blur",b.class]);return(t,o)=>(e.openBlock(),e.createElementBlock("section",e.mergeProps(U.value,{class:Yt.value}),[e.createElementVNode("div",cn,[e.renderSlot(t.$slots,"default")]),e.createElementVNode("div",{ref_key:"scrollViewportRef",ref:h,"data-testid":"items-scroll-container",class:"mt-4 min-h-0 flex-1 overflow-auto",style:e.normalizeStyle({paddingRight:W.value+"px"}),onScroll:Lt},[le.value?(e.openBlock(),e.createElementBlock("div",fn,o[0]||(o[0]=[e.createElementVNode("div",{class:"inline-flex items-center gap-3 text-sm text-slate-600"},[e.createElementVNode("svg",{class:"h-5 w-5 animate-spin text-slate-500",viewBox:"0 0 24 24","aria-hidden":"true"},[e.createElementVNode("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",fill:"none",stroke:"currentColor","stroke-width":"4"}),e.createElementVNode("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 0 1 8-8v4a4 4 0 0 0-4 4H4z"})]),e.createElementVNode("span",null,"Loading…")],-1)]))):ge.value?(e.openBlock(),e.createElementBlock("p",dn,"Error: "+e.toDisplayString(ge.value),1)):(e.openBlock(),e.createElementBlock("div",{key:2,class:"relative",style:e.normalizeStyle({height:Ht.value+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Ye.value,n=>(e.openBlock(),e.createElementBlock("article",{key:p.value[n].id,"data-testid":"item-card",class:"absolute overflow-hidden rounded-xl border border-slate-200/60 bg-white shadow-sm",style:e.normalizeStyle({width:Me.value+"px",transition:Ft(p.value[n].id),transitionDelay:Fe(p.value[n].id),transform:_t(n)})},[fe.value||D.value>0?(e.openBlock(),e.createElementBlock("div",{key:0,"data-testid":"item-header-container",class:"w-full",style:e.normalizeStyle(Ee.value)},[e.createVNode(e.unref(k),{"slot-fn":G.value,"slot-props":{item:p.value[n],remove:()=>Re(p.value[n])}},null,8,["slot-fn","slot-props"])],4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"group relative",onMouseenter:l=>v(p.value[n].id),onMouseleave:l=>g(p.value[n].id)},[e.createVNode(pt,{item:p.value[n],remove:()=>Re(p.value[n]),"loader-slot-fn":te.value,"error-slot-fn":Be.value,hovered:y.value===p.value[n].id,onSuccess:H,onError:j},null,8,["item","remove","loader-slot-fn","error-slot-fn","hovered"]),ve.value?(e.openBlock(),e.createElementBlock("div",mn,[e.createVNode(e.unref(k),{"slot-fn":be.value,"slot-props":{item:p.value[n],remove:()=>Re(p.value[n])}},null,8,["slot-fn","slot-props"])])):e.createCommentVNode("",!0)],40,vn),de.value||L.value>0?(e.openBlock(),e.createElementBlock("div",{key:1,"data-testid":"item-footer-container",class:"w-full",style:e.normalizeStyle(Ie.value)},[e.createVNode(e.unref(k),{"slot-fn":ce.value,"slot-props":{item:p.value[n],remove:()=>Re(p.value[n])}},null,8,["slot-fn","slot-props"])],4)):e.createCommentVNode("",!0)],4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(J.value,n=>(e.openBlock(),e.createElementBlock("article",{key:n.id+":leaving","data-testid":"item-card-leaving",class:"pointer-events-none absolute overflow-hidden rounded-xl border border-slate-200/60 bg-white shadow-sm",style:e.normalizeStyle({width:n.width+"px",transition:"transform "+bt+"ms ease-out",transform:n.leaving?"translate3d("+n.fromX+"px,"+n.fromY+"px,0)":"translate3d("+n.fromX+"px,"+n.toY+"px,0)"})},[fe.value||D.value>0?(e.openBlock(),e.createElementBlock("div",{key:0,"data-testid":"item-header-container",class:"w-full",style:e.normalizeStyle(Ee.value)},[e.createVNode(e.unref(k),{"slot-fn":G.value,"slot-props":{item:n.item,remove:()=>{}}},null,8,["slot-fn","slot-props"])],4)):e.createCommentVNode("",!0),e.createElementVNode("div",hn,[e.createVNode(pt,{item:n.item,remove:()=>{},"loader-slot-fn":te.value,"error-slot-fn":Be.value,hovered:!1},null,8,["item","loader-slot-fn","error-slot-fn"]),ve.value?(e.openBlock(),e.createElementBlock("div",pn,[e.createVNode(e.unref(k),{"slot-fn":be.value,"slot-props":{item:n.item,remove:()=>{}}},null,8,["slot-fn","slot-props"])])):e.createCommentVNode("",!0)]),de.value||L.value>0?(e.openBlock(),e.createElementBlock("div",{key:1,"data-testid":"item-footer-container",class:"w-full",style:e.normalizeStyle(Ie.value)},[e.createVNode(e.unref(k),{"slot-fn":ce.value,"slot-props":{item:n.item,remove:()=>{}}},null,8,["slot-fn","slot-props"])],4)):e.createCommentVNode("",!0)],4))),128))],4)),e.createElementVNode("div",gn,[re.value?(e.openBlock(),e.createElementBlock("span",yn,o[1]||(o[1]=[e.createElementVNode("svg",{class:"h-4 w-4 animate-spin text-slate-500",viewBox:"0 0 24 24","aria-hidden":"true"},[e.createElementVNode("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",fill:"none",stroke:"currentColor","stroke-width":"4"}),e.createElementVNode("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 0 1 8-8v4a4 4 0 0 0-4 4H4z"})],-1),e.createElementVNode("span",null,"Loading more…",-1)]))):A.value==null?(e.openBlock(),e.createElementBlock("span",wn,"End of list")):(e.openBlock(),e.createElementBlock("span",kn,"Scroll to load page "+e.toDisplayString(A.value),1))])],36)],16))}}),Et=e.defineComponent({name:"MasonryItem",setup(r,{slots:x,attrs:u}){const i=e.inject(St,null);if(!i)return()=>null;const d=u.onPreloaded,b=u.onFailed,k=x.overlay,c=x.default;return i({header:x.header,loader:x.loader,overlay:k??c,error:x.error,footer:x.footer,onPreloaded:typeof d=="function"?d:Array.isArray(d)?y=>{for(const v of d)typeof v=="function"&&v(y)}:void 0,onFailed:typeof b=="function"?b:Array.isArray(b)?y=>{for(const v of b)typeof v=="function"&&v(y)}:void 0}),()=>null}}),Bn={install(r){r.component("Masonry",Bt),r.component("MasonryItem",Et),r.component("MasonryVideoControls",We)}};exports.Masonry=Bt;exports.MasonryItem=Et;exports.MasonryVideoControls=We;exports.VibePlugin=Bn;exports.masonryDefaults=xt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),yt={mode:"default",pageSize:20,backfillRequestDelayMs:2e3,enterStaggerMs:40,page:1,itemWidth:300,prefetchThresholdPx:200,gapX:16,gapY:16,headerHeight:0,footerHeight:0,overscanPx:600},Xt=["aria-label","aria-valuemax","aria-valuenow"],De=e.defineComponent({__name:"MasonryVideoControls",props:{currentTime:{},duration:{},ariaLabel:{default:"Seek"},step:{default:.1},keyboardStep:{default:5}},emits:["seek"],setup(r,{expose:x,emit:u}){const s=r,d=u,w=e.ref(null),k=e.ref(null),c=e.ref(null),v=e.ref(!1),p=e.computed(()=>Number.isFinite(s.step)?Math.max(0,s.step):0),g=e.computed(()=>Number.isFinite(s.duration)?Math.max(0,s.duration):0),E=e.computed(()=>{const f=Number.isFinite(s.currentTime)?s.currentTime:0;return N(f,0,g.value)}),B=e.computed(()=>g.value>0?E.value/g.value:0);function N(f,S,F){return Math.min(F,Math.max(S,f))}function I(f){return p.value<=0?f:Math.round(f/p.value)*p.value}function R(f){const S=N(f,0,g.value);d("seek",I(S))}function V(f){const S=k.value;if(!S)return;const F=S.getBoundingClientRect();if(!F.width)return;const L=N((f-F.left)/F.width,0,1);R(L*g.value)}function Y(f){const S=k.value;S&&(v.value=!0,S.setPointerCapture&&S.setPointerCapture(f.pointerId),V(f.clientX))}function H(f){v.value&&V(f.clientX)}function z(f){if(!v.value)return;v.value=!1;const S=k.value;S?.releasePointerCapture&&S.releasePointerCapture(f.pointerId)}function G(f){if(g.value<=0)return;const S=Number.isFinite(s.keyboardStep)?s.keyboardStep:1;let F=E.value;switch(f.key){case"ArrowLeft":case"ArrowDown":F-=S;break;case"ArrowRight":case"ArrowUp":F+=S;break;case"Home":F=0;break;case"End":F=g.value;break;default:return}f.preventDefault(),R(F)}function K(){w.value?.focus()}return x({focus:K,seekTo:R,percent:B,currentValue:E,maxValue:g,isDragging:v,rootEl:w,trackEl:k,thumbEl:c}),(f,S)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootEl",ref:w,class:"w-full select-none",role:"slider",tabindex:"0","aria-label":s.ariaLabel,"aria-valuemin":0,"aria-valuemax":g.value,"aria-valuenow":E.value,onKeydown:G},[e.createElementVNode("div",{ref_key:"trackEl",ref:k,class:"relative h-2 w-full cursor-pointer rounded-full bg-slate-200",onPointerdown:Y,onPointermove:H,onPointerup:z,onPointercancel:z,onPointerleave:z},[e.createElementVNode("div",{class:"absolute inset-y-0 left-0 rounded-full bg-slate-500",style:e.normalizeStyle({width:`${B.value*100}%`})},null,4),e.createElementVNode("div",{ref_key:"thumbEl",ref:c,class:"absolute top-1/2 h-3 w-3 -translate-x-1/2 -translate-y-1/2 rounded-full bg-slate-700 shadow",style:e.normalizeStyle({left:`${B.value*100}%`}),"aria-hidden":"true"},null,4)],544)],40,Xt))}}),jt={key:0,"data-testid":"masonry-loader-spinner",class:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-1"},Ut={key:1,class:"h-5 w-5 animate-spin text-slate-500",viewBox:"0 0 24 24","aria-hidden":"true"},Wt={key:1,"data-testid":"masonry-loader-error",class:"absolute inset-0 z-20 grid place-items-center p-3 pointer-events-none"},Gt={class:"pointer-events-auto flex flex-col items-center justify-center gap-2"},Kt={key:1,class:"text-center text-xs font-medium text-red-700"},Jt=["src","width","height","alt"],Qt=["poster"],Zt=["src"],en={key:4,class:"pointer-events-none absolute inset-x-0 bottom-0 z-20 px-2 pb-2 opacity-0 transition-opacity duration-200 group-hover:pointer-events-auto group-hover:opacity-100"},dt=e.defineComponent({__name:"MasonryLoader",props:{item:{},remove:{},loaderSlotFn:{},errorSlotFn:{},hovered:{type:Boolean,default:!1}},emits:["success","error"],setup(r,{emit:x}){const u=r,s=x,d=e.defineComponent({name:"SlotRenderer",props:{slotFn:{type:Function,required:!1},slotProps:{type:Object,required:!0}},setup(i){return()=>{const b=i.slotFn;return b?b(i.slotProps):null}}}),w=e.ref(null),k=e.ref(null),c=e.ref(null),v=e.ref(!1),p=e.ref(!1),g=e.ref(!1),E=e.ref(null),B=e.computed(()=>u.item?.type==="video"),N=e.computed(()=>{if(!B.value)return;const i=u.item?.preview,b=u.item?.original;if(!(typeof i!="string"||!i)&&!(typeof b=="string"&&i===b)&&!/\.(mp4|webm)(\?|#|$)/i.test(i))return i}),I=e.computed(()=>{if(!B.value)return;const i=u.item?.preview;if(typeof i=="string"&&i&&/\.(mp4|webm)(\?|#|$)/i.test(i))return i;const b=u.item?.original;if(typeof b=="string"&&b)return b}),R=e.ref(!1),V=e.computed(()=>!!u.hovered),Y=e.ref(0),H=e.ref(0);function z(){u.remove?.()}const G=e.computed(()=>{const i=u.item?.width,b=u.item?.height;return{aspectRatio:`${i} / ${b}`}}),K=e.computed(()=>u.item?.type==="image");let f=null,S=null;function F(){v.value||(v.value=!0,p.value=!1,g.value=!1,E.value=null)}function L(i){Y.value=Number.isFinite(i.duration)?i.duration:0,H.value=Number.isFinite(i.currentTime)?i.currentTime:0}async function J(){if(!B.value||!V.value||!v.value||!p.value||!R.value)return;const i=c.value;if(i)try{i.muted=!0,await i.play()}catch{}}function X(){const i=c.value;i&&(i.paused||i.pause())}function ge(){const i=c.value;i&&(i.paused||i.pause())}e.watch(()=>u.hovered,i=>{if(i){F(),J();return}X()});function ye(i){const b=c.value;b&&Number.isFinite(i)&&(b.currentTime=Math.max(0,Math.min(i,Number.isFinite(b.duration)?b.duration:i)),L(b))}e.onMounted(()=>{if(typeof IntersectionObserver>"u"){F();return}if(f=new IntersectionObserver(i=>{for(const b of i)if(b.isIntersecting&&!((b.intersectionRatio??0)<.5)){F(),f?.disconnect(),f=null;return}},{threshold:[0,.5,1]}),w.value&&f.observe(w.value),B.value&&w.value){const i=w.value.closest('[data-testid="items-scroll-container"]');S=new IntersectionObserver(b=>{for(const O of b){const we=O.intersectionRatio??0,de=!!O.isIntersecting&&we>=.5;R.value=de,de?V.value&&J():ge()}},{root:i??void 0,threshold:[0,.25,.5,.75,1]}),S.observe(w.value)}}),e.onUnmounted(()=>{f?.disconnect(),f=null,S?.disconnect(),S=null});function $(){p.value||(p.value=!0,g.value=!1,E.value=null,s("success",u.item))}function q(i){g.value||(p.value=!1,g.value=!0,E.value=i,s("error",{item:u.item,error:i}))}function fe(){$();const i=c.value;i&&L(i),J()}function ae(){const i=c.value;i&&L(i)}return(i,b)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootEl",ref:w,class:"relative bg-slate-100",style:e.normalizeStyle(G.value)},[v.value&&!p.value&&!g.value?(e.openBlock(),e.createElementBlock("div",jt,[u.loaderSlotFn?(e.openBlock(),e.createBlock(e.unref(d),{key:0,"slot-fn":u.loaderSlotFn,"slot-props":{item:u.item,remove:z}},null,8,["slot-fn","slot-props"])):(e.openBlock(),e.createElementBlock("svg",Ut,b[2]||(b[2]=[e.createElementVNode("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",fill:"none",stroke:"currentColor","stroke-width":"4"},null,-1),e.createElementVNode("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 0 1 8-8v4a4 4 0 0 0-4 4H4z"},null,-1)])))])):v.value&&g.value?(e.openBlock(),e.createElementBlock("div",Wt,[e.createElementVNode("div",Gt,[u.errorSlotFn?(e.openBlock(),e.createBlock(e.unref(d),{key:0,"slot-fn":u.errorSlotFn,"slot-props":{item:u.item,remove:z,error:E.value}},null,8,["slot-fn","slot-props"])):(e.openBlock(),e.createElementBlock("p",Kt,"Error "+e.toDisplayString(E.value),1))])])):e.createCommentVNode("",!0),v.value&&K.value&&!g.value?(e.openBlock(),e.createElementBlock("img",{key:u.item.id+":img",ref_key:"imgEl",ref:k,class:e.normalizeClass(["h-full w-full object-cover transition-opacity duration-300",p.value?"opacity-100":"opacity-0"]),src:u.item.preview,width:u.item.width,height:u.item.height,loading:"lazy",alt:u.item.id,onLoad:$,onError:b[0]||(b[0]=O=>q(O))},null,42,Jt)):v.value&&!g.value?(e.openBlock(),e.createElementBlock("video",{key:u.item.id+":vid",class:e.normalizeClass(["h-full w-full object-cover transition-opacity duration-300",p.value?"opacity-100":"opacity-0"]),poster:N.value,ref_key:"videoEl",ref:c,playsinline:"",loop:"",preload:"metadata",onLoadedmetadata:fe,onTimeupdate:ae,onDurationchange:ae,onLoadeddata:ae,onError:b[1]||(b[1]=O=>q(O))},[e.createElementVNode("source",{src:I.value,type:"video/mp4"},null,8,Zt)],42,Qt)):e.createCommentVNode("",!0),v.value&&B.value&&!g.value?(e.openBlock(),e.createElementBlock("div",en,[e.createVNode(De,{duration:Y.value,"current-time":H.value,onSeek:ye},null,8,["duration","current-time"])])):e.createCommentVNode("",!0)],4))}}),wt=Symbol("masonryItemRegistry");function tn(r,x){return!r||r<=0||!x||x<=0?1:Math.max(1,Math.floor(r/x))}function nn(r,x,u,s=0){if(!r||r<=0||!x||x<=0)return u;const d=typeof s=="number"&&s>0?s:0,w=Math.max(0,x-1)*d,k=r-w;return!k||k<=0?u:k/x}function on(r,x){const u=r?.width,s=r?.height;return typeof u=="number"&&typeof s=="number"&&u>0&&s>0?s/u*x:x}function kt(r){return Number.isFinite(r)&&r>0?Math.floor(r):1}function Le(r){return Number.isFinite(r)&&r>0?Math.floor(r):0}function ln(r){async function x(s){const d=Le(s);if(d<=0)return;r.stats.value={...r.stats.value,cooldownMsTotal:d,cooldownMsRemaining:d};const w=Date.now(),k=100;await new Promise(c=>{const v=setInterval(()=>{const p=Date.now()-w,g=Math.max(0,d-p);r.stats.value={...r.stats.value,cooldownMsTotal:d,cooldownMsRemaining:g},g<=0&&(clearInterval(v),c())},k)})}async function u(s){const d=kt(r.getPageSize()),w=r.isEnabled(),k=Le(r.getRequestDelayMs()),c=[];let v=0;r.buffer.value.length&&(v=r.buffer.value.length,c.push(...r.buffer.value),r.buffer.value=[]),r.stats.value={...r.stats.value,enabled:w,isBackfillActive:!1,isRequestInFlight:!1,requestPage:null,cooldownMsTotal:k,cooldownMsRemaining:0,progress:{collected:0,target:0},pageSize:d,bufferSize:0};const p=[];let g=s,E=0,B=!1;for(;c.length<d&&g!=null;){const R=g;B&&(r.stats.value={...r.stats.value,enabled:w,isBackfillActive:!0,isRequestInFlight:!0,requestPage:R,progress:{collected:Math.min(c.length,d),target:d},cooldownMsTotal:k,cooldownMsRemaining:0,pageSize:d});const V=await r.getContent(R);p.push(R),B&&(r.stats.value={...r.stats.value,enabled:w,isBackfillActive:!0,isRequestInFlight:!1,requestPage:null}),E+=V.items.length,r.markEnterFromLeft(V.items),c.push(...V.items),g=V.nextPage,!B&&c.length<d&&g!=null?(B=!0,r.stats.value={...r.stats.value,enabled:w,isBackfillActive:!0,isRequestInFlight:!1,requestPage:null,progress:{collected:Math.min(c.length,d),target:d},cooldownMsTotal:k,cooldownMsRemaining:0,pageSize:d}):B&&(r.stats.value={...r.stats.value,enabled:w,isBackfillActive:!0,progress:{collected:Math.min(c.length,d),target:d}}),B&&c.length<d&&g!=null&&await x(k)}const N=c.slice(0,d),I=c.slice(d);return r.buffer.value=I,r.stats.value={...r.stats.value,enabled:w,isBackfillActive:!1,isRequestInFlight:!1,requestPage:null,progress:{collected:0,target:0},cooldownMsTotal:k,cooldownMsRemaining:0,pageSize:d,bufferSize:I.length,lastBatch:{startPage:s,pages:p,usedFromBuffer:v,fetchedFromNetwork:E,collectedTotal:c.length,emitted:N.length,carried:I.length},totals:{pagesFetched:r.stats.value.totals.pagesFetched+p.length,itemsFetchedFromNetwork:r.stats.value.totals.itemsFetchedFromNetwork+E}},{batchItems:N,pages:p,nextPage:g}}return{loadBackfillBatch:u}}function rn(r){const x=r.columnCount,u=r.columnWidth,s=r.gapX,d=r.gapY,w=r.headerHeight,k=r.footerHeight,c=r.bucketPx,v=Array.from({length:x},()=>0),p=new Array(r.items.length),g=new Array(r.items.length),E=new Map,B=new Map;let N=0;for(let I=0;I<r.items.length;I+=1){const R=r.items[I];R?.id&&B.set(R.id,I);let V=0;for(let f=1;f<v.length;f+=1)v[f]<v[V]&&(V=f);const Y=V*(u+s),H=v[V],z=on(R,u)+w+k;p[I]={x:Y,y:H},g[I]=z,v[V]=H+z+d,N=Math.max(N,H+z);const G=Math.floor(H/c),K=Math.floor((H+z)/c);for(let f=G;f<=K;f+=1){const S=E.get(f);S?S.push(I):E.set(f,[I])}}return{positions:p,heights:g,buckets:E,contentHeight:N,indexById:B}}function an(r){const x=r.itemCount;if(!x)return[];if(r.viewportHeight<=0)return Array.from({length:x},(v,p)=>p);const u=Math.max(0,r.scrollTop-r.overscanPx),s=r.scrollTop+r.viewportHeight+r.overscanPx,d=Math.floor(u/r.bucketPx),w=Math.floor(s/r.bucketPx),k=new Set;for(let v=d;v<=w;v+=1){const p=r.buckets.get(v);if(p)for(const g of p)k.add(g)}const c=Array.from(k);return c.sort((v,p)=>v-p),c}const sn={class:"hidden"},un={key:0,class:"flex h-full items-center justify-center"},cn={key:1,class:"text-sm font-medium text-red-700"},fn=["onMouseenter","onMouseleave"],dn={key:0,class:"pointer-events-auto absolute inset-0 z-10"},vn={class:"relative"},mn={key:0,class:"pointer-events-auto absolute inset-0 z-10"},hn={class:"mt-4 pb-2 text-center text-xs text-slate-600"},pn={key:0,class:"inline-flex items-center justify-center gap-2"},gn={key:1},yn={key:2},vt=100,wn=200,mt=600,ht=300,pt=600,gt=600,kn=400,bn=5,xn=1e3,bt=e.defineComponent({inheritAttrs:!1,__name:"Masonry",props:e.mergeDefaults({getContent:{},mode:{},pageSize:{},backfillRequestDelayMs:{},enterStaggerMs:{},items:{},page:{},restoredPages:{},itemWidth:{},prefetchThresholdPx:{},gapX:{},gapY:{},headerHeight:{},footerHeight:{},overscanPx:{}},yt),emits:["update:items","preloaded","failures"],setup(r,{expose:x,emit:u}){const s=r,d=u,w=e.useAttrs(),k=e.defineComponent({name:"SlotRenderer",props:{slotFn:{type:Function,required:!1},slotProps:{type:Object,required:!0}},setup(t){return()=>{const o=t.slotFn;return o?o(t.slotProps):null}}}),c=e.shallowRef(null),v=e.ref(null);function p(t){v.value=t}function g(t){v.value===t&&(v.value=null)}e.provide(wt,t=>{c.value||(c.value=t)});const E=[],B=[];let N=null,I=null;function R(){if(!E.length)return;const t=E.splice(0,E.length);d("preloaded",t)}function V(){if(!B.length)return;const t=B.splice(0,B.length);d("failures",t)}function Y(){N||(N=setTimeout(()=>{N=null,R()},vt))}function H(){I||(I=setTimeout(()=>{I=null,V()},vt))}function z(t){c.value?.onPreloaded?.(t),E.push(t),Y()}function G(t){c.value?.onFailed?.(t),B.push(t),H()}e.onMounted(()=>{if(!c.value)throw new Error("[Masonry] Missing <MasonryItem> definition. Add <MasonryItem> as a child of <Masonry>.")});const K=e.computed(()=>{const{class:t,...o}=w;return o}),f=e.ref(null),S=e.ref(0),F=e.ref(0),L=e.ref(0);let J;const X=e.computed(()=>s.gapX),ge=e.computed(()=>s.gapY);function ye(t){if(!t)return 0;const o=Math.max(0,X.value);return Math.max(0,t.clientWidth-o)}const $=e.computed(()=>s.headerHeight),q=e.computed(()=>s.footerHeight),fe=e.computed(()=>c.value?.header),ae=e.computed(()=>c.value?.loader),i=e.computed(()=>c.value?.footer),b=e.computed(()=>c.value?.overlay),O=e.computed(()=>c.value?.error),we=e.computed(()=>!!fe.value),de=e.computed(()=>!!i.value),$e=e.computed(()=>!!b.value),qe=e.computed(()=>{if($.value>0)return{height:`${$.value}px`}}),Oe=e.computed(()=>{if(q.value>0)return{height:`${q.value}px`}}),ve=e.ref([]),Pe=e.ref([]),Ye=e.ref(new Map),Xe=e.ref(0),ke=e.ref(new Map);function St(t){const o=typeof t=="number"&&Number.isFinite(t)?t:0;return L.value+F.value+Math.max(0,o)}const Q=e.ref(new Set),Z=e.ref(new Set),be=new Set,me=e.ref(new Map);function Mt(t){return Number.isFinite(t)?Math.max(0,Math.min(250,t)):0}function Bt(t){if(!Z.value.has(t))return;const o=me.value.get(t)??0;if(!(o<=0))return`${o}ms`}const xe=e.ref(new Map),j=e.ref(new Set),U=e.ref([]);function Et(t){const o=xe.value.get(t);return o||{dx:0,dy:0}}function It(t){if(Z.value.has(t))return`transform ${pt}ms ease-out`;if(j.value.has(t))return`transform ${ht}ms ease-out`}function Ft(t){const n=h.value[t]?.id,l=ve.value[t]??{x:0,y:0},a=Pe.value[t]??0,m=a>0?a:pe.value,y=l.x,P=n&&Q.value.has(n)?St(m):l.y,T=n?Et(n):{dx:0,dy:0};return`translate3d(${y+T.dx}px,${P+T.dy}px,0)`}function se(t){(typeof requestAnimationFrame=="function"?requestAnimationFrame:n=>setTimeout(()=>n(0),0))(()=>t())}function Pt(t){se(()=>se(t))}const je=new Set;function Ue(t){return typeof t=="number"&&Number.isFinite(t)&&t>0}function Se(t){if(!Array.isArray(t)||t.length===0)return;const o=new Set(Q.value);let n=!1;for(const l of t){const a=l?.id;if(a){if(!je.has(a)){const m=l?.width,y=l?.height;(!Ue(m)||!Ue(y))&&(je.add(a),console.warn(`[Masonry] Item "${a}" has invalid dimensions (width=${String(m)}, height=${String(y)}); layout expects { id, width, height }.`))}o.has(a)||(o.add(a),n=!0)}}n&&(Q.value=o)}function We(){const t=new Map;for(const o of Ae.value){const l=h.value[o]?.id;if(!l)continue;const a=ve.value[o];a&&t.set(l,{x:a.x,y:a.y})}return t}function Ge(t,o){if(!t.size)return;const n=new Map,l=[];for(const[m,y]of t.entries()){if(o?.has(m))continue;const P=ke.value.get(m);if(P==null)continue;const T=ve.value[P];if(!T)continue;const _=y.x-T.x,M=y.y-T.y;(_||M)&&(n.set(m,{dx:_,dy:M}),l.push(m))}if(!n.size)return;xe.value=n;const a=new Set(j.value);for(const m of l)a.delete(m);j.value=a,se(()=>{j.value=new Set([...j.value,...l]),se(()=>{xe.value=new Map})}),setTimeout(()=>{const m=new Set(j.value);for(const y of l)m.delete(y);j.value=m},ht)}const ee=e.ref(!0),te=e.ref(!1),ie=e.ref("");let A=0,_e=0,Ne=0;function Ke(t){return t instanceof Error&&t.name==="AbortError"}function Je(){const t=new Error("aborted");return t.name="AbortError",t}function _t(t){return new Promise(o=>setTimeout(o,t))}async function Qe(t,o){let n=0;for(;;){if(o!==A)throw Je();try{return await s.getContent(t)}catch(l){if(o!==A)throw Je();if(n>=bn)throw l;n+=1,await _t(n*xn)}}}const D=e.ref([]),Ze=e.ref([]),Ve=e.ref([]),C=e.ref(s.page),Me=e.ref([]);let ne=null,oe=null,Be=0;function Nt(t){let o=-1;for(const n of t){const l=n?.originalIndex;he(l)&&l>o&&(o=l)}Be=o+1}function ue(t){for(const o of t)!o||typeof o!="object"||o.id&&o.originalIndex==null&&(o.originalIndex=Be,Be+=1)}const le=new Map,re=[];function he(t){return typeof t=="number"&&Number.isFinite(t)}function Vt(t,o){if(!o.length)return t;const n=new Set;for(const y of t){const P=y?.id;P&&n.add(P)}const l=[];for(const y of o){const P=y?.id;P&&(n.has(P)||(l.push(y),n.add(P)))}if(!l.length)return t;const a=l.slice().sort((y,P)=>{const T=he(y.originalIndex)?y.originalIndex:Number.POSITIVE_INFINITY,_=he(P.originalIndex)?P.originalIndex:Number.POSITIVE_INFINITY;return T-_}),m=t.slice();for(const y of a){const P=y.originalIndex;if(!he(P)){m.push(y);continue}let T=0,_=m.length;for(;T<_;){const M=T+_>>1,W=m[M]?.originalIndex;(he(W)?W:Number.POSITIVE_INFINITY)<=P?T=M+1:_=M}m.splice(T,0,y)}return m}async function et(t){if(!t.length)return;Se(t);const o=We();h.value=Vt(h.value,t),await e.nextTick(),Ge(o)}async function Tt(t){const n=(Array.isArray(t)?t:[t]).map(Re).filter(Boolean);if(!n.length)return;const l=[];for(const a of n){const m=le.get(a);m&&l.push(m)}if(l.length){await et(l);for(const a of l)a?.id&&le.delete(a.id)}}async function Ct(){const t=re.pop();if(!t?.length)return;const o=[];for(const n of t){const l=le.get(n);l&&o.push(l)}if(o.length){await et(o);for(const n of o)n?.id&&le.delete(n.id)}}function Rt(t){const n=(Array.isArray(t)?t:[t]).map(Re).filter(Boolean);if(!n.length)return;const l=new Set(n);for(const a of l)le.delete(a);for(let a=re.length-1;a>=0;a-=1){const y=re[a].filter(P=>!l.has(P));y.length?re[a]=y:re.splice(a,1)}}const Te=e.shallowRef({enabled:!1,isBackfillActive:!1,isRequestInFlight:!1,requestPage:null,progress:{collected:0,target:0},cooldownMsRemaining:0,cooldownMsTotal:2e3,pageSize:20,bufferSize:0,lastBatch:null,totals:{pagesFetched:0,itemsFetchedFromNetwork:0}}),tt=ln({getContent:t=>Qe(t,A),markEnterFromLeft:Se,buffer:Me,stats:Te,isEnabled:()=>s.mode==="backfill",getPageSize:()=>s.pageSize,getRequestDelayMs:()=>s.backfillRequestDelayMs}),Ee=e.computed(()=>s.items!==void 0);e.watch(()=>s.items,t=>{Ee.value&&(Ve.value=Array.isArray(t)?t:[])},{immediate:!0});const h=e.computed({get(){return Ee.value?Ve.value:Ze.value},set(t){Ee.value?(Ve.value=t,d("update:items",t)):Ze.value=t}}),ce=e.ref(!1),Ce=e.ref(!1);async function nt(t){const o=await Qe(t,A);return ue(o.items),Se(o.items),{items:o.items,nextPage:o.nextPage}}function Re(t){return t?typeof t=="string"?t:t?.id:null}async function ot(t){const n=(Array.isArray(t)?t:[t]).map(Re).filter(Boolean);if(!n.length)return;const l=new Set(n),a=[];for(const _ of l){const M=ke.value.get(_);if(M==null)continue;const W=h.value[M];W&&(le.set(_,W),a.push(_))}a.length&&re.push(a);const m=We(),y=pe.value,P=L.value+F.value,T=[];for(const _ of l){const M=ke.value.get(_);if(M==null)continue;const W=h.value[M];if(!W)continue;const Fe=ve.value[M]??{x:0,y:0},ft=Pe.value[M]??y,Yt=Math.max(Fe.y,P);T.push({id:_,item:W,fromX:Fe.x,fromY:Fe.y,toY:Yt+Math.max(0,ft),width:y,height:ft,leaving:!0})}if(T.length&&(U.value=[...U.value,...T]),h.value=h.value.filter(_=>{const M=_?.id;return!M||!l.has(M)}),await e.nextTick(),Ge(m,l),T.length){const _=new Set(T.map(M=>M.id));se(()=>{U.value=U.value.map(M=>_.has(M.id)?{...M,leaving:!1}:M),setTimeout(()=>{U.value=U.value.filter(M=>!_.has(M.id))},gt)})}}async function Ie(t){return ot(t)}function At(){A+=1,ne=null,oe=null,ee.value=!1,te.value=!1}x({remove:ot,restore:Tt,undo:Ct,forget:Rt,loadNextPage:rt,cancel:At,get pagesLoaded(){return D.value},set pagesLoaded(t){D.value=t},get nextPage(){return C.value},set nextPage(t){C.value=t},get isLoading(){return ee.value||te.value},get hasReachedEnd(){return s.mode!=="backfill"?C.value==null:C.value==null&&Me.value.length===0},get backfillStats(){return Te.value}});function lt(){const t=rn({items:h.value,columnCount:He.value,columnWidth:pe.value,gapX:X.value,gapY:ge.value,headerHeight:$.value,footerHeight:q.value,bucketPx:mt});ve.value=t.positions,Pe.value=t.heights,Ye.value=t.buckets,Xe.value=t.contentHeight,ke.value=t.indexById}const zt=e.computed(()=>Math.max(Xe.value,F.value)+wn),Ae=e.computed(()=>an({itemCount:h.value.length,viewportHeight:F.value,scrollTop:L.value,overscanPx:s.overscanPx,bucketPx:mt,buckets:Ye.value}));e.watch(Ae,t=>{if(!t?.length)return;if(ce.value&&!Ce.value){const l=[];for(const a of t){const m=h.value[a];m&&l.push(m)}l.length&&Se(l),Ce.value=!0}const o=[];for(const l of t){const a=h.value[l]?.id;a&&Q.value.has(a)&&(be.has(a)||(be.add(a),o.push(a)))}if(!o.length)return;const n=o.length>1?Mt(s.enterStaggerMs):0;if(n>0){const l=new Map(me.value);for(let a=0;a<o.length;a+=1){const m=o[a],y=Math.min(a*n,kn);l.set(m,y)}me.value=l}se(()=>{const l=new Set(Z.value);for(const a of o)l.add(a);Z.value=l}),Pt(()=>{const l=new Set(Q.value);for(const a of o)l.delete(a);Q.value=l,setTimeout(()=>{const a=new Set(Z.value),m=new Map(me.value);for(const y of o)a.delete(y),be.delete(y),m.delete(y);Z.value=a,me.value=m},pt)})},{flush:"post"});async function rt(){if(ne)return ne;if(ee.value||te.value||s.mode!=="backfill"&&C.value==null||s.mode==="backfill"&&C.value==null&&Me.value.length===0)return;const t=A;let o=null;return o=(async()=>{try{if(te.value=!0,ie.value="",s.mode==="backfill"){const a=await tt.loadBackfillBatch(C.value);if(t!==A)return;a.pages.length&&(D.value=[...D.value,...a.pages]),ue(a.batchItems),h.value=[...h.value,...a.batchItems],C.value=a.nextPage;return}const n=C.value;if(n==null)return;const l=await nt(n);if(t!==A)return;D.value=[...D.value,n],ue(l.items),h.value=[...h.value,...l.items],C.value=l.nextPage}catch(n){if(t!==A||Ke(n))return;ie.value=n instanceof Error?n.message:String(n)}finally{t===A&&(te.value=!1),ne===o&&(ne=null)}})(),ne=o,o}function Ht(){const t=f.value;if(!t)return;const o=t.scrollTop,n=t.clientHeight,l=t.scrollHeight;L.value=o,F.value=n;const a=_e,m=Ne,y=m>0&&l<m;if(_e=o,Ne=l,y&&o<=a)return;l-(o+n)<=s.prefetchThresholdPx&&rt()}function at(){return f.value}function st(t){S.value=ye(t),F.value=t.clientHeight}function Lt(){typeof ResizeObserver>"u"||(J=new ResizeObserver(()=>{const t=at();t&&st(t)}))}function Dt(){return{enabled:s.mode==="backfill",isBackfillActive:!1,isRequestInFlight:!1,requestPage:null,progress:{collected:0,target:0},cooldownMsRemaining:0,cooldownMsTotal:Le(s.backfillRequestDelayMs),pageSize:kt(s.pageSize),bufferSize:0,lastBatch:null,totals:{pagesFetched:0,itemsFetchedFromNetwork:0}}}function it(){A+=1,ne=null,oe=null,_e=0,Ne=0,Be=0,le.clear(),re.length=0,Q.value=new Set,Z.value=new Set,be.clear(),xe.value=new Map,j.value=new Set,U.value=[],D.value=[],C.value=null,Me.value=[],Te.value=Dt(),ee.value=!0,te.value=!1,ie.value="",Ce.value=!1}function ut(t){it(),h.value=[],C.value=t}function $t(t){const o=Array.isArray(t)?t:[t],n=[],l=new Set;for(const a of o){if(a==null)continue;const m=typeof a=="string"?`s:${a}`:`n:${String(a)}`;l.has(m)||(l.add(m),n.push(a))}return n}function ze(t){it(),D.value=t?$t(t):[],C.value=s.page,ee.value=!1,Nt(h.value),ue(h.value)}async function ct(t){if(oe)return oe;const o=A;let n=null;return n=(async()=>{try{if(s.mode==="backfill"){const l=await tt.loadBackfillBatch(t);if(o!==A)return;D.value=l.pages.length?l.pages:[t],ue(l.batchItems),h.value=l.batchItems,C.value=l.nextPage}else{const l=await nt(t);if(o!==A)return;D.value=[t],ue(l.items),h.value=l.items,C.value=l.nextPage}}catch(l){if(o!==A||Ke(l))return;ie.value=l instanceof Error?l.message:String(l)}finally{o===A&&(ee.value=!1),oe===n&&(oe=null)}})(),oe=n,n}function qt(){const t=at();t&&(st(t),L.value=t.scrollTop,J?.observe(t))}e.onMounted(async()=>{if(Lt(),qt(),s.restoredPages!=null){ce.value=!0,ze(s.restoredPages);return}if(Ee.value&&h.value.length>0){ce.value=!0,ze();return}ce.value=!1,ut(s.page),await ct(s.page)}),e.onUnmounted(()=>{J?.disconnect(),N&&(clearTimeout(N),N=null),I&&(clearTimeout(I),I=null),R(),V()}),e.watch(()=>s.page,async t=>{if(ce.value){C.value=t;return}ut(t),await ct(t)}),e.watch(()=>s.restoredPages,t=>{t&&(ce.value=!0,ze(t))}),e.watch(X,()=>{const t=f.value;t&&(S.value=ye(t))},{immediate:!1});const He=e.computed(()=>tn(S.value,s.itemWidth)),pe=e.computed(()=>nn(S.value,He.value,s.itemWidth,X.value));e.watch([He,pe,X,ge,$,q],()=>{lt()},{immediate:!0}),e.watch(()=>[h.value,h.value.length],()=>lt(),{immediate:!0});const Ot=e.computed(()=>["mt-8 flex min-h-0 flex-1 flex-col rounded-2xl border border-slate-200/70 bg-white/70 p-5 shadow-sm backdrop-blur",w.class]);return(t,o)=>(e.openBlock(),e.createElementBlock("section",e.mergeProps(K.value,{class:Ot.value}),[e.createElementVNode("div",sn,[e.renderSlot(t.$slots,"default")]),e.createElementVNode("div",{ref_key:"scrollViewportRef",ref:f,"data-testid":"items-scroll-container",class:"mt-4 min-h-0 flex-1 overflow-auto",style:e.normalizeStyle({paddingRight:X.value+"px"}),onScroll:Ht},[ee.value?(e.openBlock(),e.createElementBlock("div",un,o[0]||(o[0]=[e.createElementVNode("div",{class:"inline-flex items-center gap-3 text-sm text-slate-600"},[e.createElementVNode("svg",{class:"h-5 w-5 animate-spin text-slate-500",viewBox:"0 0 24 24","aria-hidden":"true"},[e.createElementVNode("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",fill:"none",stroke:"currentColor","stroke-width":"4"}),e.createElementVNode("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 0 1 8-8v4a4 4 0 0 0-4 4H4z"})]),e.createElementVNode("span",null,"Loading…")],-1)]))):ie.value?(e.openBlock(),e.createElementBlock("p",cn,"Error: "+e.toDisplayString(ie.value),1)):(e.openBlock(),e.createElementBlock("div",{key:2,class:"relative",style:e.normalizeStyle({height:zt.value+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Ae.value,n=>(e.openBlock(),e.createElementBlock("article",{key:h.value[n].id,"data-testid":"item-card",class:"absolute overflow-hidden rounded-xl border border-slate-200/60 bg-white shadow-sm",style:e.normalizeStyle({width:pe.value+"px",transition:It(h.value[n].id),transitionDelay:Bt(h.value[n].id),transform:Ft(n)})},[we.value||$.value>0?(e.openBlock(),e.createElementBlock("div",{key:0,"data-testid":"item-header-container",class:"w-full",style:e.normalizeStyle(qe.value)},[e.createVNode(e.unref(k),{"slot-fn":fe.value,"slot-props":{item:h.value[n],remove:()=>Ie(h.value[n])}},null,8,["slot-fn","slot-props"])],4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"group relative",onMouseenter:l=>p(h.value[n].id),onMouseleave:l=>g(h.value[n].id)},[e.createVNode(dt,{item:h.value[n],remove:()=>Ie(h.value[n]),"loader-slot-fn":ae.value,"error-slot-fn":O.value,hovered:v.value===h.value[n].id,onSuccess:z,onError:G},null,8,["item","remove","loader-slot-fn","error-slot-fn","hovered"]),$e.value?(e.openBlock(),e.createElementBlock("div",dn,[e.createVNode(e.unref(k),{"slot-fn":b.value,"slot-props":{item:h.value[n],remove:()=>Ie(h.value[n])}},null,8,["slot-fn","slot-props"])])):e.createCommentVNode("",!0)],40,fn),de.value||q.value>0?(e.openBlock(),e.createElementBlock("div",{key:1,"data-testid":"item-footer-container",class:"w-full",style:e.normalizeStyle(Oe.value)},[e.createVNode(e.unref(k),{"slot-fn":i.value,"slot-props":{item:h.value[n],remove:()=>Ie(h.value[n])}},null,8,["slot-fn","slot-props"])],4)):e.createCommentVNode("",!0)],4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(U.value,n=>(e.openBlock(),e.createElementBlock("article",{key:n.id+":leaving","data-testid":"item-card-leaving",class:"pointer-events-none absolute overflow-hidden rounded-xl border border-slate-200/60 bg-white shadow-sm",style:e.normalizeStyle({width:n.width+"px",transition:"transform "+gt+"ms ease-out",transform:n.leaving?"translate3d("+n.fromX+"px,"+n.fromY+"px,0)":"translate3d("+n.fromX+"px,"+n.toY+"px,0)"})},[we.value||$.value>0?(e.openBlock(),e.createElementBlock("div",{key:0,"data-testid":"item-header-container",class:"w-full",style:e.normalizeStyle(qe.value)},[e.createVNode(e.unref(k),{"slot-fn":fe.value,"slot-props":{item:n.item,remove:()=>{}}},null,8,["slot-fn","slot-props"])],4)):e.createCommentVNode("",!0),e.createElementVNode("div",vn,[e.createVNode(dt,{item:n.item,remove:()=>{},"loader-slot-fn":ae.value,"error-slot-fn":O.value,hovered:!1},null,8,["item","loader-slot-fn","error-slot-fn"]),$e.value?(e.openBlock(),e.createElementBlock("div",mn,[e.createVNode(e.unref(k),{"slot-fn":b.value,"slot-props":{item:n.item,remove:()=>{}}},null,8,["slot-fn","slot-props"])])):e.createCommentVNode("",!0)]),de.value||q.value>0?(e.openBlock(),e.createElementBlock("div",{key:1,"data-testid":"item-footer-container",class:"w-full",style:e.normalizeStyle(Oe.value)},[e.createVNode(e.unref(k),{"slot-fn":i.value,"slot-props":{item:n.item,remove:()=>{}}},null,8,["slot-fn","slot-props"])],4)):e.createCommentVNode("",!0)],4))),128))],4)),e.createElementVNode("div",hn,[te.value?(e.openBlock(),e.createElementBlock("span",pn,o[1]||(o[1]=[e.createElementVNode("svg",{class:"h-4 w-4 animate-spin text-slate-500",viewBox:"0 0 24 24","aria-hidden":"true"},[e.createElementVNode("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",fill:"none",stroke:"currentColor","stroke-width":"4"}),e.createElementVNode("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 0 1 8-8v4a4 4 0 0 0-4 4H4z"})],-1),e.createElementVNode("span",null,"Loading more…",-1)]))):C.value==null?(e.openBlock(),e.createElementBlock("span",gn,"End of list")):(e.openBlock(),e.createElementBlock("span",yn,"Scroll to load page "+e.toDisplayString(C.value),1))])],36)],16))}}),xt=e.defineComponent({name:"MasonryItem",setup(r,{slots:x,attrs:u}){const s=e.inject(wt,null);if(!s)return()=>null;const d=u.onPreloaded,w=u.onFailed,k=x.overlay,c=x.default;return s({header:x.header,loader:x.loader,overlay:k??c,error:x.error,footer:x.footer,onPreloaded:typeof d=="function"?d:Array.isArray(d)?v=>{for(const p of d)typeof p=="function"&&p(v)}:void 0,onFailed:typeof w=="function"?w:Array.isArray(w)?v=>{for(const p of w)typeof p=="function"&&p(v)}:void 0}),()=>null}}),Sn={install(r){r.component("Masonry",bt),r.component("MasonryItem",xt),r.component("MasonryVideoControls",De)}};exports.Masonry=bt;exports.MasonryItem=xt;exports.MasonryVideoControls=De;exports.VibePlugin=Sn;exports.masonryDefaults=yt;
|