import{E as e,d as t,l as a,m as l,c as o,az as s,o as u,e as i,w as n,f as r,n as c,R as d,q as f,v as h,F as v,h as b,i as p,T as g,bs as m,bu as y,aq as x,H as w,bv as _,r as F,b as S,j as X,Q as Y,g as C,t as k,bw as B}from"./index-de4504bf.js";import{_ as T}from"./u-badge.b8e9eb88.js";import{_ as z}from"./u-sticky.34e1a57d.js";import{_ as j}from"./_plugin-vue_export-helper.1b428a4d.js";const W=j(t({__name:"tabs",props:{isScroll:{type:Boolean,default:!0},current:{default:0},height:{default:80},fontSize:{default:28},duration:{default:.3},activeColor:{default:"var(--color-primary)"},inactiveColor:{default:"#333"},barWidth:{default:40},barHeight:{default:4},gutter:{default:30},bgColor:{default:"#FFFFFF"},name:{default:"name"},count:{default:"count"},offset:{default:[5,20]},bold:{type:Boolean,default:!0},activeItemStyle:{default:{}},showBar:{type:Boolean,default:!0},barStyle:{default:{}},itemWidth:{default:"auto"},isFixed:{type:Boolean,default:!1},top:{default:0},stickyBgColor:{default:"#FFFFFF"},swipeable:{type:Boolean,default:!0}},emits:["change"],setup(t,{emit:j}){const W=t,{touch:$,resetTouchStatus:R,touchStart:H,touchMove:M}=function(){const t=e({direction:"",deltaX:0,deltaY:0,offsetX:0,offsetY:0}),a=()=>{t.direction="",t.deltaX=0,t.deltaY=0,t.offsetX=0,t.offsetY=0};return{touch:t,resetTouchStatus:a,touchStart:e=>{a();const l=e.touches[0];t.startX=l.clientX,t.startY=l.clientY},touchMove:e=>{const a=e.touches[0];var l,o;t.deltaX=a.clientX-t.startX,t.deltaY=a.clientY-t.startY,t.offsetX=Math.abs(t.deltaX),t.offsetY=Math.abs(t.deltaY),t.direction=t.direction||((l=t.offsetX)>(o=t.offsetY)&&l>10?"horizontal":o>l&&o>10?"vertical":"")}}}(),I=a([]),q=a([]),E=a(0),O=a([]),Q=a(0),A=a(0),D=a(0),G=a("cu-tab"),J=a(W.current),K=a(!0),L=a(!1),N=B();l(()=>I.value,async(e,t)=>{K.value||e.length===t.length||(J.value=0),await m(),Z()}),l(()=>W.current,(e,t)=>{m(()=>{J.value=e,te()})},{immediate:!0});const P=o(()=>{const e={width:W.barWidth+"rpx",transform:`translate(${A.value}px, -100%)`,"transition-duration":`${K.value?0:W.duration}s`,"background-color":W.activeColor,height:W.barHeight+"rpx",opacity:K.value?0:1,"border-radius":W.barHeight/2+"px"};return Object.assign(e,W.barStyle),e}),U=o(()=>e=>{let t={height:W.height+"rpx","line-height":W.height+"rpx","font-size":W.fontSize+"rpx",padding:W.isScroll?`0 ${W.gutter}rpx`:"",flex:W.isScroll?"auto":"1",width:`${W.itemWidth}rpx`};return e==J.value&&W.bold&&(t.fontWeight="bold"),e==J.value?(t.color=W.activeColor,t=Object.assign(t,W.activeItemStyle)):t.color=W.inactiveColor,t}),V=()=>{I.value=q.value.map(e=>{const{name:t,dot:a,active:l,inited:o}=e.event,{updateRender:s}=e;return{name:t,dot:a,active:l,inited:o,updateRender:s}})},Z=async()=>{const e=await y("#"+G.value,!1,N);D.value=e.left,Q.value=e.width,ee()},ee=()=>{const e=x().in(N);for(let t=0;t{O.value=e,te()})},te=()=>{const e=O.value[J.value];if(!e)return;const t=e.width,a=e.left-D.value-(Q.value-t)/2;E.value=a<0?0:a;const l=e.left+e.width/2-D.value;A.value=l-w(W.barWidth)/2,1==K.value&&setTimeout(()=>{K.value=!1},100),q.value.forEach((e,t)=>{const a=t===J.value;a===e.event.active&&e.event.inited||e.updateRender(a)})},ae=e=>{W.swipeable&&(L.value=!0,H(e))},le=e=>{W.swipeable&&L.value&&M(e)},oe=()=>{if(!W.swipeable||!L.value)return;if("horizontal"===$.direction&&$.offsetX>=50){let e,t=I.value.length,a=J.value;e=$.deltaX<=0?a>=t-1?0:a+1:a<=0?t-1:a-1,m(()=>{J.value=e,te()}),j("change",e)}L.value=!1};return s(()=>{V()}),_("handleChange",(e,t)=>{q.value.push({event:e,updateRender:t})}),_("updateTabs",V),(e,a)=>{const l=F(S("u-badge"),T),o=X,s=Y,y=F(S("u-sticky"),z);return u(),i(o,{class:"tabs"},{default:n(()=>[r(y,{enable:t.isFixed,"bg-color":t.stickyBgColor,"offset-top":t.top,"h5-nav-height":0},{default:n(()=>[r(o,{id:G.value,style:c({background:t.bgColor})},{default:n(()=>[r(s,{style:c({height:t.height+"rpx"}),"scroll-x":"",class:"scroll-view","scroll-left":E.value,"scroll-with-animation":""},{default:n(()=>[r(o,{class:d(["scroll-box",{"tabs-scorll-flex":!t.isScroll}])},{default:n(()=>[(u(!0),f(v,null,h(I.value,(e,a)=>(u(),i(o,{class:"tab-item line1",id:"tab-item-"+a,key:a,onClick:e=>(e=>{e!=J.value&&(m(()=>{J.value=e,te()}),j("change",e))})(a),style:c([b(U)(a)])},{default:n(()=>[r(l,{count:e[t.count]||e.dot||0,offset:t.offset,size:"mini"},null,8,["count","offset"]),C(" "+k(e[t.name]||e.name),1)]),_:2},1032,["id","onClick","style"]))),128)),t.showBar?(u(),i(o,{key:0,class:"tab-bar",style:c([b(P)])},null,8,["style"])):p("",!0)]),_:1},8,["class"])]),_:1},8,["style","scroll-left"])]),_:1},8,["id","style"])]),_:1},8,["enable","bg-color","offset-top"]),r(o,{class:"tab-content",onTouchstart:ae,onTouchmove:le,onTouchcancel:oe,onTouchend:oe},{default:n(()=>[r(o,null,{default:n(()=>[g(e.$slots,"default",{},void 0,!0)]),_:3})]),_:3})]),_:3})}}}),[["__scopeId","data-v-a021632e"]]);export{W as t};