import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
import { _ as __decorate, a as __metadata } from './tslib.es6.js';
import { b as isSpaceKey } from './index.esm.js';
import { a as ariaBooleanToString } from './aria.js';
import { i as inheritAttributes } from './attributes.js';
import { B as BEM } from './bem.js';
import { F as FOCUS_KEYS } from './focus-visible.js';
import { d as defaultBalAriaForm } from './form.js';
import { s as stopEventBubbling, i as inputSetFocus, a as inputSetBlur } from './form-input.js';
import { i as isDescendant } from './helpers.js';
import { L as Logger } from './log.js';
import { d as defineCustomElement$1 } from './bal-radio-icon2.js';
import { L as ListenToElementStates } from './element-states.decorator.js';

const balRadioCss = "@media (hover: hover)and (pointer: fine){.bal-radio.bal-focused{-webkit-box-shadow:var(--bal-focus-shadow) !important;box-shadow:var(--bal-focus-shadow) !important}}:root{--bal-radio-symbol-size:1.5rem;--bal-radio-symbol-border-width:2px;--bal-radio-symbol-background:transparent;--bal-radio-label-min-height:1.5rem;--bal-radio-button-background-hover:var(--bal-color-grey-2);--bal-radio-button-background-active:var(--bal-color-grey-2);--bal-radio-button-background-checked:var(--bal-color-primary);--bal-radio-button-background-checked-hover:var(--bal-color-light-blue-5);--bal-radio-button-background-checked-active:var(--bal-color-primary-6);--bal-radio-button-background-invalid:var(--bal-color-danger-1);--bal-radio-button-background-invalid-hover:var(--bal-color-danger-1);--bal-radio-button-background-invalid-active:var(--bal-color-danger-1);--bal-radio-button-background-invalid-checked:var(--bal-color-border-danger);--bal-radio-button-background-invalid-checked-hover:var(--bal-color-danger-5);--bal-radio-button-background-invalid-checked-active:var(--bal-color-danger-6);--bal-radio-button-background-disabled-hover-active:var(--bal-color-grey-2);--bal-radio-button-background-disabled-checked-hover-active:var(--bal-color-border-grey-dark);--bal-radio-button-background:transparent;--bal-radio-button-background-checked-green:var(--bal-color-green-1);--bal-radio-button-background-checked-purple:var(--bal-color-purple-1);--bal-radio-button-background-checked-red:var(--bal-color-red-1);--bal-radio-button-background-checked-yellow:var(--bal-color-yellow-1);--bal-radio-button-background-disabled:var(--bal-color-grey-1);--bal-radio-button-background-hover:var(--bal-color-grey-1);--bal-radio-button-border-color:var(--bal-color-primary);--bal-radio-button-border-color-hover:var(--bal-color-light-blue-5);--bal-radio-button-border-color-active:var(--bal-color-primary-6);--bal-radio-button-border-color-invalid:var(--bal-color-border-danger);--bal-radio-button-border-color-invalid-hover:var(--bal-color-danger-5);--bal-radio-button-border-color-invalid-active:var(--bal-color-danger-6);--bal-radio-button-border-color-invalid-checked:var(--bal-color-border-danger);--bal-radio-button-border-color-invalid-checked-hover:var(--bal-color-danger-5);--bal-radio-button-border-color-invalid-checked-active:var(--bal-color-danger-6);--bal-radio-button-border-color-disabled-hover-active:var(--bal-color-border-grey-dark);--bal-radio-button-border-color-disabled-checked-hover-active:var(--bal-color-border-grey-dark);--bal-radio-tile-background:transparent;--bal-radio-tile-background-hover:var(--bal-color-grey-1);--bal-radio-tile-background-disabled:var(--bal-color-grey-1);--bal-radio-tile-background-invalid-hover:var(--bal-color-danger-1);--bal-radio-tile-background-invalid-active:var(--bal-color-danger-1);--bal-radio-tile-background-checked-green:var(--bal-color-green-1);--bal-radio-tile-background-checked-purple:var(--bal-color-purple-1);--bal-radio-tile-background-checked-red:var(--bal-color-red-1);--bal-radio-tile-background-checked-yellow:var(--bal-color-yellow-1);--bal-radio-tile-border-style:var(--bal-form-field-control-border-style);--bal-radio-tile-border-radius:var(--bal-form-field-control-radius);--bal-radio-tile-border-width:var(--bal-form-field-control-border-width);--bal-radio-tile-padding:var(--bal-text-size-medium);--bal-radio-tile-border-color:var(--bal-color-border);--bal-radio-tile-border-color-hover:var(--bal-color-border-primary-hovered);--bal-radio-tile-border-color-active:var(--bal-color-border-primary-pressed);--bal-radio-tile-border-color-invalid-hover:var(--bal-color-border-danger-hovered);--bal-radio-tile-border-color-invalid-active:var(--bal-color-border-danger-pressed);--bal-radio-tile-border-color-checked:var(--bal-color-border-primary);--bal-radio-tile-border-color-invalid:var(--bal-color-border-danger);--bal-radio-tile-border-color-disabled:var(--bal-color-border-grey-dark)}.bal-radio{position:relative;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-pack:start;justify-content:flex-start;-ms-flex-align:center;align-items:center;outline:none;min-width:var(--bal-radio-symbol-size);border-radius:var(--bal-radius-normal);cursor:pointer}.bal-radio .bal-radio__label{cursor:pointer}.bal-radio--invisible{position:absolute !important;left:0;top:0;margin:0;padding:0;opacity:0;outline:0;border:none;width:1px;height:1px;clip:rect(1px, 1px, 1px, 1px);overflow:hidden}.bal-radio.bal-radio--flat{min-height:var(--bal-radio-symbol-size)}.bal-radio:not(.bal-radio--flat){min-height:3rem}.bal-radio--invalid{color:var(--bal-form-field-label-danger-color)}.bal-radio--disabled,.bal-radio--disabled .bal-radio__label{color:var(--bal-form-field-label-disabled-color);cursor:default}.bal-radio__input{position:absolute !important;left:0;top:0;margin:0;padding:0;opacity:0;outline:0;border:none;width:1px;height:1px;clip:rect(1px, 1px, 1px, 1px);overflow:hidden;width:100%;height:100%}.bal-radio__label{display:-ms-flexbox;display:flex;-ms-flex-pack:start;justify-content:flex-start;-ms-flex-align:center;align-items:center;gap:.5rem;-ms-flex-direction:row;flex-direction:row}.bal-radio__label__text{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;text-align:left;contain:layout style;font-family:var(--bal-font-family-text);padding-top:.25rem;padding-bottom:.25rem;width:100%}.bal-radio__label__text--hidden{display:none}.bal-radio__label__icon{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}@media (hover: hover)and (pointer: fine){.bal-radio:not(.bal-radio--button):not(.bal-radio--disabled):not(.bal-radio--invalid).bal-radio--hovered .bal-radio__label__text,.bal-radio:not(.bal-radio--button):not(.bal-radio--disabled):not(.bal-radio--invalid):hover .bal-radio__label__text{color:var(--bal-color-text-primary-hovered)}.bal-radio:not(.bal-radio--button):not(.bal-radio--disabled):not(.bal-radio--invalid).bal-radio--hovered .bal-radio__label__icon,.bal-radio:not(.bal-radio--button):not(.bal-radio--disabled):not(.bal-radio--invalid):hover .bal-radio__label__icon{color:var(--bal-color-text-primary-hovered)}}.bal-radio:not(.bal-radio--button):not(.bal-radio--disabled):not(.bal-radio--invalid).bal-radio--pressed .bal-radio__label__text,.bal-radio:not(.bal-radio--button):not(.bal-radio--disabled):not(.bal-radio--invalid):active .bal-radio__label__text{color:var(--bal-color-text-primary-pressed)}.bal-radio:not(.bal-radio--button):not(.bal-radio--disabled):not(.bal-radio--invalid).bal-radio--pressed .bal-radio__label__icon,.bal-radio:not(.bal-radio--button):not(.bal-radio--disabled):not(.bal-radio--invalid):active .bal-radio__label__icon{color:var(--bal-color-text-primary-pressed)}@media (hover: hover)and (pointer: fine){.bal-radio--invalid:not(.bal-radio--button):not(.bal-radio--disabled).bal-radio--hovered .bal-radio__label__text,.bal-radio--invalid:not(.bal-radio--button):not(.bal-radio--disabled):hover .bal-radio__label__text{color:var(--bal-color-text-danger-hovered)}.bal-radio--invalid:not(.bal-radio--button):not(.bal-radio--disabled).bal-radio--hovered .bal-radio__label__icon,.bal-radio--invalid:not(.bal-radio--button):not(.bal-radio--disabled):hover .bal-radio__label__icon{color:var(--bal-color-text-danger-hovered)}}.bal-radio--invalid:not(.bal-radio--button):not(.bal-radio--disabled).bal-radio--pressed .bal-radio__label__text,.bal-radio--invalid:not(.bal-radio--button):not(.bal-radio--disabled):active .bal-radio__label__text{color:var(--bal-color-text-danger-pressed)}.bal-radio--invalid:not(.bal-radio--button):not(.bal-radio--disabled).bal-radio--pressed .bal-radio__label__icon,.bal-radio--invalid:not(.bal-radio--button):not(.bal-radio--disabled):active .bal-radio__label__icon{color:var(--bal-color-text-danger-pressed)}.bal-radio--button{-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:wrap;flex-wrap:wrap;gap:var(--bal-space-x-small);-ms-flex-pack:center;justify-content:center;-ms-flex-align:start;align-items:flex-start;padding-left:.75rem;padding-right:.75rem;min-width:3rem;border-width:2px;border-style:var(--bal-form-field-control-border-style);border-radius:var(--bal-form-field-control-radius);border-color:var(--bal-radio-button-border-color)}.bal-radio--button.bal-radio--checked{background:var(--bal-radio-button-background-checked);color:var(--bal-color-white)}.bal-radio--button.bal-radio--checked .bal-radio__label__text,.bal-radio--button.bal-radio--checked .bal-radio__label__text .link{color:var(--bal-color-white)}.bal-radio--button.bal-radio--invalid{border-color:var(--bal-color-border-danger);color:var(--bal-color-text-danger-hovered);background:var(--bal-color-danger-1)}.bal-radio--button.bal-radio--invalid.bal-radio--checked{color:var(--bal-color-white);background:var(--bal-color-border-danger)}.bal-radio--button.bal-radio--invalid.bal-radio--checked .bal-radio__label__text,.bal-radio--button.bal-radio--invalid.bal-radio--checked .bal-radio__label__text .link{color:var(--bal-color-white)}.bal-radio--button.bal-radio--disabled{border-color:var(--bal-color-grey-4);background:var(--bal-color-grey-2)}.bal-radio--button.bal-radio--disabled .bal-radio__label__text{color:var(--bal-color-text-grey)}.bal-radio--button.bal-radio--disabled.bal-radio--checked{background:var(--bal-color-grey-4);color:var(--bal-color-white)}.bal-radio--button.bal-radio--disabled.bal-radio--checked .bal-radio__label__text,.bal-radio--button.bal-radio--disabled.bal-radio--checked .bal-radio__label__text .link{color:var(--bal-color-white)}@media (hover: hover)and (pointer: fine){.bal-radio--button:not(.bal-radio--disabled):not(.bal-radio--invalid).bal-radio--hovered,.bal-radio--button:not(.bal-radio--disabled):not(.bal-radio--invalid):hover{background:var(--bal-color-grey-2);border-color:var(--bal-color-border-primary-hovered)}.bal-radio--button:not(.bal-radio--disabled):not(.bal-radio--invalid).bal-radio--hovered .bal-radio__label__text,.bal-radio--button:not(.bal-radio--disabled):not(.bal-radio--invalid):hover .bal-radio__label__text{color:var(--bal-color-text-primary-hovered)}}.bal-radio--button:not(.bal-radio--disabled):not(.bal-radio--invalid).bal-radio--pressed,.bal-radio--button:not(.bal-radio--disabled):not(.bal-radio--invalid):active{background:var(--bal-color-grey-2);border-color:var(--bal-color-border-primary-pressed)}.bal-radio--button:not(.bal-radio--disabled):not(.bal-radio--invalid).bal-radio--pressed .bal-radio__label__text,.bal-radio--button:not(.bal-radio--disabled):not(.bal-radio--invalid):active .bal-radio__label__text{color:var(--bal-color-text-primary-pressed)}@media (hover: hover)and (pointer: fine){.bal-radio--button.bal-radio--checked:not(.bal-radio--disabled):not(.bal-radio--invalid).bal-radio--hovered,.bal-radio--button.bal-radio--checked:not(.bal-radio--disabled):not(.bal-radio--invalid):hover{background:var(--bal-color-border-primary-hovered);border-color:var(--bal-color-border-primary-hovered)}.bal-radio--button.bal-radio--checked:not(.bal-radio--disabled):not(.bal-radio--invalid).bal-radio--hovered .bal-radio__label__text,.bal-radio--button.bal-radio--checked:not(.bal-radio--disabled):not(.bal-radio--invalid):hover .bal-radio__label__text{color:var(--bal-color-white)}}.bal-radio--button.bal-radio--checked:not(.bal-radio--disabled):not(.bal-radio--invalid).bal-radio--pressed,.bal-radio--button.bal-radio--checked:not(.bal-radio--disabled):not(.bal-radio--invalid):active{background:var(--bal-color-border-primary-pressed);border-color:var(--bal-color-border-primary-pressed)}.bal-radio--button.bal-radio--checked:not(.bal-radio--disabled):not(.bal-radio--invalid).bal-radio--pressed .bal-radio__label__text,.bal-radio--button.bal-radio--checked:not(.bal-radio--disabled):not(.bal-radio--invalid):active .bal-radio__label__text{color:var(--bal-color-white)}@media (hover: hover)and (pointer: fine){.bal-radio--button.bal-radio--invalid:not(.bal-radio--disabled).bal-radio--hovered,.bal-radio--button.bal-radio--invalid:not(.bal-radio--disabled):hover{background:var(--bal-color-danger-1);border-color:var(--bal-color-border-danger-hovered)}.bal-radio--button.bal-radio--invalid:not(.bal-radio--disabled).bal-radio--hovered .bal-radio__label__text,.bal-radio--button.bal-radio--invalid:not(.bal-radio--disabled):hover .bal-radio__label__text{color:var(--bal-color-text-danger-hovered)}}.bal-radio--button.bal-radio--invalid:not(.bal-radio--disabled).bal-radio--pressed,.bal-radio--button.bal-radio--invalid:not(.bal-radio--disabled):active{background:var(--bal-color-danger-1);border-color:var(--bal-color-border-danger-pressed)}.bal-radio--button.bal-radio--invalid:not(.bal-radio--disabled).bal-radio--pressed .bal-radio__label__text,.bal-radio--button.bal-radio--invalid:not(.bal-radio--disabled):active .bal-radio__label__text{color:var(--bal-color-text-danger-pressed)}@media (hover: hover)and (pointer: fine){.bal-radio--button.bal-radio--invalid.bal-radio--checked:not(.bal-radio--disabled).bal-radio--hovered,.bal-radio--button.bal-radio--invalid.bal-radio--checked:not(.bal-radio--disabled):hover{background:var(--bal-color-border-danger-hovered);border-color:var(--bal-color-border-danger-hovered)}.bal-radio--button.bal-radio--invalid.bal-radio--checked:not(.bal-radio--disabled).bal-radio--hovered .bal-radio__label__text,.bal-radio--button.bal-radio--invalid.bal-radio--checked:not(.bal-radio--disabled):hover .bal-radio__label__text{color:var(--bal-color-white)}}.bal-radio--button.bal-radio--invalid.bal-radio--checked:not(.bal-radio--disabled).bal-radio--pressed,.bal-radio--button.bal-radio--invalid.bal-radio--checked:not(.bal-radio--disabled):active{background:var(--bal-color-border-danger-pressed);border-color:var(--bal-color-border-danger-pressed)}.bal-radio--button.bal-radio--invalid.bal-radio--checked:not(.bal-radio--disabled).bal-radio--pressed .bal-radio__label__text,.bal-radio--button.bal-radio--invalid.bal-radio--checked:not(.bal-radio--disabled):active .bal-radio__label__text{color:var(--bal-color-white)}.bal-radio--tile{display:block;-ms-flex:0 0 100%;flex:0 0 100%;background:var(--bal-radio-tile-background);border-style:var(--bal-radio-tile-border-style);border-radius:var(--bal-radio-tile-border-radius);border-width:var(--bal-radio-tile-border-width);border-color:var(--bal-radio-tile-border-color);padding:var(--bal-radio-tile-padding)}.bal-radio--tile .bal-radio__label{height:100%;-ms-flex-align:stretch;align-items:stretch}.bal-radio--tile.bal-radio--checked{border-color:var(--bal-radio-tile-border-color-checked)}.bal-radio--tile.bal-radio--invalid{border-color:var(--bal-radio-tile-border-color-invalid)}.bal-radio--tile.bal-radio--disabled{background:var(--bal-radio-tile-background-disabled);border-color:var(--bal-radio-tile-border-color-disabled);cursor:default}@media (hover: hover)and (pointer: fine){.bal-radio--tile:not(.bal-radio--disabled):not(.bal-radio--invalid).bal-radio--hovered,.bal-radio--tile:not(.bal-radio--disabled):not(.bal-radio--invalid):hover{background:var(--bal-radio-tile-background-hover);border-color:var(--bal-radio-tile-border-color-hover)}}.bal-radio--tile:not(.bal-radio--disabled):not(.bal-radio--invalid).bal-radio--pressed,.bal-radio--tile:not(.bal-radio--disabled):not(.bal-radio--invalid):active{background:var(--bal-radio-tile-background-hover);border-color:var(--bal-radio-tile-border-color-active)}@media (hover: hover)and (pointer: fine){.bal-radio--tile.bal-radio--invalid:not(.bal-radio--disabled).bal-radio--hovered,.bal-radio--tile.bal-radio--invalid:not(.bal-radio--disabled):hover{background:var(--bal-radio-tile-background-invalid-hover);border-color:var(--bal-radio-tile-border-color-invalid-hover)}}.bal-radio--tile.bal-radio--invalid:not(.bal-radio--disabled).bal-radio--pressed,.bal-radio--tile.bal-radio--invalid:not(.bal-radio--disabled):active{background:var(--bal-radio-tile-background-invalid-active);border-color:var(--bal-radio-tile-border-color-invalid-active)}.bal-radio--tile-color-green:not(.bal-radio--disabled).bal-radio--checked,.bal-radio--tile-color-green:not(.bal-radio--disabled).bal-radio--checked.bal-radio--hovered,.bal-radio--tile-color-green:not(.bal-radio--disabled).bal-radio--checked:hover{background:var(--bal-radio-tile-background-checked-green)}.bal-radio--tile-color-red:not(.bal-radio--disabled).bal-radio--checked,.bal-radio--tile-color-red:not(.bal-radio--disabled).bal-radio--checked.bal-radio--hovered,.bal-radio--tile-color-red:not(.bal-radio--disabled).bal-radio--checked:hover{background:var(--bal-radio-tile-background-checked-red)}.bal-radio--tile-color-purple:not(.bal-radio--disabled).bal-radio--checked,.bal-radio--tile-color-purple:not(.bal-radio--disabled).bal-radio--checked.bal-radio--hovered,.bal-radio--tile-color-purple:not(.bal-radio--disabled).bal-radio--checked:hover{background:var(--bal-radio-tile-background-checked-purple)}.bal-radio--tile-color-yellow:not(.bal-radio--disabled).bal-radio--checked,.bal-radio--tile-color-yellow:not(.bal-radio--disabled).bal-radio--checked.bal-radio--hovered,.bal-radio--tile-color-yellow:not(.bal-radio--disabled).bal-radio--checked:hover{background:var(--bal-radio-tile-background-checked-yellow)}@media screen and (min-width: 769px),print{.bal-radio--column-2{-ms-flex:0 0 calc(50% - var(--bal-space-normal)*1/2);flex:0 0 calc(50% - var(--bal-space-normal)*1/2)}.bal-radio--column-3{-ms-flex:0 0 calc(33.3333333333% - var(--bal-space-normal)*2/3);flex:0 0 calc(33.3333333333% - var(--bal-space-normal)*2/3)}.bal-radio--column-4{-ms-flex:0 0 calc(25% - var(--bal-space-normal)*3/4);flex:0 0 calc(25% - var(--bal-space-normal)*3/4)}}@media screen and (max-width: 768px){.bal-radio--column-mobile-2{-ms-flex:0 0 calc(50% - var(--bal-space-normal)*1/2);flex:0 0 calc(50% - var(--bal-space-normal)*1/2)}.bal-radio--column-mobile-3{-ms-flex:0 0 calc(33.3333333333% - var(--bal-space-normal)*2/3);flex:0 0 calc(33.3333333333% - var(--bal-space-normal)*2/3)}.bal-radio--column-mobile-4{-ms-flex:0 0 calc(25% - var(--bal-space-normal)*3/4);flex:0 0 calc(25% - var(--bal-space-normal)*3/4)}}@media screen and (min-width: 769px),print{.bal-radio--column-tablet-2{-ms-flex:0 0 calc(50% - var(--bal-space-normal)*1/2);flex:0 0 calc(50% - var(--bal-space-normal)*1/2)}.bal-radio--column-tablet-3{-ms-flex:0 0 calc(33.3333333333% - var(--bal-space-normal)*2/3);flex:0 0 calc(33.3333333333% - var(--bal-space-normal)*2/3)}.bal-radio--column-tablet-4{-ms-flex:0 0 calc(25% - var(--bal-space-normal)*3/4);flex:0 0 calc(25% - var(--bal-space-normal)*3/4)}}@media screen and (min-width: 1024px){.bal-radio--column-2{-ms-flex:0 0 calc(50% - var(--bal-space-normal)*1/2);flex:0 0 calc(50% - var(--bal-space-normal)*1/2)}.bal-radio--column-3{-ms-flex:0 0 calc(33.3333333333% - var(--bal-space-normal)*2/3);flex:0 0 calc(33.3333333333% - var(--bal-space-normal)*2/3)}.bal-radio--column-4{-ms-flex:0 0 calc(25% - var(--bal-space-normal)*3/4);flex:0 0 calc(25% - var(--bal-space-normal)*3/4)}}";

