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