@pi-chamber/web 0.9.9 → 1.0.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 (46) hide show
  1. package/README.md +70 -67
  2. package/dist/assets/{DiagramView-YPcSEyVl.js → DiagramView-CbSxUe1D.js} +1 -1
  3. package/dist/assets/{DiffView-IrM_w65M.js → DiffView-VyBf4ilo.js} +1 -1
  4. package/dist/assets/{FileSaveConflictDialog-CtDwDmHo.js → FileSaveConflictDialog-BCvbQ234.js} +1 -1
  5. package/dist/assets/{FilesView-EUL5SZDG.js → FilesView-DasA5EU2.js} +1 -1
  6. package/dist/assets/{GitView-7K4eJ1V3.js → GitView-DU3mOECp.js} +3 -3
  7. package/dist/assets/{JsonTreeView-Qz0QeRmI.js → JsonTreeView-xZiWDwua.js} +1 -1
  8. package/dist/assets/{MarkdownRendererImpl-CsJfFWDC.js → MarkdownRendererImpl-BBwdI2OF.js} +2 -2
  9. package/dist/assets/{PatchDiff-DNhojsLA.js → PatchDiff-BhKm_JPT.js} +1 -1
  10. package/dist/assets/{SessionSwitcherContent-l1fTUann.js → SessionSwitcherContent-DTGSP_RB.js} +1 -1
  11. package/dist/assets/{SessionSwitcherDropdown-CUyTFUnd.js → SessionSwitcherDropdown-CedOB-xC.js} +2 -2
  12. package/dist/assets/{SessionUnreadDot-CY3rTilj.js → SessionUnreadDot-CZSNKram.js} +1 -1
  13. package/dist/assets/SettingsView-B5nmu8x4.js +2 -0
  14. package/dist/assets/{SettingsWindow-9FD4QY3p.js → SettingsWindow-y33YrpBE.js} +1 -1
  15. package/dist/assets/{ToolOutputDialog-0uj3Kf5J.js → ToolOutputDialog-JqIXJWAH.js} +3 -3
  16. package/dist/assets/{ToolPartDiffPreview-B29vAjqI.js → ToolPartDiffPreview-CRi_33jE.js} +1 -1
  17. package/dist/assets/{VirtualizedFileDiff-B1Jii7gu.js → VirtualizedFileDiff-ehLQSR5W.js} +4 -4
  18. package/dist/assets/{collapsible-B6bVtxgp.js → collapsible-Vypq-nMP.js} +1 -1
  19. package/dist/assets/{computeVirtualFileMetrics-B6RnDAuP.js → computeVirtualFileMetrics-BTfrj_fR.js} +2 -2
  20. package/dist/assets/{contextFileOpenGuard-DIpJPFxL.js → contextFileOpenGuard-Dl6mFfD1.js} +1 -1
  21. package/dist/assets/{gitStatusPredicates-lhIrHyDw.js → gitStatusPredicates-LAsJAhCL.js} +1 -1
  22. package/dist/assets/{index-BXgR2dKM.css → index-BXX8l7mM.css} +1 -1
  23. package/dist/assets/{index-BOtRfXre.js → index-DvNeSFO9.js} +1 -1
  24. package/dist/assets/{index-BUxQG4Eq.js → index-OveFsNBm.js} +1 -1
  25. package/dist/assets/{isDiffPlainText-r5sF6_KV.js → isDiffPlainText-CNZohQ4q.js} +1 -1
  26. package/dist/assets/{isFilePlainText-B4e2b2Bv.js → isFilePlainText-Dz8UubRT.js} +1 -1
  27. package/dist/assets/{main-DSfSGm2f.js → main-BsDkATRV.js} +3 -3
  28. package/dist/assets/{main-DMYsDuaV.js → main-C393Ywhx.js} +2 -2
  29. package/dist/assets/{markdownCore-0ygaCYcc.js → markdownCore-Bz9-Y75q.js} +1 -1
  30. package/dist/assets/{miniChat-DUMRG1q5.js → miniChat-CWEerp3c.js} +2 -2
  31. package/dist/assets/{mobile-DUcoCNyj.js → mobile-YxV9KcxF.js} +2 -2
  32. package/dist/assets/{renderElectronMiniChatApp-BNmJJQdl.js → renderElectronMiniChatApp-GrLmBQRb.js} +2 -2
  33. package/dist/assets/{renderMobileApp-DnhfWGEW.js → renderMobileApp-C29wquBe.js} +3 -3
  34. package/dist/assets/{runtimeEndpointReset-B0SWG9Uo.js → runtimeEndpointReset-DHARMv9w.js} +14 -14
  35. package/dist/assets/{runtimeSurface-CPm7KWaN.js → runtimeSurface-DUXw4-oa.js} +1 -1
  36. package/dist/assets/{useAppFontEffects-CDmJGQlK.js → useAppFontEffects-ad-lZJ6o.js} +86 -86
  37. package/dist/assets/{useFilesViewSearch-DDMI---4.js → useFilesViewSearch-C4oOHPml.js} +1 -1
  38. package/dist/assets/{usePushVisibilityBeacon-i8sRCEtS.js → usePushVisibilityBeacon-xd8Q10cI.js} +1 -1
  39. package/dist/assets/{useSwitcherItems-BT_toOh9.js → useSwitcherItems-B6VC7tug.js} +1 -1
  40. package/dist/assets/{vendor-codemirror-language-data-D09wcguI.js → vendor-codemirror-language-data-B4j3gkaT.js} +2 -2
  41. package/dist/assets/{web-components-Cb0vnR_a.js → web-components-B0RFakat.js} +3 -3
  42. package/dist/index.html +4 -4
  43. package/dist/mini-chat.html +3 -3
  44. package/dist/mobile.html +3 -3
  45. package/package.json +1 -1
  46. package/dist/assets/SettingsView-Cm4cKNof.js +0 -2
package/README.md CHANGED
@@ -1,81 +1,84 @@
1
1
  # @pi-chamber/web
2
2
 
