import{G as C,ac as E,a1 as L,I as w,d as R,V as h,ad as B,a4 as m,aX as N,W as I,al as U,ag as V,j as r,Y as _,Z as T,ah as j,aU as y,P as F}from"./ResizeObserver.es.62ab429c.js";import{u as G}from"./use-tab-status.a98984d2.js";const[H,o,M]=C("list"),W={error:Boolean,offset:E(300),loading:Boolean,finished:Boolean,errorText:String,direction:L("down"),loadingText:String,finishedText:String,immediateCheck:w};var X=R({name:H,props:W,emits:["load","update:error","update:loading"],setup(e,{emit:c,slots:a}){const d=h(!1),u=h(),g=h(),s=G(),x=B(u),n=()=>{_(()=>{if(d.value||e.finished||e.error||(s==null?void 0:s.value)===!1)return;const{offset:t,direction:l}=e,i=T(x);if(!i.height||j(u))return;let f=!1;const v=T(g);l==="up"?f=i.top-v.top<=t:f=v.bottom-i.bottom<=t,f&&(d.value=!0,c("update:loading",!0),c("load"))})},P=()=>{if(e.finished){const t=a.finished?a.finished():e.finishedText;if(t)return r("div",{class:o("finished-text")},[t])}},b=()=>{c("update:error",!1),n()},k=()=>{if(e.error){const t=a.error?a.error():e.errorText;if(t)return r("div",{role:"button",class:o("error-text"),tabindex:0,onClick:b},[t])}},S=()=>{if(d.value&&!e.finished)return r("div",{class:o("loading")},[a.loading?a.loading():r(y,{class:o("loading-icon")},{default:()=>[e.loadingText||M("loading")]})])};return m(()=>[e.loading,e.finished,e.error],n),s&&m(s,t=>{t&&n()}),N(()=>{d.value=e.loading}),I(()=>{e.immediateCheck&&n()}),U({check:n}),V("scroll",n,{target:x}),()=>{var t;const l=(t=a.default)==null?void 0:t.call(a),i=r("div",{ref:g,class:o("placeholder")},null);return r("div",{ref:u,role:"feed",class:o(),"aria-busy":d.value},[e.direction==="down"?l:i,S(),P(),k(),e.direction==="up"?l:i])}}});const q=F(X);export{q as L};
