import{x as C,a6 as E,W as L,z as R,d as w,O as h,a7 as B,Z as m,aR as N,P as _,af as y,aa as z,i as r,S as F,T,ab as H,aP as I,K}from"./index.afa1b71c.js";import{u as M}from"./use-tab-status.7451baf9.js";const[O,o,U]=C("list"),V={error:Boolean,offset:E(300),loading:Boolean,finished:Boolean,errorText:String,direction:L("down"),loadingText:String,finishedText:String,immediateCheck:R};var W=w({name:O,props:V,emits:["load","update:error","update:loading"],setup(e,{emit:c,slots:a}){const d=h(!1),f=h(),g=h(),s=M(),x=B(f),n=()=>{F(()=>{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||H(f))return;let u=!1;const v=T(g);l==="up"?u=i.top-v.top<=t:u=v.bottom-i.bottom<=t,u&&(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(I,{class:o("loading-icon")},{default:()=>[e.loadingText||U("loading")]})])};return m(()=>[e.loading,e.finished,e.error],n),s&&m(s,t=>{t&&n()}),N(()=>{d.value=e.loading}),_(()=>{e.immediateCheck&&n()}),y({check:n}),z("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:f,role:"feed",class:o(),"aria-busy":d.value},[e.direction==="down"?l:i,S(),P(),k(),e.direction==="up"?l:i])}}});const q=K(W);export{q as L};