const Radio = /*@__PURE__*/ proxyCustomElement(class Radio extends HTMLElement {
    constructor(registerHost) {
        super();
        if (registerHost !== false) {
            this.__registerHost();
        }
        this.balFocus = createEvent(this, "balFocus", 7);
        this.balBlur = createEvent(this, "balBlur", 7);
        this.balChange = createEvent(this, "balChange", 7);
        this.inputId = `bal-rb-${radioIds++}`;
        this.inheritedAttributes = {};
        this.keyboardMode = true;
        /**
         * Track focus state
         * If `true` checkbox needs to remain focused
         */
        this.wasFocused = false;
        this.checked = false;
        this.focused = false;
        this.ariaForm = defaultBalAriaForm;
        this.outerElementState = {
            hovered: false,
            pressed: false,
        };
        this.innerElementState = {
            hovered: false,
            pressed: false,
        };
        this.mergedElementState = {
            hovered: false,
            pressed: false,
        };
        /**
         * PUBLIC PROPERTY API
         * ------------------------------------------------------
         */
        /**
         * The name of the control, which is submitted with the form data.
         */
        this.name = this.inputId;
        /**
         * Label of the radio item.
         */
        this.label = '';
        /**
         * If `true` the radio has no label
         */
        this.labelHidden = false;
        /**
         * If `true` the control is no padding
         */
        this.flat = false;
        /**
         * Defines the layout of the radio button
         */
        this.interface = 'radio';
        /**
         * If `true`, the element is not mutable, focusable, or even submitted with the form. The user can neither edit nor focus on the control, nor its form control descendants.
         */
        this.disabled = false;
        /**
         * If `true` the element can not mutated, meaning the user can not edit the control.
         */
        this.readonly = false;
        /**
         * If `true`, the user must fill in a value before submitting a form.
         */
        this.required = false;
        /**
         * If `true`, the value will not be send with a form submit
         */
        this.nonSubmit = false;
        /**
         * If `true` the component gets a invalid style.
         */
        this.invalid = false;
        /**
         * @internal
         */
        this.hovered = false;
        /**
         * @internal
         */
        this.pressed = false;
        /**
         * @internal
         */
        this.colSize = 1;
        /**
         * @internal
         */
        this.colSizeTablet = 1;
        /**
         * @internal
         */
        this.colSizeMobile = 1;
        this.setChecked = (state) => {
            this.checked = state;
            this.balChange.emit(this.checked);
        };
        this.toggleChecked = (ev) => {
            ev.preventDefault();
            this.setFocus();
            this.checked = true;
            this.setChecked(this.checked);
        };
        this.onClick = (ev) => {
            if (this.disabled) {
                return;
            }
            const element = ev.target;
            if (element.href) {
                return;
            }
            if (this.wasFocused) {
                this.focused = true;
            }
            this.toggleChecked(ev);
        };
        this.onFocus = (ev) => {
            if (this.disabled || this.readonly) {
                this.focused = false;
                return stopEventBubbling(ev);
            }
            this.balFocus.emit(ev);
            if (this.keyboardMode) {
                this.focused = true;
                this.wasFocused = true;
            }
        };
        this.onBlur = (ev) => {
            if (this.disabled || this.readonly) {
                return stopEventBubbling(ev);
            }
            this.balBlur.emit(ev);
            this.focused = false;
        };
        this.onPointerDown = () => (this.keyboardMode = false);
        this.onKeydown = (ev) => {
            if (!isSpaceKey(ev)) {
                this.wasFocused = false;
            }
            this.keyboardMode = FOCUS_KEYS.includes(ev.key);
        };
    }
    createLogger(log) {
        this.log = log;
    }
    hoveredChanged() {
        this.innerElementState = {
            hovered: this.hovered,
            pressed: this.pressed,
        };
        this.mergeElementState();
    }
    pressedChanged() {
        this.innerElementState = {
            hovered: this.hovered,
            pressed: this.pressed,
        };
        this.mergeElementState();
    }
    /**
     * LIFECYCLE
     * ------------------------------------------------------
     */
    connectedCallback() {
        this.hoveredChanged();
        if (this.value === undefined) {
            this.value = this.inputId;
        }
        if (this.group) {
            this.updateState();
            this.group.addEventListener('balChange', this.updateState);
        }
        this.el.addEventListener('keydown', this.onKeydown);
        this.el.addEventListener('touchstart', this.onPointerDown);
        this.el.addEventListener('mousedown', this.onPointerDown);
    }
    componentWillLoad() {
        this.inheritedAttributes = inheritAttributes(this.el, ['aria-label', 'tabindex', 'title']);
    }
    componentWillRender() {
        this.interactionChildElements.forEach(el => {
            el.disabled = this.disabled || this.readonly;
            el.invalid = this.invalid;
            el.checked = this.checked;
        });
    }
    disconnectedCallback() {
        if (this.group) {
            this.group.removeEventListener('balChange', this.updateState);
        }
        this.el.removeEventListener('keydown', this.onKeydown);
        this.el.removeEventListener('touchstart', this.onPointerDown);
        this.el.removeEventListener('mousedown', this.onPointerDown);
    }
    /**
     * LISTENERS
     * ------------------------------------------------------
     */
    listenOnClick(ev) {
        if ((this.disabled || this.readonly) &&
            ev.target &&
            (ev.target === this.el || isDescendant(this.el, ev.target))) {
            stopEventBubbling(ev);
        }
    }
    elementStateListener(info) {
        this.outerElementState = info;
        this.mergeElementState();
    }
    /**
     * PUBLIC METHODS
     * ------------------------------------------------------
     */
    /**
     * Sets the focus on the checkbox input element.
     */
    async setFocus() {
        inputSetFocus(this);
    }
    /**
     * Sets blur on the native `input`. Use this method instead of the global
     * `input.blur()`.
     * @internal
     */
    async setBlur() {
        inputSetBlur(this);
    }
    /** @internal */
    async setButtonTabindex(value) {
        this.buttonTabindex = value;
    }
    /**
     * Returns the native `<input>` element used under the hood.
     */
    async getInputElement() {
        return Promise.resolve(this.nativeInput);
    }
    /**
     * Options of the tab like label, value etc.
     */
    async getOption() {
        return this.option;
    }
    /**
     * @internal
     * Options of the tab like label, value etc.
     */
    async updateState() {
        if (this.group) {
            const newChecked = this.group.value === this.value;
            if (newChecked !== this.checked) {
                this.checked = newChecked;
            }
        }
    }
    /**
     * @internal
     */
    async setAriaForm(ariaForm) {
        this.ariaForm = Object.assign({}, ariaForm);
    }
    /**
     * GETTERS
     * ------------------------------------------------------
     */
    get group() {
        return this.el.closest('bal-radio-group');
    }
    get interactionChildElements() {
        return Array.from(this.el.querySelectorAll('bal-radio-icon, bal-icon'));
    }
    get option() {
        return {
            name: this.name,
            value: this.value,
            label: this.label,
            labelHidden: this.labelHidden,
            flat: this.flat,
            interface: this.interface,
            disabled: this.disabled,
            readonly: this.readonly,
            required: this.required,
            nonSubmit: this.nonSubmit,
            invalid: this.invalid,
        };
    }
    /**
     * EVENT BINDING
     * ------------------------------------------------------
     */
    mergeElementState() {
        this.mergedElementState = {
            hovered: this.outerElementState.hovered || this.innerElementState.hovered,
            pressed: this.outerElementState.pressed || this.innerElementState.pressed,
        };
        this.interactionChildElements.forEach(el => {
            el.hovered = this.mergedElementState.hovered;
            el.pressed = this.mergedElementState.pressed;
        });
    }
    /**
     * RENDER
     * ------------------------------------------------------
     */
    render() {
        const block = BEM.block('radio');
        const inputEl = block.element('input');
        const labelEl = block.element('label');
        const labelTextEl = labelEl.element('text');
        const labelIconEl = labelEl.element('icon');
        const focused = this.focused && this.buttonTabindex !== -1;
        const value = typeof this.value === 'boolean' ? JSON.stringify(this.value) : this.value;
        const hasFormControl = !this.nonSubmit;
        const id = this.ariaForm.controlId || this.inputId;
        const labelId = this.ariaForm.labelId || null;
        const LabelTag = hasFormControl ? 'label' : 'span';
        const inputAttributes = this.inheritedAttributes;
        if (this.buttonTabindex !== undefined) {
            inputAttributes.tabIndex = this.buttonTabindex;
        }
        if (this.labelHidden) {
            inputAttributes['aria-labelledby'] = labelId;
        }
        return (h(Host, { key: 'faa44091416d0505e2d84a792bd49f5eab82f897', "aria-checked": `${this.checked}`, "aria-disabled": ariaBooleanToString(this.disabled), "aria-invalid": this.invalid === true ? 'true' : 'false', "aria-hidden": this.disabled ? 'true' : null, "aria-focused": focused ? 'true' : null, "aria-labelledby": labelId, "aria-describedby": this.ariaForm.messageId, class: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ 'bal-focused': focused }, block.class()), block.modifier('button').class(this.interface === 'button')), block.modifier('tile').class(this.interface === 'tile')), block.modifier(`tile-color-${this.color}`).class(this.interface === 'tile' && !!this.color)), block.modifier('invalid').class(this.invalid)), block.modifier('checked').class(this.checked)), block.modifier('flat').class(this.flat)), block.modifier('disabled').class(this.disabled || this.readonly)), block.modifier('hovered').class(this.hovered)), block.modifier('pressed').class(this.pressed)), block.modifier(`column-${this.colSize}`).class(this.interface === 'tile' && this.colSize > 1)), block
                .modifier(`column-tablet-${this.colSizeTablet}`)
                .class(this.interface === 'tile' && this.colSizeTablet > 1)), block
                .modifier(`column-mobile-${this.colSizeMobile}`)
                .class(this.interface === 'tile' && this.colSizeMobile > 1)), onClick: this.onClick }, h(LabelTag, { key: '3588b099302b821eccd777ae3149744f53a97834', class: Object.assign({}, labelEl.class()), "data-testid": "bal-radio-label" }, hasFormControl ? (h("input", Object.assign({ id: id, type: "radio", "data-testid": "bal-radio-input", name: this.name, value: value, checked: this.checked, required: this.required, disabled: this.disabled || this.nonSubmit, readonly: this.readonly, class: Object.assign({}, inputEl.class()), "aria-hidden": ariaBooleanToString(this.nonSubmit), "aria-invalid": this.invalid === true ? 'true' : 'false', "aria-describedby": this.ariaForm.messageId, onChange: ev => this.toggleChecked(ev), onFocus: ev => this.onFocus(ev), onBlur: ev => this.onBlur(ev), ref: inputEl => (this.nativeInput = inputEl) }, inputAttributes))) : (''), this.interface !== 'tile' ? (h("div", { class: Object.assign({}, labelIconEl.class()) }, h("bal-radio-icon", { checked: this.checked, disabled: this.disabled || this.readonly, invalid: this.invalid, inverted: this.interface === 'button' && this.checked, hovered: this.mergedElementState.hovered, pressed: this.mergedElementState.pressed }))) : (''), h("div", { key: '599fda9c376491dcb156c0b3fa8ecd41353027a8', class: Object.assign(Object.assign({}, labelTextEl.class()), labelTextEl.modifier('hidden').class(this.labelHidden)) }, h("slot", { key: '752d10816299c2f7840ae907b426501a76ae8d23' })))));
    }
    get el() { return this; }
    static get watchers() { return {
        "hovered": ["hoveredChanged"],
        "pressed": ["pressedChanged"]
    }; }
    static get style() { return balRadioCss; }
}, [260, "bal-radio", {
        "name": [1],
        "value": [8],
        "label": [1],
        "labelHidden": [4, "label-hidden"],
        "flat": [4],
        "interface": [1],
        "disabled": [4],
        "readonly": [4],
        "required": [4],
        "nonSubmit": [4, "non-submit"],
        "invalid": [4],
        "hovered": [4],
        "pressed": [4],
        "color": [1],
        "colSize": [2, "col-size"],
        "colSizeTablet": [2, "col-size-tablet"],
        "colSizeMobile": [2, "col-size-mobile"],
        "wasFocused": [32],
        "checked": [32],
        "focused": [32],
        "buttonTabindex": [32],
        "ariaForm": [32],
        "mergedElementState": [32],
        "setFocus": [64],
        "setBlur": [64],
        "setButtonTabindex": [64],
        "getInputElement": [64],
        "getOption": [64],
        "updateState": [64],
        "setAriaForm": [64]
    }, [[6, "click", "listenOnClick"]], {
        "hovered": ["hoveredChanged"],
        "pressed": ["pressedChanged"]
    }]);
__decorate([
    Logger('bal-radio'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Function]),
    __metadata("design:returntype", void 0)
], Radio.prototype, "createLogger", null);
__decorate([
    ListenToElementStates(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", void 0)
], Radio.prototype, "elementStateListener", null);
let radioIds = 0;
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["bal-radio", "bal-radio-icon"];
    components.forEach(tagName => { switch (tagName) {
        case "bal-radio":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, Radio);
            }
            break;
        case "bal-radio-icon":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}

export { Radio as R, defineCustomElement as d };
