import{g as L,p as N,J as R,K as w,i as _,s as D,a3 as E,I as $,ca as B,n as q,o as s,q as H,r as W,x as J,cc as K,R as v,cC as O,cD as U,L as j,E as g,bi as G,b9 as x,M as Q}from"./index-D-FY8Yx2.js";const X=N({color:String,direction:{type:String,default:"vertical",validator:e=>["vertical","horizontal"].includes(e)},side:{type:String,default:"end",validator:e=>["start","end","both"].includes(e)},mode:{type:String,default:"intersect",validator:e=>["intersect","manual"].includes(e)},margin:[Number,String],loadMoreText:{type:String,default:"$vuetify.infiniteScroll.loadMore"},emptyText:{type:String,default:"$vuetify.infiniteScroll.empty"},...K(),...J()},"VInfiniteScroll"),A=O({name:"VInfiniteScrollIntersect",props:{side:{type:String,required:!0},rootMargin:String},emits:{intersect:(e,d)=>!0},setup(e,d){let{emit:o}=d;const{intersectionRef:S,isIntersecting:i}=U();return j(i,async a=>{o("intersect",e.side,a)}),q(()=>g("div",{class:"v-infinite-scroll-intersect",style:{"--v-infinite-margin-size":e.rootMargin},ref:S},[G(" ")])),{}}}),Z=L()({name:"VInfiniteScroll",props:X(),emits:{load:e=>!0},setup(e,d){let{slots:o,emit:S}=d;const i=R(),a=w("ok"),f=w("ok"),k=_(()=>D(e.margin)),y=w(!1);function m(t){if(!i.value)return;const n=e.direction==="vertical"?"scrollTop":"scrollLeft";i.value[n]=t}function V(){if(!i.value)return 0;const t=e.direction==="vertical"?"scrollTop":"scrollLeft";return i.value[t]}function u(){if(!i.value)return 0;const t=e.direction==="vertical"?"scrollHeight":"scrollWidth";return i.value[t]}function C(){if(!i.value)return 0;const t=e.direction==="vertical"?"clientHeight":"clientWidth";return i.value[t]}E(()=>{i.value&&(e.side==="start"?m(u()):e.side==="both"&&m(u()/2-C()/2))});function I(t,n){t==="start"?a.value=n:t==="end"?f.value=n:t==="both"&&(a.value=n,f.value=n)}function z(t){return t==="start"?a.value:f.value}let h=0;function b(t,n){y.value=n,y.value&&c(t)}function c(t){if(e.mode!=="manual"&&!y.value)return;const n=z(t);if(!i.value||["empty","loading"].includes(n))return;h=u(),I(t,"loading");function l(r){I(t,r),v(()=>{r==="empty"||r==="error"||(r==="ok"&&t==="start"&&m(u()-h+V()),e.mode!=="manual"&&v(()=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{c(t)})})})}))})}S("load",{side:t,done:l})}const{t:T}=$();function M(t,n){if(e.side!==t&&e.side!=="both")return;const l=()=>c(t),r={side:t,props:{onClick:l,color:e.color}};return n==="error"?o.error?.(r):n==="empty"?o.empty?.(r)??g("div",null,[T(e.emptyText)]):e.mode==="manual"?n==="loading"?o.loading?.(r)??s(x,{indeterminate:!0,color:e.color},null):o["load-more"]?.(r)??s(Q,{variant:"outlined",color:e.color,onClick:l},{default:()=>[T(e.loadMoreText)]}):o.loading?.(r)??s(x,{indeterminate:!0,color:e.color},null)}const{dimensionStyles:F}=B(e);q(()=>{const t=e.tag,n=e.side==="start"||e.side==="both",l=e.side==="end"||e.side==="both",r=e.mode==="intersect";return s(t,{ref:i,class:W(["v-infinite-scroll",`v-infinite-scroll--${e.direction}`,{"v-infinite-scroll--start":n,"v-infinite-scroll--end":l}]),style:H(F.value)},{default:()=>[g("div",{class:"v-infinite-scroll__side"},[M("start",a.value)]),n&&r&&s(A,{key:"start",side:"start",onIntersect:b,rootMargin:k.value},null),o.default?.(),l&&r&&s(A,{key:"end",side:"end",onIntersect:b,rootMargin:k.value},null),g("div",{class:"v-infinite-scroll__side"},[M("end",f.value)])]})});function P(t){const n=t??e.side;I(n,"ok"),v(()=>{n!=="end"&&m(u()-h+V()),e.mode!=="manual"&&v(()=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{n==="both"?(c("start"),c("end")):c(n)})})})})})}return{reset:P}}});export{Z as V};
