// #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 { Appearanceable } from '../../../Behaviors/Appearanceable';
import { Disableable } from '../../../Behaviors/Disableable';
import { Sizeable } from '../../../Behaviors/Sizeable';
import { TextFormattable } from '../../../Behaviors/TextFormattable';
import { Themeable } from '../../../Behaviors/Themeable';
import { Variantable } from '../../../Behaviors/Variantable';
import { addInheritanceConsumerController } from '../../../Controllers/InheritanceConsumerController';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { ListBulletType } from '../../../Types/ListBulletType';
import { ListNumberingType } from '../../../Types/ListNumberingType';
import { ListType } from '../../../Types/ListType';
import { CustomElement } from '../../Abstracts/CustomElement';
import { TextElement } from '../Text/TextElement';
import { LISTING_INHERITANCE_CONTEXT } from './ListingInheritanceContext';
import { listingItemElementTemplate } from './ListingItemElementTemplate';
import { ListingItemMarkerElement } from './ListingItemMarkerElement';
import { listingItemElementCosmopolitanStyle } from './Themes/ListingItemElement.Cosmopolitan';
import { listingItemElementJoyStyle } from './Themes/ListingItemElement.Joy';
import { listingItemElementMemphisStyle } from './Themes/ListingItemElement.Memphis';
// #endregion
/**
 * ListingItem - A list item component for use inside a `<mosaik-listing>`.
 *
 * @description
 * The ListingItem component renders a single item within a listing. It automatically
 * consumes inherited properties from its parent `<mosaik-listing>` to determine list type,
 * numbering style, and visual appearance. Each item renders a `<mosaik-listing-item-marker>` in a
 * slotted `marker` area and content in the default slot. The marker is auto-indexed
 * based on the item's DOM position among sibling listing items.
 *
 * @name ListingItem
 * @element mosaik-listing-item
 * @category Primitives
 *
 * @slot - Default slot for list item content.
 * @slot marker - Slot for a custom marker element. Defaults to an auto-configured `<mosaik-listing-item-marker>`.
 *
 * @csspart content - The content wrapper.
 * @csspart content-text - The content text element.
 * @csspart header - The header text element.
 * @csspart item - The outer list item container.
 * @csspart marker - The default marker element.
 *
 * @cssprop {String} --listing-item-background-color - The background color of the list item.
 * @cssprop {String} --listing-item-font-family - The font family for list item content.
 * @cssprop {String} --listing-item-font-letter-spacing - The item font letter spacing CSS custom property.
 * @cssprop {String} --listing-item-font-line-height - The line height for list item content.
 * @cssprop {String} --listing-item-font-size - The font size for list item content.
 * @cssprop {String} --listing-item-font-text-decoration - The item font text decoration CSS custom property.
 * @cssprop {String} --listing-item-font-text-transform - The item font text transform CSS custom property.
 * @cssprop {String} --listing-item-font-weight - The font weight for list item content.
 * @cssprop {String} --listing-item-foreground-color - The text color of the list item.
 * @cssprop {String} --listing-item-gap - The gap between marker and content.
 * @cssprop {String} --listing-item-padding-bottom - The bottom padding inside the list item.
 * @cssprop {String} --listing-item-padding-left - The left padding inside the list item.
 * @cssprop {String} --listing-item-padding-right - The right padding inside the list item.
 * @cssprop {String} --listing-item-padding-top - The top padding inside the list item.
 * @cssprop {String} --listing-item-shadow - The item shadow CSS custom property.
 * @cssprop {String} --listing-item-shadow-blur - The item shadow blur CSS custom property.
 * @cssprop {String} --listing-item-shadow-color - The item shadow color CSS custom property.
 * @cssprop {String} --listing-item-shadow-offset-x - The item shadow offset x CSS custom property.
 * @cssprop {String} --listing-item-shadow-offset-y - The item shadow offset y CSS custom property.
 * @cssprop {String} --listing-item-shadow-spread - The item shadow spread CSS custom property.
 * @cssprop {String} --listing-item-transition-duration - The duration of transition animations.
 * @cssprop {String} --listing-item-transition-mode - The timing function for transition animations.
 * @cssprop {String} --listing-item-transition-property - The CSS properties to animate during transitions.
 * @cssprop {String} --listing-item-translate - The item translate CSS custom property.
 *
 * @dependency mosaik-listing-item-marker - The Listing Item Marker element.
 * @dependency mosaik-text - The Text element.
 *
 * @example
 * Basic listing item inside an ordered listing:
 * ```html
 * <mosaik-listing type="ordered">
 *   <mosaik-listing-item>First item</mosaik-listing-item>
 *   <mosaik-listing-item>Second item</mosaik-listing-item>
 * </mosaik-listing>
 * ```
 *
 * @example
 * Listing item with custom ordinal value:
 * ```html
 * <mosaik-listing type="ordered">
 *   <mosaik-listing-item value="5">Starts at five</mosaik-listing-item>
 *   <mosaik-listing-item>Continues at six</mosaik-listing-item>
 * </mosaik-listing>
 * ```
 *
 * @public
 */
