litepaseo 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +46 -13
  3. package/dist/server/cli.mjs +189 -7
  4. package/dist/web/assets/{CodeBlockNode-fLbELjCG.js → CodeBlockNode-BOQ7WC72.js} +1 -1
  5. package/dist/web/assets/CodeBlockNode-BOQ7WC72.js.br +0 -0
  6. package/dist/web/assets/CodeBlockNode-BOQ7WC72.js.gz +0 -0
  7. package/dist/web/assets/FileViewer-16UXxzOe.js +2 -0
  8. package/dist/web/assets/FileViewer-16UXxzOe.js.br +0 -0
  9. package/dist/web/assets/FileViewer-16UXxzOe.js.gz +0 -0
  10. package/dist/web/assets/FileViewer-T756VVq4.css +1 -0
  11. package/dist/web/assets/FileViewer-T756VVq4.css.br +0 -0
  12. package/dist/web/assets/FileViewer-T756VVq4.css.gz +0 -0
  13. package/dist/web/assets/{FilesPanel-B1YfdWK8.js → FilesPanel-CdDybrQn.js} +1 -1
  14. package/dist/web/assets/FilesPanel-CdDybrQn.js.br +0 -0
  15. package/dist/web/assets/FilesPanel-CdDybrQn.js.gz +0 -0
  16. package/dist/web/assets/MarkdownMessage-Bm42-B56.js +199 -0
  17. package/dist/web/assets/MarkdownMessage-Bm42-B56.js.br +0 -0
  18. package/dist/web/assets/MarkdownMessage-Bm42-B56.js.gz +0 -0
  19. package/dist/web/assets/{PreCodeBlock-3ozveRNf.js → PreCodeBlock-BiQ6xAvM.js} +1 -1
  20. package/dist/web/assets/{PreCodeBlock.vue_vue_type_style_index_0_lang-BPnMZFbo.js → PreCodeBlock.vue_vue_type_style_index_0_lang-DUZXIc-h.js} +1 -1
  21. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-DUZXIc-h.js.br +0 -0
  22. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-DUZXIc-h.js.gz +0 -0
  23. package/dist/web/assets/{TerminalPanel-BR2okuCE.js → TerminalPanel-B5K5NCf0.js} +1 -1
  24. package/dist/web/assets/TerminalPanel-B5K5NCf0.js.br +0 -0
  25. package/dist/web/assets/TerminalPanel-B5K5NCf0.js.gz +0 -0
  26. package/dist/web/assets/{Tooltip-Dh7ELGI1.js → Tooltip-ClqPy17d.js} +1 -1
  27. package/dist/web/assets/Tooltip-ClqPy17d.js.br +0 -0
  28. package/dist/web/assets/Tooltip-ClqPy17d.js.gz +0 -0
  29. package/dist/web/assets/highlight-BnTrj1LT.js +5 -0
  30. package/dist/web/assets/highlight-BnTrj1LT.js.br +0 -0
  31. package/dist/web/assets/highlight-BnTrj1LT.js.gz +0 -0
  32. package/dist/web/assets/index-By8I8BM7.js +32 -0
  33. package/dist/web/assets/index-By8I8BM7.js.br +0 -0
  34. package/dist/web/assets/index-By8I8BM7.js.gz +0 -0
  35. package/dist/web/assets/index-CITaZKmy.css +1 -0
  36. package/dist/web/assets/index-CITaZKmy.css.br +0 -0
  37. package/dist/web/assets/index-CITaZKmy.css.gz +0 -0
  38. package/dist/web/assets/{index10-BXOnBXXV.js → index10-BG65E54y.js} +1 -1
  39. package/dist/web/assets/index10-BG65E54y.js.br +0 -0
  40. package/dist/web/assets/index10-BG65E54y.js.gz +0 -0
  41. package/dist/web/assets/index3-6tLrzhUa.js +1 -0
  42. package/dist/web/assets/index4-CZn-viSK.js +1 -0
  43. package/dist/web/assets/{index5-BrR0S3K6.js → index5-CzcXp9wR.js} +1 -1
  44. package/dist/web/assets/index5-CzcXp9wR.js.br +0 -0
  45. package/dist/web/assets/index5-CzcXp9wR.js.gz +0 -0
  46. package/dist/web/assets/{index6-DWBoE2gM.js → index6-DPLyU-vO.js} +1 -1
  47. package/dist/web/assets/index6-DPLyU-vO.js.br +0 -0
  48. package/dist/web/assets/index6-DPLyU-vO.js.gz +0 -0
  49. package/dist/web/assets/{index7-CoJTOvQ5.js → index7-6uQOIsxo.js} +1 -1
  50. package/dist/web/assets/index7-6uQOIsxo.js.br +0 -0
  51. package/dist/web/assets/index7-6uQOIsxo.js.gz +0 -0
  52. package/dist/web/assets/{index8-CQGhir4p.js → index8-DUBqmq2E.js} +1 -1
  53. package/dist/web/assets/index8-DUBqmq2E.js.br +0 -0
  54. package/dist/web/assets/index8-DUBqmq2E.js.gz +0 -0
  55. package/dist/web/assets/{index9-D_kItRZJ.js → index9-Czv_zULn.js} +1 -1
  56. package/dist/web/assets/index9-Czv_zULn.js.br +0 -0
  57. package/dist/web/assets/index9-Czv_zULn.js.gz +0 -0
  58. package/dist/web/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  59. package/dist/web/assets/vue.runtime.esm-bundler-DwGo9CTz.js +4 -0
  60. package/dist/web/assets/vue.runtime.esm-bundler-DwGo9CTz.js.br +0 -0
  61. package/dist/web/assets/vue.runtime.esm-bundler-DwGo9CTz.js.gz +0 -0
  62. package/dist/web/index.html +4 -3
  63. package/dist/web/index.html.br +0 -0
  64. package/dist/web/index.html.gz +0 -0
  65. package/docs/markstream-integration-validation.md +3 -2
  66. package/package.json +3 -2
  67. package/dist/web/assets/CodeBlockNode-fLbELjCG.js.br +0 -0
  68. package/dist/web/assets/CodeBlockNode-fLbELjCG.js.gz +0 -0
  69. package/dist/web/assets/FileViewer-C7zGfiFt.js +0 -2
  70. package/dist/web/assets/FileViewer-C7zGfiFt.js.br +0 -0
  71. package/dist/web/assets/FileViewer-C7zGfiFt.js.gz +0 -0
  72. package/dist/web/assets/FileViewer-CljYTF8J.css +0 -1
  73. package/dist/web/assets/FileViewer-CljYTF8J.css.br +0 -0
  74. package/dist/web/assets/FileViewer-CljYTF8J.css.gz +0 -0
  75. package/dist/web/assets/FilesPanel-B1YfdWK8.js.br +0 -0
  76. package/dist/web/assets/FilesPanel-B1YfdWK8.js.gz +0 -0
  77. package/dist/web/assets/MarkdownMessage-C30PkBRA.js +0 -199
  78. package/dist/web/assets/MarkdownMessage-C30PkBRA.js.br +0 -0
  79. package/dist/web/assets/MarkdownMessage-C30PkBRA.js.gz +0 -0
  80. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-BPnMZFbo.js.br +0 -0
  81. package/dist/web/assets/PreCodeBlock.vue_vue_type_style_index_0_lang-BPnMZFbo.js.gz +0 -0
  82. package/dist/web/assets/TerminalPanel-BR2okuCE.js.br +0 -0
  83. package/dist/web/assets/TerminalPanel-BR2okuCE.js.gz +0 -0
  84. package/dist/web/assets/Tooltip-Dh7ELGI1.js.br +0 -0
  85. package/dist/web/assets/Tooltip-Dh7ELGI1.js.gz +0 -0
  86. package/dist/web/assets/index-BJ4CkuXT.js +0 -30
  87. package/dist/web/assets/index-BJ4CkuXT.js.br +0 -0
  88. package/dist/web/assets/index-BJ4CkuXT.js.gz +0 -0
  89. package/dist/web/assets/index-CaFqUnEO.css +0 -1
  90. package/dist/web/assets/index-CaFqUnEO.css.br +0 -0
  91. package/dist/web/assets/index-CaFqUnEO.css.gz +0 -0
  92. package/dist/web/assets/index10-BXOnBXXV.js.br +0 -0
  93. package/dist/web/assets/index10-BXOnBXXV.js.gz +0 -0
  94. package/dist/web/assets/index3-C1CbKHXb.js +0 -1
  95. package/dist/web/assets/index4-CE4EA6Rx.js +0 -1
  96. package/dist/web/assets/index5-BrR0S3K6.js.br +0 -0
  97. package/dist/web/assets/index5-BrR0S3K6.js.gz +0 -0
  98. package/dist/web/assets/index6-DWBoE2gM.js.br +0 -0
  99. package/dist/web/assets/index6-DWBoE2gM.js.gz +0 -0
  100. package/dist/web/assets/index7-CoJTOvQ5.js.br +0 -0
  101. package/dist/web/assets/index7-CoJTOvQ5.js.gz +0 -0
  102. package/dist/web/assets/index8-CQGhir4p.js.br +0 -0
  103. package/dist/web/assets/index8-CQGhir4p.js.gz +0 -0
  104. package/dist/web/assets/index9-D_kItRZJ.js.br +0 -0
  105. package/dist/web/assets/index9-D_kItRZJ.js.gz +0 -0
  106. package/dist/web/assets/vue.runtime.esm-bundler-D6xZ1zFq.js +0 -4
  107. package/dist/web/assets/vue.runtime.esm-bundler-D6xZ1zFq.js.br +0 -0
  108. package/dist/web/assets/vue.runtime.esm-bundler-D6xZ1zFq.js.gz +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Conversation
6
+
7
+ - Messages sent while a turn runs (the **Queue** setting, formerly Steer) wait in a list above
8
+ the composer instead of appearing in the conversation. Each can be edited, removed, or sent at
9
+ once with **Interrupt**; the rest go one per turn when the agent finishes. Queued messages
10
+ stay in the open tab, which warns before closing while any are waiting.
11
+ - Code blocks and opened files are syntax highlighted (highlight.js, common languages, loaded
12
+ on demand; very large text stays plain).
13
+ - Long conversations load earlier and newer messages as you scroll, and return to the live
14
+ tail at the bottom, instead of asking for a click per page. Only about 150 rows stay mounted.
15
+ - Outline rail, as in Paseo: one tick per prompt along the left edge of a wide conversation.
16
+ Resting on it previews the prompt; clicking jumps there, even far back in history.
17
+ - Rewind from a user message (hover it): rewind the conversation, the files, or both, as the
18
+ agent's provider supports. The rewound prompt returns to an empty composer.
19
+ - Finished turns show Copy, the model, the finish time and how long the turn took, with icons,
20
+ as in Paseo. User messages show their time and a copy button on hover.
21
+
22
+ ### Settings without environment variables
23
+
24
+ - `litepaseo config` shows the port, listening address and push contact, and where each value
25
+ comes from. `litepaseo config set <key> <value>` saves one; it applies on every start and is
26
+ included in backups. `LITEPASEO_PORT`, `LITEPASEO_BIND` and `LITEPASEO_PUSH_SUBJECT` still
27
+ work and override the saved value for that run.
28
+
29
+ ### Notifications
30
+
31
+ - In Brave, turning notifications on no longer fails with a bare "push service error": Settings
32
+ says to enable **Use Google services for push messaging** in `brave://settings/privacy`. Other
33
+ browsers that cannot reach their push service get a short explanation too.
34
+
35
+ **Upgrading from 0.3.x:** no data migration; drafts, boards and settings are kept. The
36
+ outline rail needs a Paseo daemon with the prompt index (older daemons simply show no rail),
37
+ and Rewind appears only for providers that support it. The composer's **Steer** setting is
38
+ now called **Queue**: messages wait in this tab until the running turn ends.
39
+
3
40
  ## 0.3.1
4
41
 
5
42
  ### Faster voice input
package/README.md CHANGED
@@ -45,6 +45,12 @@ package, with no separate database service to deploy.
45
45
  - Manage conversations across multiple Paseo hosts in one place.
46
46
  - Create sessions, choose a provider/model, send messages, stop turns, and answer
47
47
  permission requests or structured questions.
48
+ - Queue messages while an agent works, then edit, drop or send one at once as an
49
+ interrupt; rewind a conversation (and, where the provider supports it, its files)
50
+ to an earlier message.
51
+ - Read long conversations without clicking through pages: history loads as you
52
+ scroll, an outline rail previews and jumps to any prompt, and code is
53
+ syntax highlighted.
48
54
  - Attach files and images, with previews and upload status.
49
55
  - Dictate messages through one OpenAI-compatible speech-to-text service set up in
50
56
  LitePaseo, rather than configuring each Paseo host.
@@ -101,8 +107,21 @@ responses (SSE) without buffering.
101
107
  Open your HTTPS address and install from the browser's menu. On iPhone/iPad,
102
108
  use Safari → Share → **Add to Home Screen**, then open the installed app to enable
103
109
  push notifications. Turn them on in **Settings → Notifications** to hear when an
104
- agent needs input or finishes. Set `LITEPASEO_PUSH_SUBJECT=mailto:you@example.com`
105
- before starting the server for Apple push delivery.
110
+ agent needs input or finishes. For Apple devices, set a contact once with
111
+ `litepaseo config set push-subject mailto:you@example.com` and restart (see
112
+ [Configuration](#configuration)).
113
+
114
+ If turning notifications on fails with **"Registration failed - push service error"**,
115
+ the browser could not reach its own push service; LitePaseo is not involved yet.
116
+
117
+ - **Brave** disables push by default. Open `brave://settings/privacy`, turn on
118
+ **Use Google services for push messaging**, restart Brave, and try again.
119
+ - **Chromium builds without Google services** (many Linux distribution packages,
120
+ ungoogled-chromium) cannot receive Web Push. Use Google Chrome, Edge or Firefox.
121
+ - **Chrome or Edge**: open `chrome://gcm-internals` (`edge://gcm-internals`). If
122
+ **Connection State** is not `CONNECTED`, a proxy, VPN or firewall is blocking the push
123
+ service (Chrome needs `mtalk.google.com:5228` and `fcm.googleapis.com`).
124
+ - Private and incognito windows do not support push.
106
125
 
107
126
  Optional two-factor sign-in is under **Settings → Authenticator code**; signed-in
108
127
  devices can be revoked in Settings. If you lose your authenticator, run
@@ -165,21 +184,35 @@ Reinstall the service after changing its environment settings or Node/CLI paths.
165
184
 
166
185
  ### Configuration
167
186
 
168
- Set these variables before starting LitePaseo:
169
-
170
- | Variable | Default | Purpose |
171
- | --- | --- | --- |
172
- | `LITEPASEO_PORT` | `8787` | HTTP port |
173
- | `LITEPASEO_BIND` | `127.0.0.1` | Listening address |
174
- | `LITEPASEO_HOME` | `~/.litepaseo` | Application data directory |
175
- | `LITEPASEO_PUSH_SUBJECT` | — | Contact URL or `mailto:` address for push services |
176
-
177
- For example:
187
+ Save settings once with `litepaseo config`; they apply on every start and are
188
+ included in backups:
178
189
 
179
190
  ```sh
180
- LITEPASEO_PORT=9000 litepaseo start
191
+ litepaseo config # show settings and where each comes from
192
+ litepaseo config set push-subject mailto:you@example.com
193
+ litepaseo config set port 9000
194
+ litepaseo config unset port # back to the default
195
+ litepaseo restart # apply (or: litepaseo service restart)
181
196
  ```
182
197
 
198
+ | Key | Default | Purpose | Environment override |
199
+ | --- | --- | --- | --- |
200
+ | `port` | `8787` | HTTP port | `LITEPASEO_PORT` |
201
+ | `bind` | `127.0.0.1` | Listening address | `LITEPASEO_BIND` |
202
+ | `push-subject` | `mailto:litepaseo@example.com` | Contact for push services (see below) | `LITEPASEO_PUSH_SUBJECT` |
203
+
204
+ An environment variable, when set, wins over the saved value for that run.
205
+ `LITEPASEO_HOME` (default `~/.litepaseo`) chooses the data directory itself, so it
206
+ is only an environment variable.
207
+
208
+ **`push-subject`** is the contact address LitePaseo includes, signed, when it hands a
209
+ notification to Apple, Google or Mozilla. They use it only to reach whoever runs
210
+ the server if its notifications cause problems. It is never shown to anyone or
211
+ emailed, and it does not have to be personal: any `mailto:` address or `https://`
212
+ page you control works, such as your console's own address
213
+ (`https://agents.example.com`). Replace the placeholder default with a real one;
214
+ Apple is the strictest of the push services about this value.
215
+
183
216
  LitePaseo's data directory contains credentials and settings. Conversation
184
217
  history stays on your daemons, and drafts stay in browser storage.
185
218
 
@@ -23,7 +23,7 @@ import webpush from "web-push";
23
23
  import WebSocket, { WebSocketServer } from "ws";
24
24
  import { fileURLToPath } from "node:url";
25
25
  // src/server/version.ts
26
- const VERSION = "0.3.1";
26
+ const VERSION = "0.4.0";
27
27
  // src/server/rotating-log.ts
28
28
  /** One writer (the supervisor); bounded active file plus numbered archives. */
29
29
  var RotatingLog = class {
@@ -984,9 +984,19 @@ function summarize(hostId, agent, project, activity = time(agent.updatedAt)) {
984
984
  thinking: agent.effectiveThinkingOptionId ?? agent.thinkingOptionId ?? agent.runtimeInfo?.thinkingOptionId ?? null,
985
985
  modeId: agent.currentModeId ?? null,
986
986
  contextUsed: agent.lastUsage?.contextWindowUsedTokens ?? null,
987
- contextMax: agent.lastUsage?.contextWindowMaxTokens ?? null
987
+ contextMax: agent.lastUsage?.contextWindowMaxTokens ?? null,
988
+ rewind: rewindModes(agent.capabilities)
988
989
  };
989
990
  }
991
+ /** The rewind modes a provider supports, in Paseo's menu order. */
992
+ function rewindModes(capabilities) {
993
+ const c = capabilities ?? {};
994
+ const modes = [];
995
+ if (c.supportsRewindConversation === true) modes.push("conversation");
996
+ if (c.supportsRewindFiles === true) modes.push("files");
997
+ if (c.supportsRewindBoth === true) modes.push("both");
998
+ return modes;
999
+ }
990
1000
  const agentAdapter = {
991
1001
  updateType: "agent_update",
992
1002
  base: { scope: "active" },
@@ -3987,6 +3997,46 @@ function createApp(store, hosts, token, webRoot, options = {}) {
3987
3997
  }))
3988
3998
  });
