@openclaw-china/qqbot 0.1.5 → 0.1.6

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 CHANGED
@@ -1,16 +1,174 @@
1
1
  import * as fs3 from 'fs';
2
+ import { existsSync } from 'fs';
2
3
  import * as os from 'os';
4
+ import { homedir } from 'os';
3
5
  import * as path from 'path';
6
+ import { join } from 'path';
4
7
  import { fileURLToPath } from 'url';
5
8
  import * as fsPromises from 'fs/promises';
6
9
  import { createHmac } from 'crypto';
10
+ import N2, { stdout, stdin } from 'process';
11
+ import ot from 'readline';
12
+ import 'tty';
13
+ import 'util';
7
14
  import WebSocket from 'ws';
8
15
 
16
+ var __create = Object.create;
9
17
  var __defProp = Object.defineProperty;
18
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
19
+ var __getOwnPropNames = Object.getOwnPropertyNames;
20
+ var __getProtoOf = Object.getPrototypeOf;
21
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
22
+ var __commonJS = (cb, mod) => function __require() {
23
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
24
+ };
10
25
  var __export = (target, all) => {
11
26
  for (var name in all)
12
27
  __defProp(target, name, { get: all[name], enumerable: true });
13
28
  };
29
+ var __copyProps = (to, from, except, desc) => {
30
+ if (from && typeof from === "object" || typeof from === "function") {
31
+ for (let key of __getOwnPropNames(from))
32
+ if (!__hasOwnProp.call(to, key) && key !== except)
33
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
+ }
35
+ return to;
36
+ };
37
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
38
+ // If the importer is in node compatibility mode or this is not an ESM
39
+ // file that has been converted to a CommonJS file using a Babel-
40
+ // compatible transform (i.e. "__esModule" has not been set), then set
41
+ // "default" to the CommonJS "module.exports" for node compatibility.
42
+ __defProp(target, "default", { value: mod, enumerable: true }) ,
43
+ mod
44
+ ));
45
+
46
+ // ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
47
+ var require_picocolors = __commonJS({
48
+ "../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports$1, module) {
49
+ var p = process || {};
50
+ var argv = p.argv || [];
51
+ var env = p.env || {};
52
+ 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);
53
+ var formatter = (open, close, replace = open) => (input2) => {
54
+ let string = "" + input2, index = string.indexOf(close, open.length);
55
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
56
+ };
57
+ var replaceClose = (string, close, replace, index) => {
58
+ let result = "", cursor = 0;
59
+ do {
60
+ result += string.substring(cursor, index) + replace;
61
+ cursor = index + close.length;
62
+ index = string.indexOf(close, cursor);
63
+ } while (~index);
64
+ return result + string.substring(cursor);
65
+ };
66
+ var createColors = (enabled = isColorSupported) => {
67
+ let f = enabled ? formatter : () => String;
68
+ return {
69
+ isColorSupported: enabled,
70
+ reset: f("\x1B[0m", "\x1B[0m"),
71
+ bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
72
+ dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
73
+ italic: f("\x1B[3m", "\x1B[23m"),
74
+ underline: f("\x1B[4m", "\x1B[24m"),
75
+ inverse: f("\x1B[7m", "\x1B[27m"),
76
+ hidden: f("\x1B[8m", "\x1B[28m"),
77
+ strikethrough: f("\x1B[9m", "\x1B[29m"),
78
+ black: f("\x1B[30m", "\x1B[39m"),
79
+ red: f("\x1B[31m", "\x1B[39m"),
80
+ green: f("\x1B[32m", "\x1B[39m"),
81
+ yellow: f("\x1B[33m", "\x1B[39m"),
82
+ blue: f("\x1B[34m", "\x1B[39m"),
83
+ magenta: f("\x1B[35m", "\x1B[39m"),
84
+ cyan: f("\x1B[36m", "\x1B[39m"),
85
+ white: f("\x1B[37m", "\x1B[39m"),
86
+ gray: f("\x1B[90m", "\x1B[39m"),
87
+ bgBlack: f("\x1B[40m", "\x1B[49m"),
88
+ bgRed: f("\x1B[41m", "\x1B[49m"),
89
+ bgGreen: f("\x1B[42m", "\x1B[49m"),
90
+ bgYellow: f("\x1B[43m", "\x1B[49m"),
91
+ bgBlue: f("\x1B[44m", "\x1B[49m"),
92
+ bgMagenta: f("\x1B[45m", "\x1B[49m"),
93
+ bgCyan: f("\x1B[46m", "\x1B[49m"),
94
+ bgWhite: f("\x1B[47m", "\x1B[49m"),
95
+ blackBright: f("\x1B[90m", "\x1B[39m"),
96
+ redBright: f("\x1B[91m", "\x1B[39m"),
97
+ greenBright: f("\x1B[92m", "\x1B[39m"),
98
+ yellowBright: f("\x1B[93m", "\x1B[39m"),
99
+ blueBright: f("\x1B[94m", "\x1B[39m"),
100
+ magentaBright: f("\x1B[95m", "\x1B[39m"),
101
+ cyanBright: f("\x1B[96m", "\x1B[39m"),
102
+ whiteBright: f("\x1B[97m", "\x1B[39m"),
103
+ bgBlackBright: f("\x1B[100m", "\x1B[49m"),
104
+ bgRedBright: f("\x1B[101m", "\x1B[49m"),
105
+ bgGreenBright: f("\x1B[102m", "\x1B[49m"),
106
+ bgYellowBright: f("\x1B[103m", "\x1B[49m"),
107
+ bgBlueBright: f("\x1B[104m", "\x1B[49m"),
108
+ bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
109
+ bgCyanBright: f("\x1B[106m", "\x1B[49m"),
110
+ bgWhiteBright: f("\x1B[107m", "\x1B[49m")
111
+ };
112
+ };
113
+ module.exports = createColors();
114
+ module.exports.createColors = createColors;
115
+ }
116
+ });
117
+
118
+ // ../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
119
+ var require_src = __commonJS({
120
+ "../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports$1, module) {
121
+ var ESC = "\x1B";
122
+ var CSI = `${ESC}[`;
123
+ var beep = "\x07";
124
+ var cursor = {
125
+ to(x3, y2) {
126
+ if (!y2) return `${CSI}${x3 + 1}G`;
127
+ return `${CSI}${y2 + 1};${x3 + 1}H`;
128
+ },
129
+ move(x3, y2) {
130
+ let ret = "";
131
+ if (x3 < 0) ret += `${CSI}${-x3}D`;
132
+ else if (x3 > 0) ret += `${CSI}${x3}C`;
133
+ if (y2 < 0) ret += `${CSI}${-y2}A`;
134
+ else if (y2 > 0) ret += `${CSI}${y2}B`;
135
+ return ret;
136
+ },
137
+ up: (count = 1) => `${CSI}${count}A`,
138
+ down: (count = 1) => `${CSI}${count}B`,
139
+ forward: (count = 1) => `${CSI}${count}C`,
140
+ backward: (count = 1) => `${CSI}${count}D`,
141
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
142
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
143
+ left: `${CSI}G`,
144
+ hide: `${CSI}?25l`,
145
+ show: `${CSI}?25h`,
146
+ save: `${ESC}7`,
147
+ restore: `${ESC}8`
148
+ };
149
+ var scroll = {
150
+ up: (count = 1) => `${CSI}S`.repeat(count),
151
+ down: (count = 1) => `${CSI}T`.repeat(count)
152
+ };
153
+ var erase = {
154
+ screen: `${CSI}2J`,
155
+ up: (count = 1) => `${CSI}1J`.repeat(count),
156
+ down: (count = 1) => `${CSI}J`.repeat(count),
157
+ line: `${CSI}2K`,
158
+ lineEnd: `${CSI}K`,
159
+ lineStart: `${CSI}1K`,
160
+ lines(count) {
161
+ let clear = "";
162
+ for (let i = 0; i < count; i++)
163
+ clear += this.line + (i < count - 1 ? cursor.up() : "");
164
+ if (count)
165
+ clear += cursor.left;
166
+ return clear;
167
+ }
168
+ };
169
+ module.exports = { cursor, scroll, erase, beep };
170
+ }
171
+ });
14
172
 
15
173
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
16
174
  var external_exports = {};
