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CACA,iBAAA,GAKC,OAJA,KAAK,eAAiB,KAAK,eAAe,kBAAkB,KAAK,KACjE,KAAK,QAAQ,SAAS,IACrB,KAAK,eAAe,KAAK,EAAO,IAE1B,KAAK,cACb,GAGD,SAAS,aAAa,GACrB,MAAM,EAAW,EAAI,SACrB,IAAI,EAAY,GAChB,OAAO,KAAK,GAAU,SAAS,IAC9B,MAAM,EAAe,EAAS,GAC9B,EAAY,aAAa,CAAC,EAAW,EAAa,WAAW,IAE9D,EAAI,OAAS,EAEY,IAArB,EAAU,QACb,gBAAgB,EAElB,CAEA,cAAc,SAAW,SACzB,cAAc,OAAS,QAAQ,eAC/B,cAAc,aAAe,QAAQ,sBACrC,cAAc,eAAiB,QAAQ,yBACvC,cAAc,WAAa,QAAQ,oBACnC,OAAO,QAAU","file":"/npm/@baitic/docxtemplater@3.25.2/es6/docxtemplater.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.19.2.\n * Original file: /npm/@baitic/docxtemplater@3.25.2/es6/docxtemplater.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const DocUtils = require(\"./doc-utils.js\");\nDocUtils.traits = require(\"./traits.js\");\nDocUtils.moduleWrapper = require(\"./module-wrapper.js\");\nconst createScope = require(\"./scope-manager.js\");\nconst {\n\tthrowMultiError,\n\tthrowResolveBeforeCompile,\n\tthrowRenderInvalidTemplate,\n} = require(\"./errors.js\");\n\nconst collectContentTypes = require(\"./collect-content-types.js\");\nconst ctXML = \"[Content_Types].xml\";\nconst commonModule = require(\"./modules/common.js\");\n\nconst Lexer = require(\"./lexer.js\");\nconst { defaults, str2xml, xml2str, moduleWrapper, concatArrays, uniq } =\n\tDocUtils;\nconst {\n\tXTInternalError,\n\tthrowFileTypeNotIdentified,\n\tthrowFileTypeNotHandled,\n\tthrowApiVersionError,\n} = require(\"./errors.js\");\n\nconst currentModuleApiVersion = [3, 27, 0];\n\nconst Docxtemplater = class Docxtemplater {\n\tconstructor(zip, { modules = [], ...options } = {}) {\n\t\tif (!Array.isArray(modules)) {\n\t\t\tthrow new Error(\n\t\t\t\t\"The modules argument of docxtemplater's constructor must be an array\"\n\t\t\t);\n\t\t}\n\t\tthis.scopeManagers = {};\n\t\tthis.compiled = {};\n\t\tthis.modules = [commonModule()];\n\t\tthis.setOptions(options);\n\t\tmodules.forEach((module) => {\n\t\t\tthis.attachModule(module);\n\t\t});\n\t\tif (arguments.length > 0) {\n\t\t\tif (!zip || !zip.files || typeof zip.file !== \"function\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"The first argument of docxtemplater's constructor must be a valid zip file (jszip v2 or pizzip v3)\"\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.loadZip(zip);\n\t\t\t// remove the unsupported modules\n\t\t\tthis.modules = this.modules.filter((module) => {\n\t\t\t\tif (module.supportedFileTypes) {\n\t\t\t\t\tif (!Array.isArray(module.supportedFileTypes)) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\"The supportedFileTypes field of the module must be an array\"\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst isSupportedModule =\n\t\t\t\t\t\tmodule.supportedFileTypes.indexOf(this.fileType) !== -1;\n\t\t\t\t\tif (!isSupportedModule) {\n\t\t\t\t\t\tmodule.on(\"detached\");\n\t\t\t\t\t}\n\t\t\t\t\treturn isSupportedModule;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t});\n\t\t\tthis.compile();\n\t\t\tthis.v4Constructor = true;\n\t\t}\n\t}\n\tverifyApiVersion(neededVersion) {\n\t\tneededVersion = neededVersion.split(\".\").map(function (i) {\n\t\t\treturn parseInt(i, 10);\n\t\t});\n\t\tif (neededVersion.length !== 3) {\n\t\t\tthrowApiVersionError(\"neededVersion is not a valid version\", {\n\t\t\t\tneededVersion,\n\t\t\t\texplanation: \"the neededVersion must be an array of length 3\",\n\t\t\t});\n\t\t}\n\t\tif (neededVersion[0] !== currentModuleApiVersion[0]) {\n\t\t\tthrowApiVersionError(\n\t\t\t\t\"The major api version do not match, you probably have to update docxtemplater with npm install --save docxtemplater\",\n\t\t\t\t{\n\t\t\t\t\tneededVersion,\n\t\t\t\t\tcurrentModuleApiVersion,\n\t\t\t\t\texplanation: `moduleAPIVersionMismatch : needed=${neededVersion.join(\n\t\t\t\t\t\t\".\"\n\t\t\t\t\t)}, current=${currentModuleApiVersion.join(\".\")}`,\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t\tif (neededVersion[1] > currentModuleApiVersion[1]) {\n\t\t\tthrowApiVersionError(\n\t\t\t\t\"The minor api version is not uptodate, you probably have to update docxtemplater with npm install --save docxtemplater\",\n\t\t\t\t{\n\t\t\t\t\tneededVersion,\n\t\t\t\t\tcurrentModuleApiVersion,\n\t\t\t\t\texplanation: `moduleAPIVersionMismatch : needed=${neededVersion.join(\n\t\t\t\t\t\t\".\"\n\t\t\t\t\t)}, current=${currentModuleApiVersion.join(\".\")}`,\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\tneededVersion[1] === currentModuleApiVersion[1] &&\n\t\t\tneededVersion[2] > currentModuleApiVersion[2]\n\t\t) {\n\t\t\tthrowApiVersionError(\n\t\t\t\t\"The patch api version is not uptodate, you probably have to update docxtemplater with npm install --save docxtemplater\",\n\t\t\t\t{\n\t\t\t\t\tneededVersion,\n\t\t\t\t\tcurrentModuleApiVersion,\n\t\t\t\t\texplanation: `moduleAPIVersionMismatch : needed=${neededVersion.join(\n\t\t\t\t\t\t\".\"\n\t\t\t\t\t)}, current=${currentModuleApiVersion.join(\".\")}`,\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t\treturn true;\n\t}\n\tsetModules(obj) {\n\t\tthis.modules.forEach((module) => {\n\t\t\tmodule.set(obj);\n\t\t});\n\t}\n\tsendEvent(eventName) {\n\t\tthis.modules.forEach((module) => {\n\t\t\tmodule.on(eventName);\n\t\t});\n\t}\n\tattachModule(module) {\n\t\tif (this.v4Constructor) {\n\t\t\tthrow new Error(\n\t\t\t\t\"attachModule() should not be called manually when using the v4 constructor\"\n\t\t\t);\n\t\t}\n\t\tif (module.requiredAPIVersion) {\n\t\t\tthis.verifyApiVersion(module.requiredAPIVersion);\n\t\t}\n\t\tif (module.attached === true) {\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot attach a module that was already attached : \"${module.name}\". Maybe you are instantiating the module at the root level, and using it for multiple instances of Docxtemplater`\n\t\t\t);\n\t\t}\n\t\tmodule.attached = true;\n\t\tconst wrappedModule = moduleWrapper(module);\n\t\tthis.modules.push(wrappedModule);\n\t\twrappedModule.on(\"attached\");\n\t\treturn this;\n\t}\n\tsetOptions(options) {\n\t\tif (this.v4Constructor) {\n\t\t\tthrow new Error(\n\t\t\t\t\"setOptions() should not be called manually when using the v4 constructor\"\n\t\t\t);\n\t\t}\n\t\tif (!options) {\n\t\t\tthrow new Error(\n\t\t\t\t\"setOptions should be called with an object as first parameter\"\n\t\t\t);\n\t\t}\n\t\tthis.options = {};\n\t\tObject.keys(defaults).forEach((key) => {\n\t\t\tconst defaultValue = defaults[key];\n\t\t\tthis.options[key] = options[key] != null ? options[key] : defaultValue;\n\t\t\tthis[key] = this.options[key];\n\t\t});\n\t\tif (this.zip) {\n\t\t\tthis.updateFileTypeConfig();\n\t\t}\n\t\treturn this;\n\t}\n\tloadZip(zip) {\n\t\tif (this.v4Constructor) {\n\t\t\tthrow new Error(\n\t\t\t\t\"loadZip() should not be called manually when using the v4 constructor\"\n\t\t\t);\n\t\t}\n\t\tif (zip.loadAsync) {\n\t\t\tthrow new XTInternalError(\n\t\t\t\t\"Docxtemplater doesn't handle JSZip version >=3, please use pizzip\"\n\t\t\t);\n\t\t}\n\t\tthis.zip = zip;\n\t\tthis.updateFileTypeConfig();\n\n\t\tthis.modules = concatArrays([\n\t\t\tthis.fileTypeConfig.baseModules.map(function (moduleFunction) {\n\t\t\t\treturn moduleFunction();\n\t\t\t}),\n\t\t\tthis.modules,\n\t\t]);\n\t\treturn this;\n\t}\n\tprecompileFile(fileName) {\n\t\tconst currentFile = this.createTemplateClass(fileName);\n\t\tcurrentFile.preparse();\n\t\tthis.compiled[fileName] = currentFile;\n\t}\n\tcompileFile(fileName) {\n\t\tthis.compiled[fileName].parse();\n\t}\n\tgetScopeManager(to, currentFile, tags) {\n\t\tif (!this.scopeManagers[to]) {\n\t\t\tthis.scopeManagers[to] = createScope({\n\t\t\t\ttags: tags || {},\n\t\t\t\tparser: this.parser,\n\t\t\t\tcachedParsers: currentFile.cachedParsers,\n\t\t\t});\n\t\t}\n\t\treturn this.scopeManagers[to];\n\t}\n\tresolveData(data) {\n\t\tlet errors = [];\n\t\tif (!Object.keys(this.compiled).length) {\n\t\t\tthrowResolveBeforeCompile();\n\t\t}\n\t\treturn Promise.resolve(data).then((data) => {\n\t\t\tthis.setData(data);\n\t\t\tthis.setModules({\n\t\t\t\tdata: this.data,\n\t\t\t\tLexer,\n\t\t\t});\n\t\t\tthis.mapper = this.modules.reduce(function (value, module) {\n\t\t\t\treturn module.getRenderedMap(value);\n\t\t\t}, {});\n\t\t\treturn Promise.all(\n\t\t\t\tObject.keys(this.mapper).map((to) => {\n\t\t\t\t\tconst { from, data } = this.mapper[to];\n\t\t\t\t\treturn Promise.resolve(data).then((data) => {\n\t\t\t\t\t\tconst currentFile = this.compiled[from];\n\t\t\t\t\t\tcurrentFile.filePath = to;\n\t\t\t\t\t\tcurrentFile.scopeManager = this.getScopeManager(\n\t\t\t\t\t\t\tto,\n\t\t\t\t\t\t\tcurrentFile,\n\t\t\t\t\t\t\tdata\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn currentFile.resolveTags(data).then(\n\t\t\t\t\t\t\tfunction (result) {\n\t\t\t\t\t\t\t\tcurrentFile.scopeManager.finishedResolving = true;\n\t\t\t\t\t\t\t\treturn result;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tfunction (errs) {\n\t\t\t\t\t\t\t\terrors = errors.concat(errs);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t).then((resolved) => {\n\t\t\t\tif (errors.length !== 0) {\n\t\t\t\t\tthrowMultiError(errors);\n\t\t\t\t}\n\t\t\t\treturn concatArrays(resolved);\n\t\t\t});\n\t\t});\n\t}\n\tcompile() {\n\t\tif (Object.keys(this.compiled).length) {\n\t\t\treturn this;\n\t\t}\n\t\tthis.options = this.modules.reduce((options, module) => {\n\t\t\treturn module.optionsTransformer(options, this);\n\t\t}, this.options);\n\t\tthis.options.xmlFileNames = uniq(this.options.xmlFileNames);\n\t\tthis.xmlDocuments = this.options.xmlFileNames.reduce(\n\t\t\t(xmlDocuments, fileName) => {\n\t\t\t\tconst content = this.zip.files[fileName].asText();\n\t\t\t\txmlDocuments[fileName] = str2xml(content);\n\t\t\t\treturn xmlDocuments;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\tthis.setModules({\n\t\t\tzip: this.zip,\n\t\t\txmlDocuments: this.xmlDocuments,\n\t\t});\n\t\tthis.getTemplatedFiles();\n\t\t// Loop inside all templatedFiles (ie xml files with content).\n\t\t// Sometimes they don't exist (footer.xml for example)\n\t\tthis.templatedFiles.forEach((fileName) => {\n\t\t\tif (this.zip.files[fileName] != null) {\n\t\t\t\tthis.precompileFile(fileName);\n\t\t\t}\n\t\t});\n\t\tthis.templatedFiles.forEach((fileName) => {\n\t\t\tif (this.zip.files[fileName] != null) {\n\t\t\t\tthis.compileFile(fileName);\n\t\t\t}\n\t\t});\n\t\tthis.setModules({ compiled: this.compiled });\n\t\tverifyErrors(this);\n\t\treturn this;\n\t}\n\tupdateFileTypeConfig() {\n\t\tlet fileType;\n\t\tif (this.zip.files.mimetype) {\n\t\t\tfileType = \"odt\";\n\t\t}\n\t\tconst contentTypes = this.zip.files[ctXML];\n\t\tthis.targets = [];\n\t\tconst contentTypeXml = contentTypes ? str2xml(contentTypes.asText()) : null;\n\t\tconst overrides = contentTypeXml\n\t\t\t? contentTypeXml.getElementsByTagName(\"Override\")\n\t\t\t: null;\n\t\tconst defaults = contentTypeXml\n\t\t\t? contentTypeXml.getElementsByTagName(\"Default\")\n\t\t\t: null;\n\t\tif (contentTypeXml) {\n\t\t\tthis.filesContentTypes = collectContentTypes(\n\t\t\t\toverrides,\n\t\t\t\tdefaults,\n\t\t\t\tthis.zip\n\t\t\t);\n\t\t\tthis.invertedContentTypes = DocUtils.invertMap(this.filesContentTypes);\n\t\t\tthis.setModules({\n\t\t\t\tcontentTypes: this.contentTypes,\n\t\t\t\tinvertedContentTypes: this.invertedContentTypes,\n\t\t\t});\n\t\t}\n\t\tthis.modules.forEach((module) => {\n\t\t\tfileType =\n\t\t\t\tmodule.getFileType({\n\t\t\t\t\tzip: this.zip,\n\t\t\t\t\tcontentTypes,\n\t\t\t\t\tcontentTypeXml,\n\t\t\t\t\toverrides,\n\t\t\t\t\tdefaults,\n\t\t\t\t\tdoc: this,\n\t\t\t\t}) || fileType;\n\t\t});\n\t\tif (fileType === \"odt\") {\n\t\t\tthrowFileTypeNotHandled(fileType);\n\t\t}\n\t\tif (!fileType) {\n\t\t\tthrowFileTypeNotIdentified();\n\t\t}\n\n\t\tthis.fileType = fileType;\n\n\t\tthis.fileTypeConfig =\n\t\t\tthis.options.fileTypeConfig ||\n\t\t\tthis.fileTypeConfig ||\n\t\t\tDocxtemplater.FileTypeConfig[this.fileType]();\n\t\treturn this;\n\t}\n\trenderAsync(data) {\n\t\treturn this.resolveData(data).then(() => {\n\t\t\treturn this.render();\n\t\t});\n\t}\n\trender(data) {\n\t\tthis.compile();\n\t\tif (this.errors.length > 0) {\n\t\t\tthrowRenderInvalidTemplate();\n\t\t}\n\t\tif (data) {\n\t\t\tthis.setData(data);\n\t\t}\n\t\tthis.setModules({\n\t\t\tdata: this.data,\n\t\t\tLexer,\n\t\t});\n\t\tthis.mapper =\n\t\t\tthis.mapper ||\n\t\t\tthis.modules.reduce(function (value, module) {\n\t\t\t\treturn module.getRenderedMap(value);\n\t\t\t}, {});\n\n\t\tObject.keys(this.mapper).forEach((to) => {\n\t\t\tconst { from, data } = this.mapper[to];\n\t\t\tconst currentFile = this.compiled[from];\n\t\t\tcurrentFile.scopeManager = this.getScopeManager(to, currentFile, data);\n\t\t\tcurrentFile.render(to);\n\t\t\tthis.zip.file(to, currentFile.content, { createFolders: true });\n\t\t});\n\n\t\tverifyErrors(this);\n\t\tthis.sendEvent(\"syncing-zip\");\n\t\tthis.syncZip();\n\t\treturn this;\n\t}\n\tsyncZip() {\n\t\tObject.keys(this.xmlDocuments).forEach((fileName) => {\n\t\t\tthis.zip.remove(fileName);\n\t\t\tconst content = xml2str(this.xmlDocuments[fileName]);\n\t\t\treturn this.zip.file(fileName, content, { createFolders: true });\n\t\t});\n\t}\n\tsetData(data) {\n\t\tthis.data = data;\n\t\treturn this;\n\t}\n\tgetZip() {\n\t\treturn this.zip;\n\t}\n\tcreateTemplateClass(path) {\n\t\tconst content = this.zip.files[path].asText();\n\t\treturn this.createTemplateClassFromContent(content, path);\n\t}\n\tcreateTemplateClassFromContent(content, filePath) {\n\t\tconst xmltOptions = {\n\t\t\tfilePath,\n\t\t\tcontentType: this.filesContentTypes[filePath],\n\t\t};\n\t\tObject.keys(defaults)\n\t\t\t.concat([\"filesContentTypes\", \"fileTypeConfig\", \"modules\"])\n\t\t\t.forEach((key) => {\n\t\t\t\txmltOptions[key] = this[key];\n\t\t\t});\n\t\treturn new Docxtemplater.XmlTemplater(content, xmltOptions);\n\t}\n\tgetFullText(path) {\n\t\treturn this.createTemplateClass(\n\t\t\tpath || this.fileTypeConfig.textPath(this)\n\t\t).getFullText();\n\t}\n\tgetTemplatedFiles() {\n\t\tthis.templatedFiles = this.fileTypeConfig.getTemplatedFiles(this.zip);\n\t\tthis.targets.forEach((target) => {\n\t\t\tthis.templatedFiles.push(target);\n\t\t});\n\t\treturn this.templatedFiles;\n\t}\n};\n\nfunction verifyErrors(doc) {\n\tconst compiled = doc.compiled;\n\tlet allErrors = [];\n\tObject.keys(compiled).forEach((name) => {\n\t\tconst templatePart = compiled[name];\n\t\tallErrors = concatArrays([allErrors, templatePart.allErrors]);\n\t});\n\tdoc.errors = allErrors;\n\n\tif (allErrors.length !== 0) {\n\t\tthrowMultiError(allErrors);\n\t}\n}\n\nDocxtemplater.DocUtils = DocUtils;\nDocxtemplater.Errors = require(\"./errors.js\");\nDocxtemplater.XmlTemplater = require(\"./xml-templater.js\");\nDocxtemplater.FileTypeConfig = require(\"./file-type-config.js\");\nDocxtemplater.XmlMatcher = require(\"./xml-matcher.js\");\nmodule.exports = Docxtemplater;\n"]}