@shapesos/clay 0.18.0 → 0.19.1
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.
- package/dist/artifacts.cjs +207 -139
- package/dist/artifacts.cjs.map +1 -1
- package/dist/artifacts.js +5 -2
- package/dist/badge.cjs +70 -0
- package/dist/badge.cjs.map +1 -0
- package/dist/badge.d.cts +28 -0
- package/dist/badge.d.ts +28 -0
- package/dist/badge.js +9 -0
- package/dist/badge.js.map +1 -0
- package/dist/blocks.cjs +452 -185
- package/dist/blocks.cjs.map +1 -1
- package/dist/blocks.css +1 -1
- package/dist/blocks.d.cts +14 -3
- package/dist/blocks.d.ts +14 -3
- package/dist/blocks.js +17 -5
- package/dist/chat.cjs +457 -240
- package/dist/chat.cjs.map +1 -1
- package/dist/chat.d.cts +1 -1
- package/dist/chat.d.ts +1 -1
- package/dist/chat.js +10 -5
- package/dist/{chunk-JGMN6W72.js → chunk-2X4KUXYP.js} +1 -1
- package/dist/{chunk-QR4VBGK4.js → chunk-63AGNGKG.js} +81 -200
- package/dist/chunk-63AGNGKG.js.map +1 -0
- package/dist/chunk-CSTCTO3B.js +161 -0
- package/dist/chunk-CSTCTO3B.js.map +1 -0
- package/dist/chunk-EIAWZXE4.js +69 -0
- package/dist/chunk-EIAWZXE4.js.map +1 -0
- package/dist/chunk-EXRNGIQ2.js +41 -0
- package/dist/chunk-EXRNGIQ2.js.map +1 -0
- package/dist/{chunk-4MZZH3WX.js → chunk-HU5W7CGE.js} +37 -2
- package/dist/chunk-HU5W7CGE.js.map +1 -0
- package/dist/chunk-PISZYS2H.js +406 -0
- package/dist/chunk-PISZYS2H.js.map +1 -0
- package/dist/{chunk-CATIRDZP.js → chunk-PWSEEUVL.js} +10 -44
- package/dist/chunk-PWSEEUVL.js.map +1 -0
- package/dist/copy-button.cjs +439 -0
- package/dist/copy-button.cjs.map +1 -0
- package/dist/copy-button.d.cts +20 -0
- package/dist/copy-button.d.ts +20 -0
- package/dist/copy-button.js +12 -0
- package/dist/copy-button.js.map +1 -0
- package/dist/index.cjs +533 -298
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +26 -9
- package/dist/table.cjs +40 -0
- package/dist/table.cjs.map +1 -1
- package/dist/table.d.cts +37 -2
- package/dist/table.d.ts +37 -2
- package/dist/table.js +11 -1
- package/dist/{types-BDYPVP2N.d.cts → types-Bhg0_ES8.d.cts} +74 -2
- package/dist/{types-BMwa4bPW.d.ts → types-orOQcI2z.d.ts} +74 -2
- package/package.json +11 -1
- package/dist/chunk-4MZZH3WX.js.map +0 -1
- package/dist/chunk-7MY4X4YL.js +0 -250
- package/dist/chunk-7MY4X4YL.js.map +0 -1
- package/dist/chunk-CATIRDZP.js.map +0 -1
- package/dist/chunk-QR4VBGK4.js.map +0 -1
- /package/dist/{chunk-JGMN6W72.js.map → chunk-2X4KUXYP.js.map} +0 -0
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CopyButton
|
|
3
|
+
} from "./chunk-EIAWZXE4.js";
|
|
4
|
+
import {
|
|
5
|
+
markdownToPlainText
|
|
6
|
+
} from "./chunk-NMKKU2UG.js";
|
|
7
|
+
import {
|
|
8
|
+
ArtifactServices,
|
|
9
|
+
artifactToClipboardText
|
|
10
|
+
} from "./chunk-63AGNGKG.js";
|
|
11
|
+
import {
|
|
12
|
+
IconChevronDown,
|
|
13
|
+
IconFlask2Filled
|
|
14
|
+
} from "./chunk-CSTCTO3B.js";
|
|
15
|
+
import {
|
|
16
|
+
Badge
|
|
17
|
+
} from "./chunk-EXRNGIQ2.js";
|
|
18
|
+
import {
|
|
19
|
+
Icon
|
|
20
|
+
} from "./chunk-OLJIJYB5.js";
|
|
21
|
+
import {
|
|
22
|
+
typographyMixin,
|
|
23
|
+
typographyTypes
|
|
24
|
+
} from "./chunk-UXT2H3FM.js";
|
|
25
|
+
import {
|
|
26
|
+
colors
|
|
27
|
+
} from "./chunk-SN3ORQSJ.js";
|
|
28
|
+
import {
|
|
29
|
+
DATA_TABLE_CELL_CLASS,
|
|
30
|
+
DATA_TABLE_HEAD_CLASS,
|
|
31
|
+
DATA_TABLE_ROW_CLASS,
|
|
32
|
+
DataTable,
|
|
33
|
+
TableCell,
|
|
34
|
+
TableHead,
|
|
35
|
+
TableRow
|
|
36
|
+
} from "./chunk-HU5W7CGE.js";
|
|
37
|
+
|
|
38
|
+
// src/components/blocks/types.ts
|
|
39
|
+
var blockTypes = {
|
|
40
|
+
TEXT: "TEXT",
|
|
41
|
+
ARTIFACT_REF: "ARTIFACT_REF",
|
|
42
|
+
NOTIFICATION_DRAFT: "NOTIFICATION_DRAFT"
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// src/components/blocks/artifact-ref-block/artifact-ref-block.tsx
|
|
46
|
+
import { jsx } from "react/jsx-runtime";
|
|
47
|
+
function ArtifactRefBlock({ block }) {
|
|
48
|
+
const { artifact, labels, callbacks } = block.payload;
|
|
49
|
+
const entry = ArtifactServices[artifact.type];
|
|
50
|
+
if (!entry) return null;
|
|
51
|
+
const Component = entry.Component;
|
|
52
|
+
return /* @__PURE__ */ jsx(Component, { artifact, labels, callbacks });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/components/blocks/block-services/artifact-ref-block-service.ts
|
|
56
|
+
var ArtifactRefBlockService = {
|
|
57
|
+
type: blockTypes.ARTIFACT_REF,
|
|
58
|
+
Component: ArtifactRefBlock,
|
|
59
|
+
/**
|
|
60
|
+
* Delegates to the registered artifact component's `toClipboardText`. Falls back to
|
|
61
|
+
* `[Artifact: <title>]` via `artifactToClipboardText`'s own fallback when the artifact type
|
|
62
|
+
* has no registered component, so copy never silently produces an empty string.
|
|
63
|
+
*/
|
|
64
|
+
toClipboardText: (block) => artifactToClipboardText(block.payload.artifact)
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// src/components/blocks/notification-draft-block/types.ts
|
|
68
|
+
var notificationChannels = {
|
|
69
|
+
/** Branded email — renders a From/subject header. */
|
|
70
|
+
EMAIL: "email",
|
|
71
|
+
/** Slack DM — renders as a chat bubble, no subject. */
|
|
72
|
+
SLACK: "slack",
|
|
73
|
+
/** Microsoft Teams DM — renders as a chat bubble, no subject. */
|
|
74
|
+
TEAMS: "teams"
|
|
75
|
+
};
|
|
76
|
+
var notificationEmailTypes = {
|
|
77
|
+
/** Recipient's work email. */
|
|
78
|
+
WORK: "work",
|
|
79
|
+
/** Recipient's personal email. */
|
|
80
|
+
PERSONAL: "personal"
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// src/components/blocks/notification-draft-block/notification-draft-block.tsx
|
|
84
|
+
import { useState } from "react";
|
|
85
|
+
|
|
86
|
+
// src/components/blocks/markdown/markdown.tsx
|
|
87
|
+
import ReactMarkdown from "react-markdown";
|
|
88
|
+
import remarkBreaks from "remark-breaks";
|
|
89
|
+
import remarkGfm from "remark-gfm";
|
|
90
|
+
|
|
91
|
+
// src/components/blocks/scrollable-table/scrollable-table-styles.ts
|
|
92
|
+
import styled from "styled-components";
|
|
93
|
+
var TableContainer = styled.div`
|
|
94
|
+
position: relative;
|
|
95
|
+
margin-block: 8px 16px;
|
|
96
|
+
`;
|
|
97
|
+
var TableScroll = styled.div`
|
|
98
|
+
width: 100%;
|
|
99
|
+
overflow-x: auto;
|
|
100
|
+
overflow-y: hidden;
|
|
101
|
+
`;
|
|
102
|
+
|
|
103
|
+
// src/components/blocks/scrollable-table/scrollable-table.tsx
|
|
104
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
105
|
+
function ScrollableTable({ node: _node, ...props }) {
|
|
106
|
+
return /* @__PURE__ */ jsx2(TableContainer, { children: /* @__PURE__ */ jsx2(TableScroll, { children: /* @__PURE__ */ jsx2("table", { ...props }) }) });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// src/components/blocks/text-block/sanitize.ts
|
|
110
|
+
function sanitize(text) {
|
|
111
|
+
return text.split("\n").filter((line) => {
|
|
112
|
+
const t = line.trim();
|
|
113
|
+
return !(t.startsWith("<!-- table-title:") && t.endsWith("-->"));
|
|
114
|
+
}).join("\n");
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// src/components/blocks/text-block/text-block-styles.ts
|
|
118
|
+
import styled2 from "styled-components";
|
|
119
|
+
var TextBlockWrapper = styled2.div`
|
|
120
|
+
${typographyMixin(typographyTypes.GEIST_BODY_S_REGULAR)};
|
|
121
|
+
color: ${colors["brown-100"]};
|
|
122
|
+
word-break: break-word;
|
|
123
|
+
|
|
124
|
+
& h1 {
|
|
125
|
+
${typographyMixin(typographyTypes.GEIST_HEADING_S_BOLD)};
|
|
126
|
+
margin-block: 20px;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
& h2 {
|
|
130
|
+
${typographyMixin(typographyTypes.GEIST_BODY_L_SEMI_BOLD)};
|
|
131
|
+
margin-block: 12px;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
& h3,
|
|
135
|
+
& h4,
|
|
136
|
+
& h5,
|
|
137
|
+
& h6 {
|
|
138
|
+
${typographyMixin(typographyTypes.GEIST_BODY_M_SEMI_BOLD)};
|
|
139
|
+
margin-block: 8px;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
& strong {
|
|
143
|
+
${typographyMixin(typographyTypes.GEIST_BODY_S_SEMI_BOLD)};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
& p {
|
|
147
|
+
margin-block: 0px;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
& p + p {
|
|
151
|
+
margin-block: 8px 0px;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
& ul,
|
|
155
|
+
& ol {
|
|
156
|
+
margin-block: 16px;
|
|
157
|
+
padding-left: 20px;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
& li + li {
|
|
161
|
+
margin-block: 4px;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
& ul {
|
|
165
|
+
list-style-type: disc;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
& ul ul {
|
|
169
|
+
list-style-type: circle;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
& ul ul ul {
|
|
173
|
+
list-style-type: square;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
& ol {
|
|
177
|
+
list-style-type: decimal;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
& ol ol {
|
|
181
|
+
list-style-type: lower-alpha;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
& ol ol ol {
|
|
185
|
+
list-style-type: lower-roman;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
& a {
|
|
189
|
+
color: inherit;
|
|
190
|
+
text-decoration-line: underline;
|
|
191
|
+
text-decoration-style: dotted;
|
|
192
|
+
text-decoration-thickness: auto;
|
|
193
|
+
text-underline-offset: auto;
|
|
194
|
+
text-underline-position: from-font;
|
|
195
|
+
transition: color 75ms ease-in-out;
|
|
196
|
+
|
|
197
|
+
&:hover {
|
|
198
|
+
color: ${colors["blue-600"]};
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
& hr {
|
|
203
|
+
border: none;
|
|
204
|
+
border-top: 1px solid ${colors["brown-40"]};
|
|
205
|
+
margin-block: 20px;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
& table {
|
|
209
|
+
margin: 0;
|
|
210
|
+
width: 100%;
|
|
211
|
+
border-collapse: collapse;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
& th,
|
|
215
|
+
& td {
|
|
216
|
+
border: none;
|
|
217
|
+
border-bottom: 1px solid ${colors["brown-40"]};
|
|
218
|
+
text-align: left;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
& th {
|
|
222
|
+
${typographyMixin(typographyTypes.GEIST_LABEL_CAPTION_MEDIUM)};
|
|
223
|
+
padding: 8px;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
& td {
|
|
227
|
+
${typographyMixin(typographyTypes.GEIST_BODY_XS_MEDIUM)};
|
|
228
|
+
padding: 16px 8px;
|
|
229
|
+
min-width: 150px;
|
|
230
|
+
width: 1%;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
& td strong {
|
|
234
|
+
font-weight: inherit;
|
|
235
|
+
font-size: inherit;
|
|
236
|
+
line-height: inherit;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
& blockquote {
|
|
240
|
+
margin-block: 4px;
|
|
241
|
+
margin-inline: 0px;
|
|
242
|
+
padding-left: 16px;
|
|
243
|
+
border-left: 4px solid ${colors["brown-40"]};
|
|
244
|
+
color: ${colors["brown-80"]};
|
|
245
|
+
}
|
|
246
|
+
`;
|
|
247
|
+
|
|
248
|
+
// src/components/blocks/markdown/markdown.tsx
|
|
249
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
250
|
+
var markdownComponents = {
|
|
251
|
+
table: ((tableProps) => /* @__PURE__ */ jsx3(ScrollableTable, { ...tableProps }))
|
|
252
|
+
};
|
|
253
|
+
function Markdown({ children }) {
|
|
254
|
+
return /* @__PURE__ */ jsx3(TextBlockWrapper, { children: /* @__PURE__ */ jsx3(ReactMarkdown, { remarkPlugins: [remarkGfm, remarkBreaks], components: markdownComponents, children: sanitize(children) }) });
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// src/components/blocks/notification-draft-block/to-text.ts
|
|
258
|
+
function notificationDraftToText(payload) {
|
|
259
|
+
const { channel, subject, body } = payload;
|
|
260
|
+
const text = markdownToPlainText(body);
|
|
261
|
+
return channel === notificationChannels.EMAIL && subject ? `${subject}
|
|
262
|
+
|
|
263
|
+
${text}` : text;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// src/components/blocks/notification-draft-block/notification-draft-block.tsx
|
|
267
|
+
import { jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
268
|
+
var CHIP_LIMIT = 3;
|
|
269
|
+
var RECIPIENTS_MAX_HEIGHT = 320;
|
|
270
|
+
function chipLabel(recipient) {
|
|
271
|
+
return recipient.name ?? recipient.email ?? recipient.employeeId;
|
|
272
|
+
}
|
|
273
|
+
function channelCellText(recipient) {
|
|
274
|
+
return recipient.fallback ? `${recipient.channelLabel} (fallback)` : recipient.channelLabel;
|
|
275
|
+
}
|
|
276
|
+
function FieldLabel({ children }) {
|
|
277
|
+
return /* @__PURE__ */ jsx4("span", { className: "text-geist-label-caption-medium tracking-wide text-brown-60", children });
|
|
278
|
+
}
|
|
279
|
+
function RecipientChips({ recipients }) {
|
|
280
|
+
const shown = recipients.slice(0, CHIP_LIMIT);
|
|
281
|
+
const overflow = recipients.length - shown.length;
|
|
282
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [
|
|
283
|
+
shown.map((recipient) => /* @__PURE__ */ jsx4(Badge, { variant: "outline", children: chipLabel(recipient) }, recipient.employeeId)),
|
|
284
|
+
overflow > 0 && /* @__PURE__ */ jsx4(Badge, { variant: "subtle", children: `+${overflow}` })
|
|
285
|
+
] });
|
|
286
|
+
}
|
|
287
|
+
function RecipientsTable({ recipients }) {
|
|
288
|
+
return /* @__PURE__ */ jsx4(
|
|
289
|
+
DataTable,
|
|
290
|
+
{
|
|
291
|
+
maxBodyHeight: RECIPIENTS_MAX_HEIGHT,
|
|
292
|
+
header: /* @__PURE__ */ jsxs(TableRow, { className: "hover:bg-transparent", children: [
|
|
293
|
+
/* @__PURE__ */ jsx4(TableHead, { scope: "col", className: DATA_TABLE_HEAD_CLASS, children: "Name" }),
|
|
294
|
+
/* @__PURE__ */ jsx4(TableHead, { scope: "col", className: DATA_TABLE_HEAD_CLASS, children: "Email" }),
|
|
295
|
+
/* @__PURE__ */ jsx4(TableHead, { scope: "col", className: DATA_TABLE_HEAD_CLASS, children: "Channel" })
|
|
296
|
+
] }),
|
|
297
|
+
children: recipients.map((recipient) => /* @__PURE__ */ jsxs(TableRow, { className: DATA_TABLE_ROW_CLASS, children: [
|
|
298
|
+
/* @__PURE__ */ jsx4(TableCell, { className: DATA_TABLE_CELL_CLASS, children: recipient.name ?? "\u2014" }),
|
|
299
|
+
/* @__PURE__ */ jsx4(TableCell, { className: DATA_TABLE_CELL_CLASS, children: recipient.email ?? "\u2014" }),
|
|
300
|
+
/* @__PURE__ */ jsx4(TableCell, { className: DATA_TABLE_CELL_CLASS, children: /* @__PURE__ */ jsx4(Badge, { tone: recipient.fallback ? "warning" : "neutral", variant: "subtle", children: channelCellText(recipient) }) })
|
|
301
|
+
] }, recipient.employeeId))
|
|
302
|
+
}
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
function NotificationDraftBlock({ block }) {
|
|
306
|
+
const { channel, subject, body, recipients } = block.payload;
|
|
307
|
+
const [detailsOpen, setDetailsOpen] = useState(false);
|
|
308
|
+
const showSubject = channel === notificationChannels.EMAIL && subject;
|
|
309
|
+
return /* @__PURE__ */ jsxs("div", { className: "overflow-hidden rounded-2xl border border-brown-30 bg-white", children: [
|
|
310
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 border-b border-brown-30 px-4 py-3", children: [
|
|
311
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
312
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
313
|
+
/* @__PURE__ */ jsx4("span", { className: "text-geist-body-s-semi-bold text-brown-100", children: "Notification draft" }),
|
|
314
|
+
/* @__PURE__ */ jsxs(Badge, { tone: "violet", variant: "subtle", size: "sm", className: "gap-1 py-1", children: [
|
|
315
|
+
/* @__PURE__ */ jsx4(Icon, { icon: IconFlask2Filled, size: 12 }),
|
|
316
|
+
"Labs"
|
|
317
|
+
] })
|
|
318
|
+
] }),
|
|
319
|
+
/* @__PURE__ */ jsx4(CopyButton, { text: notificationDraftToText(block.payload), copyLabel: "Copy draft", copiedLabel: "Copied" })
|
|
320
|
+
] }),
|
|
321
|
+
showSubject && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5", children: [
|
|
322
|
+
/* @__PURE__ */ jsx4(FieldLabel, { children: "Title" }),
|
|
323
|
+
/* @__PURE__ */ jsx4("p", { className: "text-geist-body-s-medium text-brown-100", children: subject })
|
|
324
|
+
] }),
|
|
325
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
326
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
327
|
+
/* @__PURE__ */ jsx4(FieldLabel, { children: `Recipients (${recipients.length})` }),
|
|
328
|
+
/* @__PURE__ */ jsxs(
|
|
329
|
+
"button",
|
|
330
|
+
{
|
|
331
|
+
type: "button",
|
|
332
|
+
"aria-expanded": detailsOpen,
|
|
333
|
+
onClick: () => setDetailsOpen((open) => !open),
|
|
334
|
+
className: "inline-flex items-center gap-1 text-geist-label-caption-medium text-brown-70 transition-colors hover:text-brown-100",
|
|
335
|
+
children: [
|
|
336
|
+
"Details",
|
|
337
|
+
/* @__PURE__ */ jsx4(Icon, { icon: IconChevronDown, size: 14, className: detailsOpen ? "rotate-180" : void 0 })
|
|
338
|
+
]
|
|
339
|
+
}
|
|
340
|
+
)
|
|
341
|
+
] }),
|
|
342
|
+
detailsOpen ? /* @__PURE__ */ jsx4(RecipientsTable, { recipients }) : /* @__PURE__ */ jsx4(RecipientChips, { recipients })
|
|
343
|
+
] })
|
|
344
|
+
] }),
|
|
345
|
+
/* @__PURE__ */ jsx4("div", { className: "px-4 py-3", children: /* @__PURE__ */ jsx4(Markdown, { children: body }) })
|
|
346
|
+
] });
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// src/components/blocks/block-services/notification-draft-block-service.ts
|
|
350
|
+
var NotificationDraftBlockService = {
|
|
351
|
+
type: blockTypes.NOTIFICATION_DRAFT,
|
|
352
|
+
Component: NotificationDraftBlock,
|
|
353
|
+
/**
|
|
354
|
+
* Plain-text clipboard form of the drafted notification — shared with the in-block copy button
|
|
355
|
+
* via {@link notificationDraftToText} so both copy the same text.
|
|
356
|
+
*/
|
|
357
|
+
toClipboardText: (block) => notificationDraftToText(block.payload)
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
// src/components/blocks/text-block/text-block.tsx
|
|
361
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
362
|
+
function TextBlock({ block }) {
|
|
363
|
+
return /* @__PURE__ */ jsx5(Markdown, { children: block.payload.text });
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// src/components/blocks/block-services/text-block-service.ts
|
|
367
|
+
var TextBlockService = {
|
|
368
|
+
type: blockTypes.TEXT,
|
|
369
|
+
Component: TextBlock,
|
|
370
|
+
/**
|
|
371
|
+
* Converts the block's markdown source to plain text so the final clipboard value is clean
|
|
372
|
+
* when pasted into tools that don't render markdown. Each block type owns its own clipboard
|
|
373
|
+
* conversion so `useCopyToClipboard` can write text verbatim without a second pass.
|
|
374
|
+
*/
|
|
375
|
+
toClipboardText: (block) => markdownToPlainText(block.payload.text)
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
// src/components/blocks/block-services/index.ts
|
|
379
|
+
var BlockServices = {
|
|
380
|
+
[blockTypes.TEXT]: TextBlockService,
|
|
381
|
+
[blockTypes.ARTIFACT_REF]: ArtifactRefBlockService,
|
|
382
|
+
[blockTypes.NOTIFICATION_DRAFT]: NotificationDraftBlockService
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
// src/components/blocks/block/block.tsx
|
|
386
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
387
|
+
function Block({ block }) {
|
|
388
|
+
const service = BlockServices[block.type];
|
|
389
|
+
if (!service) return null;
|
|
390
|
+
const { Component } = service;
|
|
391
|
+
return /* @__PURE__ */ jsx6(Component, { block });
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export {
|
|
395
|
+
blockTypes,
|
|
396
|
+
ArtifactRefBlock,
|
|
397
|
+
ArtifactRefBlockService,
|
|
398
|
+
notificationChannels,
|
|
399
|
+
notificationEmailTypes,
|
|
400
|
+
NotificationDraftBlock,
|
|
401
|
+
NotificationDraftBlockService,
|
|
402
|
+
TextBlockService,
|
|
403
|
+
BlockServices,
|
|
404
|
+
Block
|
|
405
|
+
};
|
|
406
|
+
//# sourceMappingURL=chunk-PISZYS2H.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/blocks/types.ts","../src/components/blocks/artifact-ref-block/artifact-ref-block.tsx","../src/components/blocks/block-services/artifact-ref-block-service.ts","../src/components/blocks/notification-draft-block/types.ts","../src/components/blocks/notification-draft-block/notification-draft-block.tsx","../src/components/blocks/markdown/markdown.tsx","../src/components/blocks/scrollable-table/scrollable-table-styles.ts","../src/components/blocks/scrollable-table/scrollable-table.tsx","../src/components/blocks/text-block/sanitize.ts","../src/components/blocks/text-block/text-block-styles.ts","../src/components/blocks/notification-draft-block/to-text.ts","../src/components/blocks/block-services/notification-draft-block-service.ts","../src/components/blocks/text-block/text-block.tsx","../src/components/blocks/block-services/text-block-service.ts","../src/components/blocks/block-services/index.ts","../src/components/blocks/block/block.tsx"],"sourcesContent":["import type { ComponentType } from \"react\";\n\nimport type { ArtifactCallbacksOf, ArtifactLabelsOf, ArtifactRecord } from \"@/components/artifacts/types\";\nimport type { NotificationDraftBlockRecord } from \"./notification-draft-block/types\";\n\n/** Block-type discriminator constants. Mirrors the wire shape from io-server / shapes-agent. */\nexport const blockTypes = {\n TEXT: \"TEXT\",\n ARTIFACT_REF: \"ARTIFACT_REF\",\n NOTIFICATION_DRAFT: \"NOTIFICATION_DRAFT\",\n} as const;\n\n/** Discriminator for content blocks. */\nexport type BlockType = (typeof blockTypes)[keyof typeof blockTypes];\n\n/** Plain-text content block — rendered as Markdown. */\nexport interface TextBlockRecord {\n /** Block-type discriminator. */\n type: typeof blockTypes.TEXT;\n /** Type-specific data; kept as `payload` to match the wire shape 1:1. */\n payload: {\n /** The Markdown source for this text segment. */\n text: string;\n };\n}\n\n/**\n * Reference-to-an-artifact content block — dispatched to the per-type artifact component.\n *\n * The artifact-domain types (`ArtifactRecord`, `TableArtifactRecord`, etc.) live in\n * `@/components/artifacts/types` so the artifact layer can be consumed independently of the\n * block layer (e.g. by a future surface that renders an artifact outside chat). The block layer\n * imports them here to wrap an artifact in an `ARTIFACT_REF` block.\n *\n * `ArtifactRefBlockRecord` is a *distributed* union over `ArtifactRecord` branches — TS narrows\n * `labels` and `callbacks` to the slice matching `artifact.type` via `ArtifactLabelsOf<T>` /\n * `ArtifactCallbacksOf<T>`. Without this distribution, `Partial<ChartLabels | TableLabels>`\n * collapses to `Partial<ChartLabels> | Partial<TableLabels>` and TS accepts chart-only keys on\n * a TABLE block's payload (the discriminator becomes load-bearing only at runtime, not in the\n * type system).\n */\nexport type ArtifactRefBlockRecord = ArtifactRecord extends infer TArtifact\n ? TArtifact extends ArtifactRecord\n ? {\n /** Block-type discriminator. */\n type: typeof blockTypes.ARTIFACT_REF;\n /** Type-specific data; kept as `payload` to match the wire shape 1:1. */\n payload: {\n /** The artifact's stable identifier, used for keying / future cross-message reuse. */\n artifactId: string;\n /** Inlined artifact metadata — clients fetch the underlying data via `artifact.protectedAsset.presignedUrl`. */\n artifact: TArtifact;\n /**\n * Optional consumer-supplied labels for the rendered artifact's action buttons + status\n * messages — a flat slice narrowed by `artifact.type`. NOT a wire field; the consumer\n * constructs this from their i18n layer when materialising the block-record from the\n * server payload, then passes the augmented block to `<Block>`. The dispatcher forwards\n * the slice directly to the matching renderer — no per-type key wrapping (the block\n * already carries the discriminator).\n *\n * TS catches cross-type assignments here: `block.payload.labels = { downloadCsv: 'X' }`\n * on a `TableArtifactRecord`-typed block is a type error because `downloadCsv` isn't a\n * `TableArtifactLabels` key.\n */\n labels?: Partial<ArtifactLabelsOf<TArtifact>>;\n /**\n * Optional side-effect callbacks for actions on the rendered artifact (e.g. `onDownload`).\n * Flat slice narrowed by `artifact.type` via `ArtifactCallbacksOf<T>`. NOT a wire field\n * — the consumer wires this once to bridge artifact actions to their analytics /\n * observability layer.\n */\n callbacks?: Partial<ArtifactCallbacksOf<TArtifact>>;\n };\n }\n : never\n : never;\n\n/** Discriminated union of all supported content blocks. Additive — new types extend this union. */\nexport type BlockRecord = TextBlockRecord | ArtifactRefBlockRecord | NotificationDraftBlockRecord;\n\n/** Props every concrete block component receives from the dispatcher. */\nexport interface BlockComponentProps<TBlock extends BlockRecord = BlockRecord> {\n /** The block to render. */\n block: TBlock;\n}\n\n/** Per-block-type service — registry entry that pairs a discriminator with its concrete component. */\nexport interface BlockService<TBlock extends BlockRecord = BlockRecord> {\n /** Discriminator value this service handles. */\n type: BlockType;\n /** React component that renders a block of this type. */\n Component: ComponentType<BlockComponentProps<TBlock>>;\n /**\n * Returns a plain-text or markdown string representation of this block suitable for clipboard\n * copy. Called by `copyMessageText` when the user clicks \"copy message\".\n *\n * - `TextBlockService`: returns `block.payload.text` verbatim (markdown preserved).\n * - `ArtifactRefBlockService`: delegates to `ArtifactServices[artifact.type].toClipboardText`.\n * Falls back to `[Artifact: <title>]` when the artifact type has no registered component.\n *\n * Optional so external `BlockService` implementors don't break on upgrade — when omitted, the\n * aggregator treats the block as contributing the empty string (silently skipped). Implementations\n * must be pure, synchronous functions — no async, no hooks, no side effects.\n */\n toClipboardText?: (block: TBlock) => string;\n}\n","import type { ComponentType, ReactNode } from \"react\";\n\nimport { ArtifactServices } from \"@/components/artifacts/artifact-services\";\nimport type { ArtifactRefBlockRecord, BlockComponentProps } from \"../types\";\n\n/**\n * Renders an `ARTIFACT_REF` block by dispatching the inlined artifact to its per-type component.\n *\n * The cast at the seam is necessary because the registry-based dispatch can't statically prove\n * type-T narrowing — but it's not hiding a bug. `ArtifactRefBlockRecord` is a distributed union\n * over `ArtifactRecord` branches (see `blocks/types.ts`), so TS catches wrong-shape labels at the\n * consumer's construction site: a chart-labels bag assigned to a TABLE block's payload is a type\n * error there, not silently forwarded to the wrong renderer here.\n *\n * Unknown artifact types render as `null` — the map only contains types we know how to render,\n * so an older clay client receiving a future artifact type degrades silently rather than\n * crashing the chat.\n */\nexport function ArtifactRefBlock({ block }: BlockComponentProps<ArtifactRefBlockRecord>): ReactNode {\n const { artifact, labels, callbacks } = block.payload;\n const entry = ArtifactServices[artifact.type];\n if (!entry) return null;\n // The registry stores `ArtifactService<ArtifactRecord>` (the union), so `entry.Component` is\n // `ComponentType<ArtifactServiceProps<ArtifactRecord>>`. The labels/callbacks props in the\n // narrower per-type `ArtifactServiceProps<TArtifact>` are `Partial<ArtifactLabelsOf<TArtifact>>`\n // which the union doesn't satisfy positionally. Cast forwards the values verbatim — the\n // runtime invariant is provably correct because the distributed `ArtifactRefBlockRecord` type\n // enforces it at construction.\n const Component = entry.Component as ComponentType<{\n artifact: typeof artifact;\n labels?: typeof labels;\n callbacks?: typeof callbacks;\n }>;\n return <Component artifact={artifact} labels={labels} callbacks={callbacks} />;\n}\n","import { artifactToClipboardText } from \"@/components/artifacts/artifact-services\";\nimport { ArtifactRefBlock } from \"../artifact-ref-block/artifact-ref-block\";\nimport { blockTypes } from \"../types\";\nimport type { ArtifactRefBlockRecord, BlockService } from \"../types\";\n\nexport const ArtifactRefBlockService: BlockService<ArtifactRefBlockRecord> = {\n type: blockTypes.ARTIFACT_REF,\n Component: ArtifactRefBlock,\n /**\n * Delegates to the registered artifact component's `toClipboardText`. Falls back to\n * `[Artifact: <title>]` via `artifactToClipboardText`'s own fallback when the artifact type\n * has no registered component, so copy never silently produces an empty string.\n */\n toClipboardText: (block) => artifactToClipboardText(block.payload.artifact),\n};\n","import { blockTypes } from \"../types\";\n\n/** Delivery channel the drafted notification targets. */\nexport const notificationChannels = {\n /** Branded email — renders a From/subject header. */\n EMAIL: \"email\",\n /** Slack DM — renders as a chat bubble, no subject. */\n SLACK: \"slack\",\n /** Microsoft Teams DM — renders as a chat bubble, no subject. */\n TEAMS: \"teams\",\n} as const;\n\n/** One of the supported notification channels. */\nexport type NotificationChannel = (typeof notificationChannels)[keyof typeof notificationChannels];\n\n/** Which recipient address the email is sent to (email channel only). */\nexport const notificationEmailTypes = {\n /** Recipient's work email. */\n WORK: \"work\",\n /** Recipient's personal email. */\n PERSONAL: \"personal\",\n} as const;\n\n/** One of the supported email address types. */\nexport type NotificationEmailType = (typeof notificationEmailTypes)[keyof typeof notificationEmailTypes];\n\n/**\n * A single resolved recipient of the drafted notification — the block's one source of recipient\n * truth. The summary chips and the detail table are both projected from this (count, chip labels,\n * and fallback count are all derived, never transmitted separately).\n */\nexport interface NotificationRecipient {\n /** Stable employee identifier — used as the React key. */\n employeeId: string;\n /** Display name; falls back to `email` for the chip label when absent. */\n name?: string | null;\n /** Resolved delivery address (work or personal, already resolved server-side). */\n email?: string | null;\n /**\n * Human-readable label for the channel this recipient is reached on (e.g. \"Email\", \"Slack\").\n * Client-provided so clay isn't limited to a fixed channel set and holds no channel copy of its\n * own — the consumer passes whatever label fits its use case in the payload.\n */\n channelLabel: string;\n /** Whether this recipient is unreachable on the chosen channel and falls back to email. */\n fallback: boolean;\n}\n\n/**\n * Wire payload for a drafted notification preview — populated by the agent from the\n * `validate_send_notification` dry-run. Presentation only: this block previews what will be\n * sent, it is NOT the approval/confirmation control.\n */\nexport interface NotificationDraftPayload {\n /** Delivery channel; drives whether a subject title is shown (email only). */\n channel: NotificationChannel;\n /** Which address the email is sent to. Email channel only; ignored otherwise. */\n emailType?: NotificationEmailType;\n /** Email subject line. Email channel only; absent for slack/teams. */\n subject?: string;\n /** Message body (markdown source). Rendered as markdown, identical to chat assistant text. */\n body: string;\n /** Resolved From display name, e.g. \"Acme HR via Shapes\". Email channel only. */\n fromDisplay?: string;\n /**\n * Every resolved recipient. Clay derives the count, the summary chips (`name ?? email`, with a\n * \"+N\" overflow), and the fallback count from this single array.\n */\n recipients: NotificationRecipient[];\n}\n\n/** A NOTIFICATION_DRAFT content block — wraps a {@link NotificationDraftPayload}. */\nexport interface NotificationDraftBlockRecord {\n /** Block-type discriminator. */\n type: typeof blockTypes.NOTIFICATION_DRAFT;\n /** Type-specific data; kept as `payload` to match the wire shape 1:1. */\n payload: NotificationDraftPayload;\n}\n","import type { ReactNode } from \"react\";\nimport { useState } from \"react\";\nimport { IconChevronDown, IconFlask2Filled } from \"@tabler/icons-react\";\n\nimport { Badge } from \"@/components/badge\";\nimport { CopyButton } from \"@/components/copy-button\";\nimport { Icon } from \"@/components/icon\";\nimport {\n DataTable,\n DATA_TABLE_CELL_CLASS,\n DATA_TABLE_HEAD_CLASS,\n DATA_TABLE_ROW_CLASS,\n TableCell,\n TableHead,\n TableRow,\n} from \"@/components/table\";\nimport { Markdown } from \"../markdown/markdown\";\nimport type { BlockComponentProps } from \"../types\";\nimport { notificationDraftToText } from \"./to-text\";\nimport { type NotificationDraftBlockRecord, type NotificationRecipient, notificationChannels } from \"./types\";\n\n/** Number of recipient chips shown before collapsing the rest into a \"+N\" overflow chip. */\nconst CHIP_LIMIT = 3;\n\n/** Max recipient-table height (px) before it scrolls, engaging the sticky header + scroll shadow. */\nconst RECIPIENTS_MAX_HEIGHT = 320;\n\n/** Chip label for a recipient — name, falling back to email, then the id. */\nfunction chipLabel(recipient: NotificationRecipient): string {\n return recipient.name ?? recipient.email ?? recipient.employeeId;\n}\n\n/** Channel cell text — the client-provided channel label, marked when it's a fallback. */\nfunction channelCellText(recipient: NotificationRecipient): string {\n return recipient.fallback ? `${recipient.channelLabel} (fallback)` : recipient.channelLabel;\n}\n\n/** Small muted form-field caption sitting tightly above the value it labels. */\nfunction FieldLabel({ children }: { children: string }): ReactNode {\n return <span className=\"text-geist-label-caption-medium tracking-wide text-brown-60\">{children}</span>;\n}\n\n/** Collapsed summary: the first few recipients as chips with a \"+N\" overflow. */\nfunction RecipientChips({ recipients }: { recipients: NotificationRecipient[] }): ReactNode {\n const shown = recipients.slice(0, CHIP_LIMIT);\n const overflow = recipients.length - shown.length;\n return (\n <div className=\"flex flex-wrap items-center gap-1.5\">\n {shown.map((recipient) => (\n <Badge key={recipient.employeeId} variant=\"outline\">\n {chipLabel(recipient)}\n </Badge>\n ))}\n {overflow > 0 && <Badge variant=\"subtle\">{`+${overflow}`}</Badge>}\n </div>\n );\n}\n\n/** Expanded detail: one row per recipient with name, email, and resolved channel (fallback tagged). */\nfunction RecipientsTable({ recipients }: { recipients: NotificationRecipient[] }): ReactNode {\n return (\n <DataTable\n maxBodyHeight={RECIPIENTS_MAX_HEIGHT}\n header={\n <TableRow className=\"hover:bg-transparent\">\n <TableHead scope=\"col\" className={DATA_TABLE_HEAD_CLASS}>\n Name\n </TableHead>\n <TableHead scope=\"col\" className={DATA_TABLE_HEAD_CLASS}>\n Email\n </TableHead>\n <TableHead scope=\"col\" className={DATA_TABLE_HEAD_CLASS}>\n Channel\n </TableHead>\n </TableRow>\n }\n >\n {recipients.map((recipient) => (\n <TableRow key={recipient.employeeId} className={DATA_TABLE_ROW_CLASS}>\n <TableCell className={DATA_TABLE_CELL_CLASS}>{recipient.name ?? \"—\"}</TableCell>\n <TableCell className={DATA_TABLE_CELL_CLASS}>{recipient.email ?? \"—\"}</TableCell>\n <TableCell className={DATA_TABLE_CELL_CLASS}>\n <Badge tone={recipient.fallback ? \"warning\" : \"neutral\"} variant=\"subtle\">\n {channelCellText(recipient)}\n </Badge>\n </TableCell>\n </TableRow>\n ))}\n </DataTable>\n );\n}\n\n/**\n * Preview of a drafted notification — one uniform card for every channel. Header carries a \"Labs\"\n * badge (experimental) and a copy-to-clipboard button; the body renders as markdown. Recipients are\n * a single source of truth shown two ways, never both at once: collapsed as summary chips, or\n * expanded (via the \"Details\" toggle) as a Name / Email / Channel table matching the table artifact.\n * The only cross-channel difference is a bold subject title, shown for email. Presentation only.\n */\nexport function NotificationDraftBlock({ block }: BlockComponentProps<NotificationDraftBlockRecord>): ReactNode {\n const { channel, subject, body, recipients } = block.payload;\n const [detailsOpen, setDetailsOpen] = useState(false);\n // Subject is the sole cross-channel difference — email only (§16); slack/teams have no subject line.\n const showSubject = channel === notificationChannels.EMAIL && subject;\n\n return (\n <div className=\"overflow-hidden rounded-2xl border border-brown-30 bg-white\">\n <div className=\"flex flex-col gap-3 border-b border-brown-30 px-4 py-3\">\n <div className=\"flex items-center justify-between gap-2\">\n <div className=\"flex items-center gap-2\">\n <span className=\"text-geist-body-s-semi-bold text-brown-100\">Notification draft</span>\n <Badge tone=\"violet\" variant=\"subtle\" size=\"sm\" className=\"gap-1 py-1\">\n <Icon icon={IconFlask2Filled} size={12} />\n Labs\n </Badge>\n </div>\n <CopyButton text={notificationDraftToText(block.payload)} copyLabel=\"Copy draft\" copiedLabel=\"Copied\" />\n </div>\n\n {showSubject && (\n <div className=\"flex flex-col gap-0.5\">\n <FieldLabel>Title</FieldLabel>\n <p className=\"text-geist-body-s-medium text-brown-100\">{subject}</p>\n </div>\n )}\n\n <div className=\"flex flex-col gap-1\">\n <div className=\"flex items-center justify-between gap-2\">\n <FieldLabel>{`Recipients (${recipients.length})`}</FieldLabel>\n <button\n type=\"button\"\n aria-expanded={detailsOpen}\n onClick={() => setDetailsOpen((open) => !open)}\n className=\"inline-flex items-center gap-1 text-geist-label-caption-medium text-brown-70 transition-colors hover:text-brown-100\"\n >\n Details\n <Icon icon={IconChevronDown} size={14} className={detailsOpen ? \"rotate-180\" : undefined} />\n </button>\n </div>\n {detailsOpen ? <RecipientsTable recipients={recipients} /> : <RecipientChips recipients={recipients} />}\n </div>\n </div>\n\n <div className=\"px-4 py-3\">\n <Markdown>{body}</Markdown>\n </div>\n </div>\n );\n}\n","import type { ReactNode } from \"react\";\nimport ReactMarkdown from \"react-markdown\";\nimport remarkBreaks from \"remark-breaks\";\nimport remarkGfm from \"remark-gfm\";\n\nimport { ScrollableTable } from \"../scrollable-table/scrollable-table\";\nimport { sanitize } from \"../text-block/sanitize\";\nimport { TextBlockWrapper } from \"../text-block/text-block-styles\";\n\nconst markdownComponents = {\n table: ((tableProps: { node?: unknown; children?: ReactNode }) => (\n <ScrollableTable {...tableProps} />\n )) as React.ComponentType<unknown>,\n};\n\n/**\n * Shared markdown renderer for chat content blocks — GFM (tables, strikethrough) + single-newline\n * line breaks, tables wrapped in a scrollable container, prose typography from `TextBlockWrapper`.\n * The single source of the markdown setup so every block (TextBlock, NotificationDraftBlock) renders\n * assistant text identically.\n */\nexport function Markdown({ children }: { children: string }): ReactNode {\n return (\n <TextBlockWrapper>\n <ReactMarkdown remarkPlugins={[remarkGfm, remarkBreaks]} components={markdownComponents}>\n {sanitize(children)}\n </ReactMarkdown>\n </TextBlockWrapper>\n );\n}\n","import styled from \"styled-components\";\n\nexport const TableContainer = styled.div`\n position: relative;\n margin-block: 8px 16px;\n`;\n\nexport const TableScroll = styled.div`\n width: 100%;\n overflow-x: auto;\n overflow-y: hidden;\n`;\n","import { type ReactNode } from \"react\";\n\nimport { TableContainer, TableScroll } from \"./scrollable-table-styles\";\n\n/** Props for the ScrollableTable component. */\ninterface ScrollableTableProps {\n /** Unused node prop from react-markdown. */\n node?: unknown;\n /** Table children elements. */\n children?: ReactNode;\n}\n\n/** Renders a markdown table inside a horizontally scrollable wrapper. Read-only — actions live on artifact-tables. */\nexport function ScrollableTable({ node: _node, ...props }: ScrollableTableProps): ReactNode {\n return (\n <TableContainer>\n <TableScroll>\n <table {...props} />\n </TableScroll>\n </TableContainer>\n );\n}\n","// Strips io-server's `<!-- table-title: ... -->` HTML-comment metadata before rendering.\n// The marker is emitted by the server's CSV-export pipeline so the export button can label\n// the file; it has no place in the visual output. If the server-side format changes\n// (prefix, spacing, closing-tag style), this filter silently stops matching and the\n// raw HTML comment leaks into rendered Markdown — keep this contract aligned with io-server.\nexport function sanitize(text: string): string {\n return text\n .split(\"\\n\")\n .filter((line) => {\n const t = line.trim();\n return !(t.startsWith(\"<!-- table-title:\") && t.endsWith(\"-->\"));\n })\n .join(\"\\n\");\n}\n","import styled from \"styled-components\";\n\nimport { colors } from \"@/tokens/colors\";\nimport { typographyMixin, typographyTypes } from \"@/tokens/typography\";\n\nexport const TextBlockWrapper = styled.div`\n ${typographyMixin(typographyTypes.GEIST_BODY_S_REGULAR)};\n color: ${colors[\"brown-100\"]};\n word-break: break-word;\n\n & h1 {\n ${typographyMixin(typographyTypes.GEIST_HEADING_S_BOLD)};\n margin-block: 20px;\n }\n\n & h2 {\n ${typographyMixin(typographyTypes.GEIST_BODY_L_SEMI_BOLD)};\n margin-block: 12px;\n }\n\n & h3,\n & h4,\n & h5,\n & h6 {\n ${typographyMixin(typographyTypes.GEIST_BODY_M_SEMI_BOLD)};\n margin-block: 8px;\n }\n\n & strong {\n ${typographyMixin(typographyTypes.GEIST_BODY_S_SEMI_BOLD)};\n }\n\n & p {\n margin-block: 0px;\n }\n\n & p + p {\n margin-block: 8px 0px;\n }\n\n & ul,\n & ol {\n margin-block: 16px;\n padding-left: 20px;\n }\n\n & li + li {\n margin-block: 4px;\n }\n\n & ul {\n list-style-type: disc;\n }\n\n & ul ul {\n list-style-type: circle;\n }\n\n & ul ul ul {\n list-style-type: square;\n }\n\n & ol {\n list-style-type: decimal;\n }\n\n & ol ol {\n list-style-type: lower-alpha;\n }\n\n & ol ol ol {\n list-style-type: lower-roman;\n }\n\n & a {\n color: inherit;\n text-decoration-line: underline;\n text-decoration-style: dotted;\n text-decoration-thickness: auto;\n text-underline-offset: auto;\n text-underline-position: from-font;\n transition: color 75ms ease-in-out;\n\n &:hover {\n color: ${colors[\"blue-600\"]};\n }\n }\n\n & hr {\n border: none;\n border-top: 1px solid ${colors[\"brown-40\"]};\n margin-block: 20px;\n }\n\n & table {\n margin: 0;\n width: 100%;\n border-collapse: collapse;\n }\n\n & th,\n & td {\n border: none;\n border-bottom: 1px solid ${colors[\"brown-40\"]};\n text-align: left;\n }\n\n & th {\n ${typographyMixin(typographyTypes.GEIST_LABEL_CAPTION_MEDIUM)};\n padding: 8px;\n }\n\n & td {\n ${typographyMixin(typographyTypes.GEIST_BODY_XS_MEDIUM)};\n padding: 16px 8px;\n min-width: 150px;\n width: 1%;\n }\n\n & td strong {\n font-weight: inherit;\n font-size: inherit;\n line-height: inherit;\n }\n\n & blockquote {\n margin-block: 4px;\n margin-inline: 0px;\n padding-left: 16px;\n border-left: 4px solid ${colors[\"brown-40\"]};\n color: ${colors[\"brown-80\"]};\n }\n`;\n","import { markdownToPlainText } from \"@/utils/markdown-to-plain-text\";\nimport { notificationChannels } from \"./types\";\nimport type { NotificationDraftPayload } from \"./types\";\n\n/**\n * Plain-text projection of a drafted notification: subject + body for email (which has a subject),\n * body alone for slack/teams. The body is markdown (§16), so it's run through `markdownToPlainText`\n * — matching `TextBlockService.toClipboardText` — so a copied draft never carries `**`, list\n * markers, etc. into plain-text paste targets. Shared by the block-service's `toClipboardText` and\n * the in-block copy button so both copy the same text.\n */\nexport function notificationDraftToText(payload: NotificationDraftPayload): string {\n const { channel, subject, body } = payload;\n const text = markdownToPlainText(body);\n return channel === notificationChannels.EMAIL && subject ? `${subject}\\n\\n${text}` : text;\n}\n","import { NotificationDraftBlock } from \"../notification-draft-block/notification-draft-block\";\nimport { notificationDraftToText } from \"../notification-draft-block/to-text\";\nimport type { NotificationDraftBlockRecord } from \"../notification-draft-block/types\";\nimport { blockTypes } from \"../types\";\nimport type { BlockService } from \"../types\";\n\nexport const NotificationDraftBlockService: BlockService<NotificationDraftBlockRecord> = {\n type: blockTypes.NOTIFICATION_DRAFT,\n Component: NotificationDraftBlock,\n /**\n * Plain-text clipboard form of the drafted notification — shared with the in-block copy button\n * via {@link notificationDraftToText} so both copy the same text.\n */\n toClipboardText: (block) => notificationDraftToText(block.payload),\n};\n","import type { ReactNode } from \"react\";\n\nimport { Markdown } from \"../markdown/markdown\";\nimport type { BlockComponentProps, TextBlockRecord } from \"../types\";\n\n/** Renders a TEXT block as Markdown with GFM (tables, strikethrough) and line breaks. */\nexport function TextBlock({ block }: BlockComponentProps<TextBlockRecord>): ReactNode {\n return <Markdown>{block.payload.text}</Markdown>;\n}\n","import { markdownToPlainText } from \"@/utils/markdown-to-plain-text\";\nimport { TextBlock } from \"../text-block/text-block\";\nimport { blockTypes } from \"../types\";\nimport type { BlockService, TextBlockRecord } from \"../types\";\n\nexport const TextBlockService: BlockService<TextBlockRecord> = {\n type: blockTypes.TEXT,\n Component: TextBlock,\n /**\n * Converts the block's markdown source to plain text so the final clipboard value is clean\n * when pasted into tools that don't render markdown. Each block type owns its own clipboard\n * conversion so `useCopyToClipboard` can write text verbatim without a second pass.\n */\n toClipboardText: (block) => markdownToPlainText(block.payload.text),\n};\n","import { blockTypes, type BlockService, type BlockType } from \"../types\";\nimport { ArtifactRefBlockService } from \"./artifact-ref-block-service\";\nimport { NotificationDraftBlockService } from \"./notification-draft-block-service\";\nimport { TextBlockService } from \"./text-block-service\";\n\n// `BlockService<TBlock>` is invariant on `TBlock` via React's `ComponentType` (props are\n// contravariant). The concrete services overlap structurally with the base `BlockService` type\n// enough for a direct `as BlockService` cast. The registry dispatches by runtime discriminator —\n// `BlockServices[block.type]` always resolves to the matching concrete service — so the cast is sound.\nexport const BlockServices: Record<BlockType, BlockService> = {\n [blockTypes.TEXT]: TextBlockService as BlockService,\n [blockTypes.ARTIFACT_REF]: ArtifactRefBlockService as BlockService,\n [blockTypes.NOTIFICATION_DRAFT]: NotificationDraftBlockService as BlockService,\n};\n","import type { ReactNode } from \"react\";\n\nimport { BlockServices } from \"../block-services\";\nimport type { BlockRecord } from \"../types\";\n\n/** Props for the Block dispatcher. */\ninterface BlockProps {\n /** The block to render. Dispatched to the registered concrete component for its `type`. */\n block: BlockRecord;\n}\n\n/**\n * Dispatches a single block to its registered concrete component. Unknown types render as a no-op.\n *\n * Generic by design: per-block-type extras (e.g. localized artifact labels for `ARTIFACT_REF`)\n * live on the block's `payload`, not as sibling props here. That keeps the dispatcher's contract\n * shallow — third-party `BlockService` implementors only need to handle `{ block }` — and lets\n * the consumer materialise a fully-decorated block once (from the server payload + their i18n\n * layer) instead of threading sibling props through every dispatch site.\n */\nexport function Block({ block }: BlockProps): ReactNode {\n const service = BlockServices[block.type];\n if (!service) return null;\n const { Component } = service;\n return <Component block={block} />;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AU,oBAAoB,MAAM,QAAQ,IAAI;AACpE;;;ACLO,IAAM,gBAAiD;AAAA,EAC5D,CAAC,WAAW,IAAI,GAAG;AAAA,EACnB,CAAC,WAAW,YAAY,GAAG;AAAA,EAC3B,CAAC,WAAW,kBAAkB,GAAG;AACnC;;;ACWS,gBAAAC,YAAA;AAJF,SAAS,MAAM,EAAE,MAAM,GAA0B;AACtD,QAAM,UAAU,cAAc,MAAM,IAAI;AACxC,MAAI,CAAC,QAAS,QAAO;AACrB,QAAM,EAAE,UAAU,IAAI;AACtB,SAAO,gBAAAA,KAAC,aAAU,OAAc;AAClC;","names":["jsx","styled","styled","jsx","jsx","jsx","jsx"]}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Block,
|
|
3
3
|
BlockServices
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-PISZYS2H.js";
|
|
5
|
+
import {
|
|
6
|
+
useCopyToClipboard
|
|
7
|
+
} from "./chunk-EIAWZXE4.js";
|
|
5
8
|
import {
|
|
6
9
|
IconCheck,
|
|
7
10
|
IconCopy,
|
|
8
11
|
IconThumbDown,
|
|
9
12
|
IconThumbUp
|
|
10
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-CSTCTO3B.js";
|
|
11
14
|
import {
|
|
12
15
|
IconButton
|
|
13
16
|
} from "./chunk-E36VI2HA.js";
|
|
@@ -37,7 +40,7 @@ function copyMessageText(message) {
|
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
// src/components/chat/chat-message-actions/chat-message-actions.tsx
|
|
40
|
-
import { useCallback
|
|
43
|
+
import { useCallback } from "react";
|
|
41
44
|
|
|
42
45
|
// src/components/chat/chat-context/chat-context.ts
|
|
43
46
|
import { createContext, useContext } from "react";
|
|
@@ -50,42 +53,6 @@ function useChatContext() {
|
|
|
50
53
|
return context;
|
|
51
54
|
}
|
|
52
55
|
|
|
53
|
-
// src/components/chat/hooks/use-copy-to-clipboard.ts
|
|
54
|
-
import { useState, useCallback, useRef, useEffect } from "react";
|
|
55
|
-
|
|
56
|
-
// src/utils/clipboard.ts
|
|
57
|
-
function copyToClipboard(text, options) {
|
|
58
|
-
navigator.clipboard.writeText(text).then(
|
|
59
|
-
() => options?.onSuccess?.(),
|
|
60
|
-
(error) => options?.onFailure?.(error)
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// src/components/chat/hooks/use-copy-to-clipboard.ts
|
|
65
|
-
var RESET_DELAY_MS = 2e3;
|
|
66
|
-
function useCopyToClipboard() {
|
|
67
|
-
const [isCopied, setIsCopied] = useState(false);
|
|
68
|
-
const timeoutRef = useRef(null);
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
return () => {
|
|
71
|
-
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
72
|
-
};
|
|
73
|
-
}, []);
|
|
74
|
-
const copy = useCallback((text) => {
|
|
75
|
-
copyToClipboard(text, {
|
|
76
|
-
onSuccess: () => {
|
|
77
|
-
setIsCopied(true);
|
|
78
|
-
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
79
|
-
timeoutRef.current = setTimeout(() => {
|
|
80
|
-
setIsCopied(false);
|
|
81
|
-
timeoutRef.current = null;
|
|
82
|
-
}, RESET_DELAY_MS);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}, []);
|
|
86
|
-
return { isCopied, copy };
|
|
87
|
-
}
|
|
88
|
-
|
|
89
56
|
// src/components/chat/constants.ts
|
|
90
57
|
var MESSAGE_ROLE = {
|
|
91
58
|
USER: "user",
|
|
@@ -115,14 +82,14 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
115
82
|
function ChatMessageActions({ className, messageId, content, role, isHelpful }) {
|
|
116
83
|
const { onCopyMessage, onThumbUpClick, onThumbDownClick } = useChatContext();
|
|
117
84
|
const { isCopied, copy } = useCopyToClipboard();
|
|
118
|
-
const handleCopy =
|
|
85
|
+
const handleCopy = useCallback(() => {
|
|
119
86
|
copy(content);
|
|
120
87
|
onCopyMessage?.(messageId);
|
|
121
88
|
}, [content, messageId, copy, onCopyMessage]);
|
|
122
|
-
const handleThumbUp =
|
|
89
|
+
const handleThumbUp = useCallback(() => {
|
|
123
90
|
onThumbUpClick?.(messageId, isHelpful === true ? null : true);
|
|
124
91
|
}, [messageId, isHelpful, onThumbUpClick]);
|
|
125
|
-
const handleThumbDown =
|
|
92
|
+
const handleThumbDown = useCallback(() => {
|
|
126
93
|
onThumbDownClick?.(messageId, isHelpful === false ? null : false);
|
|
127
94
|
}, [messageId, isHelpful, onThumbDownClick]);
|
|
128
95
|
const isAssistant = role === MESSAGE_ROLE.ASSISTANT;
|
|
@@ -216,8 +183,7 @@ export {
|
|
|
216
183
|
copyMessageText,
|
|
217
184
|
ChatContext,
|
|
218
185
|
useChatContext,
|
|
219
|
-
useCopyToClipboard,
|
|
220
186
|
MESSAGE_ROLE,
|
|
221
187
|
ChatMessage
|
|
222
188
|
};
|
|
223
|
-
//# sourceMappingURL=chunk-
|
|
189
|
+
//# sourceMappingURL=chunk-PWSEEUVL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/chat-message/chat-message.tsx","../src/components/chat/hooks/copy-message-text.ts","../src/components/chat/chat-message-actions/chat-message-actions.tsx","../src/components/chat/chat-context/chat-context.ts","../src/components/chat/constants.ts","../src/components/chat/chat-message-actions/chat-message-actions-styles.ts","../src/components/chat/chat-message/chat-message-styles.ts"],"sourcesContent":["import { useMemo } from \"react\";\n\nimport { Block } from \"@/components/blocks/block\";\nimport { copyMessageText } from \"../hooks/copy-message-text\";\nimport type { ChatMessage as ChatMessageType } from \"../types\";\nimport { ChatMessageActions } from \"../chat-message-actions/chat-message-actions\";\nimport { MessageRow, MessageBubble, MessageContainer } from \"./chat-message-styles\";\n\ninterface ChatMessageProps {\n message: ChatMessageType;\n}\n\nexport function ChatMessage({ message }: ChatMessageProps) {\n // Aggregate per-block clipboard text so the copy button produces richer output than the\n // server-supplied `fallbackText` (which is typically \"[table: Title]\" for artifact blocks).\n // `useMemo` keeps the string stable across re-renders that don't change the blocks array.\n const clipboardText = useMemo(() => copyMessageText(message), [message]);\n\n return (\n <MessageRow $role={message.role} role=\"article\" aria-label={`${message.role} message`}>\n <MessageContainer $role={message.role}>\n <MessageBubble $role={message.role} data-testid=\"message-bubble\">\n {message.blocks.map((block, index) => (\n <Block key={index} block={block} />\n ))}\n </MessageBubble>\n <ChatMessageActions\n messageId={message.id}\n content={clipboardText}\n role={message.role}\n isHelpful={message.isHelpful}\n />\n </MessageContainer>\n </MessageRow>\n );\n}\n","import { BlockServices } from \"@/components/blocks/block-services\";\nimport type { ChatMessage } from \"../types\";\n\n/**\n * Aggregates the clipboard text for all blocks in a message.\n *\n * Iterates `message.blocks` in order, calls `BlockServices[block.type].toClipboardText(block)`\n * for each, and joins the results with `\"\\n\\n\"` so multi-block messages have a blank line between\n * each section (matching the visual gap rendered between blocks in the chat UI).\n *\n * Block-type-specific behaviour:\n * - `TEXT` blocks: markdown stripped to plain text via `markdownToPlainText`.\n * - `ARTIFACT_REF` blocks: delegates to the registered artifact component's `toClipboardText`\n * (e.g. the artifact title as plain text for table artifacts).\n * - Unknown block types: silently skipped (no registered service → no contribution to output).\n *\n * Falls back to `message.fallbackText` only when every block produces an empty string — this\n * guards against edge cases (empty message, all-unknown block types) while still preferring\n * the richer per-block text in the normal case.\n *\n * @param message The chat message whose blocks should be aggregated.\n * @returns A string suitable for writing to the system clipboard.\n */\nexport function copyMessageText(message: ChatMessage): string {\n const parts: string[] = [];\n\n for (const block of message.blocks) {\n const service = BlockServices[block.type];\n if (!service) continue;\n // `toClipboardText` is optional on the BlockService interface — external implementors may\n // omit it. Skip silently when absent (contributes \"\" to the aggregated output).\n if (!service.toClipboardText) continue;\n // The registry is keyed by BlockType and each service's toClipboardText is typed to its\n // concrete TBlock. The cast is safe because BlockServices[block.type] is always the matching\n // service for block.type — same soundness argument as the registry's own type erasure.\n const text = (service as { toClipboardText: (b: typeof block) => string }).toClipboardText(block);\n if (text) parts.push(text);\n }\n\n if (parts.length === 0) return message.fallbackText;\n return parts.join(\"\\n\\n\");\n}\n","import { useCallback } from \"react\";\nimport { IconCopy, IconCheck, IconThumbUp, IconThumbDown } from \"@tabler/icons-react\";\n\nimport { IconButton } from \"../../icon-button/icon-button\";\nimport { useChatContext } from \"../chat-context/chat-context\";\nimport { useCopyToClipboard } from \"../hooks/use-copy-to-clipboard\";\nimport { MESSAGE_ROLE } from \"../constants\";\nimport type { MessageRole } from \"../types\";\nimport { ActionsContainer, AnimatedAction } from \"./chat-message-actions-styles\";\n\ninterface ChatMessageActionsProps {\n className?: string;\n messageId: string;\n content: string;\n role: MessageRole;\n isHelpful?: boolean | null;\n}\n\nexport function ChatMessageActions({ className, messageId, content, role, isHelpful }: ChatMessageActionsProps) {\n const { onCopyMessage, onThumbUpClick, onThumbDownClick } = useChatContext();\n const { isCopied, copy } = useCopyToClipboard();\n\n const handleCopy = useCallback(() => {\n copy(content);\n onCopyMessage?.(messageId);\n }, [content, messageId, copy, onCopyMessage]);\n\n const handleThumbUp = useCallback(() => {\n onThumbUpClick?.(messageId, isHelpful === true ? null : true);\n }, [messageId, isHelpful, onThumbUpClick]);\n\n const handleThumbDown = useCallback(() => {\n onThumbDownClick?.(messageId, isHelpful === false ? null : false);\n }, [messageId, isHelpful, onThumbDownClick]);\n\n const isAssistant = role === MESSAGE_ROLE.ASSISTANT;\n const hasFeedback = isAssistant && (onThumbUpClick || onThumbDownClick);\n\n return (\n <ActionsContainer $role={role} className={className}>\n <IconButton\n icon={isCopied ? IconCheck : IconCopy}\n onClick={handleCopy}\n aria-label={isCopied ? \"Copied\" : \"Copy message\"}\n />\n\n {hasFeedback && (\n <AnimatedAction $visible={isHelpful !== false}>\n <IconButton\n icon={IconThumbUp}\n onClick={handleThumbUp}\n isSelected={isHelpful === true}\n aria-label=\"Good response\"\n />\n </AnimatedAction>\n )}\n\n {hasFeedback && (\n <AnimatedAction $visible={isHelpful !== true}>\n <IconButton\n icon={IconThumbDown}\n onClick={handleThumbDown}\n isSelected={isHelpful === false}\n aria-label=\"Bad response\"\n />\n </AnimatedAction>\n )}\n </ActionsContainer>\n );\n}\n","import { createContext, useContext } from \"react\";\nimport type { ChatContextValue } from \"../types\";\n\nexport const ChatContext = createContext<ChatContextValue | null>(null);\n\nexport function useChatContext(): ChatContextValue {\n const context = useContext(ChatContext);\n if (!context) {\n throw new Error(\"useChatContext must be used within a Chat.Root component\");\n }\n return context;\n}\n","export const MESSAGE_ROLE = {\n USER: \"user\",\n ASSISTANT: \"assistant\",\n} as const;\n","import styled from \"styled-components\";\n\nimport { MESSAGE_ROLE } from \"../constants\";\nimport type { MessageRole } from \"../types\";\n\nconst FADE_DURATION_MS = 150;\nconst ANIMATE_DURATION_MS = 200;\n\nexport const ActionsContainer = styled.div<{ $role: MessageRole }>`\n display: flex;\n opacity: ${({ $role }) => ($role === MESSAGE_ROLE.ASSISTANT ? 1 : 0)};\n pointer-events: ${({ $role }) => ($role === MESSAGE_ROLE.ASSISTANT ? \"auto\" : \"none\")};\n transition: opacity ${FADE_DURATION_MS}ms ease;\n`;\n\nexport const AnimatedAction = styled.div<{ $visible: boolean }>`\n display: flex;\n overflow: hidden;\n max-width: ${({ $visible }) => ($visible ? \"40px\" : \"0\")};\n opacity: ${({ $visible }) => ($visible ? 1 : 0)};\n transition: max-width ${ANIMATE_DURATION_MS}ms ease, opacity ${ANIMATE_DURATION_MS}ms ease;\n`;\n","import styled from \"styled-components\";\n\nimport { colors } from \"../../../tokens/colors\";\nimport { typographyMixin, typographyTypes } from \"../../../tokens/typography\";\nimport { ActionsContainer } from \"../chat-message-actions/chat-message-actions-styles\";\nimport { MESSAGE_ROLE } from \"../constants\";\nimport type { MessageRole } from \"../types\";\n\nexport const MessageRow = styled.div<{ $role: MessageRole }>`\n display: flex;\n justify-content: ${({ $role }) => ($role === MESSAGE_ROLE.USER ? \"flex-end\" : \"flex-start\")};\n\n &:hover ${ActionsContainer} {\n opacity: 1;\n pointer-events: auto;\n }\n`;\n\nexport const MessageContainer = styled.div<{ $role: MessageRole }>`\n display: flex;\n flex-direction: column;\n align-items: ${({ $role }) => ($role === MESSAGE_ROLE.USER ? \"flex-end\" : \"flex-start\")};\n max-width: 90%;\n width: ${({ $role }) => ($role === MESSAGE_ROLE.USER ? \"auto\" : \"100%\")};\n gap: 12px;\n`;\n\nexport const MessageBubble = styled.div<{ $role: MessageRole }>`\n ${typographyMixin(typographyTypes.GEIST_BODY_S_REGULAR)};\n color: ${colors[\"brown-100\"]};\n background: ${({ $role }) => ($role === MESSAGE_ROLE.USER ? colors.white : \"transparent\")};\n padding: ${({ $role }) => ($role === MESSAGE_ROLE.USER ? \"12px 16px\" : \"0\")};\n border-radius: ${({ $role }) => ($role === MESSAGE_ROLE.USER ? \"16px\" : \"0\")};\n max-width: 100%;\n width: 100%;\n min-width: 0;\n /* Vertical rhythm between consecutive blocks — renderer-owned, not agent-emitted.\n * Industry standard (Claude, ChatGPT, Vercel AI Elements): the chat renderer applies\n * spacing via CSS; agents emit semantic blocks only. Value matches the MessageContainer\n * gap. TODO: replace 12px with a clay spacing token when a spacing scale is added. */\n display: flex;\n flex-direction: column;\n gap: 12px;\n`;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,eAAe;;;ACuBjB,SAAS,gBAAgB,SAA8B;AAC5D,QAAM,QAAkB,CAAC;AAEzB,aAAW,SAAS,QAAQ,QAAQ;AAClC,UAAM,UAAU,cAAc,MAAM,IAAI;AACxC,QAAI,CAAC,QAAS;AAGd,QAAI,CAAC,QAAQ,gBAAiB;AAI9B,UAAM,OAAQ,QAA6D,gBAAgB,KAAK;AAChG,QAAI,KAAM,OAAM,KAAK,IAAI;AAAA,EAC3B;AAEA,MAAI,MAAM,WAAW,EAAG,QAAO,QAAQ;AACvC,SAAO,MAAM,KAAK,MAAM;AAC1B;;;ACzCA,SAAS,mBAAmB;;;ACA5B,SAA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