@av-pi-studio/workbench 0.0.0-stage → 0.0.118

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 (273) hide show
  1. package/README.md +157 -2
  2. package/dist/chunks/BinaryFallbackViewer-BN-9Yvel.js +19 -0
  3. package/dist/chunks/ChatPanel-CjPUJMEs.js +2493 -0
  4. package/dist/chunks/CodeView-6kJms_MF.js +143 -0
  5. package/dist/chunks/DiffView-BqDuT3CF.js +48 -0
  6. package/dist/chunks/FilePanel-B8IXG2bj.js +92 -0
  7. package/dist/chunks/HtmlViewer-DpuVFaDo.js +490 -0
  8. package/dist/chunks/ImageViewer-BBfyA5QN.js +27 -0
  9. package/dist/chunks/MarkdownFileViewer-DPFPDS7G.js +88 -0
  10. package/dist/chunks/ModelProvidersPanel-Dsezq7Ss.js +95 -0
  11. package/dist/chunks/MoleculeViewerPanel-DEEU6Zkx.js +191 -0
  12. package/dist/chunks/PdfViewer-BdacmAu_.js +300 -0
  13. package/dist/chunks/SaveFileButton-2rOu02Xx.js +33 -0
  14. package/dist/chunks/SettingsDialog-DO1tDhMW.js +471 -0
  15. package/dist/chunks/SkillsPanel-DZDia4Pw.js +833 -0
  16. package/dist/chunks/TerminalPanel-bphwCSyW.js +242 -0
  17. package/dist/chunks/TextViewer-CVGqN6yy.js +63 -0
  18. package/dist/chunks/VideoViewer-BkB9BoOr.js +20 -0
  19. package/dist/chunks/ViewersPanel-C2E9FLf7.js +50 -0
  20. package/dist/chunks/href-resolution-jv3tpRcp.js +25 -0
  21. package/dist/chunks/index-Dlz8mEKZ.js +6258 -0
  22. package/dist/chunks/markdown-B2OXhZ-_.js +353 -0
  23. package/dist/chunks/provider-auth-store-C1GaLTlw.js +34 -0
  24. package/dist/chunks/use-file-download-CogCqTvU.js +31 -0
  25. package/dist/chunks/use-file-watch-Bb_Xzbr-.js +55 -0
  26. package/dist/chunks/use-provider-auth-list-DTjIZycd.js +16 -0
  27. package/dist/features/agent-ui/AskCard.d.ts +62 -0
  28. package/dist/features/agent-ui/agent-ui-store.d.ts +84 -0
  29. package/dist/features/agent-ui/announce.d.ts +51 -0
  30. package/dist/features/agent-ui/ask-list.d.ts +53 -0
  31. package/dist/features/agent-ui/ask-placement.d.ts +47 -0
  32. package/dist/features/agent-ui/deadline.d.ts +27 -0
  33. package/dist/features/agent-ui/keyboard.d.ts +37 -0
  34. package/dist/features/agent-ui/notify-effect.d.ts +41 -0
  35. package/dist/features/agent-ui/option-layout.d.ts +24 -0
  36. package/dist/features/agent-ui/outcome-line.d.ts +38 -0
  37. package/dist/features/agent-ui/prompt-text.d.ts +24 -0
  38. package/dist/features/chat/Attachments.d.ts +20 -0
  39. package/dist/features/chat/ChatPanel.d.ts +12 -0
  40. package/dist/features/chat/CommandMenu.d.ts +41 -0
  41. package/dist/features/chat/Composer.d.ts +58 -0
  42. package/dist/features/chat/ForkDialog.d.ts +24 -0
  43. package/dist/features/chat/ModelMenu.d.ts +54 -0
  44. package/dist/features/chat/ThinkingMenu.d.ts +39 -0
  45. package/dist/features/chat/Timeline.d.ts +30 -0
  46. package/dist/features/chat/TurnProgressBar.d.ts +14 -0
  47. package/dist/features/chat/composer-busy.d.ts +22 -0
  48. package/dist/features/chat/composer-gate.d.ts +37 -0
  49. package/dist/features/chat/composer-path-drop.d.ts +75 -0
  50. package/dist/features/chat/fork-correlation.d.ts +39 -0
  51. package/dist/features/chat/fork-gate.d.ts +27 -0
  52. package/dist/features/chat/fork-picker-nav.d.ts +14 -0
  53. package/dist/features/chat/fork-result.d.ts +43 -0
  54. package/dist/features/chat/model-menu-sort.d.ts +30 -0
  55. package/dist/features/chat/onboarding-nudge.d.ts +18 -0
  56. package/dist/features/chat/rows/AssistantRow.d.ts +24 -0
  57. package/dist/features/chat/rows/CompactionRow.d.ts +16 -0
  58. package/dist/features/chat/rows/ErrorRow.d.ts +13 -0
  59. package/dist/features/chat/rows/ReasoningRow.d.ts +16 -0
  60. package/dist/features/chat/rows/RowShell.d.ts +37 -0
  61. package/dist/features/chat/rows/SystemRow.d.ts +11 -0
  62. package/dist/features/chat/rows/ToolCard.d.ts +30 -0
  63. package/dist/features/chat/rows/UserRow.d.ts +43 -0
  64. package/dist/features/chat/slash-commands.d.ts +81 -0
  65. package/dist/features/chat/thinking-level-source.d.ts +29 -0
  66. package/dist/features/chat/todos/TodoPanel.d.ts +11 -0
  67. package/dist/features/chat/todos/agent-todos-store.d.ts +35 -0
  68. package/dist/features/chat/todos/todo-collapse-codec.d.ts +12 -0
  69. package/dist/features/chat/todos/todo-panel-model.d.ts +37 -0
  70. package/dist/features/chat/use-bottom-anchor.d.ts +33 -0
  71. package/dist/features/chat/use-fork-action.d.ts +32 -0
  72. package/dist/features/connection/ConnectionBar.d.ts +18 -0
  73. package/dist/features/connection/connection-presentation.d.ts +70 -0
  74. package/dist/features/files/BinaryFallbackViewer.d.ts +9 -0
  75. package/dist/features/files/CodeView.d.ts +15 -0
  76. package/dist/features/files/DiffView.d.ts +18 -0
  77. package/dist/features/files/FileContextMenu.d.ts +13 -0
  78. package/dist/features/files/FileExplorer.d.ts +24 -0
  79. package/dist/features/files/FilePanel.d.ts +26 -0
  80. package/dist/features/files/HtmlViewer.d.ts +22 -0
  81. package/dist/features/files/ImageViewer.d.ts +8 -0
  82. package/dist/features/files/MarkdownFileViewer.d.ts +14 -0
  83. package/dist/features/files/MoleculeViewer.d.ts +60 -0
  84. package/dist/features/files/MoleculeViewerPanel.d.ts +9 -0
  85. package/dist/features/files/PdfViewer.d.ts +14 -0
  86. package/dist/features/files/RightSidebar.d.ts +9 -0
  87. package/dist/features/files/SaveFileButton.d.ts +9 -0
  88. package/dist/features/files/TextViewer.d.ts +23 -0
  89. package/dist/features/files/TreeDraftRow.d.ts +15 -0
  90. package/dist/features/files/TreeNode.d.ts +42 -0
  91. package/dist/features/files/TreeRenameRow.d.ts +19 -0
  92. package/dist/features/files/VideoViewer.d.ts +8 -0
  93. package/dist/features/files/create-entry.d.ts +23 -0
  94. package/dist/features/files/delete-entry.d.ts +17 -0
  95. package/dist/features/files/file-tree.d.ts +92 -0
  96. package/dist/features/files/git-status-index.d.ts +37 -0
  97. package/dist/features/files/html-asset-loader.d.ts +43 -0
  98. package/dist/features/files/html-assets.d.ts +97 -0
  99. package/dist/features/files/html-sandbox.d.ts +62 -0
  100. package/dist/features/files/molecule-reload.d.ts +20 -0
  101. package/dist/features/files/molecule-source.d.ts +10 -0
  102. package/dist/features/files/molecule-theme.d.ts +31 -0
  103. package/dist/features/files/move-entry.d.ts +10 -0
  104. package/dist/features/files/move-status.d.ts +10 -0
  105. package/dist/features/files/move-target.d.ts +31 -0
  106. package/dist/features/files/open-file-tab.d.ts +32 -0
  107. package/dist/features/files/pdf-layout.d.ts +28 -0
  108. package/dist/features/files/pdfjs-runtime.d.ts +30 -0
  109. package/dist/features/files/polymer-file.d.ts +33 -0
  110. package/dist/features/files/text-viewer-state.d.ts +53 -0
  111. package/dist/features/files/upload-sources.d.ts +20 -0
  112. package/dist/features/files/viewer-registry.d.ts +81 -0
  113. package/dist/features/files/write-file.d.ts +12 -0
  114. package/dist/features/git/ChangesPanel.d.ts +13 -0
  115. package/dist/features/provider-auth/LoginDialog.d.ts +21 -0
  116. package/dist/features/provider-auth/ModelProvidersPanel.d.ts +12 -0
  117. package/dist/features/provider-auth/QrCode.d.ts +26 -0
  118. package/dist/features/provider-auth/login-flow.d.ts +55 -0
  119. package/dist/features/provider-auth/provider-auth-presentation.d.ts +31 -0
  120. package/dist/features/provider-auth/provider-auth-store.d.ts +42 -0
  121. package/dist/features/sessions/SessionContextMenu.d.ts +11 -0
  122. package/dist/features/sessions/SessionItem.d.ts +22 -0
  123. package/dist/features/sessions/SessionList.d.ts +9 -0
  124. package/dist/features/sessions/WorkspaceContextMenu.d.ts +9 -0
  125. package/dist/features/sessions/WorkspaceGroupHeader.d.ts +26 -0
  126. package/dist/features/sessions/apply-agent-deep-link.d.ts +7 -0
  127. package/dist/features/sessions/open-chat-tab.d.ts +14 -0
  128. package/dist/features/sessions/open-workspace.d.ts +20 -0
  129. package/dist/features/sessions/session-actions.d.ts +18 -0
  130. package/dist/features/sessions/session-presentation.d.ts +47 -0
  131. package/dist/features/sessions/status-map.d.ts +10 -0
  132. package/dist/features/sessions/workspace-grouping.d.ts +30 -0
  133. package/dist/features/settings/SettingsDialog.d.ts +22 -0
  134. package/dist/features/settings/ViewersPanel.d.ts +18 -0
  135. package/dist/features/settings/settings-categories.d.ts +32 -0
  136. package/dist/features/skills/InstallSkillDialog.d.ts +21 -0
  137. package/dist/features/skills/SkillsPanel.d.ts +32 -0
  138. package/dist/features/skills/skills-presentation.d.ts +159 -0
  139. package/dist/features/skills/use-skills.d.ts +215 -0
  140. package/dist/features/terminal/TerminalPanel.d.ts +37 -0
  141. package/dist/features/terminal/terminal-font.d.ts +44 -0
  142. package/dist/features/terminal/terminal-size.d.ts +52 -0
  143. package/dist/features/workspace/ContextMeter.d.ts +15 -0
  144. package/dist/features/workspace/ContextMeterPopover.d.ts +16 -0
  145. package/dist/features/workspace/DropPreview.d.ts +23 -0
  146. package/dist/features/workspace/PaneDividers.d.ts +30 -0
  147. package/dist/features/workspace/StatusBar.d.ts +16 -0
  148. package/dist/features/workspace/TabContextMenu.d.ts +15 -0
  149. package/dist/features/workspace/TabPanelHost.d.ts +30 -0
  150. package/dist/features/workspace/TabStrip.d.ts +36 -0
  151. package/dist/features/workspace/compact-action.d.ts +21 -0
  152. package/dist/features/workspace/context-meter.d.ts +26 -0
  153. package/dist/features/workspace/external-drag.d.ts +99 -0
  154. package/dist/features/workspace/pane-dnd.d.ts +70 -0
  155. package/dist/features/workspace/pane-layout-view.d.ts +73 -0
  156. package/dist/features/workspace/pane-tree.d.ts +141 -0
  157. package/dist/features/workspace/panel-registry.d.ts +13 -0
  158. package/dist/features/workspace/reopen-client-tabs.d.ts +44 -0
  159. package/dist/features/workspace/restore-active-workspace.d.ts +30 -0
  160. package/dist/features/workspace/status-bar-format.d.ts +20 -0
  161. package/dist/features/workspace/tab-attention.d.ts +35 -0
  162. package/dist/features/workspace-picker/OpenWorkspaceDialog.d.ts +11 -0
  163. package/dist/fonts/CascadiaMono.woff2 +0 -0
  164. package/dist/fonts/CascadiaMonoNF.woff2 +0 -0
  165. package/dist/fonts/LICENSE-Cascadia.txt +97 -0
  166. package/dist/fonts.css +60 -0
  167. package/dist/hooks/agent-stream-events.d.ts +20 -0
  168. package/dist/hooks/file-text-state.d.ts +31 -0
  169. package/dist/hooks/file-transfer-instance.d.ts +10 -0
  170. package/dist/hooks/use-agent-commands.d.ts +18 -0
  171. package/dist/hooks/use-agent-deep-link-boot.d.ts +9 -0
  172. package/dist/hooks/use-agent-stream.d.ts +15 -0
  173. package/dist/hooks/use-agent-todos.d.ts +10 -0
  174. package/dist/hooks/use-checkout-status.d.ts +13 -0
  175. package/dist/hooks/use-connection.d.ts +27 -0
  176. package/dist/hooks/use-explorer-tree.d.ts +20 -0
  177. package/dist/hooks/use-explorer-watch.d.ts +39 -0
  178. package/dist/hooks/use-explorer.d.ts +21 -0
  179. package/dist/hooks/use-external-pane-drop.d.ts +47 -0
  180. package/dist/hooks/use-file-diff.d.ts +9 -0
  181. package/dist/hooks/use-file-download.d.ts +18 -0
  182. package/dist/hooks/use-file-live-refresh.d.ts +31 -0
  183. package/dist/hooks/use-file-read.d.ts +31 -0
  184. package/dist/hooks/use-file-source.d.ts +16 -0
  185. package/dist/hooks/use-file-text.d.ts +21 -0
  186. package/dist/hooks/use-file-transfer.d.ts +18 -0
  187. package/dist/hooks/use-file-watch.d.ts +36 -0
  188. package/dist/hooks/use-home-dir.d.ts +14 -0
  189. package/dist/hooks/use-inline-image.d.ts +37 -0
  190. package/dist/hooks/use-is-compacting.d.ts +9 -0
  191. package/dist/hooks/use-pane-drag.d.ts +40 -0
  192. package/dist/hooks/use-pane-layout.d.ts +40 -0
  193. package/dist/hooks/use-provider-auth-list.d.ts +19 -0
  194. package/dist/hooks/use-provider-models.d.ts +14 -0
  195. package/dist/hooks/use-session-restore.d.ts +44 -0
  196. package/dist/hooks/use-session-stats.d.ts +40 -0
  197. package/dist/hooks/use-shortcuts.d.ts +6 -0
  198. package/dist/hooks/use-terminal-exit-watch.d.ts +47 -0
  199. package/dist/hooks/use-terminal-restore.d.ts +38 -0
  200. package/dist/hooks/use-thinking-levels.d.ts +13 -0
  201. package/dist/hooks/use-timeline-reset-watch.d.ts +43 -0
  202. package/dist/hooks/use-viewer-settings.d.ts +17 -0
  203. package/dist/host/browser-clipboard.d.ts +9 -0
  204. package/dist/host/browser-connection.d.ts +13 -0
  205. package/dist/host/browser-files.d.ts +9 -0
  206. package/dist/host/browser-host.d.ts +14 -0
  207. package/dist/host/browser-launch.d.ts +19 -0
  208. package/dist/host/browser-worker-timers.d.ts +29 -0
  209. package/dist/host/external-link.d.ts +14 -0
  210. package/dist/host/index.d.ts +4 -0
  211. package/dist/host/install.d.ts +21 -0
  212. package/dist/host/types.d.ts +168 -0
  213. package/dist/index.d.ts +14 -0
  214. package/dist/index.js +18 -0
  215. package/dist/lib/agent-deep-link.d.ts +29 -0
  216. package/dist/lib/connection/connection-store.d.ts +49 -0
  217. package/dist/lib/connection/files-changed.d.ts +41 -0
  218. package/dist/lib/connection/live-file-transfer.d.ts +8 -0
  219. package/dist/lib/connection/normalize-url.d.ts +16 -0
  220. package/dist/lib/connection/query-client.d.ts +3 -0
  221. package/dist/lib/connection/resolve-connect-target.d.ts +10 -0
  222. package/dist/lib/connection/resume-action.d.ts +33 -0
  223. package/dist/lib/connection/resume-handler.d.ts +6 -0
  224. package/dist/lib/connection/rpc-keys.d.ts +39 -0
  225. package/dist/lib/drag-guard.d.ts +39 -0
  226. package/dist/lib/inline-image-cache.d.ts +34 -0
  227. package/dist/lib/pane-layout-persistence.d.ts +74 -0
  228. package/dist/lib/paths.d.ts +33 -0
  229. package/dist/lib/protocol/events.d.ts +19 -0
  230. package/dist/lib/protocol/timeline-paging.d.ts +29 -0
  231. package/dist/lib/random-id.d.ts +16 -0
  232. package/dist/shell/Workbench.d.ts +6 -0
  233. package/dist/shell/WorkbenchBoot.d.ts +4 -0
  234. package/dist/shell/WorkbenchProvider.d.ts +10 -0
  235. package/dist/shell/WorkspaceShell.d.ts +12 -0
  236. package/dist/shell/context.d.ts +8 -0
  237. package/dist/shell/hooks.d.ts +32 -0
  238. package/dist/shell/regions.d.ts +17 -0
  239. package/dist/stores/compaction-store.d.ts +45 -0
  240. package/dist/stores/deep-link-store.d.ts +15 -0
  241. package/dist/stores/draft-store.d.ts +45 -0
  242. package/dist/stores/explorer-store.d.ts +63 -0
  243. package/dist/stores/fork-store.d.ts +69 -0
  244. package/dist/stores/git-store.d.ts +59 -0
  245. package/dist/stores/layout-store.d.ts +137 -0
  246. package/dist/stores/materialize.d.ts +47 -0
  247. package/dist/stores/session-store.d.ts +76 -0
  248. package/dist/stores/stats-store.d.ts +48 -0
  249. package/dist/stores/tab-store.d.ts +145 -0
  250. package/dist/stores/ui-store.d.ts +85 -0
  251. package/dist/styles.css +1 -0
  252. package/dist/timeline/FileLink.d.ts +22 -0
  253. package/dist/timeline/InlineImage.d.ts +16 -0
  254. package/dist/timeline/bottom-anchor.d.ts +77 -0
  255. package/dist/timeline/compaction.d.ts +12 -0
  256. package/dist/timeline/file-link-src.d.ts +34 -0
  257. package/dist/timeline/file-open-target.d.ts +19 -0
  258. package/dist/timeline/format-meta-time.d.ts +10 -0
  259. package/dist/timeline/highlight.d.ts +9 -0
  260. package/dist/timeline/href-resolution.d.ts +34 -0
  261. package/dist/timeline/image-src.d.ts +32 -0
  262. package/dist/timeline/inline-image-view.d.ts +34 -0
  263. package/dist/timeline/live-tail.d.ts +5 -0
  264. package/dist/timeline/markdown.d.ts +35 -0
  265. package/dist/timeline/mermaid-theme.d.ts +23 -0
  266. package/dist/timeline/reducer.d.ts +38 -0
  267. package/dist/timeline/row-model.d.ts +154 -0
  268. package/dist/timeline/streaming-split.d.ts +42 -0
  269. package/dist/timeline/tool-mapping.d.ts +60 -0
  270. package/dist/viewer-plugins/viewer-settings-store.d.ts +55 -0
  271. package/dist/vite/index.d.ts +36 -0
  272. package/dist/vite/index.js +39 -0
  273. package/package.json +81 -4
