"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_STYLE = void 0;
const element_1 = require("../../../../../client/element");
const style_1 = require("../../../../../client/style");
exports.DEFAULT_STYLE = {
    display: 'block',
    height: '100%',
    width: '100%',
    boxSizing: 'border-box',
    // outline: 'none',
};
class AudioComp extends element_1.Element {
    constructor($props, $system) {
        super($props, $system);
        this.propHandler = {
            className: (className = '') => {
                this._audio_el.className = className;
            },
            style: (style) => {
                (0, style_1.applyStyle)(this._audio_el, Object.assign(Object.assign({}, exports.DEFAULT_STYLE), style));
            },
            src: (src) => {
                if (src === undefined) {
                    this._audio_el.pause();
                    this._audio_el.removeAttribute('src'); // empty source
                    this._audio_el.load();
                }
                else {
                    this._audio_el.src = src;
                }
            },
            stream: (stream) => {
                if (stream === undefined) {
                    this._audio_el.srcObject = null;
                }
                else {
                    this._audio_el.srcObject = stream;
                }
            },
            controls: (controls) => {
                if (controls === undefined) {
                    this._audio_el.removeAttribute('controls');
                }
                else {
                    this._audio_el.controls = controls;
                }
            },
        };
        const { className, style = {}, src, controls = true } = this.$props;
        const audio_element = this.$system.api.document.createElement('audio');
        audio_element.controls = controls;
        if (className) {
            audio_element.className = className;
        }
        if (src) {
            audio_element.src = src;
        }
        (0, style_1.applyStyle)(audio_element, Object.assign(Object.assign({}, exports.DEFAULT_STYLE), style));
        this._audio_el = audio_element;
        this.$element = audio_element;
    }
    onPropChanged(prop, current) {
        this.propHandler[prop](current);
    }
}
exports.default = AudioComp;
//# sourceMappingURL=Component.js.map