// #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 { Rippleable } from '../../../Behaviors/Rippleable';
import { Sizeable } from '../../../Behaviors/Sizeable';
import { Slottable } from '../../../Behaviors/Slottable';
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 { Property } from '../../../Decorators/PropertyDecorator';
import { CustomElement } from '../../Abstracts/CustomElement';
import { RippleElement } from '../../Effects/Ripple/RippleElement';
import { CheckmarkElement } from '../../Primitives/Checkmark/CheckmarkElement';
import { TextElement } from '../../Primitives/Text/TextElement';
import { IconElement } from '../Icon/IconElement';
import { chipElementTemplate } from './ChipElementTemplate';
import { CHIP_GROUP_INHERITANCE_CONTEXT } from './ChipGroupInheritanceContext';
import { chipElementCosmopolitanStyle } from './Themes/ChipElement.Cosmopolitan';
import { chipElementJoyStyle } from './Themes/ChipElement.Joy';
import { chipElementMemphisStyle } from './Themes/ChipElement.Memphis';
// #endregion
/**
 * Chip - A compact element representing information, a tag, or a selection.
 *
 * @element mosaik-chip
 *
 * @slot checkmark - The checkmark slot.
 * @slot close - The close button slot.
 * @slot icon - The icon slot.
 * @slot label - The label slot.
 *
 * @csspart checkmark - The checkmark element shown when checked.
 * @csspart checkmark-container - The container for the checkmark with slide-in animation.
 * @csspart close - The close button element.
 * @csspart focusRing - The focus ring element.
 * @csspart icon - The icon element.
 * @csspart label - The label text element.
 * @csspart ripple - The ripple effect element.
 *
 * @cssprop {String} --chip-background-color - The background color CSS custom property.
 * @cssprop {String} --chip-border-color - The border color CSS custom property.
 * @cssprop {String} --chip-border-radius - The border radius CSS custom property.
 * @cssprop {String} --chip-border-style - The border style CSS custom property.
 * @cssprop {String} --chip-border-width - The border width CSS custom property.
 * @cssprop {String} --chip-focus-ring-active-width - The focus ring active width CSS custom property.
 * @cssprop {String} --chip-focus-ring-color - The focus ring color CSS custom property.
 * @cssprop {String} --chip-focus-ring-inward-offset - The focus ring inward offset CSS custom property.
 * @cssprop {String} --chip-focus-ring-outward-offset - The focus ring outward offset CSS custom property.
 * @cssprop {String} --chip-font-family - The font family CSS custom property.
 * @cssprop {String} --chip-font-letter-spacing - The font letter spacing CSS custom property.
 * @cssprop {String} --chip-font-line-height - The font line height CSS custom property.
 * @cssprop {String} --chip-font-size - The font size CSS custom property.
 * @cssprop {String} --chip-font-text-decoration - The font text decoration CSS custom property.
 * @cssprop {String} --chip-font-text-transform - The font text transform CSS custom property.
 * @cssprop {String} --chip-font-weight - The font weight CSS custom property.
 * @cssprop {String} --chip-foreground-color - The foreground color CSS custom property.
 * @cssprop {String} --chip-gap - The gap CSS custom property.
 * @cssprop {String} --chip-height - The height CSS custom property.
 * @cssprop {String} --chip-padding-bottom - The padding bottom CSS custom property.
 * @cssprop {String} --chip-padding-left - The padding left CSS custom property.
 * @cssprop {String} --chip-padding-right - The padding right CSS custom property.
 * @cssprop {String} --chip-padding-top - The padding top CSS custom property.
 * @cssprop {Color} --chip-ripple-color - The ripple color CSS custom property.
 * @cssprop {String} --chip-ripple-duration - The ripple duration CSS custom property.
 * @cssprop {String} --chip-shadow - The shadow CSS custom property.
 * @cssprop {String} --chip-shadow-blur - The shadow blur CSS custom property.
 * @cssprop {String} --chip-shadow-color - The shadow color CSS custom property.
 * @cssprop {String} --chip-shadow-offset-x - The shadow offset x CSS custom property.
 * @cssprop {String} --chip-shadow-offset-y - The shadow offset y CSS custom property.
 * @cssprop {String} --chip-shadow-spread - The shadow spread CSS custom property.
 * @cssprop {String} --chip-transition-duration - The transition duration CSS custom property.
 * @cssprop {String} --chip-transition-mode - The transition mode CSS custom property.
 * @cssprop {String} --chip-transition-property - The transition property CSS custom property.
 * @cssprop {String} --chip-translate - The translate CSS custom property.
 *
 * @fires toggled {ToggledEvent} - Dispatched when the chip is toggled, regardless of the new state.
 * @fires checked {CheckedEvent} - Dispatched when the chip is checked.
 * @fires unchecked {UncheckedEvent} - Dispatched when the chip is unchecked.
 * @fires closed {ClosedEvent} - Dispatched when the chip is closed.
 *
 * @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 chip (set display label via the `label` JavaScript property):
 * ```html
 * <mosaik-chip value="tag-1"></mosaik-chip>
 * ```
 *
 * @example
 * Checkable chip with a value:
 * ```html
 * <mosaik-chip is-checkable value="option-a"></mosaik-chip>
 * ```
 *
 * @example
 * Pre-checked chip with variant and appearance:
 * ```html
 * <mosaik-chip is-checkable is-checked variant="primary" appearance="soft" value="selected"></mosaik-chip>
 * ```
 *
 * @public
 */
let ChipElement = class ChipElement extends Themeable(Rippleable(Closeable(Variantable(Appearanceable(Checkable(Disableable(Sizeable(Focusable(Labelable(Slottable(Valueable(CustomElement)))))))))))) {
    // #region Fields
    _inheritance = addInheritanceConsumerController(this, {
        context: CHIP_GROUP_INHERITANCE_CONTEXT
    });
    _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;
    }
    /**
     * @public
     * @override
     */
    get size() {
        return this._inheritance.get('size', super.size);
    }
    set size(value) {
        this._inheritance.markExplicit('size');
        super.size = value;
    }
    /**
     * @public
     * @override
     */
    get disabled() {
        return this._inheritance.get('disabled', super.disabled);
    }
    set disabled(value) {
        this._inheritance.markExplicit('disabled');
        super.disabled = 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 appearance() {
        return this._inheritance.get('appearance', super.appearance);
    }
    set appearance(value) {
        this._inheritance.markExplicit('appearance');
        super.appearance = 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,
            memphis: chipElementMemphisStyle,
            cosmopolitan: chipElementCosmopolitanStyle
        },
        host: {
            tabIndex: '-1'
        },
        imports: [
            CheckmarkElement,
            RippleElement,
            TextElement,
            IconElement
        ]
    }),
    __metadata("design:paramtypes", [])
], ChipElement);
export { ChipElement };
//# sourceMappingURL=ChipElement.js.map