import{r as s,h as t}from"./p-0d5a2e05.js";const i=class{constructor(t){s(this,t)}handleExpanded(s){if(s){this.submenuElement.style.maxHeight="fit-content"}else{this.submenuElement.style.maxHeight=""}const t=this.submenuElement.scrollHeight;this.onChildExpanded(s,t)}render(){if(!this.childRoute.children||this.childRoute.children.length===0){return t("li",{key:this.childRoute.path},t("tab-link",{text:this.childRoute.name,link:`${this.route.path}${this.childRoute.path}`,level:this.childRoute.level,type:"child",icon:this.childRoute.icon,badge:this.childRoute.badge,disabled:this.childRoute.disabled}))}return t("li",{key:this.childRoute.path},t("tab-link",{text:this.childRoute.name,link:`${this.route.path}${this.childRoute.path}`,type:"parent",icon:this.childRoute.icon,disabled:this.childRoute.disabled,onExpand:this.handleExpanded.bind(this)}),t("ul",{class:"sidepanel__submenu-list",ref:s=>this.submenuElement=s},this.childRoute.children.map(((s,i)=>t("submenu-component",{key:i,route:this.route,childRoute:s})))))}};const e=class{constructor(t){s(this,t);this.type="parent";this.onColor=false;this.level=1;this.externalLink=false;this.text="link";this.link="/pages";this.expanded=false;this.disabled=false;this.isExpanded=this.expanded}toggleTab(s){var t;if(this.type==="parent"){s.preventDefault();this.isExpanded=!this.isExpanded;(t=this.onExpand)===null||t===void 0?void 0:t.call(this,this.isExpanded)}}handleMouseEvents(s){const t=s==="add"?"add":"remove";this.tabRef.classList[t]("pressed")}render(){const s={class:`${this.type==="parent"?"sidepanel__menu-tab":"sidepanel__submenu-tab"} \n              ${this.level>1?"sidepanel__submenu--sublevel":""} \n              ${this.disabled?"disabled":""} \n              ${this.isExpanded?"active":""}`,onMouseDown:()=>this.handleMouseEvents("add"),onMouseUp:()=>this.handleMouseEvents("remove"),onMouseOut:()=>this.handleMouseEvents("remove"),ref:s=>this.tabRef=s};if(this.externalLink){return t("a",Object.assign({href:this.link},s,{tabindex:"0"}),this.icon&&t("span",{class:"sidepanel__menu-tab-icon"},t("dga-icon-v2",Object.assign({},this.icon))),t("span",{class:"sidepanel__menu-tab-label"},this.text),this.type==="parent"&&t("span",{class:"sidepanel__menu-tab-arrow"},t("i",{class:"hgi-stroke hgi-arrow-down-01",style:{fontSize:"16px"}})," "),this.badge!==undefined&&t("dga-tag",{color:this.onColor?"on-color":"gray",label:this.badge>=100?"+99":this.badge.toString(),size:"sm"}))}if(this.type==="parent"){console.log(this.icon,"this.iconthis.icon");return t("a",Object.assign({href:"#"},s,{onClick:s=>this.toggleTab(s),tabindex:"0"}),this.icon&&t("span",{class:"sidepanel__menu-tab-icon"},t("dga-icon-v2",Object.assign({},this.icon))),t("span",{class:"sidepanel__menu-tab-label"},this.text),t("span",{class:"sidepanel__menu-tab-arrow"},t("i",{class:"hgi-stroke hgi-arrow-down-01",style:{fontSize:"16px"}})," "),this.badge!==undefined&&t("dga-tag",{color:this.onColor?"on-color":"gray",label:this.badge>=100?"+99":this.badge.toString(),size:"sm"}))}return t("stencil-route-link",Object.assign({url:this.link},s,{tabindex:"0"}),this.icon&&t("span",{class:"sidepanel__menu-tab-icon"},t("dga-icon-v2",Object.assign({},this.icon))),t("span",{class:"sidepanel__menu-tab-label"},this.text),this.badge!==undefined&&t("dga-tag",{color:this.onColor?"on-color":"gray",label:this.badge>=100?"+99":this.badge.toString(),size:"sm"}))}};export{i as submenu_component,e as tab_link};
//# sourceMappingURL=p-173a44c2.entry.js.map