@heigin/ui 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 (41) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/dist/components/crm/agent-decision-tree.d.ts +82 -0
  3. package/dist/components/crm/agent-decision-tree.js +580 -0
  4. package/dist/components/crm/agent-decision-tree.module.js +113 -0
  5. package/dist/components/crm/agent-task-trail.d.ts +56 -0
  6. package/dist/components/crm/agent-task-trail.js +419 -0
  7. package/dist/components/crm/agent-thinking.d.ts +36 -0
  8. package/dist/components/crm/agent-thinking.js +443 -0
  9. package/dist/components/crm/agent-thinking.module.js +33 -0
  10. package/dist/components/crm/agent.module.js +81 -0
  11. package/dist/components/crm/crm.module.js +44 -4
  12. package/dist/components/crm/record-header.d.ts +2 -2
  13. package/dist/components/crm/workspace-switcher.d.ts +49 -0
  14. package/dist/components/crm/workspace-switcher.js +205 -0
  15. package/dist/components/ui/avatar.d.ts +9 -1
  16. package/dist/components/ui/avatar.js +61 -4
  17. package/dist/components/ui/avatar.module.js +4 -2
  18. package/dist/components/ui/breadcrumb.d.ts +10 -0
  19. package/dist/components/ui/breadcrumb.js +48 -0
  20. package/dist/components/ui/breadcrumb.module.js +19 -0
  21. package/dist/components/ui/heigin-mark.d.ts +11 -0
  22. package/dist/components/ui/heigin-mark.js +41 -0
  23. package/dist/components/ui/loader.d.ts +21 -0
  24. package/dist/components/ui/loader.js +45 -0
  25. package/dist/components/ui/pagination.d.ts +1 -2
  26. package/dist/components/ui/pagination.js +0 -1
  27. package/dist/components/ui/table.d.ts +9 -1
  28. package/dist/components/ui/table.js +136 -89
  29. package/dist/components/ui/table.module.js +13 -1
  30. package/dist/components/ui/thinking-orb.d.ts +27 -0
  31. package/dist/components/ui/thinking-orb.js +27 -0
  32. package/dist/components/ui/type-motion.d.ts +31 -0
  33. package/dist/components/ui/type-motion.js +394 -0
  34. package/dist/components/ui/type-motion.module.js +31 -0
  35. package/dist/index.d.ts +9 -0
  36. package/dist/index.js +10 -1
  37. package/dist/styles.css +1733 -8
  38. package/dist/tokens.css +1 -1
  39. package/dist/tokens.d.ts +2 -2
  40. package/dist/tokens.js +7 -6
  41. package/package.json +3 -2
