import{t as L,w,u as C,v as E,d as R,R as h,ap as B,Z as m,az as N,$ as _,W as y,a0 as z,c as r,_ as A,an as b,aA as D,L as F,D as H}from"./index.d1dca38b.js";import{u as I}from"./use-tab-status.03ea8dd0.js";const[M,o,U]=L("list"),V={error:Boolean,offset:w(300),loading:Boolean,disabled:Boolean,finished:Boolean,errorText:String,direction:C("down"),loadingText:String,finishedText:String,immediateCheck:E};var W=R({name:M,props:V,emits:["load","update:error","update:loading"],setup(e,{emit:c,slots:a}){const d=h(e.loading),u=h(),g=h(),l=I(),v=B(u),n=()=>{A(()=>{if(d.value||e.finished||e.disabled||e.error||(l==null?void 0:l.value)===!1)return;const{offset:t,direction:s}=e,i=b(v);if(!i.height||D(u))return;let f=!1;const x=b(g);s==="up"?f=i.top-x.top<=t:f=x.bottom-i.bottom<=t,f&&(d.value=!0,c("update:loading",!0),c("load"))})},T=()=>{if(e.finished){const t=a.finished?a.finished():e.finishedText;if(t)return r("div",{class:o("finished-text")},[t])}},k=()=>{c("update:error",!1),n()},P=()=>{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:k},[t])}},S=()=>{if(d.value&&!e.finished&&!e.disabled)return r("div",{class:o("loading")},[a.loading?a.loading():r(F,{class:o("loading-icon")},{default:()=>[e.loadingText||U("loading")]})])};return m(()=>[e.loading,e.finished,e.error],n),l&&m(l,t=>{t&&n()}),N(()=>{d.value=e.loading}),_(()=>{e.immediateCheck&&n()}),y({check:n}),z("scroll",n,{target:v,passive:!0}),()=>{var t;const s=(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"?s:i,S(),T(),P(),e.direction==="up"?s:i])}}});const j=H(W);export{j as L};
