// #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 { HTMLElementEventEmitter } from '@breadstone/mosaik-elements';
import { Emit } from '../../../../../events/Decorators/EmitDecorator';
import { Themeable } from '../../../../Behaviors/Themeable';
import { Attribute } from '../../../../Decorators/AttributeDecorator';
import { Component } from '../../../../Decorators/ComponentDecorator';
import { Property } from '../../../../Decorators/PropertyDecorator';
import { RecorderState } from '../../../../Types/RecorderState';
import { ButtonElement } from '../../../Buttons/Button/ButtonElement';
import { TextElement } from '../../../Primitives/Text/TextElement';
import { ChatToolBaseElement } from './Abstracts/ChatToolBaseElement';
import { voiceRecorderChatToolElementJoyStyle } from './Themes/VoiceRecorderChatToolElement.Joy';
import { voiceRecorderChatToolElementTemplate } from './VoiceRecorderChatToolElementTemplate';
// #endregion
/**
 * The `VoiceRecorderChatToolElement` element.
 *
 * @csspart cancel - The cancel part.
 * @csspart row - The row part.
 * @csspart start - The start part.
 * @csspart stop - The stop part.
 * @csspart timer - The timer part.
 *
 * @fires recorderCancel {RecorderCancelEvent} - Called when the recording is canceled.
 * @fires recorderStart {RecorderStartEvent} - Called when the recording is started.
 * @fires recorderPause {RecorderPauseEvent} - Called when the recording is paused.
 * @fires recorderResume {RecorderResumeEvent} - Called when the recording is resumed.
 * @fires recorderStop {RecorderStopEvent} - Called when the recording is stopped.
 *
 * @dependency mosaik-button - The Button element.
 * @dependency mosaik-text - The Text element.
 *
 * @example
 * Basic usage inside a chat element tools slot:
 * ```html
 * <mosaik-voice-recorder-chat-tool></mosaik-voice-recorder-chat-tool>
 * ```
 *
 * @example
 * With pause support enabled:
 * ```html
 * <mosaik-voice-recorder-chat-tool can-pause></mosaik-voice-recorder-chat-tool>
 * ```
 *
 * @public
 */
