@locusgraph/loop 0.1.0 → 0.2.0

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 (115) hide show
  1. package/README.md +2 -0
  2. package/dist/agent/pulse/gradient-label.js +86 -15
  3. package/dist/agent/pulse/marks/bars-mark.js +46 -10
  4. package/dist/agent/pulse/marks/glyph-mark.js +56 -11
  5. package/dist/agent/pulse/marks/locus-mark.js +63 -28
  6. package/dist/agent/pulse/marks/orb-mark.js +31 -8
  7. package/dist/agent/pulse/marks/spinner-mark.js +29 -1
  8. package/dist/agent/pulse/pulse.js +150 -35
  9. package/dist/agent/pulse/use-loop-animation.js +36 -17
  10. package/dist/agent/steps/step-icon.js +110 -24
  11. package/dist/agent/steps/steps.js +235 -25
  12. package/dist/agent/thinking/thinking.js +203 -23
  13. package/dist/agent/thinking/thought-duration.js +7 -9
  14. package/dist/agent/tool/json-block.js +38 -11
  15. package/dist/agent/tool/tool-status.js +51 -18
  16. package/dist/agent/tool/tool.js +184 -6
  17. package/dist/approval/inbox/inbox-row.d.ts +3 -2
  18. package/dist/approval/inbox/inbox-row.js +321 -7
  19. package/dist/approval/inbox/inbox-selection.js +7 -13
  20. package/dist/approval/inbox/inbox.d.ts +2 -1
  21. package/dist/approval/inbox/inbox.js +250 -18
  22. package/dist/approval/inbox/virtual-inbox-list.d.ts +13 -0
  23. package/dist/approval/inbox/virtual-inbox-list.js +129 -0
  24. package/dist/approval/memory/memory-choices.js +27 -22
  25. package/dist/approval/memory/memory-review.js +242 -17
  26. package/dist/approval/memory/memory-row.js +215 -19
  27. package/dist/approval/plan/plan-review.js +279 -28
  28. package/dist/approval/plan/plan-step-row.js +194 -43
  29. package/dist/approval/plan/plan-steps.js +24 -23
  30. package/dist/approval/plan/question-choices.js +158 -39
  31. package/dist/approval/plan/question.d.ts +1 -1
  32. package/dist/approval/plan/question.js +223 -26
  33. package/dist/approval/run/run-bar.js +178 -22
  34. package/dist/approval/shared/decision-line.js +1 -1
  35. package/dist/approval/shared/risk-badge.js +47 -16
  36. package/dist/approval/shared/time.js +5 -8
  37. package/dist/approval/shared/use-focus-on-mount.js +23 -6
  38. package/dist/approval/spend/raise-cap-form.js +235 -17
  39. package/dist/approval/spend/spend-gate.js +239 -21
  40. package/dist/approval/spend/spend-math.js +7 -8
  41. package/dist/approval/spend/spend-meter.js +362 -34
  42. package/dist/approval/tool/approval.js +272 -27
  43. package/dist/approval/tool/args/args-editor.js +262 -26
  44. package/dist/approval/tool/args/args-field.js +259 -19
  45. package/dist/approval/tool/args/args-validation.js +38 -47
  46. package/dist/approval/tool/deny-form.js +130 -10
  47. package/dist/approval/tool/tool-inputs.js +127 -38
  48. package/dist/chat/chat/chat-item-spacing.d.ts +3 -0
  49. package/dist/chat/chat/chat-item-spacing.js +19 -0
  50. package/dist/chat/chat/chat.d.ts +2 -1
  51. package/dist/chat/chat/chat.js +181 -5
  52. package/dist/chat/chat/use-stick-to-bottom.js +123 -47
  53. package/dist/chat/chat/virtual-chat-items.d.ts +8 -0
  54. package/dist/chat/chat/virtual-chat-items.js +153 -0
  55. package/dist/chat/composer/composer-actions.js +151 -16
  56. package/dist/chat/composer/composer.js +330 -32
  57. package/dist/chat/composer/use-auto-grow.js +24 -9
  58. package/dist/chat/files/file-meta.js +19 -19
  59. package/dist/chat/files/files.js +316 -28
  60. package/dist/chat/reply/fenced-code.js +45 -21
  61. package/dist/chat/reply/markdown-components.js +137 -17
  62. package/dist/chat/reply/reply.js +105 -10
  63. package/dist/chat/turn/group-parts.js +43 -29
  64. package/dist/chat/turn/turn.js +238 -30
  65. package/dist/cost/context.js +321 -23
  66. package/dist/cost/cost-steps.js +220 -14
  67. package/dist/cost/cost.js +521 -27
  68. package/dist/cost/model-picker.js +181 -6
  69. package/dist/cost/shared/context-breakdown.js +299 -10
  70. package/dist/cost/shared/meter-marks.js +107 -9
  71. package/dist/cost/shared/model-option-row.js +178 -21
  72. package/dist/cost/shared/step-cost-row.js +248 -20
  73. package/dist/cost/shared/usage-totals.js +22 -18
  74. package/dist/memory/cite.js +182 -11
  75. package/dist/memory/memorized.js +217 -11
  76. package/dist/memory/recall.js +296 -17
  77. package/dist/memory/shared/host-label.js +19 -22
  78. package/dist/memory/shared/source-mark.js +39 -3
  79. package/dist/memory/sources.js +255 -13
  80. package/dist/shared/decision-summary.js +133 -14
  81. package/dist/shared/panel-empty.js +78 -3
  82. package/dist/shared/panel.js +243 -13
  83. package/dist/shared/status-dot.js +38 -8
  84. package/dist/shared/virtual/use-list-virtualizer.d.ts +24 -0
  85. package/dist/shared/virtual/use-list-virtualizer.js +68 -0
  86. package/dist/thread/actions/action-button.js +65 -3
  87. package/dist/thread/actions/actions.js +184 -13
  88. package/dist/thread/actions/branch-switcher.js +102 -5
  89. package/dist/thread/canvas/canvas.js +205 -5
  90. package/dist/thread/canvas/version-switcher.js +149 -8
  91. package/dist/thread/code/code.js +186 -24
  92. package/dist/thread/code/copy-code-button.js +61 -13
  93. package/dist/thread/code/highlight.js +30 -29
  94. package/dist/thread/history/history-rows.d.ts +16 -0
  95. package/dist/thread/history/history-rows.js +23 -0
  96. package/dist/thread/history/history.d.ts +3 -2
  97. package/dist/thread/history/history.js +174 -5
  98. package/dist/thread/history/{history-row.d.ts → row/history-row.d.ts} +3 -2
  99. package/dist/thread/history/row/history-row.js +137 -0
  100. package/dist/thread/history/row/thread-item-menu.js +84 -0
  101. package/dist/thread/history/row/thread-title-editor.js +81 -0
  102. package/dist/thread/history/thread-groups.d.ts +1 -1
  103. package/dist/thread/history/thread-groups.js +40 -34
  104. package/dist/thread/history/virtual-history-list.d.ts +11 -0
  105. package/dist/thread/history/virtual-history-list.js +107 -0
  106. package/dist/thread/index.d.ts +1 -1
  107. package/dist/thread/starters/starters.js +92 -7
  108. package/dist/thread/use-copied.js +45 -15
  109. package/dist/types.js +1 -1
  110. package/package.json +6 -4
  111. package/dist/thread/history/history-row.js +0 -17
  112. package/dist/thread/history/thread-item-menu.js +0 -6
  113. package/dist/thread/history/thread-title-editor.js +0 -25
  114. /package/dist/thread/history/{thread-item-menu.d.ts → row/thread-item-menu.d.ts} +0 -0
  115. /package/dist/thread/history/{thread-title-editor.d.ts → row/thread-title-editor.d.ts} +0 -0
