// #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 { getSlotElements } from '../../../../Dom/Slot';
import { Appearanceable } from '../../../Behaviors/Appearanceable';
import { Busyable } from '../../../Behaviors/Busyable';
import { Disableable } from '../../../Behaviors/Disableable';
import { TextFormattable } from '../../../Behaviors/TextFormattable';
import { Variantable } from '../../../Behaviors/Variantable';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { Property } from '../../../Decorators/PropertyDecorator';
import { Watch } from '../../../Decorators/WatchDecorator';
import { Appearance } from '../../../Types/Appearance';
import { Variant } from '../../../Types/Variant';
import { CustomElement } from '../../Abstracts/CustomElement';
import { StackElement } from '../../Layouts/Stack/StackElement';
import { TextElement } from '../../Primitives/Text/TextElement';
import { AvatarElement } from '../Avatar/AvatarElement';
import { ChatMessageAvatarElement } from './ChatMessageAvatarElement';
import { chatMessageElementTemplate } from './ChatMessageElementTemplate';
import { chatMessageElementJoyStyle } from './Themes/ChatMessageElement.Joy';
import { chatMessageElementRetroStyle } from './Themes/ChatMessageElement.Retro';
import { chatMessageElementCosmopolitanStyle } from './Themes/ChatMessageElement.Cosmopolitan';
import { Themeable } from '../../../Behaviors/Themeable';
import { Valueable } from '../../../Behaviors/Valueable';
// #endregion
/**
 * The `{@link ChatMessageElement}` element.
 *
 * @public
 */
let ChatMessageElement = class ChatMessageElement extends Themeable(Variantable(Appearanceable(Disableable(TextFormattable(Busyable(Valueable(CustomElement))))))) {
    // #region Fields
    _text;
    _attachments;
    _reply;
    _at;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._text = '';
        this._attachments = new Array();
        this._reply = false;
        this._at = '';
    }
    // #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-chat-message';
    }
    /**
     * Gets or sets the `text` property.
     *
     * @public
     */
    get text() {
        return this._text;
    }
    set text(value) {
        if (this._text !== value) {
            this._text = value;
            this.requestUpdate('text');
        }
    }
    /**
     * Gets or sets the `attachments` property.
     *
     * @public
     */
    get attachments() {
        return this._attachments;
    }
    set attachments(value) {
        if (this._attachments !== value) {
            this._attachments = value;
            this.requestUpdate('attachments');
        }
    }
    /**
     * Gets or sets the `reply` property.
     *
     * @public
     * @attr
     */
    get reply() {
        return this._reply;
    }
    set reply(value) {
        if (this._reply !== value) {
            this._reply = value;
            this.requestUpdate('reply');
        }
    }
    /**
     * Gets or sets the `at` property.
     *
     * @public
     */
    get at() {
        return this._at;
    }
    set at(value) {
        if (this._at !== value) {
            this._at = value;
            this.requestUpdate('at');
        }
    }
    // #endregion
    // #region Methods
    /**
     * @protected
     * @template
     */
    onSlotChange(_event) {
        const items = getSlotElements(this.shadowRoot, 'avatar');
        // set inherited properties
        if (this.hasUpdated) {
            items.forEach((x) => {
                x.variant = this.variant;
                x.appearance = this.appearance;
                x.disabled = this.disabled;
            });
        }
    }
    /**
     * @protected
     */
    onVariantPropertyChanged(_prev, next) {
        const items = getSlotElements(this.shadowRoot, 'avatar');
        if (next) {
            items.forEach((x) => {
                x.variant = next;
            });
        }
    }
    /**
     * @protected
     */
    onAppearancePropertyChanged(_prev, next) {
        const items = getSlotElements(this.shadowRoot, 'avatar');
        if (next) {
            items.forEach((x) => {
                x.appearance = next;
            });
        }
    }
    /**
     * @protected
     */
    onDisabledPropertyChanged(_prev, next) {
        const items = getSlotElements(this.shadowRoot, 'avatar');
        if (next !== undefined) {
            items.forEach((x) => {
                x.disabled = next;
            });
        }
    }
};
__decorate([
    Property({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], ChatMessageElement.prototype, "text", null);
__decorate([
    Property({ type: Array }),
    __metadata("design:type", Array),
    __metadata("design:paramtypes", [Array])
], ChatMessageElement.prototype, "attachments", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], ChatMessageElement.prototype, "reply", null);
__decorate([
    Property({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], ChatMessageElement.prototype, "at", null);
__decorate([
    Watch('variant'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String]),
    __metadata("design:returntype", void 0)
], ChatMessageElement.prototype, "onVariantPropertyChanged", null);
__decorate([
    Watch('appearance'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String]),
    __metadata("design:returntype", void 0)
], ChatMessageElement.prototype, "onAppearancePropertyChanged", null);
__decorate([
    Watch('disabled'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Boolean, Boolean]),
    __metadata("design:returntype", void 0)
], ChatMessageElement.prototype, "onDisabledPropertyChanged", null);
ChatMessageElement = __decorate([
    Component({
        selector: 'mosaik-chat-message',
        template: chatMessageElementTemplate,
        themes: {
            joy: chatMessageElementJoyStyle,
            retro: chatMessageElementRetroStyle,
            cosmopolitan: chatMessageElementCosmopolitanStyle
        },
        host: {
            role: 'listitem',
            slot: 'message'
        },
        imports: [
            TextElement,
            AvatarElement,
            ChatMessageAvatarElement,
            StackElement
        ]
    }),
    __metadata("design:paramtypes", [])
], ChatMessageElement);
export { ChatMessageElement };
//# sourceMappingURL=ChatMessageElement.js.map