import{r as o,h as a,n as h,e as c,H as d,am as r,m as f,q as v}from"./index-DJsSmExJ.js";import{n as p}from"./dev.utils-202fb0ba-DJkMZKVl.js";import{v as _}from"./label-7d1ce375-BbZF87oK.js";import{v as b}from"./open-74ada92d-B8HiotOq.js";import{v as u}from"./href-3ee53c2c-DmqhOJk8.js";/*!
 * KoliBri - The accessible HTML-Standard
 */const m=(e,t,s)=>{v(e,"_active",t,s)},O=class{constructor(e){o(this,e),this.groupId=`tree-group-${p()}`,this.level=void 0,this.state={_active:!1,_hasChildren:!1,_href:"",_label:"",_open:!1},this._active=void 0,this._label=void 0,this._open=void 0,this._href=void 0}render(){const{_href:e,_active:t,_hasChildren:s,_open:i,_label:n}=this.state;return a(d,{key:"7138fb8c723f2bf3e3a06fbb6aea211534068f36",onSlotchange:this.handleSlotchange.bind(this),class:"kol-tree-item-wc"},a("li",{key:"f790d81d295f070457e39b6591de5c58cbe95b09",class:"tree-item",style:{"--level":`${this.level}`}},a(h,{key:"77d589d030b3eae35b1e7810fdc225f169e6bb4c",class:{"tree-link":!0,"first-level":this.level===0,active:!!t},_href:e,_label:"",_role:"treeitem",_tabIndex:t?0:-1,_ariaExpanded:s?i:void 0,_ariaOwns:s?this.groupId:void 0,ref:l=>this.linkElement=l},a("span",{key:"cdc688eb4d867dd1c7f4629139e38c471e02c23f",class:"tree-link-inner",slot:"expert"},s?a("span",{class:"toggle-button",onClick:l=>i?void this.handleCollapseClick(l):void this.handleExpandClick(l)},a(c,{class:"toggle-button-icon",_icons:`codicon codicon-${i?"chevron-down":"chevron-right"}`,_label:""})):a("span",{class:"toggle-button-placeholder"}),a("span",{key:"f2147ae17873f9a96221aef13dda7953ac7f592c",class:"text"},n))),a("ul",{key:"1020c40614da618527a53c460f9d974ed575da6f",hidden:!s||!i,role:"group",id:this.groupId},a("slot",{key:"d73bfce093bfbb5ff28758e82888a6d449b28c88"}))))}validateActive(e){m(this,e||!1)}validateLabel(e){_(this,e)}validateOpen(e){b(this,e)}validateHref(e){u(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()!==r&&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 f(this)}static get watchers(){return{_active:["validateActive"],_label:["validateLabel"],_open:["validateOpen"],_href:["validateHref"]}}};export{O as kol_tree_item_wc};
//# sourceMappingURL=kol-tree-item-wc.entry-CEpr651w.js.map
