@space-lens/cli 0.2.0 → 0.2.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.
package/dist/cli.mjs CHANGED
@@ -1,48 +1,4138 @@
1
- #!/usr/bin/env bun
2
- import { n as SORT_MODES, r as normalizeCliConfig } from "./cli-config-AZ8GhaEx.mjs";
1
+ import { a as formatBytes, c as SORT_MODES, i as createScanViewModel, l as normalizeCliConfig, n as createCleanViewModel, o as getSelectedEntries, r as createInitialTuiState, t as applyTuiAction } from "./assets/model-D5_IMhZA.js";
3
2
  import { Args, Command, Options } from "@effect/cli";
4
3
  import * as NodeContext from "@effect/platform-node/NodeContext";
5
4
  import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
6
5
  import { Effect } from "effect";
7
- //#region src/runtime.ts
8
- function isBunRuntime(runtime = globalThis) {
9
- return runtime.Bun !== void 0;
6
+ import { AnsiCellSurface, FocusManager, FrameClock, StyleTable, StyleTable as StyleTable$1, TerminalDriver, TextInputMachine, TuiRenderer, clampScroll, hitTest, scrollbarThumb, toInputKey } from "@uniview/tui-core";
7
+ import { common, createLowlight } from "lowlight";
8
+ import "marked";
9
+ //#region ../../node_modules/solid-js/dist/solid.js
10
+ var sharedConfig = {
11
+ context: void 0,
12
+ registry: void 0,
13
+ effects: void 0,
14
+ done: false,
15
+ getContextId() {
16
+ return getContextId(this.context.count);
17
+ },
18
+ getNextContextId() {
19
+ return getContextId(this.context.count++);
20
+ }
21
+ };
22
+ function getContextId(count) {
23
+ const num = String(count), len = num.length - 1;
24
+ return sharedConfig.context.id + (len ? String.fromCharCode(96 + len) : "") + num;
25
+ }
26
+ function setHydrateContext(context) {
27
+ sharedConfig.context = context;
28
+ }
29
+ function nextHydrateContext() {
30
+ return {
31
+ ...sharedConfig.context,
32
+ id: sharedConfig.getNextContextId(),
33
+ count: 0
34
+ };
35
+ }
36
+ var equalFn = (a, b) => a === b;
37
+ var $PROXY = Symbol("solid-proxy");
38
+ var SUPPORTS_PROXY = typeof Proxy === "function";
39
+ var $TRACK = Symbol("solid-track");
40
+ var signalOptions = { equals: equalFn };
41
+ var ERROR = null;
42
+ var runEffects = runQueue;
43
+ var STALE = 1;
44
+ var PENDING = 2;
45
+ var UNOWNED = {
46
+ owned: null,
47
+ cleanups: null,
48
+ context: null,
49
+ owner: null
50
+ };
51
+ var Owner = null;
52
+ var Transition = null;
53
+ var Scheduler = null;
54
+ var ExternalSourceConfig = null;
55
+ var Listener = null;
56
+ var Updates = null;
57
+ var Effects = null;
58
+ var ExecCount = 0;
59
+ function createRoot(fn, detachedOwner) {
60
+ const listener = Listener, owner = Owner, unowned = fn.length === 0, current = detachedOwner === void 0 ? owner : detachedOwner, root = unowned ? UNOWNED : {
61
+ owned: null,
62
+ cleanups: null,
63
+ context: current ? current.context : null,
64
+ owner: current
65
+ }, updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
66
+ Owner = root;
67
+ Listener = null;
68
+ try {
69
+ return runUpdates(updateFn, true);
70
+ } finally {
71
+ Listener = listener;
72
+ Owner = owner;
73
+ }
74
+ }
75
+ function createSignal(value, options) {
76
+ options = options ? Object.assign({}, signalOptions, options) : signalOptions;
77
+ const s = {
78
+ value,
79
+ observers: null,
80
+ observerSlots: null,
81
+ comparator: options.equals || void 0
82
+ };
83
+ const setter = (value) => {
84
+ if (typeof value === "function") {
85
+ if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
86
+ else value = value(s.value);
87
+ }
88
+ return writeSignal(s, value);
89
+ };
90
+ return [readSignal.bind(s), setter];
91
+ }
92
+ function createRenderEffect(fn, value, options) {
93
+ const c = createComputation(fn, value, false, STALE);
94
+ if (Scheduler && Transition && Transition.running) Updates.push(c);
95
+ else updateComputation(c);
96
+ }
97
+ function createEffect(fn, value, options) {
98
+ runEffects = runUserEffects;
99
+ const c = createComputation(fn, value, false, STALE), s = SuspenseContext && useContext(SuspenseContext);
100
+ if (s) c.suspense = s;
101
+ if (!options || !options.render) c.user = true;
102
+ Effects ? Effects.push(c) : updateComputation(c);
103
+ }
104
+ function createMemo(fn, value, options) {
105
+ options = options ? Object.assign({}, signalOptions, options) : signalOptions;
106
+ const c = createComputation(fn, value, true, 0);
107
+ c.observers = null;
108
+ c.observerSlots = null;
109
+ c.comparator = options.equals || void 0;
110
+ if (Scheduler && Transition && Transition.running) {
111
+ c.tState = STALE;
112
+ Updates.push(c);
113
+ } else updateComputation(c);
114
+ return readSignal.bind(c);
115
+ }
116
+ function untrack(fn) {
117
+ if (!ExternalSourceConfig && Listener === null) return fn();
118
+ const listener = Listener;
119
+ Listener = null;
120
+ try {
121
+ if (ExternalSourceConfig) return ExternalSourceConfig.untrack(fn);
122
+ return fn();
123
+ } finally {
124
+ Listener = listener;
125
+ }
126
+ }
127
+ function onCleanup(fn) {
128
+ if (Owner === null);
129
+ else if (Owner.cleanups === null) Owner.cleanups = [fn];
130
+ else Owner.cleanups.push(fn);
131
+ return fn;
132
+ }
133
+ function startTransition(fn) {
134
+ if (Transition && Transition.running) {
135
+ fn();
136
+ return Transition.done;
137
+ }
138
+ const l = Listener;
139
+ const o = Owner;
140
+ return Promise.resolve().then(() => {
141
+ Listener = l;
142
+ Owner = o;
143
+ let t;
144
+ if (Scheduler || SuspenseContext) {
145
+ t = Transition || (Transition = {
146
+ sources: /* @__PURE__ */ new Set(),
147
+ effects: [],
148
+ promises: /* @__PURE__ */ new Set(),
149
+ disposed: /* @__PURE__ */ new Set(),
150
+ queue: /* @__PURE__ */ new Set(),
151
+ running: true
152
+ });
153
+ t.done || (t.done = new Promise((res) => t.resolve = res));
154
+ t.running = true;
155
+ }
156
+ runUpdates(fn, false);
157
+ Listener = Owner = null;
158
+ return t ? t.done : void 0;
159
+ });
160
+ }
161
+ var [transPending, setTransPending] = /*@__PURE__*/ createSignal(false);
162
+ function createContext(defaultValue, options) {
163
+ const id = Symbol("context");
164
+ return {
165
+ id,
166
+ Provider: createProvider(id),
167
+ defaultValue
168
+ };
169
+ }
170
+ function useContext(context) {
171
+ let value;
172
+ return Owner && Owner.context && (value = Owner.context[context.id]) !== void 0 ? value : context.defaultValue;
173
+ }
174
+ function children(fn) {
175
+ const children = createMemo(fn);
176
+ const memo = createMemo(() => resolveChildren(children()));
177
+ memo.toArray = () => {
178
+ const c = memo();
179
+ return Array.isArray(c) ? c : c != null ? [c] : [];
180
+ };
181
+ return memo;
182
+ }
183
+ var SuspenseContext;
184
+ function readSignal() {
185
+ const runningTransition = Transition && Transition.running;
186
+ if (this.sources && (runningTransition ? this.tState : this.state)) {
187
+ if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
188
+ else {
189
+ const updates = Updates;
190
+ Updates = null;
191
+ runUpdates(() => lookUpstream(this), false);
192
+ Updates = updates;
193
+ }
194
+ }
195
+ if (Listener) {
196
+ const observers = this.observers;
197
+ if (!observers || observers[observers.length - 1] !== Listener) {
198
+ const sSlot = observers ? observers.length : 0;
199
+ if (!Listener.sources) {
200
+ Listener.sources = [this];
201
+ Listener.sourceSlots = [sSlot];
202
+ } else {
203
+ Listener.sources.push(this);
204
+ Listener.sourceSlots.push(sSlot);
205
+ }
206
+ if (!observers) {
207
+ this.observers = [Listener];
208
+ this.observerSlots = [Listener.sources.length - 1];
209
+ } else {
210
+ observers.push(Listener);
211
+ this.observerSlots.push(Listener.sources.length - 1);
212
+ }
213
+ }
214
+ }
215
+ if (runningTransition && Transition.sources.has(this)) return this.tValue;
216
+ return this.value;
217
+ }
218
+ function writeSignal(node, value, isComp) {
219
+ let current = Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
220
+ if (!node.comparator || !node.comparator(current, value)) {
221
+ if (Transition) {
222
+ const TransitionRunning = Transition.running;
223
+ if (TransitionRunning || !isComp && Transition.sources.has(node)) {
224
+ Transition.sources.add(node);
225
+ node.tValue = value;
226
+ }
227
+ if (!TransitionRunning) node.value = value;
228
+ } else node.value = value;
229
+ if (node.observers && node.observers.length) runUpdates(() => {
230
+ for (let i = 0; i < node.observers.length; i += 1) {
231
+ const o = node.observers[i];
232
+ const TransitionRunning = Transition && Transition.running;
233
+ if (TransitionRunning && Transition.disposed.has(o)) continue;
234
+ if (TransitionRunning ? !o.tState : !o.state) {
235
+ if (o.pure) Updates.push(o);
236
+ else Effects.push(o);
237
+ if (o.observers) markDownstream(o);
238
+ }
239
+ if (!TransitionRunning) o.state = STALE;
240
+ else o.tState = STALE;
241
+ }
242
+ if (Updates.length > 1e6) {
243
+ Updates = [];
244
+ throw new Error();
245
+ }
246
+ }, false);
247
+ }
248
+ return value;
249
+ }
250
+ function updateComputation(node) {
251
+ if (!node.fn) return;
252
+ cleanNode(node);
253
+ const time = ExecCount;
254
+ runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
255
+ if (Transition && !Transition.running && Transition.sources.has(node)) queueMicrotask(() => {
256
+ runUpdates(() => {
257
+ Transition && (Transition.running = true);
258
+ Listener = Owner = node;
259
+ runComputation(node, node.tValue, time);
260
+ Listener = Owner = null;
261
+ }, false);
262
+ });
263
+ }
264
+ function runComputation(node, value, time) {
265
+ let nextValue;
266
+ const owner = Owner, listener = Listener;
267
+ Listener = Owner = node;
268
+ try {
269
+ nextValue = node.fn(value);
270
+ } catch (err) {
271
+ if (node.pure) {
272
+ if (Transition && Transition.running) {
273
+ node.tState = STALE;
274
+ node.tOwned && node.tOwned.forEach(cleanNode);
275
+ node.tOwned = void 0;
276
+ } else {
277
+ node.state = STALE;
278
+ node.owned && node.owned.forEach(cleanNode);
279
+ node.owned = null;
280
+ }
281
+ }
282
+ node.updatedAt = time + 1;
283
+ return handleError(err);
284
+ } finally {
285
+ Listener = listener;
286
+ Owner = owner;
287
+ }
288
+ if (!node.updatedAt || node.updatedAt <= time) {
289
+ if (node.updatedAt != null && "observers" in node) writeSignal(node, nextValue, true);
290
+ else if (Transition && Transition.running && node.pure) {
291
+ if (!Transition.sources.has(node)) node.value = nextValue;
292
+ Transition.sources.add(node);
293
+ node.tValue = nextValue;
294
+ } else node.value = nextValue;
295
+ node.updatedAt = time;
296
+ }
297
+ }
298
+ function createComputation(fn, init, pure, state = STALE, options) {
299
+ const c = {
300
+ fn,
301
+ state,
302
+ updatedAt: null,
303
+ owned: null,
304
+ sources: null,
305
+ sourceSlots: null,
306
+ cleanups: null,
307
+ value: init,
308
+ owner: Owner,
309
+ context: Owner ? Owner.context : null,
310
+ pure
311
+ };
312
+ if (Transition && Transition.running) {
313
+ c.state = 0;
314
+ c.tState = state;
315
+ }
316
+ if (Owner === null);
317
+ else if (Owner !== UNOWNED) {
318
+ if (Transition && Transition.running && Owner.pure) {
319
+ if (!Owner.tOwned) Owner.tOwned = [c];
320
+ else Owner.tOwned.push(c);
321
+ } else if (!Owner.owned) Owner.owned = [c];
322
+ else Owner.owned.push(c);
323
+ }
324
+ if (ExternalSourceConfig && c.fn) {
325
+ const sourceFn = c.fn;
326
+ const [track, trigger] = createSignal(void 0, { equals: false });
327
+ const ordinary = ExternalSourceConfig.factory(sourceFn, trigger);
328
+ onCleanup(() => ordinary.dispose());
329
+ let inTransition;
330
+ const triggerInTransition = () => startTransition(trigger).then(() => {
331
+ if (inTransition) {
332
+ inTransition.dispose();
333
+ inTransition = void 0;
334
+ }
335
+ });
336
+ c.fn = (x) => {
337
+ track();
338
+ if (Transition && Transition.running) {
339
+ if (!inTransition) inTransition = ExternalSourceConfig.factory(sourceFn, triggerInTransition);
340
+ return inTransition.track(x);
341
+ }
342
+ return ordinary.track(x);
343
+ };
344
+ }
345
+ return c;
346
+ }
347
+ function runTop(node) {
348
+ const runningTransition = Transition && Transition.running;
349
+ if ((runningTransition ? node.tState : node.state) === 0) return;
350
+ if ((runningTransition ? node.tState : node.state) === PENDING) return lookUpstream(node);
351
+ if (node.suspense && untrack(node.suspense.inFallback)) return node.suspense.effects.push(node);
352
+ const ancestors = [node];
353
+ while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
354
+ if (runningTransition && Transition.disposed.has(node)) return;
355
+ if (runningTransition ? node.tState : node.state) ancestors.push(node);
356
+ }
357
+ for (let i = ancestors.length - 1; i >= 0; i--) {
358
+ node = ancestors[i];
359
+ if (runningTransition) {
360
+ let top = node, prev = ancestors[i + 1];
361
+ while ((top = top.owner) && top !== prev) if (Transition.disposed.has(top)) return;
362
+ }
363
+ if ((runningTransition ? node.tState : node.state) === STALE) updateComputation(node);
364
+ else if ((runningTransition ? node.tState : node.state) === PENDING) {
365
+ const updates = Updates;
366
+ Updates = null;
367
+ runUpdates(() => lookUpstream(node, ancestors[0]), false);
368
+ Updates = updates;
369
+ }
370
+ }
371
+ }
372
+ function runUpdates(fn, init) {
373
+ if (Updates) return fn();
374
+ let wait = false;
375
+ if (!init) Updates = [];
376
+ if (Effects) wait = true;
377
+ else Effects = [];
378
+ ExecCount++;
379
+ try {
380
+ const res = fn();
381
+ completeUpdates(wait);
382
+ return res;
383
+ } catch (err) {
384
+ if (!wait) Effects = null;
385
+ Updates = null;
386
+ handleError(err);
387
+ }
388
+ }
389
+ function completeUpdates(wait) {
390
+ if (Updates) {
391
+ if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
392
+ else runQueue(Updates);
393
+ Updates = null;
394
+ }
395
+ if (wait) return;
396
+ let res;
397
+ if (Transition) {
398
+ if (!Transition.promises.size && !Transition.queue.size) {
399
+ const sources = Transition.sources;
400
+ const disposed = Transition.disposed;
401
+ Effects.push.apply(Effects, Transition.effects);
402
+ res = Transition.resolve;
403
+ for (const e of Effects) {
404
+ "tState" in e && (e.state = e.tState);
405
+ delete e.tState;
406
+ }
407
+ Transition = null;
408
+ runUpdates(() => {
409
+ for (const d of disposed) cleanNode(d);
410
+ for (const v of sources) {
411
+ v.value = v.tValue;
412
+ if (v.owned) for (let i = 0, len = v.owned.length; i < len; i++) cleanNode(v.owned[i]);
413
+ if (v.tOwned) v.owned = v.tOwned;
414
+ delete v.tValue;
415
+ delete v.tOwned;
416
+ v.tState = 0;
417
+ }
418
+ setTransPending(false);
419
+ }, false);
420
+ } else if (Transition.running) {
421
+ Transition.running = false;
422
+ Transition.effects.push.apply(Transition.effects, Effects);
423
+ Effects = null;
424
+ setTransPending(true);
425
+ return;
426
+ }
427
+ }
428
+ const e = Effects;
429
+ Effects = null;
430
+ if (e.length) runUpdates(() => runEffects(e), false);
431
+ if (res) res();
432
+ }
433
+ function runQueue(queue) {
434
+ for (let i = 0; i < queue.length; i++) runTop(queue[i]);
435
+ }
436
+ function scheduleQueue(queue) {
437
+ for (let i = 0; i < queue.length; i++) {
438
+ const item = queue[i];
439
+ const tasks = Transition.queue;
440
+ if (!tasks.has(item)) {
441
+ tasks.add(item);
442
+ Scheduler(() => {
443
+ tasks.delete(item);
444
+ runUpdates(() => {
445
+ Transition.running = true;
446
+ runTop(item);
447
+ }, false);
448
+ Transition && (Transition.running = false);
449
+ });
450
+ }
451
+ }
452
+ }
453
+ function runUserEffects(queue) {
454
+ let i, userLength = 0;
455
+ for (i = 0; i < queue.length; i++) {
456
+ const e = queue[i];
457
+ if (!e.user) runTop(e);
458
+ else queue[userLength++] = e;
459
+ }
460
+ if (sharedConfig.context) {
461
+ if (sharedConfig.count) {
462
+ sharedConfig.effects || (sharedConfig.effects = []);
463
+ sharedConfig.effects.push(...queue.slice(0, userLength));
464
+ return;
465
+ }
466
+ setHydrateContext();
467
+ }
468
+ if (sharedConfig.effects && (sharedConfig.done || !sharedConfig.count)) {
469
+ queue = [...sharedConfig.effects, ...queue];
470
+ userLength += sharedConfig.effects.length;
471
+ delete sharedConfig.effects;
472
+ }
473
+ for (i = 0; i < userLength; i++) runTop(queue[i]);
474
+ }
475
+ function lookUpstream(node, ignore) {
476
+ const runningTransition = Transition && Transition.running;
477
+ if (runningTransition) node.tState = 0;
478
+ else node.state = 0;
479
+ for (let i = 0; i < node.sources.length; i += 1) {
480
+ const source = node.sources[i];
481
+ if (source.sources) {
482
+ const state = runningTransition ? source.tState : source.state;
483
+ if (state === STALE) {
484
+ if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
485
+ } else if (state === PENDING) lookUpstream(source, ignore);
486
+ }
487
+ }
488
+ }
489
+ function markDownstream(node) {
490
+ const runningTransition = Transition && Transition.running;
491
+ for (let i = 0; i < node.observers.length; i += 1) {
492
+ const o = node.observers[i];
493
+ if (runningTransition ? !o.tState : !o.state) {
494
+ if (runningTransition) o.tState = PENDING;
495
+ else o.state = PENDING;
496
+ if (o.pure) Updates.push(o);
497
+ else Effects.push(o);
498
+ o.observers && markDownstream(o);
499
+ }
500
+ }
501
+ }
502
+ function cleanNode(node) {
503
+ let i;
504
+ if (node.sources) while (node.sources.length) {
505
+ const source = node.sources.pop(), index = node.sourceSlots.pop(), obs = source.observers;
506
+ if (obs && obs.length) {
507
+ const n = obs.pop(), s = source.observerSlots.pop();
508
+ if (index < obs.length) {
509
+ n.sourceSlots[s] = index;
510
+ obs[index] = n;
511
+ source.observerSlots[index] = s;
512
+ }
513
+ }
514
+ }
515
+ if (node.tOwned) {
516
+ for (i = node.tOwned.length - 1; i >= 0; i--) cleanNode(node.tOwned[i]);
517
+ delete node.tOwned;
518
+ }
519
+ if (Transition && Transition.running && node.pure) reset(node, true);
520
+ else if (node.owned) {
521
+ for (i = node.owned.length - 1; i >= 0; i--) cleanNode(node.owned[i]);
522
+ node.owned = null;
523
+ }
524
+ if (node.cleanups) {
525
+ for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
526
+ node.cleanups = null;
527
+ }
528
+ if (Transition && Transition.running) node.tState = 0;
529
+ else node.state = 0;
530
+ }
531
+ function reset(node, top) {
532
+ if (!top) {
533
+ node.tState = 0;
534
+ Transition.disposed.add(node);
535
+ }
536
+ if (node.owned) for (let i = 0; i < node.owned.length; i++) reset(node.owned[i]);
537
+ }
538
+ function castError(err) {
539
+ if (err instanceof Error) return err;
540
+ return new Error(typeof err === "string" ? err : "Unknown error", { cause: err });
541
+ }
542
+ function runErrors(err, fns, owner) {
543
+ try {
544
+ for (const f of fns) f(err);
545
+ } catch (e) {
546
+ handleError(e, owner && owner.owner || null);
547
+ }
548
+ }
549
+ function handleError(err, owner = Owner) {
550
+ const fns = ERROR && owner && owner.context && owner.context[ERROR];
551
+ const error = castError(err);
552
+ if (!fns) throw error;
553
+ if (Effects) Effects.push({
554
+ fn() {
555
+ runErrors(error, fns, owner);
556
+ },
557
+ state: STALE
558
+ });
559
+ else runErrors(error, fns, owner);
560
+ }
561
+ function resolveChildren(children) {
562
+ if (typeof children === "function" && !children.length) return resolveChildren(children());
563
+ if (Array.isArray(children)) {
564
+ const results = [];
565
+ for (let i = 0; i < children.length; i++) {
566
+ const result = resolveChildren(children[i]);
567
+ if (Array.isArray(result)) {
568
+ if (result.length < 32768) results.push.apply(results, result);
569
+ else for (let j = 0; j < result.length; j++) results.push(result[j]);
570
+ } else results.push(result);
571
+ }
572
+ return results;
573
+ }
574
+ return children;
575
+ }
576
+ function createProvider(id, options) {
577
+ return function provider(props) {
578
+ let res;
579
+ createRenderEffect(() => res = untrack(() => {
580
+ Owner.context = {
581
+ ...Owner.context,
582
+ [id]: props.value
583
+ };
584
+ return children(() => props.children);
585
+ }), void 0);
586
+ return res;
587
+ };
588
+ }
589
+ var FALLBACK = Symbol("fallback");
590
+ function dispose(d) {
591
+ for (let i = 0; i < d.length; i++) d[i]();
592
+ }
593
+ function mapArray(list, mapFn, options = {}) {
594
+ let items = [], mapped = [], disposers = [], len = 0, indexes = mapFn.length > 1 ? [] : null;
595
+ onCleanup(() => dispose(disposers));
596
+ return () => {
597
+ let newItems = list() || [], newLen = newItems.length, i, j;
598
+ newItems[$TRACK];
599
+ return untrack(() => {
600
+ let newIndices, newIndicesNext, temp, tempdisposers, tempIndexes, start, end, newEnd, item;
601
+ if (newLen === 0) {
602
+ if (len !== 0) {
603
+ dispose(disposers);
604
+ disposers = [];
605
+ items = [];
606
+ mapped = [];
607
+ len = 0;
608
+ indexes && (indexes = []);
609
+ }
610
+ if (options.fallback) {
611
+ items = [FALLBACK];
612
+ mapped[0] = createRoot((disposer) => {
613
+ disposers[0] = disposer;
614
+ return options.fallback();
615
+ });
616
+ len = 1;
617
+ }
618
+ } else if (len === 0) {
619
+ mapped = new Array(newLen);
620
+ for (j = 0; j < newLen; j++) {
621
+ items[j] = newItems[j];
622
+ mapped[j] = createRoot(mapper);
623
+ }
624
+ len = newLen;
625
+ } else {
626
+ temp = new Array(newLen);
627
+ tempdisposers = new Array(newLen);
628
+ indexes && (tempIndexes = new Array(newLen));
629
+ for (start = 0, end = Math.min(len, newLen); start < end && items[start] === newItems[start]; start++);
630
+ for (end = len - 1, newEnd = newLen - 1; end >= start && newEnd >= start && items[end] === newItems[newEnd]; end--, newEnd--) {
631
+ temp[newEnd] = mapped[end];
632
+ tempdisposers[newEnd] = disposers[end];
633
+ indexes && (tempIndexes[newEnd] = indexes[end]);
634
+ }
635
+ newIndices = /* @__PURE__ */ new Map();
636
+ newIndicesNext = new Array(newEnd + 1);
637
+ for (j = newEnd; j >= start; j--) {
638
+ item = newItems[j];
639
+ i = newIndices.get(item);
640
+ newIndicesNext[j] = i === void 0 ? -1 : i;
641
+ newIndices.set(item, j);
642
+ }
643
+ for (i = start; i <= end; i++) {
644
+ item = items[i];
645
+ j = newIndices.get(item);
646
+ if (j !== void 0 && j !== -1) {
647
+ temp[j] = mapped[i];
648
+ tempdisposers[j] = disposers[i];
649
+ indexes && (tempIndexes[j] = indexes[i]);
650
+ j = newIndicesNext[j];
651
+ newIndices.set(item, j);
652
+ } else disposers[i]();
653
+ }
654
+ for (j = start; j < newLen; j++) if (j in temp) {
655
+ mapped[j] = temp[j];
656
+ disposers[j] = tempdisposers[j];
657
+ if (indexes) {
658
+ indexes[j] = tempIndexes[j];
659
+ indexes[j](j);
660
+ }
661
+ } else mapped[j] = createRoot(mapper);
662
+ mapped = mapped.slice(0, len = newLen);
663
+ items = newItems.slice(0);
664
+ }
665
+ return mapped;
666
+ });
667
+ function mapper(disposer) {
668
+ disposers[j] = disposer;
669
+ if (indexes) {
670
+ const [s, set] = createSignal(j);
671
+ indexes[j] = set;
672
+ return mapFn(newItems[j], s);
673
+ }
674
+ return mapFn(newItems[j]);
675
+ }
676
+ };
677
+ }
678
+ function indexArray(list, mapFn, options = {}) {
679
+ let items = [], mapped = [], disposers = [], signals = [], len = 0, i;
680
+ onCleanup(() => dispose(disposers));
681
+ return () => {
682
+ const newItems = list() || [], newLen = newItems.length;
683
+ newItems[$TRACK];
684
+ return untrack(() => {
685
+ if (newLen === 0) {
686
+ if (len !== 0) {
687
+ dispose(disposers);
688
+ disposers = [];
689
+ items = [];
690
+ mapped = [];
691
+ len = 0;
692
+ signals = [];
693
+ }
694
+ if (options.fallback) {
695
+ items = [FALLBACK];
696
+ mapped[0] = createRoot((disposer) => {
697
+ disposers[0] = disposer;
698
+ return options.fallback();
699
+ });
700
+ len = 1;
701
+ }
702
+ return mapped;
703
+ }
704
+ if (items[0] === FALLBACK) {
705
+ disposers[0]();
706
+ disposers = [];
707
+ items = [];
708
+ mapped = [];
709
+ len = 0;
710
+ }
711
+ for (i = 0; i < newLen; i++) if (i < items.length && items[i] !== newItems[i]) signals[i](() => newItems[i]);
712
+ else if (i >= items.length) mapped[i] = createRoot(mapper);
713
+ for (; i < items.length; i++) disposers[i]();
714
+ len = signals.length = disposers.length = newLen;
715
+ items = newItems.slice(0);
716
+ return mapped = mapped.slice(0, len);
717
+ });
718
+ function mapper(disposer) {
719
+ disposers[i] = disposer;
720
+ const [s, set] = createSignal(newItems[i]);
721
+ signals[i] = set;
722
+ return mapFn(s, i);
723
+ }
724
+ };
725
+ }
726
+ var hydrationEnabled = false;
727
+ function createComponent(Comp, props) {
728
+ if (hydrationEnabled) {
729
+ if (sharedConfig.context) {
730
+ const c = sharedConfig.context;
731
+ setHydrateContext(nextHydrateContext());
732
+ const r = untrack(() => Comp(props || {}));
733
+ setHydrateContext(c);
734
+ return r;
735
+ }
736
+ }
737
+ return untrack(() => Comp(props || {}));
10
738
  }