3989
3999
  });
4000
+ /** The conversation's user prompts (seq + short preview), for the outline rail. */
4001
+ app.get("/api/hosts/:host/agents/:agent/timeline/prompts", async (c) => {
4002
+ const client = hosts.get(c.req.param("host"));
4003
+ try {
4004
+ const page = await client.driver.listAgentTimelinePrompts(c.req.param("agent"), { timeout: 15e3 });
4005
+ return c.json({
4006
+ epoch: page.epoch,
4007
+ prompts: page.prompts.map((p) => ({
4008
+ seq: p.seq,
4009
+ preview: p.preview.replace(/\s+/g, " ").trim().slice(0, 240)
4010
+ }))
4011
+ });
4012
+ } catch (error) {
4013
+ return c.json({ error: error.message || "Prompt index unavailable" }, 501);
4014
+ }
4015
+ });
4016
+ /**
4017
+ * Rewinds to just before a user message: the conversation, the tracked files, or both, as
4018
+ * the provider supports. Cannot be undone; the timeline is replaced (new epoch) on success.
4019
+ */
4020
+ app.post("/api/hosts/:host/agents/:agent/rewind", async (c) => {
4021
+ const { messageId, mode } = z.object({
4022
+ messageId: z.string().min(1).max(500),
4023
+ mode: z.enum([
4024
+ "conversation",
4025
+ "files",
4026
+ "both"
4027
+ ])
4028
+ }).parse(await c.req.json());
4029
+ const client = hosts.get(c.req.param("host"));
4030
+ const facts = client.directory.facts(c.req.param("agent"));
4031
+ if (!facts) return c.json({ error: "Unknown agent" }, 404);
4032
+ if (!rewindModes(facts.capabilities).includes(mode)) return c.json({ error: "This agent cannot rewind that way." }, 400);
4033
+ try {
4034
+ await client.driver.rewindAgent(c.req.param("agent"), messageId, mode);
4035
+ return c.json({ ok: true });
4036
+ } catch (error) {
4037
+ return c.json({ error: error.message || "Rewind failed" }, 502);
4038
+ }
4039
+ });
3990
4040
  /**
3991
4041
  * An image an agent referenced in a message (`![](file:///…)`, an absolute or workspace path).
3992
4042
  * Workspace files go through the daemon's file API; images the daemon materialized from
@@ -4333,6 +4383,75 @@ function createApp(store, hosts, token, webRoot, options = {}) {
4333
4383
  }
4334
4384
  });
4335
4385
  }
4386
+ // src/server/config.ts
4387
+ /**
4388
+ * Settings that used to need an environment variable on every start. `litepaseo config set`
4389
+ * saves them with the rest of LitePaseo's data (so backups carry them); an environment
4390
+ * variable, when present, still wins for that run.
4391
+ */
4392
+ const CONFIG_KEYS = {
4393
+ port: {
4394
+ env: "LITEPASEO_PORT",
4395
+ fallback: "8787",
4396
+ summary: "Port the web console listens on",
4397
+ check: (value) => /^\d+$/.test(value) && Number(value) >= 1 && Number(value) <= 65535 ? null : "Use a port number from 1 to 65535."
4398
+ },
4399
+ bind: {
4400
+ env: "LITEPASEO_BIND",
4401
+ fallback: "127.0.0.1",
4402
+ summary: "Address to listen on (keep 127.0.0.1 behind a tunnel)",
4403
+ check: (value) => /^[^\s/]{1,255}$/.test(value) ? null : "Use an IP address or host name, such as 127.0.0.1."
4404
+ },
4405
+ "push-subject": {
4406
+ env: "LITEPASEO_PUSH_SUBJECT",
4407
+ fallback: "mailto:litepaseo@example.com",
4408
+ summary: "Contact sent to push services (mailto: or https: URL)",
4409
+ check: (value) => {
4410
+ if (/^mailto:[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) return null;
4411
+ try {
4412
+ if (new URL(value).protocol === "https:") return null;
4413
+ } catch {}
4414
+ return "Use mailto:you@example.com or an https:// address you control.";
4415
+ }
4416
+ }
4417
+ };
4418
+ const configKeys = Object.keys(CONFIG_KEYS);
4419
+ const isConfigKey = (key) => Object.hasOwn(CONFIG_KEYS, key);
4420
+ const settingName = (key) => `config.${key}`;
4421
+ function setConfig(store, key, value) {
4422
+ if (value !== null) {
4423
+ const problem = CONFIG_KEYS[key].check(value);
4424
+ if (problem) throw new Error(problem);
4425
+ }
4426
+ store.setSetting(settingName(key), value);
4427
+ }
4428
+ /** The value in effect for each key: environment, then saved configuration, then the default. */
4429
+ function effectiveConfig(store, env) {
4430
+ const entries = configKeys.map((key) => {
4431
+ const { env: name, fallback } = CONFIG_KEYS[key];
4432
+ const saved = store.setting(settingName(key));
4433
+ const fromEnv = env[name];
4434
+ if (fromEnv !== void 0 && fromEnv !== "") return {
4435
+ key,
4436
+ value: fromEnv,
4437
+ source: "environment",
4438
+ saved
4439
+ };
4440
+ if (saved !== null) return {
4441
+ key,
4442
+ value: saved,
4443
+ source: "saved",
4444
+ saved
4445
+ };
4446
+ return {
4447
+ key,
4448
+ value: fallback,
4449
+ source: "default",
4450
+ saved
4451
+ };
4452
+ });
4453
+ return Object.fromEntries(entries.map((entry) => [entry.key, entry]));
4454
+ }
4336
4455
  // src/server/worker.ts
4337
4456
  async function runWorker(directory, webRoot) {
4338
4457
  if (!process.send) throw new Error("worker is an internal supervised command");
@@ -4347,8 +4466,9 @@ async function runWorker(directory, webRoot) {
4347
4466
  } catch {
4348
4467
  console.error("Could not initialize host", host.id);
4349
4468
  }
4350
- const port = Number(process.env.LITEPASEO_PORT ?? 8787), hostname = process.env.LITEPASEO_BIND ?? "127.0.0.1";
4351
- const app = createApp(store, hosts, tokenFile(tokenPath), webRoot, { pushSubject: process.env.LITEPASEO_PUSH_SUBJECT });
4469
+ const config = effectiveConfig(store, process.env);
4470
+ const port = Number(config.port.value), hostname = config.bind.value;
4471
+ const app = createApp(store, hosts, tokenFile(tokenPath), webRoot, { pushSubject: config["push-subject"].value });
4352
4472
  const server = serve({
4353
4473
  fetch: app.fetch,
4354
4474
  port,
@@ -4371,7 +4491,7 @@ async function runWorker(directory, webRoot) {
4371
4491
  process.once("SIGTERM", () => void shutdown());
4372
4492
  process.once("disconnect", () => void shutdown());
4373
4493
  server.once("error", (error) => {
4374
- const message = error.code === "EADDRINUSE" ? `Port ${port} on ${hostname} is already in use (set LITEPASEO_PORT to use another)` : error.code === "EACCES" ? `Not permitted to listen on ${hostname}:${port}` : error.message;
4494
+ const message = error.code === "EADDRINUSE" ? `Port ${port} on ${hostname} is already in use (choose another with: litepaseo config set port <number>)` : error.code === "EACCES" ? `Not permitted to listen on ${hostname}:${port}` : error.message;
4375
4495
  console.error(message);
4376
4496
  process.send?.({
4377
4497
  type: "fatal",
@@ -4545,6 +4665,7 @@ const json = {
4545
4665
  summary: "Print machine-readable JSON"
4546
4666
  };
4547
4667
  const TOKEN_ACTIONS = ["set", "rotate"];
4668
+ const CONFIG_ACTIONS = ["set", "unset"];
4548
4669
  const SERVICE_ACTIONS = [
4549
4670
  "print",
4550
4671
  "install",
@@ -4625,6 +4746,29 @@ const COMMANDS = [
4625
4746
  "litepaseo token rotate"
4626
4747
  ]
4627
4748
  },
4749
+ {
4750
+ name: "config",
4751
+ group: "Configuration",
4752
+ args: "[set|unset] [key] [value]",
4753
+ summary: "Show or change saved settings",
4754
+ details: [
4755
+ "Saved settings apply on every start, so environment variables are no longer needed.",
4756
+ "An environment variable still overrides its setting for that run.",
4757
+ "",
4758
+ "Keys:",
4759
+ " port port the web console listens on (8787)",
4760
+ " bind address to listen on (127.0.0.1; keep it behind a tunnel)",
4761
+ " push-subject contact for push services: mailto:you@example.com or an https:// URL",
4762
+ "",
4763
+ "Changes apply after 'litepaseo restart' (or 'litepaseo service restart')."
4764
+ ],
4765
+ flags: [json],
4766
+ examples: [
4767
+ "litepaseo config",
4768
+ "litepaseo config set push-subject mailto:you@example.com",
4769
+ "litepaseo config unset port"
4770
+ ]
4771
+ },
4628
4772
  {
4629
4773
  name: "totp-reset",
4630
4774
  group: "Sign-in",
@@ -4769,11 +4913,13 @@ function mainHelp(version, directory, s) {
4769
4913
  `${s.bold("Usage:")} litepaseo <command> [options]`
4770
4914
  ];
4771
4915
  const groups = [...new Set(COMMANDS.map((c) => c.group))];
4916
+ const label = (c) => c.name + (c.args ? " " + c.args : "");
4917
+ const width = Math.max(22, ...COMMANDS.map((c) => label(c).length + 2));
4772
4918
  for (const group of groups) {
4773
4919
  lines.push("", s.bold(group));
4774
- for (const c of COMMANDS.filter((x) => x.group === group)) lines.push(` ${s.cyan((c.name + (c.args ? " " + c.args : "")).padEnd(22))}${c.summary}`);
4920
+ for (const c of COMMANDS.filter((x) => x.group === group)) lines.push(` ${s.cyan(label(c).padEnd(width))}${c.summary}`);
4775
4921
  }
4776
- lines.push("", s.bold("Options"), ` ${s.cyan("-h, --help".padEnd(22))}Show help (also after a command)`, ` ${s.cyan("-v, --version".padEnd(22))}Print the version`, "", s.bold("Environment"), ` ${s.cyan("LITEPASEO_HOME".padEnd(24))}Data directory ${s.dim(`(now ${directory})`)}`, ` ${s.cyan("LITEPASEO_PORT".padEnd(24))}Port ${s.dim("(8787)")}`, ` ${s.cyan("LITEPASEO_BIND".padEnd(24))}Listen address ${s.dim("(127.0.0.1)")}`, ` ${s.cyan("LITEPASEO_PUSH_SUBJECT".padEnd(24))}mailto: or https: contact for push services`, "", `Run ${s.bold("litepaseo help <command>")} for details on a command.`);
4922
+ lines.push("", s.bold("Options"), ` ${s.cyan("-h, --help".padEnd(22))}Show help (also after a command)`, ` ${s.cyan("-v, --version".padEnd(22))}Print the version`, "", `${s.bold("Environment")} ${s.dim("(overrides 'litepaseo config' for one run)")}`, ` ${s.cyan("LITEPASEO_HOME".padEnd(24))}Data directory ${s.dim(`(now ${directory})`)}`, ` ${s.cyan("LITEPASEO_PORT".padEnd(24))}Port ${s.dim("(8787)")}`, ` ${s.cyan("LITEPASEO_BIND".padEnd(24))}Listen address ${s.dim("(127.0.0.1)")}`, ` ${s.cyan("LITEPASEO_PUSH_SUBJECT".padEnd(24))}mailto: or https: contact for push services`, "", `Run ${s.bold("litepaseo help <command>")} for details on a command.`);
4777
4923
  return lines.join("\n");
4778
4924
  }
4779
4925
  function commandHelp(c, s) {
@@ -5037,6 +5183,41 @@ async function token(paths, action) {
5037
5183
  const note = running && versionNote(running, VERSION, err);
5038
5184
  if (note) console.error(note);
5039
5185
  }
5186
+ async function config(paths, args) {
5187
+ const [action, key, value] = args.positional;
5188
+ const store = new Store(paths.directory);
5189
+ try {
5190
+ if (action === void 0) {
5191
+ const entries = Object.values(effectiveConfig(store, process.env));
5192
+ if (args.flags.json) return console.log(JSON.stringify(Object.fromEntries(entries.map((e) => [e.key, {
5193
+ value: e.value,
5194
+ source: e.source
5195
+ }]))));
5196
+ for (const entry of entries) {
5197
+ const note = entry.source === "environment" ? `from ${CONFIG_KEYS[entry.key].env}${entry.saved !== null ? `, overriding saved ${entry.saved}` : ""}` : entry.source;
5198
+ console.log(`${out.cyan(entry.key.padEnd(14))}${entry.value} ${out.dim(`(${note})`)}`);
5199
+ }
5200
+ return;
5201
+ }
5202
+ if (!CONFIG_ACTIONS.includes(action)) {
5203
+ const guess = suggest(action, CONFIG_ACTIONS);
5204
+ throw new UsageError(`Unknown config action '${action}'.${guess ? ` Did you mean '${guess}'?` : ""} Actions: ${CONFIG_ACTIONS.join(", ")}.`);
5205
+ }
5206
+ if (!key || !isConfigKey(key)) {
5207
+ const guess = key ? suggest(key, configKeys) : void 0;
5208
+ throw new UsageError(`${key ? `Unknown key '${key}'.` : "Missing key."}${guess ? ` Did you mean '${guess}'?` : ""} Keys: ${configKeys.join(", ")}.`);
5209
+ }
5210
+ if (action === "set" && value === void 0) throw new UsageError(`Missing value for '${key}'.`);
5211
+ if (action === "unset" && value !== void 0) throw new UsageError(`'unset' takes no value.`);
5212
+ setConfig(store, key, action === "set" ? value : null);
5213
+ const entry = effectiveConfig(store, process.env)[key];
5214
+ console.log(action === "set" ? `${key} saved: ${value}` : `${key} reset to the default: ${CONFIG_KEYS[key].fallback}`);
5215
+ if (entry.source === "environment") console.log(out.yellow(`! ${CONFIG_KEYS[key].env} is set in this shell and overrides it.`));
5216
+ } finally {
5217
+ store.close();
5218
+ }
5219
+ if (await status(paths)) console.log(out.dim(" Restart to apply: litepaseo restart (or litepaseo service restart)"));
5220
+ }
5040
5221
  async function version(args) {
5041
5222
  const paths = await dataDirectory();
5042
5223
  const state = await status(paths);
@@ -5096,6 +5277,7 @@ async function run() {
5096
5277
  case "logs": return logs(paths, args);
5097
5278
  case "serve": return supervise(paths.directory, fileURLToPath(import.meta.url));
5098
5279
  case "token": return token(paths, args.positional[0]);
5280
+ case "config": return config(paths, args);
5099
5281
  case "totp-reset":
5100
5282
  case "signout-all": {
5101
5283
  const store = new Store(paths.directory);
@@ -1,3 +1,3 @@
1
- import{$ as e,B as t,C as n,E as r,G as i,I as a,J as o,M as s,N as c,P as l,T as u,W as d,_ as f,at as p,b as ee,d as m,et as te,g as h,h as g,j as _,k as ne,l as re,m as v,nt as ie,ot as ae,q as oe,rt as se,v as ce,y as le}from"./vue.runtime.esm-bundler-D6xZ1zFq.js";import{E as ue,G as de,U as fe,W as pe,X as me,Y as he,Z as ge,a as _e,at as ve,b as ye,c as be,d as xe,et as Se,ft as Ce,g as we,it as Te,lt as Ee,n as De,nt as Oe,ot as ke,rt as Ae,ut as je,v as Me,w as Ne,x as Pe}from"./MarkdownMessage-C30PkBRA.js";import{n as Fe,r as Ie,t as Le}from"./PreCodeBlock.vue_vue_type_style_index_0_lang-BPnMZFbo.js";import{n as Re,t as y}from"./safeRaf-BDp3SJMs.js";import{a as ze}from"./index-BJ4CkuXT.js";var b=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),Be=!1,Ve=null,He=null,Ue=null;function We(){return b(this,null,function*(){if(Ue)return Ue;Ue=b(null,null,function*(){if(!He)try{if(He=function(e){let t=e,n=typeof t?.createCodeBlockRuntime==`function`||typeof t?.useMonaco==`function`?t:e?.default,r=n?.createCodeBlockRuntime??n?.useMonaco;return typeof r==`function`?{createCodeBlockRuntime:e=>r.call(n,e),detectLanguage:(n?.detectLanguage)?.bind(n),preloadStreamDiffs:(n?.preloadStreamDiffs)?.bind(n)}:null}(yield ze(()=>import(`./markstream_markstream-vue-Bj0UewdV.js`),[])),!He)return null}catch{return null}try{return yield function(e){return b(this,null,function*(){if(!Be)return Ve||(Ve=b(null,null,function*(){let t=e?.preloadStreamDiffs;typeof t==`function`&&(yield t()),Be=!0}).finally(()=>{Ve=null}),Ve)})}(He),pe(),He}catch{return null}});try{return yield Ue}finally{Ue=null}})}var Ge=Object.defineProperty,Ke=Object.defineProperties,x=Object.getOwnPropertyDescriptors,S=Object.getOwnPropertySymbols,qe=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,Je=(e,t,n)=>t in e?Ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||={})qe.call(t,n)&&Je(e,n,t[n]);if(S)for(var n of S(t))C.call(t,n)&&Je(e,n,t[n]);return e},Ye=(e,t)=>Ke(e,x(t)),T=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),E={class:`html-preview-frame__header`},Xe={class:`html-preview-frame__title`},D={class:`html-preview-frame__label`},O=[`sandbox`,`srcdoc`],Ze=Me(u({__name:`HtmlPreviewFrame`,props:{code:{},isDark:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},onClose:{type:Function},title:{}},setup(e){let t=e,{t:n}=Pe(),r=g(()=>{let e=t.code||``,n=e.trim().toLowerCase();return n.startsWith(`<!doctype`)||n.startsWith(`<html`)||n.startsWith(`<body`)?e:`<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style>\n html, body {\n margin: 0;\n padding: 0;\n height: 100%;\n background-color: ${t.isDark?`#020617`:`#ffffff`};\n color: ${t.isDark?`#e5e7eb`:`#020617`};\n }\n body {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text', ui-sans-serif, sans-serif;\n }\n </style>\n </head>\n <body>\n ${e}\n </body>\n</html>`}),i=g(()=>{return e=t.htmlPreviewSandbox,n=t.htmlPreviewAllowScripts,typeof e==`string`?e:e===void 0&&!0===n?`allow-scripts`:``;var e,n});function o(e){var n;e.key!==`Escape`&&e.key!==`Esc`||(n=t.onClose)==null||n.call(t)}return c(()=>{typeof window<`u`&&window.addEventListener(`keydown`,o)}),l(()=>{typeof window<`u`&&window.removeEventListener(`keydown`,o)}),(e,o)=>(a(),f(v,{to:`body`},[h(`div`,{class:se([`markstream-vue`,{dark:t.isDark}])},[h(`div`,{class:`html-preview-frame__backdrop`,onClick:o[2]||=e=>t.onClose?.call(t)},[h(`div`,{class:`html-preview-frame`,onClick:o[1]||=m(()=>{},[`stop`])},[h(`div`,E,[h(`div`,Xe,[o[3]||=h(`span`,{class:`html-preview-frame__dot`},null,-1),h(`span`,D,ae(t.title||ie(n)(`common.preview`)||`Preview`),1)]),h(`button`,{type:`button`,class:`html-preview-frame__close`,onClick:o[0]||=e=>t.onClose?.call(t)},` × `)]),h(`iframe`,{class:`html-preview-frame__iframe`,sandbox:i.value,referrerpolicy:`no-referrer`,srcdoc:r.value},null,8,O)])])],2)]))}}),[[`__scopeId`,`data-v-24e66176`]]),Qe=[`data-markstream-enhanced`,`data-markstream-enhancement-state`,`data-markstream-code-block-state`,`data-markstream-pending`,`data-markstream-viewport-pending`],$e={class:`code-header-main`},et=[`innerHTML`],tt={class:`code-header-copy`},nt={class:`code-header-title`},rt={key:0,class:`code-header-caption`},it=[`data-markstream-host-hidden`],k=Me(u({__name:`CodeBlockNode`,props:{node:{},codeBlockOptions:{},clipboardWriter:{},showLineNumbers:{type:Boolean,default:void 0},isDark:{type:Boolean,default:!1},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},theme:{},darkTheme:{default:void 0},lightTheme:{default:void 0},isShowPreview:{type:Boolean,default:!0},enableFontSizeControl:{type:Boolean,default:!0},minWidth:{default:void 0},maxWidth:{default:void 0},themes:{},showPreviewButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},showTooltips:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},customId:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},estimatedHeightPx:{},estimatedContentHeightPx:{},estimatedDiffInline:{type:Boolean}},emits:[`previewCode`,`copy`],setup(u,{emit:m}){let v=u,pe=m,Me=g(()=>v.showLineNumbers??!0!==v.codeBlockOptions?.disableLineNumbers),ze=d(),b=ne(me,null),Be=ne(`markstreamHostScrollManaged`,null),Ve=ne(we,void 0),He=g(()=>be(v,ze)),Ue=r(),Ge=g(()=>{let e=Ue?.vnode.props;return!(!e||!e.onPreviewCode&&!e[`onPreview-code`])}),{t:Ke}=Pe(),x=e(null),S=e(null),qe=e(!1),C=e(Hr(v.node.language,v.node.code,Vr())),Je=g(()=>ge(C.value)),E=g(()=>Je.value===`plaintext`?`text`:Je.value),Xe=g(()=>Je.value===`plaintext`),D=e(!1),O=e(!1),k=e(!1),A=e(!1),j=e(!1),at=e(!1),M=!1,ot=!1,st=null,ct=null,lt=null,ut=0,dt=!1,ft=``,pt=e(null),mt=0,ht=!1,gt=De(),_t=ue(),vt=xe(),yt=te(null),N=e(typeof window>`u`||!vt.value),bt=r()?.vnode.el?.textContent??``,xt=typeof window<`u`&&String(v.node.code??``).length>0&&bt.includes(String(v.node.code)),St=e(!xt);c(()=>{St.value=!0}),typeof window<`u`&&i([()=>S.value,vt],([e,t],n,r)=>{var i;if((i=yt.value)==null||i.destroy(),yt.value=null,!t||N.value)return void(N.value=!0);if(!e)return void(N.value=!1);let a=!0,o=_t?.value.heavyBlockMargin??_t?.value.rootMargin??`0px`,s=gt(e,{rootMargin:o,allowIdle:!1});yt.value=s,N.value=N.value||s.isVisible.value,s.whenVisible.then(()=>{a&&yt.value===s&&(N.value=!0)}).catch(()=>{}),r(()=>{a=!1,s.destroy(),yt.value===s&&(yt.value=null)})},{immediate:!0}),s(()=>{var e;M=!0,function(){let e=ft;b&&e&&(ft=``,b.markSettled(e))}(),(e=yt.value)==null||e.destroy(),yt.value=null});let P=null,Ct=null,wt=()=>{},Tt=()=>{},Et=()=>{},Dt=()=>{},Ot=()=>null,F=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),I=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),kt=()=>{},At=()=>{},jt=()=>{},Mt=null,L=null,Nt=null,Pt=null,Ft=()=>String(v.node.language??`plaintext`),It=()=>T(null,null,function*(){}),Lt=!1,Rt=null,zt=[],Bt=[],R=null,Vt=null,z=g(()=>Ae(v.node)),Ht=e({removed:0,added:0}),Ut=g(()=>`-${Ht.value.removed} +${Ht.value.added}`);function Wt(e,t){return{original:e,updated:t}}function Gt(e){return String(e??``).replace(/\r\n$|\n$|\r$/,``)}function Kt(e){return String(e?.message??e).includes(`no diff result available`)}function qt(){if(!$())try{let e=jt();e&&typeof e.catch==`function`&&e.catch(e=>{Kt(e)})}catch(e){Kt(e)}}let Jt=g(()=>{let e=w({},v.codeBlockOptions||{});for(let t of[`theme`,`themes`,`themeType`,`language`,`languages`,`stream`,`disableFileHeader`,`onThemeChange`,`renderCustomHeader`,`renderHeaderMetadata`,`renderHeaderPrefix`,`maxHeight`,`padding`,`tabSize`])delete e[t];if(!z.value)return e;let t=e.parseDiffOptions&&typeof e.parseDiffOptions==`object`?e.parseDiffOptions:{},n={diffStyle:`split`,expandUnchanged:!1,collapsedContextThreshold:5,hunkSeparators:`line-info`,parseDiffOptions:{context:2}};return Ye(w(w({},n),e),{parseDiffOptions:w(w({},n.parseDiffOptions),t)})}),Yt=g(()=>{return(v.theme===void 0?!fi(v.darkTheme,v.lightTheme):(e=v.theme)&&typeof e==`object`&&`light`in e&&`dark`in e)?!!v.isDark:function(e){let t=di(e)??``;return Te(t,!0===v.isDark)}(pi());var e}),Xt=g(()=>(z.value,Yt.value?`dark`:`light`)),Zt=g(()=>z.value?Xt.value===`dark`:Yt.value),B=g(()=>je({darkTheme:v.darkTheme,isDark:v.isDark,lightTheme:v.lightTheme,theme:v.theme,themes:v.themes})),Qt=g(()=>z.value?`diff`:`single`),$t=e(Qt.value),V=e(!1),H=e(!1),en=e(!1),U=e(!1),tn=e(null),nn=e(0),rn=e(0),an=e(!1),on=null,sn=!1,cn=null,ln=!1,un=g(()=>!!z.value&&Jt.value?.diffStyle===`unified`),dn=g(()=>ke(Jt.value));function fn(e){return!0===Be?.value||!!e&&(!!e.closest(`[data-markstream-virtual-timeline="1"], .markstream-virtual-timeline`)||!!e.closest(`.vue-recycle-scroller, [data-virtualizer], [data-virtual-scroll-root]`))}let pn=g(()=>fn(S.value)),mn=g(()=>!(V.value||!U.value&&H.value)),hn=g(()=>mn.value),gn=g(()=>mn.value&&!en.value),_n=g(()=>!V.value&&!U.value&&mn.value),vn=g(()=>H.value&&!V.value?`ready`:U.value?`fallback`:`pending`),yn=e(!1),W=g(()=>Gt(v.node.code)),bn=g(()=>z.value?!0===v.node.diff?v.node:Ye(w({},v.node),{diff:!0}):W.value===v.node.code?v.node:Ye(w({},v.node),{code:W.value}));function xn(e){let t=e.detectLanguage;typeof t==`function`&&(Ft=t),Vt=e,R=gi();let n=e.createCodeBlockRuntime(R);return!!n&&(P=n.createEditor||P,Ct=n.createDiffEditor||Ct,wt=n.updateCode||wt,Tt=n.updateDiff||Tt,Et=n.finalizeCode||Et,Dt=n.finalizeDiff||Dt,Ot=n.getEditor||Ot,F=n.getEditorView||F,I=n.getDiffEditorView||I,kt=n.cleanupEditor||kt,At=n.safeClean||n.cleanupEditor||At,jt=n.refreshDiffPresentation||jt,It=n.setTheme||It,Mt=n.whenVisualReady||null,at.value=!0,!0)}let G=e(typeof v.codeBlockOptions?.fontSize==`number`?v.codeBlockOptions.fontSize:NaN),K=e(G.value),Sn=e(null),Cn=e(null),wn=e(null),Tn=e(null),En=g(()=>{let e=G.value,t=K.value;return typeof e==`number`&&Number.isFinite(e)&&e>0&&typeof t==`number`&&Number.isFinite(t)&&t>0}),Dn=g(()=>{let e=v.codeBlockOptions?.fontSize;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;let t=K.value;return typeof t==`number`&&Number.isFinite(t)&&t>0?t:12}),On=g(()=>{let e=v.codeBlockOptions?.lineHeight;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:Dn.value===12?18:Math.max(12,Math.round(1.5*Dn.value))}),kn=g(()=>On.value),An=g(()=>{let e=v.codeBlockOptions?.tabSize;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:4}),jn=g(()=>{let e=v.codeBlockOptions?.padding,t=typeof e==`number`&&Number.isFinite(e)&&e>=0?e:8;return{top:t,bottom:t}}),Mn=g(()=>Ye(w({},Ce(v.codeBlockOptions)),{fontSize:Dn.value,lineHeight:kn.value,maxHeight:zr(),padding:jn.value.top,paddingBottom:jn.value.bottom,tabSize:An.value})),Nn=g(()=>{let e=v.estimatedContentHeightPx;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:null});function Pn(e){if(e==null)return null;let t=Math.ceil(e);return!Number.isFinite(t)||t<=0?null:Math.min(t,Math.ceil(zr()))}function Fn(){return!z.value&&!1!==v.stream&&!1!==v.loading}let In=e(Fn());function Ln(){return Fn()||In.value}let Rn=g(()=>z.value?null:Nn.value==null||Ln()?Math.ceil((e=>{let t=String(e??``);if(!t)return 1;let n=1;for(let e=0;e<t.length;e++)t[e]===`
1
+ import{$ as e,B as t,C as n,E as r,G as i,I as a,J as o,M as s,N as c,P as l,T as u,W as d,_ as f,at as p,b as ee,d as m,et as te,g as h,h as g,j as _,k as ne,l as re,m as v,nt as ie,ot as ae,q as oe,rt as se,v as ce,y as le}from"./vue.runtime.esm-bundler-DwGo9CTz.js";import{E as ue,G as de,U as fe,W as pe,X as me,Y as he,Z as ge,a as _e,at as ve,b as ye,c as be,d as xe,et as Se,ft as Ce,g as we,it as Te,lt as Ee,n as De,nt as Oe,ot as ke,rt as Ae,ut as je,v as Me,w as Ne,x as Pe}from"./MarkdownMessage-Bm42-B56.js";import{n as Fe,r as Ie,t as Le}from"./PreCodeBlock.vue_vue_type_style_index_0_lang-DUZXIc-h.js";import{n as Re,t as y}from"./safeRaf-BDp3SJMs.js";import{a as ze}from"./index-By8I8BM7.js";var b=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),Be=!1,Ve=null,He=null,Ue=null;function We(){return b(this,null,function*(){if(Ue)return Ue;Ue=b(null,null,function*(){if(!He)try{if(He=function(e){let t=e,n=typeof t?.createCodeBlockRuntime==`function`||typeof t?.useMonaco==`function`?t:e?.default,r=n?.createCodeBlockRuntime??n?.useMonaco;return typeof r==`function`?{createCodeBlockRuntime:e=>r.call(n,e),detectLanguage:(n?.detectLanguage)?.bind(n),preloadStreamDiffs:(n?.preloadStreamDiffs)?.bind(n)}:null}(yield ze(()=>import(`./markstream_markstream-vue-Bj0UewdV.js`),[])),!He)return null}catch{return null}try{return yield function(e){return b(this,null,function*(){if(!Be)return Ve||(Ve=b(null,null,function*(){let t=e?.preloadStreamDiffs;typeof t==`function`&&(yield t()),Be=!0}).finally(()=>{Ve=null}),Ve)})}(He),pe(),He}catch{return null}});try{return yield Ue}finally{Ue=null}})}var Ge=Object.defineProperty,Ke=Object.defineProperties,x=Object.getOwnPropertyDescriptors,S=Object.getOwnPropertySymbols,qe=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,Je=(e,t,n)=>t in e?Ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||={})qe.call(t,n)&&Je(e,n,t[n]);if(S)for(var n of S(t))C.call(t,n)&&Je(e,n,t[n]);return e},Ye=(e,t)=>Ke(e,x(t)),T=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),E={class:`html-preview-frame__header`},Xe={class:`html-preview-frame__title`},D={class:`html-preview-frame__label`},O=[`sandbox`,`srcdoc`],Ze=Me(u({__name:`HtmlPreviewFrame`,props:{code:{},isDark:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},onClose:{type:Function},title:{}},setup(e){let t=e,{t:n}=Pe(),r=g(()=>{let e=t.code||``,n=e.trim().toLowerCase();return n.startsWith(`<!doctype`)||n.startsWith(`<html`)||n.startsWith(`<body`)?e:`<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style>\n html, body {\n margin: 0;\n padding: 0;\n height: 100%;\n background-color: ${t.isDark?`#020617`:`#ffffff`};\n color: ${t.isDark?`#e5e7eb`:`#020617`};\n }\n body {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text', ui-sans-serif, sans-serif;\n }\n </style>\n </head>\n <body>\n ${e}\n </body>\n</html>`}),i=g(()=>{return e=t.htmlPreviewSandbox,n=t.htmlPreviewAllowScripts,typeof e==`string`?e:e===void 0&&!0===n?`allow-scripts`:``;var e,n});function o(e){var n;e.key!==`Escape`&&e.key!==`Esc`||(n=t.onClose)==null||n.call(t)}return c(()=>{typeof window<`u`&&window.addEventListener(`keydown`,o)}),l(()=>{typeof window<`u`&&window.removeEventListener(`keydown`,o)}),(e,o)=>(a(),f(v,{to:`body`},[h(`div`,{class:se([`markstream-vue`,{dark:t.isDark}])},[h(`div`,{class:`html-preview-frame__backdrop`,onClick:o[2]||=e=>t.onClose?.call(t)},[h(`div`,{class:`html-preview-frame`,onClick:o[1]||=m(()=>{},[`stop`])},[h(`div`,E,[h(`div`,Xe,[o[3]||=h(`span`,{class:`html-preview-frame__dot`},null,-1),h(`span`,D,ae(t.title||ie(n)(`common.preview`)||`Preview`),1)]),h(`button`,{type:`button`,class:`html-preview-frame__close`,onClick:o[0]||=e=>t.onClose?.call(t)},` × `)]),h(`iframe`,{class:`html-preview-frame__iframe`,sandbox:i.value,referrerpolicy:`no-referrer`,srcdoc:r.value},null,8,O)])])],2)]))}}),[[`__scopeId`,`data-v-24e66176`]]),Qe=[`data-markstream-enhanced`,`data-markstream-enhancement-state`,`data-markstream-code-block-state`,`data-markstream-pending`,`data-markstream-viewport-pending`],$e={class:`code-header-main`},et=[`innerHTML`],tt={class:`code-header-copy`},nt={class:`code-header-title`},rt={key:0,class:`code-header-caption`},it=[`data-markstream-host-hidden`],k=Me(u({__name:`CodeBlockNode`,props:{node:{},codeBlockOptions:{},clipboardWriter:{},showLineNumbers:{type:Boolean,default:void 0},isDark:{type:Boolean,default:!1},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},theme:{},darkTheme:{default:void 0},lightTheme:{default:void 0},isShowPreview:{type:Boolean,default:!0},enableFontSizeControl:{type:Boolean,default:!0},minWidth:{default:void 0},maxWidth:{default:void 0},themes:{},showPreviewButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},showTooltips:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},customId:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},estimatedHeightPx:{},estimatedContentHeightPx:{},estimatedDiffInline:{type:Boolean}},emits:[`previewCode`,`copy`],setup(u,{emit:m}){let v=u,pe=m,Me=g(()=>v.showLineNumbers??!0!==v.codeBlockOptions?.disableLineNumbers),ze=d(),b=ne(me,null),Be=ne(`markstreamHostScrollManaged`,null),Ve=ne(we,void 0),He=g(()=>be(v,ze)),Ue=r(),Ge=g(()=>{let e=Ue?.vnode.props;return!(!e||!e.onPreviewCode&&!e[`onPreview-code`])}),{t:Ke}=Pe(),x=e(null),S=e(null),qe=e(!1),C=e(Hr(v.node.language,v.node.code,Vr())),Je=g(()=>ge(C.value)),E=g(()=>Je.value===`plaintext`?`text`:Je.value),Xe=g(()=>Je.value===`plaintext`),D=e(!1),O=e(!1),k=e(!1),A=e(!1),j=e(!1),at=e(!1),M=!1,ot=!1,st=null,ct=null,lt=null,ut=0,dt=!1,ft=``,pt=e(null),mt=0,ht=!1,gt=De(),_t=ue(),vt=xe(),yt=te(null),N=e(typeof window>`u`||!vt.value),bt=r()?.vnode.el?.textContent??``,xt=typeof window<`u`&&String(v.node.code??``).length>0&&bt.includes(String(v.node.code)),St=e(!xt);c(()=>{St.value=!0}),typeof window<`u`&&i([()=>S.value,vt],([e,t],n,r)=>{var i;if((i=yt.value)==null||i.destroy(),yt.value=null,!t||N.value)return void(N.value=!0);if(!e)return void(N.value=!1);let a=!0,o=_t?.value.heavyBlockMargin??_t?.value.rootMargin??`0px`,s=gt(e,{rootMargin:o,allowIdle:!1});yt.value=s,N.value=N.value||s.isVisible.value,s.whenVisible.then(()=>{a&&yt.value===s&&(N.value=!0)}).catch(()=>{}),r(()=>{a=!1,s.destroy(),yt.value===s&&(yt.value=null)})},{immediate:!0}),s(()=>{var e;M=!0,function(){let e=ft;b&&e&&(ft=``,b.markSettled(e))}(),(e=yt.value)==null||e.destroy(),yt.value=null});let P=null,Ct=null,wt=()=>{},Tt=()=>{},Et=()=>{},Dt=()=>{},Ot=()=>null,F=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),I=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),kt=()=>{},At=()=>{},jt=()=>{},Mt=null,L=null,Nt=null,Pt=null,Ft=()=>String(v.node.language??`plaintext`),It=()=>T(null,null,function*(){}),Lt=!1,Rt=null,zt=[],Bt=[],R=null,Vt=null,z=g(()=>Ae(v.node)),Ht=e({removed:0,added:0}),Ut=g(()=>`-${Ht.value.removed} +${Ht.value.added}`);function Wt(e,t){return{original:e,updated:t}}function Gt(e){return String(e??``).replace(/\r\n$|\n$|\r$/,``)}function Kt(e){return String(e?.message??e).includes(`no diff result available`)}function qt(){if(!$())try{let e=jt();e&&typeof e.catch==`function`&&e.catch(e=>{Kt(e)})}catch(e){Kt(e)}}let Jt=g(()=>{let e=w({},v.codeBlockOptions||{});for(let t of[`theme`,`themes`,`themeType`,`language`,`languages`,`stream`,`disableFileHeader`,`onThemeChange`,`renderCustomHeader`,`renderHeaderMetadata`,`renderHeaderPrefix`,`maxHeight`,`padding`,`tabSize`])delete e[t];if(!z.value)return e;let t=e.parseDiffOptions&&typeof e.parseDiffOptions==`object`?e.parseDiffOptions:{},n={diffStyle:`split`,expandUnchanged:!1,collapsedContextThreshold:5,hunkSeparators:`line-info`,parseDiffOptions:{context:2}};return Ye(w(w({},n),e),{parseDiffOptions:w(w({},n.parseDiffOptions),t)})}),Yt=g(()=>{return(v.theme===void 0?!fi(v.darkTheme,v.lightTheme):(e=v.theme)&&typeof e==`object`&&`light`in e&&`dark`in e)?!!v.isDark:function(e){let t=di(e)??``;return Te(t,!0===v.isDark)}(pi());var e}),Xt=g(()=>(z.value,Yt.value?`dark`:`light`)),Zt=g(()=>z.value?Xt.value===`dark`:Yt.value),B=g(()=>je({darkTheme:v.darkTheme,isDark:v.isDark,lightTheme:v.lightTheme,theme:v.theme,themes:v.themes})),Qt=g(()=>z.value?`diff`:`single`),$t=e(Qt.value),V=e(!1),H=e(!1),en=e(!1),U=e(!1),tn=e(null),nn=e(0),rn=e(0),an=e(!1),on=null,sn=!1,cn=null,ln=!1,un=g(()=>!!z.value&&Jt.value?.diffStyle===`unified`),dn=g(()=>ke(Jt.value));function fn(e){return!0===Be?.value||!!e&&(!!e.closest(`[data-markstream-virtual-timeline="1"], .markstream-virtual-timeline`)||!!e.closest(`.vue-recycle-scroller, [data-virtualizer], [data-virtual-scroll-root]`))}let pn=g(()=>fn(S.value)),mn=g(()=>!(V.value||!U.value&&H.value)),hn=g(()=>mn.value),gn=g(()=>mn.value&&!en.value),_n=g(()=>!V.value&&!U.value&&mn.value),vn=g(()=>H.value&&!V.value?`ready`:U.value?`fallback`:`pending`),yn=e(!1),W=g(()=>Gt(v.node.code)),bn=g(()=>z.value?!0===v.node.diff?v.node:Ye(w({},v.node),{diff:!0}):W.value===v.node.code?v.node:Ye(w({},v.node),{code:W.value}));function xn(e){let t=e.detectLanguage;typeof t==`function`&&(Ft=t),Vt=e,R=gi();let n=e.createCodeBlockRuntime(R);return!!n&&(P=n.createEditor||P,Ct=n.createDiffEditor||Ct,wt=n.updateCode||wt,Tt=n.updateDiff||Tt,Et=n.finalizeCode||Et,Dt=n.finalizeDiff||Dt,Ot=n.getEditor||Ot,F=n.getEditorView||F,I=n.getDiffEditorView||I,kt=n.cleanupEditor||kt,At=n.safeClean||n.cleanupEditor||At,jt=n.refreshDiffPresentation||jt,It=n.setTheme||It,Mt=n.whenVisualReady||null,at.value=!0,!0)}let G=e(typeof v.codeBlockOptions?.fontSize==`number`?v.codeBlockOptions.fontSize:NaN),K=e(G.value),Sn=e(null),Cn=e(null),wn=e(null),Tn=e(null),En=g(()=>{let e=G.value,t=K.value;return typeof e==`number`&&Number.isFinite(e)&&e>0&&typeof t==`number`&&Number.isFinite(t)&&t>0}),Dn=g(()=>{let e=v.codeBlockOptions?.fontSize;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;let t=K.value;return typeof t==`number`&&Number.isFinite(t)&&t>0?t:12}),On=g(()=>{let e=v.codeBlockOptions?.lineHeight;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:Dn.value===12?18:Math.max(12,Math.round(1.5*Dn.value))}),kn=g(()=>On.value),An=g(()=>{let e=v.codeBlockOptions?.tabSize;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:4}),jn=g(()=>{let e=v.codeBlockOptions?.padding,t=typeof e==`number`&&Number.isFinite(e)&&e>=0?e:8;return{top:t,bottom:t}}),Mn=g(()=>Ye(w({},Ce(v.codeBlockOptions)),{fontSize:Dn.value,lineHeight:kn.value,maxHeight:zr(),padding:jn.value.top,paddingBottom:jn.value.bottom,tabSize:An.value})),Nn=g(()=>{let e=v.estimatedContentHeightPx;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:null});function Pn(e){if(e==null)return null;let t=Math.ceil(e);return!Number.isFinite(t)||t<=0?null:Math.min(t,Math.ceil(zr()))}function Fn(){return!z.value&&!1!==v.stream&&!1!==v.loading}let In=e(Fn());function Ln(){return Fn()||In.value}let Rn=g(()=>z.value?null:Nn.value==null||Ln()?Math.ceil((e=>{let t=String(e??``);if(!t)return 1;let n=1;for(let e=0;e<t.length;e++)t[e]===`
2
2
  `?n++:t[e]===`\r`&&(n++,t[e+1]===`
3
3
  `&&e++);return n})(W.value)*kn.value+1):null),zn=g(()=>{if(z.value)return null;let e=Nn.value;return e==null||Ln()?Pn(Rn.value):Pn(e)}),Bn=g(()=>{let e=v.estimatedHeightPx;return typeof e==`number`&&Number.isFinite(e)&&e>0?e:null}),Vn=e(null);function Hn(){let e=Vn.value;return typeof e==`number`&&Number.isFinite(e)&&e>0?Math.round(e):null}let Un=g(()=>Hn()??(!z.value&&an.value?null:mn.value||!H.value?zn.value:null));function Wn(e){let t=e?`hsl(152 42% 60%)`:`var(--diff-added-fg)`,n=e?`hsl(0 58% 58%)`:`var(--diff-removed-fg)`,r=e?`color-mix(in lab, #121212 80%, #4d9375)`:`color-mix(in lab, #ffffff 88%, #1e754f)`,i=e?`color-mix(in lab, #121212 80%, #cb7676)`:`color-mix(in lab, #ffffff 88%, #ab5959)`;return{"--markstream-diff-line-number-bg":`var(--markstream-diff-editor-bg)`,"--markstream-diff-added-fg":t,"--markstream-diff-removed-fg":n,"--markstream-diff-added-line":r,"--markstream-diff-removed-line":i,"--markstream-diff-added-line-fill":r,"--markstream-diff-added-number-fill":e?`color-mix(in lab, #121212 85%, #4d9375)`:`color-mix(in lab, #ffffff 91%, #1e754f)`,"--markstream-diff-removed-line-fill":i,"--markstream-diff-removed-number-fill":e?`color-mix(in lab, #121212 85%, #cb7676)`:`color-mix(in lab, #ffffff 91%, #ab5959)`,"--markstream-diff-added-gutter":`linear-gradient(90deg, ${t} 0 4px, transparent 4px 100%)`,"--markstream-diff-removed-gutter":`linear-gradient(90deg, ${n} 0 4px, transparent 4px 100%)`,"--markstream-diff-added-inline":e?`hsl(152 42% 60% / 0.28)`:`var(--diff-added-inline-bg)`,"--markstream-diff-removed-inline":e?`hsl(0 58% 58% / 0.28)`:`var(--diff-removed-inline-bg)`}}let Gn=g(()=>{let e=Pn(Nn.value),t=Pn(Rn.value),n=Ln(),r=w({},z.value||e==null||n?z.value||t==null?{}:{minHeight:`${t}px`}:{height:`${e}px`,minHeight:`${e}px`});if(r[`--markstream-code-fallback-bg`]=B.value.background,r[`--markstream-code-fallback-fg`]=B.value.foreground,B.value.builtin&&(r[`--markstream-code-theme-bg`]=B.value.background,r[`--markstream-code-theme-fg`]=B.value.foreground,r[`--markstream-code-theme-line-number`]=B.value.lineNumber),r[`--markstream-pre-line-number-top`]=`${jn.value.top}px`,r[`--markstream-pre-line-number-left`]=`0px`,r[`--markstream-pre-line-number-padding-left`]=`2ch`,r[`--markstream-pre-line-number-padding-right`]=`1ch`,r[`--markstream-pre-line-number-separator-width`]=`2px`,z.value){r[`--markstream-pre-diff-line-height`]=`${kn.value}px`,r[`--markstream-pre-diff-pane-bottom-padding`]=(un.value,`0px`);let e=Tn.value;e!=null&&e>0&&(r.height=`${e}px`,r.minHeight=`${e}px`,r.maxHeight=`${e}px`),Object.assign(r,Wn(Zt.value))}return r}),Kn=g(()=>Un.value!=null&&(!H.value||Hn()!=null)),qn=g(()=>{let e=Un.value;if(e==null)return null;if(z.value)return Math.ceil(e);let t=Bn.value,n=Nn.value;if(t==null||n==null)return Math.ceil(e);let r=Math.max(0,Math.ceil(t)-Math.ceil(n));return Math.ceil(e+r)}),Jn=g(()=>{if(z.value&&mn.value)return{};let e=Un.value;return Kn.value&&e!=null?{minHeight:`${e}px`}:{}});function Yn(){Vn.value=null}function Xn(){var e,t,n,r;let i=S.value?.querySelector(`pre.code-pre-fallback`),a=I(),o=i?.scrollTop??0;(t=(e=(a?.getOriginalEditor)?.call(a))?.setScrollTop)==null||t.call(e,o),(r=(n=(a?.getModifiedEditor)?.call(a))?.setScrollTop)==null||r.call(n,o)}function Zn(){return T(this,null,function*(){return z.value?(vr(),er(),X(!0),Xn(),Z(),en.value=!0,yield _(),X(!0),yield q(),X(!0),gr(),er(),!!(yield function(){return T(this,null,function*(){if(!z.value)return!0;for(let e=0;e<4;e++){let e=er();X(!0),Qn(e),$n(e),yield _(),yield q();let t=S.value?.querySelector(`pre.code-pre-fallback`);if(!t)return!1;if(e==null)return jr();let n=t.getBoundingClientRect().height;if(n>0&&Math.abs(n-e)<=2)return!0}return!1})}())&&(H.value=!0,yield _(),er(),X(!0),gr(),Z(),y(()=>{M||y(()=>{M||(function(){let e=S.value?.querySelector(`.code-block-shell-content`),t=S.value?.querySelector(`.code-editor-layer`);e&&t&&(t.style.removeProperty(`height`),t.style.removeProperty(`min-height`),e.style.removeProperty(`height`),e.style.removeProperty(`min-height`))}(),Q(!0))})}),Q(),!0)):!(Mt&&!(yield Mt())||(en.value=!0,yield _(),X(!0),H.value=!0,yield _(),Q(),0))})}function Qn(e){if(!z.value)return;let t=x.value,n=S.value?.querySelector(`pre.code-pre-fallback`);if(!t||!n)return;let r=e??Number.parseFloat(t.style.height||``);if(!Number.isFinite(r)||r<=0)return;let i=Math.ceil(r),a=`${i}px`;Tn.value=i;let o=S.value;o&&(o.dataset.markstreamDiffHandoffHeight=a),n.dataset.markstreamDiffHandoffHeight=a,n.style.setProperty(`height`,a),n.style.setProperty(`min-height`,a)}function $n(e){if(!z.value)return;let t=S.value?.querySelector(`.code-block-shell-content`),n=S.value?.querySelector(`.code-editor-layer`);if(!t||!n)return;let r=typeof e==`number`&&Number.isFinite(e)&&e>0?Math.ceil(e):Number.parseFloat(x.value?.style.height||``);if(!Number.isFinite(r)||r<=0)return;let i=`${r}px`;n.style.height=i,n.style.minHeight=i,t.style.height=i,t.style.minHeight=i}function er(){let e=x.value;if(e&&jr(e)){Z();let t=mr(e);if(t!=null&&t>0){let n=Math.ceil(t),r=Math.ceil(zr()),i=Math.min(n,r),a=`${i}px`;return e.style.height=a,e.style.minHeight=`0px`,e.style.maxHeight=`${r}px`,e.style.overflow=n>r+1?`auto`:`hidden`,mn.value&&(Tn.value=i,Qn(i)),Dr(),i}return Y({preferModelDiffHeight:!0}),Qn(),Dr(),Number.parseFloat(e.style.height||``)||null}return vr()}function tr(e,t=!1,n={}){let r=Math.ceil(e),i=Hn();if(i==null)return r;let a=!0===n.allowBelowEstimatedFloor;return r>=i||a?((t||a)&&j.value&&Yn(),r):i}function q(){return new Promise(e=>{let t=!1,n=null,r=null,i=()=>{t||(t=!0,r!=null&&globalThis.clearTimeout(r),n!=null&&Re(n),e())};r=globalThis.setTimeout(i,50),n=y(i)})}function nr(){try{let e=x.value;if(!e)return null;let t=e.querySelector(`.stream-diffs-shell .stream-diffs-surface`)??e.querySelector(`.stream-diffs-shell`);if(t){let e=Math.ceil(t.getBoundingClientRect().height);if(e>0)return e}}catch{}return null}function rr(){var e;try{let t=z.value?((e=I())?.getModifiedEditor)?.call(e)??I():F(),n=Ot()?.EditorOption?.fontInfo;if(t&&n!=null){let e=t.getOption?.call(t,n)?.fontSize;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e}}catch{}try{let e=x.value;if(e){let t=e.querySelector(`.stream-diffs-shell .stream-diffs-surface`)??e.querySelector(`.stream-diffs-shell`);if(t)try{if(typeof window<`u`&&typeof window.getComputedStyle==`function`){let e=window.getComputedStyle(t).fontSize,n=e&&e.match(/^(\d+(?:\.\d+)?)/);if(n)return Number.parseFloat(n[1])}}catch{}}}catch{}return null}function ir(e){try{let t=Ot()?.EditorOption?.lineHeight;if(t!=null){let n=(e?.getOption)?.call(e,t);if(typeof n==`number`&&n>0)return n}}catch{}let t=nr();if(t&&t>0)return t;let n=Number.isFinite(K.value)&&K.value>0?K.value:14;return Math.max(12,Math.round(1.35*n))}function ar(){let e=v.codeBlockOptions?.padding;return typeof e==`number`&&Number.isFinite(e)?2*Math.max(0,e):z.value?24:0}function or(e){return!!Xe.value||!!e&&($(e)||Mt!=null)}function sr(){z.value?Ht.value=Oe(String(v.node.originalCode??``),String(v.node.updatedCode??``)):Ht.value={removed:0,added:0}}function cr(){if(Number.isFinite(K.value)&&K.value>0&&Number.isFinite(G.value))return K.value;if(typeof v.codeBlockOptions?.fontSize==`number`)return G.value=v.codeBlockOptions.fontSize,K.value=v.codeBlockOptions.fontSize,v.codeBlockOptions.fontSize;let e=rr();return e&&e>0?(G.value=e,K.value=e,e):(G.value=12,K.value=12,12)}function lr(){let e=cr(),t=Math.min(36,e+1);K.value=t}function ur(){let e=cr(),t=Math.max(10,e-1);K.value=t}function dr(){cr(),Number.isFinite(G.value)&&(K.value=G.value)}function fr(){var e,t,n,r,i;try{let a=z.value?I():null,o=z.value?a:F();if(!o)return null;if(a?.getOriginalEditor&&a?.getModifiedEditor){let i=a.getOriginalEditor?.call(a),o=a.getModifiedEditor?.call(a);(e=i?.layout)==null||e.call(i),(t=o?.layout)==null||t.call(o);let s=(i?.getContentHeight)?.call(i)||0,c=(o?.getContentHeight)?.call(o)||0,l=Math.max(s,c);if(l>0)return Math.ceil(l);let u=((n=(i?.getModel)?.call(i))?.getLineCount)?.call(n)||1,d=((r=(o?.getModel)?.call(o))?.getLineCount)?.call(r)||1,f=Math.max(u,d),p=Math.max(ir(i),ir(o)),ee=ar();return Math.ceil(f*p+ee+0)}if(o?.getContentHeight){(i=o?.layout)==null||i.call(o);let e=o.getContentHeight();if(e>0)return z.value||(an.value=!0),Math.ceil(e)}let s=(o?.getModel)?.call(o),c=1;s&&typeof s.getLineCount==`function`&&(c=s.getLineCount());let l=ir(o);return Math.ceil(c*(l+1.5)+0)}catch{return null}}function pr(){var e;if(z.value)return!1;try{let t=((e=F())?.getContentHeight)?.call(e),n=typeof t==`number`&&Number.isFinite(t)&&t>0;return n&&(an.value=!0),n}catch{return!1}}function mr(e){if(typeof window>`u`)return null;try{if(window.getComputedStyle(e).display===`none`)return null;let t=e.querySelector(`diffs-container`);if(t instanceof HTMLElement){let e=t.getBoundingClientRect();if(e.height>0)return Math.ceil(e.height)}let n=e.querySelector(`.stream-diffs-shell`);if(n){let e=n.getBoundingClientRect();if(e.height>0)return Math.ceil(e.height)}return null}catch{return null}}function hr(e){let t=String(e??``).trim(),n=t.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i)?.[1];if(n){let e=n.length===3?n.split(``).map(e=>`${e}${e}`).join(``):n;return .2126*Number.parseInt(e.slice(0,2),16)+.7152*Number.parseInt(e.slice(2,4),16)+.0722*Number.parseInt(e.slice(4,6),16)}let r=t.match(/\d+(?:\.\d+)?/g);if(!r||r.length<3)return null;let[i,a,o]=r.slice(0,3).map(Number);return .2126*i+.7152*a+.0722*o}function gr(){var e;if(_r())return;let t=rr();t&&t>0&&(Sn.value=t,K.value=t,G.value=t);try{let t=ir(z.value?((e=I())?.getModifiedEditor)?.call(e)??I():F());t&&t>0&&(Cn.value=t)}catch{}try{let e=nr();e&&e>0&&(Cn.value=e)}catch{}}function _r(){return z.value&&hn.value}function vr(){if(!mn.value)return null;let e=x.value,t=S.value?.querySelector(`pre.code-pre-fallback`);if(!e||!t)return null;let n=Math.ceil(t.getBoundingClientRect().height),r=z.value?mr(e):null,i=Math.max(n,r!=null&&r>0?Math.ceil(r):0),a=Math.ceil(zr()),o=Math.min(i,a);return!Number.isFinite(o)||o<=0?null:(z.value&&o>n&&(Tn.value=o),e.style.height=`${o}px`,e.style.minHeight=`${o}px`,e.style.maxHeight=`${a}px`,e.style.overflow=i>a+1?`auto`:`hidden`,o)}function yr(){let e=x.value,t=S.value;if(!e||!t)return;let n=e;n.style.setProperty(`--markstream-diff-metadata-bg`,B.value.background),n.style.setProperty(`--markstream-diff-metadata-fg`,B.value.lineNumber),n.style.setProperty(`--diffs-tab-size`,String(An.value)),n.style.setProperty(`--diffs-scrollbar-gutter-override`,`0px`),typeof v.codeBlockOptions?.padding==`number`?n.style.setProperty(`--diffs-gap-block`,`${jn.value.top}px`):n.style.removeProperty(`--diffs-gap-block`);let r=e.querySelector(`.stream-diffs-shell`)||e,i=r,a=r,o=null,s=null,c=null;try{typeof window<`u`&&typeof window.getComputedStyle==`function`&&(o=window.getComputedStyle(r),s=i===r?o:window.getComputedStyle(i),c=a===r?o:window.getComputedStyle(a))}catch{o=null,s=null,c=null}let l=String(o?.getPropertyValue(`--vscode-editor-foreground`)??``).trim(),u=String(o?.getPropertyValue(`--vscode-editor-background`)??``).trim(),d=String(o?.getPropertyValue(`--vscode-editor-selectionBackground`)??o?.getPropertyValue(`--vscode-editor-hoverHighlightBackground`)??``).trim(),f=l||String(c?.color??o?.color??``).trim(),p=u||String(s?.backgroundColor??o?.backgroundColor??``).trim(),ee=function(){var e;try{let t=z.value?((e=I())?.getModifiedEditor)?.call(e)??I():F(),n=Ot()?.EditorOption?.fontInfo;if(t&&n!=null){let e=t.getOption?.call(t,n)?.typicalHalfwidthCharacterWidth;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e}}catch{}return null}();if(ee!=null&&(wn.value=ee),z.value){let e=(e,r)=>{r?(t.style.setProperty(e,r),n.style.setProperty(e,r)):(t.style.removeProperty(e),n.style.removeProperty(e))};for(let[n,r]of Object.entries(Wn(t.classList.contains(`is-dark`))))e(n,r);f?(t.style.setProperty(`--markstream-diff-editor-fg`,f),n.style.setProperty(`--vscode-editor-foreground`,f)):(t.style.removeProperty(`--markstream-diff-editor-fg`),n.style.removeProperty(`--vscode-editor-foreground`)),p?(t.style.setProperty(`--markstream-diff-editor-bg`,p),t.style.setProperty(`--markstream-diff-panel-bg`,p),t.style.setProperty(`--markstream-diff-panel-bg-soft`,p),t.style.setProperty(`--markstream-diff-panel-bg-strong`,p),n.style.setProperty(`--vscode-editor-background`,p),n.style.backgroundColor=p):(t.style.removeProperty(`--markstream-diff-editor-bg`),t.style.removeProperty(`--markstream-diff-panel-bg`),t.style.removeProperty(`--markstream-diff-panel-bg-soft`),t.style.removeProperty(`--markstream-diff-panel-bg-strong`),n.style.removeProperty(`--vscode-editor-background`),n.style.backgroundColor=``),d?n.style.setProperty(`--vscode-editor-selectionBackground`,d):n.style.removeProperty(`--vscode-editor-selectionBackground`)}else{if(function(e,t,n){if(!Xe.value)return!1;let r=hr(e),i=hr(t);return n?r!=null&&r>170||i!=null&&i<110:r!=null&&r<85||i!=null&&i>190}(p,f,t.classList.contains(`is-dark`)))return n.style.removeProperty(`--vscode-editor-foreground`),n.style.removeProperty(`--vscode-editor-background`),void n.style.removeProperty(`--vscode-editor-selectionBackground`);f&&n.style.setProperty(`--vscode-editor-foreground`,f),p&&n.style.setProperty(`--vscode-editor-background`,p),d&&n.style.setProperty(`--vscode-editor-selectionBackground`,d)}}i(()=>[v.stream,v.loading,v.node.loading,z.value],([e,t,n,r])=>{r||!1===e||!1===t||In.value?(r||!1===e)&&In.value&&(In.value=!1):(In.value=!0,Yn())},{immediate:!0});let br=0,xr=0,Sr=/auto|scroll|overlay/i;function J(e,t,n){if(typeof window>`u`||z.value||function(e){return pn.value||fn(e)}(e))return;let r=Math.ceil(n)-Math.ceil(t);if(Math.abs(r)<=1)return;let i=function(e){if(typeof window>`u`)return null;let t=e?.ownerDocument??document,n=t.scrollingElement||t.documentElement||t.body,r=e?.parentElement??null;for(;r&&r!==t.body&&r!==n;){let e=window.getComputedStyle(r),t=(e.overflowY||``).toLowerCase(),n=(e.overflow||``).toLowerCase();if(Sr.test(t)||Sr.test(n))return r;r=r.parentElement}return n}(e);if(!i)return;let a=e.ownerDocument??document,o=i===a.body||i===a.documentElement||i===a.scrollingElement,s=o?0:i.getBoundingClientRect().top;e.getBoundingClientRect().top-s>=0||(o&&typeof window.scrollBy==`function`?window.scrollBy(0,r):i.scrollTop+=r)}function Cr(){try{let e=x.value;if(!e)return;let t=e.getBoundingClientRect().height,n=fr();if(n!=null&&n>0){let r=tr(n,!0,{allowBelowEstimatedFloor:!z.value&&j.value&&pr()}),i=Hn();e.style.minHeight=i==null?`0px`:`${i}px`,e.style.height=`${r}px`,e.style.maxHeight=`none`,e.style.overflow=`visible`,J(e,t,r);return}let r=Hn();r!=null&&(e.style.minHeight=`${r}px`,e.style.height=`${r}px`,e.style.maxHeight=`none`,e.style.overflow=`visible`,J(e,t,r))}catch{}}function wr(){for(var e,t;zt.length>0;)try{(t=(e=zt.pop())?.dispose)==null||t.call(e)}catch{}st!=null&&(Re(st),st=null),ct!=null&&(Re(ct),ct=null),lt!=null&&(Re(lt),lt=null),ut=0,dt=!1}function Tr(){for(var e;Bt.length>0;)try{(e=Bt.pop())==null||e()}catch{}}function Y(e=!1){O.value||(D.value?Cr():function(e={}){try{let t=x.value;if(!t)return;let n=t.getBoundingClientRect().height,r=Math.ceil(n||0),i=zr(),a=r,o=Number.parseFloat(t.style.height||``),s=a>0?a:Number.isFinite(o)&&o>0?Math.ceil(o):0,c=z.value?function(){var e,t;if($())return null;try{let n=I(),r=(n?.getOriginalEditor)?.call(n),i=(n?.getModifiedEditor)?.call(n);if(!r||!i)return null;let a=((e=r.getModel?.call(r))?.getLineCount)?.call(e)||1,o=((t=i.getModel?.call(i))?.getLineCount)?.call(t)||1,s=Math.max(a,o),c=Math.max(ir(r),ir(i)),l=ar(),u=Math.max(r.getContentHeight?.call(r)??0,i.getContentHeight?.call(i)??0);return Math.ceil(Math.max(u,s*c+l+0))}catch{return null}}():null,l=z.value&&jr(t);if(mt>0&&(mt--,pt.value!=null))return void J(t,n,Or(t,pt.value,i,{preserveScrollableOverflow:Ar(t)}));if(z.value&&!l&&mn.value){let e=vr();if(e!=null){let r=Or(t,e,i,{allowBelowEstimatedFloor:!0});X(!0),J(t,n,r);return}}let u=z.value&&!0===e.preferModelDiffHeight,d=z.value?mr(t):null,f=!z.value&&j.value&&pr(),p=z.value&&!1!==v.loading&&(d!=null||c!=null&&a>0&&c<a-1),ee=c!=null,m;if(z.value){if(u){let e=c!=null&&!1===v.loading&&s>0&&c<s-1;m=!1===v.loading&&d!=null?c==null?d:Math.max(d,c):e?c:d!=null&&c!=null?Math.max(d,c,!1===v.loading?0:s):Math.max(d??0,c??0,!1===v.loading?0:s)||null}else m=un.value&&d!=null||d!=null?ee?Math.max(d,c):d:z.value&&!1!==v.loading?c!=null&&s>0&&c<s-1?c:s>0?s:null:c}else m=fr();if(z.value&&m!=null&&s>0&&(!1!==v.loading||!0===e.holdCurrentDiffHeight)&&(m=Math.max(m,s)),m!=null&&m>0)return void J(t,n,Or(t,m,i,{clearEstimatedFloor:!0,allowBelowEstimatedFloor:f||p,preserveScrollableOverflow:Ar(t),renderedStreamingDiffHeight:d}));if(pt.value!=null)return void J(t,n,Or(t,pt.value,i,{preserveScrollableOverflow:Ar(t)}));let te=z.value&&!1!==v.loading?a:Math.max(a,c!=null&&c>0?c:0);if(te>0)return void J(t,n,Or(t,te,i));let h=Hn();if(!(h==null||z.value&&!1!==v.loading&&l))return void J(t,n,Or(t,h,i));let g=Number.parseFloat(t.style.height);!Number.isNaN(g)&&g>0?J(t,n,Or(t,g,i)):z.value||J(t,n,Or(t,i,i))}catch{}}(typeof e==`object`?e:{}))}function Er(){br=0,xr=0}function X(e=!1){if(O.value)return;let t=x.value;if(!t)return;let n=z.value?I():F();if(n&&typeof n.layout==`function`)try{let r=t.getBoundingClientRect?.call(t),i=Math.ceil((r?.width??0)||t.clientWidth||0),a=Math.ceil((r?.height??0)||t.clientHeight||Number.parseFloat(t.style.height||``)||0);if(i>0&&a>0){if(!e&&i===br&&a===xr)return;br=i,xr=a,n.layout({width:i,height:a})}else Er(),n.layout()}catch{}}function Z(){Tr()}function Q(e=!1){if(M||st!=null)return;let t=()=>{M||(Z(),Y(e),X())};st=y(()=>{st=null,t(),ct=y(()=>{ct=null,t()})}),Dr()}function Dr(e=!1){if(!z.value||M||!e&&!1===v.loading||(dt||=e,ut=Math.max(ut,e?18:6),lt!=null))return;let t=()=>{if(lt=null,!z.value||M||ut<=0||!dt&&!1===v.loading)return ut=0,void(dt=!1);ut--,Z(),Y({preferModelDiffHeight:!0,holdCurrentDiffHeight:dt}),X(),ut>0?lt=y(t):dt=!1};lt=y(t)}function Or(e,t,n,r={}){var i;let a=z.value&&!1!==v.loading,o=`renderedStreamingDiffHeight`in r?a&&(i=r.renderedStreamingDiffHeight)!=null?i:null:a?mr(e):null,s=o!=null&&o>t+1?o:t,c=Math.min(s,n),l=!0===r.allowBelowEstimatedFloor,u=tr(c,!0===r.clearEstimatedFloor,{allowBelowEstimatedFloor:l}),d=Hn();e.style.minHeight=d==null||l?`0px`:`${Math.min(d,Math.ceil(n))}px`,e.style.height=`${u}px`,e.style.maxHeight=`${Math.ceil(n)}px`;let f=!0===r.preserveScrollableOverflow||s>n+1||kr(e,u);return e.style.overflow=f?`auto`:`hidden`,u}function kr(e,t=0){let n=Math.ceil(e.getBoundingClientRect?.call(e).height||0),r=Math.max(t,e.clientHeight||0,n);return r>0&&e.scrollHeight>r+1}function Ar(e){return ht||kr(e,pt.value??0)}function jr(e=x.value){return $(e)}function Mr(e=x.value){return $(e)}function Nr(){var e;if($())return!0;let t=((e=F())?.getModel)?.call(e);return typeof t?.getValue==`function`&&t.getValue()===W.value}function $(e=x.value){return!!e?.querySelector(`diffs-container`)}function Pr(){return!1!==v.loading||H.value}function Fr(){let e=I();return typeof e?.getOriginalEditor==`function`||typeof e?.getModifiedEditor==`function`||typeof e?.getLineChanges==`function`}function Ir(){return T(this,null,function*(){if(!z.value)return!0;for(let e=0;e<30;e++){if(M)return!1;if($())return yield _(),yield q(),!M&&$();yield _(),yield q()}return!1})}let Lr=``;function Rr(e,t,n){return T(this,null,function*(){let r=`${e}\0${t}\0${n}`;if(Lr!==r){try{yield Tt(e,t,n),Lr=r;return}catch(e){if(!Kt(e))throw e}if(yield _(),yield q(),!M&&z.value)try{yield Tt(e,t,n),Lr=r}catch(e){if(!Kt(e))throw e}}})}function zr(){return v.codeBlockOptions?.maxHeight??500}let Br=g(()=>v.isShowPreview&&(C.value===`html`||C.value===`svg`));function Vr(){return typeof v.node.loading==`boolean`?v.node.loading:!0===v.loading}function Hr(e,t,n){return!n||function(){if(!Vr())return!0;let e=String(v.node.raw??``),t=e.split(/\r\n|\n|\r/,1)[0]?.trimStart()??``;return!/^(?:`{3,}|~{3,})/.test(t)||/\r\n|\n|\r/.test(e)}()&&String(t??``)?fe(String(e??``)):`plain`}function Ur(){return Vr()}let Wr=null,Gr=!1,Kr=0;function qr(){Wr=null,Kr++}function Jr(){return T(this,arguments,function*(e=Kr){if(!Gr){Gr=!0;try{for(;Wr&&!M&&!z.value&&e===Kr;){let e=Wr;Wr=null;try{yield Promise.resolve(wt(e.code,e.language)),yield _(),M||z.value||(Y(!1),X())}catch{}}}finally{Gr=!1,!Wr||M||z.value||Jr()}}})}function Yr(e,t){Wr={code:e,language:t},Jr(Kr)}i(()=>[v.node.language,v.node.code,v.node.raw,v.node.loading,v.loading],([e,t,n,r,i])=>{C.value=Hr(e,t,typeof r==`boolean`?r:!0===i)}),i(()=>[v.node.originalCode,v.node.updatedCode,z.value],()=>{y(()=>sr())},{immediate:!0});let Xr=0;i(()=>[v.node.originalCode,v.node.updatedCode,E.value,z.value,v.stream],e=>T(null,[e],function*([,,,e,t]){let n=++Xr;if(!e||Vr()||!1===t&&!k.value)return;if(!1!==t&&P&&!k.value&&x.value)try{yield ci(x.value)}catch{}let r=Nt;if(r&&!A.value){try{yield r}catch{}if(M||!z.value||n!==Xr)return}if(n!==Xr)return;let i=Wt(String(v.node.originalCode??``),String(v.node.updatedCode??``)),a=!1===v.loading;a&&_i();try{if(yield Rr(i.original,i.updated,E.value),M||!z.value||n!==Xr)return;yield _(),X(!0),Z(),Y(!1===v.loading||{preferModelDiffHeight:!0}),X(!0),Q(!0)}catch{return}if(a){if(M||!z.value)return;qt(),Z(),sr(),Q(),Dr(!0)}D.value&&y(()=>Cr())})),i(()=>v.node.code,e=>T(null,null,function*(){if(Vr()||!1===v.stream||(C.value||=fe(Ft(e)),z.value))return;let t=Nt;if(t&&!A.value){try{yield t}catch{}if(M||z.value)return}if(P&&!k.value&&x.value)try{yield ci(x.value)}catch{}Yr(Gt(v.node.code),E.value),D.value&&y(()=>Cr())}));let Zr=g(()=>{let e=C.value;return e?he[e]||e.charAt(0).toUpperCase()+e.slice(1):he[``]||`Plain Text`}),Qr=g(()=>ve(String(v.node.raw??``),Zr.value,z.value)),$r=g(()=>Qr.value.title),ei=g(()=>Qr.value.caption),ti=g(()=>(de.value,Ie(C.value||``,Ve))),ni=g(()=>{let e={};e[`--markstream-code-layout-character-width`]=wn.value==null?`1ch`:`${wn.value}px`,e[`--markstream-code-fallback-bg`]=B.value.background,e[`--markstream-code-fallback-fg`]=B.value.foreground,B.value.builtin&&(e[`--markstream-code-theme-bg`]=B.value.background,e[`--markstream-code-theme-fg`]=B.value.foreground,e[`--markstream-code-theme-line-number`]=B.value.lineNumber),e[`--markstream-diff-added-line-fill`]=B.value.diffAddedLine,e[`--markstream-diff-added-number-fill`]=B.value.diffAddedNumber,e[`--markstream-diff-editor-bg`]=B.value.background,e[`--markstream-diff-removed-line-fill`]=B.value.diffRemovedLine,e[`--markstream-diff-removed-number-fill`]=B.value.diffRemovedNumber,e[`--markstream-diff-shell-bg`]=B.value.background,e[`--markstream-pre-resolved-theme-bg`]=B.value.background,e[`--markstream-pre-resolved-theme-fg`]=B.value.foreground,e[`--markstream-pre-resolved-theme-line-number`]=B.value.lineNumber;let t=e=>{if(e!=null)return typeof e==`number`?`${e}px`:String(e)},n=t(v.minWidth),r=t(v.maxWidth);if(n&&(e.minWidth=n),r&&(e.maxWidth=r),Kn.value&&!z.value&&!O.value){let t=qn.value;t!=null&&(e.minHeight=`${t}px`)}return e.color=`var(--markstream-code-fallback-fg, var(--markstream-code-theme-fg, var(--markstream-pre-resolved-theme-fg)))`,e.backgroundColor=`var(--markstream-code-fallback-bg, var(--markstream-code-theme-bg, var(--markstream-pre-resolved-theme-bg)))`,z.value||(e.borderColor=`var(--markstream-code-border-color, var(--code-border))`),e}),ri=g(()=>!1!==v.showTooltips);function ii(){return T(this,null,function*(){let e=v.node.code;try{v.clipboardWriter?yield v.clipboardWriter(e):typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`&&(yield navigator.clipboard.writeText(e)),qe.value=!0,pe(`copy`,e),setTimeout(()=>{qe.value=!1},1e3)}catch(e){console.error(`复制失败:`,e)}})}function ai(){D.value=!D.value;let e=z.value?I():F(),t=x.value;e&&t&&(D.value?(t.style.maxHeight=`none`,t.style.overflow=`visible`,Y(!0)):(t.style.overflow=`auto`,Y(!0)))}function oi(){var e;if(O.value=!O.value,O.value){if(ht=!1,x.value){let t=Math.ceil((e=x.value).getBoundingClientRect?.call(e).height||0);ht=kr(x.value,t)||x.value.style.overflow===`auto`||x.value.style.overflowY===`auto`,t>0&&(pt.value=t)}}else x.value&&pt.value!=null&&(x.value.style.height=`${pt.value}px`),mt=2,_(()=>{O.value||M||(Y(!0),X(!0))})}function si(){if(!Br.value)return;let e=C.value;if(Ge.value){let t=e===`html`?`text/html`:`image/svg+xml`,n=e===`html`?Ke(`artifacts.htmlPreviewTitle`)||`HTML Preview`:Ke(`artifacts.svgPreviewTitle`)||`SVG Preview`;pe(`previewCode`,{node:v.node,artifactType:t,artifactTitle:n,id:`temp-${e}-${Date.now()}`})}else e===`html`&&(yn.value=!yn.value)}function ci(e,t={}){if(!P||M||!1===v.stream&&!1!==v.loading||(Ci(),wi())||V.value||x.value!==e||Ur())return null;if(L)return L;if(k.value&&j.value)return Promise.resolve();let n=xi(),r=nn.value,i=!1;k.value=!0,function(){let e=He.value;b&&e&&ft!==e&&(ft&&b.markSettled(ft),ft=e,b.markPending(e))}();let a=T(null,null,function*(){try{yield function(e){return T(this,null,function*(){var t;if(!P||M)return;ot=!1;let n=Qt.value;if(ln=!1,U.value=!1,tn.value=null,A.value=!1,H.value=!1,en.value=!1,Sn.value=null,Cn.value=null,wn.value=null,Tn.value=null,Er(),function(){if(an.value=!1,Ln())return void(Vn.value=null);let e=zn.value;Vn.value=j.value||e==null?null:e}(),wr(),Tr(),function(e){e.replaceChildren()}(e),_i(),yield ye(hi()),M)return;let r=T(null,null,function*(){if(n===`diff`){(function(){if(Lt||typeof window>`u`)return;Lt=!0;let e=e=>{Kt(`reason`in e?e.reason:e.error??e.message)&&(e.preventDefault(),e.stopImmediatePropagation())};window.addEventListener(`error`,e,!0),window.addEventListener(`unhandledrejection`,e,!0),Rt=()=>{window.removeEventListener(`error`,e,!0),window.removeEventListener(`unhandledrejection`,e,!0),Lt=!1,Rt=null}})(),At();let t=Wt(String(v.node.originalCode??``),String(v.node.updatedCode??``));Ct?yield Ct(e,t.original,t.updated,E.value):yield P(e,v.node.code,E.value)}else yield P(e,W.value,E.value);A.value=!0}).finally(()=>{Nt===r&&(Nt=null)});if(Nt=r,yield function(e){return T(this,null,function*(){if(!z.value)return void(yield e);let t,n=!1;for(e.then(()=>{n=!0},e=>{n=!0,t=e});;){if(M)return;if(n){if(t)throw t;return}if(jr()&&Fr())return;yield _(),yield q()}})}(r),M||Qt.value!==n)return;A.value=!0;let i=v.codeBlockOptions?.fontSize;if(typeof i==`number`&&Number.isFinite(i)&&i>0){let e=n===`diff`?I():F();(t=e?.updateOptions)==null||t.call(e,{fontSize:i}),G.value=i,K.value=i}else if(!_r()){let e=rr();e&&e>0?(G.value=e,K.value=e):(G.value=12,K.value=12)}for(gr();ot;)if(ot=!1,yield mi(),M)return;D.value||O.value||Y(!1),j.value=!0,$t.value=n,function(){if(wr(),z.value){let e=I(),t=(e?.getOriginalEditor)?.call(e),n=(e?.getModifiedEditor)?.call(e),r=(e,t)=>{try{let n=e?.[t];if(typeof n!=`function`)return;let r=n.call(e,()=>Q());r&&zt.push(r)}catch{}};try{let t=(e?.onDidUpdateDiff)?.call(e,()=>{Q(),y(()=>sr())});t&&zt.push(t)}catch{}r(t,`onDidContentSizeChange`),r(n,`onDidContentSizeChange`);let i=x.value;if(i&&typeof MutationObserver<`u`){let e=`diffs-container,.stream-diffs-shell,.stream-diffs-surface`,t=t=>{let n=t instanceof HTMLElement?t:t.parentElement;return!!(n?.closest)?.call(n,e)},n=t=>{let n=t instanceof HTMLElement?t:t.parentElement;return!!((n?.closest)?.call(n,e)||(n?.querySelector)?.call(n,e))},r=new MutationObserver(e=>{z.value&&Pr()&&e.some(e=>t(e.target)||Array.from(e.addedNodes).some(n)||Array.from(e.removedNodes).some(t))&&(Z(),Y({preferModelDiffHeight:!0}),X(),Dr())});r.observe(i,{attributeFilter:[`class`],attributes:!0,childList:!0,characterData:!0,subtree:!0}),zt.push({dispose:()=>r.disconnect()})}if(i&&typeof ResizeObserver<`u`){let e=new ResizeObserver(()=>{if(!z.value||(X(),!Pr()))return;let e=mr(i);e!=null&&(Math.ceil(i.getBoundingClientRect().height||0)<=e+1||(Z(),Y({preferModelDiffHeight:!0}),X()))});e.observe(i),zt.push({dispose:()=>e.disconnect()})}return}let e=F();try{let t=(e?.onDidContentSizeChange)?.call(e,()=>Q());t&&zt.push(t)}catch{}try{let t=(e?.onDidLayoutChange)?.call(e,()=>Q());t&&zt.push(t)}catch{}}(),yr(),gr(),Z(),sr(),Q(),yield _();let a=null;Mt&&(a=yield Mt(),a&&(yield _(),yield q()));let o=a??(n===`diff`?yield Ir():yield function(){return T(this,null,function*(){if($())return yield _(),yield q(),$();for(let e=0;e<30;e++){if(M||z.value)return!1;let e=x.value,t=Nr(),n=Mr(e),r=!W.value.trim()||or(e);if(t&&n&&r&&(yield _(),yield q(),!M&&!z.value&&Nr()&&Mr(x.value)&&(!W.value.trim()||or(x.value))))return!0;yield _(),yield q()}return!1})}());M||(o?(gr(),er(),(yield Zn())||Ti()):Ti())})}(e),on=null}catch(e){let a=xi(),o=r!==nn.value,s=!1!==t.allowStaleContentRetry&&o&&on!==a;if(n!==a||s)return s&&(on=a),i=!0,k.value=!1,j.value=!1,A.value=!1,void(H.value=!1);throw Ti(n),e}}).finally(()=>{L===a&&(L=null),function(){let e=ft;b&&e&&(ft=``,_(()=>{if(!M){let t=S.value?.offsetHeight??0;t>0&&b.reportHeight(e,t)}b.markSettled(e)}))}(),i&&!M&&queueMicrotask(()=>{var e;let t=x.value;t&&!M&&((e=ci(t))==null||e.catch(e=>{j.value=!1,H.value=!1,Ti()}))})});return L=a,a}i(ri,e=>{e||Ne()}),i(()=>K.value,(e,t)=>{var n;let r=z.value?I():F();r&&typeof e==`number`&&Number.isFinite(e)&&e>0&&((n=r.updateOptions)==null||n.call(r,{fontSize:e}),O.value||Y(!0))},{flush:`post`,immediate:!1});let li=0,ui=i(()=>[x.value,z.value,v.stream,v.loading,at.value,N.value,v.node.language,v.node.raw,v.node.code,v.node.loading],e=>T(null,[e],function*([e,t,n,r,i,a]){let o=++li;if(!e||!a||Vr()||sn||!1===n&&!1!==r||!P&&(yield function(){return T(this,null,function*(){if(typeof window>`u`||M||at.value||V.value)return;if(Pt)return Pt;let e=T(null,null,function*(){try{let e=yield We();if(M)return;if(!e)return void(V.value=!0);xn(e)}catch{if(M)return;V.value=!0}}).finally(()=>{Pt===e&&(Pt=null)});return Pt=e,e})}(),o!==li||!1===v.stream&&!1!==v.loading||Ur()||!N.value||!P||V.value||k.value||wi()||M||x.value!==e)||Ur())return;let s=ci(e);if(s){try{yield s}catch{j.value=!1,H.value=!1,Ti()}j.value&&H.value&&ui()}}));function di(e){return typeof e==`string`?e:null}function fi(e,t){if(e===t)return!0;let n=di(e),r=di(t);return!!n&&n===r}function pi(){return Ee({darkTheme:v.darkTheme,isDark:v.isDark,lightTheme:v.lightTheme,theme:v.theme,themes:v.themes})}function mi(){return T(this,arguments,function*(e={}){_i();let t=()=>{z.value&&qt(),y(()=>{yr(),Q()})};if(e.appearanceOnly)return void t();let n=pi();if(n)try{yield ye(hi()),yield It(n),t()}catch{}else t()})}function hi(){let e=v.themes;return e&&typeof e[0]==`string`&&typeof e[1]==`string`?{dark:e[0],light:e[1]}:pi()}function gi(){let e=Mn.value,t=Ye(w({},Jt.value||{}),{wordWrap:e.overflow===`wrap`?`on`:`off`,overflow:e.overflow,themes:v.themes,stream:!1,MAX_HEIGHT:v.codeBlockOptions?.maxHeight??500,fontSize:Dn.value,lineHeight:kn.value,theme:pi(),themeType:v.isDark?`dark`:`light`,disableLineNumbers:!Me.value,disableFileHeader:!0,workerManager:Jt.value?.workerManager??_e()??void 0,onThemeChange(){yr()}}),n=function(){let e=Jt.value?.fontFamily;return typeof e==`string`&&e.trim()?e.trim():z.value?function(){if(typeof window>`u`)return;let e=S.value?.querySelector(`pre.code-pre-fallback`);if(e)return window.getComputedStyle(e).fontFamily.trim()||void 0}():void 0}();n&&(t.fontFamily??=n);let r=typeof t.unsafeCSS==`string`?t.unsafeCSS:``;return t.unsafeCSS=Se(e.overflow,r),t}function _i(){let e=gi();if(!R)return R=e,R;for(let t of Object.keys(R))t in e||delete R[t];return Object.assign(R,e),R}i(Qt,(e,t)=>T(null,null,function*(){if(e===t||U.value||sn||(qr(),!P||!x.value)||!k.value||!1===v.stream&&!1!==v.loading||!N.value)return;let n=L;if(n){try{yield n}catch{}if(M||!x.value)return}if($t.value!==e||!k.value||!j.value)try{j.value=!1,H.value=!1,k.value=!1,A.value=!1,wr(),Tr(),At(),yield _(),yield ci(x.value)}catch{j.value=!1,H.value=!1,Ti()}}));let vi=e(0),yi=g(()=>String(vi.value)),bi=!1;function xi(){let e=pi();return JSON.stringify({kind:Qt.value,language:E.value,structural:yi.value,optionsRevision:vi.value,settledContentGeneration:rn.value,theme:di(e)??(e==null?null:`custom`),isDark:v.isDark})}i(()=>v.codeBlockOptions?.fontSize,e=>{let t=typeof e==`number`&&Number.isFinite(e)&&e>0?e:12;G.value=t,K.value=t,Sn.value=null,Cn.value=null,wn.value=null}),i(()=>[v.codeBlockOptions,v.showLineNumbers],()=>{vi.value+=1,!1===v.stream&&!1!==v.loading&&(bi=!0)},{deep:!0}),i(()=>[W.value,v.node.originalCode,v.node.updatedCode],()=>{nn.value+=1,Vr()||(rn.value+=1)});let Si=g(()=>xi());function Ci(){U.value&&tn.value!==Si.value&&(U.value=!1,tn.value=null,on=null,cn=null,k.value=!1,j.value=!1,A.value=!1,H.value=!1,en.value=!1)}function wi(){return Ci(),U.value&&tn.value===Si.value}function Ti(e=Si.value){tn.value=e,U.value=!0,en.value=!1}return i(Si,()=>T(null,null,function*(){if(sn||!U.value||tn.value===Si.value||!P||!x.value||V.value||M||!N.value||!1===v.stream&&!1!==v.loading||Ur())return;let e=Si.value;sn=!0;try{if(Ci(),U.value)return;yield ci(x.value)}catch{j.value=!1,H.value=!1,Ti()}finally{cn=e,yield _(),sn=!1}})),i(()=>[v.codeBlockOptions,N.value],()=>{var e;if(_i(),!P||!N.value)return;let t=z.value?I():F(),n=typeof v.codeBlockOptions?.fontSize==`number`?v.codeBlockOptions.fontSize:Number.isFinite(K.value)?K.value:void 0;typeof n==`number`&&Number.isFinite(n)&&n>0&&((e=t?.updateOptions)==null||e.call(t,{fontSize:n})),Y(!1)},{deep:!0}),i(()=>[pi(),Xt.value,at.value,k.value,N.value],([e,t],n)=>{if(!at.value||!N.value)return;let r=n!=null&&fi(e,n[0]),i=n!=null&&t!==n[1];j.value?(ot=!1,mi({appearanceOnly:r})):r&&!i||(ot=!0)},{flush:`post`}),i(()=>[yi.value,at.value,N.value],(e,t)=>T(null,[e,t],function*([e,t,n],[r]){if(_i(),!t||!n||!P||!x.value||!k.value||e===r)return;if(!1===v.stream&&!1!==v.loading)return void(bi=!0);bi=!1;let i=L;if(i){try{yield i}catch{}if(M||!x.value)return}try{j.value=!1,H.value=!1,k.value=!1,A.value=!1,wr(),Tr(),At(),Vt&&xn(Vt),yield _(),yield ci(x.value,{allowStaleContentRetry:!1})}catch{j.value=!1,H.value=!1,Ti()}}),{flush:`post`}),i(()=>[v.loading,N.value],([e,t])=>{!1===e&&t&&bi&&(bi=!1,vi.value+=1)},{flush:`post`}),i(()=>[v.loading,N.value],(e,t)=>T(null,[e,t],function*([e,t],n){if(!t)return;let r=n?.[0];if(!1===r&&!1!==e&&z.value&&k.value&&(yield _(),y(()=>{T(null,null,function*(){let e=L;if(e)try{yield e}catch{}!M&&z.value&&!1!==v.loading&&(_i(),qt(),Q())})})),e)return;let i=r!==void 0&&!1!==r;yield _(),y(()=>{T(null,null,function*(){try{if(i&&(yield function(){return T(this,null,function*(){if(!U.value||!P||!x.value||V.value||M||!N.value)return!1;if(cn===Si.value)return!0;sn=!0;try{U.value=!1,tn.value=null,on=null,k.value=!1,j.value=!1,A.value=!1,H.value=!1,wr(),Tr(),At(),Vt&&xn(Vt),yield _();try{yield ci(x.value)}catch{j.value=!1,H.value=!1,Ti()}}finally{yield _(),sn=!1}return!0})}()))return void Y(!1);if(i&&z.value&&k.value&&ln&&x.value)return ln=!1,j.value=!1,H.value=!1,k.value=!1,A.value=!1,wr(),Tr(),At(),yield _(),yield ci(x.value,{allowStaleContentRetry:!1}),void Dr(!0);if(i&&k.value){if(z.value&&x.value){let e=L;if(e)try{yield e}catch{}_i();let t=Wt(String(v.node.originalCode??``),String(v.node.updatedCode??``));if(yield Rr(t.original,t.updated,E.value),M||!z.value)return;yield Promise.resolve(Dt()),qt(),X(!0),Xn(),Z(),sr();let n=yield Ir();M||!n||H.value||(yield Zn()),Q(),Dr(!0)}else qr(),Yr(W.value,E.value),yield new Promise(e=>{let t=()=>{M?e():Gr||Wr?setTimeout(t,16):e()};t()}),M||z.value||(yield Promise.resolve(Et()))}i&&z.value?(Y({preferModelDiffHeight:!0,holdCurrentDiffHeight:!0}),Dr(!0)):Y(!1)}catch{}})})}),{immediate:!0,flush:`post`}),l(()=>{wr(),Tr(),kt(),Rt?.()}),(e,r)=>{var i;return V.value?(a(),f(Le,{key:0,style:p(Gn.value),node:bn.value,loading:v.loading,"show-line-numbers":Me.value,"diff-inline":un.value,"diff-hide-unchanged-regions":dn.value,"code-block-options":v.codeBlockOptions,"resolved-visual-options":Mn.value,"reserved-height-px":z.value&&(i=Tn.value)!=null?i:void 0,"is-dark":v.isDark,theme:v.theme,"dark-theme":v.darkTheme,"light-theme":v.lightTheme,themes:v.themes,"show-header":v.showHeader,"show-copy-button":v.showCopyButton,"clipboard-writer":v.clipboardWriter,"show-tooltips":v.showTooltips,onCopy:r[0]||=e=>pe(`copy`,e)},ee({_:2},[e.$slots[`header-left`]?{name:`header-left`,fn:oe(()=>[t(e.$slots,`header-left`,{},void 0,!0)]),key:`0`}:void 0,e.$slots[`header-right`]?{name:`header-right`,fn:oe(()=>[t(e.$slots,`header-right`,{},void 0,!0)]),key:`1`}:void 0]),1032,[`style`,`node`,`loading`,`show-line-numbers`,`diff-inline`,`diff-hide-unchanged-regions`,`code-block-options`,`resolved-visual-options`,`reserved-height-px`,`is-dark`,`theme`,`dark-theme`,`light-theme`,`themes`,`show-header`,`show-copy-button`,`clipboard-writer`,`show-tooltips`])):(a(),le(`div`,{key:1,ref_key:`container`,ref:S,style:p(ni.value),class:se([`code-block-container rounded-lg border`,[{dark:v.isDark,"is-rendering":v.loading,"is-dark":Zt.value,"is-diff":z.value,"is-plain-text":Xe.value}]]),"data-markstream-code-block":`1`,"data-markstream-enhanced":H.value&&!V.value?`true`:`false`,"data-markstream-enhancement-state":vn.value,"data-markstream-code-block-state":Vr()?`streaming`:`settled`,"data-markstream-pending":_n.value?`true`:void 0,"data-markstream-viewport-pending":St.value&&ie(vt)&&!N.value?`true`:void 0},[n(Fe,{"show-header":v.showHeader,"show-collapse-button":v.showCollapseButton,"show-font-size-buttons":v.showFontSizeButtons,"enable-font-size-control":v.enableFontSizeControl,"show-copy-button":v.showCopyButton,"show-expand-button":v.showExpandButton,"show-preview-button":v.showPreviewButton,"show-tooltips":v.showTooltips,"is-dark":v.isDark,loading:v.loading,stream:u.stream,"is-collapsed":O.value,"is-expanded":D.value,"copy-text":qe.value,"is-previewable":Br.value,"code-font-size":K.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":G.value,"font-baseline-ready":En.value,"diff-stats":z.value?Ht.value:null,"diff-stats-aria-label":Ut.value,onToggleCollapse:oi,onDecreaseFont:ur,onResetFont:dr,onIncreaseFont:lr,onCopy:ii,onToggleExpand:ai,onPreview:si},ee({"header-left":oe(()=>[t(e.$slots,`header-left`,{},()=>[h(`div`,$e,[h(`span`,{class:`icon-slot h-4 w-4 flex-shrink-0`,innerHTML:ti.value},null,8,et),h(`div`,tt,[h(`div`,nt,ae($r.value),1),ei.value?(a(),le(`div`,rt,ae(ei.value),1)):ce(``,!0)])])],!0)]),loading:oe(()=>[t(e.$slots,`loading`,{loading:u.loading,stream:u.stream},()=>[r[1]||=h(`div`,{class:`loading-skeleton`},[h(`div`,{class:`skeleton-line`}),h(`div`,{class:`skeleton-line`}),h(`div`,{class:`skeleton-line short`})],-1)],!0)]),default:oe(()=>{var e;return[o(h(`div`,{class:se([`code-editor-layer`,{"code-editor-layer--collapsed":O.value}])},[h(`div`,{ref_key:`codeEditor`,ref:x,class:se([`code-editor-container`,u.stream?``:`code-height-placeholder`]),"data-markstream-host-hidden":gn.value?`true`:void 0,style:p(Jn.value)},null,14,it),hn.value?(a(),f(Le,{key:0,style:p(Gn.value),node:bn.value,loading:v.loading,"show-line-numbers":Me.value,"diff-inline":un.value,"diff-hide-unchanged-regions":dn.value,"code-block-options":v.codeBlockOptions,"resolved-visual-options":Mn.value,"reserved-height-px":z.value&&(e=Tn.value)!=null?e:void 0,"is-dark":v.isDark,theme:v.theme,"dark-theme":v.darkTheme,"light-theme":v.lightTheme,themes:v.themes,"show-toolbar":!1},null,8,[`style`,`node`,`loading`,`show-line-numbers`,`diff-inline`,`diff-hide-unchanged-regions`,`code-block-options`,`resolved-visual-options`,`reserved-height-px`,`is-dark`,`theme`,`dark-theme`,`light-theme`,`themes`])):ce(``,!0)],2),[[re,!!u.stream||!u.loading]]),yn.value&&!Ge.value&&Br.value&&C.value===`html`?(a(),f(Ze,{key:0,code:v.node.code,"html-preview-allow-scripts":v.htmlPreviewAllowScripts,"html-preview-sandbox":v.htmlPreviewSandbox,"is-dark":v.isDark,"on-close":()=>yn.value=!1},null,8,[`code`,`html-preview-allow-scripts`,`html-preview-sandbox`,`is-dark`,`on-close`])):ce(``,!0)]}),_:2},[e.$slots[`header-right`]?{name:`header-right`,fn:oe(()=>[t(e.$slots,`header-right`,{},void 0,!0)]),key:`0`}:void 0]),1032,[`show-header`,`show-collapse-button`,`show-font-size-buttons`,`enable-font-size-control`,`show-copy-button`,`show-expand-button`,`show-preview-button`,`show-tooltips`,`is-dark`,`loading`,`stream`,`is-collapsed`,`is-expanded`,`copy-text`,`is-previewable`,`code-font-size`,`default-code-font-size`,`font-baseline-ready`,`diff-stats`,`diff-stats-aria-label`])],14,Qe))}}}),[[`__scopeId`,`data-v-f293a87c`]]);export{k as default};
@@ -0,0 +1,2 @@
1
+ import{$ as e,C as t,G as n,H as r,I as i,S as a,T as o,_ as s,f as c,g as l,h as u,nt as d,ot as f,v as p,y as m}from"./vue.runtime.esm-bundler-DwGo9CTz.js";import{i as h,n as g,r as _,s as v}from"./index-By8I8BM7.js";import{n as y,t as b}from"./highlight-BnTrj1LT.js";var x={class:`file-view`},S={class:`file-bar`},C=[`title`],w={key:0,class:`file-bar-meta`},T=[`title`],E=[`title`],D={class:`file-body`},O={key:0,class:`timeline-empty`},k={key:1,class:`file-error`},A=[`src`,`alt`],j={key:3,class:`file-markdown`},M={key:1,class:`file-text wrap`},N={class:`code-wrap`},P={class:`code-gutter`,"aria-hidden":`true`},F=[`innerHTML`],I={key:1,class:`file-text`},L={key:0,class:`file-note`},R={key:5,class:`file-note`},z=g(o({__name:`FileViewer`,props:{hostId:{},cwd:{},path:{},api:{type:Function}},setup(o){let g=o,z=e(null),B=e(``),V=e(!1),H=e(!0),U=u(()=>`/hosts/${encodeURIComponent(g.hostId)}/fs`),W=u(()=>`cwd=${encodeURIComponent(g.cwd)}&path=${encodeURIComponent(g.path)}`),G=u(()=>/\.(png|jpe?g|webp|gif|bmp|avif)$/i.test(g.path)),K=u(()=>/\.(md|markdown|mdx)$/i.test(g.path)&&z.value?.text!==void 0);async function q(){V.value=!0,B.value=``;try{z.value=await g.api(`${U.value}/read?${W.value}`),K.value&&_()}catch(e){B.value=e.message}finally{V.value=!1}}n(()=>[g.hostId,g.cwd,g.path],q,{immediate:!0});let J=u(()=>`/api${U.value}/raw?${W.value}`),Y=u(()=>{let e=z.value?.text??``,t=1;for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t++;return Array.from({length:t},(e,t)=>t+1).join(`
2
+ `)}),X=u(()=>z.value?.text===void 0?null:b(z.value.text,y(g.path))),Z=e=>e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`,Q=e(!1);async function $(){await navigator.clipboard?.writeText(`${g.cwd.replace(/\/$/,``)}/${g.path}`).catch(()=>{}),Q.value=!0,setTimeout(()=>Q.value=!1,1200)}return(e,n)=>(i(),m(`div`,x,[l(`div`,S,[t(v,{name:`file`,size:14,class:`file-bar-icon`}),l(`span`,{class:`file-bar-path`,title:o.path},f(o.path),9,C),z.value?(i(),m(`span`,w,f(Z(z.value.size)),1)):p(``,!0),K.value?(i(),m(`button`,{key:1,class:`icon-btn`,title:H.value?`Show source`:`Show rendered`,onClick:n[0]||=e=>H.value=!H.value},[t(v,{name:H.value?`terminal`:`eye`,size:14},null,8,[`name`])],8,T)):p(``,!0),l(`button`,{class:`icon-btn`,title:`Reload`,"aria-label":`Reload file`,onClick:q},[t(v,{name:`refresh`,size:14})]),l(`button`,{class:`icon-btn`,title:Q.value?`Copied`:`Copy path`,"aria-label":`Copy path`,onClick:$},[t(v,{name:Q.value?`check`:`copy`,size:14},null,8,[`name`])],8,E)]),l(`div`,D,[V.value&&!z.value?(i(),m(`div`,O,[...n[1]||=[l(`span`,{class:`spinner`},null,-1)]])):B.value?(i(),m(`p`,k,[t(v,{name:`alert`,size:13}),a(f(B.value),1)])):G.value?(i(),m(`img`,{key:2,src:J.value,alt:o.path,class:`file-image`},null,8,A)):K.value&&H.value?(i(),m(`div`,j,[d(h)?(i(),s(r(d(h)),{key:0,content:z.value?.text??``,final:!0},null,8,[`content`])):(i(),m(`pre`,M,f(z.value?.text),1))])):z.value?.text===void 0?z.value?(i(),m(`p`,R,f(z.value.mime||z.value.kind)+` · not shown as text`,1)):p(``,!0):(i(),m(c,{key:4},[l(`div`,N,[l(`pre`,P,f(Y.value),1),X.value===null?(i(),m(`pre`,I,f(z.value.text),1)):(i(),m(`pre`,{key:0,class:`file-text hljs`,innerHTML:X.value},null,8,F))]),z.value.truncated?(i(),m(`p`,L,`Showing the first 1 MB.`)):p(``,!0)],64))])]))}}),[[`__scopeId`,`data-v-f15866a0`]]);export{z as default};
@@ -0,0 +1 @@
1
+ .file-view[data-v-f15866a0]{flex-direction:column;flex:1;min-height:0;display:flex}.file-bar[data-v-f15866a0]{border-bottom:1px solid var(--border);height:36px;color:var(--fg-muted);flex:none;align-items:center;gap:6px;padding:0 10px 0 16px;font-size:12.5px;display:flex}.file-bar .icon-btn[data-v-f15866a0]{width:28px;height:28px}.file-bar-icon[data-v-f15866a0]{color:var(--fg-faint);flex:none}.file-bar-path[data-v-f15866a0]{min-width:0;font-family:var(--mono);color:var(--fg);text-overflow:ellipsis;white-space:nowrap;flex:1;font-size:12px;overflow:hidden}.file-bar-meta[data-v-f15866a0]{color:var(--fg-faint);flex:none;font-size:11.5px}.file-body[data-v-f15866a0]{flex:1;min-height:0;overflow:auto}.file-error[data-v-f15866a0]{color:var(--danger);align-items:center;gap:6px;margin:16px;font-size:13px;display:flex}.file-note[data-v-f15866a0]{color:var(--fg-faint);margin:8px 16px 16px;font-size:12px}.file-image[data-v-f15866a0]{border-radius:8px;max-width:calc(100% - 32px);margin:16px auto;display:block}.file-markdown[data-v-f15866a0]{max-width:780px;margin:0 auto;padding:20px 24px 40px}.code-wrap[data-v-f15866a0]{min-width:max-content;display:flex}.code-gutter[data-v-f15866a0]{font:12.5px/1.6 var(--mono);text-align:right;color:var(--fg-faint);-webkit-user-select:none;user-select:none;border-right:1px solid var(--border);flex:none;margin:0;padding:10px 10px 10px 14px}.file-text[data-v-f15866a0]{font:12.5px/1.6 var(--mono);color:var(--fg);white-space:pre;tab-size:4;margin:0;padding:10px 16px}.file-text.wrap[data-v-f15866a0]{white-space:pre-wrap}
@@ -1 +1 @@
1
- import{$ as e,C as t,G as n,I as r,S as i,T as a,_ as o,at as s,et as c,f as l,g as u,h as d,ot as f,rt as p,v as m,y as h,z as g}from"./vue.runtime.esm-bundler-D6xZ1zFq.js";import{n as _,s as v}from"./index-BJ4CkuXT.js";var y={class:`files`},b={class:`files-head`},x=[`title`],S={key:0,class:`files-error`},C={class:`tree`,role:`tree`},w=[`aria-expanded`,`title`,`onClick`],T={key:1,class:`tree-caret`},E={class:`tree-name`},D={key:2,class:`spinner spinner-sm`},O={key:0,class:`files-empty`},k=_(a({__name:`FilesPanel`,props:{hostId:{},cwd:{},api:{type:Function},activePath:{}},emits:[`open`],setup(a,{emit:_}){let k=a,A=_,j=c(new Map),M=e(new Set),N=e(new Set),P=e(``),F=d(()=>`/hosts/${encodeURIComponent(k.hostId)}/fs`),I=e=>`cwd=${encodeURIComponent(k.cwd)}&path=${encodeURIComponent(e)}`;async function L(e){if(!N.value.has(e)){N.value=new Set(N.value).add(e);try{let t=await k.api(`${F.value}/list?${I(e)}`),n=new Map(j.value);n.set(e,t.entries),j.value=n,P.value=``}catch(e){P.value=e.message}finally{let t=new Set(N.value);t.delete(e),N.value=t}}}n(()=>[k.hostId,k.cwd],()=>{j.value=new Map,M.value=new Set,L(`.`)},{immediate:!0});function R(e){let t=new Set(M.value);t.has(e.path)?t.delete(e.path):(t.add(e.path),j.value.has(e.path)||L(e.path)),M.value=t}let z=d(()=>{let e=[],t=(n,r)=>{for(let i of j.value.get(n)??[])e.push({entry:i,depth:r}),i.kind===`directory`&&M.value.has(i.path)&&t(i.path,r+1)};return t(`.`,0),e});return(e,n)=>(r(),h(`div`,y,[u(`div`,b,[u(`span`,{class:`files-root`,title:a.cwd},f(a.cwd.split(`/`).filter(Boolean).pop()||a.cwd),9,x),u(`button`,{class:`icon-btn`,title:`Refresh`,"aria-label":`Refresh files`,onClick:n[0]||=e=>{j.value=new Map,M.value=new Set,L(`.`)}},[t(v,{name:`refresh`,size:14})])]),P.value?(r(),h(`p`,S,[t(v,{name:`alert`,size:13}),i(f(P.value),1)])):m(``,!0),u(`div`,C,[(r(!0),h(l,null,g(z.value,e=>(r(),h(`button`,{key:e.entry.path,class:p([`tree-row`,{chosen:e.entry.path===a.activePath}]),role:`treeitem`,"aria-expanded":e.entry.kind===`directory`?M.value.has(e.entry.path):void 0,style:s({paddingLeft:8+e.depth*14+`px`}),title:e.entry.path,onClick:t=>e.entry.kind===`directory`?R(e.entry):A(`open`,e.entry.path)},[e.entry.kind===`directory`?(r(),o(v,{key:0,name:`chevron`,size:11,class:p([`tree-caret`,{open:M.value.has(e.entry.path)}])},null,8,[`class`])):(r(),h(`span`,T)),t(v,{name:e.entry.kind===`directory`?`folder`:`file`,size:14,class:`tree-icon`},null,8,[`name`]),u(`span`,E,f(e.entry.name),1),N.value.has(e.entry.path)?(r(),h(`span`,D)):m(``,!0)],14,w))),128)),!z.value.length&&N.value.has(`.`)?(r(),h(`div`,O,[...n[1]||=[u(`span`,{class:`spinner`},null,-1)]])):m(``,!0)])]))}}),[[`__scopeId`,`data-v-f29d6f68`]]);export{k as default};
1
+ import{$ as e,C as t,G as n,I as r,S as i,T as a,_ as o,at as s,et as c,f as l,g as u,h as d,ot as f,rt as p,v as m,y as h,z as g}from"./vue.runtime.esm-bundler-DwGo9CTz.js";import{n as _,s as v}from"./index-By8I8BM7.js";var y={class:`files`},b={class:`files-head`},x=[`title`],S={key:0,class:`files-error`},C={class:`tree`,role:`tree`},w=[`aria-expanded`,`title`,`onClick`],T={key:1,class:`tree-caret`},E={class:`tree-name`},D={key:2,class:`spinner spinner-sm`},O={key:0,class:`files-empty`},k=_(a({__name:`FilesPanel`,props:{hostId:{},cwd:{},api:{type:Function},activePath:{}},emits:[`open`],setup(a,{emit:_}){let k=a,A=_,j=c(new Map),M=e(new Set),N=e(new Set),P=e(``),F=d(()=>`/hosts/${encodeURIComponent(k.hostId)}/fs`),I=e=>`cwd=${encodeURIComponent(k.cwd)}&path=${encodeURIComponent(e)}`;async function L(e){if(!N.value.has(e)){N.value=new Set(N.value).add(e);try{let t=await k.api(`${F.value}/list?${I(e)}`),n=new Map(j.value);n.set(e,t.entries),j.value=n,P.value=``}catch(e){P.value=e.message}finally{let t=new Set(N.value);t.delete(e),N.value=t}}}n(()=>[k.hostId,k.cwd],()=>{j.value=new Map,M.value=new Set,L(`.`)},{immediate:!0});function R(e){let t=new Set(M.value);t.has(e.path)?t.delete(e.path):(t.add(e.path),j.value.has(e.path)||L(e.path)),M.value=t}let z=d(()=>{let e=[],t=(n,r)=>{for(let i of j.value.get(n)??[])e.push({entry:i,depth:r}),i.kind===`directory`&&M.value.has(i.path)&&t(i.path,r+1)};return t(`.`,0),e});return(e,n)=>(r(),h(`div`,y,[u(`div`,b,[u(`span`,{class:`files-root`,title:a.cwd},f(a.cwd.split(`/`).filter(Boolean).pop()||a.cwd),9,x),u(`button`,{class:`icon-btn`,title:`Refresh`,"aria-label":`Refresh files`,onClick:n[0]||=e=>{j.value=new Map,M.value=new Set,L(`.`)}},[t(v,{name:`refresh`,size:14})])]),P.value?(r(),h(`p`,S,[t(v,{name:`alert`,size:13}),i(f(P.value),1)])):m(``,!0),u(`div`,C,[(r(!0),h(l,null,g(z.value,e=>(r(),h(`button`,{key:e.entry.path,class:p([`tree-row`,{chosen:e.entry.path===a.activePath}]),role:`treeitem`,"aria-expanded":e.entry.kind===`directory`?M.value.has(e.entry.path):void 0,style:s({paddingLeft:8+e.depth*14+`px`}),title:e.entry.path,onClick:t=>e.entry.kind===`directory`?R(e.entry):A(`open`,e.entry.path)},[e.entry.kind===`directory`?(r(),o(v,{key:0,name:`chevron`,size:11,class:p([`tree-caret`,{open:M.value.has(e.entry.path)}])},null,8,[`class`])):(r(),h(`span`,T)),t(v,{name:e.entry.kind===`directory`?`folder`:`file`,size:14,class:`tree-icon`},null,8,[`name`]),u(`span`,E,f(e.entry.name),1),N.value.has(e.entry.path)?(r(),h(`span`,D)):m(``,!0)],14,w))),128)),!z.value.length&&N.value.has(`.`)?(r(),h(`div`,O,[...n[1]||=[u(`span`,{class:`spinner`},null,-1)]])):m(``,!0)])]))}}),[[`__scopeId`,`data-v-f29d6f68`]]);export{k as default};