import{c as $,n as x,m as b,e as M,g as N,h as w,E as p,I as U,l as j,Q as z,R as B,w as E,K as O,y as Y}from"./index-f8f67ba0.js";import{d as I,r as S,a as q,o as F,s as G,R as K,w as _,c as i,m as Q,T as X,A,B as Z}from"./index-b63c6ed2.js";import{b as J}from"./function-call-6876fcd3.js";import{L as W}from"./index-5062ddcf.js";function tt(e,r){let n=null,l=0;return function(...d){if(n)return;const c=Date.now()-l,f=()=>{l=Date.now(),n=!1,e.apply(this,d)};c>=r?f():n=setTimeout(f,r)}}const[et,P]=$("back-top"),at={right:x,bottom:x,zIndex:x,target:[String,Object],offset:b(200),immediate:Boolean,teleport:{type:[String,Object],default:"body"}};var st=I({name:et,inheritAttrs:!1,props:at,emits:["click"],setup(e,{emit:r,slots:n,attrs:l}){let d=!1;const c=S(!1),f=S(),a=S(),h=q(()=>M(N(e.zIndex),{right:w(e.right),bottom:w(e.bottom)})),D=o=>{var g;r("click",o),(g=a.value)==null||g.scrollTo({top:0,behavior:e.immediate?"auto":"smooth"})},m=()=>{c.value=a.value?B(a.value)>=+e.offset:!1},k=()=>{const{target:o}=e;if(typeof o=="string"){const g=document.querySelector(o);if(g)return g}else return o},u=()=>{j&&A(()=>{a.value=e.target?k():z(f.value),m()})};return p("scroll",tt(m,100),{target:a}),F(u),G(()=>{d&&(c.value=!0,d=!1)}),K(()=>{c.value&&e.teleport&&(c.value=!1,d=!0)}),_(()=>e.target,u),()=>{const o=i("div",Q({ref:e.teleport?void 0:f,class:P({active:c.value}),style:h.value,onClick:D},l),[n.default?n.default():i(U,{name:"back-top",class:P("icon")},null)]);return e.teleport?[i("div",{ref:f,class:P("placeholder")},null),i(X,{to:e.teleport},{default:()=>[o]})]:o}}});const ht=E(st),[nt,T,ot]=$("pull-refresh"),R=50,lt=["pulling","loosing","success"],ct={disabled:Boolean,modelValue:Boolean,headHeight:b(R),successText:String,pullingText:String,loosingText:String,loadingText:String,pullDistance:x,successDuration:b(500),animationDuration:b(300)};var ut=I({name:nt,props:ct,emits:["change","refresh","update:modelValue"],setup(e,{emit:r,slots:n}){let l;const d=S(),c=S(),f=O(d),a=Z({status:"normal",distance:0,duration:0}),h=J(),D=()=>{if(e.headHeight!==R)return{height:`${e.headHeight}px`}},m=()=>a.status!=="loading"&&a.status!=="success"&&!e.disabled,k=t=>{const s=+(e.pullDistance||e.headHeight);return t>s&&(t{const v=+(e.pullDistance||e.headHeight);a.distance=t,s?a.status="loading":t===0?a.status="normal":t{const{status:t}=a;return t==="normal"?"":e[`${t}Text`]||ot(t)},g=()=>{const{status:t,distance:s}=a;if(n[t])return n[t]({distance:s});const v=[];return lt.includes(t)&&v.push(i("div",{class:T("text")},[o()])),t==="loading"&&v.push(i(W,{class:T("loading")},{default:o})),v},V=()=>{a.status="success",setTimeout(()=>{u(0)},+e.successDuration)},y=t=>{l=B(f.value)===0,l&&(a.duration=0,h.start(t))},C=t=>{m()&&y(t)},L=t=>{if(m()){l||y(t);const{deltaY:s}=h;h.move(t),l&&s.value>=0&&h.isVertical()&&(Y(t),u(k(s.value)))}},H=()=>{l&&h.deltaY.value&&m()&&(a.duration=+e.animationDuration,a.status==="loosing"?(u(+e.headHeight,!0),r("update:modelValue",!0),A(()=>r("refresh"))):u(0))};return _(()=>e.modelValue,t=>{a.duration=+e.animationDuration,t?u(+e.headHeight,!0):n.success||e.successText?V():u(0,!1)}),p("touchmove",L,{target:c}),()=>{var t;const s={transitionDuration:`${a.duration}ms`,transform:a.distance?`translate3d(0,${a.distance}px, 0)`:""};return i("div",{ref:d,class:T()},[i("div",{ref:c,class:T("track"),style:s,onTouchstartPassive:C,onTouchend:H,onTouchcancel:H},[i("div",{class:T("head"),style:D()},[g()]),(t=n.default)==null?void 0:t.call(n)])])}}});const gt=E(ut);export{ht as B,gt as P};