@pi-chamber/web 1.0.4-rc.4 → 1.0.5-rc.1
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.
- package/README.md +1 -1
- package/bin/cli.js +21 -2
- package/bin/cli.test.js +164 -4
- package/bin/lib/DOCUMENTATION.md +3 -3
- package/bin/lib/cli-args.js +96 -13
- package/bin/lib/commands-connect-url-tailscale.test.js +136 -0
- package/bin/lib/commands-connect-url.js +146 -39
- package/bin/lib/commands-connect-url.test.js +126 -0
- package/bin/lib/commands-serve.js +45 -2
- package/bin/lib/commands-status.js +28 -5
- package/bin/lib/commands-status.test.js +107 -0
- package/bin/lib/commands-tunnel.js +36 -10
- package/dist/assets/{DiagramView--BGR3PRZ.js → DiagramView-D-OSWTbO.js} +1 -1
- package/dist/assets/DiffView-BKT-MIH4.js +18 -0
- package/dist/assets/{FileSaveConflictDialog-CcrWHRvd.js → FileSaveConflictDialog-DBkVFssC.js} +2 -2
- package/dist/assets/FilesView-B7GIuRlh.js +6 -0
- package/dist/assets/{GitHubDetailScaffold-BZhP67Va.js → GitHubDetailScaffold-C9rCZMUT.js} +2 -2
- package/dist/assets/{GitHubLinkPicker-CJZmDljp.js → GitHubLinkPicker-Bm09hvhJ.js} +1 -1
- package/dist/assets/{GitHubListPrimitives-DhF42guB.js → GitHubListPrimitives-DlhAlxI6.js} +1 -1
- package/dist/assets/{GitView-JK-QCK9R.js → GitView-BgqdMb0m.js} +4 -4
- package/dist/assets/{IssuesSurface-CAqQzrsv.js → IssuesSurface-BZXAvt49.js} +3 -3
- package/dist/assets/{JsonTreeView-CKTqB1CD.js → JsonTreeView-BKgCQjh_.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-B5kJy9Nt.js → MarkdownRendererImpl-BdcyMPw-.js} +1 -1
- package/dist/assets/{PatchDiff-BQnRFN30.js → PatchDiff-2MmWXcGe.js} +1 -1
- package/dist/assets/PierreDiffViewer-D1F2WvD0.js +135 -0
- package/dist/assets/PullRequestsSurface-CN2z3DFv.js +2 -0
- package/dist/assets/SessionSwitcherContent-CCljxAZb.js +1 -0
- package/dist/assets/SessionSwitcherDropdown-DtNt3qw4.js +2 -0
- package/dist/assets/SessionUnreadDot-B9bHMy5q.js +1 -0
- package/dist/assets/SettingsView-DaZVCInW.js +6 -0
- package/dist/assets/{SettingsWindow-CAxKgYOu.js → SettingsWindow-C-ydfopH.js} +1 -1
- package/dist/assets/StickyHorizontalScrollbar-BMITjK4e.js +8 -0
- package/dist/assets/{ToolOutputDialog-lz5exVQ4.js → ToolOutputDialog-DJUAx_Oj.js} +4 -4
- package/dist/assets/{ToolPartDiffPreview-nIUiNLpP.js → ToolPartDiffPreview-DFyuJM4c.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-IWqCJNXu.js → VirtualizedFileDiff-BS-af6rn.js} +4 -4
- package/dist/assets/{Virtualizer-Cp_cJWbI.js → Virtualizer-DP6HbEeC.js} +1 -1
- package/dist/assets/{collapsible-C7oyikVm.js → collapsible-BOcd0lzY.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-CyhUKEfv.js → computeVirtualFileMetrics-BI6wORhM.js} +1 -1
- package/dist/assets/{contextFileOpenGuard-DkjmJ-NU.js → contextFileOpenGuard-DUMSGR4M.js} +1 -1
- package/dist/assets/{gitStatusPredicates-DBmUY3kA.js → gitStatusPredicates-FdKYDZe3.js} +1 -1
- package/dist/assets/{githubLink-BdbPMMAK.js → githubLink-B3-BaGpb.js} +5 -5
- package/dist/assets/index-DWSrsQWl.js +11 -0
- package/dist/assets/{index-CKgYIOis.js → index-Df-vmvzu.js} +1 -1
- package/dist/assets/index-DsQIBAWK.css +1 -0
- package/dist/assets/main-61_cd7S7.js +2 -0
- package/dist/assets/main-q43jqZ2I.js +136 -0
- package/dist/assets/{markdownCore-D7V46WY9.js → markdownCore-CqHYlXi_.js} +2 -2
- package/dist/assets/{miniChat-PanPmbEK.js → miniChat-vOuWN5pV.js} +2 -2
- package/dist/assets/mobile-mrXWV5ky.js +2 -0
- package/dist/assets/{nativeFileSave-BzhtrDoD.js → nativeFileSave-CFuugNKV.js} +1 -1
- package/dist/assets/pi-session-focus-preference-BEufpwC6.js +9 -0
- package/dist/assets/{renderDiffWithHighlighter-ByZtK9za.js → renderDiffWithHighlighter-BD9CAhZU.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-QQFXkY5Y.js +2 -0
- package/dist/assets/{renderFileWithHighlighter-CnN0Tv_8.js → renderFileWithHighlighter-KiEWMtzI.js} +1 -1
- package/dist/assets/renderMobileApp-DIZYvrhi.js +11 -0
- package/dist/assets/runtimeEndpointReset-BA2uP2rj.js +62 -0
- package/dist/assets/{runtimeSurface-DBiUWYK2.js → runtimeSurface-Der4qUnI.js} +1 -1
- package/dist/assets/useAppFontEffects-Bfw_d5eB.js +212 -0
- package/dist/assets/{useFilesViewSearch-BWABG6pS.js → useFilesViewSearch-Budwejnx.js} +3 -3
- package/dist/assets/useGitHubRemoteSearch-gUdylYy3.js +1 -0
- package/dist/assets/{useSwitcherItems-BSTSev5C.js → useSwitcherItems-yHSMduoo.js} +1 -1
- package/dist/assets/{vendor-aparajita-capacitor-secure-storage-BYohCVY0.js → vendor-aparajita-capacitor-secure-storage-BDrMx_CE.js} +1 -1
- package/dist/assets/{vendor-base-ui-BscvGUFt.js → vendor-base-ui-CKRUCG-f.js} +1 -1
- package/dist/assets/{vendor-boot-Dgb9NVFe.js → vendor-boot-EC6IyLt1.js} +13 -13
- package/dist/assets/{vendor-capacitor-app-BjdQVib9.js → vendor-capacitor-app-BaupizkW.js} +1 -1
- package/dist/assets/{vendor-capacitor-keyboard-eTtI5go3.js → vendor-capacitor-keyboard-9BVxykO7.js} +1 -1
- package/dist/assets/{vendor-capacitor-status-bar-9rNIGxlO.js → vendor-capacitor-status-bar-BsrUwiaA.js} +1 -1
- package/dist/assets/{vendor-codemirror-autocomplete-DxS3jwvE.js → vendor-codemirror-autocomplete-CGpAsPWp.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-angular-DdjXl9e2.js → vendor-codemirror-lang-angular-CDJoHJSY.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp--aMr7NVt.js → vendor-codemirror-lang-cpp-BmHofQls.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-CZ_qxZY9.js → vendor-codemirror-lang-css-RM2HqXZ0.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-Ca-y2Alu.js → vendor-codemirror-lang-go-Crwca_X7.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-html-COZ0L5wT.js → vendor-codemirror-lang-html-CHSHUpwq.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-java-D3Rf3QNJ.js → vendor-codemirror-lang-java-lhQXgWu0.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-javascript-DwJ-IvCs.js → vendor-codemirror-lang-javascript-Dw4kFO4e.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-jinja-D_5lod6k.js → vendor-codemirror-lang-jinja-_pAC3UTN.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-BG8C7OpC.js → vendor-codemirror-lang-json-B-b1vAv-.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-CVEkoaTw.js → vendor-codemirror-lang-less-xIgOi1ze.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-U9vj0m8w.js → vendor-codemirror-lang-liquid-CP49m5dB.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-markdown-DqlYH9gY.js → vendor-codemirror-lang-markdown-BTht2ATe.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-php-BFEiEVA1.js → vendor-codemirror-lang-php-BguZDhaO.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-python-Cz1dQXQd.js → vendor-codemirror-lang-python-CH6_em9L.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-rust-C_CoD9mj.js → vendor-codemirror-lang-rust-EG_DtGyi.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-BuR0aKh5.js → vendor-codemirror-lang-sass-BknY5Qpo.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-DggNUjdM.js → vendor-codemirror-lang-sql-B0f-qCZo.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-DFZHi2J3.js → vendor-codemirror-lang-vue-CyGn9snv.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-zuTN3SHT.js → vendor-codemirror-lang-wast-CsFfSyyB.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-xml-CrcvhI-k.js → vendor-codemirror-lang-xml-Cdan_Jp1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-yaml-DcVWsakb.js → vendor-codemirror-lang-yaml-COI5hck8.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-CCLITgCF.js → vendor-codemirror-language-data-CqU7kHmg.js} +2 -2
- package/dist/assets/{vendor-codemirror-search-H7NOEdbX.js → vendor-codemirror-search-DUfSCF9S.js} +1 -1
- package/dist/assets/{vendor-lezer-cpp-C8aD2KAr.js → vendor-lezer-cpp-DMZOJzBa.js} +1 -1
- package/dist/assets/{vendor-lezer-css-2lbTJF-Y.js → vendor-lezer-css-DUkkbMp7.js} +1 -1
- package/dist/assets/{vendor-lezer-go-Bw6LFTrZ.js → vendor-lezer-go-CHIhCNY6.js} +1 -1
- package/dist/assets/{vendor-lezer-html-D7ym2z7S.js → vendor-lezer-html-B3h0MOrG.js} +1 -1
- package/dist/assets/{vendor-lezer-java-CZhK7w21.js → vendor-lezer-java-tMazV_6X.js} +1 -1
- package/dist/assets/{vendor-lezer-javascript-rpKeTHZp.js → vendor-lezer-javascript-ctwLWf4v.js} +1 -1
- package/dist/assets/{vendor-lezer-json-C7jwsd2G.js → vendor-lezer-json-BP_UAzLL.js} +1 -1
- package/dist/assets/{vendor-lezer-lr-DR-ylqNN.js → vendor-lezer-lr-B8TQctNw.js} +1 -1
- package/dist/assets/{vendor-lezer-markdown-Bir0m5nB.js → vendor-lezer-markdown-aGLZf_3h.js} +1 -1
- package/dist/assets/{vendor-lezer-php-y0hIEfo1.js → vendor-lezer-php-D5zCNzlt.js} +1 -1
- package/dist/assets/{vendor-lezer-python-D64A9lNV.js → vendor-lezer-python-EJ4Im4y2.js} +1 -1
- package/dist/assets/{vendor-lezer-rust-E3ZA9T2L.js → vendor-lezer-rust-DO5c7OtA.js} +1 -1
- package/dist/assets/{vendor-lezer-sass-C5UFI9SP.js → vendor-lezer-sass-CMi6zfXI.js} +1 -1
- package/dist/assets/{vendor-lezer-xml-DOy7FzCR.js → vendor-lezer-xml-0MHMeZDp.js} +1 -1
- package/dist/assets/{vendor-lezer-yaml-kEjaSCvZ.js → vendor-lezer-yaml-BE2EFjpA.js} +1 -1
- package/dist/assets/{vendor-replit-codemirror-vim-BLfh0LPy.js → vendor-replit-codemirror-vim-AnOuN8yJ.js} +1 -1
- package/dist/assets/{web-components-CdMfsnXE.js → web-components-CeHLxvED.js} +3 -3
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/dist/sw.js +1 -1
- package/package.json +1 -2
- package/server/index.js +69 -30
- package/server/lib/client-auth/DOCUMENTATION.md +15 -1
- package/server/lib/client-auth/pairing.js +2 -12
- package/server/lib/client-auth/remote-clients.js +2 -12
- package/server/lib/cloudflare-tunnel.js +0 -132
- package/server/lib/fs/DOCUMENTATION.md +8 -0
- package/server/lib/fs/atomic-write.js +111 -0
- package/server/lib/fs/atomic-write.test.js +133 -0
- package/server/lib/notifications/DOCUMENTATION.md +43 -32
- package/server/lib/notifications/pi-notification-watcher.js +8 -7
- package/server/lib/notifications/pi-notification-watcher.test.js +88 -2
- package/server/lib/pi/routes-extension-events.test.js +231 -0
- package/server/lib/pi/routes.js +137 -4
- package/server/lib/pi/routes.test.js +248 -2
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +17 -4
- package/server/lib/pi/session-daemon/daemon-process.js +2 -0
- package/server/lib/pi/session-daemon/engines/index.js +6 -0
- package/server/lib/pi/session-daemon/extension-bridge-draft.test.js +1 -1
- package/server/lib/pi/session-daemon/extension-bridge.js +24 -0
- package/server/lib/pi/session-daemon/extension-message-render.js +74 -0
- package/server/lib/pi/session-daemon/extension-message-render.test.js +164 -0
- package/server/lib/pi/session-daemon/extension-tool-render.js +13 -6
- package/server/lib/pi/session-daemon/pending-input.js +188 -0
- package/server/lib/pi/session-daemon/pending-input.test.js +202 -0
- package/server/lib/pi/session-daemon/session-daemon-engines.test.js +828 -0
- package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +296 -6
- package/server/lib/pi/session-daemon/session-daemon-turn.e2e.test.js +9 -0
- package/server/lib/pi/session-daemon/session-daemon.js +219 -19
- package/server/lib/pi/session-daemon/session-daemon.test.js +30 -2
- package/server/lib/pi/session-daemon/session-engine-router.js +390 -0
- package/server/lib/pi/session-daemon/session-engine-router.test.js +515 -0
- package/server/lib/pi/session-daemon/session-engines.js +467 -0
- package/server/lib/pi/session-daemon/session-engines.test.js +383 -0
- package/server/lib/pi/snippets-store.js +8 -17
- package/server/lib/pi/ui-settings-store.js +6 -10
- package/server/lib/pi/ui-settings-store.test.js +37 -1
- package/server/lib/relay/DOCUMENTATION.md +6 -4
- package/server/lib/relay/identity-store.js +116 -0
- package/server/lib/relay/identity-store.test.js +169 -0
- package/server/lib/relay/identity.js +6 -4
- package/server/lib/relay/server-id.js +63 -0
- package/server/lib/relay/server-id.test.js +132 -0
- package/server/lib/relay/signing-key.js +14 -11
- package/server/lib/security/bind-host.js +6 -2
- package/server/lib/security/bind-host.test.js +17 -0
- package/server/lib/server/core-routes.js +27 -1
- package/server/lib/server/lan-addresses.js +18 -6
- package/server/lib/server/lan-addresses.test.js +28 -0
- package/server/lib/server/tunnel-auth.js +47 -7
- package/server/lib/server/tunnel-auth.rate-limit.test.js +164 -0
- package/server/lib/server/tunnel-service.DOCUMENTATION.md +3 -4
- package/server/lib/server/tunnel-service.js +23 -20
- package/server/lib/server/tunnel-service.test.js +19 -2
- package/server/lib/stt/config-store.js +5 -15
- package/server/lib/tailscale/DOCUMENTATION.md +264 -0
- package/server/lib/tailscale/routes.js +45 -0
- package/server/lib/tailscale/service.js +959 -0
- package/server/lib/tailscale/tailscale.js +302 -0
- package/server/lib/tailscale/tailscale.test.js +1861 -0
- package/server/lib/tunnels/DOCUMENTATION.md +3 -4
- package/server/lib/tunnels/providers/cloudflare.js +1 -22
- package/server/lib/tunnels/types.js +0 -2
- package/server/lib/ui-auth/DOCUMENTATION.md +31 -0
- package/server/lib/ui-auth/ui-auth.js +80 -6
- package/server/lib/ui-auth/ui-auth.test.js +136 -0
- package/server/lib/ui-auth/ui-passkeys.js +2 -13
- package/server/lib/update-job-store.js +4 -6
- package/dist/assets/DiffView-hz90_htv.js +0 -18
- package/dist/assets/FilesView-DaqkPMqx.js +0 -6
- package/dist/assets/PierreDiffViewer-BeGpdI0x.js +0 -134
- package/dist/assets/PullRequestsSurface-D9beq2x9.js +0 -2
- package/dist/assets/SessionSwitcherContent-DElQ_cjm.js +0 -1
- package/dist/assets/SessionSwitcherDropdown-JaIDcDIj.js +0 -2
- package/dist/assets/SessionUnreadDot-Czfvjbdi.js +0 -1
- package/dist/assets/SettingsView-C_GC1Mx3.js +0 -6
- package/dist/assets/index-BnZVqcki.js +0 -11
- package/dist/assets/index-BnieExes.css +0 -1
- package/dist/assets/main-6YKi4QM2.js +0 -2
- package/dist/assets/main-CWdWdhdL.js +0 -136
- package/dist/assets/mobile-0LY-2fxw.js +0 -2
- package/dist/assets/pi-session-focus-preference-BC-ze1oC.js +0 -10
- package/dist/assets/renderElectronMiniChatApp-DETQLjFi.js +0 -2
- package/dist/assets/renderMobileApp-DS0FDQLg.js +0 -11
- package/dist/assets/runtimeEndpointReset-BqqXMwE9.js +0 -62
- package/dist/assets/useAppFontEffects-BisjofNZ.js +0 -212
- package/dist/assets/useGitHubRemoteSearch-Bsf2YeQP.js +0 -1
- package/dist/assets/vendor-capacitor-push-notifications-CBKq2Arn.js +0 -1
- package/server/lib/notifications/delivery-runtime.js +0 -314
- package/server/lib/notifications/delivery-runtime.test.js +0 -85
- package/server/lib/notifications/routes.js +0 -74
- package/server/lib/relay/service.js +0 -9
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{ah as bo,ca as Nt,cb as Mn,z as c,af as pa,M as me,cc as wo,cd as yo,L as ha,K as nn,am as ga,S as ko,an as Pn,k as t,ai as jo,c4 as Co,ad as No,ce as So,c7 as st,cf as Er,c3 as Ro,G as Fo,Q as kn,cg as Eo,ch as zo,c6 as Mo,aL as To,ci as Do,U as Ao,J as Oo}from"./vendor-boot-Dgb9NVFe.js";import{R as s,a as y}from"./vendor-react-DASdDPIk.js";import{o as J,H as Po,h as Lo,bW as Io,F as Bo,bX as $o,t as Fe,bY as xa,K as Re,a as Vo,A as Wo,L as _o,bZ as Ct,I as Ko,J as qo,_ as zr,b_ as Go,ae as Mr,m as Tr,G as jn,aA as Ho}from"./index-BnZVqcki.js";import{ch as Uo,a7 as xt,B as q,I as F,ai as Et,ci as Jo,ak as va,al as ba,am as wa,an as ya,ao as ka,ap as ja,a8 as Ln,ab as In,ad as Bn,ae as Qt,t as pe,af as Zt,ag as Xo,cj as en,aj as Ca,E as Dr,b2 as Yo,ck as Na,cl as Sa,cm as Ra,cn as Fa,co as Tn,cp as Qo,a9 as Xe,aa as Ye,ac as Qe,q as Zo,aq as ei,a4 as ti,p as ni,ah as ri,cq as Ar,ar as Or,aM as ai,cr as Pr}from"./useAppFontEffects-BisjofNZ.js";import{javascript as ht}from"./vendor-codemirror-lang-javascript-DwJ-IvCs.js";import{json as Ea}from"./vendor-codemirror-lang-json-BG8C7OpC.js";import{css as za}from"./vendor-codemirror-lang-css-CZ_qxZY9.js";import{html as Dn}from"./vendor-codemirror-lang-html-COZ0L5wT.js";import{markdown as Ma}from"./vendor-codemirror-lang-markdown-DqlYH9gY.js";import{l as Ta}from"./vendor-codemirror-language-data-CCLITgCF.js";import{python as Da}from"./vendor-codemirror-lang-python-Cz1dQXQd.js";import{shell as si}from"./shell-CjFT_Tl9.js";import{ensurePierreThemeRegistered as Lr,getResolvedShikiTheme as oi}from"./appThemeRegistry-gegrE2dq.js";import{D as ii,i as Aa,b as Oa,s as ci,F as li}from"./FileSaveConflictDialog-CcrWHRvd.js";import{h as Ir,y as ui,z as di,B as fi,E as mi,G as pi,P as Xt}from"./runtimeEndpointReset-BqqXMwE9.js";import{h as An,i as Pa,j as La}from"./SessionUnreadDot-Czfvjbdi.js";import{g as St,c as Ia,d as Ba,e as $n,n as hi,f as gi,M as Rt,h as oe,j as xi,s as vi,i as bi,a as wi,t as Yt,k as Cn,b as yi,l as ki,u as ji,m as Br,o as Ci,p as $r}from"./useFilesViewSearch-BWABG6pS.js";import{J as Ni,F as Si}from"./JsonTreeView-CKTqB1CD.js";import{a as Vr,g as tn,b as Wr,c as _r,o as Ri,d as Fi}from"./vendor-codemirror-search-H7NOEdbX.js";import{v as Ei,g as zi}from"./vendor-replit-codemirror-vim-BLfh0LPy.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./runtimeSurface-DBiUWYK2.js";import"./nativeFileSave-BzhtrDoD.js";import"./vendor-lezer-javascript-rpKeTHZp.js";import"./vendor-lezer-lr-DR-ylqNN.js";import"./vendor-codemirror-autocomplete-DxS3jwvE.js";import"./vendor-lezer-json-C7jwsd2G.js";import"./vendor-lezer-css-2lbTJF-Y.js";import"./vendor-lezer-html-D7ym2z7S.js";import"./vendor-lezer-markdown-Bir0m5nB.js";import"./vendor-lezer-python-D64A9lNV.js";import"./registerCustomTheme-DmolaWWZ.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.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-react-drawio-Duu5LgQA.js";/* empty css */import"./permissionStore-B9Hkrqny.js";import"./web-components-CdMfsnXE.js";import"./computeVirtualFileMetrics-CyhUKEfv.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.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"./Virtualizer-Cp_cJWbI.js";import"./renderFileWithHighlighter-CnN0Tv_8.js";const On=bo.define(si);function Mi(e){const n=e.trim().toLowerCase();switch(n){case"bash":case"sh":case"zsh":case"shell":case"shellsession":case"console":return On;case"json":case"jsonc":case"json5":return Ea().language;case"js":case"javascript":return ht().language;case"jsx":return ht({jsx:!0}).language;case"ts":case"typescript":return ht({typescript:!0}).language;case"tsx":return ht({typescript:!0,jsx:!0}).language;case"html":return Dn().language;case"css":return za().language;case"py":case"python":return Da().language;case"md":case"markdown":case"mdown":case"mkd":return Ma().language;case"heex":case"eex":case"leex":return Dn().language;default:return pa.matchLanguageName(Ta,n,!0)}}const $a=e=>e.split("/").pop()?.toLowerCase()??"",Ti=e=>{const n=$a(e);return n?pa.matchFilename(Ta,n):null},Di=()=>Nt(Mn.define([{tag:[c.heading1,c.heading2,c.heading3,c.heading4,c.heading5,c.heading6],fontWeight:"600"},{tag:c.strong,fontWeight:"600"},{tag:c.emphasis,fontStyle:"italic"},{tag:c.strikethrough,textDecoration:"line-through"},{tag:[c.link,c.url],color:"var(--markdown-link, currentColor)",textDecoration:"underline"},{tag:c.monospace,color:"var(--markdown-inline-code, currentColor)",backgroundColor:"var(--markdown-inline-code-bg, transparent)"},{tag:c.quote,color:"var(--markdown-blockquote, currentColor)",fontStyle:"italic"},{tag:c.list,color:"color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)"},{tag:c.heading,color:"var(--markdown-heading1, currentColor)"}]));function Ai(e){const n=e.toLowerCase();switch($a(n)){case"makefile":case"gnumakefile":return On}const i=n.lastIndexOf("."),o=i>=0?n.slice(i+1):"";switch(o){case"ts":case"tsx":case"mts":case"cts":return ht({typescript:!0,jsx:o==="tsx"});case"js":case"jsx":case"mjs":case"cjs":return ht({typescript:!1,jsx:o==="jsx"});case"json":case"jsonc":case"json5":case"jsonl":case"ndjson":case"geojson":return Ea();case"css":case"scss":case"sass":case"less":return za();case"html":case"htm":case"xml":case"drawio":case"dio":return Dn();case"md":case"mdx":case"markdown":case"mdown":case"mkd":return[Ma({codeLanguages:Mi}),Di()];case"sh":case"bash":case"zsh":case"fish":case"env":return On;case"py":case"pyw":case"pyi":return Da();default:return null}}async function Oi(e){const n=Ti(e);if(!n)return null;if(n.support)return n.support;try{return await n.load()}catch{return null}}function Kr(e,n){const a=e.metadata.variant==="dark",i=e.config?.fonts?.mono||"monospace",o=e.colors.syntax.highlights||{},u=e.colors.syntax.tokens||{},f=n?.fontSize?`${n.fontSize}px`:"var(--text-code)",m=me.theme({"&":{backgroundColor:"var(--background)",color:e.colors.syntax.base.foreground,fontSize:f,lineHeight:"1.5",position:"relative"},".cm-scroller":{fontFamily:i,backgroundColor:"var(--background)"},".cm-comment":{color:e.colors.syntax.base.comment},".cm-keyword":{color:e.colors.syntax.base.keyword},".cm-string":{color:e.colors.syntax.base.string},".cm-string-2":{color:u.stringEscape||e.colors.syntax.base.string},".cm-number":{color:e.colors.syntax.base.number},".cm-operator":{color:e.colors.syntax.base.operator},".cm-punctuation":{color:u.punctuation||e.colors.syntax.base.comment},".cm-atom":{color:u.boolean||e.colors.syntax.base.number},".cm-builtin":{color:u.functionCall||e.colors.syntax.base.function},".cm-def":{color:u.variableGlobal||e.colors.syntax.base.variable},".cm-attribute":{color:u.variableOther||u.variableProperty||e.colors.syntax.base.operator},".cm-meta":{color:e.colors.syntax.base.comment},".cm-property":{color:u.variableProperty||e.colors.syntax.base.keyword},".cm-variable":{color:e.colors.syntax.base.variable},".cm-variable-2":{color:u.variableOther||e.colors.syntax.base.function},".cm-variable-3":{color:u.variableGlobal||e.colors.syntax.base.type},".cm-tag":{color:u.tag||e.colors.syntax.base.keyword},".cm-link":{color:u.url||e.colors.syntax.base.keyword,textDecoration:"underline"},".cm-content":{caretColor:e.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e.colors.interactive.selection},".cm-gutters":{backgroundColor:"var(--background)",color:o.lineNumber||e.colors.syntax.base.comment,borderRight:`1px solid ${e.colors.interactive.border}`,position:"sticky",paddingRight:"8px",left:0,zIndex:2,boxShadow:"0 0 0 var(--background)"},".cm-gutter":{backgroundColor:"var(--background)"},".cm-gutterElement":{backgroundColor:"var(--background)"},".cm-lineNumbers":{backgroundColor:"var(--background)"},".cm-lineNumbers .cm-gutterElement":{paddingLeft:"8px",paddingRight:"8px",minWidth:"42px"},".cm-activeLineGutter":{color:o.lineNumberActive||e.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:e.colors.surface.overlay},".cm-panels":{backgroundColor:"transparent",color:e.colors.surface.foreground,position:"absolute",top:"0",right:"0",left:"auto",width:"auto",zIndex:10,pointerEvents:"none"},".cm-panels-top":{borderBottom:"none",position:"absolute",top:"6px",right:"14px",left:"auto",width:"auto"},".cm-panels-bottom":{position:"static",width:"100%",pointerEvents:"auto"},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.colors.surface.mutedForeground,fontFamily:"var(--font-mono)",fontSize:"12px",minHeight:"22px",padding:"2px 8px"},".cm-panel.cm-search":{pointerEvents:"auto",padding:"4px",backgroundColor:`color-mix(in srgb, ${e.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${e.colors.interactive.border}`,borderRadius:"10px",boxShadow:`0 2px 8px color-mix(in srgb, ${e.colors.surface.background} 60%, transparent)`,width:"auto",minWidth:"360px",maxWidth:"480px"},".cm-search":{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0",width:"100%",color:e.colors.surface.foreground,fontFamily:"inherit",fontSize:"13px",lineHeight:"1"},".cm-search br":{display:"none"},".cm-search .cm-textfield":{appearance:"none",height:"26px",margin:0,padding:"0 8px",borderRadius:"6px !important",border:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.background,color:e.colors.surface.foreground,fontFamily:"inherit",fontSize:"12px",lineHeight:"1",outline:"none",transition:"border-color 150ms ease"},".cm-search .cm-textfield::placeholder":{color:e.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:e.colors.primary.base},'.cm-search .cm-textfield[name="search"]':{order:1,flex:"1 1 120px",maxWidth:"calc(100% - 142px)",minWidth:"100px"},".cm-search label":{order:2,display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"1px solid transparent",backgroundColor:"transparent",color:"transparent",cursor:"pointer",userSelect:"none",fontSize:"1px",lineHeight:"0",overflow:"hidden",position:"relative",transition:"background-color 120ms ease, border-color 120ms ease"},".cm-search label:hover":{backgroundColor:e.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:e.colors.interactive.hover,borderColor:e.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:"none",WebkitAppearance:"none",width:"0",height:"0",margin:"0",padding:"0",border:"none",position:"absolute",opacity:"0",pointerEvents:"none"},".cm-search label::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"13px",fontWeight:"600",lineHeight:"1",fontFamily:"inherit",color:e.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search label:hover::after":{color:e.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:e.colors.surface.foreground},'.cm-search label:has(input[name="case"])::after':{content:'"Aa"',fontSize:"12px",letterSpacing:"-0.5px"},'.cm-search label:has(input[name="re"])::after':{content:'".*"',fontSize:"13px",fontFamily:"monospace"},'.cm-search label:has(input[name="word"])::after':{content:'"ab"',fontSize:"12px",textDecoration:"underline",textUnderlineOffset:"2px"},".cm-search .cm-search-message":{order:3,color:e.colors.surface.mutedForeground,backgroundColor:"transparent",border:"none",borderRadius:"0",padding:"0 6px",fontSize:"11px",whiteSpace:"nowrap",lineHeight:"26px"},".cm-search .cm-button":{appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:"transparent",cursor:"pointer",fontSize:"1px",fontWeight:"400",lineHeight:"0",overflow:"hidden",position:"relative",boxShadow:"none",transition:"background-color 120ms ease"},".cm-search .cm-button::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"15px",lineHeight:"1",color:e.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search .cm-button:hover":{backgroundColor:e.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:e.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:e.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:"none",boxShadow:`0 0 0 1px ${e.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:"default",pointerEvents:"none"},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:"2px"},'.cm-search .cm-button[name="prev"]::after':{content:'"↑"'},'.cm-search .cm-button[name="next"]':{order:22,marginTop:"2px"},'.cm-search .cm-button[name="next"]::after':{content:'"↓"'},'.cm-search .cm-button[name="select"]':{order:23,marginTop:"2px"},'.cm-search .cm-button[name="select"]::after':{content:'"≡"',fontSize:"17px"},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:"0 0 0 auto",padding:"0",borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:e.colors.surface.mutedForeground,cursor:"pointer",fontSize:"16px",lineHeight:"1",boxShadow:"none",position:"relative",overflow:"visible",transition:"background-color 120ms ease, color 120ms ease"},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:e.colors.interactive.hover,color:e.colors.surface.foreground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:"2px"},'.cm-search .cm-button[name="replace"]::after':{content:'"⇄"'},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:"2px"},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:'"⇉"'},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:"1 1 100%",maxWidth:"calc(100% - 142px)",minWidth:"80px",marginTop:"2px"},".cm-searchMatch":{backgroundColor:e.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${e.colors.status.infoBorder}`,borderRadius:"2px"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.borderFocus}`},"&.cm-focused":{outline:"none"}},{dark:a}),g=Mn.define([{tag:[c.comment,c.docComment,c.meta,c.documentMeta],class:"cm-comment"},{tag:[c.keyword,c.controlKeyword,c.moduleKeyword,c.definitionKeyword,c.modifier],class:"cm-keyword"},{tag:[c.operatorKeyword,c.operator,c.derefOperator,c.updateOperator,c.definitionOperator,c.typeOperator,c.controlOperator,c.logicOperator,c.bitwiseOperator,c.arithmeticOperator,c.compareOperator],class:"cm-operator"},{tag:[c.punctuation,c.separator,c.bracket,c.paren,c.brace,c.squareBracket,c.angleBracket],class:"cm-punctuation"},{tag:[c.string,c.regexp,c.attributeValue,c.special(c.string),c.monospace],class:"cm-string"},{tag:c.escape,class:"cm-string-2"},{tag:[c.number,c.bool,c.atom,c.null,c.self],class:"cm-number"},{tag:[c.function(c.variableName),c.function(c.definition(c.variableName)),c.function(c.propertyName),c.standard(c.variableName),c.special(c.variableName)],class:"cm-builtin"},{tag:c.definition(c.variableName),class:"cm-def"},{tag:[c.variableName,c.local(c.variableName),c.constant(c.variableName),c.literal],class:"cm-variable"},{tag:c.propertyName,class:"cm-property"},{tag:c.attributeName,class:"cm-attribute"},{tag:[c.className,c.typeName,c.namespace],class:"cm-variable-3"},{tag:[c.tagName,c.labelName,c.annotation,c.macroName],class:"cm-tag"},{tag:c.link,class:"cm-link"},{tag:[c.heading,c.heading1,c.heading2,c.heading3,c.heading4,c.heading5,c.heading6],class:"cm-keyword"}]),w=Mn.define([{tag:[c.comment,c.docComment,c.meta,c.documentMeta],color:e.colors.syntax.base.comment},{tag:[c.keyword,c.controlKeyword,c.moduleKeyword,c.definitionKeyword,c.modifier],color:e.colors.syntax.base.keyword},{tag:[c.operatorKeyword,c.operator,c.derefOperator,c.updateOperator,c.definitionOperator,c.typeOperator,c.controlOperator,c.logicOperator,c.bitwiseOperator,c.arithmeticOperator,c.compareOperator],color:e.colors.syntax.base.operator},{tag:[c.string,c.regexp,c.attributeValue,c.special(c.string),c.monospace],color:e.colors.syntax.base.string},{tag:c.escape,color:u.stringEscape||e.colors.syntax.base.string},{tag:[c.number,c.bool,c.atom,c.null,c.self],color:e.colors.syntax.base.number},{tag:[c.function(c.variableName),c.function(c.definition(c.variableName)),c.function(c.propertyName),c.standard(c.variableName),c.special(c.variableName)],color:e.colors.syntax.base.function},{tag:c.definition(c.variableName),color:u.variableGlobal||e.colors.syntax.base.variable},{tag:[c.variableName,c.local(c.variableName),c.constant(c.variableName),c.literal],color:e.colors.syntax.base.variable},{tag:c.propertyName,color:u.variableProperty||e.colors.syntax.base.variable},{tag:c.attributeName,color:u.variableOther||e.colors.syntax.base.variable},{tag:[c.className,c.typeName,c.namespace],color:e.colors.syntax.base.type},{tag:[c.tagName,c.labelName,c.annotation,c.macroName],color:u.tag||e.colors.syntax.base.keyword},{tag:c.link,color:u.url||e.colors.syntax.base.function,textDecoration:"underline"},{tag:[c.punctuation,c.separator,c.bracket,c.paren,c.brace,c.squareBracket,c.angleBracket],color:u.punctuation||e.colors.syntax.base.comment}]);return n?.syntaxColors===!1?[m]:[m,Nt(wo,{fallback:!0}),Nt(yo),Nt(g),Nt(w)]}const Pi=180,Va=ko.define(),Li=1,Ii=2,Bi=4,qr=new Map,$i=(e,n)=>{const a=`${e}|${n}`,i=qr.get(a);if(i)return i;let o="";e&&(o+=`color:${e};`),n&Li&&(o+="font-style:italic;"),n&Ii&&(o+="font-weight:bold;"),n&Bi&&(o+="text-decoration:underline;");const u=nn.mark({attributes:{style:o}});return qr.set(a,u),u},Vi=(e,n)=>{const a=new Pn,i=e.state.doc,o=Math.min(n.length,i.lines);for(let u=0;u<o;u+=1){const f=n[u];if(!f||f.length===0)continue;const m=i.line(u+1);let g=m.from;for(const[w,N,x]of f){if(w<=0)continue;const b=g,j=Math.min(g+w,m.to);g+=w,!(j<=b)&&(!N&&!x||a.add(b,j,$i(N,x)))}}return a.finish()},Wi=ha.define({create(){return nn.none},update(e,n){let a=e.map(n.changes);for(const i of n.effects)i.is(Va)&&(a=i.value);return a},provide:e=>me.decorations.from(e)}),_i=e=>ga.fromClass(class{timer;generation=0;constructor(n){this.tokenize(n)}update(n){n.docChanged&&this.schedule(n.view)}schedule(n){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.tokenize(n)},Pi)}async tokenize(n){const a=++this.generation,i=n.state.doc.toString(),o=await Uo(i,e.language,e.themeName,e.theme);o&&a===this.generation&&n.state.doc.length===i.length&&n.dispatch({effects:Va.of(Vi(n,o))})}destroy(){this.timer&&clearTimeout(this.timer)}}),Ki=e=>[Wi,_i(e)],Ke=e=>(e||"").replace(/\\/g,"/").replace(/\/+$/g,""),gt=e=>{const n=Ke(e);return!n||n==="/"?n||"/":n.split("/").filter(Boolean).at(-1)??n},Wa=e=>{const n=Ke(e);if(!n||n==="/")return null;const a=n.lastIndexOf("/");if(a<0)return null;if(a===0)return"/";const i=n.slice(0,a);return/^[A-Za-z]:$/.test(i)?`${i}/`:i},Gr=(e,n)=>{const a=Ke(e),i=Ke(n);return!a||!i?!1:a===i||a.startsWith(`${i}/`)},Hr=(e,n)=>{const a=Ke(e);if(!a)return Ke(n);if(a.startsWith("/")||/^[A-Za-z]:(\/|$)/.test(a))return a;const i=Ke(n);return i?`${i}/${a}`:a},qi=(e,n)=>{const a=Ke(e),i=Ke(n);if(!a||a===i)return!1;const o=Wa(a);return o?i&&Gr(a,i)?Gr(o,i):!0:!1},Gi=e=>{if(typeof e!="number"||!Number.isFinite(e)||e<0)return"";if(e<1024)return`${e} B`;const n=["KB","MB","GB"];let a=e/1024;for(const i of n){if(a<1024||i===n[n.length-1])return`${a.toFixed(a>=10?0:1)} ${i}`;a/=1024}return""},Hi=(e,n)=>!n||e===n?gt(e):e.startsWith(`${n}/`)?e.slice(n.length+1):e,Ui=({root:e,directory:n,entries:a,query:i,searchResults:o,isSearching:u,directoryError:f,refreshing:m,editorPath:g,editor:w,onClose:N,onQueryChange:x,onOpenDirectory:b,onOpenFile:j,onBackFromEditor:C,onRefresh:v})=>{if(!e)return t.jsx(Ft,{message:"Select a project to browse files."});if(g)return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsx(Ir,{leading:t.jsx(q,{type:"button",variant:"ghost",size:"icon","aria-label":"Back",onClick:C,style:{touchAction:"manipulation"},children:t.jsx(F,{name:"arrow-left",className:"size-4"})}),icon:t.jsx(xt,{filePath:g,className:"size-4 shrink-0"}),title:gt(g)}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:w})]});const L=n===e?"Project files":gt(n),I=qi(n,e)?Wa(n):null,l=!!I&&!i.trim(),B=I===e?"Project files":gt(I??""),G=N||l&&I?t.jsxs(t.Fragment,{children:[N?t.jsx(q,{type:"button",variant:"ghost",size:"icon","aria-label":"Close",onClick:N,style:{touchAction:"manipulation"},children:t.jsx(F,{name:"close",className:"size-4"})}):null,l&&I?t.jsx(q,{type:"button",variant:"ghost",size:"icon","aria-label":`Back to ${gt(I)}`,onClick:()=>b(I),style:{touchAction:"manipulation"},children:t.jsx(F,{name:"arrow-left",className:"size-4"})}):null]}):void 0;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsx(Ir,{leading:G,icon:n===e?"file-text":"folder",title:L,actions:t.jsx(q,{type:"button",variant:"ghost",size:"icon","aria-label":"Refresh files",onClick:v,style:{touchAction:"manipulation"},children:t.jsx(F,{name:"refresh",className:J("size-4",m&&"animate-spin")})})}),t.jsx("div",{className:"shrink-0 px-3 py-2",children:t.jsxs("div",{className:"relative",children:[t.jsx(F,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),t.jsx(Et,{value:i,onChange:D=>x(D.target.value),placeholder:"Search files",className:"h-8 pl-7"})]})}),t.jsx(Jo,{className:"min-h-0 w-full flex-1 overflow-y-auto pb-3",children:f?t.jsx(Ft,{message:f}):i.trim()?t.jsx(Ji,{root:e,results:o,isSearching:u,onOpenFile:j}):a===void 0?t.jsx(Ft,{loading:!0,message:"Loading..."}):t.jsxs("div",{className:"flex w-full min-w-0 flex-col px-1",children:[l&&I?t.jsxs("button",{type:"button",className:J(La,"px-2"),"aria-label":`Up one level to ${B}`,onClick:()=>b(I),style:{touchAction:"manipulation"},children:[t.jsx(F,{name:"arrow-left",className:J(An(!0),"text-muted-foreground")}),t.jsx("span",{className:J(Pa(!0),"flex-1 text-muted-foreground"),children:"Up one level"})]}):null,a.length===0?t.jsx("div",{className:"px-3 py-8 text-center typography-ui-label text-muted-foreground",children:"This directory is empty."}):null,a.map(D=>t.jsx(_a,{name:D.name,path:D.path,directory:D.type==="directory",meta:D.type==="directory"?void 0:Gi(D.size),onClick:()=>D.type==="directory"?b(Hr(D.path,n||e)):j(Hr(D.path,n||e))},D.path))]})})]})},_a=({name:e,path:n,directory:a,meta:i,onClick:o})=>t.jsxs("button",{type:"button",className:J(La,"px-2"),onClick:o,style:{touchAction:"manipulation"},children:[a?t.jsx(F,{name:"folder-3-fill",className:J(An(!0),"text-primary/80")}):t.jsx(xt,{filePath:n,className:An(!0)}),t.jsx("span",{className:J(Pa(!0),"flex-1 text-foreground"),children:e}),i?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:i}):null,a?t.jsx(F,{name:"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground/60"}):null]}),Ji=({root:e,results:n,isSearching:a,onOpenFile:i})=>a?t.jsx(Ft,{loading:!0,message:"Loading..."}):n.length===0?t.jsx(Ft,{message:"No files found."}):t.jsx("div",{className:"flex w-full min-w-0 flex-col px-1",children:n.map(o=>t.jsx(_a,{name:gt(o.path),path:o.path,directory:!1,meta:o.relativePath??Hi(o.path,e),onClick:()=>i(o.path)},o.path))}),Ft=({message:e,loading:n=!1})=>t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[n?t.jsx(F,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):t.jsx(F,{name:"folder-open-fill",className:"size-6 text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:e})]})}),Xi=({activeDialog:e,dialogData:n,dialogInputValue:a,onDialogInputChange:i,isDialogSubmitting:o,onDialogSubmit:u,onClose:f,inputRef:m})=>t.jsx(va,{open:!!e,onOpenChange:g=>!g&&f(),children:t.jsxs(ba,{initialFocus:m,children:[t.jsxs(wa,{children:[t.jsxs(ya,{children:[e==="createFile"&&"Create File",e==="createFolder"&&"Create Folder",e==="rename"&&"Rename",e==="delete"&&"Delete"]}),t.jsxs(ka,{children:[e==="createFile"&&`Create a new file in ${n?.path??"root"}`,e==="createFolder"&&`Create a new folder in ${n?.path??"root"}`,e==="rename"&&`Rename ${n?.name??""}`,e==="delete"&&`Are you sure you want to delete ${n?.name??""}? This action cannot be undone.`]})]}),e!=="delete"&&t.jsx("div",{className:"py-4",children:t.jsx(Et,{value:a,onChange:g=>i(g.target.value),placeholder:e==="rename"?"New name":"Name",onKeyDown:g=>{g.key==="Enter"&&u()},ref:m})}),t.jsxs(ja,{children:[t.jsx(q,{variant:"outline",onClick:f,disabled:o,children:"Cancel"}),t.jsx(q,{variant:e==="delete"?"destructive":"default",onClick:()=>{u()},disabled:o||e!=="delete"&&!a.trim(),children:o?t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):e==="delete"?"Delete":"Confirm"})]})]})}),Yi=({label:e,iconDataUrl:n})=>{const[a,i]=s.useState(!1),o=e.trim().slice(0,1).toUpperCase()||"?";return n&&!a?t.jsx("img",{src:n,alt:"",className:"size-4 rounded-sm",onError:()=>i(!0)}):t.jsx("span",{className:J("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),children:o})},Ka=({filePath:e,extension:n})=>t.jsx(xt,{filePath:e,extension:n}),Qi=({status:e})=>{const n={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"}[e];return t.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:n}})},Ur=({name:e})=>{const n=s.useRef(null),a=s.useRef(null),[i,o]=s.useState(!1);return s.useLayoutEffect(()=>{const u=n.current,f=a.current;if(!u||!f)return;const m=()=>{o(f.scrollWidth>u.clientWidth+1)};m();const g=new ResizeObserver(m);return g.observe(u),g.observe(f),()=>{g.disconnect()}},[e]),t.jsxs("span",{ref:n,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[t.jsx("span",{ref:a,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:e}),i?t.jsxs("span",{className:"open-file-name-marquee-track",children:[t.jsx("span",{className:"open-file-name-marquee-item",children:e}),t.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:e})]}):t.jsx("span",{className:"block min-w-0 truncate",children:e})]})},Zi=({node:e,root:n,isExpanded:a,isActive:i,isMobile:o,isBrowserClient:u,alwaysShowActions:f,status:m,badge:g,permissions:w,downloadFile:N,contextMenuPath:x,setContextMenuPath:b,rightClickMenuPath:j,setRightClickMenuPath:C,onSelect:v,onToggle:L,onRevealPath:I,onOpenDialog:l})=>{const B=e.type==="directory",{canRename:G,canCreateFile:D,canCreateFolder:$,canDelete:H,canReveal:_}=w,X=!B&&!!N,A=_&&!u,T=G||D||$||H||X||A,k=s.useCallback(d=>{T&&(d?.preventDefault(),C(e.path))},[T,e.path,C]),V=s.useCallback(()=>{B?L(e.path):v(e)},[B,e,v,L]),E=s.useCallback(d=>{d.stopPropagation(),C(null),b(e.path)},[e.path,b,C]),R=({Item:d,Separator:O})=>t.jsxs(t.Fragment,{children:[G&&t.jsxs(d,{onClick:S=>{S.stopPropagation(),l("rename",e)},children:[t.jsx(F,{name:"edit",className:"mr-2 size-4"})," ","Rename"]}),t.jsxs(d,{onClick:S=>{S.stopPropagation(),Qt(e.path).then(P=>{if(P.ok){pe.success("Path copied");return}pe.error("Copy failed")})},children:[t.jsx(F,{name:"file-copy",className:"mr-2 size-4"})," ","Copy Path"]}),t.jsxs(d,{onClick:S=>{S.stopPropagation();const P=St(n,e.path)||e.path;Qt(P).then(Y=>{if(Y.ok){pe.success("Relative path copied");return}pe.error("Copy failed")})},children:[t.jsx(F,{name:"file-copy-2",className:"mr-2 size-4"})," ","Copy Relative Path"]}),!B&&N&&t.jsxs(d,{onClick:S=>{S.stopPropagation(),N(e.path).catch(P=>{console.error("Download failed:",P),pe.error("Operation failed")})},children:[t.jsx(F,{name:"download",className:"mr-2 size-4"})," ",u?"Download":"Save"]}),A&&t.jsxs(d,{onClick:S=>{S.stopPropagation(),I(e.path)},children:[t.jsx(F,{name:"folder-received",className:"mr-2 size-4"})," ",Po()]}),B&&(D||$)&&t.jsxs(t.Fragment,{children:[t.jsx(O,{}),D&&t.jsxs(d,{onClick:S=>{S.stopPropagation(),l("createFile",e)},children:[t.jsx(F,{name:"file-add",className:"mr-2 size-4"})," ","New File"]}),$&&t.jsxs(d,{onClick:S=>{S.stopPropagation(),l("createFolder",e)},children:[t.jsx(F,{name:"folder-add",className:"mr-2 size-4"})," ","New Folder"]})]}),H&&t.jsxs(t.Fragment,{children:[t.jsx(O,{}),t.jsxs(d,{onClick:S=>{S.stopPropagation(),l("delete",e)},className:"text-destructive focus:text-destructive",children:[t.jsx(F,{name:"delete-bin",className:"mr-2 size-4"})," ","Delete"]})]})]});return t.jsxs(ui,{open:j===e.path,onOpenChange:d=>C(d?e.path:null),children:[t.jsxs(di,{render:t.jsx("div",{className:"group relative flex items-center",onContextMenu:o?void 0:k}),children:[t.jsxs("button",{type:"button",onClick:V,onContextMenu:o?void 0:k,className:J("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[B?a?t.jsx(F,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):t.jsx(F,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):t.jsx(Ka,{filePath:e.path,extension:e.extension}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:e.path,children:e.name}),!B&&m&&t.jsx(Qi,{status:m}),B&&g&&t.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[g.modified>0&&t.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",g.modified]}),g.added>0&&t.jsxs("span",{className:"text-[var(--status-success)]",children:["+",g.added]})]})]}),T&&t.jsx("div",{className:J("absolute right-1 top-1/2 -translate-y-1/2",f?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:t.jsxs(Ln,{open:x===e.path,onOpenChange:d=>b(d?e.path:null),children:[t.jsx(In,{asChild:!0,children:t.jsx(q,{variant:"ghost",size:"icon",className:"size-6",onClick:E,children:t.jsx(F,{name:"more-2-fill",className:"size-4"})})}),t.jsx(Bn,{align:"end",side:"bottom",onCloseAutoFocus:()=>b(null),children:R({Item:Zt,Separator:Xo})})]})})]}),t.jsx(fi,{className:"min-w-[180px]",children:R({Item:mi,Separator:pi})})]})},Nn=(e,n,a)=>{const[i,o]=s.useState(""),[u,f]=s.useState(0);return s.useEffect(()=>{if(!e){o("");return}let m=!1;o("");const g=Lo(),w=Io(g);Bo(g).then(x=>{m||!x||(o(e),n(null))}).catch(x=>{m||(n(x instanceof Error?x.message:a),o(e))});const N=$o(()=>{m||(o(e),f(x=>x+1),n(null))});return()=>{m=!0,w(),N()}},[e,n,a]),{readyKey:i,nonce:u}},ec=e=>e!==null&&typeof e=="object"&&"updateStatus"in e&&typeof e.updateStatus=="function",tc=e=>{const n=document.createElement("div");n.className="cm-vim-panel";const a=zi(e);if(!a)return{top:!1,dom:n};a.state.statusbar=n;const i=a.state.vimPlugin;return ec(i)&&i.updateStatus(),{top:!1,dom:n,destroy(){a.state.statusbar===n&&(a.state.statusbar=null)}}};function Jr(e){return e?[Ei(),jo.of(tc),Co()]:[]}const nc={next:"Next match",prev:"Previous match",select:"Select all matches",replace:"Replace",replaceAll:"Replace all",close:"Close"},rc={case:"Match case",re:"Regular expression",word:"Match whole word"};function ac(e){const n=e.querySelector(".cm-search");if(n){for(const[a,i]of Object.entries(nc)){const o=n.querySelector(`button[name="${a}"]`);o&&!o.title&&(o.title=i)}for(const[a,i]of Object.entries(rc)){const u=n.querySelector(`input[name="${a}"]`)?.parentElement;u&&!u.title&&(u.title=i)}}}const Sn=new WeakMap;function sc(e,n){const a=tn(e.state);if(!a.valid)return Sn.delete(e),0;const i=Sn.get(e);if(!n&&i?.doc===e.state.doc&&i.query.eq(a))return i.total;const o=a.getCursor(e.state);let u=0;for(let f=o.next();!f.done;f=o.next())u+=1;return Sn.set(e,{query:a,doc:e.state.doc,total:u}),u}function oc(e){const n=tn(e.state);if(!n.valid)return 0;const a=e.state.selection.main,i=n.getCursor(e.state);let o=0,u=0;for(let f=i.next();!f.done;f=i.next()){const m=f.value;if(o+=1,u===0&&(u=o),a.from===m.from&&a.to===m.to||a.from<m.to&&a.to>m.from||m.from>=a.head)return o}return u}function Xr(e,n,a=!1){const i=e.querySelector(".cm-search");if(!i)return;let o=i.querySelector(".cm-search-message");if(!o){o=document.createElement("span"),o.className="cm-search-message",o.setAttribute("aria-live","polite");const m=i.querySelector('button[name="next"]'),g=m?.parentNode===i?m:i.firstChild;i.insertBefore(o,g)}const u=sc(n,a),f=u===0?0:oc(n);o.textContent=u===0?"":`${f}/${u}`}const Yr=new st,Qr=new st,Zr=new st,ea=new st,ta=new st,na=new st,ra=new st,aa=e=>e,Rn=Do,ic=Ri,cc=Fi;class lc extends Ao{constructor(n,a){super(),this.id=n,this.containerMap=a}toDOM(){let n=this.containerMap.get(this.id);return n||(n=document.createElement("div"),n.className="oc-block-widget",n.dataset.widgetId=this.id,this.containerMap.set(this.id,n)),n}eq(n){return n.id===this.id}destroy(){}}const sa=(e,n)=>!e||e.length===0?[]:ha.define({create(a){const i=new Pn,o=[...e].sort((u,f)=>u.afterLine-f.afterLine);for(const u of o){const f=a.doc.lines;if(u.afterLine>f)continue;const m=a.doc.line(u.afterLine);i.add(m.to,m.to,nn.widget({widget:new lc(u.id,n),block:!0,side:1}))}return i.finish()},update(a,i){return a.map(i.changes)},provide:a=>me.decorations.from(a)}),oa=e=>{if(!e)return[];const n=Math.max(1,e.start),a=Math.max(n,e.end);return ga.fromClass(class{decorations;constructor(i){this.decorations=this.build(i)}update(i){(i.docChanged||i.viewportChanged)&&(this.decorations=this.build(i.view))}build(i){const o=new Pn;for(let u=n;u<=a&&u<=i.state.doc.lines;u+=1){const f=i.state.doc.line(u);o.add(f.from,f.from,nn.line({class:"oc-cm-selected-line"}))}return o.finish()}},{decorations:i=>i.decorations})};function uc({value:e,onChange:n,extensions:a,className:i,readOnly:o,lineNumbersConfig:u,highlightLines:f,onViewReady:m,onViewDestroy:g,blockWidgets:w,enableSearch:N,searchOpen:x,onSearchOpenChange:b,vimMode:j}){const C=s.useRef(null),v=s.useRef(null),L=s.useRef(e),I=s.useRef(n),l=s.useRef(m),B=s.useRef(g),G=s.useRef(b),D=s.useRef(w),$=s.useRef(j),H=s.useRef(new Map),[_,X]=s.useState([]),A=s.useCallback(k=>{const V=(k??[]).map(E=>{const R=H.current.get(E.id);return R?{id:E.id,content:E.content,container:R}:null}).filter(E=>E!==null);X(E=>E.length===V.length&&E.every((R,d)=>{const O=V[d];return R.id===O.id&&R.content===O.content&&R.container===O.container})?E:V)},[]),T=s.useCallback(k=>{const V=C.current,E=k??v.current;if(!V||!E)return;const R=E.dom.querySelector(".cm-gutters"),d=R instanceof HTMLElement?R.getBoundingClientRect().width:0;V.style.setProperty("--oc-editor-gutter-width",`${d}px`)},[]);return s.useEffect(()=>{L.current=e},[e]),s.useEffect(()=>{I.current=n},[n]),s.useEffect(()=>{l.current=m,B.current=g},[m,g]),s.useEffect(()=>{G.current=b},[b]),s.useEffect(()=>{D.current=w,A(w)},[w,A]),s.useEffect(()=>{if(!C.current)return;const k=(()=>{if(typeof document>"u")return null;const E=document.querySelector('meta[name="csp-nonce"]')?.getAttribute("content");if(E)return E;const R=window.__PICHAMBER_CSP_NONCE__;return typeof R=="string"&&R.length>0?R:null})(),V=No.create({doc:L.current,extensions:[...k?[me.cspNonce.of(k)]:[],So({fixed:!0}),Yr.of(Er(u)),Ro(),Fo.of(" "),ra.of(Jr(j)),kn.of([Eo,...zo,...Mo]),me.updateListener.of(E=>{T(E.view),(E.viewportChanged||E.geometryChanged)&&A(D.current);const R=Vr(E.startState),d=Vr(E.state);R!==d&&G.current?.(d);const O=!tn(E.startState).eq(tn(E.state));if(d&&(R!==d||O||E.docChanged||E.selectionSet)&&Xr(E.view.dom,E.view,R!==d||O||E.docChanged),!E.docChanged)return;const S=E.state.doc.toString();L.current=S,I.current(S),A(D.current)}),Qr.of(me.editable.of(!o)),Zr.of(a??[]),ea.of(oa(f)),ta.of(sa(w,H.current)),na.of(N?[Wr({top:!0}),kn.of(aa(_r))]:[])]});return v.current=new me({state:V,parent:C.current}),Rn(v.current,v.current.state.doc.length,200),v.current.requestMeasure(),requestAnimationFrame(()=>{T(v.current),A(D.current)}),v.current&&l.current?.(v.current),()=>{B.current?.(),v.current?.destroy(),v.current=null,X([])}},[D,T,A]),s.useEffect(()=>{const k=v.current;k&&(k.dispatch({effects:[Yr.reconfigure(Er(u)),Qr.reconfigure(me.editable.of(!o)),Zr.reconfigure(a??[]),ea.reconfigure(oa(f)),ta.reconfigure(sa(w,H.current)),na.reconfigure(N?[Wr({top:!0}),kn.of(aa(_r))]:[])]}),Rn(k,k.state.doc.length,200),k.requestMeasure(),requestAnimationFrame(()=>{T(k),A(D.current)}))},[a,f,u,o,w,N,T,A]),s.useEffect(()=>{const k=v.current;if(!k){$.current=j;return}$.current!==j&&($.current=j,k.dispatch({effects:ra.reconfigure(Jr(j))}))},[j]),s.useEffect(()=>{const k=v.current;!k||N===!1||(x?(ic(k),requestAnimationFrame(()=>{ac(k.dom),Xr(k.dom,k,!0)})):cc(k))},[x,N]),s.useEffect(()=>{const k=v.current;if(!k)return;const V=k.state.doc.toString();V!==e&&(k.dispatch({changes:{from:0,to:V.length,insert:e}}),Rn(k,k.state.doc.length,300),k.requestMeasure(),requestAnimationFrame(()=>T(k)))},[e,T]),t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:C,className:J("h-full w-full","[&_.cm-editor]:h-full [&_.cm-editor]:w-full","[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6","[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]",i)}),_.map(k=>To.createPortal(k.content,k.container,k.id))]})}const ia=({variant:e,selectedFile:n,loading:a,suppressLoadingIndicator:i,fileError:o,isSelectedImage:u,imageSrc:f,imagePreviewNonce:m,isSelectedPdf:g,pdfSrc:w,pdfPreviewNonce:N,isUnsupportedBinary:x,onDownload:b,enableRichPreviews:j,drawioViewMode:C,drawioRemountNonce:v,diagramEditorRef:L,diagramEditorXml:I,onDiagramChange:l,jsonViewMode:B,markdownViewMode:G,htmlViewMode:D,htmlLoading:$,htmlPreviewNonce:H,htmlPreviewSrc:_,fileContent:X,canUseShikiFileView:A,textViewMode:T,draftContent:k,onDraftChange:V,canEdit:E,vimMode:R,editorExtensions:d,editorWrapperRef:O,shouldMaskEditorForPendingNavigation:S,onEditorViewReady:P,onEditorViewDestroy:Y,enableSearch:ee=!1,searchOpen:re,onSearchOpenChange:te,pierreTheme:K,shikiThemeType:Z,wrapLines:Ze})=>{const Oe=e==="fullscreen",le=Oe?"p-4":"p-3",Pe=!!(n?.path&&en(n.path)),Le=!!(n?.path&&Ia(n.path)),ae=!!(n?.path&&Ba(n.path)),ue=!!(n?.path&&$n(n.path)),ye=()=>n?t.jsx("div",{className:"h-full",children:t.jsx(Si,{file:{name:n.name,contents:k,lang:Na(n.path)||void 0},options:{disableFileHeader:!0,overflow:Ze?"wrap":"scroll",theme:K,themeType:Z},className:"block h-full w-full",style:{height:"100%"}})}):null;return t.jsx(Ca,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:n?a?i?t.jsx("div",{className:le}):t.jsxs("div",{className:`${le} flex items-center gap-2 typography-ui text-muted-foreground`,children:[t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),Oe?"Loading…":"Loading..."]}):o?t.jsx("div",{className:`${le} typography-ui text-[color:var(--status-error)]`,children:o}):u?t.jsx("div",{className:J("flex h-full items-center justify-center",le),children:t.jsx("img",{src:f,alt:n.name||"Image",className:J("max-w-full object-contain rounded-md border border-border/30 bg-primary/10",Oe?"max-h-full":"max-h-[70vh]")},m)}):g?t.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:t.jsx("iframe",{src:w,className:"h-full w-full border-0",title:n.name},N)}):x?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("div",{className:"typography-ui-header text-foreground",children:"Cannot preview binary file"}),t.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:"This file is binary and cannot be edited in PiChamber. Download it to open with another app."}),b?t.jsxs(q,{type:"button",variant:"outline",size:"sm",onClick:b,children:[t.jsx(F,{name:"download",className:"mr-2 size-4"}),"Save file"]}):null]}):j&&Pe&&C==="preview"?t.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:t.jsx(ii,{ref:L,xml:I,onChange:l},`${n.path}:${v}`)}):j&&Le&&B==="tree"?t.jsx(Dr,{fallback:t.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[t.jsx("div",{className:"mb-1 font-medium text-destructive",children:"JSON viewer unavailable"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Switch to text mode to view raw content."})]}),children:t.jsx("div",{className:"h-full overflow-auto",children:t.jsx(Ni,{jsonString:X,maxHeight:"100%",initiallyExpandedDepth:2})})}):ae&&G==="preview"?t.jsxs("div",{className:J("h-full overflow-auto",le),children:[X.length>500*1024?t.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:`This file is large (${Math.round(X.length/1024)}KB). Preview may be limited.`}):null,t.jsx(Dr,{fallback:t.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[t.jsx("div",{className:"mb-1 font-medium text-destructive",children:"Preview unavailable"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Switch to edit mode to fix the issue."})]}),children:t.jsx(Yo,{content:X,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}):j&&ue&&D==="preview"?$?t.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:"Loading..."}):t.jsx("div",{className:"h-full overflow-hidden",children:t.jsx("iframe",{src:_,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:"HTML Preview"},H)}):A&&T==="view"?ye():t.jsxs("div",{className:J("relative h-full",S&&"overflow-hidden"),ref:O,children:[t.jsx("div",{className:J("h-full",S&&"invisible"),children:t.jsx(uc,{value:k,onChange:V,readOnly:!E,vimMode:R,extensions:d,className:"h-full",onViewReady:P,onViewDestroy:Y,...ee?{enableSearch:!0,searchOpen:re,onSearchOpenChange:te}:{}})}),S?t.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:t.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),"Opening file at change..."]})}):null]}):t.jsx("div",{className:`${le} typography-ui text-muted-foreground`,children:"Pick a file from the tree."})})};async function dc(e,n,a){if(Sa(e)&&!Ra(e))return{kind:n?"desktop-image":"asset-image"};if(Fa(e))return{kind:"pdf"};if(Tn(e))return{kind:"binary",detectedFromContent:!1};const o=await a(e);if(Qo(o))return{kind:"binary",detectedFromContent:!0};const u=hi(o);return{kind:"text",content:u,draft:u.length>Rt?`${u.slice(0,Rt)}
|
|
2
|
-
|
|
3
|
-
… truncated …`:u,lineEnding:gi(o)}}function fc({isDirty:e,saveDraft:n}){const a=Fe(b=>b.setMainTabGuard),[i,o]=y.useState(!1),u=y.useRef(null),f=y.useRef(!1),m=y.useCallback(b=>f.current?(f.current=!1,!1):e?(u.current=b,o(!0),!0):!1,[e]);y.useEffect(()=>{if(!e){a(null);return}const b=j=>!m({kind:"tab",tab:j});return a(b),()=>{Fe.getState().mainTabGuard===b&&a(null)}},[e,m,a]);const g=y.useCallback(()=>{const b=u.current;return u.current=null,f.current=!0,o(!1),b?.kind==="tab"&&a(null),b},[a]),w=y.useCallback(()=>g(),[g]),N=y.useCallback(async()=>await n()?g():(f.current=!1,null),[n,g]),x=y.useCallback(b=>{b||o(!0)},[]);return{confirmOpen:i,discardAndTakeIntent:w,keepModalOpen:x,requestNavigation:m,saveAndTakeIntent:N}}function mc(e,n){if(e.state.doc.length!==n.length)return!1;if(n.length===0)return!0;const a=Math.min(128,n.length);if(e.state.sliceDoc(0,a)!==n.slice(0,a))return!1;const i=Math.max(0,n.length-a);return e.state.sliceDoc(i,n.length)===n.slice(i)}function pc({root:e,selectedPath:n,loadedPath:a,fileLoading:i,fileError:o,isImage:u,isPdf:f,isUnsupportedBinary:m,canEdit:g,textViewMode:w,setTextViewMode:N,draftContent:x,confirmDiscardOpen:b,selectFilePath:j}){const C=Fe(A=>A.pendingFileNavigation),v=Fe(A=>A.setPendingFileNavigation),L=Fe(A=>A.pendingFileFocusPath),I=Fe(A=>A.setPendingFileFocusPath),l=y.useRef(null),[B,G]=y.useState(0),D=y.useRef(null),$=y.useRef({key:"",attempts:0}),H=y.useCallback(()=>{G(A=>A+1)},[]);y.useEffect(()=>()=>{D.current!==null&&window.cancelAnimationFrame(D.current)},[]),y.useEffect(()=>{if(!C||!e)return;const A=()=>{D.current===null&&(D.current=window.requestAnimationFrame(()=>{D.current=null,H()}))},T=()=>{v(null),$.current={key:"",attempts:0}},k=oe(C.path);if(!k){T();return}const V=`${k}:${C.line}:${C.column??1}`;if($.current.key!==V&&($.current={key:V,attempts:0}),n!==k){b||j(k);return}if(i||a!==k)return;if(o||u||f||m){T();return}if(!g)return;if(w!=="edit"){N("edit");return}const E=l.current;if(!E||!mc(E,x)){A();return}const R=Math.max(1,Math.min(C.line,E.state.doc.lines)),d=E.state.doc.line(R),O=Math.max(1,C.column||1),S=d.from+Math.min(Math.max(0,d.to-d.from),O-1);if(!(E.state.selection.main.head===S)||$.current.attempts===0){$.current.attempts+=1,E.dispatch({selection:{anchor:S},effects:me.scrollIntoView(S,{y:"center"})}),E.focus(),A();return}window.requestAnimationFrame(()=>{const Y=l.current;Y&&(Y.dispatch({selection:{anchor:S},effects:me.scrollIntoView(S,{y:"center"})}),Y.focus())}),T()},[g,b,x,B,o,i,u,f,m,a,H,C,e,n,j,v,N,w]),y.useEffect(()=>{if(!L||!e)return;const A=oe(L);if(!A){I(null);return}n!==A||i||a!==A||(!o&&!u&&!f&&!m&&g&&w==="edit"&&l.current?.focus(),I(null))},[g,o,i,u,f,m,a,L,e,n,I,w]);const _=oe(C?.path??"");return{editorViewRef:l,notifyEditorViewChanged:H,shouldMaskEditor:!!(C&&_&&n===_&&!i&&!o&&!u&&!f&&!m)}}function hc(e){return!(!e.autoSaveEnabled||!e.isDirty||!e.canWrite||e.isSaving||e.fileLoading||e.isNonEditableBinary||!e.selectedFilePath||e.loadedFilePath!==e.selectedFilePath)}function gc(e){return e.selectedFilePath?e.isDirty?!(e.fileLoading||e.loadedFilePath!==e.selectedFilePath||e.isNonEditableBinary||e.draftContent===""&&e.fileContent!==""&&e.loadedFilePath!==e.selectedFilePath):!0:!1}const xc=1500,vc=2e3;function bc({autoSaveEnabled:e,selectedPath:n,loadedPath:a,fileLoading:i,isDirty:o,draftContent:u,fileContent:f,lineEnding:m,isNonEditableBinary:g,writeFile:w,expectedRevision:N,onSaved:x,captureSaveScope:b,currentSaveScope:j,onConflict:C}){const[v,L]=y.useState(!1),[I,l]=y.useState("idle"),[B,G]=y.useState(null),D=y.useRef(null),$=y.useRef(null),H=y.useRef(C);H.current=C;const _=y.useRef(b);_.current=b;const X=y.useRef(j);X.current=j;const A=y.useCallback(R=>R?Aa(R,X.current?.()??null):!0,[]),T=y.useCallback(()=>{D.current&&(clearTimeout(D.current),D.current=null)},[]),k=y.useCallback(()=>{l("saved"),$.current&&clearTimeout($.current),$.current=setTimeout(()=>{$.current=null,l("idle")},vc)},[]),V=y.useCallback(async R=>{if(!n||!w)return pe.error("Saving not supported"),!1;if(!gc({selectedFilePath:n,loadedFilePath:a,fileLoading:i,isDirty:o,draftContent:u,fileContent:f,isNonEditableBinary:g}))return g?console.warn(`[saveDraft] refusing to save binary file "${n}".`):u===""&&f!==""&&a!==n&&console.warn(`[saveDraft] refusing to save empty draft for "${n}" (${f.length} bytes were expected). The file may have been read during a concurrent write (O_TRUNC race). Try again after content finishes loading if the save was intentional.`),!1;if(!o)return!0;L(!0);const d=_.current?.()??null;try{const O=xi(u,m),S=Oa(N,R?.overwrite),P=await w(n,O,S);return P?.success?A(d)?(G(null),x(n,u,P?.revision,d),!0):!1:(pe.error("Failed to write file"),!1)}catch(O){if(xa(O)){if(!A(d))return!1;const S={path:n,currentRevision:O.currentRevision??null,exists:O.exists};return G(S),H.current?.(S),!1}return pe.error(O instanceof Error?O.message:"Save failed"),!1}finally{L(!1)}},[u,N,f,i,o,g,A,m,a,x,n,w]),E=y.useCallback(async R=>{if(T(),v)return!1;const d=await V(R);return d&&k(),d},[T,v,V,k]);return y.useEffect(()=>{e||(l("idle"),T())},[e,T]),y.useEffect(()=>{if(hc({autoSaveEnabled:e,isDirty:o,canWrite:!!(n&&w),isSaving:v,fileLoading:i,selectedFilePath:n,loadedFilePath:a,isNonEditableBinary:g}))return D.current=setTimeout(()=>{D.current=null,V().then(R=>{R&&k()})},xc),T},[e,T,u,i,o,g,v,a,V,n,k,w]),y.useEffect(()=>{l("idle"),L(!1),G(null)},[n]),y.useEffect(()=>()=>{T(),$.current&&clearTimeout($.current)},[T]),{autoSaveStatus:I,cancelPendingAutosave:T,isSaving:v,saveConflict:B,clearSaveConflict:()=>G(null),saveDraft:V,saveNow:E}}function wc(e,n){return typeof e.revision=="string"&&typeof n.revision=="string"&&e.revision!==n.revision?!0:n.mtimeMs!==void 0&&e.mtimeMs!==void 0&&n.mtimeMs!==e.mtimeMs||n.size!==e.size}function yc({selectedPath:e,loadedPath:n,isDirty:a,readStat:i,onExternalChange:o,pollIntervalMs:u=2e3}){const f=y.useRef(null),m=y.useRef(a);m.current=a;const g=y.useCallback(w=>{f.current=w},[]);return y.useEffect(()=>{if(!e||n!==e)return;let w=!1;const N=window.setInterval(()=>{if(document.hidden)return;const x=f.current,b=x&&x.path===e&&typeof x.revision=="string"?x.revision:null;i(e,{knownRevision:b}).then(j=>{if(w||!j)return;const C=f.current;if(!C||C.path!==e){f.current=j;return}!wc(C,j)||m.current||(f.current=j,o())}).catch(()=>{})},u);return()=>{w=!0,window.clearInterval(N)}},[n,o,u,i,e]),{recordStat:g}}const ca="pichamber:files:md-viewer-mode",la="pichamber:files:html-viewer-mode",ua="pichamber:files:json-viewer-mode",kc=1500,jc=1500;function Fn(e,n,a){try{const i=localStorage.getItem(e);if(i&&n.includes(i))return i}catch{}return a}function En(e,n){try{localStorage.setItem(e,n)}catch{}}function Cc({root:e,selectedPath:n,fileContent:a,draftContent:i,setDraftContent:o,autoSaveEnabled:u,writeFile:f,expectedRevision:m,captureSaveScope:g,currentSaveScope:w,onSaved:N,onConflict:x}){const[b,j]=y.useState("edit"),[C,v]=y.useState("edit"),[L,I]=y.useState("text"),[l,B]=y.useState("edit"),[G,D]=y.useState("edit"),[$,H]=y.useState(0),[_,X]=y.useState(!1),A=y.useRef({}),T=y.useRef({}),k=y.useRef({}),V=y.useRef({}),E=y.useRef(""),R=y.useRef(""),d=y.useRef(null),O=y.useRef(null),S=y.useRef(null),P=y.useRef(m);P.current=m;const Y=y.useRef(g);Y.current=g;const ee=y.useRef(w);ee.current=w;const re=y.useRef(N);re.current=N;const te=y.useRef(x);te.current=x;const K=y.useCallback(()=>{d.current&&(clearTimeout(d.current),d.current=null),S.current!==null&&(cancelAnimationFrame(S.current),S.current=null)},[]),Z=y.useCallback(W=>{E.current=W,R.current=W},[]),Ze=y.useCallback(()=>Z(""),[Z]);y.useEffect(()=>{n&&(j(A.current[n]??"edit"),v(T.current[n]??Fn(ca,["preview","edit"],"edit")),B(k.current[n]??Fn(la,["preview","edit"],"edit")),D(V.current[n]??"edit"),I(Fn(ua,["tree","text"],"text")))},[n]);const Oe=y.useCallback(W=>{n&&(A.current[n]=W),j(W)},[n]),le=y.useCallback(W=>{n&&(T.current[n]=W),v(W),En(ca,W)},[n]),Pe=y.useCallback(W=>{n&&(k.current[n]=W),B(W),En(la,W)},[n]),Le=y.useCallback(W=>{I(W),En(ua,W)},[]),ae=y.useCallback(W=>{if(n&&(V.current[n]=W),K(),W==="edit"){o(E.current||a),D(W);return}E.current=i;const U=n;D("edit"),S.current=requestAnimationFrame(()=>{S.current=requestAnimationFrame(()=>{S.current=null,!(e&&U&&Re.getState().byRoot[e]?.selectedPath!==U)&&(H(se=>se+1),D("preview"))})})},[K,i,a,e,n,o]),ue=y.useCallback(W=>W?Aa(W,ee.current?.()??null):!0,[]),ye=y.useCallback(async(W,U,se)=>{if(!f||U===R.current)return!1;const ge=Y.current?.()??null;if(ge&&ge.path!==W)return!1;try{const de=await f(W,U,Oa(P.current,se?.overwrite));return de?.success?ue(ge)?(Z(U),o(U),re.current?.(W,U,de?.revision,ge),!0):!1:(pe.error("Failed to write file"),!1)}catch(de){return xa(de)?(ue(ge)&&te.current?.({path:W,currentRevision:de.currentRevision??null,exists:de.exists,xml:U}),!1):(pe.error(de instanceof Error?de.message:"Save failed"),!1)}},[ue,Z,o,f]),he=y.useCallback(()=>{X(!0),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>X(!1),jc)},[]),Ie=y.useCallback(async(W,U,se)=>{d.current&&(clearTimeout(d.current),d.current=null);const ge=await ye(W,U,se);return ge&&he(),ge},[ye,he]),vt=y.useCallback(W=>{E.current=W,!(!u||!n||G!=="preview"||!f)&&(d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,ye(n,W).then(U=>{U&&he()})},kc))},[u,G,ye,n,he,f]);y.useEffect(()=>K,[K,G,n]),y.useEffect(()=>()=>{O.current&&clearTimeout(O.current)},[]);const Ee=en(n??"")&&(E.current||i)||a;return{clearDiagramContent:Ze,diagramEditorXml:Ee,diagramSaved:_,drawioRemountNonce:$,drawioViewMode:G,handleDiagramChange:vt,htmlViewMode:l,jsonViewMode:L,mdViewMode:C,recordDiagramContent:Z,saveDiagramNow:Ie,saveDiagramXml:ye,saveDrawioViewMode:ae,saveHtmlViewMode:Pe,saveJsonViewMode:Le,saveMdViewMode:le,saveTextViewMode:Oe,setTextViewMode:j,textViewMode:b}}function Nc(e,n){return e==="mobile"?!0:n==="full"}function Sc(e,n){if(e===n)return!0;if(e.length!==n.length)return!1;for(let a=0;a<e.length;a+=1){const i=e[a],o=n[a];if(i.name!==o.name||i.path!==o.path||i.type!==o.type||i.extension!==o.extension||i.relativePath!==o.relativePath||i.size!==o.size)return!1}return!0}function Rc({files:e,root:n,activeDirectory:a,expandedPaths:i,chrome:o,showGitignored:u,removeExpandedPathsByPrefix:f,enabled:m=!0,visible:g=!0}){const[w,N]=s.useState({}),[x,b]=s.useState({}),j=s.useRef(new Set),C=s.useRef(new Set),v=s.useRef(new Map),L=s.useRef(new Map),I=s.useRef(0),l=s.useRef(!1),[B,G]=s.useState(()=>Vo());s.useEffect(()=>Wo(R=>{G(R.runtimeKey)}),[]),s.useEffect(()=>(l.current=!1,()=>{l.current=!0,L.current=new Map,C.current=new Set,v.current=new Map}),[]);const D=s.useCallback((R,d)=>{const O=[];for(const S of d){if(!S?.name||o==="desktop"&&!u&&vi(S.name))continue;const P=oe(S.path||""),Y=P?bi(P)?P:oe(`${R}/${P}`):oe(`${R}/${S.name}`),ee=S.isDirectory?"directory":"file";O.push({name:S.name,path:Y,type:ee,extension:ee==="file"&&S.name.includes(".")?S.name.split(".").pop()?.toLowerCase():void 0,size:S.size})}return wi(O)},[o,u]),$=`${B}|${n}|g${u?"1":"0"}|${o}`,H=s.useRef($);H.current=$;const _=s.useCallback(async R=>{if(!m)return;const d=oe(R.trim());if(!d||j.current.has(d))return;const O=v.current.get(d);if(O){await O;return}const S=H.current,P=I.current+1;I.current=P,L.current=new Map(L.current).set(d,P),C.current=new Set(C.current).add(d);const Y=()=>!l.current&&H.current===S&&L.current.get(d)===P,ee=(async()=>{try{const re=e.listDirectory?(await e.listDirectory(d)).entries.map(K=>({name:K.name,path:K.path,isDirectory:K.isDirectory,size:K.size})):(await _o(d)).map(K=>({name:K.name,path:K.path,isDirectory:K.isDirectory}));if(!Y())return;j.current=new Set(j.current).add(d),b(K=>{if(!K[d])return K;const Z={...K};return delete Z[d],Z});const te=D(d,re);N(K=>{const Z=K[d];return Z&&Sc(Z,te)?K:{...K,[d]:te}})}catch(re){if(!Y())return;const te=re instanceof Error?re.message:String(re??"");te==="Directory not found"&&n&&d!==n?(f(n,d),b(K=>{if(!K[d])return K;const Z={...K};return delete Z[d],Z})):(console.error("Failed to load files directory:",re),b(K=>({...K,[d]:te})))}finally{L.current.get(d)===P&&(L.current=new Map(L.current),L.current.delete(d))}})();v.current.set(d,ee);try{await ee}finally{v.current.get(d)===ee&&(v.current.delete(d),C.current=new Set(C.current),C.current.delete(d))}},[m,e,D,f,n]),X=s.useCallback(()=>{j.current=new Set,C.current=new Set,v.current=new Map,L.current=new Map,b({}),N(R=>Object.keys(R).length===0?R:{})},[]),A=s.useCallback(async()=>{!m||!n||(X(),await _(n))},[m,_,X,n]),T=s.useCallback(async R=>{if(!m)return;if(!R){await A();return}const d=oe(R);j.current=new Set(j.current),j.current.delete(d),C.current=new Set(C.current),C.current.delete(d),v.current.delete(d),L.current=new Map(L.current),L.current.delete(d),await _(d)},[m,_,A]),k=s.useRef("");s.useEffect(()=>{k.current!==$&&(k.current=$,X())},[X,$]),s.useEffect(()=>{!m||!g||!n||j.current.has(oe(n))||_(n)},[m,_,n,$,g]),s.useEffect(()=>{!m||!g||!a||_(a)},[a,m,_,g]),s.useEffect(()=>{if(!m||!g||!e.listDirectory)return;const R=P=>{const Y=oe(P);return v.current.has(Y)||C.current.has(Y)},d=()=>{if(!(typeof document<"u"&&document.hidden))for(const P of i)R(P)||T(P)},O=()=>{typeof document<"u"&&document.hidden||d()};typeof document<"u"&&document.addEventListener("visibilitychange",O);const S=i.length>0?window.setInterval(d,8e3):null;return()=>{typeof document<"u"&&document.removeEventListener("visibilitychange",O),S!==null&&window.clearInterval(S)}},[m,i,e.listDirectory,T,g]);const V=s.useRef(m&&g);s.useEffect(()=>{const R=m&&g,d=V.current;if(V.current=R,!(!R||d)){if(!e.listDirectory){n&&!j.current.has(oe(n))&&_(n);return}if(i.length===0){n&&!j.current.has(oe(n))&&_(n);return}for(const O of i){const S=oe(O);v.current.has(S)||C.current.has(S)||T(O)}}},[m,i,e.listDirectory,_,T,n,g]);const E=s.useCallback(R=>j.current.has(oe(R)),[]);return{childrenByDir:w,loadErrorsByDir:x,isLoaded:E,loadDirectory:_,refreshDirectory:T,refreshRoot:A}}const Fc=({showEditorTabsRow:e,isMobile:n,showMobilePageContent:a,onBackMobile:i,selectedFile:o,openFiles:u,root:f,alwaysShowActions:m,editorTabsOverflow:g,editorTabsScrollRef:w,onSelectFile:N,onCloseFile:x})=>e?t.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[n&&a&&t.jsx("button",{type:"button",onClick:i,"aria-label":"Back",className:"inline-flex size-7 flex-shrink-0 items-center justify-center mr-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:t.jsx(F,{name:"arrow-left-s",className:"size-5"})}),n?o?t.jsxs(Ln,{children:[t.jsx(In,{asChild:!0,children:t.jsxs("button",{type:"button",className:"inline-flex min-w-0 max-w-full items-center gap-1 text-left typography-ui-label font-medium","aria-label":"Open files",children:[t.jsx(xt,{filePath:o.path,extension:o.extension,className:"size-3.5 flex-shrink-0"}),t.jsx(Ur,{name:o.name}),t.jsx(F,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),t.jsx(Bn,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:u.map(b=>{const j=o?.path===b.path;return t.jsxs(Zt,{onSelect:C=>{if(C.target.closest("[data-close-open-file]")){C.preventDefault();return}j||N(b)},className:J("flex min-w-0 items-center justify-between gap-2 overflow-hidden",j&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[t.jsx(xt,{filePath:b.path,extension:b.extension,className:"size-3.5 flex-shrink-0"}),t.jsx(Ur,{name:b.name})]}),t.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:C=>{C.preventDefault(),C.stopPropagation()},onClick:C=>{C.preventDefault(),C.stopPropagation(),x(b.path)},className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]","aria-label":`Close ${b.name}`,children:t.jsx(F,{name:"close",className:"size-3.5"})})]},b.path)})})]}):t.jsx("div",{className:"typography-ui-label font-medium truncate",children:"Select a file"}):u.length>0?t.jsxs("div",{className:"relative min-w-0 flex-1",children:[g.left&&t.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r from-background to-transparent"}),g.right&&t.jsx("div",{className:"pointer-events-none absolute right-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l from-background to-transparent"}),t.jsx("div",{ref:w,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},"data-no-drawer-swipe":"true",children:u.map(b=>{const j=o?.path===b.path;return t.jsxs("div",{title:St(f,b.path),className:J("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",j?"bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]":"bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]"),children:[t.jsx(xt,{filePath:b.path,extension:b.extension,className:"size-3.5 flex-shrink-0"}),t.jsx("button",{type:"button",onClick:()=>{j||N(b)},className:"max-w-[12rem] truncate text-left",children:b.name}),t.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),x(b.path)},className:J("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!j&&!m&&"opacity-0 group-hover:opacity-100"),"aria-label":`Close ${b.name}`,children:t.jsx(F,{name:"close",className:"size-3.5"})})]},b.path)})})]}):t.jsx("div",{className:"typography-ui-label font-medium truncate",children:"Select a file"})]}):null,Ec=(e,n)=>{if(!n)return null;const a=Number.parseInt(e.trim(),10);return!Number.isFinite(a)||a<1?null:Math.min(a,n.state.doc.lines)},da=(e,n)=>{const a=e.state.doc.lineAt(n.main.head);return{lineNumber:a.number,character:n.main.head-a.from+1,selection:n}},fa=(e,n,a)=>{const i=e.state.doc.line(n),o=Math.max(1,Math.min(a,i.length+1)),u=i.from+o-1;e.dispatch({selection:Oo.cursor(u),effects:me.scrollIntoView(u,{y:"center"})})};function zc({open:e,onOpenChange:n,view:a,variant:i="overlay"}){const[o,u]=s.useState(""),f=s.useRef(null),m=s.useRef(!1),g=s.useRef(null),w=s.useRef(null),N=s.useMemo(()=>Ec(o,a),[o,a]);s.useEffect(()=>{!e||!a||(m.current=!1,f.current=da(a,a.state.selection),u(""))},[e,a]),s.useEffect(()=>{e&&window.requestAnimationFrame(()=>{w.current?.focus(),w.current?.select()})},[e]),s.useEffect(()=>{if(!(!e||!a||!f.current)){if(N===null){const{selection:v}=f.current;a.dispatch({selection:v,effects:me.scrollIntoView(v.main.from,{y:"center"})});return}fa(a,N,f.current.character)}},[N,e,a]);const x=s.useCallback(()=>{if(!a||m.current||!f.current)return;const{selection:v}=f.current;a.dispatch({selection:v,effects:me.scrollIntoView(v.main.from,{y:"center"})})},[a]),b=s.useCallback(v=>{v||x(),n(v)},[n,x]),j=s.useCallback(()=>{!a||N===null||!f.current||(m.current=!0,fa(a,N,f.current.character),n(!1),a.focus())},[N,n,a]);s.useEffect(()=>{if(!e)return;const v=I=>{const l=g.current,B=I.target;!l||!(B instanceof Node)||l.contains(B)||b(!1)},L=I=>{I.key==="Escape"&&(I.preventDefault(),b(!1))};return document.addEventListener("pointerdown",v,!0),document.addEventListener("keydown",L,!0),()=>{document.removeEventListener("pointerdown",v,!0),document.removeEventListener("keydown",L,!0)}},[b,e,i]);const C=s.useMemo(()=>a?N===null?`Current Line: ${(f.current??da(a,a.state.selection)).lineNumber}. Type a line number between 1 and ${a.state.doc.lines} to navigate to.`:`Go to line ${N}`:"Editor unavailable.",[N,a]);return i==="inline"?e?t.jsxs("div",{ref:g,className:"ml-1 flex h-6 items-center gap-1",children:[t.jsx(Et,{ref:w,type:"number",min:1,step:1,inputMode:"numeric",value:o,onChange:v=>u(v.target.value),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),j())},placeholder:"Line",className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),t.jsx(q,{variant:"outline",size:"xs",onClick:j,disabled:!a||N===null,className:"h-6 px-2",children:"Go"})]}):null:t.jsx("div",{ref:g,className:J("absolute left-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",e?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:t.jsxs("div",{className:"min-w-0",children:[t.jsx(Et,{ref:w,type:"number",min:1,step:1,inputMode:"numeric",value:o,onChange:v=>u(v.target.value),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),j())},placeholder:"Line number",className:"h-8 w-full rounded-md border-border/70 bg-background/60 typography-ui-label"}),t.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:C})]})})}const zn=({currentMode:e,onToggle:n})=>{const a=e==="preview",i=a?"Switch to edit mode":"Switch to preview mode",o=a?"Edit":"Preview";return t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx(q,{variant:"ghost",size:"sm",onClick:n,"aria-label":i,className:"h-5 w-5 p-0",children:a?t.jsx(F,{name:"eye",className:"size-4","aria-hidden":"true"}):t.jsx(F,{name:"eye-off",className:"size-4","aria-hidden":"true"})})}),t.jsx(Qe,{sideOffset:8,children:o})]})},Mc=({selectedFile:e,displaySelectedPath:n,layout:a="floating",exitFullscreenOnly:i=!1,canEdit:o,isEditingFile:u,isSaving:f,autoSaveEnabled:m,autoSaveStatus:g,isDirty:w,onSaveDraft:N,onToggleAutoSave:x,openInApps:b,openInCacheStale:j,onOpenInApp:C,onRefreshOpenInApps:v,onToolbarDropdownOpenChange:L,isSelectedImage:I,isSelectedPdf:l,isUnsupportedBinary:B,wrapLines:G,onToggleWrapLines:D,textViewMode:$,onToggleSearch:H,isGoToLineOpen:_,onOpenGoToLineChange:X,editorView:A,canUseShikiFileView:T,isJson:k,isHtml:V,onToggleTextViewMode:E,isMarkdown:R,mdViewMode:d,onToggleMdViewMode:O,isDrawio:S,drawioViewMode:P,onToggleDrawioViewMode:Y,diagramSaved:ee,onSaveDiagram:re,jsonViewMode:te,onToggleJsonViewMode:K,canCopy:Z,copiedContent:Ze,onCopyContent:Oe,canCopyPath:le,copiedPath:Pe,onCopyPath:Le,onDownloadFile:ae,isMobile:ue,mode:ye,isFullscreen:he,onToggleFullscreen:Ie,onExitFullscreen:vt})=>{if(!e)return null;const W=a==="docked"?"pointer-events-auto flex flex-wrap items-center gap-1":"pointer-events-auto flex items-center gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-sm",U=(se,ge)=>t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex",children:ge})}),t.jsx(Qe,{side:"bottom",sideOffset:6,children:se})]});return t.jsxs("div",{className:W,children:[o&&u&&t.jsxs(t.Fragment,{children:[f?t.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[t.jsx(F,{name:"loader-4",className:"size-3.5 animate-spin"}),"Saving..."]}):m&&g==="saved"&&!w?t.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[t.jsx(F,{name:"check",className:"size-3.5"}),"Saved"]}):w?U(m?`Save now (${Ct()}+S) - auto-saves after 1.5s`:`Save now (${Ct()}+S)`,t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>{N()},className:"h-6 gap-1 px-1 text-muted-foreground opacity-80 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:m?`Save now (${Ct()}+S) - auto-saves after 1.5s`:`Save now (${Ct()}+S)`,"aria-label":`Save (${Ct()}+S)`,children:t.jsx(F,{name:"save-3",className:"size-4"})})):null,U(m?"Auto-save on":"Manual save",t.jsx(q,{variant:"ghost",size:"sm",onClick:x,className:J("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",m?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:m?"Auto-save on":"Manual save","aria-label":m?"Auto-save on":"Manual save",children:m?t.jsx(F,{name:"file-check-fill",className:"size-4"}):t.jsx(F,{name:"file-check",className:"size-4"})}))]}),t.jsxs(Ln,{onOpenChange:L,children:[t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex",children:t.jsx(In,{asChild:!0,children:t.jsx(q,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Open in desktop app","aria-label":"Open in desktop app",children:t.jsx(F,{name:"file-transfer",className:"size-4"})})})})}),t.jsx(Qe,{side:"bottom",sideOffset:6,children:"Open in desktop app"})]}),t.jsxs(Bn,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[b.map(se=>t.jsxs(Zt,{className:"flex items-center gap-2",onClick:()=>{C(se)},children:[t.jsx(Yi,{label:se.label,iconDataUrl:se.iconDataUrl}),t.jsx("span",{className:"typography-ui-label text-foreground",children:se.label})]},se.id)),j?t.jsxs(Zt,{className:"flex items-center gap-2",onClick:()=>{v()},children:[t.jsx(F,{name:"refresh",className:"size-4"}),t.jsx("span",{className:"typography-ui-label text-foreground",children:"Refresh Apps"})]}):null]})]}),!I&&!l&&!B&&t.jsxs(t.Fragment,{children:[U(G?"Disable line wrap":"Enable line wrap",t.jsx(q,{variant:"ghost",size:"sm",onClick:D,className:J("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",G?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:G?"Disable line wrap":"Enable line wrap",children:t.jsx(F,{name:"text-wrap",className:"size-4"})})),$==="edit"&&t.jsxs(t.Fragment,{children:[U("Find in file",t.jsx(q,{variant:"ghost",size:"sm",onClick:se=>{H(),se.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Find in file",children:t.jsx(F,{name:"search",className:"size-4"})})),U("Go to line",t.jsx(q,{variant:"ghost",size:"sm",onClick:se=>{X(!_),se.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Go to line",children:t.jsx(F,{name:"menu-fold-2",className:"size-4"})})),t.jsx(zc,{open:_,onOpenChange:X,view:A,variant:"inline"})]})]}),T&&o&&!k&&!V&&t.jsx(zn,{currentMode:$==="view"?"preview":"edit",onToggle:E}),R&&U(d==="preview"?"Switch to edit mode":"Switch to preview mode",t.jsx(q,{variant:"ghost",size:"sm",onClick:O,className:J("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",d==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)] focus-visible:bg-[var(--interactive-selection)] active:bg-[var(--interactive-selection)]":"text-muted-foreground opacity-65 hover:opacity-100"),title:d==="preview"?"Switch to edit mode":"Switch to preview mode","aria-label":d==="preview"?"Switch to edit mode":"Switch to preview mode",children:t.jsx(F,{name:d==="preview"?"eye":"eye-off",className:"size-4"})})),$n(e?.path??"")&&t.jsx(zn,{currentMode:V?"preview":"edit",onToggle:E}),S&&t.jsxs(t.Fragment,{children:[t.jsx(zn,{currentMode:P,onToggle:Y}),P==="preview"&&t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>{re()},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Save diagram",children:ee?t.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):t.jsx(F,{name:"save-3",className:"size-4"})})]}),k&&U(te==="tree"?"Switch to Text View":"Switch to Tree View",t.jsx(q,{variant:"ghost",size:"sm",onClick:K,className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:te==="tree"?"Switch to Text View":"Switch to Tree View",children:te==="tree"?t.jsx(F,{name:"code-sslash",className:"size-4"}):t.jsx(F,{name:"node-tree",className:"size-4"})})),Z&&U("Copy file contents",t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>{Oe()},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Copy file contents","aria-label":"Copy file contents",children:Ze?t.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):t.jsx(F,{name:"clipboard",className:"size-4"})})),le&&U(`Copy file path (${n})`,t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>{Le()},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:`Copy file path (${n})`,"aria-label":`Copy file path (${n})`,children:Pe?t.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):t.jsx(F,{name:"file-copy-2",className:"size-4"})})),ae&&U("Save file",t.jsx(q,{variant:"ghost",size:"sm",onClick:ae,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Save file","aria-label":"Save file",children:t.jsx(F,{name:"download",className:"size-4"})})),i?U("Exit fullscreen",t.jsx(q,{variant:"ghost",size:"sm",onClick:vt,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Exit fullscreen","aria-label":"Exit fullscreen",children:t.jsx(F,{name:"fullscreen-exit",className:"size-4"})})):!ue&&ye==="full"&&U(he?"Exit fullscreen":"Fullscreen",t.jsx(q,{variant:"ghost",size:"sm",onClick:Ie,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:he?"Exit fullscreen":"Fullscreen","aria-label":he?"Exit fullscreen":"Fullscreen",children:he?t.jsx(F,{name:"fullscreen-exit",className:"size-4"}):t.jsx(F,{name:"fullscreen",className:"size-4"})}))]})},Tc=({open:e,onOpenChange:n,isSaving:a,onSaveAndContinue:i,onDiscardAndContinue:o})=>t.jsx(va,{open:e,onOpenChange:n,children:t.jsxs(ba,{showCloseButton:!1,className:"max-w-md",children:[t.jsxs(wa,{children:[t.jsx(ya,{children:"Unsaved changes"}),t.jsx(ka,{children:"Save your edits before continuing?"})]}),t.jsxs(ja,{children:[t.jsx(q,{variant:"outline",onClick:i,disabled:a,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:"Save changes"}),t.jsx(q,{variant:"destructive",onClick:o,children:"Discard"})]})]})}),ma=(e,n)=>e.startsWith(`${n}/`)?e.slice(n.length+1):e,Dc=e=>e.index==="A"||e.working_dir==="?"?"git-added":e.index==="D"?"git-deleted":e.index==="M"||e.working_dir==="M"?"git-modified":null,Ac=({root:e,openPaths:n,gitFiles:a})=>{const i=new Set(n),o=new Map,u=new Map,f={modified:0,added:0};for(const w of a??[]){o.has(w.path)||o.set(w.path,w);const N=+(w.index==="M"||w.working_dir==="M"),x=+(w.index==="A"||w.working_dir==="?");if(N===0&&x===0)continue;f.modified+=N,f.added+=x;const b=w.path.split("/");for(let j=1;j<b.length;j+=1){const C=b.slice(0,j).join("/");if(!C)continue;let v=u.get(C);v||(v={modified:0,added:0},u.set(C,v)),v.modified+=N,v.added+=x}}return{getFileStatus:w=>{if(i.has(w))return"open";if(o.size===0)return null;const N=ma(w,e),x=o.get(N);return x?Dc(x):null},getFolderBadge:w=>{if(!a)return null;const N=ma(w,e);if(!N)return f.modified+f.added>0?{...f}:null;const x=u.get(N);return x?{...x}:null}}},Oc=e=>new Set(e),Pc=({root:e,isMobile:n,searchQuery:a,onSearchQueryChange:i,searchInputRef:o,searching:u,searchResults:f,selectedFile:m,onSelectFile:g,onOpenDialog:w,currentDirectory:N,refreshRoot:x,childrenByDir:b,loadErrorsByDir:j,expandedPaths:C,isBrowserClient:v,alwaysShowActions:L,getFileStatus:I,getFolderBadge:l,fileRowPermissions:B,downloadFile:G,contextMenuPath:D,setContextMenuPath:$,rightClickMenuPath:H,setRightClickMenuPath:_,toggleDirectory:X,handleRevealPath:A,refreshDirectory:T})=>{const k=!!(e&&b[e]),V=e?j[e]:null,E=s.useMemo(()=>Oc(C),[C]);function R(d,O){const S=b[d]??[];return S.map((P,Y)=>{const ee=P.type==="directory",re=ee&&E.has(P.path),te=m?.path===P.path,K=Y===S.length-1;return t.jsxs("li",{className:"relative",children:[O>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),K&&t.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),t.jsx(Zi,{node:P,root:e,isExpanded:re,isActive:te,isMobile:n,isBrowserClient:v,alwaysShowActions:L,status:ee?void 0:I(P.path),badge:ee?l(P.path):void 0,permissions:B,downloadFile:G,contextMenuPath:D,setContextMenuPath:$,rightClickMenuPath:H,setRightClickMenuPath:_,onSelect:g,onToggle:X,onRevealPath:A,onOpenDialog:w}),ee&&re&&t.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[j[P.path]?t.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:j[P.path],children:j[P.path]}),t.jsxs(q,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{T(P.path)},children:[t.jsx(F,{name:"refresh",className:"size-3.5"}),"Refresh"]})]}):null,R(P.path,O+1)]})]},P.path)})}return t.jsxs("section",{className:J("flex min-h-0 flex-col overflow-hidden",n?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[t.jsx("div",{className:J("flex flex-col gap-2 py-2",n?"px-3":"px-2"),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"relative flex-1 min-w-0",children:[t.jsx(F,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),t.jsx(Et,{ref:o,value:a,onChange:d=>i(d.target.value),placeholder:"Search files...",className:"h-8 pl-8 pr-8 typography-meta"}),a.trim().length>0&&t.jsx("button",{type:"button","aria-label":"Clear search",className:"absolute right-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{i(""),o.current?.focus()},children:t.jsx(F,{name:"close",className:"size-4"})})]}),t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex flex-shrink-0",children:t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>w("createFile",{path:N,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:"New File","aria-label":"New File",children:t.jsx(F,{name:"file-add",className:"size-4"})})})}),t.jsx(Qe,{side:"bottom",sideOffset:6,children:"New File"})]}),t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex flex-shrink-0",children:t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>w("createFolder",{path:N,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:"New Folder","aria-label":"New Folder",children:t.jsx(F,{name:"folder-add",className:"size-4"})})})}),t.jsx(Qe,{side:"bottom",sideOffset:6,children:"New Folder"})]}),t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex flex-shrink-0",children:t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>{x()},className:"size-8 p-0 flex-shrink-0",title:"Refresh","aria-label":"Refresh",children:t.jsx(F,{name:"refresh",className:"size-4"})})})}),t.jsx(Qe,{side:"bottom",sideOffset:6,children:"Refresh"})]})]})}),t.jsx(Ca,{outerClassName:"flex-1 min-h-0",className:J("py-2",n?"px-3":"px-2"),children:t.jsx("ul",{className:"flex flex-col",children:u?t.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),"Searching..."]}):f.length>0?f.map(d=>{const O=m?.path===d.path;return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>{g(d)},className:J("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",O?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[t.jsx(Ka,{filePath:d.path,extension:d.extension}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},title:d.path,children:d.relativePath??d.path})]})},d.path)}):V?t.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[t.jsx("span",{className:"text-[var(--status-error)]",children:V}),t.jsxs(q,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{x()},children:[t.jsx(F,{name:"refresh",className:"size-3.5"}),"Refresh"]})]}):k?R(e,0):t.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:"Loading..."})})})]})},Yl=({mode:e="full",chrome:n="desktop",onClose:a,isVisible:i=!0})=>{const{files:o,runtime:u}=Zo(),f=n==="mobile",{currentTheme:m,availableThemes:g,lightThemeId:w,darkThemeId:N}=ei(),{isMobile:x,isTablet:b,screenWidth:j}=ti(),C=Ko(u.platform),v=x||b,L=qo(),I=ni()??"",l=oe(I.trim()),B=Nc(n,e),G=e!=="editor-only",D=e==="editor-only"&&!x,$=ri(I),[H,_]=s.useState(""),X=s.useRef(null),[A,T]=s.useState(!1),[k,V]=s.useState(l),[E,R]=s.useState(!1),[d,O]=s.useState(!0),[S,P]=s.useState(!1),[Y,ee]=s.useState(!1),[re,te]=s.useState(!1),K=s.useRef(null);s.useEffect(()=>{f&&(V(l),_(""),T(!1))},[f,l]);const Z=s.useRef(0),Ze=s.useCallback(r=>{Z.current=Math.max(0,Z.current+(r?1:-1))},[]),Oe=s.useCallback(r=>r instanceof Element?r.closest('[data-slot="dropdown-menu-content"], [data-slot="dropdown-menu-item"]')!==null:!1,[]);s.useEffect(()=>{if(!re)return;const r=h=>{Z.current>0||Oe(h.target)||K.current&&!K.current.contains(h.target)&&te(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[Oe,re]);const le=s.useMemo(()=>g.find(r=>r.metadata.id===w)??zr(!1),[g,w]),Pe=s.useMemo(()=>g.find(r=>r.metadata.id===N)??zr(!0),[g,N]);s.useEffect(()=>{Lr(le),Lr(Pe)},[le,Pe]);const Le=s.useMemo(()=>[],[]),ae=Re(r=>l?r.byRoot[l]?.openPaths??Le:Le),ue=Re(r=>l?r.byRoot[l]?.selectedPath??null:null),ye=Re(r=>l?r.byRoot[l]?.expandedPaths??Le:Le),he=Re(r=>r.removeOpenPath),Ie=Re(r=>r.removeOpenPathsByPrefix),vt=Re(r=>r.removeExpandedPathsByPrefix),Ee=Re(r=>r.setSelectedPath),W=Re(r=>r.toggleExpandedPath),U=Re(r=>r.expandPaths),{childrenByDir:se,loadErrorsByDir:ge,isLoaded:de,loadDirectory:ot,refreshDirectory:zt,refreshRoot:qa}=Rc({files:o,root:l,activeDirectory:f?k:void 0,expandedPaths:ye,chrome:n,showGitignored:L,removeExpandedPathsByPrefix:vt,enabled:B,visible:i}),qe=s.useCallback(r=>{const h=oe(r),z=h.split("/"),M=z[z.length-1]||h,ne=M.includes(".")?M.split(".").pop()?.toLowerCase():void 0;return{name:M,path:h,type:"file",extension:ne}},[]),Mt=s.useMemo(()=>ae.map(qe),[ae,qe]),rn=s.useMemo(()=>{if(ue){const r=Yt(ue);if(ae.some(h=>Yt(h)===r))return ue}return ae[0]??null},[ae,ue]),p=s.useMemo(()=>rn?qe(rn):null,[rn,qe]),Ve=p?.path??"";s.useEffect(()=>{if(!l||!ue)return;const r=Yt(ue);ae.some(z=>Yt(z)===r)||Ee(l,ae[0]??null)},[ae,l,ue,Ee]);const Tt=!!(l&&Ve&&!Cn(Ve,l)),Vn=Tt?Ar(Ve):void 0,ce=s.useMemo(()=>({allowOutsideWorkspace:e==="editor-only"&&Tt,outsideFileGrant:Vn,directory:l||void 0}),[e,Tt,Vn,l]),an=s.useRef(null),[Ga,Ha]=s.useState({left:!1,right:!1}),Wn=s.useCallback(()=>{const r=an.current;r&&Ha({left:r.scrollLeft>2,right:r.scrollLeft+r.clientWidth<r.scrollWidth-2})},[]),_n=s.useRef(Wn);_n.current=Wn,s.useEffect(()=>{const r=an.current;if(!r)return;const h=()=>_n.current();h(),r.addEventListener("scroll",h,{passive:!0});const z=new ResizeObserver(h);return z.observe(r),()=>{r.removeEventListener("scroll",h),z.disconnect()}},[Mt.length]);const[ke,Be]=s.useState(""),[sn,it]=s.useState(!1),[Kn,xe]=s.useState(null),[Ua,Ge]=s.useState(""),ve=s.useRef(""),[et,je]=s.useState(null),[ct,Ce]=s.useState(void 0),[qn,Ne]=s.useState(null),be=Re(r=>r.activeRuntimeKey),[fe,$e]=s.useState(null),[on,Gn]=s.useState(!1),[Ja,ze]=s.useState(!1),[lt,Se]=s.useState(""),[Xa,Ya]=s.useState(`
|
|
4
|
-
`),Hn=s.useRef(null),Me=s.useRef(0),ut=s.useRef(null),[Un,cn]=s.useState(!1),Dt=Fe(r=>r.autoSaveEnabled),Qa=Fe(r=>r.setAutoSaveEnabled),Za=s.useRef(null),[es,ts]=s.useState(null),[ns,rs]=s.useState(null),{value:as,show:ss}=Or(!1,1200),{value:os,show:is}=Or(!1,1200),[cs,ls]=s.useState(!1),bt=s.useCallback(()=>{l&&Ee(l,null),Be(""),xe(null),Ge(""),je(null),Ce(void 0),Ne(null),$e(null),ze(!1),x&&T(!1)},[x,l,Ee]),{operation:us,target:ds,inputValue:fs,setInputValue:ms,submitting:ps,inputRef:hs,open:gs,close:xs,submit:vs,capabilities:{canCreateFile:Jn,canCreateFolder:Xn,canRename:Yn,canDelete:Qn}}=yi({files:o,root:l,selectedPath:p?.path??"",refreshDirectory:zt,removeOpenPathsByPrefix:Ie,clearSelectedPath:bt}),Zn=!!o.revealPath,bs=Xt(r=>r.availableApps),ws=Xt(r=>r.isCacheStale),er=Xt(r=>r.initialize),ys=Xt(r=>r.loadInstalledApps);s.useEffect(()=>{er()},[er]);const ks=s.useCallback(r=>{o.revealPath&&o.revealPath(r).catch(()=>{pe.error("Failed to reveal path")})},[o]),js=s.useCallback(async r=>{if(!p?.path||await Go(p.path,r.id,r.appName)||await Mr(p.path,r.appName))return;const M=ki(p.path)||l;M&&await Mr(M,r.appName)||pe.error(`Failed to open in ${r.appName}`)},[l,p?.path]),Cs=Fe(r=>r.fileEditorKeymap),tr=Fe(r=>r.expandedEditorToolbar);s.useEffect(()=>{Se("")},[p?.path]);const nr=s.useRef("");s.useEffect(()=>{!l||nr.current===l||(nr.current=l,Be(""),xe(null),Ge(""),je(null),Ce(void 0),Ne(null),$e(null),ze(!1),T(!1))},[l]);const rr=s.useRef(be);s.useEffect(()=>{rr.current!==be&&(rr.current=be,Me.current+=1,ut.current=null,Be(""),Se(""),xe(null),it(!1),Ge(""),je(null),Ce(void 0),Ne(null),$e(null),ze(!1),cn(!1))},[be]);const Ns=f?k:I,{results:ar,searching:sr}=ji({directory:Ns,query:H,chrome:n,showGitignored:L}),At=s.useCallback(async(r,h)=>{if(o.readFile){const Ae=await o.readFile(r,{...h??{},directory:l||void 0});return{content:Ae.content??"",revision:Ae.revision,exists:Ae.exists}}const z=new URLSearchParams({path:r});h?.allowOutsideWorkspace&&z.set("allowOutsideWorkspace","true"),h?.outsideFileGrant&&z.set("outsideFileGrant",h.outsideFileGrant),h?.optional&&z.set("optional","true"),l&&z.set("directory",l);const M=await Tr(`/api/fs/read?${z.toString()}`,{cache:h?.optional?"no-store":"default"});if(!M.ok){const Ae=await M.json().catch(()=>({error:M.statusText}));throw new Error(Ae.error||"Failed to read file")}const ne=await M.text(),Q=M.headers?.get?.("x-pichamber-file-revision"),De=M.headers?.get?.("x-pichamber-file-exists")!=="false";return{content:ne,revision:typeof Q=="string"&&Q.length>0?Q:De?void 0:null,exists:De}},[o,l]),dt=s.useCallback(async(r,h)=>{if(o.statFile){const z=await o.statFile(r,{...h??{},directory:l||void 0});return{path:z.path,size:z.size,mtimeMs:z.mtimeMs,revision:z.revision}}return null},[o,l]);s.useEffect(()=>{if(!l||!o.statFile||ae.length===0)return;let r=!1;const h=[...ae];return Promise.all(h.map(async z=>{try{const M=await o.statFile?.(z,{directory:l||void 0});!r&&M&&!M.isFile&&Ie(l,z)}catch(M){!r&&Br(M)&&Ie(l,z)}})),()=>{r=!0}},[o,ae,Ie,l]);const ln=s.useMemo(()=>ke.length>Rt?`${ke.slice(0,Rt)}
|
|
5
|
-
|
|
6
|
-
… truncated …`:ke,[ke]),Ot=lt!==ln,Ss=s.useCallback((r,h)=>dt(r,{...ce,...h}),[dt,ce]),Rs=s.useCallback(()=>{je(null),Ce(void 0),Ne(null)},[]),{recordStat:tt}=yc({selectedPath:p?.path??null,loadedPath:et,isDirty:Ot,readStat:Ss,onExternalChange:Rs}),or=s.useRef(null),ir=s.useCallback((r,h,z,M)=>{Be(h);const ne=M?.generation??Me.current;if(typeof z<"u"&&(Ce(z),Ne({runtimeKey:M?.runtimeKey??be,root:M?.root??l,path:r,generation:ne})),l&&Cn(r,l)){const Q=St(l,r);Q&&ai.requestGitRefresh({directory:l,paths:[Q]})}en(r)&&or.current?.(h),dt(r).then(Q=>{Q&&Me.current===ne&&tt(Q)}).catch(()=>{})},[be,dt,tt,l]),un=s.useCallback(()=>p?.path?{runtimeKey:be,root:l,path:p.path,generation:Me.current}:null,[be,l,p?.path]),cr=un,lr=s.useCallback(async(r,h=null)=>{const z=Me.current,M=r.path;let ne=null,Q=r.currentRevision,_e=r.exists;try{if(_e){const De=await At(M,ce);ne=De.content,typeof De.revision=="string"&&(Q=De.revision),_e=De.exists!==!1}}catch{}Me.current===z&&($e({path:M,displayPath:St(l,M)||M,exists:_e,currentRevision:Q,currentContent:ne,diagramXml:h}),ze(!1))},[At,l,ce]),ur=s.useMemo(()=>{if(!p?.path||et!==p.path)return;const r=qn;if(r){if(ci({...r},{runtimeKey:be,root:l,path:p.path,generation:Me.current}))return typeof ct=="string"||ct===null?"__stale__":void 0;if(typeof ct=="string"||ct===null)return ct}},[be,et,ct,qn,l,p?.path]),{clearDiagramContent:dr,diagramEditorXml:Fs,diagramSaved:Es,drawioRemountNonce:zs,drawioViewMode:dn,handleDiagramChange:Ms,htmlViewMode:Pt,jsonViewMode:Lt,mdViewMode:It,recordDiagramContent:fn,saveDiagramNow:mn,saveDrawioViewMode:Ts,saveJsonViewMode:Ds,saveMdViewMode:fr,saveTextViewMode:As,setTextViewMode:pn,textViewMode:nt}=Cc({root:l,selectedPath:p?.path??null,fileContent:ke,draftContent:lt,setDraftContent:Se,autoSaveEnabled:Dt,writeFile:o.writeFile,expectedRevision:ur,captureSaveScope:un,currentSaveScope:cr,onSaved:ir,onConflict:r=>{lr(r,r.xml)}});or.current=fn;const He=s.useCallback(()=>It,[It]),{autoSaveStatus:Os,isSaving:hn,clearSaveConflict:rt,saveDraft:mr,saveNow:Bt}=bc({autoSaveEnabled:Dt,selectedPath:p?.path??null,loadedPath:et,fileLoading:sn,isDirty:Ot,draftContent:lt,fileContent:ke,lineEnding:Xa,isNonEditableBinary:!!(p?.path&&(Tn(p.path)||Un)),writeFile:o.writeFile,expectedRevision:ur,onSaved:ir,captureSaveScope:un,currentSaveScope:cr,onConflict:r=>{lr(r)}}),{confirmOpen:pr,discardAndTakeIntent:hr,keepModalOpen:Ps,requestNavigation:$t,saveAndTakeIntent:gr}=fc({isDirty:Ot,saveDraft:mr});s.useEffect(()=>{const r=h=>{Ho(h)&&(h.key.toLowerCase()==="s"?(h.preventDefault(),Bt()):h.key.toLowerCase()==="f"&&(h.preventDefault(),ee(!0)))};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[Bt]);const xr=s.useCallback(async r=>{const h=Me.current+1;Me.current=h;const z=be,M=l,ne=()=>{if(!l||z!==be||M!==l)return!1;const ie=Re.getState().byRoot[l],Je=ie?.selectedPath??ie?.openPaths[0]??null;return Me.current===h&&Je===r.path};xe(null),Ge(""),je(null),Ce(void 0),Ne(null),$e(null),ze(!1),rt(),cn(!1),x&&T(!0);const Q=Ar(r.path),_e={allowOutsideWorkspace:e==="editor-only"&&!!l&&!Cn(r.path,l),outsideFileGrant:Q};let De=!1;it(!0);let Ae;await dc(r.path,u.isDesktop,ie=>At(ie,_e).then(Je=>(Ae=Je.revision,Je.content))).then(ie=>{if(ne()){if(ie.kind!=="text"){if(Be(""),Se(""),ie.kind==="desktop-image"){De=!0;return}ie.kind==="binary"&&cn(ie.detectedFromContent),je(r.path);return}Ya(ie.lineEnding),Be(ie.content),fn(ie.content),Se(ie.draft),je(r.path),Ce(Ae),Ne({runtimeKey:z,root:M,path:r.path,generation:h}),dt(r.path,_e).then(Je=>{Je&&ne()&&tt(Je)}).catch(()=>{})}}).catch(ie=>{if(ne()){if(Ci(ie)){if(it(!1),l&&Ee(l,null),xe(null),Be(""),Se(""),je(null),Ce(void 0),Ne(null),tt(null),H.trim().length>0&&_(""),x&&T(!1),l){const yn=[...$r(r.path,l),r.path];yn.length>0&&U(l,yn);for(const Fr of yn)de(Fr)||ot(Fr)}return}if(Br(ie)){l&&Ie(l,r.path),Be(""),Se(""),xe(null),Ce(void 0),Ne(null),tt(null),x&&T(!1);return}Be(""),Se(""),xe(ie instanceof Error?ie.message:"Failed to read file"),Ce(void 0),Ne(null),tt(null)}}).finally(()=>{ne()&&!De&&it(!1)})},[be,rt,U,de,x,ot,e,At,dt,fn,tt,Ie,l,u.isDesktop,H,Ee]),Vt=s.useCallback(async(r,h)=>{if(!l||!B)return;const z=$r(r,l),M=h?[...z,r]:z;M.length>0&&U(l,M);const ne=M.map(Q=>{if(!de(Q))return ot(Q)}).filter(Boolean);await Promise.all(ne)},[U,de,ot,B,l]),vr=s.useCallback((r,h)=>{const z=h.findIndex(M=>M.path===r);return z===-1||h.length<=1?null:h[z+1]??h[z-1]??null},[]),We=s.useCallback(async r=>{$t({kind:"select",file:r})||(l&&(Ee(l,r.path),Vt(r.path,!1)),xe(null),Ge(""),Be(""),dr(),Se(""),je(null),Ce(void 0),Ne(null),$e(null),ze(!1),rt(),x&&T(!0))},[dr,rt,Vt,x,$t,l,Ee]),Ls=s.useCallback(r=>{We(qe(r))},[We,qe]),Is=s.useCallback(r=>{const h=oe(r);h&&(_(""),V(h),T(!1))},[]),Bs=s.useCallback(r=>{const h=oe(r);h&&(T(!0),We(qe(h)))},[We,qe]),$s=s.useCallback(async()=>{if(!(!k||E)){R(!0);try{await zt(k)}finally{R(!1)}}},[k,E,zt]),Vs=s.useCallback(()=>{const r=fe;if(r){if(!r.exists){l&&he(l,r.path),bt(),$e(null),ze(!1),rt();return}Se(""),je(null),Ce(void 0),Ne(null),$e(null),ze(!1),rt()}},[rt,bt,he,l,fe]),Ws=s.useCallback(async()=>{if(!(!fe||on)){Gn(!0);try{(fe.diagramXml!==null?await mn(fe.path,fe.diagramXml,{overwrite:!0}):await Bt({overwrite:!0}))&&($e(null),ze(!1))}finally{Gn(!1)}}},[on,fe,mn,Bt]),_s=s.useCallback(()=>{$e(null),ze(!1)},[]);s.useEffect(()=>{!p?.path||!B||!i||Vt(p.path,!1)},[Vt,i,B,p?.path]),s.useEffect(()=>{if(!p){Me.current+=1,ut.current=null,it(!1);return}if(et===p.path||ut.current===p.path)return;const r=p.path;ut.current=r,xr(p).finally(()=>{ut.current===r&&(ut.current=null)})},[xr,et,p]);const ft=s.useCallback(async r=>{if(r.kind==="select"){await We(r.file);return}if(r.kind==="tab"){Fe.getState().setActiveMainTab(r.tab);return}l&&he(l,r.path),p?.path===r.path&&(r.nextFile?await We(r.nextFile):bt())},[bt,We,he,l,p?.path]),Ks=s.useCallback(()=>{const r=hr();Se(ln),r&&ft(r)},[ft,hr,ln]),qs=s.useCallback(async()=>{const r=await gr();r&&await ft(r)},[ft,gr]),Gs=s.useCallback(r=>{const h=p?.path===r,z={kind:"close",path:r,nextFile:vr(r,Mt)};h&&$t(z)||ft(z)},[ft,vr,Mt,$t,p?.path]),Wt=s.useMemo(()=>Ac({root:l,openPaths:ae,gitFiles:$?.files}),[l,ae,$]),Hs=s.useCallback(r=>Wt.getFileStatus(r),[Wt]),Us=s.useCallback(r=>Wt.getFolderBadge(r),[Wt]),Js=s.useCallback(async r=>{const h=oe(r);!l||!B||(W(l,h),de(h)||await ot(h))},[de,ot,B,l,W]),Xs=s.useMemo(()=>({canRename:Yn,canCreateFile:Jn,canCreateFolder:Xn,canDelete:Qn,canReveal:Zn}),[Yn,Jn,Xn,Qn,Zn]),Te=!!(p?.path&&Sa(p.path)),mt=!!(p?.path&&Ra(p.path)),at=!!(p?.path&&Fa(p.path)),gn=!!(p?.path&&(Tn(p.path)||Un)),_t=gn&&!Te&&!at,pt=s.useMemo(()=>St(l,Ve),[Ve,l]),Ys=!!(p&&(!Te||mt)&&!at&&!_t&&ke.length>0),Qs=!!(p&&pt.length>0),wt=!!(p&&!Tt&&!gn&&!Te&&o.writeFile&&ke.length<=Rt),yt=!!(p?.path&&Ba(p.path)),xn=!!(p?.path&&Ia(p.path)),kt=!!(p?.path&&$n(p.path)),br=!!(p?.path&&en(p.path)),Zs=!!(p&&!gn&&!Te),{editorViewRef:we,notifyEditorViewChanged:Kt,shouldMaskEditor:eo}=pc({root:l,selectedPath:Ve||null,loadedPath:et,fileLoading:sn,fileError:Kn,isImage:Te,isPdf:at,isUnsupportedBinary:_t,canEdit:wt,textViewMode:nt,setTextViewMode:pn,draftContent:lt,confirmDiscardOpen:pr,selectFilePath:Ls}),wr=Zs&&!yt&&!br&&!(kt&&Pt==="preview"),to=yt&&It==="edit"||kt&&Pt==="edit"||xn&&Lt==="text"||!yt&&!kt&&!xn&&nt==="edit",qt=s.useMemo(()=>Ve?Ai(Ve):null,[Ve]),[yr,vn]=s.useState(null);s.useEffect(()=>{let r=!1;const h=p?.path;if(!h||qt){vn(null);return}return vn(null),Oi(h).then(z=>{r||vn(z)}),()=>{r=!0}},[p?.path,qt]),s.useEffect(()=>{!wt&&nt==="edit"&&pn("view")},[wt,pn,nt]);const Ue=s.useCallback(r=>{if(!x||!r||!r.hasFocus||typeof window>"u")return;const h=window.visualViewport;if(!h)return;const z=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,z-(h.offsetTop+h.height))<=0)return;const ne=r.state.selection.main.head,Q=r.coordsAtPos(ne);if(!Q)return;const _e=Math.round(h.offsetTop+h.height),Ae=Q.bottom+20-_e;Ae<=0||(r.scrollDOM.scrollTop+=Ae)},[x]);s.useEffect(()=>{if(!x||typeof window>"u")return;const r=()=>{window.requestAnimationFrame(()=>{Ue(we.current)})},h=window.visualViewport;return h?.addEventListener("resize",r),h?.addEventListener("scroll",r,{passive:!0}),document.addEventListener("selectionchange",r),()=>{h?.removeEventListener("resize",r),h?.removeEventListener("scroll",r),document.removeEventListener("selectionchange",r)}},[we,x,Ue]);const Gt=Fe(r=>r.editorFontSize),no=s.useMemo(()=>{if(!p?.path)return[Kr(m,{fontSize:Gt})];const r=Na(p.path),h=[Kr(m,r?{syntaxColors:!1,fontSize:Gt}:{fontSize:Gt})],z=qt??yr;return z&&h.push(z),r&&h.push(Ki({language:r,themeName:m.metadata.id,theme:oi(m)})),d&&h.push(me.lineWrapping),x&&h.push(me.updateListener.of(M=>{M.view.hasFocus&&(M.selectionSet||M.focusChanged||M.viewportChanged||M.geometryChanged)&&window.requestAnimationFrame(()=>{Ue(M.view)})})),h},[m,p?.path,qt,yr,d,x,Ue,Gt]),ro=s.useMemo(()=>({light:le.metadata.id,dark:Pe.metadata.id}),[le.metadata.id,Pe.metadata.id]),Ht=p?.path&&Te&&!u.isDesktop&&!mt?`${p.path}|${ce.allowOutsideWorkspace?"outside":"workspace"}|${ce.outsideFileGrant??""}`:"",Ut=p?.path&&at?`${p.path}|${ce.allowOutsideWorkspace?"outside":"workspace"}|${ce.outsideFileGrant??""}`:"",jt=p?.path&&kt&&Pt==="preview"?p.path:"",bn="Failed to read file",{readyKey:kr,nonce:ao}=Nn(Ht,xe,bn),{readyKey:jr,nonce:so}=Nn(jt,xe,bn),{readyKey:Cr,nonce:oo}=Nn(Ut,xe,bn),io=!!(Ht&&kr!==Ht),co=!!(jt&&jr!==jt),lo=!!(Ut&&Cr!==Ut),uo=p?.path&&Te?u.isDesktop?mt?`data:${Pr(p.path)};utf8,${encodeURIComponent(ke)}`:Ua:mt?`data:${Pr(p.path)};utf8,${encodeURIComponent(ke)}`:kr===Ht?jn().authenticatedAsset("/api/fs/raw",{path:p.path,allowOutsideWorkspace:ce.allowOutsideWorkspace?"true":void 0,outsideFileGrant:ce.outsideFileGrant,directory:l||void 0}):"":"",fo=p?.path&&at&&Cr===Ut?jn().authenticatedAsset("/api/fs/raw",{path:p.path,allowOutsideWorkspace:ce.allowOutsideWorkspace?"true":void 0,outsideFileGrant:ce.outsideFileGrant,directory:l||void 0}):"",mo=jt&&jr===jt&&p?.path?(()=>{const r=p.path.split("/").map(h=>encodeURIComponent(h)).join("/");return jn().authenticatedAsset(`/api/fs/serve${r.startsWith("/")?r:`/${r}`}`)})():void 0;s.useEffect(()=>{let r=!1;return(async()=>{if(!u.isDesktop||!p?.path||!Te||mt){ve.current&&(URL.revokeObjectURL(ve.current),ve.current=""),Ge("");return}xe(null),ve.current&&(URL.revokeObjectURL(ve.current),ve.current=""),await(o.readFileBinary?o.readFileBinary(p.path,ce).then(M=>M.dataUrl):(async()=>{const M=await Tr("/api/fs/raw",{query:{path:p.path,allowOutsideWorkspace:ce.allowOutsideWorkspace?"true":void 0,outsideFileGrant:ce.outsideFileGrant,directory:l||void 0}});if(!M.ok)throw new Error("Failed to read file");const ne=await M.blob(),Q=URL.createObjectURL(ne);return r?(URL.revokeObjectURL(Q),""):(ve.current=Q,Q)})()).then(M=>{r||(Ge(M),je(p.path))}).catch(M=>{ve.current&&(URL.revokeObjectURL(ve.current),ve.current=""),r||(Ge(""),xe(M instanceof Error?M.message:"Failed to read file"),je(null))}).finally(()=>{r||it(!1)})})(),()=>{r=!0}},[o,Te,mt,l,u.isDesktop,p?.path,ce]),s.useEffect(()=>()=>{ve.current&&(URL.revokeObjectURL(ve.current),ve.current="")},[]);const Nr=s.useCallback(()=>{const r=o.downloadFile,h=p?.path;!r||!h||r(h).catch(z=>{console.error("Download failed:",z),pe.error("Operation failed")})},[o.downloadFile,p?.path]),wn=({exitFullscreenOnly:r=!1,layout:h="floating"}={})=>t.jsx(Mc,{selectedFile:p,displaySelectedPath:pt,layout:h,exitFullscreenOnly:r,canEdit:wt,isEditingFile:to,isSaving:hn,autoSaveEnabled:Dt,autoSaveStatus:Os,isDirty:Ot,onSaveDraft:mr,onToggleAutoSave:()=>Qa(!Dt),openInApps:bs,openInCacheStale:ws,onOpenInApp:js,onRefreshOpenInApps:()=>ys(!0),onToolbarDropdownOpenChange:Ze,isSelectedImage:Te,isSelectedPdf:at,isUnsupportedBinary:_t,wrapLines:d,onToggleWrapLines:()=>O(!d),textViewMode:nt,onToggleSearch:()=>ee(!Y),isGoToLineOpen:cs,onOpenGoToLineChange:ls,editorView:we.current,canUseShikiFileView:wr,isJson:xn,isHtml:kt,onToggleTextViewMode:()=>{As(nt==="view"?"edit":"view")},isMarkdown:yt,mdViewMode:He(),onToggleMdViewMode:()=>fr(He()==="preview"?"edit":"preview"),isDrawio:br,drawioViewMode:dn,onToggleDrawioViewMode:()=>Ts(dn==="preview"?"edit":"preview"),diagramSaved:Es,onSaveDiagram:async()=>{const z=Hn.current?.getXml();p?.path&&z&&await mn(p.path,z)},jsonViewMode:Lt,onToggleJsonViewMode:()=>Ds(Lt==="tree"?"text":"tree"),canCopy:Ys,copiedContent:as,onCopyContent:async()=>{(await Qt(ke)).ok?ss(!0):pe.error("Copy failed")},canCopyPath:Qs,copiedPath:os,onCopyPath:async()=>{(await Qt(pt)).ok?is(!0):pe.error("Copy failed")},onDownloadFile:o.downloadFile&&p?Nr:void 0,isMobile:x,mode:e,isFullscreen:S,onToggleFullscreen:()=>P(!S),onExitFullscreen:()=>P(!1)}),po=s.useCallback(r=>{we.current=r,Kt(),window.requestAnimationFrame(()=>{Ue(r)})},[we,Kt,Ue]),ho=s.useCallback(()=>{we.current&&(we.current=null),Kt()},[we,Kt]),go=s.useCallback(r=>{we.current=r,window.requestAnimationFrame(()=>{Ue(r)})},[we,Ue]),xo=s.useCallback(()=>{we.current&&(we.current=null)},[we]),Sr={selectedFile:p,loading:sn||io||lo,suppressLoadingIndicator:D,fileError:Kn,isSelectedImage:Te,imageSrc:uo,imagePreviewNonce:ao,isSelectedPdf:at,pdfSrc:fo,pdfPreviewNonce:oo,isUnsupportedBinary:_t,onDownload:o.downloadFile&&p?Nr:void 0,drawioViewMode:dn,drawioRemountNonce:zs,diagramEditorRef:Hn,diagramEditorXml:Fs,onDiagramChange:Ms,jsonViewMode:Lt,markdownViewMode:It,htmlViewMode:Pt,htmlLoading:co,htmlPreviewNonce:so,htmlPreviewSrc:mo,fileContent:ke,canUseShikiFileView:wr,textViewMode:nt,draftContent:lt,onDraftChange:Se,canEdit:wt,vimMode:Cs==="vim",editorExtensions:no,shouldMaskEditorForPendingNavigation:eo,pierreTheme:ro,shikiThemeType:m.metadata.variant==="dark"?"dark":"light",wrapLines:d},Jt=t.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[t.jsx(Tc,{open:pr,onOpenChange:Ps,isSaving:hn,onSaveAndContinue:()=>{qs()},onDiscardAndContinue:Ks}),t.jsx(li,{open:!!fe,conflict:fe?{path:fe.path,displayPath:fe.displayPath,exists:fe.exists,currentRevision:fe.currentRevision,currentContent:fe.currentContent,dirtyContent:fe.diagramXml??lt}:null,isResolving:on||hn,showCompare:Ja,onToggleCompare:()=>ze(r=>!r),onReload:Vs,onOverwrite:()=>{Ws()},onClose:_s}),t.jsxs("div",{className:J("flex flex-col flex-shrink-0",G&&"border-b border-border/40"),children:[t.jsx(Fc,{showEditorTabsRow:G,isMobile:x,showMobilePageContent:A,onBackMobile:()=>T(!1),selectedFile:p,openFiles:Mt,root:l,alwaysShowActions:v,editorTabsOverflow:Ga,editorTabsScrollRef:an,onSelectFile:We,onCloseFile:Gs}),(tr||x)&&p?t.jsxs("div",{className:"flex min-w-0 items-center gap-3 border-t border-border/40 bg-[var(--surface-subtle)] px-3 py-1",children:[pt&&!x?t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:pt,children:pt}):null,t.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:wn({layout:"docked"})})]}):null]}),t.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[p&&!Y&&!(tr||x)&&t.jsx("div",{ref:K,className:"absolute right-3 top-3 z-30",onMouseLeave:()=>{Z.current>0||te(!1)},children:re?wn():t.jsxs("div",{className:"flex items-center gap-1",children:[yt?t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex",children:t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>fr(He()==="preview"?"edit":"preview"),className:J("size-8 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-0 shadow-sm transition-colors",He()==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)]":"text-muted-foreground hover:text-foreground"),"aria-label":He()==="preview"?"Switch to edit mode":"Switch to preview mode",title:He()==="preview"?"Switch to edit mode":"Switch to preview mode",children:t.jsx(F,{name:He()==="preview"?"eye":"eye-off",className:"size-4"})})})}),t.jsx(Qe,{side:"bottom",sideOffset:6,children:He()==="preview"?"Switch to edit mode":"Switch to preview mode"})]}):null,t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex",onMouseEnter:()=>te(!0),children:t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>te(!0),className:"size-8 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-0 text-muted-foreground shadow-sm hover:text-foreground","aria-label":"Show editor controls",title:"Editor controls",children:t.jsx(F,{name:"more-2-fill",className:"size-4"})})})}),t.jsx(Qe,{side:"bottom",sideOffset:6,children:"Editor controls"})]})]})}),t.jsx(ia,{variant:"embedded",...Sr,enableRichPreviews:!0,editorWrapperRef:Za,onEditorViewReady:po,onEditorViewDestroy:ho,enableSearch:!0,searchOpen:Y,onSearchOpenChange:ee})]})]}),Rr=t.jsx(Pc,{root:l,isMobile:x,searchQuery:H,onSearchQueryChange:_,searchInputRef:X,searching:sr,searchResults:ar,selectedFile:p,onSelectFile:We,onOpenDialog:gs,currentDirectory:I,refreshRoot:qa,childrenByDir:se,loadErrorsByDir:ge,expandedPaths:ye,isBrowserClient:C,alwaysShowActions:v,getFileStatus:Hs,getFolderBadge:Us,fileRowPermissions:Xs,downloadFile:o.downloadFile,contextMenuPath:es,setContextMenuPath:ts,rightClickMenuPath:ns,setRightClickMenuPath:rs,toggleDirectory:Js,handleRevealPath:ks,refreshDirectory:zt}),vo=e==="full"&&S&&p&&t.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:t.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[t.jsx("div",{className:"absolute right-4 top-4 z-30",children:wn({exitFullscreenOnly:!0})}),t.jsx(ia,{variant:"fullscreen",...Sr,enableRichPreviews:!1,onEditorViewReady:go,onEditorViewDestroy:xo})]})});return f?t.jsx(Ui,{root:l,directory:k||l,entries:k||l?se[k||l]:void 0,query:H,searchResults:ar,isSearching:sr,directoryError:k||l?ge[k||l]??null:null,refreshing:E,editorPath:A?p?.path??null:null,editor:Jt,onClose:a,onQueryChange:_,onOpenDirectory:Is,onOpenFile:Bs,onBackFromEditor:()=>T(!1),onRefresh:()=>{$s()}}):t.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[t.jsx(Xi,{activeDialog:us,dialogData:ds,dialogInputValue:fs,onDialogInputChange:ms,isDialogSubmitting:ps,onDialogSubmit:vs,onClose:xs,inputRef:hs}),vo,x?A?Jt:Rr:e==="editor-only"?t.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:t.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:Jt})}):t.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[j>=700&&t.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:Rr}),t.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:Jt})]})]})};export{Yl as FilesView};
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import{aN as Re,k as M}from"./vendor-boot-Dgb9NVFe.js";import{a as d,R as ae}from"./vendor-react-DASdDPIk.js";import{B as Se}from"./web-components-CdMfsnXE.js";import{f as ce}from"./computeVirtualFileMetrics-CyhUKEfv.js";import{V as Ee,F as ke}from"./VirtualizedFileDiff-IWqCJNXu.js";import{aX as xe,aj as Te}from"./useAppFontEffects-BisjofNZ.js";import{a$ as Oe}from"./runtimeEndpointReset-BqqXMwE9.js";import{ensurePierreThemeRegistered as ue,getResolvedShikiTheme as he}from"./appThemeRegistry-gegrE2dq.js";import{_ as de,o as fe}from"./index-BnZVqcki.js";const J=new Set;let ne=null;function E(n){J.add(n),ne??=requestAnimationFrame(ve)}function ve(n){const e=new Set(J);J.clear();for(const t of e)try{t(n)}catch(r){console.error(r)}J.size>0?ne=requestAnimationFrame(ve):ne=null}function ge({scrollTop:n,scrollHeight:e,height:t,fitPerfectly:r=!1,fitPerfectlyOverscroll:i=0,overscrollSize:s}){const h=t+s*2,f=r?t+i*2:h;if(e=Math.max(e,f),h>=e||r){const g=Math.max(n-i,0),y=Math.min(n+f,e);return{top:g,bottom:Math.max(y,g)}}let c=n+t/2-h/2,m=c+h;return c<0&&(c=0),m>e&&(m=e),c=Math.floor(Math.max(c,0)),{top:c,bottom:Math.ceil(Math.max(Math.min(m,e),c))}}function ze(n,e){return n==null||e==null?n===e:n.top===e.top&&n.bottom===e.bottom}const be=1e3,De=be*4,Ce=[0,1e-6,.99999,1],Ie={overscrollSize:be,intersectionObserverMargin:De,resizeDebugging:!1};let X=0,Me=-1;var He=class x{static __STOP=!1;static __lastScrollPosition=0;__id=`virtualizer-${++Me}`;config;type="simple";intersectionObserver;scrollTop=0;height=0;scrollHeight=0;windowSpecs={top:0,bottom:0};root;contentContainer;resizeObserver;observers=new Map;visibleInstances=new Map;visibleInstancesDirty=!1;instancesChanged=new Set;scrollDirty=!0;heightDirty=!0;scrollHeightDirty=!0;renderedObservers=0;connectQueue=new Map;constructor(e){this.config={...Ie,...e}}setup(e,t){if(this.root==null){this.root=e,this.resizeObserver=new ResizeObserver(this.handleContainerResize),this.intersectionObserver=new IntersectionObserver(this.handleIntersectionChange,{root:this.root,threshold:Ce,rootMargin:`${this.config.intersectionObserverMargin}px 0px ${this.config.intersectionObserverMargin}px 0px`}),e instanceof Document?this.setupWindow():this.setupElement(t),window.__INSTANCE=this,window.__TOGGLE=()=>{x.__STOP?(x.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:x.__lastScrollPosition}),E(this.computeRenderRangeAndEmit)):(x.__lastScrollPosition=this.getScrollTop(),x.__STOP=!0)};for(const[r,i]of this.connectQueue.entries())this.connect(r,i);this.connectQueue.clear(),this.markDOMDirty(),E(this.computeRenderRangeAndEmit)}}instanceChanged(e,t){this.instancesChanged.add(e),t&&this.markDOMDirty(),E(this.computeRenderRangeAndEmit)}getWindowSpecs(){return this.windowSpecs.top===0&&this.windowSpecs.bottom===0&&(this.windowSpecs=ge({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize})),this.windowSpecs}isInstanceVisible(e,t){const r=this.getScrollTop(),i=this.getHeight(),s=this.config.intersectionObserverMargin,h=r-s,f=r+i+s;return!(e<h-t||e>f)}handleContainerResize=e=>{if(this.root==null)return;let t=!1;for(const r of e){const i=r.borderBoxSize[0].blockSize;this.root instanceof Document?i!==this.scrollHeight&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: content size change",this.__id,{sizeChange:i-X,newSize:i}),X=i)):r.target===this.root?i!==this.height&&(this.heightDirty=!0,t=!0):r.target===this.contentContainer&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: scroller size change",this.__id,{sizeChange:i-X,newSize:i}),X=i))}t&&E(this.computeRenderRangeAndEmit)};setupWindow(){if(this.root==null||!(this.root instanceof Document))throw new Error("Virtualizer.setupWindow: Invalid setup method");window.addEventListener("scroll",this.handleWindowScroll,{passive:!0}),window.addEventListener("resize",this.handleWindowResize,{passive:!0}),this.resizeObserver?.observe(this.root.documentElement)}setupElement(e){if(this.root==null||this.root instanceof Document)throw new Error("Virtualizer.setupElement: Invalid setup method");this.root.addEventListener("scroll",this.handleElementScroll,{passive:!0}),this.resizeObserver?.observe(this.root),e??=this.root.firstElementChild??void 0,e instanceof HTMLElement&&(this.contentContainer=e,this.resizeObserver?.observe(e))}cleanUp(){this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.root?.removeEventListener("scroll",this.handleElementScroll),window.removeEventListener("scroll",this.handleWindowScroll),window.removeEventListener("resize",this.handleWindowResize),this.root=void 0,this.contentContainer=void 0,this.observers.clear(),this.visibleInstances.clear(),this.instancesChanged.clear(),this.connectQueue.clear(),this.visibleInstancesDirty=!1,this.windowSpecs={top:0,bottom:0},this.scrollTop=0,this.height=0,this.scrollHeight=0}getOffsetInScrollContainer(e){return this.getScrollTop()+U(e,this.getScrollContainerElement())}connect(e,t){if(this.observers.has(e))throw new Error("Virtualizer.connect: instance is already connected...");return this.intersectionObserver==null?this.connectQueue.set(e,t):(this.intersectionObserver.observe(e),this.observers.set(e,t),this.instancesChanged.add(t),this.markDOMDirty(),E(this.computeRenderRangeAndEmit)),()=>this.disconnect(e)}disconnect(e){const t=this.observers.get(e);this.connectQueue.delete(e),t!=null&&(this.intersectionObserver?.unobserve(e),this.observers.delete(e),this.visibleInstances.delete(e)&&(this.visibleInstancesDirty=!0),this.markDOMDirty(),E(this.computeRenderRangeAndEmit))}handleWindowResize=()=>{x.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,E(this.computeRenderRangeAndEmit))};handleWindowScroll=()=>{x.__STOP||this.root==null||!(this.root instanceof Document)||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};handleElementScroll=()=>{x.__STOP||this.root==null||this.root instanceof Document||(this.scrollDirty=!0,E(this.computeRenderRangeAndEmit))};computeRenderRangeAndEmit=()=>{if(x.__STOP)return;const e=this.heightDirty||this.scrollHeightDirty;if(!this.scrollDirty&&!this.scrollHeightDirty&&!this.heightDirty&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&this.instancesChanged.size===0)return;let t=this.instancesChanged.size>0;if(this.instancesChanged.size===0){const s=ge({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize});if(!e&&ze(this.windowSpecs,s)&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty)return;this.windowSpecs=s}this.visibleInstancesDirty=!1,this.renderedObservers=this.observers.size;const r=this.getScrollAnchor(this.height),i=new Set;for(const s of e?this.observers.values():this.visibleInstances.values())s.onRender(e)&&i.add(s);for(const s of this.instancesChanged)i.has(s)||s.onRender(e)&&i.add(s);this.scrollFix(r);for(const s of i)s.reconcileHeights();t||=this.instancesChanged.size>0,t&&this.markDOMDirty(),(t||e)&&E(this.computeRenderRangeAndEmit),i.clear(),this.instancesChanged.clear()};scrollFix(e){if(e==null)return;const t=this.getScrollContainerElement(),{lineIndex:r,lineOffset:i,fileElement:s,fileOffset:h,fileTypeOffset:f}=e;if(r!=null&&i!=null){const m=s.shadowRoot?.querySelector(`[data-line][data-line-index="${r}"]`);if(m instanceof HTMLElement){const g=U(m,t);if(g!==i){const y=g-i;this.applyScrollFix(y)}return}}const c=U(s,t);if(f==="top")c!==h&&this.applyScrollFix(c-h);else{const m=c+s.getBoundingClientRect().height;m!==h&&this.applyScrollFix(m-h)}}applyScrollFix(e){this.root==null||this.root instanceof Document?window.scrollTo({top:window.scrollY+e,behavior:"instant"}):this.root.scrollTo({top:this.root.scrollTop+e,behavior:"instant"}),this.markDOMDirty()}getScrollAnchor(e){const t=this.getScrollContainerElement();let r;for(const[i]of this.visibleInstances.entries()){const s=U(i,t),h=s+i.offsetHeight;let f,c;h<=0?(f=h,c="bottom"):(f=s,c="top");let m,g;if(h>0&&s<e)for(const w of i.shadowRoot?.querySelectorAll("[data-line][data-line-index]")??[]){if(!(w instanceof HTMLElement))continue;const q=w.dataset.lineIndex;if(q==null)continue;const z=U(w,t);if(!(z<0)){m=q,g=z;break}}if(r?.lineOffset!=null&&g==null)continue;let y=!1;(r==null||g!=null&&(r.lineOffset==null||g<r.lineOffset)||g==null&&r.lineOffset==null&&(f>=0&&(r.fileOffset<0||f<r.fileOffset)||f<0&&r.fileOffset<0&&f>r.fileOffset))&&(y=!0),y&&(r={fileElement:i,fileTypeOffset:c,fileOffset:f,lineIndex:m,lineOffset:g})}return r}handleIntersectionChange=e=>{this.scrollDirty=!0;for(const{target:t,isIntersecting:r}of e){if(!(t instanceof HTMLElement))throw new Error("Virtualizer.handleIntersectionChange: target not an HTMLElement");const i=this.observers.get(t);i!=null&&(r&&!this.visibleInstances.has(t)?(i.setVisibility(!0),this.visibleInstances.set(t,i),this.visibleInstancesDirty=!0):!r&&this.visibleInstances.has(t)&&(i.setVisibility(!1),this.visibleInstances.delete(t),this.visibleInstancesDirty=!0))}this.visibleInstancesDirty&&E(this.computeRenderRangeAndEmit)};getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root==null?0:this.root instanceof Document?window.scrollY:this.root.scrollTop;return e=Math.max(0,Math.min(e,this.getScrollHeight()-this.getHeight())),this.scrollTop=e,e}getScrollHeight(){return this.scrollHeightDirty?(this.scrollHeightDirty=!1,this.scrollHeight=this.root==null?0:this.root instanceof Document?this.root.documentElement.scrollHeight:this.root.scrollHeight,this.scrollHeight):this.scrollHeight}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root==null?0:this.root instanceof Document?globalThis.innerHeight:this.root.getBoundingClientRect().height,this.height):this.height}markDOMDirty(){this.scrollDirty=!0,this.scrollHeightDirty=!0,this.heightDirty=!0}getScrollContainerElement(){return this.root==null||this.root instanceof Document?void 0:this.root}};function U(n,e){const t=n.getBoundingClientRect(),r=e?.getBoundingClientRect().top??0;return t.top-r}const pe=5e5,Pe=`
|
|
2
|
-
:host {
|
|
3
|
-
font-family: var(--font-mono);
|
|
4
|
-
font-size: var(--text-code);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
pre, [data-code] {
|
|
8
|
-
font-family: var(--font-mono);
|
|
9
|
-
font-size: var(--text-code);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/* Mobile touch selection support */
|
|
13
|
-
[data-line-number] {
|
|
14
|
-
touch-action: manipulation;
|
|
15
|
-
-webkit-tap-highlight-color: transparent;
|
|
16
|
-
cursor: pointer;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/* Ensure interactive line numbers work on touch */
|
|
20
|
-
pre[data-interactive-line-numbers] [data-line-number] {
|
|
21
|
-
touch-action: manipulation;
|
|
22
|
-
}
|
|
23
|
-
`,Le=`
|
|
24
|
-
${Pe}
|
|
25
|
-
|
|
26
|
-
:host {
|
|
27
|
-
--diffs-bg-separator-override: var(--surface-elevated);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
[data-diff-header],
|
|
31
|
-
[data-diff] {
|
|
32
|
-
[data-separator] {
|
|
33
|
-
height: 24px !important;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
[data-separator="line-info-basic"] {
|
|
38
|
-
height: 24px !important;
|
|
39
|
-
background: var(--diffs-bg) !important;
|
|
40
|
-
position: relative;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
[data-diff-type="single"] [data-gutter],
|
|
44
|
-
[data-diff-type="split"] [data-deletions] [data-gutter] {
|
|
45
|
-
[data-separator-wrapper] {
|
|
46
|
-
position: absolute;
|
|
47
|
-
left: 100%;
|
|
48
|
-
display: flex;
|
|
49
|
-
align-items: center;
|
|
50
|
-
gap: unset;
|
|
51
|
-
width: max-content;
|
|
52
|
-
background: transparent;
|
|
53
|
-
color: var(--diffs-fg-number);
|
|
54
|
-
font-family: var(--diffs-header-font-family, var(--font-sans));
|
|
55
|
-
font-size: 0.75rem;
|
|
56
|
-
line-height: 1;
|
|
57
|
-
margin-left: calc(-2ch - 2px);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
[data-separator-wrapper][data-separator-multi-button] {
|
|
61
|
-
margin-left: calc(-3ch - 2px);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
[data-expand-button],
|
|
65
|
-
[data-separator-content] {
|
|
66
|
-
display: block;
|
|
67
|
-
align-self: unset;
|
|
68
|
-
min-width: unset;
|
|
69
|
-
min-height: unset;
|
|
70
|
-
padding: 0;
|
|
71
|
-
flex-shrink: 0;
|
|
72
|
-
grid-column: unset;
|
|
73
|
-
border: none;
|
|
74
|
-
width: auto;
|
|
75
|
-
height: auto;
|
|
76
|
-
background-color: transparent;
|
|
77
|
-
color: inherit;
|
|
78
|
-
font: inherit;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
[data-expand-button]:not([data-expand-all-button]) {
|
|
82
|
-
&[data-expand-down]::before {
|
|
83
|
-
content: '\\2191';
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
&[data-expand-up]::before {
|
|
87
|
-
content: '\\2193';
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
&[data-expand-both]::before {
|
|
91
|
-
content: '\\2195';
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
svg {
|
|
95
|
-
display: none;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
[data-separator-content] {
|
|
100
|
-
background: transparent;
|
|
101
|
-
margin-left: calc(2px + 1ch);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
[data-expand-all-button] {
|
|
105
|
-
position: relative;
|
|
106
|
-
margin-left: 14px;
|
|
107
|
-
text-transform: lowercase;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
[data-expand-all-button]::before {
|
|
111
|
-
content: '';
|
|
112
|
-
display: block;
|
|
113
|
-
position: absolute;
|
|
114
|
-
top: 50%;
|
|
115
|
-
left: -8px;
|
|
116
|
-
margin-top: -1px;
|
|
117
|
-
width: 3px;
|
|
118
|
-
height: 3px;
|
|
119
|
-
border-radius: 2px;
|
|
120
|
-
background-color: var(--diffs-fg-number);
|
|
121
|
-
pointer-events: none;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
[data-separator-content]:hover,
|
|
125
|
-
[data-expand-button]:hover,
|
|
126
|
-
[data-expand-all-button]:hover {
|
|
127
|
-
color: var(--diffs-fg);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
[data-expand-all-button]:hover {
|
|
131
|
-
text-decoration: underline;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
`;function _e(n){let e=2166136261;for(let t=0;t<n.length;t+=1)e^=n.charCodeAt(t),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return e.toString(16)}function me(n){const e=n.length>400?`${n.slice(0,200)}${n.slice(-200)}`:n;return`${n.length}:${_e(e)}`}const Fe=n=>n==="auto"||n==="scroll"||n==="overlay",Ae=n=>{let e=n?.parentElement??null;for(;e;){const t=window.getComputedStyle(e);if(Fe(t.overflowY))return e;e=e.parentElement}return null},Ve=(n,e)=>{if(!n||!e||typeof window>"u")return()=>{};const t=Ae(n);if(!t)return()=>{};const r=e.getBoundingClientRect().height;if(!r)return()=>{};const i=n.getBoundingClientRect().top-t.getBoundingClientRect().top,s=e.style.minHeight;e.style.minHeight=`${Math.ceil(r)}px`;let h=!1;return()=>{if(h)return;h=!0,e.style.minHeight=s;const c=n.getBoundingClientRect().top-t.getBoundingClientRect().top-i;c&&(t.scrollTop+=c)}},$e=(n,e)=>{if(typeof window>"u")return()=>{};let t=null,r=null,i=!1;const s=()=>{i||(r?.disconnect(),r=null,t=window.requestAnimationFrame(()=>{t=window.requestAnimationFrame(()=>{i||e()})}))},h=()=>n.querySelector("diffs-container")?.shadowRoot??void 0,f=(c=h())=>!!c?.querySelector("[data-line]");return f()?s():typeof MutationObserver<"u"?(r=new MutationObserver(()=>{const c=h();if(c){if(f(c)){s();return}r?.disconnect(),r=new MutationObserver(()=>{f(c)&&s()}),r.observe(c,{childList:!0,subtree:!0})}}),r.observe(n,{childList:!0,subtree:!0})):t=window.requestAnimationFrame(s),()=>{i=!0,r?.disconnect(),t!==null&&window.cancelAnimationFrame(t)}},Z=new WeakMap,qe={lineHeight:24,hunkSeparatorHeight:24,spacing:0};function Ne(n){const e=n.closest("[data-diff-virtual-root]");if(e instanceof HTMLElement){const t=e.querySelector("[data-diff-virtual-content]");return{key:e,root:e,content:t instanceof HTMLElement?t:void 0}}return{key:document,root:document,content:void 0}}function We(n){if(typeof document>"u")return null;const e=Ne(n);let t=Z.get(e.key);if(!t){const i=new He;i.setup(e.root,e.content),t={virtualizer:i,refs:0},Z.set(e.key,t)}t.refs+=1;let r=!1;return{virtualizer:t.virtualizer,root:e.root,release:()=>{if(r)return;r=!0;const i=Z.get(e.key);i&&(i.refs-=1,!(i.refs>0)&&(i.virtualizer.cleanUp(),Z.delete(e.key)))}}}const Be=(n,e,t)=>{if(typeof window>"u")return()=>{};const r=[],i=()=>{try{n.rerender()}catch{}const s=e?.root;s instanceof HTMLElement?s.dispatchEvent(new Event("scroll",{bubbles:!1})):document.dispatchEvent(new Event("scroll",{bubbles:!1})),window.dispatchEvent(new Event("resize")),t()};return r.push(window.requestAnimationFrame(i)),r.push(window.requestAnimationFrame(()=>{r.push(window.requestAnimationFrame(i))})),()=>{for(const s of r)window.cancelAnimationFrame(s)}},tt=({original:n,modified:e,fileDiff:t,language:r,fileName:i,renderSideBySide:s,wrapLines:h,layout:f="fill",enableGutterUtility:c=!1,enableLineSelection:m=!1,onGutterUtilityClick:g,onLineSelectionEnd:y,lineAnnotations:w,renderAnnotation:q})=>{const z=xe(),D=z?.currentTheme.metadata.variant==="dark",_=z?.availableThemes.find(o=>o.metadata.id===z.lightThemeId)??de(!1),F=z?.availableThemes.find(o=>o.metadata.id===z.darkThemeId)??de(!0);ue(_),ue(F);const N=`${_.metadata.id}:${F.metadata.id}:${D?"dark":"light"}`,W=d.useMemo(()=>{if(t){const o=t.deletionLines.reduce((a,u)=>a+u.length,0),l=t.additionLines.reduce((a,u)=>a+u.length,0);return Math.max(o,l)>pe}return Math.max(n.length,e.length)>pe},[t,e.length,n.length]),Q=d.useRef(null),B=d.useRef(null),A=d.useRef(null),j=d.useRef(null),ee=d.useRef(null),te=d.useRef(null),re=d.useRef(void 0),K=d.useRef(void 0),G=d.useRef(void 0),Y=d.useRef(void 0),[,se]=ae.useReducer(o=>o+1,0),V=Oe(W?"unified":s?"split":"unified"),C=d.useRef(new Map),ie=d.useRef(q);ie.current=q;const oe=o=>`${o.side}:${o.lineNumber}`,le=d.useCallback(o=>{if(typeof document>"u")return;const l=`${o.side}:${o.lineNumber}`;let a=C.current.get(l);if(!a){const u=document.createElement("div");u.setAttribute("data-pichamber-line-annotation",l),a={root:Re.createRoot(u),element:u},C.current.set(l,a)}return a.root.render(ie.current?.(o)??null),a.element},[]);d.useEffect(()=>{if(!w){for(const[,a]of C.current)a.root.unmount();C.current.clear();return}const o=new Set(w.map(oe));for(const[a,u]of C.current)o.has(a)||(u.root.unmount(),C.current.delete(a));const l=ie.current;if(l)for(const a of w){const u=C.current.get(oe(a));u&&u.root.render(l(a))}},[w]),d.useEffect(()=>{const o=C.current;return()=>{for(const l of o.values())l.root.unmount();o.clear()}},[]);const T=d.useMemo(()=>he(_),[_]),O=d.useMemo(()=>he(F),[F]);ae.useLayoutEffect(()=>{const o=Q.current;if(!o)return;const l=o.querySelector("diffs-container");if(!l)return;const a=D?O:T,u=(ye,we)=>ye.colors?.[we],R=u(T,"terminal.ansiGreen"),v=u(T,"terminal.ansiRed"),b=u(T,"terminal.ansiBlue"),P=u(O,"terminal.ansiGreen"),k=u(O,"terminal.ansiRed"),I=u(O,"terminal.ansiBlue");l.style.setProperty("--shiki-light",T.fg),l.style.setProperty("--shiki-light-bg",T.bg),R&&l.style.setProperty("--shiki-light-addition-color",R),v&&l.style.setProperty("--shiki-light-deletion-color",v),b&&l.style.setProperty("--shiki-light-modified-color",b),l.style.setProperty("--shiki-dark",O.fg),l.style.setProperty("--shiki-dark-bg",O.bg),P&&l.style.setProperty("--shiki-dark-addition-color",P),k&&l.style.setProperty("--shiki-dark-deletion-color",k),I&&l.style.setProperty("--shiki-dark-modified-color",I),l.style.setProperty("--diffs-bg",a.bg),l.style.setProperty("--diffs-fg",a.fg);const S=D?P:R,L=D?k:v,$=D?I:b;S&&l.style.setProperty("--diffs-addition-color-override",S),L&&l.style.setProperty("--diffs-deletion-color-override",L),$&&l.style.setProperty("--diffs-modified-color-override",$);const p=l.shadowRoot?.querySelector("pre");p&&(p.style.setProperty("--shiki-light",T.fg),p.style.setProperty("--shiki-light-bg",T.bg),R&&p.style.setProperty("--shiki-light-addition-color",R),v&&p.style.setProperty("--shiki-light-deletion-color",v),b&&p.style.setProperty("--shiki-light-modified-color",b),p.style.setProperty("--shiki-dark",O.fg),p.style.setProperty("--shiki-dark-bg",O.bg),P&&p.style.setProperty("--shiki-dark-addition-color",P),k&&p.style.setProperty("--shiki-dark-deletion-color",k),I&&p.style.setProperty("--shiki-dark-modified-color",I),p.style.setProperty("--diffs-bg",a.bg),p.style.setProperty("--diffs-fg",a.fg),S&&p.style.setProperty("--diffs-addition-color-override",S),L&&p.style.setProperty("--diffs-deletion-color-override",L),$&&p.style.setProperty("--diffs-modified-color-override",$))},[O,N,D,T]);const H=d.useMemo(()=>({theme:{dark:F.metadata.id,light:_.metadata.id},themeType:D?"dark":"light",diffStyle:s?"split":"unified",diffIndicators:"none",hunkSeparators:"line-info-basic",lineDiffType:"none",maxLineDiffLength:W?0:1e3,maxLineLengthForHighlighting:W?1:1e3,tokenizeMaxLineLength:W?1:1e3,collapsedContextThreshold:0,expansionLineCount:20,overflow:h?"wrap":"scroll",disableFileHeader:!0,enableLineSelection:m,enableGutterUtility:c,enableHoverUtility:!1,...g?{onGutterUtilityClick:g}:{},...y?{onLineSelectionEnd:y}:{},renderAnnotation:le,unsafeCSS:Le}),[le,F.metadata.id,c,m,D,W,_.metadata.id,g,y,s,h]);return d.useEffect(()=>{const o=B.current;return()=>{A.current?.cleanUp(),A.current=null,j.current?.release(),j.current=null,ee.current=null,te.current=null,re.current=void 0,K.current=void 0,G.current=void 0,Y.current=void 0,o&&(o.innerHTML="")}},[]),d.useEffect(()=>{if(typeof window>"u")return;const o=B.current,l=Q.current;if(!o||!V)return;const a=Ve(l,o);let u=j.current;u||(u=We(o),j.current=u),j.current=u;const R=u?.virtualizer??null,v=t?void 0:{name:i||"",contents:n,lang:r,cacheKey:`old:${N}:${i}:${me(n)}`},b=t?void 0:{name:i||"",contents:e,lang:r,cacheKey:`new:${N}:${i}:${me(e)}`},P=t?K.current!==t:K.current!==void 0||!v||!b||!G.current||!Y.current||!ce(G.current,v)||!ce(Y.current,b),k=A.current,I=!!(k&&(ee.current!==R||te.current!==V||R&&(re.current!==H.hunkSeparators||P)));I&&(k?.cleanUp(),A.current=null,o.innerHTML="");let S=A.current;const L=!I&&k?!Se(k.options,H):!1;if(S?S.setOptions(H):(S=u?new Ee(H,u.virtualizer,qe,V):new ke(H,V),A.current=S),ee.current=R,te.current=V,re.current=R?H.hunkSeparators:void 0,K.current=t,G.current=v,Y.current=b,t)S.render({fileDiff:t,forceRender:L,containerWrapper:o,...w?{lineAnnotations:w}:{}});else{if(!v||!b)return;S.render({oldFile:v,newFile:b,forceRender:L,containerWrapper:o,...w?{lineAnnotations:w}:{}})}const $=$e(o,()=>{a(),Be(S,u,se)});return()=>{$(),a()}},[N,t,i,r,w,e,H,n,V]),d.useEffect(()=>{const o=B.current;if(!o)return;let l=null,a=null;const R=setTimeout(()=>{const v=o.querySelector("diffs-container");if(!(v instanceof HTMLElement))return;const b=v.shadowRoot;l=new MutationObserver(()=>{a&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{se(),a=null})}),l.observe(v,{childList:!0,subtree:!0}),b&&l.observe(b,{childList:!0,subtree:!0})},100);return()=>{clearTimeout(R),a&&cancelAnimationFrame(a),l?.disconnect()}},[N,i]),typeof window>"u"?null:f==="fill"?M.jsx("div",{className:fe("flex flex-col relative","size-full"),"data-diff-virtual-root":!0,children:M.jsx("div",{className:"flex-1 relative min-h-0",children:M.jsx(Te,{outerClassName:"pierre-diff-wrapper size-full",disableHorizontal:!1,fillContainer:!0,"data-diff-virtual-content":!0,children:M.jsx("div",{ref:Q,className:"size-full relative",children:M.jsx("div",{ref:B,className:"size-full"})})})})}):M.jsx("div",{className:fe("relative","w-full"),children:M.jsx("div",{ref:Q,className:"pierre-diff-wrapper w-full overflow-x-auto overflow-y-visible relative","data-no-drawer-swipe":"true",children:M.jsx("div",{ref:B,className:"w-full"})})})};export{tt as P};
|