import{b7 as E,by as L,bm as w,cn as B,bk as N,r as h,co as R,Q as v,cp as q,O as y,bH as H,cq as O,c as _,N as r,p as j,T as x,cr as F,bq as I,aq as M}from"./index-xnhGKCfe.js";import{u as Q}from"./use-tab-status-C1dTAhJi.js";const[U,o,V]=N("list"),z={error:Boolean,offset:B(300),loading:Boolean,disabled:Boolean,finished:Boolean,scroller:Object,errorText:String,direction:w("down"),loadingText:String,finishedText:String,immediateCheck:L};var A=E({name:U,props:z,emits:["load","update:error","update:loading"],setup(e,{emit:c,slots:a}){const d=h(e.loading),u=h(),g=h(),s=Q(),T=R(u),b=_(()=>e.scroller||T.value),n=()=>{j(()=>{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=x(b);if(!i.height||F(u))return;let f=!1;const m=x(g);t==="up"?f=i.top-m.top<=l:f=m.bottom-i.bottom<=l,f&&(d.value=!0,c("update:loading",!0),c("load"))})},k=()=>{if(e.finished){const t=a.finished?a.finished():e.finishedText;if(t)return r("div",{class:o("finished-text")},[t])}},P=()=>{c("update:error",!1),n()},S=()=>{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:P},[t])}},C=()=>{if(d.value&&!e.finished&&!e.disabled)return r("div",{class:o("loading")},[a.loading?a.loading():r(I,{class:o("loading-icon")},{default:()=>[e.loadingText||V("loading")]})])};return v(()=>[e.loading,e.finished,e.error],n),s&&v(s,t=>{t&&n()}),q(()=>{d.value=e.loading}),y(()=>{e.immediateCheck&&n()}),H({check:n}),O("scroll",n,{target:b,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,C(),k(),S(),e.direction==="up"?l:i])}}});const J=M(A);export{J as L};
