var Se=Object.defineProperty;var ie=t=>{throw TypeError(t)};var ye=(t,e,i)=>e in t?Se(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var re=(t,e,i)=>ye(t,typeof e!="symbol"?e+"":e,i),J=(t,e,i)=>e.has(t)||ie("Cannot "+i);var f=(t,e,i)=>(J(t,e,"read from private field"),i?i.call(t):e.get(t)),K=(t,e,i)=>e.has(t)?ie("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),N=(t,e,i,o)=>(J(t,e,"write to private field"),o?o.call(t,i):e.set(t,i),i),ne=(t,e,i)=>(J(t,e,"access private method"),i);import{a as L,t as de,e as Q}from"./legacy.BFrtrUTY.js";import{R as We,q as He,p as Me,d as I,u as se,t as Pe,a as Be,s as oe,S as Ge,b as m,g as r,e as z,c as ae,r as U,f as V}from"./index.Chpxrmiw.js";import{p as b,a as q,i as le,b as Ke,r as Le}from"./index-client.D0CpKjVb.js";import{e as ze,d as C,f as Fe}from"./index.svelte_svelte_type_style_lang.oHDPoyLK.js";function W(t,e,i,o){var a=t.__styles??(t.__styles={});a[e]!==i&&(a[e]=i,i==null?t.style.removeProperty(e):t.style.setProperty(e,i,""))}var x,H,F,R,fe;const j=class j{constructor(e){K(this,R);K(this,x,new WeakMap);K(this,H);K(this,F);N(this,F,e)}observe(e,i){var o=f(this,x).get(e)||new Set;return o.add(i),f(this,x).set(e,o),ne(this,R,fe).call(this).observe(e,f(this,F)),()=>{var a=f(this,x).get(e);a.delete(i),a.size===0&&(f(this,x).delete(e),f(this,H).unobserve(e))}}};x=new WeakMap,H=new WeakMap,F=new WeakMap,R=new WeakSet,fe=function(){return f(this,H)??N(this,H,new ResizeObserver(e=>{for(var i of e){j.entries.set(i.target,i);for(var o of f(this,x).get(i.target)||[])o(i)}}))},re(j,"entries",new WeakMap);let Y=j;var Oe=new Y({box:"border-box"});function X(t,e,i){var o=Oe.observe(t,()=>i(t[e]));We(()=>(He(()=>i(t[e])),o))}function qe(t=100){let e;return i=>{clearTimeout(e),e=setTimeout(i,t)}}function Ce(t=200){let e,i;return(o,a)=>c=>{e&&(Math.abs(c-e)>o?(a.fast(),i!==void 0&&(clearTimeout(i),i=void 0),i=setTimeout(()=>{a.slow(),i=void 0},t)):i===void 0&&a.slow()),e=c}}const Z={ceil:(t,e)=>Math.ceil(t/e)*e,floor:(t,e)=>~~(t/e)*e},Re=(t,e,i,o,a,c)=>{const T=[],d=Z.floor(c/e*o,o),O=d>a?d-a:0,A=d>0&&O>=0?O:d,S=Math.min(t,Z.ceil((c+i)/e*o,o))+a,M=S<t?S:t;for(let u=A;u<M;u++)T.push(u);return T},ce=(t,e)=>~~(t/e),je=qe(),Ae=Ce();var De=de("<div><!></div>"),Ee=de("<div><!> <div></div> <!></div>");function Xe(t,e){Me(e,!0);let i=b(e,"width",3,"100%"),o=b(e,"overScan",3,1),a=b(e,"marginLeft",3,0),c=b(e,"marginTop",3,0),T=b(e,"scrollPosition",15,0),d=b(e,"scrollBehavior",3,"auto"),O=b(e,"getKey",3,n=>n),A=Le(e,["$$slots","$$events","$$legacy","itemCount","itemHeight","itemWidth","height","width","overScan","marginLeft","marginTop","scrollPosition","scrollBehavior","getKey","columnCount","onscroll","header","item","placeholder","footer"]),h=I(void 0),S=I(q(T())),M=I(0),u=I(0),k=I(0),p=I(q([])),y=!1,D=!1,E=I(!1);function he(n,s=d()){$(ce(n,r(v))*e.itemHeight+c()+r(M),s)}function ue(n,s=d()){$(n,s)}const $=(n,s=d())=>{r(h)&&(y=!0,r(h).scrollTo({top:n,behavior:s}),y=!1)},ve=n=>{r(h)&&!y&&!D&&(y=!0,r(h).scrollTo({top:n,behavior:d()}),y=!1)},ge=n=>{const s=ce(n,r(v)),_=n%r(v);return{rowIndex:s,columnIndex:_,style:`position: absolute; transform: translate3d(${_*e.itemWidth+a()}px, ${s*e.itemHeight+c()}px, 0px); height: ${e.itemHeight}px; width: ${e.itemWidth}px; will-change: transform;`}},me=n=>{D=!0,y||(m(S,q(Math.max(0,n.currentTarget.scrollTop-r(M)))),T(n.currentTarget.scrollTop),r(we)(r(S))),je(()=>{D=!1})};let v=z(()=>e.columnCount?e.columnCount:Math.max(~~((r(u)-a()-(r(u)-r(k)))/e.itemWidth),1)),xe=z(()=>Z.ceil(e.itemCount,r(v))*e.itemHeight/r(v)),_e=z(()=>r(v)*o());se(()=>{(r(u)||r(v))&&m(p,q(Re(e.itemCount,e.itemHeight,e.height,r(v),r(_e),r(S))))}),se(()=>{r(h)&&ve(T())});let we=z(()=>Ae(e.height,{fast:()=>{m(E,!0)},slow:()=>{m(E,!1)}}));var l=Ee(),Ie=n=>{var s;me(n),(s=e.onscroll)==null||s.call(e,n)};let ee;var te=ae(l);le(te,()=>e.header,n=>{var s=De(),_=ae(s);C(_,()=>e.header),U(s),X(s,"offsetHeight",g=>m(M,g)),L(n,s)});var P=oe(te,2);W(P,"width","100%"),ze(P,21,()=>r(p),n=>O()(n),(n,s)=>{var _=Q();const g=z(()=>{const{rowIndex:B,columnIndex:w,style:G}=ge(r(s));return{rowIndex:B,columnIndex:w,style:G}});var Te=V(_);le(Te,()=>!r(E)||!e.placeholder,B=>{var w=Q(),G=V(w);C(G,()=>e.item,()=>({index:r(s),rowIndex:r(g).rowIndex,columnIndex:r(g).columnIndex,style:r(g).style})),L(B,w)},B=>{var w=Q(),G=V(w);C(G,()=>e.placeholder,()=>({index:r(s),rowIndex:r(g).rowIndex,columnIndex:r(g).columnIndex,style:r(g).style})),L(B,w)}),L(n,_)}),U(P);var be=oe(P,2);return C(be,()=>e.footer??Ge),U(l),Ke(l,n=>m(h,n),()=>r(h)),Pe(()=>{ee=Fe(l,ee,{onscroll:Ie,...A}),W(l,"position","relative"),W(l,"overflow","auto"),W(l,"height",`${e.height??""}px`),W(l,"width",i()),W(P,"height",`${r(xe)??""}px`)}),X(l,"offsetWidth",n=>m(u,n)),X(l,"clientWidth",n=>m(k,n)),L(t,l),Be({scrollToIndex:he,scrollToPosition:ue})}export{Xe as G};
