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