@@ -1,24 +1,303 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { ChevronRight as ChevronRightIcon, RecentlyViewed as HistoryIcon, } from "@carbon/icons-react";
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { ChevronRight as ChevronRightIcon, RecentlyViewed as HistoryIcon } from "@carbon/icons-react";
3
3
  import { Collapsible, CollapsibleContent, CollapsibleTrigger, cn } from "@locusgraph/components";
4
4
  import { pluralize } from "@locusgraph/utils";
5
- import { chevronClass, collapsibleTriggerClass, interactiveRowClass, ruledListClass, } from "./shared/disclosure.js";
5
+ import { chevronClass, collapsibleTriggerClass, interactiveRowClass, ruledListClass } from "./shared/disclosure.js";
6
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
6
7
  export function relevancePercent(relevance) {
7
- return Math.round(Math.min(Math.max(relevance, 0), 1) * 100);
8
+ return Math.round(Math.min(Math.max(relevance, 0), 1) * 100);
8
9
  }
9
- export function Recall({ memories, onOpenMemory, defaultOpen = false, className }) {
10
- if (memories.length === 0)
11
- return null;
12
- return (_jsxs(Collapsible, { "data-slot": "recall", defaultOpen: defaultOpen, className: cn("flex min-w-0 flex-col gap-2", className), children: [_jsxs(CollapsibleTrigger, { className: collapsibleTriggerClass, children: [_jsx(HistoryIcon, { "aria-hidden": true }), "Recalled ", pluralize(memories.length, "memory", "memories"), _jsx(ChevronRightIcon, { "aria-hidden": true, className: chevronClass })] }), _jsx(CollapsibleContent, { children: _jsx("ul", { className: ruledListClass, children: memories.map((memory) => (_jsx(RecallRow, { memory: memory, onOpenMemory: onOpenMemory }, memory.id))) }) })] }));
10
+ export function Recall(t0) {
11
+ const $ = _c(20);
12
+ const {
13
+ memories,
14
+ onOpenMemory,
15
+ defaultOpen: t1,
16
+ className
17
+ } = t0;
18
+ const defaultOpen = t1 === undefined ? false : t1;
19
+ if (memories.length === 0) {
20
+ return null;
21
+ }
22
+ let t2;
23
+ if ($[0] !== className) {
24
+ t2 = cn("flex min-w-0 flex-col gap-2", className);
25
+ $[0] = className;
26
+ $[1] = t2;
27
+ } else {
28
+ t2 = $[1];
29
+ }
30
+ let t3;
31
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
32
+ t3 = /*#__PURE__*/_jsx(HistoryIcon, {
33
+ "aria-hidden": true
34
+ });
35
+ $[2] = t3;
36
+ } else {
37
+ t3 = $[2];
38
+ }
39
+ let t4;
40
+ if ($[3] !== memories.length) {
41
+ t4 = pluralize(memories.length, "memory", "memories");
42
+ $[3] = memories.length;
43
+ $[4] = t4;
44
+ } else {
45
+ t4 = $[4];
46
+ }
47
+ let t5;
48
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
49
+ t5 = /*#__PURE__*/_jsx(ChevronRightIcon, {
50
+ "aria-hidden": true,
51
+ className: chevronClass
52
+ });
53
+ $[5] = t5;
54
+ } else {
55
+ t5 = $[5];
56
+ }
57
+ let t6;
58
+ if ($[6] !== t4) {
59
+ t6 = /*#__PURE__*/_jsxs(CollapsibleTrigger, {
60
+ className: collapsibleTriggerClass,
61
+ children: [t3, "Recalled ", t4, t5]
62
+ });
63
+ $[6] = t4;
64
+ $[7] = t6;
65
+ } else {
66
+ t6 = $[7];
67
+ }
68
+ let t7;
69
+ if ($[8] !== memories || $[9] !== onOpenMemory) {
70
+ let t8;
71
+ if ($[11] !== onOpenMemory) {
72
+ t8 = memory => /*#__PURE__*/_jsx(RecallRow, {
73
+ memory: memory,
74
+ onOpenMemory: onOpenMemory
75
+ }, memory.id);
76
+ $[11] = onOpenMemory;
77
+ $[12] = t8;
78
+ } else {
79
+ t8 = $[12];
80
+ }
81
+ t7 = memories.map(t8);
82
+ $[8] = memories;
83
+ $[9] = onOpenMemory;
84
+ $[10] = t7;
85
+ } else {
86
+ t7 = $[10];
87
+ }
88
+ let t8;
89
+ if ($[13] !== t7) {
90
+ t8 = /*#__PURE__*/_jsx(CollapsibleContent, {
91
+ children: /*#__PURE__*/_jsx("ul", {
92
+ className: ruledListClass,
93
+ children: t7
94
+ })
95
+ });
96
+ $[13] = t7;
97
+ $[14] = t8;
98
+ } else {
99
+ t8 = $[14];
100
+ }
101
+ let t9;
102
+ if ($[15] !== defaultOpen || $[16] !== t2 || $[17] !== t6 || $[18] !== t8) {
103
+ t9 = /*#__PURE__*/_jsxs(Collapsible, {
104
+ "data-slot": "recall",
105
+ defaultOpen: defaultOpen,
106
+ className: t2,
107
+ children: [t6, t8]
108
+ });
109
+ $[15] = defaultOpen;
110
+ $[16] = t2;
111
+ $[17] = t6;
112
+ $[18] = t8;
113
+ $[19] = t9;
114
+ } else {
115
+ t9 = $[19];
116
+ }
117
+ return t9;
13
118
  }
