import{au as j,ah as we,av as Te,E as M,d as V,G as B,H as D,W as C,j as h,M as K,aw as Ce,ax as Z,U as $,a3 as I,V as Se,a0 as ke,ab as E,a1 as xe,ac as Ie,aj as Be,S as Re,ad as _e,al as $e,X as _,ak as ae,ao as Ae,ap as Pe,aa as Ne,af as ze,ag as Oe,a2 as Q,ay as Ee,az as Le,aA as p,Y as ee,a8 as De,aB as Me,aC as Ve,aD as We,J as He,K as Ze,I as Fe,at as je,aE as Ke,a6 as Ue,aF as Xe,O as le}from"./ResizeObserver.es.b7226882.js";import{u as ie}from"./use-id.5d5e6e63.js";import{T as Ye}from"./use-tab-status.db1f6d2e.js";import{S as qe,a as Ge}from"./index.cf00521e.js";import{u as Je}from"./use-refs.428b450a.js";import{S as Qe}from"./index.f6c44874.js";function pe(e,l,i){let f=0;const a=e.scrollLeft,u=i===0?1:Math.round(i*1e3/16);function d(){e.scrollLeft+=(l-a)/u,++fl||!u&&al?j(o):f&&j(f)}o()}const[tt,te]=M("tab");var nt=V({name:tt,props:{id:String,dot:Boolean,type:String,color:String,title:String,badge:B,shrink:Boolean,isActive:Boolean,disabled:Boolean,controls:String,scrollable:Boolean,activeColor:String,inactiveColor:String,showZeroBadge:D},setup(e,{slots:l}){const i=C(()=>{const a={},{type:u,color:d,disabled:v,isActive:o,activeColor:g,inactiveColor:w}=e;d&&u==="card"&&(a.borderColor=d,v||(o?a.backgroundColor=d:a.color=d));const y=o?g:w;return y&&(a.color=y),a}),f=()=>{const a=h("span",{class:te("text",{ellipsis:!e.scrollable})},[l.title?l.title():e.title]);return e.dot||K(e.badge)&&e.badge!==""?h(Ce,{dot:e.dot,content:e.badge,showZero:e.showZeroBadge},{default:()=>[a]}):a};return()=>h("div",{id:e.id,role:"tab",class:[te([e.type,{grow:e.scrollable&&!e.shrink,shrink:e.shrink,active:e.isActive,disabled:e.disabled}])],style:i.value,tabindex:e.disabled?void 0:e.isActive?0:-1,"aria-selected":e.isActive,"aria-disabled":e.disabled||void 0,"aria-controls":e.controls},[f()])}});const[at,ne]=M("tabs");var lt=V({name:at,props:{count:Z(Number),inited:Boolean,animated:Boolean,duration:Z(B),swipeable:Boolean,lazyRender:Boolean,currentIndex:Z(Number)},emits:["change"],setup(e,{emit:l,slots:i}){const f=$(),a=v=>l("change",v),u=()=>{var v;const o=(v=i.default)==null?void 0:v.call(i);return e.animated||e.swipeable?h(qe,{ref:f,loop:!1,class:ne("track"),duration:+e.duration*1e3,touchable:e.swipeable,lazyRender:e.lazyRender,showIndicators:!1,onChange:a},{default:()=>[o]}):o},d=v=>{const o=f.value;o&&o.state.active!==v&&o.swipeTo(v,{immediate:!e.inited})};return I(()=>e.currentIndex,d),Se(()=>{d(e.currentIndex)}),()=>h("div",{class:ne("content",{animated:e.animated||e.swipeable})},[u()])}});const[oe,L]=M("tabs"),it={type:ke("line"),color:String,border:Boolean,sticky:Boolean,shrink:Boolean,active:E(0),duration:E(.3),animated:Boolean,ellipsis:D,swipeable:Boolean,scrollspy:Boolean,offsetTop:E(0),background:String,lazyRender:D,lineWidth:B,lineHeight:B,beforeChange:Function,swipeThreshold:E(5),titleActiveColor:String,titleInactiveColor:String},re=Symbol(oe);var ot=V({name:oe,props:it,emits:["click","change","scroll","disabled","rendered","click-tab","update:active"],setup(e,{emit:l,slots:i}){var f,a;{const t=(a=(f=xe())==null?void 0:f.vnode)==null?void 0:a.props;t&&"onClick"in t&&console.warn('[Vant] Tabs: "click" event is deprecated, using "click-tab" instead.'),t&&"onDisabled"in t&&console.warn('[Vant] Tabs: "disabled" event is deprecated, using "click-tab" instead.')}let u,d,v;const o=$(),g=$(),w=$(),S=ie(),y=Ie(o),[R,W]=Je(),{children:c,linkChildren:U}=Be(re),s=Re({inited:!1,position:"",lineStyle:{},currentIndex:-1}),k=C(()=>c.length>e.swipeThreshold||!e.ellipsis||e.shrink),se=C(()=>({borderColor:e.color,background:e.background})),A=(t,n)=>{var r;return(r=t.name)!=null?r:n},X=C(()=>{const t=c[s.currentIndex];if(t)return A(t,s.currentIndex)}),H=C(()=>_e(e.offsetTop)),Y=C(()=>e.sticky?H.value+u:0),P=t=>{const n=g.value,r=R.value;if(!k.value||!n||!r||!r[s.currentIndex])return;const b=r[s.currentIndex].$el,m=b.offsetLeft-(n.offsetWidth-b.offsetWidth)/2;pe(n,m,t?0:+e.duration)},T=()=>{const t=s.inited;_(()=>{const n=R.value;if(!n||!n[s.currentIndex]||e.type!=="line"||Oe(o.value))return;const r=n[s.currentIndex].$el,{lineWidth:b,lineHeight:m}=e,x=r.offsetLeft+r.offsetWidth/2,O={width:Q(b),backgroundColor:e.color,transform:`translateX(${x}px) translateX(-50%)`};if(t&&(O.transitionDuration=`${e.duration}s`),K(m)){const J=Q(m);O.height=J,O.borderRadius=J}s.lineStyle=O})},ce=t=>{const n=t=0&&t{const n=ce(t);if(!K(n))return;const r=c[n],b=A(r,n),m=s.currentIndex!==null;s.currentIndex=n,b!==e.active&&(l("update:active",b),m&&l("change",b,r.title))},z=t=>{const n=c.find((b,m)=>A(b,m)===t),r=n?c.indexOf(n):0;N(r)},q=(t=!1)=>{if(e.scrollspy){const n=c[s.currentIndex].$el;if(n&&y.value){const r=p(n,y.value)-Y.value;d=!0,et(y.value,r,t?0:+e.duration,()=>{d=!1})}}},de=(t,n,r)=>{const{title:b,disabled:m}=c[n],x=A(c[n],n);m?l("disabled",x,b):(Ve(e.beforeChange,{args:[x],done:()=>{N(n),q()}}),l("click",x,b),We(t)),l("click-tab",{name:x,title:b,event:r,disabled:m})},ue=t=>{v=t.isFixed,l("scroll",t)},fe=t=>{_(()=>{z(t),q(!0)})},ve=()=>{for(let t=0;tY.value)return t===0?0:t-1}return c.length-1},be=()=>{if(e.scrollspy&&!d){const t=ve();N(t)}},he=()=>c.map((t,n)=>h(nt,De({id:`${S}-${n}`,ref:W(n),type:e.type,color:e.color,style:t.titleStyle,class:t.titleClass,shrink:e.shrink,isActive:n===s.currentIndex,controls:t.id,scrollable:k.value,activeColor:e.titleActiveColor,inactiveColor:e.titleInactiveColor,onClick:r=>de(t,n,r)},Me(t,["dot","badge","title","disabled","showZeroBadge"])),{title:t.$slots.title})),ge=()=>{if(e.type==="line"&&c.length)return h("div",{class:L("line"),style:s.lineStyle},null)},G=()=>{var t,n;const{type:r,border:b}=e;return h("div",{ref:w,class:[L("wrap"),{[Ee]:r==="line"&&b}]},[h("div",{ref:g,role:"tablist",class:L("nav",[r,{shrink:e.shrink,complete:k.value}]),style:se.value,"aria-orientation":"horizontal"},[(t=i["nav-left"])==null?void 0:t.call(i),he(),ge(),(n=i["nav-right"])==null?void 0:n.call(i)])])};I([()=>e.color,$e],T),I(()=>e.active,t=>{t!==X.value&&z(t)}),I(()=>c.length,()=>{s.inited&&(z(e.active),T(),_(()=>{P(!0)}))}),I(()=>s.currentIndex,()=>{P(),T(),v&&!e.scrollspy&&Le(Math.ceil(p(o.value)-H.value))});const me=()=>{z(e.active),_(()=>{s.inited=!0,w.value&&(u=ee(w.value).height),P(!0)})},ye=(t,n)=>l("rendered",t,n);return ae({resize:T,scrollTo:fe}),Ae(T),Pe(T),Ne(me),ze("scroll",be,{target:y}),U({id:S,props:e,setLine:T,onRendered:ye,currentName:X,scrollIntoView:P}),()=>{var t;return h("div",{ref:o,class:L([e.type])},[e.sticky?h(Qe,{container:o.value,offsetTop:H.value,onScroll:ue},{default:()=>{var n;return[G(),(n=i["nav-bottom"])==null?void 0:n.call(i)]}}):[G(),(t=i["nav-bottom"])==null?void 0:t.call(i)],h(lt,{count:c.length,inited:s.inited,animated:e.animated,duration:e.duration,swipeable:e.swipeable,lazyRender:e.lazyRender,currentIndex:s.currentIndex,onChange:N},{default:()=>{var n;return[(n=i.default)==null?void 0:n.call(i)]}})])}}});const[rt,F]=M("tab"),st=He({},Ze,{dot:Boolean,name:B,badge:B,title:String,disabled:Boolean,titleClass:Fe,titleStyle:[String,Object],showZeroBadge:D});var ct=V({name:rt,props:st,setup(e,{slots:l}){const i=ie(),f=$(!1),{parent:a,index:u}=je(re);if(!a){console.error("[Vant] must be a child component of .");return}const d=()=>{var g;return(g=e.name)!=null?g:u.value},v=()=>{f.value=!0,a.props.lazyRender&&_(()=>{a.onRendered(d(),e.title)})},o=C(()=>{const g=d()===a.currentName.value;return g&&!f.value&&v(),g});return I(()=>e.title,()=>{a.setLine(),a.scrollIntoView()}),Ke(Ye,o),()=>{var g;const w=`${a.id}-${u.value}`,{animated:S,swipeable:y,scrollspy:R,lazyRender:W}=a.props;if(!l.default&&!S)return;const c=R||o.value;if(S||y)return h(Ge,{id:i,role:"tabpanel",class:F("panel-wrapper",{inactive:!o.value}),tabindex:o.value?0:-1,"aria-hidden":!o.value,"aria-labelledby":w},{default:()=>{var k;return[h("div",{class:F("panel")},[(k=l.default)==null?void 0:k.call(l)])]}});const s=f.value||R||!W?(g=l.default)==null?void 0:g.call(l):null;return ae({id:i}),Ue(h("div",{id:i,role:"tabpanel",class:F("panel"),tabindex:c?0:-1,"aria-labelledby":w},[s]),[[Xe,c]])}}});const gt=le(ct),mt=le(ot);export{mt as T,gt as a};