@engenty/wizards-runtime 0.11.4 → 0.11.6

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 (92) hide show
  1. package/apps/runtime/dist/agents/architect.js +6 -7
  2. package/apps/runtime/dist/agents/chat-clients.js +3 -0
  3. package/apps/runtime/dist/agents/studio-assistant.js +26 -7
  4. package/apps/runtime/dist/agents/subscription.js +24 -11
  5. package/apps/runtime/dist/assistant/knows.js +1 -1
  6. package/apps/runtime/dist/auth/index.js +15 -2
  7. package/apps/runtime/dist/authoring/guide.js +2 -8
  8. package/apps/runtime/dist/credits/estimate.js +1 -1
  9. package/apps/runtime/dist/data/chat-models.json +116 -0
  10. package/apps/runtime/dist/db/migrations/tenant/0025_drop_mcp_servers.sql +1 -0
  11. package/apps/runtime/dist/db/migrations/tenant/meta/0025_snapshot.json +3959 -0
  12. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
  13. package/apps/runtime/dist/db/schema.js +0 -4
  14. package/apps/runtime/dist/docs/dev/plugins/events.md +2 -2
  15. package/apps/runtime/dist/docs/dev/wizard-format/agent-steps.md +1 -2
  16. package/apps/runtime/dist/docs/dev/wizard-format/wizard-file.md +6 -8
  17. package/apps/runtime/dist/docs/user-guide/cloud-sync.md +2 -2
  18. package/apps/runtime/dist/docs/user-guide/connectors.md +1 -10
  19. package/apps/runtime/dist/docs/user-guide/models.md +15 -5
  20. package/apps/runtime/dist/docs/user-guide/steps.md +2 -3
  21. package/apps/runtime/dist/engine/steps.js +126 -131
  22. package/apps/runtime/dist/env.js +5 -0
  23. package/apps/runtime/dist/live/views.js +1 -3
  24. package/apps/runtime/dist/mcp/tools.js +1 -1
  25. package/apps/runtime/dist/models.js +8 -9
  26. package/apps/runtime/dist/routes/studio.js +39 -6
  27. package/apps/runtime/dist/services/architect.js +5 -5
  28. package/apps/runtime/dist/services/chat-models.js +58 -0
  29. package/apps/runtime/dist/services/package-file.js +0 -1
  30. package/apps/runtime/dist/services/package.js +0 -10
  31. package/apps/runtime/dist/services/projects.js +1 -31
  32. package/apps/runtime/dist/services/spaces.js +5 -23
  33. package/apps/runtime/dist/services/wizards.js +8 -0
  34. package/apps/runtime/dist/sync/records.js +0 -9
  35. package/apps/runtime/dist/tools/index.js +0 -28
  36. package/apps/web/dist/assets/{AboutDialog-B7ThTqw4.js → AboutDialog-30Mc1_N_.js} +1 -1
  37. package/apps/web/dist/assets/{ChangelogDialog-DBpXTjxr.js → ChangelogDialog-Vjxg6JV8.js} +1 -1
  38. package/apps/web/dist/assets/{CodeEditor-BTcAUlGY.js → CodeEditor-CmMRfVhS.js} +1 -1
  39. package/apps/web/dist/assets/EditorPage-Di5KB-Ei.js +3 -0
  40. package/apps/web/dist/assets/{FlowPreview-Sjnlj0OO.js → FlowPreview-BkcO3iCf.js} +1 -1
  41. package/apps/web/dist/assets/{Harness-BKl73EG5.js → Harness-D_Hr80Fo.js} +1 -1
  42. package/apps/web/dist/assets/Marketplace-BxFBMUsi.js +2 -0
  43. package/apps/web/dist/assets/{NewWizardChannels-DarxdQRt.js → NewWizardChannels-BIzOtfc8.js} +1 -1
  44. package/apps/web/dist/assets/{NewWizardPage-BCoPZjp5.js → NewWizardPage-BenzMrPD.js} +1 -1
  45. package/apps/web/dist/assets/{OnboardingPage-qV_YA_mZ.js → OnboardingPage-DuckyzQr.js} +1 -1
  46. package/apps/web/dist/assets/{PreviewPane-B5_GY6Cv.js → PreviewPane-D9hmriSm.js} +2 -2
  47. package/apps/web/dist/assets/{ProjectPage-Bcc81_KO.js → ProjectPage-A8Z8cS1E.js} +1 -1
  48. package/apps/web/dist/assets/{PublicRunner-hlxaESAv.js → PublicRunner-QPvlEAxx.js} +1 -1
  49. package/apps/web/dist/assets/{ReadOnly-BUnTzhA3.js → ReadOnly-DFn32cvo.js} +1 -1
  50. package/apps/web/dist/assets/SettingsPage-ByP15ndy.js +2 -0
  51. package/apps/web/dist/assets/{SetupPage-DAgnVxDA.js → SetupPage-WNHH74hu.js} +1 -1
  52. package/apps/web/dist/assets/{SharePage-aKBNZDby.js → SharePage-Bw4TRWtv.js} +1 -1
  53. package/apps/web/dist/assets/changelog-Dr9tAFY9.js +1 -0
  54. package/apps/web/dist/assets/{coins-C8RAtYAu.js → coins-DTH3SKgZ.js} +1 -1
  55. package/apps/web/dist/assets/i18n-CLxuuhp_.js +55 -0
  56. package/apps/web/dist/assets/index-Bha72INy.css +1 -0
  57. package/apps/web/dist/assets/index-HhslPV6N.js +34 -0
  58. package/apps/web/dist/assets/oss-credits-CZT1KRIp.js +1 -0
  59. package/apps/web/dist/assets/{phone-DTuPPVhC.js → phone-DymZ7rLO.js} +1 -1
  60. package/apps/web/dist/assets/{runners-BcK_yEKU.js → runners-UfKeoOe4.js} +1 -1
  61. package/apps/web/dist/assets/{session-C7ciCzbV.js → session-COf_im0l.js} +1 -1
  62. package/apps/web/dist/assets/{settings-menu-b7am2SP5.js → settings-menu-mtOjI15L.js} +1 -1
  63. package/apps/web/dist/assets/{theme-BOAjs_xb.js → theme-DWoTWDAG.js} +1 -1
  64. package/apps/web/dist/assets/{ui-DKK_O65k.js → ui-D_0Xdrjh.js} +2 -2
  65. package/apps/web/dist/assets/{upload-Cbcw8l_0.js → upload-BizIzwxa.js} +1 -1
  66. package/apps/web/dist/assets/{useMutation-D8Bpwvs1.js → useMutation-BJfRETsQ.js} +1 -1
  67. package/apps/web/dist/assets/{volume-2-CgRP_A7r.js → volume-2-BGkyA8T9.js} +1 -1
  68. package/apps/web/dist/assets/{wrench-me5bf7bd.js → wrench-Be5zav03.js} +1 -1
  69. package/apps/web/dist/index.html +9 -9
  70. package/apps/web/dist/mcp/flow.html +3 -3
  71. package/node_modules/@engenty/wizards-shared/dist/assistant.d.ts +1 -0
  72. package/node_modules/@engenty/wizards-shared/dist/assistant.js +2 -0
  73. package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +0 -4
  74. package/node_modules/@engenty/wizards-shared/dist/definition.js +0 -3
  75. package/node_modules/@engenty/wizards-shared/dist/fit.d.ts +1 -1
  76. package/node_modules/@engenty/wizards-shared/dist/fit.js +0 -4
  77. package/node_modules/@engenty/wizards-shared/dist/marketplace.js +2 -2
  78. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +1 -2
  79. package/node_modules/@engenty/wizards-shared/dist/run.js +2 -4
  80. package/node_modules/@engenty/wizards-shared/dist/wizard-package.d.ts +0 -4
  81. package/node_modules/@engenty/wizards-shared/dist/wizard-package.js +0 -5
  82. package/package.json +1 -2
  83. package/plugin/.claude-plugin/plugin.json +1 -1
  84. package/plugin/plugin.json +1 -1
  85. package/apps/web/dist/assets/EditorPage-B_cFXR-B.js +0 -3
  86. package/apps/web/dist/assets/Marketplace-BNu-Hjzu.js +0 -2
  87. package/apps/web/dist/assets/SettingsPage-BoA-ykQU.js +0 -2
  88. package/apps/web/dist/assets/changelog-DwJOKc4z.js +0 -1
  89. package/apps/web/dist/assets/i18n-Bq6dt_qv.js +0 -55
  90. package/apps/web/dist/assets/index-BdwA-8jc.js +0 -34
  91. package/apps/web/dist/assets/index-DQc1EITf.css +0 -1
  92. package/apps/web/dist/assets/oss-credits-C6bPkfSE.js +0 -1
