import{r as o,h as a,j as r,i as c,H as h,aq as d,g as _,m as f}from"./index-DscFWUNz.js";import{v}from"./href-zZq6HYWf-Ck9QiEBy.js";import{v as p}from"./label-CdtNxOKu-DuSxxbJz.js";import{v as m}from"./open-D9q98v46-B5otfJDq.js";import{n as k}from"./dev.utils-Bbi3sn8s-CRUPlhXY.js";import{c as b}from"./clsx-eK3rPvPS-BT_IL7Fz.js";/*!
 * KoliBri - The accessible HTML-Standard
 */const g=(e,t,i)=>{f(e,"_active",t,i)},E=class{constructor(e){o(this,e),this.groupId=`tree-group-${k()}`,this.state={_active:!1,_hasChildren:!1,_href:"",_label:"",_open:!1}}render(){const{_href:e,_active:t,_hasChildren:i,_open:l,_label:n}=this.state;return a(h,{key:"e8cebee52ed0f115c3aa30e82e2e3ccf5d09e626",onSlotchange:this.handleSlotchange.bind(this)},a("li",{key:"c4b1d56ae69f55ca57ad8d863df02fe0d7ff4f00",class:"kol-tree-item",style:{"--level":`${this.level}`}},a(r,{key:"8e87e00dae2d0e6dcad5602e28b5642bc31702f5",class:b("kol-tree-item__link",{"kol-tree-item__link--first-level":this.level===0,"kol-tree-item__link--active":t}),_href:e,_label:"",_role:"treeitem",_tabIndex:t?0:-1,_ariaExpanded:i?l:void 0,_ariaOwns:i?this.groupId:void 0,ref:s=>this.linkElement=s},a("span",{key:"2375f5ff6abe59419b5d4ef28e5e0f104034fef3",class:"kol-tree-item__link-inner",slot:"expert"},i?a("span",{class:"kol-tree-item__toggle-button",onClick:s=>l?void this.handleCollapseClick(s):void this.handleExpandClick(s)},a(c,{class:"kol-tree-item__toggle-button-icon",_icons:`codicon codicon-${l?"chevron-down":"chevron-right"}`,_label:""})):a("span",{class:"kol-tree-item__toggle-button-placeholder"}),a("span",{key:"39c07661723143bfafcc6ee8e96e51bd88daa940",class:"kol-tree-item__text"},n))),a("ul",{key:"2bd2e3a880b4d1946f00e46784f476e69508441b",class:"kol-tree-item__children",hidden:!i||!l,role:"group",id:this.groupId},a("slot",{key:"472cc53e288b84a99a0190a82be67e04ce851f99"}))))}validateActive(e){g(this,e||!1)}validateLabel(e){p(this,e)}validateOpen(e){m(this,e)}validateHref(e){v(this,e)}componentWillLoad(){this.validateActive(this._active),this.validateLabel(this._label),this.validateOpen(this._open),this.validateHref(this._href),this.checkForChildren(),this.determineTreeItemDepth()}determineTreeItemDepth(){let e=0,t=this.host.parentNode.host.parentNode;for(;t!==null&&t.tagName.toLowerCase()!==d&&t!==document.body;)t=t.parentElement,e+=1;this.level=e}handleSlotchange(){this.checkForChildren()}checkForChildren(){var e,t;this.state=Object.assign(Object.assign({},this.state),{_hasChildren:!!(!((t=(e=this.host.querySelector("slot"))===null||e===void 0?void 0:e.assignedElements)===null||t===void 0)&&t.call(e).length)})}async focusLink(){await this.linkElement.kolFocus()}async handleExpandClick(e){e.preventDefault(),await this.linkElement.kolFocus(),await this.expand()}async expand(){this.state._hasChildren&&(this.state=Object.assign(Object.assign({},this.state),{_open:!0}))}async handleCollapseClick(e){e.preventDefault(),this.linkElement.focus(),await this.collapse()}async collapse(){this.state._hasChildren&&(this.state=Object.assign(Object.assign({},this.state),{_open:!1}))}async isOpen(){var e;return(e=this.state._open)!==null&&e!==void 0?e:!1}get host(){return _(this)}static get watchers(){return{_active:["validateActive"],_label:["validateLabel"],_open:["validateOpen"],_href:["validateHref"]}}};export{E as kol_tree_item_wc};
//# sourceMappingURL=kol-tree-item-wc.entry-M_2D25XL.js.map
