citadel_cli 1.4.1 → 1.4.2

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.
@@ -1,11 +1,11 @@
1
- var Ie = Object.defineProperty;
2
- var Pe = (t, e, n) => e in t ? Ie(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var y = (t, e, n) => Pe(t, typeof e != "symbol" ? e + "" : e, n);
4
- import { jsx as m, jsxs as A, Fragment as He } from "react/jsx-runtime";
5
- import $, { createContext as Re, useState as _, useMemo as P, useEffect as I, useContext as Z, useCallback as f, useReducer as _e, useRef as T, useLayoutEffect as Me } from "react";
6
- import { createRoot as Te } from "react-dom/client";
7
- var V = /* @__PURE__ */ ((t) => (t.Pending = "pending", t.Success = "success", t.Failure = "failure", t.Timeout = "timeout", t))(V || {});
8
- class K {
1
+ var Te = Object.defineProperty;
2
+ var Me = (n, e, t) => e in n ? Te(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var y = (n, e, t) => Me(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { jsx as m, jsxs as A, Fragment as Oe } from "react/jsx-runtime";
5
+ import K, { createContext as De, useState as M, useMemo as _, useEffect as I, useContext as re, useCallback as f, useReducer as ze, useRef as R, useLayoutEffect as Fe } from "react";
6
+ import { createRoot as Le } from "react-dom/client";
7
+ var Y = /* @__PURE__ */ ((n) => (n.Pending = "pending", n.Success = "success", n.Failure = "failure", n.Timeout = "timeout", n))(Y || {});
8
+ class W {
9
9
  constructor(e = Date.now()) {
10
10
  y(this, "_status", "pending");
11
11
  this.timestamp = e;
@@ -23,46 +23,46 @@ class K {
23
23
  this._status = "timeout";
24
24
  }
25
25
  }
26
- class ze extends K {
27
- constructor(e, n) {
28
- super(n), this.data = e;
26
+ class Ue extends W {
27
+ constructor(e, t) {
28
+ super(t), this.data = e;
29
29
  }
30
30
  render() {
31
31
  return /* @__PURE__ */ m("pre", { className: "citadel-result-json", children: JSON.stringify(this.data, null, 2) });
32
32
  }
33
33
  }
34
- class G extends K {
35
- constructor(e, n) {
36
- super(n), this.text = e;
34
+ class ee extends W {
35
+ constructor(e, t) {
36
+ super(t), this.text = e;
37
37
  }
38
38
  render() {
39
39
  return /* @__PURE__ */ m("div", { className: "citadel-result-text", children: this.text });
40
40
  }
41
41
  }
42
- class De extends K {
43
- constructor(e, n = "true", s = "false", r) {
44
- super(r), this.value = e, this.trueText = n, this.falseText = s;
42
+ class $e extends W {
43
+ constructor(e, t = "true", r = "false", s) {
44
+ super(s), this.value = e, this.trueText = t, this.falseText = r;
45
45
  }
46
46
  render() {
47
47
  return /* @__PURE__ */ m("div", { className: "citadel-result-text citadel-result-boolean", children: this.value ? this.trueText : this.falseText });
48
48
  }
49
49
  }
50
- class we extends K {
51
- constructor(e, n) {
52
- super(n), this.error = e, this.markFailure();
50
+ class be extends W {
51
+ constructor(e, t) {
52
+ super(t), this.error = e, this.markFailure();
53
53
  }
54
54
  render() {
55
55
  return /* @__PURE__ */ m("div", { className: "citadel-result-error", children: this.error });
56
56
  }
57
57
  }
58
- class Oe extends K {
58
+ class je extends W {
59
59
  render() {
60
60
  return /* @__PURE__ */ m("div", { className: "citadel-result-pending", children: "..." });
61
61
  }
62
62
  }
63
- class Fe extends K {
64
- constructor(e, n = "", s) {
65
- super(s), this.imageUrl = e, this.altText = n;
63
+ class Ke extends W {
64
+ constructor(e, t = "", r) {
65
+ super(r), this.imageUrl = e, this.altText = t;
66
66
  }
67
67
  render() {
68
68
  return /* @__PURE__ */ m("div", { className: "citadel-result-image-wrap", children: /* @__PURE__ */ m(
@@ -75,36 +75,36 @@ class Fe extends K {
75
75
  ) });
76
76
  }
77
77
  }
78
- const Le = (t) => async function() {
79
- const n = t.commands.filter((s) => s.fullPath[0] !== "help").map((s) => {
80
- const o = `${s.segments.map((c) => c.type === "argument" ? `<${c.name}>` : c.name).join(" ")} - ${s.description}`, a = s.segments.filter((c) => c.type === "argument" && c.description).map((c) => ` <${c.name}>: ${c.description}`);
78
+ const We = (n) => async function() {
79
+ const t = n.commands.filter((r) => r.fullPath[0] !== "help").map((r) => {
80
+ const a = `${r.segments.map((c) => c.type === "argument" ? `<${c.name}>` : c.name).join(" ")} - ${r.description}`, o = r.segments.filter((c) => c.type === "argument" && c.description).map((c) => ` <${c.name}>: ${c.description}`);
81
81
  return {
82
- commandLine: o,
83
- argumentLines: a
82
+ commandLine: a,
83
+ argumentLines: o
84
84
  };
85
- }).sort((s, r) => s.commandLine.localeCompare(r.commandLine)).flatMap((s) => [
86
- s.commandLine,
87
- ...s.argumentLines
85
+ }).sort((r, s) => r.commandLine.localeCompare(s.commandLine)).flatMap((r) => [
86
+ r.commandLine,
87
+ ...r.argumentLines
88
88
  ]);
89
- return n.length === 0 ? new G(
89
+ return t.length === 0 ? new ee(
90
90
  "No commands available yet. Add some commands to get started!"
91
- ) : (n.push("help - Show available commands"), new G(
91
+ ) : (t.push("help - Show available commands"), new ee(
92
92
  `Available Commands:
93
- ` + n.join(`
93
+ ` + t.join(`
94
94
  `)
95
95
  ));
96
96
  };
97
- var ie = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.ERROR = 1] = "ERROR", t[t.WARN = 2] = "WARN", t[t.INFO = 3] = "INFO", t[t.DEBUG = 4] = "DEBUG", t[t.TRACE = 5] = "TRACE", t))(ie || {});
98
- const ue = !0;
99
- class b {
97
+ var me = /* @__PURE__ */ ((n) => (n[n.NONE = 0] = "NONE", n[n.ERROR = 1] = "ERROR", n[n.WARN = 2] = "WARN", n[n.INFO = 3] = "INFO", n[n.DEBUG = 4] = "DEBUG", n[n.TRACE = 5] = "TRACE", n))(me || {});
98
+ const fe = !0;
99
+ class k {
100
100
  static configure(e) {
101
101
  this.level = e.level, this.prefix = e.prefix || "[Citadel]";
102
102
  }
103
103
  static trace(...e) {
104
- this.level >= 5 && !ue && console.trace(this.prefix, ...e);
104
+ this.level >= 5 && !fe && console.trace(this.prefix, ...e);
105
105
  }
106
106
  static debug(...e) {
107
- this.level >= 4 && !ue && console.debug(this.prefix, ...e);
107
+ this.level >= 4 && !fe && console.debug(this.prefix, ...e);
108
108
  }
109
109
  static info(...e) {
110
110
  this.level >= 3 && console.info(this.prefix, ...e);
@@ -116,8 +116,8 @@ class b {
116
116
  this.level >= 1 && console.error(this.prefix, ...e);
117
117
  }
118
118
  }
119
- y(b, "level", 0), y(b, "prefix", "");
120
- const x = {
119
+ y(k, "level", 0), y(k, "prefix", "");
120
+ const E = {
121
121
  commandTimeoutMs: 1e4,
122
122
  cursorColor: "var(--cursor-color, #fff)",
123
123
  cursorSpeed: 530,
@@ -126,10 +126,11 @@ const x = {
126
126
  fontFamily: "monospace",
127
127
  fontSize: "0.875rem",
128
128
  initialHeight: "50vh",
129
- logLevel: ie.ERROR,
129
+ logLevel: me.ERROR,
130
130
  maxHeight: "80vh",
131
131
  minHeight: "200",
132
132
  outputFontSize: "0.875rem",
133
+ showOutputPane: !0,
133
134
  resetStateOnHide: !1,
134
135
  closeOnEscape: !0,
135
136
  showCitadelKey: ".",
@@ -139,35 +140,35 @@ const x = {
139
140
  type: "localStorage",
140
141
  maxCommands: 100
141
142
  }
142
- }, Ce = async () => new G("");
143
- class ce {
144
- constructor(e, n, s) {
145
- this.type = e, this.name = n, this.description = s;
143
+ }, Ee = async () => new ee("");
144
+ class ue {
145
+ constructor(e, t, r) {
146
+ this.type = e, this.name = t, this.description = r;
146
147
  }
147
148
  toString() {
148
149
  return this.name;
149
150
  }
150
151
  }
151
- class le extends ce {
152
+ class pe extends ue {
152
153
  constructor() {
153
154
  super("null", ">null<", "Empty segment");
154
155
  }
155
156
  }
156
- class ve extends ce {
157
- constructor(e, n) {
158
- super("word", e, n);
157
+ class ke extends ue {
158
+ constructor(e, t) {
159
+ super("word", e, t);
159
160
  }
160
161
  }
161
- class q extends ce {
162
- constructor(e, n, s, r) {
163
- super("argument", e, n), this.value = s, this.valid = r;
162
+ class q extends ue {
163
+ constructor(e, t, r, s) {
164
+ super("argument", e, t), this.value = r, this.valid = s;
164
165
  }
165
166
  }
166
- const je = (t) => {
167
- if (t.type === "word")
168
- return new ve(t.name, t.description);
169
- if (t.type === "argument") {
170
- const e = t;
167
+ const qe = (n) => {
168
+ if (n.type === "word")
169
+ return new ke(n.name, n.description);
170
+ if (n.type === "argument") {
171
+ const e = n;
171
172
  return new q(
172
173
  e.name,
173
174
  e.description,
@@ -175,15 +176,15 @@ const je = (t) => {
175
176
  e.valid
176
177
  );
177
178
  }
178
- return new le();
179
- }, z = (t) => t.map((e) => je(e));
180
- class Ue {
181
- constructor(e, n, s = Ce) {
179
+ return new pe();
180
+ }, L = (n) => n.map((e) => qe(e));
181
+ class Be {
182
+ constructor(e, t, r = Ee) {
182
183
  y(this, "_segments");
183
184
  y(this, "_description");
184
185
  // Used by `Help` command, etc.
185
186
  y(this, "_handler");
186
- this._segments = e, this._description = n, this._handler = s;
187
+ this._segments = e, this._description = t, this._handler = r;
187
188
  }
188
189
  get segments() {
189
190
  return this._segments;
@@ -207,7 +208,7 @@ class Ue {
207
208
  return this.fullPath.join(" ") === e.fullPath.join(" ");
208
209
  }
209
210
  }
210
- class ee {
211
+ class se {
211
212
  constructor() {
212
213
  y(this, "_commands", []);
213
214
  }
@@ -225,20 +226,20 @@ class ee {
225
226
  * @param handler Async handler executed when the command is submitted; defaults to `NoopHandler`.
226
227
  * @throws {Error} If the segment list is empty or the path collides with an existing command.
227
228
  */
228
- addCommand(e, n, s = Ce) {
229
+ addCommand(e, t, r = Ee) {
229
230
  if (e === void 0 || e.length === 0)
230
231
  throw new Error("Command path cannot be empty");
231
- const r = new Ue(e, n, s), o = this._commands.find((a) => {
232
- const c = a.segments.map(
232
+ const s = new Be(e, t, r), a = this._commands.find((o) => {
233
+ const c = o.segments.map(
233
234
  (d) => d.type === "argument" ? "*" : d.name
234
235
  ).join(" "), i = e.map(
235
236
  (d) => d.type === "argument" ? "*" : d.name
236
237
  ).join(" ");
237
238
  return c === i;
238
239
  });
239
- if (o)
240
- throw new Error(`Duplicate commands: '${o.fullPath_s}' and '${r.fullPath_s}'`);
241
- this._commands.push(r);
240
+ if (a)
241
+ throw new Error(`Duplicate commands: '${a.fullPath_s}' and '${s.fullPath_s}'`);
242
+ this._commands.push(s);
242
243
  }
243
244
  /**
244
245
  * Removes a command that exactly matches the provided path.
@@ -247,8 +248,8 @@ class ee {
247
248
  * @returns True if a command was removed; otherwise false.
248
249
  */
249
250
  removeCommand(e) {
250
- const n = e.join(" "), s = this._commands.findIndex((r) => r.fullPath.join(" ") === n);
251
- return s === -1 ? !1 : (this._commands.splice(s, 1), !0);
251
+ const t = e.join(" "), r = this._commands.findIndex((s) => s.fullPath.join(" ") === t);
252
+ return r === -1 ? !1 : (this._commands.splice(r, 1), !0);
252
253
  }
253
254
  /**
254
255
  * Retrieves a command from the registry for the given path.
@@ -257,26 +258,26 @@ class ee {
257
258
  * @returns The command node or undefined if not found.
258
259
  */
259
260
  getCommand(e) {
260
- return this._commands.find((n) => {
261
- const s = n.fullPath.join(" "), r = e.join(" ");
262
- if (s === r)
261
+ return this._commands.find((t) => {
262
+ const r = t.fullPath.join(" "), s = e.join(" ");
263
+ if (r === s)
263
264
  return !0;
264
- const a = n.segments.filter((c) => c.type === "word").map((c) => c.name);
265
- return a.length === e.length && a.join(" ") === r;
265
+ const o = t.segments.filter((c) => c.type === "word").map((c) => c.name);
266
+ return o.length === e.length && o.join(" ") === s;
266
267
  });
267
268
  }
268
269
  commandExistsForPath(e) {
269
- const n = this._commands.map(
270
- (r) => r.segments.map(
271
- (o) => o.type === "argument" ? "*" : o.name
270
+ const t = this._commands.map(
271
+ (s) => s.segments.map(
272
+ (a) => a.type === "argument" ? "*" : a.name
272
273
  ).join(" ")
273
- ), s = e.map((r, o) => this._commands.some(
274
+ ), r = e.map((s, a) => this._commands.some(
274
275
  (c) => {
275
276
  var i;
276
- return ((i = c.segments[o]) == null ? void 0 : i.type) === "argument";
277
+ return ((i = c.segments[a]) == null ? void 0 : i.type) === "argument";
277
278
  }
278
- ) ? "*" : r).join(" ");
279
- return n.includes(s);
279
+ ) ? "*" : s).join(" ");
280
+ return t.includes(r);
280
281
  }
281
282
  /**
282
283
  * Gets possible matches for a given path.
@@ -285,26 +286,26 @@ class ee {
285
286
  * @returns An array of completion strings.
286
287
  */
287
288
  getCompletionNames(e) {
288
- return this.getCompletions(e).map((n) => n.name);
289
+ return this.getCompletions(e).map((t) => t.name);
289
290
  }
290
291
  /**
291
292
  * Returns completion segments whose names start with the given prefix.
292
293
  * Matching is case-insensitive.
293
294
  */
294
- getMatchingCompletions(e, n) {
295
- const s = n.trim().toLowerCase(), r = this.getCompletions(e);
296
- return s ? r.filter(
297
- (o) => o.name.toLowerCase().startsWith(s)
298
- ) : r;
295
+ getMatchingCompletions(e, t) {
296
+ const r = t.trim().toLowerCase(), s = this.getCompletions(e);
297
+ return r ? s.filter(
298
+ (a) => a.name.toLowerCase().startsWith(r)
299
+ ) : s;
299
300
  }
300
301
  /**
301
302
  * Returns a single completion when prefix matching is unambiguous.
302
303
  * Returns undefined for ambiguous or no-match prefixes.
303
304
  */
304
- getUniqueCompletion(e, n) {
305
- const s = this.getMatchingCompletions(e, n);
306
- if (s.length === 1)
307
- return s[0];
305
+ getUniqueCompletion(e, t) {
306
+ const r = this.getMatchingCompletions(e, t);
307
+ if (r.length === 1)
308
+ return r[0];
308
309
  }
309
310
  /**
310
311
  * Gets an array of segments reachable from a given path
@@ -313,29 +314,29 @@ class ee {
313
314
  * @returns An array of completion strings.
314
315
  */
315
316
  getCompletions(e) {
316
- if (b.debug("[getCompletions] path: ", e), !e.length) {
317
- const o = this._commands.map((i) => i.segments[0]), a = (i, d) => i.type === d.type && i.name === d.name;
318
- return o.filter(
319
- (i, d, g) => d === g.findIndex((u) => a(u, i))
317
+ if (k.debug("[getCompletions] path: ", e), !e.length) {
318
+ const a = this._commands.map((i) => i.segments[0]), o = (i, d) => i.type === d.type && i.name === d.name;
319
+ return a.filter(
320
+ (i, d, h) => d === h.findIndex((u) => o(u, i))
320
321
  );
321
322
  }
322
- const n = e.length;
323
- return this._commands.filter((o) => {
324
- const a = o.segments;
325
- if (a.length <= n - 1)
323
+ const t = e.length;
324
+ return this._commands.filter((a) => {
325
+ const o = a.segments;
326
+ if (o.length <= t - 1)
326
327
  return !1;
327
- for (let c = 0; c < n; c++) {
328
- const i = e[c], d = a[c];
328
+ for (let c = 0; c < t; c++) {
329
+ const i = e[c], d = o[c];
329
330
  if (!(i === "*" && d.type === "argument") && i !== d.name)
330
331
  return !1;
331
332
  }
332
333
  return !0;
333
- }).filter((o) => o.segments.length > n).map((o) => {
334
- const a = o.segments[n], c = a.type === "argument" ? q : ve;
335
- return new c(a.name, a.description);
334
+ }).filter((a) => a.segments.length > t).map((a) => {
335
+ const o = a.segments[t], c = o.type === "argument" ? q : ke;
336
+ return new c(o.name, o.description);
336
337
  }).filter(
337
- (o, a, c) => a === c.findIndex(
338
- (i) => i.type === o.type && i.name === o.name
338
+ (a, o, c) => o === c.findIndex(
339
+ (i) => i.type === a.type && i.name === a.name
339
340
  )
340
341
  );
341
342
  }
@@ -343,7 +344,7 @@ class ee {
343
344
  return this.getCompletions(e).length > 0;
344
345
  }
345
346
  }
346
- class Se {
347
+ class Ne {
347
348
  constructor(e) {
348
349
  y(this, "config");
349
350
  this.config = {
@@ -356,88 +357,88 @@ class Se {
356
357
  * Add a command to history, enforcing storage limits
357
358
  */
358
359
  async addStoredCommand(e) {
359
- const n = await this.getStoredCommands();
360
- for (n.push(e); n.length > this.config.maxCommands; )
361
- n.shift();
362
- await this.saveCommands(n);
360
+ const t = await this.getStoredCommands();
361
+ for (t.push(e); t.length > this.config.maxCommands; )
362
+ t.shift();
363
+ await this.saveCommands(t);
363
364
  }
364
365
  }
365
- class $e extends Se {
366
- constructor(n) {
367
- super(n);
366
+ class Ve extends Ne {
367
+ constructor(t) {
368
+ super(t);
368
369
  y(this, "storageKey", "citadel_command_history");
369
370
  }
370
371
  async getStoredCommands() {
371
372
  try {
372
- const n = window.localStorage.getItem(this.storageKey);
373
- return n ? JSON.parse(n).map((r) => ({
374
- commandSegments: Array.isArray(r.commandSegments) ? z(r.commandSegments) : [],
375
- timestamp: r.timestamp
373
+ const t = window.localStorage.getItem(this.storageKey);
374
+ return t ? JSON.parse(t).map((s) => ({
375
+ commandSegments: Array.isArray(s.commandSegments) ? L(s.commandSegments) : [],
376
+ timestamp: s.timestamp
376
377
  })) : [];
377
- } catch (n) {
378
- return console.warn("Failed to load commands from localStorage:", n), [];
378
+ } catch (t) {
379
+ return console.warn("Failed to load commands from localStorage:", t), [];
379
380
  }
380
381
  }
381
382
  async clear() {
382
383
  try {
383
384
  window.localStorage.removeItem(this.storageKey);
384
- } catch (n) {
385
- console.warn("Failed to clear localStorage:", n);
385
+ } catch (t) {
386
+ console.warn("Failed to clear localStorage:", t);
386
387
  }
387
388
  }
388
- async saveCommands(n) {
389
+ async saveCommands(t) {
389
390
  try {
390
- const s = n.map((r) => ({
391
- commandSegments: Array.isArray(r.commandSegments) ? z(r.commandSegments).map((o) => ({
392
- type: o.type,
393
- name: o.name,
394
- description: o.description,
395
- ...o instanceof q ? { value: o.value } : {}
391
+ const r = t.map((s) => ({
392
+ commandSegments: Array.isArray(s.commandSegments) ? L(s.commandSegments).map((a) => ({
393
+ type: a.type,
394
+ name: a.name,
395
+ description: a.description,
396
+ ...a instanceof q ? { value: a.value } : {}
396
397
  })) : [],
397
- timestamp: r.timestamp
398
+ timestamp: s.timestamp
398
399
  }));
399
- window.localStorage.setItem(this.storageKey, JSON.stringify(s));
400
- } catch (s) {
401
- throw console.warn("Failed to save commands to localStorage:", s), s;
400
+ window.localStorage.setItem(this.storageKey, JSON.stringify(r));
401
+ } catch (r) {
402
+ throw console.warn("Failed to save commands to localStorage:", r), r;
402
403
  }
403
404
  }
404
405
  }
405
- class pe extends Se {
406
- constructor(n) {
407
- super(n);
406
+ class ye extends Ne {
407
+ constructor(t) {
408
+ super(t);
408
409
  y(this, "storedCommands", []);
409
410
  }
410
411
  async getStoredCommands() {
411
- return this.storedCommands.map((n) => ({
412
- commandSegments: Array.isArray(n.commandSegments) ? z(n.commandSegments) : [],
413
- timestamp: n.timestamp
412
+ return this.storedCommands.map((t) => ({
413
+ commandSegments: Array.isArray(t.commandSegments) ? L(t.commandSegments) : [],
414
+ timestamp: t.timestamp
414
415
  }));
415
416
  }
416
417
  async clear() {
417
418
  this.storedCommands = [];
418
419
  }
419
- async saveCommands(n) {
420
- this.storedCommands = n.map((s) => ({
421
- commandSegments: Array.isArray(s.commandSegments) ? z(s.commandSegments) : [],
422
- timestamp: s.timestamp
420
+ async saveCommands(t) {
421
+ this.storedCommands = t.map((r) => ({
422
+ commandSegments: Array.isArray(r.commandSegments) ? L(r.commandSegments) : [],
423
+ timestamp: r.timestamp
423
424
  }));
424
425
  }
425
426
  }
426
- const j = class j {
427
+ const $ = class $ {
427
428
  constructor() {
428
429
  y(this, "currentStorage");
429
430
  }
430
431
  static reset() {
431
- j.instance = void 0;
432
+ $.instance = void 0;
432
433
  }
433
434
  static getInstance() {
434
- return j.instance || (j.instance = new j()), j.instance;
435
+ return $.instance || ($.instance = new $()), $.instance;
435
436
  }
436
437
  initializeStorage(e) {
437
438
  try {
438
- e.type === "memory" ? this.currentStorage = new pe(e) : this.currentStorage = new $e(e);
439
- } catch (n) {
440
- console.warn("Failed to create storage, falling back to memory storage:", n), this.currentStorage = new pe(e);
439
+ e.type === "memory" ? this.currentStorage = new ye(e) : this.currentStorage = new Ve(e);
440
+ } catch (t) {
441
+ console.warn("Failed to create storage, falling back to memory storage:", t), this.currentStorage = new ye(e);
441
442
  }
442
443
  }
443
444
  getStorage() {
@@ -446,19 +447,19 @@ const j = class j {
446
447
  return this.currentStorage;
447
448
  }
448
449
  };
449
- y(j, "instance");
450
- let Q = j;
451
- class xe {
450
+ y($, "instance");
451
+ let te = $;
452
+ class Ie {
452
453
  constructor() {
453
454
  y(this, "segments", []);
454
- y(this, "nullSegment", new le());
455
+ y(this, "nullSegment", new pe());
455
456
  y(this, "observers", []);
456
457
  }
457
458
  subscribe(e) {
458
459
  this.observers.push(e);
459
460
  }
460
461
  unsubscribe(e) {
461
- this.observers = this.observers.filter((n) => n !== e);
462
+ this.observers = this.observers.filter((t) => t !== e);
462
463
  }
463
464
  notifyObservers() {
464
465
  this.observers.forEach((e) => e.update());
@@ -479,7 +480,7 @@ class xe {
479
480
  * Pushes an array of segments onto the stack
480
481
  */
481
482
  pushAll(e) {
482
- e.forEach((n) => this.push(n));
483
+ e.forEach((t) => this.push(t));
483
484
  }
484
485
  /**
485
486
  * Removes and returns the top segment from the stack
@@ -535,36 +536,36 @@ class xe {
535
536
  return [...this.segments];
536
537
  }
537
538
  }
538
- const Ke = {
539
- config: x,
540
- commands: new ee(),
541
- segmentStack: new xe()
542
- }, Y = Re(Ke), We = ({ config: t = x, commandRegistry: e, children: n }) => {
543
- const [s, r] = $.useState(), [o] = _(() => new xe()), a = P(() => ({
544
- ...x,
545
- ...t,
539
+ const Ge = {
540
+ config: E,
541
+ commands: new se(),
542
+ segmentStack: new Ie()
543
+ }, J = De(Ge), Ye = ({ config: n = E, commandRegistry: e, children: t }) => {
544
+ const [r, s] = K.useState(), [a] = M(() => new Ie()), o = _(() => ({
545
+ ...E,
546
+ ...n,
546
547
  // Ensure nested objects are properly merged
547
548
  storage: {
548
- ...x.storage,
549
- ...t.storage
549
+ ...E.storage,
550
+ ...n.storage
550
551
  },
551
552
  // Ensure explicit values from config take precedence
552
- cursorType: t.cursorType ?? x.cursorType,
553
- cursorColor: t.cursorColor ?? x.cursorColor,
554
- cursorSpeed: t.cursorSpeed ?? x.cursorSpeed,
555
- closeOnEscape: t.closeOnEscape ?? x.closeOnEscape,
556
- showCitadelKey: t.showCitadelKey ?? x.showCitadelKey,
557
- showOnLoad: t.showOnLoad ?? x.showOnLoad
558
- }), [t]);
553
+ cursorType: n.cursorType ?? E.cursorType,
554
+ cursorColor: n.cursorColor ?? E.cursorColor,
555
+ cursorSpeed: n.cursorSpeed ?? E.cursorSpeed,
556
+ closeOnEscape: n.closeOnEscape ?? E.closeOnEscape,
557
+ showCitadelKey: n.showCitadelKey ?? E.showCitadelKey,
558
+ showOnLoad: n.showOnLoad ?? E.showOnLoad
559
+ }), [n]);
559
560
  I(() => {
560
- Q.getInstance().initializeStorage(
561
- a.storage ?? x.storage
562
- ), r(Q.getInstance().getStorage());
563
- }, [a.storage]), I(() => {
561
+ te.getInstance().initializeStorage(
562
+ o.storage ?? E.storage
563
+ ), s(te.getInstance().getStorage());
564
+ }, [o.storage]), I(() => {
564
565
  if (e) {
565
- if (a.includeHelpCommand) {
566
+ if (o.includeHelpCommand) {
566
567
  if (!e.commandExistsForPath(["help"])) {
567
- const i = Le(e);
568
+ const i = We(e);
568
569
  e.addCommand(
569
570
  [{ type: "word", name: "help" }],
570
571
  "Show available commands",
@@ -575,105 +576,105 @@ const Ke = {
575
576
  }
576
577
  e.removeCommand(["help"]);
577
578
  }
578
- }, [e, a.includeHelpCommand]);
579
- const c = P(() => ({
580
- config: a,
581
- commands: e || new ee(),
582
- storage: s,
583
- segmentStack: o
584
- }), [a, e, s, o]);
585
- return /* @__PURE__ */ m(Y.Provider, { value: c, children: n });
586
- }, U = () => {
587
- const t = Z(Y);
588
- if (t === void 0)
579
+ }, [e, o.includeHelpCommand]);
580
+ const c = _(() => ({
581
+ config: o,
582
+ commands: e || new se(),
583
+ storage: r,
584
+ segmentStack: a
585
+ }), [o, e, r, a]);
586
+ return /* @__PURE__ */ m(J.Provider, { value: c, children: t });
587
+ }, j = () => {
588
+ const n = re(J);
589
+ if (n === void 0)
589
590
  throw new Error("useCitadelConfig must be used within a CitadelConfigProvider");
590
- return t.config;
591
- }, te = () => {
592
- const t = Z(Y);
593
- if (t === void 0)
591
+ return n.config;
592
+ }, oe = () => {
593
+ const n = re(J);
594
+ if (n === void 0)
594
595
  throw new Error("useCitadelCommands must be used within a CitadelConfigProvider");
595
- return t.commands;
596
- }, be = () => {
597
- const t = Z(Y);
598
- if (t === void 0)
596
+ return n.commands;
597
+ }, Ae = () => {
598
+ const n = re(J);
599
+ if (n === void 0)
599
600
  throw new Error("useCitadelStorage must be used within a CitadelConfigProvider");
600
- return t.storage;
601
- }, J = () => {
602
- const t = Z(Y);
603
- if (t === void 0)
601
+ return n.storage;
602
+ }, X = () => {
603
+ const n = re(J);
604
+ if (n === void 0)
604
605
  throw new Error("useSegmentStack must be used within a CitadelConfigProvider");
605
- return t.segmentStack;
606
- }, X = class X {
607
- constructor(e, n) {
606
+ return n.segmentStack;
607
+ }, ne = class ne {
608
+ constructor(e, t) {
608
609
  y(this, "id");
609
610
  y(this, "timestamp");
610
611
  y(this, "command");
611
612
  y(this, "result");
612
- this.id = `output-${Date.now()}-${X.idCounter++}`, this.command = e.toArray().map((s) => s.type === "argument" ? s.value || "" : s.name), this.timestamp = Date.now(), this.result = n ?? new Oe();
613
+ this.id = `output-${Date.now()}-${ne.idCounter++}`, this.command = e.toArray().map((r) => r.type === "argument" ? r.value || "" : r.name), this.timestamp = Date.now(), this.result = t ?? new je();
613
614
  }
614
615
  };
615
- y(X, "idCounter", 0);
616
- let oe = X;
617
- function qe(t) {
616
+ y(ne, "idCounter", 0);
617
+ let de = ne;
618
+ function Je(n) {
618
619
  return {
619
- commandSegments: z(t),
620
+ commandSegments: L(n),
620
621
  timestamp: Date.now()
621
622
  };
622
623
  }
623
- function ke() {
624
- const t = be(), [e, n] = _({
624
+ function Pe() {
625
+ const n = Ae(), [e, t] = M({
625
626
  storedCommands: [],
626
627
  position: null
627
- }), s = f(async (c) => {
628
- if (t)
628
+ }), r = f(async (c) => {
629
+ if (n)
629
630
  try {
630
- const i = qe(c);
631
- await t.addStoredCommand(i), n((d) => ({
631
+ const i = Je(c);
632
+ await n.addStoredCommand(i), t((d) => ({
632
633
  ...d,
633
634
  storedCommands: [...d.storedCommands, {
634
635
  ...i,
635
- commandSegments: z(i.commandSegments)
636
+ commandSegments: L(i.commandSegments)
636
637
  }],
637
638
  position: null
638
639
  }));
639
640
  } catch (i) {
640
641
  console.warn("Failed to save command to history:", i);
641
642
  }
642
- }, [t]), r = f(async () => t ? (await t.getStoredCommands()).map((i) => ({
643
+ }, [n]), s = f(async () => n ? (await n.getStoredCommands()).map((i) => ({
643
644
  ...i,
644
- commandSegments: z(i.commandSegments)
645
- })) : [], [t]);
645
+ commandSegments: L(i.commandSegments)
646
+ })) : [], [n]);
646
647
  I(() => {
647
- if (!t) return;
648
+ if (!n) return;
648
649
  (async () => {
649
650
  try {
650
- const d = (await t.getStoredCommands()).map((g) => ({
651
- ...g,
652
- commandSegments: z(g.commandSegments)
651
+ const d = (await n.getStoredCommands()).map((h) => ({
652
+ ...h,
653
+ commandSegments: L(h.commandSegments)
653
654
  }));
654
- return n((g) => ({
655
- ...g,
655
+ return t((h) => ({
656
+ ...h,
656
657
  storedCommands: d
657
658
  })), d;
658
659
  } catch (i) {
659
660
  console.warn("Failed to load command history:", i);
660
661
  }
661
662
  })();
662
- }, [t]);
663
- const o = f(async (c) => {
664
- const i = await r();
663
+ }, [n]);
664
+ const a = f(async (c) => {
665
+ const i = await s();
665
666
  if (i.length === 0)
666
- return n((u) => ({
667
+ return t((u) => ({
667
668
  ...u,
668
669
  storedCommands: [],
669
670
  position: null
670
671
  })), { segments: null, position: null };
671
672
  let d = null;
672
- if (c === "up" ? e.position === null ? d = i.length - 1 : e.position > 0 ? d = e.position - 1 : d = 0 : e.position === null || e.position >= i.length - 1 ? d = null : d = e.position + 1, n((u) => ({
673
+ if (c === "up" ? e.position === null ? d = i.length - 1 : e.position > 0 ? d = e.position - 1 : d = 0 : e.position === null || e.position >= i.length - 1 ? d = null : d = e.position + 1, t((u) => ({
673
674
  ...u,
674
- storedCommands: i.map((h) => ({
675
- ...h,
676
- commandSegments: z(h.commandSegments)
675
+ storedCommands: i.map((g) => ({
676
+ ...g,
677
+ commandSegments: L(g.commandSegments)
677
678
  })),
678
679
  position: d
679
680
  })), d === null)
@@ -681,198 +682,198 @@ function ke() {
681
682
  segments: [],
682
683
  position: null
683
684
  };
684
- const g = i[d];
685
- return g ? {
686
- segments: z(g.commandSegments),
685
+ const h = i[d];
686
+ return h ? {
687
+ segments: L(h.commandSegments),
687
688
  position: d
688
689
  } : {
689
690
  segments: [],
690
691
  position: null
691
692
  };
692
- }, [e.position, r]), a = f(async () => {
693
+ }, [e.position, s]), o = f(async () => {
693
694
  try {
694
- if (!t) return;
695
- await t.clear(), n({
695
+ if (!n) return;
696
+ await n.clear(), t({
696
697
  storedCommands: [],
697
698
  position: null
698
699
  });
699
700
  } catch (c) {
700
701
  console.warn("Failed to clear command history:", c);
701
702
  }
702
- }, [t]);
703
+ }, [n]);
703
704
  return {
704
705
  history: e,
705
- addStoredCommand: s,
706
- getStoredCommands: r,
707
- navigateHistory: o,
708
- clear: a
706
+ addStoredCommand: r,
707
+ getStoredCommands: s,
708
+ navigateHistory: a,
709
+ clear: o
709
710
  };
710
711
  }
711
- const de = () => {
712
- const t = U(), e = te(), n = ke(), s = J(), r = be(), [o, a] = _({
712
+ const he = () => {
713
+ const n = j(), e = oe(), t = Pe(), r = X(), s = Ae(), [a, o] = M({
713
714
  currentInput: "",
714
715
  isEnteringArg: !1,
715
716
  output: [],
716
717
  history: {
717
718
  commands: [],
718
719
  position: null,
719
- storage: r
720
+ storage: s
720
721
  }
721
722
  });
722
723
  I(() => {
723
- }, [r]), I(() => {
724
- a((i) => ({
724
+ }, [s]), I(() => {
725
+ o((i) => ({
725
726
  ...i,
726
727
  history: {
727
- commands: n.history.storedCommands,
728
- position: n.history.position,
729
- storage: r
728
+ commands: t.history.storedCommands,
729
+ position: t.history.position,
730
+ storage: s
730
731
  }
731
732
  }));
732
- }, [n.history, r]);
733
+ }, [t.history, s]);
733
734
  const c = {
734
735
  setCurrentInput: f((i) => {
735
- b.debug("[CitadelActions] setCurrentInput: ", i), a((d) => ({ ...d, currentInput: i }));
736
+ k.debug("[CitadelActions] setCurrentInput: ", i), o((d) => ({ ...d, currentInput: i }));
736
737
  }, []),
737
738
  setIsEnteringArg: f((i) => {
738
- b.debug("[CitadelActions] setIsEnteringArg: ", i), a((d) => ({ ...d, isEnteringArg: i }));
739
+ k.debug("[CitadelActions] setIsEnteringArg: ", i), o((d) => ({ ...d, isEnteringArg: i }));
739
740
  }, []),
740
741
  addOutput: f((i) => {
741
- b.debug("[CitadelActions]addOutput: ", i), a((d) => ({
742
+ k.debug("[CitadelActions]addOutput: ", i), o((d) => ({
742
743
  ...d,
743
744
  output: [...d.output, i]
744
745
  }));
745
746
  }, []),
746
747
  executeCommand: f(async () => {
747
- const i = s.path(), d = e.getCommand(i);
748
+ const i = r.path(), d = e.getCommand(i);
748
749
  if (!d) {
749
750
  console.error("[CitadelActions][executeCommand] Cannot execute command because no command was found for the given path: ", i);
750
751
  return;
751
752
  }
752
- const g = new oe(s);
753
- a((u) => ({
753
+ const h = new de(r);
754
+ o((u) => ({
754
755
  ...u,
755
- output: [...u.output, g]
756
+ output: [...u.output, h]
756
757
  }));
757
758
  try {
758
- const u = new Promise((C, k) => {
759
+ const u = new Promise((v, b) => {
759
760
  setTimeout(() => {
760
- k(new Error("Request timed out"));
761
- }, t.commandTimeoutMs);
762
- }), h = s.arguments.map((C) => C.value || ""), S = await Promise.race([
763
- d.handler(h),
761
+ b(new Error("Request timed out"));
762
+ }, n.commandTimeoutMs);
763
+ }), g = r.arguments.map((v) => v.value || ""), w = await Promise.race([
764
+ d.handler(g),
764
765
  u
765
766
  ]);
766
- if (!(S instanceof K))
767
+ if (!(w instanceof W))
767
768
  throw new Error(
768
769
  `The ${i.join(".")} command returned an invalid result type. Commands must return an instance of a CommandResult.
769
770
  For example:
770
771
  return new JsonCommandResult({ text: "Hello World" });
771
772
  Check the definition of the ${i.join(".")} command and update the return type for its handler.`
772
773
  );
773
- S.markSuccess(), a((C) => ({
774
- ...C,
775
- output: C.output.map(
776
- (k) => k.id === g.id ? { ...k, result: S } : k
774
+ w.markSuccess(), o((v) => ({
775
+ ...v,
776
+ output: v.output.map(
777
+ (b) => b.id === h.id ? { ...b, result: w } : b
777
778
  )
778
779
  }));
779
780
  } catch (u) {
780
- const h = new we(
781
+ const g = new be(
781
782
  u instanceof Error ? u.message : "Unknown error"
782
783
  );
783
- h.markFailure(), a((S) => ({
784
- ...S,
785
- output: S.output.map(
786
- (C) => C.id === g.id ? { ...C, result: h } : C
784
+ g.markFailure(), o((w) => ({
785
+ ...w,
786
+ output: w.output.map(
787
+ (v) => v.id === h.id ? { ...v, result: g } : v
787
788
  )
788
789
  }));
789
790
  }
790
- }, [e, t.commandTimeoutMs, s]),
791
+ }, [e, n.commandTimeoutMs, r]),
791
792
  clearHistory: f(async () => {
792
793
  try {
793
- await n.clear();
794
+ await t.clear();
794
795
  } catch (i) {
795
796
  console.warn("Failed to clear history:", i);
796
797
  }
797
- }, [n])
798
+ }, [t])
798
799
  };
799
- return { state: o, actions: c };
800
- }, Be = ({
801
- onOpen: t,
800
+ return { state: a, actions: c };
801
+ }, Xe = ({
802
+ onOpen: n,
802
803
  onClose: e,
803
- isVisible: n,
804
- showCitadelKey: s,
805
- closeOnEscape: r
804
+ isVisible: t,
805
+ showCitadelKey: r,
806
+ closeOnEscape: s
806
807
  }) => {
807
808
  I(() => {
808
- const o = (a) => {
809
+ const a = (o) => {
809
810
  var c, i;
810
- !n && a.key === s && !["input", "textarea"].includes(((i = (c = a.target) == null ? void 0 : c.tagName) == null ? void 0 : i.toLowerCase()) || "") && (a.preventDefault(), t()), r && n && a.key === "Escape" && (a.preventDefault(), e());
811
+ !t && o.key === r && !["input", "textarea"].includes(((i = (c = o.target) == null ? void 0 : c.tagName) == null ? void 0 : i.toLowerCase()) || "") && (o.preventDefault(), n()), s && t && o.key === "Escape" && (o.preventDefault(), e());
811
812
  };
812
- return document.addEventListener("keydown", o), () => document.removeEventListener("keydown", o);
813
- }, [t, e, n, s, r]);
814
- }, Ve = 200, Ye = (t) => {
815
- const { isVisible: e, isClosing: n, onAnimationComplete: s } = t, r = P(() => e ? n ? "citadel_slideDown" : "citadel_slideUp" : "", [e, n]);
813
+ return document.addEventListener("keydown", a), () => document.removeEventListener("keydown", a);
814
+ }, [n, e, t, r, s]);
815
+ }, Qe = 200, Ze = (n) => {
816
+ const { isVisible: e, isClosing: t, onAnimationComplete: r } = n, s = _(() => e ? t ? "citadel_slideDown" : "citadel_slideUp" : "", [e, t]);
816
817
  return I(() => {
817
- if (!n || !s) return;
818
+ if (!t || !r) return;
818
819
  if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
819
- s();
820
+ r();
820
821
  return;
821
822
  }
822
- const a = setTimeout(() => {
823
- s();
824
- }, Ve);
825
- return () => clearTimeout(a);
826
- }, [n, s]), {
827
- animationClass: r
823
+ const o = setTimeout(() => {
824
+ r();
825
+ }, Qe);
826
+ return () => clearTimeout(o);
827
+ }, [t, r]), {
828
+ animationClass: s
828
829
  };
829
- }, Je = () => /* @__PURE__ */ m(
830
+ }, et = () => /* @__PURE__ */ m(
830
831
  "div",
831
832
  {
832
833
  "data-testid": "spinner",
833
834
  className: "citadel-spinner"
834
835
  }
835
- ), Ee = (t) => {
836
- const e = t == null ? void 0 : t.trim();
836
+ ), He = (n) => {
837
+ const e = n == null ? void 0 : n.trim();
837
838
  return e || void 0;
838
- }, Ge = (t) => {
839
- const e = Ee(t);
839
+ }, tt = (n) => {
840
+ const e = He(n);
840
841
  return e ? { style: { fontSize: e } } : {};
841
- }, ne = (t, e) => {
842
- const n = Ee(t), r = {
843
- ...Ge(e).style
842
+ }, ae = (n, e) => {
843
+ const t = He(n), s = {
844
+ ...tt(e).style
844
845
  };
845
- return n && (r.fontFamily = n), {
846
- style: Object.keys(r).length > 0 ? r : void 0
846
+ return t && (s.fontFamily = t), {
847
+ style: Object.keys(s).length > 0 ? s : void 0
847
848
  };
848
- }, Qe = ({
849
- command: t,
849
+ }, nt = ({
850
+ command: n,
850
851
  timestamp: e,
851
- status: n,
852
- fontFamily: s,
853
- fontSize: r
852
+ status: t,
853
+ fontFamily: r,
854
+ fontSize: s
854
855
  }) => {
855
- const o = P(
856
- () => ne(s, r ?? "0.875rem"),
857
- [s, r]
856
+ const a = _(
857
+ () => ae(r, s ?? "0.875rem"),
858
+ [r, s]
858
859
  );
859
860
  return /* @__PURE__ */ A(
860
861
  "div",
861
862
  {
862
863
  className: "citadel-output-line",
863
- style: o.style,
864
+ style: a.style,
864
865
  children: [
865
866
  /* @__PURE__ */ A("span", { className: "citadel-output-command", children: [
866
867
  "> ",
867
- t.split(" ").map((a, c) => {
868
- const i = a.startsWith("<") && a.endsWith(">");
868
+ n.split(" ").map((o, c) => {
869
+ const i = o.startsWith("<") && o.endsWith(">");
869
870
  return /* @__PURE__ */ A(
870
871
  "span",
871
872
  {
872
873
  className: i ? "citadel-output-command-arg" : "citadel-output-command-word",
873
874
  children: [
874
875
  c > 0 ? " " : "",
875
- a
876
+ o
876
877
  ]
877
878
  },
878
879
  c
@@ -881,15 +882,15 @@ Check the definition of the ${i.join(".")} command and update the return type fo
881
882
  ] }),
882
883
  /* @__PURE__ */ m("span", { className: "citadel-output-separator", children: "·" }),
883
884
  /* @__PURE__ */ m("span", { className: "citadel-output-timestamp", children: e }),
884
- n === V.Pending && /* @__PURE__ */ m(Je, {}),
885
- n === V.Success && /* @__PURE__ */ m(
885
+ t === Y.Pending && /* @__PURE__ */ m(et, {}),
886
+ t === Y.Success && /* @__PURE__ */ m(
886
887
  "div",
887
888
  {
888
889
  "data-testid": "success-indicator",
889
890
  className: "citadel-status-dot citadel-status-dot-success"
890
891
  }
891
892
  ),
892
- (n === V.Timeout || n === V.Failure) && /* @__PURE__ */ m(
893
+ (t === Y.Timeout || t === Y.Failure) && /* @__PURE__ */ m(
893
894
  "div",
894
895
  {
895
896
  "data-testid": "success-indicator",
@@ -899,53 +900,53 @@ Check the definition of the ${i.join(".")} command and update the return type fo
899
900
  ]
900
901
  }
901
902
  );
902
- }, Xe = ({ output: t, outputRef: e }) => {
903
- const n = U(), s = P(
904
- () => ne(n.fontFamily, n.outputFontSize ?? n.fontSize),
905
- [n.fontFamily, n.fontSize, n.outputFontSize]
906
- ), r = f(() => {
903
+ }, rt = ({ output: n, outputRef: e }) => {
904
+ const t = j(), r = _(
905
+ () => ae(t.fontFamily, t.outputFontSize ?? t.fontSize),
906
+ [t.fontFamily, t.fontSize, t.outputFontSize]
907
+ ), s = f(() => {
907
908
  if (e.current) {
908
- const o = e.current;
909
+ const a = e.current;
909
910
  requestAnimationFrame(() => {
910
- o.scrollTop = o.scrollHeight;
911
+ a.scrollTop = a.scrollHeight;
911
912
  });
912
913
  }
913
914
  }, [e]);
914
915
  return I(() => {
915
- if (r(), e.current) {
916
- const o = e.current.getElementsByTagName("img"), a = o[o.length - 1];
917
- if (a && !a.complete)
918
- return a.addEventListener("load", r), () => a.removeEventListener("load", r);
916
+ if (s(), e.current) {
917
+ const a = e.current.getElementsByTagName("img"), o = a[a.length - 1];
918
+ if (o && !o.complete)
919
+ return o.addEventListener("load", s), () => o.removeEventListener("load", s);
919
920
  }
920
- }, [t, r, e]), /* @__PURE__ */ m(
921
+ }, [n, s, e]), /* @__PURE__ */ m(
921
922
  "div",
922
923
  {
923
924
  ref: e,
924
925
  className: "citadel-output",
925
926
  "data-testid": "citadel-command-output",
926
- children: t.map((o) => /* @__PURE__ */ A("div", { className: "citadel-output-item", children: [
927
+ children: n.map((a) => /* @__PURE__ */ A("div", { className: "citadel-output-item", children: [
927
928
  /* @__PURE__ */ m(
928
- Qe,
929
+ nt,
929
930
  {
930
- command: o.command.join(" "),
931
- timestamp: new Date(o.timestamp).toLocaleTimeString(),
932
- status: o.result.status,
933
- fontFamily: n.fontFamily,
934
- fontSize: n.fontSize
931
+ command: a.command.join(" "),
932
+ timestamp: new Date(a.timestamp).toLocaleTimeString(),
933
+ status: a.result.status,
934
+ fontFamily: t.fontFamily,
935
+ fontSize: t.fontSize
935
936
  }
936
937
  ),
937
938
  /* @__PURE__ */ m(
938
939
  "div",
939
940
  {
940
941
  className: "citadel-output-content",
941
- style: s.style,
942
- children: o.result.render()
942
+ style: r.style,
943
+ children: a.result.render()
943
944
  }
944
945
  )
945
- ] }, o.id))
946
+ ] }, a.id))
946
947
  }
947
948
  );
948
- }, Ze = {
949
+ }, st = {
949
950
  blink: {
950
951
  character: "▋",
951
952
  speed: 530,
@@ -966,276 +967,276 @@ Check the definition of the ${i.join(".")} command and update the return type fo
966
967
  speed: 120,
967
968
  color: "#fff"
968
969
  }
969
- }, he = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"], ge = ["|", "/", "-", "\\"], et = ({
970
- style: t = { type: "blink" },
970
+ }, we = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"], Ce = ["|", "/", "-", "\\"], ot = ({
971
+ style: n = { type: "blink" },
971
972
  isValid: e = !0,
972
- errorMessage: n
973
+ errorMessage: t
973
974
  }) => {
974
- const s = P(() => ({
975
- ...Ze[t.type],
976
- ...t
977
- }), [t]), [r, o] = _(!0), [a, c] = _(0);
975
+ const r = _(() => ({
976
+ ...st[n.type],
977
+ ...n
978
+ }), [n]), [s, a] = M(!0), [o, c] = M(0);
978
979
  I(() => {
979
- if (s.speed === 0) return;
980
- const g = setInterval(() => {
981
- s.type === "blink" ? o((u) => !u) : ["spin", "bbs"].includes(s.type) && c((u) => (u + 1) % (s.type === "bbs" ? ge.length : he.length));
982
- }, s.speed);
983
- return () => clearInterval(g);
984
- }, [s.type, s.speed]);
985
- const i = P(() => ({
986
- color: e ? s.color : "#ff4444",
980
+ if (r.speed === 0) return;
981
+ const h = setInterval(() => {
982
+ r.type === "blink" ? a((u) => !u) : ["spin", "bbs"].includes(r.type) && c((u) => (u + 1) % (r.type === "bbs" ? Ce.length : we.length));
983
+ }, r.speed);
984
+ return () => clearInterval(h);
985
+ }, [r.type, r.speed]);
986
+ const i = _(() => ({
987
+ color: e ? r.color : "#ff4444",
987
988
  transition: "color 0.15s ease-in-out"
988
- }), [e, s.color]);
989
+ }), [e, r.color]);
989
990
  return /* @__PURE__ */ m("div", { className: "citadel-cursor-wrapper", children: /* @__PURE__ */ m(
990
991
  "span",
991
992
  {
992
993
  className: `command-cursor ${e ? "" : "animate-shake"}`,
993
994
  style: i,
994
- title: n,
995
- children: !e && n ? "✗" : ["spin", "bbs"].includes(s.type) ? (s.type === "bbs" ? ge : he)[a] : s.type === "solid" || r ? s.character : " "
995
+ title: t,
996
+ children: !e && t ? "✗" : ["spin", "bbs"].includes(r.type) ? (r.type === "bbs" ? Ce : we)[o] : r.type === "solid" || s ? r.character : " "
996
997
  }
997
998
  ) });
998
999
  };
999
- function tt(t, e) {
1000
+ function at(n, e) {
1000
1001
  switch (e.type) {
1001
1002
  case "set":
1002
- return b.debug(`[inputStateReducer] InputState changing from ${t} to ${e.state}`), e.state;
1003
+ return k.debug(`[inputStateReducer] InputState changing from ${n} to ${e.state}`), e.state;
1003
1004
  default:
1004
- return t;
1005
+ return n;
1005
1006
  }
1006
1007
  }
1007
- const nt = () => {
1008
- const { state: t } = de(), e = te(), n = ke(), s = J(), [r, o] = _e(tt, "idle"), a = (l) => {
1009
- o({ type: "set", state: l });
1008
+ const it = () => {
1009
+ const { state: n } = he(), e = oe(), t = Pe(), r = X(), [s, a] = ze(at, "idle"), o = (l) => {
1010
+ a({ type: "set", state: l });
1010
1011
  }, c = f(() => {
1011
- const p = e.getCompletions(s.path())[0] || s.nullSegment;
1012
- return b.debug("[getNextExpectedSegment] ", p), p;
1013
- }, [e, s]), i = f(() => e.getCompletionNames(s.path()).map((p) => e.getCommand([...s.path(), p])).filter((p) => p !== void 0), [e, s]), d = f((l, p) => {
1012
+ const p = e.getCompletions(r.path())[0] || r.nullSegment;
1013
+ return k.debug("[getNextExpectedSegment] ", p), p;
1014
+ }, [e, r]), i = f(() => e.getCompletionNames(r.path()).map((p) => e.getCommand([...r.path(), p])).filter((p) => p !== void 0), [e, r]), d = f((l, p) => {
1014
1015
  if (!l) return p;
1015
- const w = s.path().length;
1016
+ const C = r.path().length;
1016
1017
  return p.filter((D) => {
1017
- const v = D.segments[w];
1018
- return !v || v.type !== "word" ? !1 : v.name.toLowerCase().startsWith(l.toLowerCase());
1018
+ const S = D.segments[C];
1019
+ return !S || S.type !== "word" ? !1 : S.name.toLowerCase().startsWith(l.toLowerCase());
1019
1020
  });
1020
- }, [s]), g = f((l) => {
1021
- const p = e.getUniqueCompletion(s.path(), l);
1022
- return p && p.type === "word" ? p : s.nullSegment;
1023
- }, [e, s]), u = f((l) => {
1024
- const p = s.path(), w = e.getCompletions(p);
1025
- return w.length === 0 && l ? !1 : w.some((v) => v.type === "argument") ? !0 : e.getMatchingCompletions(p, l).some((v) => v.type === "word");
1026
- }, [e, s]), h = f((l) => {
1027
- b.debug("[tryAutoComplete] input: ", l);
1028
- const p = g(l);
1029
- return !p || p.type === "null" ? new le() : (b.debug("[tryAutoComplete] result: ", p), p);
1030
- }, [g]), S = f((l, p) => {
1031
- if (t.history.position !== null)
1021
+ }, [r]), h = f((l) => {
1022
+ const p = e.getUniqueCompletion(r.path(), l);
1023
+ return p && p.type === "word" ? p : r.nullSegment;
1024
+ }, [e, r]), u = f((l) => {
1025
+ const p = r.path(), C = e.getCompletions(p);
1026
+ return C.length === 0 && l ? !1 : C.some((S) => S.type === "argument") ? !0 : e.getMatchingCompletions(p, l).some((S) => S.type === "word");
1027
+ }, [e, r]), g = f((l) => {
1028
+ k.debug("[tryAutoComplete] input: ", l);
1029
+ const p = h(l);
1030
+ return !p || p.type === "null" ? new pe() : (k.debug("[tryAutoComplete] result: ", p), p);
1031
+ }, [h]), w = f((l, p) => {
1032
+ if (n.history.position !== null)
1032
1033
  return;
1033
- p.setCurrentInput(l), b.debug("[useCommandParser][handleInputChange] newValue: ", l);
1034
- const w = c();
1035
- if (w.type === "argument" || r === "entering_argument") {
1036
- const H = fe(l);
1037
- if (H.isQuoted)
1038
- if (H.isComplete) {
1039
- if (!(w instanceof q)) return;
1040
- w.value = l.trim() || "", b.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", w), s.push(w), p.setCurrentInput(""), a("idle");
1034
+ p.setCurrentInput(l), k.debug("[useCommandParser][handleInputChange] newValue: ", l);
1035
+ const C = c();
1036
+ if (C.type === "argument" || s === "entering_argument") {
1037
+ const T = ve(l);
1038
+ if (T.isQuoted)
1039
+ if (T.isComplete) {
1040
+ if (!(C instanceof q)) return;
1041
+ C.value = l.trim() || "", k.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", C), r.push(C), p.setCurrentInput(""), o("idle");
1041
1042
  return;
1042
1043
  } else
1043
1044
  return;
1044
- else if (H.isComplete) {
1045
- if (!(w instanceof q)) return;
1046
- w.value = l.trim() || "", b.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", w), s.push(w), p.setCurrentInput(""), a("idle");
1045
+ else if (T.isComplete) {
1046
+ if (!(C instanceof q)) return;
1047
+ C.value = l.trim() || "", k.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", C), r.push(C), p.setCurrentInput(""), o("idle");
1047
1048
  return;
1048
1049
  } else
1049
1050
  return;
1050
1051
  }
1051
1052
  if (l.endsWith(" ")) {
1052
- const H = l.trim().toLowerCase(), M = e.getCompletions(s.path()).filter(
1053
- (E) => E.type === "word" && E.name.toLowerCase() === H
1053
+ const T = l.trim().toLowerCase(), U = e.getCompletions(r.path()).filter(
1054
+ (N) => N.type === "word" && N.name.toLowerCase() === T
1054
1055
  );
1055
- if (M.length === 1) {
1056
- s.push(M[0]), p.setCurrentInput(""), a("idle");
1056
+ if (U.length === 1) {
1057
+ r.push(U[0]), p.setCurrentInput(""), o("idle");
1057
1058
  return;
1058
1059
  }
1059
1060
  }
1060
- const v = h(l);
1061
- if (v.type === "word") {
1062
- b.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", v), s.push(v), p.setCurrentInput(""), a("idle");
1061
+ const S = g(l);
1062
+ if (S.type === "word") {
1063
+ k.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", S), r.push(S), p.setCurrentInput(""), o("idle");
1063
1064
  return;
1064
1065
  }
1065
- }, [h, t, c, r, s, e]), C = f((l) => {
1066
- l.setCurrentInput(""), l.setIsEnteringArg(!1), s.clear(), a("idle");
1067
- }, [s]), k = f((l, p, w) => {
1066
+ }, [g, n, c, s, r, e]), v = f((l) => {
1067
+ l.setCurrentInput(""), l.setIsEnteringArg(!1), r.clear(), o("idle");
1068
+ }, [r]), b = f((l, p, C) => {
1068
1069
  if (!(l.key === "Backspace" || l.key === "Enter" || l.key === "ArrowUp" || l.key === "ArrowDown" || l.key === "ArrowLeft" || l.key === "ArrowRight" || l.key === "Escape" || l.key === "Delete" || l.key === "Home" || l.key === "End" || l.key.length === 1))
1069
1070
  return !0;
1070
- const { currentInput: v, isEnteringArg: H } = p, M = fe(v);
1071
+ const { currentInput: S, isEnteringArg: T } = p, U = ve(S);
1071
1072
  switch (l.key) {
1072
1073
  case "Backspace":
1073
- return v === "" && (l.preventDefault(), s.size() > 0 && s.pop(), a("idle")), !0;
1074
+ return S === "" && (l.preventDefault(), r.size() > 0 && r.pop(), o("idle")), !0;
1074
1075
  case "Enter": {
1075
- if (l.preventDefault(), M.isQuoted && !M.isComplete)
1076
+ if (l.preventDefault(), U.isQuoted && !U.isComplete)
1076
1077
  return !0;
1077
- if (r === "entering_argument" || H && v.trim()) {
1078
+ if (s === "entering_argument" || T && S.trim()) {
1078
1079
  const F = c();
1079
- F instanceof q && (F.value = v, b.debug("[handleKeyDown][Enter]['entering_argument'] pushing: ", F), s.push(F));
1080
+ F instanceof q && (F.value = S, k.debug("[handleKeyDown][Enter]['entering_argument'] pushing: ", F), r.push(F));
1080
1081
  }
1081
- const E = s.path(), B = e.getCommand(E);
1082
- if (!B)
1082
+ const N = r.path(), z = e.getCommand(N);
1083
+ if (!z)
1083
1084
  return !1;
1084
- const O = B.segments.filter((F) => F.type === "argument"), W = s.arguments;
1085
- return O.length > W.length ? !1 : (b.debug("[handleKeyDown][Enter] calling actions.executeCommand. segmentStack: ", s), w.executeCommand(), n.addStoredCommand(s.toArray()), C(w), !0);
1085
+ const O = z.segments.filter((F) => F.type === "argument"), B = r.arguments;
1086
+ return O.length > B.length ? !1 : (k.debug("[handleKeyDown][Enter] calling actions.executeCommand. segmentStack: ", r), C.executeCommand(), t.addStoredCommand(r.toArray()), v(C), !0);
1086
1087
  }
1087
1088
  case "ArrowUp":
1088
1089
  return l.preventDefault(), (async () => {
1089
- const E = await n.navigateHistory("up");
1090
- return E.segments && (s.clear(), s.pushAll(E.segments), w.setCurrentInput("")), !0;
1090
+ const N = await t.navigateHistory("up");
1091
+ return N.segments && (r.clear(), r.pushAll(N.segments), C.setCurrentInput("")), !0;
1091
1092
  })();
1092
1093
  case "ArrowDown":
1093
1094
  return l.preventDefault(), (async () => {
1094
- const E = await n.navigateHistory("down");
1095
- return E.segments && (s.clear(), s.pushAll(E.segments), w.setCurrentInput("")), !0;
1095
+ const N = await t.navigateHistory("down");
1096
+ return N.segments && (r.clear(), r.pushAll(N.segments), C.setCurrentInput("")), !0;
1096
1097
  })();
1097
1098
  default: {
1098
- if (!H && l.key.length === 1) {
1099
- const E = v + l.key;
1100
- if (!u(E))
1099
+ if (!T && l.key.length === 1) {
1100
+ const N = S + l.key;
1101
+ if (!u(N))
1101
1102
  return l.preventDefault(), !1;
1102
1103
  }
1103
1104
  return !0;
1104
1105
  }
1105
1106
  }
1106
1107
  }, [
1107
- r,
1108
+ s,
1108
1109
  u,
1109
1110
  c,
1110
- n,
1111
- C,
1111
+ t,
1112
+ v,
1112
1113
  e,
1113
- s
1114
+ r
1114
1115
  ]);
1115
1116
  return {
1116
- handleInputChange: S,
1117
- handleKeyDown: k,
1118
- inputState: r,
1119
- setInputStateWithLogging: a,
1117
+ handleInputChange: w,
1118
+ handleKeyDown: b,
1119
+ inputState: s,
1120
+ setInputStateWithLogging: o,
1120
1121
  // Expose internal functions for testing
1121
1122
  findMatchingCommands: d,
1122
- getAutocompleteSuggestion: g,
1123
+ getAutocompleteSuggestion: h,
1123
1124
  getAvailableNodes: i,
1124
1125
  getNextExpectedSegment: c,
1125
1126
  isValidCommandInput: u
1126
1127
  };
1127
1128
  };
1128
- function fe(t) {
1129
+ function ve(n) {
1129
1130
  const e = [];
1130
- let n = "", s = !1, r;
1131
- for (let o = 0; o < t.length; o++) {
1132
- const a = t[o];
1133
- (a === '"' || a === "'") && (!s || a === r) ? s ? (e.push(n), n = "", s = !1, r = void 0) : (n && (e.push(n), n = ""), s = !0, r = a) : !s && a === " " ? n && (e.push(n), n = "") : n += a;
1131
+ let t = "", r = !1, s;
1132
+ for (let a = 0; a < n.length; a++) {
1133
+ const o = n[a];
1134
+ (o === '"' || o === "'") && (!r || o === s) ? r ? (e.push(t), t = "", r = !1, s = void 0) : (t && (e.push(t), t = ""), r = !0, s = o) : !r && o === " " ? t && (e.push(t), t = "") : t += o;
1134
1135
  }
1135
1136
  return {
1136
1137
  words: e,
1137
- currentWord: n,
1138
- isQuoted: s,
1139
- quoteChar: r,
1140
- isComplete: !s && !n
1138
+ currentWord: t,
1139
+ isQuoted: r,
1140
+ quoteChar: s,
1141
+ isComplete: !r && !t
1141
1142
  };
1142
1143
  }
1143
- const st = () => {
1144
- const t = J(), [e, n] = _(0);
1144
+ const ct = () => {
1145
+ const n = X(), [e, t] = M(0);
1145
1146
  return I(() => {
1146
- const s = {
1147
+ const r = {
1147
1148
  update: () => {
1148
- n((r) => r + 1);
1149
+ t((s) => s + 1);
1149
1150
  }
1150
1151
  };
1151
- return t.subscribe(s), () => {
1152
- t.unsubscribe(s);
1152
+ return n.subscribe(r), () => {
1153
+ n.unsubscribe(r);
1153
1154
  };
1154
- }, [t]), e;
1155
- }, rt = ({
1156
- state: t,
1155
+ }, [n]), e;
1156
+ }, lt = ({
1157
+ state: n,
1157
1158
  actions: e
1158
1159
  }) => {
1159
- const n = T(null), s = te(), r = J(), {
1160
- handleKeyDown: o,
1161
- handleInputChange: a,
1160
+ const t = R(null), r = oe(), s = X(), {
1161
+ handleKeyDown: a,
1162
+ handleInputChange: o,
1162
1163
  inputState: c,
1163
1164
  setInputStateWithLogging: i,
1164
1165
  getNextExpectedSegment: d
1165
- } = nt(), [g, u] = _(!1), h = U(), S = st(), C = T(null), [k, l] = _(0), p = P(
1166
- () => ne(h.fontFamily, h.fontSize),
1167
- [h.fontFamily, h.fontSize]
1168
- ), w = f(async (N) => {
1169
- const R = o(N, t, e);
1170
- await Promise.resolve(R) === !1 && (u(!0), setTimeout(() => u(!1), 500));
1171
- }, [e, o, t]), D = f((N) => {
1172
- a(N.target.value, e);
1173
- }, [e, a]), v = f((N) => {
1174
- N.preventDefault();
1175
- const R = N.clipboardData.getData("text");
1176
- a(R, e);
1177
- }, [e, a]);
1166
+ } = it(), [h, u] = M(!1), g = j(), w = ct(), v = R(null), [b, l] = M(0), p = _(
1167
+ () => ae(g.fontFamily, g.fontSize),
1168
+ [g.fontFamily, g.fontSize]
1169
+ ), C = f(async (x) => {
1170
+ const P = a(x, n, e);
1171
+ await Promise.resolve(P) === !1 && (u(!0), setTimeout(() => u(!1), 500));
1172
+ }, [e, a, n]), D = f((x) => {
1173
+ o(x.target.value, e);
1174
+ }, [e, o]), S = f((x) => {
1175
+ x.preventDefault();
1176
+ const P = x.clipboardData.getData("text");
1177
+ o(P, e);
1178
+ }, [e, o]);
1178
1179
  I(() => {
1179
- n.current && n.current.focus(), c !== "entering_command" && i("entering_command");
1180
+ t.current && t.current.focus(), c !== "entering_command" && i("entering_command");
1180
1181
  }, [c, i]), I(() => {
1181
1182
  if (c !== "idle") return;
1182
- const N = d();
1183
- let R = "idle";
1184
- switch (N.type) {
1183
+ const x = d();
1184
+ let P = "idle";
1185
+ switch (x.type) {
1185
1186
  case "word":
1186
- R = "entering_command", e.setIsEnteringArg(!1);
1187
+ P = "entering_command", e.setIsEnteringArg(!1);
1187
1188
  break;
1188
1189
  case "argument":
1189
- R = "entering_argument", e.setIsEnteringArg(!0);
1190
+ P = "entering_argument", e.setIsEnteringArg(!0);
1190
1191
  break;
1191
1192
  }
1192
- i(R);
1193
- }, [S, c, d, i, e]);
1194
- const H = P(() => {
1195
- const N = [], R = r.toArray().map((L, se) => {
1196
- N.push(L.name);
1197
- const me = s.hasNextSegment(N);
1198
- if (L.type === "argument") {
1199
- const re = L;
1200
- return /* @__PURE__ */ A($.Fragment, { children: [
1201
- /* @__PURE__ */ m("span", { className: "citadel-input-segment-arg", children: re.value }),
1202
- se < r.size() && me && /* @__PURE__ */ m("span", { className: "citadel-input-segment-space", children: " " })
1203
- ] }, "arg-" + re.name + re.value);
1193
+ i(P);
1194
+ }, [w, c, d, i, e]);
1195
+ const T = _(() => {
1196
+ const x = [], P = s.toArray().map((H, V) => {
1197
+ x.push(H.name);
1198
+ const Q = r.hasNextSegment(x);
1199
+ if (H.type === "argument") {
1200
+ const G = H;
1201
+ return /* @__PURE__ */ A(K.Fragment, { children: [
1202
+ /* @__PURE__ */ m("span", { className: "citadel-input-segment-arg", children: G.value }),
1203
+ V < s.size() && Q && /* @__PURE__ */ m("span", { className: "citadel-input-segment-space", children: " " })
1204
+ ] }, "arg-" + G.name + G.value);
1204
1205
  }
1205
- return /* @__PURE__ */ A($.Fragment, { children: [
1206
- /* @__PURE__ */ m("span", { className: "citadel-input-segment-word", children: L.name }),
1207
- se < r.size() && me && /* @__PURE__ */ m("span", { className: "citadel-input-segment-space citadel-input-segment-space-command", children: " " })
1208
- ] }, "word-" + L.name);
1206
+ return /* @__PURE__ */ A(K.Fragment, { children: [
1207
+ /* @__PURE__ */ m("span", { className: "citadel-input-segment-word", children: H.name }),
1208
+ V < s.size() && Q && /* @__PURE__ */ m("span", { className: "citadel-input-segment-space citadel-input-segment-space-command", children: " " })
1209
+ ] }, "word-" + H.name);
1209
1210
  });
1210
- return [/* @__PURE__ */ m("div", { className: "citadel-input-segments", "data-testid": "user-input-area", children: R }, S)];
1211
- }, [S, s, r]), [M, E] = _("");
1211
+ return [/* @__PURE__ */ m("div", { className: "citadel-input-segments", "data-testid": "user-input-area", children: P }, w)];
1212
+ }, [w, r, s]), [U, N] = M("");
1212
1213
  I(() => {
1213
- const N = d();
1214
- N.type === "argument" ? E(N.name) : E("");
1215
- }, [S, d]);
1216
- const O = !t.isEnteringArg ? "is-command-mode" : "is-argument-mode", W = P(
1214
+ const x = d();
1215
+ x.type === "argument" ? N(x.name) : N("");
1216
+ }, [w, d]);
1217
+ const O = !n.isEnteringArg ? "is-command-mode" : "is-argument-mode", B = _(
1217
1218
  () => ({
1218
- left: `${k}px`,
1219
+ left: `${b}px`,
1219
1220
  transition: "left 0.05s ease-out"
1220
1221
  }),
1221
- [k]
1222
- ), F = P(
1222
+ [b]
1223
+ ), F = _(
1223
1224
  () => ({
1224
- type: h.cursorType ?? x.cursorType,
1225
- color: h.cursorColor || x.cursorColor,
1226
- speed: h.cursorSpeed || x.cursorSpeed
1225
+ type: g.cursorType ?? E.cursorType,
1226
+ color: g.cursorColor || E.cursorColor,
1227
+ speed: g.cursorSpeed || E.cursorSpeed
1227
1228
  }),
1228
- [h.cursorColor, h.cursorSpeed, h.cursorType]
1229
+ [g.cursorColor, g.cursorSpeed, g.cursorType]
1229
1230
  );
1230
- return Me(() => {
1231
- const N = C.current, R = n.current;
1232
- if (!N || !R) {
1231
+ return Fe(() => {
1232
+ const x = v.current, P = t.current;
1233
+ if (!x || !P) {
1233
1234
  l(0);
1234
1235
  return;
1235
1236
  }
1236
- const L = N.getBoundingClientRect().width;
1237
- l(Math.max(0, L - R.scrollLeft));
1238
- }, [t.currentInput, O, p.style]), /* @__PURE__ */ m("div", { className: "citadel-input-shell", children: /* @__PURE__ */ A(
1237
+ const H = x.getBoundingClientRect().width;
1238
+ l(Math.max(0, H - P.scrollLeft));
1239
+ }, [n.currentInput, O, p.style]), /* @__PURE__ */ m("div", { className: "citadel-input-shell", children: /* @__PURE__ */ A(
1239
1240
  "div",
1240
1241
  {
1241
1242
  className: "citadel-input-line",
@@ -1243,40 +1244,40 @@ const st = () => {
1243
1244
  children: [
1244
1245
  /* @__PURE__ */ m("div", { className: "citadel-input-prompt", children: ">" }),
1245
1246
  /* @__PURE__ */ A("div", { className: "citadel-input-row", children: [
1246
- H,
1247
+ T,
1247
1248
  /* @__PURE__ */ A("div", { className: "citadel-input-control", children: [
1248
1249
  /* @__PURE__ */ m(
1249
1250
  "span",
1250
1251
  {
1251
- ref: C,
1252
+ ref: v,
1252
1253
  className: `citadel-input-measure ${O}`.trim(),
1253
1254
  "aria-hidden": "true",
1254
- children: t.currentInput
1255
+ children: n.currentInput
1255
1256
  }
1256
1257
  ),
1257
1258
  /* @__PURE__ */ m(
1258
1259
  "input",
1259
1260
  {
1260
- ref: n,
1261
+ ref: t,
1261
1262
  type: "text",
1262
1263
  role: "textbox",
1263
- value: t.currentInput,
1264
+ value: n.currentInput,
1264
1265
  onChange: D,
1265
- onKeyDown: w,
1266
- onPaste: v,
1266
+ onKeyDown: C,
1267
+ onPaste: S,
1267
1268
  "data-testid": "citadel-command-input",
1268
- className: `citadel-input-field ${O} ${g ? "invalid-input-animation" : ""}`.trim(),
1269
+ className: `citadel-input-field ${O} ${h ? "invalid-input-animation" : ""}`.trim(),
1269
1270
  spellCheck: !1,
1270
1271
  autoComplete: "off",
1271
- placeholder: M
1272
+ placeholder: U
1272
1273
  }
1273
1274
  ),
1274
1275
  /* @__PURE__ */ m(
1275
1276
  "div",
1276
1277
  {
1277
1278
  className: "citadel-input-cursor",
1278
- style: W,
1279
- children: /* @__PURE__ */ m(et, { style: F })
1279
+ style: B,
1280
+ children: /* @__PURE__ */ m(ot, { style: F })
1280
1281
  }
1281
1282
  )
1282
1283
  ] })
@@ -1284,171 +1285,197 @@ const st = () => {
1284
1285
  ]
1285
1286
  }
1286
1287
  ) });
1287
- }, at = ({ currentInput: t = "" }) => {
1288
- const e = te(), n = U(), s = J(), r = $.useMemo(
1289
- () => ne(n.fontFamily, n.fontSize),
1290
- [n.fontFamily, n.fontSize]
1291
- ), o = t.trim().toLowerCase(), a = e.getMatchingCompletions(
1292
- s.path(),
1293
- o
1288
+ }, dt = ({ currentInput: n = "" }) => {
1289
+ const e = oe(), t = j(), r = X(), s = K.useMemo(
1290
+ () => ae(t.fontFamily, t.fontSize),
1291
+ [t.fontFamily, t.fontSize]
1292
+ ), a = n.trim().toLowerCase(), o = e.getMatchingCompletions(
1293
+ r.path(),
1294
+ a
1294
1295
  );
1295
- b.debug("[AvailableCommands] nextCommandSegments: ", a);
1296
- const c = $.useMemo(() => {
1297
- const u = [...a], h = (l) => l.name.toLowerCase() === "help", S = u.filter(h);
1298
- return [...u.filter((l) => !h(l)).sort(
1296
+ k.debug("[AvailableCommands] nextCommandSegments: ", o);
1297
+ const c = K.useMemo(() => {
1298
+ const u = [...o], g = (l) => l.name.toLowerCase() === "help", w = u.filter(g);
1299
+ return [...u.filter((l) => !g(l)).sort(
1299
1300
  (l, p) => l.name.localeCompare(p.name, void 0, { sensitivity: "base" })
1300
- ), ...S];
1301
- }, [a]), i = $.useMemo(() => {
1301
+ ), ...w];
1302
+ }, [o]), i = K.useMemo(() => {
1302
1303
  const u = /* @__PURE__ */ new Map();
1303
- for (const h of c) {
1304
- const S = c.reduce((C, k) => {
1305
- if (k === h) return C;
1304
+ for (const g of c) {
1305
+ const w = c.reduce((v, b) => {
1306
+ if (b === g) return v;
1306
1307
  let l = 0;
1307
- for (; l < h.name.length && l < k.name.length && h.name[l].toLowerCase() === k.name[l].toLowerCase(); )
1308
+ for (; l < g.name.length && l < b.name.length && g.name[l].toLowerCase() === b.name[l].toLowerCase(); )
1308
1309
  l++;
1309
- return Math.max(C, l + 1);
1310
+ return Math.max(v, l + 1);
1310
1311
  }, 1);
1311
- u.set(h.name, S);
1312
+ u.set(g.name, w);
1312
1313
  }
1313
1314
  return u;
1314
- }, [c]), d = a.some((u) => u.type === "argument"), g = a[0];
1315
- return /* @__PURE__ */ m("div", { className: "citadel-available-commands", "data-testid": "available-commands", children: /* @__PURE__ */ m("div", { className: "citadel-available-commands-content", style: r.style, children: d ? a.length > 0 ? /* @__PURE__ */ A(He, { children: [
1316
- /* @__PURE__ */ m("span", { className: "citadel-available-next-arg", children: g.name }),
1317
- g.description && /* @__PURE__ */ A("span", { className: "citadel-available-next-desc", children: [
1315
+ }, [c]), d = o.some((u) => u.type === "argument"), h = o[0];
1316
+ return /* @__PURE__ */ m("div", { className: "citadel-available-commands", "data-testid": "available-commands", children: /* @__PURE__ */ m("div", { className: "citadel-available-commands-content", style: s.style, children: d ? o.length > 0 ? /* @__PURE__ */ A(Oe, { children: [
1317
+ /* @__PURE__ */ m("span", { className: "citadel-available-next-arg", children: h.name }),
1318
+ h.description && /* @__PURE__ */ A("span", { className: "citadel-available-next-desc", children: [
1318
1319
  "- ",
1319
- g.description
1320
+ h.description
1320
1321
  ] })
1321
1322
  ] }) : null : /* @__PURE__ */ m("div", { className: "citadel-available-chip-list", children: c == null ? void 0 : c.map((u) => {
1322
- const h = i.get(u.name) ?? 1;
1323
+ const g = i.get(u.name) ?? 1;
1323
1324
  return /* @__PURE__ */ m(
1324
1325
  "div",
1325
1326
  {
1326
1327
  "data-testid": "available-command-chip",
1327
1328
  className: "citadel-available-chip",
1328
1329
  children: /* @__PURE__ */ A("span", { className: "citadel-available-chip-text", children: [
1329
- /* @__PURE__ */ m("strong", { className: "citadel-available-chip-prefix", children: u.name.slice(0, h) }),
1330
- u.name.slice(h)
1330
+ /* @__PURE__ */ m("strong", { className: "citadel-available-chip-prefix", children: u.name.slice(0, g) }),
1331
+ u.name.slice(g)
1331
1332
  ] })
1332
1333
  },
1333
1334
  u.name
1334
1335
  );
1335
1336
  }) }) }) });
1336
- }, Ne = ({
1337
- state: t,
1337
+ }, _e = ({
1338
+ state: n,
1338
1339
  actions: e,
1339
- outputRef: n
1340
+ outputRef: t
1340
1341
  }) => {
1341
- const r = U().displayMode === "inline", o = $.useMemo(
1342
- () => r ? { overflow: "hidden" } : void 0,
1343
- [r]
1342
+ const r = j(), s = r.displayMode === "inline", a = r.showOutputPane ?? !0, o = K.useMemo(
1343
+ () => a && s ? { overflow: "hidden" } : void 0,
1344
+ [s, a]
1344
1345
  );
1345
1346
  return /* @__PURE__ */ A("div", { className: "innerContainer citadel-tty", children: [
1346
- /* @__PURE__ */ m(
1347
+ a ? /* @__PURE__ */ m(
1347
1348
  "div",
1348
1349
  {
1349
1350
  className: "citadel-tty-output-pane",
1350
1351
  "data-testid": "citadel-output-pane",
1351
1352
  style: o,
1352
- children: /* @__PURE__ */ m(Xe, { output: t.output, outputRef: n })
1353
+ children: /* @__PURE__ */ m(rt, { output: n.output, outputRef: t })
1353
1354
  }
1354
- ),
1355
+ ) : null,
1355
1356
  /* @__PURE__ */ A("div", { className: "citadel-tty-input-region", children: [
1356
- /* @__PURE__ */ m(rt, { state: t, actions: e }),
1357
- /* @__PURE__ */ m(at, { currentInput: t.isEnteringArg ? "" : t.currentInput })
1357
+ /* @__PURE__ */ m(lt, { state: n, actions: e }),
1358
+ /* @__PURE__ */ m(dt, { currentInput: n.isEnteringArg ? "" : n.currentInput })
1358
1359
  ] })
1359
1360
  ] });
1360
- }, ot = () => {
1361
- const t = U(), [e, n] = _(() => t.showOnLoad ?? !1), [s, r] = _(!1), [o, a] = _(() => t.initialHeight || null), c = T(null), i = T(null), d = T(!1), g = T(0), u = T(0), { state: h, actions: S } = de(), C = f(() => {
1362
- r(!1), n(!0);
1363
- }, []), k = f(() => {
1364
- r(!0);
1361
+ }, Z = "128px", mt = "200px", ut = "80vh", ie = (n) => {
1362
+ if (!n) return;
1363
+ const e = n.trim();
1364
+ if (e)
1365
+ return /^\d+(\.\d+)?$/.test(e) ? `${e}px` : e;
1366
+ }, Se = (n, e) => {
1367
+ if (!n) return e;
1368
+ const t = n.trim();
1369
+ if (!t) return e;
1370
+ if (t.endsWith("vh")) {
1371
+ const s = Number.parseFloat(t);
1372
+ return Number.isFinite(s) ? window.innerHeight * s / 100 : e;
1373
+ }
1374
+ const r = Number.parseFloat(t);
1375
+ return Number.isFinite(r) ? r : e;
1376
+ }, pt = () => {
1377
+ const n = j(), e = n.showOutputPane ?? !0, t = ie(n.minHeight) ?? mt, r = ie(n.maxHeight) ?? ut, s = e ? t : Z, a = Number.parseFloat(Z), [o, c] = M(() => {
1378
+ const H = ie(n.initialHeight);
1379
+ return e ? H ?? null : Z;
1380
+ }), [i, d] = M(() => n.showOnLoad ?? !1), [h, u] = M(!1), g = R(null), w = R(null), v = R(!1), b = R(0), l = R(0), p = R(null), C = R(o), D = R(e), { state: S, actions: T } = he(), U = f(() => {
1381
+ u(!1), d(!0);
1382
+ }, []), N = f(() => {
1383
+ u(!0);
1365
1384
  }, []);
1366
- Be({
1367
- onOpen: C,
1368
- onClose: k,
1369
- isVisible: e && !s,
1370
- showCitadelKey: t.showCitadelKey || ".",
1371
- closeOnEscape: t.closeOnEscape ?? !0
1385
+ Xe({
1386
+ onOpen: U,
1387
+ onClose: N,
1388
+ isVisible: i && !h,
1389
+ showCitadelKey: n.showCitadelKey || ".",
1390
+ closeOnEscape: n.closeOnEscape ?? !0
1372
1391
  });
1373
- const l = f((M) => {
1374
- var W;
1375
- if (!d.current) return;
1376
- const E = M.clientY - g.current, B = (W = t.maxHeight) != null && W.endsWith("vh") ? window.innerHeight * parseInt(t.maxHeight, 10) / 100 : parseInt(t.maxHeight || "80vh", 10), O = Math.min(
1377
- Math.max(u.current - E, parseInt(t.minHeight || "200", 10)),
1378
- B
1392
+ const z = f((H) => {
1393
+ if (!v.current) return;
1394
+ const V = H.clientY - b.current, Q = Se(r, window.innerHeight * 80 / 100), G = Se(s, a), ge = Math.min(
1395
+ Math.max(l.current - V, G),
1396
+ Q
1379
1397
  );
1380
- i.current && (i.current.style.height = `${O}px`, i.current.style.bottom = "0", a(`${O}px`));
1381
- }, [t.maxHeight, t.minHeight]), p = f(() => {
1382
- d.current = !1, document.documentElement.style.userSelect = "", document.documentElement.style.webkitUserSelect = "", document.documentElement.style.mozUserSelect = "", document.documentElement.style.msUserSelect = "", document.removeEventListener("mousemove", l), document.removeEventListener("mouseup", p);
1383
- }, [l]), w = f((M) => {
1384
- i.current && (d.current = !0, g.current = M.clientY, u.current = i.current.offsetHeight, document.documentElement.style.userSelect = "none", document.documentElement.style.webkitUserSelect = "none", document.documentElement.style.mozUserSelect = "none", document.documentElement.style.msUserSelect = "none", document.addEventListener("mousemove", l), document.addEventListener("mouseup", p));
1385
- }, [l, p]);
1398
+ w.current && (w.current.style.height = `${ge}px`, w.current.style.bottom = "0", c(`${ge}px`));
1399
+ }, [a, s, r]), O = f(() => {
1400
+ v.current = !1, document.documentElement.style.userSelect = "", document.documentElement.style.webkitUserSelect = "", document.documentElement.style.mozUserSelect = "", document.documentElement.style.msUserSelect = "", document.removeEventListener("mousemove", z), document.removeEventListener("mouseup", O);
1401
+ }, [z]), B = f((H) => {
1402
+ w.current && (v.current = !0, b.current = H.clientY, l.current = w.current.offsetHeight, document.documentElement.style.userSelect = "none", document.documentElement.style.webkitUserSelect = "none", document.documentElement.style.mozUserSelect = "none", document.documentElement.style.msUserSelect = "none", document.addEventListener("mousemove", z), document.addEventListener("mouseup", O));
1403
+ }, [z, O]);
1386
1404
  I(() => () => {
1387
- document.removeEventListener("mousemove", l), document.removeEventListener("mouseup", p);
1388
- }, [l, p]);
1389
- const D = f(() => {
1390
- s && (n(!1), r(!1));
1391
- }, [s]), { animationClass: v } = Ye({
1392
- isVisible: e,
1393
- isClosing: s,
1394
- onAnimationComplete: D
1395
- }), H = P(
1405
+ document.removeEventListener("mousemove", z), document.removeEventListener("mouseup", O);
1406
+ }, [z, O]), I(() => {
1407
+ C.current = o;
1408
+ }, [o]), I(() => {
1409
+ if (!e) {
1410
+ D.current && (p.current = C.current ?? (w.current ? `${w.current.offsetHeight}px` : null)), D.current = !1, c(Z);
1411
+ return;
1412
+ }
1413
+ D.current = !0, p.current && (c(p.current), p.current = null);
1414
+ }, [e]);
1415
+ const F = f(() => {
1416
+ h && (d(!1), u(!1));
1417
+ }, [h]), { animationClass: x } = Ze({
1418
+ isVisible: i,
1419
+ isClosing: h,
1420
+ onAnimationComplete: F
1421
+ }), P = _(
1396
1422
  () => ({
1397
1423
  ...o ? { height: o } : {},
1398
- maxHeight: t.maxHeight
1424
+ minHeight: s,
1425
+ maxHeight: r
1399
1426
  }),
1400
- [t.maxHeight, o]
1427
+ [s, o, r]
1401
1428
  );
1402
- return e ? /* @__PURE__ */ A(
1429
+ return i ? /* @__PURE__ */ A(
1403
1430
  "div",
1404
1431
  {
1405
- ref: i,
1406
- className: `panelContainer ${v}`.trim(),
1407
- style: H,
1432
+ ref: w,
1433
+ className: `panelContainer ${x}`.trim(),
1434
+ style: P,
1408
1435
  children: [
1409
- /* @__PURE__ */ m("div", { className: "resizeHandle", onMouseDown: w }),
1436
+ /* @__PURE__ */ m("div", { className: "resizeHandle", onMouseDown: B }),
1410
1437
  /* @__PURE__ */ m(
1411
- Ne,
1438
+ _e,
1412
1439
  {
1413
- state: h,
1414
- actions: S,
1415
- outputRef: c
1440
+ state: S,
1441
+ actions: T,
1442
+ outputRef: g
1416
1443
  }
1417
1444
  )
1418
1445
  ]
1419
1446
  }
1420
1447
  ) : null;
1421
- }, ae = (t) => {
1422
- if (!t) return;
1423
- const e = t.trim();
1448
+ }, ce = "128px", le = (n) => {
1449
+ if (!n) return;
1450
+ const e = n.trim();
1424
1451
  if (e)
1425
1452
  return /^\d+(\.\d+)?$/.test(e) ? `${e}px` : e;
1426
- }, it = () => {
1427
- const { state: t, actions: e } = de(), n = U(), s = T(null), r = P(
1453
+ }, ht = () => {
1454
+ const { state: n, actions: e } = he(), t = j(), r = t.showOutputPane ?? !0, s = R(null), a = _(
1428
1455
  () => ({
1429
- height: ae(n.initialHeight),
1430
- maxHeight: ae(n.maxHeight),
1431
- minHeight: ae(n.minHeight)
1456
+ height: r ? le(t.initialHeight) : ce,
1457
+ maxHeight: r ? le(t.maxHeight) : ce,
1458
+ minHeight: r ? le(t.minHeight) : ce
1432
1459
  }),
1433
- [n.initialHeight, n.maxHeight, n.minHeight]
1460
+ [t.initialHeight, t.maxHeight, t.minHeight, r]
1434
1461
  );
1435
1462
  return /* @__PURE__ */ m(
1436
1463
  "div",
1437
1464
  {
1438
1465
  className: "inlineContainer",
1439
1466
  "data-testid": "citadel-inline-container",
1440
- style: r,
1467
+ style: a,
1441
1468
  children: /* @__PURE__ */ m(
1442
- Ne,
1469
+ _e,
1443
1470
  {
1444
- state: t,
1471
+ state: n,
1445
1472
  actions: e,
1446
1473
  outputRef: s
1447
1474
  }
1448
1475
  )
1449
1476
  }
1450
1477
  );
1451
- }, ye = `:host {
1478
+ }, xe = `:host {
1452
1479
  --citadel-bg: oklch(20.8% 0.042 265.8);
1453
1480
  --citadel-surface: oklch(27.9% 0.041 260);
1454
1481
  --citadel-border: oklch(37.2% 0.044 257.3);
@@ -1920,76 +1947,76 @@ const st = () => {
1920
1947
  object-fit: contain;
1921
1948
  border-radius: 0.5rem;
1922
1949
  }
1923
- `, vt = ({
1924
- config: t = x,
1950
+ `, It = ({
1951
+ config: n = E,
1925
1952
  commandRegistry: e,
1926
- containerId: n = null
1953
+ containerId: t = null
1927
1954
  }) => {
1928
- const s = T(new ee()), r = e ?? s.current, o = T(null), a = P(() => ({ width: "100%", height: "100%" }), []), c = t.displayMode ?? x.displayMode ?? "panel";
1955
+ const r = R(new se()), s = e ?? r.current, a = R(null), o = _(() => ({ width: "100%", height: "100%" }), []), c = n.displayMode ?? E.displayMode ?? "panel";
1929
1956
  return I(() => {
1930
- b.configure({
1931
- level: t.logLevel || x.logLevel || ie.ERROR,
1957
+ k.configure({
1958
+ level: n.logLevel || E.logLevel || me.ERROR,
1932
1959
  prefix: "[Citadel]"
1933
1960
  });
1934
- const i = new Ae(r, t), d = c === "inline" && !n, g = d ? o.current : n ? document.getElementById(n) : document.body;
1935
- if (g)
1936
- g.appendChild(i);
1961
+ const i = new Re(s, n), d = c === "inline" && !t, h = d ? a.current : t ? document.getElementById(t) : document.body;
1962
+ if (h)
1963
+ h.appendChild(i);
1937
1964
  else {
1938
1965
  if (d) {
1939
1966
  console.warn("[Citadel] No host available for inline mode; skipping mount.");
1940
1967
  return;
1941
1968
  }
1942
- console.warn(`Container with id "${n}" not found, falling back to body`), document.body.appendChild(i);
1969
+ console.warn(`Container with id "${t}" not found, falling back to body`), document.body.appendChild(i);
1943
1970
  }
1944
1971
  return () => {
1945
1972
  var u;
1946
1973
  (u = i.parentElement) == null || u.removeChild(i);
1947
1974
  };
1948
- }, [r, n, t, c]), c === "inline" && !n ? /* @__PURE__ */ m("div", { ref: o, style: a }) : null;
1975
+ }, [s, t, n, c]), c === "inline" && !t ? /* @__PURE__ */ m("div", { ref: a, style: o }) : null;
1949
1976
  };
1950
- class Ae extends HTMLElement {
1951
- constructor(n, s) {
1952
- var o;
1977
+ class Re extends HTMLElement {
1978
+ constructor(t, r) {
1979
+ var a;
1953
1980
  super();
1954
1981
  y(this, "shadow");
1955
1982
  y(this, "root", null);
1956
1983
  y(this, "commandRegistry");
1957
1984
  y(this, "config");
1958
- this.shadow = this.attachShadow({ mode: "open" }), this.commandRegistry = n, this.config = s;
1959
- const r = ((o = this.config) == null ? void 0 : o.displayMode) ?? "panel";
1960
- this.setAttribute("data-display-mode", r);
1985
+ this.shadow = this.attachShadow({ mode: "open" }), this.commandRegistry = t, this.config = r;
1986
+ const s = ((a = this.config) == null ? void 0 : a.displayMode) ?? "panel";
1987
+ this.setAttribute("data-display-mode", s);
1961
1988
  }
1962
1989
  connectedCallback() {
1963
1990
  try {
1964
- const s = [ye].map((r) => {
1965
- const o = new CSSStyleSheet();
1966
- return o.replaceSync(r), o;
1991
+ const r = [xe].map((s) => {
1992
+ const a = new CSSStyleSheet();
1993
+ return a.replaceSync(s), a;
1967
1994
  });
1968
- this.shadow.adoptedStyleSheets = [...s];
1995
+ this.shadow.adoptedStyleSheets = [...r];
1969
1996
  } catch {
1970
- const s = [ye].join(`
1971
- `), r = document.createElement("style");
1972
- r.textContent = s, this.shadow.appendChild(r);
1997
+ const r = [xe].join(`
1998
+ `), s = document.createElement("style");
1999
+ s.textContent = r, this.shadow.appendChild(s);
1973
2000
  }
1974
- const n = document.createElement("div");
1975
- n.id = "citadel-root", n.style.width = "100%", n.style.height = "100%", this.shadow.appendChild(n), this.root = Te(n), this.root.render(
1976
- /* @__PURE__ */ m(We, { config: this.config || x, commandRegistry: this.commandRegistry, children: /* @__PURE__ */ m(ct, {}) })
2001
+ const t = document.createElement("div");
2002
+ t.id = "citadel-root", t.style.width = "100%", t.style.height = "100%", this.shadow.appendChild(t), this.root = Le(t), this.root.render(
2003
+ /* @__PURE__ */ m(Ye, { config: this.config || E, commandRegistry: this.commandRegistry, children: /* @__PURE__ */ m(gt, {}) })
1977
2004
  );
1978
2005
  }
1979
2006
  disconnectedCallback() {
1980
- const n = this.root;
1981
- if (this.root = null, !n) {
2007
+ const t = this.root;
2008
+ if (this.root = null, !t) {
1982
2009
  this.shadow.replaceChildren();
1983
2010
  return;
1984
2011
  }
1985
2012
  queueMicrotask(() => {
1986
- n.unmount(), this.shadow.replaceChildren();
2013
+ t.unmount(), this.shadow.replaceChildren();
1987
2014
  });
1988
2015
  }
1989
2016
  }
1990
- typeof window < "u" && window.customElements && !window.customElements.get("citadel-element") && window.customElements.define("citadel-element", Ae);
1991
- const ct = () => (U().displayMode ?? "panel") === "inline" ? /* @__PURE__ */ m(it, {}) : /* @__PURE__ */ m(ot, {});
1992
- class lt {
2017
+ typeof window < "u" && window.customElements && !window.customElements.get("citadel-element") && window.customElements.define("citadel-element", Re);
2018
+ const gt = () => (j().displayMode ?? "panel") === "inline" ? /* @__PURE__ */ m(ht, {}) : /* @__PURE__ */ m(pt, {});
2019
+ class ft {
1993
2020
  constructor() {
1994
2021
  y(this, "_description");
1995
2022
  }
@@ -2000,13 +2027,13 @@ class lt {
2000
2027
  return this._description;
2001
2028
  }
2002
2029
  }
2003
- class dt {
2030
+ class yt {
2004
2031
  constructor(e) {
2005
2032
  y(this, "state");
2006
2033
  this.state = {
2007
2034
  path: e,
2008
2035
  description: "",
2009
- segments: mt(e)
2036
+ segments: wt(e)
2010
2037
  };
2011
2038
  }
2012
2039
  describe(e) {
@@ -2015,12 +2042,12 @@ class dt {
2015
2042
  details(e) {
2016
2043
  return this.state.details = e, this;
2017
2044
  }
2018
- arg(e, n) {
2019
- const s = new lt();
2020
- return n == null || n(s), this.state.segments.push({
2045
+ arg(e, t) {
2046
+ const r = new ft();
2047
+ return t == null || t(r), this.state.segments.push({
2021
2048
  type: "argument",
2022
2049
  name: e,
2023
- description: s.description
2050
+ description: r.description
2024
2051
  }), this;
2025
2052
  }
2026
2053
  handle(e) {
@@ -2033,90 +2060,90 @@ class dt {
2033
2060
  };
2034
2061
  }
2035
2062
  }
2036
- function mt(t) {
2037
- const e = t.trim();
2063
+ function wt(n) {
2064
+ const e = n.trim();
2038
2065
  if (!e)
2039
2066
  throw new Error("Command path cannot be empty");
2040
- const n = e.split(".");
2041
- if (n.some((s) => s.trim() === ""))
2042
- throw new Error(`Invalid command path "${t}". Empty segments are not allowed.`);
2043
- if (n.some((s) => s.includes(" ")))
2067
+ const t = e.split(".");
2068
+ if (t.some((r) => r.trim() === ""))
2069
+ throw new Error(`Invalid command path "${n}". Empty segments are not allowed.`);
2070
+ if (t.some((r) => r.includes(" ")))
2044
2071
  throw new Error(
2045
- `Invalid command path "${t}". Use dot-delimited words (e.g. "user.show").`
2072
+ `Invalid command path "${n}". Use dot-delimited words (e.g. "user.show").`
2046
2073
  );
2047
- return n.map((s) => ({
2074
+ return t.map((r) => ({
2048
2075
  type: "word",
2049
- name: s
2076
+ name: r
2050
2077
  }));
2051
2078
  }
2052
- function ut(t) {
2053
- return t.flatMap((e) => e.type === "argument" ? [e.name] : []);
2079
+ function Ct(n) {
2080
+ return n.flatMap((e) => e.type === "argument" ? [e.name] : []);
2054
2081
  }
2055
- function pt(t) {
2056
- const e = ut(t.segments);
2057
- return async (n) => {
2058
- const s = e.reduce((r, o, a) => (r[o] = n[a], r), {});
2082
+ function vt(n) {
2083
+ const e = Ct(n.segments);
2084
+ return async (t) => {
2085
+ const r = e.reduce((s, a, o) => (s[a] = t[o], s), {});
2059
2086
  return Promise.resolve(
2060
- t.handler({
2061
- rawArgs: n,
2062
- namedArgs: s,
2063
- commandPath: t.path
2087
+ n.handler({
2088
+ rawArgs: t,
2089
+ namedArgs: r,
2090
+ commandPath: n.path
2064
2091
  })
2065
2092
  );
2066
2093
  };
2067
2094
  }
2068
- function St(t) {
2069
- return new dt(t);
2095
+ function At(n) {
2096
+ return new yt(n);
2070
2097
  }
2071
- function ht(t, e) {
2072
- t.addCommand(
2098
+ function St(n, e) {
2099
+ n.addCommand(
2073
2100
  e.segments,
2074
2101
  e.description,
2075
- pt(e)
2102
+ vt(e)
2076
2103
  );
2077
2104
  }
2078
- function gt(t, e) {
2079
- return e.forEach((n) => ht(t, n)), t;
2105
+ function xt(n, e) {
2106
+ return e.forEach((t) => St(n, t)), n;
2080
2107
  }
2081
- function xt(t) {
2082
- const e = new ee();
2083
- return gt(e, t);
2108
+ function Pt(n) {
2109
+ const e = new se();
2110
+ return xt(e, n);
2084
2111
  }
2085
- function bt(t) {
2086
- return new G(t);
2112
+ function Ht(n) {
2113
+ return new ee(n);
2087
2114
  }
2088
- function kt(t, e = "true", n = "false") {
2089
- return new De(t, e, n);
2115
+ function _t(n, e = "true", t = "false") {
2116
+ return new $e(n, e, t);
2090
2117
  }
2091
- function Et(t) {
2092
- return new ze(t);
2118
+ function Rt(n) {
2119
+ return new Ue(n);
2093
2120
  }
2094
- function Nt(t, e = "") {
2095
- return new Fe(t, e);
2121
+ function Tt(n, e = "") {
2122
+ return new Ke(n, e);
2096
2123
  }
2097
- function At(t) {
2098
- return new we(t);
2124
+ function Mt(n) {
2125
+ return new be(n);
2099
2126
  }
2100
2127
  export {
2101
- De as BooleanCommandResult,
2102
- vt as Citadel,
2103
- ee as CommandRegistry,
2104
- K as CommandResult,
2105
- V as CommandStatus,
2106
- Ze as DEFAULT_CURSOR_CONFIGS,
2107
- we as ErrorCommandResult,
2108
- Fe as ImageCommandResult,
2109
- ze as JsonCommandResult,
2110
- oe as OutputItem,
2111
- Oe as PendingCommandResult,
2112
- G as TextCommandResult,
2113
- kt as bool,
2114
- St as command,
2115
- xt as createCommandRegistry,
2116
- At as error,
2117
- Nt as image,
2118
- Et as json,
2119
- ht as registerCommand,
2120
- gt as registerCommands,
2121
- bt as text
2128
+ $e as BooleanCommandResult,
2129
+ It as Citadel,
2130
+ se as CommandRegistry,
2131
+ W as CommandResult,
2132
+ Y as CommandStatus,
2133
+ st as DEFAULT_CURSOR_CONFIGS,
2134
+ be as ErrorCommandResult,
2135
+ Ke as ImageCommandResult,
2136
+ Ue as JsonCommandResult,
2137
+ de as OutputItem,
2138
+ je as PendingCommandResult,
2139
+ ee as TextCommandResult,
2140
+ _t as bool,
2141
+ At as command,
2142
+ Pt as createCommandRegistry,
2143
+ Mt as error,
2144
+ Tt as image,
2145
+ Rt as json,
2146
+ St as registerCommand,
2147
+ xt as registerCommands,
2148
+ Ht as text
2122
2149
  };