import { r as i, c as g, h as o, g as r } from "./index.e6beb8d9.js";
import { c as l } from "./index-orsBiyT_.fc4357c3.js";
import "react";
import "react-dom";
const a = () => ":host{display:inline-block}:host *{box-sizing:border-box}.toggle-group{padding:var(--s-space-2);background-color:var(--s-surface-sunken-default);border-radius:var(--s-space-8);transition:box-shadow 0.3s}.toggle-group--elevated{box-shadow:var(--s-shadow-level-2)}.toggle-group--variant-outline{outline:var(--s-border-width-default) solid var(--s-border-strong);outline-offset:calc(var(--s-border-width-default) * -1)}", n = class {
  constructor(t) {
    i(this, t), this.selectedToggleChange = g(this, "selectedToggleChange", 7), this.variant = "flat", this.toggleButtons = [], this.onSlotChange = () => {
      this.toggleButtons = Array.from(this.el.querySelectorAll("swirl-toggle-button")), this.setTogglePressedStates();
    };
  }
  watchSelectedToggleId(t, e) {
    t !== e && (this.selectedToggleChange.emit(t), this.setTogglePressedStates());
  }
  onClick(t) {
    const e = t.target;
    if ((e == null ? void 0 : e.tagName) === "SWIRL-TOGGLE-BUTTON") {
      t.stopPropagation();
      const s = e;
      this.selectedToggleId = s.identifier;
    }
  }
  setTogglePressedStates() {
    var e;
    if (!((e = this.toggleButtons) != null && e.length))
      return;
    if (!this.selectedToggleId) {
      this.toggleButtonWithId(this.toggleButtons[0].identifier);
      return;
    }
    if (!this.toggleButtons.some((s) => s.identifier === this.selectedToggleId)) {
      this.toggleButtonWithId(this.toggleButtons[0].identifier);
      return;
    }
    this.toggleButtonWithId(this.selectedToggleId);
  }
  toggleButtonWithId(t) {
    var e;
    !((e = this.toggleButtons) != null && e.length) || this.toggleButtons.forEach((s) => {
      s.identifier === t ? s.isPressed = !0 : s.isPressed = !1;
    });
  }
  render() {
    const t = l("toggle-group", `toggle-group--variant-${this.variant}`, {
      "toggle-group--elevated": this.elevated
    });
    return o("swirl-stack", { key: "86db70a77b4c71c52533392d8daab961555c0224", class: t, "aria-label": this.swirlAriaLabel, spacing: "4", orientation: "horizontal", align: "center", role: "group" }, o("slot", { key: "4f6742043f6e16c0953c7ec069ff7e4e2c2c1406", onSlotchange: this.onSlotChange }));
  }
  get el() {
    return r(this);
  }
  static get watchers() {
    return {
      selectedToggleId: [{
        watchSelectedToggleId: 0
      }]
    };
  }
};
n.style = a();
export {
  n as swirl_toggle_group
};
