citadel_cli 1.1.4 → 1.1.5

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,44 +1,11 @@
1
- var pe = Object.defineProperty;
2
- var ge = (r, e, n) => e in r ? pe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
- var b = (r, e, n) => ge(r, typeof e != "symbol" ? e + "" : e, n);
4
- import { jsx as m, jsxs as N, Fragment as he } from "react/jsx-runtime";
5
- import L, { useEffect as _, useMemo as V, createContext as fe, useContext as Y, useState as R, useCallback as w, useReducer as we, useRef as U } from "react";
6
- import { createRoot as be } from "react-dom/client";
7
- const ye = ({ onOpen: r, onClose: e, isVisible: n, showCitadelKey: t }) => {
8
- _(() => {
9
- const o = (s) => {
10
- var i, c;
11
- !n && s.key === t && !["input", "textarea"].includes(((c = (i = s.target) == null ? void 0 : i.tagName) == null ? void 0 : c.toLowerCase()) || "") && (s.preventDefault(), r()), n && s.key === "Escape" && (s.preventDefault(), e());
12
- };
13
- return document.addEventListener("keydown", o), () => document.removeEventListener("keydown", o);
14
- }, [r, e, n, t]);
15
- }, xe = "_container_141sr_3", ve = "_innerContainer_141sr_19", Ce = "_inputSection_141sr_28", Se = "_resizeHandle_141sr_35", ke = "_citadel_slideUp_141sr_64", Ee = "_citadel_slideDown_141sr_68", Q = {
16
- container: xe,
17
- innerContainer: ve,
18
- inputSection: Ce,
19
- resizeHandle: Se,
20
- citadel_slideUp: ke,
21
- citadel_slideDown: Ee
22
- }, Ne = (r) => {
23
- const { isVisible: e, isClosing: n, onAnimationComplete: t } = r, o = V(() => e ? n ? Q.slideDown : Q.slideUp : "", [e, n]);
24
- return _(() => {
25
- if (t) {
26
- const i = setTimeout(() => {
27
- t();
28
- }, 200);
29
- return () => clearTimeout(i);
30
- }
31
- }, [n, t]), {
32
- style: V(() => ({
33
- opacity: e ? 1 : 0,
34
- transform: e ? "translateY(0)" : n ? "translateY(100%)" : "translateY(-100%)",
35
- transition: "opacity 200ms ease-in-out, transform 200ms ease-in-out"
36
- }), [e, n]),
37
- animationClass: o
38
- };
39
- };
40
- var M = /* @__PURE__ */ ((r) => (r.Pending = "pending", r.Success = "success", r.Failure = "failure", r.Timeout = "timeout", r))(M || {});
41
- class F {
1
+ var ge = Object.defineProperty;
2
+ var fe = (r, e, n) => e in r ? ge(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
+ var b = (r, e, n) => fe(r, typeof e != "symbol" ? e + "" : e, n);
4
+ import { jsx as m, jsxs as _, Fragment as we } from "react/jsx-runtime";
5
+ import L, { createContext as be, useEffect as A, useContext as Y, useState as R, useCallback as w, useMemo as V, useReducer as ye, useRef as H } from "react";
6
+ import { createRoot as xe } from "react-dom/client";
7
+ var T = /* @__PURE__ */ ((r) => (r.Pending = "pending", r.Success = "success", r.Failure = "failure", r.Timeout = "timeout", r))(T || {});
8
+ class U {
42
9
  constructor(e = Date.now()) {
43
10
  b(this, "_status", "pending");
44
11
  this.timestamp = e;
@@ -56,7 +23,7 @@ class F {
56
23
  this._status = "timeout";
57
24
  }
58
25
  }
59
- class nn extends F {
26
+ class an extends U {
60
27
  constructor(e, n) {
61
28
  super(n), this.data = e;
62
29
  }
@@ -64,7 +31,7 @@ class nn extends F {
64
31
  return /* @__PURE__ */ m("pre", { className: "text-gray-200", children: JSON.stringify(this.data, null, 2) });
65
32
  }
66
33
  }
67
- class oe extends F {
34
+ class ae extends U {
68
35
  constructor(e, n) {
69
36
  super(n), this.text = e;
70
37
  }
@@ -72,7 +39,7 @@ class oe extends F {
72
39
  return /* @__PURE__ */ m("div", { className: "text-gray-200 whitespace-pre font-mono", children: this.text });
73
40
  }
74
41
  }
75
- class _e extends F {
42
+ class ve extends U {
76
43
  constructor(e, n) {
77
44
  super(n), this.error = e, this.markFailure();
78
45
  }
@@ -80,12 +47,12 @@ class _e extends F {
80
47
  return /* @__PURE__ */ m("div", { className: "mt-1 text-red-400", children: this.error });
81
48
  }
82
49
  }
83
- class Ae extends F {
50
+ class Ce extends U {
84
51
  render() {
85
52
  return /* @__PURE__ */ m("div", { className: "text-gray-400", children: "..." });
86
53
  }
87
54
  }
88
- class tn extends F {
55
+ class ln extends U {
89
56
  constructor(e, n = "", t) {
90
57
  super(t), this.imageUrl = e, this.altText = n;
91
58
  }
@@ -100,9 +67,9 @@ class tn extends F {
100
67
  ) });
101
68
  }
102
69
  }
103
- const ze = (r) => async function() {
70
+ const Se = (r) => async function() {
104
71
  const e = r.commands.filter((n) => n.fullPath[0] !== "help").map((n) => `${n.segments.map((o) => o.type === "argument" ? `<${o.name}>` : o.name).join(" ")} - ${n.description}`).sort();
105
- return e.push("help - Show available commands"), new oe(
72
+ return e.push("help - Show available commands"), new ae(
106
73
  e.length > 0 ? `Available Commands:
107
74
  ` + e.join(`
108
75
  `) : "No commands available yet. Add some commands to get started!"
@@ -130,7 +97,7 @@ class C {
130
97
  }
131
98
  }
132
99
  b(C, "level", 0), b(C, "prefix", "");
133
- const A = {
100
+ const z = {
134
101
  commandTimeoutMs: 1e4,
135
102
  cursorColor: "var(--cursor-color, #fff)",
136
103
  cursorSpeed: 530,
@@ -143,12 +110,13 @@ const A = {
143
110
  outputFontSize: "0.875rem",
144
111
  resetStateOnHide: !1,
145
112
  showCitadelKey: ".",
113
+ displayMode: "panel",
146
114
  storage: {
147
115
  type: "localStorage",
148
116
  maxCommands: 100
149
117
  }
150
118
  };
151
- class se {
119
+ class ie {
152
120
  constructor(e) {
153
121
  b(this, "config");
154
122
  this.config = {
@@ -167,7 +135,7 @@ class se {
167
135
  await this.saveCommands(n);
168
136
  }
169
137
  }
170
- class Ie extends se {
138
+ class ke extends ie {
171
139
  constructor(n) {
172
140
  super(n);
173
141
  b(this, "storageKey", "citadel_command_history");
@@ -202,7 +170,7 @@ class Ie extends se {
202
170
  }
203
171
  }
204
172
  }
205
- class Re extends se {
173
+ class Ee extends ie {
206
174
  constructor(n) {
207
175
  super(n);
208
176
  b(this, "storedCommands", []);
@@ -233,9 +201,9 @@ const D = class D {
233
201
  initializeStorage(e) {
234
202
  if (!this.currentStorage)
235
203
  try {
236
- this.currentStorage = new Ie(e);
204
+ this.currentStorage = new ke(e);
237
205
  } catch (n) {
238
- console.warn("Failed to create storage, falling back to memory storage:", n), this.currentStorage = new Re(e);
206
+ console.warn("Failed to create storage, falling back to memory storage:", n), this.currentStorage = new Ee(e);
239
207
  }
240
208
  }
241
209
  getStorage() {
@@ -246,8 +214,8 @@ const D = class D {
246
214
  };
247
215
  b(D, "instance");
248
216
  let q = D;
249
- const ae = async () => new oe("");
250
- class G {
217
+ const le = async () => new ae("");
218
+ class J {
251
219
  constructor(e, n, t) {
252
220
  this.type = e, this.name = n, this.description = t;
253
221
  }
@@ -255,23 +223,23 @@ class G {
255
223
  return this.name;
256
224
  }
257
225
  }
258
- class ie extends G {
226
+ class ce extends J {
259
227
  constructor() {
260
228
  super("null", ">null<", "Empty segment");
261
229
  }
262
230
  }
263
- class Pe extends G {
231
+ class Ne extends J {
264
232
  constructor(e, n) {
265
233
  super("word", e, n);
266
234
  }
267
235
  }
268
- class He extends G {
236
+ class _e extends J {
269
237
  constructor(e, n, t, o) {
270
238
  super("argument", e, n), this.value = t, this.valid = o;
271
239
  }
272
240
  }
273
- class De {
274
- constructor(e, n, t = ae) {
241
+ class Ae {
242
+ constructor(e, n, t = le) {
275
243
  b(this, "_segments");
276
244
  b(this, "_description");
277
245
  // Used by `Help` command, etc.
@@ -300,7 +268,7 @@ class De {
300
268
  return this.fullPath.join(" ") === e.fullPath.join(" ");
301
269
  }
302
270
  }
303
- class J {
271
+ class Q {
304
272
  constructor() {
305
273
  b(this, "_commands", []);
306
274
  }
@@ -308,22 +276,26 @@ class J {
308
276
  return this._commands;
309
277
  }
310
278
  /**
311
- * Registers a new command
312
- *
313
- * @param newCommandNode The new command to add
314
- * @throws {Error} If attempting to add a duplicate leaf command or a subcommand to a leaf
315
- *
279
+ * Registers a new command composed of ordered segments.
280
+ *
281
+ * Each segment describes either a literal word or an argument placeholder. The resulting
282
+ * path must be unique across the registry once argument placeholders are normalized.
283
+ *
284
+ * @param segments Ordered command path definition.
285
+ * @param description Human-readable summary surfaced by help and search results.
286
+ * @param handler Async handler executed when the command is submitted; defaults to `NoopHandler`.
287
+ * @throws {Error} If the segment list is empty or the path collides with an existing command.
316
288
  */
317
- addCommand(e, n, t = ae) {
289
+ addCommand(e, n, t = le) {
318
290
  if (e === void 0 || e.length === 0)
319
291
  throw new Error("Command path cannot be empty");
320
- const o = new De(e, n, t), s = this._commands.find((i) => {
321
- const c = i.segments.map(
322
- (l) => l.type === "argument" ? "*" : l.name
292
+ const o = new Ae(e, n, t), s = this._commands.find((a) => {
293
+ const l = a.segments.map(
294
+ (c) => c.type === "argument" ? "*" : c.name
323
295
  ).join(" "), d = e.map(
324
- (l) => l.type === "argument" ? "*" : l.name
296
+ (c) => c.type === "argument" ? "*" : c.name
325
297
  ).join(" ");
326
- return c === d;
298
+ return l === d;
327
299
  });
328
300
  if (s)
329
301
  throw new Error(`Duplicate commands: '${s.fullPath_s}' and '${o.fullPath_s}'`);
@@ -340,8 +312,8 @@ class J {
340
312
  const t = n.fullPath.join(" "), o = e.join(" ");
341
313
  if (t === o)
342
314
  return !0;
343
- const i = n.segments.filter((c) => c.type === "word").map((c) => c.name);
344
- return i.length === e.length && i.join(" ") === o;
315
+ const a = n.segments.filter((l) => l.type === "word").map((l) => l.name);
316
+ return a.length === e.length && a.join(" ") === o;
345
317
  });
346
318
  }
347
319
  commandExistsForPath(e) {
@@ -350,9 +322,9 @@ class J {
350
322
  (s) => s.type === "argument" ? "*" : s.name
351
323
  ).join(" ")
352
324
  ), t = e.map((o, s) => this._commands.some(
353
- (c) => {
325
+ (l) => {
354
326
  var d;
355
- return ((d = c.segments[s]) == null ? void 0 : d.type) === "argument";
327
+ return ((d = l.segments[s]) == null ? void 0 : d.type) === "argument";
356
328
  }
357
329
  ) ? "*" : o).join(" ");
358
330
  return n.includes(t);
@@ -375,27 +347,27 @@ class J {
375
347
  */
376
348
  getCompletions(e) {
377
349
  if (C.debug("[getCompletions] path: ", e), !e.length) {
378
- const s = this._commands.map((d) => d.segments[0]), i = (d, l) => d.type === l.type && d.name === l.name;
350
+ const s = this._commands.map((d) => d.segments[0]), a = (d, c) => d.type === c.type && d.name === c.name;
379
351
  return s.filter(
380
- (d, l, u) => l === u.findIndex((p) => i(p, d))
352
+ (d, c, u) => c === u.findIndex((p) => a(p, d))
381
353
  );
382
354
  }
383
355
  const n = e.length;
384
356
  return this._commands.filter((s) => {
385
- const i = s.segments;
386
- if (i.length <= n - 1)
357
+ const a = s.segments;
358
+ if (a.length <= n - 1)
387
359
  return !1;
388
- for (let c = 0; c < n; c++) {
389
- const d = e[c], l = i[c];
390
- if (!(d === "*" && l.type === "argument") && d !== l.name)
360
+ for (let l = 0; l < n; l++) {
361
+ const d = e[l], c = a[l];
362
+ if (!(d === "*" && c.type === "argument") && d !== c.name)
391
363
  return !1;
392
364
  }
393
365
  return !0;
394
366
  }).filter((s) => s.segments.length > n).map((s) => {
395
- const i = s.segments[n], c = i.type === "argument" ? He : Pe;
396
- return new c(i.name, i.description);
367
+ const a = s.segments[n], l = a.type === "argument" ? _e : Ne;
368
+ return new l(a.name, a.description);
397
369
  }).filter(
398
- (s, i, c) => i === c.findIndex(
370
+ (s, a, l) => a === l.findIndex(
399
371
  (d) => d.type === s.type && d.name === s.name
400
372
  )
401
373
  );
@@ -404,10 +376,10 @@ class J {
404
376
  return this.getCompletions(e).length > 0;
405
377
  }
406
378
  }
407
- class le {
379
+ class de {
408
380
  constructor() {
409
381
  b(this, "segments", []);
410
- b(this, "nullSegment", new ie());
382
+ b(this, "nullSegment", new ce());
411
383
  b(this, "observers", []);
412
384
  }
413
385
  subscribe(e) {
@@ -491,105 +463,105 @@ class le {
491
463
  return [...this.segments];
492
464
  }
493
465
  }
494
- const Ue = {
495
- config: A,
496
- commands: new J(),
497
- segmentStack: new le()
498
- }, O = fe(Ue), Fe = ({ config: r = A, commandRegistry: e, children: n }) => {
466
+ const ze = {
467
+ config: z,
468
+ commands: new Q(),
469
+ segmentStack: new de()
470
+ }, j = be(ze), Ie = ({ config: r = z, commandRegistry: e, children: n }) => {
499
471
  const [t, o] = L.useState(), s = {
500
- ...A,
472
+ ...z,
501
473
  ...r,
502
474
  // Ensure nested objects are properly merged
503
475
  storage: {
504
- ...A.storage,
476
+ ...z.storage,
505
477
  ...r.storage
506
478
  },
507
479
  // Ensure explicit values from config take precedence
508
- cursorType: r.cursorType ?? A.cursorType,
509
- cursorColor: r.cursorColor ?? A.cursorColor,
510
- cursorSpeed: r.cursorSpeed ?? A.cursorSpeed,
480
+ cursorType: r.cursorType ?? z.cursorType,
481
+ cursorColor: r.cursorColor ?? z.cursorColor,
482
+ cursorSpeed: r.cursorSpeed ?? z.cursorSpeed,
511
483
  showCitadelKey: r.showCitadelKey || "."
512
484
  };
513
- _(() => {
485
+ A(() => {
514
486
  q.getInstance().initializeStorage(
515
- s.storage ?? A.storage
487
+ s.storage ?? z.storage
516
488
  ), o(q.getInstance().getStorage());
517
- }, []), _(() => {
489
+ }, []), A(() => {
518
490
  if (e && s.includeHelpCommand && !e.commandExistsForPath(["help"])) {
519
- const c = ze(e);
491
+ const l = Se(e);
520
492
  e.addCommand(
521
493
  [{ type: "word", name: "help" }],
522
494
  "Show available commands",
523
- c
495
+ l
524
496
  );
525
497
  }
526
498
  }, [e, s.includeHelpCommand]);
527
- const i = {
499
+ const a = {
528
500
  config: s,
529
- commands: e || new J(),
501
+ commands: e || new Q(),
530
502
  storage: t,
531
- segmentStack: new le()
503
+ segmentStack: new de()
532
504
  };
533
- return /* @__PURE__ */ m(O.Provider, { value: i, children: n });
534
- }, $ = () => {
535
- const r = Y(O);
505
+ return /* @__PURE__ */ m(j.Provider, { value: a, children: n });
506
+ }, F = () => {
507
+ const r = Y(j);
536
508
  if (r === void 0)
537
509
  throw new Error("useCitadelConfig must be used within a CitadelConfigProvider");
538
510
  return r.config;
539
511
  }, B = () => {
540
- const r = Y(O);
512
+ const r = Y(j);
541
513
  if (r === void 0)
542
514
  throw new Error("useCitadelCommands must be used within a CitadelConfigProvider");
543
515
  return r.commands;
544
- }, ce = () => {
545
- const r = Y(O);
516
+ }, me = () => {
517
+ const r = Y(j);
546
518
  if (r === void 0)
547
519
  throw new Error("useCitadelStorage must be used within a CitadelConfigProvider");
548
520
  return r.storage;
549
- }, K = () => {
550
- const r = Y(O);
521
+ }, O = () => {
522
+ const r = Y(j);
551
523
  if (r === void 0)
552
524
  throw new Error("useSegmentStack must be used within a CitadelConfigProvider");
553
525
  return r.segmentStack;
554
526
  };
555
- class Te {
527
+ class Re {
556
528
  constructor(e, n) {
557
529
  b(this, "timestamp");
558
530
  b(this, "command");
559
531
  b(this, "result");
560
- this.command = e.toArray().map((t) => t.type === "argument" ? t.value || "" : t.name), this.timestamp = Date.now(), this.result = n ?? new Ae();
532
+ this.command = e.toArray().map((t) => t.type === "argument" ? t.value || "" : t.name), this.timestamp = Date.now(), this.result = n ?? new Ce();
561
533
  }
562
534
  }
563
- function je(r) {
535
+ function Pe(r) {
564
536
  return {
565
537
  commandSegments: r,
566
538
  timestamp: Date.now()
567
539
  };
568
540
  }
569
- function de() {
570
- const r = ce(), [e, n] = R({
541
+ function ue() {
542
+ const r = me(), [e, n] = R({
571
543
  storedCommands: [],
572
544
  position: null
573
- }), t = w(async (c) => {
545
+ }), t = w(async (l) => {
574
546
  if (r)
575
547
  try {
576
- const d = je(c);
577
- await r.addStoredCommand(d), n((l) => ({
578
- ...l,
579
- storedCommands: [...l.storedCommands, d],
548
+ const d = Pe(l);
549
+ await r.addStoredCommand(d), n((c) => ({
550
+ ...c,
551
+ storedCommands: [...c.storedCommands, d],
580
552
  position: null
581
553
  }));
582
554
  } catch (d) {
583
555
  console.warn("Failed to save command to history:", d);
584
556
  }
585
557
  }, [r]), o = w(async () => r ? await r.getStoredCommands() : [], [r]);
586
- _(() => {
558
+ A(() => {
587
559
  if (!r) return;
588
560
  (async () => {
589
561
  try {
590
562
  const d = await r.getStoredCommands();
591
- return n((l) => ({
592
- ...l,
563
+ return n((c) => ({
564
+ ...c,
593
565
  storedCommands: d
594
566
  })), d;
595
567
  } catch (d) {
@@ -597,29 +569,29 @@ function de() {
597
569
  }
598
570
  })();
599
571
  }, [r]);
600
- const s = w(async (c) => {
572
+ const s = w(async (l) => {
601
573
  if ((await o()).length === 0)
602
574
  return { segments: null, position: null };
603
- let l = null;
604
- return c === "up" ? e.position === null ? l = e.storedCommands.length - 1 : e.position > 0 ? l = e.position - 1 : l = 0 : e.position === null || e.position >= e.storedCommands.length - 1 ? l = null : l = e.position + 1, n((p) => ({
575
+ let c = null;
576
+ return l === "up" ? e.position === null ? c = e.storedCommands.length - 1 : e.position > 0 ? c = e.position - 1 : c = 0 : e.position === null || e.position >= e.storedCommands.length - 1 ? c = null : c = e.position + 1, n((p) => ({
605
577
  ...p,
606
- position: l
607
- })), l === null ? {
578
+ position: c
579
+ })), c === null ? {
608
580
  segments: [],
609
581
  position: null
610
582
  } : {
611
- segments: l !== null ? e.storedCommands[l].commandSegments : null,
612
- position: l
583
+ segments: c !== null ? e.storedCommands[c].commandSegments : null,
584
+ position: c
613
585
  };
614
- }, [e, o]), i = w(async () => {
586
+ }, [e, o]), a = w(async () => {
615
587
  try {
616
588
  if (!r) return;
617
589
  await r.clear(), n({
618
590
  storedCommands: [],
619
591
  position: null
620
592
  });
621
- } catch (c) {
622
- console.warn("Failed to clear command history:", c);
593
+ } catch (l) {
594
+ console.warn("Failed to clear command history:", l);
623
595
  }
624
596
  }, [r]);
625
597
  return {
@@ -627,11 +599,11 @@ function de() {
627
599
  addStoredCommand: t,
628
600
  getStoredCommands: o,
629
601
  navigateHistory: s,
630
- clear: i
602
+ clear: a
631
603
  };
632
604
  }
633
- const me = () => {
634
- const r = $(), e = B(), n = de(), t = K(), o = ce(), [s, i] = R({
605
+ const X = () => {
606
+ const r = F(), e = B(), n = ue(), t = O(), o = me(), [s, a] = R({
635
607
  currentInput: "",
636
608
  isEnteringArg: !1,
637
609
  output: [],
@@ -641,9 +613,9 @@ const me = () => {
641
613
  storage: o
642
614
  }
643
615
  });
644
- _(() => {
645
- }, [o]), _(() => {
646
- i((u) => ({
616
+ A(() => {
617
+ }, [o]), A(() => {
618
+ a((u) => ({
647
619
  ...u,
648
620
  history: {
649
621
  commands: n.history.storedCommands,
@@ -652,15 +624,15 @@ const me = () => {
652
624
  }
653
625
  }));
654
626
  }, [n.history, o]);
655
- const c = {
627
+ const l = {
656
628
  setCurrentInput: w((u) => {
657
- C.debug("[CitadelActions] setCurrentInput: ", u), i((p) => ({ ...p, currentInput: u }));
629
+ C.debug("[CitadelActions] setCurrentInput: ", u), a((p) => ({ ...p, currentInput: u }));
658
630
  }, []),
659
631
  setIsEnteringArg: w((u) => {
660
- C.debug("[CitadelActions] setIsEnteringArg: ", u), i((p) => ({ ...p, isEnteringArg: u }));
632
+ C.debug("[CitadelActions] setIsEnteringArg: ", u), a((p) => ({ ...p, isEnteringArg: u }));
661
633
  }, []),
662
634
  addOutput: w((u) => {
663
- C.debug("[CitadelActions]addOutput: ", u), i((p) => ({
635
+ C.debug("[CitadelActions]addOutput: ", u), a((p) => ({
664
636
  ...p,
665
637
  output: [...p.output, u]
666
638
  }));
@@ -671,41 +643,41 @@ const me = () => {
671
643
  console.error("[CitadelActions][executeCommand] Cannot execute command because no command was found for the given path: ", u);
672
644
  return;
673
645
  }
674
- const S = new Te(t);
675
- i((y) => ({
646
+ const k = new Re(t);
647
+ a((y) => ({
676
648
  ...y,
677
- output: [...y.output, S]
649
+ output: [...y.output, k]
678
650
  }));
679
651
  try {
680
- const y = new Promise((a, g) => {
652
+ const y = new Promise((i, h) => {
681
653
  setTimeout(() => {
682
- g(new Error("Request timed out"));
654
+ h(new Error("Request timed out"));
683
655
  }, r.commandTimeoutMs);
684
- }), z = t.arguments.map((a) => a.value || ""), E = await Promise.race([
685
- p.handler(z),
656
+ }), E = t.arguments.map((i) => i.value || ""), N = await Promise.race([
657
+ p.handler(E),
686
658
  y
687
659
  ]);
688
- if (!(E instanceof F))
660
+ if (!(N instanceof U))
689
661
  throw new Error(
690
662
  `The ${u.join(".")} command returned an invalid result type. Commands must return an instance of a CommandResult.
691
663
  For example:
692
664
  return new JsonCommandResult({ text: "Hello World" });
693
665
  Check the definition of the ${u.join(".")} command and update the return type for its handler.`
694
666
  );
695
- E.markSuccess(), i((a) => ({
696
- ...a,
697
- output: a.output.map(
698
- (g) => g.timestamp === S.timestamp ? { ...g, result: E } : g
667
+ N.markSuccess(), a((i) => ({
668
+ ...i,
669
+ output: i.output.map(
670
+ (h) => h.timestamp === k.timestamp ? { ...h, result: N } : h
699
671
  )
700
672
  }));
701
673
  } catch (y) {
702
- const z = new _e(
674
+ const E = new ve(
703
675
  y instanceof Error ? y.message : "Unknown error"
704
676
  );
705
- z.markFailure(), i((E) => ({
706
- ...E,
707
- output: E.output.map(
708
- (a) => a.timestamp === S.timestamp ? { ...a, result: z } : a
677
+ E.markFailure(), a((N) => ({
678
+ ...N,
679
+ output: N.output.map(
680
+ (i) => i.timestamp === k.timestamp ? { ...i, result: E } : i
709
681
  )
710
682
  }));
711
683
  }
@@ -717,14 +689,126 @@ Check the definition of the ${u.join(".")} command and update the return type fo
717
689
  console.warn("Failed to clear history:", u);
718
690
  }
719
691
  }, [n])
720
- }, d = w(() => e.getCompletions_s(t.path()), [t, e]), l = w(() => e.getCompletions(t.path()), [t, e]);
692
+ }, d = w(() => e.getCompletions_s(t.path()), [t, e]), c = w(() => e.getCompletions(t.path()), [t, e]);
721
693
  return {
722
694
  state: s,
723
- actions: c,
695
+ actions: l,
724
696
  getAvailableCommands_s: d,
725
- getAvailableCommandSegments: l
697
+ getAvailableCommandSegments: c
726
698
  };
727
- }, Me = {
699
+ }, He = ({ onOpen: r, onClose: e, isVisible: n, showCitadelKey: t }) => {
700
+ A(() => {
701
+ const o = (s) => {
702
+ var a, l;
703
+ !n && s.key === t && !["input", "textarea"].includes(((l = (a = s.target) == null ? void 0 : a.tagName) == null ? void 0 : l.toLowerCase()) || "") && (s.preventDefault(), r()), n && s.key === "Escape" && (s.preventDefault(), e());
704
+ };
705
+ return document.addEventListener("keydown", o), () => document.removeEventListener("keydown", o);
706
+ }, [r, e, n, t]);
707
+ }, De = "_panelContainer_1pav9_3", Me = "_innerContainer_1pav9_19", Ue = "_inputSection_1pav9_29", Fe = "_resizeHandle_1pav9_36", Te = "_citadel_slideUp_1pav9_65", je = "_citadel_slideDown_1pav9_69", Oe = "_inlineContainer_1pav9_73", Z = {
708
+ panelContainer: De,
709
+ innerContainer: Me,
710
+ inputSection: Ue,
711
+ resizeHandle: Fe,
712
+ citadel_slideUp: Te,
713
+ citadel_slideDown: je,
714
+ inlineContainer: Oe
715
+ }, $e = (r) => {
716
+ const { isVisible: e, isClosing: n, onAnimationComplete: t } = r, o = V(() => e ? n ? Z.slideDown : Z.slideUp : "", [e, n]);
717
+ return A(() => {
718
+ if (t) {
719
+ const a = setTimeout(() => {
720
+ t();
721
+ }, 200);
722
+ return () => clearTimeout(a);
723
+ }
724
+ }, [n, t]), {
725
+ style: V(() => ({
726
+ opacity: e ? 1 : 0,
727
+ transform: e ? "translateY(0)" : n ? "translateY(100%)" : "translateY(-100%)",
728
+ transition: "opacity 200ms ease-in-out, transform 200ms ease-in-out"
729
+ }), [e, n]),
730
+ animationClass: o
731
+ };
732
+ }, Ke = () => /* @__PURE__ */ m(
733
+ "div",
734
+ {
735
+ "data-testid": "spinner",
736
+ className: "animate-spin rounded-full h-4 w-4 border-2 border-gray-300 border-t-gray-600"
737
+ }
738
+ ), Le = ({
739
+ command: r,
740
+ timestamp: e,
741
+ status: n
742
+ }) => /* @__PURE__ */ _("div", { className: "flex items-center gap-2 font-mono text-sm", children: [
743
+ /* @__PURE__ */ _("span", { className: "text-gray-200", children: [
744
+ "> ",
745
+ r.split(" ").map((t, o) => {
746
+ const s = t.startsWith("<") && t.endsWith(">");
747
+ return /* @__PURE__ */ _(
748
+ "span",
749
+ {
750
+ className: s ? "text-green-400" : "text-gray-200",
751
+ children: [
752
+ o > 0 ? " " : "",
753
+ t
754
+ ]
755
+ },
756
+ o
757
+ );
758
+ })
759
+ ] }),
760
+ /* @__PURE__ */ m("span", { className: "text-gray-400", children: "·" }),
761
+ /* @__PURE__ */ m("span", { className: "text-gray-500", children: e }),
762
+ n === T.Pending && /* @__PURE__ */ m(Ke, {}),
763
+ n === T.Success && /* @__PURE__ */ m(
764
+ "div",
765
+ {
766
+ "data-testid": "success-indicator",
767
+ className: "w-4 h-4 rounded-full bg-green-500"
768
+ }
769
+ ),
770
+ (n === T.Timeout || n === T.Failure) && /* @__PURE__ */ m(
771
+ "div",
772
+ {
773
+ "data-testid": "success-indicator",
774
+ className: "w-4 h-4 rounded-full bg-red-500"
775
+ }
776
+ )
777
+ ] }), Ve = ({ output: r, outputRef: e }) => {
778
+ const n = F(), t = w(() => {
779
+ if (e.current) {
780
+ const o = e.current;
781
+ requestAnimationFrame(() => {
782
+ o.scrollTop = o.scrollHeight;
783
+ });
784
+ }
785
+ }, [e]);
786
+ return A(() => {
787
+ if (t(), e.current) {
788
+ const o = e.current.getElementsByTagName("img"), s = o[o.length - 1];
789
+ if (s && !s.complete)
790
+ return s.addEventListener("load", t), () => s.removeEventListener("load", t);
791
+ }
792
+ }, [r, t, e]), /* @__PURE__ */ m(
793
+ "div",
794
+ {
795
+ ref: e,
796
+ className: "h-full overflow-y-auto border border-gray-700 rounded-lg p-3 text-left",
797
+ "data-testid": "citadel-command-output",
798
+ children: r.map((o, s) => /* @__PURE__ */ _("div", { className: "mb-4 last:mb-0", children: [
799
+ /* @__PURE__ */ m(
800
+ Le,
801
+ {
802
+ command: o.command.join(" "),
803
+ timestamp: new Date(o.timestamp).toLocaleTimeString(),
804
+ status: o.result.status
805
+ }
806
+ ),
807
+ /* @__PURE__ */ m("pre", { className: `text-gray-200 whitespace-pre font-mono ${n.outputFontSize}`, children: o.result.render() })
808
+ ] }, s))
809
+ }
810
+ );
811
+ }, We = {
728
812
  blink: {
729
813
  character: "▋",
730
814
  speed: 530,
@@ -745,19 +829,19 @@ Check the definition of the ${u.join(".")} command and update the return type fo
745
829
  speed: 120,
746
830
  color: "#fff"
747
831
  }
748
- }, X = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"], Z = ["|", "/", "-", "\\"], Oe = ({
832
+ }, ee = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"], ne = ["|", "/", "-", "\\"], qe = ({
749
833
  style: r = { type: "blink" },
750
834
  isValid: e = !0,
751
835
  errorMessage: n
752
836
  }) => {
753
837
  const t = V(() => ({
754
- ...Me[r.type],
838
+ ...We[r.type],
755
839
  ...r
756
- }), [r]), [o, s] = R(!0), [i, c] = R(0);
757
- _(() => {
840
+ }), [r]), [o, s] = R(!0), [a, l] = R(0);
841
+ A(() => {
758
842
  if (t.speed === 0) return;
759
843
  const u = setInterval(() => {
760
- t.type === "blink" ? s((p) => !p) : ["spin", "bbs"].includes(t.type) && c((p) => (p + 1) % (t.type === "bbs" ? Z.length : X.length));
844
+ t.type === "blink" ? s((p) => !p) : ["spin", "bbs"].includes(t.type) && l((p) => (p + 1) % (t.type === "bbs" ? ne.length : ee.length));
761
845
  }, t.speed);
762
846
  return () => clearInterval(u);
763
847
  }, [t.type, t.speed]);
@@ -771,11 +855,11 @@ Check the definition of the ${u.join(".")} command and update the return type fo
771
855
  className: `command-cursor ${e ? "" : "animate-shake"}`,
772
856
  style: d,
773
857
  title: n,
774
- children: !e && n ? "✗" : ["spin", "bbs"].includes(t.type) ? (t.type === "bbs" ? Z : X)[i] : t.type === "solid" || o ? t.character : " "
858
+ children: !e && n ? "✗" : ["spin", "bbs"].includes(t.type) ? (t.type === "bbs" ? ne : ee)[a] : t.type === "solid" || o ? t.character : " "
775
859
  }
776
860
  ) });
777
861
  };
778
- function $e(r, e) {
862
+ function Ye(r, e) {
779
863
  switch (e.type) {
780
864
  case "set":
781
865
  return C.debug(`[inputStateReducer] InputState changing from ${r} to ${e.state}`), e.state;
@@ -783,104 +867,102 @@ function $e(r, e) {
783
867
  return r;
784
868
  }
785
869
  }
786
- const Ke = () => {
787
- const { state: r } = me(), e = B(), n = de(), t = K(), [o, s] = we($e, "idle"), i = (a) => {
788
- s({ type: "set", state: a });
789
- }, c = w(() => {
790
- const g = e.getCompletions(t.path())[0] || t.nullSegment;
791
- return C.debug("[getNextExpectedSegment] ", g), g;
792
- }, [e, t]), d = w(() => e.getCompletions_s(t.path()).map((g) => e.getCommand([...t.path(), g])).filter((g) => g !== void 0), [e, t]), l = w((a, g) => {
793
- if (!a) return g;
794
- const h = g.reduce((f, x) => {
795
- const v = c();
870
+ const Be = () => {
871
+ const { state: r } = X(), e = B(), n = ue(), t = O(), [o, s] = ye(Ye, "idle"), a = (i) => {
872
+ s({ type: "set", state: i });
873
+ }, l = w(() => {
874
+ const h = e.getCompletions(t.path())[0] || t.nullSegment;
875
+ return C.debug("[getNextExpectedSegment] ", h), h;
876
+ }, [e, t]), d = w(() => e.getCompletions_s(t.path()).map((h) => e.getCommand([...t.path(), h])).filter((h) => h !== void 0), [e, t]), c = w((i, h) => {
877
+ if (!i) return h;
878
+ const g = h.reduce((f, x) => {
879
+ const v = l();
796
880
  return (v == null ? void 0 : v.type) === "word" && f.set(v.name, x), f;
797
881
  }, /* @__PURE__ */ new Map());
798
- return Array.from(h.values()).filter(() => {
799
- const f = c();
800
- return f.type !== "word" ? !1 : f.name.toLowerCase().startsWith(a.toLowerCase());
882
+ return Array.from(g.values()).filter(() => {
883
+ const f = l();
884
+ return f.type !== "word" ? !1 : f.name.toLowerCase().startsWith(i.toLowerCase());
801
885
  });
802
- }, [c]), u = w((a) => {
803
- const h = e.getCompletions(t.path()).filter((k) => k.type === "word").filter(
804
- (k) => k.name.toLowerCase().startsWith(a.toLowerCase())
886
+ }, [l]), u = w((i) => {
887
+ const g = e.getCompletions(t.path()).filter((S) => S.type === "word").filter(
888
+ (S) => S.name.toLowerCase().startsWith(i.toLowerCase())
805
889
  );
806
- return h.length === 1 ? h[0] : t.nullSegment;
807
- }, [e, t]), p = w((a) => {
808
- const g = t.path(), h = e.getCompletions(g);
809
- return h.length === 0 && a ? !1 : h.some((f) => f.type === "argument") ? !0 : h.some(
810
- (f) => f.type === "word" && f.name.toLowerCase().startsWith(a.toLowerCase())
890
+ return g.length === 1 ? g[0] : t.nullSegment;
891
+ }, [e, t]), p = w((i) => {
892
+ const h = t.path(), g = e.getCompletions(h);
893
+ return g.length === 0 && i ? !1 : g.some((f) => f.type === "argument") ? !0 : g.some(
894
+ (f) => f.type === "word" && f.name.toLowerCase().startsWith(i.toLowerCase())
811
895
  );
812
- }, [e, t]), S = w((a) => {
813
- C.debug("[tryAutoComplete] input: ", a);
814
- const g = u(a);
815
- return !g || g.name === a ? new ie() : (C.debug("[tryAutoComplete] result: ", g), g);
816
- }, [u]), y = w((a, g) => {
896
+ }, [e, t]), k = w((i) => {
897
+ C.debug("[tryAutoComplete] input: ", i);
898
+ const h = u(i);
899
+ return !h || h.name === i ? new ce() : (C.debug("[tryAutoComplete] result: ", h), h);
900
+ }, [u]), y = w((i, h) => {
817
901
  if (r.history.position === null) {
818
- if (g.setCurrentInput(a), C.debug("[useCommandParser][handleInputChange] newValue: ", a), o === "entering_argument") {
819
- const h = ee(a);
820
- if (h.isQuoted)
821
- if (h.isComplete) {
822
- const k = c();
823
- if (k.type === "argument") {
824
- const f = k;
825
- f.value = a.trim() || "", C.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", f), t.push(f), g.setCurrentInput(""), i("idle");
902
+ if (h.setCurrentInput(i), C.debug("[useCommandParser][handleInputChange] newValue: ", i), o === "entering_argument") {
903
+ const g = te(i);
904
+ if (g.isQuoted)
905
+ if (g.isComplete) {
906
+ const S = l();
907
+ if (S.type === "argument") {
908
+ const f = S;
909
+ f.value = i.trim() || "", C.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", f), t.push(f), h.setCurrentInput(""), a("idle");
826
910
  return;
827
911
  }
828
912
  } else
829
913
  return;
830
- else if (h.isComplete) {
831
- const k = c();
832
- k.value = a.trim() || "", C.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", k), t.push(k), g.setCurrentInput(""), i("idle");
914
+ else if (g.isComplete) {
915
+ const S = l();
916
+ S.value = i.trim() || "", C.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", S), t.push(S), h.setCurrentInput(""), a("idle");
833
917
  return;
834
918
  } else
835
919
  return;
836
920
  }
837
921
  if (o == "entering_command") {
838
- const h = S(a);
839
- if (h.type === "word") {
840
- C.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", h), t.push(h), g.setCurrentInput(""), i("idle");
922
+ const g = k(i);
923
+ if (g.type === "word") {
924
+ C.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", g), t.push(g), h.setCurrentInput(""), a("idle");
841
925
  return;
842
926
  }
843
927
  }
844
928
  }
845
- }, [S, r, c, o, t]), z = w((a) => {
846
- a.setCurrentInput(""), a.setIsEnteringArg(!1), t.clear(), i("idle");
847
- }, [t]), E = w((a, g, h) => {
848
- if (!(a.key === "Backspace" || a.key === "Enter" || a.key === "ArrowUp" || a.key === "ArrowDown" || a.key === "ArrowLeft" || a.key === "ArrowRight" || a.key === "Escape" || a.key === "Delete" || a.key === "Home" || a.key === "End" || a.key.length === 1))
929
+ }, [k, r, l, o, t]), E = w((i) => {
930
+ i.setCurrentInput(""), i.setIsEnteringArg(!1), t.clear(), a("idle");
931
+ }, [t]), N = w((i, h, g) => {
932
+ if (!(i.key === "Backspace" || i.key === "Enter" || i.key === "ArrowUp" || i.key === "ArrowDown" || i.key === "ArrowLeft" || i.key === "ArrowRight" || i.key === "Escape" || i.key === "Delete" || i.key === "Home" || i.key === "End" || i.key.length === 1))
849
933
  return !0;
850
- const { currentInput: f, isEnteringArg: x } = g, v = ee(f);
851
- switch (a.key) {
934
+ const { currentInput: f, isEnteringArg: x } = h, v = te(f);
935
+ switch (i.key) {
852
936
  case "Backspace":
853
- return f === "" && (a.preventDefault(), t.size() > 0 && t.pop(), i("idle")), !0;
937
+ return f === "" && (i.preventDefault(), t.size() > 0 && t.pop(), a("idle")), !0;
854
938
  case "Enter": {
855
- if (a.preventDefault(), v.isQuoted && !v.isComplete)
939
+ if (i.preventDefault(), v.isQuoted && !v.isComplete)
856
940
  return !0;
857
941
  if (o === "entering_argument" || x && f.trim()) {
858
- const H = c();
859
- H.value = f, C.debug("[handleKeyDown][Enter]['entering_argument'] pushing: ", H), t.push(H);
942
+ const G = l();
943
+ G.value = f, C.debug("[handleKeyDown][Enter]['entering_argument'] pushing: ", G), t.push(G);
860
944
  }
861
945
  const I = t.path(), P = e.getCommand(I);
862
- if (P) {
863
- const T = P.segments.filter((j) => j.type === "argument"), H = t.arguments;
864
- if (T.length > H.length)
865
- return !1;
866
- }
867
- return C.debug("[handleKeyDown][Enter] calling actions.executeCommand. segmentStack: ", t), h.executeCommand(), n.addStoredCommand(t.toArray()), z(h), !0;
946
+ if (!P)
947
+ return !1;
948
+ const $ = P.segments.filter((M) => M.type === "argument"), K = t.arguments;
949
+ return $.length > K.length ? !1 : (C.debug("[handleKeyDown][Enter] calling actions.executeCommand. segmentStack: ", t), g.executeCommand(), n.addStoredCommand(t.toArray()), E(g), !0);
868
950
  }
869
951
  case "ArrowUp":
870
- return a.preventDefault(), (async () => {
952
+ return i.preventDefault(), (async () => {
871
953
  const I = await n.navigateHistory("up", t.toArray());
872
- return I.segments && (t.clear(), t.pushAll(I.segments), h.setCurrentInput("")), !0;
954
+ return I.segments && (t.clear(), t.pushAll(I.segments), g.setCurrentInput("")), !0;
873
955
  })();
874
956
  case "ArrowDown":
875
- return a.preventDefault(), (async () => {
957
+ return i.preventDefault(), (async () => {
876
958
  const I = await n.navigateHistory("down", t.toArray());
877
- return I.segments && (t.clear(), t.pushAll(I.segments), h.setCurrentInput("")), !0;
959
+ return I.segments && (t.clear(), t.pushAll(I.segments), g.setCurrentInput("")), !0;
878
960
  })();
879
961
  default: {
880
- if (!x && a.key.length === 1) {
881
- const I = f + a.key;
962
+ if (!x && i.key.length === 1) {
963
+ const I = f + i.key;
882
964
  if (!p(I))
883
- return a.preventDefault(), !1;
965
+ return i.preventDefault(), !1;
884
966
  }
885
967
  return !0;
886
968
  }
@@ -888,30 +970,31 @@ const Ke = () => {
888
970
  }, [
889
971
  o,
890
972
  p,
891
- c,
973
+ l,
892
974
  n,
893
- z,
975
+ E,
976
+ e,
894
977
  t
895
978
  ]);
896
979
  return {
897
980
  handleInputChange: y,
898
- handleKeyDown: E,
981
+ handleKeyDown: N,
899
982
  inputState: o,
900
- setInputStateWithLogging: i,
983
+ setInputStateWithLogging: a,
901
984
  // Expose internal functions for testing
902
- findMatchingCommands: l,
985
+ findMatchingCommands: c,
903
986
  getAutocompleteSuggestion: u,
904
987
  getAvailableNodes: d,
905
- getNextExpectedSegment: c,
988
+ getNextExpectedSegment: l,
906
989
  isValidCommandInput: p
907
990
  };
908
991
  };
909
- function ee(r) {
992
+ function te(r) {
910
993
  const e = [];
911
994
  let n = "", t = !1, o;
912
995
  for (let s = 0; s < r.length; s++) {
913
- const i = r[s];
914
- (i === '"' || i === "'") && (!t || i === o) ? t ? (e.push(n), n = "", t = !1, o = void 0) : (n && (e.push(n), n = ""), t = !0, o = i) : !t && i === " " ? n && (e.push(n), n = "") : n += i;
996
+ const a = r[s];
997
+ (a === '"' || a === "'") && (!t || a === o) ? t ? (e.push(n), n = "", t = !1, o = void 0) : (n && (e.push(n), n = ""), t = !0, o = a) : !t && a === " " ? n && (e.push(n), n = "") : n += a;
915
998
  }
916
999
  return {
917
1000
  words: e,
@@ -921,9 +1004,9 @@ function ee(r) {
921
1004
  isComplete: !t && !n
922
1005
  };
923
1006
  }
924
- const Le = () => {
925
- const r = K(), [e, n] = R(0);
926
- return _(() => {
1007
+ const Ge = () => {
1008
+ const r = O(), [e, n] = R(0);
1009
+ return A(() => {
927
1010
  const t = {
928
1011
  update: () => {
929
1012
  n((o) => o + 1);
@@ -933,31 +1016,31 @@ const Le = () => {
933
1016
  r.unsubscribe(t);
934
1017
  };
935
1018
  }, [r]), e;
936
- }, Ve = ({
1019
+ }, Je = ({
937
1020
  state: r,
938
1021
  actions: e
939
1022
  }) => {
940
- const n = U(null), t = B(), o = K(), {
1023
+ const n = H(null), t = B(), o = O(), {
941
1024
  handleKeyDown: s,
942
- handleInputChange: i,
943
- inputState: c,
1025
+ handleInputChange: a,
1026
+ inputState: l,
944
1027
  setInputStateWithLogging: d,
945
- getNextExpectedSegment: l
946
- } = Ke(), [u, p] = R(!1), S = $(), y = Le(), z = async (x) => {
1028
+ getNextExpectedSegment: c
1029
+ } = Be(), [u, p] = R(!1), k = F(), y = Ge(), E = async (x) => {
947
1030
  const v = s(x, r, e);
948
1031
  await Promise.resolve(v) === !1 && (p(!0), setTimeout(() => p(!1), 500));
949
- }, E = (x) => {
950
- i(x.target.value, e);
951
- }, a = (x) => {
1032
+ }, N = (x) => {
1033
+ a(x.target.value, e);
1034
+ }, i = (x) => {
952
1035
  x.preventDefault();
953
1036
  const v = x.clipboardData.getData("text");
954
- i(v, e);
1037
+ a(v, e);
955
1038
  };
956
- _(() => {
957
- n.current && n.current.focus(), c !== "entering_command" && d("entering_command");
958
- }, [c, d]), _(() => {
959
- if (c !== "idle") return;
960
- const x = l();
1039
+ A(() => {
1040
+ n.current && n.current.focus(), l !== "entering_command" && d("entering_command");
1041
+ }, [l, d]), A(() => {
1042
+ if (l !== "idle") return;
1043
+ const x = c();
961
1044
  let v = "idle";
962
1045
  switch (x.type) {
963
1046
  case "word":
@@ -968,31 +1051,31 @@ const Le = () => {
968
1051
  break;
969
1052
  }
970
1053
  d(v);
971
- }, [y, c, l, d, e]);
972
- const [g, h] = R([]);
973
- _(() => {
974
- const x = [], v = o.toArray().map((P, T) => {
1054
+ }, [y, l, c, d, e]);
1055
+ const [h, g] = R([]);
1056
+ A(() => {
1057
+ const x = [], v = o.toArray().map((P, $) => {
975
1058
  x.push(P.name);
976
- const H = t.hasNextSegment(x);
1059
+ const K = t.hasNextSegment(x);
977
1060
  if (P.type === "argument") {
978
- const j = P;
979
- return /* @__PURE__ */ N(L.Fragment, { children: [
980
- /* @__PURE__ */ m("span", { className: "text-gray-200 whitespace-pre", children: j.value }),
981
- T < o.size() && H && /* @__PURE__ */ m("span", { className: "text-gray-200 whitespace-pre", children: " " })
982
- ] }, "arg-" + j.name + j.value);
1061
+ const M = P;
1062
+ return /* @__PURE__ */ _(L.Fragment, { children: [
1063
+ /* @__PURE__ */ m("span", { className: "text-gray-200 whitespace-pre", children: M.value }),
1064
+ $ < o.size() && K && /* @__PURE__ */ m("span", { className: "text-gray-200 whitespace-pre", children: " " })
1065
+ ] }, "arg-" + M.name + M.value);
983
1066
  }
984
- return /* @__PURE__ */ N(L.Fragment, { children: [
1067
+ return /* @__PURE__ */ _(L.Fragment, { children: [
985
1068
  /* @__PURE__ */ m("span", { className: "text-blue-400 whitespace-pre", children: P.name }),
986
- T < o.size() && H && /* @__PURE__ */ m("span", { className: "text-blue-400 whitespace-pre", children: " " })
1069
+ $ < o.size() && K && /* @__PURE__ */ m("span", { className: "text-blue-400 whitespace-pre", children: " " })
987
1070
  ] }, "word-" + P.name);
988
1071
  });
989
- h([/* @__PURE__ */ m("div", { className: "flex items-center gap-1", "data-testid": "user-input-area", children: v }, "{segmentStackVersion}")]);
1072
+ g([/* @__PURE__ */ m("div", { className: "flex items-center gap-1", "data-testid": "user-input-area", children: v }, "{segmentStackVersion}")]);
990
1073
  }, [y, t, o]);
991
- const [k, f] = R("");
992
- return _(() => {
993
- const x = l();
1074
+ const [S, f] = R("");
1075
+ return A(() => {
1076
+ const x = c();
994
1077
  x.type === "argument" ? f(x.name) : f("");
995
- }, [y, l]), /* @__PURE__ */ N("div", { className: "flex flex-col w-full bg-gray-900 rounded-lg p-4", children: [
1078
+ }, [y, c]), /* @__PURE__ */ _("div", { className: "flex flex-col w-full bg-gray-900 rounded-lg p-4", children: [
996
1079
  /* @__PURE__ */ m("style", { children: `
997
1080
  @keyframes subtleGlow {
998
1081
  0%, 100% { box-shadow: 0 0 0 rgba(239, 68, 68, 0); }
@@ -1002,11 +1085,11 @@ const Le = () => {
1002
1085
  animation: subtleGlow 0.4s ease-in-out;
1003
1086
  }
1004
1087
  ` }),
1005
- /* @__PURE__ */ N("div", { className: "flex items-center gap-2", children: [
1088
+ /* @__PURE__ */ _("div", { className: "flex items-center gap-2", children: [
1006
1089
  /* @__PURE__ */ m("div", { className: "text-gray-400 font-mono", children: ">" }),
1007
- /* @__PURE__ */ N("div", { className: "flex-1 font-mono flex items-center", children: [
1008
- g,
1009
- /* @__PURE__ */ N("div", { className: "relative flex-1", children: [
1090
+ /* @__PURE__ */ _("div", { className: "flex-1 font-mono flex items-center", children: [
1091
+ h,
1092
+ /* @__PURE__ */ _("div", { className: "relative flex-1", children: [
1010
1093
  /* @__PURE__ */ m(
1011
1094
  "input",
1012
1095
  {
@@ -1014,14 +1097,14 @@ const Le = () => {
1014
1097
  type: "text",
1015
1098
  role: "textbox",
1016
1099
  value: r.currentInput,
1017
- onChange: E,
1018
- onKeyDown: z,
1019
- onPaste: a,
1100
+ onChange: N,
1101
+ onKeyDown: E,
1102
+ onPaste: i,
1020
1103
  "data-testid": "citadel-command-input",
1021
1104
  className: `w-full bg-transparent outline-none text-gray-200 caret-transparent ${u ? "invalid-input-animation" : ""}`,
1022
1105
  spellCheck: !1,
1023
1106
  autoComplete: "off",
1024
- placeholder: k
1107
+ placeholder: S
1025
1108
  }
1026
1109
  ),
1027
1110
  /* @__PURE__ */ m(
@@ -1033,12 +1116,12 @@ const Le = () => {
1033
1116
  transition: "left 0.05s ease-out"
1034
1117
  },
1035
1118
  children: /* @__PURE__ */ m(
1036
- Oe,
1119
+ qe,
1037
1120
  {
1038
1121
  style: {
1039
- type: S.cursorType ?? A.cursorType,
1040
- color: S.cursorColor || A.cursorColor,
1041
- speed: S.cursorSpeed || A.cursorSpeed
1122
+ type: k.cursorType ?? z.cursorType,
1123
+ color: k.cursorColor || z.cursorColor,
1124
+ speed: k.cursorSpeed || z.cursorSpeed
1042
1125
  }
1043
1126
  }
1044
1127
  )
@@ -1048,105 +1131,27 @@ const Le = () => {
1048
1131
  ] })
1049
1132
  ] })
1050
1133
  ] });
1051
- }, We = () => /* @__PURE__ */ m(
1052
- "div",
1053
- {
1054
- "data-testid": "spinner",
1055
- className: "animate-spin rounded-full h-4 w-4 border-2 border-gray-300 border-t-gray-600"
1056
- }
1057
- ), qe = ({
1058
- command: r,
1059
- timestamp: e,
1060
- status: n
1061
- }) => /* @__PURE__ */ N("div", { className: "flex items-center gap-2 font-mono text-sm", children: [
1062
- /* @__PURE__ */ N("span", { className: "text-gray-200", children: [
1063
- "> ",
1064
- r.split(" ").map((t, o) => {
1065
- const s = t.startsWith("<") && t.endsWith(">");
1066
- return /* @__PURE__ */ N(
1067
- "span",
1068
- {
1069
- className: s ? "text-green-400" : "text-gray-200",
1070
- children: [
1071
- o > 0 ? " " : "",
1072
- t
1073
- ]
1074
- },
1075
- o
1076
- );
1077
- })
1078
- ] }),
1079
- /* @__PURE__ */ m("span", { className: "text-gray-400", children: "·" }),
1080
- /* @__PURE__ */ m("span", { className: "text-gray-500", children: e }),
1081
- n === M.Pending && /* @__PURE__ */ m(We, {}),
1082
- n === M.Success && /* @__PURE__ */ m(
1083
- "div",
1084
- {
1085
- "data-testid": "success-indicator",
1086
- className: "w-4 h-4 rounded-full bg-green-500"
1087
- }
1088
- ),
1089
- (n === M.Timeout || n === M.Failure) && /* @__PURE__ */ m(
1090
- "div",
1091
- {
1092
- "data-testid": "success-indicator",
1093
- className: "w-4 h-4 rounded-full bg-red-500"
1094
- }
1095
- )
1096
- ] }), Ye = ({ output: r, outputRef: e }) => {
1097
- const n = $(), t = w(() => {
1098
- if (e.current) {
1099
- const o = e.current;
1100
- requestAnimationFrame(() => {
1101
- o.scrollTop = o.scrollHeight;
1102
- });
1103
- }
1104
- }, [e]);
1105
- return _(() => {
1106
- if (t(), e.current) {
1107
- const o = e.current.getElementsByTagName("img"), s = o[o.length - 1];
1108
- if (s && !s.complete)
1109
- return s.addEventListener("load", t), () => s.removeEventListener("load", t);
1110
- }
1111
- }, [r, t, e]), /* @__PURE__ */ m(
1112
- "div",
1113
- {
1114
- ref: e,
1115
- className: "h-full overflow-y-auto border border-gray-700 rounded-lg p-3 text-left",
1116
- children: r.map((o, s) => /* @__PURE__ */ N("div", { className: "mb-4 last:mb-0", children: [
1117
- /* @__PURE__ */ m(
1118
- qe,
1119
- {
1120
- command: o.command.join(" "),
1121
- timestamp: new Date(o.timestamp).toLocaleTimeString(),
1122
- status: o.result.status
1123
- }
1124
- ),
1125
- /* @__PURE__ */ m("pre", { className: `text-gray-200 whitespace-pre font-mono ${n.outputFontSize}`, children: o.result.render() })
1126
- ] }, s))
1127
- }
1128
- );
1129
- }, Be = () => {
1130
- const r = B(), e = $(), n = K(), t = "h-12 mt-2 border-t border-gray-700 px-4", o = "text-gray-300 pt-2", s = r.getCompletions(n.path());
1134
+ }, Qe = () => {
1135
+ const r = B(), e = F(), n = O(), t = "h-12 mt-2 border-t border-gray-700 px-4", o = "text-gray-300 pt-2", s = r.getCompletions(n.path());
1131
1136
  C.debug("[AvailableCommands] nextCommandSegments: ", s);
1132
- const i = L.useMemo(() => {
1137
+ const a = L.useMemo(() => {
1133
1138
  if (e.includeHelpCommand) {
1134
- const l = s.filter((p) => p.name !== "help"), u = s.find((p) => p.name === "help");
1135
- return [...l, ...u ? [u] : []];
1139
+ const c = s.filter((p) => p.name !== "help"), u = s.find((p) => p.name === "help");
1140
+ return [...c, ...u ? [u] : []];
1136
1141
  }
1137
1142
  return s;
1138
- }, [s, e.includeHelpCommand]), c = s.some((l) => l.type === "argument"), d = s[0];
1139
- return /* @__PURE__ */ m("div", { className: t, "data-testid": "available-commands", children: /* @__PURE__ */ m("div", { className: o, children: c ? s.length > 0 ? /* @__PURE__ */ N(he, { children: [
1143
+ }, [s, e.includeHelpCommand]), l = s.some((c) => c.type === "argument"), d = s[0];
1144
+ return /* @__PURE__ */ m("div", { className: t, "data-testid": "available-commands", children: /* @__PURE__ */ m("div", { className: o, children: l ? s.length > 0 ? /* @__PURE__ */ _(we, { children: [
1140
1145
  /* @__PURE__ */ m("span", { className: "text-blue-400", children: d.name }),
1141
- d.description && /* @__PURE__ */ N("span", { className: "text-gray-400 ml-2", children: [
1146
+ d.description && /* @__PURE__ */ _("span", { className: "text-gray-400 ml-2", children: [
1142
1147
  "- ",
1143
1148
  d.description
1144
1149
  ] })
1145
- ] }) : null : /* @__PURE__ */ m("div", { className: "flex flex-wrap gap-2", children: i == null ? void 0 : i.map((l) => {
1146
- const u = i == null ? void 0 : i.reduce((p, S) => {
1147
- if (S === l) return p;
1150
+ ] }) : null : /* @__PURE__ */ m("div", { className: "flex flex-wrap gap-2", children: a == null ? void 0 : a.map((c) => {
1151
+ const u = a == null ? void 0 : a.reduce((p, k) => {
1152
+ if (k === c) return p;
1148
1153
  let y = 0;
1149
- for (; y < l.name.length && y < S.name.length && l.name[y].toLowerCase() === S.name[y].toLowerCase(); )
1154
+ for (; y < c.name.length && y < k.name.length && c.name[y].toLowerCase() === k.name[y].toLowerCase(); )
1150
1155
  y++;
1151
1156
  return Math.max(p, y + 1);
1152
1157
  }, 1);
@@ -1154,15 +1159,95 @@ const Le = () => {
1154
1159
  "div",
1155
1160
  {
1156
1161
  className: "px-2 py-1 rounded bg-gray-800 mr-2 last:mr-0",
1157
- children: /* @__PURE__ */ N("span", { className: "font-mono text-white", children: [
1158
- /* @__PURE__ */ m("strong", { className: "underline", children: l.name.slice(0, u) }),
1159
- l.name.slice(u)
1162
+ children: /* @__PURE__ */ _("span", { className: "font-mono text-white", children: [
1163
+ /* @__PURE__ */ m("strong", { className: "underline", children: c.name.slice(0, u) }),
1164
+ c.name.slice(u)
1160
1165
  ] })
1161
1166
  },
1162
- l.name
1167
+ c.name
1163
1168
  );
1164
1169
  }) }) }) });
1165
- }, ne = `:host {
1170
+ }, pe = ({
1171
+ state: r,
1172
+ actions: e,
1173
+ outputRef: n
1174
+ }) => /* @__PURE__ */ _("div", { className: "innerContainer", children: [
1175
+ /* @__PURE__ */ m("div", { className: "flex-1 min-h-0 pt-3 px-4", children: /* @__PURE__ */ m(Ve, { output: r.output, outputRef: n }) }),
1176
+ /* @__PURE__ */ _("div", { children: [
1177
+ /* @__PURE__ */ m(Je, { state: r, actions: e }),
1178
+ /* @__PURE__ */ m(Qe, {})
1179
+ ] })
1180
+ ] }), Xe = () => {
1181
+ const [r, e] = R(!1), [n, t] = R(!1), o = F(), [s, a] = R(() => o.initialHeight || null), l = H(null), d = H(null), c = H(!1), u = H(0), p = H(0), { state: k, actions: y } = X();
1182
+ He({
1183
+ onOpen: () => e(!0),
1184
+ onClose: () => t(!0),
1185
+ isVisible: r,
1186
+ showCitadelKey: o.showCitadelKey || "."
1187
+ });
1188
+ const E = w((g) => {
1189
+ var v;
1190
+ if (!c.current) return;
1191
+ const S = g.clientY - u.current, f = (v = o.maxHeight) != null && v.endsWith("vh") ? window.innerHeight * parseInt(o.maxHeight, 10) / 100 : parseInt(o.maxHeight || "80vh", 10), x = Math.min(
1192
+ Math.max(p.current - S, parseInt(o.minHeight || "200", 10)),
1193
+ f
1194
+ );
1195
+ d.current && (d.current.style.height = `${x}px`, d.current.style.bottom = "0", a(`${x}px`));
1196
+ }, [o.maxHeight, o.minHeight]), N = w(() => {
1197
+ c.current = !1, document.documentElement.style.userSelect = "", document.documentElement.style.webkitUserSelect = "", document.documentElement.style.mozUserSelect = "", document.documentElement.style.msUserSelect = "", document.removeEventListener("mousemove", E), document.removeEventListener("mouseup", N);
1198
+ }, [E]), i = w((g) => {
1199
+ d.current && (c.current = !0, u.current = g.clientY, p.current = d.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", E), document.addEventListener("mouseup", N));
1200
+ }, [E, N]);
1201
+ A(() => () => {
1202
+ document.removeEventListener("mousemove", E), document.removeEventListener("mouseup", N);
1203
+ }, [E, N]);
1204
+ const h = w(() => {
1205
+ n && (e(!1), t(!1));
1206
+ }, [n]);
1207
+ return $e({
1208
+ isVisible: r,
1209
+ isClosing: n,
1210
+ onAnimationComplete: h
1211
+ }), r ? /* @__PURE__ */ _(
1212
+ "div",
1213
+ {
1214
+ ref: d,
1215
+ className: `panelContainer ${r ? "citadel_slideUp" : ""} ${n ? "citadel_slideDown" : ""}`,
1216
+ style: {
1217
+ ...s ? { height: s } : void 0,
1218
+ maxHeight: o.maxHeight
1219
+ },
1220
+ children: [
1221
+ /* @__PURE__ */ m("div", { className: "resizeHandle", onMouseDown: i }),
1222
+ /* @__PURE__ */ m(
1223
+ pe,
1224
+ {
1225
+ state: k,
1226
+ actions: y,
1227
+ outputRef: l
1228
+ }
1229
+ )
1230
+ ]
1231
+ }
1232
+ ) : null;
1233
+ }, Ze = () => {
1234
+ const { state: r, actions: e } = X(), n = H(null);
1235
+ return /* @__PURE__ */ m(
1236
+ "div",
1237
+ {
1238
+ className: "inlineContainer",
1239
+ "data-testid": "citadel-inline-container",
1240
+ children: /* @__PURE__ */ m(
1241
+ pe,
1242
+ {
1243
+ state: r,
1244
+ actions: e,
1245
+ outputRef: n
1246
+ }
1247
+ )
1248
+ }
1249
+ );
1250
+ }, re = `:host {
1166
1251
  --citadel-bg: rgb(17, 24, 39);
1167
1252
  --citadel-text: rgba(255, 255, 255, 0.87);
1168
1253
  --citadel-border: rgb(55, 65, 81);
@@ -1173,23 +1258,38 @@ const Le = () => {
1173
1258
  --citadel-default-height: 35vh;
1174
1259
  --citadel-error: rgb(239, 68, 68);
1175
1260
 
1176
- height: var(--citadel-default-height);
1177
- max-height: var(--citadel-max-height);
1178
- min-height: var(--citadel-min-height);
1179
- width: 100%;
1261
+ display: block;
1262
+ pointer-events: auto;
1263
+ font-synthesis: none;
1264
+ text-rendering: optimizeLegibility;
1265
+ -webkit-font-smoothing: antialiased;
1266
+ -moz-osx-font-smoothing: grayscale;
1267
+ }
1180
1268
 
1269
+ :host([data-display-mode="panel"]) {
1181
1270
  position: fixed;
1182
1271
  bottom: 0;
1183
1272
  left: 0;
1184
1273
  right: 0;
1274
+ width: 100%;
1275
+ height: var(--citadel-default-height);
1276
+ max-height: var(--citadel-max-height);
1277
+ min-height: var(--citadel-min-height);
1185
1278
  z-index: 2147483647; /* Maximum z-index value */
1186
1279
  overflow: hidden;
1280
+ }
1187
1281
 
1188
- pointer-events: auto;
1189
- font-synthesis: none;
1190
- text-rendering: optimizeLegibility;
1191
- -webkit-font-smoothing: antialiased;
1192
- -moz-osx-font-smoothing: grayscale;
1282
+ :host([data-display-mode="inline"]) {
1283
+ position: relative;
1284
+ bottom: auto;
1285
+ left: auto;
1286
+ right: auto;
1287
+ z-index: auto;
1288
+ width: 100%;
1289
+ height: 100%;
1290
+ max-height: none;
1291
+ min-height: 0;
1292
+ overflow: hidden;
1193
1293
  }
1194
1294
 
1195
1295
  button {
@@ -1251,10 +1351,9 @@ a:hover {
1251
1351
  .text-left {
1252
1352
  text-align: left;
1253
1353
  }
1354
+ `, oe = `/* Keep only component-specific styles here */
1254
1355
 
1255
- `, te = `/* Keep only component-specific styles here */
1256
-
1257
- .container {
1356
+ .panelContainer {
1258
1357
  position: fixed;
1259
1358
  height: var(--citadel-default-height);
1260
1359
  min-height: var(--citadel-min-height);
@@ -1272,6 +1371,7 @@ a:hover {
1272
1371
 
1273
1372
  .innerContainer {
1274
1373
  height: 100%;
1374
+ flex: 1;
1275
1375
  width: 100%;
1276
1376
  display: flex;
1277
1377
  flex-direction: column;
@@ -1322,10 +1422,21 @@ a:hover {
1322
1422
  .citadel_slideDown {
1323
1423
  animation: citadel_slideDown 0.2s ease-out forwards;
1324
1424
  }
1325
- `, re = `@tailwind base;
1425
+
1426
+ .inlineContainer {
1427
+ position: relative;
1428
+ width: 100%;
1429
+ height: 100%;
1430
+ display: flex;
1431
+ flex-direction: column;
1432
+ background-color: var(--citadel-bg);
1433
+ overflow: hidden;
1434
+ box-sizing: border-box;
1435
+ }
1436
+ `, se = `@tailwind base;
1326
1437
  @tailwind components;
1327
1438
  @tailwind utilities;
1328
- `, Ge = `*, ::before, ::after {
1439
+ `, en = `*, ::before, ::after {
1329
1440
  --tw-border-spacing-x: 0;
1330
1441
  --tw-border-spacing-y: 0;
1331
1442
  --tw-translate-x: 0;
@@ -2142,112 +2253,75 @@ video {
2142
2253
  .last\\:mr-0:last-child {
2143
2254
  margin-right: 0px;
2144
2255
  }
2145
- `, rn = ({
2146
- config: r = A,
2147
- commandRegistry: e = new J(),
2256
+ `, cn = ({
2257
+ config: r = z,
2258
+ commandRegistry: e = new Q(),
2148
2259
  containerId: n = null
2149
- }) => (_(() => {
2150
- C.configure({
2151
- level: r.logLevel || A.logLevel || W.ERROR,
2152
- prefix: "[Citadel]"
2153
- });
2154
- const t = new ue(e, r), o = n ? document.getElementById(n) : document.body;
2155
- return o ? o.appendChild(t) : (console.warn(`Container with id "${n}" not found, falling back to body`), document.body.appendChild(t)), () => {
2156
- var s;
2157
- (s = t.parentElement) == null || s.removeChild(t);
2158
- };
2159
- }, [e, n, r]), null);
2160
- class ue extends HTMLElement {
2260
+ }) => {
2261
+ const t = H(null), o = r.displayMode ?? z.displayMode ?? "panel";
2262
+ return A(() => {
2263
+ C.configure({
2264
+ level: r.logLevel || z.logLevel || W.ERROR,
2265
+ prefix: "[Citadel]"
2266
+ });
2267
+ const s = new he(e, r), a = o === "inline" && !n, l = a ? t.current : n ? document.getElementById(n) : document.body;
2268
+ if (l)
2269
+ l.appendChild(s);
2270
+ else {
2271
+ if (a) {
2272
+ console.warn("[Citadel] No host available for inline mode; skipping mount.");
2273
+ return;
2274
+ }
2275
+ console.warn(`Container with id "${n}" not found, falling back to body`), document.body.appendChild(s);
2276
+ }
2277
+ return () => {
2278
+ var d;
2279
+ (d = s.parentElement) == null || d.removeChild(s);
2280
+ };
2281
+ }, [e, n, r, o]), o === "inline" && !n ? /* @__PURE__ */ m("div", { ref: t, style: { width: "100%", height: "100%" } }) : null;
2282
+ };
2283
+ class he extends HTMLElement {
2161
2284
  constructor(n, t) {
2285
+ var s;
2162
2286
  super();
2163
2287
  b(this, "shadow");
2164
2288
  b(this, "root", null);
2165
2289
  b(this, "commandRegistry");
2166
2290
  b(this, "config");
2167
2291
  this.shadow = this.attachShadow({ mode: "open" }), this.commandRegistry = n, this.config = t;
2292
+ const o = ((s = this.config) == null ? void 0 : s.displayMode) ?? "panel";
2293
+ this.setAttribute("data-display-mode", o);
2168
2294
  }
2169
2295
  connectedCallback() {
2170
2296
  try {
2171
- const t = [ne, te, re, Ge].map((o) => {
2297
+ const t = [re, oe, se, en].map((o) => {
2172
2298
  const s = new CSSStyleSheet();
2173
2299
  return s.replaceSync(o), s;
2174
2300
  });
2175
2301
  this.shadow.adoptedStyleSheets = [...t];
2176
2302
  } catch {
2177
- const t = [ne, te, re].join(`
2303
+ const t = [re, oe, se].join(`
2178
2304
  `), o = document.createElement("style");
2179
2305
  o.textContent = t, this.shadow.appendChild(o);
2180
2306
  }
2181
2307
  const n = document.createElement("div");
2182
- n.id = "citadel-root", this.shadow.appendChild(n), this.root = be(n), this.root.render(
2183
- /* @__PURE__ */ m(Fe, { config: this.config || A, commandRegistry: this.commandRegistry, children: /* @__PURE__ */ m(Je, {}) })
2308
+ n.id = "citadel-root", n.style.width = "100%", n.style.height = "100%", this.shadow.appendChild(n), this.root = xe(n), this.root.render(
2309
+ /* @__PURE__ */ m(Ie, { config: this.config || z, commandRegistry: this.commandRegistry, children: /* @__PURE__ */ m(nn, {}) })
2184
2310
  );
2185
2311
  }
2186
2312
  }
2187
- customElements.define("citadel-element", ue);
2188
- const Je = () => {
2189
- const [r, e] = R(!1), [n, t] = R(!1), o = $(), [s, i] = R(() => o.initialHeight || null), c = U(null), d = U(null), l = U(!1), u = U(0), p = U(0), { state: S, actions: y } = me();
2190
- ye({
2191
- onOpen: () => e(!0),
2192
- onClose: () => t(!0),
2193
- isVisible: r,
2194
- showCitadelKey: o.showCitadelKey || "."
2195
- });
2196
- const z = w((h) => {
2197
- d.current && (l.current = !0, u.current = h.clientY, p.current = d.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", E), document.addEventListener("mouseup", a));
2198
- }, []), E = w((h) => {
2199
- var v;
2200
- if (!l.current) return;
2201
- const k = h.clientY - u.current, f = (v = o.maxHeight) != null && v.endsWith("vh") ? window.innerHeight * parseInt(o.maxHeight, 10) / 100 : parseInt(o.maxHeight || "80vh", 10), x = Math.min(
2202
- Math.max(p.current - k, parseInt(o.minHeight || "200", 10)),
2203
- f
2204
- );
2205
- d.current && (d.current.style.height = `${x}px`, d.current.style.bottom = "0", i(`${x}px`));
2206
- }, [o.maxHeight, o.minHeight]), a = w(() => {
2207
- l.current = !1, document.documentElement.style.userSelect = "", document.documentElement.style.webkitUserSelect = "", document.documentElement.style.mozUserSelect = "", document.documentElement.style.msUserSelect = "", document.removeEventListener("mousemove", E), document.removeEventListener("mouseup", a);
2208
- }, [E]);
2209
- _(() => () => {
2210
- document.removeEventListener("mousemove", E), document.removeEventListener("mouseup", a);
2211
- }, [E, a]);
2212
- const g = w(() => {
2213
- n && (e(!1), t(!1));
2214
- }, [n]);
2215
- return Ne({
2216
- isVisible: r,
2217
- isClosing: n,
2218
- onAnimationComplete: g
2219
- }), r ? /* @__PURE__ */ N(
2220
- "div",
2221
- {
2222
- ref: d,
2223
- className: `container ${r ? "citadel_slideUp" : ""} ${n ? "citadel_slideDown" : ""}`,
2224
- style: {
2225
- ...s ? { height: s } : void 0,
2226
- maxHeight: o.maxHeight
2227
- },
2228
- children: [
2229
- /* @__PURE__ */ m("div", { className: "resizeHandle", onMouseDown: z }),
2230
- /* @__PURE__ */ N("div", { className: "innerContainer", children: [
2231
- /* @__PURE__ */ m("div", { className: "flex-1 min-h-0 pt-3 px-4", children: /* @__PURE__ */ m(Ye, { output: S.output, outputRef: c }) }),
2232
- /* @__PURE__ */ N("div", { children: [
2233
- /* @__PURE__ */ m(Ve, { state: S, actions: y }),
2234
- /* @__PURE__ */ m(Be, {})
2235
- ] })
2236
- ] })
2237
- ]
2238
- }
2239
- ) : null;
2240
- };
2313
+ customElements.define("citadel-element", he);
2314
+ const nn = () => (F().displayMode ?? "panel") === "inline" ? /* @__PURE__ */ m(Ze, {}) : /* @__PURE__ */ m(Xe, {});
2241
2315
  export {
2242
- rn as Citadel,
2243
- J as CommandRegistry,
2244
- F as CommandResult,
2245
- M as CommandStatus,
2246
- Me as DEFAULT_CURSOR_CONFIGS,
2247
- _e as ErrorCommandResult,
2248
- tn as ImageCommandResult,
2249
- nn as JsonCommandResult,
2250
- Te as OutputItem,
2251
- Ae as PendingCommandResult,
2252
- oe as TextCommandResult
2316
+ cn as Citadel,
2317
+ Q as CommandRegistry,
2318
+ U as CommandResult,
2319
+ T as CommandStatus,
2320
+ We as DEFAULT_CURSOR_CONFIGS,
2321
+ ve as ErrorCommandResult,
2322
+ ln as ImageCommandResult,
2323
+ an as JsonCommandResult,
2324
+ Re as OutputItem,
2325
+ Ce as PendingCommandResult,
2326
+ ae as TextCommandResult
2253
2327
  };