// #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 { 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 { LabelPosition } from '../../../Types/LabelPosition';
import { ToggableElement } from '../../Primitives/Abstracts/Toggable/ToggableElement';
import { CheckmarkElement } from '../../Primitives/Checkmark/CheckmarkElement';
import { TextElement } from '../../Primitives/Text/TextElement';
import { checkboxElementTemplate } from './CheckBoxElementTemplate';
import { CHECKBOX_GROUP_INHERITANCE_CONTEXT } from './CheckBoxGroupInheritanceContext';
import { checkBoxElementCosmopolitanStyle } from './Themes/CheckBoxElement.Cosmopolitan';
import { checkBoxElementJoyStyle } from './Themes/CheckBoxElement.Joy';
import { checkBoxElementMemphisStyle } from './Themes/CheckBoxElement.Memphis';
// #endregion
/**
 * Checkbox - A control element that allows users to select or deselect an option.
 *
 * @description
 * The Checkbox component allows users to make binary choices (checked/unchecked) or multiple selections from a set of options.
 * It supports various states including checked, unchecked, indeterminate, and disabled. Checkboxes are commonly used in forms,
 * settings panels, and anywhere users need to make boolean choices or multiple selections.
 *
 * @name Checkbox
 * @element mosaik-checkbox
 * @category Inputs
 *
 * @slot checkmark - The checkmark slot.
 * @slot label - The label slot.
 *
 * @csspart checkmark - the checkmark part.
 * @csspart focusRing - the focus ring part.
 * @csspart input - the input part.
 * @csspart label - the label part.
 *
 * @cssprop {Color} --check-box-background-color - The background color.
 * @cssprop {Color} --check-box-border-color - The border color.
 * @cssprop {String} --check-box-border-radius - The border radius.
 * @cssprop {String} --check-box-border-style - The border style.
 * @cssprop {String} --check-box-border-width - The border width.
 * @cssprop {String} --check-box-font-family - The font family.
 * @cssprop {String} --check-box-font-letter-spacing - The font letter spacing.
 * @cssprop {String} --check-box-font-line-height - The font line height.
 * @cssprop {String} --check-box-font-size - The font size.
 * @cssprop {String} --check-box-font-text-decoration - The font text decoration.
 * @cssprop {String} --check-box-font-text-transform - The font text transform.
 * @cssprop {String} --check-box-font-weight - The font weight.
 * @cssprop {Color} --check-box-foreground-color - The foreground color.
 * @cssprop {String} --check-box-gap - The gap.
 * @cssprop {String} --check-box-padding-bottom - The padding bottom.
 * @cssprop {String} --check-box-padding-left - The padding left.
 * @cssprop {String} --check-box-padding-right - The padding right.
 * @cssprop {String} --check-box-padding-top - The padding top.
 * @cssprop {String} --check-box-shadow - The shadow.
 * @cssprop {String} --check-box-shadow-blur - The box shadow blur CSS custom property.
 * @cssprop {String} --check-box-shadow-color - The box shadow color CSS custom property.
 * @cssprop {String} --check-box-shadow-offset-x - The box shadow offset x CSS custom property.
 * @cssprop {String} --check-box-shadow-offset-y - The box shadow offset y CSS custom property.
 * @cssprop {String} --check-box-shadow-spread - The box shadow spread CSS custom property.
 * @cssprop {String} --check-box-transition-duration - The transition duration.
 * @cssprop {String} --check-box-transition-mode - The transition mode.
 * @cssprop {String} --check-box-transition-property - The transition property.
 * @cssprop {String} --check-box-translate - The box translate CSS custom property.
 *
 * @dependency {CheckmarkElement} mosaik-checkmark - The checkmark element.
 * @dependency mosaik-focus-ring - The Focus Ring element.
 * @dependency {TextElement} mosaik-text - The text element.
 *
 * @example
 * Basic checkbox:
 * ```html
 * <mosaik-checkbox label="Accept terms and conditions" value="accepted"></mosaik-checkbox>
 * ```
 *
 * @example
 * Pre-checked checkbox:
 * ```html
 * <mosaik-checkbox label="Subscribe to newsletter" is-checked></mosaik-checkbox>
 * ```
 *
 * @example
 * Checkbox group composition:
 * ```html
 * <mosaik-checkbox-group name="preferences">
 *   <mosaik-checkbox label="Email notifications" value="email"></mosaik-checkbox>
 *   <mosaik-checkbox label="SMS notifications" value="sms"></mosaik-checkbox>
 *   <mosaik-checkbox label="Push notifications" value="push"></mosaik-checkbox>
 * </mosaik-checkbox-group>
 * ```
 *
 * @public
 */
let CheckboxElement = class CheckboxElement extends Themeable(Invalidable(Valueable(Variantable(Appearanceable(Disableable(Labelable(TextFormattable(ToggableElement)))))))) {
    // #region Fields
    _inheritance = addInheritanceConsumerController(this, {
        context: CHECKBOX_GROUP_INHERITANCE_CONTEXT
    });
    _inputElement;
    _labelPosition;
    _required;
    _name;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._labelPosition = LabelPosition.After;
        this._required = false;
        this._name = '';
    }
    // #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-checkbox';
    }
    /**
     * @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;
    }
    /**
     * @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 `labelPosition` property.
     *
     * @public
     * @attr
     */
    get labelPosition() {
        return this._labelPosition;
    }
    set labelPosition(value) {
        if (this._labelPosition !== value) {
            this._labelPosition = value;
            this.requestUpdate('labelPosition');
        }
    }
    /**
     * 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 `name` property.
     * When used inside a CheckBoxGroup, 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');
        }
    }
    // #endregion
    // #region Methods
    /**
     * @public
     * @overload
     */
    connectedCallback() {
        super.connectedCallback();
        this.on('click', (event) => {
            event.stopPropagation();
            this.toggle();
        });
    }
    /**
     * Resets the element to its initial state.
     *
     * @public
     */
    reset() {
        this.isChecked = false;
        this.invalid = false;
    }
    /**
     * Checks the validity of the element and returns `true` if it is valid; otherwise, `false`.
     *
     * @public
     */
    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();
    }
    /**
     * Toggles the element between checked and unchecked states.
     *
     * @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: LabelPosition }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], CheckboxElement.prototype, "labelPosition", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], CheckboxElement.prototype, "required", null);
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], CheckboxElement.prototype, "name", null);
CheckboxElement = __decorate([
    Component({
        selector: 'mosaik-checkbox',
        themes: {
            joy: checkBoxElementJoyStyle,
            memphis: checkBoxElementMemphisStyle,
            cosmopolitan: checkBoxElementCosmopolitanStyle
        },
        template: checkboxElementTemplate,
        options: {
            mode: 'open',
            delegatesFocus: true
        },
        imports: [
            CheckmarkElement,
            TextElement
        ]
    }),
    __metadata("design:paramtypes", [])
], CheckboxElement);
export { CheckboxElement };
//# sourceMappingURL=CheckBoxElement.js.map