@@ -0,0 +1,490 @@
1
+ import { jsx as w, jsxs as m } from "react/jsx-runtime";
2
+ import { useState as P, useMemo as S } from "react";
3
+ import { useQueryClient as ie, useQuery as ae } from "@tanstack/react-query";
4
+ import { EmptyState as N, Spinner as j, Button as I, Switch as ce } from "@av-pi-studio/ui-library";
5
+ import { u as le, C as ue } from "./CodeView-6kJms_MF.js";
6
+ import { n as de, H as G, _ as fe, Q as X, u as D, i as me, r as R, $ as pe } from "./index-Dlz8mEKZ.js";
7
+ import { p as he, S as ge } from "./href-resolution-jv3tpRcp.js";
8
+ import { S as we } from "./SaveFileButton-2rOu02Xx.js";
9
+ const O = {
10
+ maxCount: 64,
11
+ maxBytesPerAsset: 2 * 1024 * 1024,
12
+ // 2 MiB
13
+ maxBytesTotal: 16 * 1024 * 1024
14
+ // 16 MiB — base64 inflates raw bytes ~33%; this cap keeps the
15
+ // assembled `srcdoc` string off the main thread as a multi-hundred-MB allocation.
16
+ };
17
+ function F(n, t, e) {
18
+ return !(n >= O.maxCount || e > O.maxBytesPerAsset || t + e > O.maxBytesTotal);
19
+ }
20
+ function Y(n) {
21
+ return n === "" || n.startsWith("#") ? "unsupported" : n.startsWith("//") || ge.test(n) ? "external" : null;
22
+ }
23
+ function ve(n, t, e) {
24
+ return e !== null && t === e ? n : t;
25
+ }
26
+ function J(n, t, e, s, o = null) {
27
+ const r = n.trim(), c = Y(r);
28
+ if (c) return { kind: "skip", raw: n, reason: c };
29
+ const i = he(r);
30
+ let p;
31
+ if (i.startsWith("/") ? p = i : i === "~" || i.startsWith("~/") ? p = o !== null ? de(i, o) : null : p = G(i, t), !p) return { kind: "skip", raw: n, reason: "unsupported" };
32
+ const h = fe(p);
33
+ return h !== e && !h.startsWith(`${e}/`) ? { kind: "skip", raw: n, reason: "outside-workspace" } : { kind: "local", raw: n, path: h, context: s };
34
+ }
35
+ const xe = {
36
+ css: "text/css",
37
+ js: "text/javascript",
38
+ mjs: "text/javascript",
39
+ html: "text/html",
40
+ htm: "text/html",
41
+ json: "application/json",
42
+ png: "image/png",
43
+ jpg: "image/jpeg",
44
+ jpeg: "image/jpeg",
45
+ gif: "image/gif",
46
+ webp: "image/webp",
47
+ svg: "image/svg+xml",
48
+ ico: "image/x-icon",
49
+ bmp: "image/bmp",
50
+ avif: "image/avif",
51
+ mp4: "video/mp4",
52
+ webm: "video/webm",
53
+ mov: "video/quicktime",
54
+ m4v: "video/x-m4v",
55
+ ogv: "video/ogg",
56
+ mp3: "audio/mpeg",
57
+ wav: "audio/wav",
58
+ oga: "audio/ogg",
59
+ ogg: "audio/ogg",
60
+ m4a: "audio/mp4",
61
+ woff: "font/woff",
62
+ woff2: "font/woff2",
63
+ ttf: "font/ttf",
64
+ otf: "font/otf",
65
+ eot: "application/vnd.ms-fontobject"
66
+ };
67
+ function be(n) {
68
+ const t = n.lastIndexOf("/"), e = n.lastIndexOf(".");
69
+ return e <= t ? "application/octet-stream" : xe[n.slice(e + 1).toLowerCase()] ?? "application/octet-stream";
70
+ }
71
+ function ye(n) {
72
+ let t = "";
73
+ for (let s = 0; s < n.length; s += 32768)
74
+ t += String.fromCharCode(...n.subarray(s, s + 32768));
75
+ return btoa(t);
76
+ }
77
+ function K(n, t) {
78
+ return `data:${n};base64,${ye(t)}`;
79
+ }
80
+ const M = /<([a-zA-Z][a-zA-Z0-9]*)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*)(\s*\/?>)/g, V = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+))/g;
81
+ function ee(n) {
82
+ const t = /* @__PURE__ */ new Map();
83
+ V.lastIndex = 0;
84
+ let e;
85
+ for (; e = V.exec(n); ) {
86
+ const s = e[1].toLowerCase();
87
+ t.has(s) || t.set(s, e[2] ?? e[3] ?? e[4] ?? "");
88
+ }
89
+ return t;
90
+ }
91
+ function te(n, t) {
92
+ switch (n) {
93
+ case "link": {
94
+ const e = t.get("rel") ?? "";
95
+ return /(^|\s)stylesheet(\s|$)/i.test(e) ? t.has("href") ? [{ name: "href", context: "style", multi: !1 }] : [] : [];
96
+ }
97
+ case "script":
98
+ return t.has("src") ? [{ name: "src", context: "script", multi: !1 }] : [];
99
+ case "img": {
100
+ const e = [];
101
+ return t.has("src") && e.push({ name: "src", context: "image", multi: !1 }), t.has("srcset") && e.push({ name: "srcset", context: "image", multi: !0 }), e;
102
+ }
103
+ case "source": {
104
+ const e = [];
105
+ return t.has("src") && e.push({ name: "src", context: "media", multi: !1 }), t.has("srcset") && e.push({ name: "srcset", context: "media", multi: !0 }), e;
106
+ }
107
+ case "video": {
108
+ const e = [];
109
+ return t.has("src") && e.push({ name: "src", context: "media", multi: !1 }), t.has("poster") && e.push({ name: "poster", context: "media", multi: !1 }), e;
110
+ }
111
+ case "audio":
112
+ return t.has("src") ? [{ name: "src", context: "media", multi: !1 }] : [];
113
+ default:
114
+ return [];
115
+ }
116
+ }
117
+ function ne(n) {
118
+ return n.split(",").map((t) => t.trim()).filter((t) => t !== "").map((t) => {
119
+ const e = t.search(/\s/);
120
+ return e === -1 ? { url: t, descriptor: "" } : { url: t.slice(0, e), descriptor: t.slice(e).trim() };
121
+ });
122
+ }
123
+ function _e(n) {
124
+ return n.map((t) => t.descriptor ? `${t.url} ${t.descriptor}` : t.url).join(", ");
125
+ }
126
+ function $(n, t, e) {
127
+ Y(t.trim()) || n.has(t) || n.set(t, { raw: t, context: e });
128
+ }
129
+ function ke(n) {
130
+ const t = /* @__PURE__ */ new Map();
131
+ M.lastIndex = 0;
132
+ let e;
133
+ for (; e = M.exec(n); ) {
134
+ const s = e[1].toLowerCase(), o = ee(e[2] ?? "");
135
+ for (const r of te(s, o)) {
136
+ const c = o.get(r.name) ?? "";
137
+ if (r.multi)
138
+ for (const i of ne(c)) $(t, i.url, r.context);
139
+ else
140
+ $(t, c, r.context);
141
+ }
142
+ }
143
+ return [...t.values()];
144
+ }
145
+ function Se(n, t) {
146
+ let e = !1;
147
+ const s = ne(n).map((o) => {
148
+ const r = t[o.url];
149
+ return r === void 0 ? o : (e = !0, { url: r, descriptor: o.descriptor });
150
+ });
151
+ return e ? _e(s) : null;
152
+ }
153
+ function Ee(n, t) {
154
+ return Object.keys(t).length === 0 ? n : (M.lastIndex = 0, n.replace(M, (e, s, o, r) => {
155
+ const c = ee(o), i = te(s.toLowerCase(), c);
156
+ if (i.length === 0) return e;
157
+ const p = new Map(i.map((u) => [u.name, u]));
158
+ let h = !1;
159
+ const A = o.replace(
160
+ V,
161
+ (u, d, a, x, y) => {
162
+ const b = p.get(d.toLowerCase());
163
+ if (!b) return u;
164
+ const g = a ?? x ?? y ?? "", E = b.multi ? Se(g, t) : t[g] ?? null;
165
+ return E === null ? u : (h = !0, `${d}="${E}"`);
166
+ }
167
+ );
168
+ return h ? `<${s}${A}${r}` : e;
169
+ }));
170
+ }
171
+ const z = /url\(\s*(?:"([^"]*)"|'([^']*)'|([^'")\s]*))\s*\)/gi, q = /@font-face\s*\{[^}]*\}/gi;
172
+ function se(n, t, e) {
173
+ return n ?? t ?? e ?? "";
174
+ }
175
+ function Le(n) {
176
+ const t = [];
177
+ q.lastIndex = 0;
178
+ let e;
179
+ for (; e = q.exec(n); ) t.push([e.index, e.index + e[0].length]);
180
+ return t;
181
+ }
182
+ function Ae(n) {
183
+ const t = Le(n), e = /* @__PURE__ */ new Map();
184
+ z.lastIndex = 0;
185
+ let s;
186
+ for (; s = z.exec(n); ) {
187
+ const o = se(s[1], s[2], s[3]), r = t.some(
188
+ ([c, i]) => s.index >= c && s.index < i
189
+ ) ? "font" : "image";
190
+ $(e, o, r);
191
+ }
192
+ return [...e.values()];
193
+ }
194
+ function Ce(n, t) {
195
+ return Object.keys(t).length === 0 ? n : (z.lastIndex = 0, n.replace(z, (e, s, o, r) => {
196
+ const c = t[se(s, o, r)];
197
+ return c === void 0 ? e : `url("${c}")`;
198
+ }));
199
+ }
200
+ const Ne = Object.freeze(["allow-scripts"]), Te = "https://pi-studio-preview.invalid/", Be = "default-src 'none'; img-src data:; style-src 'unsafe-inline' data:; script-src 'unsafe-inline' data:; font-src data:; media-src data:", Re = `<script>(function(){document.addEventListener("click",function(e){var a=e.target&&e.target.closest&&e.target.closest('a[href^="#"]');if(!a)return;var frag=a.getAttribute("href").slice(1);e.preventDefault();if(!frag){window.scrollTo(0,0);return;}var el=document.getElementById(frag)||document.getElementsByName(frag)[0];if(el)el.scrollIntoView();},true);})();<\/script>`, He = /<head(\s[^>]*)?>/i, Me = /<html(\s[^>]*)?>/i, ze = /<base[\s/>]/i;
201
+ function Pe(n, t) {
202
+ const e = Ee(n, t.assets ?? {}), s = [];
203
+ t.blockRemote && s.push(
204
+ `<meta http-equiv="Content-Security-Policy" content="${Be}">`
205
+ ), ze.test(e) || (s.push(`<base href="${Te}">`), s.push(Re));
206
+ const o = s.join("");
207
+ if (o === "") return e;
208
+ const r = He.exec(e);
209
+ if (r) {
210
+ const i = r.index + r[0].length;
211
+ return e.slice(0, i) + o + e.slice(i);
212
+ }
213
+ const c = Me.exec(e);
214
+ if (c) {
215
+ const i = c.index + c[0].length;
216
+ return e.slice(0, i) + `<head>${o}</head>` + e.slice(i);
217
+ }
218
+ return `<head>${o}</head>` + e;
219
+ }
220
+ const Q = 6;
221
+ async function W(n, t, e) {
222
+ let s = 0;
223
+ async function o() {
224
+ for (; s < n.length; ) {
225
+ const r = n[s];
226
+ s += 1, await e(r);
227
+ }
228
+ }
229
+ await Promise.all(Array.from({ length: Math.min(t, n.length) }, o));
230
+ }
231
+ function U(n) {
232
+ const t = /* @__PURE__ */ new Map();
233
+ for (const e of n) {
234
+ const s = t.get(e.path);
235
+ s ? s.push(e) : t.set(e.path, [e]);
236
+ }
237
+ return t;
238
+ }
239
+ async function je(n, t) {
240
+ const e = {}, s = [];
241
+ let o = 0, r = 0, c = !1;
242
+ const i = [];
243
+ for (const u of n)
244
+ u.kind === "skip" ? s.push({ raw: u.raw, reason: u.reason }) : i.push(u);
245
+ function p(u, d) {
246
+ for (const a of u) s.push({ raw: a.raw, reason: d });
247
+ }
248
+ async function h(u, d) {
249
+ if (c) {
250
+ p(d, "over-cap");
251
+ return;
252
+ }
253
+ let a;
254
+ try {
255
+ a = await t.fetchBytes(u);
256
+ } catch {
257
+ p(d, "fetch-failed");
258
+ return;
259
+ }
260
+ if (!F(o, r, a.byteLength)) {
261
+ c = !0, p(d, "over-cap");
262
+ return;
263
+ }
264
+ if (o += 1, r += a.byteLength, d[0].context !== "style") {
265
+ const f = K(be(u), a);
266
+ for (const k of d) e[k.raw] = f;
267
+ return;
268
+ }
269
+ const x = new TextDecoder().decode(a), y = X(u), b = Ae(x).map(
270
+ (f) => J(f.raw, y, t.root, f.context, t.homeDir)
271
+ ), g = [];
272
+ for (const f of b)
273
+ f.kind === "skip" ? s.push({ raw: f.raw, reason: f.reason }) : g.push(f);
274
+ const E = U(g);
275
+ await W(
276
+ [...E.entries()],
277
+ Q,
278
+ ([f, k]) => h(f, k)
279
+ );
280
+ const T = {};
281
+ for (const f of g) {
282
+ const k = e[f.raw];
283
+ k !== void 0 && (T[f.raw] = k);
284
+ }
285
+ const C = Ce(x, T), L = new TextEncoder().encode(C), _ = L.byteLength - a.byteLength;
286
+ if (_ > 0 && !F(o - 1, r - a.byteLength, L.byteLength)) {
287
+ c = !0, p(d, "over-cap");
288
+ return;
289
+ }
290
+ r += _;
291
+ const B = K("text/css", L);
292
+ for (const f of d) e[f.raw] = B;
293
+ }
294
+ const A = U(i);
295
+ return await W(
296
+ [...A.entries()],
297
+ Q,
298
+ ([u, d]) => h(u, d)
299
+ ), { assets: e, skipped: s };
300
+ }
301
+ const Ie = "piwb-HtmlViewer_wrap_zVa2Y", Oe = "piwb-HtmlViewer_toolbar_BJS-C", Ve = "piwb-HtmlViewer_modeToggle_vtj-V", $e = "piwb-HtmlViewer_controls_7oQnM", De = "piwb-HtmlViewer_switchLabel_lI99i", Fe = "piwb-HtmlViewer_streamedNote_Dbx4P", Ke = "piwb-HtmlViewer_skippedNote_ITPaJ", qe = "piwb-HtmlViewer_skippedToggle_X2Aij", Qe = "piwb-HtmlViewer_skippedList_cCdE1", We = "piwb-HtmlViewer_body_Ub6gT", Ue = "piwb-HtmlViewer_frame_feA57", Ze = "piwb-HtmlViewer_tooLarge_W3dLq", v = {
302
+ wrap: Ie,
303
+ toolbar: Oe,
304
+ modeToggle: Ve,
305
+ controls: $e,
306
+ switchLabel: De,
307
+ streamedNote: Fe,
308
+ skippedNote: Ke,
309
+ skippedToggle: qe,
310
+ skippedList: Qe,
311
+ body: We,
312
+ frame: Ue,
313
+ tooLarge: Ze
314
+ }, Ge = Ne.join(" "), Z = Object.freeze({}), Xe = Object.freeze([]), re = {
315
+ external: "external",
316
+ "outside-workspace": "outside workspace",
317
+ unsupported: "unsupported",
318
+ "over-cap": "over cap",
319
+ "fetch-failed": "not found"
320
+ };
321
+ function Ye(n) {
322
+ const t = /* @__PURE__ */ new Map();
323
+ for (const e of n) {
324
+ const s = re[e.reason];
325
+ t.set(s, (t.get(s) ?? 0) + 1);
326
+ }
327
+ return [...t.entries()].map(([e, s]) => `${s} ${e}`).join(", ");
328
+ }
329
+ function Je(n) {
330
+ let t = 2166136261;
331
+ for (let e = 0; e < n.length; e++)
332
+ t ^= n.charCodeAt(e), t = Math.imul(t, 16777619);
333
+ return (t >>> 0).toString(16);
334
+ }
335
+ function H(n) {
336
+ return `${(n / (1024 * 1024)).toFixed(1)} MB`;
337
+ }
338
+ function lt({ path: n, workspaceCwd: t }) {
339
+ const e = le(n), [s, o] = P("preview"), [r, c] = P(!1), [i, p] = P(!1), h = ie(), A = D((l) => l.client), u = D((l) => l.daemon), d = me(), a = e.kind === "inline" || e.kind === "streamed" ? e.content : null, x = S(() => {
340
+ const l = G(n, t);
341
+ return l ? X(l) : null;
342
+ }, [n, t]), y = S(
343
+ () => x !== null ? ve(x, t, d) : null,
344
+ [x, t, d]
345
+ ), b = S(() => a === null || x === null || y === null ? [] : ke(a).map(
346
+ (l) => J(l.raw, x, y, l.context, d)
347
+ ), [a, x, y, d]), g = S(() => b.some((l) => l.kind === "local"), [b]), E = S(
348
+ () => b.flatMap(
349
+ (l) => l.kind === "skip" ? [{ raw: l.raw, reason: l.reason }] : []
350
+ ),
351
+ [b]
352
+ ), T = S(
353
+ () => g && a !== null ? Je(a) : "",
354
+ [a, g]
355
+ ), C = ae({
356
+ queryKey: R.htmlAssetBundle(n, T),
357
+ queryFn: () => y === null ? Promise.resolve({ assets: {}, skipped: [] }) : je(b, { root: y, homeDir: d, fetchBytes: async (oe) => {
358
+ if (!A || !u) throw new Error("not connected");
359
+ return (await pe(u).download(oe)).bytes;
360
+ } }),
361
+ enabled: g,
362
+ // Immutable per (path, content hash) — a change is only ever observed via a new key
363
+ // (document edited) or an explicit Reload invalidation, never a background refetch.
364
+ staleTime: 1 / 0
365
+ }), L = g ? C.data?.assets ?? Z : Z, _ = g ? C.data?.skipped ?? Xe : E, B = S(() => a === null ? null : Pe(a, { assets: L, blockRemote: r }), [a, L, r]);
366
+ function f() {
367
+ h.invalidateQueries({ queryKey: R.fileRead(n) }), h.invalidateQueries({ queryKey: R.fileDownload(n) }), h.invalidateQueries({ queryKey: R.htmlAssetBundleByPath(n) });
368
+ }
369
+ switch (e.kind) {
370
+ case "loading":
371
+ return /* @__PURE__ */ m(N, { children: [
372
+ /* @__PURE__ */ w(j, { size: "sm" }),
373
+ " Loading..."
374
+ ] });
375
+ case "streaming":
376
+ return /* @__PURE__ */ m(N, { children: [
377
+ /* @__PURE__ */ w(j, { size: "sm" }),
378
+ " Streaming ",
379
+ H(e.size),
380
+ " file..."
381
+ ] });
382
+ case "stream-error":
383
+ case "error":
384
+ return /* @__PURE__ */ m(N, { children: [
385
+ "Error: ",
386
+ e.message
387
+ ] });
388
+ case "too-large":
389
+ return /* @__PURE__ */ w(N, { children: /* @__PURE__ */ m("div", { className: v.tooLarge, children: [
390
+ /* @__PURE__ */ m("div", { children: [
391
+ H(e.size),
392
+ " — too large to display (display ceiling is",
393
+ " ",
394
+ H(e.maxDisplayBytes),
395
+ ")."
396
+ ] }),
397
+ /* @__PURE__ */ w(we, { path: n })
398
+ ] }) });
399
+ }
400
+ if (a === null || B === null) return null;
401
+ if (g && C.data === void 0)
402
+ return /* @__PURE__ */ m(N, { children: [
403
+ /* @__PURE__ */ w(j, { size: "sm" }),
404
+ " Loading assets..."
405
+ ] });
406
+ const k = n.split("/").pop() || n;
407
+ return /* @__PURE__ */ m("div", { className: v.wrap, children: [
408
+ /* @__PURE__ */ m("div", { className: v.toolbar, children: [
409
+ /* @__PURE__ */ m("div", { className: v.modeToggle, children: [
410
+ /* @__PURE__ */ w(
411
+ I,
412
+ {
413
+ size: "xs",
414
+ variant: s === "preview" ? "default" : "ghost",
415
+ onClick: () => o("preview"),
416
+ children: "Preview"
417
+ }
418
+ ),
419
+ /* @__PURE__ */ w(
420
+ I,
421
+ {
422
+ size: "xs",
423
+ variant: s === "source" ? "default" : "ghost",
424
+ onClick: () => o("source"),
425
+ children: "Source"
426
+ }
427
+ )
428
+ ] }),
429
+ /* @__PURE__ */ m("div", { className: v.controls, children: [
430
+ /* @__PURE__ */ m("label", { className: v.switchLabel, children: [
431
+ /* @__PURE__ */ w(
432
+ ce,
433
+ {
434
+ checked: r,
435
+ onCheckedChange: c,
436
+ "aria-label": "Block remote resources"
437
+ }
438
+ ),
439
+ "Block remote resources"
440
+ ] }),
441
+ /* @__PURE__ */ w(I, { size: "xs", variant: "ghost", onClick: f, children: "Reload" })
442
+ ] })
443
+ ] }),
444
+ e.kind === "streamed" ? /* @__PURE__ */ m("div", { className: v.streamedNote, children: [
445
+ H(e.size),
446
+ " file streamed"
447
+ ] }) : null,
448
+ _.length > 0 ? /* @__PURE__ */ m("div", { className: v.skippedNote, children: [
449
+ /* @__PURE__ */ m(
450
+ "button",
451
+ {
452
+ type: "button",
453
+ className: v.skippedToggle,
454
+ onClick: () => p((l) => !l),
455
+ children: [
456
+ _.length,
457
+ " reference",
458
+ _.length === 1 ? "" : "s",
459
+ " not inlined (",
460
+ Ye(_),
461
+ ")"
462
+ ]
463
+ }
464
+ ),
465
+ i ? /* @__PURE__ */ w("ul", { className: v.skippedList, children: _.map((l) => /* @__PURE__ */ m("li", { children: [
466
+ l.raw,
467
+ " — ",
468
+ re[l.reason]
469
+ ] }, l.raw)) }) : null
470
+ ] }) : null,
471
+ /* @__PURE__ */ m("div", { className: v.body, children: [
472
+ /* @__PURE__ */ w(
473
+ "iframe",
474
+ {
475
+ sandbox: Ge,
476
+ srcDoc: B,
477
+ referrerPolicy: "no-referrer",
478
+ allow: "",
479
+ className: v.frame,
480
+ style: s === "preview" ? void 0 : { display: "none" },
481
+ title: k
482
+ }
483
+ ),
484
+ s === "source" ? /* @__PURE__ */ w(ue, { path: n, content: a }) : null
485
+ ] })
486
+ ] });
487
+ }
488
+ export {
489
+ lt as HtmlViewer
490
+ };
@@ -0,0 +1,27 @@
1
+ import { jsxs as o, jsx as i } from "react/jsx-runtime";
2
+ import { EmptyState as a, Spinner as n } from "@av-pi-studio/ui-library";
3
+ import { u as t } from "./use-file-download-CogCqTvU.js";
4
+ const m = "piwb-ImageViewer_wrap_ANXrA", c = "piwb-ImageViewer_image_fw4so", s = {
5
+ wrap: m,
6
+ image: c
7
+ };
8
+ function d({ path: e, workspaceCwd: p }) {
9
+ const r = t(e);
10
+ return r.isLoading ? /* @__PURE__ */ o(a, { children: [
11
+ /* @__PURE__ */ i(n, { size: "sm" }),
12
+ " Loading image..."
13
+ ] }) : r.isError ? /* @__PURE__ */ o(a, { children: [
14
+ "Error: ",
15
+ r.error instanceof Error ? r.error.message : "unknown error"
16
+ ] }) : r.data ? /* @__PURE__ */ i("div", { className: s.wrap, children: /* @__PURE__ */ i(
17
+ "img",
18
+ {
19
+ className: s.image,
20
+ src: r.data.objectUrl,
21
+ alt: e.split("/").pop() || e
22
+ }
23
+ ) }) : null;
24
+ }
25
+ export {
26
+ d as ImageViewer
27
+ };
@@ -0,0 +1,88 @@
1
+ import { jsxs as o, jsx as e } from "react/jsx-runtime";
2
+ import { useState as f, useMemo as g } from "react";
3
+ import { Button as m, EmptyState as a, Spinner as w } from "@av-pi-studio/ui-library";
4
+ import { u as v, C as h } from "./CodeView-6kJms_MF.js";
5
+ import { H as b, Q as M } from "./index-Dlz8mEKZ.js";
6
+ import { M as k } from "./markdown-B2OXhZ-_.js";
7
+ import { S as N } from "./SaveFileButton-2rOu02Xx.js";
8
+ const _ = "piwb-MarkdownFileViewer_wrap_b6KEN", F = "piwb-MarkdownFileViewer_toolbar_ALfg9", S = "piwb-MarkdownFileViewer_rendered_8pDh3", x = "piwb-MarkdownFileViewer_streamedNote_wlOSB", y = "piwb-MarkdownFileViewer_tooLarge_1oWTj", t = {
9
+ wrap: _,
10
+ toolbar: F,
11
+ rendered: S,
12
+ streamedNote: x,
13
+ tooLarge: y
14
+ };
15
+ function n(i) {
16
+ return `${(i / (1024 * 1024)).toFixed(1)} MB`;
17
+ }
18
+ function D({ path: i, workspaceCwd: d }) {
19
+ const r = v(i), [l, c] = f("preview"), u = g(() => {
20
+ const s = b(i, d);
21
+ return s ? M(s) : null;
22
+ }, [i, d]);
23
+ switch (r.kind) {
24
+ case "loading":
25
+ return /* @__PURE__ */ o(a, { children: [
26
+ /* @__PURE__ */ e(w, { size: "sm" }),
27
+ " Loading..."
28
+ ] });
29
+ case "streaming":
30
+ return /* @__PURE__ */ o(a, { children: [
31
+ /* @__PURE__ */ e(w, { size: "sm" }),
32
+ " Streaming ",
33
+ n(r.size),
34
+ " file..."
35
+ ] });
36
+ case "stream-error":
37
+ case "error":
38
+ return /* @__PURE__ */ o(a, { children: [
39
+ "Error: ",
40
+ r.message
41
+ ] });
42
+ case "too-large":
43
+ return /* @__PURE__ */ e(a, { children: /* @__PURE__ */ o("div", { className: t.tooLarge, children: [
44
+ /* @__PURE__ */ o("div", { children: [
45
+ n(r.size),
46
+ " — too large to display (display ceiling is",
47
+ " ",
48
+ n(r.maxDisplayBytes),
49
+ ")."
50
+ ] }),
51
+ /* @__PURE__ */ e(N, { path: i })
52
+ ] }) });
53
+ case "inline":
54
+ case "streamed": {
55
+ const s = r.content, p = r.kind === "streamed";
56
+ return /* @__PURE__ */ o("div", { className: t.wrap, children: [
57
+ /* @__PURE__ */ o("div", { className: t.toolbar, children: [
58
+ /* @__PURE__ */ e(
59
+ m,
60
+ {
61
+ size: "xs",
62
+ variant: l === "preview" ? "default" : "ghost",
63
+ onClick: () => c("preview"),
64
+ children: "Preview"
65
+ }
66
+ ),
67
+ /* @__PURE__ */ e(
68
+ m,
69
+ {
70
+ size: "xs",
71
+ variant: l === "source" ? "default" : "ghost",
72
+ onClick: () => c("source"),
73
+ children: "Source"
74
+ }
75
+ )
76
+ ] }),
77
+ p ? /* @__PURE__ */ o("div", { className: t.streamedNote, children: [
78
+ n(r.size),
79
+ " file streamed"
80
+ ] }) : null,
81
+ l === "preview" ? /* @__PURE__ */ e("div", { className: t.rendered, children: /* @__PURE__ */ e(k, { text: s, assetBase: u, workspaceCwd: d }) }) : /* @__PURE__ */ e(h, { path: i, content: s })
82
+ ] });
83
+ }
84
+ }
85
+ }
86
+ export {
87
+ D as MarkdownFileViewer
88
+ };