import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-ClISz4NF.js';
import { d as FormRadioGroupClass, F as FormGroupClass, a as FormGroupSizes, b as FormGroupOrientation } from './constants-Du0ZtfYe.js';
import { g as govHost } from './template-CoD1xawt.js';
import { v as validateProp } from './props-CJZgTDla.js';
import { t as tick } from './stencil.utils-Cjg0wpDG.js';
import './utils-CQvUntGY.js';
import './sizes-BcQO4NH2.js';
import './gov.log-BtqD9K8d.js';

const govFormGroupCss = "gov-form-group,.gov-form-group,gov-form-radio-group,.gov-form-radio-group,gov-form-checkbox-group,.gov-form-checkbox-group{margin-top:0;margin-bottom:0;position:relative;display:flex;width:100%;flex-direction:column;align-items:flex-start}gov-form-group .gov-form-label__label,.gov-form-group .gov-form-label__label,gov-form-radio-group .gov-form-label__label,.gov-form-radio-group .gov-form-label__label,gov-form-checkbox-group .gov-form-label__label,.gov-form-checkbox-group .gov-form-label__label{margin:0}gov-form-group[orientation=horizontal],.gov-form-group[orientation=horizontal],gov-form-radio-group[orientation=horizontal],.gov-form-radio-group[orientation=horizontal],gov-form-checkbox-group[orientation=horizontal],.gov-form-checkbox-group[orientation=horizontal]{flex-direction:row;flex-wrap:wrap}gov-form-group[orientation=horizontal] .gov-form-label__label,.gov-form-group[orientation=horizontal] .gov-form-label__label,gov-form-radio-group[orientation=horizontal] .gov-form-label__label,.gov-form-radio-group[orientation=horizontal] .gov-form-label__label,gov-form-checkbox-group[orientation=horizontal] .gov-form-label__label,.gov-form-checkbox-group[orientation=horizontal] .gov-form-label__label{white-space:nowrap}gov-form-group[gap=xs],.gov-form-group[gap=xs],gov-form-radio-group[gap=xs],.gov-form-radio-group[gap=xs],gov-form-checkbox-group[gap=xs],.gov-form-checkbox-group[gap=xs]{gap:var(--gap, var(--spacing-xs-nudge))}gov-form-group[gap=s],.gov-form-group[gap=s],gov-form-radio-group[gap=s],.gov-form-radio-group[gap=s],gov-form-checkbox-group[gap=s],.gov-form-checkbox-group[gap=s]{gap:var(--gap, var(--spacing-s))}gov-form-group[gap=m],.gov-form-group[gap=m],gov-form-radio-group[gap=m],.gov-form-radio-group[gap=m],gov-form-checkbox-group[gap=m],.gov-form-checkbox-group[gap=m]{gap:var(--gap, var(--spacing-m))}gov-form-group[gap=l],.gov-form-group[gap=l],gov-form-radio-group[gap=l],.gov-form-radio-group[gap=l],gov-form-checkbox-group[gap=l],.gov-form-checkbox-group[gap=l]{gap:var(--gap, var(--spacing-l))}gov-form-group[gap=xl],.gov-form-group[gap=xl],gov-form-radio-group[gap=xl],.gov-form-radio-group[gap=xl],gov-form-checkbox-group[gap=xl],.gov-form-checkbox-group[gap=xl]{gap:var(--gap, var(--spacing-xl))}";

const GovFormRadioGroup = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.govChange = createEvent(this, "gov-change");
        /**
         * Gap's size.
         */
        this.gap = undefined;
        /**
         * Elements orientation
         */
        this.orientation = 'vertical';
        /**
         * Group's value
         */
        this.value = undefined;
        this.handleChange = (event) => {
            event.stopPropagation();
            this.value = event.detail.value;
            this.govChange.emit({
                value: this.value,
                component: FormRadioGroupClass.root,
            });
        };
        this.h = govHost(this.host);
    }
    validateGap(newValue) {
        if (newValue) {
            validateProp(FormGroupSizes, newValue, FormGroupClass.root);
        }
    }
    validateOrientation(newValue) {
        if (newValue) {
            validateProp(FormGroupOrientation, newValue, FormGroupClass.root);
        }
    }
    componentWillLoad() {
        this.validateGap(this.gap);
        this.validateOrientation(this.orientation);
    }
    componentDidRender() {
        tick(() => this.rerenderComponent());
    }
    rerenderComponent() {
        this.host.querySelectorAll('gov-form-radio').forEach((element) => {
            if (!element.hasAttribute('listener-attached')) {
                element.addEventListener('gov-change', this.handleChange);
            }
            element.setAttribute('listener-attached', 'true');
            element.checked = element.value === this.value;
        });
    }
    render() {
        return (h(Host, { key: 'ff3703e838e4b031b4826be5e54679bf64872eb4', gap: this.gap, class: this.h.classes(FormGroupClass.root), value: this.value }, h("slot", { key: 'a2536dadd509602565fd860ebc6d9c4a148b468c' })));
    }
    get host() { return getElement(this); }
    static get watchers() { return {
        "gap": ["validateGap"],
        "orientation": ["validateOrientation"]
    }; }
};
GovFormRadioGroup.style = govFormGroupCss;

export { GovFormRadioGroup as gov_form_radio_group };
//# sourceMappingURL=gov-form-radio-group.entry.js.map

//# sourceMappingURL=gov-form-radio-group.entry.js.map