"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AutoFilterXform = void 0;
const col_cache_1 = require("../../../utils/col-cache.js");
const base_xform_1 = require("../base-xform.js");
class AutoFilterXform extends base_xform_1.BaseXform {
    get tag() {
        return "autoFilter";
    }
    render(xmlStream, model) {
        if (model) {
            if (typeof model === "string") {
                // assume range
                xmlStream.leafNode("autoFilter", { ref: model });
            }
            else {
                const getAddress = function (addr) {
                    if (typeof addr === "string") {
                        return addr;
                    }
                    return col_cache_1.colCache.getAddress(addr.row, addr.column).address;
                };
                const firstAddress = getAddress(model.from);
                const secondAddress = getAddress(model.to);
                if (firstAddress && secondAddress) {
                    xmlStream.leafNode("autoFilter", { ref: `${firstAddress}:${secondAddress}` });
                }
            }
        }
    }
    parseOpen(node) {
        if (node.name === "autoFilter") {
            this.model = node.attributes.ref;
        }
    }
}
exports.AutoFilterXform = AutoFilterXform;
