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AAqB,kBAAZ,EAA8B,iBAAmB,iBAC1D,EAAuB,iBAAX,EAA6B,SAAW,eACpD,QAAY,KAAK,QAAQ,EAAS,EAAI,CAAC,GAC7C,IAAI,EAAO,EACP,IACF,EAAO,EAAI,GACP,EAAK,WAAW,QAClB,EAAO,EAAK,UAAU,KAAK,UAG/B,MAEM,EAAa,YAFQ,GAAG,IAAS,IAAY,IAAa,IAAW,IAAS,IAAO,IAAW,KAAkB,IAAU,OAClG,iBAAX,EAA6B,GAAK,cAGvD,EAAE,UAAU,EAAO,EAAQ,EAAU,OAAQ,EAC/C,CACA,EAAE,WACA,EACA,iEAGF,MAAM,EAAiB,EAAE,YAAY,CACnC,OAAQ,EACR,gBAAgB,EAChB,OAAO,IAEH,EAAc,KAAK,uBACzB,IAAI,EAAW,EACf,GAAI,GAAe,EAAY,UAAqC,KAAzB,EAAY,SACrD,IACE,MAAM,QAAyB,IAAI,kBAAkB,GAC/C,QAAoB,IAAI,kBAAkB,GAC1C,EAAY,mBAAmB,cAAc,GACnD,EAAU,eAAe,EAAkB,GAC3C,EAAW,EAAU,SACrB,EAAiB,UACjB,EAAY,SACd,CAAE,MAAO,GACP,QAAQ,KAAK,iCAAkC,GAC/C,EAAW,CACb,CAEF,MAAO,CACL,KAAM,EAAE,WACR,IAAK,EAET,GAGN,CACA,IAAI,cAAgB,eAElB,QACA","file":"/npm/vite-plugin-comlink@5.3.0/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/vite-plugin-comlink@5.3.0/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","// src/index.ts\nimport JSON5 from \"json5\";\nimport MagicString from \"magic-string\";\nimport { normalizePath } from \"vite\";\nimport { SourceMapConsumer, SourceMapGenerator } from \"source-map\";\nvar urlPrefix_normal = \"internal:comlink:\";\nvar urlPrefix_shared = \"internal:comlink-shared:\";\nvar mode = \"\";\nvar root = \"\";\nfunction comlink() {\n  return [\n    {\n      configResolved(conf) {\n        mode = conf.mode;\n        root = conf.root;\n      },\n      name: \"comlink\",\n      resolveId(id) {\n        if (id.includes(urlPrefix_normal)) {\n          return urlPrefix_normal + id.split(urlPrefix_normal)[1];\n        }\n        if (id.includes(urlPrefix_shared)) {\n          return urlPrefix_shared + id.split(urlPrefix_shared)[1];\n        }\n      },\n      async load(id) {\n        if (id.includes(urlPrefix_normal)) {\n          const realID = normalizePath(id.replace(urlPrefix_normal, \"\"));\n          return `\n            import {expose} from 'comlink'\n            import * as api from '${normalizePath(realID)}'\n\n            expose(api)\n          `;\n        }\n        if (id.includes(urlPrefix_shared)) {\n          const realID = normalizePath(id.replace(urlPrefix_shared, \"\"));\n          return `\n            import {expose} from 'comlink'\n            import * as api from '${normalizePath(realID)}'\n\n            addEventListener('connect', (event) => {\n                const port = event.ports[0];\n                  \n                expose(api, port);\n                // We might need this later...\n                // port.start()\n            })\n          `;\n        }\n      },\n      async transform(code, id) {\n        if (!code.includes(\"ComlinkWorker\") && !code.includes(\"ComlinkSharedWorker\"))\n          return;\n        const workerSearcher = /(\\bnew\\s+)(ComlinkWorker|ComlinkSharedWorker)(\\s*\\(\\s*new\\s+URL\\s*\\(\\s*)('[^']+'|\"[^\"]+\"|`[^`]+`)(\\s*,\\s*import\\.meta\\.url\\s*\\)\\s*)(,?)([^\\)]*)(\\))/g;\n        let s = new MagicString(code);\n        const matches = code.matchAll(workerSearcher);\n        for (const match of matches) {\n          const index = match.index;\n          const matchCode = match[0];\n          const c1_new = match[1];\n          const c2_type = match[2];\n          const c3_new_url = match[3];\n          let c4_path = match[4];\n          const c5_import_meta = match[5];\n          const c6_koma = match[6];\n          const c7_options = match[7];\n          const c8_end = match[8];\n          const opt = c7_options ? JSON5.parse(c7_options) : {};\n          const urlQuote = c4_path[0];\n          c4_path = c4_path.substring(1, c4_path.length - 1);\n          if (mode === \"development\") {\n            opt.type = \"module\";\n          }\n          const options = JSON.stringify(opt);\n          const prefix = c2_type === \"ComlinkWorker\" ? urlPrefix_normal : urlPrefix_shared;\n          const className = c2_type == \"ComlinkWorker\" ? \"Worker\" : \"SharedWorker\";\n          const res = await this.resolve(c4_path, id, {});\n          let path = c4_path;\n          if (res) {\n            path = res.id;\n            if (path.startsWith(root)) {\n              path = path.substring(root.length);\n            }\n          }\n          const worker_constructor = `${c1_new}${className}${c3_new_url}${urlQuote}${prefix}${path}${urlQuote}${c5_import_meta},${options}${c8_end}`;\n          const extra_shared = c2_type == \"ComlinkWorker\" ? \"\" : \".port\";\n          const insertCode = `___wrap((${worker_constructor})${extra_shared});\n`;\n          s.overwrite(index, index + matchCode.length, insertCode);\n        }\n        s.appendLeft(\n          0,\n          `import {wrap as ___wrap} from 'vite-plugin-comlink/symbol';\n`\n        );\n        const magicStringMap = s.generateMap({\n          source: id,\n          includeContent: true,\n          hires: true\n        });\n        const existingMap = this.getCombinedSourcemap();\n        let finalMap = magicStringMap;\n        if (existingMap && existingMap.mappings && existingMap.mappings !== \"\") {\n          try {\n            const existingConsumer = await new SourceMapConsumer(existingMap);\n            const newConsumer = await new SourceMapConsumer(magicStringMap);\n            const generator = SourceMapGenerator.fromSourceMap(newConsumer);\n            generator.applySourceMap(existingConsumer, id);\n            finalMap = generator.toJSON();\n            existingConsumer.destroy();\n            newConsumer.destroy();\n          } catch (error) {\n            console.warn(\"Failed to combine source maps:\", error);\n            finalMap = magicStringMap;\n          }\n        }\n        return {\n          code: s.toString(),\n          map: finalMap\n        };\n      }\n    }\n  ];\n}\nvar index_default = comlink;\nexport {\n  comlink,\n  index_default as default\n};\n"]}