@epam/ai-dial-conversation-stages 1.2.0-dev.99 → 1.2.0-rc.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 (36) hide show
  1. package/components/CollapsedGroup/CollapsedGroup.d.ts.map +1 -1
  2. package/components/StageItem/StageItem.d.ts +11 -3
  3. package/components/StageItem/StageItem.d.ts.map +1 -1
  4. package/components/StageList/StageList.d.ts +29 -0
  5. package/components/StageList/StageList.d.ts.map +1 -0
  6. package/components/StageMarkdownContent/StageCodeBlock.d.ts +4 -2
  7. package/components/StageMarkdownContent/StageCodeBlock.d.ts.map +1 -1
  8. package/components/StageMarkdownContent/StageMarkdownContent.d.ts +6 -0
  9. package/components/StageMarkdownContent/StageMarkdownContent.d.ts.map +1 -1
  10. package/components/StagesPanel/StagesPanel.d.ts +15 -1
  11. package/components/StagesPanel/StagesPanel.d.ts.map +1 -1
  12. package/constants/stage-accordion.d.ts +11 -0
  13. package/constants/stage-accordion.d.ts.map +1 -0
  14. package/hooks/useStageExpansion/useStageExpansion.d.ts +9 -0
  15. package/hooks/useStageExpansion/useStageExpansion.d.ts.map +1 -0
  16. package/index.css +2 -2
  17. package/index.js +790 -426
  18. package/models/collapsed-group.d.ts +12 -6
  19. package/models/collapsed-group.d.ts.map +1 -1
  20. package/models/stage-grouping.d.ts +6 -6
  21. package/models/stage-grouping.d.ts.map +1 -1
  22. package/models/stage-tree.d.ts +21 -0
  23. package/models/stage-tree.d.ts.map +1 -0
  24. package/models/stages-props.d.ts +15 -5
  25. package/models/stages-props.d.ts.map +1 -1
  26. package/package.json +5 -4
  27. package/utils/stage-attachments.d.ts +11 -0
  28. package/utils/stage-attachments.d.ts.map +1 -0
  29. package/utils/stage-grouping.d.ts +7 -3
  30. package/utils/stage-grouping.d.ts.map +1 -1
  31. package/utils/stage-name.d.ts +0 -6
  32. package/utils/stage-name.d.ts.map +1 -1
  33. package/utils/stage-progress.d.ts +0 -2
  34. package/utils/stage-progress.d.ts.map +1 -1
  35. package/utils/stage-tree.d.ts +14 -0
  36. package/utils/stage-tree.d.ts.map +1 -0
package/index.js CHANGED
@@ -1,502 +1,866 @@
1
- import { MarkdownRenderer as e, StageStatus as t, buildCssVars as n, copyToClipboard as r, mergeClasses as i } from "@epam/ai-dial-chat-shared";
2
- import { DIAL_ICON_SIZE as a, DIAL_KIT_ICON_STROKE as o, ElementSize as s, EllipsisTooltip as c, GhostIconButton as l, LinkButton as u, Spinner as d } from "@epam/ai-dial-ui-kit";
3
- import { IconAlertCircle as f, IconCheck as p, IconChevronDown as m, IconChevronRight as h, IconCopy as g } from "@tabler/icons-react";
4
- import { memo as _, useCallback as v, useEffect as y, useRef as b, useState as x } from "react";
5
- import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
1
+ import { AttachmentErrorReason as e, AttachmentType as t, MIME_TYPE_EXT_MAP as n, MarkdownCodeBlock as r, MarkdownRenderer as i, RequestStatus as a, StageStatus as o, buildCssVars as s, mergeClasses as c, messageAttachmentsToDisplayAttachments as l, normalizeMimeType as u } from "@epam/ai-dial-chat-shared";
2
+ import { Accordion as d, DIAL_ICON_SIZE as f, DIAL_KIT_ICON_STROKE as p, ElementSize as m, EllipsisTooltip as h, Highlight as g, Skeleton as _, SkeletonVariant as v, Spinner as y, StaticIconButton as b } from "@epam/ai-dial-ui-kit";
3
+ import { IconAlertCircle as x, IconCheck as S, IconClipboard as C, IconDownload as w, IconExternalLink as T, IconFile as E, IconFileTypeBmp as D, IconFileTypeCss as O, IconFileTypeCsv as k, IconFileTypeDoc as A, IconFileTypeDocx as j, IconFileTypeHtml as M, IconFileTypeJpg as N, IconFileTypeJs as P, IconFileTypeJsx as F, IconFileTypePdf as I, IconFileTypePhp as L, IconFileTypePng as R, IconFileTypePpt as z, IconFileTypeRs as ee, IconFileTypeSql as te, IconFileTypeSvg as ne, IconFileTypeTs as re, IconFileTypeTsx as B, IconFileTypeTxt as ie, IconFileTypeVue as ae, IconFileTypeXls as oe, IconFileTypeXml as se, IconFileTypeZip as ce, IconMusic as le, IconPhoto as V, IconReload as ue, IconTerminal2 as de, IconVideo as fe, IconX as pe } from "@tabler/icons-react";
4
+ import { memo as me, useCallback as H, useEffect as U, useId as he, useMemo as W, useRef as ge, useState as G } from "react";
5
+ import { Fragment as _e, jsx as K, jsxs as q } from "react/jsx-runtime";
6
6
  //#region src/constants/public-class-names.ts
