@_davideast/stitch-mcp 0.5.2 → 0.5.3

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.
Files changed (126) hide show
  1. package/dist/chunk-22bymmh9.js +137 -0
  2. package/dist/chunk-22bymmh9.js.map +10 -0
  3. package/dist/chunk-387yyye2.js +248 -0
  4. package/dist/chunk-387yyye2.js.map +14 -0
  5. package/dist/chunk-3ff2k44g.js +19 -0
  6. package/dist/chunk-3ff2k44g.js.map +9 -0
  7. package/dist/chunk-46cay1zp.js +273 -0
  8. package/dist/chunk-46cay1zp.js.map +10 -0
  9. package/dist/chunk-48e1jpm8.js +167 -0
  10. package/dist/chunk-48e1jpm8.js.map +10 -0
  11. package/dist/chunk-4arzkk1s.js +69 -0
  12. package/dist/chunk-4arzkk1s.js.map +10 -0
  13. package/dist/chunk-4js7vw6h.js +415 -0
  14. package/dist/chunk-4js7vw6h.js.map +20 -0
  15. package/dist/chunk-4p1wfk3t.js +736 -0
  16. package/dist/chunk-4p1wfk3t.js.map +16 -0
  17. package/dist/chunk-4zg969tc.js +370 -0
  18. package/dist/chunk-4zg969tc.js.map +16 -0
  19. package/dist/chunk-5jjt7tgw.js +247 -0
  20. package/dist/chunk-5jjt7tgw.js.map +14 -0
  21. package/dist/chunk-5t2h8z2n.js +273 -0
  22. package/dist/chunk-5t2h8z2n.js.map +10 -0
  23. package/dist/chunk-5zy3et1m.js +759 -0
  24. package/dist/chunk-5zy3et1m.js.map +19 -0
  25. package/dist/chunk-6wvst7z8.js +125 -0
  26. package/dist/chunk-6wvst7z8.js.map +12 -0
  27. package/dist/chunk-8mm08arm.js +256 -0
  28. package/dist/chunk-8mm08arm.js.map +11 -0
  29. package/dist/chunk-8nv4wwv0.js +19 -0
  30. package/dist/chunk-8nv4wwv0.js.map +9 -0
  31. package/dist/chunk-9cjny9z2.js +19 -0
  32. package/dist/chunk-9cjny9z2.js.map +9 -0
  33. package/dist/chunk-9ggfw78s.js +19 -0
  34. package/dist/chunk-9ggfw78s.js.map +9 -0
  35. package/dist/chunk-9nyyn1hn.js +125 -0
  36. package/dist/chunk-9nyyn1hn.js.map +12 -0
  37. package/dist/chunk-9nzbvp6r.js +19 -0
  38. package/dist/chunk-9nzbvp6r.js.map +9 -0
  39. package/dist/chunk-a0gmbh8e.js +415 -0
  40. package/dist/chunk-a0gmbh8e.js.map +20 -0
  41. package/dist/chunk-acv998mp.js +941 -0
  42. package/dist/chunk-acv998mp.js.map +27 -0
  43. package/dist/chunk-cpjsvven.js +10 -0
  44. package/dist/chunk-cpjsvven.js.map +9 -0
  45. package/dist/chunk-dmrahbs1.js +31467 -0
  46. package/dist/chunk-dmrahbs1.js.map +245 -0
  47. package/dist/chunk-dts6851a.js +137 -0
  48. package/dist/chunk-dts6851a.js.map +10 -0
  49. package/dist/chunk-efd0rm6g.js +69 -0
  50. package/dist/chunk-efd0rm6g.js.map +10 -0
  51. package/dist/chunk-f1kjn6cd.js +16554 -0
  52. package/dist/chunk-f1kjn6cd.js.map +98 -0
  53. package/dist/chunk-f5f6ekgp.js +109 -0
  54. package/dist/chunk-f5f6ekgp.js.map +10 -0
  55. package/dist/chunk-fmewhfh3.js +137 -0
  56. package/dist/chunk-fmewhfh3.js.map +10 -0
  57. package/dist/chunk-fmhrn6cg.js +6382 -0
  58. package/dist/chunk-fmhrn6cg.js.map +109 -0
  59. package/dist/chunk-gh7dzfhb.js +256 -0
  60. package/dist/chunk-gh7dzfhb.js.map +11 -0
  61. package/dist/chunk-gwhtc0fe.js +370 -0
  62. package/dist/chunk-gwhtc0fe.js.map +16 -0
  63. package/dist/chunk-hc7sdwmn.js +449 -0
  64. package/dist/chunk-hc7sdwmn.js.map +17 -0
  65. package/dist/chunk-k4xwb3wp.js +44184 -0
  66. package/dist/chunk-k4xwb3wp.js.map +237 -0
  67. package/dist/chunk-k751yfm6.js +736 -0
  68. package/dist/chunk-k751yfm6.js.map +16 -0
  69. package/dist/chunk-kkc2tvar.js +19 -0
  70. package/dist/chunk-kkc2tvar.js.map +9 -0
  71. package/dist/chunk-kva47mgc.js +10 -0
  72. package/dist/chunk-kva47mgc.js.map +9 -0
  73. package/dist/chunk-nv2j020p.js +45210 -0
  74. package/dist/chunk-nv2j020p.js.map +258 -0
  75. package/dist/chunk-pdj9s41r.js +683 -0
  76. package/dist/chunk-pdj9s41r.js.map +17 -0
  77. package/dist/chunk-ppphsy4t.js +273 -0
  78. package/dist/chunk-ppphsy4t.js.map +10 -0
  79. package/dist/chunk-psmw9zpa.js +941 -0
  80. package/dist/chunk-psmw9zpa.js.map +27 -0
  81. package/dist/chunk-pz31v3ma.js +24 -0
  82. package/dist/chunk-pz31v3ma.js.map +9 -0
  83. package/dist/chunk-qbt0906e.js +1495 -0
  84. package/dist/chunk-qbt0906e.js.map +23 -0
  85. package/dist/chunk-rh3k09h7.js +19 -0
  86. package/dist/chunk-rh3k09h7.js.map +9 -0
  87. package/dist/chunk-saznae7w.js +10 -0
  88. package/dist/chunk-saznae7w.js.map +9 -0
  89. package/dist/chunk-sscqdg1j.js +69 -0
  90. package/dist/chunk-sscqdg1j.js.map +10 -0
  91. package/dist/chunk-stgj6y85.js +835 -0
  92. package/dist/chunk-stgj6y85.js.map +19 -0
  93. package/dist/chunk-t3tqmxyj.js +42 -0
  94. package/dist/chunk-t3tqmxyj.js.map +9 -0
  95. package/dist/chunk-v8ak35zd.js +94 -0
  96. package/dist/chunk-v8ak35zd.js.map +10 -0
  97. package/dist/chunk-w9acw256.js +167 -0
  98. package/dist/chunk-w9acw256.js.map +10 -0
  99. package/dist/chunk-wq60thjn.js +167 -0
  100. package/dist/chunk-wq60thjn.js.map +10 -0
  101. package/dist/chunk-wzkdeb8a.js +736 -0
  102. package/dist/chunk-wzkdeb8a.js.map +16 -0
  103. package/dist/chunk-xxv6j815.js +256 -0
  104. package/dist/chunk-xxv6j815.js.map +11 -0
  105. package/dist/chunk-yjnj35q8.js +1495 -0
  106. package/dist/chunk-yjnj35q8.js.map +23 -0
  107. package/dist/chunk-yvzzrczy.js +45206 -0
  108. package/dist/chunk-yvzzrczy.js.map +258 -0
  109. package/dist/chunk-ywax1akt.js +370 -0
  110. package/dist/chunk-ywax1akt.js.map +16 -0
  111. package/dist/chunk-zakq9pc0.js +4989 -0
  112. package/dist/chunk-zakq9pc0.js.map +65 -0
  113. package/dist/commands/doctor/command.js +1 -1
  114. package/dist/commands/doctor/steps/AdcProjectCheckStep.d.ts +8 -0
  115. package/dist/commands/init/command.js +1 -1
  116. package/dist/commands/logout/command.js +1 -1
  117. package/dist/commands/proxy/command.js +1 -1
  118. package/dist/commands/screens/command.js +2 -2
  119. package/dist/commands/serve/command.js +3 -3
  120. package/dist/commands/site/command.js +1 -1
  121. package/dist/commands/snapshot/command.js +1 -1
  122. package/dist/commands/tool/command.js +1 -1
  123. package/dist/commands/view/command.js +1 -1
  124. package/dist/index.js +4 -4
  125. package/dist/lib/server/AssetGateway.d.ts +12 -0
  126. package/package.json +1 -1
