@vitejs/devtools 0.0.0-alpha.32 → 0.0.0-alpha.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/{DockIcon-DC06YRV1.js → DockIcon-BxTh1m5v.js} +11 -14
  2. package/dist/{ViewBuiltinLogs-BpU8wNYx.js → ViewBuiltinLogs-BwyIDX5w.js} +3 -5
  3. package/dist/{ViewBuiltinTerminals-1w0Jz6t0.js → ViewBuiltinTerminals-yFL0jGW0.js} +5 -11
  4. package/dist/cli-commands-BRi5CDUR.js +94 -0
  5. package/dist/cli-commands.js +3 -67
  6. package/dist/cli.js +3 -5
  7. package/dist/client/inject.js +6 -9
  8. package/dist/client/standalone/assets/ViewBuiltinLogs-B6YocKEt.js +1 -0
  9. package/dist/client/standalone/assets/{ViewBuiltinTerminals-BfkQ4Bsj.js → ViewBuiltinTerminals-BoJR1xWn.js} +2 -2
  10. package/dist/client/standalone/assets/_plugin-vue_export-helper-DCOpKI5t.js +1 -0
  11. package/dist/client/standalone/assets/index-7t5UlDkF.css +1 -0
  12. package/dist/client/standalone/assets/index-BmL7atlP.js +3 -0
  13. package/dist/client/standalone/index.html +3 -2
  14. package/dist/client/webcomponents.d.ts +4 -4
  15. package/dist/client/webcomponents.js +162 -79
  16. package/dist/config.js +1 -3
  17. package/dist/dirs.js +1 -3
  18. package/dist/{dist-B1eLoAag.js → dist-C5wFunwn.js} +11 -50
  19. package/dist/{docks-BVWse3rL.js → docks-YFmtkjZj.js} +2 -6
  20. package/dist/{export-helper-DjM8b2QE.js → export-helper-C1Zyf6xf.js} +1 -2
  21. package/dist/index.js +2 -3
  22. package/dist/plugins-C3h3TsXX.js +1870 -0
  23. package/dist/{vue.runtime.esm-bundler-CHmRsJSH.js → vue.runtime.esm-bundler-DL9ItCI-.js} +71 -96
  24. package/package.json +14 -14
  25. package/dist/client/standalone/assets/ViewBuiltinLogs-D_1j1vpl.js +0 -1
  26. package/dist/client/standalone/assets/index-DWcF5wcd.js +0 -2
  27. package/dist/client/standalone/assets/index-DzhHPm4X.css +0 -1
  28. package/dist/plugins-CM-4geJK.js +0 -3040
  29. package/dist/standalone-CfUW6ZhV.js +0 -34
