create-grocms 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,3966 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __grocmsCreateRequire } from "node:module"; const require = __grocmsCreateRequire(import.meta.url);
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
10
+ get: (a3, b3) => (typeof require !== "undefined" ? require : a3)[b3]
11
+ }) : x2)(function(x2) {
12
+ if (typeof require !== "undefined") return require.apply(this, arguments);
13
+ throw Error('Dynamic require of "' + x2 + '" is not supported');
14
+ });
15
+ var __commonJS = (cb, mod) => function __require2() {
16
+ try {
17
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
18
+ } catch (e2) {
19
+ throw mod = 0, e2;
20
+ }
21
+ };
22
+ var __copyProps = (to, from, except, desc) => {
23
+ if (from && typeof from === "object" || typeof from === "function") {
24
+ for (let key of __getOwnPropNames(from))
25
+ if (!__hasOwnProp.call(to, key) && key !== except)
26
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
27
+ }
28
+ return to;
29
+ };
30
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
31
+ // If the importer is in node compatibility mode or this is not an ESM
32
+ // file that has been converted to a CommonJS file using a Babel-
33
+ // compatible transform (i.e. "__esModule" has not been set), then set
34
+ // "default" to the CommonJS "module.exports" for node compatibility.
35
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
36
+ mod
37
+ ));
38
+
39
+ // node_modules/sisteransi/src/index.js
40
+ var require_src = __commonJS({
41
+ "node_modules/sisteransi/src/index.js"(exports, module) {
42
+ "use strict";
43
+ var ESC = "\x1B";
44
+ var CSI = `${ESC}[`;
45
+ var beep = "\x07";
46
+ var cursor = {
47
+ to(x2, y3) {
48
+ if (!y3) return `${CSI}${x2 + 1}G`;
49
+ return `${CSI}${y3 + 1};${x2 + 1}H`;
50
+ },
51
+ move(x2, y3) {
52
+ let ret = "";
53
+ if (x2 < 0) ret += `${CSI}${-x2}D`;
54
+ else if (x2 > 0) ret += `${CSI}${x2}C`;
55
+ if (y3 < 0) ret += `${CSI}${-y3}A`;
56
+ else if (y3 > 0) ret += `${CSI}${y3}B`;
57
+ return ret;
58
+ },
59
+ up: (count = 1) => `${CSI}${count}A`,
60
+ down: (count = 1) => `${CSI}${count}B`,
61
+ forward: (count = 1) => `${CSI}${count}C`,
62
+ backward: (count = 1) => `${CSI}${count}D`,
63
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
64
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
65
+ left: `${CSI}G`,
66
+ hide: `${CSI}?25l`,
67
+ show: `${CSI}?25h`,
68
+ save: `${ESC}7`,
69
+ restore: `${ESC}8`
70
+ };
71
+ var scroll = {
72
+ up: (count = 1) => `${CSI}S`.repeat(count),
73
+ down: (count = 1) => `${CSI}T`.repeat(count)
74
+ };
75
+ var erase = {
76
+ screen: `${CSI}2J`,
77
+ up: (count = 1) => `${CSI}1J`.repeat(count),
78
+ down: (count = 1) => `${CSI}J`.repeat(count),
79
+ line: `${CSI}2K`,
80
+ lineEnd: `${CSI}K`,
81
+ lineStart: `${CSI}1K`,
82
+ lines(count) {
83
+ let clear = "";
84
+ for (let i = 0; i < count; i++)
85
+ clear += this.line + (i < count - 1 ? cursor.up() : "");
86
+ if (count)
87
+ clear += cursor.left;
88
+ return clear;
89
+ }
90
+ };
91
+ module.exports = { cursor, scroll, erase, beep };
92
+ }
93
+ });
94
+
95
+ // node_modules/picocolors/picocolors.js
96
+ var require_picocolors = __commonJS({
97
+ "node_modules/picocolors/picocolors.js"(exports, module) {
98
+ var p = process || {};
99
+ var argv = p.argv || [];
100
+ var env = p.env || {};
101
+ var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
102
+ var formatter = (open2, close, replace = open2) => (input) => {
103
+ let string = "" + input, index = string.indexOf(close, open2.length);
104
+ return ~index ? open2 + replaceClose(string, close, replace, index) + close : open2 + string + close;
105
+ };
106
+ var replaceClose = (string, close, replace, index) => {
107
+ let result = "", cursor = 0;
108
+ do {
109
+ result += string.substring(cursor, index) + replace;
110
+ cursor = index + close.length;
111
+ index = string.indexOf(close, cursor);
112
+ } while (~index);
113
+ return result + string.substring(cursor);
114
+ };
115
+ var createColors = (enabled = isColorSupported) => {
116
+ let f2 = enabled ? formatter : () => String;
117
+ return {
118
+ isColorSupported: enabled,
119
+ reset: f2("\x1B[0m", "\x1B[0m"),
120
+ bold: f2("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
121
+ dim: f2("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
122
+ italic: f2("\x1B[3m", "\x1B[23m"),
123
+ underline: f2("\x1B[4m", "\x1B[24m"),
124
+ inverse: f2("\x1B[7m", "\x1B[27m"),
125
+ hidden: f2("\x1B[8m", "\x1B[28m"),
126
+ strikethrough: f2("\x1B[9m", "\x1B[29m"),
127
+ black: f2("\x1B[30m", "\x1B[39m"),
128
+ red: f2("\x1B[31m", "\x1B[39m"),
129
+ green: f2("\x1B[32m", "\x1B[39m"),
130
+ yellow: f2("\x1B[33m", "\x1B[39m"),
131
+ blue: f2("\x1B[34m", "\x1B[39m"),
132
+ magenta: f2("\x1B[35m", "\x1B[39m"),
133
+ cyan: f2("\x1B[36m", "\x1B[39m"),
134
+ white: f2("\x1B[37m", "\x1B[39m"),
135
+ gray: f2("\x1B[90m", "\x1B[39m"),
136
+ bgBlack: f2("\x1B[40m", "\x1B[49m"),
137
+ bgRed: f2("\x1B[41m", "\x1B[49m"),
138
+ bgGreen: f2("\x1B[42m", "\x1B[49m"),
139
+ bgYellow: f2("\x1B[43m", "\x1B[49m"),
140
+ bgBlue: f2("\x1B[44m", "\x1B[49m"),
141
+ bgMagenta: f2("\x1B[45m", "\x1B[49m"),
142
+ bgCyan: f2("\x1B[46m", "\x1B[49m"),
143
+ bgWhite: f2("\x1B[47m", "\x1B[49m"),
144
+ blackBright: f2("\x1B[90m", "\x1B[39m"),
145
+ redBright: f2("\x1B[91m", "\x1B[39m"),
146
+ greenBright: f2("\x1B[92m", "\x1B[39m"),
147
+ yellowBright: f2("\x1B[93m", "\x1B[39m"),
148
+ blueBright: f2("\x1B[94m", "\x1B[39m"),
149
+ magentaBright: f2("\x1B[95m", "\x1B[39m"),
150
+ cyanBright: f2("\x1B[96m", "\x1B[39m"),
151
+ whiteBright: f2("\x1B[97m", "\x1B[39m"),
152
+ bgBlackBright: f2("\x1B[100m", "\x1B[49m"),
153
+ bgRedBright: f2("\x1B[101m", "\x1B[49m"),
154
+ bgGreenBright: f2("\x1B[102m", "\x1B[49m"),
155
+ bgYellowBright: f2("\x1B[103m", "\x1B[49m"),
156
+ bgBlueBright: f2("\x1B[104m", "\x1B[49m"),
157
+ bgMagentaBright: f2("\x1B[105m", "\x1B[49m"),
158
+ bgCyanBright: f2("\x1B[106m", "\x1B[49m"),
159
+ bgWhiteBright: f2("\x1B[107m", "\x1B[49m")
160
+ };
161
+ };
162
+ module.exports = createColors();
163
+ module.exports.createColors = createColors;
164
+ }
165
+ });
166
+
167
+ // node_modules/adm-zip/util/constants.js
168
+ var require_constants = __commonJS({
169
+ "node_modules/adm-zip/util/constants.js"(exports, module) {
170
+ module.exports = {
171
+ /* The local file header */
172
+ LOCHDR: 30,
173
+ // LOC header size
174
+ LOCSIG: 67324752,
175
+ // "PK\003\004"
176
+ LOCVER: 4,
177
+ // version needed to extract
178
+ LOCFLG: 6,
179
+ // general purpose bit flag
180
+ LOCHOW: 8,
181
+ // compression method
182
+ LOCTIM: 10,
183
+ // modification time (2 bytes time, 2 bytes date)
184
+ LOCCRC: 14,
185
+ // uncompressed file crc-32 value
186
+ LOCSIZ: 18,
187
+ // compressed size
188
+ LOCLEN: 22,
189
+ // uncompressed size
190
+ LOCNAM: 26,
191
+ // filename length
192
+ LOCEXT: 28,
193
+ // extra field length
194
+ /* The Data descriptor */
195
+ EXTSIG: 134695760,
196
+ // "PK\007\008"
197
+ EXTHDR: 16,
198
+ // EXT header size
199
+ EXTCRC: 4,
200
+ // uncompressed file crc-32 value
201
+ EXTSIZ: 8,
202
+ // compressed size
203
+ EXTLEN: 12,
204
+ // uncompressed size
205
+ /* The central directory file header */
206
+ CENHDR: 46,
207
+ // CEN header size
208
+ CENSIG: 33639248,
209
+ // "PK\001\002"
210
+ CENVEM: 4,
211
+ // version made by
212
+ CENVER: 6,
213
+ // version needed to extract
214
+ CENFLG: 8,
215
+ // encrypt, decrypt flags
216
+ CENHOW: 10,
217
+ // compression method
218
+ CENTIM: 12,
219
+ // modification time (2 bytes time, 2 bytes date)
220
+ CENCRC: 16,
221
+ // uncompressed file crc-32 value
222
+ CENSIZ: 20,
223
+ // compressed size
224
+ CENLEN: 24,
225
+ // uncompressed size
226
+ CENNAM: 28,
227
+ // filename length
228
+ CENEXT: 30,
229
+ // extra field length
230
+ CENCOM: 32,
231
+ // file comment length
232
+ CENDSK: 34,
233
+ // volume number start
234
+ CENATT: 36,
235
+ // internal file attributes
236
+ CENATX: 38,
237
+ // external file attributes (host system dependent)
238
+ CENOFF: 42,
239
+ // LOC header offset
240
+ /* The entries in the end of central directory */
241
+ ENDHDR: 22,
242
+ // END header size
243
+ ENDSIG: 101010256,
244
+ // "PK\005\006"
245
+ ENDSUB: 8,
246
+ // number of entries on this disk
247
+ ENDTOT: 10,
248
+ // total number of entries
249
+ ENDSIZ: 12,
250
+ // central directory size in bytes
251
+ ENDOFF: 16,
252
+ // offset of first CEN header
253
+ ENDCOM: 20,
254
+ // zip file comment length
255
+ END64HDR: 20,
256
+ // zip64 END header size
257
+ END64SIG: 117853008,
258
+ // zip64 Locator signature, "PK\006\007"
259
+ END64START: 4,
260
+ // number of the disk with the start of the zip64
261
+ END64OFF: 8,
262
+ // relative offset of the zip64 end of central directory
263
+ END64NUMDISKS: 16,
264
+ // total number of disks
265
+ ZIP64SIG: 101075792,
266
+ // zip64 signature, "PK\006\006"
267
+ ZIP64HDR: 56,
268
+ // zip64 record minimum size
269
+ ZIP64LEAD: 12,
270
+ // leading bytes at the start of the record, not counted by the value stored in ZIP64SIZE
271
+ ZIP64SIZE: 4,
272
+ // zip64 size of the central directory record
273
+ ZIP64VEM: 12,
274
+ // zip64 version made by
275
+ ZIP64VER: 14,
276
+ // zip64 version needed to extract
277
+ ZIP64DSK: 16,
278
+ // zip64 number of this disk
279
+ ZIP64DSKDIR: 20,
280
+ // number of the disk with the start of the record directory
281
+ ZIP64SUB: 24,
282
+ // number of entries on this disk
283
+ ZIP64TOT: 32,
284
+ // total number of entries
285
+ ZIP64SIZB: 40,
286
+ // zip64 central directory size in bytes
287
+ ZIP64OFF: 48,
288
+ // offset of start of central directory with respect to the starting disk number
289
+ ZIP64EXTRA: 56,
290
+ // extensible data sector
291
+ /* Compression methods */
292
+ STORED: 0,
293
+ // no compression
294
+ SHRUNK: 1,
295
+ // shrunk
296
+ REDUCED1: 2,
297
+ // reduced with compression factor 1
298
+ REDUCED2: 3,
299
+ // reduced with compression factor 2
300
+ REDUCED3: 4,
301
+ // reduced with compression factor 3
302
+ REDUCED4: 5,
303
+ // reduced with compression factor 4
304
+ IMPLODED: 6,
305
+ // imploded
306
+ // 7 reserved for Tokenizing compression algorithm
307
+ DEFLATED: 8,
308
+ // deflated
309
+ ENHANCED_DEFLATED: 9,
310
+ // enhanced deflated
311
+ PKWARE: 10,
312
+ // PKWare DCL imploded
313
+ // 11 reserved by PKWARE
314
+ BZIP2: 12,
315
+ // compressed using BZIP2
316
+ // 13 reserved by PKWARE
317
+ LZMA: 14,
318
+ // LZMA
319
+ // 15-17 reserved by PKWARE
320
+ IBM_TERSE: 18,
321
+ // compressed using IBM TERSE
322
+ IBM_LZ77: 19,
323
+ // IBM LZ77 z
324
+ AES_ENCRYPT: 99,
325
+ // WinZIP AES encryption method
326
+ /* General purpose bit flag */
327
+ // values can obtained with expression 2**bitnr
328
+ FLG_ENC: 1,
329
+ // Bit 0: encrypted file
330
+ FLG_COMP1: 2,
331
+ // Bit 1, compression option
332
+ FLG_COMP2: 4,
333
+ // Bit 2, compression option
334
+ FLG_DESC: 8,
335
+ // Bit 3, data descriptor
336
+ FLG_ENH: 16,
337
+ // Bit 4, enhanced deflating
338
+ FLG_PATCH: 32,
339
+ // Bit 5, indicates that the file is compressed patched data.
340
+ FLG_STR: 64,
341
+ // Bit 6, strong encryption (patented)
342
+ // Bits 7-10: Currently unused.
343
+ FLG_EFS: 2048,
344
+ // Bit 11: Language encoding flag (EFS)
345
+ // Bit 12: Reserved by PKWARE for enhanced compression.
346
+ // Bit 13: encrypted the Central Directory (patented).
347
+ // Bits 14-15: Reserved by PKWARE.
348
+ FLG_MSK: 4096,
349
+ // mask header values
350
+ /* Load type */
351
+ FILE: 2,
352
+ BUFFER: 1,
353
+ NONE: 0,
354
+ /* 4.5 Extensible data fields */
355
+ EF_ID: 0,
356
+ EF_SIZE: 2,
357
+ /* Header IDs */
358
+ ID_ZIP64: 1,
359
+ ID_AVINFO: 7,
360
+ ID_PFS: 8,
361
+ ID_OS2: 9,
362
+ ID_NTFS: 10,
363
+ ID_OPENVMS: 12,
364
+ ID_UNIX: 13,
365
+ ID_FORK: 14,
366
+ ID_PATCH: 15,
367
+ ID_X509_PKCS7: 20,
368
+ ID_X509_CERTID_F: 21,
369
+ ID_X509_CERTID_C: 22,
370
+ ID_STRONGENC: 23,
371
+ ID_RECORD_MGT: 24,
372
+ ID_X509_PKCS7_RL: 25,
373
+ ID_IBM1: 101,
374
+ ID_IBM2: 102,
375
+ ID_POSZIP: 18064,
376
+ EF_ZIP64_OR_32: 4294967295,
377
+ EF_ZIP64_OR_16: 65535,
378
+ EF_ZIP64_SUNCOMP: 0,
379
+ EF_ZIP64_SCOMP: 8,
380
+ EF_ZIP64_RHO: 16,
381
+ EF_ZIP64_DSN: 24
382
+ };
383
+ }
384
+ });
385
+
386
+ // node_modules/adm-zip/util/errors.js
387
+ var require_errors = __commonJS({
388
+ "node_modules/adm-zip/util/errors.js"(exports) {
389
+ var errors = {
390
+ /* Header error messages */
391
+ INVALID_LOC: "Invalid LOC header (bad signature)",
392
+ INVALID_CEN: "Invalid CEN header (bad signature)",
393
+ INVALID_END: "Invalid END header (bad signature)",
394
+ /* Descriptor */
395
+ DESCRIPTOR_NOT_EXIST: "No descriptor present",
396
+ DESCRIPTOR_UNKNOWN: "Unknown descriptor format",
397
+ DESCRIPTOR_FAULTY: "Descriptor data is malformed",
398
+ /* ZipEntry error messages*/
399
+ NO_DATA: "Nothing to decompress",
400
+ BAD_CRC: "CRC32 checksum failed {0}",
401
+ MAX_OUTPUT_EXCEEDED: "Decompressed data exceeds the declared uncompressed size",
402
+ FILE_IN_THE_WAY: "There is a file in the way: {0}",
403
+ UNKNOWN_METHOD: "Invalid/unsupported compression method",
404
+ /* Inflater error messages */
405
+ AVAIL_DATA: "inflate::Available inflate data did not terminate",
406
+ INVALID_DISTANCE: "inflate::Invalid literal/length or distance code in fixed or dynamic block",
407
+ TO_MANY_CODES: "inflate::Dynamic block code description: too many length or distance codes",
408
+ INVALID_REPEAT_LEN: "inflate::Dynamic block code description: repeat more than specified lengths",
409
+ INVALID_REPEAT_FIRST: "inflate::Dynamic block code description: repeat lengths with no first length",
410
+ INCOMPLETE_CODES: "inflate::Dynamic block code description: code lengths codes incomplete",
411
+ INVALID_DYN_DISTANCE: "inflate::Dynamic block code description: invalid distance code lengths",
412
+ INVALID_CODES_LEN: "inflate::Dynamic block code description: invalid literal/length code lengths",
413
+ INVALID_STORE_BLOCK: "inflate::Stored block length did not match one's complement",
414
+ INVALID_BLOCK_TYPE: "inflate::Invalid block type (type == 3)",
415
+ /* ADM-ZIP error messages */
416
+ CANT_EXTRACT_FILE: "Could not extract the file",
417
+ CANT_OVERRIDE: "Target file already exists",
418
+ DISK_ENTRY_TOO_LARGE: "Number of disk entries is too large",
419
+ NO_ZIP: "No zip file was loaded",
420
+ NO_ENTRY: "Entry doesn't exist",
421
+ DUPLICATE_ENTRY: "Duplicate entry name {0}",
422
+ DIRECTORY_CONTENT_ERROR: "A directory cannot have content",
423
+ FILE_NOT_FOUND: 'File not found: "{0}"',
424
+ NOT_IMPLEMENTED: "Not implemented",
425
+ INVALID_FILENAME: "Invalid filename",
426
+ INVALID_FORMAT: "Invalid or unsupported zip format. No END header found",
427
+ ZIP64_VALUE_TOO_LARGE: "Zip64 value exceeds the maximum safe integer",
428
+ INVALID_PASS_PARAM: "Incompatible password parameter",
429
+ WRONG_PASSWORD: "Wrong Password",
430
+ /* ADM-ZIP */
431
+ COMMENT_TOO_LONG: "Comment is too long",
432
+ // Comment can be max 65535 bytes long (NOTE: some non-US characters may take more space)
433
+ EXTRA_FIELD_PARSE_ERROR: "Extra field parsing error"
434
+ };
435
+ function E(message) {
436
+ return function(...args) {
437
+ if (args.length) {
438
+ message = message.replace(/\{(\d)\}/g, (_3, n) => args[n] || "");
439
+ }
440
+ return new Error("ADM-ZIP: " + message);
441
+ };
442
+ }
443
+ for (const msg of Object.keys(errors)) {
444
+ exports[msg] = E(errors[msg]);
445
+ }
446
+ }
447
+ });
448
+
449
+ // node_modules/adm-zip/util/utils.js
450
+ var require_utils = __commonJS({
451
+ "node_modules/adm-zip/util/utils.js"(exports, module) {
452
+ var fsystem = __require("fs");
453
+ var pth = __require("path");
454
+ var Constants = require_constants();
455
+ var Errors = require_errors();
456
+ var isWin = typeof process === "object" && "win32" === process.platform;
457
+ var is_Obj = (obj) => typeof obj === "object" && obj !== null;
458
+ var crcTable = new Uint32Array(256).map((t, c2) => {
459
+ for (let k3 = 0; k3 < 8; k3++) {
460
+ if ((c2 & 1) !== 0) {
461
+ c2 = 3988292384 ^ c2 >>> 1;
462
+ } else {
463
+ c2 >>>= 1;
464
+ }
465
+ }
466
+ return c2 >>> 0;
467
+ });
468
+ function Utils(opts) {
469
+ this.sep = pth.sep;
470
+ this.fs = fsystem;
471
+ if (is_Obj(opts)) {
472
+ if (is_Obj(opts.fs) && typeof opts.fs.statSync === "function") {
473
+ this.fs = opts.fs;
474
+ }
475
+ }
476
+ }
477
+ module.exports = Utils;
478
+ Utils.prototype.makeDir = function(folder) {
479
+ const self = this;
480
+ function mkdirSync(fpath) {
481
+ let resolvedPath = fpath.split(self.sep)[0];
482
+ fpath.split(self.sep).forEach(function(name) {
483
+ if (!name || name.substr(-1, 1) === ":") return;
484
+ resolvedPath += self.sep + name;
485
+ var stat;
486
+ try {
487
+ stat = self.fs.statSync(resolvedPath);
488
+ } catch (e2) {
489
+ if (e2.message && e2.message.startsWith("ENOENT")) {
490
+ self.fs.mkdirSync(resolvedPath);
491
+ } else {
492
+ throw e2;
493
+ }
494
+ }
495
+ if (stat && stat.isFile()) throw Errors.FILE_IN_THE_WAY(`"${resolvedPath}"`);
496
+ });
497
+ }
498
+ mkdirSync(folder);
499
+ };
500
+ Utils.prototype.writeFileTo = function(path6, content, overwrite, attr) {
501
+ const self = this;
502
+ if (self.fs.existsSync(path6)) {
503
+ if (!overwrite) return false;
504
+ var stat = self.fs.statSync(path6);
505
+ if (stat.isDirectory()) {
506
+ return false;
507
+ }
508
+ }
509
+ var folder = pth.dirname(path6);
510
+ if (!self.fs.existsSync(folder)) {
511
+ self.makeDir(folder);
512
+ }
513
+ var fd;
514
+ try {
515
+ fd = self.fs.openSync(path6, "w", 438);
516
+ } catch (e2) {
517
+ self.fs.chmodSync(path6, 438);
518
+ fd = self.fs.openSync(path6, "w", 438);
519
+ }
520
+ if (fd) {
521
+ try {
522
+ self.fs.writeSync(fd, content, 0, content.length, 0);
523
+ } finally {
524
+ self.fs.closeSync(fd);
525
+ }
526
+ }
527
+ self.fs.chmodSync(path6, attr || 438);
528
+ return true;
529
+ };
530
+ Utils.prototype.writeFileToAsync = function(path6, content, overwrite, attr, callback) {
531
+ if (typeof attr === "function") {
532
+ callback = attr;
533
+ attr = void 0;
534
+ }
535
+ const self = this;
536
+ self.fs.exists(path6, function(exist) {
537
+ if (exist && !overwrite) return callback(false);
538
+ self.fs.stat(path6, function(err, stat) {
539
+ if (exist && stat && stat.isDirectory()) {
540
+ return callback(false);
541
+ }
542
+ var folder = pth.dirname(path6);
543
+ self.fs.exists(folder, function(exists) {
544
+ if (!exists) {
545
+ try {
546
+ self.makeDir(folder);
547
+ } catch (e2) {
548
+ return callback(false);
549
+ }
550
+ }
551
+ const writeToFd = function(fd) {
552
+ self.fs.write(fd, content, 0, content.length, 0, function(writeErr) {
553
+ self.fs.close(fd, function() {
554
+ if (writeErr) return callback(false);
555
+ self.fs.chmod(path6, attr || 438, function() {
556
+ callback(true);
557
+ });
558
+ });
559
+ });
560
+ };
561
+ self.fs.open(path6, "w", 438, function(err2, fd) {
562
+ if (err2) {
563
+ self.fs.chmod(path6, 438, function() {
564
+ self.fs.open(path6, "w", 438, function(retryErr, fd2) {
565
+ if (retryErr || !fd2) return callback(false);
566
+ writeToFd(fd2);
567
+ });
568
+ });
569
+ } else if (fd) {
570
+ writeToFd(fd);
571
+ } else {
572
+ callback(false);
573
+ }
574
+ });
575
+ });
576
+ });
577
+ });
578
+ };
579
+ Utils.prototype.assertPathSafe = function(root, target) {
580
+ const self = this;
581
+ if (typeof self.fs.lstatSync !== "function") return;
582
+ const resolvedRoot = pth.resolve(root);
583
+ const resolvedTarget = pth.resolve(target);
584
+ if (resolvedTarget === resolvedRoot) return;
585
+ const rel = pth.relative(resolvedRoot, resolvedTarget);
586
+ if (!rel || rel === ".." || rel.startsWith(".." + pth.sep) || pth.isAbsolute(rel)) return;
587
+ let cur = resolvedRoot;
588
+ for (const part of rel.split(pth.sep)) {
589
+ if (!part || part === ".") continue;
590
+ cur = pth.join(cur, part);
591
+ let stat;
592
+ try {
593
+ stat = self.fs.lstatSync(cur);
594
+ } catch (e2) {
595
+ break;
596
+ }
597
+ if (stat.isSymbolicLink()) throw Errors.FILE_IN_THE_WAY(`"${cur}"`);
598
+ }
599
+ };
600
+ Utils.prototype.findFiles = function(path6) {
601
+ const self = this;
602
+ const canLstat = typeof self.fs.lstatSync === "function";
603
+ const rootReal = self.fs.realpathSync(path6);
604
+ function escapesRoot(p) {
605
+ if (!canLstat) return false;
606
+ if (!self.fs.lstatSync(p).isSymbolicLink()) return false;
607
+ let real;
608
+ try {
609
+ real = self.fs.realpathSync(p);
610
+ } catch (e2) {
611
+ return true;
612
+ }
613
+ return !(real === rootReal || real.startsWith(rootReal + pth.sep));
614
+ }
615
+ function findSync(dir, pattern, recursive, visited) {
616
+ if (typeof pattern === "boolean") {
617
+ recursive = pattern;
618
+ pattern = void 0;
619
+ }
620
+ let files = [];
621
+ self.fs.readdirSync(dir).forEach(function(file) {
622
+ const path7 = pth.join(dir, file);
623
+ if (escapesRoot(path7)) return;
624
+ const stat = self.fs.statSync(path7);
625
+ if (!pattern || pattern.test(path7)) {
626
+ files.push(pth.normalize(path7) + (stat.isDirectory() ? self.sep : ""));
627
+ }
628
+ if (stat.isDirectory() && recursive) {
629
+ const realDir = self.fs.realpathSync(path7);
630
+ if (!visited.has(realDir)) {
631
+ visited.add(realDir);
632
+ files = files.concat(findSync(path7, pattern, recursive, visited));
633
+ }
634
+ }
635
+ });
636
+ return files;
637
+ }
638
+ return findSync(path6, void 0, true, /* @__PURE__ */ new Set([rootReal]));
639
+ };
640
+ Utils.prototype.findFilesAsync = function(dir, cb) {
641
+ const self = this;
642
+ const results = [];
643
+ let finished = false;
644
+ const finish = function(err) {
645
+ if (finished) return;
646
+ finished = true;
647
+ cb(err, err ? void 0 : results);
648
+ };
649
+ const canLstat = typeof self.fs.lstat === "function";
650
+ let rootReal = null;
651
+ const escapesRoot = function(file, cb2) {
652
+ if (!canLstat) return cb2(null, false);
653
+ self.fs.lstat(file, function(err, lst) {
654
+ if (err) return cb2(err);
655
+ if (!lst || !lst.isSymbolicLink()) return cb2(null, false);
656
+ self.fs.realpath(file, function(err2, real) {
657
+ if (err2) return cb2(null, true);
658
+ cb2(null, !(real === rootReal || real.startsWith(rootReal + pth.sep)));
659
+ });
660
+ });
661
+ };
662
+ const walk = function(dir2, visited, done) {
663
+ self.fs.readdir(dir2, function(err, list) {
664
+ if (err) return done(err);
665
+ let pending = list.length;
666
+ if (!pending) return done();
667
+ list.forEach(function(name) {
668
+ const file = pth.join(dir2, name);
669
+ escapesRoot(file, function(err2, escapes) {
670
+ if (err2) return done(err2);
671
+ if (escapes) {
672
+ if (!--pending) done();
673
+ return;
674
+ }
675
+ self.fs.stat(file, function(err3, stat) {
676
+ if (err3) return done(err3);
677
+ if (!stat) {
678
+ if (!--pending) done();
679
+ return;
680
+ }
681
+ results.push(pth.normalize(file) + (stat.isDirectory() ? self.sep : ""));
682
+ if (!stat.isDirectory()) {
683
+ if (!--pending) done();
684
+ return;
685
+ }
686
+ self.fs.realpath(file, function(err4, realDir) {
687
+ if (err4) return done(err4);
688
+ if (visited.has(realDir)) {
689
+ if (!--pending) done();
690
+ return;
691
+ }
692
+ visited.add(realDir);
693
+ walk(file, visited, function(err5) {
694
+ if (err5) return done(err5);
695
+ if (!--pending) done();
696
+ });
697
+ });
698
+ });
699
+ });
700
+ });
701
+ });
702
+ };
703
+ self.fs.realpath(dir, function(err, realDir) {
704
+ if (err) return finish(err);
705
+ rootReal = realDir;
706
+ walk(dir, /* @__PURE__ */ new Set([realDir]), finish);
707
+ });
708
+ };
709
+ Utils.prototype.getAttributes = function() {
710
+ };
711
+ Utils.prototype.setAttributes = function() {
712
+ };
713
+ Utils.crc32update = function(crc, byte) {
714
+ return crcTable[(crc ^ byte) & 255] ^ crc >>> 8;
715
+ };
716
+ Utils.crc32 = function(buf) {
717
+ if (typeof buf === "string") {
718
+ buf = Buffer.from(buf, "utf8");
719
+ }
720
+ let len = buf.length;
721
+ let crc = ~0;
722
+ for (let off = 0; off < len; ) crc = Utils.crc32update(crc, buf[off++]);
723
+ return ~crc >>> 0;
724
+ };
725
+ Utils.methodToString = function(method) {
726
+ switch (method) {
727
+ case Constants.STORED:
728
+ return "STORED (" + method + ")";
729
+ case Constants.DEFLATED:
730
+ return "DEFLATED (" + method + ")";
731
+ default:
732
+ return "UNSUPPORTED (" + method + ")";
733
+ }
734
+ };
735
+ Utils.canonical = function(path6) {
736
+ if (!path6) return "";
737
+ const safeSuffix = pth.posix.normalize("/" + path6.split("\\").join("/"));
738
+ return pth.join(".", safeSuffix);
739
+ };
740
+ Utils.zipnamefix = function(path6) {
741
+ if (!path6) return "";
742
+ const safeSuffix = pth.posix.normalize("/" + path6.split("\\").join("/"));
743
+ return pth.posix.join(".", safeSuffix);
744
+ };
745
+ Utils.findLast = function(arr, callback) {
746
+ if (!Array.isArray(arr)) throw new TypeError("arr is not array");
747
+ const len = arr.length >>> 0;
748
+ for (let i = len - 1; i >= 0; i--) {
749
+ if (callback(arr[i], i, arr)) {
750
+ return arr[i];
751
+ }
752
+ }
753
+ return void 0;
754
+ };
755
+ Utils.sanitize = function(prefix, name) {
756
+ prefix = pth.resolve(pth.normalize(prefix));
757
+ var parts = name.split("/");
758
+ for (var i = 0, l2 = parts.length; i < l2; i++) {
759
+ var path6 = pth.normalize(pth.join(prefix, parts.slice(i, l2).join(pth.sep)));
760
+ if (path6 === prefix || path6.startsWith(prefix + pth.sep)) {
761
+ return path6;
762
+ }
763
+ }
764
+ return pth.normalize(pth.join(prefix, pth.basename(name)));
765
+ };
766
+ Utils.toBuffer = function toBuffer(input, encoder) {
767
+ if (Buffer.isBuffer(input)) {
768
+ return input;
769
+ } else if (input instanceof Uint8Array) {
770
+ return Buffer.from(input);
771
+ } else {
772
+ return typeof input === "string" ? encoder(input) : Buffer.alloc(0);
773
+ }
774
+ };
775
+ Utils.readBigUInt64LE = function(buffer, index) {
776
+ const lo = buffer.readUInt32LE(index);
777
+ const hi = buffer.readUInt32LE(index + 4);
778
+ const value = hi * 4294967296 + lo;
779
+ if (value > Number.MAX_SAFE_INTEGER) {
780
+ throw Errors.ZIP64_VALUE_TOO_LARGE();
781
+ }
782
+ return value;
783
+ };
784
+ Utils.writeBigUInt64LE = function(buffer, value, index) {
785
+ const lo = value >>> 0;
786
+ const hi = Math.floor(value / 4294967296) >>> 0;
787
+ buffer.writeUInt32LE(lo, index);
788
+ buffer.writeUInt32LE(hi, index + 4);
789
+ };
790
+ Utils.fromDOS2Date = function(val) {
791
+ 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);
792
+ };
793
+ Utils.fromDate2DOS = function(val) {
794
+ let date = 0;
795
+ let time = 0;
796
+ if (val.getFullYear() > 1979) {
797
+ date = (val.getFullYear() - 1980 & 127) << 9 | val.getMonth() + 1 << 5 | val.getDate();
798
+ time = val.getHours() << 11 | val.getMinutes() << 5 | val.getSeconds() >> 1;
799
+ }
800
+ return date << 16 | time;
801
+ };
802
+ Utils.isWin = isWin;
803
+ Utils.crcTable = crcTable;
804
+ }
805
+ });
806
+
807
+ // node_modules/adm-zip/util/fattr.js
808
+ var require_fattr = __commonJS({
809
+ "node_modules/adm-zip/util/fattr.js"(exports, module) {
810
+ var pth = __require("path");
811
+ module.exports = function(path6, { fs }) {
812
+ var _path = path6 || "", _obj = newAttr(), _stat = null;
813
+ function newAttr() {
814
+ return {
815
+ directory: false,
816
+ readonly: false,
817
+ hidden: false,
818
+ executable: false,
819
+ mtime: 0,
820
+ atime: 0
821
+ };
822
+ }
823
+ if (_path && fs.existsSync(_path)) {
824
+ _stat = fs.statSync(_path);
825
+ _obj.directory = _stat.isDirectory();
826
+ _obj.mtime = _stat.mtime;
827
+ _obj.atime = _stat.atime;
828
+ _obj.executable = (73 & _stat.mode) !== 0;
829
+ _obj.readonly = (128 & _stat.mode) === 0;
830
+ _obj.hidden = pth.basename(_path)[0] === ".";
831
+ } else {
832
+ console.warn("Invalid path: " + _path);
833
+ }
834
+ return {
835
+ get directory() {
836
+ return _obj.directory;
837
+ },
838
+ get readOnly() {
839
+ return _obj.readonly;
840
+ },
841
+ get hidden() {
842
+ return _obj.hidden;
843
+ },
844
+ get mtime() {
845
+ return _obj.mtime;
846
+ },
847
+ get atime() {
848
+ return _obj.atime;
849
+ },
850
+ get executable() {
851
+ return _obj.executable;
852
+ },
853
+ decodeAttributes: function() {
854
+ },
855
+ encodeAttributes: function() {
856
+ },
857
+ toJSON: function() {
858
+ return {
859
+ path: _path,
860
+ isDirectory: _obj.directory,
861
+ isReadOnly: _obj.readonly,
862
+ isHidden: _obj.hidden,
863
+ isExecutable: _obj.executable,
864
+ mTime: _obj.mtime,
865
+ aTime: _obj.atime
866
+ };
867
+ },
868
+ toString: function() {
869
+ return JSON.stringify(this.toJSON(), null, " ");
870
+ }
871
+ };
872
+ };
873
+ }
874
+ });
875
+
876
+ // node_modules/adm-zip/util/decoder.js
877
+ var require_decoder = __commonJS({
878
+ "node_modules/adm-zip/util/decoder.js"(exports, module) {
879
+ module.exports = {
880
+ efs: true,
881
+ encode: (data) => Buffer.from(data, "utf8"),
882
+ decode: (data) => data.toString("utf8")
883
+ };
884
+ }
885
+ });
886
+
887
+ // node_modules/adm-zip/util/index.js
888
+ var require_util = __commonJS({
889
+ "node_modules/adm-zip/util/index.js"(exports, module) {
890
+ module.exports = require_utils();
891
+ module.exports.Constants = require_constants();
892
+ module.exports.Errors = require_errors();
893
+ module.exports.FileAttr = require_fattr();
894
+ module.exports.decoder = require_decoder();
895
+ }
896
+ });
897
+
898
+ // node_modules/adm-zip/headers/entryHeader.js
899
+ var require_entryHeader = __commonJS({
900
+ "node_modules/adm-zip/headers/entryHeader.js"(exports, module) {
901
+ var Utils = require_util();
902
+ var Constants = Utils.Constants;
903
+ module.exports = function() {
904
+ 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;
905
+ _verMade |= Utils.isWin ? 2560 : 768;
906
+ _flags |= Constants.FLG_EFS;
907
+ const _localHeader = {
908
+ extraLen: 0
909
+ };
910
+ const uint32 = (val) => Math.max(0, val) >>> 0;
911
+ const uint16 = (val) => Math.max(0, val) & 65535;
912
+ const uint8 = (val) => Math.max(0, val) & 255;
913
+ _time = Utils.fromDate2DOS(/* @__PURE__ */ new Date());
914
+ return {
915
+ get made() {
916
+ return _verMade;
917
+ },
918
+ set made(val) {
919
+ _verMade = val;
920
+ },
921
+ get version() {
922
+ return _version;
923
+ },
924
+ set version(val) {
925
+ _version = val;
926
+ },
927
+ get flags() {
928
+ return _flags;
929
+ },
930
+ set flags(val) {
931
+ _flags = val;
932
+ },
933
+ get flags_efs() {
934
+ return (_flags & Constants.FLG_EFS) > 0;
935
+ },
936
+ set flags_efs(val) {
937
+ if (val) {
938
+ _flags |= Constants.FLG_EFS;
939
+ } else {
940
+ _flags &= ~Constants.FLG_EFS;
941
+ }
942
+ },
943
+ get flags_desc() {
944
+ return (_flags & Constants.FLG_DESC) > 0;
945
+ },
946
+ set flags_desc(val) {
947
+ if (val) {
948
+ _flags |= Constants.FLG_DESC;
949
+ } else {
950
+ _flags &= ~Constants.FLG_DESC;
951
+ }
952
+ },
953
+ get method() {
954
+ return _method;
955
+ },
956
+ set method(val) {
957
+ switch (val) {
958
+ case Constants.STORED:
959
+ this.version = 10;
960
+ break;
961
+ case Constants.DEFLATED:
962
+ default:
963
+ this.version = 20;
964
+ }
965
+ _method = val;
966
+ },
967
+ get time() {
968
+ return Utils.fromDOS2Date(this.timeval);
969
+ },
970
+ set time(val) {
971
+ val = new Date(val);
972
+ this.timeval = Utils.fromDate2DOS(val);
973
+ },
974
+ get timeval() {
975
+ return _time;
976
+ },
977
+ set timeval(val) {
978
+ _time = uint32(val);
979
+ },
980
+ get timeHighByte() {
981
+ return uint8(_time >>> 8);
982
+ },
983
+ get crc() {
984
+ return _crc;
985
+ },
986
+ set crc(val) {
987
+ _crc = uint32(val);
988
+ },
989
+ get compressedSize() {
990
+ return _compressedSize;
991
+ },
992
+ set compressedSize(val) {
993
+ _compressedSize = uint32(val);
994
+ },
995
+ get size() {
996
+ return _size;
997
+ },
998
+ set size(val) {
999
+ _size = uint32(val);
1000
+ },
1001
+ get fileNameLength() {
1002
+ return _fnameLen;
1003
+ },
1004
+ set fileNameLength(val) {
1005
+ _fnameLen = val;
1006
+ },
1007
+ get extraLength() {
1008
+ return _extraLen;
1009
+ },
1010
+ set extraLength(val) {
1011
+ _extraLen = val;
1012
+ },
1013
+ get extraLocalLength() {
1014
+ return _localHeader.extraLen;
1015
+ },
1016
+ set extraLocalLength(val) {
1017
+ _localHeader.extraLen = val;
1018
+ },
1019
+ get commentLength() {
1020
+ return _comLen;
1021
+ },
1022
+ set commentLength(val) {
1023
+ _comLen = val;
1024
+ },
1025
+ get diskNumStart() {
1026
+ return _diskStart;
1027
+ },
1028
+ set diskNumStart(val) {
1029
+ _diskStart = uint32(val);
1030
+ },
1031
+ get inAttr() {
1032
+ return _inattr;
1033
+ },
1034
+ set inAttr(val) {
1035
+ _inattr = uint32(val);
1036
+ },
1037
+ get attr() {
1038
+ return _attr;
1039
+ },
1040
+ set attr(val) {
1041
+ _attr = uint32(val);
1042
+ },
1043
+ // get Unix file permissions
1044
+ get fileAttr() {
1045
+ return (_attr || 0) >> 16 & 511;
1046
+ },
1047
+ get offset() {
1048
+ return _offset;
1049
+ },
1050
+ set offset(val) {
1051
+ _offset = uint32(val);
1052
+ },
1053
+ get encrypted() {
1054
+ return (_flags & Constants.FLG_ENC) === Constants.FLG_ENC;
1055
+ },
1056
+ get centralHeaderSize() {
1057
+ return Constants.CENHDR + _fnameLen + _extraLen + _comLen;
1058
+ },
1059
+ get realDataOffset() {
1060
+ return _offset + Constants.LOCHDR + _localHeader.fnameLen + _localHeader.extraLen;
1061
+ },
1062
+ get localHeader() {
1063
+ return _localHeader;
1064
+ },
1065
+ loadLocalHeaderFromBinary: function(input) {
1066
+ if (_offset < 0 || _offset + Constants.LOCHDR > input.length) {
1067
+ throw Utils.Errors.INVALID_LOC();
1068
+ }
1069
+ var data = input.slice(_offset, _offset + Constants.LOCHDR);
1070
+ if (data.readUInt32LE(0) !== Constants.LOCSIG) {
1071
+ throw Utils.Errors.INVALID_LOC();
1072
+ }
1073
+ _localHeader.version = data.readUInt16LE(Constants.LOCVER);
1074
+ _localHeader.flags = data.readUInt16LE(Constants.LOCFLG);
1075
+ _localHeader.flags_desc = (_localHeader.flags & Constants.FLG_DESC) > 0;
1076
+ _localHeader.method = data.readUInt16LE(Constants.LOCHOW);
1077
+ _localHeader.time = data.readUInt32LE(Constants.LOCTIM);
1078
+ _localHeader.crc = data.readUInt32LE(Constants.LOCCRC);
1079
+ _localHeader.compressedSize = data.readUInt32LE(Constants.LOCSIZ);
1080
+ _localHeader.size = data.readUInt32LE(Constants.LOCLEN);
1081
+ _localHeader.fnameLen = data.readUInt16LE(Constants.LOCNAM);
1082
+ _localHeader.extraLen = data.readUInt16LE(Constants.LOCEXT);
1083
+ const extraStart = _offset + Constants.LOCHDR + _localHeader.fnameLen;
1084
+ const extraEnd = extraStart + _localHeader.extraLen;
1085
+ return input.slice(extraStart, extraEnd);
1086
+ },
1087
+ loadFromBinary: function(data) {
1088
+ if (data.length !== Constants.CENHDR || data.readUInt32LE(0) !== Constants.CENSIG) {
1089
+ throw Utils.Errors.INVALID_CEN();
1090
+ }
1091
+ _verMade = data.readUInt16LE(Constants.CENVEM);
1092
+ _version = data.readUInt16LE(Constants.CENVER);
1093
+ _flags = data.readUInt16LE(Constants.CENFLG);
1094
+ _method = data.readUInt16LE(Constants.CENHOW);
1095
+ _time = data.readUInt32LE(Constants.CENTIM);
1096
+ _crc = data.readUInt32LE(Constants.CENCRC);
1097
+ _compressedSize = data.readUInt32LE(Constants.CENSIZ);
1098
+ _size = data.readUInt32LE(Constants.CENLEN);
1099
+ _fnameLen = data.readUInt16LE(Constants.CENNAM);
1100
+ _extraLen = data.readUInt16LE(Constants.CENEXT);
1101
+ _comLen = data.readUInt16LE(Constants.CENCOM);
1102
+ _diskStart = data.readUInt16LE(Constants.CENDSK);
1103
+ _inattr = data.readUInt16LE(Constants.CENATT);
1104
+ _attr = data.readUInt32LE(Constants.CENATX);
1105
+ _offset = data.readUInt32LE(Constants.CENOFF);
1106
+ },
1107
+ localHeaderToBinary: function() {
1108
+ var data = Buffer.alloc(Constants.LOCHDR);
1109
+ data.writeUInt32LE(Constants.LOCSIG, 0);
1110
+ data.writeUInt16LE(_version, Constants.LOCVER);
1111
+ data.writeUInt16LE(_flags & ~Constants.FLG_DESC, Constants.LOCFLG);
1112
+ data.writeUInt16LE(_method, Constants.LOCHOW);
1113
+ data.writeUInt32LE(_time, Constants.LOCTIM);
1114
+ data.writeUInt32LE(_crc, Constants.LOCCRC);
1115
+ data.writeUInt32LE(_compressedSize, Constants.LOCSIZ);
1116
+ data.writeUInt32LE(_size, Constants.LOCLEN);
1117
+ data.writeUInt16LE(_fnameLen, Constants.LOCNAM);
1118
+ data.writeUInt16LE(_localHeader.extraLen, Constants.LOCEXT);
1119
+ return data;
1120
+ },
1121
+ centralHeaderToBinary: function() {
1122
+ var data = Buffer.alloc(Constants.CENHDR + _fnameLen + _extraLen + _comLen);
1123
+ data.writeUInt32LE(Constants.CENSIG, 0);
1124
+ data.writeUInt16LE(_verMade, Constants.CENVEM);
1125
+ data.writeUInt16LE(_version, Constants.CENVER);
1126
+ data.writeUInt16LE(_flags & ~Constants.FLG_DESC, Constants.CENFLG);
1127
+ data.writeUInt16LE(_method, Constants.CENHOW);
1128
+ data.writeUInt32LE(_time, Constants.CENTIM);
1129
+ data.writeUInt32LE(_crc, Constants.CENCRC);
1130
+ data.writeUInt32LE(_compressedSize, Constants.CENSIZ);
1131
+ data.writeUInt32LE(_size, Constants.CENLEN);
1132
+ data.writeUInt16LE(_fnameLen, Constants.CENNAM);
1133
+ data.writeUInt16LE(_extraLen, Constants.CENEXT);
1134
+ data.writeUInt16LE(_comLen, Constants.CENCOM);
1135
+ data.writeUInt16LE(_diskStart, Constants.CENDSK);
1136
+ data.writeUInt16LE(_inattr, Constants.CENATT);
1137
+ data.writeUInt32LE(_attr, Constants.CENATX);
1138
+ data.writeUInt32LE(_offset, Constants.CENOFF);
1139
+ return data;
1140
+ },
1141
+ toJSON: function() {
1142
+ const bytes = function(nr) {
1143
+ return nr + " bytes";
1144
+ };
1145
+ return {
1146
+ made: _verMade,
1147
+ version: _version,
1148
+ flags: _flags,
1149
+ method: Utils.methodToString(_method),
1150
+ time: this.time,
1151
+ crc: "0x" + _crc.toString(16).toUpperCase(),
1152
+ compressedSize: bytes(_compressedSize),
1153
+ size: bytes(_size),
1154
+ fileNameLength: bytes(_fnameLen),
1155
+ extraLength: bytes(_extraLen),
1156
+ commentLength: bytes(_comLen),
1157
+ diskNumStart: _diskStart,
1158
+ inAttr: _inattr,
1159
+ attr: _attr,
1160
+ offset: _offset,
1161
+ centralHeaderSize: bytes(Constants.CENHDR + _fnameLen + _extraLen + _comLen)
1162
+ };
1163
+ },
1164
+ toString: function() {
1165
+ return JSON.stringify(this.toJSON(), null, " ");
1166
+ }
1167
+ };
1168
+ };
1169
+ }
1170
+ });
1171
+
1172
+ // node_modules/adm-zip/headers/mainHeader.js
1173
+ var require_mainHeader = __commonJS({
1174
+ "node_modules/adm-zip/headers/mainHeader.js"(exports, module) {
1175
+ var Utils = require_util();
1176
+ var Constants = Utils.Constants;
1177
+ module.exports = function() {
1178
+ var _volumeEntries = 0, _totalEntries = 0, _size = 0, _offset = 0, _commentLength = 0;
1179
+ const needsZip64 = () => _volumeEntries > Constants.EF_ZIP64_OR_16 || _totalEntries > Constants.EF_ZIP64_OR_16 || _size > Constants.EF_ZIP64_OR_32 || _offset > Constants.EF_ZIP64_OR_32;
1180
+ return {
1181
+ get diskEntries() {
1182
+ return _volumeEntries;
1183
+ },
1184
+ set diskEntries(val) {
1185
+ _volumeEntries = _totalEntries = val;
1186
+ },
1187
+ get totalEntries() {
1188
+ return _totalEntries;
1189
+ },
1190
+ set totalEntries(val) {
1191
+ _totalEntries = _volumeEntries = val;
1192
+ },
1193
+ get size() {
1194
+ return _size;
1195
+ },
1196
+ set size(val) {
1197
+ _size = val;
1198
+ },
1199
+ get offset() {
1200
+ return _offset;
1201
+ },
1202
+ set offset(val) {
1203
+ _offset = val;
1204
+ },
1205
+ get commentLength() {
1206
+ return _commentLength;
1207
+ },
1208
+ set commentLength(val) {
1209
+ _commentLength = val;
1210
+ },
1211
+ get mainHeaderSize() {
1212
+ return (needsZip64() ? Constants.ZIP64HDR + Constants.END64HDR : 0) + Constants.ENDHDR + _commentLength;
1213
+ },
1214
+ loadFromBinary: function(data) {
1215
+ if ((data.length !== Constants.ENDHDR || data.readUInt32LE(0) !== Constants.ENDSIG) && (data.length < Constants.ZIP64HDR || data.readUInt32LE(0) !== Constants.ZIP64SIG)) {
1216
+ throw Utils.Errors.INVALID_END();
1217
+ }
1218
+ if (data.readUInt32LE(0) === Constants.ENDSIG) {
1219
+ _volumeEntries = data.readUInt16LE(Constants.ENDSUB);
1220
+ _totalEntries = data.readUInt16LE(Constants.ENDTOT);
1221
+ _size = data.readUInt32LE(Constants.ENDSIZ);
1222
+ _offset = data.readUInt32LE(Constants.ENDOFF);
1223
+ _commentLength = data.readUInt16LE(Constants.ENDCOM);
1224
+ } else {
1225
+ _volumeEntries = Utils.readBigUInt64LE(data, Constants.ZIP64SUB);
1226
+ _totalEntries = Utils.readBigUInt64LE(data, Constants.ZIP64TOT);
1227
+ _size = Utils.readBigUInt64LE(data, Constants.ZIP64SIZB);
1228
+ _offset = Utils.readBigUInt64LE(data, Constants.ZIP64OFF);
1229
+ _commentLength = 0;
1230
+ }
1231
+ },
1232
+ toBinary: function() {
1233
+ if (!needsZip64()) {
1234
+ var b3 = Buffer.alloc(Constants.ENDHDR + _commentLength);
1235
+ b3.writeUInt32LE(Constants.ENDSIG, 0);
1236
+ b3.writeUInt32LE(0, 4);
1237
+ b3.writeUInt16LE(_volumeEntries, Constants.ENDSUB);
1238
+ b3.writeUInt16LE(_totalEntries, Constants.ENDTOT);
1239
+ b3.writeUInt32LE(_size, Constants.ENDSIZ);
1240
+ b3.writeUInt32LE(_offset, Constants.ENDOFF);
1241
+ b3.writeUInt16LE(_commentLength, Constants.ENDCOM);
1242
+ b3.fill(" ", Constants.ENDHDR);
1243
+ return b3;
1244
+ }
1245
+ var b3 = Buffer.alloc(this.mainHeaderSize);
1246
+ let offset = 0;
1247
+ b3.writeUInt32LE(Constants.ZIP64SIG, offset);
1248
+ Utils.writeBigUInt64LE(b3, Constants.ZIP64HDR - Constants.ZIP64LEAD, offset + Constants.ZIP64SIZE);
1249
+ b3.writeUInt16LE(45, offset + Constants.ZIP64VEM);
1250
+ b3.writeUInt16LE(45, offset + Constants.ZIP64VER);
1251
+ b3.writeUInt32LE(0, offset + Constants.ZIP64DSK);
1252
+ b3.writeUInt32LE(0, offset + Constants.ZIP64DSKDIR);
1253
+ Utils.writeBigUInt64LE(b3, _volumeEntries, offset + Constants.ZIP64SUB);
1254
+ Utils.writeBigUInt64LE(b3, _totalEntries, offset + Constants.ZIP64TOT);
1255
+ Utils.writeBigUInt64LE(b3, _size, offset + Constants.ZIP64SIZB);
1256
+ Utils.writeBigUInt64LE(b3, _offset, offset + Constants.ZIP64OFF);
1257
+ const zip64EndOffset = _offset + _size;
1258
+ offset += Constants.ZIP64HDR;
1259
+ b3.writeUInt32LE(Constants.END64SIG, offset);
1260
+ b3.writeUInt32LE(0, offset + Constants.END64START);
1261
+ Utils.writeBigUInt64LE(b3, zip64EndOffset, offset + Constants.END64OFF);
1262
+ b3.writeUInt32LE(1, offset + Constants.END64NUMDISKS);
1263
+ offset += Constants.END64HDR;
1264
+ b3.writeUInt32LE(Constants.ENDSIG, offset);
1265
+ b3.writeUInt32LE(0, offset + 4);
1266
+ b3.writeUInt16LE(Math.min(_volumeEntries, Constants.EF_ZIP64_OR_16), offset + Constants.ENDSUB);
1267
+ b3.writeUInt16LE(Math.min(_totalEntries, Constants.EF_ZIP64_OR_16), offset + Constants.ENDTOT);
1268
+ b3.writeUInt32LE(Math.min(_size, Constants.EF_ZIP64_OR_32), offset + Constants.ENDSIZ);
1269
+ b3.writeUInt32LE(Math.min(_offset, Constants.EF_ZIP64_OR_32), offset + Constants.ENDOFF);
1270
+ b3.writeUInt16LE(_commentLength, offset + Constants.ENDCOM);
1271
+ b3.fill(" ", offset + Constants.ENDHDR);
1272
+ return b3;
1273
+ },
1274
+ toJSON: function() {
1275
+ const offset = function(nr, len) {
1276
+ let offs = nr.toString(16).toUpperCase();
1277
+ while (offs.length < len) offs = "0" + offs;
1278
+ return "0x" + offs;
1279
+ };
1280
+ return {
1281
+ diskEntries: _volumeEntries,
1282
+ totalEntries: _totalEntries,
1283
+ size: _size + " bytes",
1284
+ offset: offset(_offset, 4),
1285
+ commentLength: _commentLength
1286
+ };
1287
+ },
1288
+ toString: function() {
1289
+ return JSON.stringify(this.toJSON(), null, " ");
1290
+ }
1291
+ };
1292
+ };
1293
+ }
1294
+ });
1295
+
1296
+ // node_modules/adm-zip/headers/index.js
1297
+ var require_headers = __commonJS({
1298
+ "node_modules/adm-zip/headers/index.js"(exports) {
1299
+ exports.EntryHeader = require_entryHeader();
1300
+ exports.MainHeader = require_mainHeader();
1301
+ }
1302
+ });
1303
+
1304
+ // node_modules/adm-zip/methods/deflater.js
1305
+ var require_deflater = __commonJS({
1306
+ "node_modules/adm-zip/methods/deflater.js"(exports, module) {
1307
+ module.exports = function(inbuf) {
1308
+ var zlib = __require("zlib");
1309
+ var opts = { chunkSize: (parseInt(inbuf.length / 1024) + 1) * 1024 };
1310
+ return {
1311
+ deflate: function() {
1312
+ return zlib.deflateRawSync(inbuf, opts);
1313
+ },
1314
+ deflateAsync: function(callback) {
1315
+ var tmp = zlib.createDeflateRaw(opts), parts = [], total = 0;
1316
+ tmp.on("data", function(data) {
1317
+ parts.push(data);
1318
+ total += data.length;
1319
+ });
1320
+ tmp.on("end", function() {
1321
+ var buf = Buffer.alloc(total), written = 0;
1322
+ buf.fill(0);
1323
+ for (var i = 0; i < parts.length; i++) {
1324
+ var part = parts[i];
1325
+ part.copy(buf, written);
1326
+ written += part.length;
1327
+ }
1328
+ callback && callback(buf);
1329
+ });
1330
+ tmp.end(inbuf);
1331
+ }
1332
+ };
1333
+ };
1334
+ }
1335
+ });
1336
+
1337
+ // node_modules/adm-zip/methods/inflater.js
1338
+ var require_inflater = __commonJS({
1339
+ "node_modules/adm-zip/methods/inflater.js"(exports, module) {
1340
+ var version = +(process?.versions?.node ?? "").split(".")[0] || 0;
1341
+ var Errors = require_errors();
1342
+ module.exports = function(inbuf, expectedLength) {
1343
+ var zlib = __require("zlib");
1344
+ const maxOutputLength = expectedLength > 0 ? expectedLength : 1;
1345
+ const option = version >= 15 ? { maxOutputLength } : {};
1346
+ return {
1347
+ inflate: function() {
1348
+ return zlib.inflateRawSync(inbuf, option);
1349
+ },
1350
+ inflateAsync: function(callback) {
1351
+ var tmp = zlib.createInflateRaw(option), parts = [], total = 0, done = false;
1352
+ const fail = function(err) {
1353
+ if (done) return;
1354
+ done = true;
1355
+ tmp.destroy();
1356
+ callback && callback(Buffer.alloc(0), err);
1357
+ };
1358
+ tmp.on("error", function(err) {
1359
+ fail(err);
1360
+ });
1361
+ tmp.on("data", function(data) {
1362
+ if (done) return;
1363
+ total += data.length;
1364
+ if (total > maxOutputLength) {
1365
+ return fail(Errors.MAX_OUTPUT_EXCEEDED());
1366
+ }
1367
+ parts.push(data);
1368
+ });
1369
+ tmp.on("end", function() {
1370
+ if (done) return;
1371
+ done = true;
1372
+ var buf = Buffer.alloc(total), written = 0;
1373
+ buf.fill(0);
1374
+ for (var i = 0; i < parts.length; i++) {
1375
+ var part = parts[i];
1376
+ part.copy(buf, written);
1377
+ written += part.length;
1378
+ }
1379
+ callback && callback(buf);
1380
+ });
1381
+ tmp.end(inbuf);
1382
+ }
1383
+ };
1384
+ };
1385
+ }
1386
+ });
1387
+
1388
+ // node_modules/adm-zip/methods/zipcrypto.js
1389
+ var require_zipcrypto = __commonJS({
1390
+ "node_modules/adm-zip/methods/zipcrypto.js"(exports, module) {
1391
+ "use strict";
1392
+ var { randomFillSync } = __require("crypto");
1393
+ var Errors = require_errors();
1394
+ var crctable = new Uint32Array(256).map((t, crc) => {
1395
+ for (let j3 = 0; j3 < 8; j3++) {
1396
+ if (0 !== (crc & 1)) {
1397
+ crc = crc >>> 1 ^ 3988292384;
1398
+ } else {
1399
+ crc >>>= 1;
1400
+ }
1401
+ }
1402
+ return crc >>> 0;
1403
+ });
1404
+ var uMul = (a3, b3) => Math.imul(a3, b3) >>> 0;
1405
+ var crc32update = (pCrc32, bval) => {
1406
+ return crctable[(pCrc32 ^ bval) & 255] ^ pCrc32 >>> 8;
1407
+ };
1408
+ var genSalt = () => {
1409
+ if ("function" === typeof randomFillSync) {
1410
+ return randomFillSync(Buffer.alloc(12));
1411
+ } else {
1412
+ return genSalt.node();
1413
+ }
1414
+ };
1415
+ genSalt.node = () => {
1416
+ const salt = Buffer.alloc(12);
1417
+ const len = salt.length;
1418
+ for (let i = 0; i < len; i++) salt[i] = Math.random() * 256 & 255;
1419
+ return salt;
1420
+ };
1421
+ var config = {
1422
+ genSalt
1423
+ };
1424
+ function Initkeys(pw) {
1425
+ const pass = Buffer.isBuffer(pw) ? pw : Buffer.from(pw);
1426
+ this.keys = new Uint32Array([305419896, 591751049, 878082192]);
1427
+ for (let i = 0; i < pass.length; i++) {
1428
+ this.updateKeys(pass[i]);
1429
+ }
1430
+ }
1431
+ Initkeys.prototype.updateKeys = function(byteValue) {
1432
+ const keys = this.keys;
1433
+ keys[0] = crc32update(keys[0], byteValue);
1434
+ keys[1] += keys[0] & 255;
1435
+ keys[1] = uMul(keys[1], 134775813) + 1;
1436
+ keys[2] = crc32update(keys[2], keys[1] >>> 24);
1437
+ return byteValue;
1438
+ };
1439
+ Initkeys.prototype.next = function() {
1440
+ const k3 = (this.keys[2] | 2) >>> 0;
1441
+ return uMul(k3, k3 ^ 1) >> 8 & 255;
1442
+ };
1443
+ function make_decrypter(pwd) {
1444
+ const keys = new Initkeys(pwd);
1445
+ return function(data) {
1446
+ const result = Buffer.alloc(data.length);
1447
+ let pos = 0;
1448
+ for (let c2 of data) {
1449
+ result[pos++] = keys.updateKeys(c2 ^ keys.next());
1450
+ }
1451
+ return result;
1452
+ };
1453
+ }
1454
+ function make_encrypter(pwd) {
1455
+ const keys = new Initkeys(pwd);
1456
+ return function(data, result, pos = 0) {
1457
+ if (!result) result = Buffer.alloc(data.length);
1458
+ for (let c2 of data) {
1459
+ const k3 = keys.next();
1460
+ result[pos++] = c2 ^ k3;
1461
+ keys.updateKeys(c2);
1462
+ }
1463
+ return result;
1464
+ };
1465
+ }
1466
+ function decrypt(data, header, pwd) {
1467
+ if (!data || !Buffer.isBuffer(data) || data.length < 12) {
1468
+ return Buffer.alloc(0);
1469
+ }
1470
+ const decrypter = make_decrypter(pwd);
1471
+ const salt = decrypter(data.slice(0, 12));
1472
+ const verifyByte = (header.flags & 8) === 8 ? header.timeHighByte : header.crc >>> 24;
1473
+ if (salt[11] !== verifyByte) {
1474
+ throw Errors.WRONG_PASSWORD();
1475
+ }
1476
+ return decrypter(data.slice(12));
1477
+ }
1478
+ function _salter(data) {
1479
+ if (Buffer.isBuffer(data) && data.length >= 12) {
1480
+ config.genSalt = function() {
1481
+ return data.slice(0, 12);
1482
+ };
1483
+ } else if (data === "node") {
1484
+ config.genSalt = genSalt.node;
1485
+ } else {
1486
+ config.genSalt = genSalt;
1487
+ }
1488
+ }
1489
+ function encrypt(data, header, pwd, oldlike = false) {
1490
+ if (data == null) data = Buffer.alloc(0);
1491
+ if (!Buffer.isBuffer(data)) data = Buffer.from(data.toString());
1492
+ const encrypter = make_encrypter(pwd);
1493
+ const salt = config.genSalt();
1494
+ salt[11] = header.crc >>> 24 & 255;
1495
+ if (oldlike) salt[10] = header.crc >>> 16 & 255;
1496
+ const result = Buffer.alloc(data.length + 12);
1497
+ encrypter(salt, result);
1498
+ return encrypter(data, result, 12);
1499
+ }
1500
+ module.exports = { decrypt, encrypt, _salter };
1501
+ }
1502
+ });
1503
+
1504
+ // node_modules/adm-zip/methods/index.js
1505
+ var require_methods = __commonJS({
1506
+ "node_modules/adm-zip/methods/index.js"(exports) {
1507
+ exports.Deflater = require_deflater();
1508
+ exports.Inflater = require_inflater();
1509
+ exports.ZipCrypto = require_zipcrypto();
1510
+ }
1511
+ });
1512
+
1513
+ // node_modules/adm-zip/zipEntry.js
1514
+ var require_zipEntry = __commonJS({
1515
+ "node_modules/adm-zip/zipEntry.js"(exports, module) {
1516
+ var Utils = require_util();
1517
+ var Headers = require_headers();
1518
+ var Constants = Utils.Constants;
1519
+ var Methods = require_methods();
1520
+ module.exports = function(options, input) {
1521
+ 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;
1522
+ const opts = options;
1523
+ const decoder = typeof opts.decoder === "object" ? opts.decoder : Utils.decoder;
1524
+ _efs = decoder.hasOwnProperty("efs") ? decoder.efs : false;
1525
+ function getCompressedDataFromZip() {
1526
+ if (!input || !(input instanceof Uint8Array)) {
1527
+ return Buffer.alloc(0);
1528
+ }
1529
+ _extralocal = _centralHeader.loadLocalHeaderFromBinary(input);
1530
+ const dataOffset = _centralHeader.realDataOffset;
1531
+ const dataEnd = dataOffset + _centralHeader.compressedSize;
1532
+ if (dataOffset < 0 || dataEnd < dataOffset || dataEnd > input.length) {
1533
+ throw Utils.Errors.INVALID_LOC();
1534
+ }
1535
+ return input.slice(dataOffset, dataEnd);
1536
+ }
1537
+ function crc32OK(data) {
1538
+ const expectedCrc = _centralHeader.flags_desc || _centralHeader.localHeader.flags_desc ? _centralHeader.crc : _centralHeader.localHeader.crc;
1539
+ return Utils.crc32(data) === expectedCrc;
1540
+ }
1541
+ function decompress(async, callback, pass) {
1542
+ if (typeof callback === "undefined" && typeof async === "string") {
1543
+ pass = async;
1544
+ async = void 0;
1545
+ }
1546
+ if (_isDirectory) {
1547
+ if (async && callback) {
1548
+ callback(Buffer.alloc(0), Utils.Errors.DIRECTORY_CONTENT_ERROR());
1549
+ }
1550
+ return Buffer.alloc(0);
1551
+ }
1552
+ var compressedData;
1553
+ try {
1554
+ compressedData = getCompressedDataFromZip();
1555
+ if (compressedData.length === 0) {
1556
+ if (async && callback) callback(compressedData);
1557
+ return compressedData;
1558
+ }
1559
+ if (_centralHeader.encrypted) {
1560
+ if ("string" !== typeof pass && !Buffer.isBuffer(pass)) {
1561
+ throw Utils.Errors.INVALID_PASS_PARAM();
1562
+ }
1563
+ compressedData = Methods.ZipCrypto.decrypt(compressedData, _centralHeader, pass);
1564
+ }
1565
+ } catch (err) {
1566
+ if (async && callback) {
1567
+ callback(Buffer.alloc(0), err);
1568
+ return Buffer.alloc(0);
1569
+ }
1570
+ throw err;
1571
+ }
1572
+ var data;
1573
+ switch (_centralHeader.method) {
1574
+ case Utils.Constants.STORED:
1575
+ data = Buffer.alloc(compressedData.length);
1576
+ compressedData.copy(data);
1577
+ if (!crc32OK(data)) {
1578
+ if (async && callback) callback(data, Utils.Errors.BAD_CRC());
1579
+ throw Utils.Errors.BAD_CRC();
1580
+ } else {
1581
+ if (async && callback) callback(data);
1582
+ return data;
1583
+ }
1584
+ case Utils.Constants.DEFLATED:
1585
+ var inflater = new Methods.Inflater(compressedData, _centralHeader.size);
1586
+ if (!async) {
1587
+ data = inflater.inflate();
1588
+ if (!crc32OK(data)) {
1589
+ throw Utils.Errors.BAD_CRC(`"${decoder.decode(_entryName)}"`);
1590
+ }
1591
+ return data;
1592
+ } else {
1593
+ inflater.inflateAsync(function(result, err) {
1594
+ if (!callback) return;
1595
+ if (err) {
1596
+ callback(Buffer.alloc(0), err);
1597
+ } else if (!crc32OK(result)) {
1598
+ callback(result, Utils.Errors.BAD_CRC());
1599
+ } else {
1600
+ callback(result);
1601
+ }
1602
+ });
1603
+ }
1604
+ break;
1605
+ default:
1606
+ if (async && callback) callback(Buffer.alloc(0), Utils.Errors.UNKNOWN_METHOD());
1607
+ throw Utils.Errors.UNKNOWN_METHOD();
1608
+ }
1609
+ }
1610
+ function compress(async, callback) {
1611
+ if ((!uncompressedData || !uncompressedData.length) && Buffer.isBuffer(input)) {
1612
+ if (async && callback) callback(getCompressedDataFromZip());
1613
+ return getCompressedDataFromZip();
1614
+ }
1615
+ if (uncompressedData.length && !_isDirectory) {
1616
+ var compressedData;
1617
+ switch (_centralHeader.method) {
1618
+ case Utils.Constants.STORED:
1619
+ _centralHeader.compressedSize = _centralHeader.size;
1620
+ compressedData = Buffer.alloc(uncompressedData.length);
1621
+ uncompressedData.copy(compressedData);
1622
+ if (async && callback) callback(compressedData);
1623
+ return compressedData;
1624
+ default:
1625
+ case Utils.Constants.DEFLATED:
1626
+ var deflater = new Methods.Deflater(uncompressedData);
1627
+ if (!async) {
1628
+ var deflated = deflater.deflate();
1629
+ _centralHeader.compressedSize = deflated.length;
1630
+ return deflated;
1631
+ } else {
1632
+ deflater.deflateAsync(function(data) {
1633
+ compressedData = Buffer.alloc(data.length);
1634
+ _centralHeader.compressedSize = data.length;
1635
+ data.copy(compressedData);
1636
+ callback && callback(compressedData);
1637
+ });
1638
+ }
1639
+ deflater = null;
1640
+ break;
1641
+ }
1642
+ } else if (async && callback) {
1643
+ callback(Buffer.alloc(0));
1644
+ } else {
1645
+ return Buffer.alloc(0);
1646
+ }
1647
+ }
1648
+ function readUInt64LE(buffer, offset) {
1649
+ return Utils.readBigUInt64LE(buffer, offset);
1650
+ }
1651
+ function parseExtra(data) {
1652
+ try {
1653
+ var offset = 0;
1654
+ var signature, size, part;
1655
+ while (offset + 4 < data.length) {
1656
+ signature = data.readUInt16LE(offset);
1657
+ offset += 2;
1658
+ size = data.readUInt16LE(offset);
1659
+ offset += 2;
1660
+ part = data.slice(offset, offset + size);
1661
+ offset += size;
1662
+ if (Constants.ID_ZIP64 === signature) {
1663
+ parseZip64ExtendedInformation(part);
1664
+ }
1665
+ }
1666
+ } catch (error) {
1667
+ throw Utils.Errors.EXTRA_FIELD_PARSE_ERROR();
1668
+ }
1669
+ }
1670
+ function parseZip64ExtendedInformation(data) {
1671
+ var size, compressedSize, offset, diskNumStart;
1672
+ if (data.length >= Constants.EF_ZIP64_SCOMP) {
1673
+ size = readUInt64LE(data, Constants.EF_ZIP64_SUNCOMP);
1674
+ if (_centralHeader.size === Constants.EF_ZIP64_OR_32) {
1675
+ _centralHeader.size = size;
1676
+ }
1677
+ }
1678
+ if (data.length >= Constants.EF_ZIP64_RHO) {
1679
+ compressedSize = readUInt64LE(data, Constants.EF_ZIP64_SCOMP);
1680
+ if (_centralHeader.compressedSize === Constants.EF_ZIP64_OR_32) {
1681
+ _centralHeader.compressedSize = compressedSize;
1682
+ }
1683
+ }
1684
+ if (data.length >= Constants.EF_ZIP64_DSN) {
1685
+ offset = readUInt64LE(data, Constants.EF_ZIP64_RHO);
1686
+ if (_centralHeader.offset === Constants.EF_ZIP64_OR_32) {
1687
+ _centralHeader.offset = offset;
1688
+ }
1689
+ }
1690
+ if (data.length >= Constants.EF_ZIP64_DSN + 4) {
1691
+ diskNumStart = data.readUInt32LE(Constants.EF_ZIP64_DSN);
1692
+ if (_centralHeader.diskNumStart === Constants.EF_ZIP64_OR_16) {
1693
+ _centralHeader.diskNumStart = diskNumStart;
1694
+ }
1695
+ }
1696
+ }
1697
+ return {
1698
+ get entryName() {
1699
+ return decoder.decode(_entryName);
1700
+ },
1701
+ get rawEntryName() {
1702
+ return _entryName;
1703
+ },
1704
+ set entryName(val) {
1705
+ _entryName = Utils.toBuffer(val, decoder.encode);
1706
+ var lastChar = _entryName[_entryName.length - 1];
1707
+ _isDirectory = lastChar === 47 || lastChar === 92;
1708
+ _centralHeader.fileNameLength = _entryName.length;
1709
+ },
1710
+ get efs() {
1711
+ if (typeof _efs === "function") {
1712
+ return _efs(this.entryName);
1713
+ } else {
1714
+ return _efs;
1715
+ }
1716
+ },
1717
+ get extra() {
1718
+ return _extra;
1719
+ },
1720
+ set extra(val) {
1721
+ _extra = val;
1722
+ _centralHeader.extraLength = val.length;
1723
+ parseExtra(val);
1724
+ },
1725
+ get comment() {
1726
+ return decoder.decode(_comment);
1727
+ },
1728
+ set comment(val) {
1729
+ _comment = Utils.toBuffer(val, decoder.encode);
1730
+ _centralHeader.commentLength = _comment.length;
1731
+ if (_comment.length > 65535) throw Utils.Errors.COMMENT_TOO_LONG();
1732
+ },
1733
+ get name() {
1734
+ const n = decoder.decode(_entryName);
1735
+ return _isDirectory ? n.replace(/[/\\]$/, "").split("/").pop() : n.split("/").pop();
1736
+ },
1737
+ get isDirectory() {
1738
+ return _isDirectory;
1739
+ },
1740
+ getCompressedData: function() {
1741
+ return compress(false, null);
1742
+ },
1743
+ getCompressedDataAsync: function(callback) {
1744
+ compress(true, callback);
1745
+ },
1746
+ setData: function(value) {
1747
+ uncompressedData = Utils.toBuffer(value, Utils.decoder.encode);
1748
+ if (!_isDirectory && uncompressedData.length) {
1749
+ _centralHeader.size = uncompressedData.length;
1750
+ _centralHeader.method = Utils.Constants.DEFLATED;
1751
+ _centralHeader.crc = Utils.crc32(value);
1752
+ _centralHeader.changed = true;
1753
+ } else {
1754
+ _centralHeader.method = Utils.Constants.STORED;
1755
+ }
1756
+ },
1757
+ getData: function(pass) {
1758
+ if (_centralHeader.changed) {
1759
+ return uncompressedData;
1760
+ } else {
1761
+ return decompress(false, null, pass);
1762
+ }
1763
+ },
1764
+ getDataAsync: function(callback, pass) {
1765
+ if (_centralHeader.changed) {
1766
+ callback(uncompressedData);
1767
+ } else {
1768
+ decompress(true, callback, pass);
1769
+ }
1770
+ },
1771
+ set attr(attr) {
1772
+ _centralHeader.attr = attr;
1773
+ },
1774
+ get attr() {
1775
+ return _centralHeader.attr;
1776
+ },
1777
+ set header(data) {
1778
+ _centralHeader.loadFromBinary(data);
1779
+ },
1780
+ get header() {
1781
+ return _centralHeader;
1782
+ },
1783
+ packCentralHeader: function() {
1784
+ _centralHeader.flags_efs = this.efs;
1785
+ _centralHeader.extraLength = _extra.length;
1786
+ var header = _centralHeader.centralHeaderToBinary();
1787
+ var addpos = Utils.Constants.CENHDR;
1788
+ _entryName.copy(header, addpos);
1789
+ addpos += _entryName.length;
1790
+ _extra.copy(header, addpos);
1791
+ addpos += _centralHeader.extraLength;
1792
+ _comment.copy(header, addpos);
1793
+ return header;
1794
+ },
1795
+ packLocalHeader: function() {
1796
+ let addpos = 0;
1797
+ _centralHeader.flags_efs = this.efs;
1798
+ _centralHeader.extraLocalLength = _extralocal.length;
1799
+ const localHeaderBuf = _centralHeader.localHeaderToBinary();
1800
+ const localHeader = Buffer.alloc(localHeaderBuf.length + _entryName.length + _centralHeader.extraLocalLength);
1801
+ localHeaderBuf.copy(localHeader, addpos);
1802
+ addpos += localHeaderBuf.length;
1803
+ _entryName.copy(localHeader, addpos);
1804
+ addpos += _entryName.length;
1805
+ _extralocal.copy(localHeader, addpos);
1806
+ addpos += _extralocal.length;
1807
+ return localHeader;
1808
+ },
1809
+ toJSON: function() {
1810
+ const bytes = function(nr) {
1811
+ return "<" + (nr && nr.length + " bytes buffer" || "null") + ">";
1812
+ };
1813
+ return {
1814
+ entryName: this.entryName,
1815
+ name: this.name,
1816
+ comment: this.comment,
1817
+ isDirectory: this.isDirectory,
1818
+ header: _centralHeader.toJSON(),
1819
+ compressedData: bytes(input),
1820
+ data: bytes(uncompressedData)
1821
+ };
1822
+ },
1823
+ toString: function() {
1824
+ return JSON.stringify(this.toJSON(), null, " ");
1825
+ }
1826
+ };
1827
+ };
1828
+ }
1829
+ });
1830
+
1831
+ // node_modules/adm-zip/zipFile.js
1832
+ var require_zipFile = __commonJS({
1833
+ "node_modules/adm-zip/zipFile.js"(exports, module) {
1834
+ var ZipEntry = require_zipEntry();
1835
+ var Headers = require_headers();
1836
+ var Utils = require_util();
1837
+ module.exports = function(inBuffer, options) {
1838
+ var entryList = [], entryTable = /* @__PURE__ */ Object.create(null), _comment = Buffer.alloc(0), mainHeader = new Headers.MainHeader(), loadedEntries = false;
1839
+ var password = null;
1840
+ const temporary = /* @__PURE__ */ new Set();
1841
+ const opts = options;
1842
+ const { noSort, decoder } = opts;
1843
+ if (inBuffer) {
1844
+ readMainHeader(opts.readEntries);
1845
+ } else {
1846
+ loadedEntries = true;
1847
+ }
1848
+ function makeTemporaryFolders() {
1849
+ const foldersList = /* @__PURE__ */ new Set();
1850
+ for (const elem of Object.keys(entryTable)) {
1851
+ const elements = elem.split("/");
1852
+ elements.pop();
1853
+ if (!elements.length) continue;
1854
+ for (let i = 0; i < elements.length; i++) {
1855
+ const sub = elements.slice(0, i + 1).join("/") + "/";
1856
+ foldersList.add(sub);
1857
+ }
1858
+ }
1859
+ for (const elem of foldersList) {
1860
+ if (!(elem in entryTable)) {
1861
+ const tempfolder = new ZipEntry(opts);
1862
+ tempfolder.entryName = elem;
1863
+ tempfolder.attr = 16;
1864
+ tempfolder.temporary = true;
1865
+ entryList.push(tempfolder);
1866
+ entryTable[tempfolder.entryName] = tempfolder;
1867
+ temporary.add(tempfolder);
1868
+ }
1869
+ }
1870
+ }
1871
+ function readEntries() {
1872
+ loadedEntries = true;
1873
+ entryTable = /* @__PURE__ */ Object.create(null);
1874
+ if (mainHeader.diskEntries > (inBuffer.length - mainHeader.offset) / Utils.Constants.CENHDR) {
1875
+ throw Utils.Errors.DISK_ENTRY_TOO_LARGE();
1876
+ }
1877
+ entryList = new Array(mainHeader.diskEntries);
1878
+ var index = mainHeader.offset;
1879
+ for (var i = 0; i < entryList.length; i++) {
1880
+ var tmp = index, entry = new ZipEntry(opts, inBuffer);
1881
+ entry.header = inBuffer.slice(tmp, tmp += Utils.Constants.CENHDR);
1882
+ entry.entryName = inBuffer.slice(tmp, tmp += entry.header.fileNameLength);
1883
+ if (entry.header.extraLength) {
1884
+ entry.extra = inBuffer.slice(tmp, tmp += entry.header.extraLength);
1885
+ }
1886
+ if (entry.header.commentLength) entry.comment = inBuffer.slice(tmp, tmp + entry.header.commentLength);
1887
+ index += entry.header.centralHeaderSize;
1888
+ if (entry.entryName in entryTable) {
1889
+ throw Utils.Errors.DUPLICATE_ENTRY(`"${entry.entryName}"`);
1890
+ }
1891
+ entryList[i] = entry;
1892
+ entryTable[entry.entryName] = entry;
1893
+ }
1894
+ temporary.clear();
1895
+ makeTemporaryFolders();
1896
+ }
1897
+ function readMainHeader(readNow) {
1898
+ var i = inBuffer.length - Utils.Constants.ENDHDR, max = Math.max(0, i - 65535), n = max, endStart = inBuffer.length, endOffset = -1, commentEnd = 0;
1899
+ const trailingSpace = typeof opts.trailingSpace === "boolean" ? opts.trailingSpace : false;
1900
+ if (trailingSpace) max = 0;
1901
+ for (i; i >= n; i--) {
1902
+ if (inBuffer[i] !== 80) continue;
1903
+ if (inBuffer.readUInt32LE(i) === Utils.Constants.ENDSIG) {
1904
+ endOffset = i;
1905
+ commentEnd = i;
1906
+ endStart = i + Utils.Constants.ENDHDR;
1907
+ n = i - Utils.Constants.END64HDR;
1908
+ continue;
1909
+ }
1910
+ if (inBuffer.readUInt32LE(i) === Utils.Constants.END64SIG) {
1911
+ n = max;
1912
+ continue;
1913
+ }
1914
+ if (inBuffer.readUInt32LE(i) === Utils.Constants.ZIP64SIG) {
1915
+ endOffset = i;
1916
+ endStart = i + Utils.readBigUInt64LE(inBuffer, i + Utils.Constants.ZIP64SIZE) + Utils.Constants.ZIP64LEAD;
1917
+ break;
1918
+ }
1919
+ }
1920
+ if (endOffset == -1) throw Utils.Errors.INVALID_FORMAT();
1921
+ mainHeader.loadFromBinary(inBuffer.slice(endOffset, endStart));
1922
+ if (mainHeader.commentLength) {
1923
+ _comment = inBuffer.slice(commentEnd + Utils.Constants.ENDHDR);
1924
+ }
1925
+ if (readNow) readEntries();
1926
+ }
1927
+ function sortEntries() {
1928
+ if (entryList.length > 1 && !noSort) {
1929
+ entryList = entryList.map((entry) => ({ entry, key: entry.entryName.toLowerCase() })).sort((a3, b3) => a3.key.localeCompare(b3.key)).map((pair) => pair.entry);
1930
+ }
1931
+ }
1932
+ return {
1933
+ /**
1934
+ * Returns an array of ZipEntry objects existent in the current opened archive
1935
+ * @return Array
1936
+ */
1937
+ get entries() {
1938
+ if (!loadedEntries) {
1939
+ readEntries();
1940
+ }
1941
+ return entryList.filter((e2) => !temporary.has(e2));
1942
+ },
1943
+ /**
1944
+ * Archive comment
1945
+ * @return {String}
1946
+ */
1947
+ get comment() {
1948
+ return decoder.decode(_comment);
1949
+ },
1950
+ set comment(val) {
1951
+ _comment = Utils.toBuffer(val, decoder.encode);
1952
+ mainHeader.commentLength = _comment.length;
1953
+ },
1954
+ getEntryCount: function() {
1955
+ if (!loadedEntries) {
1956
+ return mainHeader.diskEntries;
1957
+ }
1958
+ return entryList.length;
1959
+ },
1960
+ forEach: function(callback) {
1961
+ this.entries.forEach(callback);
1962
+ },
1963
+ /**
1964
+ * Returns a reference to the entry with the given name or null if entry is inexistent
1965
+ *
1966
+ * @param entryName
1967
+ * @return ZipEntry
1968
+ */
1969
+ getEntry: function(entryName) {
1970
+ if (!loadedEntries) {
1971
+ readEntries();
1972
+ }
1973
+ return entryTable[entryName] || null;
1974
+ },
1975
+ /**
1976
+ * Adds the given entry to the entry list
1977
+ *
1978
+ * @param entry
1979
+ */
1980
+ setEntry: function(entry) {
1981
+ if (!loadedEntries) {
1982
+ readEntries();
1983
+ }
1984
+ entryList.push(entry);
1985
+ entryTable[entry.entryName] = entry;
1986
+ mainHeader.totalEntries = entryList.length;
1987
+ },
1988
+ /**
1989
+ * Removes the file with the given name from the entry list.
1990
+ *
1991
+ * If the entry is a directory, then all nested files and directories will be removed
1992
+ * @param entryName
1993
+ * @returns {void}
1994
+ */
1995
+ deleteFile: function(entryName, withsubfolders = true) {
1996
+ if (!loadedEntries) {
1997
+ readEntries();
1998
+ }
1999
+ const entry = entryTable[entryName];
2000
+ const list = this.getEntryChildren(entry, withsubfolders).map((child) => child.entryName);
2001
+ list.forEach(this.deleteEntry);
2002
+ },
2003
+ /**
2004
+ * Removes the entry with the given name from the entry list.
2005
+ *
2006
+ * @param {string} entryName
2007
+ * @returns {void}
2008
+ */
2009
+ deleteEntry: function(entryName) {
2010
+ if (!loadedEntries) {
2011
+ readEntries();
2012
+ }
2013
+ const entry = entryTable[entryName];
2014
+ const index = entryList.indexOf(entry);
2015
+ if (index >= 0) {
2016
+ entryList.splice(index, 1);
2017
+ delete entryTable[entryName];
2018
+ mainHeader.totalEntries = entryList.length;
2019
+ }
2020
+ },
2021
+ /**
2022
+ * Iterates and returns all nested files and directories of the given entry
2023
+ *
2024
+ * @param entry
2025
+ * @return Array
2026
+ */
2027
+ getEntryChildren: function(entry, subfolders = true) {
2028
+ if (!loadedEntries) {
2029
+ readEntries();
2030
+ }
2031
+ if (typeof entry === "object") {
2032
+ if (entry.isDirectory && subfolders) {
2033
+ const list = [];
2034
+ const name = entry.entryName;
2035
+ for (const zipEntry of entryList) {
2036
+ if (zipEntry.entryName.startsWith(name)) {
2037
+ list.push(zipEntry);
2038
+ }
2039
+ }
2040
+ return list;
2041
+ } else {
2042
+ return [entry];
2043
+ }
2044
+ }
2045
+ return [];
2046
+ },
2047
+ /**
2048
+ * How many child elements entry has
2049
+ *
2050
+ * @param {ZipEntry} entry
2051
+ * @return {integer}
2052
+ */
2053
+ getChildCount: function(entry) {
2054
+ if (entry && entry.isDirectory) {
2055
+ const list = this.getEntryChildren(entry);
2056
+ return list.includes(entry) ? list.length - 1 : list.length;
2057
+ }
2058
+ return 0;
2059
+ },
2060
+ /**
2061
+ * Returns the zip file
2062
+ *
2063
+ * @return Buffer
2064
+ */
2065
+ compressToBuffer: function() {
2066
+ if (!loadedEntries) {
2067
+ readEntries();
2068
+ }
2069
+ sortEntries();
2070
+ const dataBlock = [];
2071
+ const headerBlocks = [];
2072
+ let totalSize = 0;
2073
+ let dindex = 0;
2074
+ mainHeader.size = 0;
2075
+ mainHeader.offset = 0;
2076
+ let totalEntries = 0;
2077
+ for (const entry of this.entries) {
2078
+ const compressedData = entry.getCompressedData();
2079
+ entry.header.offset = dindex;
2080
+ const localHeader = entry.packLocalHeader();
2081
+ const dataLength = localHeader.length + compressedData.length;
2082
+ dindex += dataLength;
2083
+ dataBlock.push(localHeader);
2084
+ dataBlock.push(compressedData);
2085
+ const centralHeader = entry.packCentralHeader();
2086
+ headerBlocks.push(centralHeader);
2087
+ mainHeader.size += centralHeader.length;
2088
+ totalSize += dataLength + centralHeader.length;
2089
+ totalEntries++;
2090
+ }
2091
+ totalSize += mainHeader.mainHeaderSize;
2092
+ mainHeader.offset = dindex;
2093
+ mainHeader.totalEntries = totalEntries;
2094
+ dindex = 0;
2095
+ const outBuffer = Buffer.alloc(totalSize);
2096
+ for (const content of dataBlock) {
2097
+ content.copy(outBuffer, dindex);
2098
+ dindex += content.length;
2099
+ }
2100
+ for (const content of headerBlocks) {
2101
+ content.copy(outBuffer, dindex);
2102
+ dindex += content.length;
2103
+ }
2104
+ const mh = mainHeader.toBinary();
2105
+ if (_comment) {
2106
+ _comment.copy(mh, mh.length - _comment.length);
2107
+ }
2108
+ mh.copy(outBuffer, dindex);
2109
+ inBuffer = outBuffer;
2110
+ loadedEntries = false;
2111
+ return outBuffer;
2112
+ },
2113
+ toAsyncBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
2114
+ try {
2115
+ if (!loadedEntries) {
2116
+ readEntries();
2117
+ }
2118
+ sortEntries();
2119
+ const dataBlock = [];
2120
+ const centralHeaders = [];
2121
+ let totalSize = 0;
2122
+ let dindex = 0;
2123
+ let totalEntries = 0;
2124
+ mainHeader.size = 0;
2125
+ mainHeader.offset = 0;
2126
+ const compress2Buffer = function(entryLists) {
2127
+ if (entryLists.length > 0) {
2128
+ const entry = entryLists.shift();
2129
+ const name = entry.entryName + entry.extra.toString();
2130
+ if (onItemStart) onItemStart(name);
2131
+ entry.getCompressedDataAsync(function(compressedData) {
2132
+ if (onItemEnd) onItemEnd(name);
2133
+ entry.header.offset = dindex;
2134
+ const localHeader = entry.packLocalHeader();
2135
+ const dataLength = localHeader.length + compressedData.length;
2136
+ dindex += dataLength;
2137
+ dataBlock.push(localHeader);
2138
+ dataBlock.push(compressedData);
2139
+ const centalHeader = entry.packCentralHeader();
2140
+ centralHeaders.push(centalHeader);
2141
+ mainHeader.size += centalHeader.length;
2142
+ totalSize += dataLength + centalHeader.length;
2143
+ totalEntries++;
2144
+ compress2Buffer(entryLists);
2145
+ });
2146
+ } else {
2147
+ totalSize += mainHeader.mainHeaderSize;
2148
+ mainHeader.offset = dindex;
2149
+ mainHeader.totalEntries = totalEntries;
2150
+ dindex = 0;
2151
+ const outBuffer = Buffer.alloc(totalSize);
2152
+ dataBlock.forEach(function(content) {
2153
+ content.copy(outBuffer, dindex);
2154
+ dindex += content.length;
2155
+ });
2156
+ centralHeaders.forEach(function(content) {
2157
+ content.copy(outBuffer, dindex);
2158
+ dindex += content.length;
2159
+ });
2160
+ const mh = mainHeader.toBinary();
2161
+ if (_comment) {
2162
+ _comment.copy(mh, mh.length - _comment.length);
2163
+ }
2164
+ mh.copy(outBuffer, dindex);
2165
+ inBuffer = outBuffer;
2166
+ loadedEntries = false;
2167
+ onSuccess(outBuffer);
2168
+ }
2169
+ };
2170
+ compress2Buffer(Array.from(this.entries));
2171
+ } catch (e2) {
2172
+ onFail(e2);
2173
+ }
2174
+ }
2175
+ };
2176
+ };
2177
+ }
2178
+ });
2179
+
2180
+ // node_modules/adm-zip/adm-zip.js
2181
+ var require_adm_zip = __commonJS({
2182
+ "node_modules/adm-zip/adm-zip.js"(exports, module) {
2183
+ var Utils = require_util();
2184
+ var pth = __require("path");
2185
+ var ZipEntry = require_zipEntry();
2186
+ var ZipFile = require_zipFile();
2187
+ var get_Bool = (...val) => Utils.findLast(val, (c2) => typeof c2 === "boolean");
2188
+ var get_Str = (...val) => Utils.findLast(val, (c2) => typeof c2 === "string");
2189
+ var get_Fun = (...val) => Utils.findLast(val, (c2) => typeof c2 === "function");
2190
+ var defaultOptions = {
2191
+ // option "noSort" : if true it disables files sorting
2192
+ noSort: false,
2193
+ // read entries during load (initial loading may be slower)
2194
+ readEntries: false,
2195
+ // default method is none
2196
+ method: Utils.Constants.NONE,
2197
+ // file system
2198
+ fs: null
2199
+ };
2200
+ module.exports = function(input, options) {
2201
+ let inBuffer = null;
2202
+ const opts = Object.assign(/* @__PURE__ */ Object.create(null), defaultOptions);
2203
+ if (input && "object" === typeof input) {
2204
+ if (!(input instanceof Uint8Array)) {
2205
+ Object.assign(opts, input);
2206
+ input = opts.input ? opts.input : void 0;
2207
+ if (opts.input) delete opts.input;
2208
+ }
2209
+ if (Buffer.isBuffer(input)) {
2210
+ inBuffer = input;
2211
+ opts.method = Utils.Constants.BUFFER;
2212
+ input = void 0;
2213
+ }
2214
+ }
2215
+ Object.assign(opts, options);
2216
+ const filetools = new Utils(opts);
2217
+ const applyDirAttributes = (dirEntries) => {
2218
+ dirEntries.filter((d2) => d2.attr).sort((a3, b3) => b3.path.length - a3.path.length).forEach((d2) => filetools.fs.chmodSync(d2.path, d2.attr));
2219
+ };
2220
+ if (typeof opts.decoder !== "object" || typeof opts.decoder.encode !== "function" || typeof opts.decoder.decode !== "function") {
2221
+ opts.decoder = Utils.decoder;
2222
+ }
2223
+ if (input && "string" === typeof input) {
2224
+ if (filetools.fs.existsSync(input)) {
2225
+ opts.method = Utils.Constants.FILE;
2226
+ opts.filename = input;
2227
+ inBuffer = filetools.fs.readFileSync(input);
2228
+ } else {
2229
+ throw Utils.Errors.INVALID_FILENAME();
2230
+ }
2231
+ }
2232
+ const _zip = new ZipFile(inBuffer, opts);
2233
+ const { canonical, sanitize, zipnamefix } = Utils;
2234
+ function getEntry(entry) {
2235
+ if (entry && _zip) {
2236
+ var item;
2237
+ if (typeof entry === "string") item = _zip.getEntry(pth.posix.normalize(entry));
2238
+ if (typeof entry === "object" && typeof entry.entryName !== "undefined" && typeof entry.header !== "undefined") item = _zip.getEntry(entry.entryName);
2239
+ if (item) {
2240
+ return item;
2241
+ }
2242
+ }
2243
+ return null;
2244
+ }
2245
+ function fixPath(zipPath) {
2246
+ const { join, normalize, sep } = pth.posix;
2247
+ return join(pth.isAbsolute(zipPath) ? "/" : ".", normalize(sep + zipPath.split("\\").join(sep) + sep));
2248
+ }
2249
+ function filenameFilter(filterfn) {
2250
+ if (filterfn instanceof RegExp) {
2251
+ return /* @__PURE__ */ (function(rx) {
2252
+ return function(filename) {
2253
+ return rx.test(filename);
2254
+ };
2255
+ })(filterfn);
2256
+ } else if ("function" !== typeof filterfn) {
2257
+ return () => true;
2258
+ }
2259
+ return filterfn;
2260
+ }
2261
+ const relativePath = (local, entry) => {
2262
+ let lastChar = entry.slice(-1);
2263
+ lastChar = lastChar === filetools.sep ? filetools.sep : "";
2264
+ return pth.relative(local, entry) + lastChar;
2265
+ };
2266
+ return {
2267
+ /**
2268
+ * Extracts the given entry from the archive and returns the content as a Buffer object
2269
+ * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2270
+ * @param {Buffer|string} [pass] - password
2271
+ * @return Buffer or Null in case of error
2272
+ */
2273
+ readFile: function(entry, pass) {
2274
+ var item = getEntry(entry);
2275
+ return item && item.getData(pass) || null;
2276
+ },
2277
+ /**
2278
+ * Returns how many child elements has on entry (directories) on files it is always 0
2279
+ * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2280
+ * @returns {integer}
2281
+ */
2282
+ childCount: function(entry) {
2283
+ const item = getEntry(entry);
2284
+ if (item) {
2285
+ return _zip.getChildCount(item);
2286
+ }
2287
+ },
2288
+ /**
2289
+ * Asynchronous readFile
2290
+ * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2291
+ * @param {callback} callback
2292
+ *
2293
+ * @return Buffer or Null in case of error
2294
+ */
2295
+ readFileAsync: function(entry, callback) {
2296
+ var item = getEntry(entry);
2297
+ if (item) {
2298
+ item.getDataAsync(callback);
2299
+ } else {
2300
+ callback(null, "getEntry failed for:" + entry);
2301
+ }
2302
+ },
2303
+ /**
2304
+ * Extracts the given entry from the archive and returns the content as plain text in the given encoding
2305
+ * @param {ZipEntry|string} entry - ZipEntry object or String with the full path of the entry
2306
+ * @param {string} encoding - Optional. If no encoding is specified utf8 is used
2307
+ *
2308
+ * @return String
2309
+ */
2310
+ readAsText: function(entry, encoding) {
2311
+ var item = getEntry(entry);
2312
+ if (item) {
2313
+ var data = item.getData();
2314
+ if (data && data.length) {
2315
+ return data.toString(encoding || "utf8");
2316
+ }
2317
+ }
2318
+ return "";
2319
+ },
2320
+ /**
2321
+ * Asynchronous readAsText
2322
+ * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2323
+ * @param {callback} callback
2324
+ * @param {string} [encoding] - Optional. If no encoding is specified utf8 is used
2325
+ *
2326
+ * @return String
2327
+ */
2328
+ readAsTextAsync: function(entry, callback, encoding) {
2329
+ var item = getEntry(entry);
2330
+ if (item) {
2331
+ item.getDataAsync(function(data, err) {
2332
+ if (err) {
2333
+ callback(data, err);
2334
+ return;
2335
+ }
2336
+ if (data && data.length) {
2337
+ callback(data.toString(encoding || "utf8"));
2338
+ } else {
2339
+ callback("");
2340
+ }
2341
+ });
2342
+ } else {
2343
+ callback("");
2344
+ }
2345
+ },
2346
+ /**
2347
+ * Remove the entry from the file or the entry and all it's nested directories and files if the given entry is a directory
2348
+ *
2349
+ * @param {ZipEntry|string} entry
2350
+ * @param {boolean} withsubfolders
2351
+ * @returns {void}
2352
+ */
2353
+ deleteFile: function(entry, withsubfolders = true) {
2354
+ var item = getEntry(entry);
2355
+ if (item) {
2356
+ _zip.deleteFile(item.entryName, withsubfolders);
2357
+ }
2358
+ },
2359
+ /**
2360
+ * Remove the entry from the file or directory without affecting any nested entries
2361
+ *
2362
+ * @param {ZipEntry|string} entry
2363
+ * @returns {void}
2364
+ */
2365
+ deleteEntry: function(entry) {
2366
+ var item = getEntry(entry);
2367
+ if (item) {
2368
+ _zip.deleteEntry(item.entryName);
2369
+ }
2370
+ },
2371
+ /**
2372
+ * Adds a comment to the zip. The zip must be rewritten after adding the comment.
2373
+ *
2374
+ * @param {string} comment
2375
+ */
2376
+ addZipComment: function(comment) {
2377
+ _zip.comment = comment;
2378
+ },
2379
+ /**
2380
+ * Returns the zip comment
2381
+ *
2382
+ * @return String
2383
+ */
2384
+ getZipComment: function() {
2385
+ return _zip.comment || "";
2386
+ },
2387
+ /**
2388
+ * Adds a comment to a specified zipEntry. The zip must be rewritten after adding the comment
2389
+ * The comment cannot exceed 65535 characters in length
2390
+ *
2391
+ * @param {ZipEntry} entry
2392
+ * @param {string} comment
2393
+ */
2394
+ addZipEntryComment: function(entry, comment) {
2395
+ var item = getEntry(entry);
2396
+ if (item) {
2397
+ item.comment = comment;
2398
+ }
2399
+ },
2400
+ /**
2401
+ * Returns the comment of the specified entry
2402
+ *
2403
+ * @param {ZipEntry} entry
2404
+ * @return String
2405
+ */
2406
+ getZipEntryComment: function(entry) {
2407
+ var item = getEntry(entry);
2408
+ if (item) {
2409
+ return item.comment || "";
2410
+ }
2411
+ return "";
2412
+ },
2413
+ /**
2414
+ * Updates the content of an existing entry inside the archive. The zip must be rewritten after updating the content
2415
+ *
2416
+ * @param {ZipEntry} entry
2417
+ * @param {Buffer} content
2418
+ */
2419
+ updateFile: function(entry, content) {
2420
+ var item = getEntry(entry);
2421
+ if (item) {
2422
+ item.setData(content);
2423
+ }
2424
+ },
2425
+ /**
2426
+ * Adds a file from the disk to the archive
2427
+ *
2428
+ * @param {string} localPath File to add to zip
2429
+ * @param {string} [zipPath] Optional path inside the zip
2430
+ * @param {string} [zipName] Optional name for the file
2431
+ * @param {string} [comment] Optional file comment
2432
+ */
2433
+ addLocalFile: function(localPath, zipPath, zipName, comment) {
2434
+ if (filetools.fs.existsSync(localPath)) {
2435
+ zipPath = zipPath ? fixPath(zipPath) : "";
2436
+ const p = pth.win32.basename(pth.win32.normalize(localPath));
2437
+ zipPath += zipName ? zipName : p;
2438
+ const _attr = filetools.fs.statSync(localPath);
2439
+ const data = _attr.isFile() ? filetools.fs.readFileSync(localPath) : Buffer.alloc(0);
2440
+ if (_attr.isDirectory()) zipPath += filetools.sep;
2441
+ this.addFile(zipPath, data, comment, _attr);
2442
+ } else {
2443
+ throw Utils.Errors.FILE_NOT_FOUND(localPath);
2444
+ }
2445
+ },
2446
+ /**
2447
+ * Callback for showing if everything was done.
2448
+ *
2449
+ * @callback doneCallback
2450
+ * @param {Error} err - Error object
2451
+ * @param {boolean} done - was request fully completed
2452
+ */
2453
+ /**
2454
+ * Adds a file from the disk to the archive
2455
+ *
2456
+ * @param {(object|string)} options - options object, if it is string it us used as localPath.
2457
+ * @param {string} options.localPath - Local path to the file.
2458
+ * @param {string} [options.comment] - Optional file comment.
2459
+ * @param {string} [options.zipPath] - Optional path inside the zip
2460
+ * @param {string} [options.zipName] - Optional name for the file
2461
+ * @param {doneCallback} callback - The callback that handles the response.
2462
+ */
2463
+ addLocalFileAsync: function(options2, callback) {
2464
+ options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
2465
+ const localPath = pth.resolve(options2.localPath);
2466
+ const { comment } = options2;
2467
+ let { zipPath, zipName } = options2;
2468
+ const self = this;
2469
+ filetools.fs.stat(localPath, function(err, stats) {
2470
+ if (err) return callback(err, false);
2471
+ zipPath = zipPath ? fixPath(zipPath) : "";
2472
+ const p = pth.win32.basename(pth.win32.normalize(localPath));
2473
+ zipPath += zipName ? zipName : p;
2474
+ if (stats.isFile()) {
2475
+ filetools.fs.readFile(localPath, function(err2, data) {
2476
+ if (err2) return callback(err2, false);
2477
+ self.addFile(zipPath, data, comment, stats);
2478
+ return setImmediate(callback, void 0, true);
2479
+ });
2480
+ } else if (stats.isDirectory()) {
2481
+ zipPath += filetools.sep;
2482
+ self.addFile(zipPath, Buffer.alloc(0), comment, stats);
2483
+ return setImmediate(callback, void 0, true);
2484
+ }
2485
+ });
2486
+ },
2487
+ /**
2488
+ * Adds a local directory and all its nested files and directories to the archive
2489
+ *
2490
+ * @param {string} localPath - local path to the folder
2491
+ * @param {string} [zipPath] - optional path inside zip
2492
+ * @param {(RegExp|function)} [filter] - optional RegExp or Function if files match will be included.
2493
+ */
2494
+ addLocalFolder: function(localPath, zipPath, filter) {
2495
+ filter = filenameFilter(filter);
2496
+ zipPath = zipPath ? fixPath(zipPath) : "";
2497
+ localPath = pth.normalize(localPath);
2498
+ if (filetools.fs.existsSync(localPath)) {
2499
+ const items = filetools.findFiles(localPath);
2500
+ const self = this;
2501
+ if (items.length) {
2502
+ for (const filepath of items) {
2503
+ const p = pth.join(zipPath, relativePath(localPath, filepath));
2504
+ if (filter(p)) {
2505
+ self.addLocalFile(filepath, pth.dirname(p));
2506
+ }
2507
+ }
2508
+ }
2509
+ } else {
2510
+ throw Utils.Errors.FILE_NOT_FOUND(localPath);
2511
+ }
2512
+ },
2513
+ /**
2514
+ * Asynchronous addLocalFolder
2515
+ * @param {string} localPath
2516
+ * @param {callback} callback
2517
+ * @param {string} [zipPath] optional path inside zip
2518
+ * @param {RegExp|function} [filter] optional RegExp or Function if files match will
2519
+ * be included.
2520
+ */
2521
+ addLocalFolderAsync: function(localPath, callback, zipPath, filter) {
2522
+ filter = filenameFilter(filter);
2523
+ zipPath = zipPath ? fixPath(zipPath) : "";
2524
+ localPath = pth.normalize(localPath);
2525
+ var self = this;
2526
+ filetools.fs.open(localPath, "r", function(err) {
2527
+ if (err && err.code === "ENOENT") {
2528
+ callback(void 0, Utils.Errors.FILE_NOT_FOUND(localPath));
2529
+ } else if (err) {
2530
+ callback(void 0, err);
2531
+ } else {
2532
+ var items = filetools.findFiles(localPath);
2533
+ var i = -1;
2534
+ var next = function() {
2535
+ i += 1;
2536
+ if (i < items.length) {
2537
+ var filepath = items[i];
2538
+ var p = relativePath(localPath, filepath).split("\\").join("/");
2539
+ p = p.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
2540
+ if (filter(p)) {
2541
+ filetools.fs.stat(filepath, function(er0, stats) {
2542
+ if (er0) callback(void 0, er0);
2543
+ if (stats.isFile()) {
2544
+ filetools.fs.readFile(filepath, function(er1, data) {
2545
+ if (er1) {
2546
+ callback(void 0, er1);
2547
+ } else {
2548
+ self.addFile(zipPath + p, data, "", stats);
2549
+ next();
2550
+ }
2551
+ });
2552
+ } else {
2553
+ self.addFile(zipPath + p + "/", Buffer.alloc(0), "", stats);
2554
+ next();
2555
+ }
2556
+ });
2557
+ } else {
2558
+ process.nextTick(() => {
2559
+ next();
2560
+ });
2561
+ }
2562
+ } else {
2563
+ callback(true, void 0);
2564
+ }
2565
+ };
2566
+ next();
2567
+ }
2568
+ });
2569
+ },
2570
+ /**
2571
+ * Adds a local directory and all its nested files and directories to the archive
2572
+ *
2573
+ * @param {object | string} options - options object, if it is string it us used as localPath.
2574
+ * @param {string} options.localPath - Local path to the folder.
2575
+ * @param {string} [options.zipPath] - optional path inside zip.
2576
+ * @param {RegExp|function} [options.filter] - optional RegExp or Function if files match will be included.
2577
+ * @param {function|string} [options.namefix] - optional function to help fix filename
2578
+ * @param {doneCallback} callback - The callback that handles the response.
2579
+ *
2580
+ */
2581
+ addLocalFolderAsync2: function(options2, callback) {
2582
+ const self = this;
2583
+ options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
2584
+ const localPath = pth.resolve(options2.localPath);
2585
+ let { zipPath, filter, namefix } = options2;
2586
+ if (filter instanceof RegExp) {
2587
+ filter = /* @__PURE__ */ (function(rx) {
2588
+ return function(filename) {
2589
+ return rx.test(filename);
2590
+ };
2591
+ })(filter);
2592
+ } else if ("function" !== typeof filter) {
2593
+ filter = function() {
2594
+ return true;
2595
+ };
2596
+ }
2597
+ zipPath = zipPath ? fixPath(zipPath) : "";
2598
+ if (namefix === "latin1") {
2599
+ namefix = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
2600
+ }
2601
+ if (typeof namefix !== "function") namefix = (str) => str;
2602
+ const relPathFix = (entry) => pth.join(zipPath, namefix(relativePath(localPath, entry)));
2603
+ const fileNameFix = (entry) => pth.win32.basename(pth.win32.normalize(namefix(entry)));
2604
+ filetools.fs.open(localPath, "r", function(err) {
2605
+ if (err && err.code === "ENOENT") {
2606
+ callback(Utils.Errors.FILE_NOT_FOUND(localPath), false);
2607
+ } else if (err) {
2608
+ callback(err, false);
2609
+ } else {
2610
+ filetools.findFilesAsync(localPath, function(err2, fileEntries) {
2611
+ if (err2) return callback(err2, false);
2612
+ fileEntries = fileEntries.filter((dir) => filter(relPathFix(dir)));
2613
+ if (!fileEntries.length) return callback(void 0, true);
2614
+ setImmediate(
2615
+ fileEntries.reverse().reduce(function(next, entry) {
2616
+ return function(err3, done) {
2617
+ if (err3 || done === false) return setImmediate(next, err3, false);
2618
+ self.addLocalFileAsync(
2619
+ {
2620
+ localPath: entry,
2621
+ zipPath: pth.dirname(relPathFix(entry)),
2622
+ zipName: fileNameFix(entry)
2623
+ },
2624
+ next
2625
+ );
2626
+ };
2627
+ }, callback)
2628
+ );
2629
+ });
2630
+ }
2631
+ });
2632
+ },
2633
+ /**
2634
+ * Adds a local directory and all its nested files and directories to the archive
2635
+ *
2636
+ * @param {string} localPath - path where files will be extracted
2637
+ * @param {object} props - optional properties
2638
+ * @param {string} [props.zipPath] - optional path inside zip
2639
+ * @param {RegExp|function} [props.filter] - optional RegExp or Function if files match will be included.
2640
+ * @param {function|string} [props.namefix] - optional function to help fix filename
2641
+ */
2642
+ addLocalFolderPromise: function(localPath, props) {
2643
+ return new Promise((resolve, reject) => {
2644
+ this.addLocalFolderAsync2(Object.assign({ localPath }, props), (err, done) => {
2645
+ if (err) return reject(err);
2646
+ if (done) resolve(this);
2647
+ });
2648
+ });
2649
+ },
2650
+ /**
2651
+ * Allows you to create a entry (file or directory) in the zip file.
2652
+ * If you want to create a directory the entryName must end in / and a null buffer should be provided.
2653
+ * Comment and attributes are optional
2654
+ *
2655
+ * @param {string} entryName
2656
+ * @param {Buffer | string} content - file content as buffer or utf8 coded string
2657
+ * @param {string} [comment] - file comment
2658
+ * @param {number | object} [attr] - number as unix file permissions, object as filesystem Stats object
2659
+ */
2660
+ addFile: function(entryName, content, comment, attr) {
2661
+ entryName = zipnamefix(entryName);
2662
+ let entry = getEntry(entryName);
2663
+ const update = entry != null;
2664
+ if (!update) {
2665
+ entry = new ZipEntry(opts);
2666
+ entry.entryName = entryName;
2667
+ }
2668
+ entry.comment = comment || "";
2669
+ const isStat = "object" === typeof attr && attr instanceof filetools.fs.Stats;
2670
+ if (isStat) {
2671
+ entry.header.time = attr.mtime;
2672
+ }
2673
+ var fileattr = entry.isDirectory ? 16 : 0;
2674
+ let unix = entry.isDirectory ? 16384 : 32768;
2675
+ if (isStat) {
2676
+ unix |= 4095 & attr.mode;
2677
+ } else if ("number" === typeof attr) {
2678
+ unix |= 4095 & attr;
2679
+ } else {
2680
+ unix |= entry.isDirectory ? 493 : 420;
2681
+ }
2682
+ fileattr = (fileattr | unix << 16) >>> 0;
2683
+ entry.attr = fileattr;
2684
+ entry.setData(content);
2685
+ if (!update) _zip.setEntry(entry);
2686
+ return entry;
2687
+ },
2688
+ /**
2689
+ * Returns an array of ZipEntry objects representing the files and folders inside the archive
2690
+ *
2691
+ * @param {string} [password]
2692
+ * @returns Array
2693
+ */
2694
+ getEntries: function(password) {
2695
+ _zip.password = password;
2696
+ return _zip ? _zip.entries : [];
2697
+ },
2698
+ /**
2699
+ * Returns a ZipEntry object representing the file or folder specified by ``name``.
2700
+ *
2701
+ * @param {string} name
2702
+ * @return ZipEntry
2703
+ */
2704
+ getEntry: function(name) {
2705
+ return getEntry(name);
2706
+ },
2707
+ getEntryCount: function() {
2708
+ return _zip.getEntryCount();
2709
+ },
2710
+ forEach: function(callback) {
2711
+ return _zip.forEach(callback);
2712
+ },
2713
+ /**
2714
+ * Extracts the given entry to the given targetPath
2715
+ * If the entry is a directory inside the archive, the entire directory and it's subdirectories will be extracted
2716
+ *
2717
+ * @param {string|ZipEntry} entry - ZipEntry object or String with the full path of the entry
2718
+ * @param {string} targetPath - Target folder where to write the file
2719
+ * @param {boolean} [maintainEntryPath=true] - If maintainEntryPath is true and the entry is inside a folder, the entry folder will be created in targetPath as well. Default is TRUE
2720
+ * @param {boolean} [overwrite=false] - If the file already exists at the target path, the file will be overwriten if this is true.
2721
+ * @param {boolean} [keepOriginalPermission=false] - The file will be set as the permission from the entry if this is true.
2722
+ * @param {string} [outFileName] - String If set will override the filename of the extracted file (Only works if the entry is a file)
2723
+ *
2724
+ * @return Boolean
2725
+ */
2726
+ extractEntryTo: function(entry, targetPath, maintainEntryPath, overwrite, keepOriginalPermission, outFileName) {
2727
+ overwrite = get_Bool(false, overwrite);
2728
+ keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2729
+ maintainEntryPath = get_Bool(true, maintainEntryPath);
2730
+ outFileName = get_Str(keepOriginalPermission, outFileName);
2731
+ var item = getEntry(entry);
2732
+ if (!item) {
2733
+ throw Utils.Errors.NO_ENTRY();
2734
+ }
2735
+ var entryName = canonical(item.entryName);
2736
+ var target = sanitize(targetPath, outFileName && !item.isDirectory ? canonical(outFileName) : maintainEntryPath ? entryName : pth.basename(entryName));
2737
+ if (item.isDirectory) {
2738
+ var children = _zip.getEntryChildren(item);
2739
+ children.forEach(function(child) {
2740
+ if (child.isDirectory) return;
2741
+ var content2 = child.getData();
2742
+ if (!content2) {
2743
+ throw Utils.Errors.CANT_EXTRACT_FILE();
2744
+ }
2745
+ var name = canonical(maintainEntryPath ? child.entryName : child.entryName.substring(item.entryName.length));
2746
+ var childName = sanitize(targetPath, name);
2747
+ filetools.assertPathSafe(targetPath, childName);
2748
+ const fileAttr2 = keepOriginalPermission ? child.header.fileAttr : void 0;
2749
+ filetools.writeFileTo(childName, content2, overwrite, fileAttr2);
2750
+ });
2751
+ return true;
2752
+ }
2753
+ var content = item.getData(_zip.password);
2754
+ if (!content) throw Utils.Errors.CANT_EXTRACT_FILE();
2755
+ filetools.assertPathSafe(targetPath, target);
2756
+ if (filetools.fs.existsSync(target) && !overwrite) {
2757
+ throw Utils.Errors.CANT_OVERRIDE();
2758
+ }
2759
+ const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2760
+ filetools.writeFileTo(target, content, overwrite, fileAttr);
2761
+ return true;
2762
+ },
2763
+ /**
2764
+ * Test the archive
2765
+ * @param {string} [pass]
2766
+ */
2767
+ test: function(pass) {
2768
+ if (!_zip) {
2769
+ return false;
2770
+ }
2771
+ for (var entry of _zip.entries) {
2772
+ try {
2773
+ if (entry.isDirectory) {
2774
+ continue;
2775
+ }
2776
+ var content = entry.getData(pass);
2777
+ if (!content) {
2778
+ return false;
2779
+ }
2780
+ } catch (err) {
2781
+ return false;
2782
+ }
2783
+ }
2784
+ return true;
2785
+ },
2786
+ /**
2787
+ * Extracts the entire archive to the given location
2788
+ *
2789
+ * @param {string} targetPath Target location
2790
+ * @param {boolean} [overwrite=false] If the file already exists at the target path, the file will be overwriten if this is true.
2791
+ * Default is FALSE
2792
+ * @param {boolean} [keepOriginalPermission=false] The file will be set as the permission from the entry if this is true.
2793
+ * Default is FALSE
2794
+ * @param {string|Buffer} [pass] password
2795
+ */
2796
+ extractAllTo: function(targetPath, overwrite, keepOriginalPermission, pass) {
2797
+ keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2798
+ pass = get_Str(keepOriginalPermission, pass);
2799
+ overwrite = get_Bool(false, overwrite);
2800
+ if (!_zip) throw Utils.Errors.NO_ZIP();
2801
+ const dirEntries = [];
2802
+ _zip.entries.forEach(function(entry) {
2803
+ var entryName = sanitize(targetPath, canonical(entry.entryName));
2804
+ filetools.assertPathSafe(targetPath, entryName);
2805
+ if (entry.isDirectory) {
2806
+ filetools.makeDir(entryName);
2807
+ if (keepOriginalPermission) dirEntries.push({ path: entryName, attr: entry.header.fileAttr });
2808
+ return;
2809
+ }
2810
+ var content = entry.getData(pass);
2811
+ if (!content) {
2812
+ throw Utils.Errors.CANT_EXTRACT_FILE();
2813
+ }
2814
+ const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2815
+ filetools.writeFileTo(entryName, content, overwrite, fileAttr);
2816
+ try {
2817
+ filetools.fs.utimesSync(entryName, entry.header.time, entry.header.time);
2818
+ } catch (err) {
2819
+ }
2820
+ });
2821
+ applyDirAttributes(dirEntries);
2822
+ },
2823
+ /**
2824
+ * Asynchronous extractAllTo
2825
+ *
2826
+ * @param {string} targetPath Target location
2827
+ * @param {boolean} [overwrite=false] If the file already exists at the target path, the file will be overwriten if this is true.
2828
+ * Default is FALSE
2829
+ * @param {boolean} [keepOriginalPermission=false] The file will be set as the permission from the entry if this is true.
2830
+ * Default is FALSE
2831
+ * @param {function} callback The callback will be executed when all entries are extracted successfully or any error is thrown.
2832
+ */
2833
+ extractAllToAsync: function(targetPath, overwrite, keepOriginalPermission, callback) {
2834
+ callback = get_Fun(overwrite, keepOriginalPermission, callback);
2835
+ keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2836
+ overwrite = get_Bool(false, overwrite);
2837
+ if (!callback) {
2838
+ return new Promise((resolve, reject) => {
2839
+ this.extractAllToAsync(targetPath, overwrite, keepOriginalPermission, function(err) {
2840
+ if (err) {
2841
+ reject(err);
2842
+ } else {
2843
+ resolve(this);
2844
+ }
2845
+ });
2846
+ });
2847
+ }
2848
+ if (!_zip) {
2849
+ callback(Utils.Errors.NO_ZIP());
2850
+ return;
2851
+ }
2852
+ targetPath = pth.resolve(targetPath);
2853
+ const getPath = (entry) => sanitize(targetPath, pth.normalize(canonical(entry.entryName)));
2854
+ const getError = (msg, file) => new Error(msg + ': "' + file + '"');
2855
+ const dirEntries = [];
2856
+ const fileEntries = [];
2857
+ _zip.entries.forEach((e2) => {
2858
+ if (e2.isDirectory) {
2859
+ dirEntries.push(e2);
2860
+ } else {
2861
+ fileEntries.push(e2);
2862
+ }
2863
+ });
2864
+ const deferredDirAttr = [];
2865
+ for (const entry of dirEntries) {
2866
+ const dirPath = getPath(entry);
2867
+ const dirAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2868
+ try {
2869
+ filetools.assertPathSafe(targetPath, dirPath);
2870
+ filetools.makeDir(dirPath);
2871
+ } catch (er) {
2872
+ callback(getError("Unable to create folder", dirPath));
2873
+ continue;
2874
+ }
2875
+ if (dirAttr) deferredDirAttr.push({ path: dirPath, attr: dirAttr });
2876
+ try {
2877
+ filetools.fs.utimesSync(dirPath, entry.header.time, entry.header.time);
2878
+ } catch (er) {
2879
+ }
2880
+ }
2881
+ const done = (err) => {
2882
+ if (!err) {
2883
+ try {
2884
+ applyDirAttributes(deferredDirAttr);
2885
+ } catch (er) {
2886
+ return callback(getError("Unable to set folder permissions", er.path || ""));
2887
+ }
2888
+ }
2889
+ callback(err);
2890
+ };
2891
+ fileEntries.reverse().reduce(function(next, entry) {
2892
+ return function(err) {
2893
+ if (err) {
2894
+ next(err);
2895
+ } else {
2896
+ const entryName = pth.normalize(canonical(entry.entryName));
2897
+ const filePath = sanitize(targetPath, entryName);
2898
+ try {
2899
+ filetools.assertPathSafe(targetPath, filePath);
2900
+ } catch (er) {
2901
+ return next(er);
2902
+ }
2903
+ entry.getDataAsync(function(content, err_1) {
2904
+ if (err_1) {
2905
+ next(err_1);
2906
+ } else if (!content) {
2907
+ next(Utils.Errors.CANT_EXTRACT_FILE());
2908
+ } else {
2909
+ const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2910
+ filetools.writeFileToAsync(filePath, content, overwrite, fileAttr, function(succ) {
2911
+ if (!succ) {
2912
+ return next(getError("Unable to write file", filePath));
2913
+ }
2914
+ filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function() {
2915
+ next();
2916
+ });
2917
+ });
2918
+ }
2919
+ });
2920
+ }
2921
+ };
2922
+ }, done)();
2923
+ },
2924
+ /**
2925
+ * Writes the newly created zip file to disk at the specified location or if a zip was opened and no ``targetFileName`` is provided, it will overwrite the opened zip
2926
+ *
2927
+ * @param {string} targetFileName
2928
+ * @param {function} callback
2929
+ */
2930
+ writeZip: function(targetFileName, callback) {
2931
+ if (arguments.length === 1) {
2932
+ if (typeof targetFileName === "function") {
2933
+ callback = targetFileName;
2934
+ targetFileName = "";
2935
+ }
2936
+ }
2937
+ if (!targetFileName && opts.filename) {
2938
+ targetFileName = opts.filename;
2939
+ }
2940
+ if (!targetFileName) return;
2941
+ var zipData = _zip.compressToBuffer();
2942
+ if (zipData) {
2943
+ var ok = filetools.writeFileTo(targetFileName, zipData, true);
2944
+ if (typeof callback === "function") callback(!ok ? new Error("failed") : null, "");
2945
+ }
2946
+ },
2947
+ /**
2948
+ *
2949
+ * @param {string} targetFileName
2950
+ * @param {object} [props]
2951
+ * @param {boolean} [props.overwrite=true] If the file already exists at the target path, the file will be overwriten if this is true.
2952
+ * @param {boolean} [props.perm] The file will be set as the permission from the entry if this is true.
2953
+
2954
+ * @returns {Promise<void>}
2955
+ */
2956
+ writeZipPromise: function(targetFileName, props) {
2957
+ const { overwrite, perm } = Object.assign({ overwrite: true }, props);
2958
+ return new Promise((resolve, reject) => {
2959
+ if (!targetFileName && opts.filename) targetFileName = opts.filename;
2960
+ if (!targetFileName) reject("ADM-ZIP: ZIP File Name Missing");
2961
+ this.toBufferPromise().then((zipData) => {
2962
+ const ret = (done) => done ? resolve(done) : reject("ADM-ZIP: Wasn't able to write zip file");
2963
+ filetools.writeFileToAsync(targetFileName, zipData, overwrite, perm, ret);
2964
+ }, reject);
2965
+ });
2966
+ },
2967
+ /**
2968
+ * @returns {Promise<Buffer>} A promise to the Buffer.
2969
+ */
2970
+ toBufferPromise: function() {
2971
+ return new Promise((resolve, reject) => {
2972
+ _zip.toAsyncBuffer(resolve, reject);
2973
+ });
2974
+ },
2975
+ /**
2976
+ * Returns the content of the entire zip file as a Buffer object
2977
+ *
2978
+ * @prop {function} [onSuccess]
2979
+ * @prop {function} [onFail]
2980
+ * @prop {function} [onItemStart]
2981
+ * @prop {function} [onItemEnd]
2982
+ * @returns {Buffer}
2983
+ */
2984
+ toBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
2985
+ if (typeof onSuccess === "function") {
2986
+ _zip.toAsyncBuffer(onSuccess, onFail, onItemStart, onItemEnd);
2987
+ return null;
2988
+ }
2989
+ return _zip.compressToBuffer();
2990
+ }
2991
+ };
2992
+ };
2993
+ }
2994
+ });
2995
+
2996
+ // node_modules/@clack/core/dist/index.mjs
2997
+ var import_sisteransi = __toESM(require_src(), 1);
2998
+ var import_picocolors = __toESM(require_picocolors(), 1);
2999
+ import { stdin as $, stdout as k } from "node:process";
3000
+ import * as f from "node:readline";
3001
+ import _ from "node:readline";
3002
+ import { WriteStream as U } from "node:tty";
3003
+ function q({ onlyFirst: e2 = false } = {}) {
3004
+ const F = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
3005
+ return new RegExp(F, e2 ? void 0 : "g");
3006
+ }
3007
+ var J = q();
3008
+ function S(e2) {
3009
+ if (typeof e2 != "string") throw new TypeError(`Expected a \`string\`, got \`${typeof e2}\``);
3010
+ return e2.replace(J, "");
3011
+ }
3012
+ function T(e2) {
3013
+ return e2 && e2.__esModule && Object.prototype.hasOwnProperty.call(e2, "default") ? e2.default : e2;
3014
+ }
3015
+ var j = { exports: {} };
3016
+ (function(e2) {
3017
+ var u2 = {};
3018
+ e2.exports = u2, u2.eastAsianWidth = function(t) {
3019
+ var s = t.charCodeAt(0), C2 = t.length == 2 ? t.charCodeAt(1) : 0, D = s;
3020
+ return 55296 <= s && s <= 56319 && 56320 <= C2 && C2 <= 57343 && (s &= 1023, C2 &= 1023, D = s << 10 | C2, D += 65536), D == 12288 || 65281 <= D && D <= 65376 || 65504 <= D && D <= 65510 ? "F" : D == 8361 || 65377 <= D && D <= 65470 || 65474 <= D && D <= 65479 || 65482 <= D && D <= 65487 || 65490 <= D && D <= 65495 || 65498 <= D && D <= 65500 || 65512 <= D && D <= 65518 ? "H" : 4352 <= D && D <= 4447 || 4515 <= D && D <= 4519 || 4602 <= D && D <= 4607 || 9001 <= D && D <= 9002 || 11904 <= D && D <= 11929 || 11931 <= D && D <= 12019 || 12032 <= D && D <= 12245 || 12272 <= D && D <= 12283 || 12289 <= D && D <= 12350 || 12353 <= D && D <= 12438 || 12441 <= D && D <= 12543 || 12549 <= D && D <= 12589 || 12593 <= D && D <= 12686 || 12688 <= D && D <= 12730 || 12736 <= D && D <= 12771 || 12784 <= D && D <= 12830 || 12832 <= D && D <= 12871 || 12880 <= D && D <= 13054 || 13056 <= D && D <= 19903 || 19968 <= D && D <= 42124 || 42128 <= D && D <= 42182 || 43360 <= D && D <= 43388 || 44032 <= D && D <= 55203 || 55216 <= D && D <= 55238 || 55243 <= D && D <= 55291 || 63744 <= D && D <= 64255 || 65040 <= D && D <= 65049 || 65072 <= D && D <= 65106 || 65108 <= D && D <= 65126 || 65128 <= D && D <= 65131 || 110592 <= D && D <= 110593 || 127488 <= D && D <= 127490 || 127504 <= D && D <= 127546 || 127552 <= D && D <= 127560 || 127568 <= D && D <= 127569 || 131072 <= D && D <= 194367 || 177984 <= D && D <= 196605 || 196608 <= D && D <= 262141 ? "W" : 32 <= D && D <= 126 || 162 <= D && D <= 163 || 165 <= D && D <= 166 || D == 172 || D == 175 || 10214 <= D && D <= 10221 || 10629 <= D && D <= 10630 ? "Na" : D == 161 || D == 164 || 167 <= D && D <= 168 || D == 170 || 173 <= D && D <= 174 || 176 <= D && D <= 180 || 182 <= D && D <= 186 || 188 <= D && D <= 191 || D == 198 || D == 208 || 215 <= D && D <= 216 || 222 <= D && D <= 225 || D == 230 || 232 <= D && D <= 234 || 236 <= D && D <= 237 || D == 240 || 242 <= D && D <= 243 || 247 <= D && D <= 250 || D == 252 || D == 254 || D == 257 || D == 273 || D == 275 || D == 283 || 294 <= D && D <= 295 || D == 299 || 305 <= D && D <= 307 || D == 312 || 319 <= D && D <= 322 || D == 324 || 328 <= D && D <= 331 || D == 333 || 338 <= D && D <= 339 || 358 <= D && D <= 359 || D == 363 || D == 462 || D == 464 || D == 466 || D == 468 || D == 470 || D == 472 || D == 474 || D == 476 || D == 593 || D == 609 || D == 708 || D == 711 || 713 <= D && D <= 715 || D == 717 || D == 720 || 728 <= D && D <= 731 || D == 733 || D == 735 || 768 <= D && D <= 879 || 913 <= D && D <= 929 || 931 <= D && D <= 937 || 945 <= D && D <= 961 || 963 <= D && D <= 969 || D == 1025 || 1040 <= D && D <= 1103 || D == 1105 || D == 8208 || 8211 <= D && D <= 8214 || 8216 <= D && D <= 8217 || 8220 <= D && D <= 8221 || 8224 <= D && D <= 8226 || 8228 <= D && D <= 8231 || D == 8240 || 8242 <= D && D <= 8243 || D == 8245 || D == 8251 || D == 8254 || D == 8308 || D == 8319 || 8321 <= D && D <= 8324 || D == 8364 || D == 8451 || D == 8453 || D == 8457 || D == 8467 || D == 8470 || 8481 <= D && D <= 8482 || D == 8486 || D == 8491 || 8531 <= D && D <= 8532 || 8539 <= D && D <= 8542 || 8544 <= D && D <= 8555 || 8560 <= D && D <= 8569 || D == 8585 || 8592 <= D && D <= 8601 || 8632 <= D && D <= 8633 || D == 8658 || D == 8660 || D == 8679 || D == 8704 || 8706 <= D && D <= 8707 || 8711 <= D && D <= 8712 || D == 8715 || D == 8719 || D == 8721 || D == 8725 || D == 8730 || 8733 <= D && D <= 8736 || D == 8739 || D == 8741 || 8743 <= D && D <= 8748 || D == 8750 || 8756 <= D && D <= 8759 || 8764 <= D && D <= 8765 || D == 8776 || D == 8780 || D == 8786 || 8800 <= D && D <= 8801 || 8804 <= D && D <= 8807 || 8810 <= D && D <= 8811 || 8814 <= D && D <= 8815 || 8834 <= D && D <= 8835 || 8838 <= D && D <= 8839 || D == 8853 || D == 8857 || D == 8869 || D == 8895 || D == 8978 || 9312 <= D && D <= 9449 || 9451 <= D && D <= 9547 || 9552 <= D && D <= 9587 || 9600 <= D && D <= 9615 || 9618 <= D && D <= 9621 || 9632 <= D && D <= 9633 || 9635 <= D && D <= 9641 || 9650 <= D && D <= 9651 || 9654 <= D && D <= 9655 || 9660 <= D && D <= 9661 || 9664 <= D && D <= 9665 || 9670 <= D && D <= 9672 || D == 9675 || 9678 <= D && D <= 9681 || 9698 <= D && D <= 9701 || D == 9711 || 9733 <= D && D <= 9734 || D == 9737 || 9742 <= D && D <= 9743 || 9748 <= D && D <= 9749 || D == 9756 || D == 9758 || D == 9792 || D == 9794 || 9824 <= D && D <= 9825 || 9827 <= D && D <= 9829 || 9831 <= D && D <= 9834 || 9836 <= D && D <= 9837 || D == 9839 || 9886 <= D && D <= 9887 || 9918 <= D && D <= 9919 || 9924 <= D && D <= 9933 || 9935 <= D && D <= 9953 || D == 9955 || 9960 <= D && D <= 9983 || D == 10045 || D == 10071 || 10102 <= D && D <= 10111 || 11093 <= D && D <= 11097 || 12872 <= D && D <= 12879 || 57344 <= D && D <= 63743 || 65024 <= D && D <= 65039 || D == 65533 || 127232 <= D && D <= 127242 || 127248 <= D && D <= 127277 || 127280 <= D && D <= 127337 || 127344 <= D && D <= 127386 || 917760 <= D && D <= 917999 || 983040 <= D && D <= 1048573 || 1048576 <= D && D <= 1114109 ? "A" : "N";
3021
+ }, u2.characterLength = function(t) {
3022
+ var s = this.eastAsianWidth(t);
3023
+ return s == "F" || s == "W" || s == "A" ? 2 : 1;
3024
+ };
3025
+ function F(t) {
3026
+ return t.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
3027
+ }
3028
+ u2.length = function(t) {
3029
+ for (var s = F(t), C2 = 0, D = 0; D < s.length; D++) C2 = C2 + this.characterLength(s[D]);
3030
+ return C2;
3031
+ }, u2.slice = function(t, s, C2) {
3032
+ textLen = u2.length(t), s = s || 0, C2 = C2 || 1, s < 0 && (s = textLen + s), C2 < 0 && (C2 = textLen + C2);
3033
+ for (var D = "", i = 0, n = F(t), E = 0; E < n.length; E++) {
3034
+ var h2 = n[E], o = u2.length(h2);
3035
+ if (i >= s - (o == 2 ? 1 : 0)) if (i + o <= C2) D += h2;
3036
+ else break;
3037
+ i += o;
3038
+ }
3039
+ return D;
3040
+ };
3041
+ })(j);
3042
+ var Q = j.exports;
3043
+ var X = T(Q);
3044
+ var DD = function() {
3045
+ return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
3046
+ };
3047
+ var uD = T(DD);
3048
+ function A(e2, u2 = {}) {
3049
+ if (typeof e2 != "string" || e2.length === 0 || (u2 = { ambiguousIsNarrow: true, ...u2 }, e2 = S(e2), e2.length === 0)) return 0;
3050
+ e2 = e2.replace(uD(), " ");
3051
+ const F = u2.ambiguousIsNarrow ? 1 : 2;
3052
+ let t = 0;
3053
+ for (const s of e2) {
3054
+ const C2 = s.codePointAt(0);
3055
+ if (C2 <= 31 || C2 >= 127 && C2 <= 159 || C2 >= 768 && C2 <= 879) continue;
3056
+ switch (X.eastAsianWidth(s)) {
3057
+ case "F":
3058
+ case "W":
3059
+ t += 2;
3060
+ break;
3061
+ case "A":
3062
+ t += F;
3063
+ break;
3064
+ default:
3065
+ t += 1;
3066
+ }
3067
+ }
3068
+ return t;
3069
+ }
3070
+ var d = 10;
3071
+ var M = (e2 = 0) => (u2) => `\x1B[${u2 + e2}m`;
3072
+ var P = (e2 = 0) => (u2) => `\x1B[${38 + e2};5;${u2}m`;
3073
+ var W = (e2 = 0) => (u2, F, t) => `\x1B[${38 + e2};2;${u2};${F};${t}m`;
3074
+ var r = { modifier: { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], overline: [53, 55], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29] }, color: { black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], blackBright: [90, 39], gray: [90, 39], grey: [90, 39], redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39] }, bgColor: { bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], bgBlackBright: [100, 49], bgGray: [100, 49], bgGrey: [100, 49], bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49] } };
3075
+ Object.keys(r.modifier);
3076
+ var FD = Object.keys(r.color);
3077
+ var eD = Object.keys(r.bgColor);
3078
+ [...FD, ...eD];
3079
+ function tD() {
3080
+ const e2 = /* @__PURE__ */ new Map();
3081
+ for (const [u2, F] of Object.entries(r)) {
3082
+ for (const [t, s] of Object.entries(F)) r[t] = { open: `\x1B[${s[0]}m`, close: `\x1B[${s[1]}m` }, F[t] = r[t], e2.set(s[0], s[1]);
3083
+ Object.defineProperty(r, u2, { value: F, enumerable: false });
3084
+ }
3085
+ return Object.defineProperty(r, "codes", { value: e2, enumerable: false }), r.color.close = "\x1B[39m", r.bgColor.close = "\x1B[49m", r.color.ansi = M(), r.color.ansi256 = P(), r.color.ansi16m = W(), r.bgColor.ansi = M(d), r.bgColor.ansi256 = P(d), r.bgColor.ansi16m = W(d), Object.defineProperties(r, { rgbToAnsi256: { value: (u2, F, t) => u2 === F && F === t ? u2 < 8 ? 16 : u2 > 248 ? 231 : Math.round((u2 - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(u2 / 255 * 5) + 6 * Math.round(F / 255 * 5) + Math.round(t / 255 * 5), enumerable: false }, hexToRgb: { value: (u2) => {
3086
+ const F = /[a-f\d]{6}|[a-f\d]{3}/i.exec(u2.toString(16));
3087
+ if (!F) return [0, 0, 0];
3088
+ let [t] = F;
3089
+ t.length === 3 && (t = [...t].map((C2) => C2 + C2).join(""));
3090
+ const s = Number.parseInt(t, 16);
3091
+ return [s >> 16 & 255, s >> 8 & 255, s & 255];
3092
+ }, enumerable: false }, hexToAnsi256: { value: (u2) => r.rgbToAnsi256(...r.hexToRgb(u2)), enumerable: false }, ansi256ToAnsi: { value: (u2) => {
3093
+ if (u2 < 8) return 30 + u2;
3094
+ if (u2 < 16) return 90 + (u2 - 8);
3095
+ let F, t, s;
3096
+ if (u2 >= 232) F = ((u2 - 232) * 10 + 8) / 255, t = F, s = F;
3097
+ else {
3098
+ u2 -= 16;
3099
+ const i = u2 % 36;
3100
+ F = Math.floor(u2 / 36) / 5, t = Math.floor(i / 6) / 5, s = i % 6 / 5;
3101
+ }
3102
+ const C2 = Math.max(F, t, s) * 2;
3103
+ if (C2 === 0) return 30;
3104
+ let D = 30 + (Math.round(s) << 2 | Math.round(t) << 1 | Math.round(F));
3105
+ return C2 === 2 && (D += 60), D;
3106
+ }, enumerable: false }, rgbToAnsi: { value: (u2, F, t) => r.ansi256ToAnsi(r.rgbToAnsi256(u2, F, t)), enumerable: false }, hexToAnsi: { value: (u2) => r.ansi256ToAnsi(r.hexToAnsi256(u2)), enumerable: false } }), r;
3107
+ }
3108
+ var sD = tD();
3109
+ var g = /* @__PURE__ */ new Set(["\x1B", "\x9B"]);
3110
+ var CD = 39;
3111
+ var b = "\x07";
3112
+ var O = "[";
3113
+ var iD = "]";
3114
+ var I = "m";
3115
+ var w = `${iD}8;;`;
3116
+ var N = (e2) => `${g.values().next().value}${O}${e2}${I}`;
3117
+ var L = (e2) => `${g.values().next().value}${w}${e2}${b}`;
3118
+ var rD = (e2) => e2.split(" ").map((u2) => A(u2));
3119
+ var y = (e2, u2, F) => {
3120
+ const t = [...u2];
3121
+ let s = false, C2 = false, D = A(S(e2[e2.length - 1]));
3122
+ for (const [i, n] of t.entries()) {
3123
+ const E = A(n);
3124
+ if (D + E <= F ? e2[e2.length - 1] += n : (e2.push(n), D = 0), g.has(n) && (s = true, C2 = t.slice(i + 1).join("").startsWith(w)), s) {
3125
+ C2 ? n === b && (s = false, C2 = false) : n === I && (s = false);
3126
+ continue;
3127
+ }
3128
+ D += E, D === F && i < t.length - 1 && (e2.push(""), D = 0);
3129
+ }
3130
+ !D && e2[e2.length - 1].length > 0 && e2.length > 1 && (e2[e2.length - 2] += e2.pop());
3131
+ };
3132
+ var ED = (e2) => {
3133
+ const u2 = e2.split(" ");
3134
+ let F = u2.length;
3135
+ for (; F > 0 && !(A(u2[F - 1]) > 0); ) F--;
3136
+ return F === u2.length ? e2 : u2.slice(0, F).join(" ") + u2.slice(F).join("");
3137
+ };
3138
+ var oD = (e2, u2, F = {}) => {
3139
+ if (F.trim !== false && e2.trim() === "") return "";
3140
+ let t = "", s, C2;
3141
+ const D = rD(e2);
3142
+ let i = [""];
3143
+ for (const [E, h2] of e2.split(" ").entries()) {
3144
+ F.trim !== false && (i[i.length - 1] = i[i.length - 1].trimStart());
3145
+ let o = A(i[i.length - 1]);
3146
+ if (E !== 0 && (o >= u2 && (F.wordWrap === false || F.trim === false) && (i.push(""), o = 0), (o > 0 || F.trim === false) && (i[i.length - 1] += " ", o++)), F.hard && D[E] > u2) {
3147
+ const B2 = u2 - o, p = 1 + Math.floor((D[E] - B2 - 1) / u2);
3148
+ Math.floor((D[E] - 1) / u2) < p && i.push(""), y(i, h2, u2);
3149
+ continue;
3150
+ }
3151
+ if (o + D[E] > u2 && o > 0 && D[E] > 0) {
3152
+ if (F.wordWrap === false && o < u2) {
3153
+ y(i, h2, u2);
3154
+ continue;
3155
+ }
3156
+ i.push("");
3157
+ }
3158
+ if (o + D[E] > u2 && F.wordWrap === false) {
3159
+ y(i, h2, u2);
3160
+ continue;
3161
+ }
3162
+ i[i.length - 1] += h2;
3163
+ }
3164
+ F.trim !== false && (i = i.map((E) => ED(E)));
3165
+ const n = [...i.join(`
3166
+ `)];
3167
+ for (const [E, h2] of n.entries()) {
3168
+ if (t += h2, g.has(h2)) {
3169
+ const { groups: B2 } = new RegExp(`(?:\\${O}(?<code>\\d+)m|\\${w}(?<uri>.*)${b})`).exec(n.slice(E).join("")) || { groups: {} };
3170
+ if (B2.code !== void 0) {
3171
+ const p = Number.parseFloat(B2.code);
3172
+ s = p === CD ? void 0 : p;
3173
+ } else B2.uri !== void 0 && (C2 = B2.uri.length === 0 ? void 0 : B2.uri);
3174
+ }
3175
+ const o = sD.codes.get(Number(s));
3176
+ n[E + 1] === `
3177
+ ` ? (C2 && (t += L("")), s && o && (t += N(o))) : h2 === `
3178
+ ` && (s && o && (t += N(s)), C2 && (t += L(C2)));
3179
+ }
3180
+ return t;
3181
+ };
3182
+ function R(e2, u2, F) {
3183
+ return String(e2).normalize().replace(/\r\n/g, `
3184
+ `).split(`
3185
+ `).map((t) => oD(t, u2, F)).join(`
3186
+ `);
3187
+ }
3188
+ var nD = Object.defineProperty;
3189
+ var aD = (e2, u2, F) => u2 in e2 ? nD(e2, u2, { enumerable: true, configurable: true, writable: true, value: F }) : e2[u2] = F;
3190
+ var a = (e2, u2, F) => (aD(e2, typeof u2 != "symbol" ? u2 + "" : u2, F), F);
3191
+ function hD(e2, u2) {
3192
+ if (e2 === u2) return;
3193
+ const F = e2.split(`
3194
+ `), t = u2.split(`
3195
+ `), s = [];
3196
+ for (let C2 = 0; C2 < Math.max(F.length, t.length); C2++) F[C2] !== t[C2] && s.push(C2);
3197
+ return s;
3198
+ }
3199
+ var V = /* @__PURE__ */ Symbol("clack:cancel");
3200
+ function lD(e2) {
3201
+ return e2 === V;
3202
+ }
3203
+ function v(e2, u2) {
3204
+ e2.isTTY && e2.setRawMode(u2);
3205
+ }
3206
+ var z = /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"]]);
3207
+ var xD = /* @__PURE__ */ new Set(["up", "down", "left", "right", "space", "enter"]);
3208
+ var x = class {
3209
+ constructor({ render: u2, input: F = $, output: t = k, ...s }, C2 = true) {
3210
+ a(this, "input"), a(this, "output"), a(this, "rl"), a(this, "opts"), a(this, "_track", false), a(this, "_render"), a(this, "_cursor", 0), a(this, "state", "initial"), a(this, "value"), a(this, "error", ""), a(this, "subscribers", /* @__PURE__ */ new Map()), a(this, "_prevFrame", ""), this.opts = s, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = u2.bind(this), this._track = C2, this.input = F, this.output = t;
3211
+ }
3212
+ prompt() {
3213
+ const u2 = new U(0);
3214
+ return u2._write = (F, t, s) => {
3215
+ this._track && (this.value = this.rl.line.replace(/\t/g, ""), this._cursor = this.rl.cursor, this.emit("value", this.value)), s();
3216
+ }, this.input.pipe(u2), this.rl = _.createInterface({ input: this.input, output: u2, tabSize: 2, prompt: "", escapeCodeTimeout: 50 }), _.emitKeypressEvents(this.input, this.rl), this.rl.prompt(), this.opts.initialValue !== void 0 && this._track && this.rl.write(this.opts.initialValue), this.input.on("keypress", this.onKeypress), v(this.input, true), this.output.on("resize", this.render), this.render(), new Promise((F, t) => {
3217
+ this.once("submit", () => {
3218
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), v(this.input, false), F(this.value);
3219
+ }), this.once("cancel", () => {
3220
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), v(this.input, false), F(V);
3221
+ });
3222
+ });
3223
+ }
3224
+ on(u2, F) {
3225
+ const t = this.subscribers.get(u2) ?? [];
3226
+ t.push({ cb: F }), this.subscribers.set(u2, t);
3227
+ }
3228
+ once(u2, F) {
3229
+ const t = this.subscribers.get(u2) ?? [];
3230
+ t.push({ cb: F, once: true }), this.subscribers.set(u2, t);
3231
+ }
3232
+ emit(u2, ...F) {
3233
+ const t = this.subscribers.get(u2) ?? [], s = [];
3234
+ for (const C2 of t) C2.cb(...F), C2.once && s.push(() => t.splice(t.indexOf(C2), 1));
3235
+ for (const C2 of s) C2();
3236
+ }
3237
+ unsubscribe() {
3238
+ this.subscribers.clear();
3239
+ }
3240
+ onKeypress(u2, F) {
3241
+ if (this.state === "error" && (this.state = "active"), F?.name && !this._track && z.has(F.name) && this.emit("cursor", z.get(F.name)), F?.name && xD.has(F.name) && this.emit("cursor", F.name), u2 && (u2.toLowerCase() === "y" || u2.toLowerCase() === "n") && this.emit("confirm", u2.toLowerCase() === "y"), u2 === " " && this.opts.placeholder && (this.value || (this.rl.write(this.opts.placeholder), this.emit("value", this.opts.placeholder))), u2 && this.emit("key", u2.toLowerCase()), F?.name === "return") {
3242
+ if (this.opts.validate) {
3243
+ const t = this.opts.validate(this.value);
3244
+ t && (this.error = t, this.state = "error", this.rl.write(this.value));
3245
+ }
3246
+ this.state !== "error" && (this.state = "submit");
3247
+ }
3248
+ u2 === "" && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
3249
+ }
3250
+ close() {
3251
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
3252
+ `), v(this.input, false), this.rl.close(), this.emit(`${this.state}`, this.value), this.unsubscribe();
3253
+ }
3254
+ restoreCursor() {
3255
+ const u2 = R(this._prevFrame, process.stdout.columns, { hard: true }).split(`
3256
+ `).length - 1;
3257
+ this.output.write(import_sisteransi.cursor.move(-999, u2 * -1));
3258
+ }
3259
+ render() {
3260
+ const u2 = R(this._render(this) ?? "", process.stdout.columns, { hard: true });
3261
+ if (u2 !== this._prevFrame) {
3262
+ if (this.state === "initial") this.output.write(import_sisteransi.cursor.hide);
3263
+ else {
3264
+ const F = hD(this._prevFrame, u2);
3265
+ if (this.restoreCursor(), F && F?.length === 1) {
3266
+ const t = F[0];
3267
+ this.output.write(import_sisteransi.cursor.move(0, t)), this.output.write(import_sisteransi.erase.lines(1));
3268
+ const s = u2.split(`
3269
+ `);
3270
+ this.output.write(s[t]), this._prevFrame = u2, this.output.write(import_sisteransi.cursor.move(0, s.length - t - 1));
3271
+ return;
3272
+ } else if (F && F?.length > 1) {
3273
+ const t = F[0];
3274
+ this.output.write(import_sisteransi.cursor.move(0, t)), this.output.write(import_sisteransi.erase.down());
3275
+ const s = u2.split(`
3276
+ `).slice(t);
3277
+ this.output.write(s.join(`
3278
+ `)), this._prevFrame = u2;
3279
+ return;
3280
+ }
3281
+ this.output.write(import_sisteransi.erase.down());
3282
+ }
3283
+ this.output.write(u2), this.state === "initial" && (this.state = "active"), this._prevFrame = u2;
3284
+ }
3285
+ }
3286
+ };
3287
+ var mD = Object.defineProperty;
3288
+ var dD = (e2, u2, F) => u2 in e2 ? mD(e2, u2, { enumerable: true, configurable: true, writable: true, value: F }) : e2[u2] = F;
3289
+ var Y = (e2, u2, F) => (dD(e2, typeof u2 != "symbol" ? u2 + "" : u2, F), F);
3290
+ var bD = class extends x {
3291
+ constructor({ mask: u2, ...F }) {
3292
+ super(F), Y(this, "valueWithCursor", ""), Y(this, "_mask", "\u2022"), this._mask = u2 ?? "\u2022", this.on("finalize", () => {
3293
+ this.valueWithCursor = this.masked;
3294
+ }), this.on("value", () => {
3295
+ if (this.cursor >= this.value.length) this.valueWithCursor = `${this.masked}${import_picocolors.default.inverse(import_picocolors.default.hidden("_"))}`;
3296
+ else {
3297
+ const t = this.masked.slice(0, this.cursor), s = this.masked.slice(this.cursor);
3298
+ this.valueWithCursor = `${t}${import_picocolors.default.inverse(s[0])}${s.slice(1)}`;
3299
+ }
3300
+ });
3301
+ }
3302
+ get cursor() {
3303
+ return this._cursor;
3304
+ }
3305
+ get masked() {
3306
+ return this.value.replaceAll(/./g, this._mask);
3307
+ }
3308
+ };
3309
+ var TD = Object.defineProperty;
3310
+ var jD = (e2, u2, F) => u2 in e2 ? TD(e2, u2, { enumerable: true, configurable: true, writable: true, value: F }) : e2[u2] = F;
3311
+ var MD = (e2, u2, F) => (jD(e2, typeof u2 != "symbol" ? u2 + "" : u2, F), F);
3312
+ var PD = class extends x {
3313
+ constructor(u2) {
3314
+ super(u2), MD(this, "valueWithCursor", ""), this.on("finalize", () => {
3315
+ this.value || (this.value = u2.defaultValue), this.valueWithCursor = this.value;
3316
+ }), this.on("value", () => {
3317
+ if (this.cursor >= this.value.length) this.valueWithCursor = `${this.value}${import_picocolors.default.inverse(import_picocolors.default.hidden("_"))}`;
3318
+ else {
3319
+ const F = this.value.slice(0, this.cursor), t = this.value.slice(this.cursor);
3320
+ this.valueWithCursor = `${F}${import_picocolors.default.inverse(t[0])}${t.slice(1)}`;
3321
+ }
3322
+ });
3323
+ }
3324
+ get cursor() {
3325
+ return this._cursor;
3326
+ }
3327
+ };
3328
+ var WD = globalThis.process.platform.startsWith("win");
3329
+ function OD({ input: e2 = $, output: u2 = k, overwrite: F = true, hideCursor: t = true } = {}) {
3330
+ const s = f.createInterface({ input: e2, output: u2, prompt: "", tabSize: 1 });
3331
+ f.emitKeypressEvents(e2, s), e2.isTTY && e2.setRawMode(true);
3332
+ const C2 = (D, { name: i }) => {
3333
+ if (String(D) === "") {
3334
+ t && u2.write(import_sisteransi.cursor.show), process.exit(0);
3335
+ return;
3336
+ }
3337
+ if (!F) return;
3338
+ let n = i === "return" ? 0 : -1, E = i === "return" ? -1 : 0;
3339
+ f.moveCursor(u2, n, E, () => {
3340
+ f.clearLine(u2, 1, () => {
3341
+ e2.once("keypress", C2);
3342
+ });
3343
+ });
3344
+ };
3345
+ return t && u2.write(import_sisteransi.cursor.hide), e2.once("keypress", C2), () => {
3346
+ e2.off("keypress", C2), t && u2.write(import_sisteransi.cursor.show), e2.isTTY && !WD && e2.setRawMode(false), s.terminal = false, s.close();
3347
+ };
3348
+ }
3349
+
3350
+ // node_modules/@clack/prompts/dist/index.mjs
3351
+ var import_picocolors2 = __toESM(require_picocolors(), 1);
3352
+ var import_sisteransi2 = __toESM(require_src(), 1);
3353
+ import h from "node:process";
3354
+ function K() {
3355
+ return h.platform !== "win32" ? h.env.TERM !== "linux" : !!h.env.CI || !!h.env.WT_SESSION || !!h.env.TERMINUS_SUBLIME || h.env.ConEmuTask === "{cmd::Cmder}" || h.env.TERM_PROGRAM === "Terminus-Sublime" || h.env.TERM_PROGRAM === "vscode" || h.env.TERM === "xterm-256color" || h.env.TERM === "alacritty" || h.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
3356
+ }
3357
+ var C = K();
3358
+ var u = (s, n) => C ? s : n;
3359
+ var Y2 = u("\u25C6", "*");
3360
+ var P2 = u("\u25A0", "x");
3361
+ var V2 = u("\u25B2", "x");
3362
+ var M2 = u("\u25C7", "o");
3363
+ var Q2 = u("\u250C", "T");
3364
+ var a2 = u("\u2502", "|");
3365
+ var $2 = u("\u2514", "\u2014");
3366
+ var I2 = u("\u25CF", ">");
3367
+ var T2 = u("\u25CB", " ");
3368
+ var j2 = u("\u25FB", "[\u2022]");
3369
+ var b2 = u("\u25FC", "[+]");
3370
+ var B = u("\u25FB", "[ ]");
3371
+ var X2 = u("\u25AA", "\u2022");
3372
+ var G = u("\u2500", "-");
3373
+ var H = u("\u256E", "+");
3374
+ var ee = u("\u251C", "+");
3375
+ var te = u("\u256F", "+");
3376
+ var se = u("\u25CF", "\u2022");
3377
+ var re = u("\u25C6", "*");
3378
+ var ie = u("\u25B2", "!");
3379
+ var ne = u("\u25A0", "x");
3380
+ var y2 = (s) => {
3381
+ switch (s) {
3382
+ case "initial":
3383
+ case "active":
3384
+ return import_picocolors2.default.cyan(Y2);
3385
+ case "cancel":
3386
+ return import_picocolors2.default.red(P2);
3387
+ case "error":
3388
+ return import_picocolors2.default.yellow(V2);
3389
+ case "submit":
3390
+ return import_picocolors2.default.green(M2);
3391
+ }
3392
+ };
3393
+ var ae = (s) => new PD({ validate: s.validate, placeholder: s.placeholder, defaultValue: s.defaultValue, initialValue: s.initialValue, render() {
3394
+ const n = `${import_picocolors2.default.gray(a2)}
3395
+ ${y2(this.state)} ${s.message}
3396
+ `, t = s.placeholder ? import_picocolors2.default.inverse(s.placeholder[0]) + import_picocolors2.default.dim(s.placeholder.slice(1)) : import_picocolors2.default.inverse(import_picocolors2.default.hidden("_")), i = this.value ? this.valueWithCursor : t;
3397
+ switch (this.state) {
3398
+ case "error":
3399
+ return `${n.trim()}
3400
+ ${import_picocolors2.default.yellow(a2)} ${i}
3401
+ ${import_picocolors2.default.yellow($2)} ${import_picocolors2.default.yellow(this.error)}
3402
+ `;
3403
+ case "submit":
3404
+ return `${n}${import_picocolors2.default.gray(a2)} ${import_picocolors2.default.dim(this.value || s.placeholder)}`;
3405
+ case "cancel":
3406
+ return `${n}${import_picocolors2.default.gray(a2)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(this.value ?? ""))}${this.value?.trim() ? `
3407
+ ` + import_picocolors2.default.gray(a2) : ""}`;
3408
+ default:
3409
+ return `${n}${import_picocolors2.default.cyan(a2)} ${i}
3410
+ ${import_picocolors2.default.cyan($2)}
3411
+ `;
3412
+ }
3413
+ } }).prompt();
3414
+ var oe = (s) => new bD({ validate: s.validate, mask: s.mask ?? X2, render() {
3415
+ const n = `${import_picocolors2.default.gray(a2)}
3416
+ ${y2(this.state)} ${s.message}
3417
+ `, t = this.valueWithCursor, i = this.masked;
3418
+ switch (this.state) {
3419
+ case "error":
3420
+ return `${n.trim()}
3421
+ ${import_picocolors2.default.yellow(a2)} ${i}
3422
+ ${import_picocolors2.default.yellow($2)} ${import_picocolors2.default.yellow(this.error)}
3423
+ `;
3424
+ case "submit":
3425
+ return `${n}${import_picocolors2.default.gray(a2)} ${import_picocolors2.default.dim(i)}`;
3426
+ case "cancel":
3427
+ return `${n}${import_picocolors2.default.gray(a2)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(i ?? ""))}${i ? `
3428
+ ` + import_picocolors2.default.gray(a2) : ""}`;
3429
+ default:
3430
+ return `${n}${import_picocolors2.default.cyan(a2)} ${t}
3431
+ ${import_picocolors2.default.cyan($2)}
3432
+ `;
3433
+ }
3434
+ } }).prompt();
3435
+ var he = (s = "") => {
3436
+ process.stdout.write(`${import_picocolors2.default.gray($2)} ${import_picocolors2.default.red(s)}
3437
+
3438
+ `);
3439
+ };
3440
+ var pe = (s = "") => {
3441
+ process.stdout.write(`${import_picocolors2.default.gray(Q2)} ${s}
3442
+ `);
3443
+ };
3444
+ var ge = (s = "") => {
3445
+ process.stdout.write(`${import_picocolors2.default.gray(a2)}
3446
+ ${import_picocolors2.default.gray($2)} ${s}
3447
+
3448
+ `);
3449
+ };
3450
+ var _2 = () => {
3451
+ const s = C ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], n = C ? 80 : 120;
3452
+ let t, i, r2 = false, o = "";
3453
+ const c2 = (g2) => {
3454
+ const m2 = g2 > 1 ? "Something went wrong" : "Canceled";
3455
+ r2 && x2(m2, g2);
3456
+ }, l2 = () => c2(2), d2 = () => c2(1), p = () => {
3457
+ process.on("uncaughtExceptionMonitor", l2), process.on("unhandledRejection", l2), process.on("SIGINT", d2), process.on("SIGTERM", d2), process.on("exit", c2);
3458
+ }, S2 = () => {
3459
+ process.removeListener("uncaughtExceptionMonitor", l2), process.removeListener("unhandledRejection", l2), process.removeListener("SIGINT", d2), process.removeListener("SIGTERM", d2), process.removeListener("exit", c2);
3460
+ }, f2 = (g2 = "") => {
3461
+ r2 = true, t = OD(), o = g2.replace(/\.+$/, ""), process.stdout.write(`${import_picocolors2.default.gray(a2)}
3462
+ `);
3463
+ let m2 = 0, w2 = 0;
3464
+ p(), i = setInterval(() => {
3465
+ const L2 = import_picocolors2.default.magenta(s[m2]), O2 = ".".repeat(Math.floor(w2)).slice(0, 3);
3466
+ process.stdout.write(import_sisteransi2.cursor.move(-999, 0)), process.stdout.write(import_sisteransi2.erase.down(1)), process.stdout.write(`${L2} ${o}${O2}`), m2 = m2 + 1 < s.length ? m2 + 1 : 0, w2 = w2 < s.length ? w2 + 0.125 : 0;
3467
+ }, n);
3468
+ }, x2 = (g2 = "", m2 = 0) => {
3469
+ o = g2 ?? o, r2 = false, clearInterval(i);
3470
+ const w2 = m2 === 0 ? import_picocolors2.default.green(M2) : m2 === 1 ? import_picocolors2.default.red(P2) : import_picocolors2.default.red(V2);
3471
+ process.stdout.write(import_sisteransi2.cursor.move(-999, 0)), process.stdout.write(import_sisteransi2.erase.down(1)), process.stdout.write(`${w2} ${o}
3472
+ `), S2(), t();
3473
+ };
3474
+ return { start: f2, stop: x2, message: (g2 = "") => {
3475
+ o = g2 ?? o;
3476
+ } };
3477
+ };
3478
+
3479
+ // packages/create-grocms/bin/index.js
3480
+ var import_picocolors3 = __toESM(require_picocolors(), 1);
3481
+ import { existsSync, realpathSync } from "node:fs";
3482
+ import path5 from "node:path";
3483
+ import { execSync } from "node:child_process";
3484
+
3485
+ // packages/create-grocms/src/extract.js
3486
+ import { mkdir, writeFile } from "node:fs/promises";
3487
+ import path2 from "node:path";
3488
+
3489
+ // packages/create-grocms/src/destination.js
3490
+ import { lstat, readdir } from "node:fs/promises";
3491
+ import path from "node:path";
3492
+ async function validateDestination(value) {
3493
+ if (typeof value !== "string" || !value.trim()) throw new Error("Please provide a folder name.");
3494
+ const destination = path.resolve(value.trim());
3495
+ if (destination === path.parse(destination).root) throw new Error("Choose a project directory, not a filesystem root.");
3496
+ let current = destination;
3497
+ while (true) {
3498
+ try {
3499
+ const info = await lstat(current);
3500
+ if (info.isSymbolicLink() || !info.isDirectory()) throw new Error("The target and its parents must be regular directories, not links or files.");
3501
+ } catch (error) {
3502
+ if (error.code !== "ENOENT") throw error;
3503
+ }
3504
+ const parent = path.dirname(current);
3505
+ if (parent === current) break;
3506
+ current = parent;
3507
+ }
3508
+ try {
3509
+ if ((await readdir(destination)).length) throw new Error("Target directory already exists and is not empty.");
3510
+ } catch (error) {
3511
+ if (error.code !== "ENOENT") throw error;
3512
+ }
3513
+ return destination;
3514
+ }
3515
+
3516
+ // packages/archive/index.js
3517
+ var import_adm_zip = __toESM(require_adm_zip(), 1);
3518
+ import { open } from "node:fs/promises";
3519
+ var ARCHIVE_LIMITS = Object.freeze({ compressed: 64 * 1024 * 1024, expanded: 256 * 1024 * 1024, member: 32 * 1024 * 1024, entries: 1e4 });
3520
+ async function readArchive(filename) {
3521
+ const file = await open(filename, "r");
3522
+ try {
3523
+ const info = await file.stat();
3524
+ if (!info.isFile() || info.size > ARCHIVE_LIMITS.compressed) throw new Error("Release archive exceeds the 64 MiB compressed limit or is not a file.");
3525
+ const chunks = [];
3526
+ let bytes = 0;
3527
+ for await (const chunk of file.createReadStream({ autoClose: false })) {
3528
+ bytes += chunk.length;
3529
+ if (bytes > ARCHIVE_LIMITS.compressed) throw new Error("Release archive exceeds the 64 MiB compressed limit.");
3530
+ chunks.push(chunk);
3531
+ }
3532
+ return Buffer.concat(chunks, bytes);
3533
+ } finally {
3534
+ await file.close();
3535
+ }
3536
+ }
3537
+ function memberPath(entry) {
3538
+ const raw = entry.entryName;
3539
+ if (/^[\\/]|^[a-z]:/i.test(raw) || /[\\\x00-\x1f\x7f:]/.test(raw)) throw new Error("Unsafe archive path.");
3540
+ const name = raw.replace(/^\.\//, "").replace(/\/$/, "");
3541
+ if (entry.isDirectory && (!name || name === ".")) return "";
3542
+ const parts = name.split("/");
3543
+ if (parts.some((part) => !part || part === "." || part === ".." || /[. ]$/.test(part) || /[<>"|?*]/.test(part) || /^(con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³])(?:\.|$)/i.test(part))) throw new Error("Unsafe archive path.");
3544
+ return name;
3545
+ }
3546
+ function inspectArchive(bytes) {
3547
+ if (!Buffer.isBuffer(bytes) || bytes.length > ARCHIVE_LIMITS.compressed) throw new Error("Release archive exceeds the 64 MiB compressed limit.");
3548
+ let footer = -1;
3549
+ for (let offset = bytes.length - 22; offset >= Math.max(0, bytes.length - 65557); offset--) {
3550
+ if (bytes.readUInt32LE(offset) === 101010256 && offset + 22 + bytes.readUInt16LE(offset + 20) === bytes.length) {
3551
+ footer = offset;
3552
+ break;
3553
+ }
3554
+ }
3555
+ if (footer < 0 || bytes.readUInt16LE(footer + 4) !== 0 || bytes.readUInt16LE(footer + 6) !== 0 || bytes.readUInt16LE(footer + 8) !== bytes.readUInt16LE(footer + 10)) throw new Error("Invalid or multipart release archive.");
3556
+ const count = bytes.readUInt16LE(footer + 10);
3557
+ if (!count || count > ARCHIVE_LIMITS.entries) throw new Error("Release archive has an invalid entry count (maximum 10,000).");
3558
+ const entries = new import_adm_zip.default(bytes).getEntries();
3559
+ if (!entries.length || entries.length > ARCHIVE_LIMITS.entries) throw new Error("Release archive has an invalid entry count (maximum 10,000).");
3560
+ const names = /* @__PURE__ */ new Map();
3561
+ const spellings = /* @__PURE__ */ new Map();
3562
+ let expanded = 0;
3563
+ const inventory = [];
3564
+ for (const entry of entries) {
3565
+ const name = memberPath(entry);
3566
+ const mode = entry.header.attr >>> 16 & 65535;
3567
+ const kind = mode & 61440;
3568
+ if (kind && kind !== (entry.isDirectory ? 16384 : 32768) || entry.header.flags & 1) throw new Error("Links, special files and encrypted entries are not supported.");
3569
+ const size = entry.header.size;
3570
+ if (!Number.isSafeInteger(size) || size < 0 || size > ARCHIVE_LIMITS.member || entry.isDirectory && size !== 0) throw new Error("Release archive member exceeds the 32 MiB limit or has invalid size.");
3571
+ expanded += size;
3572
+ if (expanded > ARCHIVE_LIMITS.expanded) throw new Error("Release archive exceeds the 256 MiB expanded limit.");
3573
+ if (!name) continue;
3574
+ const key = name.normalize("NFC").toLowerCase();
3575
+ if (names.has(key)) throw new Error("Duplicate or case-colliding archive destination.");
3576
+ names.set(key, entry.isDirectory);
3577
+ const parts = name.split("/");
3578
+ for (let index = 1; index <= parts.length; index++) {
3579
+ const prefix = parts.slice(0, index).join("/");
3580
+ const canonical = prefix.normalize("NFC").toLowerCase();
3581
+ if (spellings.has(canonical) && spellings.get(canonical) !== prefix) throw new Error("Duplicate or case-colliding archive destination.");
3582
+ spellings.set(canonical, prefix);
3583
+ }
3584
+ inventory.push({ entry, name, size, mode });
3585
+ }
3586
+ for (const { name } of inventory) {
3587
+ const parts = name.normalize("NFC").toLowerCase().split("/");
3588
+ for (let index = 1; index < parts.length; index++) {
3589
+ if (names.get(parts.slice(0, index).join("/")) === false) throw new Error("Archive file/directory conflict.");
3590
+ }
3591
+ }
3592
+ return inventory;
3593
+ }
3594
+
3595
+ // packages/create-grocms/src/extract.js
3596
+ async function extractArchive(archivePathOrBuffer, destDir) {
3597
+ const bytes = typeof archivePathOrBuffer === "string" ? await readArchive(archivePathOrBuffer) : archivePathOrBuffer;
3598
+ const inventory = inspectArchive(bytes);
3599
+ const destination = await validateDestination(destDir);
3600
+ await mkdir(destination, { recursive: true, mode: 448 });
3601
+ let total = 0;
3602
+ for (const { entry, name, size, mode } of inventory) {
3603
+ const target = path2.join(destination, ...name.split("/"));
3604
+ if (entry.isDirectory) {
3605
+ await mkdir(target, { recursive: true, mode: 493 });
3606
+ continue;
3607
+ }
3608
+ const data = entry.getData();
3609
+ total += data.length;
3610
+ if (data.length !== size || data.length > ARCHIVE_LIMITS.member || total > ARCHIVE_LIMITS.expanded) throw new Error("Archive decompressed size does not match its bounded inventory.");
3611
+ await mkdir(path2.dirname(target), { recursive: true, mode: 493 });
3612
+ await writeFile(target, data, { flag: "wx", mode: mode & 73 ? 493 : 420 });
3613
+ }
3614
+ return { extractedFiles: inventory.filter((item) => !item.entry.isDirectory).length };
3615
+ }
3616
+
3617
+ // packages/create-grocms/src/scaffold.js
3618
+ import { lstat as lstat3, mkdir as mkdir2, mkdtemp, rename, rmdir, rm } from "node:fs/promises";
3619
+ import path4 from "node:path";
3620
+
3621
+ // packages/create-grocms/src/env.js
3622
+ import { randomBytes } from "node:crypto";
3623
+ import { lstat as lstat2, writeFile as writeFile2 } from "node:fs/promises";
3624
+ import path3 from "node:path";
3625
+ function generateSecrets() {
3626
+ return {
3627
+ authSecret: randomBytes(32).toString("hex"),
3628
+ dbPassword: randomBytes(16).toString("hex"),
3629
+ dbAdminPassword: randomBytes(16).toString("hex"),
3630
+ dbMigratorPassword: randomBytes(16).toString("hex")
3631
+ };
3632
+ }
3633
+ async function writeEnvironmentFiles(destDir, options) {
3634
+ const { port = 3100 } = options;
3635
+ const origin = new URL(options.publicUrl);
3636
+ if (!["http:", "https:"].includes(origin.protocol) || origin.username || origin.password || origin.search || origin.hash || origin.pathname !== "/") {
3637
+ throw new Error("Use an HTTP(S) site origin without a path, credentials, query or fragment.");
3638
+ }
3639
+ if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error("Use a valid HTTP port.");
3640
+ const publicUrl = origin.origin;
3641
+ const filenames = [".env.local", ".env.infrastructure.local", ".env.production.local"];
3642
+ for (const filename of filenames) {
3643
+ try {
3644
+ await lstat2(path3.join(destDir, filename));
3645
+ throw new Error("Environment files already exist. Existing credentials are never overwritten.");
3646
+ } catch (error) {
3647
+ if (error.code !== "ENOENT") throw error;
3648
+ }
3649
+ }
3650
+ const secrets = generateSecrets();
3651
+ const localEnv = `# GroCMS Local Development Configuration
3652
+ # Auto-generated by create-grocms
3653
+ PUBLIC_URL=${publicUrl}
3654
+ BETTER_AUTH_URL=${publicUrl}
3655
+ BETTER_AUTH_SECRET=${secrets.authSecret}
3656
+ DATABASE_URL=postgresql://gcms:${secrets.dbPassword}@127.0.0.1:55432/gcms
3657
+ MEDIA_ROOT=./.data/media
3658
+ SMTP_HOST=127.0.0.1
3659
+ SMTP_PORT=51025
3660
+ SMTP_SECURE=false
3661
+ `;
3662
+ const infraLocal = `# GroCMS Local Infrastructure Configuration
3663
+ POSTGRES_PASSWORD=${secrets.dbPassword}
3664
+ DATABASE_URL=postgresql://gcms:${secrets.dbPassword}@127.0.0.1:55432/gcms
3665
+ `;
3666
+ const prodEnv = `# GroCMS Production Configuration
3667
+ # Auto-generated by create-grocms
3668
+ PUBLIC_URL=${publicUrl}
3669
+ BETTER_AUTH_URL=${publicUrl}
3670
+ BETTER_AUTH_SECRET=${secrets.authSecret}
3671
+ GCMS_HTTP_PORT=${port}
3672
+ COMPOSE_PROJECT_NAME=gcms
3673
+ GCMS_IMAGE=gcms
3674
+ GCMS_IMAGE_TAG=latest
3675
+ GCMS_BIND_HOST=127.0.0.1
3676
+ GCMS_AUTH_IP_SOURCE=none
3677
+
3678
+ # Database configuration
3679
+ DATABASE_URL=postgresql://gcms:${secrets.dbPassword}@db:5432/gcms
3680
+ GCMS_ADMIN_PASSWORD=${secrets.dbAdminPassword}
3681
+ GCMS_MIGRATOR_PASSWORD=${secrets.dbMigratorPassword}
3682
+ GCMS_RUNTIME_PASSWORD=${secrets.dbPassword}
3683
+
3684
+ # Media volume & mail
3685
+ MEDIA_ROOT=/app/.data/media
3686
+ SMTP_HOST=
3687
+ SMTP_PORT=587
3688
+ SMTP_SECURE=false
3689
+ SMTP_FROM=GroCMS <noreply@grocms.local>
3690
+ `;
3691
+ for (const [index, contents] of [localEnv, infraLocal, prodEnv].entries()) {
3692
+ await writeFile2(path3.join(destDir, filenames[index]), contents, { encoding: "utf8", flag: "wx", mode: 384 });
3693
+ }
3694
+ return { secrets };
3695
+ }
3696
+
3697
+ // packages/create-grocms/src/scaffold.js
3698
+ async function scaffoldArchive(archive, target, options, { beforePublish = async () => {
3699
+ } } = {}) {
3700
+ const destination = await validateDestination(target);
3701
+ const parent = path4.dirname(destination);
3702
+ await mkdir2(parent, { recursive: true });
3703
+ const staging = await mkdtemp(path4.join(parent, ".grocms-install-"));
3704
+ try {
3705
+ const result = await extractArchive(archive, staging);
3706
+ await writeEnvironmentFiles(staging, options);
3707
+ await beforePublish();
3708
+ await validateDestination(destination);
3709
+ try {
3710
+ const existing = await lstat3(destination);
3711
+ if (!existing.isDirectory() || existing.isSymbolicLink()) throw new Error("Installer destination changed before publication.");
3712
+ await rmdir(destination);
3713
+ } catch (error) {
3714
+ if (error.code !== "ENOENT") throw error;
3715
+ }
3716
+ await rename(staging, destination);
3717
+ return result;
3718
+ } finally {
3719
+ await rm(staging, { recursive: true, force: true });
3720
+ }
3721
+ }
3722
+
3723
+ // packages/create-grocms/bin/index.js
3724
+ import { fileURLToPath } from "node:url";
3725
+ var DEFAULT_SERVER_URL = process.env.GROCMS_RELEASE_SERVER || "https://download.grocms.com";
3726
+ function parseArgs(args) {
3727
+ const parsed = {
3728
+ targetDir: void 0,
3729
+ publicUrl: void 0,
3730
+ licenseKey: void 0,
3731
+ releaseUrl: void 0,
3732
+ localArchive: void 0,
3733
+ skipInstall: false,
3734
+ includeDemo: false
3735
+ };
3736
+ for (let i = 0; i < args.length; i++) {
3737
+ const arg = args[i];
3738
+ if (arg === "--help" || arg === "-h") {
3739
+ printHelp();
3740
+ process.exit(0);
3741
+ } else if (arg === "--url" && args[i + 1]) {
3742
+ parsed.publicUrl = args[++i];
3743
+ } else if ((arg === "--key" || arg === "-k") && args[i + 1]) {
3744
+ parsed.licenseKey = args[++i];
3745
+ } else if (arg === "--release-url" && args[i + 1]) {
3746
+ parsed.releaseUrl = args[++i];
3747
+ } else if (arg === "--local-archive" && args[i + 1]) {
3748
+ parsed.localArchive = args[++i];
3749
+ } else if (arg === "--skip-install") {
3750
+ parsed.skipInstall = true;
3751
+ } else if (arg === "--demo") {
3752
+ parsed.includeDemo = true;
3753
+ } else if (arg === "--no-demo") {
3754
+ parsed.includeDemo = false;
3755
+ } else if (!arg.startsWith("-") && !parsed.targetDir) {
3756
+ parsed.targetDir = arg;
3757
+ }
3758
+ }
3759
+ return parsed;
3760
+ }
3761
+ function printHelp() {
3762
+ console.log(`
3763
+ ${import_picocolors3.default.bold("create-grocms")} \u2014 Scaffolds a new GroCMS project
3764
+
3765
+ ${import_picocolors3.default.bold("Usage:")}
3766
+ npx create-grocms [target-directory] [options]
3767
+
3768
+ ${import_picocolors3.default.bold("Options:")}
3769
+ --url <url> Public site URL (default: http://localhost:3100)
3770
+ --key, -k <license> License key or customer download token
3771
+ --release-url <url> Custom release server URL
3772
+ --local-archive <path> Install directly from a local release ZIP archive
3773
+ --skip-install Skip running npm ci automatically
3774
+ --demo Show setup instructions for the optional reference demo
3775
+ --no-demo Use the minimal starter (default: one post and one page)
3776
+ --help, -h Display this help message
3777
+ `);
3778
+ }
3779
+ async function fetchReleaseArchive(serverUrl, licenseKey, s, fetcher = fetch) {
3780
+ let downloadEndpoint;
3781
+ try {
3782
+ const parsed = new URL(serverUrl);
3783
+ downloadEndpoint = parsed.pathname.includes("/download") ? serverUrl : `${serverUrl.replace(/\/$/, "")}/api/releases/download`;
3784
+ } catch {
3785
+ downloadEndpoint = serverUrl.includes("/download") ? serverUrl : `${serverUrl.replace(/\/$/, "")}/api/releases/download`;
3786
+ }
3787
+ const url = new URL(downloadEndpoint);
3788
+ if (licenseKey) {
3789
+ url.searchParams.delete("token");
3790
+ url.searchParams.delete("key");
3791
+ }
3792
+ s.message(`Connecting to release server (${url.origin})...`);
3793
+ const headers = {
3794
+ "User-Agent": "create-grocms/0.1.0",
3795
+ Accept: "application/zip, application/octet-stream"
3796
+ };
3797
+ if (licenseKey) {
3798
+ headers["Authorization"] = `Bearer ${licenseKey}`;
3799
+ }
3800
+ let response;
3801
+ try {
3802
+ response = await fetcher(url.toString(), { headers, signal: AbortSignal.timeout(12e4) });
3803
+ } catch {
3804
+ throw new Error(`Could not connect to release server at ${url.origin}.`);
3805
+ }
3806
+ if (!response.ok) {
3807
+ if (response.status === 401 || response.status === 403) {
3808
+ throw new Error("Invalid or expired license key. Please check your purchase receipt.");
3809
+ }
3810
+ if (response.status === 404) {
3811
+ throw new Error("Release package not found on server.");
3812
+ }
3813
+ throw new Error(`Release server returned HTTP ${response.status}.`);
3814
+ }
3815
+ s.message("Downloading GroCMS package archive...");
3816
+ if (Number(response.headers.get("content-length")) > ARCHIVE_LIMITS.compressed) {
3817
+ await response.body?.cancel();
3818
+ throw new Error("Release archive exceeds the 64 MiB compressed limit.");
3819
+ }
3820
+ if (!response.body) throw new Error("Release server returned an empty archive.");
3821
+ const reader = response.body.getReader();
3822
+ const chunks = [];
3823
+ let size = 0;
3824
+ try {
3825
+ while (true) {
3826
+ const { value, done } = await reader.read();
3827
+ if (done) break;
3828
+ size += value.length;
3829
+ if (size > ARCHIVE_LIMITS.compressed) throw new Error("Release archive exceeds the 64 MiB compressed limit.");
3830
+ chunks.push(value);
3831
+ }
3832
+ return Buffer.concat(chunks, size);
3833
+ } finally {
3834
+ await reader.cancel().catch(() => {
3835
+ });
3836
+ }
3837
+ }
3838
+ function installDependencies(destination, execute = execSync) {
3839
+ try {
3840
+ execute("npm ci", { cwd: destination, stdio: "ignore", timeout: 3e5 });
3841
+ } catch {
3842
+ throw new Error("Dependency installation failed. Your scaffold and generated secrets are preserved. Resolve the npm error and run npm ci inside the new directory; do not rerun the scaffolder over it.");
3843
+ }
3844
+ }
3845
+ async function main(argv = process.argv.slice(2)) {
3846
+ const args = parseArgs(argv);
3847
+ if (Number(process.versions.node.split(".")[0]) !== 24) {
3848
+ throw new Error("GroCMS requires Node.js 24. Install Node.js 24 before creating a project.");
3849
+ }
3850
+ console.clear();
3851
+ pe(import_picocolors3.default.bgCyan(import_picocolors3.default.black(" GroCMS Scaffolding Wizard ")));
3852
+ let targetDir = args.targetDir;
3853
+ if (!targetDir) {
3854
+ const input = await ae({
3855
+ message: "Where would you like to create your new GroCMS project?",
3856
+ placeholder: "my-website",
3857
+ initialValue: "my-website",
3858
+ validate(val) {
3859
+ if (!val || !val.trim()) return "Please provide a folder name.";
3860
+ }
3861
+ });
3862
+ if (lD(input)) {
3863
+ he("Installation cancelled.");
3864
+ process.exit(0);
3865
+ }
3866
+ targetDir = input.trim();
3867
+ }
3868
+ const destPath = await validateDestination(targetDir);
3869
+ let publicUrl = args.publicUrl;
3870
+ if (!publicUrl) {
3871
+ const input = await ae({
3872
+ message: "What is your public site URL?",
3873
+ placeholder: "http://localhost:3100",
3874
+ initialValue: "http://localhost:3100",
3875
+ validate(val) {
3876
+ if (!val || !val.trim()) return "Please enter a valid URL.";
3877
+ try {
3878
+ new URL(val.trim());
3879
+ } catch {
3880
+ return "Please enter a valid URL (e.g. http://localhost:3100 or https://example.com).";
3881
+ }
3882
+ }
3883
+ });
3884
+ if (lD(input)) {
3885
+ he("Installation cancelled.");
3886
+ process.exit(0);
3887
+ }
3888
+ publicUrl = input.trim();
3889
+ }
3890
+ let licenseKey = args.licenseKey;
3891
+ if (!args.localArchive && !licenseKey) {
3892
+ const input = await oe({
3893
+ message: "Enter your GroCMS License Key / Download Token:",
3894
+ validate(val) {
3895
+ if (!val || !val.trim()) {
3896
+ return "A valid GroCMS license key is required to download this release.";
3897
+ }
3898
+ }
3899
+ });
3900
+ if (lD(input)) {
3901
+ he("Installation cancelled.");
3902
+ process.exit(0);
3903
+ }
3904
+ licenseKey = input.trim();
3905
+ }
3906
+ const s = _2();
3907
+ s.start("Preparing release archive...");
3908
+ let archiveBuffer;
3909
+ if (args.localArchive) {
3910
+ s.message(`Reading local archive from ${args.localArchive}...`);
3911
+ const archiveFile = path5.resolve(process.cwd(), args.localArchive);
3912
+ if (!existsSync(archiveFile)) {
3913
+ throw new Error(`Local archive file not found: ${archiveFile}`);
3914
+ }
3915
+ archiveBuffer = await readArchive(archiveFile);
3916
+ } else {
3917
+ const serverUrl = args.releaseUrl || DEFAULT_SERVER_URL;
3918
+ archiveBuffer = await fetchReleaseArchive(serverUrl, licenseKey, s);
3919
+ }
3920
+ s.message(`Extracting files into ${import_picocolors3.default.cyan(targetDir)}...`);
3921
+ const { extractedFiles } = await scaffoldArchive(archiveBuffer, destPath, { publicUrl });
3922
+ try {
3923
+ execSync("git init", { cwd: destPath, stdio: "ignore", timeout: 1e4 });
3924
+ } catch {
3925
+ }
3926
+ if (!args.skipInstall) {
3927
+ s.message("Installing project dependencies with npm (this may take a minute)...");
3928
+ installDependencies(destPath);
3929
+ }
3930
+ s.stop(import_picocolors3.default.green(`\u2714 Successfully scaffolded GroCMS in ${import_picocolors3.default.bold(targetDir)} (${extractedFiles} files)`));
3931
+ const devCommand = args.includeDemo ? "npm run setup -- --design-only && npm run seed:demo" : "npm run setup";
3932
+ ge(`
3933
+ ${import_picocolors3.default.bold(import_picocolors3.default.green("Your GroCMS project is ready!"))}
3934
+
3935
+ ${import_picocolors3.default.bold("Quick Start:")}
3936
+ ${import_picocolors3.default.cyan(`1. cd ${targetDir}`)}
3937
+ ${import_picocolors3.default.cyan("2. docker compose --env-file .env.infrastructure.local -f compose.dev.yaml up -d --wait")}
3938
+ ${import_picocolors3.default.cyan("3. npm run db:migrate")}
3939
+ ${import_picocolors3.default.cyan(`4. ${devCommand}`)}
3940
+ ${import_picocolors3.default.cyan("5. npm run dev")}
3941
+
3942
+ ${import_picocolors3.default.bold("Open in your browser:")}
3943
+ Website: ${import_picocolors3.default.underline(import_picocolors3.default.cyan(publicUrl))}
3944
+ Admin Studio: ${import_picocolors3.default.underline(import_picocolors3.default.cyan(`${publicUrl.replace(/\/$/, "")}/admin`))}
3945
+
3946
+ ${import_picocolors3.default.bold("Production Docker Deployment:")}
3947
+ Review ${import_picocolors3.default.cyan(".env.production.local")} and configure SMTP, then:
3948
+ ${import_picocolors3.default.cyan("docker compose --env-file .env.production.local -f compose.yaml build web worker")}
3949
+ ${import_picocolors3.default.cyan("docker compose --env-file .env.production.local -f compose.yaml up -d --wait db")}
3950
+ ${import_picocolors3.default.cyan("docker compose --env-file .env.production.local -f compose.yaml run --rm --no-deps migrate")}
3951
+ Create a private .env.bootstrap.local with GCMS_BOOTSTRAP_EMAIL, GCMS_BOOTSTRAP_NAME and GCMS_BOOTSTRAP_PASSWORD.
3952
+ ${import_picocolors3.default.cyan("node scripts/ops/setup.mjs --env-file .env.production.local --credentials-file .env.bootstrap.local --project gcms" + (args.includeDemo ? " --demo true" : ""))}
3953
+ ${import_picocolors3.default.cyan("node scripts/ops/deploy.mjs --env-file .env.production.local --project gcms")}
3954
+ `);
3955
+ }
3956
+ if (process.argv[1] && existsSync(process.argv[1]) && realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) main().catch((err) => {
3957
+ console.error(import_picocolors3.default.red("\n\u2716 Error:"), err.message);
3958
+ process.exit(1);
3959
+ });
3960
+ export {
3961
+ DEFAULT_SERVER_URL,
3962
+ fetchReleaseArchive,
3963
+ installDependencies,
3964
+ main,
3965
+ parseArgs
3966
+ };