import{button_group_styles_default as t}from"./chunk.WISH4DLW.js";import{ShoelaceElement as o}from"./chunk.Z7XDKKOD.js";import{__decorateClass as s}from"./chunk.6M63UXML.js";import{html as l}from"../../../../lit/index.js";import{property as e,query as n,state as u}from"../../../../lit/decorators.js";var r=class extends o{constructor(){super(...arguments),this.disableRole=!1,this.label=""}handleFocus(t){const o=findButton(t.target);null==o||o.classList.add("sl-button-group__button--focus")}handleBlur(t){const o=findButton(t.target);null==o||o.classList.remove("sl-button-group__button--focus")}handleMouseOver(t){const o=findButton(t.target);null==o||o.classList.add("sl-button-group__button--hover")}handleMouseOut(t){const o=findButton(t.target);null==o||o.classList.remove("sl-button-group__button--hover")}handleSlotChange(){const t=[...this.defaultSlot.assignedElements({flatten:!0})];t.forEach((o=>{const s=t.indexOf(o),l=findButton(o);l&&(l.classList.add("sl-button-group__button"),l.classList.toggle("sl-button-group__button--first",0===s),l.classList.toggle("sl-button-group__button--inner",s>0&&s<t.length-1),l.classList.toggle("sl-button-group__button--last",s===t.length-1),l.classList.toggle("sl-button-group__button--radio","sl-radio-button"===l.tagName.toLowerCase()))}))}render(){return l`
      <div
        part="base"
        class="button-group"
        role="${this.disableRole?"presentation":"group"}"
        aria-label=${this.label}
        @focusout=${this.handleBlur}
        @focusin=${this.handleFocus}
        @mouseover=${this.handleMouseOver}
        @mouseout=${this.handleMouseOut}
      >
        <slot @slotchange=${this.handleSlotChange}></slot>
      </div>
    `}};function findButton(t){var o;const s="sl-button, sl-radio-button";return null!=(o=t.closest(s))?o:t.querySelector(s)}r.styles=t,s([n("slot")],r.prototype,"defaultSlot",2),s([u()],r.prototype,"disableRole",2),s([e()],r.prototype,"label",2);export{r as SlButtonGroup};