// #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 { Animatable } from '../../../Behaviors/Animatable';
import { Appearanceable } from '../../../Behaviors/Appearanceable';
import { Disableable } from '../../../Behaviors/Disableable';
import { Rippleable } from '../../../Behaviors/Rippleable';
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 { Property } from '../../../Decorators/PropertyDecorator';
import { CaretPosition } from '../../../Types/CaretPosition';
import { ExpandDirection } from '../../../Types/ExpandDirection';
import { CustomElement } from '../../Abstracts/CustomElement';
import { RippleElement } from '../../Effects/Ripple/RippleElement';
import { StackElement } from '../../Layouts/Stack/StackElement';
import { IconElement } from '../../Media/Icon/IconElement';
import { FocusRingElement } from '../../Primitives/FocusRing/FocusRingElement';
import { TextElement } from '../../Primitives/Text/TextElement';
import { expanderElementTemplate } from './ExpanderElementTemplate';
import { EXPANDER_GROUP_INHERITANCE_CONTEXT } from './ExpanderGroupInheritanceContext';
import { ExpanderHeaderElement } from './ExpanderHeaderElement';
import { ExpanderSubHeaderElement } from './ExpanderSubHeaderElement';
import { expanderElementCosmopolitanStyle } from './Themes/ExpanderElement.Cosmopolitan';
import { expanderElementJoyStyle } from './Themes/ExpanderElement.Joy';
import { expanderElementMemphisStyle } from './Themes/ExpanderElement.Memphis';
// #endregion
/**
 * Expander - A component that represents an expandable section of content.
 *
 * @description This component allows users to expand or collapse a section of content, making it useful for organizing information without overwhelming the user.
 *
 * @name Expander
 * @element mosaik-expander
 * @category Grouping
 *
 * @slot - The default slot for placing main content inside the expander.
 * @slot header - The header slot.
 * @slot actions - The slot for placing action elements in the expander header.
 * @slot icon - The slot for placing an icon in the expander.
 * @slot subHeader - The slot for placing sub-header content.
 *
 * @csspart actions - The actions part.
 * @csspart caret - The part representing the caret or indicator for expansion.
 * @csspart expandable - The part representing the expandable content area.
 * @csspart focusRing - The focus ring part for accessibility.
 * @csspart actions - The part representing the actions area in the header.
 * @csspart heading - The part representing the header area.
 * @csspart icon - The part representing the icon.
 * @csspart ripple - The ripple effect part for interaction.
 * @csspart root - The root part of the expander.
 * @csspart stack - The stack part.
 * @csspart subHeader - The part representing the sub-header text.
 *
 * @cssprop {Color} --expander-background-color - The background-color property for the expander.
 * @cssprop {Color} --expander-border-color - The border-color property for the expander.
 * @cssprop {String} --expander-border-radius - The border-radius property for the expander.
 * @cssprop {String} --expander-border-style - The border-style property for the expander.
 * @cssprop {String} --expander-border-width - The border-width property for the expander.
 * @cssprop {String} --expander-divider-height - The height of the divider within the expander.
 * @cssprop {String} --expander-font-family - The font-family property for the expander text.
 * @cssprop {String} --expander-font-letter-spacing - The letter-spacing property for the expander text.
 * @cssprop {String} --expander-font-line-height - The line-height property for the expander text.
 * @cssprop {String} --expander-font-size - The font-size property for the expander text.
 * @cssprop {String} --expander-font-text-decoration - The text-decoration property for the expander text.
 * @cssprop {String} --expander-font-text-transform - The text-transform property for the expander text.
 * @cssprop {String} --expander-font-weight - The font-weight property for the expander text.
 * @cssprop {Color} --expander-foreground-color - The foreground-color property for the expander.
 * @cssprop {String} --expander-gap - The gap property for spacing within the expander.
 * @cssprop {String} --expander-padding-bottom - The padding-bottom property for the expander.
 * @cssprop {String} --expander-padding-left - The padding-left property for the expander.
 * @cssprop {String} --expander-padding-right - The padding-right property for the expander.
 * @cssprop {String} --expander-padding-top - The padding-top property for the expander.
 * @cssprop {Color} --expander-ripple-color - The ripple color CSS custom property.
 * @cssprop {String} --expander-ripple-duration - The ripple duration CSS custom property.
 * @cssprop {String} --expander-shadow - The shadow CSS custom property.
 * @cssprop {String} --expander-shadow-blur - Shadow blur radius for elevation effect
 * @cssprop {String} --expander-shadow-color - Shadow color for elevation effect
 * @cssprop {String} --expander-shadow-offset-x - Horizontal shadow offset
 * @cssprop {String} --expander-shadow-offset-y - Vertical shadow offset
 * @cssprop {String} --expander-shadow-spread - Shadow spread radius
 * @cssprop {String} --expander-transition-duration - The transition duration for the expander animations.
 * @cssprop {String} --expander-transition-mode - The transition mode for the expander animations.
 * @cssprop {String} --expander-transition-property - The transition property for the expander animations.
 * @cssprop {String} --expander-translate - The translate CSS custom property.
 *
 * @fires expanded {ExpandedEvent} - Fired when the element is expanded.
 * @fires collapsed {CollapsedEvent} - Fired when the element is collapsed.
 * @fires toggled {ToggledEvent} - Fired when the element is toggled.
 *
 * @dependency mosaik-button - The Button element.
 * @dependency mosaik-expandable - The Expandable element.
 * @dependency mosaik-expander-header - The Expander Header element.
 * @dependency mosaik-expander-sub-header - The Expander Sub Header element.
 * @dependency mosaik-focus-ring - The Focus Ring element.
 * @dependency mosaik-icon - The Icon element.
 * @dependency mosaik-ripple - The Ripple element.
 *
 * @example
 * Basic expander with header attribute:
 * ```html
 * <mosaik-expander header="Expander Header">
 *   <mosaik-text text="Content inside the expander."></mosaik-text>
 * </mosaik-expander>
 * ```
 *
 * @example
 * Expander with sub-header and pre-expanded state:
 * ```html
 * <mosaik-expander header="Advanced Settings" sub-header="Configure advanced options" is-expanded>
 *   <mosaik-text text="Advanced configuration content goes here."></mosaik-text>
 * </mosaik-expander>
 * ```
 *
 * @public
 */
