// #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 { DomServiceLocator } from '../../../../Dom/Dom';
import { Listen } from '../../../../events/Decorators/ListenDecorator';
import { Disableable } from '../../../Behaviors/Disableable';
import { Focusable } from '../../../Behaviors/Focusable';
import { Labelable } from '../../../Behaviors/Labelable';
import { Rippleable } from '../../../Behaviors/Rippleable';
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 { Property } from '../../../Decorators/PropertyDecorator';
import { SelectionMode } from '../../../Types/SelectionMode';
import { CheckmarkElement } from '../../Primitives/Checkmark/CheckmarkElement';
import { PortalProjectionElement } from '../../Primitives/Portal/PortalProjectionElement';
import { SelectorItemElement } from '../Abstracts/Selector/SelectorItemElement';
import { COMBO_INHERITANCE_CONTEXT } from './ComboInheritanceContext';
import { comboItemElementTemplate } from './ComboItemElementTemplate';
import { comboItemElementCosmopolitanStyle } from './Themes/ComboItemElement.Cosmopolitan';
import { comboItemElementJoyStyle } from './Themes/ComboItemElement.Joy';
import { comboItemElementMemphisStyle } from './Themes/ComboItemElement.Memphis';
// #endregion
/**
 * ComboItem - An individual selectable option within a combo dropdown component.
 *
 * Represents a single choice that users can select from within a combo box dropdown.
 * Supports visual states (selected, focused, disabled) and provides value binding
 * for form integration and selection management.
 *
 * @name ComboItemElement
 * @element mosaik-combo-item
 * @category Selectors
 *
 * @slot checkmark - The checkmark slot.
 * @slot end - The end slot.
 * @slot icon - The icon slot.
 * @slot - Default content area for the option label and description
 * @slot start - The start slot.
 *
 * @csspart checkmark - Checkmark indicator for selected state
 * @csspart focusRing - The focusRing part.
 * @csspart ripple - The ripple part.
 *
 * @cssprop {String} --combo-item-background-color - The item background color CSS custom property.
 * @cssprop {String} --combo-item-border-color - The item border color CSS custom property.
 * @cssprop {String} --combo-item-border-radius - Border radius for option styling
 * @cssprop {String} --combo-item-border-style - The item border style CSS custom property.
 * @cssprop {String} --combo-item-border-width - The item border width CSS custom property.
 * @cssprop {String} --combo-item-focus-ring-active-width - The item focus ring active width CSS custom property.
 * @cssprop {String} --combo-item-focus-ring-color - The item focus ring color CSS custom property.
 * @cssprop {String} --combo-item-focus-ring-inward-offset - The item focus ring inward offset CSS custom property.
 * @cssprop {String} --combo-item-focus-ring-outward-offset - The item focus ring outward offset CSS custom property.
 * @cssprop {String} --combo-item-font-family - The item font family CSS custom property.
 * @cssprop {String} --combo-item-font-letter-spacing - The item font letter spacing CSS custom property.
 * @cssprop {String} --combo-item-font-line-height - The item font line height CSS custom property.
 * @cssprop {String} --combo-item-font-size - The item font size CSS custom property.
 * @cssprop {String} --combo-item-font-text-decoration - The item font text decoration CSS custom property.
 * @cssprop {String} --combo-item-font-text-transform - The item font text transform CSS custom property.
 * @cssprop {String} --combo-item-font-weight - The item font weight CSS custom property.
 * @cssprop {String} --combo-item-foreground-color - The item foreground color CSS custom property.
 * @cssprop {String} --combo-item-gap - The item gap CSS custom property.
 * @cssprop {String} --combo-item-padding-bottom - The item padding bottom CSS custom property.
 * @cssprop {String} --combo-item-padding-left - The item padding left CSS custom property.
 * @cssprop {String} --combo-item-padding-right - The item padding right CSS custom property.
 * @cssprop {String} --combo-item-padding-top - The item padding top CSS custom property.
 * @cssprop {String} --combo-item-ripple-color - The item ripple color CSS custom property.
 * @cssprop {String} --combo-item-ripple-duration - The item ripple duration CSS custom property.
 * @cssprop {String} --combo-item-shadow - The item shadow CSS custom property.
 * @cssprop {String} --combo-item-shadow-blur - The item shadow blur CSS custom property.
 * @cssprop {String} --combo-item-shadow-color - The item shadow color CSS custom property.
 * @cssprop {String} --combo-item-shadow-offset-x - The item shadow offset x CSS custom property.
 * @cssprop {String} --combo-item-shadow-offset-y - The item shadow offset y CSS custom property.
 * @cssprop {String} --combo-item-shadow-spread - The item shadow spread CSS custom property.
 * @cssprop {String} --combo-item-transition-duration - The item transition duration CSS custom property.
 * @cssprop {String} --combo-item-transition-mode - The item transition mode CSS custom property.
 * @cssprop {String} --combo-item-transition-property - The item transition property CSS custom property.
 * @cssprop {String} --combo-item-translate - The item translate CSS custom property.
 *
 * @fires selected {SelectedEvent} - Called when the element is selected.
 * @fires deselected {DeselectedEvent} - Called when the element is deselected.
 *
 * @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
 * ```html
 * <!-- Simple text option -->
 * <mosaik-combo-item value="option1">Option 1</mosaik-combo-item>
 *
 * <!-- Option with icon prefix -->
 * <mosaik-combo-item value="javascript">
 *   <mosaik-icon slot="prefix"></mosaik-icon>
 *   JavaScript
 * </mosaik-combo-item>
 *
 * <!-- Option with description -->
 * <mosaik-combo-item value="premium">
 *   Premium Plan
 *   <mosaik-text slot="suffix" variant="caption">$29/month</mosaik-text>
 * </mosaik-combo-item>
 *
 * <!-- Disabled option -->
 * <mosaik-combo-item value="unavailable" disabled>
 *   <mosaik-icon slot="prefix"></mosaik-icon>
 *   Premium Feature (Upgrade Required)
 * </mosaik-combo-item>
 * ```
 *
 * @public
 */
