import { r as o, c as s, h as r, H as d, g as n } from "./index.61732cef.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)}", c = 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: "7004ea866ef7bb6d89d94f303189cfc2a91bd858", "aria-describedby": this.swirlAriaDescribedby, role: "radiogroup" }, r("div", { key: "adb4ee3d7f60627ab5e9afdf5cce1ca0967ca811", class: "radio-group" }, r("slot", { key: "bde0e53f36ef4d92cfb1419883c90a9f758ede08" })));
  }
  get el() {
    return n(this);
  }
};
c.style = l();
export {
  c as swirl_radio_group
};