@@ -0,0 +1,1870 @@
1
+ import { dirClientStandalone, dirDist } from "./dirs.js";
2
+ import { createDebug } from "obug";
3
+ import { debounce } from "perfect-debounce";
4
+ import { normalizePath, searchForWorkspaceRoot } from "vite";
5
+ import { toDataURL } from "mlly";
6
+ import { DEFAULT_STATE_USER_SETTINGS } from "@vitejs/devtools-kit/constants";
7
+ import { createEventEmitter } from "@vitejs/devtools-kit/utils/events";
8
+ import { dirname, join } from "pathe";
9
+ import fs, { existsSync } from "node:fs";
10
+ import { createSharedState } from "@vitejs/devtools-kit/utils/shared-state";
11
+ import { RpcFunctionsCollectorBase } from "@vitejs/devtools-rpc";
12
+ import process$1, { stdin, stdout } from "node:process";
13
+ import sirv from "sirv";
14
+ import { stripVTControlCharacters, styleText } from "node:util";
15
+ import "node:readline";
16
+ import ot from "node:readline";
17
+ import "node:tty";
18
+ import { join as join$1 } from "node:path";
19
+ import { defineRpcFunction } from "@vitejs/devtools-kit";
20
+ import { createApp, eventHandler, fromNodeMiddleware, toNodeListener } from "h3";
21
+ import { AsyncLocalStorage } from "node:async_hooks";
22
+ import { createWsRpcPreset } from "@vitejs/devtools-rpc/presets/ws/server";
23
+ import { createRpcServer } from "@vitejs/devtools-rpc/server";
24
+ import { createServer } from "node:net";
25
+ import { networkInterfaces } from "node:os";
26
+ import "node:fs/promises";
27
+ //#region \0rolldown/runtime.js
28
+ var __create = Object.create;
29
+ var __defProp = Object.defineProperty;
30
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
31
+ var __getOwnPropNames = Object.getOwnPropertyNames;
32
+ var __getProtoOf = Object.getPrototypeOf;
33
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
34
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
35
+ var __copyProps = (to, from, except, desc) => {
36
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
37
+ key = keys[i];
38
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
39
+ get: ((k) => from[k]).bind(null, key),
40
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
41
+ });
42
+ }
43
+ return to;
44
+ };
45
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
46
+ value: mod,
47
+ enumerable: true
48
+ }) : target, mod));
49
+ //#endregion
50
+ //#region src/node/context-utils.ts
51
+ const ContextUtils = { createSimpleClientScript(fn) {
52
+ return {
53
+ importFrom: toDataURL(`const fn = ${fn.toString()}; export default fn`),
54
+ importName: "default"
55
+ };
56
+ } };
57
+ //#endregion
58
+ //#region src/node/storage.ts
59
+ function createStorage(options) {
60
+ const { mergeInitialValue = (initialValue, savedValue) => ({
61
+ ...initialValue,
62
+ ...savedValue
63
+ }), debounce: debounceTime = 100 } = options;
64
+ let initialValue;
65
+ if (fs.existsSync(options.filepath)) {
66
+ const savedValue = JSON.parse(fs.readFileSync(options.filepath, "utf-8"));
67
+ initialValue = mergeInitialValue ? mergeInitialValue(options.initialValue, savedValue) : savedValue;
68
+ } else initialValue = options.initialValue;
69
+ const state = createSharedState({
70
+ initialValue,
71
+ enablePatches: false
72
+ });
73
+ state.on("updated", debounce((newState) => {
74
+ fs.mkdirSync(dirname(options.filepath), { recursive: true });
75
+ fs.writeFileSync(options.filepath, `${JSON.stringify(newState, null, 2)}\n`);
76
+ }, debounceTime));
77
+ return state;
78
+ }
79
+ //#endregion
80
+ //#region src/node/host-docks.ts
81
+ var DevToolsDockHost = class {
82
+ views = /* @__PURE__ */ new Map();
83
+ events = createEventEmitter();
84
+ userSettings = void 0;
85
+ constructor(context) {
86
+ this.context = context;
87
+ }
88
+ async init() {
89
+ this.userSettings = await this.context.rpc.sharedState.get("devtoolskit:internal:user-settings", { sharedState: createStorage({
90
+ filepath: join(this.context.workspaceRoot, "node_modules/.vite/devtools/settings.json"),
91
+ initialValue: DEFAULT_STATE_USER_SETTINGS()
92
+ }) });
93
+ }
94
+ values({ includeBuiltin = true } = {}) {
95
+ const context = this.context;
96
+ const builtinDocksEntries = [
97
+ {
98
+ type: "~builtin",
99
+ id: "~terminals",
100
+ title: "Terminals",
101
+ icon: "ph:terminal-duotone",
102
+ category: "~builtin",
103
+ get isHidden() {
104
+ return context.terminals.sessions.size === 0;
105
+ }
106
+ },
107
+ {
108
+ type: "~builtin",
109
+ id: "~logs",
110
+ title: "Logs",
111
+ icon: "ph:notification-duotone",
112
+ category: "~builtin",
113
+ isHidden: true
114
+ },
115
+ {
116
+ type: "~builtin",
117
+ id: "~settings",
118
+ title: "Settings",
119
+ category: "~builtin",
120
+ icon: "ph:gear-duotone"
121
+ }
122
+ ];
123
+ return [...Array.from(this.views.values()), ...includeBuiltin ? builtinDocksEntries : []];
124
+ }
125
+ register(view, force) {
126
+ if (this.views.has(view.id) && !force) throw new Error(`Dock with id "${view.id}" is already registered`);
127
+ this.views.set(view.id, view);
128
+ this.events.emit("dock:entry:updated", view);
129
+ return { update: (patch) => {
130
+ if (patch.id && patch.id !== view.id) throw new Error(`Cannot change the id of a dock. Use register() to add new docks.`);
131
+ this.update(Object.assign(this.views.get(view.id), patch));
132
+ } };
133
+ }
134
+ update(view) {
135
+ if (!this.views.has(view.id)) throw new Error(`Dock with id "${view.id}" is not registered. Use register() to add new docks.`);
136
+ this.views.set(view.id, view);
137
+ this.events.emit("dock:entry:updated", view);
138
+ }
139
+ };
140
+ //#endregion
141
+ //#region src/node/rpc-shared-state.ts
142
+ const debug$1 = createDebug("vite:devtools:rpc:state:changed");
143
+ function createRpcSharedStateServerHost(rpc) {
144
+ const sharedState = /* @__PURE__ */ new Map();
145
+ function registerSharedState(key, state) {
146
+ const offs = [];
147
+ offs.push(state.on("updated", (fullState, patches, syncId) => {
148
+ if (patches) {
149
+ debug$1("patch", {
150
+ key,
151
+ syncId
152
+ });
153
+ rpc.broadcast({
154
+ method: "devtoolskit:internal:rpc:client-state:patch",
155
+ args: [
156
+ key,
157
+ patches,
158
+ syncId
159
+ ],
160
+ filter: (client) => client.$meta.subscribedStates.has(key)
161
+ });
162
+ } else {
163
+ debug$1("updated", {
164
+ key,
165
+ syncId
166
+ });
167
+ rpc.broadcast({
168
+ method: "devtoolskit:internal:rpc:client-state:updated",
169
+ args: [
170
+ key,
171
+ fullState,
172
+ syncId
173
+ ],
174
+ filter: (client) => client.$meta.subscribedStates.has(key)
175
+ });
176
+ }
177
+ }));
178
+ return () => {
179
+ for (const off of offs) off();
180
+ };
181
+ }
182
+ return { get: async (key, options) => {
183
+ if (sharedState.has(key)) return sharedState.get(key);
184
+ if (options?.initialValue === void 0 && options?.sharedState === void 0) throw new Error(`Shared state of "${key}" is not found, please provide an initial value for the first time`);
185
+ debug$1("new-state", key);
186
+ const state = options.sharedState ?? createSharedState({
187
+ initialValue: options.initialValue,
188
+ enablePatches: false
189
+ });
190
+ registerSharedState(key, state);
191
+ sharedState.set(key, state);
192
+ return state;
193
+ } };
194
+ }
195
+ //#endregion
196
+ //#region src/node/host-functions.ts
197
+ const debugBroadcast = createDebug("vite:devtools:rpc:broadcast");
198
+ var RpcFunctionsHost = class extends RpcFunctionsCollectorBase {
199
+ /**
200
+ * @internal
201
+ */
202
+ _rpcGroup = void 0;
203
+ _asyncStorage = void 0;
204
+ constructor(context) {
205
+ super(context);
206
+ this.sharedState = createRpcSharedStateServerHost(this);
207
+ }
208
+ sharedState;
209
+ async broadcast(options) {
210
+ if (!this._rpcGroup) throw new Error("RpcFunctionsHost] RpcGroup is not set, it likely to be an internal bug of Vite DevTools");
211
+ debugBroadcast(JSON.stringify(options.method));
212
+ await Promise.all(this._rpcGroup.clients.map((client) => {
213
+ if (options.filter?.(client) === false) return void 0;
214
+ return client.$callRaw({
215
+ optional: true,
216
+ event: true,
217
+ ...options
218
+ });
219
+ }));
220
+ }
221
+ getCurrentRpcSession() {
222
+ if (!this._asyncStorage) throw new Error("RpcFunctionsHost] AsyncLocalStorage is not set, it likely to be an internal bug of Vite DevTools");
223
+ return this._asyncStorage.getStore();
224
+ }
225
+ };
226
+ //#endregion
227
+ //#region src/node/host-terminals.ts
228
+ var DevToolsTerminalHost = class {
229
+ sessions = /* @__PURE__ */ new Map();
230
+ events = createEventEmitter();
231
+ _boundStreams = /* @__PURE__ */ new Map();
232
+ constructor(context) {
233
+ this.context = context;
234
+ }
235
+ register(session) {
236
+ if (this.sessions.has(session.id)) throw new Error(`Terminal session with id "${session.id}" already registered`);
237
+ this.sessions.set(session.id, session);
238
+ this.bindStream(session);
239
+ this.events.emit("terminal:session:updated", session);
240
+ return session;
241
+ }
242
+ update(patch) {
243
+ if (!this.sessions.has(patch.id)) throw new Error(`Terminal session with id "${patch.id}" not registered`);
244
+ const session = this.sessions.get(patch.id);
245
+ Object.assign(session, patch);
246
+ this.sessions.set(patch.id, session);
247
+ this.bindStream(session);
248
+ this.events.emit("terminal:session:updated", session);
249
+ }
250
+ remove(session) {
251
+ this.sessions.delete(session.id);
252
+ this.events.emit("terminal:session:updated", session);
253
+ this._boundStreams.delete(session.id);
254
+ }
255
+ bindStream(session) {
256
+ if (this._boundStreams.has(session.id) && this._boundStreams.get(session.id)?.stream === session.stream) return;
257
+ this._boundStreams.get(session.id)?.dispose();
258
+ this._boundStreams.delete(session.id);
259
+ if (!session.stream) return;
260
+ session.buffer ||= [];
261
+ const events = this.events;
262
+ const writer = new WritableStream({ write(chunk) {
263
+ session.buffer.push(chunk);
264
+ events.emit("terminal:session:stream-chunk", {
265
+ id: session.id,
266
+ chunks: [chunk],
267
+ ts: Date.now()
268
+ });
269
+ } });
270
+ session.stream.pipeTo(writer);
271
+ this._boundStreams.set(session.id, {
272
+ dispose: () => {
273
+ writer.close();
274
+ },
275
+ stream: session.stream
276
+ });
277
+ }
278
+ async startChildProcess(executeOptions, terminal) {
279
+ if (this.sessions.has(terminal.id)) throw new Error(`Terminal session with id "${terminal.id}" already registered`);
280
+ const { exec } = await import("tinyexec");
281
+ let controller;
282
+ const stream = new ReadableStream({ start(_controller) {
283
+ controller = _controller;
284
+ } });
285
+ function createChildProcess() {
286
+ const cp = exec(executeOptions.command, executeOptions.args || [], { nodeOptions: {
287
+ env: {
288
+ COLORS: "true",
289
+ FORCE_COLOR: "true",
290
+ ...executeOptions.env || {}
291
+ },
292
+ cwd: executeOptions.cwd ?? process$1.cwd(),
293
+ stdio: "pipe"
294
+ } });
295
+ (async () => {
296
+ for await (const chunk of cp) controller?.enqueue(chunk);
297
+ })();
298
+ return cp;
299
+ }
300
+ let cp = createChildProcess();
301
+ const restart = async () => {
302
+ cp?.kill();
303
+ cp = createChildProcess();
304
+ };
305
+ const terminate = async () => {
306
+ cp?.kill();
307
+ cp = void 0;
308
+ };
309
+ const session = {
310
+ ...terminal,
311
+ status: "running",
312
+ stream,
313
+ type: "child-process",
314
+ executeOptions,
315
+ getChildProcess: () => cp?.process,
316
+ terminate,
317
+ restart
318
+ };
319
+ this.register(session);
320
+ return Promise.resolve(session);
321
+ }
322
+ };
323
+ //#endregion
324
+ //#region src/node/host-views.ts
325
+ var DevToolsViewHost = class {
326
+ /**
327
+ * @internal
328
+ */
329
+ buildStaticDirs = [];
330
+ constructor(context) {
331
+ this.context = context;
332
+ }
333
+ hostStatic(baseUrl, distDir) {
334
+ if (!existsSync(distDir)) throw new Error(`[Vite DevTools] distDir ${distDir} does not exist`);
335
+ this.buildStaticDirs.push({
336
+ baseUrl,
337
+ distDir
338
+ });
339
+ if (this.context.viteConfig.command === "serve") {
340
+ if (!this.context.viteServer) throw new Error("[Vite DevTools] viteServer is required in dev mode");
341
+ this.context.viteServer.middlewares.use(baseUrl, sirv(distDir, {
342
+ dev: true,
343
+ single: true
344
+ }));
345
+ }
346
+ }
347
+ };
348
+ //#endregion
349
+ //#region ../../node_modules/.pnpm/@clack+core@1.1.0/node_modules/@clack/core/dist/index.mjs
350
+ var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
351
+ const ESC = "\x1B";
352
+ const CSI = `${ESC}[`;
353
+ const beep = "\x07";
354
+ const cursor = {
355
+ to(x, y) {
356
+ if (!y) return `${CSI}${x + 1}G`;
357
+ return `${CSI}${y + 1};${x + 1}H`;
358
+ },
359
+ move(x, y) {
360
+ let ret = "";
361
+ if (x < 0) ret += `${CSI}${-x}D`;
362
+ else if (x > 0) ret += `${CSI}${x}C`;
363
+ if (y < 0) ret += `${CSI}${-y}A`;
364
+ else if (y > 0) ret += `${CSI}${y}B`;
365
+ return ret;
366
+ },
367
+ up: (count = 1) => `${CSI}${count}A`,
368
+ down: (count = 1) => `${CSI}${count}B`,
369
+ forward: (count = 1) => `${CSI}${count}C`,
370
+ backward: (count = 1) => `${CSI}${count}D`,
371
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
372
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
373
+ left: `${CSI}G`,
374
+ hide: `${CSI}?25l`,
375
+ show: `${CSI}?25h`,
376
+ save: `${ESC}7`,
377
+ restore: `${ESC}8`
378
+ };
379
+ module.exports = {
380
+ cursor,
381
+ scroll: {
382
+ up: (count = 1) => `${CSI}S`.repeat(count),
383
+ down: (count = 1) => `${CSI}T`.repeat(count)
384
+ },
385
+ erase: {
386
+ screen: `${CSI}2J`,
387
+ up: (count = 1) => `${CSI}1J`.repeat(count),
388
+ down: (count = 1) => `${CSI}J`.repeat(count),
389
+ line: `${CSI}2K`,
390
+ lineEnd: `${CSI}K`,
391
+ lineStart: `${CSI}1K`,
392
+ lines(count) {
393
+ let clear = "";
394
+ for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
395
+ if (count) clear += cursor.left;
396
+ return clear;
397
+ }
398
+ },
399
+ beep
400
+ };
401
+ })))();
402
+ function x$1(t, e, s) {
403
+ if (!s.some((u) => !u.disabled)) return t;
404
+ const i = t + e, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
405
+ return s[n].disabled ? x$1(n, e < 0 ? -1 : 1, s) : n;
406
+ }
407
+ const 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, lt = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510, 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, O = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, y = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, L = /\t{1,1000}/y, 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?))*/uy, M = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, ct = /\p{M}+/gu, ft$1 = {
408
+ limit: Infinity,
409
+ ellipsis: ""
410
+ }, X$1 = (t, e = {}, s = {}) => {
411
+ const i = e.limit ?? Infinity, r = e.ellipsis ?? "", n = e?.ellipsisWidth ?? (r ? X$1(r, ft$1, 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, V = s.wideWidth ?? 2;
412
+ let h = 0, o = 0, p = t.length, v = 0, F = !1, d = p, b = Math.max(0, i - n), C = 0, w = 0, c = 0, f = 0;
413
+ t: for (;;) {
414
+ if (w > C || o >= p && o > h) {
415
+ const ut = t.slice(C, w) || t.slice(h, o);
416
+ v = 0;
417
+ for (const Y of ut.replaceAll(ct, "")) {
418
+ const $ = Y.codePointAt(0) || 0;
419
+ if (lt($) ? f = m : ht($) ? f = V : E !== A && at($) ? f = E : f = A, c + f > b && (d = Math.min(d, Math.max(C, h) + v)), c + f > i) {
420
+ F = !0;
421
+ break t;
422
+ }
423
+ v += Y.length, c += f;
424
+ }
425
+ C = w = 0;
426
+ }
427
+ if (o >= p) break;
428
+ if (M.lastIndex = o, M.test(t)) {
429
+ if (v = M.lastIndex - o, f = v * A, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / A))), c + f > i) {
430
+ F = !0;
431
+ break;
432
+ }
433
+ c += f, C = h, w = o, o = h = M.lastIndex;
434
+ continue;
435
+ }
436
+ if (O.lastIndex = o, O.test(t)) {
437
+ if (c + u > b && (d = Math.min(d, o)), c + u > i) {
438
+ F = !0;
439
+ break;
440
+ }
441
+ c += u, C = h, w = o, o = h = O.lastIndex;
442
+ continue;
443
+ }
444
+ if (y.lastIndex = o, y.test(t)) {
445
+ if (v = y.lastIndex - o, f = v * a, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / a))), c + f > i) {
446
+ F = !0;
447
+ break;
448
+ }
449
+ c += f, C = h, w = o, o = h = y.lastIndex;
450
+ continue;
451
+ }
452
+ if (L.lastIndex = o, L.test(t)) {
453
+ if (v = L.lastIndex - o, f = v * l, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / l))), c + f > i) {
454
+ F = !0;
455
+ break;
456
+ }
457
+ c += f, C = h, w = o, o = h = L.lastIndex;
458
+ continue;
459
+ }
460
+ if (P.lastIndex = o, P.test(t)) {
461
+ if (c + g > b && (d = Math.min(d, o)), c + g > i) {
462
+ F = !0;
463
+ break;
464
+ }
465
+ c += g, C = h, w = o, o = h = P.lastIndex;
466
+ continue;
467
+ }
468
+ o += 1;
469
+ }
470
+ return {
471
+ width: F ? b : c,
472
+ index: F ? d : p,
473
+ truncated: F,
474
+ ellipsed: F && i >= n
475
+ };
476
+ }, pt$1 = {
477
+ limit: Infinity,
478
+ ellipsis: "",
479
+ ellipsisWidth: 0
480
+ }, S = (t, e = {}) => X$1(t, pt$1, e).width, T = "\x1B", Z = "›", Ft$1 = 39, j = "\x07", Q$1 = "[", dt = "]", tt = "m", U$1 = `${dt}8;;`, et = new RegExp(`(?:\\${Q$1}(?<code>\\d+)m|\\${U$1}(?<uri>.*)${j})`, "y"), mt$1 = (t) => {
481
+ if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
482
+ if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
483
+ if (t === 1 || t === 2) return 22;
484
+ if (t === 3) return 23;
485
+ if (t === 4) return 24;
486
+ if (t === 7) return 27;
487
+ if (t === 8) return 28;
488
+ if (t === 9) return 29;
489
+ if (t === 0) return 0;
490
+ }, st = (t) => `${T}${Q$1}${t}${tt}`, it = (t) => `${T}${U$1}${t}${j}`, gt$1 = (t) => t.map((e) => S(e)), G = (t, e, s) => {
491
+ const i = e[Symbol.iterator]();
492
+ let r = !1, n = !1, u = t.at(-1), a = u === void 0 ? 0 : S(u), l = i.next(), E = i.next(), g = 0;
493
+ for (; !l.done;) {
494
+ const m = l.value, A = S(m);
495
+ a + A <= s ? t[t.length - 1] += m : (t.push(m), a = 0), (m === T || m === Z) && (r = !0, n = e.startsWith(U$1, g + 1)), r ? n ? m === j && (r = !1, n = !1) : m === tt && (r = !1) : (a += A, a === s && !E.done && (t.push(""), a = 0)), l = E, E = i.next(), g += m.length;
496
+ }
497
+ u = t.at(-1), !a && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
498
+ }, vt$1 = (t) => {
499
+ const e = t.split(" ");
500
+ let s = e.length;
501
+ for (; s > 0 && !(S(e[s - 1]) > 0);) s--;
502
+ return s === e.length ? t : e.slice(0, s).join(" ") + e.slice(s).join("");
503
+ }, Et$1 = (t, e, s = {}) => {
504
+ if (s.trim !== !1 && t.trim() === "") return "";
505
+ let i = "", r, n;
506
+ const u = t.split(" "), a = gt$1(u);
507
+ let l = [""];
508
+ for (const [h, o] of u.entries()) {
509
+ s.trim !== !1 && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
510
+ let p = S(l.at(-1) ?? "");
511
+ if (h !== 0 && (p >= e && (s.wordWrap === !1 || s.trim === !1) && (l.push(""), p = 0), (p > 0 || s.trim === !1) && (l[l.length - 1] += " ", p++)), s.hard && a[h] > e) {
512
+ const v = e - p, F = 1 + Math.floor((a[h] - v - 1) / e);
513
+ Math.floor((a[h] - 1) / e) < F && l.push(""), G(l, o, e);
514
+ continue;
515
+ }
516
+ if (p + a[h] > e && p > 0 && a[h] > 0) {
517
+ if (s.wordWrap === !1 && p < e) {
518
+ G(l, o, e);
519
+ continue;
520
+ }
521
+ l.push("");
522
+ }
523
+ if (p + a[h] > e && s.wordWrap === !1) {
524
+ G(l, o, e);
525
+ continue;
526
+ }
527
+ l[l.length - 1] += o;
528
+ }
529
+ s.trim !== !1 && (l = l.map((h) => vt$1(h)));
530
+ const E = l.join(`
531
+ `), g = E[Symbol.iterator]();
532
+ let m = g.next(), A = g.next(), V = 0;
533
+ for (; !m.done;) {
534
+ const h = m.value, o = A.value;
535
+ if (i += h, h === T || h === Z) {
536
+ et.lastIndex = V + 1;
537
+ const F = et.exec(E)?.groups;
538
+ if (F?.code !== void 0) {
539
+ const d = Number.parseFloat(F.code);
540
+ r = d === Ft$1 ? void 0 : d;
541
+ } else F?.uri !== void 0 && (n = F.uri.length === 0 ? void 0 : F.uri);
542
+ }
543
+ const p = r ? mt$1(r) : void 0;
544
+ o === `
545
+ ` ? (n && (i += it("")), r && p && (i += st(p))) : h === `
546
+ ` && (r && p && (i += st(r)), n && (i += it(n))), V += h.length, m = A, A = g.next();
547
+ }
548
+ return i;
549
+ };
550
+ function K$1(t, e, s) {
551
+ return String(t).normalize().replaceAll(`\r
552
+ `, `
553
+ `).split(`
554
+ `).map((i) => Et$1(i, e, s)).join(`
555
+ `);
556
+ }
557
+ const _ = {
558
+ actions: new Set([
559
+ "up",
560
+ "down",
561
+ "left",
562
+ "right",
563
+ "space",
564
+ "enter",
565
+ "cancel"
566
+ ]),
567
+ aliases: new Map([
568
+ ["k", "up"],
569
+ ["j", "down"],
570
+ ["h", "left"],
571
+ ["l", "right"],
572
+ ["", "cancel"],
573
+ ["escape", "cancel"]
574
+ ]),
575
+ messages: {
576
+ cancel: "Canceled",
577
+ error: "Something went wrong"
578
+ },
579
+ withGuide: !0
580
+ };
581
+ function H$1(t, e) {
582
+ if (typeof t == "string") return _.aliases.get(t) === e;
583
+ for (const s of t) if (s !== void 0 && H$1(s, e)) return !0;
584
+ return !1;
585
+ }
586
+ function _t$1(t, e) {
587
+ if (t === e) return;
588
+ const s = t.split(`
589
+ `), i = e.split(`
590
+ `), r = Math.max(s.length, i.length), n = [];
591
+ for (let u = 0; u < r; u++) s[u] !== i[u] && n.push(u);
592
+ return {
593
+ lines: n,
594
+ numLinesBefore: s.length,
595
+ numLinesAfter: i.length,
596
+ numLines: r
597
+ };
598
+ }
599
+ globalThis.process.platform.startsWith("win");
600
+ const z$1 = Symbol("clack:cancel");
601
+ function W$1(t, e) {
602
+ const s = t;
603
+ s.isTTY && s.setRawMode(e);
604
+ }
605
+ const rt = (t) => "columns" in t && typeof t.columns == "number" ? t.columns : 80, nt = (t) => "rows" in t && typeof t.rows == "number" ? t.rows : 20;
606
+ var B = class {
607
+ input;
608
+ output;
609
+ _abortSignal;
610
+ rl;
611
+ opts;
612
+ _render;
613
+ _track = !1;
614
+ _prevFrame = "";
615
+ _subscribers = /* @__PURE__ */ new Map();
616
+ _cursor = 0;
617
+ state = "initial";
618
+ error = "";
619
+ value;
620
+ userInput = "";
621
+ constructor(e, s = !0) {
622
+ const { input: i = stdin, output: r = stdout, render: n, signal: u, ...a } = e;
623
+ 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;
624
+ }
625
+ unsubscribe() {
626
+ this._subscribers.clear();
627
+ }
628
+ setSubscriber(e, s) {
629
+ const i = this._subscribers.get(e) ?? [];
630
+ i.push(s), this._subscribers.set(e, i);
631
+ }
632
+ on(e, s) {
633
+ this.setSubscriber(e, { cb: s });
634
+ }
635
+ once(e, s) {
636
+ this.setSubscriber(e, {
637
+ cb: s,
638
+ once: !0
639
+ });
640
+ }
641
+ emit(e, ...s) {
642
+ const i = this._subscribers.get(e) ?? [], r = [];
643
+ for (const n of i) n.cb(...s), n.once && r.push(() => i.splice(i.indexOf(n), 1));
644
+ for (const n of r) n();
645
+ }
646
+ prompt() {
647
+ return new Promise((e) => {
648
+ if (this._abortSignal) {
649
+ if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e(z$1);
650
+ this._abortSignal.addEventListener("abort", () => {
651
+ this.state = "cancel", this.close();
652
+ }, { once: !0 });
653
+ }
654
+ this.rl = ot.createInterface({
655
+ input: this.input,
656
+ tabSize: 2,
657
+ prompt: "",
658
+ escapeCodeTimeout: 50,
659
+ terminal: !0
660
+ }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress), W$1(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
661
+ this.output.write(import_src.cursor.show), this.output.off("resize", this.render), W$1(this.input, !1), e(this.value);
662
+ }), this.once("cancel", () => {
663
+ this.output.write(import_src.cursor.show), this.output.off("resize", this.render), W$1(this.input, !1), e(z$1);
664
+ });
665
+ });
666
+ }
667
+ _isActionKey(e, s) {
668
+ return e === " ";
669
+ }
670
+ _setValue(e) {
671
+ this.value = e, this.emit("value", this.value);
672
+ }
673
+ _setUserInput(e, s) {
674
+ this.userInput = e ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
675
+ }
676
+ _clearUserInput() {
677
+ this.rl?.write(null, {
678
+ ctrl: !0,
679
+ name: "u"
680
+ }), this._setUserInput("");
681
+ }
682
+ onKeypress(e, s) {
683
+ if (this._track && s.name !== "return" && (s.name && this._isActionKey(e, s) && this.rl?.write(null, {
684
+ ctrl: !0,
685
+ name: "h"
686
+ }), 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)), e && (e.toLowerCase() === "y" || e.toLowerCase() === "n") && this.emit("confirm", e.toLowerCase() === "y"), this.emit("key", e?.toLowerCase(), s), s?.name === "return") {
687
+ if (this.opts.validate) {
688
+ const i = this.opts.validate(this.value);
689
+ i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
690
+ }
691
+ this.state !== "error" && (this.state = "submit");
692
+ }
693
+ H$1([
694
+ e,
695
+ s?.name,
696
+ s?.sequence
697
+ ], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
698
+ }
699
+ close() {
700
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
701
+ `), W$1(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
702
+ }
703
+ restoreCursor() {
704
+ const e = K$1(this._prevFrame, process.stdout.columns, {
705
+ hard: !0,
706
+ trim: !1
707
+ }).split(`
708
+ `).length - 1;
709
+ this.output.write(import_src.cursor.move(-999, e * -1));
710
+ }
711
+ render() {
712
+ const e = K$1(this._render(this) ?? "", process.stdout.columns, {
713
+ hard: !0,
714
+ trim: !1
715
+ });
716
+ if (e !== this._prevFrame) {
717
+ if (this.state === "initial") this.output.write(import_src.cursor.hide);
718
+ else {
719
+ const s = _t$1(this._prevFrame, e), i = nt(this.output);
720
+ if (this.restoreCursor(), s) {
721
+ const r = Math.max(0, s.numLinesAfter - i), n = Math.max(0, s.numLinesBefore - i);
722
+ let u = s.lines.find((a) => a >= r);
723
+ if (u === void 0) {
724
+ this._prevFrame = e;
725
+ return;
726
+ }
727
+ if (s.lines.length === 1) {
728
+ this.output.write(import_src.cursor.move(0, u - n)), this.output.write(import_src.erase.lines(1));
729
+ const a = e.split(`
730
+ `);
731
+ this.output.write(a[u]), this._prevFrame = e, this.output.write(import_src.cursor.move(0, a.length - u - 1));
732
+ return;
733
+ } else if (s.lines.length > 1) {
734
+ if (r < n) u = r;
735
+ else {
736
+ const l = u - n;
737
+ l > 0 && this.output.write(import_src.cursor.move(0, l));
738
+ }
739
+ this.output.write(import_src.erase.down());
740
+ const a = e.split(`
741
+ `).slice(u);
742
+ this.output.write(a.join(`
743
+ `)), this._prevFrame = e;
744
+ return;
745
+ }
746
+ }
747
+ this.output.write(import_src.erase.down());
748
+ }
749
+ this.output.write(e), this.state === "initial" && (this.state = "active"), this._prevFrame = e;
750
+ }
751
+ }
752
+ };
753
+ var kt$1 = class extends B {
754
+ get cursor() {
755
+ return this.value ? 0 : 1;
756
+ }
757
+ get _value() {
758
+ return this.cursor === 0;
759
+ }
760
+ constructor(e) {
761
+ super(e, !1), this.value = !!e.initialValue, this.on("userInput", () => {
762
+ this.value = this._value;
763
+ }), this.on("confirm", (s) => {
764
+ this.output.write(import_src.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
765
+ }), this.on("cursor", () => {
766
+ this.value = !this.value;
767
+ });
768
+ }
769
+ };
770
+ //#endregion
771
+ //#region ../../node_modules/.pnpm/@clack+prompts@1.1.0/node_modules/@clack/prompts/dist/index.mjs
772
+ function pt() {
773
+ return process$1.platform !== "win32" ? process$1.env.TERM !== "linux" : !!process$1.env.CI || !!process$1.env.WT_SESSION || !!process$1.env.TERMINUS_SUBLIME || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
774
+ }
775
+ const ee = pt(), I = (e, r) => ee ? e : r, Re = I("◆", "*"), $e = I("■", "x"), de = I("▲", "x"), V = I("◇", "o");
776
+ I("┌", "T");
777
+ const h = I("│", "|"), x = I("└", "—");
778
+ I("┐", "T");
779
+ I("┘", "—");
780
+ const z = I("●", ">"), H = I("○", " ");
781
+ I("◻", "[•]");
782
+ I("◼", "[+]");
783
+ I("◻", "[ ]");
784
+ I("▪", "•");
785
+ const se = I("─", "-"), pe = I("╮", "+"), We = I("├", "+"), me = I("╯", "+"), ge = I("╰", "+");
786
+ I("╭", "+");
787
+ const fe = I("●", "•"), Fe = I("◆", "*"), ye = I("▲", "!"), Ee = I("■", "x"), W = (e) => {
788
+ switch (e) {
789
+ case "initial":
790
+ case "active": return styleText("cyan", Re);
791
+ case "cancel": return styleText("red", $e);
792
+ case "error": return styleText("yellow", de);
793
+ case "submit": return styleText("green", V);
794
+ }
795
+ }, mt = (e) => e === 161 || e === 164 || e === 167 || e === 168 || e === 170 || e === 173 || e === 174 || e >= 176 && e <= 180 || e >= 182 && e <= 186 || e >= 188 && e <= 191 || e === 198 || e === 208 || e === 215 || e === 216 || e >= 222 && e <= 225 || e === 230 || e >= 232 && e <= 234 || e === 236 || e === 237 || e === 240 || e === 242 || e === 243 || e >= 247 && e <= 250 || e === 252 || e === 254 || e === 257 || e === 273 || e === 275 || e === 283 || e === 294 || e === 295 || e === 299 || e >= 305 && e <= 307 || e === 312 || e >= 319 && e <= 322 || e === 324 || e >= 328 && e <= 331 || e === 333 || e === 338 || e === 339 || e === 358 || e === 359 || e === 363 || e === 462 || e === 464 || e === 466 || e === 468 || e === 470 || e === 472 || e === 474 || e === 476 || e === 593 || e === 609 || e === 708 || e === 711 || e >= 713 && e <= 715 || e === 717 || e === 720 || e >= 728 && e <= 731 || e === 733 || e === 735 || e >= 768 && e <= 879 || e >= 913 && e <= 929 || e >= 931 && e <= 937 || e >= 945 && e <= 961 || e >= 963 && e <= 969 || e === 1025 || e >= 1040 && e <= 1103 || e === 1105 || e === 8208 || e >= 8211 && e <= 8214 || e === 8216 || e === 8217 || e === 8220 || e === 8221 || e >= 8224 && e <= 8226 || e >= 8228 && e <= 8231 || e === 8240 || e === 8242 || e === 8243 || e === 8245 || e === 8251 || e === 8254 || e === 8308 || e === 8319 || e >= 8321 && e <= 8324 || e === 8364 || e === 8451 || e === 8453 || e === 8457 || e === 8467 || e === 8470 || e === 8481 || e === 8482 || e === 8486 || e === 8491 || e === 8531 || e === 8532 || e >= 8539 && e <= 8542 || e >= 8544 && e <= 8555 || e >= 8560 && e <= 8569 || e === 8585 || e >= 8592 && e <= 8601 || e === 8632 || e === 8633 || e === 8658 || e === 8660 || e === 8679 || e === 8704 || e === 8706 || e === 8707 || e === 8711 || e === 8712 || e === 8715 || e === 8719 || e === 8721 || e === 8725 || e === 8730 || e >= 8733 && e <= 8736 || e === 8739 || e === 8741 || e >= 8743 && e <= 8748 || e === 8750 || e >= 8756 && e <= 8759 || e === 8764 || e === 8765 || e === 8776 || e === 8780 || e === 8786 || e === 8800 || e === 8801 || e >= 8804 && e <= 8807 || e === 8810 || e === 8811 || e === 8814 || e === 8815 || e === 8834 || e === 8835 || e === 8838 || e === 8839 || e === 8853 || e === 8857 || e === 8869 || e === 8895 || e === 8978 || e >= 9312 && e <= 9449 || e >= 9451 && e <= 9547 || e >= 9552 && e <= 9587 || e >= 9600 && e <= 9615 || e >= 9618 && e <= 9621 || e === 9632 || e === 9633 || e >= 9635 && e <= 9641 || e === 9650 || e === 9651 || e === 9654 || e === 9655 || e === 9660 || e === 9661 || e === 9664 || e === 9665 || e >= 9670 && e <= 9672 || e === 9675 || e >= 9678 && e <= 9681 || e >= 9698 && e <= 9701 || e === 9711 || e === 9733 || e === 9734 || e === 9737 || e === 9742 || e === 9743 || e === 9756 || e === 9758 || e === 9792 || e === 9794 || e === 9824 || e === 9825 || e >= 9827 && e <= 9829 || e >= 9831 && e <= 9834 || e === 9836 || e === 9837 || e === 9839 || e === 9886 || e === 9887 || e === 9919 || e >= 9926 && e <= 9933 || e >= 9935 && e <= 9939 || e >= 9941 && e <= 9953 || e === 9955 || e === 9960 || e === 9961 || e >= 9963 && e <= 9969 || e === 9972 || e >= 9974 && e <= 9977 || e === 9979 || e === 9980 || e === 9982 || e === 9983 || e === 10045 || e >= 10102 && e <= 10111 || e >= 11094 && e <= 11097 || e >= 12872 && e <= 12879 || e >= 57344 && e <= 63743 || e >= 65024 && e <= 65039 || e === 65533 || e >= 127232 && e <= 127242 || e >= 127248 && e <= 127277 || e >= 127280 && e <= 127337 || e >= 127344 && e <= 127373 || e === 127375 || e === 127376 || e >= 127387 && e <= 127404 || e >= 917760 && e <= 917999 || e >= 983040 && e <= 1048573 || e >= 1048576 && e <= 1114109, gt = (e) => e === 12288 || e >= 65281 && e <= 65376 || e >= 65504 && e <= 65510, ft = (e) => e >= 4352 && e <= 4447 || e === 8986 || e === 8987 || e === 9001 || e === 9002 || e >= 9193 && e <= 9196 || e === 9200 || e === 9203 || e === 9725 || e === 9726 || e === 9748 || e === 9749 || e >= 9800 && e <= 9811 || e === 9855 || e === 9875 || e === 9889 || e === 9898 || e === 9899 || e === 9917 || e === 9918 || e === 9924 || e === 9925 || e === 9934 || e === 9940 || e === 9962 || e === 9970 || e === 9971 || e === 9973 || e === 9978 || e === 9981 || e === 9989 || e === 9994 || e === 9995 || e === 10024 || e === 10060 || e === 10062 || e >= 10067 && e <= 10069 || e === 10071 || e >= 10133 && e <= 10135 || e === 10160 || e === 10175 || e === 11035 || e === 11036 || e === 11088 || e === 11093 || e >= 11904 && e <= 11929 || e >= 11931 && e <= 12019 || e >= 12032 && e <= 12245 || e >= 12272 && e <= 12287 || e >= 12289 && e <= 12350 || e >= 12353 && e <= 12438 || e >= 12441 && e <= 12543 || e >= 12549 && e <= 12591 || e >= 12593 && e <= 12686 || e >= 12688 && e <= 12771 || e >= 12783 && e <= 12830 || e >= 12832 && e <= 12871 || e >= 12880 && e <= 19903 || e >= 19968 && e <= 42124 || e >= 42128 && e <= 42182 || e >= 43360 && e <= 43388 || e >= 44032 && e <= 55203 || e >= 63744 && e <= 64255 || e >= 65040 && e <= 65049 || e >= 65072 && e <= 65106 || e >= 65108 && e <= 65126 || e >= 65128 && e <= 65131 || e >= 94176 && e <= 94180 || e === 94192 || e === 94193 || e >= 94208 && e <= 100343 || e >= 100352 && e <= 101589 || e >= 101632 && e <= 101640 || e >= 110576 && e <= 110579 || e >= 110581 && e <= 110587 || e === 110589 || e === 110590 || e >= 110592 && e <= 110882 || e === 110898 || e >= 110928 && e <= 110930 || e === 110933 || e >= 110948 && e <= 110951 || e >= 110960 && e <= 111355 || e === 126980 || e === 127183 || e === 127374 || e >= 127377 && e <= 127386 || e >= 127488 && e <= 127490 || e >= 127504 && e <= 127547 || e >= 127552 && e <= 127560 || e === 127568 || e === 127569 || e >= 127584 && e <= 127589 || e >= 127744 && e <= 127776 || e >= 127789 && e <= 127797 || e >= 127799 && e <= 127868 || e >= 127870 && e <= 127891 || e >= 127904 && e <= 127946 || e >= 127951 && e <= 127955 || e >= 127968 && e <= 127984 || e === 127988 || e >= 127992 && e <= 128062 || e === 128064 || e >= 128066 && e <= 128252 || e >= 128255 && e <= 128317 || e >= 128331 && e <= 128334 || e >= 128336 && e <= 128359 || e === 128378 || e === 128405 || e === 128406 || e === 128420 || e >= 128507 && e <= 128591 || e >= 128640 && e <= 128709 || e === 128716 || e >= 128720 && e <= 128722 || e >= 128725 && e <= 128727 || e >= 128732 && e <= 128735 || e === 128747 || e === 128748 || e >= 128756 && e <= 128764 || e >= 128992 && e <= 129003 || e === 129008 || e >= 129292 && e <= 129338 || e >= 129340 && e <= 129349 || e >= 129351 && e <= 129535 || e >= 129648 && e <= 129660 || e >= 129664 && e <= 129672 || e >= 129680 && e <= 129725 || e >= 129727 && e <= 129733 || e >= 129742 && e <= 129755 || e >= 129760 && e <= 129768 || e >= 129776 && e <= 129784 || e >= 131072 && e <= 196605 || e >= 196608 && e <= 262141, we = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, re = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, ie = /\t{1,1000}/y, Ae = /[\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?))*/uy, ne = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, Ft = /\p{M}+/gu, yt = {
796
+ limit: Infinity,
797
+ ellipsis: ""
798
+ }, Le = (e, r = {}, s = {}) => {
799
+ const i = r.limit ?? Infinity, a = r.ellipsis ?? "", o = r?.ellipsisWidth ?? (a ? Le(a, yt, s).width : 0), u = s.ansiWidth ?? 0, l = s.controlWidth ?? 0, n = s.tabWidth ?? 8, c = s.ambiguousWidth ?? 1, p = s.emojiWidth ?? 2, f = s.fullWidthWidth ?? 2, g = s.regularWidth ?? 1, E = s.wideWidth ?? 2;
800
+ let $ = 0, m = 0, d = e.length, F = 0, y = !1, v = d, C = Math.max(0, i - o), A = 0, b = 0, w = 0, S = 0;
801
+ e: for (;;) {
802
+ if (b > A || m >= d && m > $) {
803
+ const T = e.slice(A, b) || e.slice($, m);
804
+ F = 0;
805
+ for (const M of T.replaceAll(Ft, "")) {
806
+ const O = M.codePointAt(0) || 0;
807
+ if (gt(O) ? S = f : ft(O) ? S = E : c !== g && mt(O) ? S = c : S = g, w + S > C && (v = Math.min(v, Math.max(A, $) + F)), w + S > i) {
808
+ y = !0;
809
+ break e;
810
+ }
811
+ F += M.length, w += S;
812
+ }
813
+ A = b = 0;
814
+ }
815
+ if (m >= d) break;
816
+ if (ne.lastIndex = m, ne.test(e)) {
817
+ if (F = ne.lastIndex - m, S = F * g, w + S > C && (v = Math.min(v, m + Math.floor((C - w) / g))), w + S > i) {
818
+ y = !0;
819
+ break;
820
+ }
821
+ w += S, A = $, b = m, m = $ = ne.lastIndex;
822
+ continue;
823
+ }
824
+ if (we.lastIndex = m, we.test(e)) {
825
+ if (w + u > C && (v = Math.min(v, m)), w + u > i) {
826
+ y = !0;
827
+ break;
828
+ }
829
+ w += u, A = $, b = m, m = $ = we.lastIndex;
830
+ continue;
831
+ }
832
+ if (re.lastIndex = m, re.test(e)) {
833
+ if (F = re.lastIndex - m, S = F * l, w + S > C && (v = Math.min(v, m + Math.floor((C - w) / l))), w + S > i) {
834
+ y = !0;
835
+ break;
836
+ }
837
+ w += S, A = $, b = m, m = $ = re.lastIndex;
838
+ continue;
839
+ }
840
+ if (ie.lastIndex = m, ie.test(e)) {
841
+ if (F = ie.lastIndex - m, S = F * n, w + S > C && (v = Math.min(v, m + Math.floor((C - w) / n))), w + S > i) {
842
+ y = !0;
843
+ break;
844
+ }
845
+ w += S, A = $, b = m, m = $ = ie.lastIndex;
846
+ continue;
847
+ }
848
+ if (Ae.lastIndex = m, Ae.test(e)) {
849
+ if (w + p > C && (v = Math.min(v, m)), w + p > i) {
850
+ y = !0;
851
+ break;
852
+ }
853
+ w += p, A = $, b = m, m = $ = Ae.lastIndex;
854
+ continue;
855
+ }
856
+ m += 1;
857
+ }
858
+ return {
859
+ width: y ? C : w,
860
+ index: y ? v : d,
861
+ truncated: y,
862
+ ellipsed: y && i >= o
863
+ };
864
+ }, Et = {
865
+ limit: Infinity,
866
+ ellipsis: "",
867
+ ellipsisWidth: 0
868
+ }, D = (e, r = {}) => Le(e, Et, r).width, ae = "\x1B", je = "›", vt = 39, Ce = "\x07", ke = "[", wt = "]", Ve = "m", Se = `${wt}8;;`, He = new RegExp(`(?:\\${ke}(?<code>\\d+)m|\\${Se}(?<uri>.*)${Ce})`, "y"), At = (e) => {
869
+ if (e >= 30 && e <= 37 || e >= 90 && e <= 97) return 39;
870
+ if (e >= 40 && e <= 47 || e >= 100 && e <= 107) return 49;
871
+ if (e === 1 || e === 2) return 22;
872
+ if (e === 3) return 23;
873
+ if (e === 4) return 24;
874
+ if (e === 7) return 27;
875
+ if (e === 8) return 28;
876
+ if (e === 9) return 29;
877
+ if (e === 0) return 0;
878
+ }, Ue = (e) => `${ae}${ke}${e}${Ve}`, Ke = (e) => `${ae}${Se}${e}${Ce}`, Ct = (e) => e.map((r) => D(r)), Ie = (e, r, s) => {
879
+ const i = r[Symbol.iterator]();
880
+ let a = !1, o = !1, u = e.at(-1), l = u === void 0 ? 0 : D(u), n = i.next(), c = i.next(), p = 0;
881
+ for (; !n.done;) {
882
+ const f = n.value, g = D(f);
883
+ l + g <= s ? e[e.length - 1] += f : (e.push(f), l = 0), (f === ae || f === je) && (a = !0, o = r.startsWith(Se, p + 1)), a ? o ? f === Ce && (a = !1, o = !1) : f === Ve && (a = !1) : (l += g, l === s && !c.done && (e.push(""), l = 0)), n = c, c = i.next(), p += f.length;
884
+ }
885
+ u = e.at(-1), !l && u !== void 0 && u.length > 0 && e.length > 1 && (e[e.length - 2] += e.pop());
886
+ }, St = (e) => {
887
+ const r = e.split(" ");
888
+ let s = r.length;
889
+ for (; s > 0 && !(D(r[s - 1]) > 0);) s--;
890
+ return s === r.length ? e : r.slice(0, s).join(" ") + r.slice(s).join("");
891
+ }, It = (e, r, s = {}) => {
892
+ if (s.trim !== !1 && e.trim() === "") return "";
893
+ let i = "", a, o;
894
+ const u = e.split(" "), l = Ct(u);
895
+ let n = [""];
896
+ for (const [$, m] of u.entries()) {
897
+ s.trim !== !1 && (n[n.length - 1] = (n.at(-1) ?? "").trimStart());
898
+ let d = D(n.at(-1) ?? "");
899
+ if ($ !== 0 && (d >= r && (s.wordWrap === !1 || s.trim === !1) && (n.push(""), d = 0), (d > 0 || s.trim === !1) && (n[n.length - 1] += " ", d++)), s.hard && l[$] > r) {
900
+ const F = r - d, y = 1 + Math.floor((l[$] - F - 1) / r);
901
+ Math.floor((l[$] - 1) / r) < y && n.push(""), Ie(n, m, r);
902
+ continue;
903
+ }
904
+ if (d + l[$] > r && d > 0 && l[$] > 0) {
905
+ if (s.wordWrap === !1 && d < r) {
906
+ Ie(n, m, r);
907
+ continue;
908
+ }
909
+ n.push("");
910
+ }
911
+ if (d + l[$] > r && s.wordWrap === !1) {
912
+ Ie(n, m, r);
913
+ continue;
914
+ }
915
+ n[n.length - 1] += m;
916
+ }
917
+ s.trim !== !1 && (n = n.map(($) => St($)));
918
+ const c = n.join(`
919
+ `), p = c[Symbol.iterator]();
920
+ let f = p.next(), g = p.next(), E = 0;
921
+ for (; !f.done;) {
922
+ const $ = f.value, m = g.value;
923
+ if (i += $, $ === ae || $ === je) {
924
+ He.lastIndex = E + 1;
925
+ const y = He.exec(c)?.groups;
926
+ if (y?.code !== void 0) {
927
+ const v = Number.parseFloat(y.code);
928
+ a = v === vt ? void 0 : v;
929
+ } else y?.uri !== void 0 && (o = y.uri.length === 0 ? void 0 : y.uri);
930
+ }
931
+ const d = a ? At(a) : void 0;
932
+ m === `
933
+ ` ? (o && (i += Ke("")), a && d && (i += Ue(d))) : $ === `
934
+ ` && (a && d && (i += Ue(a)), o && (i += Ke(o))), E += $.length, f = g, g = p.next();
935
+ }
936
+ return i;
937
+ };
938
+ function J(e, r, s) {
939
+ return String(e).normalize().replaceAll(`\r
940
+ `, `
941
+ `).split(`
942
+ `).map((i) => It(i, r, s)).join(`
943
+ `);
944
+ }
945
+ const Rt = (e) => {
946
+ const r = e.active ?? "Yes", s = e.inactive ?? "No";
947
+ return new kt$1({
948
+ active: r,
949
+ inactive: s,
950
+ signal: e.signal,
951
+ input: e.input,
952
+ output: e.output,
953
+ initialValue: e.initialValue ?? !0,
954
+ render() {
955
+ const i = e.withGuide ?? _.withGuide, a = `${i ? `${styleText("gray", h)}
956
+ ` : ""}${W(this.state)} ${e.message}
957
+ `, o = this.value ? r : s;
958
+ switch (this.state) {
959
+ case "submit": return `${a}${i ? `${styleText("gray", h)} ` : ""}${styleText("dim", o)}`;
960
+ case "cancel": return `${a}${i ? `${styleText("gray", h)} ` : ""}${styleText(["strikethrough", "dim"], o)}${i ? `
961
+ ${styleText("gray", h)}` : ""}`;
962
+ default: {
963
+ const u = i ? `${styleText("cyan", h)} ` : "", l = i ? styleText("cyan", x) : "";
964
+ return `${a}${u}${this.value ? `${styleText("green", z)} ${r}` : `${styleText("dim", H)} ${styleText("dim", r)}`}${e.vertical ? i ? `
965
+ ${styleText("cyan", h)} ` : `
966
+ ` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim", H)} ${styleText("dim", s)}` : `${styleText("green", z)} ${s}`}
967
+ ${l}
968
+ `;
969
+ }
970
+ }
971
+ }
972
+ }).prompt();
973
+ }, R = {
974
+ message: (e = [], { symbol: r = styleText("gray", h), secondarySymbol: s = styleText("gray", h), output: i = process.stdout, spacing: a = 1, withGuide: o } = {}) => {
975
+ const u = [], l = o ?? _.withGuide, n = l ? s : "", c = l ? `${r} ` : "", p = l ? `${s} ` : "";
976
+ for (let g = 0; g < a; g++) u.push(n);
977
+ const f = Array.isArray(e) ? e : e.split(`
978
+ `);
979
+ if (f.length > 0) {
980
+ const [g, ...E] = f;
981
+ g.length > 0 ? u.push(`${c}${g}`) : u.push(l ? r : "");
982
+ for (const $ of E) $.length > 0 ? u.push(`${p}${$}`) : u.push(l ? s : "");
983
+ }
984
+ i.write(`${u.join(`
985
+ `)}
986
+ `);
987
+ },
988
+ info: (e, r) => {
989
+ R.message(e, {
990
+ ...r,
991
+ symbol: styleText("blue", fe)
992
+ });
993
+ },
994
+ success: (e, r) => {
995
+ R.message(e, {
996
+ ...r,
997
+ symbol: styleText("green", Fe)
998
+ });
999
+ },
1000
+ step: (e, r) => {
1001
+ R.message(e, {
1002
+ ...r,
1003
+ symbol: styleText("green", V)
1004
+ });
1005
+ },
1006
+ warn: (e, r) => {
1007
+ R.message(e, {
1008
+ ...r,
1009
+ symbol: styleText("yellow", ye)
1010
+ });
1011
+ },
1012
+ warning: (e, r) => {
1013
+ R.warn(e, r);
1014
+ },
1015
+ error: (e, r) => {
1016
+ R.message(e, {
1017
+ ...r,
1018
+ symbol: styleText("red", Ee)
1019
+ });
1020
+ }
1021
+ }, Gt = (e = "", r) => {
1022
+ const s = r?.output ?? process.stdout, i = r?.withGuide ?? _.withGuide ? `${styleText("gray", h)}
1023
+ ${styleText("gray", x)} ` : "";
1024
+ s.write(`${i}${e}
1025
+
1026
+ `);
1027
+ }, jt = (e) => styleText("dim", e), kt = (e, r, s) => {
1028
+ const i = {
1029
+ hard: !0,
1030
+ trim: !1
1031
+ }, a = J(e, r, i).split(`
1032
+ `), o = a.reduce((n, c) => Math.max(D(c), n), 0);
1033
+ return J(e, r - (a.map(s).reduce((n, c) => Math.max(D(c), n), 0) - o), i);
1034
+ }, Vt = (e = "", r = "", s) => {
1035
+ const i = s?.output ?? process$1.stdout, a = s?.withGuide ?? _.withGuide, o = s?.format ?? jt, u = [
1036
+ "",
1037
+ ...kt(e, rt(i) - 6, o).split(`
1038
+ `).map(o),
1039
+ ""
1040
+ ], l = D(r), n = Math.max(u.reduce((g, E) => {
1041
+ const $ = D(E);
1042
+ return $ > g ? $ : g;
1043
+ }, 0), l) + 2, c = u.map((g) => `${styleText("gray", h)} ${g}${" ".repeat(n - D(g))}${styleText("gray", h)}`).join(`
1044
+ `), p = a ? `${styleText("gray", h)}
1045
+ ` : "", f = a ? We : ge;
1046
+ i.write(`${p}${styleText("green", V)} ${styleText("reset", r)} ${styleText("gray", se.repeat(Math.max(n - l - 1, 1)) + pe)}
1047
+ ${c}
1048
+ ${styleText("gray", f + se.repeat(n + 2) + me)}
1049
+ `);
1050
+ };
1051
+ I("─", "-"), I("━", "="), I("█", "#");
1052
+ const Qe = `${styleText("gray", h)} `, K = {
1053
+ message: async (e, { symbol: r = styleText("gray", h) } = {}) => {
1054
+ process.stdout.write(`${styleText("gray", h)}
1055
+ ${r} `);
1056
+ let s = 3;
1057
+ for await (let i of e) {
1058
+ i = i.replace(/\n/g, `
1059
+ ${Qe}`), i.includes(`
1060
+ `) && (s = 3 + stripVTControlCharacters(i.slice(i.lastIndexOf(`
1061
+ `))).length);
1062
+ const a = stripVTControlCharacters(i).length;
1063
+ s + a < process.stdout.columns ? (s += a, process.stdout.write(i)) : (process.stdout.write(`
1064
+ ${Qe}${i.trimStart()}`), s = 3 + stripVTControlCharacters(i.trimStart()).length);
1065
+ }
1066
+ process.stdout.write(`
1067
+ `);
1068
+ },
1069
+ info: (e) => K.message(e, { symbol: styleText("blue", fe) }),
1070
+ success: (e) => K.message(e, { symbol: styleText("green", Fe) }),
1071
+ step: (e) => K.message(e, { symbol: styleText("green", V) }),
1072
+ warn: (e) => K.message(e, { symbol: styleText("yellow", ye) }),
1073
+ warning: (e) => K.warn(e),
1074
+ error: (e) => K.message(e, { symbol: styleText("red", Ee) })
1075
+ };
1076
+ //#endregion
1077
+ //#region ../../node_modules/.pnpm/ansis@4.2.0/node_modules/ansis/index.mjs
1078
+ var import_ansis = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
1079
+ let e, t, r, { defineProperty: l, setPrototypeOf: n, create: o, keys: s } = Object, i = "", { round: c, max: a } = Math, p = (e) => {
1080
+ let t = /([a-f\d]{3,6})/i.exec(e)?.[1], r = t?.length, l = parseInt(6 ^ r ? 3 ^ r ? "0" : t[0] + t[0] + t[1] + t[1] + t[2] + t[2] : t, 16);
1081
+ return [
1082
+ l >> 16 & 255,
1083
+ l >> 8 & 255,
1084
+ 255 & l
1085
+ ];
1086
+ }, u = (e, t, r) => e ^ t || t ^ r ? 16 + 36 * c(e / 51) + 6 * c(t / 51) + c(r / 51) : 8 > e ? 16 : e > 248 ? 231 : c(24 * (e - 8) / 247) + 232, d = (e) => {
1087
+ let t, r, l, n, o;
1088
+ return 8 > e ? 30 + e : 16 > e ? e - 8 + 90 : (232 > e ? (o = (e -= 16) % 36, t = (e / 36 | 0) / 5, r = (o / 6 | 0) / 5, l = o % 6 / 5) : t = r = l = (10 * (e - 232) + 8) / 255, n = 2 * a(t, r, l), n ? 30 + (c(l) << 2 | c(r) << 1 | c(t)) + (2 ^ n ? 0 : 60) : 30);
1089
+ }, f = (() => {
1090
+ let r = (e) => o.some(((t) => e.test(t))), l = globalThis, n = l.process ?? {}, o = n.argv ?? [], i = n.env ?? {}, c = -1;
1091
+ try {
1092
+ e = "," + s(i).join(",");
1093
+ } catch (e) {
1094
+ i = {}, c = 0;
1095
+ }
1096
+ let a = "FORCE_COLOR", p = {
1097
+ false: 0,
1098
+ 0: 0,
1099
+ 1: 1,
1100
+ 2: 2,
1101
+ 3: 3
1102
+ }[i[a]] ?? -1, u = a in i && p || r(/^--color=?(true|always)?$/);
1103
+ return u && (c = p), ~c || (c = ((r, l, n) => (t = r.TERM, {
1104
+ "24bit": 3,
1105
+ truecolor: 3,
1106
+ ansi256: 2,
1107
+ ansi: 1
1108
+ }[r.COLORTERM] || (r.CI ? /,GITHUB/.test(e) ? 3 : 1 : l && "dumb" !== t ? n ? 3 : /-256/.test(t) ? 2 : 1 : 0)))(i, !!i.PM2_HOME || i.NEXT_RUNTIME?.includes("edge") || !!n.stdout?.isTTY, "win32" === n.platform)), !p || i.NO_COLOR || r(/^--(no-color|color=(false|never))$/) ? 0 : l.window?.chrome || u && !c ? 3 : c;
1109
+ })(), g = {
1110
+ open: i,
1111
+ close: i
1112
+ }, h = 39, b = 49, O = {}, m = ({ p: e }, { open: t, close: l }) => {
1113
+ let o = (e, ...r) => {
1114
+ if (!e) {
1115
+ if (t && t === l) return t;
1116
+ if ((e ?? i) === i) return i;
1117
+ }
1118
+ let n, s = e.raw ? String.raw({ raw: e }, ...r) : i + e, c = o.p, a = c.o, p = c.c;
1119
+ if (s.includes("\x1B")) for (; c; c = c.p) {
1120
+ let { open: e, close: t } = c, r = t.length, l = i, o = 0;
1121
+ if (r) for (; ~(n = s.indexOf(t, o)); o = n + r) l += s.slice(o, n) + e;
1122
+ s = l + s.slice(o);
1123
+ }
1124
+ return a + (s.includes("\n") ? s.replace(/(\r?\n)/g, p + "$1" + a) : s) + p;
1125
+ }, s = t, c = l;
1126
+ return e && (s = e.o + t, c = l + e.c), n(o, r), o.p = {
1127
+ open: t,
1128
+ close: l,
1129
+ o: s,
1130
+ c,
1131
+ p: e
1132
+ }, o.open = s, o.close = c, o;
1133
+ };
1134
+ const w = new function e(t = f) {
1135
+ let s = {
1136
+ Ansis: e,
1137
+ level: t,
1138
+ isSupported: () => a,
1139
+ strip: (e) => e.replace(/[›][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, i),
1140
+ extend(e) {
1141
+ for (let t in e) {
1142
+ let r = e[t], l = (typeof r)[0];
1143
+ "s" === l ? (c(t, T(...p(r))), c(_(t), v(...p(r)))) : c(t, r, "f" === l);
1144
+ }
1145
+ return r = o({}, O), n(s, r), s;
1146
+ }
1147
+ }, c = (e, t, r) => {
1148
+ O[e] = { get() {
1149
+ let n = r ? (...e) => m(this, t(...e)) : m(this, t);
1150
+ return l(this, e, { value: n }), n;
1151
+ } };
1152
+ }, a = t > 0, w = (e, t) => a ? {
1153
+ open: `[${e}m`,
1154
+ close: `[${t}m`
1155
+ } : g, y = (e) => (t) => e(...p(t)), R = (e, t) => (r, l, n) => w(`${e}8;2;${r};${l};${n}`, t), $ = (e, t) => (r, l, n) => w(((e, t, r) => d(u(e, t, r)))(r, l, n) + e, t), x = (e) => (t, r, l) => e(u(t, r, l)), T = R(3, h), v = R(4, b), C = (e) => w("38;5;" + e, h), E = (e) => w("48;5;" + e, b);
1156
+ 2 === t ? (T = x(C), v = x(E)) : 1 === t && (T = $(0, h), v = $(10, b), C = (e) => w(d(e), h), E = (e) => w(d(e) + 10, b));
1157
+ let M, I = {
1158
+ fg: C,
1159
+ bg: E,
1160
+ rgb: T,
1161
+ bgRgb: v,
1162
+ hex: y(T),
1163
+ bgHex: y(v),
1164
+ visible: g,
1165
+ reset: w(0, 0),
1166
+ bold: w(1, 22),
1167
+ dim: w(2, 22),
1168
+ italic: w(3, 23),
1169
+ underline: w(4, 24),
1170
+ inverse: w(7, 27),
1171
+ hidden: w(8, 28),
1172
+ strikethrough: w(9, 29)
1173
+ }, _ = (e) => "bg" + e[0].toUpperCase() + e.slice(1), k = "Bright";
1174
+ return "black,red,green,yellow,blue,magenta,cyan,white,gray".split(",").map(((e, t) => {
1175
+ M = _(e), 8 > t ? (I[e + k] = w(90 + t, h), I[M + k] = w(100 + t, b)) : t = 60, I[e] = w(30 + t, h), I[M] = w(40 + t, b);
1176
+ })), s.extend(I);
1177
+ }();
1178
+ module.exports = w, w.default = w;
1179
+ })))(), 1);
1180
+ var ansis_default = import_ansis.default;
1181
+ const { Ansis, fg, bg, rgb, bgRgb, hex, bgHex, reset, inverse, hidden, visible, bold, dim, italic, underline, strikethrough, black, red, green, yellow, blue, magenta, cyan, white, gray, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bgGray, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright } = import_ansis.default;
1182
+ //#endregion
1183
+ //#region src/node/context-internal.ts
1184
+ const internalContextMap = /* @__PURE__ */ new WeakMap();
1185
+ function getInternalContext(context) {
1186
+ if (!internalContextMap.has(context)) {
1187
+ const internalContext = { storage: { auth: createStorage({
1188
+ filepath: join(context.workspaceRoot, "node_modules/.vite/devtools/auth.json"),
1189
+ initialValue: { trusted: {} }
1190
+ }) } };
1191
+ internalContextMap.set(context, internalContext);
1192
+ }
1193
+ return internalContextMap.get(context);
1194
+ }
1195
+ //#endregion
1196
+ //#region src/node/rpc/anonymous/auth.ts
1197
+ const anonymousAuth = defineRpcFunction({
1198
+ name: "vite:anonymous:auth",
1199
+ type: "action",
1200
+ setup: (context) => {
1201
+ const storage = getInternalContext(context).storage.auth;
1202
+ return { handler: async (query) => {
1203
+ const session = context.rpc.getCurrentRpcSession();
1204
+ if (!session) throw new Error("Failed to retrieve the current RPC session");
1205
+ if (session.meta.isTrusted || storage.value().trusted[query.authId]) {
1206
+ session.meta.clientAuthId = query.authId;
1207
+ session.meta.isTrusted = true;
1208
+ return { isTrusted: true };
1209
+ }
1210
+ const message = [
1211
+ `A browser is requesting permissions to connect to the Vite DevTools.`,
1212
+ "",
1213
+ `User Agent: ${ansis_default.yellow(ansis_default.bold(query.ua || "Unknown"))}`,
1214
+ `Origin : ${ansis_default.cyan(ansis_default.bold(query.origin || "Unknown"))}`,
1215
+ `Identifier: ${ansis_default.green(ansis_default.bold(query.authId))}`,
1216
+ "",
1217
+ "This will allow the browser to interact with the server, make file changes and run commands.",
1218
+ ansis_default.red(ansis_default.bold("You should only trust your local development browsers."))
1219
+ ];
1220
+ Vt(ansis_default.reset(message.join("\n")), ansis_default.bold(ansis_default.yellow(" Vite DevTools Permission Request ")));
1221
+ if (await Rt({
1222
+ message: ansis_default.bold(`Do you trust this client (${ansis_default.green(ansis_default.bold(query.authId))})?`),
1223
+ initialValue: false
1224
+ })) {
1225
+ storage.mutate((state) => {
1226
+ state.trusted[query.authId] = {
1227
+ authId: query.authId,
1228
+ ua: query.ua,
1229
+ origin: query.origin,
1230
+ timestamp: Date.now()
1231
+ };
1232
+ });
1233
+ session.meta.clientAuthId = query.authId;
1234
+ session.meta.isTrusted = true;
1235
+ Gt(ansis_default.green(ansis_default.bold(`You have granted permissions to ${ansis_default.bold(query.authId)}`)));
1236
+ return { isTrusted: true };
1237
+ }
1238
+ Gt(ansis_default.red(ansis_default.bold(`You have denied permissions to ${ansis_default.bold(query.authId)}`)));
1239
+ return { isTrusted: false };
1240
+ } };
1241
+ }
1242
+ });
1243
+ //#endregion
1244
+ //#region src/node/rpc/internal/docks-on-launch.ts
1245
+ const docksOnLaunch = defineRpcFunction({
1246
+ name: "devtoolskit:internal:docks:on-launch",
1247
+ type: "action",
1248
+ setup: (context) => {
1249
+ const launchMap = /* @__PURE__ */ new Map();
1250
+ return { handler: async (entryId) => {
1251
+ if (launchMap.has(entryId)) return launchMap.get(entryId);
1252
+ const entry = context.docks.values().find((entry) => entry.id === entryId);
1253
+ if (!entry) throw new Error(`Dock entry with id "${entryId}" not found`);
1254
+ if (entry.type !== "launcher") throw new Error(`Dock entry with id "${entryId}" is not a launcher`);
1255
+ try {
1256
+ context.docks.update({
1257
+ ...entry,
1258
+ launcher: {
1259
+ ...entry.launcher,
1260
+ status: "loading"
1261
+ }
1262
+ });
1263
+ const promise = entry.launcher.onLaunch();
1264
+ launchMap.set(entryId, promise);
1265
+ const result = await promise;
1266
+ const newEntry = context.docks.values().find((entry) => entry.id === entryId) || entry;
1267
+ if (newEntry.type === "launcher") context.docks.update({
1268
+ ...newEntry,
1269
+ launcher: {
1270
+ ...newEntry.launcher,
1271
+ status: "success"
1272
+ }
1273
+ });
1274
+ return result;
1275
+ } catch (error) {
1276
+ console.error(`[VITE DEVTOOLS] Error launching dock entry "${entryId}"`, error);
1277
+ context.docks.update({
1278
+ ...entry,
1279
+ launcher: {
1280
+ ...entry.launcher,
1281
+ status: "error",
1282
+ error: error instanceof Error ? error.message : String(error)
1283
+ }
1284
+ });
1285
+ }
1286
+ } };
1287
+ }
1288
+ });
1289
+ //#endregion
1290
+ //#region src/node/rpc/internal/rpc-server-list.ts
1291
+ const rpcServerList = defineRpcFunction({
1292
+ name: "devtoolskit:internal:rpc:server:list",
1293
+ type: "static",
1294
+ setup: (context) => {
1295
+ return { async handler() {
1296
+ return Object.fromEntries(Array.from(context.rpc.definitions.entries()).map(([name, fn]) => [name, { type: fn.type }]));
1297
+ } };
1298
+ }
1299
+ });
1300
+ //#endregion
1301
+ //#region src/node/rpc/internal/state/get.ts
1302
+ const sharedStateGet = defineRpcFunction({
1303
+ name: "devtoolskit:internal:rpc:server-state:get",
1304
+ type: "query",
1305
+ setup: (context) => {
1306
+ return { handler: async (key) => {
1307
+ return (await context.rpc.sharedState.get(key)).value();
1308
+ } };
1309
+ }
1310
+ });
1311
+ //#endregion
1312
+ //#region src/node/rpc/internal/state/patch.ts
1313
+ const sharedStatePatch = defineRpcFunction({
1314
+ name: "devtoolskit:internal:rpc:server-state:patch",
1315
+ type: "query",
1316
+ setup: (context) => {
1317
+ return { handler: async (key, patches, syncId) => {
1318
+ (await context.rpc.sharedState.get(key)).patch(patches, syncId);
1319
+ } };
1320
+ }
1321
+ });
1322
+ //#endregion
1323
+ //#region src/node/rpc/internal/state/set.ts
1324
+ const sharedStateSet = defineRpcFunction({
1325
+ name: "devtoolskit:internal:rpc:server-state:set",
1326
+ type: "query",
1327
+ setup: (context) => {
1328
+ return { handler: async (key, value, syncId) => {
1329
+ (await context.rpc.sharedState.get(key)).mutate(() => value, syncId);
1330
+ } };
1331
+ }
1332
+ });
1333
+ //#endregion
1334
+ //#region src/node/rpc/internal/state/subscribe.ts
1335
+ const debug = createDebug("vite:devtools:rpc:state:subscribe");
1336
+ const sharedStateSubscribe = defineRpcFunction({
1337
+ name: "devtoolskit:internal:rpc:server-state:subscribe",
1338
+ type: "event",
1339
+ setup: (context) => {
1340
+ return { handler: async (key) => {
1341
+ const session = context.rpc.getCurrentRpcSession();
1342
+ if (!session) return;
1343
+ debug("subscribe", {
1344
+ key,
1345
+ session: session.meta.id
1346
+ });
1347
+ session.meta.subscribedStates.add(key);
1348
+ } };
1349
+ }
1350
+ });
1351
+ //#endregion
1352
+ //#region src/node/rpc/internal/terminals-list.ts
1353
+ const terminalsList = defineRpcFunction({
1354
+ name: "devtoolskit:internal:terminals:list",
1355
+ type: "static",
1356
+ setup: (context) => {
1357
+ return { async handler() {
1358
+ return Array.from(context.terminals.sessions.values()).map((i) => {
1359
+ return {
1360
+ id: i.id,
1361
+ title: i.title,
1362
+ description: i.description,
1363
+ status: i.status
1364
+ };
1365
+ });
1366
+ } };
1367
+ }
1368
+ });
1369
+ //#endregion
1370
+ //#region src/node/rpc/internal/terminals-read.ts
1371
+ const terminalsRead = defineRpcFunction({
1372
+ name: "devtoolskit:internal:terminals:read",
1373
+ type: "query",
1374
+ setup: (context) => {
1375
+ return { async handler(id) {
1376
+ const session = context.terminals.sessions.get(id);
1377
+ if (!session) throw new Error(`Terminal session with id "${id}" not found`);
1378
+ return {
1379
+ buffer: session.buffer ?? [],
1380
+ ts: Date.now()
1381
+ };
1382
+ } };
1383
+ }
1384
+ });
1385
+ //#endregion
1386
+ //#region src/node/rpc/index.ts
1387
+ const builtinPublicRpcDeclarations = [defineRpcFunction({
1388
+ name: "vite:core:open-in-editor",
1389
+ type: "action",
1390
+ setup: () => {
1391
+ return { handler: async (path) => {
1392
+ await import("launch-editor").then((r) => r.default(path));
1393
+ } };
1394
+ }
1395
+ }), defineRpcFunction({
1396
+ name: "vite:core:open-in-finder",
1397
+ type: "action",
1398
+ setup: () => {
1399
+ return { handler: async (path) => {
1400
+ await import("open").then((r) => r.default(path));
1401
+ } };
1402
+ }
1403
+ })];
1404
+ const builtinAnonymousRpcDeclarations = [anonymousAuth];
1405
+ const builtinInternalRpcDeclarations = [
1406
+ docksOnLaunch,
1407
+ rpcServerList,
1408
+ sharedStateGet,
1409
+ sharedStatePatch,
1410
+ sharedStateSet,
1411
+ sharedStateSubscribe,
1412
+ terminalsList,
1413
+ terminalsRead
1414
+ ];
1415
+ const builtinRpcDeclarations = [
1416
+ ...builtinPublicRpcDeclarations,
1417
+ ...builtinAnonymousRpcDeclarations,
1418
+ ...builtinInternalRpcDeclarations
1419
+ ];
1420
+ //#endregion
1421
+ //#region src/node/context.ts
1422
+ const debugSetup = createDebug("vite:devtools:context:setup");
1423
+ async function createDevToolsContext(viteConfig, viteServer) {
1424
+ const cwd = viteConfig.root;
1425
+ const context = {
1426
+ cwd,
1427
+ workspaceRoot: searchForWorkspaceRoot(cwd) ?? cwd,
1428
+ viteConfig,
1429
+ viteServer,
1430
+ mode: viteConfig.command === "serve" ? "dev" : "build",
1431
+ rpc: void 0,
1432
+ docks: void 0,
1433
+ views: void 0,
1434
+ utils: ContextUtils,
1435
+ terminals: void 0
1436
+ };
1437
+ const rpcHost = new RpcFunctionsHost(context);
1438
+ const docksHost = new DevToolsDockHost(context);
1439
+ const viewsHost = new DevToolsViewHost(context);
1440
+ const terminalsHost = new DevToolsTerminalHost(context);
1441
+ context.rpc = rpcHost;
1442
+ context.docks = docksHost;
1443
+ context.views = viewsHost;
1444
+ context.terminals = terminalsHost;
1445
+ for (const fn of builtinRpcDeclarations) rpcHost.register(fn);
1446
+ await docksHost.init();
1447
+ const docksSharedState = await rpcHost.sharedState.get("devtoolskit:internal:docks", { initialValue: [] });
1448
+ docksHost.events.on("dock:entry:updated", debounce(() => {
1449
+ docksSharedState.mutate(() => context.docks.values());
1450
+ }, 10));
1451
+ terminalsHost.events.on("terminal:session:updated", debounce(() => {
1452
+ rpcHost.broadcast({
1453
+ method: "devtoolskit:internal:terminals:updated",
1454
+ args: []
1455
+ });
1456
+ docksSharedState.mutate(() => context.docks.values());
1457
+ }, 10));
1458
+ terminalsHost.events.on("terminal:session:stream-chunk", (data) => {
1459
+ rpcHost.broadcast({
1460
+ method: "devtoolskit:internal:terminals:stream-chunk",
1461
+ args: [data]
1462
+ });
1463
+ });
1464
+ const plugins = viteConfig.plugins.filter((plugin) => "devtools" in plugin);
1465
+ for (const plugin of plugins) {
1466
+ if (!plugin.devtools?.setup) continue;
1467
+ try {
1468
+ debugSetup(`setting up plugin ${JSON.stringify(plugin.name)}`);
1469
+ await plugin.devtools?.setup?.(context);
1470
+ } catch (error) {
1471
+ console.error(`[Vite DevTools] Error setting up plugin ${plugin.name}:`, error);
1472
+ throw error;
1473
+ }
1474
+ }
1475
+ return context;
1476
+ }
1477
+ //#endregion
1478
+ //#region src/node/plugins/injection.ts
1479
+ function DevToolsInjection() {
1480
+ return {
1481
+ name: "vite:devtools:injection",
1482
+ enforce: "post",
1483
+ transformIndexHtml() {
1484
+ return [{
1485
+ tag: "script",
1486
+ attrs: {
1487
+ src: `/@fs/${process$1.env.VITE_DEVTOOLS_LOCAL_DEV ? normalizePath(join$1(dirDist, "..", "src/client/inject/index.ts")) : normalizePath(join$1(dirDist, "client/inject.js"))}`,
1488
+ type: "module"
1489
+ },
1490
+ injectTo: "body"
1491
+ }];
1492
+ }
1493
+ };
1494
+ }
1495
+ //#endregion
1496
+ //#region ../../node_modules/.pnpm/get-port-please@3.2.0/node_modules/get-port-please/dist/index.mjs
1497
+ const unsafePorts = /* @__PURE__ */ new Set([
1498
+ 1,
1499
+ 7,
1500
+ 9,
1501
+ 11,
1502
+ 13,
1503
+ 15,
1504
+ 17,
1505
+ 19,
1506
+ 20,
1507
+ 21,
1508
+ 22,
1509
+ 23,
1510
+ 25,
1511
+ 37,
1512
+ 42,
1513
+ 43,
1514
+ 53,
1515
+ 69,
1516
+ 77,
1517
+ 79,
1518
+ 87,
1519
+ 95,
1520
+ 101,
1521
+ 102,
1522
+ 103,
1523
+ 104,
1524
+ 109,
1525
+ 110,
1526
+ 111,
1527
+ 113,
1528
+ 115,
1529
+ 117,
1530
+ 119,
1531
+ 123,
1532
+ 135,
1533
+ 137,
1534
+ 139,
1535
+ 143,
1536
+ 161,
1537
+ 179,
1538
+ 389,
1539
+ 427,
1540
+ 465,
1541
+ 512,
1542
+ 513,
1543
+ 514,
1544
+ 515,
1545
+ 526,
1546
+ 530,
1547
+ 531,
1548
+ 532,
1549
+ 540,
1550
+ 548,
1551
+ 554,
1552
+ 556,
1553
+ 563,
1554
+ 587,
1555
+ 601,
1556
+ 636,
1557
+ 989,
1558
+ 990,
1559
+ 993,
1560
+ 995,
1561
+ 1719,
1562
+ 1720,
1563
+ 1723,
1564
+ 2049,
1565
+ 3659,
1566
+ 4045,
1567
+ 5060,
1568
+ 5061,
1569
+ 6e3,
1570
+ 6566,
1571
+ 6665,
1572
+ 6666,
1573
+ 6667,
1574
+ 6668,
1575
+ 6669,
1576
+ 6697,
1577
+ 10080
1578
+ ]);
1579
+ function isUnsafePort(port) {
1580
+ return unsafePorts.has(port);
1581
+ }
1582
+ function isSafePort(port) {
1583
+ return !isUnsafePort(port);
1584
+ }
1585
+ var GetPortError = class extends Error {
1586
+ constructor(message, opts) {
1587
+ super(message, opts);
1588
+ this.message = message;
1589
+ }
1590
+ name = "GetPortError";
1591
+ };
1592
+ function _log(verbose, message) {
1593
+ if (verbose) console.log(`[get-port] ${message}`);
1594
+ }
1595
+ function _generateRange(from, to) {
1596
+ if (to < from) return [];
1597
+ const r = [];
1598
+ for (let index = from; index <= to; index++) r.push(index);
1599
+ return r;
1600
+ }
1601
+ function _tryPort(port, host) {
1602
+ return new Promise((resolve) => {
1603
+ const server = createServer();
1604
+ server.unref();
1605
+ server.on("error", () => {
1606
+ resolve(false);
1607
+ });
1608
+ server.listen({
1609
+ port,
1610
+ host
1611
+ }, () => {
1612
+ const { port: port2 } = server.address();
1613
+ server.close(() => {
1614
+ resolve(isSafePort(port2) && port2);
1615
+ });
1616
+ });
1617
+ });
1618
+ }
1619
+ function _getLocalHosts(additional) {
1620
+ const hosts = new Set(additional);
1621
+ for (const _interface of Object.values(networkInterfaces())) for (const config of _interface || []) if (config.address && !config.internal && !config.address.startsWith("fe80::") && !config.address.startsWith("169.254")) hosts.add(config.address);
1622
+ return [...hosts];
1623
+ }
1624
+ async function _findPort(ports, host) {
1625
+ for (const port of ports) {
1626
+ const r = await _tryPort(port, host);
1627
+ if (r) return r;
1628
+ }
1629
+ }
1630
+ function _fmtOnHost(hostname) {
1631
+ return hostname ? `on host ${JSON.stringify(hostname)}` : "on any host";
1632
+ }
1633
+ const HOSTNAME_RE = /^(?!-)[\d.:A-Za-z-]{1,63}(?<!-)$/;
1634
+ function _validateHostname(hostname, _public, verbose) {
1635
+ if (hostname && !HOSTNAME_RE.test(hostname)) {
1636
+ const fallbackHost = _public ? "0.0.0.0" : "127.0.0.1";
1637
+ _log(verbose, `Invalid hostname: ${JSON.stringify(hostname)}. Using ${JSON.stringify(fallbackHost)} as fallback.`);
1638
+ return fallbackHost;
1639
+ }
1640
+ return hostname;
1641
+ }
1642
+ async function getPort(_userOptions = {}) {
1643
+ if (typeof _userOptions === "number" || typeof _userOptions === "string") _userOptions = { port: Number.parseInt(_userOptions + "") || 0 };
1644
+ const _port = Number(_userOptions.port ?? process.env.PORT);
1645
+ const _userSpecifiedAnyPort = Boolean(_userOptions.port || _userOptions.ports?.length || _userOptions.portRange?.length);
1646
+ const options = {
1647
+ random: _port === 0,
1648
+ ports: [],
1649
+ portRange: [],
1650
+ alternativePortRange: _userSpecifiedAnyPort ? [] : [3e3, 3100],
1651
+ verbose: false,
1652
+ ..._userOptions,
1653
+ port: _port,
1654
+ host: _validateHostname(_userOptions.host ?? process.env.HOST, _userOptions.public, _userOptions.verbose)
1655
+ };
1656
+ if (options.random && !_userSpecifiedAnyPort) return getRandomPort(options.host);
1657
+ const portsToCheck = [
1658
+ options.port,
1659
+ ...options.ports,
1660
+ ..._generateRange(...options.portRange)
1661
+ ].filter((port) => {
1662
+ if (!port) return false;
1663
+ if (!isSafePort(port)) {
1664
+ _log(options.verbose, `Ignoring unsafe port: ${port}`);
1665
+ return false;
1666
+ }
1667
+ return true;
1668
+ });
1669
+ if (portsToCheck.length === 0) portsToCheck.push(3e3);
1670
+ let availablePort = await _findPort(portsToCheck, options.host);
1671
+ if (!availablePort && options.alternativePortRange.length > 0) {
1672
+ availablePort = await _findPort(_generateRange(...options.alternativePortRange), options.host);
1673
+ if (portsToCheck.length > 0) {
1674
+ let message = `Unable to find an available port (tried ${portsToCheck.join("-")} ${_fmtOnHost(options.host)}).`;
1675
+ if (availablePort) message += ` Using alternative port ${availablePort}.`;
1676
+ _log(options.verbose, message);
1677
+ }
1678
+ }
1679
+ if (!availablePort && _userOptions.random !== false) {
1680
+ availablePort = await getRandomPort(options.host);
1681
+ if (availablePort) _log(options.verbose, `Using random port ${availablePort}`);
1682
+ }
1683
+ if (!availablePort) {
1684
+ const triedRanges = [
1685
+ options.port,
1686
+ options.portRange.join("-"),
1687
+ options.alternativePortRange.join("-")
1688
+ ].filter(Boolean).join(", ");
1689
+ throw new GetPortError(`Unable to find an available port ${_fmtOnHost(options.host)} (tried ${triedRanges})`);
1690
+ }
1691
+ return availablePort;
1692
+ }
1693
+ async function getRandomPort(host) {
1694
+ const port = await checkPort(0, host);
1695
+ if (port === false) throw new GetPortError(`Unable to find a random port ${_fmtOnHost(host)}`);
1696
+ return port;
1697
+ }
1698
+ async function checkPort(port, host = process.env.HOST, verbose) {
1699
+ if (!host) host = _getLocalHosts([void 0, "0.0.0.0"]);
1700
+ if (!Array.isArray(host)) return _tryPort(port, host);
1701
+ for (const _host of host) {
1702
+ const _port = await _tryPort(port, _host);
1703
+ if (_port === false) {
1704
+ if (port < 1024 && verbose) _log(verbose, `Unable to listen to the privileged port ${port} ${_fmtOnHost(_host)}`);
1705
+ return false;
1706
+ }
1707
+ if (port === 0 && _port !== 0) port = _port;
1708
+ }
1709
+ return port;
1710
+ }
1711
+ ansis_default.green("✔");
1712
+ const MARK_INFO = ansis_default.blue("ℹ");
1713
+ ansis_default.red("✖");
1714
+ //#endregion
1715
+ //#region src/node/ws.ts
1716
+ const debugInvoked = createDebug("vite:devtools:rpc:invoked");
1717
+ const ANONYMOUS_SCOPE = "vite:anonymous:";
1718
+ async function createWsServer(options) {
1719
+ const rpcHost = options.context.rpc;
1720
+ const host = options.hostWebSocket ?? "localhost";
1721
+ const https = options.context.viteConfig.server.https;
1722
+ const port = options.portWebSocket ?? await getPort({
1723
+ port: 7812,
1724
+ host,
1725
+ random: true
1726
+ });
1727
+ const wsClients = /* @__PURE__ */ new Set();
1728
+ const context = options.context;
1729
+ const contextInternal = getInternalContext(context);
1730
+ const isClientAuthDisabled = context.mode === "build" || context.viteConfig.devtools?.config?.clientAuth === false || process$1.env.VITE_DEVTOOLS_DISABLE_CLIENT_AUTH === "true";
1731
+ if (isClientAuthDisabled) console.warn("[Vite DevTools] Client authentication is disabled. Any browser can connect to the devtools and access to your server and filesystem.");
1732
+ const preset = createWsRpcPreset({
1733
+ port,
1734
+ host,
1735
+ https,
1736
+ onConnected: (ws, req, meta) => {
1737
+ const authId = new URL(req.url ?? "", "http://localhost").searchParams.get("vite_devtools_auth_id") ?? void 0;
1738
+ if (isClientAuthDisabled) meta.isTrusted = true;
1739
+ else if (authId && contextInternal.storage.auth.value().trusted[authId]) {
1740
+ meta.isTrusted = true;
1741
+ meta.clientAuthId = authId;
1742
+ }
1743
+ wsClients.add(ws);
1744
+ const color = meta.isTrusted ? ansis_default.green : ansis_default.yellow;
1745
+ console.log(color`${MARK_INFO} Websocket client connected. [${meta.id}] [${meta.clientAuthId}] (${meta.isTrusted ? "trusted" : "untrusted"})`);
1746
+ },
1747
+ onDisconnected: (ws, meta) => {
1748
+ wsClients.delete(ws);
1749
+ console.log(ansis_default.red`${MARK_INFO} Websocket client disconnected. [${meta.id}]`);
1750
+ }
1751
+ });
1752
+ const asyncStorage = new AsyncLocalStorage();
1753
+ const rpcGroup = createRpcServer(rpcHost.functions, {
1754
+ preset,
1755
+ rpcOptions: {
1756
+ onFunctionError(error, name) {
1757
+ console.error(ansis_default.red`⬢ RPC error on executing "${ansis_default.bold(name)}":`);
1758
+ console.error(error);
1759
+ },
1760
+ onGeneralError(error) {
1761
+ console.error(ansis_default.red`⬢ RPC error on executing rpc`);
1762
+ console.error(error);
1763
+ },
1764
+ resolver(name, fn) {
1765
+ const rpc = this;
1766
+ if (!name.startsWith(ANONYMOUS_SCOPE) && !rpc.$meta.isTrusted) return () => {
1767
+ throw new Error(`Unauthorized access to method ${JSON.stringify(name)} from client [${rpc.$meta.id}]`);
1768
+ };
1769
+ if (!fn) return void 0;
1770
+ return async function(...args) {
1771
+ debugInvoked(`${JSON.stringify(name)} from #${rpc.$meta.id}`);
1772
+ return await asyncStorage.run({
1773
+ rpc,
1774
+ meta: rpc.$meta
1775
+ }, async () => {
1776
+ return (await fn).apply(this, args);
1777
+ });
1778
+ };
1779
+ }
1780
+ }
1781
+ });
1782
+ rpcHost._rpcGroup = rpcGroup;
1783
+ rpcHost._asyncStorage = asyncStorage;
1784
+ const getConnectionMeta = async () => {
1785
+ return {
1786
+ backend: "websocket",
1787
+ websocket: port
1788
+ };
1789
+ };
1790
+ return {
1791
+ port,
1792
+ rpc: rpcGroup,
1793
+ rpcHost,
1794
+ getConnectionMeta
1795
+ };
1796
+ }
1797
+ //#endregion
1798
+ //#region src/node/server.ts
1799
+ async function createDevToolsMiddleware(options) {
1800
+ const h3 = createApp();
1801
+ const { rpc, getConnectionMeta } = await createWsServer(options);
1802
+ h3.use("/.vdt-connection.json", eventHandler(async (event) => {
1803
+ event.node.res.setHeader("Content-Type", "application/json");
1804
+ return event.node.res.end(JSON.stringify(await getConnectionMeta()));
1805
+ }));
1806
+ h3.use(fromNodeMiddleware(sirv(dirClientStandalone, {
1807
+ dev: true,
1808
+ single: true
1809
+ })));
1810
+ return {
1811
+ h3,
1812
+ rpc,
1813
+ middleware: toNodeListener(h3),
1814
+ getConnectionMeta
1815
+ };
1816
+ }
1817
+ //#endregion
1818
+ //#region src/node/plugins/server.ts
1819
+ /**
1820
+ * Core plugin for enabling Vite DevTools
1821
+ */
1822
+ function DevToolsServer() {
1823
+ let context;
1824
+ return {
1825
+ name: "vite:devtools:server",
1826
+ enforce: "post",
1827
+ apply: "serve",
1828
+ async configureServer(viteDevServer) {
1829
+ context = await createDevToolsContext(viteDevServer.config, viteDevServer);
1830
+ const host = viteDevServer.config.server.host === true ? "0.0.0.0" : viteDevServer.config.server.host || "localhost";
1831
+ const { middleware } = await createDevToolsMiddleware({
1832
+ cwd: viteDevServer.config.root,
1833
+ hostWebSocket: host,
1834
+ context
1835
+ });
1836
+ viteDevServer.middlewares.use("/.devtools/", middleware);
1837
+ },
1838
+ resolveId(id) {
1839
+ if (id === "/.devtools-imports") return id;
1840
+ },
1841
+ load(id) {
1842
+ if (id === "/.devtools-imports") {
1843
+ if (!context) throw new Error("DevTools context is not initialized");
1844
+ const docks = Array.from(context.docks.values());
1845
+ const map = /* @__PURE__ */ new Map();
1846
+ for (const dock of docks) {
1847
+ const id = `${dock.type}:${dock.id}`;
1848
+ if (dock.type === "action") map.set(id, dock.action);
1849
+ else if (dock.type === "custom-render") map.set(id, dock.renderer);
1850
+ else if (dock.type === "iframe" && dock.clientScript) map.set(id, dock.clientScript);
1851
+ }
1852
+ return [
1853
+ `export const importsMap = {`,
1854
+ ...[...map.entries()].filter(([, entry]) => entry != null).map(([id, { importFrom, importName }]) => ` [${JSON.stringify(id)}]: () => import(${JSON.stringify(importFrom)}).then(r => r[${JSON.stringify(importName)}]),`),
1855
+ "}"
1856
+ ].join("\n");
1857
+ }
1858
+ }
1859
+ };
1860
+ }
1861
+ //#endregion
1862
+ //#region src/node/plugins/index.ts
1863
+ async function DevTools(options = {}) {
1864
+ const { builtinDevTools = true } = options;
1865
+ const plugins = [DevToolsInjection(), DevToolsServer()];
1866
+ if (builtinDevTools) plugins.push(await import("@vitejs/devtools-rolldown").then((m) => m.DevToolsRolldownUI()));
1867
+ return plugins;
1868
+ }
1869
+ //#endregion
1870
+ export { ansis_default as a, createDevToolsContext as i, createDevToolsMiddleware as n, getPort as r, DevTools as t };