// #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 { HTMLElementEventEmitter } from '@breadstone/mosaik-elements';
import { Emit } from '../../../../events/Decorators/EmitDecorator';
import { Appearanceable } from '../../../Behaviors/Appearanceable';
import { Disableable } from '../../../Behaviors/Disableable';
import { Orientable } from '../../../Behaviors/Orientable';
import { Sizeable } from '../../../Behaviors/Sizeable';
import { Themeable } from '../../../Behaviors/Themeable';
import { Variantable } from '../../../Behaviors/Variantable';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { SpinDirection } from '../../../Types/SpinDirection';
import { UpDownSpinPosition } from '../../../Types/UpDownSpinPosition';
import { CustomElement } from '../../Abstracts/CustomElement';
import { RepeatButtonElement } from '../../Buttons/RepeatButton/RepeatButtonElement';
import { upDownSpinnerElementCosmopolitanStyle } from './Themes/UpDownSpinnerElement.Cosmopolitan';
import { upDownSpinnerElementJoyStyle } from './Themes/UpDownSpinnerElement.Joy';
import { upDownSpinnerElementMemphisStyle } from './Themes/UpDownSpinnerElement.Memphis';
import { upDownSpinnerElementTemplate } from './UpDownSpinnerElementTemplate';
// #endregion
/**
 * UpDownSpinner - Increment/decrement controls for numeric input fields and value adjustments.
 *
 * @description
 * The UpDownSpinner element provides a pair of increase/decrease buttons typically used alongside
 * numeric inputs, date pickers, or any value that can be adjusted incrementally. Features auto-repeat
 * functionality when buttons are held down, customizable icons, delay/interval settings, and support
 * for disabling individual buttons when limits are reached. Commonly used in number inputs, quantity
 * selectors, and stepper controls.
 *
 * @name UpDownSpinner
 * @element mosaik-updown-spinner
 * @category Primitives
 *
 * @slot - Default content slot displayed between the spinner buttons
 * @slot prefix - Content displayed before the default slot
 * @slot suffix - Content displayed after the default slot
 *
 * @csspart content - Container for slotted content (prefix, default, suffix)
 * @csspart increase - The increase/up button
 * @csspart decrease - The decrease/down button
 *
 * @dependency {RepeatButtonElement} - Auto-repeating button component
 *
 * @fires spinned {SpinEvent} - Fired when increase or decrease is triggered, includes direction
 *
 * @example
 * Basic spinner with numeric input:
 * ```html
 * <div class="number-input">
 *   <input type="number" id="quantity" value="1" min="1" max="10">
 *   <mosaik-updown-spinner id="spinner"></mosaik-updown-spinner>
 * </div>
 *
 * <script>
 *   const input = document.getElementById('quantity');
 *   const spinner = document.getElementById('spinner');
 *
 *   spinner.addEventListener('spinned', (e) => {
 *     const current = parseInt(input.value);
 *     if (e.detail.direction === 'increase') {
 *       input.value = Math.min(current + 1, 10);
 *     } else {
 *       input.value = Math.max(current - 1, 1);
 *     }
 *   });
 * </script>
 * ```
 *
 * @example
 * Custom icons and styling:
 * ```html
 * <mosaik-updown-spinner
 *   increase-icon="custom-plus-icon"
 *   decrease-icon="custom-minus-icon"
 *   variant="primary"
 *   size="small"
 *   appearance="outline">
 * </mosaik-updown-spinner>
 * ```
 *
 * @example
 * With disabled states at limits:
 * ```html
 * <mosaik-updown-spinner
 *   id="limitedSpinner"
 *   increase-disabled="false"
 *   decrease-disabled="true">
 * </mosaik-updown-spinner>
 *
 * <script>
 *   const spinner = document.getElementById('limitedSpinner');
 *   let value = 0;
 *   const min = 0, max = 10;
 *
 *   spinner.addEventListener('spinned', (e) => {
 *     if (e.detail.direction === 'increase' && value < max) {
 *       value++;
 *     } else if (e.detail.direction === 'decrease' && value > min) {
 *       value--;
 *     }
 *
 *     spinner.increaseDisabled = value >= max;
 *     spinner.decreaseDisabled = value <= min;
 *   });
 * </script>
 * ```
 *
 * @example
 * Horizontal orientation with custom timing:
 * ```html
 * <mosaik-updown-spinner
 *   orientation="horizontal"
 *   delay="300"
 *   interval="200"
 *   position="after">
 * </mosaik-updown-spinner>
 * ```
 *
 * @public
 */
