/*!
 * KoliBri - The accessible HTML-Standard
 */
import{r as registerInstance,h,H as Host,g as getElement}from"./index-9ca46203.js";import{aP as validateActive,v as validateLabel,l as validateOpen,aL as validateHref}from"./index-0489af72.js";import{h as KolLinkTag}from"./component-names-61247f2f.js";const KolTreeItemWc=class{constructor(e){registerInstance(this,e),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(){return h(Host,{key:"83bbef4a6573e8f8db6a79a62264c33b0bc1c8ee",onSlotchange:this.handleSlotchange.bind(this),class:"kol-tree-item-wc"},h("li",{key:"7681e149dbabff21b30b58ef9438a1ffa6a6896d",class:"tree-item"},h(KolLinkTag,{key:"e13e85b22f341446ca106124b90db1bdc9327123",class:{"tree-link":!0,active:Boolean(this.state._active)},_label:"",_href:this.state._href,ref:e=>this.linkElement=e,_tabIndex:this.state._active?0:-1},h("span",{key:"c379822a5452765a330f6700a262738dc5aa8414",slot:"expert"},this.state._hasChildren&&(this.state._open?h("span",{class:"toggle-button",onClick:e=>{this.handleCollapseClick(e)}},"-"):h("span",{class:"toggle-button",onClick:e=>{this.handleExpandClick(e)}},"+"))," ",this.state._label)),h("ul",{key:"b09e26cdcad7a8a0e22517056db1562c28805ef2",hidden:!this.state._hasChildren||!this.state._open,role:"group"},h("slot",{key:"7010ba5c7ff4adbeb277e9e117b54d47d933258a"}))))}validateActive(e){validateActive(this,e||!1)}validateLabel(e){validateLabel(this,e)}validateOpen(e){validateOpen(this,e)}validateHref(e){validateHref(this,e)}componentWillLoad(){this.validateActive(this._active),this.validateLabel(this._label),this.validateOpen(this._open),this.validateHref(this._href),this.checkForChildren()}handleSlotchange(){this.checkForChildren()}checkForChildren(){var e;this.state=Object.assign(Object.assign({},this.state),{_hasChildren:Boolean(null===(e=this.host.querySelector("slot"))||void 0===e?void 0:e.assignedElements().length)})}async focusLink(){this.linkElement.focus()}async handleExpandClick(e){e.preventDefault(),this.linkElement.focus(),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 null!==(e=this.state._open)&&void 0!==e&&e}get host(){return getElement(this)}static get watchers(){return{_active:["validateActive"],_label:["validateLabel"],_open:["validateOpen"],_href:["validateHref"]}}};export{KolTreeItemWc as kol_tree_item_wc};