// #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 { Busyable } from '../../Behaviors/Busyable';
import { Slottable } from '../../Behaviors/Slottable';
import { Themeable } from '../../Behaviors/Themeable';
import { HideOnScrollController } from '../../Controllers/HideOnScrollController';
import { Attribute } from '../../Decorators/AttributeDecorator';
import { Component } from '../../Decorators/ComponentDecorator';
import { Property } from '../../Decorators/PropertyDecorator';
import { CustomElement } from '../Abstracts/CustomElement';
import { ButtonElement } from '../Buttons/Button/ButtonElement';
import { ToolbarElement } from '../Grouping/Toolbar/ToolbarElement';
import { ProgressBarElement } from '../Ranges/ProgressBar/ProgressBarElement';
import { appHeaderElementTemplate } from './AppHeaderElementTemplate';
import { appHeaderElementCosmopolitanStyle } from './Themes/AppHeaderElement.Cosmopolitan';
import { appHeaderElementJoyStyle } from './Themes/AppHeaderElement.Joy';
import { appHeaderElementMemphisStyle } from './Themes/AppHeaderElement.Memphis';
// #endregion
/**
 * AppHeader - A component representing the header section of an application, often used to display application
 *             branding, navigation, and other important elements.
 *
 * @description
 * The AppHeader component is designed to provide a consistent header section across an application. It typically
 * includes elements such as the application title, navigation menus, and user profile options. This component
 * is customizable and can be styled to fit the application's branding and layout needs.
 *
 * @name AppHeader
 * @element mosaik-app-header
 * @category Shell
 *
 * @slot actions - The slot for action buttons or icons, typically used for user profile options or quick actions.
 * @slot brand - The slot for the application branding, such as a logo or title.
 * @slot menu - The slot for the menu button, which can be used to toggle navigation drawers or other menus.
 *
 * @csspart progressBar - The progressBar part.
 * @csspart root - The root part of the AppHeader component, used for applying styles and theming.
 * @csspart toggle - The toggle button part of the AppHeader, which can be used to open or close navigation drawers.
 * @csspart toolbar - The toolbar part of the AppHeader component, used for containing navigation or action items.
 *
 * @cssprop {String} --app-header-background-color - The header background color CSS custom property.
 * @cssprop {String} --app-header-border-color - The header border color CSS custom property.
 * @cssprop {String} --app-header-border-radius - The header border radius CSS custom property.
 * @cssprop {String} --app-header-border-style - The header border style CSS custom property.
 * @cssprop {String} --app-header-border-width - The header border width CSS custom property.
 * @cssprop {String} --app-header-font-family - The header font family CSS custom property.
 * @cssprop {String} --app-header-font-letter-spacing - The header font letter spacing CSS custom property.
 * @cssprop {String} --app-header-font-line-height - The header font line height CSS custom property.
 * @cssprop {String} --app-header-font-size - The header font size CSS custom property.
 * @cssprop {String} --app-header-font-text-decoration - The header font text decoration CSS custom property.
 * @cssprop {String} --app-header-font-text-transform - The header font text transform CSS custom property.
 * @cssprop {String} --app-header-font-weight - The header font weight CSS custom property.
 * @cssprop {String} --app-header-foreground-color - The header foreground color CSS custom property.
 * @cssprop {String} --app-header-gap - The header gap CSS custom property.
 * @cssprop {String} --app-header-line-thickness - The header line thickness CSS custom property.
 * @cssprop {String} --app-header-padding-bottom - The header padding bottom CSS custom property.
 * @cssprop {String} --app-header-padding-left - The header padding left CSS custom property.
 * @cssprop {String} --app-header-padding-right - The header padding right CSS custom property.
 * @cssprop {String} --app-header-padding-top - The header padding top CSS custom property.
 * @cssprop {String} --app-header-shadow - The header shadow CSS custom property.
 * @cssprop {String} --app-header-shadow-blur - The header shadow blur CSS custom property.
 * @cssprop {String} --app-header-shadow-color - The header shadow color CSS custom property.
 * @cssprop {String} --app-header-shadow-offset-x - The header shadow offset x CSS custom property.
 * @cssprop {String} --app-header-shadow-offset-y - The header shadow offset y CSS custom property.
 * @cssprop {String} --app-header-shadow-spread - The header shadow spread CSS custom property.
 * @cssprop {String} --app-header-transition-duration - The header transition duration CSS custom property.
 * @cssprop {String} --app-header-transition-mode - The header transition mode CSS custom property.
 * @cssprop {String} --app-header-transition-property - The header transition property CSS custom property.
 * @cssprop {String} --app-header-translate - The header translate CSS custom property.
 *
 * @dependency mosaik-button - The Button element.
 * @dependency mosaik-progress-bar - The Progress Bar element.
 * @dependency mosaik-toolbar - The Toolbar element.
 *
 * @example
 * ```html
 * <mosaik-app-header>
 *   <div slot="menu">
 *   </div>
 *   <div slot="brand">
 *   </div>
 *   <div slot="actions">
 *   </div>
 * </mosaik-app-header>
 * ```
 *
 * @example
 * App header with toggle state:
 * ```html
 * <mosaik-app-header is-toggled>
 *   <span slot="brand">My Application</span>
 * </mosaik-app-header>
 * ```
 *
 * @public
 */