let ExpanderElement = class ExpanderElement extends Themeable(Rippleable(Disableable(Animatable(Variantable(Appearanceable(CustomElement)))))) {
    // #region Fields
    _inheritance = addInheritanceConsumerController(this, {
        context: EXPANDER_GROUP_INHERITANCE_CONTEXT
    });
    _expandableElement;
    _header;
    _subHeader;
    _icon;
    _direction;
    _isExpanded;
    _caretPosition;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._header = '';
        this._subHeader = '';
        this._icon = '';
        this._direction = ExpandDirection.Down;
        this._isExpanded = false;
        this._caretPosition = CaretPosition.After;
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `is` property.
     * The `is` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-expander';
    }
    /**
     * @public
     * @override
     */
    get disabled() {
        return this._inheritance.get('disabled', super.disabled);
    }
    set disabled(value) {
        this._inheritance.markExplicit('disabled');
        super.disabled = 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 variant() {
        return this._inheritance.get('variant', super.variant);
    }
    set variant(value) {
        this._inheritance.markExplicit('variant');
        super.variant = value;
    }
    /**
     * @public
     * @override
     */
    get dir() {
        return this._inheritance.get('dir', super.dir);
    }
    set dir(value) {
        this._inheritance.markExplicit('dir');
        super.dir = value;
    }
    /**
     * Gets or sets the `header` property.
     *
     * @public
     * @attr
     */
    get header() {
        return this._header;
    }
    set header(value) {
        if (this._header !== value) {
            this._header = value;
            this.requestUpdate('header');
        }
    }
    /**
     * Gets or sets the `subHeader` property.
     *
     * @public
     * @attr
     */
    get subHeader() {
        return this._subHeader;
    }
    set subHeader(value) {
        if (this._subHeader !== value) {
            this._subHeader = value;
            this.requestUpdate('subHeader');
        }
    }
    /**
     * 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 `direction` property.
     * When used inside an ExpanderGroup, inherits the group's direction unless explicitly set.
     *
     * @public
     * @attr
     */
    get direction() {
        return this._inheritance.get('direction', this._direction);
    }
    set direction(value) {
        this._inheritance.markExplicit('direction');
        if (this._direction !== value) {
            this._direction = value;
            this.requestUpdate('direction');
        }
    }
    /**
     * Gets or sets the `isExpanded` property.
     *
     * @public
     * @attr
     */
    get isExpanded() {
        return this._isExpanded;
    }
    set isExpanded(value) {
        if (this._isExpanded !== value) {
            this._isExpanded = value;
            this.requestUpdate('isExpanded');
        }
    }
    /**
     * Gets or sets the `caretPosition` property.
     *
     * @public
     * @attr
     */
    get caretPosition() {
        return this._caretPosition;
    }
    set caretPosition(value) {
        if (this._caretPosition !== value) {
            this._caretPosition = value;
            this.requestUpdate('caretPosition');
        }
    }
    // #endregion
    // #region Methods
    /**
     * @public
     */
    toggle() {
        if (this.disabled) {
            return;
        }
        if (!this.isExpanded) {
            this.expand();
        }
        else {
            this.collapse();
        }
    }
    /**
     * @public
     */
    expand() {
        if (this.disabled) {
            return;
        }
        if (this._isExpanded) {
            return;
        }
        this._expandableElement.expand();
    }
    /**
     * @public
     */
    collapse() {
        if (this.disabled) {
            return;
        }
        if (!this._isExpanded) {
            return;
        }
        this._expandableElement.collapse();
    }
    /**
     * @protected
     * @template
     */
    onApplyTemplate() {
        super.onApplyTemplate();
        this._expandableElement = this.getTemplatePart('expandable');
    }
};
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], ExpanderElement.prototype, "header", null);
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], ExpanderElement.prototype, "subHeader", null);
__decorate([
    Property({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], ExpanderElement.prototype, "icon", null);
__decorate([
    Attribute({ type: ExpandDirection }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], ExpanderElement.prototype, "direction", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], ExpanderElement.prototype, "isExpanded", null);
__decorate([
    Attribute({ type: CaretPosition }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], ExpanderElement.prototype, "caretPosition", null);
ExpanderElement = __decorate([
    Component({
        selector: 'mosaik-expander',
        template: expanderElementTemplate,
        themes: {
            joy: expanderElementJoyStyle,
            memphis: expanderElementMemphisStyle,
            cosmopolitan: expanderElementCosmopolitanStyle
        },
        imports: [
            ExpanderHeaderElement,
            ExpanderSubHeaderElement,
            IconElement,
            RippleElement,
            FocusRingElement,
            TextElement,
            StackElement
        ]
    }),
    __metadata("design:paramtypes", [])
], ExpanderElement);
export { ExpanderElement };
//# sourceMappingURL=ExpanderElement.js.map