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,EAAI,YAAY,cAEvC,EAAK,UAAU,GACX,EAAK,YAAc,EAAQ,EAAM,OAAS,GAAG,EAAK,iBAC1D,GACJ,EAEA,KAAK,KAAO,SAAU,EAAM,GAExB,IAAI,EAAM,KAAK,OAAO,GAElB,EAAM,EAAI,KAAK,qBAAqB,SACpC,EAAa,EAAI,QAAQ,YAAc,EACvC,EAAW,EAAI,YAAY,aAE/B,EAAM,EAAI,QAAQ,EAAI,MAAM,EAAY,GAAW,KAAK,MAAM,KAAK,KAEnE,eAAe,qBAAqB,EAAK,KAAK,eAC9C,MAAM,eAAe,EAAK,KAAK,OAAQ,KAAK,QAC5C,eAAe,kBAAkB,EAAK,KAAK,MAC3C,iBAAiB,kBAAkB,EAAK,KAAK,YAC7C,MAAM,eAAe,EAAK,KAAK,QAE/B,EAAI,KAAK,oBAAqB,GAE9B,EAAS,EAAI,SAAS,CAAE,KAAM,IAClC,EAEI,KAAK,OAAO,OAAS,GAErB,KAAK,UAAU,KAAK,OAE5B,CAEA,OAAO,QAAU","file":"/npm/docx-merger@1.2.2/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/docx-merger@1.2.2/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","var JSZip = require('jszip');\nvar DOMParser = require('xmldom').DOMParser;\nvar XMLSerializer = require('xmldom').XMLSerializer;\n\nvar Style = require('./merge-styles');\nvar Media = require('./merge-media');\nvar RelContentType = require('./merge-relations-and-content-type');\nvar bulletsNumbering = require('./merge-bullets-numberings');\n\nfunction DocxMerger(options, files) {\n\n    this._body = [];\n    this._header = [];\n    this._footer = [];\n    this._Basestyle = options.style || 'source';\n    this._style = [];\n    this._numbering = [];\n    this._pageBreak = typeof options.pageBreak !== 'undefined' ? !!options.pageBreak : true;\n    this._files = [];\n    var self = this;\n    (files || []).forEach(function (file) {\n        self._files.push(new JSZip(file));\n    });\n    this._contentTypes = {};\n\n    this._media = {};\n    this._rel = {};\n\n    this._builder = this._body;\n\n    this.insertPageBreak = function () {\n        var pb = '<w:p> \\\r\n\t\t\t\t\t<w:r> \\\r\n\t\t\t\t\t\t<w:br w:type=\"page\"/> \\\r\n\t\t\t\t\t</w:r> \\\r\n\t\t\t\t  </w:p>';\n\n        this._builder.push(pb);\n    };\n\n    this.insertRaw = function (xml) {\n\n        this._builder.push(xml);\n    };\n\n    this.mergeBody = function (files) {\n\n        var self = this;\n        this._builder = this._body;\n\n        RelContentType.mergeContentTypes(files, this._contentTypes);\n        Media.prepareMediaFiles(files, this._media);\n        RelContentType.mergeRelations(files, this._rel);\n\n        bulletsNumbering.prepareNumbering(files);\n        bulletsNumbering.mergeNumbering(files, this._numbering);\n\n        Style.prepareStyles(files, this._style);\n        Style.mergeStyles(files, this._style);\n\n        files.forEach(function (zip, index) {\n            //var zip = new JSZip(file);\n            var xml = zip.file(\"word/document.xml\").asText();\n            xml = xml.substring(xml.indexOf(\"<w:body>\") + 8);\n            xml = xml.substring(0, xml.indexOf(\"</w:body>\"));\n            xml = xml.substring(0, xml.lastIndexOf(\"<w:sectPr\"));\n\n            self.insertRaw(xml);\n            if (self._pageBreak && index < files.length - 1) self.insertPageBreak();\n        });\n    };\n\n    this.save = function (type, callback) {\n\n        var zip = this._files[0];\n\n        var xml = zip.file(\"word/document.xml\").asText();\n        var startIndex = xml.indexOf(\"<w:body>\") + 8;\n        var endIndex = xml.lastIndexOf(\"<w:sectPr\");\n\n        xml = xml.replace(xml.slice(startIndex, endIndex), this._body.join(''));\n\n        RelContentType.generateContentTypes(zip, this._contentTypes);\n        Media.copyMediaFiles(zip, this._media, this._files);\n        RelContentType.generateRelations(zip, this._rel);\n        bulletsNumbering.generateNumbering(zip, this._numbering);\n        Style.generateStyles(zip, this._style);\n\n        zip.file(\"word/document.xml\", xml);\n\n        callback(zip.generate({ type: type }));\n    };\n\n    if (this._files.length > 0) {\n\n        this.mergeBody(this._files);\n    }\n}\n\nmodule.exports = DocxMerger;"]}