// #region Imports
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Appearanceable } from '../../../Behaviors/Appearanceable';
import { Disableable } from '../../../Behaviors/Disableable';
import { Invalidable } from '../../../Behaviors/Invalidable';
import { Labelable } from '../../../Behaviors/Labelable';
import { Valueable } from '../../../Behaviors/Valueable';
import { Variantable } from '../../../Behaviors/Variantable';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { QueryChild } from '../../../Decorators/QueryChildDecorator';
import { IconPosition } from '../../../Types/IconPosition';
import { IconElement } from '../../Media/Icon/IconElement';
import { ToggableElement } from '../../Primitives/Abstracts/Toggable/ToggableElement';
import { CheckmarkElement } from '../../Primitives/Checkmark/CheckmarkElement';
import { FocusRingElement } from '../../Primitives/FocusRing/FocusRingElement';
import { TextElement } from '../../Primitives/Text/TextElement';
import { choiceElementTemplate } from './ChoiceElementTemplate';
import { choiceElementJoyStyle } from './Themes/ChoiceElement.Joy';
import { choiceElementRetroStyle } from './Themes/ChoiceElement.Retro';
import { choiceElementCosmopolitanStyle } from './Themes/ChoiceElement.Cosmopolitan';
import { Themeable } from '../../../Behaviors/Themeable';
// #endregion
/**
 * Choice - An option within a group of choices.
 *
 * @element mosaik-choice
 *
 * @description
 * The Choice component represents an individual option within a group of choices.
 * It is typically used as part of a Choice Group, such as radio buttons or checkboxes.
 * Each choice may include text or other content to indicate the available selection.
 *
 * @category Forms
 *
 * @example
 * ```html
 * <mosaik-choice></mosaik-choice>
 * ```
 *
 * @public
 */
let ChoiceElement = class ChoiceElement extends Themeable(Invalidable(Disableable(Appearanceable(Variantable(Labelable(Valueable(ToggableElement))))))) {
    // #region Fields
    _inputElement;
    _name;
    _additional;
    _required;
    _icon;
    _iconPosition;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._name = '';
        this._additional = '';
        this._required = false;
        this._icon = '';
        this._iconPosition = IconPosition.Before;
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `{@link is}` property.
     * The `{@link is}` property represents natural name of this element.
     *
     * @public
     * @static
     * @override
     * @readonly
     */
    static get is() {
        return 'mosaik-choice';
    }
    /**
     * Gets or sets the `name` property.
     *
     * @public
     * @attr
     */
    get name() {
        return this._name;
    }
    set name(value) {
        if (this._name !== value) {
            this._name = value;
            this.requestUpdate('name');
        }
    }
    /**
     * Gets or sets the `additional` property.
     *
     * @public
     * @attr
     */
    get additional() {
        return this._additional;
    }
    set additional(value) {
        if (this._additional !== value) {
            this._additional = value;
            this.requestUpdate('additional');
        }
    }
    /**
     * Gets or sets the `required` property.
     *
     * @public
     * @attr
     */
    get required() {
        return this._required;
    }
    set required(value) {
        if (this._required !== value) {
            this._required = value;
            this.requestUpdate('required');
        }
    }
    /**
     * Gets or sets the `icon` property.
     *
     * @public
     * @attr
     */
    get icon() {
        return this._icon;
    }
    set icon(value) {
        if (this._icon !== value) {
            this._icon = value;
            this.requestUpdate('icon');
        }
    }
    /**
     * Gets or sets the `iconPosition` property.
     *
     * @public
     * @attr
     */
    get iconPosition() {
        return this._iconPosition;
    }
    set iconPosition(value) {
        if (this._iconPosition !== value) {
            this._iconPosition = value;
            this.requestUpdate('iconPosition');
        }
    }
    // #endregion
    // #region Methods
    /**
     * @public
     * @overload
     */
    connectedCallback() {
        super.connectedCallback();
        this.on('click', (event) => {
            event.stopPropagation();
            this.toggle();
        });
    }
    /**
     * Resets the value, all kinds of validation and errors.
     *
     * @public
     */
    reset() {
        this.value = false;
        this.invalid = false;
    }
    /**
     * Checks the validity of the element and returns `true` if it is valid; otherwise, `false`.
     *
     * @public
     * @override
     */
    checkValidity() {
        return this.shadowRoot
            ? this._inputElement?.checkValidity() ?? true
            : true;
    }
    /**
     * @public
     * @override
     */
    check() {
        if (this.disabled) {
            return;
        }
        this._inputElement?.focus();
        super.check();
    }
    /**
     * @public
     * @override
     */
    uncheck() {
        if (this.disabled) {
            return;
        }
        this._inputElement?.focus();
        super.uncheck();
    }
    /**
     * @public
     * @override
     */
    toggle() {
        if (this.disabled) {
            return;
        }
        this._inputElement?.focus();
        super.toggle();
    }
};
__decorate([
    QueryChild('[part="input"]'),
    __metadata("design:type", HTMLInputElement)
], ChoiceElement.prototype, "_inputElement", void 0);
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], ChoiceElement.prototype, "name", null);
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], ChoiceElement.prototype, "additional", null);
__decorate([
    Attribute({ type: Boolean, useDefault: true }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], ChoiceElement.prototype, "required", null);
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], ChoiceElement.prototype, "icon", null);
__decorate([
    Attribute({ type: IconPosition }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], ChoiceElement.prototype, "iconPosition", null);
ChoiceElement = __decorate([
    Component({
        selector: 'mosaik-choice',
        template: choiceElementTemplate,
        themes: {
            joy: choiceElementJoyStyle,
            retro: choiceElementRetroStyle,
            cosmopolitan: choiceElementCosmopolitanStyle
        },
        options: {
            mode: 'open',
            delegatesFocus: true
        },
        imports: [
            FocusRingElement,
            CheckmarkElement,
            TextElement,
            IconElement
        ]
    }),
    __metadata("design:paramtypes", [])
], ChoiceElement);
export { ChoiceElement };
//# sourceMappingURL=ChoiceElement.js.map