import { r as o, c as s, h as r, H as d, g as n } from "./index.e6beb8d9.js";
import "react";
import "react-dom";
const l = () => ".sc-swirl-radio-group-h{display:block}.sc-swirl-radio-group-h *.sc-swirl-radio-group{box-sizing:border-box}.radio-group.sc-swirl-radio-group{display:flex;flex-direction:column;gap:var(--s-space-12)}", h = class {
  constructor(e) {
    o(this, e), this.valueChange = s(this, "valueChange", 7), this.componentLoaded = !1, this.onRadioValueChange = (a) => {
      a.stopPropagation();
      const i = a.target;
      (i.checked === !0 || i.checked === "true") && (this.value = i.value, this.valueChange.emit(i.value), this.radioButtons.forEach((t) => {
        t !== i && (t.checked = !1);
      }));
    };
  }
  connectedCallback() {
    this.componentLoaded && this.addValueChangeListeners();
  }
  componentDidLoad() {
    this.radioButtons = Array.from(this.el.querySelectorAll("swirl-radio")), this.initValue(), this.addValueChangeListeners(), this.componentLoaded = !0;
  }
  disconnectedCallback() {
    this.removeValueChangeListeners();
  }
  initValue() {
    if (this.value === void 0)
      return;
    const e = this.radioButtons.find((a) => a.value === this.value);
    !Boolean(e) || (e.checked = !0);
  }
  addValueChangeListeners() {
    this.radioButtons.forEach((e) => {
      e.addEventListener("valueChange", this.onRadioValueChange);
    });
  }
  removeValueChangeListeners() {
    var e;
    (e = this.radioButtons) == null || e.forEach((a) => {
      a.removeEventListener("valueChange", this.onRadioValueChange);
    });
  }
  render() {
    return r(d, { key: "02a2ceb9ec09ed6ecf211ea675ca8a2d3d13b67d", "aria-describedby": this.swirlAriaDescribedby, role: "radiogroup" }, r("div", { key: "e04e1f71d856aa60d66a633e2df5534f10511359", class: "radio-group" }, r("slot", { key: "ed6352ae3e37b9d8dda44e58d87dafcd548364a5" })));
  }
  get el() {
    return n(this);
  }
};
h.style = l();
export {
  h as swirl_radio_group
};
