@adecore/agents-react 0.49.4 → 0.49.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/chat/chat-references.d.ts +13 -1
  2. package/dist/chat/chat-references.js +13 -2
  3. package/dist/chat/ui/ReferenceChip.js +98 -77
  4. package/dist/chat/ui/ReferenceTrail.d.ts +11 -0
  5. package/dist/chat/ui/ReferenceTrail.js +65 -0
  6. package/dist/chat/ui/RunSettings.js +2 -2
  7. package/dist/chat/ui/SessionLine.js +1 -1
  8. package/dist/chat/ui/chips.d.ts +1 -0
  9. package/dist/chat/ui/chips.js +2 -0
  10. package/dist/chat/ui/composer/ComposerMenu.js +28 -22
  11. package/dist/chat/ui/composer/chips.d.ts +3 -2
  12. package/dist/chat/ui/composer/chips.js +21 -9
  13. package/dist/chat/ui/composer/use-prompt-menus.d.ts +1 -0
  14. package/dist/chat/ui/composer/use-prompt-menus.js +115 -121
  15. package/dist/chat/ui/reference-icons.js +3 -1
  16. package/dist/chat/ui/rows/MessageRows.js +21 -8
  17. package/dist/locales/en/agent-chat.d.ts +3 -0
  18. package/dist/locales/en/agent-chat.js +4 -1
  19. package/dist/locales/en/agent-usage.d.ts +0 -1
  20. package/dist/locales/en/agent-usage.js +0 -1
  21. package/dist/locales/nl/agent-chat.d.ts +3 -0
  22. package/dist/locales/nl/agent-chat.js +4 -1
  23. package/dist/locales/nl/agent-usage.d.ts +0 -1
  24. package/dist/locales/nl/agent-usage.js +0 -1
  25. package/dist/usage/LimitsList.d.ts +5 -2
  26. package/dist/usage/LimitsList.js +649 -231
  27. package/dist/usage/UsageBreakdown.js +1 -1
  28. package/dist/usage/UsageLimits.js +1 -1
  29. package/dist/usage/UsageLimitsCard.js +81 -54
  30. package/dist/usage/limit-groups.d.ts +4 -3
  31. package/dist/usage/limit-groups.js +21 -11
  32. package/package.json +8 -8
  33. package/src/chat/chat-references.ts +53 -4
  34. package/src/chat/ui/ReferenceChip.tsx +8 -2
  35. package/src/chat/ui/ReferenceTrail.tsx +29 -0
  36. package/src/chat/ui/RunSettings.tsx +2 -2
  37. package/src/chat/ui/SessionLine.tsx +1 -1
  38. package/src/chat/ui/chips.ts +3 -0
  39. package/src/chat/ui/composer/ComposerMenu.tsx +30 -11
  40. package/src/chat/ui/composer/chips.ts +29 -11
  41. package/src/chat/ui/composer/use-prompt-menus.ts +12 -7
  42. package/src/chat/ui/reference-icons.ts +18 -1
  43. package/src/chat/ui/rows/MessageRows.tsx +1 -0
  44. package/src/locales/en/agent-chat.ts +4 -1
  45. package/src/locales/en/agent-usage.ts +0 -1
  46. package/src/locales/nl/agent-chat.ts +4 -1
  47. package/src/locales/nl/agent-usage.ts +0 -1
  48. package/src/usage/LimitsList.tsx +183 -54
  49. package/src/usage/UsageBreakdown.tsx +1 -1
  50. package/src/usage/UsageLimits.tsx +1 -1
  51. package/src/usage/UsageLimitsCard.tsx +11 -7
  52. package/src/usage/limit-groups.ts +25 -8
@@ -2,15 +2,18 @@ import { c as _c } from "react/compiler-runtime";
2
2
  import { Fragment } from 'react';
3
3
  import clsx from 'clsx';
4
4
  import { useTranslation } from 'react-i18next';
5
+ import { ChevronRight } from 'lucide-react';
5
6
  import { limitsAccountId } from '../agents/account-limits.js';
6
- import { AccountDot } from '../agents/AccountDot.js';
7
- import { Tooltip } from '@adecore/ui';
7
+ import { accountColor } from '../agents/accounts.js';
8
+ import { ProviderLogo } from '../agents/ProviderLogo.js';
9
+ import { Icon, Tooltip } from '@adecore/ui';
8
10
  import { formatClock, formatWeekdayClock, isSameDay, formatCountdown, formatPercent } from '@adecore/ui/format';
11
+ import { useChatHost } from '../host.js';
9
12
  import { ChartLogo } from './ChartLogo.js';
10
- import { PROVIDER_LABELS } from './format.js';
11
- import { accountNote, evenPace, explain, isSignedOut, nextReset, paceText } from './limit-groups.js';
13
+ import { PROVIDER_COLORS, PROVIDER_LABELS } from './format.js';
14
+ import { accountNote, emptyWindows, evenPace, explain, isSignedOut, limitAccountKey, noteIsWarning, paceText, ringWindows } from './limit-groups.js';
12
15
  /* Red where a window is nearly spent, amber where it is worth knowing; room to spare is not news and takes the text color. */
13
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
16
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
17
  function toneOf(used) {
15
18
  return used >= 0.9 ? 'bg-status-error' : used >= 0.7 ? 'bg-status-needs-you' : 'bg-text';
16
19
  }
