@ddtcorex/dsh-maestro-config 0.1.0
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/README.md +10 -0
- package/cordis.patch.yml +6 -0
- package/lib/client.js +3028 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +44 -0
- package/lib/index.js.map +1 -0
- package/lib/service.d.ts +16 -0
- package/lib/service.d.ts.map +1 -0
- package/lib/service.js +24 -0
- package/lib/service.js.map +1 -0
- package/lib/types/client/api.d.ts +23 -0
- package/lib/types/client/api.d.ts.map +1 -0
- package/lib/types/client/index.d.ts +7 -0
- package/lib/types/client/index.d.ts.map +1 -0
- package/lib/types/client/maestro-card.d.ts +9 -0
- package/lib/types/client/maestro-card.d.ts.map +1 -0
- package/lib/types/client/settings-nav-icon.d.ts +21 -0
- package/lib/types/client/settings-nav-icon.d.ts.map +1 -0
- package/lib/types/client/webhook-secret.d.ts +5 -0
- package/lib/types/client/webhook-secret.d.ts.map +1 -0
- package/package.json +65 -0
- package/src/client/api.ts +23 -0
- package/src/client/index.tsx +79 -0
- package/src/client/maestro-card.jsx +702 -0
- package/src/client/settings-nav-icon.ts +68 -0
- package/src/client/webhook-secret.ts +13 -0
- package/src/host/index.ts +58 -0
- package/src/host/service.ts +33 -0
package/lib/client.js
ADDED
|
@@ -0,0 +1,3028 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: '@ddtcorex/dsh-maestro-config',
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
var React = require("react");
|
|
7
|
+
"use strict";
|
|
8
|
+
var __create = Object.create;
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
15
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
+
};
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name2 in all)
|
|
19
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
20
|
+
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(from))
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
|
|
39
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js
|
|
40
|
+
var require_can_promise = __commonJS({
|
|
41
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js"(exports, module2) {
|
|
42
|
+
module2.exports = function() {
|
|
43
|
+
return typeof Promise === "function" && Promise.prototype && Promise.prototype.then;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js
|
|
49
|
+
var require_utils = __commonJS({
|
|
50
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"(exports) {
|
|
51
|
+
var toSJISFunction;
|
|
52
|
+
var CODEWORDS_COUNT = [
|
|
53
|
+
0,
|
|
54
|
+
// Not used
|
|
55
|
+
26,
|
|
56
|
+
44,
|
|
57
|
+
70,
|
|
58
|
+
100,
|
|
59
|
+
134,
|
|
60
|
+
172,
|
|
61
|
+
196,
|
|
62
|
+
242,
|
|
63
|
+
292,
|
|
64
|
+
346,
|
|
65
|
+
404,
|
|
66
|
+
466,
|
|
67
|
+
532,
|
|
68
|
+
581,
|
|
69
|
+
655,
|
|
70
|
+
733,
|
|
71
|
+
815,
|
|
72
|
+
901,
|
|
73
|
+
991,
|
|
74
|
+
1085,
|
|
75
|
+
1156,
|
|
76
|
+
1258,
|
|
77
|
+
1364,
|
|
78
|
+
1474,
|
|
79
|
+
1588,
|
|
80
|
+
1706,
|
|
81
|
+
1828,
|
|
82
|
+
1921,
|
|
83
|
+
2051,
|
|
84
|
+
2185,
|
|
85
|
+
2323,
|
|
86
|
+
2465,
|
|
87
|
+
2611,
|
|
88
|
+
2761,
|
|
89
|
+
2876,
|
|
90
|
+
3034,
|
|
91
|
+
3196,
|
|
92
|
+
3362,
|
|
93
|
+
3532,
|
|
94
|
+
3706
|
|
95
|
+
];
|
|
96
|
+
exports.getSymbolSize = function getSymbolSize(version) {
|
|
97
|
+
if (!version) throw new Error('"version" cannot be null or undefined');
|
|
98
|
+
if (version < 1 || version > 40) throw new Error('"version" should be in range from 1 to 40');
|
|
99
|
+
return version * 4 + 17;
|
|
100
|
+
};
|
|
101
|
+
exports.getSymbolTotalCodewords = function getSymbolTotalCodewords(version) {
|
|
102
|
+
return CODEWORDS_COUNT[version];
|
|
103
|
+
};
|
|
104
|
+
exports.getBCHDigit = function(data) {
|
|
105
|
+
let digit = 0;
|
|
106
|
+
while (data !== 0) {
|
|
107
|
+
digit++;
|
|
108
|
+
data >>>= 1;
|
|
109
|
+
}
|
|
110
|
+
return digit;
|
|
111
|
+
};
|
|
112
|
+
exports.setToSJISFunction = function setToSJISFunction(f) {
|
|
113
|
+
if (typeof f !== "function") {
|
|
114
|
+
throw new Error('"toSJISFunc" is not a valid function.');
|
|
115
|
+
}
|
|
116
|
+
toSJISFunction = f;
|
|
117
|
+
};
|
|
118
|
+
exports.isKanjiModeEnabled = function() {
|
|
119
|
+
return typeof toSJISFunction !== "undefined";
|
|
120
|
+
};
|
|
121
|
+
exports.toSJIS = function toSJIS(kanji) {
|
|
122
|
+
return toSJISFunction(kanji);
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js
|
|
128
|
+
var require_error_correction_level = __commonJS({
|
|
129
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js"(exports) {
|
|
130
|
+
exports.L = { bit: 1 };
|
|
131
|
+
exports.M = { bit: 0 };
|
|
132
|
+
exports.Q = { bit: 3 };
|
|
133
|
+
exports.H = { bit: 2 };
|
|
134
|
+
function fromString(string) {
|
|
135
|
+
if (typeof string !== "string") {
|
|
136
|
+
throw new Error("Param is not a string");
|
|
137
|
+
}
|
|
138
|
+
const lcStr = string.toLowerCase();
|
|
139
|
+
switch (lcStr) {
|
|
140
|
+
case "l":
|
|
141
|
+
case "low":
|
|
142
|
+
return exports.L;
|
|
143
|
+
case "m":
|
|
144
|
+
case "medium":
|
|
145
|
+
return exports.M;
|
|
146
|
+
case "q":
|
|
147
|
+
case "quartile":
|
|
148
|
+
return exports.Q;
|
|
149
|
+
case "h":
|
|
150
|
+
case "high":
|
|
151
|
+
return exports.H;
|
|
152
|
+
default:
|
|
153
|
+
throw new Error("Unknown EC Level: " + string);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.isValid = function isValid(level) {
|
|
157
|
+
return level && typeof level.bit !== "undefined" && level.bit >= 0 && level.bit < 4;
|
|
158
|
+
};
|
|
159
|
+
exports.from = function from(value, defaultValue) {
|
|
160
|
+
if (exports.isValid(value)) {
|
|
161
|
+
return value;
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
return fromString(value);
|
|
165
|
+
} catch (e) {
|
|
166
|
+
return defaultValue;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js
|
|
173
|
+
var require_bit_buffer = __commonJS({
|
|
174
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js"(exports, module2) {
|
|
175
|
+
function BitBuffer() {
|
|
176
|
+
this.buffer = [];
|
|
177
|
+
this.length = 0;
|
|
178
|
+
}
|
|
179
|
+
BitBuffer.prototype = {
|
|
180
|
+
get: function(index) {
|
|
181
|
+
const bufIndex = Math.floor(index / 8);
|
|
182
|
+
return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) === 1;
|
|
183
|
+
},
|
|
184
|
+
put: function(num, length) {
|
|
185
|
+
for (let i = 0; i < length; i++) {
|
|
186
|
+
this.putBit((num >>> length - i - 1 & 1) === 1);
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
getLengthInBits: function() {
|
|
190
|
+
return this.length;
|
|
191
|
+
},
|
|
192
|
+
putBit: function(bit) {
|
|
193
|
+
const bufIndex = Math.floor(this.length / 8);
|
|
194
|
+
if (this.buffer.length <= bufIndex) {
|
|
195
|
+
this.buffer.push(0);
|
|
196
|
+
}
|
|
197
|
+
if (bit) {
|
|
198
|
+
this.buffer[bufIndex] |= 128 >>> this.length % 8;
|
|
199
|
+
}
|
|
200
|
+
this.length++;
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
module2.exports = BitBuffer;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js
|
|
208
|
+
var require_bit_matrix = __commonJS({
|
|
209
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js"(exports, module2) {
|
|
210
|
+
function BitMatrix(size) {
|
|
211
|
+
if (!size || size < 1) {
|
|
212
|
+
throw new Error("BitMatrix size must be defined and greater than 0");
|
|
213
|
+
}
|
|
214
|
+
this.size = size;
|
|
215
|
+
this.data = new Uint8Array(size * size);
|
|
216
|
+
this.reservedBit = new Uint8Array(size * size);
|
|
217
|
+
}
|
|
218
|
+
BitMatrix.prototype.set = function(row, col, value, reserved) {
|
|
219
|
+
const index = row * this.size + col;
|
|
220
|
+
this.data[index] = value;
|
|
221
|
+
if (reserved) this.reservedBit[index] = true;
|
|
222
|
+
};
|
|
223
|
+
BitMatrix.prototype.get = function(row, col) {
|
|
224
|
+
return this.data[row * this.size + col];
|
|
225
|
+
};
|
|
226
|
+
BitMatrix.prototype.xor = function(row, col, value) {
|
|
227
|
+
this.data[row * this.size + col] ^= value;
|
|
228
|
+
};
|
|
229
|
+
BitMatrix.prototype.isReserved = function(row, col) {
|
|
230
|
+
return this.reservedBit[row * this.size + col];
|
|
231
|
+
};
|
|
232
|
+
module2.exports = BitMatrix;
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js
|
|
237
|
+
var require_alignment_pattern = __commonJS({
|
|
238
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js"(exports) {
|
|
239
|
+
var getSymbolSize = require_utils().getSymbolSize;
|
|
240
|
+
exports.getRowColCoords = function getRowColCoords(version) {
|
|
241
|
+
if (version === 1) return [];
|
|
242
|
+
const posCount = Math.floor(version / 7) + 2;
|
|
243
|
+
const size = getSymbolSize(version);
|
|
244
|
+
const intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2;
|
|
245
|
+
const positions = [size - 7];
|
|
246
|
+
for (let i = 1; i < posCount - 1; i++) {
|
|
247
|
+
positions[i] = positions[i - 1] - intervals;
|
|
248
|
+
}
|
|
249
|
+
positions.push(6);
|
|
250
|
+
return positions.reverse();
|
|
251
|
+
};
|
|
252
|
+
exports.getPositions = function getPositions(version) {
|
|
253
|
+
const coords = [];
|
|
254
|
+
const pos = exports.getRowColCoords(version);
|
|
255
|
+
const posLength = pos.length;
|
|
256
|
+
for (let i = 0; i < posLength; i++) {
|
|
257
|
+
for (let j = 0; j < posLength; j++) {
|
|
258
|
+
if (i === 0 && j === 0 || // top-left
|
|
259
|
+
i === 0 && j === posLength - 1 || // bottom-left
|
|
260
|
+
i === posLength - 1 && j === 0) {
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
coords.push([pos[i], pos[j]]);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return coords;
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js
|
|
272
|
+
var require_finder_pattern = __commonJS({
|
|
273
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js"(exports) {
|
|
274
|
+
var getSymbolSize = require_utils().getSymbolSize;
|
|
275
|
+
var FINDER_PATTERN_SIZE = 7;
|
|
276
|
+
exports.getPositions = function getPositions(version) {
|
|
277
|
+
const size = getSymbolSize(version);
|
|
278
|
+
return [
|
|
279
|
+
// top-left
|
|
280
|
+
[0, 0],
|
|
281
|
+
// top-right
|
|
282
|
+
[size - FINDER_PATTERN_SIZE, 0],
|
|
283
|
+
// bottom-left
|
|
284
|
+
[0, size - FINDER_PATTERN_SIZE]
|
|
285
|
+
];
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js
|
|
291
|
+
var require_mask_pattern = __commonJS({
|
|
292
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js"(exports) {
|
|
293
|
+
exports.Patterns = {
|
|
294
|
+
PATTERN000: 0,
|
|
295
|
+
PATTERN001: 1,
|
|
296
|
+
PATTERN010: 2,
|
|
297
|
+
PATTERN011: 3,
|
|
298
|
+
PATTERN100: 4,
|
|
299
|
+
PATTERN101: 5,
|
|
300
|
+
PATTERN110: 6,
|
|
301
|
+
PATTERN111: 7
|
|
302
|
+
};
|
|
303
|
+
var PenaltyScores = {
|
|
304
|
+
N1: 3,
|
|
305
|
+
N2: 3,
|
|
306
|
+
N3: 40,
|
|
307
|
+
N4: 10
|
|
308
|
+
};
|
|
309
|
+
exports.isValid = function isValid(mask) {
|
|
310
|
+
return mask != null && mask !== "" && !isNaN(mask) && mask >= 0 && mask <= 7;
|
|
311
|
+
};
|
|
312
|
+
exports.from = function from(value) {
|
|
313
|
+
return exports.isValid(value) ? parseInt(value, 10) : void 0;
|
|
314
|
+
};
|
|
315
|
+
exports.getPenaltyN1 = function getPenaltyN1(data) {
|
|
316
|
+
const size = data.size;
|
|
317
|
+
let points = 0;
|
|
318
|
+
let sameCountCol = 0;
|
|
319
|
+
let sameCountRow = 0;
|
|
320
|
+
let lastCol = null;
|
|
321
|
+
let lastRow = null;
|
|
322
|
+
for (let row = 0; row < size; row++) {
|
|
323
|
+
sameCountCol = sameCountRow = 0;
|
|
324
|
+
lastCol = lastRow = null;
|
|
325
|
+
for (let col = 0; col < size; col++) {
|
|
326
|
+
let module3 = data.get(row, col);
|
|
327
|
+
if (module3 === lastCol) {
|
|
328
|
+
sameCountCol++;
|
|
329
|
+
} else {
|
|
330
|
+
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
|
|
331
|
+
lastCol = module3;
|
|
332
|
+
sameCountCol = 1;
|
|
333
|
+
}
|
|
334
|
+
module3 = data.get(col, row);
|
|
335
|
+
if (module3 === lastRow) {
|
|
336
|
+
sameCountRow++;
|
|
337
|
+
} else {
|
|
338
|
+
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
|
|
339
|
+
lastRow = module3;
|
|
340
|
+
sameCountRow = 1;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
|
|
344
|
+
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
|
|
345
|
+
}
|
|
346
|
+
return points;
|
|
347
|
+
};
|
|
348
|
+
exports.getPenaltyN2 = function getPenaltyN2(data) {
|
|
349
|
+
const size = data.size;
|
|
350
|
+
let points = 0;
|
|
351
|
+
for (let row = 0; row < size - 1; row++) {
|
|
352
|
+
for (let col = 0; col < size - 1; col++) {
|
|
353
|
+
const last = data.get(row, col) + data.get(row, col + 1) + data.get(row + 1, col) + data.get(row + 1, col + 1);
|
|
354
|
+
if (last === 4 || last === 0) points++;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return points * PenaltyScores.N2;
|
|
358
|
+
};
|
|
359
|
+
exports.getPenaltyN3 = function getPenaltyN3(data) {
|
|
360
|
+
const size = data.size;
|
|
361
|
+
let points = 0;
|
|
362
|
+
let bitsCol = 0;
|
|
363
|
+
let bitsRow = 0;
|
|
364
|
+
for (let row = 0; row < size; row++) {
|
|
365
|
+
bitsCol = bitsRow = 0;
|
|
366
|
+
for (let col = 0; col < size; col++) {
|
|
367
|
+
bitsCol = bitsCol << 1 & 2047 | data.get(row, col);
|
|
368
|
+
if (col >= 10 && (bitsCol === 1488 || bitsCol === 93)) points++;
|
|
369
|
+
bitsRow = bitsRow << 1 & 2047 | data.get(col, row);
|
|
370
|
+
if (col >= 10 && (bitsRow === 1488 || bitsRow === 93)) points++;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return points * PenaltyScores.N3;
|
|
374
|
+
};
|
|
375
|
+
exports.getPenaltyN4 = function getPenaltyN4(data) {
|
|
376
|
+
let darkCount = 0;
|
|
377
|
+
const modulesCount = data.data.length;
|
|
378
|
+
for (let i = 0; i < modulesCount; i++) darkCount += data.data[i];
|
|
379
|
+
const k = Math.abs(Math.ceil(darkCount * 100 / modulesCount / 5) - 10);
|
|
380
|
+
return k * PenaltyScores.N4;
|
|
381
|
+
};
|
|
382
|
+
function getMaskAt(maskPattern, i, j) {
|
|
383
|
+
switch (maskPattern) {
|
|
384
|
+
case exports.Patterns.PATTERN000:
|
|
385
|
+
return (i + j) % 2 === 0;
|
|
386
|
+
case exports.Patterns.PATTERN001:
|
|
387
|
+
return i % 2 === 0;
|
|
388
|
+
case exports.Patterns.PATTERN010:
|
|
389
|
+
return j % 3 === 0;
|
|
390
|
+
case exports.Patterns.PATTERN011:
|
|
391
|
+
return (i + j) % 3 === 0;
|
|
392
|
+
case exports.Patterns.PATTERN100:
|
|
393
|
+
return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0;
|
|
394
|
+
case exports.Patterns.PATTERN101:
|
|
395
|
+
return i * j % 2 + i * j % 3 === 0;
|
|
396
|
+
case exports.Patterns.PATTERN110:
|
|
397
|
+
return (i * j % 2 + i * j % 3) % 2 === 0;
|
|
398
|
+
case exports.Patterns.PATTERN111:
|
|
399
|
+
return (i * j % 3 + (i + j) % 2) % 2 === 0;
|
|
400
|
+
default:
|
|
401
|
+
throw new Error("bad maskPattern:" + maskPattern);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
exports.applyMask = function applyMask(pattern, data) {
|
|
405
|
+
const size = data.size;
|
|
406
|
+
for (let col = 0; col < size; col++) {
|
|
407
|
+
for (let row = 0; row < size; row++) {
|
|
408
|
+
if (data.isReserved(row, col)) continue;
|
|
409
|
+
data.xor(row, col, getMaskAt(pattern, row, col));
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
exports.getBestMask = function getBestMask(data, setupFormatFunc) {
|
|
414
|
+
const numPatterns = Object.keys(exports.Patterns).length;
|
|
415
|
+
let bestPattern = 0;
|
|
416
|
+
let lowerPenalty = Infinity;
|
|
417
|
+
for (let p = 0; p < numPatterns; p++) {
|
|
418
|
+
setupFormatFunc(p);
|
|
419
|
+
exports.applyMask(p, data);
|
|
420
|
+
const penalty = exports.getPenaltyN1(data) + exports.getPenaltyN2(data) + exports.getPenaltyN3(data) + exports.getPenaltyN4(data);
|
|
421
|
+
exports.applyMask(p, data);
|
|
422
|
+
if (penalty < lowerPenalty) {
|
|
423
|
+
lowerPenalty = penalty;
|
|
424
|
+
bestPattern = p;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return bestPattern;
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js
|
|
433
|
+
var require_error_correction_code = __commonJS({
|
|
434
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js"(exports) {
|
|
435
|
+
var ECLevel = require_error_correction_level();
|
|
436
|
+
var EC_BLOCKS_TABLE = [
|
|
437
|
+
// L M Q H
|
|
438
|
+
1,
|
|
439
|
+
1,
|
|
440
|
+
1,
|
|
441
|
+
1,
|
|
442
|
+
1,
|
|
443
|
+
1,
|
|
444
|
+
1,
|
|
445
|
+
1,
|
|
446
|
+
1,
|
|
447
|
+
1,
|
|
448
|
+
2,
|
|
449
|
+
2,
|
|
450
|
+
1,
|
|
451
|
+
2,
|
|
452
|
+
2,
|
|
453
|
+
4,
|
|
454
|
+
1,
|
|
455
|
+
2,
|
|
456
|
+
4,
|
|
457
|
+
4,
|
|
458
|
+
2,
|
|
459
|
+
4,
|
|
460
|
+
4,
|
|
461
|
+
4,
|
|
462
|
+
2,
|
|
463
|
+
4,
|
|
464
|
+
6,
|
|
465
|
+
5,
|
|
466
|
+
2,
|
|
467
|
+
4,
|
|
468
|
+
6,
|
|
469
|
+
6,
|
|
470
|
+
2,
|
|
471
|
+
5,
|
|
472
|
+
8,
|
|
473
|
+
8,
|
|
474
|
+
4,
|
|
475
|
+
5,
|
|
476
|
+
8,
|
|
477
|
+
8,
|
|
478
|
+
4,
|
|
479
|
+
5,
|
|
480
|
+
8,
|
|
481
|
+
11,
|
|
482
|
+
4,
|
|
483
|
+
8,
|
|
484
|
+
10,
|
|
485
|
+
11,
|
|
486
|
+
4,
|
|
487
|
+
9,
|
|
488
|
+
12,
|
|
489
|
+
16,
|
|
490
|
+
4,
|
|
491
|
+
9,
|
|
492
|
+
16,
|
|
493
|
+
16,
|
|
494
|
+
6,
|
|
495
|
+
10,
|
|
496
|
+
12,
|
|
497
|
+
18,
|
|
498
|
+
6,
|
|
499
|
+
10,
|
|
500
|
+
17,
|
|
501
|
+
16,
|
|
502
|
+
6,
|
|
503
|
+
11,
|
|
504
|
+
16,
|
|
505
|
+
19,
|
|
506
|
+
6,
|
|
507
|
+
13,
|
|
508
|
+
18,
|
|
509
|
+
21,
|
|
510
|
+
7,
|
|
511
|
+
14,
|
|
512
|
+
21,
|
|
513
|
+
25,
|
|
514
|
+
8,
|
|
515
|
+
16,
|
|
516
|
+
20,
|
|
517
|
+
25,
|
|
518
|
+
8,
|
|
519
|
+
17,
|
|
520
|
+
23,
|
|
521
|
+
25,
|
|
522
|
+
9,
|
|
523
|
+
17,
|
|
524
|
+
23,
|
|
525
|
+
34,
|
|
526
|
+
9,
|
|
527
|
+
18,
|
|
528
|
+
25,
|
|
529
|
+
30,
|
|
530
|
+
10,
|
|
531
|
+
20,
|
|
532
|
+
27,
|
|
533
|
+
32,
|
|
534
|
+
12,
|
|
535
|
+
21,
|
|
536
|
+
29,
|
|
537
|
+
35,
|
|
538
|
+
12,
|
|
539
|
+
23,
|
|
540
|
+
34,
|
|
541
|
+
37,
|
|
542
|
+
12,
|
|
543
|
+
25,
|
|
544
|
+
34,
|
|
545
|
+
40,
|
|
546
|
+
13,
|
|
547
|
+
26,
|
|
548
|
+
35,
|
|
549
|
+
42,
|
|
550
|
+
14,
|
|
551
|
+
28,
|
|
552
|
+
38,
|
|
553
|
+
45,
|
|
554
|
+
15,
|
|
555
|
+
29,
|
|
556
|
+
40,
|
|
557
|
+
48,
|
|
558
|
+
16,
|
|
559
|
+
31,
|
|
560
|
+
43,
|
|
561
|
+
51,
|
|
562
|
+
17,
|
|
563
|
+
33,
|
|
564
|
+
45,
|
|
565
|
+
54,
|
|
566
|
+
18,
|
|
567
|
+
35,
|
|
568
|
+
48,
|
|
569
|
+
57,
|
|
570
|
+
19,
|
|
571
|
+
37,
|
|
572
|
+
51,
|
|
573
|
+
60,
|
|
574
|
+
19,
|
|
575
|
+
38,
|
|
576
|
+
53,
|
|
577
|
+
63,
|
|
578
|
+
20,
|
|
579
|
+
40,
|
|
580
|
+
56,
|
|
581
|
+
66,
|
|
582
|
+
21,
|
|
583
|
+
43,
|
|
584
|
+
59,
|
|
585
|
+
70,
|
|
586
|
+
22,
|
|
587
|
+
45,
|
|
588
|
+
62,
|
|
589
|
+
74,
|
|
590
|
+
24,
|
|
591
|
+
47,
|
|
592
|
+
65,
|
|
593
|
+
77,
|
|
594
|
+
25,
|
|
595
|
+
49,
|
|
596
|
+
68,
|
|
597
|
+
81
|
|
598
|
+
];
|
|
599
|
+
var EC_CODEWORDS_TABLE = [
|
|
600
|
+
// L M Q H
|
|
601
|
+
7,
|
|
602
|
+
10,
|
|
603
|
+
13,
|
|
604
|
+
17,
|
|
605
|
+
10,
|
|
606
|
+
16,
|
|
607
|
+
22,
|
|
608
|
+
28,
|
|
609
|
+
15,
|
|
610
|
+
26,
|
|
611
|
+
36,
|
|
612
|
+
44,
|
|
613
|
+
20,
|
|
614
|
+
36,
|
|
615
|
+
52,
|
|
616
|
+
64,
|
|
617
|
+
26,
|
|
618
|
+
48,
|
|
619
|
+
72,
|
|
620
|
+
88,
|
|
621
|
+
36,
|
|
622
|
+
64,
|
|
623
|
+
96,
|
|
624
|
+
112,
|
|
625
|
+
40,
|
|
626
|
+
72,
|
|
627
|
+
108,
|
|
628
|
+
130,
|
|
629
|
+
48,
|
|
630
|
+
88,
|
|
631
|
+
132,
|
|
632
|
+
156,
|
|
633
|
+
60,
|
|
634
|
+
110,
|
|
635
|
+
160,
|
|
636
|
+
192,
|
|
637
|
+
72,
|
|
638
|
+
130,
|
|
639
|
+
192,
|
|
640
|
+
224,
|
|
641
|
+
80,
|
|
642
|
+
150,
|
|
643
|
+
224,
|
|
644
|
+
264,
|
|
645
|
+
96,
|
|
646
|
+
176,
|
|
647
|
+
260,
|
|
648
|
+
308,
|
|
649
|
+
104,
|
|
650
|
+
198,
|
|
651
|
+
288,
|
|
652
|
+
352,
|
|
653
|
+
120,
|
|
654
|
+
216,
|
|
655
|
+
320,
|
|
656
|
+
384,
|
|
657
|
+
132,
|
|
658
|
+
240,
|
|
659
|
+
360,
|
|
660
|
+
432,
|
|
661
|
+
144,
|
|
662
|
+
280,
|
|
663
|
+
408,
|
|
664
|
+
480,
|
|
665
|
+
168,
|
|
666
|
+
308,
|
|
667
|
+
448,
|
|
668
|
+
532,
|
|
669
|
+
180,
|
|
670
|
+
338,
|
|
671
|
+
504,
|
|
672
|
+
588,
|
|
673
|
+
196,
|
|
674
|
+
364,
|
|
675
|
+
546,
|
|
676
|
+
650,
|
|
677
|
+
224,
|
|
678
|
+
416,
|
|
679
|
+
600,
|
|
680
|
+
700,
|
|
681
|
+
224,
|
|
682
|
+
442,
|
|
683
|
+
644,
|
|
684
|
+
750,
|
|
685
|
+
252,
|
|
686
|
+
476,
|
|
687
|
+
690,
|
|
688
|
+
816,
|
|
689
|
+
270,
|
|
690
|
+
504,
|
|
691
|
+
750,
|
|
692
|
+
900,
|
|
693
|
+
300,
|
|
694
|
+
560,
|
|
695
|
+
810,
|
|
696
|
+
960,
|
|
697
|
+
312,
|
|
698
|
+
588,
|
|
699
|
+
870,
|
|
700
|
+
1050,
|
|
701
|
+
336,
|
|
702
|
+
644,
|
|
703
|
+
952,
|
|
704
|
+
1110,
|
|
705
|
+
360,
|
|
706
|
+
700,
|
|
707
|
+
1020,
|
|
708
|
+
1200,
|
|
709
|
+
390,
|
|
710
|
+
728,
|
|
711
|
+
1050,
|
|
712
|
+
1260,
|
|
713
|
+
420,
|
|
714
|
+
784,
|
|
715
|
+
1140,
|
|
716
|
+
1350,
|
|
717
|
+
450,
|
|
718
|
+
812,
|
|
719
|
+
1200,
|
|
720
|
+
1440,
|
|
721
|
+
480,
|
|
722
|
+
868,
|
|
723
|
+
1290,
|
|
724
|
+
1530,
|
|
725
|
+
510,
|
|
726
|
+
924,
|
|
727
|
+
1350,
|
|
728
|
+
1620,
|
|
729
|
+
540,
|
|
730
|
+
980,
|
|
731
|
+
1440,
|
|
732
|
+
1710,
|
|
733
|
+
570,
|
|
734
|
+
1036,
|
|
735
|
+
1530,
|
|
736
|
+
1800,
|
|
737
|
+
570,
|
|
738
|
+
1064,
|
|
739
|
+
1590,
|
|
740
|
+
1890,
|
|
741
|
+
600,
|
|
742
|
+
1120,
|
|
743
|
+
1680,
|
|
744
|
+
1980,
|
|
745
|
+
630,
|
|
746
|
+
1204,
|
|
747
|
+
1770,
|
|
748
|
+
2100,
|
|
749
|
+
660,
|
|
750
|
+
1260,
|
|
751
|
+
1860,
|
|
752
|
+
2220,
|
|
753
|
+
720,
|
|
754
|
+
1316,
|
|
755
|
+
1950,
|
|
756
|
+
2310,
|
|
757
|
+
750,
|
|
758
|
+
1372,
|
|
759
|
+
2040,
|
|
760
|
+
2430
|
|
761
|
+
];
|
|
762
|
+
exports.getBlocksCount = function getBlocksCount(version, errorCorrectionLevel) {
|
|
763
|
+
switch (errorCorrectionLevel) {
|
|
764
|
+
case ECLevel.L:
|
|
765
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 0];
|
|
766
|
+
case ECLevel.M:
|
|
767
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 1];
|
|
768
|
+
case ECLevel.Q:
|
|
769
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 2];
|
|
770
|
+
case ECLevel.H:
|
|
771
|
+
return EC_BLOCKS_TABLE[(version - 1) * 4 + 3];
|
|
772
|
+
default:
|
|
773
|
+
return void 0;
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
exports.getTotalCodewordsCount = function getTotalCodewordsCount(version, errorCorrectionLevel) {
|
|
777
|
+
switch (errorCorrectionLevel) {
|
|
778
|
+
case ECLevel.L:
|
|
779
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0];
|
|
780
|
+
case ECLevel.M:
|
|
781
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1];
|
|
782
|
+
case ECLevel.Q:
|
|
783
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2];
|
|
784
|
+
case ECLevel.H:
|
|
785
|
+
return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3];
|
|
786
|
+
default:
|
|
787
|
+
return void 0;
|
|
788
|
+
}
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
});
|
|
792
|
+
|
|
793
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js
|
|
794
|
+
var require_galois_field = __commonJS({
|
|
795
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js"(exports) {
|
|
796
|
+
var EXP_TABLE = new Uint8Array(512);
|
|
797
|
+
var LOG_TABLE = new Uint8Array(256);
|
|
798
|
+
(function initTables() {
|
|
799
|
+
let x = 1;
|
|
800
|
+
for (let i = 0; i < 255; i++) {
|
|
801
|
+
EXP_TABLE[i] = x;
|
|
802
|
+
LOG_TABLE[x] = i;
|
|
803
|
+
x <<= 1;
|
|
804
|
+
if (x & 256) {
|
|
805
|
+
x ^= 285;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
for (let i = 255; i < 512; i++) {
|
|
809
|
+
EXP_TABLE[i] = EXP_TABLE[i - 255];
|
|
810
|
+
}
|
|
811
|
+
})();
|
|
812
|
+
exports.log = function log(n) {
|
|
813
|
+
if (n < 1) throw new Error("log(" + n + ")");
|
|
814
|
+
return LOG_TABLE[n];
|
|
815
|
+
};
|
|
816
|
+
exports.exp = function exp(n) {
|
|
817
|
+
return EXP_TABLE[n];
|
|
818
|
+
};
|
|
819
|
+
exports.mul = function mul(x, y) {
|
|
820
|
+
if (x === 0 || y === 0) return 0;
|
|
821
|
+
return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]];
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
});
|
|
825
|
+
|
|
826
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js
|
|
827
|
+
var require_polynomial = __commonJS({
|
|
828
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js"(exports) {
|
|
829
|
+
var GF = require_galois_field();
|
|
830
|
+
exports.mul = function mul(p1, p2) {
|
|
831
|
+
const coeff = new Uint8Array(p1.length + p2.length - 1);
|
|
832
|
+
for (let i = 0; i < p1.length; i++) {
|
|
833
|
+
for (let j = 0; j < p2.length; j++) {
|
|
834
|
+
coeff[i + j] ^= GF.mul(p1[i], p2[j]);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
return coeff;
|
|
838
|
+
};
|
|
839
|
+
exports.mod = function mod(divident, divisor) {
|
|
840
|
+
let result = new Uint8Array(divident);
|
|
841
|
+
while (result.length - divisor.length >= 0) {
|
|
842
|
+
const coeff = result[0];
|
|
843
|
+
for (let i = 0; i < divisor.length; i++) {
|
|
844
|
+
result[i] ^= GF.mul(divisor[i], coeff);
|
|
845
|
+
}
|
|
846
|
+
let offset = 0;
|
|
847
|
+
while (offset < result.length && result[offset] === 0) offset++;
|
|
848
|
+
result = result.slice(offset);
|
|
849
|
+
}
|
|
850
|
+
return result;
|
|
851
|
+
};
|
|
852
|
+
exports.generateECPolynomial = function generateECPolynomial(degree) {
|
|
853
|
+
let poly = new Uint8Array([1]);
|
|
854
|
+
for (let i = 0; i < degree; i++) {
|
|
855
|
+
poly = exports.mul(poly, new Uint8Array([1, GF.exp(i)]));
|
|
856
|
+
}
|
|
857
|
+
return poly;
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
});
|
|
861
|
+
|
|
862
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js
|
|
863
|
+
var require_reed_solomon_encoder = __commonJS({
|
|
864
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js"(exports, module2) {
|
|
865
|
+
var Polynomial = require_polynomial();
|
|
866
|
+
function ReedSolomonEncoder(degree) {
|
|
867
|
+
this.genPoly = void 0;
|
|
868
|
+
this.degree = degree;
|
|
869
|
+
if (this.degree) this.initialize(this.degree);
|
|
870
|
+
}
|
|
871
|
+
ReedSolomonEncoder.prototype.initialize = function initialize(degree) {
|
|
872
|
+
this.degree = degree;
|
|
873
|
+
this.genPoly = Polynomial.generateECPolynomial(this.degree);
|
|
874
|
+
};
|
|
875
|
+
ReedSolomonEncoder.prototype.encode = function encode(data) {
|
|
876
|
+
if (!this.genPoly) {
|
|
877
|
+
throw new Error("Encoder not initialized");
|
|
878
|
+
}
|
|
879
|
+
const paddedData = new Uint8Array(data.length + this.degree);
|
|
880
|
+
paddedData.set(data);
|
|
881
|
+
const remainder = Polynomial.mod(paddedData, this.genPoly);
|
|
882
|
+
const start = this.degree - remainder.length;
|
|
883
|
+
if (start > 0) {
|
|
884
|
+
const buff = new Uint8Array(this.degree);
|
|
885
|
+
buff.set(remainder, start);
|
|
886
|
+
return buff;
|
|
887
|
+
}
|
|
888
|
+
return remainder;
|
|
889
|
+
};
|
|
890
|
+
module2.exports = ReedSolomonEncoder;
|
|
891
|
+
}
|
|
892
|
+
});
|
|
893
|
+
|
|
894
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js
|
|
895
|
+
var require_version_check = __commonJS({
|
|
896
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js"(exports) {
|
|
897
|
+
exports.isValid = function isValid(version) {
|
|
898
|
+
return !isNaN(version) && version >= 1 && version <= 40;
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
});
|
|
902
|
+
|
|
903
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js
|
|
904
|
+
var require_regex = __commonJS({
|
|
905
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js"(exports) {
|
|
906
|
+
var numeric = "[0-9]+";
|
|
907
|
+
var alphanumeric = "[A-Z $%*+\\-./:]+";
|
|
908
|
+
var kanji = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";
|
|
909
|
+
kanji = kanji.replace(/u/g, "\\u");
|
|
910
|
+
var byte = "(?:(?![A-Z0-9 $%*+\\-./:]|" + kanji + ")(?:.|[\r\n]))+";
|
|
911
|
+
exports.KANJI = new RegExp(kanji, "g");
|
|
912
|
+
exports.BYTE_KANJI = new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g");
|
|
913
|
+
exports.BYTE = new RegExp(byte, "g");
|
|
914
|
+
exports.NUMERIC = new RegExp(numeric, "g");
|
|
915
|
+
exports.ALPHANUMERIC = new RegExp(alphanumeric, "g");
|
|
916
|
+
var TEST_KANJI = new RegExp("^" + kanji + "$");
|
|
917
|
+
var TEST_NUMERIC = new RegExp("^" + numeric + "$");
|
|
918
|
+
var TEST_ALPHANUMERIC = new RegExp("^[A-Z0-9 $%*+\\-./:]+$");
|
|
919
|
+
exports.testKanji = function testKanji(str) {
|
|
920
|
+
return TEST_KANJI.test(str);
|
|
921
|
+
};
|
|
922
|
+
exports.testNumeric = function testNumeric(str) {
|
|
923
|
+
return TEST_NUMERIC.test(str);
|
|
924
|
+
};
|
|
925
|
+
exports.testAlphanumeric = function testAlphanumeric(str) {
|
|
926
|
+
return TEST_ALPHANUMERIC.test(str);
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
});
|
|
930
|
+
|
|
931
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js
|
|
932
|
+
var require_mode = __commonJS({
|
|
933
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"(exports) {
|
|
934
|
+
var VersionCheck = require_version_check();
|
|
935
|
+
var Regex = require_regex();
|
|
936
|
+
exports.NUMERIC = {
|
|
937
|
+
id: "Numeric",
|
|
938
|
+
bit: 1 << 0,
|
|
939
|
+
ccBits: [10, 12, 14]
|
|
940
|
+
};
|
|
941
|
+
exports.ALPHANUMERIC = {
|
|
942
|
+
id: "Alphanumeric",
|
|
943
|
+
bit: 1 << 1,
|
|
944
|
+
ccBits: [9, 11, 13]
|
|
945
|
+
};
|
|
946
|
+
exports.BYTE = {
|
|
947
|
+
id: "Byte",
|
|
948
|
+
bit: 1 << 2,
|
|
949
|
+
ccBits: [8, 16, 16]
|
|
950
|
+
};
|
|
951
|
+
exports.KANJI = {
|
|
952
|
+
id: "Kanji",
|
|
953
|
+
bit: 1 << 3,
|
|
954
|
+
ccBits: [8, 10, 12]
|
|
955
|
+
};
|
|
956
|
+
exports.MIXED = {
|
|
957
|
+
bit: -1
|
|
958
|
+
};
|
|
959
|
+
exports.getCharCountIndicator = function getCharCountIndicator(mode, version) {
|
|
960
|
+
if (!mode.ccBits) throw new Error("Invalid mode: " + mode);
|
|
961
|
+
if (!VersionCheck.isValid(version)) {
|
|
962
|
+
throw new Error("Invalid version: " + version);
|
|
963
|
+
}
|
|
964
|
+
if (version >= 1 && version < 10) return mode.ccBits[0];
|
|
965
|
+
else if (version < 27) return mode.ccBits[1];
|
|
966
|
+
return mode.ccBits[2];
|
|
967
|
+
};
|
|
968
|
+
exports.getBestModeForData = function getBestModeForData(dataStr) {
|
|
969
|
+
if (Regex.testNumeric(dataStr)) return exports.NUMERIC;
|
|
970
|
+
else if (Regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC;
|
|
971
|
+
else if (Regex.testKanji(dataStr)) return exports.KANJI;
|
|
972
|
+
else return exports.BYTE;
|
|
973
|
+
};
|
|
974
|
+
exports.toString = function toString(mode) {
|
|
975
|
+
if (mode && mode.id) return mode.id;
|
|
976
|
+
throw new Error("Invalid mode");
|
|
977
|
+
};
|
|
978
|
+
exports.isValid = function isValid(mode) {
|
|
979
|
+
return mode && mode.bit && mode.ccBits;
|
|
980
|
+
};
|
|
981
|
+
function fromString(string) {
|
|
982
|
+
if (typeof string !== "string") {
|
|
983
|
+
throw new Error("Param is not a string");
|
|
984
|
+
}
|
|
985
|
+
const lcStr = string.toLowerCase();
|
|
986
|
+
switch (lcStr) {
|
|
987
|
+
case "numeric":
|
|
988
|
+
return exports.NUMERIC;
|
|
989
|
+
case "alphanumeric":
|
|
990
|
+
return exports.ALPHANUMERIC;
|
|
991
|
+
case "kanji":
|
|
992
|
+
return exports.KANJI;
|
|
993
|
+
case "byte":
|
|
994
|
+
return exports.BYTE;
|
|
995
|
+
default:
|
|
996
|
+
throw new Error("Unknown mode: " + string);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
exports.from = function from(value, defaultValue) {
|
|
1000
|
+
if (exports.isValid(value)) {
|
|
1001
|
+
return value;
|
|
1002
|
+
}
|
|
1003
|
+
try {
|
|
1004
|
+
return fromString(value);
|
|
1005
|
+
} catch (e) {
|
|
1006
|
+
return defaultValue;
|
|
1007
|
+
}
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
});
|
|
1011
|
+
|
|
1012
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js
|
|
1013
|
+
var require_version = __commonJS({
|
|
1014
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js"(exports) {
|
|
1015
|
+
var Utils = require_utils();
|
|
1016
|
+
var ECCode = require_error_correction_code();
|
|
1017
|
+
var ECLevel = require_error_correction_level();
|
|
1018
|
+
var Mode = require_mode();
|
|
1019
|
+
var VersionCheck = require_version_check();
|
|
1020
|
+
var G18 = 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0;
|
|
1021
|
+
var G18_BCH = Utils.getBCHDigit(G18);
|
|
1022
|
+
function getBestVersionForDataLength(mode, length, errorCorrectionLevel) {
|
|
1023
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
|
|
1024
|
+
if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) {
|
|
1025
|
+
return currentVersion;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
return void 0;
|
|
1029
|
+
}
|
|
1030
|
+
function getReservedBitsCount(mode, version) {
|
|
1031
|
+
return Mode.getCharCountIndicator(mode, version) + 4;
|
|
1032
|
+
}
|
|
1033
|
+
function getTotalBitsFromDataArray(segments, version) {
|
|
1034
|
+
let totalBits = 0;
|
|
1035
|
+
segments.forEach(function(data) {
|
|
1036
|
+
const reservedBits = getReservedBitsCount(data.mode, version);
|
|
1037
|
+
totalBits += reservedBits + data.getBitsLength();
|
|
1038
|
+
});
|
|
1039
|
+
return totalBits;
|
|
1040
|
+
}
|
|
1041
|
+
function getBestVersionForMixedData(segments, errorCorrectionLevel) {
|
|
1042
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
|
|
1043
|
+
const length = getTotalBitsFromDataArray(segments, currentVersion);
|
|
1044
|
+
if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) {
|
|
1045
|
+
return currentVersion;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
return void 0;
|
|
1049
|
+
}
|
|
1050
|
+
exports.from = function from(value, defaultValue) {
|
|
1051
|
+
if (VersionCheck.isValid(value)) {
|
|
1052
|
+
return parseInt(value, 10);
|
|
1053
|
+
}
|
|
1054
|
+
return defaultValue;
|
|
1055
|
+
};
|
|
1056
|
+
exports.getCapacity = function getCapacity(version, errorCorrectionLevel, mode) {
|
|
1057
|
+
if (!VersionCheck.isValid(version)) {
|
|
1058
|
+
throw new Error("Invalid QR Code version");
|
|
1059
|
+
}
|
|
1060
|
+
if (typeof mode === "undefined") mode = Mode.BYTE;
|
|
1061
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version);
|
|
1062
|
+
const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
|
|
1063
|
+
const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
|
|
1064
|
+
if (mode === Mode.MIXED) return dataTotalCodewordsBits;
|
|
1065
|
+
const usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version);
|
|
1066
|
+
switch (mode) {
|
|
1067
|
+
case Mode.NUMERIC:
|
|
1068
|
+
return Math.floor(usableBits / 10 * 3);
|
|
1069
|
+
case Mode.ALPHANUMERIC:
|
|
1070
|
+
return Math.floor(usableBits / 11 * 2);
|
|
1071
|
+
case Mode.KANJI:
|
|
1072
|
+
return Math.floor(usableBits / 13);
|
|
1073
|
+
case Mode.BYTE:
|
|
1074
|
+
default:
|
|
1075
|
+
return Math.floor(usableBits / 8);
|
|
1076
|
+
}
|
|
1077
|
+
};
|
|
1078
|
+
exports.getBestVersionForData = function getBestVersionForData(data, errorCorrectionLevel) {
|
|
1079
|
+
let seg;
|
|
1080
|
+
const ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M);
|
|
1081
|
+
if (Array.isArray(data)) {
|
|
1082
|
+
if (data.length > 1) {
|
|
1083
|
+
return getBestVersionForMixedData(data, ecl);
|
|
1084
|
+
}
|
|
1085
|
+
if (data.length === 0) {
|
|
1086
|
+
return 1;
|
|
1087
|
+
}
|
|
1088
|
+
seg = data[0];
|
|
1089
|
+
} else {
|
|
1090
|
+
seg = data;
|
|
1091
|
+
}
|
|
1092
|
+
return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl);
|
|
1093
|
+
};
|
|
1094
|
+
exports.getEncodedBits = function getEncodedBits(version) {
|
|
1095
|
+
if (!VersionCheck.isValid(version) || version < 7) {
|
|
1096
|
+
throw new Error("Invalid QR Code version");
|
|
1097
|
+
}
|
|
1098
|
+
let d = version << 12;
|
|
1099
|
+
while (Utils.getBCHDigit(d) - G18_BCH >= 0) {
|
|
1100
|
+
d ^= G18 << Utils.getBCHDigit(d) - G18_BCH;
|
|
1101
|
+
}
|
|
1102
|
+
return version << 12 | d;
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
});
|
|
1106
|
+
|
|
1107
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js
|
|
1108
|
+
var require_format_info = __commonJS({
|
|
1109
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js"(exports) {
|
|
1110
|
+
var Utils = require_utils();
|
|
1111
|
+
var G15 = 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0;
|
|
1112
|
+
var G15_MASK = 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1;
|
|
1113
|
+
var G15_BCH = Utils.getBCHDigit(G15);
|
|
1114
|
+
exports.getEncodedBits = function getEncodedBits(errorCorrectionLevel, mask) {
|
|
1115
|
+
const data = errorCorrectionLevel.bit << 3 | mask;
|
|
1116
|
+
let d = data << 10;
|
|
1117
|
+
while (Utils.getBCHDigit(d) - G15_BCH >= 0) {
|
|
1118
|
+
d ^= G15 << Utils.getBCHDigit(d) - G15_BCH;
|
|
1119
|
+
}
|
|
1120
|
+
return (data << 10 | d) ^ G15_MASK;
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1123
|
+
});
|
|
1124
|
+
|
|
1125
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js
|
|
1126
|
+
var require_numeric_data = __commonJS({
|
|
1127
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js"(exports, module2) {
|
|
1128
|
+
var Mode = require_mode();
|
|
1129
|
+
function NumericData(data) {
|
|
1130
|
+
this.mode = Mode.NUMERIC;
|
|
1131
|
+
this.data = data.toString();
|
|
1132
|
+
}
|
|
1133
|
+
NumericData.getBitsLength = function getBitsLength(length) {
|
|
1134
|
+
return 10 * Math.floor(length / 3) + (length % 3 ? length % 3 * 3 + 1 : 0);
|
|
1135
|
+
};
|
|
1136
|
+
NumericData.prototype.getLength = function getLength() {
|
|
1137
|
+
return this.data.length;
|
|
1138
|
+
};
|
|
1139
|
+
NumericData.prototype.getBitsLength = function getBitsLength() {
|
|
1140
|
+
return NumericData.getBitsLength(this.data.length);
|
|
1141
|
+
};
|
|
1142
|
+
NumericData.prototype.write = function write(bitBuffer) {
|
|
1143
|
+
let i, group, value;
|
|
1144
|
+
for (i = 0; i + 3 <= this.data.length; i += 3) {
|
|
1145
|
+
group = this.data.substr(i, 3);
|
|
1146
|
+
value = parseInt(group, 10);
|
|
1147
|
+
bitBuffer.put(value, 10);
|
|
1148
|
+
}
|
|
1149
|
+
const remainingNum = this.data.length - i;
|
|
1150
|
+
if (remainingNum > 0) {
|
|
1151
|
+
group = this.data.substr(i);
|
|
1152
|
+
value = parseInt(group, 10);
|
|
1153
|
+
bitBuffer.put(value, remainingNum * 3 + 1);
|
|
1154
|
+
}
|
|
1155
|
+
};
|
|
1156
|
+
module2.exports = NumericData;
|
|
1157
|
+
}
|
|
1158
|
+
});
|
|
1159
|
+
|
|
1160
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js
|
|
1161
|
+
var require_alphanumeric_data = __commonJS({
|
|
1162
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js"(exports, module2) {
|
|
1163
|
+
var Mode = require_mode();
|
|
1164
|
+
var ALPHA_NUM_CHARS = [
|
|
1165
|
+
"0",
|
|
1166
|
+
"1",
|
|
1167
|
+
"2",
|
|
1168
|
+
"3",
|
|
1169
|
+
"4",
|
|
1170
|
+
"5",
|
|
1171
|
+
"6",
|
|
1172
|
+
"7",
|
|
1173
|
+
"8",
|
|
1174
|
+
"9",
|
|
1175
|
+
"A",
|
|
1176
|
+
"B",
|
|
1177
|
+
"C",
|
|
1178
|
+
"D",
|
|
1179
|
+
"E",
|
|
1180
|
+
"F",
|
|
1181
|
+
"G",
|
|
1182
|
+
"H",
|
|
1183
|
+
"I",
|
|
1184
|
+
"J",
|
|
1185
|
+
"K",
|
|
1186
|
+
"L",
|
|
1187
|
+
"M",
|
|
1188
|
+
"N",
|
|
1189
|
+
"O",
|
|
1190
|
+
"P",
|
|
1191
|
+
"Q",
|
|
1192
|
+
"R",
|
|
1193
|
+
"S",
|
|
1194
|
+
"T",
|
|
1195
|
+
"U",
|
|
1196
|
+
"V",
|
|
1197
|
+
"W",
|
|
1198
|
+
"X",
|
|
1199
|
+
"Y",
|
|
1200
|
+
"Z",
|
|
1201
|
+
" ",
|
|
1202
|
+
"$",
|
|
1203
|
+
"%",
|
|
1204
|
+
"*",
|
|
1205
|
+
"+",
|
|
1206
|
+
"-",
|
|
1207
|
+
".",
|
|
1208
|
+
"/",
|
|
1209
|
+
":"
|
|
1210
|
+
];
|
|
1211
|
+
function AlphanumericData(data) {
|
|
1212
|
+
this.mode = Mode.ALPHANUMERIC;
|
|
1213
|
+
this.data = data;
|
|
1214
|
+
}
|
|
1215
|
+
AlphanumericData.getBitsLength = function getBitsLength(length) {
|
|
1216
|
+
return 11 * Math.floor(length / 2) + 6 * (length % 2);
|
|
1217
|
+
};
|
|
1218
|
+
AlphanumericData.prototype.getLength = function getLength() {
|
|
1219
|
+
return this.data.length;
|
|
1220
|
+
};
|
|
1221
|
+
AlphanumericData.prototype.getBitsLength = function getBitsLength() {
|
|
1222
|
+
return AlphanumericData.getBitsLength(this.data.length);
|
|
1223
|
+
};
|
|
1224
|
+
AlphanumericData.prototype.write = function write(bitBuffer) {
|
|
1225
|
+
let i;
|
|
1226
|
+
for (i = 0; i + 2 <= this.data.length; i += 2) {
|
|
1227
|
+
let value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45;
|
|
1228
|
+
value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1]);
|
|
1229
|
+
bitBuffer.put(value, 11);
|
|
1230
|
+
}
|
|
1231
|
+
if (this.data.length % 2) {
|
|
1232
|
+
bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6);
|
|
1233
|
+
}
|
|
1234
|
+
};
|
|
1235
|
+
module2.exports = AlphanumericData;
|
|
1236
|
+
}
|
|
1237
|
+
});
|
|
1238
|
+
|
|
1239
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js
|
|
1240
|
+
var require_byte_data = __commonJS({
|
|
1241
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js"(exports, module2) {
|
|
1242
|
+
var Mode = require_mode();
|
|
1243
|
+
function ByteData(data) {
|
|
1244
|
+
this.mode = Mode.BYTE;
|
|
1245
|
+
if (typeof data === "string") {
|
|
1246
|
+
this.data = new TextEncoder().encode(data);
|
|
1247
|
+
} else {
|
|
1248
|
+
this.data = new Uint8Array(data);
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
ByteData.getBitsLength = function getBitsLength(length) {
|
|
1252
|
+
return length * 8;
|
|
1253
|
+
};
|
|
1254
|
+
ByteData.prototype.getLength = function getLength() {
|
|
1255
|
+
return this.data.length;
|
|
1256
|
+
};
|
|
1257
|
+
ByteData.prototype.getBitsLength = function getBitsLength() {
|
|
1258
|
+
return ByteData.getBitsLength(this.data.length);
|
|
1259
|
+
};
|
|
1260
|
+
ByteData.prototype.write = function(bitBuffer) {
|
|
1261
|
+
for (let i = 0, l = this.data.length; i < l; i++) {
|
|
1262
|
+
bitBuffer.put(this.data[i], 8);
|
|
1263
|
+
}
|
|
1264
|
+
};
|
|
1265
|
+
module2.exports = ByteData;
|
|
1266
|
+
}
|
|
1267
|
+
});
|
|
1268
|
+
|
|
1269
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js
|
|
1270
|
+
var require_kanji_data = __commonJS({
|
|
1271
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js"(exports, module2) {
|
|
1272
|
+
var Mode = require_mode();
|
|
1273
|
+
var Utils = require_utils();
|
|
1274
|
+
function KanjiData(data) {
|
|
1275
|
+
this.mode = Mode.KANJI;
|
|
1276
|
+
this.data = data;
|
|
1277
|
+
}
|
|
1278
|
+
KanjiData.getBitsLength = function getBitsLength(length) {
|
|
1279
|
+
return length * 13;
|
|
1280
|
+
};
|
|
1281
|
+
KanjiData.prototype.getLength = function getLength() {
|
|
1282
|
+
return this.data.length;
|
|
1283
|
+
};
|
|
1284
|
+
KanjiData.prototype.getBitsLength = function getBitsLength() {
|
|
1285
|
+
return KanjiData.getBitsLength(this.data.length);
|
|
1286
|
+
};
|
|
1287
|
+
KanjiData.prototype.write = function(bitBuffer) {
|
|
1288
|
+
let i;
|
|
1289
|
+
for (i = 0; i < this.data.length; i++) {
|
|
1290
|
+
let value = Utils.toSJIS(this.data[i]);
|
|
1291
|
+
if (value >= 33088 && value <= 40956) {
|
|
1292
|
+
value -= 33088;
|
|
1293
|
+
} else if (value >= 57408 && value <= 60351) {
|
|
1294
|
+
value -= 49472;
|
|
1295
|
+
} else {
|
|
1296
|
+
throw new Error(
|
|
1297
|
+
"Invalid SJIS character: " + this.data[i] + "\nMake sure your charset is UTF-8"
|
|
1298
|
+
);
|
|
1299
|
+
}
|
|
1300
|
+
value = (value >>> 8 & 255) * 192 + (value & 255);
|
|
1301
|
+
bitBuffer.put(value, 13);
|
|
1302
|
+
}
|
|
1303
|
+
};
|
|
1304
|
+
module2.exports = KanjiData;
|
|
1305
|
+
}
|
|
1306
|
+
});
|
|
1307
|
+
|
|
1308
|
+
// node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js
|
|
1309
|
+
var require_dijkstra = __commonJS({
|
|
1310
|
+
"node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js"(exports, module2) {
|
|
1311
|
+
"use strict";
|
|
1312
|
+
var dijkstra = {
|
|
1313
|
+
single_source_shortest_paths: function(graph, s, d) {
|
|
1314
|
+
var predecessors = {};
|
|
1315
|
+
var costs = {};
|
|
1316
|
+
costs[s] = 0;
|
|
1317
|
+
var open = dijkstra.PriorityQueue.make();
|
|
1318
|
+
open.push(s, 0);
|
|
1319
|
+
var closest, u, v, cost_of_s_to_u, adjacent_nodes, cost_of_e, cost_of_s_to_u_plus_cost_of_e, cost_of_s_to_v, first_visit;
|
|
1320
|
+
while (!open.empty()) {
|
|
1321
|
+
closest = open.pop();
|
|
1322
|
+
u = closest.value;
|
|
1323
|
+
cost_of_s_to_u = closest.cost;
|
|
1324
|
+
adjacent_nodes = graph[u] || {};
|
|
1325
|
+
for (v in adjacent_nodes) {
|
|
1326
|
+
if (adjacent_nodes.hasOwnProperty(v)) {
|
|
1327
|
+
cost_of_e = adjacent_nodes[v];
|
|
1328
|
+
cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
|
|
1329
|
+
cost_of_s_to_v = costs[v];
|
|
1330
|
+
first_visit = typeof costs[v] === "undefined";
|
|
1331
|
+
if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
|
|
1332
|
+
costs[v] = cost_of_s_to_u_plus_cost_of_e;
|
|
1333
|
+
open.push(v, cost_of_s_to_u_plus_cost_of_e);
|
|
1334
|
+
predecessors[v] = u;
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
if (typeof d !== "undefined" && typeof costs[d] === "undefined") {
|
|
1340
|
+
var msg = ["Could not find a path from ", s, " to ", d, "."].join("");
|
|
1341
|
+
throw new Error(msg);
|
|
1342
|
+
}
|
|
1343
|
+
return predecessors;
|
|
1344
|
+
},
|
|
1345
|
+
extract_shortest_path_from_predecessor_list: function(predecessors, d) {
|
|
1346
|
+
var nodes = [];
|
|
1347
|
+
var u = d;
|
|
1348
|
+
var predecessor;
|
|
1349
|
+
while (u) {
|
|
1350
|
+
nodes.push(u);
|
|
1351
|
+
predecessor = predecessors[u];
|
|
1352
|
+
u = predecessors[u];
|
|
1353
|
+
}
|
|
1354
|
+
nodes.reverse();
|
|
1355
|
+
return nodes;
|
|
1356
|
+
},
|
|
1357
|
+
find_path: function(graph, s, d) {
|
|
1358
|
+
var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
|
|
1359
|
+
return dijkstra.extract_shortest_path_from_predecessor_list(
|
|
1360
|
+
predecessors,
|
|
1361
|
+
d
|
|
1362
|
+
);
|
|
1363
|
+
},
|
|
1364
|
+
/**
|
|
1365
|
+
* A very naive priority queue implementation.
|
|
1366
|
+
*/
|
|
1367
|
+
PriorityQueue: {
|
|
1368
|
+
make: function(opts) {
|
|
1369
|
+
var T = dijkstra.PriorityQueue, t = {}, key;
|
|
1370
|
+
opts = opts || {};
|
|
1371
|
+
for (key in T) {
|
|
1372
|
+
if (T.hasOwnProperty(key)) {
|
|
1373
|
+
t[key] = T[key];
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
t.queue = [];
|
|
1377
|
+
t.sorter = opts.sorter || T.default_sorter;
|
|
1378
|
+
return t;
|
|
1379
|
+
},
|
|
1380
|
+
default_sorter: function(a, b) {
|
|
1381
|
+
return a.cost - b.cost;
|
|
1382
|
+
},
|
|
1383
|
+
/**
|
|
1384
|
+
* Add a new item to the queue and ensure the highest priority element
|
|
1385
|
+
* is at the front of the queue.
|
|
1386
|
+
*/
|
|
1387
|
+
push: function(value, cost) {
|
|
1388
|
+
var item = { value, cost };
|
|
1389
|
+
this.queue.push(item);
|
|
1390
|
+
this.queue.sort(this.sorter);
|
|
1391
|
+
},
|
|
1392
|
+
/**
|
|
1393
|
+
* Return the highest priority element in the queue.
|
|
1394
|
+
*/
|
|
1395
|
+
pop: function() {
|
|
1396
|
+
return this.queue.shift();
|
|
1397
|
+
},
|
|
1398
|
+
empty: function() {
|
|
1399
|
+
return this.queue.length === 0;
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
};
|
|
1403
|
+
if (typeof module2 !== "undefined") {
|
|
1404
|
+
module2.exports = dijkstra;
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
});
|
|
1408
|
+
|
|
1409
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js
|
|
1410
|
+
var require_segments = __commonJS({
|
|
1411
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js"(exports) {
|
|
1412
|
+
var Mode = require_mode();
|
|
1413
|
+
var NumericData = require_numeric_data();
|
|
1414
|
+
var AlphanumericData = require_alphanumeric_data();
|
|
1415
|
+
var ByteData = require_byte_data();
|
|
1416
|
+
var KanjiData = require_kanji_data();
|
|
1417
|
+
var Regex = require_regex();
|
|
1418
|
+
var Utils = require_utils();
|
|
1419
|
+
var dijkstra = require_dijkstra();
|
|
1420
|
+
function getStringByteLength(str) {
|
|
1421
|
+
return unescape(encodeURIComponent(str)).length;
|
|
1422
|
+
}
|
|
1423
|
+
function getSegments(regex, mode, str) {
|
|
1424
|
+
const segments = [];
|
|
1425
|
+
let result;
|
|
1426
|
+
while ((result = regex.exec(str)) !== null) {
|
|
1427
|
+
segments.push({
|
|
1428
|
+
data: result[0],
|
|
1429
|
+
index: result.index,
|
|
1430
|
+
mode,
|
|
1431
|
+
length: result[0].length
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
return segments;
|
|
1435
|
+
}
|
|
1436
|
+
function getSegmentsFromString(dataStr) {
|
|
1437
|
+
const numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr);
|
|
1438
|
+
const alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr);
|
|
1439
|
+
let byteSegs;
|
|
1440
|
+
let kanjiSegs;
|
|
1441
|
+
if (Utils.isKanjiModeEnabled()) {
|
|
1442
|
+
byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr);
|
|
1443
|
+
kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr);
|
|
1444
|
+
} else {
|
|
1445
|
+
byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr);
|
|
1446
|
+
kanjiSegs = [];
|
|
1447
|
+
}
|
|
1448
|
+
const segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs);
|
|
1449
|
+
return segs.sort(function(s1, s2) {
|
|
1450
|
+
return s1.index - s2.index;
|
|
1451
|
+
}).map(function(obj) {
|
|
1452
|
+
return {
|
|
1453
|
+
data: obj.data,
|
|
1454
|
+
mode: obj.mode,
|
|
1455
|
+
length: obj.length
|
|
1456
|
+
};
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1459
|
+
function getSegmentBitsLength(length, mode) {
|
|
1460
|
+
switch (mode) {
|
|
1461
|
+
case Mode.NUMERIC:
|
|
1462
|
+
return NumericData.getBitsLength(length);
|
|
1463
|
+
case Mode.ALPHANUMERIC:
|
|
1464
|
+
return AlphanumericData.getBitsLength(length);
|
|
1465
|
+
case Mode.KANJI:
|
|
1466
|
+
return KanjiData.getBitsLength(length);
|
|
1467
|
+
case Mode.BYTE:
|
|
1468
|
+
return ByteData.getBitsLength(length);
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
function mergeSegments(segs) {
|
|
1472
|
+
return segs.reduce(function(acc, curr) {
|
|
1473
|
+
const prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null;
|
|
1474
|
+
if (prevSeg && prevSeg.mode === curr.mode) {
|
|
1475
|
+
acc[acc.length - 1].data += curr.data;
|
|
1476
|
+
return acc;
|
|
1477
|
+
}
|
|
1478
|
+
acc.push(curr);
|
|
1479
|
+
return acc;
|
|
1480
|
+
}, []);
|
|
1481
|
+
}
|
|
1482
|
+
function buildNodes(segs) {
|
|
1483
|
+
const nodes = [];
|
|
1484
|
+
for (let i = 0; i < segs.length; i++) {
|
|
1485
|
+
const seg = segs[i];
|
|
1486
|
+
switch (seg.mode) {
|
|
1487
|
+
case Mode.NUMERIC:
|
|
1488
|
+
nodes.push([
|
|
1489
|
+
seg,
|
|
1490
|
+
{ data: seg.data, mode: Mode.ALPHANUMERIC, length: seg.length },
|
|
1491
|
+
{ data: seg.data, mode: Mode.BYTE, length: seg.length }
|
|
1492
|
+
]);
|
|
1493
|
+
break;
|
|
1494
|
+
case Mode.ALPHANUMERIC:
|
|
1495
|
+
nodes.push([
|
|
1496
|
+
seg,
|
|
1497
|
+
{ data: seg.data, mode: Mode.BYTE, length: seg.length }
|
|
1498
|
+
]);
|
|
1499
|
+
break;
|
|
1500
|
+
case Mode.KANJI:
|
|
1501
|
+
nodes.push([
|
|
1502
|
+
seg,
|
|
1503
|
+
{ data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
|
|
1504
|
+
]);
|
|
1505
|
+
break;
|
|
1506
|
+
case Mode.BYTE:
|
|
1507
|
+
nodes.push([
|
|
1508
|
+
{ data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
|
|
1509
|
+
]);
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
return nodes;
|
|
1513
|
+
}
|
|
1514
|
+
function buildGraph(nodes, version) {
|
|
1515
|
+
const table = {};
|
|
1516
|
+
const graph = { start: {} };
|
|
1517
|
+
let prevNodeIds = ["start"];
|
|
1518
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
1519
|
+
const nodeGroup = nodes[i];
|
|
1520
|
+
const currentNodeIds = [];
|
|
1521
|
+
for (let j = 0; j < nodeGroup.length; j++) {
|
|
1522
|
+
const node = nodeGroup[j];
|
|
1523
|
+
const key = "" + i + j;
|
|
1524
|
+
currentNodeIds.push(key);
|
|
1525
|
+
table[key] = { node, lastCount: 0 };
|
|
1526
|
+
graph[key] = {};
|
|
1527
|
+
for (let n = 0; n < prevNodeIds.length; n++) {
|
|
1528
|
+
const prevNodeId = prevNodeIds[n];
|
|
1529
|
+
if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {
|
|
1530
|
+
graph[prevNodeId][key] = getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) - getSegmentBitsLength(table[prevNodeId].lastCount, node.mode);
|
|
1531
|
+
table[prevNodeId].lastCount += node.length;
|
|
1532
|
+
} else {
|
|
1533
|
+
if (table[prevNodeId]) table[prevNodeId].lastCount = node.length;
|
|
1534
|
+
graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) + 4 + Mode.getCharCountIndicator(node.mode, version);
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
prevNodeIds = currentNodeIds;
|
|
1539
|
+
}
|
|
1540
|
+
for (let n = 0; n < prevNodeIds.length; n++) {
|
|
1541
|
+
graph[prevNodeIds[n]].end = 0;
|
|
1542
|
+
}
|
|
1543
|
+
return { map: graph, table };
|
|
1544
|
+
}
|
|
1545
|
+
function buildSingleSegment(data, modesHint) {
|
|
1546
|
+
let mode;
|
|
1547
|
+
const bestMode = Mode.getBestModeForData(data);
|
|
1548
|
+
mode = Mode.from(modesHint, bestMode);
|
|
1549
|
+
if (mode !== Mode.BYTE && mode.bit < bestMode.bit) {
|
|
1550
|
+
throw new Error('"' + data + '" cannot be encoded with mode ' + Mode.toString(mode) + ".\n Suggested mode is: " + Mode.toString(bestMode));
|
|
1551
|
+
}
|
|
1552
|
+
if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) {
|
|
1553
|
+
mode = Mode.BYTE;
|
|
1554
|
+
}
|
|
1555
|
+
switch (mode) {
|
|
1556
|
+
case Mode.NUMERIC:
|
|
1557
|
+
return new NumericData(data);
|
|
1558
|
+
case Mode.ALPHANUMERIC:
|
|
1559
|
+
return new AlphanumericData(data);
|
|
1560
|
+
case Mode.KANJI:
|
|
1561
|
+
return new KanjiData(data);
|
|
1562
|
+
case Mode.BYTE:
|
|
1563
|
+
return new ByteData(data);
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
exports.fromArray = function fromArray(array) {
|
|
1567
|
+
return array.reduce(function(acc, seg) {
|
|
1568
|
+
if (typeof seg === "string") {
|
|
1569
|
+
acc.push(buildSingleSegment(seg, null));
|
|
1570
|
+
} else if (seg.data) {
|
|
1571
|
+
acc.push(buildSingleSegment(seg.data, seg.mode));
|
|
1572
|
+
}
|
|
1573
|
+
return acc;
|
|
1574
|
+
}, []);
|
|
1575
|
+
};
|
|
1576
|
+
exports.fromString = function fromString(data, version) {
|
|
1577
|
+
const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled());
|
|
1578
|
+
const nodes = buildNodes(segs);
|
|
1579
|
+
const graph = buildGraph(nodes, version);
|
|
1580
|
+
const path = dijkstra.find_path(graph.map, "start", "end");
|
|
1581
|
+
const optimizedSegs = [];
|
|
1582
|
+
for (let i = 1; i < path.length - 1; i++) {
|
|
1583
|
+
optimizedSegs.push(graph.table[path[i]].node);
|
|
1584
|
+
}
|
|
1585
|
+
return exports.fromArray(mergeSegments(optimizedSegs));
|
|
1586
|
+
};
|
|
1587
|
+
exports.rawSplit = function rawSplit(data) {
|
|
1588
|
+
return exports.fromArray(
|
|
1589
|
+
getSegmentsFromString(data, Utils.isKanjiModeEnabled())
|
|
1590
|
+
);
|
|
1591
|
+
};
|
|
1592
|
+
}
|
|
1593
|
+
});
|
|
1594
|
+
|
|
1595
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js
|
|
1596
|
+
var require_qrcode = __commonJS({
|
|
1597
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js"(exports) {
|
|
1598
|
+
var Utils = require_utils();
|
|
1599
|
+
var ECLevel = require_error_correction_level();
|
|
1600
|
+
var BitBuffer = require_bit_buffer();
|
|
1601
|
+
var BitMatrix = require_bit_matrix();
|
|
1602
|
+
var AlignmentPattern = require_alignment_pattern();
|
|
1603
|
+
var FinderPattern = require_finder_pattern();
|
|
1604
|
+
var MaskPattern = require_mask_pattern();
|
|
1605
|
+
var ECCode = require_error_correction_code();
|
|
1606
|
+
var ReedSolomonEncoder = require_reed_solomon_encoder();
|
|
1607
|
+
var Version = require_version();
|
|
1608
|
+
var FormatInfo = require_format_info();
|
|
1609
|
+
var Mode = require_mode();
|
|
1610
|
+
var Segments = require_segments();
|
|
1611
|
+
function setupFinderPattern(matrix, version) {
|
|
1612
|
+
const size = matrix.size;
|
|
1613
|
+
const pos = FinderPattern.getPositions(version);
|
|
1614
|
+
for (let i = 0; i < pos.length; i++) {
|
|
1615
|
+
const row = pos[i][0];
|
|
1616
|
+
const col = pos[i][1];
|
|
1617
|
+
for (let r = -1; r <= 7; r++) {
|
|
1618
|
+
if (row + r <= -1 || size <= row + r) continue;
|
|
1619
|
+
for (let c = -1; c <= 7; c++) {
|
|
1620
|
+
if (col + c <= -1 || size <= col + c) continue;
|
|
1621
|
+
if (r >= 0 && r <= 6 && (c === 0 || c === 6) || c >= 0 && c <= 6 && (r === 0 || r === 6) || r >= 2 && r <= 4 && c >= 2 && c <= 4) {
|
|
1622
|
+
matrix.set(row + r, col + c, true, true);
|
|
1623
|
+
} else {
|
|
1624
|
+
matrix.set(row + r, col + c, false, true);
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
function setupTimingPattern(matrix) {
|
|
1631
|
+
const size = matrix.size;
|
|
1632
|
+
for (let r = 8; r < size - 8; r++) {
|
|
1633
|
+
const value = r % 2 === 0;
|
|
1634
|
+
matrix.set(r, 6, value, true);
|
|
1635
|
+
matrix.set(6, r, value, true);
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
function setupAlignmentPattern(matrix, version) {
|
|
1639
|
+
const pos = AlignmentPattern.getPositions(version);
|
|
1640
|
+
for (let i = 0; i < pos.length; i++) {
|
|
1641
|
+
const row = pos[i][0];
|
|
1642
|
+
const col = pos[i][1];
|
|
1643
|
+
for (let r = -2; r <= 2; r++) {
|
|
1644
|
+
for (let c = -2; c <= 2; c++) {
|
|
1645
|
+
if (r === -2 || r === 2 || c === -2 || c === 2 || r === 0 && c === 0) {
|
|
1646
|
+
matrix.set(row + r, col + c, true, true);
|
|
1647
|
+
} else {
|
|
1648
|
+
matrix.set(row + r, col + c, false, true);
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
function setupVersionInfo(matrix, version) {
|
|
1655
|
+
const size = matrix.size;
|
|
1656
|
+
const bits = Version.getEncodedBits(version);
|
|
1657
|
+
let row, col, mod;
|
|
1658
|
+
for (let i = 0; i < 18; i++) {
|
|
1659
|
+
row = Math.floor(i / 3);
|
|
1660
|
+
col = i % 3 + size - 8 - 3;
|
|
1661
|
+
mod = (bits >> i & 1) === 1;
|
|
1662
|
+
matrix.set(row, col, mod, true);
|
|
1663
|
+
matrix.set(col, row, mod, true);
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
function setupFormatInfo(matrix, errorCorrectionLevel, maskPattern) {
|
|
1667
|
+
const size = matrix.size;
|
|
1668
|
+
const bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern);
|
|
1669
|
+
let i, mod;
|
|
1670
|
+
for (i = 0; i < 15; i++) {
|
|
1671
|
+
mod = (bits >> i & 1) === 1;
|
|
1672
|
+
if (i < 6) {
|
|
1673
|
+
matrix.set(i, 8, mod, true);
|
|
1674
|
+
} else if (i < 8) {
|
|
1675
|
+
matrix.set(i + 1, 8, mod, true);
|
|
1676
|
+
} else {
|
|
1677
|
+
matrix.set(size - 15 + i, 8, mod, true);
|
|
1678
|
+
}
|
|
1679
|
+
if (i < 8) {
|
|
1680
|
+
matrix.set(8, size - i - 1, mod, true);
|
|
1681
|
+
} else if (i < 9) {
|
|
1682
|
+
matrix.set(8, 15 - i - 1 + 1, mod, true);
|
|
1683
|
+
} else {
|
|
1684
|
+
matrix.set(8, 15 - i - 1, mod, true);
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
matrix.set(size - 8, 8, 1, true);
|
|
1688
|
+
}
|
|
1689
|
+
function setupData(matrix, data) {
|
|
1690
|
+
const size = matrix.size;
|
|
1691
|
+
let inc = -1;
|
|
1692
|
+
let row = size - 1;
|
|
1693
|
+
let bitIndex = 7;
|
|
1694
|
+
let byteIndex = 0;
|
|
1695
|
+
for (let col = size - 1; col > 0; col -= 2) {
|
|
1696
|
+
if (col === 6) col--;
|
|
1697
|
+
while (true) {
|
|
1698
|
+
for (let c = 0; c < 2; c++) {
|
|
1699
|
+
if (!matrix.isReserved(row, col - c)) {
|
|
1700
|
+
let dark = false;
|
|
1701
|
+
if (byteIndex < data.length) {
|
|
1702
|
+
dark = (data[byteIndex] >>> bitIndex & 1) === 1;
|
|
1703
|
+
}
|
|
1704
|
+
matrix.set(row, col - c, dark);
|
|
1705
|
+
bitIndex--;
|
|
1706
|
+
if (bitIndex === -1) {
|
|
1707
|
+
byteIndex++;
|
|
1708
|
+
bitIndex = 7;
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
row += inc;
|
|
1713
|
+
if (row < 0 || size <= row) {
|
|
1714
|
+
row -= inc;
|
|
1715
|
+
inc = -inc;
|
|
1716
|
+
break;
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
function createData(version, errorCorrectionLevel, segments) {
|
|
1722
|
+
const buffer = new BitBuffer();
|
|
1723
|
+
segments.forEach(function(data) {
|
|
1724
|
+
buffer.put(data.mode.bit, 4);
|
|
1725
|
+
buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version));
|
|
1726
|
+
data.write(buffer);
|
|
1727
|
+
});
|
|
1728
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version);
|
|
1729
|
+
const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
|
|
1730
|
+
const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
|
|
1731
|
+
if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) {
|
|
1732
|
+
buffer.put(0, 4);
|
|
1733
|
+
}
|
|
1734
|
+
while (buffer.getLengthInBits() % 8 !== 0) {
|
|
1735
|
+
buffer.putBit(0);
|
|
1736
|
+
}
|
|
1737
|
+
const remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8;
|
|
1738
|
+
for (let i = 0; i < remainingByte; i++) {
|
|
1739
|
+
buffer.put(i % 2 ? 17 : 236, 8);
|
|
1740
|
+
}
|
|
1741
|
+
return createCodewords(buffer, version, errorCorrectionLevel);
|
|
1742
|
+
}
|
|
1743
|
+
function createCodewords(bitBuffer, version, errorCorrectionLevel) {
|
|
1744
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version);
|
|
1745
|
+
const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
|
|
1746
|
+
const dataTotalCodewords = totalCodewords - ecTotalCodewords;
|
|
1747
|
+
const ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel);
|
|
1748
|
+
const blocksInGroup2 = totalCodewords % ecTotalBlocks;
|
|
1749
|
+
const blocksInGroup1 = ecTotalBlocks - blocksInGroup2;
|
|
1750
|
+
const totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks);
|
|
1751
|
+
const dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks);
|
|
1752
|
+
const dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1;
|
|
1753
|
+
const ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1;
|
|
1754
|
+
const rs = new ReedSolomonEncoder(ecCount);
|
|
1755
|
+
let offset = 0;
|
|
1756
|
+
const dcData = new Array(ecTotalBlocks);
|
|
1757
|
+
const ecData = new Array(ecTotalBlocks);
|
|
1758
|
+
let maxDataSize = 0;
|
|
1759
|
+
const buffer = new Uint8Array(bitBuffer.buffer);
|
|
1760
|
+
for (let b = 0; b < ecTotalBlocks; b++) {
|
|
1761
|
+
const dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2;
|
|
1762
|
+
dcData[b] = buffer.slice(offset, offset + dataSize);
|
|
1763
|
+
ecData[b] = rs.encode(dcData[b]);
|
|
1764
|
+
offset += dataSize;
|
|
1765
|
+
maxDataSize = Math.max(maxDataSize, dataSize);
|
|
1766
|
+
}
|
|
1767
|
+
const data = new Uint8Array(totalCodewords);
|
|
1768
|
+
let index = 0;
|
|
1769
|
+
let i, r;
|
|
1770
|
+
for (i = 0; i < maxDataSize; i++) {
|
|
1771
|
+
for (r = 0; r < ecTotalBlocks; r++) {
|
|
1772
|
+
if (i < dcData[r].length) {
|
|
1773
|
+
data[index++] = dcData[r][i];
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
for (i = 0; i < ecCount; i++) {
|
|
1778
|
+
for (r = 0; r < ecTotalBlocks; r++) {
|
|
1779
|
+
data[index++] = ecData[r][i];
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
return data;
|
|
1783
|
+
}
|
|
1784
|
+
function createSymbol(data, version, errorCorrectionLevel, maskPattern) {
|
|
1785
|
+
let segments;
|
|
1786
|
+
if (Array.isArray(data)) {
|
|
1787
|
+
segments = Segments.fromArray(data);
|
|
1788
|
+
} else if (typeof data === "string") {
|
|
1789
|
+
let estimatedVersion = version;
|
|
1790
|
+
if (!estimatedVersion) {
|
|
1791
|
+
const rawSegments = Segments.rawSplit(data);
|
|
1792
|
+
estimatedVersion = Version.getBestVersionForData(rawSegments, errorCorrectionLevel);
|
|
1793
|
+
}
|
|
1794
|
+
segments = Segments.fromString(data, estimatedVersion || 40);
|
|
1795
|
+
} else {
|
|
1796
|
+
throw new Error("Invalid data");
|
|
1797
|
+
}
|
|
1798
|
+
const bestVersion = Version.getBestVersionForData(segments, errorCorrectionLevel);
|
|
1799
|
+
if (!bestVersion) {
|
|
1800
|
+
throw new Error("The amount of data is too big to be stored in a QR Code");
|
|
1801
|
+
}
|
|
1802
|
+
if (!version) {
|
|
1803
|
+
version = bestVersion;
|
|
1804
|
+
} else if (version < bestVersion) {
|
|
1805
|
+
throw new Error(
|
|
1806
|
+
"\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: " + bestVersion + ".\n"
|
|
1807
|
+
);
|
|
1808
|
+
}
|
|
1809
|
+
const dataBits = createData(version, errorCorrectionLevel, segments);
|
|
1810
|
+
const moduleCount = Utils.getSymbolSize(version);
|
|
1811
|
+
const modules = new BitMatrix(moduleCount);
|
|
1812
|
+
setupFinderPattern(modules, version);
|
|
1813
|
+
setupTimingPattern(modules);
|
|
1814
|
+
setupAlignmentPattern(modules, version);
|
|
1815
|
+
setupFormatInfo(modules, errorCorrectionLevel, 0);
|
|
1816
|
+
if (version >= 7) {
|
|
1817
|
+
setupVersionInfo(modules, version);
|
|
1818
|
+
}
|
|
1819
|
+
setupData(modules, dataBits);
|
|
1820
|
+
if (isNaN(maskPattern)) {
|
|
1821
|
+
maskPattern = MaskPattern.getBestMask(
|
|
1822
|
+
modules,
|
|
1823
|
+
setupFormatInfo.bind(null, modules, errorCorrectionLevel)
|
|
1824
|
+
);
|
|
1825
|
+
}
|
|
1826
|
+
MaskPattern.applyMask(maskPattern, modules);
|
|
1827
|
+
setupFormatInfo(modules, errorCorrectionLevel, maskPattern);
|
|
1828
|
+
return {
|
|
1829
|
+
modules,
|
|
1830
|
+
version,
|
|
1831
|
+
errorCorrectionLevel,
|
|
1832
|
+
maskPattern,
|
|
1833
|
+
segments
|
|
1834
|
+
};
|
|
1835
|
+
}
|
|
1836
|
+
exports.create = function create(data, options) {
|
|
1837
|
+
if (typeof data === "undefined" || data === "") {
|
|
1838
|
+
throw new Error("No input text");
|
|
1839
|
+
}
|
|
1840
|
+
let errorCorrectionLevel = ECLevel.M;
|
|
1841
|
+
let version;
|
|
1842
|
+
let mask;
|
|
1843
|
+
if (typeof options !== "undefined") {
|
|
1844
|
+
errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M);
|
|
1845
|
+
version = Version.from(options.version);
|
|
1846
|
+
mask = MaskPattern.from(options.maskPattern);
|
|
1847
|
+
if (options.toSJISFunc) {
|
|
1848
|
+
Utils.setToSJISFunction(options.toSJISFunc);
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
return createSymbol(data, version, errorCorrectionLevel, mask);
|
|
1852
|
+
};
|
|
1853
|
+
}
|
|
1854
|
+
});
|
|
1855
|
+
|
|
1856
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js
|
|
1857
|
+
var require_utils2 = __commonJS({
|
|
1858
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js"(exports) {
|
|
1859
|
+
function hex2rgba(hex) {
|
|
1860
|
+
if (typeof hex === "number") {
|
|
1861
|
+
hex = hex.toString();
|
|
1862
|
+
}
|
|
1863
|
+
if (typeof hex !== "string") {
|
|
1864
|
+
throw new Error("Color should be defined as hex string");
|
|
1865
|
+
}
|
|
1866
|
+
let hexCode = hex.slice().replace("#", "").split("");
|
|
1867
|
+
if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8) {
|
|
1868
|
+
throw new Error("Invalid hex color: " + hex);
|
|
1869
|
+
}
|
|
1870
|
+
if (hexCode.length === 3 || hexCode.length === 4) {
|
|
1871
|
+
hexCode = Array.prototype.concat.apply([], hexCode.map(function(c) {
|
|
1872
|
+
return [c, c];
|
|
1873
|
+
}));
|
|
1874
|
+
}
|
|
1875
|
+
if (hexCode.length === 6) hexCode.push("F", "F");
|
|
1876
|
+
const hexValue = parseInt(hexCode.join(""), 16);
|
|
1877
|
+
return {
|
|
1878
|
+
r: hexValue >> 24 & 255,
|
|
1879
|
+
g: hexValue >> 16 & 255,
|
|
1880
|
+
b: hexValue >> 8 & 255,
|
|
1881
|
+
a: hexValue & 255,
|
|
1882
|
+
hex: "#" + hexCode.slice(0, 6).join("")
|
|
1883
|
+
};
|
|
1884
|
+
}
|
|
1885
|
+
exports.getOptions = function getOptions(options) {
|
|
1886
|
+
if (!options) options = {};
|
|
1887
|
+
if (!options.color) options.color = {};
|
|
1888
|
+
const margin = typeof options.margin === "undefined" || options.margin === null || options.margin < 0 ? 4 : options.margin;
|
|
1889
|
+
const width = options.width && options.width >= 21 ? options.width : void 0;
|
|
1890
|
+
const scale = options.scale || 4;
|
|
1891
|
+
return {
|
|
1892
|
+
width,
|
|
1893
|
+
scale: width ? 4 : scale,
|
|
1894
|
+
margin,
|
|
1895
|
+
color: {
|
|
1896
|
+
dark: hex2rgba(options.color.dark || "#000000ff"),
|
|
1897
|
+
light: hex2rgba(options.color.light || "#ffffffff")
|
|
1898
|
+
},
|
|
1899
|
+
type: options.type,
|
|
1900
|
+
rendererOpts: options.rendererOpts || {}
|
|
1901
|
+
};
|
|
1902
|
+
};
|
|
1903
|
+
exports.getScale = function getScale(qrSize, opts) {
|
|
1904
|
+
return opts.width && opts.width >= qrSize + opts.margin * 2 ? opts.width / (qrSize + opts.margin * 2) : opts.scale;
|
|
1905
|
+
};
|
|
1906
|
+
exports.getImageWidth = function getImageWidth(qrSize, opts) {
|
|
1907
|
+
const scale = exports.getScale(qrSize, opts);
|
|
1908
|
+
return Math.floor((qrSize + opts.margin * 2) * scale);
|
|
1909
|
+
};
|
|
1910
|
+
exports.qrToImageData = function qrToImageData(imgData, qr, opts) {
|
|
1911
|
+
const size = qr.modules.size;
|
|
1912
|
+
const data = qr.modules.data;
|
|
1913
|
+
const scale = exports.getScale(size, opts);
|
|
1914
|
+
const symbolSize = Math.floor((size + opts.margin * 2) * scale);
|
|
1915
|
+
const scaledMargin = opts.margin * scale;
|
|
1916
|
+
const palette = [opts.color.light, opts.color.dark];
|
|
1917
|
+
for (let i = 0; i < symbolSize; i++) {
|
|
1918
|
+
for (let j = 0; j < symbolSize; j++) {
|
|
1919
|
+
let posDst = (i * symbolSize + j) * 4;
|
|
1920
|
+
let pxColor = opts.color.light;
|
|
1921
|
+
if (i >= scaledMargin && j >= scaledMargin && i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) {
|
|
1922
|
+
const iSrc = Math.floor((i - scaledMargin) / scale);
|
|
1923
|
+
const jSrc = Math.floor((j - scaledMargin) / scale);
|
|
1924
|
+
pxColor = palette[data[iSrc * size + jSrc] ? 1 : 0];
|
|
1925
|
+
}
|
|
1926
|
+
imgData[posDst++] = pxColor.r;
|
|
1927
|
+
imgData[posDst++] = pxColor.g;
|
|
1928
|
+
imgData[posDst++] = pxColor.b;
|
|
1929
|
+
imgData[posDst] = pxColor.a;
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
};
|
|
1933
|
+
}
|
|
1934
|
+
});
|
|
1935
|
+
|
|
1936
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js
|
|
1937
|
+
var require_canvas = __commonJS({
|
|
1938
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js"(exports) {
|
|
1939
|
+
var Utils = require_utils2();
|
|
1940
|
+
function clearCanvas(ctx, canvas, size) {
|
|
1941
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
1942
|
+
if (!canvas.style) canvas.style = {};
|
|
1943
|
+
canvas.height = size;
|
|
1944
|
+
canvas.width = size;
|
|
1945
|
+
canvas.style.height = size + "px";
|
|
1946
|
+
canvas.style.width = size + "px";
|
|
1947
|
+
}
|
|
1948
|
+
function getCanvasElement() {
|
|
1949
|
+
try {
|
|
1950
|
+
return document.createElement("canvas");
|
|
1951
|
+
} catch (e) {
|
|
1952
|
+
throw new Error("You need to specify a canvas element");
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
exports.render = function render(qrData, canvas, options) {
|
|
1956
|
+
let opts = options;
|
|
1957
|
+
let canvasEl = canvas;
|
|
1958
|
+
if (typeof opts === "undefined" && (!canvas || !canvas.getContext)) {
|
|
1959
|
+
opts = canvas;
|
|
1960
|
+
canvas = void 0;
|
|
1961
|
+
}
|
|
1962
|
+
if (!canvas) {
|
|
1963
|
+
canvasEl = getCanvasElement();
|
|
1964
|
+
}
|
|
1965
|
+
opts = Utils.getOptions(opts);
|
|
1966
|
+
const size = Utils.getImageWidth(qrData.modules.size, opts);
|
|
1967
|
+
const ctx = canvasEl.getContext("2d");
|
|
1968
|
+
const image = ctx.createImageData(size, size);
|
|
1969
|
+
Utils.qrToImageData(image.data, qrData, opts);
|
|
1970
|
+
clearCanvas(ctx, canvasEl, size);
|
|
1971
|
+
ctx.putImageData(image, 0, 0);
|
|
1972
|
+
return canvasEl;
|
|
1973
|
+
};
|
|
1974
|
+
exports.renderToDataURL = function renderToDataURL(qrData, canvas, options) {
|
|
1975
|
+
let opts = options;
|
|
1976
|
+
if (typeof opts === "undefined" && (!canvas || !canvas.getContext)) {
|
|
1977
|
+
opts = canvas;
|
|
1978
|
+
canvas = void 0;
|
|
1979
|
+
}
|
|
1980
|
+
if (!opts) opts = {};
|
|
1981
|
+
const canvasEl = exports.render(qrData, canvas, opts);
|
|
1982
|
+
const type = opts.type || "image/png";
|
|
1983
|
+
const rendererOpts = opts.rendererOpts || {};
|
|
1984
|
+
return canvasEl.toDataURL(type, rendererOpts.quality);
|
|
1985
|
+
};
|
|
1986
|
+
}
|
|
1987
|
+
});
|
|
1988
|
+
|
|
1989
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js
|
|
1990
|
+
var require_svg_tag = __commonJS({
|
|
1991
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js"(exports) {
|
|
1992
|
+
var Utils = require_utils2();
|
|
1993
|
+
function getColorAttrib(color, attrib) {
|
|
1994
|
+
const alpha = color.a / 255;
|
|
1995
|
+
const str = attrib + '="' + color.hex + '"';
|
|
1996
|
+
return alpha < 1 ? str + " " + attrib + '-opacity="' + alpha.toFixed(2).slice(1) + '"' : str;
|
|
1997
|
+
}
|
|
1998
|
+
function svgCmd(cmd, x, y) {
|
|
1999
|
+
let str = cmd + x;
|
|
2000
|
+
if (typeof y !== "undefined") str += " " + y;
|
|
2001
|
+
return str;
|
|
2002
|
+
}
|
|
2003
|
+
function qrToPath(data, size, margin) {
|
|
2004
|
+
let path = "";
|
|
2005
|
+
let moveBy = 0;
|
|
2006
|
+
let newRow = false;
|
|
2007
|
+
let lineLength = 0;
|
|
2008
|
+
for (let i = 0; i < data.length; i++) {
|
|
2009
|
+
const col = Math.floor(i % size);
|
|
2010
|
+
const row = Math.floor(i / size);
|
|
2011
|
+
if (!col && !newRow) newRow = true;
|
|
2012
|
+
if (data[i]) {
|
|
2013
|
+
lineLength++;
|
|
2014
|
+
if (!(i > 0 && col > 0 && data[i - 1])) {
|
|
2015
|
+
path += newRow ? svgCmd("M", col + margin, 0.5 + row + margin) : svgCmd("m", moveBy, 0);
|
|
2016
|
+
moveBy = 0;
|
|
2017
|
+
newRow = false;
|
|
2018
|
+
}
|
|
2019
|
+
if (!(col + 1 < size && data[i + 1])) {
|
|
2020
|
+
path += svgCmd("h", lineLength);
|
|
2021
|
+
lineLength = 0;
|
|
2022
|
+
}
|
|
2023
|
+
} else {
|
|
2024
|
+
moveBy++;
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
return path;
|
|
2028
|
+
}
|
|
2029
|
+
exports.render = function render(qrData, options, cb) {
|
|
2030
|
+
const opts = Utils.getOptions(options);
|
|
2031
|
+
const size = qrData.modules.size;
|
|
2032
|
+
const data = qrData.modules.data;
|
|
2033
|
+
const qrcodesize = size + opts.margin * 2;
|
|
2034
|
+
const bg = !opts.color.light.a ? "" : "<path " + getColorAttrib(opts.color.light, "fill") + ' d="M0 0h' + qrcodesize + "v" + qrcodesize + 'H0z"/>';
|
|
2035
|
+
const path = "<path " + getColorAttrib(opts.color.dark, "stroke") + ' d="' + qrToPath(data, size, opts.margin) + '"/>';
|
|
2036
|
+
const viewBox = 'viewBox="0 0 ' + qrcodesize + " " + qrcodesize + '"';
|
|
2037
|
+
const width = !opts.width ? "" : 'width="' + opts.width + '" height="' + opts.width + '" ';
|
|
2038
|
+
const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path + "</svg>\n";
|
|
2039
|
+
if (typeof cb === "function") {
|
|
2040
|
+
cb(null, svgTag);
|
|
2041
|
+
}
|
|
2042
|
+
return svgTag;
|
|
2043
|
+
};
|
|
2044
|
+
}
|
|
2045
|
+
});
|
|
2046
|
+
|
|
2047
|
+
// node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js
|
|
2048
|
+
var require_browser = __commonJS({
|
|
2049
|
+
"node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js"(exports) {
|
|
2050
|
+
var canPromise = require_can_promise();
|
|
2051
|
+
var QRCode2 = require_qrcode();
|
|
2052
|
+
var CanvasRenderer = require_canvas();
|
|
2053
|
+
var SvgRenderer = require_svg_tag();
|
|
2054
|
+
function renderCanvas(renderFunc, canvas, text, opts, cb) {
|
|
2055
|
+
const args = [].slice.call(arguments, 1);
|
|
2056
|
+
const argsNum = args.length;
|
|
2057
|
+
const isLastArgCb = typeof args[argsNum - 1] === "function";
|
|
2058
|
+
if (!isLastArgCb && !canPromise()) {
|
|
2059
|
+
throw new Error("Callback required as last argument");
|
|
2060
|
+
}
|
|
2061
|
+
if (isLastArgCb) {
|
|
2062
|
+
if (argsNum < 2) {
|
|
2063
|
+
throw new Error("Too few arguments provided");
|
|
2064
|
+
}
|
|
2065
|
+
if (argsNum === 2) {
|
|
2066
|
+
cb = text;
|
|
2067
|
+
text = canvas;
|
|
2068
|
+
canvas = opts = void 0;
|
|
2069
|
+
} else if (argsNum === 3) {
|
|
2070
|
+
if (canvas.getContext && typeof cb === "undefined") {
|
|
2071
|
+
cb = opts;
|
|
2072
|
+
opts = void 0;
|
|
2073
|
+
} else {
|
|
2074
|
+
cb = opts;
|
|
2075
|
+
opts = text;
|
|
2076
|
+
text = canvas;
|
|
2077
|
+
canvas = void 0;
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
} else {
|
|
2081
|
+
if (argsNum < 1) {
|
|
2082
|
+
throw new Error("Too few arguments provided");
|
|
2083
|
+
}
|
|
2084
|
+
if (argsNum === 1) {
|
|
2085
|
+
text = canvas;
|
|
2086
|
+
canvas = opts = void 0;
|
|
2087
|
+
} else if (argsNum === 2 && !canvas.getContext) {
|
|
2088
|
+
opts = text;
|
|
2089
|
+
text = canvas;
|
|
2090
|
+
canvas = void 0;
|
|
2091
|
+
}
|
|
2092
|
+
return new Promise(function(resolve, reject) {
|
|
2093
|
+
try {
|
|
2094
|
+
const data = QRCode2.create(text, opts);
|
|
2095
|
+
resolve(renderFunc(data, canvas, opts));
|
|
2096
|
+
} catch (e) {
|
|
2097
|
+
reject(e);
|
|
2098
|
+
}
|
|
2099
|
+
});
|
|
2100
|
+
}
|
|
2101
|
+
try {
|
|
2102
|
+
const data = QRCode2.create(text, opts);
|
|
2103
|
+
cb(null, renderFunc(data, canvas, opts));
|
|
2104
|
+
} catch (e) {
|
|
2105
|
+
cb(e);
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
exports.create = QRCode2.create;
|
|
2109
|
+
exports.toCanvas = renderCanvas.bind(null, CanvasRenderer.render);
|
|
2110
|
+
exports.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL);
|
|
2111
|
+
exports.toString = renderCanvas.bind(null, function(data, _, opts) {
|
|
2112
|
+
return SvgRenderer.render(data, opts);
|
|
2113
|
+
});
|
|
2114
|
+
}
|
|
2115
|
+
});
|
|
2116
|
+
|
|
2117
|
+
// src/client/index.tsx
|
|
2118
|
+
var index_exports = {};
|
|
2119
|
+
__export(index_exports, {
|
|
2120
|
+
apply: () => apply
|
|
2121
|
+
});
|
|
2122
|
+
module.exports = __toCommonJS(index_exports);
|
|
2123
|
+
|
|
2124
|
+
// src/client/maestro-card.jsx
|
|
2125
|
+
var import_react = require("react");
|
|
2126
|
+
var import_qrcode = __toESM(require_browser(), 1);
|
|
2127
|
+
|
|
2128
|
+
// src/client/api.ts
|
|
2129
|
+
var MAESTRO_RPC_CHANNEL = "/dsh-maestro-review";
|
|
2130
|
+
var MAESTRO_ENDPOINTS = Object.freeze({
|
|
2131
|
+
status: "maestro.status",
|
|
2132
|
+
getConfig: "maestro.getConfig",
|
|
2133
|
+
saveConfig: "maestro.saveConfig",
|
|
2134
|
+
tunnelStart: "maestro.tunnelStart",
|
|
2135
|
+
tunnelStop: "maestro.tunnelStop",
|
|
2136
|
+
proxyStatus: "maestro.proxyStatus",
|
|
2137
|
+
getPin: "maestro.getPin",
|
|
2138
|
+
rotatePin: "maestro.rotatePin",
|
|
2139
|
+
lanPinStatus: "maestro.lanPin.status",
|
|
2140
|
+
lanPinSetEnabled: "maestro.lanPin.setEnabled",
|
|
2141
|
+
lanPinRotate: "maestro.lanPin.rotate",
|
|
2142
|
+
reviewsList: "maestro.reviews.list",
|
|
2143
|
+
modelsList: "maestro.models.list",
|
|
2144
|
+
modelsCurrent: "maestro.models.current"
|
|
2145
|
+
});
|
|
2146
|
+
|
|
2147
|
+
// src/client/webhook-secret.ts
|
|
2148
|
+
var BASE64URL_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
2149
|
+
function generateWebhookSecret(randomValues = crypto.getRandomValues.bind(crypto)) {
|
|
2150
|
+
const bytes = randomValues(new Uint8Array(32));
|
|
2151
|
+
return Array.from(bytes, (byte) => BASE64URL_ALPHABET[byte & 63]).join("");
|
|
2152
|
+
}
|
|
2153
|
+
function gitlabWebhookUrl(hostname) {
|
|
2154
|
+
const authority = hostname?.trim().replace(/^https?:\/\//, "").replace(/\/+$/, "") || "<your-hostname>";
|
|
2155
|
+
return `https://${authority}/hooks/gitlab-mr`;
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
// src/client/maestro-card.jsx
|
|
2159
|
+
var inputStyle = {
|
|
2160
|
+
height: 34,
|
|
2161
|
+
padding: "0 12px",
|
|
2162
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
2163
|
+
borderRadius: 8,
|
|
2164
|
+
background: "var(--dsw-alias-bg-layer-3)",
|
|
2165
|
+
font: "inherit",
|
|
2166
|
+
fontSize: 13,
|
|
2167
|
+
color: "var(--dsw-alias-label-primary)",
|
|
2168
|
+
width: "100%",
|
|
2169
|
+
boxSizing: "border-box"
|
|
2170
|
+
};
|
|
2171
|
+
var fieldLabelStyle = {
|
|
2172
|
+
display: "block",
|
|
2173
|
+
fontSize: 12,
|
|
2174
|
+
lineHeight: 1.5,
|
|
2175
|
+
color: "var(--dsw-alias-label-secondary)",
|
|
2176
|
+
margin: "10px 0 4px"
|
|
2177
|
+
};
|
|
2178
|
+
var secondaryButtonStyle = {
|
|
2179
|
+
height: 32,
|
|
2180
|
+
padding: "0 14px",
|
|
2181
|
+
borderRadius: 16,
|
|
2182
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
2183
|
+
background: "transparent",
|
|
2184
|
+
color: "var(--dsw-alias-label-primary)",
|
|
2185
|
+
font: "inherit",
|
|
2186
|
+
fontSize: 13,
|
|
2187
|
+
cursor: "pointer",
|
|
2188
|
+
flex: "none"
|
|
2189
|
+
};
|
|
2190
|
+
var primaryButtonStyle = {
|
|
2191
|
+
...secondaryButtonStyle,
|
|
2192
|
+
border: "none",
|
|
2193
|
+
background: "var(--dsw-alias-button-primary-fill)",
|
|
2194
|
+
color: "var(--dsw-alias-label-primary-foreground)"
|
|
2195
|
+
};
|
|
2196
|
+
var captionStyle = {
|
|
2197
|
+
fontSize: 12,
|
|
2198
|
+
lineHeight: 1.5,
|
|
2199
|
+
margin: "4px 0",
|
|
2200
|
+
color: "var(--dsw-alias-label-secondary)"
|
|
2201
|
+
};
|
|
2202
|
+
var sectionStyle = {
|
|
2203
|
+
marginTop: 20,
|
|
2204
|
+
paddingTop: 16,
|
|
2205
|
+
borderTop: "1px solid var(--dsw-alias-border-l2)"
|
|
2206
|
+
};
|
|
2207
|
+
var headingStyle = {
|
|
2208
|
+
margin: "0 0 6px",
|
|
2209
|
+
fontSize: 13,
|
|
2210
|
+
fontWeight: 600,
|
|
2211
|
+
color: "var(--dsw-alias-label-primary)"
|
|
2212
|
+
};
|
|
2213
|
+
var errorStyle = {
|
|
2214
|
+
color: "var(--dsw-alias-state-error-primary)",
|
|
2215
|
+
fontSize: 12,
|
|
2216
|
+
margin: "8px 0 0"
|
|
2217
|
+
};
|
|
2218
|
+
var codeStyle = {
|
|
2219
|
+
fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
2220
|
+
fontSize: 12,
|
|
2221
|
+
color: "var(--dsw-alias-label-primary)",
|
|
2222
|
+
wordBreak: "break-all"
|
|
2223
|
+
};
|
|
2224
|
+
function QrImage({ url, size = 104 }) {
|
|
2225
|
+
const [dataUrl, setDataUrl] = (0, import_react.useState)(null);
|
|
2226
|
+
(0, import_react.useEffect)(() => {
|
|
2227
|
+
let live = true;
|
|
2228
|
+
import_qrcode.default.toDataURL(url, { margin: 0, width: size * 2 }).then((d) => {
|
|
2229
|
+
if (live) setDataUrl(d);
|
|
2230
|
+
}).catch(() => {
|
|
2231
|
+
});
|
|
2232
|
+
return () => {
|
|
2233
|
+
live = false;
|
|
2234
|
+
};
|
|
2235
|
+
}, [url, size]);
|
|
2236
|
+
return (0, import_react.createElement)(
|
|
2237
|
+
"div",
|
|
2238
|
+
{
|
|
2239
|
+
style: {
|
|
2240
|
+
background: "#ffffff",
|
|
2241
|
+
borderRadius: 10,
|
|
2242
|
+
boxSizing: "border-box",
|
|
2243
|
+
width: size + 20,
|
|
2244
|
+
height: size + 20,
|
|
2245
|
+
display: "flex",
|
|
2246
|
+
alignItems: "center",
|
|
2247
|
+
justifyContent: "center",
|
|
2248
|
+
lineHeight: 0,
|
|
2249
|
+
flex: "none",
|
|
2250
|
+
alignSelf: "flex-start"
|
|
2251
|
+
}
|
|
2252
|
+
},
|
|
2253
|
+
dataUrl === null ? (0, import_react.createElement)("div", { style: { width: size, height: size, background: "var(--dsw-alias-bg-skeleton)", borderRadius: 4 } }) : (0, import_react.createElement)("img", { src: dataUrl, alt: url, width: size, height: size, style: { display: "block" } })
|
|
2254
|
+
);
|
|
2255
|
+
}
|
|
2256
|
+
function NamedTunnelSetupNote() {
|
|
2257
|
+
return (0, import_react.createElement)(
|
|
2258
|
+
"div",
|
|
2259
|
+
{ style: captionStyle },
|
|
2260
|
+
(0, import_react.createElement)("p", { style: { ...captionStyle, marginBottom: 4 } }, "Named tunnel needs a one-time manual setup (requires your own Cloudflare account \u2014 cannot be automated):"),
|
|
2261
|
+
(0, import_react.createElement)(
|
|
2262
|
+
"ol",
|
|
2263
|
+
{ style: { margin: "4px 0", paddingLeft: 20 } },
|
|
2264
|
+
(0, import_react.createElement)("li", null, "cloudflared tunnel login"),
|
|
2265
|
+
(0, import_react.createElement)("li", null, "cloudflared tunnel create dsh-maestro-webhook"),
|
|
2266
|
+
(0, import_react.createElement)("li", null, "cloudflared tunnel route dns dsh-maestro-webhook <your-hostname>"),
|
|
2267
|
+
(0, import_react.createElement)("li", null, "Paste the printed Tunnel ID, the credentials file path (~/.cloudflared/<id>.json), and the hostname below.")
|
|
2268
|
+
)
|
|
2269
|
+
);
|
|
2270
|
+
}
|
|
2271
|
+
function ReviewModelSelector({ value, catalog, fallbackValue, fallbackLabel, onChange, label }) {
|
|
2272
|
+
const groups = catalog?.groups ?? [];
|
|
2273
|
+
const providers = groups.map((g) => g.provider);
|
|
2274
|
+
const selectedProvider = value?.provider ?? "";
|
|
2275
|
+
const providerGroup = groups.find((g) => g.provider === selectedProvider);
|
|
2276
|
+
const models = providerGroup?.models ?? [];
|
|
2277
|
+
const selectedEffort = value?.reasoningEffort ?? "";
|
|
2278
|
+
const [open, setOpen] = (0, import_react.useState)(false);
|
|
2279
|
+
const [pane, setPane] = (0, import_react.useState)("root");
|
|
2280
|
+
const rootRef = (0, import_react.useRef)(null);
|
|
2281
|
+
(0, import_react.useEffect)(() => {
|
|
2282
|
+
if (!open) return;
|
|
2283
|
+
const onDown = (e) => {
|
|
2284
|
+
if (rootRef.current && !rootRef.current.contains(e.target)) {
|
|
2285
|
+
setOpen(false);
|
|
2286
|
+
setPane("root");
|
|
2287
|
+
}
|
|
2288
|
+
};
|
|
2289
|
+
const onKey = (e) => {
|
|
2290
|
+
if (e.key === "Escape") {
|
|
2291
|
+
setOpen(false);
|
|
2292
|
+
setPane("root");
|
|
2293
|
+
}
|
|
2294
|
+
};
|
|
2295
|
+
document.addEventListener("mousedown", onDown);
|
|
2296
|
+
document.addEventListener("keydown", onKey);
|
|
2297
|
+
return () => {
|
|
2298
|
+
document.removeEventListener("mousedown", onDown);
|
|
2299
|
+
document.removeEventListener("keydown", onKey);
|
|
2300
|
+
};
|
|
2301
|
+
}, [open]);
|
|
2302
|
+
const update = (field, newVal) => {
|
|
2303
|
+
if (newVal === "" && field === "provider") {
|
|
2304
|
+
onChange(null);
|
|
2305
|
+
setOpen(false);
|
|
2306
|
+
setPane("root");
|
|
2307
|
+
return;
|
|
2308
|
+
}
|
|
2309
|
+
const next = { provider: value?.provider ?? "", model: value?.model ?? "", ...value?.reasoningEffort ? { reasoningEffort: value.reasoningEffort } : {} };
|
|
2310
|
+
if (field === "provider") {
|
|
2311
|
+
const g = groups.find((x) => x.provider === newVal);
|
|
2312
|
+
next.provider = newVal;
|
|
2313
|
+
next.model = g?.models[0] ?? "";
|
|
2314
|
+
} else if (field === "model") {
|
|
2315
|
+
next.model = newVal;
|
|
2316
|
+
} else if (field === "reasoningEffort") {
|
|
2317
|
+
if (newVal === "") delete next.reasoningEffort;
|
|
2318
|
+
else next.reasoningEffort = newVal;
|
|
2319
|
+
}
|
|
2320
|
+
if (!next.provider || !next.model) {
|
|
2321
|
+
onChange(null);
|
|
2322
|
+
} else {
|
|
2323
|
+
onChange(next);
|
|
2324
|
+
}
|
|
2325
|
+
};
|
|
2326
|
+
const effectiveFallback = fallbackValue !== void 0 ? fallbackValue : catalog?.current ?? null;
|
|
2327
|
+
const effectiveFallbackLabel = fallbackLabel ?? "Use DSH default";
|
|
2328
|
+
const triggerLabel = value ? `${value.provider} / ${value.model}${value.reasoningEffort ? ` \xB7 ${value.reasoningEffort}` : ""}` : effectiveFallback ? `${effectiveFallbackLabel} \xB7 ${effectiveFallback.provider}/${effectiveFallback.model}${effectiveFallback.reasoningEffort ? ` \xB7 ${effectiveFallback.reasoningEffort}` : ""}` : effectiveFallbackLabel;
|
|
2329
|
+
const triggerStyle = {
|
|
2330
|
+
height: 32,
|
|
2331
|
+
padding: "0 12px 0 14px",
|
|
2332
|
+
borderRadius: 20,
|
|
2333
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
2334
|
+
background: "var(--dsw-alias-bg-layer-2)",
|
|
2335
|
+
color: "var(--dsw-alias-label-primary)",
|
|
2336
|
+
font: "inherit",
|
|
2337
|
+
fontSize: 13,
|
|
2338
|
+
display: "inline-flex",
|
|
2339
|
+
alignItems: "center",
|
|
2340
|
+
gap: 8,
|
|
2341
|
+
cursor: "pointer",
|
|
2342
|
+
maxWidth: 320,
|
|
2343
|
+
whiteSpace: "nowrap"
|
|
2344
|
+
};
|
|
2345
|
+
const menuStyle = {
|
|
2346
|
+
position: "absolute",
|
|
2347
|
+
top: "calc(100% + 8px)",
|
|
2348
|
+
left: 0,
|
|
2349
|
+
minWidth: 300,
|
|
2350
|
+
maxWidth: 360,
|
|
2351
|
+
background: "var(--dsw-alias-bg-layer-1)",
|
|
2352
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
2353
|
+
borderRadius: 12,
|
|
2354
|
+
boxShadow: "0 8 24px rgba(0,0,0,.12)",
|
|
2355
|
+
zIndex: 20,
|
|
2356
|
+
padding: 6
|
|
2357
|
+
};
|
|
2358
|
+
const rowStyle = {
|
|
2359
|
+
width: "100%",
|
|
2360
|
+
display: "flex",
|
|
2361
|
+
alignItems: "center",
|
|
2362
|
+
justifyContent: "space-between",
|
|
2363
|
+
gap: 12,
|
|
2364
|
+
padding: "9px 10px",
|
|
2365
|
+
borderRadius: 8,
|
|
2366
|
+
border: "none",
|
|
2367
|
+
background: "transparent",
|
|
2368
|
+
color: "var(--dsw-alias-label-primary)",
|
|
2369
|
+
font: "inherit",
|
|
2370
|
+
fontSize: 13,
|
|
2371
|
+
cursor: "pointer",
|
|
2372
|
+
textAlign: "left"
|
|
2373
|
+
};
|
|
2374
|
+
const check = (active) => active ? (0, import_react.createElement)("svg", { width: 16, height: 16, viewBox: "0 0 16 16", style: { flex: "none" } }, (0, import_react.createElement)("path", { d: "M3.5 8.2l2.8 2.8L12.5 4.8", fill: "none", stroke: "currentColor", strokeWidth: 1.6, strokeLinecap: "round", strokeLinejoin: "round" })) : (0, import_react.createElement)("span", { style: { width: 16, flex: "none" } });
|
|
2375
|
+
const chevronDown = (0, import_react.createElement)("svg", { width: 14, height: 14, viewBox: "0 0 14 14", style: { flex: "none", opacity: 0.7 } }, (0, import_react.createElement)("path", { d: "M3.5 5L7 8.5L10.5 5", fill: "none", stroke: "currentColor", strokeWidth: 1.4, strokeLinecap: "round", strokeLinejoin: "round" }));
|
|
2376
|
+
const chevronRight = (0, import_react.createElement)("svg", { width: 14, height: 14, viewBox: "0 0 14 14", style: { flex: "none", opacity: 0.6 } }, (0, import_react.createElement)("path", { d: "M5 3.5L8.5 7L5 10.5", fill: "none", stroke: "currentColor", strokeWidth: 1.4, strokeLinecap: "round", strokeLinejoin: "round" }));
|
|
2377
|
+
const effortLabel = selectedEffort === "" ? "Default effort" : selectedEffort;
|
|
2378
|
+
const modelLabel = selectedProvider === "" ? "Select model" : value?.model ?? "Select model";
|
|
2379
|
+
return (0, import_react.createElement)(
|
|
2380
|
+
"div",
|
|
2381
|
+
{ ref: rootRef, style: { position: "relative", display: "inline-block", maxWidth: "100%" } },
|
|
2382
|
+
label && (0, import_react.createElement)("span", { style: fieldLabelStyle }, label),
|
|
2383
|
+
(0, import_react.createElement)(
|
|
2384
|
+
"button",
|
|
2385
|
+
{ type: "button", style: triggerStyle, onClick: () => {
|
|
2386
|
+
setOpen((v) => !v);
|
|
2387
|
+
setPane("root");
|
|
2388
|
+
}, "aria-expanded": open, "aria-haspopup": "menu", title: triggerLabel },
|
|
2389
|
+
(0, import_react.createElement)("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, triggerLabel),
|
|
2390
|
+
chevronDown
|
|
2391
|
+
),
|
|
2392
|
+
open && (0, import_react.createElement)(
|
|
2393
|
+
"div",
|
|
2394
|
+
{ style: menuStyle, role: "menu" },
|
|
2395
|
+
pane === "root" && (0, import_react.createElement)(
|
|
2396
|
+
"div",
|
|
2397
|
+
null,
|
|
2398
|
+
(0, import_react.createElement)(
|
|
2399
|
+
"button",
|
|
2400
|
+
{ type: "button", style: { ...rowStyle, background: !value ? "var(--dsw-alias-bg-layer-2)" : "transparent" }, onClick: () => {
|
|
2401
|
+
onChange(null);
|
|
2402
|
+
setOpen(false);
|
|
2403
|
+
} },
|
|
2404
|
+
(0, import_react.createElement)("span", null, effectiveFallbackLabel),
|
|
2405
|
+
check(!value)
|
|
2406
|
+
),
|
|
2407
|
+
(0, import_react.createElement)("div", { style: { height: 1, background: "var(--dsw-alias-border-l2)", margin: "6px 2px" } }),
|
|
2408
|
+
(0, import_react.createElement)(
|
|
2409
|
+
"button",
|
|
2410
|
+
{ type: "button", style: rowStyle, onClick: () => setPane("model") },
|
|
2411
|
+
(0, import_react.createElement)("span", null, "Model"),
|
|
2412
|
+
(0, import_react.createElement)("span", { style: { display: "flex", alignItems: "center", gap: 8, color: "var(--dsw-alias-label-secondary)", maxWidth: 160, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, (0, import_react.createElement)("span", { style: { overflow: "hidden", textOverflow: "ellipsis" } }, modelLabel), chevronRight)
|
|
2413
|
+
),
|
|
2414
|
+
(0, import_react.createElement)(
|
|
2415
|
+
"button",
|
|
2416
|
+
{ type: "button", style: rowStyle, onClick: () => setPane("effort") },
|
|
2417
|
+
(0, import_react.createElement)("span", null, "Effort"),
|
|
2418
|
+
(0, import_react.createElement)("span", { style: { display: "flex", alignItems: "center", gap: 8, color: "var(--dsw-alias-label-secondary)" } }, effortLabel, chevronRight)
|
|
2419
|
+
),
|
|
2420
|
+
value && (0, import_react.createElement)("p", { style: { ...captionStyle, margin: "8px 4px 2px" } }, `Selected: ${value.provider} / ${value.model}${value.reasoningEffort ? ` (${value.reasoningEffort})` : ""}`),
|
|
2421
|
+
!value && effectiveFallback && (0, import_react.createElement)("p", { style: { ...captionStyle, margin: "8px 4px 2px" } }, `${effectiveFallbackLabel === "Use Global" ? "Using Global" : "Using DSH default"}: ${effectiveFallback.provider} / ${effectiveFallback.model}${effectiveFallback.reasoningEffort ? ` (${effectiveFallback.reasoningEffort})` : ""}`)
|
|
2422
|
+
),
|
|
2423
|
+
pane === "model" && (0, import_react.createElement)(
|
|
2424
|
+
"div",
|
|
2425
|
+
null,
|
|
2426
|
+
(0, import_react.createElement)("button", { type: "button", style: { ...rowStyle, color: "var(--dsw-alias-label-secondary)" }, onClick: () => setPane("root") }, (0, import_react.createElement)("span", null, "\u2190 Back"), (0, import_react.createElement)("span", { style: { fontSize: 12 } }, "Model")),
|
|
2427
|
+
(0, import_react.createElement)(
|
|
2428
|
+
"div",
|
|
2429
|
+
{ style: { maxHeight: 260, overflowY: "auto", marginTop: 4 } },
|
|
2430
|
+
providers.length === 0 ? (0, import_react.createElement)("p", { style: captionStyle }, "No providers") : providers.map((p) => {
|
|
2431
|
+
const g = groups.find((x) => x.provider === p);
|
|
2432
|
+
const ms = g?.models ?? [];
|
|
2433
|
+
return (0, import_react.createElement)(
|
|
2434
|
+
"div",
|
|
2435
|
+
{ key: p, style: { marginBottom: 8 } },
|
|
2436
|
+
(0, import_react.createElement)("div", { style: { fontSize: 11, fontWeight: 600, color: "var(--dsw-alias-label-secondary)", padding: "6px 10px 2px", textTransform: "uppercase", letterSpacing: 0.4, display: "flex", alignItems: "center", gap: 6 } }, (0, import_react.createElement)("span", { style: { width: 6, height: 6, borderRadius: 3, background: "var(--dsw-alias-border-l2)", flex: "none" } }), g?.name ?? p),
|
|
2437
|
+
ms.length === 0 ? (0, import_react.createElement)("p", { style: { ...captionStyle, padding: "2px 10px 2px 28px" } }, "No models") : (0, import_react.createElement)(
|
|
2438
|
+
"div",
|
|
2439
|
+
{ style: { marginLeft: 12, borderLeft: "1px solid var(--dsw-alias-border-l2)", paddingLeft: 6, display: "flex", flexDirection: "column", gap: 2 } },
|
|
2440
|
+
ms.map((m) => (0, import_react.createElement)("button", { key: m, type: "button", style: { ...rowStyle, paddingLeft: 10, background: value?.provider === p && value?.model === m ? "var(--dsw-alias-bg-layer-2)" : "transparent" }, onClick: () => {
|
|
2441
|
+
update("model", m);
|
|
2442
|
+
if (value?.provider !== p) update("provider", p);
|
|
2443
|
+
else {
|
|
2444
|
+
const next = { provider: p, model: m, ...selectedEffort ? { reasoningEffort: selectedEffort } : {} };
|
|
2445
|
+
onChange(next);
|
|
2446
|
+
setPane("root");
|
|
2447
|
+
}
|
|
2448
|
+
} }, (0, import_react.createElement)("span", { style: { overflow: "hidden", textOverflow: "ellipsis" } }, m), check(value?.provider === p && value?.model === m)))
|
|
2449
|
+
)
|
|
2450
|
+
);
|
|
2451
|
+
})
|
|
2452
|
+
)
|
|
2453
|
+
),
|
|
2454
|
+
pane === "effort" && (0, import_react.createElement)(
|
|
2455
|
+
"div",
|
|
2456
|
+
null,
|
|
2457
|
+
(0, import_react.createElement)("button", { type: "button", style: { ...rowStyle, color: "var(--dsw-alias-label-secondary)" }, onClick: () => setPane("root") }, (0, import_react.createElement)("span", null, "\u2190 Back"), (0, import_react.createElement)("span", { style: { fontSize: 12 } }, "Effort")),
|
|
2458
|
+
(0, import_react.createElement)(
|
|
2459
|
+
"div",
|
|
2460
|
+
{ style: { marginTop: 4 } },
|
|
2461
|
+
[
|
|
2462
|
+
{ id: "", label: "Default effort" },
|
|
2463
|
+
{ id: "low", label: "low" },
|
|
2464
|
+
{ id: "medium", label: "medium" },
|
|
2465
|
+
{ id: "high", label: "high" }
|
|
2466
|
+
].map((e) => (0, import_react.createElement)("button", { key: e.id || "default", type: "button", style: { ...rowStyle, background: selectedEffort === e.id ? "var(--dsw-alias-bg-layer-2)" : "transparent" }, onClick: () => {
|
|
2467
|
+
update("reasoningEffort", e.id);
|
|
2468
|
+
setPane("root");
|
|
2469
|
+
} }, (0, import_react.createElement)("span", null, e.label), check(selectedEffort === e.id)))
|
|
2470
|
+
)
|
|
2471
|
+
)
|
|
2472
|
+
)
|
|
2473
|
+
);
|
|
2474
|
+
}
|
|
2475
|
+
function ProjectMappingsEditor({ mappings, onChange, catalog, globalReviewModel }) {
|
|
2476
|
+
const rows = mappings.length > 0 ? mappings : [{ projectPath: "", localRepoPath: "", reviewProfile: "magento2" }];
|
|
2477
|
+
const updateRow = (index, field, value) => {
|
|
2478
|
+
const next = rows.map((row, i) => i === index ? { ...row, [field]: value } : row);
|
|
2479
|
+
onChange(next.filter((r) => r.projectPath !== "" || r.localRepoPath !== ""));
|
|
2480
|
+
};
|
|
2481
|
+
const removeRow = (index) => onChange(rows.filter((_, i) => i !== index));
|
|
2482
|
+
const addRow = () => onChange([...rows, { projectPath: "", localRepoPath: "", reviewProfile: "magento2" }]);
|
|
2483
|
+
return (0, import_react.createElement)(
|
|
2484
|
+
"div",
|
|
2485
|
+
null,
|
|
2486
|
+
(0, import_react.createElement)("span", { style: fieldLabelStyle }, "Tracked projects (GitLab path \u2192 local repo checkout \u2192 review profile \u2192 review model override)"),
|
|
2487
|
+
rows.map((row, i) => (0, import_react.createElement)(
|
|
2488
|
+
"div",
|
|
2489
|
+
{ key: i, "data-maestro-mapping-row": "", style: { display: "flex", gap: 8, marginBottom: 8, alignItems: "center", flexWrap: "wrap" } },
|
|
2490
|
+
(0, import_react.createElement)("input", { placeholder: "group/project", style: { ...inputStyle, flex: "1 1 120px" }, value: row.projectPath, onChange: (e) => updateRow(i, "projectPath", e.target.value) }),
|
|
2491
|
+
(0, import_react.createElement)("input", { placeholder: "/path/to/local/clone", style: { ...inputStyle, flex: "1 1 140px" }, value: row.localRepoPath, onChange: (e) => updateRow(i, "localRepoPath", e.target.value) }),
|
|
2492
|
+
(0, import_react.createElement)(
|
|
2493
|
+
"select",
|
|
2494
|
+
{ style: { ...inputStyle, flex: "0 0 130px" }, value: row.reviewProfile ?? "magento2", onChange: (e) => updateRow(i, "reviewProfile", e.target.value) },
|
|
2495
|
+
(0, import_react.createElement)("option", { value: "magento2" }, "Magento 2"),
|
|
2496
|
+
(0, import_react.createElement)("option", { value: "generic" }, "Generic")
|
|
2497
|
+
),
|
|
2498
|
+
(0, import_react.createElement)(
|
|
2499
|
+
"div",
|
|
2500
|
+
{ style: { flex: "0 0 auto" } },
|
|
2501
|
+
(0, import_react.createElement)(ReviewModelSelector, {
|
|
2502
|
+
value: row.reviewModel ?? null,
|
|
2503
|
+
catalog,
|
|
2504
|
+
fallbackValue: globalReviewModel ?? catalog?.current ?? null,
|
|
2505
|
+
fallbackLabel: globalReviewModel ? "Use Global" : "Use DSH default",
|
|
2506
|
+
onChange: (v) => updateRow(i, "reviewModel", v),
|
|
2507
|
+
label: null
|
|
2508
|
+
})
|
|
2509
|
+
),
|
|
2510
|
+
(0, import_react.createElement)("button", { onClick: () => removeRow(i), style: secondaryButtonStyle, title: "Remove mapping" }, "\u2715")
|
|
2511
|
+
)),
|
|
2512
|
+
(0, import_react.createElement)("button", { onClick: addRow, style: secondaryButtonStyle }, "+ Add mapping")
|
|
2513
|
+
);
|
|
2514
|
+
}
|
|
2515
|
+
function SecretInput({ label, placeholder, hasSaved, onSave }) {
|
|
2516
|
+
const [draft, setDraft] = (0, import_react.useState)("");
|
|
2517
|
+
const clear = () => {
|
|
2518
|
+
setDraft("");
|
|
2519
|
+
onSave("");
|
|
2520
|
+
};
|
|
2521
|
+
return (0, import_react.createElement)(
|
|
2522
|
+
"div",
|
|
2523
|
+
null,
|
|
2524
|
+
(0, import_react.createElement)("label", { style: fieldLabelStyle }, label),
|
|
2525
|
+
(0, import_react.createElement)(
|
|
2526
|
+
"div",
|
|
2527
|
+
{ style: { display: "flex", gap: 8 } },
|
|
2528
|
+
(0, import_react.createElement)("input", {
|
|
2529
|
+
placeholder: hasSaved === true ? "saved \u2014 leave blank to keep" : placeholder,
|
|
2530
|
+
type: "password",
|
|
2531
|
+
autoComplete: "off",
|
|
2532
|
+
style: inputStyle,
|
|
2533
|
+
value: draft,
|
|
2534
|
+
onChange: (e) => setDraft(e.target.value),
|
|
2535
|
+
onBlur: () => {
|
|
2536
|
+
if (draft !== "") onSave(draft);
|
|
2537
|
+
}
|
|
2538
|
+
}),
|
|
2539
|
+
hasSaved === true && (0, import_react.createElement)("button", { type: "button", style: secondaryButtonStyle, onClick: clear }, "Clear")
|
|
2540
|
+
)
|
|
2541
|
+
);
|
|
2542
|
+
}
|
|
2543
|
+
function ToggleField({ label, caption, checked, onChange }) {
|
|
2544
|
+
return (0, import_react.createElement)(
|
|
2545
|
+
"label",
|
|
2546
|
+
{ style: { display: "flex", alignItems: "flex-start", gap: 8, margin: "8px 0", cursor: "pointer" } },
|
|
2547
|
+
(0, import_react.createElement)("input", { type: "checkbox", checked: checked === true, onChange: (e) => onChange(e.target.checked), style: { marginTop: 3 } }),
|
|
2548
|
+
(0, import_react.createElement)(
|
|
2549
|
+
"span",
|
|
2550
|
+
null,
|
|
2551
|
+
(0, import_react.createElement)("div", { style: { fontSize: 13 } }, label),
|
|
2552
|
+
caption != null && (0, import_react.createElement)("div", { style: captionStyle }, caption)
|
|
2553
|
+
)
|
|
2554
|
+
);
|
|
2555
|
+
}
|
|
2556
|
+
function ReviewHistoryPanel({ rpcCall }) {
|
|
2557
|
+
const [entries, setEntries] = (0, import_react.useState)(null);
|
|
2558
|
+
(0, import_react.useEffect)(() => {
|
|
2559
|
+
rpcCall(MAESTRO_ENDPOINTS.reviewsList, {}).then((res) => {
|
|
2560
|
+
if (res?.ok) setEntries(res.value ?? []);
|
|
2561
|
+
}).catch(() => setEntries([]));
|
|
2562
|
+
}, []);
|
|
2563
|
+
if (entries === null) return (0, import_react.createElement)("p", { style: captionStyle }, "Loading review history\u2026");
|
|
2564
|
+
if (entries.length === 0) return (0, import_react.createElement)("p", { style: captionStyle }, "No reviews recorded yet.");
|
|
2565
|
+
const icon = (entry) => entry.status === "completed" ? "\u2705" : entry.status === "failed" ? "\u26A0\uFE0F" : "\u{1F440}";
|
|
2566
|
+
return (0, import_react.createElement)(
|
|
2567
|
+
"ul",
|
|
2568
|
+
{ style: { listStyle: "none", margin: 0, padding: 0 } },
|
|
2569
|
+
entries.map((entry) => (0, import_react.createElement)(
|
|
2570
|
+
"li",
|
|
2571
|
+
{ key: entry.id, style: { padding: "6px 0", borderBottom: "1px solid var(--dsw-alias-separator-default, #333)", fontSize: 13 } },
|
|
2572
|
+
(0, import_react.createElement)("span", null, `${icon(entry)} ${entry.projectPath} !${entry.mrIid} \xB7 ${entry.mode}${entry.trigger !== "mention" ? ` \xB7 ${entry.trigger}` : ""}`),
|
|
2573
|
+
(0, import_react.createElement)(
|
|
2574
|
+
"div",
|
|
2575
|
+
{ style: captionStyle },
|
|
2576
|
+
`${new Date(entry.startedAt).toLocaleString()}${entry.summary ? ` \u2014 ${entry.summary}` : ""}${entry.error ? ` \u2014 ${entry.error}` : ""}`
|
|
2577
|
+
)
|
|
2578
|
+
))
|
|
2579
|
+
);
|
|
2580
|
+
}
|
|
2581
|
+
function LanAccess({ proxyStatus, lanPin }) {
|
|
2582
|
+
const urls = proxyStatus?.lanUrls ?? [];
|
|
2583
|
+
const [selected, setSelected] = (0, import_react.useState)(0);
|
|
2584
|
+
const index = Math.min(selected, Math.max(urls.length - 1, 0));
|
|
2585
|
+
if (!proxyStatus?.running) {
|
|
2586
|
+
return (0, import_react.createElement)("p", { style: errorStyle }, proxyStatus?.errorMessage ?? "Proxy not running");
|
|
2587
|
+
}
|
|
2588
|
+
return (0, import_react.createElement)(
|
|
2589
|
+
"div",
|
|
2590
|
+
null,
|
|
2591
|
+
(0, import_react.createElement)("p", { style: captionStyle }, lanPin?.enabled === true ? "Open this full DSH UI from any device on your network \u2014 visitors enter the LAN PIN below." : "Open this full DSH UI from any device on your network \u2014 no PIN needed."),
|
|
2592
|
+
urls.length > 0 && (0, import_react.createElement)(
|
|
2593
|
+
"div",
|
|
2594
|
+
{ style: { display: "flex", gap: 6, flexWrap: "wrap", marginBottom: 12 } },
|
|
2595
|
+
urls.map((url, i) => (0, import_react.createElement)("button", {
|
|
2596
|
+
key: url,
|
|
2597
|
+
onClick: () => setSelected(i),
|
|
2598
|
+
style: {
|
|
2599
|
+
...secondaryButtonStyle,
|
|
2600
|
+
height: 26,
|
|
2601
|
+
padding: "0 10px",
|
|
2602
|
+
fontSize: 12,
|
|
2603
|
+
borderRadius: 13,
|
|
2604
|
+
...i === index ? { background: "var(--dsw-alias-button-primary-fill)", borderColor: "transparent", color: "var(--dsw-alias-label-primary-foreground)" } : {}
|
|
2605
|
+
}
|
|
2606
|
+
}, url.replace(/^http:\/\//, "")))
|
|
2607
|
+
),
|
|
2608
|
+
urls.length > 0 && (0, import_react.createElement)(
|
|
2609
|
+
"div",
|
|
2610
|
+
{ style: { display: "flex", gap: 14, alignItems: "center" } },
|
|
2611
|
+
(0, import_react.createElement)(QrImage, { url: urls[index], size: 116 }),
|
|
2612
|
+
(0, import_react.createElement)(
|
|
2613
|
+
"div",
|
|
2614
|
+
null,
|
|
2615
|
+
(0, import_react.createElement)("div", { style: codeStyle }, urls[index]),
|
|
2616
|
+
(0, import_react.createElement)("p", { style: captionStyle }, "Scan with a phone connected to the same network.")
|
|
2617
|
+
)
|
|
2618
|
+
),
|
|
2619
|
+
lanPin !== null && (0, import_react.createElement)(LanPinRow, { lanPin })
|
|
2620
|
+
);
|
|
2621
|
+
}
|
|
2622
|
+
function LanPinRow({ lanPin }) {
|
|
2623
|
+
return (0, import_react.createElement)(
|
|
2624
|
+
"div",
|
|
2625
|
+
{ style: { marginTop: 12 } },
|
|
2626
|
+
(0, import_react.createElement)(
|
|
2627
|
+
"label",
|
|
2628
|
+
{ style: { display: "flex", gap: 8, alignItems: "center", cursor: "pointer" } },
|
|
2629
|
+
(0, import_react.createElement)("input", {
|
|
2630
|
+
type: "checkbox",
|
|
2631
|
+
checked: lanPin.enabled,
|
|
2632
|
+
onChange: (e) => lanPin.onToggle(e.target.checked),
|
|
2633
|
+
style: { width: 15, height: 15, accentColor: "var(--dsw-alias-button-primary-fill)" }
|
|
2634
|
+
}),
|
|
2635
|
+
(0, import_react.createElement)("span", { style: { ...fieldLabelStyle, margin: 0 } }, "Require a PIN on the LAN")
|
|
2636
|
+
),
|
|
2637
|
+
lanPin.enabled && (0, import_react.createElement)(
|
|
2638
|
+
"div",
|
|
2639
|
+
{ style: { display: "flex", gap: 8, alignItems: "center", marginTop: 8 } },
|
|
2640
|
+
(0, import_react.createElement)("span", { style: { ...fieldLabelStyle, margin: 0 } }, "LAN PIN"),
|
|
2641
|
+
(0, import_react.createElement)("code", { style: { ...codeStyle, fontSize: 15, letterSpacing: 2 } }, lanPin.show ? lanPin.pin ?? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"),
|
|
2642
|
+
lanPin.show ? (0, import_react.createElement)("button", { onClick: lanPin.onHide, style: secondaryButtonStyle }, "Hide") : (0, import_react.createElement)("button", { onClick: lanPin.onShow, style: secondaryButtonStyle }, "Show"),
|
|
2643
|
+
(0, import_react.createElement)("button", { onClick: lanPin.onRotate, style: secondaryButtonStyle }, "Rotate")
|
|
2644
|
+
)
|
|
2645
|
+
);
|
|
2646
|
+
}
|
|
2647
|
+
function PublicAccess({ status, pin, showPin, onRevealPin, onHidePin, onRotatePin }) {
|
|
2648
|
+
return (0, import_react.createElement)(
|
|
2649
|
+
"div",
|
|
2650
|
+
null,
|
|
2651
|
+
status?.running && status?.publicUrl ? (0, import_react.createElement)(
|
|
2652
|
+
"div",
|
|
2653
|
+
null,
|
|
2654
|
+
(0, import_react.createElement)(
|
|
2655
|
+
"div",
|
|
2656
|
+
{ style: { display: "flex", gap: 14, alignItems: "center", marginBottom: 12 } },
|
|
2657
|
+
(0, import_react.createElement)(QrImage, { url: status.publicUrl, size: 116 }),
|
|
2658
|
+
(0, import_react.createElement)(
|
|
2659
|
+
"div",
|
|
2660
|
+
null,
|
|
2661
|
+
(0, import_react.createElement)("div", { style: codeStyle }, status.publicUrl),
|
|
2662
|
+
(0, import_react.createElement)("p", { style: captionStyle }, "Works from anywhere; visitors enter the PIN below.")
|
|
2663
|
+
)
|
|
2664
|
+
)
|
|
2665
|
+
) : (0, import_react.createElement)("p", { style: captionStyle }, "Start the tunnel to get a public address."),
|
|
2666
|
+
(0, import_react.createElement)(
|
|
2667
|
+
"div",
|
|
2668
|
+
{ style: { display: "flex", gap: 8, alignItems: "center" } },
|
|
2669
|
+
(0, import_react.createElement)("span", { style: { ...fieldLabelStyle, margin: 0 } }, "Access PIN"),
|
|
2670
|
+
(0, import_react.createElement)("code", { style: { ...codeStyle, fontSize: 15, letterSpacing: 2 } }, showPin && pin !== null ? pin : "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"),
|
|
2671
|
+
showPin ? (0, import_react.createElement)("button", { onClick: onHidePin, style: secondaryButtonStyle }, "Hide") : (0, import_react.createElement)("button", { onClick: onRevealPin, style: secondaryButtonStyle }, "Show"),
|
|
2672
|
+
(0, import_react.createElement)("button", { onClick: onRotatePin, style: secondaryButtonStyle }, "Rotate")
|
|
2673
|
+
),
|
|
2674
|
+
(0, import_react.createElement)("p", { style: captionStyle }, "Stays the same across tunnel and DSH restarts; use Rotate when you need a new PIN.")
|
|
2675
|
+
);
|
|
2676
|
+
}
|
|
2677
|
+
function MaestroSettingsTab({ rpcCall }) {
|
|
2678
|
+
const [status, setStatus] = (0, import_react.useState)(null);
|
|
2679
|
+
const [proxyStatus, setProxyStatus] = (0, import_react.useState)(null);
|
|
2680
|
+
const [config, setConfig] = (0, import_react.useState)({ tunnelMode: "quick", projectMappings: [] });
|
|
2681
|
+
const [catalog, setCatalog] = (0, import_react.useState)(null);
|
|
2682
|
+
const [busy, setBusy] = (0, import_react.useState)(false);
|
|
2683
|
+
const [error, setError] = (0, import_react.useState)(null);
|
|
2684
|
+
const [pin, setPin] = (0, import_react.useState)(null);
|
|
2685
|
+
const [showPin, setShowPin] = (0, import_react.useState)(false);
|
|
2686
|
+
const [lanPinEnabled, setLanPinEnabled] = (0, import_react.useState)(false);
|
|
2687
|
+
const [lanPin, setLanPin] = (0, import_react.useState)(null);
|
|
2688
|
+
const [showLanPin, setShowLanPin] = (0, import_react.useState)(false);
|
|
2689
|
+
const call = async (endpoint, payload) => {
|
|
2690
|
+
const res = await rpcCall(endpoint, payload);
|
|
2691
|
+
if (!res?.ok) throw new Error(res?.error?.message ?? "RPC failed");
|
|
2692
|
+
return res.value;
|
|
2693
|
+
};
|
|
2694
|
+
const refresh = async () => {
|
|
2695
|
+
try {
|
|
2696
|
+
setStatus(await call(MAESTRO_ENDPOINTS.status, {}));
|
|
2697
|
+
} catch {
|
|
2698
|
+
}
|
|
2699
|
+
try {
|
|
2700
|
+
setProxyStatus(await call(MAESTRO_ENDPOINTS.proxyStatus, {}));
|
|
2701
|
+
} catch {
|
|
2702
|
+
}
|
|
2703
|
+
};
|
|
2704
|
+
(0, import_react.useEffect)(() => {
|
|
2705
|
+
call(MAESTRO_ENDPOINTS.getConfig, {}).then((saved) => setConfig((prev) => ({ ...prev, ...saved }))).catch(() => {
|
|
2706
|
+
});
|
|
2707
|
+
call(MAESTRO_ENDPOINTS.lanPinStatus, {}).then((value) => {
|
|
2708
|
+
setLanPinEnabled(value.enabled);
|
|
2709
|
+
if (value.enabled) setLanPin(value.pin ?? null);
|
|
2710
|
+
}).catch(() => {
|
|
2711
|
+
});
|
|
2712
|
+
call(MAESTRO_ENDPOINTS.modelsList, {}).then((value) => setCatalog(value)).catch(() => {
|
|
2713
|
+
});
|
|
2714
|
+
}, []);
|
|
2715
|
+
(0, import_react.useEffect)(() => {
|
|
2716
|
+
refresh();
|
|
2717
|
+
const t = setInterval(refresh, 3e3);
|
|
2718
|
+
return () => clearInterval(t);
|
|
2719
|
+
}, []);
|
|
2720
|
+
const revealPin = async () => {
|
|
2721
|
+
if (pin === null) {
|
|
2722
|
+
try {
|
|
2723
|
+
setPin((await call(MAESTRO_ENDPOINTS.getPin, {})).pin);
|
|
2724
|
+
} catch (err) {
|
|
2725
|
+
setError(err.message);
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
setShowPin(true);
|
|
2729
|
+
};
|
|
2730
|
+
const rotatePin = async () => {
|
|
2731
|
+
setError(null);
|
|
2732
|
+
try {
|
|
2733
|
+
const fresh = (await call(MAESTRO_ENDPOINTS.rotatePin, {})).pin;
|
|
2734
|
+
setPin(fresh);
|
|
2735
|
+
setShowPin(true);
|
|
2736
|
+
} catch (err) {
|
|
2737
|
+
setError(err.message);
|
|
2738
|
+
}
|
|
2739
|
+
};
|
|
2740
|
+
const toggleLanPin = async (enabled) => {
|
|
2741
|
+
setError(null);
|
|
2742
|
+
const previous = lanPinEnabled;
|
|
2743
|
+
setLanPinEnabled(enabled);
|
|
2744
|
+
try {
|
|
2745
|
+
await call(MAESTRO_ENDPOINTS.lanPinSetEnabled, { enabled });
|
|
2746
|
+
if (enabled) {
|
|
2747
|
+
const value = await call(MAESTRO_ENDPOINTS.lanPinStatus, {});
|
|
2748
|
+
setLanPin(value.pin ?? null);
|
|
2749
|
+
setShowLanPin(true);
|
|
2750
|
+
} else {
|
|
2751
|
+
setLanPin(null);
|
|
2752
|
+
setShowLanPin(false);
|
|
2753
|
+
}
|
|
2754
|
+
} catch (err) {
|
|
2755
|
+
setLanPinEnabled(previous);
|
|
2756
|
+
setError(err.message);
|
|
2757
|
+
}
|
|
2758
|
+
};
|
|
2759
|
+
const revealLanPin = async () => {
|
|
2760
|
+
if (lanPin === null) {
|
|
2761
|
+
try {
|
|
2762
|
+
setLanPin((await call(MAESTRO_ENDPOINTS.lanPinStatus, {})).pin ?? null);
|
|
2763
|
+
} catch (err) {
|
|
2764
|
+
setError(err.message);
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
setShowLanPin(true);
|
|
2768
|
+
};
|
|
2769
|
+
const rotateLanPin = async () => {
|
|
2770
|
+
setError(null);
|
|
2771
|
+
try {
|
|
2772
|
+
const fresh = (await call(MAESTRO_ENDPOINTS.lanPinRotate, {})).pin;
|
|
2773
|
+
setLanPin(fresh);
|
|
2774
|
+
setShowLanPin(true);
|
|
2775
|
+
} catch (err) {
|
|
2776
|
+
setError(err.message);
|
|
2777
|
+
}
|
|
2778
|
+
};
|
|
2779
|
+
const startTunnel = async () => {
|
|
2780
|
+
setBusy(true);
|
|
2781
|
+
setError(null);
|
|
2782
|
+
try {
|
|
2783
|
+
setStatus(await call(MAESTRO_ENDPOINTS.tunnelStart, {}));
|
|
2784
|
+
} catch (err) {
|
|
2785
|
+
setError(err.message);
|
|
2786
|
+
} finally {
|
|
2787
|
+
setBusy(false);
|
|
2788
|
+
}
|
|
2789
|
+
};
|
|
2790
|
+
const stopTunnel = async () => {
|
|
2791
|
+
setBusy(true);
|
|
2792
|
+
setError(null);
|
|
2793
|
+
try {
|
|
2794
|
+
setStatus(await call(MAESTRO_ENDPOINTS.tunnelStop, {}));
|
|
2795
|
+
} catch (err) {
|
|
2796
|
+
setError(err.message);
|
|
2797
|
+
} finally {
|
|
2798
|
+
setBusy(false);
|
|
2799
|
+
}
|
|
2800
|
+
};
|
|
2801
|
+
const saveField = async (field, value) => {
|
|
2802
|
+
setError(null);
|
|
2803
|
+
setConfig((prev) => ({ ...prev, [field]: value }));
|
|
2804
|
+
try {
|
|
2805
|
+
await call(MAESTRO_ENDPOINTS.saveConfig, { [field]: value });
|
|
2806
|
+
} catch (err) {
|
|
2807
|
+
setError(err.message);
|
|
2808
|
+
}
|
|
2809
|
+
};
|
|
2810
|
+
return (0, import_react.createElement)(
|
|
2811
|
+
"div",
|
|
2812
|
+
{ "data-maestro-settings-card": "", style: { maxWidth: 520 } },
|
|
2813
|
+
(0, import_react.createElement)("h3", { style: { ...headingStyle, fontSize: 15, margin: "0 0 12px" } }, "Maestro"),
|
|
2814
|
+
(0, import_react.createElement)("label", { style: fieldLabelStyle }, "Tunnel mode"),
|
|
2815
|
+
(0, import_react.createElement)(
|
|
2816
|
+
"select",
|
|
2817
|
+
{ value: config.tunnelMode, style: inputStyle, onChange: (e) => saveField("tunnelMode", e.target.value) },
|
|
2818
|
+
(0, import_react.createElement)("option", { value: "quick" }, "Quick (no setup, URL changes on restart)"),
|
|
2819
|
+
(0, import_react.createElement)("option", { value: "named" }, "Named (stable URL, one-time setup)")
|
|
2820
|
+
),
|
|
2821
|
+
config.tunnelMode === "named" && (0, import_react.createElement)(NamedTunnelSetupNote),
|
|
2822
|
+
config.tunnelMode === "named" && (0, import_react.createElement)(
|
|
2823
|
+
"div",
|
|
2824
|
+
null,
|
|
2825
|
+
(0, import_react.createElement)("label", { style: fieldLabelStyle }, "Tunnel ID"),
|
|
2826
|
+
(0, import_react.createElement)("input", { placeholder: "Tunnel ID", style: inputStyle, value: config.tunnelId ?? "", onChange: (e) => saveField("tunnelId", e.target.value) }),
|
|
2827
|
+
(0, import_react.createElement)("label", { style: fieldLabelStyle }, "Credentials file path"),
|
|
2828
|
+
(0, import_react.createElement)("input", { placeholder: "~/.cloudflared/<id>.json", style: inputStyle, value: config.tunnelCredentialsFile ?? "", onChange: (e) => saveField("tunnelCredentialsFile", e.target.value) }),
|
|
2829
|
+
(0, import_react.createElement)("label", { style: fieldLabelStyle }, "Hostname"),
|
|
2830
|
+
(0, import_react.createElement)("input", { placeholder: "dsh.example.com", style: inputStyle, value: config.tunnelHostname ?? "", onChange: (e) => saveField("tunnelHostname", e.target.value) })
|
|
2831
|
+
),
|
|
2832
|
+
(0, import_react.createElement)(
|
|
2833
|
+
"div",
|
|
2834
|
+
{ style: { marginTop: 12 } },
|
|
2835
|
+
status?.running ? (0, import_react.createElement)("button", { disabled: busy, onClick: stopTunnel, style: secondaryButtonStyle }, "Stop tunnel") : (0, import_react.createElement)("button", { disabled: busy, onClick: startTunnel, style: primaryButtonStyle }, "Start tunnel")
|
|
2836
|
+
),
|
|
2837
|
+
(0, import_react.createElement)(
|
|
2838
|
+
"div",
|
|
2839
|
+
{ style: sectionStyle },
|
|
2840
|
+
(0, import_react.createElement)("h4", { style: headingStyle }, "Remote access (LAN)"),
|
|
2841
|
+
(0, import_react.createElement)(LanAccess, {
|
|
2842
|
+
proxyStatus,
|
|
2843
|
+
lanPin: lanPinEnabled === null ? null : {
|
|
2844
|
+
enabled: lanPinEnabled,
|
|
2845
|
+
pin: lanPin,
|
|
2846
|
+
show: showLanPin,
|
|
2847
|
+
onShow: revealLanPin,
|
|
2848
|
+
onHide: () => setShowLanPin(false),
|
|
2849
|
+
onRotate: rotateLanPin,
|
|
2850
|
+
onToggle: toggleLanPin
|
|
2851
|
+
}
|
|
2852
|
+
})
|
|
2853
|
+
),
|
|
2854
|
+
(0, import_react.createElement)(
|
|
2855
|
+
"div",
|
|
2856
|
+
{ style: sectionStyle },
|
|
2857
|
+
(0, import_react.createElement)("h4", { style: headingStyle }, "Public access"),
|
|
2858
|
+
(0, import_react.createElement)(PublicAccess, { status, pin, showPin, onRevealPin: revealPin, onHidePin: () => setShowPin(false), onRotatePin: rotatePin })
|
|
2859
|
+
),
|
|
2860
|
+
(0, import_react.createElement)(
|
|
2861
|
+
"div",
|
|
2862
|
+
{ style: sectionStyle },
|
|
2863
|
+
(0, import_react.createElement)("h4", { style: headingStyle }, "Telegram notifications"),
|
|
2864
|
+
(0, import_react.createElement)("p", { style: captionStyle }, "Send one protected startup update with the current public-access PIN to a single Telegram chat."),
|
|
2865
|
+
(0, import_react.createElement)(SecretInput, {
|
|
2866
|
+
label: "Bot token",
|
|
2867
|
+
placeholder: "123456:ABC-DEF...",
|
|
2868
|
+
hasSaved: config.hasTelegramBotToken,
|
|
2869
|
+
onSave: (value) => saveField("telegramBotToken", value)
|
|
2870
|
+
}),
|
|
2871
|
+
(0, import_react.createElement)("label", { style: fieldLabelStyle }, "Chat ID"),
|
|
2872
|
+
(0, import_react.createElement)("input", { placeholder: "-1001234567890", autoComplete: "off", style: inputStyle, value: config.telegramChatId ?? "", onChange: (e) => saveField("telegramChatId", e.target.value) }),
|
|
2873
|
+
(0, import_react.createElement)(ToggleField, {
|
|
2874
|
+
label: "Also notify about finished reviews",
|
|
2875
|
+
caption: "One message per review run with its outcome and a short summary.",
|
|
2876
|
+
checked: config.telegramReviewNotifications,
|
|
2877
|
+
onChange: (checked) => saveField("telegramReviewNotifications", checked)
|
|
2878
|
+
}),
|
|
2879
|
+
(0, import_react.createElement)("p", { style: captionStyle }, "Leave either credential blank to disable notifications. Telegram delivery failures never prevent DSH from starting.")
|
|
2880
|
+
),
|
|
2881
|
+
(0, import_react.createElement)(
|
|
2882
|
+
"div",
|
|
2883
|
+
{ style: sectionStyle },
|
|
2884
|
+
(0, import_react.createElement)("h4", { style: headingStyle }, "GitLab"),
|
|
2885
|
+
(0, import_react.createElement)("label", { style: fieldLabelStyle }, "GitLab base URL"),
|
|
2886
|
+
(0, import_react.createElement)("input", { placeholder: "https://gitlab.example.com", style: inputStyle, value: config.gitlabBaseUrl ?? "", onChange: (e) => saveField("gitlabBaseUrl", e.target.value) }),
|
|
2887
|
+
(0, import_react.createElement)(SecretInput, {
|
|
2888
|
+
label: "GitLab token",
|
|
2889
|
+
placeholder: "GitLab token",
|
|
2890
|
+
hasSaved: config.hasGitlabToken,
|
|
2891
|
+
onSave: (value) => saveField("gitlabToken", value)
|
|
2892
|
+
}),
|
|
2893
|
+
(0, import_react.createElement)("label", { style: fieldLabelStyle }, "Bot username"),
|
|
2894
|
+
(0, import_react.createElement)("input", { placeholder: "maestro-bot", style: inputStyle, value: config.botUsername ?? "", onChange: (e) => saveField("botUsername", e.target.value) }),
|
|
2895
|
+
(0, import_react.createElement)(SecretInput, {
|
|
2896
|
+
label: "Webhook secret",
|
|
2897
|
+
placeholder: "Webhook secret",
|
|
2898
|
+
hasSaved: config.hasWebhookSecret,
|
|
2899
|
+
onSave: (value) => saveField("webhookSecret", value)
|
|
2900
|
+
}),
|
|
2901
|
+
(0, import_react.createElement)("button", { type: "button", style: { ...secondaryButtonStyle, marginTop: 10 }, onClick: () => saveField("webhookSecret", generateWebhookSecret()) }, "Generate new secret"),
|
|
2902
|
+
(0, import_react.createElement)("p", { style: captionStyle }, "In GitLab: Settings \u2192 Webhooks, set Secret token to this value and enable Merge request events."),
|
|
2903
|
+
(0, import_react.createElement)("p", { style: captionStyle }, "Webhook URL:"),
|
|
2904
|
+
(0, import_react.createElement)("code", { style: codeStyle }, gitlabWebhookUrl(config.tunnelHostname)),
|
|
2905
|
+
(0, import_react.createElement)("p", { style: captionStyle }, "Overrides MAESTRO_GITLAB_WEBHOOK_SECRET immediately, no restart needed.")
|
|
2906
|
+
),
|
|
2907
|
+
(0, import_react.createElement)(
|
|
2908
|
+
"div",
|
|
2909
|
+
{ style: sectionStyle },
|
|
2910
|
+
(0, import_react.createElement)("h4", { style: headingStyle }, "Review automation"),
|
|
2911
|
+
(0, import_react.createElement)(ToggleField, {
|
|
2912
|
+
label: "Re-review when new commits are pushed",
|
|
2913
|
+
caption: "After a completed review, further pushes to the same MR trigger an automatic quick re-review.",
|
|
2914
|
+
checked: config.autoRereviewOnPush,
|
|
2915
|
+
onChange: (checked) => saveField("autoRereviewOnPush", checked)
|
|
2916
|
+
}),
|
|
2917
|
+
(0, import_react.createElement)(ReviewHistoryPanel, { rpcCall })
|
|
2918
|
+
),
|
|
2919
|
+
(0, import_react.createElement)(
|
|
2920
|
+
"div",
|
|
2921
|
+
{ style: sectionStyle },
|
|
2922
|
+
(0, import_react.createElement)("h4", { style: headingStyle }, "Review model"),
|
|
2923
|
+
(0, import_react.createElement)("p", { style: captionStyle }, "Model used for automated GitLab reviews (reviewer & auditor). Empty = DSH default. Per-project empty = inherits Global, or DSH default when Global is empty."),
|
|
2924
|
+
(0, import_react.createElement)(ReviewModelSelector, {
|
|
2925
|
+
value: config.reviewModel ?? null,
|
|
2926
|
+
catalog,
|
|
2927
|
+
fallbackValue: catalog?.current ?? null,
|
|
2928
|
+
fallbackLabel: "Use DSH default",
|
|
2929
|
+
onChange: (v) => saveField("reviewModel", v),
|
|
2930
|
+
label: "Global review model"
|
|
2931
|
+
})
|
|
2932
|
+
),
|
|
2933
|
+
(0, import_react.createElement)(
|
|
2934
|
+
"div",
|
|
2935
|
+
{ style: sectionStyle },
|
|
2936
|
+
(0, import_react.createElement)("h4", { style: headingStyle }, "Projects"),
|
|
2937
|
+
(0, import_react.createElement)(ProjectMappingsEditor, { mappings: config.projectMappings ?? [], onChange: (mappings) => saveField("projectMappings", mappings), catalog, globalReviewModel: config.reviewModel ?? null })
|
|
2938
|
+
),
|
|
2939
|
+
error && (0, import_react.createElement)("p", { style: errorStyle }, error)
|
|
2940
|
+
);
|
|
2941
|
+
}
|
|
2942
|
+
|
|
2943
|
+
// src/client/settings-nav-icon.ts
|
|
2944
|
+
var SETTINGS_NAV_MARKER = "data-maestro-settings-nav";
|
|
2945
|
+
function registerSettingsNavIcon(label, root) {
|
|
2946
|
+
if (typeof document === "undefined" && root === void 0) {
|
|
2947
|
+
return () => {
|
|
2948
|
+
};
|
|
2949
|
+
}
|
|
2950
|
+
const scope = root ?? document;
|
|
2951
|
+
let disposed = false;
|
|
2952
|
+
const sync = () => {
|
|
2953
|
+
if (disposed) return;
|
|
2954
|
+
const currentLabel = label().trim();
|
|
2955
|
+
const buttons = scope.querySelectorAll('[role="dialog"] nav button');
|
|
2956
|
+
for (const button of Array.from(buttons)) {
|
|
2957
|
+
const el = button;
|
|
2958
|
+
const matches = currentLabel.length > 0 && button.textContent != null && button.textContent.trim() === currentLabel;
|
|
2959
|
+
if (matches) el.setAttribute(SETTINGS_NAV_MARKER, "");
|
|
2960
|
+
else el.removeAttribute(SETTINGS_NAV_MARKER);
|
|
2961
|
+
}
|
|
2962
|
+
};
|
|
2963
|
+
sync();
|
|
2964
|
+
let observer = null;
|
|
2965
|
+
if (typeof MutationObserver !== "undefined") {
|
|
2966
|
+
observer = new MutationObserver(sync);
|
|
2967
|
+
observer.observe(document.body, { childList: true, subtree: true, characterData: true });
|
|
2968
|
+
}
|
|
2969
|
+
return () => {
|
|
2970
|
+
disposed = true;
|
|
2971
|
+
if (observer !== null) observer.disconnect();
|
|
2972
|
+
for (const element of Array.from(scope.querySelectorAll(`[${SETTINGS_NAV_MARKER}]`))) {
|
|
2973
|
+
;
|
|
2974
|
+
element.removeAttribute(SETTINGS_NAV_MARKER);
|
|
2975
|
+
}
|
|
2976
|
+
};
|
|
2977
|
+
}
|
|
2978
|
+
|
|
2979
|
+
// src/client/index.tsx
|
|
2980
|
+
var SETTINGS_NAV_CSS2 = `
|
|
2981
|
+
|
|
2982
|
+
/* maestro: replace the settings-nav fallback gear with the maestro glyph */
|
|
2983
|
+
[${SETTINGS_NAV_MARKER}] > svg:first-child {
|
|
2984
|
+
display: none;
|
|
2985
|
+
}
|
|
2986
|
+
|
|
2987
|
+
[${SETTINGS_NAV_MARKER}]::before {
|
|
2988
|
+
content: '';
|
|
2989
|
+
flex: none;
|
|
2990
|
+
width: 16px;
|
|
2991
|
+
height: 16px;
|
|
2992
|
+
background: currentColor;
|
|
2993
|
+
-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 10v3'/%3E%3Cpath d='M6 4v16'/%3E%3Cpath d='M10 8v8'/%3E%3Cpath d='M14 4v16'/%3E%3Cpath d='M18 6v12'/%3E%3Cpath d='M22 10v3'/%3E%3C/svg%3E") center / contain no-repeat;
|
|
2994
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 10v3'/%3E%3Cpath d='M6 4v16'/%3E%3Cpath d='M10 8v8'/%3E%3Cpath d='M14 4v16'/%3E%3Cpath d='M18 6v12'/%3E%3Cpath d='M22 10v3'/%3E%3C/svg%3E") center / contain no-repeat;
|
|
2995
|
+
}
|
|
2996
|
+
`;
|
|
2997
|
+
function installNavIconStyle() {
|
|
2998
|
+
const tag = document.createElement("style");
|
|
2999
|
+
tag.dataset.plugin = "@ddtcorex/dsh-maestro-config";
|
|
3000
|
+
tag.dataset.pluginCss = "maestro/settings-nav.css";
|
|
3001
|
+
tag.textContent = SETTINGS_NAV_CSS2;
|
|
3002
|
+
document.head.appendChild(tag);
|
|
3003
|
+
return () => {
|
|
3004
|
+
document.querySelector('style[data-plugin-css="maestro/settings-nav.css"]')?.remove();
|
|
3005
|
+
};
|
|
3006
|
+
}
|
|
3007
|
+
function apply(ctx) {
|
|
3008
|
+
const slots = ctx.get?.("slots");
|
|
3009
|
+
if (slots === void 0) return;
|
|
3010
|
+
const rpcCall = (endpoint, payload, signal) => {
|
|
3011
|
+
const connection = ctx.get?.("connection");
|
|
3012
|
+
if (!connection?.rpc?.call) return Promise.reject(new Error("RPC not available"));
|
|
3013
|
+
return connection.rpc.call(MAESTRO_RPC_CHANNEL, endpoint, payload, signal);
|
|
3014
|
+
};
|
|
3015
|
+
ctx.effect(() => registerSettingsNavIcon(() => "Maestro"), "maestro: settings nav icon");
|
|
3016
|
+
ctx.effect(installNavIconStyle, "maestro: settings nav css");
|
|
3017
|
+
slots.inject(
|
|
3018
|
+
"settings.section",
|
|
3019
|
+
() => slots.register(
|
|
3020
|
+
{ name: "settings.section", id: "maestro", order: 25, label: () => "Maestro", inject: () => ({ rpcCall }) },
|
|
3021
|
+
MaestroSettingsTab
|
|
3022
|
+
)
|
|
3023
|
+
);
|
|
3024
|
+
}
|
|
3025
|
+
|
|
3026
|
+
return module.exports;
|
|
3027
|
+
}
|
|
3028
|
+
});
|