let UpDownSpinnerElement = class UpDownSpinnerElement extends Themeable(Variantable(Sizeable(Appearanceable(Orientable(Disableable(CustomElement)))))) {
    // #region Fields
    _spinned;
    _delay;
    _interval;
    _position;
    _increaseDisabled;
    _increaseIcon;
    _decreaseDisabled;
    _decreaseIcon;
    _focusable;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._position = UpDownSpinPosition.After;
        this._delay = 500;
        this._interval = 330;
        this._increaseDisabled = false;
        this._increaseIcon = '';
        this._decreaseDisabled = false;
        this._decreaseIcon = '';
        this._focusable = false;
        this._spinned = new HTMLElementEventEmitter(this, 'spinned', { cancelable: true });
    }
    // #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-updown-spinner';
    }
    /**
     * Gets or sets the `delay` property.
     *
     * @public
     * @attr
     */
    get delay() {
        return this._delay;
    }
    set delay(value) {
        if (this._delay !== value) {
            this._delay = value;
            this.requestUpdate('delay');
        }
    }
    /**
     * Gets or sets the `interval` property.
     *
     * @public
     * @attr
     */
    get interval() {
        return this._interval;
    }
    set interval(value) {
        if (this._interval !== value) {
            this._interval = value;
            this.requestUpdate('interval');
        }
    }
    /**
     * Gets or sets the `position` property.
     *
     * @public
     * @attr
     */
    get position() {
        return this._position;
    }
    set position(value) {
        if (this._position !== value) {
            this._position = value;
            this.requestUpdate('position');
        }
    }
    /**
     * Gets or sets the `increaseDisabled` property.
     *
     * @public
     * @attr
     */
    get increaseDisabled() {
        return this._increaseDisabled;
    }
    set increaseDisabled(value) {
        if (this._increaseDisabled !== value) {
            this._increaseDisabled = value;
            this.requestUpdate('increaseDisabled');
        }
    }
    /**
     * Gets or sets the `increaseIcon` property.
     *
     * @public
     * @attr
     */
    get increaseIcon() {
        return this._increaseIcon;
    }
    set increaseIcon(value) {
        if (this._increaseIcon !== value) {
            this._increaseIcon = value;
            this.requestUpdate('increaseIcon');
        }
    }
    /**
     * Gets or sets the `decreaseDisabled` property.
     *
     * @public
     * @attr
     */
    get decreaseDisabled() {
        return this._decreaseDisabled;
    }
    set decreaseDisabled(value) {
        if (this._decreaseDisabled !== value) {
            this._decreaseDisabled = value;
            this.requestUpdate('decreaseDisabled');
        }
    }
    /**
     * Gets or sets the `decreaseIcon` property.
     *
     * @public
     * @attr
     */
    get decreaseIcon() {
        return this._decreaseIcon;
    }
    set decreaseIcon(value) {
        if (this._decreaseIcon !== value) {
            this._decreaseIcon = value;
            this.requestUpdate('decreaseIcon');
        }
    }
    /**
     * Gets or sets the `focusable` property.
     *
     * @public
     * @attr
     */
    get focusable() {
        return this._focusable;
    }
    set focusable(value) {
        if (this._focusable !== value) {
            this._focusable = value;
            this.requestUpdate('focusable');
        }
    }
    /**
     * Called when the element is spinned.
     * Provides reference to `ISpinEventDetail` as event argument.
     *
     * @public
     * @readonly
     * @eventProperty
     */
    get spinned() {
        return this._spinned;
    }
    /**
     * Emits the {@link spinned} event.
     *
     * @protected
     */
    onSpinned(args) {
        this._spinned.emit(args);
    }
    // #endregion
    // #region Methods
    /**
     * @private
     * @template
     */
    onIncrease(event) {
        event?.stopPropagation();
        event?.preventDefault();
        const args = {
            direction: SpinDirection.Increase,
            cancel: false
        };
        this._spinned.emit(args);
    }
    /**
     * @private
     * @template
     */
    onDecrease(event) {
        event?.stopPropagation();
        event?.preventDefault();
        const args = {
            direction: SpinDirection.Decrease,
            cancel: false
        };
        this._spinned.emit(args);
    }
};
__decorate([
    Attribute({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], UpDownSpinnerElement.prototype, "delay", null);
__decorate([
    Attribute({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], UpDownSpinnerElement.prototype, "interval", null);
__decorate([
    Attribute({ type: UpDownSpinPosition }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], UpDownSpinnerElement.prototype, "position", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], UpDownSpinnerElement.prototype, "increaseDisabled", null);
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], UpDownSpinnerElement.prototype, "increaseIcon", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], UpDownSpinnerElement.prototype, "decreaseDisabled", null);
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], UpDownSpinnerElement.prototype, "decreaseIcon", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], UpDownSpinnerElement.prototype, "focusable", null);
__decorate([
    Emit(),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [])
], UpDownSpinnerElement.prototype, "spinned", null);
UpDownSpinnerElement = __decorate([
    Component({
        selector: 'mosaik-updown-spinner',
        template: upDownSpinnerElementTemplate,
        themes: {
            joy: upDownSpinnerElementJoyStyle,
            memphis: upDownSpinnerElementMemphisStyle,
            cosmopolitan: upDownSpinnerElementCosmopolitanStyle
        },
        imports: [
            RepeatButtonElement
        ]
    }),
    __metadata("design:paramtypes", [])
], UpDownSpinnerElement);
export { UpDownSpinnerElement };
//# sourceMappingURL=UpDownSpinnerElement.js.map