import{m as E,q as L,n as C,t as w,d as B,S as h,ak as R,E as x,ay as y,X as N,G as q,Y as _,k as r,W as F,at as b,aq as G,L as H,y as I}from"./index.879f7421.js";import{u as M}from"./use-tab-status.fe36a003.js";const[U,o,V]=E("list"),W={error:Boolean,offset:L(300),loading:Boolean,disabled:Boolean,finished:Boolean,errorText:String,direction:C("down"),loadingText:String,finishedText:String,immediateCheck:w};var X=B({name:U,props:W,emits:["load","update:error","update:loading"],setup(e,{emit:c,slots:a}){const d=h(e.loading),u=h(),g=h(),l=M(),m=R(u),n=()=>{F(()=>{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(m);if(!i.height||G(u))return;let f=!1;const v=b(g);s==="up"?f=i.top-v.top<=t:f=v.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(H,{class:o("loading-icon")},{default:()=>[e.loadingText||V("loading")]})])};return x(()=>[e.loading,e.finished,e.error],n),l&&x(l,t=>{t&&n()}),y(()=>{d.value=e.loading}),N(()=>{e.immediateCheck&&n()}),q({check:n}),_("scroll",n,{target:m,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 z=I(X);export{z as L};
