import{A as j,G as I,E as X,aa as _,d as U,S as se,Q as q,ah as ce,ai as ue,V as d,aj as G,a2 as T,ak as re,al as ve,am as fe,U as K,an as de,ao as he,a8 as me,a4 as ge,j as C,af as H,W as L,ap as we,aq as z,ar as D,N as Q,as as pe}from"./index.3bfa6a0e.js";const[F,M]=j("swipe"),ye={loop:I,width:X,height:X,vertical:Boolean,autoplay:_(0),duration:_(500),touchable:I,lazyRender:Boolean,initialSwipe:_(0),indicatorColor:String,showIndicators:I,stopPropagation:I},J=Symbol(F);var be=U({name:F,props:ye,emits:["change"],setup(a,{emit:P,slots:h}){const u=se(),e=q({rect:null,width:0,height:0,offset:0,active:0,swiping:!1}),s=ce(),{children:m,linkChildren:k}=ue(J),i=d(()=>m.length),n=d(()=>e[a.vertical?"height":"width"]),r=d(()=>a.vertical?s.deltaY.value:s.deltaX.value),f=d(()=>e.rect?(a.vertical?e.rect.height:e.rect.width)-n.value*i.value:0),$=d(()=>Math.ceil(Math.abs(f.value)/n.value)),y=d(()=>i.value*n.value),w=d(()=>(e.active+i.value)%i.value),E=d(()=>{const t=a.vertical?"vertical":"horizontal";return s.direction.value===t}),Z=d(()=>{const t={transitionDuration:`${e.swiping?0:a.duration}ms`,transform:`translate${a.vertical?"Y":"X"}(${e.offset}px)`};if(n.value){const l=a.vertical?"height":"width",o=a.vertical?"width":"height";t[l]=`${y.value}px`,t[o]=a[o]?`${a[o]}px`:""}return t}),ee=t=>{const{active:l}=e;return t?a.loop?D(l+t,-1,i.value):D(l+t,0,$.value):l},R=(t,l=0)=>{let o=t*n.value;a.loop||(o=Math.min(o,-f.value));let v=l-o;return a.loop||(v=D(v,f.value,0)),v},g=({pace:t=0,offset:l=0,emitChange:o})=>{if(i.value<=1)return;const{active:v}=e,c=ee(t),x=R(c,l);if(a.loop){if(m[0]&&x!==f.value){const O=x<f.value;m[0].setOffset(O?y.value:0)}if(m[i.value-1]&&x!==0){const O=x>0;m[i.value-1].setOffset(O?-y.value:0)}}e.active=c,e.offset=x,o&&c!==v&&P("change",w.value)},A=()=>{e.swiping=!0,e.active<=-1?g({pace:i.value}):e.active>=i.value&&g({pace:-i.value})},te=()=>{A(),s.reset(),z(()=>{e.swiping=!1,g({pace:-1,emitChange:!0})})},B=()=>{A(),s.reset(),z(()=>{e.swiping=!1,g({pace:1,emitChange:!0})})};let Y;const b=()=>clearTimeout(Y),S=()=>{b(),a.autoplay>0&&i.value>1&&(Y=setTimeout(()=>{B(),S()},+a.autoplay))},p=(t=+a.initialSwipe)=>{if(!u.value)return;const l=()=>{var o,v;if(!H(u)){const c={width:u.value.offsetWidth,height:u.value.offsetHeight};e.rect=c,e.width=+((o=a.width)!=null?o:c.width),e.height=+((v=a.height)!=null?v:c.height)}i.value&&(t=Math.min(i.value-1,t)),e.active=t,e.swiping=!0,e.offset=R(t),m.forEach(c=>{c.setOffset(0)}),S()};H(u)?L().then(l):l()},N=()=>p(e.active);let V;const ae=t=>{!a.touchable||(s.start(t),V=Date.now(),b(),A())},ie=t=>{a.touchable&&e.swiping&&(s.move(t),E.value&&(we(t,a.stopPropagation),g({offset:r.value})))},W=()=>{if(!a.touchable||!e.swiping)return;const t=Date.now()-V,l=r.value/t;if((Math.abs(l)>.25||Math.abs(r.value)>n.value/2)&&E.value){const v=a.vertical?s.offsetY.value:s.offsetX.value;let c=0;a.loop?c=v>0?r.value>0?-1:1:0:c=-Math[r.value>0?"ceil":"floor"](r.value/n.value),g({pace:c,emitChange:!0})}else r.value&&g({pace:0});e.swiping=!1,S()},ne=(t,l={})=>{A(),s.reset(),z(()=>{let o;a.loop&&t===i.value?o=e.active===0?0:t:o=t%i.value,l.immediate?z(()=>{e.swiping=!1}):e.swiping=!1,g({pace:o-e.active,emitChange:!0})})},oe=(t,l)=>{const o=l===w.value,v=o?{backgroundColor:a.indicatorColor}:void 0;return C("i",{style:v,class:M("indicator",{active:o})},null)},le=()=>{if(h.indicator)return h.indicator({active:w.value,total:i.value});if(a.showIndicators&&i.value>1)return C("div",{class:M("indicators",{vertical:a.vertical})},[Array(i.value).fill("").map(oe)])};return G({prev:te,next:B,state:e,resize:N,swipeTo:ne}),k({size:n,props:a,count:i,activeIndicator:w}),T(()=>a.initialSwipe,t=>p(+t)),T(i,()=>p(e.active)),T(()=>a.autoplay,S),T([re,ve],N),T(fe(),t=>{t==="visible"?S():b()}),K(p),de(()=>p(e.active)),he(()=>p(e.active)),me(b),ge(b),()=>{var t;return C("div",{ref:u,class:M()},[C("div",{style:Z.value,class:M("track",{vertical:a.vertical}),onTouchstart:ae,onTouchmove:ie,onTouchend:W,onTouchcancel:W},[(t=h.default)==null?void 0:t.call(h)]),le()])}}});const Pe=Q(be),[Se,xe]=j("swipe-item");var Te=U({name:Se,setup(a,{slots:P}){let h;const u=q({offset:0,inited:!1,mounted:!1}),{parent:e,index:s}=pe(J);if(!e){console.error("[Vant] <SwipeItem> must be a child component of <Swipe>.");return}const m=d(()=>{const n={},{vertical:r}=e.props;return e.size.value&&(n[r?"height":"width"]=`${e.size.value}px`),u.offset&&(n.transform=`translate${r?"Y":"X"}(${u.offset}px)`),n}),k=d(()=>{const{loop:n,lazyRender:r}=e.props;if(!r||h)return!0;if(!u.mounted)return!1;const f=e.activeIndicator.value,$=e.count.value-1,y=f===0&&n?$:f-1,w=f===$&&n?0:f+1;return h=s.value===f||s.value===y||s.value===w,h}),i=n=>{u.offset=n};return K(()=>{L(()=>{u.mounted=!0})}),G({setOffset:i}),()=>{var n;return C("div",{class:xe(),style:m.value},[k.value?(n=P.default)==null?void 0:n.call(P):null])}}});const $e=Q(Te);export{Pe as S,$e as a};
