/*!
 * KoliBri - The accessible HTML-Standard
 */
import{proxyCustomElement,HTMLElement,h,Host}from"@stencil/core/internal/client";import{aQ as validateActive,v as validateLabel,z as validateOpen,a7 as validateHref}from"./index2.js";import{d as defineCustomElement$5}from"./component.js";import{d as defineCustomElement$4}from"./shadow2.js";import{d as defineCustomElement$3}from"./component9.js";import{d as defineCustomElement$2}from"./component2.js";import{d as defineCustomElement$1}from"./component3.js";const KolTreeItemWc=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),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,{onSlotchange:this.handleSlotchange.bind(this)},h("li",{class:"tree-item"},h("kol-link",{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",{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",{hidden:!this.state._hasChildren||!this.state._open,role:"group"},h("slot",null))))}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 this}static get watchers(){return{_active:["validateActive"],_label:["validateLabel"],_open:["validateOpen"],_href:["validateHref"]}}},[4,"kol-tree-item-wc",{_active:[4],_label:[1],_open:[4],_href:[1],state:[32],focusLink:[64],expand:[64],collapse:[64],isOpen:[64]},void 0,{_active:["validateActive"],_label:["validateLabel"],_open:["validateOpen"],_href:["validateHref"]}]);function defineCustomElement(){if("undefined"==typeof customElements)return;["kol-tree-item-wc","kol-icon","kol-link","kol-link-wc","kol-span-wc","kol-tooltip-wc"].forEach((e=>{switch(e){case"kol-tree-item-wc":customElements.get(e)||customElements.define(e,KolTreeItemWc);break;case"kol-icon":customElements.get(e)||defineCustomElement$5();break;case"kol-link":customElements.get(e)||defineCustomElement$4();break;case"kol-link-wc":customElements.get(e)||defineCustomElement$3();break;case"kol-span-wc":customElements.get(e)||defineCustomElement$2();break;case"kol-tooltip-wc":customElements.get(e)||defineCustomElement$1()}}))}export{KolTreeItemWc as K,defineCustomElement as d};