"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExtXform = void 0;
const base_xform_1 = require("../base-xform.js");
/** https://en.wikipedia.org/wiki/Office_Open_XML_file_formats#DrawingML */
const EMU_PER_PIXEL_AT_96_DPI = 9525;
class ExtXform extends base_xform_1.BaseXform {
    constructor(options) {
        super();
        this.tag = options.tag;
        this.map = {};
        this.model = { width: 0, height: 0 };
    }
    render(xmlStream, model) {
        xmlStream.openNode(this.tag);
        const width = Math.floor(model.width * EMU_PER_PIXEL_AT_96_DPI);
        const height = Math.floor(model.height * EMU_PER_PIXEL_AT_96_DPI);
        xmlStream.addAttribute("cx", width);
        xmlStream.addAttribute("cy", height);
        xmlStream.closeNode();
    }
    parseOpen(node) {
        if (node.name === this.tag) {
            this.model = {
                width: parseInt(node.attributes.cx || "0", 10) / EMU_PER_PIXEL_AT_96_DPI,
                height: parseInt(node.attributes.cy || "0", 10) / EMU_PER_PIXEL_AT_96_DPI
            };
            return true;
        }
        return false;
    }
    parseText(_text) { }
    parseClose(_name) {
        return false;
    }
}
exports.ExtXform = ExtXform;
