import{r as t,h as o,g as s}from"./p-dfbe004d.js";const n=class{constructor(o){t(this,o)}findButton(t){return["sc-button"].includes(t.tagName.toLowerCase())?t:t.querySelector(["sc-button"].join(","))}handleFocus(t){const o=this.findButton(t.target);null==o||o.classList.add("sc-button-group__button--focus")}handleBlur(t){const o=this.findButton(t.target);null==o||o.classList.remove("sc-button-group__button--focus")}handleMouseOver(t){const o=this.findButton(t.target);null==o||o.classList.add("sc-button-group__button--hover")}handleMouseOut(t){const o=this.findButton(t.target);null==o||o.classList.remove("sc-button-group__button--hover")}handleSlotChange(){if(this.separate)return;const t=this.el.shadowRoot.querySelector("slot").assignedElements({flatten:!0});t.forEach((o=>{const s=this.el.shadowRoot.querySelector("slot").assignedNodes().indexOf(o),n=this.findButton(o);null===n&&this.separate||(n.classList.add("sc-button-group__button"),n.classList.toggle("sc-button-group__button--first",0===s),n.classList.toggle("sc-button-group__button--inner",s>0&&s<t.length-1),n.classList.toggle("sc-button-group__button--last",s===t.length-1))}))}render(){return o("sc-form-control",{part:"base",class:{"button-group":!0,"button-group--separate":this.separate},role:"group","aria-label":this.label,onFocusout:t=>this.handleBlur(t),onFocusin:t=>this.handleFocus(t),onMouseOver:t=>this.handleMouseOver(t),onMouseOut:t=>this.handleMouseOut(t),label:this.label},o("slot",{onSlotchange:()=>this.handleSlotChange()}))}get el(){return s(this)}};n.style=":host{display:inline-block;--gap:var(--sc-spacing-small)}.button-group{display:flex;flex-wrap:wrap}.button-group--separate{gap:var(--gap)}";export{n as sc_button_group}