import { BaseXform } from "../base-xform.js";
class SheetFormatPropertiesXform extends BaseXform {
    get tag() {
        return "sheetFormatPr";
    }
    render(xmlStream, model) {
        if (model) {
            const attributes = {
                defaultRowHeight: model.defaultRowHeight,
                // Only output outlineLevelRow/Col when non-zero (matches Excel behavior)
                outlineLevelRow: model.outlineLevelRow || undefined,
                outlineLevelCol: model.outlineLevelCol || undefined,
                // Only output dyDescent if explicitly set (MS extension, not ECMA-376 standard)
                "x14ac:dyDescent": model.dyDescent || undefined
            };
            // Only output defaultColWidth if explicitly set
            if (model.defaultColWidth) {
                attributes.defaultColWidth = model.defaultColWidth;
            }
            // default value for 'defaultRowHeight' is 15, this should not be 'custom'
            if (!model.defaultRowHeight || model.defaultRowHeight !== 15) {
                attributes.customHeight = "1";
            }
            if (Object.values(attributes).some((value) => value !== undefined)) {
                xmlStream.leafNode("sheetFormatPr", attributes);
            }
        }
    }
    parseOpen(node) {
        if (node.name === "sheetFormatPr") {
            this.model = {
                defaultRowHeight: parseFloat(node.attributes.defaultRowHeight || "0"),
                dyDescent: parseFloat(node.attributes["x14ac:dyDescent"] || "0"),
                outlineLevelRow: parseInt(node.attributes.outlineLevelRow || "0", 10),
                outlineLevelCol: parseInt(node.attributes.outlineLevelCol || "0", 10)
            };
            if (node.attributes.defaultColWidth) {
                this.model.defaultColWidth = parseFloat(node.attributes.defaultColWidth);
            }
            return true;
        }
        return false;
    }
    parseText() { }
    parseClose() {
        return false;
    }
}
export { SheetFormatPropertiesXform };
