"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LAYOUT_STYLE_ATTRS = void 0;
exports.extractStyle = extractStyle;
exports._extractStyle = _extractStyle;
exports.extractLayoutStyle = extractLayoutStyle;
exports._extractFromRawStyle = _extractFromRawStyle;
const id_1 = require("./id");
const rawExtractStyle_1 = require("./rawExtractStyle");
exports.LAYOUT_STYLE_ATTRS = [
    'position',
    'boxSizing',
    'margin',
    'marginLeft',
    'marginTop',
    'marginBottom',
    'marginRight',
    'top',
    'left',
    'right',
    'bottom',
    'width',
    'height',
    'opacity',
    'fontSize',
    'transform',
    'aspectRatio',
    'color',
    'object-fit',
];
function extractStyle(component, trait, measureText) {
    const { $node } = component;
    return _extractStyle(component, $node, trait, measureText);
}
function _extractStyle(component, element, trait, measureText) {
    const style = (0, rawExtractStyle_1.rawExtractStyle)(element, trait, measureText);
    return _extractFromRawStyle(component, element, style, trait, measureText);
}
function extractLayoutStyle(style) {
    const style_ = {};
    for (const attr of exports.LAYOUT_STYLE_ATTRS) {
        style_[attr] = style[attr] ?? style[(0, id_1.camelToDashed)(attr)] ?? '';
    }
    return style_;
}
function _extractFromRawStyle(component, element, style, trait, measureText) {
    const { api: { window: { getComputedStyle }, }, } = component.$system;
    if (element instanceof SVGElement) {
        const treatProp = (name) => {
            if (style[name] === undefined) {
                style[name] = '100%';
            }
        };
        treatProp('width');
        treatProp('height');
    }
    return style;
}
//# sourceMappingURL=extractStyle.js.map