// #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 { Rippleable } from '../../../Behaviors/Rippleable';
import { TextFormattable } from '../../../Behaviors/TextFormattable';
import { Themeable } from '../../../Behaviors/Themeable';
import { Valueable } from '../../../Behaviors/Valueable';
import { Variantable } from '../../../Behaviors/Variantable';
import { addInheritanceConsumerController } from '../../../Controllers/InheritanceConsumerController';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
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 { CHOICE_GROUP_INHERITANCE_CONTEXT } from './ChoiceGroupInheritanceContext';
import { choiceElementCosmopolitanStyle } from './Themes/ChoiceElement.Cosmopolitan';
import { choiceElementJoyStyle } from './Themes/ChoiceElement.Joy';
import { choiceElementMemphisStyle } from './Themes/ChoiceElement.Memphis';
// #endregion
/**
 * Choice - An option within a group of choices.
 *
 * @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.
 *
 * @name Choice
 * @element mosaik-choice
 * @category Forms
 *
 * @slot additional - The additional slot.
 * @slot checkmark - The checkmark slot.
 * @slot label - The label slot.
 *
 * @csspart additional - The additional part.
 * @csspart focusRing - The focusRing part.
 * @csspart input - The input part.
 * @csspart label - The label part.
 * @csspart ripple - The ripple part.
 *
 * @cssprop {String} --choice-background-color - The background color CSS custom property.
 * @cssprop {String} --choice-border-color - The border color CSS custom property.
 * @cssprop {String} --choice-border-radius - The border radius CSS custom property.
 * @cssprop {String} --choice-border-style - The border style CSS custom property.
 * @cssprop {String} --choice-border-width - The border width CSS custom property.
 * @cssprop {String} --choice-checkmark-border-radius - The checkmark border radius CSS custom property.
 * @cssprop {String} --choice-focus-ring-border-radius - The focus ring border radius CSS custom property.
 * @cssprop {String} --choice-focus-ring-color - The focus ring color CSS custom property.
 * @cssprop {String} --choice-focus-ring-outward-offset - The focus ring outward offset CSS custom property.
 * @cssprop {String} --choice-font-family - The font family CSS custom property.
 * @cssprop {String} --choice-font-letter-spacing - The font letter spacing CSS custom property.
 * @cssprop {String} --choice-font-line-height - The font line height CSS custom property.
 * @cssprop {String} --choice-font-size - The font size CSS custom property.
 * @cssprop {String} --choice-font-text-decoration - The font text decoration CSS custom property.
 * @cssprop {String} --choice-font-text-transform - The font text transform CSS custom property.
 * @cssprop {String} --choice-font-weight - The font weight CSS custom property.
 * @cssprop {String} --choice-foreground-color - The foreground color CSS custom property.
 * @cssprop {String} --choice-gap - The gap CSS custom property.
 * @cssprop {String} --choice-padding-bottom - The padding bottom CSS custom property.
 * @cssprop {String} --choice-padding-left - The padding left CSS custom property.
 * @cssprop {String} --choice-padding-right - The padding right CSS custom property.
 * @cssprop {String} --choice-padding-top - The padding top CSS custom property.
 * @cssprop {String} --choice-shadow - The shadow CSS custom property.
 * @cssprop {String} --choice-shadow-blur - The shadow blur CSS custom property.
 * @cssprop {String} --choice-shadow-color - The shadow color CSS custom property.
 * @cssprop {String} --choice-shadow-offset-x - The shadow offset x CSS custom property.
 * @cssprop {String} --choice-shadow-offset-y - The shadow offset y CSS custom property.
 * @cssprop {String} --choice-shadow-spread - The shadow spread CSS custom property.
 * @cssprop {String} --choice-transition-duration - The transition duration CSS custom property.
 * @cssprop {String} --choice-transition-mode - The transition mode CSS custom property.
 * @cssprop {String} --choice-transition-property - The transition property CSS custom property.
 * @cssprop {String} --choice-translate - The translate CSS custom property.
 *
 * @dependency mosaik-checkmark - The Checkmark element.
 * @dependency mosaik-focus-ring - The Focus Ring element.
 * @dependency mosaik-icon - The Icon element.
 * @dependency mosaik-ripple - The Ripple element.
 * @dependency mosaik-text - The Text element.
 *
 * @example
 * Basic choice option with label and value:
 * ```html
 * <mosaik-choice label="Premium Plan" value="premium"></mosaik-choice>
 * ```
 *
 * @example
 * Choice with additional description:
 * ```html
 * <mosaik-choice
 *   label="Professional"
 *   value="pro"
 *   additional="Full access to all features">
 * </mosaik-choice>
 * ```
 *
 * @example
 * Choice group composition:
 * ```html
 * <mosaik-choice-group name="plan">
 *   <mosaik-choice label="Basic" value="basic" additional="Free tier"></mosaik-choice>
 *   <mosaik-choice label="Professional" value="pro" additional="$9/month"></mosaik-choice>
 *   <mosaik-choice label="Enterprise" value="enterprise" additional="Contact sales"></mosaik-choice>
 * </mosaik-choice-group>
 * ```
 *
 * @public
 */
