import{r as e,h as t,g as s}from"./p-3b76effa.js";class a{constructor(t){e(this,t)}componentDidLoad(){this.createGroup().then(()=>{const[e]=this.tabGroup;this.selectGroup(e),this.selectedIndex&&(this.activeIndex=Number(this.selectedIndex)-1)})}componentDidUpdate(){this.selectedIndex&&(this.activeIndex=Number(this.selectedIndex)-1)}onSelectedTab(e){const t=this.tabGroup.find(t=>t.header.id===e.detail.id);this.selectGroup(t)}async createGroup(){const e=Array.from(this.host.querySelectorAll("ema-tab-header"));this.tabsHeader=[],e.map(async e=>{this.tabsHeader.push(await e.getChild())});const t=Array.from(this.host.querySelectorAll("ema-tab-content"));this.tabsContent=[],t.map(async e=>{this.tabsContent.push(await e.getChild())}),await new Promise(e=>setTimeout(e,40)),this.tabGroup=this.tabsHeader.map(e=>{const t=this.tabsContent.find(t=>t.name===e.name);return{header:e,content:t}})}selectGroup(e){this.tabGroup.forEach(e=>{e.header.unselect(),e.content.unselect()}),e.header.select(),e.content.select()}set activeIndex(e){let t=0;this.tabGroup.forEach(s=>{t==e?(s.header.select(),s.content.select()):(s.header.unselect(),s.content.unselect()),t++})}render(){return[t("div",{class:"ema-tabs-header"},t("slot",{name:"header"})),t("div",{class:"ema-tabs-content"},t("slot",{name:"content"}))]}get host(){return s(this)}static get style(){return":root{--ema-color:#343a40;--ema-primary:#007bff;--ema-secondary:#6c757d;--ema-success:#28a745;--ema-info:#17a2b8;--ema-warning:#ffc107;--ema-danger:#dc3545;--ema-light:#f8f9fa;--ema-dark:#343a40;--ema-background:#fff;--ema-background-diap:rgba(29,29,29,0.97);--ema-border-color:#c5c9cd;--ema-border:1px solid #c5c9cd;--ema-border-radius:3px 3px 3px 3px;--ema-box-shadow:1px 1px 10px 1px #ccc;--ema-margin:0.25rem;--ema-margin-sm:0.5rem;--ema-margin-md:1rem;--ema-margin-lg:1.5rem;--ema-margin-xl:2rem;--ema-padding:0.25rem;--ema-padding-sm:0.5rem;--ema-padding-md:1rem;--ema-padding-lg:1.5rem;--ema-padding-xl:2rem;--ema-gray-100:#f8f9fa;--ema-gray-200:#e9ecef;--ema-gray-300:#dee2e6;--ema-gray-400:#ced4da;--ema-gray-500:#adb5bd;--ema-gray-600:#868e96;--ema-gray-700:#495057;--ema-gray-800:#343a40;--ema-gray-900:#212529}.ema-tabs-header{display:-ms-flexbox;display:flex;border-bottom:1px solid rgba(0,0,0,.3)}.ema-tabs-content{padding:10px}"}}export{a as ema_tabs};