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-BeCeuELg.js";import{n as p}from"./dev.utils-109baad9-BGIjjL5C.js";import{v as b}from"./label-3757689e-D7ErDa5R.js";import{v as _}from"./open-6a9969be-CmmX04qw.js";import{v as u}from"./href-bf07fbb8-BOmKbEFg.js";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:"1181be8d7250b750cf064480ef9941c2d99fe2d0",onSlotchange:this.handleSlotchange.bind(this),class:"kol-tree-item-wc"},a("li",{key:"3349d65ca244c70fa6fa82403f45bb521f88d2d5",class:"tree-item",style:{"--level":`${this.level}`}},a(h,{key:"7387e1ffd5327583f1e9dc8733b0835c2248070e",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:"456e0b79433f48e81811f6e4e635d2e1281b4e6b",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:"074816a9371ebf5cb3a49b3460c5a368bc36465d",class:"text"},n))),a("ul",{key:"b073f00265bc39c0b44f38b6e48de75f57418ceb",hidden:!s||!i,role:"group",id:this.groupId},a("slot",{key:"79717d641b1cbf39ad956e19224ffed46ecee014"}))))}validateActive(e){m(this,e||!1)}validateLabel(e){b(this,e)}validateOpen(e){_(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-JYphkfWl.js.map
