'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const __chunk_1 = require('./chunk-c92d86f4.js');

class RadioGroup {
    constructor(hostRef) {
        __chunk_1.registerInstance(this, hostRef);
        this.change = __chunk_1.createEvent(this, "change", 7);
    }
    componentDidLoad() {
        const isRadioChecked = this.host.querySelector('materials-radio[checked]');
        this.value = isRadioChecked ? isRadioChecked.value : null;
        this.materialsRadioNodes = Array.from(this.host.querySelectorAll('materials-radio'));
        this.materialsRadioNodes.forEach((radioEl) => {
            radioEl.addEventListener('change', (value) => this.handleEvent(value));
        });
    }
    handleEvent(event) {
        event.stopPropagation();
        this.value = event.detail;
        this.cleanNeighbors(this.value);
        this.change.emit(this.value);
    }
    cleanNeighbors(except) {
        this.materialsRadioNodes.filter(el => !except || el.value !== except).forEach(el => el.checked = false);
    }
    render() {
        return (__chunk_1.h(__chunk_1.Host, { class: { 'linebreak': this.linebreak } }, this.label && __chunk_1.h("span", null, this.label), __chunk_1.h("slot", null)));
    }
    get host() { return __chunk_1.getElement(this); }
    static get style() { return ":host linebreak{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}"; }
}

exports.materials_radio_group = RadioGroup;