let AppHeaderElement = class AppHeaderElement extends Themeable(Slottable(Busyable(CustomElement))) {
    // #region Fields
    _scrollController;
    _isToggled;
    _scrollTargetFn;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._isToggled = false;
        this._scrollTargetFn = null;
        this._scrollController = new HideOnScrollController(this, {
            hideOnScroll: true,
            scrollUpThreshold: 1,
            scrollDownThreshold: screen.height,
            behavior: 'auto'
        });
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `is` property.
     * The `is` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-app-header';
    }
    /**
     * Gets or sets the `isToggled` property.
     *
     * @public
     * @attr
     */
    get isToggled() {
        return this._isToggled;
    }
    set isToggled(value) {
        if (this._isToggled !== value) {
            this._isToggled = value;
            this.requestUpdate('isToggled');
        }
    }
    /**
     * Gets or sets the `scrollTargetFn` property.
     *
     * @public
     */
    get scrollTargetFn() {
        return this._scrollTargetFn;
    }
    set scrollTargetFn(value) {
        if (this._scrollTargetFn !== value) {
            this._scrollTargetFn = value;
            this.requestUpdate('scrollTargetFn');
            this._scrollController.scrollTargetFn = this._scrollTargetFn;
        }
    }
    // #endregion
    // #region Methods
    /**
     * @public
     * @override
     */
    onSlotChanges(slotName) {
        super.onSlotChanges(slotName);
        if (slotName === 'menu') {
            const toggleButton = this.getSlotAssignmentsOf(slotName, ButtonElement)[0];
            toggleButton?.on('click', () => this.onToggle());
        }
    }
    /**
     * @protected
     * @override
     */
    onApplyTemplate() {
        super.onApplyTemplate();
        const toggleButton = this.getTemplatePart('toggle');
        toggleButton.on('click', () => this.onToggle());
    }
    /**
     * @private
     */
    onToggle() {
        DomServiceLocator.current.findAncestor(this, 'mosaik-app')?.toggleNavigation();
    }
};
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], AppHeaderElement.prototype, "isToggled", null);
__decorate([
    Property({ type: Function }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [Object])
], AppHeaderElement.prototype, "scrollTargetFn", null);
AppHeaderElement = __decorate([
    Component({
        selector: 'mosaik-app-header',
        template: appHeaderElementTemplate,
        themes: {
            joy: appHeaderElementJoyStyle,
            memphis: appHeaderElementMemphisStyle,
            cosmopolitan: appHeaderElementCosmopolitanStyle
        },
        host: {
            'slot': 'header',
            'part': 'header',
            'attr.exportparts': 'toolbar:header-toolbar'
        },
        imports: [
            ProgressBarElement,
            ToolbarElement,
            ButtonElement
        ]
    }),
    __metadata("design:paramtypes", [])
], AppHeaderElement);
export { AppHeaderElement };
//# sourceMappingURL=AppHeaderElement.js.map