@adoptai/genui-components 0.1.56 → 0.1.58

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/builders/BuilderForm.d.ts.map +1 -1
  2. package/dist/composites/decision-card/resolver.cjs +634 -0
  3. package/dist/composites/decision-card/resolver.cjs.map +1 -0
  4. package/dist/composites/decision-card/resolver.d.ts +13 -0
  5. package/dist/composites/decision-card/resolver.d.ts.map +1 -0
  6. package/dist/composites/decision-card/resolver.js +627 -0
  7. package/dist/composites/decision-card/resolver.js.map +1 -0
  8. package/dist/composites/document-field-extraction/FieldAuditLog.d.ts +27 -0
  9. package/dist/composites/document-field-extraction/FieldAuditLog.d.ts.map +1 -0
  10. package/dist/composites/document-field-extraction/FieldDetail.d.ts +22 -0
  11. package/dist/composites/document-field-extraction/FieldDetail.d.ts.map +1 -0
  12. package/dist/composites/document-field-extraction/FieldDetails.d.ts +18 -0
  13. package/dist/composites/document-field-extraction/FieldDetails.d.ts.map +1 -0
  14. package/dist/composites/document-field-extraction/bboxTransform.d.ts +25 -0
  15. package/dist/composites/document-field-extraction/bboxTransform.d.ts.map +1 -0
  16. package/dist/composites/document-field-extraction/fieldLabels.d.ts +2 -0
  17. package/dist/composites/document-field-extraction/fieldLabels.d.ts.map +1 -0
  18. package/dist/composites/document-field-extraction/resolver.d.ts +16 -0
  19. package/dist/composites/document-field-extraction/resolver.d.ts.map +1 -0
  20. package/dist/composites/workflow-stepper/resolver.cjs +4 -1
  21. package/dist/composites/workflow-stepper/resolver.cjs.map +1 -1
  22. package/dist/composites/workflow-stepper/resolver.js +4 -1
  23. package/dist/composites/workflow-stepper/resolver.js.map +1 -1
  24. package/dist/index.cjs +2735 -382
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.ts +7 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +2530 -183
  29. package/dist/index.js.map +1 -1
  30. package/dist/renderer.cjs +2410 -178
  31. package/dist/renderer.cjs.map +1 -1
  32. package/dist/renderer.js +2267 -35
  33. package/dist/renderer.js.map +1 -1
  34. package/dist/resolver.cjs +2409 -177
  35. package/dist/resolver.cjs.map +1 -1
  36. package/dist/resolver.d.ts.map +1 -1
  37. package/dist/resolver.js +2267 -35
  38. package/dist/resolver.js.map +1 -1
  39. package/dist/schemas/decision-card.d.ts +149 -0
  40. package/dist/schemas/decision-card.d.ts.map +1 -0
  41. package/dist/schemas/document-field-extraction.d.ts +258 -0
  42. package/dist/schemas/document-field-extraction.d.ts.map +1 -0
  43. package/dist/schemas/index.cjs +283 -1
  44. package/dist/schemas/index.cjs.map +1 -1
  45. package/dist/schemas/index.d.ts +407 -0
  46. package/dist/schemas/index.d.ts.map +1 -1
  47. package/dist/schemas/index.js +283 -1
  48. package/dist/schemas/index.js.map +1 -1
  49. package/dist/shared/InteractionContext.d.ts +10 -0
  50. package/dist/shared/InteractionContext.d.ts.map +1 -1
  51. package/dist/tool-definitions.json +359 -3
  52. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"BuilderForm.d.ts","sourceRoot":"","sources":["../../src/builders/BuilderForm.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiC,MAAM,OAAO,CAAC;AAItD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7E;;;kDAGkD;AAClD,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,YAAY,CAAC;IAChD,MAAM,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAA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AC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAC1D;AAED,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,cAAc,EACd,QAAQ,EACR,SAAS,EACT,WAAW,EACX,KAAK,EACL,iBAAiB,GAClB,EAAE,gBAAgB,2CAwHlB"}
