// #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 { fadeOut, fadeSlideIn } from '../../../../Animations/Presets/Fade';
import { Emit } from '../../../../Events/Decorators/EmitDecorator';
import { HTMLElementEventEmitter } from '@breadstone/mosaik-elements';
import { IntlController } from '../../../../Intl/IntlController';
import { Animatable } from '../../../Behaviors/Animatable';
import { Elevatable } from '../../../Behaviors/Elevatable';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { CustomElement } from '../../Abstracts/CustomElement';
import { ButtonElement } from '../../Buttons/Button/ButtonElement';
import { BannerElement } from '../../Grouping/Banner/BannerElement';
import { cookiesConsentElementTemplate } from './CookiesConsentElementTemplate';
import { CookiesConsentElementIntl } from './Intl/CookiesConsentElementIntl';
import { cookiesConsentElementJoyStyle } from './Themes/CookiesConsentElement.Joy';
import { cookiesConsentElementRetroStyle } from './Themes/CookiesConsentElement.Retro';
import { cookiesConsentElementCosmopolitanStyle } from './Themes/CookiesConsentElement.Cosmopolitan';
import { Themeable } from '../../../Behaviors/Themeable';
// #endregion
/**
 * The `{@link CookiesConsentElement}` element.
 *
 * @fires accepted - Called when the user accepts the cookies disclaimer.
 * @fires rejected - Called when the user rejects the cookies disclaimer.
 * @fires detailed - Called when the user wants to see the detailed cookies disclaimer.
 *
 * @public
 */
let CookiesConsentElement = class CookiesConsentElement extends Themeable(Animatable(Elevatable(CustomElement))) {
    // #region Fields
    _intl;
    _accepted;
    _dismissed;
    _hasAcceptedCookies;
    _acceptable;
    _dismissable;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._intl = new IntlController(this, {
            factory: () => new CookiesConsentElementIntl()
        });
        this._hasAcceptedCookies = false;
        this._acceptable = false;
        this._dismissable = false;
        this._accepted = new HTMLElementEventEmitter(this, 'accepted');
        this._dismissed = new HTMLElementEventEmitter(this, 'dismissed');
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `{@link is}` property.
     * The `{@link is}` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-cookies-consent';
    }
    /**
     * Gets or sets the `hasAcceptedCookies` property.
     * Whether the user has already accepted the cookies disclaimer.
     *
     * @public
     * @attr
     */
    get hasAcceptedCookies() {
        return this._hasAcceptedCookies;
    }
    set hasAcceptedCookies(value) {
        if (this._hasAcceptedCookies !== value) {
            this._hasAcceptedCookies = value;
            this.requestUpdate('hasAcceptedCookies');
        }
    }
    /**
     * Gets or sets the `acceptable` property.
     *
     * @public
     * @attr
     */
    get acceptable() {
        return this._acceptable;
    }
    set acceptable(value) {
        if (this._acceptable !== value) {
            this._acceptable = value;
            this.requestUpdate('acceptable');
        }
    }
    /**
     * Gets or sets the `dismissable` property.
     *
     * @public
     * @attr
     */
    get dismissable() {
        return this._dismissable;
    }
    set dismissable(value) {
        if (this._dismissable !== value) {
            this._dismissable = value;
            this.requestUpdate('dismissable');
        }
    }
    /**
     * Called when the cookies disclaimer is accepted.
     * Provides reference to `{@link IEventDetail}` as event detail.
     *
     * @public
     * @readonly
     * @eventProperty
     */
    get accepted() {
        return this._accepted;
    }
    /**
     * Called when the cookies disclaimer is rejected.
     * Provides reference to `{@link IEventDetail}` as event detail.
     *
     * @public
     * @readonly
     * @eventProperty
     */
    get dismissed() {
        return this._dismissed;
    }
    /**
     * Returns the `intl` property.
     *
     * @public
     * @readonly
     */
    get intl() {
        return this._intl.intl;
    }
    // #endregion
    // #region Methods
    /**
     * @public
     * @override
     */
    onEnterAnimation() {
        return this.play(fadeSlideIn);
    }
    /**
     * @public
     * @override
     */
    onExitAnimation() {
        return this.play(fadeOut);
    }
    /**
     * @public
     * @override
     */
    disconnectedCallback() {
        super.disconnectedCallback();
    }
    /**
     * Emits the {@link accepted} event.
     *
     * @protected
     */
    onAccepted(args) {
        this.hasAcceptedCookies = true;
        void this.onExitAnimation().then(() => {
            this._accepted.emit(args);
        });
    }
    /**
     * Emits the {@link dismissed} event.
     *
     * @protected
     */
    onDismissed(args) {
        this.hasAcceptedCookies = false;
        void this.onExitAnimation().then(() => {
            this._dismissed.emit(args);
        });
    }
    /**
     * @private
     * @template
     */
    onAccept() {
        this.onAccepted({});
    }
    /**
     * @private
     * @template
     */
    onDismiss() {
        this.onDismissed({});
    }
};
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], CookiesConsentElement.prototype, "hasAcceptedCookies", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], CookiesConsentElement.prototype, "acceptable", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], CookiesConsentElement.prototype, "dismissable", null);
__decorate([
    Emit({ eventName: 'accepted' }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [])
], CookiesConsentElement.prototype, "accepted", null);
__decorate([
    Emit({ eventName: 'dismissed' }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [])
], CookiesConsentElement.prototype, "dismissed", null);
CookiesConsentElement = __decorate([
    Component({
        selector: 'mosaik-cookies-consent',
        template: cookiesConsentElementTemplate,
        themes: {
            joy: cookiesConsentElementJoyStyle,
            retro: cookiesConsentElementRetroStyle,
            cosmopolitan: cookiesConsentElementCosmopolitanStyle
        },
        imports: [
            BannerElement,
            ButtonElement
        ]
    }),
    __metadata("design:paramtypes", [])
], CookiesConsentElement);
export { CookiesConsentElement };
//# sourceMappingURL=CookiesConsentElement.js.map