@openclaw-china/wecom 0.1.21 → 0.1.23

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,18 +1,174 @@
1
1
  import * as path3 from 'path';
2
- import path3__default from 'path';
2
+ import path3__default, { join } from 'path';
3
3
  import * as fsPromises from 'fs/promises';
4
4
  import { access } from 'fs/promises';
5
5
  import crypto, { randomBytes } from 'crypto';
6
6
  import * as fs3 from 'fs';
7
- import { promises } from 'fs';
7
+ import { promises, existsSync } from 'fs';
8
8
  import * as os2 from 'os';
9
+ import { homedir } from 'os';
9
10
  import { fileURLToPath } from 'url';
11
+ import N2, { stdout, stdin } from 'process';
12
+ import ot from 'readline';
13
+ import 'tty';
14
+ import 'util';
10
15
 
16
+ var __create = Object.create;
11
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
+ };
12
25
  var __export = (target, all) => {
13
26
  for (var name in all)
14
27
  __defProp(target, name, { get: all[name], enumerable: true });
15
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
+ });
16
172
 
17
173
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
18
174
  var external_exports = {};
@@ -129,7 +285,7 @@ __export(external_exports, {
129
285
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
130
286
  var util;
131
287
  (function(util2) {
132
- util2.assertEqual = (_) => {
288
+ util2.assertEqual = (_2) => {
133
289
  };
134
290
  function assertIs(_arg) {
135
291
  }
@@ -146,16 +302,16 @@ var util;
146
302
  return obj;
147
303
  };
148
304
  util2.getValidEnumValues = (obj) => {
149
- 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");
150
306
  const filtered = {};
151
- for (const k of validKeys) {
152
- filtered[k] = obj[k];
307
+ for (const k2 of validKeys) {
308
+ filtered[k2] = obj[k2];
153
309
  }
154
310
  return util2.objectValues(filtered);
155
311
  };
156
312
  util2.objectValues = (obj) => {
157
- return util2.objectKeys(obj).map(function(e) {
158
- return obj[e];
313
+ return util2.objectKeys(obj).map(function(e2) {
314
+ return obj[e2];
159
315
  });
160
316
  };
161
317
  util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
@@ -179,7 +335,7 @@ var util;
179
335
  return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
180
336
  }
181
337
  util2.joinValues = joinValues;
182
- util2.jsonStringifyReplacer = (_, value) => {
338
+ util2.jsonStringifyReplacer = (_2, value) => {
183
339
  if (typeof value === "bigint") {
184
340
  return value.toString();
185
341
  }
@@ -532,7 +688,7 @@ function addIssueToContext(ctx, issueData) {
532
688
  // then global override map
533
689
  overrideMap === en_default ? void 0 : en_default
534
690
  // then global default map
535
- ].filter((x) => !!x)
691
+ ].filter((x3) => !!x3)
536
692
  });
537
693
  ctx.common.issues.push(issue);
538
694
  }
@@ -595,10 +751,10 @@ var INVALID = Object.freeze({
595
751
  });
596
752
  var DIRTY = (value) => ({ status: "dirty", value });
597
753
  var OK = (value) => ({ status: "valid", value });
598
- var isAborted = (x) => x.status === "aborted";
599
- var isDirty = (x) => x.status === "dirty";
600
- var isValid = (x) => x.status === "valid";
601
- 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;
602
758
 
603
759
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
604
760
  var errorUtil;
@@ -673,41 +829,41 @@ var ZodType = class {
673
829
  get description() {
674
830
  return this._def.description;
675
831
  }
676
- _getType(input) {
677
- return getParsedType(input.data);
832
+ _getType(input2) {
833
+ return getParsedType(input2.data);
678
834
  }
679
- _getOrReturnCtx(input, ctx) {
835
+ _getOrReturnCtx(input2, ctx) {
680
836
  return ctx || {
681
- common: input.parent.common,
682
- data: input.data,
683
- parsedType: getParsedType(input.data),
837
+ common: input2.parent.common,
838
+ data: input2.data,
839
+ parsedType: getParsedType(input2.data),
684
840
  schemaErrorMap: this._def.errorMap,
685
- path: input.path,
686
- parent: input.parent
841
+ path: input2.path,
842
+ parent: input2.parent
687
843
  };
688
844
  }
689
- _processInputParams(input) {
845
+ _processInputParams(input2) {
690
846
  return {
691
847
  status: new ParseStatus(),
692
848
  ctx: {
693
- common: input.parent.common,
694
- data: input.data,
695
- parsedType: getParsedType(input.data),
849
+ common: input2.parent.common,
850
+ data: input2.data,
851
+ parsedType: getParsedType(input2.data),
696
852
  schemaErrorMap: this._def.errorMap,
697
- path: input.path,
698
- parent: input.parent
853
+ path: input2.path,
854
+ parent: input2.parent
699
855
  }
700
856
  };
701
857
  }
702
- _parseSync(input) {
703
- const result = this._parse(input);
858
+ _parseSync(input2) {
859
+ const result = this._parse(input2);
704
860
  if (isAsync(result)) {
705
861
  throw new Error("Synchronous parse encountered promise.");
706
862
  }
707
863
  return result;
708
864
  }
709
- _parseAsync(input) {
710
- const result = this._parse(input);
865
+ _parseAsync(input2) {
866
+ const result = this._parse(input2);
711
867
  return Promise.resolve(result);
712
868
  }
713
869
  parse(data, params) {
@@ -1033,13 +1189,13 @@ function isValidCidr(ip, version) {
1033
1189
  return false;
1034
1190
  }
1035
1191
  var ZodString = class _ZodString extends ZodType {
1036
- _parse(input) {
1192
+ _parse(input2) {
1037
1193
  if (this._def.coerce) {
1038
- input.data = String(input.data);
1194
+ input2.data = String(input2.data);
1039
1195
  }
1040
- const parsedType = this._getType(input);
1196
+ const parsedType = this._getType(input2);
1041
1197
  if (parsedType !== ZodParsedType.string) {
1042
- const ctx2 = this._getOrReturnCtx(input);
1198
+ const ctx2 = this._getOrReturnCtx(input2);
1043
1199
  addIssueToContext(ctx2, {
1044
1200
  code: ZodIssueCode.invalid_type,
1045
1201
  expected: ZodParsedType.string,
@@ -1051,8 +1207,8 @@ var ZodString = class _ZodString extends ZodType {
1051
1207
  let ctx = void 0;
1052
1208
  for (const check of this._def.checks) {
1053
1209
  if (check.kind === "min") {
1054
- if (input.data.length < check.value) {
1055
- ctx = this._getOrReturnCtx(input, ctx);
1210
+ if (input2.data.length < check.value) {
1211
+ ctx = this._getOrReturnCtx(input2, ctx);
1056
1212
  addIssueToContext(ctx, {
1057
1213
  code: ZodIssueCode.too_small,
1058
1214
  minimum: check.value,
@@ -1064,8 +1220,8 @@ var ZodString = class _ZodString extends ZodType {
1064
1220
  status.dirty();
1065
1221
  }
1066
1222
  } else if (check.kind === "max") {
1067
- if (input.data.length > check.value) {
1068
- ctx = this._getOrReturnCtx(input, ctx);
1223
+ if (input2.data.length > check.value) {
1224
+ ctx = this._getOrReturnCtx(input2, ctx);
1069
1225
  addIssueToContext(ctx, {
1070
1226
  code: ZodIssueCode.too_big,
1071
1227
  maximum: check.value,
@@ -1077,10 +1233,10 @@ var ZodString = class _ZodString extends ZodType {
1077
1233
  status.dirty();
1078
1234
  }
1079
1235
  } else if (check.kind === "length") {
1080
- const tooBig = input.data.length > check.value;
1081
- const tooSmall = input.data.length < check.value;
1236
+ const tooBig = input2.data.length > check.value;
1237
+ const tooSmall = input2.data.length < check.value;
1082
1238
  if (tooBig || tooSmall) {
1083
- ctx = this._getOrReturnCtx(input, ctx);
1239
+ ctx = this._getOrReturnCtx(input2, ctx);
1084
1240
  if (tooBig) {
1085
1241
  addIssueToContext(ctx, {
1086
1242
  code: ZodIssueCode.too_big,
@@ -1103,8 +1259,8 @@ var ZodString = class _ZodString extends ZodType {
1103
1259
  status.dirty();
1104
1260
  }
1105
1261
  } else if (check.kind === "email") {
1106
- if (!emailRegex.test(input.data)) {
1107
- ctx = this._getOrReturnCtx(input, ctx);
1262
+ if (!emailRegex.test(input2.data)) {
1263
+ ctx = this._getOrReturnCtx(input2, ctx);
1108
1264
  addIssueToContext(ctx, {
1109
1265
  validation: "email",
1110
1266
  code: ZodIssueCode.invalid_string,
@@ -1116,8 +1272,8 @@ var ZodString = class _ZodString extends ZodType {
1116
1272
  if (!emojiRegex) {
1117
1273
  emojiRegex = new RegExp(_emojiRegex, "u");
1118
1274
  }
1119
- if (!emojiRegex.test(input.data)) {
1120
- ctx = this._getOrReturnCtx(input, ctx);
1275
+ if (!emojiRegex.test(input2.data)) {
1276
+ ctx = this._getOrReturnCtx(input2, ctx);
1121
1277
  addIssueToContext(ctx, {
1122
1278
  validation: "emoji",
1123
1279
  code: ZodIssueCode.invalid_string,
@@ -1126,8 +1282,8 @@ var ZodString = class _ZodString extends ZodType {
1126
1282
  status.dirty();
1127
1283
  }
1128
1284
  } else if (check.kind === "uuid") {
1129
- if (!uuidRegex.test(input.data)) {
1130
- ctx = this._getOrReturnCtx(input, ctx);
1285
+ if (!uuidRegex.test(input2.data)) {
1286
+ ctx = this._getOrReturnCtx(input2, ctx);
1131
1287
  addIssueToContext(ctx, {
1132
1288
  validation: "uuid",
1133
1289
  code: ZodIssueCode.invalid_string,
@@ -1136,8 +1292,8 @@ var ZodString = class _ZodString extends ZodType {
1136
1292
  status.dirty();
1137
1293
  }
1138
1294
  } else if (check.kind === "nanoid") {
1139
- if (!nanoidRegex.test(input.data)) {
1140
- ctx = this._getOrReturnCtx(input, ctx);
1295
+ if (!nanoidRegex.test(input2.data)) {
1296
+ ctx = this._getOrReturnCtx(input2, ctx);
1141
1297
  addIssueToContext(ctx, {
1142
1298
  validation: "nanoid",
1143
1299
  code: ZodIssueCode.invalid_string,
@@ -1146,8 +1302,8 @@ var ZodString = class _ZodString extends ZodType {
1146
1302
  status.dirty();
1147
1303
  }
1148
1304
  } else if (check.kind === "cuid") {
1149
- if (!cuidRegex.test(input.data)) {
1150
- ctx = this._getOrReturnCtx(input, ctx);
1305
+ if (!cuidRegex.test(input2.data)) {
1306
+ ctx = this._getOrReturnCtx(input2, ctx);
1151
1307
  addIssueToContext(ctx, {
1152
1308
  validation: "cuid",
1153
1309
  code: ZodIssueCode.invalid_string,
@@ -1156,8 +1312,8 @@ var ZodString = class _ZodString extends ZodType {
1156
1312
  status.dirty();
1157
1313
  }
1158
1314
  } else if (check.kind === "cuid2") {
1159
- if (!cuid2Regex.test(input.data)) {
1160
- ctx = this._getOrReturnCtx(input, ctx);
1315
+ if (!cuid2Regex.test(input2.data)) {
1316
+ ctx = this._getOrReturnCtx(input2, ctx);
1161
1317
  addIssueToContext(ctx, {
1162
1318
  validation: "cuid2",
1163
1319
  code: ZodIssueCode.invalid_string,
@@ -1166,8 +1322,8 @@ var ZodString = class _ZodString extends ZodType {
1166
1322
  status.dirty();
1167
1323
  }
1168
1324
  } else if (check.kind === "ulid") {
1169
- if (!ulidRegex.test(input.data)) {
1170
- ctx = this._getOrReturnCtx(input, ctx);
1325
+ if (!ulidRegex.test(input2.data)) {
1326
+ ctx = this._getOrReturnCtx(input2, ctx);
1171
1327
  addIssueToContext(ctx, {
1172
1328
  validation: "ulid",
1173
1329
  code: ZodIssueCode.invalid_string,
@@ -1177,9 +1333,9 @@ var ZodString = class _ZodString extends ZodType {
1177
1333
  }
1178
1334
  } else if (check.kind === "url") {
1179
1335
  try {
1180
- new URL(input.data);
1336
+ new URL(input2.data);
1181
1337
  } catch {
1182
- ctx = this._getOrReturnCtx(input, ctx);
1338
+ ctx = this._getOrReturnCtx(input2, ctx);
1183
1339
  addIssueToContext(ctx, {
1184
1340
  validation: "url",
1185
1341
  code: ZodIssueCode.invalid_string,
@@ -1189,9 +1345,9 @@ var ZodString = class _ZodString extends ZodType {
1189
1345
  }
1190
1346
  } else if (check.kind === "regex") {
1191
1347
  check.regex.lastIndex = 0;
1192
- const testResult = check.regex.test(input.data);
1348
+ const testResult = check.regex.test(input2.data);
1193
1349
  if (!testResult) {
1194
- ctx = this._getOrReturnCtx(input, ctx);
1350
+ ctx = this._getOrReturnCtx(input2, ctx);
1195
1351
  addIssueToContext(ctx, {
1196
1352
  validation: "regex",
1197
1353
  code: ZodIssueCode.invalid_string,
@@ -1200,10 +1356,10 @@ var ZodString = class _ZodString extends ZodType {
1200
1356
  status.dirty();
1201
1357
  }
1202
1358
  } else if (check.kind === "trim") {
1203
- input.data = input.data.trim();
1359
+ input2.data = input2.data.trim();
1204
1360
  } else if (check.kind === "includes") {
1205
- if (!input.data.includes(check.value, check.position)) {
1206
- ctx = this._getOrReturnCtx(input, ctx);
1361
+ if (!input2.data.includes(check.value, check.position)) {
1362
+ ctx = this._getOrReturnCtx(input2, ctx);
1207
1363
  addIssueToContext(ctx, {
1208
1364
  code: ZodIssueCode.invalid_string,
1209
1365
  validation: { includes: check.value, position: check.position },
@@ -1212,12 +1368,12 @@ var ZodString = class _ZodString extends ZodType {
1212
1368
  status.dirty();
1213
1369
  }
1214
1370
  } else if (check.kind === "toLowerCase") {
1215
- input.data = input.data.toLowerCase();
1371
+ input2.data = input2.data.toLowerCase();
1216
1372
  } else if (check.kind === "toUpperCase") {
1217
- input.data = input.data.toUpperCase();
1373
+ input2.data = input2.data.toUpperCase();
1218
1374
  } else if (check.kind === "startsWith") {
1219
- if (!input.data.startsWith(check.value)) {
1220
- ctx = this._getOrReturnCtx(input, ctx);
1375
+ if (!input2.data.startsWith(check.value)) {
1376
+ ctx = this._getOrReturnCtx(input2, ctx);
1221
1377
  addIssueToContext(ctx, {
1222
1378
  code: ZodIssueCode.invalid_string,
1223
1379
  validation: { startsWith: check.value },
@@ -1226,8 +1382,8 @@ var ZodString = class _ZodString extends ZodType {
1226
1382
  status.dirty();
1227
1383
  }
1228
1384
  } else if (check.kind === "endsWith") {
1229
- if (!input.data.endsWith(check.value)) {
1230
- ctx = this._getOrReturnCtx(input, ctx);
1385
+ if (!input2.data.endsWith(check.value)) {
1386
+ ctx = this._getOrReturnCtx(input2, ctx);
1231
1387
  addIssueToContext(ctx, {
1232
1388
  code: ZodIssueCode.invalid_string,
1233
1389
  validation: { endsWith: check.value },
@@ -1237,8 +1393,8 @@ var ZodString = class _ZodString extends ZodType {
1237
1393
  }
1238
1394
  } else if (check.kind === "datetime") {
1239
1395
  const regex = datetimeRegex(check);
1240
- if (!regex.test(input.data)) {
1241
- ctx = this._getOrReturnCtx(input, ctx);
1396
+ if (!regex.test(input2.data)) {
1397
+ ctx = this._getOrReturnCtx(input2, ctx);
1242
1398
  addIssueToContext(ctx, {
1243
1399
  code: ZodIssueCode.invalid_string,
1244
1400
  validation: "datetime",
@@ -1248,8 +1404,8 @@ var ZodString = class _ZodString extends ZodType {
1248
1404
  }
1249
1405
  } else if (check.kind === "date") {
1250
1406
  const regex = dateRegex;
1251
- if (!regex.test(input.data)) {
1252
- ctx = this._getOrReturnCtx(input, ctx);
1407
+ if (!regex.test(input2.data)) {
1408
+ ctx = this._getOrReturnCtx(input2, ctx);
1253
1409
  addIssueToContext(ctx, {
1254
1410
  code: ZodIssueCode.invalid_string,
1255
1411
  validation: "date",
@@ -1259,8 +1415,8 @@ var ZodString = class _ZodString extends ZodType {
1259
1415
  }
1260
1416
  } else if (check.kind === "time") {
1261
1417
  const regex = timeRegex(check);
1262
- if (!regex.test(input.data)) {
1263
- ctx = this._getOrReturnCtx(input, ctx);
1418
+ if (!regex.test(input2.data)) {
1419
+ ctx = this._getOrReturnCtx(input2, ctx);
1264
1420
  addIssueToContext(ctx, {
1265
1421
  code: ZodIssueCode.invalid_string,
1266
1422
  validation: "time",
@@ -1269,8 +1425,8 @@ var ZodString = class _ZodString extends ZodType {
1269
1425
  status.dirty();
1270
1426
  }
1271
1427
  } else if (check.kind === "duration") {
1272
- if (!durationRegex.test(input.data)) {
1273
- ctx = this._getOrReturnCtx(input, ctx);
1428
+ if (!durationRegex.test(input2.data)) {
1429
+ ctx = this._getOrReturnCtx(input2, ctx);
1274
1430
  addIssueToContext(ctx, {
1275
1431
  validation: "duration",
1276
1432
  code: ZodIssueCode.invalid_string,
@@ -1279,8 +1435,8 @@ var ZodString = class _ZodString extends ZodType {
1279
1435
  status.dirty();
1280
1436
  }
1281
1437
  } else if (check.kind === "ip") {
1282
- if (!isValidIP(input.data, check.version)) {
1283
- ctx = this._getOrReturnCtx(input, ctx);
1438
+ if (!isValidIP(input2.data, check.version)) {
1439
+ ctx = this._getOrReturnCtx(input2, ctx);
1284
1440
  addIssueToContext(ctx, {
1285
1441
  validation: "ip",
1286
1442
  code: ZodIssueCode.invalid_string,
@@ -1289,8 +1445,8 @@ var ZodString = class _ZodString extends ZodType {
1289
1445
  status.dirty();
1290
1446
  }
1291
1447
  } else if (check.kind === "jwt") {
1292
- if (!isValidJWT(input.data, check.alg)) {
1293
- ctx = this._getOrReturnCtx(input, ctx);
1448
+ if (!isValidJWT(input2.data, check.alg)) {
1449
+ ctx = this._getOrReturnCtx(input2, ctx);
1294
1450
  addIssueToContext(ctx, {
1295
1451
  validation: "jwt",
1296
1452
  code: ZodIssueCode.invalid_string,
@@ -1299,8 +1455,8 @@ var ZodString = class _ZodString extends ZodType {
1299
1455
  status.dirty();
1300
1456
  }
1301
1457
  } else if (check.kind === "cidr") {
1302
- if (!isValidCidr(input.data, check.version)) {
1303
- ctx = this._getOrReturnCtx(input, ctx);
1458
+ if (!isValidCidr(input2.data, check.version)) {
1459
+ ctx = this._getOrReturnCtx(input2, ctx);
1304
1460
  addIssueToContext(ctx, {
1305
1461
  validation: "cidr",
1306
1462
  code: ZodIssueCode.invalid_string,
@@ -1309,8 +1465,8 @@ var ZodString = class _ZodString extends ZodType {
1309
1465
  status.dirty();
1310
1466
  }
1311
1467
  } else if (check.kind === "base64") {
1312
- if (!base64Regex.test(input.data)) {
1313
- ctx = this._getOrReturnCtx(input, ctx);
1468
+ if (!base64Regex.test(input2.data)) {
1469
+ ctx = this._getOrReturnCtx(input2, ctx);
1314
1470
  addIssueToContext(ctx, {
1315
1471
  validation: "base64",
1316
1472
  code: ZodIssueCode.invalid_string,
@@ -1319,8 +1475,8 @@ var ZodString = class _ZodString extends ZodType {
1319
1475
  status.dirty();
1320
1476
  }
1321
1477
  } else if (check.kind === "base64url") {
1322
- if (!base64urlRegex.test(input.data)) {
1323
- ctx = this._getOrReturnCtx(input, ctx);
1478
+ if (!base64urlRegex.test(input2.data)) {
1479
+ ctx = this._getOrReturnCtx(input2, ctx);
1324
1480
  addIssueToContext(ctx, {
1325
1481
  validation: "base64url",
1326
1482
  code: ZodIssueCode.invalid_string,
@@ -1332,7 +1488,7 @@ var ZodString = class _ZodString extends ZodType {
1332
1488
  util.assertNever(check);
1333
1489
  }
1334
1490
  }
1335
- return { status: status.value, value: input.data };
1491
+ return { status: status.value, value: input2.data };
1336
1492
  }
1337
1493
  _regex(regex, validation, message) {
1338
1494
  return this.refinement((data) => regex.test(data), {
@@ -1593,13 +1749,13 @@ var ZodNumber = class _ZodNumber extends ZodType {
1593
1749
  this.max = this.lte;
1594
1750
  this.step = this.multipleOf;
1595
1751
  }
1596
- _parse(input) {
1752
+ _parse(input2) {
1597
1753
  if (this._def.coerce) {
1598
- input.data = Number(input.data);
1754
+ input2.data = Number(input2.data);
1599
1755
  }
1600
- const parsedType = this._getType(input);
1756
+ const parsedType = this._getType(input2);
1601
1757
  if (parsedType !== ZodParsedType.number) {
1602
- const ctx2 = this._getOrReturnCtx(input);
1758
+ const ctx2 = this._getOrReturnCtx(input2);
1603
1759
  addIssueToContext(ctx2, {
1604
1760
  code: ZodIssueCode.invalid_type,
1605
1761
  expected: ZodParsedType.number,
@@ -1611,8 +1767,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
1611
1767
  const status = new ParseStatus();
1612
1768
  for (const check of this._def.checks) {
1613
1769
  if (check.kind === "int") {
1614
- if (!util.isInteger(input.data)) {
1615
- ctx = this._getOrReturnCtx(input, ctx);
1770
+ if (!util.isInteger(input2.data)) {
1771
+ ctx = this._getOrReturnCtx(input2, ctx);
1616
1772
  addIssueToContext(ctx, {
1617
1773
  code: ZodIssueCode.invalid_type,
1618
1774
  expected: "integer",
@@ -1622,9 +1778,9 @@ var ZodNumber = class _ZodNumber extends ZodType {
1622
1778
  status.dirty();
1623
1779
  }
1624
1780
  } else if (check.kind === "min") {
1625
- 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;
1626
1782
  if (tooSmall) {
1627
- ctx = this._getOrReturnCtx(input, ctx);
1783
+ ctx = this._getOrReturnCtx(input2, ctx);
1628
1784
  addIssueToContext(ctx, {
1629
1785
  code: ZodIssueCode.too_small,
1630
1786
  minimum: check.value,
@@ -1636,9 +1792,9 @@ var ZodNumber = class _ZodNumber extends ZodType {
1636
1792
  status.dirty();
1637
1793
  }
1638
1794
  } else if (check.kind === "max") {
1639
- 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;
1640
1796
  if (tooBig) {
1641
- ctx = this._getOrReturnCtx(input, ctx);
1797
+ ctx = this._getOrReturnCtx(input2, ctx);
1642
1798
  addIssueToContext(ctx, {
1643
1799
  code: ZodIssueCode.too_big,
1644
1800
  maximum: check.value,
@@ -1650,8 +1806,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
1650
1806
  status.dirty();
1651
1807
  }
1652
1808
  } else if (check.kind === "multipleOf") {
1653
- if (floatSafeRemainder(input.data, check.value) !== 0) {
1654
- ctx = this._getOrReturnCtx(input, ctx);
1809
+ if (floatSafeRemainder(input2.data, check.value) !== 0) {
1810
+ ctx = this._getOrReturnCtx(input2, ctx);
1655
1811
  addIssueToContext(ctx, {
1656
1812
  code: ZodIssueCode.not_multiple_of,
1657
1813
  multipleOf: check.value,
@@ -1660,8 +1816,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
1660
1816
  status.dirty();
1661
1817
  }
1662
1818
  } else if (check.kind === "finite") {
1663
- if (!Number.isFinite(input.data)) {
1664
- ctx = this._getOrReturnCtx(input, ctx);
1819
+ if (!Number.isFinite(input2.data)) {
1820
+ ctx = this._getOrReturnCtx(input2, ctx);
1665
1821
  addIssueToContext(ctx, {
1666
1822
  code: ZodIssueCode.not_finite,
1667
1823
  message: check.message
@@ -1672,7 +1828,7 @@ var ZodNumber = class _ZodNumber extends ZodType {
1672
1828
  util.assertNever(check);
1673
1829
  }
1674
1830
  }
1675
- return { status: status.value, value: input.data };
1831
+ return { status: status.value, value: input2.data };
1676
1832
  }
1677
1833
  gte(value, message) {
1678
1834
  return this.setLimit("min", value, true, errorUtil.toString(message));
@@ -1824,25 +1980,25 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
1824
1980
  this.min = this.gte;
1825
1981
  this.max = this.lte;
1826
1982
  }
1827
- _parse(input) {
1983
+ _parse(input2) {
1828
1984
  if (this._def.coerce) {
1829
1985
  try {
1830
- input.data = BigInt(input.data);
1986
+ input2.data = BigInt(input2.data);
1831
1987
  } catch {
1832
- return this._getInvalidInput(input);
1988
+ return this._getInvalidInput(input2);
1833
1989
  }
1834
1990
  }
1835
- const parsedType = this._getType(input);
1991
+ const parsedType = this._getType(input2);
1836
1992
  if (parsedType !== ZodParsedType.bigint) {
1837
- return this._getInvalidInput(input);
1993
+ return this._getInvalidInput(input2);
1838
1994
  }
1839
1995
  let ctx = void 0;
1840
1996
  const status = new ParseStatus();
1841
1997
  for (const check of this._def.checks) {
1842
1998
  if (check.kind === "min") {
1843
- 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;
1844
2000
  if (tooSmall) {
1845
- ctx = this._getOrReturnCtx(input, ctx);
2001
+ ctx = this._getOrReturnCtx(input2, ctx);
1846
2002
  addIssueToContext(ctx, {
1847
2003
  code: ZodIssueCode.too_small,
1848
2004
  type: "bigint",
@@ -1853,9 +2009,9 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
1853
2009
  status.dirty();
1854
2010
  }
1855
2011
  } else if (check.kind === "max") {
1856
- 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;
1857
2013
  if (tooBig) {
1858
- ctx = this._getOrReturnCtx(input, ctx);
2014
+ ctx = this._getOrReturnCtx(input2, ctx);
1859
2015
  addIssueToContext(ctx, {
1860
2016
  code: ZodIssueCode.too_big,
1861
2017
  type: "bigint",
@@ -1866,8 +2022,8 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
1866
2022
  status.dirty();
1867
2023
  }
1868
2024
  } else if (check.kind === "multipleOf") {
1869
- if (input.data % check.value !== BigInt(0)) {
1870
- ctx = this._getOrReturnCtx(input, ctx);
2025
+ if (input2.data % check.value !== BigInt(0)) {
2026
+ ctx = this._getOrReturnCtx(input2, ctx);
1871
2027
  addIssueToContext(ctx, {
1872
2028
  code: ZodIssueCode.not_multiple_of,
1873
2029
  multipleOf: check.value,
@@ -1879,10 +2035,10 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
1879
2035
  util.assertNever(check);
1880
2036
  }
1881
2037
  }
1882
- return { status: status.value, value: input.data };
2038
+ return { status: status.value, value: input2.data };
1883
2039
  }
1884
- _getInvalidInput(input) {
1885
- const ctx = this._getOrReturnCtx(input);
2040
+ _getInvalidInput(input2) {
2041
+ const ctx = this._getOrReturnCtx(input2);
1886
2042
  addIssueToContext(ctx, {
1887
2043
  code: ZodIssueCode.invalid_type,
1888
2044
  expected: ZodParsedType.bigint,
@@ -1991,13 +2147,13 @@ ZodBigInt.create = (params) => {
1991
2147
  });
1992
2148
  };
1993
2149
  var ZodBoolean = class extends ZodType {
1994
- _parse(input) {
2150
+ _parse(input2) {
1995
2151
  if (this._def.coerce) {
1996
- input.data = Boolean(input.data);
2152
+ input2.data = Boolean(input2.data);
1997
2153
  }
1998
- const parsedType = this._getType(input);
2154
+ const parsedType = this._getType(input2);
1999
2155
  if (parsedType !== ZodParsedType.boolean) {
2000
- const ctx = this._getOrReturnCtx(input);
2156
+ const ctx = this._getOrReturnCtx(input2);
2001
2157
  addIssueToContext(ctx, {
2002
2158
  code: ZodIssueCode.invalid_type,
2003
2159
  expected: ZodParsedType.boolean,
@@ -2005,7 +2161,7 @@ var ZodBoolean = class extends ZodType {
2005
2161
  });
2006
2162
  return INVALID;
2007
2163
  }
2008
- return OK(input.data);
2164
+ return OK(input2.data);
2009
2165
  }
2010
2166
  };
2011
2167
  ZodBoolean.create = (params) => {
@@ -2016,13 +2172,13 @@ ZodBoolean.create = (params) => {
2016
2172
  });
2017
2173
  };
2018
2174
  var ZodDate = class _ZodDate extends ZodType {
2019
- _parse(input) {
2175
+ _parse(input2) {
2020
2176
  if (this._def.coerce) {
2021
- input.data = new Date(input.data);
2177
+ input2.data = new Date(input2.data);
2022
2178
  }
2023
- const parsedType = this._getType(input);
2179
+ const parsedType = this._getType(input2);
2024
2180
  if (parsedType !== ZodParsedType.date) {
2025
- const ctx2 = this._getOrReturnCtx(input);
2181
+ const ctx2 = this._getOrReturnCtx(input2);
2026
2182
  addIssueToContext(ctx2, {
2027
2183
  code: ZodIssueCode.invalid_type,
2028
2184
  expected: ZodParsedType.date,
@@ -2030,8 +2186,8 @@ var ZodDate = class _ZodDate extends ZodType {
2030
2186
  });
2031
2187
  return INVALID;
2032
2188
  }
2033
- if (Number.isNaN(input.data.getTime())) {
2034
- const ctx2 = this._getOrReturnCtx(input);
2189
+ if (Number.isNaN(input2.data.getTime())) {
2190
+ const ctx2 = this._getOrReturnCtx(input2);
2035
2191
  addIssueToContext(ctx2, {
2036
2192
  code: ZodIssueCode.invalid_date
2037
2193
  });
@@ -2041,8 +2197,8 @@ var ZodDate = class _ZodDate extends ZodType {
2041
2197
  let ctx = void 0;
2042
2198
  for (const check of this._def.checks) {
2043
2199
  if (check.kind === "min") {
2044
- if (input.data.getTime() < check.value) {
2045
- ctx = this._getOrReturnCtx(input, ctx);
2200
+ if (input2.data.getTime() < check.value) {
2201
+ ctx = this._getOrReturnCtx(input2, ctx);
2046
2202
  addIssueToContext(ctx, {
2047
2203
  code: ZodIssueCode.too_small,
2048
2204
  message: check.message,
@@ -2054,8 +2210,8 @@ var ZodDate = class _ZodDate extends ZodType {
2054
2210
  status.dirty();
2055
2211
  }
2056
2212
  } else if (check.kind === "max") {
2057
- if (input.data.getTime() > check.value) {
2058
- ctx = this._getOrReturnCtx(input, ctx);
2213
+ if (input2.data.getTime() > check.value) {
2214
+ ctx = this._getOrReturnCtx(input2, ctx);
2059
2215
  addIssueToContext(ctx, {
2060
2216
  code: ZodIssueCode.too_big,
2061
2217
  message: check.message,
@@ -2072,7 +2228,7 @@ var ZodDate = class _ZodDate extends ZodType {
2072
2228
  }
2073
2229
  return {
2074
2230
  status: status.value,
2075
- value: new Date(input.data.getTime())
2231
+ value: new Date(input2.data.getTime())
2076
2232
  };
2077
2233
  }
2078
2234
  _addCheck(check) {
@@ -2125,10 +2281,10 @@ ZodDate.create = (params) => {
2125
2281
  });
2126
2282
  };
2127
2283
  var ZodSymbol = class extends ZodType {
2128
- _parse(input) {
2129
- const parsedType = this._getType(input);
2284
+ _parse(input2) {
2285
+ const parsedType = this._getType(input2);
2130
2286
  if (parsedType !== ZodParsedType.symbol) {
2131
- const ctx = this._getOrReturnCtx(input);
2287
+ const ctx = this._getOrReturnCtx(input2);
2132
2288
  addIssueToContext(ctx, {
2133
2289
  code: ZodIssueCode.invalid_type,
2134
2290
  expected: ZodParsedType.symbol,
@@ -2136,7 +2292,7 @@ var ZodSymbol = class extends ZodType {
2136
2292
  });
2137
2293
  return INVALID;
2138
2294
  }
2139
- return OK(input.data);
2295
+ return OK(input2.data);
2140
2296
  }
2141
2297
  };
2142
2298
  ZodSymbol.create = (params) => {
@@ -2146,10 +2302,10 @@ ZodSymbol.create = (params) => {
2146
2302
  });
2147
2303
  };
2148
2304
  var ZodUndefined = class extends ZodType {
2149
- _parse(input) {
2150
- const parsedType = this._getType(input);
2305
+ _parse(input2) {
2306
+ const parsedType = this._getType(input2);
2151
2307
  if (parsedType !== ZodParsedType.undefined) {
2152
- const ctx = this._getOrReturnCtx(input);
2308
+ const ctx = this._getOrReturnCtx(input2);
2153
2309
  addIssueToContext(ctx, {
2154
2310
  code: ZodIssueCode.invalid_type,
2155
2311
  expected: ZodParsedType.undefined,
@@ -2157,7 +2313,7 @@ var ZodUndefined = class extends ZodType {
2157
2313
  });
2158
2314
  return INVALID;
2159
2315
  }
2160
- return OK(input.data);
2316
+ return OK(input2.data);
2161
2317
  }
2162
2318
  };
2163
2319
  ZodUndefined.create = (params) => {
@@ -2167,10 +2323,10 @@ ZodUndefined.create = (params) => {
2167
2323
  });
2168
2324
  };
2169
2325
  var ZodNull = class extends ZodType {
2170
- _parse(input) {
2171
- const parsedType = this._getType(input);
2326
+ _parse(input2) {
2327
+ const parsedType = this._getType(input2);
2172
2328
  if (parsedType !== ZodParsedType.null) {
2173
- const ctx = this._getOrReturnCtx(input);
2329
+ const ctx = this._getOrReturnCtx(input2);
2174
2330
  addIssueToContext(ctx, {
2175
2331
  code: ZodIssueCode.invalid_type,
2176
2332
  expected: ZodParsedType.null,
@@ -2178,7 +2334,7 @@ var ZodNull = class extends ZodType {
2178
2334
  });
2179
2335
  return INVALID;
2180
2336
  }
2181
- return OK(input.data);
2337
+ return OK(input2.data);
2182
2338
  }
2183
2339
  };
2184
2340
  ZodNull.create = (params) => {
@@ -2192,8 +2348,8 @@ var ZodAny = class extends ZodType {
2192
2348
  super(...arguments);
2193
2349
  this._any = true;
2194
2350
  }
2195
- _parse(input) {
2196
- return OK(input.data);
2351
+ _parse(input2) {
2352
+ return OK(input2.data);
2197
2353
  }
2198
2354
  };
2199
2355
  ZodAny.create = (params) => {
@@ -2207,8 +2363,8 @@ var ZodUnknown = class extends ZodType {
2207
2363
  super(...arguments);
2208
2364
  this._unknown = true;
2209
2365
  }
2210
- _parse(input) {
2211
- return OK(input.data);
2366
+ _parse(input2) {
2367
+ return OK(input2.data);
2212
2368
  }
2213
2369
  };
2214
2370
  ZodUnknown.create = (params) => {
@@ -2218,8 +2374,8 @@ ZodUnknown.create = (params) => {
2218
2374
  });
2219
2375
  };
2220
2376
  var ZodNever = class extends ZodType {
2221
- _parse(input) {
2222
- const ctx = this._getOrReturnCtx(input);
2377
+ _parse(input2) {
2378
+ const ctx = this._getOrReturnCtx(input2);
2223
2379
  addIssueToContext(ctx, {
2224
2380
  code: ZodIssueCode.invalid_type,
2225
2381
  expected: ZodParsedType.never,
@@ -2235,10 +2391,10 @@ ZodNever.create = (params) => {
2235
2391
  });
2236
2392
  };
2237
2393
  var ZodVoid = class extends ZodType {
2238
- _parse(input) {
2239
- const parsedType = this._getType(input);
2394
+ _parse(input2) {
2395
+ const parsedType = this._getType(input2);
2240
2396
  if (parsedType !== ZodParsedType.undefined) {
2241
- const ctx = this._getOrReturnCtx(input);
2397
+ const ctx = this._getOrReturnCtx(input2);
2242
2398
  addIssueToContext(ctx, {
2243
2399
  code: ZodIssueCode.invalid_type,
2244
2400
  expected: ZodParsedType.void,
@@ -2246,7 +2402,7 @@ var ZodVoid = class extends ZodType {
2246
2402
  });
2247
2403
  return INVALID;
2248
2404
  }
2249
- return OK(input.data);
2405
+ return OK(input2.data);
2250
2406
  }
2251
2407
  };
2252
2408
  ZodVoid.create = (params) => {
@@ -2256,8 +2412,8 @@ ZodVoid.create = (params) => {
2256
2412
  });
2257
2413
  };
2258
2414
  var ZodArray = class _ZodArray extends ZodType {
2259
- _parse(input) {
2260
- const { ctx, status } = this._processInputParams(input);
2415
+ _parse(input2) {
2416
+ const { ctx, status } = this._processInputParams(input2);
2261
2417
  const def = this._def;
2262
2418
  if (ctx.parsedType !== ZodParsedType.array) {
2263
2419
  addIssueToContext(ctx, {
@@ -2397,10 +2553,10 @@ var ZodObject = class _ZodObject extends ZodType {
2397
2553
  this._cached = { shape, keys };
2398
2554
  return this._cached;
2399
2555
  }
2400
- _parse(input) {
2401
- const parsedType = this._getType(input);
2556
+ _parse(input2) {
2557
+ const parsedType = this._getType(input2);
2402
2558
  if (parsedType !== ZodParsedType.object) {
2403
- const ctx2 = this._getOrReturnCtx(input);
2559
+ const ctx2 = this._getOrReturnCtx(input2);
2404
2560
  addIssueToContext(ctx2, {
2405
2561
  code: ZodIssueCode.invalid_type,
2406
2562
  expected: ZodParsedType.object,
@@ -2408,7 +2564,7 @@ var ZodObject = class _ZodObject extends ZodType {
2408
2564
  });
2409
2565
  return INVALID;
2410
2566
  }
2411
- const { status, ctx } = this._processInputParams(input);
2567
+ const { status, ctx } = this._processInputParams(input2);
2412
2568
  const { shape, keys: shapeKeys } = this._getCached();
2413
2569
  const extraKeys = [];
2414
2570
  if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
@@ -2720,8 +2876,8 @@ ZodObject.lazycreate = (shape, params) => {
2720
2876
  });
2721
2877
  };
2722
2878
  var ZodUnion = class extends ZodType {
2723
- _parse(input) {
2724
- const { ctx } = this._processInputParams(input);
2879
+ _parse(input2) {
2880
+ const { ctx } = this._processInputParams(input2);
2725
2881
  const options = this._def.options;
2726
2882
  function handleResults(results) {
2727
2883
  for (const result of results) {
@@ -2842,8 +2998,8 @@ var getDiscriminator = (type) => {
2842
2998
  }
2843
2999
  };
2844
3000
  var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
2845
- _parse(input) {
2846
- const { ctx } = this._processInputParams(input);
3001
+ _parse(input2) {
3002
+ const { ctx } = this._processInputParams(input2);
2847
3003
  if (ctx.parsedType !== ZodParsedType.object) {
2848
3004
  addIssueToContext(ctx, {
2849
3005
  code: ZodIssueCode.invalid_type,
@@ -2956,8 +3112,8 @@ function mergeValues(a, b) {
2956
3112
  }
2957
3113
  }
2958
3114
  var ZodIntersection = class extends ZodType {
2959
- _parse(input) {
2960
- const { status, ctx } = this._processInputParams(input);
3115
+ _parse(input2) {
3116
+ const { status, ctx } = this._processInputParams(input2);
2961
3117
  const handleParsed = (parsedLeft, parsedRight) => {
2962
3118
  if (isAborted(parsedLeft) || isAborted(parsedRight)) {
2963
3119
  return INVALID;
@@ -3009,8 +3165,8 @@ ZodIntersection.create = (left, right, params) => {
3009
3165
  });
3010
3166
  };
3011
3167
  var ZodTuple = class _ZodTuple extends ZodType {
3012
- _parse(input) {
3013
- const { status, ctx } = this._processInputParams(input);
3168
+ _parse(input2) {
3169
+ const { status, ctx } = this._processInputParams(input2);
3014
3170
  if (ctx.parsedType !== ZodParsedType.array) {
3015
3171
  addIssueToContext(ctx, {
3016
3172
  code: ZodIssueCode.invalid_type,
@@ -3045,7 +3201,7 @@ var ZodTuple = class _ZodTuple extends ZodType {
3045
3201
  if (!schema)
3046
3202
  return null;
3047
3203
  return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
3048
- }).filter((x) => !!x);
3204
+ }).filter((x3) => !!x3);
3049
3205
  if (ctx.common.async) {
3050
3206
  return Promise.all(items).then((results) => {
3051
3207
  return ParseStatus.mergeArray(status, results);
@@ -3082,8 +3238,8 @@ var ZodRecord = class _ZodRecord extends ZodType {
3082
3238
  get valueSchema() {
3083
3239
  return this._def.valueType;
3084
3240
  }
3085
- _parse(input) {
3086
- const { status, ctx } = this._processInputParams(input);
3241
+ _parse(input2) {
3242
+ const { status, ctx } = this._processInputParams(input2);
3087
3243
  if (ctx.parsedType !== ZodParsedType.object) {
3088
3244
  addIssueToContext(ctx, {
3089
3245
  code: ZodIssueCode.invalid_type,
@@ -3135,8 +3291,8 @@ var ZodMap = class extends ZodType {
3135
3291
  get valueSchema() {
3136
3292
  return this._def.valueType;
3137
3293
  }
3138
- _parse(input) {
3139
- const { status, ctx } = this._processInputParams(input);
3294
+ _parse(input2) {
3295
+ const { status, ctx } = this._processInputParams(input2);
3140
3296
  if (ctx.parsedType !== ZodParsedType.map) {
3141
3297
  addIssueToContext(ctx, {
3142
3298
  code: ZodIssueCode.invalid_type,
@@ -3195,8 +3351,8 @@ ZodMap.create = (keyType, valueType, params) => {
3195
3351
  });
3196
3352
  };
3197
3353
  var ZodSet = class _ZodSet extends ZodType {
3198
- _parse(input) {
3199
- const { status, ctx } = this._processInputParams(input);
3354
+ _parse(input2) {
3355
+ const { status, ctx } = this._processInputParams(input2);
3200
3356
  if (ctx.parsedType !== ZodParsedType.set) {
3201
3357
  addIssueToContext(ctx, {
3202
3358
  code: ZodIssueCode.invalid_type,
@@ -3284,8 +3440,8 @@ var ZodFunction = class _ZodFunction extends ZodType {
3284
3440
  super(...arguments);
3285
3441
  this.validate = this.implement;
3286
3442
  }
3287
- _parse(input) {
3288
- const { ctx } = this._processInputParams(input);
3443
+ _parse(input2) {
3444
+ const { ctx } = this._processInputParams(input2);
3289
3445
  if (ctx.parsedType !== ZodParsedType.function) {
3290
3446
  addIssueToContext(ctx, {
3291
3447
  code: ZodIssueCode.invalid_type,
@@ -3298,7 +3454,7 @@ var ZodFunction = class _ZodFunction extends ZodType {
3298
3454
  return makeIssue({
3299
3455
  data: args,
3300
3456
  path: ctx.path,
3301
- 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),
3302
3458
  issueData: {
3303
3459
  code: ZodIssueCode.invalid_arguments,
3304
3460
  argumentsError: error
@@ -3309,7 +3465,7 @@ var ZodFunction = class _ZodFunction extends ZodType {
3309
3465
  return makeIssue({
3310
3466
  data: returns,
3311
3467
  path: ctx.path,
3312
- 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),
3313
3469
  issueData: {
3314
3470
  code: ZodIssueCode.invalid_return_type,
3315
3471
  returnTypeError: error
@@ -3319,29 +3475,29 @@ var ZodFunction = class _ZodFunction extends ZodType {
3319
3475
  const params = { errorMap: ctx.common.contextualErrorMap };
3320
3476
  const fn = ctx.data;
3321
3477
  if (this._def.returns instanceof ZodPromise) {
3322
- const me = this;
3478
+ const me2 = this;
3323
3479
  return OK(async function(...args) {
3324
3480
  const error = new ZodError([]);
3325
- const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
3326
- error.addIssue(makeArgsIssue(args, e));
3481
+ const parsedArgs = await me2._def.args.parseAsync(args, params).catch((e2) => {
3482
+ error.addIssue(makeArgsIssue(args, e2));
3327
3483
  throw error;
3328
3484
  });
3329
3485
  const result = await Reflect.apply(fn, this, parsedArgs);
3330
- const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
3331
- 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));
3332
3488
  throw error;
3333
3489
  });
3334
3490
  return parsedReturns;
3335
3491
  });
3336
3492
  } else {
3337
- const me = this;
3493
+ const me2 = this;
3338
3494
  return OK(function(...args) {
3339
- const parsedArgs = me._def.args.safeParse(args, params);
3495
+ const parsedArgs = me2._def.args.safeParse(args, params);
3340
3496
  if (!parsedArgs.success) {
3341
3497
  throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
3342
3498
  }
3343
3499
  const result = Reflect.apply(fn, this, parsedArgs.data);
3344
- const parsedReturns = me._def.returns.safeParse(result, params);
3500
+ const parsedReturns = me2._def.returns.safeParse(result, params);
3345
3501
  if (!parsedReturns.success) {
3346
3502
  throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
3347
3503
  }
@@ -3388,8 +3544,8 @@ var ZodLazy = class extends ZodType {
3388
3544
  get schema() {
3389
3545
  return this._def.getter();
3390
3546
  }
3391
- _parse(input) {
3392
- const { ctx } = this._processInputParams(input);
3547
+ _parse(input2) {
3548
+ const { ctx } = this._processInputParams(input2);
3393
3549
  const lazySchema = this._def.getter();
3394
3550
  return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
3395
3551
  }
@@ -3402,9 +3558,9 @@ ZodLazy.create = (getter, params) => {
3402
3558
  });
3403
3559
  };
3404
3560
  var ZodLiteral = class extends ZodType {
3405
- _parse(input) {
3406
- if (input.data !== this._def.value) {
3407
- const ctx = this._getOrReturnCtx(input);
3561
+ _parse(input2) {
3562
+ if (input2.data !== this._def.value) {
3563
+ const ctx = this._getOrReturnCtx(input2);
3408
3564
  addIssueToContext(ctx, {
3409
3565
  received: ctx.data,
3410
3566
  code: ZodIssueCode.invalid_literal,
@@ -3412,7 +3568,7 @@ var ZodLiteral = class extends ZodType {
3412
3568
  });
3413
3569
  return INVALID;
3414
3570
  }
3415
- return { status: "valid", value: input.data };
3571
+ return { status: "valid", value: input2.data };
3416
3572
  }
3417
3573
  get value() {
3418
3574
  return this._def.value;
@@ -3433,9 +3589,9 @@ function createZodEnum(values, params) {
3433
3589
  });
3434
3590
  }
3435
3591
  var ZodEnum = class _ZodEnum extends ZodType {
3436
- _parse(input) {
3437
- if (typeof input.data !== "string") {
3438
- const ctx = this._getOrReturnCtx(input);
3592
+ _parse(input2) {
3593
+ if (typeof input2.data !== "string") {
3594
+ const ctx = this._getOrReturnCtx(input2);
3439
3595
  const expectedValues = this._def.values;
3440
3596
  addIssueToContext(ctx, {
3441
3597
  expected: util.joinValues(expectedValues),
@@ -3447,8 +3603,8 @@ var ZodEnum = class _ZodEnum extends ZodType {
3447
3603
  if (!this._cache) {
3448
3604
  this._cache = new Set(this._def.values);
3449
3605
  }
3450
- if (!this._cache.has(input.data)) {
3451
- const ctx = this._getOrReturnCtx(input);
3606
+ if (!this._cache.has(input2.data)) {
3607
+ const ctx = this._getOrReturnCtx(input2);
3452
3608
  const expectedValues = this._def.values;
3453
3609
  addIssueToContext(ctx, {
3454
3610
  received: ctx.data,
@@ -3457,7 +3613,7 @@ var ZodEnum = class _ZodEnum extends ZodType {
3457
3613
  });
3458
3614
  return INVALID;
3459
3615
  }
3460
- return OK(input.data);
3616
+ return OK(input2.data);
3461
3617
  }
3462
3618
  get options() {
3463
3619
  return this._def.values;
@@ -3498,9 +3654,9 @@ var ZodEnum = class _ZodEnum extends ZodType {
3498
3654
  };
3499
3655
  ZodEnum.create = createZodEnum;
3500
3656
  var ZodNativeEnum = class extends ZodType {
3501
- _parse(input) {
3657
+ _parse(input2) {
3502
3658
  const nativeEnumValues = util.getValidEnumValues(this._def.values);
3503
- const ctx = this._getOrReturnCtx(input);
3659
+ const ctx = this._getOrReturnCtx(input2);
3504
3660
  if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
3505
3661
  const expectedValues = util.objectValues(nativeEnumValues);
3506
3662
  addIssueToContext(ctx, {
@@ -3513,7 +3669,7 @@ var ZodNativeEnum = class extends ZodType {
3513
3669
  if (!this._cache) {
3514
3670
  this._cache = new Set(util.getValidEnumValues(this._def.values));
3515
3671
  }
3516
- if (!this._cache.has(input.data)) {
3672
+ if (!this._cache.has(input2.data)) {
3517
3673
  const expectedValues = util.objectValues(nativeEnumValues);
3518
3674
  addIssueToContext(ctx, {
3519
3675
  received: ctx.data,
@@ -3522,7 +3678,7 @@ var ZodNativeEnum = class extends ZodType {
3522
3678
  });
3523
3679
  return INVALID;
3524
3680
  }
3525
- return OK(input.data);
3681
+ return OK(input2.data);
3526
3682
  }
3527
3683
  get enum() {
3528
3684
  return this._def.values;
@@ -3539,8 +3695,8 @@ var ZodPromise = class extends ZodType {
3539
3695
  unwrap() {
3540
3696
  return this._def.type;
3541
3697
  }
3542
- _parse(input) {
3543
- const { ctx } = this._processInputParams(input);
3698
+ _parse(input2) {
3699
+ const { ctx } = this._processInputParams(input2);
3544
3700
  if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
3545
3701
  addIssueToContext(ctx, {
3546
3702
  code: ZodIssueCode.invalid_type,
@@ -3572,8 +3728,8 @@ var ZodEffects = class extends ZodType {
3572
3728
  sourceType() {
3573
3729
  return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3574
3730
  }
3575
- _parse(input) {
3576
- const { status, ctx } = this._processInputParams(input);
3731
+ _parse(input2) {
3732
+ const { status, ctx } = this._processInputParams(input2);
3577
3733
  const effect = this._def.effect || null;
3578
3734
  const checkCtx = {
3579
3735
  addIssue: (arg) => {
@@ -3705,12 +3861,12 @@ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
3705
3861
  });
3706
3862
  };
3707
3863
  var ZodOptional = class extends ZodType {
3708
- _parse(input) {
3709
- const parsedType = this._getType(input);
3864
+ _parse(input2) {
3865
+ const parsedType = this._getType(input2);
3710
3866
  if (parsedType === ZodParsedType.undefined) {
3711
3867
  return OK(void 0);
3712
3868
  }
3713
- return this._def.innerType._parse(input);
3869
+ return this._def.innerType._parse(input2);
3714
3870
  }
3715
3871
  unwrap() {
3716
3872
  return this._def.innerType;
@@ -3724,12 +3880,12 @@ ZodOptional.create = (type, params) => {
3724
3880
  });
3725
3881
  };
3726
3882
  var ZodNullable = class extends ZodType {
3727
- _parse(input) {
3728
- const parsedType = this._getType(input);
3883
+ _parse(input2) {
3884
+ const parsedType = this._getType(input2);
3729
3885
  if (parsedType === ZodParsedType.null) {
3730
3886
  return OK(null);
3731
3887
  }
3732
- return this._def.innerType._parse(input);
3888
+ return this._def.innerType._parse(input2);
3733
3889
  }
3734
3890
  unwrap() {
3735
3891
  return this._def.innerType;
@@ -3743,8 +3899,8 @@ ZodNullable.create = (type, params) => {
3743
3899
  });
3744
3900
  };
3745
3901
  var ZodDefault = class extends ZodType {
3746
- _parse(input) {
3747
- const { ctx } = this._processInputParams(input);
3902
+ _parse(input2) {
3903
+ const { ctx } = this._processInputParams(input2);
3748
3904
  let data = ctx.data;
3749
3905
  if (ctx.parsedType === ZodParsedType.undefined) {
3750
3906
  data = this._def.defaultValue();
@@ -3768,8 +3924,8 @@ ZodDefault.create = (type, params) => {
3768
3924
  });
3769
3925
  };
3770
3926
  var ZodCatch = class extends ZodType {
3771
- _parse(input) {
3772
- const { ctx } = this._processInputParams(input);
3927
+ _parse(input2) {
3928
+ const { ctx } = this._processInputParams(input2);
3773
3929
  const newCtx = {
3774
3930
  ...ctx,
3775
3931
  common: {
@@ -3821,10 +3977,10 @@ ZodCatch.create = (type, params) => {
3821
3977
  });
3822
3978
  };
3823
3979
  var ZodNaN = class extends ZodType {
3824
- _parse(input) {
3825
- const parsedType = this._getType(input);
3980
+ _parse(input2) {
3981
+ const parsedType = this._getType(input2);
3826
3982
  if (parsedType !== ZodParsedType.nan) {
3827
- const ctx = this._getOrReturnCtx(input);
3983
+ const ctx = this._getOrReturnCtx(input2);
3828
3984
  addIssueToContext(ctx, {
3829
3985
  code: ZodIssueCode.invalid_type,
3830
3986
  expected: ZodParsedType.nan,
@@ -3832,7 +3988,7 @@ var ZodNaN = class extends ZodType {
3832
3988
  });
3833
3989
  return INVALID;
3834
3990
  }
3835
- return { status: "valid", value: input.data };
3991
+ return { status: "valid", value: input2.data };
3836
3992
  }
3837
3993
  };
3838
3994
  ZodNaN.create = (params) => {
@@ -3843,8 +3999,8 @@ ZodNaN.create = (params) => {
3843
3999
  };
3844
4000
  var BRAND = /* @__PURE__ */ Symbol("zod_brand");
3845
4001
  var ZodBranded = class extends ZodType {
3846
- _parse(input) {
3847
- const { ctx } = this._processInputParams(input);
4002
+ _parse(input2) {
4003
+ const { ctx } = this._processInputParams(input2);
3848
4004
  const data = ctx.data;
3849
4005
  return this._def.type._parse({
3850
4006
  data,
@@ -3857,8 +4013,8 @@ var ZodBranded = class extends ZodType {
3857
4013
  }
3858
4014
  };
3859
4015
  var ZodPipeline = class _ZodPipeline extends ZodType {
3860
- _parse(input) {
3861
- const { status, ctx } = this._processInputParams(input);
4016
+ _parse(input2) {
4017
+ const { status, ctx } = this._processInputParams(input2);
3862
4018
  if (ctx.common.async) {
3863
4019
  const handleAsync = async () => {
3864
4020
  const inResult = await this._def.in._parseAsync({
@@ -3912,8 +4068,8 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
3912
4068
  }
3913
4069
  };
3914
4070
  var ZodReadonly = class extends ZodType {
3915
- _parse(input) {
3916
- const result = this._def.innerType._parse(input);
4071
+ _parse(input2) {
4072
+ const result = this._def.innerType._parse(input2);
3917
4073
  const freeze = (data) => {
3918
4074
  if (isValid(data)) {
3919
4075
  data.value = Object.freeze(data.value);
@@ -4492,7 +4648,7 @@ function extractMediaFromText(text, options = {}) {
4492
4648
  const {
4493
4649
  removeFromText = true,
4494
4650
  checkExists = false,
4495
- existsSync: existsSync3,
4651
+ existsSync: existsSync4,
4496
4652
  parseMediaLines = false,
4497
4653
  parseMarkdownImages = true,
4498
4654
  parseHtmlImages = true,
@@ -4507,7 +4663,7 @@ function extractMediaFromText(text, options = {}) {
4507
4663
  const key = media.localPath || media.source;
4508
4664
  if (seenSources.has(key)) return false;
4509
4665
  if (checkExists && media.isLocal && media.localPath) {
4510
- const exists = existsSync3 ? existsSync3(media.localPath) : fs3.existsSync(media.localPath);
4666
+ const exists = existsSync4 ? existsSync4(media.localPath) : fs3.existsSync(media.localPath);
4511
4667
  if (!exists) return false;
4512
4668
  }
4513
4669
  seenSources.add(key);
@@ -4698,6 +4854,1381 @@ function extractMediaFromText(text, options = {}) {
4698
4854
  all: [...images, ...files]
4699
4855
  };
4700
4856
  }
4857
+
4858
+ // ../../node_modules/.pnpm/@clack+core@1.0.1/node_modules/@clack/core/dist/index.mjs
4859
+ var import_picocolors = __toESM(require_picocolors());
4860
+ var import_sisteransi = __toESM(require_src());
4861
+ function B(t, e2, s) {
4862
+ if (!s.some((u) => !u.disabled)) return t;
4863
+ const i = t + e2, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
4864
+ return s[n].disabled ? B(n, e2 < 0 ? -1 : 1, s) : n;
4865
+ }
4866
+ 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;
4867
+ var lt = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510;
4868
+ 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;
4869
+ var O = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
4870
+ var y = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
4871
+ var L = /\t{1,1000}/y;
4872
+ 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;
4873
+ var M = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
4874
+ var ct = /\p{M}+/gu;
4875
+ var ft = { limit: 1 / 0, ellipsis: "" };
4876
+ var X = (t, e2 = {}, s = {}) => {
4877
+ 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;
4878
+ 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;
4879
+ t: for (; ; ) {
4880
+ if (w > C2 || o >= p && o > h) {
4881
+ const ut2 = t.slice(C2, w) || t.slice(h, o);
4882
+ v = 0;
4883
+ for (const Y of ut2.replaceAll(ct, "")) {
4884
+ const $ = Y.codePointAt(0) || 0;
4885
+ 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) {
4886
+ F = true;
4887
+ break t;
4888
+ }
4889
+ v += Y.length, c += f;
4890
+ }
4891
+ C2 = w = 0;
4892
+ }
4893
+ if (o >= p) break;
4894
+ if (M.lastIndex = o, M.test(t)) {
4895
+ if (v = M.lastIndex - o, f = v * A, c + f > b && (d2 = Math.min(d2, o + Math.floor((b - c) / A))), c + f > i) {
4896
+ F = true;
4897
+ break;
4898
+ }
4899
+ c += f, C2 = h, w = o, o = h = M.lastIndex;
4900
+ continue;
4901
+ }
4902
+ if (O.lastIndex = o, O.test(t)) {
4903
+ if (c + u > b && (d2 = Math.min(d2, o)), c + u > i) {
4904
+ F = true;
4905
+ break;
4906
+ }
4907
+ c += u, C2 = h, w = o, o = h = O.lastIndex;
4908
+ continue;
4909
+ }
4910
+ if (y.lastIndex = o, y.test(t)) {
4911
+ if (v = y.lastIndex - o, f = v * a, c + f > b && (d2 = Math.min(d2, o + Math.floor((b - c) / a))), c + f > i) {
4912
+ F = true;
4913
+ break;
4914
+ }
4915
+ c += f, C2 = h, w = o, o = h = y.lastIndex;
4916
+ continue;
4917
+ }
4918
+ if (L.lastIndex = o, L.test(t)) {
4919
+ if (v = L.lastIndex - o, f = v * l, c + f > b && (d2 = Math.min(d2, o + Math.floor((b - c) / l))), c + f > i) {
4920
+ F = true;
4921
+ break;
4922
+ }
4923
+ c += f, C2 = h, w = o, o = h = L.lastIndex;
4924
+ continue;
4925
+ }
4926
+ if (P.lastIndex = o, P.test(t)) {
4927
+ if (c + g > b && (d2 = Math.min(d2, o)), c + g > i) {
4928
+ F = true;
4929
+ break;
4930
+ }
4931
+ c += g, C2 = h, w = o, o = h = P.lastIndex;
4932
+ continue;
4933
+ }
4934
+ o += 1;
4935
+ }
4936
+ return { width: F ? b : c, index: F ? d2 : p, truncated: F, ellipsed: F && i >= n };
4937
+ };
4938
+ var pt = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
4939
+ var S = (t, e2 = {}) => X(t, pt, e2).width;
4940
+ var W = "\x1B";
4941
+ var Z = "\x9B";
4942
+ var Ft = 39;
4943
+ var j = "\x07";
4944
+ var Q = "[";
4945
+ var dt = "]";
4946
+ var tt = "m";
4947
+ var U = `${dt}8;;`;
4948
+ var et = new RegExp(`(?:\\${Q}(?<code>\\d+)m|\\${U}(?<uri>.*)${j})`, "y");
4949
+ var mt = (t) => {
4950
+ if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
4951
+ if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
4952
+ if (t === 1 || t === 2) return 22;
4953
+ if (t === 3) return 23;
4954
+ if (t === 4) return 24;
4955
+ if (t === 7) return 27;
4956
+ if (t === 8) return 28;
4957
+ if (t === 9) return 29;
4958
+ if (t === 0) return 0;
4959
+ };
4960
+ var st = (t) => `${W}${Q}${t}${tt}`;
4961
+ var it = (t) => `${W}${U}${t}${j}`;
4962
+ var gt = (t) => t.map((e2) => S(e2));
4963
+ var G = (t, e2, s) => {
4964
+ const i = e2[Symbol.iterator]();
4965
+ let r = false, n = false, u = t.at(-1), a = u === void 0 ? 0 : S(u), l = i.next(), E = i.next(), g = 0;
4966
+ for (; !l.done; ) {
4967
+ const m = l.value, A = S(m);
4968
+ 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;
4969
+ }
4970
+ u = t.at(-1), !a && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
4971
+ };
4972
+ var vt = (t) => {
4973
+ const e2 = t.split(" ");
4974
+ let s = e2.length;
4975
+ for (; s > 0 && !(S(e2[s - 1]) > 0); ) s--;
4976
+ return s === e2.length ? t : e2.slice(0, s).join(" ") + e2.slice(s).join("");
4977
+ };
4978
+ var Et = (t, e2, s = {}) => {
4979
+ if (s.trim !== false && t.trim() === "") return "";
4980
+ let i = "", r, n;
4981
+ const u = t.split(" "), a = gt(u);
4982
+ let l = [""];
4983
+ for (const [h, o] of u.entries()) {
4984
+ s.trim !== false && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
4985
+ let p = S(l.at(-1) ?? "");
4986
+ 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) {
4987
+ const v = e2 - p, F = 1 + Math.floor((a[h] - v - 1) / e2);
4988
+ Math.floor((a[h] - 1) / e2) < F && l.push(""), G(l, o, e2);
4989
+ continue;
4990
+ }
4991
+ if (p + a[h] > e2 && p > 0 && a[h] > 0) {
4992
+ if (s.wordWrap === false && p < e2) {
4993
+ G(l, o, e2);
4994
+ continue;
4995
+ }
4996
+ l.push("");
4997
+ }
4998
+ if (p + a[h] > e2 && s.wordWrap === false) {
4999
+ G(l, o, e2);
5000
+ continue;
5001
+ }
5002
+ l[l.length - 1] += o;
5003
+ }
5004
+ s.trim !== false && (l = l.map((h) => vt(h)));
5005
+ const E = l.join(`
5006
+ `), g = E[Symbol.iterator]();
5007
+ let m = g.next(), A = g.next(), V2 = 0;
5008
+ for (; !m.done; ) {
5009
+ const h = m.value, o = A.value;
5010
+ if (i += h, h === W || h === Z) {
5011
+ et.lastIndex = V2 + 1;
5012
+ const F = et.exec(E)?.groups;
5013
+ if (F?.code !== void 0) {
5014
+ const d2 = Number.parseFloat(F.code);
5015
+ r = d2 === Ft ? void 0 : d2;
5016
+ } else F?.uri !== void 0 && (n = F.uri.length === 0 ? void 0 : F.uri);
5017
+ }
5018
+ const p = r ? mt(r) : void 0;
5019
+ o === `
5020
+ ` ? (n && (i += it("")), r && p && (i += st(p))) : h === `
5021
+ ` && (r && p && (i += st(r)), n && (i += it(n))), V2 += h.length, m = A, A = g.next();
5022
+ }
5023
+ return i;
5024
+ };
5025
+ function K(t, e2, s) {
5026
+ return String(t).normalize().replaceAll(`\r
5027
+ `, `
5028
+ `).split(`
5029
+ `).map((i) => Et(i, e2, s)).join(`
5030
+ `);
5031
+ }
5032
+ var At = ["up", "down", "left", "right", "space", "enter", "cancel"];
5033
+ var _ = { actions: new Set(At), aliases: /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["", "cancel"], ["escape", "cancel"]]), withGuide: true };
5034
+ function H(t, e2) {
5035
+ if (typeof t == "string") return _.aliases.get(t) === e2;
5036
+ for (const s of t) if (s !== void 0 && H(s, e2)) return true;
5037
+ return false;
5038
+ }
5039
+ function _t(t, e2) {
5040
+ if (t === e2) return;
5041
+ const s = t.split(`
5042
+ `), i = e2.split(`
5043
+ `), r = Math.max(s.length, i.length), n = [];
5044
+ for (let u = 0; u < r; u++) s[u] !== i[u] && n.push(u);
5045
+ return { lines: n, numLinesBefore: s.length, numLinesAfter: i.length, numLines: r };
5046
+ }
5047
+ globalThis.process.platform.startsWith("win");
5048
+ var z = /* @__PURE__ */ Symbol("clack:cancel");
5049
+ function Ct(t) {
5050
+ return t === z;
5051
+ }
5052
+ function T(t, e2) {
5053
+ const s = t;
5054
+ s.isTTY && s.setRawMode(e2);
5055
+ }
5056
+ var rt = (t) => "columns" in t && typeof t.columns == "number" ? t.columns : 80;
5057
+ var nt = (t) => "rows" in t && typeof t.rows == "number" ? t.rows : 20;
5058
+ function xt(t, e2, s, i = s) {
5059
+ const r = rt(t ?? stdout);
5060
+ return K(e2, r - s.length, { hard: true, trim: false }).split(`
5061
+ `).map((n, u) => `${u === 0 ? i : s}${n}`).join(`
5062
+ `);
5063
+ }
5064
+ var x = class {
5065
+ input;
5066
+ output;
5067
+ _abortSignal;
5068
+ rl;
5069
+ opts;
5070
+ _render;
5071
+ _track = false;
5072
+ _prevFrame = "";
5073
+ _subscribers = /* @__PURE__ */ new Map();
5074
+ _cursor = 0;
5075
+ state = "initial";
5076
+ error = "";
5077
+ value;
5078
+ userInput = "";
5079
+ constructor(e2, s = true) {
5080
+ const { input: i = stdin, output: r = stdout, render: n, signal: u, ...a } = e2;
5081
+ 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;
5082
+ }
5083
+ unsubscribe() {
5084
+ this._subscribers.clear();
5085
+ }
5086
+ setSubscriber(e2, s) {
5087
+ const i = this._subscribers.get(e2) ?? [];
5088
+ i.push(s), this._subscribers.set(e2, i);
5089
+ }
5090
+ on(e2, s) {
5091
+ this.setSubscriber(e2, { cb: s });
5092
+ }
5093
+ once(e2, s) {
5094
+ this.setSubscriber(e2, { cb: s, once: true });
5095
+ }
5096
+ emit(e2, ...s) {
5097
+ const i = this._subscribers.get(e2) ?? [], r = [];
5098
+ for (const n of i) n.cb(...s), n.once && r.push(() => i.splice(i.indexOf(n), 1));
5099
+ for (const n of r) n();
5100
+ }
5101
+ prompt() {
5102
+ return new Promise((e2) => {
5103
+ if (this._abortSignal) {
5104
+ if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e2(z);
5105
+ this._abortSignal.addEventListener("abort", () => {
5106
+ this.state = "cancel", this.close();
5107
+ }, { once: true });
5108
+ }
5109
+ 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", () => {
5110
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), T(this.input, false), e2(this.value);
5111
+ }), this.once("cancel", () => {
5112
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), T(this.input, false), e2(z);
5113
+ });
5114
+ });
5115
+ }
5116
+ _isActionKey(e2, s) {
5117
+ return e2 === " ";
5118
+ }
5119
+ _setValue(e2) {
5120
+ this.value = e2, this.emit("value", this.value);
5121
+ }
5122
+ _setUserInput(e2, s) {
5123
+ this.userInput = e2 ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
5124
+ }
5125
+ _clearUserInput() {
5126
+ this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
5127
+ }
5128
+ onKeypress(e2, s) {
5129
+ 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") {
5130
+ if (this.opts.validate) {
5131
+ const i = this.opts.validate(this.value);
5132
+ i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
5133
+ }
5134
+ this.state !== "error" && (this.state = "submit");
5135
+ }
5136
+ 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();
5137
+ }
5138
+ close() {
5139
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
5140
+ `), T(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
5141
+ }
5142
+ restoreCursor() {
5143
+ const e2 = K(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
5144
+ `).length - 1;
5145
+ this.output.write(import_sisteransi.cursor.move(-999, e2 * -1));
5146
+ }
5147
+ render() {
5148
+ const e2 = K(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
5149
+ if (e2 !== this._prevFrame) {
5150
+ if (this.state === "initial") this.output.write(import_sisteransi.cursor.hide);
5151
+ else {
5152
+ const s = _t(this._prevFrame, e2), i = nt(this.output);
5153
+ if (this.restoreCursor(), s) {
5154
+ const r = Math.max(0, s.numLinesAfter - i), n = Math.max(0, s.numLinesBefore - i);
5155
+ let u = s.lines.find((a) => a >= r);
5156
+ if (u === void 0) {
5157
+ this._prevFrame = e2;
5158
+ return;
5159
+ }
5160
+ if (s.lines.length === 1) {
5161
+ this.output.write(import_sisteransi.cursor.move(0, u - n)), this.output.write(import_sisteransi.erase.lines(1));
5162
+ const a = e2.split(`
5163
+ `);
5164
+ this.output.write(a[u]), this._prevFrame = e2, this.output.write(import_sisteransi.cursor.move(0, a.length - u - 1));
5165
+ return;
5166
+ } else if (s.lines.length > 1) {
5167
+ if (r < n) u = r;
5168
+ else {
5169
+ const l = u - n;
5170
+ l > 0 && this.output.write(import_sisteransi.cursor.move(0, l));
5171
+ }
5172
+ this.output.write(import_sisteransi.erase.down());
5173
+ const a = e2.split(`
5174
+ `).slice(u);
5175
+ this.output.write(a.join(`
5176
+ `)), this._prevFrame = e2;
5177
+ return;
5178
+ }
5179
+ }
5180
+ this.output.write(import_sisteransi.erase.down());
5181
+ }
5182
+ this.output.write(e2), this.state === "initial" && (this.state = "active"), this._prevFrame = e2;
5183
+ }
5184
+ }
5185
+ };
5186
+ var kt = class extends x {
5187
+ get cursor() {
5188
+ return this.value ? 0 : 1;
5189
+ }
5190
+ get _value() {
5191
+ return this.cursor === 0;
5192
+ }
5193
+ constructor(e2) {
5194
+ super(e2, false), this.value = !!e2.initialValue, this.on("userInput", () => {
5195
+ this.value = this._value;
5196
+ }), this.on("confirm", (s) => {
5197
+ this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
5198
+ }), this.on("cursor", () => {
5199
+ this.value = !this.value;
5200
+ });
5201
+ }
5202
+ };
5203
+ var Wt = class extends x {
5204
+ options;
5205
+ cursor = 0;
5206
+ get _selectedValue() {
5207
+ return this.options[this.cursor];
5208
+ }
5209
+ changeValue() {
5210
+ this.value = this._selectedValue.value;
5211
+ }
5212
+ constructor(e2) {
5213
+ super(e2, false), this.options = e2.options;
5214
+ const s = this.options.findIndex(({ value: r }) => r === e2.initialValue), i = s === -1 ? 0 : s;
5215
+ this.cursor = this.options[i].disabled ? B(i, 1, this.options) : i, this.changeValue(), this.on("cursor", (r) => {
5216
+ switch (r) {
5217
+ case "left":
5218
+ case "up":
5219
+ this.cursor = B(this.cursor, -1, this.options);
5220
+ break;
5221
+ case "down":
5222
+ case "right":
5223
+ this.cursor = B(this.cursor, 1, this.options);
5224
+ break;
5225
+ }
5226
+ this.changeValue();
5227
+ });
5228
+ }
5229
+ };
5230
+ var $t = class extends x {
5231
+ get userInputWithCursor() {
5232
+ if (this.state === "submit") return this.userInput;
5233
+ const e2 = this.userInput;
5234
+ if (this.cursor >= e2.length) return `${this.userInput}\u2588`;
5235
+ const s = e2.slice(0, this.cursor), [i, ...r] = e2.slice(this.cursor);
5236
+ return `${s}${import_picocolors.default.inverse(i)}${r.join("")}`;
5237
+ }
5238
+ get cursor() {
5239
+ return this._cursor;
5240
+ }
5241
+ constructor(e2) {
5242
+ super({ ...e2, initialUserInput: e2.initialUserInput ?? e2.initialValue }), this.on("userInput", (s) => {
5243
+ this._setValue(s);
5244
+ }), this.on("finalize", () => {
5245
+ this.value || (this.value = e2.defaultValue), this.value === void 0 && (this.value = "");
5246
+ });
5247
+ }
5248
+ };
5249
+
5250
+ // ../../node_modules/.pnpm/@clack+prompts@1.0.1/node_modules/@clack/prompts/dist/index.mjs
5251
+ var import_picocolors2 = __toESM(require_picocolors());
5252
+ __toESM(require_src());
5253
+ function me() {
5254
+ 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";
5255
+ }
5256
+ var et2 = me();
5257
+ var C = (t, r) => et2 ? t : r;
5258
+ var Rt = C("\u25C6", "*");
5259
+ var dt2 = C("\u25A0", "x");
5260
+ var $t2 = C("\u25B2", "x");
5261
+ var V = C("\u25C7", "o");
5262
+ var ht2 = C("\u250C", "T");
5263
+ var d = C("\u2502", "|");
5264
+ var x2 = C("\u2514", "\u2014");
5265
+ var Q2 = C("\u25CF", ">");
5266
+ var H2 = C("\u25CB", " ");
5267
+ var rt2 = C("\u2500", "-");
5268
+ var mt2 = C("\u256E", "+");
5269
+ var Wt2 = C("\u251C", "+");
5270
+ var pt2 = C("\u256F", "+");
5271
+ var W2 = (t) => {
5272
+ switch (t) {
5273
+ case "initial":
5274
+ case "active":
5275
+ return import_picocolors2.default.cyan(Rt);
5276
+ case "cancel":
5277
+ return import_picocolors2.default.red(dt2);
5278
+ case "error":
5279
+ return import_picocolors2.default.yellow($t2);
5280
+ case "submit":
5281
+ return import_picocolors2.default.green(V);
5282
+ }
5283
+ };
5284
+ var vt2 = (t) => {
5285
+ switch (t) {
5286
+ case "initial":
5287
+ case "active":
5288
+ return import_picocolors2.default.cyan(d);
5289
+ case "cancel":
5290
+ return import_picocolors2.default.red(d);
5291
+ case "error":
5292
+ return import_picocolors2.default.yellow(d);
5293
+ case "submit":
5294
+ return import_picocolors2.default.green(d);
5295
+ }
5296
+ };
5297
+ 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;
5298
+ var ge = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510;
5299
+ 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;
5300
+ var At2 = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
5301
+ var it2 = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
5302
+ var nt2 = /\t{1,1000}/y;
5303
+ 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;
5304
+ var at2 = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
5305
+ var Fe = /\p{M}+/gu;
5306
+ var ye = { limit: 1 / 0, ellipsis: "" };
5307
+ var jt = (t, r = {}, s = {}) => {
5308
+ 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;
5309
+ 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;
5310
+ t: for (; ; ) {
5311
+ if (B2 > I2 || m >= h && m > $) {
5312
+ const _2 = t.slice(I2, B2) || t.slice($, m);
5313
+ y2 = 0;
5314
+ for (const D2 of _2.replaceAll(Fe, "")) {
5315
+ const T2 = D2.codePointAt(0) || 0;
5316
+ 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) {
5317
+ f = true;
5318
+ break t;
5319
+ }
5320
+ y2 += D2.length, A += w;
5321
+ }
5322
+ I2 = B2 = 0;
5323
+ }
5324
+ if (m >= h) break;
5325
+ if (at2.lastIndex = m, at2.test(t)) {
5326
+ if (y2 = at2.lastIndex - m, w = y2 * p, A + w > S2 && (v = Math.min(v, m + Math.floor((S2 - A) / p))), A + w > i) {
5327
+ f = true;
5328
+ break;
5329
+ }
5330
+ A += w, I2 = $, B2 = m, m = $ = at2.lastIndex;
5331
+ continue;
5332
+ }
5333
+ if (At2.lastIndex = m, At2.test(t)) {
5334
+ if (A + u > S2 && (v = Math.min(v, m)), A + u > i) {
5335
+ f = true;
5336
+ break;
5337
+ }
5338
+ A += u, I2 = $, B2 = m, m = $ = At2.lastIndex;
5339
+ continue;
5340
+ }
5341
+ if (it2.lastIndex = m, it2.test(t)) {
5342
+ if (y2 = it2.lastIndex - m, w = y2 * l, A + w > S2 && (v = Math.min(v, m + Math.floor((S2 - A) / l))), A + w > i) {
5343
+ f = true;
5344
+ break;
5345
+ }
5346
+ A += w, I2 = $, B2 = m, m = $ = it2.lastIndex;
5347
+ continue;
5348
+ }
5349
+ if (nt2.lastIndex = m, nt2.test(t)) {
5350
+ if (y2 = nt2.lastIndex - m, w = y2 * n, A + w > S2 && (v = Math.min(v, m + Math.floor((S2 - A) / n))), A + w > i) {
5351
+ f = true;
5352
+ break;
5353
+ }
5354
+ A += w, I2 = $, B2 = m, m = $ = nt2.lastIndex;
5355
+ continue;
5356
+ }
5357
+ if (wt.lastIndex = m, wt.test(t)) {
5358
+ if (A + g > S2 && (v = Math.min(v, m)), A + g > i) {
5359
+ f = true;
5360
+ break;
5361
+ }
5362
+ A += g, I2 = $, B2 = m, m = $ = wt.lastIndex;
5363
+ continue;
5364
+ }
5365
+ m += 1;
5366
+ }
5367
+ return { width: f ? S2 : A, index: f ? v : h, truncated: f, ellipsed: f && i >= o };
5368
+ };
5369
+ var Ee = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
5370
+ var M2 = (t, r = {}) => jt(t, Ee, r).width;
5371
+ var ot2 = "\x1B";
5372
+ var Gt = "\x9B";
5373
+ var ve = 39;
5374
+ var Ct2 = "\x07";
5375
+ var kt2 = "[";
5376
+ var Ae = "]";
5377
+ var Vt2 = "m";
5378
+ var St = `${Ae}8;;`;
5379
+ var Ht = new RegExp(`(?:\\${kt2}(?<code>\\d+)m|\\${St}(?<uri>.*)${Ct2})`, "y");
5380
+ var we = (t) => {
5381
+ if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
5382
+ if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
5383
+ if (t === 1 || t === 2) return 22;
5384
+ if (t === 3) return 23;
5385
+ if (t === 4) return 24;
5386
+ if (t === 7) return 27;
5387
+ if (t === 8) return 28;
5388
+ if (t === 9) return 29;
5389
+ if (t === 0) return 0;
5390
+ };
5391
+ var Ut = (t) => `${ot2}${kt2}${t}${Vt2}`;
5392
+ var Kt = (t) => `${ot2}${St}${t}${Ct2}`;
5393
+ var Ce = (t) => t.map((r) => M2(r));
5394
+ var It2 = (t, r, s) => {
5395
+ const i = r[Symbol.iterator]();
5396
+ let a = false, o = false, u = t.at(-1), l = u === void 0 ? 0 : M2(u), n = i.next(), c = i.next(), g = 0;
5397
+ for (; !n.done; ) {
5398
+ const F = n.value, p = M2(F);
5399
+ 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;
5400
+ }
5401
+ u = t.at(-1), !l && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
5402
+ };
5403
+ var Se = (t) => {
5404
+ const r = t.split(" ");
5405
+ let s = r.length;
5406
+ for (; s > 0 && !(M2(r[s - 1]) > 0); ) s--;
5407
+ return s === r.length ? t : r.slice(0, s).join(" ") + r.slice(s).join("");
5408
+ };
5409
+ var Ie = (t, r, s = {}) => {
5410
+ if (s.trim !== false && t.trim() === "") return "";
5411
+ let i = "", a, o;
5412
+ const u = t.split(" "), l = Ce(u);
5413
+ let n = [""];
5414
+ for (const [$, m] of u.entries()) {
5415
+ s.trim !== false && (n[n.length - 1] = (n.at(-1) ?? "").trimStart());
5416
+ let h = M2(n.at(-1) ?? "");
5417
+ 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) {
5418
+ const y2 = r - h, f = 1 + Math.floor((l[$] - y2 - 1) / r);
5419
+ Math.floor((l[$] - 1) / r) < f && n.push(""), It2(n, m, r);
5420
+ continue;
5421
+ }
5422
+ if (h + l[$] > r && h > 0 && l[$] > 0) {
5423
+ if (s.wordWrap === false && h < r) {
5424
+ It2(n, m, r);
5425
+ continue;
5426
+ }
5427
+ n.push("");
5428
+ }
5429
+ if (h + l[$] > r && s.wordWrap === false) {
5430
+ It2(n, m, r);
5431
+ continue;
5432
+ }
5433
+ n[n.length - 1] += m;
5434
+ }
5435
+ s.trim !== false && (n = n.map(($) => Se($)));
5436
+ const c = n.join(`
5437
+ `), g = c[Symbol.iterator]();
5438
+ let F = g.next(), p = g.next(), E = 0;
5439
+ for (; !F.done; ) {
5440
+ const $ = F.value, m = p.value;
5441
+ if (i += $, $ === ot2 || $ === Gt) {
5442
+ Ht.lastIndex = E + 1;
5443
+ const f = Ht.exec(c)?.groups;
5444
+ if (f?.code !== void 0) {
5445
+ const v = Number.parseFloat(f.code);
5446
+ a = v === ve ? void 0 : v;
5447
+ } else f?.uri !== void 0 && (o = f.uri.length === 0 ? void 0 : f.uri);
5448
+ }
5449
+ const h = a ? we(a) : void 0;
5450
+ m === `
5451
+ ` ? (o && (i += Kt("")), a && h && (i += Ut(h))) : $ === `
5452
+ ` && (a && h && (i += Ut(a)), o && (i += Kt(o))), E += $.length, F = p, p = g.next();
5453
+ }
5454
+ return i;
5455
+ };
5456
+ function J2(t, r, s) {
5457
+ return String(t).normalize().replaceAll(`\r
5458
+ `, `
5459
+ `).split(`
5460
+ `).map((i) => Ie(i, r, s)).join(`
5461
+ `);
5462
+ }
5463
+ var be = (t, r, s, i, a) => {
5464
+ let o = r, u = 0;
5465
+ for (let l = s; l < i; l++) {
5466
+ const n = t[l];
5467
+ if (o = o - n.length, u++, o <= a) break;
5468
+ }
5469
+ return { lineCount: o, removals: u };
5470
+ };
5471
+ var X2 = (t) => {
5472
+ 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);
5473
+ let $ = 0;
5474
+ r >= E - 3 && ($ = Math.max(Math.min(r - E + 3, s.length - E), 0));
5475
+ let m = E < s.length && $ > 0, h = E < s.length && $ + E < s.length;
5476
+ const y2 = Math.min($ + E, s.length), f = [];
5477
+ let v = 0;
5478
+ m && v++, h && v++;
5479
+ const S2 = $ + (m ? 1 : 0), I2 = y2 - (h ? 1 : 0);
5480
+ for (let A = S2; A < I2; A++) {
5481
+ const w = J2(i(s[A], A === r), n, { hard: true, trim: false }).split(`
5482
+ `);
5483
+ f.push(w), v += w.length;
5484
+ }
5485
+ if (v > p) {
5486
+ let A = 0, w = 0, _2 = v;
5487
+ const D2 = r - S2, T2 = (Y, L2) => be(f, _2, Y, L2, p);
5488
+ 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));
5489
+ }
5490
+ const B2 = [];
5491
+ m && B2.push(g);
5492
+ for (const A of f) for (const w of A) B2.push(w);
5493
+ return h && B2.push(g), B2;
5494
+ };
5495
+ var Re = (t) => {
5496
+ const r = t.active ?? "Yes", s = t.inactive ?? "No";
5497
+ return new kt({ active: r, inactive: s, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue ?? true, render() {
5498
+ const i = t.withGuide ?? _.withGuide, a = `${i ? `${import_picocolors2.default.gray(d)}
5499
+ ` : ""}${W2(this.state)} ${t.message}
5500
+ `, o = this.value ? r : s;
5501
+ switch (this.state) {
5502
+ case "submit": {
5503
+ const u = i ? `${import_picocolors2.default.gray(d)} ` : "";
5504
+ return `${a}${u}${import_picocolors2.default.dim(o)}`;
5505
+ }
5506
+ case "cancel": {
5507
+ const u = i ? `${import_picocolors2.default.gray(d)} ` : "";
5508
+ return `${a}${u}${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(o))}${i ? `
5509
+ ${import_picocolors2.default.gray(d)}` : ""}`;
5510
+ }
5511
+ default: {
5512
+ const u = i ? `${import_picocolors2.default.cyan(d)} ` : "", l = i ? import_picocolors2.default.cyan(x2) : "";
5513
+ return `${a}${u}${this.value ? `${import_picocolors2.default.green(Q2)} ${r}` : `${import_picocolors2.default.dim(H2)} ${import_picocolors2.default.dim(r)}`}${t.vertical ? i ? `
5514
+ ${import_picocolors2.default.cyan(d)} ` : `
5515
+ ` : ` ${import_picocolors2.default.dim("/")} `}${this.value ? `${import_picocolors2.default.dim(H2)} ${import_picocolors2.default.dim(s)}` : `${import_picocolors2.default.green(Q2)} ${s}`}
5516
+ ${l}
5517
+ `;
5518
+ }
5519
+ }
5520
+ } }).prompt();
5521
+ };
5522
+ var Ne = (t = "", r) => {
5523
+ (process.stdout).write(`${import_picocolors2.default.gray(x2)} ${import_picocolors2.default.red(t)}
5524
+
5525
+ `);
5526
+ };
5527
+ var We = (t = "", r) => {
5528
+ (process.stdout).write(`${import_picocolors2.default.gray(ht2)} ${t}
5529
+ `);
5530
+ };
5531
+ var Le = (t = "", r) => {
5532
+ (process.stdout).write(`${import_picocolors2.default.gray(d)}
5533
+ ${import_picocolors2.default.gray(x2)} ${t}
5534
+
5535
+ `);
5536
+ };
5537
+ var Ge = (t) => import_picocolors2.default.dim(t);
5538
+ var ke = (t, r, s) => {
5539
+ const i = { hard: true, trim: false }, a = J2(t, r, i).split(`
5540
+ `), 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);
5541
+ return J2(t, l, i);
5542
+ };
5543
+ var Ve = (t = "", r = "", s) => {
5544
+ const i = N2.stdout, o = Ge, u = ["", ...ke(t, rt(i) - 6, o).split(`
5545
+ `).map(o), ""], l = M2(r), n = Math.max(u.reduce((p, E) => {
5546
+ const $ = M2(E);
5547
+ return $ > p ? $ : p;
5548
+ }, 0), l) + 2, c = u.map((p) => `${import_picocolors2.default.gray(d)} ${p}${" ".repeat(n - M2(p))}${import_picocolors2.default.gray(d)}`).join(`
5549
+ `), g = `${import_picocolors2.default.gray(d)}
5550
+ ` , F = Wt2 ;
5551
+ 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)}
5552
+ ${c}
5553
+ ${import_picocolors2.default.gray(F + rt2.repeat(n + 2) + pt2)}
5554
+ `);
5555
+ };
5556
+ import_picocolors2.default.magenta;
5557
+ var lt2 = (t, r) => t.includes(`
5558
+ `) ? t.split(`
5559
+ `).map((s) => r(s)).join(`
5560
+ `) : r(t);
5561
+ var Je = (t) => {
5562
+ const r = (s, i) => {
5563
+ const a = s.label ?? String(s.value);
5564
+ switch (i) {
5565
+ case "disabled":
5566
+ return `${import_picocolors2.default.gray(H2)} ${lt2(a, import_picocolors2.default.gray)}${s.hint ? ` ${import_picocolors2.default.dim(`(${s.hint ?? "disabled"})`)}` : ""}`;
5567
+ case "selected":
5568
+ return `${lt2(a, import_picocolors2.default.dim)}`;
5569
+ case "active":
5570
+ return `${import_picocolors2.default.green(Q2)} ${a}${s.hint ? ` ${import_picocolors2.default.dim(`(${s.hint})`)}` : ""}`;
5571
+ case "cancelled":
5572
+ return `${lt2(a, (o) => import_picocolors2.default.strikethrough(import_picocolors2.default.dim(o)))}`;
5573
+ default:
5574
+ return `${import_picocolors2.default.dim(H2)} ${lt2(a, import_picocolors2.default.dim)}`;
5575
+ }
5576
+ };
5577
+ return new Wt({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue, render() {
5578
+ 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)}
5579
+ ` : ""}${o}
5580
+ `;
5581
+ switch (this.state) {
5582
+ case "submit": {
5583
+ const l = s ? `${import_picocolors2.default.gray(d)} ` : "", n = xt(t.output, r(this.options[this.cursor], "selected"), l);
5584
+ return `${u}${n}`;
5585
+ }
5586
+ case "cancel": {
5587
+ const l = s ? `${import_picocolors2.default.gray(d)} ` : "", n = xt(t.output, r(this.options[this.cursor], "cancelled"), l);
5588
+ return `${u}${n}${s ? `
5589
+ ${import_picocolors2.default.gray(d)}` : ""}`;
5590
+ }
5591
+ default: {
5592
+ const l = s ? `${import_picocolors2.default.cyan(d)} ` : "", n = s ? import_picocolors2.default.cyan(x2) : "", c = u.split(`
5593
+ `).length, g = s ? 2 : 1;
5594
+ 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(`
5595
+ ${l}`)}
5596
+ ${n}
5597
+ `;
5598
+ }
5599
+ }
5600
+ } }).prompt();
5601
+ };
5602
+ `${import_picocolors2.default.gray(d)} `;
5603
+ 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() {
5604
+ const r = t?.withGuide ?? _.withGuide, s = `${`${r ? `${import_picocolors2.default.gray(d)}
5605
+ ` : ""}${W2(this.state)} `}${t.message}
5606
+ `, 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 ?? "";
5607
+ switch (this.state) {
5608
+ case "error": {
5609
+ const u = this.error ? ` ${import_picocolors2.default.yellow(this.error)}` : "", l = r ? `${import_picocolors2.default.yellow(d)} ` : "", n = r ? import_picocolors2.default.yellow(x2) : "";
5610
+ return `${s.trim()}
5611
+ ${l}${a}
5612
+ ${n}${u}
5613
+ `;
5614
+ }
5615
+ case "submit": {
5616
+ const u = o ? ` ${import_picocolors2.default.dim(o)}` : "", l = r ? import_picocolors2.default.gray(d) : "";
5617
+ return `${s}${l}${u}`;
5618
+ }
5619
+ case "cancel": {
5620
+ const u = o ? ` ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(o))}` : "", l = r ? import_picocolors2.default.gray(d) : "";
5621
+ return `${s}${l}${u}${o.trim() ? `
5622
+ ${l}` : ""}`;
5623
+ }
5624
+ default: {
5625
+ const u = r ? `${import_picocolors2.default.cyan(d)} ` : "", l = r ? import_picocolors2.default.cyan(x2) : "";
5626
+ return `${s}${u}${a}
5627
+ ${l}
5628
+ `;
5629
+ }
5630
+ }
5631
+ } }).prompt();
5632
+ var PROJECT_REPO = "https://github.com/BytePioneer-AI/moltbot-china";
5633
+ var GUIDES_BASE = "https://github.com/BytePioneer-AI/openclaw-china/tree/main/doc/guides";
5634
+ var OPENCLAW_HOME = join(homedir(), ".openclaw");
5635
+ var DEFAULT_PLUGIN_PATH = join(OPENCLAW_HOME, "extensions");
5636
+ var LEGACY_PLUGIN_PATH = join(OPENCLAW_HOME, "plugins");
5637
+ var CONFIG_FILE_PATH = join(OPENCLAW_HOME, "openclaw.json");
5638
+ var ANSI_RESET = "\x1B[0m";
5639
+ var ANSI_LINK = "\x1B[1;4;96m";
5640
+ var ANSI_BORDER = "\x1B[92m";
5641
+ var CHANNEL_ORDER = [
5642
+ "dingtalk",
5643
+ "qqbot",
5644
+ "wecom",
5645
+ "wecom-app",
5646
+ "feishu-china"
5647
+ ];
5648
+ var CHANNEL_DISPLAY_LABELS = {
5649
+ dingtalk: "DingTalk\uFF08\u9489\u9489\uFF09",
5650
+ "feishu-china": "Feishu\uFF08\u98DE\u4E66\uFF09",
5651
+ wecom: "WeCom\uFF08\u4F01\u4E1A\u5FAE\u4FE1-\u667A\u80FD\u673A\u5668\u4EBA\uFF09",
5652
+ "wecom-app": "WeCom App\uFF08\u81EA\u5EFA\u5E94\u7528-\u53EF\u63A5\u5165\u5FAE\u4FE1\uFF09",
5653
+ qqbot: "QQBot\uFF08QQ \u673A\u5668\u4EBA\uFF09"
5654
+ };
5655
+ var CHANNEL_GUIDE_LINKS = {
5656
+ dingtalk: `${GUIDES_BASE}/dingtalk/configuration.md`,
5657
+ "feishu-china": "https://github.com/BytePioneer-AI/openclaw-china/blob/main/README.md",
5658
+ wecom: `${GUIDES_BASE}/wecom/configuration.md`,
5659
+ "wecom-app": `${GUIDES_BASE}/wecom-app/configuration.md`,
5660
+ qqbot: `${GUIDES_BASE}/qqbot/configuration.md`
5661
+ };
5662
+ var CHINA_CLI_STATE_KEY = /* @__PURE__ */ Symbol.for("@openclaw-china/china-cli-state");
5663
+ var PromptCancelledError = class extends Error {
5664
+ constructor() {
5665
+ super("prompt-cancelled");
5666
+ }
5667
+ };
5668
+ function isChannelId(value) {
5669
+ return typeof value === "string" && CHANNEL_ORDER.includes(value);
5670
+ }
5671
+ function getChinaCliState() {
5672
+ const root = globalThis;
5673
+ const cached = root[CHINA_CLI_STATE_KEY];
5674
+ if (isRecord(cached)) {
5675
+ const channels = cached.channels;
5676
+ const cliRegistered = cached.cliRegistered;
5677
+ if (channels instanceof Set && typeof cliRegistered === "boolean") {
5678
+ return {
5679
+ channels,
5680
+ cliRegistered
5681
+ };
5682
+ }
5683
+ }
5684
+ const created = {
5685
+ channels: /* @__PURE__ */ new Set(),
5686
+ cliRegistered: false
5687
+ };
5688
+ root[CHINA_CLI_STATE_KEY] = created;
5689
+ return created;
5690
+ }
5691
+ function normalizeChannels(channels) {
5692
+ const selected = channels && channels.length > 0 ? channels : CHANNEL_ORDER;
5693
+ const unique = /* @__PURE__ */ new Set();
5694
+ for (const channelId of selected) {
5695
+ if (isChannelId(channelId)) {
5696
+ unique.add(channelId);
5697
+ }
5698
+ }
5699
+ return CHANNEL_ORDER.filter((channelId) => unique.has(channelId));
5700
+ }
5701
+ function getInstalledChannels(state) {
5702
+ return CHANNEL_ORDER.filter((channelId) => state.channels.has(channelId));
5703
+ }
5704
+ function guardCancel(value) {
5705
+ if (Ct(value)) {
5706
+ Ne("\u5DF2\u53D6\u6D88\u914D\u7F6E\u3002");
5707
+ throw new PromptCancelledError();
5708
+ }
5709
+ return value;
5710
+ }
5711
+ function warn(text) {
5712
+ stdout.write(`
5713
+ [warn] ${text}
5714
+ `);
5715
+ }
5716
+ function section(title) {
5717
+ stdout.write(`
5718
+ ${title}
5719
+ `);
5720
+ }
5721
+ function resolvePluginPath() {
5722
+ if (existsSync(DEFAULT_PLUGIN_PATH)) {
5723
+ return DEFAULT_PLUGIN_PATH;
5724
+ }
5725
+ if (existsSync(LEGACY_PLUGIN_PATH)) {
5726
+ return LEGACY_PLUGIN_PATH;
5727
+ }
5728
+ return DEFAULT_PLUGIN_PATH;
5729
+ }
5730
+ function renderReadyMessage() {
5731
+ return [
5732
+ `${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}`,
5733
+ " OpenClaw China Channels \u5DF2\u5C31\u7EEA!",
5734
+ `${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}`,
5735
+ "",
5736
+ "\u63D2\u4EF6\u8DEF\u5F84:",
5737
+ ` ${resolvePluginPath()}`,
5738
+ "",
5739
+ "\u914D\u7F6E\u6587\u4EF6:",
5740
+ ` ${CONFIG_FILE_PATH}`,
5741
+ "",
5742
+ "\u66F4\u65B0\u63D2\u4EF6:",
5743
+ " openclaw plugins update <plugin-id>",
5744
+ "",
5745
+ "\u9879\u76EE\u4ED3\u5E93:",
5746
+ ` ${ANSI_LINK}${PROJECT_REPO}${ANSI_RESET}`,
5747
+ "",
5748
+ "\u2B50 \u5982\u679C\u8FD9\u4E2A\u9879\u76EE\u5BF9\u4F60\u6709\u5E2E\u52A9\uFF0C\u8BF7\u7ED9\u6211\u4EEC\u4E00\u4E2A Star\uFF01\u2B50",
5749
+ "",
5750
+ "\u4E0B\u4E00\u6B65:",
5751
+ " openclaw gateway --port 18789 --verbose",
5752
+ ""
5753
+ ].join("\n");
5754
+ }
5755
+ function showReadyMessage() {
5756
+ stdout.write(`
5757
+ ${renderReadyMessage()}
5758
+ `);
5759
+ }
5760
+ function showGuideLink(channelId) {
5761
+ const url = CHANNEL_GUIDE_LINKS[channelId];
5762
+ Ve(`\u914D\u7F6E\u6587\u6863\uFF1A${url}`, "Docs");
5763
+ }
5764
+ function isRecord(value) {
5765
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5766
+ }
5767
+ function resolveWriteConfig(runtime2) {
5768
+ if (!isRecord(runtime2)) {
5769
+ return void 0;
5770
+ }
5771
+ const config = runtime2.config;
5772
+ if (!isRecord(config)) {
5773
+ return void 0;
5774
+ }
5775
+ if (typeof config.writeConfigFile !== "function") {
5776
+ return void 0;
5777
+ }
5778
+ return config.writeConfigFile;
5779
+ }
5780
+ function isCommandLike(value) {
5781
+ if (!isRecord(value)) {
5782
+ return false;
5783
+ }
5784
+ return typeof value.command === "function" && typeof value.description === "function" && typeof value.action === "function";
5785
+ }
5786
+ function toTrimmedString(value) {
5787
+ if (typeof value !== "string") {
5788
+ return void 0;
5789
+ }
5790
+ const trimmed = value.trim();
5791
+ return trimmed || void 0;
5792
+ }
5793
+ function hasNonEmptyString(value) {
5794
+ return typeof value === "string" && value.trim().length > 0;
5795
+ }
5796
+ function toBoolean(value, fallback) {
5797
+ return typeof value === "boolean" ? value : fallback;
5798
+ }
5799
+ function toNumber(value) {
5800
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
5801
+ }
5802
+ function cloneConfig(cfg) {
5803
+ try {
5804
+ return structuredClone(cfg);
5805
+ } catch {
5806
+ return JSON.parse(JSON.stringify(cfg));
5807
+ }
5808
+ }
5809
+ function getChannelConfig(cfg, channelId) {
5810
+ const channels = isRecord(cfg.channels) ? cfg.channels : {};
5811
+ const existing = channels[channelId];
5812
+ return isRecord(existing) ? existing : {};
5813
+ }
5814
+ function getPreferredAccountConfig(channelCfg) {
5815
+ const accounts = channelCfg.accounts;
5816
+ if (!isRecord(accounts)) {
5817
+ return void 0;
5818
+ }
5819
+ const defaultAccountId = toTrimmedString(channelCfg.defaultAccount);
5820
+ if (defaultAccountId) {
5821
+ const preferred = accounts[defaultAccountId];
5822
+ if (isRecord(preferred)) {
5823
+ return preferred;
5824
+ }
5825
+ }
5826
+ for (const value of Object.values(accounts)) {
5827
+ if (isRecord(value)) {
5828
+ return value;
5829
+ }
5830
+ }
5831
+ return void 0;
5832
+ }
5833
+ function hasTokenPair(channelCfg) {
5834
+ if (hasNonEmptyString(channelCfg.token) && hasNonEmptyString(channelCfg.encodingAESKey)) {
5835
+ return true;
5836
+ }
5837
+ const accountCfg = getPreferredAccountConfig(channelCfg);
5838
+ return Boolean(
5839
+ accountCfg && hasNonEmptyString(accountCfg.token) && hasNonEmptyString(accountCfg.encodingAESKey)
5840
+ );
5841
+ }
5842
+ function isChannelConfigured(cfg, channelId) {
5843
+ const channelCfg = getChannelConfig(cfg, channelId);
5844
+ switch (channelId) {
5845
+ case "dingtalk":
5846
+ return hasNonEmptyString(channelCfg.clientId) && hasNonEmptyString(channelCfg.clientSecret);
5847
+ case "feishu-china":
5848
+ return hasNonEmptyString(channelCfg.appId) && hasNonEmptyString(channelCfg.appSecret);
5849
+ case "qqbot":
5850
+ return hasNonEmptyString(channelCfg.appId) && hasNonEmptyString(channelCfg.clientSecret);
5851
+ case "wecom":
5852
+ case "wecom-app":
5853
+ return hasTokenPair(channelCfg);
5854
+ default:
5855
+ return false;
5856
+ }
5857
+ }
5858
+ function withConfiguredSuffix(cfg, channelId) {
5859
+ const base = CHANNEL_DISPLAY_LABELS[channelId];
5860
+ return isChannelConfigured(cfg, channelId) ? `${base}\uFF08\u5DF2\u914D\u7F6E\uFF09` : base;
5861
+ }
5862
+ function mergeChannelConfig(cfg, channelId, patch) {
5863
+ const channels = isRecord(cfg.channels) ? { ...cfg.channels } : {};
5864
+ const existing = getChannelConfig(cfg, channelId);
5865
+ channels[channelId] = {
5866
+ ...existing,
5867
+ ...patch,
5868
+ enabled: true
5869
+ };
5870
+ return {
5871
+ ...cfg,
5872
+ channels
5873
+ };
5874
+ }
5875
+ var SetupPrompter = class {
5876
+ async askText(params) {
5877
+ const { label, required = false, defaultValue } = params;
5878
+ while (true) {
5879
+ const value = String(
5880
+ guardCancel(
5881
+ await Ze({
5882
+ message: label,
5883
+ initialValue: defaultValue
5884
+ })
5885
+ )
5886
+ ).trim();
5887
+ if (value) {
5888
+ return value;
5889
+ }
5890
+ if (defaultValue) {
5891
+ return defaultValue;
5892
+ }
5893
+ if (!required) {
5894
+ return "";
5895
+ }
5896
+ warn("\u8BE5\u5B57\u6BB5\u4E3A\u5FC5\u586B\u9879\u3002");
5897
+ }
5898
+ }
5899
+ async askSecret(params) {
5900
+ const { label, existingValue, required = true } = params;
5901
+ return this.askText({
5902
+ label,
5903
+ required,
5904
+ defaultValue: existingValue
5905
+ });
5906
+ }
5907
+ async askConfirm(label, defaultValue = true) {
5908
+ return Boolean(
5909
+ guardCancel(
5910
+ await Re({
5911
+ message: label,
5912
+ initialValue: defaultValue
5913
+ })
5914
+ )
5915
+ );
5916
+ }
5917
+ async askNumber(params) {
5918
+ const { label, min, defaultValue } = params;
5919
+ while (true) {
5920
+ const raw = String(
5921
+ guardCancel(
5922
+ await Ze({
5923
+ message: label,
5924
+ initialValue: defaultValue !== void 0 ? String(defaultValue) : void 0
5925
+ })
5926
+ )
5927
+ ).trim();
5928
+ const parsed = Number.parseInt(raw, 10);
5929
+ if (Number.isFinite(parsed) && (min === void 0 || parsed >= min)) {
5930
+ return parsed;
5931
+ }
5932
+ warn(`\u8BF7\u8F93\u5165\u6709\u6548\u6574\u6570${min !== void 0 ? `\uFF08>= ${min}\uFF09` : ""}\u3002`);
5933
+ }
5934
+ }
5935
+ async askSelect(message, options, defaultValue) {
5936
+ const initial = options.some((opt) => opt.value === defaultValue) ? defaultValue : options[0]?.value;
5937
+ const selectOptions = options.map((option) => ({
5938
+ value: option.value,
5939
+ label: option.label
5940
+ }));
5941
+ return guardCancel(
5942
+ await Je({
5943
+ message,
5944
+ options: selectOptions,
5945
+ initialValue: initial
5946
+ })
5947
+ );
5948
+ }
5949
+ };
5950
+ async function configureDingtalk(prompter, cfg) {
5951
+ section("\u914D\u7F6E DingTalk\uFF08\u9489\u9489\uFF09");
5952
+ showGuideLink("dingtalk");
5953
+ const existing = getChannelConfig(cfg, "dingtalk");
5954
+ const clientId = await prompter.askText({
5955
+ label: "DingTalk clientId\uFF08AppKey\uFF09",
5956
+ defaultValue: toTrimmedString(existing.clientId),
5957
+ required: true
5958
+ });
5959
+ const clientSecret = await prompter.askSecret({
5960
+ label: "DingTalk clientSecret\uFF08AppSecret\uFF09",
5961
+ existingValue: toTrimmedString(existing.clientSecret),
5962
+ required: true
5963
+ });
5964
+ const enableAICard = await prompter.askConfirm(
5965
+ "\u542F\u7528 AI Card \u6D41\u5F0F\u56DE\u590D\uFF08\u63A8\u8350\u5173\u95ED\uFF0C\u4F7F\u7528\u975E\u6D41\u5F0F\uFF09",
5966
+ toBoolean(existing.enableAICard, false)
5967
+ );
5968
+ return mergeChannelConfig(cfg, "dingtalk", {
5969
+ clientId,
5970
+ clientSecret,
5971
+ enableAICard
5972
+ });
5973
+ }
5974
+ async function configureFeishu(prompter, cfg) {
5975
+ section("\u914D\u7F6E Feishu\uFF08\u98DE\u4E66\uFF09");
5976
+ showGuideLink("feishu-china");
5977
+ const existing = getChannelConfig(cfg, "feishu-china");
5978
+ const appId = await prompter.askText({
5979
+ label: "Feishu appId",
5980
+ defaultValue: toTrimmedString(existing.appId),
5981
+ required: true
5982
+ });
5983
+ const appSecret = await prompter.askSecret({
5984
+ label: "Feishu appSecret",
5985
+ existingValue: toTrimmedString(existing.appSecret),
5986
+ required: true
5987
+ });
5988
+ const sendMarkdownAsCard = await prompter.askConfirm(
5989
+ "\u4EE5\u5361\u7247\u5F62\u5F0F\u53D1\u9001 Markdown",
5990
+ toBoolean(existing.sendMarkdownAsCard, true)
5991
+ );
5992
+ return mergeChannelConfig(cfg, "feishu-china", {
5993
+ appId,
5994
+ appSecret,
5995
+ sendMarkdownAsCard
5996
+ });
5997
+ }
5998
+ async function configureWecom(prompter, cfg) {
5999
+ section("\u914D\u7F6E WeCom\uFF08\u4F01\u4E1A\u5FAE\u4FE1-\u667A\u80FD\u673A\u5668\u4EBA\uFF09");
6000
+ showGuideLink("wecom");
6001
+ const existing = getChannelConfig(cfg, "wecom");
6002
+ const webhookPath = await prompter.askText({
6003
+ label: "Webhook \u8DEF\u5F84\uFF08\u9700\u4E0E\u4F01\u4E1A\u5FAE\u4FE1\u540E\u53F0\u914D\u7F6E\u4E00\u81F4\uFF0C\u9ED8\u8BA4 /wecom\uFF09",
6004
+ defaultValue: toTrimmedString(existing.webhookPath) ?? "/wecom",
6005
+ required: true
6006
+ });
6007
+ const token = await prompter.askSecret({
6008
+ label: "WeCom token",
6009
+ existingValue: toTrimmedString(existing.token),
6010
+ required: true
6011
+ });
6012
+ const encodingAESKey = await prompter.askSecret({
6013
+ label: "WeCom encodingAESKey",
6014
+ existingValue: toTrimmedString(existing.encodingAESKey),
6015
+ required: true
6016
+ });
6017
+ return mergeChannelConfig(cfg, "wecom", {
6018
+ webhookPath,
6019
+ token,
6020
+ encodingAESKey
6021
+ });
6022
+ }
6023
+ async function configureWecomApp(prompter, cfg) {
6024
+ section("\u914D\u7F6E WeCom App\uFF08\u81EA\u5EFA\u5E94\u7528-\u53EF\u63A5\u5165\u5FAE\u4FE1\uFF09");
6025
+ showGuideLink("wecom-app");
6026
+ const existing = getChannelConfig(cfg, "wecom-app");
6027
+ const webhookPath = await prompter.askText({
6028
+ label: "Webhook \u8DEF\u5F84\uFF08\u9700\u4E0E\u4F01\u4E1A\u5FAE\u4FE1\u540E\u53F0\u914D\u7F6E\u4E00\u81F4\uFF0C\u9ED8\u8BA4 /wecom-app\uFF09",
6029
+ defaultValue: toTrimmedString(existing.webhookPath) ?? "/wecom-app",
6030
+ required: true
6031
+ });
6032
+ const token = await prompter.askSecret({
6033
+ label: "WeCom App token",
6034
+ existingValue: toTrimmedString(existing.token),
6035
+ required: true
6036
+ });
6037
+ const encodingAESKey = await prompter.askSecret({
6038
+ label: "WeCom App encodingAESKey",
6039
+ existingValue: toTrimmedString(existing.encodingAESKey),
6040
+ required: true
6041
+ });
6042
+ const patch = {
6043
+ webhookPath,
6044
+ token,
6045
+ encodingAESKey
6046
+ };
6047
+ const corpId = await prompter.askText({
6048
+ label: "corpId",
6049
+ defaultValue: toTrimmedString(existing.corpId),
6050
+ required: true
6051
+ });
6052
+ const corpSecret = await prompter.askSecret({
6053
+ label: "corpSecret",
6054
+ existingValue: toTrimmedString(existing.corpSecret),
6055
+ required: true
6056
+ });
6057
+ const agentId = await prompter.askNumber({
6058
+ label: "agentId",
6059
+ min: 1,
6060
+ defaultValue: toNumber(existing.agentId)
6061
+ });
6062
+ patch.corpId = corpId;
6063
+ patch.corpSecret = corpSecret;
6064
+ patch.agentId = agentId;
6065
+ return mergeChannelConfig(cfg, "wecom-app", patch);
6066
+ }
6067
+ async function configureQQBot(prompter, cfg) {
6068
+ section("\u914D\u7F6E QQBot\uFF08QQ \u673A\u5668\u4EBA\uFF09");
6069
+ showGuideLink("qqbot");
6070
+ const existing = getChannelConfig(cfg, "qqbot");
6071
+ const appId = await prompter.askText({
6072
+ label: "QQBot appId",
6073
+ defaultValue: toTrimmedString(existing.appId),
6074
+ required: true
6075
+ });
6076
+ const clientSecret = await prompter.askSecret({
6077
+ label: "QQBot clientSecret",
6078
+ existingValue: toTrimmedString(existing.clientSecret),
6079
+ required: true
6080
+ });
6081
+ const markdownSupport = await prompter.askConfirm(
6082
+ "\u542F\u7528 Markdown \u652F\u6301",
6083
+ toBoolean(existing.markdownSupport, false)
6084
+ );
6085
+ const replyFinalOnly = await prompter.askConfirm(
6086
+ "\u4EC5\u53D1\u9001\u6700\u7EC8\u56DE\u590D\uFF08\u5173\u95ED\u6D41\u5F0F\u5206\u7247\uFF09",
6087
+ toBoolean(existing.replyFinalOnly, false)
6088
+ );
6089
+ return mergeChannelConfig(cfg, "qqbot", {
6090
+ appId,
6091
+ clientSecret,
6092
+ markdownSupport,
6093
+ replyFinalOnly
6094
+ });
6095
+ }
6096
+ async function configureSingleChannel(channel, prompter, cfg) {
6097
+ switch (channel) {
6098
+ case "dingtalk":
6099
+ return configureDingtalk(prompter, cfg);
6100
+ case "feishu-china":
6101
+ return configureFeishu(prompter, cfg);
6102
+ case "wecom":
6103
+ return configureWecom(prompter, cfg);
6104
+ case "wecom-app":
6105
+ return configureWecomApp(prompter, cfg);
6106
+ case "qqbot":
6107
+ return configureQQBot(prompter, cfg);
6108
+ default:
6109
+ return cfg;
6110
+ }
6111
+ }
6112
+ async function runChinaSetup(params) {
6113
+ if (!stdin.isTTY || !stdout.isTTY) {
6114
+ params.logger.error?.("\u4EA4\u4E92\u5F0F\u914D\u7F6E\u9700\u8981\u5728 TTY \u7EC8\u7AEF\u4E2D\u8FD0\u884C\u3002");
6115
+ return;
6116
+ }
6117
+ const prompter = new SetupPrompter();
6118
+ const touched = /* @__PURE__ */ new Set();
6119
+ let next = cloneConfig(params.initialConfig);
6120
+ try {
6121
+ We("OpenClaw China \u914D\u7F6E\u5411\u5BFC");
6122
+ Ve(
6123
+ [
6124
+ "\u4F7F\u7528\u65B9\u5411\u952E\u9009\u62E9\uFF0C\u6309 Enter \u786E\u8BA4\u3002",
6125
+ `\u9879\u76EE\u4ED3\u5E93\uFF1A${ANSI_LINK}${PROJECT_REPO}${ANSI_RESET}`
6126
+ ].join("\n"),
6127
+ "\u6B22\u8FCE"
6128
+ );
6129
+ if (params.availableChannels.length === 0) {
6130
+ params.logger.error?.("\u672A\u68C0\u6D4B\u5230\u53EF\u914D\u7F6E\u7684 China \u6E20\u9053\u63D2\u4EF6\u3002");
6131
+ return;
6132
+ }
6133
+ const channelOptions = params.availableChannels.map((channelId, index) => ({
6134
+ key: index === 0 ? "recommended" : "",
6135
+ value: channelId,
6136
+ label: withConfiguredSuffix(next, channelId)
6137
+ }));
6138
+ const defaultChannel = channelOptions[0]?.value ?? "save";
6139
+ let continueLoop = true;
6140
+ while (continueLoop) {
6141
+ const selected = await prompter.askSelect(
6142
+ "\u8BF7\u9009\u62E9\u8981\u914D\u7F6E\u7684\u6E20\u9053",
6143
+ [
6144
+ ...channelOptions,
6145
+ { key: "", value: "save", label: "\u4FDD\u5B58\u5E76\u9000\u51FA" },
6146
+ { key: "", value: "cancel", label: "\u4E0D\u4FDD\u5B58\u5E76\u9000\u51FA" }
6147
+ ],
6148
+ defaultChannel
6149
+ );
6150
+ if (selected === "cancel") {
6151
+ Ne("\u5DF2\u53D6\u6D88\uFF0C\u672A\u5199\u5165\u4EFB\u4F55\u914D\u7F6E\u3002");
6152
+ return;
6153
+ }
6154
+ if (selected === "save") {
6155
+ break;
6156
+ }
6157
+ next = await configureSingleChannel(selected, prompter, next);
6158
+ touched.add(selected);
6159
+ Ve(`\u5DF2\u5B8C\u6210\uFF1A${CHANNEL_DISPLAY_LABELS[selected]}`, "\u5B8C\u6210");
6160
+ continueLoop = await prompter.askConfirm("\u7EE7\u7EED\u914D\u7F6E\u5176\u4ED6\u6E20\u9053", true);
6161
+ }
6162
+ if (touched.size === 0) {
6163
+ Ne("\u672A\u8FDB\u884C\u4EFB\u4F55\u4FEE\u6539\u3002");
6164
+ return;
6165
+ }
6166
+ Ve(
6167
+ `\u5DF2\u914D\u7F6E\u6E20\u9053\uFF1A${Array.from(touched).map((channelId) => CHANNEL_DISPLAY_LABELS[channelId]).join(", ")}`,
6168
+ "\u6458\u8981"
6169
+ );
6170
+ if (!params.writeConfig) {
6171
+ 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");
6172
+ return;
6173
+ }
6174
+ await params.writeConfig(next);
6175
+ Le("\u914D\u7F6E\u5DF2\u4FDD\u5B58\u3002");
6176
+ showReadyMessage();
6177
+ } catch (err) {
6178
+ if (err instanceof PromptCancelledError) {
6179
+ return;
6180
+ }
6181
+ throw err;
6182
+ }
6183
+ }
6184
+ function registerChinaSetupCli(api, opts) {
6185
+ const state = getChinaCliState();
6186
+ for (const channelId of normalizeChannels(opts?.channels)) {
6187
+ state.channels.add(channelId);
6188
+ }
6189
+ if (state.cliRegistered || typeof api.registerCli !== "function") {
6190
+ return;
6191
+ }
6192
+ state.cliRegistered = true;
6193
+ const writeConfig = resolveWriteConfig(api.runtime);
6194
+ const fallbackLogger = {
6195
+ info: (message) => stdout.write(`${message}
6196
+ `),
6197
+ warn: (message) => warn(message),
6198
+ error: (message) => warn(message)
6199
+ };
6200
+ api.registerCli(
6201
+ (ctx) => {
6202
+ if (!isCommandLike(ctx.program)) {
6203
+ const logger = ctx.logger ?? api.logger ?? fallbackLogger;
6204
+ logger.error?.("\u65E0\u6CD5\u6CE8\u518C china \u547D\u4EE4\uFF1ACLI program \u5B9E\u4F8B\u65E0\u6548\u3002");
6205
+ return;
6206
+ }
6207
+ const root = ctx.program.command("china").description("OpenClaw China \u63D2\u4EF6\u547D\u4EE4");
6208
+ root.command("setup").description("\u4E2D\u56FD\u6E20\u9053\u4EA4\u4E92\u5F0F\u914D\u7F6E\u5411\u5BFC").action(async () => {
6209
+ const logger = ctx.logger ?? api.logger ?? fallbackLogger;
6210
+ const availableChannels = getInstalledChannels(state);
6211
+ await runChinaSetup({
6212
+ initialConfig: isRecord(ctx.config) ? ctx.config : {},
6213
+ writeConfig,
6214
+ logger,
6215
+ availableChannels
6216
+ });
6217
+ });
6218
+ root.command("about").description("\u663E\u793A\u9879\u76EE\u4FE1\u606F").action(() => {
6219
+ const installed = getInstalledChannels(state);
6220
+ We("OpenClaw China \u6E20\u9053\u63D2\u4EF6");
6221
+ Ve(
6222
+ 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",
6223
+ "\u5173\u4E8E"
6224
+ );
6225
+ Le(PROJECT_REPO);
6226
+ showReadyMessage();
6227
+ });
6228
+ },
6229
+ { commands: ["china"] }
6230
+ );
6231
+ }
4701
6232
  function decodeEncodingAESKey(encodingAESKey) {
4702
6233
  const trimmed = encodingAESKey.trim();
4703
6234
  if (!trimmed) throw new Error("encodingAESKey missing");
@@ -4727,8 +6258,8 @@ function pkcs7Unpad(buf, blockSize) {
4727
6258
  }
4728
6259
  return buf.subarray(0, buf.length - pad);
4729
6260
  }
4730
- function sha1Hex(input) {
4731
- return crypto.createHash("sha1").update(input).digest("hex");
6261
+ function sha1Hex(input2) {
6262
+ return crypto.createHash("sha1").update(input2).digest("hex");
4732
6263
  }
4733
6264
  function computeWecomMsgSignature(params) {
4734
6265
  const parts = [params.token, params.timestamp, params.nonce, params.encrypt].map((value) => String(value ?? "")).sort();
@@ -5403,9 +6934,9 @@ async function downloadAndDecryptMedia(params) {
5403
6934
  } catch (err) {
5404
6935
  throw new Error(`\u89E3\u5BC6\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`);
5405
6936
  }
5406
- const sanitizeFileName = (input) => {
5407
- if (!input) return void 0;
5408
- const base = path3.basename(input);
6937
+ const sanitizeFileName = (input2) => {
6938
+ if (!input2) return void 0;
6939
+ const base = path3.basename(input2);
5409
6940
  const cleaned = base.replace(/[\\\/]+/g, "_").replace(/[\x00-\x1f\x7f]/g, "").trim();
5410
6941
  if (!cleaned || cleaned === "." || cleaned === "..") return void 0;
5411
6942
  return cleaned.length > 200 ? cleaned.slice(0, 200) : cleaned;
@@ -6730,6 +8261,7 @@ var plugin = {
6730
8261
  properties: {}
6731
8262
  },
6732
8263
  register(api) {
8264
+ registerChinaSetupCli(api, { channels: ["wecom"] });
6733
8265
  if (api.runtime) {
6734
8266
  setWecomRuntime(api.runtime);
6735
8267
  }