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AU,EAAc,GACzE,OAAO,YAAY,gBAAgB,EAAmB,OAAQ,OAChE,CASA,SAAS,YAAY,EAAU,EAAmB,GAChD,OAAO,IAAI,SAAQ,SAAU,EAAS,GACpC,YAAY,mBAAmB,GAC/B,IAAI,EAAU,CAAC,EAAU,WAAY,oBAAqB,GACtD,EAAe,cAAc,MAAM,EAAW,GAElD,EAAa,GAAG,SAAS,WACvB,GACF,IAEA,EAAa,GAAG,SAAS,SAAU,GACjC,EAAO,MAAM,GACf,GACF,GACF,CAEA,QAAQ,kBAAoB,kBAC5B,QAAQ,uBAAyB,uBACjC,QAAQ,oBAAsB,oBAC9B,QAAQ,oBAAsB,oBAC9B,QAAQ,gBAAkB,gBAC1B,QAAQ,gBAAkB,gBAC1B,QAAQ,qBAAuB,qBAC/B,QAAQ,YAAc","file":"/npm/kra-js@0.2.2/public/bundle.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/kra-js@0.2.2/public/bundle.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nvar fs = require('fs');\nvar child_process = require('child_process');\nvar fileHelpers = require('file-helpers');\n\nvar MAINDOCDTDOPTIONS = {\n  doctype: {\n    sysID: 'http://www.calligra.org/DTD/krita-2.0.dtd',\n    pubID: '-//KDE//DTD krita 2.0//EN'\n  }\n};\n\nvar DOCUMENTINFODTDOPTIONS = {\n  doctype: {\n    sysID: 'http://www.calligra.org/DTD/document-info-1.1.dtd',\n    pubID: '-//KDE//DTD document-info 1.1//EN'\n  }\n};\n\n/**\n * \n * @param {Object} documentInfoJSON \n * @param {string} folderPath \n */\nfunction makeDocumentInfoXML(documentInfoJSON, folderPath) {\n  return fileHelpers.JSONToXML(documentInfoJSON, folderPath + '/documentinfo.xml', MAINDOCDTDOPTIONS);\n}\n\n/**\n * \n * @param {Object} mainDocumentJSON \n * @param {string} folderPath \n */\nfunction makeMainDocumentXML(mainDocumentJSON, folderPath) {\n  return fileHelpers.JSONToXML(mainDocumentJSON, folderPath + '/maindoc.xml', MAINDOCDTDOPTIONS);\n}\n\nfunction readFilePromise(filePath) {\n  return new Promise(function (resolve, reject) {\n    fs.readFile(filePath, function (err, data) {\n      if (err) reject(Error(err));\n      resolve(data.toString());\n    });\n  });\n}\n\n/**\n * \n * @param {string} folderPath \n */\nfunction getDocumentInfoXML(folderPath) {\n  return readFilePromise(folderPath + '/documentinfo.xml');\n}\n\n/**\n * \n * @param {string} folderPath \n */\nfunction getMainDocumentXML(folderPath) {\n  return readFilePromise(folderPath + '/maindoc.xml');\n}\n\n/**\n * \n * @param {string} folderPath\n */\nfunction getDocumentInfo(folderPath) {\n  return new Promise(function (resolve, reject) {\n    getDocumentInfoXML(folderPath).then(function (data) {\n      return fileHelpers.XMLToJSON(data);\n    }).then(function (json) {\n      resolve(json);\n    }).catch(function (err) {\n      reject(Error(err));\n    });\n  });\n}\n\n/**\n * \n * @param {string} folderPath\n */\nfunction getMainDocument(folderPath) {\n  return new Promise(function (resolve, reject) {\n    getMainDocumentXML(folderPath).then(function (data) {\n      return fileHelpers.XMLToJSON(data);\n    }).then(function (json) {\n      resolve(json);\n    }).catch(function (err) {\n      reject(Error(err));\n    });\n  });\n}\n\n/**\n * \n * @param {string} filePath \n * @param {string} sourceFolder \n * @param {string} convertedFolder \n */\nfunction getConvertedFilePath(filePath, sourceFolder, convertedFolder) {\n  var convertedFilePath = fileHelpers.changeFolder(filePath, sourceFolder, convertedFolder);\n  return fileHelpers.changeExtension(convertedFilePath, '.kra', '.png');\n}\n\n/**\n * \n * @param {string} filePath \n * @param {string} convertedFilePath \n * @param {string} kritaPath \n * @param {string} settings \n */\nfunction convertFile(filePath, convertedFilePath, kritaPath) {\n  return new Promise(function (resolve, reject) {\n    fileHelpers.createFilePathSync(convertedFilePath);\n    var options = [filePath, '--export', '--export-filename', convertedFilePath];\n    var kritaProcess = child_process.spawn(kritaPath, options);\n\n    kritaProcess.on('close', function () {\n      resolve();\n    });\n\n    kritaProcess.on('error', function (err) {\n      reject(Error(err));\n    });\n  });\n}\n\nexports.MAINDOCDTDOPTIONS = MAINDOCDTDOPTIONS;\nexports.DOCUMENTINFODTDOPTIONS = DOCUMENTINFODTDOPTIONS;\nexports.makeDocumentInfoXML = makeDocumentInfoXML;\nexports.makeMainDocumentXML = makeMainDocumentXML;\nexports.getDocumentInfo = getDocumentInfo;\nexports.getMainDocument = getMainDocument;\nexports.getConvertedFilePath = getConvertedFilePath;\nexports.convertFile = convertFile;\n"]}