import{__decorate as t}from"tslib";import{html as e,nothing as s}from"lit";import{property as i,state as a,customElement as n}from"lit/decorators.js";import{s as r}from"./nile-context-menu-item.css.esm.js";import{N as o}from"../internal/nile-element.esm.js";import"../internal/accessibility/a11y.state.enum.esm.js";import"../internal/accessibility/a11y.property.enum.esm.js";import"../internal/accessibility/role.enum.esm.js";let l=class extends o{constructor(){super(...arguments),this.value="",this.disabled=!1,this._hasSubmenu=!1,this._hasIcon=!1,this._submenuExpanded=!1,this._onSlotChange=t=>{const e=t.target.assignedElements({flatten:!0});this._hasSubmenu=e.some((t=>"nile-context-submenu"===t.tagName.toLowerCase()))},this._onIconSlotChange=t=>{const e=t.target;this._hasIcon=e.assignedNodes({flatten:!0}).some((t=>t.nodeType===Node.ELEMENT_NODE||""!==(t.textContent??"").trim()))}}static get styles(){return[r]}setSubmenuExpanded(t){this._submenuExpanded=t}focus(t){const e=this.shadowRoot?.querySelector(".item");e?.focus(t)}get hasSubmenu(){return this._hasSubmenu}render(){return e`
      <div
        part="item"
        class="item"
        role="menuitem"
        tabindex="-1"
        aria-disabled=${this.disabled?"true":"false"}
        aria-haspopup=${this._hasSubmenu?"menu":s}
        aria-expanded=${this._hasSubmenu?String(this._submenuExpanded):s}
        data-has-submenu=${this._hasSubmenu?"true":"false"}
      >
        <span part="icon" class="icon" data-empty=${this._hasIcon?"false":"true"}>
          <slot name="icon" @slotchange=${this._onIconSlotChange}></slot>
        </span>
        <span part="label" class="label"><slot @slotchange=${this._onSlotChange}></slot></span>
        ${this._hasSubmenu?e`<span part="chevron" class="chevron" aria-hidden="true">
              <nile-glyph name="ng-chevron-right" size="16"></nile-glyph>
            </span>`:""}
      </div>
    `}};t([i({attribute:!0,type:String,reflect:!0})],l.prototype,"value",void 0),t([i({attribute:!0,type:Boolean,reflect:!0})],l.prototype,"disabled",void 0),t([a()],l.prototype,"_hasSubmenu",void 0),t([a()],l.prototype,"_hasIcon",void 0),t([a()],l.prototype,"_submenuExpanded",void 0),l=t([n("nile-context-menu-item")],l);export{l as N};
