"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_STYLE = void 0;
const namespaceURI_1 = require("../../../../../client/component/namespaceURI");
const element_1 = require("../../../../../client/element");
const style_1 = require("../../../../../client/style");
exports.DEFAULT_STYLE = {
    fill: 'currentColor',
};
class SVGText extends element_1.Element {
    constructor($props, $system) {
        super($props, $system);
        const { style = {}, className, value, x, y, dx, dy, textAnchor = 'start', } = this.$props;
        const text_el = this.$system.api.document.createElementNS(namespaceURI_1.namespaceURI, 'text');
        (0, style_1.applyStyle)(text_el, Object.assign(Object.assign({}, exports.DEFAULT_STYLE), style));
        if (className) {
            text_el.classList.add(className);
        }
        if (value !== undefined) {
            text_el.textContent = value;
        }
        if (x !== undefined) {
            text_el.setAttribute('x', `${x}`);
        }
        if (y !== undefined) {
            text_el.setAttribute('y', `${y}`);
        }
        if (dx !== undefined) {
            text_el.setAttribute('dx', `${dx}`);
        }
        if (dy !== undefined) {
            text_el.setAttribute('dy', `${dy}`);
        }
        if (textAnchor !== undefined) {
            text_el.setAttribute('text-anchor', textAnchor);
        }
        this._text_el = text_el;
        this.$element = text_el;
    }
    onPropChanged(prop, current) {
        if (prop === 'style') {
            (0, style_1.applyStyle)(this._text_el, Object.assign(Object.assign({}, exports.DEFAULT_STYLE), current));
        }
        else if (prop === 'value') {
            this._text_el.textContent = current;
        }
        else if (prop === 'dy') {
            this._text_el.setAttribute('dy', `${current !== null && current !== void 0 ? current : ''}`);
        }
        else if (prop === 'dx') {
            this._text_el.setAttribute('dx', `${current !== null && current !== void 0 ? current : ''}`);
        }
        else if (prop === 'x') {
            this._text_el.setAttribute('x', `${current !== null && current !== void 0 ? current : ''}`);
        }
        else if (prop === 'y') {
            this._text_el.setAttribute('y', `${current !== null && current !== void 0 ? current : ''}`);
        }
        else if (prop === 'textAnchor') {
            this._text_el.setAttribute('text-anchor', current);
        }
    }
}
exports.default = SVGText;
//# sourceMappingURL=Component.js.map