/**
 * @license
 * Copyright Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { __decorate } from "tslib";
import { attachShadowTemplate, coerceBoolean, CustomElement, FoundationProperty, toggleAttribute } from '@tylertech/forge-core';
import { internals, setDefaultAria } from '../../constants';
import { BaseComponent } from '../../core/base/base-component';
import { WithDefaultAria } from '../../core/mixins/internals/with-default-aria';
import { WithElementInternals } from '../../core/mixins/internals/with-element-internals';
import { WithLabelAwareness } from '../../core/mixins/label/with-label-aware';
import { RadioComponent } from '../radio/radio';
import { RadioGroupAdapter } from './radio-group-adapter';
import { RADIO_GROUP_CONSTANTS } from './radio-group-constants';
import { RadioGroupFoundation } from './radio-group-foundation';
const template = '<template><slot></slot></template>';
/**
 * @tag forge-radio-group
 *
 * @summary The Forge Radio Group component groups a set of radio buttons together.
 *
 * @property {boolean} disabled - Whether or not the radio group is disabled.
 *
 * @attribute {boolean} disabled - Whether or not the radio group is disabled.
 */
let RadioGroupComponent = class RadioGroupComponent extends WithLabelAwareness(WithDefaultAria(WithElementInternals(BaseComponent))) {
    get form() {
        return this[internals].form;
    }
    get labels() {
        return this[internals].labels;
    }
    get name() {
        var _a;
        return (_a = this.getAttribute('name')) !== null && _a !== void 0 ? _a : '';
    }
    set name(value) {
        toggleAttribute(this, !!value, 'name', value);
    }
    static get observedAttributes() {
        return Object.values(RADIO_GROUP_CONSTANTS.observedAttributes);
    }
    constructor() {
        super();
        attachShadowTemplate(this, template);
        this._foundation = new RadioGroupFoundation(new RadioGroupAdapter(this));
    }
    connectedCallback() {
        this[setDefaultAria]({
            role: 'radiogroup',
            ariaDisabled: this.disabled ? 'true' : null
        });
        this._foundation.initialize();
    }
    attributeChangedCallback(name, oldValue, newValue) {
        switch (name) {
            case RADIO_GROUP_CONSTANTS.attributes.DISABLED:
                this.disabled = coerceBoolean(newValue);
                break;
        }
    }
    formDisabledCallback(isDisabled) {
        this.disabled = isDisabled;
    }
    labelChangedCallback(value) {
        this[setDefaultAria]({
            ariaLabel: value !== null && value !== void 0 ? value : null
        });
    }
};
RadioGroupComponent.formAssociated = true;
__decorate([
    FoundationProperty()
], RadioGroupComponent.prototype, "disabled", void 0);
RadioGroupComponent = __decorate([
    CustomElement({
        name: RADIO_GROUP_CONSTANTS.elementName,
        dependencies: [RadioComponent]
    })
], RadioGroupComponent);
export { RadioGroupComponent };