7
- var T = {
7
+ var J = {
8
8
  panel: "dial-conversation-stages-panel",
9
9
  group: "dial-conversation-stages-group",
10
10
  groupToggle: "dial-conversation-stages-group-toggle"
11
- }, E = /[([][^()[\]]*[)\]]/g, D = /(\d+(?:\.\d+)?)\s*s\b/, O = /\bStart:\s*(\d{1,2}):([0-5]\d):([0-5]\d(?:\.\d+)?)\b/i, k = (e) => {
11
+ }, ve = () => {
12
+ let [e, t] = G(() => /* @__PURE__ */ new Set()), n = H((e, n) => {
13
+ t((t) => {
14
+ if (t.has(e) === n) return t;
15
+ let r = new Set(t);
16
+ return n ? r.add(e) : r.delete(e), r;
17
+ });
18
+ }, []), r = H(() => {
19
+ t((e) => e.size ? /* @__PURE__ */ new Set() : e);
20
+ }, []);
21
+ return W(() => ({
22
+ isExpanded: (t) => e.has(t),
23
+ onToggle: n,
24
+ reset: r
25
+ }), [
26
+ e,
27
+ n,
28
+ r
29
+ ]);
30
+ }, ye = /[([][^()[\]]*[)\]]/g, be = /(\d+(?:\.\d+)?)\s*s\b/, xe = (e) => {
12
31
  let t = e.trimEnd();
13
32
  return t.endsWith(":") ? t.slice(0, -1) : t;
14
- }, A = 1440 * 60, j = A / 2, M = (e) => {
15
- let t = O.exec(e);
16
- if (!t) return;
17
- let n = Number(t[1]);
18
- if (!(n > 23)) return n * 60 * 60 + Number(t[2]) * 60 + Number(t[3]);
19
- }, N = (e) => {
20
- E.lastIndex = 0;
33
+ }, Se = (e) => {
34
+ ye.lastIndex = 0;
21
35
  let t;
22
- for (; t = E.exec(e);) {
23
- let e = t[0].slice(1, -1), n = D.exec(e);
36
+ for (; t = ye.exec(e);) {
37
+ let e = t[0].slice(1, -1), n = be.exec(e);
24
38
  if (n) return {
25
39
  durationLabel: `${n[1]}s`,
26
40
  groupIndex: t.index,
27
- groupLength: t[0].length,
28
- startTimeSeconds: M(e)
41
+ groupLength: t[0].length
29
42
  };
30
43
  }
31
- }, P = (e) => {
32
- let t = e ?? "", n = N(t);
44
+ }, Y = (e) => {
45
+ let t = e ?? "", n = Se(t);
33
46
  return {
34
- name: k(n ? t.slice(0, n.groupIndex) + t.slice(n.groupIndex + n.groupLength) : t).trim().replace(/ {2,}/g, " "),
47
+ name: xe(n ? t.slice(0, n.groupIndex) + t.slice(n.groupIndex + n.groupLength) : t).trim().replace(/ {2,}/g, " "),
35
48
  durationLabel: n?.durationLabel
36
49
  };
37
- }, F = (e) => e.length > 0 && !/\s/.test(e) && e.includes("_"), I = (e) => e >= 60 ? `${Math.floor(e / 60)}m ${Math.round(e % 60)}s` : `${e.toFixed(1)}s`, L = (e) => {
38
- if (!e) return;
39
- let t = /^(\d+(?:\.\d+)?)s$/.exec(e);
40
- return t ? parseFloat(t[1]) : void 0;
41
- }, R = (e) => {
42
- let t = e.flatMap((e) => {
43
- let t = N(e ?? ""), n = L(t?.durationLabel);
44
- return n == null ? [] : [{
45
- durationSeconds: n,
46
- startTimeSeconds: t?.startTimeSeconds
47
- }];
48
- });
49
- if (t.length === 0) return 0;
50
- if (t.some(({ startTimeSeconds: e }) => e == null)) return t.reduce((e, { durationSeconds: t }) => e + t, 0);
51
- let n = 0, r, i = t.flatMap(({ durationSeconds: e, startTimeSeconds: t }) => {
52
- if (t == null) return [];
53
- let i = t + n;
54
- return r != null && r - i > j && (n += A, i += A), r = i, {
55
- start: i,
56
- end: i + e
57
- };
58
- }).sort((e, t) => e.start - t.start), a = 0, o = i[0].start, s = i[0].end;
59
- for (let e of i.slice(1)) e.start <= s ? s = Math.max(s, e.end) : (a += s - o, o = e.start, s = e.end);
60
- return a + s - o;
61
- }, z = (e) => [...e].reverse().find((e) => e.status == null), B = (e, t) => e.findIndex((e) => e.index === t.index) + 1, V = (e) => {
50
+ }, Ce = (e) => e.length > 0 && !/\s/.test(e) && e.includes("_"), we = (e) => [...e].reverse().find((e) => e.status == null), Te = (e, t) => {
51
+ let n = e.parent_stage_index;
52
+ if (!(n == null || !Number.isInteger(n) || n < 0 || n >= e.index)) return t.get(n);
53
+ }, Ee = (e) => {
54
+ let t = e.map((e) => ({
55
+ stage: e,
56
+ children: []
57
+ })), n = /* @__PURE__ */ new Map();
58
+ for (let e of t) n.has(e.stage.index) || n.set(e.stage.index, e);
59
+ let r = [];
60
+ for (let e of t) {
61
+ let t = Te(e.stage, n);
62
+ t ? t.children.push(e) : r.push(e);
63
+ }
64
+ return r;
65
+ }, De = (e) => `stage:${e}`, Oe = (e) => `group:${e}`, ke = "min-w-0 overflow-visible py-0", Ae = "min-w-0 justify-start gap-2 rounded-lg px-2 py-1.5 text-start mobile:min-h-11", je = (e) => {
62
66
  let t = [], n = 0;
63
67
  for (; n < e.length;) {
64
- let r = e[n], i = P(r.name).name, a = n + 1;
65
- for (; a < e.length && P(e[a].name).name === i;) a += 1;
68
+ let r = e[n], i = Y(r.stage.name).name, a = n + 1;
69
+ for (; a < e.length && Y(e[a].stage.name).name === i;) a += 1;
66
70
  let o = e.slice(n, a);
67
71
  o.length > 1 ? t.push({
68
- key: r.index,
72
+ key: r.stage.index,
69
73
  name: i,
70
74
  attempts: o
71
75
  }) : t.push({
72
- key: r.index,
73
- stage: r
76
+ key: r.stage.index,
77
+ node: r
74
78
  }), n = a;
75
79
  }
76
80
  return t;
77
- }, H = {
78
- panel: "_panel_vd48n_1",
79
- row: "_row_vd48n_5",
80
- collapseButton: "_collapseButton_vd48n_9",
81
- stageName: "_stageName_vd48n_13",
82
- stageNameFailed: "_stageNameFailed_vd48n_17",
83
- monoName: "_monoName_vd48n_21",
84
- tag: "_tag_vd48n_25",
85
- count: "_count_vd48n_29",
86
- duration: "_duration_vd48n_34",
87
- iconSecondary: "_iconSecondary_vd48n_39",
88
- iconCompleted: "_iconCompleted_vd48n_44",
89
- iconError: "_iconError_vd48n_48",
90
- stageContent: "_stageContent_vd48n_52",
91
- codeBlock: "_codeBlock_vd48n_56",
92
- codeInline: "_codeInline_vd48n_62",
93
- blockquote: "_blockquote_vd48n_68",
94
- tableCell: "_tableCell_vd48n_73"
95
- }, U = ({ status: e, isLive: n, runningLabel: r = "Running", failedLabel: i = "Failed" }) => e === t.Failed ? /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(f, {
96
- size: a.MD,
97
- className: H.iconError,
81
+ }, X = {
82
+ panel: "_panel_w65is_2",
83
+ row: "_row_w65is_6",
84
+ collapseButton: "_collapseButton_w65is_10",
85
+ stageHeader: "_stageHeader_w65is_19",
86
+ stageRegion: "_stageRegion_w65is_28",
87
+ stageName: "_stageName_w65is_32",
88
+ stageNameFailed: "_stageNameFailed_w65is_36",
89
+ monoName: "_monoName_w65is_40",
90
+ tag: "_tag_w65is_44",
91
+ count: "_count_w65is_48",
92
+ duration: "_duration_w65is_53",
93
+ iconSecondary: "_iconSecondary_w65is_58",
94
+ iconCompleted: "_iconCompleted_w65is_63",
95
+ iconError: "_iconError_w65is_67",
96
+ stageContent: "_stageContent_w65is_71",
97
+ codeBlock: "_codeBlock_w65is_75",
98
+ codeInline: "_codeInline_w65is_84",
99
+ blockquote: "_blockquote_w65is_91",
100
+ tableCell: "_tableCell_w65is_96"
101
+ }, Me = ({ status: e, isLive: t, runningLabel: n = "Running", failedLabel: r = "Failed" }) => e === o.Failed ? /* @__PURE__ */ q(_e, { children: [/* @__PURE__ */ K(x, {
102
+ size: f.MD,
103
+ className: X.iconError,
98
104
  "aria-hidden": !0,
99
- stroke: o
100
- }), /* @__PURE__ */ C("span", {
105
+ stroke: p
106
+ }), /* @__PURE__ */ K("span", {
101
107
  className: "sr-only",
102
- children: i
103
- })] }) : e === t.Completed ? /* @__PURE__ */ C(p, {
104
- size: a.SM,
105
- className: H.iconCompleted,
108
+ children: r
109
+ })] }) : e === o.Completed ? /* @__PURE__ */ K(S, {
110
+ size: f.SM,
111
+ className: X.iconCompleted,
106
112
  "aria-hidden": !0,
107
- stroke: o
108
- }) : n ? /* @__PURE__ */ C(d, {
113
+ stroke: p
114
+ }) : t ? /* @__PURE__ */ K(y, {
109
115
  size: 16,
110
- ariaLabel: r
111
- }) : null, W = ({ children: e, codeClassName: t, blockClassName: n = "dial-code-text", copyAriaLabel: c }) => {
112
- let [u, d] = x(!1), f = b(null);
113
- y(() => () => {
114
- f.current != null && clearTimeout(f.current);
115
- }, []);
116
- let m = v(() => {
117
- r(typeof e == "string" ? e : String(e ?? "")), f.current && clearTimeout(f.current), d(!0), f.current = setTimeout(() => d(!1), 2e3);
118
- }, [e]);
119
- return /* @__PURE__ */ w("pre", {
120
- className: i("relative max-h-[300px] overflow-auto rounded border p-3", n, H.codeBlock),
121
- children: [/* @__PURE__ */ C(l, {
122
- size: s.Small,
123
- icon: C(u ? p : g, {
124
- size: a.SM,
125
- className: H.iconSecondary,
126
- stroke: o
127
- }),
128
- "aria-label": c,
129
- onClick: m,
130
- className: "absolute end-2 top-2"
131
- }), /* @__PURE__ */ C("code", {
132
- className: t,
133
- children: e
116
+ ariaLabel: n
117
+ }) : null, Ne = (e) => {
118
+ if (e == null) return "";
119
+ let t = e.lastIndexOf(".");
120
+ return t > 0 ? e.slice(0, t) : e;
121
+ }, Pe = (e) => {
122
+ if (!e) return E;
123
+ let t = u(e);
124
+ if (t.startsWith("image/")) switch (t) {
125
+ case "image/jpeg": return N;
126
+ case "image/png": return R;
127
+ case "image/svg+xml": return ne;
128
+ case "image/bmp": return D;
129
+ default: return V;
130
+ }
131
+ if (t.startsWith("video/")) return fe;
132
+ if (t.startsWith("audio/")) return le;
133
+ switch (t) {
134
+ case "application/pdf": return I;
135
+ case "application/msword": return A;
136
+ case "application/vnd.openxmlformats-officedocument.wordprocessingml.document": return j;
137
+ case "application/vnd.ms-powerpoint": return z;
138
+ case "application/vnd.openxmlformats-officedocument.presentationml.presentation": return z;
139
+ case "application/vnd.ms-excel": return oe;
140
+ case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": return oe;
141
+ case "application/zip":
142
+ case "application/vnd.rar":
143
+ case "application/x-7z-compressed":
144
+ case "application/gzip":
145
+ case "application/x-tar": return ce;
146
+ case "text/csv": return k;
147
+ case "text/plain": return ie;
148
+ case "text/html":
149
+ case "application/xhtml+xml": return M;
150
+ case "application/xml": return se;
151
+ case "application/sql": return te;
152
+ case "text/javascript": return P;
153
+ case "text/jsx": return F;
154
+ case "text/typescript": return re;
155
+ case "text/tsx": return B;
156
+ case "text/css": return O;
157
+ case "text/x-php": return L;
158
+ case "text/x-rustsrc": return ee;
159
+ case "text/x-vue": return ae;
160
+ default: return E;
161
+ }
162
+ }, Fe = (e) => {
163
+ let { type: n, contentType: r } = e;
164
+ return n === t.Prompt ? de : n === t.Pasted ? C : n === t.Image ? V : Pe(r ?? "");
165
+ }, Ie = (e) => {
166
+ let t = u(e), r = n[t];
167
+ if (r) return r;
168
+ let i = t.split("/")[1];
169
+ if (i && !i.startsWith("vnd.") && !i.includes("+")) return i;
170
+ }, Le = (e, n) => {
171
+ let { type: r, name: i, contentType: a } = e;
172
+ if (r === t.Prompt) return n.promptLabel ?? "Prompt";
173
+ if (r === t.Pasted) return n.pastedLabel ?? "Pasted";
174
+ if (r === t.Image) return n.imageLabel ?? "Image";
175
+ if (a) {
176
+ let e = Ie(a);
177
+ if (e) return `.${e}`;
178
+ }
179
+ if (i == null) return "";
180
+ let o = i.lastIndexOf(".");
181
+ return o > 0 && o < i.length - 1 ? `.${i.slice(o + 1).toLowerCase()}` : i;
182
+ }, Re = (e, n = {}) => {
183
+ let { type: r, status: i, previewUrl: o, url: s } = e, c = i === a.Loading, l = i === a.Error, u = r === t.Image && !!(o ?? s) && !l, d = r === t.Link && !l;
184
+ return {
185
+ isLoading: c,
186
+ isError: l,
187
+ isImage: u,
188
+ isLink: d,
189
+ BottomIcon: d ? null : Fe(e),
190
+ typeLabel: d ? null : Le(e, n)
191
+ };
192
+ }, ze = "flex size-[84px] items-center justify-center rounded-xl border", Z = {
193
+ tray: "dial-ai-attachment-tray",
194
+ trayItem: "dial-ai-attachment-tray-item",
195
+ tile: "dial-ai-attachment-tile",
196
+ tileSelected: "dial-ai-attachment-tile-selected",
197
+ tileName: "dial-ai-attachment-tile-name",
198
+ tileType: "dial-ai-attachment-tile-type",
199
+ tileAction: "dial-ai-attachment-tile-action"
200
+ }, Q = {
201
+ tile: "_tile_1tdbq_12",
202
+ hovered: "_hovered_1tdbq_18",
203
+ selected: "_selected_1tdbq_28",
204
+ tileError: "_tileError_1tdbq_33",
205
+ nameText: "_nameText_1tdbq_38",
206
+ typeText: "_typeText_1tdbq_42",
207
+ retryIcon: "_retryIcon_1tdbq_46",
208
+ track: "_track_1tdbq_50",
209
+ actionButton: "_actionButton_1tdbq_56",
210
+ imageActionButton: "_imageActionButton_1tdbq_60"
211
+ }, Be = ({ ariaLabel: e, errorTitle: t, errorDescId: n, onClick: r, id: i, icon: a, className: o }) => /* @__PURE__ */ K(b, {
212
+ icon: a,
213
+ size: m.Small,
214
+ className: c("opacity-0 focus-visible:opacity-100 group-focus-within/attachment-tile:opacity-100 group-hover/attachment-tile:opacity-100", Q.actionButton, o, Z.tileAction),
215
+ "aria-label": e,
216
+ "aria-describedby": t ? n : void 0,
217
+ onClick: (e) => {
218
+ e.stopPropagation(), r(i);
219
+ }
220
+ }), Ve = ({ ...e }) => /* @__PURE__ */ K(Be, {
221
+ icon: /* @__PURE__ */ K(ue, {
222
+ size: f.SM,
223
+ "aria-hidden": !0,
224
+ stroke: p
225
+ }),
226
+ className: Q.retryIcon,
227
+ ...e
228
+ }), He = ({ ...e }) => /* @__PURE__ */ K(Be, {
229
+ icon: /* @__PURE__ */ K(w, {
230
+ size: f.SM,
231
+ "aria-hidden": !0,
232
+ stroke: p
233
+ }),
234
+ ...e
235
+ }), Ue = ({ ...e }) => /* @__PURE__ */ K(Be, {
236
+ icon: /* @__PURE__ */ K(T, {
237
+ size: f.SM,
238
+ "aria-hidden": !0,
239
+ stroke: p
240
+ }),
241
+ ...e
242
+ }), We = ({ ...e }) => /* @__PURE__ */ K(Be, {
243
+ icon: /* @__PURE__ */ K(pe, {
244
+ size: f.SM,
245
+ "aria-hidden": !0,
246
+ stroke: p
247
+ }),
248
+ ...e
249
+ }), Ge = {
250
+ [e.Network]: "Upload failed · network error",
251
+ [e.UnsupportedType]: "Upload failed · unsupported file type",
252
+ [e.FileTooLarge]: "Upload failed · file too large"
253
+ }, Ke = ({ attachment: t, searchQuery: n = "", onClick: r, onRetry: i, labels: o, styles: s, onDownload: l, isLink: u, cssVars: d, onExpand: f, isExpandable: p, onRemove: m, isSelected: h }) => {
254
+ let { clickLabel: _ = "Download attachment", expandLabel: v = "Expand pasted text", downloadLabel: b = "Download attachment", retryLabel: x = "Retry upload", removeLabel: S = "Remove attachment", openInNewTabLabel: C = "Open in new tab", sizeLabel: w, uploadingLabel: T = "Uploading", errorReasonLabels: E, genericErrorLabel: D = "Upload failed" } = o ?? {}, { typography: O, className: k } = s ?? {}, { id: A, name: j, status: M, errorReason: N } = t, P = M === a.Loading, F = M === a.Error, I = he(), L = F ? N && (E?.[N] ?? Ge[N]) || D : "", { BottomIcon: R, typeLabel: z } = Re(t), ee = !F && !P && l && !u, te = F && !!i && N !== e.UnsupportedType && N !== e.FileTooLarge, ne = Number(!!ee) + Number(!!te) + Number(!!u) + Number(!!m), re = ne > 1 ? "pe-11" : ne === 1 ? "pe-5" : void 0, B = !!p && f !== void 0, ie = B || r !== void 0, ae = () => {
255
+ B ? f(A) : r?.(A);
256
+ }, oe = (e) => {
257
+ e.target === e.currentTarget && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), ae());
258
+ }, se = W(() => Ne(j), [j]), ce = H(() => {
259
+ window.open(t.referenceUrl, "_blank", "noopener,noreferrer");
260
+ }, [t]), le = c(ze, "group/attachment-tile relative flex-col justify-between items-start gap-1 overflow-hidden p-1.5", Q.tile, !F && Q.hovered, h && Q.selected, F && Q.tileError, Z.tile, h && Z.tileSelected), V = /* @__PURE__ */ K("div", {
261
+ title: se,
262
+ className: c(O?.nameClassName ?? "dial-caption-text", "line-clamp-2 w-full min-w-0 break-words", Q.nameText, !F && re, Z.tileName),
263
+ children: n ? /* @__PURE__ */ K(g, {
264
+ text: se,
265
+ query: n,
266
+ maxLines: 2
267
+ }) : se
268
+ }), ue = R && /* @__PURE__ */ q("div", {
269
+ className: c("flex w-full items-center gap-1", F && re, Z.tileType),
270
+ children: [/* @__PURE__ */ K(R, {
271
+ size: 16,
272
+ className: Q.typeText,
273
+ "aria-hidden": !0
274
+ }), /* @__PURE__ */ K("span", {
275
+ className: c(O?.metaClassName ?? "dial-caption-text", "min-w-0 flex-1 truncate", Q.typeText),
276
+ children: w ? `${z} · ${w}` : z
134
277
  })]
278
+ }), de = ie ? {
279
+ role: "button",
280
+ tabIndex: 0,
281
+ "aria-label": B ? v : _,
282
+ onClick: ae,
283
+ onKeyDown: oe
284
+ } : {}, fe = /* @__PURE__ */ q(_e, { children: [
285
+ V,
286
+ ue,
287
+ P && /* @__PURE__ */ K("div", {
288
+ role: "progressbar",
289
+ "aria-label": T,
290
+ className: c("absolute start-[-1px] top-[-1px] flex size-full items-center justify-center rounded", Q.track),
291
+ children: /* @__PURE__ */ K(y, { size: 32 })
292
+ }),
293
+ /* @__PURE__ */ q("div", {
294
+ className: "absolute end-1 top-1 flex gap-1",
295
+ children: [
296
+ ee && /* @__PURE__ */ K(He, {
297
+ ariaLabel: b,
298
+ errorTitle: L,
299
+ errorDescId: I,
300
+ onClick: l,
301
+ id: A
302
+ }),
303
+ te && /* @__PURE__ */ K(Ve, {
304
+ ariaLabel: x,
305
+ errorTitle: L,
306
+ errorDescId: I,
307
+ onClick: i,
308
+ id: A
309
+ }),
310
+ u && /* @__PURE__ */ K(Ue, {
311
+ ariaLabel: C,
312
+ errorTitle: L,
313
+ errorDescId: I,
314
+ onClick: ce
315
+ }),
316
+ m && /* @__PURE__ */ K(We, {
317
+ ariaLabel: S,
318
+ errorTitle: L,
319
+ errorDescId: I,
320
+ onClick: m,
321
+ id: A
322
+ })
323
+ ]
324
+ }),
325
+ F && /* @__PURE__ */ K("span", {
326
+ id: I,
327
+ role: "status",
328
+ "aria-live": "polite",
329
+ className: "sr-only",
330
+ children: L
331
+ })
332
+ ] });
333
+ return /* @__PURE__ */ K("div", {
334
+ style: d,
335
+ className: c("inline-flex", k),
336
+ children: /* @__PURE__ */ K("div", {
337
+ ...de,
338
+ "aria-busy": P,
339
+ style: d,
340
+ className: c(le, ie && "cursor-pointer", "focus-within:outline focus-within:outline-1 focus-within:outline-offset-1"),
341
+ children: fe
342
+ })
343
+ });
344
+ }, qe = /* @__PURE__ */ function(e) {
345
+ return e.Idle = "idle", e.Loading = "loading", e.Loaded = "loaded", e.Error = "error", e;
346
+ }({}), Je = ({ enabled: e, src: t }) => {
347
+ let n = ge(null), [r, i] = G("idle");
348
+ return U(() => {
349
+ i(e && t ? "loading" : "idle");
350
+ }, [e, t]), U(() => {
351
+ let r = n.current;
352
+ if (!r || !e || !t) return;
353
+ let a = () => i("loaded"), o = () => i("error");
354
+ return r.addEventListener("load", a), r.addEventListener("error", o), r.complete && i(r.naturalWidth > 0 ? "loaded" : "error"), () => {
355
+ r.removeEventListener("load", a), r.removeEventListener("error", o);
356
+ };
357
+ }, [e, t]), {
358
+ imageRef: n,
359
+ imageLoadStatus: r
360
+ };
361
+ }, Ye = ({ attachment: e, onExpand: n, onClick: r, labels: i, onRemove: a, cssVars: o, onDownload: s, styles: l, isSelected: u }) => {
362
+ let { clickLabel: d = "Open attachment", expandLabel: m = "Expand pasted text", removeLabel: h = "Remove attachment", downloadLabel: g = "Download attachment" } = i ?? {}, { className: y } = l ?? {}, { id: b, name: x } = e, S = e.previewUrl ?? e.url, C = e.type === t.Pasted && n !== void 0, { isLoading: w, isError: T, isImage: E } = W(() => Re(e), [e]), D = r !== void 0 && !C && !w && !T, O = C || D, { imageRef: k, imageLoadStatus: A } = Je({
363
+ enabled: E,
364
+ src: S
365
+ }), j = () => {
366
+ C && n ? n(b) : D && r && r(b);
367
+ }, M = O ? {
368
+ role: "button",
369
+ tabIndex: 0,
370
+ "aria-label": C ? m : d,
371
+ onClick: j,
372
+ onKeyDown: (e) => {
373
+ e.target === e.currentTarget && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), j());
374
+ }
375
+ } : {};
376
+ return /* @__PURE__ */ K("div", {
377
+ className: c(ze, "group/attachment-tile", O && "cursor-pointer", Q.tile, u && Q.selected, y, Z.tile, u && Z.tileSelected),
378
+ ...M,
379
+ style: o,
380
+ children: /* @__PURE__ */ q("div", {
381
+ className: "relative h-full w-full overflow-hidden",
382
+ children: [
383
+ /* @__PURE__ */ q("div", {
384
+ className: "absolute end-1 top-1 z-10 flex gap-1",
385
+ children: [a && /* @__PURE__ */ K(We, {
386
+ ariaLabel: h,
387
+ onClick: a,
388
+ id: b,
389
+ className: Q.imageActionButton
390
+ }), s && /* @__PURE__ */ K(He, {
391
+ ariaLabel: g,
392
+ onClick: s,
393
+ id: b,
394
+ className: Q.imageActionButton
395
+ })]
396
+ }),
397
+ A !== qe.Loaded && /* @__PURE__ */ K(_, {
398
+ variant: v.Rectangular,
399
+ width: "100%",
400
+ height: "100%",
401
+ active: A === qe.Loading,
402
+ overlay: /* @__PURE__ */ K(V, {
403
+ size: f.LG,
404
+ className: Q.typeText,
405
+ "aria-hidden": !0,
406
+ stroke: p
407
+ }),
408
+ className: "absolute inset-0 rounded-xl"
409
+ }),
410
+ /* @__PURE__ */ K("img", {
411
+ ref: k,
412
+ src: S,
413
+ alt: x,
414
+ loading: "lazy",
415
+ decoding: "async",
416
+ className: c("h-full w-full rounded-xl object-cover transition-opacity duration-200", A === qe.Loaded ? "opacity-100" : "opacity-0")
417
+ })
418
+ ]
419
+ })
420
+ });
421
+ }, Xe = ({ attachment: e, searchQuery: n = "", onRemove: r, onRetry: i, onExpand: a, onClick: o, onDownload: c, labels: l, styles: u, isSelected: d }) => {
422
+ let { colors: f } = u ?? {}, p = e.type === t.Pasted && a !== void 0, m = s({
423
+ "--ai-tile-bg": f?.background,
424
+ "--ai-tile-border": f?.border,
425
+ "--ai-tile-bg-hover": f?.backgroundHover,
426
+ "--ai-tile-border-hover": f?.borderHover,
427
+ "--ai-tile-bg-selected": f?.backgroundSelected,
428
+ "--ai-tile-border-selected": f?.borderSelected,
429
+ "--ai-tile-focus-outline": f?.focusOutline,
430
+ "--ai-tile-bg-error": f?.backgroundError,
431
+ "--ai-tile-border-error": f?.borderError,
432
+ "--ai-tile-error-text": f?.errorText,
433
+ "--ai-tile-name-text": f?.nameText,
434
+ "--ai-tile-type-text": f?.typeText,
435
+ "--ai-tile-hover-icon-bg": f?.hoverIconBackground,
436
+ "--ai-tile-hover-icon-color": f?.hoverIconColor,
437
+ "--ai-tile-progress-track": f?.trackBackground
438
+ }), { isImage: h, isLink: g } = W(() => Re(e), [e]);
439
+ return h ? /* @__PURE__ */ K(Ye, {
440
+ attachment: e,
441
+ labels: l,
442
+ onClick: o,
443
+ onExpand: a,
444
+ styles: u,
445
+ onRemove: r,
446
+ cssVars: m,
447
+ onDownload: c,
448
+ isSelected: d
449
+ }) : /* @__PURE__ */ K(Ke, {
450
+ attachment: e,
451
+ searchQuery: n,
452
+ onClick: o,
453
+ onRetry: i,
454
+ onRemove: r,
455
+ onDownload: c,
456
+ isLink: g,
457
+ styles: u,
458
+ labels: l,
459
+ onExpand: a,
460
+ cssVars: m,
461
+ isExpandable: p,
462
+ isSelected: d
135
463
  });
136
- }, G = _(({ content: t, typography: n, copyAriaLabel: r = "Copy" }) => {
137
- let a = "mb-1.5 last:mb-0", o = i(n?.headingClassName ?? "dial-small-semi-text", H.stageContent, a);
138
- return /* @__PURE__ */ C(e, {
139
- content: t,
464
+ }, Ze = (e) => {
465
+ let t = l(e);
466
+ if (!e?.length) return t;
467
+ let n = /* @__PURE__ */ new Map();
468
+ for (let t of e) {
469
+ let e = t.url ?? t.data ?? t.title;
470
+ n.has(e) || n.set(e, t.type);
471
+ }
472
+ return t.map((e) => {
473
+ let t = n.get(e.id);
474
+ return t ? {
475
+ ...e,
476
+ contentType: t
477
+ } : e;
478
+ });
479
+ }, Qe = ({ children: e, codeClassName: t, blockClassName: n = "dial-code-text", copyAriaLabel: i, copiedLabel: a }) => /* @__PURE__ */ K(r, {
480
+ language: t?.replace(/^language-/, "") ?? "",
481
+ value: typeof e == "string" ? e : String(e ?? ""),
482
+ codeClassName: n,
483
+ containerClassName: c(X.codeBlock, n),
484
+ copyLabel: i,
485
+ copiedLabel: a,
486
+ hideDownload: !0
487
+ }), $e = me(({ content: e, typography: t, copyAriaLabel: n = "Copy", copiedLabel: r, tableScrollRegionAriaLabel: a, mathScrollRegionAriaLabel: o }) => {
488
+ let s = "mb-1.5 last:mb-0", l = c(t?.headingClassName ?? "dial-small-semi-text", X.stageContent, s);
489
+ return /* @__PURE__ */ K(i, {
490
+ content: e,
491
+ tableScrollRegionAriaLabel: a,
492
+ mathScrollRegionAriaLabel: o,
140
493
  classNames: {
141
- h1: o,
142
- h2: o,
143
- h3: o,
144
- h4: o,
145
- h5: o,
146
- h6: o,
147
- p: i(n?.contentClassName ?? "dial-tiny-text", H.stageContent, "mb-1.5"),
148
- ul: i(n?.contentClassName ?? "dial-tiny-text", H.stageContent, a),
149
- ol: i(n?.contentClassName ?? "dial-tiny-text", H.stageContent, a),
150
- strong: i(n?.strongClassName ?? n?.contentClassName ?? "dial-tiny-text", H.stageContent),
151
- codeInline: H.codeInline,
152
- blockquote: i(n?.contentClassName ?? "dial-tiny-text", H.blockquote, a),
153
- link: i(n?.contentClassName ?? "dial-tiny-text", H.stageContent),
154
- tableCell: i(n?.contentClassName ?? "dial-tiny-text", H.tableCell)
494
+ h1: l,
495
+ h2: l,
496
+ h3: l,
497
+ h4: l,
498
+ h5: l,
499
+ h6: l,
500
+ p: c(t?.contentClassName ?? "dial-tiny-text", X.stageContent, "mb-1.5"),
501
+ ul: c(t?.contentClassName ?? "dial-tiny-text", X.stageContent, s),
502
+ ol: c(t?.contentClassName ?? "dial-tiny-text", X.stageContent, s),
503
+ strong: c(t?.strongClassName ?? t?.contentClassName ?? "dial-tiny-text", X.stageContent),
504
+ codeInline: X.codeInline,
505
+ blockquote: c(t?.contentClassName ?? "dial-tiny-text", X.blockquote, s),
506
+ link: c(t?.contentClassName ?? "dial-tiny-text", X.stageContent),
507
+ tableCell: c(t?.contentClassName ?? "dial-tiny-text", X.tableCell)
155
508
  },
156
- components: { code: ({ children: e, className: t }) => t?.includes("language-") ? /* @__PURE__ */ C(W, {
157
- codeClassName: t,
158
- blockClassName: n?.codeBlockClassName,
159
- copyAriaLabel: r,
509
+ components: { code: ({ children: e, className: i }) => i?.includes("language-") ? /* @__PURE__ */ K(Qe, {
510
+ codeClassName: i,
511
+ blockClassName: t?.codeBlockClassName,
512
+ copyAriaLabel: n,
513
+ copiedLabel: r,
160
514
  children: e
161
- }) : /* @__PURE__ */ C("code", {
162
- className: i("inline-block px-1.5 py-1", n?.codeClassName ?? "dial-code-text rounded-md", H.codeInline),
515
+ }) : /* @__PURE__ */ K("code", {
516
+ className: c("px-1 py-0.5", t?.codeClassName ?? "dial-tiny-text rounded-md", X.codeInline),
163
517
  children: e
164
518
  }) }
165
519
  });
166
- }), K = ({ stage: e, isLive: n, typography: r, labels: s, nameOverride: l }) => {
167
- let [u, d] = x(!1), { copyAriaLabel: f = "Copy stage content", runningAriaLabel: p, failedAriaLabel: g } = s ?? {}, { name: _, durationLabel: v } = P(e.name), y = l ?? _, b = !l && F(_), T = e.status === t.Failed, E = !!e.content, D = /* @__PURE__ */ w(S, { children: [
168
- /* @__PURE__ */ C("span", {
520
+ }), et = ({ attachments: e, clickLabel: t, onAttachmentClick: n }) => {
521
+ let r = H((t) => {
522
+ let r = e.find((e) => e.id === t);
523
+ r && n?.(r);
524
+ }, [e, n]);
525
+ return /* @__PURE__ */ K("div", {
526
+ role: "list",
527
+ className: "flex flex-wrap gap-3",
528
+ children: e.map((e) => /* @__PURE__ */ K("div", {
529
+ role: "listitem",
530
+ children: /* @__PURE__ */ K(Xe, {
531
+ attachment: e,
532
+ onClick: n && r,
533
+ labels: { clickLabel: t }
534
+ })
535
+ }, e.id))
536
+ });
537
+ }, tt = ({ stage: e, isLive: t, typography: n, labels: r, nameOverride: i, onAttachmentClick: a, childList: s, isExpanded: l, onToggle: u }) => {
538
+ let [f, p] = G(!1), m = l ?? f, g = H((e) => {
539
+ l === void 0 && p(e), u?.(e);
540
+ }, [l, u]), { copyAriaLabel: _ = "Copy stage content", codeBlockCopiedLabel: v, tableScrollRegionAriaLabel: y, mathScrollRegionAriaLabel: b, runningAriaLabel: x, failedAriaLabel: S, attachmentClickLabel: C = "Preview search result" } = r ?? {}, w = W(() => Ze(e.attachments), [e.attachments]), { name: T, durationLabel: E } = Y(e.name), D = i ?? T, O = !i && Ce(T), k = e.status === o.Failed, A = !!e.content || !!e.attachments?.length, j = A || s != null, M = /* @__PURE__ */ q(_e, { children: [
541
+ /* @__PURE__ */ K("span", {
169
542
  className: "flex flex-none items-center",
170
- children: /* @__PURE__ */ C(U, {
543
+ children: /* @__PURE__ */ K(Me, {
171
544
  status: e.status,
172
- isLive: n,
173
- runningLabel: p,
174
- failedLabel: g
545
+ isLive: t,
546
+ runningLabel: x,
547
+ failedLabel: S
175
548
  })
176
549
  }),
177
- /* @__PURE__ */ C("span", {
178
- className: i("min-w-0 max-w-[22rem] truncate", r?.fontClassName ?? "dial-small-text", H.stageName, T && H.stageNameFailed, b && H.monoName),
179
- children: /* @__PURE__ */ C(c, { text: y || e.status || "" })
550
+ /* @__PURE__ */ K("span", {
551
+ className: c("min-w-0 max-w-[22rem] truncate", n?.fontClassName ?? "dial-small-text", X.stageName, k && X.stageNameFailed, O && X.monoName),
552
+ children: /* @__PURE__ */ K(h, { text: D || e.status || "" })
180
553
  }),
181
- e.tag && /* @__PURE__ */ C("span", {
182
- className: i("flex-none", r?.tagClassName ?? "dial-tiny-lead-text", H.tag),
554
+ e.tag && /* @__PURE__ */ K("span", {
555
+ className: c("flex-none", n?.tagClassName ?? "dial-tiny-lead-text", X.tag),
183
556
  children: e.tag
184
557
  }),
185
- v && /* @__PURE__ */ C("span", {
186
- className: i("flex-none", r?.countFontClassName ?? "dial-tiny-text", H.duration),
187
- children: v
188
- }),
189
- E && /* @__PURE__ */ C("span", {
190
- className: i("flex-none", H.iconSecondary),
191
- children: u ? /* @__PURE__ */ C(m, {
192
- size: a.SM,
193
- "aria-hidden": !0,
194
- stroke: o
195
- }) : /* @__PURE__ */ C(h, {
196
- size: a.SM,
197
- className: "rtl:scale-x-[-1]",
198
- "aria-hidden": !0,
199
- stroke: o
200
- })
558
+ E && /* @__PURE__ */ K("span", {
559
+ className: c("flex-none", n?.countFontClassName ?? "dial-tiny-text", X.duration),
560
+ children: E
201
561
  })
202
- ] }), O = i("flex w-full items-center gap-2 px-2 py-1.5", H.row);
203
- return E ? /* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("div", {
204
- className: O,
205
- children: /* @__PURE__ */ C("button", {
206
- type: "button",
207
- onClick: () => d((e) => !e),
208
- "aria-expanded": u,
209
- className: "flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-start",
210
- children: D
211
- })
212
- }), /* @__PURE__ */ C("div", {
213
- className: i("grid overflow-hidden transition-[grid-template-rows] duration-[250ms] ease-in-out", u ? "grid-rows-[1fr]" : "grid-rows-[0fr]"),
214
- children: /* @__PURE__ */ C("div", {
215
- className: "overflow-hidden",
216
- children: /* @__PURE__ */ C("div", {
217
- className: "mt-2 flex flex-col gap-3 py-1 ps-8",
218
- children: e.content && /* @__PURE__ */ C("div", {
219
- className: "max-h-[300px] overflow-y-auto",
220
- children: /* @__PURE__ */ C(G, {
221
- content: e.content,
222
- typography: r,
223
- copyAriaLabel: f
224
- })
562
+ ] });
563
+ return j ? /* @__PURE__ */ q(d, {
564
+ expanded: m,
565
+ onToggle: g,
566
+ title: /* @__PURE__ */ K("span", {
567
+ className: "flex min-w-0 items-center gap-2",
568
+ children: M
569
+ }),
570
+ className: ke,
571
+ headerClassName: c(Ae, X.row, X.stageHeader),
572
+ contentClassName: c("-mt-1 flex min-w-0 flex-col gap-3 px-0 py-1", X.stageRegion),
573
+ children: [m && A && /* @__PURE__ */ q("div", {
574
+ className: "flex min-w-0 flex-col gap-3 ps-8",
575
+ children: [e.content && /* @__PURE__ */ K("div", {
576
+ className: "max-h-[300px] min-w-0 overflow-y-auto",
577
+ children: /* @__PURE__ */ K($e, {
578
+ content: e.content,
579
+ typography: n,
580
+ copyAriaLabel: _,
581
+ copiedLabel: v,
582
+ tableScrollRegionAriaLabel: y,
583
+ mathScrollRegionAriaLabel: b
225
584
  })
226
- })
227
- })
228
- })] }) : /* @__PURE__ */ C("div", {
229
- className: O,
230
- children: D
585
+ }), w.length > 0 && /* @__PURE__ */ K(et, {
586
+ attachments: w,
587
+ clickLabel: C,
588
+ onAttachmentClick: a
589
+ })]
590
+ }), m && s]
591
+ }) : /* @__PURE__ */ K("div", {
592
+ className: c("flex w-full items-center gap-2 px-2 py-1.5", X.row),
593
+ children: M
231
594
  });
232
- }, q = ({ row: e, isLive: n, typography: r, labels: s }) => {
233
- let { runningAriaLabel: l, failedAriaLabel: u, attemptLabel: d = (e) => `Attempt ${e}` } = s ?? {}, [f, p] = x(!1), g = e.attempts?.some((e) => e.status == null) ?? !1, _ = e.attempts?.some((e) => e.status === t.Failed), v = g ? null : _ ? t.Failed : t.Completed, y = R((e.attempts || []).map((e) => e.name)), b = y > 0 ? I(y) : void 0;
234
- return /* @__PURE__ */ w("div", { children: [/* @__PURE__ */ w("button", {
235
- type: "button",
236
- onClick: () => p((e) => !e),
237
- "aria-expanded": f,
238
- className: i("flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-start", H.collapseButton, H.row),
239
- children: [
240
- /* @__PURE__ */ C("span", {
241
- className: "flex flex-none items-center",
242
- children: /* @__PURE__ */ C(U, {
243
- status: v,
244
- isLive: n,
245
- runningLabel: l,
246
- failedLabel: u
247
- })
248
- }),
249
- /* @__PURE__ */ C("span", {
250
- className: i("min-w-0 max-w-[22rem] truncate", r?.fontClassName ?? "dial-small-text", H.stageName, _ && H.stageNameFailed),
251
- children: /* @__PURE__ */ C(c, { text: e.name })
252
- }),
253
- /* @__PURE__ */ w("span", {
254
- className: i("flex-none", r?.countFontClassName ?? "dial-tiny-text", H.count),
255
- children: ["×", e.attempts?.length ?? 0]
256
- }),
257
- b && /* @__PURE__ */ C("span", {
258
- className: i("flex-none", r?.countFontClassName ?? "dial-tiny-text", H.duration),
259
- children: b
260
- }),
261
- /* @__PURE__ */ C("span", {
262
- className: i("flex-none", H.iconSecondary),
263
- children: f ? /* @__PURE__ */ C(m, {
264
- size: a.SM,
265
- "aria-hidden": !0,
266
- stroke: o
267
- }) : /* @__PURE__ */ C(h, {
268
- size: a.SM,
269
- className: "rtl:scale-x-[-1]",
270
- "aria-hidden": !0,
271
- stroke: o
272
- })
273
- })
274
- ]
275
- }), /* @__PURE__ */ C("div", {
276
- className: i("grid overflow-hidden transition-[grid-template-rows] duration-[250ms] ease-in-out", f ? "grid-rows-[1fr]" : "grid-rows-[0fr]"),
277
- children: /* @__PURE__ */ C("div", {
278
- className: "overflow-hidden",
279
- children: /* @__PURE__ */ C("ul", {
280
- role: "list",
281
- className: "mt-1 flex flex-col gap-0.5 ps-6",
282
- children: e.attempts?.map((e, t) => /* @__PURE__ */ C("li", {
283
- role: "listitem",
284
- children: /* @__PURE__ */ C(K, {
285
- stage: e,
286
- nameOverride: d(t + 1),
287
- isLive: n && e.status == null,
288
- typography: r,
289
- labels: s
595
+ }, nt = (e) => e <= 3 ? "ps-4" : "ps-0", rt = (e) => e <= 3 ? "ps-6" : "ps-0", it = ({ node: e, depth: t, nameOverride: n, isStreaming: r, expansion: i, typography: a, labels: o, onAttachmentClick: s }) => {
596
+ let c = De(e.stage.index), l = t + 1;
597
+ return /* @__PURE__ */ K(tt, {
598
+ stage: e.stage,
599
+ nameOverride: n,
600
+ isLive: r && e.stage.status == null,
601
+ typography: a,
602
+ labels: o,
603
+ onAttachmentClick: s,
604
+ isExpanded: i.isExpanded(c),
605
+ onToggle: (e) => i.onToggle(c, e),
606
+ childList: e.children.length > 0 ? /* @__PURE__ */ K(ot, {
607
+ nodes: e.children,
608
+ depth: l,
609
+ className: nt(l),
610
+ isStreaming: r,
611
+ expansion: i,
612
+ typography: a,
613
+ labels: o,
614
+ onAttachmentClick: s
615
+ }) : void 0
616
+ });
617
+ }, at = ({ row: e, depth: t, isStreaming: n, expansion: r, typography: i, labels: a, onAttachmentClick: s }) => {
618
+ let { runningAriaLabel: l, failedAriaLabel: u, attemptLabel: f = (e) => `Attempt ${e}` } = a ?? {}, p = e.attempts ?? [], m = p.some((e) => e.stage.status == null), g = p.some((e) => e.stage.status === o.Failed), _ = o.Completed;
619
+ m ? _ = null : g && (_ = o.Failed);
620
+ let v = Oe(e.key), y = r.isExpanded(v), b = t + 1;
621
+ return /* @__PURE__ */ K(d, {
622
+ title: /* @__PURE__ */ q("span", {
623
+ className: "flex min-w-0 items-center gap-2",
624
+ children: [
625
+ /* @__PURE__ */ K("span", {
626
+ className: "flex flex-none items-center",
627
+ children: /* @__PURE__ */ K(Me, {
628
+ status: _,
629
+ isLive: n && m,
630
+ runningLabel: l,
631
+ failedLabel: u
290
632
  })
291
- }, e.index))
292
- })
293
- })
294
- })] });
295
- }, J = ({ stages: e, isStreaming: t, className: r, styles: a, labels: o }) => {
296
- let { colors: s, typography: c } = a ?? {}, l = n({
297
- "--cs-text": s?.text,
298
- "--cs-row-hover": s?.rowHoverColor,
299
- "--cs-button-bg": s?.collapsedButtonBg,
300
- "--cs-stage-text": s?.stageTextColor,
301
- "--cs-failed-text": s?.failedColor,
302
- "--cs-tag-text": s?.tagTextColor,
303
- "--cs-count-text": s?.countTextColor,
304
- "--cs-duration-text": s?.durationTextColor,
305
- "--cs-icon-secondary": s?.iconSecondaryColor,
306
- "--cs-icon-completed": s?.iconCompletedColor,
307
- "--cs-icon-error": s?.iconErrorColor,
308
- "--cs-code-bg": s?.codeBg,
309
- "--cs-code-border": s?.codeBorderColor,
310
- "--cs-code-text": s?.codeTextColor,
311
- "--cs-border": s?.borderColor
312
- }), u = V(e);
313
- return /* @__PURE__ */ C("div", {
314
- style: l,
315
- className: i("w-full", H.panel, r, T.panel),
316
- children: /* @__PURE__ */ C("ul", {
317
- role: "list",
318
- className: "flex w-full flex-col gap-0.5 ps-5",
319
- children: u.map((e) => e.stage ? /* @__PURE__ */ C("li", {
320
- role: "listitem",
321
- children: /* @__PURE__ */ C(K, {
322
- stage: e.stage,
323
- isLive: t && e.stage.status == null,
324
- typography: c,
325
- labels: o
633
+ }),
634
+ /* @__PURE__ */ K("span", {
635
+ className: c("min-w-0 max-w-[22rem] truncate", i?.fontClassName ?? "dial-small-text", X.stageName, g && X.stageNameFailed),
636
+ children: /* @__PURE__ */ K(h, { text: e.name })
637
+ }),
638
+ /* @__PURE__ */ q("span", {
639
+ className: c("flex-none", i?.countFontClassName ?? "dial-tiny-text", X.count),
640
+ children: ["×", p.length]
326
641
  })
327
- }, e.key) : /* @__PURE__ */ C("li", {
642
+ ]
643
+ }),
644
+ expanded: y,
645
+ onToggle: (e) => r.onToggle(v, e),
646
+ className: ke,
647
+ headerClassName: c(Ae, X.collapseButton, X.row, X.stageHeader),
648
+ contentClassName: c("-mt-2 min-w-0 px-0", rt(b), X.stageRegion),
649
+ children: /* @__PURE__ */ K("ul", {
650
+ role: "list",
651
+ className: "flex min-w-0 flex-col gap-0.5",
652
+ children: y && p.map((e, t) => /* @__PURE__ */ K("li", {
328
653
  role: "listitem",
329
- children: /* @__PURE__ */ C(q, {
330
- row: e,
331
- isLive: t && (e.attempts?.some((e) => e.status == null) ?? !1),
332
- typography: c,
333
- labels: o
654
+ className: "min-w-0",
655
+ children: /* @__PURE__ */ K(it, {
656
+ node: e,
657
+ depth: b,
658
+ nameOverride: f(t + 1),
659
+ isStreaming: n,
660
+ expansion: r,
661
+ typography: i,
662
+ labels: a,
663
+ onAttachmentClick: s
334
664
  })
335
- }, e.key))
665
+ }, e.stage.index))
336
666
  })
337
667
  });
338
- }, Y = {
339
- toggleButton: "_toggleButton_1sa5v_1",
340
- executedLabel: "_executedLabel_1sa5v_13",
341
- stepsCount: "_stepsCount_1sa5v_17",
342
- doneIcon: "_doneIcon_1sa5v_22",
343
- failedText: "_failedText_1sa5v_26",
344
- liveName: "_liveName_1sa5v_30"
345
- }, X = ({ stages: e, isStreaming: r, labels: s, className: l, styles: f }) => {
346
- let { executedLabel: g = "Executed", stepsLabel: _ = () => "steps", failedCountLabel: v = (e) => `${e} failed`, runningStepLabel: S = (e, t) => `Step ${e} of ${t}`, runningAriaLabel: E = "Running", copyAriaLabel: D, failedAriaLabel: O, attemptLabel: k } = s ?? {}, [A, j] = x(r), M = b(r);
347
- y(() => {
348
- M.current && !r && j(!1), M.current = r;
349
- }, [r]);
350
- let { colors: N, panel: F } = f ?? {}, L = f?.typography ?? { fontClassName: "dial-small-text" }, V = n({
351
- "--cs-cg-label": N?.labelColor,
352
- "--cs-cg-label-hover": N?.labelHoverColor,
353
- "--cs-cg-steps-count": N?.stepsCountColor,
354
- "--cs-cg-done": N?.doneColor,
355
- "--cs-cg-failed": N?.failedColor,
356
- "--cs-text": F?.text,
357
- "--cs-row-hover": F?.rowHoverColor,
358
- "--cs-button-bg": F?.collapsedButtonBg,
359
- "--cs-stage-text": F?.stageTextColor,
360
- "--cs-failed-text": F?.failedColor,
361
- "--cs-tag-text": F?.tagTextColor,
362
- "--cs-count-text": F?.countTextColor,
363
- "--cs-duration-text": F?.durationTextColor,
364
- "--cs-icon-secondary": F?.iconSecondaryColor,
365
- "--cs-icon-completed": F?.iconCompletedColor,
366
- "--cs-icon-error": F?.iconErrorColor,
367
- "--cs-code-bg": F?.codeBg,
368
- "--cs-code-border": F?.codeBorderColor,
369
- "--cs-code-text": F?.codeTextColor,
370
- "--cs-border": F?.borderColor
668
+ }, ot = ({ nodes: e, depth: t, className: n, ...r }) => /* @__PURE__ */ K("ul", {
669
+ role: "list",
670
+ className: c("flex min-w-0 flex-col gap-0.5", n),
671
+ children: je(e).map((e) => /* @__PURE__ */ K("li", {
672
+ role: "listitem",
673
+ className: "min-w-0",
674
+ children: e.node ? /* @__PURE__ */ K(it, {
675
+ node: e.node,
676
+ depth: t,
677
+ ...r
678
+ }) : /* @__PURE__ */ K(at, {
679
+ row: e,
680
+ depth: t,
681
+ ...r
682
+ })
683
+ }, e.key))
684
+ }), st = ({ stages: e, isStreaming: t, className: n, styles: r, labels: i, onAttachmentClick: a, expansion: o }) => {
685
+ let { colors: l, typography: u } = r ?? {}, d = s({
686
+ "--cs-text": l?.text,
687
+ "--cs-row-hover": l?.rowHoverColor,
688
+ "--cs-button-bg": l?.collapsedButtonBg,
689
+ "--cs-stage-text": l?.stageTextColor,
690
+ "--cs-failed-text": l?.failedColor,
691
+ "--cs-tag-text": l?.tagTextColor,
692
+ "--cs-count-text": l?.countTextColor,
693
+ "--cs-duration-text": l?.durationTextColor,
694
+ "--cs-icon-secondary": l?.iconSecondaryColor,
695
+ "--cs-icon-completed": l?.iconCompletedColor,
696
+ "--cs-icon-error": l?.iconErrorColor,
697
+ "--cs-code-bg": l?.codeBg,
698
+ "--cs-code-border": l?.codeBorderColor,
699
+ "--cs-code-text": l?.codeTextColor,
700
+ "--cs-border": l?.borderColor
701
+ }), f = W(() => Ee(e), [e]);
702
+ return /* @__PURE__ */ K("div", {
703
+ style: d,
704
+ className: c("w-full min-w-0", X.panel, n, J.panel),
705
+ children: /* @__PURE__ */ K(ot, {
706
+ nodes: f,
707
+ depth: 0,
708
+ className: "w-full ps-5",
709
+ isStreaming: t,
710
+ expansion: o,
711
+ typography: u,
712
+ labels: i,
713
+ onAttachmentClick: a
714
+ })
715
+ });
716
+ }, ct = (e) => {
717
+ let t = ve();
718
+ return /* @__PURE__ */ K(st, {
719
+ ...e,
720
+ expansion: t
721
+ });
722
+ }, $ = {
723
+ toggleButton: "_toggleButton_16fae_7",
724
+ groupRegion: "_groupRegion_16fae_28",
725
+ executedLabel: "_executedLabel_16fae_32",
726
+ doneIcon: "_doneIcon_16fae_36",
727
+ failedText: "_failedText_16fae_40",
728
+ liveName: "_liveName_16fae_44"
729
+ }, lt = ({ stages: e, isStreaming: t, labels: n, className: r, styles: i, onAttachmentClick: a }) => {
730
+ let { executedLabel: l = "Executed", stepsLabel: u = () => "steps", failedCountLabel: m = (e) => `${e} failed`, runningAriaLabel: g = "Running", copyAriaLabel: _, codeBlockCopiedLabel: v, tableScrollRegionAriaLabel: b, mathScrollRegionAriaLabel: x, failedAriaLabel: C, attemptLabel: w, attachmentClickLabel: T } = n ?? {}, [E, D] = G(t), O = ve(), { reset: k } = O, A = e.length > 1;
731
+ U(() => {
732
+ A && !E && k();
733
+ }, [
734
+ A,
735
+ E,
736
+ k
737
+ ]);
738
+ let j = ge(t);
739
+ U(() => {
740
+ j.current && !t && D(!1), j.current = t;
741
+ }, [t]);
742
+ let { colors: M, panel: N } = i ?? {}, P = i?.typography ?? { fontClassName: "dial-small-text" }, F = s({
743
+ "--cs-cg-label": M?.labelColor,
744
+ "--cs-cg-label-hover": M?.labelHoverColor,
745
+ "--cs-cg-done": M?.doneColor,
746
+ "--cs-cg-failed": M?.failedColor,
747
+ "--cs-text": N?.text,
748
+ "--cs-row-hover": N?.rowHoverColor,
749
+ "--cs-button-bg": N?.collapsedButtonBg,
750
+ "--cs-stage-text": N?.stageTextColor,
751
+ "--cs-failed-text": N?.failedColor,
752
+ "--cs-tag-text": N?.tagTextColor,
753
+ "--cs-count-text": N?.countTextColor,
754
+ "--cs-duration-text": N?.durationTextColor,
755
+ "--cs-icon-secondary": N?.iconSecondaryColor,
756
+ "--cs-icon-completed": N?.iconCompletedColor,
757
+ "--cs-icon-error": N?.iconErrorColor,
758
+ "--cs-code-bg": N?.codeBg,
759
+ "--cs-code-border": N?.codeBorderColor,
760
+ "--cs-code-text": N?.codeTextColor,
761
+ "--cs-border": N?.borderColor
371
762
  });
372
763
  if (e.length === 0) return null;
373
- let H = {
374
- copyAriaLabel: D,
375
- runningAriaLabel: E,
376
- failedAriaLabel: O,
377
- attemptLabel: k
764
+ let I = {
765
+ copyAriaLabel: _,
766
+ codeBlockCopiedLabel: v,
767
+ tableScrollRegionAriaLabel: b,
768
+ mathScrollRegionAriaLabel: x,
769
+ runningAriaLabel: g,
770
+ failedAriaLabel: C,
771
+ attemptLabel: w,
772
+ attachmentClickLabel: T
378
773
  };
379
- if (e.length === 1) return /* @__PURE__ */ C(J, {
774
+ if (e.length === 1) return /* @__PURE__ */ K(st, {
380
775
  stages: e,
381
- isStreaming: r,
382
- className: l,
776
+ isStreaming: t,
777
+ expansion: O,
778
+ className: r,
383
779
  styles: {
384
- colors: F,
385
- typography: f?.typography
780
+ colors: N,
781
+ typography: i?.typography
386
782
  },
387
- labels: H
783
+ labels: I,
784
+ onAttachmentClick: a
388
785
  });
389
- let U = e.some((e) => e.status === t.Failed), W = R(e.map((e) => e.name)), G = W > 0 ? I(W) : void 0, K = r ? z(e) : void 0, q;
390
- if (r) {
391
- let t = K ? B(e, K) : e.length, n = K ? P(K.name).name : "";
392
- q = /* @__PURE__ */ w("span", {
786
+ let L = e.some((e) => e.status === o.Failed), R;
787
+ if (t) {
788
+ let t = Y((we(e) ?? e[e.length - 1]).name).name;
789
+ R = /* @__PURE__ */ q("span", {
393
790
  role: "status",
394
791
  "aria-live": "polite",
395
792
  className: "flex min-w-0 items-center gap-2",
396
- children: [
397
- /* @__PURE__ */ C("span", {
398
- className: "flex flex-none items-center",
399
- children: /* @__PURE__ */ C(d, {
400
- size: 14,
401
- ariaLabel: E
402
- })
403
- }),
404
- /* @__PURE__ */ C("span", {
405
- className: i("flex-none whitespace-nowrap", L.fontClassName, Y.liveName),
406
- children: S(t, e.length)
407
- }),
408
- n && /* @__PURE__ */ C("span", {
409
- className: i("min-w-0 max-w-[22rem] truncate", L.fontClassName, Y.executedLabel),
410
- children: /* @__PURE__ */ C(c, { text: n })
793
+ children: [/* @__PURE__ */ K("span", {
794
+ className: "flex flex-none items-center",
795
+ children: /* @__PURE__ */ K(y, {
796
+ size: 14,
797
+ ariaLabel: g
411
798
  })
412
- ]
799
+ }), t && /* @__PURE__ */ K("span", {
800
+ className: c("min-w-0 max-w-[22rem] truncate", P.fontClassName, $.liveName),
801
+ children: /* @__PURE__ */ K(h, { text: t })
802
+ })]
413
803
  });
414
- } else if (U) {
415
- let n = e.filter((e) => e.status === t.Failed).length;
416
- q = /* @__PURE__ */ w("span", {
804
+ } else if (L) {
805
+ let t = e.filter((e) => e.status === o.Failed).length;
806
+ R = /* @__PURE__ */ q("span", {
417
807
  className: "inline-flex items-center gap-1",
418
- children: [
419
- /* @__PURE__ */ w("span", {
420
- className: i(L.fontClassName, Y.executedLabel),
421
- children: [
422
- g,
423
- " ",
424
- e.length,
425
- " ",
426
- _(e.length)
427
- ]
428
- }),
429
- /* @__PURE__ */ C("span", {
430
- className: i(L.fontClassName, Y.failedText),
431
- children: v(n)
432
- }),
433
- G && /* @__PURE__ */ C("span", {
434
- className: i(L.fontClassName, Y.stepsCount),
435
- children: G
436
- })
437
- ]
438
- });
439
- } else q = /* @__PURE__ */ w("span", {
440
- className: "inline-flex items-center gap-1",
441
- children: [
442
- /* @__PURE__ */ C(p, {
443
- size: a.SM,
444
- className: Y.doneIcon,
445
- "aria-hidden": !0,
446
- stroke: o
447
- }),
448
- /* @__PURE__ */ w("span", {
449
- className: i(L.fontClassName, Y.executedLabel),
808
+ children: [/* @__PURE__ */ q("span", {
809
+ className: c(P.fontClassName, $.executedLabel),
450
810
  children: [
451
- g,
811
+ l,
452
812
  " ",
453
813
  e.length,
454
814
  " ",
455
- _(e.length)
815
+ u(e.length)
456
816
  ]
457
- }),
458
- G && /* @__PURE__ */ C("span", {
459
- className: i(L.fontClassName, Y.stepsCount),
460
- children: G
461
- })
462
- ]
817
+ }), /* @__PURE__ */ K("span", {
818
+ className: c(P.fontClassName, $.failedText),
819
+ children: m(t)
820
+ })]
821
+ });
822
+ } else R = /* @__PURE__ */ q("span", {
823
+ className: "inline-flex items-center gap-1",
824
+ children: [/* @__PURE__ */ K(S, {
825
+ size: f.SM,
826
+ className: $.doneIcon,
827
+ "aria-hidden": !0,
828
+ stroke: p
829
+ }), /* @__PURE__ */ q("span", {
830
+ className: c(P.fontClassName, $.executedLabel),
831
+ children: [
832
+ l,
833
+ " ",
834
+ e.length,
835
+ " ",
836
+ u(e.length)
837
+ ]
838
+ })]
463
839
  });
464
- return /* @__PURE__ */ w("div", {
465
- style: V,
466
- className: i("flex w-full flex-col gap-1", l, T.group),
467
- children: [/* @__PURE__ */ C(u, {
468
- className: i(Y.toggleButton, T.groupToggle),
469
- textClassName: "min-w-0",
470
- onClick: () => j((e) => !e),
471
- "aria-expanded": A,
472
- iconAfter: A ? /* @__PURE__ */ C(m, {
473
- size: 12,
474
- "aria-hidden": !0,
475
- stroke: o
476
- }) : /* @__PURE__ */ C(h, {
477
- size: 12,
478
- className: "rtl:scale-x-[-1]",
479
- "aria-hidden": !0,
480
- stroke: o
481
- }),
482
- label: q
483
- }), /* @__PURE__ */ C("div", {
484
- className: i("grid transition-[grid-template-rows] duration-300 ease-in-out", A ? "grid-rows-[1fr]" : "grid-rows-[0fr]"),
485
- children: /* @__PURE__ */ C("div", {
486
- className: "overflow-hidden",
487
- children: /* @__PURE__ */ C(J, {
488
- stages: e,
489
- isStreaming: r,
490
- styles: {
491
- colors: F,
492
- typography: f?.typography
493
- },
494
- labels: H,
495
- className: "pt-1"
496
- })
840
+ return /* @__PURE__ */ K("div", {
841
+ style: F,
842
+ className: c("flex w-full flex-col gap-1", r, J.group),
843
+ children: /* @__PURE__ */ K(d, {
844
+ title: R,
845
+ expanded: E,
846
+ onToggle: D,
847
+ className: "overflow-visible py-0",
848
+ headerClassName: c("justify-start gap-1 rounded-none px-0", $.toggleButton, J.groupToggle),
849
+ contentClassName: c("-mt-2 px-0", $.groupRegion),
850
+ children: E && /* @__PURE__ */ K(st, {
851
+ stages: e,
852
+ isStreaming: t,
853
+ expansion: O,
854
+ styles: {
855
+ colors: N,
856
+ typography: i?.typography
857
+ },
858
+ labels: I,
859
+ className: "pt-1",
860
+ onAttachmentClick: a
497
861
  })
498
- })]
862
+ })
499
863
  });
500
864
  };
501
865
  //#endregion
502
- export { T as CONVERSATION_STAGES_CLASS, X as CollapsedGroup, J as StagesPanel };
866
+ export { J as CONVERSATION_STAGES_CLASS, lt as CollapsedGroup, ct as StagesPanel };