let ComboItemElement = class ComboItemElement extends Themeable(Rippleable(Disableable(Valueable(Variantable(Focusable(Labelable(SelectorItemElement))))))) {
    // #region Fields
    _inheritance = addInheritanceConsumerController(this, {
        context: COMBO_INHERITANCE_CONTEXT
    });
    _isChecked;
    _icon;
    _isActive;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._isChecked = false;
        this._icon = '';
        this._isActive = false;
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `is` property.
     * The `is` property represents natural name of this element.
     *
     * @public
     * @static
     * @override
     * @readonly
     */
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    static get is() {
        return 'mosaik-combo-item';
    }
    /**
     * @inheritdoc
     * When used inside a Combo, inherits the combo's disabled state unless explicitly set.
     *
     * @public
     * @override
     */
    get disabled() {
        return this._inheritance.get('disabled', super.disabled);
    }
    set disabled(value) {
        this._inheritance.markExplicit('disabled');
        super.disabled = value;
    }
    /**
     * @inheritdoc
     * When used inside a Combo, inherits the combo's variant unless explicitly set.
     *
     * @public
     * @override
     */
    get variant() {
        return this._inheritance.get('variant', super.variant);
    }
    set variant(value) {
        this._inheritance.markExplicit('variant');
        super.variant = value;
    }
    /**
     * Gets or sets the `isChecked` property.
     *
     * @public
     * @attr
     */
    get isChecked() {
        return this._isChecked;
    }
    set isChecked(value) {
        if (this._isChecked !== value) {
            this._isChecked = value;
            this.requestUpdate('isChecked');
        }
    }
    /**
     * 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 `isActive` property.
     *
     * @public
     * @attr
     */
    get isActive() {
        return this._isActive;
    }
    set isActive(value) {
        if (this._isActive !== value) {
            this._isActive = value;
            this.requestUpdate('isActive');
        }
    }
    /**
     * Gets the `displayText` property.
     * Falls back to text content if label is empty.
     *
     * @public
     * @readonly
     * @hidden
     */
    get displayText() {
        const label = this.label.trim();
        // Fallback to text content if label attribute is not set
        if (!label) {
            return this.textContent.trim();
        }
        return label;
    }
    /**
     * Get the item parent.
     *
     * @protected
     * @readonly
     */
    get parent() {
        const projection = DomServiceLocator.current.findAncestor(this, PortalProjectionElement.is, { strict: true });
        const parent = DomServiceLocator.current.findShadowDomHost(projection.portal, { strict: true });
        return parent;
    }
    // #endregion
    // #region Methods
    /**
     * @protected
     */
    onClick(event) {
        if (this.disabled) {
            return;
        }
        if (this === event.currentTarget) {
            if (!(this.parent.selectionMode === SelectionMode.Single || this.parent.selectionMode === SelectionMode.None)) {
                this.isChecked = !this._isChecked;
            }
        }
    }
};
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], ComboItemElement.prototype, "isChecked", null);
__decorate([
    Property({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], ComboItemElement.prototype, "icon", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], ComboItemElement.prototype, "isActive", null);
__decorate([
    Listen('click'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Event]),
    __metadata("design:returntype", void 0)
], ComboItemElement.prototype, "onClick", null);
ComboItemElement = __decorate([
    Component({
        selector: 'mosaik-combo-item',
        template: comboItemElementTemplate,
        themes: {
            joy: comboItemElementJoyStyle,
            memphis: comboItemElementMemphisStyle,
            cosmopolitan: comboItemElementCosmopolitanStyle
        },
        host: {
            'tabIndex': '0',
            'role': 'option',
            'aria-selected': 'false'
        },
        options: {
            mode: 'open',
            delegatesFocus: true
        },
        imports: [
            CheckmarkElement
        ]
    }),
    __metadata("design:paramtypes", [])
], ComboItemElement);
export { ComboItemElement };
//# sourceMappingURL=ComboItemElement.js.map