/*!
 * KoliBri - The accessible HTML-Standard
 */
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const index=require("./index-f0fde70b.js"),index$1=require("./index-cb2ce614.js"),componentNames=require("./component-names-4cf3e7f5.js"),KolTreeItemWc=class{constructor(e){index.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 index.h(index.Host,{key:"83bbef4a6573e8f8db6a79a62264c33b0bc1c8ee",onSlotchange:this.handleSlotchange.bind(this),class:"kol-tree-item-wc"},index.h("li",{key:"7681e149dbabff21b30b58ef9438a1ffa6a6896d",class:"tree-item"},index.h(componentNames.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},index.h("span",{key:"c379822a5452765a330f6700a262738dc5aa8414",slot:"expert"},this.state._hasChildren&&(this.state._open?index.h("span",{class:"toggle-button",onClick:e=>{this.handleCollapseClick(e)}},"-"):index.h("span",{class:"toggle-button",onClick:e=>{this.handleExpandClick(e)}},"+"))," ",this.state._label)),index.h("ul",{key:"b09e26cdcad7a8a0e22517056db1562c28805ef2",hidden:!this.state._hasChildren||!this.state._open,role:"group"},index.h("slot",{key:"7010ba5c7ff4adbeb277e9e117b54d47d933258a"}))))}validateActive(e){index$1.validateActive(this,e||!1)}validateLabel(e){index$1.validateLabel(this,e)}validateOpen(e){index$1.validateOpen(this,e)}validateHref(e){index$1.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 index.getElement(this)}static get watchers(){return{_active:["validateActive"],_label:["validateLabel"],_open:["validateOpen"],_href:["validateHref"]}}};exports.kol_tree_item_wc=KolTreeItemWc;