let ListingItemElement = class ListingItemElement extends Themeable(TextFormattable(Appearanceable(Variantable(Sizeable(Disableable(CustomElement)))))) {
    // #region Fields
    _inheritance = addInheritanceConsumerController(this, {
        context: LISTING_INHERITANCE_CONTEXT
    });
    _header;
    _content;
    _value;
    // #endregion
    // #region Ctor
    constructor() {
        super();
        this._header = '';
        this._content = '';
        this._value = null;
    }
    // #endregion
    // #region Properties
    static get is() {
        return 'mosaik-listing-item';
    }
    /**
     * Gets or sets the `header` property.
     * The default value is an empty string, which means no header is displayed.
     *
     * @public
     * @attr
     */
    get header() {
        return this._header;
    }
    set header(value) {
        if (this._header !== value) {
            this._header = value;
            this.requestUpdate('header');
        }
    }
    /**
     * Gets or sets the `content` property.
     * The default value is an empty string, which means no content text is displayed.
     *
     * @public
     * @attr
     */
    get content() {
        return this._content;
    }
    set content(value) {
        if (this._content !== value) {
            this._content = value;
            this.requestUpdate('content');
        }
    }
    /**
     * Gets or sets the ordinal value of this list item.
     * When set, overrides the auto-calculated index.
     * The default value is `null` (auto-numbered).
     *
     * @public
     * @attr
     */
    get value() {
        return this._value;
    }
    set value(value) {
        if (this._value !== value) {
            this._value = value;
            this.requestUpdate('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;
    }
    /**
     * @public
     * @override
     */
    get size() {
        return this._inheritance.get('size', super.size);
    }
    set size(value) {
        this._inheritance.markExplicit('size');
        super.size = value;
    }
    /**
     * Gets the inherited list type from the parent listing.
     *
     * @public
     * @readonly
     */
    get listType() {
        return this._inheritance.get('type', ListType.Unordered);
    }
    /**
     * Gets the inherited numbering type from the parent listing.
     *
     * @public
     * @readonly
     */
    get listNumberingType() {
        return this._inheritance.get('numberingType', ListNumberingType.Decimal);
    }
    /**
     * Gets the inherited bullet type from the parent listing.
     *
     * @public
     * @readonly
     */
    get listBulletType() {
        return this._inheritance.get('bulletType', ListBulletType.Disc);
    }
    // #endregion
    // #region Methods
    /**
     * Computes the resolved index of this item within its parent listing.
     * Takes into account `value` overrides, `start`, and `reversed` props.
     *
     * @returns The resolved 1-based index.
     *
     * @internal
     */
    resolveIndex() {
        if (this._value !== null) {
            return this._value;
        }
        const parent = this.parentElement;
        if (!parent) {
            return 1;
        }
        const siblings = Array.from(parent.querySelectorAll(':scope > mosaik-listing-item'));
        const position = siblings.indexOf(this);
        if (position === -1) {
            return 1;
        }
        const start = this._inheritance.get('start', null) ?? 1;
        const reversed = this._inheritance.get('reversed', false);
        if (reversed) {
            return start + siblings.length - 1 - position;
        }
        return start + position;
    }
};
__decorate([
    Attribute({
        type: String
    }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], ListingItemElement.prototype, "header", null);
__decorate([
    Attribute({
        type: String
    }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], ListingItemElement.prototype, "content", null);
__decorate([
    Attribute({
        type: Number
    }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [Object])
], ListingItemElement.prototype, "value", null);
ListingItemElement = __decorate([
    Component({
        selector: 'mosaik-listing-item',
        template: listingItemElementTemplate,
        themes: {
            joy: listingItemElementJoyStyle,
            memphis: listingItemElementMemphisStyle,
            cosmopolitan: listingItemElementCosmopolitanStyle
        },
        host: {
            'role': 'listitem'
        },
        imports: [ListingItemMarkerElement, TextElement]
    }),
    __metadata("design:paramtypes", [])
], ListingItemElement);
export { ListingItemElement };
//# sourceMappingURL=ListingItemElement.js.map