@@ -78,7 +81,7 @@ export function WindowBar(t0) {
78
81
  const t7 = compact ? "inset-y-1" : "inset-y-1.5";
79
82
  let t8;
80
83
  if ($[13] !== t7) {
81
- t8 = clsx("absolute inset-x-0 rounded-full bg-surface-sunken", t7);
84
+ t8 = clsx("absolute inset-x-0 rounded-full bg-track", t7);
82
85
  $[13] = t7;
83
86
  $[14] = t8;
84
87
  } else {
@@ -268,7 +271,7 @@ export function LimitsList(t0) {
268
271
  children: [/*#__PURE__*/_jsx(ChartLogo, {
269
272
  provider: provider.kind
270
273
  }), PROVIDER_LABELS[provider.kind], provider.plan !== null && /*#__PURE__*/_jsxs("span", {
271
- className: "text-text-muted",
274
+ className: "text-text-muted capitalize",
272
275
  children: ["\xB7 ", provider.plan]
273
276
  })]
274
277
  }), note === null ? /*#__PURE__*/_jsx("div", {
@@ -312,9 +315,18 @@ export function LimitsList(t0) {
312
315
  }
313
316
  return t5;
314
317
  }
315
- /* One window on one line, for a card that holds several accounts: the label, a thin bar with the elapsed mark, the percent. */
318
+ /* Red where a window is nearly spent, amber where it is worth knowing, in the color of a word. */
319
+ function textToneOf(used) {
320
+ return used >= 0.9 ? 'text-status-error' : used >= 0.7 ? 'text-status-needs-you' : 'text-text';
321
+ }
322
+ function strokeToneOf(used) {
323
+ return used >= 0.9 ? 'stroke-status-error' : used >= 0.7 ? 'stroke-status-needs-you' : 'stroke-text';
324
+ }
325
+ const WINDOW_LINE = 'grid grid-cols-[104px_minmax(0,1fr)_34px_50px] items-center gap-x-2';
326
+ const RING_RADII = [8.75, 5.25, 1.75];
327
+ /* One window on one line: the label, a thin bar with the elapsed mark, the percent, the time left. Fixed columns, so the bars of every account line up. */
316
328
  function WindowLine(t0) {
317
- const $ = _c(44);
329
+ const $ = _c(53);
318
330
  const {
319
331
  window,
320
332
  now
@@ -324,30 +336,43 @@ function WindowLine(t0) {
324
336
  } = useTranslation("agent-usage");
325
337
  let mark;
326
338
  let percent;
339
+ let resetsIn;
327
340
  let t1;
328
341
  let t2;
329
342
  let t3;
343
+ let t4;
330
344
  if ($[0] !== now || $[1] !== t || $[2] !== window) {
331
345
  percent = Math.round(window.used * 100);
332
- let t4;
333
- if ($[8] !== now || $[9] !== window) {
334
- t4 = evenPace(window, now)?.percent ?? null;
335
- $[8] = now;
336
- $[9] = window;
337
- $[10] = t4;
346
+ let t5;
347
+ if ($[10] !== now || $[11] !== window) {
348
+ t5 = evenPace(window, now)?.percent ?? null;
349
+ $[10] = now;
350
+ $[11] = window;
351
+ $[12] = t5;
338
352
  } else {
339
- t4 = $[10];
353
+ t5 = $[12];
354
+ }
355
+ mark = t5;
356
+ let t6;
357
+ if ($[13] !== now || $[14] !== window.resetsAt) {
358
+ t6 = window.resetsAt === null ? null : resetInLabel(window.resetsAt, now);
359
+ $[13] = now;
360
+ $[14] = window.resetsAt;
361
+ $[15] = t6;
362
+ } else {
363
+ t6 = $[15];
340
364
  }
341
- mark = t4;
342
- if ($[11] !== window.label) {
343
- t3 = /*#__PURE__*/_jsx("span", {
344
- className: "text-text-muted",
365
+ resetsIn = t6;
366
+ t3 = WINDOW_LINE;
367
+ if ($[16] !== window.label) {
368
+ t4 = /*#__PURE__*/_jsx("span", {
369
+ className: "truncate text-text-muted",
345
370
  children: window.label
346
371
  });
347
- $[11] = window.label;
348
- $[12] = t3;
372
+ $[16] = window.label;
373
+ $[17] = t4;
349
374
  } else {
350
- t3 = $[12];
375
+ t4 = $[17];
351
376
  }
352
377
  t1 = "progressbar";
353
378
  t2 = t("limits.bar", {
@@ -359,310 +384,703 @@ function WindowLine(t0) {
359
384
  $[2] = window;
360
385
  $[3] = mark;
361
386
  $[4] = percent;
362
- $[5] = t1;
363
- $[6] = t2;
364
- $[7] = t3;
387
+ $[5] = resetsIn;
388
+ $[6] = t1;
389
+ $[7] = t2;
390
+ $[8] = t3;
391
+ $[9] = t4;
365
392
  } else {
366
393
  mark = $[3];
367
394
  percent = $[4];
368
- t1 = $[5];
369
- t2 = $[6];
370
- t3 = $[7];
395
+ resetsIn = $[5];
396
+ t1 = $[6];
397
+ t2 = $[7];
398
+ t3 = $[8];
399
+ t4 = $[9];
371
400
  }
372
- let t4;
373
- if ($[13] !== now || $[14] !== window) {
374
- t4 = paceText(window, now);
375
- $[13] = now;
376
- $[14] = window;
377
- $[15] = t4;
401
+ let t5;
402
+ if ($[18] !== now || $[19] !== window) {
403
+ t5 = paceText(window, now);
404
+ $[18] = now;
405
+ $[19] = window;
406
+ $[20] = t5;
378
407
  } else {
379
- t4 = $[15];
408
+ t5 = $[20];
380
409
  }
381
- let t5;
382
- if ($[16] !== window.used) {
383
- t5 = clsx("absolute inset-y-0 left-0 rounded-full", toneOf(window.used));
384
- $[16] = window.used;
385
- $[17] = t5;
410
+ let t6;
411
+ if ($[21] !== window.used) {
412
+ t6 = clsx("absolute inset-y-0 left-0 rounded-full", toneOf(window.used));
413
+ $[21] = window.used;
414
+ $[22] = t6;
386
415
  } else {
387
- t5 = $[17];
416
+ t6 = $[22];
388
417
  }
389
- const t6 = `${Math.min(100, percent)}%`;
390
- let t7;
391
- if ($[18] !== t6) {
392
- t7 = {
393
- width: t6
418
+ const t7 = `${Math.min(100, percent)}%`;
419
+ let t8;
420
+ if ($[23] !== t7) {
421
+ t8 = {
422
+ width: t7
394
423
  };
395
- $[18] = t6;
396
- $[19] = t7;
424
+ $[23] = t7;
425
+ $[24] = t8;
397
426
  } else {
398
- t7 = $[19];
427
+ t8 = $[24];
399
428
  }
400
- let t8;
401
- if ($[20] !== t5 || $[21] !== t7) {
402
- t8 = /*#__PURE__*/_jsx("div", {
403
- className: t5,
404
- style: t7
429
+ let t9;
430
+ if ($[25] !== t6 || $[26] !== t8) {
431
+ t9 = /*#__PURE__*/_jsx("div", {
432
+ className: t6,
433
+ style: t8
405
434
  });
406
- $[20] = t5;
407
- $[21] = t7;
408
- $[22] = t8;
435
+ $[25] = t6;
436
+ $[26] = t8;
437
+ $[27] = t9;
409
438
  } else {
410
- t8 = $[22];
439
+ t9 = $[27];
411
440
  }
412
- let t9;
413
- if ($[23] !== mark || $[24] !== percent) {
414
- t9 = mark !== null && /*#__PURE__*/_jsx("span", {
441
+ let t10;
442
+ if ($[28] !== mark || $[29] !== percent) {
443
+ t10 = mark !== null && /*#__PURE__*/_jsx("span", {
415
444
  "aria-hidden": true,
416
445
  className: clsx("absolute -inset-y-0.5 w-px -translate-x-1/2", mark <= percent ? "bg-surface-raised" : "bg-text-muted"),
417
446
  style: {
418
447
  left: `${mark}%`
419
448
  }
420
449
  });
421
- $[23] = mark;
422
- $[24] = percent;
423
- $[25] = t9;
450
+ $[28] = mark;
451
+ $[29] = percent;
452
+ $[30] = t10;
424
453
  } else {
425
- t9 = $[25];
454
+ t10 = $[30];
426
455
  }
427
- let t10;
428
- if ($[26] !== percent || $[27] !== t1 || $[28] !== t2 || $[29] !== t4 || $[30] !== t8 || $[31] !== t9) {
429
- t10 = /*#__PURE__*/_jsxs("div", {
456
+ let t11;
457
+ if ($[31] !== percent || $[32] !== t1 || $[33] !== t10 || $[34] !== t2 || $[35] !== t5 || $[36] !== t9) {
458
+ t11 = /*#__PURE__*/_jsxs("div", {
430
459
  role: t1,
431
460
  "aria-label": t2,
432
461
  "aria-valuenow": percent,
433
- "aria-valuetext": t4,
462
+ "aria-valuetext": t5,
434
463
  "aria-valuemin": 0,
435
464
  "aria-valuemax": 100,
436
- className: "relative h-1.5 rounded-full bg-surface-sunken",
437
- children: [t8, t9]
465
+ className: "relative h-1.5 rounded-full bg-track",
466
+ children: [t9, t10]
438
467
  });
439
- $[26] = percent;
440
- $[27] = t1;
441
- $[28] = t2;
442
- $[29] = t4;
443
- $[30] = t8;
444
- $[31] = t9;
445
- $[32] = t10;
468
+ $[31] = percent;
469
+ $[32] = t1;
470
+ $[33] = t10;
471
+ $[34] = t2;
472
+ $[35] = t5;
473
+ $[36] = t9;
474
+ $[37] = t11;
446
475
  } else {
447
- t10 = $[32];
476
+ t11 = $[37];
448
477
  }
449
- const t11 = window.used >= 0.9 ? "text-status-error" : "text-text";
450
478
  let t12;
451
- if ($[33] !== t11) {
452
- t12 = clsx("text-right tabular-nums", t11);
453
- $[33] = t11;
454
- $[34] = t12;
479
+ if ($[38] !== window.used) {
480
+ t12 = clsx("text-right tabular-nums", textToneOf(window.used));
481
+ $[38] = window.used;
482
+ $[39] = t12;
455
483
  } else {
456
- t12 = $[34];
484
+ t12 = $[39];
457
485
  }
458
486
  let t13;
459
- if ($[35] !== percent) {
487
+ if ($[40] !== percent) {
460
488
  t13 = formatPercent(percent);
461
- $[35] = percent;
462
- $[36] = t13;
489
+ $[40] = percent;
490
+ $[41] = t13;
463
491
  } else {
464
- t13 = $[36];
492
+ t13 = $[41];
465
493
  }
466
494
  let t14;
467
- if ($[37] !== t12 || $[38] !== t13) {
495
+ if ($[42] !== t12 || $[43] !== t13) {
468
496
  t14 = /*#__PURE__*/_jsx("span", {
469
497
  className: t12,
470
498
  children: t13
471
499
  });
472
- $[37] = t12;
473
- $[38] = t13;
474
- $[39] = t14;
500
+ $[42] = t12;
501
+ $[43] = t13;
502
+ $[44] = t14;
475
503
  } else {
476
- t14 = $[39];
504
+ t14 = $[44];
477
505
  }
478
- let t15;
479
- if ($[40] !== t10 || $[41] !== t14 || $[42] !== t3) {
480
- t15 = /*#__PURE__*/_jsxs(_Fragment, {
481
- children: [t3, t10, t14]
506
+ const t15 = resetsIn ?? "-";
507
+ let t16;
508
+ if ($[45] !== t15) {
509
+ t16 = /*#__PURE__*/_jsx("span", {
510
+ className: "text-right whitespace-nowrap text-text-faint tabular-nums",
511
+ children: t15
482
512
  });
483
- $[40] = t10;
484
- $[41] = t14;
485
- $[42] = t3;
486
- $[43] = t15;
513
+ $[45] = t15;
514
+ $[46] = t16;
487
515
  } else {
488
- t15 = $[43];
516
+ t16 = $[46];
489
517
  }
490
- return t15;
518
+ let t17;
519
+ if ($[47] !== t11 || $[48] !== t14 || $[49] !== t16 || $[50] !== t3 || $[51] !== t4) {
520
+ t17 = /*#__PURE__*/_jsxs("div", {
521
+ className: t3,
522
+ children: [t4, t11, t14, t16]
523
+ });
524
+ $[47] = t11;
525
+ $[48] = t14;
526
+ $[49] = t16;
527
+ $[50] = t3;
528
+ $[51] = t4;
529
+ $[52] = t17;
530
+ } else {
531
+ t17 = $[52];
532
+ }
533
+ return t17;
534
+ }
535
+ /* A window this account has not reported on: no number to draw, so an empty bar and a dash. */
536
+ function EmptyWindowLine(t0) {
537
+ const $ = _c(7);
538
+ const {
539
+ label
540
+ } = t0;
541
+ let t1;
542
+ if ($[0] !== label) {
543
+ t1 = /*#__PURE__*/_jsx("span", {
544
+ className: "truncate text-text-muted",
545
+ children: label
546
+ });
547
+ $[0] = label;
548
+ $[1] = t1;
549
+ } else {
550
+ t1 = $[1];
551
+ }
552
+ let t2;
553
+ let t3;
554
+ let t4;
555
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
556
+ t2 = /*#__PURE__*/_jsx("div", {
557
+ className: "h-1.5 rounded-full bg-track"
558
+ });
559
+ t3 = /*#__PURE__*/_jsx("span", {
560
+ className: "text-right text-text-faint",
561
+ children: "-"
562
+ });
563
+ t4 = /*#__PURE__*/_jsx("span", {
564
+ className: "text-right text-text-faint",
565
+ children: "-"
566
+ });
567
+ $[2] = t2;
568
+ $[3] = t3;
569
+ $[4] = t4;
570
+ } else {
571
+ t2 = $[2];
572
+ t3 = $[3];
573
+ t4 = $[4];
574
+ }
575
+ let t5;
576
+ if ($[5] !== t1) {
577
+ t5 = /*#__PURE__*/_jsxs("div", {
578
+ className: WINDOW_LINE,
579
+ children: [t1, t2, t3, t4]
580
+ });
581
+ $[5] = t1;
582
+ $[6] = t5;
583
+ } else {
584
+ t5 = $[6];
585
+ }
586
+ return t5;
491
587
  }
492
- function AccountLines(t0) {
493
- const $ = _c(29);
588
+ /* A ring per window, what a folded account keeps of its bars. The largest is the first window. */
589
+ function WindowRings(t0) {
590
+ const $ = _c(30);
591
+ const {
592
+ windows,
593
+ empty
594
+ } = t0;
595
+ const {
596
+ t
597
+ } = useTranslation("agent-usage");
598
+ let t1;
599
+ let t10;
600
+ let t2;
601
+ let t3;
602
+ let t4;
603
+ let t5;
604
+ let t6;
605
+ let t7;
606
+ let t8;
607
+ let t9;
608
+ if ($[0] !== empty || $[1] !== t || $[2] !== windows) {
609
+ const rings = ringWindows(windows);
610
+ let t11;
611
+ if ($[13] !== t) {
612
+ t11 = window => t("limits.bar", {
613
+ window: window.label,
614
+ percent: Math.round(window.used * 100)
615
+ });
616
+ $[13] = t;
617
+ $[14] = t11;
618
+ } else {
619
+ t11 = $[14];
620
+ }
621
+ const label = rings.map(t11).join(", ");
622
+ t1 = "0 0 20 20";
623
+ t2 = "20";
624
+ t3 = "20";
625
+ t4 = "none";
626
+ t5 = "2.5";
627
+ t6 = empty ? undefined : "img";
628
+ t7 = empty ? true : undefined;
629
+ t8 = empty ? undefined : label;
630
+ const t12 = empty && "opacity-50";
631
+ if ($[15] !== t12) {
632
+ t9 = clsx("ml-auto shrink-0", t12);
633
+ $[15] = t12;
634
+ $[16] = t9;
635
+ } else {
636
+ t9 = $[16];
637
+ }
638
+ let t13;
639
+ if ($[17] !== empty) {
640
+ t13 = (window_0, index) => {
641
+ const radius = RING_RADII[index] ?? 0;
642
+ const circumference = 2 * Math.PI * radius;
643
+ return /*#__PURE__*/_jsxs(Fragment, {
644
+ children: [/*#__PURE__*/_jsx("circle", {
645
+ cx: "10",
646
+ cy: "10",
647
+ r: radius,
648
+ className: "stroke-track"
649
+ }), !empty && /*#__PURE__*/_jsx("circle", {
650
+ cx: "10",
651
+ cy: "10",
652
+ r: radius,
653
+ strokeDasharray: `${Math.min(1, window_0.used) * circumference} ${circumference}`,
654
+ transform: "rotate(-90 10 10)",
655
+ className: strokeToneOf(window_0.used)
656
+ })]
657
+ }, window_0.id);
658
+ };
659
+ $[17] = empty;
660
+ $[18] = t13;
661
+ } else {
662
+ t13 = $[18];
663
+ }
664
+ t10 = rings.map(t13);
665
+ $[0] = empty;
666
+ $[1] = t;
667
+ $[2] = windows;
668
+ $[3] = t1;
669
+ $[4] = t10;
670
+ $[5] = t2;
671
+ $[6] = t3;
672
+ $[7] = t4;
673
+ $[8] = t5;
674
+ $[9] = t6;
675
+ $[10] = t7;
676
+ $[11] = t8;
677
+ $[12] = t9;
678
+ } else {
679
+ t1 = $[3];
680
+ t10 = $[4];
681
+ t2 = $[5];
682
+ t3 = $[6];
683
+ t4 = $[7];
684
+ t5 = $[8];
685
+ t6 = $[9];
686
+ t7 = $[10];
687
+ t8 = $[11];
688
+ t9 = $[12];
689
+ }
690
+ let t11;
691
+ if ($[19] !== t1 || $[20] !== t10 || $[21] !== t2 || $[22] !== t3 || $[23] !== t4 || $[24] !== t5 || $[25] !== t6 || $[26] !== t7 || $[27] !== t8 || $[28] !== t9) {
692
+ t11 = /*#__PURE__*/_jsx("svg", {
693
+ viewBox: t1,
694
+ width: t2,
695
+ height: t3,
696
+ fill: t4,
697
+ strokeWidth: t5,
698
+ role: t6,
699
+ "aria-hidden": t7,
700
+ "aria-label": t8,
701
+ className: t9,
702
+ children: t10
703
+ });
704
+ $[19] = t1;
705
+ $[20] = t10;
706
+ $[21] = t2;
707
+ $[22] = t3;
708
+ $[23] = t4;
709
+ $[24] = t5;
710
+ $[25] = t6;
711
+ $[26] = t7;
712
+ $[27] = t8;
713
+ $[28] = t9;
714
+ $[29] = t11;
715
+ } else {
716
+ t11 = $[29];
717
+ }
718
+ return t11;
719
+ }
720
+ function AccountLogo(t0) {
721
+ const $ = _c(12);
494
722
  const {
495
723
  account,
496
- now
724
+ className
725
+ } = t0;
726
+ const {
727
+ accents
728
+ } = useChatHost();
729
+ let t1;
730
+ if ($[0] !== accents.all || $[1] !== account.color || $[2] !== account.kind) {
731
+ t1 = accountColor(account.color, accents.all) ?? PROVIDER_COLORS[account.kind];
732
+ $[0] = accents.all;
733
+ $[1] = account.color;
734
+ $[2] = account.kind;
735
+ $[3] = t1;
736
+ } else {
737
+ t1 = $[3];
738
+ }
739
+ let t2;
740
+ if ($[4] !== t1) {
741
+ t2 = {
742
+ color: t1
743
+ };
744
+ $[4] = t1;
745
+ $[5] = t2;
746
+ } else {
747
+ t2 = $[5];
748
+ }
749
+ let t3;
750
+ if ($[6] !== account.kind) {
751
+ t3 = /*#__PURE__*/_jsx(ProviderLogo, {
752
+ provider: account.kind
753
+ });
754
+ $[6] = account.kind;
755
+ $[7] = t3;
756
+ } else {
757
+ t3 = $[7];
758
+ }
759
+ let t4;
760
+ if ($[8] !== className || $[9] !== t2 || $[10] !== t3) {
761
+ t4 = /*#__PURE__*/_jsx("span", {
762
+ className: className,
763
+ style: t2,
764
+ children: t3
765
+ });
766
+ $[8] = className;
767
+ $[9] = t2;
768
+ $[10] = t3;
769
+ $[11] = t4;
770
+ } else {
771
+ t4 = $[11];
772
+ }
773
+ return t4;
774
+ }
775
+ /* One account: a row that folds its windows away, or only a row with the words for why it has none. */
776
+ function AccountRow(t0) {
777
+ const $ = _c(56);
778
+ const {
779
+ group,
780
+ account,
781
+ now,
782
+ folded,
783
+ onToggle
497
784
  } = t0;
498
785
  const {
499
786
  t
500
787
  } = useTranslation("agent-usage");
501
788
  let t1;
502
- if ($[0] !== account) {
503
- t1 = isSignedOut(account);
789
+ if ($[0] !== account || $[1] !== group) {
790
+ t1 = emptyWindows(group, account);
504
791
  $[0] = account;
505
- $[1] = t1;
792
+ $[1] = group;
793
+ $[2] = t1;
506
794
  } else {
507
- t1 = $[1];
795
+ t1 = $[2];
508
796
  }
509
- const signedOut = t1;
797
+ const empty = t1;
510
798
  let t2;
511
- if ($[2] !== account || $[3] !== signedOut) {
512
- t2 = signedOut ? null : accountNote(account);
513
- $[2] = account;
514
- $[3] = signedOut;
515
- $[4] = t2;
799
+ if ($[3] !== account || $[4] !== t) {
800
+ t2 = isSignedOut(account) ? t("limits.signedOut") : accountNote(account);
801
+ $[3] = account;
802
+ $[4] = t;
803
+ $[5] = t2;
516
804
  } else {
517
- t2 = $[4];
805
+ t2 = $[5];
518
806
  }
519
807
  const note = t2;
520
- let t3;
521
- if ($[5] !== account.color || $[6] !== account.entry || $[7] !== account.name || $[8] !== note || $[9] !== now || $[10] !== signedOut || $[11] !== t) {
522
- const windows = signedOut || note !== null ? [] : account.entry?.windows ?? [];
523
- const next = nextReset(windows, now);
524
- const resetsIn = next === null ? null : resetInLabel(next.resetsAt, now);
525
- let t4;
526
- if ($[13] !== account.color) {
527
- t4 = /*#__PURE__*/_jsx(AccountDot, {
528
- color: account.color
808
+ if (note !== null && empty.length === 0) {
809
+ let t3;
810
+ if ($[6] !== account) {
811
+ t3 = /*#__PURE__*/_jsx(AccountLogo, {
812
+ account: account,
813
+ className: "grid size-3.5 shrink-0"
529
814
  });
530
- $[13] = account.color;
531
- $[14] = t4;
815
+ $[6] = account;
816
+ $[7] = t3;
532
817
  } else {
533
- t4 = $[14];
818
+ t3 = $[7];
534
819
  }
535
- let t5;
536
- if ($[15] !== account.name) {
537
- t5 = /*#__PURE__*/_jsx("span", {
538
- className: "truncate",
820
+ let t4;
821
+ if ($[8] !== account.name) {
822
+ t4 = /*#__PURE__*/_jsx("span", {
823
+ className: "max-w-1/2 shrink-0 truncate font-medium",
539
824
  children: account.name
540
825
  });
541
- $[15] = account.name;
542
- $[16] = t5;
826
+ $[8] = account.name;
827
+ $[9] = t4;
543
828
  } else {
544
- t5 = $[16];
829
+ t4 = $[9];
830
+ }
831
+ let t5;
832
+ if ($[10] !== account) {
833
+ t5 = noteIsWarning(account) ? "text-status-needs-you" : "text-text-faint";
834
+ $[10] = account;
835
+ $[11] = t5;
836
+ } else {
837
+ t5 = $[11];
545
838
  }
546
839
  let t6;
547
- if ($[17] !== account.entry || $[18] !== signedOut || $[19] !== t) {
548
- t6 = signedOut ? /*#__PURE__*/_jsxs("span", {
549
- className: "shrink-0 text-text-faint",
550
- children: ["\xB7 ", t("limits.signedOut")]
551
- }) : account.entry?.plan && /*#__PURE__*/_jsxs("span", {
552
- className: "shrink-0 text-text-muted",
553
- children: ["\xB7 ", account.entry.plan]
554
- });
555
- $[17] = account.entry;
556
- $[18] = signedOut;
557
- $[19] = t;
558
- $[20] = t6;
840
+ if ($[12] !== t5) {
841
+ t6 = clsx("ml-auto min-w-0 text-right", t5);
842
+ $[12] = t5;
843
+ $[13] = t6;
559
844
  } else {
560
- t6 = $[20];
845
+ t6 = $[13];
561
846
  }
562
847
  let t7;
563
- if ($[21] !== t4 || $[22] !== t5 || $[23] !== t6) {
564
- t7 = /*#__PURE__*/_jsxs("p", {
565
- className: "col-span-full mt-2 flex min-w-0 items-center gap-2",
566
- children: [t4, t5, t6]
848
+ if ($[14] !== note || $[15] !== t6) {
849
+ t7 = /*#__PURE__*/_jsx("span", {
850
+ className: t6,
851
+ children: note
567
852
  });
568
- $[21] = t4;
569
- $[22] = t5;
570
- $[23] = t6;
571
- $[24] = t7;
853
+ $[14] = note;
854
+ $[15] = t6;
855
+ $[16] = t7;
572
856
  } else {
573
- t7 = $[24];
857
+ t7 = $[16];
574
858
  }
575
859
  let t8;
576
- if ($[25] !== note) {
577
- t8 = note !== null && /*#__PURE__*/_jsx("p", {
578
- className: "col-span-full text-text-faint",
579
- children: note
860
+ if ($[17] !== t3 || $[18] !== t4 || $[19] !== t7) {
861
+ t8 = /*#__PURE__*/_jsxs("p", {
862
+ className: "flex min-h-7 min-w-0 items-center gap-2 px-1.5",
863
+ children: [t3, t4, t7]
580
864
  });
581
- $[25] = note;
582
- $[26] = t8;
865
+ $[17] = t3;
866
+ $[18] = t4;
867
+ $[19] = t7;
868
+ $[20] = t8;
583
869
  } else {
584
- t8 = $[26];
870
+ t8 = $[20];
585
871
  }
586
- let t9;
587
- if ($[27] !== now) {
588
- t9 = window => /*#__PURE__*/_jsx(WindowLine, {
589
- window: window,
872
+ return t8;
873
+ }
874
+ let t3;
875
+ if ($[21] !== account.entry?.windows || $[22] !== empty) {
876
+ t3 = empty.length > 0 ? empty : account.entry?.windows ?? [];
877
+ $[21] = account.entry?.windows;
878
+ $[22] = empty;
879
+ $[23] = t3;
880
+ } else {
881
+ t3 = $[23];
882
+ }
883
+ const windows = t3;
884
+ const t4 = !folded;
885
+ let t5;
886
+ if ($[24] !== account) {
887
+ t5 = /*#__PURE__*/_jsx(AccountLogo, {
888
+ account: account,
889
+ className: "grid group-hover:hidden group-focus-visible:hidden"
890
+ });
891
+ $[24] = account;
892
+ $[25] = t5;
893
+ } else {
894
+ t5 = $[25];
895
+ }
896
+ const t6 = !folded && "rotate-90";
897
+ let t7;
898
+ if ($[26] !== t6) {
899
+ t7 = clsx("hidden text-text-muted group-hover:block group-focus-visible:block", t6);
900
+ $[26] = t6;
901
+ $[27] = t7;
902
+ } else {
903
+ t7 = $[27];
904
+ }
905
+ let t8;
906
+ if ($[28] !== t7) {
907
+ t8 = /*#__PURE__*/_jsx(Icon, {
908
+ icon: ChevronRight,
909
+ size: 14,
910
+ className: t7
911
+ });
912
+ $[28] = t7;
913
+ $[29] = t8;
914
+ } else {
915
+ t8 = $[29];
916
+ }
917
+ let t9;
918
+ if ($[30] !== t5 || $[31] !== t8) {
919
+ t9 = /*#__PURE__*/_jsxs("span", {
920
+ className: "grid size-3.5 shrink-0",
921
+ children: [t5, t8]
922
+ });
923
+ $[30] = t5;
924
+ $[31] = t8;
925
+ $[32] = t9;
926
+ } else {
927
+ t9 = $[32];
928
+ }
929
+ let t10;
930
+ if ($[33] !== account.name) {
931
+ t10 = /*#__PURE__*/_jsx("span", {
932
+ className: "min-w-0 truncate font-medium",
933
+ children: account.name
934
+ });
935
+ $[33] = account.name;
936
+ $[34] = t10;
937
+ } else {
938
+ t10 = $[34];
939
+ }
940
+ let t11;
941
+ if ($[35] !== account.entry) {
942
+ t11 = account.entry?.plan && /*#__PURE__*/_jsx("span", {
943
+ className: "shrink-0 text-text-muted capitalize",
944
+ children: account.entry.plan
945
+ });
946
+ $[35] = account.entry;
947
+ $[36] = t11;
948
+ } else {
949
+ t11 = $[36];
950
+ }
951
+ let t12;
952
+ if ($[37] !== empty.length || $[38] !== folded || $[39] !== windows) {
953
+ t12 = folded && /*#__PURE__*/_jsx(WindowRings, {
954
+ windows: windows,
955
+ empty: empty.length > 0
956
+ });
957
+ $[37] = empty.length;
958
+ $[38] = folded;
959
+ $[39] = windows;
960
+ $[40] = t12;
961
+ } else {
962
+ t12 = $[40];
963
+ }
964
+ let t13;
965
+ if ($[41] !== onToggle || $[42] !== t10 || $[43] !== t11 || $[44] !== t12 || $[45] !== t4 || $[46] !== t9) {
966
+ t13 = /*#__PURE__*/_jsxs("button", {
967
+ type: "button",
968
+ "aria-expanded": t4,
969
+ className: "group flex min-h-7 w-full min-w-0 items-center gap-2 rounded-md px-1.5 text-left hover:bg-surface-hover focus-visible:bg-surface-hover",
970
+ onClick: onToggle,
971
+ children: [t9, t10, t11, t12]
972
+ });
973
+ $[41] = onToggle;
974
+ $[42] = t10;
975
+ $[43] = t11;
976
+ $[44] = t12;
977
+ $[45] = t4;
978
+ $[46] = t9;
979
+ $[47] = t13;
980
+ } else {
981
+ t13 = $[47];
982
+ }
983
+ let t14;
984
+ if ($[48] !== empty || $[49] !== folded || $[50] !== now || $[51] !== windows) {
985
+ t14 = !folded && /*#__PURE__*/_jsx("div", {
986
+ className: "flex flex-col gap-0.75 pt-0.5 pr-1.5 pb-2 pl-7",
987
+ children: empty.length > 0 ? empty.map(_temp) : windows.map(window_0 => /*#__PURE__*/_jsx(WindowLine, {
988
+ window: window_0,
590
989
  now: now
591
- }, window.id);
592
- $[27] = now;
593
- $[28] = t9;
594
- } else {
595
- t9 = $[28];
596
- }
597
- t3 = /*#__PURE__*/_jsxs(_Fragment, {
598
- children: [t7, t8, windows.map(t9), next !== null && /*#__PURE__*/_jsxs("p", {
599
- className: "col-span-full whitespace-nowrap text-text-faint",
600
- children: [t("limits.nextReset", {
601
- window: next.label,
602
- at: resetAtLabel(next.resetsAt, now)
603
- }), resetsIn !== null && ` · ${resetsIn}`]
604
- })]
990
+ }, window_0.id))
605
991
  });
606
- $[5] = account.color;
607
- $[6] = account.entry;
608
- $[7] = account.name;
609
- $[8] = note;
610
- $[9] = now;
611
- $[10] = signedOut;
612
- $[11] = t;
613
- $[12] = t3;
992
+ $[48] = empty;
993
+ $[49] = folded;
994
+ $[50] = now;
995
+ $[51] = windows;
996
+ $[52] = t14;
614
997
  } else {
615
- t3 = $[12];
998
+ t14 = $[52];
616
999
  }
617
- return t3;
1000
+ let t15;
1001
+ if ($[53] !== t13 || $[54] !== t14) {
1002
+ t15 = /*#__PURE__*/_jsxs("div", {
1003
+ className: "flex flex-col",
1004
+ children: [t13, t14]
1005
+ });
1006
+ $[53] = t13;
1007
+ $[54] = t14;
1008
+ $[55] = t15;
1009
+ } else {
1010
+ t15 = $[55];
1011
+ }
1012
+ return t15;
1013
+ }
1014
+ /* A flat list of accounts for a hover card, whichever CLI they belong to; the logo says which. */
1015
+ function _temp(window) {
1016
+ return /*#__PURE__*/_jsx(EmptyWindowLine, {
1017
+ label: window.label
1018
+ }, window.id);
618
1019
  }
619
- /*
620
- * The hover card once a CLI has several accounts: a block per account, a line per window. One grid over
621
- * the whole card, so the bars of every account start and end at the same place whatever their labels.
622
- */
623
1020
  export function AccountLimitsList(t0) {
624
- const $ = _c(7);
1021
+ const $ = _c(14);
625
1022
  const {
626
1023
  groups,
627
- now
1024
+ now,
1025
+ folded,
1026
+ onFoldedChange
628
1027
  } = t0;
629
1028
  let t1;
630
- if ($[0] !== groups || $[1] !== now) {
631
- let t2;
632
- if ($[3] !== now) {
633
- t2 = group => /*#__PURE__*/_jsxs(Fragment, {
634
- children: [/*#__PURE__*/_jsxs("p", {
635
- className: "col-span-full mt-3 flex items-center gap-2 font-medium first:mt-0",
636
- children: [/*#__PURE__*/_jsx(ChartLogo, {
637
- provider: group.kind
638
- }), PROVIDER_LABELS[group.kind]]
639
- }), group.accounts.map(account => /*#__PURE__*/_jsx(AccountLines, {
640
- account: account,
641
- now: now
642
- }, account.id))]
643
- }, group.kind);
644
- $[3] = now;
645
- $[4] = t2;
646
- } else {
647
- t2 = $[4];
648
- }
649
- t1 = groups.map(t2);
650
- $[0] = groups;
651
- $[1] = now;
1029
+ if ($[0] !== folded || $[1] !== onFoldedChange) {
1030
+ t1 = key => {
1031
+ const next = new Set(folded);
1032
+ if (!next.delete(key)) {
1033
+ next.add(key);
1034
+ }
1035
+ onFoldedChange(next);
1036
+ };
1037
+ $[0] = folded;
1038
+ $[1] = onFoldedChange;
652
1039
  $[2] = t1;
653
1040
  } else {
654
1041
  t1 = $[2];
655
1042
  }
1043
+ const toggle = t1;
656
1044
  let t2;
657
- if ($[5] !== t1) {
658
- t2 = /*#__PURE__*/_jsx("div", {
659
- className: "grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-2 gap-y-1 text-xs",
660
- children: t1
1045
+ if ($[3] !== folded || $[4] !== groups || $[5] !== now || $[6] !== toggle) {
1046
+ let t3;
1047
+ if ($[8] !== folded || $[9] !== now || $[10] !== toggle) {
1048
+ t3 = group => group.accounts.map(account => {
1049
+ const key_0 = limitAccountKey(account);
1050
+ return /*#__PURE__*/_jsx(AccountRow, {
1051
+ group: group,
1052
+ account: account,
1053
+ now: now,
1054
+ folded: folded.has(key_0),
1055
+ onToggle: () => toggle(key_0)
1056
+ }, key_0);
1057
+ });
1058
+ $[8] = folded;
1059
+ $[9] = now;
1060
+ $[10] = toggle;
1061
+ $[11] = t3;
1062
+ } else {
1063
+ t3 = $[11];
1064
+ }
1065
+ t2 = groups.flatMap(t3);
1066
+ $[3] = folded;
1067
+ $[4] = groups;
1068
+ $[5] = now;
1069
+ $[6] = toggle;
1070
+ $[7] = t2;
1071
+ } else {
1072
+ t2 = $[7];
1073
+ }
1074
+ let t3;
1075
+ if ($[12] !== t2) {
1076
+ t3 = /*#__PURE__*/_jsx("div", {
1077
+ className: "flex flex-col gap-0.5 text-xs",
1078
+ children: t2
661
1079
  });
662
- $[5] = t1;
663
- $[6] = t2;
1080
+ $[12] = t2;
1081
+ $[13] = t3;
664
1082
  } else {
665
- t2 = $[6];
1083
+ t3 = $[13];
666
1084
  }
667
- return t2;
1085
+ return t3;
668
1086
  }