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