import{j as T,ao as h,t as e,d as L,i as H,aD as p,O as c,aj as N,w as F,ak as r,g as B,a7 as t,y as P,aF as n,al as z,D as Z,F as V,h as u}from"./index-1d4a9afa.js";import{I as J}from"./index-c272bcfa.js";const[m,D,d]=T("pull-refresh"),j=50,f=["pulling","loosing","success"],b={disabled:Boolean,modelValue:Boolean,headHeight:h(j),successText:String,pullingText:String,loosingText:String,loadingText:String,pullDistance:e,successDuration:h(500),animationDuration:h(300)};var X=L({name:m,props:b,emits:["change","refresh","update:modelValue"],setup(g,{emit:i,slots:E}){let Q;const w=H(),S=H(),a=p(w),C=c({status:"normal",distance:0,duration:0}),M=N(),y=()=>{if(g.headHeight!==j)return{height:`${g.headHeight}px`}},k=()=>C.status!=="loading"&&C.status!=="success"&&!g.disabled,R=A=>{const I=+(g.pullDistance||g.headHeight);return A>I&&(A<I*2?A=I+(A-I)/2:A=I*1.5+(A-I*2)/4),Math.round(A)},K=(A,I)=>{const o=+(g.pullDistance||g.headHeight);C.distance=A,I?C.status="loading":A===0?C.status="normal":A<o?C.status="pulling":C.status="loosing",i("change",{status:C.status,distance:A})},U=()=>{const{status:A}=C;return A==="normal"?"":g[`${A}Text`]||d(A)},x=()=>{const{status:A,distance:I}=C;if(E[A])return E[A]({distance:I});const o=[];return f.includes(A)&&o.push(B("div",{class:D("text")},[U()])),A==="loading"&&o.push(B(t,{class:D("loading")},{default:U})),o},l=()=>{C.status="success",setTimeout(()=>{K(0)},+g.successDuration)},Y=A=>{Q=n(a.value)===0,Q&&(C.duration=0,M.start(A))},W=A=>{k()&&Y(A)},q=A=>{if(k()){Q||Y(A);const{deltaY:I}=M;M.move(A),Q&&I.value>=0&&M.isVertical()&&(z(A),K(R(I.value)))}},G=()=>{Q&&M.deltaY.value&&k()&&(C.duration=+g.animationDuration,C.status==="loosing"?(K(+g.headHeight,!0),i("update:modelValue",!0),P(()=>i("refresh"))):K(0))};return F(()=>g.modelValue,A=>{C.duration=+g.animationDuration,A?K(+g.headHeight,!0):E.success||g.successText?l():K(0,!1)}),r("touchmove",q,{target:S}),()=>{var A;const I={transitionDuration:`${C.duration}ms`,transform:C.distance?`translate3d(0,${C.distance}px, 0)`:""};return B("div",{ref:w,class:D()},[B("div",{ref:S,class:D("track"),style:I,onTouchstartPassive:W,onTouchend:G,onTouchcancel:G},[B("div",{class:D("head"),style:y()},[x()]),(A=E.default)==null?void 0:A.call(E)])])}}});const v=Z(X),_="_animateWrap_1kuq9_1",$="_loading_1kuq9_5",AA="_pullRefresh_1kuq9_13",s={animateWrap:_,loading:$,pullRefresh:AA};const O=""+new URL("loading-9729222e.gif",import.meta.url).href,CA="data:image/gif;base64,[encoded data, 64032 characters]",gA={loading:CA},QA=L({name:"s-full-refresh",props:{title:String,modelValue:{type:Boolean,default:!1}},emits:["refresh","update:modelValue"],setup(g,{emit:i,slots:E}){const Q=c({fullState:!1});return F(()=>g.modelValue,w=>{Q.fullState=w}),F(()=>Q.fullState,w=>{i("update:modelValue",w)}),()=>B(v,{modelValue:Q.fullState,"onUpdate:modelValue":w=>Q.fullState=w,onRefresh:()=>i("refresh"),loadingText:" ",class:s.pullRefresh},{loading:()=>B("div",null,[B(J,{src:gA.loading,class:s.loading},null)]),pulling:()=>B("div",null,[B(J,{src:O,class:s.loading},null)]),loosing:()=>B("div",null,[B(J,{src:O,class:s.loading},null)]),default:()=>B(V,null,[u(" "),E.default&&E.default()])})}});export{QA as M};
