import{r as o,h as a,n as d,e as h,H as c,am as r,m as f,q as v}from"./index-TUFJsQwj.js";import{n as p}from"./dev.utils-52f8c2e9-DbX55uYj.js";import{v as _}from"./label-7d1ce375-CT1s1cqK.js";import{v as b}from"./open-74ada92d-BVFlr-Lp.js";import{v as u}from"./href-3ee53c2c-nDCfGCul.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(c,{key:"10844c4679cde6b05366172544dbf02bc948d70c",onSlotchange:this.handleSlotchange.bind(this),class:"kol-tree-item-wc"},a("li",{key:"a7da471fabd4f32662471cea460eac72c5d9e72b",class:"tree-item",style:{"--level":`${this.level}`}},a(d,{key:"9fe32ddea2ab88e29f7f30494291e8d48e03b51c",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:"dbe0d75274599878cf69b313b664353fc39aea60",class:"tree-link-inner",slot:"expert"},s?a("span",{class:"toggle-button",onClick:l=>i?void this.handleCollapseClick(l):void this.handleExpandClick(l)},a(h,{class:"toggle-button-icon",_icons:`codicon codicon-${i?"chevron-down":"chevron-right"}`,_label:""})):a("span",{class:"toggle-button-placeholder"}),a("span",{key:"3d3ce0044fff50ed43a144b7c1b19458da654ef0",class:"text"},n))),a("ul",{key:"ff36340e2630cb36a8f1ddd7e1e9deedba400a64",hidden:!s||!i,role:"group",id:this.groupId},a("slot",{key:"a281d64f9c45e5dd6f4dc091d8ec454f872d39a7"}))))}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-5butcPW-.js.map