11
- function assertSupportedRuntime(runtime = globalThis) {
12
- if (!isBunRuntime(runtime)) throw new Error("OpenTUI currently requires Bun. Run this CLI with `bun` or `yarn tui`.");
739
+ function trueFn() {
740
+ return true;
741
+ }
742
+ var propTraps = {
743
+ get(_, property, receiver) {
744
+ if (property === $PROXY) return receiver;
745
+ return _.get(property);
746
+ },
747
+ has(_, property) {
748
+ if (property === $PROXY) return true;
749
+ return _.has(property);
750
+ },
751
+ set: trueFn,
752
+ deleteProperty: trueFn,
753
+ getOwnPropertyDescriptor(_, property) {
754
+ return {
755
+ configurable: true,
756
+ enumerable: true,
757
+ get() {
758
+ return _.get(property);
759
+ },
760
+ set: trueFn,
761
+ deleteProperty: trueFn
762
+ };
763
+ },
764
+ ownKeys(_) {
765
+ return _.keys();
766
+ }
767
+ };
768
+ function resolveSource(s) {
769
+ return !(s = typeof s === "function" ? s() : s) ? {} : s;
770
+ }
771
+ function resolveSources() {
772
+ for (let i = 0, length = this.length; i < length; ++i) {
773
+ const v = this[i]();
774
+ if (v !== void 0) return v;
775
+ }
776
+ }
777
+ function mergeProps(...sources) {
778
+ let proxy = false;
779
+ for (let i = 0; i < sources.length; i++) {
780
+ const s = sources[i];
781
+ proxy = proxy || !!s && $PROXY in s;
782
+ sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
783
+ }
784
+ if (SUPPORTS_PROXY && proxy) return new Proxy({
785
+ get(property) {
786
+ for (let i = sources.length - 1; i >= 0; i--) {
787
+ const v = resolveSource(sources[i])[property];
788
+ if (v !== void 0) return v;
789
+ }
790
+ },
791
+ has(property) {
792
+ for (let i = sources.length - 1; i >= 0; i--) if (property in resolveSource(sources[i])) return true;
793
+ return false;
794
+ },
795
+ keys() {
796
+ const keys = [];
797
+ for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
798
+ return [...new Set(keys)];
799
+ }
800
+ }, propTraps);
801
+ const sourcesMap = {};
802
+ const defined = Object.create(null);
803
+ for (let i = sources.length - 1; i >= 0; i--) {
804
+ const source = sources[i];
805
+ if (!source) continue;
806
+ const sourceKeys = Object.getOwnPropertyNames(source);
807
+ for (let i = sourceKeys.length - 1; i >= 0; i--) {
808
+ const key = sourceKeys[i];
809
+ if (key === "__proto__" || key === "constructor") continue;
810
+ const desc = Object.getOwnPropertyDescriptor(source, key);
811
+ if (!defined[key]) defined[key] = desc.get ? {
812
+ enumerable: true,
813
+ configurable: true,
814
+ get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
815
+ } : desc.value !== void 0 ? desc : void 0;
816
+ else {
817
+ const sources = sourcesMap[key];
818
+ if (sources) {
819
+ if (desc.get) sources.push(desc.get.bind(source));
820
+ else if (desc.value !== void 0) sources.push(() => desc.value);
821
+ }
822
+ }
823
+ }
824
+ }
825
+ const target = {};
826
+ const definedKeys = Object.keys(defined);
827
+ for (let i = definedKeys.length - 1; i >= 0; i--) {
828
+ const key = definedKeys[i], desc = defined[key];
829
+ if (desc && desc.get) Object.defineProperty(target, key, desc);
830
+ else target[key] = desc ? desc.value : void 0;
831
+ }
832
+ return target;
833
+ }
834
+ function splitProps(props, ...keys) {
835
+ const len = keys.length;
836
+ if (SUPPORTS_PROXY && $PROXY in props) {
837
+ const blocked = len > 1 ? keys.flat() : keys[0];
838
+ const res = keys.map((k) => {
839
+ return new Proxy({
840
+ get(property) {
841
+ return k.includes(property) ? props[property] : void 0;
842
+ },
843
+ has(property) {
844
+ return k.includes(property) && property in props;
845
+ },
846
+ keys() {
847
+ return k.filter((property) => property in props);
848
+ }
849
+ }, propTraps);
850
+ });
851
+ res.push(new Proxy({
852
+ get(property) {
853
+ return blocked.includes(property) ? void 0 : props[property];
854
+ },
855
+ has(property) {
856
+ return blocked.includes(property) ? false : property in props;
857
+ },
858
+ keys() {
859
+ return Object.keys(props).filter((k) => !blocked.includes(k));
860
+ }
861
+ }, propTraps));
862
+ return res;
863
+ }
864
+ const objects = [];
865
+ for (let i = 0; i <= len; i++) objects[i] = {};
866
+ for (const propName of Object.getOwnPropertyNames(props)) {
867
+ let keyIndex = len;
868
+ for (let i = 0; i < keys.length; i++) if (keys[i].includes(propName)) {
869
+ keyIndex = i;
870
+ break;
871
+ }
872
+ const desc = Object.getOwnPropertyDescriptor(props, propName);
873
+ !desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable ? objects[keyIndex][propName] = desc.value : Object.defineProperty(objects[keyIndex], propName, desc);
874
+ }
875
+ return objects;
876
+ }
877
+ var narrowedError = (name) => `Stale read from <${name}>.`;
878
+ function For(props) {
879
+ const fallback = "fallback" in props && { fallback: () => props.fallback };
880
+ return createMemo(mapArray(() => props.each, props.children, fallback || void 0));
881
+ }
882
+ function Index(props) {
883
+ const fallback = "fallback" in props && { fallback: () => props.fallback };
884
+ return createMemo(indexArray(() => props.each, props.children, fallback || void 0));
885
+ }
886
+ function Show(props) {
887
+ const keyed = props.keyed;
888
+ const conditionValue = createMemo(() => props.when, void 0, void 0);
889
+ const condition = keyed ? conditionValue : createMemo(conditionValue, void 0, { equals: (a, b) => !a === !b });
890
+ return createMemo(() => {
891
+ const c = condition();
892
+ if (c) {
893
+ const child = props.children;
894
+ return typeof child === "function" && child.length > 0 ? untrack(() => child(keyed ? c : () => {
895
+ if (!untrack(condition)) throw narrowedError("Show");
896
+ return conditionValue();
897
+ })) : child;
898
+ }
899
+ return props.fallback;
900
+ }, void 0, void 0);
13
901
  }
14
902
  //#endregion
15
- //#region src/cli-program.ts
16
- const APP_VERSION = "0.2.0";
17
- const commandConfig = {
18
- paths: Args.text({ name: "path" }).pipe(Args.atLeast(0), Args.withDescription("Directory to scan. Repeat by passing multiple paths.")),
19
- presets: Options.text("preset").pipe(Options.withAlias("p"), Options.repeated, Options.withDescription("Cleanup preset to include: node, rust, gitignored. Can be repeated or comma-separated.")),
20
- ignoreHidden: Options.boolean("ignore-hidden").pipe(Options.withDescription("Skip hidden paths while scanning.")),
21
- sort: Options.choice("sort", SORT_MODES).pipe(Options.withDefault("size"), Options.withDescription("Sort cleanup candidates by size or path."))
903
+ //#region ../../node_modules/@uniview/tui-solid/dist/dist-bXJeAA2t.mjs
904
+ /**
905
+ * Reserved node type for text content (protocol v3).
906
+ * Text nodes carry their content in `text` and have no props/children.
907
+ */
908
+ var TEXT_NODE_TYPE = "#text";
909
+ /**
910
+ * Read the text content of a child, whether it uses the v3 explicit text
911
+ * node form or the legacy bare-string form.
912
+ */
913
+ function textContent(node) {
914
+ if (typeof node === "string") return node;
915
+ if (node.type === "#text") return node.text ?? "";
916
+ return null;
917
+ }
918
+ /**
919
+ * Runtime form of {@link EventPropName} — the DOM-style events, not every
920
+ * handler prop. See that type before using this as a filter.
921
+ */
922
+ var EVENT_PROPS = [
923
+ "onClick",
924
+ "onChange",
925
+ "onInput",
926
+ "onSubmit",
927
+ "onFocus",
928
+ "onBlur",
929
+ "onKeyDown",
930
+ "onKeyUp",
931
+ "onMouseEnter",
932
+ "onMouseLeave",
933
+ "onWheel"
934
+ ];
935
+ /**
936
+ * Check if a prop name is a handler ID prop
937
+ * e.g., '_onClickHandlerId' -> true
938
+ */
939
+ function isHandlerIdProp(propName) {
940
+ return propName.startsWith("_") && propName.endsWith("HandlerId");
941
+ }
942
+ /**
943
+ * Extract the event name from a handler ID prop name
944
+ * e.g., '_onClickHandlerId' -> 'onClick'
945
+ *
946
+ * Returns null for a handler id prop outside {@link EVENT_PROPS} — meaning "not
947
+ * a DOM event I can auto-wire", NOT "dead prop". `_onActionHandlerId` lands
948
+ * here and is still bound by name on the AppKit and Svelte hosts, so a caller
949
+ * filtering on this must pass the unrecognized ones through rather than drop
950
+ * them (see host-svelte's ComponentRenderer).
951
+ */
952
+ var HANDLER_ID_PREFIX_LENGTH = 1;
953
+ function extractEventName(handlerIdProp) {
954
+ if (!isHandlerIdProp(handlerIdProp)) return null;
955
+ const eventName = handlerIdProp.slice(HANDLER_ID_PREFIX_LENGTH, -9);
956
+ if (EVENT_PROPS.includes(eventName)) return eventName;
957
+ return null;
958
+ }
959
+ /**
960
+ * The Tailwind color palette, as flat `<family>-<shade>` tokens.
961
+ *
962
+ * These are plain design tokens, not a Tailwind dependency: the resolver looks
963
+ * class names up in `Theme.colors`, and this is what seeds the default theme so
964
+ * that `bg-emerald-500` / `text-zinc-400` resolve to a concrete color instead of
965
+ * being silently dropped.
966
+ *
967
+ * Values are literal hex. A native host receives the color the plugin author
968
+ * asked for, exactly — semantic, appearance-adaptive colors are a separate
969
+ * concern, expressed by the theme's semantic tokens (`foreground`, `border`, …).
970
+ *
971
+ * These are GENERATED from `tailwindcss/theme.css`, not typed by hand. Tailwind
972
+ * v4 defines its palette in oklch and re-tuned nearly every shade from v3, so a
973
+ * palette written from memory is a palette from the wrong major version: the
974
+ * first draft of this file had 185 of 242 tokens wrong, and `bg-emerald-500`
975
+ * rendered a different green natively than it did in a browser — from the same
976
+ * class name, which is the one thing this project cannot get wrong.
977
+ *
978
+ * `pnpm --filter @uniview/style gen:palette` regenerates; `palette.test.ts`
979
+ * fails if this file and the installed Tailwind ever disagree.
980
+ */
981
+ var FAMILIES = {
982
+ red: [
983
+ "#fef2f2",
984
+ "#ffe2e2",
985
+ "#ffc9c9",
986
+ "#ffa2a2",
987
+ "#ff6467",
988
+ "#fb2c36",
989
+ "#e7000b",
990
+ "#c10007",
991
+ "#9f0712",
992
+ "#82181a",
993
+ "#460809"
994
+ ],
995
+ orange: [
996
+ "#fff7ed",
997
+ "#ffedd4",
998
+ "#ffd6a7",
999
+ "#ffb86a",
1000
+ "#ff8904",
1001
+ "#ff6900",
1002
+ "#f54900",
1003
+ "#ca3500",
1004
+ "#9f2d00",
1005
+ "#7e2a0c",
1006
+ "#441306"
1007
+ ],
1008
+ amber: [
1009
+ "#fffbeb",
1010
+ "#fef3c6",
1011
+ "#fee685",
1012
+ "#ffd230",
1013
+ "#ffb900",
1014
+ "#fe9a00",
1015
+ "#e17100",
1016
+ "#bb4d00",
1017
+ "#973c00",
1018
+ "#7b3306",
1019
+ "#461901"
1020
+ ],
1021
+ yellow: [
1022
+ "#fefce8",
1023
+ "#fef9c2",
1024
+ "#fff085",
1025
+ "#ffdf20",
1026
+ "#fdc700",
1027
+ "#f0b100",
1028
+ "#d08700",
1029
+ "#a65f00",
1030
+ "#894b00",
1031
+ "#733e0a",
1032
+ "#432004"
1033
+ ],
1034
+ lime: [
1035
+ "#f7fee7",
1036
+ "#ecfcca",
1037
+ "#d8f999",
1038
+ "#bbf451",
1039
+ "#9ae600",
1040
+ "#7ccf00",
1041
+ "#5ea500",
1042
+ "#497d00",
1043
+ "#3c6300",
1044
+ "#35530e",
1045
+ "#192e03"
1046
+ ],
1047
+ green: [
1048
+ "#f0fdf4",
1049
+ "#dcfce7",
1050
+ "#b9f8cf",
1051
+ "#7bf1a8",
1052
+ "#05df72",
1053
+ "#00c950",
1054
+ "#00a63e",
1055
+ "#008236",
1056
+ "#016630",
1057
+ "#0d542b",
1058
+ "#032e15"
1059
+ ],
1060
+ emerald: [
1061
+ "#ecfdf5",
1062
+ "#d0fae5",
1063
+ "#a4f4cf",
1064
+ "#5ee9b5",
1065
+ "#00d492",
1066
+ "#00bc7d",
1067
+ "#009966",
1068
+ "#007a55",
1069
+ "#006045",
1070
+ "#004f3b",
1071
+ "#002c22"
1072
+ ],
1073
+ teal: [
1074
+ "#f0fdfa",
1075
+ "#cbfbf1",
1076
+ "#96f7e4",
1077
+ "#46ecd5",
1078
+ "#00d5be",
1079
+ "#00bba7",
1080
+ "#009689",
1081
+ "#00786f",
1082
+ "#005f5a",
1083
+ "#0b4f4a",
1084
+ "#022f2e"
1085
+ ],
1086
+ cyan: [
1087
+ "#ecfeff",
1088
+ "#cefafe",
1089
+ "#a2f4fd",
1090
+ "#53eafd",
1091
+ "#00d3f2",
1092
+ "#00b8db",
1093
+ "#0092b8",
1094
+ "#007595",
1095
+ "#005f78",
1096
+ "#104e64",
1097
+ "#053345"
1098
+ ],
1099
+ sky: [
1100
+ "#f0f9ff",
1101
+ "#dff2fe",
1102
+ "#b8e6fe",
1103
+ "#74d4ff",
1104
+ "#00bcff",
1105
+ "#00a6f4",
1106
+ "#0084d1",
1107
+ "#0069a8",
1108
+ "#00598a",
1109
+ "#024a70",
1110
+ "#052f4a"
1111
+ ],
1112
+ blue: [
1113
+ "#eff6ff",
1114
+ "#dbeafe",
1115
+ "#bedbff",
1116
+ "#8ec5ff",
1117
+ "#51a2ff",
1118
+ "#2b7fff",
1119
+ "#155dfc",
1120
+ "#1447e6",
1121
+ "#193cb8",
1122
+ "#1c398e",
1123
+ "#162456"
1124
+ ],
1125
+ indigo: [
1126
+ "#eef2ff",
1127
+ "#e0e7ff",
1128
+ "#c6d2ff",
1129
+ "#a3b3ff",
1130
+ "#7c86ff",
1131
+ "#615fff",
1132
+ "#4f39f6",
1133
+ "#432dd7",
1134
+ "#372aac",
1135
+ "#312c85",
1136
+ "#1e1a4d"
1137
+ ],
1138
+ violet: [
1139
+ "#f5f3ff",
1140
+ "#ede9fe",
1141
+ "#ddd6ff",
1142
+ "#c4b4ff",
1143
+ "#a684ff",
1144
+ "#8e51ff",
1145
+ "#7f22fe",
1146
+ "#7008e7",
1147
+ "#5d0ec0",
1148
+ "#4d179a",
1149
+ "#2f0d68"
1150
+ ],
1151
+ purple: [
1152
+ "#faf5ff",
1153
+ "#f3e8ff",
1154
+ "#e9d4ff",
1155
+ "#dab2ff",
1156
+ "#c27aff",
1157
+ "#ad46ff",
1158
+ "#9810fa",
1159
+ "#8200db",
1160
+ "#6e11b0",
1161
+ "#59168b",
1162
+ "#3c0366"
1163
+ ],
1164
+ fuchsia: [
1165
+ "#fdf4ff",
1166
+ "#fae8ff",
1167
+ "#f6cfff",
1168
+ "#f4a8ff",
1169
+ "#ed6aff",
1170
+ "#e12afb",
1171
+ "#c800de",
1172
+ "#a800b7",
1173
+ "#8a0194",
1174
+ "#721378",
1175
+ "#4b004f"
1176
+ ],
1177
+ pink: [
1178
+ "#fdf2f8",
1179
+ "#fce7f3",
1180
+ "#fccee8",
1181
+ "#fda5d5",
1182
+ "#fb64b6",
1183
+ "#f6339a",
1184
+ "#e60076",
1185
+ "#c6005c",
1186
+ "#a3004c",
1187
+ "#861043",
1188
+ "#510424"
1189
+ ],
1190
+ rose: [
1191
+ "#fff1f2",
1192
+ "#ffe4e6",
1193
+ "#ffccd3",
1194
+ "#ffa1ad",
1195
+ "#ff637e",
1196
+ "#ff2056",
1197
+ "#ec003f",
1198
+ "#c70036",
1199
+ "#a50036",
1200
+ "#8b0836",
1201
+ "#4d0218"
1202
+ ],
1203
+ slate: [
1204
+ "#f8fafc",
1205
+ "#f1f5f9",
1206
+ "#e2e8f0",
1207
+ "#cad5e2",
1208
+ "#90a1b9",
1209
+ "#62748e",
1210
+ "#45556c",
1211
+ "#314158",
1212
+ "#1d293d",
1213
+ "#0f172b",
1214
+ "#020618"
1215
+ ],
1216
+ gray: [
1217
+ "#f9fafb",
1218
+ "#f3f4f6",
1219
+ "#e5e7eb",
1220
+ "#d1d5dc",
1221
+ "#99a1af",
1222
+ "#6a7282",
1223
+ "#4a5565",
1224
+ "#364153",
1225
+ "#1e2939",
1226
+ "#101828",
1227
+ "#030712"
1228
+ ],
1229
+ zinc: [
1230
+ "#fafafa",
1231
+ "#f4f4f5",
1232
+ "#e4e4e7",
1233
+ "#d4d4d8",
1234
+ "#9f9fa9",
1235
+ "#71717b",
1236
+ "#52525c",
1237
+ "#3f3f46",
1238
+ "#27272a",
1239
+ "#18181b",
1240
+ "#09090b"
1241
+ ],
1242
+ neutral: [
1243
+ "#fafafa",
1244
+ "#f5f5f5",
1245
+ "#e5e5e5",
1246
+ "#d4d4d4",
1247
+ "#a1a1a1",
1248
+ "#737373",
1249
+ "#525252",
1250
+ "#404040",
1251
+ "#262626",
1252
+ "#171717",
1253
+ "#0a0a0a"
1254
+ ],
1255
+ stone: [
1256
+ "#fafaf9",
1257
+ "#f5f5f4",
1258
+ "#e7e5e4",
1259
+ "#d6d3d1",
1260
+ "#a6a09b",
1261
+ "#79716b",
1262
+ "#57534d",
1263
+ "#44403b",
1264
+ "#292524",
1265
+ "#1c1917",
1266
+ "#0c0a09"
1267
+ ]
1268
+ };
1269
+ var SHADES = [
1270
+ 50,
1271
+ 100,
1272
+ 200,
1273
+ 300,
1274
+ 400,
1275
+ 500,
1276
+ 600,
1277
+ 700,
1278
+ 800,
1279
+ 900,
1280
+ 950
1281
+ ];
1282
+ function buildPalette() {
1283
+ const palette = {
1284
+ white: "#ffffff",
1285
+ black: "#000000",
1286
+ transparent: "transparent"
1287
+ };
1288
+ for (const [family, hexes] of Object.entries(FAMILIES)) SHADES.forEach((shade, i) => {
1289
+ palette[`${family}-${shade}`] = hexes[i];
1290
+ });
1291
+ return palette;
1292
+ }
1293
+ /** `{ "zinc-400": "#9f9fa9", "emerald-500": "#00bc7d", ... }` */
1294
+ var tailwindPalette = buildPalette();
1295
+ /**
1296
+ * The semantic vocabulary — shadcn's token names, mapped onto colors the OS owns.
1297
+ * Every one of these has a native counterpart the host resolves per view; the hex
1298
+ * here is what a web host (or a TS-resolving theme) uses.
1299
+ */
1300
+ var SEMANTIC_COLORS = {
1301
+ background: "#ffffff",
1302
+ foreground: "#111111",
1303
+ primary: "#0a84ff",
1304
+ "primary-foreground": "#ffffff",
1305
+ accent: "#0a84ff",
1306
+ "accent-foreground": "#ffffff",
1307
+ secondary: "#5856d6",
1308
+ muted: "#f2f2f7",
1309
+ "muted-foreground": "#6b7280",
1310
+ border: "#d1d5db",
1311
+ card: "#ffffff",
1312
+ destructive: "#ff3b30"
1313
+ };
1314
+ var defaultTheme = {
1315
+ colors: {
1316
+ ...tailwindPalette,
1317
+ ...SEMANTIC_COLORS
1318
+ },
1319
+ nativeTokens: new Set(Object.keys(SEMANTIC_COLORS)),
1320
+ spacing: (n) => n * 4,
1321
+ radii: {
1322
+ none: 0,
1323
+ sm: 4,
1324
+ md: 6,
1325
+ lg: 8,
1326
+ xl: 12,
1327
+ "2xl": 16,
1328
+ "3xl": 24,
1329
+ full: 9999,
1330
+ default: 6
1331
+ },
1332
+ fontSizes: {
1333
+ xs: 11,
1334
+ sm: 12,
1335
+ base: 13,
1336
+ lg: 15,
1337
+ xl: 18,
1338
+ "2xl": 22,
1339
+ "3xl": 28,
1340
+ "4xl": 34
1341
+ },
1342
+ shadows: {
1343
+ none: {
1344
+ offsetX: 0,
1345
+ offsetY: 0,
1346
+ radius: 0,
1347
+ color: "transparent"
1348
+ },
1349
+ sm: {
1350
+ offsetX: 0,
1351
+ offsetY: 1,
1352
+ radius: 2,
1353
+ color: "#0000000d"
1354
+ },
1355
+ default: {
1356
+ offsetX: 0,
1357
+ offsetY: 1,
1358
+ radius: 3,
1359
+ color: "#0000001a"
1360
+ },
1361
+ md: {
1362
+ offsetX: 0,
1363
+ offsetY: 4,
1364
+ radius: 6,
1365
+ color: "#0000001a"
1366
+ },
1367
+ lg: {
1368
+ offsetX: 0,
1369
+ offsetY: 10,
1370
+ radius: 15,
1371
+ color: "#0000001a"
1372
+ },
1373
+ xl: {
1374
+ offsetX: 0,
1375
+ offsetY: 20,
1376
+ radius: 25,
1377
+ color: "#0000001a"
1378
+ },
1379
+ "2xl": {
1380
+ offsetX: 0,
1381
+ offsetY: 25,
1382
+ radius: 50,
1383
+ color: "#00000040"
1384
+ }
1385
+ },
1386
+ leadings: {
1387
+ none: 1,
1388
+ tight: 1.25,
1389
+ snug: 1.375,
1390
+ normal: 1.5,
1391
+ relaxed: 1.625,
1392
+ loose: 2
1393
+ },
1394
+ sizes: {
1395
+ xs: 320,
1396
+ sm: 384,
1397
+ md: 448,
1398
+ lg: 512,
1399
+ xl: 576,
1400
+ "2xl": 672,
1401
+ "3xl": 768,
1402
+ "4xl": 896,
1403
+ "5xl": 1024,
1404
+ "6xl": 1152,
1405
+ "7xl": 1280
1406
+ }
22
1407
  };
23
- const spaceLensTuiCommand = Command.make("spacelens", commandConfig, (rawConfig) => Effect.gen(function* () {
1408
+ ({ ...defaultTheme });
1409
+ ({ ...defaultTheme }), { ...defaultTheme.colors };
1410
+ /**
1411
+ * The Tailwind-subset resolver. Runs plugin-side: a native host receives the
1412
+ * finished `ResolvedStyle` and never parses a class name.
1413
+ *
1414
+ * Two places where this deliberately follows *CSS* semantics rather than a
1415
+ * naive token mapping, because plugins are authored against CSS:
1416
+ *
1417
+ * - `flex` sets `flexDirection: "row"`. CSS's `display:flex` defaults to row,
1418
+ * but a flex engine (Yoga) defaults to column, so treating `flex` as a no-op
1419
+ * would silently stack every `<div className="flex gap-2">` vertically.
1420
+ * - `space-y-N` / `space-x-N` become `gap`. Tailwind implements them as margins
1421
+ * on the children; on a flex engine `gap` is the equivalent, and every native
1422
+ * container is a flex box. (The axis distinction is lost — a `space-y` on a
1423
+ * row will space it horizontally.)
1424
+ */
1425
+ /** Classes with a fixed mapping (no argument). */
1426
+ var STATIC_CLASSES = {
1427
+ flex: { flexDirection: "row" },
1428
+ "flex-row": { flexDirection: "row" },
1429
+ "flex-col": { flexDirection: "column" },
1430
+ "flex-row-reverse": { flexDirection: "row-reverse" },
1431
+ "flex-col-reverse": { flexDirection: "column-reverse" },
1432
+ "flex-wrap": { flexWrap: "wrap" },
1433
+ "flex-nowrap": { flexWrap: "nowrap" },
1434
+ "flex-1": {
1435
+ flexGrow: 1,
1436
+ flexShrink: 1,
1437
+ flexBasis: 0
1438
+ },
1439
+ "flex-auto": {
1440
+ flexGrow: 1,
1441
+ flexShrink: 1,
1442
+ flexBasis: "auto"
1443
+ },
1444
+ "flex-none": {
1445
+ flexGrow: 0,
1446
+ flexShrink: 0
1447
+ },
1448
+ grow: { flexGrow: 1 },
1449
+ "grow-0": { flexGrow: 0 },
1450
+ shrink: { flexShrink: 1 },
1451
+ "shrink-0": { flexShrink: 0 },
1452
+ "items-start": { alignItems: "flex-start" },
1453
+ "items-center": { alignItems: "center" },
1454
+ "items-end": { alignItems: "flex-end" },
1455
+ "items-stretch": { alignItems: "stretch" },
1456
+ "items-baseline": { alignItems: "baseline" },
1457
+ "justify-start": { justifyContent: "flex-start" },
1458
+ "justify-center": { justifyContent: "center" },
1459
+ "justify-end": { justifyContent: "flex-end" },
1460
+ "justify-between": { justifyContent: "space-between" },
1461
+ "justify-around": { justifyContent: "space-around" },
1462
+ "justify-evenly": { justifyContent: "space-evenly" },
1463
+ "self-auto": { alignSelf: "auto" },
1464
+ "self-start": { alignSelf: "flex-start" },
1465
+ "self-center": { alignSelf: "center" },
1466
+ "self-end": { alignSelf: "flex-end" },
1467
+ "self-stretch": { alignSelf: "stretch" },
1468
+ relative: { position: "relative" },
1469
+ absolute: { position: "absolute" },
1470
+ hidden: { display: "none" },
1471
+ block: { display: "flex" },
1472
+ "overflow-visible": { overflow: "visible" },
1473
+ "overflow-hidden": { overflow: "hidden" },
1474
+ "overflow-scroll": { overflow: "scroll" },
1475
+ "overflow-auto": { overflow: "scroll" },
1476
+ border: { borderWidth: 1 },
1477
+ "border-0": { borderWidth: 0 },
1478
+ "font-normal": { fontWeight: "normal" },
1479
+ "font-medium": { fontWeight: "medium" },
1480
+ "font-semibold": { fontWeight: "semibold" },
1481
+ "font-bold": { fontWeight: "bold" },
1482
+ italic: { fontStyle: "italic" },
1483
+ "not-italic": { fontStyle: "normal" },
1484
+ underline: { textDecoration: "underline" },
1485
+ "line-through": { textDecoration: "line-through" },
1486
+ "no-underline": { textDecoration: "none" },
1487
+ truncate: { maxLines: 1 },
1488
+ "text-left": { textAlign: "left" },
1489
+ "text-center": { textAlign: "center" },
1490
+ "text-right": { textAlign: "right" }
1491
+ };
1492
+ /**
1493
+ * Rules whose argument is a length on the spacing scale. The argument is matched
1494
+ * loosely (`(.+)`) and handed to `spacingValue`, so an arbitrary value
1495
+ * (`p-[13px]`) works everywhere a step (`p-4`) does, without a second rule table.
1496
+ */
1497
+ var EDGE_RULES = [
1498
+ [/^gap-(.+)$/, (v) => ({ gap: v })],
1499
+ [/^space-[xy]-(.+)$/, (v) => ({ gap: v })],
1500
+ [/^p-(.+)$/, (v) => ({
1501
+ paddingTop: v,
1502
+ paddingRight: v,
1503
+ paddingBottom: v,
1504
+ paddingLeft: v
1505
+ })],
1506
+ [/^px-(.+)$/, (v) => ({
1507
+ paddingLeft: v,
1508
+ paddingRight: v
1509
+ })],
1510
+ [/^py-(.+)$/, (v) => ({
1511
+ paddingTop: v,
1512
+ paddingBottom: v
1513
+ })],
1514
+ [/^pt-(.+)$/, (v) => ({ paddingTop: v })],
1515
+ [/^pr-(.+)$/, (v) => ({ paddingRight: v })],
1516
+ [/^pb-(.+)$/, (v) => ({ paddingBottom: v })],
1517
+ [/^pl-(.+)$/, (v) => ({ paddingLeft: v })],
1518
+ [/^m-(.+)$/, (v) => ({
1519
+ marginTop: v,
1520
+ marginRight: v,
1521
+ marginBottom: v,
1522
+ marginLeft: v
1523
+ })],
1524
+ [/^mx-(.+)$/, (v) => ({
1525
+ marginLeft: v,
1526
+ marginRight: v
1527
+ })],
1528
+ [/^my-(.+)$/, (v) => ({
1529
+ marginTop: v,
1530
+ marginBottom: v
1531
+ })],
1532
+ [/^mt-(.+)$/, (v) => ({ marginTop: v })],
1533
+ [/^mr-(.+)$/, (v) => ({ marginRight: v })],
1534
+ [/^mb-(.+)$/, (v) => ({ marginBottom: v })],
1535
+ [/^ml-(.+)$/, (v) => ({ marginLeft: v })],
1536
+ [/^inset-x-(.+)$/, (v) => ({
1537
+ left: v,
1538
+ right: v
1539
+ })],
1540
+ [/^inset-y-(.+)$/, (v) => ({
1541
+ top: v,
1542
+ bottom: v
1543
+ })],
1544
+ [/^inset-(.+)$/, (v) => ({
1545
+ top: v,
1546
+ right: v,
1547
+ bottom: v,
1548
+ left: v
1549
+ })],
1550
+ [/^top-(.+)$/, (v) => ({ top: v })],
1551
+ [/^right-(.+)$/, (v) => ({ right: v })],
1552
+ [/^bottom-(.+)$/, (v) => ({ bottom: v })],
1553
+ [/^left-(.+)$/, (v) => ({ left: v })]
1554
+ ];
1555
+ /** Rules that a leading `-` may negate (`-mt-2`, `-inset-1`). Lengths only. */
1556
+ var NEGATABLE = /^(m[xytrbl]?|inset(-[xy])?|top|right|bottom|left|z)-/;
1557
+ var AUTO_MARGINS = {
1558
+ "m-auto": {
1559
+ marginTop: "auto",
1560
+ marginRight: "auto",
1561
+ marginBottom: "auto",
1562
+ marginLeft: "auto"
1563
+ },
1564
+ "mx-auto": {
1565
+ marginLeft: "auto",
1566
+ marginRight: "auto"
1567
+ },
1568
+ "my-auto": {
1569
+ marginTop: "auto",
1570
+ marginBottom: "auto"
1571
+ },
1572
+ "mt-auto": { marginTop: "auto" },
1573
+ "mr-auto": { marginRight: "auto" },
1574
+ "mb-auto": { marginBottom: "auto" },
1575
+ "ml-auto": { marginLeft: "auto" }
1576
+ };
1577
+ var SIZE_RULES = [
1578
+ [/^w-(.+)$/, (d) => ({ width: d })],
1579
+ [/^h-(.+)$/, (d) => ({ height: d })],
1580
+ [/^min-w-(.+)$/, (d) => ({ minWidth: d })],
1581
+ [/^min-h-(.+)$/, (d) => ({ minHeight: d })],
1582
+ [/^max-w-(.+)$/, (d) => ({ maxWidth: d })],
1583
+ [/^max-h-(.+)$/, (d) => ({ maxHeight: d })]
1584
+ ];
1585
+ /**
1586
+ * The contents of an arbitrary value: `[13px]` → `"13px"`. Tailwind's escape
1587
+ * hatch, and the answer to every "the scale doesn't have the number I need".
1588
+ */
1589
+ function arbitrary(token) {
1590
+ return token.startsWith("[") && token.endsWith("]") ? token.slice(1, -1).replace(/_/g, " ") : void 0;
1591
+ }
1592
+ /** A length in points: a spacing step (`4` → 16), or an arbitrary `[13px]`. */
1593
+ function spacingValue(token, theme) {
1594
+ const raw = arbitrary(token);
1595
+ if (raw !== void 0) {
1596
+ const n = Number.parseFloat(raw);
1597
+ return Number.isNaN(n) ? void 0 : n;
1598
+ }
1599
+ if (token === "px") return 1;
1600
+ return /^\d+(\.\d+)?$/.test(token) ? theme.spacing(Number(token)) : void 0;
1601
+ }
1602
+ /**
1603
+ * A sizing argument: `full`, `auto`, `screen`, a named size (`md` → the theme's
1604
+ * size scale), a fraction (`1/2` → `"50%"`), an arbitrary `[137px]` / `[50%]`,
1605
+ * or a spacing step (`10` → 40px).
1606
+ */
1607
+ function parseDimension(token, theme) {
1608
+ if (token === "full") return "100%";
1609
+ if (token === "auto") return "auto";
1610
+ const raw = arbitrary(token);
1611
+ if (raw !== void 0) {
1612
+ if (raw.endsWith("%")) {
1613
+ const pct = Number.parseFloat(raw);
1614
+ return Number.isNaN(pct) ? void 0 : `${pct}%`;
1615
+ }
1616
+ const n = Number.parseFloat(raw);
1617
+ return Number.isNaN(n) ? void 0 : n;
1618
+ }
1619
+ if (token in theme.sizes) return theme.sizes[token];
1620
+ const fraction = token.match(/^(\d+)\/(\d+)$/);
1621
+ if (fraction) {
1622
+ const pct = Number(fraction[1]) / Number(fraction[2]) * 100;
1623
+ return `${Number(pct.toFixed(4))}%`;
1624
+ }
1625
+ return spacingValue(token, theme);
1626
+ }
1627
+ /** `0` → `"00"`, `255` → `"ff"`. */
1628
+ function alphaByte(fraction) {
1629
+ return Math.round(Math.max(0, Math.min(1, fraction)) * 255).toString(16).padStart(2, "0");
1630
+ }
1631
+ /**
1632
+ * A color argument, with Tailwind's optional `/N` alpha suffix.
1633
+ *
1634
+ * A token in `theme.nativeTokens` keeps its NAME (`card`, `card/50`): the native
1635
+ * host owns what it looks like, so that it can keep looking right when the
1636
+ * appearance changes. Everything else resolves to a literal, and its alpha folds
1637
+ * into an 8-digit `#rrggbbaa` — the form native color parsers already take, so no
1638
+ * host needs an `rgba()` parser.
1639
+ */
1640
+ function parseColor(token, theme) {
1641
+ const literal = arbitrary(token);
1642
+ if (literal !== void 0) return literal;
1643
+ const slash = token.lastIndexOf("/");
1644
+ const name = slash === -1 ? token : token.slice(0, slash);
1645
+ if (theme.nativeTokens.has(name)) return token;
1646
+ const base = theme.colors[name];
1647
+ if (base === void 0) return void 0;
1648
+ if (slash === -1) return base;
1649
+ const percent = Number(token.slice(slash + 1));
1650
+ if (Number.isNaN(percent)) return void 0;
1651
+ if (!/^#[0-9a-f]{6}$/i.test(base)) return base;
1652
+ return base + alphaByte(percent / 100);
1653
+ }
1654
+ /** Resolve one class token to a partial style, or null when unrecognized. */
1655
+ function matchToken(token, theme) {
1656
+ if (token.startsWith("-") && NEGATABLE.test(token.slice(1))) {
1657
+ const positive = matchToken(token.slice(1), theme);
1658
+ if (!positive) return null;
1659
+ return Object.fromEntries(Object.entries(positive).map(([key, value]) => [key, typeof value === "number" ? -value : value]));
1660
+ }
1661
+ const staticMatch = STATIC_CLASSES[token] ?? AUTO_MARGINS[token];
1662
+ if (staticMatch) return staticMatch;
1663
+ for (const [pattern, build] of EDGE_RULES) {
1664
+ const m = token.match(pattern);
1665
+ if (!m) continue;
1666
+ const value = spacingValue(m[1], theme);
1667
+ return value === void 0 ? null : build(value);
1668
+ }
1669
+ for (const [pattern, build] of SIZE_RULES) {
1670
+ const m = token.match(pattern);
1671
+ if (!m) continue;
1672
+ const dimension = parseDimension(m[1], theme);
1673
+ return dimension === void 0 ? null : build(dimension);
1674
+ }
1675
+ let m;
1676
+ if (m = token.match(/^rounded(?:-(.+))?$/)) {
1677
+ const key = m[1] ?? "default";
1678
+ if (key in theme.radii) return { borderRadius: theme.radii[key] };
1679
+ const value = spacingValue(key, theme) ?? Number(key);
1680
+ return Number.isNaN(value) ? null : { borderRadius: value };
1681
+ }
1682
+ if (m = token.match(/^shadow(?:-(.+))?$/)) {
1683
+ const key = m[1] ?? "default";
1684
+ if (key in theme.shadows) return { shadow: theme.shadows[key] };
1685
+ const color = parseColor(key, theme);
1686
+ return color === void 0 ? null : { shadowColor: color };
1687
+ }
1688
+ if (m = token.match(/^z-(\d+)$/)) return { zIndex: Number(m[1]) };
1689
+ if (m = token.match(/^aspect-(.+)$/)) {
1690
+ const key = m[1];
1691
+ if (key === "square") return { aspectRatio: 1 };
1692
+ if (key === "video") return { aspectRatio: 16 / 9 };
1693
+ const raw = arbitrary(key) ?? key;
1694
+ const ratio = raw.match(/^(\d+(?:\.\d+)?)\/(\d+(?:\.\d+)?)$/);
1695
+ if (ratio) return { aspectRatio: Number(ratio[1]) / Number(ratio[2]) };
1696
+ const n = Number.parseFloat(raw);
1697
+ return Number.isNaN(n) ? null : { aspectRatio: n };
1698
+ }
1699
+ if (m = token.match(/^leading-(.+)$/)) {
1700
+ const key = m[1];
1701
+ if (key in theme.leadings) return { lineHeightMultiple: theme.leadings[key] };
1702
+ const value = spacingValue(key, theme);
1703
+ return value === void 0 ? null : { lineHeight: value };
1704
+ }
1705
+ if (m = token.match(/^line-clamp-(\d+)$/)) return { maxLines: Number(m[1]) };
1706
+ if (m = token.match(/^border-(\d+)$/)) return { borderWidth: Number(m[1]) };
1707
+ if (m = token.match(/^opacity-(\d+(?:\.\d+)?)$/)) return { opacity: Number(m[1]) / 100 };
1708
+ if (m = token.match(/^bg-(.+)$/)) {
1709
+ const color = parseColor(m[1], theme);
1710
+ return color === void 0 ? null : { backgroundColor: color };
1711
+ }
1712
+ if (m = token.match(/^border-(.+)$/)) {
1713
+ const color = parseColor(m[1], theme);
1714
+ return color === void 0 ? null : { borderColor: color };
1715
+ }
1716
+ if (m = token.match(/^text-(.+)$/)) {
1717
+ const key = m[1];
1718
+ if (key in theme.fontSizes) return { fontSize: theme.fontSizes[key] };
1719
+ const size = arbitrary(key);
1720
+ if (size !== void 0 && /^[\d.]/.test(size)) return { fontSize: Number.parseFloat(size) };
1721
+ const color = parseColor(key, theme);
1722
+ return color === void 0 ? null : { color };
1723
+ }
1724
+ return null;
1725
+ }
1726
+ var GRADIENT_DIRECTIONS = /* @__PURE__ */ new Set([
1727
+ "to-t",
1728
+ "to-tr",
1729
+ "to-r",
1730
+ "to-br",
1731
+ "to-b",
1732
+ "to-bl",
1733
+ "to-l",
1734
+ "to-tl"
1735
+ ]);
1736
+ /**
1737
+ * `bg-linear-to-br from-sky-500 via-indigo-400 to-violet-600` (v4), or the same
1738
+ * with v3's `bg-gradient-to-br`.
1739
+ *
1740
+ * A gradient is the one thing in Tailwind that a *single* token cannot express:
1741
+ * the direction and each stop arrive as separate classes and have to be gathered.
1742
+ * So it gets a pass of its own rather than being bent into the per-token table.
1743
+ *
1744
+ * `to-` is deliberately matched only here. Everywhere else in Tailwind a bare
1745
+ * `to-…` means nothing, so there is no ambiguity to resolve.
1746
+ */
1747
+ function gradient(tokens, theme) {
1748
+ let direction;
1749
+ let from;
1750
+ let to;
1751
+ const via = [];
1752
+ for (const token of tokens) {
1753
+ const arrow = token.match(/^bg-(?:linear|gradient)-(to-[a-z]{1,2})$/);
1754
+ if (arrow && GRADIENT_DIRECTIONS.has(arrow[1])) {
1755
+ direction = arrow[1];
1756
+ continue;
1757
+ }
1758
+ const stop = token.match(/^(from|via|to)-(.+)$/);
1759
+ if (!stop) continue;
1760
+ const color = parseColor(stop[2], theme);
1761
+ if (color === void 0) continue;
1762
+ if (stop[1] === "from") from = color;
1763
+ else if (stop[1] === "to") to = color;
1764
+ else via.push(color);
1765
+ }
1766
+ if (direction === void 0 || from === void 0 || to === void 0) return void 0;
1767
+ return {
1768
+ direction,
1769
+ colors: [
1770
+ from,
1771
+ ...via,
1772
+ to
1773
+ ]
1774
+ };
1775
+ }
1776
+ /**
1777
+ * Class strings are static literals re-serialized on every render, so the parse
1778
+ * is memoized per theme. Cached results are frozen: callers spread, never write.
1779
+ */
1780
+ var cache = /* @__PURE__ */ new WeakMap();
1781
+ /**
1782
+ * Resolve a Tailwind-subset class string into a `ResolvedStyle`. Unknown tokens
1783
+ * are ignored; later tokens override earlier ones.
1784
+ */
1785
+ function resolveClassName(className, theme = defaultTheme) {
1786
+ let themeCache = cache.get(theme);
1787
+ if (!themeCache) {
1788
+ themeCache = /* @__PURE__ */ new Map();
1789
+ cache.set(theme, themeCache);
1790
+ }
1791
+ const hit = themeCache.get(className);
1792
+ if (hit) return hit;
1793
+ const tokens = className.trim().split(/\s+/).filter(Boolean);
1794
+ const out = {};
1795
+ const variants = {};
1796
+ const base = [];
1797
+ for (const token of tokens) {
1798
+ const split = splitVariants(token);
1799
+ if (split === null) continue;
1800
+ const [conditions, rest] = split;
1801
+ if (conditions.length === 0) {
1802
+ base.push(rest);
1803
+ const partial = matchToken(rest, theme);
1804
+ if (partial) Object.assign(out, partial);
1805
+ continue;
1806
+ }
1807
+ const partial = matchToken(rest, theme);
1808
+ if (!partial) continue;
1809
+ const key = conditions.join(":");
1810
+ variants[key] = {
1811
+ ...variants[key],
1812
+ ...partial
1813
+ };
1814
+ }
1815
+ const fill = gradient(base, theme);
1816
+ if (fill) out.backgroundGradient = fill;
1817
+ if (Object.keys(variants).length > 0) out.variants = variants;
1818
+ const frozen = Object.freeze(out);
1819
+ themeCache.set(className, frozen);
1820
+ return frozen;
1821
+ }
1822
+ /** The conditions a variant prefix may name. Anything else is not a variant. */
1823
+ var VARIANTS = /* @__PURE__ */ new Set([
1824
+ "dark",
1825
+ "light",
1826
+ "hover",
1827
+ "focus",
1828
+ "active",
1829
+ "disabled"
1830
+ ]);
1831
+ /**
1832
+ * `dark:hover:bg-zinc-800` → `[["dark", "hover"], "bg-zinc-800"]`.
1833
+ *
1834
+ * Returns `null` for a prefix that isn't a variant we can honour. Dropping the
1835
+ * whole token is deliberate: strip an unknown `md:` and it would silently become
1836
+ * an *unconditional* style, which is worse than it not working.
1837
+ */
1838
+ function splitVariants(token) {
1839
+ const bracket = token.indexOf("[");
1840
+ const count = (bracket === -1 ? token : token.slice(0, bracket)).split(":").length - 1;
1841
+ if (count === 0) return [[], token];
1842
+ const conditions = token.split(":", count);
1843
+ const rest = token.slice(conditions.reduce((n, c) => n + c.length + 1, 0));
1844
+ return conditions.every((c) => VARIANTS.has(c)) ? [conditions, rest] : null;
1845
+ }
1846
+ /**
1847
+ * Expand the padding/margin shorthands in a style object into the four explicit
1848
+ * edges. Precedence, low → high: all-sides, then horizontal/vertical, then edge.
1849
+ */
1850
+ function normalizeStyleInput(style) {
1851
+ const { padding, paddingHorizontal, paddingVertical, margin, marginHorizontal, marginVertical, ...rest } = style;
1852
+ const out = { ...rest };
1853
+ const edges = [
1854
+ [
1855
+ "paddingTop",
1856
+ out.paddingTop,
1857
+ paddingVertical,
1858
+ padding
1859
+ ],
1860
+ [
1861
+ "paddingBottom",
1862
+ out.paddingBottom,
1863
+ paddingVertical,
1864
+ padding
1865
+ ],
1866
+ [
1867
+ "paddingLeft",
1868
+ out.paddingLeft,
1869
+ paddingHorizontal,
1870
+ padding
1871
+ ],
1872
+ [
1873
+ "paddingRight",
1874
+ out.paddingRight,
1875
+ paddingHorizontal,
1876
+ padding
1877
+ ],
1878
+ [
1879
+ "marginTop",
1880
+ out.marginTop,
1881
+ marginVertical,
1882
+ margin
1883
+ ],
1884
+ [
1885
+ "marginBottom",
1886
+ out.marginBottom,
1887
+ marginVertical,
1888
+ margin
1889
+ ],
1890
+ [
1891
+ "marginLeft",
1892
+ out.marginLeft,
1893
+ marginHorizontal,
1894
+ margin
1895
+ ],
1896
+ [
1897
+ "marginRight",
1898
+ out.marginRight,
1899
+ marginHorizontal,
1900
+ margin
1901
+ ]
1902
+ ];
1903
+ for (const [key, edge, axis, all] of edges) {
1904
+ const value = edge ?? axis ?? all;
1905
+ if (value !== void 0) Object.assign(out, { [key]: value });
1906
+ }
1907
+ return out;
1908
+ }
1909
+ /**
1910
+ * Resolve `className` + `style` into one `ResolvedStyle`. The style object wins
1911
+ * over the class string on any field they both set.
1912
+ */
1913
+ function resolveStyle(input, theme = defaultTheme) {
1914
+ const fromClass = input.className ? resolveClassName(input.className, theme) : {};
1915
+ const fromStyle = input.style ? normalizeStyleInput(input.style) : {};
1916
+ return {
1917
+ ...fromClass,
1918
+ ...fromStyle
1919
+ };
1920
+ }
1921
+ /**
1922
+ * Resolve a node's `className` + `style` into the Style IR object that travels on
1923
+ * the wire as `_style`, or `null` when the node has no styling.
1924
+ *
1925
+ * This is what every renderer's serializer emits so that a native host — which
1926
+ * has no CSS engine and never parses `className` — still gets the resolved
1927
+ * layout and visual style. It lives here, in `@uniview/style`, precisely so that
1928
+ * a *new* renderer (React, Solid, and whatever comes next) does not re-implement
1929
+ * it and drift: the whole point of the framework-agnostic contract is that the IR
1930
+ * is produced identically no matter which plugin-side framework authored the
1931
+ * tree. (The Solid renderer once forwarded `className` untouched, so Solid
1932
+ * plugins rendered natively lost every Tailwind-derived style — this exists so
1933
+ * that can't recur.)
1934
+ *
1935
+ * `undefined` fields are dropped so the object is JSON-clean; the result is a
1936
+ * plain `ResolvedStyle`, which is already JSON-safe, and callers hand it across
1937
+ * the boundary as-is.
1938
+ */
1939
+ function resolveStyleIR(props, theme = defaultTheme) {
1940
+ const input = {};
1941
+ if (typeof props.className === "string") input.className = props.className;
1942
+ if (typeof props.style === "object" && props.style !== null && !Array.isArray(props.style)) input.style = props.style;
1943
+ if (input.className === void 0 && input.style === void 0) return null;
1944
+ const resolved = {};
1945
+ for (const [key, value] of Object.entries(resolveStyle(input, theme))) if (value !== void 0) Object.assign(resolved, { [key]: value });
1946
+ return Object.keys(resolved).length > 0 ? resolved : null;
1947
+ }
1948
+ var idCounter = 0;
1949
+ function generateId(prefix = "node") {
1950
+ return `${prefix}-${++idCounter}`;
1951
+ }
1952
+ function resetIdCounter() {
1953
+ idCounter = 0;
1954
+ }
1955
+ var memo$1 = (fn) => createMemo(() => fn());
1956
+ function createRenderer({ createElement, createTextNode, createSlotNode, isTextNode, replaceText, insertNode, removeNode, setProperty, getParentNode, getFirstChild, getNextSibling }) {
1957
+ function insert(parent, accessor, marker, initial) {
1958
+ if (marker !== void 0 && !initial) initial = [];
1959
+ if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
1960
+ createRenderEffect((current) => insertExpression(parent, accessor(), current, marker), initial);
1961
+ }
1962
+ function insertExpression(parent, value, current, marker, unwrapArray) {
1963
+ while (typeof current === "function") current = current();
1964
+ if (value === current) return current;
1965
+ const t = typeof value, multi = marker !== void 0;
1966
+ if (t === "string" || t === "number") {
1967
+ if (t === "number") value = value.toString();
1968
+ if (multi) {
1969
+ let node = current[0];
1970
+ if (node && isTextNode(node)) replaceText(node, value);
1971
+ else node = createTextNode(value);
1972
+ current = cleanChildren(parent, current, marker, node);
1973
+ } else if (current !== "" && typeof current === "string") replaceText(getFirstChild(parent), current = value);
1974
+ else {
1975
+ cleanChildren(parent, current, marker, createTextNode(value));
1976
+ current = value;
1977
+ }
1978
+ } else if (value == null || t === "boolean") current = cleanChildren(parent, current, marker);
1979
+ else if (t === "function") {
1980
+ createRenderEffect(() => {
1981
+ let v = value();
1982
+ while (typeof v === "function") v = v();
1983
+ current = insertExpression(parent, v, current, marker);
1984
+ });
1985
+ return () => current;
1986
+ } else if (Array.isArray(value)) {
1987
+ const array = [];
1988
+ if (normalizeIncomingArray(array, value, unwrapArray)) {
1989
+ createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
1990
+ return () => current;
1991
+ }
1992
+ if (array.length === 0) {
1993
+ const replacement = cleanChildren(parent, current, marker);
1994
+ if (multi) return current = replacement;
1995
+ } else if (Array.isArray(current)) if (current.length === 0) appendNodes(parent, array, marker);
1996
+ else reconcileArrays(parent, current, array);
1997
+ else if (current == null || current === "") appendNodes(parent, array);
1998
+ else reconcileArrays(parent, multi && current || [getFirstChild(parent)], array);
1999
+ current = array;
2000
+ } else {
2001
+ if (Array.isArray(current)) {
2002
+ if (multi) return current = cleanChildren(parent, current, marker, value);
2003
+ cleanChildren(parent, current, null, value);
2004
+ } else if (current == null || current === "" || !getFirstChild(parent)) insertNode(parent, value);
2005
+ else replaceNode(parent, value, getFirstChild(parent));
2006
+ current = value;
2007
+ }
2008
+ return current;
2009
+ }
2010
+ function normalizeIncomingArray(normalized, array, unwrap) {
2011
+ let dynamic = false;
2012
+ for (let i = 0, len = array.length; i < len; i++) {
2013
+ let item = array[i], t;
2014
+ if (item == null || item === true || item === false);
2015
+ else if (Array.isArray(item)) dynamic = normalizeIncomingArray(normalized, item) || dynamic;
2016
+ else if ((t = typeof item) === "string" || t === "number") normalized.push(createTextNode(item));
2017
+ else if (t === "function") if (unwrap) {
2018
+ while (typeof item === "function") item = item();
2019
+ dynamic = normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item]) || dynamic;
2020
+ } else {
2021
+ normalized.push(item);
2022
+ dynamic = true;
2023
+ }
2024
+ else normalized.push(item);
2025
+ }
2026
+ return dynamic;
2027
+ }
2028
+ function reconcileArrays(parentNode, a, b) {
2029
+ let bLength = b.length, aEnd = a.length, bEnd = bLength, aStart = 0, bStart = 0, after = getNextSibling(a[aEnd - 1]), map = null;
2030
+ while (aStart < aEnd || bStart < bEnd) {
2031
+ if (a[aStart] === b[bStart]) {
2032
+ aStart++;
2033
+ bStart++;
2034
+ continue;
2035
+ }
2036
+ while (a[aEnd - 1] === b[bEnd - 1]) {
2037
+ aEnd--;
2038
+ bEnd--;
2039
+ }
2040
+ if (aEnd === aStart) {
2041
+ const node = bEnd < bLength ? bStart ? getNextSibling(b[bStart - 1]) : b[bEnd - bStart] : after;
2042
+ while (bStart < bEnd) insertNode(parentNode, b[bStart++], node);
2043
+ } else if (bEnd === bStart) while (aStart < aEnd) {
2044
+ if (!map || !map.has(a[aStart])) removeNode(parentNode, a[aStart]);
2045
+ aStart++;
2046
+ }
2047
+ else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
2048
+ const node = getNextSibling(a[--aEnd]);
2049
+ insertNode(parentNode, b[bStart++], getNextSibling(a[aStart++]));
2050
+ insertNode(parentNode, b[--bEnd], node);
2051
+ a[aEnd] = b[bEnd];
2052
+ } else {
2053
+ if (!map) {
2054
+ map = /* @__PURE__ */ new Map();
2055
+ let i = bStart;
2056
+ while (i < bEnd) map.set(b[i], i++);
2057
+ }
2058
+ const index = map.get(a[aStart]);
2059
+ if (index != null) if (bStart < index && index < bEnd) {
2060
+ let i = aStart, sequence = 1, t;
2061
+ while (++i < aEnd && i < bEnd) {
2062
+ if ((t = map.get(a[i])) == null || t !== index + sequence) break;
2063
+ sequence++;
2064
+ }
2065
+ if (sequence > index - bStart) {
2066
+ const node = a[aStart];
2067
+ while (bStart < index) insertNode(parentNode, b[bStart++], node);
2068
+ } else replaceNode(parentNode, b[bStart++], a[aStart++]);
2069
+ } else aStart++;
2070
+ else removeNode(parentNode, a[aStart++]);
2071
+ }
2072
+ }
2073
+ }
2074
+ function cleanChildren(parent, current, marker, replacement) {
2075
+ if (marker === void 0) {
2076
+ let removed;
2077
+ while (removed = getFirstChild(parent)) removeNode(parent, removed);
2078
+ replacement && insertNode(parent, replacement);
2079
+ return replacement;
2080
+ }
2081
+ const node = replacement || createSlotNode();
2082
+ if (current.length) {
2083
+ let inserted = false;
2084
+ for (let i = current.length - 1; i >= 0; i--) {
2085
+ const el = current[i];
2086
+ if (node !== el) {
2087
+ const isParent = getParentNode(el) === parent;
2088
+ if (!inserted && !i) isParent ? replaceNode(parent, node, el) : insertNode(parent, node, marker);
2089
+ else isParent && removeNode(parent, el);
2090
+ } else inserted = true;
2091
+ }
2092
+ } else insertNode(parent, node, marker);
2093
+ return [node];
2094
+ }
2095
+ function appendNodes(parent, array, marker) {
2096
+ for (let i = 0, len = array.length; i < len; i++) insertNode(parent, array[i], marker);
2097
+ }
2098
+ function replaceNode(parent, newNode, oldNode) {
2099
+ insertNode(parent, newNode, oldNode);
2100
+ removeNode(parent, oldNode);
2101
+ }
2102
+ function spreadExpression(node, props, prevProps = {}, skipChildren) {
2103
+ props || (props = {});
2104
+ if (!skipChildren) createRenderEffect(() => prevProps.children = insertExpression(node, props.children, prevProps.children));
2105
+ createRenderEffect(() => props.ref && props.ref(node));
2106
+ createRenderEffect(() => {
2107
+ for (const prop in props) {
2108
+ if (prop === "children" || prop === "ref") continue;
2109
+ const value = props[prop];
2110
+ if (value === prevProps[prop]) continue;
2111
+ setProperty(node, prop, value, prevProps[prop]);
2112
+ prevProps[prop] = value;
2113
+ }
2114
+ });
2115
+ return prevProps;
2116
+ }
2117
+ return {
2118
+ render(code, element) {
2119
+ let disposer;
2120
+ createRoot((dispose) => {
2121
+ disposer = dispose;
2122
+ insert(element, code());
2123
+ });
2124
+ return disposer;
2125
+ },
2126
+ insert,
2127
+ spread(node, accessor, skipChildren) {
2128
+ if (typeof accessor === "function") createRenderEffect((current) => spreadExpression(node, accessor(), current, skipChildren));
2129
+ else spreadExpression(node, accessor, void 0, skipChildren);
2130
+ },
2131
+ createElement,
2132
+ createTextNode,
2133
+ insertNode,
2134
+ setProp(node, name, value, prev) {
2135
+ setProperty(node, name, value, prev);
2136
+ return value;
2137
+ },
2138
+ mergeProps,
2139
+ effect: createRenderEffect,
2140
+ memo: memo$1,
2141
+ createComponent,
2142
+ use(fn, element, arg) {
2143
+ return untrack(() => fn(element, arg));
2144
+ }
2145
+ };
2146
+ }
2147
+ var updateCallback = null;
2148
+ var mutationUpdateCallback = null;
2149
+ var mutationCollector = null;
2150
+ var rootNode = null;
2151
+ var scheduled = false;
2152
+ var warnedMultipleRoots = false;
2153
+ function scheduleUpdate() {
2154
+ if (scheduled) return;
2155
+ scheduled = true;
2156
+ queueMicrotask(() => {
2157
+ scheduled = false;
2158
+ if (!warnedMultipleRoots && rootNode) {
2159
+ if (rootNode.children.filter((c) => c._type !== "slot").length > 1) {
2160
+ warnedMultipleRoots = true;
2161
+ console.error("[uniview] plugin root must be a single element — wrap top-level siblings in one parent element (only the first is rendered)");
2162
+ }
2163
+ }
2164
+ if (mutationCollector && mutationUpdateCallback) {
2165
+ const mutations = mutationCollector.flushCommit();
2166
+ if (mutations.length > 0) mutationUpdateCallback(mutations);
2167
+ }
2168
+ if (updateCallback && rootNode) updateCallback(rootNode);
2169
+ });
2170
+ }
2171
+ function setUpdateCallback(cb) {
2172
+ updateCallback = cb;
2173
+ }
2174
+ function setMutationUpdateCallback(cb) {
2175
+ mutationUpdateCallback = cb;
2176
+ }
2177
+ function setMutationCollector(collector) {
2178
+ mutationCollector = collector;
2179
+ }
2180
+ function getRootNode() {
2181
+ return rootNode;
2182
+ }
2183
+ function setRootNode(node) {
2184
+ rootNode = node;
2185
+ warnedMultipleRoots = false;
2186
+ }
2187
+ function _createElement(tagName) {
2188
+ return {
2189
+ _type: "element",
2190
+ id: generateId(tagName),
2191
+ type: tagName,
2192
+ props: {},
2193
+ children: [],
2194
+ parent: null
2195
+ };
2196
+ }
2197
+ function _createTextNode(value) {
2198
+ return {
2199
+ _type: "text",
2200
+ id: generateId("text"),
2201
+ value: String(value),
2202
+ parent: null
2203
+ };
2204
+ }
2205
+ function _createSlotNode() {
2206
+ return {
2207
+ _type: "slot",
2208
+ id: generateId("slot"),
2209
+ parent: null
2210
+ };
2211
+ }
2212
+ function _isTextNode(node) {
2213
+ return node._type === "text";
2214
+ }
2215
+ function _replaceText(textNode, value) {
2216
+ textNode.value = value;
2217
+ mutationCollector?.collectSetText(textNode);
2218
+ scheduleUpdate();
2219
+ }
2220
+ /**
2221
+ * Remove a node from its current parent's children array (if attached).
2222
+ * Solid's universal renderer reuses insertNode to MOVE existing nodes
2223
+ * (keyed list reorders); DOM insertBefore auto-detaches, an array-based
2224
+ * children model must do it explicitly or reorders duplicate the node.
2225
+ */
2226
+ function _detachFromParent(node) {
2227
+ const prevParent = node.parent;
2228
+ if (!prevParent) return;
2229
+ const index = prevParent.children.indexOf(node);
2230
+ if (index !== -1) prevParent.children.splice(index, 1);
2231
+ }
2232
+ /**
2233
+ * Emit a setRoot mutation seeding the host from the container's real root
2234
+ * element. Solid mounts the plugin into a synthetic container (`rootNode`,
2235
+ * id "root") the host never sees; appendChild/removeChild against that
2236
+ * container referenced the internal "root" id, so incremental hosts could
2237
+ * never seed their tree and the runtime had to resend the whole tree every
2238
+ * flush. Addressing container-level changes as setRoot fixes that — every
2239
+ * later mutation then references real node ids.
2240
+ */
2241
+ function _syncContainerRoot() {
2242
+ if (!mutationCollector || !rootNode) return;
2243
+ const root = rootNode.children.find((c) => c._type !== "slot") ?? null;
2244
+ mutationCollector.collectSetRoot(root ?? null);
2245
+ }
2246
+ function _insertNode(parent, node, anchor) {
2247
+ _detachFromParent(node);
2248
+ node.parent = parent;
2249
+ const isContainerInsert = parent === rootNode;
2250
+ if (anchor) {
2251
+ const anchorIndex = parent.children.indexOf(anchor);
2252
+ if (anchorIndex !== -1) {
2253
+ parent.children.splice(anchorIndex, 0, node);
2254
+ if (!isContainerInsert) mutationCollector?.collectInsertBefore(parent, node, anchor);
2255
+ } else {
2256
+ parent.children.push(node);
2257
+ if (!isContainerInsert) mutationCollector?.collectAppendChild(parent, node);
2258
+ }
2259
+ } else {
2260
+ parent.children.push(node);
2261
+ if (!isContainerInsert) mutationCollector?.collectAppendChild(parent, node);
2262
+ }
2263
+ if (isContainerInsert) _syncContainerRoot();
2264
+ scheduleUpdate();
2265
+ }
2266
+ function _removeNode(parent, node) {
2267
+ const index = parent.children.indexOf(node);
2268
+ const wasContainerChild = parent === rootNode;
2269
+ if (index !== -1) {
2270
+ parent.children.splice(index, 1);
2271
+ if (wasContainerChild) {
2272
+ mutationCollector?.cleanupHandlers(node);
2273
+ _syncContainerRoot();
2274
+ } else mutationCollector?.collectRemoveChild(parent, node);
2275
+ }
2276
+ node.parent = null;
2277
+ scheduleUpdate();
2278
+ }
2279
+ function _setProperty(node, name, value, _prev) {
2280
+ if (value === void 0) delete node.props[name];
2281
+ else node.props[name] = value;
2282
+ mutationCollector?.collectSetProps(node);
2283
+ scheduleUpdate();
2284
+ }
2285
+ function _getParentNode(childNode) {
2286
+ return childNode.parent ?? void 0;
2287
+ }
2288
+ function _getFirstChild(node) {
2289
+ return node.children[0];
2290
+ }
2291
+ function _getNextSibling(node) {
2292
+ const parent = node.parent;
2293
+ if (!parent) return void 0;
2294
+ const index = parent.children.indexOf(node);
2295
+ if (index === -1 || index >= parent.children.length - 1) return void 0;
2296
+ return parent.children[index + 1];
2297
+ }
2298
+ var { render, effect, memo, createComponent: createComponent$1, createElement, createTextNode, insertNode, insert, spread, setProp, mergeProps: mergeProps$1, use } = createRenderer({
2299
+ createElement: _createElement,
2300
+ createTextNode: _createTextNode,
2301
+ createSlotNode: _createSlotNode,
2302
+ isTextNode: _isTextNode,
2303
+ replaceText: _replaceText,
2304
+ insertNode: _insertNode,
2305
+ removeNode: _removeNode,
2306
+ setProperty: _setProperty,
2307
+ getParentNode: _getParentNode,
2308
+ getFirstChild: _getFirstChild,
2309
+ getNextSibling: _getNextSibling
2310
+ });
2311
+ /**
2312
+ * Registry mapping stable handler ids to plugin-side functions.
2313
+ *
2314
+ * Handler ids are deterministic — `${nodeId}:${propName}` — so re-serializing
2315
+ * a node OVERWRITES its entries instead of growing the registry, and an
2316
+ * event RPC that arrives after a re-render executes that node's latest
2317
+ * handler (correct semantics) instead of a stale or wrong one. The previous
2318
+ * counter-based ids were reset by clear() on every full update, so a late
2319
+ * event could execute a DIFFERENT node's handler that reused the id.
2320
+ *
2321
+ * Ownership is tracked per node: `syncNode` replaces a node's full handler
2322
+ * set (dropping props that disappeared), `releaseNode` frees everything a
2323
+ * removed node owned. Full-tree serialization brackets its walk with
2324
+ * `beginSweep`/`endSweep` to release nodes that are no longer in the tree.
2325
+ */
2326
+ var HandlerRegistry = class {
2327
+ handlers = /* @__PURE__ */ new Map();
2328
+ nodeHandlers = /* @__PURE__ */ new Map();
2329
+ sweepSeen = null;
2330
+ /**
2331
+ * Replace the handler set owned by a node. Ids present before but not in
2332
+ * `next` are released; ids in `next` are (re-)registered in place.
2333
+ */
2334
+ syncNode(nodeId, next) {
2335
+ this.sweepSeen?.add(nodeId);
2336
+ const prev = this.nodeHandlers.get(nodeId);
2337
+ if (prev) {
2338
+ for (const id of prev) if (!next.has(id)) this.handlers.delete(id);
2339
+ }
2340
+ if (next.size === 0) {
2341
+ this.nodeHandlers.delete(nodeId);
2342
+ return;
2343
+ }
2344
+ const ids = /* @__PURE__ */ new Set();
2345
+ for (const [id, handler] of next) {
2346
+ this.handlers.set(id, handler);
2347
+ ids.add(id);
2348
+ }
2349
+ this.nodeHandlers.set(nodeId, ids);
2350
+ }
2351
+ /** Release every handler owned by a node (e.g. on removeChild). */
2352
+ releaseNode(nodeId) {
2353
+ const ids = this.nodeHandlers.get(nodeId);
2354
+ if (!ids) return;
2355
+ for (const id of ids) this.handlers.delete(id);
2356
+ this.nodeHandlers.delete(nodeId);
2357
+ }
2358
+ /**
2359
+ * Start tracking which nodes a full-tree serialization touches.
2360
+ * Nodes not seen by the matching `endSweep` are released — they left
2361
+ * the tree without an explicit removeChild (full update mode).
2362
+ */
2363
+ beginSweep() {
2364
+ this.sweepSeen = /* @__PURE__ */ new Set();
2365
+ }
2366
+ endSweep() {
2367
+ const seen = this.sweepSeen;
2368
+ this.sweepSeen = null;
2369
+ if (!seen) return;
2370
+ for (const nodeId of [...this.nodeHandlers.keys()]) if (!seen.has(nodeId)) this.releaseNode(nodeId);
2371
+ }
2372
+ async execute(handlerId, ...args) {
2373
+ const handler = this.handlers.get(handlerId);
2374
+ if (!handler) {
2375
+ console.warn(`[uniview] executeHandler: no handler registered for "${handlerId}" (node unmounted or event arrived after removal)`);
2376
+ return;
2377
+ }
2378
+ const result = handler(...args);
2379
+ if (result instanceof Promise) return await result;
2380
+ return result;
2381
+ }
2382
+ has(handlerId) {
2383
+ return this.handlers.has(handlerId);
2384
+ }
2385
+ clear() {
2386
+ this.handlers.clear();
2387
+ this.nodeHandlers.clear();
2388
+ this.sweepSeen = null;
2389
+ }
2390
+ get size() {
2391
+ return this.handlers.size;
2392
+ }
2393
+ };
2394
+ /**
2395
+ * The Style IR travels as a derived `_style` prop, alongside the untouched
2396
+ * `className` / `style` the author wrote. A native host has no CSS engine and
2397
+ * reads `_style`; web hosts ignore it and render `className` themselves.
2398
+ *
2399
+ * This is resolved by the shared `@uniview/style` helper — the SAME one the React
2400
+ * renderer uses — on purpose: a Solid plugin rendered through the native bridge
2401
+ * must produce the identical IR a React plugin would, or the framework-agnostic
2402
+ * contract is a lie. (It was: this serializer used to forward `className`
2403
+ * untouched, so every Solid plugin lost its Tailwind styling on the native side.)
2404
+ */
2405
+ var STYLE_IR_PROP = "_style";
2406
+ /**
2407
+ * Serialize props for a node, converting event handlers to handler IDs
2408
+ * and filtering out non-serializable values.
2409
+ *
2410
+ * Any `on[A-Z]*` function prop becomes a handler id (matching the react
2411
+ * renderer — custom app-level handlers like onSearchTextChange included,
2412
+ * not just the DOM event whitelist). Do not narrow this to `EVENT_PROPS`:
2413
+ * that list is only the DOM-style subset hosts auto-wire to real input events,
2414
+ * NOT the closed set of handler props a host may bind. AppKit binds
2415
+ * `_onSelectHandlerId` for menu items and `_onActionHandlerId` /
2416
+ * `_onSearchTextChangeHandlerId` / `_onSelectionChangeHandlerId` for the
2417
+ * Raycast-style surfaces, and the Svelte host passes unrecognized handler id
2418
+ * props through for registered components to relay. `extractEventName`
2419
+ * returning null means "not a DOM event", not "nobody binds it".
2420
+ *
2421
+ * Handler ids are deterministic (`${nodeId}:${propName}`) and the node's full
2422
+ * handler set is synced into the registry in one shot, so repeated
2423
+ * serialization never grows it.
2424
+ *
2425
+ * This is shared between full-tree serialization and mutation-based updates.
2426
+ */
2427
+ var warnedNestedFunctionProps = /* @__PURE__ */ new Set();
2428
+ function serializeProps(props, registry, nodeId) {
2429
+ const serializedProps = {};
2430
+ const handlers = /* @__PURE__ */ new Map();
2431
+ for (const [key, value] of Object.entries(props)) {
2432
+ if (key === "children" || key === "key" || key === "ref") continue;
2433
+ if (typeof value === "function") {
2434
+ if (/^on[A-Z]/.test(key)) {
2435
+ const handlerId = `${nodeId}:${key}`;
2436
+ handlers.set(handlerId, value);
2437
+ serializedProps[`_${key}HandlerId`] = handlerId;
2438
+ }
2439
+ continue;
2440
+ } else if (value === void 0) continue;
2441
+ else if (value === null) serializedProps[key] = null;
2442
+ else try {
2443
+ let hasNestedFunction = false;
2444
+ JSON.stringify(value, (_k, v) => {
2445
+ if (typeof v === "function") {
2446
+ hasNestedFunction = true;
2447
+ return;
2448
+ }
2449
+ return v;
2450
+ });
2451
+ if (hasNestedFunction && !warnedNestedFunctionProps.has(key)) {
2452
+ warnedNestedFunctionProps.add(key);
2453
+ console.warn(`[uniview] prop "${key}" contains nested function(s) that will NOT become event handlers — only top-level on[A-Z]* function props are converted to handler ids. Pass callbacks as top-level props or model the data as child elements.`);
2454
+ }
2455
+ serializedProps[key] = value;
2456
+ } catch {
2457
+ continue;
2458
+ }
2459
+ }
2460
+ const ir = resolveStyleIR(props);
2461
+ if (ir !== null) serializedProps[STYLE_IR_PROP] = ir;
2462
+ registry.syncNode(nodeId, handlers);
2463
+ return serializedProps;
2464
+ }
2465
+ function isTextNode$1(node) {
2466
+ return node._type === "text";
2467
+ }
2468
+ function isSlotNode$1(node) {
2469
+ return node._type === "slot";
2470
+ }
2471
+ function isElementNode$1(node) {
2472
+ return node._type === "element";
2473
+ }
2474
+ /**
2475
+ * Serialize a full tree from the root. Brackets the walk with a registry
2476
+ * sweep so handlers owned by nodes that left the tree are released —
2477
+ * without this, full update mode leaks handlers for every removed node.
2478
+ */
2479
+ function serializeTree(node, registry) {
2480
+ registry.beginSweep();
2481
+ try {
2482
+ return serializeNode(node, registry);
2483
+ } finally {
2484
+ registry.endSweep();
2485
+ }
2486
+ }
2487
+ function serializeNode(node, registry) {
2488
+ if (node == null) return null;
2489
+ if (isTextNode$1(node)) return {
2490
+ id: node.id,
2491
+ type: TEXT_NODE_TYPE,
2492
+ props: {},
2493
+ children: [],
2494
+ text: node.value
2495
+ };
2496
+ if (isSlotNode$1(node)) return null;
2497
+ if (!isElementNode$1(node)) return null;
2498
+ const serializedChildren = [];
2499
+ for (const child of node.children) {
2500
+ const serializedChild = serializeNode(child, registry);
2501
+ if (serializedChild !== null) serializedChildren.push(serializedChild);
2502
+ }
2503
+ return {
2504
+ type: node.type,
2505
+ props: serializeProps(node.props, registry, node.id),
2506
+ children: serializedChildren,
2507
+ id: node.id
2508
+ };
2509
+ }
2510
+ //#endregion
2511
+ //#region ../../node_modules/@uniview/tui-solid/dist/index.mjs
2512
+ function isElement(child) {
2513
+ return typeof child !== "string";
2514
+ }
2515
+ /**
2516
+ * Applies protocol {@link Mutation}s to a UINode tree, maintaining an id index
2517
+ * and parent map so mutations address nodes in O(1). Moves (append/insert of an
2518
+ * already-present node) detach the node from its old parent first, per the
2519
+ * protocol contract.
2520
+ */
2521
+ var MutableTree = class {
2522
+ root = null;
2523
+ nodes = /* @__PURE__ */ new Map();
2524
+ parentOf = /* @__PURE__ */ new Map();
2525
+ getRoot() {
2526
+ return this.root;
2527
+ }
2528
+ getNode(id) {
2529
+ return this.nodes.get(id);
2530
+ }
2531
+ /** The id of a node's parent, or undefined for the root/unknown nodes. */
2532
+ parentId(id) {
2533
+ return this.parentOf.get(id);
2534
+ }
2535
+ applyBatch(mutations) {
2536
+ for (const mutation of mutations) this.apply(mutation);
2537
+ }
2538
+ apply(mutation) {
2539
+ switch (mutation.type) {
2540
+ case "setRoot":
2541
+ if (this.root) this.unindex(this.root);
2542
+ this.root = mutation.node;
2543
+ if (mutation.node) this.index(mutation.node, null);
2544
+ return;
2545
+ case "appendChild": {
2546
+ const parent = this.nodes.get(mutation.parentId);
2547
+ if (!parent) return;
2548
+ this.ensureDetached(mutation.node.id);
2549
+ parent.children.push(mutation.node);
2550
+ this.index(mutation.node, parent.id);
2551
+ return;
2552
+ }
2553
+ case "insertBefore": {
2554
+ const parent = this.nodes.get(mutation.parentId);
2555
+ if (!parent) return;
2556
+ this.ensureDetached(mutation.node.id);
2557
+ const at = parent.children.findIndex((c) => isElement(c) && c.id === mutation.beforeId);
2558
+ parent.children.splice(at < 0 ? parent.children.length : at, 0, mutation.node);
2559
+ this.index(mutation.node, parent.id);
2560
+ return;
2561
+ }
2562
+ case "removeChild": {
2563
+ const parent = this.nodes.get(mutation.parentId);
2564
+ if (!parent) return;
2565
+ const at = parent.children.findIndex((c) => isElement(c) && c.id === mutation.nodeId);
2566
+ if (at < 0) return;
2567
+ const [removed] = parent.children.splice(at, 1);
2568
+ if (removed && isElement(removed)) this.unindex(removed);
2569
+ return;
2570
+ }
2571
+ case "setText": {
2572
+ const node = this.nodes.get(mutation.nodeId);
2573
+ if (node) node.text = mutation.text;
2574
+ return;
2575
+ }
2576
+ case "setProps": {
2577
+ const node = this.nodes.get(mutation.nodeId);
2578
+ if (node) node.props = mutation.props;
2579
+ return;
2580
+ }
2581
+ }
2582
+ }
2583
+ index(node, parentId) {
2584
+ this.nodes.set(node.id, node);
2585
+ if (parentId !== null) this.parentOf.set(node.id, parentId);
2586
+ else this.parentOf.delete(node.id);
2587
+ for (const child of node.children) if (isElement(child)) this.index(child, node.id);
2588
+ }
2589
+ unindex(node) {
2590
+ this.nodes.delete(node.id);
2591
+ this.parentOf.delete(node.id);
2592
+ for (const child of node.children) if (isElement(child)) this.unindex(child);
2593
+ }
2594
+ /** Detach an existing node from its parent and drop its old index entries. */
2595
+ ensureDetached(id) {
2596
+ const existing = this.nodes.get(id);
2597
+ if (!existing) return;
2598
+ const parentId = this.parentOf.get(id);
2599
+ const parent = parentId !== void 0 ? this.nodes.get(parentId) : void 0;
2600
+ if (parent) {
2601
+ const at = parent.children.findIndex((c) => isElement(c) && c.id === id);
2602
+ if (at >= 0) parent.children.splice(at, 1);
2603
+ }
2604
+ this.unindex(existing);
2605
+ }
2606
+ };
2607
+ /** Element types treated as inline text (their text children are flattened). */
2608
+ var TEXT_TYPES$1 = /* @__PURE__ */ new Set([
2609
+ "text",
2610
+ "span",
2611
+ "p",
2612
+ "strong",
2613
+ "em",
2614
+ "code",
2615
+ "label"
2616
+ ]);
2617
+ /** Layout props copied straight through to {@link TuiStyle}. */
2618
+ var STYLE_KEYS = [
2619
+ "display",
2620
+ "position",
2621
+ "top",
2622
+ "right",
2623
+ "bottom",
2624
+ "left",
2625
+ "flexDirection",
2626
+ "flexGrow",
2627
+ "flexShrink",
2628
+ "flexBasis",
2629
+ "justifyContent",
2630
+ "alignItems",
2631
+ "alignSelf",
2632
+ "width",
2633
+ "height",
2634
+ "minWidth",
2635
+ "maxWidth",
2636
+ "minHeight",
2637
+ "maxHeight",
2638
+ "margin",
2639
+ "padding",
2640
+ "gap",
2641
+ "rowGap",
2642
+ "columnGap",
2643
+ "border",
2644
+ "overflow",
2645
+ "zIndex"
2646
+ ];
2647
+ var TEXT_STYLE_FLAGS = [
2648
+ "bold",
2649
+ "dim",
2650
+ "italic",
2651
+ "underline",
2652
+ "strikethrough",
2653
+ "inverse",
2654
+ "blink",
2655
+ "hidden"
2656
+ ];
2657
+ function propsToStyle(props) {
2658
+ const style = {};
2659
+ for (const key of STYLE_KEYS) {
2660
+ const value = props[key];
2661
+ if (value !== void 0) style[key] = value;
2662
+ }
2663
+ return style;
2664
+ }
2665
+ /** Accept a color prop as a named/CSS string or an `{ r, g, b }` triple. */
2666
+ function asColor(value) {
2667
+ if (typeof value === "string") return value;
2668
+ if (value !== null && typeof value === "object" && !Array.isArray(value)) {
2669
+ const o = value;
2670
+ if (typeof o.r === "number" && typeof o.g === "number" && typeof o.b === "number") return {
2671
+ r: o.r,
2672
+ g: o.g,
2673
+ b: o.b
2674
+ };
2675
+ }
2676
+ }
2677
+ function asAlign(value) {
2678
+ return value === "left" || value === "center" || value === "right" ? value : void 0;
2679
+ }
2680
+ function propsToTextStyle(props) {
2681
+ const style = {};
2682
+ const fg = asColor(props.color);
2683
+ const bg = asColor(props.backgroundColor);
2684
+ if (fg !== void 0) style.fg = fg;
2685
+ if (bg !== void 0) style.bg = bg;
2686
+ for (const flag of TEXT_STYLE_FLAGS) if (props[flag] === true) style[flag] = true;
2687
+ return style;
2688
+ }
2689
+ /** Coerce a JSON `spans` prop into {@link StyledSpan}s, dropping malformed entries. */
2690
+ function parseSpans(value) {
2691
+ if (!Array.isArray(value)) return [];
2692
+ const spans = [];
2693
+ for (const item of value) {
2694
+ if (item === null || typeof item !== "object" || Array.isArray(item)) continue;
2695
+ const record = item;
2696
+ if (typeof record.text !== "string") continue;
2697
+ const span = { text: record.text };
2698
+ const style = record.style;
2699
+ if (style !== null && typeof style === "object" && !Array.isArray(style)) span.style = style;
2700
+ spans.push(span);
2701
+ }
2702
+ return spans;
2703
+ }
2704
+ /**
2705
+ * Flatten a text-type node's children into one string. `textContent` only
2706
+ * handles the two leaf shapes (a bare string, or an explicit text node); a
2707
+ * nested UINode (e.g. `<text><strong>OK</strong></text>`) falls through and
2708
+ * must be descended into recursively, or its text silently disappears from
2709
+ * the visual render while `semantics.ts`'s `collectText` (which already
2710
+ * recurses) still finds it — a query/render mismatch, not just missing text.
2711
+ */
2712
+ function joinText(node) {
2713
+ let text = "";
2714
+ for (const child of node.children) {
2715
+ if (typeof child === "string") {
2716
+ text += child;
2717
+ continue;
2718
+ }
2719
+ const content = textContent(child);
2720
+ text += content !== null ? content : joinText(child);
2721
+ }
2722
+ return text;
2723
+ }
2724
+ /**
2725
+ * Convert a protocol {@link UINode} (or bare string child) into a
2726
+ * {@link RenderNode} for @uniview/tui-core. Text elements flatten their text
2727
+ * children; box elements recurse. The node id is preserved so painted cells map
2728
+ * back to plugin nodes for hit-testing and event dispatch.
2729
+ *
2730
+ * `focusedId` resolves the text-field caret host-side (the plan's principle 3:
2731
+ * focus is local, never streamed to the plugin). A `<text caret>` cell renders
2732
+ * as an inverse, terminal-blinking block **only** while its enclosing textbox
2733
+ * is the focused node, and as a plain cell otherwise — so exactly one caret
2734
+ * blinks, on the field the user is actually editing.
2735
+ */
2736
+ function uinodeToRenderNode(node, focusedId = null) {
2737
+ return convert(node, focusedId, false);
2738
+ }
2739
+ function convert(node, focusedId, inFocused) {
2740
+ if (typeof node === "string") return {
2741
+ type: "text",
2742
+ text: node
2743
+ };
2744
+ if (node.type === "#text") return {
2745
+ type: "text",
2746
+ text: node.text ?? ""
2747
+ };
2748
+ const style = propsToStyle(node.props);
2749
+ if (node.type === "richtext") {
2750
+ const rendered = {
2751
+ type: "richtext",
2752
+ id: node.id,
2753
+ style,
2754
+ spans: parseSpans(node.props.spans)
2755
+ };
2756
+ if (typeof node.props.selectable === "boolean") rendered.selectable = node.props.selectable;
2757
+ const bg = asColor(node.props.backgroundColor);
2758
+ if (bg !== void 0) rendered.background = bg;
2759
+ return rendered;
2760
+ }
2761
+ if (TEXT_TYPES$1.has(node.type)) {
2762
+ const textStyle = propsToTextStyle(node.props);
2763
+ if (node.props.caret === true && inFocused) {
2764
+ textStyle.inverse = true;
2765
+ textStyle.blink = true;
2766
+ }
2767
+ const rendered = {
2768
+ type: "text",
2769
+ id: node.id,
2770
+ text: joinText(node),
2771
+ textStyle,
2772
+ style
2773
+ };
2774
+ if (typeof node.props.selectable === "boolean") rendered.selectable = node.props.selectable;
2775
+ return rendered;
2776
+ }
2777
+ const childInFocused = inFocused || focusedId !== null && node.id === focusedId;
2778
+ const rendered = {
2779
+ type: node.type,
2780
+ id: node.id,
2781
+ style,
2782
+ children: node.children.map((child) => convert(child, focusedId, childInFocused)).filter((c) => c !== null)
2783
+ };
2784
+ const bg = asColor(node.props.backgroundColor);
2785
+ if (bg !== void 0) rendered.background = bg;
2786
+ if (typeof node.props.title === "string") rendered.title = node.props.title;
2787
+ const titleAlign = asAlign(node.props.titleAlign);
2788
+ if (titleAlign) rendered.titleAlign = titleAlign;
2789
+ if (typeof node.props.footer === "string") rendered.footer = node.props.footer;
2790
+ const footerAlign = asAlign(node.props.footerAlign);
2791
+ if (footerAlign) rendered.footerAlign = footerAlign;
2792
+ const borderColor = asColor(node.props.borderColor);
2793
+ if (borderColor !== void 0) rendered.borderStyle = { fg: borderColor };
2794
+ return rendered;
2795
+ }
2796
+ /**
2797
+ * Walk a UINode tree and collect the handler ids attached to each node, keyed
2798
+ * by node id, so the host can dispatch events without re-parsing props.
2799
+ */
2800
+ function extractHandlers(root) {
2801
+ const handlers = /* @__PURE__ */ new Map();
2802
+ if (!root) return handlers;
2803
+ const visit = (node) => {
2804
+ let entry;
2805
+ for (const [key, value] of Object.entries(node.props)) {
2806
+ if (!isHandlerIdProp(key) || typeof value !== "string") continue;
2807
+ const event = extractEventName(key);
2808
+ if (!event || !EVENT_PROPS.includes(event)) continue;
2809
+ (entry ??= {})[event] = value;
2810
+ }
2811
+ if (entry) handlers.set(node.id, entry);
2812
+ for (const child of node.children) if (typeof child !== "string") visit(child);
2813
+ };
2814
+ visit(root);
2815
+ return handlers;
2816
+ }
2817
+ var TEXT_TYPES = /* @__PURE__ */ new Set([
2818
+ "#text",
2819
+ "text",
2820
+ "span",
2821
+ "p",
2822
+ "strong",
2823
+ "em",
2824
+ "code",
2825
+ "label"
2826
+ ]);
2827
+ var TEXTBOX_TYPES = /* @__PURE__ */ new Set([
2828
+ "input",
2829
+ "textarea",
2830
+ "textbox"
2831
+ ]);
2832
+ function hasClickHandler(node) {
2833
+ return Object.keys(node.props).some((key) => isHandlerIdProp(key) && key.includes("onClick"));
2834
+ }
2835
+ function inferRole(node) {
2836
+ const explicit = node.props.role;
2837
+ if (typeof explicit === "string") return explicit;
2838
+ if (node.type === "checkbox" || node.type === "switch") return "checkbox";
2839
+ if (node.type === "tab") return "tab";
2840
+ if (TEXTBOX_TYPES.has(node.type)) return "textbox";
2841
+ if (node.type === "button" || hasClickHandler(node)) return "button";
2842
+ if (TEXT_TYPES.has(node.type)) return "text";
2843
+ return "group";
2844
+ }
2845
+ /** Flattened text content of a node's subtree. */
2846
+ function collectText(node) {
2847
+ if (node.type === "#text") return node.text ?? "";
2848
+ let out = "";
2849
+ for (const child of node.children) {
2850
+ const direct = textContent(child);
2851
+ out += direct !== null ? direct : typeof child === "string" ? child : collectText(child);
2852
+ }
2853
+ return out;
2854
+ }
2855
+ function accessibleName(node, text) {
2856
+ const candidates = [
2857
+ node.props["aria-label"],
2858
+ node.props.name,
2859
+ node.props.label
2860
+ ];
2861
+ for (const value of candidates) if (typeof value === "string" && value.length > 0) return value;
2862
+ return text.length > 0 ? text : void 0;
2863
+ }
2864
+ /** Derive the semantic (accessibility) tree from a UINode tree. */
2865
+ function buildSemanticTree(node) {
2866
+ if (!node) return null;
2867
+ const role = inferRole(node);
2868
+ const text = collectText(node);
2869
+ const semantic = {
2870
+ id: node.id,
2871
+ role,
2872
+ children: node.children.filter((c) => typeof c !== "string" && c.type !== "#text").map((c) => buildSemanticTree(c)).filter((c) => c !== null)
2873
+ };
2874
+ if (role === "text") semantic.text = text;
2875
+ else {
2876
+ const name = accessibleName(node, role === "group" ? "" : text);
2877
+ if (name !== void 0) semantic.name = name;
2878
+ }
2879
+ if (role === "textbox" && typeof node.props.value === "string") semantic.value = node.props.value;
2880
+ if (node.props.disabled === true) semantic.disabled = true;
2881
+ if (node.props.checked === true) semantic.checked = true;
2882
+ if (node.props.selected === true) semantic.selected = true;
2883
+ return semantic;
2884
+ }
2885
+ function matches(value, matcher) {
2886
+ if (value === void 0) return false;
2887
+ return typeof matcher === "string" ? value === matcher : matcher.test(value);
2888
+ }
2889
+ function* walk$1(node) {
2890
+ if (!node) return;
2891
+ yield node;
2892
+ for (const child of node.children) yield* walk$1(child);
2893
+ }
2894
+ /** First node matching `role` (and optional accessible name). */
2895
+ function queryByRole(tree, role, query = {}) {
2896
+ for (const node of walk$1(tree)) {
2897
+ if (node.role !== role) continue;
2898
+ if (query.name !== void 0 && !matches(node.name, query.name)) continue;
2899
+ return node;
2900
+ }
2901
+ return null;
2902
+ }
2903
+ /** First node whose text or name matches. */
2904
+ function queryByText(tree, matcher) {
2905
+ for (const node of walk$1(tree)) if (matches(node.text, matcher) || matches(node.name, matcher)) return node;
2906
+ return null;
2907
+ }
2908
+ /** Node with the given id. */
2909
+ function queryById(tree, id) {
2910
+ for (const node of walk$1(tree)) if (node.id === id) return node;
2911
+ return null;
2912
+ }
2913
+ /**
2914
+ * A terminal host for the Uniview protocol. It consumes `setRoot` and mutation
2915
+ * batches into a {@link MutableTree}, converts the tree to a tui-core render
2916
+ * tree, drives a {@link TuiRenderer}, and dispatches input back to plugin
2917
+ * handlers by id — the plan's "TUI becomes a Uniview host".
2918
+ */
2919
+ var TuiHost = class {
2920
+ renderer;
2921
+ tree = new MutableTree();
2922
+ onInvokeHandler;
2923
+ handlers = /* @__PURE__ */ new Map();
2924
+ invocations = [];
2925
+ committed;
2926
+ staticCounts = /* @__PURE__ */ new Map();
2927
+ focusedId = null;
2928
+ lifecycle = "active";
2929
+ /** Whether host mutations and event dispatch remain available. */
2930
+ get isActive() {
2931
+ if (this.lifecycle === "active" && !this.renderer.isActive) this.lifecycle = "destroying";
2932
+ return this.lifecycle === "active";
2933
+ }
2934
+ constructor(options) {
2935
+ this.onInvokeHandler = options.onInvokeHandler;
2936
+ this.committed = options.committed;
2937
+ this.renderer = new TuiRenderer({
2938
+ surface: options.surface,
2939
+ size: options.size,
2940
+ styles: options.styles ?? new StyleTable(),
2941
+ schedule: options.schedule,
2942
+ layoutEngine: options.layoutEngine,
2943
+ selection: options.selection
2944
+ });
2945
+ }
2946
+ /** Replace the whole tree and render. */
2947
+ setRoot(node) {
2948
+ this.assertActive("set a root");
2949
+ this.tree.apply({
2950
+ type: "setRoot",
2951
+ node
2952
+ });
2953
+ this.render();
2954
+ }
2955
+ /** Apply a mutation batch and render. */
2956
+ applyBatch(mutations) {
2957
+ this.assertActive("apply mutations");
2958
+ this.tree.applyBatch(mutations);
2959
+ this.render();
2960
+ }
2961
+ /** Convert the current tree and paint a frame. */
2962
+ render() {
2963
+ this.assertActive("render");
2964
+ try {
2965
+ const root = this.tree.getRoot();
2966
+ this.handlers = extractHandlers(root);
2967
+ this.flushStatic(root);
2968
+ this.renderer.setRoot(root ? uinodeToRenderNode(root, this.focusedId) : null);
2969
+ this.renderer.flush();
2970
+ } catch (error) {
2971
+ if (!this.renderer.isActive) this.lifecycle = "destroying";
2972
+ throw error;
2973
+ }
2974
+ }
2975
+ /**
2976
+ * Record which node currently holds focus and repaint if it changed. The
2977
+ * {@link InputRouter} calls this after every focus move so the text-field
2978
+ * caret (resolved in {@link uinodeToRenderNode}) tracks focus without a
2979
+ * plugin re-render — focus stays host-local (the plan's principle 3).
2980
+ */
2981
+ setFocusedId(id) {
2982
+ this.assertActive("set focus");
2983
+ if (id === this.focusedId) return;
2984
+ this.focusedId = id;
2985
+ this.render();
2986
+ }
2987
+ /** Imperatively append finalized lines to the committed-output channel (direct mode). */
2988
+ commitStatic(lines) {
2989
+ this.assertActive("commit static output");
2990
+ this.committed?.commit(lines);
2991
+ }
2992
+ /**
2993
+ * Commit the `staticLines` of every `role="log"` node, deduped per node id —
2994
+ * only lines beyond that node's high-water mark are written, so appending
2995
+ * items re-commits only the new ones and a plain re-render writes nothing.
2996
+ */
2997
+ flushStatic(root) {
2998
+ const committed = this.committed;
2999
+ if (!committed || !root) return;
3000
+ const visit = (node) => {
3001
+ const lines = node.props.staticLines;
3002
+ if (Array.isArray(lines)) {
3003
+ const already = this.staticCounts.get(node.id) ?? 0;
3004
+ if (lines.length > already) {
3005
+ const fresh = [];
3006
+ for (let i = already; i < lines.length; i += 1) {
3007
+ const value = lines[i];
3008
+ if (typeof value === "string") fresh.push([{ text: value }]);
3009
+ }
3010
+ committed.commit(fresh);
3011
+ this.staticCounts.set(node.id, lines.length);
3012
+ }
3013
+ }
3014
+ for (const child of node.children) if (typeof child !== "string") visit(child);
3015
+ };
3016
+ visit(root);
3017
+ }
3018
+ /** Node ids (in tree order) that have a handler for `event`. */
3019
+ eventTargets(event) {
3020
+ const ids = [];
3021
+ for (const [id, map] of this.handlers) if (map[event] !== void 0) ids.push(id);
3022
+ return ids;
3023
+ }
3024
+ /** True when `nodeId`'s UINode carries `disabled: true`. */
3025
+ isDisabled(nodeId) {
3026
+ return this.tree.getNode(nodeId)?.props.disabled === true;
3027
+ }
3028
+ /**
3029
+ * Focusable nodes in tree order — those that can be clicked or that edit
3030
+ * text. `textbox` is true when the node accepts text input (has onChange).
3031
+ * Disabled nodes are excluded, matching how HTML `disabled` removes an
3032
+ * element from the tab order rather than merely styling it.
3033
+ */
3034
+ focusableTargets() {
3035
+ const targets = [];
3036
+ for (const [id, map] of this.handlers) {
3037
+ if (this.isDisabled(id)) continue;
3038
+ const textbox = map.onChange !== void 0;
3039
+ if (map.onClick !== void 0 || map.onKeyDown !== void 0 || textbox) {
3040
+ const autoFocus = this.tree.getNode(id)?.props.autoFocus === true;
3041
+ targets.push({
3042
+ id,
3043
+ textbox,
3044
+ autoFocus
3045
+ });
3046
+ }
3047
+ }
3048
+ return targets;
3049
+ }
3050
+ /** The plugin node id owning the cell at `(x, y)`, or null. */
3051
+ nodeAt(x, y) {
3052
+ const frame = this.renderer.currentFrame;
3053
+ if (!frame) return null;
3054
+ return hitTest(frame, this.renderer.owners, x, y);
3055
+ }
3056
+ /**
3057
+ * Fire an event on a node; returns whether a handler was invoked. A disabled
3058
+ * node never fires — this is the single choke point every input path
3059
+ * (click, key, automation) routes through, so gating here is what actually
3060
+ * makes `disabled` mean something rather than a prop `semantics.ts` reports
3061
+ * but nothing enforces.
3062
+ */
3063
+ fireEvent(nodeId, event, payload) {
3064
+ this.assertActive("dispatch an event");
3065
+ if (this.isDisabled(nodeId)) return false;
3066
+ const handlerId = this.handlers.get(nodeId)?.[event];
3067
+ if (handlerId === void 0) return false;
3068
+ this.invocations.push({
3069
+ id: handlerId,
3070
+ payload
3071
+ });
3072
+ this.onInvokeHandler?.(handlerId, payload);
3073
+ return true;
3074
+ }
3075
+ /** The handler ids invoked so far (a command trace for automation). */
3076
+ commands() {
3077
+ return this.invocations;
3078
+ }
3079
+ /** Clear the recorded command trace. */
3080
+ resetCommands() {
3081
+ this.assertActive("reset commands");
3082
+ this.invocations.length = 0;
3083
+ }
3084
+ /**
3085
+ * The nearest node at or above `startId` that has a handler for any of
3086
+ * `events` — used to resolve hover/wheel targets by bubbling from the node
3087
+ * under the pointer. Returns null when none is found.
3088
+ */
3089
+ nearestTarget(startId, events) {
3090
+ let id = startId;
3091
+ while (id) {
3092
+ const map = this.handlers.get(id);
3093
+ if (map && events.some((e) => map[e] !== void 0)) return id;
3094
+ id = this.tree.parentId(id);
3095
+ }
3096
+ return null;
3097
+ }
3098
+ /**
3099
+ * The nearest node at or above `startId` that can take focus. A pointer hit
3100
+ * usually lands on a leaf (the label inside a row), which is not focusable
3101
+ * itself — focusing it would be a silent no-op, leaving focus stranded on
3102
+ * whatever was focused before.
3103
+ */
3104
+ nearestFocusable(startId) {
3105
+ const focusable = new Set(this.focusableTargets().map((t) => t.id));
3106
+ let id = startId;
3107
+ while (id) {
3108
+ if (focusable.has(id)) return id;
3109
+ id = this.tree.parentId(id);
3110
+ }
3111
+ return null;
3112
+ }
3113
+ /**
3114
+ * Fire an event starting at `startId` and bubbling up ancestors until a
3115
+ * handler runs (like DOM bubbling). Returns whether any handler was invoked.
3116
+ */
3117
+ fireEventBubbling(startId, event, payload) {
3118
+ this.assertActive("dispatch a bubbling event");
3119
+ let id = startId;
3120
+ while (id) {
3121
+ if (this.fireEvent(id, event, payload)) return true;
3122
+ id = this.tree.parentId(id);
3123
+ }
3124
+ return false;
3125
+ }
3126
+ /** The accessibility tree derived from the current UINode tree. */
3127
+ semanticTree() {
3128
+ return buildSemanticTree(this.tree.getRoot());
3129
+ }
3130
+ queryByRole(role, query) {
3131
+ return queryByRole(this.semanticTree(), role, query);
3132
+ }
3133
+ queryByText(matcher) {
3134
+ return queryByText(this.semanticTree(), matcher);
3135
+ }
3136
+ queryById(id) {
3137
+ return queryById(this.semanticTree(), id);
3138
+ }
3139
+ /**
3140
+ * Resolve a semantic target (by role+name or id) and activate it — the
3141
+ * automation `act` primitive that drives by semantics, not coordinates.
3142
+ * Returns whether a matching control's handler ran.
3143
+ */
3144
+ activate(target) {
3145
+ this.assertActive("activate a target");
3146
+ const node = "id" in target ? this.queryById(target.id) : this.queryByRole(target.role, { name: target.name });
3147
+ if (!node) return false;
3148
+ return this.fireEvent(node.id, "onClick");
3149
+ }
3150
+ destroy() {
3151
+ if (this.lifecycle === "destroyed") return;
3152
+ this.lifecycle = "destroying";
3153
+ this.renderer.destroy();
3154
+ this.lifecycle = "destroyed";
3155
+ }
3156
+ assertActive(action) {
3157
+ if (!this.isActive) throw new Error(`Cannot ${action} after TUI host teardown has started`);
3158
+ }
3159
+ };
3160
+ var HOVER_EVENTS = ["onMouseEnter", "onMouseLeave"];
3161
+ var WHEEL_EVENTS = ["onWheel"];
3162
+ var KEY_EVENTS = ["onKeyDown"];
3163
+ var TEXT_EDITING_KEYS = /* @__PURE__ */ new Set([
3164
+ "ArrowLeft",
3165
+ "ArrowRight",
3166
+ "Home",
3167
+ "End",
3168
+ "Backspace",
3169
+ "Delete",
3170
+ "Enter"
3171
+ ]);
3172
+ function isTextEditingEvent(event) {
3173
+ return event.type === "text" || event.type === "paste" || event.type === "key" && TEXT_EDITING_KEYS.has(event.key);
3174
+ }
3175
+ /**
3176
+ * Routes normalized input to the right control for a {@link TuiHost}: keeps a
3177
+ * host-local {@link TextInputMachine} per text field, dispatches editing keys
3178
+ * to the focused field (firing onChange/onSubmit), and Tab/Enter/Space/click to
3179
+ * buttons. Field state lives in the host, not the plugin — the plan's
3180
+ * "local default actions" with optimistic controlled reconciliation (§5.4).
3181
+ */
3182
+ var InputRouter = class {
3183
+ host;
3184
+ focus = new FocusManager();
3185
+ fields = /* @__PURE__ */ new Map();
3186
+ hoveredId = null;
3187
+ autoFocused = false;
3188
+ inputSubscribers = /* @__PURE__ */ new Set();
3189
+ constructor(host) {
3190
+ this.host = host;
3191
+ }
3192
+ /**
3193
+ * Subscribe to global input — key/text events the focused control did not
3194
+ * consume, plus every paste. This is the host-side seam useInput/usePaste
3195
+ * build on: high-frequency keys resolve here, never one RPC round trip per
3196
+ * event (the plan's principle 3). Returns an unsubscribe function.
3197
+ */
3198
+ subscribeInput(listener) {
3199
+ this.assertActive("subscribe to input");
3200
+ this.inputSubscribers.add(listener);
3201
+ return () => this.inputSubscribers.delete(listener);
3202
+ }
3203
+ emitGlobal(event) {
3204
+ for (const listener of this.inputSubscribers) {
3205
+ if (!this.host.isActive) return;
3206
+ listener(event);
3207
+ }
3208
+ }
3209
+ /** Refresh the focusable set after a render; prunes fields for removed nodes. */
3210
+ onRender() {
3211
+ this.assertActive("refresh input state");
3212
+ const targets = this.host.focusableTargets();
3213
+ this.focus.setFocusables(targets.map((t) => ({ id: t.id })));
3214
+ const live = new Set(targets.map((t) => t.id));
3215
+ for (const id of [...this.fields.keys()]) if (!live.has(id)) this.fields.delete(id);
3216
+ if (this.hoveredId && this.host.nearestTarget(this.hoveredId, HOVER_EVENTS) !== this.hoveredId) this.hoveredId = null;
3217
+ if (!this.autoFocused && this.focus.focused === null) {
3218
+ const auto = targets.find((t) => t.autoFocus);
3219
+ if (auto) {
3220
+ this.autoFocused = true;
3221
+ this.focus.focus(auto.id, "programmatic");
3222
+ }
3223
+ }
3224
+ this.syncFocus();
3225
+ }
3226
+ /** Mirror the current focus into the host so the caret repaints where focus went. */
3227
+ syncFocus() {
3228
+ this.host.setFocusedId(this.focus.focused);
3229
+ }
3230
+ /** Update hover: leave the previous target, enter the new one under (x, y). */
3231
+ updateHover(x, y) {
3232
+ const target = this.host.nearestTarget(this.host.nodeAt(x, y), HOVER_EVENTS);
3233
+ if (target === this.hoveredId) return target !== null;
3234
+ if (this.hoveredId) this.host.fireEvent(this.hoveredId, "onMouseLeave", {
3235
+ x,
3236
+ y
3237
+ });
3238
+ this.hoveredId = target;
3239
+ if (target) this.host.fireEvent(target, "onMouseEnter", {
3240
+ x,
3241
+ y
3242
+ });
3243
+ return true;
3244
+ }
3245
+ get focusedId() {
3246
+ return this.focus.focused;
3247
+ }
3248
+ /** Release local pointer/keyboard focus so application-level navigation can take over. */
3249
+ clearFocus() {
3250
+ this.assertActive("clear focus");
3251
+ this.focus.focus(null, "programmatic");
3252
+ this.syncFocus();
3253
+ }
3254
+ isTextbox(id) {
3255
+ return this.host.focusableTargets().some((t) => t.id === id && t.textbox);
3256
+ }
3257
+ hasKeyHandler(id) {
3258
+ return this.host.eventTargets("onKeyDown").includes(id);
3259
+ }
3260
+ fieldFor(id) {
3261
+ const committed = this.host.queryById(id)?.value ?? "";
3262
+ let field = this.fields.get(id);
3263
+ if (!field) {
3264
+ field = {
3265
+ machine: new TextInputMachine({
3266
+ value: committed,
3267
+ cursor: committed.length
3268
+ }),
3269
+ lastSent: committed,
3270
+ lastObserved: committed
3271
+ };
3272
+ this.fields.set(id, field);
3273
+ } else if (committed !== field.lastObserved) {
3274
+ field.lastObserved = committed;
3275
+ if (committed !== field.lastSent) {
3276
+ field.machine.setValue(committed);
3277
+ field.lastSent = committed;
3278
+ }
3279
+ }
3280
+ return field;
3281
+ }
3282
+ /**
3283
+ * Route one event and report whether a local control consumed it.
3284
+ *
3285
+ * `false` means the event reached the global input layer. Direct terminal
3286
+ * clients can use that signal to apply their own hotkeys without stealing
3287
+ * Enter/Space from a focused button, row, or tab.
3288
+ */
3289
+ dispatch(event) {
3290
+ this.assertActive("dispatch input");
3291
+ if (this.host.renderer.handleSelectionInput(event).consumed) return true;
3292
+ if (event.type === "mouse") {
3293
+ if (event.action === "move" || event.action === "drag") return this.updateHover(event.x, event.y);
3294
+ if (event.action === "wheel") {
3295
+ const target = this.host.nearestTarget(this.host.nodeAt(event.x, event.y), WHEEL_EVENTS);
3296
+ if (target) this.host.fireEvent(target, "onWheel", {
3297
+ deltaY: event.deltaY ?? 0,
3298
+ x: event.x,
3299
+ y: event.y
3300
+ });
3301
+ return target !== null;
3302
+ }
3303
+ if (event.action === "up" && event.button === "left") {
3304
+ const id = this.host.nodeAt(event.x, event.y);
3305
+ let consumed = false;
3306
+ if (id) {
3307
+ const focusTarget = this.host.nearestFocusable(id);
3308
+ if (focusTarget) {
3309
+ this.focus.focus(focusTarget, "pointer");
3310
+ this.syncFocus();
3311
+ consumed = true;
3312
+ }
3313
+ if (!this.isTextbox(id)) consumed = this.host.fireEventBubbling(id, "onClick", {
3314
+ x: event.x,
3315
+ y: event.y
3316
+ }) || consumed;
3317
+ }
3318
+ return consumed;
3319
+ }
3320
+ return false;
3321
+ }
3322
+ if (event.type === "key" && event.key === "Tab") {
3323
+ const focused = this.focus.move(event.shift ? "previous" : "next");
3324
+ this.syncFocus();
3325
+ if (focused !== null) return true;
3326
+ this.emitGlobal(event);
3327
+ return false;
3328
+ }
3329
+ const focused = this.focus.focused;
3330
+ if (focused && this.isTextbox(focused)) {
3331
+ const field = this.fieldFor(focused);
3332
+ const before = field.machine.value;
3333
+ const effects = field.machine.handle(event);
3334
+ for (const effect of effects) if (effect.type === "change") {
3335
+ if (effect.value !== before) {
3336
+ field.lastSent = effect.value;
3337
+ this.host.fireEvent(focused, "onChange", effect.value);
3338
+ }
3339
+ } else this.host.fireEvent(focused, "onSubmit", effect.value);
3340
+ if (effects.length > 0 || isTextEditingEvent(event)) return true;
3341
+ }
3342
+ if (event.type === "key" && focused && this.hasKeyHandler(focused)) {
3343
+ this.fireKey(focused, event);
3344
+ return true;
3345
+ }
3346
+ if (event.type === "key" && event.key === "Enter" && focused) {
3347
+ if (this.host.fireEvent(focused, "onClick")) return true;
3348
+ }
3349
+ if (event.type === "text" && event.text === " " && focused) {
3350
+ if (this.host.fireEvent(focused, "onClick")) return true;
3351
+ }
3352
+ if (event.type === "key" && focused) {
3353
+ const target = this.host.nearestTarget(focused, KEY_EVENTS);
3354
+ if (target) {
3355
+ this.fireKey(target, event);
3356
+ return true;
3357
+ }
3358
+ }
3359
+ if (event.type === "key" || event.type === "text" || event.type === "paste") this.emitGlobal(event);
3360
+ return false;
3361
+ }
3362
+ fireKey(id, event) {
3363
+ this.host.fireEvent(id, "onKeyDown", {
3364
+ key: event.key,
3365
+ ctrl: event.ctrl,
3366
+ alt: event.alt,
3367
+ shift: event.shift,
3368
+ meta: event.meta
3369
+ });
3370
+ }
3371
+ assertActive(action) {
3372
+ if (!this.host.isActive) throw new Error(`Cannot ${action} after TUI host teardown has started`);
3373
+ }
3374
+ };
3375
+ /** Provides the host {@link InputRouter} to `useInput`/`usePaste`. */
3376
+ var TuiRuntimeContext = createContext();
3377
+ /**
3378
+ * Subscribe to global keyboard input (keys/text the focused control did not
3379
+ * consume). Same signature and mapping as `@uniview/tui-react`'s `useInput`, so
3380
+ * a plugin reads identically in either binding. Resolved host-side — no per-event
3381
+ * RPC. A no-op outside a Tui root.
3382
+ */
3383
+ function useInput(handler, opts = {}) {
3384
+ const router = useContext(TuiRuntimeContext);
3385
+ createEffect(() => {
3386
+ if (!router || opts.isActive === false) return;
3387
+ onCleanup(router.subscribeInput((event) => {
3388
+ if (event.type !== "key" && event.type !== "text") return;
3389
+ const { input, key } = toInputKey(event);
3390
+ handler(input, key);
3391
+ }));
3392
+ });
3393
+ }
3394
+ function devFlag() {
3395
+ return typeof process !== "undefined" && process.env?.TUI_DEVTOOLS === "1";
3396
+ }
3397
+ /**
3398
+ * Connect the plugin to Solid DevTools when a dev flag is set. The devtools
3399
+ * package is *dynamically imported behind the flag* (a variable specifier, so
3400
+ * it need not be installed for production builds/type-checks) and any failure
3401
+ * — including the package being absent — is swallowed: devtools is best-effort.
3402
+ */
3403
+ async function connectSolidDevTools(opts = {}) {
3404
+ if (!(opts.enabled ?? devFlag())) return;
3405
+ const connect = opts.connect ?? (async () => {
3406
+ await import("solid-devtools");
3407
+ });
3408
+ try {
3409
+ await connect();
3410
+ } catch (error) {
3411
+ console.warn("[tui-solid] devtools connection failed:", error);
3412
+ }
3413
+ }
3414
+ createLowlight(common);
3415
+ /**
3416
+ * First-class JSX components for the Uniview TUI host primitives, so Solid
3417
+ * plugins author terminal UI in real JSX (ink-style), e.g.
3418
+ *
3419
+ * ```tsx
3420
+ * <Box flexDirection="column" padding={1} border="rounded">
3421
+ * <Text color="cyan" bold>Hello</Text>
3422
+ * </Box>
3423
+ * ```
3424
+ *
3425
+ * They are thin, typed wrappers over the `box` / `text` / `richtext`
3426
+ * primitives the Solid renderer renders — capitalized because Solid's
3427
+ * lowercase JSX intrinsics are typed only by a catch-all
3428
+ * `[tag: string]: unknown` (zero safety). Mirrors
3429
+ * `@uniview/tui-react`'s `primitives.ts` convention.
3430
+ */
3431
+ /** Attributes shared by every TUI element: layout ({@link TuiStyle}) + handlers + semantics. */
3432
+ /** Props for {@link Box}. */
3433
+ /** Props for {@link Text}. */
3434
+ /** Props for {@link RichText}. */
3435
+ /**
3436
+ * A flexbox container (`box` primitive).
3437
+ *
3438
+ * NOTE: props are spread, never destructured — destructuring would read each
3439
+ * prop eagerly and break Solid's fine-grained (getter-based) reactivity.
3440
+ */
3441
+ function Box(props) {
3442
+ return (() => {
3443
+ var _el$ = createElement("box");
3444
+ spread(_el$, props, false);
3445
+ return _el$;
3446
+ })();
3447
+ }
3448
+ /**
3449
+ * Styled text (`text` primitive). Children are strings/numbers.
3450
+ *
3451
+ * Built via the low-level renderer primitives instead of literal
3452
+ * `<text {...props} />` JSX: solid-js's own JSX typings declare a `text` SVG
3453
+ * intrinsic (`JSX.IntrinsicElements["text"]: TextSVGAttributes<SVGTextElement>`)
3454
+ * whose `onChange` expects a DOM `Event`, which is structurally incompatible
3455
+ * with {@link TuiEventHandlers.onChange}'s `(value: string) => void`.
3456
+ * TypeScript requires every partial declaration merged into
3457
+ * `JSX.IntrinsicElements` to agree on a property's type, so that collision
3458
+ * can't be resolved by widening `"text"`'s declared prop type — the only tag
3459
+ * among box/text/richtext that collides with a real DOM/SVG element name.
3460
+ * This mirrors exactly how `@uniview/tui-react` avoids the same class of
3461
+ * problem: it builds the element via `createElement("text", props)` instead
3462
+ * of raw `<text>` JSX. `spread` reads `props` through its getters inside a
3463
+ * reactive effect (the same mechanism the compiler emits for `{...props}`),
3464
+ * so this preserves Solid's fine-grained reactivity exactly like the JSX form.
3465
+ */
3466
+ function Text(props) {
3467
+ const node = createElement("text");
3468
+ spread(node, props, false);
3469
+ return node;
3470
+ }
3471
+ /**
3472
+ * A vertical scrollbar: a 1-cell-wide column of `height` rows with a thumb sized
3473
+ * and positioned by {@link scrollbarThumb}. Reusable on its own or inside
3474
+ * {@link ScrollView}.
3475
+ */
3476
+ function Scrollbar(props) {
3477
+ const geometry = createMemo(() => scrollbarThumb(props.total, props.height, props.value));
3478
+ return (() => {
3479
+ var _el$ = createElement("box");
3480
+ setProp(_el$, "flexDirection", "column");
3481
+ setProp(_el$, "width", 1);
3482
+ insert(_el$, createComponent$1(Index, {
3483
+ get each() {
3484
+ return Array.from({ length: props.height });
3485
+ },
3486
+ children: (_, i) => {
3487
+ const on = createMemo(() => i >= geometry().start && i < geometry().start + geometry().thumb);
3488
+ return createComponent$1(Text, {
3489
+ get color() {
3490
+ return memo(() => !!on())() ? props.thumbColor ?? "white" : props.trackColor ?? "gray";
3491
+ },
3492
+ get dim() {
3493
+ return !on();
3494
+ },
3495
+ get children() {
3496
+ return on() ? "█" : "│";
3497
+ }
3498
+ });
3499
+ }
3500
+ }));
3501
+ return _el$;
3502
+ })();
3503
+ }
3504
+ /** A bordered, titled, focusable panel — the lazygit window primitive. */
3505
+ /**
3506
+ * Solid port of `@uniview/tui-react`'s `Panel` — stateless, a pure prop→element
3507
+ * mapping onto the `box` primitive (whose `title`/`footer`/`borderColor` props
3508
+ * are interpreted by `@uniview/host-tui`'s converter).
3509
+ *
3510
+ * NOTE: props are read through {@link splitProps} + getters, never destructured
3511
+ * — destructuring would snapshot each prop eagerly and break Solid's
3512
+ * fine-grained reactivity (a `focused` signal would stop repainting the border).
3513
+ */
3514
+ function Panel(props) {
3515
+ const [, rest] = splitProps(props, [
3516
+ "title",
3517
+ "titleAlign",
3518
+ "footer",
3519
+ "footerAlign",
3520
+ "focused",
3521
+ "focusedColor",
3522
+ "borderColor",
3523
+ "border",
3524
+ "children"
3525
+ ]);
3526
+ const border = () => props.border ?? "rounded";
3527
+ const resolvedBorderColor = () => props.focused ? props.focusedColor ?? "green" : props.borderColor;
3528
+ return (() => {
3529
+ var _el$ = createElement("box");
3530
+ spread(_el$, mergeProps$1(rest, {
3531
+ get border() {
3532
+ return border();
3533
+ },
3534
+ get title() {
3535
+ return props.title;
3536
+ },
3537
+ get titleAlign() {
3538
+ return props.titleAlign;
3539
+ },
3540
+ get footer() {
3541
+ return props.footer;
3542
+ },
3543
+ get footerAlign() {
3544
+ return props.footerAlign;
3545
+ },
3546
+ get borderColor() {
3547
+ return resolvedBorderColor();
3548
+ }
3549
+ }), true);
3550
+ insert(_el$, () => props.children);
3551
+ return _el$;
3552
+ })();
3553
+ }
3554
+ var activeSolidRootOwner = null;
3555
+ var pendingSolidSessionCleanup = null;
3556
+ var retryingPendingSolidSessionCleanup = false;
3557
+ function retryPendingSolidSessionCleanup(nextOwner) {
3558
+ const pending = pendingSolidSessionCleanup;
3559
+ if (!pending || pending.owner === nextOwner) return;
3560
+ if (retryingPendingSolidSessionCleanup) throw new Error("TUI Solid root cleanup is already in progress");
3561
+ retryingPendingSolidSessionCleanup = true;
3562
+ try {
3563
+ pending.driver.stop();
3564
+ if (pendingSolidSessionCleanup === pending) pendingSolidSessionCleanup = null;
3565
+ } finally {
3566
+ retryingPendingSolidSessionCleanup = false;
3567
+ }
3568
+ }
3569
+ function reserveSolidRootOwnership(owner) {
3570
+ retryPendingSolidSessionCleanup(owner);
3571
+ if (activeSolidRootOwner && activeSolidRootOwner !== owner) throw new Error("Cannot render because another TUI Solid root is active; destroy it before rendering this root");
3572
+ activeSolidRootOwner = owner;
3573
+ }
3574
+ function releaseSolidRootOwnership(owner) {
3575
+ if (activeSolidRootOwner === owner) activeSolidRootOwner = null;
3576
+ }
3577
+ /**
3578
+ * Render a Solid plugin to a terminal {@link CellSurface}. Solid's fine-grained
3579
+ * reactivity commits synchronously; each update serializes to UINode and feeds
3580
+ * a {@link TuiHost}, and input routes back exactly as in the React adapter.
3581
+ * Together with @uniview/tui-react this proves the framework-agnostic host.
3582
+ *
3583
+ * Note: solid-renderer uses a single module-global root, so one Solid root may
3584
+ * be active per process at a time.
3585
+ */
3586
+ function createTuiSolidRootInternal(options, owner) {
3587
+ const registry = new HandlerRegistry();
3588
+ const host = new TuiHost({
3589
+ surface: options.surface,
3590
+ size: options.size,
3591
+ styles: options.styles,
3592
+ committed: options.committed,
3593
+ layoutEngine: options.layoutEngine,
3594
+ selection: options.selection,
3595
+ onInvokeHandler: (handlerId, payload) => {
3596
+ registry.execute(handlerId, payload);
3597
+ }
3598
+ });
3599
+ const router = new InputRouter(host);
3600
+ const clock = options.clock ?? new FrameClock({
3601
+ now: () => performance.now(),
3602
+ requestFrame: (frame) => {
3603
+ setTimeout(frame, 16);
3604
+ },
3605
+ diagnostics: host.renderer.diagnostics
3606
+ });
3607
+ if (options.devtools) connectSolidDevTools({ enabled: true });
3608
+ const ownsGlobals = () => activeSolidRootOwner === owner;
3609
+ const sync = () => {
3610
+ const appRoot = getRootNode()?.children[0] ?? null;
3611
+ const tree = appRoot ? serializeTree(appRoot, registry) : null;
3612
+ host.setRoot(tree && typeof tree !== "string" ? tree : null);
3613
+ router.onRender();
3614
+ };
3615
+ let dispose = null;
3616
+ let teardownStarted = false;
3617
+ let globalsInstalled = false;
3618
+ let hostDestroyed = false;
3619
+ const reserveOwnership = () => {
3620
+ reserveSolidRootOwnership(owner);
3621
+ };
3622
+ const releaseOwnership = () => {
3623
+ if (!ownsGlobals()) return;
3624
+ if (globalsInstalled) {
3625
+ setUpdateCallback(null);
3626
+ setMutationUpdateCallback(null);
3627
+ setMutationCollector(null);
3628
+ setRootNode(null);
3629
+ }
3630
+ globalsInstalled = false;
3631
+ releaseSolidRootOwnership(owner);
3632
+ };
3633
+ const installGlobals = () => {
3634
+ reserveOwnership();
3635
+ if (globalsInstalled) return;
3636
+ globalsInstalled = true;
3637
+ try {
3638
+ setRootNode(null);
3639
+ setMutationUpdateCallback(null);
3640
+ setMutationCollector(null);
3641
+ setUpdateCallback(sync);
3642
+ } catch (error) {
3643
+ releaseOwnership();
3644
+ throw error;
3645
+ }
3646
+ };
3647
+ const disposeMount = () => {
3648
+ const activeDispose = dispose;
3649
+ try {
3650
+ activeDispose?.();
3651
+ if (dispose === activeDispose) dispose = null;
3652
+ } finally {
3653
+ registry.clear();
3654
+ if (ownsGlobals() && globalsInstalled) setRootNode(null);
3655
+ }
3656
+ };
3657
+ return {
3658
+ host,
3659
+ clock,
3660
+ render(App) {
3661
+ if (hostDestroyed && !ownsGlobals()) throw new Error("Cannot render into a destroyed TUI Solid root");
3662
+ if (teardownStarted) throw new Error("Cannot render after TUI Solid root teardown has started");
3663
+ installGlobals();
3664
+ disposeMount();
3665
+ resetIdCounter();
3666
+ const container = {
3667
+ _type: "element",
3668
+ id: "__root",
3669
+ type: "div",
3670
+ props: {},
3671
+ children: [],
3672
+ parent: null
3673
+ };
3674
+ setRootNode(container);
3675
+ try {
3676
+ dispose = render(() => createComponent$1(TuiRuntimeContext.Provider, {
3677
+ value: router,
3678
+ get children() {
3679
+ return App();
3680
+ }
3681
+ }), container);
3682
+ } catch (error) {
3683
+ try {
3684
+ disposeMount();
3685
+ } catch {}
3686
+ if (dispose === null) try {
3687
+ releaseOwnership();
3688
+ } catch {}
3689
+ try {
3690
+ host.setRoot(null);
3691
+ router.onRender();
3692
+ } catch {}
3693
+ throw error;
3694
+ }
3695
+ sync();
3696
+ },
3697
+ dispatchInput(event) {
3698
+ if (teardownStarted) throw new Error("Cannot dispatch input after TUI Solid root teardown has started");
3699
+ router.dispatch(event);
3700
+ },
3701
+ dispatchInputWithResult(event) {
3702
+ if (teardownStarted) throw new Error("Cannot dispatch input after TUI Solid root teardown has started");
3703
+ return router.dispatch(event);
3704
+ },
3705
+ clearFocus() {
3706
+ if (teardownStarted) throw new Error("Cannot clear focus after TUI Solid root teardown has started");
3707
+ router.clearFocus();
3708
+ },
3709
+ destroy() {
3710
+ if (hostDestroyed && dispose === null && !ownsGlobals()) return;
3711
+ teardownStarted = true;
3712
+ let firstError;
3713
+ let hasError = false;
3714
+ const attempt = (cleanup, complete) => {
3715
+ try {
3716
+ cleanup();
3717
+ complete?.();
3718
+ } catch (error) {
3719
+ if (!hasError) {
3720
+ firstError = error;
3721
+ hasError = true;
3722
+ }
3723
+ }
3724
+ };
3725
+ if (dispose !== null) attempt(disposeMount);
3726
+ if (dispose === null && ownsGlobals()) attempt(releaseOwnership);
3727
+ if (!hostDestroyed) attempt(() => host.destroy(), () => {
3728
+ hostDestroyed = true;
3729
+ });
3730
+ if (hasError) throw firstError;
3731
+ }
3732
+ };
3733
+ }
3734
+ function createTuiSolidRoot(options) {
3735
+ return createTuiSolidRootInternal(options, {});
3736
+ }
3737
+ //#endregion
3738
+ //#region src/ui.tsx
3739
+ function runTui(options) {
3740
+ return new Promise((resolve) => {
3741
+ const styles = new StyleTable$1();
3742
+ const surface = new AnsiCellSurface({
3743
+ write: (chunk) => process.stdout.write(chunk),
3744
+ styles
3745
+ });
3746
+ const initialSize = {
3747
+ width: process.stdout.columns ?? 80,
3748
+ height: process.stdout.rows ?? 24
3749
+ };
3750
+ const [terminalSize, setTerminalSize] = createSignal(initialSize);
3751
+ const root = createTuiSolidRoot({
3752
+ surface,
3753
+ styles,
3754
+ size: initialSize
3755
+ });
3756
+ let stopped = false;
3757
+ let driverStarted = false;
3758
+ const quit = () => {
3759
+ if (stopped) return;
3760
+ stopped = true;
3761
+ root.destroy();
3762
+ if (driverStarted) driver.stop();
3763
+ resolve();
3764
+ };
3765
+ const driver = new TerminalDriver({
3766
+ input: process.stdin,
3767
+ output: process.stdout,
3768
+ screen: "alternate",
3769
+ mouse: "click",
3770
+ onEvent: (event) => {
3771
+ if (event.type === "resize") {
3772
+ setTerminalSize({
3773
+ width: event.width,
3774
+ height: event.height
3775
+ });
3776
+ root.host.renderer.resize({
3777
+ width: event.width,
3778
+ height: event.height
3779
+ });
3780
+ } else root.dispatchInput(event);
3781
+ }
3782
+ });
3783
+ try {
3784
+ driver.start();
3785
+ driverStarted = true;
3786
+ root.render(() => createComponent$1(SpaceLensApp, {
3787
+ options,
3788
+ terminalHeight: () => terminalSize().height,
3789
+ onQuit: quit
3790
+ }));
3791
+ process.stdin.on?.("end", quit);
3792
+ } catch (error) {
3793
+ try {
3794
+ root.destroy();
3795
+ } finally {
3796
+ if (driverStarted) driver.stop();
3797
+ }
3798
+ throw error;
3799
+ }
3800
+ });
3801
+ }
3802
+ function SpaceLensApp(props) {
3803
+ const state = createInitialTuiState();
3804
+ const [data, setData] = createSignal(props.options.initialData);
3805
+ const [executing, setExecuting] = createSignal(false);
3806
+ const [revision, setRevision] = createSignal(0);
3807
+ const touch = () => setRevision((value) => value + 1);
3808
+ const act = (action) => {
3809
+ applyTuiAction(state, action);
3810
+ touch();
3811
+ };
3812
+ const scan = createMemo(() => {
3813
+ revision();
3814
+ return createScanViewModel(data().scanTrees, state);
3815
+ });
3816
+ const clean = createMemo(() => {
3817
+ revision();
3818
+ return createCleanViewModel(data().plan, {
3819
+ sort: props.options.sort,
3820
+ state
3821
+ });
3822
+ });
3823
+ const selected = createMemo(() => {
3824
+ revision();
3825
+ return getSelectedEntries(state, data().plan.entries);
3826
+ });
3827
+ const viewportHeight = () => listViewportHeight(props.terminalHeight(), clean().errors.length);
3828
+ const activeRows = () => state.mode === "scan" ? scan().rows : clean().rows;
3829
+ const activeMode = () => {
3830
+ revision();
3831
+ return state.mode;
3832
+ };
3833
+ const status = () => {
3834
+ revision();
3835
+ return state.status;
3836
+ };
3837
+ const confirmExecute = () => {
3838
+ revision();
3839
+ return state.confirmExecute;
3840
+ };
3841
+ const move = (delta) => {
3842
+ act({
3843
+ type: "move",
3844
+ delta,
3845
+ rowCount: activeRows().length
3846
+ });
3847
+ };
3848
+ const toggleCurrent = () => {
3849
+ if (activeMode() !== "clean") return;
3850
+ const row = clean().rows[clean().cursor];
3851
+ if (row) act({
3852
+ type: "toggle-selected",
3853
+ path: row.path
3854
+ });
3855
+ };
3856
+ const executeSelected = () => {
3857
+ const entries = selected();
3858
+ if (entries.length === 0) {
3859
+ act({
3860
+ type: "set-status",
3861
+ status: "Nothing selected."
3862
+ });
3863
+ return;
3864
+ }
3865
+ setExecuting(true);
3866
+ act({
3867
+ type: "set-status",
3868
+ status: `Removing ${entries.length} selected paths...`
3869
+ });
3870
+ try {
3871
+ const outcome = props.options.executeEntries(entries);
3872
+ setData(props.options.refreshData());
3873
+ act({ type: "clear-selection" });
3874
+ act({
3875
+ type: "set-status",
3876
+ status: removalStatus(outcome)
3877
+ });
3878
+ } catch (error) {
3879
+ act({
3880
+ type: "set-status",
3881
+ status: `Delete failed: ${error instanceof Error ? error.message : String(error)}`
3882
+ });
3883
+ } finally {
3884
+ setExecuting(false);
3885
+ }
3886
+ };
3887
+ useInput((input, key) => {
3888
+ if (executing()) return;
3889
+ if (key.ctrl) return props.onQuit();
3890
+ if (key.tab) return act({ type: "switch-mode" });
3891
+ if (key.return) return confirmExecute() ? executeSelected() : void 0;
3892
+ if (key.escape) return act({ type: "cancel-execute" });
3893
+ if (input === "q") return props.onQuit();
3894
+ if (input === "j" || key.downArrow) return move(1);
3895
+ if (input === "k" || key.upArrow) return move(-1);
3896
+ if (key.pageDown) return move(viewportHeight());
3897
+ if (key.pageUp) return move(-viewportHeight());
3898
+ if (input === " ") return toggleCurrent();
3899
+ if (input === "a" && activeMode() === "clean") return act({
3900
+ type: "toggle-all",
3901
+ paths: clean().rows.map((row) => row.path)
3902
+ });
3903
+ if (input === "x" && activeMode() === "clean") return act({ type: "request-execute" });
3904
+ });
3905
+ return createComponent$1(Box, {
3906
+ flexDirection: "column",
3907
+ gap: 1,
3908
+ padding: 1,
3909
+ width: "100%",
3910
+ height: "100%",
3911
+ get children() {
3912
+ return [
3913
+ createComponent$1(Text, {
3914
+ color: "cyan",
3915
+ get children() {
3916
+ return [
3917
+ "Space Lens | ",
3918
+ memo(() => activeMode() === "scan" ? "SCAN" : "CLEAN"),
3919
+ " | tab switch | j/k move | q quit"
3920
+ ];
3921
+ }
3922
+ }),
3923
+ createComponent$1(Text, {
3924
+ color: "white",
3925
+ get children() {
3926
+ return memo(() => activeMode() === "scan")() ? `${scan().summary} | tree view` : `${clean().summary} | space select | a all | x delete`;
3927
+ }
3928
+ }),
3929
+ createComponent$1(Text, {
3930
+ get color() {
3931
+ return confirmExecute() ? "red" : "gray";
3932
+ },
3933
+ get children() {
3934
+ return statusLine(selected(), confirmExecute(), executing(), status());
3935
+ }
3936
+ }),
3937
+ createComponent$1(Show, {
3938
+ get when() {
3939
+ return activeMode() === "scan";
3940
+ },
3941
+ get fallback() {
3942
+ return createComponent$1(ListPanel, {
3943
+ get title() {
3944
+ return memo(() => selected().length > 0)() ? `cleanup candidates (${selected().length} selected)` : "cleanup candidates";
3945
+ },
3946
+ get rows() {
3947
+ return clean().rows;
3948
+ },
3949
+ get cursor() {
3950
+ return clean().cursor;
3951
+ },
3952
+ get height() {
3953
+ return viewportHeight();
3954
+ },
3955
+ get danger() {
3956
+ return confirmExecute();
3957
+ },
3958
+ empty: "No cleanup candidates found.",
3959
+ renderRow: (row) => createComponent$1(Text, {
3960
+ get color() {
3961
+ return memo(() => !!row.active)() ? "cyan" : colorForPreset(row.preset);
3962
+ },
3963
+ get children() {
3964
+ return `${row.active ? ">" : " "} ${row.selected ? "[x]" : "[ ]"} ${row.sizeLabel.padEnd(24)} ${row.preset.padEnd(10)} ${row.path} ${row.reason}`;
3965
+ }
3966
+ })
3967
+ });
3968
+ },
3969
+ get children() {
3970
+ return createComponent$1(ListPanel, {
3971
+ title: "scan tree",
3972
+ get rows() {
3973
+ return scan().rows;
3974
+ },
3975
+ get cursor() {
3976
+ return scan().cursor;
3977
+ },
3978
+ get height() {
3979
+ return viewportHeight();
3980
+ },
3981
+ empty: "No scan results.",
3982
+ renderRow: (row) => createComponent$1(Text, {
3983
+ get color() {
3984
+ return memo(() => !!row.active)() ? "cyan" : row.ignored ? "yellow" : "white";
3985
+ },
3986
+ get children() {
3987
+ return `${row.active ? ">" : " "} ${row.sizeLabel.padEnd(24)} ${row.label}`;
3988
+ }
3989
+ })
3990
+ });
3991
+ }
3992
+ }),
3993
+ createComponent$1(For, {
3994
+ get each() {
3995
+ return clean().errors;
3996
+ },
3997
+ children: (error) => createComponent$1(Text, {
3998
+ color: "yellow",
3999
+ get children() {
4000
+ return ["Warnings: ", error];
4001
+ }
4002
+ })
4003
+ })
4004
+ ];
4005
+ }
4006
+ });
4007
+ }
4008
+ function ListPanel(props) {
4009
+ const [scrollTop, setScrollTop] = createSignal(0);
4010
+ const maxScroll = () => Math.max(0, props.rows.length - props.height);
4011
+ const visible = () => props.rows.slice(scrollTop(), scrollTop() + props.height);
4012
+ createEffect(() => {
4013
+ const cursor = props.cursor;
4014
+ const height = props.height;
4015
+ const max = maxScroll();
4016
+ setScrollTop((top) => {
4017
+ if (cursor < top) return cursor;
4018
+ if (cursor >= top + height) return Math.min(max, cursor - height + 1);
4019
+ return Math.min(top, max);
4020
+ });
4021
+ });
4022
+ const onWheel = (event) => {
4023
+ setScrollTop((top) => clampScroll(top + event.deltaY * 3, props.rows.length, props.height));
4024
+ };
4025
+ const footer = () => props.rows.length > props.height ? `${Math.min(scrollTop() + props.height, props.rows.length)} / ${props.rows.length}` : void 0;
4026
+ return createComponent$1(Panel, {
4027
+ get title() {
4028
+ return props.title;
4029
+ },
4030
+ get footer() {
4031
+ return footer();
4032
+ },
4033
+ get borderColor() {
4034
+ return props.danger ? "red" : "gray";
4035
+ },
4036
+ flexGrow: 1,
4037
+ flexShrink: 1,
4038
+ minHeight: 0,
4039
+ overflow: "hidden",
4040
+ onWheel,
4041
+ get children() {
4042
+ return createComponent$1(Box, {
4043
+ flexDirection: "row",
4044
+ flexGrow: 1,
4045
+ flexShrink: 1,
4046
+ minWidth: 0,
4047
+ get height() {
4048
+ return props.height;
4049
+ },
4050
+ get children() {
4051
+ return [createComponent$1(Box, {
4052
+ flexDirection: "column",
4053
+ flexGrow: 1,
4054
+ flexShrink: 1,
4055
+ minWidth: 0,
4056
+ get height() {
4057
+ return props.height;
4058
+ },
4059
+ get children() {
4060
+ return createComponent$1(Show, {
4061
+ get when() {
4062
+ return props.rows.length > 0;
4063
+ },
4064
+ get fallback() {
4065
+ return createComponent$1(Text, {
4066
+ color: "gray",
4067
+ get children() {
4068
+ return props.empty;
4069
+ }
4070
+ });
4071
+ },
4072
+ get children() {
4073
+ return createComponent$1(For, {
4074
+ get each() {
4075
+ return visible();
4076
+ },
4077
+ children: (row, index) => props.renderRow(row, scrollTop() + index())
4078
+ });
4079
+ }
4080
+ });
4081
+ }
4082
+ }), createComponent$1(Scrollbar, {
4083
+ get total() {
4084
+ return props.rows.length;
4085
+ },
4086
+ get height() {
4087
+ return props.height;
4088
+ },
4089
+ get value() {
4090
+ return scrollTop();
4091
+ }
4092
+ })];
4093
+ }
4094
+ });
4095
+ }
4096
+ });
4097
+ }
4098
+ function listViewportHeight(terminalHeight, warningCount) {
4099
+ return Math.max(1, terminalHeight - 12 - warningCount * 2);
4100
+ }
4101
+ function statusLine(selected, confirm, executing, status) {
4102
+ if (executing) return status;
4103
+ if (confirm) return `Confirm delete ${selected.length} paths (${formatBytes(selected.reduce((total, entry) => total + entry.size, 0))}): enter execute, esc cancel.`;
4104
+ return status || "Scan mode shows disk tree. Clean mode selects cleanup candidates.";
4105
+ }
4106
+ function removalStatus(outcome) {
4107
+ return `Removed ${outcome.removed.length} paths, ${formatBytes(outcome.bytesRemoved)}.${outcome.errors.length > 0 ? ` ${outcome.errors.length} errors.` : ""}`;
4108
+ }
4109
+ function colorForPreset(preset) {
4110
+ return preset === "node" ? "green" : preset === "rust" ? "red" : preset === "gitignored" ? "yellow" : "white";
4111
+ }
4112
+ //#endregion
4113
+ //#region src/cli-program.ts
4114
+ var APP_VERSION = "0.2.2";
4115
+ var command = Command.make("spacelens", {
4116
+ paths: Args.text({ name: "path" }).pipe(Args.atLeast(0), Args.withDescription("Directory to scan.")),
4117
+ presets: Options.text("preset").pipe(Options.withAlias("p"), Options.repeated, Options.withDescription("Cleanup preset: node, rust, gitignored.")),
4118
+ ignoreHidden: Options.boolean("ignore-hidden").pipe(Options.withDescription("Skip hidden paths.")),
4119
+ sort: Options.choice("sort", SORT_MODES).pipe(Options.withDefault("size"), Options.withDescription("Sort by size or path."))
4120
+ }, (rawConfig) => Effect.gen(function* () {
24
4121
  yield* runTuiProgram(yield* Effect.try({
25
4122
  try: () => normalizeCliConfig(rawConfig),
26
4123
  catch: toError
27
4124
  }));
28
- }).pipe(Effect.catchAll(reportCliError))).pipe(Command.withDescription("OpenTUI scanner and cleanup picker for Space Lens."));
29
- const cli = Command.run(spaceLensTuiCommand, {
4125
+ }).pipe(Effect.catchAll(reportCliError))).pipe(Command.withDescription("Space Lens scanner and cleanup picker."));
4126
+ var cli = Command.run(command, {
30
4127
  name: "Space Lens TUI",
31
4128
  version: APP_VERSION
32
4129
  });
33
- function makeCliEffect(argv) {
34
- return cli(argv).pipe(Effect.provide(NodeContext.layer));
35
- }
36
4130
  function runCli(argv = process.argv) {
37
- NodeRuntime.runMain(makeCliEffect(argv));
4131
+ NodeRuntime.runMain(cli(argv).pipe(Effect.provide(NodeContext.layer)));
38
4132
  }
39
- const runTuiProgram = Effect.fn("runTuiProgram")((options) => Effect.gen(function* () {
40
- yield* Effect.try({
41
- try: () => assertSupportedRuntime(),
42
- catch: toError
43
- });
44
- const [{ executeCleanupEntries, loadSpaceLensData }, { runTui }] = yield* Effect.tryPromise({
45
- try: () => Promise.all([import("./scanner-BwSuW3ks.mjs"), import("./ui-BKn7TAnJ.mjs")]),
4133
+ var runTuiProgram = Effect.fn("runTuiProgram")((options) => Effect.gen(function* () {
4134
+ const [{ executeCleanupEntries, loadSpaceLensData }] = yield* Effect.tryPromise({
4135
+ try: () => Promise.all([import("./assets/scanner-DiwQ0w5N.js")]),
46
4136
  catch: toError
47
4137
  });
48
4138
  const initialData = yield* Effect.try({