@@ -127,7 +285,7 @@ __export(external_exports, {
127
285
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
128
286
  var util;
129
287
  (function(util2) {
130
- util2.assertEqual = (_) => {
288
+ util2.assertEqual = (_2) => {
131
289
  };
132
290
  function assertIs(_arg) {
133
291
  }
@@ -144,16 +302,16 @@ var util;
144
302
  return obj;
145
303
  };
146
304
  util2.getValidEnumValues = (obj) => {
147
- const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
305
+ const validKeys = util2.objectKeys(obj).filter((k2) => typeof obj[obj[k2]] !== "number");
148
306
  const filtered = {};
149
- for (const k of validKeys) {
150
- filtered[k] = obj[k];
307
+ for (const k2 of validKeys) {
308
+ filtered[k2] = obj[k2];
151
309
  }
152
310
  return util2.objectValues(filtered);
153
311
  };
154
312
  util2.objectValues = (obj) => {
155
- return util2.objectKeys(obj).map(function(e) {
156
- return obj[e];
313
+ return util2.objectKeys(obj).map(function(e2) {
314
+ return obj[e2];
157
315
  });
158
316
  };
159
317
  util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
@@ -177,7 +335,7 @@ var util;
177
335
  return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
178
336
  }
179
337
  util2.joinValues = joinValues;
180
- util2.jsonStringifyReplacer = (_, value) => {
338
+ util2.jsonStringifyReplacer = (_2, value) => {
181
339
  if (typeof value === "bigint") {
182
340
  return value.toString();
183
341
  }
@@ -530,7 +688,7 @@ function addIssueToContext(ctx, issueData) {
530
688
  // then global override map
531
689
  overrideMap === en_default ? void 0 : en_default
532
690
  // then global default map
533
- ].filter((x) => !!x)
691
+ ].filter((x3) => !!x3)
534
692
  });
535
693
  ctx.common.issues.push(issue);
536
694
  }
@@ -593,10 +751,10 @@ var INVALID = Object.freeze({
593
751
  });
594
752
  var DIRTY = (value) => ({ status: "dirty", value });
595
753
  var OK = (value) => ({ status: "valid", value });
596
- var isAborted = (x) => x.status === "aborted";
597
- var isDirty = (x) => x.status === "dirty";
598
- var isValid = (x) => x.status === "valid";
599
- var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
754
+ var isAborted = (x3) => x3.status === "aborted";
755
+ var isDirty = (x3) => x3.status === "dirty";
756
+ var isValid = (x3) => x3.status === "valid";
757
+ var isAsync = (x3) => typeof Promise !== "undefined" && x3 instanceof Promise;
600
758
 
601
759
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
602
760
  var errorUtil;
@@ -671,41 +829,41 @@ var ZodType = class {
671
829
  get description() {
672
830
  return this._def.description;
673
831
  }
674
- _getType(input) {
675
- return getParsedType(input.data);
832
+ _getType(input2) {
833
+ return getParsedType(input2.data);
676
834
  }
677
- _getOrReturnCtx(input, ctx) {
835
+ _getOrReturnCtx(input2, ctx) {
678
836
  return ctx || {
679
- common: input.parent.common,
680
- data: input.data,
681
- parsedType: getParsedType(input.data),
837
+ common: input2.parent.common,
838
+ data: input2.data,
839
+ parsedType: getParsedType(input2.data),
682
840
  schemaErrorMap: this._def.errorMap,
683
- path: input.path,
684
- parent: input.parent
841
+ path: input2.path,
842
+ parent: input2.parent
685
843
  };
686
844
  }
687
- _processInputParams(input) {
845
+ _processInputParams(input2) {
688
846
  return {
689
847
  status: new ParseStatus(),
690
848
  ctx: {
691
- common: input.parent.common,
692
- data: input.data,
693
- parsedType: getParsedType(input.data),
849
+ common: input2.parent.common,
850
+ data: input2.data,
851
+ parsedType: getParsedType(input2.data),
694
852
  schemaErrorMap: this._def.errorMap,
695
- path: input.path,
696
- parent: input.parent
853
+ path: input2.path,
854
+ parent: input2.parent
697
855
  }
698
856
  };
699
857
  }
700
- _parseSync(input) {
701
- const result = this._parse(input);
858
+ _parseSync(input2) {
859
+ const result = this._parse(input2);
702
860
  if (isAsync(result)) {
703
861
  throw new Error("Synchronous parse encountered promise.");
704
862
  }
705
863
  return result;
706
864
  }
707
- _parseAsync(input) {
708
- const result = this._parse(input);
865
+ _parseAsync(input2) {
866
+ const result = this._parse(input2);
709
867
  return Promise.resolve(result);
710
868
  }
711
869
  parse(data, params) {
@@ -1031,13 +1189,13 @@ function isValidCidr(ip, version) {
1031
1189
  return false;
1032
1190
  }
1033
1191
  var ZodString = class _ZodString extends ZodType {
1034
- _parse(input) {
1192
+ _parse(input2) {
1035
1193
  if (this._def.coerce) {
1036
- input.data = String(input.data);
1194
+ input2.data = String(input2.data);
1037
1195
  }
1038
- const parsedType = this._getType(input);
1196
+ const parsedType = this._getType(input2);
1039
1197
  if (parsedType !== ZodParsedType.string) {
1040
- const ctx2 = this._getOrReturnCtx(input);
1198
+ const ctx2 = this._getOrReturnCtx(input2);
1041
1199
  addIssueToContext(ctx2, {
1042
1200
  code: ZodIssueCode.invalid_type,
1043
1201
  expected: ZodParsedType.string,
@@ -1049,8 +1207,8 @@ var ZodString = class _ZodString extends ZodType {
1049
1207
  let ctx = void 0;
1050
1208
  for (const check of this._def.checks) {
1051
1209
  if (check.kind === "min") {
1052
- if (input.data.length < check.value) {
1053
- ctx = this._getOrReturnCtx(input, ctx);
1210
+ if (input2.data.length < check.value) {
1211
+ ctx = this._getOrReturnCtx(input2, ctx);
1054
1212
  addIssueToContext(ctx, {
1055
1213
  code: ZodIssueCode.too_small,
1056
1214
  minimum: check.value,
@@ -1062,8 +1220,8 @@ var ZodString = class _ZodString extends ZodType {
1062
1220
  status.dirty();
1063
1221
  }
1064
1222
  } else if (check.kind === "max") {
1065
- if (input.data.length > check.value) {
1066
- ctx = this._getOrReturnCtx(input, ctx);
1223
+ if (input2.data.length > check.value) {
1224
+ ctx = this._getOrReturnCtx(input2, ctx);
1067
1225
  addIssueToContext(ctx, {
1068
1226
  code: ZodIssueCode.too_big,
1069
1227
  maximum: check.value,
@@ -1075,10 +1233,10 @@ var ZodString = class _ZodString extends ZodType {
1075
1233
  status.dirty();
1076
1234
  }
1077
1235
  } else if (check.kind === "length") {
1078
- const tooBig = input.data.length > check.value;
1079
- const tooSmall = input.data.length < check.value;
1236
+ const tooBig = input2.data.length > check.value;
1237
+ const tooSmall = input2.data.length < check.value;
1080
1238
  if (tooBig || tooSmall) {
1081
- ctx = this._getOrReturnCtx(input, ctx);
1239
+ ctx = this._getOrReturnCtx(input2, ctx);
1082
1240
  if (tooBig) {
1083
1241
  addIssueToContext(ctx, {
1084
1242
  code: ZodIssueCode.too_big,
@@ -1101,8 +1259,8 @@ var ZodString = class _ZodString extends ZodType {
1101
1259
  status.dirty();
1102
1260
  }
1103
1261
  } else if (check.kind === "email") {
1104
- if (!emailRegex.test(input.data)) {
1105
- ctx = this._getOrReturnCtx(input, ctx);
1262
+ if (!emailRegex.test(input2.data)) {
1263
+ ctx = this._getOrReturnCtx(input2, ctx);
1106
1264
  addIssueToContext(ctx, {
1107
1265
  validation: "email",
1108
1266
  code: ZodIssueCode.invalid_string,
@@ -1114,8 +1272,8 @@ var ZodString = class _ZodString extends ZodType {
1114
1272
  if (!emojiRegex) {
1115
1273
  emojiRegex = new RegExp(_emojiRegex, "u");
1116
1274
  }
1117
- if (!emojiRegex.test(input.data)) {
1118
- ctx = this._getOrReturnCtx(input, ctx);
1275
+ if (!emojiRegex.test(input2.data)) {
1276
+ ctx = this._getOrReturnCtx(input2, ctx);
1119
1277
  addIssueToContext(ctx, {
1120
1278
  validation: "emoji",
1121
1279
  code: ZodIssueCode.invalid_string,
@@ -1124,8 +1282,8 @@ var ZodString = class _ZodString extends ZodType {
1124
1282
  status.dirty();
1125
1283
  }
1126
1284
  } else if (check.kind === "uuid") {
1127
- if (!uuidRegex.test(input.data)) {
1128
- ctx = this._getOrReturnCtx(input, ctx);
1285
+ if (!uuidRegex.test(input2.data)) {
1286
+ ctx = this._getOrReturnCtx(input2, ctx);
1129
1287
  addIssueToContext(ctx, {
1130
1288
  validation: "uuid",
1131
1289
  code: ZodIssueCode.invalid_string,
@@ -1134,8 +1292,8 @@ var ZodString = class _ZodString extends ZodType {
1134
1292
  status.dirty();
1135
1293
  }
1136
1294
  } else if (check.kind === "nanoid") {
1137
- if (!nanoidRegex.test(input.data)) {
1138
- ctx = this._getOrReturnCtx(input, ctx);
1295
+ if (!nanoidRegex.test(input2.data)) {
1296
+ ctx = this._getOrReturnCtx(input2, ctx);
1139
1297
  addIssueToContext(ctx, {
1140
1298
  validation: "nanoid",
1141
1299
  code: ZodIssueCode.invalid_string,
@@ -1144,8 +1302,8 @@ var ZodString = class _ZodString extends ZodType {
1144
1302
  status.dirty();
1145
1303
  }
1146
1304
  } else if (check.kind === "cuid") {
1147
- if (!cuidRegex.test(input.data)) {
1148
- ctx = this._getOrReturnCtx(input, ctx);
1305
+ if (!cuidRegex.test(input2.data)) {
1306
+ ctx = this._getOrReturnCtx(input2, ctx);
1149
1307
  addIssueToContext(ctx, {
1150
1308
  validation: "cuid",
1151
1309
  code: ZodIssueCode.invalid_string,
@@ -1154,8 +1312,8 @@ var ZodString = class _ZodString extends ZodType {
1154
1312
  status.dirty();
1155
1313
  }
1156
1314
  } else if (check.kind === "cuid2") {
1157
- if (!cuid2Regex.test(input.data)) {
1158
- ctx = this._getOrReturnCtx(input, ctx);
1315
+ if (!cuid2Regex.test(input2.data)) {
1316
+ ctx = this._getOrReturnCtx(input2, ctx);
1159
1317
  addIssueToContext(ctx, {
1160
1318
  validation: "cuid2",
1161
1319
  code: ZodIssueCode.invalid_string,
@@ -1164,8 +1322,8 @@ var ZodString = class _ZodString extends ZodType {
1164
1322
  status.dirty();
1165
1323
  }
1166
1324
  } else if (check.kind === "ulid") {
1167
- if (!ulidRegex.test(input.data)) {
1168
- ctx = this._getOrReturnCtx(input, ctx);
1325
+ if (!ulidRegex.test(input2.data)) {
1326
+ ctx = this._getOrReturnCtx(input2, ctx);
1169
1327
  addIssueToContext(ctx, {
1170
1328
  validation: "ulid",
1171
1329
  code: ZodIssueCode.invalid_string,
@@ -1175,9 +1333,9 @@ var ZodString = class _ZodString extends ZodType {
1175
1333
  }
1176
1334
  } else if (check.kind === "url") {
1177
1335
  try {
1178
- new URL(input.data);
1336
+ new URL(input2.data);
1179
1337
  } catch {
1180
- ctx = this._getOrReturnCtx(input, ctx);
1338
+ ctx = this._getOrReturnCtx(input2, ctx);
1181
1339
  addIssueToContext(ctx, {
1182
1340
  validation: "url",
1183
1341
  code: ZodIssueCode.invalid_string,
@@ -1187,9 +1345,9 @@ var ZodString = class _ZodString extends ZodType {
1187
1345
  }
1188
1346
  } else if (check.kind === "regex") {
1189
1347
  check.regex.lastIndex = 0;
1190
- const testResult = check.regex.test(input.data);
1348
+ const testResult = check.regex.test(input2.data);
1191
1349
  if (!testResult) {
1192
- ctx = this._getOrReturnCtx(input, ctx);
1350
+ ctx = this._getOrReturnCtx(input2, ctx);
1193
1351
  addIssueToContext(ctx, {
1194
1352
  validation: "regex",
1195
1353
  code: ZodIssueCode.invalid_string,
@@ -1198,10 +1356,10 @@ var ZodString = class _ZodString extends ZodType {
1198
1356
  status.dirty();
1199
1357
  }
1200
1358
  } else if (check.kind === "trim") {
1201
- input.data = input.data.trim();
1359
+ input2.data = input2.data.trim();
1202
1360
  } else if (check.kind === "includes") {
1203
- if (!input.data.includes(check.value, check.position)) {
1204
- ctx = this._getOrReturnCtx(input, ctx);
1361
+ if (!input2.data.includes(check.value, check.position)) {
1362
+ ctx = this._getOrReturnCtx(input2, ctx);
1205
1363
  addIssueToContext(ctx, {
1206
1364
  code: ZodIssueCode.invalid_string,
1207
1365
  validation: { includes: check.value, position: check.position },
@@ -1210,12 +1368,12 @@ var ZodString = class _ZodString extends ZodType {
1210
1368
  status.dirty();
1211
1369
  }
1212
1370
  } else if (check.kind === "toLowerCase") {
1213
- input.data = input.data.toLowerCase();
1371
+ input2.data = input2.data.toLowerCase();
1214
1372
  } else if (check.kind === "toUpperCase") {
1215
- input.data = input.data.toUpperCase();
1373
+ input2.data = input2.data.toUpperCase();
1216
1374
  } else if (check.kind === "startsWith") {
1217
- if (!input.data.startsWith(check.value)) {
1218
- ctx = this._getOrReturnCtx(input, ctx);
1375
+ if (!input2.data.startsWith(check.value)) {
1376
+ ctx = this._getOrReturnCtx(input2, ctx);
1219
1377
  addIssueToContext(ctx, {
1220
1378
  code: ZodIssueCode.invalid_string,
1221
1379
  validation: { startsWith: check.value },
@@ -1224,8 +1382,8 @@ var ZodString = class _ZodString extends ZodType {
1224
1382
  status.dirty();
1225
1383
  }
1226
1384
  } else if (check.kind === "endsWith") {
1227
- if (!input.data.endsWith(check.value)) {
1228
- ctx = this._getOrReturnCtx(input, ctx);
1385
+ if (!input2.data.endsWith(check.value)) {
1386
+ ctx = this._getOrReturnCtx(input2, ctx);
1229
1387
  addIssueToContext(ctx, {
1230
1388
  code: ZodIssueCode.invalid_string,
1231
1389
  validation: { endsWith: check.value },
@@ -1235,8 +1393,8 @@ var ZodString = class _ZodString extends ZodType {
1235
1393
  }
1236
1394
  } else if (check.kind === "datetime") {
1237
1395
  const regex = datetimeRegex(check);
1238
- if (!regex.test(input.data)) {
1239
- ctx = this._getOrReturnCtx(input, ctx);
1396
+ if (!regex.test(input2.data)) {
1397
+ ctx = this._getOrReturnCtx(input2, ctx);
1240
1398
  addIssueToContext(ctx, {
1241
1399
  code: ZodIssueCode.invalid_string,
1242
1400
  validation: "datetime",
@@ -1246,8 +1404,8 @@ var ZodString = class _ZodString extends ZodType {
1246
1404
  }
1247
1405
  } else if (check.kind === "date") {
1248
1406
  const regex = dateRegex;
1249
- if (!regex.test(input.data)) {
1250
- ctx = this._getOrReturnCtx(input, ctx);
1407
+ if (!regex.test(input2.data)) {
1408
+ ctx = this._getOrReturnCtx(input2, ctx);
1251
1409
  addIssueToContext(ctx, {
1252
1410
  code: ZodIssueCode.invalid_string,
1253
1411
  validation: "date",
@@ -1257,8 +1415,8 @@ var ZodString = class _ZodString extends ZodType {
1257
1415
  }
1258
1416
  } else if (check.kind === "time") {
1259
1417
  const regex = timeRegex(check);
1260
- if (!regex.test(input.data)) {
1261
- ctx = this._getOrReturnCtx(input, ctx);
1418
+ if (!regex.test(input2.data)) {
1419
+ ctx = this._getOrReturnCtx(input2, ctx);
1262
1420
  addIssueToContext(ctx, {
1263
1421
  code: ZodIssueCode.invalid_string,
1264
1422
  validation: "time",
@@ -1267,8 +1425,8 @@ var ZodString = class _ZodString extends ZodType {
1267
1425
  status.dirty();
1268
1426
  }
1269
1427
  } else if (check.kind === "duration") {
1270
- if (!durationRegex.test(input.data)) {
1271
- ctx = this._getOrReturnCtx(input, ctx);
1428
+ if (!durationRegex.test(input2.data)) {
1429
+ ctx = this._getOrReturnCtx(input2, ctx);
1272
1430
  addIssueToContext(ctx, {
1273
1431
  validation: "duration",
1274
1432
  code: ZodIssueCode.invalid_string,
@@ -1277,8 +1435,8 @@ var ZodString = class _ZodString extends ZodType {
1277
1435
  status.dirty();
1278
1436
  }
1279
1437
  } else if (check.kind === "ip") {
1280
- if (!isValidIP(input.data, check.version)) {
1281
- ctx = this._getOrReturnCtx(input, ctx);
1438
+ if (!isValidIP(input2.data, check.version)) {
1439
+ ctx = this._getOrReturnCtx(input2, ctx);
1282
1440
  addIssueToContext(ctx, {
1283
1441
  validation: "ip",
1284
1442
  code: ZodIssueCode.invalid_string,
@@ -1287,8 +1445,8 @@ var ZodString = class _ZodString extends ZodType {
1287
1445
  status.dirty();
1288
1446
  }
1289
1447
  } else if (check.kind === "jwt") {
1290
- if (!isValidJWT(input.data, check.alg)) {
1291
- ctx = this._getOrReturnCtx(input, ctx);
1448
+ if (!isValidJWT(input2.data, check.alg)) {
1449
+ ctx = this._getOrReturnCtx(input2, ctx);
1292
1450
  addIssueToContext(ctx, {
1293
1451
  validation: "jwt",
1294
1452
  code: ZodIssueCode.invalid_string,
@@ -1297,8 +1455,8 @@ var ZodString = class _ZodString extends ZodType {
1297
1455
  status.dirty();
1298
1456
  }
1299
1457
  } else if (check.kind === "cidr") {
1300
- if (!isValidCidr(input.data, check.version)) {
1301
- ctx = this._getOrReturnCtx(input, ctx);
1458
+ if (!isValidCidr(input2.data, check.version)) {
1459
+ ctx = this._getOrReturnCtx(input2, ctx);
1302
1460
  addIssueToContext(ctx, {
1303
1461
  validation: "cidr",
1304
1462
  code: ZodIssueCode.invalid_string,
@@ -1307,8 +1465,8 @@ var ZodString = class _ZodString extends ZodType {
1307
1465
  status.dirty();
1308
1466
  }
1309
1467
  } else if (check.kind === "base64") {
1310
- if (!base64Regex.test(input.data)) {
1311
- ctx = this._getOrReturnCtx(input, ctx);
1468
+ if (!base64Regex.test(input2.data)) {
1469
+ ctx = this._getOrReturnCtx(input2, ctx);
1312
1470
  addIssueToContext(ctx, {
1313
1471
  validation: "base64",
1314
1472
  code: ZodIssueCode.invalid_string,
@@ -1317,8 +1475,8 @@ var ZodString = class _ZodString extends ZodType {
1317
1475
  status.dirty();
1318
1476
  }
1319
1477
  } else if (check.kind === "base64url") {
1320
- if (!base64urlRegex.test(input.data)) {
1321
- ctx = this._getOrReturnCtx(input, ctx);
1478
+ if (!base64urlRegex.test(input2.data)) {
1479
+ ctx = this._getOrReturnCtx(input2, ctx);
1322
1480
  addIssueToContext(ctx, {
1323
1481
  validation: "base64url",
1324
1482
  code: ZodIssueCode.invalid_string,
@@ -1330,7 +1488,7 @@ var ZodString = class _ZodString extends ZodType {
1330
1488
  util.assertNever(check);
1331
1489
  }
1332
1490
  }
1333
- return { status: status.value, value: input.data };
1491
+ return { status: status.value, value: input2.data };
1334
1492
  }
1335
1493
  _regex(regex, validation, message) {
1336
1494
  return this.refinement((data) => regex.test(data), {
@@ -1591,13 +1749,13 @@ var ZodNumber = class _ZodNumber extends ZodType {
1591
1749
  this.max = this.lte;
1592
1750
  this.step = this.multipleOf;
1593
1751
  }
1594
- _parse(input) {
1752
+ _parse(input2) {
1595
1753
  if (this._def.coerce) {
1596
- input.data = Number(input.data);
1754
+ input2.data = Number(input2.data);
1597
1755
  }
1598
- const parsedType = this._getType(input);
1756
+ const parsedType = this._getType(input2);
1599
1757
  if (parsedType !== ZodParsedType.number) {
1600
- const ctx2 = this._getOrReturnCtx(input);
1758
+ const ctx2 = this._getOrReturnCtx(input2);
1601
1759
  addIssueToContext(ctx2, {
1602
1760
  code: ZodIssueCode.invalid_type,
1603
1761
  expected: ZodParsedType.number,
@@ -1609,8 +1767,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
1609
1767
  const status = new ParseStatus();
1610
1768
  for (const check of this._def.checks) {
1611
1769
  if (check.kind === "int") {
1612
- if (!util.isInteger(input.data)) {
1613
- ctx = this._getOrReturnCtx(input, ctx);
1770
+ if (!util.isInteger(input2.data)) {
1771
+ ctx = this._getOrReturnCtx(input2, ctx);
1614
1772
  addIssueToContext(ctx, {
1615
1773
  code: ZodIssueCode.invalid_type,
1616
1774
  expected: "integer",
@@ -1620,9 +1778,9 @@ var ZodNumber = class _ZodNumber extends ZodType {
1620
1778
  status.dirty();
1621
1779
  }
1622
1780
  } else if (check.kind === "min") {
1623
- const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1781
+ const tooSmall = check.inclusive ? input2.data < check.value : input2.data <= check.value;
1624
1782
  if (tooSmall) {
1625
- ctx = this._getOrReturnCtx(input, ctx);
1783
+ ctx = this._getOrReturnCtx(input2, ctx);
1626
1784
  addIssueToContext(ctx, {
1627
1785
  code: ZodIssueCode.too_small,
1628
1786
  minimum: check.value,
@@ -1634,9 +1792,9 @@ var ZodNumber = class _ZodNumber extends ZodType {
1634
1792
  status.dirty();
1635
1793
  }
1636
1794
  } else if (check.kind === "max") {
1637
- const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1795
+ const tooBig = check.inclusive ? input2.data > check.value : input2.data >= check.value;
1638
1796
  if (tooBig) {
1639
- ctx = this._getOrReturnCtx(input, ctx);
1797
+ ctx = this._getOrReturnCtx(input2, ctx);
1640
1798
  addIssueToContext(ctx, {
1641
1799
  code: ZodIssueCode.too_big,
1642
1800
  maximum: check.value,
@@ -1648,8 +1806,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
1648
1806
  status.dirty();
1649
1807
  }
1650
1808
  } else if (check.kind === "multipleOf") {
1651
- if (floatSafeRemainder(input.data, check.value) !== 0) {
1652
- ctx = this._getOrReturnCtx(input, ctx);
1809
+ if (floatSafeRemainder(input2.data, check.value) !== 0) {
1810
+ ctx = this._getOrReturnCtx(input2, ctx);
1653
1811
  addIssueToContext(ctx, {
1654
1812
  code: ZodIssueCode.not_multiple_of,
1655
1813
  multipleOf: check.value,
@@ -1658,8 +1816,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
1658
1816
  status.dirty();
1659
1817
  }
1660
1818
  } else if (check.kind === "finite") {
1661
- if (!Number.isFinite(input.data)) {
1662
- ctx = this._getOrReturnCtx(input, ctx);
1819
+ if (!Number.isFinite(input2.data)) {
1820
+ ctx = this._getOrReturnCtx(input2, ctx);
1663
1821
  addIssueToContext(ctx, {
1664
1822
  code: ZodIssueCode.not_finite,
1665
1823
  message: check.message
@@ -1670,7 +1828,7 @@ var ZodNumber = class _ZodNumber extends ZodType {
1670
1828
  util.assertNever(check);
1671
1829
  }
1672
1830
  }
1673
- return { status: status.value, value: input.data };
1831
+ return { status: status.value, value: input2.data };
1674
1832
  }
1675
1833
  gte(value, message) {
1676
1834
  return this.setLimit("min", value, true, errorUtil.toString(message));
@@ -1822,25 +1980,25 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
1822
1980
  this.min = this.gte;
1823
1981
  this.max = this.lte;
1824
1982
  }
1825
- _parse(input) {
1983
+ _parse(input2) {
1826
1984
  if (this._def.coerce) {
1827
1985
  try {
1828
- input.data = BigInt(input.data);
1986
+ input2.data = BigInt(input2.data);
1829
1987
  } catch {
1830
- return this._getInvalidInput(input);
1988
+ return this._getInvalidInput(input2);
1831
1989
  }
1832
1990
  }
1833
- const parsedType = this._getType(input);
1991
+ const parsedType = this._getType(input2);
1834
1992
  if (parsedType !== ZodParsedType.bigint) {
1835
- return this._getInvalidInput(input);
1993
+ return this._getInvalidInput(input2);
1836
1994
  }
1837
1995
  let ctx = void 0;
1838
1996
  const status = new ParseStatus();
1839
1997
  for (const check of this._def.checks) {
1840
1998
  if (check.kind === "min") {
1841
- const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1999
+ const tooSmall = check.inclusive ? input2.data < check.value : input2.data <= check.value;
1842
2000
  if (tooSmall) {
1843
- ctx = this._getOrReturnCtx(input, ctx);
2001
+ ctx = this._getOrReturnCtx(input2, ctx);
1844
2002
  addIssueToContext(ctx, {
1845
2003
  code: ZodIssueCode.too_small,
1846
2004
  type: "bigint",
@@ -1851,9 +2009,9 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
1851
2009
  status.dirty();
1852
2010
  }
1853
2011
  } else if (check.kind === "max") {
1854
- const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
2012
+ const tooBig = check.inclusive ? input2.data > check.value : input2.data >= check.value;
1855
2013
  if (tooBig) {
1856
- ctx = this._getOrReturnCtx(input, ctx);
2014
+ ctx = this._getOrReturnCtx(input2, ctx);
1857
2015
  addIssueToContext(ctx, {
1858
2016
  code: ZodIssueCode.too_big,
1859
2017
  type: "bigint",
@@ -1864,8 +2022,8 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
1864
2022
  status.dirty();
1865
2023
  }
1866
2024
  } else if (check.kind === "multipleOf") {
1867
- if (input.data % check.value !== BigInt(0)) {
1868
- ctx = this._getOrReturnCtx(input, ctx);
2025
+ if (input2.data % check.value !== BigInt(0)) {
2026
+ ctx = this._getOrReturnCtx(input2, ctx);
1869
2027
  addIssueToContext(ctx, {
1870
2028
  code: ZodIssueCode.not_multiple_of,
1871
2029
  multipleOf: check.value,
@@ -1877,10 +2035,10 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
1877
2035
  util.assertNever(check);
1878
2036
  }
1879
2037
  }
1880
- return { status: status.value, value: input.data };
2038
+ return { status: status.value, value: input2.data };
1881
2039
  }
1882
- _getInvalidInput(input) {
1883
- const ctx = this._getOrReturnCtx(input);
2040
+ _getInvalidInput(input2) {
2041
+ const ctx = this._getOrReturnCtx(input2);
1884
2042
  addIssueToContext(ctx, {
1885
2043
  code: ZodIssueCode.invalid_type,
1886
2044
  expected: ZodParsedType.bigint,
@@ -1989,13 +2147,13 @@ ZodBigInt.create = (params) => {
1989
2147
  });
1990
2148
  };
1991
2149
  var ZodBoolean = class extends ZodType {
1992
- _parse(input) {
2150
+ _parse(input2) {
1993
2151
  if (this._def.coerce) {
1994
- input.data = Boolean(input.data);
2152
+ input2.data = Boolean(input2.data);
1995
2153
  }
1996
- const parsedType = this._getType(input);
2154
+ const parsedType = this._getType(input2);
1997
2155
  if (parsedType !== ZodParsedType.boolean) {
1998
- const ctx = this._getOrReturnCtx(input);
2156
+ const ctx = this._getOrReturnCtx(input2);
1999
2157
  addIssueToContext(ctx, {
2000
2158
  code: ZodIssueCode.invalid_type,
2001
2159
  expected: ZodParsedType.boolean,
@@ -2003,7 +2161,7 @@ var ZodBoolean = class extends ZodType {
2003
2161
  });
2004
2162
  return INVALID;
2005
2163
  }
2006
- return OK(input.data);
2164
+ return OK(input2.data);
2007
2165
  }
2008
2166
  };
2009
2167
  ZodBoolean.create = (params) => {
@@ -2014,13 +2172,13 @@ ZodBoolean.create = (params) => {
2014
2172
  });
2015
2173
  };
2016
2174
  var ZodDate = class _ZodDate extends ZodType {
2017
- _parse(input) {
2175
+ _parse(input2) {
2018
2176
  if (this._def.coerce) {
2019
- input.data = new Date(input.data);
2177
+ input2.data = new Date(input2.data);
2020
2178
  }
2021
- const parsedType = this._getType(input);
2179
+ const parsedType = this._getType(input2);
2022
2180
  if (parsedType !== ZodParsedType.date) {
2023
- const ctx2 = this._getOrReturnCtx(input);
2181
+ const ctx2 = this._getOrReturnCtx(input2);
2024
2182
  addIssueToContext(ctx2, {
2025
2183
  code: ZodIssueCode.invalid_type,
2026
2184
  expected: ZodParsedType.date,
@@ -2028,8 +2186,8 @@ var ZodDate = class _ZodDate extends ZodType {
2028
2186
  });
2029
2187
  return INVALID;
2030
2188
  }
2031
- if (Number.isNaN(input.data.getTime())) {
2032
- const ctx2 = this._getOrReturnCtx(input);
2189
+ if (Number.isNaN(input2.data.getTime())) {
2190
+ const ctx2 = this._getOrReturnCtx(input2);
2033
2191
  addIssueToContext(ctx2, {
2034
2192
  code: ZodIssueCode.invalid_date
2035
2193
  });
@@ -2039,8 +2197,8 @@ var ZodDate = class _ZodDate extends ZodType {
2039
2197
  let ctx = void 0;
2040
2198
  for (const check of this._def.checks) {
2041
2199
  if (check.kind === "min") {
2042
- if (input.data.getTime() < check.value) {
2043
- ctx = this._getOrReturnCtx(input, ctx);
2200
+ if (input2.data.getTime() < check.value) {
2201
+ ctx = this._getOrReturnCtx(input2, ctx);
2044
2202
  addIssueToContext(ctx, {
2045
2203
  code: ZodIssueCode.too_small,
2046
2204
  message: check.message,
@@ -2052,8 +2210,8 @@ var ZodDate = class _ZodDate extends ZodType {
2052
2210
  status.dirty();
2053
2211
  }
2054
2212
  } else if (check.kind === "max") {
2055
- if (input.data.getTime() > check.value) {
2056
- ctx = this._getOrReturnCtx(input, ctx);
2213
+ if (input2.data.getTime() > check.value) {
2214
+ ctx = this._getOrReturnCtx(input2, ctx);
2057
2215
  addIssueToContext(ctx, {
2058
2216
  code: ZodIssueCode.too_big,
2059
2217
  message: check.message,
@@ -2070,7 +2228,7 @@ var ZodDate = class _ZodDate extends ZodType {
2070
2228
  }
2071
2229
  return {
2072
2230
  status: status.value,
2073
- value: new Date(input.data.getTime())
2231
+ value: new Date(input2.data.getTime())
2074
2232
  };
2075
2233
  }
2076
2234
  _addCheck(check) {
@@ -2123,10 +2281,10 @@ ZodDate.create = (params) => {
2123
2281
  });
2124
2282
  };
2125
2283
  var ZodSymbol = class extends ZodType {
2126
- _parse(input) {
2127
- const parsedType = this._getType(input);
2284
+ _parse(input2) {
2285
+ const parsedType = this._getType(input2);
2128
2286
  if (parsedType !== ZodParsedType.symbol) {
2129
- const ctx = this._getOrReturnCtx(input);
2287
+ const ctx = this._getOrReturnCtx(input2);
2130
2288
  addIssueToContext(ctx, {
2131
2289
  code: ZodIssueCode.invalid_type,
2132
2290
  expected: ZodParsedType.symbol,
@@ -2134,7 +2292,7 @@ var ZodSymbol = class extends ZodType {
2134
2292
  });
2135
2293
  return INVALID;
2136
2294
  }
2137
- return OK(input.data);
2295
+ return OK(input2.data);
2138
2296
  }
2139
2297
  };
2140
2298
  ZodSymbol.create = (params) => {
@@ -2144,10 +2302,10 @@ ZodSymbol.create = (params) => {
2144
2302
  });
2145
2303
  };
2146
2304
  var ZodUndefined = class extends ZodType {
2147
- _parse(input) {
2148
- const parsedType = this._getType(input);
2305
+ _parse(input2) {
2306
+ const parsedType = this._getType(input2);
2149
2307
  if (parsedType !== ZodParsedType.undefined) {
2150
- const ctx = this._getOrReturnCtx(input);
2308
+ const ctx = this._getOrReturnCtx(input2);
2151
2309
  addIssueToContext(ctx, {
2152
2310
  code: ZodIssueCode.invalid_type,
2153
2311
  expected: ZodParsedType.undefined,
@@ -2155,7 +2313,7 @@ var ZodUndefined = class extends ZodType {
2155
2313
  });
2156
2314
  return INVALID;
2157
2315
  }
2158
- return OK(input.data);
2316
+ return OK(input2.data);
2159
2317
  }
2160
2318
  };
2161
2319
  ZodUndefined.create = (params) => {
@@ -2165,10 +2323,10 @@ ZodUndefined.create = (params) => {
2165
2323
  });
2166
2324
  };
2167
2325
  var ZodNull = class extends ZodType {
2168
- _parse(input) {
2169
- const parsedType = this._getType(input);
2326
+ _parse(input2) {
2327
+ const parsedType = this._getType(input2);
2170
2328
  if (parsedType !== ZodParsedType.null) {
2171
- const ctx = this._getOrReturnCtx(input);
2329
+ const ctx = this._getOrReturnCtx(input2);
2172
2330
  addIssueToContext(ctx, {
2173
2331
  code: ZodIssueCode.invalid_type,
2174
2332
  expected: ZodParsedType.null,
@@ -2176,7 +2334,7 @@ var ZodNull = class extends ZodType {
2176
2334
  });
2177
2335
  return INVALID;
2178
2336
  }
2179
- return OK(input.data);
2337
+ return OK(input2.data);
2180
2338
  }
2181
2339
  };
2182
2340
  ZodNull.create = (params) => {
@@ -2190,8 +2348,8 @@ var ZodAny = class extends ZodType {
2190
2348
  super(...arguments);
2191
2349
  this._any = true;
2192
2350
  }
2193
- _parse(input) {
2194
- return OK(input.data);
2351
+ _parse(input2) {
2352
+ return OK(input2.data);
2195
2353
  }
2196
2354
  };
2197
2355
  ZodAny.create = (params) => {
@@ -2205,8 +2363,8 @@ var ZodUnknown = class extends ZodType {
2205
2363
  super(...arguments);
2206
2364
  this._unknown = true;
2207
2365
  }
2208
- _parse(input) {
2209
- return OK(input.data);
2366
+ _parse(input2) {
2367
+ return OK(input2.data);
2210
2368
  }
2211
2369
  };
2212
2370
  ZodUnknown.create = (params) => {
@@ -2216,8 +2374,8 @@ ZodUnknown.create = (params) => {
2216
2374
  });
2217
2375
  };
2218
2376
  var ZodNever = class extends ZodType {
2219
- _parse(input) {
2220
- const ctx = this._getOrReturnCtx(input);
2377
+ _parse(input2) {
2378
+ const ctx = this._getOrReturnCtx(input2);
2221
2379
  addIssueToContext(ctx, {
2222
2380
  code: ZodIssueCode.invalid_type,
2223
2381
  expected: ZodParsedType.never,
@@ -2233,10 +2391,10 @@ ZodNever.create = (params) => {
2233
2391
  });
2234
2392
  };
2235
2393
  var ZodVoid = class extends ZodType {
2236
- _parse(input) {
2237
- const parsedType = this._getType(input);
2394
+ _parse(input2) {
2395
+ const parsedType = this._getType(input2);
2238
2396
  if (parsedType !== ZodParsedType.undefined) {
2239
- const ctx = this._getOrReturnCtx(input);
2397
+ const ctx = this._getOrReturnCtx(input2);
2240
2398
  addIssueToContext(ctx, {
2241
2399
  code: ZodIssueCode.invalid_type,
2242
2400
  expected: ZodParsedType.void,
@@ -2244,7 +2402,7 @@ var ZodVoid = class extends ZodType {
2244
2402
  });
2245
2403
  return INVALID;
2246
2404
  }
2247
- return OK(input.data);
2405
+ return OK(input2.data);
2248
2406
  }
2249
2407
  };
2250
2408
  ZodVoid.create = (params) => {
@@ -2254,8 +2412,8 @@ ZodVoid.create = (params) => {
2254
2412
  });
2255
2413
  };
2256
2414
  var ZodArray = class _ZodArray extends ZodType {
2257
- _parse(input) {
2258
- const { ctx, status } = this._processInputParams(input);
2415
+ _parse(input2) {
2416
+ const { ctx, status } = this._processInputParams(input2);
2259
2417
  const def = this._def;
2260
2418
  if (ctx.parsedType !== ZodParsedType.array) {
2261
2419
  addIssueToContext(ctx, {
@@ -2395,10 +2553,10 @@ var ZodObject = class _ZodObject extends ZodType {
2395
2553
  this._cached = { shape, keys };
2396
2554
  return this._cached;
2397
2555
  }
2398
- _parse(input) {
2399
- const parsedType = this._getType(input);
2556
+ _parse(input2) {
2557
+ const parsedType = this._getType(input2);
2400
2558
  if (parsedType !== ZodParsedType.object) {
2401
- const ctx2 = this._getOrReturnCtx(input);
2559
+ const ctx2 = this._getOrReturnCtx(input2);
2402
2560
  addIssueToContext(ctx2, {
2403
2561
  code: ZodIssueCode.invalid_type,
2404
2562
  expected: ZodParsedType.object,
@@ -2406,7 +2564,7 @@ var ZodObject = class _ZodObject extends ZodType {
2406
2564
  });
2407
2565
  return INVALID;
2408
2566
  }
2409
- const { status, ctx } = this._processInputParams(input);
2567
+ const { status, ctx } = this._processInputParams(input2);
2410
2568
  const { shape, keys: shapeKeys } = this._getCached();
2411
2569
  const extraKeys = [];
2412
2570
  if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
@@ -2718,8 +2876,8 @@ ZodObject.lazycreate = (shape, params) => {
2718
2876
  });
2719
2877
  };
2720
2878
  var ZodUnion = class extends ZodType {
2721
- _parse(input) {
2722
- const { ctx } = this._processInputParams(input);
2879
+ _parse(input2) {
2880
+ const { ctx } = this._processInputParams(input2);
2723
2881
  const options = this._def.options;
2724
2882
  function handleResults(results) {
2725
2883
  for (const result of results) {
@@ -2840,8 +2998,8 @@ var getDiscriminator = (type) => {
2840
2998
  }
2841
2999
  };
2842
3000
  var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
2843
- _parse(input) {
2844
- const { ctx } = this._processInputParams(input);
3001
+ _parse(input2) {
3002
+ const { ctx } = this._processInputParams(input2);
2845
3003
  if (ctx.parsedType !== ZodParsedType.object) {
2846
3004
  addIssueToContext(ctx, {
2847
3005
  code: ZodIssueCode.invalid_type,
@@ -2954,8 +3112,8 @@ function mergeValues(a, b) {
2954
3112
  }
2955
3113
  }
2956
3114
  var ZodIntersection = class extends ZodType {
2957
- _parse(input) {
2958
- const { status, ctx } = this._processInputParams(input);
3115
+ _parse(input2) {
3116
+ const { status, ctx } = this._processInputParams(input2);
2959
3117
  const handleParsed = (parsedLeft, parsedRight) => {
2960
3118
  if (isAborted(parsedLeft) || isAborted(parsedRight)) {
2961
3119
  return INVALID;
@@ -3007,8 +3165,8 @@ ZodIntersection.create = (left, right, params) => {
3007
3165
  });
3008
3166
  };
3009
3167
  var ZodTuple = class _ZodTuple extends ZodType {
3010
- _parse(input) {
3011
- const { status, ctx } = this._processInputParams(input);
3168
+ _parse(input2) {
3169
+ const { status, ctx } = this._processInputParams(input2);
3012
3170
  if (ctx.parsedType !== ZodParsedType.array) {
3013
3171
  addIssueToContext(ctx, {
3014
3172
  code: ZodIssueCode.invalid_type,
@@ -3043,7 +3201,7 @@ var ZodTuple = class _ZodTuple extends ZodType {
3043
3201
  if (!schema)
3044
3202
  return null;
3045
3203
  return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
3046
- }).filter((x) => !!x);
3204
+ }).filter((x3) => !!x3);
3047
3205
  if (ctx.common.async) {
3048
3206
  return Promise.all(items).then((results) => {
3049
3207
  return ParseStatus.mergeArray(status, results);
@@ -3080,8 +3238,8 @@ var ZodRecord = class _ZodRecord extends ZodType {
3080
3238
  get valueSchema() {
3081
3239
  return this._def.valueType;
3082
3240
  }
3083
- _parse(input) {
3084
- const { status, ctx } = this._processInputParams(input);
3241
+ _parse(input2) {
3242
+ const { status, ctx } = this._processInputParams(input2);
3085
3243
  if (ctx.parsedType !== ZodParsedType.object) {
3086
3244
  addIssueToContext(ctx, {
3087
3245
  code: ZodIssueCode.invalid_type,
@@ -3133,8 +3291,8 @@ var ZodMap = class extends ZodType {
3133
3291
  get valueSchema() {
3134
3292
  return this._def.valueType;
3135
3293
  }
3136
- _parse(input) {
3137
- const { status, ctx } = this._processInputParams(input);
3294
+ _parse(input2) {
3295
+ const { status, ctx } = this._processInputParams(input2);
3138
3296
  if (ctx.parsedType !== ZodParsedType.map) {
3139
3297
  addIssueToContext(ctx, {
3140
3298
  code: ZodIssueCode.invalid_type,
@@ -3193,8 +3351,8 @@ ZodMap.create = (keyType, valueType, params) => {
3193
3351
  });
3194
3352
  };
3195
3353
  var ZodSet = class _ZodSet extends ZodType {
3196
- _parse(input) {
3197
- const { status, ctx } = this._processInputParams(input);
3354
+ _parse(input2) {
3355
+ const { status, ctx } = this._processInputParams(input2);
3198
3356
  if (ctx.parsedType !== ZodParsedType.set) {
3199
3357
  addIssueToContext(ctx, {
3200
3358
  code: ZodIssueCode.invalid_type,
@@ -3282,8 +3440,8 @@ var ZodFunction = class _ZodFunction extends ZodType {
3282
3440
  super(...arguments);
3283
3441
  this.validate = this.implement;
3284
3442
  }
3285
- _parse(input) {
3286
- const { ctx } = this._processInputParams(input);
3443
+ _parse(input2) {
3444
+ const { ctx } = this._processInputParams(input2);
3287
3445
  if (ctx.parsedType !== ZodParsedType.function) {
3288
3446
  addIssueToContext(ctx, {
3289
3447
  code: ZodIssueCode.invalid_type,
@@ -3296,7 +3454,7 @@ var ZodFunction = class _ZodFunction extends ZodType {
3296
3454
  return makeIssue({
3297
3455
  data: args,
3298
3456
  path: ctx.path,
3299
- errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
3457
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x3) => !!x3),
3300
3458
  issueData: {
3301
3459
  code: ZodIssueCode.invalid_arguments,
3302
3460
  argumentsError: error
@@ -3307,7 +3465,7 @@ var ZodFunction = class _ZodFunction extends ZodType {
3307
3465
  return makeIssue({
3308
3466
  data: returns,
3309
3467
  path: ctx.path,
3310
- errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
3468
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x3) => !!x3),
3311
3469
  issueData: {
3312
3470
  code: ZodIssueCode.invalid_return_type,
3313
3471
  returnTypeError: error
@@ -3317,29 +3475,29 @@ var ZodFunction = class _ZodFunction extends ZodType {
3317
3475
  const params = { errorMap: ctx.common.contextualErrorMap };
3318
3476
  const fn = ctx.data;
3319
3477
  if (this._def.returns instanceof ZodPromise) {
3320
- const me = this;
3478
+ const me2 = this;
3321
3479
  return OK(async function(...args) {
3322
3480
  const error = new ZodError([]);
3323
- const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
3324
- error.addIssue(makeArgsIssue(args, e));
3481
+ const parsedArgs = await me2._def.args.parseAsync(args, params).catch((e2) => {
3482
+ error.addIssue(makeArgsIssue(args, e2));
3325
3483
  throw error;
3326
3484
  });
3327
3485
  const result = await Reflect.apply(fn, this, parsedArgs);
3328
- const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
3329
- error.addIssue(makeReturnsIssue(result, e));
3486
+ const parsedReturns = await me2._def.returns._def.type.parseAsync(result, params).catch((e2) => {
3487
+ error.addIssue(makeReturnsIssue(result, e2));
3330
3488
  throw error;
3331
3489
  });
3332
3490
  return parsedReturns;
3333
3491
  });
3334
3492
  } else {
3335
- const me = this;
3493
+ const me2 = this;
3336
3494
  return OK(function(...args) {
3337
- const parsedArgs = me._def.args.safeParse(args, params);
3495
+ const parsedArgs = me2._def.args.safeParse(args, params);
3338
3496
  if (!parsedArgs.success) {
3339
3497
  throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
3340
3498
  }
3341
3499
  const result = Reflect.apply(fn, this, parsedArgs.data);
3342
- const parsedReturns = me._def.returns.safeParse(result, params);
3500
+ const parsedReturns = me2._def.returns.safeParse(result, params);
3343
3501
  if (!parsedReturns.success) {
3344
3502
  throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
3345
3503
  }
@@ -3386,8 +3544,8 @@ var ZodLazy = class extends ZodType {
3386
3544
  get schema() {
3387
3545
  return this._def.getter();
3388
3546
  }
3389
- _parse(input) {
3390
- const { ctx } = this._processInputParams(input);
3547
+ _parse(input2) {
3548
+ const { ctx } = this._processInputParams(input2);
3391
3549
  const lazySchema = this._def.getter();
3392
3550
  return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
3393
3551
  }
@@ -3400,9 +3558,9 @@ ZodLazy.create = (getter, params) => {
3400
3558
  });
3401
3559
  };
3402
3560
  var ZodLiteral = class extends ZodType {
3403
- _parse(input) {
3404
- if (input.data !== this._def.value) {
3405
- const ctx = this._getOrReturnCtx(input);
3561
+ _parse(input2) {
3562
+ if (input2.data !== this._def.value) {
3563
+ const ctx = this._getOrReturnCtx(input2);
3406
3564
  addIssueToContext(ctx, {
3407
3565
  received: ctx.data,
3408
3566
  code: ZodIssueCode.invalid_literal,
@@ -3410,7 +3568,7 @@ var ZodLiteral = class extends ZodType {
3410
3568
  });
3411
3569
  return INVALID;
3412
3570
  }
3413
- return { status: "valid", value: input.data };
3571
+ return { status: "valid", value: input2.data };
3414
3572
  }
3415
3573
  get value() {
3416
3574
  return this._def.value;
@@ -3431,9 +3589,9 @@ function createZodEnum(values, params) {
3431
3589
  });
3432
3590
  }
3433
3591
  var ZodEnum = class _ZodEnum extends ZodType {
3434
- _parse(input) {
3435
- if (typeof input.data !== "string") {
3436
- const ctx = this._getOrReturnCtx(input);
3592
+ _parse(input2) {
3593
+ if (typeof input2.data !== "string") {
3594
+ const ctx = this._getOrReturnCtx(input2);
3437
3595
  const expectedValues = this._def.values;
3438
3596
  addIssueToContext(ctx, {
3439
3597
  expected: util.joinValues(expectedValues),
@@ -3445,8 +3603,8 @@ var ZodEnum = class _ZodEnum extends ZodType {
3445
3603
  if (!this._cache) {
3446
3604
  this._cache = new Set(this._def.values);
3447
3605
  }
3448
- if (!this._cache.has(input.data)) {
3449
- const ctx = this._getOrReturnCtx(input);
3606
+ if (!this._cache.has(input2.data)) {
3607
+ const ctx = this._getOrReturnCtx(input2);
3450
3608
  const expectedValues = this._def.values;
3451
3609
  addIssueToContext(ctx, {
3452
3610
  received: ctx.data,
@@ -3455,7 +3613,7 @@ var ZodEnum = class _ZodEnum extends ZodType {
3455
3613
  });
3456
3614
  return INVALID;
3457
3615
  }
3458
- return OK(input.data);
3616
+ return OK(input2.data);
3459
3617
  }
3460
3618
  get options() {
3461
3619
  return this._def.values;
@@ -3496,9 +3654,9 @@ var ZodEnum = class _ZodEnum extends ZodType {
3496
3654
  };
3497
3655
  ZodEnum.create = createZodEnum;
3498
3656
  var ZodNativeEnum = class extends ZodType {
3499
- _parse(input) {
3657
+ _parse(input2) {
3500
3658
  const nativeEnumValues = util.getValidEnumValues(this._def.values);
3501
- const ctx = this._getOrReturnCtx(input);
3659
+ const ctx = this._getOrReturnCtx(input2);
3502
3660
  if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
3503
3661
  const expectedValues = util.objectValues(nativeEnumValues);
3504
3662
  addIssueToContext(ctx, {
@@ -3511,7 +3669,7 @@ var ZodNativeEnum = class extends ZodType {
3511
3669
  if (!this._cache) {
3512
3670
  this._cache = new Set(util.getValidEnumValues(this._def.values));
3513
3671
  }
3514
- if (!this._cache.has(input.data)) {
3672
+ if (!this._cache.has(input2.data)) {
3515
3673
  const expectedValues = util.objectValues(nativeEnumValues);
3516
3674
  addIssueToContext(ctx, {
3517
3675
  received: ctx.data,
@@ -3520,7 +3678,7 @@ var ZodNativeEnum = class extends ZodType {
3520
3678
  });
3521
3679
  return INVALID;
3522
3680
  }
3523
- return OK(input.data);
3681
+ return OK(input2.data);
3524
3682
  }
3525
3683
  get enum() {
3526
3684
  return this._def.values;
@@ -3537,8 +3695,8 @@ var ZodPromise = class extends ZodType {
3537
3695
  unwrap() {
3538
3696
  return this._def.type;
3539
3697
  }
3540
- _parse(input) {
3541
- const { ctx } = this._processInputParams(input);
3698
+ _parse(input2) {
3699
+ const { ctx } = this._processInputParams(input2);
3542
3700
  if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
3543
3701
  addIssueToContext(ctx, {
3544
3702
  code: ZodIssueCode.invalid_type,
@@ -3570,8 +3728,8 @@ var ZodEffects = class extends ZodType {
3570
3728
  sourceType() {
3571
3729
  return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3572
3730
  }
3573
- _parse(input) {
3574
- const { status, ctx } = this._processInputParams(input);
3731
+ _parse(input2) {
3732
+ const { status, ctx } = this._processInputParams(input2);
3575
3733
  const effect = this._def.effect || null;
3576
3734
  const checkCtx = {
3577
3735
  addIssue: (arg) => {
@@ -3703,12 +3861,12 @@ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
3703
3861
  });
3704
3862
  };
3705
3863
  var ZodOptional = class extends ZodType {
3706
- _parse(input) {
3707
- const parsedType = this._getType(input);
3864
+ _parse(input2) {
3865
+ const parsedType = this._getType(input2);
3708
3866
  if (parsedType === ZodParsedType.undefined) {
3709
3867
  return OK(void 0);
3710
3868
  }
3711
- return this._def.innerType._parse(input);
3869
+ return this._def.innerType._parse(input2);
3712
3870
  }
3713
3871
  unwrap() {
3714
3872
  return this._def.innerType;
@@ -3722,12 +3880,12 @@ ZodOptional.create = (type, params) => {
3722
3880
  });
3723
3881
  };
3724
3882
  var ZodNullable = class extends ZodType {
3725
- _parse(input) {
3726
- const parsedType = this._getType(input);
3883
+ _parse(input2) {
3884
+ const parsedType = this._getType(input2);
3727
3885
  if (parsedType === ZodParsedType.null) {
3728
3886
  return OK(null);
3729
3887
  }
3730
- return this._def.innerType._parse(input);
3888
+ return this._def.innerType._parse(input2);
3731
3889
  }
3732
3890
  unwrap() {
3733
3891
  return this._def.innerType;
@@ -3741,8 +3899,8 @@ ZodNullable.create = (type, params) => {
3741
3899
  });
3742
3900
  };
3743
3901
  var ZodDefault = class extends ZodType {
3744
- _parse(input) {
3745
- const { ctx } = this._processInputParams(input);
3902
+ _parse(input2) {
3903
+ const { ctx } = this._processInputParams(input2);
3746
3904
  let data = ctx.data;
3747
3905
  if (ctx.parsedType === ZodParsedType.undefined) {
3748
3906
  data = this._def.defaultValue();
@@ -3766,8 +3924,8 @@ ZodDefault.create = (type, params) => {
3766
3924
  });
3767
3925
  };
3768
3926
  var ZodCatch = class extends ZodType {
3769
- _parse(input) {
3770
- const { ctx } = this._processInputParams(input);
3927
+ _parse(input2) {
3928
+ const { ctx } = this._processInputParams(input2);
3771
3929
  const newCtx = {
3772
3930
  ...ctx,
3773
3931
  common: {
@@ -3819,10 +3977,10 @@ ZodCatch.create = (type, params) => {
3819
3977
  });
3820
3978
  };
3821
3979
  var ZodNaN = class extends ZodType {
3822
- _parse(input) {
3823
- const parsedType = this._getType(input);
3980
+ _parse(input2) {
3981
+ const parsedType = this._getType(input2);
3824
3982
  if (parsedType !== ZodParsedType.nan) {
3825
- const ctx = this._getOrReturnCtx(input);
3983
+ const ctx = this._getOrReturnCtx(input2);
3826
3984
  addIssueToContext(ctx, {
3827
3985
  code: ZodIssueCode.invalid_type,
3828
3986
  expected: ZodParsedType.nan,
@@ -3830,7 +3988,7 @@ var ZodNaN = class extends ZodType {
3830
3988
  });
3831
3989
  return INVALID;
3832
3990
  }
3833
- return { status: "valid", value: input.data };
3991
+ return { status: "valid", value: input2.data };
3834
3992
  }
3835
3993
  };
3836
3994
  ZodNaN.create = (params) => {
@@ -3841,8 +3999,8 @@ ZodNaN.create = (params) => {
3841
3999
  };
3842
4000
  var BRAND = /* @__PURE__ */ Symbol("zod_brand");
3843
4001
  var ZodBranded = class extends ZodType {
3844
- _parse(input) {
3845
- const { ctx } = this._processInputParams(input);
4002
+ _parse(input2) {
4003
+ const { ctx } = this._processInputParams(input2);
3846
4004
  const data = ctx.data;
3847
4005
  return this._def.type._parse({
3848
4006
  data,
@@ -3855,8 +4013,8 @@ var ZodBranded = class extends ZodType {
3855
4013
  }
3856
4014
  };
3857
4015
  var ZodPipeline = class _ZodPipeline extends ZodType {
3858
- _parse(input) {
3859
- const { status, ctx } = this._processInputParams(input);
4016
+ _parse(input2) {
4017
+ const { status, ctx } = this._processInputParams(input2);
3860
4018
  if (ctx.common.async) {
3861
4019
  const handleAsync = async () => {
3862
4020
  const inResult = await this._def.in._parseAsync({
@@ -3910,8 +4068,8 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
3910
4068
  }
3911
4069
  };
3912
4070
  var ZodReadonly = class extends ZodType {
3913
- _parse(input) {
3914
- const result = this._def.innerType._parse(input);
4071
+ _parse(input2) {
4072
+ const result = this._def.innerType._parse(input2);
3915
4073
  const freeze = (data) => {
3916
4074
  if (isValid(data)) {
3917
4075
  data.value = Object.freeze(data.value);
@@ -4504,7 +4662,7 @@ function extractMediaFromText(text, options = {}) {
4504
4662
  const {
4505
4663
  removeFromText = true,
4506
4664
  checkExists = false,
4507
- existsSync: existsSync4,
4665
+ existsSync: existsSync5,
4508
4666
  parseMediaLines = false,
4509
4667
  parseMarkdownImages = true,
4510
4668
  parseHtmlImages = true,
@@ -4519,7 +4677,7 @@ function extractMediaFromText(text, options = {}) {
4519
4677
  const key = media.localPath || media.source;
4520
4678
  if (seenSources.has(key)) return false;
4521
4679
  if (checkExists && media.isLocal && media.localPath) {
4522
- const exists = existsSync4 ? existsSync4(media.localPath) : fs3.existsSync(media.localPath);
4680
+ const exists = existsSync5 ? existsSync5(media.localPath) : fs3.existsSync(media.localPath);
4523
4681
  if (!exists) return false;
4524
4682
  }
4525
4683
  seenSources.add(key);
@@ -5259,6 +5417,1381 @@ async function transcribeTencentFlash(params) {
5259
5417
  }
5260
5418
  }
5261
5419
 
5420
+ // ../../node_modules/.pnpm/@clack+core@1.0.1/node_modules/@clack/core/dist/index.mjs
5421
+ var import_picocolors = __toESM(require_picocolors());
5422
+ var import_sisteransi = __toESM(require_src());
5423
+ function B(t, e2, s) {
5424
+ if (!s.some((u) => !u.disabled)) return t;
5425
+ const i = t + e2, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
5426
+ return s[n].disabled ? B(n, e2 < 0 ? -1 : 1, s) : n;
5427
+ }
5428
+ var at = (t) => t === 161 || t === 164 || t === 167 || t === 168 || t === 170 || t === 173 || t === 174 || t >= 176 && t <= 180 || t >= 182 && t <= 186 || t >= 188 && t <= 191 || t === 198 || t === 208 || t === 215 || t === 216 || t >= 222 && t <= 225 || t === 230 || t >= 232 && t <= 234 || t === 236 || t === 237 || t === 240 || t === 242 || t === 243 || t >= 247 && t <= 250 || t === 252 || t === 254 || t === 257 || t === 273 || t === 275 || t === 283 || t === 294 || t === 295 || t === 299 || t >= 305 && t <= 307 || t === 312 || t >= 319 && t <= 322 || t === 324 || t >= 328 && t <= 331 || t === 333 || t === 338 || t === 339 || t === 358 || t === 359 || t === 363 || t === 462 || t === 464 || t === 466 || t === 468 || t === 470 || t === 472 || t === 474 || t === 476 || t === 593 || t === 609 || t === 708 || t === 711 || t >= 713 && t <= 715 || t === 717 || t === 720 || t >= 728 && t <= 731 || t === 733 || t === 735 || t >= 768 && t <= 879 || t >= 913 && t <= 929 || t >= 931 && t <= 937 || t >= 945 && t <= 961 || t >= 963 && t <= 969 || t === 1025 || t >= 1040 && t <= 1103 || t === 1105 || t === 8208 || t >= 8211 && t <= 8214 || t === 8216 || t === 8217 || t === 8220 || t === 8221 || t >= 8224 && t <= 8226 || t >= 8228 && t <= 8231 || t === 8240 || t === 8242 || t === 8243 || t === 8245 || t === 8251 || t === 8254 || t === 8308 || t === 8319 || t >= 8321 && t <= 8324 || t === 8364 || t === 8451 || t === 8453 || t === 8457 || t === 8467 || t === 8470 || t === 8481 || t === 8482 || t === 8486 || t === 8491 || t === 8531 || t === 8532 || t >= 8539 && t <= 8542 || t >= 8544 && t <= 8555 || t >= 8560 && t <= 8569 || t === 8585 || t >= 8592 && t <= 8601 || t === 8632 || t === 8633 || t === 8658 || t === 8660 || t === 8679 || t === 8704 || t === 8706 || t === 8707 || t === 8711 || t === 8712 || t === 8715 || t === 8719 || t === 8721 || t === 8725 || t === 8730 || t >= 8733 && t <= 8736 || t === 8739 || t === 8741 || t >= 8743 && t <= 8748 || t === 8750 || t >= 8756 && t <= 8759 || t === 8764 || t === 8765 || t === 8776 || t === 8780 || t === 8786 || t === 8800 || t === 8801 || t >= 8804 && t <= 8807 || t === 8810 || t === 8811 || t === 8814 || t === 8815 || t === 8834 || t === 8835 || t === 8838 || t === 8839 || t === 8853 || t === 8857 || t === 8869 || t === 8895 || t === 8978 || t >= 9312 && t <= 9449 || t >= 9451 && t <= 9547 || t >= 9552 && t <= 9587 || t >= 9600 && t <= 9615 || t >= 9618 && t <= 9621 || t === 9632 || t === 9633 || t >= 9635 && t <= 9641 || t === 9650 || t === 9651 || t === 9654 || t === 9655 || t === 9660 || t === 9661 || t === 9664 || t === 9665 || t >= 9670 && t <= 9672 || t === 9675 || t >= 9678 && t <= 9681 || t >= 9698 && t <= 9701 || t === 9711 || t === 9733 || t === 9734 || t === 9737 || t === 9742 || t === 9743 || t === 9756 || t === 9758 || t === 9792 || t === 9794 || t === 9824 || t === 9825 || t >= 9827 && t <= 9829 || t >= 9831 && t <= 9834 || t === 9836 || t === 9837 || t === 9839 || t === 9886 || t === 9887 || t === 9919 || t >= 9926 && t <= 9933 || t >= 9935 && t <= 9939 || t >= 9941 && t <= 9953 || t === 9955 || t === 9960 || t === 9961 || t >= 9963 && t <= 9969 || t === 9972 || t >= 9974 && t <= 9977 || t === 9979 || t === 9980 || t === 9982 || t === 9983 || t === 10045 || t >= 10102 && t <= 10111 || t >= 11094 && t <= 11097 || t >= 12872 && t <= 12879 || t >= 57344 && t <= 63743 || t >= 65024 && t <= 65039 || t === 65533 || t >= 127232 && t <= 127242 || t >= 127248 && t <= 127277 || t >= 127280 && t <= 127337 || t >= 127344 && t <= 127373 || t === 127375 || t === 127376 || t >= 127387 && t <= 127404 || t >= 917760 && t <= 917999 || t >= 983040 && t <= 1048573 || t >= 1048576 && t <= 1114109;
5429
+ var lt = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510;
5430
+ var ht = (t) => t >= 4352 && t <= 4447 || t === 8986 || t === 8987 || t === 9001 || t === 9002 || t >= 9193 && t <= 9196 || t === 9200 || t === 9203 || t === 9725 || t === 9726 || t === 9748 || t === 9749 || t >= 9800 && t <= 9811 || t === 9855 || t === 9875 || t === 9889 || t === 9898 || t === 9899 || t === 9917 || t === 9918 || t === 9924 || t === 9925 || t === 9934 || t === 9940 || t === 9962 || t === 9970 || t === 9971 || t === 9973 || t === 9978 || t === 9981 || t === 9989 || t === 9994 || t === 9995 || t === 10024 || t === 10060 || t === 10062 || t >= 10067 && t <= 10069 || t === 10071 || t >= 10133 && t <= 10135 || t === 10160 || t === 10175 || t === 11035 || t === 11036 || t === 11088 || t === 11093 || t >= 11904 && t <= 11929 || t >= 11931 && t <= 12019 || t >= 12032 && t <= 12245 || t >= 12272 && t <= 12287 || t >= 12289 && t <= 12350 || t >= 12353 && t <= 12438 || t >= 12441 && t <= 12543 || t >= 12549 && t <= 12591 || t >= 12593 && t <= 12686 || t >= 12688 && t <= 12771 || t >= 12783 && t <= 12830 || t >= 12832 && t <= 12871 || t >= 12880 && t <= 19903 || t >= 19968 && t <= 42124 || t >= 42128 && t <= 42182 || t >= 43360 && t <= 43388 || t >= 44032 && t <= 55203 || t >= 63744 && t <= 64255 || t >= 65040 && t <= 65049 || t >= 65072 && t <= 65106 || t >= 65108 && t <= 65126 || t >= 65128 && t <= 65131 || t >= 94176 && t <= 94180 || t === 94192 || t === 94193 || t >= 94208 && t <= 100343 || t >= 100352 && t <= 101589 || t >= 101632 && t <= 101640 || t >= 110576 && t <= 110579 || t >= 110581 && t <= 110587 || t === 110589 || t === 110590 || t >= 110592 && t <= 110882 || t === 110898 || t >= 110928 && t <= 110930 || t === 110933 || t >= 110948 && t <= 110951 || t >= 110960 && t <= 111355 || t === 126980 || t === 127183 || t === 127374 || t >= 127377 && t <= 127386 || t >= 127488 && t <= 127490 || t >= 127504 && t <= 127547 || t >= 127552 && t <= 127560 || t === 127568 || t === 127569 || t >= 127584 && t <= 127589 || t >= 127744 && t <= 127776 || t >= 127789 && t <= 127797 || t >= 127799 && t <= 127868 || t >= 127870 && t <= 127891 || t >= 127904 && t <= 127946 || t >= 127951 && t <= 127955 || t >= 127968 && t <= 127984 || t === 127988 || t >= 127992 && t <= 128062 || t === 128064 || t >= 128066 && t <= 128252 || t >= 128255 && t <= 128317 || t >= 128331 && t <= 128334 || t >= 128336 && t <= 128359 || t === 128378 || t === 128405 || t === 128406 || t === 128420 || t >= 128507 && t <= 128591 || t >= 128640 && t <= 128709 || t === 128716 || t >= 128720 && t <= 128722 || t >= 128725 && t <= 128727 || t >= 128732 && t <= 128735 || t === 128747 || t === 128748 || t >= 128756 && t <= 128764 || t >= 128992 && t <= 129003 || t === 129008 || t >= 129292 && t <= 129338 || t >= 129340 && t <= 129349 || t >= 129351 && t <= 129535 || t >= 129648 && t <= 129660 || t >= 129664 && t <= 129672 || t >= 129680 && t <= 129725 || t >= 129727 && t <= 129733 || t >= 129742 && t <= 129755 || t >= 129760 && t <= 129768 || t >= 129776 && t <= 129784 || t >= 131072 && t <= 196605 || t >= 196608 && t <= 262141;
5431
+ var O = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
5432
+ var y = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
5433
+ var L = /\t{1,1000}/y;
5434
+ var P = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
5435
+ var M = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
5436
+ var ct = /\p{M}+/gu;
5437
+ var ft = { limit: 1 / 0, ellipsis: "" };
5438
+ var X = (t, e2 = {}, s = {}) => {
5439
+ const i = e2.limit ?? 1 / 0, r = e2.ellipsis ?? "", n = e2?.ellipsisWidth ?? (r ? X(r, ft, s).width : 0), u = s.ansiWidth ?? 0, a = s.controlWidth ?? 0, l = s.tabWidth ?? 8, E = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, m = s.fullWidthWidth ?? 2, A = s.regularWidth ?? 1, V2 = s.wideWidth ?? 2;
5440
+ let h = 0, o = 0, p = t.length, v = 0, F = false, d2 = p, b = Math.max(0, i - n), C2 = 0, w = 0, c = 0, f = 0;
5441
+ t: for (; ; ) {
5442
+ if (w > C2 || o >= p && o > h) {
5443
+ const ut2 = t.slice(C2, w) || t.slice(h, o);
5444
+ v = 0;
5445
+ for (const Y of ut2.replaceAll(ct, "")) {
5446
+ const $ = Y.codePointAt(0) || 0;
5447
+ if (lt($) ? f = m : ht($) ? f = V2 : E !== A && at($) ? f = E : f = A, c + f > b && (d2 = Math.min(d2, Math.max(C2, h) + v)), c + f > i) {
5448
+ F = true;
5449
+ break t;
5450
+ }
5451
+ v += Y.length, c += f;
5452
+ }
5453
+ C2 = w = 0;
5454
+ }
5455
+ if (o >= p) break;
5456
+ if (M.lastIndex = o, M.test(t)) {
5457
+ if (v = M.lastIndex - o, f = v * A, c + f > b && (d2 = Math.min(d2, o + Math.floor((b - c) / A))), c + f > i) {
5458
+ F = true;
5459
+ break;
5460
+ }
5461
+ c += f, C2 = h, w = o, o = h = M.lastIndex;
5462
+ continue;
5463
+ }
5464
+ if (O.lastIndex = o, O.test(t)) {
5465
+ if (c + u > b && (d2 = Math.min(d2, o)), c + u > i) {
5466
+ F = true;
5467
+ break;
5468
+ }
5469
+ c += u, C2 = h, w = o, o = h = O.lastIndex;
5470
+ continue;
5471
+ }
5472
+ if (y.lastIndex = o, y.test(t)) {
5473
+ if (v = y.lastIndex - o, f = v * a, c + f > b && (d2 = Math.min(d2, o + Math.floor((b - c) / a))), c + f > i) {
5474
+ F = true;
5475
+ break;
5476
+ }
5477
+ c += f, C2 = h, w = o, o = h = y.lastIndex;
5478
+ continue;
5479
+ }
5480
+ if (L.lastIndex = o, L.test(t)) {
5481
+ if (v = L.lastIndex - o, f = v * l, c + f > b && (d2 = Math.min(d2, o + Math.floor((b - c) / l))), c + f > i) {
5482
+ F = true;
5483
+ break;
5484
+ }
5485
+ c += f, C2 = h, w = o, o = h = L.lastIndex;
5486
+ continue;
5487
+ }
5488
+ if (P.lastIndex = o, P.test(t)) {
5489
+ if (c + g > b && (d2 = Math.min(d2, o)), c + g > i) {
5490
+ F = true;
5491
+ break;
5492
+ }
5493
+ c += g, C2 = h, w = o, o = h = P.lastIndex;
5494
+ continue;
5495
+ }
5496
+ o += 1;
5497
+ }
5498
+ return { width: F ? b : c, index: F ? d2 : p, truncated: F, ellipsed: F && i >= n };
5499
+ };
5500
+ var pt = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
5501
+ var S = (t, e2 = {}) => X(t, pt, e2).width;
5502
+ var W = "\x1B";
5503
+ var Z = "\x9B";
5504
+ var Ft = 39;
5505
+ var j = "\x07";
5506
+ var Q = "[";
5507
+ var dt = "]";
5508
+ var tt = "m";
5509
+ var U = `${dt}8;;`;
5510
+ var et = new RegExp(`(?:\\${Q}(?<code>\\d+)m|\\${U}(?<uri>.*)${j})`, "y");
5511
+ var mt = (t) => {
5512
+ if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
5513
+ if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
5514
+ if (t === 1 || t === 2) return 22;
5515
+ if (t === 3) return 23;
5516
+ if (t === 4) return 24;
5517
+ if (t === 7) return 27;
5518
+ if (t === 8) return 28;
5519
+ if (t === 9) return 29;
5520
+ if (t === 0) return 0;
5521
+ };
5522
+ var st = (t) => `${W}${Q}${t}${tt}`;
5523
+ var it = (t) => `${W}${U}${t}${j}`;
5524
+ var gt = (t) => t.map((e2) => S(e2));
5525
+ var G = (t, e2, s) => {
5526
+ const i = e2[Symbol.iterator]();
5527
+ let r = false, n = false, u = t.at(-1), a = u === void 0 ? 0 : S(u), l = i.next(), E = i.next(), g = 0;
5528
+ for (; !l.done; ) {
5529
+ const m = l.value, A = S(m);
5530
+ a + A <= s ? t[t.length - 1] += m : (t.push(m), a = 0), (m === W || m === Z) && (r = true, n = e2.startsWith(U, g + 1)), r ? n ? m === j && (r = false, n = false) : m === tt && (r = false) : (a += A, a === s && !E.done && (t.push(""), a = 0)), l = E, E = i.next(), g += m.length;
5531
+ }
5532
+ u = t.at(-1), !a && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
5533
+ };
5534
+ var vt = (t) => {
5535
+ const e2 = t.split(" ");
5536
+ let s = e2.length;
5537
+ for (; s > 0 && !(S(e2[s - 1]) > 0); ) s--;
5538
+ return s === e2.length ? t : e2.slice(0, s).join(" ") + e2.slice(s).join("");
5539
+ };
5540
+ var Et = (t, e2, s = {}) => {
5541
+ if (s.trim !== false && t.trim() === "") return "";
5542
+ let i = "", r, n;
5543
+ const u = t.split(" "), a = gt(u);
5544
+ let l = [""];
5545
+ for (const [h, o] of u.entries()) {
5546
+ s.trim !== false && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
5547
+ let p = S(l.at(-1) ?? "");
5548
+ if (h !== 0 && (p >= e2 && (s.wordWrap === false || s.trim === false) && (l.push(""), p = 0), (p > 0 || s.trim === false) && (l[l.length - 1] += " ", p++)), s.hard && a[h] > e2) {
5549
+ const v = e2 - p, F = 1 + Math.floor((a[h] - v - 1) / e2);
5550
+ Math.floor((a[h] - 1) / e2) < F && l.push(""), G(l, o, e2);
5551
+ continue;
5552
+ }
5553
+ if (p + a[h] > e2 && p > 0 && a[h] > 0) {
5554
+ if (s.wordWrap === false && p < e2) {
5555
+ G(l, o, e2);
5556
+ continue;
5557
+ }
5558
+ l.push("");
5559
+ }
5560
+ if (p + a[h] > e2 && s.wordWrap === false) {
5561
+ G(l, o, e2);
5562
+ continue;
5563
+ }
5564
+ l[l.length - 1] += o;
5565
+ }
5566
+ s.trim !== false && (l = l.map((h) => vt(h)));
5567
+ const E = l.join(`
5568
+ `), g = E[Symbol.iterator]();
5569
+ let m = g.next(), A = g.next(), V2 = 0;
5570
+ for (; !m.done; ) {
5571
+ const h = m.value, o = A.value;
5572
+ if (i += h, h === W || h === Z) {
5573
+ et.lastIndex = V2 + 1;
5574
+ const F = et.exec(E)?.groups;
5575
+ if (F?.code !== void 0) {
5576
+ const d2 = Number.parseFloat(F.code);
5577
+ r = d2 === Ft ? void 0 : d2;
5578
+ } else F?.uri !== void 0 && (n = F.uri.length === 0 ? void 0 : F.uri);
5579
+ }
5580
+ const p = r ? mt(r) : void 0;
5581
+ o === `
5582
+ ` ? (n && (i += it("")), r && p && (i += st(p))) : h === `
5583
+ ` && (r && p && (i += st(r)), n && (i += it(n))), V2 += h.length, m = A, A = g.next();
5584
+ }
5585
+ return i;
5586
+ };
5587
+ function K(t, e2, s) {
5588
+ return String(t).normalize().replaceAll(`\r
5589
+ `, `
5590
+ `).split(`
5591
+ `).map((i) => Et(i, e2, s)).join(`
5592
+ `);
5593
+ }
5594
+ var At = ["up", "down", "left", "right", "space", "enter", "cancel"];
5595
+ var _ = { actions: new Set(At), aliases: /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["", "cancel"], ["escape", "cancel"]]), withGuide: true };
5596
+ function H(t, e2) {
5597
+ if (typeof t == "string") return _.aliases.get(t) === e2;
5598
+ for (const s of t) if (s !== void 0 && H(s, e2)) return true;
5599
+ return false;
5600
+ }
5601
+ function _t(t, e2) {
5602
+ if (t === e2) return;
5603
+ const s = t.split(`
5604
+ `), i = e2.split(`
5605
+ `), r = Math.max(s.length, i.length), n = [];
5606
+ for (let u = 0; u < r; u++) s[u] !== i[u] && n.push(u);
5607
+ return { lines: n, numLinesBefore: s.length, numLinesAfter: i.length, numLines: r };
5608
+ }
5609
+ globalThis.process.platform.startsWith("win");
5610
+ var z = /* @__PURE__ */ Symbol("clack:cancel");
5611
+ function Ct(t) {
5612
+ return t === z;
5613
+ }
5614
+ function T(t, e2) {
5615
+ const s = t;
5616
+ s.isTTY && s.setRawMode(e2);
5617
+ }
5618
+ var rt = (t) => "columns" in t && typeof t.columns == "number" ? t.columns : 80;
5619
+ var nt = (t) => "rows" in t && typeof t.rows == "number" ? t.rows : 20;
5620
+ function xt(t, e2, s, i = s) {
5621
+ const r = rt(t ?? stdout);
5622
+ return K(e2, r - s.length, { hard: true, trim: false }).split(`
5623
+ `).map((n, u) => `${u === 0 ? i : s}${n}`).join(`
5624
+ `);
5625
+ }
5626
+ var x = class {
5627
+ input;
5628
+ output;
5629
+ _abortSignal;
5630
+ rl;
5631
+ opts;
5632
+ _render;
5633
+ _track = false;
5634
+ _prevFrame = "";
5635
+ _subscribers = /* @__PURE__ */ new Map();
5636
+ _cursor = 0;
5637
+ state = "initial";
5638
+ error = "";
5639
+ value;
5640
+ userInput = "";
5641
+ constructor(e2, s = true) {
5642
+ const { input: i = stdin, output: r = stdout, render: n, signal: u, ...a } = e2;
5643
+ this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = u, this.input = i, this.output = r;
5644
+ }
5645
+ unsubscribe() {
5646
+ this._subscribers.clear();
5647
+ }
5648
+ setSubscriber(e2, s) {
5649
+ const i = this._subscribers.get(e2) ?? [];
5650
+ i.push(s), this._subscribers.set(e2, i);
5651
+ }
5652
+ on(e2, s) {
5653
+ this.setSubscriber(e2, { cb: s });
5654
+ }
5655
+ once(e2, s) {
5656
+ this.setSubscriber(e2, { cb: s, once: true });
5657
+ }
5658
+ emit(e2, ...s) {
5659
+ const i = this._subscribers.get(e2) ?? [], r = [];
5660
+ for (const n of i) n.cb(...s), n.once && r.push(() => i.splice(i.indexOf(n), 1));
5661
+ for (const n of r) n();
5662
+ }
5663
+ prompt() {
5664
+ return new Promise((e2) => {
5665
+ if (this._abortSignal) {
5666
+ if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e2(z);
5667
+ this._abortSignal.addEventListener("abort", () => {
5668
+ this.state = "cancel", this.close();
5669
+ }, { once: true });
5670
+ }
5671
+ this.rl = ot.createInterface({ input: this.input, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), T(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
5672
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), T(this.input, false), e2(this.value);
5673
+ }), this.once("cancel", () => {
5674
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), T(this.input, false), e2(z);
5675
+ });
5676
+ });
5677
+ }
5678
+ _isActionKey(e2, s) {
5679
+ return e2 === " ";
5680
+ }
5681
+ _setValue(e2) {
5682
+ this.value = e2, this.emit("value", this.value);
5683
+ }
5684
+ _setUserInput(e2, s) {
5685
+ this.userInput = e2 ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
5686
+ }
5687
+ _clearUserInput() {
5688
+ this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
5689
+ }
5690
+ onKeypress(e2, s) {
5691
+ if (this._track && s.name !== "return" && (s.name && this._isActionKey(e2, s) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && _.aliases.has(s.name) && this.emit("cursor", _.aliases.get(s.name)), _.actions.has(s.name) && this.emit("cursor", s.name)), e2 && (e2.toLowerCase() === "y" || e2.toLowerCase() === "n") && this.emit("confirm", e2.toLowerCase() === "y"), this.emit("key", e2?.toLowerCase(), s), s?.name === "return") {
5692
+ if (this.opts.validate) {
5693
+ const i = this.opts.validate(this.value);
5694
+ i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
5695
+ }
5696
+ this.state !== "error" && (this.state = "submit");
5697
+ }
5698
+ H([e2, s?.name, s?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
5699
+ }
5700
+ close() {
5701
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
5702
+ `), T(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
5703
+ }
5704
+ restoreCursor() {
5705
+ const e2 = K(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
5706
+ `).length - 1;
5707
+ this.output.write(import_sisteransi.cursor.move(-999, e2 * -1));
5708
+ }
5709
+ render() {
5710
+ const e2 = K(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
5711
+ if (e2 !== this._prevFrame) {
5712
+ if (this.state === "initial") this.output.write(import_sisteransi.cursor.hide);
5713
+ else {
5714
+ const s = _t(this._prevFrame, e2), i = nt(this.output);
5715
+ if (this.restoreCursor(), s) {
5716
+ const r = Math.max(0, s.numLinesAfter - i), n = Math.max(0, s.numLinesBefore - i);
5717
+ let u = s.lines.find((a) => a >= r);
5718
+ if (u === void 0) {
5719
+ this._prevFrame = e2;
5720
+ return;
5721
+ }
5722
+ if (s.lines.length === 1) {
5723
+ this.output.write(import_sisteransi.cursor.move(0, u - n)), this.output.write(import_sisteransi.erase.lines(1));
5724
+ const a = e2.split(`
5725
+ `);
5726
+ this.output.write(a[u]), this._prevFrame = e2, this.output.write(import_sisteransi.cursor.move(0, a.length - u - 1));
5727
+ return;
5728
+ } else if (s.lines.length > 1) {
5729
+ if (r < n) u = r;
5730
+ else {
5731
+ const l = u - n;
5732
+ l > 0 && this.output.write(import_sisteransi.cursor.move(0, l));
5733
+ }
5734
+ this.output.write(import_sisteransi.erase.down());
5735
+ const a = e2.split(`
5736
+ `).slice(u);
5737
+ this.output.write(a.join(`
5738
+ `)), this._prevFrame = e2;
5739
+ return;
5740
+ }
5741
+ }
5742
+ this.output.write(import_sisteransi.erase.down());
5743
+ }
5744
+ this.output.write(e2), this.state === "initial" && (this.state = "active"), this._prevFrame = e2;
5745
+ }
5746
+ }
5747
+ };
5748
+ var kt = class extends x {
5749
+ get cursor() {
5750
+ return this.value ? 0 : 1;
5751
+ }
5752
+ get _value() {
5753
+ return this.cursor === 0;
5754
+ }
5755
+ constructor(e2) {
5756
+ super(e2, false), this.value = !!e2.initialValue, this.on("userInput", () => {
5757
+ this.value = this._value;
5758
+ }), this.on("confirm", (s) => {
5759
+ this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
5760
+ }), this.on("cursor", () => {
5761
+ this.value = !this.value;
5762
+ });
5763
+ }
5764
+ };
5765
+ var Wt = class extends x {
5766
+ options;
5767
+ cursor = 0;
5768
+ get _selectedValue() {
5769
+ return this.options[this.cursor];
5770
+ }
5771
+ changeValue() {
5772
+ this.value = this._selectedValue.value;
5773
+ }
5774
+ constructor(e2) {
5775
+ super(e2, false), this.options = e2.options;
5776
+ const s = this.options.findIndex(({ value: r }) => r === e2.initialValue), i = s === -1 ? 0 : s;
5777
+ this.cursor = this.options[i].disabled ? B(i, 1, this.options) : i, this.changeValue(), this.on("cursor", (r) => {
5778
+ switch (r) {
5779
+ case "left":
5780
+ case "up":
5781
+ this.cursor = B(this.cursor, -1, this.options);
5782
+ break;
5783
+ case "down":
5784
+ case "right":
5785
+ this.cursor = B(this.cursor, 1, this.options);
5786
+ break;
5787
+ }
5788
+ this.changeValue();
5789
+ });
5790
+ }
5791
+ };
5792
+ var $t = class extends x {
5793
+ get userInputWithCursor() {
5794
+ if (this.state === "submit") return this.userInput;
5795
+ const e2 = this.userInput;
5796
+ if (this.cursor >= e2.length) return `${this.userInput}\u2588`;
5797
+ const s = e2.slice(0, this.cursor), [i, ...r] = e2.slice(this.cursor);
5798
+ return `${s}${import_picocolors.default.inverse(i)}${r.join("")}`;
5799
+ }
5800
+ get cursor() {
5801
+ return this._cursor;
5802
+ }
5803
+ constructor(e2) {
5804
+ super({ ...e2, initialUserInput: e2.initialUserInput ?? e2.initialValue }), this.on("userInput", (s) => {
5805
+ this._setValue(s);
5806
+ }), this.on("finalize", () => {
5807
+ this.value || (this.value = e2.defaultValue), this.value === void 0 && (this.value = "");
5808
+ });
5809
+ }
5810
+ };
5811
+
5812
+ // ../../node_modules/.pnpm/@clack+prompts@1.0.1/node_modules/@clack/prompts/dist/index.mjs
5813
+ var import_picocolors2 = __toESM(require_picocolors());
5814
+ __toESM(require_src());
5815
+ function me() {
5816
+ return N2.platform !== "win32" ? N2.env.TERM !== "linux" : !!N2.env.CI || !!N2.env.WT_SESSION || !!N2.env.TERMINUS_SUBLIME || N2.env.ConEmuTask === "{cmd::Cmder}" || N2.env.TERM_PROGRAM === "Terminus-Sublime" || N2.env.TERM_PROGRAM === "vscode" || N2.env.TERM === "xterm-256color" || N2.env.TERM === "alacritty" || N2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
5817
+ }
5818
+ var et2 = me();
5819
+ var C = (t, r) => et2 ? t : r;
5820
+ var Rt = C("\u25C6", "*");
5821
+ var dt2 = C("\u25A0", "x");
5822
+ var $t2 = C("\u25B2", "x");
5823
+ var V = C("\u25C7", "o");
5824
+ var ht2 = C("\u250C", "T");
5825
+ var d = C("\u2502", "|");
5826
+ var x2 = C("\u2514", "\u2014");
5827
+ var Q2 = C("\u25CF", ">");
5828
+ var H2 = C("\u25CB", " ");
5829
+ var rt2 = C("\u2500", "-");
5830
+ var mt2 = C("\u256E", "+");
5831
+ var Wt2 = C("\u251C", "+");
5832
+ var pt2 = C("\u256F", "+");
5833
+ var W2 = (t) => {
5834
+ switch (t) {
5835
+ case "initial":
5836
+ case "active":
5837
+ return import_picocolors2.default.cyan(Rt);
5838
+ case "cancel":
5839
+ return import_picocolors2.default.red(dt2);
5840
+ case "error":
5841
+ return import_picocolors2.default.yellow($t2);
5842
+ case "submit":
5843
+ return import_picocolors2.default.green(V);
5844
+ }
5845
+ };
5846
+ var vt2 = (t) => {
5847
+ switch (t) {
5848
+ case "initial":
5849
+ case "active":
5850
+ return import_picocolors2.default.cyan(d);
5851
+ case "cancel":
5852
+ return import_picocolors2.default.red(d);
5853
+ case "error":
5854
+ return import_picocolors2.default.yellow(d);
5855
+ case "submit":
5856
+ return import_picocolors2.default.green(d);
5857
+ }
5858
+ };
5859
+ var pe = (t) => t === 161 || t === 164 || t === 167 || t === 168 || t === 170 || t === 173 || t === 174 || t >= 176 && t <= 180 || t >= 182 && t <= 186 || t >= 188 && t <= 191 || t === 198 || t === 208 || t === 215 || t === 216 || t >= 222 && t <= 225 || t === 230 || t >= 232 && t <= 234 || t === 236 || t === 237 || t === 240 || t === 242 || t === 243 || t >= 247 && t <= 250 || t === 252 || t === 254 || t === 257 || t === 273 || t === 275 || t === 283 || t === 294 || t === 295 || t === 299 || t >= 305 && t <= 307 || t === 312 || t >= 319 && t <= 322 || t === 324 || t >= 328 && t <= 331 || t === 333 || t === 338 || t === 339 || t === 358 || t === 359 || t === 363 || t === 462 || t === 464 || t === 466 || t === 468 || t === 470 || t === 472 || t === 474 || t === 476 || t === 593 || t === 609 || t === 708 || t === 711 || t >= 713 && t <= 715 || t === 717 || t === 720 || t >= 728 && t <= 731 || t === 733 || t === 735 || t >= 768 && t <= 879 || t >= 913 && t <= 929 || t >= 931 && t <= 937 || t >= 945 && t <= 961 || t >= 963 && t <= 969 || t === 1025 || t >= 1040 && t <= 1103 || t === 1105 || t === 8208 || t >= 8211 && t <= 8214 || t === 8216 || t === 8217 || t === 8220 || t === 8221 || t >= 8224 && t <= 8226 || t >= 8228 && t <= 8231 || t === 8240 || t === 8242 || t === 8243 || t === 8245 || t === 8251 || t === 8254 || t === 8308 || t === 8319 || t >= 8321 && t <= 8324 || t === 8364 || t === 8451 || t === 8453 || t === 8457 || t === 8467 || t === 8470 || t === 8481 || t === 8482 || t === 8486 || t === 8491 || t === 8531 || t === 8532 || t >= 8539 && t <= 8542 || t >= 8544 && t <= 8555 || t >= 8560 && t <= 8569 || t === 8585 || t >= 8592 && t <= 8601 || t === 8632 || t === 8633 || t === 8658 || t === 8660 || t === 8679 || t === 8704 || t === 8706 || t === 8707 || t === 8711 || t === 8712 || t === 8715 || t === 8719 || t === 8721 || t === 8725 || t === 8730 || t >= 8733 && t <= 8736 || t === 8739 || t === 8741 || t >= 8743 && t <= 8748 || t === 8750 || t >= 8756 && t <= 8759 || t === 8764 || t === 8765 || t === 8776 || t === 8780 || t === 8786 || t === 8800 || t === 8801 || t >= 8804 && t <= 8807 || t === 8810 || t === 8811 || t === 8814 || t === 8815 || t === 8834 || t === 8835 || t === 8838 || t === 8839 || t === 8853 || t === 8857 || t === 8869 || t === 8895 || t === 8978 || t >= 9312 && t <= 9449 || t >= 9451 && t <= 9547 || t >= 9552 && t <= 9587 || t >= 9600 && t <= 9615 || t >= 9618 && t <= 9621 || t === 9632 || t === 9633 || t >= 9635 && t <= 9641 || t === 9650 || t === 9651 || t === 9654 || t === 9655 || t === 9660 || t === 9661 || t === 9664 || t === 9665 || t >= 9670 && t <= 9672 || t === 9675 || t >= 9678 && t <= 9681 || t >= 9698 && t <= 9701 || t === 9711 || t === 9733 || t === 9734 || t === 9737 || t === 9742 || t === 9743 || t === 9756 || t === 9758 || t === 9792 || t === 9794 || t === 9824 || t === 9825 || t >= 9827 && t <= 9829 || t >= 9831 && t <= 9834 || t === 9836 || t === 9837 || t === 9839 || t === 9886 || t === 9887 || t === 9919 || t >= 9926 && t <= 9933 || t >= 9935 && t <= 9939 || t >= 9941 && t <= 9953 || t === 9955 || t === 9960 || t === 9961 || t >= 9963 && t <= 9969 || t === 9972 || t >= 9974 && t <= 9977 || t === 9979 || t === 9980 || t === 9982 || t === 9983 || t === 10045 || t >= 10102 && t <= 10111 || t >= 11094 && t <= 11097 || t >= 12872 && t <= 12879 || t >= 57344 && t <= 63743 || t >= 65024 && t <= 65039 || t === 65533 || t >= 127232 && t <= 127242 || t >= 127248 && t <= 127277 || t >= 127280 && t <= 127337 || t >= 127344 && t <= 127373 || t === 127375 || t === 127376 || t >= 127387 && t <= 127404 || t >= 917760 && t <= 917999 || t >= 983040 && t <= 1048573 || t >= 1048576 && t <= 1114109;
5860
+ var ge = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510;
5861
+ var fe = (t) => t >= 4352 && t <= 4447 || t === 8986 || t === 8987 || t === 9001 || t === 9002 || t >= 9193 && t <= 9196 || t === 9200 || t === 9203 || t === 9725 || t === 9726 || t === 9748 || t === 9749 || t >= 9800 && t <= 9811 || t === 9855 || t === 9875 || t === 9889 || t === 9898 || t === 9899 || t === 9917 || t === 9918 || t === 9924 || t === 9925 || t === 9934 || t === 9940 || t === 9962 || t === 9970 || t === 9971 || t === 9973 || t === 9978 || t === 9981 || t === 9989 || t === 9994 || t === 9995 || t === 10024 || t === 10060 || t === 10062 || t >= 10067 && t <= 10069 || t === 10071 || t >= 10133 && t <= 10135 || t === 10160 || t === 10175 || t === 11035 || t === 11036 || t === 11088 || t === 11093 || t >= 11904 && t <= 11929 || t >= 11931 && t <= 12019 || t >= 12032 && t <= 12245 || t >= 12272 && t <= 12287 || t >= 12289 && t <= 12350 || t >= 12353 && t <= 12438 || t >= 12441 && t <= 12543 || t >= 12549 && t <= 12591 || t >= 12593 && t <= 12686 || t >= 12688 && t <= 12771 || t >= 12783 && t <= 12830 || t >= 12832 && t <= 12871 || t >= 12880 && t <= 19903 || t >= 19968 && t <= 42124 || t >= 42128 && t <= 42182 || t >= 43360 && t <= 43388 || t >= 44032 && t <= 55203 || t >= 63744 && t <= 64255 || t >= 65040 && t <= 65049 || t >= 65072 && t <= 65106 || t >= 65108 && t <= 65126 || t >= 65128 && t <= 65131 || t >= 94176 && t <= 94180 || t === 94192 || t === 94193 || t >= 94208 && t <= 100343 || t >= 100352 && t <= 101589 || t >= 101632 && t <= 101640 || t >= 110576 && t <= 110579 || t >= 110581 && t <= 110587 || t === 110589 || t === 110590 || t >= 110592 && t <= 110882 || t === 110898 || t >= 110928 && t <= 110930 || t === 110933 || t >= 110948 && t <= 110951 || t >= 110960 && t <= 111355 || t === 126980 || t === 127183 || t === 127374 || t >= 127377 && t <= 127386 || t >= 127488 && t <= 127490 || t >= 127504 && t <= 127547 || t >= 127552 && t <= 127560 || t === 127568 || t === 127569 || t >= 127584 && t <= 127589 || t >= 127744 && t <= 127776 || t >= 127789 && t <= 127797 || t >= 127799 && t <= 127868 || t >= 127870 && t <= 127891 || t >= 127904 && t <= 127946 || t >= 127951 && t <= 127955 || t >= 127968 && t <= 127984 || t === 127988 || t >= 127992 && t <= 128062 || t === 128064 || t >= 128066 && t <= 128252 || t >= 128255 && t <= 128317 || t >= 128331 && t <= 128334 || t >= 128336 && t <= 128359 || t === 128378 || t === 128405 || t === 128406 || t === 128420 || t >= 128507 && t <= 128591 || t >= 128640 && t <= 128709 || t === 128716 || t >= 128720 && t <= 128722 || t >= 128725 && t <= 128727 || t >= 128732 && t <= 128735 || t === 128747 || t === 128748 || t >= 128756 && t <= 128764 || t >= 128992 && t <= 129003 || t === 129008 || t >= 129292 && t <= 129338 || t >= 129340 && t <= 129349 || t >= 129351 && t <= 129535 || t >= 129648 && t <= 129660 || t >= 129664 && t <= 129672 || t >= 129680 && t <= 129725 || t >= 129727 && t <= 129733 || t >= 129742 && t <= 129755 || t >= 129760 && t <= 129768 || t >= 129776 && t <= 129784 || t >= 131072 && t <= 196605 || t >= 196608 && t <= 262141;
5862
+ var At2 = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
5863
+ var it2 = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
5864
+ var nt2 = /\t{1,1000}/y;
5865
+ var wt = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
5866
+ var at2 = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
5867
+ var Fe = /\p{M}+/gu;
5868
+ var ye = { limit: 1 / 0, ellipsis: "" };
5869
+ var jt = (t, r = {}, s = {}) => {
5870
+ const i = r.limit ?? 1 / 0, a = r.ellipsis ?? "", o = r?.ellipsisWidth ?? (a ? jt(a, ye, s).width : 0), u = s.ansiWidth ?? 0, l = s.controlWidth ?? 0, n = s.tabWidth ?? 8, c = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, F = s.fullWidthWidth ?? 2, p = s.regularWidth ?? 1, E = s.wideWidth ?? 2;
5871
+ let $ = 0, m = 0, h = t.length, y2 = 0, f = false, v = h, S2 = Math.max(0, i - o), I2 = 0, B2 = 0, A = 0, w = 0;
5872
+ t: for (; ; ) {
5873
+ if (B2 > I2 || m >= h && m > $) {
5874
+ const _2 = t.slice(I2, B2) || t.slice($, m);
5875
+ y2 = 0;
5876
+ for (const D2 of _2.replaceAll(Fe, "")) {
5877
+ const T2 = D2.codePointAt(0) || 0;
5878
+ if (ge(T2) ? w = F : fe(T2) ? w = E : c !== p && pe(T2) ? w = c : w = p, A + w > S2 && (v = Math.min(v, Math.max(I2, $) + y2)), A + w > i) {
5879
+ f = true;
5880
+ break t;
5881
+ }
5882
+ y2 += D2.length, A += w;
5883
+ }
5884
+ I2 = B2 = 0;
5885
+ }
5886
+ if (m >= h) break;
5887
+ if (at2.lastIndex = m, at2.test(t)) {
5888
+ if (y2 = at2.lastIndex - m, w = y2 * p, A + w > S2 && (v = Math.min(v, m + Math.floor((S2 - A) / p))), A + w > i) {
5889
+ f = true;
5890
+ break;
5891
+ }
5892
+ A += w, I2 = $, B2 = m, m = $ = at2.lastIndex;
5893
+ continue;
5894
+ }
5895
+ if (At2.lastIndex = m, At2.test(t)) {
5896
+ if (A + u > S2 && (v = Math.min(v, m)), A + u > i) {
5897
+ f = true;
5898
+ break;
5899
+ }
5900
+ A += u, I2 = $, B2 = m, m = $ = At2.lastIndex;
5901
+ continue;
5902
+ }
5903
+ if (it2.lastIndex = m, it2.test(t)) {
5904
+ if (y2 = it2.lastIndex - m, w = y2 * l, A + w > S2 && (v = Math.min(v, m + Math.floor((S2 - A) / l))), A + w > i) {
5905
+ f = true;
5906
+ break;
5907
+ }
5908
+ A += w, I2 = $, B2 = m, m = $ = it2.lastIndex;
5909
+ continue;
5910
+ }
5911
+ if (nt2.lastIndex = m, nt2.test(t)) {
5912
+ if (y2 = nt2.lastIndex - m, w = y2 * n, A + w > S2 && (v = Math.min(v, m + Math.floor((S2 - A) / n))), A + w > i) {
5913
+ f = true;
5914
+ break;
5915
+ }
5916
+ A += w, I2 = $, B2 = m, m = $ = nt2.lastIndex;
5917
+ continue;
5918
+ }
5919
+ if (wt.lastIndex = m, wt.test(t)) {
5920
+ if (A + g > S2 && (v = Math.min(v, m)), A + g > i) {
5921
+ f = true;
5922
+ break;
5923
+ }
5924
+ A += g, I2 = $, B2 = m, m = $ = wt.lastIndex;
5925
+ continue;
5926
+ }
5927
+ m += 1;
5928
+ }
5929
+ return { width: f ? S2 : A, index: f ? v : h, truncated: f, ellipsed: f && i >= o };
5930
+ };
5931
+ var Ee = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
5932
+ var M2 = (t, r = {}) => jt(t, Ee, r).width;
5933
+ var ot2 = "\x1B";
5934
+ var Gt = "\x9B";
5935
+ var ve = 39;
5936
+ var Ct2 = "\x07";
5937
+ var kt2 = "[";
5938
+ var Ae = "]";
5939
+ var Vt2 = "m";
5940
+ var St = `${Ae}8;;`;
5941
+ var Ht = new RegExp(`(?:\\${kt2}(?<code>\\d+)m|\\${St}(?<uri>.*)${Ct2})`, "y");
5942
+ var we = (t) => {
5943
+ if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
5944
+ if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
5945
+ if (t === 1 || t === 2) return 22;
5946
+ if (t === 3) return 23;
5947
+ if (t === 4) return 24;
5948
+ if (t === 7) return 27;
5949
+ if (t === 8) return 28;
5950
+ if (t === 9) return 29;
5951
+ if (t === 0) return 0;
5952
+ };
5953
+ var Ut = (t) => `${ot2}${kt2}${t}${Vt2}`;
5954
+ var Kt = (t) => `${ot2}${St}${t}${Ct2}`;
5955
+ var Ce = (t) => t.map((r) => M2(r));
5956
+ var It2 = (t, r, s) => {
5957
+ const i = r[Symbol.iterator]();
5958
+ let a = false, o = false, u = t.at(-1), l = u === void 0 ? 0 : M2(u), n = i.next(), c = i.next(), g = 0;
5959
+ for (; !n.done; ) {
5960
+ const F = n.value, p = M2(F);
5961
+ l + p <= s ? t[t.length - 1] += F : (t.push(F), l = 0), (F === ot2 || F === Gt) && (a = true, o = r.startsWith(St, g + 1)), a ? o ? F === Ct2 && (a = false, o = false) : F === Vt2 && (a = false) : (l += p, l === s && !c.done && (t.push(""), l = 0)), n = c, c = i.next(), g += F.length;
5962
+ }
5963
+ u = t.at(-1), !l && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
5964
+ };
5965
+ var Se = (t) => {
5966
+ const r = t.split(" ");
5967
+ let s = r.length;
5968
+ for (; s > 0 && !(M2(r[s - 1]) > 0); ) s--;
5969
+ return s === r.length ? t : r.slice(0, s).join(" ") + r.slice(s).join("");
5970
+ };
5971
+ var Ie = (t, r, s = {}) => {
5972
+ if (s.trim !== false && t.trim() === "") return "";
5973
+ let i = "", a, o;
5974
+ const u = t.split(" "), l = Ce(u);
5975
+ let n = [""];
5976
+ for (const [$, m] of u.entries()) {
5977
+ s.trim !== false && (n[n.length - 1] = (n.at(-1) ?? "").trimStart());
5978
+ let h = M2(n.at(-1) ?? "");
5979
+ if ($ !== 0 && (h >= r && (s.wordWrap === false || s.trim === false) && (n.push(""), h = 0), (h > 0 || s.trim === false) && (n[n.length - 1] += " ", h++)), s.hard && l[$] > r) {
5980
+ const y2 = r - h, f = 1 + Math.floor((l[$] - y2 - 1) / r);
5981
+ Math.floor((l[$] - 1) / r) < f && n.push(""), It2(n, m, r);
5982
+ continue;
5983
+ }
5984
+ if (h + l[$] > r && h > 0 && l[$] > 0) {
5985
+ if (s.wordWrap === false && h < r) {
5986
+ It2(n, m, r);
5987
+ continue;
5988
+ }
5989
+ n.push("");
5990
+ }
5991
+ if (h + l[$] > r && s.wordWrap === false) {
5992
+ It2(n, m, r);
5993
+ continue;
5994
+ }
5995
+ n[n.length - 1] += m;
5996
+ }
5997
+ s.trim !== false && (n = n.map(($) => Se($)));
5998
+ const c = n.join(`
5999
+ `), g = c[Symbol.iterator]();
6000
+ let F = g.next(), p = g.next(), E = 0;
6001
+ for (; !F.done; ) {
6002
+ const $ = F.value, m = p.value;
6003
+ if (i += $, $ === ot2 || $ === Gt) {
6004
+ Ht.lastIndex = E + 1;
6005
+ const f = Ht.exec(c)?.groups;
6006
+ if (f?.code !== void 0) {
6007
+ const v = Number.parseFloat(f.code);
6008
+ a = v === ve ? void 0 : v;
6009
+ } else f?.uri !== void 0 && (o = f.uri.length === 0 ? void 0 : f.uri);
6010
+ }
6011
+ const h = a ? we(a) : void 0;
6012
+ m === `
6013
+ ` ? (o && (i += Kt("")), a && h && (i += Ut(h))) : $ === `
6014
+ ` && (a && h && (i += Ut(a)), o && (i += Kt(o))), E += $.length, F = p, p = g.next();
6015
+ }
6016
+ return i;
6017
+ };
6018
+ function J2(t, r, s) {
6019
+ return String(t).normalize().replaceAll(`\r
6020
+ `, `
6021
+ `).split(`
6022
+ `).map((i) => Ie(i, r, s)).join(`
6023
+ `);
6024
+ }
6025
+ var be = (t, r, s, i, a) => {
6026
+ let o = r, u = 0;
6027
+ for (let l = s; l < i; l++) {
6028
+ const n = t[l];
6029
+ if (o = o - n.length, u++, o <= a) break;
6030
+ }
6031
+ return { lineCount: o, removals: u };
6032
+ };
6033
+ var X2 = (t) => {
6034
+ const { cursor: r, options: s, style: i } = t, a = t.output ?? process.stdout, o = rt(a), u = t.columnPadding ?? 0, l = t.rowPadding ?? 4, n = o - u, c = nt(a), g = import_picocolors2.default.dim("..."), F = t.maxItems ?? Number.POSITIVE_INFINITY, p = Math.max(c - l, 0), E = Math.max(Math.min(F, p), 5);
6035
+ let $ = 0;
6036
+ r >= E - 3 && ($ = Math.max(Math.min(r - E + 3, s.length - E), 0));
6037
+ let m = E < s.length && $ > 0, h = E < s.length && $ + E < s.length;
6038
+ const y2 = Math.min($ + E, s.length), f = [];
6039
+ let v = 0;
6040
+ m && v++, h && v++;
6041
+ const S2 = $ + (m ? 1 : 0), I2 = y2 - (h ? 1 : 0);
6042
+ for (let A = S2; A < I2; A++) {
6043
+ const w = J2(i(s[A], A === r), n, { hard: true, trim: false }).split(`
6044
+ `);
6045
+ f.push(w), v += w.length;
6046
+ }
6047
+ if (v > p) {
6048
+ let A = 0, w = 0, _2 = v;
6049
+ const D2 = r - S2, T2 = (Y, L2) => be(f, _2, Y, L2, p);
6050
+ m ? ({ lineCount: _2, removals: A } = T2(0, D2), _2 > p && ({ lineCount: _2, removals: w } = T2(D2 + 1, f.length))) : ({ lineCount: _2, removals: w } = T2(D2 + 1, f.length), _2 > p && ({ lineCount: _2, removals: A } = T2(0, D2))), A > 0 && (m = true, f.splice(0, A)), w > 0 && (h = true, f.splice(f.length - w, w));
6051
+ }
6052
+ const B2 = [];
6053
+ m && B2.push(g);
6054
+ for (const A of f) for (const w of A) B2.push(w);
6055
+ return h && B2.push(g), B2;
6056
+ };
6057
+ var Re = (t) => {
6058
+ const r = t.active ?? "Yes", s = t.inactive ?? "No";
6059
+ return new kt({ active: r, inactive: s, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue ?? true, render() {
6060
+ const i = t.withGuide ?? _.withGuide, a = `${i ? `${import_picocolors2.default.gray(d)}
6061
+ ` : ""}${W2(this.state)} ${t.message}
6062
+ `, o = this.value ? r : s;
6063
+ switch (this.state) {
6064
+ case "submit": {
6065
+ const u = i ? `${import_picocolors2.default.gray(d)} ` : "";
6066
+ return `${a}${u}${import_picocolors2.default.dim(o)}`;
6067
+ }
6068
+ case "cancel": {
6069
+ const u = i ? `${import_picocolors2.default.gray(d)} ` : "";
6070
+ return `${a}${u}${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(o))}${i ? `
6071
+ ${import_picocolors2.default.gray(d)}` : ""}`;
6072
+ }
6073
+ default: {
6074
+ const u = i ? `${import_picocolors2.default.cyan(d)} ` : "", l = i ? import_picocolors2.default.cyan(x2) : "";
6075
+ return `${a}${u}${this.value ? `${import_picocolors2.default.green(Q2)} ${r}` : `${import_picocolors2.default.dim(H2)} ${import_picocolors2.default.dim(r)}`}${t.vertical ? i ? `
6076
+ ${import_picocolors2.default.cyan(d)} ` : `
6077
+ ` : ` ${import_picocolors2.default.dim("/")} `}${this.value ? `${import_picocolors2.default.dim(H2)} ${import_picocolors2.default.dim(s)}` : `${import_picocolors2.default.green(Q2)} ${s}`}
6078
+ ${l}
6079
+ `;
6080
+ }
6081
+ }
6082
+ } }).prompt();
6083
+ };
6084
+ var Ne = (t = "", r) => {
6085
+ (process.stdout).write(`${import_picocolors2.default.gray(x2)} ${import_picocolors2.default.red(t)}
6086
+
6087
+ `);
6088
+ };
6089
+ var We = (t = "", r) => {
6090
+ (process.stdout).write(`${import_picocolors2.default.gray(ht2)} ${t}
6091
+ `);
6092
+ };
6093
+ var Le = (t = "", r) => {
6094
+ (process.stdout).write(`${import_picocolors2.default.gray(d)}
6095
+ ${import_picocolors2.default.gray(x2)} ${t}
6096
+
6097
+ `);
6098
+ };
6099
+ var Ge = (t) => import_picocolors2.default.dim(t);
6100
+ var ke = (t, r, s) => {
6101
+ const i = { hard: true, trim: false }, a = J2(t, r, i).split(`
6102
+ `), o = a.reduce((n, c) => Math.max(M2(c), n), 0), u = a.map(s).reduce((n, c) => Math.max(M2(c), n), 0), l = r - (u - o);
6103
+ return J2(t, l, i);
6104
+ };
6105
+ var Ve = (t = "", r = "", s) => {
6106
+ const i = N2.stdout, o = Ge, u = ["", ...ke(t, rt(i) - 6, o).split(`
6107
+ `).map(o), ""], l = M2(r), n = Math.max(u.reduce((p, E) => {
6108
+ const $ = M2(E);
6109
+ return $ > p ? $ : p;
6110
+ }, 0), l) + 2, c = u.map((p) => `${import_picocolors2.default.gray(d)} ${p}${" ".repeat(n - M2(p))}${import_picocolors2.default.gray(d)}`).join(`
6111
+ `), g = `${import_picocolors2.default.gray(d)}
6112
+ ` , F = Wt2 ;
6113
+ i.write(`${g}${import_picocolors2.default.green(V)} ${import_picocolors2.default.reset(r)} ${import_picocolors2.default.gray(rt2.repeat(Math.max(n - l - 1, 1)) + mt2)}
6114
+ ${c}
6115
+ ${import_picocolors2.default.gray(F + rt2.repeat(n + 2) + pt2)}
6116
+ `);
6117
+ };
6118
+ import_picocolors2.default.magenta;
6119
+ var lt2 = (t, r) => t.includes(`
6120
+ `) ? t.split(`
6121
+ `).map((s) => r(s)).join(`
6122
+ `) : r(t);
6123
+ var Je = (t) => {
6124
+ const r = (s, i) => {
6125
+ const a = s.label ?? String(s.value);
6126
+ switch (i) {
6127
+ case "disabled":
6128
+ return `${import_picocolors2.default.gray(H2)} ${lt2(a, import_picocolors2.default.gray)}${s.hint ? ` ${import_picocolors2.default.dim(`(${s.hint ?? "disabled"})`)}` : ""}`;
6129
+ case "selected":
6130
+ return `${lt2(a, import_picocolors2.default.dim)}`;
6131
+ case "active":
6132
+ return `${import_picocolors2.default.green(Q2)} ${a}${s.hint ? ` ${import_picocolors2.default.dim(`(${s.hint})`)}` : ""}`;
6133
+ case "cancelled":
6134
+ return `${lt2(a, (o) => import_picocolors2.default.strikethrough(import_picocolors2.default.dim(o)))}`;
6135
+ default:
6136
+ return `${import_picocolors2.default.dim(H2)} ${lt2(a, import_picocolors2.default.dim)}`;
6137
+ }
6138
+ };
6139
+ return new Wt({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue, render() {
6140
+ const s = t.withGuide ?? _.withGuide, i = `${W2(this.state)} `, a = `${vt2(this.state)} `, o = xt(t.output, t.message, a, i), u = `${s ? `${import_picocolors2.default.gray(d)}
6141
+ ` : ""}${o}
6142
+ `;
6143
+ switch (this.state) {
6144
+ case "submit": {
6145
+ const l = s ? `${import_picocolors2.default.gray(d)} ` : "", n = xt(t.output, r(this.options[this.cursor], "selected"), l);
6146
+ return `${u}${n}`;
6147
+ }
6148
+ case "cancel": {
6149
+ const l = s ? `${import_picocolors2.default.gray(d)} ` : "", n = xt(t.output, r(this.options[this.cursor], "cancelled"), l);
6150
+ return `${u}${n}${s ? `
6151
+ ${import_picocolors2.default.gray(d)}` : ""}`;
6152
+ }
6153
+ default: {
6154
+ const l = s ? `${import_picocolors2.default.cyan(d)} ` : "", n = s ? import_picocolors2.default.cyan(x2) : "", c = u.split(`
6155
+ `).length, g = s ? 2 : 1;
6156
+ return `${u}${l}${X2({ output: t.output, cursor: this.cursor, options: this.options, maxItems: t.maxItems, columnPadding: l.length, rowPadding: c + g, style: (F, p) => r(F, F.disabled ? "disabled" : p ? "active" : "inactive") }).join(`
6157
+ ${l}`)}
6158
+ ${n}
6159
+ `;
6160
+ }
6161
+ }
6162
+ } }).prompt();
6163
+ };
6164
+ `${import_picocolors2.default.gray(d)} `;
6165
+ var Ze = (t) => new $t({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, output: t.output, signal: t.signal, input: t.input, render() {
6166
+ const r = t?.withGuide ?? _.withGuide, s = `${`${r ? `${import_picocolors2.default.gray(d)}
6167
+ ` : ""}${W2(this.state)} `}${t.message}
6168
+ `, i = t.placeholder ? import_picocolors2.default.inverse(t.placeholder[0]) + import_picocolors2.default.dim(t.placeholder.slice(1)) : import_picocolors2.default.inverse(import_picocolors2.default.hidden("_")), a = this.userInput ? this.userInputWithCursor : i, o = this.value ?? "";
6169
+ switch (this.state) {
6170
+ case "error": {
6171
+ const u = this.error ? ` ${import_picocolors2.default.yellow(this.error)}` : "", l = r ? `${import_picocolors2.default.yellow(d)} ` : "", n = r ? import_picocolors2.default.yellow(x2) : "";
6172
+ return `${s.trim()}
6173
+ ${l}${a}
6174
+ ${n}${u}
6175
+ `;
6176
+ }
6177
+ case "submit": {
6178
+ const u = o ? ` ${import_picocolors2.default.dim(o)}` : "", l = r ? import_picocolors2.default.gray(d) : "";
6179
+ return `${s}${l}${u}`;
6180
+ }
6181
+ case "cancel": {
6182
+ const u = o ? ` ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(o))}` : "", l = r ? import_picocolors2.default.gray(d) : "";
6183
+ return `${s}${l}${u}${o.trim() ? `
6184
+ ${l}` : ""}`;
6185
+ }
6186
+ default: {
6187
+ const u = r ? `${import_picocolors2.default.cyan(d)} ` : "", l = r ? import_picocolors2.default.cyan(x2) : "";
6188
+ return `${s}${u}${a}
6189
+ ${l}
6190
+ `;
6191
+ }
6192
+ }
6193
+ } }).prompt();
6194
+ var PROJECT_REPO = "https://github.com/BytePioneer-AI/moltbot-china";
6195
+ var GUIDES_BASE = "https://github.com/BytePioneer-AI/openclaw-china/tree/main/doc/guides";
6196
+ var OPENCLAW_HOME = join(homedir(), ".openclaw");
6197
+ var DEFAULT_PLUGIN_PATH = join(OPENCLAW_HOME, "extensions");
6198
+ var LEGACY_PLUGIN_PATH = join(OPENCLAW_HOME, "plugins");
6199
+ var CONFIG_FILE_PATH = join(OPENCLAW_HOME, "openclaw.json");
6200
+ var ANSI_RESET = "\x1B[0m";
6201
+ var ANSI_LINK = "\x1B[1;4;96m";
6202
+ var ANSI_BORDER = "\x1B[92m";
6203
+ var CHANNEL_ORDER = [
6204
+ "dingtalk",
6205
+ "qqbot",
6206
+ "wecom",
6207
+ "wecom-app",
6208
+ "feishu-china"
6209
+ ];
6210
+ var CHANNEL_DISPLAY_LABELS = {
6211
+ dingtalk: "DingTalk\uFF08\u9489\u9489\uFF09",
6212
+ "feishu-china": "Feishu\uFF08\u98DE\u4E66\uFF09",
6213
+ wecom: "WeCom\uFF08\u4F01\u4E1A\u5FAE\u4FE1-\u667A\u80FD\u673A\u5668\u4EBA\uFF09",
6214
+ "wecom-app": "WeCom App\uFF08\u81EA\u5EFA\u5E94\u7528-\u53EF\u63A5\u5165\u5FAE\u4FE1\uFF09",
6215
+ qqbot: "QQBot\uFF08QQ \u673A\u5668\u4EBA\uFF09"
6216
+ };
6217
+ var CHANNEL_GUIDE_LINKS = {
6218
+ dingtalk: `${GUIDES_BASE}/dingtalk/configuration.md`,
6219
+ "feishu-china": "https://github.com/BytePioneer-AI/openclaw-china/blob/main/README.md",
6220
+ wecom: `${GUIDES_BASE}/wecom/configuration.md`,
6221
+ "wecom-app": `${GUIDES_BASE}/wecom-app/configuration.md`,
6222
+ qqbot: `${GUIDES_BASE}/qqbot/configuration.md`
6223
+ };
6224
+ var CHINA_CLI_STATE_KEY = /* @__PURE__ */ Symbol.for("@openclaw-china/china-cli-state");
6225
+ var PromptCancelledError = class extends Error {
6226
+ constructor() {
6227
+ super("prompt-cancelled");
6228
+ }
6229
+ };
6230
+ function isChannelId(value) {
6231
+ return typeof value === "string" && CHANNEL_ORDER.includes(value);
6232
+ }
6233
+ function getChinaCliState() {
6234
+ const root = globalThis;
6235
+ const cached = root[CHINA_CLI_STATE_KEY];
6236
+ if (isRecord(cached)) {
6237
+ const channels = cached.channels;
6238
+ const cliRegistered = cached.cliRegistered;
6239
+ if (channels instanceof Set && typeof cliRegistered === "boolean") {
6240
+ return {
6241
+ channels,
6242
+ cliRegistered
6243
+ };
6244
+ }
6245
+ }
6246
+ const created = {
6247
+ channels: /* @__PURE__ */ new Set(),
6248
+ cliRegistered: false
6249
+ };
6250
+ root[CHINA_CLI_STATE_KEY] = created;
6251
+ return created;
6252
+ }
6253
+ function normalizeChannels(channels) {
6254
+ const selected = channels && channels.length > 0 ? channels : CHANNEL_ORDER;
6255
+ const unique = /* @__PURE__ */ new Set();
6256
+ for (const channelId of selected) {
6257
+ if (isChannelId(channelId)) {
6258
+ unique.add(channelId);
6259
+ }
6260
+ }
6261
+ return CHANNEL_ORDER.filter((channelId) => unique.has(channelId));
6262
+ }
6263
+ function getInstalledChannels(state) {
6264
+ return CHANNEL_ORDER.filter((channelId) => state.channels.has(channelId));
6265
+ }
6266
+ function guardCancel(value) {
6267
+ if (Ct(value)) {
6268
+ Ne("\u5DF2\u53D6\u6D88\u914D\u7F6E\u3002");
6269
+ throw new PromptCancelledError();
6270
+ }
6271
+ return value;
6272
+ }
6273
+ function warn(text) {
6274
+ stdout.write(`
6275
+ [warn] ${text}
6276
+ `);
6277
+ }
6278
+ function section(title) {
6279
+ stdout.write(`
6280
+ ${title}
6281
+ `);
6282
+ }
6283
+ function resolvePluginPath() {
6284
+ if (existsSync(DEFAULT_PLUGIN_PATH)) {
6285
+ return DEFAULT_PLUGIN_PATH;
6286
+ }
6287
+ if (existsSync(LEGACY_PLUGIN_PATH)) {
6288
+ return LEGACY_PLUGIN_PATH;
6289
+ }
6290
+ return DEFAULT_PLUGIN_PATH;
6291
+ }
6292
+ function renderReadyMessage() {
6293
+ return [
6294
+ `${ANSI_BORDER}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501${ANSI_RESET}`,
6295
+ " OpenClaw China Channels \u5DF2\u5C31\u7EEA!",
6296
+ `${ANSI_BORDER}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501${ANSI_RESET}`,
6297
+ "",
6298
+ "\u63D2\u4EF6\u8DEF\u5F84:",
6299
+ ` ${resolvePluginPath()}`,
6300
+ "",
6301
+ "\u914D\u7F6E\u6587\u4EF6:",
6302
+ ` ${CONFIG_FILE_PATH}`,
6303
+ "",
6304
+ "\u66F4\u65B0\u63D2\u4EF6:",
6305
+ " openclaw plugins update <plugin-id>",
6306
+ "",
6307
+ "\u9879\u76EE\u4ED3\u5E93:",
6308
+ ` ${ANSI_LINK}${PROJECT_REPO}${ANSI_RESET}`,
6309
+ "",
6310
+ "\u2B50 \u5982\u679C\u8FD9\u4E2A\u9879\u76EE\u5BF9\u4F60\u6709\u5E2E\u52A9\uFF0C\u8BF7\u7ED9\u6211\u4EEC\u4E00\u4E2A Star\uFF01\u2B50",
6311
+ "",
6312
+ "\u4E0B\u4E00\u6B65:",
6313
+ " openclaw gateway --port 18789 --verbose",
6314
+ ""
6315
+ ].join("\n");
6316
+ }
6317
+ function showReadyMessage() {
6318
+ stdout.write(`
6319
+ ${renderReadyMessage()}
6320
+ `);
6321
+ }
6322
+ function showGuideLink(channelId) {
6323
+ const url = CHANNEL_GUIDE_LINKS[channelId];
6324
+ Ve(`\u914D\u7F6E\u6587\u6863\uFF1A${url}`, "Docs");
6325
+ }
6326
+ function isRecord(value) {
6327
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6328
+ }
6329
+ function resolveWriteConfig(runtime2) {
6330
+ if (!isRecord(runtime2)) {
6331
+ return void 0;
6332
+ }
6333
+ const config = runtime2.config;
6334
+ if (!isRecord(config)) {
6335
+ return void 0;
6336
+ }
6337
+ if (typeof config.writeConfigFile !== "function") {
6338
+ return void 0;
6339
+ }
6340
+ return config.writeConfigFile;
6341
+ }
6342
+ function isCommandLike(value) {
6343
+ if (!isRecord(value)) {
6344
+ return false;
6345
+ }
6346
+ return typeof value.command === "function" && typeof value.description === "function" && typeof value.action === "function";
6347
+ }
6348
+ function toTrimmedString(value) {
6349
+ if (typeof value !== "string") {
6350
+ return void 0;
6351
+ }
6352
+ const trimmed = value.trim();
6353
+ return trimmed || void 0;
6354
+ }
6355
+ function hasNonEmptyString(value) {
6356
+ return typeof value === "string" && value.trim().length > 0;
6357
+ }
6358
+ function toBoolean(value, fallback) {
6359
+ return typeof value === "boolean" ? value : fallback;
6360
+ }
6361
+ function toNumber(value) {
6362
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
6363
+ }
6364
+ function cloneConfig(cfg) {
6365
+ try {
6366
+ return structuredClone(cfg);
6367
+ } catch {
6368
+ return JSON.parse(JSON.stringify(cfg));
6369
+ }
6370
+ }
6371
+ function getChannelConfig(cfg, channelId) {
6372
+ const channels = isRecord(cfg.channels) ? cfg.channels : {};
6373
+ const existing = channels[channelId];
6374
+ return isRecord(existing) ? existing : {};
6375
+ }
6376
+ function getPreferredAccountConfig(channelCfg) {
6377
+ const accounts = channelCfg.accounts;
6378
+ if (!isRecord(accounts)) {
6379
+ return void 0;
6380
+ }
6381
+ const defaultAccountId = toTrimmedString(channelCfg.defaultAccount);
6382
+ if (defaultAccountId) {
6383
+ const preferred = accounts[defaultAccountId];
6384
+ if (isRecord(preferred)) {
6385
+ return preferred;
6386
+ }
6387
+ }
6388
+ for (const value of Object.values(accounts)) {
6389
+ if (isRecord(value)) {
6390
+ return value;
6391
+ }
6392
+ }
6393
+ return void 0;
6394
+ }
6395
+ function hasTokenPair(channelCfg) {
6396
+ if (hasNonEmptyString(channelCfg.token) && hasNonEmptyString(channelCfg.encodingAESKey)) {
6397
+ return true;
6398
+ }
6399
+ const accountCfg = getPreferredAccountConfig(channelCfg);
6400
+ return Boolean(
6401
+ accountCfg && hasNonEmptyString(accountCfg.token) && hasNonEmptyString(accountCfg.encodingAESKey)
6402
+ );
6403
+ }
6404
+ function isChannelConfigured(cfg, channelId) {
6405
+ const channelCfg = getChannelConfig(cfg, channelId);
6406
+ switch (channelId) {
6407
+ case "dingtalk":
6408
+ return hasNonEmptyString(channelCfg.clientId) && hasNonEmptyString(channelCfg.clientSecret);
6409
+ case "feishu-china":
6410
+ return hasNonEmptyString(channelCfg.appId) && hasNonEmptyString(channelCfg.appSecret);
6411
+ case "qqbot":
6412
+ return hasNonEmptyString(channelCfg.appId) && hasNonEmptyString(channelCfg.clientSecret);
6413
+ case "wecom":
6414
+ case "wecom-app":
6415
+ return hasTokenPair(channelCfg);
6416
+ default:
6417
+ return false;
6418
+ }
6419
+ }
6420
+ function withConfiguredSuffix(cfg, channelId) {
6421
+ const base = CHANNEL_DISPLAY_LABELS[channelId];
6422
+ return isChannelConfigured(cfg, channelId) ? `${base}\uFF08\u5DF2\u914D\u7F6E\uFF09` : base;
6423
+ }
6424
+ function mergeChannelConfig(cfg, channelId, patch) {
6425
+ const channels = isRecord(cfg.channels) ? { ...cfg.channels } : {};
6426
+ const existing = getChannelConfig(cfg, channelId);
6427
+ channels[channelId] = {
6428
+ ...existing,
6429
+ ...patch,
6430
+ enabled: true
6431
+ };
6432
+ return {
6433
+ ...cfg,
6434
+ channels
6435
+ };
6436
+ }
6437
+ var SetupPrompter = class {
6438
+ async askText(params) {
6439
+ const { label, required = false, defaultValue } = params;
6440
+ while (true) {
6441
+ const value = String(
6442
+ guardCancel(
6443
+ await Ze({
6444
+ message: label,
6445
+ initialValue: defaultValue
6446
+ })
6447
+ )
6448
+ ).trim();
6449
+ if (value) {
6450
+ return value;
6451
+ }
6452
+ if (defaultValue) {
6453
+ return defaultValue;
6454
+ }
6455
+ if (!required) {
6456
+ return "";
6457
+ }
6458
+ warn("\u8BE5\u5B57\u6BB5\u4E3A\u5FC5\u586B\u9879\u3002");
6459
+ }
6460
+ }
6461
+ async askSecret(params) {
6462
+ const { label, existingValue, required = true } = params;
6463
+ return this.askText({
6464
+ label,
6465
+ required,
6466
+ defaultValue: existingValue
6467
+ });
6468
+ }
6469
+ async askConfirm(label, defaultValue = true) {
6470
+ return Boolean(
6471
+ guardCancel(
6472
+ await Re({
6473
+ message: label,
6474
+ initialValue: defaultValue
6475
+ })
6476
+ )
6477
+ );
6478
+ }
6479
+ async askNumber(params) {
6480
+ const { label, min, defaultValue } = params;
6481
+ while (true) {
6482
+ const raw = String(
6483
+ guardCancel(
6484
+ await Ze({
6485
+ message: label,
6486
+ initialValue: defaultValue !== void 0 ? String(defaultValue) : void 0
6487
+ })
6488
+ )
6489
+ ).trim();
6490
+ const parsed = Number.parseInt(raw, 10);
6491
+ if (Number.isFinite(parsed) && (min === void 0 || parsed >= min)) {
6492
+ return parsed;
6493
+ }
6494
+ warn(`\u8BF7\u8F93\u5165\u6709\u6548\u6574\u6570${min !== void 0 ? `\uFF08>= ${min}\uFF09` : ""}\u3002`);
6495
+ }
6496
+ }
6497
+ async askSelect(message, options, defaultValue) {
6498
+ const initial = options.some((opt) => opt.value === defaultValue) ? defaultValue : options[0]?.value;
6499
+ const selectOptions = options.map((option) => ({
6500
+ value: option.value,
6501
+ label: option.label
6502
+ }));
6503
+ return guardCancel(
6504
+ await Je({
6505
+ message,
6506
+ options: selectOptions,
6507
+ initialValue: initial
6508
+ })
6509
+ );
6510
+ }
6511
+ };
6512
+ async function configureDingtalk(prompter, cfg) {
6513
+ section("\u914D\u7F6E DingTalk\uFF08\u9489\u9489\uFF09");
6514
+ showGuideLink("dingtalk");
6515
+ const existing = getChannelConfig(cfg, "dingtalk");
6516
+ const clientId = await prompter.askText({
6517
+ label: "DingTalk clientId\uFF08AppKey\uFF09",
6518
+ defaultValue: toTrimmedString(existing.clientId),
6519
+ required: true
6520
+ });
6521
+ const clientSecret = await prompter.askSecret({
6522
+ label: "DingTalk clientSecret\uFF08AppSecret\uFF09",
6523
+ existingValue: toTrimmedString(existing.clientSecret),
6524
+ required: true
6525
+ });
6526
+ const enableAICard = await prompter.askConfirm(
6527
+ "\u542F\u7528 AI Card \u6D41\u5F0F\u56DE\u590D\uFF08\u63A8\u8350\u5173\u95ED\uFF0C\u4F7F\u7528\u975E\u6D41\u5F0F\uFF09",
6528
+ toBoolean(existing.enableAICard, false)
6529
+ );
6530
+ return mergeChannelConfig(cfg, "dingtalk", {
6531
+ clientId,
6532
+ clientSecret,
6533
+ enableAICard
6534
+ });
6535
+ }
6536
+ async function configureFeishu(prompter, cfg) {
6537
+ section("\u914D\u7F6E Feishu\uFF08\u98DE\u4E66\uFF09");
6538
+ showGuideLink("feishu-china");
6539
+ const existing = getChannelConfig(cfg, "feishu-china");
6540
+ const appId = await prompter.askText({
6541
+ label: "Feishu appId",
6542
+ defaultValue: toTrimmedString(existing.appId),
6543
+ required: true
6544
+ });
6545
+ const appSecret = await prompter.askSecret({
6546
+ label: "Feishu appSecret",
6547
+ existingValue: toTrimmedString(existing.appSecret),
6548
+ required: true
6549
+ });
6550
+ const sendMarkdownAsCard = await prompter.askConfirm(
6551
+ "\u4EE5\u5361\u7247\u5F62\u5F0F\u53D1\u9001 Markdown",
6552
+ toBoolean(existing.sendMarkdownAsCard, true)
6553
+ );
6554
+ return mergeChannelConfig(cfg, "feishu-china", {
6555
+ appId,
6556
+ appSecret,
6557
+ sendMarkdownAsCard
6558
+ });
6559
+ }
6560
+ async function configureWecom(prompter, cfg) {
6561
+ section("\u914D\u7F6E WeCom\uFF08\u4F01\u4E1A\u5FAE\u4FE1-\u667A\u80FD\u673A\u5668\u4EBA\uFF09");
6562
+ showGuideLink("wecom");
6563
+ const existing = getChannelConfig(cfg, "wecom");
6564
+ const webhookPath = await prompter.askText({
6565
+ label: "Webhook \u8DEF\u5F84\uFF08\u9700\u4E0E\u4F01\u4E1A\u5FAE\u4FE1\u540E\u53F0\u914D\u7F6E\u4E00\u81F4\uFF0C\u9ED8\u8BA4 /wecom\uFF09",
6566
+ defaultValue: toTrimmedString(existing.webhookPath) ?? "/wecom",
6567
+ required: true
6568
+ });
6569
+ const token = await prompter.askSecret({
6570
+ label: "WeCom token",
6571
+ existingValue: toTrimmedString(existing.token),
6572
+ required: true
6573
+ });
6574
+ const encodingAESKey = await prompter.askSecret({
6575
+ label: "WeCom encodingAESKey",
6576
+ existingValue: toTrimmedString(existing.encodingAESKey),
6577
+ required: true
6578
+ });
6579
+ return mergeChannelConfig(cfg, "wecom", {
6580
+ webhookPath,
6581
+ token,
6582
+ encodingAESKey
6583
+ });
6584
+ }
6585
+ async function configureWecomApp(prompter, cfg) {
6586
+ section("\u914D\u7F6E WeCom App\uFF08\u81EA\u5EFA\u5E94\u7528-\u53EF\u63A5\u5165\u5FAE\u4FE1\uFF09");
6587
+ showGuideLink("wecom-app");
6588
+ const existing = getChannelConfig(cfg, "wecom-app");
6589
+ const webhookPath = await prompter.askText({
6590
+ label: "Webhook \u8DEF\u5F84\uFF08\u9700\u4E0E\u4F01\u4E1A\u5FAE\u4FE1\u540E\u53F0\u914D\u7F6E\u4E00\u81F4\uFF0C\u9ED8\u8BA4 /wecom-app\uFF09",
6591
+ defaultValue: toTrimmedString(existing.webhookPath) ?? "/wecom-app",
6592
+ required: true
6593
+ });
6594
+ const token = await prompter.askSecret({
6595
+ label: "WeCom App token",
6596
+ existingValue: toTrimmedString(existing.token),
6597
+ required: true
6598
+ });
6599
+ const encodingAESKey = await prompter.askSecret({
6600
+ label: "WeCom App encodingAESKey",
6601
+ existingValue: toTrimmedString(existing.encodingAESKey),
6602
+ required: true
6603
+ });
6604
+ const patch = {
6605
+ webhookPath,
6606
+ token,
6607
+ encodingAESKey
6608
+ };
6609
+ const corpId = await prompter.askText({
6610
+ label: "corpId",
6611
+ defaultValue: toTrimmedString(existing.corpId),
6612
+ required: true
6613
+ });
6614
+ const corpSecret = await prompter.askSecret({
6615
+ label: "corpSecret",
6616
+ existingValue: toTrimmedString(existing.corpSecret),
6617
+ required: true
6618
+ });
6619
+ const agentId = await prompter.askNumber({
6620
+ label: "agentId",
6621
+ min: 1,
6622
+ defaultValue: toNumber(existing.agentId)
6623
+ });
6624
+ patch.corpId = corpId;
6625
+ patch.corpSecret = corpSecret;
6626
+ patch.agentId = agentId;
6627
+ return mergeChannelConfig(cfg, "wecom-app", patch);
6628
+ }
6629
+ async function configureQQBot(prompter, cfg) {
6630
+ section("\u914D\u7F6E QQBot\uFF08QQ \u673A\u5668\u4EBA\uFF09");
6631
+ showGuideLink("qqbot");
6632
+ const existing = getChannelConfig(cfg, "qqbot");
6633
+ const appId = await prompter.askText({
6634
+ label: "QQBot appId",
6635
+ defaultValue: toTrimmedString(existing.appId),
6636
+ required: true
6637
+ });
6638
+ const clientSecret = await prompter.askSecret({
6639
+ label: "QQBot clientSecret",
6640
+ existingValue: toTrimmedString(existing.clientSecret),
6641
+ required: true
6642
+ });
6643
+ const markdownSupport = await prompter.askConfirm(
6644
+ "\u542F\u7528 Markdown \u652F\u6301",
6645
+ toBoolean(existing.markdownSupport, false)
6646
+ );
6647
+ const replyFinalOnly = await prompter.askConfirm(
6648
+ "\u4EC5\u53D1\u9001\u6700\u7EC8\u56DE\u590D\uFF08\u5173\u95ED\u6D41\u5F0F\u5206\u7247\uFF09",
6649
+ toBoolean(existing.replyFinalOnly, false)
6650
+ );
6651
+ return mergeChannelConfig(cfg, "qqbot", {
6652
+ appId,
6653
+ clientSecret,
6654
+ markdownSupport,
6655
+ replyFinalOnly
6656
+ });
6657
+ }
6658
+ async function configureSingleChannel(channel, prompter, cfg) {
6659
+ switch (channel) {
6660
+ case "dingtalk":
6661
+ return configureDingtalk(prompter, cfg);
6662
+ case "feishu-china":
6663
+ return configureFeishu(prompter, cfg);
6664
+ case "wecom":
6665
+ return configureWecom(prompter, cfg);
6666
+ case "wecom-app":
6667
+ return configureWecomApp(prompter, cfg);
6668
+ case "qqbot":
6669
+ return configureQQBot(prompter, cfg);
6670
+ default:
6671
+ return cfg;
6672
+ }
6673
+ }
6674
+ async function runChinaSetup(params) {
6675
+ if (!stdin.isTTY || !stdout.isTTY) {
6676
+ params.logger.error?.("\u4EA4\u4E92\u5F0F\u914D\u7F6E\u9700\u8981\u5728 TTY \u7EC8\u7AEF\u4E2D\u8FD0\u884C\u3002");
6677
+ return;
6678
+ }
6679
+ const prompter = new SetupPrompter();
6680
+ const touched = /* @__PURE__ */ new Set();
6681
+ let next = cloneConfig(params.initialConfig);
6682
+ try {
6683
+ We("OpenClaw China \u914D\u7F6E\u5411\u5BFC");
6684
+ Ve(
6685
+ [
6686
+ "\u4F7F\u7528\u65B9\u5411\u952E\u9009\u62E9\uFF0C\u6309 Enter \u786E\u8BA4\u3002",
6687
+ `\u9879\u76EE\u4ED3\u5E93\uFF1A${ANSI_LINK}${PROJECT_REPO}${ANSI_RESET}`
6688
+ ].join("\n"),
6689
+ "\u6B22\u8FCE"
6690
+ );
6691
+ if (params.availableChannels.length === 0) {
6692
+ params.logger.error?.("\u672A\u68C0\u6D4B\u5230\u53EF\u914D\u7F6E\u7684 China \u6E20\u9053\u63D2\u4EF6\u3002");
6693
+ return;
6694
+ }
6695
+ const channelOptions = params.availableChannels.map((channelId, index) => ({
6696
+ key: index === 0 ? "recommended" : "",
6697
+ value: channelId,
6698
+ label: withConfiguredSuffix(next, channelId)
6699
+ }));
6700
+ const defaultChannel = channelOptions[0]?.value ?? "save";
6701
+ let continueLoop = true;
6702
+ while (continueLoop) {
6703
+ const selected = await prompter.askSelect(
6704
+ "\u8BF7\u9009\u62E9\u8981\u914D\u7F6E\u7684\u6E20\u9053",
6705
+ [
6706
+ ...channelOptions,
6707
+ { key: "", value: "save", label: "\u4FDD\u5B58\u5E76\u9000\u51FA" },
6708
+ { key: "", value: "cancel", label: "\u4E0D\u4FDD\u5B58\u5E76\u9000\u51FA" }
6709
+ ],
6710
+ defaultChannel
6711
+ );
6712
+ if (selected === "cancel") {
6713
+ Ne("\u5DF2\u53D6\u6D88\uFF0C\u672A\u5199\u5165\u4EFB\u4F55\u914D\u7F6E\u3002");
6714
+ return;
6715
+ }
6716
+ if (selected === "save") {
6717
+ break;
6718
+ }
6719
+ next = await configureSingleChannel(selected, prompter, next);
6720
+ touched.add(selected);
6721
+ Ve(`\u5DF2\u5B8C\u6210\uFF1A${CHANNEL_DISPLAY_LABELS[selected]}`, "\u5B8C\u6210");
6722
+ continueLoop = await prompter.askConfirm("\u7EE7\u7EED\u914D\u7F6E\u5176\u4ED6\u6E20\u9053", true);
6723
+ }
6724
+ if (touched.size === 0) {
6725
+ Ne("\u672A\u8FDB\u884C\u4EFB\u4F55\u4FEE\u6539\u3002");
6726
+ return;
6727
+ }
6728
+ Ve(
6729
+ `\u5DF2\u914D\u7F6E\u6E20\u9053\uFF1A${Array.from(touched).map((channelId) => CHANNEL_DISPLAY_LABELS[channelId]).join(", ")}`,
6730
+ "\u6458\u8981"
6731
+ );
6732
+ if (!params.writeConfig) {
6733
+ params.logger.error?.("\u65E0\u6CD5\u4FDD\u5B58\u914D\u7F6E\uFF1A\u5F53\u524D\u8FD0\u884C\u65F6\u672A\u63D0\u4F9B\u914D\u7F6E\u5199\u5165\u80FD\u529B\u3002");
6734
+ return;
6735
+ }
6736
+ await params.writeConfig(next);
6737
+ Le("\u914D\u7F6E\u5DF2\u4FDD\u5B58\u3002");
6738
+ showReadyMessage();
6739
+ } catch (err) {
6740
+ if (err instanceof PromptCancelledError) {
6741
+ return;
6742
+ }
6743
+ throw err;
6744
+ }
6745
+ }
6746
+ function registerChinaSetupCli(api, opts) {
6747
+ const state = getChinaCliState();
6748
+ for (const channelId of normalizeChannels(opts?.channels)) {
6749
+ state.channels.add(channelId);
6750
+ }
6751
+ if (state.cliRegistered || typeof api.registerCli !== "function") {
6752
+ return;
6753
+ }
6754
+ state.cliRegistered = true;
6755
+ const writeConfig = resolveWriteConfig(api.runtime);
6756
+ const fallbackLogger = {
6757
+ info: (message) => stdout.write(`${message}
6758
+ `),
6759
+ warn: (message) => warn(message),
6760
+ error: (message) => warn(message)
6761
+ };
6762
+ api.registerCli(
6763
+ (ctx) => {
6764
+ if (!isCommandLike(ctx.program)) {
6765
+ const logger = ctx.logger ?? api.logger ?? fallbackLogger;
6766
+ logger.error?.("\u65E0\u6CD5\u6CE8\u518C china \u547D\u4EE4\uFF1ACLI program \u5B9E\u4F8B\u65E0\u6548\u3002");
6767
+ return;
6768
+ }
6769
+ const root = ctx.program.command("china").description("OpenClaw China \u63D2\u4EF6\u547D\u4EE4");
6770
+ root.command("setup").description("\u4E2D\u56FD\u6E20\u9053\u4EA4\u4E92\u5F0F\u914D\u7F6E\u5411\u5BFC").action(async () => {
6771
+ const logger = ctx.logger ?? api.logger ?? fallbackLogger;
6772
+ const availableChannels = getInstalledChannels(state);
6773
+ await runChinaSetup({
6774
+ initialConfig: isRecord(ctx.config) ? ctx.config : {},
6775
+ writeConfig,
6776
+ logger,
6777
+ availableChannels
6778
+ });
6779
+ });
6780
+ root.command("about").description("\u663E\u793A\u9879\u76EE\u4FE1\u606F").action(() => {
6781
+ const installed = getInstalledChannels(state);
6782
+ We("OpenClaw China \u6E20\u9053\u63D2\u4EF6");
6783
+ Ve(
6784
+ installed.length > 0 ? `\u5F53\u524D\u5DF2\u5B89\u88C5\u6E20\u9053\uFF1A${installed.map((channelId) => CHANNEL_DISPLAY_LABELS[channelId]).join("\u3001")}` : "OpenClaw China \u6E20\u9053\u63D2\u4EF6",
6785
+ "\u5173\u4E8E"
6786
+ );
6787
+ Le(PROJECT_REPO);
6788
+ showReadyMessage();
6789
+ });
6790
+ },
6791
+ { commands: ["china"] }
6792
+ );
6793
+ }
6794
+
5262
6795
  // src/client.ts
5263
6796
  var API_BASE = "https://api.sgroup.qq.com";
5264
6797
  var TOKEN_URL = "https://bots.qq.com/app/getAppAccessToken";
@@ -5754,7 +7287,7 @@ function toString(value) {
5754
7287
  if (typeof value === "string" && value.trim()) return value;
5755
7288
  return void 0;
5756
7289
  }
5757
- function toNumber(value) {
7290
+ function toNumber2(value) {
5758
7291
  if (typeof value === "number" && Number.isFinite(value)) return value;
5759
7292
  if (typeof value === "string") {
5760
7293
  const parsed = Date.parse(value);
@@ -5988,7 +7521,7 @@ function parseC2CMessage(data) {
5988
7521
  const payload = data;
5989
7522
  const { text, attachments } = parseTextWithAttachments(payload);
5990
7523
  const id = toString(payload.id);
5991
- const timestamp = toNumber(payload.timestamp) ?? Date.now();
7524
+ const timestamp = toNumber2(payload.timestamp) ?? Date.now();
5992
7525
  const author = payload.author ?? {};
5993
7526
  const senderId = toString(author.user_openid);
5994
7527
  if (!text && attachments.length === 0 || !id || !senderId) return null;
@@ -6008,7 +7541,7 @@ function parseGroupMessage(data) {
6008
7541
  const payload = data;
6009
7542
  const { text, attachments } = parseTextWithAttachments(payload);
6010
7543
  const id = toString(payload.id);
6011
- const timestamp = toNumber(payload.timestamp) ?? Date.now();
7544
+ const timestamp = toNumber2(payload.timestamp) ?? Date.now();
6012
7545
  const groupOpenid = toString(payload.group_openid);
6013
7546
  const author = payload.author ?? {};
6014
7547
  const senderId = toString(author.member_openid);
@@ -6029,7 +7562,7 @@ function parseChannelMessage(data) {
6029
7562
  const payload = data;
6030
7563
  const { text, attachments } = parseTextWithAttachments(payload);
6031
7564
  const id = toString(payload.id);
6032
- const timestamp = toNumber(payload.timestamp) ?? Date.now();
7565
+ const timestamp = toNumber2(payload.timestamp) ?? Date.now();
6033
7566
  const channelId = toString(payload.channel_id);
6034
7567
  const guildId = toString(payload.guild_id);
6035
7568
  const author = payload.author ?? {};
@@ -6052,7 +7585,7 @@ function parseDirectMessage(data) {
6052
7585
  const payload = data;
6053
7586
  const { text, attachments } = parseTextWithAttachments(payload);
6054
7587
  const id = toString(payload.id);
6055
- const timestamp = toNumber(payload.timestamp) ?? Date.now();
7588
+ const timestamp = toNumber2(payload.timestamp) ?? Date.now();
6056
7589
  const guildId = toString(payload.guild_id);
6057
7590
  const author = payload.author ?? {};
6058
7591
  const senderId = toString(author.id);
@@ -7050,6 +8583,7 @@ var plugin = {
7050
8583
  }
7051
8584
  },
7052
8585
  register(api) {
8586
+ registerChinaSetupCli(api, { channels: ["qqbot"] });
7053
8587
  if (api.runtime) {
7054
8588
  setQQBotRuntime(api.runtime);
7055
8589
  }