"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const html_1 = require("../../../../client/html");
const renderComponent_1 = require("../../../../client/render/renderComponent");
const element_1 = require("../../../../util/element");
const DEFAULT_STYLE = {
    width: '100%',
    height: '100%',
    color: 'currentColor',
    boxSizing: 'border-box',
};
class Render extends html_1.default {
    constructor($props, $system) {
        super($props, $system, $system.api.document.createElement('div'), DEFAULT_STYLE);
        const { component, id, className, innerText, tabIndex, title, draggable } = this.$props;
        if (id !== undefined) {
            this.$element.id = id;
        }
        if (className !== undefined) {
            this.$element.className = className;
        }
        if (innerText) {
            this.$element.innerText = innerText;
        }
        if (tabIndex !== undefined) {
            this.$element.tabIndex = tabIndex;
        }
        if (title) {
            this.$element.title = title;
        }
        if (draggable !== undefined) {
            this.$element.setAttribute('draggable', draggable.toString());
        }
        this.$propHandler = {
            ...this.$propHandler,
            unit: (component) => {
                if (this._unlisten) {
                    this._unlisten();
                    this._unlisten = undefined;
                    (0, element_1.removeChildren)(this.$element);
                }
                if (component) {
                    this._unlisten = (0, renderComponent_1.renderComponent)(this.$element, this.$system, component);
                }
            },
        };
    }
}
exports.default = Render;
//# sourceMappingURL=Component.js.map