wizards 0.3.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/apps/runtime/dist/agents/studio-assistant.js +285 -31
  2. package/apps/runtime/dist/agents/website.js +256 -34
  3. package/apps/runtime/dist/db/schema.js +1 -1
  4. package/apps/runtime/dist/documents/parse.js +14 -0
  5. package/apps/runtime/dist/engine/steps.js +42 -6
  6. package/apps/runtime/dist/engine/template.js +50 -3
  7. package/apps/runtime/dist/film/project.js +54 -4
  8. package/apps/runtime/dist/routes/studio.js +37 -1
  9. package/apps/runtime/dist/services/brand.js +6 -3
  10. package/apps/runtime/dist/services/project-files.js +59 -3
  11. package/apps/runtime/dist/services/projects.js +150 -2
  12. package/apps/web/dist/assets/AboutDialog-C0dN86zd.js +1 -0
  13. package/apps/web/dist/assets/{ChangelogDialog-m2M7gZiB.js → ChangelogDialog-Cv81t7tj.js} +1 -1
  14. package/apps/web/dist/assets/ChatView-uogJ3nht.js +10 -0
  15. package/apps/web/dist/assets/EditorPage-n8YuTh6j.js +3 -0
  16. package/apps/web/dist/assets/{FlowPreview-BdRy7FO7.js → FlowPreview-D4dp1MWS.js} +1 -1
  17. package/apps/web/dist/assets/{Harness-DmJkTwOO.js → Harness-v7r0e6vK.js} +2 -2
  18. package/apps/web/dist/assets/NewWizardChannels-Be-7VhBi.js +1 -0
  19. package/apps/web/dist/assets/NewWizardPage-C8hPvrK8.js +7 -0
  20. package/apps/web/dist/assets/ProjectPage-B686ArYy.js +1 -0
  21. package/apps/web/dist/assets/PublicRunner-DeCpVfZP.js +1 -0
  22. package/apps/web/dist/assets/{ReadOnly-CaGzgOPe.js → ReadOnly-B-UCgnqW.js} +1 -1
  23. package/apps/web/dist/assets/RunDrawer-C6pzi8AJ.js +4 -0
  24. package/apps/web/dist/assets/{RunnerView-CJ4cLA_0.js → RunnerView-Deenymq0.js} +1 -1
  25. package/apps/web/dist/assets/SettingsPage-CK6L0yEe.js +1 -0
  26. package/apps/web/dist/assets/SetupPage-9CH3qXdH.js +1 -0
  27. package/apps/web/dist/assets/SharePage-B778xUFo.js +1 -0
  28. package/apps/web/dist/assets/changelog-DCJo2mbx.js +1 -0
  29. package/apps/web/dist/assets/{circle-alert-CpuMIhbH.js → circle-alert-DLvC9ePT.js} +1 -1
  30. package/apps/web/dist/assets/{esm-DRaZAcXQ.js → esm-BJskogLD.js} +1 -1
  31. package/apps/web/dist/assets/index-D6hUM8NU.css +1 -0
  32. package/apps/web/dist/assets/index-Df6UxElH.js +12 -0
  33. package/apps/web/dist/assets/{lock-BGotwAyN.js → lock-DR7NakPn.js} +1 -1
  34. package/apps/web/dist/assets/{phone-CA2A8W7I.js → phone-BORh3jfv.js} +1 -1
  35. package/apps/web/dist/assets/{settings-menu-DxswVOqQ.js → settings-menu-DV5D91TD.js} +1 -1
  36. package/apps/web/dist/assets/{ui-DAHMnAVc.js → ui-BOCXzzHi.js} +1 -1
  37. package/apps/web/dist/assets/{upload-DLbJVvfd.js → upload-B3yv8gsk.js} +1 -1
  38. package/apps/web/dist/index.html +3 -8
  39. package/apps/web/dist/mcp/flow.html +2 -2
  40. package/node_modules/@engenty-wizards/plugin-sdk/dist/index.d.ts +3 -3
  41. package/node_modules/@engenty-wizards/shared/dist/projects.d.ts +138 -3
  42. package/node_modules/@engenty-wizards/shared/dist/projects.js +153 -4
  43. package/package.json +1 -1
  44. package/apps/web/dist/assets/AboutDialog-Dz_tYBSU.js +0 -1
  45. package/apps/web/dist/assets/ChatView-D21o-lq8.js +0 -10
  46. package/apps/web/dist/assets/EditorPage-D6j3dQpu.js +0 -3
  47. package/apps/web/dist/assets/Marketplace-B-gy2onK.js +0 -2
  48. package/apps/web/dist/assets/NewWizardChannels-B3FEpsJ-.js +0 -1
  49. package/apps/web/dist/assets/NewWizardPage-CT1lThNM.js +0 -7
  50. package/apps/web/dist/assets/ProjectPage-BIanCF0m.js +0 -2
  51. package/apps/web/dist/assets/PublicRunner-H1fXa9BK.js +0 -1
  52. package/apps/web/dist/assets/RunDrawer-8sjkAbm5.js +0 -4
  53. package/apps/web/dist/assets/SettingsPage-BsdwE1OA.js +0 -1
  54. package/apps/web/dist/assets/SetupPage-sqrv7Auf.js +0 -1
  55. package/apps/web/dist/assets/SharePage-B6ets1ot.js +0 -1
  56. package/apps/web/dist/assets/brand-BRw18WJF.js +0 -2
  57. package/apps/web/dist/assets/changelog-BOFdRjx2.js +0 -1
  58. package/apps/web/dist/assets/index-DY9CslcT.css +0 -1
  59. package/apps/web/dist/assets/index-DkDBEMwz.js +0 -11
  60. package/apps/web/dist/assets/session-DBOQL_bg.js +0 -1
  61. package/apps/web/dist/assets/useMutation-DKyQXgyj.js +0 -1
  62. package/apps/web/dist/assets/volume-2-KaKQ4zMJ.js +0 -1
@@ -13,6 +13,7 @@ import { nanoid } from "nanoid";
13
13
  import { z } from "zod";
14
14
  import { runStudioAssistant } from "../agents/studio-assistant.js";
15
15
  import { chatEngine, setChatEngine, subscriptionClients } from "../agents/subscription.js";
16
+ import { scanColors, scanFonts, scanImages, scanLogos } from "../agents/website.js";
16
17
  import { answerBrowser, awaitBrowser } from "../assistant/browser.js";
17
18
  import { accountOverview, linkedAccount, startLink, unlink } from "../auth/account.js";
18
19
  import { createLocalKey, deleteLocalKey, listLocalKeys } from "../auth/keys.js";
@@ -45,7 +46,7 @@ import { categoryContents, listKnowledge, resolvePath, valueContents, } from "..
45
46
  import { writeSummary } from "../services/knowledge-model.js";
46
47
  import { exportWizard, importWizard } from "../services/package.js";
47
48
  import { profileSchema, saveProfile, userProfile } from "../services/profile.js";
48
- import { addProjectFile, fileView, orderProjectFiles, projectFile, projectFileContent, projectFiles, reindexProjectFile, removeProjectFile, updateProjectFile, } from "../services/project-files.js";
49
+ import { addProjectFile, addProjectFileFromUrl, fileView, orderProjectFiles, projectFile, projectFileContent, projectFiles, reindexProjectFile, removeProjectFile, updateProjectFile, } from "../services/project-files.js";
49
50
  import { documentText, queueIndex, searchKnowledge } from "../services/project-index.js";
50
51
  import { createProject, deleteProject, listProjects, maskedServers, ownedProject, projectLimitOrNull, projectPatchSchema, updateProject, } from "../services/projects.js";
51
52
  import { runnersOf, wizardRunners } from "../services/runners.js";
@@ -452,6 +453,41 @@ export const studio = new Hono()
452
453
  data: new Uint8Array(await file.arrayBuffer()),
453
454
  });
454
455
  return c.json(fileView(row));
456
+ })
457
+ .post("/projects/:id/files/url", async (c) => {
458
+ const project = await ownedProject(c.get("user").id, c.req.param("id"));
459
+ const input = z
460
+ .object({ url: z.string().min(1).max(500_000), kind: z.enum(PROJECT_FILE_KINDS) })
461
+ .parse(await c.req.json());
462
+ const url = /^(https?:\/\/|data:)/i.test(input.url) ? input.url : `https://${input.url}`;
463
+ try {
464
+ return c.json({ file: fileView(await addProjectFileFromUrl(project.id, { ...input, url })) });
465
+ }
466
+ catch (err) {
467
+ // A web page where a logo or an asset was asked for: its logos or pictures, to pick from.
468
+ if (err instanceof ServiceError && err.data.reason === "page") {
469
+ const page = String(err.data.url ?? url);
470
+ const scan = input.kind === "logo" ? scanLogos : scanImages;
471
+ return c.json({ candidates: await scan(page) });
472
+ }
473
+ throw err;
474
+ }
475
+ })
476
+ .post("/projects/:id/colors/scan", async (c) => {
477
+ await ownedProject(c.get("user").id, c.req.param("id"));
478
+ const { url } = z.object({ url: z.string().min(1).max(2000) }).parse(await c.req.json());
479
+ const colors = await scanColors(url).catch(() => {
480
+ throw new ServiceError("invalid", "Die Seite ist nicht erreichbar.");
481
+ });
482
+ return c.json({ colors });
483
+ })
484
+ .post("/projects/:id/fonts/scan", async (c) => {
485
+ await ownedProject(c.get("user").id, c.req.param("id"));
486
+ const { url } = z.object({ url: z.string().min(1).max(2000) }).parse(await c.req.json());
487
+ const fonts = await scanFonts(url).catch(() => {
488
+ throw new ServiceError("invalid", "Die Seite ist nicht erreichbar.");
489
+ });
490
+ return c.json({ fonts });
455
491
  })