@@ -0,0 +1,580 @@
1
+ "use client";
2
+ "use client";
3
+ import { cn } from "../../lib/cn.js";
4
+ import { Button } from "../ui/button.js";
5
+ import { Kbd } from "../ui/kbd.js";
6
+ import { Loader } from "../ui/loader.js";
7
+ import { HeiGinMark } from "../ui/heigin-mark.js";
8
+ import { VisuallyHidden } from "../ui/visually-hidden.js";
9
+ import agent_decision_tree_module_default from "./agent-decision-tree.module.js";
10
+ import * as React from "react";
11
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
+ import { ArrowRight, ArrowUpRight, Check, GitFork, TriangleAlert } from "lucide-react";
13
+ //#region src/components/crm/agent-decision-tree.tsx
14
+ var RISK_LABEL = {
15
+ high: "High risk",
16
+ medium: "Medium risk",
17
+ low: "Low risk"
18
+ };
19
+ function Apps({ items }) {
20
+ if (!items?.length) return null;
21
+ return /* @__PURE__ */ jsx("span", {
22
+ className: agent_decision_tree_module_default.dtApps,
23
+ "aria-hidden": "true",
24
+ children: items.map((a, i) => /* @__PURE__ */ jsx("span", { children: a }, i))
25
+ });
26
+ }
27
+ /**
28
+ * A queue of decisions an agent needs from a person, drawn as a tree: the question, the branches it
29
+ * considered, follow-up options with their consequences, and the agent's own pick. One click (or a
30
+ * number key) commits; the next decision slides in.
31
+ */
32
+ function AgentDecisionTree({ decisions, onDecide, loader = "orb", title = "Decisions", hotkeys = true, empty, className }) {
33
+ const headingId = React.useId();
34
+ const uid = React.useId();
35
+ const [decided, setDecided] = React.useState(() => /* @__PURE__ */ new Set());
36
+ const [cursor, setCursor] = React.useState(0);
37
+ const [chosen, setChosen] = React.useState(null);
38
+ const [hover, setHover] = React.useState(null);
39
+ const [phase, setPhase] = React.useState("choosing");
40
+ const [picked, setPicked] = React.useState(null);
41
+ const [reply, setReply] = React.useState(null);
42
+ const [otherText, setOtherText] = React.useState("");
43
+ const [failed, setFailed] = React.useState(false);
44
+ const stageRef = React.useRef(null);
45
+ const wiresRef = React.useRef(null);
46
+ const otherRef = React.useRef(null);
47
+ const open = decisions.filter((d) => !decided.has(d.id));
48
+ const current = open.length ? open[Math.min(cursor, open.length - 1)] : void 0;
49
+ const branches = current ? [...current.branches, ...current.allowOther === false ? [] : [{
50
+ id: "__other",
51
+ label: "Other…"
52
+ }]] : [];
53
+ const chosenBranch = branches.find((b) => b.id === chosen);
54
+ const focusBranch = chosen ?? hover ?? current?.recommended ?? null;
55
+ const reset = React.useCallback(() => {
56
+ setChosen(null);
57
+ setHover(null);
58
+ setPhase("choosing");
59
+ setPicked(null);
60
+ setReply(null);
61
+ setOtherText("");
62
+ setFailed(false);
63
+ }, []);
64
+ React.useEffect(() => reset(), [current?.id, reset]);
65
+ const commit = async (choice, pickedId) => {
66
+ if (!current || phase !== "choosing") return;
67
+ setPicked(pickedId);
68
+ setPhase("sending");
69
+ setFailed(false);
70
+ let result;
71
+ try {
72
+ result = await onDecide(current, choice);
73
+ } catch {
74
+ setPicked(null);
75
+ setPhase("choosing");
76
+ setFailed(true);
77
+ return;
78
+ }
79
+ if (typeof result === "string") setReply(result);
80
+ setPhase("sent");
81
+ window.setTimeout(() => {
82
+ setPhase("leaving");
83
+ window.setTimeout(() => setDecided((d) => new Set(d).add(current.id)), 320);
84
+ }, typeof result === "string" ? 2200 : 1100);
85
+ };
86
+ const choose = (branch) => {
87
+ if (phase !== "choosing") return;
88
+ setChosen(branch.id);
89
+ setHover(null);
90
+ if (branch.id === "__other") window.setTimeout(() => otherRef.current?.focus(), 30);
91
+ };
92
+ const skip = () => {
93
+ if (open.length < 2 || phase !== "choosing") return;
94
+ setCursor((c) => (Math.min(c, open.length - 1) + 1) % open.length);
95
+ };
96
+ const onKeyDown = (e) => {
97
+ if (!hotkeys || !current || e.metaKey || e.ctrlKey || e.altKey) return;
98
+ if (e.target.tagName === "INPUT") {
99
+ if (e.key === "Escape") reset();
100
+ return;
101
+ }
102
+ const n = Number.parseInt(e.key, 10);
103
+ if (!Number.isNaN(n) && n > 0) {
104
+ if (!chosenBranch) {
105
+ const b = branches[n - 1];
106
+ if (b) {
107
+ e.preventDefault();
108
+ choose(b);
109
+ }
110
+ } else if (chosenBranch.options) {
111
+ const o = chosenBranch.options[n - 1];
112
+ if (o) {
113
+ e.preventDefault();
114
+ commit({
115
+ kind: "option",
116
+ branch: chosenBranch,
117
+ option: o
118
+ }, o.id);
119
+ }
120
+ }
121
+ } else if (e.key === "Escape" && chosen && phase === "choosing") {
122
+ e.preventDefault();
123
+ reset();
124
+ } else if (e.key === "ArrowRight" && !chosen) {
125
+ e.preventDefault();
126
+ skip();
127
+ }
128
+ };
129
+ const draw = React.useCallback(() => {
130
+ const stage = stageRef.current;
131
+ const svg = wiresRef.current;
132
+ if (!stage || !svg) return;
133
+ if (getComputedStyle(svg).display === "none") return;
134
+ const sb = stage.getBoundingClientRect();
135
+ const rel = (el) => {
136
+ const r = el.getBoundingClientRect();
137
+ return {
138
+ l: r.left - sb.left,
139
+ r: r.right - sb.left,
140
+ t: r.top - sb.top,
141
+ b: r.bottom - sb.top,
142
+ cy: r.top - sb.top + r.height / 2,
143
+ h: r.height
144
+ };
145
+ };
146
+ const root = stage.querySelector("[data-dt-root]");
147
+ if (!root) return;
148
+ const rr = rel(root);
149
+ const R = 8;
150
+ const elbow = (x1, y1, xm, x2, y2) => {
151
+ if (Math.abs(y2 - y1) < 1) return `M${x1} ${y1} H${x2}`;
152
+ const s = y2 > y1 ? 1 : -1;
153
+ const r = Math.min(R, Math.abs(y2 - y1) / 2, Math.abs(xm - x1), Math.abs(x2 - xm));
154
+ return `M${x1} ${y1} H${xm - r} Q${xm} ${y1} ${xm} ${y1 + s * r} V${y2 - s * r} Q${xm} ${y2} ${xm + r} ${y2} H${x2}`;
155
+ };
156
+ let out = "";
157
+ stage.querySelectorAll("[data-dt-lane]").forEach((lane) => {
158
+ if (lane.getBoundingClientRect().height < 4) return;
159
+ const hot = lane.dataset.dtLane === lane.closest("[data-focus]")?.getAttribute("data-focus");
160
+ const dim = lane.dataset.dim === "true";
161
+ const cls = cn(hot ? agent_decision_tree_module_default.dtWireHot : agent_decision_tree_module_default.dtWire, dim && agent_decision_tree_module_default.dtWireDim);
162
+ const br = lane.querySelector("[data-dt-branch]");
163
+ if (!br) return;
164
+ const b = rel(br);
165
+ out += `<path class="${cls}" d="${elbow(rr.r, rr.cy, rr.r + 22, b.l, b.cy)}"/>`;
166
+ const ask = lane.querySelector("[data-dt-ask]");
167
+ if (ask) {
168
+ const a = rel(ask);
169
+ out += `<path class="${cls}" d="${elbow(b.r, b.cy, b.r + 18, a.l, a.cy)}"/>`;
170
+ const x = a.l + 13;
171
+ lane.querySelectorAll("[data-dt-opt], [data-dt-pill]").forEach((o) => {
172
+ const r = rel(o);
173
+ const y = r.t + Math.min(19, r.h / 2);
174
+ out += `<path class="${o.hasAttribute("data-dt-pill") ? agent_decision_tree_module_default.dtWireHot : cls}" d="M${x} ${a.b} V${y - R} Q${x} ${y} ${x + R} ${y} H${r.l}"/>`;
175
+ });
176
+ }
177
+ const oc = lane.querySelector("[data-dt-outcome]");
178
+ if (oc) out += `<path class="${cls}" d="M${b.r} ${b.cy} H${rel(oc).l}"/>`;
179
+ const pill = !ask ? lane.querySelector("[data-dt-pill]") : null;
180
+ if (pill) {
181
+ const p = rel(pill);
182
+ out += `<path class="${agent_decision_tree_module_default.dtWireHot}" d="${elbow(b.r, b.cy, b.r + 18, p.l, p.cy)}"/>`;
183
+ }
184
+ });
185
+ svg.innerHTML = out;
186
+ }, []);
187
+ React.useLayoutEffect(() => {
188
+ let raf = 0;
189
+ const until = performance.now() + 700;
190
+ const loop = () => {
191
+ draw();
192
+ if (performance.now() < until) raf = requestAnimationFrame(loop);
193
+ };
194
+ loop();
195
+ return () => cancelAnimationFrame(raf);
196
+ }, [
197
+ draw,
198
+ current?.id,
199
+ chosen,
200
+ hover,
201
+ phase,
202
+ reply
203
+ ]);
204
+ React.useEffect(() => {
205
+ const stage = stageRef.current;
206
+ if (!stage || typeof ResizeObserver === "undefined") return;
207
+ const ro = new ResizeObserver(() => draw());
208
+ ro.observe(stage);
209
+ return () => ro.disconnect();
210
+ }, [draw, current?.id]);
211
+ const pill = phase === "sending" || phase === "sent" || phase === "leaving" ? reply ? /* @__PURE__ */ jsxs("div", {
212
+ className: agent_decision_tree_module_default.dtReply,
213
+ "data-dt-pill": true,
214
+ role: "status",
215
+ children: [/* @__PURE__ */ jsxs("b", { children: [
216
+ /* @__PURE__ */ jsx(ArrowUpRight, {
217
+ "aria-hidden": "true",
218
+ strokeWidth: 1.8
219
+ }),
220
+ "Sent to the ",
221
+ current?.agent.name.toLowerCase()
222
+ ] }), /* @__PURE__ */ jsx("p", { children: reply })]
223
+ }) : /* @__PURE__ */ jsxs("div", {
224
+ className: agent_decision_tree_module_default.dtPill,
225
+ "data-dt-pill": true,
226
+ role: "status",
227
+ children: [
228
+ phase === "sending" ? /* @__PURE__ */ jsx(Loader, {
229
+ variant: loader,
230
+ size: "sm",
231
+ label: null
232
+ }) : /* @__PURE__ */ jsx(Check, {
233
+ "aria-hidden": "true",
234
+ strokeWidth: 2
235
+ }),
236
+ /* @__PURE__ */ jsx("b", { children: phase === "sending" ? "Sending" : "Approved" }),
237
+ /* @__PURE__ */ jsxs("span", { children: ["· ", phase === "sending" ? "telling the agent" : "running"] })
238
+ ]
239
+ }) : null;
240
+ const waiting = open.length;
241
+ return /* @__PURE__ */ jsxs("section", {
242
+ className: cn(agent_decision_tree_module_default.dt, className),
243
+ "aria-labelledby": headingId,
244
+ onKeyDown,
245
+ children: [
246
+ /* @__PURE__ */ jsxs("header", {
247
+ className: agent_decision_tree_module_default.dtTop,
248
+ children: [
249
+ /* @__PURE__ */ jsx(GitFork, {
250
+ className: agent_decision_tree_module_default.dtLogo,
251
+ "aria-hidden": "true",
252
+ strokeWidth: 1.8
253
+ }),
254
+ /* @__PURE__ */ jsx("h3", {
255
+ id: headingId,
256
+ className: agent_decision_tree_module_default.dtTitle,
257
+ children: title
258
+ }),
259
+ /* @__PURE__ */ jsx("span", {
260
+ className: agent_decision_tree_module_default.dtWaiting,
261
+ children: waiting ? `${waiting} waiting for you` : `${decisions.length} of ${decisions.length} decided`
262
+ }),
263
+ waiting > 0 && /* @__PURE__ */ jsxs("span", {
264
+ className: agent_decision_tree_module_default.dtPager,
265
+ children: [
266
+ /* @__PURE__ */ jsx("span", {
267
+ className: agent_decision_tree_module_default.dtDots,
268
+ "aria-hidden": "true",
269
+ children: open.map((d) => /* @__PURE__ */ jsx("i", { "data-on": d.id === current?.id }, d.id))
270
+ }),
271
+ Math.min(cursor, open.length - 1) + 1,
272
+ " of ",
273
+ open.length
274
+ ]
275
+ })
276
+ ]
277
+ }),
278
+ !current ? /* @__PURE__ */ jsx("div", {
279
+ className: agent_decision_tree_module_default.dtEmpty,
280
+ role: "status",
281
+ children: empty ?? /* @__PURE__ */ jsxs(Fragment, { children: [
282
+ /* @__PURE__ */ jsx("span", {
283
+ className: agent_decision_tree_module_default.dtEmptyIcon,
284
+ "aria-hidden": "true",
285
+ children: /* @__PURE__ */ jsx(Check, { strokeWidth: 2 })
286
+ }),
287
+ /* @__PURE__ */ jsx("b", { children: "All decided" }),
288
+ /* @__PURE__ */ jsx("p", { children: "New decisions from your agents show up here." })
289
+ ] })
290
+ }) : /* @__PURE__ */ jsx("div", {
291
+ className: agent_decision_tree_module_default.dtScroll,
292
+ children: /* @__PURE__ */ jsxs("article", {
293
+ ref: stageRef,
294
+ className: agent_decision_tree_module_default.dtStage,
295
+ "data-phase": phase,
296
+ "data-focus": focusBranch ?? void 0,
297
+ "aria-labelledby": `${uid}-q`,
298
+ children: [
299
+ /* @__PURE__ */ jsx("svg", {
300
+ ref: wiresRef,
301
+ className: agent_decision_tree_module_default.dtWires,
302
+ "aria-hidden": "true"
303
+ }),
304
+ /* @__PURE__ */ jsxs("div", {
305
+ className: agent_decision_tree_module_default.dtRoot,
306
+ children: [current.risk && /* @__PURE__ */ jsx("span", {
307
+ className: agent_decision_tree_module_default.dtRisk,
308
+ "data-risk": current.risk,
309
+ children: RISK_LABEL[current.risk]
310
+ }), /* @__PURE__ */ jsxs("div", {
311
+ className: agent_decision_tree_module_default.dtRootCard,
312
+ "data-dt-root": true,
313
+ children: [
314
+ /* @__PURE__ */ jsxs("div", {
315
+ className: agent_decision_tree_module_default.dtAgent,
316
+ children: [/* @__PURE__ */ jsx("span", {
317
+ className: agent_decision_tree_module_default.dtMark,
318
+ children: current.agent.icon ?? /* @__PURE__ */ jsx(HeiGinMark, { size: 16 })
319
+ }), /* @__PURE__ */ jsxs("span", { children: [/* @__PURE__ */ jsx("b", { children: current.agent.name }), current.agent.model && /* @__PURE__ */ jsx("small", { children: current.agent.model })] })]
320
+ }),
321
+ /* @__PURE__ */ jsx("p", {
322
+ id: `${uid}-q`,
323
+ className: agent_decision_tree_module_default.dtQuestion,
324
+ children: current.question
325
+ }),
326
+ current.context && /* @__PURE__ */ jsx("p", {
327
+ className: agent_decision_tree_module_default.dtContext,
328
+ children: current.context
329
+ })
330
+ ]
331
+ })]
332
+ }),
333
+ /* @__PURE__ */ jsx("ol", {
334
+ className: agent_decision_tree_module_default.dtLanes,
335
+ "aria-label": "Options",
336
+ children: branches.map((b, i) => {
337
+ const isChosen = chosen === b.id;
338
+ const gone = chosen !== null && !isChosen;
339
+ const dim = chosen === null && hover !== null && hover !== b.id;
340
+ const isOther = b.id === "__other";
341
+ const recommended = current.recommended === b.id;
342
+ return /* @__PURE__ */ jsx("li", {
343
+ className: agent_decision_tree_module_default.dtLane,
344
+ "data-dt-lane": b.id,
345
+ "data-gone": gone,
346
+ "data-dim": dim,
347
+ "aria-hidden": gone || void 0,
348
+ children: /* @__PURE__ */ jsxs("div", {
349
+ className: agent_decision_tree_module_default.dtLaneInner,
350
+ children: [
351
+ isOther && isChosen ? /* @__PURE__ */ jsxs("form", {
352
+ className: agent_decision_tree_module_default.dtBranch,
353
+ "data-dt-branch": true,
354
+ "data-hot": "true",
355
+ onSubmit: (e) => {
356
+ e.preventDefault();
357
+ const text = otherText.trim();
358
+ if (text) commit({
359
+ kind: "other",
360
+ text
361
+ }, "__other");
362
+ },
363
+ children: [
364
+ /* @__PURE__ */ jsxs("label", {
365
+ htmlFor: `${uid}-other`,
366
+ className: agent_decision_tree_module_default.srOnly,
367
+ children: [
368
+ "Tell the ",
369
+ current.agent.name.toLowerCase(),
370
+ " what to do instead"
371
+ ]
372
+ }),
373
+ /* @__PURE__ */ jsx("input", {
374
+ ref: otherRef,
375
+ id: `${uid}-other`,
376
+ className: agent_decision_tree_module_default.dtOtherInput,
377
+ value: otherText,
378
+ disabled: phase !== "choosing",
379
+ placeholder: "Tell the agent what to do instead…",
380
+ onChange: (e) => setOtherText(e.target.value)
381
+ }),
382
+ /* @__PURE__ */ jsx("button", {
383
+ type: "submit",
384
+ className: agent_decision_tree_module_default.dtSend,
385
+ disabled: !otherText.trim() || phase !== "choosing",
386
+ "aria-label": "Send instruction",
387
+ children: /* @__PURE__ */ jsx(ArrowRight, {
388
+ "aria-hidden": "true",
389
+ strokeWidth: 1.8
390
+ })
391
+ })
392
+ ]
393
+ }) : /* @__PURE__ */ jsxs("button", {
394
+ type: "button",
395
+ className: cn(agent_decision_tree_module_default.dtBranch, isOther && agent_decision_tree_module_default.dtBranchOther),
396
+ "data-dt-branch": true,
397
+ "data-hot": focusBranch === b.id,
398
+ "aria-expanded": b.options || isOther ? isChosen : void 0,
399
+ "aria-pressed": !b.options && !isOther ? isChosen : void 0,
400
+ tabIndex: gone ? -1 : void 0,
401
+ onMouseEnter: () => chosen === null && setHover(b.id),
402
+ onMouseLeave: () => chosen === null && setHover(null),
403
+ onFocus: () => chosen === null && setHover(b.id),
404
+ onBlur: () => chosen === null && setHover(null),
405
+ onClick: () => isChosen ? void 0 : choose(b),
406
+ children: [
407
+ /* @__PURE__ */ jsx("span", {
408
+ className: agent_decision_tree_module_default.dtNum,
409
+ "aria-hidden": "true",
410
+ children: i + 1
411
+ }),
412
+ b.icon && /* @__PURE__ */ jsx("span", {
413
+ className: agent_decision_tree_module_default.dtIco,
414
+ "aria-hidden": "true",
415
+ children: b.icon
416
+ }),
417
+ /* @__PURE__ */ jsx("span", {
418
+ className: agent_decision_tree_module_default.dtLbl,
419
+ children: b.label
420
+ }),
421
+ recommended && /* @__PURE__ */ jsx("span", {
422
+ className: agent_decision_tree_module_default.dtPick,
423
+ children: "Agent’s pick"
424
+ })
425
+ ]
426
+ }),
427
+ b.question && b.options && /* @__PURE__ */ jsxs("div", {
428
+ className: agent_decision_tree_module_default.dtSub,
429
+ children: [/* @__PURE__ */ jsx("div", {
430
+ className: agent_decision_tree_module_default.dtAsk,
431
+ "data-dt-ask": true,
432
+ children: b.question
433
+ }), /* @__PURE__ */ jsx("ul", {
434
+ className: agent_decision_tree_module_default.dtOpts,
435
+ children: b.options.map((o, k) => {
436
+ const noteId = o.note ? `${uid}-${b.id}-${o.id}-note` : void 0;
437
+ return /* @__PURE__ */ jsxs(React.Fragment, { children: [/* @__PURE__ */ jsxs("li", {
438
+ className: agent_decision_tree_module_default.dtOptItem,
439
+ children: [/* @__PURE__ */ jsxs("button", {
440
+ type: "button",
441
+ className: agent_decision_tree_module_default.dtOpt,
442
+ "data-dt-opt": true,
443
+ "data-faded": picked !== null && picked !== o.id,
444
+ "aria-describedby": noteId,
445
+ tabIndex: isChosen ? void 0 : -1,
446
+ disabled: phase !== "choosing",
447
+ onClick: () => {
448
+ if (!isChosen) choose(b);
449
+ commit({
450
+ kind: "option",
451
+ branch: b,
452
+ option: o
453
+ }, o.id);
454
+ },
455
+ children: [
456
+ /* @__PURE__ */ jsx("span", {
457
+ className: agent_decision_tree_module_default.dtNum,
458
+ "aria-hidden": "true",
459
+ "data-show": isChosen,
460
+ children: k + 1
461
+ }),
462
+ /* @__PURE__ */ jsxs("span", {
463
+ className: agent_decision_tree_module_default.dtOptTitle,
464
+ children: [
465
+ o.icon && /* @__PURE__ */ jsx("span", {
466
+ className: agent_decision_tree_module_default.dtIco,
467
+ "aria-hidden": "true",
468
+ children: o.icon
469
+ }),
470
+ o.label,
471
+ b.recommendedOption === o.id && /* @__PURE__ */ jsx("em", { children: "Agent’s pick" })
472
+ ]
473
+ }),
474
+ /* @__PURE__ */ jsxs("span", {
475
+ className: agent_decision_tree_module_default.dtOptMeta,
476
+ children: [o.warning ? /* @__PURE__ */ jsx("span", {
477
+ className: agent_decision_tree_module_default.dtWarn,
478
+ children: o.warning
479
+ }) : o.detail, /* @__PURE__ */ jsx(Apps, { items: o.apps })]
480
+ })
481
+ ]
482
+ }), o.note && /* @__PURE__ */ jsxs("span", {
483
+ className: agent_decision_tree_module_default.dtNote,
484
+ id: noteId,
485
+ role: "note",
486
+ children: [
487
+ /* @__PURE__ */ jsxs("small", { children: [/* @__PURE__ */ jsx(TriangleAlert, {
488
+ "aria-hidden": "true",
489
+ strokeWidth: 2
490
+ }), "Agent’s note"] }),
491
+ /* @__PURE__ */ jsx("span", {
492
+ className: agent_decision_tree_module_default.dtNoteText,
493
+ children: o.note.text
494
+ }),
495
+ o.note.source && /* @__PURE__ */ jsx("span", {
496
+ className: agent_decision_tree_module_default.dtNoteSrc,
497
+ children: o.note.source
498
+ })
499
+ ]
500
+ })]
501
+ }), isChosen && picked === o.id && pill && /* @__PURE__ */ jsx("li", {
502
+ className: agent_decision_tree_module_default.dtOptItem,
503
+ children: pill
504
+ })] }, o.id);
505
+ })
506
+ })]
507
+ }),
508
+ b.outcome !== void 0 && /* @__PURE__ */ jsxs("div", {
509
+ className: agent_decision_tree_module_default.dtOutcome,
510
+ "data-dt-outcome": true,
511
+ children: [/* @__PURE__ */ jsx("span", { children: b.outcome }), /* @__PURE__ */ jsx(Apps, { items: b.apps })]
512
+ }),
513
+ isChosen && b.outcome !== void 0 && phase === "choosing" && /* @__PURE__ */ jsx(Button, {
514
+ size: "sm",
515
+ touch: false,
516
+ onClick: () => commit({
517
+ kind: "outcome",
518
+ branch: b
519
+ }, b.id),
520
+ children: "Confirm"
521
+ }),
522
+ isChosen && !b.options && pill
523
+ ]
524
+ })
525
+ }, b.id);
526
+ })
527
+ })
528
+ ]
529
+ }, current.id)
530
+ }),
531
+ current && /* @__PURE__ */ jsx("footer", {
532
+ className: agent_decision_tree_module_default.dtFoot,
533
+ children: !chosenBranch ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("span", { children: [
534
+ "Pick a branch ",
535
+ /* @__PURE__ */ jsx(Kbd, { children: "1" }),
536
+ " – ",
537
+ /* @__PURE__ */ jsx(Kbd, { children: branches.length })
538
+ ] }), open.length > 1 && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
539
+ "aria-hidden": "true",
540
+ children: "·"
541
+ }), /* @__PURE__ */ jsxs("button", {
542
+ type: "button",
543
+ className: agent_decision_tree_module_default.dtLink,
544
+ onClick: skip,
545
+ children: ["Next ", /* @__PURE__ */ jsx(Kbd, {
546
+ "aria-hidden": "true",
547
+ children: "→"
548
+ })]
549
+ })] })] }) : phase === "choosing" ? /* @__PURE__ */ jsxs(Fragment, { children: [
550
+ failed && /* @__PURE__ */ jsx("span", {
551
+ className: agent_decision_tree_module_default.dtFailed,
552
+ role: "alert",
553
+ children: "Couldn’t send that to the agent. Try again."
554
+ }),
555
+ /* @__PURE__ */ jsx("span", { children: chosenBranch.options ? /* @__PURE__ */ jsxs(Fragment, { children: [
556
+ "Then ",
557
+ /* @__PURE__ */ jsx(Kbd, { children: "1" }),
558
+ " – ",
559
+ /* @__PURE__ */ jsx(Kbd, { children: chosenBranch.options.length })
560
+ ] }) : chosenBranch.id === "__other" ? "Type your instruction, then press Enter" : "Confirm to send it" }),
561
+ /* @__PURE__ */ jsx("span", {
562
+ "aria-hidden": "true",
563
+ children: "·"
564
+ }),
565
+ /* @__PURE__ */ jsxs("button", {
566
+ type: "button",
567
+ className: agent_decision_tree_module_default.dtLink,
568
+ onClick: reset,
569
+ children: ["Back ", /* @__PURE__ */ jsx(Kbd, {
570
+ "aria-hidden": "true",
571
+ children: "esc"
572
+ })]
573
+ })
574
+ ] }) : /* @__PURE__ */ jsx(VisuallyHidden, { children: "Sending your decision" })
575
+ })
576
+ ]
577
+ });
578
+ }
579
+ //#endregion
580
+ export { AgentDecisionTree };
@@ -0,0 +1,113 @@
1
+ //#region src/components/crm/agent-decision-tree.module.css
2
+ var srOnly = "hg-agent-decision-tree-module_srOnly_Piwqr";
3
+ var dt = "hg-agent-decision-tree-module_dt_n4h7f";
4
+ var dtTop = "hg-agent-decision-tree-module_dtTop_lgQ2j";
5
+ var dtLogo = "hg-agent-decision-tree-module_dtLogo_gVm3w";
6
+ var dtTitle = "hg-agent-decision-tree-module_dtTitle_kFCzA";
7
+ var dtWaiting = "hg-agent-decision-tree-module_dtWaiting_F5R1i";
8
+ var dtPager = "hg-agent-decision-tree-module_dtPager_SF12d";
9
+ var dtDots = "hg-agent-decision-tree-module_dtDots_-hCCb";
10
+ var dtScroll = "hg-agent-decision-tree-module_dtScroll_bjmaQ";
11
+ var dtStage = "hg-agent-decision-tree-module_dtStage_uiEo6";
12
+ var dtIn = "hg-agent-decision-tree-module_dtIn_9iYEc";
13
+ var dtWires = "hg-agent-decision-tree-module_dtWires_4V1W3";
14
+ var dtWire = "hg-agent-decision-tree-module_dtWire_Gordj";
15
+ var dtWireHot = "hg-agent-decision-tree-module_dtWireHot_s56q4";
16
+ var dtWireDim = "hg-agent-decision-tree-module_dtWireDim_HxiD7";
17
+ var dtRoot = "hg-agent-decision-tree-module_dtRoot_Bu5k1";
18
+ var dtRisk = "hg-agent-decision-tree-module_dtRisk_MtpJI";
19
+ var dtRootCard = "hg-agent-decision-tree-module_dtRootCard_DdreP";
20
+ var dtAgent = "hg-agent-decision-tree-module_dtAgent_9j4Se";
21
+ var dtMark = "hg-agent-decision-tree-module_dtMark_ac-Ke";
22
+ var dtQuestion = "hg-agent-decision-tree-module_dtQuestion_pXC9y";
23
+ var dtContext = "hg-agent-decision-tree-module_dtContext_eV8Ci";
24
+ var dtLanes = "hg-agent-decision-tree-module_dtLanes_KT3iG";
25
+ var dtLane = "hg-agent-decision-tree-module_dtLane_-sRZ6";
26
+ var dtLaneInner = "hg-agent-decision-tree-module_dtLaneInner_YKXNl";
27
+ var dtBranch = "hg-agent-decision-tree-module_dtBranch_5jAba";
28
+ var dtOpt = "hg-agent-decision-tree-module_dtOpt_xLn2Q";
29
+ var dtSend = "hg-agent-decision-tree-module_dtSend_ytpTY";
30
+ var dtLink = "hg-agent-decision-tree-module_dtLink_DVIVz";
31
+ var dtBranchOther = "hg-agent-decision-tree-module_dtBranchOther_9cljQ";
32
+ var dtLbl = "hg-agent-decision-tree-module_dtLbl_Gi30W";
33
+ var dtPick = "hg-agent-decision-tree-module_dtPick_vlmrl";
34
+ var dtNum = "hg-agent-decision-tree-module_dtNum_iLLZa";
35
+ var dtIco = "hg-agent-decision-tree-module_dtIco_-ppXY";
36
+ var dtOtherInput = "hg-agent-decision-tree-module_dtOtherInput_W0s5v";
37
+ var dtSub = "hg-agent-decision-tree-module_dtSub_wEI7f";
38
+ var dtAsk = "hg-agent-decision-tree-module_dtAsk_Kz19A";
39
+ var dtOpts = "hg-agent-decision-tree-module_dtOpts_QzUaV";
40
+ var dtOptItem = "hg-agent-decision-tree-module_dtOptItem_0bdyF";
41
+ var dtOptTitle = "hg-agent-decision-tree-module_dtOptTitle_KUvXG";
42
+ var dtOptMeta = "hg-agent-decision-tree-module_dtOptMeta_-Bilc";
43
+ var dtWarn = "hg-agent-decision-tree-module_dtWarn_p6qsQ";
44
+ var dtApps = "hg-agent-decision-tree-module_dtApps_Y4P32";
45
+ var dtNote = "hg-agent-decision-tree-module_dtNote_OLScq";
46
+ var dtNoteText = "hg-agent-decision-tree-module_dtNoteText_F5cvB";
47
+ var dtNoteSrc = "hg-agent-decision-tree-module_dtNoteSrc_bzm2i";
48
+ var dtOutcome = "hg-agent-decision-tree-module_dtOutcome_qB0c3";
49
+ var dtPill = "hg-agent-decision-tree-module_dtPill_expBc";
50
+ var dtPop = "hg-agent-decision-tree-module_dtPop_i9Gfg";
51
+ var dtReply = "hg-agent-decision-tree-module_dtReply_PlEPM";
52
+ var dtFoot = "hg-agent-decision-tree-module_dtFoot_-nmHQ";
53
+ var dtFailed = "hg-agent-decision-tree-module_dtFailed_4xRXr";
54
+ var dtEmpty = "hg-agent-decision-tree-module_dtEmpty_fAkqm";
55
+ var dtEmptyIcon = "hg-agent-decision-tree-module_dtEmptyIcon_zRykg";
56
+ var agent_decision_tree_module_default = {
57
+ srOnly,
58
+ dt,
59
+ dtTop,
60
+ dtLogo,
61
+ dtTitle,
62
+ dtWaiting,
63
+ dtPager,
64
+ dtDots,
65
+ dtScroll,
66
+ dtStage,
67
+ dtIn,
68
+ dtWires,
69
+ dtWire,
70
+ dtWireHot,
71
+ dtWireDim,
72
+ dtRoot,
73
+ dtRisk,
74
+ dtRootCard,
75
+ dtAgent,
76
+ dtMark,
77
+ dtQuestion,
78
+ dtContext,
79
+ dtLanes,
80
+ dtLane,
81
+ dtLaneInner,
82
+ dtBranch,
83
+ dtOpt,
84
+ dtSend,
85
+ dtLink,
86
+ dtBranchOther,
87
+ dtLbl,
88
+ dtPick,
89
+ dtNum,
90
+ dtIco,
91
+ dtOtherInput,
92
+ dtSub,
93
+ dtAsk,
94
+ dtOpts,
95
+ dtOptItem,
96
+ dtOptTitle,
97
+ dtOptMeta,
98
+ dtWarn,
99
+ dtApps,
100
+ dtNote,
101
+ dtNoteText,
102
+ dtNoteSrc,
103
+ dtOutcome,
104
+ dtPill,
105
+ dtPop,
106
+ dtReply,
107
+ dtFoot,
108
+ dtFailed,
109
+ dtEmpty,
110
+ dtEmptyIcon
111
+ };
112
+ //#endregion
113
+ export { agent_decision_tree_module_default as default, dt, dtAgent, dtApps, dtAsk, dtBranch, dtBranchOther, dtContext, dtDots, dtEmpty, dtEmptyIcon, dtFailed, dtFoot, dtIco, dtIn, dtLane, dtLaneInner, dtLanes, dtLbl, dtLink, dtLogo, dtMark, dtNote, dtNoteSrc, dtNoteText, dtNum, dtOpt, dtOptItem, dtOptMeta, dtOptTitle, dtOpts, dtOtherInput, dtOutcome, dtPager, dtPick, dtPill, dtPop, dtQuestion, dtReply, dtRisk, dtRoot, dtRootCard, dtScroll, dtSend, dtStage, dtSub, dtTitle, dtTop, dtWaiting, dtWarn, dtWire, dtWireDim, dtWireHot, dtWires, srOnly };