dsh-codex-subscription 2.5.9 → 3.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -11,6 +11,7 @@ window.__ModuleLoader__.load({
11
11
  var __getOwnPropNames = Object.getOwnPropertyNames;
12
12
  var __getProtoOf = Object.getPrototypeOf;
13
13
  var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
14
15
  var __copyProps = (to, from, except, desc) => {
15
16
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
16
17
  key = keys[i];
@@ -1086,6 +1087,10 @@ window.__ModuleLoader__.load({
1086
1087
  "runtime/cancel",
1087
1088
  "storage/status",
1088
1089
  "storage/clear-forecast",
1090
+ "remote/status",
1091
+ "remote/enable",
1092
+ "remote/disable",
1093
+ "remote/pair",
1089
1094
  "reset-credit/inspect",
1090
1095
  "reset-credit/prepare",
1091
1096
  "reset-credit/consume",
@@ -5680,6 +5685,24 @@ window.__ModuleLoader__.load({
5680
5685
  subagentBackend_dsh: "DSH",
5681
5686
  subagentBackend_codex: "Codex",
5682
5687
  connectionTitle: "连接方式",
5688
+ remoteTitle: "手机远程控制",
5689
+ remote_off: "关闭",
5690
+ remote_on: "开启",
5691
+ remoteHint: "实验功能,默认关闭。开启后,这台电脑上的 DSH 会出现在 ChatGPT 手机 App 的 Codex 主机列表里,可用手机查看对话、发消息、切换模型和审批。需要订阅账号登录;电脑要保持开机和联网。",
5692
+ remoteConnected: "已连接",
5693
+ remoteConnecting: "正在连接",
5694
+ remoteError: "连接失败,会自动重试",
5695
+ remoteStopped: "已停止",
5696
+ remotePhones: "{count} 个手机连接",
5697
+ remotePair: "显示配对码",
5698
+ remotePairAgain: "重新生成配对码",
5699
+ remotePairFailed: "无法生成配对码,请确认已登录订阅账号。",
5700
+ remotePairSteps: "在手机 ChatGPT App 的 Codex 里扫码,或输入下面的手动码。",
5701
+ remoteManualCode: "手动配对码",
5702
+ remoteQrLabel: "配对二维码",
5703
+ remoteExpires: "约 {minutes} 分钟内有效",
5704
+ remoteExpired: "配对码已过期,请重新生成。",
5705
+ remoteLimits: "手机上可以查看和继续 DSH 里的对话、新建对话、切换模型、选择权限并审批。手机暂不能直接在电脑上执行命令。",
5683
5706
  reviewModelTitle: "Auto review 审查模型",
5684
5707
  reviewModel_session: "当前模型",
5685
5708
  reviewModel_official: "Codex 官方审查模型",
@@ -6267,6 +6290,24 @@ window.__ModuleLoader__.load({
6267
6290
  subagentBackend_dsh: "DSH",
6268
6291
  subagentBackend_codex: "Codex",
6269
6292
  connectionTitle: "Connection",
6293
+ remoteTitle: "Phone remote control",
6294
+ remote_off: "Off",
6295
+ remote_on: "On",
6296
+ remoteHint: "Experimental, off by default. When on, this computer's DSH appears as a host in the ChatGPT mobile app's Codex list, so you can follow conversations, send messages, switch models and approve actions from your phone. Needs a signed-in subscription account; the computer must stay on and online.",
6297
+ remoteConnected: "Connected",
6298
+ remoteConnecting: "Connecting",
6299
+ remoteError: "Connection failed, retrying",
6300
+ remoteStopped: "Stopped",
6301
+ remotePhones: "{count} phone(s) connected",
6302
+ remotePair: "Show pairing code",
6303
+ remotePairAgain: "New pairing code",
6304
+ remotePairFailed: "Could not create a pairing code. Check that the subscription account is signed in.",
6305
+ remotePairSteps: "Scan this in the ChatGPT app's Codex section, or type the manual code.",
6306
+ remoteManualCode: "Manual pairing code",
6307
+ remoteQrLabel: "Pairing QR code",
6308
+ remoteExpires: "Valid for about {minutes} minute(s)",
6309
+ remoteExpired: "The pairing code expired. Create a new one.",
6310
+ remoteLimits: "From the phone you can follow and continue DSH conversations, start new ones, switch models, choose permissions and approve actions. The phone cannot run commands on the computer directly.",
6270
6311
  reviewModelTitle: "Auto review model",
6271
6312
  reviewModel_session: "Current model",
6272
6313
  reviewModel_official: "Codex reviewer",
@@ -6999,6 +7040,7 @@ window.__ModuleLoader__.load({
6999
7040
  .codexSubscriptionSettingRows>.codexImagePreference+.codexImagePreference{border-top:1px solid var(--dsw-alias-border-l2)}
7000
7041
  .codexSubscriptionDiagnostics .codexSubscriptionSectionHead{align-items:flex-start;flex-direction:column;gap:12px}
7001
7042
  .codexSubscriptionDiagnostics .codexSubscriptionSectionTitle{display:flex;flex-direction:column;gap:5px}
7043
+ .codexSubscriptionRemotePair{display:flex;gap:16px;align-items:center;flex-wrap:wrap;margin-top:8px}.codexSubscriptionRemoteQr{width:168px;height:168px;flex:none;border-radius:12px;overflow:hidden;background:#fff}.codexSubscriptionRemoteQr svg{display:block;width:100%;height:100%}.codexSubscriptionRemoteCode{margin:6px 0;font:600 20px/28px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;letter-spacing:.08em;user-select:all}
7002
7044
  .codexSubscriptionStorageMeter{display:flex;flex-direction:column;gap:9px;padding:12px;border-radius:10px;background:var(--dsw-alias-bg-module-platform)}
7003
7045
  .codexSubscriptionStorageMeter>div{display:flex;justify-content:space-between;gap:8px;flex-wrap:wrap;font-size:12px;line-height:18px}
7004
7046
  .codexSubscriptionStorageMeter output{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-secondary)}
@@ -8498,6 +8540,7 @@ window.__ModuleLoader__.load({
8498
8540
  autoQuotaRetry: normalizeAutoQuotaRetry(value?.[AUTO_QUOTA_RETRY_FIELD]),
8499
8541
  connectionMode: value?.connectionMode === "websocket" ? "websocket" : "sse",
8500
8542
  reviewModel: value?.reviewModel === "official" ? "official" : "session",
8543
+ remoteControl: value?.remoteControl === "on" ? "on" : "off",
8501
8544
  compactionMode: value?.compactionMode === "cloud" ? "cloud" : "dsh",
8502
8545
  subagentBackend: value?.subagentBackend === "codex" ? "codex" : "dsh",
8503
8546
  subagentBackendAvailable,
@@ -8558,6 +8601,7 @@ window.__ModuleLoader__.load({
8558
8601
  [AUTO_QUOTA_RETRY_FIELD]: normalizeAutoQuotaRetry(value?.[AUTO_QUOTA_RETRY_FIELD]),
8559
8602
  connectionMode: value?.connectionMode === "websocket" ? "websocket" : "sse",
8560
8603
  reviewModel: value?.reviewModel === "official" ? "official" : "session",
8604
+ remoteControl: value?.remoteControl === "on" ? "on" : "off",
8561
8605
  compactionMode: value?.compactionMode === "cloud" ? "cloud" : "dsh",
8562
8606
  subagentBackend: value?.subagentBackend === "codex" ? "codex" : "dsh",
8563
8607
  ...readCapabilitySettings(value),
@@ -9091,7 +9135,7 @@ window.__ModuleLoader__.load({
9091
9135
  }
9092
9136
  //#endregion
9093
9137
  //#region src/version.js
9094
- const PACKAGE_VERSION = "2.5.9";
9138
+ const PACKAGE_VERSION = "3.0.0-beta.1";
9095
9139
  //#endregion
9096
9140
  //#region src/client-recovery.js
9097
9141
  async function recoveryCall(rpc, endpoint, payload = {}, timeoutMs = 1e4) {
@@ -10219,6 +10263,2371 @@ window.__ModuleLoader__.load({
10219
10263
  });
10220
10264
  }
10221
10265
  //#endregion
10266
+ //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js
10267
+ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
10268
+ let toSJISFunction;
10269
+ const CODEWORDS_COUNT = [
10270
+ 0,
10271
+ 26,
10272
+ 44,
10273
+ 70,
10274
+ 100,
10275
+ 134,
10276
+ 172,
10277
+ 196,
10278
+ 242,
10279
+ 292,
10280
+ 346,
10281
+ 404,
10282
+ 466,
10283
+ 532,
10284
+ 581,
10285
+ 655,
10286
+ 733,
10287
+ 815,
10288
+ 901,
10289
+ 991,
10290
+ 1085,
10291
+ 1156,
10292
+ 1258,
10293
+ 1364,
10294
+ 1474,
10295
+ 1588,
10296
+ 1706,
10297
+ 1828,
10298
+ 1921,
10299
+ 2051,
10300
+ 2185,
10301
+ 2323,
10302
+ 2465,
10303
+ 2611,
10304
+ 2761,
10305
+ 2876,
10306
+ 3034,
10307
+ 3196,
10308
+ 3362,
10309
+ 3532,
10310
+ 3706
10311
+ ];
10312
+ /**
10313
+ * Returns the QR Code size for the specified version
10314
+ *
10315
+ * @param {Number} version QR Code version
10316
+ * @return {Number} size of QR code
10317
+ */
10318
+ exports.getSymbolSize = function getSymbolSize(version) {
10319
+ if (!version) throw new Error("\"version\" cannot be null or undefined");
10320
+ if (version < 1 || version > 40) throw new Error("\"version\" should be in range from 1 to 40");
10321
+ return version * 4 + 17;
10322
+ };
10323
+ /**
10324
+ * Returns the total number of codewords used to store data and EC information.
10325
+ *
10326
+ * @param {Number} version QR Code version
10327
+ * @return {Number} Data length in bits
10328
+ */
10329
+ exports.getSymbolTotalCodewords = function getSymbolTotalCodewords(version) {
10330
+ return CODEWORDS_COUNT[version];
10331
+ };
10332
+ /**
10333
+ * Encode data with Bose-Chaudhuri-Hocquenghem
10334
+ *
10335
+ * @param {Number} data Value to encode
10336
+ * @return {Number} Encoded value
10337
+ */
10338
+ exports.getBCHDigit = function(data) {
10339
+ let digit = 0;
10340
+ while (data !== 0) {
10341
+ digit++;
10342
+ data >>>= 1;
10343
+ }
10344
+ return digit;
10345
+ };
10346
+ exports.setToSJISFunction = function setToSJISFunction(f) {
10347
+ if (typeof f !== "function") throw new Error("\"toSJISFunc\" is not a valid function.");
10348
+ toSJISFunction = f;
10349
+ };
10350
+ exports.isKanjiModeEnabled = function() {
10351
+ return typeof toSJISFunction !== "undefined";
10352
+ };
10353
+ exports.toSJIS = function toSJIS(kanji) {
10354
+ return toSJISFunction(kanji);
10355
+ };
10356
+ }));
10357
+ //#endregion
10358
+ //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js
10359
+ var require_error_correction_level = /* @__PURE__ */ __commonJSMin(((exports) => {
10360
+ exports.L = { bit: 1 };
10361
+ exports.M = { bit: 0 };
10362
+ exports.Q = { bit: 3 };
10363
+ exports.H = { bit: 2 };
10364
+ function fromString(string) {
10365
+ if (typeof string !== "string") throw new Error("Param is not a string");
10366
+ switch (string.toLowerCase()) {
10367
+ case "l":
10368
+ case "low": return exports.L;
10369
+ case "m":
10370
+ case "medium": return exports.M;
10371
+ case "q":
10372
+ case "quartile": return exports.Q;
10373
+ case "h":
10374
+ case "high": return exports.H;
10375
+ default: throw new Error("Unknown EC Level: " + string);
10376
+ }
10377
+ }
10378
+ exports.isValid = function isValid(level) {
10379
+ return level && typeof level.bit !== "undefined" && level.bit >= 0 && level.bit < 4;
10380
+ };
10381
+ exports.from = function from(value, defaultValue) {
10382
+ if (exports.isValid(value)) return value;
10383
+ try {
10384
+ return fromString(value);
10385
+ } catch (e) {
10386
+ return defaultValue;
10387
+ }
10388
+ };
10389
+ }));
10390
+ //#endregion
10391
+ //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js
10392
+ var require_bit_buffer = /* @__PURE__ */ __commonJSMin(((exports, module) => {
10393
+ function BitBuffer() {
10394
+ this.buffer = [];
10395
+ this.length = 0;
10396
+ }
10397
+ BitBuffer.prototype = {
10398
+ get: function(index) {
10399
+ const bufIndex = Math.floor(index / 8);
10400
+ return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) === 1;
10401
+ },
10402
+ put: function(num, length) {
10403
+ for (let i = 0; i < length; i++) this.putBit((num >>> length - i - 1 & 1) === 1);
10404
+ },
10405
+ getLengthInBits: function() {
10406
+ return this.length;
10407
+ },
10408
+ putBit: function(bit) {
10409
+ const bufIndex = Math.floor(this.length / 8);
10410
+ if (this.buffer.length <= bufIndex) this.buffer.push(0);
10411
+ if (bit) this.buffer[bufIndex] |= 128 >>> this.length % 8;
10412
+ this.length++;
10413
+ }
10414
+ };
10415
+ module.exports = BitBuffer;
10416
+ }));
10417
+ //#endregion
10418
+ //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js
10419
+ var require_bit_matrix = /* @__PURE__ */ __commonJSMin(((exports, module) => {
10420
+ /**
10421
+ * Helper class to handle QR Code symbol modules
10422
+ *
10423
+ * @param {Number} size Symbol size
10424
+ */
10425
+ function BitMatrix(size) {
10426
+ if (!size || size < 1) throw new Error("BitMatrix size must be defined and greater than 0");
10427
+ this.size = size;
10428
+ this.data = new Uint8Array(size * size);
10429
+ this.reservedBit = new Uint8Array(size * size);
10430
+ }
10431
+ /**
10432
+ * Set bit value at specified location
10433
+ * If reserved flag is set, this bit will be ignored during masking process
10434
+ *
10435
+ * @param {Number} row
10436
+ * @param {Number} col
10437
+ * @param {Boolean} value
10438
+ * @param {Boolean} reserved
10439
+ */
10440
+ BitMatrix.prototype.set = function(row, col, value, reserved) {
10441
+ const index = row * this.size + col;
10442
+ this.data[index] = value;
10443
+ if (reserved) this.reservedBit[index] = true;
10444
+ };
10445
+ /**
10446
+ * Returns bit value at specified location
10447
+ *
10448
+ * @param {Number} row
10449
+ * @param {Number} col
10450
+ * @return {Boolean}
10451
+ */
10452
+ BitMatrix.prototype.get = function(row, col) {
10453
+ return this.data[row * this.size + col];
10454
+ };
10455
+ /**
10456
+ * Applies xor operator at specified location
10457
+ * (used during masking process)
10458
+ *
10459
+ * @param {Number} row
10460
+ * @param {Number} col
10461
+ * @param {Boolean} value
10462
+ */
10463
+ BitMatrix.prototype.xor = function(row, col, value) {
10464
+ this.data[row * this.size + col] ^= value;
10465
+ };
10466
+ /**
10467
+ * Check if bit at specified location is reserved
10468
+ *
10469
+ * @param {Number} row
10470
+ * @param {Number} col
10471
+ * @return {Boolean}
10472
+ */
10473
+ BitMatrix.prototype.isReserved = function(row, col) {
10474
+ return this.reservedBit[row * this.size + col];
10475
+ };
10476
+ module.exports = BitMatrix;
10477
+ }));
10478
+ //#endregion
10479
+ //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js
10480
+ var require_alignment_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
10481
+ /**
10482
+ * Alignment pattern are fixed reference pattern in defined positions
10483
+ * in a matrix symbology, which enables the decode software to re-synchronise
10484
+ * the coordinate mapping of the image modules in the event of moderate amounts
10485
+ * of distortion of the image.
10486
+ *
10487
+ * Alignment patterns are present only in QR Code symbols of version 2 or larger
10488
+ * and their number depends on the symbol version.
10489
+ */
10490
+ const getSymbolSize = require_utils().getSymbolSize;
10491
+ /**
10492
+ * Calculate the row/column coordinates of the center module of each alignment pattern
10493
+ * for the specified QR Code version.
10494
+ *
10495
+ * The alignment patterns are positioned symmetrically on either side of the diagonal
10496
+ * running from the top left corner of the symbol to the bottom right corner.
10497
+ *
10498
+ * Since positions are simmetrical only half of the coordinates are returned.
10499
+ * Each item of the array will represent in turn the x and y coordinate.
10500
+ * @see {@link getPositions}
10501
+ *
10502
+ * @param {Number} version QR Code version
10503
+ * @return {Array} Array of coordinate
10504
+ */
10505
+ exports.getRowColCoords = function getRowColCoords(version) {
10506
+ if (version === 1) return [];
10507
+ const posCount = Math.floor(version / 7) + 2;
10508
+ const size = getSymbolSize(version);
10509
+ const intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2;
10510
+ const positions = [size - 7];
10511
+ for (let i = 1; i < posCount - 1; i++) positions[i] = positions[i - 1] - intervals;
10512
+ positions.push(6);
10513
+ return positions.reverse();
10514
+ };
10515
+ /**
10516
+ * Returns an array containing the positions of each alignment pattern.
10517
+ * Each array's element represent the center point of the pattern as (x, y) coordinates
10518
+ *
10519
+ * Coordinates are calculated expanding the row/column coordinates returned by {@link getRowColCoords}
10520
+ * and filtering out the items that overlaps with finder pattern
10521
+ *
10522
+ * @example
10523
+ * For a Version 7 symbol {@link getRowColCoords} returns values 6, 22 and 38.
10524
+ * The alignment patterns, therefore, are to be centered on (row, column)
10525
+ * positions (6,22), (22,6), (22,22), (22,38), (38,22), (38,38).
10526
+ * Note that the coordinates (6,6), (6,38), (38,6) are occupied by finder patterns
10527
+ * and are not therefore used for alignment patterns.
10528
+ *
10529
+ * let pos = getPositions(7)
10530
+ * // [[6,22], [22,6], [22,22], [22,38], [38,22], [38,38]]
10531
+ *
10532
+ * @param {Number} version QR Code version
10533
+ * @return {Array} Array of coordinates
10534
+ */
10535
+ exports.getPositions = function getPositions(version) {
10536
+ const coords = [];
10537
+ const pos = exports.getRowColCoords(version);
10538
+ const posLength = pos.length;
10539
+ for (let i = 0; i < posLength; i++) for (let j = 0; j < posLength; j++) {
10540
+ if (i === 0 && j === 0 || i === 0 && j === posLength - 1 || i === posLength - 1 && j === 0) continue;
10541
+ coords.push([pos[i], pos[j]]);
10542
+ }
10543
+ return coords;
10544
+ };
10545
+ }));
10546
+ //#endregion
10547
+ //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js
10548
+ var require_finder_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
10549
+ const getSymbolSize = require_utils().getSymbolSize;
10550
+ const FINDER_PATTERN_SIZE = 7;
10551
+ /**
10552
+ * Returns an array containing the positions of each finder pattern.
10553
+ * Each array's element represent the top-left point of the pattern as (x, y) coordinates
10554
+ *
10555
+ * @param {Number} version QR Code version
10556
+ * @return {Array} Array of coordinates
10557
+ */
10558
+ exports.getPositions = function getPositions(version) {
10559
+ const size = getSymbolSize(version);
10560
+ return [
10561
+ [0, 0],
10562
+ [size - FINDER_PATTERN_SIZE, 0],
10563
+ [0, size - FINDER_PATTERN_SIZE]
10564
+ ];
10565
+ };
10566
+ }));
10567
+ //#endregion
10568
+ //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js
10569
+ var require_mask_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
10570
+ /**
10571
+ * Data mask pattern reference
10572
+ * @type {Object}
10573
+ */
10574
+ exports.Patterns = {
10575
+ PATTERN000: 0,
10576
+ PATTERN001: 1,
10577
+ PATTERN010: 2,
10578
+ PATTERN011: 3,
10579
+ PATTERN100: 4,
10580
+ PATTERN101: 5,
10581
+ PATTERN110: 6,
10582
+ PATTERN111: 7
10583
+ };
10584
+ /**
10585
+ * Weighted penalty scores for the undesirable features
10586
+ * @type {Object}
10587
+ */
10588
+ const PenaltyScores = {
10589
+ N1: 3,
10590
+ N2: 3,
10591
+ N3: 40,
10592
+ N4: 10
10593
+ };
10594
+ /**
10595
+ * Check if mask pattern value is valid
10596
+ *
10597
+ * @param {Number} mask Mask pattern
10598
+ * @return {Boolean} true if valid, false otherwise
10599
+ */
10600
+ exports.isValid = function isValid(mask) {
10601
+ return mask != null && mask !== "" && !isNaN(mask) && mask >= 0 && mask <= 7;
10602
+ };
10603
+ /**
10604
+ * Returns mask pattern from a value.
10605
+ * If value is not valid, returns undefined
10606
+ *
10607
+ * @param {Number|String} value Mask pattern value
10608
+ * @return {Number} Valid mask pattern or undefined
10609
+ */
10610
+ exports.from = function from(value) {
10611
+ return exports.isValid(value) ? parseInt(value, 10) : void 0;
10612
+ };
10613
+ /**
10614
+ * Find adjacent modules in row/column with the same color
10615
+ * and assign a penalty value.
10616
+ *
10617
+ * Points: N1 + i
10618
+ * i is the amount by which the number of adjacent modules of the same color exceeds 5
10619
+ */
10620
+ exports.getPenaltyN1 = function getPenaltyN1(data) {
10621
+ const size = data.size;
10622
+ let points = 0;
10623
+ let sameCountCol = 0;
10624
+ let sameCountRow = 0;
10625
+ let lastCol = null;
10626
+ let lastRow = null;
10627
+ for (let row = 0; row < size; row++) {
10628
+ sameCountCol = sameCountRow = 0;
10629
+ lastCol = lastRow = null;
10630
+ for (let col = 0; col < size; col++) {
10631
+ let module$1 = data.get(row, col);
10632
+ if (module$1 === lastCol) sameCountCol++;
10633
+ else {
10634
+ if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
10635
+ lastCol = module$1;
10636
+ sameCountCol = 1;
10637
+ }
10638
+ module$1 = data.get(col, row);
10639
+ if (module$1 === lastRow) sameCountRow++;
10640
+ else {
10641
+ if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
10642
+ lastRow = module$1;
10643
+ sameCountRow = 1;
10644
+ }
10645
+ }
10646
+ if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
10647
+ if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
10648
+ }
10649
+ return points;
10650
+ };
10651
+ /**
10652
+ * Find 2x2 blocks with the same color and assign a penalty value
10653
+ *
10654
+ * Points: N2 * (m - 1) * (n - 1)
10655
+ */
10656
+ exports.getPenaltyN2 = function getPenaltyN2(data) {
10657
+ const size = data.size;
10658
+ let points = 0;
10659
+ for (let row = 0; row < size - 1; row++) for (let col = 0; col < size - 1; col++) {
10660
+ const last = data.get(row, col) + data.get(row, col + 1) + data.get(row + 1, col) + data.get(row + 1, col + 1);
10661
+ if (last === 4 || last === 0) points++;
10662
+ }
10663
+ return points * PenaltyScores.N2;
10664
+ };
10665
+ /**
10666
+ * Find 1:1:3:1:1 ratio (dark:light:dark:light:dark) pattern in row/column,
10667
+ * preceded or followed by light area 4 modules wide
10668
+ *
10669
+ * Points: N3 * number of pattern found
10670
+ */
10671
+ exports.getPenaltyN3 = function getPenaltyN3(data) {
10672
+ const size = data.size;
10673
+ let points = 0;
10674
+ let bitsCol = 0;
10675
+ let bitsRow = 0;
10676
+ for (let row = 0; row < size; row++) {
10677
+ bitsCol = bitsRow = 0;
10678
+ for (let col = 0; col < size; col++) {
10679
+ bitsCol = bitsCol << 1 & 2047 | data.get(row, col);
10680
+ if (col >= 10 && (bitsCol === 1488 || bitsCol === 93)) points++;
10681
+ bitsRow = bitsRow << 1 & 2047 | data.get(col, row);
10682
+ if (col >= 10 && (bitsRow === 1488 || bitsRow === 93)) points++;
10683
+ }
10684
+ }
10685
+ return points * PenaltyScores.N3;
10686
+ };
10687
+ /**
10688
+ * Calculate proportion of dark modules in entire symbol
10689
+ *
10690
+ * Points: N4 * k
10691
+ *
10692
+ * k is the rating of the deviation of the proportion of dark modules
10693
+ * in the symbol from 50% in steps of 5%
10694
+ */
10695
+ exports.getPenaltyN4 = function getPenaltyN4(data) {
10696
+ let darkCount = 0;
10697
+ const modulesCount = data.data.length;
10698
+ for (let i = 0; i < modulesCount; i++) darkCount += data.data[i];
10699
+ return Math.abs(Math.ceil(darkCount * 100 / modulesCount / 5) - 10) * PenaltyScores.N4;
10700
+ };
10701
+ /**
10702
+ * Return mask value at given position
10703
+ *
10704
+ * @param {Number} maskPattern Pattern reference value
10705
+ * @param {Number} i Row
10706
+ * @param {Number} j Column
10707
+ * @return {Boolean} Mask value
10708
+ */
10709
+ function getMaskAt(maskPattern, i, j) {
10710
+ switch (maskPattern) {
10711
+ case exports.Patterns.PATTERN000: return (i + j) % 2 === 0;
10712
+ case exports.Patterns.PATTERN001: return i % 2 === 0;
10713
+ case exports.Patterns.PATTERN010: return j % 3 === 0;
10714
+ case exports.Patterns.PATTERN011: return (i + j) % 3 === 0;
10715
+ case exports.Patterns.PATTERN100: return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0;
10716
+ case exports.Patterns.PATTERN101: return i * j % 2 + i * j % 3 === 0;
10717
+ case exports.Patterns.PATTERN110: return (i * j % 2 + i * j % 3) % 2 === 0;
10718
+ case exports.Patterns.PATTERN111: return (i * j % 3 + (i + j) % 2) % 2 === 0;
10719
+ default: throw new Error("bad maskPattern:" + maskPattern);
10720
+ }
10721
+ }
10722
+ /**
10723
+ * Apply a mask pattern to a BitMatrix
10724
+ *
10725
+ * @param {Number} pattern Pattern reference number
10726
+ * @param {BitMatrix} data BitMatrix data
10727
+ */
10728
+ exports.applyMask = function applyMask(pattern, data) {
10729
+ const size = data.size;
10730
+ for (let col = 0; col < size; col++) for (let row = 0; row < size; row++) {
10731
+ if (data.isReserved(row, col)) continue;
10732
+ data.xor(row, col, getMaskAt(pattern, row, col));
10733
+ }
10734
+ };
10735
+ /**
10736
+ * Returns the best mask pattern for data
10737
+ *
10738
+ * @param {BitMatrix} data
10739
+ * @return {Number} Mask pattern reference number
10740
+ */
10741
+ exports.getBestMask = function getBestMask(data, setupFormatFunc) {
10742
+ const numPatterns = Object.keys(exports.Patterns).length;
10743
+ let bestPattern = 0;
10744
+ let lowerPenalty = Infinity;
10745
+ for (let p = 0; p < numPatterns; p++) {
10746
+ setupFormatFunc(p);
10747
+ exports.applyMask(p, data);
10748
+ const penalty = exports.getPenaltyN1(data) + exports.getPenaltyN2(data) + exports.getPenaltyN3(data) + exports.getPenaltyN4(data);
10749
+ exports.applyMask(p, data);
10750
+ if (penalty < lowerPenalty) {
10751
+ lowerPenalty = penalty;
10752
+ bestPattern = p;
10753
+ }
10754
+ }
10755
+ return bestPattern;
10756
+ };
10757
+ }));
10758
+ //#endregion
10759
+ //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js
10760
+ var require_error_correction_code = /* @__PURE__ */ __commonJSMin(((exports) => {
10761
+ const ECLevel = require_error_correction_level();
10762
+ const EC_BLOCKS_TABLE = [
10763
+ 1,
10764
+ 1,
10765
+ 1,
10766
+ 1,
10767
+ 1,
10768
+ 1,
10769
+ 1,
10770
+ 1,
10771
+ 1,
10772
+ 1,
10773
+ 2,
10774
+ 2,
10775
+ 1,
10776
+ 2,
10777
+ 2,
10778
+ 4,
10779
+ 1,
10780
+ 2,
10781
+ 4,
10782
+ 4,
10783
+ 2,
10784
+ 4,
10785
+ 4,
10786
+ 4,
10787
+ 2,
10788
+ 4,
10789
+ 6,
10790
+ 5,
10791
+ 2,
10792
+ 4,
10793
+ 6,
10794
+ 6,
10795
+ 2,
10796
+ 5,
10797
+ 8,
10798
+ 8,
10799
+ 4,
10800
+ 5,
10801
+ 8,
10802
+ 8,
10803
+ 4,
10804
+ 5,
10805
+ 8,
10806
+ 11,
10807
+ 4,
10808
+ 8,
10809
+ 10,
10810
+ 11,
10811
+ 4,
10812
+ 9,
10813
+ 12,
10814
+ 16,
10815
+ 4,
10816
+ 9,
10817
+ 16,
10818
+ 16,
10819
+ 6,
10820
+ 10,
10821
+ 12,
10822
+ 18,
10823
+ 6,
10824
+ 10,
10825
+ 17,
10826
+ 16,
10827
+ 6,
10828
+ 11,
10829
+ 16,
10830
+ 19,
10831
+ 6,
10832
+ 13,
10833
+ 18,
10834
+ 21,
10835
+ 7,
10836
+ 14,
10837
+ 21,
10838
+ 25,
10839
+ 8,
10840
+ 16,
10841
+ 20,
10842
+ 25,
10843
+ 8,
10844
+ 17,
10845
+ 23,
10846
+ 25,
10847
+ 9,
10848
+ 17,
10849
+ 23,
10850
+ 34,
10851
+ 9,
10852
+ 18,
10853
+ 25,
10854
+ 30,
10855
+ 10,
10856
+ 20,
10857
+ 27,
10858
+ 32,
10859
+ 12,
10860
+ 21,
10861
+ 29,
10862
+ 35,
10863
+ 12,
10864
+ 23,
10865
+ 34,
10866
+ 37,
10867
+ 12,
10868
+ 25,
10869
+ 34,
10870
+ 40,
10871
+ 13,
10872
+ 26,
10873
+ 35,
10874
+ 42,
10875
+ 14,
10876
+ 28,
10877
+ 38,
10878
+ 45,
10879
+ 15,
10880
+ 29,
10881
+ 40,
10882
+ 48,
10883
+ 16,
10884
+ 31,
10885
+ 43,
10886
+ 51,
10887
+ 17,
10888
+ 33,
10889
+ 45,
10890
+ 54,
10891
+ 18,
10892
+ 35,
10893
+ 48,
10894
+ 57,
10895
+ 19,
10896
+ 37,
10897
+ 51,
10898
+ 60,
10899
+ 19,
10900
+ 38,
10901
+ 53,
10902
+ 63,
10903
+ 20,
10904
+ 40,
10905
+ 56,
10906
+ 66,
10907
+ 21,
10908
+ 43,
10909
+ 59,
10910
+ 70,
10911
+ 22,
10912
+ 45,
10913
+ 62,
10914
+ 74,
10915
+ 24,
10916
+ 47,
10917
+ 65,
10918
+ 77,
10919
+ 25,
10920
+ 49,
10921
+ 68,
10922
+ 81
10923
+ ];
10924
+ const EC_CODEWORDS_TABLE = [
10925
+ 7,
10926
+ 10,
10927
+ 13,
10928
+ 17,
10929
+ 10,
10930
+ 16,
10931
+ 22,
10932
+ 28,
10933
+ 15,
10934
+ 26,
10935
+ 36,
10936
+ 44,
10937
+ 20,
10938
+ 36,
10939
+ 52,
10940
+ 64,
10941
+ 26,
10942
+ 48,
10943
+ 72,
10944
+ 88,
10945
+ 36,
10946
+ 64,
10947
+ 96,
10948
+ 112,
10949
+ 40,
10950
+ 72,
10951
+ 108,
10952
+ 130,
10953
+ 48,
10954
+ 88,
10955
+ 132,
10956
+ 156,
10957
+ 60,
10958
+ 110,
10959
+ 160,
10960
+ 192,
10961
+ 72,
10962
+ 130,
10963
+ 192,
10964
+ 224,
10965
+ 80,
10966
+ 150,
10967
+ 224,
10968
+ 264,
10969
+ 96,
10970
+ 176,
10971
+ 260,
10972
+ 308,
10973
+ 104,
10974
+ 198,
10975
+ 288,
10976
+ 352,
10977
+ 120,
10978
+ 216,
10979
+ 320,
10980
+ 384,
10981
+ 132,
10982
+ 240,
10983
+ 360,
10984
+ 432,
10985
+ 144,
10986
+ 280,
10987
+ 408,
10988
+ 480,
10989
+ 168,
10990
+ 308,
10991
+ 448,
10992
+ 532,
10993
+ 180,
10994
+ 338,
10995
+ 504,
10996
+ 588,
10997
+ 196,
10998
+ 364,
10999
+ 546,
11000
+ 650,
11001
+ 224,
11002
+ 416,
11003
+ 600,
11004
+ 700,
11005
+ 224,
11006
+ 442,
11007
+ 644,
11008
+ 750,
11009
+ 252,
11010
+ 476,
11011
+ 690,
11012
+ 816,
11013
+ 270,
11014
+ 504,
11015
+ 750,
11016
+ 900,
11017
+ 300,
11018
+ 560,
11019
+ 810,
11020
+ 960,
11021
+ 312,
11022
+ 588,
11023
+ 870,
11024
+ 1050,
11025
+ 336,
11026
+ 644,
11027
+ 952,
11028
+ 1110,
11029
+ 360,
11030
+ 700,
11031
+ 1020,
11032
+ 1200,
11033
+ 390,
11034
+ 728,
11035
+ 1050,
11036
+ 1260,
11037
+ 420,
11038
+ 784,
11039
+ 1140,
11040
+ 1350,
11041
+ 450,
11042
+ 812,
11043
+ 1200,
11044
+ 1440,
11045
+ 480,
11046
+ 868,
11047
+ 1290,
11048
+ 1530,
11049
+ 510,
11050
+ 924,
11051
+ 1350,
11052
+ 1620,
11053
+ 540,
11054
+ 980,
11055
+ 1440,
11056
+ 1710,
11057
+ 570,
11058
+ 1036,
11059
+ 1530,
11060
+ 1800,
11061
+ 570,
11062
+ 1064,
11063
+ 1590,
11064
+ 1890,
11065
+ 600,
11066
+ 1120,
11067
+ 1680,
11068
+ 1980,
11069
+ 630,
11070
+ 1204,
11071
+ 1770,
11072
+ 2100,
11073
+ 660,
11074
+ 1260,
11075
+ 1860,
11076
+ 2220,
11077
+ 720,
11078
+ 1316,
11079
+ 1950,
11080
+ 2310,
11081
+ 750,
11082
+ 1372,
11083
+ 2040,
11084
+ 2430
11085
+ ];
11086
+ /**
11087
+ * Returns the number of error correction block that the QR Code should contain
11088
+ * for the specified version and error correction level.
11089
+ *
11090
+ * @param {Number} version QR Code version
11091
+ * @param {Number} errorCorrectionLevel Error correction level
11092
+ * @return {Number} Number of error correction blocks
11093
+ */
11094
+ exports.getBlocksCount = function getBlocksCount(version, errorCorrectionLevel) {
11095
+ switch (errorCorrectionLevel) {
11096
+ case ECLevel.L: return EC_BLOCKS_TABLE[(version - 1) * 4 + 0];
11097
+ case ECLevel.M: return EC_BLOCKS_TABLE[(version - 1) * 4 + 1];
11098
+ case ECLevel.Q: return EC_BLOCKS_TABLE[(version - 1) * 4 + 2];
11099
+ case ECLevel.H: return EC_BLOCKS_TABLE[(version - 1) * 4 + 3];
11100
+ default: return;
11101
+ }
11102
+ };
11103
+ /**
11104
+ * Returns the number of error correction codewords to use for the specified
11105
+ * version and error correction level.
11106
+ *
11107
+ * @param {Number} version QR Code version
11108
+ * @param {Number} errorCorrectionLevel Error correction level
11109
+ * @return {Number} Number of error correction codewords
11110
+ */
11111
+ exports.getTotalCodewordsCount = function getTotalCodewordsCount(version, errorCorrectionLevel) {
11112
+ switch (errorCorrectionLevel) {
11113
+ case ECLevel.L: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0];
11114
+ case ECLevel.M: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1];
11115
+ case ECLevel.Q: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2];
11116
+ case ECLevel.H: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3];
11117
+ default: return;
11118
+ }
11119
+ };
11120
+ }));
11121
+ //#endregion
11122
+ //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js
11123
+ var require_galois_field = /* @__PURE__ */ __commonJSMin(((exports) => {
11124
+ const EXP_TABLE = /* @__PURE__ */ new Uint8Array(512);
11125
+ const LOG_TABLE = /* @__PURE__ */ new Uint8Array(256);
11126
+ (function initTables() {
11127
+ let x = 1;
11128
+ for (let i = 0; i < 255; i++) {
11129
+ EXP_TABLE[i] = x;
11130
+ LOG_TABLE[x] = i;
11131
+ x <<= 1;
11132
+ if (x & 256) x ^= 285;
11133
+ }
11134
+ for (let i = 255; i < 512; i++) EXP_TABLE[i] = EXP_TABLE[i - 255];
11135
+ })();
11136
+ /**
11137
+ * Returns log value of n inside Galois Field
11138
+ *
11139
+ * @param {Number} n
11140
+ * @return {Number}
11141
+ */
11142
+ exports.log = function log(n) {
11143
+ if (n < 1) throw new Error("log(" + n + ")");
11144
+ return LOG_TABLE[n];
11145
+ };
11146
+ /**
11147
+ * Returns anti-log value of n inside Galois Field
11148
+ *
11149
+ * @param {Number} n
11150
+ * @return {Number}
11151
+ */
11152
+ exports.exp = function exp(n) {
11153
+ return EXP_TABLE[n];
11154
+ };
11155
+ /**
11156
+ * Multiplies two number inside Galois Field
11157
+ *
11158
+ * @param {Number} x
11159
+ * @param {Number} y
11160
+ * @return {Number}
11161
+ */
11162
+ exports.mul = function mul(x, y) {
11163
+ if (x === 0 || y === 0) return 0;
11164
+ return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]];
11165
+ };
11166
+ }));
11167
+ //#endregion
11168
+ //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js
11169
+ var require_polynomial = /* @__PURE__ */ __commonJSMin(((exports) => {
11170
+ const GF = require_galois_field();
11171
+ /**
11172
+ * Multiplies two polynomials inside Galois Field
11173
+ *
11174
+ * @param {Uint8Array} p1 Polynomial
11175
+ * @param {Uint8Array} p2 Polynomial
11176
+ * @return {Uint8Array} Product of p1 and p2
11177
+ */
11178
+ exports.mul = function mul(p1, p2) {
11179
+ const coeff = new Uint8Array(p1.length + p2.length - 1);
11180
+ for (let i = 0; i < p1.length; i++) for (let j = 0; j < p2.length; j++) coeff[i + j] ^= GF.mul(p1[i], p2[j]);
11181
+ return coeff;
11182
+ };
11183
+ /**
11184
+ * Calculate the remainder of polynomials division
11185
+ *
11186
+ * @param {Uint8Array} divident Polynomial
11187
+ * @param {Uint8Array} divisor Polynomial
11188
+ * @return {Uint8Array} Remainder
11189
+ */
11190
+ exports.mod = function mod(divident, divisor) {
11191
+ let result = new Uint8Array(divident);
11192
+ while (result.length - divisor.length >= 0) {
11193
+ const coeff = result[0];
11194
+ for (let i = 0; i < divisor.length; i++) result[i] ^= GF.mul(divisor[i], coeff);
11195
+ let offset = 0;
11196
+ while (offset < result.length && result[offset] === 0) offset++;
11197
+ result = result.slice(offset);
11198
+ }
11199
+ return result;
11200
+ };
11201
+ /**
11202
+ * Generate an irreducible generator polynomial of specified degree
11203
+ * (used by Reed-Solomon encoder)
11204
+ *
11205
+ * @param {Number} degree Degree of the generator polynomial
11206
+ * @return {Uint8Array} Buffer containing polynomial coefficients
11207
+ */
11208
+ exports.generateECPolynomial = function generateECPolynomial(degree) {
11209
+ let poly = new Uint8Array([1]);
11210
+ for (let i = 0; i < degree; i++) poly = exports.mul(poly, new Uint8Array([1, GF.exp(i)]));
11211
+ return poly;
11212
+ };
11213
+ }));
11214
+ //#endregion
11215
+ //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js
11216
+ var require_reed_solomon_encoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11217
+ const Polynomial = require_polynomial();
11218
+ function ReedSolomonEncoder(degree) {
11219
+ this.genPoly = void 0;
11220
+ this.degree = degree;
11221
+ if (this.degree) this.initialize(this.degree);
11222
+ }
11223
+ /**
11224
+ * Initialize the encoder.
11225
+ * The input param should correspond to the number of error correction codewords.
11226
+ *
11227
+ * @param {Number} degree
11228
+ */
11229
+ ReedSolomonEncoder.prototype.initialize = function initialize(degree) {
11230
+ this.degree = degree;
11231
+ this.genPoly = Polynomial.generateECPolynomial(this.degree);
11232
+ };
11233
+ /**
11234
+ * Encodes a chunk of data
11235
+ *
11236
+ * @param {Uint8Array} data Buffer containing input data
11237
+ * @return {Uint8Array} Buffer containing encoded data
11238
+ */
11239
+ ReedSolomonEncoder.prototype.encode = function encode(data) {
11240
+ if (!this.genPoly) throw new Error("Encoder not initialized");
11241
+ const paddedData = new Uint8Array(data.length + this.degree);
11242
+ paddedData.set(data);
11243
+ const remainder = Polynomial.mod(paddedData, this.genPoly);
11244
+ const start = this.degree - remainder.length;
11245
+ if (start > 0) {
11246
+ const buff = new Uint8Array(this.degree);
11247
+ buff.set(remainder, start);
11248
+ return buff;
11249
+ }
11250
+ return remainder;
11251
+ };
11252
+ module.exports = ReedSolomonEncoder;
11253
+ }));
11254
+ //#endregion
11255
+ //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js
11256
+ var require_version_check = /* @__PURE__ */ __commonJSMin(((exports) => {
11257
+ /**
11258
+ * Check if QR Code version is valid
11259
+ *
11260
+ * @param {Number} version QR Code version
11261
+ * @return {Boolean} true if valid version, false otherwise
11262
+ */
11263
+ exports.isValid = function isValid(version) {
11264
+ return !isNaN(version) && version >= 1 && version <= 40;
11265
+ };
11266
+ }));
11267
+ //#endregion
11268
+ //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js
11269
+ var require_regex = /* @__PURE__ */ __commonJSMin(((exports) => {
11270
+ const numeric = "[0-9]+";
11271
+ const alphanumeric = "[A-Z $%*+\\-./:]+";
11272
+ let kanji = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";
11273
+ kanji = kanji.replace(/u/g, "\\u");
11274
+ const byte = "(?:(?![A-Z0-9 $%*+\\-./:]|" + kanji + ")(?:.|[\r\n]))+";
11275
+ exports.KANJI = new RegExp(kanji, "g");
11276
+ exports.BYTE_KANJI = /* @__PURE__ */ new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g");
11277
+ exports.BYTE = new RegExp(byte, "g");
11278
+ exports.NUMERIC = new RegExp(numeric, "g");
11279
+ exports.ALPHANUMERIC = new RegExp(alphanumeric, "g");
11280
+ const TEST_KANJI = new RegExp("^" + kanji + "$");
11281
+ const TEST_NUMERIC = /* @__PURE__ */ new RegExp("^[0-9]+$");
11282
+ const TEST_ALPHANUMERIC = /* @__PURE__ */ new RegExp("^[A-Z0-9 $%*+\\-./:]+$");
11283
+ exports.testKanji = function testKanji(str) {
11284
+ return TEST_KANJI.test(str);
11285
+ };
11286
+ exports.testNumeric = function testNumeric(str) {
11287
+ return TEST_NUMERIC.test(str);
11288
+ };
11289
+ exports.testAlphanumeric = function testAlphanumeric(str) {
11290
+ return TEST_ALPHANUMERIC.test(str);
11291
+ };
11292
+ }));
11293
+ //#endregion
11294
+ //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js
11295
+ var require_mode = /* @__PURE__ */ __commonJSMin(((exports) => {
11296
+ const VersionCheck = require_version_check();
11297
+ const Regex = require_regex();
11298
+ /**
11299
+ * Numeric mode encodes data from the decimal digit set (0 - 9)
11300
+ * (byte values 30HEX to 39HEX).
11301
+ * Normally, 3 data characters are represented by 10 bits.
11302
+ *
11303
+ * @type {Object}
11304
+ */
11305
+ exports.NUMERIC = {
11306
+ id: "Numeric",
11307
+ bit: 1,
11308
+ ccBits: [
11309
+ 10,
11310
+ 12,
11311
+ 14
11312
+ ]
11313
+ };
11314
+ /**
11315
+ * Alphanumeric mode encodes data from a set of 45 characters,
11316
+ * i.e. 10 numeric digits (0 - 9),
11317
+ * 26 alphabetic characters (A - Z),
11318
+ * and 9 symbols (SP, $, %, *, +, -, ., /, :).
11319
+ * Normally, two input characters are represented by 11 bits.
11320
+ *
11321
+ * @type {Object}
11322
+ */
11323
+ exports.ALPHANUMERIC = {
11324
+ id: "Alphanumeric",
11325
+ bit: 2,
11326
+ ccBits: [
11327
+ 9,
11328
+ 11,
11329
+ 13
11330
+ ]
11331
+ };
11332
+ /**
11333
+ * In byte mode, data is encoded at 8 bits per character.
11334
+ *
11335
+ * @type {Object}
11336
+ */
11337
+ exports.BYTE = {
11338
+ id: "Byte",
11339
+ bit: 4,
11340
+ ccBits: [
11341
+ 8,
11342
+ 16,
11343
+ 16
11344
+ ]
11345
+ };
11346
+ /**
11347
+ * The Kanji mode efficiently encodes Kanji characters in accordance with
11348
+ * the Shift JIS system based on JIS X 0208.
11349
+ * The Shift JIS values are shifted from the JIS X 0208 values.
11350
+ * JIS X 0208 gives details of the shift coded representation.
11351
+ * Each two-byte character value is compacted to a 13-bit binary codeword.
11352
+ *
11353
+ * @type {Object}
11354
+ */
11355
+ exports.KANJI = {
11356
+ id: "Kanji",
11357
+ bit: 8,
11358
+ ccBits: [
11359
+ 8,
11360
+ 10,
11361
+ 12
11362
+ ]
11363
+ };
11364
+ /**
11365
+ * Mixed mode will contain a sequences of data in a combination of any of
11366
+ * the modes described above
11367
+ *
11368
+ * @type {Object}
11369
+ */
11370
+ exports.MIXED = { bit: -1 };
11371
+ /**
11372
+ * Returns the number of bits needed to store the data length
11373
+ * according to QR Code specifications.
11374
+ *
11375
+ * @param {Mode} mode Data mode
11376
+ * @param {Number} version QR Code version
11377
+ * @return {Number} Number of bits
11378
+ */
11379
+ exports.getCharCountIndicator = function getCharCountIndicator(mode, version) {
11380
+ if (!mode.ccBits) throw new Error("Invalid mode: " + mode);
11381
+ if (!VersionCheck.isValid(version)) throw new Error("Invalid version: " + version);
11382
+ if (version >= 1 && version < 10) return mode.ccBits[0];
11383
+ else if (version < 27) return mode.ccBits[1];
11384
+ return mode.ccBits[2];
11385
+ };
11386
+ /**
11387
+ * Returns the most efficient mode to store the specified data
11388
+ *
11389
+ * @param {String} dataStr Input data string
11390
+ * @return {Mode} Best mode
11391
+ */
11392
+ exports.getBestModeForData = function getBestModeForData(dataStr) {
11393
+ if (Regex.testNumeric(dataStr)) return exports.NUMERIC;
11394
+ else if (Regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC;
11395
+ else if (Regex.testKanji(dataStr)) return exports.KANJI;
11396
+ else return exports.BYTE;
11397
+ };
11398
+ /**
11399
+ * Return mode name as string
11400
+ *
11401
+ * @param {Mode} mode Mode object
11402
+ * @returns {String} Mode name
11403
+ */
11404
+ exports.toString = function toString(mode) {
11405
+ if (mode && mode.id) return mode.id;
11406
+ throw new Error("Invalid mode");
11407
+ };
11408
+ /**
11409
+ * Check if input param is a valid mode object
11410
+ *
11411
+ * @param {Mode} mode Mode object
11412
+ * @returns {Boolean} True if valid mode, false otherwise
11413
+ */
11414
+ exports.isValid = function isValid(mode) {
11415
+ return mode && mode.bit && mode.ccBits;
11416
+ };
11417
+ /**
11418
+ * Get mode object from its name
11419
+ *
11420
+ * @param {String} string Mode name
11421
+ * @returns {Mode} Mode object
11422
+ */
11423
+ function fromString(string) {
11424
+ if (typeof string !== "string") throw new Error("Param is not a string");
11425
+ switch (string.toLowerCase()) {
11426
+ case "numeric": return exports.NUMERIC;
11427
+ case "alphanumeric": return exports.ALPHANUMERIC;
11428
+ case "kanji": return exports.KANJI;
11429
+ case "byte": return exports.BYTE;
11430
+ default: throw new Error("Unknown mode: " + string);
11431
+ }
11432
+ }
11433
+ /**
11434
+ * Returns mode from a value.
11435
+ * If value is not a valid mode, returns defaultValue
11436
+ *
11437
+ * @param {Mode|String} value Encoding mode
11438
+ * @param {Mode} defaultValue Fallback value
11439
+ * @return {Mode} Encoding mode
11440
+ */
11441
+ exports.from = function from(value, defaultValue) {
11442
+ if (exports.isValid(value)) return value;
11443
+ try {
11444
+ return fromString(value);
11445
+ } catch (e) {
11446
+ return defaultValue;
11447
+ }
11448
+ };
11449
+ }));
11450
+ //#endregion
11451
+ //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js
11452
+ var require_version = /* @__PURE__ */ __commonJSMin(((exports) => {
11453
+ const Utils = require_utils();
11454
+ const ECCode = require_error_correction_code();
11455
+ const ECLevel = require_error_correction_level();
11456
+ const Mode = require_mode();
11457
+ const VersionCheck = require_version_check();
11458
+ const G18 = 7973;
11459
+ const G18_BCH = Utils.getBCHDigit(G18);
11460
+ function getBestVersionForDataLength(mode, length, errorCorrectionLevel) {
11461
+ for (let currentVersion = 1; currentVersion <= 40; currentVersion++) if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) return currentVersion;
11462
+ }
11463
+ function getReservedBitsCount(mode, version) {
11464
+ return Mode.getCharCountIndicator(mode, version) + 4;
11465
+ }
11466
+ function getTotalBitsFromDataArray(segments, version) {
11467
+ let totalBits = 0;
11468
+ segments.forEach(function(data) {
11469
+ const reservedBits = getReservedBitsCount(data.mode, version);
11470
+ totalBits += reservedBits + data.getBitsLength();
11471
+ });
11472
+ return totalBits;
11473
+ }
11474
+ function getBestVersionForMixedData(segments, errorCorrectionLevel) {
11475
+ for (let currentVersion = 1; currentVersion <= 40; currentVersion++) if (getTotalBitsFromDataArray(segments, currentVersion) <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) return currentVersion;
11476
+ }
11477
+ /**
11478
+ * Returns version number from a value.
11479
+ * If value is not a valid version, returns defaultValue
11480
+ *
11481
+ * @param {Number|String} value QR Code version
11482
+ * @param {Number} defaultValue Fallback value
11483
+ * @return {Number} QR Code version number
11484
+ */
11485
+ exports.from = function from(value, defaultValue) {
11486
+ if (VersionCheck.isValid(value)) return parseInt(value, 10);
11487
+ return defaultValue;
11488
+ };
11489
+ /**
11490
+ * Returns how much data can be stored with the specified QR code version
11491
+ * and error correction level
11492
+ *
11493
+ * @param {Number} version QR Code version (1-40)
11494
+ * @param {Number} errorCorrectionLevel Error correction level
11495
+ * @param {Mode} mode Data mode
11496
+ * @return {Number} Quantity of storable data
11497
+ */
11498
+ exports.getCapacity = function getCapacity(version, errorCorrectionLevel, mode) {
11499
+ if (!VersionCheck.isValid(version)) throw new Error("Invalid QR Code version");
11500
+ if (typeof mode === "undefined") mode = Mode.BYTE;
11501
+ const dataTotalCodewordsBits = (Utils.getSymbolTotalCodewords(version) - ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)) * 8;
11502
+ if (mode === Mode.MIXED) return dataTotalCodewordsBits;
11503
+ const usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version);
11504
+ switch (mode) {
11505
+ case Mode.NUMERIC: return Math.floor(usableBits / 10 * 3);
11506
+ case Mode.ALPHANUMERIC: return Math.floor(usableBits / 11 * 2);
11507
+ case Mode.KANJI: return Math.floor(usableBits / 13);
11508
+ case Mode.BYTE:
11509
+ default: return Math.floor(usableBits / 8);
11510
+ }
11511
+ };
11512
+ /**
11513
+ * Returns the minimum version needed to contain the amount of data
11514
+ *
11515
+ * @param {Segment} data Segment of data
11516
+ * @param {Number} [errorCorrectionLevel=H] Error correction level
11517
+ * @param {Mode} mode Data mode
11518
+ * @return {Number} QR Code version
11519
+ */
11520
+ exports.getBestVersionForData = function getBestVersionForData(data, errorCorrectionLevel) {
11521
+ let seg;
11522
+ const ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M);
11523
+ if (Array.isArray(data)) {
11524
+ if (data.length > 1) return getBestVersionForMixedData(data, ecl);
11525
+ if (data.length === 0) return 1;
11526
+ seg = data[0];
11527
+ } else seg = data;
11528
+ return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl);
11529
+ };
11530
+ /**
11531
+ * Returns version information with relative error correction bits
11532
+ *
11533
+ * The version information is included in QR Code symbols of version 7 or larger.
11534
+ * It consists of an 18-bit sequence containing 6 data bits,
11535
+ * with 12 error correction bits calculated using the (18, 6) Golay code.
11536
+ *
11537
+ * @param {Number} version QR Code version
11538
+ * @return {Number} Encoded version info bits
11539
+ */
11540
+ exports.getEncodedBits = function getEncodedBits(version) {
11541
+ if (!VersionCheck.isValid(version) || version < 7) throw new Error("Invalid QR Code version");
11542
+ let d = version << 12;
11543
+ while (Utils.getBCHDigit(d) - G18_BCH >= 0) d ^= G18 << Utils.getBCHDigit(d) - G18_BCH;
11544
+ return version << 12 | d;
11545
+ };
11546
+ }));
11547
+ //#endregion
11548
+ //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js
11549
+ var require_format_info = /* @__PURE__ */ __commonJSMin(((exports) => {
11550
+ const Utils = require_utils();
11551
+ const G15 = 1335;
11552
+ const G15_MASK = 21522;
11553
+ const G15_BCH = Utils.getBCHDigit(G15);
11554
+ /**
11555
+ * Returns format information with relative error correction bits
11556
+ *
11557
+ * The format information is a 15-bit sequence containing 5 data bits,
11558
+ * with 10 error correction bits calculated using the (15, 5) BCH code.
11559
+ *
11560
+ * @param {Number} errorCorrectionLevel Error correction level
11561
+ * @param {Number} mask Mask pattern
11562
+ * @return {Number} Encoded format information bits
11563
+ */
11564
+ exports.getEncodedBits = function getEncodedBits(errorCorrectionLevel, mask) {
11565
+ const data = errorCorrectionLevel.bit << 3 | mask;
11566
+ let d = data << 10;
11567
+ while (Utils.getBCHDigit(d) - G15_BCH >= 0) d ^= G15 << Utils.getBCHDigit(d) - G15_BCH;
11568
+ return (data << 10 | d) ^ G15_MASK;
11569
+ };
11570
+ }));
11571
+ //#endregion
11572
+ //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js
11573
+ var require_numeric_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11574
+ const Mode = require_mode();
11575
+ function NumericData(data) {
11576
+ this.mode = Mode.NUMERIC;
11577
+ this.data = data.toString();
11578
+ }
11579
+ NumericData.getBitsLength = function getBitsLength(length) {
11580
+ return 10 * Math.floor(length / 3) + (length % 3 ? length % 3 * 3 + 1 : 0);
11581
+ };
11582
+ NumericData.prototype.getLength = function getLength() {
11583
+ return this.data.length;
11584
+ };
11585
+ NumericData.prototype.getBitsLength = function getBitsLength() {
11586
+ return NumericData.getBitsLength(this.data.length);
11587
+ };
11588
+ NumericData.prototype.write = function write(bitBuffer) {
11589
+ let i, group, value;
11590
+ for (i = 0; i + 3 <= this.data.length; i += 3) {
11591
+ group = this.data.substr(i, 3);
11592
+ value = parseInt(group, 10);
11593
+ bitBuffer.put(value, 10);
11594
+ }
11595
+ const remainingNum = this.data.length - i;
11596
+ if (remainingNum > 0) {
11597
+ group = this.data.substr(i);
11598
+ value = parseInt(group, 10);
11599
+ bitBuffer.put(value, remainingNum * 3 + 1);
11600
+ }
11601
+ };
11602
+ module.exports = NumericData;
11603
+ }));
11604
+ //#endregion
11605
+ //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js
11606
+ var require_alphanumeric_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11607
+ const Mode = require_mode();
11608
+ /**
11609
+ * Array of characters available in alphanumeric mode
11610
+ *
11611
+ * As per QR Code specification, to each character
11612
+ * is assigned a value from 0 to 44 which in this case coincides
11613
+ * with the array index
11614
+ *
11615
+ * @type {Array}
11616
+ */
11617
+ const ALPHA_NUM_CHARS = [
11618
+ "0",
11619
+ "1",
11620
+ "2",
11621
+ "3",
11622
+ "4",
11623
+ "5",
11624
+ "6",
11625
+ "7",
11626
+ "8",
11627
+ "9",
11628
+ "A",
11629
+ "B",
11630
+ "C",
11631
+ "D",
11632
+ "E",
11633
+ "F",
11634
+ "G",
11635
+ "H",
11636
+ "I",
11637
+ "J",
11638
+ "K",
11639
+ "L",
11640
+ "M",
11641
+ "N",
11642
+ "O",
11643
+ "P",
11644
+ "Q",
11645
+ "R",
11646
+ "S",
11647
+ "T",
11648
+ "U",
11649
+ "V",
11650
+ "W",
11651
+ "X",
11652
+ "Y",
11653
+ "Z",
11654
+ " ",
11655
+ "$",
11656
+ "%",
11657
+ "*",
11658
+ "+",
11659
+ "-",
11660
+ ".",
11661
+ "/",
11662
+ ":"
11663
+ ];
11664
+ function AlphanumericData(data) {
11665
+ this.mode = Mode.ALPHANUMERIC;
11666
+ this.data = data;
11667
+ }
11668
+ AlphanumericData.getBitsLength = function getBitsLength(length) {
11669
+ return 11 * Math.floor(length / 2) + 6 * (length % 2);
11670
+ };
11671
+ AlphanumericData.prototype.getLength = function getLength() {
11672
+ return this.data.length;
11673
+ };
11674
+ AlphanumericData.prototype.getBitsLength = function getBitsLength() {
11675
+ return AlphanumericData.getBitsLength(this.data.length);
11676
+ };
11677
+ AlphanumericData.prototype.write = function write(bitBuffer) {
11678
+ let i;
11679
+ for (i = 0; i + 2 <= this.data.length; i += 2) {
11680
+ let value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45;
11681
+ value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1]);
11682
+ bitBuffer.put(value, 11);
11683
+ }
11684
+ if (this.data.length % 2) bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6);
11685
+ };
11686
+ module.exports = AlphanumericData;
11687
+ }));
11688
+ //#endregion
11689
+ //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js
11690
+ var require_byte_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11691
+ const Mode = require_mode();
11692
+ function ByteData(data) {
11693
+ this.mode = Mode.BYTE;
11694
+ if (typeof data === "string") this.data = new TextEncoder().encode(data);
11695
+ else this.data = new Uint8Array(data);
11696
+ }
11697
+ ByteData.getBitsLength = function getBitsLength(length) {
11698
+ return length * 8;
11699
+ };
11700
+ ByteData.prototype.getLength = function getLength() {
11701
+ return this.data.length;
11702
+ };
11703
+ ByteData.prototype.getBitsLength = function getBitsLength() {
11704
+ return ByteData.getBitsLength(this.data.length);
11705
+ };
11706
+ ByteData.prototype.write = function(bitBuffer) {
11707
+ for (let i = 0, l = this.data.length; i < l; i++) bitBuffer.put(this.data[i], 8);
11708
+ };
11709
+ module.exports = ByteData;
11710
+ }));
11711
+ //#endregion
11712
+ //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js
11713
+ var require_kanji_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11714
+ const Mode = require_mode();
11715
+ const Utils = require_utils();
11716
+ function KanjiData(data) {
11717
+ this.mode = Mode.KANJI;
11718
+ this.data = data;
11719
+ }
11720
+ KanjiData.getBitsLength = function getBitsLength(length) {
11721
+ return length * 13;
11722
+ };
11723
+ KanjiData.prototype.getLength = function getLength() {
11724
+ return this.data.length;
11725
+ };
11726
+ KanjiData.prototype.getBitsLength = function getBitsLength() {
11727
+ return KanjiData.getBitsLength(this.data.length);
11728
+ };
11729
+ KanjiData.prototype.write = function(bitBuffer) {
11730
+ let i;
11731
+ for (i = 0; i < this.data.length; i++) {
11732
+ let value = Utils.toSJIS(this.data[i]);
11733
+ if (value >= 33088 && value <= 40956) value -= 33088;
11734
+ else if (value >= 57408 && value <= 60351) value -= 49472;
11735
+ else throw new Error("Invalid SJIS character: " + this.data[i] + "\nMake sure your charset is UTF-8");
11736
+ value = (value >>> 8 & 255) * 192 + (value & 255);
11737
+ bitBuffer.put(value, 13);
11738
+ }
11739
+ };
11740
+ module.exports = KanjiData;
11741
+ }));
11742
+ //#endregion
11743
+ //#region node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js
11744
+ var require_dijkstra = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11745
+ /******************************************************************************
11746
+ * Created 2008-08-19.
11747
+ *
11748
+ * Dijkstra path-finding functions. Adapted from the Dijkstar Python project.
11749
+ *
11750
+ * Copyright (C) 2008
11751
+ * Wyatt Baldwin <self@wyattbaldwin.com>
11752
+ * All rights reserved
11753
+ *
11754
+ * Licensed under the MIT license.
11755
+ *
11756
+ * http://www.opensource.org/licenses/mit-license.php
11757
+ *
11758
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11759
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11760
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
11761
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
11762
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
11763
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11764
+ * THE SOFTWARE.
11765
+ *****************************************************************************/
11766
+ var dijkstra = {
11767
+ single_source_shortest_paths: function(graph, s, d) {
11768
+ var predecessors = {};
11769
+ var costs = {};
11770
+ costs[s] = 0;
11771
+ var open = dijkstra.PriorityQueue.make();
11772
+ open.push(s, 0);
11773
+ var closest, u, v, cost_of_s_to_u, adjacent_nodes, cost_of_e, cost_of_s_to_u_plus_cost_of_e, cost_of_s_to_v, first_visit;
11774
+ while (!open.empty()) {
11775
+ closest = open.pop();
11776
+ u = closest.value;
11777
+ cost_of_s_to_u = closest.cost;
11778
+ adjacent_nodes = graph[u] || {};
11779
+ for (v in adjacent_nodes) if (adjacent_nodes.hasOwnProperty(v)) {
11780
+ cost_of_e = adjacent_nodes[v];
11781
+ cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
11782
+ cost_of_s_to_v = costs[v];
11783
+ first_visit = typeof costs[v] === "undefined";
11784
+ if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
11785
+ costs[v] = cost_of_s_to_u_plus_cost_of_e;
11786
+ open.push(v, cost_of_s_to_u_plus_cost_of_e);
11787
+ predecessors[v] = u;
11788
+ }
11789
+ }
11790
+ }
11791
+ if (typeof d !== "undefined" && typeof costs[d] === "undefined") {
11792
+ var msg = [
11793
+ "Could not find a path from ",
11794
+ s,
11795
+ " to ",
11796
+ d,
11797
+ "."
11798
+ ].join("");
11799
+ throw new Error(msg);
11800
+ }
11801
+ return predecessors;
11802
+ },
11803
+ extract_shortest_path_from_predecessor_list: function(predecessors, d) {
11804
+ var nodes = [];
11805
+ var u = d;
11806
+ while (u) {
11807
+ nodes.push(u);
11808
+ predecessors[u];
11809
+ u = predecessors[u];
11810
+ }
11811
+ nodes.reverse();
11812
+ return nodes;
11813
+ },
11814
+ find_path: function(graph, s, d) {
11815
+ var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
11816
+ return dijkstra.extract_shortest_path_from_predecessor_list(predecessors, d);
11817
+ },
11818
+ /**
11819
+ * A very naive priority queue implementation.
11820
+ */
11821
+ PriorityQueue: {
11822
+ make: function(opts) {
11823
+ var T = dijkstra.PriorityQueue, t = {}, key;
11824
+ opts = opts || {};
11825
+ for (key in T) if (T.hasOwnProperty(key)) t[key] = T[key];
11826
+ t.queue = [];
11827
+ t.sorter = opts.sorter || T.default_sorter;
11828
+ return t;
11829
+ },
11830
+ default_sorter: function(a, b) {
11831
+ return a.cost - b.cost;
11832
+ },
11833
+ /**
11834
+ * Add a new item to the queue and ensure the highest priority element
11835
+ * is at the front of the queue.
11836
+ */
11837
+ push: function(value, cost) {
11838
+ var item = {
11839
+ value,
11840
+ cost
11841
+ };
11842
+ this.queue.push(item);
11843
+ this.queue.sort(this.sorter);
11844
+ },
11845
+ /**
11846
+ * Return the highest priority element in the queue.
11847
+ */
11848
+ pop: function() {
11849
+ return this.queue.shift();
11850
+ },
11851
+ empty: function() {
11852
+ return this.queue.length === 0;
11853
+ }
11854
+ }
11855
+ };
11856
+ if (typeof module !== "undefined") module.exports = dijkstra;
11857
+ }));
11858
+ //#endregion
11859
+ //#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js
11860
+ var require_segments = /* @__PURE__ */ __commonJSMin(((exports) => {
11861
+ const Mode = require_mode();
11862
+ const NumericData = require_numeric_data();
11863
+ const AlphanumericData = require_alphanumeric_data();
11864
+ const ByteData = require_byte_data();
11865
+ const KanjiData = require_kanji_data();
11866
+ const Regex = require_regex();
11867
+ const Utils = require_utils();
11868
+ const dijkstra = require_dijkstra();
11869
+ /**
11870
+ * Returns UTF8 byte length
11871
+ *
11872
+ * @param {String} str Input string
11873
+ * @return {Number} Number of byte
11874
+ */
11875
+ function getStringByteLength(str) {
11876
+ return unescape(encodeURIComponent(str)).length;
11877
+ }
11878
+ /**
11879
+ * Get a list of segments of the specified mode
11880
+ * from a string
11881
+ *
11882
+ * @param {Mode} mode Segment mode
11883
+ * @param {String} str String to process
11884
+ * @return {Array} Array of object with segments data
11885
+ */
11886
+ function getSegments(regex, mode, str) {
11887
+ const segments = [];
11888
+ let result;
11889
+ while ((result = regex.exec(str)) !== null) segments.push({
11890
+ data: result[0],
11891
+ index: result.index,
11892
+ mode,
11893
+ length: result[0].length
11894
+ });
11895
+ return segments;
11896
+ }
11897
+ /**
11898
+ * Extracts a series of segments with the appropriate
11899
+ * modes from a string
11900
+ *
11901
+ * @param {String} dataStr Input string
11902
+ * @return {Array} Array of object with segments data
11903
+ */
11904
+ function getSegmentsFromString(dataStr) {
11905
+ const numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr);
11906
+ const alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr);
11907
+ let byteSegs;
11908
+ let kanjiSegs;
11909
+ if (Utils.isKanjiModeEnabled()) {
11910
+ byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr);
11911
+ kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr);
11912
+ } else {
11913
+ byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr);
11914
+ kanjiSegs = [];
11915
+ }
11916
+ return numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs).sort(function(s1, s2) {
11917
+ return s1.index - s2.index;
11918
+ }).map(function(obj) {
11919
+ return {
11920
+ data: obj.data,
11921
+ mode: obj.mode,
11922
+ length: obj.length
11923
+ };
11924
+ });
11925
+ }
11926
+ /**
11927
+ * Returns how many bits are needed to encode a string of
11928
+ * specified length with the specified mode
11929
+ *
11930
+ * @param {Number} length String length
11931
+ * @param {Mode} mode Segment mode
11932
+ * @return {Number} Bit length
11933
+ */
11934
+ function getSegmentBitsLength(length, mode) {
11935
+ switch (mode) {
11936
+ case Mode.NUMERIC: return NumericData.getBitsLength(length);
11937
+ case Mode.ALPHANUMERIC: return AlphanumericData.getBitsLength(length);
11938
+ case Mode.KANJI: return KanjiData.getBitsLength(length);
11939
+ case Mode.BYTE: return ByteData.getBitsLength(length);
11940
+ }
11941
+ }
11942
+ /**
11943
+ * Merges adjacent segments which have the same mode
11944
+ *
11945
+ * @param {Array} segs Array of object with segments data
11946
+ * @return {Array} Array of object with segments data
11947
+ */
11948
+ function mergeSegments(segs) {
11949
+ return segs.reduce(function(acc, curr) {
11950
+ const prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null;
11951
+ if (prevSeg && prevSeg.mode === curr.mode) {
11952
+ acc[acc.length - 1].data += curr.data;
11953
+ return acc;
11954
+ }
11955
+ acc.push(curr);
11956
+ return acc;
11957
+ }, []);
11958
+ }
11959
+ /**
11960
+ * Generates a list of all possible nodes combination which
11961
+ * will be used to build a segments graph.
11962
+ *
11963
+ * Nodes are divided by groups. Each group will contain a list of all the modes
11964
+ * in which is possible to encode the given text.
11965
+ *
11966
+ * For example the text '12345' can be encoded as Numeric, Alphanumeric or Byte.
11967
+ * The group for '12345' will contain then 3 objects, one for each
11968
+ * possible encoding mode.
11969
+ *
11970
+ * Each node represents a possible segment.
11971
+ *
11972
+ * @param {Array} segs Array of object with segments data
11973
+ * @return {Array} Array of object with segments data
11974
+ */
11975
+ function buildNodes(segs) {
11976
+ const nodes = [];
11977
+ for (let i = 0; i < segs.length; i++) {
11978
+ const seg = segs[i];
11979
+ switch (seg.mode) {
11980
+ case Mode.NUMERIC:
11981
+ nodes.push([
11982
+ seg,
11983
+ {
11984
+ data: seg.data,
11985
+ mode: Mode.ALPHANUMERIC,
11986
+ length: seg.length
11987
+ },
11988
+ {
11989
+ data: seg.data,
11990
+ mode: Mode.BYTE,
11991
+ length: seg.length
11992
+ }
11993
+ ]);
11994
+ break;
11995
+ case Mode.ALPHANUMERIC:
11996
+ nodes.push([seg, {
11997
+ data: seg.data,
11998
+ mode: Mode.BYTE,
11999
+ length: seg.length
12000
+ }]);
12001
+ break;
12002
+ case Mode.KANJI:
12003
+ nodes.push([seg, {
12004
+ data: seg.data,
12005
+ mode: Mode.BYTE,
12006
+ length: getStringByteLength(seg.data)
12007
+ }]);
12008
+ break;
12009
+ case Mode.BYTE: nodes.push([{
12010
+ data: seg.data,
12011
+ mode: Mode.BYTE,
12012
+ length: getStringByteLength(seg.data)
12013
+ }]);
12014
+ }
12015
+ }
12016
+ return nodes;
12017
+ }
12018
+ /**
12019
+ * Builds a graph from a list of nodes.
12020
+ * All segments in each node group will be connected with all the segments of
12021
+ * the next group and so on.
12022
+ *
12023
+ * At each connection will be assigned a weight depending on the
12024
+ * segment's byte length.
12025
+ *
12026
+ * @param {Array} nodes Array of object with segments data
12027
+ * @param {Number} version QR Code version
12028
+ * @return {Object} Graph of all possible segments
12029
+ */
12030
+ function buildGraph(nodes, version) {
12031
+ const table = {};
12032
+ const graph = { start: {} };
12033
+ let prevNodeIds = ["start"];
12034
+ for (let i = 0; i < nodes.length; i++) {
12035
+ const nodeGroup = nodes[i];
12036
+ const currentNodeIds = [];
12037
+ for (let j = 0; j < nodeGroup.length; j++) {
12038
+ const node = nodeGroup[j];
12039
+ const key = "" + i + j;
12040
+ currentNodeIds.push(key);
12041
+ table[key] = {
12042
+ node,
12043
+ lastCount: 0
12044
+ };
12045
+ graph[key] = {};
12046
+ for (let n = 0; n < prevNodeIds.length; n++) {
12047
+ const prevNodeId = prevNodeIds[n];
12048
+ if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {
12049
+ graph[prevNodeId][key] = getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) - getSegmentBitsLength(table[prevNodeId].lastCount, node.mode);
12050
+ table[prevNodeId].lastCount += node.length;
12051
+ } else {
12052
+ if (table[prevNodeId]) table[prevNodeId].lastCount = node.length;
12053
+ graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) + 4 + Mode.getCharCountIndicator(node.mode, version);
12054
+ }
12055
+ }
12056
+ }
12057
+ prevNodeIds = currentNodeIds;
12058
+ }
12059
+ for (let n = 0; n < prevNodeIds.length; n++) graph[prevNodeIds[n]].end = 0;
12060
+ return {
12061
+ map: graph,
12062
+ table
12063
+ };
12064
+ }
12065
+ /**
12066
+ * Builds a segment from a specified data and mode.
12067
+ * If a mode is not specified, the more suitable will be used.
12068
+ *
12069
+ * @param {String} data Input data
12070
+ * @param {Mode | String} modesHint Data mode
12071
+ * @return {Segment} Segment
12072
+ */
12073
+ function buildSingleSegment(data, modesHint) {
12074
+ let mode;
12075
+ const bestMode = Mode.getBestModeForData(data);
12076
+ mode = Mode.from(modesHint, bestMode);
12077
+ if (mode !== Mode.BYTE && mode.bit < bestMode.bit) throw new Error("\"" + data + "\" cannot be encoded with mode " + Mode.toString(mode) + ".\n Suggested mode is: " + Mode.toString(bestMode));
12078
+ if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) mode = Mode.BYTE;
12079
+ switch (mode) {
12080
+ case Mode.NUMERIC: return new NumericData(data);
12081
+ case Mode.ALPHANUMERIC: return new AlphanumericData(data);
12082
+ case Mode.KANJI: return new KanjiData(data);
12083
+ case Mode.BYTE: return new ByteData(data);
12084
+ }
12085
+ }
12086
+ /**
12087
+ * Builds a list of segments from an array.
12088
+ * Array can contain Strings or Objects with segment's info.
12089
+ *
12090
+ * For each item which is a string, will be generated a segment with the given
12091
+ * string and the more appropriate encoding mode.
12092
+ *
12093
+ * For each item which is an object, will be generated a segment with the given
12094
+ * data and mode.
12095
+ * Objects must contain at least the property "data".
12096
+ * If property "mode" is not present, the more suitable mode will be used.
12097
+ *
12098
+ * @param {Array} array Array of objects with segments data
12099
+ * @return {Array} Array of Segments
12100
+ */
12101
+ exports.fromArray = function fromArray(array) {
12102
+ return array.reduce(function(acc, seg) {
12103
+ if (typeof seg === "string") acc.push(buildSingleSegment(seg, null));
12104
+ else if (seg.data) acc.push(buildSingleSegment(seg.data, seg.mode));
12105
+ return acc;
12106
+ }, []);
12107
+ };
12108
+ /**
12109
+ * Builds an optimized sequence of segments from a string,
12110
+ * which will produce the shortest possible bitstream.
12111
+ *
12112
+ * @param {String} data Input string
12113
+ * @param {Number} version QR Code version
12114
+ * @return {Array} Array of segments
12115
+ */
12116
+ exports.fromString = function fromString(data, version) {
12117
+ const graph = buildGraph(buildNodes(getSegmentsFromString(data, Utils.isKanjiModeEnabled())), version);
12118
+ const path = dijkstra.find_path(graph.map, "start", "end");
12119
+ const optimizedSegs = [];
12120
+ for (let i = 1; i < path.length - 1; i++) optimizedSegs.push(graph.table[path[i]].node);
12121
+ return exports.fromArray(mergeSegments(optimizedSegs));
12122
+ };
12123
+ /**
12124
+ * Splits a string in various segments with the modes which
12125
+ * best represent their content.
12126
+ * The produced segments are far from being optimized.
12127
+ * The output of this function is only used to estimate a QR Code version
12128
+ * which may contain the data.
12129
+ *
12130
+ * @param {string} data Input string
12131
+ * @return {Array} Array of segments
12132
+ */
12133
+ exports.rawSplit = function rawSplit(data) {
12134
+ return exports.fromArray(getSegmentsFromString(data, Utils.isKanjiModeEnabled()));
12135
+ };
12136
+ }));
12137
+ //#endregion
12138
+ //#region src/client-remote-control.jsx
12139
+ var import_qrcode = (/* @__PURE__ */ __commonJSMin(((exports) => {
12140
+ const Utils = require_utils();
12141
+ const ECLevel = require_error_correction_level();
12142
+ const BitBuffer = require_bit_buffer();
12143
+ const BitMatrix = require_bit_matrix();
12144
+ const AlignmentPattern = require_alignment_pattern();
12145
+ const FinderPattern = require_finder_pattern();
12146
+ const MaskPattern = require_mask_pattern();
12147
+ const ECCode = require_error_correction_code();
12148
+ const ReedSolomonEncoder = require_reed_solomon_encoder();
12149
+ const Version = require_version();
12150
+ const FormatInfo = require_format_info();
12151
+ const Mode = require_mode();
12152
+ const Segments = require_segments();
12153
+ /**
12154
+ * QRCode for JavaScript
12155
+ *
12156
+ * modified by Ryan Day for nodejs support
12157
+ * Copyright (c) 2011 Ryan Day
12158
+ *
12159
+ * Licensed under the MIT license:
12160
+ * http://www.opensource.org/licenses/mit-license.php
12161
+ *
12162
+ //---------------------------------------------------------------------
12163
+ // QRCode for JavaScript
12164
+ //
12165
+ // Copyright (c) 2009 Kazuhiko Arase
12166
+ //
12167
+ // URL: http://www.d-project.com/
12168
+ //
12169
+ // Licensed under the MIT license:
12170
+ // http://www.opensource.org/licenses/mit-license.php
12171
+ //
12172
+ // The word "QR Code" is registered trademark of
12173
+ // DENSO WAVE INCORPORATED
12174
+ // http://www.denso-wave.com/qrcode/faqpatent-e.html
12175
+ //
12176
+ //---------------------------------------------------------------------
12177
+ */
12178
+ /**
12179
+ * Add finder patterns bits to matrix
12180
+ *
12181
+ * @param {BitMatrix} matrix Modules matrix
12182
+ * @param {Number} version QR Code version
12183
+ */
12184
+ function setupFinderPattern(matrix, version) {
12185
+ const size = matrix.size;
12186
+ const pos = FinderPattern.getPositions(version);
12187
+ for (let i = 0; i < pos.length; i++) {
12188
+ const row = pos[i][0];
12189
+ const col = pos[i][1];
12190
+ for (let r = -1; r <= 7; r++) {
12191
+ if (row + r <= -1 || size <= row + r) continue;
12192
+ for (let c = -1; c <= 7; c++) {
12193
+ if (col + c <= -1 || size <= col + c) continue;
12194
+ if (r >= 0 && r <= 6 && (c === 0 || c === 6) || c >= 0 && c <= 6 && (r === 0 || r === 6) || r >= 2 && r <= 4 && c >= 2 && c <= 4) matrix.set(row + r, col + c, true, true);
12195
+ else matrix.set(row + r, col + c, false, true);
12196
+ }
12197
+ }
12198
+ }
12199
+ }
12200
+ /**
12201
+ * Add timing pattern bits to matrix
12202
+ *
12203
+ * Note: this function must be called before {@link setupAlignmentPattern}
12204
+ *
12205
+ * @param {BitMatrix} matrix Modules matrix
12206
+ */
12207
+ function setupTimingPattern(matrix) {
12208
+ const size = matrix.size;
12209
+ for (let r = 8; r < size - 8; r++) {
12210
+ const value = r % 2 === 0;
12211
+ matrix.set(r, 6, value, true);
12212
+ matrix.set(6, r, value, true);
12213
+ }
12214
+ }
12215
+ /**
12216
+ * Add alignment patterns bits to matrix
12217
+ *
12218
+ * Note: this function must be called after {@link setupTimingPattern}
12219
+ *
12220
+ * @param {BitMatrix} matrix Modules matrix
12221
+ * @param {Number} version QR Code version
12222
+ */
12223
+ function setupAlignmentPattern(matrix, version) {
12224
+ const pos = AlignmentPattern.getPositions(version);
12225
+ for (let i = 0; i < pos.length; i++) {
12226
+ const row = pos[i][0];
12227
+ const col = pos[i][1];
12228
+ for (let r = -2; r <= 2; r++) for (let c = -2; c <= 2; c++) if (r === -2 || r === 2 || c === -2 || c === 2 || r === 0 && c === 0) matrix.set(row + r, col + c, true, true);
12229
+ else matrix.set(row + r, col + c, false, true);
12230
+ }
12231
+ }
12232
+ /**
12233
+ * Add version info bits to matrix
12234
+ *
12235
+ * @param {BitMatrix} matrix Modules matrix
12236
+ * @param {Number} version QR Code version
12237
+ */
12238
+ function setupVersionInfo(matrix, version) {
12239
+ const size = matrix.size;
12240
+ const bits = Version.getEncodedBits(version);
12241
+ let row, col, mod;
12242
+ for (let i = 0; i < 18; i++) {
12243
+ row = Math.floor(i / 3);
12244
+ col = i % 3 + size - 8 - 3;
12245
+ mod = (bits >> i & 1) === 1;
12246
+ matrix.set(row, col, mod, true);
12247
+ matrix.set(col, row, mod, true);
12248
+ }
12249
+ }
12250
+ /**
12251
+ * Add format info bits to matrix
12252
+ *
12253
+ * @param {BitMatrix} matrix Modules matrix
12254
+ * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
12255
+ * @param {Number} maskPattern Mask pattern reference value
12256
+ */
12257
+ function setupFormatInfo(matrix, errorCorrectionLevel, maskPattern) {
12258
+ const size = matrix.size;
12259
+ const bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern);
12260
+ let i, mod;
12261
+ for (i = 0; i < 15; i++) {
12262
+ mod = (bits >> i & 1) === 1;
12263
+ if (i < 6) matrix.set(i, 8, mod, true);
12264
+ else if (i < 8) matrix.set(i + 1, 8, mod, true);
12265
+ else matrix.set(size - 15 + i, 8, mod, true);
12266
+ if (i < 8) matrix.set(8, size - i - 1, mod, true);
12267
+ else if (i < 9) matrix.set(8, 15 - i - 1 + 1, mod, true);
12268
+ else matrix.set(8, 15 - i - 1, mod, true);
12269
+ }
12270
+ matrix.set(size - 8, 8, 1, true);
12271
+ }
12272
+ /**
12273
+ * Add encoded data bits to matrix
12274
+ *
12275
+ * @param {BitMatrix} matrix Modules matrix
12276
+ * @param {Uint8Array} data Data codewords
12277
+ */
12278
+ function setupData(matrix, data) {
12279
+ const size = matrix.size;
12280
+ let inc = -1;
12281
+ let row = size - 1;
12282
+ let bitIndex = 7;
12283
+ let byteIndex = 0;
12284
+ for (let col = size - 1; col > 0; col -= 2) {
12285
+ if (col === 6) col--;
12286
+ while (true) {
12287
+ for (let c = 0; c < 2; c++) if (!matrix.isReserved(row, col - c)) {
12288
+ let dark = false;
12289
+ if (byteIndex < data.length) dark = (data[byteIndex] >>> bitIndex & 1) === 1;
12290
+ matrix.set(row, col - c, dark);
12291
+ bitIndex--;
12292
+ if (bitIndex === -1) {
12293
+ byteIndex++;
12294
+ bitIndex = 7;
12295
+ }
12296
+ }
12297
+ row += inc;
12298
+ if (row < 0 || size <= row) {
12299
+ row -= inc;
12300
+ inc = -inc;
12301
+ break;
12302
+ }
12303
+ }
12304
+ }
12305
+ }
12306
+ /**
12307
+ * Create encoded codewords from data input
12308
+ *
12309
+ * @param {Number} version QR Code version
12310
+ * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
12311
+ * @param {ByteData} data Data input
12312
+ * @return {Uint8Array} Buffer containing encoded codewords
12313
+ */
12314
+ function createData(version, errorCorrectionLevel, segments) {
12315
+ const buffer = new BitBuffer();
12316
+ segments.forEach(function(data) {
12317
+ buffer.put(data.mode.bit, 4);
12318
+ buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version));
12319
+ data.write(buffer);
12320
+ });
12321
+ const dataTotalCodewordsBits = (Utils.getSymbolTotalCodewords(version) - ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)) * 8;
12322
+ if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) buffer.put(0, 4);
12323
+ while (buffer.getLengthInBits() % 8 !== 0) buffer.putBit(0);
12324
+ const remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8;
12325
+ for (let i = 0; i < remainingByte; i++) buffer.put(i % 2 ? 17 : 236, 8);
12326
+ return createCodewords(buffer, version, errorCorrectionLevel);
12327
+ }
12328
+ /**
12329
+ * Encode input data with Reed-Solomon and return codewords with
12330
+ * relative error correction bits
12331
+ *
12332
+ * @param {BitBuffer} bitBuffer Data to encode
12333
+ * @param {Number} version QR Code version
12334
+ * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
12335
+ * @return {Uint8Array} Buffer containing encoded codewords
12336
+ */
12337
+ function createCodewords(bitBuffer, version, errorCorrectionLevel) {
12338
+ const totalCodewords = Utils.getSymbolTotalCodewords(version);
12339
+ const dataTotalCodewords = totalCodewords - ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
12340
+ const ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel);
12341
+ const blocksInGroup1 = ecTotalBlocks - totalCodewords % ecTotalBlocks;
12342
+ const totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks);
12343
+ const dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks);
12344
+ const dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1;
12345
+ const ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1;
12346
+ const rs = new ReedSolomonEncoder(ecCount);
12347
+ let offset = 0;
12348
+ const dcData = new Array(ecTotalBlocks);
12349
+ const ecData = new Array(ecTotalBlocks);
12350
+ let maxDataSize = 0;
12351
+ const buffer = new Uint8Array(bitBuffer.buffer);
12352
+ for (let b = 0; b < ecTotalBlocks; b++) {
12353
+ const dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2;
12354
+ dcData[b] = buffer.slice(offset, offset + dataSize);
12355
+ ecData[b] = rs.encode(dcData[b]);
12356
+ offset += dataSize;
12357
+ maxDataSize = Math.max(maxDataSize, dataSize);
12358
+ }
12359
+ const data = new Uint8Array(totalCodewords);
12360
+ let index = 0;
12361
+ let i, r;
12362
+ for (i = 0; i < maxDataSize; i++) for (r = 0; r < ecTotalBlocks; r++) if (i < dcData[r].length) data[index++] = dcData[r][i];
12363
+ for (i = 0; i < ecCount; i++) for (r = 0; r < ecTotalBlocks; r++) data[index++] = ecData[r][i];
12364
+ return data;
12365
+ }
12366
+ /**
12367
+ * Build QR Code symbol
12368
+ *
12369
+ * @param {String} data Input string
12370
+ * @param {Number} version QR Code version
12371
+ * @param {ErrorCorretionLevel} errorCorrectionLevel Error level
12372
+ * @param {MaskPattern} maskPattern Mask pattern
12373
+ * @return {Object} Object containing symbol data
12374
+ */
12375
+ function createSymbol(data, version, errorCorrectionLevel, maskPattern) {
12376
+ let segments;
12377
+ if (Array.isArray(data)) segments = Segments.fromArray(data);
12378
+ else if (typeof data === "string") {
12379
+ let estimatedVersion = version;
12380
+ if (!estimatedVersion) {
12381
+ const rawSegments = Segments.rawSplit(data);
12382
+ estimatedVersion = Version.getBestVersionForData(rawSegments, errorCorrectionLevel);
12383
+ }
12384
+ segments = Segments.fromString(data, estimatedVersion || 40);
12385
+ } else throw new Error("Invalid data");
12386
+ const bestVersion = Version.getBestVersionForData(segments, errorCorrectionLevel);
12387
+ if (!bestVersion) throw new Error("The amount of data is too big to be stored in a QR Code");
12388
+ if (!version) version = bestVersion;
12389
+ else if (version < bestVersion) throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: " + bestVersion + ".\n");
12390
+ const dataBits = createData(version, errorCorrectionLevel, segments);
12391
+ const moduleCount = Utils.getSymbolSize(version);
12392
+ const modules = new BitMatrix(moduleCount);
12393
+ setupFinderPattern(modules, version);
12394
+ setupTimingPattern(modules);
12395
+ setupAlignmentPattern(modules, version);
12396
+ setupFormatInfo(modules, errorCorrectionLevel, 0);
12397
+ if (version >= 7) setupVersionInfo(modules, version);
12398
+ setupData(modules, dataBits);
12399
+ if (isNaN(maskPattern)) maskPattern = MaskPattern.getBestMask(modules, setupFormatInfo.bind(null, modules, errorCorrectionLevel));
12400
+ MaskPattern.applyMask(maskPattern, modules);
12401
+ setupFormatInfo(modules, errorCorrectionLevel, maskPattern);
12402
+ return {
12403
+ modules,
12404
+ version,
12405
+ errorCorrectionLevel,
12406
+ maskPattern,
12407
+ segments
12408
+ };
12409
+ }
12410
+ /**
12411
+ * QR Code
12412
+ *
12413
+ * @param {String | Array} data Input data
12414
+ * @param {Object} options Optional configurations
12415
+ * @param {Number} options.version QR Code version
12416
+ * @param {String} options.errorCorrectionLevel Error correction level
12417
+ * @param {Function} options.toSJISFunc Helper func to convert utf8 to sjis
12418
+ */
12419
+ exports.create = function create(data, options) {
12420
+ if (typeof data === "undefined" || data === "") throw new Error("No input text");
12421
+ let errorCorrectionLevel = ECLevel.M;
12422
+ let version;
12423
+ let mask;
12424
+ if (typeof options !== "undefined") {
12425
+ errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M);
12426
+ version = Version.from(options.version);
12427
+ mask = MaskPattern.from(options.maskPattern);
12428
+ if (options.toSJISFunc) Utils.setToSJISFunction(options.toSJISFunc);
12429
+ }
12430
+ return createSymbol(data, version, errorCorrectionLevel, mask);
12431
+ };
12432
+ })))();
12433
+ const PAIR_URL = "https://chatgpt.com/codex/pair?pairing_code=";
12434
+ const STATUS_KEYS = {
12435
+ connected: "remoteConnected",
12436
+ connecting: "remoteConnecting",
12437
+ error: "remoteError",
12438
+ stopped: "remoteStopped"
12439
+ };
12440
+ const MARGIN = 2;
12441
+ function Qr({ value, label }) {
12442
+ let modules;
12443
+ try {
12444
+ modules = (0, import_qrcode.create)(value, { errorCorrectionLevel: "M" }).modules;
12445
+ } catch {
12446
+ return null;
12447
+ }
12448
+ const size = modules.size;
12449
+ let path = "";
12450
+ for (let row = 0; row < size; row++) for (let column = 0; column < size; column++) if (modules.get(row, column)) path += `M${column + MARGIN} ${row + MARGIN}h1v1h-1z`;
12451
+ const span = size + MARGIN * 2;
12452
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
12453
+ className: "codexSubscriptionRemoteQr",
12454
+ role: "img",
12455
+ "aria-label": label,
12456
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
12457
+ viewBox: `0 0 ${span} ${span}`,
12458
+ shapeRendering: "crispEdges",
12459
+ "aria-hidden": "true",
12460
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
12461
+ width: span,
12462
+ height: span,
12463
+ fill: "#fff"
12464
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
12465
+ d: path,
12466
+ fill: "#000"
12467
+ })]
12468
+ })
12469
+ });
12470
+ }
12471
+ /** Beta: show this DSH in the ChatGPT mobile app's Codex list (Remote Control). */
12472
+ function RemoteControlCard({ rpc, preference, snapshot, t }) {
12473
+ const [state, setState] = (0, react.useState)();
12474
+ const [pairing, setPairing] = (0, react.useState)();
12475
+ const [busy, setBusy] = (0, react.useState)(false);
12476
+ const [failed, setFailed] = (0, react.useState)(false);
12477
+ const [now, setNow] = (0, react.useState)(Date.now());
12478
+ const alive = (0, react.useRef)(false);
12479
+ const on = snapshot.remoteControl === "on";
12480
+ const read = async () => {
12481
+ try {
12482
+ const result = await rpc.call(CHANNEL, "remote/status", {});
12483
+ if (alive.current && result.ok) setState(result.value);
12484
+ } catch {}
12485
+ };
12486
+ (0, react.useEffect)(() => {
12487
+ alive.current = true;
12488
+ return () => {
12489
+ alive.current = false;
12490
+ };
12491
+ }, []);
12492
+ (0, react.useEffect)(() => {
12493
+ if (!on) {
12494
+ setState(void 0);
12495
+ setPairing(void 0);
12496
+ return;
12497
+ }
12498
+ let stopped = false, timer;
12499
+ const poll = async () => {
12500
+ await read();
12501
+ if (!stopped) timer = setTimeout(poll, 4e3);
12502
+ };
12503
+ poll();
12504
+ return () => {
12505
+ stopped = true;
12506
+ clearTimeout(timer);
12507
+ };
12508
+ }, [on, rpc]);
12509
+ (0, react.useEffect)(() => {
12510
+ if (!pairing) return void 0;
12511
+ const timer = setInterval(() => setNow(Date.now()), 5e3);
12512
+ return () => clearInterval(timer);
12513
+ }, [pairing]);
12514
+ const pair = async () => {
12515
+ if (busy) return;
12516
+ setBusy(true);
12517
+ setFailed(false);
12518
+ try {
12519
+ const result = await rpc.call(CHANNEL, "remote/pair", {});
12520
+ if (!alive.current) return;
12521
+ if (!result.ok) {
12522
+ setFailed(true);
12523
+ return;
12524
+ }
12525
+ setPairing(result.value);
12526
+ setNow(Date.now());
12527
+ read();
12528
+ } catch {
12529
+ if (alive.current) setFailed(true);
12530
+ } finally {
12531
+ if (alive.current) setBusy(false);
12532
+ }
12533
+ };
12534
+ const expired = pairing && pairing.expiresAt <= now;
12535
+ const minutes = pairing ? Math.max(0, Math.ceil((pairing.expiresAt - now) / 6e4)) : 0;
12536
+ const status = state?.status ?? "connecting";
12537
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
12538
+ className: "codexSubscriptionCard codexSubscriptionPreferencesCard",
12539
+ "aria-label": t("remoteTitle"),
12540
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12541
+ className: "codexSubscriptionPreference",
12542
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12543
+ className: "codexSubscriptionPreferenceCopy",
12544
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
12545
+ className: "codexSubscriptionPreferenceLabel",
12546
+ children: [
12547
+ t("remoteTitle"),
12548
+ " ",
12549
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: "Beta" })
12550
+ ]
12551
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
12552
+ className: "codexSubscriptionPreferenceHint",
12553
+ children: t("remoteHint")
12554
+ })]
12555
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
12556
+ className: "codexSubscriptionQuotaModes",
12557
+ role: "radiogroup",
12558
+ "aria-label": t("remoteTitle"),
12559
+ "aria-busy": snapshot.saving || void 0,
12560
+ children: ["off", "on"].map((value) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
12561
+ className: "codexSubscriptionQuotaMode",
12562
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
12563
+ type: "radio",
12564
+ name: "codex-remote-control",
12565
+ checked: snapshot.remoteControl === value,
12566
+ disabled: !snapshot.writable,
12567
+ onChange: () => {
12568
+ preference.set({ remoteControl: value });
12569
+ }
12570
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t(`remote_${value}`) })]
12571
+ }, value))
12572
+ })]
12573
+ }), on ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
12574
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "codexSubscriptionDivider" }),
12575
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12576
+ className: "codexSubscriptionPreference",
12577
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
12578
+ role: "status",
12579
+ children: [
12580
+ t(STATUS_KEYS[status] ?? "remoteConnecting"),
12581
+ status === "error" && state?.lastError ? ` · ${state.lastError}` : "",
12582
+ state?.phones > 0 ? ` · ${t("remotePhones").replace("{count}", String(state.phones))}` : ""
12583
+ ]
12584
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
12585
+ type: "button",
12586
+ variant: "outline",
12587
+ disabled: busy || status === "stopped",
12588
+ onClick: () => {
12589
+ pair();
12590
+ },
12591
+ children: t(pairing ? "remotePairAgain" : "remotePair")
12592
+ })]
12593
+ }),
12594
+ failed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
12595
+ role: "alert",
12596
+ className: "codexSubscriptionHelp",
12597
+ children: t("remotePairFailed")
12598
+ }) : null,
12599
+ pairing && !expired ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12600
+ className: "codexSubscriptionRemotePair",
12601
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Qr, {
12602
+ value: `${PAIR_URL}${pairing.pairingCode}`,
12603
+ label: t("remoteQrLabel")
12604
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
12605
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
12606
+ className: "codexSubscriptionHelp",
12607
+ children: t("remotePairSteps")
12608
+ }),
12609
+ pairing.manualCode ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
12610
+ className: "codexSubscriptionRemoteCode",
12611
+ "aria-label": t("remoteManualCode"),
12612
+ children: pairing.manualCode
12613
+ }) : null,
12614
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
12615
+ className: "codexSubscriptionHelp",
12616
+ children: t("remoteExpires").replace("{minutes}", String(minutes))
12617
+ })
12618
+ ] })]
12619
+ }) : pairing ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
12620
+ className: "codexSubscriptionHelp",
12621
+ children: t("remoteExpired")
12622
+ }) : null,
12623
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
12624
+ className: "codexSubscriptionHelp",
12625
+ children: t("remoteLimits")
12626
+ })
12627
+ ] }) : null]
12628
+ });
12629
+ }
12630
+ //#endregion
10222
12631
  //#region src/context-draft-state.js
10223
12632
  const hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value ?? {}, key);
10224
12633
  /**
@@ -10801,6 +13210,12 @@ window.__ModuleLoader__.load({
10801
13210
  })]
10802
13211
  })
10803
13212
  }),
13213
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RemoteControlCard, {
13214
+ rpc,
13215
+ preference,
13216
+ snapshot,
13217
+ t
13218
+ }),
10804
13219
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
10805
13220
  className: "codexSubscriptionCard codexSubscriptionPreferencesCard",
10806
13221
  "aria-label": t("compactionTitle"),