// #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 { Themeable } from '../../../../Controls/Behaviors/Themeable';
import { Appearanceable } from '../../../Behaviors/Appearanceable';
import { Checkable } from '../../../Behaviors/Checkable';
import { Closeable } from '../../../Behaviors/Closeable';
import { Disableable } from '../../../Behaviors/Disableable';
import { Focusable } from '../../../Behaviors/Focusable';
import { Labelable } from '../../../Behaviors/Labelable';
import { Sizeable } from '../../../Behaviors/Sizeable';
import { Variantable } from '../../../Behaviors/Variantable';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { Property } from '../../../Decorators/PropertyDecorator';
import { CustomElement } from '../../Abstracts/CustomElement';
import { RippleElement } from '../../Effects/Ripple/RippleElement';
import { CheckmarkElement } from '../../Primitives/Checkmark/CheckmarkElement';
import { FlipElement } from '../../Primitives/Flip/FlipElement';
import { TextElement } from '../../Primitives/Text/TextElement';
import { IconElement } from '../Icon/IconElement';
import { chipElementTemplate } from './ChipElementTemplate';
import { chipElementJoyStyle } from './Themes/ChipElement.Joy';
import { chipElementCosmopolitanStyle } from './Themes/ChipElement.Cosmopolitan';
import { chipElementRetroStyle } from './Themes/ChipElement.Retro';
import { Slottable } from '../../../Behaviors/Slottable';
// #endregion
/**
 * Chip - A compact element representing information, a tag, or a selection.
 *
 * @element mosaik-chip
 *
 * @fires checked - Dispatched when the `ChipElement` is checked.
 * @fires unchecked - Dispatched when the `ChipElement` is unchecked.
 * @fires closed - Dispatched when the `ChipElement` is closed.
 *
 * @slot checkmark - The checkmark slot.
 * @slot label - The label slot.
 * @slot icon - The icon slot.
 *
 * @public
 */
let ChipElement = class ChipElement extends Themeable(Closeable(Variantable(Appearanceable(Checkable(Disableable(Sizeable(Focusable(Labelable(Slottable(CustomElement)))))))))) {
    // #region Fields
    _icon;
    _isCheckable;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._isCheckable = false;
        this._icon = '';
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `is` property.
     *
     * @public
     * @static
     * @readonly
    */
    static get is() {
        return 'mosaik-chip';
    }
    /**
     * Gets or sets the `icon` property.
     *
     * @public
     */
    get icon() {
        return this._icon;
    }
    set icon(value) {
        if (this._icon !== value) {
            this._icon = value;
            this.requestUpdate('icon');
        }
    }
    /**
     * Gets or sets the `isCheckable` property.
     *
     * @public
     * @attr
     */
    get isCheckable() {
        return this._isCheckable;
    }
    set isCheckable(value) {
        if (this._isCheckable !== value) {
            this._isCheckable = value;
            this.tabIndex = value ? 0 : -1;
            this.requestUpdate('isCheckable');
            // Update the isChecked state afterwords.
            if (!this._isCheckable && this.isChecked) {
                this.isChecked = false;
            }
        }
    }
    /**
     * @public
     * @override
     */
    get isChecked() {
        return super.isChecked;
    }
    set isChecked(value) {
        if (!this._isCheckable) {
            throw new Error('The isChecked property can only be changed when isCheckable is true.');
        }
        super.isChecked = value;
    }
    // #endregion
    // #region Methods
    /**
     * @public
     * @override
     */
    connectedCallback() {
        super.connectedCallback();
    }
    /**
     * @public
     * @overload
     */
    check() {
        if (!this._isCheckable) {
            return;
        }
        super.check();
    }
    /**
     * @public
     * @override
     */
    uncheck() {
        if (!this._isCheckable) {
            return;
        }
        super.uncheck();
    }
    /**
     * @public
     * @override
     */
    toggle() {
        if (!this._isCheckable) {
            return;
        }
        super.toggle();
    }
    /**
     * @protected
     * @template
     */
    onCloseClick(e) {
        e.stopPropagation();
        void this.close();
    }
};
__decorate([
    Property({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], ChipElement.prototype, "icon", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], ChipElement.prototype, "isCheckable", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], ChipElement.prototype, "isChecked", null);
ChipElement = __decorate([
    Component({
        selector: 'mosaik-chip',
        template: chipElementTemplate,
        themes: {
            joy: chipElementJoyStyle,
            retro: chipElementRetroStyle,
            cosmopolitan: chipElementCosmopolitanStyle
        },
        host: {
            tabIndex: '-1'
        },
        // Options: {
        //     Mode: 'open',
        //     DelegatesFocus: true
        // },
        imports: [
            CheckmarkElement,
            RippleElement,
            TextElement,
            IconElement,
            FlipElement
        ]
    }),
    __metadata("design:paramtypes", [])
], ChipElement);
export { ChipElement };
//# sourceMappingURL=ChipElement.js.map