// #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 { Disableable } from '../../../Behaviors/Disableable';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { CustomElement } from '../../Abstracts/CustomElement';
import { colorThumbElementTemplate } from './ColorThumbElementTemplate';
import { colorThumbElementJoyStyle } from './Themes/ColorThumbElement.Joy';
import { colorThumbElementMemphisStyle } from './Themes/ColorThumbElement.Memphis';
import { colorThumbElementCosmopolitanStyle } from './Themes/ColorThumbElement.Cosmopolitan';
import { Themeable } from '../../../Behaviors/Themeable';
// #endregion
/**
 * Color Thumb - A user interface component used for selecting or adjusting colors.
 *
 * @element mosaik-color-thumb
 *
 * @description
 * The Color Thumb component is designed to enable users to interact with and modify colors in various applications.
 * It typically appears as a draggable or clickable element that can be used to select a color from a palette, adjust
 * color values, or perform color-related actions. Color thumbs are commonly found in color pickers, design tools,
 * and applications where color customization is essential.
 *
 * @category Media
 *
 * @public
 */
let ColorThumbElement = class ColorThumbElement extends Themeable(Disableable(CustomElement)) {
    // #region Fields
    _color;
    _isOpen;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._color = '';
        this._isOpen = false;
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `{@link is}` property.
     * The `{@link is}` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-color-thumb';
    }
    /**
     * Gets or sets the `color` property.
     *
     * @public
     * @attr
     */
    get color() {
        return this._color;
    }
    set color(value) {
        if (this._color !== value) {
            this._color = value;
            this.requestUpdate('color');
        }
    }
    /**
     * Gets or sets the `isOpen` property.
     *
     * @public
     * @attr
     */
    get isOpen() {
        return this._isOpen;
    }
    set isOpen(value) {
        if (this._isOpen !== value) {
            this._isOpen = value;
            this.requestUpdate('isOpen');
        }
    }
    // #endregion
    // #region Methods
    /**
     * @protected
     * @overload
     */
    onApplyTemplate() {
        super.onApplyTemplate();
        this.on('pointerdown', (e) => this.handlePointerdown(e));
        this.on('pointerup', (e) => this.handlePointerup(e));
        this.on('pointercancel', (e) => this.handlePointerup(e));
    }
    /**
     * @private
     */
    handlePointerdown(event) {
        if (event.pointerType === 'touch') {
            this.isOpen = true;
        }
        this.setPointerCapture(event.pointerId);
    }
    /**
     * @private
     */
    handlePointerup(event) {
        this.isOpen = false;
        this.releasePointerCapture(event.pointerId);
    }
};
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], ColorThumbElement.prototype, "color", null);
__decorate([
    Attribute({ type: Boolean, useDefault: true }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], ColorThumbElement.prototype, "isOpen", null);
ColorThumbElement = __decorate([
    Component({
        selector: 'mosaik-color-thumb',
        template: colorThumbElementTemplate,
        themes: {
            joy: colorThumbElementJoyStyle,
            memphis: colorThumbElementMemphisStyle,
            cosmopolitan: colorThumbElementCosmopolitanStyle
        },
        imports: []
    }),
    __metadata("design:paramtypes", [])
], ColorThumbElement);
export { ColorThumbElement };
//# sourceMappingURL=ColorThumbElement.js.map