@@ -0,0 +1,4989 @@
1
+ import {
2
+ onExit
3
+ } from "./chunk-tz7wnw4s.js";
4
+ import {
5
+ theme
6
+ } from "./chunk-kbtqrkwh.js";
7
+ import {
8
+ exports_external
9
+ } from "./chunk-c6ge431q.js";
10
+ import {
11
+ __commonJS,
12
+ __require,
13
+ __toESM
14
+ } from "./chunk-9wyra8hs.js";
15
+
16
+ // node_modules/adm-zip/util/constants.js
17
+ var require_constants = __commonJS((exports, module) => {
18
+ module.exports = {
19
+ LOCHDR: 30,
20
+ LOCSIG: 67324752,
21
+ LOCVER: 4,
22
+ LOCFLG: 6,
23
+ LOCHOW: 8,
24
+ LOCTIM: 10,
25
+ LOCCRC: 14,
26
+ LOCSIZ: 18,
27
+ LOCLEN: 22,
28
+ LOCNAM: 26,
29
+ LOCEXT: 28,
30
+ EXTSIG: 134695760,
31
+ EXTHDR: 16,
32
+ EXTCRC: 4,
33
+ EXTSIZ: 8,
34
+ EXTLEN: 12,
35
+ CENHDR: 46,
36
+ CENSIG: 33639248,
37
+ CENVEM: 4,
38
+ CENVER: 6,
39
+ CENFLG: 8,
40
+ CENHOW: 10,
41
+ CENTIM: 12,
42
+ CENCRC: 16,
43
+ CENSIZ: 20,
44
+ CENLEN: 24,
45
+ CENNAM: 28,
46
+ CENEXT: 30,
47
+ CENCOM: 32,
48
+ CENDSK: 34,
49
+ CENATT: 36,
50
+ CENATX: 38,
51
+ CENOFF: 42,
52
+ ENDHDR: 22,
53
+ ENDSIG: 101010256,
54
+ ENDSUB: 8,
55
+ ENDTOT: 10,
56
+ ENDSIZ: 12,
57
+ ENDOFF: 16,
58
+ ENDCOM: 20,
59
+ END64HDR: 20,
60
+ END64SIG: 117853008,
61
+ END64START: 4,
62
+ END64OFF: 8,
63
+ END64NUMDISKS: 16,
64
+ ZIP64SIG: 101075792,
65
+ ZIP64HDR: 56,
66
+ ZIP64LEAD: 12,
67
+ ZIP64SIZE: 4,
68
+ ZIP64VEM: 12,
69
+ ZIP64VER: 14,
70
+ ZIP64DSK: 16,
71
+ ZIP64DSKDIR: 20,
72
+ ZIP64SUB: 24,
73
+ ZIP64TOT: 32,
74
+ ZIP64SIZB: 40,
75
+ ZIP64OFF: 48,
76
+ ZIP64EXTRA: 56,
77
+ STORED: 0,
78
+ SHRUNK: 1,
79
+ REDUCED1: 2,
80
+ REDUCED2: 3,
81
+ REDUCED3: 4,
82
+ REDUCED4: 5,
83
+ IMPLODED: 6,
84
+ DEFLATED: 8,
85
+ ENHANCED_DEFLATED: 9,
86
+ PKWARE: 10,
87
+ BZIP2: 12,
88
+ LZMA: 14,
89
+ IBM_TERSE: 18,
90
+ IBM_LZ77: 19,
91
+ AES_ENCRYPT: 99,
92
+ FLG_ENC: 1,
93
+ FLG_COMP1: 2,
94
+ FLG_COMP2: 4,
95
+ FLG_DESC: 8,
96
+ FLG_ENH: 16,
97
+ FLG_PATCH: 32,
98
+ FLG_STR: 64,
99
+ FLG_EFS: 2048,
100
+ FLG_MSK: 4096,
101
+ FILE: 2,
102
+ BUFFER: 1,
103
+ NONE: 0,
104
+ EF_ID: 0,
105
+ EF_SIZE: 2,
106
+ ID_ZIP64: 1,
107
+ ID_AVINFO: 7,
108
+ ID_PFS: 8,
109
+ ID_OS2: 9,
110
+ ID_NTFS: 10,
111
+ ID_OPENVMS: 12,
112
+ ID_UNIX: 13,
113
+ ID_FORK: 14,
114
+ ID_PATCH: 15,
115
+ ID_X509_PKCS7: 20,
116
+ ID_X509_CERTID_F: 21,
117
+ ID_X509_CERTID_C: 22,
118
+ ID_STRONGENC: 23,
119
+ ID_RECORD_MGT: 24,
120
+ ID_X509_PKCS7_RL: 25,
121
+ ID_IBM1: 101,
122
+ ID_IBM2: 102,
123
+ ID_POSZIP: 18064,
124
+ EF_ZIP64_OR_32: 4294967295,
125
+ EF_ZIP64_OR_16: 65535,
126
+ EF_ZIP64_SUNCOMP: 0,
127
+ EF_ZIP64_SCOMP: 8,
128
+ EF_ZIP64_RHO: 16,
129
+ EF_ZIP64_DSN: 24
130
+ };
131
+ });
132
+
133
+ // node_modules/adm-zip/util/errors.js
134
+ var require_errors = __commonJS((exports) => {
135
+ var errors = {
136
+ INVALID_LOC: "Invalid LOC header (bad signature)",
137
+ INVALID_CEN: "Invalid CEN header (bad signature)",
138
+ INVALID_END: "Invalid END header (bad signature)",
139
+ DESCRIPTOR_NOT_EXIST: "No descriptor present",
140
+ DESCRIPTOR_UNKNOWN: "Unknown descriptor format",
141
+ DESCRIPTOR_FAULTY: "Descriptor data is malformed",
142
+ NO_DATA: "Nothing to decompress",
143
+ BAD_CRC: "CRC32 checksum failed {0}",
144
+ FILE_IN_THE_WAY: "There is a file in the way: {0}",
145
+ UNKNOWN_METHOD: "Invalid/unsupported compression method",
146
+ AVAIL_DATA: "inflate::Available inflate data did not terminate",
147
+ INVALID_DISTANCE: "inflate::Invalid literal/length or distance code in fixed or dynamic block",
148
+ TO_MANY_CODES: "inflate::Dynamic block code description: too many length or distance codes",
149
+ INVALID_REPEAT_LEN: "inflate::Dynamic block code description: repeat more than specified lengths",
150
+ INVALID_REPEAT_FIRST: "inflate::Dynamic block code description: repeat lengths with no first length",
151
+ INCOMPLETE_CODES: "inflate::Dynamic block code description: code lengths codes incomplete",
152
+ INVALID_DYN_DISTANCE: "inflate::Dynamic block code description: invalid distance code lengths",
153
+ INVALID_CODES_LEN: "inflate::Dynamic block code description: invalid literal/length code lengths",
154
+ INVALID_STORE_BLOCK: "inflate::Stored block length did not match one's complement",
155
+ INVALID_BLOCK_TYPE: "inflate::Invalid block type (type == 3)",
156
+ CANT_EXTRACT_FILE: "Could not extract the file",
157
+ CANT_OVERRIDE: "Target file already exists",
158
+ DISK_ENTRY_TOO_LARGE: "Number of disk entries is too large",
159
+ NO_ZIP: "No zip file was loaded",
160
+ NO_ENTRY: "Entry doesn't exist",
161
+ DIRECTORY_CONTENT_ERROR: "A directory cannot have content",
162
+ FILE_NOT_FOUND: 'File not found: "{0}"',
163
+ NOT_IMPLEMENTED: "Not implemented",
164
+ INVALID_FILENAME: "Invalid filename",
165
+ INVALID_FORMAT: "Invalid or unsupported zip format. No END header found",
166
+ INVALID_PASS_PARAM: "Incompatible password parameter",
167
+ WRONG_PASSWORD: "Wrong Password",
168
+ COMMENT_TOO_LONG: "Comment is too long",
169
+ EXTRA_FIELD_PARSE_ERROR: "Extra field parsing error"
170
+ };
171
+ function E(message) {
172
+ return function(...args) {
173
+ if (args.length) {
174
+ message = message.replace(/\{(\d)\}/g, (_, n) => args[n] || "");
175
+ }
176
+ return new Error("ADM-ZIP: " + message);
177
+ };
178
+ }
179
+ for (const msg of Object.keys(errors)) {
180
+ exports[msg] = E(errors[msg]);
181
+ }
182
+ });
183
+
184
+ // node_modules/adm-zip/util/utils.js
185
+ var require_utils = __commonJS((exports, module) => {
186
+ var fsystem = __require("fs");
187
+ var pth = __require("path");
188
+ var Constants = require_constants();
189
+ var Errors = require_errors();
190
+ var isWin = typeof process === "object" && process.platform === "win32";
191
+ var is_Obj = (obj) => typeof obj === "object" && obj !== null;
192
+ var crcTable = new Uint32Array(256).map((t, c) => {
193
+ for (let k = 0;k < 8; k++) {
194
+ if ((c & 1) !== 0) {
195
+ c = 3988292384 ^ c >>> 1;
196
+ } else {
197
+ c >>>= 1;
198
+ }
199
+ }
200
+ return c >>> 0;
201
+ });
202
+ function Utils(opts) {
203
+ this.sep = pth.sep;
204
+ this.fs = fsystem;
205
+ if (is_Obj(opts)) {
206
+ if (is_Obj(opts.fs) && typeof opts.fs.statSync === "function") {
207
+ this.fs = opts.fs;
208
+ }
209
+ }
210
+ }
211
+ module.exports = Utils;
212
+ Utils.prototype.makeDir = function(folder) {
213
+ const self = this;
214
+ function mkdirSync(fpath) {
215
+ let resolvedPath = fpath.split(self.sep)[0];
216
+ fpath.split(self.sep).forEach(function(name) {
217
+ if (!name || name.substr(-1, 1) === ":")
218
+ return;
219
+ resolvedPath += self.sep + name;
220
+ var stat;
221
+ try {
222
+ stat = self.fs.statSync(resolvedPath);
223
+ } catch (e) {
224
+ if (e.message && e.message.startsWith("ENOENT")) {
225
+ self.fs.mkdirSync(resolvedPath);
226
+ } else {
227
+ throw e;
228
+ }
229
+ }
230
+ if (stat && stat.isFile())
231
+ throw Errors.FILE_IN_THE_WAY(`"${resolvedPath}"`);
232
+ });
233
+ }
234
+ mkdirSync(folder);
235
+ };
236
+ Utils.prototype.writeFileTo = function(path2, content, overwrite, attr) {
237
+ const self = this;
238
+ if (self.fs.existsSync(path2)) {
239
+ if (!overwrite)
240
+ return false;
241
+ var stat = self.fs.statSync(path2);
242
+ if (stat.isDirectory()) {
243
+ return false;
244
+ }
245
+ }
246
+ var folder = pth.dirname(path2);
247
+ if (!self.fs.existsSync(folder)) {
248
+ self.makeDir(folder);
249
+ }
250
+ var fd;
251
+ try {
252
+ fd = self.fs.openSync(path2, "w", 438);
253
+ } catch (e) {
254
+ self.fs.chmodSync(path2, 438);
255
+ fd = self.fs.openSync(path2, "w", 438);
256
+ }
257
+ if (fd) {
258
+ try {
259
+ self.fs.writeSync(fd, content, 0, content.length, 0);
260
+ } finally {
261
+ self.fs.closeSync(fd);
262
+ }
263
+ }
264
+ self.fs.chmodSync(path2, attr || 438);
265
+ return true;
266
+ };
267
+ Utils.prototype.writeFileToAsync = function(path2, content, overwrite, attr, callback) {
268
+ if (typeof attr === "function") {
269
+ callback = attr;
270
+ attr = undefined;
271
+ }
272
+ const self = this;
273
+ self.fs.exists(path2, function(exist) {
274
+ if (exist && !overwrite)
275
+ return callback(false);
276
+ self.fs.stat(path2, function(err, stat) {
277
+ if (exist && stat.isDirectory()) {
278
+ return callback(false);
279
+ }
280
+ var folder = pth.dirname(path2);
281
+ self.fs.exists(folder, function(exists) {
282
+ if (!exists)
283
+ self.makeDir(folder);
284
+ self.fs.open(path2, "w", 438, function(err2, fd) {
285
+ if (err2) {
286
+ self.fs.chmod(path2, 438, function() {
287
+ self.fs.open(path2, "w", 438, function(err3, fd2) {
288
+ self.fs.write(fd2, content, 0, content.length, 0, function() {
289
+ self.fs.close(fd2, function() {
290
+ self.fs.chmod(path2, attr || 438, function() {
291
+ callback(true);
292
+ });
293
+ });
294
+ });
295
+ });
296
+ });
297
+ } else if (fd) {
298
+ self.fs.write(fd, content, 0, content.length, 0, function() {
299
+ self.fs.close(fd, function() {
300
+ self.fs.chmod(path2, attr || 438, function() {
301
+ callback(true);
302
+ });
303
+ });
304
+ });
305
+ } else {
306
+ self.fs.chmod(path2, attr || 438, function() {
307
+ callback(true);
308
+ });
309
+ }
310
+ });
311
+ });
312
+ });
313
+ });
314
+ };
315
+ Utils.prototype.findFiles = function(path2) {
316
+ const self = this;
317
+ function findSync(dir, pattern, recursive) {
318
+ if (typeof pattern === "boolean") {
319
+ recursive = pattern;
320
+ pattern = undefined;
321
+ }
322
+ let files = [];
323
+ self.fs.readdirSync(dir).forEach(function(file) {
324
+ const path3 = pth.join(dir, file);
325
+ const stat = self.fs.statSync(path3);
326
+ if (!pattern || pattern.test(path3)) {
327
+ files.push(pth.normalize(path3) + (stat.isDirectory() ? self.sep : ""));
328
+ }
329
+ if (stat.isDirectory() && recursive)
330
+ files = files.concat(findSync(path3, pattern, recursive));
331
+ });
332
+ return files;
333
+ }
334
+ return findSync(path2, undefined, true);
335
+ };
336
+ Utils.prototype.findFilesAsync = function(dir, cb) {
337
+ const self = this;
338
+ let results = [];
339
+ self.fs.readdir(dir, function(err, list) {
340
+ if (err)
341
+ return cb(err);
342
+ let list_length = list.length;
343
+ if (!list_length)
344
+ return cb(null, results);
345
+ list.forEach(function(file) {
346
+ file = pth.join(dir, file);
347
+ self.fs.stat(file, function(err2, stat) {
348
+ if (err2)
349
+ return cb(err2);
350
+ if (stat) {
351
+ results.push(pth.normalize(file) + (stat.isDirectory() ? self.sep : ""));
352
+ if (stat.isDirectory()) {
353
+ self.findFilesAsync(file, function(err3, res) {
354
+ if (err3)
355
+ return cb(err3);
356
+ results = results.concat(res);
357
+ if (!--list_length)
358
+ cb(null, results);
359
+ });
360
+ } else {
361
+ if (!--list_length)
362
+ cb(null, results);
363
+ }
364
+ }
365
+ });
366
+ });
367
+ });
368
+ };
369
+ Utils.prototype.getAttributes = function() {};
370
+ Utils.prototype.setAttributes = function() {};
371
+ Utils.crc32update = function(crc, byte) {
372
+ return crcTable[(crc ^ byte) & 255] ^ crc >>> 8;
373
+ };
374
+ Utils.crc32 = function(buf) {
375
+ if (typeof buf === "string") {
376
+ buf = Buffer.from(buf, "utf8");
377
+ }
378
+ let len = buf.length;
379
+ let crc = ~0;
380
+ for (let off = 0;off < len; )
381
+ crc = Utils.crc32update(crc, buf[off++]);
382
+ return ~crc >>> 0;
383
+ };
384
+ Utils.methodToString = function(method) {
385
+ switch (method) {
386
+ case Constants.STORED:
387
+ return "STORED (" + method + ")";
388
+ case Constants.DEFLATED:
389
+ return "DEFLATED (" + method + ")";
390
+ default:
391
+ return "UNSUPPORTED (" + method + ")";
392
+ }
393
+ };
394
+ Utils.canonical = function(path2) {
395
+ if (!path2)
396
+ return "";
397
+ const safeSuffix = pth.posix.normalize("/" + path2.split("\\").join("/"));
398
+ return pth.join(".", safeSuffix);
399
+ };
400
+ Utils.zipnamefix = function(path2) {
401
+ if (!path2)
402
+ return "";
403
+ const safeSuffix = pth.posix.normalize("/" + path2.split("\\").join("/"));
404
+ return pth.posix.join(".", safeSuffix);
405
+ };
406
+ Utils.findLast = function(arr, callback) {
407
+ if (!Array.isArray(arr))
408
+ throw new TypeError("arr is not array");
409
+ const len = arr.length >>> 0;
410
+ for (let i = len - 1;i >= 0; i--) {
411
+ if (callback(arr[i], i, arr)) {
412
+ return arr[i];
413
+ }
414
+ }
415
+ return;
416
+ };
417
+ Utils.sanitize = function(prefix, name) {
418
+ prefix = pth.resolve(pth.normalize(prefix));
419
+ var parts = name.split("/");
420
+ for (var i = 0, l = parts.length;i < l; i++) {
421
+ var path2 = pth.normalize(pth.join(prefix, parts.slice(i, l).join(pth.sep)));
422
+ if (path2.indexOf(prefix) === 0) {
423
+ return path2;
424
+ }
425
+ }
426
+ return pth.normalize(pth.join(prefix, pth.basename(name)));
427
+ };
428
+ Utils.toBuffer = function toBuffer(input, encoder) {
429
+ if (Buffer.isBuffer(input)) {
430
+ return input;
431
+ } else if (input instanceof Uint8Array) {
432
+ return Buffer.from(input);
433
+ } else {
434
+ return typeof input === "string" ? encoder(input) : Buffer.alloc(0);
435
+ }
436
+ };
437
+ Utils.readBigUInt64LE = function(buffer, index) {
438
+ const lo = buffer.readUInt32LE(index);
439
+ const hi = buffer.readUInt32LE(index + 4);
440
+ return hi * 4294967296 + lo;
441
+ };
442
+ Utils.fromDOS2Date = function(val) {
443
+ return new Date((val >> 25 & 127) + 1980, Math.max((val >> 21 & 15) - 1, 0), Math.max(val >> 16 & 31, 1), val >> 11 & 31, val >> 5 & 63, (val & 31) << 1);
444
+ };
445
+ Utils.fromDate2DOS = function(val) {
446
+ let date = 0;
447
+ let time = 0;
448
+ if (val.getFullYear() > 1979) {
449
+ date = (val.getFullYear() - 1980 & 127) << 9 | val.getMonth() + 1 << 5 | val.getDate();
450
+ time = val.getHours() << 11 | val.getMinutes() << 5 | val.getSeconds() >> 1;
451
+ }
452
+ return date << 16 | time;
453
+ };
454
+ Utils.isWin = isWin;
455
+ Utils.crcTable = crcTable;
456
+ });
457
+
458
+ // node_modules/adm-zip/util/fattr.js
459
+ var require_fattr = __commonJS((exports, module) => {
460
+ var pth = __require("path");
461
+ module.exports = function(path2, { fs: fs2 }) {
462
+ var _path = path2 || "", _obj = newAttr(), _stat = null;
463
+ function newAttr() {
464
+ return {
465
+ directory: false,
466
+ readonly: false,
467
+ hidden: false,
468
+ executable: false,
469
+ mtime: 0,
470
+ atime: 0
471
+ };
472
+ }
473
+ if (_path && fs2.existsSync(_path)) {
474
+ _stat = fs2.statSync(_path);
475
+ _obj.directory = _stat.isDirectory();
476
+ _obj.mtime = _stat.mtime;
477
+ _obj.atime = _stat.atime;
478
+ _obj.executable = (73 & _stat.mode) !== 0;
479
+ _obj.readonly = (128 & _stat.mode) === 0;
480
+ _obj.hidden = pth.basename(_path)[0] === ".";
481
+ } else {
482
+ console.warn("Invalid path: " + _path);
483
+ }
484
+ return {
485
+ get directory() {
486
+ return _obj.directory;
487
+ },
488
+ get readOnly() {
489
+ return _obj.readonly;
490
+ },
491
+ get hidden() {
492
+ return _obj.hidden;
493
+ },
494
+ get mtime() {
495
+ return _obj.mtime;
496
+ },
497
+ get atime() {
498
+ return _obj.atime;
499
+ },
500
+ get executable() {
501
+ return _obj.executable;
502
+ },
503
+ decodeAttributes: function() {},
504
+ encodeAttributes: function() {},
505
+ toJSON: function() {
506
+ return {
507
+ path: _path,
508
+ isDirectory: _obj.directory,
509
+ isReadOnly: _obj.readonly,
510
+ isHidden: _obj.hidden,
511
+ isExecutable: _obj.executable,
512
+ mTime: _obj.mtime,
513
+ aTime: _obj.atime
514
+ };
515
+ },
516
+ toString: function() {
517
+ return JSON.stringify(this.toJSON(), null, "\t");
518
+ }
519
+ };
520
+ };
521
+ });
522
+
523
+ // node_modules/adm-zip/util/decoder.js
524
+ var require_decoder = __commonJS((exports, module) => {
525
+ module.exports = {
526
+ efs: true,
527
+ encode: (data) => Buffer.from(data, "utf8"),
528
+ decode: (data) => data.toString("utf8")
529
+ };
530
+ });
531
+
532
+ // node_modules/adm-zip/util/index.js
533
+ var require_util = __commonJS((exports, module) => {
534
+ module.exports = require_utils();
535
+ module.exports.Constants = require_constants();
536
+ module.exports.Errors = require_errors();
537
+ module.exports.FileAttr = require_fattr();
538
+ module.exports.decoder = require_decoder();
539
+ });
540
+
541
+ // node_modules/adm-zip/headers/entryHeader.js
542
+ var require_entryHeader = __commonJS((exports, module) => {
543
+ var Utils = require_util();
544
+ var Constants = Utils.Constants;
545
+ module.exports = function() {
546
+ var _verMade = 20, _version = 10, _flags = 0, _method = 0, _time = 0, _crc = 0, _compressedSize = 0, _size = 0, _fnameLen = 0, _extraLen = 0, _comLen = 0, _diskStart = 0, _inattr = 0, _attr = 0, _offset = 0;
547
+ _verMade |= Utils.isWin ? 2560 : 768;
548
+ _flags |= Constants.FLG_EFS;
549
+ const _localHeader = {
550
+ extraLen: 0
551
+ };
552
+ const uint32 = (val) => Math.max(0, val) >>> 0;
553
+ const uint16 = (val) => Math.max(0, val) & 65535;
554
+ const uint8 = (val) => Math.max(0, val) & 255;
555
+ _time = Utils.fromDate2DOS(new Date);
556
+ return {
557
+ get made() {
558
+ return _verMade;
559
+ },
560
+ set made(val) {
561
+ _verMade = val;
562
+ },
563
+ get version() {
564
+ return _version;
565
+ },
566
+ set version(val) {
567
+ _version = val;
568
+ },
569
+ get flags() {
570
+ return _flags;
571
+ },
572
+ set flags(val) {
573
+ _flags = val;
574
+ },
575
+ get flags_efs() {
576
+ return (_flags & Constants.FLG_EFS) > 0;
577
+ },
578
+ set flags_efs(val) {
579
+ if (val) {
580
+ _flags |= Constants.FLG_EFS;
581
+ } else {
582
+ _flags &= ~Constants.FLG_EFS;
583
+ }
584
+ },
585
+ get flags_desc() {
586
+ return (_flags & Constants.FLG_DESC) > 0;
587
+ },
588
+ set flags_desc(val) {
589
+ if (val) {
590
+ _flags |= Constants.FLG_DESC;
591
+ } else {
592
+ _flags &= ~Constants.FLG_DESC;
593
+ }
594
+ },
595
+ get method() {
596
+ return _method;
597
+ },
598
+ set method(val) {
599
+ switch (val) {
600
+ case Constants.STORED:
601
+ this.version = 10;
602
+ case Constants.DEFLATED:
603
+ default:
604
+ this.version = 20;
605
+ }
606
+ _method = val;
607
+ },
608
+ get time() {
609
+ return Utils.fromDOS2Date(this.timeval);
610
+ },
611
+ set time(val) {
612
+ val = new Date(val);
613
+ this.timeval = Utils.fromDate2DOS(val);
614
+ },
615
+ get timeval() {
616
+ return _time;
617
+ },
618
+ set timeval(val) {
619
+ _time = uint32(val);
620
+ },
621
+ get timeHighByte() {
622
+ return uint8(_time >>> 8);
623
+ },
624
+ get crc() {
625
+ return _crc;
626
+ },
627
+ set crc(val) {
628
+ _crc = uint32(val);
629
+ },
630
+ get compressedSize() {
631
+ return _compressedSize;
632
+ },
633
+ set compressedSize(val) {
634
+ _compressedSize = uint32(val);
635
+ },
636
+ get size() {
637
+ return _size;
638
+ },
639
+ set size(val) {
640
+ _size = uint32(val);
641
+ },
642
+ get fileNameLength() {
643
+ return _fnameLen;
644
+ },
645
+ set fileNameLength(val) {
646
+ _fnameLen = val;
647
+ },
648
+ get extraLength() {
649
+ return _extraLen;
650
+ },
651
+ set extraLength(val) {
652
+ _extraLen = val;
653
+ },
654
+ get extraLocalLength() {
655
+ return _localHeader.extraLen;
656
+ },
657
+ set extraLocalLength(val) {
658
+ _localHeader.extraLen = val;
659
+ },
660
+ get commentLength() {
661
+ return _comLen;
662
+ },
663
+ set commentLength(val) {
664
+ _comLen = val;
665
+ },
666
+ get diskNumStart() {
667
+ return _diskStart;
668
+ },
669
+ set diskNumStart(val) {
670
+ _diskStart = uint32(val);
671
+ },
672
+ get inAttr() {
673
+ return _inattr;
674
+ },
675
+ set inAttr(val) {
676
+ _inattr = uint32(val);
677
+ },
678
+ get attr() {
679
+ return _attr;
680
+ },
681
+ set attr(val) {
682
+ _attr = uint32(val);
683
+ },
684
+ get fileAttr() {
685
+ return (_attr || 0) >> 16 & 4095;
686
+ },
687
+ get offset() {
688
+ return _offset;
689
+ },
690
+ set offset(val) {
691
+ _offset = uint32(val);
692
+ },
693
+ get encrypted() {
694
+ return (_flags & Constants.FLG_ENC) === Constants.FLG_ENC;
695
+ },
696
+ get centralHeaderSize() {
697
+ return Constants.CENHDR + _fnameLen + _extraLen + _comLen;
698
+ },
699
+ get realDataOffset() {
700
+ return _offset + Constants.LOCHDR + _localHeader.fnameLen + _localHeader.extraLen;
701
+ },
702
+ get localHeader() {
703
+ return _localHeader;
704
+ },
705
+ loadLocalHeaderFromBinary: function(input) {
706
+ var data = input.slice(_offset, _offset + Constants.LOCHDR);
707
+ if (data.readUInt32LE(0) !== Constants.LOCSIG) {
708
+ throw Utils.Errors.INVALID_LOC();
709
+ }
710
+ _localHeader.version = data.readUInt16LE(Constants.LOCVER);
711
+ _localHeader.flags = data.readUInt16LE(Constants.LOCFLG);
712
+ _localHeader.flags_desc = (_localHeader.flags & Constants.FLG_DESC) > 0;
713
+ _localHeader.method = data.readUInt16LE(Constants.LOCHOW);
714
+ _localHeader.time = data.readUInt32LE(Constants.LOCTIM);
715
+ _localHeader.crc = data.readUInt32LE(Constants.LOCCRC);
716
+ _localHeader.compressedSize = data.readUInt32LE(Constants.LOCSIZ);
717
+ _localHeader.size = data.readUInt32LE(Constants.LOCLEN);
718
+ _localHeader.fnameLen = data.readUInt16LE(Constants.LOCNAM);
719
+ _localHeader.extraLen = data.readUInt16LE(Constants.LOCEXT);
720
+ const extraStart = _offset + Constants.LOCHDR + _localHeader.fnameLen;
721
+ const extraEnd = extraStart + _localHeader.extraLen;
722
+ return input.slice(extraStart, extraEnd);
723
+ },
724
+ loadFromBinary: function(data) {
725
+ if (data.length !== Constants.CENHDR || data.readUInt32LE(0) !== Constants.CENSIG) {
726
+ throw Utils.Errors.INVALID_CEN();
727
+ }
728
+ _verMade = data.readUInt16LE(Constants.CENVEM);
729
+ _version = data.readUInt16LE(Constants.CENVER);
730
+ _flags = data.readUInt16LE(Constants.CENFLG);
731
+ _method = data.readUInt16LE(Constants.CENHOW);
732
+ _time = data.readUInt32LE(Constants.CENTIM);
733
+ _crc = data.readUInt32LE(Constants.CENCRC);
734
+ _compressedSize = data.readUInt32LE(Constants.CENSIZ);
735
+ _size = data.readUInt32LE(Constants.CENLEN);
736
+ _fnameLen = data.readUInt16LE(Constants.CENNAM);
737
+ _extraLen = data.readUInt16LE(Constants.CENEXT);
738
+ _comLen = data.readUInt16LE(Constants.CENCOM);
739
+ _diskStart = data.readUInt16LE(Constants.CENDSK);
740
+ _inattr = data.readUInt16LE(Constants.CENATT);
741
+ _attr = data.readUInt32LE(Constants.CENATX);
742
+ _offset = data.readUInt32LE(Constants.CENOFF);
743
+ },
744
+ localHeaderToBinary: function() {
745
+ var data = Buffer.alloc(Constants.LOCHDR);
746
+ data.writeUInt32LE(Constants.LOCSIG, 0);
747
+ data.writeUInt16LE(_version, Constants.LOCVER);
748
+ data.writeUInt16LE(_flags, Constants.LOCFLG);
749
+ data.writeUInt16LE(_method, Constants.LOCHOW);
750
+ data.writeUInt32LE(_time, Constants.LOCTIM);
751
+ data.writeUInt32LE(_crc, Constants.LOCCRC);
752
+ data.writeUInt32LE(_compressedSize, Constants.LOCSIZ);
753
+ data.writeUInt32LE(_size, Constants.LOCLEN);
754
+ data.writeUInt16LE(_fnameLen, Constants.LOCNAM);
755
+ data.writeUInt16LE(_localHeader.extraLen, Constants.LOCEXT);
756
+ return data;
757
+ },
758
+ centralHeaderToBinary: function() {
759
+ var data = Buffer.alloc(Constants.CENHDR + _fnameLen + _extraLen + _comLen);
760
+ data.writeUInt32LE(Constants.CENSIG, 0);
761
+ data.writeUInt16LE(_verMade, Constants.CENVEM);
762
+ data.writeUInt16LE(_version, Constants.CENVER);
763
+ data.writeUInt16LE(_flags, Constants.CENFLG);
764
+ data.writeUInt16LE(_method, Constants.CENHOW);
765
+ data.writeUInt32LE(_time, Constants.CENTIM);
766
+ data.writeUInt32LE(_crc, Constants.CENCRC);
767
+ data.writeUInt32LE(_compressedSize, Constants.CENSIZ);
768
+ data.writeUInt32LE(_size, Constants.CENLEN);
769
+ data.writeUInt16LE(_fnameLen, Constants.CENNAM);
770
+ data.writeUInt16LE(_extraLen, Constants.CENEXT);
771
+ data.writeUInt16LE(_comLen, Constants.CENCOM);
772
+ data.writeUInt16LE(_diskStart, Constants.CENDSK);
773
+ data.writeUInt16LE(_inattr, Constants.CENATT);
774
+ data.writeUInt32LE(_attr, Constants.CENATX);
775
+ data.writeUInt32LE(_offset, Constants.CENOFF);
776
+ return data;
777
+ },
778
+ toJSON: function() {
779
+ const bytes = function(nr) {
780
+ return nr + " bytes";
781
+ };
782
+ return {
783
+ made: _verMade,
784
+ version: _version,
785
+ flags: _flags,
786
+ method: Utils.methodToString(_method),
787
+ time: this.time,
788
+ crc: "0x" + _crc.toString(16).toUpperCase(),
789
+ compressedSize: bytes(_compressedSize),
790
+ size: bytes(_size),
791
+ fileNameLength: bytes(_fnameLen),
792
+ extraLength: bytes(_extraLen),
793
+ commentLength: bytes(_comLen),
794
+ diskNumStart: _diskStart,
795
+ inAttr: _inattr,
796
+ attr: _attr,
797
+ offset: _offset,
798
+ centralHeaderSize: bytes(Constants.CENHDR + _fnameLen + _extraLen + _comLen)
799
+ };
800
+ },
801
+ toString: function() {
802
+ return JSON.stringify(this.toJSON(), null, "\t");
803
+ }
804
+ };
805
+ };
806
+ });
807
+
808
+ // node_modules/adm-zip/headers/mainHeader.js
809
+ var require_mainHeader = __commonJS((exports, module) => {
810
+ var Utils = require_util();
811
+ var Constants = Utils.Constants;
812
+ module.exports = function() {
813
+ var _volumeEntries = 0, _totalEntries = 0, _size = 0, _offset = 0, _commentLength = 0;
814
+ return {
815
+ get diskEntries() {
816
+ return _volumeEntries;
817
+ },
818
+ set diskEntries(val) {
819
+ _volumeEntries = _totalEntries = val;
820
+ },
821
+ get totalEntries() {
822
+ return _totalEntries;
823
+ },
824
+ set totalEntries(val) {
825
+ _totalEntries = _volumeEntries = val;
826
+ },
827
+ get size() {
828
+ return _size;
829
+ },
830
+ set size(val) {
831
+ _size = val;
832
+ },
833
+ get offset() {
834
+ return _offset;
835
+ },
836
+ set offset(val) {
837
+ _offset = val;
838
+ },
839
+ get commentLength() {
840
+ return _commentLength;
841
+ },
842
+ set commentLength(val) {
843
+ _commentLength = val;
844
+ },
845
+ get mainHeaderSize() {
846
+ return Constants.ENDHDR + _commentLength;
847
+ },
848
+ loadFromBinary: function(data) {
849
+ if ((data.length !== Constants.ENDHDR || data.readUInt32LE(0) !== Constants.ENDSIG) && (data.length < Constants.ZIP64HDR || data.readUInt32LE(0) !== Constants.ZIP64SIG)) {
850
+ throw Utils.Errors.INVALID_END();
851
+ }
852
+ if (data.readUInt32LE(0) === Constants.ENDSIG) {
853
+ _volumeEntries = data.readUInt16LE(Constants.ENDSUB);
854
+ _totalEntries = data.readUInt16LE(Constants.ENDTOT);
855
+ _size = data.readUInt32LE(Constants.ENDSIZ);
856
+ _offset = data.readUInt32LE(Constants.ENDOFF);
857
+ _commentLength = data.readUInt16LE(Constants.ENDCOM);
858
+ } else {
859
+ _volumeEntries = Utils.readBigUInt64LE(data, Constants.ZIP64SUB);
860
+ _totalEntries = Utils.readBigUInt64LE(data, Constants.ZIP64TOT);
861
+ _size = Utils.readBigUInt64LE(data, Constants.ZIP64SIZE);
862
+ _offset = Utils.readBigUInt64LE(data, Constants.ZIP64OFF);
863
+ _commentLength = 0;
864
+ }
865
+ },
866
+ toBinary: function() {
867
+ var b = Buffer.alloc(Constants.ENDHDR + _commentLength);
868
+ b.writeUInt32LE(Constants.ENDSIG, 0);
869
+ b.writeUInt32LE(0, 4);
870
+ b.writeUInt16LE(_volumeEntries, Constants.ENDSUB);
871
+ b.writeUInt16LE(_totalEntries, Constants.ENDTOT);
872
+ b.writeUInt32LE(_size, Constants.ENDSIZ);
873
+ b.writeUInt32LE(_offset, Constants.ENDOFF);
874
+ b.writeUInt16LE(_commentLength, Constants.ENDCOM);
875
+ b.fill(" ", Constants.ENDHDR);
876
+ return b;
877
+ },
878
+ toJSON: function() {
879
+ const offset = function(nr, len) {
880
+ let offs = nr.toString(16).toUpperCase();
881
+ while (offs.length < len)
882
+ offs = "0" + offs;
883
+ return "0x" + offs;
884
+ };
885
+ return {
886
+ diskEntries: _volumeEntries,
887
+ totalEntries: _totalEntries,
888
+ size: _size + " bytes",
889
+ offset: offset(_offset, 4),
890
+ commentLength: _commentLength
891
+ };
892
+ },
893
+ toString: function() {
894
+ return JSON.stringify(this.toJSON(), null, "\t");
895
+ }
896
+ };
897
+ };
898
+ });
899
+
900
+ // node_modules/adm-zip/headers/index.js
901
+ var require_headers = __commonJS((exports) => {
902
+ exports.EntryHeader = require_entryHeader();
903
+ exports.MainHeader = require_mainHeader();
904
+ });
905
+
906
+ // node_modules/adm-zip/methods/deflater.js
907
+ var require_deflater = __commonJS((exports, module) => {
908
+ module.exports = function(inbuf) {
909
+ var zlib = __require("zlib");
910
+ var opts = { chunkSize: (parseInt(inbuf.length / 1024) + 1) * 1024 };
911
+ return {
912
+ deflate: function() {
913
+ return zlib.deflateRawSync(inbuf, opts);
914
+ },
915
+ deflateAsync: function(callback) {
916
+ var tmp = zlib.createDeflateRaw(opts), parts = [], total = 0;
917
+ tmp.on("data", function(data) {
918
+ parts.push(data);
919
+ total += data.length;
920
+ });
921
+ tmp.on("end", function() {
922
+ var buf = Buffer.alloc(total), written = 0;
923
+ buf.fill(0);
924
+ for (var i = 0;i < parts.length; i++) {
925
+ var part = parts[i];
926
+ part.copy(buf, written);
927
+ written += part.length;
928
+ }
929
+ callback && callback(buf);
930
+ });
931
+ tmp.end(inbuf);
932
+ }
933
+ };
934
+ };
935
+ });
936
+
937
+ // node_modules/adm-zip/methods/inflater.js
938
+ var require_inflater = __commonJS((exports, module) => {
939
+ var version = +(process.versions ? process.versions.node : "").split(".")[0] || 0;
940
+ module.exports = function(inbuf, expectedLength) {
941
+ var zlib = __require("zlib");
942
+ const option = version >= 15 && expectedLength > 0 ? { maxOutputLength: expectedLength } : {};
943
+ return {
944
+ inflate: function() {
945
+ return zlib.inflateRawSync(inbuf, option);
946
+ },
947
+ inflateAsync: function(callback) {
948
+ var tmp = zlib.createInflateRaw(option), parts = [], total = 0;
949
+ tmp.on("data", function(data) {
950
+ parts.push(data);
951
+ total += data.length;
952
+ });
953
+ tmp.on("end", function() {
954
+ var buf = Buffer.alloc(total), written = 0;
955
+ buf.fill(0);
956
+ for (var i = 0;i < parts.length; i++) {
957
+ var part = parts[i];
958
+ part.copy(buf, written);
959
+ written += part.length;
960
+ }
961
+ callback && callback(buf);
962
+ });
963
+ tmp.end(inbuf);
964
+ }
965
+ };
966
+ };
967
+ });
968
+
969
+ // node_modules/adm-zip/methods/zipcrypto.js
970
+ var require_zipcrypto = __commonJS((exports, module) => {
971
+ var { randomFillSync } = __require("crypto");
972
+ var Errors = require_errors();
973
+ var crctable = new Uint32Array(256).map((t, crc) => {
974
+ for (let j = 0;j < 8; j++) {
975
+ if ((crc & 1) !== 0) {
976
+ crc = crc >>> 1 ^ 3988292384;
977
+ } else {
978
+ crc >>>= 1;
979
+ }
980
+ }
981
+ return crc >>> 0;
982
+ });
983
+ var uMul = (a, b) => Math.imul(a, b) >>> 0;
984
+ var crc32update = (pCrc32, bval) => {
985
+ return crctable[(pCrc32 ^ bval) & 255] ^ pCrc32 >>> 8;
986
+ };
987
+ var genSalt = () => {
988
+ if (typeof randomFillSync === "function") {
989
+ return randomFillSync(Buffer.alloc(12));
990
+ } else {
991
+ return genSalt.node();
992
+ }
993
+ };
994
+ genSalt.node = () => {
995
+ const salt = Buffer.alloc(12);
996
+ const len = salt.length;
997
+ for (let i = 0;i < len; i++)
998
+ salt[i] = Math.random() * 256 & 255;
999
+ return salt;
1000
+ };
1001
+ var config = {
1002
+ genSalt
1003
+ };
1004
+ function Initkeys(pw) {
1005
+ const pass = Buffer.isBuffer(pw) ? pw : Buffer.from(pw);
1006
+ this.keys = new Uint32Array([305419896, 591751049, 878082192]);
1007
+ for (let i = 0;i < pass.length; i++) {
1008
+ this.updateKeys(pass[i]);
1009
+ }
1010
+ }
1011
+ Initkeys.prototype.updateKeys = function(byteValue) {
1012
+ const keys = this.keys;
1013
+ keys[0] = crc32update(keys[0], byteValue);
1014
+ keys[1] += keys[0] & 255;
1015
+ keys[1] = uMul(keys[1], 134775813) + 1;
1016
+ keys[2] = crc32update(keys[2], keys[1] >>> 24);
1017
+ return byteValue;
1018
+ };
1019
+ Initkeys.prototype.next = function() {
1020
+ const k = (this.keys[2] | 2) >>> 0;
1021
+ return uMul(k, k ^ 1) >> 8 & 255;
1022
+ };
1023
+ function make_decrypter(pwd) {
1024
+ const keys = new Initkeys(pwd);
1025
+ return function(data) {
1026
+ const result = Buffer.alloc(data.length);
1027
+ let pos = 0;
1028
+ for (let c of data) {
1029
+ result[pos++] = keys.updateKeys(c ^ keys.next());
1030
+ }
1031
+ return result;
1032
+ };
1033
+ }
1034
+ function make_encrypter(pwd) {
1035
+ const keys = new Initkeys(pwd);
1036
+ return function(data, result, pos = 0) {
1037
+ if (!result)
1038
+ result = Buffer.alloc(data.length);
1039
+ for (let c of data) {
1040
+ const k = keys.next();
1041
+ result[pos++] = c ^ k;
1042
+ keys.updateKeys(c);
1043
+ }
1044
+ return result;
1045
+ };
1046
+ }
1047
+ function decrypt(data, header, pwd) {
1048
+ if (!data || !Buffer.isBuffer(data) || data.length < 12) {
1049
+ return Buffer.alloc(0);
1050
+ }
1051
+ const decrypter = make_decrypter(pwd);
1052
+ const salt = decrypter(data.slice(0, 12));
1053
+ const verifyByte = (header.flags & 8) === 8 ? header.timeHighByte : header.crc >>> 24;
1054
+ if (salt[11] !== verifyByte) {
1055
+ throw Errors.WRONG_PASSWORD();
1056
+ }
1057
+ return decrypter(data.slice(12));
1058
+ }
1059
+ function _salter(data) {
1060
+ if (Buffer.isBuffer(data) && data.length >= 12) {
1061
+ config.genSalt = function() {
1062
+ return data.slice(0, 12);
1063
+ };
1064
+ } else if (data === "node") {
1065
+ config.genSalt = genSalt.node;
1066
+ } else {
1067
+ config.genSalt = genSalt;
1068
+ }
1069
+ }
1070
+ function encrypt(data, header, pwd, oldlike = false) {
1071
+ if (data == null)
1072
+ data = Buffer.alloc(0);
1073
+ if (!Buffer.isBuffer(data))
1074
+ data = Buffer.from(data.toString());
1075
+ const encrypter = make_encrypter(pwd);
1076
+ const salt = config.genSalt();
1077
+ salt[11] = header.crc >>> 24 & 255;
1078
+ if (oldlike)
1079
+ salt[10] = header.crc >>> 16 & 255;
1080
+ const result = Buffer.alloc(data.length + 12);
1081
+ encrypter(salt, result);
1082
+ return encrypter(data, result, 12);
1083
+ }
1084
+ module.exports = { decrypt, encrypt, _salter };
1085
+ });
1086
+
1087
+ // node_modules/adm-zip/methods/index.js
1088
+ var require_methods = __commonJS((exports) => {
1089
+ exports.Deflater = require_deflater();
1090
+ exports.Inflater = require_inflater();
1091
+ exports.ZipCrypto = require_zipcrypto();
1092
+ });
1093
+
1094
+ // node_modules/adm-zip/zipEntry.js
1095
+ var require_zipEntry = __commonJS((exports, module) => {
1096
+ var Utils = require_util();
1097
+ var Headers = require_headers();
1098
+ var Constants = Utils.Constants;
1099
+ var Methods = require_methods();
1100
+ module.exports = function(options, input) {
1101
+ var _centralHeader = new Headers.EntryHeader, _entryName = Buffer.alloc(0), _comment = Buffer.alloc(0), _isDirectory = false, uncompressedData = null, _extra = Buffer.alloc(0), _extralocal = Buffer.alloc(0), _efs = true;
1102
+ const opts = options;
1103
+ const decoder = typeof opts.decoder === "object" ? opts.decoder : Utils.decoder;
1104
+ _efs = decoder.hasOwnProperty("efs") ? decoder.efs : false;
1105
+ function getCompressedDataFromZip() {
1106
+ if (!input || !(input instanceof Uint8Array)) {
1107
+ return Buffer.alloc(0);
1108
+ }
1109
+ _extralocal = _centralHeader.loadLocalHeaderFromBinary(input);
1110
+ return input.slice(_centralHeader.realDataOffset, _centralHeader.realDataOffset + _centralHeader.compressedSize);
1111
+ }
1112
+ function crc32OK(data) {
1113
+ if (!_centralHeader.flags_desc && !_centralHeader.localHeader.flags_desc) {
1114
+ if (Utils.crc32(data) !== _centralHeader.localHeader.crc) {
1115
+ return false;
1116
+ }
1117
+ } else {
1118
+ const descriptor = {};
1119
+ const dataEndOffset = _centralHeader.realDataOffset + _centralHeader.compressedSize;
1120
+ if (input.readUInt32LE(dataEndOffset) == Constants.LOCSIG || input.readUInt32LE(dataEndOffset) == Constants.CENSIG) {
1121
+ throw Utils.Errors.DESCRIPTOR_NOT_EXIST();
1122
+ }
1123
+ if (input.readUInt32LE(dataEndOffset) == Constants.EXTSIG) {
1124
+ descriptor.crc = input.readUInt32LE(dataEndOffset + Constants.EXTCRC);
1125
+ descriptor.compressedSize = input.readUInt32LE(dataEndOffset + Constants.EXTSIZ);
1126
+ descriptor.size = input.readUInt32LE(dataEndOffset + Constants.EXTLEN);
1127
+ } else if (input.readUInt16LE(dataEndOffset + 12) === 19280) {
1128
+ descriptor.crc = input.readUInt32LE(dataEndOffset + Constants.EXTCRC - 4);
1129
+ descriptor.compressedSize = input.readUInt32LE(dataEndOffset + Constants.EXTSIZ - 4);
1130
+ descriptor.size = input.readUInt32LE(dataEndOffset + Constants.EXTLEN - 4);
1131
+ } else {
1132
+ throw Utils.Errors.DESCRIPTOR_UNKNOWN();
1133
+ }
1134
+ if (descriptor.compressedSize !== _centralHeader.compressedSize || descriptor.size !== _centralHeader.size || descriptor.crc !== _centralHeader.crc) {
1135
+ throw Utils.Errors.DESCRIPTOR_FAULTY();
1136
+ }
1137
+ if (Utils.crc32(data) !== descriptor.crc) {
1138
+ return false;
1139
+ }
1140
+ }
1141
+ return true;
1142
+ }
1143
+ function decompress(async, callback, pass) {
1144
+ if (typeof callback === "undefined" && typeof async === "string") {
1145
+ pass = async;
1146
+ async = undefined;
1147
+ }
1148
+ if (_isDirectory) {
1149
+ if (async && callback) {
1150
+ callback(Buffer.alloc(0), Utils.Errors.DIRECTORY_CONTENT_ERROR());
1151
+ }
1152
+ return Buffer.alloc(0);
1153
+ }
1154
+ var compressedData = getCompressedDataFromZip();
1155
+ if (compressedData.length === 0) {
1156
+ if (async && callback)
1157
+ callback(compressedData);
1158
+ return compressedData;
1159
+ }
1160
+ if (_centralHeader.encrypted) {
1161
+ if (typeof pass !== "string" && !Buffer.isBuffer(pass)) {
1162
+ throw Utils.Errors.INVALID_PASS_PARAM();
1163
+ }
1164
+ compressedData = Methods.ZipCrypto.decrypt(compressedData, _centralHeader, pass);
1165
+ }
1166
+ var data = Buffer.alloc(_centralHeader.size);
1167
+ switch (_centralHeader.method) {
1168
+ case Utils.Constants.STORED:
1169
+ compressedData.copy(data);
1170
+ if (!crc32OK(data)) {
1171
+ if (async && callback)
1172
+ callback(data, Utils.Errors.BAD_CRC());
1173
+ throw Utils.Errors.BAD_CRC();
1174
+ } else {
1175
+ if (async && callback)
1176
+ callback(data);
1177
+ return data;
1178
+ }
1179
+ case Utils.Constants.DEFLATED:
1180
+ var inflater = new Methods.Inflater(compressedData, _centralHeader.size);
1181
+ if (!async) {
1182
+ const result = inflater.inflate(data);
1183
+ result.copy(data, 0);
1184
+ if (!crc32OK(data)) {
1185
+ throw Utils.Errors.BAD_CRC(`"${decoder.decode(_entryName)}"`);
1186
+ }
1187
+ return data;
1188
+ } else {
1189
+ inflater.inflateAsync(function(result) {
1190
+ result.copy(result, 0);
1191
+ if (callback) {
1192
+ if (!crc32OK(result)) {
1193
+ callback(result, Utils.Errors.BAD_CRC());
1194
+ } else {
1195
+ callback(result);
1196
+ }
1197
+ }
1198
+ });
1199
+ }
1200
+ break;
1201
+ default:
1202
+ if (async && callback)
1203
+ callback(Buffer.alloc(0), Utils.Errors.UNKNOWN_METHOD());
1204
+ throw Utils.Errors.UNKNOWN_METHOD();
1205
+ }
1206
+ }
1207
+ function compress(async, callback) {
1208
+ if ((!uncompressedData || !uncompressedData.length) && Buffer.isBuffer(input)) {
1209
+ if (async && callback)
1210
+ callback(getCompressedDataFromZip());
1211
+ return getCompressedDataFromZip();
1212
+ }
1213
+ if (uncompressedData.length && !_isDirectory) {
1214
+ var compressedData;
1215
+ switch (_centralHeader.method) {
1216
+ case Utils.Constants.STORED:
1217
+ _centralHeader.compressedSize = _centralHeader.size;
1218
+ compressedData = Buffer.alloc(uncompressedData.length);
1219
+ uncompressedData.copy(compressedData);
1220
+ if (async && callback)
1221
+ callback(compressedData);
1222
+ return compressedData;
1223
+ default:
1224
+ case Utils.Constants.DEFLATED:
1225
+ var deflater = new Methods.Deflater(uncompressedData);
1226
+ if (!async) {
1227
+ var deflated = deflater.deflate();
1228
+ _centralHeader.compressedSize = deflated.length;
1229
+ return deflated;
1230
+ } else {
1231
+ deflater.deflateAsync(function(data) {
1232
+ compressedData = Buffer.alloc(data.length);
1233
+ _centralHeader.compressedSize = data.length;
1234
+ data.copy(compressedData);
1235
+ callback && callback(compressedData);
1236
+ });
1237
+ }
1238
+ deflater = null;
1239
+ break;
1240
+ }
1241
+ } else if (async && callback) {
1242
+ callback(Buffer.alloc(0));
1243
+ } else {
1244
+ return Buffer.alloc(0);
1245
+ }
1246
+ }
1247
+ function readUInt64LE(buffer, offset) {
1248
+ return Utils.readBigUInt64LE(buffer, offset);
1249
+ }
1250
+ function parseExtra(data) {
1251
+ try {
1252
+ var offset = 0;
1253
+ var signature, size, part;
1254
+ while (offset + 4 < data.length) {
1255
+ signature = data.readUInt16LE(offset);
1256
+ offset += 2;
1257
+ size = data.readUInt16LE(offset);
1258
+ offset += 2;
1259
+ part = data.slice(offset, offset + size);
1260
+ offset += size;
1261
+ if (Constants.ID_ZIP64 === signature) {
1262
+ parseZip64ExtendedInformation(part);
1263
+ }
1264
+ }
1265
+ } catch (error) {
1266
+ throw Utils.Errors.EXTRA_FIELD_PARSE_ERROR();
1267
+ }
1268
+ }
1269
+ function parseZip64ExtendedInformation(data) {
1270
+ var size, compressedSize, offset, diskNumStart;
1271
+ if (data.length >= Constants.EF_ZIP64_SCOMP) {
1272
+ size = readUInt64LE(data, Constants.EF_ZIP64_SUNCOMP);
1273
+ if (_centralHeader.size === Constants.EF_ZIP64_OR_32) {
1274
+ _centralHeader.size = size;
1275
+ }
1276
+ }
1277
+ if (data.length >= Constants.EF_ZIP64_RHO) {
1278
+ compressedSize = readUInt64LE(data, Constants.EF_ZIP64_SCOMP);
1279
+ if (_centralHeader.compressedSize === Constants.EF_ZIP64_OR_32) {
1280
+ _centralHeader.compressedSize = compressedSize;
1281
+ }
1282
+ }
1283
+ if (data.length >= Constants.EF_ZIP64_DSN) {
1284
+ offset = readUInt64LE(data, Constants.EF_ZIP64_RHO);
1285
+ if (_centralHeader.offset === Constants.EF_ZIP64_OR_32) {
1286
+ _centralHeader.offset = offset;
1287
+ }
1288
+ }
1289
+ if (data.length >= Constants.EF_ZIP64_DSN + 4) {
1290
+ diskNumStart = data.readUInt32LE(Constants.EF_ZIP64_DSN);
1291
+ if (_centralHeader.diskNumStart === Constants.EF_ZIP64_OR_16) {
1292
+ _centralHeader.diskNumStart = diskNumStart;
1293
+ }
1294
+ }
1295
+ }
1296
+ return {
1297
+ get entryName() {
1298
+ return decoder.decode(_entryName);
1299
+ },
1300
+ get rawEntryName() {
1301
+ return _entryName;
1302
+ },
1303
+ set entryName(val) {
1304
+ _entryName = Utils.toBuffer(val, decoder.encode);
1305
+ var lastChar = _entryName[_entryName.length - 1];
1306
+ _isDirectory = lastChar === 47 || lastChar === 92;
1307
+ _centralHeader.fileNameLength = _entryName.length;
1308
+ },
1309
+ get efs() {
1310
+ if (typeof _efs === "function") {
1311
+ return _efs(this.entryName);
1312
+ } else {
1313
+ return _efs;
1314
+ }
1315
+ },
1316
+ get extra() {
1317
+ return _extra;
1318
+ },
1319
+ set extra(val) {
1320
+ _extra = val;
1321
+ _centralHeader.extraLength = val.length;
1322
+ parseExtra(val);
1323
+ },
1324
+ get comment() {
1325
+ return decoder.decode(_comment);
1326
+ },
1327
+ set comment(val) {
1328
+ _comment = Utils.toBuffer(val, decoder.encode);
1329
+ _centralHeader.commentLength = _comment.length;
1330
+ if (_comment.length > 65535)
1331
+ throw Utils.Errors.COMMENT_TOO_LONG();
1332
+ },
1333
+ get name() {
1334
+ var n = decoder.decode(_entryName);
1335
+ return _isDirectory ? n.substr(n.length - 1).split("/").pop() : n.split("/").pop();
1336
+ },
1337
+ get isDirectory() {
1338
+ return _isDirectory;
1339
+ },
1340
+ getCompressedData: function() {
1341
+ return compress(false, null);
1342
+ },
1343
+ getCompressedDataAsync: function(callback) {
1344
+ compress(true, callback);
1345
+ },
1346
+ setData: function(value) {
1347
+ uncompressedData = Utils.toBuffer(value, Utils.decoder.encode);
1348
+ if (!_isDirectory && uncompressedData.length) {
1349
+ _centralHeader.size = uncompressedData.length;
1350
+ _centralHeader.method = Utils.Constants.DEFLATED;
1351
+ _centralHeader.crc = Utils.crc32(value);
1352
+ _centralHeader.changed = true;
1353
+ } else {
1354
+ _centralHeader.method = Utils.Constants.STORED;
1355
+ }
1356
+ },
1357
+ getData: function(pass) {
1358
+ if (_centralHeader.changed) {
1359
+ return uncompressedData;
1360
+ } else {
1361
+ return decompress(false, null, pass);
1362
+ }
1363
+ },
1364
+ getDataAsync: function(callback, pass) {
1365
+ if (_centralHeader.changed) {
1366
+ callback(uncompressedData);
1367
+ } else {
1368
+ decompress(true, callback, pass);
1369
+ }
1370
+ },
1371
+ set attr(attr) {
1372
+ _centralHeader.attr = attr;
1373
+ },
1374
+ get attr() {
1375
+ return _centralHeader.attr;
1376
+ },
1377
+ set header(data) {
1378
+ _centralHeader.loadFromBinary(data);
1379
+ },
1380
+ get header() {
1381
+ return _centralHeader;
1382
+ },
1383
+ packCentralHeader: function() {
1384
+ _centralHeader.flags_efs = this.efs;
1385
+ _centralHeader.extraLength = _extra.length;
1386
+ var header = _centralHeader.centralHeaderToBinary();
1387
+ var addpos = Utils.Constants.CENHDR;
1388
+ _entryName.copy(header, addpos);
1389
+ addpos += _entryName.length;
1390
+ _extra.copy(header, addpos);
1391
+ addpos += _centralHeader.extraLength;
1392
+ _comment.copy(header, addpos);
1393
+ return header;
1394
+ },
1395
+ packLocalHeader: function() {
1396
+ let addpos = 0;
1397
+ _centralHeader.flags_efs = this.efs;
1398
+ _centralHeader.extraLocalLength = _extralocal.length;
1399
+ const localHeaderBuf = _centralHeader.localHeaderToBinary();
1400
+ const localHeader = Buffer.alloc(localHeaderBuf.length + _entryName.length + _centralHeader.extraLocalLength);
1401
+ localHeaderBuf.copy(localHeader, addpos);
1402
+ addpos += localHeaderBuf.length;
1403
+ _entryName.copy(localHeader, addpos);
1404
+ addpos += _entryName.length;
1405
+ _extralocal.copy(localHeader, addpos);
1406
+ addpos += _extralocal.length;
1407
+ return localHeader;
1408
+ },
1409
+ toJSON: function() {
1410
+ const bytes = function(nr) {
1411
+ return "<" + (nr && nr.length + " bytes buffer" || "null") + ">";
1412
+ };
1413
+ return {
1414
+ entryName: this.entryName,
1415
+ name: this.name,
1416
+ comment: this.comment,
1417
+ isDirectory: this.isDirectory,
1418
+ header: _centralHeader.toJSON(),
1419
+ compressedData: bytes(input),
1420
+ data: bytes(uncompressedData)
1421
+ };
1422
+ },
1423
+ toString: function() {
1424
+ return JSON.stringify(this.toJSON(), null, "\t");
1425
+ }
1426
+ };
1427
+ };
1428
+ });
1429
+
1430
+ // node_modules/adm-zip/zipFile.js
1431
+ var require_zipFile = __commonJS((exports, module) => {
1432
+ var ZipEntry = require_zipEntry();
1433
+ var Headers = require_headers();
1434
+ var Utils = require_util();
1435
+ module.exports = function(inBuffer, options) {
1436
+ var entryList = [], entryTable = {}, _comment = Buffer.alloc(0), mainHeader = new Headers.MainHeader, loadedEntries = false;
1437
+ var password = null;
1438
+ const temporary = new Set;
1439
+ const opts = options;
1440
+ const { noSort, decoder } = opts;
1441
+ if (inBuffer) {
1442
+ readMainHeader(opts.readEntries);
1443
+ } else {
1444
+ loadedEntries = true;
1445
+ }
1446
+ function makeTemporaryFolders() {
1447
+ const foldersList = new Set;
1448
+ for (const elem of Object.keys(entryTable)) {
1449
+ const elements = elem.split("/");
1450
+ elements.pop();
1451
+ if (!elements.length)
1452
+ continue;
1453
+ for (let i = 0;i < elements.length; i++) {
1454
+ const sub = elements.slice(0, i + 1).join("/") + "/";
1455
+ foldersList.add(sub);
1456
+ }
1457
+ }
1458
+ for (const elem of foldersList) {
1459
+ if (!(elem in entryTable)) {
1460
+ const tempfolder = new ZipEntry(opts);
1461
+ tempfolder.entryName = elem;
1462
+ tempfolder.attr = 16;
1463
+ tempfolder.temporary = true;
1464
+ entryList.push(tempfolder);
1465
+ entryTable[tempfolder.entryName] = tempfolder;
1466
+ temporary.add(tempfolder);
1467
+ }
1468
+ }
1469
+ }
1470
+ function readEntries() {
1471
+ loadedEntries = true;
1472
+ entryTable = {};
1473
+ if (mainHeader.diskEntries > (inBuffer.length - mainHeader.offset) / Utils.Constants.CENHDR) {
1474
+ throw Utils.Errors.DISK_ENTRY_TOO_LARGE();
1475
+ }
1476
+ entryList = new Array(mainHeader.diskEntries);
1477
+ var index = mainHeader.offset;
1478
+ for (var i = 0;i < entryList.length; i++) {
1479
+ var tmp = index, entry = new ZipEntry(opts, inBuffer);
1480
+ entry.header = inBuffer.slice(tmp, tmp += Utils.Constants.CENHDR);
1481
+ entry.entryName = inBuffer.slice(tmp, tmp += entry.header.fileNameLength);
1482
+ if (entry.header.extraLength) {
1483
+ entry.extra = inBuffer.slice(tmp, tmp += entry.header.extraLength);
1484
+ }
1485
+ if (entry.header.commentLength)
1486
+ entry.comment = inBuffer.slice(tmp, tmp + entry.header.commentLength);
1487
+ index += entry.header.centralHeaderSize;
1488
+ entryList[i] = entry;
1489
+ entryTable[entry.entryName] = entry;
1490
+ }
1491
+ temporary.clear();
1492
+ makeTemporaryFolders();
1493
+ }
1494
+ function readMainHeader(readNow) {
1495
+ var i = inBuffer.length - Utils.Constants.ENDHDR, max = Math.max(0, i - 65535), n = max, endStart = inBuffer.length, endOffset = -1, commentEnd = 0;
1496
+ const trailingSpace = typeof opts.trailingSpace === "boolean" ? opts.trailingSpace : false;
1497
+ if (trailingSpace)
1498
+ max = 0;
1499
+ for (i;i >= n; i--) {
1500
+ if (inBuffer[i] !== 80)
1501
+ continue;
1502
+ if (inBuffer.readUInt32LE(i) === Utils.Constants.ENDSIG) {
1503
+ endOffset = i;
1504
+ commentEnd = i;
1505
+ endStart = i + Utils.Constants.ENDHDR;
1506
+ n = i - Utils.Constants.END64HDR;
1507
+ continue;
1508
+ }
1509
+ if (inBuffer.readUInt32LE(i) === Utils.Constants.END64SIG) {
1510
+ n = max;
1511
+ continue;
1512
+ }
1513
+ if (inBuffer.readUInt32LE(i) === Utils.Constants.ZIP64SIG) {
1514
+ endOffset = i;
1515
+ endStart = i + Utils.readBigUInt64LE(inBuffer, i + Utils.Constants.ZIP64SIZE) + Utils.Constants.ZIP64LEAD;
1516
+ break;
1517
+ }
1518
+ }
1519
+ if (endOffset == -1)
1520
+ throw Utils.Errors.INVALID_FORMAT();
1521
+ mainHeader.loadFromBinary(inBuffer.slice(endOffset, endStart));
1522
+ if (mainHeader.commentLength) {
1523
+ _comment = inBuffer.slice(commentEnd + Utils.Constants.ENDHDR);
1524
+ }
1525
+ if (readNow)
1526
+ readEntries();
1527
+ }
1528
+ function sortEntries() {
1529
+ if (entryList.length > 1 && !noSort) {
1530
+ entryList.sort((a, b) => a.entryName.toLowerCase().localeCompare(b.entryName.toLowerCase()));
1531
+ }
1532
+ }
1533
+ return {
1534
+ get entries() {
1535
+ if (!loadedEntries) {
1536
+ readEntries();
1537
+ }
1538
+ return entryList.filter((e) => !temporary.has(e));
1539
+ },
1540
+ get comment() {
1541
+ return decoder.decode(_comment);
1542
+ },
1543
+ set comment(val) {
1544
+ _comment = Utils.toBuffer(val, decoder.encode);
1545
+ mainHeader.commentLength = _comment.length;
1546
+ },
1547
+ getEntryCount: function() {
1548
+ if (!loadedEntries) {
1549
+ return mainHeader.diskEntries;
1550
+ }
1551
+ return entryList.length;
1552
+ },
1553
+ forEach: function(callback) {
1554
+ this.entries.forEach(callback);
1555
+ },
1556
+ getEntry: function(entryName) {
1557
+ if (!loadedEntries) {
1558
+ readEntries();
1559
+ }
1560
+ return entryTable[entryName] || null;
1561
+ },
1562
+ setEntry: function(entry) {
1563
+ if (!loadedEntries) {
1564
+ readEntries();
1565
+ }
1566
+ entryList.push(entry);
1567
+ entryTable[entry.entryName] = entry;
1568
+ mainHeader.totalEntries = entryList.length;
1569
+ },
1570
+ deleteFile: function(entryName, withsubfolders = true) {
1571
+ if (!loadedEntries) {
1572
+ readEntries();
1573
+ }
1574
+ const entry = entryTable[entryName];
1575
+ const list = this.getEntryChildren(entry, withsubfolders).map((child) => child.entryName);
1576
+ list.forEach(this.deleteEntry);
1577
+ },
1578
+ deleteEntry: function(entryName) {
1579
+ if (!loadedEntries) {
1580
+ readEntries();
1581
+ }
1582
+ const entry = entryTable[entryName];
1583
+ const index = entryList.indexOf(entry);
1584
+ if (index >= 0) {
1585
+ entryList.splice(index, 1);
1586
+ delete entryTable[entryName];
1587
+ mainHeader.totalEntries = entryList.length;
1588
+ }
1589
+ },
1590
+ getEntryChildren: function(entry, subfolders = true) {
1591
+ if (!loadedEntries) {
1592
+ readEntries();
1593
+ }
1594
+ if (typeof entry === "object") {
1595
+ if (entry.isDirectory && subfolders) {
1596
+ const list = [];
1597
+ const name = entry.entryName;
1598
+ for (const zipEntry of entryList) {
1599
+ if (zipEntry.entryName.startsWith(name)) {
1600
+ list.push(zipEntry);
1601
+ }
1602
+ }
1603
+ return list;
1604
+ } else {
1605
+ return [entry];
1606
+ }
1607
+ }
1608
+ return [];
1609
+ },
1610
+ getChildCount: function(entry) {
1611
+ if (entry && entry.isDirectory) {
1612
+ const list = this.getEntryChildren(entry);
1613
+ return list.includes(entry) ? list.length - 1 : list.length;
1614
+ }
1615
+ return 0;
1616
+ },
1617
+ compressToBuffer: function() {
1618
+ if (!loadedEntries) {
1619
+ readEntries();
1620
+ }
1621
+ sortEntries();
1622
+ const dataBlock = [];
1623
+ const headerBlocks = [];
1624
+ let totalSize = 0;
1625
+ let dindex = 0;
1626
+ mainHeader.size = 0;
1627
+ mainHeader.offset = 0;
1628
+ let totalEntries = 0;
1629
+ for (const entry of this.entries) {
1630
+ const compressedData = entry.getCompressedData();
1631
+ entry.header.offset = dindex;
1632
+ const localHeader = entry.packLocalHeader();
1633
+ const dataLength = localHeader.length + compressedData.length;
1634
+ dindex += dataLength;
1635
+ dataBlock.push(localHeader);
1636
+ dataBlock.push(compressedData);
1637
+ const centralHeader = entry.packCentralHeader();
1638
+ headerBlocks.push(centralHeader);
1639
+ mainHeader.size += centralHeader.length;
1640
+ totalSize += dataLength + centralHeader.length;
1641
+ totalEntries++;
1642
+ }
1643
+ totalSize += mainHeader.mainHeaderSize;
1644
+ mainHeader.offset = dindex;
1645
+ mainHeader.totalEntries = totalEntries;
1646
+ dindex = 0;
1647
+ const outBuffer = Buffer.alloc(totalSize);
1648
+ for (const content of dataBlock) {
1649
+ content.copy(outBuffer, dindex);
1650
+ dindex += content.length;
1651
+ }
1652
+ for (const content of headerBlocks) {
1653
+ content.copy(outBuffer, dindex);
1654
+ dindex += content.length;
1655
+ }
1656
+ const mh = mainHeader.toBinary();
1657
+ if (_comment) {
1658
+ _comment.copy(mh, Utils.Constants.ENDHDR);
1659
+ }
1660
+ mh.copy(outBuffer, dindex);
1661
+ inBuffer = outBuffer;
1662
+ loadedEntries = false;
1663
+ return outBuffer;
1664
+ },
1665
+ toAsyncBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
1666
+ try {
1667
+ if (!loadedEntries) {
1668
+ readEntries();
1669
+ }
1670
+ sortEntries();
1671
+ const dataBlock = [];
1672
+ const centralHeaders = [];
1673
+ let totalSize = 0;
1674
+ let dindex = 0;
1675
+ let totalEntries = 0;
1676
+ mainHeader.size = 0;
1677
+ mainHeader.offset = 0;
1678
+ const compress2Buffer = function(entryLists) {
1679
+ if (entryLists.length > 0) {
1680
+ const entry = entryLists.shift();
1681
+ const name = entry.entryName + entry.extra.toString();
1682
+ if (onItemStart)
1683
+ onItemStart(name);
1684
+ entry.getCompressedDataAsync(function(compressedData) {
1685
+ if (onItemEnd)
1686
+ onItemEnd(name);
1687
+ entry.header.offset = dindex;
1688
+ const localHeader = entry.packLocalHeader();
1689
+ const dataLength = localHeader.length + compressedData.length;
1690
+ dindex += dataLength;
1691
+ dataBlock.push(localHeader);
1692
+ dataBlock.push(compressedData);
1693
+ const centalHeader = entry.packCentralHeader();
1694
+ centralHeaders.push(centalHeader);
1695
+ mainHeader.size += centalHeader.length;
1696
+ totalSize += dataLength + centalHeader.length;
1697
+ totalEntries++;
1698
+ compress2Buffer(entryLists);
1699
+ });
1700
+ } else {
1701
+ totalSize += mainHeader.mainHeaderSize;
1702
+ mainHeader.offset = dindex;
1703
+ mainHeader.totalEntries = totalEntries;
1704
+ dindex = 0;
1705
+ const outBuffer = Buffer.alloc(totalSize);
1706
+ dataBlock.forEach(function(content) {
1707
+ content.copy(outBuffer, dindex);
1708
+ dindex += content.length;
1709
+ });
1710
+ centralHeaders.forEach(function(content) {
1711
+ content.copy(outBuffer, dindex);
1712
+ dindex += content.length;
1713
+ });
1714
+ const mh = mainHeader.toBinary();
1715
+ if (_comment) {
1716
+ _comment.copy(mh, Utils.Constants.ENDHDR);
1717
+ }
1718
+ mh.copy(outBuffer, dindex);
1719
+ inBuffer = outBuffer;
1720
+ loadedEntries = false;
1721
+ onSuccess(outBuffer);
1722
+ }
1723
+ };
1724
+ compress2Buffer(Array.from(this.entries));
1725
+ } catch (e) {
1726
+ onFail(e);
1727
+ }
1728
+ }
1729
+ };
1730
+ };
1731
+ });
1732
+
1733
+ // node_modules/adm-zip/adm-zip.js
1734
+ var require_adm_zip = __commonJS((exports, module) => {
1735
+ var Utils = require_util();
1736
+ var pth = __require("path");
1737
+ var ZipEntry = require_zipEntry();
1738
+ var ZipFile = require_zipFile();
1739
+ var get_Bool = (...val) => Utils.findLast(val, (c) => typeof c === "boolean");
1740
+ var get_Str = (...val) => Utils.findLast(val, (c) => typeof c === "string");
1741
+ var get_Fun = (...val) => Utils.findLast(val, (c) => typeof c === "function");
1742
+ var defaultOptions = {
1743
+ noSort: false,
1744
+ readEntries: false,
1745
+ method: Utils.Constants.NONE,
1746
+ fs: null
1747
+ };
1748
+ module.exports = function(input, options) {
1749
+ let inBuffer = null;
1750
+ const opts = Object.assign(Object.create(null), defaultOptions);
1751
+ if (input && typeof input === "object") {
1752
+ if (!(input instanceof Uint8Array)) {
1753
+ Object.assign(opts, input);
1754
+ input = opts.input ? opts.input : undefined;
1755
+ if (opts.input)
1756
+ delete opts.input;
1757
+ }
1758
+ if (Buffer.isBuffer(input)) {
1759
+ inBuffer = input;
1760
+ opts.method = Utils.Constants.BUFFER;
1761
+ input = undefined;
1762
+ }
1763
+ }
1764
+ Object.assign(opts, options);
1765
+ const filetools = new Utils(opts);
1766
+ if (typeof opts.decoder !== "object" || typeof opts.decoder.encode !== "function" || typeof opts.decoder.decode !== "function") {
1767
+ opts.decoder = Utils.decoder;
1768
+ }
1769
+ if (input && typeof input === "string") {
1770
+ if (filetools.fs.existsSync(input)) {
1771
+ opts.method = Utils.Constants.FILE;
1772
+ opts.filename = input;
1773
+ inBuffer = filetools.fs.readFileSync(input);
1774
+ } else {
1775
+ throw Utils.Errors.INVALID_FILENAME();
1776
+ }
1777
+ }
1778
+ const _zip = new ZipFile(inBuffer, opts);
1779
+ const { canonical, sanitize, zipnamefix } = Utils;
1780
+ function getEntry(entry) {
1781
+ if (entry && _zip) {
1782
+ var item;
1783
+ if (typeof entry === "string")
1784
+ item = _zip.getEntry(pth.posix.normalize(entry));
1785
+ if (typeof entry === "object" && typeof entry.entryName !== "undefined" && typeof entry.header !== "undefined")
1786
+ item = _zip.getEntry(entry.entryName);
1787
+ if (item) {
1788
+ return item;
1789
+ }
1790
+ }
1791
+ return null;
1792
+ }
1793
+ function fixPath(zipPath) {
1794
+ const { join, normalize, sep } = pth.posix;
1795
+ return join(pth.isAbsolute(zipPath) ? "/" : ".", normalize(sep + zipPath.split("\\").join(sep) + sep));
1796
+ }
1797
+ function filenameFilter(filterfn) {
1798
+ if (filterfn instanceof RegExp) {
1799
+ return function(rx) {
1800
+ return function(filename) {
1801
+ return rx.test(filename);
1802
+ };
1803
+ }(filterfn);
1804
+ } else if (typeof filterfn !== "function") {
1805
+ return () => true;
1806
+ }
1807
+ return filterfn;
1808
+ }
1809
+ const relativePath = (local, entry) => {
1810
+ let lastChar = entry.slice(-1);
1811
+ lastChar = lastChar === filetools.sep ? filetools.sep : "";
1812
+ return pth.relative(local, entry) + lastChar;
1813
+ };
1814
+ return {
1815
+ readFile: function(entry, pass) {
1816
+ var item = getEntry(entry);
1817
+ return item && item.getData(pass) || null;
1818
+ },
1819
+ childCount: function(entry) {
1820
+ const item = getEntry(entry);
1821
+ if (item) {
1822
+ return _zip.getChildCount(item);
1823
+ }
1824
+ },
1825
+ readFileAsync: function(entry, callback) {
1826
+ var item = getEntry(entry);
1827
+ if (item) {
1828
+ item.getDataAsync(callback);
1829
+ } else {
1830
+ callback(null, "getEntry failed for:" + entry);
1831
+ }
1832
+ },
1833
+ readAsText: function(entry, encoding) {
1834
+ var item = getEntry(entry);
1835
+ if (item) {
1836
+ var data = item.getData();
1837
+ if (data && data.length) {
1838
+ return data.toString(encoding || "utf8");
1839
+ }
1840
+ }
1841
+ return "";
1842
+ },
1843
+ readAsTextAsync: function(entry, callback, encoding) {
1844
+ var item = getEntry(entry);
1845
+ if (item) {
1846
+ item.getDataAsync(function(data, err) {
1847
+ if (err) {
1848
+ callback(data, err);
1849
+ return;
1850
+ }
1851
+ if (data && data.length) {
1852
+ callback(data.toString(encoding || "utf8"));
1853
+ } else {
1854
+ callback("");
1855
+ }
1856
+ });
1857
+ } else {
1858
+ callback("");
1859
+ }
1860
+ },
1861
+ deleteFile: function(entry, withsubfolders = true) {
1862
+ var item = getEntry(entry);
1863
+ if (item) {
1864
+ _zip.deleteFile(item.entryName, withsubfolders);
1865
+ }
1866
+ },
1867
+ deleteEntry: function(entry) {
1868
+ var item = getEntry(entry);
1869
+ if (item) {
1870
+ _zip.deleteEntry(item.entryName);
1871
+ }
1872
+ },
1873
+ addZipComment: function(comment) {
1874
+ _zip.comment = comment;
1875
+ },
1876
+ getZipComment: function() {
1877
+ return _zip.comment || "";
1878
+ },
1879
+ addZipEntryComment: function(entry, comment) {
1880
+ var item = getEntry(entry);
1881
+ if (item) {
1882
+ item.comment = comment;
1883
+ }
1884
+ },
1885
+ getZipEntryComment: function(entry) {
1886
+ var item = getEntry(entry);
1887
+ if (item) {
1888
+ return item.comment || "";
1889
+ }
1890
+ return "";
1891
+ },
1892
+ updateFile: function(entry, content) {
1893
+ var item = getEntry(entry);
1894
+ if (item) {
1895
+ item.setData(content);
1896
+ }
1897
+ },
1898
+ addLocalFile: function(localPath2, zipPath, zipName, comment) {
1899
+ if (filetools.fs.existsSync(localPath2)) {
1900
+ zipPath = zipPath ? fixPath(zipPath) : "";
1901
+ const p = pth.win32.basename(pth.win32.normalize(localPath2));
1902
+ zipPath += zipName ? zipName : p;
1903
+ const _attr = filetools.fs.statSync(localPath2);
1904
+ const data = _attr.isFile() ? filetools.fs.readFileSync(localPath2) : Buffer.alloc(0);
1905
+ if (_attr.isDirectory())
1906
+ zipPath += filetools.sep;
1907
+ this.addFile(zipPath, data, comment, _attr);
1908
+ } else {
1909
+ throw Utils.Errors.FILE_NOT_FOUND(localPath2);
1910
+ }
1911
+ },
1912
+ addLocalFileAsync: function(options2, callback) {
1913
+ options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
1914
+ const localPath2 = pth.resolve(options2.localPath);
1915
+ const { comment } = options2;
1916
+ let { zipPath, zipName } = options2;
1917
+ const self = this;
1918
+ filetools.fs.stat(localPath2, function(err, stats) {
1919
+ if (err)
1920
+ return callback(err, false);
1921
+ zipPath = zipPath ? fixPath(zipPath) : "";
1922
+ const p = pth.win32.basename(pth.win32.normalize(localPath2));
1923
+ zipPath += zipName ? zipName : p;
1924
+ if (stats.isFile()) {
1925
+ filetools.fs.readFile(localPath2, function(err2, data) {
1926
+ if (err2)
1927
+ return callback(err2, false);
1928
+ self.addFile(zipPath, data, comment, stats);
1929
+ return setImmediate(callback, undefined, true);
1930
+ });
1931
+ } else if (stats.isDirectory()) {
1932
+ zipPath += filetools.sep;
1933
+ self.addFile(zipPath, Buffer.alloc(0), comment, stats);
1934
+ return setImmediate(callback, undefined, true);
1935
+ }
1936
+ });
1937
+ },
1938
+ addLocalFolder: function(localPath2, zipPath, filter) {
1939
+ filter = filenameFilter(filter);
1940
+ zipPath = zipPath ? fixPath(zipPath) : "";
1941
+ localPath2 = pth.normalize(localPath2);
1942
+ if (filetools.fs.existsSync(localPath2)) {
1943
+ const items = filetools.findFiles(localPath2);
1944
+ const self = this;
1945
+ if (items.length) {
1946
+ for (const filepath of items) {
1947
+ const p = pth.join(zipPath, relativePath(localPath2, filepath));
1948
+ if (filter(p)) {
1949
+ self.addLocalFile(filepath, pth.dirname(p));
1950
+ }
1951
+ }
1952
+ }
1953
+ } else {
1954
+ throw Utils.Errors.FILE_NOT_FOUND(localPath2);
1955
+ }
1956
+ },
1957
+ addLocalFolderAsync: function(localPath2, callback, zipPath, filter) {
1958
+ filter = filenameFilter(filter);
1959
+ zipPath = zipPath ? fixPath(zipPath) : "";
1960
+ localPath2 = pth.normalize(localPath2);
1961
+ var self = this;
1962
+ filetools.fs.open(localPath2, "r", function(err) {
1963
+ if (err && err.code === "ENOENT") {
1964
+ callback(undefined, Utils.Errors.FILE_NOT_FOUND(localPath2));
1965
+ } else if (err) {
1966
+ callback(undefined, err);
1967
+ } else {
1968
+ var items = filetools.findFiles(localPath2);
1969
+ var i = -1;
1970
+ var next = function() {
1971
+ i += 1;
1972
+ if (i < items.length) {
1973
+ var filepath = items[i];
1974
+ var p = relativePath(localPath2, filepath).split("\\").join("/");
1975
+ p = p.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
1976
+ if (filter(p)) {
1977
+ filetools.fs.stat(filepath, function(er0, stats) {
1978
+ if (er0)
1979
+ callback(undefined, er0);
1980
+ if (stats.isFile()) {
1981
+ filetools.fs.readFile(filepath, function(er1, data) {
1982
+ if (er1) {
1983
+ callback(undefined, er1);
1984
+ } else {
1985
+ self.addFile(zipPath + p, data, "", stats);
1986
+ next();
1987
+ }
1988
+ });
1989
+ } else {
1990
+ self.addFile(zipPath + p + "/", Buffer.alloc(0), "", stats);
1991
+ next();
1992
+ }
1993
+ });
1994
+ } else {
1995
+ process.nextTick(() => {
1996
+ next();
1997
+ });
1998
+ }
1999
+ } else {
2000
+ callback(true, undefined);
2001
+ }
2002
+ };
2003
+ next();
2004
+ }
2005
+ });
2006
+ },
2007
+ addLocalFolderAsync2: function(options2, callback) {
2008
+ const self = this;
2009
+ options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
2010
+ localPath = pth.resolve(fixPath(options2.localPath));
2011
+ let { zipPath, filter, namefix } = options2;
2012
+ if (filter instanceof RegExp) {
2013
+ filter = function(rx) {
2014
+ return function(filename) {
2015
+ return rx.test(filename);
2016
+ };
2017
+ }(filter);
2018
+ } else if (typeof filter !== "function") {
2019
+ filter = function() {
2020
+ return true;
2021
+ };
2022
+ }
2023
+ zipPath = zipPath ? fixPath(zipPath) : "";
2024
+ if (namefix == "latin1") {
2025
+ namefix = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
2026
+ }
2027
+ if (typeof namefix !== "function")
2028
+ namefix = (str) => str;
2029
+ const relPathFix = (entry) => pth.join(zipPath, namefix(relativePath(localPath, entry)));
2030
+ const fileNameFix = (entry) => pth.win32.basename(pth.win32.normalize(namefix(entry)));
2031
+ filetools.fs.open(localPath, "r", function(err) {
2032
+ if (err && err.code === "ENOENT") {
2033
+ callback(undefined, Utils.Errors.FILE_NOT_FOUND(localPath));
2034
+ } else if (err) {
2035
+ callback(undefined, err);
2036
+ } else {
2037
+ filetools.findFilesAsync(localPath, function(err2, fileEntries) {
2038
+ if (err2)
2039
+ return callback(err2);
2040
+ fileEntries = fileEntries.filter((dir) => filter(relPathFix(dir)));
2041
+ if (!fileEntries.length)
2042
+ callback(undefined, false);
2043
+ setImmediate(fileEntries.reverse().reduce(function(next, entry) {
2044
+ return function(err3, done) {
2045
+ if (err3 || done === false)
2046
+ return setImmediate(next, err3, false);
2047
+ self.addLocalFileAsync({
2048
+ localPath: entry,
2049
+ zipPath: pth.dirname(relPathFix(entry)),
2050
+ zipName: fileNameFix(entry)
2051
+ }, next);
2052
+ };
2053
+ }, callback));
2054
+ });
2055
+ }
2056
+ });
2057
+ },
2058
+ addLocalFolderPromise: function(localPath2, props) {
2059
+ return new Promise((resolve, reject) => {
2060
+ this.addLocalFolderAsync2(Object.assign({ localPath: localPath2 }, props), (err, done) => {
2061
+ if (err)
2062
+ reject(err);
2063
+ if (done)
2064
+ resolve(this);
2065
+ });
2066
+ });
2067
+ },
2068
+ addFile: function(entryName, content, comment, attr) {
2069
+ entryName = zipnamefix(entryName);
2070
+ let entry = getEntry(entryName);
2071
+ const update = entry != null;
2072
+ if (!update) {
2073
+ entry = new ZipEntry(opts);
2074
+ entry.entryName = entryName;
2075
+ }
2076
+ entry.comment = comment || "";
2077
+ const isStat = typeof attr === "object" && attr instanceof filetools.fs.Stats;
2078
+ if (isStat) {
2079
+ entry.header.time = attr.mtime;
2080
+ }
2081
+ var fileattr = entry.isDirectory ? 16 : 0;
2082
+ let unix = entry.isDirectory ? 16384 : 32768;
2083
+ if (isStat) {
2084
+ unix |= 4095 & attr.mode;
2085
+ } else if (typeof attr === "number") {
2086
+ unix |= 4095 & attr;
2087
+ } else {
2088
+ unix |= entry.isDirectory ? 493 : 420;
2089
+ }
2090
+ fileattr = (fileattr | unix << 16) >>> 0;
2091
+ entry.attr = fileattr;
2092
+ entry.setData(content);
2093
+ if (!update)
2094
+ _zip.setEntry(entry);
2095
+ return entry;
2096
+ },
2097
+ getEntries: function(password) {
2098
+ _zip.password = password;
2099
+ return _zip ? _zip.entries : [];
2100
+ },
2101
+ getEntry: function(name) {
2102
+ return getEntry(name);
2103
+ },
2104
+ getEntryCount: function() {
2105
+ return _zip.getEntryCount();
2106
+ },
2107
+ forEach: function(callback) {
2108
+ return _zip.forEach(callback);
2109
+ },
2110
+ extractEntryTo: function(entry, targetPath, maintainEntryPath, overwrite, keepOriginalPermission, outFileName) {
2111
+ overwrite = get_Bool(false, overwrite);
2112
+ keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2113
+ maintainEntryPath = get_Bool(true, maintainEntryPath);
2114
+ outFileName = get_Str(keepOriginalPermission, outFileName);
2115
+ var item = getEntry(entry);
2116
+ if (!item) {
2117
+ throw Utils.Errors.NO_ENTRY();
2118
+ }
2119
+ var entryName = canonical(item.entryName);
2120
+ var target = sanitize(targetPath, outFileName && !item.isDirectory ? outFileName : maintainEntryPath ? entryName : pth.basename(entryName));
2121
+ if (item.isDirectory) {
2122
+ var children = _zip.getEntryChildren(item);
2123
+ children.forEach(function(child) {
2124
+ if (child.isDirectory)
2125
+ return;
2126
+ var content2 = child.getData();
2127
+ if (!content2) {
2128
+ throw Utils.Errors.CANT_EXTRACT_FILE();
2129
+ }
2130
+ var name = canonical(child.entryName);
2131
+ var childName = sanitize(targetPath, maintainEntryPath ? name : pth.basename(name));
2132
+ const fileAttr2 = keepOriginalPermission ? child.header.fileAttr : undefined;
2133
+ filetools.writeFileTo(childName, content2, overwrite, fileAttr2);
2134
+ });
2135
+ return true;
2136
+ }
2137
+ var content = item.getData(_zip.password);
2138
+ if (!content)
2139
+ throw Utils.Errors.CANT_EXTRACT_FILE();
2140
+ if (filetools.fs.existsSync(target) && !overwrite) {
2141
+ throw Utils.Errors.CANT_OVERRIDE();
2142
+ }
2143
+ const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
2144
+ filetools.writeFileTo(target, content, overwrite, fileAttr);
2145
+ return true;
2146
+ },
2147
+ test: function(pass) {
2148
+ if (!_zip) {
2149
+ return false;
2150
+ }
2151
+ for (var entry in _zip.entries) {
2152
+ try {
2153
+ if (entry.isDirectory) {
2154
+ continue;
2155
+ }
2156
+ var content = _zip.entries[entry].getData(pass);
2157
+ if (!content) {
2158
+ return false;
2159
+ }
2160
+ } catch (err) {
2161
+ return false;
2162
+ }
2163
+ }
2164
+ return true;
2165
+ },
2166
+ extractAllTo: function(targetPath, overwrite, keepOriginalPermission, pass) {
2167
+ keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2168
+ pass = get_Str(keepOriginalPermission, pass);
2169
+ overwrite = get_Bool(false, overwrite);
2170
+ if (!_zip)
2171
+ throw Utils.Errors.NO_ZIP();
2172
+ _zip.entries.forEach(function(entry) {
2173
+ var entryName = sanitize(targetPath, canonical(entry.entryName));
2174
+ if (entry.isDirectory) {
2175
+ filetools.makeDir(entryName);
2176
+ return;
2177
+ }
2178
+ var content = entry.getData(pass);
2179
+ if (!content) {
2180
+ throw Utils.Errors.CANT_EXTRACT_FILE();
2181
+ }
2182
+ const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
2183
+ filetools.writeFileTo(entryName, content, overwrite, fileAttr);
2184
+ try {
2185
+ filetools.fs.utimesSync(entryName, entry.header.time, entry.header.time);
2186
+ } catch (err) {
2187
+ throw Utils.Errors.CANT_EXTRACT_FILE();
2188
+ }
2189
+ });
2190
+ },
2191
+ extractAllToAsync: function(targetPath, overwrite, keepOriginalPermission, callback) {
2192
+ callback = get_Fun(overwrite, keepOriginalPermission, callback);
2193
+ keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2194
+ overwrite = get_Bool(false, overwrite);
2195
+ if (!callback) {
2196
+ return new Promise((resolve, reject) => {
2197
+ this.extractAllToAsync(targetPath, overwrite, keepOriginalPermission, function(err) {
2198
+ if (err) {
2199
+ reject(err);
2200
+ } else {
2201
+ resolve(this);
2202
+ }
2203
+ });
2204
+ });
2205
+ }
2206
+ if (!_zip) {
2207
+ callback(Utils.Errors.NO_ZIP());
2208
+ return;
2209
+ }
2210
+ targetPath = pth.resolve(targetPath);
2211
+ const getPath = (entry) => sanitize(targetPath, pth.normalize(canonical(entry.entryName)));
2212
+ const getError = (msg, file) => new Error(msg + ': "' + file + '"');
2213
+ const dirEntries = [];
2214
+ const fileEntries = [];
2215
+ _zip.entries.forEach((e) => {
2216
+ if (e.isDirectory) {
2217
+ dirEntries.push(e);
2218
+ } else {
2219
+ fileEntries.push(e);
2220
+ }
2221
+ });
2222
+ for (const entry of dirEntries) {
2223
+ const dirPath = getPath(entry);
2224
+ const dirAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
2225
+ try {
2226
+ filetools.makeDir(dirPath);
2227
+ if (dirAttr)
2228
+ filetools.fs.chmodSync(dirPath, dirAttr);
2229
+ filetools.fs.utimesSync(dirPath, entry.header.time, entry.header.time);
2230
+ } catch (er) {
2231
+ callback(getError("Unable to create folder", dirPath));
2232
+ }
2233
+ }
2234
+ fileEntries.reverse().reduce(function(next, entry) {
2235
+ return function(err) {
2236
+ if (err) {
2237
+ next(err);
2238
+ } else {
2239
+ const entryName = pth.normalize(canonical(entry.entryName));
2240
+ const filePath = sanitize(targetPath, entryName);
2241
+ entry.getDataAsync(function(content, err_1) {
2242
+ if (err_1) {
2243
+ next(err_1);
2244
+ } else if (!content) {
2245
+ next(Utils.Errors.CANT_EXTRACT_FILE());
2246
+ } else {
2247
+ const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
2248
+ filetools.writeFileToAsync(filePath, content, overwrite, fileAttr, function(succ) {
2249
+ if (!succ) {
2250
+ next(getError("Unable to write file", filePath));
2251
+ }
2252
+ filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function(err_2) {
2253
+ if (err_2) {
2254
+ next(getError("Unable to set times", filePath));
2255
+ } else {
2256
+ next();
2257
+ }
2258
+ });
2259
+ });
2260
+ }
2261
+ });
2262
+ }
2263
+ };
2264
+ }, callback)();
2265
+ },
2266
+ writeZip: function(targetFileName, callback) {
2267
+ if (arguments.length === 1) {
2268
+ if (typeof targetFileName === "function") {
2269
+ callback = targetFileName;
2270
+ targetFileName = "";
2271
+ }
2272
+ }
2273
+ if (!targetFileName && opts.filename) {
2274
+ targetFileName = opts.filename;
2275
+ }
2276
+ if (!targetFileName)
2277
+ return;
2278
+ var zipData = _zip.compressToBuffer();
2279
+ if (zipData) {
2280
+ var ok = filetools.writeFileTo(targetFileName, zipData, true);
2281
+ if (typeof callback === "function")
2282
+ callback(!ok ? new Error("failed") : null, "");
2283
+ }
2284
+ },
2285
+ writeZipPromise: function(targetFileName, props) {
2286
+ const { overwrite, perm } = Object.assign({ overwrite: true }, props);
2287
+ return new Promise((resolve, reject) => {
2288
+ if (!targetFileName && opts.filename)
2289
+ targetFileName = opts.filename;
2290
+ if (!targetFileName)
2291
+ reject("ADM-ZIP: ZIP File Name Missing");
2292
+ this.toBufferPromise().then((zipData) => {
2293
+ const ret = (done) => done ? resolve(done) : reject("ADM-ZIP: Wasn't able to write zip file");
2294
+ filetools.writeFileToAsync(targetFileName, zipData, overwrite, perm, ret);
2295
+ }, reject);
2296
+ });
2297
+ },
2298
+ toBufferPromise: function() {
2299
+ return new Promise((resolve, reject) => {
2300
+ _zip.toAsyncBuffer(resolve, reject);
2301
+ });
2302
+ },
2303
+ toBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
2304
+ if (typeof onSuccess === "function") {
2305
+ _zip.toAsyncBuffer(onSuccess, onFail, onItemStart, onItemEnd);
2306
+ return null;
2307
+ }
2308
+ return _zip.compressToBuffer();
2309
+ }
2310
+ };
2311
+ };
2312
+ });
2313
+
2314
+ // node_modules/cli-width/index.js
2315
+ var require_cli_width = __commonJS((exports, module) => {
2316
+ module.exports = cliWidth;
2317
+ function normalizeOpts(options) {
2318
+ const defaultOpts = {
2319
+ defaultWidth: 0,
2320
+ output: process.stdout,
2321
+ tty: __require("tty")
2322
+ };
2323
+ if (!options) {
2324
+ return defaultOpts;
2325
+ }
2326
+ Object.keys(defaultOpts).forEach(function(key) {
2327
+ if (!options[key]) {
2328
+ options[key] = defaultOpts[key];
2329
+ }
2330
+ });
2331
+ return options;
2332
+ }
2333
+ function cliWidth(options) {
2334
+ const opts = normalizeOpts(options);
2335
+ if (opts.output.getWindowSize) {
2336
+ return opts.output.getWindowSize()[0] || opts.defaultWidth;
2337
+ }
2338
+ if (opts.tty.getWindowSize) {
2339
+ return opts.tty.getWindowSize()[1] || opts.defaultWidth;
2340
+ }
2341
+ if (opts.output.columns) {
2342
+ return opts.output.columns;
2343
+ }
2344
+ if (process.env.CLI_WIDTH) {
2345
+ const width = parseInt(process.env.CLI_WIDTH, 10);
2346
+ if (!isNaN(width) && width !== 0) {
2347
+ return width;
2348
+ }
2349
+ }
2350
+ return opts.defaultWidth;
2351
+ }
2352
+ });
2353
+
2354
+ // node_modules/mute-stream/lib/index.js
2355
+ var require_lib = __commonJS((exports, module) => {
2356
+ var Stream = __require("stream");
2357
+
2358
+ class MuteStream extends Stream {
2359
+ #isTTY = null;
2360
+ constructor(opts = {}) {
2361
+ super(opts);
2362
+ this.writable = this.readable = true;
2363
+ this.muted = false;
2364
+ this.on("pipe", this._onpipe);
2365
+ this.replace = opts.replace;
2366
+ this._prompt = opts.prompt || null;
2367
+ this._hadControl = false;
2368
+ }
2369
+ #destSrc(key, def) {
2370
+ if (this._dest) {
2371
+ return this._dest[key];
2372
+ }
2373
+ if (this._src) {
2374
+ return this._src[key];
2375
+ }
2376
+ return def;
2377
+ }
2378
+ #proxy(method, ...args) {
2379
+ if (typeof this._dest?.[method] === "function") {
2380
+ this._dest[method](...args);
2381
+ }
2382
+ if (typeof this._src?.[method] === "function") {
2383
+ this._src[method](...args);
2384
+ }
2385
+ }
2386
+ get isTTY() {
2387
+ if (this.#isTTY !== null) {
2388
+ return this.#isTTY;
2389
+ }
2390
+ return this.#destSrc("isTTY", false);
2391
+ }
2392
+ set isTTY(val) {
2393
+ this.#isTTY = val;
2394
+ }
2395
+ get rows() {
2396
+ return this.#destSrc("rows");
2397
+ }
2398
+ get columns() {
2399
+ return this.#destSrc("columns");
2400
+ }
2401
+ mute() {
2402
+ this.muted = true;
2403
+ }
2404
+ unmute() {
2405
+ this.muted = false;
2406
+ }
2407
+ _onpipe(src) {
2408
+ this._src = src;
2409
+ }
2410
+ pipe(dest, options) {
2411
+ this._dest = dest;
2412
+ return super.pipe(dest, options);
2413
+ }
2414
+ pause() {
2415
+ if (this._src) {
2416
+ return this._src.pause();
2417
+ }
2418
+ }
2419
+ resume() {
2420
+ if (this._src) {
2421
+ return this._src.resume();
2422
+ }
2423
+ }
2424
+ write(c) {
2425
+ if (this.muted) {
2426
+ if (!this.replace) {
2427
+ return true;
2428
+ }
2429
+ if (c.match(/^\u001b/)) {
2430
+ if (c.indexOf(this._prompt) === 0) {
2431
+ c = c.slice(this._prompt.length);
2432
+ c = c.replace(/./g, this.replace);
2433
+ c = this._prompt + c;
2434
+ }
2435
+ this._hadControl = true;
2436
+ return this.emit("data", c);
2437
+ } else {
2438
+ if (this._prompt && this._hadControl && c.indexOf(this._prompt) === 0) {
2439
+ this._hadControl = false;
2440
+ this.emit("data", this._prompt);
2441
+ c = c.slice(this._prompt.length);
2442
+ }
2443
+ c = c.toString().replace(/./g, this.replace);
2444
+ }
2445
+ }
2446
+ this.emit("data", c);
2447
+ }
2448
+ end(c) {
2449
+ if (this.muted) {
2450
+ if (c && this.replace) {
2451
+ c = c.toString().replace(/./g, this.replace);
2452
+ } else {
2453
+ c = null;
2454
+ }
2455
+ }
2456
+ if (c) {
2457
+ this.emit("data", c);
2458
+ }
2459
+ this.emit("end");
2460
+ }
2461
+ destroy(...args) {
2462
+ return this.#proxy("destroy", ...args);
2463
+ }
2464
+ destroySoon(...args) {
2465
+ return this.#proxy("destroySoon", ...args);
2466
+ }
2467
+ close(...args) {
2468
+ return this.#proxy("close", ...args);
2469
+ }
2470
+ }
2471
+ module.exports = MuteStream;
2472
+ });
2473
+
2474
+ // src/platform/detector.ts
2475
+ import os from "node:os";
2476
+ function detectPlatform() {
2477
+ const platform = process.platform;
2478
+ const arch = process.arch;
2479
+ const detectedOS = platform === "win32" ? "windows" : platform === "darwin" ? "macos" : "linux";
2480
+ const detectedArch = arch === "arm64" ? "arm64" : "x86_64";
2481
+ return {
2482
+ os: detectedOS,
2483
+ arch: detectedArch,
2484
+ gcloudDownloadUrl: getGcloudDownloadUrl(detectedOS, detectedArch),
2485
+ gcloudBinaryName: platform === "win32" ? "gcloud.cmd" : "gcloud",
2486
+ isWindows: platform === "win32"
2487
+ };
2488
+ }
2489
+ function getGcloudDownloadUrl(os2, arch) {
2490
+ const baseUrl = "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads";
2491
+ if (os2 === "macos") {
2492
+ if (arch === "arm64") {
2493
+ return `${baseUrl}/google-cloud-cli-darwin-arm.tar.gz`;
2494
+ }
2495
+ return `${baseUrl}/google-cloud-cli-darwin-x86_64.tar.gz`;
2496
+ }
2497
+ if (os2 === "linux") {
2498
+ return `${baseUrl}/google-cloud-cli-linux-x86_64.tar.gz`;
2499
+ }
2500
+ if (os2 === "windows") {
2501
+ return `${baseUrl}/google-cloud-cli-windows-x86_64-bundled-python.zip`;
2502
+ }
2503
+ throw new Error(`Unsupported platform: ${os2} ${arch}`);
2504
+ }
2505
+ function getHomeDir() {
2506
+ return os.homedir();
2507
+ }
2508
+ function getStitchDir() {
2509
+ return `${getHomeDir()}/.stitch-mcp`;
2510
+ }
2511
+ function getGcloudSdkPath() {
2512
+ return `${getStitchDir()}/google-cloud-sdk`;
2513
+ }
2514
+ function getGcloudConfigPath() {
2515
+ return `${getStitchDir()}/config`;
2516
+ }
2517
+
2518
+ // src/platform/shell.ts
2519
+ import * as childProcess from "node:child_process";
2520
+ function getSpawnArgs(command, args) {
2521
+ if (process.platform === "win32") {
2522
+ return {
2523
+ cmd: "cmd.exe",
2524
+ args: ["/d", "/s", "/c", command, ...args]
2525
+ };
2526
+ }
2527
+ return { cmd: command, args };
2528
+ }
2529
+ async function execCommand(command, options) {
2530
+ const cmd = command[0];
2531
+ if (!cmd)
2532
+ throw new Error("Command cannot be empty");
2533
+ const args = command.slice(1);
2534
+ return new Promise((resolve) => {
2535
+ const stdoutChunks = [];
2536
+ const stderrChunks = [];
2537
+ const spawnOptions = {
2538
+ cwd: options?.cwd || process.cwd(),
2539
+ env: { ...process.env, ...options?.env || {} },
2540
+ stdio: "pipe",
2541
+ timeout: options?.timeout,
2542
+ shell: false
2543
+ };
2544
+ const { cmd: spawnCmd, args: spawnArgs } = getSpawnArgs(cmd, args);
2545
+ const child = childProcess.spawn(spawnCmd, spawnArgs, spawnOptions);
2546
+ if (child.stdout) {
2547
+ child.stdout.on("data", (data) => {
2548
+ stdoutChunks.push(data);
2549
+ });
2550
+ }
2551
+ if (child.stderr) {
2552
+ child.stderr.on("data", (data) => {
2553
+ stderrChunks.push(data);
2554
+ });
2555
+ }
2556
+ child.on("error", (err) => {
2557
+ resolve({
2558
+ success: false,
2559
+ stdout: Buffer.concat(stdoutChunks).toString(),
2560
+ stderr: Buffer.concat(stderrChunks).toString(),
2561
+ exitCode: 1,
2562
+ error: err.message
2563
+ });
2564
+ });
2565
+ child.on("close", (code) => {
2566
+ resolve({
2567
+ success: code === 0,
2568
+ stdout: Buffer.concat(stdoutChunks).toString(),
2569
+ stderr: Buffer.concat(stderrChunks).toString(),
2570
+ exitCode: code ?? 1
2571
+ });
2572
+ });
2573
+ });
2574
+ }
2575
+ async function commandExists(command) {
2576
+ const result = await execCommand(process.platform === "win32" ? ["where", command] : ["which", command]);
2577
+ return result.success;
2578
+ }
2579
+
2580
+ // src/platform/paths.ts
2581
+ import path from "node:path";
2582
+ function joinPath(...parts) {
2583
+ return path.join(...parts);
2584
+ }
2585
+
2586
+ // src/services/gcloud/core.ts
2587
+ import fs from "node:fs";
2588
+
2589
+ class GcloudExecutor {
2590
+ platform = detectPlatform();
2591
+ gcloudPath = null;
2592
+ useSystemGcloud = false;
2593
+ constructor() {}
2594
+ setGcloudPath(path2, isSystem) {
2595
+ this.gcloudPath = path2;
2596
+ this.useSystemGcloud = isSystem;
2597
+ this.setupEnvironment();
2598
+ }
2599
+ getGcloudPath() {
2600
+ return this.gcloudPath;
2601
+ }
2602
+ isSystemGcloud() {
2603
+ return this.useSystemGcloud;
2604
+ }
2605
+ setupEnvironment() {
2606
+ if (this.gcloudPath && !this.useSystemGcloud && !process.env.STITCH_USE_SYSTEM_GCLOUD) {
2607
+ const sdkPath = getGcloudSdkPath();
2608
+ const binPath = joinPath(sdkPath, "bin");
2609
+ process.env.PATH = `${binPath}:${process.env.PATH}`;
2610
+ const configPath = getGcloudConfigPath();
2611
+ process.env.CLOUDSDK_CONFIG = configPath;
2612
+ process.env.CLOUDSDK_CORE_DISABLE_PROMPTS = "1";
2613
+ process.env.CLOUDSDK_COMPONENT_MANAGER_DISABLE_UPDATE_CHECK = "1";
2614
+ process.env.CLOUDSDK_CORE_DISABLE_USAGE_REPORTING = "true";
2615
+ }
2616
+ }
2617
+ getEnvironment(useSystem) {
2618
+ if (useSystem || this.useSystemGcloud || process.env.STITCH_USE_SYSTEM_GCLOUD) {
2619
+ return {};
2620
+ }
2621
+ const configPath = getGcloudConfigPath();
2622
+ return {
2623
+ CLOUDSDK_CONFIG: configPath,
2624
+ CLOUDSDK_CORE_DISABLE_PROMPTS: "1",
2625
+ CLOUDSDK_COMPONENT_MANAGER_DISABLE_UPDATE_CHECK: "1",
2626
+ CLOUDSDK_CORE_DISABLE_USAGE_REPORTING: "true"
2627
+ };
2628
+ }
2629
+ async getGcloudCommand() {
2630
+ if (this.gcloudPath) {
2631
+ return this.gcloudPath;
2632
+ }
2633
+ if (this.useSystemGcloud || process.env.STITCH_USE_SYSTEM_GCLOUD) {
2634
+ return this.platform.gcloudBinaryName;
2635
+ }
2636
+ const sdkPath = getGcloudSdkPath();
2637
+ const localBinaryPath = joinPath(sdkPath, "bin", this.platform.gcloudBinaryName);
2638
+ try {
2639
+ await fs.promises.access(localBinaryPath, fs.constants.F_OK);
2640
+ this.gcloudPath = localBinaryPath;
2641
+ this.setupEnvironment();
2642
+ return localBinaryPath;
2643
+ } catch {
2644
+ return this.platform.gcloudBinaryName;
2645
+ }
2646
+ }
2647
+ async exec(args, options) {
2648
+ const cmd = await this.getGcloudCommand();
2649
+ const env = { ...this.getEnvironment(), ...options?.env || {} };
2650
+ return execCommand([cmd, ...args], { ...options, env });
2651
+ }
2652
+ async execRaw(command, options) {
2653
+ const env = { ...this.getEnvironment(), ...options?.env || {} };
2654
+ return execCommand(command, { ...options, env });
2655
+ }
2656
+ }
2657
+
2658
+ // src/services/gcloud/install.ts
2659
+ var import_adm_zip = __toESM(require_adm_zip(), 1);
2660
+ import fs2 from "node:fs";
2661
+ class GcloudInstallService {
2662
+ executor;
2663
+ constructor(executor) {
2664
+ this.executor = executor;
2665
+ }
2666
+ async ensureInstalled(input) {
2667
+ if (!input.forceLocal) {
2668
+ const globalPath = await this.findGlobalGcloud();
2669
+ if (globalPath) {
2670
+ const version2 = await this.getVersionFromPath(globalPath);
2671
+ if (version2 && this.isVersionValid(version2, input.minVersion)) {
2672
+ this.executor.setGcloudPath(globalPath, true);
2673
+ return {
2674
+ success: true,
2675
+ data: {
2676
+ version: version2,
2677
+ location: "system",
2678
+ path: globalPath
2679
+ }
2680
+ };
2681
+ }
2682
+ }
2683
+ }
2684
+ const localSdkPath = getGcloudSdkPath();
2685
+ const localBinaryPath = joinPath(localSdkPath, "bin", this.executor.platform.gcloudBinaryName);
2686
+ let localExists = false;
2687
+ try {
2688
+ await fs2.promises.access(localBinaryPath, fs2.constants.F_OK);
2689
+ localExists = true;
2690
+ } catch {}
2691
+ if (localExists) {
2692
+ const version2 = await this.getVersionFromPath(localBinaryPath);
2693
+ if (version2) {
2694
+ this.executor.setGcloudPath(localBinaryPath, false);
2695
+ return {
2696
+ success: true,
2697
+ data: {
2698
+ version: version2,
2699
+ location: "bundled",
2700
+ path: localBinaryPath
2701
+ }
2702
+ };
2703
+ }
2704
+ }
2705
+ if (!input.forceLocal) {
2706
+ const globalPath = await this.findGlobalGcloud();
2707
+ if (globalPath) {
2708
+ const version2 = await this.getVersionFromPath(globalPath);
2709
+ if (version2 && this.isVersionValid(version2, input.minVersion)) {
2710
+ this.executor.setGcloudPath(globalPath, true);
2711
+ return {
2712
+ success: true,
2713
+ data: {
2714
+ version: version2,
2715
+ location: "system",
2716
+ path: globalPath
2717
+ }
2718
+ };
2719
+ }
2720
+ }
2721
+ }
2722
+ const localPath2 = await this.installLocal();
2723
+ if (!localPath2) {
2724
+ return {
2725
+ success: false,
2726
+ error: {
2727
+ code: "DOWNLOAD_FAILED",
2728
+ message: "Failed to install gcloud locally",
2729
+ suggestion: "Check your internet connection and try again",
2730
+ recoverable: true
2731
+ }
2732
+ };
2733
+ }
2734
+ const version = await this.getVersionFromPath(localPath2);
2735
+ if (!version) {
2736
+ return {
2737
+ success: false,
2738
+ error: {
2739
+ code: "VERSION_CHECK_FAILED",
2740
+ message: "Could not determine gcloud version",
2741
+ recoverable: false
2742
+ }
2743
+ };
2744
+ }
2745
+ this.executor.setGcloudPath(localPath2, false);
2746
+ return {
2747
+ success: true,
2748
+ data: {
2749
+ version,
2750
+ location: "bundled",
2751
+ path: localPath2
2752
+ }
2753
+ };
2754
+ }
2755
+ async installBetaComponents() {
2756
+ try {
2757
+ const result = await this.executor.exec(["components", "install", "beta", "--quiet"]);
2758
+ if (!result.success) {
2759
+ return {
2760
+ success: false,
2761
+ error: {
2762
+ message: `Failed to install beta components: ${result.stderr || result.error || "Unknown error"}`
2763
+ }
2764
+ };
2765
+ }
2766
+ return { success: true };
2767
+ } catch (error) {
2768
+ return {
2769
+ success: false,
2770
+ error: {
2771
+ message: error instanceof Error ? error.message : String(error)
2772
+ }
2773
+ };
2774
+ }
2775
+ }
2776
+ async findGlobalGcloud() {
2777
+ const exists = await commandExists(this.executor.platform.gcloudBinaryName);
2778
+ if (!exists) {
2779
+ return null;
2780
+ }
2781
+ const result = await execCommand(this.executor.platform.isWindows ? ["where", this.executor.platform.gcloudBinaryName] : ["which", this.executor.platform.gcloudBinaryName]);
2782
+ if (result.success) {
2783
+ return result.stdout.trim().split(`
2784
+ `)[0] || null;
2785
+ }
2786
+ return null;
2787
+ }
2788
+ async getVersionFromPath(gcloudPath) {
2789
+ const result = await execCommand([gcloudPath, "version", "--format=json"]);
2790
+ if (result.success) {
2791
+ try {
2792
+ const versionData = JSON.parse(result.stdout);
2793
+ return versionData["Google Cloud SDK"] || null;
2794
+ } catch {
2795
+ const match = result.stdout.match(/Google Cloud SDK ([\d.]+)/);
2796
+ return match?.[1] || null;
2797
+ }
2798
+ }
2799
+ return null;
2800
+ }
2801
+ isVersionValid(current, minimum) {
2802
+ const currentParts = current.split(".").map(Number);
2803
+ const minimumParts = minimum.split(".").map(Number);
2804
+ for (let i = 0;i < Math.max(currentParts.length, minimumParts.length); i++) {
2805
+ const cur = currentParts[i] || 0;
2806
+ const min = minimumParts[i] || 0;
2807
+ if (cur > min)
2808
+ return true;
2809
+ if (cur < min)
2810
+ return false;
2811
+ }
2812
+ return true;
2813
+ }
2814
+ async installLocal() {
2815
+ const sdkPath = getGcloudSdkPath();
2816
+ const stitchDir = getStitchDir();
2817
+ await fs2.promises.mkdir(stitchDir, { recursive: true });
2818
+ const downloadUrl = this.executor.platform.gcloudDownloadUrl;
2819
+ const downloadPath = joinPath(stitchDir, this.executor.platform.isWindows ? "gcloud.zip" : "gcloud.tar.gz");
2820
+ try {
2821
+ const response = await fetch(downloadUrl);
2822
+ if (!response.ok) {
2823
+ return null;
2824
+ }
2825
+ const buffer = await response.arrayBuffer();
2826
+ await fs2.promises.writeFile(downloadPath, Buffer.from(buffer));
2827
+ if (this.executor.platform.isWindows) {
2828
+ const zip = new import_adm_zip.default(downloadPath);
2829
+ await new Promise((resolve, reject) => {
2830
+ zip.extractAllToAsync(stitchDir, true, false, (err) => {
2831
+ if (err) {
2832
+ reject(err);
2833
+ } else {
2834
+ resolve();
2835
+ }
2836
+ });
2837
+ });
2838
+ } else {
2839
+ await execCommand(["tar", "-xzf", downloadPath, "-C", stitchDir]);
2840
+ }
2841
+ await fs2.promises.unlink(downloadPath);
2842
+ return joinPath(sdkPath, "bin", this.executor.platform.gcloudBinaryName);
2843
+ } catch {
2844
+ return null;
2845
+ }
2846
+ }
2847
+ }
2848
+
2849
+ // src/services/gcloud/auth.ts
2850
+ import fs3 from "node:fs";
2851
+ class GcloudAuthService {
2852
+ executor;
2853
+ constructor(executor) {
2854
+ this.executor = executor;
2855
+ }
2856
+ async authenticate(input) {
2857
+ try {
2858
+ if (input.skipIfActive) {
2859
+ const activeAccount = await this.getActiveAccount();
2860
+ if (activeAccount) {
2861
+ return {
2862
+ success: true,
2863
+ data: {
2864
+ account: activeAccount,
2865
+ type: "user"
2866
+ }
2867
+ };
2868
+ }
2869
+ }
2870
+ const result = await this.runAuthFlow(["auth", "login"]);
2871
+ if (!result.success) {
2872
+ return {
2873
+ success: false,
2874
+ error: {
2875
+ code: "AUTH_FAILED",
2876
+ message: "Failed to authenticate with gcloud",
2877
+ suggestion: "Complete the browser authentication flow",
2878
+ recoverable: true
2879
+ }
2880
+ };
2881
+ }
2882
+ const account = await this.getActiveAccount();
2883
+ if (!account) {
2884
+ return {
2885
+ success: false,
2886
+ error: {
2887
+ code: "AUTH_FAILED",
2888
+ message: "Authentication appeared to succeed but no active account found",
2889
+ recoverable: false
2890
+ }
2891
+ };
2892
+ }
2893
+ return {
2894
+ success: true,
2895
+ data: {
2896
+ account,
2897
+ type: "user"
2898
+ }
2899
+ };
2900
+ } catch (error) {
2901
+ return {
2902
+ success: false,
2903
+ error: {
2904
+ code: "AUTH_FAILED",
2905
+ message: error instanceof Error ? error.message : String(error),
2906
+ recoverable: false
2907
+ }
2908
+ };
2909
+ }
2910
+ }
2911
+ async authenticateADC(input) {
2912
+ try {
2913
+ if (input.skipIfActive) {
2914
+ const hasADC = await this.hasADC();
2915
+ if (hasADC) {
2916
+ const account2 = await this.getActiveAccount();
2917
+ return {
2918
+ success: true,
2919
+ data: {
2920
+ account: account2 || "unknown",
2921
+ type: "adc"
2922
+ }
2923
+ };
2924
+ }
2925
+ }
2926
+ const result = await this.runAuthFlow(["auth", "application-default", "login"]);
2927
+ if (!result.success) {
2928
+ return {
2929
+ success: false,
2930
+ error: {
2931
+ code: "ADC_FAILED",
2932
+ message: "Failed to authenticate application default credentials",
2933
+ suggestion: "Complete the browser authentication flow",
2934
+ recoverable: true
2935
+ }
2936
+ };
2937
+ }
2938
+ const account = await this.getActiveAccount();
2939
+ return {
2940
+ success: true,
2941
+ data: {
2942
+ account: account || "unknown",
2943
+ type: "adc"
2944
+ }
2945
+ };
2946
+ } catch (error) {
2947
+ return {
2948
+ success: false,
2949
+ error: {
2950
+ code: "ADC_FAILED",
2951
+ message: error instanceof Error ? error.message : String(error),
2952
+ recoverable: false
2953
+ }
2954
+ };
2955
+ }
2956
+ }
2957
+ async getAccessToken() {
2958
+ try {
2959
+ const result = await this.executor.exec(["auth", "application-default", "print-access-token"]);
2960
+ if (result.success) {
2961
+ return result.stdout.trim();
2962
+ }
2963
+ const loginCmd = await this.getLoginCommand();
2964
+ console.error(`[Gcloud] Token fetch failed. Please run:
2965
+
2966
+ ${loginCmd}
2967
+
2968
+ to obtain new credentials.`);
2969
+ return null;
2970
+ } catch (e) {
2971
+ console.error("[Gcloud] Token fetch exception:", e);
2972
+ return null;
2973
+ }
2974
+ }
2975
+ async getActiveAccount() {
2976
+ const result = await this.executor.exec(["auth", "list", "--filter=status:ACTIVE", "--format=value(account)"]);
2977
+ if (result.success && result.stdout.trim()) {
2978
+ return result.stdout.trim().split(`
2979
+ `)[0] || null;
2980
+ }
2981
+ return null;
2982
+ }
2983
+ async hasADC() {
2984
+ let fileExists = false;
2985
+ if (!this.executor.isSystemGcloud() && !process.env.STITCH_USE_SYSTEM_GCLOUD) {
2986
+ const stitchConfigPath = getGcloudConfigPath();
2987
+ const stitchAdcPath = joinPath(stitchConfigPath, "application_default_credentials.json");
2988
+ try {
2989
+ await fs3.promises.access(stitchAdcPath, fs3.constants.F_OK);
2990
+ fileExists = true;
2991
+ } catch {
2992
+ fileExists = false;
2993
+ }
2994
+ } else {
2995
+ try {
2996
+ const result = await this.executor.exec(["info", "--format=value(config.paths.global_config_dir)"]);
2997
+ if (result.success && result.stdout.trim()) {
2998
+ const configDir = result.stdout.trim();
2999
+ const adcPath = joinPath(configDir, "application_default_credentials.json");
3000
+ try {
3001
+ await fs3.promises.access(adcPath, fs3.constants.F_OK);
3002
+ fileExists = true;
3003
+ } catch {
3004
+ fileExists = false;
3005
+ }
3006
+ }
3007
+ } catch {}
3008
+ }
3009
+ if (!fileExists) {
3010
+ return false;
3011
+ }
3012
+ try {
3013
+ const result = await this.executor.exec(["auth", "application-default", "print-access-token"]);
3014
+ return result.success && !!result.stdout.trim();
3015
+ } catch {
3016
+ return false;
3017
+ }
3018
+ }
3019
+ async runAuthFlow(authArgs) {
3020
+ console.log(theme.gray(" Opening browser for authentication..."));
3021
+ const noBrowserResult = await this.executor.exec([...authArgs, "--no-launch-browser"], { timeout: 5000 });
3022
+ const outputText = noBrowserResult.stderr || noBrowserResult.stdout || "";
3023
+ const urlMatch = outputText.match(/https:\/\/accounts\.google\.com[^\s]+/);
3024
+ if (urlMatch) {
3025
+ console.log(theme.gray(` If it doesn't open automatically, visit this URL: ${theme.cyan(urlMatch[0])}
3026
+ `));
3027
+ } else {
3028
+ console.log(theme.gray(` Note: Could not extract authentication URL from gcloud output
3029
+ `));
3030
+ }
3031
+ return this.executor.exec([...authArgs, "--quiet"]);
3032
+ }
3033
+ async getLoginCommand() {
3034
+ const gcloudCmd = await this.executor.getGcloudCommand();
3035
+ if (this.executor.isSystemGcloud() || process.env.STITCH_USE_SYSTEM_GCLOUD) {
3036
+ return `${gcloudCmd} auth application-default login`;
3037
+ }
3038
+ const configPath = getGcloudConfigPath();
3039
+ return `CLOUDSDK_CONFIG="${configPath}" ${gcloudCmd} auth application-default login`;
3040
+ }
3041
+ }
3042
+
3043
+ // src/services/gcloud/spec.ts
3044
+ var PROJECT_ID_REGEX = /^[a-z][a-z0-9-]{4,28}[a-z0-9]$/;
3045
+ var EnsureGcloudInputSchema = exports_external.object({
3046
+ minVersion: exports_external.string().default("400.0.0"),
3047
+ forceLocal: exports_external.boolean().default(false),
3048
+ useSystemGcloud: exports_external.boolean().default(false).optional()
3049
+ });
3050
+ var AuthenticateInputSchema = exports_external.object({
3051
+ skipIfActive: exports_external.boolean().default(true)
3052
+ });
3053
+ var ListProjectsInputSchema = exports_external.object({
3054
+ limit: exports_external.number().optional(),
3055
+ filter: exports_external.string().optional(),
3056
+ sortBy: exports_external.string().optional()
3057
+ });
3058
+ var SetProjectInputSchema = exports_external.object({
3059
+ projectId: exports_external.string().regex(PROJECT_ID_REGEX, {
3060
+ message: "Invalid project ID format. Project IDs must be 6-30 characters, start with a letter, end with a letter or number, and contain only lowercase letters, numbers, and hyphens."
3061
+ })
3062
+ });
3063
+ var GcloudErrorCode = exports_external.enum([
3064
+ "DOWNLOAD_FAILED",
3065
+ "EXTRACTION_FAILED",
3066
+ "VERSION_CHECK_FAILED",
3067
+ "INVALID_VERSION",
3068
+ "AUTH_FAILED",
3069
+ "ADC_FAILED",
3070
+ "PROJECT_LIST_FAILED",
3071
+ "PROJECT_SET_FAILED",
3072
+ "COMMAND_NOT_FOUND",
3073
+ "UNKNOWN_ERROR"
3074
+ ]);
3075
+ var GcloudInstallDataSchema = exports_external.object({
3076
+ version: exports_external.string(),
3077
+ location: exports_external.enum(["system", "bundled"]),
3078
+ path: exports_external.string()
3079
+ });
3080
+ var GcloudSuccess = exports_external.object({
3081
+ success: exports_external.literal(true),
3082
+ data: GcloudInstallDataSchema
3083
+ });
3084
+ var GcloudFailure = exports_external.object({
3085
+ success: exports_external.literal(false),
3086
+ error: exports_external.object({
3087
+ code: GcloudErrorCode,
3088
+ message: exports_external.string(),
3089
+ suggestion: exports_external.string().optional(),
3090
+ recoverable: exports_external.boolean()
3091
+ })
3092
+ });
3093
+ var AuthDataSchema = exports_external.object({
3094
+ account: exports_external.string(),
3095
+ type: exports_external.enum(["user", "adc"])
3096
+ });
3097
+ var AuthSuccess = exports_external.object({
3098
+ success: exports_external.literal(true),
3099
+ data: AuthDataSchema
3100
+ });
3101
+ var AuthFailure = exports_external.object({
3102
+ success: exports_external.literal(false),
3103
+ error: exports_external.object({
3104
+ code: GcloudErrorCode,
3105
+ message: exports_external.string(),
3106
+ suggestion: exports_external.string().optional(),
3107
+ recoverable: exports_external.boolean()
3108
+ })
3109
+ });
3110
+ var ProjectSchema = exports_external.object({
3111
+ projectId: exports_external.string(),
3112
+ name: exports_external.string(),
3113
+ projectNumber: exports_external.string().optional(),
3114
+ createTime: exports_external.string().optional()
3115
+ });
3116
+ var ProjectListSuccess = exports_external.object({
3117
+ success: exports_external.literal(true),
3118
+ data: exports_external.object({
3119
+ projects: exports_external.array(ProjectSchema)
3120
+ })
3121
+ });
3122
+ var ProjectListFailure = exports_external.object({
3123
+ success: exports_external.literal(false),
3124
+ error: exports_external.object({
3125
+ code: GcloudErrorCode,
3126
+ message: exports_external.string(),
3127
+ suggestion: exports_external.string().optional(),
3128
+ recoverable: exports_external.boolean()
3129
+ })
3130
+ });
3131
+ var ProjectSetSuccess = exports_external.object({
3132
+ success: exports_external.literal(true),
3133
+ data: exports_external.object({
3134
+ projectId: exports_external.string()
3135
+ })
3136
+ });
3137
+ var ProjectSetFailure = exports_external.object({
3138
+ success: exports_external.literal(false),
3139
+ error: exports_external.object({
3140
+ code: GcloudErrorCode,
3141
+ message: exports_external.string(),
3142
+ suggestion: exports_external.string().optional(),
3143
+ recoverable: exports_external.boolean()
3144
+ })
3145
+ });
3146
+
3147
+ // src/services/gcloud/projects.ts
3148
+ class GcloudProjectService {
3149
+ executor;
3150
+ constructor(executor) {
3151
+ this.executor = executor;
3152
+ }
3153
+ async listProjects(input) {
3154
+ try {
3155
+ const args = ["projects", "list", "--format=json"];
3156
+ if (input.limit) {
3157
+ args.push(`--limit=${input.limit}`);
3158
+ }
3159
+ if (input.filter) {
3160
+ args.push(`--filter=${input.filter}`);
3161
+ }
3162
+ if (input.sortBy) {
3163
+ args.push(`--sort-by=${input.sortBy}`);
3164
+ }
3165
+ const result = await this.executor.exec(args);
3166
+ if (!result.success) {
3167
+ return {
3168
+ success: false,
3169
+ error: {
3170
+ code: "PROJECT_LIST_FAILED",
3171
+ message: `Failed to list projects: ${result.stderr}`,
3172
+ suggestion: "Ensure you are authenticated and have access to projects",
3173
+ recoverable: true
3174
+ }
3175
+ };
3176
+ }
3177
+ const projects = JSON.parse(result.stdout);
3178
+ return {
3179
+ success: true,
3180
+ data: {
3181
+ projects: projects.map((p) => ({
3182
+ projectId: p.projectId,
3183
+ name: p.name,
3184
+ projectNumber: p.projectNumber,
3185
+ createTime: p.createTime
3186
+ }))
3187
+ }
3188
+ };
3189
+ } catch (error) {
3190
+ return {
3191
+ success: false,
3192
+ error: {
3193
+ code: "PROJECT_LIST_FAILED",
3194
+ message: error instanceof Error ? error.message : String(error),
3195
+ recoverable: false
3196
+ }
3197
+ };
3198
+ }
3199
+ }
3200
+ async setProject(input) {
3201
+ if (!PROJECT_ID_REGEX.test(input.projectId)) {
3202
+ return {
3203
+ success: false,
3204
+ error: {
3205
+ code: "PROJECT_SET_FAILED",
3206
+ message: `Invalid project ID: ${input.projectId}. Project IDs must be 6-30 characters, start with a letter, and contain only lowercase letters, numbers, and hyphens.`,
3207
+ suggestion: "Verify the project ID is correct",
3208
+ recoverable: false
3209
+ }
3210
+ };
3211
+ }
3212
+ try {
3213
+ const result = await this.executor.exec(["config", "set", "project", input.projectId, "--quiet"]);
3214
+ if (!result.success) {
3215
+ return {
3216
+ success: false,
3217
+ error: {
3218
+ code: "PROJECT_SET_FAILED",
3219
+ message: `Failed to set project: ${input.projectId}`,
3220
+ suggestion: "Verify the project ID is correct",
3221
+ recoverable: true
3222
+ }
3223
+ };
3224
+ }
3225
+ return {
3226
+ success: true,
3227
+ data: {
3228
+ projectId: input.projectId
3229
+ }
3230
+ };
3231
+ } catch (error) {
3232
+ return {
3233
+ success: false,
3234
+ error: {
3235
+ code: "PROJECT_SET_FAILED",
3236
+ message: error instanceof Error ? error.message : String(error),
3237
+ recoverable: false
3238
+ }
3239
+ };
3240
+ }
3241
+ }
3242
+ async getProjectId() {
3243
+ if (process.env.STITCH_PROJECT_ID) {
3244
+ return process.env.STITCH_PROJECT_ID;
3245
+ }
3246
+ if (process.env.GOOGLE_CLOUD_PROJECT) {
3247
+ return process.env.GOOGLE_CLOUD_PROJECT;
3248
+ }
3249
+ try {
3250
+ const result = await this.executor.exec(["config", "get-value", "project"]);
3251
+ if (result.success && result.stdout.trim()) {
3252
+ return result.stdout.trim();
3253
+ }
3254
+ return null;
3255
+ } catch (e) {
3256
+ return null;
3257
+ }
3258
+ }
3259
+ }
3260
+
3261
+ // src/services/gcloud/handler.ts
3262
+ class GcloudHandler {
3263
+ executor;
3264
+ installService;
3265
+ authService;
3266
+ projectService;
3267
+ constructor() {
3268
+ this.executor = new GcloudExecutor;
3269
+ this.installService = new GcloudInstallService(this.executor);
3270
+ this.authService = new GcloudAuthService(this.executor);
3271
+ this.projectService = new GcloudProjectService(this.executor);
3272
+ }
3273
+ async ensureInstalled(input) {
3274
+ return this.installService.ensureInstalled(input);
3275
+ }
3276
+ async authenticate(input) {
3277
+ return this.authService.authenticate(input);
3278
+ }
3279
+ async authenticateADC(input) {
3280
+ return this.authService.authenticateADC(input);
3281
+ }
3282
+ async listProjects(input) {
3283
+ return this.projectService.listProjects(input);
3284
+ }
3285
+ async setProject(input) {
3286
+ return this.projectService.setProject(input);
3287
+ }
3288
+ async getAccessToken() {
3289
+ return this.authService.getAccessToken();
3290
+ }
3291
+ async getProjectId() {
3292
+ return this.projectService.getProjectId();
3293
+ }
3294
+ async installBetaComponents() {
3295
+ return this.installService.installBetaComponents();
3296
+ }
3297
+ async getActiveAccount() {
3298
+ return this.authService.getActiveAccount();
3299
+ }
3300
+ async hasADC() {
3301
+ return this.authService.hasADC();
3302
+ }
3303
+ }
3304
+
3305
+ // node_modules/@inquirer/core/dist/lib/key.js
3306
+ var isUpKey = (key, keybindings = []) => key.name === "up" || keybindings.includes("vim") && key.name === "k" || keybindings.includes("emacs") && key.ctrl && key.name === "p";
3307
+ var isDownKey = (key, keybindings = []) => key.name === "down" || keybindings.includes("vim") && key.name === "j" || keybindings.includes("emacs") && key.ctrl && key.name === "n";
3308
+ var isBackspaceKey = (key) => key.name === "backspace";
3309
+ var isTabKey = (key) => key.name === "tab";
3310
+ var isNumberKey = (key) => "1234567890".includes(key.name);
3311
+ var isEnterKey = (key) => key.name === "enter" || key.name === "return";
3312
+ // node_modules/@inquirer/core/dist/lib/errors.js
3313
+ class AbortPromptError extends Error {
3314
+ name = "AbortPromptError";
3315
+ message = "Prompt was aborted";
3316
+ constructor(options) {
3317
+ super();
3318
+ this.cause = options?.cause;
3319
+ }
3320
+ }
3321
+
3322
+ class CancelPromptError extends Error {
3323
+ name = "CancelPromptError";
3324
+ message = "Prompt was canceled";
3325
+ }
3326
+
3327
+ class ExitPromptError extends Error {
3328
+ name = "ExitPromptError";
3329
+ }
3330
+
3331
+ class HookError extends Error {
3332
+ name = "HookError";
3333
+ }
3334
+
3335
+ class ValidationError extends Error {
3336
+ name = "ValidationError";
3337
+ }
3338
+ // node_modules/@inquirer/core/dist/lib/use-state.js
3339
+ import { AsyncResource as AsyncResource2 } from "node:async_hooks";
3340
+
3341
+ // node_modules/@inquirer/core/dist/lib/hook-engine.js
3342
+ import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
3343
+ var hookStorage = new AsyncLocalStorage;
3344
+ function createStore(rl) {
3345
+ const store = {
3346
+ rl,
3347
+ hooks: [],
3348
+ hooksCleanup: [],
3349
+ hooksEffect: [],
3350
+ index: 0,
3351
+ handleChange() {}
3352
+ };
3353
+ return store;
3354
+ }
3355
+ function withHooks(rl, cb) {
3356
+ const store = createStore(rl);
3357
+ return hookStorage.run(store, () => {
3358
+ function cycle(render) {
3359
+ store.handleChange = () => {
3360
+ store.index = 0;
3361
+ render();
3362
+ };
3363
+ store.handleChange();
3364
+ }
3365
+ return cb(cycle);
3366
+ });
3367
+ }
3368
+ function getStore() {
3369
+ const store = hookStorage.getStore();
3370
+ if (!store) {
3371
+ throw new HookError("[Inquirer] Hook functions can only be called from within a prompt");
3372
+ }
3373
+ return store;
3374
+ }
3375
+ function readline() {
3376
+ return getStore().rl;
3377
+ }
3378
+ function withUpdates(fn) {
3379
+ const wrapped = (...args) => {
3380
+ const store = getStore();
3381
+ let shouldUpdate = false;
3382
+ const oldHandleChange = store.handleChange;
3383
+ store.handleChange = () => {
3384
+ shouldUpdate = true;
3385
+ };
3386
+ const returnValue = fn(...args);
3387
+ if (shouldUpdate) {
3388
+ oldHandleChange();
3389
+ }
3390
+ store.handleChange = oldHandleChange;
3391
+ return returnValue;
3392
+ };
3393
+ return AsyncResource.bind(wrapped);
3394
+ }
3395
+ function withPointer(cb) {
3396
+ const store = getStore();
3397
+ const { index } = store;
3398
+ const pointer = {
3399
+ get() {
3400
+ return store.hooks[index];
3401
+ },
3402
+ set(value) {
3403
+ store.hooks[index] = value;
3404
+ },
3405
+ initialized: index in store.hooks
3406
+ };
3407
+ const returnValue = cb(pointer);
3408
+ store.index++;
3409
+ return returnValue;
3410
+ }
3411
+ function handleChange() {
3412
+ getStore().handleChange();
3413
+ }
3414
+ var effectScheduler = {
3415
+ queue(cb) {
3416
+ const store = getStore();
3417
+ const { index } = store;
3418
+ store.hooksEffect.push(() => {
3419
+ store.hooksCleanup[index]?.();
3420
+ const cleanFn = cb(readline());
3421
+ if (cleanFn != null && typeof cleanFn !== "function") {
3422
+ throw new ValidationError("useEffect return value must be a cleanup function or nothing.");
3423
+ }
3424
+ store.hooksCleanup[index] = cleanFn;
3425
+ });
3426
+ },
3427
+ run() {
3428
+ const store = getStore();
3429
+ withUpdates(() => {
3430
+ store.hooksEffect.forEach((effect) => {
3431
+ effect();
3432
+ });
3433
+ store.hooksEffect.length = 0;
3434
+ })();
3435
+ },
3436
+ clearAll() {
3437
+ const store = getStore();
3438
+ store.hooksCleanup.forEach((cleanFn) => {
3439
+ cleanFn?.();
3440
+ });
3441
+ store.hooksEffect.length = 0;
3442
+ store.hooksCleanup.length = 0;
3443
+ }
3444
+ };
3445
+
3446
+ // node_modules/@inquirer/core/dist/lib/use-state.js
3447
+ function useState(defaultValue) {
3448
+ return withPointer((pointer) => {
3449
+ const setState = AsyncResource2.bind(function setState2(newValue) {
3450
+ if (pointer.get() !== newValue) {
3451
+ pointer.set(newValue);
3452
+ handleChange();
3453
+ }
3454
+ });
3455
+ if (pointer.initialized) {
3456
+ return [pointer.get(), setState];
3457
+ }
3458
+ const value = typeof defaultValue === "function" ? defaultValue() : defaultValue;
3459
+ pointer.set(value);
3460
+ return [value, setState];
3461
+ });
3462
+ }
3463
+
3464
+ // node_modules/@inquirer/core/dist/lib/use-effect.js
3465
+ function useEffect(cb, depArray) {
3466
+ withPointer((pointer) => {
3467
+ const oldDeps = pointer.get();
3468
+ const hasChanged = !Array.isArray(oldDeps) || depArray.some((dep, i) => !Object.is(dep, oldDeps[i]));
3469
+ if (hasChanged) {
3470
+ effectScheduler.queue(cb);
3471
+ }
3472
+ pointer.set(depArray);
3473
+ });
3474
+ }
3475
+
3476
+ // node_modules/@inquirer/core/dist/lib/theme.js
3477
+ import { styleText } from "node:util";
3478
+
3479
+ // node_modules/@inquirer/figures/dist/index.js
3480
+ import process2 from "node:process";
3481
+ function isUnicodeSupported() {
3482
+ if (process2.platform !== "win32") {
3483
+ return process2.env["TERM"] !== "linux";
3484
+ }
3485
+ return Boolean(process2.env["WT_SESSION"]) || Boolean(process2.env["TERMINUS_SUBLIME"]) || process2.env["ConEmuTask"] === "{cmd::Cmder}" || process2.env["TERM_PROGRAM"] === "Terminus-Sublime" || process2.env["TERM_PROGRAM"] === "vscode" || process2.env["TERM"] === "xterm-256color" || process2.env["TERM"] === "alacritty" || process2.env["TERMINAL_EMULATOR"] === "JetBrains-JediTerm";
3486
+ }
3487
+ var common = {
3488
+ circleQuestionMark: "(?)",
3489
+ questionMarkPrefix: "(?)",
3490
+ square: "█",
3491
+ squareDarkShade: "▓",
3492
+ squareMediumShade: "▒",
3493
+ squareLightShade: "░",
3494
+ squareTop: "▀",
3495
+ squareBottom: "▄",
3496
+ squareLeft: "▌",
3497
+ squareRight: "▐",
3498
+ squareCenter: "■",
3499
+ bullet: "●",
3500
+ dot: "․",
3501
+ ellipsis: "…",
3502
+ pointerSmall: "›",
3503
+ triangleUp: "▲",
3504
+ triangleUpSmall: "▴",
3505
+ triangleDown: "▼",
3506
+ triangleDownSmall: "▾",
3507
+ triangleLeftSmall: "◂",
3508
+ triangleRightSmall: "▸",
3509
+ home: "⌂",
3510
+ heart: "♥",
3511
+ musicNote: "♪",
3512
+ musicNoteBeamed: "♫",
3513
+ arrowUp: "↑",
3514
+ arrowDown: "↓",
3515
+ arrowLeft: "←",
3516
+ arrowRight: "→",
3517
+ arrowLeftRight: "↔",
3518
+ arrowUpDown: "↕",
3519
+ almostEqual: "≈",
3520
+ notEqual: "≠",
3521
+ lessOrEqual: "≤",
3522
+ greaterOrEqual: "≥",
3523
+ identical: "≡",
3524
+ infinity: "∞",
3525
+ subscriptZero: "₀",
3526
+ subscriptOne: "₁",
3527
+ subscriptTwo: "₂",
3528
+ subscriptThree: "₃",
3529
+ subscriptFour: "₄",
3530
+ subscriptFive: "₅",
3531
+ subscriptSix: "₆",
3532
+ subscriptSeven: "₇",
3533
+ subscriptEight: "₈",
3534
+ subscriptNine: "₉",
3535
+ oneHalf: "½",
3536
+ oneThird: "⅓",
3537
+ oneQuarter: "¼",
3538
+ oneFifth: "⅕",
3539
+ oneSixth: "⅙",
3540
+ oneEighth: "⅛",
3541
+ twoThirds: "⅔",
3542
+ twoFifths: "⅖",
3543
+ threeQuarters: "¾",
3544
+ threeFifths: "⅗",
3545
+ threeEighths: "⅜",
3546
+ fourFifths: "⅘",
3547
+ fiveSixths: "⅚",
3548
+ fiveEighths: "⅝",
3549
+ sevenEighths: "⅞",
3550
+ line: "─",
3551
+ lineBold: "━",
3552
+ lineDouble: "═",
3553
+ lineDashed0: "┄",
3554
+ lineDashed1: "┅",
3555
+ lineDashed2: "┈",
3556
+ lineDashed3: "┉",
3557
+ lineDashed4: "╌",
3558
+ lineDashed5: "╍",
3559
+ lineDashed6: "╴",
3560
+ lineDashed7: "╶",
3561
+ lineDashed8: "╸",
3562
+ lineDashed9: "╺",
3563
+ lineDashed10: "╼",
3564
+ lineDashed11: "╾",
3565
+ lineDashed12: "−",
3566
+ lineDashed13: "–",
3567
+ lineDashed14: "‐",
3568
+ lineDashed15: "⁃",
3569
+ lineVertical: "│",
3570
+ lineVerticalBold: "┃",
3571
+ lineVerticalDouble: "║",
3572
+ lineVerticalDashed0: "┆",
3573
+ lineVerticalDashed1: "┇",
3574
+ lineVerticalDashed2: "┊",
3575
+ lineVerticalDashed3: "┋",
3576
+ lineVerticalDashed4: "╎",
3577
+ lineVerticalDashed5: "╏",
3578
+ lineVerticalDashed6: "╵",
3579
+ lineVerticalDashed7: "╷",
3580
+ lineVerticalDashed8: "╹",
3581
+ lineVerticalDashed9: "╻",
3582
+ lineVerticalDashed10: "╽",
3583
+ lineVerticalDashed11: "╿",
3584
+ lineDownLeft: "┐",
3585
+ lineDownLeftArc: "╮",
3586
+ lineDownBoldLeftBold: "┓",
3587
+ lineDownBoldLeft: "┒",
3588
+ lineDownLeftBold: "┑",
3589
+ lineDownDoubleLeftDouble: "╗",
3590
+ lineDownDoubleLeft: "╖",
3591
+ lineDownLeftDouble: "╕",
3592
+ lineDownRight: "┌",
3593
+ lineDownRightArc: "╭",
3594
+ lineDownBoldRightBold: "┏",
3595
+ lineDownBoldRight: "┎",
3596
+ lineDownRightBold: "┍",
3597
+ lineDownDoubleRightDouble: "╔",
3598
+ lineDownDoubleRight: "╓",
3599
+ lineDownRightDouble: "╒",
3600
+ lineUpLeft: "┘",
3601
+ lineUpLeftArc: "╯",
3602
+ lineUpBoldLeftBold: "┛",
3603
+ lineUpBoldLeft: "┚",
3604
+ lineUpLeftBold: "┙",
3605
+ lineUpDoubleLeftDouble: "╝",
3606
+ lineUpDoubleLeft: "╜",
3607
+ lineUpLeftDouble: "╛",
3608
+ lineUpRight: "└",
3609
+ lineUpRightArc: "╰",
3610
+ lineUpBoldRightBold: "┗",
3611
+ lineUpBoldRight: "┖",
3612
+ lineUpRightBold: "┕",
3613
+ lineUpDoubleRightDouble: "╚",
3614
+ lineUpDoubleRight: "╙",
3615
+ lineUpRightDouble: "╘",
3616
+ lineUpDownLeft: "┤",
3617
+ lineUpBoldDownBoldLeftBold: "┫",
3618
+ lineUpBoldDownBoldLeft: "┨",
3619
+ lineUpDownLeftBold: "┥",
3620
+ lineUpBoldDownLeftBold: "┩",
3621
+ lineUpDownBoldLeftBold: "┪",
3622
+ lineUpDownBoldLeft: "┧",
3623
+ lineUpBoldDownLeft: "┦",
3624
+ lineUpDoubleDownDoubleLeftDouble: "╣",
3625
+ lineUpDoubleDownDoubleLeft: "╢",
3626
+ lineUpDownLeftDouble: "╡",
3627
+ lineUpDownRight: "├",
3628
+ lineUpBoldDownBoldRightBold: "┣",
3629
+ lineUpBoldDownBoldRight: "┠",
3630
+ lineUpDownRightBold: "┝",
3631
+ lineUpBoldDownRightBold: "┡",
3632
+ lineUpDownBoldRightBold: "┢",
3633
+ lineUpDownBoldRight: "┟",
3634
+ lineUpBoldDownRight: "┞",
3635
+ lineUpDoubleDownDoubleRightDouble: "╠",
3636
+ lineUpDoubleDownDoubleRight: "╟",
3637
+ lineUpDownRightDouble: "╞",
3638
+ lineDownLeftRight: "┬",
3639
+ lineDownBoldLeftBoldRightBold: "┳",
3640
+ lineDownLeftBoldRightBold: "┯",
3641
+ lineDownBoldLeftRight: "┰",
3642
+ lineDownBoldLeftBoldRight: "┱",
3643
+ lineDownBoldLeftRightBold: "┲",
3644
+ lineDownLeftRightBold: "┮",
3645
+ lineDownLeftBoldRight: "┭",
3646
+ lineDownDoubleLeftDoubleRightDouble: "╦",
3647
+ lineDownDoubleLeftRight: "╥",
3648
+ lineDownLeftDoubleRightDouble: "╤",
3649
+ lineUpLeftRight: "┴",
3650
+ lineUpBoldLeftBoldRightBold: "┻",
3651
+ lineUpLeftBoldRightBold: "┷",
3652
+ lineUpBoldLeftRight: "┸",
3653
+ lineUpBoldLeftBoldRight: "┹",
3654
+ lineUpBoldLeftRightBold: "┺",
3655
+ lineUpLeftRightBold: "┶",
3656
+ lineUpLeftBoldRight: "┵",
3657
+ lineUpDoubleLeftDoubleRightDouble: "╩",
3658
+ lineUpDoubleLeftRight: "╨",
3659
+ lineUpLeftDoubleRightDouble: "╧",
3660
+ lineUpDownLeftRight: "┼",
3661
+ lineUpBoldDownBoldLeftBoldRightBold: "╋",
3662
+ lineUpDownBoldLeftBoldRightBold: "╈",
3663
+ lineUpBoldDownLeftBoldRightBold: "╇",
3664
+ lineUpBoldDownBoldLeftRightBold: "╊",
3665
+ lineUpBoldDownBoldLeftBoldRight: "╉",
3666
+ lineUpBoldDownLeftRight: "╀",
3667
+ lineUpDownBoldLeftRight: "╁",
3668
+ lineUpDownLeftBoldRight: "┽",
3669
+ lineUpDownLeftRightBold: "┾",
3670
+ lineUpBoldDownBoldLeftRight: "╂",
3671
+ lineUpDownLeftBoldRightBold: "┿",
3672
+ lineUpBoldDownLeftBoldRight: "╃",
3673
+ lineUpBoldDownLeftRightBold: "╄",
3674
+ lineUpDownBoldLeftBoldRight: "╅",
3675
+ lineUpDownBoldLeftRightBold: "╆",
3676
+ lineUpDoubleDownDoubleLeftDoubleRightDouble: "╬",
3677
+ lineUpDoubleDownDoubleLeftRight: "╫",
3678
+ lineUpDownLeftDoubleRightDouble: "╪",
3679
+ lineCross: "╳",
3680
+ lineBackslash: "╲",
3681
+ lineSlash: "╱"
3682
+ };
3683
+ var specialMainSymbols = {
3684
+ tick: "✔",
3685
+ info: "ℹ",
3686
+ warning: "⚠",
3687
+ cross: "✘",
3688
+ squareSmall: "◻",
3689
+ squareSmallFilled: "◼",
3690
+ circle: "◯",
3691
+ circleFilled: "◉",
3692
+ circleDotted: "◌",
3693
+ circleDouble: "◎",
3694
+ circleCircle: "ⓞ",
3695
+ circleCross: "ⓧ",
3696
+ circlePipe: "Ⓘ",
3697
+ radioOn: "◉",
3698
+ radioOff: "◯",
3699
+ checkboxOn: "☒",
3700
+ checkboxOff: "☐",
3701
+ checkboxCircleOn: "ⓧ",
3702
+ checkboxCircleOff: "Ⓘ",
3703
+ pointer: "❯",
3704
+ triangleUpOutline: "△",
3705
+ triangleLeft: "◀",
3706
+ triangleRight: "▶",
3707
+ lozenge: "◆",
3708
+ lozengeOutline: "◇",
3709
+ hamburger: "☰",
3710
+ smiley: "㋡",
3711
+ mustache: "෴",
3712
+ star: "★",
3713
+ play: "▶",
3714
+ nodejs: "⬢",
3715
+ oneSeventh: "⅐",
3716
+ oneNinth: "⅑",
3717
+ oneTenth: "⅒"
3718
+ };
3719
+ var specialFallbackSymbols = {
3720
+ tick: "√",
3721
+ info: "i",
3722
+ warning: "‼",
3723
+ cross: "×",
3724
+ squareSmall: "□",
3725
+ squareSmallFilled: "■",
3726
+ circle: "( )",
3727
+ circleFilled: "(*)",
3728
+ circleDotted: "( )",
3729
+ circleDouble: "( )",
3730
+ circleCircle: "(○)",
3731
+ circleCross: "(×)",
3732
+ circlePipe: "(│)",
3733
+ radioOn: "(*)",
3734
+ radioOff: "( )",
3735
+ checkboxOn: "[×]",
3736
+ checkboxOff: "[ ]",
3737
+ checkboxCircleOn: "(×)",
3738
+ checkboxCircleOff: "( )",
3739
+ pointer: ">",
3740
+ triangleUpOutline: "∆",
3741
+ triangleLeft: "◄",
3742
+ triangleRight: "►",
3743
+ lozenge: "♦",
3744
+ lozengeOutline: "◊",
3745
+ hamburger: "≡",
3746
+ smiley: "☺",
3747
+ mustache: "┌─┐",
3748
+ star: "✶",
3749
+ play: "►",
3750
+ nodejs: "♦",
3751
+ oneSeventh: "1/7",
3752
+ oneNinth: "1/9",
3753
+ oneTenth: "1/10"
3754
+ };
3755
+ var mainSymbols = {
3756
+ ...common,
3757
+ ...specialMainSymbols
3758
+ };
3759
+ var fallbackSymbols = {
3760
+ ...common,
3761
+ ...specialFallbackSymbols
3762
+ };
3763
+ var shouldUseMain = isUnicodeSupported();
3764
+ var figures = shouldUseMain ? mainSymbols : fallbackSymbols;
3765
+ var dist_default = figures;
3766
+ var replacements = Object.entries(specialMainSymbols);
3767
+
3768
+ // node_modules/@inquirer/core/dist/lib/theme.js
3769
+ var defaultTheme = {
3770
+ prefix: {
3771
+ idle: styleText("blue", "?"),
3772
+ done: styleText("green", dist_default.tick)
3773
+ },
3774
+ spinner: {
3775
+ interval: 80,
3776
+ frames: ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"].map((frame) => styleText("yellow", frame))
3777
+ },
3778
+ style: {
3779
+ answer: (text) => styleText("cyan", text),
3780
+ message: (text) => styleText("bold", text),
3781
+ error: (text) => styleText("red", `> ${text}`),
3782
+ defaultAnswer: (text) => styleText("dim", `(${text})`),
3783
+ help: (text) => styleText("dim", text),
3784
+ highlight: (text) => styleText("cyan", text),
3785
+ key: (text) => styleText("cyan", styleText("bold", `<${text}>`))
3786
+ }
3787
+ };
3788
+
3789
+ // node_modules/@inquirer/core/dist/lib/make-theme.js
3790
+ function isPlainObject(value) {
3791
+ if (typeof value !== "object" || value === null)
3792
+ return false;
3793
+ let proto = value;
3794
+ while (Object.getPrototypeOf(proto) !== null) {
3795
+ proto = Object.getPrototypeOf(proto);
3796
+ }
3797
+ return Object.getPrototypeOf(value) === proto;
3798
+ }
3799
+ function deepMerge(...objects) {
3800
+ const output = {};
3801
+ for (const obj of objects) {
3802
+ for (const [key, value] of Object.entries(obj)) {
3803
+ const prevValue = output[key];
3804
+ output[key] = isPlainObject(prevValue) && isPlainObject(value) ? deepMerge(prevValue, value) : value;
3805
+ }
3806
+ }
3807
+ return output;
3808
+ }
3809
+ function makeTheme(...themes) {
3810
+ const themesToMerge = [
3811
+ defaultTheme,
3812
+ ...themes.filter((theme2) => theme2 != null)
3813
+ ];
3814
+ return deepMerge(...themesToMerge);
3815
+ }
3816
+
3817
+ // node_modules/@inquirer/core/dist/lib/use-prefix.js
3818
+ function usePrefix({ status = "idle", theme: theme2 }) {
3819
+ const [showLoader, setShowLoader] = useState(false);
3820
+ const [tick, setTick] = useState(0);
3821
+ const { prefix, spinner } = makeTheme(theme2);
3822
+ useEffect(() => {
3823
+ if (status === "loading") {
3824
+ let tickInterval;
3825
+ let inc = -1;
3826
+ const delayTimeout = setTimeout(() => {
3827
+ setShowLoader(true);
3828
+ tickInterval = setInterval(() => {
3829
+ inc = inc + 1;
3830
+ setTick(inc % spinner.frames.length);
3831
+ }, spinner.interval);
3832
+ }, 300);
3833
+ return () => {
3834
+ clearTimeout(delayTimeout);
3835
+ clearInterval(tickInterval);
3836
+ };
3837
+ } else {
3838
+ setShowLoader(false);
3839
+ }
3840
+ }, [status]);
3841
+ if (showLoader) {
3842
+ return spinner.frames[tick];
3843
+ }
3844
+ const iconName = status === "loading" ? "idle" : status;
3845
+ return typeof prefix === "string" ? prefix : prefix[iconName] ?? prefix["idle"];
3846
+ }
3847
+ // node_modules/@inquirer/core/dist/lib/use-memo.js
3848
+ function useMemo(fn, dependencies) {
3849
+ return withPointer((pointer) => {
3850
+ const prev = pointer.get();
3851
+ if (!prev || prev.dependencies.length !== dependencies.length || prev.dependencies.some((dep, i) => dep !== dependencies[i])) {
3852
+ const value = fn();
3853
+ pointer.set({ value, dependencies });
3854
+ return value;
3855
+ }
3856
+ return prev.value;
3857
+ });
3858
+ }
3859
+ // node_modules/@inquirer/core/dist/lib/use-ref.js
3860
+ function useRef(val) {
3861
+ return useState({ current: val })[0];
3862
+ }
3863
+ // node_modules/@inquirer/core/dist/lib/use-keypress.js
3864
+ function useKeypress(userHandler) {
3865
+ const signal = useRef(userHandler);
3866
+ signal.current = userHandler;
3867
+ useEffect((rl) => {
3868
+ let ignore = false;
3869
+ const handler = withUpdates((_input, event) => {
3870
+ if (ignore)
3871
+ return;
3872
+ signal.current(event, rl);
3873
+ });
3874
+ rl.input.on("keypress", handler);
3875
+ return () => {
3876
+ ignore = true;
3877
+ rl.input.removeListener("keypress", handler);
3878
+ };
3879
+ }, []);
3880
+ }
3881
+ // node_modules/@inquirer/core/dist/lib/utils.js
3882
+ var import_cli_width = __toESM(require_cli_width(), 1);
3883
+
3884
+ // node_modules/fast-string-truncated-width/dist/utils.js
3885
+ var getCodePointsLength = (() => {
3886
+ const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
3887
+ return (input) => {
3888
+ let surrogatePairsNr = 0;
3889
+ SURROGATE_PAIR_RE.lastIndex = 0;
3890
+ while (SURROGATE_PAIR_RE.test(input)) {
3891
+ surrogatePairsNr += 1;
3892
+ }
3893
+ return input.length - surrogatePairsNr;
3894
+ };
3895
+ })();
3896
+ var isFullWidth = (x) => {
3897
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
3898
+ };
3899
+ var isWideNotCJKTNotEmoji = (x) => {
3900
+ return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
3901
+ };
3902
+
3903
+ // node_modules/fast-string-truncated-width/dist/index.js
3904
+ var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
3905
+ var CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
3906
+ var CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu;
3907
+ var TAB_RE = /\t{1,1000}/y;
3908
+ var EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
3909
+ var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
3910
+ var MODIFIER_RE = /\p{M}+/gu;
3911
+ var NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
3912
+ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
3913
+ const LIMIT = truncationOptions.limit ?? Infinity;
3914
+ const ELLIPSIS = truncationOptions.ellipsis ?? "";
3915
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
3916
+ const ANSI_WIDTH = 0;
3917
+ const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
3918
+ const TAB_WIDTH = widthOptions.tabWidth ?? 8;
3919
+ const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
3920
+ const FULL_WIDTH_WIDTH = 2;
3921
+ const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
3922
+ const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
3923
+ const PARSE_BLOCKS = [
3924
+ [LATIN_RE, REGULAR_WIDTH],
3925
+ [ANSI_RE, ANSI_WIDTH],
3926
+ [CONTROL_RE, CONTROL_WIDTH],
3927
+ [TAB_RE, TAB_WIDTH],
3928
+ [EMOJI_RE, EMOJI_WIDTH],
3929
+ [CJKT_WIDE_RE, WIDE_WIDTH]
3930
+ ];
3931
+ let indexPrev = 0;
3932
+ let index = 0;
3933
+ let length = input.length;
3934
+ let lengthExtra = 0;
3935
+ let truncationEnabled = false;
3936
+ let truncationIndex = length;
3937
+ let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
3938
+ let unmatchedStart = 0;
3939
+ let unmatchedEnd = 0;
3940
+ let width = 0;
3941
+ let widthExtra = 0;
3942
+ outer:
3943
+ while (true) {
3944
+ if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
3945
+ const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
3946
+ lengthExtra = 0;
3947
+ for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
3948
+ const codePoint = char.codePointAt(0) || 0;
3949
+ if (isFullWidth(codePoint)) {
3950
+ widthExtra = FULL_WIDTH_WIDTH;
3951
+ } else if (isWideNotCJKTNotEmoji(codePoint)) {
3952
+ widthExtra = WIDE_WIDTH;
3953
+ } else {
3954
+ widthExtra = REGULAR_WIDTH;
3955
+ }
3956
+ if (width + widthExtra > truncationLimit) {
3957
+ truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
3958
+ }
3959
+ if (width + widthExtra > LIMIT) {
3960
+ truncationEnabled = true;
3961
+ break outer;
3962
+ }
3963
+ lengthExtra += char.length;
3964
+ width += widthExtra;
3965
+ }
3966
+ unmatchedStart = unmatchedEnd = 0;
3967
+ }
3968
+ if (index >= length) {
3969
+ break outer;
3970
+ }
3971
+ for (let i = 0, l = PARSE_BLOCKS.length;i < l; i++) {
3972
+ const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
3973
+ BLOCK_RE.lastIndex = index;
3974
+ if (BLOCK_RE.test(input)) {
3975
+ lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
3976
+ widthExtra = lengthExtra * BLOCK_WIDTH;
3977
+ if (width + widthExtra > truncationLimit) {
3978
+ truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
3979
+ }
3980
+ if (width + widthExtra > LIMIT) {
3981
+ truncationEnabled = true;
3982
+ break outer;
3983
+ }
3984
+ width += widthExtra;
3985
+ unmatchedStart = indexPrev;
3986
+ unmatchedEnd = index;
3987
+ index = indexPrev = BLOCK_RE.lastIndex;
3988
+ continue outer;
3989
+ }
3990
+ }
3991
+ index += 1;
3992
+ }
3993
+ return {
3994
+ width: truncationEnabled ? truncationLimit : width,
3995
+ index: truncationEnabled ? truncationIndex : length,
3996
+ truncated: truncationEnabled,
3997
+ ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
3998
+ };
3999
+ };
4000
+ var dist_default2 = getStringTruncatedWidth;
4001
+
4002
+ // node_modules/fast-string-width/dist/index.js
4003
+ var NO_TRUNCATION2 = {
4004
+ limit: Infinity,
4005
+ ellipsis: "",
4006
+ ellipsisWidth: 0
4007
+ };
4008
+ var fastStringWidth = (input, options = {}) => {
4009
+ return dist_default2(input, NO_TRUNCATION2, options).width;
4010
+ };
4011
+ var dist_default3 = fastStringWidth;
4012
+
4013
+ // node_modules/fast-wrap-ansi/lib/main.js
4014
+ var ESC = "\x1B";
4015
+ var CSI = "›";
4016
+ var END_CODE = 39;
4017
+ var ANSI_ESCAPE_BELL = "\x07";
4018
+ var ANSI_CSI = "[";
4019
+ var ANSI_OSC = "]";
4020
+ var ANSI_SGR_TERMINATOR = "m";
4021
+ var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
4022
+ var GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
4023
+ var getClosingCode = (openingCode) => {
4024
+ if (openingCode >= 30 && openingCode <= 37)
4025
+ return 39;
4026
+ if (openingCode >= 90 && openingCode <= 97)
4027
+ return 39;
4028
+ if (openingCode >= 40 && openingCode <= 47)
4029
+ return 49;
4030
+ if (openingCode >= 100 && openingCode <= 107)
4031
+ return 49;
4032
+ if (openingCode === 1 || openingCode === 2)
4033
+ return 22;
4034
+ if (openingCode === 3)
4035
+ return 23;
4036
+ if (openingCode === 4)
4037
+ return 24;
4038
+ if (openingCode === 7)
4039
+ return 27;
4040
+ if (openingCode === 8)
4041
+ return 28;
4042
+ if (openingCode === 9)
4043
+ return 29;
4044
+ if (openingCode === 0)
4045
+ return 0;
4046
+ return;
4047
+ };
4048
+ var wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
4049
+ var wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
4050
+ var wrapWord = (rows, word, columns) => {
4051
+ const characters = word[Symbol.iterator]();
4052
+ let isInsideEscape = false;
4053
+ let isInsideLinkEscape = false;
4054
+ let lastRow = rows.at(-1);
4055
+ let visible = lastRow === undefined ? 0 : dist_default3(lastRow);
4056
+ let currentCharacter = characters.next();
4057
+ let nextCharacter = characters.next();
4058
+ let rawCharacterIndex = 0;
4059
+ while (!currentCharacter.done) {
4060
+ const character = currentCharacter.value;
4061
+ const characterLength = dist_default3(character);
4062
+ if (visible + characterLength <= columns) {
4063
+ rows[rows.length - 1] += character;
4064
+ } else {
4065
+ rows.push(character);
4066
+ visible = 0;
4067
+ }
4068
+ if (character === ESC || character === CSI) {
4069
+ isInsideEscape = true;
4070
+ isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
4071
+ }
4072
+ if (isInsideEscape) {
4073
+ if (isInsideLinkEscape) {
4074
+ if (character === ANSI_ESCAPE_BELL) {
4075
+ isInsideEscape = false;
4076
+ isInsideLinkEscape = false;
4077
+ }
4078
+ } else if (character === ANSI_SGR_TERMINATOR) {
4079
+ isInsideEscape = false;
4080
+ }
4081
+ } else {
4082
+ visible += characterLength;
4083
+ if (visible === columns && !nextCharacter.done) {
4084
+ rows.push("");
4085
+ visible = 0;
4086
+ }
4087
+ }
4088
+ currentCharacter = nextCharacter;
4089
+ nextCharacter = characters.next();
4090
+ rawCharacterIndex += character.length;
4091
+ }
4092
+ lastRow = rows.at(-1);
4093
+ if (!visible && lastRow !== undefined && lastRow.length && rows.length > 1) {
4094
+ rows[rows.length - 2] += rows.pop();
4095
+ }
4096
+ };
4097
+ var stringVisibleTrimSpacesRight = (string) => {
4098
+ const words = string.split(" ");
4099
+ let last = words.length;
4100
+ while (last) {
4101
+ if (dist_default3(words[last - 1])) {
4102
+ break;
4103
+ }
4104
+ last--;
4105
+ }
4106
+ if (last === words.length) {
4107
+ return string;
4108
+ }
4109
+ return words.slice(0, last).join(" ") + words.slice(last).join("");
4110
+ };
4111
+ var exec = (string, columns, options = {}) => {
4112
+ if (options.trim !== false && string.trim() === "") {
4113
+ return "";
4114
+ }
4115
+ let returnValue = "";
4116
+ let escapeCode;
4117
+ let escapeUrl;
4118
+ const words = string.split(" ");
4119
+ let rows = [""];
4120
+ let rowLength = 0;
4121
+ for (let index = 0;index < words.length; index++) {
4122
+ const word = words[index];
4123
+ if (options.trim !== false) {
4124
+ const row = rows.at(-1) ?? "";
4125
+ const trimmed = row.trimStart();
4126
+ if (row.length !== trimmed.length) {
4127
+ rows[rows.length - 1] = trimmed;
4128
+ rowLength = dist_default3(trimmed);
4129
+ }
4130
+ }
4131
+ if (index !== 0) {
4132
+ if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
4133
+ rows.push("");
4134
+ rowLength = 0;
4135
+ }
4136
+ if (rowLength || options.trim === false) {
4137
+ rows[rows.length - 1] += " ";
4138
+ rowLength++;
4139
+ }
4140
+ }
4141
+ const wordLength = dist_default3(word);
4142
+ if (options.hard && wordLength > columns) {
4143
+ const remainingColumns = columns - rowLength;
4144
+ const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
4145
+ const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
4146
+ if (breaksStartingNextLine < breaksStartingThisLine) {
4147
+ rows.push("");
4148
+ }
4149
+ wrapWord(rows, word, columns);
4150
+ rowLength = dist_default3(rows.at(-1) ?? "");
4151
+ continue;
4152
+ }
4153
+ if (rowLength + wordLength > columns && rowLength && wordLength) {
4154
+ if (options.wordWrap === false && rowLength < columns) {
4155
+ wrapWord(rows, word, columns);
4156
+ rowLength = dist_default3(rows.at(-1) ?? "");
4157
+ continue;
4158
+ }
4159
+ rows.push("");
4160
+ rowLength = 0;
4161
+ }
4162
+ if (rowLength + wordLength > columns && options.wordWrap === false) {
4163
+ wrapWord(rows, word, columns);
4164
+ rowLength = dist_default3(rows.at(-1) ?? "");
4165
+ continue;
4166
+ }
4167
+ rows[rows.length - 1] += word;
4168
+ rowLength += wordLength;
4169
+ }
4170
+ if (options.trim !== false) {
4171
+ rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
4172
+ }
4173
+ const preString = rows.join(`
4174
+ `);
4175
+ let inSurrogate = false;
4176
+ for (let i = 0;i < preString.length; i++) {
4177
+ const character = preString[i];
4178
+ returnValue += character;
4179
+ if (!inSurrogate) {
4180
+ inSurrogate = character >= "\uD800" && character <= "\uDBFF";
4181
+ if (inSurrogate) {
4182
+ continue;
4183
+ }
4184
+ } else {
4185
+ inSurrogate = false;
4186
+ }
4187
+ if (character === ESC || character === CSI) {
4188
+ GROUP_REGEX.lastIndex = i + 1;
4189
+ const groupsResult = GROUP_REGEX.exec(preString);
4190
+ const groups = groupsResult?.groups;
4191
+ if (groups?.code !== undefined) {
4192
+ const code = Number.parseFloat(groups.code);
4193
+ escapeCode = code === END_CODE ? undefined : code;
4194
+ } else if (groups?.uri !== undefined) {
4195
+ escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
4196
+ }
4197
+ }
4198
+ if (preString[i + 1] === `
4199
+ `) {
4200
+ if (escapeUrl) {
4201
+ returnValue += wrapAnsiHyperlink("");
4202
+ }
4203
+ const closingCode = escapeCode ? getClosingCode(escapeCode) : undefined;
4204
+ if (escapeCode && closingCode) {
4205
+ returnValue += wrapAnsiCode(closingCode);
4206
+ }
4207
+ } else if (character === `
4208
+ `) {
4209
+ if (escapeCode && getClosingCode(escapeCode)) {
4210
+ returnValue += wrapAnsiCode(escapeCode);
4211
+ }
4212
+ if (escapeUrl) {
4213
+ returnValue += wrapAnsiHyperlink(escapeUrl);
4214
+ }
4215
+ }
4216
+ }
4217
+ return returnValue;
4218
+ };
4219
+ var CRLF_OR_LF = /\r?\n/;
4220
+ function wrapAnsi(string, columns, options) {
4221
+ return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join(`
4222
+ `);
4223
+ }
4224
+
4225
+ // node_modules/@inquirer/core/dist/lib/utils.js
4226
+ function breakLines(content, width) {
4227
+ return content.split(`
4228
+ `).flatMap((line) => wrapAnsi(line, width, { trim: false, hard: true }).split(`
4229
+ `).map((str) => str.trimEnd())).join(`
4230
+ `);
4231
+ }
4232
+ function readlineWidth() {
4233
+ return import_cli_width.default({ defaultWidth: 80, output: readline().output });
4234
+ }
4235
+
4236
+ // node_modules/@inquirer/core/dist/lib/pagination/use-pagination.js
4237
+ function usePointerPosition({ active, renderedItems, pageSize, loop }) {
4238
+ const state = useRef({
4239
+ lastPointer: active,
4240
+ lastActive: undefined
4241
+ });
4242
+ const { lastPointer, lastActive } = state.current;
4243
+ const middle = Math.floor(pageSize / 2);
4244
+ const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
4245
+ const defaultPointerPosition = renderedItems.slice(0, active).reduce((acc, item) => acc + item.length, 0);
4246
+ let pointer = defaultPointerPosition;
4247
+ if (renderedLength > pageSize) {
4248
+ if (loop) {
4249
+ pointer = lastPointer;
4250
+ if (lastActive != null && lastActive < active && active - lastActive < pageSize) {
4251
+ pointer = Math.min(middle, Math.abs(active - lastActive) === 1 ? Math.min(lastPointer + (renderedItems[lastActive]?.length ?? 0), Math.max(defaultPointerPosition, lastPointer)) : lastPointer + active - lastActive);
4252
+ }
4253
+ } else {
4254
+ const spaceUnderActive = renderedItems.slice(active).reduce((acc, item) => acc + item.length, 0);
4255
+ pointer = spaceUnderActive < pageSize - middle ? pageSize - spaceUnderActive : Math.min(defaultPointerPosition, middle);
4256
+ }
4257
+ }
4258
+ state.current.lastPointer = pointer;
4259
+ state.current.lastActive = active;
4260
+ return pointer;
4261
+ }
4262
+ function usePagination({ items, active, renderItem, pageSize, loop = true }) {
4263
+ const width = readlineWidth();
4264
+ const bound = (num) => (num % items.length + items.length) % items.length;
4265
+ const renderedItems = items.map((item, index) => {
4266
+ if (item == null)
4267
+ return [];
4268
+ return breakLines(renderItem({ item, index, isActive: index === active }), width).split(`
4269
+ `);
4270
+ });
4271
+ const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
4272
+ const renderItemAtIndex = (index) => renderedItems[index] ?? [];
4273
+ const pointer = usePointerPosition({ active, renderedItems, pageSize, loop });
4274
+ const activeItem = renderItemAtIndex(active).slice(0, pageSize);
4275
+ const activeItemPosition = pointer + activeItem.length <= pageSize ? pointer : pageSize - activeItem.length;
4276
+ const pageBuffer = Array.from({ length: pageSize });
4277
+ pageBuffer.splice(activeItemPosition, activeItem.length, ...activeItem);
4278
+ const itemVisited = new Set([active]);
4279
+ let bufferPointer = activeItemPosition + activeItem.length;
4280
+ let itemPointer = bound(active + 1);
4281
+ while (bufferPointer < pageSize && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer > active)) {
4282
+ const lines = renderItemAtIndex(itemPointer);
4283
+ const linesToAdd = lines.slice(0, pageSize - bufferPointer);
4284
+ pageBuffer.splice(bufferPointer, linesToAdd.length, ...linesToAdd);
4285
+ itemVisited.add(itemPointer);
4286
+ bufferPointer += linesToAdd.length;
4287
+ itemPointer = bound(itemPointer + 1);
4288
+ }
4289
+ bufferPointer = activeItemPosition - 1;
4290
+ itemPointer = bound(active - 1);
4291
+ while (bufferPointer >= 0 && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer < active)) {
4292
+ const lines = renderItemAtIndex(itemPointer);
4293
+ const linesToAdd = lines.slice(Math.max(0, lines.length - bufferPointer - 1));
4294
+ pageBuffer.splice(bufferPointer - linesToAdd.length + 1, linesToAdd.length, ...linesToAdd);
4295
+ itemVisited.add(itemPointer);
4296
+ bufferPointer -= linesToAdd.length;
4297
+ itemPointer = bound(itemPointer - 1);
4298
+ }
4299
+ return pageBuffer.filter((line) => typeof line === "string").join(`
4300
+ `);
4301
+ }
4302
+ // node_modules/@inquirer/core/dist/lib/create-prompt.js
4303
+ var import_mute_stream = __toESM(require_lib(), 1);
4304
+ import * as readline2 from "node:readline";
4305
+ import { AsyncResource as AsyncResource3 } from "node:async_hooks";
4306
+
4307
+ // node_modules/@inquirer/core/dist/lib/screen-manager.js
4308
+ import { stripVTControlCharacters } from "node:util";
4309
+
4310
+ // node_modules/@inquirer/ansi/dist/index.js
4311
+ var ESC2 = "\x1B[";
4312
+ var cursorLeft = ESC2 + "G";
4313
+ var cursorHide = ESC2 + "?25l";
4314
+ var cursorShow = ESC2 + "?25h";
4315
+ var cursorUp = (rows = 1) => rows > 0 ? `${ESC2}${rows}A` : "";
4316
+ var cursorDown = (rows = 1) => rows > 0 ? `${ESC2}${rows}B` : "";
4317
+ var cursorTo = (x, y) => {
4318
+ if (typeof y === "number" && !Number.isNaN(y)) {
4319
+ return `${ESC2}${y + 1};${x + 1}H`;
4320
+ }
4321
+ return `${ESC2}${x + 1}G`;
4322
+ };
4323
+ var eraseLine = ESC2 + "2K";
4324
+ var eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + cursorLeft : "";
4325
+
4326
+ // node_modules/@inquirer/core/dist/lib/screen-manager.js
4327
+ var height = (content) => content.split(`
4328
+ `).length;
4329
+ var lastLine = (content) => content.split(`
4330
+ `).pop() ?? "";
4331
+
4332
+ class ScreenManager {
4333
+ height = 0;
4334
+ extraLinesUnderPrompt = 0;
4335
+ cursorPos;
4336
+ rl;
4337
+ constructor(rl) {
4338
+ this.rl = rl;
4339
+ this.cursorPos = rl.getCursorPos();
4340
+ }
4341
+ write(content) {
4342
+ this.rl.output.unmute();
4343
+ this.rl.output.write(content);
4344
+ this.rl.output.mute();
4345
+ }
4346
+ render(content, bottomContent = "") {
4347
+ const promptLine = lastLine(content);
4348
+ const rawPromptLine = stripVTControlCharacters(promptLine);
4349
+ let prompt = rawPromptLine;
4350
+ if (this.rl.line.length > 0) {
4351
+ prompt = prompt.slice(0, -this.rl.line.length);
4352
+ }
4353
+ this.rl.setPrompt(prompt);
4354
+ this.cursorPos = this.rl.getCursorPos();
4355
+ const width = readlineWidth();
4356
+ content = breakLines(content, width);
4357
+ bottomContent = breakLines(bottomContent, width);
4358
+ if (rawPromptLine.length % width === 0) {
4359
+ content += `
4360
+ `;
4361
+ }
4362
+ let output = content + (bottomContent ? `
4363
+ ` + bottomContent : "");
4364
+ const promptLineUpDiff = Math.floor(rawPromptLine.length / width) - this.cursorPos.rows;
4365
+ const bottomContentHeight = promptLineUpDiff + (bottomContent ? height(bottomContent) : 0);
4366
+ if (bottomContentHeight > 0)
4367
+ output += cursorUp(bottomContentHeight);
4368
+ output += cursorTo(this.cursorPos.cols);
4369
+ this.write(cursorDown(this.extraLinesUnderPrompt) + eraseLines(this.height) + output);
4370
+ this.extraLinesUnderPrompt = bottomContentHeight;
4371
+ this.height = height(output);
4372
+ }
4373
+ checkCursorPos() {
4374
+ const cursorPos = this.rl.getCursorPos();
4375
+ if (cursorPos.cols !== this.cursorPos.cols) {
4376
+ this.write(cursorTo(cursorPos.cols));
4377
+ this.cursorPos = cursorPos;
4378
+ }
4379
+ }
4380
+ done({ clearContent }) {
4381
+ this.rl.setPrompt("");
4382
+ let output = cursorDown(this.extraLinesUnderPrompt);
4383
+ output += clearContent ? eraseLines(this.height) : `
4384
+ `;
4385
+ output += cursorShow;
4386
+ this.write(output);
4387
+ this.rl.close();
4388
+ }
4389
+ }
4390
+
4391
+ // node_modules/@inquirer/core/dist/lib/promise-polyfill.js
4392
+ class PromisePolyfill extends Promise {
4393
+ static withResolver() {
4394
+ let resolve;
4395
+ let reject;
4396
+ const promise = new Promise((res, rej) => {
4397
+ resolve = res;
4398
+ reject = rej;
4399
+ });
4400
+ return { promise, resolve, reject };
4401
+ }
4402
+ }
4403
+
4404
+ // node_modules/@inquirer/core/dist/lib/create-prompt.js
4405
+ var nativeSetImmediate = globalThis.setImmediate;
4406
+ function getCallSites() {
4407
+ const _prepareStackTrace = Error.prepareStackTrace;
4408
+ let result = [];
4409
+ try {
4410
+ Error.prepareStackTrace = (_, callSites) => {
4411
+ const callSitesWithoutCurrent = callSites.slice(1);
4412
+ result = callSitesWithoutCurrent;
4413
+ return callSitesWithoutCurrent;
4414
+ };
4415
+ new Error().stack;
4416
+ } catch {
4417
+ return result;
4418
+ }
4419
+ Error.prepareStackTrace = _prepareStackTrace;
4420
+ return result;
4421
+ }
4422
+ function createPrompt(view) {
4423
+ const callSites = getCallSites();
4424
+ const prompt = (config, context = {}) => {
4425
+ const { input = process.stdin, signal } = context;
4426
+ const cleanups = new Set;
4427
+ const output = new import_mute_stream.default;
4428
+ output.pipe(context.output ?? process.stdout);
4429
+ output.mute();
4430
+ const rl = readline2.createInterface({
4431
+ terminal: true,
4432
+ input,
4433
+ output
4434
+ });
4435
+ const screen = new ScreenManager(rl);
4436
+ const { promise, resolve, reject } = PromisePolyfill.withResolver();
4437
+ const cancel = () => reject(new CancelPromptError);
4438
+ if (signal) {
4439
+ const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
4440
+ if (signal.aborted) {
4441
+ abort();
4442
+ return Object.assign(promise, { cancel });
4443
+ }
4444
+ signal.addEventListener("abort", abort);
4445
+ cleanups.add(() => signal.removeEventListener("abort", abort));
4446
+ }
4447
+ cleanups.add(onExit((code, signal2) => {
4448
+ reject(new ExitPromptError(`User force closed the prompt with ${code} ${signal2}`));
4449
+ }));
4450
+ const sigint = () => reject(new ExitPromptError(`User force closed the prompt with SIGINT`));
4451
+ rl.on("SIGINT", sigint);
4452
+ cleanups.add(() => rl.removeListener("SIGINT", sigint));
4453
+ return withHooks(rl, (cycle) => {
4454
+ const hooksCleanup = AsyncResource3.bind(() => effectScheduler.clearAll());
4455
+ rl.on("close", hooksCleanup);
4456
+ cleanups.add(() => rl.removeListener("close", hooksCleanup));
4457
+ const startCycle = () => {
4458
+ const checkCursorPos = () => screen.checkCursorPos();
4459
+ rl.input.on("keypress", checkCursorPos);
4460
+ cleanups.add(() => rl.input.removeListener("keypress", checkCursorPos));
4461
+ cycle(() => {
4462
+ try {
4463
+ const nextView = view(config, (value) => {
4464
+ setImmediate(() => resolve(value));
4465
+ });
4466
+ if (nextView === undefined) {
4467
+ const callerFilename = callSites[1]?.getFileName();
4468
+ throw new Error(`Prompt functions must return a string.
4469
+ at ${callerFilename}`);
4470
+ }
4471
+ const [content, bottomContent] = typeof nextView === "string" ? [nextView] : nextView;
4472
+ screen.render(content, bottomContent);
4473
+ effectScheduler.run();
4474
+ } catch (error) {
4475
+ reject(error);
4476
+ }
4477
+ });
4478
+ };
4479
+ if ("readableFlowing" in input) {
4480
+ nativeSetImmediate(startCycle);
4481
+ } else {
4482
+ startCycle();
4483
+ }
4484
+ return Object.assign(promise.then((answer) => {
4485
+ effectScheduler.clearAll();
4486
+ return answer;
4487
+ }, (error) => {
4488
+ effectScheduler.clearAll();
4489
+ throw error;
4490
+ }).finally(() => {
4491
+ cleanups.forEach((cleanup) => cleanup());
4492
+ screen.done({ clearContent: Boolean(context.clearPromptOnDone) });
4493
+ output.end();
4494
+ }).then(() => promise), { cancel });
4495
+ });
4496
+ };
4497
+ return prompt;
4498
+ }
4499
+ // node_modules/@inquirer/core/dist/lib/Separator.js
4500
+ import { styleText as styleText2 } from "node:util";
4501
+ class Separator {
4502
+ separator = styleText2("dim", Array.from({ length: 15 }).join(dist_default.line));
4503
+ type = "separator";
4504
+ constructor(separator) {
4505
+ if (separator) {
4506
+ this.separator = separator;
4507
+ }
4508
+ }
4509
+ static isSeparator(choice) {
4510
+ return Boolean(choice && typeof choice === "object" && "type" in choice && choice.type === "separator");
4511
+ }
4512
+ }
4513
+ // node_modules/@inquirer/confirm/dist/index.js
4514
+ function getBooleanValue(value, defaultValue) {
4515
+ let answer = defaultValue !== false;
4516
+ if (/^(y|yes)/i.test(value))
4517
+ answer = true;
4518
+ else if (/^(n|no)/i.test(value))
4519
+ answer = false;
4520
+ return answer;
4521
+ }
4522
+ function boolToString(value) {
4523
+ return value ? "Yes" : "No";
4524
+ }
4525
+ var dist_default4 = createPrompt((config, done) => {
4526
+ const { transformer = boolToString } = config;
4527
+ const [status, setStatus] = useState("idle");
4528
+ const [value, setValue] = useState("");
4529
+ const theme2 = makeTheme(config.theme);
4530
+ const prefix = usePrefix({ status, theme: theme2 });
4531
+ useKeypress((key, rl) => {
4532
+ if (status !== "idle")
4533
+ return;
4534
+ if (isEnterKey(key)) {
4535
+ const answer = getBooleanValue(value, config.default);
4536
+ setValue(transformer(answer));
4537
+ setStatus("done");
4538
+ done(answer);
4539
+ } else if (isTabKey(key)) {
4540
+ const answer = boolToString(!getBooleanValue(value, config.default));
4541
+ rl.clearLine(0);
4542
+ rl.write(answer);
4543
+ setValue(answer);
4544
+ } else {
4545
+ setValue(rl.line);
4546
+ }
4547
+ });
4548
+ let formattedValue = value;
4549
+ let defaultValue = "";
4550
+ if (status === "done") {
4551
+ formattedValue = theme2.style.answer(value);
4552
+ } else {
4553
+ defaultValue = ` ${theme2.style.defaultAnswer(config.default === false ? "y/N" : "Y/n")}`;
4554
+ }
4555
+ const message = theme2.style.message(config.message, status);
4556
+ return `${prefix} ${message}${defaultValue} ${formattedValue}`;
4557
+ });
4558
+ // node_modules/@inquirer/input/dist/index.js
4559
+ var inputTheme = {
4560
+ validationFailureMode: "keep"
4561
+ };
4562
+ var dist_default5 = createPrompt((config, done) => {
4563
+ const { prefill = "tab" } = config;
4564
+ const theme2 = makeTheme(inputTheme, config.theme);
4565
+ const [status, setStatus] = useState("idle");
4566
+ const [defaultValue, setDefaultValue] = useState(String(config.default ?? ""));
4567
+ const [errorMsg, setError] = useState();
4568
+ const [value, setValue] = useState("");
4569
+ const prefix = usePrefix({ status, theme: theme2 });
4570
+ async function validate(value2) {
4571
+ const { required, pattern, patternError = "Invalid input" } = config;
4572
+ if (required && !value2) {
4573
+ return "You must provide a value";
4574
+ }
4575
+ if (pattern && !pattern.test(value2)) {
4576
+ return patternError;
4577
+ }
4578
+ if (typeof config.validate === "function") {
4579
+ return await config.validate(value2) || "You must provide a valid value";
4580
+ }
4581
+ return true;
4582
+ }
4583
+ useKeypress(async (key, rl) => {
4584
+ if (status !== "idle") {
4585
+ return;
4586
+ }
4587
+ if (isEnterKey(key)) {
4588
+ const answer = value || defaultValue;
4589
+ setStatus("loading");
4590
+ const isValid = await validate(answer);
4591
+ if (isValid === true) {
4592
+ setValue(answer);
4593
+ setStatus("done");
4594
+ done(answer);
4595
+ } else {
4596
+ if (theme2.validationFailureMode === "clear") {
4597
+ setValue("");
4598
+ } else {
4599
+ rl.write(value);
4600
+ }
4601
+ setError(isValid);
4602
+ setStatus("idle");
4603
+ }
4604
+ } else if (isBackspaceKey(key) && !value) {
4605
+ setDefaultValue("");
4606
+ } else if (isTabKey(key) && !value) {
4607
+ setDefaultValue("");
4608
+ rl.clearLine(0);
4609
+ rl.write(defaultValue);
4610
+ setValue(defaultValue);
4611
+ } else {
4612
+ setValue(rl.line);
4613
+ setError(undefined);
4614
+ }
4615
+ });
4616
+ useEffect((rl) => {
4617
+ if (prefill === "editable" && defaultValue) {
4618
+ rl.write(defaultValue);
4619
+ setValue(defaultValue);
4620
+ }
4621
+ }, []);
4622
+ const message = theme2.style.message(config.message, status);
4623
+ let formattedValue = value;
4624
+ if (typeof config.transformer === "function") {
4625
+ formattedValue = config.transformer(value, { isFinal: status === "done" });
4626
+ } else if (status === "done") {
4627
+ formattedValue = theme2.style.answer(value);
4628
+ }
4629
+ let defaultStr;
4630
+ if (defaultValue && status !== "done" && !value) {
4631
+ defaultStr = theme2.style.defaultAnswer(defaultValue);
4632
+ }
4633
+ let error = "";
4634
+ if (errorMsg) {
4635
+ error = theme2.style.error(errorMsg);
4636
+ }
4637
+ return [
4638
+ [prefix, message, defaultStr, formattedValue].filter((v) => v !== undefined).join(" "),
4639
+ error
4640
+ ];
4641
+ });
4642
+ // node_modules/@inquirer/password/dist/index.js
4643
+ var passwordTheme = {
4644
+ style: {
4645
+ maskedText: "[input is masked]"
4646
+ }
4647
+ };
4648
+ var dist_default6 = createPrompt((config, done) => {
4649
+ const { validate = () => true } = config;
4650
+ const theme2 = makeTheme(passwordTheme, config.theme);
4651
+ const [status, setStatus] = useState("idle");
4652
+ const [errorMsg, setError] = useState();
4653
+ const [value, setValue] = useState("");
4654
+ const prefix = usePrefix({ status, theme: theme2 });
4655
+ useKeypress(async (key, rl) => {
4656
+ if (status !== "idle") {
4657
+ return;
4658
+ }
4659
+ if (isEnterKey(key)) {
4660
+ const answer = value;
4661
+ setStatus("loading");
4662
+ const isValid = await validate(answer);
4663
+ if (isValid === true) {
4664
+ setValue(answer);
4665
+ setStatus("done");
4666
+ done(answer);
4667
+ } else {
4668
+ rl.write(value);
4669
+ setError(isValid || "You must provide a valid value");
4670
+ setStatus("idle");
4671
+ }
4672
+ } else {
4673
+ setValue(rl.line);
4674
+ setError(undefined);
4675
+ }
4676
+ });
4677
+ const message = theme2.style.message(config.message, status);
4678
+ let formattedValue = "";
4679
+ let helpTip;
4680
+ if (config.mask) {
4681
+ const maskChar = typeof config.mask === "string" ? config.mask : "*";
4682
+ formattedValue = maskChar.repeat(value.length);
4683
+ } else if (status !== "done") {
4684
+ helpTip = `${theme2.style.help(theme2.style.maskedText)}${cursorHide}`;
4685
+ }
4686
+ if (status === "done") {
4687
+ formattedValue = theme2.style.answer(formattedValue);
4688
+ }
4689
+ let error = "";
4690
+ if (errorMsg) {
4691
+ error = theme2.style.error(errorMsg);
4692
+ }
4693
+ return [[prefix, message, config.mask ? formattedValue : helpTip].join(" "), error];
4694
+ });
4695
+ // node_modules/@inquirer/select/dist/index.js
4696
+ import { styleText as styleText3 } from "node:util";
4697
+ var selectTheme = {
4698
+ icon: { cursor: dist_default.pointer },
4699
+ style: {
4700
+ disabled: (text) => styleText3("dim", text),
4701
+ description: (text) => styleText3("cyan", text),
4702
+ keysHelpTip: (keys) => keys.map(([key, action]) => `${styleText3("bold", key)} ${styleText3("dim", action)}`).join(styleText3("dim", " • "))
4703
+ },
4704
+ i18n: { disabledError: "This option is disabled and cannot be selected." },
4705
+ indexMode: "hidden",
4706
+ keybindings: []
4707
+ };
4708
+ function isSelectable(item) {
4709
+ return !Separator.isSeparator(item) && !item.disabled;
4710
+ }
4711
+ function isNavigable(item) {
4712
+ return !Separator.isSeparator(item);
4713
+ }
4714
+ function normalizeChoices(choices) {
4715
+ return choices.map((choice) => {
4716
+ if (Separator.isSeparator(choice))
4717
+ return choice;
4718
+ if (typeof choice !== "object" || choice === null || !("value" in choice)) {
4719
+ const name2 = String(choice);
4720
+ return {
4721
+ value: choice,
4722
+ name: name2,
4723
+ short: name2,
4724
+ disabled: false
4725
+ };
4726
+ }
4727
+ const name = choice.name ?? String(choice.value);
4728
+ const normalizedChoice = {
4729
+ value: choice.value,
4730
+ name,
4731
+ short: choice.short ?? name,
4732
+ disabled: choice.disabled ?? false
4733
+ };
4734
+ if (choice.description) {
4735
+ normalizedChoice.description = choice.description;
4736
+ }
4737
+ return normalizedChoice;
4738
+ });
4739
+ }
4740
+ var dist_default7 = createPrompt((config, done) => {
4741
+ const { loop = true, pageSize = 7 } = config;
4742
+ const theme2 = makeTheme(selectTheme, config.theme);
4743
+ const { keybindings } = theme2;
4744
+ const [status, setStatus] = useState("idle");
4745
+ const prefix = usePrefix({ status, theme: theme2 });
4746
+ const searchTimeoutRef = useRef();
4747
+ const searchEnabled = !keybindings.includes("vim");
4748
+ const items = useMemo(() => normalizeChoices(config.choices), [config.choices]);
4749
+ const bounds = useMemo(() => {
4750
+ const first = items.findIndex(isNavigable);
4751
+ const last = items.findLastIndex(isNavigable);
4752
+ if (first === -1) {
4753
+ throw new ValidationError("[select prompt] No selectable choices. All choices are disabled.");
4754
+ }
4755
+ return { first, last };
4756
+ }, [items]);
4757
+ const defaultItemIndex = useMemo(() => {
4758
+ if (!("default" in config))
4759
+ return -1;
4760
+ return items.findIndex((item) => isSelectable(item) && item.value === config.default);
4761
+ }, [config.default, items]);
4762
+ const [active, setActive] = useState(defaultItemIndex === -1 ? bounds.first : defaultItemIndex);
4763
+ const selectedChoice = items[active];
4764
+ const [errorMsg, setError] = useState();
4765
+ useKeypress((key, rl) => {
4766
+ clearTimeout(searchTimeoutRef.current);
4767
+ if (errorMsg) {
4768
+ setError(undefined);
4769
+ }
4770
+ if (isEnterKey(key)) {
4771
+ if (selectedChoice.disabled) {
4772
+ setError(theme2.i18n.disabledError);
4773
+ } else {
4774
+ setStatus("done");
4775
+ done(selectedChoice.value);
4776
+ }
4777
+ } else if (isUpKey(key, keybindings) || isDownKey(key, keybindings)) {
4778
+ rl.clearLine(0);
4779
+ if (loop || isUpKey(key, keybindings) && active !== bounds.first || isDownKey(key, keybindings) && active !== bounds.last) {
4780
+ const offset = isUpKey(key, keybindings) ? -1 : 1;
4781
+ let next = active;
4782
+ do {
4783
+ next = (next + offset + items.length) % items.length;
4784
+ } while (!isNavigable(items[next]));
4785
+ setActive(next);
4786
+ }
4787
+ } else if (isNumberKey(key) && !Number.isNaN(Number(rl.line))) {
4788
+ const selectedIndex = Number(rl.line) - 1;
4789
+ let selectableIndex = -1;
4790
+ const position = items.findIndex((item2) => {
4791
+ if (Separator.isSeparator(item2))
4792
+ return false;
4793
+ selectableIndex++;
4794
+ return selectableIndex === selectedIndex;
4795
+ });
4796
+ const item = items[position];
4797
+ if (item != null && isSelectable(item)) {
4798
+ setActive(position);
4799
+ }
4800
+ searchTimeoutRef.current = setTimeout(() => {
4801
+ rl.clearLine(0);
4802
+ }, 700);
4803
+ } else if (isBackspaceKey(key)) {
4804
+ rl.clearLine(0);
4805
+ } else if (searchEnabled) {
4806
+ const searchTerm = rl.line.toLowerCase();
4807
+ const matchIndex = items.findIndex((item) => {
4808
+ if (Separator.isSeparator(item) || !isSelectable(item))
4809
+ return false;
4810
+ return item.name.toLowerCase().startsWith(searchTerm);
4811
+ });
4812
+ if (matchIndex !== -1) {
4813
+ setActive(matchIndex);
4814
+ }
4815
+ searchTimeoutRef.current = setTimeout(() => {
4816
+ rl.clearLine(0);
4817
+ }, 700);
4818
+ }
4819
+ });
4820
+ useEffect(() => () => {
4821
+ clearTimeout(searchTimeoutRef.current);
4822
+ }, []);
4823
+ const message = theme2.style.message(config.message, status);
4824
+ const helpLine = theme2.style.keysHelpTip([
4825
+ ["↑↓", "navigate"],
4826
+ ["⏎", "select"]
4827
+ ]);
4828
+ let separatorCount = 0;
4829
+ const page = usePagination({
4830
+ items,
4831
+ active,
4832
+ renderItem({ item, isActive, index }) {
4833
+ if (Separator.isSeparator(item)) {
4834
+ separatorCount++;
4835
+ return ` ${item.separator}`;
4836
+ }
4837
+ const cursor = isActive ? theme2.icon.cursor : " ";
4838
+ const indexLabel = theme2.indexMode === "number" ? `${index + 1 - separatorCount}. ` : "";
4839
+ if (item.disabled) {
4840
+ const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
4841
+ const disabledCursor = isActive ? theme2.icon.cursor : "-";
4842
+ return theme2.style.disabled(`${disabledCursor} ${indexLabel}${item.name} ${disabledLabel}`);
4843
+ }
4844
+ const color = isActive ? theme2.style.highlight : (x) => x;
4845
+ return color(`${cursor} ${indexLabel}${item.name}`);
4846
+ },
4847
+ pageSize,
4848
+ loop
4849
+ });
4850
+ if (status === "done") {
4851
+ return [prefix, message, theme2.style.answer(selectedChoice.short)].filter(Boolean).join(" ");
4852
+ }
4853
+ const { description } = selectedChoice;
4854
+ const lines = [
4855
+ [prefix, message].filter(Boolean).join(" "),
4856
+ page,
4857
+ " ",
4858
+ description ? theme2.style.description(description) : "",
4859
+ errorMsg ? theme2.style.error(errorMsg) : "",
4860
+ helpLine
4861
+ ].filter(Boolean).join(`
4862
+ `).trimEnd();
4863
+ return `${lines}${cursorHide}`;
4864
+ });
4865
+ // src/ui/wizard.ts
4866
+ async function promptMcpClient() {
4867
+ return await dist_default7({
4868
+ message: "Which MCP client are you using?",
4869
+ choices: [
4870
+ { name: "Antigravity", value: "antigravity" },
4871
+ { name: "VSCode", value: "vscode" },
4872
+ { name: "Cursor", value: "cursor" },
4873
+ { name: "Claude Code", value: "claude-code" },
4874
+ { name: "Gemini CLI", value: "gemini-cli" },
4875
+ { name: "Codex CLI", value: "codex" },
4876
+ { name: "OpenCode", value: "opencode" }
4877
+ ]
4878
+ });
4879
+ }
4880
+ async function promptAuthMode() {
4881
+ return await dist_default7({
4882
+ message: "Select Authentication Mode:",
4883
+ choices: [
4884
+ {
4885
+ name: "API Key",
4886
+ value: "apiKey",
4887
+ description: "Persistent keys generated in the Stitch Settings page."
4888
+ },
4889
+ {
4890
+ name: "OAuth",
4891
+ value: "oauth",
4892
+ description: "A browser-based authentication flow required by specific AI clients that do not support manual key entry, or for environments where storing persistent secrets on disk is restricted."
4893
+ }
4894
+ ]
4895
+ });
4896
+ }
4897
+ async function promptApiKeyStorage() {
4898
+ return await dist_default7({
4899
+ message: "Where would you like to store your API Key?",
4900
+ choices: [
4901
+ {
4902
+ name: ".env file",
4903
+ value: ".env",
4904
+ description: "Use the current working directory. Append if existing, create if not."
4905
+ },
4906
+ {
4907
+ name: "MCP config",
4908
+ value: "config",
4909
+ description: "Add it to the final MCP config to copy and paste."
4910
+ },
4911
+ {
4912
+ name: "Skip",
4913
+ value: "skip",
4914
+ description: "Use a placeholder in the final config."
4915
+ }
4916
+ ]
4917
+ });
4918
+ }
4919
+ async function promptApiKey() {
4920
+ return await dist_default6({
4921
+ message: "Enter your Stitch API Key:",
4922
+ mask: "*"
4923
+ });
4924
+ }
4925
+ async function promptSelect(message, choices) {
4926
+ return await dist_default7({ message, choices });
4927
+ }
4928
+ async function promptInput(message, defaultValue) {
4929
+ return await dist_default5({ message, default: defaultValue });
4930
+ }
4931
+ async function promptConfirm(message, defaultValue = true) {
4932
+ return await dist_default4({ message, default: defaultValue });
4933
+ }
4934
+ async function promptTransportType(authMode = "oauth") {
4935
+ const isApiKey = authMode === "apiKey";
4936
+ return await dist_default7({
4937
+ message: "How would you like to connect to Stitch?",
4938
+ choices: [
4939
+ {
4940
+ name: "Direct (Standard)",
4941
+ value: "http",
4942
+ description: isApiKey ? "You or the IDE/CLI handles the loading of the API key." : "Standard HTTP. Production-ready. Requires manual OAuth token management."
4943
+ },
4944
+ {
4945
+ name: "Proxy (Recommended for Dev)",
4946
+ value: "stdio",
4947
+ description: isApiKey ? "stitch-mcp will manage the loading of the API key." : "Zero-config. Uses a local bridge to auto-refresh gcloud credentials."
4948
+ }
4949
+ ]
4950
+ });
4951
+ }
4952
+
4953
+ // src/framework/ConsoleUI.ts
4954
+ class ConsoleUI {
4955
+ async promptMcpClient() {
4956
+ return promptMcpClient();
4957
+ }
4958
+ async promptAuthMode() {
4959
+ return promptAuthMode();
4960
+ }
4961
+ async promptTransportType(authMode) {
4962
+ return promptTransportType(authMode);
4963
+ }
4964
+ async promptApiKeyStorage() {
4965
+ return promptApiKeyStorage();
4966
+ }
4967
+ async promptApiKey() {
4968
+ return promptApiKey();
4969
+ }
4970
+ async promptConfirm(message, defaultYes) {
4971
+ return promptConfirm(message, defaultYes);
4972
+ }
4973
+ log(message) {
4974
+ console.log(message);
4975
+ }
4976
+ warn(message) {
4977
+ console.log(theme.yellow(message));
4978
+ }
4979
+ error(message) {
4980
+ console.error(theme.red(message));
4981
+ }
4982
+ success(message) {
4983
+ console.log(theme.green(message));
4984
+ }
4985
+ }
4986
+
4987
+ export { getGcloudConfigPath, execCommand, joinPath, GcloudExecutor, GcloudHandler, promptSelect, promptInput, promptConfirm, ConsoleUI };
4988
+
4989
+ //# debugId=00C61AAC32145D5C64756E2164756E21