@@ -45,6 +45,7 @@ import { isAdminRole, mayBuild, mayCreate, projectWritable, requireAdmin, requir
45
45
  import { architectTurn } from "../services/architect.js";
46
46
  import { addMessage, assistantLayout, assistantWidth, currentChat, earlierChats, foldChat, newChat, openChat, readChat, turnHistory, } from "../services/assistant-chats.js";
47
47
  import { describeGradient, themeLooks } from "../services/brand.js";
48
+ import { chatCatalog, chatModelChoices, setChatModelChoice } from "../services/chat-models.js";
48
49
  import { checkForCloud, cloudLinked, cloudSpaces, cloudState, forgetCloud, publishAndSync, pushSharing, removeFromCloud, replaceCloudSpaces, rotateInCloud, syncToCloud, } from "../services/cloud.js";
49
50
  import { notFound, ServiceError } from "../services/errors.js";
50
51
  import { deleteFile, listFiles, readFile, writeFile } from "../services/files.js";
@@ -67,7 +68,7 @@ import { addTableRow, createPage, createTable, deletePage, deleteTable, deleteTa
67
68
  import { deleteTheme, listThemes, saveTheme } from "../services/themes.js";
68
69
  import { deleteTranslation, editTranslation, isLangCode, publishedDefinition, } from "../services/translations.js";
69
70
  import { draftWidgetPreview } from "../services/widgets.js";
70
- import { createWizard, deleteWizard, draftChanges, duplicateWizard, ownedWizard, rotateShareLink, updateWizardSettings, writableWizard, writeDraft, } from "../services/wizards.js";
71
+ import { createWizard, deleteWizard, draftChanges, duplicateWizard, hasWizards, ownedWizard, rotateShareLink, updateWizardSettings, writableWizard, writeDraft, } from "../services/wizards.js";
71
72
  import { deleteSetting, readSetting, writeSetting } from "../settings.js";
72
73
  import { projectShareTargets, sharePreview } from "../sharing/index.js";
73
74
  import { keepCloudForAll, mergesSeen, proposeMerge, resolveConflict, startSpace, stopSpace, syncAll, syncView, undoMerge, } from "../sync/client.js";
@@ -313,10 +314,17 @@ export const studio = new Hono()
313
314
  onboarding: await onboardingFor(user, person?.tenants ?? []),
314
315
  /** The organization still has the name the Manage-App gave it at sign-up: its first admin names it. */
315
316
  startingName: managed ? startingName(info?.name) : false,
317
+ /** The organization has made a wizard: the studio's offer to install it waits for that. */
318
+ hasWizards: await hasWizards(),
316
319
  /** What answers the studio's chats (Goose, the editor's chat): the text classes, a subscription, a key or the credits. */
317
- chatEngine: managed ? "models" : await chatEngine(await hasTextModel()),
320
+ chatEngine: managed ? "models" : await chatEngine(),
318
321
  /** The ways that can answer the studio's chats now. */
319
- chatWays: managed ? ["models"] : await chatWays(await hasTextModel()),
322
+ chatWays: managed ? ["models"] : await chatWays(),
323
+ /** The models of the chats per way, and what the person chose: everyday work and extra effort. */
324
+ chatModels: {
325
+ ways: (await chatCatalog()).ways,
326
+ chosen: await chatModelChoices(),
327
+ },
320
328
  aiReady: (await hasTextModel()) || (!managed && (await subscriptionClients()).length > 0),
321
329
  mcpUrl: `${env.appUrl}/api/mcp`,
322
330
  /**
@@ -507,6 +515,7 @@ export const studio = new Hono()
507
515
  project,
508
516
  writable,
509
517
  message,
518
+ extra: body.extra,
510
519
  page,
511
520
  browserTools: body.tools,
512
521
  lang: body.lang,
@@ -1249,8 +1258,8 @@ export const studio = new Hono()
1249
1258
  .post("/wizards/:id/chat", async (c) => {
1250
1259
  const user = c.get("user");
1251
1260
  const wizardId = c.req.param("id");
1252
- const { message } = z
1253
- .object({ message: z.string().min(1).max(8000) })
1261
+ const { message, extra } = z
1262
+ .object({ message: z.string().min(1).max(8000), extra: z.boolean().optional() })
1254
1263
  .parse(await c.req.json());
1255
1264
  await writableWizard(user.id, wizardId);
1256
1265
  if (!(await canSpend())) {
@@ -1260,7 +1269,7 @@ export const studio = new Hono()
1260
1269
  const abort = new AbortController();
1261
1270
  stream.onAbort(() => abort.abort());
1262
1271
  try {
1263
- const result = await asAssistantIn(wizardId, user, () => architectTurn(user.id, wizardId, message, requestLang(c), {
1272
+ const result = await asAssistantIn(wizardId, user, () => architectTurn(user.id, wizardId, message, requestLang(c), extra, {
1264
1273
  signal: abort.signal,
1265
1274
  onText: (delta) => {
1266
1275
  void stream.writeSSE({ event: "text", data: JSON.stringify(delta) });
@@ -1637,6 +1646,30 @@ export const studio = new Hono()
1637
1646
  }
1638
1647
  closeTerminal(c.req.param("id"));
1639
1648
  return c.json({ ok: true });
1649
+ })
1650
+ .put("/local/chat-models", async (c) => {
1651
+ if (managed) {
1652
+ return c.notFound();
1653
+ }
1654
+ const body = z
1655
+ .object({
1656
+ way: z.enum(CHAT_WAYS),
1657
+ normal: z.string().min(1).max(120).nullable().optional(),
1658
+ extra: z.string().min(1).max(120).nullable().optional(),
1659
+ })
1660
+ .parse(await c.req.json());
1661
+ // Null puts a model back to what the catalog names.
1662
+ const choice = (await chatModelChoices())[body.way] ?? {};
1663
+ for (const effort of ["normal", "extra"]) {
1664
+ if (body[effort] === null) {
1665
+ delete choice[effort];
1666
+ }
1667
+ else if (body[effort]) {
1668
+ choice[effort] = body[effort];
1669
+ }
1670
+ }
1671
+ await setChatModelChoice(body.way, choice);
1672
+ return c.json({ ok: true });
1640
1673
  })
1641
1674
  .put("/local/chat", async (c) => {
1642
1675
  if (managed) {
@@ -1,10 +1,9 @@
1
1
  import { eq } from "drizzle-orm";
2
2
  import { runArchitect } from "../agents/architect.js";
3
- import { chatEngine, subscriptionTurn } from "../agents/subscription.js";
3
+ import { chatTurnWay, subscriptionTurn } from "../agents/subscription.js";
4
4
  import { listConnectors } from "../connectors/external.js";
5
5
  import { db, schema } from "../db/client.js";
6
6
  import { managed } from "../manage.js";
7
- import { hasTextModel } from "../models.js";
8
7
  import { serverText } from "../texts.js";
9
8
  import { draftFiles, readFile } from "./files.js";
10
9
  import { ownedProject } from "./projects.js";
@@ -33,7 +32,7 @@ async function attachedImages(userId, wizardId, message) {
33
32
  /** One studio chat turn: the architect reads the draft, its workspace and the thread, and changes them with tools. */
34
33
  export async function architectTurn(userId, wizardId, message,
35
34
  /** The language the admin reads: the lines about what it does, and its stock replies. */
36
- lang, io) {
35
+ lang, extra, io) {
37
36
  // Asked before the first model call: a wizard that is not changed here costs nothing to refuse.
38
37
  const w = await writableWizard(userId, wizardId);
39
38
  const history = await wizardMessages(w.id);
@@ -42,7 +41,7 @@ lang, io) {
42
41
  const userMessageId = await addMessage(w.id, { role: "user", content: message });
43
42
  try {
44
43
  // A runtime that runs alone can answer the chat on the admin's own subscription or key.
45
- const engine = managed ? "models" : await chatEngine(await hasTextModel());
44
+ const engine = await chatTurnWay(managed);
46
45
  const result = engine === "claude" || engine === "codex" || engine === "cursor"
47
46
  ? {
48
47
  ...(await subscriptionTurn({
@@ -55,6 +54,7 @@ lang, io) {
55
54
  onThought: io.onThought,
56
55
  onBuilding: io.onBuilding,
57
56
  images,
57
+ extra,
58
58
  lang,
59
59
  })),
60
60
  unfinished: false,
@@ -64,8 +64,8 @@ lang, io) {
64
64
  userId,
65
65
  wizardId: w.id,
66
66
  message,
67
+ extra,
67
68
  history: history.map((m) => ({ role: m.role, content: m.content })),
68
- mcpServers: project.mcpServers.map((s) => ({ id: s.id, name: s.name })),
69
69
  connectors: await listConnectors(project.id),
70
70
  signal: io.signal,
71
71
  onText: io.onText,
@@ -0,0 +1,58 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { z } from "zod";
3
+ import { env } from "../env.js";
4
+ import { readSetting, writeSetting } from "../settings.js";
5
+ /**
6
+ * The models the studio's chats (Goose, the editor's chat) run on, per way: the model of
7
+ * everyday work and the one that extra effort switches to. The list is the server's word, so a
8
+ * new model needs no new release: the runtime asks `CHAT_MODELS_URL` at the start and every day
9
+ * after, and keeps what it last got. `data/chat-models.json` is the fallback in the repository.
10
+ */
11
+ const entry = z.object({ id: z.string().min(1), label: z.string().min(1) });
12
+ const way = z.object({
13
+ /** The model of everyday work. */
14
+ normal: z.string().min(1),
15
+ /** The model of extra effort. */
16
+ extra: z.string().min(1),
17
+ models: z.array(entry),
18
+ });
19
+ const catalog = z.object({
20
+ version: z.literal(1),
21
+ updated: z.string().optional(),
22
+ ways: z.record(z.string(), way),
23
+ });
24
+ const DAY = 24 * 3600_000;
25
+ const bundled = catalog.parse(JSON.parse(readFileSync(new URL("../data/chat-models.json", import.meta.url), "utf8")));
26
+ let current = bundled;
27
+ let asked = 0;
28
+ /** The catalog now: what the server last said, else the file in the repository. */
29
+ export async function chatCatalog() {
30
+ if (env.chatModelsUrl && Date.now() - asked > DAY) {
31
+ asked = Date.now();
32
+ try {
33
+ const res = await fetch(env.chatModelsUrl, { signal: AbortSignal.timeout(8_000) });
34
+ const parsed = res.ok ? catalog.safeParse(await res.json()) : null;
35
+ if (parsed?.success) {
36
+ current = parsed.data;
37
+ }
38
+ }
39
+ catch {
40
+ // The server does not answer: the last list stays.
41
+ }
42
+ }
43
+ return current;
44
+ }
45
+ const KEY = "chat-models";
46
+ export async function chatModelChoices() {
47
+ return (await readSetting(KEY)) ?? {};
48
+ }
49
+ export async function setChatModelChoice(wayId, choice) {
50
+ const all = await chatModelChoices();
51
+ const next = { ...all, [wayId]: choice };
52
+ await writeSetting(KEY, next);
53
+ }
54
+ /** The model id a way runs for everyday work or for extra effort: the person's, else the catalog's. */
55
+ export async function chatModelId(wayId, effort) {
56
+ const chosen = (await chatModelChoices())[wayId]?.[effort];
57
+ return chosen ?? (await chatCatalog()).ways[wayId]?.[effort] ?? null;
58
+ }
@@ -24,7 +24,6 @@ export function readManifest(raw) {
24
24
  version: 1,
25
25
  definition: raw,
26
26
  connectors: [],
27
- mcpServers: [],
28
27
  themes: [],
29
28
  };
30
29
  }
@@ -46,7 +46,6 @@ export async function exportWizard(userId, wizardId, options = {}) {
46
46
  const definition = live ? live.definition : w.draft;
47
47
  const project = await ownedProject(userId, w.projectId);
48
48
  const named = new Set((definition.connections ?? []).map((c) => c.connector));
49
- const servers = new Set(definition.steps.flatMap((s) => (s.type === "agent" ? (s.mcp ?? []) : [])));
50
49
  const manifest = {
51
50
  $schema: PACKAGE_SCHEMA_URL,
52
51
  format: PACKAGE_FORMAT,
@@ -61,9 +60,6 @@ export async function exportWizard(userId, wizardId, options = {}) {
61
60
  domain: c.domain,
62
61
  sourceKind: c.sourceKind,
63
62
  })),
64
- mcpServers: project.mcpServers
65
- .filter((s) => servers.has(s.id))
66
- .map((s) => ({ id: s.id, name: s.name })),
67
63
  themes: themesOf(definition.themes, project.themes),
68
64
  };
69
65
  const entries = {};
@@ -123,9 +119,6 @@ async function missing(userId, projectId, draft, manifest) {
123
119
  const project = await ownedProject(userId, projectId);
124
120
  const connectors = await listConnectors(project.id);
125
121
  const wanted = [...new Set((draft.connections ?? []).flatMap((c) => c.connector ?? []))];
126
- const servers = [
127
- ...new Set(draft.steps.flatMap((s) => (s.type === "agent" ? (s.mcp ?? []) : []))),
128
- ];
129
122
  return [
130
123
  ...wanted
131
124
  .filter((id) => !connectors.some((c) => c.id === id))
@@ -133,9 +126,6 @@ async function missing(userId, projectId, draft, manifest) {
133
126
  const told = manifest.connectors.find((c) => c.id === id);
134
127
  return `Connector „${told?.name ?? id}“${told?.domain ? ` (${told.domain})` : ""}`;
135
128
  }),
136
- ...servers
137
- .filter((id) => !project.mcpServers.some((s) => s.id === id))
138
- .map((id) => `MCP-Server „${manifest.mcpServers.find((s) => s.id === id)?.name ?? id}“`),
139
129
  ];
140
130
  }
141
131
  /** Makes a new wizard of a package in the project: the draft and its workspace, not published. */
@@ -16,13 +16,6 @@ import { notFound, ServiceError } from "./errors.js";
16
16
  import { forgetWizardLinks } from "./links.js";
17
17
  import { pushPages } from "./pages.js";
18
18
  import { removeProjectFiles } from "./project-files.js";
19
- const MASK = "••••";
20
- export const mcpServerSchema = z.object({
21
- id: z.string().regex(/^[a-z][a-z0-9_]{0,30}$/),
22
- name: z.string().min(1).max(60),
23
- url: z.string().url(),
24
- headers: z.record(z.string(), z.string()).optional(),
25
- });
26
19
  const sectionId = z.string().regex(/^[A-Za-z0-9_-]{1,40}$/);
27
20
  export const brandColorSchema = z.object({
28
21
  name: z.string().max(120),
@@ -145,7 +138,6 @@ export const projectPatchSchema = z.object({
145
138
  })
146
139
  .optional(),
147
140
  facts: z.array(projectFactSchema).max(PROJECT_LIMITS.facts).optional(),
148
- mcpServers: z.array(mcpServerSchema).max(10).optional(),
149
141
  });
150
142
  /**
151
143
  * How many projects the tenant works with: the number the Manage-App gives for it, else this
@@ -255,15 +247,6 @@ export async function listProjects(_userId, lang) {
255
247
  wizardCount: counts.find((x) => x.projectId === p.id)?.n ?? 0,
256
248
  }));
257
249
  }
258
- /** MCP server headers carry the admin's credentials: shown masked, kept when sent back masked. */
259
- export function maskedServers(p) {
260
- return p.mcpServers.map((s) => ({
261
- ...s,
262
- headers: s.headers
263
- ? Object.fromEntries(Object.keys(s.headers).map((k) => [k, MASK]))
264
- : undefined,
265
- }));
266
- }
267
250
  export async function createProject(_userId, name) {
268
251
  await requireBuild();
269
252
  await requireAdmin();
@@ -276,9 +259,7 @@ export async function createProject(_userId, name) {
276
259
  throw new ServiceError("refused", limit === 1 ? note("onlyOneSpaceAllowed") : note("mostSpaces", { count: limit }));
277
260
  }
278
261
  const id = nanoid(12);
279
- await db
280
- .insert(schema.project)
281
- .values({ id, tenantId: currentTenant(), name, brand: {}, mcpServers: [] });
262
+ await db.insert(schema.project).values({ id, tenantId: currentTenant(), name, brand: {} });
282
263
  spaceChanged("space.created", id);
283
264
  return { id };
284
265
  }
@@ -286,16 +267,6 @@ export async function updateProject(userId, projectId, patch) {
286
267
  const p = await ownedProject(userId, projectId);
287
268
  await requireWritable(p);
288
269
  await requireAdmin();
289
- const mcpServers = patch.mcpServers?.map((s) => {
290
- const before = p.mcpServers.find((x) => x.id === s.id);
291
- const headers = s.headers
292
- ? Object.fromEntries(Object.entries(s.headers).map(([k, v]) => [
293
- k,
294
- v === MASK ? (before?.headers?.[k] ?? "") : v,
295
- ]))
296
- : undefined;
297
- return { ...s, headers };
298
- });
299
270
  if (patch.facts && new Set(patch.facts.map((f) => f.key)).size !== patch.facts.length) {
300
271
  throw new ServiceError("invalid", note("twoEntriesSameKey"));
301
272
  }
@@ -309,7 +280,6 @@ export async function updateProject(userId, projectId, patch) {
309
280
  ...(patch.name ? { name: patch.name } : {}),
310
281
  ...(patch.brand ? { brand: brandAfter(p.brand, patch.brand) } : {}),
311
282
  ...(patch.facts ? { facts: patch.facts } : {}),
312
- ...(mcpServers ? { mcpServers } : {}),
313
283
  ...(page ? { page } : {}),
314
284
  updatedAt: new Date(),
315
285
  })
@@ -10,7 +10,7 @@ import { and, count, eq, inArray, isNull, notInArray, sql } from "drizzle-orm";
10
10
  import { nanoid } from "nanoid";
11
11
  import { z } from "zod";
12
12
  import { db, inTransaction, schema } from "../db/client.js";
13
- import { missingModels, unavoidableSteps } from "../engine/requirements.js";
13
+ import { missingModels } from "../engine/requirements.js";
14
14
  import { env } from "../env.js";
15
15
  import { spaceChanged } from "../plugins/events.js";
16
16
  import { sandboxEngine } from "../sandbox/index.js";
@@ -85,9 +85,9 @@ const stepsWith = (def, has) => def.steps.filter(has).map((s) => ({ id: s.id, ti
85
85
  /**
86
86
  * What of a wizard does not work on this runtime: what its validator says here (a connector
87
87
  * the project lacks, a plugin's tool), model classes nothing is bound to, the sandbox where
88
- * there is none, MCP servers the project does not know.
88
+ * there is none.
89
89
  */
90
- export async function serverProblems(def, issues, mcpServers) {
90
+ export async function serverProblems(def, issues) {
91
91
  const problems = issues.map((issue) => ({
92
92
  code: /connector/i.test(issue.message) ? "connector" : "invalid",
93
93
  blocking: true,
@@ -108,23 +108,6 @@ export async function serverProblems(def, issues, mcpServers) {
108
108
  problems.push({ code: "sandbox", blocking: false, steps, detail: "" });
109
109
  }
110
110
  }
111
- const unknown = new Set();
112
- const steps = stepsWith(def, (s) => {
113
- const lacking = s.type === "agent" ? (s.mcp ?? []).filter((id) => !mcpServers.includes(id)) : [];
114
- for (const id of lacking) {
115
- unknown.add(id);
116
- }
117
- return lacking.length > 0;
118
- });
119
- if (steps.length) {
120
- const unavoidable = unavoidableSteps(def);
121
- problems.push({
122
- code: "mcp",
123
- blocking: steps.some((s) => unavoidable.has(s.id)),
124
- steps,
125
- detail: [...unknown].join(", "),
126
- });
127
- }
128
111
  return problems;
129
112
  }
130
113
  /** What a wizard would lack here, asked before it is sent: no project is touched. */
@@ -136,7 +119,7 @@ export async function checkOnServer(input) {
136
119
  .map((c) => ({
137
120
  message: `Connection "${c.id}" uses connector "${c.connector}", which this project has not imported.`,
138
121
  }));
139
- return serverProblems(draft, [...issues, ...connectors], []);
122
+ return serverProblems(draft, [...issues, ...connectors]);
140
123
  }
141
124
  async function syncedProject(spaceId) {
142
125
  const p = await db.query.project.findFirst({
@@ -234,7 +217,6 @@ async function syncSpace(spaceId, space) {
234
217
  id: spaceId,
235
218
  tenantId: currentTenant(),
236
219
  origin: "local",
237
- mcpServers: [],
238
220
  ...values,
239
221
  });
240
222
  }
@@ -302,7 +284,7 @@ export async function syncWizard(rawSpaceId, rawWizardId, input) {
302
284
  if (!row) {
303
285
  throw notFound();
304
286
  }
305
- const problems = await serverProblems(draft, await draftIssues(row), project.mcpServers.map((s) => s.id));
287
+ const problems = await serverProblems(draft, await draftIssues(row));
306
288
  const runnable = !problems.some((p) => p.blocking);
307
289
  let publishedVersion = row.publishedVersion;
308
290
  if (runnable) {
@@ -96,6 +96,14 @@ export async function listWizards(_userId, projectId) {
96
96
  });
97
97
  return rows.map(wizardSummary);
98
98
  }
99
+ /** The organization has made a wizard: the studio offers itself as an app from then on. */
100
+ export async function hasWizards() {
101
+ const row = await db.query.wizard.findFirst({
102
+ columns: { id: true },
103
+ where: eq(schema.wizard.tenantId, currentTenant()),
104
+ });
105
+ return Boolean(row);
106
+ }
99
107
  export async function publishedVersion(w) {
100
108
  if (w.publishedVersion === null) {
101
109
  return null;
@@ -91,26 +91,17 @@ const space = {
91
91
  facts: p.facts,
92
92
  themes: p.themes,
93
93
  page: p.page ?? null,
94
- // A server's headers hold keys: they are entered on each side, like API keys.
95
- mcpServers: p.mcpServers.map(({ headers: _, ...s }) => s),
96
94
  },
97
95
  };
98
96
  },
99
97
  async write(id, _item, r) {
100
98
  const before = await db.query.project.findFirst({ where: eq(schema.project.id, id) });
101
- const mcpServers = arr(r.mcpServers).map((s) => ({
102
- id: String(s.id),
103
- name: String(s.name ?? ""),
104
- url: String(s.url ?? ""),
105
- headers: before?.mcpServers.find((x) => x.id === s.id)?.headers,
106
- }));
107
99
  const values = {
108
100
  name: str(r.name) ?? before?.name ?? "Space",
109
101
  brand: obj(r.brand),
110
102
  facts: arr(r.facts),
111
103
  themes: arr(r.themes),
112
104
  page: (r.page ?? null),
113
- mcpServers,
114
105
  };
115
106
  if (before) {
116
107
  await db
@@ -1,7 +1,6 @@
1
1
  import { anthropic } from "@ai-sdk/anthropic";
2
2
  import { isTextMime } from "@engenty/wizards-shared/workspace";
3
3
  import { createTool } from "@mastra/core/tools";
4
- import { MCPClient } from "@mastra/mcp";
5
4
  import { z } from "zod";
6
5
  import { documentMime, parseDocument } from "../documents/parse.js";
7
6
  import { generateImageMedia } from "../media/generate.js";
@@ -58,7 +57,6 @@ export async function buildStepTools(step, ctx, resolved, uploads) {
58
57
  const tools = {};
59
58
  const assets = [];
60
59
  const allowed = new Set(step.tools);
61
- let mcp = null;
62
60
  if (allowed.has("web_search")) {
63
61
  // Anthropic models search natively; other models search through the AI Gateway's tool.
64
62
  if (resolved.vendor === "anthropic") {
@@ -259,29 +257,6 @@ export async function buildStepTools(step, ctx, resolved, uploads) {
259
257
  },
260
258
  });
261
259
  }
262
- const servers = ctx.project.mcpServers.filter((s) => step.mcp?.includes(s.id));
263
- if (servers.length) {
264
- mcp = new MCPClient({
265
- id: `run-${ctx.runId}-${step.id}`,
266
- servers: Object.fromEntries(servers.map((s) => [
267
- s.id,
268
- { url: new URL(s.url), requestInit: { headers: s.headers ?? {} }, timeout: 60_000 },
269
- ])),
270
- });
271
- try {
272
- Object.assign(tools, await mcp.listTools());
273
- await ctx.emit("tool", {
274
- code: "mcpConnected",
275
- params: { names: servers.map((s) => s.name).join(", ") },
276
- });
277
- }
278
- catch (err) {
279
- await ctx.emit("info", {
280
- code: "mcpUnreachable",
281
- params: { detail: err.message },
282
- });
283
- }
284
- }
285
260
  // An installed client writes and runs code of its own.
286
261
  let instructions;
287
262
  if (allowed.has("code") && !isHarnessVendor(resolved.vendor)) {
@@ -295,8 +270,5 @@ export async function buildStepTools(step, ctx, resolved, uploads) {
295
270
  tools,
296
271
  assets,
297
272
  instructions,
298
- close: async () => {
299
- await mcp?.disconnect().catch(() => undefined);
300
- },
301
273
  };
302
274
  }
@@ -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{Bn as r,Jt as i,Nn as a,Xt as o,Yt as s,in as c,on as l,qt as u,sn as d,tn as f}from"./ui-DKK_O65k.js";import{t as p}from"./preload-helper-DpV6A1kQ.js";import{t as m}from"./logo-CGNoptDg.js";import{s as h}from"./i18n-Bq6dt_qv.js";import{_t as g,nt as _,vt as v}from"./index-BdwA-8jc.js";import{c as y,f as b}from"./settings-menu-b7am2SP5.js";import{ReleaseNotes as x,loadReleases as S,releaseDate as C,releaseLabel as w}from"./ChangelogDialog-DBpXTjxr.js";var T=e(t(),1),E=[{name:`engenty wizards`,description:`credit.engenty-wizards`,homepage:`https://github.com/engenty/wizards`,license:`FSL-1.1-MIT`},{name:`engenty`,description:`credit.engenty`,homepage:`https://github.com/engenty/engenty`,license:`FSL-1.1-MIT`}],D=[{name:`Mastra`,description:`credit.mastra`,homepage:`https://github.com/mastra-ai/mastra`,license:`Apache-2.0`},{name:`AI SDK`,description:`credit.ai-sdk`,homepage:`https://github.com/vercel/ai`,license:`Apache-2.0`},{name:`Model Context Protocol`,description:`credit.model-context-protocol`,homepage:`https://github.com/modelcontextprotocol/typescript-sdk`,license:`MIT`},{name:`Hono`,description:`credit.hono`,homepage:`https://github.com/honojs/hono`,license:`MIT`},{name:`Drizzle ORM`,description:`credit.drizzle-orm`,homepage:`https://github.com/drizzle-team/drizzle-orm`,license:`Apache-2.0`},{name:`libSQL`,description:`credit.libsql`,homepage:`https://github.com/tursodatabase/libsql`,license:`MIT`},{name:`Playwright`,description:`credit.playwright`,homepage:`https://github.com/microsoft/playwright`,license:`Apache-2.0`},{name:`React`,description:`credit.react`,homepage:`https://github.com/facebook/react`,license:`MIT`},{name:`Vite`,description:`credit.vite`,homepage:`https://github.com/vitejs/vite`,license:`MIT`},{name:`Tailwind CSS`,description:`credit.tailwind-css`,homepage:`https://github.com/tailwindlabs/tailwindcss`,license:`MIT`},{name:`React Flow`,description:`credit.react-flow`,homepage:`https://github.com/xyflow/xyflow`,license:`MIT`},{name:`TanStack Query`,description:`credit.tanstack-query`,homepage:`https://github.com/TanStack/query`,license:`MIT`},{name:`xterm.js`,description:`credit.xterm-js`,homepage:`https://github.com/xtermjs/xterm.js`,license:`MIT`},{name:`Lucide`,description:`credit.lucide`,homepage:`https://github.com/lucide-icons/lucide`,license:`ISC`},{name:`Geist & Geist Mono`,description:`credit.geist-geist-mono`,homepage:`https://github.com/vercel/geist-font`,license:`OFL-1.1`},{name:`Space Grotesk`,description:`credit.space-grotesk`,homepage:`https://github.com/floriankarsten/space-grotesk`,license:`OFL-1.1`},{name:`git-cliff`,description:`credit.git-cliff`,homepage:`https://github.com/orhun/git-cliff`,license:`MIT OR Apache-2.0`}],O=e(n(),1),k=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e));function A({name:e,homepage:t,version:n,license:r,description:i}){return(0,O.jsxs)(`li`,{className:`py-2.5`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2.5 gap-y-0.5`,children:[t?(0,O.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,O.jsx)(a,{"aria-hidden":!0,className:`size-3 text-ink-4`})]}):(0,O.jsx)(`span`,{className:`font-medium text-[0.875rem] text-ink`,children:e}),n?(0,O.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:n}):null,(0,O.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:r})]}),i?(0,O.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:i}):null]})}function j({title:e,hint:t,children:n}){return(0,O.jsxs)(`section`,{className:`mt-6`,children:[(0,O.jsx)(`h3`,{className:`border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:e}),t?(0,O.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3`,children:t}):null,n]})}function M({credits:e}){return(0,O.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:e.map(e=>(0,O.jsx)(A,{name:e.name,homepage:e.homepage,license:e.license,description:h(e.description)},e.name))})}function N({label:e,packages:t}){return(0,O.jsxs)(`div`,{className:`mt-4`,children:[(0,O.jsx)(`h4`,{className:`font-medium text-[0.75rem] text-ink-3 tracking-wide`,children:e}),(0,O.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:t.map(e=>(0,O.jsx)(A,{...e},e.name))})]})}function P({active:e}){let[t,n]=(0,T.useState)(null),[r,a]=(0,T.useState)(``);(0,T.useEffect)(()=>{if(!e||t)return;let r=!1;return p(()=>import(`./oss-credits-C6bPkfSE.js`).then(e=>{r||n(e.default)}),[]),()=>{r=!0}},[e,t]),(0,T.useEffect)(()=>{e||a(``)},[e]);let s=r.trim().toLowerCase(),c=e=>s?e.filter(e=>k(s,e.name,e.license,h(e.description))):e,l=e=>s?e.filter(e=>k(s,e.name,e.license,e.version)):e,u=c(E),d=c(D),m=t?[{id:`shared`,label:h(`about.creditsShared`),packages:l(t.shared)},...t.groups.map(e=>({id:e.id,label:e.label,packages:l(e.packages)}))].filter(e=>e.packages.length>0):[],g=u.length===0&&d.length===0&&m.length===0;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`p`,{className:`mb-4 text-[0.875rem] text-ink-3`,children:h(`about.creditsHint`)}),(0,O.jsx)(o,{type:`search`,value:r,placeholder:h(`about.search`),onChange:e=>a(e.target.value)}),u.length>0?(0,O.jsx)(j,{title:h(`about.creditsProduct`),children:(0,O.jsx)(M,{credits:u})}):null,d.length>0?(0,O.jsx)(j,{title:h(`about.creditsBuiltWith`),children:(0,O.jsx)(M,{credits:d})}):null,t===null?(0,O.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,O.jsx)(f,{})}):m.length>0?(0,O.jsx)(j,{title:h(`about.creditsDeps`),hint:s?void 0:h(`about.creditsDepsHint`),children:m.map(e=>(0,O.jsx)(N,{label:e.label,packages:e.packages},e.id))}):null,t!==null&&g?(0,O.jsx)(i,{children:h(`about.noMatches`)}):null]})}var F=[`new`,`earlier`,`credits`],I=e=>h(e===`new`?`about.tab.new`:e===`earlier`?`about.tab.earlier`:`about.credits`),L=e=>e===1?h(`about.change`):h(`about.changes`,{n:e});function R({me:e,active:t,initialTab:n=`new`}){let i=e?.mode===`local`,{data:a,latest:o}=g(i&&t),[s,u]=(0,T.useState)(null),[d,p]=(0,T.useState)(n);(0,T.useEffect)(()=>p(n),[n]);let E=b(F.indexOf(d)),D=a?.newer&&o?o:v;(0,T.useEffect)(()=>{if(!t)return;let e=!1;return u(null),S(D===`0.11.4`?void 0:D).then(t=>{e||u(t)}),()=>{e=!0}},[t,D]);let k=s?.find(e=>e.version===`v${D}`)??s?.[0]??null,A=s?.filter(e=>e!==k)??[],j=i?a?.kind??null:`cloud`;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`flex flex-col items-center pt-4 text-center`,children:[(0,O.jsx)(m,{size:96}),(0,O.jsxs)(`div`,{className:`mt-4 font-display font-semibold text-[1.5rem] tracking-tight`,children:[`engenty`,(0,O.jsx)(`span`,{className:`text-ember`,children:`.`}),(0,O.jsx)(`span`,{className:`ml-1.5 font-normal text-ink-3`,children:`wizards`})]}),(0,O.jsxs)(`div`,{className:`mt-1 text-[0.9375rem] text-ink-3 tabular-nums`,children:[h(`about.version`,{v}),j?` · ${h(`about.kind.${j}`)}`:``]})]}),i?(0,O.jsx)(`div`,{className:`mt-5`,children:(0,O.jsx)(_,{enabled:t})}):null,(0,O.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,O.jsx)(c,{value:d,onChange:p,options:F.map(e=>({id:e,label:I(e)})),label:h(`about.title`)})}),(0,O.jsxs)(`div`,{className:l(`mt-5`,y(E)),children:[d===`new`?s===null?(0,O.jsx)(`div`,{className:`flex justify-center py-6 text-ink-3`,children:(0,O.jsx)(f,{})}):k?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[w(k),(0,O.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:C(k)})]}),(0,O.jsx)(`div`,{className:`mt-3`,children:(0,O.jsx)(x,{release:k})})]}):(0,O.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:h(`about.changelogEmpty`)}):null,d===`earlier`?(0,O.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:A.map(e=>(0,O.jsxs)(`details`,{className:`group/r py-2`,children:[(0,O.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-baseline gap-3 text-[0.875rem] [&::-webkit-details-marker]:hidden`,children:[(0,O.jsx)(r,{className:`size-3.5 shrink-0 self-center text-ink-4 transition group-open/r:rotate-90`}),(0,O.jsx)(`span`,{className:`font-medium text-ink tabular-nums`,children:w(e)}),(0,O.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:C(e)}),(0,O.jsx)(`span`,{className:`ml-auto text-[0.8125rem] text-ink-4`,children:L(e.commits.length)})]}),(0,O.jsx)(`div`,{className:`mt-2 pl-6`,children:(0,O.jsx)(x,{release:e})})]},e.version??`unreleased`))}):null,d===`credits`?(0,O.jsx)(P,{active:!0}):null]},d)]})}function z({open:e,onClose:t,me:n}){return(0,O.jsxs)(u,{open:e,onClose:t,wide:!0,height:`tall`,children:[(0,O.jsx)(`div`,{className:`-mt-2 -mr-2 sticky top-0 z-10 flex h-0 justify-end`,children:(0,O.jsx)(s,{label:h(`common.close`),onClick:t,children:(0,O.jsx)(d,{className:`size-4`})})}),(0,O.jsx)(R,{me:n,active:e})]})}export{z as AboutDialog,R as AboutPanel};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Bn as r,Jt as i,Nn as a,Xt as o,Yt as s,in as c,on as l,qt as u,sn as d,tn as f}from"./ui-D_0Xdrjh.js";import{t as p}from"./preload-helper-DpV6A1kQ.js";import{t as m}from"./logo-CGNoptDg.js";import{s as h}from"./i18n-CLxuuhp_.js";import{_t as g,nt as _,vt as v}from"./index-HhslPV6N.js";import{c as y,f as b}from"./settings-menu-mtOjI15L.js";import{ReleaseNotes as x,loadReleases as S,releaseDate as C,releaseLabel as w}from"./ChangelogDialog-Vjxg6JV8.js";var T=e(t(),1),E=[{name:`engenty wizards`,description:`credit.engenty-wizards`,homepage:`https://github.com/engenty/wizards`,license:`FSL-1.1-MIT`},{name:`engenty`,description:`credit.engenty`,homepage:`https://github.com/engenty/engenty`,license:`FSL-1.1-MIT`}],D=[{name:`Mastra`,description:`credit.mastra`,homepage:`https://github.com/mastra-ai/mastra`,license:`Apache-2.0`},{name:`AI SDK`,description:`credit.ai-sdk`,homepage:`https://github.com/vercel/ai`,license:`Apache-2.0`},{name:`Model Context Protocol`,description:`credit.model-context-protocol`,homepage:`https://github.com/modelcontextprotocol/typescript-sdk`,license:`MIT`},{name:`Hono`,description:`credit.hono`,homepage:`https://github.com/honojs/hono`,license:`MIT`},{name:`Drizzle ORM`,description:`credit.drizzle-orm`,homepage:`https://github.com/drizzle-team/drizzle-orm`,license:`Apache-2.0`},{name:`libSQL`,description:`credit.libsql`,homepage:`https://github.com/tursodatabase/libsql`,license:`MIT`},{name:`Playwright`,description:`credit.playwright`,homepage:`https://github.com/microsoft/playwright`,license:`Apache-2.0`},{name:`React`,description:`credit.react`,homepage:`https://github.com/facebook/react`,license:`MIT`},{name:`Vite`,description:`credit.vite`,homepage:`https://github.com/vitejs/vite`,license:`MIT`},{name:`Tailwind CSS`,description:`credit.tailwind-css`,homepage:`https://github.com/tailwindlabs/tailwindcss`,license:`MIT`},{name:`React Flow`,description:`credit.react-flow`,homepage:`https://github.com/xyflow/xyflow`,license:`MIT`},{name:`TanStack Query`,description:`credit.tanstack-query`,homepage:`https://github.com/TanStack/query`,license:`MIT`},{name:`xterm.js`,description:`credit.xterm-js`,homepage:`https://github.com/xtermjs/xterm.js`,license:`MIT`},{name:`Lucide`,description:`credit.lucide`,homepage:`https://github.com/lucide-icons/lucide`,license:`ISC`},{name:`Geist & Geist Mono`,description:`credit.geist-geist-mono`,homepage:`https://github.com/vercel/geist-font`,license:`OFL-1.1`},{name:`Space Grotesk`,description:`credit.space-grotesk`,homepage:`https://github.com/floriankarsten/space-grotesk`,license:`OFL-1.1`},{name:`git-cliff`,description:`credit.git-cliff`,homepage:`https://github.com/orhun/git-cliff`,license:`MIT OR Apache-2.0`}],O=e(n(),1),k=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e));function A({name:e,homepage:t,version:n,license:r,description:i}){return(0,O.jsxs)(`li`,{className:`py-2.5`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2.5 gap-y-0.5`,children:[t?(0,O.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,O.jsx)(a,{"aria-hidden":!0,className:`size-3 text-ink-4`})]}):(0,O.jsx)(`span`,{className:`font-medium text-[0.875rem] text-ink`,children:e}),n?(0,O.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:n}):null,(0,O.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:r})]}),i?(0,O.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:i}):null]})}function j({title:e,hint:t,children:n}){return(0,O.jsxs)(`section`,{className:`mt-6`,children:[(0,O.jsx)(`h3`,{className:`border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:e}),t?(0,O.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3`,children:t}):null,n]})}function M({credits:e}){return(0,O.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:e.map(e=>(0,O.jsx)(A,{name:e.name,homepage:e.homepage,license:e.license,description:h(e.description)},e.name))})}function N({label:e,packages:t}){return(0,O.jsxs)(`div`,{className:`mt-4`,children:[(0,O.jsx)(`h4`,{className:`font-medium text-[0.75rem] text-ink-3 tracking-wide`,children:e}),(0,O.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:t.map(e=>(0,O.jsx)(A,{...e},e.name))})]})}function P({active:e}){let[t,n]=(0,T.useState)(null),[r,a]=(0,T.useState)(``);(0,T.useEffect)(()=>{if(!e||t)return;let r=!1;return p(()=>import(`./oss-credits-CZT1KRIp.js`).then(e=>{r||n(e.default)}),[]),()=>{r=!0}},[e,t]),(0,T.useEffect)(()=>{e||a(``)},[e]);let s=r.trim().toLowerCase(),c=e=>s?e.filter(e=>k(s,e.name,e.license,h(e.description))):e,l=e=>s?e.filter(e=>k(s,e.name,e.license,e.version)):e,u=c(E),d=c(D),m=t?[{id:`shared`,label:h(`about.creditsShared`),packages:l(t.shared)},...t.groups.map(e=>({id:e.id,label:e.label,packages:l(e.packages)}))].filter(e=>e.packages.length>0):[],g=u.length===0&&d.length===0&&m.length===0;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`p`,{className:`mb-4 text-[0.875rem] text-ink-3`,children:h(`about.creditsHint`)}),(0,O.jsx)(o,{type:`search`,value:r,placeholder:h(`about.search`),onChange:e=>a(e.target.value)}),u.length>0?(0,O.jsx)(j,{title:h(`about.creditsProduct`),children:(0,O.jsx)(M,{credits:u})}):null,d.length>0?(0,O.jsx)(j,{title:h(`about.creditsBuiltWith`),children:(0,O.jsx)(M,{credits:d})}):null,t===null?(0,O.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,O.jsx)(f,{})}):m.length>0?(0,O.jsx)(j,{title:h(`about.creditsDeps`),hint:s?void 0:h(`about.creditsDepsHint`),children:m.map(e=>(0,O.jsx)(N,{label:e.label,packages:e.packages},e.id))}):null,t!==null&&g?(0,O.jsx)(i,{children:h(`about.noMatches`)}):null]})}var F=[`new`,`earlier`,`credits`],I=e=>h(e===`new`?`about.tab.new`:e===`earlier`?`about.tab.earlier`:`about.credits`),L=e=>e===1?h(`about.change`):h(`about.changes`,{n:e});function R({me:e,active:t,initialTab:n=`new`}){let i=e?.mode===`local`,{data:a,latest:o}=g(i&&t),[s,u]=(0,T.useState)(null),[d,p]=(0,T.useState)(n);(0,T.useEffect)(()=>p(n),[n]);let E=b(F.indexOf(d)),D=a?.newer&&o?o:v;(0,T.useEffect)(()=>{if(!t)return;let e=!1;return u(null),S(D===`0.11.6`?void 0:D).then(t=>{e||u(t)}),()=>{e=!0}},[t,D]);let k=s?.find(e=>e.version===`v${D}`)??s?.[0]??null,A=s?.filter(e=>e!==k)??[],j=i?a?.kind??null:`cloud`;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`flex flex-col items-center pt-4 text-center`,children:[(0,O.jsx)(m,{size:96}),(0,O.jsxs)(`div`,{className:`mt-4 font-display font-semibold text-[1.5rem] tracking-tight`,children:[`engenty`,(0,O.jsx)(`span`,{className:`text-ember`,children:`.`}),(0,O.jsx)(`span`,{className:`ml-1.5 font-normal text-ink-3`,children:`wizards`})]}),(0,O.jsxs)(`div`,{className:`mt-1 text-[0.9375rem] text-ink-3 tabular-nums`,children:[h(`about.version`,{v}),j?` · ${h(`about.kind.${j}`)}`:``]})]}),i?(0,O.jsx)(`div`,{className:`mt-5`,children:(0,O.jsx)(_,{enabled:t})}):null,(0,O.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,O.jsx)(c,{value:d,onChange:p,options:F.map(e=>({id:e,label:I(e)})),label:h(`about.title`)})}),(0,O.jsxs)(`div`,{className:l(`mt-5`,y(E)),children:[d===`new`?s===null?(0,O.jsx)(`div`,{className:`flex justify-center py-6 text-ink-3`,children:(0,O.jsx)(f,{})}):k?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[w(k),(0,O.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:C(k)})]}),(0,O.jsx)(`div`,{className:`mt-3`,children:(0,O.jsx)(x,{release:k})})]}):(0,O.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:h(`about.changelogEmpty`)}):null,d===`earlier`?(0,O.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:A.map(e=>(0,O.jsxs)(`details`,{className:`group/r py-2`,children:[(0,O.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-baseline gap-3 text-[0.875rem] [&::-webkit-details-marker]:hidden`,children:[(0,O.jsx)(r,{className:`size-3.5 shrink-0 self-center text-ink-4 transition group-open/r:rotate-90`}),(0,O.jsx)(`span`,{className:`font-medium text-ink tabular-nums`,children:w(e)}),(0,O.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:C(e)}),(0,O.jsx)(`span`,{className:`ml-auto text-[0.8125rem] text-ink-4`,children:L(e.commits.length)})]}),(0,O.jsx)(`div`,{className:`mt-2 pl-6`,children:(0,O.jsx)(x,{release:e})})]},e.version??`unreleased`))}):null,d===`credits`?(0,O.jsx)(P,{active:!0}):null]},d)]})}function z({open:e,onClose:t,me:n}){return(0,O.jsxs)(u,{open:e,onClose:t,wide:!0,height:`tall`,children:[(0,O.jsx)(`div`,{className:`-mt-2 -mr-2 sticky top-0 z-10 flex h-0 justify-end`,children:(0,O.jsx)(s,{label:h(`common.close`),onClick:t,children:(0,O.jsx)(d,{className:`size-4`})})}),(0,O.jsx)(R,{me:n,active:e})]})}export{z as AboutDialog,R as AboutPanel};
@@ -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{Jt as r,Xt as i,on as a,qt as o,tn as s}from"./ui-DKK_O65k.js";import{t as c}from"./preload-helper-DpV6A1kQ.js";import{s as l}from"./i18n-Bq6dt_qv.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/,``):l(`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/wizards/v${e}/apps/web/src/about/changelog.json`,{signal:AbortSignal.timeout(5e3)});if(t.ok)return await t.json()}catch{}return(await c(async()=>{let{default:e}=await import(`./changelog-DwJOKc4z.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:a(`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:l(`about.breaking`)}):null]})]},e.id)})})}function y({open:e,onClose:t,version:n}){let[a,c]=(0,u.useState)(null),[f,h]=(0,u.useState)(``);(0,u.useEffect)(()=>{if(!e||a)return;let t=!1;return _(n).then(e=>{t||c(e)}),()=>{t=!0}},[e,a,n]),(0,u.useEffect)(()=>{e||h(``)},[e]);let y=a?g(a,f):[];return(0,d.jsxs)(o,{open:e,onClose:t,title:l(`about.changelog`),wide:!0,height:`tall`,children:[(0,d.jsx)(`p`,{className:`-mt-3 mb-4 text-[0.875rem] text-ink-3`,children:l(`about.changelogHint`)}),a===null?(0,d.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,d.jsx)(s,{})}):a.length===0?(0,d.jsx)(r,{children:l(`about.changelogEmpty`)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(i,{type:`search`,value:f,placeholder:l(`about.search`),onChange:e=>h(e.target.value)}),y.length===0?(0,d.jsx)(r,{children:l(`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{Jt as r,Xt as i,on as a,qt as o,tn as s}from"./ui-D_0Xdrjh.js";import{t as c}from"./preload-helper-DpV6A1kQ.js";import{s as l}from"./i18n-CLxuuhp_.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/,``):l(`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/wizards/v${e}/apps/web/src/about/changelog.json`,{signal:AbortSignal.timeout(5e3)});if(t.ok)return await t.json()}catch{}return(await c(async()=>{let{default:e}=await import(`./changelog-Dr9tAFY9.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:a(`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:l(`about.breaking`)}):null]})]},e.id)})})}function y({open:e,onClose:t,version:n}){let[a,c]=(0,u.useState)(null),[f,h]=(0,u.useState)(``);(0,u.useEffect)(()=>{if(!e||a)return;let t=!1;return _(n).then(e=>{t||c(e)}),()=>{t=!0}},[e,a,n]),(0,u.useEffect)(()=>{e||h(``)},[e]);let y=a?g(a,f):[];return(0,d.jsxs)(o,{open:e,onClose:t,title:l(`about.changelog`),wide:!0,height:`tall`,children:[(0,d.jsx)(`p`,{className:`-mt-3 mb-4 text-[0.875rem] text-ink-3`,children:l(`about.changelogHint`)}),a===null?(0,d.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,d.jsx)(s,{})}):a.length===0?(0,d.jsx)(r,{children:l(`about.changelogEmpty`)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(i,{type:`search`,value:f,placeholder:l(`about.search`),onChange:e=>h(e.target.value)}),y.length===0?(0,d.jsx)(r,{children:l(`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,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{s as r}from"./i18n-Bq6dt_qv.js";import{Ct as i,Et as a,J as o,K as s,Ot as c,Q as l,Tt as u,W as d,X as f,Z as p,_t as m,at as h,bt as g,ct as _,ft as v,gt as y,ht as b,it as x,kt as S,lt as C,mt as w,n as T,ot as ee,pt as te,rt as ne,tt as re,wt as ie,xt as ae,yt as oe}from"./dist-DzdNG7Sf.js";import{n as se,r as ce,t as le}from"./dist-DVpDdhG9.js";var ue=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,E=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(ue(e)):ue,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return ie(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=S(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=u(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(E.prototype[Symbol.iterator]=function(){return this});var de={from:-1,to:-1,match:/.*/.exec(``),precise:!0},D=`gm`+(/x/.unicode==null?``:`u`),fe=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=de,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new k(e,t,n,r,i);this.re=new RegExp(t,D+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=A(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=A(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},O=new WeakMap,pe=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=O.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return O.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),O.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},k=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=de,this.matchPos=A(e,r),this.re=new RegExp(t,D+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=pe.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=A(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=pe.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(fe.prototype[Symbol.iterator]=k.prototype[Symbol.iterator]=function(){return this});function me(e){try{return new RegExp(e,D),!0}catch{return!1}}function A(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var he=e=>{let t=p(e,`cm-goto-line`);if(t){let e=t.dom.querySelector(`input[type=text]`);return e&&e.select(),!0}let{state:n}=e,r=String(n.doc.lineAt(e.state.selection.main.head).number),{close:i,result:a}=h(e,{class:`cm-goto-line`,label:n.phrase(`Go to line`),input:{type:`text`,name:`line`,value:r},focus:!0,submitLabel:n.phrase(`go`)});return a.then(t=>{let r=t&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.elements.line.value);if(!r){e.dispatch({effects:i});return}let a=n.doc.lineAt(n.selection.main.head),[,o,c,l,u]=r,d=l?+l.slice(1):0,f=c?+c:a.number;if(c&&u){let e=f/100;o&&(e=e*(o==`-`?-1:1)+a.number/n.doc.lines),f=Math.round(n.doc.lines*e)}else c&&o&&(f=f*(o==`-`?-1:1)+a.number);let p=n.doc.line(Math.max(1,Math.min(n.doc.lines,f))),m=w.cursor(p.from+Math.max(0,Math.min(d,p.length)));e.dispatch({effects:[i,s.scrollIntoView(m.from,{y:`center`})],selection:m})}),!0},ge={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},_e=y.define({combine(e){return a(e,ge,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function ve(e){let t=[we,Ce];return e&&t.push(_e.of(e)),t}var ye=d.mark({class:`cm-selectionMatch`}),be=d.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function xe(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=v.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=v.Word)}function Se(e,t,n,r){return e(t.sliceDoc(n,n+1))==v.Word&&e(t.sliceDoc(r-1,r))==v.Word}var Ce=o.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(_e),{state:n}=e,r=n.selection;if(r.ranges.length>1)return d.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return d.none;let e=n.wordAt(i.head);if(!e)return d.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return d.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(xe(o,n,i.from,i.to)&&Se(o,n,i.from,i.to)))return d.none}else if(a=n.sliceDoc(i.from,i.to),!a)return d.none}let s=[];for(let r of e.visibleRanges){let e=new E(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||xe(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(be.range(r,a)):(r>=i.to||a<=i.from)&&s.push(ye.range(r,a)),s.length>t.maxMatches))return d.none}}return d.set(s)}},{decorations:e=>e.decorations}),we=s.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Te=({state:e,dispatch:t})=>{let{selection:n}=e,r=w.create(n.ranges.map(t=>e.wordAt(t.head)||w.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)};function Ee(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new E(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new E(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var De=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Te({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=Ee(e,r);return i?(t(e.update({selection:e.selection.addRange(w.range(i.from,i.to),!1),effects:s.scrollIntoView(i.to)})),!0):!1},j=y.define({combine(e){return a(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new qe(e),scrollToMatch:e=>s.scrollIntoView(e)})}});function Oe(e){return e?[j.of(e),Z]:Z}var M=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||me(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{s as r}from"./i18n-CLxuuhp_.js";import{Ct as i,Et as a,J as o,K as s,Ot as c,Q as l,Tt as u,W as d,X as f,Z as p,_t as m,at as h,bt as g,ct as _,ft as v,gt as y,ht as b,it as x,kt as S,lt as C,mt as w,n as T,ot as ee,pt as te,rt as ne,tt as re,wt as ie,xt as ae,yt as oe}from"./dist-DzdNG7Sf.js";import{n as se,r as ce,t as le}from"./dist-DVpDdhG9.js";var ue=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,E=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(ue(e)):ue,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return ie(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=S(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=u(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(E.prototype[Symbol.iterator]=function(){return this});var de={from:-1,to:-1,match:/.*/.exec(``),precise:!0},D=`gm`+(/x/.unicode==null?``:`u`),fe=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=de,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new k(e,t,n,r,i);this.re=new RegExp(t,D+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=A(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=A(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},O=new WeakMap,pe=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=O.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return O.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),O.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},k=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=de,this.matchPos=A(e,r),this.re=new RegExp(t,D+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=pe.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=A(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=pe.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(fe.prototype[Symbol.iterator]=k.prototype[Symbol.iterator]=function(){return this});function me(e){try{return new RegExp(e,D),!0}catch{return!1}}function A(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var he=e=>{let t=p(e,`cm-goto-line`);if(t){let e=t.dom.querySelector(`input[type=text]`);return e&&e.select(),!0}let{state:n}=e,r=String(n.doc.lineAt(e.state.selection.main.head).number),{close:i,result:a}=h(e,{class:`cm-goto-line`,label:n.phrase(`Go to line`),input:{type:`text`,name:`line`,value:r},focus:!0,submitLabel:n.phrase(`go`)});return a.then(t=>{let r=t&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.elements.line.value);if(!r){e.dispatch({effects:i});return}let a=n.doc.lineAt(n.selection.main.head),[,o,c,l,u]=r,d=l?+l.slice(1):0,f=c?+c:a.number;if(c&&u){let e=f/100;o&&(e=e*(o==`-`?-1:1)+a.number/n.doc.lines),f=Math.round(n.doc.lines*e)}else c&&o&&(f=f*(o==`-`?-1:1)+a.number);let p=n.doc.line(Math.max(1,Math.min(n.doc.lines,f))),m=w.cursor(p.from+Math.max(0,Math.min(d,p.length)));e.dispatch({effects:[i,s.scrollIntoView(m.from,{y:`center`})],selection:m})}),!0},ge={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},_e=y.define({combine(e){return a(e,ge,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function ve(e){let t=[we,Ce];return e&&t.push(_e.of(e)),t}var ye=d.mark({class:`cm-selectionMatch`}),be=d.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function xe(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=v.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=v.Word)}function Se(e,t,n,r){return e(t.sliceDoc(n,n+1))==v.Word&&e(t.sliceDoc(r-1,r))==v.Word}var Ce=o.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(_e),{state:n}=e,r=n.selection;if(r.ranges.length>1)return d.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return d.none;let e=n.wordAt(i.head);if(!e)return d.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return d.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(xe(o,n,i.from,i.to)&&Se(o,n,i.from,i.to)))return d.none}else if(a=n.sliceDoc(i.from,i.to),!a)return d.none}let s=[];for(let r of e.visibleRanges){let e=new E(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||xe(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(be.range(r,a)):(r>=i.to||a<=i.from)&&s.push(ye.range(r,a)),s.length>t.maxMatches))return d.none}}return d.set(s)}},{decorations:e=>e.decorations}),we=s.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Te=({state:e,dispatch:t})=>{let{selection:n}=e,r=w.create(n.ranges.map(t=>e.wordAt(t.head)||w.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)};function Ee(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new E(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new E(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var De=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Te({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=Ee(e,r);return i?(t(e.update({selection:e.selection.addRange(w.range(i.from,i.to),!1),effects:s.scrollIntoView(i.to)})),!0):!1},j=y.define({combine(e){return a(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new qe(e),scrollToMatch:e=>s.scrollIntoView(e)})}});function Oe(e){return e?[j.of(e),Z]:Z}var M=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||me(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
2
2
  `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Fe(this):new Me(this)}getCursor(e,t=0,n){let r=e.doc?e:b.create({doc:e});return n??=r.doc.length,this.regexp?P(this,r,t,n):N(this,r,t,n)}},ke=class{constructor(e){this.spec=e}};function Ae(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function N(e,t,n,r){let i;return e.wholeWord&&(i=je(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=Ae(e.test,t,i)),new E(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function je(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(F(i,n-a))!=v.Word||t(I(i,n-a))!=v.Word)&&(t(I(i,r-a))!=v.Word||t(F(i,r-a))!=v.Word))}var Me=class extends ke{constructor(e){super(e)}nextMatch(e,t,n){let r=N(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=N(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=N(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=N(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=N(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function Ne(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function P(e,t,n,r){let i;return e.wholeWord&&(i=Pe(t.charCategorizer(t.selection.main.head))),e.test&&(i=Ne(e.test,t,i)),new fe(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function F(e,t){return e.slice(c(e,t,!1),t)}function I(e,t){return e.slice(t,c(e,t))}function Pe(e){return(t,n,r)=>!r[0].length||(e(F(r.input,r.index))!=v.Word||e(I(r.input,r.index))!=v.Word)&&(e(I(r.input,r.index+r[0].length))!=v.Word||e(F(r.input,r.index+r[0].length))!=v.Word)}var Fe=class extends ke{nextMatch(e,t,n){let r=P(this.spec,e,n,e.doc.length).next();return r.done&&(r=P(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=P(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=P(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=P(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},L=g.define(),R=g.define(),z=ae.define({create(e){return new B(K(e).create(),null)},update(e,t){for(let n of t.effects)n.is(L)?e=new B(n.value.create(),e.panel):n.is(R)&&(e=new B(e.query,n.value?G:null));return e},provide:e=>ee.from(e,e=>e.panel)}),B=class{constructor(e,t){this.query=e,this.panel=t}},Ie=d.mark({class:`cm-searchMatch`}),Le=d.mark({class:`cm-searchMatch cm-searchMatch-selected`}),Re=o.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(z))}update(e){let t=e.state.field(z);(t!=e.startState.field(z)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return d.none;let{view:n}=this,r=new oe;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?Le:Ie)})}return r.finish()}},{decorations:e=>e.decorations});function V(e){return t=>{let n=t.state.field(z,!1);return n&&n.query.spec.valid?e(t,n):We(t)}}var H=V((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=w.single(r.from,r.to),a=e.state.facet(j);return e.dispatch({selection:i,effects:[X(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),Ue(e),!0}),U=V((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=w.single(i.from,i.to),o=e.state.facet(j);return e.dispatch({selection:a,effects:[X(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),Ue(e),!0}),ze=V((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:w.create(n.map(e=>w.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),Be=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new E(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(w.range(t.value.from,t.value.to))}return t(e.update({selection:w.create(a,o),userEvent:`select.search.matches`})),!0},W=V((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,c=[],l,u,d=[];o.precise?o.from==r&&o.to==i&&(u=n.toText(t.getReplacement(o)),c.push({from:o.from,to:o.to,insert:u}),o=t.nextMatch(n,o.from,o.to),d.push(s.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):o=t.nextMatch(n,o.from,o.to);let f=e.state.changes(c);return o&&(l=w.single(o.from,o.to).map(f),d.push(X(e,o)),d.push(n.facet(j).scrollToMatch(l.main,e))),e.dispatch({changes:f,selection:l,effects:d,userEvent:`input.replace`}),!0}),Ve=V((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=r;a&&n.push({from:e,to:i,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:s.announce.of(r),userEvent:`input.replace.all`}),!0});function G(e){return e.state.facet(j).createPanel(e)}function K(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(j);return new M({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function He(e){let t=l(e,G);return t&&t.dom.querySelector(`[main-field]`)}function Ue(e){let t=He(e);t&&t==e.root.activeElement&&t.select()}var We=e=>{let t=e.state.field(z,!1);if(t&&t.panel){let n=He(e);if(n&&n!=e.root.activeElement){let r=K(e.state,t.query.spec);r.valid&&e.dispatch({effects:L.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[R.of(!0),t?L.of(K(e.state,t.query.spec)):g.appendConfig.of(Z)]});return!0},Ge=e=>{let t=e.state.field(z,!1);if(!t||!t.panel)return!1;let n=l(e,G);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:R.of(!1)}),!0},Ke=[{key:`Mod-f`,run:We,scope:`editor search-panel`},{key:`F3`,run:H,shift:U,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:H,shift:U,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:Ge,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:Be},{key:`Mod-Alt-g`,run:he},{key:`Mod-d`,run:De,preventDefault:!0}],qe=class{constructor(e){this.view=e;let t=this.query=e.state.field(z).query.spec;this.commit=this.commit.bind(this),this.searchField=_(`input`,{value:t.search,placeholder:q(e,`Find`),"aria-label":q(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=_(`input`,{value:t.replace,placeholder:q(e,`Replace`),"aria-label":q(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=_(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=_(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=_(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return _(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=_(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>H(e),[q(e,`next`)]),n(`prev`,()=>U(e),[q(e,`previous`)]),n(`select`,()=>ze(e),[q(e,`all`)]),_(`label`,null,[this.caseField,q(e,`match case`)]),_(`label`,null,[this.reField,q(e,`regexp`)]),_(`label`,null,[this.wordField,q(e,`by word`)]),...e.state.readOnly?[]:[_(`br`),this.replaceField,n(`replace`,()=>W(e),[q(e,`replace`)]),n(`replaceAll`,()=>Ve(e),[q(e,`replace all`)])],_(`button`,{name:`close`,onclick:()=>Ge(e),"aria-label":q(e,`close`),type:`button`},[`×`])])}commit(){let e=new M({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:L.of(e)}))}keydown(e){x(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?U:H)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),W(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(L)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(j).top}};function q(e,t){return e.state.phrase(t)}var J=30,Y=/[\s\.,:;?!]/;function X(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-J),o=Math.min(i,n+J),c=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<J;e++)if(!Y.test(c[e+1])&&Y.test(c[e])){c=c.slice(e);break}}if(o!=i){for(let e=c.length-1;e>c.length-J;e--)if(!Y.test(c[e-1])&&Y.test(c[e])){c=c.slice(0,e);break}}return s.announce.of(`${e.state.phrase(`current match`)}. ${c} ${e.state.phrase(`on line`)} ${r.number}.`)}var Je=s.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),Z=[z,m.low(Re),Je],Q=e(t(),1),Ye=e(n(),1),$=C.define();function Xe(e,t){let n=e.state.doc.toString();if(n===t)return;let r=0;for(;r<n.length&&r<t.length&&n[r]===t[r];)r++;let a=n.length,o=t.length;for(;a>r&&o>r&&n[a-1]===t[o-1];)a--,o--;e.dispatch({changes:{from:r,to:a,insert:t.slice(r,o)},annotations:[$.of(!0),i.addToHistory.of(!1)]})}var Ze=(e,t)=>s.theme({"&":{color:e===`dark`?`oklch(92% 0.02 260)`:`var(--ink)`,backgroundColor:`transparent`,fontSize:t===`json`?`0.75rem`:`0.9375rem`},"&.cm-focused":{outline:`none`},".cm-scroller":{fontFamily:t===`json`?`var(--f-mono)`:`var(--f-ui)`,lineHeight:t===`json`?`1.6`:`1.65`},".cm-content":{padding:t===`json`?`0.625rem 0`:`1rem 0`,caretColor:e===`dark`?`white`:`var(--ink)`},".cm-line":{padding:t===`json`?`0 0.75rem`:`0 1rem`},".cm-cursor, .cm-dropCursor":{borderLeftColor:e===`dark`?`white`:`var(--ink)`},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:`color-mix(in oklch, var(--ember) 28%, transparent)`},".cm-placeholder":{color:`var(--ink-4)`},".cm-panels":{backgroundColor:`var(--card)`,color:`var(--ink)`,borderColor:`var(--border)`},".cm-panels.cm-panels-bottom":{borderTop:`1px solid var(--border)`},".cm-search":{fontFamily:`var(--f-ui)`,fontSize:`0.8125rem`},".cm-textfield":{backgroundColor:`var(--paper)`,border:`1px solid var(--input)`,borderRadius:`0.375rem`,color:`var(--ink)`},".cm-button":{backgroundImage:`none`,backgroundColor:`var(--accent)`,border:`1px solid var(--border)`,borderRadius:`0.375rem`,color:`var(--ink)`},".cm-searchMatch":{backgroundColor:`color-mix(in oklch, var(--ember) 22%, transparent)`},".cm-searchMatch-selected":{backgroundColor:`color-mix(in oklch, var(--ember) 45%, transparent)`},".cm-selectionMatch":{backgroundColor:`color-mix(in oklch, var(--ink) 10%, transparent)`},".cm-gutters":{backgroundColor:`transparent`,border:`none`},".cm-lintRange-error":{backgroundImage:`none`,textDecoration:`underline wavy oklch(70% 0.18 25)`},".cm-tooltip.cm-tooltip-autocomplete":{padding:`0.25rem`},".cm-tooltip.cm-tooltip-autocomplete > ul":{fontFamily:`var(--f-ui)`,maxHeight:`16rem`},".cm-tooltip.cm-tooltip-autocomplete > ul > li":{padding:`0.375rem 0.625rem`,borderRadius:`0.375rem`,display:`flex`,gap:`0.75rem`,alignItems:`baseline`},".cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected]":{backgroundColor:`var(--accent)`,color:`var(--ink)`},".cm-completionLabel":{fontSize:`0.875rem`},".cm-completionDetail":{fontStyle:`normal`,fontSize:`0.75rem`,color:`var(--ink-3)`,marginLeft:`auto`},".cm-tooltip":{backgroundColor:`var(--card)`,color:`var(--ink)`,border:`1px solid var(--border)`,borderRadius:`0.5rem`}},{dark:e===`dark`}),Qe=()=>b.phrases.of({Find:r(`code.find`),Replace:r(`code.replace`),next:r(`code.next`),previous:r(`code.previous`),all:r(`code.all`),"match case":r(`code.matchCase`),regexp:r(`code.regexp`),"by word":r(`code.byWord`),replace:r(`code.replace`),"replace all":r(`code.replaceAll`),close:r(`code.close`),"Go to line":r(`code.goToLine`),go:r(`code.go`)});function $e(e){return e.length?T({icons:!1,override:[t=>{let n=t.matchBefore(/\]\([^)\s]*/);if(!n)return null;let r=n.text.slice(2).toLowerCase();return{from:n.from+2,filter:!1,options:e.filter(e=>!r||e.title.toLowerCase().includes(r)||e.path.toLowerCase().includes(r)).slice(0,50).map(e=>({label:e.title,detail:e.path,type:e.kind,apply:e.path}))}}]}):[]}function et(e,t){let n=e.state.doc.lineAt(t);for(let e of n.text.matchAll(/\[[^\]]*\]\(([^)\s]+)\)/g)){let r=n.from+(e.index??0);if(t>=r&&t<=r+e[0].length)return e[1]??null}return null}function tt(e){return s.domEventHandlers({mousedown(t,n){if(!(t.metaKey||t.ctrlKey))return!1;let r=n.posAtCoords({x:t.clientX,y:t.clientY}),i=r===null?null:et(n,r);return i?(t.preventDefault(),e(i),!0):!1}})}function nt(e){if(!e.length)return[];let t=t=>{let n=[];for(let{from:r,to:i}of t.visibleRanges)for(let a=r;a<=i;){let r=t.state.doc.lineAt(a),i=/^#{1,6}\s+(.+?)\s*#*$/.exec(r.text)?.[1]?.toLowerCase(),o=i?e.find(e=>e.heading.toLowerCase()===i):void 0;o&&n.push(d.line({attributes:{title:o.title,style:`box-shadow: inset 3px 0 0 ${o.color}`}}).range(r.from)),a=r.to+1}return d.set(n)};return o.define(e=>({decorations:t(e),update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=t(e.view))}}),{decorations:e=>e.decorations})}function rt({value:e,onChange:t,language:n,ariaLabel:r,placeholder:i,readOnly:a=!1,tone:o=`light`,onCaret:c,onBlur:l,className:u,extensions:d=[],handle:p,marks:m=[],links:h=[],onLink:g,languageParts:_}){let v=(0,Q.useRef)(new te),y=(0,Q.useRef)(new te),x=(0,Q.useRef)(null),S=(0,Q.useRef)(null),C=(0,Q.useRef)({onChange:t,onCaret:c,onBlur:l,onLink:g});C.current={onChange:t,onCaret:c,onBlur:l,onLink:g},(0,Q.useImperativeHandle)(p,()=>({view:()=>S.current}),[]),(0,Q.useEffect)(()=>{if(!x.current)return;let t=new s({parent:x.current,state:b.create({doc:e,extensions:[se(),f(),Oe({top:!1}),ve(),re.of([...Ke,...ce,...le]),Qe(),Ze(o,n),..._,b.readOnly.of(a),s.contentAttributes.of({"aria-label":r}),i?ne(i):[],s.updateListener.of(e=>{e.docChanged&&!e.transactions.some(e=>e.annotation($))&&C.current.onChange(e.state.doc.toString()),(e.selectionSet||e.docChanged)&&C.current.onCaret?.(e.state.doc.toString(),e.state.selection.main.head),e.focusChanged&&!e.view.hasFocus&&C.current.onBlur?.()}),v.current.of(nt(m)),y.current.of($e(h)),tt(e=>C.current.onLink?.(e)),...d]})});return S.current=t,()=>{t.destroy(),S.current=null}},[]);let w=JSON.stringify(m);(0,Q.useEffect)(()=>{S.current?.dispatch({effects:v.current.reconfigure(nt(m))})},[w]);let T=JSON.stringify(h);return(0,Q.useEffect)(()=>{S.current?.dispatch({effects:y.current.reconfigure($e(h))})},[T]),(0,Q.useEffect)(()=>{S.current&&Xe(S.current,e)},[e]),(0,Ye.jsx)(`div`,{ref:x,className:u})}export{Xe as applyText,rt as default,$ as remote};