456
492
  .put("/projects/:id/files/order", async (c) => {
457
493
  const project = await ownedProject(c.get("user").id, c.req.param("id"));
@@ -1,12 +1,15 @@
1
+ import { mainLogo } from "@engenty-wizards/shared/projects";
1
2
  import { and, asc, eq } from "drizzle-orm";
2
3
  import { db, schema } from "../db/client.js";
3
- /** The project's first logo: the one end users, documents and widgets get. */
4
+ /** The project's main logo, the first standard one: what end users, documents and widgets get. */
4
5
  export async function mainLogoId(projectId) {
5
- const logo = await db.query.projectFile.findFirst({
6
+ const p = await db.query.project.findFirst({ where: eq(schema.project.id, projectId) });
7
+ const logos = await db.query.projectFile.findMany({
8
+ columns: { id: true },
6
9
  where: and(eq(schema.projectFile.projectId, projectId), eq(schema.projectFile.kind, "logo")),
7
10
  orderBy: [asc(schema.projectFile.position), asc(schema.projectFile.createdAt)],
8
11
  });
9
- return logo?.id ?? null;
12
+ return mainLogo(logos, p?.brand.logoSections)?.id ?? null;
10
13
  }
11
14
  /** What end users see of the project: its title, accent and logo — never the project name. */
12
15
  export async function brandView(projectId) {
@@ -7,6 +7,7 @@ import { loadAsset, removeAsset, replaceAsset, saveAsset } from "../files/storag
7
7
  import { embeddingModel, textModel } from "../models.js";
8
8
  import { spaceFileChanged } from "../plugins/events.js";
9
9
  import { dropLinks, putLink } from "../tenants/control.js";
10
+ import { safeFetch } from "../tools/net-guard.js";
10
11
  import { requireWritableProject } from "./access.js";
11
12
  import { notFound, ServiceError } from "./errors.js";
12
13
  import { convertDocument, fillCategories } from "./knowledge-model.js";
@@ -58,12 +59,17 @@ export async function projectFileContent(projectId, fileId) {
58
59
  }
59
60
  return { row, data: found.data };
60
61
  }
62
+ /**
63
+ * Assets are what wizards put into what they make: pictures, clips, recordings, and files to
64
+ * hand on as they are — PDFs, fonts, Lottie animations (JSON), 3D models.
65
+ */
66
+ const ASSET_TYPES = /^((image|video|audio|font)\/|application\/(pdf|json)$|model\/gltf)/;
61
67
  function accepts(kind, mime) {
62
- if (kind === "logo") {
68
+ if (kind === "logo" || kind === "pattern") {
63
69
  return mime.startsWith("image/");
64
70
  }
65
71
  if (kind === "asset") {
66
- return /^(image|video|audio)\//.test(mime);
72
+ return ASSET_TYPES.test(mime);
67
73
  }
68
74
  return true;
69
75
  }
@@ -73,7 +79,9 @@ export async function addProjectFile(projectId, input) {
73
79
  if (!accepts(input.kind, mime)) {
74
80
  throw new ServiceError("invalid", input.kind === "logo"
75
81
  ? "Ein Logo ist ein Bild (PNG, SVG, JPEG, WebP)."
76
- : "Hierher gehören Bilder, Grafiken, Videos und Audio. Anderes bitte zu den Dokumenten.");
82
+ : input.kind === "pattern"
83
+ ? "Ein Muster ist ein Bild (SVG, PNG, JPEG, WebP)."
84
+ : "Hierher gehören Bilder, Videos, Audio, PDFs, Schriften, Lottie und 3D-Modelle. Texte zum Nachschlagen bitte zu den Dokumenten.");
77
85
  }
78
86
  const limit = projectFileLimit(input.kind, mime);
79
87
  if (!input.data.byteLength || input.data.byteLength > limit) {
@@ -120,6 +128,54 @@ export async function addProjectFile(projectId, input) {
120
128
  }
121
129
  return row;
122
130
  }
131
+ /**
132
+ * Fetches a file from a public web address into the project, as an upload of it would add it.
133
+ * A drawing a page holds inline comes as a `data:image/svg+xml` address. A web page where a
134
+ * picture was asked for is refused with the reason `page`.
135
+ */
136
+ export async function addProjectFileFromUrl(projectId, input) {
137
+ const { url, kind, signal } = input;
138
+ const inline = url.match(/^data:image\/svg\+xml;base64,([A-Za-z0-9+/=]+)$/);
139
+ if (inline) {
140
+ return addProjectFile(projectId, {
141
+ kind,
142
+ name: `${kind}.svg`,
143
+ mime: "image/svg+xml",
144
+ data: new Uint8Array(Buffer.from(inline[1], "base64")),
145
+ description: input.description,
146
+ });
147
+ }
148
+ const res = await safeFetch(url, {
149
+ headers: { "user-agent": "Mozilla/5.0 (compatible; engenty-wizards/0.1)" },
150
+ signal: AbortSignal.any([AbortSignal.timeout(60_000), ...(signal ? [signal] : [])]),
151
+ }).catch(() => {
152
+ throw new ServiceError("invalid", "Die Adresse ist nicht erreichbar.");
153
+ });
154
+ if (!res.ok) {
155
+ throw new ServiceError("invalid", `Die Adresse antwortete ${res.status}.`);
156
+ }
157
+ const mime = (res.headers.get("content-type") ?? "").split(";")[0].trim().toLowerCase();
158
+ if (mime === "text/html" && kind !== "document") {
159
+ await res.body?.cancel();
160
+ throw new ServiceError("invalid", "Unter der Adresse steht eine Webseite, kein Bild.", {
161
+ reason: "page",
162
+ url: res.url,
163
+ });
164
+ }
165
+ if (Number(res.headers.get("content-length") ?? 0) > projectFileLimit(kind, mime)) {
166
+ throw new ServiceError("invalid", "Die Datei ist zu groß.");
167
+ }
168
+ const data = new Uint8Array(await res.arrayBuffer());
169
+ const name = decodeURIComponent(new URL(res.url).pathname.split("/").pop() || kind);
170
+ return addProjectFile(projectId, {
171
+ kind,
172
+ name,
173
+ mime,
174
+ data,
175
+ description: input.description,
176
+ source: res.url,
177
+ });
178
+ }
123
179
  // --- reading, describing, indexing -------------------------------------------------
124
180
  /** Files are worked through two at a time: each costs model calls. */
125
181
  let running = 0;
@@ -1,4 +1,4 @@
1
- import { FACT_TYPES, PROJECT_LIMITS } from "@engenty-wizards/shared/projects";
1
+ import { COLOR_SECTION_KINDS, cleanAssetSections, cleanLogoSections, FACT_TYPES, FONT_WEIGHTS, GRADIENT_TYPES, orderColors, PROJECT_LIMITS, RULE_MARKS, } from "@engenty-wizards/shared/projects";
2
2
  import { and, count, eq, isNull } from "drizzle-orm";
3
3
  import { nanoid } from "nanoid";
4
4
  import { z } from "zod";
@@ -18,9 +18,66 @@ export const mcpServerSchema = z.object({
18
18
  url: z.string().url(),
19
19
  headers: z.record(z.string(), z.string()).optional(),
20
20
  });
21
+ const sectionId = z.string().regex(/^[A-Za-z0-9_-]{1,40}$/);
21
22
  export const brandColorSchema = z.object({
22
23
  name: z.string().max(120),
23
24
  value: z.string().regex(/^#[0-9a-fA-F]{6}$/),
25
+ section: sectionId.optional(),
26
+ });
27
+ export const colorSectionSchema = z.object({
28
+ id: sectionId,
29
+ title: z.string().max(80),
30
+ description: z.string().max(400),
31
+ kind: z.enum(COLOR_SECTION_KINDS).optional(),
32
+ });
33
+ const hexColor = z.string().regex(/^#[0-9a-fA-F]{6}$/);
34
+ export const gradientSchema = z.object({
35
+ id: sectionId,
36
+ name: z.string().max(80),
37
+ section: sectionId,
38
+ type: z.enum(GRADIENT_TYPES),
39
+ angle: z.number().min(-360).max(720),
40
+ stops: z
41
+ .array(z.object({ color: hexColor, at: z.number().min(0).max(100) }))
42
+ .min(2)
43
+ .max(12),
44
+ });
45
+ export const patternSchema = z.object({
46
+ id: sectionId,
47
+ name: z.string().max(80),
48
+ section: sectionId,
49
+ file: z.string().max(40),
50
+ tile: z.boolean().optional(),
51
+ });
52
+ const rulesSchema = z
53
+ .array(z.object({ text: z.string().max(200), mark: z.enum(RULE_MARKS).optional() }))
54
+ .max(PROJECT_LIMITS.logoRules);
55
+ export const brandFontSchema = z.object({
56
+ id: sectionId,
57
+ family: z.string().max(80),
58
+ role: z.string().max(200),
59
+ weights: z.array(z.number().int().min(100).max(900)).max(FONT_WEIGHTS.length + 3),
60
+ });
61
+ export const textStyleSchema = z.object({
62
+ id: sectionId,
63
+ name: z.string().max(60),
64
+ font: sectionId.optional(),
65
+ size: z.number().min(6).max(400),
66
+ weight: z.number().int().min(100).max(900),
67
+ lineHeight: z.number().min(50).max(300),
68
+ tracking: z.number().min(-20).max(50),
69
+ uppercase: z.boolean().optional(),
70
+ });
71
+ export const assetSectionSchema = z.object({
72
+ id: sectionId,
73
+ title: z.string().max(80),
74
+ assets: z.array(z.string().max(40)).max(PROJECT_LIMITS.files.asset),
75
+ });
76
+ export const logoSectionSchema = z.object({
77
+ id: sectionId,
78
+ title: z.string().max(80),
79
+ description: z.string().max(400),
80
+ logos: z.array(z.string().max(40)).max(PROJECT_LIMITS.files.logo),
24
81
  });
25
82
  export const projectFactSchema = z.object({
26
83
  key: z.string().regex(/^[a-z0-9_]{1,40}$/),
@@ -35,6 +92,16 @@ export const projectPatchSchema = z.object({
35
92
  name: z.string().max(120).optional(),
36
93
  about: z.string().max(8000).optional(),
37
94
  colors: z.array(brandColorSchema).max(PROJECT_LIMITS.colors).optional(),
95
+ colorSections: z.array(colorSectionSchema).max(PROJECT_LIMITS.logoSections).optional(),
96
+ gradients: z.array(gradientSchema).max(PROJECT_LIMITS.gradients).optional(),
97
+ patterns: z.array(patternSchema).max(PROJECT_LIMITS.files.pattern).optional(),
98
+ colorRules: rulesSchema.optional(),
99
+ assetSections: z.array(assetSectionSchema).max(PROJECT_LIMITS.logoSections).optional(),
100
+ fonts: z.array(brandFontSchema).max(PROJECT_LIMITS.fonts).optional(),
101
+ textStyles: z.array(textStyleSchema).max(PROJECT_LIMITS.textStyles).optional(),
102
+ typeRules: rulesSchema.optional(),
103
+ logoSections: z.array(logoSectionSchema).max(PROJECT_LIMITS.logoSections).optional(),
104
+ logoRules: rulesSchema.optional(),
38
105
  })
39
106
  .optional(),
40
107
  facts: z.array(projectFactSchema).max(PROJECT_LIMITS.facts).optional(),
@@ -182,7 +249,7 @@ export async function updateProject(userId, projectId, patch) {
182
249
  .update(schema.project)
183
250
  .set({
184
251
  ...(patch.name ? { name: patch.name } : {}),
185
- ...(patch.brand ? { brand: { ...p.brand, ...patch.brand } } : {}),
252
+ ...(patch.brand ? { brand: brandAfter(p.brand, patch.brand) } : {}),
186
253
  ...(patch.facts ? { facts: patch.facts } : {}),
187
254
  ...(mcpServers ? { mcpServers } : {}),
188
255
  updatedAt: new Date(),
@@ -190,11 +257,92 @@ export async function updateProject(userId, projectId, patch) {
190
257
  .where(eq(schema.project.id, p.id));
191
258
  spaceChanged("space.updated", p.id);
192
259
  }
260
+ /**
261
+ * The brand with the patch on it. Sections and rules are optional: a section without title and
262
+ * logos and rules without words are not kept.
263
+ */
264
+ function brandAfter(brand, patch) {
265
+ const { logoSections, logoRules, colors, colorSections, colorRules, gradients, patterns, assetSections, fonts, textStyles, typeRules, ...rest } = {
266
+ ...brand,
267
+ ...patch,
268
+ };
269
+ // A rule is its words and its sign; a bullet is the sign of none.
270
+ const rows = (list) => (list ?? [])
271
+ .map(({ text, mark }) => ({
272
+ text: text.trim(),
273
+ ...(mark && mark !== "bullet" ? { mark } : {}),
274
+ }))
275
+ .filter((r) => r.text);
276
+ const used = new Set([...(colors ?? []), ...(gradients ?? []), ...(patterns ?? [])].map((c) => c.section));
277
+ const colorGroups = (colorSections ?? [])
278
+ .map((s) => ({
279
+ ...s,
280
+ title: s.title.trim(),
281
+ description: s.description.trim(),
282
+ ...(s.kind && s.kind !== "colors" ? { kind: s.kind } : { kind: undefined }),
283
+ }))
284
+ .filter((s) => s.title || used.has(s.id));
285
+ // A gradient or a pattern lives in a section of its kind; colours only in colour sections.
286
+ const kindOf = (id) => colorGroups.find((s) => s.id === id)?.kind ?? "colors";
287
+ const inKind = (id, kind) => colorGroups.some((s) => s.id === id && s.kind === kind);
288
+ const fills = (gradients ?? [])
289
+ .filter((g) => inKind(g.section, "gradients"))
290
+ .map((g) => ({ ...g, name: g.name.trim() }));
291
+ const tiles = (patterns ?? [])
292
+ .filter((p) => inKind(p.section, "patterns"))
293
+ .map((p) => ({ ...p, name: p.name.trim() }));
294
+ const swatches = colors?.map((c) => c.section && kindOf(c.section) !== "colors" ? { name: c.name, value: c.value } : c);
295
+ const sections = cleanLogoSections((logoSections ?? []).map((s) => ({
296
+ ...s,
297
+ title: s.title.trim(),
298
+ description: s.description.trim(),
299
+ }))).filter((s) => s.title || s.logos.length);
300
+ const assetGroups = cleanAssetSections((assetSections ?? []).map((s) => ({ ...s, title: s.title.trim() }))).filter((s) => s.title || s.assets.length);
301
+ const typefaces = (fonts ?? [])
302
+ .map((f) => ({ ...f, family: f.family.trim(), role: f.role.trim() }))
303
+ .filter((f) => f.family);
304
+ const styles = (textStyles ?? [])
305
+ .map((s) => ({
306
+ ...s,
307
+ name: s.name.trim(),
308
+ font: typefaces.some((f) => f.id === s.font) ? s.font : undefined,
309
+ }))
310
+ .filter((s) => s.name);
311
+ const typeRows = rows(typeRules);
312
+ const rules = rows(logoRules);
313
+ const colourRules = rows(colorRules);
314
+ return {
315
+ ...rest,
316
+ ...(swatches ? { colors: orderColors(swatches, colorGroups) } : {}),
317
+ ...(colorGroups.length
318
+ ? { colorSections: colorGroups.map(({ kind, ...s }) => (kind ? { ...s, kind } : s)) }
319
+ : {}),
320
+ ...(fills.length ? { gradients: fills } : {}),
321
+ ...(tiles.length ? { patterns: tiles } : {}),
322
+ ...(colourRules.length ? { colorRules: colourRules } : {}),
323
+ ...(assetGroups.length ? { assetSections: assetGroups } : {}),
324
+ ...(typefaces.length ? { fonts: typefaces } : {}),
325
+ ...(styles.length ? { textStyles: styles } : {}),
326
+ ...(typeRows.length ? { typeRules: typeRows } : {}),
327
+ ...(sections.length ? { logoSections: sections } : {}),
328
+ ...(rules.length ? { logoRules: rules } : {}),
329
+ };
330
+ }
193
331
  export function projectProfile(p) {
194
332
  return {
195
333
  name: p.brand.name ?? "",
196
334
  about: p.brand.about ?? "",
197
335
  colors: p.brand.colors ?? [],
336
+ colorSections: p.brand.colorSections ?? [],
337
+ gradients: p.brand.gradients ?? [],
338
+ patterns: p.brand.patterns ?? [],
339
+ colorRules: p.brand.colorRules ?? [],
340
+ logoSections: p.brand.logoSections ?? [],
341
+ assetSections: p.brand.assetSections ?? [],
342
+ fonts: p.brand.fonts ?? [],
343
+ textStyles: p.brand.textStyles ?? [],
344
+ typeRules: p.brand.typeRules ?? [],
345
+ logoRules: p.brand.logoRules ?? [],
198
346
  facts: p.facts.filter((f) => f.value.trim()),
199
347
  };
200
348
  }
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{t as r}from"./logo-C4V2_3Ar.js";import{t as i}from"./preload-helper-CNEI7N0N.js";import{Ct as a,Dt as o,Tt as s,Zt as c,bt as l,ft as u,ht as d,jt as f,kt as p,mt as m,nn as h,pt as g}from"./ui-BOCXzzHi.js";import{ft as _,pt as v,wt as y}from"./index-Df6UxElH.js";import{c as b,f as x}from"./settings-menu-DV5D91TD.js";import{ReleaseNotes as S,loadReleases as C,releaseDate as w,releaseLabel as T}from"./ChangelogDialog-Cv81t7tj.js";var E=e(t(),1),D=[{name:`engenty wizards`,description:{de:`KI-Wizards aus einer Beschreibung, mit einem Link geteilt.`,en:`AI wizards built from a description, shared with a link.`},homepage:`https://github.com/engenty/wizards`,license:`FSL-1.1-MIT`},{name:`engenty`,description:{de:`Konnektoren, Datentabellen, Suche und die Engenties stammen aus dem engenty-Framework.`,en:`Connectors, data tables, search and the engenties come from the engenty framework.`},homepage:`https://github.com/engenty/engenty`,license:`FSL-1.1-MIT`}],O=[{name:`Mastra`,description:{de:`Agent-Framework hinter den KI-Schritten.`,en:`Agent framework behind the AI steps.`},homepage:`https://github.com/mastra-ai/mastra`,license:`Apache-2.0`},{name:`AI SDK`,description:{de:`Modell-Aufrufe für Text, Bild, Video und Sprache.`,en:`Model calls for text, image, video and speech.`},homepage:`https://github.com/vercel/ai`,license:`Apache-2.0`},{name:`Model Context Protocol`,description:{de:`MCP-Server zum Bauen von Wizards, MCP-Client für Werkzeuge der Schritte.`,en:`MCP server for building wizards, MCP client for the steps' tools.`},homepage:`https://github.com/modelcontextprotocol/typescript-sdk`,license:`MIT`},{name:`Hono`,description:{de:`HTTP-API der Runtime.`,en:`The runtime's HTTP API.`},homepage:`https://github.com/honojs/hono`,license:`MIT`},{name:`Drizzle ORM`,description:{de:`Schema und Migrationen der Datenbanken.`,en:`Schema and migrations of the databases.`},homepage:`https://github.com/drizzle-team/drizzle-orm`,license:`Apache-2.0`},{name:`libSQL`,description:{de:`Eine Datenbank je Mandant, lokal als Datei oder bei Turso.`,en:`One database per tenant, a local file or at Turso.`},homepage:`https://github.com/tursodatabase/libsql`,license:`MIT`},{name:`Playwright`,description:{de:`Browser-Schritte sowie PDF- und PNG-Export.`,en:`Browser steps and the PDF and PNG export.`},homepage:`https://github.com/microsoft/playwright`,license:`Apache-2.0`},{name:`agentOS`,description:{de:`Sandbox für Code-Schritte ohne Docker.`,en:`Sandbox for code steps without Docker.`},homepage:`https://github.com/rivet-dev/agentos`,license:`Apache-2.0`},{name:`React`,description:{de:`UI-Bibliothek der Web-App.`,en:`UI library of the web app.`},homepage:`https://github.com/facebook/react`,license:`MIT`},{name:`Vite`,description:{de:`Build-Werkzeug der Web-App.`,en:`Build tool of the web app.`},homepage:`https://github.com/vitejs/vite`,license:`MIT`},{name:`Tailwind CSS`,description:{de:`Styling der Oberfläche.`,en:`Styling of the interface.`},homepage:`https://github.com/tailwindlabs/tailwindcss`,license:`MIT`},{name:`React Flow`,description:{de:`Das Diagramm der Schritte im Editor.`,en:`The diagram of steps in the editor.`},homepage:`https://github.com/xyflow/xyflow`,license:`MIT`},{name:`TanStack Query`,description:{de:`Server-Daten in der Web-App.`,en:`Server data in the web app.`},homepage:`https://github.com/TanStack/query`,license:`MIT`},{name:`xterm.js`,description:{de:`Das Terminal auf der Seite, in dem sich KI-Clients anmelden.`,en:`The terminal on the page where AI clients sign in.`},homepage:`https://github.com/xtermjs/xterm.js`,license:`MIT`},{name:`Lucide`,description:{de:`Icons.`,en:`Icons.`},homepage:`https://github.com/lucide-icons/lucide`,license:`ISC`},{name:`Geist & Geist Mono`,description:{de:`Schrift der Oberfläche.`,en:`Typeface of the interface.`},homepage:`https://github.com/vercel/geist-font`,license:`OFL-1.1`},{name:`Space Grotesk`,description:{de:`Schrift der Überschriften.`,en:`Typeface of the headings.`},homepage:`https://github.com/floriankarsten/space-grotesk`,license:`OFL-1.1`},{name:`git-cliff`,description:{de:`Erzeugt den Changelog aus den Commits.`,en:`Generates the changelog from the commits.`},homepage:`https://github.com/orhun/git-cliff`,license:`MIT OR Apache-2.0`}],k=e(n(),1),A=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e));function j({name:e,homepage:t,version:n,license:r,description:i}){return(0,k.jsxs)(`li`,{className:`py-2.5`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2.5 gap-y-0.5`,children:[t?(0,k.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 font-medium text-[0.875rem] text-ink underline-offset-4 hover:underline`,children:[e,(0,k.jsx)(c,{"aria-hidden":!0,className:`size-3 text-ink-4`})]}):(0,k.jsx)(`span`,{className:`font-medium text-[0.875rem] text-ink`,children:e}),n?(0,k.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:n}):null,(0,k.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:r})]}),i?(0,k.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:i}):null]})}function M({title:e,hint:t,children:n}){return(0,k.jsxs)(`section`,{className:`mt-6`,children:[(0,k.jsx)(`h3`,{className:`border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:e}),t?(0,k.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3`,children:t}):null,n]})}function N({credits:e}){return(0,k.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:e.map(e=>(0,k.jsx)(j,{name:e.name,homepage:e.homepage,license:e.license,description:e.description[o]},e.name))})}function P({label:e,packages:t}){return(0,k.jsxs)(`div`,{className:`mt-4`,children:[(0,k.jsx)(`h4`,{className:`font-medium text-[0.75rem] text-ink-3 tracking-wide`,children:e}),(0,k.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:t.map(e=>(0,k.jsx)(j,{...e},e.name))})]})}function F({active:e}){let[t,n]=(0,E.useState)(null),[r,a]=(0,E.useState)(``);(0,E.useEffect)(()=>{if(!e||t)return;let r=!1;return i(()=>import(`./oss-credits-BQQX0kvk.js`).then(e=>{r||n(e.default)}),[]),()=>{r=!0}},[e,t]),(0,E.useEffect)(()=>{e||a(``)},[e]);let o=r.trim().toLowerCase(),s=e=>o?e.filter(e=>A(o,e.name,e.license,e.description.de,e.description.en)):e,c=e=>o?e.filter(e=>A(o,e.name,e.license,e.version)):e,u=s(D),f=s(O),m=t?[{id:`shared`,label:p(`about.creditsShared`),packages:c(t.shared)},...t.groups.map(e=>({id:e.id,label:e.label,packages:c(e.packages)}))].filter(e=>e.packages.length>0):[],h=u.length===0&&f.length===0&&m.length===0;return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`p`,{className:`mb-4 text-[0.875rem] text-ink-3`,children:p(`about.creditsHint`)}),(0,k.jsx)(d,{type:`search`,value:r,placeholder:p(`about.search`),onChange:e=>a(e.target.value)}),u.length>0?(0,k.jsx)(M,{title:p(`about.creditsProduct`),children:(0,k.jsx)(N,{credits:u})}):null,f.length>0?(0,k.jsx)(M,{title:p(`about.creditsBuiltWith`),children:(0,k.jsx)(N,{credits:f})}):null,t===null?(0,k.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,k.jsx)(l,{})}):m.length>0?(0,k.jsx)(M,{title:p(`about.creditsDeps`),hint:o?void 0:p(`about.creditsDepsHint`),children:m.map(e=>(0,k.jsx)(P,{label:e.label,packages:e.packages},e.id))}):null,t!==null&&h?(0,k.jsx)(g,{children:p(`about.noMatches`)}):null]})}var I=[`new`,`earlier`,`credits`],L=e=>p(e===`new`?`about.tab.new`:e===`earlier`?`about.tab.earlier`:`about.credits`),R=e=>e===1?p(`about.change`):p(`about.changes`,{n:e});function z({open:e,onClose:t,me:n}){let i=n?.mode===`local`,{data:o,latest:c}=v(i&&e),[d,g]=(0,E.useState)(null),[D,O]=(0,E.useState)(`new`),A=x(I.indexOf(D)),j=o?.newer&&c?c:y;(0,E.useEffect)(()=>{if(!e)return;let t=!1;return g(null),C(j===`0.3.7`?void 0:j).then(e=>{t||g(e)}),()=>{t=!0}},[e,j]);let M=d?.find(e=>e.version===`v${j}`)??d?.[0]??null,N=d?.filter(e=>e!==M)??[],P=i?o?.kind??null:`cloud`;return(0,k.jsxs)(u,{open:e,onClose:t,wide:!0,height:`tall`,children:[(0,k.jsx)(`div`,{className:`-mt-2 -mr-2 sticky top-0 z-10 flex h-0 justify-end`,children:(0,k.jsx)(m,{label:p(`common.close`),onClick:t,children:(0,k.jsx)(f,{className:`size-4`})})}),(0,k.jsxs)(`div`,{className:`flex flex-col items-center pt-4 text-center`,children:[(0,k.jsx)(r,{size:96}),(0,k.jsxs)(`div`,{className:`mt-4 font-display font-semibold text-[1.5rem] tracking-tight`,children:[`engenty`,(0,k.jsx)(`span`,{className:`text-ember`,children:`.`}),(0,k.jsx)(`span`,{className:`ml-1.5 font-normal text-ink-3`,children:`wizards`})]}),(0,k.jsxs)(`div`,{className:`mt-1 text-[0.9375rem] text-ink-3 tabular-nums`,children:[p(`about.version`,{v:y}),P?` · ${p(`about.kind.${P}`)}`:``]})]}),i?(0,k.jsx)(`div`,{className:`mt-5`,children:(0,k.jsx)(_,{enabled:e})}):null,(0,k.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,k.jsx)(a,{value:D,onChange:O,options:I.map(e=>({id:e,label:L(e)})),label:p(`about.title`)})}),(0,k.jsxs)(`div`,{className:s(`mt-5`,b(A)),children:[D===`new`?d===null?(0,k.jsx)(`div`,{className:`flex justify-center py-6 text-ink-3`,children:(0,k.jsx)(l,{})}):M?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[T(M),(0,k.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:w(M)})]}),(0,k.jsx)(`div`,{className:`mt-3`,children:(0,k.jsx)(S,{release:M})})]}):(0,k.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:p(`about.changelogEmpty`)}):null,D===`earlier`?(0,k.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:N.map(e=>(0,k.jsxs)(`details`,{className:`group/r py-2`,children:[(0,k.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-baseline gap-3 text-[0.875rem] [&::-webkit-details-marker]:hidden`,children:[(0,k.jsx)(h,{className:`size-3.5 shrink-0 self-center text-ink-4 transition group-open/r:rotate-90`}),(0,k.jsx)(`span`,{className:`font-medium text-ink tabular-nums`,children:T(e)}),(0,k.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:w(e)}),(0,k.jsx)(`span`,{className:`ml-auto text-[0.8125rem] text-ink-4`,children:R(e.commits.length)})]}),(0,k.jsx)(`div`,{className:`mt-2 pl-6`,children:(0,k.jsx)(S,{release:e})})]},e.version??`unreleased`))}):null,D===`credits`?(0,k.jsx)(F,{active:!0}):null]},D)]})}export{z as AboutDialog};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{t as r}from"./preload-helper-CNEI7N0N.js";import{Tt as i,bt as a,ft as o,ht as s,kt as c,pt as l}from"./ui-DAHMnAVc.js";var u=e(t(),1),d=e(n(),1);function f(e){switch(e.group){case`Added`:return{label:`NEW`,dot:`bg-moss`};case`Fixed`:return{label:`FIXED`,dot:`bg-amber`};case`Changed`:return{label:`CHANGED`,dot:`bg-cobalt`};case`Performance`:return{label:`PERFORMANCE`,dot:`bg-ember`};case`Deploy`:return{label:`DEPLOY`,dot:`bg-ink-4`};case`Docs`:return{label:`DOCS`,dot:`bg-ink-4`};default:return{label:`OTHER`,dot:`bg-ink-4`}}}var p=e=>e.version?e.version.replace(/^v/,``):c(`about.unreleased`),m=e=>e.timestamp?new Date(e.timestamp*1e3).toISOString().slice(0,10):``,h=e=>e.charAt(0).toUpperCase()+e.slice(1);function g(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=[];for(let t of e){if(`${p(t)} ${m(t)}`.toLowerCase().includes(n)){r.push(t);continue}let e=t.commits.filter(e=>`${f(e).label} ${e.scope??``} ${e.message}`.toLowerCase().includes(n));e.length>0&&r.push({...t,commits:e})}return r}async function _(e){if(e)try{let t=await fetch(`https://raw.githubusercontent.com/engenty/engenty-wizards/v${e}/apps/web/src/about/changelog.json`,{signal:AbortSignal.timeout(5e3)});if(t.ok)return await t.json()}catch{}return(await r(async()=>{let{default:e}=await import(`./changelog-BOFdRjx2.js`);return{default:e}},[])).default}function v({release:e}){return(0,d.jsx)(`ul`,{className:`flex flex-col gap-2`,children:e.commits.map(e=>{let t=f(e);return(0,d.jsxs)(`li`,{className:`flex items-start gap-2.5 text-[0.875rem]`,children:[(0,d.jsx)(`span`,{className:i(`mt-[7px] size-1.5 shrink-0 rounded-full`,t.dot)}),(0,d.jsxs)(`span`,{className:`min-w-0 text-ink-2`,children:[(0,d.jsxs)(`span`,{className:`font-semibold text-[0.75rem] text-ink tracking-wide`,children:[t.label,e.scope?` [${e.scope}]`:``]}),` `,h(e.message),e.breaking?(0,d.jsx)(`span`,{className:`ml-1.5 rounded-full bg-rose-tint px-1.5 py-0.5 font-medium text-[0.75rem] text-rose`,children:c(`about.breaking`)}):null]})]},e.id)})})}function y({open:e,onClose:t,version:n}){let[r,i]=(0,u.useState)(null),[f,h]=(0,u.useState)(``);(0,u.useEffect)(()=>{if(!e||r)return;let t=!1;return _(n).then(e=>{t||i(e)}),()=>{t=!0}},[e,r,n]),(0,u.useEffect)(()=>{e||h(``)},[e]);let y=r?g(r,f):[];return(0,d.jsxs)(o,{open:e,onClose:t,title:c(`about.changelog`),wide:!0,height:`tall`,children:[(0,d.jsx)(`p`,{className:`-mt-3 mb-4 text-[0.875rem] text-ink-3`,children:c(`about.changelogHint`)}),r===null?(0,d.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,d.jsx)(a,{})}):r.length===0?(0,d.jsx)(l,{children:c(`about.changelogEmpty`)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(s,{type:`search`,value:f,placeholder:c(`about.search`),onChange:e=>h(e.target.value)}),y.length===0?(0,d.jsx)(l,{children:c(`about.noMatches`)}):null,y.map(e=>(0,d.jsxs)(`section`,{className:`mt-6`,children:[(0,d.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[p(e),(0,d.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:m(e)})]}),(0,d.jsx)(`div`,{className:`mt-3`,children:(0,d.jsx)(v,{release:e})})]},e.version??`unreleased`))]})]})}export{y as ChangelogDialog,v as ReleaseNotes,_ as loadReleases,m as releaseDate,p as releaseLabel};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{t as r}from"./preload-helper-CNEI7N0N.js";import{Tt as i,bt as a,ft as o,ht as s,kt as c,pt as l}from"./ui-BOCXzzHi.js";var u=e(t(),1),d=e(n(),1);function f(e){switch(e.group){case`Added`:return{label:`NEW`,dot:`bg-moss`};case`Fixed`:return{label:`FIXED`,dot:`bg-amber`};case`Changed`:return{label:`CHANGED`,dot:`bg-cobalt`};case`Performance`:return{label:`PERFORMANCE`,dot:`bg-ember`};case`Deploy`:return{label:`DEPLOY`,dot:`bg-ink-4`};case`Docs`:return{label:`DOCS`,dot:`bg-ink-4`};default:return{label:`OTHER`,dot:`bg-ink-4`}}}var p=e=>e.version?e.version.replace(/^v/,``):c(`about.unreleased`),m=e=>e.timestamp?new Date(e.timestamp*1e3).toISOString().slice(0,10):``,h=e=>e.charAt(0).toUpperCase()+e.slice(1);function g(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=[];for(let t of e){if(`${p(t)} ${m(t)}`.toLowerCase().includes(n)){r.push(t);continue}let e=t.commits.filter(e=>`${f(e).label} ${e.scope??``} ${e.message}`.toLowerCase().includes(n));e.length>0&&r.push({...t,commits:e})}return r}async function _(e){if(e)try{let t=await fetch(`https://raw.githubusercontent.com/engenty/engenty-wizards/v${e}/apps/web/src/about/changelog.json`,{signal:AbortSignal.timeout(5e3)});if(t.ok)return await t.json()}catch{}return(await r(async()=>{let{default:e}=await import(`./changelog-DCJo2mbx.js`);return{default:e}},[])).default}function v({release:e}){return(0,d.jsx)(`ul`,{className:`flex flex-col gap-2`,children:e.commits.map(e=>{let t=f(e);return(0,d.jsxs)(`li`,{className:`flex items-start gap-2.5 text-[0.875rem]`,children:[(0,d.jsx)(`span`,{className:i(`mt-[7px] size-1.5 shrink-0 rounded-full`,t.dot)}),(0,d.jsxs)(`span`,{className:`min-w-0 text-ink-2`,children:[(0,d.jsxs)(`span`,{className:`font-semibold text-[0.75rem] text-ink tracking-wide`,children:[t.label,e.scope?` [${e.scope}]`:``]}),` `,h(e.message),e.breaking?(0,d.jsx)(`span`,{className:`ml-1.5 rounded-full bg-rose-tint px-1.5 py-0.5 font-medium text-[0.75rem] text-rose`,children:c(`about.breaking`)}):null]})]},e.id)})})}function y({open:e,onClose:t,version:n}){let[r,i]=(0,u.useState)(null),[f,h]=(0,u.useState)(``);(0,u.useEffect)(()=>{if(!e||r)return;let t=!1;return _(n).then(e=>{t||i(e)}),()=>{t=!0}},[e,r,n]),(0,u.useEffect)(()=>{e||h(``)},[e]);let y=r?g(r,f):[];return(0,d.jsxs)(o,{open:e,onClose:t,title:c(`about.changelog`),wide:!0,height:`tall`,children:[(0,d.jsx)(`p`,{className:`-mt-3 mb-4 text-[0.875rem] text-ink-3`,children:c(`about.changelogHint`)}),r===null?(0,d.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,d.jsx)(a,{})}):r.length===0?(0,d.jsx)(l,{children:c(`about.changelogEmpty`)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(s,{type:`search`,value:f,placeholder:c(`about.search`),onChange:e=>h(e.target.value)}),y.length===0?(0,d.jsx)(l,{children:c(`about.noMatches`)}):null,y.map(e=>(0,d.jsxs)(`section`,{className:`mt-6`,children:[(0,d.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[p(e),(0,d.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:m(e)})]}),(0,d.jsx)(`div`,{className:`mt-3`,children:(0,d.jsx)(v,{release:e})})]},e.version??`unreleased`))]})]})}export{y as ChangelogDialog,v as ReleaseNotes,_ as loadReleases,m as releaseDate,p as releaseLabel};
@@ -0,0 +1,10 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{A as r,Dt as i,E as a,Et as o,Ft as s,It as c,J as l,Kt as u,Lt as d,M as f,Mt as p,N as m,O as h,Pt as g,S as _,Tt as v,Vt as y,Wt as b,_t as x,an as S,at as C,b as w,bt as T,dn as E,et as D,it as O,j as k,k as A,kt as j,l as M,mt as N,nt as P,rt as F,s as I,sn as L,v as ee,wt as te,x as R,z}from"./ui-BOCXzzHi.js";import{t as ne}from"./phone-BORh3jfv.js";import{$t as re,Ht as ie,It as ae,bt as oe,nn as se,t as ce,vn as le,xt as ue,yt as de}from"./index-Df6UxElH.js";import{n as fe}from"./RunnerView-Deenymq0.js";var pe={name:`hand`,size:24,node:[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]};pe.node;var me=E(pe),he={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};he.node;var ge=E(he),_e={name:`video-off`,size:24,node:[[`path`,{d:`M10.66 6H14a2 2 0 0 1 2 2v2.5l5.248-3.062A.5.5 0 0 1 22 7.87v8.196`,key:`w8jjjt`}],[`path`,{d:`M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2`,key:`1xawa7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};_e.node;var ve=E(_e),ye={name:`volume-x`,size:24,node:[[`path`,{d:`M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z`,key:`1p7khw`}],[`path`,{d:`m16.5 14.5 5-5`,key:`cul3yw`}],[`path`,{d:`m16.5 9.5 5 5`,key:`1akey5`}]]};ye.node;var be=E(ye),xe=le(),B=e(t(),1),V=e(n(),1),Se=typeof window<`u`&&window.matchMedia(`(pointer: coarse)`).matches;function Ce({since:e}){let[t,n]=(0,B.useState)(Date.now());if((0,B.useEffect)(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),!e)return null;let r=Math.max(0,Math.floor((t-e)/1e3)),i=String(Math.floor(r/60)).padStart(2,`0`),a=String(r%60).padStart(2,`0`);return(0,V.jsxs)(`span`,{className:`font-mono text-[0.8125rem] text-white/60 tabular-nums`,children:[i,`:`,a]})}function H({label:e,on:t,danger:n,busy:r,onClick:i,children:a}){return(0,V.jsx)(`button`,{type:`button`,"aria-label":e,title:e,"aria-pressed":t,disabled:r,onClick:i,className:v(`flex size-12 items-center justify-center rounded-full transition disabled:opacity-50`,n?`bg-rose text-white hover:brightness-110`:t===!1?`bg-white text-neutral-900 hover:bg-white/90`:`bg-white/15 text-white hover:bg-white/25`),children:r?(0,V.jsx)(T,{className:`size-5`}):a})}function we({voice:e}){let t=(0,B.useRef)(null),{captions:n}=e;return(0,B.useEffect)(()=>{n.length&&t.current?.scrollIntoView({block:`end`})},[n]),n.length?(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 sm:px-5`,children:(0,V.jsxs)(`ol`,{className:`mx-auto flex max-w-[720px] flex-col gap-2 py-2`,children:[n.map(e=>(0,V.jsx)(`li`,{className:v(`text-[0.9375rem] leading-snug`,e.who===`bot`?`text-white/95`:`text-right text-white/50`),children:e.text},e.id)),(0,V.jsx)(`div`,{ref:t})]})}):null}function Te({voice:e,view:t,video:n,className:r}){let i=e.state===`live`,a=e.state===`connecting`,[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(!1);(0,B.useEffect)(()=>{s(i?Date.now():null)},[i]);let d=async()=>{l(!1),await e.start(),n&&await e.startCamera()},f=()=>{e.stop(),l(!0)},m=n||e.camera,h=[...e.captions].reverse().find(e=>e.who===`bot`),_=[...e.captions].reverse().find(e=>e.who===`me`),y=e.speaking?j(`talk.speaking`):e.listening?j(`talk.listening`):i?j(`talk.live`):a?j(`talk.connecting`):c?j(`video.ended`):``;return(0,V.jsxs)(`section`,{className:v(`relative flex min-h-0 flex-col bg-neutral-950 text-white`,`safe-top`,r),children:[(0,V.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 px-4 sm:px-5`,children:[(0,V.jsx)(`div`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-[1rem] tracking-tight`,children:t?.wizard.title??``}),y?(0,V.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-white/70`,children:[i?(0,V.jsx)(`span`,{className:v(`size-2 rounded-full`,e.speaking?`animate-pulse-dot bg-emerald-400`:`bg-rose`)}):null,y]}):null,(0,V.jsx)(Ce,{since:o})]}),(0,V.jsxs)(`div`,{className:v(`grid min-h-0 gap-2 px-3 pb-2 sm:px-4`,m?`flex-1 grid-cols-1 sm:grid-cols-2`:`shrink-0 grid-cols-1`,!m&&i&&e.captions.length?`h-[38%]`:m?``:`flex-1`),children:[(0,V.jsxs)(`div`,{className:v(`relative min-h-0 overflow-hidden rounded-2xl bg-neutral-900`,!m&&`hidden`),children:[(0,V.jsx)(`video`,{ref:e.video,muted:!0,playsInline:!0,autoPlay:!0,className:v(`absolute inset-0 h-full w-full object-cover`,e.facing===`user`&&`-scale-x-100`,e.camera?`block`:`hidden`)}),e.camera?null:(0,V.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 text-white/50`,children:[(0,V.jsx)(ve,{className:`size-8`}),(0,V.jsx)(`span`,{className:`text-[0.8125rem]`,children:j(`video.cameraOff`)})]}),(0,V.jsxs)(`span`,{className:`absolute bottom-2 left-3 rounded-md bg-black/50 px-2 py-0.5 text-[0.75rem]`,children:[j(`video.you`),e.muted?(0,V.jsx)(se,{className:`ml-1.5 inline size-3`}):null]})]}),(0,V.jsxs)(`div`,{className:v(`relative flex min-h-0 items-center justify-center overflow-hidden rounded-2xl transition-shadow`,m?`bg-neutral-900`:`bg-transparent`,m&&e.speaking&&`ring-2 ring-emerald-400/70`),children:[(0,V.jsx)(`div`,{className:v(`rounded-full transition-shadow duration-500`,!m&&e.listening&&`shadow-[0_0_80px_20px_rgba(244,63,94,0.25)]`,!m&&e.speaking&&`shadow-[0_0_80px_20px_rgba(52,211,153,0.3)]`,e.speaking&&`animate-breathe`),children:(0,V.jsx)(ae,{kind:t?.wizard.avatar??`round`,size:m?140:200,fluffy:!0,interactive:!1})}),m?(0,V.jsx)(`span`,{className:`absolute bottom-2 left-3 max-w-[85%] truncate rounded-md bg-black/50 px-2 py-0.5 text-[0.75rem]`,children:t?.wizard.title??``}):null]})]}),i&&!m?(0,V.jsx)(we,{voice:e}):i&&(h||_)?(0,V.jsx)(`div`,{className:`shrink-0 px-4 pb-2 sm:px-5`,children:(0,V.jsxs)(`div`,{className:`mx-auto max-w-[720px] space-y-1 text-center`,children:[_?(0,V.jsx)(`p`,{className:`line-clamp-1 text-[0.8125rem] text-white/50`,children:_.text}):null,h?(0,V.jsx)(`p`,{className:`line-clamp-3 text-[0.9375rem] text-white/95 leading-snug`,children:h.text}):null]})}):null,e.error?(0,V.jsx)(`p`,{className:`shrink-0 px-5 pb-2 text-center text-[0.8125rem] text-rose`,children:e.error}):null,(0,V.jsx)(`div`,{className:`flex shrink-0 items-center justify-center gap-3 px-4 pt-1 pb-4`,children:i?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(H,{label:j(e.muted?`video.unmute`:`video.mute`),on:!e.muted,onClick:e.toggleMute,children:e.muted?(0,V.jsx)(se,{className:`size-5`}):(0,V.jsx)(u,{className:`size-5`})}),(0,V.jsx)(H,{label:j(e.camera?`talk.cameraOff`:`talk.camera`),on:e.camera,onClick:()=>e.camera?e.stopCamera():void e.startCamera(),children:e.camera?(0,V.jsx)(p,{className:`size-5`}):(0,V.jsx)(ve,{className:`size-5`})}),e.camera&&Se?(0,V.jsx)(H,{label:j(`video.flip`),onClick:()=>void e.flipCamera(),children:(0,V.jsx)(g,{className:`size-5`})}):null,(0,V.jsx)(H,{label:j(`video.leave`),danger:!0,onClick:f,children:(0,V.jsx)(re,{className:`size-5`})})]}):(0,V.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,V.jsxs)(`button`,{type:`button`,disabled:a||!t?.talk,onClick:()=>void d(),className:`flex h-12 items-center gap-2 rounded-full bg-emerald-500 px-6 font-medium text-[0.9375rem] text-white transition hover:brightness-110 disabled:opacity-50`,children:[a?(0,V.jsx)(T,{className:`size-4`}):n?(0,V.jsx)(p,{className:`size-5`}):(0,V.jsx)(u,{className:`size-5`}),j(c?`video.rejoin`:n?`video.join`:`talk.start`)]}),!c&&!e.error?(0,V.jsx)(`p`,{className:`max-w-sm text-center text-[0.75rem] text-white/50`,children:j(n?`video.hint`:`talk.joinHint`)}):null]})})]})}var Ee=e=>z[e.kind]!==`device`,De=1024,Oe=4e3;function U(e,t){return e?e.length>t?`${e.slice(0,t)} …`:e:``}function W(e,t,n=!1){let r=[`status: ${e.status}`,`camera: ${n?`on`:`off`}`];if(e.ask)return r.push(e.ask.kind===`confirm`?`question: the step wants to "${e.ask.action.summary}" in ${e.ask.service}; answer_ask allows or skips it`:`question: a sign-in at ${e.ask.site.host}; the person types it on the screen, wait`),r.join(`
2
+ `);if(e.status===`running`){let t=[...e.events].reverse().find(e=>e.type===`tool`||e.type===`info`||e.type===`step_started`);return r.push(`working on: ${e.step?.title??``}`),t&&r.push(`doing: ${o(t)}`),r.join(`
3
+ `)}if(e.status===`done`){r.push(`done. made:`);for(let{step:t,output:n}of e.shown)r.push(`- ${t.title}: ${U(n?.text,400)||`(a file, on the screen)`}`);return r.join(`
4
+ `)}if(e.status===`failed`)return r.push(`failed: ${e.error??``}; go_back or the person retries on the screen`),r.join(`
5
+ `);if(t){r.push(`page: ${t.step.title}`);for(let e of t.fields){let n=t.values[e.id],i=n!=null&&n!==``,a=Ee(e)?`by voice`:e.kind===`image`?`with the camera (take_photo) or on the screen`:`on the screen only`,o=e.options?.length?`; options: ${e.options.join(` | `)}`:``;r.push(`- field ${e.id} (${e.kind}${e.required?`, required`:``}, ${a}): ${e.label}${e.help?` – ${e.help}`:``}${o}${i?` = ${U(String(Array.isArray(n)?n.join(`, `):n),120)}`:` = (open)`}`)}return r.join(`
6
+ `)}if(e.step?.type===`review`){r.push(`review: ${e.step.title}`);for(let{step:t,output:n}of e.shown)r.push(`- ${t.id} "${t.title}": ${U(n?.text,600)||`(a picture or file, on the screen)`}`);return r.push(`regenerate allowed: ${e.step.regenerate?`yes`:`no`}`),r.join(`
7
+ `)}return r.push(`step: ${e.step?.title??``}`),r.join(`
8
+ `)}function ke(e,t,n,r){let[i,a]=(0,B.useState)(`off`),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(!1),[f,p]=(0,B.useState)(!1),[m,h]=(0,B.useState)(`environment`),[g,_]=(0,B.useState)(!1),[v,y]=(0,B.useState)([]),b=(0,B.useRef)(null),x=(0,B.useRef)(null),S=(0,B.useRef)(0),C=(0,B.useRef)(!1);C.current=f;let w=(0,B.useRef)(null),T=(0,B.useRef)(null),E=(0,B.useRef)(null),D=(0,B.useRef)(null),O=(0,B.useRef)(t);O.current=t;let k=(0,B.useRef)(r);k.current=r;let A=(0,B.useRef)(n);A.current=n;let N=(0,B.useRef)(``),P=(0,B.useCallback)(e=>{let t=T.current;t&&t.readyState===`open`&&t.send(JSON.stringify(e))},[]),F=(0,B.useCallback)(()=>{let e=b.current;if(!C.current||!e||e.videoWidth===0)return null;let t=Math.min(1,De/e.videoWidth),n=document.createElement(`canvas`);return n.width=Math.round(e.videoWidth*t),n.height=Math.round(e.videoHeight*t),n.getContext(`2d`)?.drawImage(e,0,0,n.width,n.height),n.toDataURL(`image/jpeg`,.75)},[]),I=(0,B.useCallback)(()=>{for(let e of x.current?.getTracks()??[])e.stop();x.current=null,b.current&&(b.current.srcObject=null),p(!1)},[]),L=(0,B.useCallback)(async e=>{if(x.current)return;let t=e??`environment`;try{let e=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:t},width:{ideal:1280}},audio:!1});x.current=e;let n=e.getVideoTracks()[0]?.getSettings().facingMode;h(n===`user`||n===`environment`?n:t),b.current&&(b.current.srcObject=e,await b.current.play().catch(()=>void 0)),p(!0)}catch(e){s(e.name===`NotAllowedError`?j(`talk.cameraDenied`):e.message)}},[]),ee=(0,B.useCallback)(async()=>{let e=m===`user`?`environment`:`user`;I(),await L(e)},[m,I,L]),te=(0,B.useCallback)(()=>{_(e=>{for(let t of D.current?.getAudioTracks()??[])t.enabled=e;return!e})},[]),R=(0,B.useCallback)(()=>{I(),T.current?.close(),T.current=null,w.current?.close(),w.current=null;for(let e of D.current?.getTracks()??[])e.stop();D.current=null,E.current&&=(E.current.srcObject=null,E.current.remove(),null),N.current=``,l(!1),d(!1),_(!1),a(`off`)},[I]);(0,B.useEffect)(()=>()=>R(),[R]);let z=(0,B.useCallback)(async(t,n)=>{let r=O.current,i=k.current,a=A.current;switch(t){case`get_state`:return r?W(r,i,C.current):`no run`;case`look`:{let e=F();return e?(P({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[camera] what the person shows right now`},{type:`input_image`,image_url:e}]}}),`a picture arrived as the next message`):`the camera is off; ask the person to switch it on`}case`take_photo`:{if(!i)return`no page is open`;let t=i.fields.find(e=>e.id===String(n.field??``));if(t?.kind!==`image`)return`no such photo field on this page`;let r=F();if(!r)return`the camera is off; ask the person to switch it on`;try{let n=await(await fetch(r)).blob(),a=new File([n],`photo-${Date.now()}.jpg`,{type:`image/jpeg`}),o=await M.upload(`/api/runs/${e}/uploads`,a),s=i.values[t.id],c=t.multiple?[...Array.isArray(s)?s:s?[s]:[],o.id]:o.id,l=i.setField(t.id,c);return l?`refused: ${l}`:`the photo is in the field`}catch(e){return`failed: ${e.message}`}}case`set_field`:{if(!i)return`no page is open`;let e=i.setField(String(n.field??``),n.value);return e?`refused: ${e}`:`kept`}case`submit_page`:{if(!i)return`no page is open`;let e=i.fields.filter(e=>e.required&&Ee(e)&&e.kind!==`toggle`&&(i.values[e.id]===void 0||i.values[e.id]===null||i.values[e.id]===``));return e.length?`still open: ${e.map(e=>e.id).join(`, `)}`:(i.submit(),`sent; wait for the next state`)}case`accept_review`:return r?.step?.type===`review`?await a.accept(r.step.id)?`accepted`:a.error??`refused`:`no review is open`;case`regenerate`:return r?.step?.type===`review`?await a.regenerate(r.step.id,String(n.target??``),String(n.note??``))?`the wizard makes it again; wait`:a.error??`refused`:`no review is open`;case`answer_ask`:if(!r?.ask)return`no question is open`;try{return await M.post(`/api/runs/${e}/ask/${r.ask.id}`,{type:n.allow?`done`:`skip`}),n.allow?`allowed`:`skipped`}catch(e){return`refused: ${e.message}`}case`go_back`:return await a.back()?`went back; wait for the state`:a.error??`refused`;default:return`unknown tool ${t}`}},[e,F,P]),ne=(0,B.useCallback)(async()=>{if(!w.current){s(null),y([]),a(`connecting`);try{let t=await M.post(`/api/runs/${e}/talk`),n=await navigator.mediaDevices.getUserMedia({audio:!0});D.current=n;let r=new RTCPeerConnection;w.current=r;let i=document.createElement(`audio`);i.autoplay=!0,i.setAttribute(`playsinline`,``),document.body.append(i),E.current=i,r.ontrack=e=>{i.srcObject=e.streams[0]};for(let e of n.getTracks())r.addTrack(e,n);let o=r.createDataChannel(`oai-events`);T.current=o,o.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}switch(t.type){case`output_audio_buffer.started`:l(!0);break;case`output_audio_buffer.stopped`:case`output_audio_buffer.cleared`:l(!1);break;case`input_audio_buffer.speech_started`:{d(!0);let e=Date.now()-S.current>Oe?F():null;e&&(S.current=Date.now(),P({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[camera] what the person shows while speaking`},{type:`input_image`,image_url:e}]}}));break}case`input_audio_buffer.speech_stopped`:d(!1);break;case`response.output_audio_transcript.done`:case`conversation.item.input_audio_transcription.completed`:{let e=String(t.transcript??``).trim();if(e){let n=t.type===`response.output_audio_transcript.done`?`bot`:`me`;y(t=>[...t.slice(-199),{id:`${Date.now()}:${n}`,who:n,text:e}])}break}case`response.function_call_arguments.done`:{let e=String(t.name??``),n=String(t.call_id??``),r={};try{r=JSON.parse(String(t.arguments??`{}`))}catch{}z(e,r).then(e=>{P({type:`conversation.item.create`,item:{type:`function_call_output`,call_id:n,output:e}}),P({type:`response.create`})});break}case`error`:s(String(t.error?.message??`error`))}},o.onopen=()=>{a(`live`);let e=O.current;e&&(N.current=W(e,k.current,C.current),P({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[state]\n${N.current}\n\nGreet the person in one sentence and ask the first open field.`}]}}),P({type:`response.create`}))},o.onclose=()=>{w.current===r&&R()};let c=await r.createOffer();await r.setLocalDescription(c);let u=await fetch(t.endpoint,{method:`POST`,headers:{authorization:`Bearer ${t.clientSecret}`,"content-type":`application/sdp`},body:c.sdp});if(!u.ok)throw Error(`${j(`talk.failed`)} (${u.status})`);await r.setRemoteDescription({type:`answer`,sdp:await u.text()})}catch(e){R(),s(e.name===`NotAllowedError`?j(`chat.micDenied`):e.message),a(`error`)}}},[e,z,F,P,R]);return(0,B.useEffect)(()=>{if(i!==`live`||!t)return;let e=W(t,r,f);if(e===N.current)return;let n=N.current;N.current=e,P({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[state]\n${e}`}]}}),(t.status===`running`&&n.startsWith(`status: running`)&&!n.includes(`working on: `)||t.status!==`running`||n.split(`
9
+ `)[1]!==e.split(`
10
+ `)[1])&&P({type:`response.create`})},[i,t,r,f,P]),{state:i,error:o,speaking:c,listening:u,start:ne,stop:R,camera:f,facing:m,startCamera:L,stopCamera:I,flipCamera:ee,muted:g,toggleMute:te,captions:v,video:b}}var G=(e,t,n)=>({key:e,who:`bot`,node:t,...n}),K=(e,t,n)=>({key:e,who:`me`,node:t,...n}),Ae=(0,B.createContext)(null),q=(0,B.createContext)(null);function je(){return(0,B.useContext)(q)?.voice??null}function Me({children:e}){let t=(0,B.useContext)(Ae);return t?(0,xe.createPortal)(e,t):null}function Ne({header:e,footer:t,children:n}){let[r,i]=(0,B.useState)(null),a=(0,B.useRef)(null),o=(0,B.useRef)(null),s=(0,B.useRef)(!0);return(0,B.useLayoutEffect)(()=>{let e=a.current,t=o.current;if(!e||!t)return;let n=e.scrollTop,r=()=>{e.scrollHeight-e.scrollTop-e.clientHeight<120?s.current=!0:e.scrollTop<n&&(s.current=!1),n=e.scrollTop},i=null,c=new ResizeObserver(()=>{let r=t.querySelector(`[data-anchor]`);r&&r!==i?(i=r,e.scrollTop+=r.getBoundingClientRect().top-e.getBoundingClientRect().top-12,s.current=!1,n=e.scrollTop):s.current&&(e.scrollTop=e.scrollHeight)});return e.scrollTop=e.scrollHeight,e.addEventListener(`scroll`,r,{passive:!0}),c.observe(t),c.observe(e),()=>{c.disconnect(),e.removeEventListener(`scroll`,r)}},[]),(0,V.jsx)(Ae.Provider,{value:r,children:(0,V.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[e,(0,V.jsx)(`div`,{ref:a,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,V.jsx)(`div`,{ref:o,className:`mx-auto flex w-full max-w-[760px] flex-col gap-3 px-3 pt-5 pb-4 sm:px-6`,children:n})}),(0,V.jsxs)(`div`,{className:`shrink-0 border-border-soft border-t bg-background`,onPointerDownCapture:()=>{s.current=!0},onKeyDownCapture:()=>{s.current=!0},children:[(0,V.jsx)(`div`,{ref:i,className:`mx-auto w-full max-w-[760px] px-3 pt-3 sm:px-6`}),t]})]})})}function J({avatar:e,lines:t}){let n=(0,B.useContext)(q),r=(0,B.useMemo)(()=>t.map(e=>({key:e.key,who:e.who,spoken:!e.bare&&!e.wide})),[t]),a=(0,B.useCallback)(e=>{let t=document.querySelector(`[data-say="${CSS.escape(e)}"]`);return t?.querySelector(`[data-say-text]`)?.getAttribute(`data-say-text`)??t?.innerText??null},[]);ue(!!n?.readAloud,n?.lang??i,r,a);let o=[];for(let e of t){let t=o.at(-1);t&&t.who===`bot`&&e.who===`bot`?t.lines.push(e):o.push({who:e.who,lines:[e]})}return o.map((t,n)=>t.who===`bot`?(0,V.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,V.jsx)(`div`,{className:`sticky top-1 shrink-0 pt-0.5`,children:(0,V.jsx)(ae,{kind:e,size:30,interactive:n>=o.length-2})}),(0,V.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1.5`,children:t.lines.map(e=>(0,V.jsx)(`div`,{"data-anchor":e.anchor?``:void 0,"data-say":e.key,className:v(`animate-rise`,e.bare?`w-full pt-1`:`rounded-2xl rounded-tl-md text-[0.9375rem] text-ink leading-relaxed`,!e.bare&&(e.wide?v(`w-full bg-card p-4 shadow-soft ring-1 ring-border-soft`,e.wide===`most`&&`md:w-4/5`):`max-w-[min(36rem,100%)] bg-card px-4 py-2.5 shadow-soft ring-1 ring-border-soft`),e.tone===`error`&&`bg-rose-tint text-rose shadow-none ring-0`),children:e.node},e.key))})]},t.lines[0].key):t.lines.map(e=>(0,V.jsxs)(`div`,{className:`flex animate-rise flex-col items-end gap-1 pl-10`,children:[(0,V.jsx)(`div`,{className:`max-w-[min(32rem,100%)] whitespace-pre-wrap break-words rounded-2xl rounded-br-md bg-primary px-4 py-2.5 text-[0.9375rem] text-primary-foreground leading-relaxed`,children:e.node}),e.onEdit?(0,V.jsxs)(`button`,{type:`button`,onClick:e.onEdit,className:`inline-flex items-center gap-1 px-1 text-[0.75rem] text-ink-4 transition hover:text-ink-2 coarse:min-h-9`,children:[(0,V.jsx)(y,{className:`size-3`}),` `,j(`chat.change`)]}):null]},e.key)))}function Pe(){return(0,V.jsx)(`span`,{className:`inline-flex items-center gap-1 py-1.5`,role:`status`,"aria-label":j(`run.working`),children:[0,1,2].map(e=>(0,V.jsx)(`span`,{className:`size-1.5 animate-typing rounded-full bg-ink-3`,style:{animationDelay:`${e*160}ms`}},e))})}function Y({children:e}){return(0,V.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e})}var X=(e,t)=>G(e,(0,V.jsx)(Y,{children:t}),{bare:!0});function Z({onClick:e,children:t,primary:n,on:r,disabled:i,busy:a}){return(0,V.jsxs)(`button`,{type:`button`,"aria-pressed":r,disabled:i||a,onClick:e,className:v(`inline-flex h-10 items-center gap-1.5 rounded-full px-4 font-medium text-[0.875rem] transition active:scale-[0.98] disabled:pointer-events-none disabled:opacity-50 coarse:h-11`,n?`bg-primary text-primary-foreground hover:brightness-[1.06]`:r?`bg-ember-tint text-ink ring-1 ring-ember`:`bg-card text-ink-2 ring-1 ring-input hover:text-ink hover:ring-ink-4`),children:[a?(0,V.jsx)(T,{className:`size-4`}):null,t]})}function Fe({initial:e=``,placeholder:t,multiline:n,inputProps:r,busy:i,disabled:a,inputRef:o,onSend:c}){let[l,d]=(0,B.useState)(e),f=(0,B.useRef)(null),m=o??f,h=(0,B.useContext)(q),g=I(l,d,{endpoint:h?`/api/runs/${h.runId}/transcribe`:void 0}),_=!!h&&g.supported&&!a;(0,B.useEffect)(()=>{if(!_)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()===`m`&&(e.preventDefault(),g.toggle())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_,g.toggle]),(0,B.useEffect)(()=>{!P&&!a&&m.current?.focus()},[a,m]);let y=()=>{i||a||(g.listening&&g.toggle(),c(l)!==!1&&d(``))},b=g.listening?j(`chat.listening`):g.processing?j(`chat.transcribing`):t,x=h?.voice??null,S=!!h?.call,C=h&&!S&&(de||_||x)?(0,V.jsxs)(`div`,{className:`mb-1 flex shrink-0 items-center`,children:[x?(0,V.jsx)(N,{label:j(x.state===`live`?`talk.stop`:x.state===`connecting`?`talk.connecting`:`talk.start`),"aria-pressed":x.state===`live`,disabled:x.state===`connecting`,onClick:()=>x.state===`live`?x.stop():void x.start(),className:v(`size-9`,x.state===`live`&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`,x.state===`off`&&h.talk&&`bg-primary text-primary-foreground hover:bg-primary`),children:x.state===`connecting`?(0,V.jsx)(T,{className:`size-4`}):x.state===`live`?(0,V.jsx)(re,{className:`size-4`}):(0,V.jsx)(ne,{className:`size-4`})}):null,x?.state===`live`?(0,V.jsx)(N,{label:j(x.camera?`talk.cameraOff`:`talk.camera`),"aria-pressed":x.camera,onClick:()=>x.camera?x.stopCamera():void x.startCamera(),className:v(`size-9`,x.camera&&`text-ink`),children:x.camera?(0,V.jsx)(p,{className:`size-4`}):(0,V.jsx)(ve,{className:`size-4`})}):null,de?(0,V.jsx)(N,{label:j(h.readAloud?`chat.readAloudOff`:`chat.readAloud`),"aria-pressed":h.readAloud,onClick:()=>h.setReadAloud(!h.readAloud),className:v(`size-9`,h.readAloud&&`text-ink`),children:h.readAloud?(0,V.jsx)(ie,{className:`size-4`}):(0,V.jsx)(be,{className:`size-4`})}):null,_?(0,V.jsx)(N,{label:j(g.listening?`chat.dictateStop`:`chat.dictate`),"aria-pressed":g.listening,disabled:g.processing,onClick:g.toggle,className:v(`size-9`,g.listening&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`),children:g.processing?(0,V.jsx)(T,{className:`size-4`}):g.listening?(0,V.jsx)(s,{className:`size-3.5 animate-pulse-dot fill-current`}):(0,V.jsx)(u,{className:`size-4`})}):null]}):null;return(0,V.jsxs)(`form`,{className:`pb-3`,onSubmit:e=>{e.preventDefault(),y()},children:[x&&!S?(0,V.jsx)(`video`,{ref:x.video,muted:!0,playsInline:!0,autoPlay:!0,className:v(`mb-2 ml-auto w-32 rounded-xl bg-black object-cover shadow-soft ring-1 ring-border-soft`,x.camera?`block`:`hidden`)}):null,(0,V.jsxs)(`div`,{className:v(`flex items-end gap-1 rounded-[1.375rem] border border-input bg-card pr-1.5 pl-1 transition focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,a&&`opacity-60`),children:[C,n?(0,V.jsx)(te,{ref:m,minRows:1,maxRows:6,value:l,disabled:a,placeholder:b,autoCapitalize:`sentences`,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!P&&!e.nativeEvent.isComposing&&(e.preventDefault(),y())},className:`min-h-11 border-0 bg-transparent py-2.5 shadow-none focus:ring-0`}):(0,V.jsx)(`input`,{ref:m,...r,value:l,disabled:a,placeholder:b,enterKeyHint:`send`,onChange:e=>d(e.target.value),className:`h-11 min-w-0 flex-1 bg-transparent px-3 text-[0.9375rem] text-ink outline-none placeholder:text-ink-4`}),(0,V.jsx)(`button`,{type:`submit`,"aria-label":j(`chat.send`),title:j(`chat.send`),disabled:i||a,className:`mb-1 flex size-9 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground transition hover:brightness-[1.06] disabled:opacity-40`,children:i?(0,V.jsx)(T,{className:`size-4`}):(0,V.jsx)(L,{className:`size-4`})})]}),g.error?(0,V.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:g.error===`denied`?j(`chat.micDenied`):g.error}):S?null:x?.error?(0,V.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:x.error}):x?.state===`live`?(0,V.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:x.speaking?j(`talk.speaking`):x.listening?j(`talk.listening`):j(`talk.live`)}):h?.talk&&x?.state===`off`?(0,V.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:j(`talk.hint`)}):null]})}function Q({placeholder:e=j(`chat.above`)}){return(0,V.jsx)(Me,{children:(0,V.jsx)(Fe,{disabled:!0,placeholder:e,onSend:()=>!1})})}function Ie(e){let t=z[e.kind];return t===`typed`&&!e.scan?`typed`:t===`tapped`?`tapped`:`control`}var Le=e=>e==null||e===``||Array.isArray(e)&&e.length===0;function Re(e,t){let n=e.kind===`toggle`||e.kind===`connection`||e.kind===`list`;if(Le(t))return e.required&&!n?j(`chat.required`):null;let r=String(t).trim();if(e.kind===`email`&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r))return j(`chat.badEmail`);if(e.kind===`url`)try{new URL(r)}catch{return j(`chat.badUrl`)}return e.kind===`number`&&!Number.isFinite(Number(r.replace(`,`,`.`)))?j(`chat.badNumber`):Array.isArray(t)&&e.multiple&&e.min&&t.length<e.min?j(`run.filesMin`,{n:t.length,min:e.min}):null}function ze(e,t){let n=e.kind===`textarea`?t.replace(/\s+$/,``):t.trim();if(n)return e.kind===`url`&&!/^[a-z][a-z0-9+.-]*:/i.test(n)?`https://${n}`:n}function Be({field:e}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`font-medium`,children:e.label}),e.help?(0,V.jsx)(`span`,{className:`mt-0.5 block text-[0.8125rem] text-ink-3`,children:e.help}):null]})}function Ve({step:e,only:t}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`font-medium`,children:e.title}),e.description?(0,V.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:e.description}):null,t?.help?(0,V.jsx)(`span`,{className:`mt-1 block text-[0.8125rem] text-ink-3`,children:t.help}):null]})}function He({field:e,value:t,runId:n}){if(e.kind===`connection`)return(0,V.jsx)(V.Fragment,{children:typeof t==`string`&&t?t:j(`chat.connected`)});if(e.kind===`list`)return(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,V.jsx)(S,{className:`size-4`}),` `,j(`chat.checked`)]});if(e.kind===`toggle`)return(0,V.jsx)(V.Fragment,{children:j(t===!0?`run.yes`:`run.no`)});if(Le(t))return(0,V.jsx)(`span`,{className:`italic opacity-80`,children:j(`chat.skipped`)});switch(e.kind){case`multiselect`:return(0,V.jsx)(V.Fragment,{children:t.join(`, `)});case`date`:{let e=new Date(`${String(t)}T00:00`);return(0,V.jsx)(V.Fragment,{children:Number.isNaN(e.getTime())?String(t):new Intl.DateTimeFormat(i,{dateStyle:`long`}).format(e)})}case`color`:return(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`size-4 rounded-full ring-1 ring-white/50`,style:{background:String(t)}}),String(t)]});case`image`:case`signature`:return(0,V.jsx)(`span`,{className:`-mx-1.5 flex flex-wrap gap-1.5`,children:(Array.isArray(t)?t:[String(t)]).map(t=>(0,V.jsx)(`img`,{src:ee(`/api/runs/${n}/assets/${t}`),alt:``,className:v(`h-16 rounded-lg bg-white`,e.kind===`image`?`w-16 object-cover`:`object-contain px-1`)},t))});case`file`:{let e=Array.isArray(t)?t.length:1;return(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,V.jsx)(b,{className:`size-4`}),` `,j(e===1?`chat.file`:`chat.files`,{n:e})]})}case`audio`:{let e=t.seconds;return(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,V.jsx)(u,{className:`size-4`}),` `,j(`chat.voice`),e?` · ${Math.round(e)} s`:``]})}case`location`:{let e=t;return(0,V.jsx)(V.Fragment,{children:e.label||`${e.lat?.toFixed(5)}, ${e.lng?.toFixed(5)}`})}case`items`:return(0,V.jsx)(V.Fragment,{children:j(`chat.rows`,{n:Array.isArray(t)?t.length:0})});default:return(0,V.jsx)(V.Fragment,{children:String(t)})}}function Ue(e,t,n,r,i,a){let o=[G(t,(0,V.jsx)(Ve,{step:e,only:a}))];for(let e of i)a||o.push(G(`${t}:${e.id}`,(0,V.jsx)(Be,{field:e}))),o.push(K(`${t}:${e.id}:a`,(0,V.jsx)(He,{field:e,value:n[e.id],runId:r})));return o}var We=(e,t)=>e.fields.filter(e=>!e.when&&!l(e)||t[e.id]!==void 0&&t[e.id]!==null);function Ge(e,t){let n=[];e.wizard.description&&n.push(G(`hello`,e.wizard.description)),e.wizard.intro&&n.push(G(`intro`,e.wizard.intro));for(let[t,r]of e.answered.entries()){let i=`${t}:${r.id}`;if(r.type===`page`){let t=r.fields.length===1?r.fields[0]:void 0;n.push(...Ue(r,i,e.values,e.id,We(r,e.values),t))}else r.type===`review`&&(n.push(G(i,(0,V.jsx)(`span`,{className:`font-medium`,children:r.title}))),n.push(K(`${i}:a`,j(`run.accept`))))}let r=n.at(-1);return t&&r?.who===`me`&&(n[n.length-1]={...r,onEdit:t}),n}function Ke(e,t){return e.fields.filter(e=>!l(e)||t.decidedFields?.includes(e.id)).map(e=>t.options?.[e.id]?.length?{...e,options:t.options[e.id]}:e)}function qe({view:e,run:t,step:n,before:r}){let i=(0,B.useMemo)(()=>Ke(n,e),[n,e]),a=e.known??{},[o,s]=(0,B.useState)(()=>w(n,e)),[c,l]=(0,B.useState)(()=>n.fields.some(t=>e.values[t.id]!==void 0)?D(Ke(n,e),e.known??{},w(n,e)).slice(0,-1).map(e=>e.id):[]),[u,d]=(0,B.useState)({}),[f,p]=(0,B.useState)(!1),[m,g]=(0,B.useState)(!1),_=D(i,a,o),v=_.filter(e=>c.includes(e.id)),y=_.find(e=>!c.includes(e.id)),b=i.length===1?i[0]:void 0,x=v.at(-1),S=x?()=>l(e=>e.filter(e=>e!==x.id)):void 0;(0,B.useEffect)(()=>{let e=Object.keys(t.fieldErrors),n=D(i,a,o),r=n.findIndex(t=>e.includes(t.id));r>=0&&(l(n.slice(0,r).map(e=>e.id)),d(t.fieldErrors))},[t.fieldErrors]);let C=e=>{t.submitPage(n.id,e).then(g)},T=(0,B.useContext)(q),E=(0,B.useRef)(o);E.current=o;let O=T?.bindPage,k=(0,B.useRef)(C);k.current=C,(0,B.useEffect)(()=>{if(!O)return;let e=D(i,a,o);return O({step:n,fields:e,values:o,setField:(t,n)=>{let r=e.find(e=>e.id===t);return r?Re(r,n)||(s(e=>({...e,[t]:n})),l(e=>e.includes(t)?e:[...e,t]),d({}),null):`no such field on this page`},submit:()=>k.current(E.current)}),()=>O(null)},[O,n,i,a,o]);let A=e=>{if(!y)return!1;let t=Re(y,e);if(t)return d({[y.id]:t}),!1;let n={...o,[y.id]:e},r=[...c,y.id];return s(n),l(r),d({}),D(i,a,n).some(e=>!r.includes(e.id))||C(n),!0},M=[...r.map(e=>c.length?{...e,onEdit:void 0}:e),...Ue(n,`now:${n.id}`,o,e.id,v,b).map((e,t,n)=>t===n.length-1&&e.who===`me`&&y?{...e,onEdit:S}:e)];y?(Ie(y)===`control`?M.push(G(`now:${n.id}:${y.id}:control`,(0,V.jsx)(h,{field:y,value:o[y.id],values:o,runId:e.id,view:e,closed:e.closed?.[y.id],onChange:e=>s(t=>({...t,[y.id]:e})),onBusy:p}),{wide:!0})):b||M.push(G(`now:${n.id}:${y.id}`,(0,V.jsx)(Be,{field:y}))),u[y.id]&&M.push(G(`now:${n.id}:${y.id}:error`,u[y.id],{tone:`error`}))):t.busy||m?M.push(G(`sending`,(0,V.jsx)(Pe,{}))):t.error&&M.push(G(`send-error`,t.error,{tone:`error`}));let N=(0,V.jsx)(Q,{});if(m||!y&&c.length>0&&t.busy)N=(0,V.jsx)(Q,{placeholder:j(`run.working`)});else if(!y)M.push(X(`now:${n.id}:go`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Z,{primary:!0,busy:t.busy,onClick:()=>C(o),children:n.cta||j(`run.next`)}),S?(0,V.jsx)(Z,{onClick:S,disabled:t.busy,children:j(`run.back`)}):null]})));else{let r=Ie(y),i=!y.required&&y.kind!==`connection`&&y.kind!==`list`?(0,V.jsx)(Z,{onClick:()=>A(void 0),children:j(`chat.skip`)}):null;if(r===`typed`){i&&M.push(X(`now:${n.id}:${y.id}:replies`,i));let e=o[y.id];N=(0,V.jsx)(Me,{children:(0,V.jsx)(Fe,{initial:Le(e)?``:String(e),multiline:y.kind===`textarea`,placeholder:y.placeholder||(b?y.label:j(`chat.placeholder`)),inputProps:Je(y),busy:t.busy,onSend:e=>A(ze(y,e))},y.id)})}else if(r===`tapped`)M.push(G(`now:${n.id}:${y.id}:replies`,(0,V.jsx)(Ye,{field:y,view:e,value:o[y.id],onAnswer:A}),{bare:!0}));else{let e=_.filter(e=>!c.includes(e.id)).length===1;M.push(X(`now:${n.id}:${y.id}:replies`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Z,{primary:!0,disabled:f,onClick:()=>A(o[y.id]),children:e&&n.cta?n.cta:j(`chat.send`)}),i]})))}}return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(J,{avatar:e.wizard.avatar,lines:M}),N]})}function Je(e){switch(e.kind){case`number`:return{inputMode:`decimal`,autoComplete:`off`};case`email`:return{type:`email`,inputMode:`email`,autoComplete:`email`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1};case`url`:return{inputMode:`url`,autoComplete:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1};case`date`:return{type:`date`};default:return A(e)}}function Ye({field:e,view:t,value:n,onAnswer:r}){let i=new Set(t.closed?.[e.id]?.values.map(String)),[a,o]=(0,B.useState)(Array.isArray(n)?n:[]);if(e.kind===`toggle`)return(0,V.jsxs)(Y,{children:[(0,V.jsx)(Z,{on:n===!1,disabled:i.has(`false`),onClick:()=>r(!1),children:j(`run.no`)}),(0,V.jsx)(Z,{on:n===!0,disabled:i.has(`true`),onClick:()=>r(!0),children:j(`run.yes`)})]});let s=e.options??[];return e.kind===`multiselect`?(0,V.jsxs)(Y,{children:[s.map(e=>(0,V.jsx)(Z,{on:a.includes(e),onClick:()=>o(t=>t.includes(e)?t.filter(t=>t!==e):s.filter(n=>n===e||t.includes(n))),children:e},e)),(0,V.jsx)(Z,{primary:!0,disabled:e.required&&!a.length,onClick:()=>r(a),children:a.length||e.required?j(`chat.send`):j(`chat.skip`)})]}):(0,V.jsxs)(Y,{children:[s.map(e=>(0,V.jsx)(Z,{on:n===e,disabled:i.has(e),onClick:()=>r(e),children:e},e)),e.required?null:(0,V.jsx)(Z,{onClick:()=>r(void 0),children:j(`chat.skip`)})]})}function Xe({view:e}){let t=(0,B.useMemo)(()=>[...e.events].reverse().find(t=>t.type===`step_started`&&t.stepId===e.step?.id),[e.events,e.step?.id]),n=t?new Date(t.at).getTime():Date.now(),[r,i]=(0,B.useState)(Date.now());(0,B.useEffect)(()=>{let e=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(e)},[]);let a=e.events.filter(e=>(e.type===`tool`||e.type===`info`)&&new Date(e.at).getTime()>=n-500),s=a.at(-1),l=[...a].reverse().find(Qe),u=[...new Set(a.map(e=>e.asset).filter(e=>!!e))];return(0,V.jsxs)(`div`,{className:v(`flex max-w-full flex-col gap-1`,l?`w-full`:`w-96`),"data-say-text":t?.message??e.step?.title??j(`run.working`),children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(Pe,{}),(0,V.jsx)(`span`,{className:`font-medium`,children:t?.message??e.step?.title??j(`run.working`)}),(0,V.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:j(`run.elapsed`,{s:Math.max(0,Math.round((r-n)/1e3))})})]}),s&&s!==l?(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-ink-3`,children:[(0,V.jsx)(c,{className:`size-3.5 shrink-0 animate-breathe text-ember`}),(0,V.jsx)(`span`,{className:`truncate`,children:o(s)})]}):null,l&&e.status===`running`?(0,V.jsx)(et,{runId:e.id,event:l}):null,u.length?(0,V.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:u.slice(-6).map(t=>(0,V.jsx)(`img`,{src:ee(`/api/runs/${e.id}/assets/${t}`),alt:``,className:`size-14 rounded-lg bg-paper-2 object-cover ring-1 ring-border-soft`},t))}):null]})}var Ze=new Set([`opens`,`clicks`,`clicksOn`,`types`,`typesText`,`selects`,`scrolls`,`presses`,`goesBack`,`waitsForPage`,`fastLoop`,`looksAtPage`,`personDrives`,`agentDrives`]);function Qe(e){return!!e.note&&Ze.has(e.note.code)}var $e=1e4;function et({runId:e,event:t}){let[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(`agent`),[s,c]=(0,B.useState)(!1),l=t.note?.code;if((0,B.useEffect)(()=>{l===`personDrives`?a(`person`):l===`agentDrives`&&a(`agent`)},[l]),(0,B.useEffect)(()=>{let t=()=>M.get(`/api/runs/${e}/browser/seat`).then(e=>a(e.seat)).catch(()=>void 0);if(t(),i!==`person`)return;let n=setInterval(t,$e);return()=>clearInterval(n)},[e,i]),n!==null&&n>=t.id)return null;let u=i===`person`,d=async()=>{c(!0);try{let t=await M.post(`/api/runs/${e}/browser/seat`,{to:u?`agent`:`person`});a(t.seat)}catch{}finally{c(!1)}};return(0,V.jsx)(C,{runId:e,driving:u,caption:o(t),hint:j(`browser.driving`),onBroken:()=>r(t.id),className:`mt-1.5`,action:(0,V.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>void d(),className:v(`flex h-8 items-center gap-1.5 rounded-full px-3 font-medium text-[0.8125rem] shadow-soft transition-colors disabled:opacity-60`,u?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-card/90 text-ink ring-1 ring-border-soft backdrop-blur hover:bg-card`),children:[u?(0,V.jsx)(ge,{className:`size-3.5`}):(0,V.jsx)(me,{className:`size-3.5`}),j(u?`browser.handBack`:`browser.takeOver`)]})},n??0)}function $({children:e,end:t}){return(0,V.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,V.jsx)(`h3`,{className:`font-display font-semibold text-[1rem]`,children:e}),t]})}function tt({view:e,run:t,step:n,before:i,asked:o,onNote:s}){let c=e.shown.filter(e=>e.output),[l,u]=(0,B.useState)(c.length===1?c[0].step.id:null),d=(0,B.useRef)(null),p=[...i,...o.map((e,t)=>K(`review:${n.id}:asked:${t}`,e)),G(`review:${n.id}`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`font-medium`,children:n.title}),n.description?(0,V.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:n.description}):null]}),{anchor:!0}),...c.map(({step:t,output:r})=>G(`review:${n.id}:${t.id}`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)($,{children:t.title}),(0,V.jsx)(a,{base:`/api/runs/${e.id}`,step:t,output:r,onSurfaceAction:n.regenerate?()=>{u(t.id),d.current?.focus()}:void 0})]}),{wide:!0})),...e.lists.map(t=>G(`review:${n.id}:list:${t.def.id}`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)($,{children:t.def.title}),t.def.check?(0,V.jsx)(r,{runId:e.id,list:t}):(0,V.jsx)(f,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];t.error&&p.push(G(`review-error`,t.error,{tone:`error`}));let m=n.regenerate&&c.length>0;return p.push(X(`review:${n.id}:replies`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(Z,{primary:!0,busy:t.busy,onClick:()=>void t.accept(n.id),children:[(0,V.jsx)(S,{className:`size-4`}),` `,j(`run.accept`)]}),m&&c.length>1?c.map(({step:e})=>(0,V.jsx)(Z,{on:l===e.id,onClick:()=>u(e.id),children:e.title},e.id)):null]}))),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(J,{avatar:e.wizard.avatar,lines:p}),m?(0,V.jsx)(Me,{children:(0,V.jsx)(Fe,{multiline:!0,inputRef:d,busy:t.busy,placeholder:c.length>1&&!l?j(`run.feedbackPick`):j(`run.feedbackPlaceholder`),disabled:!l,onSend:e=>{let r=e.trim();return!r||!l?!1:(s(r),t.regenerate(n.id,l,r),!0)}})}):(0,V.jsx)(Q,{})]})}function nt({view:e,run:t,step:n,before:r,onRestart:i}){let o=e.shown.filter(e=>e.output),s=`/api/runs/${e.id}`,c=[...r,G(`result:${n.id}`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`font-display font-semibold text-[1.0625rem]`,children:n.title}),n.message?(0,V.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:n.message}):null]}),{anchor:!0}),...o.map(({step:e,output:t,formats:n,label:r})=>G(`result:${e.id}`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)($,{end:(0,V.jsx)(_,{base:s,stepId:e.id,formats:n,title:r??e.title}),children:r??e.title}),(0,V.jsx)(a,{base:s,step:e,output:t}),t?.assets?.some(e=>e.ai)?(0,V.jsx)(`p`,{className:`mt-3 text-[0.75rem] text-ink-3 leading-relaxed`,children:j(`ai.publish`)}):null]}),{wide:!0})),...e.lists.map(t=>G(`result:list:${t.def.id}`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)($,{end:(0,V.jsx)(k,{runId:e.id,list:t}),children:t.label??t.def.title}),(0,V.jsx)(f,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];return c.push(X(`result:replies`,(0,V.jsxs)(V.Fragment,{children:[o.length?(0,V.jsx)(ce,{runId:e.id,title:`${n.title} · ${e.wizard.title}`,initial:e.shareUrl?{url:e.shareUrl,expiresAt:e.expiresAt}:null}):null,i?(0,V.jsxs)(Z,{onClick:i,children:[(0,V.jsx)(d,{className:`size-4`}),` `,j(`run.again`)]}):null,e.canBack?(0,V.jsx)(Z,{onClick:()=>void t.back(),disabled:t.busy,children:j(`run.back`)}):null,e.keeps?(0,V.jsx)(`span`,{className:`ml-1`,children:(0,V.jsx)(m,{runId:e.id})}):null]}))),(0,V.jsx)(J,{avatar:e.wizard.avatar,lines:c})}function rt({runId:e,onRestart:t,onView:n,header:r,footer:a,talk:o=!1,call:s=!1}){let c=fe(e),{view:l}=c,[u,f]=(0,B.useState)(null),p=ke(e,l,c,u);(0,B.useEffect)(()=>{n?.(l)},[l,n]);let[m,h]=oe(),g=(0,B.useMemo)(()=>({runId:e,lang:l?.lang??i,readAloud:m,setReadAloud:h,voice:l?.talk?p:null,talk:o,call:!!s,bindPage:f}),[e,l?.lang,l?.talk,m,h,p,o,s]);F(l?.status===`running`&&!l.ask),R(l);let[_,v]=(0,B.useState)({}),[y,b]=(0,B.useState)(null);(0,B.useEffect)(()=>{l&&l.status!==`running`&&b(null)},[l]);let S;if(c.notFound)S=(0,V.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:j(`run.notFound`)});else if(!l)S=(0,V.jsx)(`div`,{className:`flex justify-center py-24 text-ink-4`,children:(0,V.jsx)(T,{})});else{let e=l.step,n=l.status===`waiting_input`,r=Ge(l,l.canBack&&n&&!c.busy?()=>void c.back():void 0);if(l.status===`running`&&l.ask)S=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(J,{avatar:l.wizard.avatar,lines:[...r,G(`ask:${l.ask.id}`,(0,V.jsx)(O,{runId:l.id,ask:l.ask}),{wide:!0})]}),(0,V.jsx)(Q,{})]});else if(l.status===`running`)S=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(J,{avatar:l.wizard.avatar,lines:[...r,...y?[K(`note`,y)]:[],G(`working:${e?.id}`,(0,V.jsx)(Xe,{view:l}),{wide:l.events.some(t=>t.stepId===e?.id&&Qe(t))?`most`:void 0})]}),(0,V.jsx)(Q,{placeholder:j(`run.working`)})]});else if(l.status===`failed`)S=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(J,{avatar:l.wizard.avatar,lines:[...r,G(`failed`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`font-medium`,children:j(`run.failed`)}),l.error?(0,V.jsx)(`span`,{className:`mt-0.5 block`,children:(0,V.jsx)(x,{text:l.error})}):null]}),{tone:`error`}),X(`failed:replies`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(Z,{primary:!0,busy:c.busy,onClick:()=>void c.retry(),children:[(0,V.jsx)(d,{className:`size-4`}),` `,j(`run.retry`)]}),l.canBack?(0,V.jsx)(Z,{onClick:()=>void c.back(),disabled:c.busy,children:j(`run.back`)}):null]}))]}),(0,V.jsx)(Q,{})]});else if(l.status===`cancelled`)S=(0,V.jsx)(J,{avatar:l.wizard.avatar,lines:[...r,G(`cancelled`,j(`run.cancelled`)),...t?[X(`cancelled:replies`,(0,V.jsxs)(Z,{primary:!0,onClick:t,children:[(0,V.jsx)(d,{className:`size-4`}),` `,j(`run.again`)]}))]:[]]});else if(e?.type===`page`)S=(0,V.jsx)(qe,{view:l,run:c,step:e,before:r},e.id);else if(e?.type===`review`){let t=l.shown.map(e=>e.output?.at??``).join(`|`);S=(0,V.jsx)(tt,{view:l,run:c,step:e,before:r,asked:_[e.id]??[],onNote:t=>{b(t),v(n=>({...n,[e.id]:[...n[e.id]??[],t]}))}},`${e.id}:${t}`)}else S=e?.type===`result`?(0,V.jsx)(nt,{view:l,run:c,step:e,before:r,onRestart:t}):(0,V.jsx)(J,{avatar:l.wizard.avatar,lines:r})}return s?(0,V.jsx)(q.Provider,{value:g,children:(0,V.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col lg:flex-row`,children:[(0,V.jsx)(Te,{voice:p,view:l,video:s===`video`,className:`h-[46dvh] shrink-0 lg:h-auto lg:min-h-0 lg:flex-1`}),(0,V.jsx)(`aside`,{className:`flex min-h-0 flex-1 flex-col border-border-soft border-t lg:w-[420px] lg:flex-none lg:border-t-0 lg:border-l`,children:(0,V.jsx)(Ne,{footer:a,children:S})})]})}):(0,V.jsx)(q.Provider,{value:g,children:(0,V.jsx)(Ne,{header:r,footer:a,children:S})})}export{J as a,Z as i,Ne as n,X as o,Q as r,je as s,rt as t};