{"version":3,"sources":["jsdelivr-header.js","/npm/xd2svg@2.0.1/lib/converter/xd2svg.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA;;;;;;;GAQA,OAAO,eAAe,QAAS,aAAc,CAAE,OAAO,IACtD,MAAM,WAAa,QAAQ,eACrB,KAAO,QAAQ,MACf,OAAS,QAAQ,QACjB,MAAQ,QAAQ,OAChB,OAAS,QAAQ,QACjB,SAAW,QAAQ,aACnB,OAAS,QAAQ,0BACjB,OAAS,QAAQ,UACjB,QAAU,OAAO,UAAU,YACjC,eAAe,OAAO,EAAO,EAAU,SAAS,gBAC5C,MAAM,EAAO,IACN,SAAS,kBACT,GAED,QAAkB,WAAW,GAC7B,EAAM,OAAO,YAAY,EAAW,GAG1C,OAFI,EAAU,gBACV,EAAU,iBACP,CACX,CAEA,eAAe,WAAW,GAItB,GAHI,OAAO,SAAS,KAChB,EAAQ,qBAAqB,IACjC,wBAAwB,GACpB,KAAK,UAAU,GAAO,cACtB,MAAO,CAAE,KAAM,GACnB,MAAM,EAAY,MAAM,QAAQ,CAAE,eAAe,EAAM,QAAS,IAAI,KAAK,UAMzE,aALM,QAAQ,EAAO,CAAE,IAAK,EAAU,OACjC,OAAO,IAER,MADA,OAAO,MAAM,uEACP,CAAK,IAER,CACX,CACA,SAAS,qBAAqB,GAC1B,MAAM,EAAM,MAAM,QAAQ,CAAE,eAAe,EAAM,QAAS,UAAU,KAAK,UACnE,EAAQ,OAAO,KAAK,EAAI,KAAM,WAEpC,OADA,KAAK,cAAc,EAAO,GACnB,CACX,CACA,SAAS,wBAAwB,GAC7B,IAAK,KAAK,WAAW,GAEjB,MADA,OAAO,MAAM,8BAA8B,4CACrC,IAEd,CA1BA,QAAQ,QAAU","file":"/npm/xd2svg@2.0.1/lib/converter/xd2svg.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/xd2svg@2.0.1/lib/converter/xd2svg.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\";\r\n/**\r\n * @license\r\n * Copyright Andrey Chalkin <L2jLiga>. All Rights Reserved.\r\n *\r\n * Use of this source code is governed by an MIT-style license that can be\r\n * found in the LICENSE file at https://github.com/L2jLiga/xd2svg/LICENSE\r\n */\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nconst extractZip = require(\"extract-zip\");\r\nconst fs_1 = require(\"fs\");\r\nconst path_1 = require(\"path\");\r\nconst tmp_1 = require(\"tmp\");\r\nconst util_1 = require(\"util\");\r\nconst common_1 = require(\"../common\");\r\nconst logger = require(\"../common/utils/logger\");\r\nconst core_1 = require(\"./core\");\r\nconst extract = util_1.promisify(extractZip);\r\nasync function xd2svg(input, options = common_1.defaultOptions) {\r\n    const opts = {\r\n        ...common_1.defaultOptions,\r\n        ...options,\r\n    };\r\n    const directory = await openMockup(input);\r\n    const svg = core_1.proceedFile(directory, opts);\r\n    if (directory.removeCallback)\r\n        directory.removeCallback();\r\n    return svg;\r\n}\r\nexports.default = xd2svg;\r\nasync function openMockup(input) {\r\n    if (Buffer.isBuffer(input))\r\n        input = createFileFromBuffer(input);\r\n    throwIfPathDoesNotExist(input);\r\n    if (fs_1.lstatSync(input).isDirectory())\r\n        return { name: input };\r\n    const directory = tmp_1.dirSync({ unsafeCleanup: true, postfix: `_${Date.now()}` });\r\n    await extract(input, { dir: directory.name })\r\n        .catch((error) => {\r\n        logger.error(`Unable to unpack XD, please make sure that provided file is correct`);\r\n        throw error;\r\n    });\r\n    return directory;\r\n}\r\nfunction createFileFromBuffer(data) {\r\n    const dir = tmp_1.dirSync({ unsafeCleanup: true, postfix: `_input_${Date.now()}` });\r\n    const input = path_1.join(dir.name, '/tmp.xd');\r\n    fs_1.writeFileSync(input, data);\r\n    return input;\r\n}\r\nfunction throwIfPathDoesNotExist(path) {\r\n    if (!fs_1.existsSync(path)) {\r\n        logger.error(`No such file or directory: ${path}, please make sure that path is correct`);\r\n        throw null;\r\n    }\r\n}\r\n"]}