@@ -0,0 +1,634 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var React4 = require('react');
5
+ var htmlToImage = require('html-to-image');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
+
10
+ var React4__default = /*#__PURE__*/_interopDefault(React4);
11
+
12
+ // src/shared/theme.ts
13
+ var BORDER = "#dedede";
14
+ var MUTED = "#777777";
15
+ var PAPER = "#f6f6f6";
16
+ var ACCENT = "#ff5000";
17
+ var ACCENT_SOFT = "#cc4000";
18
+ var SECONDARY = "#0364ff";
19
+ var CHART_PALETTE = [
20
+ "#ff5000",
21
+ "#0364ff",
22
+ "#16a34a",
23
+ "#dc2626",
24
+ "#7c3aed",
25
+ "#0891b2",
26
+ "#f59e0b",
27
+ "#6366f1",
28
+ "#ec4899",
29
+ "#84cc16",
30
+ "#e11d48",
31
+ "#0ea5e9"
32
+ ];
33
+ function ColumnSettingsPanel({ columns, hidden, onToggle, onShowAll, onHideAll }) {
34
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "6px", minWidth: "180px" }, children: [
35
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "space-between", paddingBottom: "4px", borderBottom: `1px solid ${BORDER}` }, children: [
36
+ /* @__PURE__ */ jsxRuntime.jsx(
37
+ "button",
38
+ {
39
+ onClick: onShowAll,
40
+ style: { background: "none", border: "none", cursor: "pointer", fontSize: "11px", color: ACCENT, fontWeight: 500, padding: 0 },
41
+ children: "Show all"
42
+ }
43
+ ),
44
+ /* @__PURE__ */ jsxRuntime.jsx(
45
+ "button",
46
+ {
47
+ onClick: onHideAll,
48
+ style: { background: "none", border: "none", cursor: "pointer", fontSize: "11px", color: MUTED, fontWeight: 500, padding: 0 },
49
+ children: "Hide all"
50
+ }
51
+ )
52
+ ] }),
53
+ columns.map((col) => /* @__PURE__ */ jsxRuntime.jsxs(
54
+ "label",
55
+ {
56
+ style: { display: "flex", alignItems: "center", gap: "8px", cursor: "pointer", fontSize: "12px", color: "var(--foreground)" },
57
+ children: [
58
+ /* @__PURE__ */ jsxRuntime.jsx(
59
+ "input",
60
+ {
61
+ type: "checkbox",
62
+ checked: !hidden.has(col.key),
63
+ onChange: () => onToggle(col.key),
64
+ style: { accentColor: ACCENT, width: "14px", height: "14px", margin: 0, cursor: "pointer" }
65
+ }
66
+ ),
67
+ col.label
68
+ ]
69
+ },
70
+ col.key
71
+ ))
72
+ ] });
73
+ }
74
+ var DOT_COLOR = "#aaaaaa";
75
+ var DOT_HOVER = "#555555";
76
+ function ComponentActions({ children, onDownloadCSV, columnConfig, filename = "component" }) {
77
+ const [open, setOpen] = React4.useState(false);
78
+ const [view, setView] = React4.useState("main");
79
+ const contentRef = React4.useRef(null);
80
+ const menuRef = React4.useRef(null);
81
+ const btnRef = React4.useRef(null);
82
+ const close = React4.useCallback(() => {
83
+ setOpen(false);
84
+ setView("main");
85
+ }, []);
86
+ React4.useEffect(() => {
87
+ if (!open) return;
88
+ const handler = (e) => {
89
+ var _a, _b;
90
+ if ((_a = menuRef.current) == null ? void 0 : _a.contains(e.target)) return;
91
+ if ((_b = btnRef.current) == null ? void 0 : _b.contains(e.target)) return;
92
+ close();
93
+ };
94
+ document.addEventListener("mousedown", handler);
95
+ return () => document.removeEventListener("mousedown", handler);
96
+ }, [open, close]);
97
+ const handleDownloadPNG = React4.useCallback(async () => {
98
+ if (!contentRef.current) return;
99
+ try {
100
+ const url = await htmlToImage.toPng(contentRef.current, { backgroundColor: "white", pixelRatio: 2 });
101
+ const a = document.createElement("a");
102
+ a.href = url;
103
+ a.download = `${filename}.png`;
104
+ a.click();
105
+ } catch (e) {
106
+ }
107
+ close();
108
+ }, [filename, close]);
109
+ const handleCSV = React4.useCallback(() => {
110
+ onDownloadCSV == null ? void 0 : onDownloadCSV();
111
+ close();
112
+ }, [onDownloadCSV, close]);
113
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column" }, children: [
114
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: contentRef, style: { width: "100%" }, children }),
115
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "flex-end", marginTop: "4px", position: "relative", zIndex: 10, flexShrink: 0 }, children: [
116
+ /* @__PURE__ */ jsxRuntime.jsx(
117
+ "button",
118
+ {
119
+ ref: btnRef,
120
+ onClick: () => {
121
+ setOpen((o) => !o);
122
+ setView("main");
123
+ },
124
+ "aria-label": "Component actions",
125
+ style: {
126
+ background: "none",
127
+ border: "none",
128
+ cursor: "pointer",
129
+ padding: "4px 8px",
130
+ display: "flex",
131
+ gap: "3px",
132
+ alignItems: "center",
133
+ borderRadius: "6px",
134
+ transition: "background 0.15s"
135
+ },
136
+ onMouseEnter: (e) => {
137
+ e.currentTarget.style.background = "#f2f2f2";
138
+ e.currentTarget.querySelectorAll("circle").forEach((c) => c.style.fill = DOT_HOVER);
139
+ },
140
+ onMouseLeave: (e) => {
141
+ e.currentTarget.style.background = "none";
142
+ e.currentTarget.querySelectorAll("circle").forEach((c) => c.style.fill = DOT_COLOR);
143
+ },
144
+ children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "20", height: "6", viewBox: "0 0 20 6", children: [
145
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "3", cy: "3", r: "2", style: { fill: DOT_COLOR, transition: "fill 0.15s" } }),
146
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "10", cy: "3", r: "2", style: { fill: DOT_COLOR, transition: "fill 0.15s" } }),
147
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "17", cy: "3", r: "2", style: { fill: DOT_COLOR, transition: "fill 0.15s" } })
148
+ ] })
149
+ }
150
+ ),
151
+ open && /* @__PURE__ */ jsxRuntime.jsx(
152
+ "div",
153
+ {
154
+ ref: menuRef,
155
+ style: {
156
+ position: "absolute",
157
+ bottom: "100%",
158
+ right: 0,
159
+ marginBottom: "4px",
160
+ background: "white",
161
+ border: `1px solid ${BORDER}`,
162
+ borderRadius: "0.75rem",
163
+ boxShadow: "0 4px 12px rgba(0,0,0,0.06)",
164
+ zIndex: 50,
165
+ padding: view === "columns" ? "10px" : "4px",
166
+ minWidth: view === "columns" ? "200px" : "160px"
167
+ },
168
+ children: view === "main" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [
169
+ columnConfig && /* @__PURE__ */ jsxRuntime.jsx(MenuButton, { label: "Customize columns", onClick: () => setView("columns") }),
170
+ onDownloadCSV && /* @__PURE__ */ jsxRuntime.jsx(MenuButton, { label: "Download CSV", onClick: handleCSV }),
171
+ /* @__PURE__ */ jsxRuntime.jsx(MenuButton, { label: "Download PNG", onClick: handleDownloadPNG })
172
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
173
+ /* @__PURE__ */ jsxRuntime.jsx(
174
+ "button",
175
+ {
176
+ onClick: () => setView("main"),
177
+ style: { background: "none", border: "none", cursor: "pointer", fontSize: "11px", color: MUTED, marginBottom: "6px", padding: 0 },
178
+ children: "\u2190 Back"
179
+ }
180
+ ),
181
+ /* @__PURE__ */ jsxRuntime.jsx(
182
+ ColumnSettingsPanel,
183
+ {
184
+ columns: columnConfig.columns,
185
+ hidden: columnConfig.hidden,
186
+ onToggle: columnConfig.onToggle,
187
+ onShowAll: columnConfig.onShowAll,
188
+ onHideAll: columnConfig.onHideAll
189
+ }
190
+ )
191
+ ] })
192
+ }
193
+ )
194
+ ] })
195
+ ] });
196
+ }
197
+ function MenuButton({ label, onClick }) {
198
+ return /* @__PURE__ */ jsxRuntime.jsx(
199
+ "button",
200
+ {
201
+ onClick,
202
+ style: {
203
+ background: "none",
204
+ border: "none",
205
+ cursor: "pointer",
206
+ padding: "8px 12px",
207
+ fontSize: "12.5px",
208
+ color: "var(--foreground)",
209
+ textAlign: "left",
210
+ borderRadius: "8px",
211
+ transition: "background 0.15s",
212
+ whiteSpace: "nowrap"
213
+ },
214
+ onMouseEnter: (e) => e.currentTarget.style.background = "#f2f2f2",
215
+ onMouseLeave: (e) => e.currentTarget.style.background = "none",
216
+ children: label
217
+ }
218
+ );
219
+ }
220
+ var DEFAULT_TOKENS = {
221
+ BORDER,
222
+ MUTED,
223
+ PAPER,
224
+ ACCENT,
225
+ ACCENT_SOFT,
226
+ SECONDARY,
227
+ CHART_PALETTE: [...CHART_PALETTE]
228
+ };
229
+ var GenUIThemeContext = React4.createContext(DEFAULT_TOKENS);
230
+ function useTheme() {
231
+ return React4.useContext(GenUIThemeContext);
232
+ }
233
+ var DEFAULT_INTERACTION = {
234
+ selectedStepId: null,
235
+ onStepSelect: void 0,
236
+ resolvedDecisions: void 0,
237
+ onDecisionResolve: void 0,
238
+ onDecisionSource: void 0
239
+ };
240
+ var GenUIInteractionContext = React4.createContext(DEFAULT_INTERACTION);
241
+ function useGenUIInteraction() {
242
+ return React4.useContext(GenUIInteractionContext);
243
+ }
244
+ var SEVERITY_COLORS = {
245
+ high: { color: "#dc2626", bg: "#fef2f2" },
246
+ medium: { color: "#f59e0b", bg: "#fff7ed" },
247
+ low: { color: "#777777", bg: "#f2f2f2" }
248
+ };
249
+ var GREEN = "#15803d";
250
+ var GREEN_SOFT = "#dcfce7";
251
+ var STACK_BELOW = 380;
252
+ function formatAmount(amount, currency = "USD") {
253
+ var _a, _b;
254
+ const abs = Math.abs(amount);
255
+ const sign = amount < 0 ? "-" : "";
256
+ let body;
257
+ if (abs >= 1e6) body = `${(abs / 1e6).toFixed(abs >= 1e7 ? 0 : 1)}M`;
258
+ else if (abs >= 1e3) body = `${(abs / 1e3).toFixed(abs >= 1e4 ? 0 : 1)}K`;
259
+ else body = `${abs}`;
260
+ let symbol = "$";
261
+ try {
262
+ const parts = new Intl.NumberFormat("en-US", {
263
+ style: "currency",
264
+ currency,
265
+ maximumFractionDigits: 0
266
+ }).formatToParts(0);
267
+ symbol = (_b = (_a = parts.find((p) => p.type === "currency")) == null ? void 0 : _a.value) != null ? _b : "$";
268
+ } catch (e) {
269
+ symbol = "$";
270
+ }
271
+ return `${sign}${symbol}${body}`;
272
+ }
273
+ function useContainerWidth(ref) {
274
+ const [w, setW] = React4__default.default.useState(0);
275
+ React4__default.default.useLayoutEffect(() => {
276
+ const el = ref.current;
277
+ if (!el || typeof ResizeObserver === "undefined") return;
278
+ const ro = new ResizeObserver((entries) => {
279
+ var _a;
280
+ const cr = (_a = entries[0]) == null ? void 0 : _a.contentRect;
281
+ if (cr) setW(cr.width);
282
+ });
283
+ ro.observe(el);
284
+ setW(el.getBoundingClientRect().width);
285
+ return () => ro.disconnect();
286
+ }, [ref]);
287
+ return w;
288
+ }
289
+ var KEYFRAMES = `
290
+ @keyframes dcRise{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
291
+ .dc-rise{animation:dcRise 0.28s cubic-bezier(0.22,1,0.36,1) both}
292
+ @media (prefers-reduced-motion: reduce){
293
+ .dc-rise{animation:none !important;opacity:1 !important;transform:none !important}
294
+ }`;
295
+ function SparkCheck({ size, color }) {
296
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(
297
+ "path",
298
+ {
299
+ d: "M5 13l4 4L19 7",
300
+ stroke: color,
301
+ strokeWidth: 2.5,
302
+ strokeLinecap: "round",
303
+ strokeLinejoin: "round"
304
+ }
305
+ ) });
306
+ }
307
+ function FlagPill({ flag }) {
308
+ var _a;
309
+ const sev = (_a = flag.severity) != null ? _a : "medium";
310
+ const { color, bg } = SEVERITY_COLORS[sev];
311
+ return /* @__PURE__ */ jsxRuntime.jsxs(
312
+ "span",
313
+ {
314
+ style: {
315
+ display: "inline-flex",
316
+ alignItems: "center",
317
+ gap: 5,
318
+ fontSize: 11,
319
+ fontWeight: 600,
320
+ padding: "3px 9px",
321
+ borderRadius: 9999,
322
+ background: bg,
323
+ color,
324
+ lineHeight: 1.2
325
+ },
326
+ children: [
327
+ /* @__PURE__ */ jsxRuntime.jsx(
328
+ "span",
329
+ {
330
+ "aria-hidden": "true",
331
+ style: { width: 6, height: 6, borderRadius: "50%", background: color, flexShrink: 0 }
332
+ }
333
+ ),
334
+ flag.field ? `${flag.field}: ${flag.issue}` : flag.issue
335
+ ]
336
+ }
337
+ );
338
+ }
339
+ function DecisionCardRenderer({
340
+ data,
341
+ resolved = null,
342
+ onResolve,
343
+ onOpenSource
344
+ }) {
345
+ var _a, _b;
346
+ const { BORDER: BORDER2, MUTED: MUTED2, ACCENT: ACCENT2, ACCENT_SOFT: ACCENT_SOFT2 } = useTheme();
347
+ const rootRef = React4__default.default.useRef(null);
348
+ const width = useContainerWidth(rootRef);
349
+ const stacked = width > 0 && width < STACK_BELOW;
350
+ const options = (_a = data.options) != null ? _a : [];
351
+ const recommendedIdx = Math.max(
352
+ 0,
353
+ options.findIndex((o) => o.recommended)
354
+ );
355
+ const railColor = data.severity ? SEVERITY_COLORS[data.severity].color : ACCENT2;
356
+ const isResolved = Boolean(resolved);
357
+ const amountNode = typeof data.amount === "number" ? /* @__PURE__ */ jsxRuntime.jsxs(
358
+ "div",
359
+ {
360
+ style: {
361
+ display: "flex",
362
+ flexDirection: "column",
363
+ alignItems: stacked ? "flex-start" : "flex-end",
364
+ gap: 1,
365
+ flexShrink: 0
366
+ },
367
+ children: [
368
+ data.amount_label && /* @__PURE__ */ jsxRuntime.jsx(
369
+ "span",
370
+ {
371
+ style: {
372
+ fontSize: 10,
373
+ textTransform: "uppercase",
374
+ letterSpacing: "0.07em",
375
+ fontWeight: 700,
376
+ color: MUTED2
377
+ },
378
+ children: data.amount_label
379
+ }
380
+ ),
381
+ /* @__PURE__ */ jsxRuntime.jsx(
382
+ "span",
383
+ {
384
+ style: {
385
+ fontSize: 18,
386
+ fontWeight: 700,
387
+ color: "var(--foreground)",
388
+ fontVariantNumeric: "tabular-nums",
389
+ letterSpacing: "-0.01em",
390
+ lineHeight: 1.1
391
+ },
392
+ children: formatAmount(data.amount, data.currency)
393
+ }
394
+ )
395
+ ]
396
+ }
397
+ ) : null;
398
+ return /* @__PURE__ */ jsxRuntime.jsxs(
399
+ "div",
400
+ {
401
+ ref: rootRef,
402
+ className: "dc-rise",
403
+ "data-testid": "decision-card",
404
+ "data-resolved": isResolved || void 0,
405
+ style: {
406
+ position: "relative",
407
+ width: "100%",
408
+ minWidth: 0,
409
+ boxSizing: "border-box",
410
+ borderRadius: "0.75rem",
411
+ border: `1px solid ${isResolved ? GREEN_SOFT : BORDER2}`,
412
+ background: isResolved ? "#f6fef9" : "white",
413
+ boxShadow: "0 1px 2px rgba(0,0,0,0.03), 0 4px 12px rgba(0,0,0,0.04)",
414
+ padding: "16px 18px 16px 20px",
415
+ display: "flex",
416
+ flexDirection: "column",
417
+ gap: 12,
418
+ overflow: "hidden"
419
+ },
420
+ children: [
421
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: KEYFRAMES }),
422
+ /* @__PURE__ */ jsxRuntime.jsx(
423
+ "div",
424
+ {
425
+ "aria-hidden": "true",
426
+ style: {
427
+ position: "absolute",
428
+ top: 0,
429
+ left: 0,
430
+ bottom: 0,
431
+ width: 4,
432
+ background: isResolved ? GREEN : railColor
433
+ }
434
+ }
435
+ ),
436
+ /* @__PURE__ */ jsxRuntime.jsxs(
437
+ "div",
438
+ {
439
+ style: {
440
+ display: "flex",
441
+ flexDirection: stacked ? "column" : "row",
442
+ alignItems: stacked ? "flex-start" : "flex-start",
443
+ justifyContent: "space-between",
444
+ gap: stacked ? 6 : 12
445
+ },
446
+ children: [
447
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { minWidth: 0, display: "flex", flexDirection: "column", gap: 4 }, children: [
448
+ /* @__PURE__ */ jsxRuntime.jsx(
449
+ "span",
450
+ {
451
+ style: {
452
+ fontSize: 10.5,
453
+ textTransform: "uppercase",
454
+ letterSpacing: "0.07em",
455
+ fontWeight: 700,
456
+ color: ACCENT2
457
+ },
458
+ children: data.decision_type ? `Decision needs you \xB7 ${data.decision_type}` : "Decision needs you"
459
+ }
460
+ ),
461
+ /* @__PURE__ */ jsxRuntime.jsx(
462
+ "p",
463
+ {
464
+ style: {
465
+ fontFamily: "var(--font-serif)",
466
+ fontSize: 17,
467
+ fontWeight: 400,
468
+ color: "var(--foreground)",
469
+ letterSpacing: "-0.01em",
470
+ margin: 0,
471
+ lineHeight: 1.2
472
+ },
473
+ children: data.title
474
+ }
475
+ )
476
+ ] }),
477
+ amountNode
478
+ ]
479
+ }
480
+ ),
481
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: { fontSize: 13, lineHeight: 1.5, color: MUTED2, margin: 0 }, children: data.question }),
482
+ data.flags && data.flags.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: 6 }, children: data.flags.map((flag, i) => {
483
+ var _a2;
484
+ return /* @__PURE__ */ jsxRuntime.jsx(FlagPill, { flag }, `${(_a2 = flag.field) != null ? _a2 : "flag"}-${i}`);
485
+ }) }),
486
+ isResolved ? /* @__PURE__ */ jsxRuntime.jsxs(
487
+ "div",
488
+ {
489
+ style: {
490
+ display: "inline-flex",
491
+ alignItems: "center",
492
+ gap: 7,
493
+ fontSize: 13,
494
+ fontWeight: 600,
495
+ color: GREEN
496
+ },
497
+ children: [
498
+ /* @__PURE__ */ jsxRuntime.jsx(SparkCheck, { size: 16, color: GREEN }),
499
+ "Resolved \xB7 ",
500
+ resolved
501
+ ]
502
+ }
503
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
504
+ /* @__PURE__ */ jsxRuntime.jsx(
505
+ "div",
506
+ {
507
+ style: {
508
+ display: "flex",
509
+ flexDirection: stacked ? "column" : "row",
510
+ flexWrap: stacked ? "nowrap" : "wrap",
511
+ gap: 8
512
+ },
513
+ children: options.map((opt, idx) => {
514
+ var _a2;
515
+ const primary = idx === recommendedIdx;
516
+ return /* @__PURE__ */ jsxRuntime.jsx(
517
+ "button",
518
+ {
519
+ type: "button",
520
+ onClick: () => onResolve == null ? void 0 : onResolve(opt.label),
521
+ style: {
522
+ width: stacked ? "100%" : "auto",
523
+ textAlign: stacked ? "left" : "center",
524
+ border: `1px solid ${primary ? ACCENT2 : BORDER2}`,
525
+ background: primary ? ACCENT2 : "white",
526
+ color: primary ? "white" : "var(--foreground)",
527
+ borderRadius: 8,
528
+ fontSize: 13,
529
+ fontWeight: 600,
530
+ padding: "9px 14px",
531
+ cursor: "pointer",
532
+ transition: "background 0.15s, border-color 0.15s, color 0.15s"
533
+ },
534
+ onMouseEnter: (e) => {
535
+ if (primary) {
536
+ e.currentTarget.style.background = ACCENT_SOFT2;
537
+ } else {
538
+ e.currentTarget.style.borderColor = ACCENT2;
539
+ e.currentTarget.style.background = "#fafafa";
540
+ }
541
+ },
542
+ onMouseLeave: (e) => {
543
+ if (primary) {
544
+ e.currentTarget.style.background = ACCENT2;
545
+ } else {
546
+ e.currentTarget.style.borderColor = BORDER2;
547
+ e.currentTarget.style.background = "white";
548
+ }
549
+ },
550
+ children: opt.label
551
+ },
552
+ (_a2 = opt.id) != null ? _a2 : opt.label
553
+ );
554
+ })
555
+ }
556
+ ),
557
+ data.source && /* @__PURE__ */ jsxRuntime.jsxs(
558
+ "button",
559
+ {
560
+ type: "button",
561
+ onClick: onOpenSource,
562
+ style: {
563
+ alignSelf: "flex-start",
564
+ display: "inline-flex",
565
+ alignItems: "center",
566
+ gap: 5,
567
+ border: "none",
568
+ background: "none",
569
+ padding: 0,
570
+ cursor: "pointer",
571
+ fontSize: 12,
572
+ fontWeight: 600,
573
+ color: MUTED2,
574
+ transition: "color 0.15s"
575
+ },
576
+ onMouseEnter: (e) => e.currentTarget.style.color = ACCENT2,
577
+ onMouseLeave: (e) => e.currentTarget.style.color = MUTED2,
578
+ children: [
579
+ /* @__PURE__ */ jsxRuntime.jsx("svg", { width: 13, height: 13, viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(
580
+ "path",
581
+ {
582
+ d: "M14 3v4a1 1 0 001 1h4M5 4a1 1 0 011-1h8l5 5v11a1 1 0 01-1 1H6a1 1 0 01-1-1V4z",
583
+ stroke: "currentColor",
584
+ strokeWidth: 1.8,
585
+ strokeLinecap: "round",
586
+ strokeLinejoin: "round"
587
+ }
588
+ ) }),
589
+ (_b = data.source.label) != null ? _b : "View source for this figure"
590
+ ]
591
+ }
592
+ )
593
+ ] })
594
+ ]
595
+ }
596
+ );
597
+ }
598
+ function DecisionCardResolver(p) {
599
+ var _a, _b, _c, _d;
600
+ const { resolvedDecisions, onDecisionResolve, onDecisionSource } = useGenUIInteraction();
601
+ const decisionId = (_a = p.id) != null ? _a : p.title;
602
+ const hostResolved = resolvedDecisions == null ? void 0 : resolvedDecisions[decisionId];
603
+ const initial = (_c = hostResolved != null ? hostResolved : (_b = p.resolved) == null ? void 0 : _b.option) != null ? _c : null;
604
+ const [localResolved, setLocalResolved] = React4__default.default.useState(initial);
605
+ React4__default.default.useEffect(() => {
606
+ if (hostResolved !== void 0) setLocalResolved(hostResolved);
607
+ }, [hostResolved]);
608
+ const resolved = hostResolved != null ? hostResolved : localResolved;
609
+ const handleResolve = (option) => {
610
+ setLocalResolved(option);
611
+ onDecisionResolve == null ? void 0 : onDecisionResolve(decisionId, option);
612
+ };
613
+ const handleSource = () => {
614
+ var _a2;
615
+ onDecisionSource == null ? void 0 : onDecisionSource(decisionId, p.source);
616
+ if (!onDecisionSource && ((_a2 = p.source) == null ? void 0 : _a2.url) && typeof window !== "undefined") {
617
+ window.open(p.source.url, "_blank", "noopener,noreferrer");
618
+ }
619
+ };
620
+ return /* @__PURE__ */ jsxRuntime.jsx(ComponentActions, { filename: (_d = p.title) != null ? _d : "decision-card", children: /* @__PURE__ */ jsxRuntime.jsx(
621
+ DecisionCardRenderer,
622
+ {
623
+ data: p,
624
+ resolved,
625
+ onResolve: handleResolve,
626
+ onOpenSource: handleSource
627
+ }
628
+ ) });
629
+ }
630
+
631
+ exports.DecisionCardRenderer = DecisionCardRenderer;
632
+ exports.DecisionCardResolver = DecisionCardResolver;
633
+ //# sourceMappingURL=resolver.cjs.map
634
+ //# sourceMappingURL=resolver.cjs.map