meshy-dsh 0.1.1 → 0.2.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 ADDED
@@ -0,0 +1,3604 @@
1
+ window.__ModuleLoader__.load({ id: "meshy-dsh", factory: (require) => {
2
+
3
+ var module = { exports: {} }; var exports = module.exports;
4
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
+ let react = require("react");
6
+ let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
7
+ let react_jsx_runtime = require("react/jsx-runtime");
8
+
9
+ // node_modules/qrcode-generator/dist/qrcode.mjs
10
+ /**
11
+ * qrcode
12
+ * @param typeNumber 1 to 40
13
+ * @param errorCorrectionLevel 'L','M','Q','H'
14
+ */
15
+ const qrcode = function(typeNumber, errorCorrectionLevel) {
16
+ const PAD0 = 236;
17
+ const PAD1 = 17;
18
+ let _typeNumber = typeNumber;
19
+ const _errorCorrectionLevel = QRErrorCorrectionLevel[errorCorrectionLevel];
20
+ let _modules = null;
21
+ let _moduleCount = 0;
22
+ let _dataCache = null;
23
+ const _dataList = [];
24
+ const _this = {};
25
+ const makeImpl = function(test, maskPattern) {
26
+ _moduleCount = _typeNumber * 4 + 17;
27
+ _modules = function(moduleCount) {
28
+ const modules = new Array(moduleCount);
29
+ for (let row = 0; row < moduleCount; row += 1) {
30
+ modules[row] = new Array(moduleCount);
31
+ for (let col = 0; col < moduleCount; col += 1) modules[row][col] = null;
32
+ }
33
+ return modules;
34
+ }(_moduleCount);
35
+ setupPositionProbePattern(0, 0);
36
+ setupPositionProbePattern(_moduleCount - 7, 0);
37
+ setupPositionProbePattern(0, _moduleCount - 7);
38
+ setupPositionAdjustPattern();
39
+ setupTimingPattern();
40
+ setupTypeInfo(test, maskPattern);
41
+ if (_typeNumber >= 7) setupTypeNumber(test);
42
+ if (_dataCache == null) _dataCache = createData(_typeNumber, _errorCorrectionLevel, _dataList);
43
+ mapData(_dataCache, maskPattern);
44
+ };
45
+ const setupPositionProbePattern = function(row, col) {
46
+ for (let r = -1; r <= 7; r += 1) {
47
+ if (row + r <= -1 || _moduleCount <= row + r) continue;
48
+ for (let c = -1; c <= 7; c += 1) {
49
+ if (col + c <= -1 || _moduleCount <= col + c) continue;
50
+ if (0 <= r && r <= 6 && (c == 0 || c == 6) || 0 <= c && c <= 6 && (r == 0 || r == 6) || 2 <= r && r <= 4 && 2 <= c && c <= 4) _modules[row + r][col + c] = true;
51
+ else _modules[row + r][col + c] = false;
52
+ }
53
+ }
54
+ };
55
+ const getBestMaskPattern = function() {
56
+ let minLostPoint = 0;
57
+ let pattern = 0;
58
+ for (let i = 0; i < 8; i += 1) {
59
+ makeImpl(true, i);
60
+ const lostPoint = QRUtil.getLostPoint(_this);
61
+ if (i == 0 || minLostPoint > lostPoint) {
62
+ minLostPoint = lostPoint;
63
+ pattern = i;
64
+ }
65
+ }
66
+ return pattern;
67
+ };
68
+ const setupTimingPattern = function() {
69
+ for (let r = 8; r < _moduleCount - 8; r += 1) {
70
+ if (_modules[r][6] != null) continue;
71
+ _modules[r][6] = r % 2 == 0;
72
+ }
73
+ for (let c = 8; c < _moduleCount - 8; c += 1) {
74
+ if (_modules[6][c] != null) continue;
75
+ _modules[6][c] = c % 2 == 0;
76
+ }
77
+ };
78
+ const setupPositionAdjustPattern = function() {
79
+ const pos = QRUtil.getPatternPosition(_typeNumber);
80
+ for (let i = 0; i < pos.length; i += 1) for (let j = 0; j < pos.length; j += 1) {
81
+ const row = pos[i];
82
+ const col = pos[j];
83
+ if (_modules[row][col] != null) continue;
84
+ for (let r = -2; r <= 2; r += 1) for (let c = -2; c <= 2; c += 1) if (r == -2 || r == 2 || c == -2 || c == 2 || r == 0 && c == 0) _modules[row + r][col + c] = true;
85
+ else _modules[row + r][col + c] = false;
86
+ }
87
+ };
88
+ const setupTypeNumber = function(test) {
89
+ const bits = QRUtil.getBCHTypeNumber(_typeNumber);
90
+ for (let i = 0; i < 18; i += 1) {
91
+ const mod = !test && (bits >> i & 1) == 1;
92
+ _modules[Math.floor(i / 3)][i % 3 + _moduleCount - 8 - 3] = mod;
93
+ }
94
+ for (let i = 0; i < 18; i += 1) {
95
+ const mod = !test && (bits >> i & 1) == 1;
96
+ _modules[i % 3 + _moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
97
+ }
98
+ };
99
+ const setupTypeInfo = function(test, maskPattern) {
100
+ const data = _errorCorrectionLevel << 3 | maskPattern;
101
+ const bits = QRUtil.getBCHTypeInfo(data);
102
+ for (let i = 0; i < 15; i += 1) {
103
+ const mod = !test && (bits >> i & 1) == 1;
104
+ if (i < 6) _modules[i][8] = mod;
105
+ else if (i < 8) _modules[i + 1][8] = mod;
106
+ else _modules[_moduleCount - 15 + i][8] = mod;
107
+ }
108
+ for (let i = 0; i < 15; i += 1) {
109
+ const mod = !test && (bits >> i & 1) == 1;
110
+ if (i < 8) _modules[8][_moduleCount - i - 1] = mod;
111
+ else if (i < 9) _modules[8][15 - i - 1 + 1] = mod;
112
+ else _modules[8][15 - i - 1] = mod;
113
+ }
114
+ _modules[_moduleCount - 8][8] = !test;
115
+ };
116
+ const mapData = function(data, maskPattern) {
117
+ let inc = -1;
118
+ let row = _moduleCount - 1;
119
+ let bitIndex = 7;
120
+ let byteIndex = 0;
121
+ const maskFunc = QRUtil.getMaskFunction(maskPattern);
122
+ for (let col = _moduleCount - 1; col > 0; col -= 2) {
123
+ if (col == 6) col -= 1;
124
+ while (true) {
125
+ for (let c = 0; c < 2; c += 1) if (_modules[row][col - c] == null) {
126
+ let dark = false;
127
+ if (byteIndex < data.length) dark = (data[byteIndex] >>> bitIndex & 1) == 1;
128
+ if (maskFunc(row, col - c)) dark = !dark;
129
+ _modules[row][col - c] = dark;
130
+ bitIndex -= 1;
131
+ if (bitIndex == -1) {
132
+ byteIndex += 1;
133
+ bitIndex = 7;
134
+ }
135
+ }
136
+ row += inc;
137
+ if (row < 0 || _moduleCount <= row) {
138
+ row -= inc;
139
+ inc = -inc;
140
+ break;
141
+ }
142
+ }
143
+ }
144
+ };
145
+ const createBytes = function(buffer, rsBlocks) {
146
+ let offset = 0;
147
+ let maxDcCount = 0;
148
+ let maxEcCount = 0;
149
+ const dcdata = new Array(rsBlocks.length);
150
+ const ecdata = new Array(rsBlocks.length);
151
+ for (let r = 0; r < rsBlocks.length; r += 1) {
152
+ const dcCount = rsBlocks[r].dataCount;
153
+ const ecCount = rsBlocks[r].totalCount - dcCount;
154
+ maxDcCount = Math.max(maxDcCount, dcCount);
155
+ maxEcCount = Math.max(maxEcCount, ecCount);
156
+ dcdata[r] = new Array(dcCount);
157
+ for (let i = 0; i < dcdata[r].length; i += 1) dcdata[r][i] = 255 & buffer.getBuffer()[i + offset];
158
+ offset += dcCount;
159
+ const rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);
160
+ const modPoly = qrPolynomial(dcdata[r], rsPoly.getLength() - 1).mod(rsPoly);
161
+ ecdata[r] = new Array(rsPoly.getLength() - 1);
162
+ for (let i = 0; i < ecdata[r].length; i += 1) {
163
+ const modIndex = i + modPoly.getLength() - ecdata[r].length;
164
+ ecdata[r][i] = modIndex >= 0 ? modPoly.getAt(modIndex) : 0;
165
+ }
166
+ }
167
+ let totalCodeCount = 0;
168
+ for (let i = 0; i < rsBlocks.length; i += 1) totalCodeCount += rsBlocks[i].totalCount;
169
+ const data = new Array(totalCodeCount);
170
+ let index = 0;
171
+ for (let i = 0; i < maxDcCount; i += 1) for (let r = 0; r < rsBlocks.length; r += 1) if (i < dcdata[r].length) {
172
+ data[index] = dcdata[r][i];
173
+ index += 1;
174
+ }
175
+ for (let i = 0; i < maxEcCount; i += 1) for (let r = 0; r < rsBlocks.length; r += 1) if (i < ecdata[r].length) {
176
+ data[index] = ecdata[r][i];
177
+ index += 1;
178
+ }
179
+ return data;
180
+ };
181
+ const createData = function(typeNumber, errorCorrectionLevel, dataList) {
182
+ const rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectionLevel);
183
+ const buffer = qrBitBuffer();
184
+ for (let i = 0; i < dataList.length; i += 1) {
185
+ const data = dataList[i];
186
+ buffer.put(data.getMode(), 4);
187
+ buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber));
188
+ data.write(buffer);
189
+ }
190
+ let totalDataCount = 0;
191
+ for (let i = 0; i < rsBlocks.length; i += 1) totalDataCount += rsBlocks[i].dataCount;
192
+ if (buffer.getLengthInBits() > totalDataCount * 8) throw "code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")";
193
+ if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) buffer.put(0, 4);
194
+ while (buffer.getLengthInBits() % 8 != 0) buffer.putBit(false);
195
+ while (true) {
196
+ if (buffer.getLengthInBits() >= totalDataCount * 8) break;
197
+ buffer.put(PAD0, 8);
198
+ if (buffer.getLengthInBits() >= totalDataCount * 8) break;
199
+ buffer.put(PAD1, 8);
200
+ }
201
+ return createBytes(buffer, rsBlocks);
202
+ };
203
+ _this.addData = function(data, mode) {
204
+ mode = mode || "Byte";
205
+ let newData = null;
206
+ switch (mode) {
207
+ case "Numeric":
208
+ newData = qrNumber(data);
209
+ break;
210
+ case "Alphanumeric":
211
+ newData = qrAlphaNum(data);
212
+ break;
213
+ case "Byte":
214
+ newData = qr8BitByte(data);
215
+ break;
216
+ case "Kanji":
217
+ newData = qrKanji(data);
218
+ break;
219
+ default: throw "mode:" + mode;
220
+ }
221
+ _dataList.push(newData);
222
+ _dataCache = null;
223
+ };
224
+ _this.isDark = function(row, col) {
225
+ if (row < 0 || _moduleCount <= row || col < 0 || _moduleCount <= col) throw row + "," + col;
226
+ return _modules[row][col];
227
+ };
228
+ _this.getModuleCount = function() {
229
+ return _moduleCount;
230
+ };
231
+ _this.make = function() {
232
+ if (_typeNumber < 1) {
233
+ let typeNumber = 1;
234
+ for (; typeNumber < 40; typeNumber++) {
235
+ const rsBlocks = QRRSBlock.getRSBlocks(typeNumber, _errorCorrectionLevel);
236
+ const buffer = qrBitBuffer();
237
+ for (let i = 0; i < _dataList.length; i++) {
238
+ const data = _dataList[i];
239
+ buffer.put(data.getMode(), 4);
240
+ buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber));
241
+ data.write(buffer);
242
+ }
243
+ let totalDataCount = 0;
244
+ for (let i = 0; i < rsBlocks.length; i++) totalDataCount += rsBlocks[i].dataCount;
245
+ if (buffer.getLengthInBits() <= totalDataCount * 8) break;
246
+ }
247
+ _typeNumber = typeNumber;
248
+ }
249
+ makeImpl(false, getBestMaskPattern());
250
+ };
251
+ _this.createTableTag = function(cellSize, margin) {
252
+ cellSize = cellSize || 2;
253
+ margin = typeof margin == "undefined" ? cellSize * 4 : margin;
254
+ let qrHtml = "";
255
+ qrHtml += "<table style=\"";
256
+ qrHtml += " border-width: 0px; border-style: none;";
257
+ qrHtml += " border-collapse: collapse;";
258
+ qrHtml += " padding: 0px; margin: " + margin + "px;";
259
+ qrHtml += "\">";
260
+ qrHtml += "<tbody>";
261
+ for (let r = 0; r < _this.getModuleCount(); r += 1) {
262
+ qrHtml += "<tr>";
263
+ for (let c = 0; c < _this.getModuleCount(); c += 1) {
264
+ qrHtml += "<td style=\"";
265
+ qrHtml += " border-width: 0px; border-style: none;";
266
+ qrHtml += " border-collapse: collapse;";
267
+ qrHtml += " padding: 0px; margin: 0px;";
268
+ qrHtml += " width: " + cellSize + "px;";
269
+ qrHtml += " height: " + cellSize + "px;";
270
+ qrHtml += " background-color: ";
271
+ qrHtml += _this.isDark(r, c) ? "#000000" : "#ffffff";
272
+ qrHtml += ";";
273
+ qrHtml += "\"/>";
274
+ }
275
+ qrHtml += "</tr>";
276
+ }
277
+ qrHtml += "</tbody>";
278
+ qrHtml += "</table>";
279
+ return qrHtml;
280
+ };
281
+ _this.createSvgTag = function(cellSize, margin, alt, title) {
282
+ let opts = {};
283
+ if (typeof arguments[0] == "object") {
284
+ opts = arguments[0];
285
+ cellSize = opts.cellSize;
286
+ margin = opts.margin;
287
+ alt = opts.alt;
288
+ title = opts.title;
289
+ }
290
+ cellSize = cellSize || 2;
291
+ margin = typeof margin == "undefined" ? cellSize * 4 : margin;
292
+ alt = typeof alt === "string" ? { text: alt } : alt || {};
293
+ alt.text = alt.text || null;
294
+ alt.id = alt.text ? alt.id || "qrcode-description" : null;
295
+ title = typeof title === "string" ? { text: title } : title || {};
296
+ title.text = title.text || null;
297
+ title.id = title.text ? title.id || "qrcode-title" : null;
298
+ const size = _this.getModuleCount() * cellSize + margin * 2;
299
+ let c, mc, r, mr, qrSvg = "", rect;
300
+ rect = "l" + cellSize + ",0 0," + cellSize + " -" + cellSize + ",0 0,-" + cellSize + "z ";
301
+ qrSvg += "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"";
302
+ qrSvg += !opts.scalable ? " width=\"" + size + "px\" height=\"" + size + "px\"" : "";
303
+ qrSvg += " viewBox=\"0 0 " + size + " " + size + "\" ";
304
+ qrSvg += " preserveAspectRatio=\"xMinYMin meet\"";
305
+ qrSvg += title.text || alt.text ? " role=\"img\" aria-labelledby=\"" + escapeXml([title.id, alt.id].join(" ").trim()) + "\"" : "";
306
+ qrSvg += ">";
307
+ qrSvg += title.text ? "<title id=\"" + escapeXml(title.id) + "\">" + escapeXml(title.text) + "</title>" : "";
308
+ qrSvg += alt.text ? "<description id=\"" + escapeXml(alt.id) + "\">" + escapeXml(alt.text) + "</description>" : "";
309
+ qrSvg += "<rect width=\"100%\" height=\"100%\" fill=\"white\" cx=\"0\" cy=\"0\"/>";
310
+ qrSvg += "<path d=\"";
311
+ for (r = 0; r < _this.getModuleCount(); r += 1) {
312
+ mr = r * cellSize + margin;
313
+ for (c = 0; c < _this.getModuleCount(); c += 1) if (_this.isDark(r, c)) {
314
+ mc = c * cellSize + margin;
315
+ qrSvg += "M" + mc + "," + mr + rect;
316
+ }
317
+ }
318
+ qrSvg += "\" stroke=\"transparent\" fill=\"black\"/>";
319
+ qrSvg += "</svg>";
320
+ return qrSvg;
321
+ };
322
+ _this.createDataURL = function(cellSize, margin) {
323
+ cellSize = cellSize || 2;
324
+ margin = typeof margin == "undefined" ? cellSize * 4 : margin;
325
+ const size = _this.getModuleCount() * cellSize + margin * 2;
326
+ const min = margin;
327
+ const max = size - margin;
328
+ return createDataURL(size, size, function(x, y) {
329
+ if (min <= x && x < max && min <= y && y < max) {
330
+ const c = Math.floor((x - min) / cellSize);
331
+ const r = Math.floor((y - min) / cellSize);
332
+ return _this.isDark(r, c) ? 0 : 1;
333
+ } else return 1;
334
+ });
335
+ };
336
+ _this.createImgTag = function(cellSize, margin, alt) {
337
+ cellSize = cellSize || 2;
338
+ margin = typeof margin == "undefined" ? cellSize * 4 : margin;
339
+ const size = _this.getModuleCount() * cellSize + margin * 2;
340
+ let img = "";
341
+ img += "<img";
342
+ img += " src=\"";
343
+ img += _this.createDataURL(cellSize, margin);
344
+ img += "\"";
345
+ img += " width=\"";
346
+ img += size;
347
+ img += "\"";
348
+ img += " height=\"";
349
+ img += size;
350
+ img += "\"";
351
+ if (alt) {
352
+ img += " alt=\"";
353
+ img += escapeXml(alt);
354
+ img += "\"";
355
+ }
356
+ img += "/>";
357
+ return img;
358
+ };
359
+ const escapeXml = function(s) {
360
+ let escaped = "";
361
+ for (let i = 0; i < s.length; i += 1) {
362
+ const c = s.charAt(i);
363
+ switch (c) {
364
+ case "<":
365
+ escaped += "&lt;";
366
+ break;
367
+ case ">":
368
+ escaped += "&gt;";
369
+ break;
370
+ case "&":
371
+ escaped += "&amp;";
372
+ break;
373
+ case "\"":
374
+ escaped += "&quot;";
375
+ break;
376
+ default: escaped += c;
377
+ }
378
+ }
379
+ return escaped;
380
+ };
381
+ const _createHalfASCII = function(margin) {
382
+ const cellSize = 1;
383
+ margin = typeof margin == "undefined" ? 2 : margin;
384
+ const size = _this.getModuleCount() * cellSize + margin * 2;
385
+ const min = margin;
386
+ const max = size - margin;
387
+ let y, x, r1, r2, p;
388
+ const blocks = {
389
+ "██": "█",
390
+ "█ ": "▀",
391
+ " █": "▄",
392
+ " ": " "
393
+ };
394
+ const blocksLastLineNoMargin = {
395
+ "██": "▀",
396
+ "█ ": "▀",
397
+ " █": " ",
398
+ " ": " "
399
+ };
400
+ let ascii = "";
401
+ for (y = 0; y < size; y += 2) {
402
+ r1 = Math.floor((y - min) / cellSize);
403
+ r2 = Math.floor((y + 1 - min) / cellSize);
404
+ for (x = 0; x < size; x += 1) {
405
+ p = "█";
406
+ if (min <= x && x < max && min <= y && y < max && _this.isDark(r1, Math.floor((x - min) / cellSize))) p = " ";
407
+ if (min <= x && x < max && min <= y + 1 && y + 1 < max && _this.isDark(r2, Math.floor((x - min) / cellSize))) p += " ";
408
+ else p += "█";
409
+ ascii += margin < 1 && y + 1 >= max ? blocksLastLineNoMargin[p] : blocks[p];
410
+ }
411
+ ascii += "\n";
412
+ }
413
+ if (size % 2 && margin > 0) return ascii.substring(0, ascii.length - size - 1) + Array(size + 1).join("▀");
414
+ return ascii.substring(0, ascii.length - 1);
415
+ };
416
+ _this.createASCII = function(cellSize, margin) {
417
+ cellSize = cellSize || 1;
418
+ if (cellSize < 2) return _createHalfASCII(margin);
419
+ cellSize -= 1;
420
+ margin = typeof margin == "undefined" ? cellSize * 2 : margin;
421
+ const size = _this.getModuleCount() * cellSize + margin * 2;
422
+ const min = margin;
423
+ const max = size - margin;
424
+ let y, x, r, p;
425
+ const white = Array(cellSize + 1).join("██");
426
+ const black = Array(cellSize + 1).join(" ");
427
+ let ascii = "";
428
+ let line = "";
429
+ for (y = 0; y < size; y += 1) {
430
+ r = Math.floor((y - min) / cellSize);
431
+ line = "";
432
+ for (x = 0; x < size; x += 1) {
433
+ p = 1;
434
+ if (min <= x && x < max && min <= y && y < max && _this.isDark(r, Math.floor((x - min) / cellSize))) p = 0;
435
+ line += p ? white : black;
436
+ }
437
+ for (r = 0; r < cellSize; r += 1) ascii += line + "\n";
438
+ }
439
+ return ascii.substring(0, ascii.length - 1);
440
+ };
441
+ _this.renderTo2dContext = function(context, cellSize) {
442
+ cellSize = cellSize || 2;
443
+ const length = _this.getModuleCount();
444
+ for (let row = 0; row < length; row++) for (let col = 0; col < length; col++) {
445
+ context.fillStyle = _this.isDark(row, col) ? "black" : "white";
446
+ context.fillRect(col * cellSize, row * cellSize, cellSize, cellSize);
447
+ }
448
+ };
449
+ return _this;
450
+ };
451
+ qrcode.stringToBytes = function(s) {
452
+ const bytes = [];
453
+ for (let i = 0; i < s.length; i += 1) {
454
+ const c = s.charCodeAt(i);
455
+ bytes.push(c & 255);
456
+ }
457
+ return bytes;
458
+ };
459
+ /**
460
+ * @param unicodeData base64 string of byte array.
461
+ * [16bit Unicode],[16bit Bytes], ...
462
+ * @param numChars
463
+ */
464
+ qrcode.createStringToBytes = function(unicodeData, numChars) {
465
+ const unicodeMap = function() {
466
+ const bin = base64DecodeInputStream(unicodeData);
467
+ const read = function() {
468
+ const b = bin.read();
469
+ if (b == -1) throw "eof";
470
+ return b;
471
+ };
472
+ let count = 0;
473
+ const unicodeMap = {};
474
+ while (true) {
475
+ const b0 = bin.read();
476
+ if (b0 == -1) break;
477
+ const b1 = read();
478
+ const b2 = read();
479
+ const b3 = read();
480
+ const k = String.fromCharCode(b0 << 8 | b1);
481
+ unicodeMap[k] = b2 << 8 | b3;
482
+ count += 1;
483
+ }
484
+ if (count != numChars) throw count + " != " + numChars;
485
+ return unicodeMap;
486
+ }();
487
+ const unknownChar = "?".charCodeAt(0);
488
+ return function(s) {
489
+ const bytes = [];
490
+ for (let i = 0; i < s.length; i += 1) {
491
+ const c = s.charCodeAt(i);
492
+ if (c < 128) bytes.push(c);
493
+ else {
494
+ const b = unicodeMap[s.charAt(i)];
495
+ if (typeof b == "number") {
496
+ if ((b & 255) == b) bytes.push(b);
497
+ else {
498
+ bytes.push(b >>> 8);
499
+ bytes.push(b & 255);
500
+ }
501
+ } else bytes.push(unknownChar);
502
+ }
503
+ }
504
+ return bytes;
505
+ };
506
+ };
507
+ const QRMode = {
508
+ MODE_NUMBER: 1,
509
+ MODE_ALPHA_NUM: 2,
510
+ MODE_8BIT_BYTE: 4,
511
+ MODE_KANJI: 8
512
+ };
513
+ const QRErrorCorrectionLevel = {
514
+ L: 1,
515
+ M: 0,
516
+ Q: 3,
517
+ H: 2
518
+ };
519
+ const QRMaskPattern = {
520
+ PATTERN000: 0,
521
+ PATTERN001: 1,
522
+ PATTERN010: 2,
523
+ PATTERN011: 3,
524
+ PATTERN100: 4,
525
+ PATTERN101: 5,
526
+ PATTERN110: 6,
527
+ PATTERN111: 7
528
+ };
529
+ const QRUtil = function() {
530
+ const PATTERN_POSITION_TABLE = [
531
+ [],
532
+ [6, 18],
533
+ [6, 22],
534
+ [6, 26],
535
+ [6, 30],
536
+ [6, 34],
537
+ [
538
+ 6,
539
+ 22,
540
+ 38
541
+ ],
542
+ [
543
+ 6,
544
+ 24,
545
+ 42
546
+ ],
547
+ [
548
+ 6,
549
+ 26,
550
+ 46
551
+ ],
552
+ [
553
+ 6,
554
+ 28,
555
+ 50
556
+ ],
557
+ [
558
+ 6,
559
+ 30,
560
+ 54
561
+ ],
562
+ [
563
+ 6,
564
+ 32,
565
+ 58
566
+ ],
567
+ [
568
+ 6,
569
+ 34,
570
+ 62
571
+ ],
572
+ [
573
+ 6,
574
+ 26,
575
+ 46,
576
+ 66
577
+ ],
578
+ [
579
+ 6,
580
+ 26,
581
+ 48,
582
+ 70
583
+ ],
584
+ [
585
+ 6,
586
+ 26,
587
+ 50,
588
+ 74
589
+ ],
590
+ [
591
+ 6,
592
+ 30,
593
+ 54,
594
+ 78
595
+ ],
596
+ [
597
+ 6,
598
+ 30,
599
+ 56,
600
+ 82
601
+ ],
602
+ [
603
+ 6,
604
+ 30,
605
+ 58,
606
+ 86
607
+ ],
608
+ [
609
+ 6,
610
+ 34,
611
+ 62,
612
+ 90
613
+ ],
614
+ [
615
+ 6,
616
+ 28,
617
+ 50,
618
+ 72,
619
+ 94
620
+ ],
621
+ [
622
+ 6,
623
+ 26,
624
+ 50,
625
+ 74,
626
+ 98
627
+ ],
628
+ [
629
+ 6,
630
+ 30,
631
+ 54,
632
+ 78,
633
+ 102
634
+ ],
635
+ [
636
+ 6,
637
+ 28,
638
+ 54,
639
+ 80,
640
+ 106
641
+ ],
642
+ [
643
+ 6,
644
+ 32,
645
+ 58,
646
+ 84,
647
+ 110
648
+ ],
649
+ [
650
+ 6,
651
+ 30,
652
+ 58,
653
+ 86,
654
+ 114
655
+ ],
656
+ [
657
+ 6,
658
+ 34,
659
+ 62,
660
+ 90,
661
+ 118
662
+ ],
663
+ [
664
+ 6,
665
+ 26,
666
+ 50,
667
+ 74,
668
+ 98,
669
+ 122
670
+ ],
671
+ [
672
+ 6,
673
+ 30,
674
+ 54,
675
+ 78,
676
+ 102,
677
+ 126
678
+ ],
679
+ [
680
+ 6,
681
+ 26,
682
+ 52,
683
+ 78,
684
+ 104,
685
+ 130
686
+ ],
687
+ [
688
+ 6,
689
+ 30,
690
+ 56,
691
+ 82,
692
+ 108,
693
+ 134
694
+ ],
695
+ [
696
+ 6,
697
+ 34,
698
+ 60,
699
+ 86,
700
+ 112,
701
+ 138
702
+ ],
703
+ [
704
+ 6,
705
+ 30,
706
+ 58,
707
+ 86,
708
+ 114,
709
+ 142
710
+ ],
711
+ [
712
+ 6,
713
+ 34,
714
+ 62,
715
+ 90,
716
+ 118,
717
+ 146
718
+ ],
719
+ [
720
+ 6,
721
+ 30,
722
+ 54,
723
+ 78,
724
+ 102,
725
+ 126,
726
+ 150
727
+ ],
728
+ [
729
+ 6,
730
+ 24,
731
+ 50,
732
+ 76,
733
+ 102,
734
+ 128,
735
+ 154
736
+ ],
737
+ [
738
+ 6,
739
+ 28,
740
+ 54,
741
+ 80,
742
+ 106,
743
+ 132,
744
+ 158
745
+ ],
746
+ [
747
+ 6,
748
+ 32,
749
+ 58,
750
+ 84,
751
+ 110,
752
+ 136,
753
+ 162
754
+ ],
755
+ [
756
+ 6,
757
+ 26,
758
+ 54,
759
+ 82,
760
+ 110,
761
+ 138,
762
+ 166
763
+ ],
764
+ [
765
+ 6,
766
+ 30,
767
+ 58,
768
+ 86,
769
+ 114,
770
+ 142,
771
+ 170
772
+ ]
773
+ ];
774
+ const G15 = 1335;
775
+ const G18 = 7973;
776
+ const G15_MASK = 21522;
777
+ const _this = {};
778
+ const getBCHDigit = function(data) {
779
+ let digit = 0;
780
+ while (data != 0) {
781
+ digit += 1;
782
+ data >>>= 1;
783
+ }
784
+ return digit;
785
+ };
786
+ _this.getBCHTypeInfo = function(data) {
787
+ let d = data << 10;
788
+ while (getBCHDigit(d) - getBCHDigit(G15) >= 0) d ^= G15 << getBCHDigit(d) - getBCHDigit(G15);
789
+ return (data << 10 | d) ^ G15_MASK;
790
+ };
791
+ _this.getBCHTypeNumber = function(data) {
792
+ let d = data << 12;
793
+ while (getBCHDigit(d) - getBCHDigit(G18) >= 0) d ^= G18 << getBCHDigit(d) - getBCHDigit(G18);
794
+ return data << 12 | d;
795
+ };
796
+ _this.getPatternPosition = function(typeNumber) {
797
+ return PATTERN_POSITION_TABLE[typeNumber - 1];
798
+ };
799
+ _this.getMaskFunction = function(maskPattern) {
800
+ switch (maskPattern) {
801
+ case QRMaskPattern.PATTERN000: return function(i, j) {
802
+ return (i + j) % 2 == 0;
803
+ };
804
+ case QRMaskPattern.PATTERN001: return function(i, j) {
805
+ return i % 2 == 0;
806
+ };
807
+ case QRMaskPattern.PATTERN010: return function(i, j) {
808
+ return j % 3 == 0;
809
+ };
810
+ case QRMaskPattern.PATTERN011: return function(i, j) {
811
+ return (i + j) % 3 == 0;
812
+ };
813
+ case QRMaskPattern.PATTERN100: return function(i, j) {
814
+ return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0;
815
+ };
816
+ case QRMaskPattern.PATTERN101: return function(i, j) {
817
+ return i * j % 2 + i * j % 3 == 0;
818
+ };
819
+ case QRMaskPattern.PATTERN110: return function(i, j) {
820
+ return (i * j % 2 + i * j % 3) % 2 == 0;
821
+ };
822
+ case QRMaskPattern.PATTERN111: return function(i, j) {
823
+ return (i * j % 3 + (i + j) % 2) % 2 == 0;
824
+ };
825
+ default: throw "bad maskPattern:" + maskPattern;
826
+ }
827
+ };
828
+ _this.getErrorCorrectPolynomial = function(errorCorrectLength) {
829
+ let a = qrPolynomial([1], 0);
830
+ for (let i = 0; i < errorCorrectLength; i += 1) a = a.multiply(qrPolynomial([1, QRMath.gexp(i)], 0));
831
+ return a;
832
+ };
833
+ _this.getLengthInBits = function(mode, type) {
834
+ if (1 <= type && type < 10) switch (mode) {
835
+ case QRMode.MODE_NUMBER: return 10;
836
+ case QRMode.MODE_ALPHA_NUM: return 9;
837
+ case QRMode.MODE_8BIT_BYTE: return 8;
838
+ case QRMode.MODE_KANJI: return 8;
839
+ default: throw "mode:" + mode;
840
+ }
841
+ else if (type < 27) switch (mode) {
842
+ case QRMode.MODE_NUMBER: return 12;
843
+ case QRMode.MODE_ALPHA_NUM: return 11;
844
+ case QRMode.MODE_8BIT_BYTE: return 16;
845
+ case QRMode.MODE_KANJI: return 10;
846
+ default: throw "mode:" + mode;
847
+ }
848
+ else if (type < 41) switch (mode) {
849
+ case QRMode.MODE_NUMBER: return 14;
850
+ case QRMode.MODE_ALPHA_NUM: return 13;
851
+ case QRMode.MODE_8BIT_BYTE: return 16;
852
+ case QRMode.MODE_KANJI: return 12;
853
+ default: throw "mode:" + mode;
854
+ }
855
+ else throw "type:" + type;
856
+ };
857
+ _this.getLostPoint = function(qrcode) {
858
+ const moduleCount = qrcode.getModuleCount();
859
+ let lostPoint = 0;
860
+ for (let row = 0; row < moduleCount; row += 1) for (let col = 0; col < moduleCount; col += 1) {
861
+ let sameCount = 0;
862
+ const dark = qrcode.isDark(row, col);
863
+ for (let r = -1; r <= 1; r += 1) {
864
+ if (row + r < 0 || moduleCount <= row + r) continue;
865
+ for (let c = -1; c <= 1; c += 1) {
866
+ if (col + c < 0 || moduleCount <= col + c) continue;
867
+ if (r == 0 && c == 0) continue;
868
+ if (dark == qrcode.isDark(row + r, col + c)) sameCount += 1;
869
+ }
870
+ }
871
+ if (sameCount > 5) lostPoint += 3 + sameCount - 5;
872
+ }
873
+ for (let row = 0; row < moduleCount - 1; row += 1) for (let col = 0; col < moduleCount - 1; col += 1) {
874
+ let count = 0;
875
+ if (qrcode.isDark(row, col)) count += 1;
876
+ if (qrcode.isDark(row + 1, col)) count += 1;
877
+ if (qrcode.isDark(row, col + 1)) count += 1;
878
+ if (qrcode.isDark(row + 1, col + 1)) count += 1;
879
+ if (count == 0 || count == 4) lostPoint += 3;
880
+ }
881
+ for (let row = 0; row < moduleCount; row += 1) for (let col = 0; col < moduleCount - 6; col += 1) if (qrcode.isDark(row, col) && !qrcode.isDark(row, col + 1) && qrcode.isDark(row, col + 2) && qrcode.isDark(row, col + 3) && qrcode.isDark(row, col + 4) && !qrcode.isDark(row, col + 5) && qrcode.isDark(row, col + 6)) lostPoint += 40;
882
+ for (let col = 0; col < moduleCount; col += 1) for (let row = 0; row < moduleCount - 6; row += 1) if (qrcode.isDark(row, col) && !qrcode.isDark(row + 1, col) && qrcode.isDark(row + 2, col) && qrcode.isDark(row + 3, col) && qrcode.isDark(row + 4, col) && !qrcode.isDark(row + 5, col) && qrcode.isDark(row + 6, col)) lostPoint += 40;
883
+ let darkCount = 0;
884
+ for (let col = 0; col < moduleCount; col += 1) for (let row = 0; row < moduleCount; row += 1) if (qrcode.isDark(row, col)) darkCount += 1;
885
+ const ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
886
+ lostPoint += ratio * 10;
887
+ return lostPoint;
888
+ };
889
+ return _this;
890
+ }();
891
+ const QRMath = function() {
892
+ const EXP_TABLE = new Array(256);
893
+ const LOG_TABLE = new Array(256);
894
+ for (let i = 0; i < 8; i += 1) EXP_TABLE[i] = 1 << i;
895
+ for (let i = 8; i < 256; i += 1) EXP_TABLE[i] = EXP_TABLE[i - 4] ^ EXP_TABLE[i - 5] ^ EXP_TABLE[i - 6] ^ EXP_TABLE[i - 8];
896
+ for (let i = 0; i < 255; i += 1) LOG_TABLE[EXP_TABLE[i]] = i;
897
+ const _this = {};
898
+ _this.glog = function(n) {
899
+ if (n < 1) throw "glog(" + n + ")";
900
+ return LOG_TABLE[n];
901
+ };
902
+ _this.gexp = function(n) {
903
+ while (n < 0) n += 255;
904
+ while (n >= 256) n -= 255;
905
+ return EXP_TABLE[n];
906
+ };
907
+ return _this;
908
+ }();
909
+ const qrPolynomial = function(num, shift) {
910
+ if (typeof num.length == "undefined") throw num.length + "/" + shift;
911
+ const _num = function() {
912
+ let offset = 0;
913
+ while (offset < num.length && num[offset] == 0) offset += 1;
914
+ const _num = new Array(num.length - offset + shift);
915
+ for (let i = 0; i < num.length - offset; i += 1) _num[i] = num[i + offset];
916
+ return _num;
917
+ }();
918
+ const _this = {};
919
+ _this.getAt = function(index) {
920
+ return _num[index];
921
+ };
922
+ _this.getLength = function() {
923
+ return _num.length;
924
+ };
925
+ _this.multiply = function(e) {
926
+ const num = new Array(_this.getLength() + e.getLength() - 1);
927
+ for (let i = 0; i < _this.getLength(); i += 1) for (let j = 0; j < e.getLength(); j += 1) num[i + j] ^= QRMath.gexp(QRMath.glog(_this.getAt(i)) + QRMath.glog(e.getAt(j)));
928
+ return qrPolynomial(num, 0);
929
+ };
930
+ _this.mod = function(e) {
931
+ if (_this.getLength() - e.getLength() < 0) return _this;
932
+ const ratio = QRMath.glog(_this.getAt(0)) - QRMath.glog(e.getAt(0));
933
+ const num = new Array(_this.getLength());
934
+ for (let i = 0; i < _this.getLength(); i += 1) num[i] = _this.getAt(i);
935
+ for (let i = 0; i < e.getLength(); i += 1) num[i] ^= QRMath.gexp(QRMath.glog(e.getAt(i)) + ratio);
936
+ return qrPolynomial(num, 0).mod(e);
937
+ };
938
+ return _this;
939
+ };
940
+ const QRRSBlock = function() {
941
+ const RS_BLOCK_TABLE = [
942
+ [
943
+ 1,
944
+ 26,
945
+ 19
946
+ ],
947
+ [
948
+ 1,
949
+ 26,
950
+ 16
951
+ ],
952
+ [
953
+ 1,
954
+ 26,
955
+ 13
956
+ ],
957
+ [
958
+ 1,
959
+ 26,
960
+ 9
961
+ ],
962
+ [
963
+ 1,
964
+ 44,
965
+ 34
966
+ ],
967
+ [
968
+ 1,
969
+ 44,
970
+ 28
971
+ ],
972
+ [
973
+ 1,
974
+ 44,
975
+ 22
976
+ ],
977
+ [
978
+ 1,
979
+ 44,
980
+ 16
981
+ ],
982
+ [
983
+ 1,
984
+ 70,
985
+ 55
986
+ ],
987
+ [
988
+ 1,
989
+ 70,
990
+ 44
991
+ ],
992
+ [
993
+ 2,
994
+ 35,
995
+ 17
996
+ ],
997
+ [
998
+ 2,
999
+ 35,
1000
+ 13
1001
+ ],
1002
+ [
1003
+ 1,
1004
+ 100,
1005
+ 80
1006
+ ],
1007
+ [
1008
+ 2,
1009
+ 50,
1010
+ 32
1011
+ ],
1012
+ [
1013
+ 2,
1014
+ 50,
1015
+ 24
1016
+ ],
1017
+ [
1018
+ 4,
1019
+ 25,
1020
+ 9
1021
+ ],
1022
+ [
1023
+ 1,
1024
+ 134,
1025
+ 108
1026
+ ],
1027
+ [
1028
+ 2,
1029
+ 67,
1030
+ 43
1031
+ ],
1032
+ [
1033
+ 2,
1034
+ 33,
1035
+ 15,
1036
+ 2,
1037
+ 34,
1038
+ 16
1039
+ ],
1040
+ [
1041
+ 2,
1042
+ 33,
1043
+ 11,
1044
+ 2,
1045
+ 34,
1046
+ 12
1047
+ ],
1048
+ [
1049
+ 2,
1050
+ 86,
1051
+ 68
1052
+ ],
1053
+ [
1054
+ 4,
1055
+ 43,
1056
+ 27
1057
+ ],
1058
+ [
1059
+ 4,
1060
+ 43,
1061
+ 19
1062
+ ],
1063
+ [
1064
+ 4,
1065
+ 43,
1066
+ 15
1067
+ ],
1068
+ [
1069
+ 2,
1070
+ 98,
1071
+ 78
1072
+ ],
1073
+ [
1074
+ 4,
1075
+ 49,
1076
+ 31
1077
+ ],
1078
+ [
1079
+ 2,
1080
+ 32,
1081
+ 14,
1082
+ 4,
1083
+ 33,
1084
+ 15
1085
+ ],
1086
+ [
1087
+ 4,
1088
+ 39,
1089
+ 13,
1090
+ 1,
1091
+ 40,
1092
+ 14
1093
+ ],
1094
+ [
1095
+ 2,
1096
+ 121,
1097
+ 97
1098
+ ],
1099
+ [
1100
+ 2,
1101
+ 60,
1102
+ 38,
1103
+ 2,
1104
+ 61,
1105
+ 39
1106
+ ],
1107
+ [
1108
+ 4,
1109
+ 40,
1110
+ 18,
1111
+ 2,
1112
+ 41,
1113
+ 19
1114
+ ],
1115
+ [
1116
+ 4,
1117
+ 40,
1118
+ 14,
1119
+ 2,
1120
+ 41,
1121
+ 15
1122
+ ],
1123
+ [
1124
+ 2,
1125
+ 146,
1126
+ 116
1127
+ ],
1128
+ [
1129
+ 3,
1130
+ 58,
1131
+ 36,
1132
+ 2,
1133
+ 59,
1134
+ 37
1135
+ ],
1136
+ [
1137
+ 4,
1138
+ 36,
1139
+ 16,
1140
+ 4,
1141
+ 37,
1142
+ 17
1143
+ ],
1144
+ [
1145
+ 4,
1146
+ 36,
1147
+ 12,
1148
+ 4,
1149
+ 37,
1150
+ 13
1151
+ ],
1152
+ [
1153
+ 2,
1154
+ 86,
1155
+ 68,
1156
+ 2,
1157
+ 87,
1158
+ 69
1159
+ ],
1160
+ [
1161
+ 4,
1162
+ 69,
1163
+ 43,
1164
+ 1,
1165
+ 70,
1166
+ 44
1167
+ ],
1168
+ [
1169
+ 6,
1170
+ 43,
1171
+ 19,
1172
+ 2,
1173
+ 44,
1174
+ 20
1175
+ ],
1176
+ [
1177
+ 6,
1178
+ 43,
1179
+ 15,
1180
+ 2,
1181
+ 44,
1182
+ 16
1183
+ ],
1184
+ [
1185
+ 4,
1186
+ 101,
1187
+ 81
1188
+ ],
1189
+ [
1190
+ 1,
1191
+ 80,
1192
+ 50,
1193
+ 4,
1194
+ 81,
1195
+ 51
1196
+ ],
1197
+ [
1198
+ 4,
1199
+ 50,
1200
+ 22,
1201
+ 4,
1202
+ 51,
1203
+ 23
1204
+ ],
1205
+ [
1206
+ 3,
1207
+ 36,
1208
+ 12,
1209
+ 8,
1210
+ 37,
1211
+ 13
1212
+ ],
1213
+ [
1214
+ 2,
1215
+ 116,
1216
+ 92,
1217
+ 2,
1218
+ 117,
1219
+ 93
1220
+ ],
1221
+ [
1222
+ 6,
1223
+ 58,
1224
+ 36,
1225
+ 2,
1226
+ 59,
1227
+ 37
1228
+ ],
1229
+ [
1230
+ 4,
1231
+ 46,
1232
+ 20,
1233
+ 6,
1234
+ 47,
1235
+ 21
1236
+ ],
1237
+ [
1238
+ 7,
1239
+ 42,
1240
+ 14,
1241
+ 4,
1242
+ 43,
1243
+ 15
1244
+ ],
1245
+ [
1246
+ 4,
1247
+ 133,
1248
+ 107
1249
+ ],
1250
+ [
1251
+ 8,
1252
+ 59,
1253
+ 37,
1254
+ 1,
1255
+ 60,
1256
+ 38
1257
+ ],
1258
+ [
1259
+ 8,
1260
+ 44,
1261
+ 20,
1262
+ 4,
1263
+ 45,
1264
+ 21
1265
+ ],
1266
+ [
1267
+ 12,
1268
+ 33,
1269
+ 11,
1270
+ 4,
1271
+ 34,
1272
+ 12
1273
+ ],
1274
+ [
1275
+ 3,
1276
+ 145,
1277
+ 115,
1278
+ 1,
1279
+ 146,
1280
+ 116
1281
+ ],
1282
+ [
1283
+ 4,
1284
+ 64,
1285
+ 40,
1286
+ 5,
1287
+ 65,
1288
+ 41
1289
+ ],
1290
+ [
1291
+ 11,
1292
+ 36,
1293
+ 16,
1294
+ 5,
1295
+ 37,
1296
+ 17
1297
+ ],
1298
+ [
1299
+ 11,
1300
+ 36,
1301
+ 12,
1302
+ 5,
1303
+ 37,
1304
+ 13
1305
+ ],
1306
+ [
1307
+ 5,
1308
+ 109,
1309
+ 87,
1310
+ 1,
1311
+ 110,
1312
+ 88
1313
+ ],
1314
+ [
1315
+ 5,
1316
+ 65,
1317
+ 41,
1318
+ 5,
1319
+ 66,
1320
+ 42
1321
+ ],
1322
+ [
1323
+ 5,
1324
+ 54,
1325
+ 24,
1326
+ 7,
1327
+ 55,
1328
+ 25
1329
+ ],
1330
+ [
1331
+ 11,
1332
+ 36,
1333
+ 12,
1334
+ 7,
1335
+ 37,
1336
+ 13
1337
+ ],
1338
+ [
1339
+ 5,
1340
+ 122,
1341
+ 98,
1342
+ 1,
1343
+ 123,
1344
+ 99
1345
+ ],
1346
+ [
1347
+ 7,
1348
+ 73,
1349
+ 45,
1350
+ 3,
1351
+ 74,
1352
+ 46
1353
+ ],
1354
+ [
1355
+ 15,
1356
+ 43,
1357
+ 19,
1358
+ 2,
1359
+ 44,
1360
+ 20
1361
+ ],
1362
+ [
1363
+ 3,
1364
+ 45,
1365
+ 15,
1366
+ 13,
1367
+ 46,
1368
+ 16
1369
+ ],
1370
+ [
1371
+ 1,
1372
+ 135,
1373
+ 107,
1374
+ 5,
1375
+ 136,
1376
+ 108
1377
+ ],
1378
+ [
1379
+ 10,
1380
+ 74,
1381
+ 46,
1382
+ 1,
1383
+ 75,
1384
+ 47
1385
+ ],
1386
+ [
1387
+ 1,
1388
+ 50,
1389
+ 22,
1390
+ 15,
1391
+ 51,
1392
+ 23
1393
+ ],
1394
+ [
1395
+ 2,
1396
+ 42,
1397
+ 14,
1398
+ 17,
1399
+ 43,
1400
+ 15
1401
+ ],
1402
+ [
1403
+ 5,
1404
+ 150,
1405
+ 120,
1406
+ 1,
1407
+ 151,
1408
+ 121
1409
+ ],
1410
+ [
1411
+ 9,
1412
+ 69,
1413
+ 43,
1414
+ 4,
1415
+ 70,
1416
+ 44
1417
+ ],
1418
+ [
1419
+ 17,
1420
+ 50,
1421
+ 22,
1422
+ 1,
1423
+ 51,
1424
+ 23
1425
+ ],
1426
+ [
1427
+ 2,
1428
+ 42,
1429
+ 14,
1430
+ 19,
1431
+ 43,
1432
+ 15
1433
+ ],
1434
+ [
1435
+ 3,
1436
+ 141,
1437
+ 113,
1438
+ 4,
1439
+ 142,
1440
+ 114
1441
+ ],
1442
+ [
1443
+ 3,
1444
+ 70,
1445
+ 44,
1446
+ 11,
1447
+ 71,
1448
+ 45
1449
+ ],
1450
+ [
1451
+ 17,
1452
+ 47,
1453
+ 21,
1454
+ 4,
1455
+ 48,
1456
+ 22
1457
+ ],
1458
+ [
1459
+ 9,
1460
+ 39,
1461
+ 13,
1462
+ 16,
1463
+ 40,
1464
+ 14
1465
+ ],
1466
+ [
1467
+ 3,
1468
+ 135,
1469
+ 107,
1470
+ 5,
1471
+ 136,
1472
+ 108
1473
+ ],
1474
+ [
1475
+ 3,
1476
+ 67,
1477
+ 41,
1478
+ 13,
1479
+ 68,
1480
+ 42
1481
+ ],
1482
+ [
1483
+ 15,
1484
+ 54,
1485
+ 24,
1486
+ 5,
1487
+ 55,
1488
+ 25
1489
+ ],
1490
+ [
1491
+ 15,
1492
+ 43,
1493
+ 15,
1494
+ 10,
1495
+ 44,
1496
+ 16
1497
+ ],
1498
+ [
1499
+ 4,
1500
+ 144,
1501
+ 116,
1502
+ 4,
1503
+ 145,
1504
+ 117
1505
+ ],
1506
+ [
1507
+ 17,
1508
+ 68,
1509
+ 42
1510
+ ],
1511
+ [
1512
+ 17,
1513
+ 50,
1514
+ 22,
1515
+ 6,
1516
+ 51,
1517
+ 23
1518
+ ],
1519
+ [
1520
+ 19,
1521
+ 46,
1522
+ 16,
1523
+ 6,
1524
+ 47,
1525
+ 17
1526
+ ],
1527
+ [
1528
+ 2,
1529
+ 139,
1530
+ 111,
1531
+ 7,
1532
+ 140,
1533
+ 112
1534
+ ],
1535
+ [
1536
+ 17,
1537
+ 74,
1538
+ 46
1539
+ ],
1540
+ [
1541
+ 7,
1542
+ 54,
1543
+ 24,
1544
+ 16,
1545
+ 55,
1546
+ 25
1547
+ ],
1548
+ [
1549
+ 34,
1550
+ 37,
1551
+ 13
1552
+ ],
1553
+ [
1554
+ 4,
1555
+ 151,
1556
+ 121,
1557
+ 5,
1558
+ 152,
1559
+ 122
1560
+ ],
1561
+ [
1562
+ 4,
1563
+ 75,
1564
+ 47,
1565
+ 14,
1566
+ 76,
1567
+ 48
1568
+ ],
1569
+ [
1570
+ 11,
1571
+ 54,
1572
+ 24,
1573
+ 14,
1574
+ 55,
1575
+ 25
1576
+ ],
1577
+ [
1578
+ 16,
1579
+ 45,
1580
+ 15,
1581
+ 14,
1582
+ 46,
1583
+ 16
1584
+ ],
1585
+ [
1586
+ 6,
1587
+ 147,
1588
+ 117,
1589
+ 4,
1590
+ 148,
1591
+ 118
1592
+ ],
1593
+ [
1594
+ 6,
1595
+ 73,
1596
+ 45,
1597
+ 14,
1598
+ 74,
1599
+ 46
1600
+ ],
1601
+ [
1602
+ 11,
1603
+ 54,
1604
+ 24,
1605
+ 16,
1606
+ 55,
1607
+ 25
1608
+ ],
1609
+ [
1610
+ 30,
1611
+ 46,
1612
+ 16,
1613
+ 2,
1614
+ 47,
1615
+ 17
1616
+ ],
1617
+ [
1618
+ 8,
1619
+ 132,
1620
+ 106,
1621
+ 4,
1622
+ 133,
1623
+ 107
1624
+ ],
1625
+ [
1626
+ 8,
1627
+ 75,
1628
+ 47,
1629
+ 13,
1630
+ 76,
1631
+ 48
1632
+ ],
1633
+ [
1634
+ 7,
1635
+ 54,
1636
+ 24,
1637
+ 22,
1638
+ 55,
1639
+ 25
1640
+ ],
1641
+ [
1642
+ 22,
1643
+ 45,
1644
+ 15,
1645
+ 13,
1646
+ 46,
1647
+ 16
1648
+ ],
1649
+ [
1650
+ 10,
1651
+ 142,
1652
+ 114,
1653
+ 2,
1654
+ 143,
1655
+ 115
1656
+ ],
1657
+ [
1658
+ 19,
1659
+ 74,
1660
+ 46,
1661
+ 4,
1662
+ 75,
1663
+ 47
1664
+ ],
1665
+ [
1666
+ 28,
1667
+ 50,
1668
+ 22,
1669
+ 6,
1670
+ 51,
1671
+ 23
1672
+ ],
1673
+ [
1674
+ 33,
1675
+ 46,
1676
+ 16,
1677
+ 4,
1678
+ 47,
1679
+ 17
1680
+ ],
1681
+ [
1682
+ 8,
1683
+ 152,
1684
+ 122,
1685
+ 4,
1686
+ 153,
1687
+ 123
1688
+ ],
1689
+ [
1690
+ 22,
1691
+ 73,
1692
+ 45,
1693
+ 3,
1694
+ 74,
1695
+ 46
1696
+ ],
1697
+ [
1698
+ 8,
1699
+ 53,
1700
+ 23,
1701
+ 26,
1702
+ 54,
1703
+ 24
1704
+ ],
1705
+ [
1706
+ 12,
1707
+ 45,
1708
+ 15,
1709
+ 28,
1710
+ 46,
1711
+ 16
1712
+ ],
1713
+ [
1714
+ 3,
1715
+ 147,
1716
+ 117,
1717
+ 10,
1718
+ 148,
1719
+ 118
1720
+ ],
1721
+ [
1722
+ 3,
1723
+ 73,
1724
+ 45,
1725
+ 23,
1726
+ 74,
1727
+ 46
1728
+ ],
1729
+ [
1730
+ 4,
1731
+ 54,
1732
+ 24,
1733
+ 31,
1734
+ 55,
1735
+ 25
1736
+ ],
1737
+ [
1738
+ 11,
1739
+ 45,
1740
+ 15,
1741
+ 31,
1742
+ 46,
1743
+ 16
1744
+ ],
1745
+ [
1746
+ 7,
1747
+ 146,
1748
+ 116,
1749
+ 7,
1750
+ 147,
1751
+ 117
1752
+ ],
1753
+ [
1754
+ 21,
1755
+ 73,
1756
+ 45,
1757
+ 7,
1758
+ 74,
1759
+ 46
1760
+ ],
1761
+ [
1762
+ 1,
1763
+ 53,
1764
+ 23,
1765
+ 37,
1766
+ 54,
1767
+ 24
1768
+ ],
1769
+ [
1770
+ 19,
1771
+ 45,
1772
+ 15,
1773
+ 26,
1774
+ 46,
1775
+ 16
1776
+ ],
1777
+ [
1778
+ 5,
1779
+ 145,
1780
+ 115,
1781
+ 10,
1782
+ 146,
1783
+ 116
1784
+ ],
1785
+ [
1786
+ 19,
1787
+ 75,
1788
+ 47,
1789
+ 10,
1790
+ 76,
1791
+ 48
1792
+ ],
1793
+ [
1794
+ 15,
1795
+ 54,
1796
+ 24,
1797
+ 25,
1798
+ 55,
1799
+ 25
1800
+ ],
1801
+ [
1802
+ 23,
1803
+ 45,
1804
+ 15,
1805
+ 25,
1806
+ 46,
1807
+ 16
1808
+ ],
1809
+ [
1810
+ 13,
1811
+ 145,
1812
+ 115,
1813
+ 3,
1814
+ 146,
1815
+ 116
1816
+ ],
1817
+ [
1818
+ 2,
1819
+ 74,
1820
+ 46,
1821
+ 29,
1822
+ 75,
1823
+ 47
1824
+ ],
1825
+ [
1826
+ 42,
1827
+ 54,
1828
+ 24,
1829
+ 1,
1830
+ 55,
1831
+ 25
1832
+ ],
1833
+ [
1834
+ 23,
1835
+ 45,
1836
+ 15,
1837
+ 28,
1838
+ 46,
1839
+ 16
1840
+ ],
1841
+ [
1842
+ 17,
1843
+ 145,
1844
+ 115
1845
+ ],
1846
+ [
1847
+ 10,
1848
+ 74,
1849
+ 46,
1850
+ 23,
1851
+ 75,
1852
+ 47
1853
+ ],
1854
+ [
1855
+ 10,
1856
+ 54,
1857
+ 24,
1858
+ 35,
1859
+ 55,
1860
+ 25
1861
+ ],
1862
+ [
1863
+ 19,
1864
+ 45,
1865
+ 15,
1866
+ 35,
1867
+ 46,
1868
+ 16
1869
+ ],
1870
+ [
1871
+ 17,
1872
+ 145,
1873
+ 115,
1874
+ 1,
1875
+ 146,
1876
+ 116
1877
+ ],
1878
+ [
1879
+ 14,
1880
+ 74,
1881
+ 46,
1882
+ 21,
1883
+ 75,
1884
+ 47
1885
+ ],
1886
+ [
1887
+ 29,
1888
+ 54,
1889
+ 24,
1890
+ 19,
1891
+ 55,
1892
+ 25
1893
+ ],
1894
+ [
1895
+ 11,
1896
+ 45,
1897
+ 15,
1898
+ 46,
1899
+ 46,
1900
+ 16
1901
+ ],
1902
+ [
1903
+ 13,
1904
+ 145,
1905
+ 115,
1906
+ 6,
1907
+ 146,
1908
+ 116
1909
+ ],
1910
+ [
1911
+ 14,
1912
+ 74,
1913
+ 46,
1914
+ 23,
1915
+ 75,
1916
+ 47
1917
+ ],
1918
+ [
1919
+ 44,
1920
+ 54,
1921
+ 24,
1922
+ 7,
1923
+ 55,
1924
+ 25
1925
+ ],
1926
+ [
1927
+ 59,
1928
+ 46,
1929
+ 16,
1930
+ 1,
1931
+ 47,
1932
+ 17
1933
+ ],
1934
+ [
1935
+ 12,
1936
+ 151,
1937
+ 121,
1938
+ 7,
1939
+ 152,
1940
+ 122
1941
+ ],
1942
+ [
1943
+ 12,
1944
+ 75,
1945
+ 47,
1946
+ 26,
1947
+ 76,
1948
+ 48
1949
+ ],
1950
+ [
1951
+ 39,
1952
+ 54,
1953
+ 24,
1954
+ 14,
1955
+ 55,
1956
+ 25
1957
+ ],
1958
+ [
1959
+ 22,
1960
+ 45,
1961
+ 15,
1962
+ 41,
1963
+ 46,
1964
+ 16
1965
+ ],
1966
+ [
1967
+ 6,
1968
+ 151,
1969
+ 121,
1970
+ 14,
1971
+ 152,
1972
+ 122
1973
+ ],
1974
+ [
1975
+ 6,
1976
+ 75,
1977
+ 47,
1978
+ 34,
1979
+ 76,
1980
+ 48
1981
+ ],
1982
+ [
1983
+ 46,
1984
+ 54,
1985
+ 24,
1986
+ 10,
1987
+ 55,
1988
+ 25
1989
+ ],
1990
+ [
1991
+ 2,
1992
+ 45,
1993
+ 15,
1994
+ 64,
1995
+ 46,
1996
+ 16
1997
+ ],
1998
+ [
1999
+ 17,
2000
+ 152,
2001
+ 122,
2002
+ 4,
2003
+ 153,
2004
+ 123
2005
+ ],
2006
+ [
2007
+ 29,
2008
+ 74,
2009
+ 46,
2010
+ 14,
2011
+ 75,
2012
+ 47
2013
+ ],
2014
+ [
2015
+ 49,
2016
+ 54,
2017
+ 24,
2018
+ 10,
2019
+ 55,
2020
+ 25
2021
+ ],
2022
+ [
2023
+ 24,
2024
+ 45,
2025
+ 15,
2026
+ 46,
2027
+ 46,
2028
+ 16
2029
+ ],
2030
+ [
2031
+ 4,
2032
+ 152,
2033
+ 122,
2034
+ 18,
2035
+ 153,
2036
+ 123
2037
+ ],
2038
+ [
2039
+ 13,
2040
+ 74,
2041
+ 46,
2042
+ 32,
2043
+ 75,
2044
+ 47
2045
+ ],
2046
+ [
2047
+ 48,
2048
+ 54,
2049
+ 24,
2050
+ 14,
2051
+ 55,
2052
+ 25
2053
+ ],
2054
+ [
2055
+ 42,
2056
+ 45,
2057
+ 15,
2058
+ 32,
2059
+ 46,
2060
+ 16
2061
+ ],
2062
+ [
2063
+ 20,
2064
+ 147,
2065
+ 117,
2066
+ 4,
2067
+ 148,
2068
+ 118
2069
+ ],
2070
+ [
2071
+ 40,
2072
+ 75,
2073
+ 47,
2074
+ 7,
2075
+ 76,
2076
+ 48
2077
+ ],
2078
+ [
2079
+ 43,
2080
+ 54,
2081
+ 24,
2082
+ 22,
2083
+ 55,
2084
+ 25
2085
+ ],
2086
+ [
2087
+ 10,
2088
+ 45,
2089
+ 15,
2090
+ 67,
2091
+ 46,
2092
+ 16
2093
+ ],
2094
+ [
2095
+ 19,
2096
+ 148,
2097
+ 118,
2098
+ 6,
2099
+ 149,
2100
+ 119
2101
+ ],
2102
+ [
2103
+ 18,
2104
+ 75,
2105
+ 47,
2106
+ 31,
2107
+ 76,
2108
+ 48
2109
+ ],
2110
+ [
2111
+ 34,
2112
+ 54,
2113
+ 24,
2114
+ 34,
2115
+ 55,
2116
+ 25
2117
+ ],
2118
+ [
2119
+ 20,
2120
+ 45,
2121
+ 15,
2122
+ 61,
2123
+ 46,
2124
+ 16
2125
+ ]
2126
+ ];
2127
+ const qrRSBlock = function(totalCount, dataCount) {
2128
+ const _this = {};
2129
+ _this.totalCount = totalCount;
2130
+ _this.dataCount = dataCount;
2131
+ return _this;
2132
+ };
2133
+ const _this = {};
2134
+ const getRsBlockTable = function(typeNumber, errorCorrectionLevel) {
2135
+ switch (errorCorrectionLevel) {
2136
+ case QRErrorCorrectionLevel.L: return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
2137
+ case QRErrorCorrectionLevel.M: return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
2138
+ case QRErrorCorrectionLevel.Q: return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
2139
+ case QRErrorCorrectionLevel.H: return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
2140
+ default: return;
2141
+ }
2142
+ };
2143
+ _this.getRSBlocks = function(typeNumber, errorCorrectionLevel) {
2144
+ const rsBlock = getRsBlockTable(typeNumber, errorCorrectionLevel);
2145
+ if (typeof rsBlock == "undefined") throw "bad rs block @ typeNumber:" + typeNumber + "/errorCorrectionLevel:" + errorCorrectionLevel;
2146
+ const length = rsBlock.length / 3;
2147
+ const list = [];
2148
+ for (let i = 0; i < length; i += 1) {
2149
+ const count = rsBlock[i * 3 + 0];
2150
+ const totalCount = rsBlock[i * 3 + 1];
2151
+ const dataCount = rsBlock[i * 3 + 2];
2152
+ for (let j = 0; j < count; j += 1) list.push(qrRSBlock(totalCount, dataCount));
2153
+ }
2154
+ return list;
2155
+ };
2156
+ return _this;
2157
+ }();
2158
+ const qrBitBuffer = function() {
2159
+ const _buffer = [];
2160
+ let _length = 0;
2161
+ const _this = {};
2162
+ _this.getBuffer = function() {
2163
+ return _buffer;
2164
+ };
2165
+ _this.getAt = function(index) {
2166
+ const bufIndex = Math.floor(index / 8);
2167
+ return (_buffer[bufIndex] >>> 7 - index % 8 & 1) == 1;
2168
+ };
2169
+ _this.put = function(num, length) {
2170
+ for (let i = 0; i < length; i += 1) _this.putBit((num >>> length - i - 1 & 1) == 1);
2171
+ };
2172
+ _this.getLengthInBits = function() {
2173
+ return _length;
2174
+ };
2175
+ _this.putBit = function(bit) {
2176
+ const bufIndex = Math.floor(_length / 8);
2177
+ if (_buffer.length <= bufIndex) _buffer.push(0);
2178
+ if (bit) _buffer[bufIndex] |= 128 >>> _length % 8;
2179
+ _length += 1;
2180
+ };
2181
+ return _this;
2182
+ };
2183
+ const qrNumber = function(data) {
2184
+ const _mode = QRMode.MODE_NUMBER;
2185
+ const _data = data;
2186
+ const _this = {};
2187
+ _this.getMode = function() {
2188
+ return _mode;
2189
+ };
2190
+ _this.getLength = function(buffer) {
2191
+ return _data.length;
2192
+ };
2193
+ _this.write = function(buffer) {
2194
+ const data = _data;
2195
+ let i = 0;
2196
+ while (i + 2 < data.length) {
2197
+ buffer.put(strToNum(data.substring(i, i + 3)), 10);
2198
+ i += 3;
2199
+ }
2200
+ if (i < data.length) {
2201
+ if (data.length - i == 1) buffer.put(strToNum(data.substring(i, i + 1)), 4);
2202
+ else if (data.length - i == 2) buffer.put(strToNum(data.substring(i, i + 2)), 7);
2203
+ }
2204
+ };
2205
+ const strToNum = function(s) {
2206
+ let num = 0;
2207
+ for (let i = 0; i < s.length; i += 1) num = num * 10 + chatToNum(s.charAt(i));
2208
+ return num;
2209
+ };
2210
+ const chatToNum = function(c) {
2211
+ if ("0" <= c && c <= "9") return c.charCodeAt(0) - "0".charCodeAt(0);
2212
+ throw "illegal char :" + c;
2213
+ };
2214
+ return _this;
2215
+ };
2216
+ const qrAlphaNum = function(data) {
2217
+ const _mode = QRMode.MODE_ALPHA_NUM;
2218
+ const _data = data;
2219
+ const _this = {};
2220
+ _this.getMode = function() {
2221
+ return _mode;
2222
+ };
2223
+ _this.getLength = function(buffer) {
2224
+ return _data.length;
2225
+ };
2226
+ _this.write = function(buffer) {
2227
+ const s = _data;
2228
+ let i = 0;
2229
+ while (i + 1 < s.length) {
2230
+ buffer.put(getCode(s.charAt(i)) * 45 + getCode(s.charAt(i + 1)), 11);
2231
+ i += 2;
2232
+ }
2233
+ if (i < s.length) buffer.put(getCode(s.charAt(i)), 6);
2234
+ };
2235
+ const getCode = function(c) {
2236
+ if ("0" <= c && c <= "9") return c.charCodeAt(0) - "0".charCodeAt(0);
2237
+ else if ("A" <= c && c <= "Z") return c.charCodeAt(0) - "A".charCodeAt(0) + 10;
2238
+ else switch (c) {
2239
+ case " ": return 36;
2240
+ case "$": return 37;
2241
+ case "%": return 38;
2242
+ case "*": return 39;
2243
+ case "+": return 40;
2244
+ case "-": return 41;
2245
+ case ".": return 42;
2246
+ case "/": return 43;
2247
+ case ":": return 44;
2248
+ default: throw "illegal char :" + c;
2249
+ }
2250
+ };
2251
+ return _this;
2252
+ };
2253
+ const qr8BitByte = function(data) {
2254
+ const _mode = QRMode.MODE_8BIT_BYTE;
2255
+ const _bytes = qrcode.stringToBytes(data);
2256
+ const _this = {};
2257
+ _this.getMode = function() {
2258
+ return _mode;
2259
+ };
2260
+ _this.getLength = function(buffer) {
2261
+ return _bytes.length;
2262
+ };
2263
+ _this.write = function(buffer) {
2264
+ for (let i = 0; i < _bytes.length; i += 1) buffer.put(_bytes[i], 8);
2265
+ };
2266
+ return _this;
2267
+ };
2268
+ const qrKanji = function(data) {
2269
+ const _mode = QRMode.MODE_KANJI;
2270
+ const stringToBytes = qrcode.stringToBytes;
2271
+ (function(c, code) {
2272
+ const test = stringToBytes(c);
2273
+ if (test.length != 2 || (test[0] << 8 | test[1]) != code) throw "sjis not supported.";
2274
+ })("友", 38726);
2275
+ const _bytes = stringToBytes(data);
2276
+ const _this = {};
2277
+ _this.getMode = function() {
2278
+ return _mode;
2279
+ };
2280
+ _this.getLength = function(buffer) {
2281
+ return ~~(_bytes.length / 2);
2282
+ };
2283
+ _this.write = function(buffer) {
2284
+ const data = _bytes;
2285
+ let i = 0;
2286
+ while (i + 1 < data.length) {
2287
+ let c = (255 & data[i]) << 8 | 255 & data[i + 1];
2288
+ if (33088 <= c && c <= 40956) c -= 33088;
2289
+ else if (57408 <= c && c <= 60351) c -= 49472;
2290
+ else throw "illegal char at " + (i + 1) + "/" + c;
2291
+ c = (c >>> 8 & 255) * 192 + (c & 255);
2292
+ buffer.put(c, 13);
2293
+ i += 2;
2294
+ }
2295
+ if (i < data.length) throw "illegal char at " + (i + 1);
2296
+ };
2297
+ return _this;
2298
+ };
2299
+ const byteArrayOutputStream = function() {
2300
+ const _bytes = [];
2301
+ const _this = {};
2302
+ _this.writeByte = function(b) {
2303
+ _bytes.push(b & 255);
2304
+ };
2305
+ _this.writeShort = function(i) {
2306
+ _this.writeByte(i);
2307
+ _this.writeByte(i >>> 8);
2308
+ };
2309
+ _this.writeBytes = function(b, off, len) {
2310
+ off = off || 0;
2311
+ len = len || b.length;
2312
+ for (let i = 0; i < len; i += 1) _this.writeByte(b[i + off]);
2313
+ };
2314
+ _this.writeString = function(s) {
2315
+ for (let i = 0; i < s.length; i += 1) _this.writeByte(s.charCodeAt(i));
2316
+ };
2317
+ _this.toByteArray = function() {
2318
+ return _bytes;
2319
+ };
2320
+ _this.toString = function() {
2321
+ let s = "";
2322
+ s += "[";
2323
+ for (let i = 0; i < _bytes.length; i += 1) {
2324
+ if (i > 0) s += ",";
2325
+ s += _bytes[i];
2326
+ }
2327
+ s += "]";
2328
+ return s;
2329
+ };
2330
+ return _this;
2331
+ };
2332
+ const base64EncodeOutputStream = function() {
2333
+ let _buffer = 0;
2334
+ let _buflen = 0;
2335
+ let _length = 0;
2336
+ let _base64 = "";
2337
+ const _this = {};
2338
+ const writeEncoded = function(b) {
2339
+ _base64 += String.fromCharCode(encode(b & 63));
2340
+ };
2341
+ const encode = function(n) {
2342
+ if (n < 0) throw "n:" + n;
2343
+ else if (n < 26) return 65 + n;
2344
+ else if (n < 52) return 97 + (n - 26);
2345
+ else if (n < 62) return 48 + (n - 52);
2346
+ else if (n == 62) return 43;
2347
+ else if (n == 63) return 47;
2348
+ else throw "n:" + n;
2349
+ };
2350
+ _this.writeByte = function(n) {
2351
+ _buffer = _buffer << 8 | n & 255;
2352
+ _buflen += 8;
2353
+ _length += 1;
2354
+ while (_buflen >= 6) {
2355
+ writeEncoded(_buffer >>> _buflen - 6);
2356
+ _buflen -= 6;
2357
+ }
2358
+ };
2359
+ _this.flush = function() {
2360
+ if (_buflen > 0) {
2361
+ writeEncoded(_buffer << 6 - _buflen);
2362
+ _buffer = 0;
2363
+ _buflen = 0;
2364
+ }
2365
+ if (_length % 3 != 0) {
2366
+ const padlen = 3 - _length % 3;
2367
+ for (let i = 0; i < padlen; i += 1) _base64 += "=";
2368
+ }
2369
+ };
2370
+ _this.toString = function() {
2371
+ return _base64;
2372
+ };
2373
+ return _this;
2374
+ };
2375
+ const base64DecodeInputStream = function(str) {
2376
+ const _str = str;
2377
+ let _pos = 0;
2378
+ let _buffer = 0;
2379
+ let _buflen = 0;
2380
+ const _this = {};
2381
+ _this.read = function() {
2382
+ while (_buflen < 8) {
2383
+ if (_pos >= _str.length) {
2384
+ if (_buflen == 0) return -1;
2385
+ throw "unexpected end of file./" + _buflen;
2386
+ }
2387
+ const c = _str.charAt(_pos);
2388
+ _pos += 1;
2389
+ if (c == "=") {
2390
+ _buflen = 0;
2391
+ return -1;
2392
+ } else if (c.match(/^\s$/)) continue;
2393
+ _buffer = _buffer << 6 | decode(c.charCodeAt(0));
2394
+ _buflen += 6;
2395
+ }
2396
+ const n = _buffer >>> _buflen - 8 & 255;
2397
+ _buflen -= 8;
2398
+ return n;
2399
+ };
2400
+ const decode = function(c) {
2401
+ if (65 <= c && c <= 90) return c - 65;
2402
+ else if (97 <= c && c <= 122) return c - 97 + 26;
2403
+ else if (48 <= c && c <= 57) return c - 48 + 52;
2404
+ else if (c == 43) return 62;
2405
+ else if (c == 47) return 63;
2406
+ else throw "c:" + c;
2407
+ };
2408
+ return _this;
2409
+ };
2410
+ const gifImage = function(width, height) {
2411
+ const _width = width;
2412
+ const _height = height;
2413
+ const _data = new Array(width * height);
2414
+ const _this = {};
2415
+ _this.setPixel = function(x, y, pixel) {
2416
+ _data[y * _width + x] = pixel;
2417
+ };
2418
+ _this.write = function(out) {
2419
+ out.writeString("GIF87a");
2420
+ out.writeShort(_width);
2421
+ out.writeShort(_height);
2422
+ out.writeByte(128);
2423
+ out.writeByte(0);
2424
+ out.writeByte(0);
2425
+ out.writeByte(0);
2426
+ out.writeByte(0);
2427
+ out.writeByte(0);
2428
+ out.writeByte(255);
2429
+ out.writeByte(255);
2430
+ out.writeByte(255);
2431
+ out.writeString(",");
2432
+ out.writeShort(0);
2433
+ out.writeShort(0);
2434
+ out.writeShort(_width);
2435
+ out.writeShort(_height);
2436
+ out.writeByte(0);
2437
+ const lzwMinCodeSize = 2;
2438
+ const raster = getLZWRaster(lzwMinCodeSize);
2439
+ out.writeByte(lzwMinCodeSize);
2440
+ let offset = 0;
2441
+ while (raster.length - offset > 255) {
2442
+ out.writeByte(255);
2443
+ out.writeBytes(raster, offset, 255);
2444
+ offset += 255;
2445
+ }
2446
+ out.writeByte(raster.length - offset);
2447
+ out.writeBytes(raster, offset, raster.length - offset);
2448
+ out.writeByte(0);
2449
+ out.writeString(";");
2450
+ };
2451
+ const bitOutputStream = function(out) {
2452
+ const _out = out;
2453
+ let _bitLength = 0;
2454
+ let _bitBuffer = 0;
2455
+ const _this = {};
2456
+ _this.write = function(data, length) {
2457
+ if (data >>> length != 0) throw "length over";
2458
+ while (_bitLength + length >= 8) {
2459
+ _out.writeByte(255 & (data << _bitLength | _bitBuffer));
2460
+ length -= 8 - _bitLength;
2461
+ data >>>= 8 - _bitLength;
2462
+ _bitBuffer = 0;
2463
+ _bitLength = 0;
2464
+ }
2465
+ _bitBuffer = data << _bitLength | _bitBuffer;
2466
+ _bitLength = _bitLength + length;
2467
+ };
2468
+ _this.flush = function() {
2469
+ if (_bitLength > 0) _out.writeByte(_bitBuffer);
2470
+ };
2471
+ return _this;
2472
+ };
2473
+ const getLZWRaster = function(lzwMinCodeSize) {
2474
+ const clearCode = 1 << lzwMinCodeSize;
2475
+ const endCode = (1 << lzwMinCodeSize) + 1;
2476
+ let bitLength = lzwMinCodeSize + 1;
2477
+ const table = lzwTable();
2478
+ for (let i = 0; i < clearCode; i += 1) table.add(String.fromCharCode(i));
2479
+ table.add(String.fromCharCode(clearCode));
2480
+ table.add(String.fromCharCode(endCode));
2481
+ const byteOut = byteArrayOutputStream();
2482
+ const bitOut = bitOutputStream(byteOut);
2483
+ bitOut.write(clearCode, bitLength);
2484
+ let dataIndex = 0;
2485
+ let s = String.fromCharCode(_data[dataIndex]);
2486
+ dataIndex += 1;
2487
+ while (dataIndex < _data.length) {
2488
+ const c = String.fromCharCode(_data[dataIndex]);
2489
+ dataIndex += 1;
2490
+ if (table.contains(s + c)) s = s + c;
2491
+ else {
2492
+ bitOut.write(table.indexOf(s), bitLength);
2493
+ if (table.size() < 4095) {
2494
+ if (table.size() == 1 << bitLength) bitLength += 1;
2495
+ table.add(s + c);
2496
+ }
2497
+ s = c;
2498
+ }
2499
+ }
2500
+ bitOut.write(table.indexOf(s), bitLength);
2501
+ bitOut.write(endCode, bitLength);
2502
+ bitOut.flush();
2503
+ return byteOut.toByteArray();
2504
+ };
2505
+ const lzwTable = function() {
2506
+ const _map = {};
2507
+ let _size = 0;
2508
+ const _this = {};
2509
+ _this.add = function(key) {
2510
+ if (_this.contains(key)) throw "dup key:" + key;
2511
+ _map[key] = _size;
2512
+ _size += 1;
2513
+ };
2514
+ _this.size = function() {
2515
+ return _size;
2516
+ };
2517
+ _this.indexOf = function(key) {
2518
+ return _map[key];
2519
+ };
2520
+ _this.contains = function(key) {
2521
+ return typeof _map[key] != "undefined";
2522
+ };
2523
+ return _this;
2524
+ };
2525
+ return _this;
2526
+ };
2527
+ const createDataURL = function(width, height, getPixel) {
2528
+ const gif = gifImage(width, height);
2529
+ for (let y = 0; y < height; y += 1) for (let x = 0; x < width; x += 1) gif.setPixel(x, y, getPixel(x, y));
2530
+ const b = byteArrayOutputStream();
2531
+ gif.write(b);
2532
+ const base64 = base64EncodeOutputStream();
2533
+ const bytes = b.toByteArray();
2534
+ for (let i = 0; i < bytes.length; i += 1) base64.writeByte(bytes[i]);
2535
+ base64.flush();
2536
+ return "data:image/gif;base64," + base64;
2537
+ };
2538
+ const stringToBytes = qrcode.stringToBytes;
2539
+
2540
+ // src/client/index.tsx
2541
+ const name = "meshy-dsh-client";
2542
+ const inject = ["slots", "locale"];
2543
+ const NS = "meshy";
2544
+ const GLB_ID = "meshy-dsh/glb";
2545
+ /**
2546
+ * dsh refuses a complete-file read above 32 MiB (`maxFileBytes`), so the preview reads 2 MiB
2547
+ * windows (`maxBytes`, the per-window cap) and stops at its own limit instead.
2548
+ */
2549
+ const WINDOW = 2 << 20;
2550
+ const MAX_GLB = 256 << 20;
2551
+ /** The left-sidebar entry and its page in the main column share this id. */
2552
+ const PAGE_ID = "meshy";
2553
+ const EXAMPLES = [
2554
+ "chest",
2555
+ "photo",
2556
+ "character",
2557
+ "print"
2558
+ ];
2559
+ const SITES = {
2560
+ global: {
2561
+ web: "https://www.meshy.ai",
2562
+ docs: "https://docs.meshy.ai",
2563
+ host: "meshy.ai"
2564
+ },
2565
+ cn: {
2566
+ web: "https://meshy.cn",
2567
+ docs: "https://docs.meshy.cn",
2568
+ host: "meshy.cn"
2569
+ }
2570
+ };
2571
+ const CN_ZONES = /* @__PURE__ */ new Set([
2572
+ "Asia/Shanghai",
2573
+ "Asia/Chongqing",
2574
+ "Asia/Chungking",
2575
+ "Asia/Harbin",
2576
+ "Asia/Urumqi",
2577
+ "Asia/Kashgar",
2578
+ "PRC"
2579
+ ]);
2580
+ function guessSite() {
2581
+ try {
2582
+ return CN_ZONES.has(Intl.DateTimeFormat().resolvedOptions().timeZone) ? "cn" : "global";
2583
+ } catch {
2584
+ return "global";
2585
+ }
2586
+ }
2587
+ let currentSite = guessSite();
2588
+ const siteListeners = /* @__PURE__ */ new Set();
2589
+ function setSite(next) {
2590
+ if (next === currentSite) return;
2591
+ currentSite = next;
2592
+ for (const notify of siteListeners) notify();
2593
+ }
2594
+ function useSite() {
2595
+ return (0, react.useSyncExternalStore)((notify) => {
2596
+ siteListeners.add(notify);
2597
+ return () => {
2598
+ siteListeners.delete(notify);
2599
+ };
2600
+ }, () => currentSite);
2601
+ }
2602
+ /** Docs in the reader's language on the global site; the China site serves Chinese by default. */
2603
+ function docsUrl(site) {
2604
+ return site === "global" && /^zh/i.test(globalThis.navigator?.language ?? "") ? `${SITES.global.docs}/zh` : SITES[site].docs;
2605
+ }
2606
+ const en = {
2607
+ nav: "Meshy",
2608
+ accountTitle: "Meshy account",
2609
+ summary: "Sign in to Meshy and preview GLB models in 3D.",
2610
+ tagline: "Text and images to 3D models, right in DeepSeek Harness",
2611
+ checking: "Checking…",
2612
+ signedIn: "Signed in",
2613
+ signedOut: "Not signed in",
2614
+ unverified: "Needs attention",
2615
+ "unverified.hint": "The saved sign-in could not be verified. Refresh, or sign in again.",
2616
+ site: "Site",
2617
+ "site.global": "Global",
2618
+ "site.cn": "China",
2619
+ credits: "Credits",
2620
+ "credits.get": "Get credits",
2621
+ method: "Signed in with",
2622
+ "method.browser": "Browser",
2623
+ "method.apiKey": "API key",
2624
+ more: "Manage account",
2625
+ signIn: "Sign in to Meshy",
2626
+ "signIn.hint": "Approve in your browser once; the Meshy skills then use this sign-in.",
2627
+ "signIn.scan": "Scan with your phone, or open the link",
2628
+ "signIn.scanHint": "Sign in to {host} and approve. This page finishes on its own.",
2629
+ "signIn.code": "Code",
2630
+ "signIn.open": "Open in browser",
2631
+ "signIn.waiting": "Waiting for your approval…",
2632
+ copy: "Copy code",
2633
+ copied: "Copied",
2634
+ cancel: "Cancel",
2635
+ retry: "Try again",
2636
+ refresh: "Refresh",
2637
+ signOut: "Sign out",
2638
+ "signOut.title": "Sign out of Meshy?",
2639
+ "signOut.body": "The Meshy skills in DeepSeek Harness will ask you to sign in again before they generate.",
2640
+ close: "Close",
2641
+ cli: "Meshy CLI {version}",
2642
+ "cli.temporary": "run through npm exec",
2643
+ "error.cli": "Meshy CLI not found",
2644
+ "error.cliHint": "Install Node.js 22.12 or newer, then run this and refresh:",
2645
+ "error.expired": "The code expired. Start again for a new one.",
2646
+ "error.generic": "Something went wrong: {message}",
2647
+ "viewer.title": "3D model",
2648
+ "viewer.loading": "Loading model…",
2649
+ "viewer.failed": "This model cannot be shown",
2650
+ "viewer.tooLarge": "The model is {size}, over the {limit} preview limit. Remesh it to fewer faces to preview it.",
2651
+ "viewer.triangles": "{count} triangles",
2652
+ "viewer.reset": "Reset view",
2653
+ "viewer.spin": "Auto-rotate",
2654
+ "viewer.stop": "Stop rotating",
2655
+ "page.tagline": "Turn text and images into 3D models, rig and animate them, or get them ready to print.",
2656
+ "page.start": "Start creating",
2657
+ "page.startHint": "Pick one to open a new session with it filled in. Edit it, then send.",
2658
+ "page.copyHint": "Copy one into a session, edit it, then send.",
2659
+ "page.try": "Start a session",
2660
+ "page.docs": "Documentation",
2661
+ "page.site": "Meshy website",
2662
+ "example.chest.title": "Game asset",
2663
+ "example.chest.prompt": "Make a low-poly cartoon treasure chest for my game and export it as GLB.",
2664
+ "example.photo.title": "Photo to 3D",
2665
+ "example.photo.prompt": "Turn the photo I attach into a textured 3D model.",
2666
+ "example.character.title": "Animated character",
2667
+ "example.character.prompt": "Create a cartoon knight, rig it, add a walking animation and export FBX.",
2668
+ "example.print.title": "3D print",
2669
+ "example.print.prompt": "Make a 10 cm tall shiba inu figurine and prepare a print-ready 3MF."
2670
+ };
2671
+ const zh = {
2672
+ nav: "Meshy",
2673
+ accountTitle: "Meshy 账号",
2674
+ summary: "登录 Meshy,并在 3D 中预览 GLB 模型。",
2675
+ tagline: "在 DeepSeek Harness 里用文字或图片生成 3D 模型",
2676
+ checking: "检查中…",
2677
+ signedIn: "已登录",
2678
+ signedOut: "未登录",
2679
+ unverified: "需要处理",
2680
+ "unverified.hint": "已保存的登录无法验证。请刷新,或重新登录。",
2681
+ site: "站点",
2682
+ "site.global": "国际站",
2683
+ "site.cn": "中国站",
2684
+ credits: "积分",
2685
+ "credits.get": "获取积分",
2686
+ method: "登录方式",
2687
+ "method.browser": "浏览器登录",
2688
+ "method.apiKey": "API key",
2689
+ more: "管理账号",
2690
+ signIn: "登录 Meshy",
2691
+ "signIn.hint": "在浏览器里批准一次,Meshy 技能之后都会使用这个登录。",
2692
+ "signIn.scan": "用手机扫码,或打开链接",
2693
+ "signIn.scanHint": "登录 {host} 并批准,本页会自动完成。",
2694
+ "signIn.code": "验证码",
2695
+ "signIn.open": "在浏览器中打开",
2696
+ "signIn.waiting": "正在等待你的批准…",
2697
+ copy: "复制验证码",
2698
+ copied: "已复制",
2699
+ cancel: "取消",
2700
+ retry: "重试",
2701
+ refresh: "刷新",
2702
+ signOut: "退出登录",
2703
+ "signOut.title": "退出 Meshy 登录?",
2704
+ "signOut.body": "退出后,DeepSeek Harness 里的 Meshy 技能在生成前会要求你重新登录。",
2705
+ close: "关闭",
2706
+ cli: "Meshy CLI {version}",
2707
+ "cli.temporary": "通过 npm exec 运行",
2708
+ "error.cli": "找不到 Meshy CLI",
2709
+ "error.cliHint": "请安装 Node.js 22.12 或更新版本,运行下面的命令后刷新:",
2710
+ "error.expired": "验证码已过期,请重新开始。",
2711
+ "error.generic": "出错了:{message}",
2712
+ "viewer.title": "3D 模型",
2713
+ "viewer.loading": "正在加载模型…",
2714
+ "viewer.failed": "无法显示这个模型",
2715
+ "viewer.tooLarge": "模型有 {size},超过 {limit} 的预览上限。减面后再预览。",
2716
+ "viewer.triangles": "{count} 个三角面",
2717
+ "viewer.reset": "重置视角",
2718
+ "viewer.spin": "自动旋转",
2719
+ "viewer.stop": "停止旋转",
2720
+ "page.tagline": "用文字或图片生成 3D 模型,绑骨做动画,或者准备好直接 3D 打印。",
2721
+ "page.start": "开始创作",
2722
+ "page.startHint": "选一个,会新开一个会话并填好需求,改一改再发送。",
2723
+ "page.copyHint": "复制到会话里,改一改再发送。",
2724
+ "page.try": "新开会话",
2725
+ "page.docs": "文档",
2726
+ "page.site": "Meshy 官网",
2727
+ "example.chest.title": "游戏资产",
2728
+ "example.chest.prompt": "做一个低多边形的卡通宝箱,用在我的游戏里,导出 GLB。",
2729
+ "example.photo.title": "照片转 3D",
2730
+ "example.photo.prompt": "把我附上的这张照片做成带贴图的 3D 模型。",
2731
+ "example.character.title": "动画角色",
2732
+ "example.character.prompt": "生成一个卡通骑士,绑骨并加上走路动画,导出 FBX。",
2733
+ "example.print.title": "3D 打印",
2734
+ "example.print.prompt": "做一个 10 厘米高的柴犬手办,并准备好可以直接打印的 3MF。"
2735
+ };
2736
+ const CSS = `
2737
+ .meshy-root{--meshy-accent:#beef54;--meshy-accent-hover:#b1ed30;--meshy-accent-label:#000;color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family);font-size:13px;line-height:22px}
2738
+ body[data-ds-dark-theme] .meshy-root{--meshy-accent:#c5f955;--meshy-accent-hover:#a8e328}
2739
+ .meshy-section{display:flex;flex-direction:column;gap:16px;padding:8px 0}
2740
+ .meshy-card{border:.5px solid var(--dsw-alias-settings-card-stroke);border-radius:var(--dsw-radius-xl);background:var(--dsw-alias-settings-card-fill);padding:12px 16px}
2741
+ .meshy-head,.meshy-row{display:flex;justify-content:space-between;align-items:center;gap:16px}
2742
+ .meshy-identity{display:flex;align-items:center;gap:10px;min-width:0;min-height:44px}
2743
+ .meshy-logo{width:32px;height:32px;flex:none;border-radius:9px}
2744
+ .meshy-copy{display:flex;flex-direction:column;min-width:0}
2745
+ .meshy-name{font-size:14px;font-weight:500}
2746
+ .meshy-muted{color:var(--dsw-alias-label-tertiary)}
2747
+ .meshy-small{font-size:12px;line-height:18px}
2748
+ .meshy-pill{display:inline-flex;align-items:center;gap:6px;flex:none;white-space:nowrap}
2749
+ .meshy-dot{width:8px;height:8px;border-radius:50%;background:var(--dsw-alias-label-tertiary)}
2750
+ .meshy-dot[data-on]{background:var(--meshy-accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--meshy-accent) 25%,transparent)}
2751
+ .meshy-dot[data-warn]{background:var(--dsw-alias-state-warn-primary)}
2752
+ .meshy-rows{display:flex;flex-direction:column;gap:8px}
2753
+ .meshy-row{box-sizing:border-box;min-height:40px;padding:6px 0}
2754
+ .meshy-divider{border-top:.5px solid var(--dsw-alias-border-l2)}
2755
+ .meshy-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:10px}
2756
+ .meshy-amount{display:inline-flex;align-items:center;gap:8px;font-size:18px;font-weight:510;line-height:28px}
2757
+ .meshy-coin{width:12px;height:12px;border-radius:50%;background:linear-gradient(135deg,#f9e855,#e99430)}
2758
+ .meshy-link{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;gap:4px;height:36px;padding:0 14px;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md);color:var(--dsw-alias-label-primary);font-size:14px;line-height:22px;text-decoration:none;white-space:nowrap}
2759
+ .meshy-link:hover{background:var(--dsw-alias-interactive-bg-hover)}
2760
+ .meshy-link:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
2761
+ .meshy-root .meshy-accent{flex:none;white-space:nowrap;border-color:transparent;background:var(--meshy-accent);color:var(--meshy-accent-label);font-weight:500}
2762
+ .meshy-root .meshy-accent:hover:not(:disabled){background:var(--meshy-accent-hover)}
2763
+ .meshy-signin{display:flex;align-items:center;gap:20px}
2764
+ .meshy-qr{flex:none;width:136px;height:136px;padding:10px;border-radius:var(--dsw-radius-lg);background:#fff;border:.5px solid var(--dsw-alias-border-l2);image-rendering:pixelated}
2765
+ .meshy-signin .meshy-copy{gap:10px}
2766
+ .meshy-code{display:inline-flex;align-items:center;gap:8px}
2767
+ .meshy-code code{font-family:var(--ds-font-family-code);font-size:16px;letter-spacing:.08em;padding:2px 10px;border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-bg-module-platform)}
2768
+ .meshy-waiting{display:inline-flex;align-items:center;gap:8px;color:var(--dsw-alias-label-secondary)}
2769
+ .meshy-alert{display:flex;align-items:flex-start;gap:8px;padding:10px 12px;border-radius:var(--dsw-radius-lg);background:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 10%,transparent)}
2770
+ .meshy-alert svg{flex:none;margin-top:3px;color:var(--dsw-alias-state-warn-primary)}
2771
+ .meshy-alert code{align-self:flex-start;margin-top:4px;padding:1px 6px;border-radius:var(--dsw-radius-xs);font-family:var(--ds-font-family-code);font-size:12px;background:color-mix(in srgb,var(--dsw-alias-label-primary) 8%,transparent)}
2772
+ .meshy-foot{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:0 4px}
2773
+ .meshy-skeleton{display:block;border-radius:6px;background:var(--dsw-alias-bg-skeleton);animation:meshy-pulse 1.4s ease-in-out infinite}
2774
+ @keyframes meshy-pulse{50%{opacity:.45}}
2775
+ .meshy-viewer{position:relative;width:100%;height:100%;min-height:360px}
2776
+ .meshy-stage{position:absolute;inset:0}
2777
+ .meshy-overlay{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:16px;text-align:center}
2778
+ .meshy-overlay .meshy-logo{width:40px;height:40px;animation:meshy-pulse 1.4s ease-in-out infinite}
2779
+ .meshy-bar{position:absolute;left:12px;right:12px;bottom:12px;display:flex;align-items:center;justify-content:space-between;gap:8px;pointer-events:none}
2780
+ .meshy-bar>*{pointer-events:auto}
2781
+ .meshy-chip{padding:2px 10px;border-radius:999px;background:color-mix(in srgb,var(--dsw-alias-bg-base) 80%,transparent);backdrop-filter:blur(8px);font-size:12px;line-height:20px;color:var(--dsw-alias-label-secondary)}
2782
+ .meshy-page{box-sizing:border-box;height:100%;overflow-y:auto}
2783
+ .meshy-page-inner{box-sizing:border-box;max-width:760px;margin:0 auto;padding:56px 32px 48px;display:flex;flex-direction:column;gap:32px}
2784
+ .meshy-hero{display:flex;align-items:center;gap:16px}
2785
+ .meshy-hero .meshy-logo{width:56px;height:56px;border-radius:14px}
2786
+ .meshy-hero h1{margin:0;font-size:24px;font-weight:600;line-height:32px;color:var(--dsw-alias-label-primary)}
2787
+ .meshy-h2{margin:0;font-size:15px;font-weight:500;line-height:24px}
2788
+ .meshy-block{display:flex;flex-direction:column;gap:12px}
2789
+ .meshy-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:12px}
2790
+ .meshy-example{box-sizing:border-box;display:flex;flex-direction:column;align-items:flex-start;gap:6px;width:100%;margin:0;padding:14px 16px;border:.5px solid var(--dsw-alias-settings-card-stroke);border-radius:var(--dsw-radius-xl);background:var(--dsw-alias-settings-card-fill);color:var(--dsw-alias-label-primary);font:inherit;text-align:left;cursor:pointer;transition:background-color .15s,border-color .15s}
2791
+ .meshy-example:hover{background:var(--dsw-alias-interactive-bg-hover);border-color:color-mix(in srgb,var(--meshy-accent) 70%,transparent)}
2792
+ .meshy-example:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
2793
+ .meshy-example-title{display:inline-flex;align-items:center;gap:8px;font-weight:500}
2794
+ .meshy-example-title::before{content:"";width:6px;height:6px;border-radius:50%;background:var(--meshy-accent)}
2795
+ .meshy-example-cta{display:inline-flex;align-items:center;gap:4px;margin-top:4px;font-size:12px;color:var(--dsw-alias-label-tertiary)}
2796
+ .meshy-example:hover .meshy-example-cta{color:var(--dsw-alias-label-primary)}
2797
+ .meshy-links{display:flex;gap:16px}
2798
+ .meshy-textlink{display:inline-flex;align-items:center;gap:4px;color:var(--dsw-alias-label-secondary);text-decoration:none}
2799
+ .meshy-textlink:hover{color:var(--dsw-alias-label-primary)}
2800
+ .meshy-mark{display:inline-flex;flex:none}
2801
+ .meshy-tools{display:flex;gap:4px;padding:2px;border-radius:var(--dsw-radius-md);background:color-mix(in srgb,var(--dsw-alias-bg-base) 80%,transparent);backdrop-filter:blur(8px)}
2802
+ `;
2803
+ if (typeof document !== "undefined" && !document.querySelector("style[data-plugin-css=\"meshy-dsh/client.css\"]")) {
2804
+ const tag = document.createElement("style");
2805
+ tag.dataset.plugin = "meshy-dsh";
2806
+ tag.dataset.pluginCss = "meshy-dsh/client.css";
2807
+ tag.textContent = CSS;
2808
+ document.head.append(tag);
2809
+ }
2810
+ async function api(path, body) {
2811
+ const res = await fetch(`api/${path}`, body === void 0 ? { cache: "no-store" } : {
2812
+ method: "POST",
2813
+ cache: "no-store",
2814
+ headers: { "content-type": "application/json" },
2815
+ body: JSON.stringify(body)
2816
+ });
2817
+ return {
2818
+ status: res.status,
2819
+ data: await res.json().catch(() => ({}))
2820
+ };
2821
+ }
2822
+ function qr(text) {
2823
+ const code = qrcode(0, "M");
2824
+ code.addData(text);
2825
+ code.make();
2826
+ return code.createDataURL(6, 0);
2827
+ }
2828
+ const Logo = () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
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MzQgNjIuMzQ0NiA0MS44ODc1IDYwLjU2OSA0MS44NDIzQzU5LjU0MTggNDEuODE2MSA1OC43MDg5IDQxLjUwNDcgNTguMjQ3NiA0MS4wNDEzWiIgZmlsbD0iI0ZGM0U4RiIvPgo8cGF0aCBkPSJNMjMuODk1MSAxMUwyNi41NjE3IDE4LjI1NDVMMzMuNzY4MiAyMC45Mzg5TDI2LjU2MTcgMjMuNjIzNEwyMy44OTUxIDMwLjg3NzlMMjEuMjI4NSAyMy42MjM0TDE0LjAyMiAyMC45Mzg5TDIxLjIyODUgMTguMjU0NUwyMy44OTUxIDExWiIgZmlsbD0iI0M1Rjk1NSIvPgo8cGF0aCBkPSJNMTIuNjI4NiAyOS43NzMzTDE0LjE0ODggMzMuOTM4TDE4LjI1NzIgMzUuNDc5TDE0LjE0ODggMzcuMDIwMUwxMi42Mjg2IDQxLjE4NDdMMTEuMTA4NCAzNy4wMjAxTDcgMzUuNDc5TDExLjEwODQgMzMuOTM4TDEyLjYyODYgMjkuNzczM1oiIGZpbGw9IiNDNUY5NTUiLz4KPC9zdmc+Cg==",
2831
+ alt: ""
2832
+ });
2833
+ function Identity({ t, page, line, pill }) {
2834
+ const title = page ? t("accountTitle") : "Meshy";
2835
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2836
+ className: "meshy-card meshy-head",
2837
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2838
+ className: "meshy-identity",
2839
+ children: [!page && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Logo, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2840
+ className: "meshy-copy",
2841
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2842
+ className: "meshy-name",
2843
+ children: title
2844
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2845
+ className: "meshy-muted",
2846
+ children: line
2847
+ })]
2848
+ })]
2849
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2850
+ className: "meshy-pill meshy-muted",
2851
+ children: [pill === "checking" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, {
2852
+ state: "ongoing",
2853
+ size: 12
2854
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2855
+ className: "meshy-dot",
2856
+ "data-on": pill === "on" || void 0,
2857
+ "data-warn": pill === "warn" || void 0
2858
+ }), t(pill === "checking" ? "checking" : pill === "on" ? "signedIn" : pill === "warn" ? "unverified" : "signedOut")]
2859
+ })]
2860
+ });
2861
+ }
2862
+ function Skeleton() {
2863
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2864
+ className: "meshy-card meshy-rows",
2865
+ "aria-hidden": "true",
2866
+ children: [
2867
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2868
+ className: "meshy-row",
2869
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2870
+ className: "meshy-skeleton",
2871
+ style: {
2872
+ width: 64,
2873
+ height: 14
2874
+ }
2875
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2876
+ className: "meshy-skeleton",
2877
+ style: {
2878
+ width: 120,
2879
+ height: 22
2880
+ }
2881
+ })]
2882
+ }),
2883
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "meshy-divider" }),
2884
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2885
+ className: "meshy-row",
2886
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2887
+ className: "meshy-skeleton",
2888
+ style: {
2889
+ width: 48,
2890
+ height: 14
2891
+ }
2892
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2893
+ className: "meshy-skeleton",
2894
+ style: {
2895
+ width: 180,
2896
+ height: 36
2897
+ }
2898
+ })]
2899
+ })
2900
+ ]
2901
+ });
2902
+ }
2903
+ function Alert({ children, action }) {
2904
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2905
+ className: "meshy-alert",
2906
+ role: "alert",
2907
+ children: [
2908
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconWarningOutlineRegular, { size: 14 }),
2909
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2910
+ className: "meshy-copy",
2911
+ style: { flex: 1 },
2912
+ children
2913
+ }),
2914
+ action
2915
+ ]
2916
+ });
2917
+ }
2918
+ function MeshyPanel({ t, view }) {
2919
+ const [status, setStatus] = (0, react.useState)();
2920
+ const site = useSite();
2921
+ const [flow, setFlow] = (0, react.useState)();
2922
+ const [busy, setBusy] = (0, react.useState)(false);
2923
+ const [problem, setProblem] = (0, react.useState)();
2924
+ const [copied, setCopied] = (0, react.useState)(false);
2925
+ const [confirmOut, setConfirmOut] = (0, react.useState)(false);
2926
+ const polling = (0, react.useRef)(0);
2927
+ (0, react.useEffect)(() => {
2928
+ if (status?.auth?.authenticated) setSite(status.auth.region);
2929
+ }, [status]);
2930
+ const refresh = (0, react.useCallback)(async () => {
2931
+ setStatus(void 0);
2932
+ setProblem(void 0);
2933
+ try {
2934
+ const next = (await api("meshy.status")).data;
2935
+ setStatus(next);
2936
+ if (!next.cli) setProblem({ kind: "cli" });
2937
+ } catch (err) {
2938
+ setStatus({ cli: null });
2939
+ setProblem({
2940
+ kind: "generic",
2941
+ message: String(err)
2942
+ });
2943
+ }
2944
+ }, []);
2945
+ (0, react.useEffect)(() => {
2946
+ if (view !== "summary") refresh();
2947
+ return () => {
2948
+ polling.current++;
2949
+ };
2950
+ }, [refresh, view]);
2951
+ if (view === "summary") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("summary") });
2952
+ const signIn = async () => {
2953
+ setBusy(true);
2954
+ setProblem(void 0);
2955
+ try {
2956
+ const { status: code, data } = await api("meshy.login", { region: site });
2957
+ if (code !== 200) throw new Error(data.error ?? String(code));
2958
+ setFlow(data);
2959
+ const run = ++polling.current;
2960
+ const deadline = Date.now() + (data.expires_in ?? 600) * 1e3;
2961
+ while (run === polling.current) {
2962
+ if (Date.now() > deadline) {
2963
+ setFlow(void 0);
2964
+ setProblem({ kind: "expired" });
2965
+ return;
2966
+ }
2967
+ const done = await api("meshy.login.finish", { flow_id: data.flow_id });
2968
+ if (run !== polling.current) return;
2969
+ if (done.status === 202) continue;
2970
+ if (done.status !== 200) {
2971
+ setFlow(void 0);
2972
+ setProblem(/expir/i.test(done.data.error ?? "") ? { kind: "expired" } : {
2973
+ kind: "generic",
2974
+ message: done.data.error ?? String(done.status)
2975
+ });
2976
+ return;
2977
+ }
2978
+ setFlow(void 0);
2979
+ await refresh();
2980
+ return;
2981
+ }
2982
+ } catch (err) {
2983
+ setFlow(void 0);
2984
+ setProblem({
2985
+ kind: "generic",
2986
+ message: String(err?.message ?? err)
2987
+ });
2988
+ } finally {
2989
+ setBusy(false);
2990
+ }
2991
+ };
2992
+ const cancel = () => {
2993
+ polling.current++;
2994
+ setFlow(void 0);
2995
+ setBusy(false);
2996
+ };
2997
+ const signOut = async () => {
2998
+ setConfirmOut(false);
2999
+ setBusy(true);
3000
+ try {
3001
+ const { status: code, data } = await api("meshy.logout", {});
3002
+ if (code !== 200) throw new Error(data.error ?? String(code));
3003
+ await refresh();
3004
+ } catch (err) {
3005
+ setProblem({
3006
+ kind: "generic",
3007
+ message: String(err?.message ?? err)
3008
+ });
3009
+ } finally {
3010
+ setBusy(false);
3011
+ }
3012
+ };
3013
+ const copy = async () => {
3014
+ if (flow && await (0, _deepseek_ai_dsh_client_ui_primitives.writeClipboard)(flow.user_code)) {
3015
+ setCopied(true);
3016
+ setTimeout(() => setCopied(false), 1500);
3017
+ }
3018
+ };
3019
+ const auth = status?.auth;
3020
+ const signedIn = !!auth?.authenticated;
3021
+ const shownSite = auth?.region ?? site;
3022
+ const problemText = problem && (problem.kind === "expired" ? t("error.expired") : problem.kind === "cli" ? t("error.cli") : t("error.generic", { message: problem.message ?? "" }));
3023
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3024
+ className: "meshy-root meshy-section",
3025
+ "aria-label": t("nav"),
3026
+ children: [!status ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Identity, {
3027
+ t,
3028
+ page: view === "page",
3029
+ line: t(view === "page" ? "summary" : "tagline"),
3030
+ pill: "checking"
3031
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Skeleton, {})] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
3032
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Identity, {
3033
+ t,
3034
+ page: view === "page",
3035
+ line: signedIn ? `${t(`site.${shownSite}`)} · ${SITES[shownSite].host}` : t(view === "page" ? "summary" : "tagline"),
3036
+ pill: !status.cli ? "off" : !signedIn ? "off" : auth.verified ? "on" : "warn"
3037
+ }),
3038
+ problem && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Alert, {
3039
+ action: problem.kind === "cli" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3040
+ variant: "outline",
3041
+ size: "sm",
3042
+ onClick: refresh,
3043
+ children: t("refresh")
3044
+ }) : problem.kind === "expired" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3045
+ variant: "outline",
3046
+ size: "sm",
3047
+ onClick: signIn,
3048
+ children: t("retry")
3049
+ }) : void 0,
3050
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: problemText }), problem.kind === "cli" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3051
+ className: "meshy-muted meshy-small",
3052
+ children: t("error.cliHint")
3053
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: "npm install -g meshy-cli@0.7" })] })]
3054
+ }),
3055
+ status.cli && signedIn && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3056
+ className: "meshy-card meshy-rows",
3057
+ children: [
3058
+ !auth.verified && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Alert, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("unverified.hint") }) }),
3059
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3060
+ className: "meshy-row",
3061
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("credits") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3062
+ className: "meshy-amount",
3063
+ children: auth.balance === null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3064
+ className: "meshy-muted meshy-small",
3065
+ children: "—"
3066
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "meshy-coin" }), auth.balance.toLocaleString()] })
3067
+ })]
3068
+ }),
3069
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "meshy-divider" }),
3070
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3071
+ className: "meshy-row",
3072
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("method") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3073
+ className: "meshy-muted",
3074
+ children: auth.method ? t(`method.${auth.method}`) : "—"
3075
+ })]
3076
+ }),
3077
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "meshy-divider" }),
3078
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3079
+ className: "meshy-row",
3080
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3081
+ className: "meshy-muted",
3082
+ children: t("more")
3083
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3084
+ className: "meshy-actions",
3085
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3086
+ variant: "outline",
3087
+ disabled: busy,
3088
+ onClick: () => setConfirmOut(true),
3089
+ children: t("signOut")
3090
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
3091
+ className: "meshy-link meshy-accent",
3092
+ href: `${SITES[shownSite].web}/pricing`,
3093
+ target: "_blank",
3094
+ rel: "noreferrer",
3095
+ children: [t("credits.get"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRightUpOutlineRegular, { size: 12 })]
3096
+ })]
3097
+ })]
3098
+ })
3099
+ ]
3100
+ }),
3101
+ status.cli && !signedIn && !flow && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3102
+ className: "meshy-card meshy-rows",
3103
+ children: [
3104
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3105
+ className: "meshy-row",
3106
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("site") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.SegmentedControl, {
3107
+ id: "meshy-site",
3108
+ label: t("site"),
3109
+ value: site,
3110
+ disabled: busy,
3111
+ onChange: (value) => setSite(value),
3112
+ options: [{
3113
+ value: "global",
3114
+ label: `${t("site.global")} · meshy.ai`
3115
+ }, {
3116
+ value: "cn",
3117
+ label: `${t("site.cn")} · meshy.cn`
3118
+ }]
3119
+ })]
3120
+ }),
3121
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "meshy-divider" }),
3122
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3123
+ className: "meshy-row",
3124
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3125
+ className: "meshy-muted",
3126
+ children: t("signIn.hint")
3127
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3128
+ variant: "primary",
3129
+ className: "meshy-accent",
3130
+ disabled: busy,
3131
+ onClick: signIn,
3132
+ children: t("signIn")
3133
+ })]
3134
+ })
3135
+ ]
3136
+ }),
3137
+ flow && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3138
+ className: "meshy-card meshy-signin",
3139
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
3140
+ className: "meshy-qr",
3141
+ src: qr(flow.verification_url),
3142
+ alt: ""
3143
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3144
+ className: "meshy-copy",
3145
+ children: [
3146
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3147
+ className: "meshy-name",
3148
+ children: t("signIn.scan")
3149
+ }),
3150
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3151
+ className: "meshy-muted",
3152
+ children: t("signIn.scanHint", { host: SITES[site].host })
3153
+ }),
3154
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3155
+ className: "meshy-code",
3156
+ children: [
3157
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3158
+ className: "meshy-muted",
3159
+ children: t("signIn.code")
3160
+ }),
3161
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: flow.user_code }),
3162
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
3163
+ label: copied ? t("copied") : t("copy"),
3164
+ side: "top",
3165
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3166
+ variant: "ghost",
3167
+ size: "sm",
3168
+ "aria-label": t("copy"),
3169
+ icon: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutlineRegular, { size: 14 }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCopyOutlineRegular, { size: 14 }),
3170
+ onClick: copy
3171
+ })
3172
+ })
3173
+ ]
3174
+ }),
3175
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3176
+ className: "meshy-waiting",
3177
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, {
3178
+ state: "ongoing",
3179
+ size: 12
3180
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.TextShimmer, {
3181
+ active: true,
3182
+ children: t("signIn.waiting")
3183
+ })]
3184
+ }),
3185
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3186
+ className: "meshy-actions",
3187
+ style: { justifyContent: "flex-start" },
3188
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
3189
+ className: "meshy-link meshy-accent",
3190
+ href: flow.verification_url,
3191
+ target: "_blank",
3192
+ rel: "noreferrer",
3193
+ children: [t("signIn.open"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRightUpOutlineRegular, { size: 12 })]
3194
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3195
+ variant: "outline",
3196
+ onClick: cancel,
3197
+ children: t("cancel")
3198
+ })]
3199
+ })
3200
+ ]
3201
+ })]
3202
+ }),
3203
+ status.cli && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3204
+ className: "meshy-foot meshy-muted meshy-small",
3205
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [t("cli", { version: status.cli.version }), status.cli.runner === "npm exec" ? ` · ${t("cli.temporary")}` : ""] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
3206
+ label: t("refresh"),
3207
+ side: "top",
3208
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3209
+ variant: "ghost",
3210
+ size: "sm",
3211
+ "aria-label": t("refresh"),
3212
+ disabled: busy,
3213
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRefreshOutlineRegular, { size: 14 }),
3214
+ onClick: refresh
3215
+ })
3216
+ })]
3217
+ })
3218
+ ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
3219
+ open: confirmOut,
3220
+ onClose: () => setConfirmOut(false),
3221
+ title: t("signOut.title"),
3222
+ closeLabel: t("close"),
3223
+ description: t("signOut.body"),
3224
+ footer: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3225
+ variant: "outline",
3226
+ onClick: () => setConfirmOut(false),
3227
+ children: t("cancel")
3228
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3229
+ variant: "primary",
3230
+ onClick: signOut,
3231
+ children: t("signOut")
3232
+ })] })
3233
+ })]
3234
+ });
3235
+ }
3236
+ /** Set while the workspace navigation service is mounted: opens a new session with the prompt filled in. */
3237
+ let startSession;
3238
+ /** Left-sidebar icon: the host passes the edge size (18 expanded, 16 collapsed); colour follows the row. */
3239
+ function MeshySidebarIcon({ size = 16 }) {
3240
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3241
+ className: "meshy-mark",
3242
+ "aria-hidden": "true",
3243
+ style: {
3244
+ width: size,
3245
+ height: size
3246
+ },
3247
+ dangerouslySetInnerHTML: { __html: "<svg fill=\"currentColor\" fill-rule=\"evenodd\" height=\"100%\" style=\"flex:none;line-height:1\" viewBox=\"0 0 24 24\" width=\"100%\" xmlns=\"http://www.w3.org/2000/svg\"><title>Meshy</title><path d=\"M3.214.358l.59 1.606 1.597.595-1.596.594-.59 1.607-.591-1.607-1.596-.594 1.596-.595.59-1.606zM16.3 1.691a8.04 8.04 0 012.178.641c6.94 2.96 6.273 11.893.308 11.306l-.008-.007c.09.247.177.51.25.779.803 2.395-2.534 3.633-4.663 3.785l.138-.078c2.107-1.3 2.17-6.033-.175-5.56-.855.303-1.641 1.093-2 2.503a6.199 6.199 0 00-.093.436 25.87 25.87 0 00-.102.614c-.147.94-.32 2.038-.821 2.66-.578.041-1.153.043-1.711.001.737-.577 1.098-1.385 1.377-2.584-3.215.395-6.084-.384-6.257-4.094.17.809.509 1.431.972 1.896.267.133.61.252 1.043.345.911.196 1.928.07 2.646-.116.36.237.648.518.823.843.23-.027.464-.061.7-.102a4.523 4.523 0 00-.01-.197 3.115 3.115 0 01-.06-.209c-.108-.395-.278-1.023-.953-1.476-.391-.261-.76-.609-.696-1.075.064-.459.478-.731.93-.84 2.84-.683 4.568-2.988 5.45-5.648C14.988 6.75 14.129 8 13.032 8.947c-2.062 1.781-5.857 1.971-7.106.487.364.217.776.359 1.219.431-.299-.122-.54-.291-.665-.52 3.221.894 6.802-2.252 8.148-6.784-2.963-.128-6.335 1.44-8.25 4.01 2.084-3.387 6.04-5.44 9.916-4.88h.007zm2.57 5.476c-.357 1.21-.224 2.564.444 3.459.058.078.121.154.188.225l-.89.809c-1.327-.571-1.541-2.22-.99-3.741a5.04 5.04 0 011.32-1.997 3.822 3.822 0 011.195-.747l.003.004a3.511 3.511 0 00-.559.574c-.322.415-.56.902-.711 1.414z\"></path><path d=\"M20.352 14.028c6.788 3.227-.077 9.51-10.095 8.441-.36-.033-.72-.08-1.077-.142 3.05-.146 5.386-.591 7.887-2.766-5.111 3.23-14.152 2.117-12.294-1.535-.236 3.143 10.482 2.832 15.062-1.501-.73 2.168-1.945 3.664-3.423 4.62 3.978-1.476 6.496-4.16 3.94-7.117zM7.742 8.427s.236.142.573-.039c.546-.292.673-2.054.673-3.083 0-.278-.342-.283-.342-.283l-.029.003c-.398.042-.704.264-.682.495.079.862-.071 1.94-.27 2.64-.028.1.003.192.077.267zM11.395 6.972c-.338.181-.573.039-.573.039a.263.263 0 01-.078-.267c.2-.7.349-1.778.27-2.64-.021-.231.285-.453.683-.495.01 0 .019-.002.028-.003 0 0 .343.005.343.283 0 1.029-.128 2.79-.673 3.083zM1.056 5.438l-.337-.922-.337.922-.91.341.91.341.337.923.337-.923.91-.34-.91-.342z\"></path></svg>" }
3248
+ });
3249
+ }
3250
+ function ExampleCard({ t, id }) {
3251
+ const prompt = t(`example.${id}.prompt`);
3252
+ const [copied, setCopied] = (0, react.useState)(false);
3253
+ const run = async () => {
3254
+ if (startSession) return startSession(prompt);
3255
+ if (await (0, _deepseek_ai_dsh_client_ui_primitives.writeClipboard)(prompt)) {
3256
+ setCopied(true);
3257
+ setTimeout(() => setCopied(false), 1500);
3258
+ }
3259
+ };
3260
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
3261
+ type: "button",
3262
+ className: "meshy-example",
3263
+ onClick: run,
3264
+ children: [
3265
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3266
+ className: "meshy-example-title",
3267
+ children: t(`example.${id}.title`)
3268
+ }),
3269
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3270
+ className: "meshy-muted",
3271
+ children: prompt
3272
+ }),
3273
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3274
+ className: "meshy-example-cta",
3275
+ children: startSession ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [t("page.try"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronRightOutlineRegular, { size: 12 })] }) : copied ? t("copied") : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [t("copy"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCopyOutlineRegular, { size: 12 })] })
3276
+ })
3277
+ ]
3278
+ });
3279
+ }
3280
+ /** The page the sidebar entry opens in the main column: the account card plus ways to start. */
3281
+ function MeshyPage({ t }) {
3282
+ const site = useSite();
3283
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3284
+ className: "meshy-root meshy-page",
3285
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3286
+ className: "meshy-page-inner",
3287
+ children: [
3288
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
3289
+ className: "meshy-hero",
3290
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Logo, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3291
+ className: "meshy-copy",
3292
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", { children: "Meshy" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3293
+ className: "meshy-muted",
3294
+ children: t("page.tagline")
3295
+ })]
3296
+ })]
3297
+ }),
3298
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MeshyPanel, {
3299
+ t,
3300
+ view: "page"
3301
+ }),
3302
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3303
+ className: "meshy-block",
3304
+ "aria-labelledby": "meshy-start",
3305
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3306
+ className: "meshy-copy",
3307
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
3308
+ id: "meshy-start",
3309
+ className: "meshy-h2",
3310
+ children: t("page.start")
3311
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3312
+ className: "meshy-muted",
3313
+ children: t(startSession ? "page.startHint" : "page.copyHint")
3314
+ })]
3315
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3316
+ className: "meshy-grid",
3317
+ children: EXAMPLES.map((id) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ExampleCard, {
3318
+ t,
3319
+ id
3320
+ }, id))
3321
+ })]
3322
+ }),
3323
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("footer", {
3324
+ className: "meshy-links meshy-small",
3325
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
3326
+ className: "meshy-textlink",
3327
+ href: docsUrl(site),
3328
+ target: "_blank",
3329
+ rel: "noreferrer",
3330
+ children: [t("page.docs"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRightUpOutlineRegular, { size: 12 })]
3331
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
3332
+ className: "meshy-textlink",
3333
+ href: SITES[site].web,
3334
+ target: "_blank",
3335
+ rel: "noreferrer",
3336
+ children: [t("page.site"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRightUpOutlineRegular, { size: 12 })]
3337
+ })]
3338
+ })
3339
+ ]
3340
+ })
3341
+ });
3342
+ }
3343
+ let workspaceFiles;
3344
+ var TooLarge = class extends Error {
3345
+ size;
3346
+ constructor(size) {
3347
+ super("too large");
3348
+ this.size = size;
3349
+ }
3350
+ };
3351
+ /** A preview tab's `dsh-resource://file/session/<id>/<path>` address (dsh-util-workspace-path's grammar). */
3352
+ function sessionFileOf(address) {
3353
+ const m = /^dsh-resource:\/\/file\/session\/([^/?#]+)\/([^?#]+)/.exec(address);
3354
+ return m ? {
3355
+ sessionId: decodeURIComponent(m[1]),
3356
+ path: m[2].split("/").map(decodeURIComponent).join("/")
3357
+ } : void 0;
3358
+ }
3359
+ /** Read the whole file window by window; a change mid-read starts over on the new version. */
3360
+ async function readWindows(address, signal, progress) {
3361
+ const file = sessionFileOf(address);
3362
+ if (!file || !workspaceFiles) throw new Error(`cannot read ${address}`);
3363
+ let chunks = [];
3364
+ let offset = 0;
3365
+ let version;
3366
+ let length = WINDOW;
3367
+ for (;;) {
3368
+ const res = await workspaceFiles.readBytes(file.sessionId, file.path, { range: {
3369
+ offset,
3370
+ length
3371
+ } }, signal);
3372
+ signal.throwIfAborted();
3373
+ if (!res.ok) {
3374
+ const limit = res.error.details?.limit;
3375
+ if (res.error.code === "workspace-file/too-large" && limit && limit < length) {
3376
+ length = limit;
3377
+ continue;
3378
+ }
3379
+ throw new Error(res.error.message ?? res.error.code);
3380
+ }
3381
+ const w = res.value;
3382
+ if (version !== void 0 && w.version !== version) {
3383
+ chunks = [];
3384
+ offset = 0;
3385
+ version = void 0;
3386
+ continue;
3387
+ }
3388
+ version = w.version;
3389
+ if ((w.bytes ?? 0) > MAX_GLB) throw new TooLarge(w.bytes);
3390
+ chunks.push(w.data);
3391
+ offset += w.data.byteLength;
3392
+ if (offset > MAX_GLB) throw new TooLarge(offset);
3393
+ progress(offset, w.bytes ?? offset);
3394
+ if (w.eof || w.data.byteLength === 0) break;
3395
+ }
3396
+ const data = new Uint8Array(offset);
3397
+ let at = 0;
3398
+ for (const c of chunks) {
3399
+ data.set(c, at);
3400
+ at += c.byteLength;
3401
+ }
3402
+ return {
3403
+ data,
3404
+ version
3405
+ };
3406
+ }
3407
+ /** The keyed `sidebar.right.tab.document` body for .glb; it reads the file itself (renderer loading). */
3408
+ function GlbBody({ content, resourceAddress, t }) {
3409
+ const host = (0, react.useRef)(null);
3410
+ const [viewer, setViewer] = (0, react.useState)();
3411
+ const [error, setError] = (0, react.useState)();
3412
+ const [spinning, setSpinning] = (0, react.useState)(false);
3413
+ const [size, setSize] = (0, react.useState)(0);
3414
+ const [progress, setProgress] = (0, react.useState)();
3415
+ (0, react.useEffect)(() => {
3416
+ const el = host.current;
3417
+ if (content.kind !== "renderer" || !el) return;
3418
+ const abort = new AbortController();
3419
+ let mounted;
3420
+ setError(void 0);
3421
+ setViewer(void 0);
3422
+ setSpinning(false);
3423
+ setProgress(void 0);
3424
+ readWindows(resourceAddress, abort.signal, (read, total) => setProgress([read, total])).then(async ({ data, version }) => {
3425
+ const v = await (await require.async("./client.viewer.js")).mountViewer(el, data);
3426
+ if (abort.signal.aborted) return v.dispose();
3427
+ mounted = v;
3428
+ setSize(data.byteLength);
3429
+ setViewer(v);
3430
+ content.loaded?.(version);
3431
+ }).catch((err) => {
3432
+ if (abort.signal.aborted) return;
3433
+ setError(err instanceof TooLarge ? t("viewer.tooLarge", {
3434
+ size: (0, _deepseek_ai_dsh_client_ui_primitives.fileSizeText)(err.size),
3435
+ limit: (0, _deepseek_ai_dsh_client_ui_primitives.fileSizeText)(MAX_GLB)
3436
+ }) : String(err?.message ?? err));
3437
+ content.failed?.();
3438
+ });
3439
+ return () => {
3440
+ abort.abort();
3441
+ mounted?.dispose();
3442
+ };
3443
+ }, [
3444
+ content.kind,
3445
+ content.revision,
3446
+ resourceAddress
3447
+ ]);
3448
+ const toggle = () => {
3449
+ viewer?.setAutoRotate(!spinning);
3450
+ setSpinning(!spinning);
3451
+ };
3452
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3453
+ className: "meshy-root meshy-viewer",
3454
+ children: [
3455
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3456
+ ref: host,
3457
+ className: "meshy-stage"
3458
+ }),
3459
+ !viewer && !error && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3460
+ className: "meshy-overlay meshy-muted",
3461
+ children: [
3462
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Logo, {}),
3463
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.TextShimmer, {
3464
+ active: true,
3465
+ children: t("viewer.loading")
3466
+ }),
3467
+ progress && progress[1] > WINDOW && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3468
+ className: "meshy-small",
3469
+ children: [
3470
+ (0, _deepseek_ai_dsh_client_ui_primitives.fileSizeText)(progress[0]),
3471
+ " / ",
3472
+ (0, _deepseek_ai_dsh_client_ui_primitives.fileSizeText)(progress[1])
3473
+ ]
3474
+ })
3475
+ ]
3476
+ }),
3477
+ error && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3478
+ className: "meshy-overlay",
3479
+ role: "alert",
3480
+ children: [
3481
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconWarningOutlineRegular, { size: 20 }),
3482
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("viewer.failed") }),
3483
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3484
+ className: "meshy-muted meshy-small",
3485
+ children: error
3486
+ })
3487
+ ]
3488
+ }),
3489
+ viewer && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3490
+ className: "meshy-bar",
3491
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3492
+ className: "meshy-chip",
3493
+ children: [
3494
+ (0, _deepseek_ai_dsh_client_ui_primitives.fileSizeText)(size),
3495
+ " · ",
3496
+ t("viewer.triangles", { count: viewer.triangles.toLocaleString() })
3497
+ ]
3498
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3499
+ className: "meshy-tools",
3500
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
3501
+ label: t("viewer.reset"),
3502
+ side: "top",
3503
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3504
+ variant: "ghost",
3505
+ size: "sm",
3506
+ "aria-label": t("viewer.reset"),
3507
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRefreshOutlineRegular, { size: 14 }),
3508
+ onClick: () => viewer.reset()
3509
+ })
3510
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
3511
+ label: spinning ? t("viewer.stop") : t("viewer.spin"),
3512
+ side: "top",
3513
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3514
+ variant: "ghost",
3515
+ size: "sm",
3516
+ "aria-label": spinning ? t("viewer.stop") : t("viewer.spin"),
3517
+ "aria-pressed": spinning,
3518
+ icon: spinning ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPauseOutlineRegular, { size: 14 }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPlayOutlineRegular, { size: 14 }),
3519
+ onClick: toggle
3520
+ })
3521
+ })]
3522
+ })]
3523
+ })
3524
+ ]
3525
+ });
3526
+ }
3527
+ function apply(ctx) {
3528
+ ctx.effect(() => ctx.locale.register(NS, {
3529
+ zh,
3530
+ en
3531
+ }), "meshy-dsh: dictionaries");
3532
+ ctx.effect(() => ctx.slots.inject("settings.section", () => ctx.slots.register({
3533
+ name: "settings.section",
3534
+ id: "meshy",
3535
+ order: 40,
3536
+ label: () => ctx.locale.bind(NS)("nav"),
3537
+ locale: NS
3538
+ }, MeshyPanel)), "meshy-dsh: settings section");
3539
+ ctx.effect(() => ctx.slots.inject("plugins.bundle.config", () => ctx.slots.register({
3540
+ name: "plugins.bundle.config",
3541
+ key: "meshy-dsh",
3542
+ locale: NS
3543
+ }, MeshyPanel)), "meshy-dsh: bundle page");
3544
+ ctx.inject([
3545
+ "layout",
3546
+ "slots",
3547
+ "locale"
3548
+ ], (ctx) => {
3549
+ ctx.effect(() => ctx.slots.inject("main", () => ctx.slots.register({
3550
+ name: "main",
3551
+ key: PAGE_ID,
3552
+ locale: NS
3553
+ }, MeshyPage)), "meshy-dsh: page");
3554
+ ctx.effect(() => ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
3555
+ name: "sidebar.panellist",
3556
+ id: PAGE_ID,
3557
+ order: 20,
3558
+ label: "Meshy"
3559
+ }, MeshySidebarIcon)), "meshy-dsh: sidebar entry");
3560
+ });
3561
+ ctx.inject(["uiWorkspace"], (ctx) => {
3562
+ ctx.effect(() => {
3563
+ startSession = (prompt) => ctx.uiWorkspace.startSession(void 0, {
3564
+ prompt,
3565
+ whenDraftExists: "replace"
3566
+ });
3567
+ return () => {
3568
+ startSession = void 0;
3569
+ };
3570
+ }, "meshy-dsh: start a session from an example");
3571
+ });
3572
+ ctx.inject([
3573
+ "documentPreviews",
3574
+ "slots",
3575
+ "locale",
3576
+ "remote",
3577
+ "remote.workspaceFiles"
3578
+ ], (ctx) => {
3579
+ ctx.effect(() => {
3580
+ workspaceFiles = ctx.remote.workspaceFiles;
3581
+ return () => {
3582
+ workspaceFiles = void 0;
3583
+ };
3584
+ }, "meshy-dsh: workspace file reads");
3585
+ ctx.effect(() => ctx.documentPreviews.register({
3586
+ id: GLB_ID,
3587
+ extensions: ["glb"],
3588
+ binaryExtensions: ["glb"],
3589
+ priority: "extension",
3590
+ title: () => ctx.locale.bind(NS)("viewer.title"),
3591
+ loading: "renderer"
3592
+ }), "meshy-dsh: glb preview");
3593
+ ctx.effect(() => ctx.slots.inject("sidebar.right.tab.document", () => ctx.slots.register({
3594
+ name: "sidebar.right.tab.document",
3595
+ key: GLB_ID,
3596
+ locale: NS
3597
+ }, GlbBody)), "meshy-dsh: glb body");
3598
+ });
3599
+ }
3600
+
3601
+ exports.apply = apply;
3602
+ exports.inject = inject;
3603
+ exports.name = name;
3604
+ return module.exports; } });