// #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 { RendererServiceLocator } from '../../../../Dom/Renderer';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { Watch } from '../../../Decorators/WatchDecorator';
import { CustomElement } from '../../Abstracts/CustomElement';
import { DrawerContainerElement } from './DrawerContainerElement';
import { drawerContentElementTemplate } from './DrawerContentElementTemplate';
import { drawerContentElementJoyStyle } from './Themes/DrawerContentElement.Joy';
import { drawerContentElementMemphisStyle } from './Themes/DrawerContentElement.Memphis';
import { drawerContentElementCosmopolitanStyle } from './Themes/DrawerContentElement.Cosmopolitan';
import { Themeable } from '../../../Behaviors/Themeable';
// #endregion
/**
 * DrawerContent - The main content area inside a drawer.
 *
 * @description
 * Provides the scrollable body region of a drawer panel.
 * Place this element inside `mosaik-drawer`.
 *
 * @name DrawerContent
 * @element mosaik-drawer-content
 * @category Overlays
 *
 * @slot - The default content element.
 *
 * @cssprop {String} --drawer-content-font-family - The content font family CSS custom property.
 * @cssprop {String} --drawer-content-font-letter-spacing - The content font letter spacing CSS custom property.
 * @cssprop {String} --drawer-content-font-line-height - The content font line height CSS custom property.
 * @cssprop {String} --drawer-content-font-size - The content font size CSS custom property.
 * @cssprop {String} --drawer-content-font-text-decoration - The content font text decoration CSS custom property.
 * @cssprop {String} --drawer-content-font-text-transform - The content font text transform CSS custom property.
 * @cssprop {String} --drawer-content-font-weight - The content font weight CSS custom property.
 * @cssprop {String} --drawer-content-gap - The content gap CSS custom property.
 * @cssprop {String} --drawer-content-padding-bottom - The content padding bottom CSS custom property.
 * @cssprop {String} --drawer-content-padding-left - The content padding left CSS custom property.
 * @cssprop {String} --drawer-content-padding-right - The content padding right CSS custom property.
 * @cssprop {String} --drawer-content-padding-top - The content padding top CSS custom property.
 * @cssprop {String} --drawer-content-shadow - The content shadow CSS custom property.
 * @cssprop {String} --drawer-content-shadow-blur - The content shadow blur CSS custom property.
 * @cssprop {String} --drawer-content-shadow-color - The content shadow color CSS custom property.
 * @cssprop {String} --drawer-content-shadow-offset-x - The content shadow offset x CSS custom property.
 * @cssprop {String} --drawer-content-shadow-offset-y - The content shadow offset y CSS custom property.
 * @cssprop {String} --drawer-content-shadow-spread - The content shadow spread CSS custom property.
 * @cssprop {String} --drawer-content-transition-duration - The content transition duration CSS custom property.
 * @cssprop {String} --drawer-content-transition-mode - The content transition mode CSS custom property.
 * @cssprop {String} --drawer-content-transition-property - The content transition property CSS custom property.
 * @cssprop {String} --drawer-content-translate - The content translate CSS custom property.
 *
 * @example
 * Drawer content with list items:
 * ```html
 * <mosaik-drawer-content>
 *   <nav>
 *     <a href="/home">Home</a>
 *     <a href="/settings">Settings</a>
 *   </nav>
 * </mosaik-drawer-content>
 * ```
 *
 * @public
 */
let DrawerContentElement = class DrawerContentElement extends Themeable(CustomElement) {
    // #region Fields
    _opened;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._opened = false;
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `is` property.
     * The `is` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-drawer-content';
    }
    /**
     * Gets or sets the `opened` property.
     *
     * @public
     * @attr
     */
    get opened() {
        return this._opened;
    }
    set opened(value) {
        if (this._opened !== value) {
            this._opened = value;
        }
    }
    // #endregion
    // #region Methods
    /**
     * @protected
     * @override
     */
    onApplyTemplate() {
        super.onApplyTemplate();
        // we use strict false here because for standalone drawers (DrawerService) the container is not necessarily.
        const container = DomServiceLocator.current.findAncestor(this, DrawerContainerElement, { strict: false });
        // If the container is not the parent of this element, then return.
        // if (container.content !== this) {
        //     return;
        // }
        container?.on('contentMarginChanged', (e) => {
            RendererServiceLocator.current.setStyle(this, 'margin-left', `${e.detail.left}px`);
            RendererServiceLocator.current.setStyle(this, 'margin-right', `${e.detail.right}px`);
            this.opened = container.drawer?.isOpen ?? false;
        }, { passive: true });
    }
    /**
     * @protected
     * @virtual
     */
    onOpenedPropertyChanged(_prev, next) {
        if (next) {
            RendererServiceLocator.current.addClass(this, 'drawer-opened');
        }
        else {
            RendererServiceLocator.current.removeClass(this, 'drawer-opened');
        }
    }
};
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], DrawerContentElement.prototype, "opened", null);
__decorate([
    Watch('opened'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Boolean, Boolean]),
    __metadata("design:returntype", void 0)
], DrawerContentElement.prototype, "onOpenedPropertyChanged", null);
DrawerContentElement = __decorate([
    Component({
        selector: 'mosaik-drawer-content',
        template: drawerContentElementTemplate,
        themes: {
            joy: drawerContentElementJoyStyle,
            memphis: drawerContentElementMemphisStyle,
            cosmopolitan: drawerContentElementCosmopolitanStyle
        },
        options: {
            mode: 'open',
            delegatesFocus: true
        },
        imports: []
    }),
    __metadata("design:paramtypes", [])
], DrawerContentElement);
export { DrawerContentElement };
//# sourceMappingURL=DrawerContentElement.js.map