llm-party-cli 0.10.1 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +3 -10
  2. package/dist/index.js +1700 -1444
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3288,6 +3288,932 @@ import { readFile as readFile6 } from "fs/promises";
3288
3288
  import path11 from "path";
3289
3289
  import { fileURLToPath as fileURLToPath3 } from "url";
3290
3290
 
3291
+ // node_modules/solid-js/dist/server.js
3292
+ var sharedConfig = {
3293
+ context: undefined,
3294
+ registry: undefined,
3295
+ effects: undefined,
3296
+ done: false,
3297
+ getContextId() {
3298
+ return getContextId(this.context.count);
3299
+ },
3300
+ getNextContextId() {
3301
+ return getContextId(this.context.count++);
3302
+ }
3303
+ };
3304
+ function getContextId(count) {
3305
+ const num = String(count), len = num.length - 1;
3306
+ return sharedConfig.context.id + (len ? String.fromCharCode(96 + len) : "") + num;
3307
+ }
3308
+ function setHydrateContext(context) {
3309
+ sharedConfig.context = context;
3310
+ }
3311
+ function nextHydrateContext() {
3312
+ return {
3313
+ ...sharedConfig.context,
3314
+ id: sharedConfig.getNextContextId(),
3315
+ count: 0
3316
+ };
3317
+ }
3318
+ var IS_DEV = false;
3319
+ var equalFn = (a, b) => a === b;
3320
+ var $PROXY = Symbol("solid-proxy");
3321
+ var SUPPORTS_PROXY = typeof Proxy === "function";
3322
+ var $TRACK = Symbol("solid-track");
3323
+ var $DEVCOMP = Symbol("solid-dev-component");
3324
+ var signalOptions = {
3325
+ equals: equalFn
3326
+ };
3327
+ var ERROR = null;
3328
+ var runEffects = runQueue;
3329
+ var STALE = 1;
3330
+ var PENDING = 2;
3331
+ var UNOWNED = {
3332
+ owned: null,
3333
+ cleanups: null,
3334
+ context: null,
3335
+ owner: null
3336
+ };
3337
+ var Owner = null;
3338
+ var Transition = null;
3339
+ var Scheduler = null;
3340
+ var ExternalSourceConfig = null;
3341
+ var Listener = null;
3342
+ var Updates = null;
3343
+ var Effects = null;
3344
+ var ExecCount = 0;
3345
+ function createRoot(fn, detachedOwner) {
3346
+ const listener = Listener, owner = Owner, unowned = fn.length === 0, current = detachedOwner === undefined ? owner : detachedOwner, root = unowned ? UNOWNED : {
3347
+ owned: null,
3348
+ cleanups: null,
3349
+ context: current ? current.context : null,
3350
+ owner: current
3351
+ }, updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
3352
+ Owner = root;
3353
+ Listener = null;
3354
+ try {
3355
+ return runUpdates(updateFn, true);
3356
+ } finally {
3357
+ Listener = listener;
3358
+ Owner = owner;
3359
+ }
3360
+ }
3361
+ function createSignal(value, options) {
3362
+ options = options ? Object.assign({}, signalOptions, options) : signalOptions;
3363
+ const s = {
3364
+ value,
3365
+ observers: null,
3366
+ observerSlots: null,
3367
+ comparator: options.equals || undefined
3368
+ };
3369
+ const setter = (value2) => {
3370
+ if (typeof value2 === "function") {
3371
+ if (Transition && Transition.running && Transition.sources.has(s))
3372
+ value2 = value2(s.tValue);
3373
+ else
3374
+ value2 = value2(s.value);
3375
+ }
3376
+ return writeSignal(s, value2);
3377
+ };
3378
+ return [readSignal.bind(s), setter];
3379
+ }
3380
+ function createRenderEffect(fn, value, options) {
3381
+ const c = createComputation(fn, value, false, STALE);
3382
+ if (Scheduler && Transition && Transition.running)
3383
+ Updates.push(c);
3384
+ else
3385
+ updateComputation(c);
3386
+ }
3387
+ function createEffect(fn, value, options) {
3388
+ runEffects = runUserEffects;
3389
+ const c = createComputation(fn, value, false, STALE), s = SuspenseContext && useContext(SuspenseContext);
3390
+ if (s)
3391
+ c.suspense = s;
3392
+ if (!options || !options.render)
3393
+ c.user = true;
3394
+ Effects ? Effects.push(c) : updateComputation(c);
3395
+ }
3396
+ function createMemo(fn, value, options) {
3397
+ options = options ? Object.assign({}, signalOptions, options) : signalOptions;
3398
+ const c = createComputation(fn, value, true, 0);
3399
+ c.observers = null;
3400
+ c.observerSlots = null;
3401
+ c.comparator = options.equals || undefined;
3402
+ if (Scheduler && Transition && Transition.running) {
3403
+ c.tState = STALE;
3404
+ Updates.push(c);
3405
+ } else
3406
+ updateComputation(c);
3407
+ return readSignal.bind(c);
3408
+ }
3409
+ function untrack(fn) {
3410
+ if (!ExternalSourceConfig && Listener === null)
3411
+ return fn();
3412
+ const listener = Listener;
3413
+ Listener = null;
3414
+ try {
3415
+ if (ExternalSourceConfig)
3416
+ return ExternalSourceConfig.untrack(fn);
3417
+ return fn();
3418
+ } finally {
3419
+ Listener = listener;
3420
+ }
3421
+ }
3422
+ function onMount(fn) {
3423
+ createEffect(() => untrack(fn));
3424
+ }
3425
+ function onCleanup(fn) {
3426
+ if (Owner === null)
3427
+ ;
3428
+ else if (Owner.cleanups === null)
3429
+ Owner.cleanups = [fn];
3430
+ else
3431
+ Owner.cleanups.push(fn);
3432
+ return fn;
3433
+ }
3434
+ function startTransition(fn) {
3435
+ if (Transition && Transition.running) {
3436
+ fn();
3437
+ return Transition.done;
3438
+ }
3439
+ const l = Listener;
3440
+ const o = Owner;
3441
+ return Promise.resolve().then(() => {
3442
+ Listener = l;
3443
+ Owner = o;
3444
+ let t;
3445
+ if (Scheduler || SuspenseContext) {
3446
+ t = Transition || (Transition = {
3447
+ sources: new Set,
3448
+ effects: [],
3449
+ promises: new Set,
3450
+ disposed: new Set,
3451
+ queue: new Set,
3452
+ running: true
3453
+ });
3454
+ t.done || (t.done = new Promise((res) => t.resolve = res));
3455
+ t.running = true;
3456
+ }
3457
+ runUpdates(fn, false);
3458
+ Listener = Owner = null;
3459
+ return t ? t.done : undefined;
3460
+ });
3461
+ }
3462
+ var [transPending, setTransPending] = /* @__PURE__ */ createSignal(false);
3463
+ function createContext(defaultValue, options) {
3464
+ const id = Symbol("context");
3465
+ return {
3466
+ id,
3467
+ Provider: createProvider(id),
3468
+ defaultValue
3469
+ };
3470
+ }
3471
+ function useContext(context) {
3472
+ let value;
3473
+ return Owner && Owner.context && (value = Owner.context[context.id]) !== undefined ? value : context.defaultValue;
3474
+ }
3475
+ function children(fn) {
3476
+ const children2 = createMemo(fn);
3477
+ const memo = createMemo(() => resolveChildren(children2()));
3478
+ memo.toArray = () => {
3479
+ const c = memo();
3480
+ return Array.isArray(c) ? c : c != null ? [c] : [];
3481
+ };
3482
+ return memo;
3483
+ }
3484
+ var SuspenseContext;
3485
+ function readSignal() {
3486
+ const runningTransition = Transition && Transition.running;
3487
+ if (this.sources && (runningTransition ? this.tState : this.state)) {
3488
+ if ((runningTransition ? this.tState : this.state) === STALE)
3489
+ updateComputation(this);
3490
+ else {
3491
+ const updates = Updates;
3492
+ Updates = null;
3493
+ runUpdates(() => lookUpstream(this), false);
3494
+ Updates = updates;
3495
+ }
3496
+ }
3497
+ if (Listener) {
3498
+ const sSlot = this.observers ? this.observers.length : 0;
3499
+ if (!Listener.sources) {
3500
+ Listener.sources = [this];
3501
+ Listener.sourceSlots = [sSlot];
3502
+ } else {
3503
+ Listener.sources.push(this);
3504
+ Listener.sourceSlots.push(sSlot);
3505
+ }
3506
+ if (!this.observers) {
3507
+ this.observers = [Listener];
3508
+ this.observerSlots = [Listener.sources.length - 1];
3509
+ } else {
3510
+ this.observers.push(Listener);
3511
+ this.observerSlots.push(Listener.sources.length - 1);
3512
+ }
3513
+ }
3514
+ if (runningTransition && Transition.sources.has(this))
3515
+ return this.tValue;
3516
+ return this.value;
3517
+ }
3518
+ function writeSignal(node, value, isComp) {
3519
+ let current = Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
3520
+ if (!node.comparator || !node.comparator(current, value)) {
3521
+ if (Transition) {
3522
+ const TransitionRunning = Transition.running;
3523
+ if (TransitionRunning || !isComp && Transition.sources.has(node)) {
3524
+ Transition.sources.add(node);
3525
+ node.tValue = value;
3526
+ }
3527
+ if (!TransitionRunning)
3528
+ node.value = value;
3529
+ } else
3530
+ node.value = value;
3531
+ if (node.observers && node.observers.length) {
3532
+ runUpdates(() => {
3533
+ for (let i = 0;i < node.observers.length; i += 1) {
3534
+ const o = node.observers[i];
3535
+ const TransitionRunning = Transition && Transition.running;
3536
+ if (TransitionRunning && Transition.disposed.has(o))
3537
+ continue;
3538
+ if (TransitionRunning ? !o.tState : !o.state) {
3539
+ if (o.pure)
3540
+ Updates.push(o);
3541
+ else
3542
+ Effects.push(o);
3543
+ if (o.observers)
3544
+ markDownstream(o);
3545
+ }
3546
+ if (!TransitionRunning)
3547
+ o.state = STALE;
3548
+ else
3549
+ o.tState = STALE;
3550
+ }
3551
+ if (Updates.length > 1e6) {
3552
+ Updates = [];
3553
+ if (IS_DEV)
3554
+ ;
3555
+ throw new Error;
3556
+ }
3557
+ }, false);
3558
+ }
3559
+ }
3560
+ return value;
3561
+ }
3562
+ function updateComputation(node) {
3563
+ if (!node.fn)
3564
+ return;
3565
+ cleanNode(node);
3566
+ const time = ExecCount;
3567
+ runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
3568
+ if (Transition && !Transition.running && Transition.sources.has(node)) {
3569
+ queueMicrotask(() => {
3570
+ runUpdates(() => {
3571
+ Transition && (Transition.running = true);
3572
+ Listener = Owner = node;
3573
+ runComputation(node, node.tValue, time);
3574
+ Listener = Owner = null;
3575
+ }, false);
3576
+ });
3577
+ }
3578
+ }
3579
+ function runComputation(node, value, time) {
3580
+ let nextValue;
3581
+ const owner = Owner, listener = Listener;
3582
+ Listener = Owner = node;
3583
+ try {
3584
+ nextValue = node.fn(value);
3585
+ } catch (err) {
3586
+ if (node.pure) {
3587
+ if (Transition && Transition.running) {
3588
+ node.tState = STALE;
3589
+ node.tOwned && node.tOwned.forEach(cleanNode);
3590
+ node.tOwned = undefined;
3591
+ } else {
3592
+ node.state = STALE;
3593
+ node.owned && node.owned.forEach(cleanNode);
3594
+ node.owned = null;
3595
+ }
3596
+ }
3597
+ node.updatedAt = time + 1;
3598
+ return handleError(err);
3599
+ } finally {
3600
+ Listener = listener;
3601
+ Owner = owner;
3602
+ }
3603
+ if (!node.updatedAt || node.updatedAt <= time) {
3604
+ if (node.updatedAt != null && "observers" in node) {
3605
+ writeSignal(node, nextValue, true);
3606
+ } else if (Transition && Transition.running && node.pure) {
3607
+ if (!Transition.sources.has(node))
3608
+ node.value = nextValue;
3609
+ Transition.sources.add(node);
3610
+ node.tValue = nextValue;
3611
+ } else
3612
+ node.value = nextValue;
3613
+ node.updatedAt = time;
3614
+ }
3615
+ }
3616
+ function createComputation(fn, init, pure, state = STALE, options) {
3617
+ const c = {
3618
+ fn,
3619
+ state,
3620
+ updatedAt: null,
3621
+ owned: null,
3622
+ sources: null,
3623
+ sourceSlots: null,
3624
+ cleanups: null,
3625
+ value: init,
3626
+ owner: Owner,
3627
+ context: Owner ? Owner.context : null,
3628
+ pure
3629
+ };
3630
+ if (Transition && Transition.running) {
3631
+ c.state = 0;
3632
+ c.tState = state;
3633
+ }
3634
+ if (Owner === null)
3635
+ ;
3636
+ else if (Owner !== UNOWNED) {
3637
+ if (Transition && Transition.running && Owner.pure) {
3638
+ if (!Owner.tOwned)
3639
+ Owner.tOwned = [c];
3640
+ else
3641
+ Owner.tOwned.push(c);
3642
+ } else {
3643
+ if (!Owner.owned)
3644
+ Owner.owned = [c];
3645
+ else
3646
+ Owner.owned.push(c);
3647
+ }
3648
+ }
3649
+ if (ExternalSourceConfig && c.fn) {
3650
+ const sourceFn = c.fn;
3651
+ const [track, trigger] = createSignal(undefined, {
3652
+ equals: false
3653
+ });
3654
+ const ordinary = ExternalSourceConfig.factory(sourceFn, trigger);
3655
+ onCleanup(() => ordinary.dispose());
3656
+ let inTransition;
3657
+ const triggerInTransition = () => startTransition(trigger).then(() => {
3658
+ if (inTransition) {
3659
+ inTransition.dispose();
3660
+ inTransition = undefined;
3661
+ }
3662
+ });
3663
+ c.fn = (x) => {
3664
+ track();
3665
+ if (Transition && Transition.running) {
3666
+ if (!inTransition)
3667
+ inTransition = ExternalSourceConfig.factory(sourceFn, triggerInTransition);
3668
+ return inTransition.track(x);
3669
+ }
3670
+ return ordinary.track(x);
3671
+ };
3672
+ }
3673
+ return c;
3674
+ }
3675
+ function runTop(node) {
3676
+ const runningTransition = Transition && Transition.running;
3677
+ if ((runningTransition ? node.tState : node.state) === 0)
3678
+ return;
3679
+ if ((runningTransition ? node.tState : node.state) === PENDING)
3680
+ return lookUpstream(node);
3681
+ if (node.suspense && untrack(node.suspense.inFallback))
3682
+ return node.suspense.effects.push(node);
3683
+ const ancestors = [node];
3684
+ while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
3685
+ if (runningTransition && Transition.disposed.has(node))
3686
+ return;
3687
+ if (runningTransition ? node.tState : node.state)
3688
+ ancestors.push(node);
3689
+ }
3690
+ for (let i = ancestors.length - 1;i >= 0; i--) {
3691
+ node = ancestors[i];
3692
+ if (runningTransition) {
3693
+ let top = node, prev = ancestors[i + 1];
3694
+ while ((top = top.owner) && top !== prev) {
3695
+ if (Transition.disposed.has(top))
3696
+ return;
3697
+ }
3698
+ }
3699
+ if ((runningTransition ? node.tState : node.state) === STALE) {
3700
+ updateComputation(node);
3701
+ } else if ((runningTransition ? node.tState : node.state) === PENDING) {
3702
+ const updates = Updates;
3703
+ Updates = null;
3704
+ runUpdates(() => lookUpstream(node, ancestors[0]), false);
3705
+ Updates = updates;
3706
+ }
3707
+ }
3708
+ }
3709
+ function runUpdates(fn, init) {
3710
+ if (Updates)
3711
+ return fn();
3712
+ let wait = false;
3713
+ if (!init)
3714
+ Updates = [];
3715
+ if (Effects)
3716
+ wait = true;
3717
+ else
3718
+ Effects = [];
3719
+ ExecCount++;
3720
+ try {
3721
+ const res = fn();
3722
+ completeUpdates(wait);
3723
+ return res;
3724
+ } catch (err) {
3725
+ if (!wait)
3726
+ Effects = null;
3727
+ Updates = null;
3728
+ handleError(err);
3729
+ }
3730
+ }
3731
+ function completeUpdates(wait) {
3732
+ if (Updates) {
3733
+ if (Scheduler && Transition && Transition.running)
3734
+ scheduleQueue(Updates);
3735
+ else
3736
+ runQueue(Updates);
3737
+ Updates = null;
3738
+ }
3739
+ if (wait)
3740
+ return;
3741
+ let res;
3742
+ if (Transition) {
3743
+ if (!Transition.promises.size && !Transition.queue.size) {
3744
+ const sources = Transition.sources;
3745
+ const disposed = Transition.disposed;
3746
+ Effects.push.apply(Effects, Transition.effects);
3747
+ res = Transition.resolve;
3748
+ for (const e2 of Effects) {
3749
+ "tState" in e2 && (e2.state = e2.tState);
3750
+ delete e2.tState;
3751
+ }
3752
+ Transition = null;
3753
+ runUpdates(() => {
3754
+ for (const d of disposed)
3755
+ cleanNode(d);
3756
+ for (const v of sources) {
3757
+ v.value = v.tValue;
3758
+ if (v.owned) {
3759
+ for (let i = 0, len = v.owned.length;i < len; i++)
3760
+ cleanNode(v.owned[i]);
3761
+ }
3762
+ if (v.tOwned)
3763
+ v.owned = v.tOwned;
3764
+ delete v.tValue;
3765
+ delete v.tOwned;
3766
+ v.tState = 0;
3767
+ }
3768
+ setTransPending(false);
3769
+ }, false);
3770
+ } else if (Transition.running) {
3771
+ Transition.running = false;
3772
+ Transition.effects.push.apply(Transition.effects, Effects);
3773
+ Effects = null;
3774
+ setTransPending(true);
3775
+ return;
3776
+ }
3777
+ }
3778
+ const e = Effects;
3779
+ Effects = null;
3780
+ if (e.length)
3781
+ runUpdates(() => runEffects(e), false);
3782
+ if (res)
3783
+ res();
3784
+ }
3785
+ function runQueue(queue) {
3786
+ for (let i = 0;i < queue.length; i++)
3787
+ runTop(queue[i]);
3788
+ }
3789
+ function scheduleQueue(queue) {
3790
+ for (let i = 0;i < queue.length; i++) {
3791
+ const item = queue[i];
3792
+ const tasks = Transition.queue;
3793
+ if (!tasks.has(item)) {
3794
+ tasks.add(item);
3795
+ Scheduler(() => {
3796
+ tasks.delete(item);
3797
+ runUpdates(() => {
3798
+ Transition.running = true;
3799
+ runTop(item);
3800
+ }, false);
3801
+ Transition && (Transition.running = false);
3802
+ });
3803
+ }
3804
+ }
3805
+ }
3806
+ function runUserEffects(queue) {
3807
+ let i, userLength = 0;
3808
+ for (i = 0;i < queue.length; i++) {
3809
+ const e = queue[i];
3810
+ if (!e.user)
3811
+ runTop(e);
3812
+ else
3813
+ queue[userLength++] = e;
3814
+ }
3815
+ if (sharedConfig.context) {
3816
+ if (sharedConfig.count) {
3817
+ sharedConfig.effects || (sharedConfig.effects = []);
3818
+ sharedConfig.effects.push(...queue.slice(0, userLength));
3819
+ return;
3820
+ }
3821
+ setHydrateContext();
3822
+ }
3823
+ if (sharedConfig.effects && (sharedConfig.done || !sharedConfig.count)) {
3824
+ queue = [...sharedConfig.effects, ...queue];
3825
+ userLength += sharedConfig.effects.length;
3826
+ delete sharedConfig.effects;
3827
+ }
3828
+ for (i = 0;i < userLength; i++)
3829
+ runTop(queue[i]);
3830
+ }
3831
+ function lookUpstream(node, ignore) {
3832
+ const runningTransition = Transition && Transition.running;
3833
+ if (runningTransition)
3834
+ node.tState = 0;
3835
+ else
3836
+ node.state = 0;
3837
+ for (let i = 0;i < node.sources.length; i += 1) {
3838
+ const source = node.sources[i];
3839
+ if (source.sources) {
3840
+ const state = runningTransition ? source.tState : source.state;
3841
+ if (state === STALE) {
3842
+ if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
3843
+ runTop(source);
3844
+ } else if (state === PENDING)
3845
+ lookUpstream(source, ignore);
3846
+ }
3847
+ }
3848
+ }
3849
+ function markDownstream(node) {
3850
+ const runningTransition = Transition && Transition.running;
3851
+ for (let i = 0;i < node.observers.length; i += 1) {
3852
+ const o = node.observers[i];
3853
+ if (runningTransition ? !o.tState : !o.state) {
3854
+ if (runningTransition)
3855
+ o.tState = PENDING;
3856
+ else
3857
+ o.state = PENDING;
3858
+ if (o.pure)
3859
+ Updates.push(o);
3860
+ else
3861
+ Effects.push(o);
3862
+ o.observers && markDownstream(o);
3863
+ }
3864
+ }
3865
+ }
3866
+ function cleanNode(node) {
3867
+ let i;
3868
+ if (node.sources) {
3869
+ while (node.sources.length) {
3870
+ const source = node.sources.pop(), index = node.sourceSlots.pop(), obs = source.observers;
3871
+ if (obs && obs.length) {
3872
+ const n = obs.pop(), s = source.observerSlots.pop();
3873
+ if (index < obs.length) {
3874
+ n.sourceSlots[s] = index;
3875
+ obs[index] = n;
3876
+ source.observerSlots[index] = s;
3877
+ }
3878
+ }
3879
+ }
3880
+ }
3881
+ if (node.tOwned) {
3882
+ for (i = node.tOwned.length - 1;i >= 0; i--)
3883
+ cleanNode(node.tOwned[i]);
3884
+ delete node.tOwned;
3885
+ }
3886
+ if (Transition && Transition.running && node.pure) {
3887
+ reset(node, true);
3888
+ } else if (node.owned) {
3889
+ for (i = node.owned.length - 1;i >= 0; i--)
3890
+ cleanNode(node.owned[i]);
3891
+ node.owned = null;
3892
+ }
3893
+ if (node.cleanups) {
3894
+ for (i = node.cleanups.length - 1;i >= 0; i--)
3895
+ node.cleanups[i]();
3896
+ node.cleanups = null;
3897
+ }
3898
+ if (Transition && Transition.running)
3899
+ node.tState = 0;
3900
+ else
3901
+ node.state = 0;
3902
+ }
3903
+ function reset(node, top) {
3904
+ if (!top) {
3905
+ node.tState = 0;
3906
+ Transition.disposed.add(node);
3907
+ }
3908
+ if (node.owned) {
3909
+ for (let i = 0;i < node.owned.length; i++)
3910
+ reset(node.owned[i]);
3911
+ }
3912
+ }
3913
+ function castError(err) {
3914
+ if (err instanceof Error)
3915
+ return err;
3916
+ return new Error(typeof err === "string" ? err : "Unknown error", {
3917
+ cause: err
3918
+ });
3919
+ }
3920
+ function runErrors(err, fns, owner) {
3921
+ try {
3922
+ for (const f of fns)
3923
+ f(err);
3924
+ } catch (e) {
3925
+ handleError(e, owner && owner.owner || null);
3926
+ }
3927
+ }
3928
+ function handleError(err, owner = Owner) {
3929
+ const fns = ERROR && owner && owner.context && owner.context[ERROR];
3930
+ const error = castError(err);
3931
+ if (!fns)
3932
+ throw error;
3933
+ if (Effects)
3934
+ Effects.push({
3935
+ fn() {
3936
+ runErrors(error, fns, owner);
3937
+ },
3938
+ state: STALE
3939
+ });
3940
+ else
3941
+ runErrors(error, fns, owner);
3942
+ }
3943
+ function resolveChildren(children2) {
3944
+ if (typeof children2 === "function" && !children2.length)
3945
+ return resolveChildren(children2());
3946
+ if (Array.isArray(children2)) {
3947
+ const results = [];
3948
+ for (let i = 0;i < children2.length; i++) {
3949
+ const result = resolveChildren(children2[i]);
3950
+ Array.isArray(result) ? results.push.apply(results, result) : results.push(result);
3951
+ }
3952
+ return results;
3953
+ }
3954
+ return children2;
3955
+ }
3956
+ function createProvider(id, options) {
3957
+ return function provider(props) {
3958
+ let res;
3959
+ createRenderEffect(() => res = untrack(() => {
3960
+ Owner.context = {
3961
+ ...Owner.context,
3962
+ [id]: props.value
3963
+ };
3964
+ return children(() => props.children);
3965
+ }), undefined);
3966
+ return res;
3967
+ };
3968
+ }
3969
+ var FALLBACK = Symbol("fallback");
3970
+ function dispose(d) {
3971
+ for (let i = 0;i < d.length; i++)
3972
+ d[i]();
3973
+ }
3974
+ function mapArray(list, mapFn, options = {}) {
3975
+ let items = [], mapped = [], disposers = [], len = 0, indexes = mapFn.length > 1 ? [] : null;
3976
+ onCleanup(() => dispose(disposers));
3977
+ return () => {
3978
+ let newItems = list() || [], newLen = newItems.length, i, j;
3979
+ newItems[$TRACK];
3980
+ return untrack(() => {
3981
+ let newIndices, newIndicesNext, temp, tempdisposers, tempIndexes, start, end, newEnd, item;
3982
+ if (newLen === 0) {
3983
+ if (len !== 0) {
3984
+ dispose(disposers);
3985
+ disposers = [];
3986
+ items = [];
3987
+ mapped = [];
3988
+ len = 0;
3989
+ indexes && (indexes = []);
3990
+ }
3991
+ if (options.fallback) {
3992
+ items = [FALLBACK];
3993
+ mapped[0] = createRoot((disposer) => {
3994
+ disposers[0] = disposer;
3995
+ return options.fallback();
3996
+ });
3997
+ len = 1;
3998
+ }
3999
+ } else if (len === 0) {
4000
+ mapped = new Array(newLen);
4001
+ for (j = 0;j < newLen; j++) {
4002
+ items[j] = newItems[j];
4003
+ mapped[j] = createRoot(mapper);
4004
+ }
4005
+ len = newLen;
4006
+ } else {
4007
+ temp = new Array(newLen);
4008
+ tempdisposers = new Array(newLen);
4009
+ indexes && (tempIndexes = new Array(newLen));
4010
+ for (start = 0, end = Math.min(len, newLen);start < end && items[start] === newItems[start]; start++)
4011
+ ;
4012
+ for (end = len - 1, newEnd = newLen - 1;end >= start && newEnd >= start && items[end] === newItems[newEnd]; end--, newEnd--) {
4013
+ temp[newEnd] = mapped[end];
4014
+ tempdisposers[newEnd] = disposers[end];
4015
+ indexes && (tempIndexes[newEnd] = indexes[end]);
4016
+ }
4017
+ newIndices = new Map;
4018
+ newIndicesNext = new Array(newEnd + 1);
4019
+ for (j = newEnd;j >= start; j--) {
4020
+ item = newItems[j];
4021
+ i = newIndices.get(item);
4022
+ newIndicesNext[j] = i === undefined ? -1 : i;
4023
+ newIndices.set(item, j);
4024
+ }
4025
+ for (i = start;i <= end; i++) {
4026
+ item = items[i];
4027
+ j = newIndices.get(item);
4028
+ if (j !== undefined && j !== -1) {
4029
+ temp[j] = mapped[i];
4030
+ tempdisposers[j] = disposers[i];
4031
+ indexes && (tempIndexes[j] = indexes[i]);
4032
+ j = newIndicesNext[j];
4033
+ newIndices.set(item, j);
4034
+ } else
4035
+ disposers[i]();
4036
+ }
4037
+ for (j = start;j < newLen; j++) {
4038
+ if (j in temp) {
4039
+ mapped[j] = temp[j];
4040
+ disposers[j] = tempdisposers[j];
4041
+ if (indexes) {
4042
+ indexes[j] = tempIndexes[j];
4043
+ indexes[j](j);
4044
+ }
4045
+ } else
4046
+ mapped[j] = createRoot(mapper);
4047
+ }
4048
+ mapped = mapped.slice(0, len = newLen);
4049
+ items = newItems.slice(0);
4050
+ }
4051
+ return mapped;
4052
+ });
4053
+ function mapper(disposer) {
4054
+ disposers[j] = disposer;
4055
+ if (indexes) {
4056
+ const [s, set] = createSignal(j);
4057
+ indexes[j] = set;
4058
+ return mapFn(newItems[j], s);
4059
+ }
4060
+ return mapFn(newItems[j]);
4061
+ }
4062
+ };
4063
+ }
4064
+ var hydrationEnabled = false;
4065
+ function createComponent(Comp, props) {
4066
+ if (hydrationEnabled) {
4067
+ if (sharedConfig.context) {
4068
+ const c = sharedConfig.context;
4069
+ setHydrateContext(nextHydrateContext());
4070
+ const r = untrack(() => Comp(props || {}));
4071
+ setHydrateContext(c);
4072
+ return r;
4073
+ }
4074
+ }
4075
+ return untrack(() => Comp(props || {}));
4076
+ }
4077
+ function trueFn() {
4078
+ return true;
4079
+ }
4080
+ var propTraps = {
4081
+ get(_, property, receiver) {
4082
+ if (property === $PROXY)
4083
+ return receiver;
4084
+ return _.get(property);
4085
+ },
4086
+ has(_, property) {
4087
+ if (property === $PROXY)
4088
+ return true;
4089
+ return _.has(property);
4090
+ },
4091
+ set: trueFn,
4092
+ deleteProperty: trueFn,
4093
+ getOwnPropertyDescriptor(_, property) {
4094
+ return {
4095
+ configurable: true,
4096
+ enumerable: true,
4097
+ get() {
4098
+ return _.get(property);
4099
+ },
4100
+ set: trueFn,
4101
+ deleteProperty: trueFn
4102
+ };
4103
+ },
4104
+ ownKeys(_) {
4105
+ return _.keys();
4106
+ }
4107
+ };
4108
+ function resolveSource(s) {
4109
+ return !(s = typeof s === "function" ? s() : s) ? {} : s;
4110
+ }
4111
+ function resolveSources() {
4112
+ for (let i = 0, length = this.length;i < length; ++i) {
4113
+ const v = this[i]();
4114
+ if (v !== undefined)
4115
+ return v;
4116
+ }
4117
+ }
4118
+ function mergeProps(...sources) {
4119
+ let proxy = false;
4120
+ for (let i = 0;i < sources.length; i++) {
4121
+ const s = sources[i];
4122
+ proxy = proxy || !!s && $PROXY in s;
4123
+ sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
4124
+ }
4125
+ if (SUPPORTS_PROXY && proxy) {
4126
+ return new Proxy({
4127
+ get(property) {
4128
+ for (let i = sources.length - 1;i >= 0; i--) {
4129
+ const v = resolveSource(sources[i])[property];
4130
+ if (v !== undefined)
4131
+ return v;
4132
+ }
4133
+ },
4134
+ has(property) {
4135
+ for (let i = sources.length - 1;i >= 0; i--) {
4136
+ if (property in resolveSource(sources[i]))
4137
+ return true;
4138
+ }
4139
+ return false;
4140
+ },
4141
+ keys() {
4142
+ const keys = [];
4143
+ for (let i = 0;i < sources.length; i++)
4144
+ keys.push(...Object.keys(resolveSource(sources[i])));
4145
+ return [...new Set(keys)];
4146
+ }
4147
+ }, propTraps);
4148
+ }
4149
+ const sourcesMap = {};
4150
+ const defined = Object.create(null);
4151
+ for (let i = sources.length - 1;i >= 0; i--) {
4152
+ const source = sources[i];
4153
+ if (!source)
4154
+ continue;
4155
+ const sourceKeys = Object.getOwnPropertyNames(source);
4156
+ for (let i2 = sourceKeys.length - 1;i2 >= 0; i2--) {
4157
+ const key = sourceKeys[i2];
4158
+ if (key === "__proto__" || key === "constructor")
4159
+ continue;
4160
+ const desc = Object.getOwnPropertyDescriptor(source, key);
4161
+ if (!defined[key]) {
4162
+ defined[key] = desc.get ? {
4163
+ enumerable: true,
4164
+ configurable: true,
4165
+ get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
4166
+ } : desc.value !== undefined ? desc : undefined;
4167
+ } else {
4168
+ const sources2 = sourcesMap[key];
4169
+ if (sources2) {
4170
+ if (desc.get)
4171
+ sources2.push(desc.get.bind(source));
4172
+ else if (desc.value !== undefined)
4173
+ sources2.push(() => desc.value);
4174
+ }
4175
+ }
4176
+ }
4177
+ }
4178
+ const target = {};
4179
+ const definedKeys = Object.keys(defined);
4180
+ for (let i = definedKeys.length - 1;i >= 0; i--) {
4181
+ const key = definedKeys[i], desc = defined[key];
4182
+ if (desc && desc.get)
4183
+ Object.defineProperty(target, key, desc);
4184
+ else
4185
+ target[key] = desc ? desc.value : undefined;
4186
+ }
4187
+ return target;
4188
+ }
4189
+ var narrowedError = (name) => `Stale read from <${name}>.`;
4190
+ function For(props) {
4191
+ const fallback = "fallback" in props && {
4192
+ fallback: () => props.fallback
4193
+ };
4194
+ return createMemo(mapArray(() => props.each, props.children, fallback || undefined));
4195
+ }
4196
+ function Show(props) {
4197
+ const keyed = props.keyed;
4198
+ const conditionValue = createMemo(() => props.when, undefined, undefined);
4199
+ const condition = keyed ? conditionValue : createMemo(conditionValue, undefined, {
4200
+ equals: (a, b) => !a === !b
4201
+ });
4202
+ return createMemo(() => {
4203
+ const c = condition();
4204
+ if (c) {
4205
+ const child = props.children;
4206
+ const fn = typeof child === "function" && child.length > 0;
4207
+ return fn ? untrack(() => child(keyed ? c : () => {
4208
+ if (!untrack(condition))
4209
+ throw narrowedError("Show");
4210
+ return conditionValue();
4211
+ })) : child;
4212
+ }
4213
+ return props.fallback;
4214
+ }, undefined, undefined);
4215
+ }
4216
+
3291
4217
  // node_modules/@opentui/solid/node_modules/@opentui/core/index-mdxq0qtt.js