3
- PiChamber's web server and browser UI for the Pi coding-agent runtime.
3
+ PiChamber server and browser UI for the [Pi coding agent](https://pi.dev). It serves the browser workspace and authenticated Pi routes, and owns its per-profile Pi session daemon.
4
4
 
5
- ## Run
5
+ ## Requirements
6
6
 
7
- ```bash
7
+ Node.js 22 or newer, or Bun.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ bun add -g @pi-chamber/web
13
+ ```
14
+
15
+ Other package managers:
16
+
17
+ ```sh
18
+ npm install -g @pi-chamber/web
19
+ pnpm add -g @pi-chamber/web
20
+ yarn global add @pi-chamber/web
21
+ ```
22
+
23
+ Run without installing:
24
+
25
+ ```sh
26
+ bunx @pi-chamber/web serve
27
+ npx @pi-chamber/web serve
28
+ pnpm dlx @pi-chamber/web serve
29
+ ```
30
+
31
+ ## Quick start
32
+
33
+ In an interactive terminal:
34
+
35
+ ```sh
8
36
  pichamber serve
9
37
  ```
10
38
 
11
- In an interactive terminal, `pichamber serve` guides you through access, port,
12
- authentication, browser UI versus API-only content, and background versus
13
- foreground process mode. It shows a review before starting. The server starts
14
- warming the local Pi session daemon as soon as HTTP is listening, serves the
15
- browser UI, and exposes authenticated Pi routes under `/api/pi/*`. HTTP
16
- readiness does not wait for Pi provider/model initialization; early Pi requests
17
- share the supervisor's in-flight startup.
39
+ The command walks through access, port, authentication, browser UI versus API-only, and background versus foreground mode, then shows a review before starting. Open the printed URL. Bare `pichamber` starts with default settings without the wizard.
18
40
 
19
41
  For scripts and non-interactive shells, pass the setup flags explicitly:
20
42
 
21
- ```bash
22
- pichamber serve --port 3000 --ui-password <password>
23
- pichamber serve --port 8080 --lan --ui-password <password>
24
- pichamber serve --port 3000 --api-only --ui-password <password>
25
- pichamber connect-url --port 3000 --qr
26
- pichamber stop --port 3000
43
+ ```sh
44
+ pichamber serve --port 3000 --ui-password "choose-a-strong-password"
45
+ pichamber serve --port 3000 --lan --ui-password "choose-a-strong-password"
46
+ pichamber serve --port 3000 --api-only --ui-password "choose-a-strong-password"
27
47
  ```
28
48
 
29
- `--quiet` and `--json` never prompt. Use `pichamber stop --force` when a broad
30
- stop should skip confirmation, and `pichamber logs --no-follow` for a one-time
31
- log tail. Use `pichamber update --yes` to update without the interactive review.
32
-
33
- Use `--api-only` for a host intended to be paired from a PiChamber desktop or mobile client. LAN-bound servers require a UI password unless the explicit unsafe-development override is set.
34
-
35
- See the [CLI guide](../docs/content/docs/cli.mdx) for guided startup, updates,
36
- tunnels, logs, pairing, and machine-readable output.
37
-
38
- ## Runtime contract
39
-
40
- - Pi session state and actions are served only through `/api/pi/*`. Session detail responses carry a bounded transcript tail; older history is available from `GET /api/pi/sessions/:sessionId/messages` with the opaque before-cursor returned by the previous page.
41
- - `POST /api/pi/attachments` accepts raw `application/octet-stream` bodies with bounded `X-PiChamber-Filename` and `X-PiChamber-Mime` metadata. It returns opaque attachment metadata plus `expiresAt`; filesystem paths remain private. The legacy base64 JSON body remains available for persisted clients. `DELETE /api/pi/attachments/:id` removes an unused upload. Prompt routes accept at most 20 attachment IDs and retire accepted uploads from the active 32-upload map while retaining their files until the one-hour expiry.
42
- - PiChamber-owned UI settings, snippets, custom themes, and updates use `/api/pi/ui-settings`, `/api/pi/snippets`, `/api/pi/themes`, `/api/pi/update-check`, `/api/pi/update-install`, and `/api/pi/update-install/:jobId`. Starting an update returns a persisted job ID; clients poll that job on the originating server across its restart, and concurrent requests reuse the active job. Polling stops if the client switches servers. Lost authentication leaves the outcome unknown until the client reauthenticates. For older servers without update jobs, fallback version polling reports version-check errors instead of treating them as successful updates. Status reads fail abandoned jobs after a bounded startup grace period or when the recorded worker exits. The settings route merges portable preferences from `settings.json` with host and device values from `runtime-state.json`; writes split fields through explicit allowlists. Electron and server update-channel subscriptions are separate host-local fields, each accepts only `stable` or `rc`, and each defaults to `stable`. The server RC channel compares `latest` and `rc` and selects the higher version; update jobs pin the selected version so restart or a moving dist-tag cannot change their target. Pi-owned resource, trust, and provider-catalog changes are saved without interrupting active sessions and report deferred runtime activation when an idle edge is required. A flat legacy file migrates on first access. A scoped portable file never contributes paths, project registrations, device values, or secrets. Removed `/api/config/*` and `/api/pichamber/*` aliases are not required. Snippets persist in the PiChamber data root (`snippets.json`) and expand through literal `#name` replacement; Pi prompt templates remain Pi-owned `/name` commands in Pi's global and trusted-project prompt directories, discovered through the active runtime's resource loader and exposed through `/api/pi/resources`, `/api/pi/resources/prompts`, and `/api/pi/commands`. Pi skills invoke as `/skill:name` (bare `/name` never invokes a skill) and extension commands use their registered `/name` (including Pi-generated suffixes); `/api/pi/commands` exposes prompts as `name`, skills as `skill:name`, and extensions under their invocation names, executed via Pi's `session.prompt()` with extension-first precedence. Snippet, prompt-template, skill, and extension-command concepts stay distinct with separate Settings pages, stores, persistence, and caches; they share only `/` autocomplete presentation. New-session starters are pinned Pi prompt templates that insert `/name ` for editing (never submit or expand in PiChamber); legacy skill starters are removed without conversion.
43
- - Final-only speech-to-text uses authenticated `/api/stt/*` routes and `/api/stt/ws`. Local model inference runs in a forked worker, while remote provider credentials remain in server configuration.
44
- - Browser and paired clients authenticate with UI sessions or scoped client credentials.
45
- - `connect-url` creates a one-time pairing link; credentials are not written to URLs or logs.
46
- - The server owns its per-profile Pi daemon lifecycle (installed web, development web, and desktop use separate namespaces) and stops only its own daemon during shutdown.
47
-
48
- ## SDK updates
49
-
50
- This release pins Pi SDK `0.85.1`, including an updated bundled OpenCode model
51
- catalog. Existing Pi sessions, credentials, settings, and custom models stay in
52
- place; no manual migration or cache deletion is needed. Custom model additions
53
- and overrides still apply to the updated catalog. If a saved default points to a
54
- removed model, select an available replacement; the upgrade does not rewrite
55
- your saved defaults or chat history.
56
-
57
- The normal update command restarts managed background instances. Linux servers
58
- configured by `pichamber startup enable` run updates in a transient systemd unit,
59
- so terminal and in-app updates survive the server restart and report status after
60
- clients reconnect. Foreground instances must be stopped and started manually.
61
- Desktop users must relaunch the updated app. Hosted and mobile clients use their
62
- connected server's SDK, so updating only the client does not update its model
63
- catalog. When a trusted hosted update response does not provide release notes,
64
- the server reads the selected version's GitHub release body, then falls back to
65
- `CHANGELOG.md` from that version tag. This keeps stable and RC notes tied to the
66
- package version chosen from the npm registry.
67
-
68
- ## Development
69
-
70
- ```bash
71
- bun run --cwd packages/web build
72
- bun run --cwd packages/web type-check
73
- bun run --cwd packages/web test
74
- ```
49
+ ## Commands
50
+
51
+ Run `pichamber --help` for the current flags.
52
+
53
+ | Command | What it does |
54
+ | --- | --- |
55
+ | `serve` | Start the server (guided setup in interactive terminals, with a review before starting) |
56
+ | `status` | Show running instances |
57
+ | `logs` | Tail logs (`--no-follow` for a one-time tail) |
58
+ | `stop` / `restart` | Stop or restart instances (broad stops confirm when more than one is affected; `--force` skips) |
59
+ | `startup` | Run at login or boot (`enable` is guided; `status` / `disable` to inspect or remove) |
60
+ | `tunnel` | Expose the server via Cloudflare Tunnel (`start` is guided; profiles cover repeatable runs) |
61
+ | `connect-url` | Create a one-time pairing link for another client (`--qr` in interactive terminals; starts the server if needed) |
62
+ | `update` | Install updates (reviews before changing anything; `--yes` skips confirmation, `--channel stable\|rc` overrides once) |
63
+ | `version` | Print the installed version |
64
+
65
+ ## Scripts and automation
66
+
67
+ `--quiet` and `--json` never prompt, and non-interactive shells never prompt either. Supply required values as flags. `--json` emits JSON only; `--quiet` keeps one concise result line.
68
+
69
+ ## Security
70
+
71
+ Servers reachable beyond this machine require a UI password. Pass `--ui-password` (omit the value to generate one) or set `PICHAMBER_UI_PASSWORD`. Prefer `--lan` only on a trusted network.
72
+
73
+ ## Docs
74
+
75
+ Full guides live in the PiChamber repository:
76
+
77
+ - [Install](https://github.com/RyderAsKing/PiChamber/blob/main/packages/docs/content/docs/install.mdx)
78
+ - [Quick start](https://github.com/RyderAsKing/PiChamber/blob/main/packages/docs/content/docs/quickstart.mdx)
79
+ - [CLI guide](https://github.com/RyderAsKing/PiChamber/blob/main/packages/docs/content/docs/cli.mdx)
80
+ - [Releases](https://github.com/RyderAsKing/PiChamber/releases/latest)
75
81
 
76
- Build flags:
82
+ ## License
77
83
 
78
- - `VITE_REACT_COMPILER=1` re-enables the `babel-plugin-react-compiler` pass for
79
- release builds. It is opt-in because the pass costs ~25s of the ~52s
80
- production build; the default build ships without compiler memoization.
81
- - `VITE_ENABLE_REACT_SCAN=1` injects the react-scan dev script into the page.
84
+ MIT. See [LICENSE](https://github.com/RyderAsKing/PiChamber/blob/main/LICENSE).
@@ -1 +1 @@
1
- import{R as t,j as c}from"./vendor-react-B5Z1Mdn3.js";import{aa as $,t as m,I as V}from"./useAppFontEffects-CDmJGQlK.js";import{u as A,a as G,z as ee,bV as W}from"./index-BOtRfXre.js";import{b as te,D as re,F as ie}from"./FileSaveConflictDialog-CtDwDmHo.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-base-ui-DXSHfszQ.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-BZOGXAGe.js";import"./vendor-use-sync-external-store-D0AXkdQC.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-sonner-BDtm25td.js";import"./vendor-codemirror-view-Ct4T37Ue.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-zustand-GVb4H8HE.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./runtimeSurface-CPm7KWaN.js";import"./vendor-dnd-kit-core-C9qcAm_1.js";import"./vendor-dnd-kit-utilities-DTY1C6ST.js";import"./vendor-dnd-kit-accessibility-DZKKhs9S.js";import"./vendor-dnd-kit-sortable-D8ozj8M-.js";import"./vendor-cmdk-zXx6sGnS.js";import"./vendor-radix-ui-react-dialog-D2yhEu2p.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-8xy6TJML.js";import"./vendor-radix-ui-react-context-CFsX-AUC.js";import"./vendor-radix-ui-react-id-D2kS9K1j.js";import"./vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js";import"./vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js";import"./vendor-radix-ui-react-dismissable-layer-DrorBNg9.js";import"./vendor-radix-ui-react-primitive-DkH8dMOR.js";import"./vendor-radix-ui-react-slot-BIDFZX0-.js";import"./vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js";import"./vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js";import"./vendor-radix-ui-react-focus-scope-D2BkImwt.js";import"./vendor-radix-ui-react-portal-YgCRIyi7.js";import"./vendor-radix-ui-react-presence-D432pCMB.js";import"./vendor-radix-ui-react-focus-guards-BfdFmL7c.js";import"./vendor-react-remove-scroll-vR1dy1aP.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-CSAHp1YF.js";import"./vendor-react-style-singleton-Ctw6HnYx.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-Vv4V8Nd1.js";import"./vendor-use-callback-ref-CVVuCyLj.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BByA_dGF.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-DuOEwJ3f.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-wd6iRebq.js";import"./vendor-codemirror-lang-json-CZ07HmNC.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-djiuoTi8.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CKHqhW5R.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-DtcZDGqe.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-D09wcguI.js";import"./vendor-codemirror-lang-python-DzzokVau.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-CNlncqrr.js";import"./vendor-tanstack-react-virtual-2skouoFw.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CfplGuM0.js";import"./vendor-motion-dom-DhJ-sYS5.js";import"./vendor-motion-utils-CKEGc_YG.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-react-drawio-BYDptOsj.js";const ne=l=>l.split("/").pop()||l;function Dt(){const{files:l}=$(),[x,k]=t.useState(null),[L,R]=t.useState(""),[M,E]=t.useState(!0),[b,h]=t.useState(null),[p,F]=t.useState(!1),[U,v]=t.useState(!1),[j,P]=t.useState(!1),[q,H]=t.useState(0),g=t.useRef(void 0),C=t.useRef(""),d=t.useRef(0),S=t.useRef(0),y=t.useRef(0),D=t.useRef(null),I=t.useRef(!0),w=t.useRef(null),T=A(e=>e.pendingDiagramFile);t.useEffect(()=>(I.current=!0,()=>{I.current=!1}),[]);const o=t.useCallback((e,i,n)=>I.current&&d.current===e&&G()===i&&w.current===n,[]),z=t.useCallback(async e=>{const i=d.current+1;d.current=i;const n=G(),u=l?.readFile;S.current+=1,y.current+=1,E(!0),k(e),w.current=e,h(null),v(!1),P(!1),F(!1);try{const r=await u?.(e);if(!o(i,n,e))return;if(!r){m.error("Failed to read file"),k(null),w.current=null,C.current="",R(""),g.current=void 0,E(!1);return}C.current=r.content,R(r.content),g.current=r.revision}catch(r){if(!o(i,n,e))return;m.error(r instanceof Error?r.message:"Failed to read file"),k(null),w.current=null,C.current="",R(""),g.current=void 0,E(!1);return}finally{o(i,n,e)&&E(!1)}},[l,o]);t.useEffect(()=>ee(()=>{if(d.current+=1,g.current=void 0,S.current+=1,y.current+=1,!I.current)return;h(null),v(!1),P(!1),F(!1);const e=w.current;e&&z(e)}),[z]),t.useEffect(()=>{if(!T)return;const e=A.getState().consumePendingDiagramFile();e&&z(e)},[z,T]);const K=t.useCallback(async(e,i,n,u,r,s)=>{let a=null,f=n,B=u;try{if(B){const N=await l?.readFile?.(e);if(!o(r,s,e))return;N&&(a=N.content??null,typeof N.revision=="string"&&(f=N.revision),B=N.exists!==!1)}}catch{if(!o(r,s,e))return}o(r,s,e)&&(h({path:e,displayPath:ne(e),exists:B,currentRevision:f,currentContent:a,dirtyContent:i,runtimeKey:s}),v(!1))},[l,o]),X=t.useCallback(async(e,i,n,u,r)=>{const s=await l?.writeFile?.(e,i,te(g.current,n?!0:void 0));return o(u,r,e)?{stale:!1,success:!!s?.success,revision:s?.revision}:{stale:!0}},[l,o]),O=t.useCallback((e,i)=>{C.current=e,typeof i<"u"&&(g.current=i),D.current?.getXml()===e&&R(e)},[]),J=t.useCallback(async()=>{const e=D.current?.getXml();if(!x||!l?.writeFile||!e||e===C.current||j||p)return;const i=d.current,n=G(),u=x,r=e,s=S.current+1;S.current=s,P(!0);try{const a=await X(u,r,!1,i,n);if(a.stale)return;if(!a.success){m.error("Failed to write file");return}O(r,a.revision)}catch(a){if(!o(i,n,u))return;if(W(a)){await K(u,r,a.currentRevision??null,a.exists,i,n);return}m.error(a instanceof Error?a.message:"Save failed")}finally{S.current===s&&P(!1)}},[O,x,l,o,p,j,K,X]),Q=t.useCallback(async()=>{const e=b;if(!e||p||!o(d.current,e.runtimeKey,e.path))return;const i=d.current,n=e.runtimeKey;if(!e.exists){k(null),w.current=null,C.current="",R(""),g.current=void 0,h(null),v(!1);return}const u=y.current+1;y.current=u,F(!0);try{const r=await l?.readFile?.(e.path);if(!o(i,n,e.path))return;if(!r){m.error("Failed to read file");return}C.current=r.content??"",R(r.content??""),g.current=r.revision,H(s=>s+1),h(null),v(!1)}catch(r){if(!o(i,n,e.path))return;m.error(r instanceof Error?r.message:"Failed to read file")}finally{y.current===u&&F(!1)}},[l,o,p,b]),Y=t.useCallback(async()=>{const e=b;if(!e||p||!o(d.current,e.runtimeKey,e.path))return;const i=d.current,n=e.runtimeKey;if(!l?.writeFile){m.error("Saving not supported");return}const s=D.current?.getXml()??e.dirtyContent;if(!s){m.error("Failed to write file");return}const a=y.current+1;y.current=a,F(!0);try{const f=await X(e.path,s,!0,i,n);if(f.stale)return;if(!f.success){m.error("Failed to write file");return}O(s,f.revision),h(null),v(!1)}catch(f){if(!o(i,n,e.path))return;if(W(f)){await K(e.path,s,f.currentRevision??e.currentRevision,f.exists,i,n);return}m.error(f instanceof Error?f.message:"Save failed")}finally{y.current===a&&F(!1)}},[O,l,o,p,K,X,b]),Z=t.useCallback(()=>{p||j||(h(null),v(!1))},[p,j]),_=x?x.split("/").pop()||x:"";return x?M?c.jsx("div",{className:"flex h-full items-center justify-center p-3",children:c.jsx(V,{name:"loader-4",className:"size-4 animate-spin"})}):c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsxs("div",{className:"flex items-center gap-2 border-b border-border/30 px-3 py-1.5",children:[c.jsx(V,{name:"file",className:"size-4 shrink-0 text-muted-foreground"}),c.jsx("span",{className:"typography-ui text-muted-foreground truncate flex-1",children:_}),c.jsx("button",{type:"button",onClick:()=>{J()},className:"size-6 flex items-center justify-center rounded-md text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:"Save diagram",children:c.jsx(V,{name:"save-3",className:"size-4"})}),c.jsx("button",{type:"button",onClick:()=>A.getState().setActiveMainTab("chat"),className:"size-6 flex items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:"Close diagram view",children:c.jsx(V,{name:"close",className:"size-4"})})]}),c.jsx("div",{className:"flex-1 min-h-0",children:c.jsx(re,{ref:D,xml:L,className:"h-full"},q)}),c.jsx(ie,{open:!!b,conflict:b,isResolving:p||j,showCompare:U,onToggleCompare:()=>v(e=>!e),onReload:()=>{Q()},onOverwrite:()=>{Y()},onClose:Z})]}):c.jsx("div",{className:"flex h-full items-center justify-center p-3",children:c.jsx("div",{className:"typography-ui text-muted-foreground",children:"Pick a file from the tree."})})}export{Dt as DiagramView};
1
+ import{R as t,j as c}from"./vendor-react-B5Z1Mdn3.js";import{ab as $,t as m,I as B}from"./useAppFontEffects-ad-lZJ6o.js";import{u as W,a as A,z as ee,bW as T}from"./index-DvNeSFO9.js";import{b as te,D as re,F as ie}from"./FileSaveConflictDialog-BCvbQ234.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-base-ui-DXSHfszQ.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-BZOGXAGe.js";import"./vendor-use-sync-external-store-D0AXkdQC.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-sonner-BDtm25td.js";import"./vendor-codemirror-view-Ct4T37Ue.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-zustand-GVb4H8HE.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./runtimeSurface-DUXw4-oa.js";import"./vendor-dnd-kit-core-C9qcAm_1.js";import"./vendor-dnd-kit-utilities-DTY1C6ST.js";import"./vendor-dnd-kit-accessibility-DZKKhs9S.js";import"./vendor-dnd-kit-sortable-D8ozj8M-.js";import"./vendor-cmdk-zXx6sGnS.js";import"./vendor-radix-ui-react-dialog-D2yhEu2p.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-8xy6TJML.js";import"./vendor-radix-ui-react-context-CFsX-AUC.js";import"./vendor-radix-ui-react-id-D2kS9K1j.js";import"./vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js";import"./vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js";import"./vendor-radix-ui-react-dismissable-layer-DrorBNg9.js";import"./vendor-radix-ui-react-primitive-DkH8dMOR.js";import"./vendor-radix-ui-react-slot-BIDFZX0-.js";import"./vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js";import"./vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js";import"./vendor-radix-ui-react-focus-scope-D2BkImwt.js";import"./vendor-radix-ui-react-portal-YgCRIyi7.js";import"./vendor-radix-ui-react-presence-D432pCMB.js";import"./vendor-radix-ui-react-focus-guards-BfdFmL7c.js";import"./vendor-react-remove-scroll-vR1dy1aP.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-CSAHp1YF.js";import"./vendor-react-style-singleton-Ctw6HnYx.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-Vv4V8Nd1.js";import"./vendor-use-callback-ref-CVVuCyLj.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BByA_dGF.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-DuOEwJ3f.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-wd6iRebq.js";import"./vendor-codemirror-lang-json-CZ07HmNC.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-djiuoTi8.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CKHqhW5R.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-DtcZDGqe.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-B4j3gkaT.js";import"./vendor-codemirror-lang-python-DzzokVau.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-CNlncqrr.js";import"./vendor-tanstack-react-virtual-2skouoFw.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CfplGuM0.js";import"./vendor-motion-dom-DhJ-sYS5.js";import"./vendor-motion-utils-CKEGc_YG.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-react-drawio-BYDptOsj.js";const ne=l=>l.split("/").pop()||l;function Dt(){const{files:l}=$(),[x,k]=t.useState(null),[L,R]=t.useState(""),[M,E]=t.useState(!0),[b,h]=t.useState(null),[p,F]=t.useState(!1),[U,v]=t.useState(!1),[j,P]=t.useState(!1),[q,H]=t.useState(0),g=t.useRef(void 0),C=t.useRef(""),d=t.useRef(0),S=t.useRef(0),y=t.useRef(0),D=t.useRef(null),I=t.useRef(!0),w=t.useRef(null),G=W(e=>e.pendingDiagramFile);t.useEffect(()=>(I.current=!0,()=>{I.current=!1}),[]);const o=t.useCallback((e,i,n)=>I.current&&d.current===e&&A()===i&&w.current===n,[]),z=t.useCallback(async e=>{const i=d.current+1;d.current=i;const n=A(),u=l?.readFile;S.current+=1,y.current+=1,E(!0),k(e),w.current=e,h(null),v(!1),P(!1),F(!1);try{const r=await u?.(e);if(!o(i,n,e))return;if(!r){m.error("Failed to read file"),k(null),w.current=null,C.current="",R(""),g.current=void 0,E(!1);return}C.current=r.content,R(r.content),g.current=r.revision}catch(r){if(!o(i,n,e))return;m.error(r instanceof Error?r.message:"Failed to read file"),k(null),w.current=null,C.current="",R(""),g.current=void 0,E(!1);return}finally{o(i,n,e)&&E(!1)}},[l,o]);t.useEffect(()=>ee(()=>{if(d.current+=1,g.current=void 0,S.current+=1,y.current+=1,!I.current)return;h(null),v(!1),P(!1),F(!1);const e=w.current;e&&z(e)}),[z]),t.useEffect(()=>{if(!G)return;const e=W.getState().consumePendingDiagramFile();e&&z(e)},[z,G]);const K=t.useCallback(async(e,i,n,u,r,s)=>{let a=null,f=n,V=u;try{if(V){const N=await l?.readFile?.(e);if(!o(r,s,e))return;N&&(a=N.content??null,typeof N.revision=="string"&&(f=N.revision),V=N.exists!==!1)}}catch{if(!o(r,s,e))return}o(r,s,e)&&(h({path:e,displayPath:ne(e),exists:V,currentRevision:f,currentContent:a,dirtyContent:i,runtimeKey:s}),v(!1))},[l,o]),X=t.useCallback(async(e,i,n,u,r)=>{const s=await l?.writeFile?.(e,i,te(g.current,n?!0:void 0));return o(u,r,e)?{stale:!1,success:!!s?.success,revision:s?.revision}:{stale:!0}},[l,o]),O=t.useCallback((e,i)=>{C.current=e,typeof i<"u"&&(g.current=i),D.current?.getXml()===e&&R(e)},[]),J=t.useCallback(async()=>{const e=D.current?.getXml();if(!x||!l?.writeFile||!e||e===C.current||j||p)return;const i=d.current,n=A(),u=x,r=e,s=S.current+1;S.current=s,P(!0);try{const a=await X(u,r,!1,i,n);if(a.stale)return;if(!a.success){m.error("Failed to write file");return}O(r,a.revision)}catch(a){if(!o(i,n,u))return;if(T(a)){await K(u,r,a.currentRevision??null,a.exists,i,n);return}m.error(a instanceof Error?a.message:"Save failed")}finally{S.current===s&&P(!1)}},[O,x,l,o,p,j,K,X]),Q=t.useCallback(async()=>{const e=b;if(!e||p||!o(d.current,e.runtimeKey,e.path))return;const i=d.current,n=e.runtimeKey;if(!e.exists){k(null),w.current=null,C.current="",R(""),g.current=void 0,h(null),v(!1);return}const u=y.current+1;y.current=u,F(!0);try{const r=await l?.readFile?.(e.path);if(!o(i,n,e.path))return;if(!r){m.error("Failed to read file");return}C.current=r.content??"",R(r.content??""),g.current=r.revision,H(s=>s+1),h(null),v(!1)}catch(r){if(!o(i,n,e.path))return;m.error(r instanceof Error?r.message:"Failed to read file")}finally{y.current===u&&F(!1)}},[l,o,p,b]),Y=t.useCallback(async()=>{const e=b;if(!e||p||!o(d.current,e.runtimeKey,e.path))return;const i=d.current,n=e.runtimeKey;if(!l?.writeFile){m.error("Saving not supported");return}const s=D.current?.getXml()??e.dirtyContent;if(!s){m.error("Failed to write file");return}const a=y.current+1;y.current=a,F(!0);try{const f=await X(e.path,s,!0,i,n);if(f.stale)return;if(!f.success){m.error("Failed to write file");return}O(s,f.revision),h(null),v(!1)}catch(f){if(!o(i,n,e.path))return;if(T(f)){await K(e.path,s,f.currentRevision??e.currentRevision,f.exists,i,n);return}m.error(f instanceof Error?f.message:"Save failed")}finally{y.current===a&&F(!1)}},[O,l,o,p,K,X,b]),Z=t.useCallback(()=>{p||j||(h(null),v(!1))},[p,j]),_=x?x.split("/").pop()||x:"";return x?M?c.jsx("div",{className:"flex h-full items-center justify-center p-3",children:c.jsx(B,{name:"loader-4",className:"size-4 animate-spin"})}):c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsxs("div",{className:"flex items-center gap-2 border-b border-border/30 px-3 py-1.5",children:[c.jsx(B,{name:"file",className:"size-4 shrink-0 text-muted-foreground"}),c.jsx("span",{className:"typography-ui text-muted-foreground truncate flex-1",children:_}),c.jsx("button",{type:"button",onClick:()=>{J()},className:"size-6 flex items-center justify-center rounded-md text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:"Save diagram",children:c.jsx(B,{name:"save-3",className:"size-4"})}),c.jsx("button",{type:"button",onClick:()=>W.getState().setActiveMainTab("chat"),className:"size-6 flex items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:"Close diagram view",children:c.jsx(B,{name:"close",className:"size-4"})})]}),c.jsx("div",{className:"flex-1 min-h-0",children:c.jsx(re,{ref:D,xml:L,className:"h-full"},q)}),c.jsx(ie,{open:!!b,conflict:b,isResolving:p||j,showCompare:U,onToggleCompare:()=>v(e=>!e),onReload:()=>{Q()},onOverwrite:()=>{Y()},onClose:Z})]}):c.jsx("div",{className:"flex h-full items-center justify-center p-3",children:c.jsx("div",{className:"typography-ui text-muted-foreground",children:"Pick a file from the tree."})})}export{Dt as DiagramView};
@@ -1,4 +1,4 @@
1
- import{j as n,R as r,b as St}from"./vendor-react-B5Z1Mdn3.js";import{o as te,u as J,a as Ze,B as ze}from"./index-BOtRfXre.js";import{ds as vt,dl as Ct,dq as jt,ae as et,a0 as tt,c5 as Nt,c6 as Ne,B as Le,I as q,aa as nt,ax as re,t as st,cv as it,b$ as Lt,dt as Dt,du as kt,ab as Rt,Z as Et,at as At,ac as Tt,cp as Mt,e as It,ao as $t,aF as Pt,a2 as _t,a3 as Wt,a5 as Bt}from"./useAppFontEffects-CDmJGQlK.js";import{d as rt,P as Ot,i as Ge,a as He,b as zt,C as Gt}from"./gitStatusPredicates-lhIrHyDw.js";import{p as Ht}from"./VirtualizedFileDiff-B1Jii7gu.js";import{v as Ut,g as Vt}from"./contextFileOpenGuard-DIpJPFxL.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zustand-GVb4H8HE.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-base-ui-DXSHfszQ.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-BZOGXAGe.js";import"./vendor-use-sync-external-store-D0AXkdQC.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-sonner-BDtm25td.js";import"./vendor-codemirror-view-Ct4T37Ue.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./runtimeSurface-CPm7KWaN.js";import"./vendor-dnd-kit-core-C9qcAm_1.js";import"./vendor-dnd-kit-utilities-DTY1C6ST.js";import"./vendor-dnd-kit-accessibility-DZKKhs9S.js";import"./vendor-dnd-kit-sortable-D8ozj8M-.js";import"./vendor-cmdk-zXx6sGnS.js";import"./vendor-radix-ui-react-dialog-D2yhEu2p.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-8xy6TJML.js";import"./vendor-radix-ui-react-context-CFsX-AUC.js";import"./vendor-radix-ui-react-id-D2kS9K1j.js";import"./vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js";import"./vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js";import"./vendor-radix-ui-react-dismissable-layer-DrorBNg9.js";import"./vendor-radix-ui-react-primitive-DkH8dMOR.js";import"./vendor-radix-ui-react-slot-BIDFZX0-.js";import"./vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js";import"./vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js";import"./vendor-radix-ui-react-focus-scope-D2BkImwt.js";import"./vendor-radix-ui-react-portal-YgCRIyi7.js";import"./vendor-radix-ui-react-presence-D432pCMB.js";import"./vendor-radix-ui-react-focus-guards-BfdFmL7c.js";import"./vendor-react-remove-scroll-vR1dy1aP.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-CSAHp1YF.js";import"./vendor-react-style-singleton-Ctw6HnYx.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-Vv4V8Nd1.js";import"./vendor-use-callback-ref-CVVuCyLj.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BByA_dGF.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-DuOEwJ3f.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-wd6iRebq.js";import"./vendor-codemirror-lang-json-CZ07HmNC.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-djiuoTi8.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CKHqhW5R.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-DtcZDGqe.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-D09wcguI.js";import"./vendor-codemirror-lang-python-DzzokVau.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-CNlncqrr.js";import"./vendor-tanstack-react-virtual-2skouoFw.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CfplGuM0.js";import"./vendor-motion-dom-DhJ-sYS5.js";import"./vendor-motion-utils-CKEGc_YG.js";import"./web-components-Cb0vnR_a.js";import"./computeVirtualFileMetrics-B6RnDAuP.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./runtimeEndpointReset-B0SWG9Uo.js";import"./SessionUnreadDot-CY3rTilj.js";import"./vendor-xterm-xterm-CrXqRur4.js";import"./permissionStore-iKN1K2_x.js";import"./appThemeRegistry-gegrE2dq.js";import"./registerCustomTheme-DmolaWWZ.js";import"./isDiffPlainText-r5sF6_KV.js";import"./vendor-diff-C3JhlQdm.js";function Kt(t,s=10){const e=[];let i;for(const l of t.split(`
1
+ import{j as n,R as r,b as St}from"./vendor-react-B5Z1Mdn3.js";import{o as te,u as J,a as Ze,B as ze}from"./index-DvNeSFO9.js";import{dt as vt,dm as Ct,dr as jt,af as et,a1 as tt,c6 as Nt,c7 as Ne,B as Le,I as q,ab as nt,ay as re,t as st,cw as it,c0 as Lt,du as Dt,dv as kt,ac as Rt,_ as Et,au as At,ad as Tt,cq as Mt,f as It,ap as $t,aG as Pt,a3 as _t,a4 as Wt,a6 as Bt}from"./useAppFontEffects-ad-lZJ6o.js";import{d as rt,P as Ot,i as Ge,a as He,b as zt,C as Gt}from"./gitStatusPredicates-LAsJAhCL.js";import{p as Ht}from"./VirtualizedFileDiff-ehLQSR5W.js";import{v as Ut,g as Vt}from"./contextFileOpenGuard-Dl6mFfD1.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zustand-GVb4H8HE.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-base-ui-DXSHfszQ.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-BZOGXAGe.js";import"./vendor-use-sync-external-store-D0AXkdQC.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-sonner-BDtm25td.js";import"./vendor-codemirror-view-Ct4T37Ue.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./runtimeSurface-DUXw4-oa.js";import"./vendor-dnd-kit-core-C9qcAm_1.js";import"./vendor-dnd-kit-utilities-DTY1C6ST.js";import"./vendor-dnd-kit-accessibility-DZKKhs9S.js";import"./vendor-dnd-kit-sortable-D8ozj8M-.js";import"./vendor-cmdk-zXx6sGnS.js";import"./vendor-radix-ui-react-dialog-D2yhEu2p.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-8xy6TJML.js";import"./vendor-radix-ui-react-context-CFsX-AUC.js";import"./vendor-radix-ui-react-id-D2kS9K1j.js";import"./vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js";import"./vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js";import"./vendor-radix-ui-react-dismissable-layer-DrorBNg9.js";import"./vendor-radix-ui-react-primitive-DkH8dMOR.js";import"./vendor-radix-ui-react-slot-BIDFZX0-.js";import"./vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js";import"./vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js";import"./vendor-radix-ui-react-focus-scope-D2BkImwt.js";import"./vendor-radix-ui-react-portal-YgCRIyi7.js";import"./vendor-radix-ui-react-presence-D432pCMB.js";import"./vendor-radix-ui-react-focus-guards-BfdFmL7c.js";import"./vendor-react-remove-scroll-vR1dy1aP.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-CSAHp1YF.js";import"./vendor-react-style-singleton-Ctw6HnYx.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-Vv4V8Nd1.js";import"./vendor-use-callback-ref-CVVuCyLj.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BByA_dGF.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-DuOEwJ3f.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-wd6iRebq.js";import"./vendor-codemirror-lang-json-CZ07HmNC.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-djiuoTi8.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CKHqhW5R.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-DtcZDGqe.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-B4j3gkaT.js";import"./vendor-codemirror-lang-python-DzzokVau.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-CNlncqrr.js";import"./vendor-tanstack-react-virtual-2skouoFw.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CfplGuM0.js";import"./vendor-motion-dom-DhJ-sYS5.js";import"./vendor-motion-utils-CKEGc_YG.js";import"./web-components-B0RFakat.js";import"./computeVirtualFileMetrics-BTfrj_fR.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./runtimeEndpointReset-DHARMv9w.js";import"./SessionUnreadDot-CZSNKram.js";import"./vendor-xterm-xterm-CrXqRur4.js";import"./permissionStore-iKN1K2_x.js";import"./appThemeRegistry-gegrE2dq.js";import"./registerCustomTheme-DmolaWWZ.js";import"./isDiffPlainText-CNZohQ4q.js";import"./vendor-diff-C3JhlQdm.js";function Kt(t,s=10){const e=[];let i;for(const l of t.split(`
2
2
  `)){const p=l.match(vt);if(p!=null){i!=null&&(i.hunkLines.length>0&&(Re(i,s,"trailing"),Ie(i,e)),i=void 0);const u=parseInt(p[3]),b=parseInt(p[1]),h=parseInt(p[4]??"1"),c=parseInt(p[2]??"1");isNaN(u)||isNaN(b)||isNaN(h)||isNaN(c)?e.push(l):i={additionStart:u,deletionStart:b,additionCount:0,deletionCount:0,hunkLines:[],contextLines:[]};continue}if(i==null){e.push(l);continue}if(l.startsWith(" "))i.contextLines.push(l);else if(l!==""){if(i.hunkLines.length>0&&i.contextLines.length>s*2){const u=i.contextLines.length-s*2,b=i.contextLines.slice(-s);Re(i,s,"trailing");const{additionCount:h,deletionCount:c}=i;Ie(i,e),i={additionStart:i.additionStart+h+u,deletionStart:i.deletionStart+c+u,deletionCount:0,additionCount:0,contextLines:b,hunkLines:[]}}Re(i,s,i.hunkLines.length===0?"leading":"before-change"),i.hunkLines.push(l),l.startsWith("+")?i.additionCount+=1:l.startsWith("-")&&(i.deletionCount+=1)}}i!=null&&i.hunkLines.length>0&&(Re(i,s,"trailing"),Ie(i,e));const a=e.join(`
3
3
  `);return t.endsWith(`
4
4
  `)?`${a}
@@ -1,3 +1,3 @@
1
- import{R as a,j as r}from"./vendor-react-B5Z1Mdn3.js";import{D}from"./vendor-react-drawio-BYDptOsj.js";import{o as C}from"./index-BOtRfXre.js";import{af as E,ag as S,ah as N,ai as B,aj as F,ak as H,B as h}from"./useAppFontEffects-CDmJGQlK.js";const A='<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>';function w(){if(typeof document>"u")return!1;const t=document.documentElement.getAttribute("data-theme");return t==="dark"||!t&&window.matchMedia("(prefers-color-scheme: dark)").matches}const P=a.forwardRef(function({xml:e,readOnly:s,className:d,onChange:u},m){const l=a.useRef(e),c=a.useRef(null),i=a.useRef(!1),[o,j]=a.useState(w),f=a.useRef(e),p=a.useRef(e);p.current!==e&&(p.current=e,f.current=e,l.current=e);const v=a.useRef(o);v.current!==o&&(v.current=o,f.current=l.current);const g=a.useRef(null);a.useEffect(()=>{const n=()=>j(w());n();const x=new MutationObserver(n);return x.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>x.disconnect()},[]),a.useEffect(()=>{const n=setTimeout(()=>{g.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(n)},[]),a.useImperativeHandle(m,()=>({getXml:()=>l.current}));const y=a.useCallback(()=>{!e&&!i.current&&(i.current=!0,setTimeout(()=>{c.current?.template({})},500))},[e]),R=a.useCallback(n=>{l.current=n.xml,u?.(n.xml)},[u]);return r.jsx("div",{ref:g,className:C("h-full w-full",d),children:r.jsx(D,{ref:c,xml:f.current||A,autosave:!0,urlParameters:{ui:s?"simple":o?"dark":"kennedy",spin:!0,libraries:!s,chrome:s,nav:s,layers:s,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:y,onAutoSave:R},o?"dark":"light")})}),T=(t,e)=>!t||t.runtimeKey!==e.runtimeKey||t.root!==e.root||t.path!==e.path||t.generation!==e.generation,b=t=>{if(typeof t=="string")return t;if(t===null)return null},X=(t,e)=>{if(e===!0)return t!==void 0?{expectedRevision:b(t),overwrite:!0}:{overwrite:!0};if(t!==void 0)return{expectedRevision:b(t)}},G=(t,e)=>!!(t&&e&&t.runtimeKey===e.runtimeKey&&t.root===e.root&&t.path===e.path&&t.generation===e.generation),k=(t,e=4e3)=>t.length>e?`${t.slice(0,e)}
1
+ import{R as a,j as r}from"./vendor-react-B5Z1Mdn3.js";import{D}from"./vendor-react-drawio-BYDptOsj.js";import{o as C}from"./index-DvNeSFO9.js";import{ag as E,ah as S,ai as N,aj as B,ak as F,al as H,B as h}from"./useAppFontEffects-ad-lZJ6o.js";const A='<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>';function w(){if(typeof document>"u")return!1;const t=document.documentElement.getAttribute("data-theme");return t==="dark"||!t&&window.matchMedia("(prefers-color-scheme: dark)").matches}const P=a.forwardRef(function({xml:e,readOnly:s,className:d,onChange:u},m){const l=a.useRef(e),c=a.useRef(null),i=a.useRef(!1),[o,j]=a.useState(w),f=a.useRef(e),p=a.useRef(e);p.current!==e&&(p.current=e,f.current=e,l.current=e);const v=a.useRef(o);v.current!==o&&(v.current=o,f.current=l.current);const g=a.useRef(null);a.useEffect(()=>{const n=()=>j(w());n();const x=new MutationObserver(n);return x.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>x.disconnect()},[]),a.useEffect(()=>{const n=setTimeout(()=>{g.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(n)},[]),a.useImperativeHandle(m,()=>({getXml:()=>l.current}));const y=a.useCallback(()=>{!e&&!i.current&&(i.current=!0,setTimeout(()=>{c.current?.template({})},500))},[e]),R=a.useCallback(n=>{l.current=n.xml,u?.(n.xml)},[u]);return r.jsx("div",{ref:g,className:C("h-full w-full",d),children:r.jsx(D,{ref:c,xml:f.current||A,autosave:!0,urlParameters:{ui:s?"simple":o?"dark":"kennedy",spin:!0,libraries:!s,chrome:s,nav:s,layers:s,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:y,onAutoSave:R},o?"dark":"light")})}),T=(t,e)=>!t||t.runtimeKey!==e.runtimeKey||t.root!==e.root||t.path!==e.path||t.generation!==e.generation,b=t=>{if(typeof t=="string")return t;if(t===null)return null},X=(t,e)=>{if(e===!0)return t!==void 0?{expectedRevision:b(t),overwrite:!0}:{overwrite:!0};if(t!==void 0)return{expectedRevision:b(t)}},G=(t,e)=>!!(t&&e&&t.runtimeKey===e.runtimeKey&&t.root===e.root&&t.path===e.path&&t.generation===e.generation),k=(t,e=4e3)=>t.length>e?`${t.slice(0,e)}
2
2
 
3
3
  … truncated …`:t,W=({open:t,conflict:e,isResolving:s,showCompare:d,onToggleCompare:u,onReload:m,onOverwrite:l,onClose:c})=>{if(!e)return null;const i=!e.exists;return r.jsx(E,{open:t,onOpenChange:o=>{o||c()},children:r.jsxs(S,{showCloseButton:!1,className:"max-w-lg",children:[r.jsxs(N,{children:[r.jsx(B,{children:i?"File deleted on disk":"File changed on disk"}),r.jsx(F,{children:i?`“${e.displayPath}” was deleted since you opened it. Your edits are preserved. Reload to discard them, or overwrite to recreate the file.`:`“${e.displayPath}” changed since you opened it. Your edits are preserved. Reload to discard them and load the current version, or overwrite to keep your edits.`})]}),d&&!i?r.jsxs("div",{className:"grid max-h-64 grid-cols-1 gap-2 overflow-auto py-2",children:[r.jsxs("div",{children:[r.jsx("div",{className:"typography-meta text-muted-foreground",children:"Current version on disk"}),r.jsx("pre",{className:"mt-1 max-h-28 overflow-auto rounded-md bg-[var(--surface-subtle)] p-2 text-xs whitespace-pre-wrap break-words",children:k(e.currentContent??"")})]}),r.jsxs("div",{children:[r.jsx("div",{className:"typography-meta text-muted-foreground",children:"Your edits"}),r.jsx("pre",{className:"mt-1 max-h-28 overflow-auto rounded-md bg-[var(--surface-subtle)] p-2 text-xs whitespace-pre-wrap break-words",children:k(e.dirtyContent)})]})]}):null,r.jsxs(H,{className:"flex flex-wrap gap-2",children:[i?null:r.jsx(h,{variant:"outline",onClick:u,disabled:s,"aria-label":d?"Hide version comparison":"Compare versions",title:d?"Hide version comparison":"Compare versions",children:d?"Hide compare":"Compare"}),r.jsx(h,{variant:"outline",onClick:m,disabled:s,"aria-label":i?"Discard edits and close":"Reload current version",title:i?"Discard edits and close":"Reload current version",children:i?"Discard edits":"Reload"}),r.jsx(h,{variant:"destructive",onClick:l,disabled:s,"aria-label":i?"Recreate file with my edits":"Overwrite with my edits",title:i?"Recreate file with my edits":"Overwrite with my edits",children:s?"Working…":"Overwrite"})]})]})})};export{P as D,W as F,X as b,G as i,T as s};