import{_ as m,O as g,aL as r,aM as T,aN as x,aO as y,L as H,a6 as w,o as f,c as b,V as _,y as S,a5 as h,aP as I,aQ as k,a as l,n as u,F as B,r as L,v}from"./entry.DPwc-EV0.js";const C={name:"Tab",props:{id:{type:String,default:null},name:{type:String,required:!0},color:{type:String},prefix:{type:String,default:""},suffix:{type:String,default:""},isHidden:{type:Boolean,default:!1},selected:{type:Boolean,default:!1}},setup(a){const o=g(!1),e=r("tabsProvider"),i=r("addTab"),d=r("updateTab"),n=r("deleteTab"),t=a.prefix+a.name+a.suffix,s=a.id?a.id:a.name.toLowerCase().replace(/ /g,"-"),c="#"+(a.isHidden?"":s);return T(()=>e.activeTabHash,()=>{o.value=c===e.activeTabHash}),T(()=>Object.assign({},a),()=>{d(s,{name:a.name,header:t,color:a==null?void 0:a.color,isHidden:a.isHidden,hash:c,index:e.tabs.length,tabId:s})}),x(()=>{i({name:a.name,color:a==null?void 0:a.color,header:t,isHidden:a.isHidden,hash:c,index:e.tabs.length,tabId:s,isSelected:a.selected})}),y(()=>{n(s)}),{header:t,tabId:s,hash:c,isActive:o}}},A=["id"];function M(a,o,e,i,d,n){return H((f(),b("section",{id:i.tabId,ref:"tab",class:"tabs-component-panel"},[_(a.$slots,"default")],8,A)),[[w,i.isActive]])}const j=m(C,[["render",M]]),E={props:{orientation:{type:String,default:"horizontal"},color:{type:String,default:"#ffffff"},fixedVerticalTabs:{type:Boolean,default:!1},verticalTabWidth:{type:Number},options:{type:Object,required:!1,default:()=>({useUrlFragment:!1,defaultTabHash:null})}},emits:["changed","clicked"],setup(a,o){const e=S({activeTabHash:"",tabs:[]}),i=(n,t)=>{t&&!a.options.useUrlFragment&&t.preventDefault();const s=d(n);s&&(e.tabs.forEach(c=>{c.isActive=c.hash===s.hash}),o.emit("changed",{tab:s}),e.activeTabHash=s.hash)},d=n=>e.tabs.find(t=>t.hash===n);return h("tabsProvider",e),h("addTab",n=>{e.tabs.push(n)}),h("updateTab",(n,t)=>{let s=e.tabs.findIndex(c=>c.tabId===n);e.tabs[s]=t}),h("deleteTab",n=>{let t=e.tabs.findIndex(s=>s.tabId===n);e.tabs.splice(t,1)}),T(()=>e.tabs.length,()=>{e.activeTabHash===""&&e.tabs.forEach(n=>{n.isSelected&&i(n.hash)})}),I(()=>{if(e.tabs.length){if(window.addEventListener("hashchange",()=>i(window.location.hash)),d(window.location.hash)){i(window.location.hash);return}if(a.options.defaultTabHash&&d("#"+a.options.defaultTabHash)){i("#"+a.options.defaultTabHash);return}i(e.tabs[0].hash)}}),{...k(e),selectTab:i,findTab:d}},computed:{activeTabs(){return this.tabs.filter(({isHidden:a})=>a!==!0)}}},F={class:"tabs-component-tabs"},O=["href","onClick","innerHTML"];function P(a,o,e,i,d,n){return f(),b("div",{class:v(["tabs-component",e.fixedVerticalTabs&&e.orientation==="vertical"?"fixed":""])},[l("div",{class:v([e.orientation,"tabs-wrapper"])},[l("div",{class:"tabs-container",style:u({width:e.orientation==="vertical"?`${e.verticalTabWidth}px`:"auto"})},[l("ul",F,[(f(!0),b(B,null,L(n.activeTabs,(t,s)=>(f(),b("li",{key:s,class:v(["tabs-component-tab",{error:t.color==="red"},t.isActive?"is-active":""]),style:u({backgroundColor:t.isActive?e.color:"inherit"})},[l("a",{class:"tab",href:t.hash,onClick:c=>i.selectTab(t.hash,c),innerHTML:t.header},null,8,O)],6))),128))])],4),l("div",{class:"tabs-component-panels",style:u({backgroundColor:e.color,marginLeft:`${e.orientation==="vertical"?e.verticalTabWidth:0}px`})},[_(a.$slots,"default")],4)],2)],2)}const z=m(E,[["render",P]]);export{j as _,z as a};