let ChoiceElement = class ChoiceElement extends Themeable(Rippleable(Invalidable(Disableable(Appearanceable(Variantable(Labelable(Valueable(TextFormattable(ToggableElement))))))))) {
    // #region Fields
    _inheritance = addInheritanceConsumerController(this, {
        context: CHOICE_GROUP_INHERITANCE_CONTEXT
    });
    _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 `is` property.
     * The `is` property represents natural name of this element.
     *
     * @public
     * @static
     * @override
     * @readonly
     */
    static get is() {
        return 'mosaik-choice';
    }
    /**
     * @public
     * @override
     */
    get disabled() {
        return this._inheritance.get('disabled', super.disabled);
    }
    set disabled(value) {
        this._inheritance.markExplicit('disabled');
        super.disabled = value;
    }
    /**
     * @public
     * @override
     */
    get appearance() {
        return this._inheritance.get('appearance', super.appearance);
    }
    set appearance(value) {
        this._inheritance.markExplicit('appearance');
        super.appearance = value;
    }
    /**
     * @public
     * @override
     */
    get variant() {
        return this._inheritance.get('variant', super.variant);
    }
    set variant(value) {
        this._inheritance.markExplicit('variant');
        super.variant = value;
    }
    /**
     * Gets or sets the `dir` property.
     * When used inside a ChoiceGroup, inherits the group's dir unless explicitly set.
     *
     * @public
     * @override
     */
    get dir() {
        return this._inheritance.get('dir', super.dir);
    }
    set dir(value) {
        this._inheritance.markExplicit('dir');
        super.dir = value;
    }
    /**
     * Gets or sets the `name` property.
     * When used inside a ChoiceGroup, inherits the group's name unless explicitly set.
     *
     * @public
     * @attr
     */
    get name() {
        return this._inheritance.get('name', this._name);
    }
    set name(value) {
        this._inheritance.markExplicit('name');
        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();
            // If the radio is already checked, do nothing because radios are single-select and cannot be unchecked.
            if (this._inputElement.checked) {
                return;
            }
            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;
    }
    /**
     * @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();
    }
    /**
     * @protected
     * @override
     */
    onApplyTemplate() {
        super.onApplyTemplate();
        this._inputElement = this.getTemplatePart('input');
    }
};
__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,
            memphis: choiceElementMemphisStyle,
            cosmopolitan: choiceElementCosmopolitanStyle
        },
        options: {
            mode: 'open',
            delegatesFocus: true
        },
        imports: [
            FocusRingElement,
            CheckmarkElement,
            TextElement,
            IconElement
        ]
    }),
    __metadata("design:paramtypes", [])
], ChoiceElement);
export { ChoiceElement };
//# sourceMappingURL=ChoiceElement.js.map