14
- function RelevanceMeter({ memory }) {
15
- if (memory.relevance === undefined)
16
- return null;
17
- const percent = relevancePercent(memory.relevance);
18
- return (_jsxs("span", { className: "flex shrink-0 items-center gap-2", children: [_jsx("span", { role: "meter", "aria-label": `Relevance of ${memory.label}`, "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": percent, "aria-valuetext": `${percent}% relevant`, className: "relative h-[3px] w-10 overflow-hidden bg-muted", children: _jsx("span", { className: "absolute inset-y-0 left-0 bg-foreground/60 transition-[width] duration-300 motion-reduce:transition-none", style: { width: `${percent}%` } }) }), _jsxs("span", { className: "w-8 text-right font-mono text-xs text-muted-foreground tabular-nums", children: [percent, "%"] })] }));
119
+ function RelevanceMeter(t0) {
120
+ const $ = _c(14);
121
+ const {
122
+ memory
123
+ } = t0;
124
+ if (memory.relevance === undefined) {
125
+ return null;
126
+ }
127
+ let t1;
128
+ if ($[0] !== memory.relevance) {
129
+ t1 = relevancePercent(memory.relevance);
130
+ $[0] = memory.relevance;
131
+ $[1] = t1;
132
+ } else {
133
+ t1 = $[1];
134
+ }
135
+ const percent = t1;
136
+ const t2 = `Relevance of ${memory.label}`;
137
+ const t3 = `${percent}% relevant`;
138
+ const t4 = `${percent}%`;
139
+ let t5;
140
+ if ($[2] !== t4) {
141
+ t5 = /*#__PURE__*/_jsx("span", {
142
+ className: "absolute inset-y-0 left-0 bg-foreground/60 transition-[width] duration-300 motion-reduce:transition-none",
143
+ style: {
144
+ width: t4
145
+ }
146
+ });
147
+ $[2] = t4;
148
+ $[3] = t5;
149
+ } else {
150
+ t5 = $[3];
151
+ }
152
+ let t6;
153
+ if ($[4] !== percent || $[5] !== t2 || $[6] !== t3 || $[7] !== t5) {
154
+ t6 = /*#__PURE__*/_jsx("span", {
155
+ role: "meter",
156
+ "aria-label": t2,
157
+ "aria-valuemin": 0,
158
+ "aria-valuemax": 100,
159
+ "aria-valuenow": percent,
160
+ "aria-valuetext": t3,
161
+ className: "relative h-[3px] w-10 overflow-hidden bg-muted",
162
+ children: t5
163
+ });
164
+ $[4] = percent;
165
+ $[5] = t2;
166
+ $[6] = t3;
167
+ $[7] = t5;
168
+ $[8] = t6;
169
+ } else {
170
+ t6 = $[8];
171
+ }
172
+ let t7;
173
+ if ($[9] !== percent) {
174
+ t7 = /*#__PURE__*/_jsxs("span", {
175
+ className: "w-8 text-right font-mono text-xs text-muted-foreground tabular-nums",
176
+ children: [percent, "%"]
177
+ });
178
+ $[9] = percent;
179
+ $[10] = t7;
180
+ } else {
181
+ t7 = $[10];
182
+ }
183
+ let t8;
184
+ if ($[11] !== t6 || $[12] !== t7) {
185
+ t8 = /*#__PURE__*/_jsxs("span", {
186
+ className: "flex shrink-0 items-center gap-2",
187
+ children: [t6, t7]
188
+ });
189
+ $[11] = t6;
190
+ $[12] = t7;
191
+ $[13] = t8;
192
+ } else {
193
+ t8 = $[13];
194
+ }
195
+ return t8;
19
196
  }
20
- function RecallRow({ memory, onOpenMemory, }) {
21
- const content = (_jsxs(_Fragment, { children: [_jsxs("span", { className: "flex w-full items-baseline gap-3", children: [_jsx("span", { className: "min-w-0 flex-1 truncate text-sm font-medium", children: memory.label }), _jsx(RelevanceMeter, { memory: memory })] }), (memory.kind || memory.snippet) && (_jsxs("span", { className: "flex w-full gap-2 text-xs text-muted-foreground", children: [memory.kind && _jsx("span", { className: "shrink-0 font-mono", children: memory.kind }), memory.kind && memory.snippet && _jsx("span", { "aria-hidden": true, children: "\u00B7" }), memory.snippet && _jsx("span", { className: "line-clamp-2 min-w-0", children: memory.snippet })] }))] }));
22
- const rowClass = "flex w-full flex-col items-start gap-1 px-3 py-2.5 text-left";
23
- return (_jsx("li", { "data-slot": "recall-item", "data-id": memory.id, children: onOpenMemory ? (_jsx("button", { type: "button", "aria-label": `Open memory ${memory.label}`, onClick: () => onOpenMemory(memory.id), className: cn(rowClass, interactiveRowClass), children: content })) : (_jsx("div", { className: rowClass, children: content })) }));
197
+ function RecallRow(t0) {
198
+ const $ = _c(21);
199
+ const {
200
+ memory,
201
+ onOpenMemory
202
+ } = t0;
203
+ let t1;
204
+ if ($[0] !== memory.label) {
205
+ t1 = /*#__PURE__*/_jsx("span", {
206
+ className: "min-w-0 flex-1 truncate text-sm font-medium",
207
+ children: memory.label
208
+ });
209
+ $[0] = memory.label;
210
+ $[1] = t1;
211
+ } else {
212
+ t1 = $[1];
213
+ }
214
+ let t2;
215
+ if ($[2] !== memory) {
216
+ t2 = /*#__PURE__*/_jsx(RelevanceMeter, {
217
+ memory: memory
218
+ });
219
+ $[2] = memory;
220
+ $[3] = t2;
221
+ } else {
222
+ t2 = $[3];
223
+ }
224
+ let t3;
225
+ if ($[4] !== t1 || $[5] !== t2) {
226
+ t3 = /*#__PURE__*/_jsxs("span", {
227
+ className: "flex w-full items-baseline gap-3",
228
+ children: [t1, t2]
229
+ });
230
+ $[4] = t1;
231
+ $[5] = t2;
232
+ $[6] = t3;
233
+ } else {
234
+ t3 = $[6];
235
+ }
236
+ let t4;
237
+ if ($[7] !== memory.kind || $[8] !== memory.snippet) {
238
+ t4 = (memory.kind || memory.snippet) && /*#__PURE__*/_jsxs("span", {
239
+ className: "flex w-full gap-2 text-xs text-muted-foreground",
240
+ children: [memory.kind && /*#__PURE__*/_jsx("span", {
241
+ className: "shrink-0 font-mono",
242
+ children: memory.kind
243
+ }), memory.kind && memory.snippet && /*#__PURE__*/_jsx("span", {
244
+ "aria-hidden": true,
245
+ children: "\xB7"
246
+ }), memory.snippet && /*#__PURE__*/_jsx("span", {
247
+ className: "line-clamp-2 min-w-0",
248
+ children: memory.snippet
249
+ })]
250
+ });
251
+ $[7] = memory.kind;
252
+ $[8] = memory.snippet;
253
+ $[9] = t4;
254
+ } else {
255
+ t4 = $[9];
256
+ }
257
+ let t5;
258
+ if ($[10] !== t3 || $[11] !== t4) {
259
+ t5 = /*#__PURE__*/_jsxs(_Fragment, {
260
+ children: [t3, t4]
261
+ });
262
+ $[10] = t3;
263
+ $[11] = t4;
264
+ $[12] = t5;
265
+ } else {
266
+ t5 = $[12];
267
+ }
268
+ const content = t5;
269
+ let t6;
270
+ if ($[13] !== content || $[14] !== memory.id || $[15] !== memory.label || $[16] !== onOpenMemory) {
271
+ t6 = onOpenMemory ? /*#__PURE__*/_jsx("button", {
272
+ type: "button",
273
+ "aria-label": `Open memory ${memory.label}`,
274
+ onClick: () => onOpenMemory(memory.id),
275
+ className: cn("flex w-full flex-col items-start gap-1 px-3 py-2.5 text-left", interactiveRowClass),
276
+ children: content
277
+ }) : /*#__PURE__*/_jsx("div", {
278
+ className: "flex w-full flex-col items-start gap-1 px-3 py-2.5 text-left",
279
+ children: content
280
+ });
281
+ $[13] = content;
282
+ $[14] = memory.id;
283
+ $[15] = memory.label;
284
+ $[16] = onOpenMemory;
285
+ $[17] = t6;
286
+ } else {
287
+ t6 = $[17];
288
+ }
289
+ let t7;
290
+ if ($[18] !== memory.id || $[19] !== t6) {
291
+ t7 = /*#__PURE__*/_jsx("li", {
292
+ "data-slot": "recall-item",
293
+ "data-id": memory.id,
294
+ children: t6
295
+ });
296
+ $[18] = memory.id;
297
+ $[19] = t6;
298
+ $[20] = t7;
299
+ } else {
300
+ t7 = $[20];
301
+ }
302
+ return t7;
24
303
  }
@@ -1,34 +1,31 @@
1
1
  export function hostLabel(url) {
2
- if (!url)
3
- return undefined;
4
- try {
5
- return new URL(url).host.replace(/^www\./, "");
6
- }
7
- catch {
8
- return url;
9
- }
2
+ if (!url) return undefined;
3
+ try {
4
+ return new URL(url).host.replace(/^www\./, "");
5
+ } catch {
6
+ return url;
7
+ }
10
8
  }
11
9
  function isSourceUrlPart(item) {
12
- return "type" in item && item.type === "source-url";
10
+ return "type" in item && item.type === "source-url";
13
11
  }
14
12
  export function toCitation(item, position) {
15
- if (!isSourceUrlPart(item))
16
- return item;
17
- return {
18
- index: position + 1,
19
- title: item.title ?? hostLabel(item.url) ?? item.url,
20
- url: item.url,
21
- };
13
+ if (!isSourceUrlPart(item)) return item;
14
+ return {
15
+ index: position + 1,
16
+ title: item.title ?? hostLabel(item.url) ?? item.url,
17
+ url: item.url
18
+ };
22
19
  }
23
20
  export function sourceKey(item, position) {
24
- return isSourceUrlPart(item) ? item.sourceId : `${item.index}:${position}`;
21
+ return isSourceUrlPart(item) ? item.sourceId : `${item.index}:${position}`;
25
22
  }
26
23
  function siteNameOf(host) {
27
- const labels = host.split(".");
28
- return labels.length > 2 ? labels.slice(-2).join(".") : host;
24
+ const labels = host.split(".");
25
+ return labels.length > 2 ? labels.slice(-2).join(".") : host;
29
26
  }
30
27
  export function sourceInitial(citation) {
31
- const host = hostLabel(citation.url);
32
- const name = host ? siteNameOf(host) : citation.title;
33
- return name.trim().charAt(0).toUpperCase() || "?";
28
+ const host = hostLabel(citation.url);
29
+ const name = host ? siteNameOf(host) : citation.title;
30
+ return name.trim().charAt(0).toUpperCase() || "?";
34
31
  }
@@ -1,6 +1,42 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { c as _c } from "react/compiler-runtime";
2
2
  import { cn } from "@locusgraph/components";
3
3
  import { sourceInitial } from "./host-label.js";
4
- export function SourceMark({ citation, className }) {
5
- return (_jsx("span", { "aria-hidden": true, "data-slot": "source-mark", className: cn("flex size-4 shrink-0 items-center justify-center bg-muted font-mono text-[11px] leading-none font-medium text-muted-foreground ring-1 ring-border", className), children: sourceInitial(citation) }));
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ export function SourceMark(t0) {
6
+ const $ = _c(7);
7
+ const {
8
+ citation,
9
+ className
10
+ } = t0;
11
+ let t1;
12
+ if ($[0] !== className) {
13
+ t1 = cn("flex size-4 shrink-0 items-center justify-center bg-muted font-mono text-[11px] leading-none font-medium text-muted-foreground ring-1 ring-border", className);
14
+ $[0] = className;
15
+ $[1] = t1;
16
+ } else {
17
+ t1 = $[1];
18
+ }
19
+ let t2;
20
+ if ($[2] !== citation) {
21
+ t2 = sourceInitial(citation);
22
+ $[2] = citation;
23
+ $[3] = t2;
24
+ } else {
25
+ t2 = $[3];
26
+ }
27
+ let t3;
28
+ if ($[4] !== t1 || $[5] !== t2) {
29
+ t3 = /*#__PURE__*/_jsx("span", {
30
+ "aria-hidden": true,
31
+ "data-slot": "source-mark",
32
+ className: t1,
33
+ children: t2
34
+ });
35
+ $[4] = t1;
36
+ $[5] = t2;
37
+ $[6] = t3;
38
+ } else {
39
+ t3 = $[6];
40
+ }
41
+ return t3;
6
42
  }
@@ -1,22 +1,264 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { c as _c } from "react/compiler-runtime";
2
2
  import { ChevronRight as ChevronRightIcon } from "@carbon/icons-react";
3
3
  import { Collapsible, CollapsibleContent, CollapsibleTrigger, cn } from "@locusgraph/components";
4
4
  import { pluralize } from "@locusgraph/utils";
5
- import { chevronClass, collapsibleTriggerClass, interactiveRowClass, ruledListClass, ruledRowClass, } from "./shared/disclosure.js";
5
+ import { chevronClass, collapsibleTriggerClass, interactiveRowClass, ruledListClass, ruledRowClass } from "./shared/disclosure.js";
6
6
  import { hostLabel, sourceKey, toCitation } from "./shared/host-label.js";
7
7
  import { SourceMark } from "./shared/source-mark.js";
8
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
8
9
  const stackedMarkLimit = 3;
9
- export function Sources({ sources, onOpen, defaultOpen = false, className }) {
10
- if (sources.length === 0)
11
- return null;
10
+ export function Sources(t0) {
11
+ const $ = _c(35);
12
+ const {
13
+ sources,
14
+ onOpen,
15
+ defaultOpen: t1,
16
+ className
17
+ } = t0;
18
+ const defaultOpen = t1 === undefined ? false : t1;
19
+ if (sources.length === 0) {
20
+ return null;
21
+ }
22
+ let T0;
23
+ let T1;
24
+ let t2;
25
+ let t3;
26
+ let t4;
27
+ let t5;
28
+ let t6;
29
+ let t7;
30
+ if ($[0] !== className || $[1] !== defaultOpen || $[2] !== onOpen || $[3] !== sources) {
12
31
  const citations = sources.map(toCitation);
13
- return (_jsxs(Collapsible, { "data-slot": "sources", defaultOpen: defaultOpen, className: cn("flex min-w-0 flex-col gap-2", className), children: [_jsxs(CollapsibleTrigger, { className: collapsibleTriggerClass, children: [_jsx("span", { "aria-hidden": true, className: "flex -space-x-1", children: citations.slice(0, stackedMarkLimit).map((citation, position) => (_jsx(SourceMark, { citation: citation, className: "ring-card" }, sourceKey(sources[position], position)))) }), "Used ", pluralize(sources.length, "source"), _jsx(ChevronRightIcon, { "aria-hidden": true, className: chevronClass })] }), _jsx(CollapsibleContent, { children: _jsx("ol", { className: ruledListClass, children: citations.map((citation, position) => (_jsx(SourceRow, { citation: citation, onOpen: onOpen }, sourceKey(sources[position], position)))) }) })] }));
32
+ T1 = Collapsible;
33
+ t4 = "sources";
34
+ t5 = defaultOpen;
35
+ if ($[12] !== className) {
36
+ t6 = cn("flex min-w-0 flex-col gap-2", className);
37
+ $[12] = className;
38
+ $[13] = t6;
39
+ } else {
40
+ t6 = $[13];
41
+ }
42
+ let t8;
43
+ if ($[14] !== sources) {
44
+ t8 = (citation, position) => /*#__PURE__*/_jsx(SourceMark, {
45
+ citation: citation,
46
+ className: "ring-card"
47
+ }, sourceKey(sources[position], position));
48
+ $[14] = sources;
49
+ $[15] = t8;
50
+ } else {
51
+ t8 = $[15];
52
+ }
53
+ let t9;
54
+ if ($[16] !== sources.length) {
55
+ t9 = pluralize(sources.length, "source");
56
+ $[16] = sources.length;
57
+ $[17] = t9;
58
+ } else {
59
+ t9 = $[17];
60
+ }
61
+ let t10;
62
+ if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
63
+ t10 = /*#__PURE__*/_jsx(ChevronRightIcon, {
64
+ "aria-hidden": true,
65
+ className: chevronClass
66
+ });
67
+ $[18] = t10;
68
+ } else {
69
+ t10 = $[18];
70
+ }
71
+ t7 = /*#__PURE__*/_jsxs(CollapsibleTrigger, {
72
+ className: collapsibleTriggerClass,
73
+ children: [/*#__PURE__*/_jsx("span", {
74
+ "aria-hidden": true,
75
+ className: "flex -space-x-1",
76
+ children: citations.slice(0, stackedMarkLimit).map(t8)
77
+ }), "Used ", t9, t10]
78
+ });
79
+ T0 = CollapsibleContent;
80
+ t2 = ruledListClass;
81
+ let t11;
82
+ if ($[19] !== onOpen || $[20] !== sources) {
83
+ t11 = (citation_0, position_0) => /*#__PURE__*/_jsx(SourceRow, {
84
+ citation: citation_0,
85
+ onOpen: onOpen
86
+ }, sourceKey(sources[position_0], position_0));
87
+ $[19] = onOpen;
88
+ $[20] = sources;
89
+ $[21] = t11;
90
+ } else {
91
+ t11 = $[21];
92
+ }
93
+ t3 = citations.map(t11);
94
+ $[0] = className;
95
+ $[1] = defaultOpen;
96
+ $[2] = onOpen;
97
+ $[3] = sources;
98
+ $[4] = T0;
99
+ $[5] = T1;
100
+ $[6] = t2;
101
+ $[7] = t3;
102
+ $[8] = t4;
103
+ $[9] = t5;
104
+ $[10] = t6;
105
+ $[11] = t7;
106
+ } else {
107
+ T0 = $[4];
108
+ T1 = $[5];
109
+ t2 = $[6];
110
+ t3 = $[7];
111
+ t4 = $[8];
112
+ t5 = $[9];
113
+ t6 = $[10];
114
+ t7 = $[11];
115
+ }
116
+ let t8;
117
+ if ($[22] !== t2 || $[23] !== t3) {
118
+ t8 = /*#__PURE__*/_jsx("ol", {
119
+ className: t2,
120
+ children: t3
121
+ });
122
+ $[22] = t2;
123
+ $[23] = t3;
124
+ $[24] = t8;
125
+ } else {
126
+ t8 = $[24];
127
+ }
128
+ let t9;
129
+ if ($[25] !== T0 || $[26] !== t8) {
130
+ t9 = /*#__PURE__*/_jsx(T0, {
131
+ children: t8
132
+ });
133
+ $[25] = T0;
134
+ $[26] = t8;
135
+ $[27] = t9;
136
+ } else {
137
+ t9 = $[27];
138
+ }
139
+ let t10;
140
+ if ($[28] !== T1 || $[29] !== t4 || $[30] !== t5 || $[31] !== t6 || $[32] !== t7 || $[33] !== t9) {
141
+ t10 = /*#__PURE__*/_jsxs(T1, {
142
+ "data-slot": t4,
143
+ defaultOpen: t5,
144
+ className: t6,
145
+ children: [t7, t9]
146
+ });
147
+ $[28] = T1;
148
+ $[29] = t4;
149
+ $[30] = t5;
150
+ $[31] = t6;
151
+ $[32] = t7;
152
+ $[33] = t9;
153
+ $[34] = t10;
154
+ } else {
155
+ t10 = $[34];
156
+ }
157
+ return t10;
14
158
  }
15
- function SourceRow({ citation, onOpen, }) {
16
- const host = hostLabel(citation.url);
17
- const showHost = host !== undefined && host !== citation.title;
18
- const content = (_jsxs(_Fragment, { children: [_jsx("span", { className: "w-4 shrink-0 font-mono text-xs text-muted-foreground tabular-nums", children: citation.index }), _jsx("span", { className: "min-w-0 flex-1 truncate", children: citation.title }), showHost && (_jsx("span", { className: "max-w-[40%] shrink-0 truncate text-xs text-muted-foreground", children: host }))] }));
19
- const rowClass = ruledRowClass;
20
- const label = `Open source ${citation.index}: ${citation.title}`;
21
- return (_jsx("li", { "data-slot": "sources-item", "data-index": citation.index, children: onOpen ? (_jsx("button", { type: "button", "aria-label": label, onClick: () => onOpen(citation), className: cn(rowClass, interactiveRowClass), children: content })) : citation.url ? (_jsx("a", { href: citation.url, target: "_blank", rel: "noreferrer", "aria-label": label, className: cn(rowClass, interactiveRowClass), children: content })) : (_jsx("div", { className: rowClass, children: content })) }));
159
+ function SourceRow(t0) {
160
+ const $ = _c(21);
161
+ const {
162
+ citation,
163
+ onOpen
164
+ } = t0;
165
+ let t1;
166
+ if ($[0] !== citation.url) {
167
+ t1 = hostLabel(citation.url);
168
+ $[0] = citation.url;
169
+ $[1] = t1;
170
+ } else {
171
+ t1 = $[1];
172
+ }
173
+ const host = t1;
174
+ const showHost = host !== undefined && host !== citation.title;
175
+ let t2;
176
+ if ($[2] !== citation.index) {
177
+ t2 = /*#__PURE__*/_jsx("span", {
178
+ className: "w-4 shrink-0 font-mono text-xs text-muted-foreground tabular-nums",
179
+ children: citation.index
180
+ });
181
+ $[2] = citation.index;
182
+ $[3] = t2;
183
+ } else {
184
+ t2 = $[3];
185
+ }
186
+ let t3;
187
+ if ($[4] !== citation.title) {
188
+ t3 = /*#__PURE__*/_jsx("span", {
189
+ className: "min-w-0 flex-1 truncate",
190
+ children: citation.title
191
+ });
192
+ $[4] = citation.title;
193
+ $[5] = t3;
194
+ } else {
195
+ t3 = $[5];
196
+ }
197
+ let t4;
198
+ if ($[6] !== host || $[7] !== showHost) {
199
+ t4 = showHost && /*#__PURE__*/_jsx("span", {
200
+ className: "max-w-[40%] shrink-0 truncate text-xs text-muted-foreground",
201
+ children: host
202
+ });
203
+ $[6] = host;
204
+ $[7] = showHost;
205
+ $[8] = t4;
206
+ } else {
207
+ t4 = $[8];
208
+ }
209
+ let t5;
210
+ if ($[9] !== t2 || $[10] !== t3 || $[11] !== t4) {
211
+ t5 = /*#__PURE__*/_jsxs(_Fragment, {
212
+ children: [t2, t3, t4]
213
+ });
214
+ $[9] = t2;
215
+ $[10] = t3;
216
+ $[11] = t4;
217
+ $[12] = t5;
218
+ } else {
219
+ t5 = $[12];
220
+ }
221
+ const content = t5;
222
+ const label = `Open source ${citation.index}: ${citation.title}`;
223
+ let t6;
224
+ if ($[13] !== citation || $[14] !== content || $[15] !== label || $[16] !== onOpen) {
225
+ t6 = onOpen ? /*#__PURE__*/_jsx("button", {
226
+ type: "button",
227
+ "aria-label": label,
228
+ onClick: () => onOpen(citation),
229
+ className: cn(ruledRowClass, interactiveRowClass),
230
+ children: content
231
+ }) : citation.url ? /*#__PURE__*/_jsx("a", {
232
+ href: citation.url,
233
+ target: "_blank",
234
+ rel: "noreferrer",
235
+ "aria-label": label,
236
+ className: cn(ruledRowClass, interactiveRowClass),
237
+ children: content
238
+ }) : /*#__PURE__*/_jsx("div", {
239
+ className: ruledRowClass,
240
+ children: content
241
+ });
242
+ $[13] = citation;
243
+ $[14] = content;
244
+ $[15] = label;
245
+ $[16] = onOpen;
246
+ $[17] = t6;
247
+ } else {
248
+ t6 = $[17];
249
+ }
250
+ let t7;
251
+ if ($[18] !== citation.index || $[19] !== t6) {
252
+ t7 = /*#__PURE__*/_jsx("li", {
253
+ "data-slot": "sources-item",
254
+ "data-index": citation.index,
255
+ children: t6
256
+ });
257
+ $[18] = citation.index;
258
+ $[19] = t6;
259
+ $[20] = t7;
260
+ } else {
261
+ t7 = $[20];
262
+ }
263
+ return t7;
22
264
  }