@openclaw-china/feishu-china 0.1.7 → 0.1.9

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