3292
4218
  import { EventEmitter } from "events";
3293
4219
  import { Buffer as Buffer2 } from "buffer";
@@ -8446,11 +9372,11 @@ function visualizeRenderableTree(renderable, maxDepth = 10) {
8446
9372
  return [`${prefix}${node.id} ... (max depth reached)`];
8447
9373
  }
8448
9374
  const lines = [];
8449
- const children = node.getChildren();
9375
+ const children2 = node.getChildren();
8450
9376
  lines.push(`${prefix}${node.id}`);
8451
- if (children.length > 0) {
8452
- const lastChildIndex = children.length - 1;
8453
- children.forEach((child, index) => {
9377
+ if (children2.length > 0) {
9378
+ const lastChildIndex = children2.length - 1;
9379
+ children2.forEach((child, index) => {
8454
9380
  const childIsLast = index === lastChildIndex;
8455
9381
  const connector = childIsLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
8456
9382
  const childPrefix = parentPrefix + (isLastChild ? " " : "\u2502 ");
@@ -18779,8 +19705,8 @@ class Renderable extends BaseRenderable {
18779
19705
  } catch (e) {}
18780
19706
  }
18781
19707
  destroyRecursively() {
18782
- const children = [...this._childrenInLayoutOrder];
18783
- for (const child of children) {
19708
+ const children2 = [...this._childrenInLayoutOrder];
19709
+ for (const child of children2) {
18784
19710
  child.destroyRecursively();
18785
19711
  }
18786
19712
  this.destroy();
@@ -18966,9 +19892,9 @@ var BrandedVNode = Symbol.for("@opentui/core/VNode");
18966
19892
  function isRenderableConstructor(value) {
18967
19893
  return typeof value === "function" && value.prototype && Renderable.prototype.isPrototypeOf(value.prototype);
18968
19894
  }
18969
- function flattenChildren(children) {
19895
+ function flattenChildren(children2) {
18970
19896
  const result = [];
18971
- for (const child of children) {
19897
+ for (const child of children2) {
18972
19898
  if (Array.isArray(child)) {
18973
19899
  result.push(...flattenChildren(child));
18974
19900
  } else if (child !== null && child !== undefined && child !== false) {
@@ -18977,7 +19903,7 @@ function flattenChildren(children) {
18977
19903
  }
18978
19904
  return result;
18979
19905
  }
18980
- function h(type, props, ...children) {
19906
+ function h(type, props, ...children2) {
18981
19907
  if (typeof type !== "function") {
18982
19908
  throw new TypeError("h() received an invalid vnode type");
18983
19909
  }
@@ -18985,7 +19911,7 @@ function h(type, props, ...children) {
18985
19911
  [BrandedVNode]: true,
18986
19912
  type,
18987
19913
  props,
18988
- children: flattenChildren(children),
19914
+ children: flattenChildren(children2),
18989
19915
  __pendingCalls: []
18990
19916
  };
18991
19917
  if (isRenderableConstructor(type)) {
@@ -19087,11 +20013,11 @@ function instantiate(ctx, node) {
19087
20013
  }
19088
20014
  const vnode = node;
19089
20015
  const { type, props } = vnode;
19090
- const children = flattenChildren(vnode.children || []);
20016
+ const children2 = flattenChildren(vnode.children || []);
19091
20017
  const delegateMap = vnode.__delegateMap;
19092
20018
  if (isRenderableConstructor(type)) {
19093
20019
  const instance = new type(ctx, props || {});
19094
- for (const child of children) {
20020
+ for (const child of children2) {
19095
20021
  if (isRenderable(child)) {
19096
20022
  instance.add(child);
19097
20023
  } else {
@@ -19112,7 +20038,7 @@ function instantiate(ctx, node) {
19112
20038
  }
19113
20039
  return delegatedInstance;
19114
20040
  }
19115
- const resolved = type(props || {}, children);
20041
+ const resolved = type(props || {}, children2);
19116
20042
  const inst = instantiate(ctx, resolved);
19117
20043
  return wrapWithDelegates(inst, delegateMap);
19118
20044
  }
@@ -20249,8 +21175,8 @@ function getObjectsInViewport(viewport, objects, direction = "column", padding =
20249
21175
  const viewportLeft = viewport.x - padding;
20250
21176
  const viewportRight = viewport.x + viewport.width + padding;
20251
21177
  const isRow = direction === "row";
20252
- const children = objects;
20253
- const totalChildren = children.length;
21178
+ const children2 = objects;
21179
+ const totalChildren = children2.length;
20254
21180
  if (totalChildren === 0)
20255
21181
  return [];
20256
21182
  const vpStart = isRow ? viewportLeft : viewportTop;
@@ -20260,7 +21186,7 @@ function getObjectsInViewport(viewport, objects, direction = "column", padding =
20260
21186
  let candidate = -1;
20261
21187
  while (lo <= hi) {
20262
21188
  const mid = lo + hi >> 1;
20263
- const c = children[mid];
21189
+ const c = children2[mid];
20264
21190
  const start = isRow ? c.x : c.y;
20265
21191
  const end = isRow ? c.x + c.width : c.y + c.height;
20266
21192
  if (end < vpStart) {
@@ -20280,7 +21206,7 @@ function getObjectsInViewport(viewport, objects, direction = "column", padding =
20280
21206
  let left = candidate;
20281
21207
  let gapCount = 0;
20282
21208
  while (left - 1 >= 0) {
20283
- const prev = children[left - 1];
21209
+ const prev = children2[left - 1];
20284
21210
  const prevEnd = isRow ? prev.x + prev.width : prev.y + prev.height;
20285
21211
  if (prevEnd <= vpStart) {
20286
21212
  gapCount++;
@@ -20294,13 +21220,13 @@ function getObjectsInViewport(viewport, objects, direction = "column", padding =
20294
21220
  }
20295
21221
  let right = candidate + 1;
20296
21222
  while (right < totalChildren) {
20297
- const next = children[right];
21223
+ const next = children2[right];
20298
21224
  if ((isRow ? next.x : next.y) >= vpEnd)
20299
21225
  break;
20300
21226
  right++;
20301
21227
  }
20302
21228
  for (let i = left;i < right; i++) {
20303
- const child = children[i];
21229
+ const child = children2[i];
20304
21230
  const start = isRow ? child.x : child.y;
20305
21231
  const end = isRow ? child.x + child.width : child.y + child.height;
20306
21232
  if (end <= vpStart)
@@ -22132,8 +23058,8 @@ Captured output:
22132
23058
  }
22133
23059
  }
22134
23060
  walkSelectableRenderables(container, selectionBounds, selectedRenderables, touchedRenderables) {
22135
- const children = getObjectsInViewport(selectionBounds, container.getChildrenSortedByPrimaryAxis(), container.primaryAxis, 0, 0);
22136
- for (const child of children) {
23061
+ const children2 = getObjectsInViewport(selectionBounds, container.getChildrenSortedByPrimaryAxis(), container.primaryAxis, 0, 0);
23062
+ for (const child of children2) {
22137
23063
  if (child.selectable) {
22138
23064
  const hasSelection = child.onSelectionChanged(this.currentSelection);
22139
23065
  if (hasSelection) {
@@ -26874,8 +27800,8 @@ class TextNodeRenderable extends BaseRenderable {
26874
27800
  get children() {
26875
27801
  return this._children;
26876
27802
  }
26877
- set children(children) {
26878
- this._children = children;
27803
+ set children(children2) {
27804
+ this._children = children2;
26879
27805
  this.requestRender();
26880
27806
  }
26881
27807
  requestRender() {
@@ -27088,66 +28014,66 @@ class RootTextNodeRenderable extends TextNodeRenderable {
27088
28014
  this.ctx.requestRender();
27089
28015
  }
27090
28016
  }
27091
- function Generic(props, ...children) {
27092
- return h(VRenderable, props || {}, ...children);
28017
+ function Generic(props, ...children2) {
28018
+ return h(VRenderable, props || {}, ...children2);
27093
28019
  }
27094
- function Box(props, ...children) {
27095
- return h(BoxRenderable, props || {}, ...children);
28020
+ function Box(props, ...children2) {
28021
+ return h(BoxRenderable, props || {}, ...children2);
27096
28022
  }
27097
- function Text(props, ...children) {
27098
- return h(TextRenderable, props || {}, ...children);
28023
+ function Text(props, ...children2) {
28024
+ return h(TextRenderable, props || {}, ...children2);
27099
28025
  }
27100
- function ASCIIFont(props, ...children) {
27101
- return h(ASCIIFontRenderable, props || {}, ...children);
28026
+ function ASCIIFont(props, ...children2) {
28027
+ return h(ASCIIFontRenderable, props || {}, ...children2);
27102
28028
  }
27103
- function Input(props, ...children) {
27104
- return h(InputRenderable, props || {}, ...children);
28029
+ function Input(props, ...children2) {
28030
+ return h(InputRenderable, props || {}, ...children2);
27105
28031
  }
27106
- function Select(props, ...children) {
27107
- return h(SelectRenderable, props || {}, ...children);
28032
+ function Select(props, ...children2) {
28033
+ return h(SelectRenderable, props || {}, ...children2);
27108
28034
  }
27109
- function TabSelect(props, ...children) {
27110
- return h(TabSelectRenderable, props || {}, ...children);
28035
+ function TabSelect(props, ...children2) {
28036
+ return h(TabSelectRenderable, props || {}, ...children2);
27111
28037
  }
27112
- function FrameBuffer(props, ...children) {
27113
- return h(FrameBufferRenderable, props, ...children);
28038
+ function FrameBuffer(props, ...children2) {
28039
+ return h(FrameBufferRenderable, props, ...children2);
27114
28040
  }
27115
- function Code(props, ...children) {
27116
- return h(CodeRenderable, props, ...children);
28041
+ function Code(props, ...children2) {
28042
+ return h(CodeRenderable, props, ...children2);
27117
28043
  }
27118
- function ScrollBox(props, ...children) {
27119
- return h(ScrollBoxRenderable, props || {}, ...children);
28044
+ function ScrollBox(props, ...children2) {
28045
+ return h(ScrollBoxRenderable, props || {}, ...children2);
27120
28046
  }
27121
- function StyledText2(props, ...children) {
28047
+ function StyledText2(props, ...children2) {
27122
28048
  const styledProps = props;
27123
28049
  const textNodeOptions = {
27124
28050
  ...styledProps,
27125
28051
  attributes: styledProps?.attributes ?? 0
27126
28052
  };
27127
28053
  const textNode = new TextNodeRenderable(textNodeOptions);
27128
- for (const child of children) {
28054
+ for (const child of children2) {
27129
28055
  textNode.add(child);
27130
28056
  }
27131
28057
  return textNode;
27132
28058
  }
27133
28059
  var vstyles = {
27134
- bold: (...children) => StyledText2({ attributes: TextAttributes.BOLD }, ...children),
27135
- italic: (...children) => StyledText2({ attributes: TextAttributes.ITALIC }, ...children),
27136
- underline: (...children) => StyledText2({ attributes: TextAttributes.UNDERLINE }, ...children),
27137
- dim: (...children) => StyledText2({ attributes: TextAttributes.DIM }, ...children),
27138
- blink: (...children) => StyledText2({ attributes: TextAttributes.BLINK }, ...children),
27139
- inverse: (...children) => StyledText2({ attributes: TextAttributes.INVERSE }, ...children),
27140
- hidden: (...children) => StyledText2({ attributes: TextAttributes.HIDDEN }, ...children),
27141
- strikethrough: (...children) => StyledText2({ attributes: TextAttributes.STRIKETHROUGH }, ...children),
27142
- boldItalic: (...children) => StyledText2({ attributes: TextAttributes.BOLD | TextAttributes.ITALIC }, ...children),
27143
- boldUnderline: (...children) => StyledText2({ attributes: TextAttributes.BOLD | TextAttributes.UNDERLINE }, ...children),
27144
- italicUnderline: (...children) => StyledText2({ attributes: TextAttributes.ITALIC | TextAttributes.UNDERLINE }, ...children),
27145
- boldItalicUnderline: (...children) => StyledText2({ attributes: TextAttributes.BOLD | TextAttributes.ITALIC | TextAttributes.UNDERLINE }, ...children),
27146
- color: (color, ...children) => StyledText2({ fg: color }, ...children),
27147
- bgColor: (bgColor, ...children) => StyledText2({ bg: bgColor }, ...children),
27148
- fg: (color, ...children) => StyledText2({ fg: color }, ...children),
27149
- bg: (bgColor, ...children) => StyledText2({ bg: bgColor }, ...children),
27150
- styled: (attributes = 0, ...children) => StyledText2({ attributes }, ...children)
28060
+ bold: (...children2) => StyledText2({ attributes: TextAttributes.BOLD }, ...children2),
28061
+ italic: (...children2) => StyledText2({ attributes: TextAttributes.ITALIC }, ...children2),
28062
+ underline: (...children2) => StyledText2({ attributes: TextAttributes.UNDERLINE }, ...children2),
28063
+ dim: (...children2) => StyledText2({ attributes: TextAttributes.DIM }, ...children2),
28064
+ blink: (...children2) => StyledText2({ attributes: TextAttributes.BLINK }, ...children2),
28065
+ inverse: (...children2) => StyledText2({ attributes: TextAttributes.INVERSE }, ...children2),
28066
+ hidden: (...children2) => StyledText2({ attributes: TextAttributes.HIDDEN }, ...children2),
28067
+ strikethrough: (...children2) => StyledText2({ attributes: TextAttributes.STRIKETHROUGH }, ...children2),
28068
+ boldItalic: (...children2) => StyledText2({ attributes: TextAttributes.BOLD | TextAttributes.ITALIC }, ...children2),
28069
+ boldUnderline: (...children2) => StyledText2({ attributes: TextAttributes.BOLD | TextAttributes.UNDERLINE }, ...children2),
28070
+ italicUnderline: (...children2) => StyledText2({ attributes: TextAttributes.ITALIC | TextAttributes.UNDERLINE }, ...children2),
28071
+ boldItalicUnderline: (...children2) => StyledText2({ attributes: TextAttributes.BOLD | TextAttributes.ITALIC | TextAttributes.UNDERLINE }, ...children2),
28072
+ color: (color, ...children2) => StyledText2({ fg: color }, ...children2),
28073
+ bgColor: (bgColor, ...children2) => StyledText2({ bg: bgColor }, ...children2),
28074
+ fg: (color, ...children2) => StyledText2({ fg: color }, ...children2),
28075
+ bg: (bgColor, ...children2) => StyledText2({ bg: bgColor }, ...children2),
28076
+ styled: (attributes = 0, ...children2) => StyledText2({ attributes }, ...children2)
27151
28077
  };
27152
28078
 
27153
28079
  class VRenderable extends Renderable {
@@ -34797,1472 +35723,546 @@ class SelectRenderable extends Renderable {
34797
35723
  set selectedBackgroundColor(value) {
34798
35724
  const newColor = parseColor(value ?? this._defaultOptions.selectedBackgroundColor);
34799
35725
  if (this._selectedBackgroundColor !== newColor) {
34800
- this._selectedBackgroundColor = newColor;
34801
- this.requestRender();
34802
- }
34803
- }
34804
- set selectedTextColor(value) {
34805
- const newColor = parseColor(value ?? this._defaultOptions.selectedTextColor);
34806
- if (this._selectedTextColor !== newColor) {
34807
- this._selectedTextColor = newColor;
34808
- this.requestRender();
34809
- }
34810
- }
34811
- set descriptionColor(value) {
34812
- const newColor = parseColor(value ?? this._defaultOptions.descriptionColor);
34813
- if (this._descriptionColor !== newColor) {
34814
- this._descriptionColor = newColor;
34815
- this.requestRender();
34816
- }
34817
- }
34818
- set selectedDescriptionColor(value) {
34819
- const newColor = parseColor(value ?? this._defaultOptions.selectedDescriptionColor);
34820
- if (this._selectedDescriptionColor !== newColor) {
34821
- this._selectedDescriptionColor = newColor;
34822
- this.requestRender();
34823
- }
34824
- }
34825
- set font(font) {
34826
- this._font = font;
34827
- this.fontHeight = measureText({ text: "A", font: this._font }).height;
34828
- this.linesPerItem = this._showDescription ? this._font ? this.fontHeight + 1 : 2 : this._font ? this.fontHeight : 1;
34829
- this.linesPerItem += this._itemSpacing;
34830
- this.maxVisibleItems = Math.max(1, Math.floor(this.height / this.linesPerItem));
34831
- this.updateScrollOffset();
34832
- this.requestRender();
34833
- }
34834
- set itemSpacing(spacing) {
34835
- this._itemSpacing = spacing;
34836
- this.linesPerItem = this._showDescription ? this._font ? this.fontHeight + 1 : 2 : this._font ? this.fontHeight : 1;
34837
- this.linesPerItem += this._itemSpacing;
34838
- this.maxVisibleItems = Math.max(1, Math.floor(this.height / this.linesPerItem));
34839
- this.updateScrollOffset();
34840
- this.requestRender();
34841
- }
34842
- set fastScrollStep(step) {
34843
- this._fastScrollStep = step;
34844
- }
34845
- set keyBindings(bindings) {
34846
- this._keyBindings = bindings;
34847
- const mergedBindings = mergeKeyBindings(defaultSelectKeybindings, bindings);
34848
- this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
34849
- }
34850
- set keyAliasMap(aliases) {
34851
- this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, aliases);
34852
- const mergedBindings = mergeKeyBindings(defaultSelectKeybindings, this._keyBindings);
34853
- this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
34854
- }
34855
- set selectedIndex(value) {
34856
- const newIndex = value ?? this._defaultOptions.selectedIndex;
34857
- const clampedIndex = this._options.length > 0 ? Math.min(Math.max(0, newIndex), this._options.length - 1) : 0;
34858
- if (this._selectedIndex !== clampedIndex) {
34859
- this._selectedIndex = clampedIndex;
34860
- this.updateScrollOffset();
34861
- this.requestRender();
34862
- }
34863
- }
34864
- }
34865
- var defaultTabSelectKeybindings = [
34866
- { name: "left", action: "move-left" },
34867
- { name: "[", action: "move-left" },
34868
- { name: "right", action: "move-right" },
34869
- { name: "]", action: "move-right" },
34870
- { name: "return", action: "select-current" },
34871
- { name: "linefeed", action: "select-current" }
34872
- ];
34873
- var TabSelectRenderableEvents;
34874
- ((TabSelectRenderableEvents2) => {
34875
- TabSelectRenderableEvents2["SELECTION_CHANGED"] = "selectionChanged";
34876
- TabSelectRenderableEvents2["ITEM_SELECTED"] = "itemSelected";
34877
- })(TabSelectRenderableEvents ||= {});
34878
- function calculateDynamicHeight(showUnderline, showDescription) {
34879
- let height = 1;
34880
- if (showUnderline) {
34881
- height += 1;
34882
- }
34883
- if (showDescription) {
34884
- height += 1;
34885
- }
34886
- return height;
34887
- }
34888
-
34889
- class TabSelectRenderable extends Renderable {
34890
- _focusable = true;
34891
- _options = [];
34892
- selectedIndex = 0;
34893
- scrollOffset = 0;
34894
- _tabWidth;
34895
- maxVisibleTabs;
34896
- _backgroundColor;
34897
- _textColor;
34898
- _focusedBackgroundColor;
34899
- _focusedTextColor;
34900
- _selectedBackgroundColor;
34901
- _selectedTextColor;
34902
- _selectedDescriptionColor;
34903
- _showScrollArrows;
34904
- _showDescription;
34905
- _showUnderline;
34906
- _wrapSelection;
34907
- _keyBindingsMap;
34908
- _keyAliasMap;
34909
- _keyBindings;
34910
- constructor(ctx, options) {
34911
- const calculatedHeight = calculateDynamicHeight(options.showUnderline ?? true, options.showDescription ?? true);
34912
- super(ctx, { ...options, height: calculatedHeight, buffered: true });
34913
- this._backgroundColor = parseColor(options.backgroundColor || "transparent");
34914
- this._textColor = parseColor(options.textColor || "#FFFFFF");
34915
- this._focusedBackgroundColor = parseColor(options.focusedBackgroundColor || options.backgroundColor || "#1a1a1a");
34916
- this._focusedTextColor = parseColor(options.focusedTextColor || options.textColor || "#FFFFFF");
34917
- this._options = options.options || [];
34918
- this._tabWidth = options.tabWidth || 20;
34919
- this._showDescription = options.showDescription ?? true;
34920
- this._showUnderline = options.showUnderline ?? true;
34921
- this._showScrollArrows = options.showScrollArrows ?? true;
34922
- this._wrapSelection = options.wrapSelection ?? false;
34923
- this.maxVisibleTabs = Math.max(1, Math.floor(this.width / this._tabWidth));
34924
- this._selectedBackgroundColor = parseColor(options.selectedBackgroundColor || "#334455");
34925
- this._selectedTextColor = parseColor(options.selectedTextColor || "#FFFF00");
34926
- this._selectedDescriptionColor = parseColor(options.selectedDescriptionColor || "#CCCCCC");
34927
- this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, options.keyAliasMap || {});
34928
- this._keyBindings = options.keyBindings || [];
34929
- const mergedBindings = mergeKeyBindings(defaultTabSelectKeybindings, this._keyBindings);
34930
- this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
34931
- }
34932
- calculateDynamicHeight() {
34933
- return calculateDynamicHeight(this._showUnderline, this._showDescription);
34934
- }
34935
- renderSelf(buffer, deltaTime) {
34936
- if (!this.visible || !this.frameBuffer)
34937
- return;
34938
- if (this.isDirty) {
34939
- this.refreshFrameBuffer();
34940
- }
34941
- }
34942
- refreshFrameBuffer() {
34943
- if (!this.frameBuffer)
34944
- return;
34945
- const bgColor = this._focused ? this._focusedBackgroundColor : this._backgroundColor;
34946
- this.frameBuffer.clear(bgColor);
34947
- if (this._options.length === 0)
34948
- return;
34949
- const contentX = 0;
34950
- const contentY = 0;
34951
- const contentWidth = this.width;
34952
- const contentHeight = this.height;
34953
- const visibleOptions = this._options.slice(this.scrollOffset, this.scrollOffset + this.maxVisibleTabs);
34954
- for (let i = 0;i < visibleOptions.length; i++) {
34955
- const actualIndex = this.scrollOffset + i;
34956
- const option = visibleOptions[i];
34957
- const isSelected = actualIndex === this.selectedIndex;
34958
- const tabX = contentX + i * this._tabWidth;
34959
- if (tabX >= contentX + contentWidth)
34960
- break;
34961
- const actualTabWidth = Math.min(this._tabWidth, contentWidth - i * this._tabWidth);
34962
- if (isSelected) {
34963
- this.frameBuffer.fillRect(tabX, contentY, actualTabWidth, 1, this._selectedBackgroundColor);
34964
- }
34965
- const baseTextColor = this._focused ? this._focusedTextColor : this._textColor;
34966
- const nameColor = isSelected ? this._selectedTextColor : baseTextColor;
34967
- const nameContent = this.truncateText(option.name, actualTabWidth - 2);
34968
- this.frameBuffer.drawText(nameContent, tabX + 1, contentY, nameColor);
34969
- if (isSelected && this._showUnderline && contentHeight >= 2) {
34970
- const underlineY = contentY + 1;
34971
- const underlineBg = isSelected ? this._selectedBackgroundColor : bgColor;
34972
- this.frameBuffer.drawText("\u25AC".repeat(actualTabWidth), tabX, underlineY, nameColor, underlineBg);
34973
- }
34974
- }
34975
- if (this._showDescription && contentHeight >= (this._showUnderline ? 3 : 2)) {
34976
- const selectedOption = this.getSelectedOption();
34977
- if (selectedOption) {
34978
- const descriptionY = contentY + (this._showUnderline ? 2 : 1);
34979
- const descColor = this._selectedDescriptionColor;
34980
- const descContent = this.truncateText(selectedOption.description, contentWidth - 2);
34981
- this.frameBuffer.drawText(descContent, contentX + 1, descriptionY, descColor);
34982
- }
34983
- }
34984
- if (this._showScrollArrows && this._options.length > this.maxVisibleTabs) {
34985
- this.renderScrollArrowsToFrameBuffer(contentX, contentY, contentWidth, contentHeight);
34986
- }
34987
- }
34988
- truncateText(text, maxWidth) {
34989
- if (text.length <= maxWidth)
34990
- return text;
34991
- return text.substring(0, Math.max(0, maxWidth - 1)) + "\u2026";
34992
- }
34993
- renderScrollArrowsToFrameBuffer(contentX, contentY, contentWidth, contentHeight) {
34994
- if (!this.frameBuffer)
34995
- return;
34996
- const hasMoreLeft = this.scrollOffset > 0;
34997
- const hasMoreRight = this.scrollOffset + this.maxVisibleTabs < this._options.length;
34998
- if (hasMoreLeft) {
34999
- this.frameBuffer.drawText("\u2039", contentX, contentY, parseColor("#AAAAAA"));
35000
- }
35001
- if (hasMoreRight) {
35002
- this.frameBuffer.drawText("\u203A", contentX + contentWidth - 1, contentY, parseColor("#AAAAAA"));
35003
- }
35004
- }
35005
- setOptions(options) {
35006
- this._options = options;
35007
- this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, options.length - 1));
35008
- this.updateScrollOffset();
35009
- this.requestRender();
35010
- }
35011
- getSelectedOption() {
35012
- return this._options[this.selectedIndex] || null;
35013
- }
35014
- getSelectedIndex() {
35015
- return this.selectedIndex;
35016
- }
35017
- moveLeft() {
35018
- if (this.selectedIndex > 0) {
35019
- this.selectedIndex--;
35020
- } else if (this._wrapSelection && this._options.length > 0) {
35021
- this.selectedIndex = this._options.length - 1;
35022
- } else {
35023
- return;
35024
- }
35025
- this.updateScrollOffset();
35026
- this.requestRender();
35027
- this.emit("selectionChanged", this.selectedIndex, this.getSelectedOption());
35028
- }
35029
- moveRight() {
35030
- if (this.selectedIndex < this._options.length - 1) {
35031
- this.selectedIndex++;
35032
- } else if (this._wrapSelection && this._options.length > 0) {
35033
- this.selectedIndex = 0;
35034
- } else {
35035
- return;
35036
- }
35037
- this.updateScrollOffset();
35038
- this.requestRender();
35039
- this.emit("selectionChanged", this.selectedIndex, this.getSelectedOption());
35040
- }
35041
- selectCurrent() {
35042
- const selected = this.getSelectedOption();
35043
- if (selected) {
35044
- this.emit("itemSelected", this.selectedIndex, selected);
35045
- }
35046
- }
35047
- setSelectedIndex(index) {
35048
- if (index >= 0 && index < this._options.length) {
35049
- this.selectedIndex = index;
35050
- this.updateScrollOffset();
35051
- this.requestRender();
35052
- this.emit("selectionChanged", this.selectedIndex, this.getSelectedOption());
35053
- }
35054
- }
35055
- updateScrollOffset() {
35056
- const halfVisible = Math.floor(this.maxVisibleTabs / 2);
35057
- const newScrollOffset = Math.max(0, Math.min(this.selectedIndex - halfVisible, this._options.length - this.maxVisibleTabs));
35058
- if (newScrollOffset !== this.scrollOffset) {
35059
- this.scrollOffset = newScrollOffset;
35060
- this.requestRender();
35061
- }
35062
- }
35063
- onResize(width, height) {
35064
- this.maxVisibleTabs = Math.max(1, Math.floor(width / this._tabWidth));
35065
- this.updateScrollOffset();
35066
- this.requestRender();
35067
- }
35068
- setTabWidth(tabWidth) {
35069
- if (this._tabWidth === tabWidth)
35070
- return;
35071
- this._tabWidth = tabWidth;
35072
- this.maxVisibleTabs = Math.max(1, Math.floor(this.width / this._tabWidth));
35073
- this.updateScrollOffset();
35074
- this.requestRender();
35075
- }
35076
- getTabWidth() {
35077
- return this._tabWidth;
35078
- }
35079
- handleKeyPress(key) {
35080
- const bindingKey = getKeyBindingKey({
35081
- name: key.name,
35082
- ctrl: key.ctrl,
35083
- shift: key.shift,
35084
- meta: key.meta,
35085
- super: key.super,
35086
- action: "move-left"
35087
- });
35088
- const action = this._keyBindingsMap.get(bindingKey);
35089
- if (action) {
35090
- switch (action) {
35091
- case "move-left":
35092
- this.moveLeft();
35093
- return true;
35094
- case "move-right":
35095
- this.moveRight();
35096
- return true;
35097
- case "select-current":
35098
- this.selectCurrent();
35099
- return true;
35100
- }
35101
- }
35102
- return false;
35103
- }
35104
- get options() {
35105
- return this._options;
35106
- }
35107
- set options(options) {
35108
- this._options = options;
35109
- this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, options.length - 1));
35110
- this.updateScrollOffset();
35111
- this.requestRender();
35112
- }
35113
- set backgroundColor(color) {
35114
- this._backgroundColor = parseColor(color);
35115
- this.requestRender();
35116
- }
35117
- set textColor(color) {
35118
- this._textColor = parseColor(color);
35119
- this.requestRender();
35120
- }
35121
- set focusedBackgroundColor(color) {
35122
- this._focusedBackgroundColor = parseColor(color);
35123
- this.requestRender();
35124
- }
35125
- set focusedTextColor(color) {
35126
- this._focusedTextColor = parseColor(color);
35127
- this.requestRender();
35128
- }
35129
- set selectedBackgroundColor(color) {
35130
- this._selectedBackgroundColor = parseColor(color);
35131
- this.requestRender();
35132
- }
35133
- set selectedTextColor(color) {
35134
- this._selectedTextColor = parseColor(color);
35135
- this.requestRender();
35136
- }
35137
- set selectedDescriptionColor(color) {
35138
- this._selectedDescriptionColor = parseColor(color);
35139
- this.requestRender();
35140
- }
35141
- get showDescription() {
35142
- return this._showDescription;
35143
- }
35144
- set showDescription(show) {
35145
- if (this._showDescription !== show) {
35146
- this._showDescription = show;
35147
- const newHeight = this.calculateDynamicHeight();
35148
- this.height = newHeight;
35726
+ this._selectedBackgroundColor = newColor;
35149
35727
  this.requestRender();
35150
35728
  }
35151
35729
  }
35152
- get showUnderline() {
35153
- return this._showUnderline;
35154
- }
35155
- set showUnderline(show) {
35156
- if (this._showUnderline !== show) {
35157
- this._showUnderline = show;
35158
- const newHeight = this.calculateDynamicHeight();
35159
- this.height = newHeight;
35730
+ set selectedTextColor(value) {
35731
+ const newColor = parseColor(value ?? this._defaultOptions.selectedTextColor);
35732
+ if (this._selectedTextColor !== newColor) {
35733
+ this._selectedTextColor = newColor;
35160
35734
  this.requestRender();
35161
35735
  }
35162
35736
  }
35163
- get showScrollArrows() {
35164
- return this._showScrollArrows;
35165
- }
35166
- set showScrollArrows(show) {
35167
- if (this._showScrollArrows !== show) {
35168
- this._showScrollArrows = show;
35737
+ set descriptionColor(value) {
35738
+ const newColor = parseColor(value ?? this._defaultOptions.descriptionColor);
35739
+ if (this._descriptionColor !== newColor) {
35740
+ this._descriptionColor = newColor;
35169
35741
  this.requestRender();
35170
35742
  }
35171
35743
  }
35172
- get wrapSelection() {
35173
- return this._wrapSelection;
35174
- }
35175
- set wrapSelection(wrap) {
35176
- this._wrapSelection = wrap;
35744
+ set selectedDescriptionColor(value) {
35745
+ const newColor = parseColor(value ?? this._defaultOptions.selectedDescriptionColor);
35746
+ if (this._selectedDescriptionColor !== newColor) {
35747
+ this._selectedDescriptionColor = newColor;
35748
+ this.requestRender();
35749
+ }
35177
35750
  }
35178
- get tabWidth() {
35179
- return this._tabWidth;
35751
+ set font(font) {
35752
+ this._font = font;
35753
+ this.fontHeight = measureText({ text: "A", font: this._font }).height;
35754
+ this.linesPerItem = this._showDescription ? this._font ? this.fontHeight + 1 : 2 : this._font ? this.fontHeight : 1;
35755
+ this.linesPerItem += this._itemSpacing;
35756
+ this.maxVisibleItems = Math.max(1, Math.floor(this.height / this.linesPerItem));
35757
+ this.updateScrollOffset();
35758
+ this.requestRender();
35180
35759
  }
35181
- set tabWidth(tabWidth) {
35182
- if (this._tabWidth === tabWidth)
35183
- return;
35184
- this._tabWidth = tabWidth;
35185
- this.maxVisibleTabs = Math.max(1, Math.floor(this.width / this._tabWidth));
35760
+ set itemSpacing(spacing) {
35761
+ this._itemSpacing = spacing;
35762
+ this.linesPerItem = this._showDescription ? this._font ? this.fontHeight + 1 : 2 : this._font ? this.fontHeight : 1;
35763
+ this.linesPerItem += this._itemSpacing;
35764
+ this.maxVisibleItems = Math.max(1, Math.floor(this.height / this.linesPerItem));
35186
35765
  this.updateScrollOffset();
35187
35766
  this.requestRender();
35188
35767
  }
35768
+ set fastScrollStep(step) {
35769
+ this._fastScrollStep = step;
35770
+ }
35189
35771
  set keyBindings(bindings) {
35190
35772
  this._keyBindings = bindings;
35191
- const mergedBindings = mergeKeyBindings(defaultTabSelectKeybindings, bindings);
35773
+ const mergedBindings = mergeKeyBindings(defaultSelectKeybindings, bindings);
35192
35774
  this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
35193
35775
  }
35194
35776
  set keyAliasMap(aliases) {
35195
35777
  this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, aliases);
35196
- const mergedBindings = mergeKeyBindings(defaultTabSelectKeybindings, this._keyBindings);
35778
+ const mergedBindings = mergeKeyBindings(defaultSelectKeybindings, this._keyBindings);
35197
35779
  this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
35198
35780
  }
35199
- }
35200
-
35201
- class TimeToFirstDrawRenderable extends Renderable {
35202
- _runtimeMs = null;
35203
- textColor;
35204
- label;
35205
- precision;
35206
- constructor(ctx, options = {}) {
35207
- super(ctx, {
35208
- width: "100%",
35209
- height: 1,
35210
- flexShrink: 0,
35211
- alignSelf: "center",
35212
- ...options
35213
- });
35214
- this.textColor = parseColor(options.fg ?? "#AAAAAA");
35215
- this.label = options.label ?? "Time to first draw";
35216
- this.precision = this.normalizePrecision(options.precision ?? 2);
35217
- }
35218
- get runtimeMs() {
35219
- return this._runtimeMs;
35220
- }
35221
- set fg(value) {
35222
- this.textColor = parseColor(value);
35223
- this.requestRender();
35224
- }
35225
- set color(value) {
35226
- this.fg = value;
35227
- }
35228
- set textLabel(value) {
35229
- if (value === this.label) {
35230
- return;
35231
- }
35232
- this.label = value;
35233
- this.requestRender();
35234
- }
35235
- set decimals(value) {
35236
- const nextPrecision = this.normalizePrecision(value);
35237
- if (nextPrecision === this.precision) {
35238
- return;
35781
+ set selectedIndex(value) {
35782
+ const newIndex = value ?? this._defaultOptions.selectedIndex;
35783
+ const clampedIndex = this._options.length > 0 ? Math.min(Math.max(0, newIndex), this._options.length - 1) : 0;
35784
+ if (this._selectedIndex !== clampedIndex) {
35785
+ this._selectedIndex = clampedIndex;
35786
+ this.updateScrollOffset();
35787
+ this.requestRender();
35239
35788
  }
35240
- this.precision = nextPrecision;
35241
- this.requestRender();
35242
- }
35243
- reset() {
35244
- this._runtimeMs = null;
35245
- this.requestRender();
35246
35789
  }
35247
- renderSelf(buffer) {
35248
- if (this._runtimeMs === null) {
35249
- this._runtimeMs = performance.now();
35250
- }
35251
- const content = `${this.label}: ${this._runtimeMs.toFixed(this.precision)}ms`;
35252
- const maxWidth = Math.max(this.width, 1);
35253
- const visibleContent = content.length > maxWidth ? content.slice(0, maxWidth) : content;
35254
- const centeredX = this.x + Math.max(0, Math.floor((maxWidth - visibleContent.length) / 2));
35255
- buffer.drawText(visibleContent, centeredX, this.y, this.textColor);
35790
+ }
35791
+ var defaultTabSelectKeybindings = [
35792
+ { name: "left", action: "move-left" },
35793
+ { name: "[", action: "move-left" },
35794
+ { name: "right", action: "move-right" },
35795
+ { name: "]", action: "move-right" },
35796
+ { name: "return", action: "select-current" },
35797
+ { name: "linefeed", action: "select-current" }
35798
+ ];
35799
+ var TabSelectRenderableEvents;
35800
+ ((TabSelectRenderableEvents2) => {
35801
+ TabSelectRenderableEvents2["SELECTION_CHANGED"] = "selectionChanged";
35802
+ TabSelectRenderableEvents2["ITEM_SELECTED"] = "itemSelected";
35803
+ })(TabSelectRenderableEvents ||= {});
35804
+ function calculateDynamicHeight(showUnderline, showDescription) {
35805
+ let height = 1;
35806
+ if (showUnderline) {
35807
+ height += 1;
35256
35808
  }
35257
- normalizePrecision(value) {
35258
- if (!Number.isFinite(value)) {
35259
- return 2;
35260
- }
35261
- return Math.max(0, Math.floor(value));
35809
+ if (showDescription) {
35810
+ height += 1;
35262
35811
  }
35812
+ return height;
35263
35813
  }
35264
35814
 
35265
- // node_modules/@opentui/solid/node_modules/@opentui/core/testing.js
35266
- var decoder2 = new TextDecoder;
35267
- class TestRecorder {
35268
- renderer;
35269
- frames = [];
35270
- recording = false;
35271
- frameNumber = 0;
35272
- startTime = 0;
35273
- originalRenderNative;
35274
- decoder = new TextDecoder;
35275
- recordBuffers;
35276
- now;
35277
- constructor(renderer, options) {
35278
- this.renderer = renderer;
35279
- this.recordBuffers = options?.recordBuffers || {};
35280
- this.now = options?.now ?? (() => performance.now());
35815
+ class TabSelectRenderable extends Renderable {
35816
+ _focusable = true;
35817
+ _options = [];
35818
+ selectedIndex = 0;
35819
+ scrollOffset = 0;
35820
+ _tabWidth;
35821
+ maxVisibleTabs;
35822
+ _backgroundColor;
35823
+ _textColor;
35824
+ _focusedBackgroundColor;
35825
+ _focusedTextColor;
35826
+ _selectedBackgroundColor;
35827
+ _selectedTextColor;
35828
+ _selectedDescriptionColor;
35829
+ _showScrollArrows;
35830
+ _showDescription;
35831
+ _showUnderline;
35832
+ _wrapSelection;
35833
+ _keyBindingsMap;
35834
+ _keyAliasMap;
35835
+ _keyBindings;
35836
+ constructor(ctx, options) {
35837
+ const calculatedHeight = calculateDynamicHeight(options.showUnderline ?? true, options.showDescription ?? true);
35838
+ super(ctx, { ...options, height: calculatedHeight, buffered: true });
35839
+ this._backgroundColor = parseColor(options.backgroundColor || "transparent");
35840
+ this._textColor = parseColor(options.textColor || "#FFFFFF");
35841
+ this._focusedBackgroundColor = parseColor(options.focusedBackgroundColor || options.backgroundColor || "#1a1a1a");
35842
+ this._focusedTextColor = parseColor(options.focusedTextColor || options.textColor || "#FFFFFF");
35843
+ this._options = options.options || [];
35844
+ this._tabWidth = options.tabWidth || 20;
35845
+ this._showDescription = options.showDescription ?? true;
35846
+ this._showUnderline = options.showUnderline ?? true;
35847
+ this._showScrollArrows = options.showScrollArrows ?? true;
35848
+ this._wrapSelection = options.wrapSelection ?? false;
35849
+ this.maxVisibleTabs = Math.max(1, Math.floor(this.width / this._tabWidth));
35850
+ this._selectedBackgroundColor = parseColor(options.selectedBackgroundColor || "#334455");
35851
+ this._selectedTextColor = parseColor(options.selectedTextColor || "#FFFF00");
35852
+ this._selectedDescriptionColor = parseColor(options.selectedDescriptionColor || "#CCCCCC");
35853
+ this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, options.keyAliasMap || {});
35854
+ this._keyBindings = options.keyBindings || [];
35855
+ const mergedBindings = mergeKeyBindings(defaultTabSelectKeybindings, this._keyBindings);
35856
+ this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
35281
35857
  }
35282
- rec() {
35283
- if (this.recording) {
35284
- return;
35285
- }
35286
- this.recording = true;
35287
- this.frames = [];
35288
- this.frameNumber = 0;
35289
- this.startTime = this.now();
35290
- this.originalRenderNative = this.renderer["renderNative"].bind(this.renderer);
35291
- this.renderer["renderNative"] = () => {
35292
- this.originalRenderNative();
35293
- this.captureFrame();
35294
- };
35858
+ calculateDynamicHeight() {
35859
+ return calculateDynamicHeight(this._showUnderline, this._showDescription);
35295
35860
  }
35296
- stop() {
35297
- if (!this.recording) {
35861
+ renderSelf(buffer, deltaTime) {
35862
+ if (!this.visible || !this.frameBuffer)
35298
35863
  return;
35864
+ if (this.isDirty) {
35865
+ this.refreshFrameBuffer();
35299
35866
  }
35300
- this.recording = false;
35301
- if (this.originalRenderNative) {
35302
- this.renderer["renderNative"] = this.originalRenderNative;
35303
- this.originalRenderNative = undefined;
35304
- }
35305
- }
35306
- get recordedFrames() {
35307
- return [...this.frames];
35308
- }
35309
- clear() {
35310
- this.frames = [];
35311
- this.frameNumber = 0;
35312
35867
  }
35313
- get isRecording() {
35314
- return this.recording;
35315
- }
35316
- captureFrame() {
35317
- const currentBuffer = this.renderer.currentRenderBuffer;
35318
- const frameBytes = currentBuffer.getRealCharBytes(true);
35319
- const frame = this.decoder.decode(frameBytes);
35320
- const recordedFrame = {
35321
- frame,
35322
- timestamp: this.now() - this.startTime,
35323
- frameNumber: this.frameNumber++
35324
- };
35325
- if (this.recordBuffers.fg || this.recordBuffers.bg || this.recordBuffers.attributes) {
35326
- const buffers = currentBuffer.buffers;
35327
- recordedFrame.buffers = {};
35328
- if (this.recordBuffers.fg) {
35329
- recordedFrame.buffers.fg = new Float32Array(buffers.fg);
35868
+ refreshFrameBuffer() {
35869
+ if (!this.frameBuffer)
35870
+ return;
35871
+ const bgColor = this._focused ? this._focusedBackgroundColor : this._backgroundColor;
35872
+ this.frameBuffer.clear(bgColor);
35873
+ if (this._options.length === 0)
35874
+ return;
35875
+ const contentX = 0;
35876
+ const contentY = 0;
35877
+ const contentWidth = this.width;
35878
+ const contentHeight = this.height;
35879
+ const visibleOptions = this._options.slice(this.scrollOffset, this.scrollOffset + this.maxVisibleTabs);
35880
+ for (let i = 0;i < visibleOptions.length; i++) {
35881
+ const actualIndex = this.scrollOffset + i;
35882
+ const option = visibleOptions[i];
35883
+ const isSelected = actualIndex === this.selectedIndex;
35884
+ const tabX = contentX + i * this._tabWidth;
35885
+ if (tabX >= contentX + contentWidth)
35886
+ break;
35887
+ const actualTabWidth = Math.min(this._tabWidth, contentWidth - i * this._tabWidth);
35888
+ if (isSelected) {
35889
+ this.frameBuffer.fillRect(tabX, contentY, actualTabWidth, 1, this._selectedBackgroundColor);
35330
35890
  }
35331
- if (this.recordBuffers.bg) {
35332
- recordedFrame.buffers.bg = new Float32Array(buffers.bg);
35891
+ const baseTextColor = this._focused ? this._focusedTextColor : this._textColor;
35892
+ const nameColor = isSelected ? this._selectedTextColor : baseTextColor;
35893
+ const nameContent = this.truncateText(option.name, actualTabWidth - 2);
35894
+ this.frameBuffer.drawText(nameContent, tabX + 1, contentY, nameColor);
35895
+ if (isSelected && this._showUnderline && contentHeight >= 2) {
35896
+ const underlineY = contentY + 1;
35897
+ const underlineBg = isSelected ? this._selectedBackgroundColor : bgColor;
35898
+ this.frameBuffer.drawText("\u25AC".repeat(actualTabWidth), tabX, underlineY, nameColor, underlineBg);
35333
35899
  }
35334
- if (this.recordBuffers.attributes) {
35335
- recordedFrame.buffers.attributes = new Uint8Array(buffers.attributes);
35900
+ }
35901
+ if (this._showDescription && contentHeight >= (this._showUnderline ? 3 : 2)) {
35902
+ const selectedOption = this.getSelectedOption();
35903
+ if (selectedOption) {
35904
+ const descriptionY = contentY + (this._showUnderline ? 2 : 1);
35905
+ const descColor = this._selectedDescriptionColor;
35906
+ const descContent = this.truncateText(selectedOption.description, contentWidth - 2);
35907
+ this.frameBuffer.drawText(descContent, contentX + 1, descriptionY, descColor);
35336
35908
  }
35337
35909
  }
35338
- this.frames.push(recordedFrame);
35339
- }
35340
- }
35341
-
35342
- // node_modules/solid-js/dist/server.js
35343
- var sharedConfig = {
35344
- context: undefined,
35345
- registry: undefined,
35346
- effects: undefined,
35347
- done: false,
35348
- getContextId() {
35349
- return getContextId(this.context.count);
35350
- },
35351
- getNextContextId() {
35352
- return getContextId(this.context.count++);
35353
- }
35354
- };
35355
- function getContextId(count) {
35356
- const num = String(count), len = num.length - 1;
35357
- return sharedConfig.context.id + (len ? String.fromCharCode(96 + len) : "") + num;
35358
- }
35359
- function setHydrateContext(context) {
35360
- sharedConfig.context = context;
35361
- }
35362
- function nextHydrateContext() {
35363
- return {
35364
- ...sharedConfig.context,
35365
- id: sharedConfig.getNextContextId(),
35366
- count: 0
35367
- };
35368
- }
35369
- var IS_DEV = false;
35370
- var equalFn = (a, b2) => a === b2;
35371
- var $PROXY = Symbol("solid-proxy");
35372
- var SUPPORTS_PROXY = typeof Proxy === "function";
35373
- var $TRACK = Symbol("solid-track");
35374
- var $DEVCOMP = Symbol("solid-dev-component");
35375
- var signalOptions = {
35376
- equals: equalFn
35377
- };
35378
- var ERROR = null;
35379
- var runEffects = runQueue;
35380
- var STALE = 1;
35381
- var PENDING = 2;
35382
- var UNOWNED = {
35383
- owned: null,
35384
- cleanups: null,
35385
- context: null,
35386
- owner: null
35387
- };
35388
- var Owner = null;
35389
- var Transition = null;
35390
- var Scheduler = null;
35391
- var ExternalSourceConfig = null;
35392
- var Listener = null;
35393
- var Updates = null;
35394
- var Effects = null;
35395
- var ExecCount = 0;
35396
- function createRoot(fn, detachedOwner) {
35397
- const listener = Listener, owner = Owner, unowned = fn.length === 0, current = detachedOwner === undefined ? owner : detachedOwner, root = unowned ? UNOWNED : {
35398
- owned: null,
35399
- cleanups: null,
35400
- context: current ? current.context : null,
35401
- owner: current
35402
- }, updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
35403
- Owner = root;
35404
- Listener = null;
35405
- try {
35406
- return runUpdates(updateFn, true);
35407
- } finally {
35408
- Listener = listener;
35409
- Owner = owner;
35410
- }
35411
- }
35412
- function createSignal(value, options) {
35413
- options = options ? Object.assign({}, signalOptions, options) : signalOptions;
35414
- const s = {
35415
- value,
35416
- observers: null,
35417
- observerSlots: null,
35418
- comparator: options.equals || undefined
35419
- };
35420
- const setter = (value2) => {
35421
- if (typeof value2 === "function") {
35422
- if (Transition && Transition.running && Transition.sources.has(s))
35423
- value2 = value2(s.tValue);
35424
- else
35425
- value2 = value2(s.value);
35910
+ if (this._showScrollArrows && this._options.length > this.maxVisibleTabs) {
35911
+ this.renderScrollArrowsToFrameBuffer(contentX, contentY, contentWidth, contentHeight);
35426
35912
  }
35427
- return writeSignal(s, value2);
35428
- };
35429
- return [readSignal.bind(s), setter];
35430
- }
35431
- function createRenderEffect(fn, value, options) {
35432
- const c = createComputation(fn, value, false, STALE);
35433
- if (Scheduler && Transition && Transition.running)
35434
- Updates.push(c);
35435
- else
35436
- updateComputation(c);
35437
- }
35438
- function createEffect(fn, value, options) {
35439
- runEffects = runUserEffects;
35440
- const c = createComputation(fn, value, false, STALE), s = SuspenseContext && useContext(SuspenseContext);
35441
- if (s)
35442
- c.suspense = s;
35443
- if (!options || !options.render)
35444
- c.user = true;
35445
- Effects ? Effects.push(c) : updateComputation(c);
35446
- }
35447
- function createMemo(fn, value, options) {
35448
- options = options ? Object.assign({}, signalOptions, options) : signalOptions;
35449
- const c = createComputation(fn, value, true, 0);
35450
- c.observers = null;
35451
- c.observerSlots = null;
35452
- c.comparator = options.equals || undefined;
35453
- if (Scheduler && Transition && Transition.running) {
35454
- c.tState = STALE;
35455
- Updates.push(c);
35456
- } else
35457
- updateComputation(c);
35458
- return readSignal.bind(c);
35459
- }
35460
- function untrack(fn) {
35461
- if (!ExternalSourceConfig && Listener === null)
35462
- return fn();
35463
- const listener = Listener;
35464
- Listener = null;
35465
- try {
35466
- if (ExternalSourceConfig)
35467
- return ExternalSourceConfig.untrack(fn);
35468
- return fn();
35469
- } finally {
35470
- Listener = listener;
35471
35913
  }
35472
- }
35473
- function onMount(fn) {
35474
- createEffect(() => untrack(fn));
35475
- }
35476
- function onCleanup(fn) {
35477
- if (Owner === null)
35478
- ;
35479
- else if (Owner.cleanups === null)
35480
- Owner.cleanups = [fn];
35481
- else
35482
- Owner.cleanups.push(fn);
35483
- return fn;
35484
- }
35485
- function startTransition(fn) {
35486
- if (Transition && Transition.running) {
35487
- fn();
35488
- return Transition.done;
35914
+ truncateText(text, maxWidth) {
35915
+ if (text.length <= maxWidth)
35916
+ return text;
35917
+ return text.substring(0, Math.max(0, maxWidth - 1)) + "\u2026";
35489
35918
  }
35490
- const l = Listener;
35491
- const o = Owner;
35492
- return Promise.resolve().then(() => {
35493
- Listener = l;
35494
- Owner = o;
35495
- let t2;
35496
- if (Scheduler || SuspenseContext) {
35497
- t2 = Transition || (Transition = {
35498
- sources: new Set,
35499
- effects: [],
35500
- promises: new Set,
35501
- disposed: new Set,
35502
- queue: new Set,
35503
- running: true
35504
- });
35505
- t2.done || (t2.done = new Promise((res) => t2.resolve = res));
35506
- t2.running = true;
35919
+ renderScrollArrowsToFrameBuffer(contentX, contentY, contentWidth, contentHeight) {
35920
+ if (!this.frameBuffer)
35921
+ return;
35922
+ const hasMoreLeft = this.scrollOffset > 0;
35923
+ const hasMoreRight = this.scrollOffset + this.maxVisibleTabs < this._options.length;
35924
+ if (hasMoreLeft) {
35925
+ this.frameBuffer.drawText("\u2039", contentX, contentY, parseColor("#AAAAAA"));
35507
35926
  }
35508
- runUpdates(fn, false);
35509
- Listener = Owner = null;
35510
- return t2 ? t2.done : undefined;
35511
- });
35512
- }
35513
- var [transPending, setTransPending] = /* @__PURE__ */ createSignal(false);
35514
- function createContext(defaultValue, options) {
35515
- const id = Symbol("context");
35516
- return {
35517
- id,
35518
- Provider: createProvider(id),
35519
- defaultValue
35520
- };
35521
- }
35522
- function useContext(context) {
35523
- let value;
35524
- return Owner && Owner.context && (value = Owner.context[context.id]) !== undefined ? value : context.defaultValue;
35525
- }
35526
- function children(fn) {
35527
- const children2 = createMemo(fn);
35528
- const memo = createMemo(() => resolveChildren(children2()));
35529
- memo.toArray = () => {
35530
- const c = memo();
35531
- return Array.isArray(c) ? c : c != null ? [c] : [];
35532
- };
35533
- return memo;
35534
- }
35535
- var SuspenseContext;
35536
- function readSignal() {
35537
- const runningTransition = Transition && Transition.running;
35538
- if (this.sources && (runningTransition ? this.tState : this.state)) {
35539
- if ((runningTransition ? this.tState : this.state) === STALE)
35540
- updateComputation(this);
35541
- else {
35542
- const updates = Updates;
35543
- Updates = null;
35544
- runUpdates(() => lookUpstream(this), false);
35545
- Updates = updates;
35927
+ if (hasMoreRight) {
35928
+ this.frameBuffer.drawText("\u203A", contentX + contentWidth - 1, contentY, parseColor("#AAAAAA"));
35546
35929
  }
35547
35930
  }
35548
- if (Listener) {
35549
- const sSlot = this.observers ? this.observers.length : 0;
35550
- if (!Listener.sources) {
35551
- Listener.sources = [this];
35552
- Listener.sourceSlots = [sSlot];
35931
+ setOptions(options) {
35932
+ this._options = options;
35933
+ this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, options.length - 1));
35934
+ this.updateScrollOffset();
35935
+ this.requestRender();
35936
+ }
35937
+ getSelectedOption() {
35938
+ return this._options[this.selectedIndex] || null;
35939
+ }
35940
+ getSelectedIndex() {
35941
+ return this.selectedIndex;
35942
+ }
35943
+ moveLeft() {
35944
+ if (this.selectedIndex > 0) {
35945
+ this.selectedIndex--;
35946
+ } else if (this._wrapSelection && this._options.length > 0) {
35947
+ this.selectedIndex = this._options.length - 1;
35553
35948
  } else {
35554
- Listener.sources.push(this);
35555
- Listener.sourceSlots.push(sSlot);
35949
+ return;
35556
35950
  }
35557
- if (!this.observers) {
35558
- this.observers = [Listener];
35559
- this.observerSlots = [Listener.sources.length - 1];
35951
+ this.updateScrollOffset();
35952
+ this.requestRender();
35953
+ this.emit("selectionChanged", this.selectedIndex, this.getSelectedOption());
35954
+ }
35955
+ moveRight() {
35956
+ if (this.selectedIndex < this._options.length - 1) {
35957
+ this.selectedIndex++;
35958
+ } else if (this._wrapSelection && this._options.length > 0) {
35959
+ this.selectedIndex = 0;
35560
35960
  } else {
35561
- this.observers.push(Listener);
35562
- this.observerSlots.push(Listener.sources.length - 1);
35961
+ return;
35563
35962
  }
35963
+ this.updateScrollOffset();
35964
+ this.requestRender();
35965
+ this.emit("selectionChanged", this.selectedIndex, this.getSelectedOption());
35564
35966
  }
35565
- if (runningTransition && Transition.sources.has(this))
35566
- return this.tValue;
35567
- return this.value;
35568
- }
35569
- function writeSignal(node, value, isComp) {
35570
- let current = Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
35571
- if (!node.comparator || !node.comparator(current, value)) {
35572
- if (Transition) {
35573
- const TransitionRunning = Transition.running;
35574
- if (TransitionRunning || !isComp && Transition.sources.has(node)) {
35575
- Transition.sources.add(node);
35576
- node.tValue = value;
35577
- }
35578
- if (!TransitionRunning)
35579
- node.value = value;
35580
- } else
35581
- node.value = value;
35582
- if (node.observers && node.observers.length) {
35583
- runUpdates(() => {
35584
- for (let i = 0;i < node.observers.length; i += 1) {
35585
- const o = node.observers[i];
35586
- const TransitionRunning = Transition && Transition.running;
35587
- if (TransitionRunning && Transition.disposed.has(o))
35588
- continue;
35589
- if (TransitionRunning ? !o.tState : !o.state) {
35590
- if (o.pure)
35591
- Updates.push(o);
35592
- else
35593
- Effects.push(o);
35594
- if (o.observers)
35595
- markDownstream(o);
35596
- }
35597
- if (!TransitionRunning)
35598
- o.state = STALE;
35599
- else
35600
- o.tState = STALE;
35601
- }
35602
- if (Updates.length > 1e6) {
35603
- Updates = [];
35604
- if (IS_DEV)
35605
- ;
35606
- throw new Error;
35607
- }
35608
- }, false);
35967
+ selectCurrent() {
35968
+ const selected = this.getSelectedOption();
35969
+ if (selected) {
35970
+ this.emit("itemSelected", this.selectedIndex, selected);
35609
35971
  }
35610
35972
  }
35611
- return value;
35612
- }
35613
- function updateComputation(node) {
35614
- if (!node.fn)
35615
- return;
35616
- cleanNode(node);
35617
- const time = ExecCount;
35618
- runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
35619
- if (Transition && !Transition.running && Transition.sources.has(node)) {
35620
- queueMicrotask(() => {
35621
- runUpdates(() => {
35622
- Transition && (Transition.running = true);
35623
- Listener = Owner = node;
35624
- runComputation(node, node.tValue, time);
35625
- Listener = Owner = null;
35626
- }, false);
35627
- });
35973
+ setSelectedIndex(index) {
35974
+ if (index >= 0 && index < this._options.length) {
35975
+ this.selectedIndex = index;
35976
+ this.updateScrollOffset();
35977
+ this.requestRender();
35978
+ this.emit("selectionChanged", this.selectedIndex, this.getSelectedOption());
35979
+ }
35628
35980
  }
35629
- }
35630
- function runComputation(node, value, time) {
35631
- let nextValue;
35632
- const owner = Owner, listener = Listener;
35633
- Listener = Owner = node;
35634
- try {
35635
- nextValue = node.fn(value);
35636
- } catch (err) {
35637
- if (node.pure) {
35638
- if (Transition && Transition.running) {
35639
- node.tState = STALE;
35640
- node.tOwned && node.tOwned.forEach(cleanNode);
35641
- node.tOwned = undefined;
35642
- } else {
35643
- node.state = STALE;
35644
- node.owned && node.owned.forEach(cleanNode);
35645
- node.owned = null;
35646
- }
35981
+ updateScrollOffset() {
35982
+ const halfVisible = Math.floor(this.maxVisibleTabs / 2);
35983
+ const newScrollOffset = Math.max(0, Math.min(this.selectedIndex - halfVisible, this._options.length - this.maxVisibleTabs));
35984
+ if (newScrollOffset !== this.scrollOffset) {
35985
+ this.scrollOffset = newScrollOffset;
35986
+ this.requestRender();
35647
35987
  }
35648
- node.updatedAt = time + 1;
35649
- return handleError(err);
35650
- } finally {
35651
- Listener = listener;
35652
- Owner = owner;
35653
35988
  }
35654
- if (!node.updatedAt || node.updatedAt <= time) {
35655
- if (node.updatedAt != null && "observers" in node) {
35656
- writeSignal(node, nextValue, true);
35657
- } else if (Transition && Transition.running && node.pure) {
35658
- if (!Transition.sources.has(node))
35659
- node.value = nextValue;
35660
- Transition.sources.add(node);
35661
- node.tValue = nextValue;
35662
- } else
35663
- node.value = nextValue;
35664
- node.updatedAt = time;
35989
+ onResize(width, height) {
35990
+ this.maxVisibleTabs = Math.max(1, Math.floor(width / this._tabWidth));
35991
+ this.updateScrollOffset();
35992
+ this.requestRender();
35665
35993
  }
35666
- }
35667
- function createComputation(fn, init, pure, state = STALE, options) {
35668
- const c = {
35669
- fn,
35670
- state,
35671
- updatedAt: null,
35672
- owned: null,
35673
- sources: null,
35674
- sourceSlots: null,
35675
- cleanups: null,
35676
- value: init,
35677
- owner: Owner,
35678
- context: Owner ? Owner.context : null,
35679
- pure
35680
- };
35681
- if (Transition && Transition.running) {
35682
- c.state = 0;
35683
- c.tState = state;
35994
+ setTabWidth(tabWidth) {
35995
+ if (this._tabWidth === tabWidth)
35996
+ return;
35997
+ this._tabWidth = tabWidth;
35998
+ this.maxVisibleTabs = Math.max(1, Math.floor(this.width / this._tabWidth));
35999
+ this.updateScrollOffset();
36000
+ this.requestRender();
35684
36001
  }
35685
- if (Owner === null)
35686
- ;
35687
- else if (Owner !== UNOWNED) {
35688
- if (Transition && Transition.running && Owner.pure) {
35689
- if (!Owner.tOwned)
35690
- Owner.tOwned = [c];
35691
- else
35692
- Owner.tOwned.push(c);
35693
- } else {
35694
- if (!Owner.owned)
35695
- Owner.owned = [c];
35696
- else
35697
- Owner.owned.push(c);
35698
- }
36002
+ getTabWidth() {
36003
+ return this._tabWidth;
35699
36004
  }
35700
- if (ExternalSourceConfig && c.fn) {
35701
- const sourceFn = c.fn;
35702
- const [track, trigger] = createSignal(undefined, {
35703
- equals: false
35704
- });
35705
- const ordinary = ExternalSourceConfig.factory(sourceFn, trigger);
35706
- onCleanup(() => ordinary.dispose());
35707
- let inTransition;
35708
- const triggerInTransition = () => startTransition(trigger).then(() => {
35709
- if (inTransition) {
35710
- inTransition.dispose();
35711
- inTransition = undefined;
35712
- }
36005
+ handleKeyPress(key) {
36006
+ const bindingKey = getKeyBindingKey({
36007
+ name: key.name,
36008
+ ctrl: key.ctrl,
36009
+ shift: key.shift,
36010
+ meta: key.meta,
36011
+ super: key.super,
36012
+ action: "move-left"
35713
36013
  });
35714
- c.fn = (x2) => {
35715
- track();
35716
- if (Transition && Transition.running) {
35717
- if (!inTransition)
35718
- inTransition = ExternalSourceConfig.factory(sourceFn, triggerInTransition);
35719
- return inTransition.track(x2);
36014
+ const action = this._keyBindingsMap.get(bindingKey);
36015
+ if (action) {
36016
+ switch (action) {
36017
+ case "move-left":
36018
+ this.moveLeft();
36019
+ return true;
36020
+ case "move-right":
36021
+ this.moveRight();
36022
+ return true;
36023
+ case "select-current":
36024
+ this.selectCurrent();
36025
+ return true;
35720
36026
  }
35721
- return ordinary.track(x2);
35722
- };
36027
+ }
36028
+ return false;
35723
36029
  }
35724
- return c;
35725
- }
35726
- function runTop(node) {
35727
- const runningTransition = Transition && Transition.running;
35728
- if ((runningTransition ? node.tState : node.state) === 0)
35729
- return;
35730
- if ((runningTransition ? node.tState : node.state) === PENDING)
35731
- return lookUpstream(node);
35732
- if (node.suspense && untrack(node.suspense.inFallback))
35733
- return node.suspense.effects.push(node);
35734
- const ancestors = [node];
35735
- while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
35736
- if (runningTransition && Transition.disposed.has(node))
35737
- return;
35738
- if (runningTransition ? node.tState : node.state)
35739
- ancestors.push(node);
36030
+ get options() {
36031
+ return this._options;
35740
36032
  }
35741
- for (let i = ancestors.length - 1;i >= 0; i--) {
35742
- node = ancestors[i];
35743
- if (runningTransition) {
35744
- let top = node, prev = ancestors[i + 1];
35745
- while ((top = top.owner) && top !== prev) {
35746
- if (Transition.disposed.has(top))
35747
- return;
35748
- }
35749
- }
35750
- if ((runningTransition ? node.tState : node.state) === STALE) {
35751
- updateComputation(node);
35752
- } else if ((runningTransition ? node.tState : node.state) === PENDING) {
35753
- const updates = Updates;
35754
- Updates = null;
35755
- runUpdates(() => lookUpstream(node, ancestors[0]), false);
35756
- Updates = updates;
35757
- }
36033
+ set options(options) {
36034
+ this._options = options;
36035
+ this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, options.length - 1));
36036
+ this.updateScrollOffset();
36037
+ this.requestRender();
35758
36038
  }
35759
- }
35760
- function runUpdates(fn, init) {
35761
- if (Updates)
35762
- return fn();
35763
- let wait = false;
35764
- if (!init)
35765
- Updates = [];
35766
- if (Effects)
35767
- wait = true;
35768
- else
35769
- Effects = [];
35770
- ExecCount++;
35771
- try {
35772
- const res = fn();
35773
- completeUpdates(wait);
35774
- return res;
35775
- } catch (err) {
35776
- if (!wait)
35777
- Effects = null;
35778
- Updates = null;
35779
- handleError(err);
36039
+ set backgroundColor(color) {
36040
+ this._backgroundColor = parseColor(color);
36041
+ this.requestRender();
35780
36042
  }
35781
- }
35782
- function completeUpdates(wait) {
35783
- if (Updates) {
35784
- if (Scheduler && Transition && Transition.running)
35785
- scheduleQueue(Updates);
35786
- else
35787
- runQueue(Updates);
35788
- Updates = null;
36043
+ set textColor(color) {
36044
+ this._textColor = parseColor(color);
36045
+ this.requestRender();
35789
36046
  }
35790
- if (wait)
35791
- return;
35792
- let res;
35793
- if (Transition) {
35794
- if (!Transition.promises.size && !Transition.queue.size) {
35795
- const sources = Transition.sources;
35796
- const disposed = Transition.disposed;
35797
- Effects.push.apply(Effects, Transition.effects);
35798
- res = Transition.resolve;
35799
- for (const e2 of Effects) {
35800
- "tState" in e2 && (e2.state = e2.tState);
35801
- delete e2.tState;
35802
- }
35803
- Transition = null;
35804
- runUpdates(() => {
35805
- for (const d2 of disposed)
35806
- cleanNode(d2);
35807
- for (const v2 of sources) {
35808
- v2.value = v2.tValue;
35809
- if (v2.owned) {
35810
- for (let i = 0, len = v2.owned.length;i < len; i++)
35811
- cleanNode(v2.owned[i]);
35812
- }
35813
- if (v2.tOwned)
35814
- v2.owned = v2.tOwned;
35815
- delete v2.tValue;
35816
- delete v2.tOwned;
35817
- v2.tState = 0;
35818
- }
35819
- setTransPending(false);
35820
- }, false);
35821
- } else if (Transition.running) {
35822
- Transition.running = false;
35823
- Transition.effects.push.apply(Transition.effects, Effects);
35824
- Effects = null;
35825
- setTransPending(true);
35826
- return;
35827
- }
36047
+ set focusedBackgroundColor(color) {
36048
+ this._focusedBackgroundColor = parseColor(color);
36049
+ this.requestRender();
35828
36050
  }
35829
- const e = Effects;
35830
- Effects = null;
35831
- if (e.length)
35832
- runUpdates(() => runEffects(e), false);
35833
- if (res)
35834
- res();
35835
- }
35836
- function runQueue(queue) {
35837
- for (let i = 0;i < queue.length; i++)
35838
- runTop(queue[i]);
35839
- }
35840
- function scheduleQueue(queue) {
35841
- for (let i = 0;i < queue.length; i++) {
35842
- const item = queue[i];
35843
- const tasks = Transition.queue;
35844
- if (!tasks.has(item)) {
35845
- tasks.add(item);
35846
- Scheduler(() => {
35847
- tasks.delete(item);
35848
- runUpdates(() => {
35849
- Transition.running = true;
35850
- runTop(item);
35851
- }, false);
35852
- Transition && (Transition.running = false);
35853
- });
36051
+ set focusedTextColor(color) {
36052
+ this._focusedTextColor = parseColor(color);
36053
+ this.requestRender();
36054
+ }
36055
+ set selectedBackgroundColor(color) {
36056
+ this._selectedBackgroundColor = parseColor(color);
36057
+ this.requestRender();
36058
+ }
36059
+ set selectedTextColor(color) {
36060
+ this._selectedTextColor = parseColor(color);
36061
+ this.requestRender();
36062
+ }
36063
+ set selectedDescriptionColor(color) {
36064
+ this._selectedDescriptionColor = parseColor(color);
36065
+ this.requestRender();
36066
+ }
36067
+ get showDescription() {
36068
+ return this._showDescription;
36069
+ }
36070
+ set showDescription(show) {
36071
+ if (this._showDescription !== show) {
36072
+ this._showDescription = show;
36073
+ const newHeight = this.calculateDynamicHeight();
36074
+ this.height = newHeight;
36075
+ this.requestRender();
35854
36076
  }
35855
36077
  }
35856
- }
35857
- function runUserEffects(queue) {
35858
- let i, userLength = 0;
35859
- for (i = 0;i < queue.length; i++) {
35860
- const e = queue[i];
35861
- if (!e.user)
35862
- runTop(e);
35863
- else
35864
- queue[userLength++] = e;
36078
+ get showUnderline() {
36079
+ return this._showUnderline;
35865
36080
  }
35866
- if (sharedConfig.context) {
35867
- if (sharedConfig.count) {
35868
- sharedConfig.effects || (sharedConfig.effects = []);
35869
- sharedConfig.effects.push(...queue.slice(0, userLength));
35870
- return;
36081
+ set showUnderline(show) {
36082
+ if (this._showUnderline !== show) {
36083
+ this._showUnderline = show;
36084
+ const newHeight = this.calculateDynamicHeight();
36085
+ this.height = newHeight;
36086
+ this.requestRender();
35871
36087
  }
35872
- setHydrateContext();
35873
36088
  }
35874
- if (sharedConfig.effects && (sharedConfig.done || !sharedConfig.count)) {
35875
- queue = [...sharedConfig.effects, ...queue];
35876
- userLength += sharedConfig.effects.length;
35877
- delete sharedConfig.effects;
36089
+ get showScrollArrows() {
36090
+ return this._showScrollArrows;
35878
36091
  }
35879
- for (i = 0;i < userLength; i++)
35880
- runTop(queue[i]);
35881
- }
35882
- function lookUpstream(node, ignore) {
35883
- const runningTransition = Transition && Transition.running;
35884
- if (runningTransition)
35885
- node.tState = 0;
35886
- else
35887
- node.state = 0;
35888
- for (let i = 0;i < node.sources.length; i += 1) {
35889
- const source = node.sources[i];
35890
- if (source.sources) {
35891
- const state = runningTransition ? source.tState : source.state;
35892
- if (state === STALE) {
35893
- if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
35894
- runTop(source);
35895
- } else if (state === PENDING)
35896
- lookUpstream(source, ignore);
36092
+ set showScrollArrows(show) {
36093
+ if (this._showScrollArrows !== show) {
36094
+ this._showScrollArrows = show;
36095
+ this.requestRender();
35897
36096
  }
35898
36097
  }
36098
+ get wrapSelection() {
36099
+ return this._wrapSelection;
36100
+ }
36101
+ set wrapSelection(wrap) {
36102
+ this._wrapSelection = wrap;
36103
+ }
36104
+ get tabWidth() {
36105
+ return this._tabWidth;
36106
+ }
36107
+ set tabWidth(tabWidth) {
36108
+ if (this._tabWidth === tabWidth)
36109
+ return;
36110
+ this._tabWidth = tabWidth;
36111
+ this.maxVisibleTabs = Math.max(1, Math.floor(this.width / this._tabWidth));
36112
+ this.updateScrollOffset();
36113
+ this.requestRender();
36114
+ }
36115
+ set keyBindings(bindings) {
36116
+ this._keyBindings = bindings;
36117
+ const mergedBindings = mergeKeyBindings(defaultTabSelectKeybindings, bindings);
36118
+ this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
36119
+ }
36120
+ set keyAliasMap(aliases) {
36121
+ this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, aliases);
36122
+ const mergedBindings = mergeKeyBindings(defaultTabSelectKeybindings, this._keyBindings);
36123
+ this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
36124
+ }
35899
36125
  }
35900
- function markDownstream(node) {
35901
- const runningTransition = Transition && Transition.running;
35902
- for (let i = 0;i < node.observers.length; i += 1) {
35903
- const o = node.observers[i];
35904
- if (runningTransition ? !o.tState : !o.state) {
35905
- if (runningTransition)
35906
- o.tState = PENDING;
35907
- else
35908
- o.state = PENDING;
35909
- if (o.pure)
35910
- Updates.push(o);
35911
- else
35912
- Effects.push(o);
35913
- o.observers && markDownstream(o);
35914
- }
36126
+
36127
+ class TimeToFirstDrawRenderable extends Renderable {
36128
+ _runtimeMs = null;
36129
+ textColor;
36130
+ label;
36131
+ precision;
36132
+ constructor(ctx, options = {}) {
36133
+ super(ctx, {
36134
+ width: "100%",
36135
+ height: 1,
36136
+ flexShrink: 0,
36137
+ alignSelf: "center",
36138
+ ...options
36139
+ });
36140
+ this.textColor = parseColor(options.fg ?? "#AAAAAA");
36141
+ this.label = options.label ?? "Time to first draw";
36142
+ this.precision = this.normalizePrecision(options.precision ?? 2);
36143
+ }
36144
+ get runtimeMs() {
36145
+ return this._runtimeMs;
36146
+ }
36147
+ set fg(value) {
36148
+ this.textColor = parseColor(value);
36149
+ this.requestRender();
35915
36150
  }
35916
- }
35917
- function cleanNode(node) {
35918
- let i;
35919
- if (node.sources) {
35920
- while (node.sources.length) {
35921
- const source = node.sources.pop(), index = node.sourceSlots.pop(), obs = source.observers;
35922
- if (obs && obs.length) {
35923
- const n = obs.pop(), s = source.observerSlots.pop();
35924
- if (index < obs.length) {
35925
- n.sourceSlots[s] = index;
35926
- obs[index] = n;
35927
- source.observerSlots[index] = s;
35928
- }
35929
- }
35930
- }
36151
+ set color(value) {
36152
+ this.fg = value;
35931
36153
  }
35932
- if (node.tOwned) {
35933
- for (i = node.tOwned.length - 1;i >= 0; i--)
35934
- cleanNode(node.tOwned[i]);
35935
- delete node.tOwned;
36154
+ set textLabel(value) {
36155
+ if (value === this.label) {
36156
+ return;
36157
+ }
36158
+ this.label = value;
36159
+ this.requestRender();
35936
36160
  }
35937
- if (Transition && Transition.running && node.pure) {
35938
- reset(node, true);
35939
- } else if (node.owned) {
35940
- for (i = node.owned.length - 1;i >= 0; i--)
35941
- cleanNode(node.owned[i]);
35942
- node.owned = null;
36161
+ set decimals(value) {
36162
+ const nextPrecision = this.normalizePrecision(value);
36163
+ if (nextPrecision === this.precision) {
36164
+ return;
36165
+ }
36166
+ this.precision = nextPrecision;
36167
+ this.requestRender();
35943
36168
  }
35944
- if (node.cleanups) {
35945
- for (i = node.cleanups.length - 1;i >= 0; i--)
35946
- node.cleanups[i]();
35947
- node.cleanups = null;
36169
+ reset() {
36170
+ this._runtimeMs = null;
36171
+ this.requestRender();
35948
36172
  }
35949
- if (Transition && Transition.running)
35950
- node.tState = 0;
35951
- else
35952
- node.state = 0;
35953
- }
35954
- function reset(node, top) {
35955
- if (!top) {
35956
- node.tState = 0;
35957
- Transition.disposed.add(node);
36173
+ renderSelf(buffer) {
36174
+ if (this._runtimeMs === null) {
36175
+ this._runtimeMs = performance.now();
36176
+ }
36177
+ const content = `${this.label}: ${this._runtimeMs.toFixed(this.precision)}ms`;
36178
+ const maxWidth = Math.max(this.width, 1);
36179
+ const visibleContent = content.length > maxWidth ? content.slice(0, maxWidth) : content;
36180
+ const centeredX = this.x + Math.max(0, Math.floor((maxWidth - visibleContent.length) / 2));
36181
+ buffer.drawText(visibleContent, centeredX, this.y, this.textColor);
35958
36182
  }
35959
- if (node.owned) {
35960
- for (let i = 0;i < node.owned.length; i++)
35961
- reset(node.owned[i]);
36183
+ normalizePrecision(value) {
36184
+ if (!Number.isFinite(value)) {
36185
+ return 2;
36186
+ }
36187
+ return Math.max(0, Math.floor(value));
35962
36188
  }
35963
36189
  }
35964
- function castError(err) {
35965
- if (err instanceof Error)
35966
- return err;
35967
- return new Error(typeof err === "string" ? err : "Unknown error", {
35968
- cause: err
35969
- });
35970
- }
35971
- function runErrors(err, fns, owner) {
35972
- try {
35973
- for (const f of fns)
35974
- f(err);
35975
- } catch (e) {
35976
- handleError(e, owner && owner.owner || null);
36190
+
36191
+ // node_modules/@opentui/solid/node_modules/@opentui/core/testing.js
36192
+ var decoder2 = new TextDecoder;
36193
+ class TestRecorder {
36194
+ renderer;
36195
+ frames = [];
36196
+ recording = false;
36197
+ frameNumber = 0;
36198
+ startTime = 0;
36199
+ originalRenderNative;
36200
+ decoder = new TextDecoder;
36201
+ recordBuffers;
36202
+ now;
36203
+ constructor(renderer, options) {
36204
+ this.renderer = renderer;
36205
+ this.recordBuffers = options?.recordBuffers || {};
36206
+ this.now = options?.now ?? (() => performance.now());
35977
36207
  }
35978
- }
35979
- function handleError(err, owner = Owner) {
35980
- const fns = ERROR && owner && owner.context && owner.context[ERROR];
35981
- const error = castError(err);
35982
- if (!fns)
35983
- throw error;
35984
- if (Effects)
35985
- Effects.push({
35986
- fn() {
35987
- runErrors(error, fns, owner);
35988
- },
35989
- state: STALE
35990
- });
35991
- else
35992
- runErrors(error, fns, owner);
35993
- }
35994
- function resolveChildren(children2) {
35995
- if (typeof children2 === "function" && !children2.length)
35996
- return resolveChildren(children2());
35997
- if (Array.isArray(children2)) {
35998
- const results = [];
35999
- for (let i = 0;i < children2.length; i++) {
36000
- const result = resolveChildren(children2[i]);
36001
- Array.isArray(result) ? results.push.apply(results, result) : results.push(result);
36208
+ rec() {
36209
+ if (this.recording) {
36210
+ return;
36002
36211
  }
36003
- return results;
36212
+ this.recording = true;
36213
+ this.frames = [];
36214
+ this.frameNumber = 0;
36215
+ this.startTime = this.now();
36216
+ this.originalRenderNative = this.renderer["renderNative"].bind(this.renderer);
36217
+ this.renderer["renderNative"] = () => {
36218
+ this.originalRenderNative();
36219
+ this.captureFrame();
36220
+ };
36004
36221
  }
36005
- return children2;
36006
- }
36007
- function createProvider(id, options) {
36008
- return function provider(props) {
36009
- let res;
36010
- createRenderEffect(() => res = untrack(() => {
36011
- Owner.context = {
36012
- ...Owner.context,
36013
- [id]: props.value
36014
- };
36015
- return children(() => props.children);
36016
- }), undefined);
36017
- return res;
36018
- };
36019
- }
36020
- var FALLBACK = Symbol("fallback");
36021
- function dispose(d2) {
36022
- for (let i = 0;i < d2.length; i++)
36023
- d2[i]();
36024
- }
36025
- function mapArray(list, mapFn, options = {}) {
36026
- let items = [], mapped = [], disposers = [], len = 0, indexes = mapFn.length > 1 ? [] : null;
36027
- onCleanup(() => dispose(disposers));
36028
- return () => {
36029
- let newItems = list() || [], newLen = newItems.length, i, j2;
36030
- newItems[$TRACK];
36031
- return untrack(() => {
36032
- let newIndices, newIndicesNext, temp, tempdisposers, tempIndexes, start, end, newEnd, item;
36033
- if (newLen === 0) {
36034
- if (len !== 0) {
36035
- dispose(disposers);
36036
- disposers = [];
36037
- items = [];
36038
- mapped = [];
36039
- len = 0;
36040
- indexes && (indexes = []);
36041
- }
36042
- if (options.fallback) {
36043
- items = [FALLBACK];
36044
- mapped[0] = createRoot((disposer) => {
36045
- disposers[0] = disposer;
36046
- return options.fallback();
36047
- });
36048
- len = 1;
36049
- }
36050
- } else if (len === 0) {
36051
- mapped = new Array(newLen);
36052
- for (j2 = 0;j2 < newLen; j2++) {
36053
- items[j2] = newItems[j2];
36054
- mapped[j2] = createRoot(mapper);
36055
- }
36056
- len = newLen;
36057
- } else {
36058
- temp = new Array(newLen);
36059
- tempdisposers = new Array(newLen);
36060
- indexes && (tempIndexes = new Array(newLen));
36061
- for (start = 0, end = Math.min(len, newLen);start < end && items[start] === newItems[start]; start++)
36062
- ;
36063
- for (end = len - 1, newEnd = newLen - 1;end >= start && newEnd >= start && items[end] === newItems[newEnd]; end--, newEnd--) {
36064
- temp[newEnd] = mapped[end];
36065
- tempdisposers[newEnd] = disposers[end];
36066
- indexes && (tempIndexes[newEnd] = indexes[end]);
36067
- }
36068
- newIndices = new Map;
36069
- newIndicesNext = new Array(newEnd + 1);
36070
- for (j2 = newEnd;j2 >= start; j2--) {
36071
- item = newItems[j2];
36072
- i = newIndices.get(item);
36073
- newIndicesNext[j2] = i === undefined ? -1 : i;
36074
- newIndices.set(item, j2);
36075
- }
36076
- for (i = start;i <= end; i++) {
36077
- item = items[i];
36078
- j2 = newIndices.get(item);
36079
- if (j2 !== undefined && j2 !== -1) {
36080
- temp[j2] = mapped[i];
36081
- tempdisposers[j2] = disposers[i];
36082
- indexes && (tempIndexes[j2] = indexes[i]);
36083
- j2 = newIndicesNext[j2];
36084
- newIndices.set(item, j2);
36085
- } else
36086
- disposers[i]();
36087
- }
36088
- for (j2 = start;j2 < newLen; j2++) {
36089
- if (j2 in temp) {
36090
- mapped[j2] = temp[j2];
36091
- disposers[j2] = tempdisposers[j2];
36092
- if (indexes) {
36093
- indexes[j2] = tempIndexes[j2];
36094
- indexes[j2](j2);
36095
- }
36096
- } else
36097
- mapped[j2] = createRoot(mapper);
36098
- }
36099
- mapped = mapped.slice(0, len = newLen);
36100
- items = newItems.slice(0);
36101
- }
36102
- return mapped;
36103
- });
36104
- function mapper(disposer) {
36105
- disposers[j2] = disposer;
36106
- if (indexes) {
36107
- const [s, set] = createSignal(j2);
36108
- indexes[j2] = set;
36109
- return mapFn(newItems[j2], s);
36110
- }
36111
- return mapFn(newItems[j2]);
36222
+ stop() {
36223
+ if (!this.recording) {
36224
+ return;
36112
36225
  }
36113
- };
36114
- }
36115
- var hydrationEnabled = false;
36116
- function createComponent(Comp, props) {
36117
- if (hydrationEnabled) {
36118
- if (sharedConfig.context) {
36119
- const c = sharedConfig.context;
36120
- setHydrateContext(nextHydrateContext());
36121
- const r = untrack(() => Comp(props || {}));
36122
- setHydrateContext(c);
36123
- return r;
36226
+ this.recording = false;
36227
+ if (this.originalRenderNative) {
36228
+ this.renderer["renderNative"] = this.originalRenderNative;
36229
+ this.originalRenderNative = undefined;
36124
36230
  }
36125
36231
  }
36126
- return untrack(() => Comp(props || {}));
36127
- }
36128
- function trueFn() {
36129
- return true;
36130
- }
36131
- var propTraps = {
36132
- get(_2, property, receiver) {
36133
- if (property === $PROXY)
36134
- return receiver;
36135
- return _2.get(property);
36136
- },
36137
- has(_2, property) {
36138
- if (property === $PROXY)
36139
- return true;
36140
- return _2.has(property);
36141
- },
36142
- set: trueFn,
36143
- deleteProperty: trueFn,
36144
- getOwnPropertyDescriptor(_2, property) {
36145
- return {
36146
- configurable: true,
36147
- enumerable: true,
36148
- get() {
36149
- return _2.get(property);
36150
- },
36151
- set: trueFn,
36152
- deleteProperty: trueFn
36153
- };
36154
- },
36155
- ownKeys(_2) {
36156
- return _2.keys();
36232
+ get recordedFrames() {
36233
+ return [...this.frames];
36157
36234
  }
36158
- };
36159
- function resolveSource(s) {
36160
- return !(s = typeof s === "function" ? s() : s) ? {} : s;
36161
- }
36162
- function resolveSources() {
36163
- for (let i = 0, length = this.length;i < length; ++i) {
36164
- const v2 = this[i]();
36165
- if (v2 !== undefined)
36166
- return v2;
36235
+ clear() {
36236
+ this.frames = [];
36237
+ this.frameNumber = 0;
36167
36238
  }
36168
- }
36169
- function mergeProps(...sources) {
36170
- let proxy = false;
36171
- for (let i = 0;i < sources.length; i++) {
36172
- const s = sources[i];
36173
- proxy = proxy || !!s && $PROXY in s;
36174
- sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
36239
+ get isRecording() {
36240
+ return this.recording;
36175
36241
  }
36176
- if (SUPPORTS_PROXY && proxy) {
36177
- return new Proxy({
36178
- get(property) {
36179
- for (let i = sources.length - 1;i >= 0; i--) {
36180
- const v2 = resolveSource(sources[i])[property];
36181
- if (v2 !== undefined)
36182
- return v2;
36183
- }
36184
- },
36185
- has(property) {
36186
- for (let i = sources.length - 1;i >= 0; i--) {
36187
- if (property in resolveSource(sources[i]))
36188
- return true;
36189
- }
36190
- return false;
36191
- },
36192
- keys() {
36193
- const keys = [];
36194
- for (let i = 0;i < sources.length; i++)
36195
- keys.push(...Object.keys(resolveSource(sources[i])));
36196
- return [...new Set(keys)];
36242
+ captureFrame() {
36243
+ const currentBuffer = this.renderer.currentRenderBuffer;
36244
+ const frameBytes = currentBuffer.getRealCharBytes(true);
36245
+ const frame = this.decoder.decode(frameBytes);
36246
+ const recordedFrame = {
36247
+ frame,
36248
+ timestamp: this.now() - this.startTime,
36249
+ frameNumber: this.frameNumber++
36250
+ };
36251
+ if (this.recordBuffers.fg || this.recordBuffers.bg || this.recordBuffers.attributes) {
36252
+ const buffers = currentBuffer.buffers;
36253
+ recordedFrame.buffers = {};
36254
+ if (this.recordBuffers.fg) {
36255
+ recordedFrame.buffers.fg = new Float32Array(buffers.fg);
36197
36256
  }
36198
- }, propTraps);
36199
- }
36200
- const sourcesMap = {};
36201
- const defined = Object.create(null);
36202
- for (let i = sources.length - 1;i >= 0; i--) {
36203
- const source = sources[i];
36204
- if (!source)
36205
- continue;
36206
- const sourceKeys = Object.getOwnPropertyNames(source);
36207
- for (let i2 = sourceKeys.length - 1;i2 >= 0; i2--) {
36208
- const key = sourceKeys[i2];
36209
- if (key === "__proto__" || key === "constructor")
36210
- continue;
36211
- const desc = Object.getOwnPropertyDescriptor(source, key);
36212
- if (!defined[key]) {
36213
- defined[key] = desc.get ? {
36214
- enumerable: true,
36215
- configurable: true,
36216
- get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
36217
- } : desc.value !== undefined ? desc : undefined;
36218
- } else {
36219
- const sources2 = sourcesMap[key];
36220
- if (sources2) {
36221
- if (desc.get)
36222
- sources2.push(desc.get.bind(source));
36223
- else if (desc.value !== undefined)
36224
- sources2.push(() => desc.value);
36225
- }
36257
+ if (this.recordBuffers.bg) {
36258
+ recordedFrame.buffers.bg = new Float32Array(buffers.bg);
36259
+ }
36260
+ if (this.recordBuffers.attributes) {
36261
+ recordedFrame.buffers.attributes = new Uint8Array(buffers.attributes);
36226
36262
  }
36227
36263
  }
36264
+ this.frames.push(recordedFrame);
36228
36265
  }
36229
- const target = {};
36230
- const definedKeys = Object.keys(defined);
36231
- for (let i = definedKeys.length - 1;i >= 0; i--) {
36232
- const key = definedKeys[i], desc = defined[key];
36233
- if (desc && desc.get)
36234
- Object.defineProperty(target, key, desc);
36235
- else
36236
- target[key] = desc ? desc.value : undefined;
36237
- }
36238
- return target;
36239
- }
36240
- var narrowedError = (name) => `Stale read from <${name}>.`;
36241
- function For(props) {
36242
- const fallback = "fallback" in props && {
36243
- fallback: () => props.fallback
36244
- };
36245
- return createMemo(mapArray(() => props.each, props.children, fallback || undefined));
36246
- }
36247
- function Show(props) {
36248
- const keyed = props.keyed;
36249
- const conditionValue = createMemo(() => props.when, undefined, undefined);
36250
- const condition = keyed ? conditionValue : createMemo(conditionValue, undefined, {
36251
- equals: (a, b2) => !a === !b2
36252
- });
36253
- return createMemo(() => {
36254
- const c = condition();
36255
- if (c) {
36256
- const child = props.children;
36257
- const fn = typeof child === "function" && child.length > 0;
36258
- return fn ? untrack(() => child(keyed ? c : () => {
36259
- if (!untrack(condition))
36260
- throw narrowedError("Show");
36261
- return conditionValue();
36262
- })) : child;
36263
- }
36264
- return props.fallback;
36265
- }, undefined, undefined);
36266
36266
  }
36267
36267
 
36268
36268
  // node_modules/entities/dist/esm/decode-codepoint.js
@@ -39882,6 +39882,22 @@ class AgentQueueManager {
39882
39882
  if (queue)
39883
39883
  queue.controller = controller;
39884
39884
  }
39885
+ cancelled = new Set;
39886
+ abortAgent(agentName) {
39887
+ const queue = this.queues.get(agentName);
39888
+ if (!queue)
39889
+ return;
39890
+ this.cancelled.add(agentName);
39891
+ queue.controller?.abort();
39892
+ queue.pending = [];
39893
+ queue.processing = false;
39894
+ }
39895
+ wasCancelled(agentName) {
39896
+ return this.cancelled.has(agentName);
39897
+ }
39898
+ clearCancelled(agentName) {
39899
+ this.cancelled.delete(agentName);
39900
+ }
39885
39901
  abortAll() {
39886
39902
  for (const q2 of this.queues.values()) {
39887
39903
  q2.controller?.abort();
@@ -40041,6 +40057,7 @@ class Orchestrator {
40041
40057
  const agent = this.agents.get(agentName);
40042
40058
  if (!agent)
40043
40059
  return;
40060
+ this.queueManager.clearCancelled(agentName);
40044
40061
  this.queueManager.setProcessing(agentName, true);
40045
40062
  this.onActivity(agentName, "thinking");
40046
40063
  const historyMaxId = this.messageId;
@@ -40055,6 +40072,12 @@ class Orchestrator {
40055
40072
  }
40056
40073
  const inputMessages = this.buildInputForAgent(agentName, unseen);
40057
40074
  const responseText = await this.streamWithTimeout(agentName, agent, inputMessages, this.timeoutFor(agentName));
40075
+ if (this.queueManager.wasCancelled(agentName)) {
40076
+ this.lastSeenByAgent.set(agentName, historyMaxId);
40077
+ this.queueManager.setProcessing(agentName, false);
40078
+ this.onActivity(agentName, "idle");
40079
+ return;
40080
+ }
40058
40081
  const response = {
40059
40082
  id: ++this.messageId,
40060
40083
  from: agentName.toUpperCase(),
@@ -40254,6 +40277,12 @@ class Orchestrator {
40254
40277
  console.error("[manifest] load failed (agents start fresh):", err);
40255
40278
  }
40256
40279
  }
40280
+ cancelAgents(names) {
40281
+ for (const name of names) {
40282
+ this.queueManager.abortAgent(name);
40283
+ this.onActivity(name, "idle");
40284
+ }
40285
+ }
40257
40286
  async abortAll() {
40258
40287
  this.queueManager.abortAll();
40259
40288
  await this.saveManifest();
@@ -42687,6 +42716,178 @@ function InfoPanel(props) {
42687
42716
  })();
42688
42717
  }
42689
42718
 
42719
+ // src/ui/CancelPanel.tsx
42720
+ function CancelPanel(props) {
42721
+ const items = () => props.activeAgents;
42722
+ const [cursor, setCursor] = createSignal(0);
42723
+ const [selected, setSelected] = createSignal(new Set);
42724
+ createEffect(() => {
42725
+ if (props.activeAgents.length === 0) {
42726
+ props.onClose();
42727
+ }
42728
+ });
42729
+ useKeyboard((key) => {
42730
+ if (key.name === "escape") {
42731
+ props.onClose();
42732
+ return;
42733
+ }
42734
+ if (key.name === "return") {
42735
+ const sel = selected();
42736
+ if (sel.size === 0) {
42737
+ props.onClose();
42738
+ return;
42739
+ }
42740
+ const names = [...sel];
42741
+ props.onCancel(names);
42742
+ return;
42743
+ }
42744
+ if (key.name === "up") {
42745
+ setCursor((c) => Math.max(0, c - 1));
42746
+ return;
42747
+ }
42748
+ if (key.name === "down") {
42749
+ setCursor((c) => Math.min(items().length - 1, c + 1));
42750
+ return;
42751
+ }
42752
+ if (key.name === "space" || key.sequence === " ") {
42753
+ const item = items()[cursor()];
42754
+ if (!item)
42755
+ return;
42756
+ setSelected((prev) => {
42757
+ const next = new Set(prev);
42758
+ if (next.has(item)) {
42759
+ next.delete(item);
42760
+ } else {
42761
+ next.add(item);
42762
+ }
42763
+ return next;
42764
+ });
42765
+ return;
42766
+ }
42767
+ });
42768
+ const totalW = 40;
42769
+ return (() => {
42770
+ var _el$ = createElement("box"), _el$2 = createElement("box"), _el$3 = createElement("box"), _el$4 = createElement("text"), _el$5 = createElement("strong"), _el$7 = createElement("text"), _el$9 = createElement("text"), _el$1 = createElement("text"), _el$10 = createElement("span"), _el$12 = createElement("span"), _el$14 = createElement("span"), _el$16 = createElement("span"), _el$18 = createElement("span"), _el$20 = createElement("span");
42771
+ insertNode(_el$, _el$2);
42772
+ setProp(_el$, "position", "absolute");
42773
+ setProp(_el$, "width", "100%");
42774
+ setProp(_el$, "height", "100%");
42775
+ setProp(_el$, "justifyContent", "center");
42776
+ setProp(_el$, "alignItems", "center");
42777
+ setProp(_el$, "zIndex", 10);
42778
+ insertNode(_el$2, _el$3);
42779
+ setProp(_el$2, "border", true);
42780
+ setProp(_el$2, "borderStyle", "rounded");
42781
+ setProp(_el$2, "paddingX", 3);
42782
+ setProp(_el$2, "paddingY", 1);
42783
+ insertNode(_el$3, _el$4);
42784
+ insertNode(_el$3, _el$7);
42785
+ insertNode(_el$3, _el$9);
42786
+ insertNode(_el$3, _el$1);
42787
+ setProp(_el$3, "flexDirection", "column");
42788
+ insertNode(_el$4, _el$5);
42789
+ setProp(_el$4, "alignSelf", "center");
42790
+ insertNode(_el$5, createTextNode(`Cancel Agents`));
42791
+ insertNode(_el$7, createTextNode(`\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`));
42792
+ setProp(_el$7, "marginTop", 1);
42793
+ insert(_el$3, createComponent2(For, {
42794
+ get each() {
42795
+ return items();
42796
+ },
42797
+ children: (item, i) => {
42798
+ const isSelected = () => selected().has(item);
42799
+ const isCursor = () => cursor() === i();
42800
+ const bullet = () => isSelected() ? "\u25A0" : "\u25A1";
42801
+ const bulletColor = () => isSelected() ? COLORS.error : COLORS.textDim;
42802
+ const labelColor = () => isCursor() ? COLORS.textPrimary : COLORS.textMuted;
42803
+ const bgColor = () => isCursor() ? COLORS.bgFocus : undefined;
42804
+ return (() => {
42805
+ var _el$22 = createElement("text"), _el$23 = createElement("span"), _el$24 = createTextNode(` `), _el$25 = createTextNode(` `), _el$26 = createElement("span");
42806
+ insertNode(_el$22, _el$23);
42807
+ insertNode(_el$22, _el$26);
42808
+ setProp(_el$22, "selectable", false);
42809
+ insertNode(_el$23, _el$24);
42810
+ insertNode(_el$23, _el$25);
42811
+ insert(_el$23, bullet, _el$25);
42812
+ insert(_el$26, item);
42813
+ effect((_p$) => {
42814
+ var _v$10 = bgColor(), _v$11 = {
42815
+ fg: bulletColor()
42816
+ }, _v$12 = {
42817
+ fg: labelColor()
42818
+ };
42819
+ _v$10 !== _p$.e && (_p$.e = setProp(_el$22, "bg", _v$10, _p$.e));
42820
+ _v$11 !== _p$.t && (_p$.t = setProp(_el$23, "style", _v$11, _p$.t));
42821
+ _v$12 !== _p$.a && (_p$.a = setProp(_el$26, "style", _v$12, _p$.a));
42822
+ return _p$;
42823
+ }, {
42824
+ e: undefined,
42825
+ t: undefined,
42826
+ a: undefined
42827
+ });
42828
+ return _el$22;
42829
+ })();
42830
+ }
42831
+ }), _el$9);
42832
+ insertNode(_el$9, createTextNode(`\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`));
42833
+ setProp(_el$9, "marginTop", 1);
42834
+ insertNode(_el$1, _el$10);
42835
+ insertNode(_el$1, _el$12);
42836
+ insertNode(_el$1, _el$14);
42837
+ insertNode(_el$1, _el$16);
42838
+ insertNode(_el$1, _el$18);
42839
+ insertNode(_el$1, _el$20);
42840
+ setProp(_el$1, "marginTop", 1);
42841
+ setProp(_el$1, "alignSelf", "center");
42842
+ insertNode(_el$10, createTextNode(`Space`));
42843
+ insertNode(_el$12, createTextNode(` toggle `));
42844
+ insertNode(_el$14, createTextNode(`Enter`));
42845
+ insertNode(_el$16, createTextNode(` kill `));
42846
+ insertNode(_el$18, createTextNode(`Esc`));
42847
+ insertNode(_el$20, createTextNode(` back`));
42848
+ effect((_p$) => {
42849
+ var _v$ = COLORS.error, _v$2 = COLORS.bgPanel, _v$3 = COLORS.error, _v$4 = COLORS.borderStrong, _v$5 = COLORS.borderStrong, _v$6 = {
42850
+ fg: COLORS.textFaint
42851
+ }, _v$7 = {
42852
+ fg: COLORS.textDim
42853
+ }, _v$8 = {
42854
+ fg: COLORS.error
42855
+ }, _v$9 = {
42856
+ fg: COLORS.textDim
42857
+ }, _v$0 = {
42858
+ fg: COLORS.textFaint
42859
+ }, _v$1 = {
42860
+ fg: COLORS.textDim
42861
+ };
42862
+ _v$ !== _p$.e && (_p$.e = setProp(_el$2, "borderColor", _v$, _p$.e));
42863
+ _v$2 !== _p$.t && (_p$.t = setProp(_el$2, "backgroundColor", _v$2, _p$.t));
42864
+ _v$3 !== _p$.a && (_p$.a = setProp(_el$4, "fg", _v$3, _p$.a));
42865
+ _v$4 !== _p$.o && (_p$.o = setProp(_el$7, "fg", _v$4, _p$.o));
42866
+ _v$5 !== _p$.i && (_p$.i = setProp(_el$9, "fg", _v$5, _p$.i));
42867
+ _v$6 !== _p$.n && (_p$.n = setProp(_el$10, "style", _v$6, _p$.n));
42868
+ _v$7 !== _p$.s && (_p$.s = setProp(_el$12, "style", _v$7, _p$.s));
42869
+ _v$8 !== _p$.h && (_p$.h = setProp(_el$14, "style", _v$8, _p$.h));
42870
+ _v$9 !== _p$.r && (_p$.r = setProp(_el$16, "style", _v$9, _p$.r));
42871
+ _v$0 !== _p$.d && (_p$.d = setProp(_el$18, "style", _v$0, _p$.d));
42872
+ _v$1 !== _p$.l && (_p$.l = setProp(_el$20, "style", _v$1, _p$.l));
42873
+ return _p$;
42874
+ }, {
42875
+ e: undefined,
42876
+ t: undefined,
42877
+ a: undefined,
42878
+ o: undefined,
42879
+ i: undefined,
42880
+ n: undefined,
42881
+ s: undefined,
42882
+ h: undefined,
42883
+ r: undefined,
42884
+ d: undefined,
42885
+ l: undefined
42886
+ });
42887
+ return _el$;
42888
+ })();
42889
+ }
42890
+
42690
42891
  // src/ui/App.tsx
42691
42892
  function copyToClipboard(text) {
42692
42893
  const proc = spawn4("pbcopy", [], {
@@ -42727,6 +42928,7 @@ function App(props) {
42727
42928
  const [freshConfig, setFreshConfig] = createSignal(props.config);
42728
42929
  const [showAgents, setShowAgents] = createSignal(false);
42729
42930
  const [showInfo, setShowInfo] = createSignal(false);
42931
+ const [showCancel, setShowCancel] = createSignal(false);
42730
42932
  const resumeSession = async (sessionId) => {
42731
42933
  try {
42732
42934
  const restored = await props.orchestrator.loadTranscript(sessionId);
@@ -42775,8 +42977,18 @@ function App(props) {
42775
42977
  setShowAgents((v2) => !v2);
42776
42978
  return;
42777
42979
  }
42778
- if (showAgents())
42980
+ if (showAgents() || showCancel() || showInfo())
42981
+ return;
42982
+ if (key.name === "escape") {
42983
+ const active = agents.filter((a) => {
42984
+ const state = agentStates().get(a.name);
42985
+ return state && state !== "idle" && state !== "error";
42986
+ }).map((a) => a.name);
42987
+ if (active.length > 0) {
42988
+ setShowCancel(true);
42989
+ }
42779
42990
  return;
42991
+ }
42780
42992
  if (key.ctrl && key.name === "c") {
42781
42993
  if (!copySelection(renderer)) {
42782
42994
  gracefulExit();
@@ -42933,10 +43145,10 @@ ${lines.join(`
42933
43145
  humanName,
42934
43146
  onSubmit: handleSubmit,
42935
43147
  get disabled() {
42936
- return showAgents() || showInfo();
43148
+ return showAgents() || showInfo() || showCancel();
42937
43149
  },
42938
43150
  get disabledMessage() {
42939
- return showAgents() ? "" : undefined;
43151
+ return showAgents() || showCancel() ? "" : undefined;
42940
43152
  }
42941
43153
  }), null);
42942
43154
  insert(_el$, (() => {
@@ -42959,6 +43171,24 @@ ${lines.join(`
42959
43171
  onClose: () => setShowInfo(false)
42960
43172
  });
42961
43173
  })(), null);
43174
+ insert(_el$, (() => {
43175
+ var _c$3 = memo2(() => !!showCancel());
43176
+ return () => _c$3() && createComponent2(CancelPanel, {
43177
+ get activeAgents() {
43178
+ return agents.filter((a) => {
43179
+ const state = agentStates().get(a.name);
43180
+ return state && state !== "idle" && state !== "error";
43181
+ }).map((a) => a.name);
43182
+ },
43183
+ onCancel: (names) => {
43184
+ props.orchestrator.cancelAgents(names);
43185
+ const label = names.length === agents.length ? "all agents" : names.join(", ");
43186
+ addSystemMessage(`Cancelled ${label}`);
43187
+ setShowCancel(false);
43188
+ },
43189
+ onClose: () => setShowCancel(false)
43190
+ });
43191
+ })(), null);
42962
43192
  effect((_$p) => setProp(_el$3, "fg", COLORS.primary, _$p));
42963
43193
  return _el$;
42964
43194
  }
@@ -42978,17 +43208,43 @@ async function main2() {
42978
43208
  };
42979
43209
  const hasConfig = await configExists();
42980
43210
  if (!hasConfig) {
42981
- await render(() => ConfigWizard({
42982
- isFirstRun: true,
42983
- onComplete: async () => {
42984
- await bootApp(appRoot, rendererConfig, resumeSessionId);
43211
+ const [boot, setBoot] = createSignal(null);
43212
+ await render(() => Show({
43213
+ get when() {
43214
+ return boot();
43215
+ },
43216
+ get fallback() {
43217
+ return ConfigWizard({
43218
+ isFirstRun: true,
43219
+ onComplete: async () => {
43220
+ const result = await buildOrchestrator(appRoot, resumeSessionId);
43221
+ setBoot(result);
43222
+ }
43223
+ });
43224
+ },
43225
+ get children() {
43226
+ const b2 = boot();
43227
+ if (!b2)
43228
+ return null;
43229
+ return App({
43230
+ orchestrator: b2.orchestrator,
43231
+ config: b2.config,
43232
+ configPath: b2.configPath,
43233
+ resumeSessionId
43234
+ });
42985
43235
  }
42986
43236
  }), rendererConfig);
42987
43237
  } else {
42988
- await bootApp(appRoot, rendererConfig, resumeSessionId);
43238
+ const result = await buildOrchestrator(appRoot, resumeSessionId);
43239
+ await render(() => App({
43240
+ orchestrator: result.orchestrator,
43241
+ config: result.config,
43242
+ configPath: result.configPath,
43243
+ resumeSessionId
43244
+ }), rendererConfig);
42989
43245
  }
42990
43246
  }
42991
- async function bootApp(appRoot, rendererConfig, resumeSessionId) {
43247
+ async function buildOrchestrator(appRoot, resumeSessionId) {
42992
43248
  const configPath = await resolveConfigPath(appRoot);
42993
43249
  const config = await loadConfig2(configPath);
42994
43250
  const humanName = config.humanName?.trim() || "USER";
@@ -43079,7 +43335,7 @@ ${mySkills.map((s) => `- ${s}`).join(`
43079
43335
  const defaultTimeout = typeof config.timeout === "number" && config.timeout > 0 ? config.timeout * 1000 : 600000;
43080
43336
  const agentTimeouts = Object.fromEntries(activeAgents.filter((agent) => typeof agent.timeout === "number" && agent.timeout > 0).map((agent) => [agent.name, agent.timeout * 1000]));
43081
43337
  const orchestrator = new Orchestrator(adapters, humanName, Object.fromEntries(activeAgents.map((agent) => [agent.name, agent.tag?.trim() || toTag(agent.name)])), humanTag, defaultTimeout, agentTimeouts, { reminderInterval: config.reminderInterval, maxAutoHops });
43082
- await render(() => App({ orchestrator, config, configPath, resumeSessionId }), rendererConfig);
43338
+ return { orchestrator, config, configPath };
43083
43339
  }
43084
43340
  function resolveMaxAutoHops(value) {
43085
43341
  if (typeof value === "number" && value === 0) {