"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PicXform = void 0;
const base_xform_1 = require("../base-xform.js");
const static_xform_1 = require("../static-xform.js");
const blip_fill_xform_1 = require("./blip-fill-xform.js");
const nv_pic_pr_xform_1 = require("./nv-pic-pr-xform.js");
const sp_pr_1 = require("./sp-pr.js");
class PicXform extends base_xform_1.BaseXform {
    constructor() {
        super();
        this.map = {
            "xdr:nvPicPr": new nv_pic_pr_xform_1.NvPicPrXform(),
            "xdr:blipFill": new blip_fill_xform_1.BlipFillXform(),
            "xdr:spPr": new static_xform_1.StaticXform(sp_pr_1.spPrJSON)
        };
    }
    get tag() {
        return "xdr:pic";
    }
    prepare(model, options) {
        model.index = options.index + 1;
    }
    render(xmlStream, model) {
        xmlStream.openNode(this.tag);
        this.map["xdr:nvPicPr"].render(xmlStream, model);
        this.map["xdr:blipFill"].render(xmlStream, model);
        this.map["xdr:spPr"].render(xmlStream, model);
        xmlStream.closeNode();
    }
    parseOpen(node) {
        if (this.parser) {
            this.parser.parseOpen(node);
            return true;
        }
        switch (node.name) {
            case this.tag:
                this.reset();
                break;
            default:
                this.parser = this.map[node.name];
                if (this.parser) {
                    this.parser.parseOpen(node);
                }
                break;
        }
        return true;
    }
    parseText() { }
    parseClose(name) {
        if (this.parser) {
            if (!this.parser.parseClose(name)) {
                this.mergeModel(this.parser.model);
                this.parser = undefined;
            }
            return true;
        }
        switch (name) {
            case this.tag:
                return false;
            default:
                // not quite sure how we get here!
                return true;
        }
    }
}
exports.PicXform = PicXform;