let VoiceRecorderChatToolElement = class VoiceRecorderChatToolElement extends Themeable(ChatToolBaseElement) {
    // #region Fields
    _recCancel;
    _recStart;
    _recPause;
    _recResume;
    _recStop;
    _state;
    _elapsedTime;
    _maxDurationTime;
    _objectUrl;
    _canPause;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._state = RecorderState.Idle;
        this._elapsedTime = 0;
        this._maxDurationTime = 0;
        this._objectUrl = null;
        this._canPause = false;
        this._recCancel = new HTMLElementEventEmitter(this, 'recorderCancel');
        this._recStart = new HTMLElementEventEmitter(this, 'recorderStart');
        this._recPause = new HTMLElementEventEmitter(this, 'recorderPause');
        this._recResume = new HTMLElementEventEmitter(this, 'recorderResume');
        this._recStop = new HTMLElementEventEmitter(this, 'recorderStop');
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `is` property.
     * The `is` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-voice-recorder-chat-tool';
    }
    /**
     * Gets or sets the `state` property.
     *
     * @public
     * @attr
     */
    get state() {
        return this._state;
    }
    set state(value) {
        if (this._state !== value) {
            this._state = value;
            this.requestUpdate('state');
        }
    }
    /**
     * Gets or sets the `elapsedTime` property.
     *
     * @public
     * @attr
     */
    get elapsedTime() {
        return this._elapsedTime;
    }
    set elapsedTime(value) {
        if (this._elapsedTime !== value) {
            this._elapsedTime = value;
            this.requestUpdate('elapsedTime');
        }
    }
    /**
     * Gets or sets the `maxDurationTime` property.
     *
     * @public
     * @attr
     */
    get maxDurationTime() {
        return this._maxDurationTime;
    }
    set maxDurationTime(value) {
        if (this._maxDurationTime !== value) {
            this._maxDurationTime = value;
            this.requestUpdate('maxDurationTime');
        }
    }
    /**
     * Gets or sets the `objectUrl` property.
     *
     * @public
     */
    get objectUrl() {
        return this._objectUrl;
    }
    set objectUrl(value) {
        if (this._objectUrl !== value) {
            this._objectUrl = value;
            this.requestUpdate('objectUrl');
        }
    }
    /**
     * Gets or sets the `canPause` property.
     *
     * @public
     * @attr
     */
    get canPause() {
        return this._canPause;
    }
    set canPause(value) {
        if (this._canPause !== value) {
            this._canPause = value;
            this.requestUpdate('canPause');
        }
    }
    /**
     * Called when the recording is canceled.
     * Provides reference to `IEventDetail` as event detail.
     *
     * @public
     * @readonly
     * @eventProperty
     */
    get recCancel() {
        return this._recCancel;
    }
    /**
     * Called when the recording is resumed.
     * Provides reference to `IEventDetail` as event detail.
     *
     * @public
     * @readonly
     * @eventProperty
     */
    get recResume() {
        return this._recResume;
    }
    /**
     * Called when the recording is stopped.
     * Provides reference to `IEventDetail` as event detail.
     *
     * @public
     * @readonly
     * @eventProperty
     */
    get recStop() {
        return this._recStop;
    }
    /**
     * Called when the recording is started.
     * Provides reference to `IEventDetail` as event detail.
     *
     * @public
     * @readonly
     * @eventProperty
     */
    get recStart() {
        return this._recStart;
    }
    /**
     * Called when the recording is paused.
     * Provides reference to `IEventDetail` as event detail.
     *
     * @public
     * @readonly
     * @eventProperty
     */
    get recPause() {
        return this._recPause;
    }
    // #endregion
    // #region Methods
    execute(args) {
        throw new Error('Method not implemented.');
    }
    /**
     * Emits the `recCancel` event.
     *
     * @protected
     */
    onRecCancel(args) {
        this._recCancel.emit(args);
    }
    /**
     * Emits the `recStart` event.
     *
     * @protected
     */
    onRecStart(args) {
        this._recStart.emit(args);
    }
    /**
     * Emits the `recPause` event.
     *
     * @protected
     */
    onRecPause(args) {
        this._recPause.emit(args);
    }
    /**
     * Emits the `recResume` event.
     *
     * @protected
     */
    onRecResume(args) {
        this._recResume.emit(args);
    }
    /**
     * Emits the `recStop` event.
     *
     * @protected
     */
    onRecStop(args) {
        this._recStop.emit(args);
    }
};
__decorate([
    Emit({ eventName: 'recorderCancel' }),
    __metadata("design:type", Object)
], VoiceRecorderChatToolElement.prototype, "_recCancel", void 0);
__decorate([
    Emit({ eventName: 'recorderStart' }),
    __metadata("design:type", Object)
], VoiceRecorderChatToolElement.prototype, "_recStart", void 0);
__decorate([
    Emit({ eventName: 'recorderPause' }),
    __metadata("design:type", Object)
], VoiceRecorderChatToolElement.prototype, "_recPause", void 0);
__decorate([
    Emit({ eventName: 'recorderResume' }),
    __metadata("design:type", Object)
], VoiceRecorderChatToolElement.prototype, "_recResume", void 0);
__decorate([
    Emit({ eventName: 'recorderStop' }),
    __metadata("design:type", Object)
], VoiceRecorderChatToolElement.prototype, "_recStop", void 0);
__decorate([
    Attribute({ type: RecorderState }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], VoiceRecorderChatToolElement.prototype, "state", null);
__decorate([
    Attribute({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], VoiceRecorderChatToolElement.prototype, "elapsedTime", null);
__decorate([
    Attribute({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], VoiceRecorderChatToolElement.prototype, "maxDurationTime", null);
__decorate([
    Property({ type: String }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [Object])
], VoiceRecorderChatToolElement.prototype, "objectUrl", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], VoiceRecorderChatToolElement.prototype, "canPause", null);
VoiceRecorderChatToolElement = __decorate([
    Component({
        selector: 'mosaik-voice-recorder-chat-tool',
        template: voiceRecorderChatToolElementTemplate,
        themes: {
            joy: voiceRecorderChatToolElementJoyStyle,
            memphis: voiceRecorderChatToolElementJoyStyle,
            cosmopolitan: voiceRecorderChatToolElementJoyStyle
        },
        host: {
            slot: 'tools'
        },
        options: {
            mode: 'open',
            delegatesFocus: true
        },
        imports: [
            ButtonElement,
            TextElement
        ]
    }),
    __metadata("design:paramtypes", [])
], VoiceRecorderChatToolElement);
export { VoiceRecorderChatToolElement };
//# sourceMappingURL=VoiceRecorderChatToolElement.js.map