UNPKG

transform-to-tailwindcss

Version:

🎨 Revolutionary CSS-to-TailwindCSS migration tool with surgical precision. Transform legacy stylesheets to utility-first classes instantly across Vue, React, Svelte, and Astro projects.

1,791 lines (1,771 loc) 214 kB
import { createRequire } from "node:module"; import fs from "node:fs"; import path from "node:path"; import process$1 from "node:process"; import { createGenerator } from "@unocss/core"; import presetUno from "@unocss/preset-uno"; import fsp from "node:fs/promises"; import { transformStyleToTailwindPre, transformStyleToTailwindcss } from "transform-to-tailwindcss-core"; import { parse } from "node-html-parser"; import { parse as parse$1, traverse } from "@babel/core"; import vueJsxPlugin from "@vue/babel-plugin-jsx"; //#region rolldown:runtime var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __commonJS = (cb, mod) => function() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { key = keys[i]; if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: ((k) => from[k]).bind(null, key), enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); var __require = /* @__PURE__ */ createRequire(import.meta.url); //#endregion //#region src/utils.ts const TRANSFER_FLAG = ".__unocss_transfer__"; /** * 检查是否在 Node.js 环境中运行 * @returns {boolean} 如果在 Node.js 环境中返回 true,在浏览器环境中返回 false */ function isNodeEnvironment() { try { var _process$versions; const process$2 = __require("node:process"); return typeof window === "undefined" && typeof process$2 !== "undefined" && Boolean((_process$versions = process$2.versions) === null || _process$versions === void 0 ? void 0 : _process$versions.node); } catch { return false; } } function isNot(s) { return /\[&:not\(/.test(s); } function getLastName(s) { const all = s.split("-"); return all[all.length - 1]; } function joinWithUnderLine(s) { return s.replace(/\s+/, " ").split(" ").join("_"); } /** * 删除空格 * @param { string } s 字符串 * @param { TrimType } type 所有 | 前置 | 前后 | 后置 'all' | 'pre' | 'around' | 'post' * @returns string */ function trim(s, type = "around") { if (type === "pre") return s.replace(/(^\s*)/g, ""); if (type === "post") return s.replace(/(\s*$)/g, ""); if (type === "all") return s.replace(/\s+/g, ""); if (type === "around") return s.replace(/(^\s*)|(\s*$)/g, ""); return s; } function diffTemplateStyle(before, after) { const s1 = before.match(/<style scoped>.*<\/style>/s); const s2 = after.match(/<style scoped>.*<\/style>/s); return s1[0] === s2[0]; } function isEmptyStyle(code) { return /<style scoped>\s*<\/style>/.test(code); } function getStyleScoped(code) { const match = code.match(/<style scoped>(.*)<\/style>/s); if (!match) return ""; return match[1]; } function getCssType(filename) { const ext = filename.split(".").pop(); return ext === "styl" ? "stylus" : ext; } function transformUnocssBack(code) { const result = []; return new Promise((resolve) => { createGenerator({}, { presets: [presetUno()] }).generate(code || "").then((res) => { const css = res.getLayers(); code.forEach((item) => { try { const reg = /* @__PURE__ */ new RegExp(`${item.replace(/([!()[\]*])/g, "\\\\$1")}{(.*)}`); const match = css.match(reg); if (!match) return; const matcher = match[1]; result.push(matcher.split(";").filter((i) => /^\w[\w\-]*:/.test(i))[0].split(":")[0]); } catch (error) {} }); resolve(result); }); }); } /** * 动态导入 Vue Compiler SFC,避免打包时的问题 * @returns Vue Compiler SFC 中的方法 */ async function getVueCompilerSfc() { const { parse: parse$3 } = await import("@vue/compiler-sfc"); return { parse: parse$3 }; } //#endregion //#region src/prettierCode.ts const emptyStyle = /<style[\s\w'=]*>(\s*)/; async function prettierCode(code) { const { parse: parse$3 } = await getVueCompilerSfc(); const { descriptor: { styles } } = parse$3(code); if (!styles.length) return code.replace(emptyStyle, (all, v) => all.replace(v, "")).replace(/\n+/g, "\n"); const { content } = styles[0]; return code.replace(content, content.replace(/\n+/g, "\n")); } //#endregion //#region src/lessCompiler.ts async function lessCompiler(css, filepath, globalCss, debug) { if (typeof window !== "undefined") throw new Error("lessCompiler is not supported in this browser"); if (debug) console.log(`[transform-to-tailwindcss] Compiling LESS file: ${filepath || "unknown file"}`); let result = globalCss ? `${globalCss}${css}` : css; try { const less = await import("less"); const { LessPluginModuleResolver } = await import("less-plugin-module-resolver"); result = (await less.default.render(result, { filename: filepath, plugins: [new LessPluginModuleResolver({ alias: {} })] })).css; return result; } catch (error) { if (error.code === "MODULE_NOT_FOUND" || error.message.includes("Cannot resolve module")) { const missingModule = error.message.includes("less-plugin-module-resolver") ? "less-plugin-module-resolver" : "less"; throw new Error(`${missingModule} not found. Please install it in your project:\nnpm install ${missingModule}\nor\nyarn add ${missingModule}\nor\npnpm add ${missingModule}`); } console.error(`Error:\n transform-to-unocss(lessCompiler) ${error.toString()}`); } } //#endregion //#region src/sassCompiler.ts /** * Sass 编译器 - 处理 SCSS/Sass 文件编译 * * 解决了以下问题: * 1. Sass 新版本的 mixed-decls 弃用警告 * 2. legacy-js-api 弃用警告(优先使用新 API) * 3. @import 规则弃用警告(Dart Sass 3.0.0 将移除) * 4. 嵌套规则后声明的兼容性问题 * 5. 支持用户项目中的 Sass 版本 * 6. 自动检测并使用最合适的 Sass API * 7. 多层次的警告抑制机制(console.warn 拦截 + 自定义 logger + silenceDeprecations) * * @param css 要编译的 CSS 内容 * @param filepath 文件路径,用于解析 @import 等 * @param globalCss 全局 CSS 内容(字符串)或包含 CSS 的对象(如 {css: string}) * @param debug 是否开启调试模式 * @returns 编译后的 CSS 字符串 */ async function sassCompiler(css, filepath, globalCss, debug) { if (typeof window !== "undefined") throw new Error("sassCompiler is not supported in this browser"); if (typeof css !== "string") { if (debug) console.warn(`[transform-to-unocss] sassCompiler received non-string CSS input: ${typeof css}`); return String(css || ""); } if (filepath) { if (!(filepath.endsWith(".scss") || filepath.endsWith(".sass") || filepath.includes(".vue") || filepath.includes(".svelte") || filepath.includes(".astro") || filepath.includes(".tsx") || filepath.includes(".jsx")) && debug) console.warn(`[transform-to-unocss] sassCompiler called for unexpected file type: ${filepath}`); } if (debug) console.log(`[transform-to-unocss] Compiling SCSS file: ${filepath || "unknown file"}`); const baseDir = path.dirname(filepath); let result = ""; if (globalCss) { if (typeof globalCss === "string") result += globalCss; else if (typeof globalCss === "object" && globalCss !== null) { const globalCssObj = globalCss; if ("css" in globalCssObj && typeof globalCssObj.css === "string") result += globalCssObj.css; else if (debug) console.warn(`[transform-to-unocss] Unexpected globalCss object format:`, globalCss); } else if (debug) console.warn(`[transform-to-unocss] globalCss is not a string or valid object: ${typeof globalCss}`, globalCss); } result += css; try { const sass = await import("sass"); const originalWarn = console.warn; const filteredWarn = (message, ...args) => { const messageStr = String(message); if (![ "Deprecation Warning", "mixed-decls", "legacy-js-api", "import", "Sass @import rules are deprecated", "will be removed in Dart Sass", "More info and automated migrator" ].some((pattern) => messageStr.includes(pattern))) originalWarn(message, ...args); }; try { const sassInfo = sass.info || ""; const isModernSass = sassInfo.includes("dart-sass") || sassInfo.includes("1."); const compileOptions = { syntax: "scss", loadPaths: [baseDir] }; if (isModernSass) { compileOptions.quietDeps = true; compileOptions.verbose = false; try { compileOptions.silenceDeprecations = [ "mixed-decls", "import", "legacy-js-api" ]; } catch (e) {} compileOptions.logger = { warn: (message, options) => { if ([ "mixed-decls", "legacy-js-api", "import", "Deprecation Warning", "behavior for declarations that appear after nested", "will be changing to match the behavior specified by CSS", "The legacy JS API is deprecated", "Sass @import rules are deprecated", "will be removed in Dart Sass 3.0.0", "More info and automated migrator" ].some((pattern) => message.includes(pattern))) return; if (debug) console.warn(`[transform-to-unocss] Sass warning: ${message}`); } }; } let compiledResult; console.warn = filteredWarn; if (sass.compile && typeof sass.compile === "function") { const fs$3 = await import("node:fs"); const tempFilePath = `${(await import("node:os")).tmpdir()}/transform-to-unocss-${Date.now()}.scss`; try { fs$3.writeFileSync(tempFilePath, result); compiledResult = sass.compile(tempFilePath, compileOptions); } finally { try { fs$3.unlinkSync(tempFilePath); } catch (e) {} } } else compiledResult = sass.compileString(result, compileOptions); result = compiledResult.css; return result; } finally { console.warn = originalWarn; } } catch (error) { if (error.code === "MODULE_NOT_FOUND" || error.message.includes("Cannot resolve module")) throw new Error("Sass compiler not found. Please install sass in your project:\nnpm install sass\nor\nyarn add sass\nor\npnpm add sass"); console.error(`Error:\n transform-to-unocss(sassCompiler) ${error.toString()}`); return css; } } //#endregion //#region src/stylusCompiler.ts async function stylusCompiler(css, filepath, globalCss, debug) { if (typeof window !== "undefined") throw new Error("Stylus is not supported in this browser"); if (debug) console.log(`[transform-to-tailwindcss] Compiling Stylus file: ${filepath || "unknown file"}`); let result = globalCss ? `${globalCss}${css}` : css; try { result = (await import("stylus")).default.render(result, { filename: filepath }); return result; } catch (error) { if (error.code === "MODULE_NOT_FOUND" || error.message.includes("Cannot resolve module")) throw new Error("Stylus compiler not found. Please install stylus in your project:\nnpm install stylus\nor\nyarn add stylus\nor\npnpm add stylus"); console.error(`Error:\n transform-to-unocss(stylusCompiler) ${error.toString()}`); } } //#endregion //#region src/compilerCss.ts function compilerCss(css, lang, filepath = isNodeEnvironment() ? process$1.cwd() : "", globalCss, debug) { switch (lang) { case "stylus": return stylusCompiler(css, filepath, globalCss, debug); case "less": return lessCompiler(css, filepath, globalCss, debug); case "scss": return sassCompiler(css, filepath, globalCss, debug); default: return css; } } //#endregion //#region node_modules/.pnpm/lazy-js-utils@0.1.49/node_modules/lazy-js-utils/dist/isBool-BdKgL6BB.js /** * 判断是否是数组 * @description EN: Alias for Array.isArray. */ const isArray = Array.isArray; //#endregion //#region node_modules/.pnpm/lazy-js-utils@0.1.49/node_modules/lazy-js-utils/dist/parallel-e0fsLjtd.js /** * 判断元素不是undefined * @description EN: Determine whether a value is defined (not undefined). * @param v - candidate value * @returns boolean */ function isDef(v) { return typeof v !== "undefined"; } var _globalThis; /** * 判断当前环境是否具有浏览器全局(window) * @description EN: True in environments where `globalThis.window` is defined (typical browsers). */ const isBrowser = isDef((_globalThis = globalThis) === null || _globalThis === void 0 ? void 0 : _globalThis.window); //#endregion //#region node_modules/.pnpm/spark-md5@3.0.2/node_modules/spark-md5/spark-md5.js var require_spark_md5 = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/spark-md5@3.0.2/node_modules/spark-md5/spark-md5.js": ((exports, module) => { (function(factory) { if (typeof exports === "object") module.exports = factory(); else if (typeof define === "function" && define.amd) define(factory); else { var glob; try { glob = window; } catch (e) { glob = self; } glob.SparkMD5 = factory(); } })(function(undefined$1) { var hex_chr = [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" ]; function md5cycle(x, k) { var a = x[0], b = x[1], c = x[2], d = x[3]; a += (b & c | ~b & d) + k[0] - 680876936 | 0; a = (a << 7 | a >>> 25) + b | 0; d += (a & b | ~a & c) + k[1] - 389564586 | 0; d = (d << 12 | d >>> 20) + a | 0; c += (d & a | ~d & b) + k[2] + 606105819 | 0; c = (c << 17 | c >>> 15) + d | 0; b += (c & d | ~c & a) + k[3] - 1044525330 | 0; b = (b << 22 | b >>> 10) + c | 0; a += (b & c | ~b & d) + k[4] - 176418897 | 0; a = (a << 7 | a >>> 25) + b | 0; d += (a & b | ~a & c) + k[5] + 1200080426 | 0; d = (d << 12 | d >>> 20) + a | 0; c += (d & a | ~d & b) + k[6] - 1473231341 | 0; c = (c << 17 | c >>> 15) + d | 0; b += (c & d | ~c & a) + k[7] - 45705983 | 0; b = (b << 22 | b >>> 10) + c | 0; a += (b & c | ~b & d) + k[8] + 1770035416 | 0; a = (a << 7 | a >>> 25) + b | 0; d += (a & b | ~a & c) + k[9] - 1958414417 | 0; d = (d << 12 | d >>> 20) + a | 0; c += (d & a | ~d & b) + k[10] - 42063 | 0; c = (c << 17 | c >>> 15) + d | 0; b += (c & d | ~c & a) + k[11] - 1990404162 | 0; b = (b << 22 | b >>> 10) + c | 0; a += (b & c | ~b & d) + k[12] + 1804603682 | 0; a = (a << 7 | a >>> 25) + b | 0; d += (a & b | ~a & c) + k[13] - 40341101 | 0; d = (d << 12 | d >>> 20) + a | 0; c += (d & a | ~d & b) + k[14] - 1502002290 | 0; c = (c << 17 | c >>> 15) + d | 0; b += (c & d | ~c & a) + k[15] + 1236535329 | 0; b = (b << 22 | b >>> 10) + c | 0; a += (b & d | c & ~d) + k[1] - 165796510 | 0; a = (a << 5 | a >>> 27) + b | 0; d += (a & c | b & ~c) + k[6] - 1069501632 | 0; d = (d << 9 | d >>> 23) + a | 0; c += (d & b | a & ~b) + k[11] + 643717713 | 0; c = (c << 14 | c >>> 18) + d | 0; b += (c & a | d & ~a) + k[0] - 373897302 | 0; b = (b << 20 | b >>> 12) + c | 0; a += (b & d | c & ~d) + k[5] - 701558691 | 0; a = (a << 5 | a >>> 27) + b | 0; d += (a & c | b & ~c) + k[10] + 38016083 | 0; d = (d << 9 | d >>> 23) + a | 0; c += (d & b | a & ~b) + k[15] - 660478335 | 0; c = (c << 14 | c >>> 18) + d | 0; b += (c & a | d & ~a) + k[4] - 405537848 | 0; b = (b << 20 | b >>> 12) + c | 0; a += (b & d | c & ~d) + k[9] + 568446438 | 0; a = (a << 5 | a >>> 27) + b | 0; d += (a & c | b & ~c) + k[14] - 1019803690 | 0; d = (d << 9 | d >>> 23) + a | 0; c += (d & b | a & ~b) + k[3] - 187363961 | 0; c = (c << 14 | c >>> 18) + d | 0; b += (c & a | d & ~a) + k[8] + 1163531501 | 0; b = (b << 20 | b >>> 12) + c | 0; a += (b & d | c & ~d) + k[13] - 1444681467 | 0; a = (a << 5 | a >>> 27) + b | 0; d += (a & c | b & ~c) + k[2] - 51403784 | 0; d = (d << 9 | d >>> 23) + a | 0; c += (d & b | a & ~b) + k[7] + 1735328473 | 0; c = (c << 14 | c >>> 18) + d | 0; b += (c & a | d & ~a) + k[12] - 1926607734 | 0; b = (b << 20 | b >>> 12) + c | 0; a += (b ^ c ^ d) + k[5] - 378558 | 0; a = (a << 4 | a >>> 28) + b | 0; d += (a ^ b ^ c) + k[8] - 2022574463 | 0; d = (d << 11 | d >>> 21) + a | 0; c += (d ^ a ^ b) + k[11] + 1839030562 | 0; c = (c << 16 | c >>> 16) + d | 0; b += (c ^ d ^ a) + k[14] - 35309556 | 0; b = (b << 23 | b >>> 9) + c | 0; a += (b ^ c ^ d) + k[1] - 1530992060 | 0; a = (a << 4 | a >>> 28) + b | 0; d += (a ^ b ^ c) + k[4] + 1272893353 | 0; d = (d << 11 | d >>> 21) + a | 0; c += (d ^ a ^ b) + k[7] - 155497632 | 0; c = (c << 16 | c >>> 16) + d | 0; b += (c ^ d ^ a) + k[10] - 1094730640 | 0; b = (b << 23 | b >>> 9) + c | 0; a += (b ^ c ^ d) + k[13] + 681279174 | 0; a = (a << 4 | a >>> 28) + b | 0; d += (a ^ b ^ c) + k[0] - 358537222 | 0; d = (d << 11 | d >>> 21) + a | 0; c += (d ^ a ^ b) + k[3] - 722521979 | 0; c = (c << 16 | c >>> 16) + d | 0; b += (c ^ d ^ a) + k[6] + 76029189 | 0; b = (b << 23 | b >>> 9) + c | 0; a += (b ^ c ^ d) + k[9] - 640364487 | 0; a = (a << 4 | a >>> 28) + b | 0; d += (a ^ b ^ c) + k[12] - 421815835 | 0; d = (d << 11 | d >>> 21) + a | 0; c += (d ^ a ^ b) + k[15] + 530742520 | 0; c = (c << 16 | c >>> 16) + d | 0; b += (c ^ d ^ a) + k[2] - 995338651 | 0; b = (b << 23 | b >>> 9) + c | 0; a += (c ^ (b | ~d)) + k[0] - 198630844 | 0; a = (a << 6 | a >>> 26) + b | 0; d += (b ^ (a | ~c)) + k[7] + 1126891415 | 0; d = (d << 10 | d >>> 22) + a | 0; c += (a ^ (d | ~b)) + k[14] - 1416354905 | 0; c = (c << 15 | c >>> 17) + d | 0; b += (d ^ (c | ~a)) + k[5] - 57434055 | 0; b = (b << 21 | b >>> 11) + c | 0; a += (c ^ (b | ~d)) + k[12] + 1700485571 | 0; a = (a << 6 | a >>> 26) + b | 0; d += (b ^ (a | ~c)) + k[3] - 1894986606 | 0; d = (d << 10 | d >>> 22) + a | 0; c += (a ^ (d | ~b)) + k[10] - 1051523 | 0; c = (c << 15 | c >>> 17) + d | 0; b += (d ^ (c | ~a)) + k[1] - 2054922799 | 0; b = (b << 21 | b >>> 11) + c | 0; a += (c ^ (b | ~d)) + k[8] + 1873313359 | 0; a = (a << 6 | a >>> 26) + b | 0; d += (b ^ (a | ~c)) + k[15] - 30611744 | 0; d = (d << 10 | d >>> 22) + a | 0; c += (a ^ (d | ~b)) + k[6] - 1560198380 | 0; c = (c << 15 | c >>> 17) + d | 0; b += (d ^ (c | ~a)) + k[13] + 1309151649 | 0; b = (b << 21 | b >>> 11) + c | 0; a += (c ^ (b | ~d)) + k[4] - 145523070 | 0; a = (a << 6 | a >>> 26) + b | 0; d += (b ^ (a | ~c)) + k[11] - 1120210379 | 0; d = (d << 10 | d >>> 22) + a | 0; c += (a ^ (d | ~b)) + k[2] + 718787259 | 0; c = (c << 15 | c >>> 17) + d | 0; b += (d ^ (c | ~a)) + k[9] - 343485551 | 0; b = (b << 21 | b >>> 11) + c | 0; x[0] = a + x[0] | 0; x[1] = b + x[1] | 0; x[2] = c + x[2] | 0; x[3] = d + x[3] | 0; } function md5blk(s) { var md5blks = [], i; for (i = 0; i < 64; i += 4) md5blks[i >> 2] = s.charCodeAt(i) + (s.charCodeAt(i + 1) << 8) + (s.charCodeAt(i + 2) << 16) + (s.charCodeAt(i + 3) << 24); return md5blks; } function md5blk_array(a) { var md5blks = [], i; for (i = 0; i < 64; i += 4) md5blks[i >> 2] = a[i] + (a[i + 1] << 8) + (a[i + 2] << 16) + (a[i + 3] << 24); return md5blks; } function md51(s) { var n = s.length, state = [ 1732584193, -271733879, -1732584194, 271733878 ], i, length, tail$1, tmp, lo, hi; for (i = 64; i <= n; i += 64) md5cycle(state, md5blk(s.substring(i - 64, i))); s = s.substring(i - 64); length = s.length; tail$1 = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; for (i = 0; i < length; i += 1) tail$1[i >> 2] |= s.charCodeAt(i) << (i % 4 << 3); tail$1[i >> 2] |= 128 << (i % 4 << 3); if (i > 55) { md5cycle(state, tail$1); for (i = 0; i < 16; i += 1) tail$1[i] = 0; } tmp = n * 8; tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/); lo = parseInt(tmp[2], 16); hi = parseInt(tmp[1], 16) || 0; tail$1[14] = lo; tail$1[15] = hi; md5cycle(state, tail$1); return state; } function md51_array(a) { var n = a.length, state = [ 1732584193, -271733879, -1732584194, 271733878 ], i, length, tail$1, tmp, lo, hi; for (i = 64; i <= n; i += 64) md5cycle(state, md5blk_array(a.subarray(i - 64, i))); a = i - 64 < n ? a.subarray(i - 64) : new Uint8Array(0); length = a.length; tail$1 = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; for (i = 0; i < length; i += 1) tail$1[i >> 2] |= a[i] << (i % 4 << 3); tail$1[i >> 2] |= 128 << (i % 4 << 3); if (i > 55) { md5cycle(state, tail$1); for (i = 0; i < 16; i += 1) tail$1[i] = 0; } tmp = n * 8; tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/); lo = parseInt(tmp[2], 16); hi = parseInt(tmp[1], 16) || 0; tail$1[14] = lo; tail$1[15] = hi; md5cycle(state, tail$1); return state; } function rhex(n) { var s = "", j; for (j = 0; j < 4; j += 1) s += hex_chr[n >> j * 8 + 4 & 15] + hex_chr[n >> j * 8 & 15]; return s; } function hex(x) { var i; for (i = 0; i < x.length; i += 1) x[i] = rhex(x[i]); return x.join(""); } if (hex(md51("hello")) !== "5d41402abc4b2a76b9719d911017c592"); /** * ArrayBuffer slice polyfill. * * @see https://github.com/ttaubert/node-arraybuffer-slice */ if (typeof ArrayBuffer !== "undefined" && !ArrayBuffer.prototype.slice) (function() { function clamp(val, length) { val = val | 0 || 0; if (val < 0) return Math.max(val + length, 0); return Math.min(val, length); } ArrayBuffer.prototype.slice = function(from, to) { var length = this.byteLength, begin = clamp(from, length), end = length, num, target, targetArray, sourceArray; if (to !== undefined$1) end = clamp(to, length); if (begin > end) return /* @__PURE__ */ new ArrayBuffer(0); num = end - begin; target = new ArrayBuffer(num); targetArray = new Uint8Array(target); sourceArray = new Uint8Array(this, begin, num); targetArray.set(sourceArray); return target; }; })(); /** * Helpers. */ function toUtf8(str) { if (/[\u0080-\uFFFF]/.test(str)) str = unescape(encodeURIComponent(str)); return str; } function utf8Str2ArrayBuffer(str, returnUInt8Array) { var length = str.length, buff = new ArrayBuffer(length), arr = new Uint8Array(buff), i; for (i = 0; i < length; i += 1) arr[i] = str.charCodeAt(i); return returnUInt8Array ? arr : buff; } function arrayBuffer2Utf8Str(buff) { return String.fromCharCode.apply(null, new Uint8Array(buff)); } function concatenateArrayBuffers(first, second, returnUInt8Array) { var result = new Uint8Array(first.byteLength + second.byteLength); result.set(new Uint8Array(first)); result.set(new Uint8Array(second), first.byteLength); return returnUInt8Array ? result : result.buffer; } function hexToBinaryString(hex$1) { var bytes = [], length = hex$1.length, x; for (x = 0; x < length - 1; x += 2) bytes.push(parseInt(hex$1.substr(x, 2), 16)); return String.fromCharCode.apply(String, bytes); } /** * SparkMD5 OOP implementation. * * Use this class to perform an incremental md5, otherwise use the * static methods instead. */ function SparkMD5$1() { this.reset(); } /** * Appends a string. * A conversion will be applied if an utf8 string is detected. * * @param {String} str The string to be appended * * @return {SparkMD5} The instance itself */ SparkMD5$1.prototype.append = function(str) { this.appendBinary(toUtf8(str)); return this; }; /** * Appends a binary string. * * @param {String} contents The binary string to be appended * * @return {SparkMD5} The instance itself */ SparkMD5$1.prototype.appendBinary = function(contents) { this._buff += contents; this._length += contents.length; var length = this._buff.length, i; for (i = 64; i <= length; i += 64) md5cycle(this._hash, md5blk(this._buff.substring(i - 64, i))); this._buff = this._buff.substring(i - 64); return this; }; /** * Finishes the incremental computation, reseting the internal state and * returning the result. * * @param {Boolean} raw True to get the raw string, false to get the hex string * * @return {String} The result */ SparkMD5$1.prototype.end = function(raw) { var buff = this._buff, length = buff.length, i, tail$1 = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], ret; for (i = 0; i < length; i += 1) tail$1[i >> 2] |= buff.charCodeAt(i) << (i % 4 << 3); this._finish(tail$1, length); ret = hex(this._hash); if (raw) ret = hexToBinaryString(ret); this.reset(); return ret; }; /** * Resets the internal state of the computation. * * @return {SparkMD5} The instance itself */ SparkMD5$1.prototype.reset = function() { this._buff = ""; this._length = 0; this._hash = [ 1732584193, -271733879, -1732584194, 271733878 ]; return this; }; /** * Gets the internal state of the computation. * * @return {Object} The state */ SparkMD5$1.prototype.getState = function() { return { buff: this._buff, length: this._length, hash: this._hash.slice() }; }; /** * Gets the internal state of the computation. * * @param {Object} state The state * * @return {SparkMD5} The instance itself */ SparkMD5$1.prototype.setState = function(state) { this._buff = state.buff; this._length = state.length; this._hash = state.hash; return this; }; /** * Releases memory used by the incremental buffer and other additional * resources. If you plan to use the instance again, use reset instead. */ SparkMD5$1.prototype.destroy = function() { delete this._hash; delete this._buff; delete this._length; }; /** * Finish the final calculation based on the tail. * * @param {Array} tail The tail (will be modified) * @param {Number} length The length of the remaining buffer */ SparkMD5$1.prototype._finish = function(tail$1, length) { var i = length, tmp, lo, hi; tail$1[i >> 2] |= 128 << (i % 4 << 3); if (i > 55) { md5cycle(this._hash, tail$1); for (i = 0; i < 16; i += 1) tail$1[i] = 0; } tmp = this._length * 8; tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/); lo = parseInt(tmp[2], 16); hi = parseInt(tmp[1], 16) || 0; tail$1[14] = lo; tail$1[15] = hi; md5cycle(this._hash, tail$1); }; /** * Performs the md5 hash on a string. * A conversion will be applied if utf8 string is detected. * * @param {String} str The string * @param {Boolean} [raw] True to get the raw string, false to get the hex string * * @return {String} The result */ SparkMD5$1.hash = function(str, raw) { return SparkMD5$1.hashBinary(toUtf8(str), raw); }; /** * Performs the md5 hash on a binary string. * * @param {String} content The binary string * @param {Boolean} [raw] True to get the raw string, false to get the hex string * * @return {String} The result */ SparkMD5$1.hashBinary = function(content, raw) { var ret = hex(md51(content)); return raw ? hexToBinaryString(ret) : ret; }; /** * SparkMD5 OOP implementation for array buffers. * * Use this class to perform an incremental md5 ONLY for array buffers. */ SparkMD5$1.ArrayBuffer = function() { this.reset(); }; /** * Appends an array buffer. * * @param {ArrayBuffer} arr The array to be appended * * @return {SparkMD5.ArrayBuffer} The instance itself */ SparkMD5$1.ArrayBuffer.prototype.append = function(arr) { var buff = concatenateArrayBuffers(this._buff.buffer, arr, true), length = buff.length, i; this._length += arr.byteLength; for (i = 64; i <= length; i += 64) md5cycle(this._hash, md5blk_array(buff.subarray(i - 64, i))); this._buff = i - 64 < length ? new Uint8Array(buff.buffer.slice(i - 64)) : new Uint8Array(0); return this; }; /** * Finishes the incremental computation, reseting the internal state and * returning the result. * * @param {Boolean} raw True to get the raw string, false to get the hex string * * @return {String} The result */ SparkMD5$1.ArrayBuffer.prototype.end = function(raw) { var buff = this._buff, length = buff.length, tail$1 = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], i, ret; for (i = 0; i < length; i += 1) tail$1[i >> 2] |= buff[i] << (i % 4 << 3); this._finish(tail$1, length); ret = hex(this._hash); if (raw) ret = hexToBinaryString(ret); this.reset(); return ret; }; /** * Resets the internal state of the computation. * * @return {SparkMD5.ArrayBuffer} The instance itself */ SparkMD5$1.ArrayBuffer.prototype.reset = function() { this._buff = new Uint8Array(0); this._length = 0; this._hash = [ 1732584193, -271733879, -1732584194, 271733878 ]; return this; }; /** * Gets the internal state of the computation. * * @return {Object} The state */ SparkMD5$1.ArrayBuffer.prototype.getState = function() { var state = SparkMD5$1.prototype.getState.call(this); state.buff = arrayBuffer2Utf8Str(state.buff); return state; }; /** * Gets the internal state of the computation. * * @param {Object} state The state * * @return {SparkMD5.ArrayBuffer} The instance itself */ SparkMD5$1.ArrayBuffer.prototype.setState = function(state) { state.buff = utf8Str2ArrayBuffer(state.buff, true); return SparkMD5$1.prototype.setState.call(this, state); }; SparkMD5$1.ArrayBuffer.prototype.destroy = SparkMD5$1.prototype.destroy; SparkMD5$1.ArrayBuffer.prototype._finish = SparkMD5$1.prototype._finish; /** * Performs the md5 hash on an array buffer. * * @param {ArrayBuffer} arr The array buffer * @param {Boolean} [raw] True to get the raw string, false to get the hex one * * @return {String} The result */ SparkMD5$1.ArrayBuffer.hash = function(arr, raw) { var ret = hex(md51_array(new Uint8Array(arr))); return raw ? hexToBinaryString(ret) : ret; }; return SparkMD5$1; }); }) }); //#endregion //#region node_modules/.pnpm/lazy-js-utils@0.1.49/node_modules/lazy-js-utils/dist/createChunk-aGYaZtph.js var import_spark_md5 = /* @__PURE__ */ __toESM(require_spark_md5(), 1); //#endregion //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js var require_can_promise = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js": ((exports, module) => { module.exports = function() { return typeof Promise === "function" && Promise.prototype && Promise.prototype.then; }; }) }); //#endregion //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js var require_utils$1 = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js": ((exports) => { let toSJISFunction; const CODEWORDS_COUNT = [ 0, 26, 44, 70, 100, 134, 172, 196, 242, 292, 346, 404, 466, 532, 581, 655, 733, 815, 901, 991, 1085, 1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051, 2185, 2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706 ]; /** * Returns the QR Code size for the specified version * * @param {Number} version QR Code version * @return {Number} size of QR code */ exports.getSymbolSize = function getSymbolSize$2(version) { if (!version) throw new Error("\"version\" cannot be null or undefined"); if (version < 1 || version > 40) throw new Error("\"version\" should be in range from 1 to 40"); return version * 4 + 17; }; /** * Returns the total number of codewords used to store data and EC information. * * @param {Number} version QR Code version * @return {Number} Data length in bits */ exports.getSymbolTotalCodewords = function getSymbolTotalCodewords(version) { return CODEWORDS_COUNT[version]; }; /** * Encode data with Bose-Chaudhuri-Hocquenghem * * @param {Number} data Value to encode * @return {Number} Encoded value */ exports.getBCHDigit = function(data) { let digit = 0; while (data !== 0) { digit++; data >>>= 1; } return digit; }; exports.setToSJISFunction = function setToSJISFunction(f) { if (typeof f !== "function") throw new Error("\"toSJISFunc\" is not a valid function."); toSJISFunction = f; }; exports.isKanjiModeEnabled = function() { return typeof toSJISFunction !== "undefined"; }; exports.toSJIS = function toSJIS(kanji$1) { return toSJISFunction(kanji$1); }; }) }); //#endregion //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js var require_error_correction_level = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js": ((exports) => { exports.L = { bit: 1 }; exports.M = { bit: 0 }; exports.Q = { bit: 3 }; exports.H = { bit: 2 }; function fromString$1(string) { if (typeof string !== "string") throw new Error("Param is not a string"); switch (string.toLowerCase()) { case "l": case "low": return exports.L; case "m": case "medium": return exports.M; case "q": case "quartile": return exports.Q; case "h": case "high": return exports.H; default: throw new Error("Unknown EC Level: " + string); } } exports.isValid = function isValid(level) { return level && typeof level.bit !== "undefined" && level.bit >= 0 && level.bit < 4; }; exports.from = function from(value, defaultValue) { if (exports.isValid(value)) return value; try { return fromString$1(value); } catch (e) { return defaultValue; } }; }) }); //#endregion //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js var require_bit_buffer = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js": ((exports, module) => { function BitBuffer$1() { this.buffer = []; this.length = 0; } BitBuffer$1.prototype = { get: function(index) { const bufIndex = Math.floor(index / 8); return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) === 1; }, put: function(num, length) { for (let i = 0; i < length; i++) this.putBit((num >>> length - i - 1 & 1) === 1); }, getLengthInBits: function() { return this.length; }, putBit: function(bit) { const bufIndex = Math.floor(this.length / 8); if (this.buffer.length <= bufIndex) this.buffer.push(0); if (bit) this.buffer[bufIndex] |= 128 >>> this.length % 8; this.length++; } }; module.exports = BitBuffer$1; }) }); //#endregion //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js var require_bit_matrix = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js": ((exports, module) => { /** * Helper class to handle QR Code symbol modules * * @param {Number} size Symbol size */ function BitMatrix$1(size) { if (!size || size < 1) throw new Error("BitMatrix size must be defined and greater than 0"); this.size = size; this.data = new Uint8Array(size * size); this.reservedBit = new Uint8Array(size * size); } /** * Set bit value at specified location * If reserved flag is set, this bit will be ignored during masking process * * @param {Number} row * @param {Number} col * @param {Boolean} value * @param {Boolean} reserved */ BitMatrix$1.prototype.set = function(row, col, value, reserved) { const index = row * this.size + col; this.data[index] = value; if (reserved) this.reservedBit[index] = true; }; /** * Returns bit value at specified location * * @param {Number} row * @param {Number} col * @return {Boolean} */ BitMatrix$1.prototype.get = function(row, col) { return this.data[row * this.size + col]; }; /** * Applies xor operator at specified location * (used during masking process) * * @param {Number} row * @param {Number} col * @param {Boolean} value */ BitMatrix$1.prototype.xor = function(row, col, value) { this.data[row * this.size + col] ^= value; }; /** * Check if bit at specified location is reserved * * @param {Number} row * @param {Number} col * @return {Boolean} */ BitMatrix$1.prototype.isReserved = function(row, col) { return this.reservedBit[row * this.size + col]; }; module.exports = BitMatrix$1; }) }); //#endregion //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js var require_alignment_pattern = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js": ((exports) => { /** * Alignment pattern are fixed reference pattern in defined positions * in a matrix symbology, which enables the decode software to re-synchronise * the coordinate mapping of the image modules in the event of moderate amounts * of distortion of the image. * * Alignment patterns are present only in QR Code symbols of version 2 or larger * and their number depends on the symbol version. */ const getSymbolSize$1 = require_utils$1().getSymbolSize; /** * Calculate the row/column coordinates of the center module of each alignment pattern * for the specified QR Code version. * * The alignment patterns are positioned symmetrically on either side of the diagonal * running from the top left corner of the symbol to the bottom right corner. * * Since positions are simmetrical only half of the coordinates are returned. * Each item of the array will represent in turn the x and y coordinate. * @see {@link getPositions} * * @param {Number} version QR Code version * @return {Array} Array of coordinate */ exports.getRowColCoords = function getRowColCoords(version) { if (version === 1) return []; const posCount = Math.floor(version / 7) + 2; const size = getSymbolSize$1(version); const intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2; const positions = [size - 7]; for (let i = 1; i < posCount - 1; i++) positions[i] = positions[i - 1] - intervals; positions.push(6); return positions.reverse(); }; /** * Returns an array containing the positions of each alignment pattern. * Each array's element represent the center point of the pattern as (x, y) coordinates * * Coordinates are calculated expanding the row/column coordinates returned by {@link getRowColCoords} * and filtering out the items that overlaps with finder pattern * * @example * For a Version 7 symbol {@link getRowColCoords} returns values 6, 22 and 38. * The alignment patterns, therefore, are to be centered on (row, column) * positions (6,22), (22,6), (22,22), (22,38), (38,22), (38,38). * Note that the coordinates (6,6), (6,38), (38,6) are occupied by finder patterns * and are not therefore used for alignment patterns. * * let pos = getPositions(7) * // [[6,22], [22,6], [22,22], [22,38], [38,22], [38,38]] * * @param {Number} version QR Code version * @return {Array} Array of coordinates */ exports.getPositions = function getPositions(version) { const coords = []; const pos = exports.getRowColCoords(version); const posLength = pos.length; for (let i = 0; i < posLength; i++) for (let j = 0; j < posLength; j++) { if (i === 0 && j === 0 || i === 0 && j === posLength - 1 || i === posLength - 1 && j === 0) continue; coords.push([pos[i], pos[j]]); } return coords; }; }) }); //#endregion //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js var require_finder_pattern = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js": ((exports) => { const getSymbolSize = require_utils$1().getSymbolSize; const FINDER_PATTERN_SIZE = 7; /** * Returns an array containing the positions of each finder pattern. * Each array's element represent the top-left point of the pattern as (x, y) coordinates * * @param {Number} version QR Code version * @return {Array} Array of coordinates */ exports.getPositions = function getPositions(version) { const size = getSymbolSize(version); return [ [0, 0], [size - FINDER_PATTERN_SIZE, 0], [0, size - FINDER_PATTERN_SIZE] ]; }; }) }); //#endregion //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js var require_mask_pattern = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js": ((exports) => { /** * Data mask pattern reference * @type {Object} */ exports.Patterns = { PATTERN000: 0, PATTERN001: 1, PATTERN010: 2, PATTERN011: 3, PATTERN100: 4, PATTERN101: 5, PATTERN110: 6, PATTERN111: 7 }; /** * Weighted penalty scores for the undesirable features * @type {Object} */ const PenaltyScores = { N1: 3, N2: 3, N3: 40, N4: 10 }; /** * Check if mask pattern value is valid * * @param {Number} mask Mask pattern * @return {Boolean} true if valid, false otherwise */ exports.isValid = function isValid(mask) { return mask != null && mask !== "" && !isNaN(mask) && mask >= 0 && mask <= 7; }; /** * Returns mask pattern from a value. * If value is not valid, returns undefined * * @param {Number|String} value Mask pattern value * @return {Number} Valid mask pattern or undefined */ exports.from = function from(value) { return exports.isValid(value) ? parseInt(value, 10) : void 0; }; /** * Find adjacent modules in row/column with the same color * and assign a penalty value. * * Points: N1 + i * i is the amount by which the number of adjacent modules of the same color exceeds 5 */ exports.getPenaltyN1 = function getPenaltyN1(data) { const size = data.size; let points = 0; let sameCountCol = 0; let sameCountRow = 0; let lastCol = null; let lastRow = null; for (let row = 0; row < size; row++) { sameCountCol = sameCountRow = 0; lastCol = lastRow = null; for (let col = 0; col < size; col++) { let module$1 = data.get(row, col); if (module$1 === lastCol) sameCountCol++; else { if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5); lastCol = module$1; sameCountCol = 1; } module$1 = data.get(col, row); if (module$1 === lastRow) sameCountRow++; else { if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5); lastRow = module$1; sameCountRow = 1; } } if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5); if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5); } return points; }; /** * Find 2x2 blocks with the same color and assign a penalty value * * Points: N2 * (m - 1) * (n - 1) */ exports.getPenaltyN2 = function getPenaltyN2(data) { const size = data.size; let points = 0; for (let row = 0; row < size - 1; row++) for (let col = 0; col < size - 1; col++) { const last = data.get(row, col) + data.get(row, col + 1) + data.get(row + 1, col) + data.get(row + 1, col + 1); if (last === 4 || last === 0) points++; } return points * PenaltyScores.N2; }; /** * Find 1:1:3:1:1 ratio (dark:light:dark:light:dark) pattern in row/column, * preceded or followed by light area 4 modules wide * * Points: N3 * number of pattern found */ exports.getPenaltyN3 = function getPenaltyN3(data) { const size = data.size; let points = 0; let bitsCol = 0; let bitsRow = 0; for (let row = 0; row < size; row++) { bitsCol = bitsRow = 0; for (let col = 0; col < size; col++) { bitsCol = bitsCol << 1 & 2047 | data.get(row, col); if (col >= 10 && (bitsCol === 1488 || bitsCol === 93)) points++; bitsRow = bitsRow << 1 & 2047 | data.get(col, row); if (col >= 10 && (bitsRow === 1488 || bitsRow === 93)) points++; } } return points * PenaltyScores.N3; }; /** * Calculate proportion of dark modules in entire symbol * * Points: N4 * k * * k is the rating of the deviation of the proportion of dark modules * in the symbol from 50% in steps of 5% */ exports.getPenaltyN4 = function getPenaltyN4(data) { let darkCount = 0; const modulesCount = data.data.length; for (let i = 0; i < modulesCount; i++) darkCount += data.data[i]; return Math.abs(Math.ceil(darkCount * 100 / modulesCount / 5) - 10) * PenaltyScores.N4; }; /** * Return mask value at given position * * @param {Number} maskPattern Pattern reference value * @param {Number} i Row * @param {Number} j Column * @return {Boolean} Mask value */ function getMaskAt(maskPattern, i, j) { switch (maskPattern) { case exports.Patterns.PATTERN000: return (i + j) % 2 === 0; case exports.Patterns.PATTERN001: return i % 2 === 0; case exports.Patterns.PATTERN010: return j % 3 === 0; case exports.Patterns.PATTERN011: return (i + j) % 3 === 0; case exports.Patterns.PATTERN100: return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0; case exports.Patterns.PATTERN101: return i * j % 2 + i * j % 3 === 0; case exports.Patterns.PATTERN110: return (i * j % 2 + i * j % 3) % 2 === 0; case exports.Patterns.PATTERN111: return (i * j % 3 + (i + j) % 2) % 2 === 0; default: throw new Error("bad maskPattern:" + maskPattern); } } /** * Apply a mask pattern to a BitMatrix * * @param {Number} pattern Pattern reference number * @param {BitMatrix} data BitMatrix data */ exports.applyMask = function applyMask(pattern, data) { const size = data.size; for (let col = 0; col < size; col++) for (let row = 0; row < size; row++) { if (data.isReserved(row, col)) continue; data.xor(row, col, getMaskAt(pattern, row, col)); } }; /** * Returns the best mask pattern for data * * @param {BitMatrix} data * @return {Number} Mask pattern reference number */ exports.getBestMask = function getBestMask(data, setupFormatFunc) { const numPatterns = Object.keys(exports.Patterns).length; let bestPattern = 0; let lowerPenalty = Infinity; for (let p = 0; p < numPatterns; p++) { setupFormatFunc(p); exports.applyMask(p, data); const penalty = exports.getPenaltyN1(data) + exports.getPenaltyN2(data) + exports.getPenaltyN3(data) + exports.getPenaltyN4(data); exports.applyMask(p, data); if (penalty < lowerPenalty) { lowerPenalty = penalty; bestPattern = p; } } return bestPattern; }; }) }); //#endregion //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js var require_error_correction_code = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js": ((exports) => { const ECLevel$2 = require_error_correction_level(); const EC_BLOCKS_TABLE = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 4, 1, 2, 4, 4, 2, 4, 4, 4, 2, 4, 6, 5, 2, 4, 6, 6, 2, 5, 8, 8, 4, 5, 8, 8, 4, 5, 8, 11, 4, 8, 10, 11, 4, 9, 12, 16, 4, 9, 16, 16, 6, 10, 12, 18, 6, 10, 17, 16, 6, 11, 16, 19, 6, 13, 18, 21, 7, 14, 21, 25, 8, 16, 20, 25, 8, 17, 23, 25, 9, 17, 23, 34, 9, 18, 25, 30, 10, 20, 27, 32, 12, 21, 29, 35, 12, 23, 34, 37, 12, 25, 34, 40, 13, 26, 35, 42, 14, 28, 38, 45, 15, 29, 40, 48, 16, 31, 43, 51, 17, 33, 45, 54, 18, 35, 48, 57, 19, 37, 51, 60, 19, 38, 53, 63, 20, 40, 56, 66, 21, 43, 59, 70, 22, 45, 62, 74, 24, 47, 65, 77, 25, 49, 68, 81 ]; const EC_CODEWORDS_TABLE = [ 7, 10, 13, 17, 10, 16, 22, 28, 15, 26, 36, 44, 20, 36, 52, 64, 26, 48, 72, 88, 36, 64, 96, 112, 40, 72, 108, 130, 48, 88, 132, 156, 60, 110, 160, 192, 72, 130, 192, 224, 80, 150, 224, 264, 96, 176, 260, 308, 104, 198, 288, 352, 120, 216, 320, 384, 132, 240, 360, 432, 144, 280, 408, 480, 168, 308, 448, 532, 180, 338, 504, 588, 196, 364, 546, 650, 224, 416, 600, 700, 224, 442, 644, 750, 252, 476, 690, 816, 270, 504, 750, 900, 300, 560, 810, 960, 312, 588, 870, 1050, 336, 644, 952, 1110, 360, 700, 1020, 1200, 390, 728, 1050, 1260, 420, 784, 1140, 1350, 450, 812, 1200, 1440, 480, 868, 1290, 1530, 510, 924, 1350, 1620, 540, 980, 1440, 1710, 570, 1036, 1530, 1800, 570, 1064, 1590, 1890, 600, 1120, 1680, 1980, 630, 1204, 1770, 2100, 660, 1260, 1860, 2220, 720, 1316, 1950, 2310, 750, 1372, 2040, 2430 ]; /** * Returns the number of error correction block that the QR Code should contain * for the specified version and error correction level. * * @param {Number} version QR Code version * @param {Number} errorCorrectionLevel Error correction level * @return {Number} Number of error correction blocks */ exports.getBlocksCount = function getBlocksCount(version, errorCorrectionLevel) { switch (errorCorrectionLevel) { case ECLevel$2.L: return EC_BLOCKS_TABLE[(version - 1) * 4 + 0]; case ECLevel$2.M: return EC_BLOCKS_TABLE[(version - 1) * 4 + 1]; case ECLevel$2.Q: return EC_BLOCKS_TABLE[(version - 1) * 4 + 2]; case ECLevel$2.H: return EC_BLOCKS_TABLE[(version - 1) * 4 + 3]; default: return; } }; /** * Returns the number of error correction codewords to use for the specified * version and error correction level. * * @param {Number} version QR Code version * @param {Number} errorCorrectionLevel Error correction level * @return {Number} Number of error correction codewords */ exports.getTotalCodewordsCount = function getTotalCodewordsCount(version, errorCorrectionLevel) { switch (errorCorrectionLevel) { case ECLevel$2.L: