@openchamber/web 2.3.0 → 2.3.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/dist/assets/AboutDialog-C1ulAXh5.js +1 -0
- package/dist/assets/ArchiveView-DJo1Bpw_.js +1 -0
- package/dist/assets/{CommandPalette-1VlA7PbL.js → CommandPalette-B6r6DPF9.js} +2 -2
- package/dist/assets/{DiffView-SHdJJ6tl.js → DiffView-mJuVm7Z4.js} +2 -2
- package/dist/assets/{FilePreviewCommentMenu-DlVgwRsr.js → FilePreviewCommentMenu-Ca4ziuof.js} +1 -1
- package/dist/assets/{FilesView-BeMtsSlV.js → FilesView-BBFbfDp9.js} +3 -3
- package/dist/assets/{GitView-npRGKKx8.js → GitView-WL1wkRFF.js} +3 -3
- package/dist/assets/GuestSurfacePane-peVDY5gW.js +1 -0
- package/dist/assets/HelpDialog-Dxc2yneu.js +1 -0
- package/dist/assets/{InProgressOperationBanner-B6iO22_7.js → InProgressOperationBanner-Dy0RiPsD.js} +1 -1
- package/dist/assets/JsonTreeView-BKUmh7Iw.js +1 -0
- package/dist/assets/MarkdownImageGallery-Cd6hLNmi.js +1 -0
- package/dist/assets/MarkdownRendererImpl-C-3B3mBt.js +1 -0
- package/dist/assets/MemoryDebugPanel-b116r1SF.js +1 -0
- package/dist/assets/OnboardingScreen-vBEhpU3q.js +1 -0
- package/dist/assets/OpenCodeStatusDialog-DH7dJ6MH.js +1 -0
- package/dist/assets/{PatchDiff-Du2s7T3U.js → PatchDiff-yM7vgQgi.js} +1 -1
- package/dist/assets/{PierreDiffViewer-B9K0gBvV.js → PierreDiffViewer-DnHKbYGl.js} +1 -1
- package/dist/assets/{PlanView-IkTcPrbw.js → PlanView-j0hLJmto.js} +2 -2
- package/dist/assets/RunOverview-ZuFZvDcu.js +2 -0
- package/dist/assets/ScheduledTasksDialog-UKXFFI91.js +5 -0
- package/dist/assets/{SettingsView-DIy5ZL4-.js → SettingsView-gB_NvyX4.js} +8 -8
- package/dist/assets/SettingsWindow-Dfb_RFpD.js +1 -0
- package/dist/assets/SourceBoardView-BjaL0nKs.js +1 -0
- package/dist/assets/SpaceAccessDialog-XzHRmIdT.js +1 -0
- package/dist/assets/SpaceApplyDialog-CxX9mrzT.js +1 -0
- package/dist/assets/{SpaceRow-YPmKQKeD.js → SpaceRow-vCpOCANO.js} +1 -1
- package/dist/assets/SpaceSetupOutput-CDZvJCf_.js +1 -0
- package/dist/assets/SpacesView-D3a9bCzn.js +1 -0
- package/dist/assets/{SubmoduleDiffSummary-RDY5md3p.js → SubmoduleDiffSummary-CQyRcvDZ.js} +1 -1
- package/dist/assets/{ToolOutputDialog-Dx85XZJs.js → ToolOutputDialog-judR_5mS.js} +2 -2
- package/dist/assets/{ToolPartDiffPreview-Dtv0xF9O.js → ToolPartDiffPreview-Ca9ISxfg.js} +1 -1
- package/dist/assets/UsageStatsView-C63Emjfj.js +1 -0
- package/dist/assets/{Virtualizer-DL535kyR.js → Virtualizer-DNgIEKcx.js} +1 -1
- package/dist/assets/{WalkthroughView-DcxbT5tc.js → WalkthroughView-D74b_7sC.js} +2 -2
- package/dist/assets/WorktreesView-hcm8Eb_C.js +1 -0
- package/dist/assets/appThemeRegistry-COeayQaQ.js +1 -0
- package/dist/assets/{ar-lP51qqz9.js → ar-1_zdYVV5.js} +2 -2
- package/dist/assets/computeVirtualFileMetrics-MZqvCQy0.js +3 -0
- package/dist/assets/{de-CpROAvTV.js → de-Ci7SGEQP.js} +3 -3
- package/dist/assets/{decorate-BNB7jeKg.js → decorate-CZeRRVC7.js} +1 -1
- package/dist/assets/{es-Bb8LKRhE.js → es-ZJii-6Tt.js} +2 -2
- package/dist/assets/{fr-BlNN9FC2.js → fr-C-hK8mvI.js} +2 -2
- package/dist/assets/{he-r546pCuc.js → he-t07CylP8.js} +2 -2
- package/dist/assets/index-D2tPUss-.js +1 -0
- package/dist/assets/{initializeSharedPreferences-dCHO04bl.js → initializeSharedPreferences-FxFkTjgn.js} +1 -1
- package/dist/assets/{isDiffPlainText-BwicHPpI.js → isDiffPlainText-C1F9opE5.js} +1 -1
- package/dist/assets/{isFilePlainText-Dk2R7BJo.js → isFilePlainText-B4SyJ-ni.js} +1 -1
- package/dist/assets/{ja-evNvJAHz.js → ja-iJr8aONy.js} +2 -2
- package/dist/assets/{katex-CMY-1eWf.css → katex-BEX7X_K8.css} +1 -1
- package/dist/assets/{katex.min-Iw9WSgM9.js → katex.min-C-51hS9A.js} +18 -18
- package/dist/assets/{ko-BPQP7lXe.js → ko-D5ow_yz-.js} +2 -2
- package/dist/assets/main-BtGnuno4.js +1048 -0
- package/dist/assets/main-uj5954n5.js +2 -0
- package/dist/assets/markdownCore-rBXCnAJp.js +9 -0
- package/dist/assets/miniChat-yWQmT2OS.js +2 -0
- package/dist/assets/mobile-NDAeGtzL.js +2 -0
- package/dist/assets/{moveWorkspacePath-B31RGdgu.js → moveWorkspacePath-BINgpJ9S.js} +1 -1
- package/dist/assets/{nl-CkQXd1nU.js → nl-CfqYrSVe.js} +2 -2
- package/dist/assets/{parseDiffFromFile-DcsKSY0J.js → parseDiffFromFile--DE4eHIp.js} +2 -2
- package/dist/assets/{patchFileDiff-Cx-HpjyI.js → patchFileDiff-BfFUmWgS.js} +1 -1
- package/dist/assets/pierreDiffTint-D9K6_CVD.js +29 -0
- package/dist/assets/{pl-C4i9Aizi.js → pl-Bn2_jAhL.js} +4 -4
- package/dist/assets/{pt-BR-CoYnG1CH.js → pt-BR-ZSDgn6cI.js} +2 -2
- package/dist/assets/relocateRestoredSession-C85Tk2y9.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-BvAEmWhZ.js +2 -0
- package/dist/assets/{renderMobileApp-gDKxRJQi.js → renderMobileApp-T20l8ise.js} +7 -7
- package/dist/assets/{restartOpenCode-dq-SGun3.js → restartOpenCode-VEmIrLer.js} +1 -1
- package/dist/assets/runtimeEndpointReset-ExJsaWzA.js +55 -0
- package/dist/assets/scheduledTasksApi-NSyxVfHu.js +1 -0
- package/dist/assets/{selectionMarkdown-sDTBbKLh.js → selectionMarkdown-BJ2RhTXc.js} +2 -2
- package/dist/assets/{sessionOwnership-kZAtwMQd.js → sessionOwnership-BAX1xEJC.js} +1 -1
- package/dist/assets/{shikiHighlight-BRNXPlF-.js → shikiHighlight-DOzrE7BE.js} +1 -1
- package/dist/assets/{space-apply-CCOKLfrX.js → space-apply-DB_ZfJBW.js} +1 -1
- package/dist/assets/space-close-1kNlTkW1.js +1 -0
- package/dist/assets/{spaceNetwork-DUxJClu3.js → spaceNetwork-DA16ov_y.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-B6UJwdZz.js → textMateThemeFromAppTheme-BfIrjFAU.js} +1 -1
- package/dist/assets/{tr-D-_lz-lC.js → tr-C89uz1hs.js} +2 -2
- package/dist/assets/{uk-B49PGMYB.js → uk-uTYVPFrO.js} +2 -2
- package/dist/assets/{useAppFontEffects-3EN8Ava3.js → useAppFontEffects-C1ceAD51.js} +185 -185
- package/dist/assets/useCallableModelProviders-BkLsgs6y.js +1 -0
- package/dist/assets/{useInlineCommentController-l9cWyfuR.js → useInlineCommentController-ynkUsoVA.js} +1 -1
- package/dist/assets/{useRootScrollLock-UAQn24Y8.js → useRootScrollLock-DnoKH1HE.js} +2 -2
- package/dist/assets/{vendor-codemirror-autocomplete-C8FBSI9t.js → vendor-codemirror-autocomplete-BRKmCSiY.js} +1 -1
- package/dist/assets/{vendor-codemirror-commands-BhRb6jns.js → vendor-codemirror-commands-MmBpgSOc.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-angular-Bj5Pk8sp.js +1 -0
- package/dist/assets/vendor-codemirror-lang-cpp-tZt-BOgi.js +1 -0
- package/dist/assets/vendor-codemirror-lang-css-DfdrZ848.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-go-BHJEONih.js → vendor-codemirror-lang-go-C9OcoXdP.js} +2 -2
- package/dist/assets/vendor-codemirror-lang-html-C5kFuJzc.js +1 -0
- package/dist/assets/vendor-codemirror-lang-java-Divn2dnj.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-javascript-CUmSxayT.js → vendor-codemirror-lang-javascript-DmPuKUEa.js} +2 -2
- package/dist/assets/vendor-codemirror-lang-jinja-B-8miA-Q.js +1 -0
- package/dist/assets/vendor-codemirror-lang-json-L0wsFFxi.js +1 -0
- package/dist/assets/vendor-codemirror-lang-less-CWlCIxCI.js +1 -0
- package/dist/assets/vendor-codemirror-lang-liquid-Dm8xthAW.js +1 -0
- package/dist/assets/vendor-codemirror-lang-markdown-CPn-qinN.js +1 -0
- package/dist/assets/vendor-codemirror-lang-php-DKIOifjN.js +1 -0
- package/dist/assets/vendor-codemirror-lang-python-BAVa3Hg5.js +3 -0
- package/dist/assets/vendor-codemirror-lang-rust-Dab90hdg.js +1 -0
- package/dist/assets/vendor-codemirror-lang-sass-eezaHFBZ.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-sql-C1Jj9uuJ.js → vendor-codemirror-lang-sql-Vu-PR7cv.js} +2 -2
- package/dist/assets/vendor-codemirror-lang-vue-BthRGZHy.js +1 -0
- package/dist/assets/vendor-codemirror-lang-wast-Db6KSic0.js +1 -0
- package/dist/assets/vendor-codemirror-lang-xml-DQkh4sc1.js +1 -0
- package/dist/assets/vendor-codemirror-lang-yaml-Bt2N__AW.js +1 -0
- package/dist/assets/vendor-codemirror-language-DkBxRck3.js +3 -0
- package/dist/assets/vendor-codemirror-language-data-CTYHXywt.js +2 -0
- package/dist/assets/{vendor-codemirror-search-CvXM_pZg.js → vendor-codemirror-search-BKAwkhkm.js} +1 -1
- package/dist/assets/vendor-codemirror-streamparser-CmlTsbN2.js +1 -0
- package/dist/assets/vendor-codemirror-view-B66jUSmE.js +4 -0
- package/dist/assets/{vendor-replit-codemirror-vim-Ck2X_WZC.js → vendor-replit-codemirror-vim-D0bqFa1D.js} +5 -5
- package/dist/assets/{worker-DdhrXE7g.js → worker-BbEdJ2Oi.js} +18 -18
- package/dist/assets/workerFactory-Bw5qLmrM.js +1 -0
- package/dist/assets/{zh-CN-CS-9Os9n.js → zh-CN-DdTNG52a.js} +2 -2
- package/dist/assets/{zh-TW-D0XYVdcl.js → zh-TW-DPm_33Fi.js} +2 -2
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +2 -2
- package/server/index.js +4 -0
- package/server/lib/environment/store.js +3 -4
- package/server/lib/environment/store.test.js +17 -0
- package/server/lib/fs/DOCUMENTATION.md +4 -2
- package/server/lib/fs/routes.js +48 -13
- package/server/lib/fs/routes.test.js +118 -5
- package/server/lib/git/DOCUMENTATION.md +3 -1
- package/server/lib/git/contributor-remote.js +4 -0
- package/server/lib/git/contributor-remote.test.js +21 -0
- package/server/lib/git/service.js +20 -25
- package/server/lib/git/service.test.js +99 -0
- package/server/lib/git/worktree-creation.js +4 -5
- package/server/lib/github/DOCUMENTATION.md +1 -1
- package/server/lib/github/routes.auth.test.js +14 -0
- package/server/lib/github/routes.js +13 -5
- package/server/lib/github/routes.mutations.test.js +18 -2
- package/server/lib/message-queue/DOCUMENTATION.md +8 -2
- package/server/lib/message-queue/runtime.js +3 -2
- package/server/lib/message-queue/runtime.test.js +64 -2
- package/server/lib/openchamber-control/service.js +48 -13
- package/server/lib/openchamber-control/service.test.js +42 -0
- package/server/lib/opencode/DOCUMENTATION.md +3 -1
- package/server/lib/opencode/project-start-command.d.ts +11 -0
- package/server/lib/opencode/project-start-command.js +56 -0
- package/server/lib/opencode/project-start-command.test.js +80 -0
- package/server/lib/opencode/session-activity.js +43 -3
- package/server/lib/opencode/session-activity.test.js +97 -0
- package/server/lib/opencode/settings-runtime.js +19 -1
- package/server/lib/opencode/settings-runtime.test.js +23 -0
- package/server/lib/opencode/skill-routes.js +34 -1
- package/server/lib/opencode/skill-routes.test.js +99 -0
- package/server/lib/quota/DOCUMENTATION.md +13 -1
- package/server/lib/quota/providers/antigravity/api.js +104 -0
- package/server/lib/quota/providers/antigravity/auth.js +45 -0
- package/server/lib/quota/providers/antigravity/index.js +76 -0
- package/server/lib/quota/providers/antigravity/transforms.js +168 -0
- package/server/lib/quota/providers/antigravity/transforms.test.js +162 -0
- package/server/lib/quota/providers/codex.js +28 -4
- package/server/lib/quota/providers/codex.test.js +29 -0
- package/server/lib/quota/providers/google/auth.js +4 -49
- package/server/lib/quota/providers/google/transforms.js +3 -22
- package/server/lib/quota/providers/index.js +8 -0
- package/server/lib/quota/providers/opencode-go.js +3 -1
- package/server/lib/quota/providers/opencode-go.test.js +12 -0
- package/server/lib/routing/DOCUMENTATION.md +3 -1
- package/server/lib/routing/runtime.js +34 -1
- package/server/lib/routing/runtime.test.js +43 -1
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +11 -0
- package/server/lib/scheduled-tasks/existing-session.js +52 -8
- package/server/lib/scheduled-tasks/existing-session.test.js +121 -0
- package/server/lib/scheduled-tasks/routes.js +26 -0
- package/server/lib/scheduled-tasks/runtime.js +1 -0
- package/server/lib/session-assist/runtime.js +3 -0
- package/server/lib/session-assist/runtime.test.js +47 -0
- package/server/lib/skills-catalog/DOCUMENTATION.md +10 -1
- package/server/lib/skills-catalog/install.js +1 -1
- package/server/lib/skills-catalog/installed-sources.d.ts +17 -0
- package/server/lib/skills-catalog/installed-sources.js +112 -0
- package/server/lib/skills-catalog/installed-sources.test.js +94 -0
- package/server/lib/small-model/DOCUMENTATION.md +12 -5
- package/server/lib/small-model/index.js +6 -4
- package/server/lib/small-model/index.test.js +40 -0
- package/server/lib/small-model/routes.js +3 -2
- package/server/lib/source-control/change-request-worktree.js +2 -6
- package/server/lib/source-control/mutation-storage.js +4 -1
- package/server/lib/source-control/mutation-storage.test.js +21 -0
- package/server/lib/spaces/DOCUMENTATION.md +1 -1
- package/server/lib/spaces/journey.js +10 -3
- package/server/lib/spaces/journey.test.js +13 -1
- package/server/lib/terminal/history.js +22 -2
- package/server/lib/terminal/history.test.js +23 -0
- package/server/lib/terminal/theme-response.js +14 -0
- package/server/lib/terminal/theme-response.test.js +10 -0
- package/dist/assets/AboutDialog-e8ek_kPI.js +0 -1
- package/dist/assets/ArchiveView-CjF4_TFg.js +0 -1
- package/dist/assets/GuestSurfacePane-4kmEXPLD.js +0 -1
- package/dist/assets/HelpDialog-CITMqPDK.js +0 -1
- package/dist/assets/JsonTreeView-xGikhCtL.js +0 -1
- package/dist/assets/MarkdownImageGallery-D0FJyr7C.js +0 -1
- package/dist/assets/MarkdownRendererImpl-BIM7Pjwk.js +0 -1
- package/dist/assets/MemoryDebugPanel-CBk8QW-M.js +0 -1
- package/dist/assets/OnboardingScreen-Cy6ARiMS.js +0 -1
- package/dist/assets/OpenCodeStatusDialog-YMHuJzwt.js +0 -1
- package/dist/assets/RunOverview-CHkGSW1x.js +0 -2
- package/dist/assets/ScheduledTasksDialog-77SO8zdJ.js +0 -4
- package/dist/assets/SettingsWindow-X74FIkdo.js +0 -1
- package/dist/assets/SourceBoardView-Cff2ejOW.js +0 -1
- package/dist/assets/SpaceAccessDialog-BXMZNRei.js +0 -1
- package/dist/assets/SpaceApplyDialog-BEJd2ryu.js +0 -1
- package/dist/assets/SpaceSetupOutput-Cb3XcIII.js +0 -1
- package/dist/assets/SpacesView-I3HaRKtW.js +0 -1
- package/dist/assets/UsageStatsView-DwTt9zIz.js +0 -1
- package/dist/assets/WorktreesView-Bh7GLvrR.js +0 -1
- package/dist/assets/appThemeRegistry-Bzb67M9O.js +0 -1
- package/dist/assets/computeVirtualFileMetrics-WAp98Bb7.js +0 -3
- package/dist/assets/index-BsupKM40.js +0 -1
- package/dist/assets/main-C_QGhDBL.js +0 -1048
- package/dist/assets/main-pWZ7F_hy.js +0 -2
- package/dist/assets/markdownCore-6gz4uJDQ.js +0 -9
- package/dist/assets/miniChat-DnaTfdYh.js +0 -2
- package/dist/assets/mobile-C7DIJqP8.js +0 -2
- package/dist/assets/pierreDiffTint-B297eqF0.js +0 -28
- package/dist/assets/relocateRestoredSession-D3lujODj.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-BF4hNe69.js +0 -2
- package/dist/assets/runtimeEndpointReset-D6Lxhk0S.js +0 -55
- package/dist/assets/scheduledTasksApi-DUbAMrjW.js +0 -1
- package/dist/assets/space-close-CWcWwH4_.js +0 -1
- package/dist/assets/useCallableModelProviders-BB9xkUzM.js +0 -1
- package/dist/assets/vendor-codemirror-lang-angular-BpYCRJSk.js +0 -1
- package/dist/assets/vendor-codemirror-lang-cpp-BI3uPyjT.js +0 -1
- package/dist/assets/vendor-codemirror-lang-css-B2_PZTBl.js +0 -1
- package/dist/assets/vendor-codemirror-lang-html-BpvvTxbZ.js +0 -1
- package/dist/assets/vendor-codemirror-lang-java-BM5LQZ4u.js +0 -1
- package/dist/assets/vendor-codemirror-lang-jinja-D8nLZQPK.js +0 -1
- package/dist/assets/vendor-codemirror-lang-json-VDxF27mO.js +0 -1
- package/dist/assets/vendor-codemirror-lang-less-BecU2BJP.js +0 -1
- package/dist/assets/vendor-codemirror-lang-liquid-DCw83Anh.js +0 -1
- package/dist/assets/vendor-codemirror-lang-markdown-CimQAQbQ.js +0 -1
- package/dist/assets/vendor-codemirror-lang-php-C5Kpnpyb.js +0 -1
- package/dist/assets/vendor-codemirror-lang-python-BFE1OJNx.js +0 -3
- package/dist/assets/vendor-codemirror-lang-rust-hqZDyGIJ.js +0 -1
- package/dist/assets/vendor-codemirror-lang-sass-CAZML-Jl.js +0 -1
- package/dist/assets/vendor-codemirror-lang-vue-BHOTXcKp.js +0 -1
- package/dist/assets/vendor-codemirror-lang-wast-DcCHfPUI.js +0 -1
- package/dist/assets/vendor-codemirror-lang-xml-BO_V-1wZ.js +0 -1
- package/dist/assets/vendor-codemirror-lang-yaml-CPimap_N.js +0 -1
- package/dist/assets/vendor-codemirror-language-BBADuAkg.js +0 -3
- package/dist/assets/vendor-codemirror-language-data-Cu5ZbrPm.js +0 -2
- package/dist/assets/vendor-codemirror-view-1e0FQ6Wn.js +0 -4
- package/dist/assets/workerFactory-De9YXIdE.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{R as i,j as s,f as Te,r as Et,c as Oc}from"./vendor-react-BUCujlKS.js";import{aT as Bc,Y as $e,l as mn,a0 as Bo,b0 as $c,aq as _c,b1 as Wc,b2 as Uc,ak as Gc,ao as Hc,aj as Be,u as qe,b3 as Kc,aZ as dr,v as qc,b4 as oo,b5 as ti,b6 as Xc,b7 as Yc,a1 as Jc,aY as Zc,a2 as Qc,a3 as eu,a5 as tu,a4 as su,b8 as _t,b9 as nu}from"./katex.min-Iw9WSgM9.js";import{u as Xe,y as pn,B as $,L as Y,bX as ru,bV as iu,bW as au,cV as ou,bP as lu,I as k,fK as cu,fL as hi,fM as uu,bd as gi,be as du,fN as fu,fO as mu,cY as Ds,ba as hu,bb as pu,aq as gu,as as wu,ar as vu,ap as xu,ao as si,e0 as bu,cI as yu,z as H,eN as ju,eM as Su,a5 as lo,au as Cu,d9 as Nu,fP as ir,_ as co,aw as ni,fQ as un,O as Fu,a2 as Eu,fR as dn,d7 as ku,e3 as ri,fS as ii,fT as uo,fU as fo,fV as mo,fW as ho,fX as Ru,fY as Tu,fZ as Mu,cN as Pu,f_ as Vu,ax as Du,f$ as Au,g0 as po,g1 as Lu,t as $o,q as _o,D as Wo,l as Uo,E as Go,o as Ho,aE as fr,aF as mr,aG as hr,aH as Vs,n as ai,aI as ar,aJ as oi,T as Wt,U as Ut,V as Gt,ag as zu,aj as Iu,bT as Ko,g2 as Ou,g3 as Bu,g4 as $u,ak as pr,g5 as _u,g6 as Wu,g7 as Uu,g8 as Gu,g9 as Hu,ga as Ku}from"./useAppFontEffects-3EN8Ava3.js";import{a as qu,c as go,s as Xu,P as Rs,C as Yu}from"./shikiHighlight-BRNXPlF-.js";import{a as qo,E as Ju,i as Xo,S as Yo,R as pi,l as Zu}from"./vendor-codemirror-state-Dek9sMtw.js";import{E as tt,k as wi,f as Qu,j as ed,m as td,g as sd,V as nd,G as rd}from"./vendor-codemirror-view-1e0FQ6Wn.js";import{v as id,A as ad,B as od,C as ld}from"./vendor-codemirror-language-BBADuAkg.js";import{D as cd,a as ud,m as dd,b as fd,G as md}from"./moveWorkspacePath-B31RGdgu.js";import{V as hd,J as pd,F as gd}from"./JsonTreeView-xGikhCtL.js";import{ensurePierreThemeRegistered as wo,getResolvedShikiTheme as wd}from"./appThemeRegistry-Bzb67M9O.js";import{V as vd,W as xd}from"./Virtualizer-BP6uuKe_.js";import{Z as bd,_ as yd,p as jd,D as Jo,F as Zo,z as Qo,A as Sd,$ as Cd,a0 as Nd}from"./runtimeEndpointReset-D6Lxhk0S.js";import{V as Fd}from"./Virtualizer-DL535kyR.js";import{D as Ed}from"./vendor-react-drawio-Ct3Q0DsD.js";import{e as kd,h as Rd}from"./vendor-codemirror-search-CvXM_pZg.js";import{a as Td,b as Md}from"./vendor-codemirror-autocomplete-C8FBSI9t.js";import{p as Pd}from"./parseDiffFromFile-DcsKSY0J.js";import{o as Vd,s as Dd}from"./vendor-zod-CVhJ1Zpv.js";import{u as Ad,n as Ld}from"./useInlineCommentController-l9cWyfuR.js";import{b as zd,F as vo}from"./FilePreviewCommentMenu-DlVgwRsr.js";import{b as Id}from"./scheduledTasksApi-DUbAMrjW.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-DgOf1DP0.js";import"./vendor-base-ui-CXFyogip.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-tanstack-react-virtual-CvuLsk7D.js";import"./vendor-tanstack-virtual-core-DPaNcJcT.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-BhRb6jns.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-CUmSxayT.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-lang-json-VDxF27mO.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-B2_PZTBl.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-BpvvTxbZ.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-CimQAQbQ.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-Cu5ZbrPm.js";import"./vendor-codemirror-lang-python-BFE1OJNx.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-capacitor-core-B4EWRrHz.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-legendapp-list-BCBzRcfK.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-replit-codemirror-vim-Ck2X_WZC.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./computeVirtualFileMetrics-WAp98Bb7.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isFilePlainText-Dk2R7BJo.js";import"./textMateThemeFromAppTheme-B6UJwdZz.js";import"./vendor-diff-C3JhlQdm.js";const Od=(r,e)=>{if(!e)return null;const a=Number.parseInt(r.trim(),10);return!Number.isFinite(a)||a<1?null:Math.min(a,e.state.doc.lines)},xo=(r,e)=>{const a=r.state.doc.lineAt(e.main.head);return{lineNumber:a.number,character:e.main.head-a.from+1,selection:e}},bo=(r,e,a)=>{const n=r.state.doc.line(e),c=Math.max(1,Math.min(a,n.length+1)),u=n.from+c-1;r.dispatch({selection:qo.cursor(u),effects:tt.scrollIntoView(u,{y:"center"})})};function Bd({open:r,onOpenChange:e,viewRef:a,variant:n="overlay"}){const{t:c}=Xe(),u=a.current,[w,m]=i.useState(""),p=i.useRef(null),j=i.useRef(!1),v=i.useRef(null),g=i.useRef(null),y=i.useMemo(()=>Od(w,u),[w,u]);i.useEffect(()=>{!r||!u||(j.current=!1,p.current=xo(u,u.state.selection),m(""))},[r,u]),i.useEffect(()=>{r&&window.requestAnimationFrame(()=>{g.current?.focus(),g.current?.select()})},[r]),i.useEffect(()=>{if(!(!r||!u||!p.current)){if(y===null){const{selection:b}=p.current;u.dispatch({selection:b,effects:tt.scrollIntoView(b.main.from,{y:"center"})});return}bo(u,y,p.current.character)}},[y,r,u]);const C=i.useCallback(()=>{if(!u||j.current||!p.current)return;const{selection:b}=p.current;u.dispatch({selection:b,effects:tt.scrollIntoView(b.main.from,{y:"center"})})},[u]),T=i.useRef(r);i.useEffect(()=>{T.current&&!r&&C(),T.current=r},[r,C]);const N=i.useCallback(b=>{b||C(),e(b)},[e,C]),E=i.useCallback(()=>{!u||y===null||!p.current||(j.current=!0,bo(u,y,p.current.character),e(!1),u.focus())},[y,e,u]);i.useEffect(()=>{if(!r)return;const b=P=>{const M=v.current,z=P.target;!M||!(z instanceof Element)||M.contains(z)||z.closest("[data-go-to-line-toggle]")||N(!1)},d=P=>{P.key==="Escape"&&(P.preventDefault(),N(!1))};return document.addEventListener("pointerdown",b,!0),document.addEventListener("keydown",d,!0),()=>{document.removeEventListener("pointerdown",b,!0),document.removeEventListener("keydown",d,!0)}},[N,r,n]);const R=i.useMemo(()=>{if(!u)return c("goToLineDialog.helper.editorUnavailable");if(y===null){const b=p.current??xo(u,u.state.selection);return c("goToLineDialog.helper.currentLineRange",{current:b.lineNumber,max:u.state.doc.lines})}return c("goToLineDialog.helper.goToLine",{line:y})},[y,c,u]);return n==="inline"?r?s.jsxs("div",{ref:v,"data-editor-overlay":!0,className:"ms-1 flex h-6 items-center gap-1",children:[s.jsx(pn,{ref:g,type:"number",min:1,step:1,inputMode:"numeric",value:w,onChange:b=>m(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),E())},placeholder:c("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),s.jsx($,{variant:"outline",size:"xs",onClick:E,disabled:!u||y===null,className:"h-6 px-2",children:c("goToLineDialog.actions.go")})]}):null:s.jsx("div",{ref:v,"data-editor-overlay":!0,className:Y("absolute inset-s-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",r?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:s.jsxs("div",{className:"min-w-0",children:[s.jsx(pn,{ref:g,type:"number",min:1,step:1,inputMode:"numeric",value:w,onChange:b=>m(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),E())},placeholder:c("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-surface-elevated/60 typography-ui-label"}),s.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:R})]})})}const $d=new Map(Object.entries({FunctionDeclaration:"function",FunctionDefinition:"function",FunctionItem:"function",FunctionDecl:"function",MethodDeclaration:"method",MethodDecl:"method",ClassDeclaration:"class",ClassDefinition:"class",InterfaceDeclaration:"class",StructItem:"class",TraitItem:"class",ImplItem:"class",TypeAliasDeclaration:"type",EnumDeclaration:"type",EnumItem:"type",TypeSpec:"type",ModItem:"module"})),_d=new Map([["VariableDeclaration","function"],["PropertyDeclaration","method"]]),Wd=new Set(["ArrowFunction","FunctionExpression"]),Ud=new Set(["VariableDefinition","PropertyDefinition","TypeDefinition","VariableName","DefName","FieldName","BoundIdentifier","TypeIdentifier"]),el=/^(?:ATXHeading|SetextHeading)([1-6])$/,tl=(r,e)=>{for(let a=r.firstChild;a;a=a.nextSibling)if(e.has(a.name))return a;return null},Gd=r=>{if(el.test(r.name))return"heading";const e=$d.get(r.name);if(e)return e;const a=_d.get(r.name);return a&&tl(r,Wd)?a:null},Hd=(r,e)=>r.doc.lineAt(e.from).text.replace(/^\s{0,3}#{1,6}\s*/,"").replace(/\s+#+\s*$/,"").trim(),Kd=(r,e=200)=>{const a=id(r,r.doc.length,e);if(!a)return[];const n=[],c=[];return a.iterate({enter:u=>{const w=Gd(u.node);if(!w)return;let m,p;if(w==="heading")m=Hd(r,u.node),p=u.from;else{const v=tl(u.node,Ud);if(!v)return;m=r.sliceDoc(v.from,v.to),p=v.from}if(!m)return;for(;c.length>0&&c[c.length-1]<=u.from;)c.pop();const j=w==="heading"?Number(el.exec(u.name)?.[1]??1)-1:c.length;n.push({name:m,kind:w,line:r.doc.lineAt(p).number,from:p,depth:j}),w!=="heading"&&c.push(u.to)}}),n},qd={function:"braces",method:"braces",class:"box-3",type:"code-box",module:"folder-3",heading:"text"},Xd="data-document-symbols-toggle";function yo({open:r,onOpenChange:e,viewRef:a}){const{t:n}=Xe(),c=a.current,u=i.useRef(null),[w,m]=i.useState([]),[p,j]=i.useState("");i.useEffect(()=>{r&&(j(""),m(c?Kd(c.state):[]))},[r,c]);const v=i.useCallback(()=>{e(!1),c?.focus()},[e,c]);i.useEffect(()=>{if(!r)return;const y=C=>{const T=C.target;!(T instanceof Element)||!u.current||u.current.contains(T)||T.closest(`[${Xd}]`)||e(!1)};return document.addEventListener("pointerdown",y,!0),()=>document.removeEventListener("pointerdown",y,!0)},[e,r]);const g=i.useCallback(y=>{c&&c.dispatch({selection:qo.cursor(y.from),effects:tt.scrollIntoView(y.from,{y:"center"})}),v()},[v,c]);return r?s.jsx("div",{ref:u,"data-editor-overlay":!0,className:"absolute inset-s-3 top-3 z-40 w-[min(28rem,calc(100%-1.5rem))] overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] shadow-lg",onKeyDown:y=>{y.key==="Escape"&&(y.preventDefault(),y.stopPropagation(),v())},children:s.jsxs(ru,{loop:!0,filter:(y,C)=>y.split("\0")[0].toLowerCase().includes(C.trim().toLowerCase())?1:0,className:"[&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1 [&_[cmdk-item]]:typography-meta",children:[s.jsx(iu,{autoFocus:!0,value:p,onValueChange:j,placeholder:n("filesView.symbols.placeholder"),"aria-label":n("filesView.symbols.placeholder")}),s.jsxs(au,{className:"max-h-[min(20rem,calc(100vh-16rem))]",children:[s.jsx(ou,{className:"px-3 py-4 typography-meta text-muted-foreground",children:w.length===0?n("filesView.symbols.noneInFile"):n("filesView.symbols.noMatches")}),w.map(y=>s.jsxs(lu,{value:`${y.name}\0${y.from}`,onSelect:()=>g(y),className:"gap-2",children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",style:{paddingInlineStart:`${y.depth*12}px`},children:[s.jsx(k,{name:qd[y.kind],className:"size-3.5 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 truncate text-foreground",children:y.name})]}),s.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:y.line})]},`${y.from}:${y.name}`))]})]})}):null}const Yd=(r,e)=>{const a=e.trim().toLowerCase(),n=[];if(!a)return n;const c=r.toLowerCase();let u=0;for(;;){const w=c.indexOf(a,u);if(w===-1)break;n.push({start:w,end:w+a.length}),u=w+a.length}return n},wr="data-md-find",li="data-md-find-current",sl="rounded-[2px] bg-status-warning/30 text-foreground",Jd="rounded-[2px] bg-status-warning/60 text-foreground",Zd=120,Qd=r=>r instanceof Element&&r.hasAttribute(wr),ef=r=>r.target instanceof Element&&r.target.hasAttribute(wr)?!0:[...r.addedNodes].some(e=>Qd(e)),nl=r=>{const e=new Set;r.querySelectorAll(`mark[${wr}]`).forEach(a=>{const n=a.parentNode;n&&(n.replaceChild(document.createTextNode(a.textContent??""),a),e.add(n))}),e.forEach(a=>a.normalize())},tf=(r,e)=>{nl(r);const a=e.trim().toLowerCase();if(!a)return[];const n=[],c=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode(w){const m=w.parentElement;return!m||m.closest("svg, script, style")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),u=[];for(;c.nextNode();){const w=c.currentNode;w instanceof Text&&u.push(w)}for(const w of u){const m=w.nodeValue??"";if(!m)continue;const p=Yd(m,a);if(p.length===0)continue;const j=w.parentNode;if(!j)continue;const v=document.createDocumentFragment();let g=0;for(const y of p){y.start>g&&v.appendChild(document.createTextNode(m.slice(g,y.start)));const C=document.createElement("mark");C.setAttribute(wr,""),C.className=sl,C.textContent=m.slice(y.start,y.end),v.appendChild(C),n.push(C),g=y.end}g<m.length&&v.appendChild(document.createTextNode(m.slice(g))),j.replaceChild(v,w)}return n},jo=({containerRef:r,open:e,onOpenChange:a,focusNonce:n,className:c})=>{const{t:u}=Xe(),[w,m]=i.useState(""),[p,j]=i.useState(0),[v,g]=i.useState(0),y=i.useRef(null),C=i.useRef([]),T=i.useRef(w);T.current=w;const N=i.useRef(null),E=i.useRef(null),R=i.useCallback((V,_=!1)=>{const A=r.current;if(!A){C.current=[],j(0),g(0);return}C.current=tf(A,V);const F=C.current.length;j(F),g(L=>!_||F===0?0:Math.min(L,F-1))},[r]),b=i.useCallback((V,_=!1)=>{N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{N.current=null,R(V,_)},Zd)},[R]);i.useEffect(()=>()=>{N.current&&clearTimeout(N.current)},[]);const d=i.useCallback(()=>{a(!1);const V=E.current;E.current=null,V?.isConnected&&V.focus()},[a]);i.useEffect(()=>{const V=r.current;if(!e||!V)return;const _=new MutationObserver(A=>{!T.current.trim()||!A.some(L=>!ef(L))||b(T.current,!0)});return _.observe(V,{childList:!0,subtree:!0,characterData:!0}),()=>{_.disconnect(),nl(V)}},[r,e,b]),i.useEffect(()=>{if(!e)return;const V=document.activeElement;V instanceof HTMLElement&&!E.current&&(E.current=V),y.current?.focus()},[e]),i.useEffect(()=>{e&&n>0&&(y.current?.focus(),y.current?.select())},[e,n]),i.useEffect(()=>{const V=r.current;if(!V||(V.querySelectorAll(`mark[${li}]`).forEach(A=>{A.removeAttribute(li),A.className=sl}),p===0))return;const _=C.current[Math.min(Math.max(v,0),p-1)];_&&(_.setAttribute(li,""),_.className=Jd,_.scrollIntoView({block:"nearest"}))},[r,v,p]);const P=i.useCallback(()=>{g(V=>p===0?0:(V+1)%p)},[p]),M=i.useCallback(()=>{g(V=>p===0?0:(V-1+p)%p)},[p]),z=i.useCallback(V=>{V.key==="Enter"?(V.preventDefault(),V.shiftKey?M():P()):V.key==="Escape"&&(V.preventDefault(),d())},[d,P,M]);return e?s.jsxs("div",{className:Y("absolute inset-e-3 top-3 z-10 flex items-center gap-1 rounded-lg border border-border/60 bg-[var(--surface-elevated)] px-1.5 py-1 shadow-lg",c),children:[s.jsx(k,{name:"search",className:"ms-0.5 size-3.5 text-muted-foreground"}),s.jsx(pn,{ref:y,value:w,onChange:V=>{m(V.target.value),b(V.target.value)},onKeyDown:z,placeholder:u("filesView.preview.find.placeholder"),"aria-label":u("filesView.preview.find.placeholder"),className:"h-7 w-40 rounded-md px-2 py-0 text-sm md:w-56"}),s.jsx("span",{className:"min-w-12 px-1 text-center typography-micro text-muted-foreground tabular-nums","aria-live":"polite","aria-label":p>0?u("filesView.preview.find.countAria",{current:v+1,total:p}):u("filesView.preview.find.noMatches"),children:w.trim()&&p===0?u("filesView.preview.find.noMatches"):p>0?`${v+1}/${p}`:""}),s.jsx($,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:M,title:u("filesView.preview.find.previousAria"),"aria-label":u("filesView.preview.find.previousAria"),disabled:p===0,children:s.jsx(k,{name:"arrow-up",className:"size-3.5"})}),s.jsx($,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:P,title:u("filesView.preview.find.nextAria"),"aria-label":u("filesView.preview.find.nextAria"),disabled:p===0,children:s.jsx(k,{name:"arrow-down",className:"size-3.5"})}),s.jsx($,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:d,title:u("filesView.preview.find.closeAria"),"aria-label":u("filesView.preview.find.closeAria"),children:s.jsx(k,{name:"close",className:"size-3.5"})})]}):null},sf=r=>{let e=!0;return{poll:async()=>{if(!e||r.isDirty())return!1;const a=r.getLoadedContent(),n=r.getLoadedRevision();try{const c=await r.readContent();if(!e||r.isDirty()||n!==r.getLoadedRevision())return!1;if(c===a)return!0;const u=await r.readContent();return!e||r.isDirty()||u!==c||n!==r.getLoadedRevision()?!1:(r.applyContent(c),!0)}catch{return!1}},dispose:()=>{e=!1}}},nf=1,So=({stat:r,showsFailure:e,sawMissing:a,hasUnsavedChanges:n,moving:c})=>r==="missing"?n||c?"none":"show-missing":r==="failed"?"none":e?a?"reload":"none":"check-changes",rf=(r,e)=>e.size!==r.size||e.mtimeMs!==void 0&&r.mtimeMs!==void 0&&Math.abs(e.mtimeMs-r.mtimeMs)>=nf,af=({selectedPath:r,targetPath:e,targetShown:a,targetSettled:n,showsText:c,canEdit:u,textViewMode:w})=>r!==e?a?"wait":"select-target":n?c?w==="edit"?"jump":u?"show-editor":"end":"end":"wait";function Co(){const r=Te.c(8),[e]=Et.useState(of),a=Et.useRef(!1);let n;r[0]!==e?(n=p=>{if(p==null){e.cleanUp(),a.current=!1;return}a.current||(a.current=!0,e.setup(p,p.firstElementChild??void 0))},r[0]=e,r[1]=n):n=r[1];const c=n;let u,w;r[2]!==e?(u=()=>()=>{a.current=!1,e.cleanUp()},w=[e],r[2]=e,r[3]=u,r[4]=w):(u=r[3],w=r[4]),Et.useLayoutEffect(u,w);let m;return r[5]!==c||r[6]!==e?(m={virtualizer:e,setScroller:c},r[5]=c,r[6]=e,r[7]=m):m=r[7],m}function of(){return new Fd}const Ts=new Map,lf=100;function or(r){const[e,a]=Et.useState(null),n=Et.useRef(null),c=Et.useRef(null),u=Et.useRef(null),w=Et.useCallback((m,p)=>{m&&p instanceof hd&&(u.current={key:r,file:p,node:m});const j=n.current,v=c.current,g=()=>{n.current===j&&(j?.(),v?.())};p?queueMicrotask(g):g()},[r]);return Et.useLayoutEffect(()=>{if(!e||!r)return;const m=Ts.get(r)??{top:0,left:0};let p=!0;const j=()=>u.current?.key===r?u.current.file:null,v=R=>u.current?.key===r?u.current.node.shadowRoot?.querySelector(`[data-line][data-line-index="${R-1}"]`):null,g=()=>{C.disconnect(),T.disconnect()},y=()=>{if(!p)return;const R=j(),b=m.line&&R?.getLinePosition(m.line.number),d=m.line&&v(m.line.number);let P=m.top;m.line&&b&&(P=(R?.top??0)+b.top-m.line.offset),m.line&&d&&(P=e.scrollTop+d.getBoundingClientRect().top-e.getBoundingClientRect().top-m.line.offset),e.scrollTop=P,e.scrollLeft=m.left,(!m.line||d)&&Math.abs(e.scrollTop-P)<1&&Math.abs(e.scrollLeft-m.left)<1&&(p=!1,g())},C=new ResizeObserver(y),T=new MutationObserver(()=>{if(p){for(const R of e.children)C.observe(R);y()}});C.observe(e);for(const R of e.children)C.observe(R);T.observe(e,{childList:!0,subtree:!0});const N=()=>{if(p)return;const R=j(),b=R?.getNumericScrollAnchor(e.scrollTop-(R.top??0)),d=b&&v(b.lineNumber),P=d?d.getBoundingClientRect().top-e.getBoundingClientRect().top:null;if(Ts.delete(r),Ts.set(r,{top:e.scrollTop,left:e.scrollLeft,line:b&&P!==null&&P>=0&&P<e.clientHeight?{number:b.lineNumber,offset:P}:void 0}),Ts.size>lf){const M=Ts.keys().next().value;M!==void 0&&Ts.delete(M)}},E=()=>{p=!1,g()};return n.current=y,c.current=N,y(),e.addEventListener("scroll",N,{passive:!0}),e.addEventListener("wheel",E,{passive:!0}),e.addEventListener("touchstart",E,{passive:!0}),e.addEventListener("pointerdown",E,{passive:!0}),e.addEventListener("keydown",E),()=>{n.current=null,c.current=null,u.current?.key===r&&(u.current=null),g(),e.removeEventListener("scroll",N),e.removeEventListener("wheel",E),e.removeEventListener("touchstart",E),e.removeEventListener("pointerdown",E),e.removeEventListener("keydown",E)}},[r,e]),{setScroller:a,restore:w}}function cf(r){return!(!r.autoSaveEnabled||!r.isDirty||!r.canWrite||r.isSaving||r.fileLoading||r.isNonEditableBinary||r.wouldEmptyFile||!r.selectedFilePath||r.loadedFilePath!==r.selectedFilePath)}function uf(r){return r.selectedFilePath?r.isDirty?!(r.fileLoading||r.loadedFilePath!==r.selectedFilePath||r.isNonEditableBinary||r.draftContent===""&&r.fileContent!==""&&r.loadedFilePath!==r.selectedFilePath):!0:!1}const rl=2e5,df=r=>{let e=0,a=0;for(let n=0;n<r.length;n++)r.charCodeAt(n)===10&&(n>0&&r.charCodeAt(n-1)===13?e++:a++);return e>a?`\r
|
|
1
|
+
import{R as i,j as s,f as Te,r as Et,c as Oc}from"./vendor-react-BUCujlKS.js";import{aT as Bc,Y as $e,l as mn,a0 as Bo,b0 as $c,ap as _c,b1 as Wc,b2 as Uc,aj as Gc,an as Hc,ai as Be,u as qe,b3 as Kc,aZ as dr,v as qc,b4 as oo,b5 as ti,b6 as Xc,b7 as Yc,a1 as Jc,aY as Zc,a2 as Qc,a3 as eu,a5 as tu,a4 as su,b8 as _t,b9 as nu}from"./katex.min-C-51hS9A.js";import{u as Xe,y as pn,B as $,L as Y,bX as ru,bV as iu,bW as au,cV as ou,bP as lu,I as k,fK as cu,fL as hi,fM as uu,bd as gi,be as du,fN as fu,fO as mu,cY as Ds,ba as hu,bb as pu,aq as gu,as as wu,ar as vu,ap as xu,ao as si,e0 as bu,cI as yu,z as H,eN as ju,eM as Su,a5 as lo,au as Cu,d9 as Nu,fP as ir,_ as co,aw as ni,fQ as un,O as Fu,a2 as Eu,fR as dn,d7 as ku,e3 as ri,fS as ii,fT as uo,fU as fo,fV as mo,fW as ho,fX as Ru,fY as Tu,fZ as Mu,cN as Pu,f_ as Vu,ax as Du,f$ as Au,g0 as po,g1 as Lu,t as $o,q as _o,D as Wo,l as Uo,E as Go,o as Ho,aE as fr,aF as mr,aG as hr,aH as Vs,n as ai,aI as ar,aJ as oi,T as Wt,U as Ut,V as Gt,ag as zu,aj as Iu,bT as Ko,g2 as Ou,g3 as Bu,g4 as $u,ak as pr,g5 as _u,g6 as Wu,g7 as Uu,g8 as Gu,g9 as Hu,ga as Ku}from"./useAppFontEffects-C1ceAD51.js";import{a as qu,c as go,s as Xu,P as Rs,C as Yu}from"./shikiHighlight-DOzrE7BE.js";import{a as qo,E as Ju,i as Xo,S as Yo,R as pi,l as Zu}from"./vendor-codemirror-state-Dek9sMtw.js";import{E as tt,k as wi,f as Qu,j as ed,m as td,g as sd,V as nd,G as rd}from"./vendor-codemirror-view-B66jUSmE.js";import{v as id,z as ad,A as od,B as ld}from"./vendor-codemirror-language-DkBxRck3.js";import{D as cd,a as ud,m as dd,b as fd,G as md}from"./moveWorkspacePath-BINgpJ9S.js";import{V as hd,J as pd,F as gd}from"./JsonTreeView-BKUmh7Iw.js";import{ensurePierreThemeRegistered as wo,getResolvedShikiTheme as wd}from"./appThemeRegistry-COeayQaQ.js";import{V as vd,W as xd}from"./Virtualizer-BP6uuKe_.js";import{Z as bd,_ as yd,p as jd,D as Jo,F as Zo,z as Qo,A as Sd,$ as Cd,a0 as Nd}from"./runtimeEndpointReset-ExJsaWzA.js";import{V as Fd}from"./Virtualizer-DNgIEKcx.js";import{D as Ed}from"./vendor-react-drawio-Ct3Q0DsD.js";import{e as kd,h as Rd}from"./vendor-codemirror-search-BKAwkhkm.js";import{a as Td,b as Md}from"./vendor-codemirror-autocomplete-BRKmCSiY.js";import{p as Pd}from"./parseDiffFromFile--DE4eHIp.js";import{o as Vd,s as Dd}from"./vendor-zod-CVhJ1Zpv.js";import{u as Ad,n as Ld}from"./useInlineCommentController-ynkUsoVA.js";import{b as zd,F as vo}from"./FilePreviewCommentMenu-Ca4ziuof.js";import{c as Id}from"./scheduledTasksApi-NSyxVfHu.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-DgOf1DP0.js";import"./vendor-base-ui-CXFyogip.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-tanstack-react-virtual-CvuLsk7D.js";import"./vendor-tanstack-virtual-core-DPaNcJcT.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-MmBpgSOc.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-DmPuKUEa.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-codemirror-streamparser-CmlTsbN2.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-lang-json-L0wsFFxi.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-DfdrZ848.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-C5kFuJzc.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-CPn-qinN.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CTYHXywt.js";import"./vendor-codemirror-lang-python-BAVa3Hg5.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-capacitor-core-B4EWRrHz.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-legendapp-list-BCBzRcfK.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-replit-codemirror-vim-D0bqFa1D.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./computeVirtualFileMetrics-MZqvCQy0.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isFilePlainText-B4SyJ-ni.js";import"./vendor-strip-json-comments-5dJlOkP1.js";import"./textMateThemeFromAppTheme-BfIrjFAU.js";import"./vendor-diff-C3JhlQdm.js";const Od=(r,e)=>{if(!e)return null;const a=Number.parseInt(r.trim(),10);return!Number.isFinite(a)||a<1?null:Math.min(a,e.state.doc.lines)},xo=(r,e)=>{const a=r.state.doc.lineAt(e.main.head);return{lineNumber:a.number,character:e.main.head-a.from+1,selection:e}},bo=(r,e,a)=>{const n=r.state.doc.line(e),c=Math.max(1,Math.min(a,n.length+1)),u=n.from+c-1;r.dispatch({selection:qo.cursor(u),effects:tt.scrollIntoView(u,{y:"center"})})};function Bd({open:r,onOpenChange:e,viewRef:a,variant:n="overlay"}){const{t:c}=Xe(),u=a.current,[w,m]=i.useState(""),p=i.useRef(null),j=i.useRef(!1),v=i.useRef(null),g=i.useRef(null),y=i.useMemo(()=>Od(w,u),[w,u]);i.useEffect(()=>{!r||!u||(j.current=!1,p.current=xo(u,u.state.selection),m(""))},[r,u]),i.useEffect(()=>{r&&window.requestAnimationFrame(()=>{g.current?.focus(),g.current?.select()})},[r]),i.useEffect(()=>{if(!(!r||!u||!p.current)){if(y===null){const{selection:b}=p.current;u.dispatch({selection:b,effects:tt.scrollIntoView(b.main.from,{y:"center"})});return}bo(u,y,p.current.character)}},[y,r,u]);const C=i.useCallback(()=>{if(!u||j.current||!p.current)return;const{selection:b}=p.current;u.dispatch({selection:b,effects:tt.scrollIntoView(b.main.from,{y:"center"})})},[u]),T=i.useRef(r);i.useEffect(()=>{T.current&&!r&&C(),T.current=r},[r,C]);const N=i.useCallback(b=>{b||C(),e(b)},[e,C]),E=i.useCallback(()=>{!u||y===null||!p.current||(j.current=!0,bo(u,y,p.current.character),e(!1),u.focus())},[y,e,u]);i.useEffect(()=>{if(!r)return;const b=P=>{const M=v.current,z=P.target;!M||!(z instanceof Element)||M.contains(z)||z.closest("[data-go-to-line-toggle]")||N(!1)},d=P=>{P.key==="Escape"&&(P.preventDefault(),N(!1))};return document.addEventListener("pointerdown",b,!0),document.addEventListener("keydown",d,!0),()=>{document.removeEventListener("pointerdown",b,!0),document.removeEventListener("keydown",d,!0)}},[N,r,n]);const R=i.useMemo(()=>{if(!u)return c("goToLineDialog.helper.editorUnavailable");if(y===null){const b=p.current??xo(u,u.state.selection);return c("goToLineDialog.helper.currentLineRange",{current:b.lineNumber,max:u.state.doc.lines})}return c("goToLineDialog.helper.goToLine",{line:y})},[y,c,u]);return n==="inline"?r?s.jsxs("div",{ref:v,"data-editor-overlay":!0,className:"ms-1 flex h-6 items-center gap-1",children:[s.jsx(pn,{ref:g,type:"number",min:1,step:1,inputMode:"numeric",value:w,onChange:b=>m(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),E())},placeholder:c("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),s.jsx($,{variant:"outline",size:"xs",onClick:E,disabled:!u||y===null,className:"h-6 px-2",children:c("goToLineDialog.actions.go")})]}):null:s.jsx("div",{ref:v,"data-editor-overlay":!0,className:Y("absolute inset-s-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",r?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:s.jsxs("div",{className:"min-w-0",children:[s.jsx(pn,{ref:g,type:"number",min:1,step:1,inputMode:"numeric",value:w,onChange:b=>m(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),E())},placeholder:c("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-surface-elevated/60 typography-ui-label"}),s.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:R})]})})}const $d=new Map(Object.entries({FunctionDeclaration:"function",FunctionDefinition:"function",FunctionItem:"function",FunctionDecl:"function",MethodDeclaration:"method",MethodDecl:"method",ClassDeclaration:"class",ClassDefinition:"class",InterfaceDeclaration:"class",StructItem:"class",TraitItem:"class",ImplItem:"class",TypeAliasDeclaration:"type",EnumDeclaration:"type",EnumItem:"type",TypeSpec:"type",ModItem:"module"})),_d=new Map([["VariableDeclaration","function"],["PropertyDeclaration","method"]]),Wd=new Set(["ArrowFunction","FunctionExpression"]),Ud=new Set(["VariableDefinition","PropertyDefinition","TypeDefinition","VariableName","DefName","FieldName","BoundIdentifier","TypeIdentifier"]),el=/^(?:ATXHeading|SetextHeading)([1-6])$/,tl=(r,e)=>{for(let a=r.firstChild;a;a=a.nextSibling)if(e.has(a.name))return a;return null},Gd=r=>{if(el.test(r.name))return"heading";const e=$d.get(r.name);if(e)return e;const a=_d.get(r.name);return a&&tl(r,Wd)?a:null},Hd=(r,e)=>r.doc.lineAt(e.from).text.replace(/^\s{0,3}#{1,6}\s*/,"").replace(/\s+#+\s*$/,"").trim(),Kd=(r,e=200)=>{const a=id(r,r.doc.length,e);if(!a)return[];const n=[],c=[];return a.iterate({enter:u=>{const w=Gd(u.node);if(!w)return;let m,p;if(w==="heading")m=Hd(r,u.node),p=u.from;else{const v=tl(u.node,Ud);if(!v)return;m=r.sliceDoc(v.from,v.to),p=v.from}if(!m)return;for(;c.length>0&&c[c.length-1]<=u.from;)c.pop();const j=w==="heading"?Number(el.exec(u.name)?.[1]??1)-1:c.length;n.push({name:m,kind:w,line:r.doc.lineAt(p).number,from:p,depth:j}),w!=="heading"&&c.push(u.to)}}),n},qd={function:"braces",method:"braces",class:"box-3",type:"code-box",module:"folder-3",heading:"text"},Xd="data-document-symbols-toggle";function yo({open:r,onOpenChange:e,viewRef:a}){const{t:n}=Xe(),c=a.current,u=i.useRef(null),[w,m]=i.useState([]),[p,j]=i.useState("");i.useEffect(()=>{r&&(j(""),m(c?Kd(c.state):[]))},[r,c]);const v=i.useCallback(()=>{e(!1),c?.focus()},[e,c]);i.useEffect(()=>{if(!r)return;const y=C=>{const T=C.target;!(T instanceof Element)||!u.current||u.current.contains(T)||T.closest(`[${Xd}]`)||e(!1)};return document.addEventListener("pointerdown",y,!0),()=>document.removeEventListener("pointerdown",y,!0)},[e,r]);const g=i.useCallback(y=>{c&&c.dispatch({selection:qo.cursor(y.from),effects:tt.scrollIntoView(y.from,{y:"center"})}),v()},[v,c]);return r?s.jsx("div",{ref:u,"data-editor-overlay":!0,className:"absolute inset-s-3 top-3 z-40 w-[min(28rem,calc(100%-1.5rem))] overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] shadow-lg",onKeyDown:y=>{y.key==="Escape"&&(y.preventDefault(),y.stopPropagation(),v())},children:s.jsxs(ru,{loop:!0,filter:(y,C)=>y.split("\0")[0].toLowerCase().includes(C.trim().toLowerCase())?1:0,className:"[&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1 [&_[cmdk-item]]:typography-meta",children:[s.jsx(iu,{autoFocus:!0,value:p,onValueChange:j,placeholder:n("filesView.symbols.placeholder"),"aria-label":n("filesView.symbols.placeholder")}),s.jsxs(au,{className:"max-h-[min(20rem,calc(100vh-16rem))]",children:[s.jsx(ou,{className:"px-3 py-4 typography-meta text-muted-foreground",children:w.length===0?n("filesView.symbols.noneInFile"):n("filesView.symbols.noMatches")}),w.map(y=>s.jsxs(lu,{value:`${y.name}\0${y.from}`,onSelect:()=>g(y),className:"gap-2",children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",style:{paddingInlineStart:`${y.depth*12}px`},children:[s.jsx(k,{name:qd[y.kind],className:"size-3.5 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 truncate text-foreground",children:y.name})]}),s.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:y.line})]},`${y.from}:${y.name}`))]})]})}):null}const Yd=(r,e)=>{const a=e.trim().toLowerCase(),n=[];if(!a)return n;const c=r.toLowerCase();let u=0;for(;;){const w=c.indexOf(a,u);if(w===-1)break;n.push({start:w,end:w+a.length}),u=w+a.length}return n},wr="data-md-find",li="data-md-find-current",sl="rounded-[2px] bg-status-warning/30 text-foreground",Jd="rounded-[2px] bg-status-warning/60 text-foreground",Zd=120,Qd=r=>r instanceof Element&&r.hasAttribute(wr),ef=r=>r.target instanceof Element&&r.target.hasAttribute(wr)?!0:[...r.addedNodes].some(e=>Qd(e)),nl=r=>{const e=new Set;r.querySelectorAll(`mark[${wr}]`).forEach(a=>{const n=a.parentNode;n&&(n.replaceChild(document.createTextNode(a.textContent??""),a),e.add(n))}),e.forEach(a=>a.normalize())},tf=(r,e)=>{nl(r);const a=e.trim().toLowerCase();if(!a)return[];const n=[],c=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode(w){const m=w.parentElement;return!m||m.closest("svg, script, style")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),u=[];for(;c.nextNode();){const w=c.currentNode;w instanceof Text&&u.push(w)}for(const w of u){const m=w.nodeValue??"";if(!m)continue;const p=Yd(m,a);if(p.length===0)continue;const j=w.parentNode;if(!j)continue;const v=document.createDocumentFragment();let g=0;for(const y of p){y.start>g&&v.appendChild(document.createTextNode(m.slice(g,y.start)));const C=document.createElement("mark");C.setAttribute(wr,""),C.className=sl,C.textContent=m.slice(y.start,y.end),v.appendChild(C),n.push(C),g=y.end}g<m.length&&v.appendChild(document.createTextNode(m.slice(g))),j.replaceChild(v,w)}return n},jo=({containerRef:r,open:e,onOpenChange:a,focusNonce:n,className:c})=>{const{t:u}=Xe(),[w,m]=i.useState(""),[p,j]=i.useState(0),[v,g]=i.useState(0),y=i.useRef(null),C=i.useRef([]),T=i.useRef(w);T.current=w;const N=i.useRef(null),E=i.useRef(null),R=i.useCallback((V,_=!1)=>{const A=r.current;if(!A){C.current=[],j(0),g(0);return}C.current=tf(A,V);const F=C.current.length;j(F),g(L=>!_||F===0?0:Math.min(L,F-1))},[r]),b=i.useCallback((V,_=!1)=>{N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{N.current=null,R(V,_)},Zd)},[R]);i.useEffect(()=>()=>{N.current&&clearTimeout(N.current)},[]);const d=i.useCallback(()=>{a(!1);const V=E.current;E.current=null,V?.isConnected&&V.focus()},[a]);i.useEffect(()=>{const V=r.current;if(!e||!V)return;const _=new MutationObserver(A=>{!T.current.trim()||!A.some(L=>!ef(L))||b(T.current,!0)});return _.observe(V,{childList:!0,subtree:!0,characterData:!0}),()=>{_.disconnect(),nl(V)}},[r,e,b]),i.useEffect(()=>{if(!e)return;const V=document.activeElement;V instanceof HTMLElement&&!E.current&&(E.current=V),y.current?.focus()},[e]),i.useEffect(()=>{e&&n>0&&(y.current?.focus(),y.current?.select())},[e,n]),i.useEffect(()=>{const V=r.current;if(!V||(V.querySelectorAll(`mark[${li}]`).forEach(A=>{A.removeAttribute(li),A.className=sl}),p===0))return;const _=C.current[Math.min(Math.max(v,0),p-1)];_&&(_.setAttribute(li,""),_.className=Jd,_.scrollIntoView({block:"nearest"}))},[r,v,p]);const P=i.useCallback(()=>{g(V=>p===0?0:(V+1)%p)},[p]),M=i.useCallback(()=>{g(V=>p===0?0:(V-1+p)%p)},[p]),z=i.useCallback(V=>{V.key==="Enter"?(V.preventDefault(),V.shiftKey?M():P()):V.key==="Escape"&&(V.preventDefault(),d())},[d,P,M]);return e?s.jsxs("div",{className:Y("absolute inset-e-3 top-3 z-10 flex items-center gap-1 rounded-lg border border-border/60 bg-[var(--surface-elevated)] px-1.5 py-1 shadow-lg",c),children:[s.jsx(k,{name:"search",className:"ms-0.5 size-3.5 text-muted-foreground"}),s.jsx(pn,{ref:y,value:w,onChange:V=>{m(V.target.value),b(V.target.value)},onKeyDown:z,placeholder:u("filesView.preview.find.placeholder"),"aria-label":u("filesView.preview.find.placeholder"),className:"h-7 w-40 rounded-md px-2 py-0 text-sm md:w-56"}),s.jsx("span",{className:"min-w-12 px-1 text-center typography-micro text-muted-foreground tabular-nums","aria-live":"polite","aria-label":p>0?u("filesView.preview.find.countAria",{current:v+1,total:p}):u("filesView.preview.find.noMatches"),children:w.trim()&&p===0?u("filesView.preview.find.noMatches"):p>0?`${v+1}/${p}`:""}),s.jsx($,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:M,title:u("filesView.preview.find.previousAria"),"aria-label":u("filesView.preview.find.previousAria"),disabled:p===0,children:s.jsx(k,{name:"arrow-up",className:"size-3.5"})}),s.jsx($,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:P,title:u("filesView.preview.find.nextAria"),"aria-label":u("filesView.preview.find.nextAria"),disabled:p===0,children:s.jsx(k,{name:"arrow-down",className:"size-3.5"})}),s.jsx($,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:d,title:u("filesView.preview.find.closeAria"),"aria-label":u("filesView.preview.find.closeAria"),children:s.jsx(k,{name:"close",className:"size-3.5"})})]}):null},sf=r=>{let e=!0;return{poll:async()=>{if(!e||r.isDirty())return!1;const a=r.getLoadedContent(),n=r.getLoadedRevision();try{const c=await r.readContent();if(!e||r.isDirty()||n!==r.getLoadedRevision())return!1;if(c===a)return!0;const u=await r.readContent();return!e||r.isDirty()||u!==c||n!==r.getLoadedRevision()?!1:(r.applyContent(c),!0)}catch{return!1}},dispose:()=>{e=!1}}},nf=1,So=({stat:r,showsFailure:e,sawMissing:a,hasUnsavedChanges:n,moving:c})=>r==="missing"?n||c?"none":"show-missing":r==="failed"?"none":e?a?"reload":"none":"check-changes",rf=(r,e)=>e.size!==r.size||e.mtimeMs!==void 0&&r.mtimeMs!==void 0&&Math.abs(e.mtimeMs-r.mtimeMs)>=nf,af=({selectedPath:r,targetPath:e,targetShown:a,targetSettled:n,showsText:c,canEdit:u,textViewMode:w})=>r!==e?a?"wait":"select-target":n?c?w==="edit"?"jump":u?"show-editor":"end":"end":"wait";function Co(){const r=Te.c(8),[e]=Et.useState(of),a=Et.useRef(!1);let n;r[0]!==e?(n=p=>{if(p==null){e.cleanUp(),a.current=!1;return}a.current||(a.current=!0,e.setup(p,p.firstElementChild??void 0))},r[0]=e,r[1]=n):n=r[1];const c=n;let u,w;r[2]!==e?(u=()=>()=>{a.current=!1,e.cleanUp()},w=[e],r[2]=e,r[3]=u,r[4]=w):(u=r[3],w=r[4]),Et.useLayoutEffect(u,w);let m;return r[5]!==c||r[6]!==e?(m={virtualizer:e,setScroller:c},r[5]=c,r[6]=e,r[7]=m):m=r[7],m}function of(){return new Fd}const Ts=new Map,lf=100;function or(r){const[e,a]=Et.useState(null),n=Et.useRef(null),c=Et.useRef(null),u=Et.useRef(null),w=Et.useCallback((m,p)=>{m&&p instanceof hd&&(u.current={key:r,file:p,node:m});const j=n.current,v=c.current,g=()=>{n.current===j&&(j?.(),v?.())};p?queueMicrotask(g):g()},[r]);return Et.useLayoutEffect(()=>{if(!e||!r)return;const m=Ts.get(r)??{top:0,left:0};let p=!0;const j=()=>u.current?.key===r?u.current.file:null,v=R=>u.current?.key===r?u.current.node.shadowRoot?.querySelector(`[data-line][data-line-index="${R-1}"]`):null,g=()=>{C.disconnect(),T.disconnect()},y=()=>{if(!p)return;const R=j(),b=m.line&&R?.getLinePosition(m.line.number),d=m.line&&v(m.line.number);let P=m.top;m.line&&b&&(P=(R?.top??0)+b.top-m.line.offset),m.line&&d&&(P=e.scrollTop+d.getBoundingClientRect().top-e.getBoundingClientRect().top-m.line.offset),e.scrollTop=P,e.scrollLeft=m.left,(!m.line||d)&&Math.abs(e.scrollTop-P)<1&&Math.abs(e.scrollLeft-m.left)<1&&(p=!1,g())},C=new ResizeObserver(y),T=new MutationObserver(()=>{if(p){for(const R of e.children)C.observe(R);y()}});C.observe(e);for(const R of e.children)C.observe(R);T.observe(e,{childList:!0,subtree:!0});const N=()=>{if(p)return;const R=j(),b=R?.getNumericScrollAnchor(e.scrollTop-(R.top??0)),d=b&&v(b.lineNumber),P=d?d.getBoundingClientRect().top-e.getBoundingClientRect().top:null;if(Ts.delete(r),Ts.set(r,{top:e.scrollTop,left:e.scrollLeft,line:b&&P!==null&&P>=0&&P<e.clientHeight?{number:b.lineNumber,offset:P}:void 0}),Ts.size>lf){const M=Ts.keys().next().value;M!==void 0&&Ts.delete(M)}},E=()=>{p=!1,g()};return n.current=y,c.current=N,y(),e.addEventListener("scroll",N,{passive:!0}),e.addEventListener("wheel",E,{passive:!0}),e.addEventListener("touchstart",E,{passive:!0}),e.addEventListener("pointerdown",E,{passive:!0}),e.addEventListener("keydown",E),()=>{n.current=null,c.current=null,u.current?.key===r&&(u.current=null),g(),e.removeEventListener("scroll",N),e.removeEventListener("wheel",E),e.removeEventListener("touchstart",E),e.removeEventListener("pointerdown",E),e.removeEventListener("keydown",E)}},[r,e]),{setScroller:a,restore:w}}function cf(r){return!(!r.autoSaveEnabled||!r.isDirty||!r.canWrite||r.isSaving||r.fileLoading||r.isNonEditableBinary||r.wouldEmptyFile||!r.selectedFilePath||r.loadedFilePath!==r.selectedFilePath)}function uf(r){return r.selectedFilePath?r.isDirty?!(r.fileLoading||r.loadedFilePath!==r.selectedFilePath||r.isNonEditableBinary||r.draftContent===""&&r.fileContent!==""&&r.loadedFilePath!==r.selectedFilePath):!0:!1}const rl=2e5,df=r=>{let e=0,a=0;for(let n=0;n<r.length;n++)r.charCodeAt(n)===10&&(n>0&&r.charCodeAt(n-1)===13?e++:a++);return e>a?`\r
|
|
2
2
|
`:`
|
|
3
3
|
`},il=r=>r.replace(/\r\n/g,`
|
|
4
4
|
`).replace(/\r/g,`
|
|
@@ -6,9 +6,9 @@ import{R as i,j as s,f as Te,r as Et,c as Oc}from"./vendor-react-BUCujlKS.js";im
|
|
|
6
6
|
`?a.replace(/\n/g,`\r
|
|
7
7
|
`):a},hf=(r,e)=>e??(r.length>rl?"view":"edit"),pf=r=>{let e=2166136261;for(let a=0;a<r.length;a++)e^=r.charCodeAt(a),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return`${r.length}:${e.toString(16)}`},gf='<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>';function No(){if(typeof document>"u")return!1;const r=document.documentElement.getAttribute("data-theme");return r==="dark"||!r&&window.matchMedia("(prefers-color-scheme: dark)").matches}const wf=i.forwardRef(function({xml:e,readOnly:a,className:n,onChange:c},u){const w=i.useRef(e),m=i.useRef(null),p=i.useRef(!1),[j,v]=i.useState(No),g=i.useRef(e),y=i.useRef(e);y.current!==e&&(y.current=e,g.current=e,w.current=e);const C=i.useRef(j);C.current!==j&&(C.current=j,g.current=w.current);const T=i.useRef(null);i.useEffect(()=>{const R=()=>v(No());R();const b=new MutationObserver(R);return b.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>b.disconnect()},[]),i.useEffect(()=>{const R=setTimeout(()=>{T.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(R)},[]),i.useImperativeHandle(u,()=>({getXml:()=>w.current}));const N=i.useCallback(()=>{!e&&!p.current&&(p.current=!0,setTimeout(()=>{m.current?.template({})},500))},[e]),E=i.useCallback(R=>{w.current=R.xml,c?.(R.xml)},[c]);return s.jsx("div",{ref:T,className:Y("h-full w-full",n),children:s.jsx(Ed,{ref:m,xml:g.current||gf,autosave:!0,urlParameters:{ui:a?"simple":j?"dark":"kennedy",spin:!0,libraries:!a,chrome:a,nav:a,layers:a,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:N,onAutoSave:E},j?"dark":"light")})}),ci={ok:!0,snapshot:null},vf=r=>r.hasCanvas&&r.viewMode==="preview"&&r.previewReady&&r.mountable,Fo=r=>r.slice(r.replace(/\\/g,"/").lastIndexOf("/")+1)||r,xf=i.forwardRef(function(e,a){const{guestId:n,editorId:c,title:u,contentKind:w,path:m,content:p,readOnly:j}=e,{t:v}=Xe(),g=i.useRef(e);g.current=e;const y=i.useCallback(R=>cu(R,{onChange:b=>{b.edited&&g.current.onEdit(),g.current.onDirtyChange(b.dirty)},onSave:()=>g.current.onSaveRequest(),onUnsupported:()=>g.current.onUnsupported()}),[]),[C,T]=i.useState(()=>w==="text"?y({path:m,name:Fo(m),readOnly:j,encoding:"text",content:p}):null),[N]=i.useState(()=>({contentKind:w,path:m,readOnly:j}));i.useEffect(()=>{if(N.contentKind!=="binary")return;let R=!1;return g.current.loadBytes().then(b=>{if(!R){if(b.byteLength>hi){g.current.onTooLarge();return}T(y({path:N.path,name:Fo(N.path),readOnly:N.readOnly,encoding:"binary",bytes:b}))}},()=>{R||g.current.onLoadFailed()}),()=>{R=!0}},[N,y]),i.useImperativeHandle(a,()=>({getContent:async R=>{const b={ok:!1,message:v("filesView.fileEditor.snapshotFailed",{editor:u})};if(!C)return b;try{const d=await C.requestSnapshot(R);return"bytes"in d?w==="binary"?{ok:!0,snapshot:{bytes:d.bytes,signature:d.version}}:b:w==="text"?{ok:!0,snapshot:{content:d.content,signature:d.version}}:b}catch{return b}},markSaved:R=>{C?.markSaved(R),g.current.onDirtyChange(!1)}}),[C,w,v,u]);const E=i.useMemo(()=>C?{editorId:c,channel:C}:null,[C,c]);return E?s.jsx(uu,{mode:Bc(n),surface:"file",fileEditor:E}):s.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:v("common.loading")})}),bf=r=>r.slice(r.replace(/\\/g,"/").lastIndexOf("/")+1),al=(r,e)=>{const a=bf(e);if(!a)return null;for(const n of r)if(!(!n.fileEditors?.length||!du(n))){for(const c of n.fileEditors)if(c.match.some(u=>fu(a,u)))return{guestId:n.id,editor:c}}return null},yf=r=>{const e=Te.c(3),a=gi(jf);let n;return e[0]!==r||e[1]!==a?(n=r?al(a,r):null,e[0]=r,e[1]=a,e[2]=n):n=e[2],n};function jf(r){return r.guests}const Sf=od.filter(r=>r.mac!==void 0),Cf=r=>{const e=document.createElement("span");e.className="cm-fold-marker";const a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("viewBox","0 0 24 24"),a.setAttribute("aria-hidden","true");const n=document.createElementNS("http://www.w3.org/2000/svg","use");return n.setAttribute("href",r?"#oc-arrow-down-s":"#oc-arrow-right-s"),a.appendChild(n),e.appendChild(a),e},Nf=()=>[ad({markerDOM:Cf}),wi.of(Sf),tt.theme({".cm-foldGutter":{width:"12px"},".cm-foldGutter .cm-gutterElement":{display:"flex",alignItems:"center",justifyContent:"center",padding:"0"},".cm-gutters:has(> .cm-foldGutter)":{paddingRight:"2px"},".cm-fold-marker":{display:"inline-flex",width:"12px",height:"12px",cursor:"pointer",opacity:"0.6"},".cm-fold-marker:hover":{opacity:"1"},".cm-fold-marker svg":{width:"12px",height:"12px",fill:"currentColor"}})],Ff=()=>[ld(),Td(),wi.of(Md)],Ef=({vimMode:r})=>[Ju.allowMultipleSelections.of(!0),Qu(),ed(),td(),r?[]:wi.of([{key:"Mod-d",run:kd,preventDefault:!0}])],kf=300,Rf=1e6,Tf=(r,e)=>{const a=new Map;if(r===e)return a;const n=Pd({name:"file",contents:r},{name:"file",contents:e});for(const c of n.hunks)for(const u of c.hunkContent){if(u.type!=="change")continue;if(u.additions===0){const m=u.additionLineIndex<=0,p=m?1:u.additionLineIndex;a.has(p)||a.set(p,m?"deletedAbove":"deleted");continue}const w=u.deletions===0?"added":"modified";for(let m=0;m<u.additions;m+=1)a.set(u.additionLineIndex+m+1,w)}return a};class lr extends rd{constructor(e){super(),this.kind=e}eq(e){return e.kind===this.kind}toDOM(){const e=document.createElement("div");return e.className=`cm-git-change cm-git-change-${this.kind}`,e}}const Mf={added:new lr("added"),modified:new lr("modified"),deleted:new lr("deleted"),deletedAbove:new lr("deletedAbove")},Pf=(r,e)=>{const a=new Zu;for(const n of[...e.keys()].sort((c,u)=>c-u)){if(n<1||n>r.lines)continue;const c=e.get(n);c&&a.add(r.line(n).from,r.line(n).from,Mf[c])}return a.finish()},vr=Yo.define(),ol=Yo.define(),vi=Xo.define({create:()=>null,update(r,e){for(const a of e.effects)if(a.is(vr))return a.value;return r}}),Eo=Xo.define({create:()=>pi.empty,update(r,e){for(const a of e.effects){if(a.is(ol))return a.value;if(a.is(vr)&&a.value===null)return pi.empty}return e.docChanged?r.map(e.changes):r}}),Vf=nd.fromClass(class{constructor(r){this.view=r}timer=null;update(r){r.transactions.some(a=>a.effects.some(n=>n.is(vr)))?this.schedule(0):r.docChanged&&this.schedule(kf)}schedule(r){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=null;const{state:e}=this.view,a=e.field(vi),n=e.doc.toString(),c=a!==null&&Math.max(a.length,n.length)>Rf,u=a===null||c?pi.empty:Pf(e.doc,Tf(a,n));this.view.dispatch({effects:ol.of(u)})},r)}destroy(){this.timer&&clearTimeout(this.timer)}}),Df=r=>[vi,Eo,Vf,sd({class:"cm-git-gutter",markers:e=>e.state.field(Eo)}),tt.theme({".cm-git-gutter":{width:"6px"},".cm-git-gutter .cm-gutterElement":{position:"relative"},".cm-git-change":{position:"absolute",left:"1px",width:"3px",top:"0",bottom:"0"},".cm-git-change-added":{backgroundColor:r.added},".cm-git-change-modified":{backgroundColor:r.modified},".cm-git-change-deleted, .cm-git-change-deletedAbove":{top:"auto",height:"6px",width:"5px",left:"0",backgroundColor:r.removed,clipPath:"polygon(0 0, 100% 50%, 0 100%)"},".cm-git-change-deleted":{bottom:"-3px"},".cm-git-change-deletedAbove":{top:"-3px",bottom:"auto"}})],Af=(r,e)=>{r.state.field(vi,!1)!==void 0&&r.dispatch({effects:vr.of(e)})},gn=r=>{const e=Te.c(18),{items:a,actions:n,className:c}=r;let u,w,m,p;if(e[0]!==n||e[1]!==c||e[2]!==a){p=Symbol.for("react.early_return_sentinel");e:{const y=a.filter(Lf);if(y.length===0&&!n){p=null;break e}e[7]!==c?(m=Y("flex min-h-7 items-center gap-2 border-b border-border/40 bg-[var(--surface-subtle)] px-3 py-1",c),e[7]=c,e[8]=m):m=e[8],u="min-w-0 flex-1 truncate typography-meta text-muted-foreground",w=y.join(" · ")}e[0]=n,e[1]=c,e[2]=a,e[3]=u,e[4]=w,e[5]=m,e[6]=p}else u=e[3],w=e[4],m=e[5],p=e[6];if(p!==Symbol.for("react.early_return_sentinel"))return p;let j;e[9]!==u||e[10]!==w?(j=s.jsx("div",{className:u,children:w}),e[9]=u,e[10]=w,e[11]=j):j=e[11];let v;e[12]!==n?(v=n?s.jsx("div",{className:"flex shrink-0 items-center gap-1",children:n}):null,e[12]=n,e[13]=v):v=e[13];let g;return e[14]!==m||e[15]!==j||e[16]!==v?(g=s.jsxs("div",{className:m,children:[j,v]}),e[14]=m,e[15]=j,e[16]=v,e[17]=g):g=e[17],g};function Lf(r){return r.length>0}const wn=r=>{if(r===null||!Number.isFinite(r)||r<0)return"";if(r<1024)return`${r} B`;const e=["KB","MB","GB"];let a=r/1024;for(const n of e){if(a<1024||n===e[e.length-1])return`${a.toFixed(a>=10?0:1)} ${n}`;a/=1024}return""},zf=r=>{if(r===null||!Number.isFinite(r)||r<0)return"";const e=Math.round(r),a=Math.floor(e/3600),n=Math.floor(e%3600/60),c=e%60,u=w=>String(w).padStart(2,"0");return a>0?`${a}:${u(n)}:${u(c)}`:`${n}:${u(c)}`},ll=r=>r&&r.width>0&&r.height>0?`${r.width} × ${r.height}`:"",If=r=>{const e=Te.c(28),{name:a,path:n,sizeBytes:c,download:u}=r,{t:w}=Xe();let m,p,j,v,g,y,C;if(e[0]!==a||e[1]!==n||e[2]!==c||e[3]!==w){const R=mu(n).toUpperCase();y="flex h-full min-h-0 flex-col",C=s.jsx(gn,{items:[R,wn(c)]}),j="flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",e[11]!==n?(v=s.jsx(Ds,{filePath:n,className:"size-10"}),e[11]=n,e[12]=v):v=e[12],e[13]!==a?(g=s.jsx("div",{className:"max-w-full truncate typography-ui-header text-foreground",children:a}),e[13]=a,e[14]=g):g=e[14],m="max-w-md typography-ui text-muted-foreground",p=R?w("filesView.artifact.binary.descriptionWithType",{extension:R}):w("filesView.artifact.binary.description"),e[0]=a,e[1]=n,e[2]=c,e[3]=w,e[4]=m,e[5]=p,e[6]=j,e[7]=v,e[8]=g,e[9]=y,e[10]=C}else m=e[4],p=e[5],j=e[6],v=e[7],g=e[8],y=e[9],C=e[10];let T;e[15]!==m||e[16]!==p?(T=s.jsx("div",{className:m,children:p}),e[15]=m,e[16]=p,e[17]=T):T=e[17];let N;e[18]!==u||e[19]!==j||e[20]!==v||e[21]!==g||e[22]!==T?(N=s.jsxs("div",{className:j,children:[v,g,T,u]}),e[18]=u,e[19]=j,e[20]=v,e[21]=g,e[22]=T,e[23]=N):N=e[23];let E;return e[24]!==y||e[25]!==C||e[26]!==N?(E=s.jsxs("div",{className:y,children:[C,N]}),e[24]=y,e[25]=C,e[26]=N,e[27]=E):E=e[27],E},Of=[48,32,24,18,14],Bf=["ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz",`0123456789 .,;:!?&@#%()[]{}<>+-=/\\*"'`];let ui=0;const $f=r=>{const e=Te.c(16),{src:a,name:n,sizeBytes:c}=r,{t:u}=Xe(),[w,m]=i.useState("loading"),[p]=i.useState(_f);let j,v;e[0]!==p||e[1]!==a?(j=()=>{let N=!1;m("loading");const E=new FontFace(p,`url("${a.replace(/"/g,"%22")}")`);return document.fonts.add(E),E.load().then(()=>{N||m("ready")}).catch(()=>{N||m("failed")}),()=>{N=!0,document.fonts.delete(E)}},v=[p,a],e[0]=p,e[1]=a,e[2]=j,e[3]=v):(j=e[2],v=e[3]),i.useEffect(j,v);let g;e[4]!==c?(g=wn(c),e[4]=c,e[5]=g):g=e[5];let y;e[6]!==n||e[7]!==g?(y=s.jsx(gn,{items:[n,g]}),e[6]=n,e[7]=g,e[8]=y):y=e[8];let C;e[9]!==p||e[10]!==w||e[11]!==u?(C=w==="failed"?s.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-center typography-ui text-muted-foreground",children:u("filesView.artifact.font.loadFailed")}):w==="loading"?s.jsxs("div",{className:"flex items-center gap-2 p-3 typography-ui text-muted-foreground",children:[s.jsx(k,{name:"loader-4",className:"size-4 animate-spin"}),u("common.loading")]}):s.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-4",style:{fontFamily:`"${p}"`},children:s.jsxs("div",{className:"flex flex-col gap-4",children:[Of.map(N=>s.jsxs("div",{className:"flex items-baseline gap-3",children:[s.jsx("span",{className:"w-8 shrink-0 text-end font-sans typography-meta text-muted-foreground",children:N}),s.jsx("span",{className:"min-w-0 break-words leading-tight text-foreground",style:{fontSize:`${N}px`},children:u("filesView.artifact.font.sample")})]},N)),s.jsx("div",{className:"mt-2 flex flex-col gap-1 border-t border-border/40 pt-4 text-foreground",style:{fontSize:"20px"},children:Bf.map(Wf)})]})}),e[9]=p,e[10]=w,e[11]=u,e[12]=C):C=e[12];let T;return e[13]!==y||e[14]!==C?(T=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[y,C]}),e[13]=y,e[14]=C,e[15]=T):T=e[15],T};function _f(){return ui=ui+1,`oc-font-preview-${ui}`}function Wf(r){return s.jsx("div",{className:"break-all leading-relaxed",children:r},r)}const gr=12,cl=.1,ul=16,ko=[.1,.25,.5,.75,1,1.5,2,3,4,6,8,12,16],Uf=16,Ro=30,Gf=(r,e)=>{const a=e.width-gr*2,n=e.height-gr*2;return r.width<=0||r.height<=0||a<=0||n<=0?1:Math.min(1,a/r.width,n/r.height)},Hf=(r,e)=>Math.min(ul,Math.max(Math.min(cl,e),r)),To=(r,e)=>e===1?ko.find(a=>a>r*1.001)??ul:[...ko].reverse().find(a=>a<r*.999)??cl,Kf=(r,e)=>{const a=e===1?r*Uf:r,n=Math.max(-Ro,Math.min(Ro,a));return Math.exp(-n/100)},Mo=(r,e)=>Math.hypot(r.clientX-e.clientX,r.clientY-e.clientY),qf=({src:r,name:e,sizeBytes:a})=>{const{t:n}=Xe(),[c,u]=i.useState(null),[w,m]=i.useState(null),[p,j]=i.useState(null),[v,g]=i.useState(!1),y=i.useRef(null),C=i.useRef(null),T=i.useRef(null),N=i.useRef(null);i.useEffect(()=>{m(null),u(null)},[r]),i.useEffect(()=>{const F=y.current;if(!F)return;const L=new ResizeObserver(()=>{j({width:F.clientWidth,height:F.clientHeight})});return L.observe(F),()=>L.disconnect()},[]);const E=w&&p?Gf(w,p):1,R=c??E,b=c!==null&&w!==null&&p!==null&&(w.width*c+gr*2>p.width||w.height*c+gr*2>p.height),d=(F,L,O)=>{const X=C.current;if(!X||!w)return;const te=X.getBoundingClientRect(),ie=X.clientWidth/w.width;ie<=0||(T.current={imageX:(L-te.left-X.clientLeft)/ie,imageY:(O-te.top-X.clientTop)/ie,clientX:L,clientY:O},Oc.flushSync(()=>u(Hf(F,E))))},P=F=>{const L=y.current;if(!L)return;const O=L.getBoundingClientRect();d(F,O.left+O.width/2,O.top+O.height/2)};i.useLayoutEffect(()=>{const F=T.current,L=y.current,O=C.current;if(T.current=null,!F||!L||!O||c===null||O.naturalWidth<=0)return;const X=O.getBoundingClientRect(),te=O.clientWidth/O.naturalWidth;L.scrollLeft+=X.left+O.clientLeft+F.imageX*te-F.clientX,L.scrollTop+=X.top+O.clientTop+F.imageY*te-F.clientY},[c]);const M=i.useRef({zoomTo:d,shownScale:R});M.current={zoomTo:d,shownScale:R},i.useEffect(()=>{const F=y.current;if(!F)return;let L=0,O=null,X=null;const te=B=>{if(!B.ctrlKey&&!B.metaKey)return;B.preventDefault();const Se=M.current;Se.zoomTo(Se.shownScale*Kf(B.deltaY,B.deltaMode),B.clientX,B.clientY)},ie=B=>{L=B.touches.length,B.touches.length===2&&(O={distance:Mo(B.touches[0],B.touches[1]),scale:M.current.shownScale})},pe=B=>{if(!O||B.touches.length!==2||O.distance<=0)return;B.preventDefault();const[Se,oe]=[B.touches[0],B.touches[1]];M.current.zoomTo(O.scale*(Mo(Se,oe)/O.distance),(Se.clientX+oe.clientX)/2,(Se.clientY+oe.clientY)/2)},ae=B=>{L=B.touches.length,B.touches.length<2&&(O=null)},me=B=>{B.preventDefault(),X=L>0?null:M.current.shownScale},ce=B=>{B.preventDefault(),X!==null&&M.current.zoomTo(X*B.scale,B.clientX,B.clientY)},ge=B=>{B.preventDefault(),X=null};return F.addEventListener("wheel",te,{passive:!1}),F.addEventListener("touchstart",ie,{passive:!0}),F.addEventListener("touchmove",pe,{passive:!1}),F.addEventListener("touchend",ae,{passive:!0}),F.addEventListener("touchcancel",ae,{passive:!0}),F.addEventListener("gesturestart",me),F.addEventListener("gesturechange",ce),F.addEventListener("gestureend",ge),()=>{F.removeEventListener("wheel",te),F.removeEventListener("touchstart",ie),F.removeEventListener("touchmove",pe),F.removeEventListener("touchend",ae),F.removeEventListener("touchcancel",ae),F.removeEventListener("gesturestart",me),F.removeEventListener("gesturechange",ce),F.removeEventListener("gestureend",ge)}},[]);const z=F=>{if(!b||F.pointerType!=="mouse"||F.button!==0)return;const L=F.currentTarget,O=L.getBoundingClientRect();F.clientX-O.left>=L.clientWidth||F.clientY-O.top>=L.clientHeight||(F.preventDefault(),L.setPointerCapture(F.pointerId),N.current={pointerId:F.pointerId,x:F.clientX,y:F.clientY,left:L.scrollLeft,top:L.scrollTop},g(!0))},V=F=>{const L=N.current;!L||L.pointerId!==F.pointerId||(F.currentTarget.scrollLeft=L.left-(F.clientX-L.x),F.currentTarget.scrollTop=L.top-(F.clientY-L.y))},_=F=>{N.current?.pointerId===F.pointerId&&(N.current=null,g(!1))},A=F=>{if(c===null){d(1,F.clientX,F.clientY);return}u(null)};return s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[s.jsx(gn,{items:[ll(w),wn(a)],actions:s.jsxs(s.Fragment,{children:[s.jsx($,{variant:"ghost",size:"xs","aria-label":n("filesView.artifact.image.zoomOut"),title:n("filesView.artifact.image.zoomOut"),disabled:!w,onClick:()=>P(To(R,-1)),children:s.jsx(k,{name:"subtract",className:"size-3.5"})}),s.jsx($,{variant:"ghost",size:"xs",className:"min-w-11 tabular-nums",title:n("filesView.artifact.image.actualTitle"),disabled:!w,onClick:()=>P(1),children:`${Math.round(R*100)}%`}),s.jsx($,{variant:"ghost",size:"xs","aria-label":n("filesView.artifact.image.zoomIn"),title:n("filesView.artifact.image.zoomIn"),disabled:!w,onClick:()=>P(To(R,1)),children:s.jsx(k,{name:"add",className:"size-3.5"})}),s.jsx($,{variant:"chip",size:"xs","aria-pressed":c===null,title:n("filesView.artifact.image.fitTitle"),onClick:()=>u(null),children:n("filesView.artifact.image.fit")})]})}),s.jsx("div",{ref:y,className:Y("min-h-0 flex-1 overflow-auto",b&&(v?"cursor-grabbing":"cursor-grab")),onPointerDown:z,onPointerMove:V,onPointerUp:_,onPointerCancel:_,onDoubleClick:A,children:s.jsx("div",{className:Y("flex items-center justify-center p-3",c===null?"h-full w-full":"min-h-full min-w-full w-max"),children:s.jsx("img",{ref:C,src:r,alt:e,draggable:!1,onLoad:F=>{const L=F.currentTarget;m({width:L.naturalWidth,height:L.naturalHeight})},style:c!==null&&w?{width:w.width*c,height:w.height*c}:void 0,className:Y("select-none rounded-md border border-border/30 bg-primary/10",c===null?"max-h-full max-w-full object-contain":"max-w-none shrink-0")},r)})})]})},Xf=r=>{const e=Te.c(24),{kind:a,src:n,name:c,sizeBytes:u,download:w}=r,{t:m}=Xe(),[p,j]=i.useState(null),[v,g]=i.useState(null),[y,C]=i.useState(!1);let T;e[0]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{j(null),g(null),C(!1)},e[0]=T):T=e[0];let N;e[1]!==n?(N=[n],e[1]=n,e[2]=N):N=e[2],i.useEffect(T,N);let E;e[3]===Symbol.for("react.memo_cache_sentinel")?(E=_=>{const A=_.currentTarget;j(Number.isFinite(A.duration)?A.duration:null),A instanceof HTMLVideoElement&&g({width:A.videoWidth,height:A.videoHeight})},e[3]=E):E=e[3];const R=E;let b;e[4]!==p?(b=zf(p),e[4]=p,e[5]=b):b=e[5];let d;e[6]!==v?(d=ll(v),e[6]=v,e[7]=d):d=e[7];let P;e[8]!==u?(P=wn(u),e[8]=u,e[9]=P):P=e[9];let M;e[10]!==b||e[11]!==d||e[12]!==P?(M=s.jsx(gn,{items:[b,d,P]}),e[10]=b,e[11]=d,e[12]=P,e[13]=M):M=e[13];let z;e[14]!==w||e[15]!==y||e[16]!==a||e[17]!==c||e[18]!==n||e[19]!==m?(z=y?s.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:m("filesView.artifact.media.unplayable")}),w]}):a==="video"?s.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center bg-[var(--surface-background)] p-3",children:s.jsx("video",{src:n,controls:!0,playsInline:!0,preload:"metadata",title:c,className:"max-h-full max-w-full rounded-md",onLoadedMetadata:R,onError:()=>C(!0)},n)}):s.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4 p-6",children:[s.jsx("div",{className:"typography-ui-label truncate text-foreground",children:c}),s.jsx("audio",{src:n,controls:!0,preload:"metadata",title:c,className:"w-full max-w-lg",onLoadedMetadata:R,onError:()=>C(!0)},n)]}),e[14]=w,e[15]=y,e[16]=a,e[17]=c,e[18]=n,e[19]=m,e[20]=z):z=e[20];let V;return e[21]!==M||e[22]!==z?(V=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[M,z]}),e[21]=M,e[22]=z,e[23]=V):V=e[23],V},Yf=2e3,Jf=r=>r.toLowerCase().endsWith(".tsv")?" ":",",Zf=(r,e,a=Yf)=>{const n=[];let c=0,u="",w=[],m=!1,p=!1;const j=()=>{w.push(u),u="",w.length===1&&w[0]===""&&!p||((c===0||n.length<=a)&&n.push(w),c+=1),w=[],p=!1},v=r.charCodeAt(0)===65279?r.slice(1):r;for(let N=0;N<v.length;N+=1){const E=v[N];if(m){E==='"'?v[N+1]==='"'?(u+='"',N+=1):m=!1:u+=E;continue}if(E==='"'){m=!0,p=!0;continue}if(E===e){w.push(u),u="",p=!0;continue}if(E===`
|
|
8
8
|
`||E==="\r"){E==="\r"&&v[N+1]===`
|
|
9
|
-
`&&(N+=1),j();continue}u+=E}(u.length>0||w.length>0||m)&&j();const g=n[0]??[],y=n.slice(1),C=n.reduce((N,E)=>Math.max(N,E.length),0),T=Math.max(0,c-1);return{header:g,rows:y,totalRows:T,columnCount:C,truncated:y.length<T}},Qf=r=>{const e=Te.c(29),{path:a,content:n,sizeBytes:c}=r,{t:u}=Xe();let w;e[0]!==n||e[1]!==a?(w=Zf(n,Jf(a)),e[0]=n,e[1]=a,e[2]=w):w=e[2];const m=w;let p;e[3]!==u||e[4]!==m.columnCount||e[5]!==m.totalRows?(p=m.totalRows===1?u("filesView.artifact.table.rowsSingle",{rows:m.totalRows,columns:m.columnCount}):u("filesView.artifact.table.rowsPlural",{rows:m.totalRows,columns:m.columnCount}),e[3]=u,e[4]=m.columnCount,e[5]=m.totalRows,e[6]=p):p=e[6];const j=p;let v;e[7]!==m.columnCount?(v=Array.from({length:m.columnCount},em),e[7]=m.columnCount,e[8]=v):v=e[8];const g=v;let y;e[9]!==u||e[10]!==m.rows||e[11]!==m.totalRows||e[12]!==m.truncated?(y=m.truncated?u("filesView.artifact.table.truncated",{shown:m.rows.length,total:m.totalRows}):"",e[9]=u,e[10]=m.rows,e[11]=m.totalRows,e[12]=m.truncated,e[13]=y):y=e[13];let C;e[14]!==c?(C=wn(c),e[14]=c,e[15]=C):C=e[15];let T;e[16]!==j||e[17]!==y||e[18]!==C?(T=s.jsx(gn,{items:[j,y,C]}),e[16]=j,e[17]=y,e[18]=C,e[19]=T):T=e[19];let N;e[20]!==g||e[21]!==u||e[22]!==m.columnCount||e[23]!==m.header||e[24]!==m.rows?(N=m.columnCount===0?s.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:u("filesView.artifact.table.empty")}):s.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:s.jsxs("table",{className:"min-w-full border-separate border-spacing-0 font-mono typography-meta",children:[s.jsx("thead",{className:"sticky top-0 z-10 bg-[var(--surface-subtle)]",children:s.jsx("tr",{children:g.map(R=>s.jsx("th",{scope:"col",className:"whitespace-nowrap border-b border-e border-border/40 px-2 py-1 text-start font-medium text-foreground last:border-e-0",children:m.header[R]??""},R))})}),s.jsx("tbody",{children:m.rows.map((R,b)=>s.jsx("tr",{className:"odd:bg-[var(--surface-background)] even:bg-[var(--surface-subtle)]/40",children:g.map(d=>s.jsx("td",{className:"max-w-[32rem] truncate border-b border-e border-border/30 px-2 py-1 align-top text-foreground last:border-e-0",title:R[d]??"",children:R[d]??""},d))},b))})]})}),e[20]=g,e[21]=u,e[22]=m.columnCount,e[23]=m.header,e[24]=m.rows,e[25]=N):N=e[25];let E;return e[26]!==T||e[27]!==N?(E=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[T,N]}),e[26]=T,e[27]=N,e[28]=E):E=e[28],E};function em(r,e){return e}const Ms="data-oc-local-asset",tm=25*1024*1024,cr=r=>{const e=r.trim();return!e||e.startsWith("#")||e.startsWith("//")?!1:!/^[a-z][a-z\d+.-]*:/i.test(e)},sm=r=>r.split(/[?#]/,1)[0]??"",nm=r=>r.trim().toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").replace(/\s+/g,"-"),rm=(r,e)=>{const a=dl(e.replace(/^#/,"")).toLowerCase();if(!a)return!1;for(const n of Array.from(r.querySelectorAll("h1, h2, h3, h4, h5, h6")))if(n.id===a||nm(n.textContent??"")===a)return n.scrollIntoView({block:"start"}),!0;return!1},dl=r=>{try{return decodeURIComponent(r)}catch{return r}},im=r=>r.split(",").flatMap(e=>{const[a,...n]=e.trim().split(/\s+/);return a?[{url:a,descriptor:n.join(" ")}]:[]}),di="data-oc-media",am=/\(\s*prefers-color-scheme\s*:\s*(light|dark)\s*\)/gi,Po=(r,e)=>{for(const a of Array.from(r.querySelectorAll("picture > source[media]"))){const n=a.getAttribute(di)??a.getAttribute("media")??"",c=n.replace(am,(u,w)=>w.toLowerCase()===e?"(min-width: 0px)":"(max-width: -1px)");c!==n&&(a.getAttribute(di)!==n&&a.setAttribute(di,n),a.getAttribute("media")!==c&&a.setAttribute("media",c))}},Vo=({container:r,filePath:e,workspaceRoot:a,onOpenFile:n,enabled:c,colorScheme:u})=>{const w=i.useRef(n);w.current=n;const m=i.useRef(u);m.current=u,i.useEffect(()=>{c&&r&&Po(r,u)},[u,r,c]),i.useEffect(()=>{if(!c||!r||!e)return;const p=e.slice(0,e.lastIndexOf("/")+1)||"/",j=b=>hu(p,dl(sm(b))),v=b=>({path:b,allowOutsideWorkspace:a&&pu(b,a)?void 0:"true",directory:a||void 0});let g=!1;const y=$e(),C=new Map,T=b=>{const d=C.get(b);if(d)return d;const P=(async()=>{const M=await mn("/api/fs/raw",{query:v(b),signal:AbortSignal.timeout(3e4)});if(!M.ok)throw new Error(`Image read failed (${M.status})`);const z=await M.blob();if(z.size>tm)throw new Error("Image too large for preview");if(g||$e()!==y)throw new Error("Preview closed");return URL.createObjectURL(z)})();return C.set(b,P),P.catch(()=>C.delete(b)),P},N=()=>{for(const b of Array.from(r.querySelectorAll("img[src]"))){const d=b.getAttribute("src")??"";if(!cr(d))continue;const P=j(d);b.setAttribute(Ms,P),T(P).then(M=>{g||b.getAttribute(Ms)!==P||b.getAttribute("src")!==M&&(b.src=M)}).catch(()=>{g||b.removeAttribute(Ms)})}for(const b of Array.from(r.querySelectorAll("source[srcset], img[srcset]"))){const d=im(b.getAttribute("srcset")??"");if(!d.some(z=>cr(z.url)))continue;const P=d.map(z=>({...z,path:cr(z.url)?j(z.url):null})),M=P.map(z=>z.path??z.url).join(",");b.setAttribute(Ms,M),Promise.all(P.map(async({url:z,descriptor:V,path:_})=>{const A=_?await T(_):z;return V?`${A} ${V}`:A})).then(z=>{if(g||b.getAttribute(Ms)!==M)return;const V=z.join(", ");b.getAttribute("srcset")!==V&&b.setAttribute("srcset",V)}).catch(()=>{g||b.removeAttribute(Ms)})}Po(r,m.current)},E=b=>{if(b.defaultPrevented||b.button!==0||b.metaKey||b.ctrlKey||b.shiftKey||b.altKey)return;const d=b.target;if(!(d instanceof Element))return;const P=d.closest("a[href]");if(!(P instanceof HTMLAnchorElement)||!r.contains(P))return;const M=P.getAttribute("href")??"";if(M.startsWith("#")){b.preventDefault(),b.stopPropagation(),rm(r,M);return}cr(M)&&(b.preventDefault(),b.stopPropagation(),w.current(j(M)))};N();const R=new MutationObserver(N);return R.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["src","srcset","media"]}),r.addEventListener("click",E,!0),()=>{g=!0,R.disconnect(),r.removeEventListener("click",E,!0);for(const b of C.values())b.then(d=>URL.revokeObjectURL(d)).catch(()=>{})}},[r,c,e,a])},om=Vd({grant:Dd().min(1)}),lm=async(r,e,a=mn)=>{const n=await a("/api/fs/preview",{method:"POST",signal:e,query:{directory:r.directory||void 0},headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r.path})});if(!n.ok)throw new Error(`Preview grant request failed (${n.status})`);const c=om.safeParse(await n.json().catch(()=>null));if(!c.success)throw new Error("Preview grant response was invalid");return c.data.grant},cm=(r,e)=>{const a=e.split("/").map(c=>encodeURIComponent(c)).join("/"),n=a.startsWith("/")?a:`/${a}`;return Bo().api(`/api/fs/preview/${encodeURIComponent(r)}${n}`)},um=(r,e,a)=>{const n=Te.c(8),c=lm;let u;n[0]===Symbol.for("react.memo_cache_sentinel")?(u={status:"idle"},n[0]=u):u=n[0];const[w,m]=i.useState(u),p=r?.path??"",j=r?.directory??"",v=r?.revision??"";let g,y;return n[1]!==j||n[2]!==e||n[3]!==c||n[4]!==p||n[5]!==v?(g=()=>{if(!p){m({status:"idle"});return}const C=new AbortController;return m({status:"loading"}),(async()=>{try{const N=await c({path:p,directory:j,revision:v},C.signal);C.signal.aborted||m({status:"ready",url:cm(N,p)})}catch(N){const E=N;if(C.signal.aborted)return;m({status:"error",message:E instanceof Error?E.message:e})}})(),()=>C.abort()},y=[p,j,v,e,c],n[1]=j,n[2]=e,n[3]=c,n[4]=p,n[5]=v,n[6]=g,n[7]=y):(g=n[6],y=n[7]),i.useEffect(g,y),w},Ls=[];let Do=!1;const Ao=()=>{$c()&&_c("desktop_set_close_tab_target",{active:Ls.length>0})},dm=()=>{Ls[Ls.length-1]?.()},fm=r=>(Do||(window.addEventListener("openchamber:close-tab",dm),Do=!0),Ls.push(r),Ao(),()=>{const e=Ls.lastIndexOf(r);e>=0&&Ls.splice(e,1),Ao()}),mm=r=>{const e=ee(r);if(!e)return"";if(e==="/"||/^[A-Za-z]:\/$/.test(e))return e;const a=e.lastIndexOf("/");if(a<0)return e;if(a===0)return"/";const n=e.slice(0,a);return/^[A-Za-z]:$/.test(n)?`${n}/`:n},hm=r=>{const e=Te.c(8),{label:a,iconDataUrl:n}=r,[c,u]=i.useState(!1);let w;e[0]!==a?(w=a.trim().slice(0,1).toUpperCase()||"?",e[0]=a,e[1]=w):w=e[1];const m=w;if(n&&!c){let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=()=>u(!0),e[2]=v):v=e[2];let g;return e[3]!==n?(g=s.jsx("img",{src:n,alt:"",className:"size-4 rounded-sm",onError:v}),e[3]=n,e[4]=g):g=e[4],g}let p;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=Y("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=p):p=e[5];let j;return e[6]!==m?(j=s.jsx("span",{className:p,children:m}),e[6]=m,e[7]=j):j=e[7],j},pm=r=>r.slice().sort((e,a)=>e.type!==a.type?e.type==="directory"?-1:1:e.name.localeCompare(a.name)),ee=r=>{if(!r)return"";const e=r.replace(/\\/g,"/"),a=e.startsWith("//");let n=e.replace(/\/+/g,"/");a&&!n.startsWith("//")&&(n=`/${n}`);const c=n==="/",u=/^[A-Za-z]:\/$/.test(n);return!c&&!u&&(n=n.replace(/\/+$/,"")),n},gm=r=>r.startsWith("/")||r.startsWith("//")||/^[A-Za-z]:\//.test(r),As=r=>/^[A-Za-z]:\//.test(r)?r.toLowerCase():r,hn=(r,e)=>{const a=ee(e),n=ee(r);if(!a||!n)return!1;const c=As(a),u=As(n);return u===c||u.startsWith(`${c}/`)},Lo=(r,e)=>{const a=ee(e),n=ee(r);if(!hn(n,a))return[];const u=n.slice(a.length).replace(/^\//,"").split("/"),w=[];let m=a;for(let p=0;p<u.length-1;p++)m=m?`${m}/${u[p]}`:u[p],w.push(m);return w},fn=(r,e)=>{if(!e)return"";const a=ee(e);if(!r||!hn(a,r))return a;const n=a.slice(r.length);return n.startsWith("/")?n.slice(1):n},wm=new Set(["node_modules"]),zo=r=>{const e=Te.c(11),{name:a}=r,n=i.useRef(null),c=i.useRef(null),[u,w]=i.useState(!1);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{const y=n.current,C=c.current;if(!y||!C)return;const T=()=>{w(C.scrollWidth>y.clientWidth+1)};T();const N=new ResizeObserver(T);return N.observe(y),N.observe(C),()=>{N.disconnect()}},e[0]=m):m=e[0];let p;e[1]!==a?(p=[a],e[1]=a,e[2]=p):p=e[2],i.useLayoutEffect(m,p);let j;e[3]!==a?(j=s.jsx("span",{ref:c,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:a}),e[3]=a,e[4]=j):j=e[4];let v;e[5]!==a||e[6]!==u?(v=u?s.jsxs("span",{className:"open-file-name-marquee-track",children:[s.jsx("span",{className:"open-file-name-marquee-item",children:a}),s.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:a})]}):s.jsx("span",{className:"block min-w-0 truncate",children:a}),e[5]=a,e[6]=u,e[7]=v):v=e[7];let g;return e[8]!==j||e[9]!==v?(g=s.jsxs("span",{ref:n,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[j,v]}),e[8]=j,e[9]=v,e[10]=g):g=e[10],g},vm=r=>wm.has(r),xm=r=>{const e=ee(r);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},bm=r=>{const a=(r instanceof Error?r.message:String(r??"")).toLowerCase();return a.includes("is a directory")||a.includes("eisdir")},ym=2e5,fi=r=>{if(!r)return!1;const e=r.toLowerCase();if(e.endsWith(".excalidraw.md"))return!1;const a=e.split(".").pop();return a==="md"||a==="markdown"},mi=r=>!!(r&&al(gi.getState().guests,r)),Io=r=>{if(!r)return!1;const e=r.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},ur=r=>{if(!r)return!1;const e=r.toLowerCase().split(".").pop();return e==="html"||e==="htm"},jm=r=>{const e=Te.c(87),{node:a,root:n,isExpanded:c,isActive:u,isMobile:w,isBrowserClient:m,alwaysShowActions:p,depth:j,isOpen:v,status:g,badge:y,permissions:C,downloadFile:T,contextMenuPath:N,setContextMenuPath:E,rightClickMenuPath:R,setRightClickMenuPath:b,onSelect:d,onToggle:P,onRevealPath:M,onOpenDialog:z,canUpload:V,onPickFiles:_}=r,{t:A}=Xe(),F=a.type==="directory",{canRename:L,canCreateFile:O,canCreateFolder:X,canDelete:te,canReveal:ie}=C,pe=!F&&!!T,ae=ie&&!m,me=F&&V,ce=L||O||X||me||te||pe||ae;let ge;e[0]!==ce||e[1]!==a.path||e[2]!==b?(ge=de=>{ce&&(de?.preventDefault(),b(a.path))},e[0]=ce,e[1]=a.path,e[2]=b,e[3]=ge):ge=e[3];const B=ge;let Se;e[4]!==F||e[5]!==a||e[6]!==d||e[7]!==P?(Se=()=>{F?P(a.path):d(a)},e[4]=F,e[5]=a,e[6]=d,e[7]=P,e[8]=Se):Se=e[8];const oe=Se;let kt;e[9]!==a.path||e[10]!==E||e[11]!==b?(kt=de=>{de.stopPropagation(),b(null),E(a.path)},e[9]=a.path,e[10]=E,e[11]=b,e[12]=kt):kt=e[12];const is=kt;let Ht;e[13]!==O||e[14]!==X||e[15]!==te||e[16]!==L||e[17]!==ae||e[18]!==me||e[19]!==T||e[20]!==m||e[21]!==F||e[22]!==a||e[23]!==z||e[24]!==_||e[25]!==M||e[26]!==n||e[27]!==A?(Ht=de=>{const{Item:he,Separator:at}=de;return s.jsxs(s.Fragment,{children:[L&&s.jsxs(he,{onClick:Z=>{Z.stopPropagation(),z("rename",a)},children:[s.jsx(k,{name:"edit",className:"me-2 size-4"})," ",A("sidebarFilesTree.menu.rename")]}),s.jsxs(he,{onClick:Z=>{Z.stopPropagation(),pr(a.path).then(Pe=>{if(Pe.ok){H.success(A("sidebarFilesTree.toast.pathCopied"));return}H.error(A("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(k,{name:"file-copy",className:"me-2 size-4"})," ",A("sidebarFilesTree.menu.copyPath")]}),s.jsxs(he,{onClick:Z=>{Z.stopPropagation();const Pe=fn(n,a.path)||a.path;pr(Pe).then(vn=>{if(vn.ok){H.success(A("filesView.toast.relativePathCopied"));return}H.error(A("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(k,{name:"file-copy-2",className:"me-2 size-4"})," ",A("filesView.tree.menu.copyRelativePath")]}),!F&&T&&s.jsxs(he,{onClick:Z=>{Z.stopPropagation(),T(a.path).catch(Pe=>{console.error("Download failed:",Pe),H.error(A("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(k,{name:"download",className:"me-2 size-4"})," ",A(m?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),ae&&s.jsxs(he,{onClick:Z=>{Z.stopPropagation(),M(a.path)},children:[s.jsx(k,{name:"folder-received",className:"me-2 size-4"})," ",A(Gu())]}),!F&&ae&&Zc()&&s.jsxs(he,{onClick:Z=>{Z.stopPropagation(),dr(a.path).then(Pe=>{Pe||H.error(A("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(k,{name:"external-link",className:"me-2 size-4"})," ",A("sidebarFilesTree.menu.openInDefaultApp")]}),F&&(O||X||me)&&s.jsxs(s.Fragment,{children:[s.jsx(at,{}),O&&s.jsxs(he,{onClick:Z=>{Z.stopPropagation(),z("createFile",a)},children:[s.jsx(k,{name:"file-add",className:"me-2 size-4"})," ",A("sidebarFilesTree.menu.newFile")]}),X&&s.jsxs(he,{onClick:Z=>{Z.stopPropagation(),z("createFolder",a)},children:[s.jsx(k,{name:"folder-add",className:"me-2 size-4"})," ",A("sidebarFilesTree.menu.newFolder")]}),me&&s.jsxs(he,{onClick:Z=>{Z.stopPropagation(),_(a.path)},children:[s.jsx(k,{name:"upload-2",className:"me-2 size-4"})," ",A("sidebarFilesTree.menu.uploadFiles")]})]}),te&&s.jsxs(s.Fragment,{children:[s.jsx(at,{}),s.jsxs(he,{onClick:Z=>{Z.stopPropagation(),z("delete",a)},className:"text-destructive focus:text-destructive",children:[s.jsx(k,{name:"delete-bin",className:"me-2 size-4"})," ",A("sidebarFilesTree.menu.delete")]})]})]})},e[13]=O,e[14]=X,e[15]=te,e[16]=L,e[17]=ae,e[18]=me,e[19]=T,e[20]=m,e[21]=F,e[22]=a,e[23]=z,e[24]=_,e[25]=M,e[26]=n,e[27]=A,e[28]=Ht):Ht=e[28];const st=Ht,as=R===a.path;let wt;e[29]!==a.path||e[30]!==b?(wt=de=>b(de?a.path:null),e[29]=a.path,e[30]=b,e[31]=wt):wt=e[31];const nt=w?void 0:B;let Rt;e[32]!==nt?(Rt=s.jsx("div",{className:"group relative flex items-center",onContextMenu:nt}),e[32]=nt,e[33]=Rt):Rt=e[33];let Ye;e[34]!==j?(Ye=s.jsx(Zo,{depth:j}),e[34]=j,e[35]=Ye):Ye=e[35];const zs=w?void 0:B;let Je;e[36]!==u?(Je=Y("flex w-full items-center gap-1.5 rounded-md py-1 pe-8 text-start transition-colors select-none",Jo(u)),e[36]=u,e[37]=Je):Je=e[37];let Tt;e[38]!==j?(Tt=Qo(j),e[38]=j,e[39]=Tt):Tt=e[39];let vt;e[40]!==Tt?(vt={paddingLeft:Tt},e[40]=Tt,e[41]=vt):vt=e[41];let Mt;e[42]!==F||e[43]!==c||e[44]!==a.extension||e[45]!==a.path?(Mt=F?s.jsx(Sd,{expanded:c}):s.jsx(Ds,{filePath:a.path,extension:a.extension,className:"ms-0.5 size-3.5"}),e[42]=F,e[43]=c,e[44]=a.extension,e[45]=a.path,e[46]=Mt):Mt=e[46];let re;e[47]!==a.name||e[48]!==a.path?(re=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:a.path,children:a.name}),e[47]=a.name,e[48]=a.path,e[49]=re):re=e[49];let Me;e[50]!==F||e[51]!==v||e[52]!==g?(Me=!F&&s.jsx(Cd,{isOpen:v,status:g}),e[50]=F,e[51]=v,e[52]=g,e[53]=Me):Me=e[53];let Ze;e[54]!==y||e[55]!==F?(Ze=F&&y&&s.jsx(Nd,{badge:y}),e[54]=y,e[55]=F,e[56]=Ze):Ze=e[56];let rt;e[57]!==oe||e[58]!==zs||e[59]!==Je||e[60]!==vt||e[61]!==Mt||e[62]!==re||e[63]!==Me||e[64]!==Ze?(rt=s.jsxs("button",{type:"button",onClick:oe,onContextMenu:zs,className:Je,style:vt,children:[Mt,re,Me,Ze]}),e[57]=oe,e[58]=zs,e[59]=Je,e[60]=vt,e[61]=Mt,e[62]=re,e[63]=Me,e[64]=Ze,e[65]=rt):rt=e[65];let Ce;e[66]!==p||e[67]!==N||e[68]!==is||e[69]!==ce||e[70]!==w||e[71]!==a.path||e[72]!==st||e[73]!==E?(Ce=ce&&s.jsx("div",{className:Y("absolute inset-e-1 top-1/2 -translate-y-1/2",p?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:s.jsxs(fr,{open:N===a.path,onOpenChange:de=>E(de?a.path:null),children:[s.jsx(mr,{asChild:!0,children:s.jsx($,{variant:"ghost",size:"icon",className:"size-6",onClick:is,children:s.jsx(k,{name:"more-2-fill",className:"size-4"})})}),s.jsx(hr,{align:"end",side:"bottom",onCloseAutoFocus:()=>E(null),children:st({Item:Vs,Separator:Ko})})]})}),e[66]=p,e[67]=N,e[68]=is,e[69]=ce,e[70]=w,e[71]=a.path,e[72]=st,e[73]=E,e[74]=Ce):Ce=e[74];let it;e[75]!==rt||e[76]!==Ce||e[77]!==Rt||e[78]!==Ye?(it=s.jsxs(Hu,{render:Rt,children:[Ye,rt,Ce]}),e[75]=rt,e[76]=Ce,e[77]=Rt,e[78]=Ye,e[79]=it):it=e[79];let Ne;e[80]!==st?(Ne=s.jsx(_u,{className:"min-w-[180px]",children:st({Item:Uu,Separator:Wu})}),e[80]=st,e[81]=Ne):Ne=e[81];let Pt;return e[82]!==it||e[83]!==Ne||e[84]!==as||e[85]!==wt?(Pt=s.jsxs(Ku,{open:as,onOpenChange:wt,children:[it,Ne]}),e[82]=it,e[83]=Ne,e[84]=as,e[85]=wt,e[86]=Pt):Pt=e[86],Pt},Sm=r=>{const e=Te.c(83),{activeDialog:a,dialogData:n,dialogInputValue:c,onDialogInputChange:u,isDialogSubmitting:w,onDialogSubmit:m,onClose:p,inputRef:j}=r,{t:v}=Xe(),g=!!a;let y;e[0]!==p?(y=ce=>!ce&&p(),e[0]=p,e[1]=y):y=e[1];let C;e[2]!==a||e[3]!==v?(C=a==="createFile"&&v("filesView.dialog.createFile.title"),e[2]=a,e[3]=v,e[4]=C):C=e[4];let T;e[5]!==a||e[6]!==v?(T=a==="createFolder"&&v("filesView.dialog.createFolder.title"),e[5]=a,e[6]=v,e[7]=T):T=e[7];let N;e[8]!==a||e[9]!==v?(N=a==="rename"&&v("filesView.dialog.rename.title"),e[8]=a,e[9]=v,e[10]=N):N=e[10];let E;e[11]!==a||e[12]!==v?(E=a==="delete"&&v("filesView.dialog.delete.title"),e[11]=a,e[12]=v,e[13]=E):E=e[13];let R;e[14]!==C||e[15]!==T||e[16]!==N||e[17]!==E?(R=s.jsxs(Uo,{children:[C,T,N,E]}),e[14]=C,e[15]=T,e[16]=N,e[17]=E,e[18]=R):R=e[18];let b;e[19]!==a||e[20]!==n?.path||e[21]!==v?(b=a==="createFile"&&v("filesView.dialog.createFile.description",{path:n?.path??v("filesView.dialog.rootFallback")}),e[19]=a,e[20]=n?.path,e[21]=v,e[22]=b):b=e[22];let d;e[23]!==a||e[24]!==n?.path||e[25]!==v?(d=a==="createFolder"&&v("filesView.dialog.createFolder.description",{path:n?.path??v("filesView.dialog.rootFallback")}),e[23]=a,e[24]=n?.path,e[25]=v,e[26]=d):d=e[26];let P;e[27]!==a||e[28]!==n?.name||e[29]!==v?(P=a==="rename"&&v("filesView.dialog.rename.description",{name:n?.name??""}),e[27]=a,e[28]=n?.name,e[29]=v,e[30]=P):P=e[30];let M;e[31]!==a||e[32]!==n?.name||e[33]!==v?(M=a==="delete"&&v("filesView.dialog.delete.description",{name:n?.name??""}),e[31]=a,e[32]=n?.name,e[33]=v,e[34]=M):M=e[34];let z;e[35]!==P||e[36]!==M||e[37]!==b||e[38]!==d?(z=s.jsxs(Go,{children:[b,d,P,M]}),e[35]=P,e[36]=M,e[37]=b,e[38]=d,e[39]=z):z=e[39];let V;e[40]!==z||e[41]!==R?(V=s.jsxs(Wo,{children:[R,z]}),e[40]=z,e[41]=R,e[42]=V):V=e[42];let _;e[43]!==a||e[44]!==c||e[45]!==j||e[46]!==u||e[47]!==m||e[48]!==v?(_=a!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(pn,{value:c,onChange:ce=>u(ce.target.value),placeholder:v(a==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:ce=>{ce.key==="Enter"&&m()},ref:j})}),e[43]=a,e[44]=c,e[45]=j,e[46]=u,e[47]=m,e[48]=v,e[49]=_):_=e[49];let A;e[50]!==v?(A=v("filesView.dialog.cancel"),e[50]=v,e[51]=A):A=e[51];let F;e[52]!==w||e[53]!==p||e[54]!==A?(F=s.jsx($,{variant:"outline",onClick:p,disabled:w,children:A}),e[52]=w,e[53]=p,e[54]=A,e[55]=F):F=e[55];const L=a==="delete"?"destructive":"default";let O;e[56]!==m?(O=()=>{m()},e[56]=m,e[57]=O):O=e[57];let X;e[58]!==a||e[59]!==c||e[60]!==w?(X=w||a!=="delete"&&!c.trim(),e[58]=a,e[59]=c,e[60]=w,e[61]=X):X=e[61];let te;e[62]!==a||e[63]!==w||e[64]!==v?(te=w?s.jsx(k,{name:"loader-4",className:"size-4 animate-spin"}):v(a==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=a,e[63]=w,e[64]=v,e[65]=te):te=e[65];let ie;e[66]!==L||e[67]!==O||e[68]!==X||e[69]!==te?(ie=s.jsx($,{variant:L,onClick:O,disabled:X,children:te}),e[66]=L,e[67]=O,e[68]=X,e[69]=te,e[70]=ie):ie=e[70];let pe;e[71]!==F||e[72]!==ie?(pe=s.jsxs(Ho,{children:[F,ie]}),e[71]=F,e[72]=ie,e[73]=pe):pe=e[73];let ae;e[74]!==j||e[75]!==V||e[76]!==_||e[77]!==pe?(ae=s.jsxs(_o,{initialFocus:j,children:[V,_,pe]}),e[74]=j,e[75]=V,e[76]=_,e[77]=pe,e[78]=ae):ae=e[78];let me;return e[79]!==g||e[80]!==y||e[81]!==ae?(me=s.jsx($o,{open:g,onOpenChange:y,children:ae}),e[79]=g,e[80]=y,e[81]=ae,e[82]=me):me=e[82],me},Ps=new Map,Cm=100,Oo=r=>{const e=Te.c(13);let a,n,c;e[0]!==r?({positionKey:n,onViewReady:a,...c}=r,e[0]=r,e[1]=a,e[2]=n,e[3]=c):(a=e[1],n=e[2],c=e[3]);const u=i.useRef(null);let w,m;e[4]!==n?(w=()=>()=>{const v=u.current;if(!v)return;const{anchor:g,head:y}=v.state.selection.main;if(Ps.delete(n),Ps.set(n,{scroll:v.scrollSnapshot(),anchor:g,head:y}),Ps.size>Cm){const C=Ps.keys().next().value;C!==void 0&&Ps.delete(C)}},m=[n],e[4]=n,e[5]=w,e[6]=m):(w=e[5],m=e[6]),i.useLayoutEffect(w,m);let p;e[7]!==a||e[8]!==n?(p=v=>{u.current=v;const g=Ps.get(n);g&&v.dispatch({selection:{anchor:Math.min(g.anchor,v.state.doc.length),head:Math.min(g.head,v.state.doc.length)},effects:g.scroll}),a?.(v)},e[7]=a,e[8]=n,e[9]=p):p=e[9];let j;return e[10]!==c||e[11]!==p?(j=s.jsx(Yu,{...c,onViewReady:p}),e[10]=c,e[11]=p,e[12]=j):j=e[12],j},Nm=(r,e,a)=>{const n=Te.c(8),[c,u]=i.useState(""),[w,m]=i.useState(0);let p,j;n[0]!==r||n[1]!==a||n[2]!==e?(p=()=>{if(!r){u("");return}let g=!1;u("");const y=Qc(),C=eu(y);tu(y).then(N=>{g||!N||(u(r),e(null))}).catch(N=>{g||(e(N instanceof Error?N.message:a),u(r))});const T=su(()=>{g||(u(r),m(Fm),e(null))});return()=>{g=!0,C(),T()}},j=[r,e,a],n[0]=r,n[1]=a,n[2]=e,n[3]=p,n[4]=j):(p=n[3],j=n[4]),i.useEffect(p,j);let v;return n[5]!==w||n[6]!==c?(v={readyKey:c,nonce:w},n[5]=w,n[6]=c,n[7]=v):v=n[7],v},Gp=({mode:r="full",visible:e=!0,onCloseFile:a})=>{const{t:n}=Xe(),{files:c,runtime:u,git:w}=gu(),{currentTheme:m,availableThemes:p,lightThemeId:j,darkThemeId:v}=wu(),{isMobile:g,isTablet:y,screenWidth:C}=vu(),T=Wc(u.platform),N=g||y,E=Uc(),R=Gc(),b=xu()??"",d=ee(b.trim()),P=g||r==="full",M=P&&e,z=si(t=>t.runtimeKey),V=JSON.stringify([z,d]),_=i.useRef(V);_.current=V;const A=JSON.stringify([z,d,E,R]),F=i.useRef(A);F.current=A;const L=r!=="editor-only",O=r==="editor-only"&&!g,X=Hc(t=>t.searchFiles),te=bu(M?b:null),[ie,pe]=i.useState(""),ae=yu(ie,200),me=i.useRef(null),[ce,ge]=i.useState(!1),[B,Se]=i.useState(!0),[oe,kt]=i.useState(!1),is=i.useCallback(t=>{if(!Er.current){kt(t);return}const o=xt.current;if(Ks.current){Ai.current?.().then(l=>{l&&xt.current===o&&kt(t)});return}Promise.resolve(ds.current?.getContent("handoff")??ci).then(l=>{if(xt.current===o){if(!l.ok){H.error(l.message);return}l.snapshot&&"content"in l.snapshot&&(fe(l.snapshot.content),ft(!1)),kt(t)}})},[]),[Ht,st]=i.useState(!1),as=i.useRef(0),wt=i.useCallback(t=>{as.current=Math.max(0,as.current+(t?1:-1))},[]),[nt,Rt]=i.useState(null),[Ye,zs]=i.useState(null),[Je,Tt]=i.useState(null),[vt,Mt]=i.useState({all:Number.POSITIVE_INFINITY,withMenu:Number.POSITIVE_INFINITY});i.useLayoutEffect(()=>{if(!nt||typeof ResizeObserver>"u")return;const t=28,o=()=>{const h=window.getComputedStyle(nt),x=Number.parseFloat(h.columnGap)||0,S=nt.clientWidth-(Number.parseFloat(h.paddingLeft)||0)-(Number.parseFloat(h.paddingRight)||0),I=nt.childElementCount>1,K=(Ye?.offsetWidth??0)+(Je?.offsetWidth??0)+4,ne=S-K-(I?x:0),G=Math.max(0,Math.floor(ne/t)),W=Math.max(0,Math.floor((ne-t)/t));Mt(q=>q.all===G&&q.withMenu===W?q:{all:G,withMenu:W})};o();const l=new ResizeObserver(()=>ju(o));return l.observe(nt),Ye&&l.observe(Ye),Je&&l.observe(Je),()=>{l.disconnect(),Su(o)}},[Ye,nt,Je]);const[re,Me]=i.useState("edit"),[Ze,rt]=i.useState("edit"),[Ce,it]=i.useState("tree"),[Ne,Pt]=i.useState("edit"),[de,he]=i.useState("preview"),[at,Z]=i.useState("preview"),[Pe,vn]=i.useState("preview"),[Is,xi]=i.useState("preview"),[Vt,bi]=i.useState("table"),[Kt,yi]=i.useState(null),[fl,ml]=i.useState(0),[hl,xn]=i.useState(0),os=i.useRef({}),Os=i.useRef({}),Bs=i.useRef({}),bn=i.useRef({}),yn=i.useRef({}),jn=i.useRef({}),$s=i.useRef({}),qt=i.useRef({}),Sn=i.useMemo(()=>p.find(t=>t.metadata.id===j)??lo(!1),[p,j]),Cn=i.useMemo(()=>p.find(t=>t.metadata.id===v)??lo(!0),[p,v]);i.useEffect(()=>{wo(Sn),wo(Cn)},[Sn,Cn]);const Nn=i.useMemo(()=>[],[]),we=Be(t=>d?t.byRoot[d]?.openPaths??Nn:Nn),Xt=Be(t=>d?t.byRoot[d]?.selectedPath??null:null),ot=Be(t=>d?t.byRoot[d]?.expandedPaths??Nn:Nn),pl=i.useMemo(()=>new Set(ot),[ot]),ji=Be(t=>t.removeOpenPath),Si=Be(t=>t.removeOpenPathsByPrefix),xr=Be(t=>t.removeUnselectedOpenPath),Ci=Be(t=>t.removeExpandedPathsByPrefix),lt=Be(t=>t.setSelectedPath),Ni=Be(t=>t.toggleExpandedPath),Fn=Be(t=>t.expandPaths),ls=i.useCallback(t=>{const o=ee(t),l=o.split("/"),h=l[l.length-1]||o,x=h.includes(".")?h.split(".").pop()?.toLowerCase():void 0;return{name:h,path:o,type:"file",extension:x}},[]),cs=i.useMemo(()=>we.map(ls),[we,ls]),br=i.useMemo(()=>{if(Xt){const t=As(Xt);if(we.some(o=>As(o)===t))return Xt}return we[0]??null},[we,Xt]),f=i.useMemo(()=>br?ls(br):null,[br,ls]),Fe=f?.path??"",xt=i.useRef(Fe);xt.current=Fe,i.useEffect(()=>{if(!d||!Xt)return;const t=As(Xt);we.some(l=>As(l)===t)||lt(d,we[0]??null)},[we,d,Xt,lt]);const En=!!(d&&Fe&&!hn(Fe,d)),_s=i.useMemo(()=>({allowOutsideWorkspace:En,directory:d||void 0}),[En,d]),ct=i.useCallback(t=>({allowOutsideWorkspace:!!(d&&!hn(t,d))}),[d]),yr=i.useRef(null),[Fi,gl]=i.useState({start:!1,end:!1}),Ei=i.useCallback(()=>{const t=yr.current;if(!t)return;const o=Math.abs(t.scrollLeft);gl({start:o>2,end:o+t.clientWidth<t.scrollWidth-2})},[]),ki=i.useRef(Ei);ki.current=Ei,i.useEffect(()=>{const t=yr.current;if(!t)return;const o=()=>ki.current();o(),t.addEventListener("scroll",o,{passive:!0});const l=new ResizeObserver(o);return l.observe(t),()=>{t.removeEventListener("scroll",o),l.disconnect()}},[cs.length]);const[Ri,jr]=i.useState({}),[kn,Ws]=i.useState({}),_e=i.useRef(new Set),Ee=i.useMemo(()=>new cd,[]);i.useEffect(()=>()=>Ee.clear(),[Ee]);const[Ti,Rn]=i.useState([]),[wl,Tn]=i.useState(!1),[U,ke]=i.useState(""),{isPlaying:Sr,play:vl,stop:xl}=Cu(),[ve,Dt]=i.useState(!1),[Qe,xe]=i.useState(null),[bl,bt]=i.useState(""),[Q,ue]=i.useState(null),Mi=i.useRef(Q);Mi.current=Q;const ut=i.useRef(null),[Cr,Pi]=i.useState(null),Us=Cr&&Cr.path===Q?Cr.documentPath:Q,[yt,Nr]=i.useState(null),Mn=i.useRef(null),At=JSON.stringify([$e(),d,Us]),[se,fe]=i.useState(""),[us,Fr]=i.useState(!1),[Vi,yl]=i.useState(`
|
|
9
|
+
`&&(N+=1),j();continue}u+=E}(u.length>0||w.length>0||m)&&j();const g=n[0]??[],y=n.slice(1),C=n.reduce((N,E)=>Math.max(N,E.length),0),T=Math.max(0,c-1);return{header:g,rows:y,totalRows:T,columnCount:C,truncated:y.length<T}},Qf=r=>{const e=Te.c(29),{path:a,content:n,sizeBytes:c}=r,{t:u}=Xe();let w;e[0]!==n||e[1]!==a?(w=Zf(n,Jf(a)),e[0]=n,e[1]=a,e[2]=w):w=e[2];const m=w;let p;e[3]!==u||e[4]!==m.columnCount||e[5]!==m.totalRows?(p=m.totalRows===1?u("filesView.artifact.table.rowsSingle",{rows:m.totalRows,columns:m.columnCount}):u("filesView.artifact.table.rowsPlural",{rows:m.totalRows,columns:m.columnCount}),e[3]=u,e[4]=m.columnCount,e[5]=m.totalRows,e[6]=p):p=e[6];const j=p;let v;e[7]!==m.columnCount?(v=Array.from({length:m.columnCount},em),e[7]=m.columnCount,e[8]=v):v=e[8];const g=v;let y;e[9]!==u||e[10]!==m.rows||e[11]!==m.totalRows||e[12]!==m.truncated?(y=m.truncated?u("filesView.artifact.table.truncated",{shown:m.rows.length,total:m.totalRows}):"",e[9]=u,e[10]=m.rows,e[11]=m.totalRows,e[12]=m.truncated,e[13]=y):y=e[13];let C;e[14]!==c?(C=wn(c),e[14]=c,e[15]=C):C=e[15];let T;e[16]!==j||e[17]!==y||e[18]!==C?(T=s.jsx(gn,{items:[j,y,C]}),e[16]=j,e[17]=y,e[18]=C,e[19]=T):T=e[19];let N;e[20]!==g||e[21]!==u||e[22]!==m.columnCount||e[23]!==m.header||e[24]!==m.rows?(N=m.columnCount===0?s.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:u("filesView.artifact.table.empty")}):s.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:s.jsxs("table",{className:"min-w-full border-separate border-spacing-0 font-mono typography-meta",children:[s.jsx("thead",{className:"sticky top-0 z-10 bg-[var(--surface-subtle)]",children:s.jsx("tr",{children:g.map(R=>s.jsx("th",{scope:"col",className:"whitespace-nowrap border-b border-e border-border/40 px-2 py-1 text-start font-medium text-foreground last:border-e-0",children:m.header[R]??""},R))})}),s.jsx("tbody",{children:m.rows.map((R,b)=>s.jsx("tr",{className:"odd:bg-[var(--surface-background)] even:bg-[var(--surface-subtle)]/40",children:g.map(d=>s.jsx("td",{className:"max-w-[32rem] truncate border-b border-e border-border/30 px-2 py-1 align-top text-foreground last:border-e-0",title:R[d]??"",children:R[d]??""},d))},b))})]})}),e[20]=g,e[21]=u,e[22]=m.columnCount,e[23]=m.header,e[24]=m.rows,e[25]=N):N=e[25];let E;return e[26]!==T||e[27]!==N?(E=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[T,N]}),e[26]=T,e[27]=N,e[28]=E):E=e[28],E};function em(r,e){return e}const Ms="data-oc-local-asset",tm=25*1024*1024,cr=r=>{const e=r.trim();return!e||e.startsWith("#")||e.startsWith("//")?!1:!/^[a-z][a-z\d+.-]*:/i.test(e)},sm=r=>r.split(/[?#]/,1)[0]??"",nm=r=>r.trim().toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").replace(/\s+/g,"-"),rm=(r,e)=>{const a=dl(e.replace(/^#/,"")).toLowerCase();if(!a)return!1;for(const n of Array.from(r.querySelectorAll("h1, h2, h3, h4, h5, h6")))if(n.id===a||nm(n.textContent??"")===a)return n.scrollIntoView({block:"start"}),!0;return!1},dl=r=>{try{return decodeURIComponent(r)}catch{return r}},im=r=>r.split(",").flatMap(e=>{const[a,...n]=e.trim().split(/\s+/);return a?[{url:a,descriptor:n.join(" ")}]:[]}),di="data-oc-media",am=/\(\s*prefers-color-scheme\s*:\s*(light|dark)\s*\)/gi,Po=(r,e)=>{for(const a of Array.from(r.querySelectorAll("picture > source[media]"))){const n=a.getAttribute(di)??a.getAttribute("media")??"",c=n.replace(am,(u,w)=>w.toLowerCase()===e?"(min-width: 0px)":"(max-width: -1px)");c!==n&&(a.getAttribute(di)!==n&&a.setAttribute(di,n),a.getAttribute("media")!==c&&a.setAttribute("media",c))}},Vo=({container:r,filePath:e,workspaceRoot:a,onOpenFile:n,enabled:c,colorScheme:u})=>{const w=i.useRef(n);w.current=n;const m=i.useRef(u);m.current=u,i.useEffect(()=>{c&&r&&Po(r,u)},[u,r,c]),i.useEffect(()=>{if(!c||!r||!e)return;const p=e.slice(0,e.lastIndexOf("/")+1)||"/",j=b=>hu(p,dl(sm(b))),v=b=>({path:b,allowOutsideWorkspace:a&&pu(b,a)?void 0:"true",directory:a||void 0});let g=!1;const y=$e(),C=new Map,T=b=>{const d=C.get(b);if(d)return d;const P=(async()=>{const M=await mn("/api/fs/raw",{query:v(b),signal:AbortSignal.timeout(3e4)});if(!M.ok)throw new Error(`Image read failed (${M.status})`);const z=await M.blob();if(z.size>tm)throw new Error("Image too large for preview");if(g||$e()!==y)throw new Error("Preview closed");return URL.createObjectURL(z)})();return C.set(b,P),P.catch(()=>C.delete(b)),P},N=()=>{for(const b of Array.from(r.querySelectorAll("img[src]"))){const d=b.getAttribute("src")??"";if(!cr(d))continue;const P=j(d);b.setAttribute(Ms,P),T(P).then(M=>{g||b.getAttribute(Ms)!==P||b.getAttribute("src")!==M&&(b.src=M)}).catch(()=>{g||b.removeAttribute(Ms)})}for(const b of Array.from(r.querySelectorAll("source[srcset], img[srcset]"))){const d=im(b.getAttribute("srcset")??"");if(!d.some(z=>cr(z.url)))continue;const P=d.map(z=>({...z,path:cr(z.url)?j(z.url):null})),M=P.map(z=>z.path??z.url).join(",");b.setAttribute(Ms,M),Promise.all(P.map(async({url:z,descriptor:V,path:_})=>{const A=_?await T(_):z;return V?`${A} ${V}`:A})).then(z=>{if(g||b.getAttribute(Ms)!==M)return;const V=z.join(", ");b.getAttribute("srcset")!==V&&b.setAttribute("srcset",V)}).catch(()=>{g||b.removeAttribute(Ms)})}Po(r,m.current)},E=b=>{if(b.defaultPrevented||b.button!==0||b.metaKey||b.ctrlKey||b.shiftKey||b.altKey)return;const d=b.target;if(!(d instanceof Element))return;const P=d.closest("a[href]");if(!(P instanceof HTMLAnchorElement)||!r.contains(P))return;const M=P.getAttribute("href")??"";if(M.startsWith("#")){b.preventDefault(),b.stopPropagation(),rm(r,M);return}cr(M)&&(b.preventDefault(),b.stopPropagation(),w.current(j(M)))};N();const R=new MutationObserver(N);return R.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["src","srcset","media"]}),r.addEventListener("click",E,!0),()=>{g=!0,R.disconnect(),r.removeEventListener("click",E,!0);for(const b of C.values())b.then(d=>URL.revokeObjectURL(d)).catch(()=>{})}},[r,c,e,a])},om=Vd({grant:Dd().min(1)}),lm=async(r,e,a=mn)=>{const n=await a("/api/fs/preview",{method:"POST",signal:e,query:{directory:r.directory||void 0},headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r.path})});if(!n.ok)throw new Error(`Preview grant request failed (${n.status})`);const c=om.safeParse(await n.json().catch(()=>null));if(!c.success)throw new Error("Preview grant response was invalid");return c.data.grant},cm=(r,e)=>{const a=e.split("/").map(c=>encodeURIComponent(c)).join("/"),n=a.startsWith("/")?a:`/${a}`;return Bo().api(`/api/fs/preview/${encodeURIComponent(r)}${n}`)},um=(r,e,a)=>{const n=Te.c(8),c=lm;let u;n[0]===Symbol.for("react.memo_cache_sentinel")?(u={status:"idle"},n[0]=u):u=n[0];const[w,m]=i.useState(u),p=r?.path??"",j=r?.directory??"",v=r?.revision??"";let g,y;return n[1]!==j||n[2]!==e||n[3]!==c||n[4]!==p||n[5]!==v?(g=()=>{if(!p){m({status:"idle"});return}const C=new AbortController;return m({status:"loading"}),(async()=>{try{const N=await c({path:p,directory:j,revision:v},C.signal);C.signal.aborted||m({status:"ready",url:cm(N,p)})}catch(N){const E=N;if(C.signal.aborted)return;m({status:"error",message:E instanceof Error?E.message:e})}})(),()=>C.abort()},y=[p,j,v,e,c],n[1]=j,n[2]=e,n[3]=c,n[4]=p,n[5]=v,n[6]=g,n[7]=y):(g=n[6],y=n[7]),i.useEffect(g,y),w},Ls=[];let Do=!1;const Ao=()=>{$c()&&_c("desktop_set_close_tab_target",{active:Ls.length>0})},dm=()=>{Ls[Ls.length-1]?.()},fm=r=>(Do||(window.addEventListener("openchamber:close-tab",dm),Do=!0),Ls.push(r),Ao(),()=>{const e=Ls.lastIndexOf(r);e>=0&&Ls.splice(e,1),Ao()}),mm=r=>{const e=ee(r);if(!e)return"";if(e==="/"||/^[A-Za-z]:\/$/.test(e))return e;const a=e.lastIndexOf("/");if(a<0)return e;if(a===0)return"/";const n=e.slice(0,a);return/^[A-Za-z]:$/.test(n)?`${n}/`:n},hm=r=>{const e=Te.c(8),{label:a,iconDataUrl:n}=r,[c,u]=i.useState(!1);let w;e[0]!==a?(w=a.trim().slice(0,1).toUpperCase()||"?",e[0]=a,e[1]=w):w=e[1];const m=w;if(n&&!c){let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=()=>u(!0),e[2]=v):v=e[2];let g;return e[3]!==n?(g=s.jsx("img",{src:n,alt:"",className:"size-4 rounded-sm",onError:v}),e[3]=n,e[4]=g):g=e[4],g}let p;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=Y("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=p):p=e[5];let j;return e[6]!==m?(j=s.jsx("span",{className:p,children:m}),e[6]=m,e[7]=j):j=e[7],j},pm=r=>r.slice().sort((e,a)=>e.type!==a.type?e.type==="directory"?-1:1:e.name.localeCompare(a.name)),ee=r=>{if(!r)return"";const e=r.replace(/\\/g,"/"),a=e.startsWith("//");let n=e.replace(/\/+/g,"/");a&&!n.startsWith("//")&&(n=`/${n}`);const c=n==="/",u=/^[A-Za-z]:\/$/.test(n);return!c&&!u&&(n=n.replace(/\/+$/,"")),n},gm=r=>r.startsWith("/")||r.startsWith("//")||/^[A-Za-z]:\//.test(r),As=r=>/^[A-Za-z]:\//.test(r)?r.toLowerCase():r,hn=(r,e)=>{const a=ee(e),n=ee(r);if(!a||!n)return!1;const c=As(a),u=As(n);return u===c||u.startsWith(`${c}/`)},Lo=(r,e)=>{const a=ee(e),n=ee(r);if(!hn(n,a))return[];const u=n.slice(a.length).replace(/^\//,"").split("/"),w=[];let m=a;for(let p=0;p<u.length-1;p++)m=m?`${m}/${u[p]}`:u[p],w.push(m);return w},fn=(r,e)=>{if(!e)return"";const a=ee(e);if(!r||!hn(a,r))return a;const n=a.slice(r.length);return n.startsWith("/")?n.slice(1):n},wm=new Set(["node_modules"]),zo=r=>{const e=Te.c(11),{name:a}=r,n=i.useRef(null),c=i.useRef(null),[u,w]=i.useState(!1);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{const y=n.current,C=c.current;if(!y||!C)return;const T=()=>{w(C.scrollWidth>y.clientWidth+1)};T();const N=new ResizeObserver(T);return N.observe(y),N.observe(C),()=>{N.disconnect()}},e[0]=m):m=e[0];let p;e[1]!==a?(p=[a],e[1]=a,e[2]=p):p=e[2],i.useLayoutEffect(m,p);let j;e[3]!==a?(j=s.jsx("span",{ref:c,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:a}),e[3]=a,e[4]=j):j=e[4];let v;e[5]!==a||e[6]!==u?(v=u?s.jsxs("span",{className:"open-file-name-marquee-track",children:[s.jsx("span",{className:"open-file-name-marquee-item",children:a}),s.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:a})]}):s.jsx("span",{className:"block min-w-0 truncate",children:a}),e[5]=a,e[6]=u,e[7]=v):v=e[7];let g;return e[8]!==j||e[9]!==v?(g=s.jsxs("span",{ref:n,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[j,v]}),e[8]=j,e[9]=v,e[10]=g):g=e[10],g},vm=r=>wm.has(r),xm=r=>{const e=ee(r);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},bm=r=>{const a=(r instanceof Error?r.message:String(r??"")).toLowerCase();return a.includes("is a directory")||a.includes("eisdir")},ym=2e5,fi=r=>{if(!r)return!1;const e=r.toLowerCase();if(e.endsWith(".excalidraw.md"))return!1;const a=e.split(".").pop();return a==="md"||a==="markdown"},mi=r=>!!(r&&al(gi.getState().guests,r)),Io=r=>{if(!r)return!1;const e=r.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},ur=r=>{if(!r)return!1;const e=r.toLowerCase().split(".").pop();return e==="html"||e==="htm"},jm=r=>{const e=Te.c(87),{node:a,root:n,isExpanded:c,isActive:u,isMobile:w,isBrowserClient:m,alwaysShowActions:p,depth:j,isOpen:v,status:g,badge:y,permissions:C,downloadFile:T,contextMenuPath:N,setContextMenuPath:E,rightClickMenuPath:R,setRightClickMenuPath:b,onSelect:d,onToggle:P,onRevealPath:M,onOpenDialog:z,canUpload:V,onPickFiles:_}=r,{t:A}=Xe(),F=a.type==="directory",{canRename:L,canCreateFile:O,canCreateFolder:X,canDelete:te,canReveal:ie}=C,pe=!F&&!!T,ae=ie&&!m,me=F&&V,ce=L||O||X||me||te||pe||ae;let ge;e[0]!==ce||e[1]!==a.path||e[2]!==b?(ge=de=>{ce&&(de?.preventDefault(),b(a.path))},e[0]=ce,e[1]=a.path,e[2]=b,e[3]=ge):ge=e[3];const B=ge;let Se;e[4]!==F||e[5]!==a||e[6]!==d||e[7]!==P?(Se=()=>{F?P(a.path):d(a)},e[4]=F,e[5]=a,e[6]=d,e[7]=P,e[8]=Se):Se=e[8];const oe=Se;let kt;e[9]!==a.path||e[10]!==E||e[11]!==b?(kt=de=>{de.stopPropagation(),b(null),E(a.path)},e[9]=a.path,e[10]=E,e[11]=b,e[12]=kt):kt=e[12];const is=kt;let Ht;e[13]!==O||e[14]!==X||e[15]!==te||e[16]!==L||e[17]!==ae||e[18]!==me||e[19]!==T||e[20]!==m||e[21]!==F||e[22]!==a||e[23]!==z||e[24]!==_||e[25]!==M||e[26]!==n||e[27]!==A?(Ht=de=>{const{Item:he,Separator:at}=de;return s.jsxs(s.Fragment,{children:[L&&s.jsxs(he,{onClick:Z=>{Z.stopPropagation(),z("rename",a)},children:[s.jsx(k,{name:"edit",className:"me-2 size-4"})," ",A("sidebarFilesTree.menu.rename")]}),s.jsxs(he,{onClick:Z=>{Z.stopPropagation(),pr(a.path).then(Pe=>{if(Pe.ok){H.success(A("sidebarFilesTree.toast.pathCopied"));return}H.error(A("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(k,{name:"file-copy",className:"me-2 size-4"})," ",A("sidebarFilesTree.menu.copyPath")]}),s.jsxs(he,{onClick:Z=>{Z.stopPropagation();const Pe=fn(n,a.path)||a.path;pr(Pe).then(vn=>{if(vn.ok){H.success(A("filesView.toast.relativePathCopied"));return}H.error(A("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(k,{name:"file-copy-2",className:"me-2 size-4"})," ",A("filesView.tree.menu.copyRelativePath")]}),!F&&T&&s.jsxs(he,{onClick:Z=>{Z.stopPropagation(),T(a.path).catch(Pe=>{console.error("Download failed:",Pe),H.error(A("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(k,{name:"download",className:"me-2 size-4"})," ",A(m?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),ae&&s.jsxs(he,{onClick:Z=>{Z.stopPropagation(),M(a.path)},children:[s.jsx(k,{name:"folder-received",className:"me-2 size-4"})," ",A(Gu())]}),!F&&ae&&Zc()&&s.jsxs(he,{onClick:Z=>{Z.stopPropagation(),dr(a.path).then(Pe=>{Pe||H.error(A("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(k,{name:"external-link",className:"me-2 size-4"})," ",A("sidebarFilesTree.menu.openInDefaultApp")]}),F&&(O||X||me)&&s.jsxs(s.Fragment,{children:[s.jsx(at,{}),O&&s.jsxs(he,{onClick:Z=>{Z.stopPropagation(),z("createFile",a)},children:[s.jsx(k,{name:"file-add",className:"me-2 size-4"})," ",A("sidebarFilesTree.menu.newFile")]}),X&&s.jsxs(he,{onClick:Z=>{Z.stopPropagation(),z("createFolder",a)},children:[s.jsx(k,{name:"folder-add",className:"me-2 size-4"})," ",A("sidebarFilesTree.menu.newFolder")]}),me&&s.jsxs(he,{onClick:Z=>{Z.stopPropagation(),_(a.path)},children:[s.jsx(k,{name:"upload-2",className:"me-2 size-4"})," ",A("sidebarFilesTree.menu.uploadFiles")]})]}),te&&s.jsxs(s.Fragment,{children:[s.jsx(at,{}),s.jsxs(he,{onClick:Z=>{Z.stopPropagation(),z("delete",a)},className:"text-destructive focus:text-destructive",children:[s.jsx(k,{name:"delete-bin",className:"me-2 size-4"})," ",A("sidebarFilesTree.menu.delete")]})]})]})},e[13]=O,e[14]=X,e[15]=te,e[16]=L,e[17]=ae,e[18]=me,e[19]=T,e[20]=m,e[21]=F,e[22]=a,e[23]=z,e[24]=_,e[25]=M,e[26]=n,e[27]=A,e[28]=Ht):Ht=e[28];const st=Ht,as=R===a.path;let wt;e[29]!==a.path||e[30]!==b?(wt=de=>b(de?a.path:null),e[29]=a.path,e[30]=b,e[31]=wt):wt=e[31];const nt=w?void 0:B;let Rt;e[32]!==nt?(Rt=s.jsx("div",{className:"group relative flex items-center",onContextMenu:nt}),e[32]=nt,e[33]=Rt):Rt=e[33];let Ye;e[34]!==j?(Ye=s.jsx(Zo,{depth:j}),e[34]=j,e[35]=Ye):Ye=e[35];const zs=w?void 0:B;let Je;e[36]!==u?(Je=Y("flex w-full items-center gap-1.5 rounded-md py-1 pe-8 text-start transition-colors select-none",Jo(u)),e[36]=u,e[37]=Je):Je=e[37];let Tt;e[38]!==j?(Tt=Qo(j),e[38]=j,e[39]=Tt):Tt=e[39];let vt;e[40]!==Tt?(vt={paddingLeft:Tt},e[40]=Tt,e[41]=vt):vt=e[41];let Mt;e[42]!==F||e[43]!==c||e[44]!==a.extension||e[45]!==a.path?(Mt=F?s.jsx(Sd,{expanded:c}):s.jsx(Ds,{filePath:a.path,extension:a.extension,className:"ms-0.5 size-3.5"}),e[42]=F,e[43]=c,e[44]=a.extension,e[45]=a.path,e[46]=Mt):Mt=e[46];let re;e[47]!==a.name||e[48]!==a.path?(re=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:a.path,children:a.name}),e[47]=a.name,e[48]=a.path,e[49]=re):re=e[49];let Me;e[50]!==F||e[51]!==v||e[52]!==g?(Me=!F&&s.jsx(Cd,{isOpen:v,status:g}),e[50]=F,e[51]=v,e[52]=g,e[53]=Me):Me=e[53];let Ze;e[54]!==y||e[55]!==F?(Ze=F&&y&&s.jsx(Nd,{badge:y}),e[54]=y,e[55]=F,e[56]=Ze):Ze=e[56];let rt;e[57]!==oe||e[58]!==zs||e[59]!==Je||e[60]!==vt||e[61]!==Mt||e[62]!==re||e[63]!==Me||e[64]!==Ze?(rt=s.jsxs("button",{type:"button",onClick:oe,onContextMenu:zs,className:Je,style:vt,children:[Mt,re,Me,Ze]}),e[57]=oe,e[58]=zs,e[59]=Je,e[60]=vt,e[61]=Mt,e[62]=re,e[63]=Me,e[64]=Ze,e[65]=rt):rt=e[65];let Ce;e[66]!==p||e[67]!==N||e[68]!==is||e[69]!==ce||e[70]!==w||e[71]!==a.path||e[72]!==st||e[73]!==E?(Ce=ce&&s.jsx("div",{className:Y("absolute inset-e-1 top-1/2 -translate-y-1/2",p?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:s.jsxs(fr,{open:N===a.path,onOpenChange:de=>E(de?a.path:null),children:[s.jsx(mr,{asChild:!0,children:s.jsx($,{variant:"ghost",size:"icon",className:"size-6",onClick:is,children:s.jsx(k,{name:"more-2-fill",className:"size-4"})})}),s.jsx(hr,{align:"end",side:"bottom",onCloseAutoFocus:()=>E(null),children:st({Item:Vs,Separator:Ko})})]})}),e[66]=p,e[67]=N,e[68]=is,e[69]=ce,e[70]=w,e[71]=a.path,e[72]=st,e[73]=E,e[74]=Ce):Ce=e[74];let it;e[75]!==rt||e[76]!==Ce||e[77]!==Rt||e[78]!==Ye?(it=s.jsxs(Hu,{render:Rt,children:[Ye,rt,Ce]}),e[75]=rt,e[76]=Ce,e[77]=Rt,e[78]=Ye,e[79]=it):it=e[79];let Ne;e[80]!==st?(Ne=s.jsx(_u,{className:"min-w-[180px]",children:st({Item:Uu,Separator:Wu})}),e[80]=st,e[81]=Ne):Ne=e[81];let Pt;return e[82]!==it||e[83]!==Ne||e[84]!==as||e[85]!==wt?(Pt=s.jsxs(Ku,{open:as,onOpenChange:wt,children:[it,Ne]}),e[82]=it,e[83]=Ne,e[84]=as,e[85]=wt,e[86]=Pt):Pt=e[86],Pt},Sm=r=>{const e=Te.c(83),{activeDialog:a,dialogData:n,dialogInputValue:c,onDialogInputChange:u,isDialogSubmitting:w,onDialogSubmit:m,onClose:p,inputRef:j}=r,{t:v}=Xe(),g=!!a;let y;e[0]!==p?(y=ce=>!ce&&p(),e[0]=p,e[1]=y):y=e[1];let C;e[2]!==a||e[3]!==v?(C=a==="createFile"&&v("filesView.dialog.createFile.title"),e[2]=a,e[3]=v,e[4]=C):C=e[4];let T;e[5]!==a||e[6]!==v?(T=a==="createFolder"&&v("filesView.dialog.createFolder.title"),e[5]=a,e[6]=v,e[7]=T):T=e[7];let N;e[8]!==a||e[9]!==v?(N=a==="rename"&&v("filesView.dialog.rename.title"),e[8]=a,e[9]=v,e[10]=N):N=e[10];let E;e[11]!==a||e[12]!==v?(E=a==="delete"&&v("filesView.dialog.delete.title"),e[11]=a,e[12]=v,e[13]=E):E=e[13];let R;e[14]!==C||e[15]!==T||e[16]!==N||e[17]!==E?(R=s.jsxs(Uo,{children:[C,T,N,E]}),e[14]=C,e[15]=T,e[16]=N,e[17]=E,e[18]=R):R=e[18];let b;e[19]!==a||e[20]!==n?.path||e[21]!==v?(b=a==="createFile"&&v("filesView.dialog.createFile.description",{path:n?.path??v("filesView.dialog.rootFallback")}),e[19]=a,e[20]=n?.path,e[21]=v,e[22]=b):b=e[22];let d;e[23]!==a||e[24]!==n?.path||e[25]!==v?(d=a==="createFolder"&&v("filesView.dialog.createFolder.description",{path:n?.path??v("filesView.dialog.rootFallback")}),e[23]=a,e[24]=n?.path,e[25]=v,e[26]=d):d=e[26];let P;e[27]!==a||e[28]!==n?.name||e[29]!==v?(P=a==="rename"&&v("filesView.dialog.rename.description",{name:n?.name??""}),e[27]=a,e[28]=n?.name,e[29]=v,e[30]=P):P=e[30];let M;e[31]!==a||e[32]!==n?.name||e[33]!==v?(M=a==="delete"&&v("filesView.dialog.delete.description",{name:n?.name??""}),e[31]=a,e[32]=n?.name,e[33]=v,e[34]=M):M=e[34];let z;e[35]!==P||e[36]!==M||e[37]!==b||e[38]!==d?(z=s.jsxs(Go,{children:[b,d,P,M]}),e[35]=P,e[36]=M,e[37]=b,e[38]=d,e[39]=z):z=e[39];let V;e[40]!==z||e[41]!==R?(V=s.jsxs(Wo,{children:[R,z]}),e[40]=z,e[41]=R,e[42]=V):V=e[42];let _;e[43]!==a||e[44]!==c||e[45]!==j||e[46]!==u||e[47]!==m||e[48]!==v?(_=a!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(pn,{value:c,onChange:ce=>u(ce.target.value),placeholder:v(a==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:ce=>{ce.key==="Enter"&&m()},ref:j})}),e[43]=a,e[44]=c,e[45]=j,e[46]=u,e[47]=m,e[48]=v,e[49]=_):_=e[49];let A;e[50]!==v?(A=v("filesView.dialog.cancel"),e[50]=v,e[51]=A):A=e[51];let F;e[52]!==w||e[53]!==p||e[54]!==A?(F=s.jsx($,{variant:"outline",onClick:p,disabled:w,children:A}),e[52]=w,e[53]=p,e[54]=A,e[55]=F):F=e[55];const L=a==="delete"?"destructive":"default";let O;e[56]!==m?(O=()=>{m()},e[56]=m,e[57]=O):O=e[57];let X;e[58]!==a||e[59]!==c||e[60]!==w?(X=w||a!=="delete"&&!c.trim(),e[58]=a,e[59]=c,e[60]=w,e[61]=X):X=e[61];let te;e[62]!==a||e[63]!==w||e[64]!==v?(te=w?s.jsx(k,{name:"loader-4",className:"size-4 animate-spin"}):v(a==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=a,e[63]=w,e[64]=v,e[65]=te):te=e[65];let ie;e[66]!==L||e[67]!==O||e[68]!==X||e[69]!==te?(ie=s.jsx($,{variant:L,onClick:O,disabled:X,children:te}),e[66]=L,e[67]=O,e[68]=X,e[69]=te,e[70]=ie):ie=e[70];let pe;e[71]!==F||e[72]!==ie?(pe=s.jsxs(Ho,{children:[F,ie]}),e[71]=F,e[72]=ie,e[73]=pe):pe=e[73];let ae;e[74]!==j||e[75]!==V||e[76]!==_||e[77]!==pe?(ae=s.jsxs(_o,{initialFocus:j,children:[V,_,pe]}),e[74]=j,e[75]=V,e[76]=_,e[77]=pe,e[78]=ae):ae=e[78];let me;return e[79]!==g||e[80]!==y||e[81]!==ae?(me=s.jsx($o,{open:g,onOpenChange:y,children:ae}),e[79]=g,e[80]=y,e[81]=ae,e[82]=me):me=e[82],me},Ps=new Map,Cm=100,Oo=r=>{const e=Te.c(13);let a,n,c;e[0]!==r?({positionKey:n,onViewReady:a,...c}=r,e[0]=r,e[1]=a,e[2]=n,e[3]=c):(a=e[1],n=e[2],c=e[3]);const u=i.useRef(null);let w,m;e[4]!==n?(w=()=>()=>{const v=u.current;if(!v)return;const{anchor:g,head:y}=v.state.selection.main;if(Ps.delete(n),Ps.set(n,{scroll:v.scrollSnapshot(),anchor:g,head:y}),Ps.size>Cm){const C=Ps.keys().next().value;C!==void 0&&Ps.delete(C)}},m=[n],e[4]=n,e[5]=w,e[6]=m):(w=e[5],m=e[6]),i.useLayoutEffect(w,m);let p;e[7]!==a||e[8]!==n?(p=v=>{u.current=v;const g=Ps.get(n);g&&v.dispatch({selection:{anchor:Math.min(g.anchor,v.state.doc.length),head:Math.min(g.head,v.state.doc.length)},effects:g.scroll}),a?.(v)},e[7]=a,e[8]=n,e[9]=p):p=e[9];let j;return e[10]!==c||e[11]!==p?(j=s.jsx(Yu,{...c,onViewReady:p}),e[10]=c,e[11]=p,e[12]=j):j=e[12],j},Nm=(r,e,a)=>{const n=Te.c(8),[c,u]=i.useState(""),[w,m]=i.useState(0);let p,j;n[0]!==r||n[1]!==a||n[2]!==e?(p=()=>{if(!r){u("");return}let g=!1;u("");const y=Qc(),C=eu(y);tu(y).then(N=>{g||!N||(u(r),e(null))}).catch(N=>{g||(e(N instanceof Error?N.message:a),u(r))});const T=su(()=>{g||(u(r),m(Fm),e(null))});return()=>{g=!0,C(),T()}},j=[r,e,a],n[0]=r,n[1]=a,n[2]=e,n[3]=p,n[4]=j):(p=n[3],j=n[4]),i.useEffect(p,j);let v;return n[5]!==w||n[6]!==c?(v={readyKey:c,nonce:w},n[5]=w,n[6]=c,n[7]=v):v=n[7],v},Kp=({mode:r="full",visible:e=!0,onCloseFile:a})=>{const{t:n}=Xe(),{files:c,runtime:u,git:w}=gu(),{currentTheme:m,availableThemes:p,lightThemeId:j,darkThemeId:v}=wu(),{isMobile:g,isTablet:y,screenWidth:C}=vu(),T=Wc(u.platform),N=g||y,E=Uc(),R=Gc(),b=xu()??"",d=ee(b.trim()),P=g||r==="full",M=P&&e,z=si(t=>t.runtimeKey),V=JSON.stringify([z,d]),_=i.useRef(V);_.current=V;const A=JSON.stringify([z,d,E,R]),F=i.useRef(A);F.current=A;const L=r!=="editor-only",O=r==="editor-only"&&!g,X=Hc(t=>t.searchFiles),te=bu(M?b:null),[ie,pe]=i.useState(""),ae=yu(ie,200),me=i.useRef(null),[ce,ge]=i.useState(!1),[B,Se]=i.useState(!0),[oe,kt]=i.useState(!1),is=i.useCallback(t=>{if(!Er.current){kt(t);return}const o=xt.current;if(Ks.current){Ai.current?.().then(l=>{l&&xt.current===o&&kt(t)});return}Promise.resolve(ds.current?.getContent("handoff")??ci).then(l=>{if(xt.current===o){if(!l.ok){H.error(l.message);return}l.snapshot&&"content"in l.snapshot&&(fe(l.snapshot.content),ft(!1)),kt(t)}})},[]),[Ht,st]=i.useState(!1),as=i.useRef(0),wt=i.useCallback(t=>{as.current=Math.max(0,as.current+(t?1:-1))},[]),[nt,Rt]=i.useState(null),[Ye,zs]=i.useState(null),[Je,Tt]=i.useState(null),[vt,Mt]=i.useState({all:Number.POSITIVE_INFINITY,withMenu:Number.POSITIVE_INFINITY});i.useLayoutEffect(()=>{if(!nt||typeof ResizeObserver>"u")return;const t=28,o=()=>{const h=window.getComputedStyle(nt),x=Number.parseFloat(h.columnGap)||0,S=nt.clientWidth-(Number.parseFloat(h.paddingLeft)||0)-(Number.parseFloat(h.paddingRight)||0),I=nt.childElementCount>1,K=(Ye?.offsetWidth??0)+(Je?.offsetWidth??0)+4,ne=S-K-(I?x:0),G=Math.max(0,Math.floor(ne/t)),W=Math.max(0,Math.floor((ne-t)/t));Mt(q=>q.all===G&&q.withMenu===W?q:{all:G,withMenu:W})};o();const l=new ResizeObserver(()=>ju(o));return l.observe(nt),Ye&&l.observe(Ye),Je&&l.observe(Je),()=>{l.disconnect(),Su(o)}},[Ye,nt,Je]);const[re,Me]=i.useState("edit"),[Ze,rt]=i.useState("edit"),[Ce,it]=i.useState("tree"),[Ne,Pt]=i.useState("edit"),[de,he]=i.useState("preview"),[at,Z]=i.useState("preview"),[Pe,vn]=i.useState("preview"),[Is,xi]=i.useState("preview"),[Vt,bi]=i.useState("table"),[Kt,yi]=i.useState(null),[fl,ml]=i.useState(0),[hl,xn]=i.useState(0),os=i.useRef({}),Os=i.useRef({}),Bs=i.useRef({}),bn=i.useRef({}),yn=i.useRef({}),jn=i.useRef({}),$s=i.useRef({}),qt=i.useRef({}),Sn=i.useMemo(()=>p.find(t=>t.metadata.id===j)??lo(!1),[p,j]),Cn=i.useMemo(()=>p.find(t=>t.metadata.id===v)??lo(!0),[p,v]);i.useEffect(()=>{wo(Sn),wo(Cn)},[Sn,Cn]);const Nn=i.useMemo(()=>[],[]),we=Be(t=>d?t.byRoot[d]?.openPaths??Nn:Nn),Xt=Be(t=>d?t.byRoot[d]?.selectedPath??null:null),ot=Be(t=>d?t.byRoot[d]?.expandedPaths??Nn:Nn),pl=i.useMemo(()=>new Set(ot),[ot]),ji=Be(t=>t.removeOpenPath),Si=Be(t=>t.removeOpenPathsByPrefix),xr=Be(t=>t.removeUnselectedOpenPath),Ci=Be(t=>t.removeExpandedPathsByPrefix),lt=Be(t=>t.setSelectedPath),Ni=Be(t=>t.toggleExpandedPath),Fn=Be(t=>t.expandPaths),ls=i.useCallback(t=>{const o=ee(t),l=o.split("/"),h=l[l.length-1]||o,x=h.includes(".")?h.split(".").pop()?.toLowerCase():void 0;return{name:h,path:o,type:"file",extension:x}},[]),cs=i.useMemo(()=>we.map(ls),[we,ls]),br=i.useMemo(()=>{if(Xt){const t=As(Xt);if(we.some(o=>As(o)===t))return Xt}return we[0]??null},[we,Xt]),f=i.useMemo(()=>br?ls(br):null,[br,ls]),Fe=f?.path??"",xt=i.useRef(Fe);xt.current=Fe,i.useEffect(()=>{if(!d||!Xt)return;const t=As(Xt);we.some(l=>As(l)===t)||lt(d,we[0]??null)},[we,d,Xt,lt]);const En=!!(d&&Fe&&!hn(Fe,d)),_s=i.useMemo(()=>({allowOutsideWorkspace:En,directory:d||void 0}),[En,d]),ct=i.useCallback(t=>({allowOutsideWorkspace:!!(d&&!hn(t,d))}),[d]),yr=i.useRef(null),[Fi,gl]=i.useState({start:!1,end:!1}),Ei=i.useCallback(()=>{const t=yr.current;if(!t)return;const o=Math.abs(t.scrollLeft);gl({start:o>2,end:o+t.clientWidth<t.scrollWidth-2})},[]),ki=i.useRef(Ei);ki.current=Ei,i.useEffect(()=>{const t=yr.current;if(!t)return;const o=()=>ki.current();o(),t.addEventListener("scroll",o,{passive:!0});const l=new ResizeObserver(o);return l.observe(t),()=>{t.removeEventListener("scroll",o),l.disconnect()}},[cs.length]);const[Ri,jr]=i.useState({}),[kn,Ws]=i.useState({}),_e=i.useRef(new Set),Ee=i.useMemo(()=>new cd,[]);i.useEffect(()=>()=>Ee.clear(),[Ee]);const[Ti,Rn]=i.useState([]),[wl,Tn]=i.useState(!1),[U,ke]=i.useState(""),{isPlaying:Sr,play:vl,stop:xl}=Cu(),[ve,Dt]=i.useState(!1),[Qe,xe]=i.useState(null),[bl,bt]=i.useState(""),[Q,ue]=i.useState(null),Mi=i.useRef(Q);Mi.current=Q;const ut=i.useRef(null),[Cr,Pi]=i.useState(null),Us=Cr&&Cr.path===Q?Cr.documentPath:Q,[yt,Nr]=i.useState(null),Mn=i.useRef(null),At=JSON.stringify([$e(),d,Us]),[se,fe]=i.useState(""),[us,Fr]=i.useState(!1),[Vi,yl]=i.useState(`
|
|
10
10
|
`),jl=i.useRef(null),dt=i.useRef(null),Ve=i.useRef(null),Lt=i.useRef(""),Gs=i.useRef(""),jt=i.useRef(null),Yt=i.useRef(null),Di=i.useRef(null),ds=i.useRef(null),[Hs,ft]=i.useState(!1),Er=i.useRef(!1);Er.current=Hs;const Ks=i.useRef(!1),Ai=i.useRef(null),De=i.useRef(null),kr=i.useRef(""),Rr=i.useRef(0),fs=i.useRef(0),Jt=i.useRef(null),[ms,Li]=i.useState(0),[Sl,hs]=i.useState("idle"),[Cl,Pn]=i.useState(!1),[Nl,zi]=i.useState(!1),[Zt,Ii]=i.useState(!1),be=qe(t=>t.autoSaveEnabled),Fl=qe(t=>t.setAutoSaveEnabled),[Tr,qs]=i.useState(!1),ps=i.useRef(null),Xs=i.useRef(null),Ys=i.useRef(!1),Js=i.useRef(null),Zs=i.useRef(null),ye=i.useRef(null),Qs=i.useRef(null),Oi=i.useRef(null),Bi=i.useRef(0),[El,Mr]=i.useState(0),gs=i.useRef(null),St=i.useRef({key:"",attempts:0,targetShown:!1});i.useEffect(()=>()=>{gs.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(gs.current),gs.current=null)},[]);const[Qt,Pr]=i.useState(null),[es,kl]=i.useState(null),[zt,$i]=i.useState(""),[Rl,Vr]=i.useState(!1),[Tl,Ml]=i.useState(null),[Pl,Vl]=i.useState(null),[Dl,_i]=i.useState(!1),[Al,Wi]=i.useState(!1),[Ll,Vn]=i.useState(!1),[Ui,en]=i.useState(!1),[Gi,Dn]=i.useState(!1),[Hi,Ki]=i.useState(0),An=i.useRef(null),Ln=i.useCallback(t=>{const o=t?.currentTarget??An.current;if(!o)return;const l=document.activeElement;l&&l!==document.body&&l!==o&&(Nu(l)||o.contains(l))||o.focus({preventScroll:!0})},[]),zn=i.useRef(null),qi=!!c.writeFile,Xi=!!c.createDirectory,Yi=!!c.rename,Ji=!!c.delete,Zi=!!c.revealPath,Qi=ir(t=>t.availableApps),zl=ir(t=>t.isCacheStale),ea=ir(t=>t.initialize),Il=ir(t=>t.loadInstalledApps);i.useEffect(()=>{ea()},[ea]);const Ol=i.useCallback(t=>{c.revealPath&&c.revealPath(t).catch(()=>{H.error(n("sidebarFilesTree.toast.revealFailed"))})},[c,n]),Bl=i.useCallback(async t=>{if(!f?.path||await Kc(f.path,t.id,t.appName)||await dr(f.path,t.appName))return;const h=mm(f.path)||d;h&&await dr(h,t.appName)||H.error(n("filesView.toast.openInAppFailed",{app:t.appName}))},[d,f?.path,n]),Dr=i.useCallback((t,o)=>{Pr(t),kl(o),$i(t==="rename"&&o.name||""),Vr(!1)},[]),[J,et]=i.useState(null),ws=i.useRef(!1),It=i.useRef(null),[ta,vs]=i.useState(!1),mt=qe(t=>t.pendingFileNavigation),In=qe(t=>t.setPendingFileNavigation),Ar=qe(t=>t.pendingFileFocusPath),Lr=qe(t=>t.setPendingFileFocusPath),xs=qe(t=>t.fileEditorKeymap),sa=qe(t=>t.fileEditorVimMappings);i.useEffect(()=>{xs==="vim"&&qu(sa)},[xs,sa]);const tn=co(t=>t.settingsDefaultFileViewerPreview),$l=co(t=>t.showMessageTTSButtons);i.useEffect(()=>{const t=()=>{ws.current=!1,It.current=null,vs(!1)};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]),i.useEffect(()=>()=>{Js.current!==null&&window.clearTimeout(Js.current),Zs.current!==null&&window.clearTimeout(Zs.current)},[]);const _l=i.useCallback((t,o)=>{const l=t.split(`
|
|
11
11
|
`),h=Math.max(1,o.start),x=Math.min(l.length,o.end);return h>x?"":l.slice(h-1,x).join(`
|
|
12
12
|
`)},[]),na=i.useRef(null),Wl=Ad({source:"file",fileLabel:f?.path??null,language:f?.path&&ni(f.path)||"text",getCodeForRange:t=>_l(U,Ld(t)),toStoreRange:t=>({startLine:t.start,endLine:t.end}),fromDraftRange:t=>({start:t.startLine,end:t.endLine})}),{drafts:ra,commentText:On,setCommentText:ia,editingDraftId:Bn,setSelection:aa,saveComment:oa,cancel:sn,reset:la,startEdit:ca,deleteDraft:ua}=Wl;i.useEffect(()=>{ut.current?.to!==f?.path&&(et(null),la(),fe(""),Fr(!1))},[f?.path,la]),i.useEffect(()=>{aa(J)},[J,aa]),i.useEffect(()=>{if(!J&&!Bn)return;const t=l=>{const h=l.target;h.closest('[data-comment-input="true"]')||h.closest('[data-comment-card="true"]')||h.closest(".cm-gutterElement")||h.closest("[data-sonner-toast]")||h.closest("[data-sonner-toaster]")||On.trim()||(et(null),sn())},o=setTimeout(()=>{document.addEventListener("click",t)},100);return()=>{clearTimeout(o),document.removeEventListener("click",t)}},[sn,On,Bn,J]),i.useEffect(()=>{if(!g||!J)return;const t=ye.current;if(!t)return;const o=t.state.selection.main;o.empty||t.dispatch({selection:{anchor:o.head}});const l=document.getSelection();l&&!l.isCollapsed&&l.anchorNode&&t.contentDOM.contains(l.anchorNode)&&l.removeAllRanges()},[g,J]);const da=i.useCallback((t,o)=>{const l=o??J??void 0;o&&et(o),oa(t,l),et(null)},[J,oa]),fa=i.useCallback((t,o)=>{const l=[];for(const h of o){if(!(h&&typeof h.name=="string"&&h.name.length>0)||!E&&h.name.startsWith(".")||!R&&vm(h.name))continue;const x=h.name,S=ee(h.path||""),I=S?gm(S)?S:ee(`${t}/${S}`):ee(`${t}/${x}`),K=h.isDirectory?"directory":"file",ne=K==="file"&&x.includes(".")?x.split(".").pop()?.toLowerCase():void 0;l.push({name:x,path:I,type:K,extension:ne})}return pm(l)},[R,E]),Re=i.useCallback(async(t,o=!1)=>{if(!M)return;const l=ee(t.trim());if(!l||!o&&_e.current.has(l))return;const h=F.current,x=$e();return Ee.run(l,async S=>{const I=()=>S()&&F.current===h&&$e()===x;try{const K=!R,ne=c.listDirectory?(await c.listDirectory(l,{respectGitignore:K})).entries:await qc.listLocalDirectory(l,{respectGitignore:K});if(!I())return;const G=fa(l,ne);_e.current=new Set(_e.current),_e.current.add(l),Ws(W=>{if(!W[l])return W;const q={...W};return delete q[l],q}),jr(W=>W[l]&&ud(W[l],G)?W:{...W,[l]:G})}catch(K){if(!I())return;const ne=K instanceof Error?K.message:String(K??"");if(ne==="Directory not found"&&d&&l!==d){Ci(d,l),Ws(G=>{if(!G[l])return G;const W={...G};return delete W[l],W});return}console.error("Failed to load files directory:",K),Ws(G=>({...G,[l]:ne}))}},o)},[Ee,c,fa,Ci,d,R,M]),$n=i.useCallback(async()=>{d&&(_e.current=new Set,Ee.clear(),Ws({}),jr(t=>Object.keys(t).length===0?t:{}),await Re(d))},[Ee,Re,d]),Ae=i.useCallback(async t=>{if(!t){await $n();return}const o=ee(t);_e.current=new Set(_e.current),_e.current.delete(o),await Re(o,!0)},[Re,$n]),{canUpload:ma,uploadingDirectory:Ul,pickFiles:ha,uploadElements:Gl}=bd({root:d,refreshDirectory:Ae}),_n=Ul!==null,pa=i.useRef(""),ga=i.useRef("");i.useEffect(()=>{if(!d)return;const t=A,o=pa.current!==V,l=ga.current!==t;!o&&!l||(o&&(pa.current=V,fs.current+=1,Jt.current=null,ke(""),xe(null),bt(""),ue(null),ge(!1)),l&&(ga.current=t,_e.current=new Set,Ee.clear(),Ws({}),jr(h=>Object.keys(h).length===0?h:{}),Re(d)))},[Ee,V,Re,d,A]),i.useEffect(()=>{if(!M||!c.listDirectory)return;const t=()=>{if(!document.hidden&&ot.length>0)for(const o of ot)Ee.has(o)||Ae(o)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[Ee,ot,c.listDirectory,Ae,M]);const wa=i.useRef(!1);i.useEffect(()=>{const t=M&&!wa.current;if(wa.current=M,!(!M||!d)&&(Re(d),t))for(const o of ot)Ee.has(o)||Ae(o)},[Ee,ot,Re,Ae,d,M]),i.useEffect(()=>{if(!M||!c.listDirectory||ot.length===0)return;const t=setInterval(()=>{if(!document.hidden)for(const o of ot)Ee.has(o)||Ae(o)},8e3);return()=>clearInterval(t)},[Ee,ot,c.listDirectory,Ae,M]);const Hl=i.useCallback(async t=>{if(t?.preventDefault(),!es||!Qt)return;Vr(!0);const o=()=>{Pr(null)},l=x=>{H.error(x)},h=()=>{Vr(!1)};if(Qt==="createFile"){if(!zt.trim()){l(n("sidebarFilesTree.toast.filenameRequired")),h();return}if(!c.writeFile){l(n("sidebarFilesTree.toast.writeNotSupported")),h();return}const x=es.path,S=x?`${x}/`:"",I=ee(`${S}${zt.trim()}`);await c.writeFile(I,"").then(async K=>{K.success&&(H.success(n("sidebarFilesTree.toast.fileCreated")),await Ae(x)),o()}).catch(()=>l(n("sidebarFilesTree.toast.operationFailed"))).finally(h);return}if(Qt==="createFolder"){if(!zt.trim()){l(n("sidebarFilesTree.toast.folderNameRequired")),h();return}const x=es.path,S=x?`${x}/`:"",I=ee(`${S}${zt.trim()}`);await c.createDirectory(I).then(async K=>{K.success&&(H.success(n("sidebarFilesTree.toast.folderCreated")),await Ae(x)),o()}).catch(()=>l(n("sidebarFilesTree.toast.operationFailed"))).finally(h);return}if(Qt==="rename"){if(!zt.trim()){l(n("sidebarFilesTree.toast.nameRequired")),h();return}if(!c.rename){l(n("sidebarFilesTree.toast.renameNotSupported")),h();return}const x=es.path,S=x.split("/").slice(0,-1).join("/"),I=S?`${S}/`:"",K=zt.trim(),ne=ee(`${I}${K}`);try{const G=await dd(c,d,x,ne);G==="moved"?(H.success(n("sidebarFilesTree.toast.renamedSuccessfully")),await Ae(S),o()):l(G==="conflict"?n("sidebarFilesTree.toast.nameTaken",{name:K,folder:fn(d,S)||n("sidebarFilesTree.dialog.rootFallback")}):n("sidebarFilesTree.toast.operationFailed"))}catch{l(n("sidebarFilesTree.toast.operationFailed"))}finally{h()}return}if(Qt==="delete"){if(!c.delete){l(n("sidebarFilesTree.toast.deleteNotSupported")),h();return}const x=es.path,S=x.split("/").slice(0,-1).join("/");await c.delete(x).then(async I=>{I.success&&(H.success(n("sidebarFilesTree.toast.deletedSuccessfully")),await Ae(S),d&&Si(d,x),(f?.path===x||f?.path.startsWith(`${x}/`))&&(d&<(d,null),ke(""),xe(null),bt(""),ue(null),g&&ge(!1))),o()}).catch(()=>l(n("sidebarFilesTree.toast.operationFailed"))).finally(h);return}h()},[Qt,es,zt,c,Ae,g,Si,d,f?.path,lt,n]);i.useEffect(()=>{if(!b){Rn([]),Tn(!1);return}const t=ae.trim();if(!t){Rn([]),Tn(!1);return}let o=!1;return Tn(!0),X(b,t,150,{includeHidden:E,respectGitignore:!R,type:"file"}).then(l=>{if(o)return;const x=l.filter(S=>R||!xm(S.path)).map(S=>({name:S.name,path:ee(S.path),type:"file",extension:S.extension,relativePath:S.relativePath}));Rn(x)}).catch(()=>{o||Rn([])}).finally(()=>{o||Tn(!1)}),()=>{o=!0}},[b,ae,X,E,R]);const Wn=i.useCallback(async(t,o)=>{const l=ct(t);if(c.readFile)return(await c.readFile(t,{...l,directory:d||void 0,...o})).content??"";const h=new URLSearchParams({path:t});l.allowOutsideWorkspace&&h.set("allowOutsideWorkspace","true"),d&&h.set("directory",d);const x=await mn(`/api/fs/read?${h.toString()}`,{cache:o?.fresh?"no-store":"default",signal:AbortSignal.timeout(3e4)});if(!x.ok){const S=await x.json().catch(()=>({error:x.statusText}));throw new Error(S.error||n("filesView.error.readFileFailed"))}return x.text()},[c,ct,d,n]),ht=i.useCallback(async t=>{if(c.statFile){const o=ct(t),l=await c.statFile(t,{...o,directory:d||void 0});return{path:l.path,size:l.size,mtimeMs:l.mtimeMs}}return null},[c,ct,d]);i.useEffect(()=>{if(!d||!c.statFile||we.length===0)return;let t=!1;const o=[...we];return Promise.all(o.map(async l=>{try{const h=ct(l),x=await c.statFile?.(l,{...h,directory:d||void 0});!t&&x&&!x.isFile&&xr(d,l)}catch(h){!t&&oo(h)&&xr(d,l)}})),()=>{t=!0}},[c,we,xr,ct,d]);const Le=se!==U||Hs,Ot=i.useCallback((t,o=!0)=>{const{content:l,lineEnding:h}=ff(t);return o&&mi(xt.current)&&xn(x=>x+1),kr.current=t,Rr.current+=1,yl(h),ke(l),Lt.current=l,Gs.current=l,fe(l),l},[]),Ct=i.useCallback(async()=>{if(!f||!c.writeFile)return H.error(n("filesView.toast.savingNotSupported")),!1;const t=(un(f.path)||Zt)&&!Ks.current;if(!uf({selectedFilePath:f.path,loadedFilePath:Q,fileLoading:ve,isDirty:Le,draftContent:se,fileContent:U,isNonEditableBinary:t}))return t?console.warn(`[saveDraft] refusing to save binary file "${f.path}".`):se===""&&U!==""&&Q!==f.path&&console.warn(`[saveDraft] refusing to save empty draft for "${f.path}" (${U.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(!Le)return!0;if(ut.current||ti(f.path))return!1;Fr(!0);try{const o=Hs?ds.current:null;Hs&&!o&&ft(!1);const l=o?await o.getContent("save"):ci;if(!l.ok)return H.error(l.message),!1;const h=l.snapshot;if(h&&"bytes"in h){if(!c.uploadFile)return H.error(n("filesView.toast.savingNotSupported")),!1;if(De.current=null,!(await c.uploadFile(f.path,new Blob([h.bytes]),{overwrite:!0}))?.success)return H.error(n("filesView.toast.writeFileFailed")),!1;ds.current?.markSaved(h.signature)}else{const x=mf(h?h.content:se,Vi);if(!(await c.writeFile(f.path,x))?.success)return H.error(n("filesView.toast.writeFileFailed")),!1;h?(Ot(x,!1),ds.current?.markSaved(h.signature)):(ke(se),kr.current=x,Rr.current+=1)}if(d&&hn(f.path,d)){const x=fn(d,f.path);x&&Fu.requestGitRefresh({directory:d,paths:[x]})}if(d&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(ee(f.path))){const x=Eu.getState().projects.find(S=>ee(S.path)===ee(d));if(x)try{await Id(x.id)}catch{H.error(n("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return f?.path&&dn(f.path)&&(Lt.current=se,Gs.current=se),ht(f.path).then(x=>{x&&(De.current=x)}).catch(()=>{}),!0}catch(o){return H.error(o instanceof Error?o.message:n("filesView.toast.saveFailed")),!1}finally{Fr(!1)}},[Ot,Zt,se,Hs,U,ve,c,Le,Vi,Q,ht,d,f,n]);Ai.current=Ct,i.useEffect(()=>{be||(hs("idle"),dt.current&&(clearTimeout(dt.current),dt.current=null))},[be]);const Un=1500;i.useEffect(()=>{const t=!!(f&&c.writeFile),o=!!(f?.path&&(un(f.path)||Zt))&&!Ks.current;if(!cf({autoSaveEnabled:be,isDirty:Le,canWrite:t,isSaving:us,fileLoading:ve,selectedFilePath:f?.path,loadedFilePath:Q,isNonEditableBinary:o,wouldEmptyFile:se===""&&U!==""}))return;const l=h=>{dt.current=setTimeout(()=>{const x=Date.now()-Bi.current;if(x<Un){l(Un-x);return}Ct().then(S=>{S&&(hs("saved"),setTimeout(()=>hs("idle"),2e3))})},h)};return l(Un),()=>{dt.current&&(clearTimeout(dt.current),dt.current=null)}},[be,Zt,se,U,ve,Le,Q,f,c.writeFile,us,Ct]),i.useEffect(()=>{hs("idle")},[f?.path]);const va=i.useCallback(()=>{dt.current&&(clearTimeout(dt.current),dt.current=null),us||Ct().then(t=>{t&&(hs("saved"),setTimeout(()=>hs("idle"),2e3))})},[us,Ct]);ku({save_file:t=>{if(!(t.target instanceof Node)||!Qs.current?.contains(t.target)&&!Oi.current?.contains(t.target))return!1;va()},find_in_file:t=>{if(!(t.target instanceof Node))return!1;if(He&&Ie()==="preview"){if(g||!(oe?zn.current:An.current)?.contains(t.target))return!1;Dn(!0),Ki(l=>l+1);return}if(!Qs.current?.contains(t.target))return!1;st(!0)}});const xa=i.useCallback(async t=>{const o=fs.current+1;fs.current=o;const l=$e(),h=_.current,x=()=>{if(!d||$e()!==l||_.current!==h)return!1;const G=Be.getState().byRoot[d],W=G?.selectedPath??G?.openPaths[0]??null;return fs.current===o&&W===t.path};ut.current=null,Pi(null),xe(null),Nr(null),Mn.current=null,bt(""),ue(null),Ii(!1),Dt(!0);const S=ri(t.path),I=ii(t.path),K=uo(t.path),ne=un(t.path);if(g&&ge(!0),u.isDesktop&&S&&!I){ke(""),fe("");return}if(!u.isDesktop&&S&&!I){ke(""),fe(""),ue(t.path),Dt(!1);return}if(K){ke(""),fe(""),ue(t.path),Dt(!1);return}if(ne){ke(""),fe(""),ue(t.path),Dt(!1);return}await Wn(t.path).then(G=>{if(!x())return;if(fo(G)){Ii(!0),ke(""),fe(""),ue(t.path);return}const W=Ot(G),q=fi(t.path)||ur(t.path)||Io(t.path)||dn(t.path)||ii(t.path)||mo(t.path)||ho(t.path)||mi(t.path);Me(q?"edit":hf(W,os.current[t.path])),ue(t.path),ht(t.path).then(le=>{le&&x()&&(De.current=le)}).catch(()=>{})}).catch(G=>{if(x()){if(bm(G)){if(Dt(!1),d&<(d,null),xe(null),ke(""),fe(""),ue(null),De.current=null,ie.trim().length>0&&pe(""),g&&ge(!1),d){const q=[...Lo(t.path,d),t.path];q.length>0&&Fn(d,q);for(const le of q)_e.current.has(le)||Re(le)}return}ke(""),fe(""),xe(G instanceof Error?G.message:n("filesView.error.readFileFailed")),Nr(t.path),De.current=null}}).finally(()=>{x()&&Dt(!1)})},[Ot,Fn,g,Re,Wn,ht,d,u.isDesktop,ie,lt,n]),Gn=i.useCallback(async(t,o)=>{if(!e||!d)return;const l=Lo(t,d),h=o?[...l,t]:l;if(h.length>0&&Fn(d,h),!M)return;const x=h.map(S=>{if(!_e.current.has(S))return Re(S)}).filter(Boolean);await Promise.all(x)},[Fn,Re,d,M,e]),ba=i.useCallback((t,o)=>{const l=o.findIndex(h=>h.path===t);return l===-1||o.length<=1?null:o[l+1]??o[l-1]??null},[]),We=i.useCallback(async t=>{if(Ys.current)Ys.current=!1;else if(Le){qs(!0),ps.current=t;return}d&&(lt(d,t.path),Gn(t.path,!1)),xe(null),bt(""),ke(""),Lt.current="",Gs.current="",ft(!1),fe(""),ue(null),g&&ge(!0)},[Gn,Le,g,d,lt]);i.useEffect(()=>{f?.path&&Gn(f.path,!1)},[Gn,f?.path]),i.useEffect(()=>Xc(({runtimeKey:t,from:o,to:l})=>{if(t!==$e())return;os.current=_t(os.current,o,l),Os.current=_t(Os.current,o,l),Bs.current=_t(Bs.current,o,l),bn.current=_t(bn.current,o,l),yn.current=_t(yn.current,o,l),jn.current=_t(jn.current,o,l),$s.current=_t($s.current,o,l),qt.current=_t(qt.current,o,l);const h=ut.current,x=h?.to??Mi.current,S=x?nu(x,o,l):null;x&&S&&(ut.current={from:h?.from??x,to:S})}),[]),i.useEffect(()=>{const t=ut.current;if(t&&f?.path===t.to){if(ut.current=null,Q===t.from){Pi({path:t.to,documentPath:Us??t.from}),ue(t.to);return}}else t&&Q!==t.from&&(ut.current=null);if(!e)return;if(!f){fs.current+=1,Jt.current=null,Dt(!1);return}if(Q===f.path||Jt.current===f.path)return;const o=f.path;Jt.current=o,xa(f).finally(()=>{Jt.current===o&&(Jt.current=null)})},[Us,ms,xa,Q,f,e]);const Hn=i.useRef(Le);Hn.current=Le,i.useEffect(()=>yd(({runtimeKey:t,paths:o})=>{const l=f?.path;t!==$e()||!l||Hn.current||!o.includes(ee(l))||(fs.current+=1,Jt.current=null,De.current=null,bt(""),xe(null),ue(null),Li(h=>h+1))}),[f?.path]),i.useEffect(()=>{if(!e||!f?.path||Q!==f.path&&yt!==f.path)return;const t=f.path,o=yt===t,l=$e(),h=_.current,x=()=>Hn.current||dn(t)&&Lt.current!==Gs.current,S=!un(t)&&!ri(t)&&!Zt?sf({readContent:()=>Wn(t,{fresh:!0}),getLoadedContent:()=>kr.current,getLoadedRevision:()=>Rr.current,isDirty:x,applyContent:W=>{if(!(I||$e()!==l||_.current!==h)){if(fo(W)){ue(null);return}Ot(W)}}}):null;let I=!1,K=!1;const ne=()=>{document.hidden||K||(K=!0,ht(t).then(async W=>{if(I||$e()!==l||_.current!==h||!W)return;const q=Mn.current===t,le=So({stat:"found",showsFailure:o,sawMissing:q,hasUnsavedChanges:x(),moving:!1});if(le==="reload"){De.current=null,ue(null),Li(ks=>ks+1);return}if(le!=="check-changes")return;const $t=De.current;if(!$t||$t.path!==t){De.current=W;return}if(rf($t,W)){if(S&&W.size<=ym){await S.poll()&&!I&&(De.current=W);return}Hn.current||(De.current=W,ue(null))}}).catch(W=>{if(I||$e()!==l||_.current!==h)return;const q=oo(W)?"missing":"failed",le=Mn.current===t,$t=ti(t)||ut.current!==null;So({stat:q,showsFailure:o,sawMissing:le,hasUnsavedChanges:x(),moving:$t})==="show-missing"&&(Mn.current=t,De.current=null,ke(""),fe(""),xe(W instanceof Error?W.message:n("filesView.error.readFileFailed")),Nr(t))}).finally(()=>{K=!1}))};ne();const G=window.setInterval(ne,2e3);return()=>{I=!0,S?.dispose(),window.clearInterval(G)}},[Ot,Zt,yt,Q,Wn,ht,f?.path,n,e]);const bs=i.useCallback((t,o)=>{if(a){a(t);return}if(d&&ji(d,t),f?.path===t){if(o){We(o);return}d&<(d,null),ke(""),xe(null),bt(""),ue(null),g&&ge(!1)}},[We,g,a,ji,d,f?.path,lt]),Kl=i.useCallback(()=>{const t=ps.current,o=Xs.current;if(ps.current=null,Xs.current=null,Ys.current=!0,qs(!1),ft(!1),xn(l=>l+1),fe(U),o){bs(o,t);return}if(t){We(t);return}},[bs,U,We]),ql=i.useCallback(async()=>{const t=ps.current,o=Xs.current;if(!await Ct()){Ys.current=!1;return}if(ps.current=null,Xs.current=null,Ys.current=!0,qs(!1),o){bs(o,t);return}if(t){await We(t);return}},[bs,We,Ct]),nn=i.useCallback(t=>{const o=f?.path===t,l=ba(t,cs);if(o&&Le){qs(!0),ps.current=l,Xs.current=t;return}bs(t,l)},[bs,ba,Le,cs,f?.path]),ya=i.useRef(nn);i.useEffect(()=>{ya.current=nn},[nn]);const zr=f?.path??null;i.useEffect(()=>{if(!(!e||!zr))return fm(()=>ya.current(zr))},[zr,e]);const Xl=i.useMemo(()=>new Set(we),[we]),Kn=i.useMemo(()=>fd(P?te?.files??[]:[]),[te?.files,P]),Yl=i.useCallback(t=>{const o=t.startsWith(d+"/")?t.slice(d.length+1):t;return Kn.statusByPath.get(o)??null},[Kn,d]),Jl=i.useCallback(t=>{if(!te?.files)return null;const o=t.startsWith(d+"/")?t.slice(d.length+1):t;return Kn.badgeByDir.get(o)??null},[te,Kn,d]),Zl=i.useCallback(async t=>{const o=ee(t);d&&(Ni(d,o),_e.current.has(o)||await Re(o))},[Re,d,Ni]),Ql=i.useMemo(()=>({canRename:Yi,canCreateFile:qi,canCreateFolder:Xi,canDelete:Ji,canReveal:Zi}),[Yi,qi,Xi,Ji,Zi]);function ja(t,o){return(Ri[t]??[]).map(h=>{const x=h.type==="directory",S=x&&pl.has(h.path),I=f?.path===h.path;return s.jsxs("li",{children:[s.jsx(jm,{node:h,root:d,isExpanded:S,isActive:I,isMobile:g,isBrowserClient:T,alwaysShowActions:N,depth:o,isOpen:!x&&Xl.has(h.path),status:x?void 0:Yl(h.path),badge:x?Jl(h.path):void 0,permissions:Ql,downloadFile:c.downloadFile,contextMenuPath:Tl,setContextMenuPath:Ml,rightClickMenuPath:Pl,setRightClickMenuPath:Vl,onSelect:We,onToggle:Zl,onRevealPath:Ol,onOpenDialog:Dr,canUpload:ma&&!_n,onPickFiles:ha}),x&&S&&s.jsxs("ul",{className:"flex flex-col",children:[kn[h.path]?s.jsxs("li",{className:"relative flex items-center gap-2 py-1 pe-2 typography-meta text-muted-foreground",style:{paddingLeft:Qo(o+1)},children:[s.jsx(Zo,{depth:o+1}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:kn[h.path],children:kn[h.path]}),s.jsxs($,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{Ae(h.path)},children:[s.jsx(k,{name:"refresh",className:"size-3.5"}),n("filesView.tree.actions.refreshTitle")]})]}):null,ja(h.path,o+1)]})]},h.path)})}const ze=!!(f?.path&&ri(f.path)),Ue=!!(f?.path&&ii(f.path)),Sa=Ue&&Pe==="edit",Bt=!!(f?.path&&uo(f.path)),Ca=!!(f?.path&&Ru(f.path)),Ir=Ca||!!(f?.path&&Tu(f.path)),Or=!!(f?.path&&Mu(f.path)),qn=!!(f?.path&&(un(f.path)||Zt)),ys=qn&&!ze&&!Bt&&!Ir&&!Or,Br=qn||ze&&!Sa,Na=i.useMemo(()=>ee(mt?.path??""),[mt?.path]),js=!!(mt&&Na&&Fe&&Fe===Na&&!ve&&!Qe&&!Br),ts=i.useMemo(()=>fn(d,Fe),[Fe,d]),ec=!!(f&&(!ze||Ue)&&!Bt&&!ys&&U.length>0),tc=!!(f&&ts.length>0),Ge=!!(f&&!En&&!qn&&(!ze||Ue)&&c.writeFile),$r=!!(f&&!qn&&(!ze||Ue)),_r=yf(f?.path),je=_r&&($r||_r.editor.content==="binary")?_r:null,Nt=je!==null,sc=Pu(),rn=je?.editor.content==="binary";Ks.current=rn;const He=!Nt&&!!(f?.path&&fi(f.path)),Ss=!Nt&&!!(f?.path&&Io(f.path)),ss=!Nt&&!!(f?.path&&ur(f.path)),an=!Nt&&!sc&&!!(f?.path&&dn(f.path)),Cs=!Nt&&!!(f?.path&&mo(f.path)),Ns=!Nt&&!!(f?.path&&ho(f.path)),Fs=Nt,on=Nt&&(rn?Kt===null||Kt<=hi:se.length<=hi),nc=gi(t=>t.status),rc=!Nt&&$r&&nc!=="unsupported"&&!!(f?.path&&Vu(f.path)),Xn=$r&&!He&&!an&&!Fs&&!(ss&&Ne==="preview")&&!(Ue&&Pe==="preview")&&!(Cs&&Is==="preview")&&!(Ns&&Vt==="table"),ic=He&&Ze==="edit"||ss&&Ne==="edit"||Fs&&(at==="edit"||!on)||Ue&&Pe==="edit"||Cs&&Is==="edit"||Ns&&Vt==="text"||Ss&&Ce==="text"||!He&&!ss&&!Ss&&!Fs&&!Ue&&!Cs&&!Ns&&re==="edit",Yn=i.useMemo(()=>Fe?Du(Fe):null,[Fe]),[Fa,Wr]=i.useState(null);i.useEffect(()=>{let t=!1;const o=f?.path;if(!o||Yn){Wr(null);return}return Wr(null),Au(o).then(l=>{t||Wr(l)}),()=>{t=!0}},[f?.path,Yn]),i.useEffect(()=>{!Ge&&re==="edit"&&Me("view")},[Ge,re]);const Ur="openchamber:files:md-viewer-mode",Gr="openchamber:files:html-viewer-mode",Hr="openchamber:files:json-viewer-mode";i.useEffect(()=>{const t=f?.path;if(!t)return;Me(os.current[t]??"edit");let o=tn?"preview":"edit";try{const x=localStorage.getItem(Ur);(x==="preview"||x==="edit")&&(o=x)}catch{}rt(Os.current[t]??o);let l=tn?"preview":"edit";try{const x=localStorage.getItem(Gr);(x==="preview"||x==="edit")&&(l=x)}catch{}Pt(Bs.current[t]??l),he($s.current[t]??(tn?"preview":"edit")),Z(qt.current[t]??"preview"),vn(bn.current[t]??"preview"),xi(yn.current[t]??"preview"),bi(jn.current[t]??"table");let h=tn?"tree":"text";try{const x=localStorage.getItem(Hr);(x==="tree"||x==="text")&&(h=x)}catch{}it(h)},[f?.path,tn]);const ac=i.useCallback(t=>{const o=f?.path;o&&(os.current[o]=t),Me(t)},[f?.path]),oc=i.useCallback(t=>{const o=f?.path;o&&(Os.current[o]=t),rt(t);try{localStorage.setItem(Ur,t)}catch{}},[f?.path]),Ie=i.useCallback(()=>Ze,[Ze]),lc=i.useCallback(t=>{const o=f?.path;o&&(bn.current[o]=t),vn(t)},[f?.path]),cc=i.useCallback(t=>{const o=f?.path;o&&(yn.current[o]=t),xi(t)},[f?.path]),uc=i.useCallback(t=>{const o=f?.path;o&&(jn.current[o]=t),bi(t)},[f?.path]);i.useEffect(()=>{const t=f?.path;if(yi(null),!t||Q!==t)return;let o=!1;return ht(t).then(l=>{!o&&l&&yi(l.size)}).catch(()=>{}),()=>{o=!0}},[ms,Q,ht,f?.path]);const Ea=f&&He&&Ie()==="preview"&&!ve?f.path:null;i.useEffect(()=>{!Ea||g||Ln()},[Ln,oe,g,Ea]);const dc=i.useCallback(t=>{it(t);try{localStorage.setItem(Hr,t)}catch{}},[]),fc=i.useCallback(t=>{const o=f?.path;o&&(Bs.current[o]=t),Pt(t);try{localStorage.setItem(Gr,t)}catch{}},[f?.path]),mc=i.useCallback(t=>{const o=f?.path;if(o&&($s.current[o]=t),Ve.current&&(clearTimeout(Ve.current),Ve.current=null),jt.current!==null&&(cancelAnimationFrame(jt.current),jt.current=null),t==="edit")fe(Lt.current||U),he(t);else{Lt.current=se;const l=o;he("edit"),jt.current=requestAnimationFrame(()=>{jt.current=requestAnimationFrame(()=>{jt.current=null,!(d&&l&&Be.getState().byRoot[d]?.selectedPath!==l)&&(ml(h=>h+1),he("preview"))})});return}},[se,U,d,f?.path]),hc=i.useCallback(t=>{const o=f?.path,l=()=>{o&&(qt.current[o]=t)};if(t==="edit"){if(!Er.current){l(),ft(!1),Z(t);return}Promise.resolve(ds.current?.getContent("handoff")??ci).then(x=>{if(xt.current===o){if(!x.ok){H.error(x.message);return}l(),fe(x.snapshot&&"content"in x.snapshot?x.snapshot.content:U),ft(!1),Z(t)}});return}if(!on){je&&H.error(n("filesView.fileEditor.tooLarge",{editor:je.editor.title}));return}l(),ft(!1);const h=o;Yt.current!==null&&cancelAnimationFrame(Yt.current),Yt.current=requestAnimationFrame(()=>{Yt.current=null,!(d&&h&&Be.getState().byRoot[d]?.selectedPath!==h)&&(xn(x=>x+1),Z("preview"))})},[on,U,je,d,f?.path,n]),Kr=i.useCallback(async(t,o)=>{if(!c.writeFile||o===Gs.current||ut.current||ti(t))return!1;if(!(await c.writeFile(t,o))?.success)return H.error(n("filesView.toast.writeFileFailed")),!1;Ot(o);const h=await ht(t).catch(()=>null);return h&&(De.current=h),!0},[Ot,c,ht,n]);i.useEffect(()=>()=>{Ve.current&&(clearTimeout(Ve.current),Ve.current=null),jt.current!==null&&(cancelAnimationFrame(jt.current),jt.current=null)},[de,f?.path]);const pc=i.useCallback(t=>{if(Lt.current=t,!be||!f?.path||de!=="preview"||!c.writeFile)return;Ve.current&&clearTimeout(Ve.current);const o=f.path;Ve.current=setTimeout(()=>{Ve.current=null,Kr(o,t).then(l=>{l&&(Pn(!0),setTimeout(()=>Pn(!1),1500))}).catch(l=>{H.error(l instanceof Error?l.message:n("filesView.toast.saveFailed"))})},Un)},[be,de,c.writeFile,Kr,f?.path,n]),gc=i.useMemo(()=>an&&(Lt.current||se)||U,[se,U,an]),wc=i.useCallback(()=>{const t=xt.current;t&&(qt.current[t]="edit"),ft(!1),Z("edit"),je&&H.error(n("filesView.fileEditor.unsupported",{editor:je.editor.title}))},[je,n]);i.useEffect(()=>()=>{Yt.current!==null&&(cancelAnimationFrame(Yt.current),Yt.current=null)},[at,f?.path]);const ka=i.useCallback(()=>Ne,[Ne]);i.useEffect(()=>{const t=l=>{const h=l?"preview":"edit",x=l?"tree":"text";for(const S of we)os.current[S]="edit",fi(S)&&(Os.current[S]=h),ur(S)&&(Bs.current[S]=h),dn(S)&&($s.current[S]=h),mi(S)&&(qt.current[S]=h);Me("edit"),rt(h),Pt(h),he(h),Z(h),it(x);try{localStorage.setItem(Ur,h),localStorage.setItem(Gr,h),localStorage.setItem(Hr,x)}catch{}},o=l=>{const h=!!l.detail?.enabled;t(h)};return window.addEventListener("openchamber:file-viewer-preview-mode-changed",o),()=>{window.removeEventListener("openchamber:file-viewer-preview-mode-changed",o)}},[we]),i.useEffect(()=>{if(!mt||!d)return;const t=()=>{typeof window>"u"||gs.current===null&&(gs.current=window.requestAnimationFrame(()=>{gs.current=null,Mr(Ke=>Ke+1)}))},o=(Ke,gt)=>{if(Ke.state.doc.length!==gt.length)return!1;if(gt.length===0)return!0;const cn=Math.min(128,gt.length);if(Ke.state.sliceDoc(0,cn)!==gt.slice(0,cn))return!1;const Oe=Math.max(0,gt.length-cn);return Ke.state.sliceDoc(Oe,gt.length)===gt.slice(Oe)},l=ee(mt.path);if(!l){In(null),St.current={key:"",attempts:0,targetShown:!1};return}const h=`${l}:${mt.line}:${mt.column??1}`;St.current.key!==h&&(St.current={key:h,attempts:0,targetShown:!1});const x=f?.path??null;x===l&&(St.current.targetShown=!0);const S=af({selectedPath:x,targetPath:l,targetShown:St.current.targetShown,targetSettled:!ve&&(Q===l||yt===l),showsText:yt!==l&&!Qe&&!ze&&!Bt&&!ys,canEdit:Ge,textViewMode:re});if(S==="select-target"){Tr||We(ls(l));return}if(S==="wait")return;if(S==="end"){In(null),St.current={key:"",attempts:0,targetShown:!1};return}if(S==="show-editor"){Me("edit");return}const I=ye.current;if(!I){t();return}if(!o(I,se)){t();return}const K=Math.max(1,Math.min(mt.line,I.state.doc.lines)),ne=I.state.doc.line(K),G=Math.max(1,mt.column||1),W=Math.max(0,ne.to-ne.from),q=Math.min(W,G-1),le=ne.from+q;if(!(I.state.selection.main.head===le)||St.current.attempts===0){St.current.attempts+=1,I.dispatch({selection:{anchor:le},effects:tt.scrollIntoView(le,{y:"center"})}),I.focus(),t();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const Ke=ye.current;Ke&&(Ke.dispatch({selection:{anchor:le},effects:tt.scrollIntoView(le,{y:"center"})}),Ke.focus())}),In(null),St.current={key:"",attempts:0,targetShown:!1}},[Ge,Tr,se,El,yt,Qe,ve,ze,Bt,ys,Q,We,mt,d,f?.path,In,re,ls]),i.useEffect(()=>{if(!Ar||!d)return;const t=ee(Ar);if(!t){Lr(null);return}f?.path===t&&(ve||Q!==t&&yt!==t||(yt!==t&&!Qe&&!ze&&!Bt&&!ys&&Ge&&re==="edit"&&ye.current?.focus(),Lr(null)))},[Ge,yt,Qe,ve,ze,Bt,ys,Q,Ar,d,f?.path,Lr,re]);const Es=i.useCallback(t=>{if(!g||!t||typeof window>"u")return;const o=document.activeElement,l=!t.hasFocus&&o instanceof HTMLElement&&t.dom.contains(o)?o.closest('[data-comment-input="true"]'):null;if(!t.hasFocus&&!l)return;const h=window.visualViewport;if(!h)return;const x=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,x-(h.offsetTop+h.height))<=0)return;const I=l?l.getBoundingClientRect():t.coordsAtPos(t.state.selection.main.head);if(!I)return;const K=Math.round(h.offsetTop+h.height),G=I.bottom+20-K;G<=0||(t.scrollDOM.scrollTop+=G)},[g]);i.useEffect(()=>{if(!g||typeof window>"u")return;const t=()=>{window.requestAnimationFrame(()=>{Es(ye.current)})},o=window.visualViewport;return o?.addEventListener("resize",t),o?.addEventListener("scroll",t,{passive:!0}),document.addEventListener("selectionchange",t),()=>{o?.removeEventListener("resize",t),o?.removeEventListener("scroll",t),document.removeEventListener("selectionchange",t)}},[g,Es]),po("open_go_to_line",t=>{if(!Ge||re!=="edit"||g)return!1;const o=t.target;if(o?.closest('[role="dialog"]')||!(o instanceof Node)||!Qs.current?.contains(o))return!1;const l=!!o?.closest(".cm-editor");if(!!o?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!l)return!1;Vn(!0)}),po("open_document_symbols",t=>{if(!Ge||re!=="edit"||g)return!1;const o=t.target;if(o?.closest('[role="dialog"]')||!(o instanceof Node)||!Qs.current?.contains(o))return!1;en(!0)});const ns=qe(t=>t.editorFontSize),Ra=i.useMemo(()=>({"--text-markdown":`${ns+1}px`,"--text-code":`${ns-1}px`}),[ns]),pt=f?.path&&d&&f.path.startsWith(`${d}/`)?f.path.slice(d.length+1):null,Ta=si(t=>{if(!pt||!d)return null;const o=t.directories.get(b)?.status,l=o?.files.find(h=>h.path===pt)??null;return JSON.stringify([pt,o?.current??null,l])}),[qr,Xr]=i.useState(null);i.useEffect(()=>{if(!pt||!d||!Ta){Xr(null);return}let t=!1;return w.getGitFileDiff(d,{path:pt}).then(o=>{if(t)return;const l=si.getState().directories.get(b)?.status?.files.find(S=>S.path===pt),h=l!==void 0&&(l.index==="?"||l.index==="A"||l.working_dir==="?"),x=!o.isBinary&&!o.submodule&&(o.original!==""||h);Xr({path:pt,text:x?o.original:null})}).catch(()=>{t||Xr({path:pt,text:null})}),()=>{t=!0}},[b,w,Ta,d]);const Ma=i.useRef(qr);Ma.current=qr;const Jn=i.useCallback(t=>{if(!t)return;const o=Ma.current;Af(t,o&&o.path===pt?o.text:null)},[pt]);i.useEffect(()=>{Jn(ye.current)},[Jn,qr]);const Pa=i.useRef(()=>{});Pa.current=()=>{if(!f?.path||!d)return;const t=Yc(d),o=qe.getState(),l=o.contextPanelByDirectory[t]?.tabs.find(h=>h.preview&&h.targetPath===f.path);l&&o.pinContextPanelTab(t,l.id)};const Va=i.useMemo(()=>tt.updateListener.of(t=>{if(!t.docChanged)return;t.transactions.some(l=>l.isUserEvent("input")||l.isUserEvent("delete")||l.isUserEvent("undo")||l.isUserEvent("redo")||l.isUserEvent("move"))&&Pa.current()}),[]),Da={mousedown:(t,o,l)=>{if(!(l instanceof MouseEvent)||l.button!==0)return!1;l.preventDefault();const h=t.state.doc.lineAt(o.from).number;if(J&&!l.shiftKey&&Math.min(J.start,J.end)===h&&Math.max(J.start,J.end)===h)return et(null),sn(),ws.current=!1,It.current=null,vs(!1),!0;if(g&&J&&!l.shiftKey){const x=Math.min(J.start,J.end,h),S=Math.max(J.start,J.end,h);return et({start:x,end:S}),ws.current=!1,It.current=null,vs(!1),!0}if(ws.current=!0,It.current=h,vs(!0),J&&l.shiftKey){const x=Math.min(J.start,h),S=Math.max(J.end,h);et({start:x,end:S})}else et({start:h,end:h});return!0},mouseover:(t,o,l)=>{if(!(l instanceof MouseEvent)||l.buttons!==1||!ws.current||It.current===null)return!1;const h=t.state.doc.lineAt(o.from).number,x=Math.min(It.current,h),S=Math.max(It.current,h);return et({start:x,end:S}),vs(!0),!1},mouseup:()=>(ws.current=!1,It.current=null,vs(!1),!1)},Zn=i.useRef(Da);Zn.current=Da;const vc=i.useMemo(()=>({domEventHandlers:{mousedown:(t,o,l)=>Zn.current.mousedown?.(t,o,l)??!1,mouseover:(t,o,l)=>Zn.current.mouseover?.(t,o,l)??!1,mouseup:(t,o,l)=>Zn.current.mouseup?.(t,o,l)??!1}}),[]),Aa=i.useMemo(()=>{if(!f?.path)return[go(m,{fontSize:ns})];const t=ni(f.path),o=[go(m,t?{syntaxColors:!1,fontSize:ns}:{fontSize:ns})],l=Yn??Fa;l&&o.push(l),t&&o.push(Xu({language:t,themeName:m.metadata.id,theme:wd(m)})),B&&o.push(tt.lineWrapping);const h=m.colors.syntax.highlights;return o.push(Df({added:h?.diffAdded??m.colors.status.success,modified:h?.diffModified??m.colors.status.info,removed:h?.diffRemoved??m.colors.status.error}),Rd({highlightWordAroundCursor:!0,minSelectionLength:2}),Va,Ff()),g||o.push(Nf(),Ef({vimMode:xs==="vim"})),g&&o.push(tt.updateListener.of(x=>{x.view.hasFocus&&(x.selectionSet||x.focusChanged||x.viewportChanged||x.geometryChanged)&&window.requestAnimationFrame(()=>{Es(x.view)})})),o},[m,f?.path,Yn,Fa,B,g,Es,ns,Va,xs]),La=i.useMemo(()=>({light:Sn.metadata.id,dark:Cn.metadata.id}),[Sn.metadata.id,Cn.metadata.id]),za=Bt||Ir||Or,ln=f?.path&&za?`${f.path}|${_s.allowOutsideWorkspace?"outside":"workspace"}|${ms}`:"",xc=i.useMemo(()=>f?.path&&ss&&Ne==="preview"&&!u.isVSCode?{path:f.path,directory:d||"",revision:String(ms)}:null,[f?.path,ss,Ne,u.isVSCode,d,ms]),Ia=n("filesView.error.readFileFailed"),rs=um(xc,Ia);i.useEffect(()=>{rs.status==="error"?xe(rs.message):rs.status==="ready"&&xe(null)},[rs,xe]);const{readyKey:Oa,nonce:Qn}=Nm(ln,xe,Ia),Yr=!!(ln&&Oa!==ln),bc=f?.path&&ze?Ue?`data:${Lu(f.path)};utf8,${encodeURIComponent(U)}`:bl:"",er=f?.path&&za&&ln&&Oa===ln?Bo().authenticatedAsset(Jc("/api/fs/raw",d),{path:f.path,allowOutsideWorkspace:_s.allowOutsideWorkspace?"true":void 0,directory:d||void 0}):"",yc=i.useCallback(t=>s.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:s.jsx("iframe",{src:er,className:"h-full w-full border-0",title:t.name},Qn)}),[er,Qn]),Ba=f&&c.downloadFile?s.jsxs($,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=c.downloadFile;!t||!f||t(f.path,_s).catch(o=>{console.error("Download failed:",o),H.error(n("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(k,{name:"download",className:"me-2 size-4"}),n("filesView.editor.saveFile")]}):null,tr=f&&!ve&&!Yr&&!Qe?(t=>ze&&!Sa?s.jsx(qf,{src:bc,name:t.name,sizeBytes:Kt}):Bt?yc(t):Ir?s.jsx(Xf,{kind:Ca?"video":"audio",src:er,name:t.name,sizeBytes:Kt,download:Ba},Qn):Or?s.jsx($f,{src:er,name:t.name,sizeBytes:Kt},Qn):ys?s.jsx(If,{name:t.name,path:t.path,sizeBytes:Kt,download:Ba}):Ns&&Vt==="table"?s.jsx(Qf,{path:t.path,content:U,sizeBytes:Kt}):Cs&&Is==="preview"?s.jsx("div",{className:"h-full min-h-0 overflow-hidden",children:s.jsx(ar,{fallback:s.jsxs("div",{className:"m-3 rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:n("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:n("filesView.error.switchToEditMode")})]}),children:s.jsx(oi,{content:`\`\`\`mermaid
|
|
13
13
|
${U}
|
|
14
|
-
\`\`\``,className:"markdown-mermaid-fullscreen h-full",enableFileReferences:!1,allowMermaidWheelEvents:!0})})}):null)(f):null;i.useEffect(()=>{let t=!1,o="";return(async()=>{if(!f?.path||!ze||Ue){bt("");return}xe(null);const h=ct(f.path);if(t)return;await(c.readFileBinary?c.readFileBinary(f.path,h).then(S=>S.dataUrl):(async()=>{const S=await mn("/api/fs/raw",{signal:AbortSignal.timeout(3e4),query:{path:f.path,allowOutsideWorkspace:h.allowOutsideWorkspace?"true":void 0,directory:d||void 0}});if(!S.ok)throw new Error(n("filesView.error.readFileFailed"));const I=await S.blob();return o=URL.createObjectURL(I),t?(URL.revokeObjectURL(o),o="",""):o})()).then(S=>{t||(bt(S),ue(f.path))}).catch(S=>{t||(bt(""),xe(S instanceof Error?S.message:n("filesView.error.readFileFailed")),ue(null))}).finally(()=>{t||Dt(!1)})})(),()=>{t=!0,o&&URL.revokeObjectURL(o)}},[ms,c,ze,Ue,ct,d,f?.path,_s,n]);const jc=i.useCallback(()=>Pr(null),[]),Sc=i.useMemo(()=>zd({drafts:ra,editingDraftId:Bn,commentText:On,onTextChange:ia,selection:J,isDragging:ta,fileLabel:f?.path??"",newWidgetId:"files-new-comment-input",mapDraftToRange:t=>({start:t.startLine,end:t.endLine}),onSave:da,onCancel:()=>{et(null),sn()},onEdit:t=>{ca(t),et({start:t.startLine,end:t.endLine})},onDelete:ua}),[sn,On,ua,Bn,ra,da,ta,J,f?.path,ia,ca]),$a=Co(),_a=Co(),sr=!ve&&!Qe&&Q===Fe,Jr=i.useMemo(()=>!!Fe&&vf({hasCanvas:Fs,viewMode:at,previewReady:sr,mountable:on}),[on,at,Fs,sr,Fe]),nr=sr&&Xn&&re==="view"&&!(Ss&&Ce==="tree"),Wa=sr&&He&&Ie()==="preview",{setScroller:Ua,restore:Cc}=or(nr?`${At}:code`:null),{setScroller:Ga,restore:Nc}=or(nr?`${At}:code:fullscreen`:null),{setScroller:Ha}=or(Wa?`${At}:markdown`:null),{setScroller:Ka}=or(Wa?`${At}:markdown:fullscreen`:null),{setScroller:qa}=$a,{setScroller:Xa}=_a,Fc=i.useCallback(t=>{qa(t),Ua(t)},[qa,Ua]),Ec=i.useCallback(t=>{Xa(t),Ga(t)},[Xa,Ga]),[kc,Rc]=i.useState(null),[Tc,Mc]=i.useState(null),Pc=i.useCallback(t=>{na.current=t,An.current=t,Rc(t),Ha(t)},[Ha]),Vc=i.useCallback(t=>{zn.current=t,Mc(t),Ka(t)},[Ka]),Ya=i.useCallback(t=>{d&&qe.getState().openContextFile(d,t)},[d]),Ja=He&&Ze==="preview"&&!ve,Za=m.metadata.variant==="light"?"light":"dark";Vo({container:kc,filePath:f?.path??null,workspaceRoot:d||null,onOpenFile:Ya,enabled:Ja,colorScheme:Za}),Vo({container:Tc,filePath:f?.path??null,workspaceRoot:d||null,onOpenFile:Ya,enabled:Ja,colorScheme:Za});const Zr=jd("unified"),Ft=se.length>rl,Qr=i.useMemo(()=>Ft&&nr?pf(se):void 0,[nr,se,Ft]),Qa=i.useCallback((t,o,l,h)=>{const x={name:t.name,contents:o,lang:ni(t.path)||void 0},S=I=>s.jsx(gd,{file:Ft&&Qr?{...x,cacheKey:`${t.path}:${Qr}`}:x,options:{disableFileHeader:!0,overflow:B?"wrap":"scroll",theme:La,themeType:m.metadata.variant==="dark"?"dark":"light",onPostRender:h},className:Ft?"block w-full":"block h-full w-full",style:Ft?void 0:{height:"100%"}},I);return Ft?s.jsx("div",{className:"h-full",children:s.jsx(vd.Provider,{value:l.virtualizer,children:s.jsx(xd.Provider,{value:Zr,children:S(`${t.path}:${Zr?"pool":"pending"}`)})})}):s.jsx("div",{className:"h-full",children:S(t.path)})},[m.metadata.variant,Ft,Qr,La,Zr,B]),eo=({exitFullscreenOnly:t=!1,layout:o="floating"}={})=>{if(!f)return null;const l=o==="docked",h=zu(Iu("save_file")),x=l?"pointer-events-auto flex 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",S=(D,Oe)=>s.jsxs(Wt,{children:[s.jsx(Ut,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:Oe})}),s.jsx(Gt,{side:"bottom",sideOffset:6,children:D})]}),I=async D=>{if(!(await pr(U)).ok){H.error(n("filesView.toast.copyFailed"));return}if(D){H.success(n("filesView.editor.toast.contentsCopied"));return}_i(!0),Js.current!==null&&window.clearTimeout(Js.current),Js.current=window.setTimeout(()=>{_i(!1)},1200)},K=async D=>{if(!(await pr(ts)).ok){H.error(n("filesView.toast.copyFailed"));return}if(D){H.success(n("sidebarFilesTree.toast.pathCopied"));return}Wi(!0),Zs.current!==null&&window.clearTimeout(Zs.current),Zs.current=window.setTimeout(()=>{Wi(!1)},1200)},ne=()=>{const D=c.downloadFile;D&&D(f.path,_s).catch(Oe=>{console.error("Download failed:",Oe),H.error(n("sidebarFilesTree.toast.operationFailed"))})},G=()=>{Sr?xl():U.trim()&&vl(U)},W=s.jsxs(s.Fragment,{children:[s.jsxs(Vs,{className:"flex items-center gap-2",onClick:()=>{f?.path&&dr(f.path).then(D=>{D||H.error(n("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(k,{name:"external-link",className:"size-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:n("sidebarFilesTree.menu.openInDefaultApp")})]}),Qi.length>0?s.jsx(Ko,{}):null,Qi.map(D=>s.jsxs(Vs,{className:"flex items-center gap-2",onClick:()=>{Bl(D)},children:[s.jsx(hm,{label:D.label,iconDataUrl:D.iconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:D.label})]},D.id)),zl?s.jsxs(Vs,{className:"flex items-center gap-2",onClick:()=>{Il(!0)},children:[s.jsx(k,{name:"refresh",className:"size-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:n("filesView.editor.refreshApps")})]}):null]}),q=[];if(!Br){const D=n(B?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap");q.push({id:"wrap",label:D,icon:s.jsx(k,{name:"text-wrap",className:"size-4"}),onSelect:()=>Se(!B),button:S(D,s.jsx($,{variant:"ghost",size:"sm",onClick:()=>Se(!B),className:Y("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",B?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:D,children:s.jsx(k,{name:"text-wrap",className:"size-4"})}))}),re==="edit"&&(q.push({id:"go-to-line",label:n("filesView.editor.goToLine"),icon:s.jsx(k,{name:"menu-fold-2",className:"size-4"}),onSelect:()=>Vn(!0),button:S(n("filesView.editor.goToLine"),s.jsx($,{variant:"ghost",size:"sm",onClick:Oe=>{Vn(rr=>!rr),Oe.currentTarget.blur()},"data-go-to-line-toggle":!0,className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:n("filesView.editor.goToLine"),children:s.jsx(k,{name:"menu-fold-2",className:"size-4"})}))}),g||q.push({id:"symbols",label:n("filesView.editor.symbols"),icon:s.jsx(k,{name:"list-unordered",className:"size-4"}),onSelect:()=>en(!0),button:S(n("filesView.editor.symbols"),s.jsx($,{variant:"ghost",size:"sm",onClick:Oe=>{en(rr=>!rr),Oe.currentTarget.blur()},"data-document-symbols-toggle":!0,className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent","aria-label":n("filesView.editor.symbols"),children:s.jsx(k,{name:"list-unordered",className:"size-4"})}))}))}if(q.push({id:"open-in-app",label:n("filesView.editor.openInDesktopApp"),icon:s.jsx(k,{name:"file-transfer",className:"size-4"}),submenu:W,button:s.jsxs(fr,{onOpenChange:wt,children:[s.jsxs(Wt,{children:[s.jsx(Ut,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(mr,{asChild:!0,children:s.jsx($,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:n("filesView.editor.openInDesktopApp"),"aria-label":n("filesView.editor.openInDesktopApp"),children:s.jsx(k,{name:"file-transfer",className:"size-4"})})})})}),s.jsx(Gt,{side:"bottom",sideOffset:6,children:n("filesView.editor.openInDesktopApp")})]}),s.jsx(hr,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:W})]})}),He&&Ie()==="preview"&&$l){const D=n(Sr?"filesView.tts.stopSpeaking":"filesView.tts.readAloud");q.push({id:"tts",label:D,icon:s.jsx(k,{name:"volume-up",className:"size-4"}),onSelect:G,button:s.jsxs(Wt,{children:[s.jsx(Ut,{asChild:!0,children:s.jsx($,{variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent","aria-label":D,onClick:G,children:s.jsx(k,{name:"volume-up",className:Y("size-4",Sr&&"animate-pulse text-[var(--primary-text)]")})})}),s.jsx(Gt,{sideOffset:8,children:D})]})})}if(ec&&q.push({id:"copy-contents",label:n("filesView.editor.copyFileContents"),icon:s.jsx(k,{name:"clipboard",className:"size-4"}),onSelect:()=>{I(!0)},button:S(n("filesView.editor.copyFileContents"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>{I(!1)},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:n("filesView.editor.copyFileContents"),"aria-label":n("filesView.editor.copyFileContents"),children:Dl?s.jsx(k,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(k,{name:"clipboard",className:"size-4"})}))}),tc){const D=n("filesView.editor.copyFilePathTitle",{path:ts});q.push({id:"copy-path",label:D,icon:s.jsx(k,{name:"file-copy-2",className:"size-4"}),onSelect:()=>{K(!0)},button:S(D,s.jsx($,{variant:"ghost",size:"sm",onClick:()=>{K(!1)},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:D,"aria-label":D,children:Al?s.jsx(k,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(k,{name:"file-copy-2",className:"size-4"})}))})}c.downloadFile&&q.push({id:"download",label:n("filesView.editor.saveFile"),icon:s.jsx(k,{name:"download",className:"size-4"}),onSelect:ne,button:S(n("filesView.editor.saveFile"),s.jsx($,{variant:"ghost",size:"sm",onClick:ne,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:n("filesView.editor.saveFile"),"aria-label":n("filesView.editor.saveFile"),children:s.jsx(k,{name:"download",className:"size-4"})}))});const le=!l||q.length<=vt.all?q.length:vt.withMenu,$t=q.slice(0,le),ks=q.slice(le),Ke=s.jsxs(s.Fragment,{children:[Ge&&ic&&s.jsxs(s.Fragment,{children:[us?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[s.jsx(k,{name:"loader-4",className:"size-3.5 animate-spin"}),n("filesView.editor.saving")]}):be&&Sl==="saved"&&!Le?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[s.jsx(k,{name:"check",className:"size-3.5"}),n("filesView.editor.saved")]}):Le?S(n(be?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:h}),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>{Ct()},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:n(be?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:h}),"aria-label":n("filesView.editor.saveAria",{shortcut:h}),children:s.jsx(k,{name:"save-3",className:"size-4"})})):null,S(n(be?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>Fl(!be),className:Y("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",be?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:n(be?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),"aria-label":n(be?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),children:be?s.jsx(k,{name:"file-check-fill",className:"size-4"}):s.jsx(k,{name:"file-check",className:"size-4"})}))]}),!Br&&re==="edit"&&s.jsxs(s.Fragment,{children:[S(n("filesView.editor.findInFile"),s.jsx($,{variant:"ghost",size:"sm",onClick:D=>{st(!Ht),D.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:n("filesView.editor.findInFile"),children:s.jsx(k,{name:"search",className:"size-4"})})),s.jsx(Bd,{open:Ll,onOpenChange:Vn,viewRef:ye,variant:"inline"})]}),Xn&&Ge&&!Ss&&!ss&&!Ue&&!Cs&&!Ns&&s.jsx(Rs,{currentMode:re==="view"?"preview":"edit",onToggle:()=>{ac(re==="view"?"edit":"view")}}),He&&S(n(Ie()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>oc(Ie()==="preview"?"edit":"preview"),className:Y("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",Ie()==="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:n(Ie()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),"aria-label":n(Ie()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:s.jsx(k,{name:Ie()==="preview"?"eye":"eye-off",className:"size-4"})})),ur(f?.path??"")&&s.jsx(Rs,{currentMode:ka(),onToggle:()=>{fc(ka()==="preview"?"edit":"preview")}}),Ue&&s.jsx(Rs,{currentMode:Pe,onToggle:()=>lc(Pe==="preview"?"edit":"preview")}),Cs&&s.jsx(Rs,{currentMode:Is,onToggle:()=>cc(Is==="preview"?"edit":"preview")}),Ns&&S(n(Vt==="table"?"filesView.artifact.table.showSource":"filesView.artifact.table.showTable"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>uc(Vt==="table"?"text":"table"),className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:n(Vt==="table"?"filesView.artifact.table.showSource":"filesView.artifact.table.showTable"),"aria-label":n(Vt==="table"?"filesView.artifact.table.showSource":"filesView.artifact.table.showTable"),children:Vt==="table"?s.jsx(k,{name:"code-sslash",className:"size-4"}):s.jsx(k,{name:"table-2",className:"size-4"})})),He&&Ie()==="preview"&&S(n("filesView.editor.findInFile"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>{Dn(!0),Ki(D=>D+1)},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:n("filesView.editor.findInFile"),children:s.jsx(k,{name:"search",className:"size-4"})})),Fs&&s.jsxs(s.Fragment,{children:[!rn&&s.jsx(Rs,{currentMode:at,onToggle:()=>hc(at==="preview"?"edit":"preview")}),at==="preview"&&s.jsx($,{variant:"ghost",size:"sm",onClick:async()=>{await Ct()&&(zi(!0),setTimeout(()=>zi(!1),1500))},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:n("filesView.fileEditor.save"),children:Nl?s.jsx(k,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(k,{name:"save-3",className:"size-4"})})]}),an&&s.jsxs(s.Fragment,{children:[s.jsx(Rs,{currentMode:de,onToggle:()=>mc(de==="preview"?"edit":"preview")}),de==="preview"&&s.jsx($,{variant:"ghost",size:"sm",onClick:async()=>{const D=Di.current?.getXml();if(Ve.current&&(clearTimeout(Ve.current),Ve.current=null),f?.path&&D){if(!await Kr(f.path,D))return;Pn(!0),setTimeout(()=>Pn(!1),1500)}},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:n("filesView.diagram.saveDiagram"),children:Cl?s.jsx(k,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(k,{name:"save-3",className:"size-4"})})]}),Ss&&S(n(Ce==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>dc(Ce==="tree"?"text":"tree"),className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:n(Ce==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),children:Ce==="tree"?s.jsx(k,{name:"code-sslash",className:"size-4"}):s.jsx(k,{name:"node-tree",className:"size-4"})}))]}),gt=t?S(n("filesView.editor.exitFullscreen"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>is(!1),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:n("filesView.editor.exitFullscreen"),"aria-label":n("filesView.editor.exitFullscreen"),children:s.jsx(k,{name:"fullscreen-exit",className:"size-4"})})):!g&&r==="full"?S(n(oe?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>is(!oe),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:n(oe?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),"aria-label":n(oe?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),children:oe?s.jsx(k,{name:"fullscreen-exit",className:"size-4"}):s.jsx(k,{name:"fullscreen",className:"size-4"})})):null,cn=ks.length>0?s.jsxs(fr,{onOpenChange:wt,children:[s.jsxs(Wt,{children:[s.jsx(Ut,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(mr,{asChild:!0,children:s.jsx($,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent","aria-label":n("filesView.editor.moreActions"),children:s.jsx(k,{name:"more",className:"size-4"})})})})}),s.jsx(Gt,{side:"bottom",sideOffset:6,children:n("filesView.editor.moreActions")})]}),s.jsx(hr,{align:"end",className:"w-56",children:ks.map(D=>D.submenu?s.jsxs(Ou,{children:[s.jsxs(Bu,{className:"flex items-center gap-2",children:[D.icon,s.jsx("span",{className:"typography-ui-label text-foreground",children:D.label})]}),s.jsx($u,{className:"w-56 max-h-[70vh] overflow-y-auto",children:D.submenu})]},D.id):s.jsxs(Vs,{className:"flex items-center gap-2",onClick:D.onSelect,children:[D.icon,s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-foreground",children:D.label})]},D.id))})]}):null;return l?s.jsxs("div",{className:x,children:[s.jsx("span",{ref:zs,className:"flex shrink-0 items-center gap-1 empty:hidden",children:Ke}),$t.map(D=>s.jsx(i.Fragment,{children:D.button},D.id)),cn,s.jsx("span",{ref:Tt,className:"flex shrink-0 items-center gap-1 empty:hidden",children:gt})]}):s.jsxs("div",{className:x,children:[Ke,q.map(D=>s.jsx(i.Fragment,{children:D.button},D.id)),gt]})},to=i.useRef(null);i.useEffect(()=>{Q&&(Ks.current&&to.current===Q&&xn(t=>t+1),to.current=Q)},[Q]);const Dc=i.useCallback(async()=>{const t=xt.current;if(!t)throw new Error("No file is open.");const o=ct(t),l=await mn("/api/fs/raw",{signal:AbortSignal.timeout(6e4),cache:"no-store",query:{path:t,allowOutsideWorkspace:o.allowOutsideWorkspace?"true":void 0,directory:d||void 0}});if(!l.ok)throw new Error(n("filesView.error.readFileFailed"));return new Uint8Array(await l.arrayBuffer())},[ct,d,n]),so=i.useCallback(t=>{const o=xt.current;o&&(qt.current[o]="edit"),ft(!1),Z("edit"),H.error(t)},[]),no=r==="full"&&oe,Ac=f?`${Us??f.path}:${hl}:${no?"fullscreen":"docked"}`:"",ro=Jr&&f&&je?s.jsx("div",{ref:Oi,className:"h-full overflow-hidden",style:{minHeight:"400px"},children:s.jsx(xf,{ref:ds,guestId:je.guestId,editorId:je.editor.id,title:je.editor.title,contentKind:rn?"binary":"text",path:ts||f.path,content:se,loadBytes:Dc,readOnly:!f||En||!c.writeFile||rn&&!c.uploadFile,onDirtyChange:ft,onEdit:()=>{Bi.current=Date.now()},onSaveRequest:va,onUnsupported:wc,onTooLarge:()=>so(n("filesView.fileEditor.tooLarge",{editor:je.editor.title})),onLoadFailed:()=>so(n("filesView.error.readFileFailed"))},`${Ac}:${je.guestId}:${je.editor.id}`)}):null,Lc=i.useCallback(()=>{const t=qe.getState();t.requestSettingsJump("integrations","integrations.extensions.excalidraw"),t.setSettingsDialogOpen(!0)},[]),ei=s.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[s.jsx($o,{open:Tr,onOpenChange:t=>{t||qs(!0)},children:s.jsxs(_o,{showCloseButton:!1,className:"max-w-md",children:[s.jsxs(Wo,{children:[s.jsx(Uo,{children:n("filesView.unsaved.title")}),s.jsx(Go,{children:n("filesView.unsaved.description")})]}),s.jsxs(Ho,{children:[s.jsx($,{variant:"outline",onClick:()=>{ql()},disabled:us,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:n("filesView.unsaved.saveChanges")}),s.jsx($,{variant:"destructive",onClick:Kl,children:n("filesView.unsaved.discard")})]})]})}),s.jsxs("div",{className:Y("flex flex-col flex-shrink-0",L&&"border-b border-border/40"),children:[L?s.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[g&&ce&&s.jsx("button",{type:"button",onClick:()=>ge(!1),"aria-label":n("filesView.editor.back"),className:"inline-flex size-7 flex-shrink-0 items-center justify-center me-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:s.jsx(k,{name:"arrow-left-s",className:"size-5"})}),g?f?s.jsxs(fr,{children:[s.jsx(mr,{asChild:!0,children:s.jsxs("button",{type:"button",className:"inline-flex min-w-0 max-w-full items-center gap-1 text-start typography-ui-label font-medium","aria-label":n("filesView.editor.openFilesAria"),children:[s.jsx(Ds,{filePath:f.path,extension:f.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(zo,{name:f.name}),s.jsx(k,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),s.jsx(hr,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:cs.map(t=>{const o=f?.path===t.path;return s.jsxs(Vs,{onSelect:l=>{if(l.target.closest("[data-close-open-file]")){l.preventDefault();return}o||We(t)},className:Y("flex min-w-0 items-center justify-between gap-2 overflow-hidden",o&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[s.jsx(Ds,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(zo,{name:t.name})]}),s.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:l=>{l.preventDefault(),l.stopPropagation()},onClick:l=>{l.preventDefault(),l.stopPropagation(),nn(t.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":n("filesView.editor.closeFileAria",{name:t.name}),children:s.jsx(k,{name:"close",className:"size-3.5"})})]},t.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:n("filesView.editor.selectFile")}):cs.length>0?s.jsxs("div",{className:"relative min-w-0 flex-1",children:[Fi.start&&s.jsx("div",{className:"pointer-events-none absolute inset-s-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r rtl:bg-gradient-to-l from-background to-transparent"}),Fi.end&&s.jsx("div",{className:"pointer-events-none absolute inset-e-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l rtl:bg-gradient-to-r from-background to-transparent"}),s.jsx("div",{ref:yr,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:cs.map(t=>{const o=f?.path===t.path;return s.jsxs("div",{title:fn(d,t.path),className:Y("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",o?"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:[s.jsx(Ds,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),s.jsx("button",{type:"button",onClick:()=>{o||We(t)},className:"max-w-[12rem] truncate text-start",children:t.name}),s.jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),nn(t.path)},className:Y("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!o&&!N&&"opacity-0 group-hover:opacity-100"),"aria-label":n("filesView.editor.closeFileAria",{name:t.name}),children:s.jsx(k,{name:"close",className:"size-3.5"})})]},t.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:n("filesView.editor.selectFile")})]}):null,f?s.jsxs("div",{ref:Rt,className:"flex h-8 min-w-0 shrink-0 items-center gap-3 border-t border-border/40 px-2",children:[ts&&!g?s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:ts,children:ts}):null,s.jsx("div",{className:"ms-auto min-w-0 shrink-0 overflow-x-auto",children:eo({layout:"docked"})})]}):null]}),rc?s.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2 border-b border-border/40 bg-[var(--surface-muted)] px-3 py-1.5 typography-ui text-muted-foreground",children:[s.jsx(k,{name:"information",className:"size-4 shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:n("filesView.excalidraw.installHint")}),s.jsx($,{type:"button",size:"xs",variant:"outline",onClick:Lc,children:n("filesView.excalidraw.installAction")})]}):null,s.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:s.jsx(ai,{ref:Fc,outerClassName:"h-full min-w-0",className:Y("h-full min-w-0",Ft&&"[overflow-anchor:none]"),children:f?ve||Yr?O?s.jsx("div",{className:"p-3"}):s.jsxs("div",{className:"p-3 flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(k,{name:"loader-4",className:"size-4 animate-spin"}),n("filesView.state.loading")]}):Qe?s.jsx("div",{className:"p-3 typography-ui text-[color:var(--status-error)]",children:Qe}):Jr?no?s.jsx("div",{className:"h-full"}):ro:tr||(f&&an&&de==="preview"?s.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:s.jsx(wf,{ref:Di,xml:gc,onChange:pc},`${Us??f.path}:${fl}`)}):f&&Ss&&Ce==="tree"?s.jsx(ar,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:n("filesView.error.jsonViewerUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:n("filesView.error.switchToTextMode")})]}),children:s.jsx("div",{className:"h-full overflow-auto",children:s.jsx(pd,{jsonString:U,maxHeight:"100%",initiallyExpandedDepth:2})})}):f&&He&&Ie()==="preview"?s.jsxs("div",{className:"relative h-full min-h-0",children:[s.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-3 outline-none",tabIndex:-1,onMouseDown:Ln,ref:Pc,children:[s.jsx(vo,{containerRef:na,filePath:f.path,fileContent:U}),U.length>500*1024&&s.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:n("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(U.length/1024)})}),s.jsx(ar,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:n("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:n("filesView.error.switchToEditMode")})]}),children:s.jsx("div",{style:Ra,children:s.jsx(oi,{content:U,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1,allowRawHtml:!0})})})]}),!oe&&s.jsx(jo,{containerRef:An,open:Gi,onOpenChange:Dn,focusNonce:Hi})]}):f&&ss&&Ne==="preview"?!u.isVSCode&&rs.status==="loading"?s.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:n("common.loading")}):s.jsx("div",{className:"h-full overflow-hidden",children:s.jsx("iframe",{src:rs.status==="ready"?rs.url:void 0,srcDoc:u.isVSCode?(()=>{const t=f.path.substring(0,f.path.lastIndexOf("/")+1);return t?U.replace(/<head([^>]*)>/i,`<head$1><base href="${t}">`):U})():void 0,className:"w-full h-full border-none",sandbox:"allow-scripts allow-forms allow-popups allow-modals allow-downloads",title:n("filesView.editor.htmlPreviewTitle")})}):f&&Xn&&re==="view"?Qa(f,se,$a,Cc):s.jsxs("div",{className:Y("relative h-full",js&&"overflow-hidden"),ref:Qs,children:[!oe&&s.jsx(yo,{open:Ui,onOpenChange:en,viewRef:ye}),s.jsx("div",{className:Y("h-full",js&&"invisible"),children:s.jsx(Oo,{positionKey:At,detached:!e,value:se,onChange:fe,readOnly:!Ge,vimMode:xs==="vim",extensions:Aa,className:"h-full",blockWidgets:Sc,onViewReady:t=>{ye.current=t,Jn(t),Mr(o=>o+1),window.requestAnimationFrame(()=>{Es(t)})},onViewDestroy:()=>{ye.current&&(ye.current=null),Mr(t=>t+1)},enableSearch:!0,searchOpen:Ht,onSearchOpenChange:st,highlightLines:J?{start:Math.min(J.start,J.end),end:Math.max(J.start,J.end)}:void 0,lineNumbersConfig:vc},At)}),js&&s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:s.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(k,{name:"loader-4",className:"size-4 animate-spin"}),n("filesView.state.openingFileAtChange")]})})]})):s.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:n("filesView.editor.pickFileFromTree")})})})]}),zc=!!(d&&Ri[d]),io=d?kn[d]:null,ao=P?s.jsxs("section",{className:Y("flex min-h-0 flex-col overflow-hidden",g?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[s.jsx("div",{className:Y("flex flex-col gap-2 py-2",g?"px-3":"px-2"),children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1 min-w-0",children:[s.jsx(k,{name:"search",className:"pointer-events-none absolute inset-s-2 top-2 size-4 text-muted-foreground"}),s.jsx(pn,{ref:me,value:ie,onChange:t=>pe(t.target.value),placeholder:n("filesView.tree.search.placeholder"),className:"h-8 ps-8 pe-8 typography-meta"}),ie.trim().length>0&&s.jsx("button",{type:"button","aria-label":n("filesView.tree.search.clearAria"),className:"absolute inset-e-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{pe(""),me.current?.focus()},children:s.jsx(k,{name:"close",className:"size-4"})})]}),s.jsxs(Wt,{children:[s.jsx(Ut,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx($,{variant:"ghost",size:"sm",onClick:()=>Dr("createFile",{path:b,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:n("filesView.tree.actions.newFileTitle"),"aria-label":n("filesView.tree.actions.newFileTitle"),children:s.jsx(k,{name:"file-add",className:"size-4"})})})}),s.jsx(Gt,{side:"bottom",sideOffset:6,children:n("filesView.tree.actions.newFileTitle")})]}),s.jsxs(Wt,{children:[s.jsx(Ut,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx($,{variant:"ghost",size:"sm",onClick:()=>Dr("createFolder",{path:b,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:n("filesView.tree.actions.newFolderTitle"),"aria-label":n("filesView.tree.actions.newFolderTitle"),children:s.jsx(k,{name:"folder-add",className:"size-4"})})})}),s.jsx(Gt,{side:"bottom",sideOffset:6,children:n("filesView.tree.actions.newFolderTitle")})]}),ma&&s.jsxs(Wt,{children:[s.jsx(Ut,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx($,{variant:"ghost",size:"sm",onClick:()=>ha(d),disabled:!d||_n,className:"size-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.uploadFilesTitle"),"aria-label":n("sidebarFilesTree.actions.uploadFilesTitle"),children:s.jsx(k,{name:_n?"loader-4":"upload-2",className:Y("size-4",_n&&"animate-spin")})})})}),s.jsx(Gt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.uploadFilesTitle")})]}),s.jsx(md,{className:"size-8"}),s.jsxs(Wt,{children:[s.jsx(Ut,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx($,{variant:"ghost",size:"sm",onClick:()=>{$n()},className:"size-8 p-0 flex-shrink-0",title:n("filesView.tree.actions.refreshTitle"),"aria-label":n("filesView.tree.actions.refreshTitle"),children:s.jsx(k,{name:"refresh",className:"size-4"})})})}),s.jsx(Gt,{side:"bottom",sideOffset:6,children:n("filesView.tree.actions.refreshTitle")})]})]})}),s.jsx(ai,{outerClassName:"flex-1 min-h-0",className:Y("py-2",g?"px-3":"px-2"),children:s.jsx("ul",{className:"flex flex-col",children:wl?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(k,{name:"loader-4",className:"size-4 animate-spin"}),n("filesView.tree.search.searching")]}):Ti.length>0?Ti.map(t=>{const o=f?.path===t.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>{We(t)},className:Y("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-start transition-colors",Jo(o)),children:[s.jsx(Ds,{filePath:t.path,extension:t.extension,className:"size-3.5"}),s.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl"},title:t.path,children:t.relativePath??t.path})]})},t.path)}):io?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"text-[var(--status-error)]",children:io}),s.jsxs($,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{$n()},children:[s.jsx(k,{name:"refresh",className:"size-3.5"}),n("filesView.tree.actions.refreshTitle")]})]}):zc?ja(d,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:n("filesView.state.loading")})})})]}):null,Ic=r==="full"&&oe&&f&&s.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:s.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[s.jsx("div",{className:"absolute inset-e-4 top-4 z-30",children:eo({exitFullscreenOnly:!0})}),s.jsx(ai,{ref:Ec,outerClassName:"h-full min-w-0",className:Y("h-full min-w-0",Ft&&"[overflow-anchor:none]"),children:ve||Yr?O?s.jsx("div",{className:"p-4"}):s.jsxs("div",{className:"p-4 flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(k,{name:"loader-4",className:"size-4 animate-spin"}),"Loading…"]}):Qe?s.jsx("div",{className:"p-4 typography-ui text-[color:var(--status-error)]",children:Qe}):Jr?ro:tr||(He&&Ie()==="preview"?s.jsxs("div",{className:"relative h-full min-h-0",children:[s.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-4 outline-none",tabIndex:-1,onMouseDown:Ln,ref:Vc,children:[f?s.jsx(vo,{containerRef:zn,filePath:f.path,fileContent:U}):null,U.length>500*1024&&s.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:n("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(U.length/1024)})}),s.jsx(ar,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:n("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:n("filesView.error.switchToEditMode")})]}),children:s.jsx("div",{style:Ra,children:s.jsx(oi,{content:U,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1,allowRawHtml:!0})})})]}),s.jsx(jo,{containerRef:zn,open:Gi,onOpenChange:Dn,focusNonce:Hi,className:"inset-e-4 top-16"})]}):Xn&&re==="view"?Qa(f,se,_a,Nc):s.jsxs("div",{className:Y("relative h-full",js&&"overflow-hidden"),children:[s.jsx(yo,{open:Ui,onOpenChange:en,viewRef:ye}),s.jsx("div",{className:Y("h-full",js&&"invisible"),children:s.jsx(Oo,{positionKey:`${At}:fullscreen`,value:se,onChange:fe,readOnly:!Ge,vimMode:xs==="vim",extensions:Aa,className:"h-full",onViewReady:t=>{ye.current=t,Jn(t),window.requestAnimationFrame(()=>{Es(t)})},onViewDestroy:()=>{ye.current&&(ye.current=null)}},`${At}:fullscreen`)}),js&&s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:s.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(k,{name:"loader-4",className:"size-4 animate-spin"}),n("filesView.state.openingFileAtChange")]})})]}))})]})});return s.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[s.jsx(Sm,{activeDialog:Qt,dialogData:es,dialogInputValue:zt,onDialogInputChange:$i,isDialogSubmitting:Rl,onDialogSubmit:Hl,onClose:jc,inputRef:jl}),Gl,Ic,g?ce?ei:ao:r==="editor-only"?s.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:ei})}):s.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[C>=700&&s.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:ao}),s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:ei})]})]})};function Fm(r){return r+1}export{Gp as FilesView};
|
|
14
|
+
\`\`\``,className:"markdown-mermaid-fullscreen h-full",enableFileReferences:!1,allowMermaidWheelEvents:!0})})}):null)(f):null;i.useEffect(()=>{let t=!1,o="";return(async()=>{if(!f?.path||!ze||Ue){bt("");return}xe(null);const h=ct(f.path);if(t)return;await(c.readFileBinary?c.readFileBinary(f.path,h).then(S=>S.dataUrl):(async()=>{const S=await mn("/api/fs/raw",{signal:AbortSignal.timeout(3e4),query:{path:f.path,allowOutsideWorkspace:h.allowOutsideWorkspace?"true":void 0,directory:d||void 0}});if(!S.ok)throw new Error(n("filesView.error.readFileFailed"));const I=await S.blob();return o=URL.createObjectURL(I),t?(URL.revokeObjectURL(o),o="",""):o})()).then(S=>{t||(bt(S),ue(f.path))}).catch(S=>{t||(bt(""),xe(S instanceof Error?S.message:n("filesView.error.readFileFailed")),ue(null))}).finally(()=>{t||Dt(!1)})})(),()=>{t=!0,o&&URL.revokeObjectURL(o)}},[ms,c,ze,Ue,ct,d,f?.path,_s,n]);const jc=i.useCallback(()=>Pr(null),[]),Sc=i.useMemo(()=>zd({drafts:ra,editingDraftId:Bn,commentText:On,onTextChange:ia,selection:J,isDragging:ta,fileLabel:f?.path??"",newWidgetId:"files-new-comment-input",mapDraftToRange:t=>({start:t.startLine,end:t.endLine}),onSave:da,onCancel:()=>{et(null),sn()},onEdit:t=>{ca(t),et({start:t.startLine,end:t.endLine})},onDelete:ua}),[sn,On,ua,Bn,ra,da,ta,J,f?.path,ia,ca]),$a=Co(),_a=Co(),sr=!ve&&!Qe&&Q===Fe,Jr=i.useMemo(()=>!!Fe&&vf({hasCanvas:Fs,viewMode:at,previewReady:sr,mountable:on}),[on,at,Fs,sr,Fe]),nr=sr&&Xn&&re==="view"&&!(Ss&&Ce==="tree"),Wa=sr&&He&&Ie()==="preview",{setScroller:Ua,restore:Cc}=or(nr?`${At}:code`:null),{setScroller:Ga,restore:Nc}=or(nr?`${At}:code:fullscreen`:null),{setScroller:Ha}=or(Wa?`${At}:markdown`:null),{setScroller:Ka}=or(Wa?`${At}:markdown:fullscreen`:null),{setScroller:qa}=$a,{setScroller:Xa}=_a,Fc=i.useCallback(t=>{qa(t),Ua(t)},[qa,Ua]),Ec=i.useCallback(t=>{Xa(t),Ga(t)},[Xa,Ga]),[kc,Rc]=i.useState(null),[Tc,Mc]=i.useState(null),Pc=i.useCallback(t=>{na.current=t,An.current=t,Rc(t),Ha(t)},[Ha]),Vc=i.useCallback(t=>{zn.current=t,Mc(t),Ka(t)},[Ka]),Ya=i.useCallback(t=>{d&&qe.getState().openContextFile(d,t)},[d]),Ja=He&&Ze==="preview"&&!ve,Za=m.metadata.variant==="light"?"light":"dark";Vo({container:kc,filePath:f?.path??null,workspaceRoot:d||null,onOpenFile:Ya,enabled:Ja,colorScheme:Za}),Vo({container:Tc,filePath:f?.path??null,workspaceRoot:d||null,onOpenFile:Ya,enabled:Ja,colorScheme:Za});const Zr=jd("unified"),Ft=se.length>rl,Qr=i.useMemo(()=>Ft&&nr?pf(se):void 0,[nr,se,Ft]),Qa=i.useCallback((t,o,l,h)=>{const x={name:t.name,contents:o,lang:ni(t.path)||void 0},S=I=>s.jsx(gd,{file:Ft&&Qr?{...x,cacheKey:`${t.path}:${Qr}`}:x,options:{disableFileHeader:!0,overflow:B?"wrap":"scroll",theme:La,themeType:m.metadata.variant==="dark"?"dark":"light",onPostRender:h},className:Ft?"block w-full":"block h-full w-full",style:Ft?void 0:{height:"100%"}},I);return Ft?s.jsx("div",{className:"h-full",children:s.jsx(vd.Provider,{value:l.virtualizer,children:s.jsx(xd.Provider,{value:Zr,children:S(`${t.path}:${Zr?"pool":"pending"}`)})})}):s.jsx("div",{className:"h-full",children:S(t.path)})},[m.metadata.variant,Ft,Qr,La,Zr,B]),eo=({exitFullscreenOnly:t=!1,layout:o="floating"}={})=>{if(!f)return null;const l=o==="docked",h=zu(Iu("save_file")),x=l?"pointer-events-auto flex 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",S=(D,Oe)=>s.jsxs(Wt,{children:[s.jsx(Ut,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:Oe})}),s.jsx(Gt,{side:"bottom",sideOffset:6,children:D})]}),I=async D=>{if(!(await pr(U)).ok){H.error(n("filesView.toast.copyFailed"));return}if(D){H.success(n("filesView.editor.toast.contentsCopied"));return}_i(!0),Js.current!==null&&window.clearTimeout(Js.current),Js.current=window.setTimeout(()=>{_i(!1)},1200)},K=async D=>{if(!(await pr(ts)).ok){H.error(n("filesView.toast.copyFailed"));return}if(D){H.success(n("sidebarFilesTree.toast.pathCopied"));return}Wi(!0),Zs.current!==null&&window.clearTimeout(Zs.current),Zs.current=window.setTimeout(()=>{Wi(!1)},1200)},ne=()=>{const D=c.downloadFile;D&&D(f.path,_s).catch(Oe=>{console.error("Download failed:",Oe),H.error(n("sidebarFilesTree.toast.operationFailed"))})},G=()=>{Sr?xl():U.trim()&&vl(U)},W=s.jsxs(s.Fragment,{children:[s.jsxs(Vs,{className:"flex items-center gap-2",onClick:()=>{f?.path&&dr(f.path).then(D=>{D||H.error(n("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(k,{name:"external-link",className:"size-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:n("sidebarFilesTree.menu.openInDefaultApp")})]}),Qi.length>0?s.jsx(Ko,{}):null,Qi.map(D=>s.jsxs(Vs,{className:"flex items-center gap-2",onClick:()=>{Bl(D)},children:[s.jsx(hm,{label:D.label,iconDataUrl:D.iconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:D.label})]},D.id)),zl?s.jsxs(Vs,{className:"flex items-center gap-2",onClick:()=>{Il(!0)},children:[s.jsx(k,{name:"refresh",className:"size-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:n("filesView.editor.refreshApps")})]}):null]}),q=[];if(!Br){const D=n(B?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap");q.push({id:"wrap",label:D,icon:s.jsx(k,{name:"text-wrap",className:"size-4"}),onSelect:()=>Se(!B),button:S(D,s.jsx($,{variant:"ghost",size:"sm",onClick:()=>Se(!B),className:Y("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",B?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:D,children:s.jsx(k,{name:"text-wrap",className:"size-4"})}))}),re==="edit"&&(q.push({id:"go-to-line",label:n("filesView.editor.goToLine"),icon:s.jsx(k,{name:"menu-fold-2",className:"size-4"}),onSelect:()=>Vn(!0),button:S(n("filesView.editor.goToLine"),s.jsx($,{variant:"ghost",size:"sm",onClick:Oe=>{Vn(rr=>!rr),Oe.currentTarget.blur()},"data-go-to-line-toggle":!0,className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:n("filesView.editor.goToLine"),children:s.jsx(k,{name:"menu-fold-2",className:"size-4"})}))}),g||q.push({id:"symbols",label:n("filesView.editor.symbols"),icon:s.jsx(k,{name:"list-unordered",className:"size-4"}),onSelect:()=>en(!0),button:S(n("filesView.editor.symbols"),s.jsx($,{variant:"ghost",size:"sm",onClick:Oe=>{en(rr=>!rr),Oe.currentTarget.blur()},"data-document-symbols-toggle":!0,className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent","aria-label":n("filesView.editor.symbols"),children:s.jsx(k,{name:"list-unordered",className:"size-4"})}))}))}if(q.push({id:"open-in-app",label:n("filesView.editor.openInDesktopApp"),icon:s.jsx(k,{name:"file-transfer",className:"size-4"}),submenu:W,button:s.jsxs(fr,{onOpenChange:wt,children:[s.jsxs(Wt,{children:[s.jsx(Ut,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(mr,{asChild:!0,children:s.jsx($,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:n("filesView.editor.openInDesktopApp"),"aria-label":n("filesView.editor.openInDesktopApp"),children:s.jsx(k,{name:"file-transfer",className:"size-4"})})})})}),s.jsx(Gt,{side:"bottom",sideOffset:6,children:n("filesView.editor.openInDesktopApp")})]}),s.jsx(hr,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:W})]})}),He&&Ie()==="preview"&&$l){const D=n(Sr?"filesView.tts.stopSpeaking":"filesView.tts.readAloud");q.push({id:"tts",label:D,icon:s.jsx(k,{name:"volume-up",className:"size-4"}),onSelect:G,button:s.jsxs(Wt,{children:[s.jsx(Ut,{asChild:!0,children:s.jsx($,{variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent","aria-label":D,onClick:G,children:s.jsx(k,{name:"volume-up",className:Y("size-4",Sr&&"animate-pulse text-[var(--primary-text)]")})})}),s.jsx(Gt,{sideOffset:8,children:D})]})})}if(ec&&q.push({id:"copy-contents",label:n("filesView.editor.copyFileContents"),icon:s.jsx(k,{name:"clipboard",className:"size-4"}),onSelect:()=>{I(!0)},button:S(n("filesView.editor.copyFileContents"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>{I(!1)},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:n("filesView.editor.copyFileContents"),"aria-label":n("filesView.editor.copyFileContents"),children:Dl?s.jsx(k,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(k,{name:"clipboard",className:"size-4"})}))}),tc){const D=n("filesView.editor.copyFilePathTitle",{path:ts});q.push({id:"copy-path",label:D,icon:s.jsx(k,{name:"file-copy-2",className:"size-4"}),onSelect:()=>{K(!0)},button:S(D,s.jsx($,{variant:"ghost",size:"sm",onClick:()=>{K(!1)},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:D,"aria-label":D,children:Al?s.jsx(k,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(k,{name:"file-copy-2",className:"size-4"})}))})}c.downloadFile&&q.push({id:"download",label:n("filesView.editor.saveFile"),icon:s.jsx(k,{name:"download",className:"size-4"}),onSelect:ne,button:S(n("filesView.editor.saveFile"),s.jsx($,{variant:"ghost",size:"sm",onClick:ne,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:n("filesView.editor.saveFile"),"aria-label":n("filesView.editor.saveFile"),children:s.jsx(k,{name:"download",className:"size-4"})}))});const le=!l||q.length<=vt.all?q.length:vt.withMenu,$t=q.slice(0,le),ks=q.slice(le),Ke=s.jsxs(s.Fragment,{children:[Ge&&ic&&s.jsxs(s.Fragment,{children:[us?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[s.jsx(k,{name:"loader-4",className:"size-3.5 animate-spin"}),n("filesView.editor.saving")]}):be&&Sl==="saved"&&!Le?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[s.jsx(k,{name:"check",className:"size-3.5"}),n("filesView.editor.saved")]}):Le?S(n(be?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:h}),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>{Ct()},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:n(be?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:h}),"aria-label":n("filesView.editor.saveAria",{shortcut:h}),children:s.jsx(k,{name:"save-3",className:"size-4"})})):null,S(n(be?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>Fl(!be),className:Y("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",be?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:n(be?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),"aria-label":n(be?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),children:be?s.jsx(k,{name:"file-check-fill",className:"size-4"}):s.jsx(k,{name:"file-check",className:"size-4"})}))]}),!Br&&re==="edit"&&s.jsxs(s.Fragment,{children:[S(n("filesView.editor.findInFile"),s.jsx($,{variant:"ghost",size:"sm",onClick:D=>{st(!Ht),D.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:n("filesView.editor.findInFile"),children:s.jsx(k,{name:"search",className:"size-4"})})),s.jsx(Bd,{open:Ll,onOpenChange:Vn,viewRef:ye,variant:"inline"})]}),Xn&&Ge&&!Ss&&!ss&&!Ue&&!Cs&&!Ns&&s.jsx(Rs,{currentMode:re==="view"?"preview":"edit",onToggle:()=>{ac(re==="view"?"edit":"view")}}),He&&S(n(Ie()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>oc(Ie()==="preview"?"edit":"preview"),className:Y("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",Ie()==="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:n(Ie()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),"aria-label":n(Ie()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:s.jsx(k,{name:Ie()==="preview"?"eye":"eye-off",className:"size-4"})})),ur(f?.path??"")&&s.jsx(Rs,{currentMode:ka(),onToggle:()=>{fc(ka()==="preview"?"edit":"preview")}}),Ue&&s.jsx(Rs,{currentMode:Pe,onToggle:()=>lc(Pe==="preview"?"edit":"preview")}),Cs&&s.jsx(Rs,{currentMode:Is,onToggle:()=>cc(Is==="preview"?"edit":"preview")}),Ns&&S(n(Vt==="table"?"filesView.artifact.table.showSource":"filesView.artifact.table.showTable"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>uc(Vt==="table"?"text":"table"),className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:n(Vt==="table"?"filesView.artifact.table.showSource":"filesView.artifact.table.showTable"),"aria-label":n(Vt==="table"?"filesView.artifact.table.showSource":"filesView.artifact.table.showTable"),children:Vt==="table"?s.jsx(k,{name:"code-sslash",className:"size-4"}):s.jsx(k,{name:"table-2",className:"size-4"})})),He&&Ie()==="preview"&&S(n("filesView.editor.findInFile"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>{Dn(!0),Ki(D=>D+1)},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:n("filesView.editor.findInFile"),children:s.jsx(k,{name:"search",className:"size-4"})})),Fs&&s.jsxs(s.Fragment,{children:[!rn&&s.jsx(Rs,{currentMode:at,onToggle:()=>hc(at==="preview"?"edit":"preview")}),at==="preview"&&s.jsx($,{variant:"ghost",size:"sm",onClick:async()=>{await Ct()&&(zi(!0),setTimeout(()=>zi(!1),1500))},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:n("filesView.fileEditor.save"),children:Nl?s.jsx(k,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(k,{name:"save-3",className:"size-4"})})]}),an&&s.jsxs(s.Fragment,{children:[s.jsx(Rs,{currentMode:de,onToggle:()=>mc(de==="preview"?"edit":"preview")}),de==="preview"&&s.jsx($,{variant:"ghost",size:"sm",onClick:async()=>{const D=Di.current?.getXml();if(Ve.current&&(clearTimeout(Ve.current),Ve.current=null),f?.path&&D){if(!await Kr(f.path,D))return;Pn(!0),setTimeout(()=>Pn(!1),1500)}},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:n("filesView.diagram.saveDiagram"),children:Cl?s.jsx(k,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(k,{name:"save-3",className:"size-4"})})]}),Ss&&S(n(Ce==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>dc(Ce==="tree"?"text":"tree"),className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:n(Ce==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),children:Ce==="tree"?s.jsx(k,{name:"code-sslash",className:"size-4"}):s.jsx(k,{name:"node-tree",className:"size-4"})}))]}),gt=t?S(n("filesView.editor.exitFullscreen"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>is(!1),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:n("filesView.editor.exitFullscreen"),"aria-label":n("filesView.editor.exitFullscreen"),children:s.jsx(k,{name:"fullscreen-exit",className:"size-4"})})):!g&&r==="full"?S(n(oe?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>is(!oe),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:n(oe?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),"aria-label":n(oe?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),children:oe?s.jsx(k,{name:"fullscreen-exit",className:"size-4"}):s.jsx(k,{name:"fullscreen",className:"size-4"})})):null,cn=ks.length>0?s.jsxs(fr,{onOpenChange:wt,children:[s.jsxs(Wt,{children:[s.jsx(Ut,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(mr,{asChild:!0,children:s.jsx($,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent","aria-label":n("filesView.editor.moreActions"),children:s.jsx(k,{name:"more",className:"size-4"})})})})}),s.jsx(Gt,{side:"bottom",sideOffset:6,children:n("filesView.editor.moreActions")})]}),s.jsx(hr,{align:"end",className:"w-56",children:ks.map(D=>D.submenu?s.jsxs(Ou,{children:[s.jsxs(Bu,{className:"flex items-center gap-2",children:[D.icon,s.jsx("span",{className:"typography-ui-label text-foreground",children:D.label})]}),s.jsx($u,{className:"w-56 max-h-[70vh] overflow-y-auto",children:D.submenu})]},D.id):s.jsxs(Vs,{className:"flex items-center gap-2",onClick:D.onSelect,children:[D.icon,s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-foreground",children:D.label})]},D.id))})]}):null;return l?s.jsxs("div",{className:x,children:[s.jsx("span",{ref:zs,className:"flex shrink-0 items-center gap-1 empty:hidden",children:Ke}),$t.map(D=>s.jsx(i.Fragment,{children:D.button},D.id)),cn,s.jsx("span",{ref:Tt,className:"flex shrink-0 items-center gap-1 empty:hidden",children:gt})]}):s.jsxs("div",{className:x,children:[Ke,q.map(D=>s.jsx(i.Fragment,{children:D.button},D.id)),gt]})},to=i.useRef(null);i.useEffect(()=>{Q&&(Ks.current&&to.current===Q&&xn(t=>t+1),to.current=Q)},[Q]);const Dc=i.useCallback(async()=>{const t=xt.current;if(!t)throw new Error("No file is open.");const o=ct(t),l=await mn("/api/fs/raw",{signal:AbortSignal.timeout(6e4),cache:"no-store",query:{path:t,allowOutsideWorkspace:o.allowOutsideWorkspace?"true":void 0,directory:d||void 0}});if(!l.ok)throw new Error(n("filesView.error.readFileFailed"));return new Uint8Array(await l.arrayBuffer())},[ct,d,n]),so=i.useCallback(t=>{const o=xt.current;o&&(qt.current[o]="edit"),ft(!1),Z("edit"),H.error(t)},[]),no=r==="full"&&oe,Ac=f?`${Us??f.path}:${hl}:${no?"fullscreen":"docked"}`:"",ro=Jr&&f&&je?s.jsx("div",{ref:Oi,className:"h-full overflow-hidden",style:{minHeight:"400px"},children:s.jsx(xf,{ref:ds,guestId:je.guestId,editorId:je.editor.id,title:je.editor.title,contentKind:rn?"binary":"text",path:ts||f.path,content:se,loadBytes:Dc,readOnly:!f||En||!c.writeFile||rn&&!c.uploadFile,onDirtyChange:ft,onEdit:()=>{Bi.current=Date.now()},onSaveRequest:va,onUnsupported:wc,onTooLarge:()=>so(n("filesView.fileEditor.tooLarge",{editor:je.editor.title})),onLoadFailed:()=>so(n("filesView.error.readFileFailed"))},`${Ac}:${je.guestId}:${je.editor.id}`)}):null,Lc=i.useCallback(()=>{const t=qe.getState();t.requestSettingsJump("integrations","integrations.extensions.excalidraw"),t.setSettingsDialogOpen(!0)},[]),ei=s.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[s.jsx($o,{open:Tr,onOpenChange:t=>{t||qs(!0)},children:s.jsxs(_o,{showCloseButton:!1,className:"max-w-md",children:[s.jsxs(Wo,{children:[s.jsx(Uo,{children:n("filesView.unsaved.title")}),s.jsx(Go,{children:n("filesView.unsaved.description")})]}),s.jsxs(Ho,{children:[s.jsx($,{variant:"outline",onClick:()=>{ql()},disabled:us,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:n("filesView.unsaved.saveChanges")}),s.jsx($,{variant:"destructive",onClick:Kl,children:n("filesView.unsaved.discard")})]})]})}),s.jsxs("div",{className:Y("flex flex-col flex-shrink-0",L&&"border-b border-border/40"),children:[L?s.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[g&&ce&&s.jsx("button",{type:"button",onClick:()=>ge(!1),"aria-label":n("filesView.editor.back"),className:"inline-flex size-7 flex-shrink-0 items-center justify-center me-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:s.jsx(k,{name:"arrow-left-s",className:"size-5"})}),g?f?s.jsxs(fr,{children:[s.jsx(mr,{asChild:!0,children:s.jsxs("button",{type:"button",className:"inline-flex min-w-0 max-w-full items-center gap-1 text-start typography-ui-label font-medium","aria-label":n("filesView.editor.openFilesAria"),children:[s.jsx(Ds,{filePath:f.path,extension:f.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(zo,{name:f.name}),s.jsx(k,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),s.jsx(hr,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:cs.map(t=>{const o=f?.path===t.path;return s.jsxs(Vs,{onSelect:l=>{if(l.target.closest("[data-close-open-file]")){l.preventDefault();return}o||We(t)},className:Y("flex min-w-0 items-center justify-between gap-2 overflow-hidden",o&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[s.jsx(Ds,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(zo,{name:t.name})]}),s.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:l=>{l.preventDefault(),l.stopPropagation()},onClick:l=>{l.preventDefault(),l.stopPropagation(),nn(t.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":n("filesView.editor.closeFileAria",{name:t.name}),children:s.jsx(k,{name:"close",className:"size-3.5"})})]},t.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:n("filesView.editor.selectFile")}):cs.length>0?s.jsxs("div",{className:"relative min-w-0 flex-1",children:[Fi.start&&s.jsx("div",{className:"pointer-events-none absolute inset-s-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r rtl:bg-gradient-to-l from-background to-transparent"}),Fi.end&&s.jsx("div",{className:"pointer-events-none absolute inset-e-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l rtl:bg-gradient-to-r from-background to-transparent"}),s.jsx("div",{ref:yr,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:cs.map(t=>{const o=f?.path===t.path;return s.jsxs("div",{title:fn(d,t.path),className:Y("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",o?"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:[s.jsx(Ds,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),s.jsx("button",{type:"button",onClick:()=>{o||We(t)},className:"max-w-[12rem] truncate text-start",children:t.name}),s.jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),nn(t.path)},className:Y("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!o&&!N&&"opacity-0 group-hover:opacity-100"),"aria-label":n("filesView.editor.closeFileAria",{name:t.name}),children:s.jsx(k,{name:"close",className:"size-3.5"})})]},t.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:n("filesView.editor.selectFile")})]}):null,f?s.jsxs("div",{ref:Rt,className:"flex h-8 min-w-0 shrink-0 items-center gap-3 border-t border-border/40 px-2",children:[ts&&!g?s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:ts,children:ts}):null,s.jsx("div",{className:"ms-auto min-w-0 shrink-0 overflow-x-auto",children:eo({layout:"docked"})})]}):null]}),rc?s.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2 border-b border-border/40 bg-[var(--surface-muted)] px-3 py-1.5 typography-ui text-muted-foreground",children:[s.jsx(k,{name:"information",className:"size-4 shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:n("filesView.excalidraw.installHint")}),s.jsx($,{type:"button",size:"xs",variant:"outline",onClick:Lc,children:n("filesView.excalidraw.installAction")})]}):null,s.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:s.jsx(ai,{ref:Fc,outerClassName:"h-full min-w-0",className:Y("h-full min-w-0",Ft&&"[overflow-anchor:none]"),children:f?ve||Yr?O?s.jsx("div",{className:"p-3"}):s.jsxs("div",{className:"p-3 flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(k,{name:"loader-4",className:"size-4 animate-spin"}),n("filesView.state.loading")]}):Qe?s.jsx("div",{className:"p-3 typography-ui text-[color:var(--status-error)]",children:Qe}):Jr?no?s.jsx("div",{className:"h-full"}):ro:tr||(f&&an&&de==="preview"?s.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:s.jsx(wf,{ref:Di,xml:gc,onChange:pc},`${Us??f.path}:${fl}`)}):f&&Ss&&Ce==="tree"?s.jsx(ar,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:n("filesView.error.jsonViewerUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:n("filesView.error.switchToTextMode")})]}),children:s.jsx("div",{className:"h-full overflow-auto",children:s.jsx(pd,{jsonString:U,format:f.path.toLowerCase().endsWith(".jsonc")?"jsonc":"json",maxHeight:"100%",initiallyExpandedDepth:2})})}):f&&He&&Ie()==="preview"?s.jsxs("div",{className:"relative h-full min-h-0",children:[s.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-3 outline-none",tabIndex:-1,onMouseDown:Ln,ref:Pc,children:[s.jsx(vo,{containerRef:na,filePath:f.path,fileContent:U}),U.length>500*1024&&s.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:n("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(U.length/1024)})}),s.jsx(ar,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:n("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:n("filesView.error.switchToEditMode")})]}),children:s.jsx("div",{style:Ra,children:s.jsx(oi,{content:U,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1,allowRawHtml:!0})})})]}),!oe&&s.jsx(jo,{containerRef:An,open:Gi,onOpenChange:Dn,focusNonce:Hi})]}):f&&ss&&Ne==="preview"?!u.isVSCode&&rs.status==="loading"?s.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:n("common.loading")}):s.jsx("div",{className:"h-full overflow-hidden",children:s.jsx("iframe",{src:rs.status==="ready"?rs.url:void 0,srcDoc:u.isVSCode?(()=>{const t=f.path.substring(0,f.path.lastIndexOf("/")+1);return t?U.replace(/<head([^>]*)>/i,`<head$1><base href="${t}">`):U})():void 0,className:"w-full h-full border-none",sandbox:"allow-scripts allow-forms allow-popups allow-modals allow-downloads",title:n("filesView.editor.htmlPreviewTitle")})}):f&&Xn&&re==="view"?Qa(f,se,$a,Cc):s.jsxs("div",{className:Y("relative h-full",js&&"overflow-hidden"),ref:Qs,children:[!oe&&s.jsx(yo,{open:Ui,onOpenChange:en,viewRef:ye}),s.jsx("div",{className:Y("h-full",js&&"invisible"),children:s.jsx(Oo,{positionKey:At,detached:!e,value:se,onChange:fe,readOnly:!Ge,vimMode:xs==="vim",extensions:Aa,className:"h-full",blockWidgets:Sc,onViewReady:t=>{ye.current=t,Jn(t),Mr(o=>o+1),window.requestAnimationFrame(()=>{Es(t)})},onViewDestroy:()=>{ye.current&&(ye.current=null),Mr(t=>t+1)},enableSearch:!0,searchOpen:Ht,onSearchOpenChange:st,highlightLines:J?{start:Math.min(J.start,J.end),end:Math.max(J.start,J.end)}:void 0,lineNumbersConfig:vc},At)}),js&&s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:s.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(k,{name:"loader-4",className:"size-4 animate-spin"}),n("filesView.state.openingFileAtChange")]})})]})):s.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:n("filesView.editor.pickFileFromTree")})})})]}),zc=!!(d&&Ri[d]),io=d?kn[d]:null,ao=P?s.jsxs("section",{className:Y("flex min-h-0 flex-col overflow-hidden",g?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[s.jsx("div",{className:Y("flex flex-col gap-2 py-2",g?"px-3":"px-2"),children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1 min-w-0",children:[s.jsx(k,{name:"search",className:"pointer-events-none absolute inset-s-2 top-2 size-4 text-muted-foreground"}),s.jsx(pn,{ref:me,value:ie,onChange:t=>pe(t.target.value),placeholder:n("filesView.tree.search.placeholder"),className:"h-8 ps-8 pe-8 typography-meta"}),ie.trim().length>0&&s.jsx("button",{type:"button","aria-label":n("filesView.tree.search.clearAria"),className:"absolute inset-e-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{pe(""),me.current?.focus()},children:s.jsx(k,{name:"close",className:"size-4"})})]}),s.jsxs(Wt,{children:[s.jsx(Ut,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx($,{variant:"ghost",size:"sm",onClick:()=>Dr("createFile",{path:b,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:n("filesView.tree.actions.newFileTitle"),"aria-label":n("filesView.tree.actions.newFileTitle"),children:s.jsx(k,{name:"file-add",className:"size-4"})})})}),s.jsx(Gt,{side:"bottom",sideOffset:6,children:n("filesView.tree.actions.newFileTitle")})]}),s.jsxs(Wt,{children:[s.jsx(Ut,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx($,{variant:"ghost",size:"sm",onClick:()=>Dr("createFolder",{path:b,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:n("filesView.tree.actions.newFolderTitle"),"aria-label":n("filesView.tree.actions.newFolderTitle"),children:s.jsx(k,{name:"folder-add",className:"size-4"})})})}),s.jsx(Gt,{side:"bottom",sideOffset:6,children:n("filesView.tree.actions.newFolderTitle")})]}),ma&&s.jsxs(Wt,{children:[s.jsx(Ut,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx($,{variant:"ghost",size:"sm",onClick:()=>ha(d),disabled:!d||_n,className:"size-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.uploadFilesTitle"),"aria-label":n("sidebarFilesTree.actions.uploadFilesTitle"),children:s.jsx(k,{name:_n?"loader-4":"upload-2",className:Y("size-4",_n&&"animate-spin")})})})}),s.jsx(Gt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.uploadFilesTitle")})]}),s.jsx(md,{className:"size-8"}),s.jsxs(Wt,{children:[s.jsx(Ut,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx($,{variant:"ghost",size:"sm",onClick:()=>{$n()},className:"size-8 p-0 flex-shrink-0",title:n("filesView.tree.actions.refreshTitle"),"aria-label":n("filesView.tree.actions.refreshTitle"),children:s.jsx(k,{name:"refresh",className:"size-4"})})})}),s.jsx(Gt,{side:"bottom",sideOffset:6,children:n("filesView.tree.actions.refreshTitle")})]})]})}),s.jsx(ai,{outerClassName:"flex-1 min-h-0",className:Y("py-2",g?"px-3":"px-2"),children:s.jsx("ul",{className:"flex flex-col",children:wl?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(k,{name:"loader-4",className:"size-4 animate-spin"}),n("filesView.tree.search.searching")]}):Ti.length>0?Ti.map(t=>{const o=f?.path===t.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>{We(t)},className:Y("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-start transition-colors",Jo(o)),children:[s.jsx(Ds,{filePath:t.path,extension:t.extension,className:"size-3.5"}),s.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl"},title:t.path,children:t.relativePath??t.path})]})},t.path)}):io?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"text-[var(--status-error)]",children:io}),s.jsxs($,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{$n()},children:[s.jsx(k,{name:"refresh",className:"size-3.5"}),n("filesView.tree.actions.refreshTitle")]})]}):zc?ja(d,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:n("filesView.state.loading")})})})]}):null,Ic=r==="full"&&oe&&f&&s.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:s.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[s.jsx("div",{className:"absolute inset-e-4 top-4 z-30",children:eo({exitFullscreenOnly:!0})}),s.jsx(ai,{ref:Ec,outerClassName:"h-full min-w-0",className:Y("h-full min-w-0",Ft&&"[overflow-anchor:none]"),children:ve||Yr?O?s.jsx("div",{className:"p-4"}):s.jsxs("div",{className:"p-4 flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(k,{name:"loader-4",className:"size-4 animate-spin"}),"Loading…"]}):Qe?s.jsx("div",{className:"p-4 typography-ui text-[color:var(--status-error)]",children:Qe}):Jr?ro:tr||(He&&Ie()==="preview"?s.jsxs("div",{className:"relative h-full min-h-0",children:[s.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-4 outline-none",tabIndex:-1,onMouseDown:Ln,ref:Vc,children:[f?s.jsx(vo,{containerRef:zn,filePath:f.path,fileContent:U}):null,U.length>500*1024&&s.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:n("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(U.length/1024)})}),s.jsx(ar,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:n("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:n("filesView.error.switchToEditMode")})]}),children:s.jsx("div",{style:Ra,children:s.jsx(oi,{content:U,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1,allowRawHtml:!0})})})]}),s.jsx(jo,{containerRef:zn,open:Gi,onOpenChange:Dn,focusNonce:Hi,className:"inset-e-4 top-16"})]}):Xn&&re==="view"?Qa(f,se,_a,Nc):s.jsxs("div",{className:Y("relative h-full",js&&"overflow-hidden"),children:[s.jsx(yo,{open:Ui,onOpenChange:en,viewRef:ye}),s.jsx("div",{className:Y("h-full",js&&"invisible"),children:s.jsx(Oo,{positionKey:`${At}:fullscreen`,value:se,onChange:fe,readOnly:!Ge,vimMode:xs==="vim",extensions:Aa,className:"h-full",onViewReady:t=>{ye.current=t,Jn(t),window.requestAnimationFrame(()=>{Es(t)})},onViewDestroy:()=>{ye.current&&(ye.current=null)}},`${At}:fullscreen`)}),js&&s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:s.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(k,{name:"loader-4",className:"size-4 animate-spin"}),n("filesView.state.openingFileAtChange")]})})]}))})]})});return s.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[s.jsx(Sm,{activeDialog:Qt,dialogData:es,dialogInputValue:zt,onDialogInputChange:$i,isDialogSubmitting:Rl,onDialogSubmit:Hl,onClose:jc,inputRef:jl}),Gl,Ic,g?ce?ei:ao:r==="editor-only"?s.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:ei})}):s.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[C>=700&&s.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:ao}),s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:ei})]})]})};function Fm(r){return r+1}export{Kp as FilesView};
|