@opengeni/react 6.1.0-canary.2 → 6.1.0-canary.4
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/README.md +5 -0
- package/dist/{browser-viewer-NTD6UIPR.js → browser-viewer-LGH4IP47.js} +3 -3
- package/dist/chunk-AWEBVNVX.js +1398 -0
- package/dist/chunk-AWEBVNVX.js.map +1 -0
- package/dist/{chunk-NYESIADM.js → chunk-B7TTSUEW.js} +3 -1
- package/dist/chunk-B7TTSUEW.js.map +1 -0
- package/dist/{chunk-UWVY3OXF.js → chunk-BC7BFCMN.js} +277 -455
- package/dist/chunk-BC7BFCMN.js.map +1 -0
- package/dist/chunk-BRM6FVZA.js +302 -0
- package/dist/chunk-BRM6FVZA.js.map +1 -0
- package/dist/{chunk-KZ4QDBGM.js → chunk-GHSSI2BK.js} +925 -1265
- package/dist/chunk-GHSSI2BK.js.map +1 -0
- package/dist/{chunk-NLTS7JHI.js → chunk-JPHDWKZE.js} +5 -5
- package/dist/{chunk-L5VJYZIW.js → chunk-O53CQZ6T.js} +7 -7
- package/dist/{chunk-24M4YBCL.js → chunk-PNAVEK2U.js} +4 -4
- package/dist/components/preview-loading.d.ts +2 -0
- package/dist/composer.js +4 -4
- package/dist/connect-setup.d.ts +2 -0
- package/dist/connect.js +19 -8
- package/dist/connect.js.map +1 -1
- package/dist/index.js +27 -27
- package/dist/interaction.js +2 -2
- package/dist/machines.js +2 -2
- package/dist/plugin-discovery.d.ts +2 -0
- package/dist/realtime.js +20 -20
- package/dist/realtime.js.map +1 -1
- package/dist/session-ui.js +7 -7
- package/dist/session.js +3 -3
- package/package.json +3 -3
- package/src/components/markdown.tsx +13 -21
- package/src/components/preview-loading.tsx +154 -0
- package/src/connect-setup.tsx +17 -5
- package/src/hooks/use-composer.ts +6 -0
- package/src/plugin-discovery.tsx +10 -6
- package/src/realtime/realtime-control.tsx +6 -8
- package/styles/compiled.css +48 -8
- package/styles/index.css +45 -0
- package/dist/chunk-G5JFM6ZE.js +0 -911
- package/dist/chunk-G5JFM6ZE.js.map +0 -1
- package/dist/chunk-HQV2I5HV.js +0 -124
- package/dist/chunk-HQV2I5HV.js.map +0 -1
- package/dist/chunk-KZ4QDBGM.js.map +0 -1
- package/dist/chunk-NYESIADM.js.map +0 -1
- package/dist/chunk-UWVY3OXF.js.map +0 -1
- /package/dist/{browser-viewer-NTD6UIPR.js.map → browser-viewer-LGH4IP47.js.map} +0 -0
- /package/dist/{chunk-NLTS7JHI.js.map → chunk-JPHDWKZE.js.map} +0 -0
- /package/dist/{chunk-L5VJYZIW.js.map → chunk-O53CQZ6T.js.map} +0 -0
- /package/dist/{chunk-24M4YBCL.js.map → chunk-PNAVEK2U.js.map} +0 -0
|
@@ -0,0 +1,1398 @@
|
|
|
1
|
+
import {
|
|
2
|
+
copyTextToClipboard,
|
|
3
|
+
tableElementToTsv
|
|
4
|
+
} from "./chunk-JVYQRRC4.js";
|
|
5
|
+
import {
|
|
6
|
+
Tooltip,
|
|
7
|
+
TooltipContent,
|
|
8
|
+
TooltipProvider,
|
|
9
|
+
TooltipTrigger,
|
|
10
|
+
useLightboxOptional
|
|
11
|
+
} from "./chunk-BRM6FVZA.js";
|
|
12
|
+
import {
|
|
13
|
+
stringifyPayload
|
|
14
|
+
} from "./chunk-PLYRL5ER.js";
|
|
15
|
+
import {
|
|
16
|
+
cn
|
|
17
|
+
} from "./chunk-22KP6LR5.js";
|
|
18
|
+
|
|
19
|
+
// src/timeline/disclosure-context.tsx
|
|
20
|
+
import { createContext, useContext } from "react";
|
|
21
|
+
import { jsx } from "react/jsx-runtime";
|
|
22
|
+
var DisclosureDefaultsContext = createContext(void 0);
|
|
23
|
+
function DisclosureDefaultsProvider({
|
|
24
|
+
defaultOpen,
|
|
25
|
+
children
|
|
26
|
+
}) {
|
|
27
|
+
return /* @__PURE__ */ jsx(DisclosureDefaultsContext.Provider, { value: defaultOpen, children });
|
|
28
|
+
}
|
|
29
|
+
function useForcedDefaultOpen() {
|
|
30
|
+
return useContext(DisclosureDefaultsContext);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/timeline/shared.tsx
|
|
34
|
+
import { CameraIcon, CameraOffIcon, ChevronRightIcon } from "lucide-react";
|
|
35
|
+
import { createContext as createContext2, useContext as useContext2, useState } from "react";
|
|
36
|
+
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
37
|
+
var ToolCallTruncationContext = createContext2(null);
|
|
38
|
+
function ToolCallTruncationProvider({
|
|
39
|
+
value,
|
|
40
|
+
children
|
|
41
|
+
}) {
|
|
42
|
+
return /* @__PURE__ */ jsx2(ToolCallTruncationContext.Provider, { value, children });
|
|
43
|
+
}
|
|
44
|
+
var ICON_TONE = {
|
|
45
|
+
accent: "text-og-accent",
|
|
46
|
+
failed: "text-og-status-failed",
|
|
47
|
+
running: "text-og-status-running",
|
|
48
|
+
muted: "text-og-fg-subtle"
|
|
49
|
+
};
|
|
50
|
+
var CompactActivityContext = createContext2(false);
|
|
51
|
+
function ActivityDisclosure({
|
|
52
|
+
icon,
|
|
53
|
+
iconTone: iconToneProp = "muted",
|
|
54
|
+
title,
|
|
55
|
+
titleMono,
|
|
56
|
+
running,
|
|
57
|
+
preview,
|
|
58
|
+
compactPreview,
|
|
59
|
+
media,
|
|
60
|
+
chip: chipProp,
|
|
61
|
+
failed,
|
|
62
|
+
cancelled,
|
|
63
|
+
expandable = true,
|
|
64
|
+
defaultOpen,
|
|
65
|
+
children
|
|
66
|
+
}) {
|
|
67
|
+
const iconTone = failed && iconToneProp === "muted" ? "failed" : iconToneProp;
|
|
68
|
+
const chip = chipProp ?? (failed ? { tone: "bad", text: "failed" } : cancelled ? { tone: "interrupted", text: "interrupted" } : void 0);
|
|
69
|
+
const forcedDefaultOpen = useForcedDefaultOpen();
|
|
70
|
+
const [open, setOpen] = useState(defaultOpen ?? forcedDefaultOpen ?? false);
|
|
71
|
+
const truncation = useContext2(ToolCallTruncationContext);
|
|
72
|
+
const compact = useContext2(CompactActivityContext);
|
|
73
|
+
if (compact)
|
|
74
|
+
return /* @__PURE__ */ jsxs("span", { className: "og-rolling-label", children: [
|
|
75
|
+
/* @__PURE__ */ jsx2("span", { className: cn("shrink-0", ICON_TONE[iconTone]), children: icon }),
|
|
76
|
+
/* @__PURE__ */ jsxs("span", { className: "og-command-reel", children: [
|
|
77
|
+
/* @__PURE__ */ jsx2("span", { className: "og-reel-title", children: title }),
|
|
78
|
+
(compactPreview === void 0 ? preview : compactPreview) ? /* @__PURE__ */ jsx2("span", { className: "og-reel-preview text-og-fg-subtle", children: compactPreview === void 0 ? preview : compactPreview }) : null
|
|
79
|
+
] })
|
|
80
|
+
] });
|
|
81
|
+
const hasBody = expandable && (children != null || truncation != null);
|
|
82
|
+
const previewVisible = preview != null && !open;
|
|
83
|
+
const rowClass = cn(
|
|
84
|
+
"group/disclosure flex w-full min-w-0 items-center gap-2 rounded-og-sm px-1.5 py-1.5 text-left text-og-base",
|
|
85
|
+
"text-og-fg-muted transition-colors duration-150",
|
|
86
|
+
// A tool row is a touch target on coarse pointers: grow its hit area to the
|
|
87
|
+
// 44px mobile minimum without loosening the dense desktop rail.
|
|
88
|
+
"pointer-coarse:min-h-11 pointer-coarse:py-2.5"
|
|
89
|
+
);
|
|
90
|
+
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
91
|
+
hasBody ? /* @__PURE__ */ jsx2(ChevronRightIcon, { className: "size-3.5 shrink-0 text-og-fg-subtle transition-transform duration-[var(--_og-duration-disclose)] ease-og-in-out group-data-[state=open]/disclosure:rotate-90" }) : /* @__PURE__ */ jsx2("span", { className: "size-3.5 shrink-0" }),
|
|
92
|
+
/* @__PURE__ */ jsx2("span", { className: cn("shrink-0", ICON_TONE[iconTone]), children: icon }),
|
|
93
|
+
/* @__PURE__ */ jsxs("span", { className: cn("og-command-reel", running && "og-command-reel-running"), children: [
|
|
94
|
+
/* @__PURE__ */ jsx2(
|
|
95
|
+
"span",
|
|
96
|
+
{
|
|
97
|
+
className: cn(
|
|
98
|
+
"min-w-0 shrink truncate text-og-base font-medium",
|
|
99
|
+
titleMono && "font-og-mono text-og-sm font-normal"
|
|
100
|
+
),
|
|
101
|
+
children: title
|
|
102
|
+
}
|
|
103
|
+
),
|
|
104
|
+
previewVisible && !media ? /* @__PURE__ */ jsx2("span", { className: "min-w-0 flex-1 truncate text-og-sm text-og-fg-subtle", children: preview }) : /* @__PURE__ */ jsx2("span", { className: "flex-1" })
|
|
105
|
+
] }),
|
|
106
|
+
media && !open ? /* @__PURE__ */ jsx2("span", { className: "ml-auto flex shrink-0 items-center gap-2 pl-2", children: media }) : chip && !open ? /* @__PURE__ */ jsx2("span", { className: "ml-auto shrink-0 pl-2", children: /* @__PURE__ */ jsx2(Chip, { chip }) }) : null
|
|
107
|
+
] });
|
|
108
|
+
const dataStatus = cancelled ? "cancelled" : failed ? "failed" : void 0;
|
|
109
|
+
if (!hasBody) {
|
|
110
|
+
return /* @__PURE__ */ jsx2("div", { className: cn(rowClass, "cursor-default"), "data-status": dataStatus, children: inner });
|
|
111
|
+
}
|
|
112
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
113
|
+
/* @__PURE__ */ jsx2(
|
|
114
|
+
"div",
|
|
115
|
+
{
|
|
116
|
+
role: "button",
|
|
117
|
+
tabIndex: 0,
|
|
118
|
+
"aria-expanded": open,
|
|
119
|
+
"data-state": open ? "open" : "closed",
|
|
120
|
+
onClick: () => setOpen((prev) => !prev),
|
|
121
|
+
onKeyDown: (event) => {
|
|
122
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
123
|
+
event.preventDefault();
|
|
124
|
+
setOpen((prev) => !prev);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"data-status": dataStatus,
|
|
128
|
+
className: cn(
|
|
129
|
+
rowClass,
|
|
130
|
+
"cursor-pointer outline-hidden hover:bg-og-surface-1 hover:text-og-fg",
|
|
131
|
+
"focus-visible:ring-2 focus-visible:ring-og-accent focus-visible:ring-offset-0"
|
|
132
|
+
),
|
|
133
|
+
children: inner
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
open ? /* @__PURE__ */ jsxs("div", { className: "mb-2 ml-7 mt-1.5 flex flex-col gap-2 overflow-hidden animate-og-expand", children: [
|
|
137
|
+
children,
|
|
138
|
+
truncation ? /* @__PURE__ */ jsx2(ToolCallTruncationNotice, { truncation }) : null
|
|
139
|
+
] }) : null
|
|
140
|
+
] });
|
|
141
|
+
}
|
|
142
|
+
function ToolCallTruncationNotice({ truncation }) {
|
|
143
|
+
const fullEvidence = truncation.fullEvidence.available ? "retained" : truncation.fullEvidence.reason ?? "unavailable";
|
|
144
|
+
return /* @__PURE__ */ jsxs("div", { "data-og-tool-output-truncation": "", className: "text-og-sm leading-5 text-og-fg-subtle", children: [
|
|
145
|
+
"Output bounded at ",
|
|
146
|
+
/* @__PURE__ */ jsx2("code", { className: "font-og-mono", children: truncation.surface }),
|
|
147
|
+
truncation.omittedBytes != null && truncation.omittedBytes > 0 ? ` \xB7 ${truncation.omittedBytes.toLocaleString()} bytes omitted` : null,
|
|
148
|
+
" \xB7 reason ",
|
|
149
|
+
/* @__PURE__ */ jsx2("code", { className: "font-og-mono", children: truncation.reason }),
|
|
150
|
+
" \xB7 full evidence ",
|
|
151
|
+
/* @__PURE__ */ jsx2("code", { className: "font-og-mono", children: fullEvidence })
|
|
152
|
+
] });
|
|
153
|
+
}
|
|
154
|
+
function Chip({ chip }) {
|
|
155
|
+
const base = "inline-flex items-center font-og-mono text-og-xs leading-none";
|
|
156
|
+
const withText = chip.text ? "gap-1.5" : "gap-0";
|
|
157
|
+
if (chip.tone === "bad") {
|
|
158
|
+
return /* @__PURE__ */ jsxs("span", { className: cn(base, withText, "text-og-status-failed"), children: [
|
|
159
|
+
/* @__PURE__ */ jsx2("span", { className: "size-1.5 rounded-full bg-og-status-failed" }),
|
|
160
|
+
chip.text
|
|
161
|
+
] });
|
|
162
|
+
}
|
|
163
|
+
if (chip.tone === "interrupted") {
|
|
164
|
+
return /* @__PURE__ */ jsx2("span", { className: cn(base, "text-og-fg-subtle og-cancelled-chip"), children: chip.text });
|
|
165
|
+
}
|
|
166
|
+
return /* @__PURE__ */ jsx2("span", { className: cn(base, "text-og-fg-subtle"), children: chip.text });
|
|
167
|
+
}
|
|
168
|
+
function TermBlock({
|
|
169
|
+
command,
|
|
170
|
+
workdir,
|
|
171
|
+
output,
|
|
172
|
+
live,
|
|
173
|
+
tailLines = 12,
|
|
174
|
+
failed
|
|
175
|
+
}) {
|
|
176
|
+
const [full, setFull] = useState(false);
|
|
177
|
+
const empty = output.trim() === "";
|
|
178
|
+
const lines = output.split("\n");
|
|
179
|
+
const big = lines.length > tailLines + 4;
|
|
180
|
+
const shown = full || !big ? output : lines.slice(-tailLines).join("\n");
|
|
181
|
+
const showMore = big && !full;
|
|
182
|
+
const showHeader = command != null || workdir != null;
|
|
183
|
+
return /* @__PURE__ */ jsxs(
|
|
184
|
+
"div",
|
|
185
|
+
{
|
|
186
|
+
className: cn(
|
|
187
|
+
"min-w-0 border-l-2 pl-3",
|
|
188
|
+
failed ? "border-og-status-failed/50" : live ? "border-og-status-running/50" : "border-og-border"
|
|
189
|
+
),
|
|
190
|
+
children: [
|
|
191
|
+
showHeader ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pb-1", children: [
|
|
192
|
+
/* @__PURE__ */ jsx2("span", { className: "select-none text-og-status-idle", children: "$" }),
|
|
193
|
+
command != null ? /* @__PURE__ */ jsx2("span", { className: "min-w-0 flex-1 truncate font-og-mono text-og-sm text-og-fg-muted", children: command }) : /* @__PURE__ */ jsx2("span", { className: "flex-1" }),
|
|
194
|
+
workdir ? /* @__PURE__ */ jsx2("span", { className: "shrink-0 font-og-mono text-og-xs text-og-fg-subtle", children: workdir }) : null
|
|
195
|
+
] }) : null,
|
|
196
|
+
empty ? /* @__PURE__ */ jsx2("p", { className: "font-og-mono text-og-xs italic text-og-fg-subtle", children: "(no output)" }) : /* @__PURE__ */ jsxs("pre", { className: "max-h-72 overflow-auto whitespace-pre-wrap break-all font-og-mono text-og-xs leading-5 text-og-fg-muted", children: [
|
|
197
|
+
shown,
|
|
198
|
+
live ? /* @__PURE__ */ jsx2("span", { className: "ml-px inline-block h-[1em] w-[2px] translate-y-[2px] animate-og-blink bg-og-accent align-middle" }) : null
|
|
199
|
+
] }),
|
|
200
|
+
showMore ? /* @__PURE__ */ jsxs(
|
|
201
|
+
"button",
|
|
202
|
+
{
|
|
203
|
+
type: "button",
|
|
204
|
+
onClick: () => setFull(true),
|
|
205
|
+
className: "mt-1 text-left text-og-xs text-og-fg-subtle transition-colors hover:text-og-fg",
|
|
206
|
+
children: [
|
|
207
|
+
"show full output (",
|
|
208
|
+
lines.length,
|
|
209
|
+
" lines)"
|
|
210
|
+
]
|
|
211
|
+
}
|
|
212
|
+
) : null
|
|
213
|
+
]
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
function PayloadBlock({
|
|
218
|
+
label,
|
|
219
|
+
value,
|
|
220
|
+
failed
|
|
221
|
+
}) {
|
|
222
|
+
const text = typeof value === "string" ? value : stringifyPayload(value);
|
|
223
|
+
if (!text || text.trim() === "") {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
return /* @__PURE__ */ jsxs(
|
|
227
|
+
"div",
|
|
228
|
+
{
|
|
229
|
+
className: cn(
|
|
230
|
+
"min-w-0 border-l-2 pl-3",
|
|
231
|
+
failed ? "border-og-status-failed/50" : "border-og-border"
|
|
232
|
+
),
|
|
233
|
+
children: [
|
|
234
|
+
/* @__PURE__ */ jsx2("p", { className: "mb-1 text-og-xs font-medium uppercase tracking-[0.08em] text-og-fg-subtle", children: label }),
|
|
235
|
+
/* @__PURE__ */ jsx2(
|
|
236
|
+
"pre",
|
|
237
|
+
{
|
|
238
|
+
className: cn(
|
|
239
|
+
"max-h-64 overflow-auto whitespace-pre-wrap break-all font-og-mono text-og-xs leading-5",
|
|
240
|
+
failed ? "text-og-status-failed" : "text-og-fg-muted"
|
|
241
|
+
),
|
|
242
|
+
children: text
|
|
243
|
+
}
|
|
244
|
+
)
|
|
245
|
+
]
|
|
246
|
+
}
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
function BodyNote({
|
|
250
|
+
children,
|
|
251
|
+
tone
|
|
252
|
+
}) {
|
|
253
|
+
if (tone === "error") {
|
|
254
|
+
return /* @__PURE__ */ jsx2("div", { className: "border-l-2 border-og-status-failed/50 pl-3 font-og-mono text-og-xs leading-5 text-og-status-failed", children });
|
|
255
|
+
}
|
|
256
|
+
return /* @__PURE__ */ jsx2("p", { className: "px-0.5 text-og-sm italic leading-5 text-og-fg-subtle", children });
|
|
257
|
+
}
|
|
258
|
+
var MEDIA_BOX = "h-7 w-[52px] shrink-0 rounded-og-xs border border-og-border";
|
|
259
|
+
function MediaSkeleton() {
|
|
260
|
+
return /* @__PURE__ */ jsxs(
|
|
261
|
+
"span",
|
|
262
|
+
{
|
|
263
|
+
className: cn(
|
|
264
|
+
MEDIA_BOX,
|
|
265
|
+
"relative inline-flex items-center justify-center overflow-hidden bg-og-surface-2"
|
|
266
|
+
),
|
|
267
|
+
children: [
|
|
268
|
+
/* @__PURE__ */ jsx2("span", { className: "absolute inset-0 animate-og-pulse bg-og-surface-3/50" }),
|
|
269
|
+
/* @__PURE__ */ jsx2(CameraIcon, { className: "relative size-3.5 text-og-fg-subtle" })
|
|
270
|
+
]
|
|
271
|
+
}
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
function MediaEmpty() {
|
|
275
|
+
return /* @__PURE__ */ jsx2("span", { className: cn(MEDIA_BOX, "inline-flex items-center justify-center bg-og-bg"), children: /* @__PURE__ */ jsx2(CameraOffIcon, { className: "size-3.5 text-og-fg-subtle" }) });
|
|
276
|
+
}
|
|
277
|
+
function Thumbnail({
|
|
278
|
+
src,
|
|
279
|
+
caption,
|
|
280
|
+
alt = "screenshot",
|
|
281
|
+
expandLabel = "Expand screenshot",
|
|
282
|
+
lightboxLabel = "Screenshot",
|
|
283
|
+
downloadFilename
|
|
284
|
+
}) {
|
|
285
|
+
const lightbox = useLightboxOptional();
|
|
286
|
+
const [failed, setFailed] = useState(false);
|
|
287
|
+
if (failed) {
|
|
288
|
+
return /* @__PURE__ */ jsx2(MediaEmpty, {});
|
|
289
|
+
}
|
|
290
|
+
const img = /* @__PURE__ */ jsx2(
|
|
291
|
+
"img",
|
|
292
|
+
{
|
|
293
|
+
src,
|
|
294
|
+
alt,
|
|
295
|
+
onError: () => setFailed(true),
|
|
296
|
+
className: "h-full w-full object-cover transition-opacity group-hover/thumb:opacity-80"
|
|
297
|
+
}
|
|
298
|
+
);
|
|
299
|
+
if (!lightbox) {
|
|
300
|
+
return /* @__PURE__ */ jsx2("span", { className: cn(MEDIA_BOX, "inline-flex overflow-hidden bg-og-bg"), children: img });
|
|
301
|
+
}
|
|
302
|
+
return /* @__PURE__ */ jsx2(
|
|
303
|
+
"button",
|
|
304
|
+
{
|
|
305
|
+
type: "button",
|
|
306
|
+
onClick: (event) => {
|
|
307
|
+
event.stopPropagation();
|
|
308
|
+
lightbox.open(src, caption, event.currentTarget, lightboxLabel, downloadFilename);
|
|
309
|
+
},
|
|
310
|
+
onKeyDown: (event) => {
|
|
311
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
312
|
+
event.stopPropagation();
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
className: cn(
|
|
316
|
+
MEDIA_BOX,
|
|
317
|
+
"group/thumb relative inline-flex overflow-hidden bg-og-bg outline-hidden",
|
|
318
|
+
"focus-visible:ring-2 focus-visible:ring-og-accent"
|
|
319
|
+
),
|
|
320
|
+
"aria-label": expandLabel,
|
|
321
|
+
children: img
|
|
322
|
+
}
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
function ScreenshotFigure({
|
|
326
|
+
src,
|
|
327
|
+
caption,
|
|
328
|
+
alt = "screenshot",
|
|
329
|
+
expandLabel = "Expand screenshot",
|
|
330
|
+
lightboxLabel = "Screenshot",
|
|
331
|
+
downloadFilename
|
|
332
|
+
}) {
|
|
333
|
+
const lightbox = useLightboxOptional();
|
|
334
|
+
const [failed, setFailed] = useState(false);
|
|
335
|
+
const surface = "block w-full overflow-hidden rounded-og-md border border-og-border bg-og-bg";
|
|
336
|
+
const img = /* @__PURE__ */ jsx2(
|
|
337
|
+
"img",
|
|
338
|
+
{
|
|
339
|
+
src,
|
|
340
|
+
alt,
|
|
341
|
+
onError: () => setFailed(true),
|
|
342
|
+
className: "max-h-80 w-full object-contain"
|
|
343
|
+
}
|
|
344
|
+
);
|
|
345
|
+
return /* @__PURE__ */ jsxs("figure", { className: "m-0 min-w-0", children: [
|
|
346
|
+
failed ? /* @__PURE__ */ jsx2("div", { className: "rounded-og-md border border-og-border bg-og-bg px-3 py-6 text-center font-og-mono text-og-xs text-og-fg-subtle", children: "image unavailable" }) : lightbox ? /* @__PURE__ */ jsx2(
|
|
347
|
+
"button",
|
|
348
|
+
{
|
|
349
|
+
type: "button",
|
|
350
|
+
onClick: (event) => lightbox.open(src, caption, event.currentTarget, lightboxLabel, downloadFilename),
|
|
351
|
+
className: surface,
|
|
352
|
+
"aria-label": expandLabel,
|
|
353
|
+
children: img
|
|
354
|
+
}
|
|
355
|
+
) : /* @__PURE__ */ jsx2("div", { className: surface, children: img }),
|
|
356
|
+
caption ? /* @__PURE__ */ jsx2("figcaption", { className: "mt-1.5 font-og-mono text-og-xs text-og-fg-subtle", children: caption }) : null
|
|
357
|
+
] });
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// src/components/copy-button.tsx
|
|
361
|
+
import { CheckIcon, CopyIcon } from "lucide-react";
|
|
362
|
+
import { useEffect, useRef, useState as useState2 } from "react";
|
|
363
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
364
|
+
var COPIED_MS = 1600;
|
|
365
|
+
function CopyButton({
|
|
366
|
+
text,
|
|
367
|
+
label = "Copy",
|
|
368
|
+
className,
|
|
369
|
+
reveal = "group-hover"
|
|
370
|
+
}) {
|
|
371
|
+
const [copied, setCopied] = useState2(false);
|
|
372
|
+
const [tipOpen, setTipOpen] = useState2(false);
|
|
373
|
+
const timerRef = useRef(null);
|
|
374
|
+
useEffect(() => {
|
|
375
|
+
return () => {
|
|
376
|
+
if (timerRef.current !== null) {
|
|
377
|
+
clearTimeout(timerRef.current);
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
}, []);
|
|
381
|
+
const onClick = async (event) => {
|
|
382
|
+
event.preventDefault();
|
|
383
|
+
event.stopPropagation();
|
|
384
|
+
const button = event.currentTarget;
|
|
385
|
+
const pointerActivated = event.detail > 0;
|
|
386
|
+
const value = typeof text === "function" ? text() : text;
|
|
387
|
+
const ok = await copyTextToClipboard(value);
|
|
388
|
+
if (!ok) {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
setCopied(true);
|
|
392
|
+
setTipOpen(true);
|
|
393
|
+
if (timerRef.current !== null) {
|
|
394
|
+
clearTimeout(timerRef.current);
|
|
395
|
+
}
|
|
396
|
+
timerRef.current = setTimeout(() => {
|
|
397
|
+
timerRef.current = null;
|
|
398
|
+
setCopied(false);
|
|
399
|
+
setTipOpen(false);
|
|
400
|
+
}, COPIED_MS);
|
|
401
|
+
if (pointerActivated) {
|
|
402
|
+
button.blur();
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
const tip = copied ? "Copied" : label;
|
|
406
|
+
return /* @__PURE__ */ jsxs2(
|
|
407
|
+
Tooltip,
|
|
408
|
+
{
|
|
409
|
+
open: copied ? true : tipOpen,
|
|
410
|
+
onOpenChange: (next) => {
|
|
411
|
+
if (!copied) {
|
|
412
|
+
setTipOpen(next);
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
children: [
|
|
416
|
+
/* @__PURE__ */ jsx3(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx3(
|
|
417
|
+
"button",
|
|
418
|
+
{
|
|
419
|
+
type: "button",
|
|
420
|
+
"data-og-copy": "",
|
|
421
|
+
"data-state": copied ? "copied" : "idle",
|
|
422
|
+
"aria-label": tip,
|
|
423
|
+
onClick,
|
|
424
|
+
className: cn(
|
|
425
|
+
"inline-flex size-7 shrink-0 items-center justify-center rounded-og-sm pointer-coarse:size-11",
|
|
426
|
+
"text-og-fg-subtle transition-[opacity,color,background-color] duration-150",
|
|
427
|
+
"hover:bg-og-surface-2/80 hover:text-og-fg",
|
|
428
|
+
"focus-visible:opacity-100 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-og-accent/40",
|
|
429
|
+
reveal === "group-hover" && "opacity-0 group-hover/copy:opacity-100 group-focus-within/copy:opacity-100 pointer-coarse:opacity-70",
|
|
430
|
+
copied && "opacity-100 text-og-accent",
|
|
431
|
+
className
|
|
432
|
+
),
|
|
433
|
+
children: copied ? /* @__PURE__ */ jsx3(CheckIcon, { className: "size-3.5", "aria-hidden": true }) : /* @__PURE__ */ jsx3(CopyIcon, { className: "size-3.5", "aria-hidden": true })
|
|
434
|
+
}
|
|
435
|
+
) }),
|
|
436
|
+
/* @__PURE__ */ jsx3(TooltipContent, { side: "top", children: tip })
|
|
437
|
+
]
|
|
438
|
+
}
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
function CopyHoverFrame({
|
|
442
|
+
children,
|
|
443
|
+
className,
|
|
444
|
+
copyText,
|
|
445
|
+
label,
|
|
446
|
+
align = "end",
|
|
447
|
+
trailing
|
|
448
|
+
}) {
|
|
449
|
+
if (copyText.trim().length === 0) {
|
|
450
|
+
return /* @__PURE__ */ jsx3("div", { className, children });
|
|
451
|
+
}
|
|
452
|
+
return /* @__PURE__ */ jsxs2("div", { className: cn("group/copy", className), children: [
|
|
453
|
+
children,
|
|
454
|
+
/* @__PURE__ */ jsxs2(
|
|
455
|
+
"div",
|
|
456
|
+
{
|
|
457
|
+
"data-og-annotation-chrome": "",
|
|
458
|
+
className: cn(
|
|
459
|
+
"flex h-6 items-center gap-1.5 pointer-coarse:h-11",
|
|
460
|
+
align === "end" ? "justify-end" : "justify-start"
|
|
461
|
+
),
|
|
462
|
+
children: [
|
|
463
|
+
/* @__PURE__ */ jsx3(
|
|
464
|
+
CopyButton,
|
|
465
|
+
{
|
|
466
|
+
text: copyText,
|
|
467
|
+
label,
|
|
468
|
+
reveal: "group-hover",
|
|
469
|
+
className: "size-6 pointer-coarse:size-11"
|
|
470
|
+
}
|
|
471
|
+
),
|
|
472
|
+
trailing
|
|
473
|
+
]
|
|
474
|
+
}
|
|
475
|
+
)
|
|
476
|
+
] });
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// src/components/markdown.tsx
|
|
480
|
+
import {
|
|
481
|
+
Children,
|
|
482
|
+
createContext as createContext3,
|
|
483
|
+
useContext as useContext3,
|
|
484
|
+
isValidElement,
|
|
485
|
+
memo,
|
|
486
|
+
useEffect as useEffect3,
|
|
487
|
+
useMemo,
|
|
488
|
+
useReducer,
|
|
489
|
+
useRef as useRef3,
|
|
490
|
+
useState as useState3
|
|
491
|
+
} from "react";
|
|
492
|
+
import ReactMarkdown, {
|
|
493
|
+
defaultUrlTransform
|
|
494
|
+
} from "react-markdown";
|
|
495
|
+
import remarkGfm from "remark-gfm";
|
|
496
|
+
import { PanelsTopLeftIcon } from "lucide-react";
|
|
497
|
+
|
|
498
|
+
// src/lib/motion.ts
|
|
499
|
+
import { flushSync } from "react-dom";
|
|
500
|
+
var query;
|
|
501
|
+
function prefersReducedMotion() {
|
|
502
|
+
if (query === void 0) {
|
|
503
|
+
query = typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia("(prefers-reduced-motion: reduce)") : null;
|
|
504
|
+
}
|
|
505
|
+
return query?.matches ?? false;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// src/lib/motion-inspect.ts
|
|
509
|
+
var MOTION_INSPECT_SCALE = 1;
|
|
510
|
+
|
|
511
|
+
// src/components/preview-loading.tsx
|
|
512
|
+
import { useEffect as useEffect2, useRef as useRef2 } from "react";
|
|
513
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
514
|
+
function PreviewLoading() {
|
|
515
|
+
const ref = useRef2(null);
|
|
516
|
+
useEffect2(() => {
|
|
517
|
+
const canvas = ref.current;
|
|
518
|
+
if (!canvas) return;
|
|
519
|
+
let ctx;
|
|
520
|
+
try {
|
|
521
|
+
ctx = canvas.getContext("2d");
|
|
522
|
+
} catch {
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
if (!ctx) return;
|
|
526
|
+
const context = ctx;
|
|
527
|
+
const motion = window.matchMedia?.("(prefers-reduced-motion: reduce)");
|
|
528
|
+
let frame;
|
|
529
|
+
let time = 2;
|
|
530
|
+
let last;
|
|
531
|
+
let disposed = false;
|
|
532
|
+
let visible = false;
|
|
533
|
+
const canAnimate = () => !disposed && visible && !document.hidden && motion?.matches === false;
|
|
534
|
+
function draw() {
|
|
535
|
+
const w = canvas.clientWidth;
|
|
536
|
+
const h = canvas.clientHeight;
|
|
537
|
+
if (!w || !h || document.hidden || disposed) return;
|
|
538
|
+
const d = Math.min(window.devicePixelRatio || 1, 2);
|
|
539
|
+
if (canvas.width !== Math.round(w * d) || canvas.height !== Math.round(h * d)) {
|
|
540
|
+
canvas.width = Math.round(w * d);
|
|
541
|
+
canvas.height = Math.round(h * d);
|
|
542
|
+
}
|
|
543
|
+
const style = getComputedStyle(canvas);
|
|
544
|
+
const ink = style.getPropertyValue("--_og-preview-ink").trim() || "#bca3ef";
|
|
545
|
+
const glowColor = style.getPropertyValue("--_og-preview-glow").trim() || "#8f6ccc";
|
|
546
|
+
context.setTransform(d, 0, 0, d, 0, 0);
|
|
547
|
+
context.clearRect(0, 0, w, h);
|
|
548
|
+
const cx = w * (0.5 + 0.13 * Math.sin(time * 0.21));
|
|
549
|
+
const cy = h * (0.5 + 0.12 * Math.cos(time * 0.27));
|
|
550
|
+
const glow = context.createRadialGradient(cx, cy, 0, cx, cy, Math.max(w, h) * 0.65);
|
|
551
|
+
glow.addColorStop(0, glowColor);
|
|
552
|
+
glow.addColorStop(1, "transparent");
|
|
553
|
+
context.globalAlpha = 0.09;
|
|
554
|
+
context.fillStyle = glow;
|
|
555
|
+
context.fillRect(0, 0, w, h);
|
|
556
|
+
const rows = Math.ceil(h / 18) + 7;
|
|
557
|
+
const cols = Math.ceil(w / 18) + 7;
|
|
558
|
+
const points = Array.from(
|
|
559
|
+
{ length: rows },
|
|
560
|
+
(_row, r) => Array.from({ length: cols }, (_col, c) => {
|
|
561
|
+
const x = (c - 3) * 18;
|
|
562
|
+
const y = (r - 3) * 18;
|
|
563
|
+
const dist = Math.hypot((x - cx) * 0.8, y - cy);
|
|
564
|
+
const wave = Math.sin(dist * 0.032 - time * 0.95);
|
|
565
|
+
return {
|
|
566
|
+
x: x + (x - cx) / Math.max(dist, 1) * wave * 4,
|
|
567
|
+
y: y + (y - cy) / Math.max(dist, 1) * wave * 4,
|
|
568
|
+
l: Math.pow((wave + 1) / 2, 5)
|
|
569
|
+
};
|
|
570
|
+
})
|
|
571
|
+
);
|
|
572
|
+
context.strokeStyle = ink;
|
|
573
|
+
context.fillStyle = ink;
|
|
574
|
+
context.lineWidth = 0.65;
|
|
575
|
+
points.forEach(
|
|
576
|
+
(row, r) => row.forEach((p, c) => {
|
|
577
|
+
context.globalAlpha = 0.035 + p.l * 0.055;
|
|
578
|
+
context.beginPath();
|
|
579
|
+
if (c + 1 < cols) {
|
|
580
|
+
context.moveTo(p.x, p.y);
|
|
581
|
+
context.lineTo(row[c + 1].x, row[c + 1].y);
|
|
582
|
+
}
|
|
583
|
+
if (r + 1 < rows) {
|
|
584
|
+
context.moveTo(p.x, p.y);
|
|
585
|
+
context.lineTo(points[r + 1][c].x, points[r + 1][c].y);
|
|
586
|
+
}
|
|
587
|
+
context.stroke();
|
|
588
|
+
context.globalAlpha = 0.15 + p.l * 0.55;
|
|
589
|
+
context.beginPath();
|
|
590
|
+
context.arc(p.x, p.y, 0.85 + p.l * 0.65, 0, Math.PI * 2);
|
|
591
|
+
context.fill();
|
|
592
|
+
})
|
|
593
|
+
);
|
|
594
|
+
context.globalAlpha = 1;
|
|
595
|
+
canvas.dataset.painted = "true";
|
|
596
|
+
}
|
|
597
|
+
function stop() {
|
|
598
|
+
if (frame !== void 0) window.cancelAnimationFrame(frame);
|
|
599
|
+
frame = void 0;
|
|
600
|
+
last = void 0;
|
|
601
|
+
}
|
|
602
|
+
function tick(stamp) {
|
|
603
|
+
frame = void 0;
|
|
604
|
+
if (!canAnimate()) return;
|
|
605
|
+
if (last !== void 0) time += Math.min((stamp - last) / 1e3, 0.05);
|
|
606
|
+
last = stamp;
|
|
607
|
+
draw();
|
|
608
|
+
frame = window.requestAnimationFrame(tick);
|
|
609
|
+
}
|
|
610
|
+
function refresh() {
|
|
611
|
+
stop();
|
|
612
|
+
if (disposed || document.hidden || !visible && intersection) return;
|
|
613
|
+
draw();
|
|
614
|
+
if (canAnimate() && typeof window.requestAnimationFrame === "function") {
|
|
615
|
+
frame = window.requestAnimationFrame(tick);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
const intersection = typeof IntersectionObserver === "function" ? new IntersectionObserver(([entry]) => {
|
|
619
|
+
visible = entry?.isIntersecting === true;
|
|
620
|
+
refresh();
|
|
621
|
+
}) : void 0;
|
|
622
|
+
intersection?.observe(canvas);
|
|
623
|
+
const resize = typeof ResizeObserver === "function" ? new ResizeObserver(refresh) : void 0;
|
|
624
|
+
resize?.observe(canvas);
|
|
625
|
+
const theme = typeof MutationObserver === "function" ? new MutationObserver(refresh) : void 0;
|
|
626
|
+
for (let ancestor = canvas.parentElement; ancestor; ancestor = ancestor.parentElement) {
|
|
627
|
+
theme?.observe(ancestor, {
|
|
628
|
+
attributes: true,
|
|
629
|
+
attributeFilter: ["class", "style", "data-og-theme"]
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
motion?.addEventListener?.("change", refresh);
|
|
633
|
+
document.addEventListener("visibilitychange", refresh);
|
|
634
|
+
window.addEventListener("resize", refresh);
|
|
635
|
+
if (!intersection) draw();
|
|
636
|
+
return () => {
|
|
637
|
+
disposed = true;
|
|
638
|
+
stop();
|
|
639
|
+
intersection?.disconnect();
|
|
640
|
+
resize?.disconnect();
|
|
641
|
+
theme?.disconnect();
|
|
642
|
+
motion?.removeEventListener?.("change", refresh);
|
|
643
|
+
document.removeEventListener("visibilitychange", refresh);
|
|
644
|
+
window.removeEventListener("resize", refresh);
|
|
645
|
+
};
|
|
646
|
+
}, []);
|
|
647
|
+
return /* @__PURE__ */ jsxs3("div", { className: "og-preview-loading", children: [
|
|
648
|
+
/* @__PURE__ */ jsx4("canvas", { ref, "aria-hidden": "true" }),
|
|
649
|
+
/* @__PURE__ */ jsx4("span", { className: "og-preview-loading-label", children: "Preparing preview\u2026" })
|
|
650
|
+
] });
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
// src/components/soften-streaming-markdown.ts
|
|
654
|
+
function softenStreamingMarkdown(source) {
|
|
655
|
+
if (source.length === 0) {
|
|
656
|
+
return source;
|
|
657
|
+
}
|
|
658
|
+
let text = source;
|
|
659
|
+
if (countFences(text) % 2 === 1) {
|
|
660
|
+
text += text.endsWith("\n") ? "```" : "\n```";
|
|
661
|
+
}
|
|
662
|
+
const segments = splitByFences(text);
|
|
663
|
+
for (const segment of segments) {
|
|
664
|
+
if (segment.kind === "fence") {
|
|
665
|
+
continue;
|
|
666
|
+
}
|
|
667
|
+
segment.value = closeInlineMarkers(segment.value);
|
|
668
|
+
}
|
|
669
|
+
let result = segments.map((segment) => segment.value).join("");
|
|
670
|
+
if (text.endsWith("\n") && !result.endsWith("\n")) {
|
|
671
|
+
result += "\n";
|
|
672
|
+
}
|
|
673
|
+
return result;
|
|
674
|
+
}
|
|
675
|
+
function countFences(text) {
|
|
676
|
+
let count = 0;
|
|
677
|
+
for (const line of text.split("\n")) {
|
|
678
|
+
if (/^ {0,3}```/.test(line)) {
|
|
679
|
+
count += 1;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
return count;
|
|
683
|
+
}
|
|
684
|
+
function splitByFences(text) {
|
|
685
|
+
const segments = [];
|
|
686
|
+
const lines = text.split("\n");
|
|
687
|
+
let buf = [];
|
|
688
|
+
let inFence = false;
|
|
689
|
+
const flush = (kind, mode) => {
|
|
690
|
+
if (buf.length === 0) {
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
let value = buf.join("\n");
|
|
694
|
+
if (mode === "boundary") {
|
|
695
|
+
value += "\n";
|
|
696
|
+
}
|
|
697
|
+
segments.push({ kind, value });
|
|
698
|
+
buf = [];
|
|
699
|
+
};
|
|
700
|
+
for (const line of lines) {
|
|
701
|
+
const isFence = /^ {0,3}```/.test(line);
|
|
702
|
+
if (isFence) {
|
|
703
|
+
if (inFence) {
|
|
704
|
+
buf.push(line);
|
|
705
|
+
flush("fence", "end");
|
|
706
|
+
inFence = false;
|
|
707
|
+
} else {
|
|
708
|
+
flush("prose", "boundary");
|
|
709
|
+
buf.push(line);
|
|
710
|
+
inFence = true;
|
|
711
|
+
}
|
|
712
|
+
continue;
|
|
713
|
+
}
|
|
714
|
+
buf.push(line);
|
|
715
|
+
}
|
|
716
|
+
flush(inFence ? "fence" : "prose", "end");
|
|
717
|
+
return segments;
|
|
718
|
+
}
|
|
719
|
+
function closeInlineMarkers(prose) {
|
|
720
|
+
let text = prose;
|
|
721
|
+
text = closeDelimiter(text, "~~");
|
|
722
|
+
text = closeDelimiter(text, "**");
|
|
723
|
+
text = closeDelimiter(text, "__");
|
|
724
|
+
text = closeSingleBackticks(text);
|
|
725
|
+
text = closeSingleAsterisks(text);
|
|
726
|
+
text = closeUnfinishedLink(text);
|
|
727
|
+
return text;
|
|
728
|
+
}
|
|
729
|
+
function closeDelimiter(text, delimiter) {
|
|
730
|
+
let count = 0;
|
|
731
|
+
let i = 0;
|
|
732
|
+
while (i < text.length) {
|
|
733
|
+
if (text[i] === "\\" && i + 1 < text.length) {
|
|
734
|
+
i += 2;
|
|
735
|
+
continue;
|
|
736
|
+
}
|
|
737
|
+
if (text.startsWith(delimiter, i)) {
|
|
738
|
+
count += 1;
|
|
739
|
+
i += delimiter.length;
|
|
740
|
+
continue;
|
|
741
|
+
}
|
|
742
|
+
i += 1;
|
|
743
|
+
}
|
|
744
|
+
return count % 2 === 1 ? insertBeforeTrailingNewlines(text, delimiter) : text;
|
|
745
|
+
}
|
|
746
|
+
function insertBeforeTrailingNewlines(text, suffix) {
|
|
747
|
+
let end = text.length;
|
|
748
|
+
while (end > 0 && text[end - 1] === "\n") {
|
|
749
|
+
end -= 1;
|
|
750
|
+
}
|
|
751
|
+
return text.slice(0, end) + suffix + text.slice(end);
|
|
752
|
+
}
|
|
753
|
+
function closeSingleBackticks(text) {
|
|
754
|
+
let count = 0;
|
|
755
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
756
|
+
if (text[i] === "\\" && i + 1 < text.length) {
|
|
757
|
+
i += 1;
|
|
758
|
+
continue;
|
|
759
|
+
}
|
|
760
|
+
if (text[i] === "`") {
|
|
761
|
+
if (text.startsWith("```", i)) {
|
|
762
|
+
i += 2;
|
|
763
|
+
continue;
|
|
764
|
+
}
|
|
765
|
+
count += 1;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
return count % 2 === 1 ? insertBeforeTrailingNewlines(text, "`") : text;
|
|
769
|
+
}
|
|
770
|
+
function closeSingleAsterisks(text) {
|
|
771
|
+
let count = 0;
|
|
772
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
773
|
+
if (text[i] === "\\" && i + 1 < text.length) {
|
|
774
|
+
i += 1;
|
|
775
|
+
continue;
|
|
776
|
+
}
|
|
777
|
+
if (text[i] === "*" && text[i + 1] === "*") {
|
|
778
|
+
i += 1;
|
|
779
|
+
continue;
|
|
780
|
+
}
|
|
781
|
+
if (text[i] === "*") {
|
|
782
|
+
count += 1;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
return count % 2 === 1 ? insertBeforeTrailingNewlines(text, "*") : text;
|
|
786
|
+
}
|
|
787
|
+
function closeUnfinishedLink(text) {
|
|
788
|
+
const open = text.lastIndexOf("](");
|
|
789
|
+
if (open === -1) {
|
|
790
|
+
return text;
|
|
791
|
+
}
|
|
792
|
+
const after = text.slice(open + 2);
|
|
793
|
+
if (after.includes(")")) {
|
|
794
|
+
return text;
|
|
795
|
+
}
|
|
796
|
+
if (after.includes("[")) {
|
|
797
|
+
return text;
|
|
798
|
+
}
|
|
799
|
+
return insertBeforeTrailingNewlines(text, ")");
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
// src/components/stream-reveal.ts
|
|
803
|
+
var INK_FADE_MS = 420 * MOTION_INSPECT_SCALE;
|
|
804
|
+
var INITIAL_ANIMATED_LIMIT = 400;
|
|
805
|
+
function createStreamReveal() {
|
|
806
|
+
let batches = [];
|
|
807
|
+
let revealedChars = -1;
|
|
808
|
+
return {
|
|
809
|
+
observe(text, now) {
|
|
810
|
+
if (revealedChars === -1) {
|
|
811
|
+
revealedChars = text.length > INITIAL_ANIMATED_LIMIT ? text.length : 0;
|
|
812
|
+
}
|
|
813
|
+
if (text.length <= revealedChars) {
|
|
814
|
+
revealedChars = Math.max(revealedChars, text.length);
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
batches.push({ start: revealedChars, end: text.length, birth: now });
|
|
818
|
+
revealedChars = text.length;
|
|
819
|
+
batches = batches.filter((batch) => batch.birth + INK_FADE_MS > now);
|
|
820
|
+
},
|
|
821
|
+
delayFor(offset, now) {
|
|
822
|
+
const batch = findBatch(batches, offset);
|
|
823
|
+
if (!batch) {
|
|
824
|
+
return null;
|
|
825
|
+
}
|
|
826
|
+
const delay = batch.birth - now;
|
|
827
|
+
return delay + INK_FADE_MS <= 0 ? null : delay;
|
|
828
|
+
},
|
|
829
|
+
hasActive(now) {
|
|
830
|
+
const last = batches[batches.length - 1];
|
|
831
|
+
return last !== void 0 && last.birth + INK_FADE_MS > now;
|
|
832
|
+
}
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
function findBatch(batches, offset) {
|
|
836
|
+
let low = 0;
|
|
837
|
+
let high = batches.length - 1;
|
|
838
|
+
while (low <= high) {
|
|
839
|
+
const mid = low + high >> 1;
|
|
840
|
+
const batch = batches[mid];
|
|
841
|
+
if (offset < batch.start) {
|
|
842
|
+
high = mid - 1;
|
|
843
|
+
} else if (offset >= batch.end) {
|
|
844
|
+
low = mid + 1;
|
|
845
|
+
} else {
|
|
846
|
+
return batch;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
return null;
|
|
850
|
+
}
|
|
851
|
+
function rehypeStreamReveal(options) {
|
|
852
|
+
const { reveal, now } = options;
|
|
853
|
+
return (tree) => {
|
|
854
|
+
walk(tree, false);
|
|
855
|
+
};
|
|
856
|
+
function walk(node, insideVerbatim) {
|
|
857
|
+
if (!node.children) {
|
|
858
|
+
return;
|
|
859
|
+
}
|
|
860
|
+
const verbatim = insideVerbatim || node.tagName === "code" || node.tagName === "pre";
|
|
861
|
+
const next = [];
|
|
862
|
+
for (const child of node.children) {
|
|
863
|
+
if (child.type === "text" && !verbatim) {
|
|
864
|
+
next.push(...splitTextNode(child));
|
|
865
|
+
continue;
|
|
866
|
+
}
|
|
867
|
+
walk(child, verbatim);
|
|
868
|
+
next.push(child);
|
|
869
|
+
}
|
|
870
|
+
node.children = next;
|
|
871
|
+
}
|
|
872
|
+
function splitTextNode(node) {
|
|
873
|
+
const sourceOffset = node.position?.start?.offset;
|
|
874
|
+
if (sourceOffset === void 0) {
|
|
875
|
+
return [node];
|
|
876
|
+
}
|
|
877
|
+
const value = node.value;
|
|
878
|
+
const out = [];
|
|
879
|
+
let plain = "";
|
|
880
|
+
const flushPlain = () => {
|
|
881
|
+
if (plain.length > 0) {
|
|
882
|
+
out.push({ type: "text", value: plain });
|
|
883
|
+
plain = "";
|
|
884
|
+
}
|
|
885
|
+
};
|
|
886
|
+
let i = 0;
|
|
887
|
+
while (i < value.length) {
|
|
888
|
+
const delay = reveal.delayFor(sourceOffset + i, now);
|
|
889
|
+
let j = i + 1;
|
|
890
|
+
while (j < value.length) {
|
|
891
|
+
const nextDelay = reveal.delayFor(sourceOffset + j, now);
|
|
892
|
+
if (nextDelay !== delay) {
|
|
893
|
+
break;
|
|
894
|
+
}
|
|
895
|
+
j += 1;
|
|
896
|
+
}
|
|
897
|
+
const slice = value.slice(i, j);
|
|
898
|
+
if (delay === null) {
|
|
899
|
+
plain += slice;
|
|
900
|
+
} else {
|
|
901
|
+
flushPlain();
|
|
902
|
+
out.push({
|
|
903
|
+
type: "element",
|
|
904
|
+
tagName: "span",
|
|
905
|
+
properties: {
|
|
906
|
+
className: ["og-stream-ink"],
|
|
907
|
+
style: `animation-delay:${Math.round(delay)}ms`
|
|
908
|
+
},
|
|
909
|
+
children: [{ type: "text", value: slice }]
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
i = j;
|
|
913
|
+
}
|
|
914
|
+
flushPlain();
|
|
915
|
+
return out.length > 0 ? out : [node];
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
// src/components/markdown.tsx
|
|
920
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
921
|
+
var InteractiveContext = createContext3({ source: "" });
|
|
922
|
+
var baseComponents = {
|
|
923
|
+
h1: ({ children, ...props }) => /* @__PURE__ */ jsx5(
|
|
924
|
+
"h1",
|
|
925
|
+
{
|
|
926
|
+
className: "mt-5 mb-2.5 text-xl font-semibold tracking-tight text-og-fg first:mt-0",
|
|
927
|
+
...props,
|
|
928
|
+
children
|
|
929
|
+
}
|
|
930
|
+
),
|
|
931
|
+
h2: ({ children, ...props }) => /* @__PURE__ */ jsx5("h2", { className: "mt-5 mb-2 text-lg font-semibold tracking-tight text-og-fg first:mt-0", ...props, children }),
|
|
932
|
+
h3: ({ children, ...props }) => /* @__PURE__ */ jsx5(
|
|
933
|
+
"h3",
|
|
934
|
+
{
|
|
935
|
+
className: "mt-4 mb-1.5 text-og-md font-semibold tracking-tight text-og-fg first:mt-0",
|
|
936
|
+
...props,
|
|
937
|
+
children
|
|
938
|
+
}
|
|
939
|
+
),
|
|
940
|
+
h4: ({ children, ...props }) => /* @__PURE__ */ jsx5(
|
|
941
|
+
"h4",
|
|
942
|
+
{
|
|
943
|
+
className: "mt-4 mb-1.5 text-og-sm font-semibold uppercase tracking-[0.04em] text-og-fg-muted first:mt-0",
|
|
944
|
+
...props,
|
|
945
|
+
children
|
|
946
|
+
}
|
|
947
|
+
),
|
|
948
|
+
p: ({ children, ...props }) => /* @__PURE__ */ jsx5("p", { className: "my-2.5 leading-7 first:mt-0 last:mb-0", ...props, children }),
|
|
949
|
+
strong: ({ children, ...props }) => /* @__PURE__ */ jsx5("strong", { className: "font-semibold text-og-fg", ...props, children }),
|
|
950
|
+
em: ({ children, ...props }) => /* @__PURE__ */ jsx5("em", { className: "italic", ...props, children }),
|
|
951
|
+
ul: ({ children, ...props }) => /* @__PURE__ */ jsx5(
|
|
952
|
+
"ul",
|
|
953
|
+
{
|
|
954
|
+
className: "my-2.5 ml-5 flex list-disc flex-col gap-1 marker:text-og-fg-subtle first:mt-0 last:mb-0",
|
|
955
|
+
...props,
|
|
956
|
+
children
|
|
957
|
+
}
|
|
958
|
+
),
|
|
959
|
+
ol: ({ children, ...props }) => /* @__PURE__ */ jsx5(
|
|
960
|
+
"ol",
|
|
961
|
+
{
|
|
962
|
+
className: "my-2.5 ml-5 flex list-decimal flex-col gap-1 marker:text-og-fg-subtle first:mt-0 last:mb-0",
|
|
963
|
+
...props,
|
|
964
|
+
children
|
|
965
|
+
}
|
|
966
|
+
),
|
|
967
|
+
// GFM task-list items carry a leading checkbox <input>; `list-none` + a
|
|
968
|
+
// negative margin pull the checkbox back to the bullet column so it aligns
|
|
969
|
+
// with the text.
|
|
970
|
+
li: ({ children, ...props }) => /* @__PURE__ */ jsx5(
|
|
971
|
+
"li",
|
|
972
|
+
{
|
|
973
|
+
className: "leading-7 marker:text-og-fg-subtle [&>ul]:my-1 [&>ol]:my-1 [&:has(>input)]:list-none [&:has(>input)]:-ml-5",
|
|
974
|
+
...props,
|
|
975
|
+
children
|
|
976
|
+
}
|
|
977
|
+
),
|
|
978
|
+
input: ({ type, ...props }) => type === "checkbox" ? /* @__PURE__ */ jsx5(
|
|
979
|
+
"input",
|
|
980
|
+
{
|
|
981
|
+
...props,
|
|
982
|
+
type: "checkbox",
|
|
983
|
+
disabled: true,
|
|
984
|
+
className: "mr-2 size-3.5 translate-y-[2px] cursor-default accent-og-accent align-baseline"
|
|
985
|
+
}
|
|
986
|
+
) : /* @__PURE__ */ jsx5("input", { type, ...props }),
|
|
987
|
+
blockquote: ({ children, ...props }) => /* @__PURE__ */ jsx5(
|
|
988
|
+
"blockquote",
|
|
989
|
+
{
|
|
990
|
+
className: "my-3 border-l-2 border-og-border-strong pl-3.5 text-og-fg-muted [&>p]:my-1.5 first:mt-0 last:mb-0",
|
|
991
|
+
...props,
|
|
992
|
+
children
|
|
993
|
+
}
|
|
994
|
+
),
|
|
995
|
+
hr: (props) => /* @__PURE__ */ jsx5("hr", { className: "my-4 border-0 border-t border-og-border", ...props }),
|
|
996
|
+
// Inline `code` vs fenced code blocks. react-markdown v10 no longer passes an
|
|
997
|
+
// `inline` flag; a fenced block is a <code> whose parent is <pre> (styled by
|
|
998
|
+
// the `pre` renderer), so a `code` reaching here is treated as inline.
|
|
999
|
+
code: ({ children, className: _className, ...props }) => /* @__PURE__ */ jsx5(
|
|
1000
|
+
"code",
|
|
1001
|
+
{
|
|
1002
|
+
className: "rounded-og-xs bg-og-surface-1 px-1 py-0.5 font-og-mono text-og-sm text-og-fg",
|
|
1003
|
+
...props,
|
|
1004
|
+
children
|
|
1005
|
+
}
|
|
1006
|
+
),
|
|
1007
|
+
// Fenced code — quiet mono block (no card / no nested vertical scroll).
|
|
1008
|
+
pre: InteractiveCodeBlock,
|
|
1009
|
+
// Tables stay unboxed (hairline rules); hover reveals a TSV copy control.
|
|
1010
|
+
table: ({ children, ...props }) => /* @__PURE__ */ jsx5(MarkdownTable, { ...props, children }),
|
|
1011
|
+
thead: ({ children, ...props }) => /* @__PURE__ */ jsx5("thead", { ...props, children }),
|
|
1012
|
+
th: ({ children, ...props }) => /* @__PURE__ */ jsx5(
|
|
1013
|
+
"th",
|
|
1014
|
+
{
|
|
1015
|
+
className: "border-b border-og-border px-0 py-1.5 pr-4 text-left font-medium text-og-fg first:pl-0",
|
|
1016
|
+
...props,
|
|
1017
|
+
children
|
|
1018
|
+
}
|
|
1019
|
+
),
|
|
1020
|
+
td: ({ children, ...props }) => /* @__PURE__ */ jsx5(
|
|
1021
|
+
"td",
|
|
1022
|
+
{
|
|
1023
|
+
className: "border-b border-og-border/70 px-0 py-1.5 pr-4 align-top text-og-fg-muted [tr:last-child>&]:border-b-0",
|
|
1024
|
+
...props,
|
|
1025
|
+
children
|
|
1026
|
+
}
|
|
1027
|
+
),
|
|
1028
|
+
img: MarkdownImage
|
|
1029
|
+
};
|
|
1030
|
+
var MARKDOWN_LINK_CLASS = "break-words font-medium text-og-accent-strong underline-offset-2 hover:underline";
|
|
1031
|
+
function markdownComponents(onSandboxFile) {
|
|
1032
|
+
return {
|
|
1033
|
+
...baseComponents,
|
|
1034
|
+
a: ({ children, href, ...props }) => {
|
|
1035
|
+
const location = sandboxFileLocationFromHref(href);
|
|
1036
|
+
if (location !== null) {
|
|
1037
|
+
return /* @__PURE__ */ jsx5(SandboxMarkdownLink, { location, onSandboxFile, children });
|
|
1038
|
+
}
|
|
1039
|
+
if (isSandboxHref(href) || !href) {
|
|
1040
|
+
return /* @__PURE__ */ jsx5(
|
|
1041
|
+
"span",
|
|
1042
|
+
{
|
|
1043
|
+
className: "break-words font-medium text-og-fg-subtle underline decoration-dotted underline-offset-2",
|
|
1044
|
+
"aria-disabled": "true",
|
|
1045
|
+
title: isSandboxHref(href) ? "This sandbox file reference is invalid" : "This link is unavailable",
|
|
1046
|
+
children
|
|
1047
|
+
}
|
|
1048
|
+
);
|
|
1049
|
+
}
|
|
1050
|
+
return /* @__PURE__ */ jsx5(
|
|
1051
|
+
"a",
|
|
1052
|
+
{
|
|
1053
|
+
className: MARKDOWN_LINK_CLASS,
|
|
1054
|
+
target: "_blank",
|
|
1055
|
+
rel: "noreferrer noopener",
|
|
1056
|
+
href,
|
|
1057
|
+
...props,
|
|
1058
|
+
children
|
|
1059
|
+
}
|
|
1060
|
+
);
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
function SandboxMarkdownLink({
|
|
1065
|
+
location,
|
|
1066
|
+
onSandboxFile,
|
|
1067
|
+
children
|
|
1068
|
+
}) {
|
|
1069
|
+
const [state, setState] = useState3("idle");
|
|
1070
|
+
const { path, line } = location;
|
|
1071
|
+
if (!onSandboxFile) {
|
|
1072
|
+
return /* @__PURE__ */ jsx5(
|
|
1073
|
+
"span",
|
|
1074
|
+
{
|
|
1075
|
+
className: "break-words font-medium text-og-fg-subtle underline decoration-dotted underline-offset-2",
|
|
1076
|
+
"aria-disabled": "true",
|
|
1077
|
+
title: "This sandbox file requires a session-aware handler",
|
|
1078
|
+
children
|
|
1079
|
+
}
|
|
1080
|
+
);
|
|
1081
|
+
}
|
|
1082
|
+
const idleTitle = line !== null ? `Open ${path} at line ${line}` : `Open ${path}`;
|
|
1083
|
+
return /* @__PURE__ */ jsxs4(
|
|
1084
|
+
"button",
|
|
1085
|
+
{
|
|
1086
|
+
type: "button",
|
|
1087
|
+
className: cn(
|
|
1088
|
+
MARKDOWN_LINK_CLASS,
|
|
1089
|
+
"inline-flex min-h-7 cursor-pointer items-center disabled:cursor-wait disabled:opacity-70 pointer-coarse:min-h-11"
|
|
1090
|
+
),
|
|
1091
|
+
disabled: state === "loading",
|
|
1092
|
+
"aria-busy": state === "loading",
|
|
1093
|
+
title: state === "error" ? "Couldn't open this file. Select to retry." : idleTitle,
|
|
1094
|
+
onClick: () => {
|
|
1095
|
+
setState("loading");
|
|
1096
|
+
void Promise.resolve(onSandboxFile(path, line ?? void 0)).then(
|
|
1097
|
+
() => setState("idle"),
|
|
1098
|
+
() => setState("error")
|
|
1099
|
+
);
|
|
1100
|
+
},
|
|
1101
|
+
children: [
|
|
1102
|
+
children,
|
|
1103
|
+
state === "loading" ? " (opening\u2026)" : state === "error" ? " (retry)" : null
|
|
1104
|
+
]
|
|
1105
|
+
}
|
|
1106
|
+
);
|
|
1107
|
+
}
|
|
1108
|
+
var SANDBOX_SCHEME = "sandbox:";
|
|
1109
|
+
var LEGACY_WORKSPACE_PREFIX = "/workspace/";
|
|
1110
|
+
var TRAILING_LINE = /:([0-9]+)$/u;
|
|
1111
|
+
var TRAILING_INVALID_LINE = /:-(?:[0-9]+)$|:[0-9]+-[0-9]+$/u;
|
|
1112
|
+
var CONTROL_CHARACTER = /[\u0000-\u001f\u007f]/u;
|
|
1113
|
+
function isSandboxHref(href) {
|
|
1114
|
+
return href?.startsWith(SANDBOX_SCHEME) ?? false;
|
|
1115
|
+
}
|
|
1116
|
+
function sandboxFileLocationFromHref(href) {
|
|
1117
|
+
if (!href) return null;
|
|
1118
|
+
const encodedLocation = isSandboxHref(href) ? href.slice(SANDBOX_SCHEME.length) : href.startsWith(LEGACY_WORKSPACE_PREFIX) ? href : null;
|
|
1119
|
+
if (!encodedLocation || encodedLocation.includes("?") || encodedLocation.includes("#")) {
|
|
1120
|
+
return null;
|
|
1121
|
+
}
|
|
1122
|
+
if (TRAILING_INVALID_LINE.test(encodedLocation)) return null;
|
|
1123
|
+
const lineMatch = TRAILING_LINE.exec(encodedLocation);
|
|
1124
|
+
const encodedPath = lineMatch ? encodedLocation.slice(0, -lineMatch[0].length) : encodedLocation;
|
|
1125
|
+
const line = lineMatch?.[1] ? Number(lineMatch[1]) : null;
|
|
1126
|
+
if (line !== null && (!Number.isSafeInteger(line) || line < 1)) return null;
|
|
1127
|
+
if (!encodedPath) return null;
|
|
1128
|
+
try {
|
|
1129
|
+
const path = decodeURIComponent(encodedPath);
|
|
1130
|
+
return path && !CONTROL_CHARACTER.test(path) ? { path, line } : null;
|
|
1131
|
+
} catch {
|
|
1132
|
+
return null;
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
function sandboxFilePathFromHref(href) {
|
|
1136
|
+
return sandboxFileLocationFromHref(href)?.path ?? null;
|
|
1137
|
+
}
|
|
1138
|
+
function retainedImageId(src) {
|
|
1139
|
+
return /^artifact:([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i.exec(src)?.[1]?.toLowerCase() ?? null;
|
|
1140
|
+
}
|
|
1141
|
+
function MarkdownImage({ src, alt }) {
|
|
1142
|
+
const { renderImage } = useContext3(InteractiveContext);
|
|
1143
|
+
if (!src) return /* @__PURE__ */ jsx5("span", { children: alt ?? "Image unavailable" });
|
|
1144
|
+
if (retainedImageId(src))
|
|
1145
|
+
return renderImage ? /* @__PURE__ */ jsx5(Fragment2, { children: renderImage({ src, alt: alt ?? "" }) }) : /* @__PURE__ */ jsxs4("span", { children: [
|
|
1146
|
+
alt || "Image",
|
|
1147
|
+
" (preview unavailable)"
|
|
1148
|
+
] });
|
|
1149
|
+
return /* @__PURE__ */ jsx5("img", { src, alt: alt ?? "", loading: "lazy", className: "my-3 max-w-full rounded-og-md" });
|
|
1150
|
+
}
|
|
1151
|
+
var markdownUrlTransform = (url, key, node) => key === "href" && node.tagName === "a" && isSandboxHref(url) || key === "src" && node.tagName === "img" && retainedImageId(url) ? url : defaultUrlTransform(url);
|
|
1152
|
+
var REVEAL_LINGER_MS = 480 * MOTION_INSPECT_SCALE;
|
|
1153
|
+
var MARKDOWN_SETTLE_MS = 480 * MOTION_INSPECT_SCALE;
|
|
1154
|
+
function nodeText(node) {
|
|
1155
|
+
if (node == null || typeof node === "boolean") {
|
|
1156
|
+
return "";
|
|
1157
|
+
}
|
|
1158
|
+
if (typeof node === "string" || typeof node === "number") {
|
|
1159
|
+
return String(node);
|
|
1160
|
+
}
|
|
1161
|
+
if (Array.isArray(node)) {
|
|
1162
|
+
return node.map(nodeText).join("");
|
|
1163
|
+
}
|
|
1164
|
+
if (isValidElement(node)) {
|
|
1165
|
+
return nodeText(node.props.children);
|
|
1166
|
+
}
|
|
1167
|
+
return "";
|
|
1168
|
+
}
|
|
1169
|
+
function fenceLanguage(children) {
|
|
1170
|
+
let found = null;
|
|
1171
|
+
Children.forEach(children, (child) => {
|
|
1172
|
+
if (found || !isValidElement(child)) {
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
const match = /language-([a-zA-Z0-9_+-]+)/.exec(child.props.className ?? "");
|
|
1176
|
+
if (match?.[1]) {
|
|
1177
|
+
found = match[1];
|
|
1178
|
+
}
|
|
1179
|
+
});
|
|
1180
|
+
return found;
|
|
1181
|
+
}
|
|
1182
|
+
function InteractiveCodeBlock({ children, node }) {
|
|
1183
|
+
const { source, render, streaming } = useContext3(InteractiveContext);
|
|
1184
|
+
const language = fenceLanguage(children);
|
|
1185
|
+
if (render && (language === "opengeni-html" || language === "opengeni-site")) {
|
|
1186
|
+
const start = node?.position?.start.offset;
|
|
1187
|
+
const end = node?.position?.end.offset;
|
|
1188
|
+
const original = start !== void 0 && end !== void 0 && end <= source.length ? source.slice(start, end) : "";
|
|
1189
|
+
const lines = original.trimEnd().split("\n");
|
|
1190
|
+
const opening = lines[0]?.match(/^ {0,3}([\x60]{3,}|~{3,})/);
|
|
1191
|
+
const closing = lines.at(-1)?.replace(/^\s*(?:>\s*)+/, "").trim();
|
|
1192
|
+
const complete = opening && lines.length > 1 && closing && closing.length >= opening[1].length && [...closing].every((c) => c === opening[1][0]);
|
|
1193
|
+
if (!complete) {
|
|
1194
|
+
return /* @__PURE__ */ jsx5("div", { role: "status", "aria-live": "polite", "aria-busy": streaming === true, className: "my-3", children: streaming ? /* @__PURE__ */ jsx5(PreviewLoading, {}) : /* @__PURE__ */ jsx5(
|
|
1195
|
+
ActivityDisclosure,
|
|
1196
|
+
{
|
|
1197
|
+
icon: /* @__PURE__ */ jsx5(PanelsTopLeftIcon, { "aria-hidden": true, className: "size-3.5" }),
|
|
1198
|
+
title: "Preview incomplete",
|
|
1199
|
+
running: false,
|
|
1200
|
+
expandable: false,
|
|
1201
|
+
preview: "Generation stopped before the preview was ready."
|
|
1202
|
+
}
|
|
1203
|
+
) });
|
|
1204
|
+
}
|
|
1205
|
+
return /* @__PURE__ */ jsx5(Fragment2, { children: render({
|
|
1206
|
+
kind: language === "opengeni-html" ? "html" : "site",
|
|
1207
|
+
content: nodeText(children).replace(/\n$/, "")
|
|
1208
|
+
}) });
|
|
1209
|
+
}
|
|
1210
|
+
return /* @__PURE__ */ jsx5(MarkdownCodeBlock, { children });
|
|
1211
|
+
}
|
|
1212
|
+
function MarkdownCodeBlock({ children }) {
|
|
1213
|
+
const code = nodeText(children).replace(/\n$/, "");
|
|
1214
|
+
const language = fenceLanguage(children);
|
|
1215
|
+
return /* @__PURE__ */ jsxs4("div", { className: "group/copy relative mt-3 first:mt-0", children: [
|
|
1216
|
+
/* @__PURE__ */ jsxs4("div", { className: "pointer-events-none absolute top-1.5 right-1.5 z-10 flex items-center gap-1", children: [
|
|
1217
|
+
language ? /* @__PURE__ */ jsx5("span", { className: "rounded px-1 py-0.5 font-og-mono text-[10px] uppercase tracking-wide text-og-fg-subtle/80 opacity-0 transition-opacity group-hover/copy:opacity-100 pointer-coarse:opacity-70", children: language }) : null,
|
|
1218
|
+
/* @__PURE__ */ jsx5("div", { className: "pointer-events-auto", children: /* @__PURE__ */ jsx5(CopyButton, { text: code, label: "Copy code", reveal: "group-hover" }) })
|
|
1219
|
+
] }),
|
|
1220
|
+
/* @__PURE__ */ jsx5(
|
|
1221
|
+
"pre",
|
|
1222
|
+
{
|
|
1223
|
+
tabIndex: 0,
|
|
1224
|
+
className: "overflow-x-auto overflow-y-hidden rounded-og-md bg-og-surface-1/70 px-3 py-2.5 font-og-mono text-og-sm leading-5 text-og-fg-muted [scrollbar-gutter:stable] [&>code]:block [&>code]:border-0 [&>code]:bg-transparent [&>code]:p-0 [&>code]:leading-5 [&>code]:text-inherit",
|
|
1225
|
+
children
|
|
1226
|
+
}
|
|
1227
|
+
)
|
|
1228
|
+
] });
|
|
1229
|
+
}
|
|
1230
|
+
function MarkdownTable({ children, className, ...props }) {
|
|
1231
|
+
const wrapperRef = useRef3(null);
|
|
1232
|
+
const tableRef = useRef3(null);
|
|
1233
|
+
const layoutRef = useRef3(void 0);
|
|
1234
|
+
useEffect3(() => {
|
|
1235
|
+
const wrapper = wrapperRef.current;
|
|
1236
|
+
const table = tableRef.current;
|
|
1237
|
+
if (!wrapper?.closest("[data-og-wide-table-message]") || !table) return;
|
|
1238
|
+
let disposed = false;
|
|
1239
|
+
void import("./markdown-table-layout-PFUEZ2U4.js").then(({ observeMarkdownTableLayout }) => {
|
|
1240
|
+
if (!disposed) layoutRef.current = observeMarkdownTableLayout(wrapper, table);
|
|
1241
|
+
}).catch(() => {
|
|
1242
|
+
});
|
|
1243
|
+
return () => {
|
|
1244
|
+
disposed = true;
|
|
1245
|
+
layoutRef.current?.disconnect();
|
|
1246
|
+
layoutRef.current = void 0;
|
|
1247
|
+
};
|
|
1248
|
+
}, []);
|
|
1249
|
+
useEffect3(() => {
|
|
1250
|
+
layoutRef.current?.measure();
|
|
1251
|
+
}, [children]);
|
|
1252
|
+
return /* @__PURE__ */ jsxs4("div", { ref: wrapperRef, className: "group/copy relative mt-3 max-w-full first:mt-0", children: [
|
|
1253
|
+
/* @__PURE__ */ jsx5("div", { className: "pointer-events-none absolute top-0 right-0 z-10", children: /* @__PURE__ */ jsx5("div", { className: "pointer-events-auto", children: /* @__PURE__ */ jsx5(
|
|
1254
|
+
CopyButton,
|
|
1255
|
+
{
|
|
1256
|
+
text: () => tableElementToTsv(tableRef.current),
|
|
1257
|
+
label: "Copy table",
|
|
1258
|
+
reveal: "group-hover"
|
|
1259
|
+
}
|
|
1260
|
+
) }) }),
|
|
1261
|
+
/* @__PURE__ */ jsx5("div", { className: "overflow-x-auto", tabIndex: 0, children: /* @__PURE__ */ jsx5(
|
|
1262
|
+
"table",
|
|
1263
|
+
{
|
|
1264
|
+
ref: tableRef,
|
|
1265
|
+
className: cn("w-full min-w-0 border-collapse text-og-base", className),
|
|
1266
|
+
...props,
|
|
1267
|
+
children
|
|
1268
|
+
}
|
|
1269
|
+
) })
|
|
1270
|
+
] });
|
|
1271
|
+
}
|
|
1272
|
+
function MarkdownImpl({
|
|
1273
|
+
children,
|
|
1274
|
+
className,
|
|
1275
|
+
streaming = false,
|
|
1276
|
+
onSandboxFile,
|
|
1277
|
+
renderInteractiveBlock,
|
|
1278
|
+
renderImage
|
|
1279
|
+
}) {
|
|
1280
|
+
const revealRef = useRef3(null);
|
|
1281
|
+
const bodyRef = useRef3(null);
|
|
1282
|
+
const [, bump] = useReducer((n) => n + 1, 0);
|
|
1283
|
+
const [settling, setSettling] = useState3(false);
|
|
1284
|
+
const hadRevealRef = useRef3(false);
|
|
1285
|
+
const now = typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
1286
|
+
const crystallize = (mutate) => {
|
|
1287
|
+
mutate();
|
|
1288
|
+
setSettling(true);
|
|
1289
|
+
bump();
|
|
1290
|
+
return setTimeout(() => setSettling(false), MARKDOWN_SETTLE_MS);
|
|
1291
|
+
};
|
|
1292
|
+
if (streaming && revealRef.current === null && !prefersReducedMotion()) {
|
|
1293
|
+
revealRef.current = createStreamReveal();
|
|
1294
|
+
}
|
|
1295
|
+
const reveal = revealRef.current;
|
|
1296
|
+
if (reveal !== null && streaming) {
|
|
1297
|
+
reveal.observe(children, now);
|
|
1298
|
+
}
|
|
1299
|
+
if (reveal !== null) {
|
|
1300
|
+
hadRevealRef.current = true;
|
|
1301
|
+
}
|
|
1302
|
+
const revealActive = reveal !== null && (streaming || reveal.hasActive(now));
|
|
1303
|
+
const rehypePlugins = revealActive && reveal !== null ? [[rehypeStreamReveal, { reveal, now }]] : void 0;
|
|
1304
|
+
useEffect3(() => {
|
|
1305
|
+
if (streaming || revealRef.current === null) {
|
|
1306
|
+
return;
|
|
1307
|
+
}
|
|
1308
|
+
let clearSettle;
|
|
1309
|
+
const timer = setTimeout(() => {
|
|
1310
|
+
const shouldSettle = hadRevealRef.current && !prefersReducedMotion();
|
|
1311
|
+
if (shouldSettle) {
|
|
1312
|
+
hadRevealRef.current = false;
|
|
1313
|
+
}
|
|
1314
|
+
if (shouldSettle) {
|
|
1315
|
+
clearSettle = crystallize(() => {
|
|
1316
|
+
revealRef.current = null;
|
|
1317
|
+
});
|
|
1318
|
+
} else {
|
|
1319
|
+
revealRef.current = null;
|
|
1320
|
+
bump();
|
|
1321
|
+
}
|
|
1322
|
+
}, REVEAL_LINGER_MS);
|
|
1323
|
+
return () => {
|
|
1324
|
+
clearTimeout(timer);
|
|
1325
|
+
if (clearSettle !== void 0) {
|
|
1326
|
+
clearTimeout(clearSettle);
|
|
1327
|
+
}
|
|
1328
|
+
};
|
|
1329
|
+
}, [streaming]);
|
|
1330
|
+
const wasStreamingRef = useRef3(streaming);
|
|
1331
|
+
useEffect3(() => {
|
|
1332
|
+
const ended = wasStreamingRef.current && !streaming;
|
|
1333
|
+
wasStreamingRef.current = streaming;
|
|
1334
|
+
if (!ended || revealRef.current !== null || prefersReducedMotion()) {
|
|
1335
|
+
return;
|
|
1336
|
+
}
|
|
1337
|
+
setSettling(true);
|
|
1338
|
+
const timer = setTimeout(() => setSettling(false), MARKDOWN_SETTLE_MS);
|
|
1339
|
+
return () => clearTimeout(timer);
|
|
1340
|
+
}, [streaming]);
|
|
1341
|
+
const parseText = streaming || revealActive ? softenStreamingMarkdown(children) : children;
|
|
1342
|
+
const components = useMemo(() => markdownComponents(onSandboxFile), [onSandboxFile]);
|
|
1343
|
+
const interactiveContext = useMemo(
|
|
1344
|
+
() => ({
|
|
1345
|
+
source: children,
|
|
1346
|
+
streaming,
|
|
1347
|
+
...renderInteractiveBlock ? { render: renderInteractiveBlock } : {},
|
|
1348
|
+
...renderImage ? { renderImage } : {}
|
|
1349
|
+
}),
|
|
1350
|
+
[children, streaming, renderInteractiveBlock, renderImage]
|
|
1351
|
+
);
|
|
1352
|
+
return /* @__PURE__ */ jsx5(InteractiveContext.Provider, { value: interactiveContext, children: /* @__PURE__ */ jsx5(TooltipProvider, { delayDuration: 400, children: /* @__PURE__ */ jsx5(
|
|
1353
|
+
"div",
|
|
1354
|
+
{
|
|
1355
|
+
ref: bodyRef,
|
|
1356
|
+
className: cn(
|
|
1357
|
+
"og-markdown-body min-w-0 break-words",
|
|
1358
|
+
settling && "og-markdown-settle",
|
|
1359
|
+
className
|
|
1360
|
+
),
|
|
1361
|
+
children: /* @__PURE__ */ jsx5(
|
|
1362
|
+
ReactMarkdown,
|
|
1363
|
+
{
|
|
1364
|
+
remarkPlugins: [remarkGfm],
|
|
1365
|
+
rehypePlugins,
|
|
1366
|
+
components,
|
|
1367
|
+
urlTransform: markdownUrlTransform,
|
|
1368
|
+
children: parseText
|
|
1369
|
+
}
|
|
1370
|
+
)
|
|
1371
|
+
}
|
|
1372
|
+
) }) });
|
|
1373
|
+
}
|
|
1374
|
+
var Markdown = memo(MarkdownImpl);
|
|
1375
|
+
|
|
1376
|
+
export {
|
|
1377
|
+
DisclosureDefaultsProvider,
|
|
1378
|
+
useForcedDefaultOpen,
|
|
1379
|
+
ToolCallTruncationProvider,
|
|
1380
|
+
CompactActivityContext,
|
|
1381
|
+
ActivityDisclosure,
|
|
1382
|
+
TermBlock,
|
|
1383
|
+
PayloadBlock,
|
|
1384
|
+
BodyNote,
|
|
1385
|
+
MediaSkeleton,
|
|
1386
|
+
MediaEmpty,
|
|
1387
|
+
Thumbnail,
|
|
1388
|
+
ScreenshotFigure,
|
|
1389
|
+
prefersReducedMotion,
|
|
1390
|
+
MOTION_INSPECT_SCALE,
|
|
1391
|
+
CopyButton,
|
|
1392
|
+
CopyHoverFrame,
|
|
1393
|
+
sandboxFileLocationFromHref,
|
|
1394
|
+
sandboxFilePathFromHref,
|
|
1395
|
+
retainedImageId,
|
|
1396
|
+
Markdown
|
|
1397
|
+
};
|
|
1398
|
+
//# sourceMappingURL=chunk-AWEBVNVX.js.map
|