@openchamber/web 2.0.2 → 2.0.4
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/bin/lib/DOCUMENTATION.md +1 -1
- package/bin/lib/commands-connect-url.js +6 -5
- package/bin/lib/commands-tunnel.js +24 -5
- package/dist/assets/{CodeMirrorCommentWidgets-CmKmyb9T.js → CodeMirrorCommentWidgets-C_zL-eri.js} +1 -1
- package/dist/assets/{DiffView-8-PFpZ2p.js → DiffView-BeN2_YYF.js} +3 -3
- package/dist/assets/FilesView-CN34wm_N.js +17 -0
- package/dist/assets/{GitView-DNUSu00w.js → GitView-DLDazOo1.js} +4 -4
- package/dist/assets/{GuestAttachDialog-Cv6QzjHC.js → GuestAttachDialog-C0xe_Lyy.js} +1 -1
- package/dist/assets/{GuestSurfacePane-Bt3jB_Ye.js → GuestSurfacePane-BdaurnDr.js} +1 -1
- package/dist/assets/{JsonTreeView-BlyHTRhM.js → JsonTreeView-B1Xq-k2t.js} +1 -1
- package/dist/assets/LinearIssuesView-BryoAHow.js +1 -0
- package/dist/assets/{MarkdownImageGallery-2UXJF-5B.js → MarkdownImageGallery-DfuEoaGq.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-B_ZcWOvX.js +12 -0
- package/dist/assets/OnboardingScreen-C22bGmnP.js +1 -0
- package/dist/assets/{PatchDiff-ByvnbG5T.js → PatchDiff-0xd6UeFB.js} +1 -1
- package/dist/assets/{PierreDiffViewer-BXieg0mH.js → PierreDiffViewer-BC950e3F.js} +3 -3
- package/dist/assets/PlanView-B7Xgihqk.js +5 -0
- package/dist/assets/PluginPane-2C71F8uF.js +3 -0
- package/dist/assets/SettingsView-m_zoFiaT.js +30 -0
- package/dist/assets/{SettingsWindow-BIz224xs.js → SettingsWindow-CofS020b.js} +1 -1
- package/dist/assets/{SubmoduleDiffSummary-CXKmlps9.js → SubmoduleDiffSummary-BSA9gnIO.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BsgAK8xu.js → ToolOutputDialog-DprkVKcj.js} +7 -7
- package/dist/assets/{ToolPartDiffPreview-vdPObXOf.js → ToolPartDiffPreview-Dq0go_fX.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-BkFNKWS5.js → VirtualizedFileDiff-Kp8hKJdT.js} +1 -1
- package/dist/assets/WalkthroughView-DGnTzqIU.js +4 -0
- package/dist/assets/{appThemeRegistry-aHUNHoqP.js → appThemeRegistry-BdEHBA4s.js} +1 -1
- package/dist/assets/{commitAndPush-Bon9r94r.js → commitAndPush-LwtVa2Oc.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-DKqr_1AQ.js → computeVirtualFileMetrics-6V1xNpO9.js} +2 -2
- package/dist/assets/de-DlgBHUAI.js +10 -0
- package/dist/assets/es-BC8G41U8.js +16 -0
- package/dist/assets/fr-I0z3vVjy.js +14 -0
- package/dist/assets/index-CgR5rJq_.js +41 -0
- package/dist/assets/{index-DpFttslC.js → index-CmNPYddV.js} +1 -1
- package/dist/assets/index-adyy_sEk.css +1 -0
- package/dist/assets/{isDiffPlainText-kzAgpIgi.js → isDiffPlainText-1bXcWCrw.js} +1 -1
- package/dist/assets/{isFilePlainText-Uj6y-jzz.js → isFilePlainText-CBAppvy1.js} +1 -1
- package/dist/assets/ja-BIElEsY8.js +16 -0
- package/dist/assets/ko-DRnnHetA.js +16 -0
- package/dist/assets/{main-CbfMxn-I.js → main-CzjTMTfW.js} +2 -2
- package/dist/assets/main-DVX34beR.js +886 -0
- package/dist/assets/markdownCore-Cxbkn5NR.js +7 -0
- package/dist/assets/{miniChat-CiAKBC10.js → miniChat-CP68IL8Q.js} +2 -2
- package/dist/assets/{mobile-CsT4sJwC.js → mobile-BrlBrNfZ.js} +2 -2
- package/dist/assets/nl-DzUV-kwp.js +16 -0
- package/dist/assets/{patchFileDiff-DeaE08W0.js → patchFileDiff-pqRSHLHI.js} +2 -2
- package/dist/assets/pl-Bb-cb7k7.js +16 -0
- package/dist/assets/pt-BR-CyIWrTcE.js +16 -0
- package/dist/assets/renderElectronMiniChatApp-DKIilR7N.js +2 -0
- package/dist/assets/renderMobileApp-B0z6-x58.js +25 -0
- package/dist/assets/runtimeEndpointReset-uu1DBwLL.js +52 -0
- package/dist/assets/{scheduledTasksApi-BZCNJ588.js → scheduledTasksApi-BuzWT445.js} +1 -1
- package/dist/assets/{shikiHighlight-BSUEa3yF.js → shikiHighlight-BWGrY5YU.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-CsATFZIV.js → textMateThemeFromAppTheme-BSUFChBY.js} +1 -1
- package/dist/assets/tr-DXEDSoYO.js +7 -0
- package/dist/assets/uk-C8hN--q_.js +16 -0
- package/dist/assets/useAppFontEffects-Dsl_sLrj.js +7366 -0
- package/dist/assets/useInlineCommentController-d5vntsQ_.js +2 -0
- package/dist/assets/{useRootScrollLock-Cp1eFoM2.js → useRootScrollLock-2rd5Y6gR.js} +2 -2
- package/dist/assets/{vendor-base-ui-CsXYnR5c.js → vendor-base-ui-DnNniUWp.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-BwwommM0.js → vendor-codemirror-language-data-B1EetJur.js} +2 -2
- package/dist/assets/vendor-opencode-client-DSZl7jSi.js +12 -0
- package/dist/assets/{vendor-tanstack-react-virtual-ClYN8CzB.js → vendor-tanstack-react-virtual--0sBrLRh.js} +1 -1
- package/dist/assets/{vendor-tanstack-virtual-core-BewVQryB.js → vendor-tanstack-virtual-core-BoA4iGMw.js} +1 -1
- package/dist/assets/{vendor-zod-BSoePkpP.js → vendor-zod-CxRSdNoV.js} +4 -4
- package/dist/assets/{web-components-D3Yjr4Zx.js → web-components-ngpHPEDU.js} +1 -1
- package/dist/assets/zh-CN-CtzXdjMZ.js +16 -0
- package/dist/assets/zh-TW-Ds0CADSz.js +16 -0
- package/dist/index.html +5 -5
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +5 -5
- package/package.json +5 -5
- package/server/index.js +82 -4
- package/server/lib/agent-tool/DOCUMENTATION.md +8 -1
- package/server/lib/agent-tool/runtime.js +13 -4
- package/server/lib/agent-tool/runtime.test.js +15 -0
- package/server/lib/context-obligatory/DOCUMENTATION.md +10 -7
- package/server/lib/context-obligatory/runtime.js +2 -1
- package/server/lib/context-obligatory/runtime.test.js +76 -30
- package/server/lib/dictation/DOCUMENTATION.md +4 -1
- package/server/lib/dictation/openai-compatible-session.js +7 -0
- package/server/lib/enterprise-mode.d.ts +30 -0
- package/server/lib/enterprise-mode.js +253 -0
- package/server/lib/enterprise-mode.test.js +247 -0
- package/server/lib/event-stream/translate-v2.js +6 -0
- package/server/lib/event-stream/translate-v2.test.js +6 -0
- package/server/lib/git/DOCUMENTATION.md +2 -1
- package/server/lib/git/routes.js +44 -1
- package/server/lib/git/routes.test.js +98 -1
- package/server/lib/git/service.js +146 -11
- package/server/lib/git/service.test.js +195 -0
- package/server/lib/github/routes.js +9 -19
- package/server/lib/github/routes.test.js +112 -0
- package/server/lib/guests/DOCUMENTATION.md +4 -2
- package/server/lib/guests/background.test.js +1 -1
- package/server/lib/guests/catalog.js +56 -2
- package/server/lib/guests/catalog.test.js +24 -1
- package/server/lib/guests/clone-network.test.js +52 -0
- package/server/lib/guests/clone.js +30 -4
- package/server/lib/guests/enterprise.js +68 -0
- package/server/lib/guests/enterprise.test.js +106 -0
- package/server/lib/guests/grant-scope.js +8 -2
- package/server/lib/guests/grant-scope.test.js +9 -0
- package/server/lib/guests/html-styles.js +16 -2
- package/server/lib/guests/html-styles.test.js +53 -4
- package/server/lib/guests/install.js +10 -0
- package/server/lib/guests/persist.js +1 -0
- package/server/lib/guests/routes.js +40 -5
- package/server/lib/guests/updates.js +9 -2
- package/server/lib/notifications/DOCUMENTATION.md +1 -1
- package/server/lib/notifications/runtime.js +22 -8
- package/server/lib/notifications/trigger-runtime.test.js +45 -0
- package/server/lib/openchamber-sessions/session-metadata-store.js +27 -0
- package/server/lib/openchamber-sessions/session-metadata-store.test.js +18 -0
- package/server/lib/opencode/DOCUMENTATION.md +13 -9
- package/server/lib/opencode/auth-state-runtime.js +2 -2
- package/server/lib/opencode/config-paths.test.js +1 -0
- package/server/lib/opencode/env-runtime.js +26 -3
- package/server/lib/opencode/env-runtime.test.js +57 -0
- package/server/lib/opencode/feature-routes-runtime.js +2 -0
- package/server/lib/opencode/hmr-state-runtime.js +4 -3
- package/server/lib/opencode/lifecycle.js +10 -5
- package/server/lib/opencode/lifecycle.test.js +6 -2
- package/server/lib/opencode/managed-config-file.js +2 -1
- package/server/lib/opencode/managed-config-file.test.js +18 -0
- package/server/lib/opencode/npm-registry-config.d.ts +1 -0
- package/server/lib/opencode/npm-registry-config.js +123 -0
- package/server/lib/opencode/npm-registry-config.test.js +167 -0
- package/server/lib/opencode/npm-registry.js +5 -6
- package/server/lib/opencode/npm-registry.test.js +30 -0
- package/server/lib/opencode/openchamber-routes.js +8 -0
- package/server/lib/opencode/project-icon-routes.js +2 -2
- package/server/lib/opencode/project-icon-routes.test.js +44 -0
- package/server/lib/opencode/provider-source-route.test.js +32 -0
- package/server/lib/opencode/routes.js +17 -2
- package/server/lib/opencode/settings-helpers.js +26 -3
- package/server/lib/opencode/settings-helpers.test.js +12 -5
- package/server/lib/opencode/settings-registry.json +35 -1
- package/server/lib/opencode/settings-runtime.js +1 -0
- package/server/lib/opencode/shutdown-runtime.js +2 -0
- package/server/lib/opencode/static-routes-runtime.js +9 -1
- package/server/lib/opencode/static-routes-runtime.test.js +58 -1
- package/server/lib/package-manager.js +4 -1
- package/server/lib/package-manager.test.js +24 -0
- package/server/lib/permission-auto-accept/DOCUMENTATION.md +23 -15
- package/server/lib/permission-auto-accept/modes.js +26 -0
- package/server/lib/permission-auto-accept/runtime.js +146 -40
- package/server/lib/permission-auto-accept/runtime.test.js +93 -9
- package/server/lib/quota/DOCUMENTATION.md +6 -0
- package/server/lib/quota/providers/zhipuai-coding-plan.js +74 -30
- package/server/lib/quota/providers/zhipuai-coding-plan.test.js +124 -0
- package/server/lib/relay/DOCUMENTATION.md +1 -1
- package/server/lib/relay/service.js +32 -12
- package/server/lib/relay/service.test.js +30 -0
- package/server/lib/routing/DOCUMENTATION.md +150 -41
- package/server/lib/routing/classifier.js +156 -0
- package/server/lib/routing/defaults.js +27 -0
- package/server/lib/routing/jev.js +5 -17
- package/server/lib/routing/routes.http.test.js +9 -0
- package/server/lib/routing/routes.js +27 -1
- package/server/lib/routing/runtime.js +199 -33
- package/server/lib/routing/runtime.test.js +299 -15
- package/server/lib/routing/store.js +57 -0
- package/server/lib/routing/store.test.js +37 -0
- package/server/lib/session-assist/DOCUMENTATION.md +17 -7
- package/server/lib/session-assist/context.js +42 -2
- package/server/lib/session-assist/context.test.js +38 -1
- package/server/lib/session-assist/runtime.js +57 -13
- package/server/lib/session-assist/runtime.test.js +45 -0
- package/server/lib/session-goal/DOCUMENTATION.md +47 -22
- package/server/lib/session-goal/audit.js +112 -0
- package/server/lib/session-goal/audit.test.js +58 -0
- package/server/lib/session-goal/runtime.js +113 -134
- package/server/lib/session-goal/runtime.test.js +146 -13
- package/server/lib/session-lineage.js +52 -0
- package/server/lib/session-lineage.test.js +45 -0
- package/server/lib/session-work/DOCUMENTATION.md +108 -0
- package/server/lib/session-work/questions.js +126 -0
- package/server/lib/session-work/runtime.js +278 -0
- package/server/lib/session-work/runtime.test.js +255 -0
- package/server/lib/session-work/state.js +48 -0
- package/server/lib/session-work/state.test.js +34 -0
- package/server/lib/small-model/DOCUMENTATION.md +14 -7
- package/server/lib/small-model/client.js +7 -4
- package/server/lib/small-model/index.js +11 -21
- package/server/lib/small-model/index.test.js +13 -26
- package/server/lib/spaces/DOCUMENTATION.md +79 -25
- package/server/lib/spaces/gatekeeper-channel.js +63 -11
- package/server/lib/spaces/gatekeeper-channel.test.js +34 -4
- package/server/lib/spaces/gatekeeper-program.cjs +64 -13
- package/server/lib/spaces/gatekeeper-program.test.js +115 -3
- package/server/lib/spaces/host.js +58 -13
- package/server/lib/spaces/host.test.js +34 -1
- package/server/lib/spaces/idle-stop.js +98 -0
- package/server/lib/spaces/idle-stop.test.js +130 -0
- package/server/lib/spaces/journey.js +427 -17
- package/server/lib/spaces/journey.test.js +592 -5
- package/server/lib/spaces/layout.js +27 -6
- package/server/lib/spaces/manager.test.js +1 -1
- package/server/lib/spaces/places/contract-suite.js +4 -2
- package/server/lib/spaces/places/docker-live-support.js +27 -4
- package/server/lib/spaces/places/docker.js +32 -5
- package/server/lib/spaces/places/docker.test.js +38 -8
- package/server/lib/spaces/places/escape-suite.js +32 -0
- package/server/lib/spaces/places/fake-docker.js +3 -1
- package/server/lib/spaces/places/grants.docker.live.test.js +197 -0
- package/server/lib/spaces/places/memory-place.js +3 -3
- package/server/lib/spaces/places/sessions.docker.live.test.js +4 -2
- package/server/lib/spaces/routes.js +49 -1
- package/server/lib/spaces/routes.test.js +31 -3
- package/server/lib/spaces/space-opencode.js +52 -0
- package/server/lib/spaces/space-opencode.test.js +41 -0
- package/server/lib/spaces/space-records.js +90 -2
- package/server/lib/spaces/space-records.test.js +58 -1
- package/server/lib/spaces/space-server.js +13 -1
- package/server/lib/spaces/space-server.test.js +13 -0
- package/server/lib/spaces/space-setup.js +173 -0
- package/server/lib/spaces/space-setup.test.js +174 -0
- package/server/lib/tts/DOCUMENTATION.md +3 -0
- package/server/lib/tts/base-url.js +8 -0
- package/server/lib/tts/routes.js +13 -1
- package/server/lib/tts/routes.test.js +26 -0
- package/server/lib/tunnels/DOCUMENTATION.md +2 -0
- package/server/lib/tunnels/routes.js +14 -0
- package/server/lib/tunnels/routes.test.js +26 -0
- package/server/lib/walkthrough/index.js +11 -7
- package/server/lib/walkthrough/jobs.test.js +8 -0
- package/server/lib/walkthrough/languages.js +1 -0
- package/server/lib/walkthrough/routes.js +7 -1
- package/dist/assets/FilesView-0Ie20mEk.js +0 -17
- package/dist/assets/LinearIssuesView-CSl2MUfA.js +0 -1
- package/dist/assets/MarkdownRendererImpl-DVHqZoug.js +0 -12
- package/dist/assets/OnboardingScreen-CIdXJpfc.js +0 -1
- package/dist/assets/PlanView-DEIi3Q7M.js +0 -5
- package/dist/assets/PluginPane-BEPUWVho.js +0 -3
- package/dist/assets/SettingsView-CiNh-RbW.js +0 -30
- package/dist/assets/WalkthroughView-6oE-MuDL.js +0 -4
- package/dist/assets/de-CgAJ51z7.js +0 -10
- package/dist/assets/es-zGi_ravM.js +0 -16
- package/dist/assets/fr-CPfogrWx.js +0 -14
- package/dist/assets/index-CHfphYL3.js +0 -41
- package/dist/assets/index-DvMJ3w6V.css +0 -1
- package/dist/assets/ja-DMk6wd-U.js +0 -16
- package/dist/assets/ko-BFpzJ8jc.js +0 -16
- package/dist/assets/main-anyZFMIs.js +0 -896
- package/dist/assets/markdownCore-CmM47cAE.js +0 -7
- package/dist/assets/pl-VdRPcZrB.js +0 -16
- package/dist/assets/pt-BR-BRys_lOW.js +0 -16
- package/dist/assets/renderElectronMiniChatApp-C5677jy0.js +0 -2
- package/dist/assets/renderMobileApp-D4dBBAqQ.js +0 -25
- package/dist/assets/runtimeEndpointReset-5r0hkd-2.js +0 -27
- package/dist/assets/tr-CA9ckNnm.js +0 -7
- package/dist/assets/uk-byjR-y8D.js +0 -16
- package/dist/assets/useAppFontEffects-BWQZ5DeI.js +0 -7341
- package/dist/assets/useInlineCommentController-DlFyVfBu.js +0 -2
- package/dist/assets/vendor-opencode-client-DYdsLbCM.js +0 -12
- package/dist/assets/zh-CN-DRabgxdG.js +0 -16
- package/dist/assets/zh-TW-rbY5c9UK.js +0 -16
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import{f as De,R as i,j as s,c as Ts,r as Ct}from"./vendor-react-BUCujlKS.js";import{b7 as Dl,a as ot,h as Ms,_ as Ll,$ as zl,a0 as Al,a1 as Il,y as tt,u as ht,ew as Ol,K as fa,D as Bl,a5 as ma,et as $l,e as _l,eu as Wl,a4 as Ul,ev as Hl}from"./index-CgR5rJq_.js";import{f as nt,bt as _a,z as ha,as as Wa,cp as Kl,I as M,h as q,ls as ql,gN as Gl,a1 as In,B as $,km as Er,c8 as Vr,iD as Xl,lt as Yl,lu as Jl,aK as zn,hB as Zl,hz as Ql,a4 as ec,T as tc,K as nc,au as sc,cK as rc,t as X,eF as pa,jh as ic,h1 as ac,l as ga,aI as vr,cD as Dn,dl as oc,b as lc,lv as Ln,cb as cc,aJ as xr,lw as wr,cE as va,cF as xa,lx as wa,ly as ba,lz as uc,lA as dc,lB as fc,lC as mc,ih as hc,lD as pc,lE as gc,lF as vc,cc as Ua,cd as Ha,ce as Ka,cf as qa,cg as Ga,ch as Xa,aC as kr,aD as Tr,aF as Mr,br as Vs,ci as br,aL as Ns,cz as yr,ao as $t,ap as _t,aq as Wt,c9 as xc,ca as wc,g as Ds,bs as bc,cJ as yc}from"./useAppFontEffects-Dsl_sLrj.js";import{t as jc,aL as Cc,aK as Sc,ab as Nc,ac as Fc,ad as Rc,ae as Ec,af as kc}from"./runtimeEndpointReset-uu1DBwLL.js";import{c as ya,s as Tc,P as fn,C as Mc}from"./shikiHighlight-BWGrY5YU.js";import{a as Vc}from"./vendor-codemirror-state-C9awkmn-.js";import{E as Ut}from"./vendor-codemirror-view-CiLROUVV.js";import{V as Pc,J as Dc,F as Lc}from"./JsonTreeView-B1Xq-k2t.js";import{ensurePierreThemeRegistered as ja,getResolvedShikiTheme as zc}from"./appThemeRegistry-BdEHBA4s.js";import{V as Ac,W as Ic}from"./Virtualizer-CZlLSacm.js";import{V as Oc}from"./Virtualizer-D_a8gKmg.js";import{D as Bc}from"./vendor-react-drawio-Ct3Q0DsD.js";import{m as $c,P as _c}from"./PluginPane-2C71F8uF.js";import{a as Wc,u as Fs,b as Uc,g as Hc,h as Kc}from"./scheduledTasksApi-BuzWT445.js";import{I as qc,u as Gc,n as Xc}from"./useInlineCommentController-d5vntsQ_.js";import{b as Yc}from"./CodeMirrorCommentWidgets-C_zL-eri.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-CxRSdNoV.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-DSZl7jSi.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-base-ui-DnNniUWp.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-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--0sBrLRh.js";import"./vendor-tanstack-virtual-core-BoA4iGMw.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.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-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.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-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-B1EetJur.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./GuestAttachDialog-C0xe_Lyy.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./web-components-ngpHPEDU.js";import"./computeVirtualFileMetrics-6V1xNpO9.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-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.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-CBAppvy1.js";import"./textMateThemeFromAppTheme-BSUFChBY.js";function Ca(r){const e=De.c(56),{containerRef:t,filePath:a,fileContent:p}=r,{t:d}=nt(),{isMobile:v}=_a(),f=ha(iu),x=ha(ru),g=Wa(),h=Kl(su),[w,F]=i.useState(null),[C,k]=i.useState(""),[y,j]=i.useState(!1),l=i.useRef(!1),S=i.useRef(null),T=i.useRef(null),[V,L]=i.useState(null);let I;e[0]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{F(null),k(""),j(!1),l.current=!1,T.current=null,L(null)},e[0]=I):I=e[0];const E=I;let z,_;e[1]!==t?(z=()=>{const G=t.current;if(!G)return;const W=()=>{if(l.current)return;const le=window.getSelection(),Se=le?.toString().trim()??"";if(!le||!Se||le.rangeCount===0){E();return}const re=le.getRangeAt(0);if(!G.contains(re.commonAncestorContainer)){E();return}const fe=re.getBoundingClientRect();T.current=re.cloneRange(),k(Se),F({x:fe.left+fe.width/2,y:fe.top-10})},oe=le=>{S.current?.contains(le.target)||l.current&&E()};return document.addEventListener("selectionchange",W),document.addEventListener("pointerdown",oe),()=>{document.removeEventListener("selectionchange",W),document.removeEventListener("pointerdown",oe)}},_=[t,E],e[1]=t,e[2]=z,e[3]=_):(z=e[2],_=e[3]),i.useEffect(z,_);let R;e[4]!==p?(R=G=>{const W=ge=>p.slice(0,ge).split(`
|
|
2
|
+
`).length,oe=tu,le=(ge,pt)=>{for(const ye of oe(ge)){const Ee=p.indexOf(ye,pt);if(Ee>=0)return Ee}return-1},Se=G.length>=8?p.indexOf(G):-1;if(Se>=0){const ge=W(Se);return{start:ge,end:ge+G.split(`
|
|
3
|
+
`).length-1}}const re=G.split(`
|
|
4
|
+
`).map(eu).filter(Boolean);if(re.length===0)return null;const fe=le(re[0],0);if(fe<0)return null;const pe=W(fe);if(re.length===1)return{start:pe,end:pe};const be=le(re[re.length-1],fe);return be<0?null:{start:pe,end:Math.max(pe,W(be))}},e[4]=p,e[5]=R):R=e[5];const P=R;let O;e[6]===Symbol.for("react.memo_cache_sentinel")?(O=()=>{const G=T.current;if(!G){L(null);return}L(ql(G))},e[6]=O):O=e[6];const K=O;let Q,ee;e[7]!==y?(Q=()=>{if(!y)return;let G=null;const W=()=>{G===null&&(G=window.requestAnimationFrame(()=>{G=null,K()}))};return document.addEventListener("scroll",W,{capture:!0,passive:!0}),window.addEventListener("resize",W),()=>{G!==null&&window.cancelAnimationFrame(G),document.removeEventListener("scroll",W,{capture:!0}),window.removeEventListener("resize",W)}},ee=[y,K],e[7]=y,e[8]=Q,e[9]=ee):(Q=e[8],ee=e[9]),i.useEffect(Q,ee);let ae;e[10]!==C?(ae=()=>{C&&(j(!0),l.current=!0,K(),window.getSelection()?.removeAllRanges())},e[10]=C,e[11]=ae):ae=e[11];const J=ae;let Y;e[12]!==h||e[13]!==f||e[14]!==g||e[15]!==a||e[16]!==x||e[17]!==P||e[18]!==C?(Y=G=>{const W=f??(x?"draft":null);if(!C||!W||!g){E();return}const oe=P(C);h({directory:g,sessionKey:W},{source:"file-quote",fileLabel:a,startLine:oe?.start??0,endLine:oe?.end??0,code:C,language:"",text:G.trim()}),E(),queueMicrotask(Qc)},e[12]=h,e[13]=f,e[14]=g,e[15]=a,e[16]=x,e[17]=P,e[18]=C,e[19]=Y):Y=e[19];const se=Y;if(!w)return null;let Le;e[20]!==y||e[21]!==P||e[22]!==C?(Le=y?P(C):null,e[20]=y,e[21]=P,e[22]=C,e[23]=Le):Le=e[23];const A=Le;let ue;e[24]!==y||e[25]!==V?(ue=y&&V&&V.length>0?s.jsx("div",{className:"pointer-events-none fixed inset-0 z-40",children:V.map(Zc)}):null,e[24]=y,e[25]=V,e[26]=ue):ue=e[26];const xe=ue;let ze;e[27]!==A?(ze=A?{start:A.start,end:A.end}:void 0,e[27]=A,e[28]=ze):ze=e[28];let Fe;e[29]!==a||e[30]!==se||e[31]!==ze?(Fe=s.jsx(qc,{fileLabel:a,lineRange:ze,onSave:se,onCancel:E}),e[29]=a,e[30]=se,e[31]=ze,e[32]=Fe):Fe=e[32];const $e=Fe;if(v){let G;e[33]===Symbol.for("react.memo_cache_sentinel")?(G={paddingBottom:"calc(0.5rem + env(safe-area-inset-bottom, 0px))"},e[33]=G):G=e[33];let W;e[34]!==$e||e[35]!==y||e[36]!==J||e[37]!==d?(W=s.jsx("div",{ref:S,className:"pointer-events-auto mx-auto max-w-[420px] px-3",style:G,children:y?$e:s.jsx("div",{className:q("mx-auto w-fit","oc-glass-popover rounded-full border border-[var(--interactive-border)]","p-1 shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]"),children:s.jsxs("button",{type:"button",onMouseDown:Jc,onClick:J,className:q("flex min-w-0 items-center gap-2 rounded-full px-4 py-2","text-sm font-medium leading-tight text-foreground","active:bg-[var(--interactive-hover)]","transition-colors duration-150"),title:d("chat.textSelection.title.commentOnSelection"),children:[s.jsx(M,{name:"chat-1",className:"size-4 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 whitespace-nowrap",children:d("chat.textSelection.actions.comment")})]})})}),e[34]=$e,e[35]=y,e[36]=J,e[37]=d,e[38]=W):W=e[38];let oe;return e[39]!==xe||e[40]!==W?(oe=Ts.createPortal(s.jsxs("div",{className:"oc-keyboard-inset-surface pointer-events-none fixed inset-x-0 bottom-0 z-50",children:[xe,W]}),document.body),e[39]=xe,e[40]=W,e[41]=oe):oe=e[41],oe}let Re;e[42]!==w.x||e[43]!==w.y?(Re={left:w.x,top:w.y,transform:"translate(-50%, -100%)"},e[42]=w.x,e[43]=w.y,e[44]=Re):Re=e[44];let ne;e[45]!==xe?(ne=xe?Ts.createPortal(xe,document.body):null,e[45]=xe,e[46]=ne):ne=e[46];let de;e[47]!==$e||e[48]!==y||e[49]!==J||e[50]!==d?(de=y?s.jsx("div",{className:"w-[min(420px,80vw)]",children:$e}):s.jsx("div",{className:q("flex items-center whitespace-nowrap","oc-glass-popover rounded-full border border-[var(--interactive-border)]","shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]","p-1"),children:s.jsx("button",{type:"button",onClick:J,className:q("px-3.5 py-1.5 rounded-full","text-sm font-medium","text-foreground","hover:bg-[var(--interactive-hover)]","transition-colors duration-150"),title:d("chat.textSelection.title.commentOnSelection"),children:d("chat.textSelection.actions.comment")})}),e[47]=$e,e[48]=y,e[49]=J,e[50]=d,e[51]=de):de=e[51];let _e;return e[52]!==Re||e[53]!==ne||e[54]!==de?(_e=Ts.createPortal(s.jsxs("div",{ref:S,className:"fixed z-50",style:Re,children:[ne,de]}),document.body),e[52]=Re,e[53]=ne,e[54]=de,e[55]=_e):_e=e[55],_e}function Jc(r){return r.preventDefault()}function Zc(r,e){return s.jsx("div",{className:"oc-chat-comment-rect absolute",style:{left:r.left,top:r.top,width:r.width,height:r.height}},e)}function Qc(){Gl()}function eu(r){return r.trim()}function tu(r){const e=r.trim();return[e,e.slice(0,32),e.split(" ").slice(0,4).join(" ")].filter(nu)}function nu(r){return r.length>=8}function su(r){return r.addDraft}function ru(r){return r.newSessionDraft?.open}function iu(r){return r.currentSessionId}const au=(r,e)=>{if(!e)return null;const t=Number.parseInt(r.trim(),10);return!Number.isFinite(t)||t<1?null:Math.min(t,e.state.doc.lines)},Sa=(r,e)=>{const t=r.state.doc.lineAt(e.main.head);return{lineNumber:t.number,character:e.main.head-t.from+1,selection:e}},Na=(r,e,t)=>{const a=r.state.doc.line(e),p=Math.max(1,Math.min(t,a.length+1)),d=a.from+p-1;r.dispatch({selection:Vc.cursor(d),effects:Ut.scrollIntoView(d,{y:"center"})})};function ou({open:r,onOpenChange:e,view:t,variant:a="overlay"}){const{t:p}=nt(),[d,v]=i.useState(""),f=i.useRef(null),x=i.useRef(!1),g=i.useRef(null),h=i.useRef(null),w=i.useMemo(()=>au(d,t),[d,t]);i.useEffect(()=>{!r||!t||(x.current=!1,f.current=Sa(t,t.state.selection),v(""))},[r,t]),i.useEffect(()=>{r&&window.requestAnimationFrame(()=>{h.current?.focus(),h.current?.select()})},[r]),i.useEffect(()=>{if(!(!r||!t||!f.current)){if(w===null){const{selection:j}=f.current;t.dispatch({selection:j,effects:Ut.scrollIntoView(j.main.from,{y:"center"})});return}Na(t,w,f.current.character)}},[w,r,t]);const F=i.useCallback(()=>{if(!t||x.current||!f.current)return;const{selection:j}=f.current;t.dispatch({selection:j,effects:Ut.scrollIntoView(j.main.from,{y:"center"})})},[t]),C=i.useCallback(j=>{j||F(),e(j)},[e,F]),k=i.useCallback(()=>{!t||w===null||!f.current||(x.current=!0,Na(t,w,f.current.character),e(!1),t.focus())},[w,e,t]);i.useEffect(()=>{if(!r)return;const j=S=>{const T=g.current,V=S.target;!T||!(V instanceof Node)||T.contains(V)||C(!1)},l=S=>{S.key==="Escape"&&(S.preventDefault(),C(!1))};return document.addEventListener("pointerdown",j,!0),document.addEventListener("keydown",l,!0),()=>{document.removeEventListener("pointerdown",j,!0),document.removeEventListener("keydown",l,!0)}},[C,r,a]);const y=i.useMemo(()=>{if(!t)return p("goToLineDialog.helper.editorUnavailable");if(w===null){const j=f.current??Sa(t,t.state.selection);return p("goToLineDialog.helper.currentLineRange",{current:j.lineNumber,max:t.state.doc.lines})}return p("goToLineDialog.helper.goToLine",{line:w})},[w,p,t]);return a==="inline"?r?s.jsxs("div",{ref:g,className:"ml-1 flex h-6 items-center gap-1",children:[s.jsx(In,{ref:h,type:"number",min:1,step:1,inputMode:"numeric",value:d,onChange:j=>v(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),k())},placeholder:p("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:k,disabled:!t||w===null,className:"h-6 px-2",children:p("goToLineDialog.actions.go")})]}):null:s.jsx("div",{ref:g,className:q("absolute left-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",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(In,{ref:h,type:"number",min:1,step:1,inputMode:"numeric",value:d,onChange:j=>v(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),k())},placeholder:p("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:y})]})})}const lu=(r,e)=>{const t=e.trim().toLowerCase(),a=[];if(!t)return a;const p=r.toLowerCase();let d=0;for(;;){const v=p.indexOf(t,d);if(v===-1)break;a.push({start:v,end:v+t.length}),d=v+t.length}return a},zs="data-md-find",jr="data-md-find-current",Ya="rounded-[2px] bg-status-warning/30 text-foreground",cu="rounded-[2px] bg-status-warning/60 text-foreground",uu=120,du=r=>r instanceof Element&&r.hasAttribute(zs),fu=r=>r.target instanceof Element&&r.target.hasAttribute(zs)?!0:[...r.addedNodes].some(e=>du(e)),Ja=r=>{const e=new Set;r.querySelectorAll(`mark[${zs}]`).forEach(t=>{const a=t.parentNode;a&&(a.replaceChild(document.createTextNode(t.textContent??""),t),e.add(a))}),e.forEach(t=>t.normalize())},mu=(r,e)=>{Ja(r);const t=e.trim().toLowerCase();if(!t)return[];const a=[],p=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode(v){const f=v.parentElement;return!f||f.closest("svg, script, style")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),d=[];for(;p.nextNode();){const v=p.currentNode;v instanceof Text&&d.push(v)}for(const v of d){const f=v.nodeValue??"";if(!f)continue;const x=lu(f,t);if(x.length===0)continue;const g=v.parentNode;if(!g)continue;const h=document.createDocumentFragment();let w=0;for(const F of x){F.start>w&&h.appendChild(document.createTextNode(f.slice(w,F.start)));const C=document.createElement("mark");C.setAttribute(zs,""),C.className=Ya,C.textContent=f.slice(F.start,F.end),h.appendChild(C),a.push(C),w=F.end}w<f.length&&h.appendChild(document.createTextNode(f.slice(w))),g.replaceChild(h,v)}return a},Fa=({containerRef:r,open:e,onOpenChange:t,focusNonce:a,className:p})=>{const{t:d}=nt(),[v,f]=i.useState(""),[x,g]=i.useState(0),[h,w]=i.useState(0),F=i.useRef(null),C=i.useRef([]),k=i.useRef(v);k.current=v;const y=i.useRef(null),j=i.useRef(null),l=i.useCallback((E,z=!1)=>{const _=r.current;if(!_){C.current=[],g(0),w(0);return}C.current=mu(_,E);const R=C.current.length;g(R),w(P=>!z||R===0?0:Math.min(P,R-1))},[r]),S=i.useCallback((E,z=!1)=>{y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{y.current=null,l(E,z)},uu)},[l]);i.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]);const T=i.useCallback(()=>{t(!1);const E=j.current;j.current=null,E?.isConnected&&E.focus()},[t]);i.useEffect(()=>{const E=r.current;if(!e||!E)return;const z=new MutationObserver(_=>{!k.current.trim()||!_.some(P=>!fu(P))||S(k.current,!0)});return z.observe(E,{childList:!0,subtree:!0,characterData:!0}),()=>{z.disconnect(),Ja(E)}},[r,e,S]),i.useEffect(()=>{if(!e)return;const E=document.activeElement;E instanceof HTMLElement&&!j.current&&(j.current=E),F.current?.focus()},[e]),i.useEffect(()=>{e&&a>0&&(F.current?.focus(),F.current?.select())},[e,a]),i.useEffect(()=>{const E=r.current;if(!E||(E.querySelectorAll(`mark[${jr}]`).forEach(_=>{_.removeAttribute(jr),_.className=Ya}),x===0))return;const z=C.current[Math.min(Math.max(h,0),x-1)];z&&(z.setAttribute(jr,""),z.className=cu,z.scrollIntoView({block:"nearest"}))},[r,h,x]);const V=i.useCallback(()=>{w(E=>x===0?0:(E+1)%x)},[x]),L=i.useCallback(()=>{w(E=>x===0?0:(E-1+x)%x)},[x]),I=i.useCallback(E=>{E.key==="Enter"?(E.preventDefault(),E.shiftKey?L():V()):E.key==="Escape"&&(E.preventDefault(),T())},[T,V,L]);return e?s.jsxs("div",{className:q("absolute right-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",p),children:[s.jsx(M,{name:"search",className:"ml-0.5 size-3.5 text-muted-foreground"}),s.jsx(In,{ref:F,value:v,onChange:E=>{f(E.target.value),S(E.target.value)},onKeyDown:I,placeholder:d("filesView.preview.find.placeholder"),"aria-label":d("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":x>0?d("filesView.preview.find.countAria",{current:h+1,total:x}):d("filesView.preview.find.noMatches"),children:v.trim()&&x===0?d("filesView.preview.find.noMatches"):x>0?`${h+1}/${x}`:""}),s.jsx($,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:L,title:d("filesView.preview.find.previousAria"),"aria-label":d("filesView.preview.find.previousAria"),disabled:x===0,children:s.jsx(M,{name:"arrow-up",className:"size-3.5"})}),s.jsx($,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:V,title:d("filesView.preview.find.nextAria"),"aria-label":d("filesView.preview.find.nextAria"),disabled:x===0,children:s.jsx(M,{name:"arrow-down",className:"size-3.5"})}),s.jsx($,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:T,title:d("filesView.preview.find.closeAria"),"aria-label":d("filesView.preview.find.closeAria"),children:s.jsx(M,{name:"close",className:"size-3.5"})})]}):null},hu=r=>{let e=!0;return{poll:async()=>{if(!e||r.isDirty())return!1;const t=r.getLoadedContent(),a=r.getLoadedRevision();try{const p=await r.readContent();if(!e||r.isDirty()||a!==r.getLoadedRevision())return!1;if(p===t)return!0;const d=await r.readContent();return!e||r.isDirty()||d!==p||a!==r.getLoadedRevision()?!1:(r.applyContent(p),!0)}catch{return!1}},dispose:()=>{e=!1}}},pu=1,gu=(r,e)=>e.size!==r.size||e.mtimeMs!==void 0&&r.mtimeMs!==void 0&&Math.abs(e.mtimeMs-r.mtimeMs)>=pu;function Ra(){const r=De.c(8),[e]=Ct.useState(vu),t=Ct.useRef(!1);let a;r[0]!==e?(a=x=>{if(x==null){e.cleanUp(),t.current=!1;return}t.current||(t.current=!0,e.setup(x,x.firstElementChild??void 0))},r[0]=e,r[1]=a):a=r[1];const p=a;let d,v;r[2]!==e?(d=()=>()=>{t.current=!1,e.cleanUp()},v=[e],r[2]=e,r[3]=d,r[4]=v):(d=r[3],v=r[4]),Ct.useLayoutEffect(d,v);let f;return r[5]!==p||r[6]!==e?(f={virtualizer:e,setScroller:p},r[5]=p,r[6]=e,r[7]=f):f=r[7],f}function vu(){return new Oc}const mn=new Map,xu=100;function Rs(r){const[e,t]=Ct.useState(null),a=Ct.useRef(null),p=Ct.useRef(null),d=Ct.useRef(null),v=Ct.useCallback((f,x)=>{f&&x instanceof Pc&&(d.current={key:r,file:x,node:f});const g=a.current,h=p.current,w=()=>{a.current===g&&(g?.(),h?.())};x?queueMicrotask(w):w()},[r]);return Ct.useLayoutEffect(()=>{if(!e||!r)return;const f=mn.get(r)??{top:0,left:0};let x=!0;const g=()=>d.current?.key===r?d.current.file:null,h=l=>d.current?.key===r?d.current.node.shadowRoot?.querySelector(`[data-line][data-line-index="${l-1}"]`):null,w=()=>{C.disconnect(),k.disconnect()},F=()=>{if(!x)return;const l=g(),S=f.line&&l?.getLinePosition(f.line.number),T=f.line&&h(f.line.number);let V=f.top;f.line&&S&&(V=(l?.top??0)+S.top-f.line.offset),f.line&&T&&(V=e.scrollTop+T.getBoundingClientRect().top-e.getBoundingClientRect().top-f.line.offset),e.scrollTop=V,e.scrollLeft=f.left,(!f.line||T)&&Math.abs(e.scrollTop-V)<1&&Math.abs(e.scrollLeft-f.left)<1&&(x=!1,w())},C=new ResizeObserver(F),k=new MutationObserver(()=>{if(x){for(const l of e.children)C.observe(l);F()}});C.observe(e);for(const l of e.children)C.observe(l);k.observe(e,{childList:!0,subtree:!0});const y=()=>{if(x)return;const l=g(),S=l?.getNumericScrollAnchor(e.scrollTop-(l.top??0)),T=S&&h(S.lineNumber),V=T?T.getBoundingClientRect().top-e.getBoundingClientRect().top:null;if(mn.delete(r),mn.set(r,{top:e.scrollTop,left:e.scrollLeft,line:S&&V!==null&&V>=0&&V<e.clientHeight?{number:S.lineNumber,offset:V}:void 0}),mn.size>xu){const L=mn.keys().next().value;L!==void 0&&mn.delete(L)}},j=()=>{x=!1,w()};return a.current=F,p.current=y,F(),e.addEventListener("scroll",y,{passive:!0}),e.addEventListener("wheel",j,{passive:!0}),e.addEventListener("touchstart",j,{passive:!0}),e.addEventListener("pointerdown",j,{passive:!0}),e.addEventListener("keydown",j),()=>{a.current=null,p.current=null,d.current?.key===r&&(d.current=null),w(),e.removeEventListener("scroll",y),e.removeEventListener("wheel",j),e.removeEventListener("touchstart",j),e.removeEventListener("pointerdown",j),e.removeEventListener("keydown",j)}},[r,e]),{setScroller:t,restore:v}}function wu(r){return!(!r.autoSaveEnabled||!r.isDirty||!r.canWrite||r.isSaving||r.fileLoading||r.isNonEditableBinary||!r.selectedFilePath||r.loadedFilePath!==r.selectedFilePath)}function bu(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 Za=2e5,yu=r=>{let e=0,t=0;for(let a=0;a<r.length;a++)r.charCodeAt(a)===10&&(a>0&&r.charCodeAt(a-1)===13?e++:t++);return e>t?`\r
|
|
5
|
+
`:`
|
|
6
|
+
`},Qa=r=>r.replace(/\r\n/g,`
|
|
7
|
+
`).replace(/\r/g,`
|
|
8
|
+
`),ju=r=>({content:Qa(r),lineEnding:yu(r)}),Cu=(r,e)=>{const t=Qa(r);return e===`\r
|
|
9
|
+
`?t.replace(/\n/g,`\r
|
|
10
|
+
`):t},Su=(r,e)=>e??(r.length>Za?"view":"edit"),Nu=r=>{let e=2166136261;for(let t=0;t<r.length;t++)e^=r.charCodeAt(t),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return`${r.length}:${e.toString(16)}`},Fu='<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 Ea(){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 Ru=i.forwardRef(function({xml:e,readOnly:t,className:a,onChange:p},d){const v=i.useRef(e),f=i.useRef(null),x=i.useRef(!1),[g,h]=i.useState(Ea),w=i.useRef(e),F=i.useRef(e);F.current!==e&&(F.current=e,w.current=e,v.current=e);const C=i.useRef(g);C.current!==g&&(C.current=g,w.current=v.current);const k=i.useRef(null);i.useEffect(()=>{const l=()=>h(Ea());l();const S=new MutationObserver(l);return S.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>S.disconnect()},[]),i.useEffect(()=>{const l=setTimeout(()=>{k.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(l)},[]),i.useImperativeHandle(d,()=>({getXml:()=>v.current}));const y=i.useCallback(()=>{!e&&!x.current&&(x.current=!0,setTimeout(()=>{f.current?.template({})},500))},[e]),j=i.useCallback(l=>{v.current=l.xml,p?.(l.xml)},[p]);return s.jsx("div",{ref:k,className:q("h-full w-full",a),children:s.jsx(Bc,{ref:f,xml:w.current||Fu,autosave:!0,urlParameters:{ui:t?"simple":g?"dark":"kennedy",spin:!0,libraries:!t,chrome:t,nav:t,layers:t,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:y,onAutoSave:j},g?"dark":"light")})}),Cr={ok:!0,snapshot:null},Eu=r=>r.hasCanvas&&r.viewMode==="preview"&&r.previewReady&&r.mountable,ka=r=>r.slice(r.replace(/\\/g,"/").lastIndexOf("/")+1)||r,ku=i.forwardRef(function(e,t){const{guestId:a,editorId:p,title:d,contentKind:v,path:f,content:x,readOnly:g}=e,{t:h}=nt(),w=i.useRef(e);w.current=e;const F=i.useCallback(l=>$c(l,{onChange:S=>{S.edited&&w.current.onEdit(),w.current.onDirtyChange(S.dirty)},onSave:()=>w.current.onSaveRequest(),onUnsupported:()=>w.current.onUnsupported()}),[]),[C,k]=i.useState(()=>v==="text"?F({path:f,name:ka(f),readOnly:g,encoding:"text",content:x}):null),[y]=i.useState(()=>({contentKind:v,path:f,readOnly:g}));i.useEffect(()=>{if(y.contentKind!=="binary")return;let l=!1;return w.current.loadBytes().then(S=>{if(!l){if(S.byteLength>Er){w.current.onTooLarge();return}k(F({path:y.path,name:ka(y.path),readOnly:y.readOnly,encoding:"binary",bytes:S}))}},()=>{l||w.current.onLoadFailed()}),()=>{l=!0}},[y,F]),i.useImperativeHandle(t,()=>({getContent:async l=>{const S={ok:!1,message:h("filesView.fileEditor.snapshotFailed",{editor:d})};if(!C)return S;try{const T=await C.requestSnapshot(l);return"bytes"in T?v==="binary"?{ok:!0,snapshot:{bytes:T.bytes,signature:T.version}}:S:v==="text"?{ok:!0,snapshot:{content:T.content,signature:T.version}}:S}catch{return S}},markSaved:l=>{C?.markSaved(l),w.current.onDirtyChange(!1)}}),[C,v,h,d]);const j=i.useMemo(()=>C?{editorId:p,channel:C}:null,[C,p]);return j?s.jsx(_c,{mode:Dl(a),surface:"file",fileEditor:j}):s.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:h("common.loading")})}),Tu=r=>r.slice(r.replace(/\\/g,"/").lastIndexOf("/")+1),eo=(r,e)=>{const t=Tu(e);if(!t)return null;for(const a of r)if(!(!a.fileEditors?.length||!Xl(a))){for(const p of a.fileEditors)if(p.match.some(d=>Yl(t,d)))return{guestId:a.id,editor:p}}return null},Mu=r=>{const e=De.c(3),t=Vr(Vu);let a;return e[0]!==r||e[1]!==t?(a=r?eo(t,r):null,e[0]=r,e[1]=t,e[2]=a):a=e[2],a};function Vu(r){return r.guests}const On=r=>{const e=De.c(18),{items:t,actions:a,className:p}=r;let d,v,f,x;if(e[0]!==a||e[1]!==p||e[2]!==t){x=Symbol.for("react.early_return_sentinel");e:{const F=t.filter(Pu);if(F.length===0&&!a){x=null;break e}e[7]!==p?(f=q("flex min-h-7 items-center gap-2 border-b border-border/40 bg-[var(--surface-subtle)] px-3 py-1",p),e[7]=p,e[8]=f):f=e[8],d="min-w-0 flex-1 truncate typography-meta text-muted-foreground",v=F.join(" · ")}e[0]=a,e[1]=p,e[2]=t,e[3]=d,e[4]=v,e[5]=f,e[6]=x}else d=e[3],v=e[4],f=e[5],x=e[6];if(x!==Symbol.for("react.early_return_sentinel"))return x;let g;e[9]!==d||e[10]!==v?(g=s.jsx("div",{className:d,children:v}),e[9]=d,e[10]=v,e[11]=g):g=e[11];let h;e[12]!==a?(h=a?s.jsx("div",{className:"flex shrink-0 items-center gap-1",children:a}):null,e[12]=a,e[13]=h):h=e[13];let w;return e[14]!==f||e[15]!==g||e[16]!==h?(w=s.jsxs("div",{className:f,children:[g,h]}),e[14]=f,e[15]=g,e[16]=h,e[17]=w):w=e[17],w};function Pu(r){return r.length>0}const Bn=r=>{if(r===null||!Number.isFinite(r)||r<0)return"";if(r<1024)return`${r} B`;const e=["KB","MB","GB"];let t=r/1024;for(const a of e){if(t<1024||a===e[e.length-1])return`${t.toFixed(t>=10?0:1)} ${a}`;t/=1024}return""},Du=r=>{if(r===null||!Number.isFinite(r)||r<0)return"";const e=Math.round(r),t=Math.floor(e/3600),a=Math.floor(e%3600/60),p=e%60,d=v=>String(v).padStart(2,"0");return t>0?`${t}:${d(a)}:${d(p)}`:`${a}:${d(p)}`},to=r=>r&&r.width>0&&r.height>0?`${r.width} × ${r.height}`:"",Lu=r=>{const e=De.c(28),{name:t,path:a,sizeBytes:p,download:d}=r,{t:v}=nt();let f,x,g,h,w,F,C;if(e[0]!==t||e[1]!==a||e[2]!==p||e[3]!==v){const l=Jl(a).toUpperCase();F="flex h-full min-h-0 flex-col",C=s.jsx(On,{items:[l,Bn(p)]}),g="flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",e[11]!==a?(h=s.jsx(zn,{filePath:a,className:"size-10"}),e[11]=a,e[12]=h):h=e[12],e[13]!==t?(w=s.jsx("div",{className:"max-w-full truncate typography-ui-header text-foreground",children:t}),e[13]=t,e[14]=w):w=e[14],f="max-w-md typography-ui text-muted-foreground",x=l?v("filesView.artifact.binary.descriptionWithType",{extension:l}):v("filesView.artifact.binary.description"),e[0]=t,e[1]=a,e[2]=p,e[3]=v,e[4]=f,e[5]=x,e[6]=g,e[7]=h,e[8]=w,e[9]=F,e[10]=C}else f=e[4],x=e[5],g=e[6],h=e[7],w=e[8],F=e[9],C=e[10];let k;e[15]!==f||e[16]!==x?(k=s.jsx("div",{className:f,children:x}),e[15]=f,e[16]=x,e[17]=k):k=e[17];let y;e[18]!==d||e[19]!==g||e[20]!==h||e[21]!==w||e[22]!==k?(y=s.jsxs("div",{className:g,children:[h,w,k,d]}),e[18]=d,e[19]=g,e[20]=h,e[21]=w,e[22]=k,e[23]=y):y=e[23];let j;return e[24]!==F||e[25]!==C||e[26]!==y?(j=s.jsxs("div",{className:F,children:[C,y]}),e[24]=F,e[25]=C,e[26]=y,e[27]=j):j=e[27],j},zu=[48,32,24,18,14],Au=["ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz",`0123456789 .,;:!?&@#%()[]{}<>+-=/\\*"'`];let Sr=0;const Iu=r=>{const e=De.c(16),{src:t,name:a,sizeBytes:p}=r,{t:d}=nt(),[v,f]=i.useState("loading"),[x]=i.useState(Ou);let g,h;e[0]!==x||e[1]!==t?(g=()=>{let y=!1;f("loading");const j=new FontFace(x,`url("${t.replace(/"/g,"%22")}")`);return document.fonts.add(j),j.load().then(()=>{y||f("ready")}).catch(()=>{y||f("failed")}),()=>{y=!0,document.fonts.delete(j)}},h=[x,t],e[0]=x,e[1]=t,e[2]=g,e[3]=h):(g=e[2],h=e[3]),i.useEffect(g,h);let w;e[4]!==p?(w=Bn(p),e[4]=p,e[5]=w):w=e[5];let F;e[6]!==a||e[7]!==w?(F=s.jsx(On,{items:[a,w]}),e[6]=a,e[7]=w,e[8]=F):F=e[8];let C;e[9]!==x||e[10]!==v||e[11]!==d?(C=v==="failed"?s.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-center typography-ui text-muted-foreground",children:d("filesView.artifact.font.loadFailed")}):v==="loading"?s.jsxs("div",{className:"flex items-center gap-2 p-3 typography-ui text-muted-foreground",children:[s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),d("common.loading")]}):s.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-4",style:{fontFamily:`"${x}"`},children:s.jsxs("div",{className:"flex flex-col gap-4",children:[zu.map(y=>s.jsxs("div",{className:"flex items-baseline gap-3",children:[s.jsx("span",{className:"w-8 shrink-0 text-right font-sans typography-meta text-muted-foreground",children:y}),s.jsx("span",{className:"min-w-0 break-words leading-tight text-foreground",style:{fontSize:`${y}px`},children:d("filesView.artifact.font.sample")})]},y)),s.jsx("div",{className:"mt-2 flex flex-col gap-1 border-t border-border/40 pt-4 text-foreground",style:{fontSize:"20px"},children:Au.map(Bu)})]})}),e[9]=x,e[10]=v,e[11]=d,e[12]=C):C=e[12];let k;return e[13]!==F||e[14]!==C?(k=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[F,C]}),e[13]=F,e[14]=C,e[15]=k):k=e[15],k};function Ou(){return Sr=Sr+1,`oc-font-preview-${Sr}`}function Bu(r){return s.jsx("div",{className:"break-all leading-relaxed",children:r},r)}const Ls=12,no=.1,so=16,Ta=[.1,.25,.5,.75,1,1.5,2,3,4,6,8,12,16],$u=16,Ma=30,_u=(r,e)=>{const t=e.width-Ls*2,a=e.height-Ls*2;return r.width<=0||r.height<=0||t<=0||a<=0?1:Math.min(1,t/r.width,a/r.height)},Wu=(r,e)=>Math.min(so,Math.max(Math.min(no,e),r)),Va=(r,e)=>e===1?Ta.find(t=>t>r*1.001)??so:[...Ta].reverse().find(t=>t<r*.999)??no,Uu=(r,e)=>{const t=e===1?r*$u:r,a=Math.max(-Ma,Math.min(Ma,t));return Math.exp(-a/100)},Pa=(r,e)=>Math.hypot(r.clientX-e.clientX,r.clientY-e.clientY),Hu=({src:r,name:e,sizeBytes:t})=>{const{t:a}=nt(),[p,d]=i.useState(null),[v,f]=i.useState(null),[x,g]=i.useState(null),[h,w]=i.useState(!1),F=i.useRef(null),C=i.useRef(null),k=i.useRef(null),y=i.useRef(null);i.useEffect(()=>{f(null),d(null)},[r]),i.useEffect(()=>{const R=F.current;if(!R)return;const P=new ResizeObserver(()=>{g({width:R.clientWidth,height:R.clientHeight})});return P.observe(R),()=>P.disconnect()},[]);const j=v&&x?_u(v,x):1,l=p??j,S=p!==null&&v!==null&&x!==null&&(v.width*p+Ls*2>x.width||v.height*p+Ls*2>x.height),T=(R,P,O)=>{const K=C.current;if(!K||!v)return;const Q=K.getBoundingClientRect(),ee=K.clientWidth/v.width;ee<=0||(k.current={imageX:(P-Q.left-K.clientLeft)/ee,imageY:(O-Q.top-K.clientTop)/ee,clientX:P,clientY:O},Ts.flushSync(()=>d(Wu(R,j))))},V=R=>{const P=F.current;if(!P)return;const O=P.getBoundingClientRect();T(R,O.left+O.width/2,O.top+O.height/2)};i.useLayoutEffect(()=>{const R=k.current,P=F.current,O=C.current;if(k.current=null,!R||!P||!O||p===null||O.naturalWidth<=0)return;const K=O.getBoundingClientRect(),Q=O.clientWidth/O.naturalWidth;P.scrollLeft+=K.left+O.clientLeft+R.imageX*Q-R.clientX,P.scrollTop+=K.top+O.clientTop+R.imageY*Q-R.clientY},[p]);const L=i.useRef({zoomTo:T,shownScale:l});L.current={zoomTo:T,shownScale:l},i.useEffect(()=>{const R=F.current;if(!R)return;let P=0,O=null,K=null;const Q=A=>{if(!A.ctrlKey&&!A.metaKey)return;A.preventDefault();const ue=L.current;ue.zoomTo(ue.shownScale*Uu(A.deltaY,A.deltaMode),A.clientX,A.clientY)},ee=A=>{P=A.touches.length,A.touches.length===2&&(O={distance:Pa(A.touches[0],A.touches[1]),scale:L.current.shownScale})},ae=A=>{if(!O||A.touches.length!==2||O.distance<=0)return;A.preventDefault();const[ue,xe]=[A.touches[0],A.touches[1]];L.current.zoomTo(O.scale*(Pa(ue,xe)/O.distance),(ue.clientX+xe.clientX)/2,(ue.clientY+xe.clientY)/2)},J=A=>{P=A.touches.length,A.touches.length<2&&(O=null)},Y=A=>{A.preventDefault(),K=P>0?null:L.current.shownScale},se=A=>{A.preventDefault(),K!==null&&L.current.zoomTo(K*A.scale,A.clientX,A.clientY)},Le=A=>{A.preventDefault(),K=null};return R.addEventListener("wheel",Q,{passive:!1}),R.addEventListener("touchstart",ee,{passive:!0}),R.addEventListener("touchmove",ae,{passive:!1}),R.addEventListener("touchend",J,{passive:!0}),R.addEventListener("touchcancel",J,{passive:!0}),R.addEventListener("gesturestart",Y),R.addEventListener("gesturechange",se),R.addEventListener("gestureend",Le),()=>{R.removeEventListener("wheel",Q),R.removeEventListener("touchstart",ee),R.removeEventListener("touchmove",ae),R.removeEventListener("touchend",J),R.removeEventListener("touchcancel",J),R.removeEventListener("gesturestart",Y),R.removeEventListener("gesturechange",se),R.removeEventListener("gestureend",Le)}},[]);const I=R=>{if(!S||R.pointerType!=="mouse"||R.button!==0)return;const P=R.currentTarget,O=P.getBoundingClientRect();R.clientX-O.left>=P.clientWidth||R.clientY-O.top>=P.clientHeight||(R.preventDefault(),P.setPointerCapture(R.pointerId),y.current={pointerId:R.pointerId,x:R.clientX,y:R.clientY,left:P.scrollLeft,top:P.scrollTop},w(!0))},E=R=>{const P=y.current;!P||P.pointerId!==R.pointerId||(R.currentTarget.scrollLeft=P.left-(R.clientX-P.x),R.currentTarget.scrollTop=P.top-(R.clientY-P.y))},z=R=>{y.current?.pointerId===R.pointerId&&(y.current=null,w(!1))},_=R=>{if(p===null){T(1,R.clientX,R.clientY);return}d(null)};return s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[s.jsx(On,{items:[to(v),Bn(t)],actions:s.jsxs(s.Fragment,{children:[s.jsx($,{variant:"ghost",size:"xs","aria-label":a("filesView.artifact.image.zoomOut"),title:a("filesView.artifact.image.zoomOut"),disabled:!v,onClick:()=>V(Va(l,-1)),children:s.jsx(M,{name:"subtract",className:"size-3.5"})}),s.jsx($,{variant:"ghost",size:"xs",className:"min-w-11 tabular-nums",title:a("filesView.artifact.image.actualTitle"),disabled:!v,onClick:()=>V(1),children:`${Math.round(l*100)}%`}),s.jsx($,{variant:"ghost",size:"xs","aria-label":a("filesView.artifact.image.zoomIn"),title:a("filesView.artifact.image.zoomIn"),disabled:!v,onClick:()=>V(Va(l,1)),children:s.jsx(M,{name:"add",className:"size-3.5"})}),s.jsx($,{variant:"chip",size:"xs","aria-pressed":p===null,title:a("filesView.artifact.image.fitTitle"),onClick:()=>d(null),children:a("filesView.artifact.image.fit")})]})}),s.jsx("div",{ref:F,className:q("min-h-0 flex-1 overflow-auto",S&&(h?"cursor-grabbing":"cursor-grab")),onPointerDown:I,onPointerMove:E,onPointerUp:z,onPointerCancel:z,onDoubleClick:_,children:s.jsx("div",{className:q("flex items-center justify-center p-3",p===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:R=>{const P=R.currentTarget;f({width:P.naturalWidth,height:P.naturalHeight})},style:p!==null&&v?{width:v.width*p,height:v.height*p}:void 0,className:q("select-none rounded-md border border-border/30 bg-primary/10",p===null?"max-h-full max-w-full object-contain":"max-w-none shrink-0")},r)})})]})},Ku=r=>{const e=De.c(24),{kind:t,src:a,name:p,sizeBytes:d,download:v}=r,{t:f}=nt(),[x,g]=i.useState(null),[h,w]=i.useState(null),[F,C]=i.useState(!1);let k;e[0]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{g(null),w(null),C(!1)},e[0]=k):k=e[0];let y;e[1]!==a?(y=[a],e[1]=a,e[2]=y):y=e[2],i.useEffect(k,y);let j;e[3]===Symbol.for("react.memo_cache_sentinel")?(j=z=>{const _=z.currentTarget;g(Number.isFinite(_.duration)?_.duration:null),_ instanceof HTMLVideoElement&&w({width:_.videoWidth,height:_.videoHeight})},e[3]=j):j=e[3];const l=j;let S;e[4]!==x?(S=Du(x),e[4]=x,e[5]=S):S=e[5];let T;e[6]!==h?(T=to(h),e[6]=h,e[7]=T):T=e[7];let V;e[8]!==d?(V=Bn(d),e[8]=d,e[9]=V):V=e[9];let L;e[10]!==S||e[11]!==T||e[12]!==V?(L=s.jsx(On,{items:[S,T,V]}),e[10]=S,e[11]=T,e[12]=V,e[13]=L):L=e[13];let I;e[14]!==v||e[15]!==F||e[16]!==t||e[17]!==p||e[18]!==a||e[19]!==f?(I=F?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:f("filesView.artifact.media.unplayable")}),v]}):t==="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:a,controls:!0,playsInline:!0,preload:"metadata",title:p,className:"max-h-full max-w-full rounded-md",onLoadedMetadata:l,onError:()=>C(!0)},a)}):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:p}),s.jsx("audio",{src:a,controls:!0,preload:"metadata",title:p,className:"w-full max-w-lg",onLoadedMetadata:l,onError:()=>C(!0)},a)]}),e[14]=v,e[15]=F,e[16]=t,e[17]=p,e[18]=a,e[19]=f,e[20]=I):I=e[20];let E;return e[21]!==L||e[22]!==I?(E=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[L,I]}),e[21]=L,e[22]=I,e[23]=E):E=e[23],E},qu=2e3,Gu=r=>r.toLowerCase().endsWith(".tsv")?" ":",",Xu=(r,e,t=qu)=>{const a=[];let p=0,d="",v=[],f=!1,x=!1;const g=()=>{v.push(d),d="",v.length===1&&v[0]===""&&!x||((p===0||a.length<=t)&&a.push(v),p+=1),v=[],x=!1},h=r.charCodeAt(0)===65279?r.slice(1):r;for(let y=0;y<h.length;y+=1){const j=h[y];if(f){j==='"'?h[y+1]==='"'?(d+='"',y+=1):f=!1:d+=j;continue}if(j==='"'){f=!0,x=!0;continue}if(j===e){v.push(d),d="",x=!0;continue}if(j===`
|
|
11
|
+
`||j==="\r"){j==="\r"&&h[y+1]===`
|
|
12
|
+
`&&(y+=1),g();continue}d+=j}(d.length>0||v.length>0||f)&&g();const w=a[0]??[],F=a.slice(1),C=a.reduce((y,j)=>Math.max(y,j.length),0),k=Math.max(0,p-1);return{header:w,rows:F,totalRows:k,columnCount:C,truncated:F.length<k}},Yu=r=>{const e=De.c(29),{path:t,content:a,sizeBytes:p}=r,{t:d}=nt();let v;e[0]!==a||e[1]!==t?(v=Xu(a,Gu(t)),e[0]=a,e[1]=t,e[2]=v):v=e[2];const f=v;let x;e[3]!==d||e[4]!==f.columnCount||e[5]!==f.totalRows?(x=f.totalRows===1?d("filesView.artifact.table.rowsSingle",{rows:f.totalRows,columns:f.columnCount}):d("filesView.artifact.table.rowsPlural",{rows:f.totalRows,columns:f.columnCount}),e[3]=d,e[4]=f.columnCount,e[5]=f.totalRows,e[6]=x):x=e[6];const g=x;let h;e[7]!==f.columnCount?(h=Array.from({length:f.columnCount},Ju),e[7]=f.columnCount,e[8]=h):h=e[8];const w=h;let F;e[9]!==d||e[10]!==f.rows||e[11]!==f.totalRows||e[12]!==f.truncated?(F=f.truncated?d("filesView.artifact.table.truncated",{shown:f.rows.length,total:f.totalRows}):"",e[9]=d,e[10]=f.rows,e[11]=f.totalRows,e[12]=f.truncated,e[13]=F):F=e[13];let C;e[14]!==p?(C=Bn(p),e[14]=p,e[15]=C):C=e[15];let k;e[16]!==g||e[17]!==F||e[18]!==C?(k=s.jsx(On,{items:[g,F,C]}),e[16]=g,e[17]=F,e[18]=C,e[19]=k):k=e[19];let y;e[20]!==w||e[21]!==d||e[22]!==f.columnCount||e[23]!==f.header||e[24]!==f.rows?(y=f.columnCount===0?s.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:d("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:w.map(l=>s.jsx("th",{scope:"col",className:"whitespace-nowrap border-b border-r border-border/40 px-2 py-1 text-left font-medium text-foreground last:border-r-0",children:f.header[l]??""},l))})}),s.jsx("tbody",{children:f.rows.map((l,S)=>s.jsx("tr",{className:"odd:bg-[var(--surface-background)] even:bg-[var(--surface-subtle)]/40",children:w.map(T=>s.jsx("td",{className:"max-w-[32rem] truncate border-b border-r border-border/30 px-2 py-1 align-top text-foreground last:border-r-0",title:l[T]??"",children:l[T]??""},T))},S))})]})}),e[20]=w,e[21]=d,e[22]=f.columnCount,e[23]=f.header,e[24]=f.rows,e[25]=y):y=e[25];let j;return e[26]!==k||e[27]!==y?(j=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[k,y]}),e[26]=k,e[27]=y,e[28]=j):j=e[28],j};function Ju(r,e){return e}const hn="data-oc-local-asset",Zu=25*1024*1024,Es=r=>{const e=r.trim();return!e||e.startsWith("#")||e.startsWith("//")?!1:!/^[a-z][a-z\d+.-]*:/i.test(e)},Qu=r=>r.split(/[?#]/,1)[0]??"",ed=r=>r.trim().toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").replace(/\s+/g,"-"),td=(r,e)=>{const t=ro(e.replace(/^#/,"")).toLowerCase();if(!t)return!1;for(const a of Array.from(r.querySelectorAll("h1, h2, h3, h4, h5, h6")))if(a.id===t||ed(a.textContent??"")===t)return a.scrollIntoView({block:"start"}),!0;return!1},ro=r=>{try{return decodeURIComponent(r)}catch{return r}},nd=r=>r.split(",").flatMap(e=>{const[t,...a]=e.trim().split(/\s+/);return t?[{url:t,descriptor:a.join(" ")}]:[]}),Nr="data-oc-media",sd=/\(\s*prefers-color-scheme\s*:\s*(light|dark)\s*\)/gi,Da=(r,e)=>{for(const t of Array.from(r.querySelectorAll("picture > source[media]"))){const a=t.getAttribute(Nr)??t.getAttribute("media")??"",p=a.replace(sd,(d,v)=>v.toLowerCase()===e?"(min-width: 0px)":"(max-width: -1px)");p!==a&&(t.getAttribute(Nr)!==a&&t.setAttribute(Nr,a),t.getAttribute("media")!==p&&t.setAttribute("media",p))}},La=({container:r,filePath:e,workspaceRoot:t,onOpenFile:a,enabled:p,colorScheme:d})=>{const v=i.useRef(a);v.current=a;const f=i.useRef(d);f.current=d,i.useEffect(()=>{p&&r&&Da(r,d)},[d,r,p]),i.useEffect(()=>{if(!p||!r||!e)return;const x=e.slice(0,e.lastIndexOf("/")+1)||"/",g=S=>Zl(x,ro(Qu(S))),h=S=>({path:S,allowOutsideWorkspace:t&&Ql(S,t)?void 0:"true",directory:t||void 0});let w=!1;const F=ot(),C=new Map,k=S=>{const T=C.get(S);if(T)return T;const V=(async()=>{const L=await Ms("/api/fs/raw",{query:h(S),signal:AbortSignal.timeout(3e4)});if(!L.ok)throw new Error(`Image read failed (${L.status})`);const I=await L.blob();if(I.size>Zu)throw new Error("Image too large for preview");if(w||ot()!==F)throw new Error("Preview closed");return URL.createObjectURL(I)})();return C.set(S,V),V.catch(()=>C.delete(S)),V},y=()=>{for(const S of Array.from(r.querySelectorAll("img[src]"))){const T=S.getAttribute("src")??"";if(!Es(T))continue;const V=g(T);S.setAttribute(hn,V),k(V).then(L=>{w||S.getAttribute(hn)!==V||S.getAttribute("src")!==L&&(S.src=L)}).catch(()=>{w||S.removeAttribute(hn)})}for(const S of Array.from(r.querySelectorAll("source[srcset], img[srcset]"))){const T=nd(S.getAttribute("srcset")??"");if(!T.some(I=>Es(I.url)))continue;const V=T.map(I=>({...I,path:Es(I.url)?g(I.url):null})),L=V.map(I=>I.path??I.url).join(",");S.setAttribute(hn,L),Promise.all(V.map(async({url:I,descriptor:E,path:z})=>{const _=z?await k(z):I;return E?`${_} ${E}`:_})).then(I=>{if(w||S.getAttribute(hn)!==L)return;const E=I.join(", ");S.getAttribute("srcset")!==E&&S.setAttribute("srcset",E)}).catch(()=>{w||S.removeAttribute(hn)})}Da(r,f.current)},j=S=>{if(S.defaultPrevented||S.button!==0||S.metaKey||S.ctrlKey||S.shiftKey||S.altKey)return;const T=S.target;if(!(T instanceof Element))return;const V=T.closest("a[href]");if(!(V instanceof HTMLAnchorElement)||!r.contains(V))return;const L=V.getAttribute("href")??"";if(L.startsWith("#")){S.preventDefault(),S.stopPropagation(),td(r,L);return}Es(L)&&(S.preventDefault(),S.stopPropagation(),v.current(g(L)))};y();const l=new MutationObserver(y);return l.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["src","srcset","media"]}),r.addEventListener("click",j,!0),()=>{w=!0,l.disconnect(),r.removeEventListener("click",j,!0);for(const S of C.values())S.then(T=>URL.revokeObjectURL(T)).catch(()=>{})}},[r,p,e,t])},rd=r=>{const e=te(r);if(!e)return"";if(e==="/"||/^[A-Za-z]:\/$/.test(e))return e;const t=e.lastIndexOf("/");if(t<0)return e;if(t===0)return"/";const a=e.slice(0,t);return/^[A-Za-z]:$/.test(a)?`${a}/`:a},id=r=>{const e=De.c(8),{label:t,iconDataUrl:a}=r,[p,d]=i.useState(!1);let v;e[0]!==t?(v=t.trim().slice(0,1).toUpperCase()||"?",e[0]=t,e[1]=v):v=e[1];const f=v;if(a&&!p){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=()=>d(!0),e[2]=h):h=e[2];let w;return e[3]!==a?(w=s.jsx("img",{src:a,alt:"",className:"size-4 rounded-sm",onError:h}),e[3]=a,e[4]=w):w=e[4],w}let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=q("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=x):x=e[5];let g;return e[6]!==f?(g=s.jsx("span",{className:x,children:f}),e[6]=f,e[7]=g):g=e[7],g},ad=r=>r.slice().sort((e,t)=>e.type!==t.type?e.type==="directory"?-1:1:e.name.localeCompare(t.name)),te=r=>{if(!r)return"";const e=r.replace(/\\/g,"/"),t=e.startsWith("//");let a=e.replace(/\/+/g,"/");t&&!a.startsWith("//")&&(a=`/${a}`);const p=a==="/",d=/^[A-Za-z]:\/$/.test(a);return!p&&!d&&(a=a.replace(/\/+$/,"")),a},od=r=>r.startsWith("/")||r.startsWith("//")||/^[A-Za-z]:\//.test(r),gn=r=>/^[A-Za-z]:\//.test(r)?r.toLowerCase():r,An=(r,e)=>{const t=te(e),a=te(r);if(!t||!a)return!1;const p=gn(t),d=gn(a);return d===p||d.startsWith(`${p}/`)},za=(r,e)=>{const t=te(e),a=te(r);if(!An(a,t))return[];const d=a.slice(t.length).replace(/^\//,"").split("/"),v=[];let f=t;for(let x=0;x<d.length-1;x++)f=f?`${f}/${d[x]}`:d[x],v.push(f);return v},Ps=(r,e)=>{if(!e)return"";const t=te(e);if(!r||!An(t,r))return t;const a=t.slice(r.length);return a.startsWith("/")?a.slice(1):a},ld=new Set(["node_modules"]),cd=r=>{const e=De.c(3),{status:t}=r;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=a):a=e[0];const p=a[t];let d;return e[1]!==p?(d=s.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:p}}),e[1]=p,e[2]=d):d=e[2],d},Aa=r=>{const e=De.c(11),{name:t}=r,a=i.useRef(null),p=i.useRef(null),[d,v]=i.useState(!1);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{const F=a.current,C=p.current;if(!F||!C)return;const k=()=>{v(C.scrollWidth>F.clientWidth+1)};k();const y=new ResizeObserver(k);return y.observe(F),y.observe(C),()=>{y.disconnect()}},e[0]=f):f=e[0];let x;e[1]!==t?(x=[t],e[1]=t,e[2]=x):x=e[2],i.useLayoutEffect(f,x);let g;e[3]!==t?(g=s.jsx("span",{ref:p,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:t}),e[3]=t,e[4]=g):g=e[4];let h;e[5]!==t||e[6]!==d?(h=d?s.jsxs("span",{className:"open-file-name-marquee-track",children:[s.jsx("span",{className:"open-file-name-marquee-item",children:t}),s.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:t})]}):s.jsx("span",{className:"block min-w-0 truncate",children:t}),e[5]=t,e[6]=d,e[7]=h):h=e[7];let w;return e[8]!==g||e[9]!==h?(w=s.jsxs("span",{ref:a,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[g,h]}),e[8]=g,e[9]=h,e[10]=w):w=e[10],w},ud=r=>ld.has(r),dd=r=>{const e=te(r);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},fd=r=>{const t=(r instanceof Error?r.message:String(r??"")).toLowerCase();return t.includes("is a directory")||t.includes("eisdir")},Ia=r=>{const t=(r instanceof Error?r.message:String(r??"")).toLowerCase();return t.includes("file not found")||t.includes("enoent")||t.includes("no such file")||t.includes("does not exist")},md=2e5,io=(r,e)=>s.jsx(zn,{filePath:r,extension:e}),Fr=r=>{if(!r)return!1;const e=r.toLowerCase();if(e.endsWith(".excalidraw.md"))return!1;const t=e.split(".").pop();return t==="md"||t==="markdown"},Rr=r=>!!(r&&eo(Vr.getState().guests,r)),Oa=r=>{if(!r)return!1;const e=r.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},ks=r=>{if(!r)return!1;const e=r.toLowerCase().split(".").pop();return e==="html"||e==="htm"},hd=r=>{const e=De.c(78),{node:t,root:a,isExpanded:p,isActive:d,isMobile:v,isBrowserClient:f,alwaysShowActions:x,status:g,badge:h,permissions:w,downloadFile:F,contextMenuPath:C,setContextMenuPath:k,rightClickMenuPath:y,setRightClickMenuPath:j,onSelect:l,onToggle:S,onRevealPath:T,onOpenDialog:V,canUpload:L,onPickFiles:I}=r,{t:E}=nt(),z=t.type==="directory",{canRename:_,canCreateFile:R,canCreateFolder:P,canDelete:O,canReveal:K}=w,Q=!z&&!!F,ee=K&&!f,ae=z&&L,J=_||R||P||ae||O||Q||ee;let Y;e[0]!==J||e[1]!==t.path||e[2]!==j?(Y=ye=>{J&&(ye?.preventDefault(),j(t.path))},e[0]=J,e[1]=t.path,e[2]=j,e[3]=Y):Y=e[3];const se=Y;let Le;e[4]!==z||e[5]!==t||e[6]!==l||e[7]!==S?(Le=()=>{z?S(t.path):l(t)},e[4]=z,e[5]=t,e[6]=l,e[7]=S,e[8]=Le):Le=e[8];const A=Le;let ue;e[9]!==t.path||e[10]!==k||e[11]!==j?(ue=ye=>{ye.stopPropagation(),j(null),k(t.path)},e[9]=t.path,e[10]=k,e[11]=j,e[12]=ue):ue=e[12];const xe=ue;let ze;e[13]!==R||e[14]!==P||e[15]!==O||e[16]!==_||e[17]!==ee||e[18]!==ae||e[19]!==F||e[20]!==f||e[21]!==z||e[22]!==t||e[23]!==V||e[24]!==I||e[25]!==T||e[26]!==a||e[27]!==E?(ze=ye=>{const{Item:Ee,Separator:st}=ye;return s.jsxs(s.Fragment,{children:[_&&s.jsxs(Ee,{onClick:me=>{me.stopPropagation(),V("rename",t)},children:[s.jsx(M,{name:"edit",className:"mr-2 size-4"})," ",E("sidebarFilesTree.menu.rename")]}),s.jsxs(Ee,{onClick:me=>{me.stopPropagation(),Ds(t.path).then(We=>{if(We.ok){X.success(E("sidebarFilesTree.toast.pathCopied"));return}X.error(E("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(M,{name:"file-copy",className:"mr-2 size-4"})," ",E("sidebarFilesTree.menu.copyPath")]}),s.jsxs(Ee,{onClick:me=>{me.stopPropagation();const We=Ps(a,t.path)||t.path;Ds(We).then($n=>{if($n.ok){X.success(E("filesView.toast.relativePathCopied"));return}X.error(E("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(M,{name:"file-copy-2",className:"mr-2 size-4"})," ",E("filesView.tree.menu.copyRelativePath")]}),!z&&F&&s.jsxs(Ee,{onClick:me=>{me.stopPropagation(),F(t.path).catch(We=>{console.error("Download failed:",We),X.error(E("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(M,{name:"download",className:"mr-2 size-4"})," ",E(f?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),ee&&s.jsxs(Ee,{onClick:me=>{me.stopPropagation(),T(t.path)},children:[s.jsx(M,{name:"folder-received",className:"mr-2 size-4"})," ",E(yc())]}),z&&(R||P||ae)&&s.jsxs(s.Fragment,{children:[s.jsx(st,{}),R&&s.jsxs(Ee,{onClick:me=>{me.stopPropagation(),V("createFile",t)},children:[s.jsx(M,{name:"file-add",className:"mr-2 size-4"})," ",E("sidebarFilesTree.menu.newFile")]}),P&&s.jsxs(Ee,{onClick:me=>{me.stopPropagation(),V("createFolder",t)},children:[s.jsx(M,{name:"folder-add",className:"mr-2 size-4"})," ",E("sidebarFilesTree.menu.newFolder")]}),ae&&s.jsxs(Ee,{onClick:me=>{me.stopPropagation(),I(t.path)},children:[s.jsx(M,{name:"upload-2",className:"mr-2 size-4"})," ",E("sidebarFilesTree.menu.uploadFiles")]})]}),O&&s.jsxs(s.Fragment,{children:[s.jsx(st,{}),s.jsxs(Ee,{onClick:me=>{me.stopPropagation(),V("delete",t)},className:"text-destructive focus:text-destructive",children:[s.jsx(M,{name:"delete-bin",className:"mr-2 size-4"})," ",E("sidebarFilesTree.menu.delete")]})]})]})},e[13]=R,e[14]=P,e[15]=O,e[16]=_,e[17]=ee,e[18]=ae,e[19]=F,e[20]=f,e[21]=z,e[22]=t,e[23]=V,e[24]=I,e[25]=T,e[26]=a,e[27]=E,e[28]=ze):ze=e[28];const Fe=ze,$e=y===t.path;let Re;e[29]!==t.path||e[30]!==j?(Re=ye=>j(ye?t.path:null),e[29]=t.path,e[30]=j,e[31]=Re):Re=e[31];const ne=v?void 0:se;let de;e[32]!==ne?(de=s.jsx("div",{className:"group relative flex items-center",onContextMenu:ne}),e[32]=ne,e[33]=de):de=e[33];const _e=v?void 0:se,G=d?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let W;e[34]!==G?(W=q("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",G),e[34]=G,e[35]=W):W=e[35];let oe;e[36]!==z||e[37]!==p||e[38]!==t.extension||e[39]!==t.path?(oe=z?p?s.jsx(M,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):s.jsx(M,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):io(t.path,t.extension),e[36]=z,e[37]=p,e[38]=t.extension,e[39]=t.path,e[40]=oe):oe=e[40];let le;e[41]!==t.name||e[42]!==t.path?(le=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:t.path,children:t.name}),e[41]=t.name,e[42]=t.path,e[43]=le):le=e[43];let Se;e[44]!==z||e[45]!==g?(Se=!z&&g&&s.jsx(cd,{status:g}),e[44]=z,e[45]=g,e[46]=Se):Se=e[46];let re;e[47]!==h||e[48]!==z?(re=z&&h&&s.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[h.modified>0&&s.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",h.modified]}),h.added>0&&s.jsxs("span",{className:"text-[var(--status-success)]",children:["+",h.added]})]}),e[47]=h,e[48]=z,e[49]=re):re=e[49];let fe;e[50]!==A||e[51]!==W||e[52]!==oe||e[53]!==le||e[54]!==Se||e[55]!==re||e[56]!==_e?(fe=s.jsxs("button",{type:"button",onClick:A,onContextMenu:_e,className:W,children:[oe,le,Se,re]}),e[50]=A,e[51]=W,e[52]=oe,e[53]=le,e[54]=Se,e[55]=re,e[56]=_e,e[57]=fe):fe=e[57];let pe;e[58]!==x||e[59]!==C||e[60]!==xe||e[61]!==J||e[62]!==v||e[63]!==t.path||e[64]!==Fe||e[65]!==k?(pe=J&&s.jsx("div",{className:q("absolute right-1 top-1/2 -translate-y-1/2",x?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:s.jsxs(kr,{open:C===t.path,onOpenChange:ye=>k(ye?t.path:null),children:[s.jsx(Tr,{asChild:!0,children:s.jsx($,{variant:"ghost",size:"icon",className:"size-6",onClick:xe,children:s.jsx(M,{name:"more-2-fill",className:"size-4"})})}),s.jsx(Mr,{align:"end",side:"bottom",onCloseAutoFocus:()=>k(null),children:Fe({Item:Vs,Separator:bc})})]})}),e[58]=x,e[59]=C,e[60]=xe,e[61]=J,e[62]=v,e[63]=t.path,e[64]=Fe,e[65]=k,e[66]=pe):pe=e[66];let be;e[67]!==fe||e[68]!==pe||e[69]!==de?(be=s.jsxs(Ec,{render:de,children:[fe,pe]}),e[67]=fe,e[68]=pe,e[69]=de,e[70]=be):be=e[70];let ge;e[71]!==Fe?(ge=s.jsx(Nc,{className:"min-w-[180px]",children:Fe({Item:Rc,Separator:Fc})}),e[71]=Fe,e[72]=ge):ge=e[72];let pt;return e[73]!==be||e[74]!==ge||e[75]!==$e||e[76]!==Re?(pt=s.jsxs(kc,{open:$e,onOpenChange:Re,children:[be,ge]}),e[73]=be,e[74]=ge,e[75]=$e,e[76]=Re,e[77]=pt):pt=e[77],pt},pd=r=>{const e=De.c(83),{activeDialog:t,dialogData:a,dialogInputValue:p,onDialogInputChange:d,isDialogSubmitting:v,onDialogSubmit:f,onClose:x,inputRef:g}=r,{t:h}=nt(),w=!!t;let F;e[0]!==x?(F=se=>!se&&x(),e[0]=x,e[1]=F):F=e[1];let C;e[2]!==t||e[3]!==h?(C=t==="createFile"&&h("filesView.dialog.createFile.title"),e[2]=t,e[3]=h,e[4]=C):C=e[4];let k;e[5]!==t||e[6]!==h?(k=t==="createFolder"&&h("filesView.dialog.createFolder.title"),e[5]=t,e[6]=h,e[7]=k):k=e[7];let y;e[8]!==t||e[9]!==h?(y=t==="rename"&&h("filesView.dialog.rename.title"),e[8]=t,e[9]=h,e[10]=y):y=e[10];let j;e[11]!==t||e[12]!==h?(j=t==="delete"&&h("filesView.dialog.delete.title"),e[11]=t,e[12]=h,e[13]=j):j=e[13];let l;e[14]!==C||e[15]!==k||e[16]!==y||e[17]!==j?(l=s.jsxs(qa,{children:[C,k,y,j]}),e[14]=C,e[15]=k,e[16]=y,e[17]=j,e[18]=l):l=e[18];let S;e[19]!==t||e[20]!==a?.path||e[21]!==h?(S=t==="createFile"&&h("filesView.dialog.createFile.description",{path:a?.path??h("filesView.dialog.rootFallback")}),e[19]=t,e[20]=a?.path,e[21]=h,e[22]=S):S=e[22];let T;e[23]!==t||e[24]!==a?.path||e[25]!==h?(T=t==="createFolder"&&h("filesView.dialog.createFolder.description",{path:a?.path??h("filesView.dialog.rootFallback")}),e[23]=t,e[24]=a?.path,e[25]=h,e[26]=T):T=e[26];let V;e[27]!==t||e[28]!==a?.name||e[29]!==h?(V=t==="rename"&&h("filesView.dialog.rename.description",{name:a?.name??""}),e[27]=t,e[28]=a?.name,e[29]=h,e[30]=V):V=e[30];let L;e[31]!==t||e[32]!==a?.name||e[33]!==h?(L=t==="delete"&&h("filesView.dialog.delete.description",{name:a?.name??""}),e[31]=t,e[32]=a?.name,e[33]=h,e[34]=L):L=e[34];let I;e[35]!==V||e[36]!==L||e[37]!==S||e[38]!==T?(I=s.jsxs(Ga,{children:[S,T,V,L]}),e[35]=V,e[36]=L,e[37]=S,e[38]=T,e[39]=I):I=e[39];let E;e[40]!==I||e[41]!==l?(E=s.jsxs(Ka,{children:[l,I]}),e[40]=I,e[41]=l,e[42]=E):E=e[42];let z;e[43]!==t||e[44]!==p||e[45]!==g||e[46]!==d||e[47]!==f||e[48]!==h?(z=t!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(In,{value:p,onChange:se=>d(se.target.value),placeholder:h(t==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:se=>{se.key==="Enter"&&f()},ref:g})}),e[43]=t,e[44]=p,e[45]=g,e[46]=d,e[47]=f,e[48]=h,e[49]=z):z=e[49];let _;e[50]!==h?(_=h("filesView.dialog.cancel"),e[50]=h,e[51]=_):_=e[51];let R;e[52]!==v||e[53]!==x||e[54]!==_?(R=s.jsx($,{variant:"outline",onClick:x,disabled:v,children:_}),e[52]=v,e[53]=x,e[54]=_,e[55]=R):R=e[55];const P=t==="delete"?"destructive":"default";let O;e[56]!==f?(O=()=>{f()},e[56]=f,e[57]=O):O=e[57];let K;e[58]!==t||e[59]!==p||e[60]!==v?(K=v||t!=="delete"&&!p.trim(),e[58]=t,e[59]=p,e[60]=v,e[61]=K):K=e[61];let Q;e[62]!==t||e[63]!==v||e[64]!==h?(Q=v?s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):h(t==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=t,e[63]=v,e[64]=h,e[65]=Q):Q=e[65];let ee;e[66]!==P||e[67]!==O||e[68]!==K||e[69]!==Q?(ee=s.jsx($,{variant:P,onClick:O,disabled:K,children:Q}),e[66]=P,e[67]=O,e[68]=K,e[69]=Q,e[70]=ee):ee=e[70];let ae;e[71]!==R||e[72]!==ee?(ae=s.jsxs(Xa,{children:[R,ee]}),e[71]=R,e[72]=ee,e[73]=ae):ae=e[73];let J;e[74]!==g||e[75]!==E||e[76]!==z||e[77]!==ae?(J=s.jsxs(Ha,{initialFocus:g,children:[E,z,ae]}),e[74]=g,e[75]=E,e[76]=z,e[77]=ae,e[78]=J):J=e[78];let Y;return e[79]!==w||e[80]!==F||e[81]!==J?(Y=s.jsx(Ua,{open:w,onOpenChange:F,children:J}),e[79]=w,e[80]=F,e[81]=J,e[82]=Y):Y=e[82],Y},pn=new Map,gd=100,Ba=r=>{const e=De.c(13);let t,a,p;e[0]!==r?({positionKey:a,onViewReady:t,...p}=r,e[0]=r,e[1]=t,e[2]=a,e[3]=p):(t=e[1],a=e[2],p=e[3]);const d=i.useRef(null);let v,f;e[4]!==a?(v=()=>()=>{const h=d.current;if(!h)return;const{anchor:w,head:F}=h.state.selection.main;if(pn.delete(a),pn.set(a,{scroll:h.scrollSnapshot(),anchor:w,head:F}),pn.size>gd){const C=pn.keys().next().value;C!==void 0&&pn.delete(C)}},f=[a],e[4]=a,e[5]=v,e[6]=f):(v=e[5],f=e[6]),i.useLayoutEffect(v,f);let x;e[7]!==t||e[8]!==a?(x=h=>{d.current=h;const w=pn.get(a);w&&h.dispatch({selection:{anchor:Math.min(w.anchor,h.state.doc.length),head:Math.min(w.head,h.state.doc.length)},effects:w.scroll}),t?.(h)},e[7]=t,e[8]=a,e[9]=x):x=e[9];let g;return e[10]!==p||e[11]!==x?(g=s.jsx(Mc,{...p,onViewReady:x}),e[10]=p,e[11]=x,e[12]=g):g=e[12],g},$a=(r,e,t)=>{const a=De.c(8),[p,d]=i.useState(""),[v,f]=i.useState(0);let x,g;a[0]!==r||a[1]!==t||a[2]!==e?(x=()=>{if(!r){d("");return}let w=!1;d("");const F=_l(),C=Wl(F);Ul(F).then(y=>{w||!y||(d(r),e(null))}).catch(y=>{w||(e(y instanceof Error?y.message:t),d(r))});const k=Hl(()=>{w||(d(r),f(vd),e(null))});return()=>{w=!0,C(),k()}},g=[r,e,t],a[0]=r,a[1]=t,a[2]=e,a[3]=x,a[4]=g):(x=a[3],g=a[4]),i.useEffect(x,g);let h;return a[5]!==v||a[6]!==p?(h={readyKey:p,nonce:v},a[5]=v,a[6]=p,a[7]=h):h=a[7],h},Om=({mode:r="full",visible:e=!0})=>{const{t}=nt(),{files:a,runtime:p}=ec(),{currentTheme:d,availableThemes:v,lightThemeId:f,darkThemeId:x}=tc(),{isMobile:g,isTablet:h,screenWidth:w}=_a(),F=Ll(p.platform),C=g||h,k=zl(),y=Al(),j=Wa()??"",l=te(j.trim()),S=g||r==="full",T=S&&e,V=nc(n=>n.runtimeKey),L=JSON.stringify([V,l]),I=i.useRef(L);I.current=L;const E=JSON.stringify([V,l,k,y]),z=i.useRef(E);z.current=E;const _=r!=="editor-only",R=r==="editor-only"&&!g,P=Il(n=>n.searchFiles),O=sc(T?j:null),[K,Q]=i.useState(""),ee=rc(K,200),ae=i.useRef(null),[J,Y]=i.useState(!1),[se,Le]=i.useState(!0),[A,ue]=i.useState(!1),xe=i.useCallback(n=>{if(!Hs.current){ue(n);return}const o=gt.current;if(yn.current){Hr.current?.().then(c=>{c&>.current===o&&ue(n)});return}Promise.resolve(Xt.current?.getContent("handoff")??Cr).then(c=>{if(gt.current===o){if(!c.ok){X.error(c.message);return}c.snapshot&&"content"in c.snapshot&&(Ce(c.snapshot.content),dt(!1)),ue(n)}})},[]),[ze,Fe]=i.useState(!1),$e=i.useRef(0),Re=i.useCallback(n=>{$e.current=Math.max(0,$e.current+(n?1:-1))},[]),[ne,de]=i.useState("edit"),[_e,G]=i.useState("edit"),[W,oe]=i.useState("tree"),[le,Se]=i.useState("edit"),[re,fe]=i.useState("preview"),[pe,be]=i.useState("preview"),[ge,pt]=i.useState("preview"),[ye,Ee]=i.useState("preview"),[st,me]=i.useState("table"),[We,$n]=i.useState(null),[ao,oo]=i.useState(0),[lo,_n]=i.useState(0),Wn=i.useRef({}),As=i.useRef({}),Is=i.useRef({}),Pr=i.useRef({}),Dr=i.useRef({}),Lr=i.useRef({}),Os=i.useRef({}),vn=i.useRef({}),Un=i.useMemo(()=>v.find(n=>n.metadata.id===f)??pa(!1),[v,f]),Hn=i.useMemo(()=>v.find(n=>n.metadata.id===x)??pa(!0),[v,x]);i.useEffect(()=>{ja(Un),ja(Hn)},[Un,Hn]);const Kn=i.useMemo(()=>[],[]),ke=tt(n=>l?n.byRoot[l]?.openPaths??Kn:Kn),Vt=tt(n=>l?n.byRoot[l]?.selectedPath??null:null),lt=tt(n=>l?n.byRoot[l]?.expandedPaths??Kn:Kn),co=i.useMemo(()=>new Set(lt),[lt]),Ht=tt(n=>n.removeOpenPath),St=tt(n=>n.removeOpenPathsByPrefix),zr=tt(n=>n.removeExpandedPathsByPrefix),Te=tt(n=>n.setSelectedPath),Ar=tt(n=>n.toggleExpandedPath),qn=tt(n=>n.expandPaths),Kt=i.useCallback(n=>{const o=te(n),c=o.split("/"),m=c[c.length-1]||o,b=m.includes(".")?m.split(".").pop()?.toLowerCase():void 0;return{name:m,path:o,type:"file",extension:b}},[]),qt=i.useMemo(()=>ke.map(Kt),[ke,Kt]),Bs=i.useMemo(()=>{if(Vt){const n=gn(Vt);if(ke.some(o=>gn(o)===n))return Vt}return ke[0]??null},[ke,Vt]),u=i.useMemo(()=>Bs?Kt(Bs):null,[Bs,Kt]),Ae=u?.path??"",gt=i.useRef(Ae);gt.current=Ae,i.useEffect(()=>{if(!l||!Vt)return;const n=gn(Vt);ke.some(c=>gn(c)===n)||Te(l,ke[0]??null)},[ke,l,Vt,Te]);const Gn=!!(l&&Ae&&!An(Ae,l)),$s=i.useMemo(()=>({allowOutsideWorkspace:Gn,directory:l||void 0}),[Gn,l]),ct=i.useCallback(n=>({allowOutsideWorkspace:!!(l&&!An(n,l))}),[l]),_s=i.useRef(null),[Ir,uo]=i.useState({left:!1,right:!1}),Or=i.useCallback(()=>{const n=_s.current;n&&uo({left:n.scrollLeft>2,right:n.scrollLeft+n.clientWidth<n.scrollWidth-2})},[]),Br=i.useRef(Or);Br.current=Or,i.useEffect(()=>{const n=_s.current;if(!n)return;const o=()=>Br.current();o(),n.addEventListener("scroll",o,{passive:!0});const c=new ResizeObserver(o);return c.observe(n),()=>{n.removeEventListener("scroll",o),c.disconnect()}},[qt.length]);const[$r,Ws]=i.useState({}),[Xn,xn]=i.useState({}),Xe=i.useRef(new Set),Ie=i.useMemo(()=>new Wc,[]);i.useEffect(()=>()=>Ie.clear(),[Ie]);const[_r,Yn]=i.useState([]),[fo,Jn]=i.useState(!1),[U,je]=i.useState(""),{isPlaying:Zn,play:mo,stop:ho}=ic(),[Me,Nt]=i.useState(!1),[rt,Ne]=i.useState(null),[po,Ye]=i.useState(""),[ce,ve]=i.useState(null),Ft=JSON.stringify([ot(),l,ce]),[ie,Ce]=i.useState(""),[Gt,Us]=i.useState(!1),[Wr,go]=i.useState(`
|
|
13
|
+
`),vo=i.useRef(null),ut=i.useRef(null),Ue=i.useRef(null),Rt=i.useRef(""),wn=i.useRef(""),vt=i.useRef(null),Pt=i.useRef(null),Ur=i.useRef(null),Xt=i.useRef(null),[bn,dt]=i.useState(!1),Hs=i.useRef(!1);Hs.current=bn;const yn=i.useRef(!1),Hr=i.useRef(null),Je=i.useRef(null),Ks=i.useRef(""),qs=i.useRef(0),Yt=i.useRef(0),Dt=i.useRef(null),[jn,xo]=i.useState(0),[wo,Jt]=i.useState("idle"),[bo,Qn]=i.useState(!1),[yo,Kr]=i.useState(!1),[Lt,qr]=i.useState(!1),Ve=ht(n=>n.autoSaveEnabled),jo=ht(n=>n.setAutoSaveEnabled),[Gs,Cn]=i.useState(!1),Zt=i.useRef(null),Sn=i.useRef(null),Nn=i.useRef(!1),Fn=i.useRef(null),Rn=i.useRef(null),Ze=i.useRef(null),es=i.useRef(null),Gr=i.useRef(null),Xr=i.useRef(0),[Co,Xs]=i.useState(0),Qt=i.useRef(null),zt=i.useRef({key:"",attempts:0});i.useEffect(()=>()=>{Qt.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(Qt.current),Qt.current=null)},[]);const[At,Ys]=i.useState(null),[It,So]=i.useState(null),[Et,Yr]=i.useState(""),[No,Js]=i.useState(!1),[Fo,Ro]=i.useState(null),[Eo,ko]=i.useState(null),[To,Jr]=i.useState(!1),[Mo,Zr]=i.useState(!1),[Vo,Zs]=i.useState(!1),[Qr,ts]=i.useState(!1),[ei,ti]=i.useState(0),ns=i.useRef(null),ss=i.useCallback(n=>{const o=n?.currentTarget??ns.current;if(!o)return;const c=document.activeElement;c&&c!==document.body&&c!==o&&(ac(c)||o.contains(c))||o.focus({preventScroll:!0})},[]),rs=i.useRef(null),ni=!!a.writeFile,si=!!a.createDirectory,ri=!!a.rename,ii=!!a.delete,ai=!!a.revealPath,Po=Fs(n=>n.availableApps),Do=Fs(n=>n.isCacheStale),oi=Fs(n=>n.initialize),Lo=Fs(n=>n.loadInstalledApps);i.useEffect(()=>{oi()},[oi]);const zo=i.useCallback(n=>{a.revealPath&&a.revealPath(n).catch(()=>{X.error(t("sidebarFilesTree.toast.revealFailed"))})},[a,t]),Ao=i.useCallback(async n=>{if(!u?.path||await Ol(u.path,n.id,n.appName)||await fa(u.path,n.appName))return;const m=rd(u.path)||l;m&&await fa(m,n.appName)||X.error(t("filesView.toast.openInAppFailed",{app:n.appName}))},[l,u?.path,t]),Qs=i.useCallback((n,o)=>{Ys(n),So(o),Yr(n==="rename"&&o.name||""),Js(!1)},[]),[Z,it]=i.useState(null),en=i.useRef(!1),kt=i.useRef(null),[li,tn]=i.useState(!1),ft=ht(n=>n.pendingFileNavigation),is=ht(n=>n.setPendingFileNavigation),er=ht(n=>n.pendingFileFocusPath),tr=ht(n=>n.setPendingFileFocusPath),ci=ht(n=>n.fileEditorKeymap),En=ga(n=>n.settingsDefaultFileViewerPreview),Io=ga(n=>n.showMessageTTSButtons);i.useEffect(()=>{const n=()=>{en.current=!1,kt.current=null,tn(!1)};return document.addEventListener("mouseup",n),()=>document.removeEventListener("mouseup",n)},[]),i.useEffect(()=>()=>{Fn.current!==null&&window.clearTimeout(Fn.current),Rn.current!==null&&window.clearTimeout(Rn.current)},[]);const Oo=i.useCallback((n,o)=>{const c=n.split(`
|
|
14
|
+
`),m=Math.max(1,o.start),b=Math.min(c.length,o.end);return m>b?"":c.slice(m-1,b).join(`
|
|
15
|
+
`)},[]),ui=i.useRef(null),Bo=Gc({source:"file",fileLabel:u?.path??null,language:u?.path&&vr(u.path)||"text",getCodeForRange:n=>Oo(U,Xc(n)),toStoreRange:n=>({startLine:n.start,endLine:n.end}),fromDraftRange:n=>({start:n.startLine,end:n.endLine})}),{drafts:di,commentText:as,setCommentText:fi,editingDraftId:os,setSelection:mi,saveComment:hi,cancel:kn,reset:pi,startEdit:gi,deleteDraft:vi}=Bo;i.useEffect(()=>{it(null),pi(),Ce(""),Us(!1)},[u?.path,pi]),i.useEffect(()=>{mi(Z)},[Z,mi]),i.useEffect(()=>{if(!Z&&!os)return;const n=c=>{const m=c.target;m.closest('[data-comment-input="true"]')||m.closest('[data-comment-card="true"]')||m.closest(".cm-gutterElement")||m.closest("[data-sonner-toast]")||m.closest("[data-sonner-toaster]")||as.trim()||(it(null),kn())},o=setTimeout(()=>{document.addEventListener("click",n)},100);return()=>{clearTimeout(o),document.removeEventListener("click",n)}},[kn,as,os,Z]),i.useEffect(()=>{if(!g||!Z)return;const n=Ze.current;if(!n)return;const o=n.state.selection.main;o.empty||n.dispatch({selection:{anchor:o.head}});const c=document.getSelection();c&&!c.isCollapsed&&c.anchorNode&&n.contentDOM.contains(c.anchorNode)&&c.removeAllRanges()},[g,Z]);const xi=i.useCallback((n,o)=>{const c=o??Z??void 0;o&&it(o),hi(n,c),it(null)},[Z,hi]),wi=i.useCallback((n,o)=>{const c=[];for(const m of o){if(!(m&&typeof m.name=="string"&&m.name.length>0)||!k&&m.name.startsWith(".")||!y&&ud(m.name))continue;const b=m.name,N=te(m.path||""),D=N?od(N)?N:te(`${n}/${N}`):te(`${n}/${b}`),H=m.isDirectory?"directory":"file",we=H==="file"&&b.includes(".")?b.split(".").pop()?.toLowerCase():void 0;c.push({name:b,path:D,type:H,extension:we})}return ad(c)},[y,k]),Oe=i.useCallback(async(n,o=!1)=>{if(!T)return;const c=te(n.trim());if(!c||!o&&Xe.current.has(c))return;const m=z.current,b=ot();return Ie.run(c,async N=>{const D=()=>N()&&z.current===m&&ot()===b;try{const H=a.listDirectory?(await a.listDirectory(c)).entries:await Bl.listLocalDirectory(c);if(!D())return;const we=wi(c,H);Xe.current=new Set(Xe.current),Xe.current.add(c),xn(B=>{if(!B[c])return B;const he={...B};return delete he[c],he}),Ws(B=>B[c]&&Uc(B[c],we)?B:{...B,[c]:we})}catch(H){if(!D())return;const we=H instanceof Error?H.message:String(H??"");if(we==="Directory not found"&&l&&c!==l){zr(l,c),xn(B=>{if(!B[c])return B;const he={...B};return delete he[c],he});return}console.error("Failed to load files directory:",H),xn(B=>({...B,[c]:we}))}},o)},[Ie,a,wi,zr,l,T]),ls=i.useCallback(async()=>{l&&(Xe.current=new Set,Ie.clear(),xn({}),Ws(n=>Object.keys(n).length===0?n:{}),await Oe(l))},[Ie,Oe,l]),He=i.useCallback(async n=>{if(!n){await ls();return}const o=te(n);Xe.current=new Set(Xe.current),Xe.current.delete(o),await Oe(o,!0)},[Oe,ls]),{canUpload:bi,uploadingDirectory:$o,pickFiles:yi,uploadElements:_o}=jc({root:l,refreshDirectory:He}),cs=$o!==null,ji=i.useRef(""),Ci=i.useRef("");i.useEffect(()=>{if(!l)return;const n=E,o=ji.current!==L,c=Ci.current!==n;!o&&!c||(o&&(ji.current=L,Yt.current+=1,Dt.current=null,je(""),Ne(null),Ye(""),ve(null),Y(!1)),c&&(Ci.current=n,Xe.current=new Set,Ie.clear(),xn({}),Ws(m=>Object.keys(m).length===0?m:{}),Oe(l)))},[Ie,L,Oe,l,E]),i.useEffect(()=>{if(!T||!a.listDirectory)return;const n=()=>{if(!document.hidden&<.length>0)for(const o of lt)Ie.has(o)||He(o)};return document.addEventListener("visibilitychange",n),()=>document.removeEventListener("visibilitychange",n)},[Ie,lt,a.listDirectory,He,T]);const Si=i.useRef(!1);i.useEffect(()=>{const n=T&&!Si.current;if(Si.current=T,!(!T||!l)&&(Oe(l),n))for(const o of lt)Ie.has(o)||He(o)},[Ie,lt,Oe,He,l,T]),i.useEffect(()=>{if(!T||!a.listDirectory||lt.length===0)return;const n=setInterval(()=>{if(!document.hidden)for(const o of lt)Ie.has(o)||He(o)},8e3);return()=>clearInterval(n)},[Ie,lt,a.listDirectory,He,T]);const Wo=i.useCallback(async n=>{if(n?.preventDefault(),!It||!At)return;Js(!0);const o=()=>{Ys(null)},c=b=>{X.error(b)},m=()=>{Js(!1)};if(At==="createFile"){if(!Et.trim()){c(t("sidebarFilesTree.toast.filenameRequired")),m();return}if(!a.writeFile){c(t("sidebarFilesTree.toast.writeNotSupported")),m();return}const b=It.path,N=b?`${b}/`:"",D=te(`${N}${Et.trim()}`);await a.writeFile(D,"").then(async H=>{H.success&&(X.success(t("sidebarFilesTree.toast.fileCreated")),await He(b)),o()}).catch(()=>c(t("sidebarFilesTree.toast.operationFailed"))).finally(m);return}if(At==="createFolder"){if(!Et.trim()){c(t("sidebarFilesTree.toast.folderNameRequired")),m();return}const b=It.path,N=b?`${b}/`:"",D=te(`${N}${Et.trim()}`);await a.createDirectory(D).then(async H=>{H.success&&(X.success(t("sidebarFilesTree.toast.folderCreated")),await He(b)),o()}).catch(()=>c(t("sidebarFilesTree.toast.operationFailed"))).finally(m);return}if(At==="rename"){if(!Et.trim()){c(t("sidebarFilesTree.toast.nameRequired")),m();return}if(!a.rename){c(t("sidebarFilesTree.toast.renameNotSupported")),m();return}const b=It.path,N=b.split("/").slice(0,-1).join("/"),D=N?`${N}/`:"",H=te(`${D}${Et.trim()}`);await a.rename(b,H).then(async we=>{we.success&&(X.success(t("sidebarFilesTree.toast.renamedSuccessfully")),await He(N),l&&St(l,b),(u?.path===b||u?.path.startsWith(`${b}/`))&&(l&&Te(l,null),je(""),Ne(null),Ye(""),ve(null),g&&Y(!1))),o()}).catch(()=>c(t("sidebarFilesTree.toast.operationFailed"))).finally(m);return}if(At==="delete"){if(!a.delete){c(t("sidebarFilesTree.toast.deleteNotSupported")),m();return}const b=It.path,N=b.split("/").slice(0,-1).join("/");await a.delete(b).then(async D=>{D.success&&(X.success(t("sidebarFilesTree.toast.deletedSuccessfully")),await He(N),l&&St(l,b),(u?.path===b||u?.path.startsWith(`${b}/`))&&(l&&Te(l,null),je(""),Ne(null),Ye(""),ve(null),g&&Y(!1))),o()}).catch(()=>c(t("sidebarFilesTree.toast.operationFailed"))).finally(m);return}m()},[At,It,Et,a,He,g,St,l,u?.path,Te,t]);i.useEffect(()=>{if(!j){Yn([]),Jn(!1);return}const n=ee.trim();if(!n){Yn([]),Jn(!1);return}let o=!1;return Jn(!0),P(j,n,150,{includeHidden:k,respectGitignore:!y,type:"file"}).then(c=>{if(o)return;const b=c.filter(N=>y||!dd(N.path)).map(N=>({name:N.name,path:te(N.path),type:"file",extension:N.extension,relativePath:N.relativePath}));Yn(b)}).catch(()=>{o||Yn([])}).finally(()=>{o||Jn(!1)}),()=>{o=!0}},[j,ee,P,k,y]);const us=i.useCallback(async(n,o)=>{const c=ct(n);if(a.readFile)return(await a.readFile(n,{...c,directory:l||void 0,...o})).content??"";const m=new URLSearchParams({path:n});c.allowOutsideWorkspace&&m.set("allowOutsideWorkspace","true"),l&&m.set("directory",l);const b=await Ms(`/api/fs/read?${m.toString()}`,{cache:o?.fresh?"no-store":"default",signal:AbortSignal.timeout(3e4)});if(!b.ok){const N=await b.json().catch(()=>({error:b.statusText}));throw new Error(N.error||t("filesView.error.readFileFailed"))}return b.text()},[a,ct,l,t]),mt=i.useCallback(async n=>{if(a.statFile){const o=ct(n),c=await a.statFile(n,{...o,directory:l||void 0});return{path:c.path,size:c.size,mtimeMs:c.mtimeMs}}return null},[a,ct,l]);i.useEffect(()=>{if(!l||!a.statFile||ke.length===0)return;let n=!1;const o=[...ke];return Promise.all(o.map(async c=>{try{const m=ct(c),b=await a.statFile?.(c,{...m,directory:l||void 0});!n&&b&&!b.isFile&&St(l,c)}catch(m){!n&&Ia(m)&&St(l,c)}})),()=>{n=!0}},[a,ke,St,ct,l]);const Ke=ie!==U||bn,Tt=i.useCallback((n,o=!0)=>{const{content:c,lineEnding:m}=ju(n);return o&&Rr(gt.current)&&_n(b=>b+1),Ks.current=n,qs.current+=1,go(m),je(c),Rt.current=c,wn.current=c,Ce(c),c},[]),xt=i.useCallback(async()=>{if(!u||!a.writeFile)return X.error(t("filesView.toast.savingNotSupported")),!1;const n=(Dn(u.path)||Lt)&&!yn.current;if(!bu({selectedFilePath:u.path,loadedFilePath:ce,fileLoading:Me,isDirty:Ke,draftContent:ie,fileContent:U,isNonEditableBinary:n}))return n?console.warn(`[saveDraft] refusing to save binary file "${u.path}".`):ie===""&&U!==""&&ce!==u.path&&console.warn(`[saveDraft] refusing to save empty draft for "${u.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(!Ke)return!0;Us(!0);try{const o=bn?Xt.current:null;bn&&!o&&dt(!1);const c=o?await o.getContent("save"):Cr;if(!c.ok)return X.error(c.message),!1;const m=c.snapshot;if(m&&"bytes"in m){if(!a.uploadFile)return X.error(t("filesView.toast.savingNotSupported")),!1;if(Je.current=null,!(await a.uploadFile(u.path,new Blob([m.bytes]),{overwrite:!0}))?.success)return X.error(t("filesView.toast.writeFileFailed")),!1;Xt.current?.markSaved(m.signature)}else{const b=Cu(m?m.content:ie,Wr);if(!(await a.writeFile(u.path,b))?.success)return X.error(t("filesView.toast.writeFileFailed")),!1;m?(Tt(b,!1),Xt.current?.markSaved(m.signature)):(je(ie),Ks.current=b,qs.current+=1)}if(l&&An(u.path,l)){const b=Ps(l,u.path);b&&oc.requestGitRefresh({directory:l,paths:[b]})}if(l&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(te(u.path))){const b=lc.getState().projects.find(N=>te(N.path)===te(l));if(b)try{await Hc(b.id)}catch{X.error(t("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return u?.path&&Ln(u.path)&&(Rt.current=ie,wn.current=ie),mt(u.path).then(b=>{b&&(Je.current=b)}).catch(()=>{}),!0}catch(o){return X.error(o instanceof Error?o.message:t("filesView.toast.saveFailed")),!1}finally{Us(!1)}},[Tt,Lt,ie,bn,U,Me,a,Ke,Wr,ce,mt,l,u,t]);Hr.current=xt,i.useEffect(()=>{Ve||(Jt("idle"),ut.current&&(clearTimeout(ut.current),ut.current=null))},[Ve]);const ds=1500;i.useEffect(()=>{const n=!!(u&&a.writeFile),o=!!(u?.path&&(Dn(u.path)||Lt))&&!yn.current;if(!wu({autoSaveEnabled:Ve,isDirty:Ke,canWrite:n,isSaving:Gt,fileLoading:Me,selectedFilePath:u?.path,loadedFilePath:ce,isNonEditableBinary:o}))return;const c=m=>{ut.current=setTimeout(()=>{const b=Date.now()-Xr.current;if(b<ds){c(ds-b);return}xt().then(N=>{N&&(Jt("saved"),setTimeout(()=>Jt("idle"),2e3))})},m)};return c(ds),()=>{ut.current&&(clearTimeout(ut.current),ut.current=null)}},[Ve,Lt,ie,Me,Ke,ce,u,a.writeFile,Gt,xt]),i.useEffect(()=>{Jt("idle")},[u?.path]);const Ni=i.useCallback(()=>{ut.current&&(clearTimeout(ut.current),ut.current=null),Gt||xt().then(n=>{n&&(Jt("saved"),setTimeout(()=>Jt("idle"),2e3))})},[Gt,xt]);cc({save_file:n=>{if(!(n.target instanceof Node)||!es.current?.contains(n.target)&&!Gr.current?.contains(n.target))return!1;Ni()},find_in_file:n=>{if(!(n.target instanceof Node))return!1;if(et&&Ge()==="preview"){if(g||!(A?rs.current:ns.current)?.contains(n.target))return!1;ts(!0),ti(c=>c+1);return}if(!es.current?.contains(n.target))return!1;Fe(!0)}});const Fi=i.useCallback(async n=>{const o=Yt.current+1;Yt.current=o;const c=ot(),m=I.current,b=()=>{if(!l||ot()!==c||I.current!==m)return!1;const B=tt.getState().byRoot[l],he=B?.selectedPath??B?.openPaths[0]??null;return Yt.current===o&&he===n.path};Ne(null),Ye(""),ve(null),qr(!1),Nt(!0);const N=xr(n.path),D=wr(n.path),H=va(n.path),we=Dn(n.path);if(g&&Y(!0),p.isDesktop&&N&&!D){je(""),Ce("");return}if(!p.isDesktop&&N&&!D){je(""),Ce(""),ve(n.path),Nt(!1);return}if(H){je(""),Ce(""),ve(n.path),Nt(!1);return}if(we){je(""),Ce(""),ve(n.path),Nt(!1);return}await us(n.path).then(B=>{if(!b())return;if(xa(B)){qr(!0),je(""),Ce(""),ve(n.path);return}const he=Tt(B),Ot=Fr(n.path)||ks(n.path)||Oa(n.path)||Ln(n.path)||wr(n.path)||wa(n.path)||ba(n.path)||Rr(n.path);de(Ot?"edit":Su(he,Wn.current[n.path])),ve(n.path),mt(n.path).then(dn=>{dn&&b()&&(Je.current=dn)}).catch(()=>{})}).catch(B=>{if(b()){if(fd(B)){if(Nt(!1),l&&Te(l,null),Ne(null),je(""),Ce(""),ve(null),Je.current=null,K.trim().length>0&&Q(""),g&&Y(!1),l){const Ot=[...za(n.path,l),n.path];Ot.length>0&&qn(l,Ot);for(const dn of Ot)Xe.current.has(dn)||Oe(dn)}return}if(Ia(B)){l&&St(l,n.path),je(""),Ce(""),Ne(null),Je.current=null,g&&Y(!1);return}je(""),Ce(""),Ne(B instanceof Error?B.message:t("filesView.error.readFileFailed")),Je.current=null}}).finally(()=>{b()&&Nt(!1)})},[Tt,qn,g,Oe,us,mt,St,l,p.isDesktop,K,Te,t]),fs=i.useCallback(async(n,o)=>{if(!e||!l)return;const c=za(n,l),m=o?[...c,n]:c;if(m.length>0&&qn(l,m),!T)return;const b=m.map(N=>{if(!Xe.current.has(N))return Oe(N)}).filter(Boolean);await Promise.all(b)},[qn,Oe,l,T,e]),Ri=i.useCallback((n,o)=>{const c=o.findIndex(m=>m.path===n);return c===-1||o.length<=1?null:o[c+1]??o[c-1]??null},[]),Be=i.useCallback(async n=>{if(Nn.current)Nn.current=!1;else if(Ke){Cn(!0),Zt.current=n;return}l&&(Te(l,n.path),fs(n.path,!1)),Ne(null),Ye(""),je(""),Rt.current="",wn.current="",dt(!1),Ce(""),ve(null),g&&Y(!0)},[fs,Ke,g,l,Te]);i.useEffect(()=>{u?.path&&fs(u.path,!1)},[fs,u?.path]),i.useEffect(()=>{if(!e)return;if(!u){Yt.current+=1,Dt.current=null,Nt(!1);return}if(ce===u.path||Dt.current===u.path)return;const n=u.path;Dt.current=n,Fi(u).finally(()=>{Dt.current===n&&(Dt.current=null)})},[jn,Fi,ce,u,e]);const ms=i.useRef(Ke);ms.current=Ke,i.useEffect(()=>Cc(({runtimeKey:n,paths:o})=>{const c=u?.path;n!==ot()||!c||ms.current||!o.includes(te(c))||(Yt.current+=1,Dt.current=null,Je.current=null,Ye(""),Ne(null),ve(null),xo(m=>m+1))}),[u?.path]),i.useEffect(()=>{if(!e||!u?.path||ce!==u.path)return;const n=u.path,o=ot(),c=I.current,m=()=>ms.current||Ln(n)&&Rt.current!==wn.current,b=!Dn(n)&&!xr(n)&&!Lt?hu({readContent:()=>us(n,{fresh:!0}),getLoadedContent:()=>Ks.current,getLoadedRevision:()=>qs.current,isDirty:m,applyContent:B=>{if(!(N||ot()!==o||I.current!==c)){if(xa(B)){ve(null);return}Tt(B)}}}):null;let N=!1,D=!1;const H=()=>{document.hidden||D||(D=!0,mt(n).then(async B=>{if(N||ot()!==o||I.current!==c||!B)return;const he=Je.current;if(!he||he.path!==n){Je.current=B;return}if(gu(he,B)){if(b&&B.size<=md){await b.poll()&&!N&&(Je.current=B);return}ms.current||(Je.current=B,ve(null))}}).catch(()=>{}).finally(()=>{D=!1}))};H();const we=window.setInterval(H,2e3);return()=>{N=!0,b?.dispose(),window.clearInterval(we)}},[Tt,Lt,ce,us,mt,u?.path,e]);const Uo=i.useCallback(()=>{const n=Zt.current,o=Sn.current;if(Zt.current=null,Sn.current=null,Nn.current=!0,Cn(!1),dt(!1),_n(c=>c+1),Ce(U),o){l&&Ht(l,o),u?.path===o&&(n?Be(n):(l&&Te(l,null),je(""),Ne(null),Ye(""),ve(null),g&&Y(!1)));return}if(n){Be(n);return}},[U,Be,g,Ht,l,u?.path,Te]),Ho=i.useCallback(async()=>{const n=Zt.current,o=Sn.current;if(!await xt()){Nn.current=!1;return}if(Zt.current=null,Sn.current=null,Nn.current=!0,Cn(!1),o){l&&Ht(l,o),u?.path===o&&(n?await Be(n):(l&&Te(l,null),je(""),Ne(null),Ye(""),ve(null),g&&Y(!1)));return}if(n){await Be(n);return}},[Be,g,Ht,l,xt,u?.path,Te]),Ei=i.useCallback(n=>{const o=u?.path===n,c=Ri(n,qt);if(o&&Ke){Cn(!0),Zt.current=c,Sn.current=n;return}if(l&&Ht(l,n),!!o){if(c){Be(c);return}l&&Te(l,null),je(""),Ne(null),Ye(""),ve(null),g&&Y(!1)}},[Ri,Be,Ke,g,qt,Ht,l,u?.path,Te]),ki=i.useMemo(()=>new Set(ke),[ke]),hs=i.useMemo(()=>Kc(S?O?.files??[]:[]),[O?.files,S]),Ko=i.useCallback(n=>{if(ki.has(n))return"open";const o=n.startsWith(l+"/")?n.slice(l.length+1):n;return hs.statusByPath.get(o)??null},[ki,hs,l]),qo=i.useCallback(n=>{if(!O?.files)return null;const o=n.startsWith(l+"/")?n.slice(l.length+1):n;return hs.badgeByDir.get(o)??null},[O,hs,l]),Go=i.useCallback(async n=>{const o=te(n);l&&(Ar(l,o),Xe.current.has(o)||await Oe(o))},[Oe,l,Ar]),Xo=i.useMemo(()=>({canRename:ri,canCreateFile:ni,canCreateFolder:si,canDelete:ii,canReveal:ai}),[ri,ni,si,ii,ai]);function Ti(n,o){const c=$r[n]??[];return c.map((m,b)=>{const N=m.type==="directory",D=N&&co.has(m.path),H=u?.path===m.path,we=b===c.length-1;return s.jsxs("li",{className:"relative",children:[o>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),we&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),s.jsx(hd,{node:m,root:l,isExpanded:D,isActive:H,isMobile:g,isBrowserClient:F,alwaysShowActions:C,status:N?void 0:Ko(m.path),badge:N?qo(m.path):void 0,permissions:Xo,downloadFile:a.downloadFile,contextMenuPath:Fo,setContextMenuPath:Ro,rightClickMenuPath:Eo,setRightClickMenuPath:ko,onSelect:Be,onToggle:Go,onRevealPath:zo,onOpenDialog:Qs,canUpload:bi&&!cs,onPickFiles:yi}),N&&D&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[Xn[m.path]?s.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:Xn[m.path],children:Xn[m.path]}),s.jsxs($,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{He(m.path)},children:[s.jsx(M,{name:"refresh",className:"size-3.5"}),t("filesView.tree.actions.refreshTitle")]})]}):null,Ti(m.path,o+1)]})]},m.path)})}const qe=!!(u?.path&&xr(u.path)),Qe=!!(u?.path&&wr(u.path)),Mi=Qe&&ge==="edit",Mt=!!(u?.path&&va(u.path)),Vi=!!(u?.path&&uc(u.path)),nr=Vi||!!(u?.path&&dc(u.path)),sr=!!(u?.path&&fc(u.path)),ps=!!(u?.path&&(Dn(u.path)||Lt)),nn=ps&&!qe&&!Mt&&!nr&&!sr,Pi=ps||qe&&!Mi,Di=i.useMemo(()=>te(ft?.path??""),[ft?.path]),sn=!!(ft&&Di&&Ae&&Ae===Di&&!Me&&!rt&&!Pi),wt=i.useMemo(()=>Ps(l,Ae),[Ae,l]),Yo=!!(u&&(!qe||Qe)&&!Mt&&!nn&&U.length>0),Jo=!!(u&&wt.length>0),at=!!(u&&!Gn&&!ps&&(!qe||Qe)&&a.writeFile),rr=!!(u&&!ps&&(!qe||Qe)),ir=Mu(u?.path),Pe=ir&&(rr||ir.editor.content==="binary")?ir:null,bt=Pe!==null,Tn=Pe?.editor.content==="binary";yn.current=Tn;const et=!bt&&!!(u?.path&&Fr(u.path)),rn=!bt&&!!(u?.path&&Oa(u.path)),an=!bt&&!!(u?.path&&ks(u.path)),Mn=!bt&&!!(u?.path&&Ln(u.path)),on=!bt&&!!(u?.path&&wa(u.path)),ln=!bt&&!!(u?.path&&ba(u.path)),cn=bt,Vn=bt&&(Tn?We===null||We<=Er:ie.length<=Er),Zo=Vr(n=>n.status),Qo=!bt&&rr&&Zo!=="unsupported"&&!!(u?.path&&mc(u.path)),gs=rr&&!et&&!Mn&&!cn&&!(an&&le==="preview")&&!(Qe&&ge==="preview")&&!(on&&ye==="preview")&&!(ln&&st==="table"),el=et&&_e==="edit"||an&&le==="edit"||cn&&(pe==="edit"||!Vn)||Qe&&ge==="edit"||on&&ye==="edit"||ln&&st==="text"||rn&&W==="text"||!et&&!an&&!rn&&!cn&&!Qe&&!on&&!ln&&ne==="edit",vs=i.useMemo(()=>Ae?hc(Ae):null,[Ae]),[Li,ar]=i.useState(null);i.useEffect(()=>{let n=!1;const o=u?.path;if(!o||vs){ar(null);return}return ar(null),pc(o).then(c=>{n||ar(c)}),()=>{n=!0}},[u?.path,vs]),i.useEffect(()=>{!at&&ne==="edit"&&de("view")},[at,ne]);const or="openchamber:files:md-viewer-mode",lr="openchamber:files:html-viewer-mode",cr="openchamber:files:json-viewer-mode";i.useEffect(()=>{const n=u?.path;if(!n)return;de(Wn.current[n]??"edit");let o=En?"preview":"edit";try{const b=localStorage.getItem(or);(b==="preview"||b==="edit")&&(o=b)}catch{}G(As.current[n]??o);let c=En?"preview":"edit";try{const b=localStorage.getItem(lr);(b==="preview"||b==="edit")&&(c=b)}catch{}Se(Is.current[n]??c),fe(Os.current[n]??(En?"preview":"edit")),be(vn.current[n]??"preview"),pt(Pr.current[n]??"preview"),Ee(Dr.current[n]??"preview"),me(Lr.current[n]??"table");let m=En?"tree":"text";try{const b=localStorage.getItem(cr);(b==="tree"||b==="text")&&(m=b)}catch{}oe(m)},[u?.path,En]);const tl=i.useCallback(n=>{const o=u?.path;o&&(Wn.current[o]=n),de(n)},[u?.path]),nl=i.useCallback(n=>{const o=u?.path;o&&(As.current[o]=n),G(n);try{localStorage.setItem(or,n)}catch{}},[u?.path]),Ge=i.useCallback(()=>_e,[_e]),sl=i.useCallback(n=>{const o=u?.path;o&&(Pr.current[o]=n),pt(n)},[u?.path]),rl=i.useCallback(n=>{const o=u?.path;o&&(Dr.current[o]=n),Ee(n)},[u?.path]),il=i.useCallback(n=>{const o=u?.path;o&&(Lr.current[o]=n),me(n)},[u?.path]);i.useEffect(()=>{const n=u?.path;if($n(null),!n||ce!==n)return;let o=!1;return mt(n).then(c=>{!o&&c&&$n(c.size)}).catch(()=>{}),()=>{o=!0}},[jn,ce,mt,u?.path]);const zi=u&&et&&Ge()==="preview"&&!Me?u.path:null;i.useEffect(()=>{!zi||g||ss()},[ss,A,g,zi]);const al=i.useCallback(n=>{oe(n);try{localStorage.setItem(cr,n)}catch{}},[]),ol=i.useCallback(n=>{const o=u?.path;o&&(Is.current[o]=n),Se(n);try{localStorage.setItem(lr,n)}catch{}},[u?.path]),ll=i.useCallback(n=>{const o=u?.path;if(o&&(Os.current[o]=n),Ue.current&&(clearTimeout(Ue.current),Ue.current=null),vt.current!==null&&(cancelAnimationFrame(vt.current),vt.current=null),n==="edit")Ce(Rt.current||U),fe(n);else{Rt.current=ie;const c=o;fe("edit"),vt.current=requestAnimationFrame(()=>{vt.current=requestAnimationFrame(()=>{vt.current=null,!(l&&c&&tt.getState().byRoot[l]?.selectedPath!==c)&&(oo(m=>m+1),fe("preview"))})});return}},[ie,U,l,u?.path]),cl=i.useCallback(n=>{const o=u?.path,c=()=>{o&&(vn.current[o]=n)};if(n==="edit"){if(!Hs.current){c(),dt(!1),be(n);return}Promise.resolve(Xt.current?.getContent("handoff")??Cr).then(b=>{if(gt.current===o){if(!b.ok){X.error(b.message);return}c(),Ce(b.snapshot&&"content"in b.snapshot?b.snapshot.content:U),dt(!1),be(n)}});return}if(!Vn){Pe&&X.error(t("filesView.fileEditor.tooLarge",{editor:Pe.editor.title}));return}c(),dt(!1);const m=o;Pt.current!==null&&cancelAnimationFrame(Pt.current),Pt.current=requestAnimationFrame(()=>{Pt.current=null,!(l&&m&&tt.getState().byRoot[l]?.selectedPath!==m)&&(_n(b=>b+1),be("preview"))})},[Vn,U,Pe,l,u?.path,t]),ur=i.useCallback(async(n,o)=>{if(!a.writeFile||o===wn.current)return!1;if(!(await a.writeFile(n,o))?.success)return X.error(t("filesView.toast.writeFileFailed")),!1;Tt(o);const m=await mt(n).catch(()=>null);return m&&(Je.current=m),!0},[Tt,a,mt,t]);i.useEffect(()=>()=>{Ue.current&&(clearTimeout(Ue.current),Ue.current=null),vt.current!==null&&(cancelAnimationFrame(vt.current),vt.current=null)},[re,u?.path]);const ul=i.useCallback(n=>{if(Rt.current=n,!Ve||!u?.path||re!=="preview"||!a.writeFile)return;Ue.current&&clearTimeout(Ue.current);const o=u.path;Ue.current=setTimeout(()=>{Ue.current=null,ur(o,n).then(c=>{c&&(Qn(!0),setTimeout(()=>Qn(!1),1500))}).catch(c=>{X.error(c instanceof Error?c.message:t("filesView.toast.saveFailed"))})},ds)},[Ve,re,a.writeFile,ur,u?.path,t]),dl=i.useMemo(()=>Mn&&(Rt.current||ie)||U,[ie,U,Mn]),fl=i.useCallback(()=>{const n=gt.current;n&&(vn.current[n]="edit"),dt(!1),be("edit"),Pe&&X.error(t("filesView.fileEditor.unsupported",{editor:Pe.editor.title}))},[Pe,t]);i.useEffect(()=>()=>{Pt.current!==null&&(cancelAnimationFrame(Pt.current),Pt.current=null)},[pe,u?.path]);const Ai=i.useCallback(()=>le,[le]);i.useEffect(()=>{const n=c=>{const m=c?"preview":"edit",b=c?"tree":"text";for(const N of ke)Wn.current[N]="edit",Fr(N)&&(As.current[N]=m),ks(N)&&(Is.current[N]=m),Ln(N)&&(Os.current[N]=m),Rr(N)&&(vn.current[N]=m);de("edit"),G(m),Se(m),fe(m),be(m),oe(b);try{localStorage.setItem(or,m),localStorage.setItem(lr,m),localStorage.setItem(cr,b)}catch{}},o=c=>{const m=!!c.detail?.enabled;n(m)};return window.addEventListener("openchamber:file-viewer-preview-mode-changed",o),()=>{window.removeEventListener("openchamber:file-viewer-preview-mode-changed",o)}},[ke]),i.useEffect(()=>{if(!ft||!l)return;const n=()=>{typeof window>"u"||Qt.current===null&&(Qt.current=window.requestAnimationFrame(()=>{Qt.current=null,Xs(jt=>jt+1)}))},o=(jt,Bt)=>{if(jt.state.doc.length!==Bt.length)return!1;if(Bt.length===0)return!0;const gr=Math.min(128,Bt.length);if(jt.state.sliceDoc(0,gr)!==Bt.slice(0,gr))return!1;const da=Math.max(0,Bt.length-gr);return jt.state.sliceDoc(da,Bt.length)===Bt.slice(da)},c=te(ft.path);if(!c){is(null),zt.current={key:"",attempts:0};return}const m=`${c}:${ft.line}:${ft.column??1}`;if(zt.current.key!==m&&(zt.current={key:m,attempts:0}),u?.path!==c){if(Gs)return;Be(Kt(c));return}if(Me||ce!==c)return;if(rt||qe||Mt||nn){is(null),zt.current={key:"",attempts:0};return}if(!at)return;if(ne!=="edit"){de("edit");return}const b=Ze.current;if(!b){n();return}if(!o(b,ie)){n();return}const N=Math.max(1,Math.min(ft.line,b.state.doc.lines)),D=b.state.doc.line(N),H=Math.max(1,ft.column||1),we=Math.max(0,D.to-D.from),B=Math.min(we,H-1),he=D.from+B;if(!(b.state.selection.main.head===he)||zt.current.attempts===0){zt.current.attempts+=1,b.dispatch({selection:{anchor:he},effects:Ut.scrollIntoView(he,{y:"center"})}),b.focus(),n();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const jt=Ze.current;jt&&(jt.dispatch({selection:{anchor:he},effects:Ut.scrollIntoView(he,{y:"center"})}),jt.focus())}),is(null),zt.current={key:"",attempts:0}},[at,Gs,ie,Co,rt,Me,qe,Mt,nn,ce,Be,ft,l,u?.path,is,ne,Kt]),i.useEffect(()=>{if(!er||!l)return;const n=te(er);if(!n){tr(null);return}u?.path===n&&(Me||ce!==n||(!rt&&!qe&&!Mt&&!nn&&at&&ne==="edit"&&Ze.current?.focus(),tr(null)))},[at,rt,Me,qe,Mt,nn,ce,er,l,u?.path,tr,ne]);const un=i.useCallback(n=>{if(!g||!n||typeof window>"u")return;const o=document.activeElement,c=!n.hasFocus&&o instanceof HTMLElement&&n.dom.contains(o)?o.closest('[data-comment-input="true"]'):null;if(!n.hasFocus&&!c)return;const m=window.visualViewport;if(!m)return;const b=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,b-(m.offsetTop+m.height))<=0)return;const D=c?c.getBoundingClientRect():n.coordsAtPos(n.state.selection.main.head);if(!D)return;const H=Math.round(m.offsetTop+m.height),B=D.bottom+20-H;B<=0||(n.scrollDOM.scrollTop+=B)},[g]);i.useEffect(()=>{if(!g||typeof window>"u")return;const n=()=>{window.requestAnimationFrame(()=>{un(Ze.current)})},o=window.visualViewport;return o?.addEventListener("resize",n),o?.addEventListener("scroll",n,{passive:!0}),document.addEventListener("selectionchange",n),()=>{o?.removeEventListener("resize",n),o?.removeEventListener("scroll",n),document.removeEventListener("selectionchange",n)}},[g,un]),gc("open_go_to_line",n=>{if(!at||ne!=="edit"||g)return!1;const o=n.target;if(o?.closest('[role="dialog"]')||!(o instanceof Node)||!es.current?.contains(o))return!1;const c=!!o?.closest(".cm-editor");if(!!o?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!c)return!1;Zs(!0)});const xs=ht(n=>n.editorFontSize),Ii=i.useMemo(()=>{if(!u?.path)return[ya(d,{fontSize:xs})];const n=vr(u.path),o=[ya(d,n?{syntaxColors:!1,fontSize:xs}:{fontSize:xs})],c=vs??Li;return c&&o.push(c),n&&o.push(Tc({language:n,themeName:d.metadata.id,theme:zc(d)})),se&&o.push(Ut.lineWrapping),g&&o.push(Ut.updateListener.of(m=>{m.view.hasFocus&&(m.selectionSet||m.focusChanged||m.viewportChanged||m.geometryChanged)&&window.requestAnimationFrame(()=>{un(m.view)})})),o},[d,u?.path,vs,Li,se,g,un,xs]),Oi=i.useMemo(()=>({light:Un.metadata.id,dark:Hn.metadata.id}),[Un.metadata.id,Hn.metadata.id]),Bi=Mt||nr||sr,Pn=u?.path&&Bi?`${u.path}|${$s.allowOutsideWorkspace?"outside":"workspace"}|${jn}`:"",ws=u?.path&&an&&le==="preview"&&!p.isVSCode?`${u.path}|${jn}`:"",$i=t("filesView.error.readFileFailed"),{readyKey:_i,nonce:ml}=$a(ws,Ne,$i),{readyKey:Wi,nonce:bs}=$a(Pn,Ne,$i),hl=!!(ws&&_i!==ws),dr=!!(Pn&&Wi!==Pn),pl=u?.path&&qe?Qe?`data:${vc(u.path)};utf8,${encodeURIComponent(U)}`:po:"",ys=u?.path&&Bi&&Pn&&Wi===Pn?ma().authenticatedAsset($l("/api/fs/raw",l),{path:u.path,allowOutsideWorkspace:$s.allowOutsideWorkspace?"true":void 0,directory:l||void 0}):"",gl=i.useCallback(n=>s.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:s.jsx("iframe",{src:ys,className:"h-full w-full border-0",title:n.name},bs)}),[ys,bs]),Ui=u&&a.downloadFile?s.jsxs($,{type:"button",variant:"outline",size:"sm",onClick:()=>{const n=a.downloadFile;!n||!u||n(u.path).catch(o=>{console.error("Download failed:",o),X.error(t("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(M,{name:"download",className:"mr-2 size-4"}),t("filesView.editor.saveFile")]}):null,js=u&&!Me&&!dr&&!rt?(n=>qe&&!Mi?s.jsx(Hu,{src:pl,name:n.name,sizeBytes:We}):Mt?gl(n):nr?s.jsx(Ku,{kind:Vi?"video":"audio",src:ys,name:n.name,sizeBytes:We,download:Ui},bs):sr?s.jsx(Iu,{src:ys,name:n.name,sizeBytes:We},bs):nn?s.jsx(Lu,{name:n.name,path:n.path,sizeBytes:We,download:Ui}):ln&&st==="table"?s.jsx(Yu,{path:n.path,content:U,sizeBytes:We}):on&&ye==="preview"?s.jsx("div",{className:"h-full min-h-0 overflow-hidden",children:s.jsx(Ns,{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:t("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToEditMode")})]}),children:s.jsx(yr,{content:`\`\`\`mermaid
|
|
16
|
+
${U}
|
|
17
|
+
\`\`\``,className:"markdown-mermaid-fullscreen h-full",enableFileReferences:!1,allowMermaidWheelEvents:!0})})}):null)(u):null;i.useEffect(()=>{let n=!1,o="";return(async()=>{if(!u?.path||!qe||Qe){Ye("");return}Ne(null);const m=ct(u.path);if(n)return;await(a.readFileBinary?a.readFileBinary(u.path,m).then(N=>N.dataUrl):(async()=>{const N=await Ms("/api/fs/raw",{signal:AbortSignal.timeout(3e4),query:{path:u.path,allowOutsideWorkspace:m.allowOutsideWorkspace?"true":void 0,directory:l||void 0}});if(!N.ok)throw new Error(t("filesView.error.readFileFailed"));const D=await N.blob();return o=URL.createObjectURL(D),n?(URL.revokeObjectURL(o),o="",""):o})()).then(N=>{n||(Ye(N),ve(u.path))}).catch(N=>{n||(Ye(""),Ne(N instanceof Error?N.message:t("filesView.error.readFileFailed")),ve(null))}).finally(()=>{n||Nt(!1)})})(),()=>{n=!0,o&&URL.revokeObjectURL(o)}},[jn,a,qe,Qe,ct,l,u?.path,$s,t]);const vl=i.useCallback(()=>Ys(null),[]),xl=i.useMemo(()=>Yc({drafts:di,editingDraftId:os,commentText:as,onTextChange:fi,selection:Z,isDragging:li,fileLabel:u?.path??"",newWidgetId:"files-new-comment-input",mapDraftToRange:n=>({start:n.startLine,end:n.endLine}),onSave:xi,onCancel:()=>{it(null),kn()},onEdit:n=>{gi(n),it({start:n.startLine,end:n.endLine})},onDelete:vi}),[kn,as,vi,os,di,xi,li,Z,u?.path,fi,gi]),Hi=Ra(),Ki=Ra(),Cs=!Me&&!rt&&ce===Ae,fr=i.useMemo(()=>!!Ae&&Eu({hasCanvas:cn,viewMode:pe,previewReady:Cs,mountable:Vn}),[Vn,pe,cn,Cs,Ae]),Ss=Cs&&gs&&ne==="view"&&!(rn&&W==="tree"),qi=Cs&&et&&Ge()==="preview",{setScroller:Gi,restore:wl}=Rs(Ss?`${Ft}:code`:null),{setScroller:Xi,restore:bl}=Rs(Ss?`${Ft}:code:fullscreen`:null),{setScroller:Yi}=Rs(qi?`${Ft}:markdown`:null),{setScroller:Ji}=Rs(qi?`${Ft}:markdown:fullscreen`:null),{setScroller:Zi}=Hi,{setScroller:Qi}=Ki,yl=i.useCallback(n=>{Zi(n),Gi(n)},[Zi,Gi]),jl=i.useCallback(n=>{Qi(n),Xi(n)},[Qi,Xi]),[Cl,Sl]=i.useState(null),[Nl,Fl]=i.useState(null),Rl=i.useCallback(n=>{ui.current=n,ns.current=n,Sl(n),Yi(n)},[Yi]),El=i.useCallback(n=>{rs.current=n,Fl(n),Ji(n)},[Ji]),ea=i.useCallback(n=>{l&&ht.getState().openContextFile(l,n)},[l]),ta=et&&_e==="preview"&&!Me,na=d.metadata.variant==="light"?"light":"dark";La({container:Cl,filePath:u?.path??null,workspaceRoot:l||null,onOpenFile:ea,enabled:ta,colorScheme:na}),La({container:Nl,filePath:u?.path??null,workspaceRoot:l||null,onOpenFile:ea,enabled:ta,colorScheme:na});const mr=Sc("unified"),yt=ie.length>Za,hr=i.useMemo(()=>yt&&Ss?Nu(ie):void 0,[Ss,ie,yt]),sa=i.useCallback((n,o,c,m)=>{const b={name:n.name,contents:o,lang:vr(n.path)||void 0},N=D=>s.jsx(Lc,{file:yt&&hr?{...b,cacheKey:`${n.path}:${hr}`}:b,options:{disableFileHeader:!0,overflow:se?"wrap":"scroll",theme:Oi,themeType:d.metadata.variant==="dark"?"dark":"light",onPostRender:m},className:yt?"block w-full":"block h-full w-full",style:yt?void 0:{height:"100%"}},D);return yt?s.jsx("div",{className:"h-full",children:s.jsx(Ac.Provider,{value:c.virtualizer,children:s.jsx(Ic.Provider,{value:mr,children:N(`${n.path}:${mr?"pool":"pending"}`)})})}):s.jsx("div",{className:"h-full",children:N(n.path)})},[d.metadata.variant,yt,hr,Oi,mr,se]),ra=({exitFullscreenOnly:n=!1,layout:o="floating"}={})=>{if(!u)return null;const c=o==="docked",m=xc(wc("save_file")),b=c?"pointer-events-auto flex flex-wrap items-center gap-1":"pointer-events-auto flex items-center gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-sm",N=(D,H)=>s.jsxs($t,{children:[s.jsx(_t,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:H})}),s.jsx(Wt,{side:"bottom",sideOffset:6,children:D})]});return s.jsxs("div",{className:b,children:[at&&el&&s.jsxs(s.Fragment,{children:[Gt?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[s.jsx(M,{name:"loader-4",className:"size-3.5 animate-spin"}),t("filesView.editor.saving")]}):Ve&&wo==="saved"&&!Ke?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[s.jsx(M,{name:"check",className:"size-3.5"}),t("filesView.editor.saved")]}):Ke?N(t(Ve?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:m}),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>{xt()},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:t(Ve?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:m}),"aria-label":t("filesView.editor.saveAria",{shortcut:m}),children:s.jsx(M,{name:"save-3",className:"size-4"})})):null,N(t(Ve?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>jo(!Ve),className:q("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",Ve?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:t(Ve?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),"aria-label":t(Ve?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),children:Ve?s.jsx(M,{name:"file-check-fill",className:"size-4"}):s.jsx(M,{name:"file-check",className:"size-4"})}))]}),s.jsxs(kr,{onOpenChange:Re,children:[s.jsxs($t,{children:[s.jsx(_t,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(Tr,{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:t("filesView.editor.openInDesktopApp"),"aria-label":t("filesView.editor.openInDesktopApp"),children:s.jsx(M,{name:"file-transfer",className:"size-4"})})})})}),s.jsx(Wt,{side:"bottom",sideOffset:6,children:t("filesView.editor.openInDesktopApp")})]}),s.jsxs(Mr,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[Po.map(D=>s.jsxs(Vs,{className:"flex items-center gap-2",onClick:()=>{Ao(D)},children:[s.jsx(id,{label:D.label,iconDataUrl:D.iconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:D.label})]},D.id)),Do?s.jsxs(Vs,{className:"flex items-center gap-2",onClick:()=>{Lo(!0)},children:[s.jsx(M,{name:"refresh",className:"size-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:t("filesView.editor.refreshApps")})]}):null]})]}),!Pi&&s.jsxs(s.Fragment,{children:[N(t(se?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>Le(!se),className:q("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",se?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:t(se?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),children:s.jsx(M,{name:"text-wrap",className:"size-4"})})),ne==="edit"&&s.jsxs(s.Fragment,{children:[N(t("filesView.editor.findInFile"),s.jsx($,{variant:"ghost",size:"sm",onClick:D=>{Fe(!ze),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:t("filesView.editor.findInFile"),children:s.jsx(M,{name:"search",className:"size-4"})})),N(t("filesView.editor.goToLine"),s.jsx($,{variant:"ghost",size:"sm",onClick:D=>{Zs(H=>!H),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:t("filesView.editor.goToLine"),children:s.jsx(M,{name:"menu-fold-2",className:"size-4"})})),s.jsx(ou,{open:Vo,onOpenChange:Zs,view:Ze.current,variant:"inline"})]})]}),gs&&at&&!rn&&!an&&!Qe&&!on&&!ln&&s.jsx(fn,{currentMode:ne==="view"?"preview":"edit",onToggle:()=>{tl(ne==="view"?"edit":"view")}}),et&&N(t(Ge()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>nl(Ge()==="preview"?"edit":"preview"),className:q("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",Ge()==="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:t(Ge()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),"aria-label":t(Ge()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:s.jsx(M,{name:Ge()==="preview"?"eye":"eye-off",className:"size-4"})})),ks(u?.path??"")&&s.jsx(fn,{currentMode:Ai(),onToggle:()=>{ol(Ai()==="preview"?"edit":"preview")}}),Qe&&s.jsx(fn,{currentMode:ge,onToggle:()=>sl(ge==="preview"?"edit":"preview")}),on&&s.jsx(fn,{currentMode:ye,onToggle:()=>rl(ye==="preview"?"edit":"preview")}),ln&&N(t(st==="table"?"filesView.artifact.table.showSource":"filesView.artifact.table.showTable"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>il(st==="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:t(st==="table"?"filesView.artifact.table.showSource":"filesView.artifact.table.showTable"),"aria-label":t(st==="table"?"filesView.artifact.table.showSource":"filesView.artifact.table.showTable"),children:st==="table"?s.jsx(M,{name:"code-sslash",className:"size-4"}):s.jsx(M,{name:"table-2",className:"size-4"})})),et&&Ge()==="preview"&&N(t("filesView.editor.findInFile"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>{ts(!0),ti(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:t("filesView.editor.findInFile"),children:s.jsx(M,{name:"search",className:"size-4"})})),et&&Ge()==="preview"&&Io&&s.jsxs($t,{children:[s.jsx(_t,{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":t(Zn?"filesView.tts.stopSpeaking":"filesView.tts.readAloud"),onClick:()=>{Zn?ho():U.trim()&&mo(U)},children:Zn?s.jsx(M,{name:"stop",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(M,{name:"volume-up",className:"size-4"})})}),s.jsx(Wt,{sideOffset:8,children:t(Zn?"filesView.tts.stopSpeaking":"filesView.tts.readAloud")})]}),cn&&s.jsxs(s.Fragment,{children:[!Tn&&s.jsx(fn,{currentMode:pe,onToggle:()=>cl(pe==="preview"?"edit":"preview")}),pe==="preview"&&s.jsx($,{variant:"ghost",size:"sm",onClick:async()=>{await xt()&&(Kr(!0),setTimeout(()=>Kr(!1),1500))},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:t("filesView.fileEditor.save"),children:yo?s.jsx(M,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(M,{name:"save-3",className:"size-4"})})]}),Mn&&s.jsxs(s.Fragment,{children:[s.jsx(fn,{currentMode:re,onToggle:()=>ll(re==="preview"?"edit":"preview")}),re==="preview"&&s.jsx($,{variant:"ghost",size:"sm",onClick:async()=>{const D=Ur.current?.getXml();if(Ue.current&&(clearTimeout(Ue.current),Ue.current=null),u?.path&&D){if(!await ur(u.path,D))return;Qn(!0),setTimeout(()=>Qn(!1),1500)}},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:t("filesView.diagram.saveDiagram"),children:bo?s.jsx(M,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(M,{name:"save-3",className:"size-4"})})]}),rn&&N(t(W==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>al(W==="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:t(W==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),children:W==="tree"?s.jsx(M,{name:"code-sslash",className:"size-4"}):s.jsx(M,{name:"node-tree",className:"size-4"})})),Yo&&N(t("filesView.editor.copyFileContents"),s.jsx($,{variant:"ghost",size:"sm",onClick:async()=>{(await Ds(U)).ok?(Jr(!0),Fn.current!==null&&window.clearTimeout(Fn.current),Fn.current=window.setTimeout(()=>{Jr(!1)},1200)):X.error(t("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:t("filesView.editor.copyFileContents"),"aria-label":t("filesView.editor.copyFileContents"),children:To?s.jsx(M,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(M,{name:"clipboard",className:"size-4"})})),Jo&&N(t("filesView.editor.copyFilePathTitle",{path:wt}),s.jsx($,{variant:"ghost",size:"sm",onClick:async()=>{(await Ds(wt)).ok?(Zr(!0),Rn.current!==null&&window.clearTimeout(Rn.current),Rn.current=window.setTimeout(()=>{Zr(!1)},1200)):X.error(t("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:t("filesView.editor.copyFilePathTitle",{path:wt}),"aria-label":t("filesView.editor.copyFilePathTitle",{path:wt}),children:Mo?s.jsx(M,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(M,{name:"file-copy-2",className:"size-4"})})),a.downloadFile&&N(t("filesView.editor.saveFile"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>{const D=a.downloadFile;D&&D(u.path).catch(H=>{console.error("Download failed:",H),X.error(t("sidebarFilesTree.toast.operationFailed"))})},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:t("filesView.editor.saveFile"),"aria-label":t("filesView.editor.saveFile"),children:s.jsx(M,{name:"download",className:"size-4"})})),n?N(t("filesView.editor.exitFullscreen"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>xe(!1),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:t("filesView.editor.exitFullscreen"),"aria-label":t("filesView.editor.exitFullscreen"),children:s.jsx(M,{name:"fullscreen-exit",className:"size-4"})})):!g&&r==="full"&&N(t(A?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),s.jsx($,{variant:"ghost",size:"sm",onClick:()=>xe(!A),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:t(A?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),"aria-label":t(A?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),children:A?s.jsx(M,{name:"fullscreen-exit",className:"size-4"}):s.jsx(M,{name:"fullscreen",className:"size-4"})}))]})},ia=i.useRef(null);i.useEffect(()=>{ce&&(yn.current&&ia.current===ce&&_n(n=>n+1),ia.current=ce)},[ce]);const kl=i.useCallback(async()=>{const n=gt.current;if(!n)throw new Error("No file is open.");const o=ct(n),c=await Ms("/api/fs/raw",{signal:AbortSignal.timeout(6e4),cache:"no-store",query:{path:n,allowOutsideWorkspace:o.allowOutsideWorkspace?"true":void 0,directory:l||void 0}});if(!c.ok)throw new Error(t("filesView.error.readFileFailed"));return new Uint8Array(await c.arrayBuffer())},[ct,l,t]),aa=i.useCallback(n=>{const o=gt.current;o&&(vn.current[o]="edit"),dt(!1),be("edit"),X.error(n)},[]),oa=r==="full"&&A,Tl=u?`${u.path}:${lo}:${oa?"fullscreen":"docked"}`:"",la=fr&&u&&Pe?s.jsx("div",{ref:Gr,className:"h-full overflow-hidden",style:{minHeight:"400px"},children:s.jsx(ku,{ref:Xt,guestId:Pe.guestId,editorId:Pe.editor.id,title:Pe.editor.title,contentKind:Tn?"binary":"text",path:wt||u.path,content:ie,loadBytes:kl,readOnly:!u||Gn||!a.writeFile||Tn&&!a.uploadFile,onDirtyChange:dt,onEdit:()=>{Xr.current=Date.now()},onSaveRequest:Ni,onUnsupported:fl,onTooLarge:()=>aa(t("filesView.fileEditor.tooLarge",{editor:Pe.editor.title})),onLoadFailed:()=>aa(t("filesView.error.readFileFailed"))},`${Tl}:${Pe.guestId}:${Pe.editor.id}`)}):null,Ml=i.useCallback(()=>{const n=ht.getState();n.requestSettingsJump("integrations","integrations.extensions.excalidraw"),n.setSettingsDialogOpen(!0)},[]),pr=s.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[s.jsx(Ua,{open:Gs,onOpenChange:n=>{n||Cn(!0)},children:s.jsxs(Ha,{showCloseButton:!1,className:"max-w-md",children:[s.jsxs(Ka,{children:[s.jsx(qa,{children:t("filesView.unsaved.title")}),s.jsx(Ga,{children:t("filesView.unsaved.description")})]}),s.jsxs(Xa,{children:[s.jsx($,{variant:"outline",onClick:()=>{Ho()},disabled:Gt,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:t("filesView.unsaved.saveChanges")}),s.jsx($,{variant:"destructive",onClick:Uo,children:t("filesView.unsaved.discard")})]})]})}),s.jsxs("div",{className:q("flex flex-col flex-shrink-0",_&&"border-b border-border/40"),children:[_?s.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[g&&J&&s.jsx("button",{type:"button",onClick:()=>Y(!1),"aria-label":t("filesView.editor.back"),className:"inline-flex size-7 flex-shrink-0 items-center justify-center mr-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:s.jsx(M,{name:"arrow-left-s",className:"size-5"})}),g?u?s.jsxs(kr,{children:[s.jsx(Tr,{asChild:!0,children:s.jsxs("button",{type:"button",className:"inline-flex min-w-0 max-w-full items-center gap-1 text-left typography-ui-label font-medium","aria-label":t("filesView.editor.openFilesAria"),children:[s.jsx(zn,{filePath:u.path,extension:u.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(Aa,{name:u.name}),s.jsx(M,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),s.jsx(Mr,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:qt.map(n=>{const o=u?.path===n.path;return s.jsxs(Vs,{onSelect:c=>{if(c.target.closest("[data-close-open-file]")){c.preventDefault();return}o||Be(n)},className:q("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(zn,{filePath:n.path,extension:n.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(Aa,{name:n.name})]}),s.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:c=>{c.preventDefault(),c.stopPropagation()},onClick:c=>{c.preventDefault(),c.stopPropagation(),Ei(n.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":t("filesView.editor.closeFileAria",{name:n.name}),children:s.jsx(M,{name:"close",className:"size-3.5"})})]},n.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:t("filesView.editor.selectFile")}):qt.length>0?s.jsxs("div",{className:"relative min-w-0 flex-1",children:[Ir.left&&s.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r from-background to-transparent"}),Ir.right&&s.jsx("div",{className:"pointer-events-none absolute right-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l from-background to-transparent"}),s.jsx("div",{ref:_s,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:qt.map(n=>{const o=u?.path===n.path;return s.jsxs("div",{title:Ps(l,n.path),className:q("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(zn,{filePath:n.path,extension:n.extension,className:"size-3.5 flex-shrink-0"}),s.jsx("button",{type:"button",onClick:()=>{o||Be(n)},className:"max-w-[12rem] truncate text-left",children:n.name}),s.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),Ei(n.path)},className:q("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!o&&!C&&"opacity-0 group-hover:opacity-100"),"aria-label":t("filesView.editor.closeFileAria",{name:n.name}),children:s.jsx(M,{name:"close",className:"size-3.5"})})]},n.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:t("filesView.editor.selectFile")})]}):null,u?s.jsxs("div",{className:"flex min-w-0 items-center gap-3 border-t border-border/40 bg-[var(--surface-subtle)] px-3 py-1",children:[wt&&!g?s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:wt,children:wt}):null,s.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:ra({layout:"docked"})})]}):null]}),Qo?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(M,{name:"information",className:"size-4 shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:t("filesView.excalidraw.installHint")}),s.jsx($,{type:"button",size:"xs",variant:"outline",onClick:Ml,children:t("filesView.excalidraw.installAction")})]}):null,s.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:s.jsx(br,{ref:yl,outerClassName:"h-full min-w-0",className:q("h-full min-w-0",yt&&"[overflow-anchor:none]"),children:u?Me||dr?R?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(M,{name:"loader-4",className:"size-4 animate-spin"}),t("filesView.state.loading")]}):rt?s.jsx("div",{className:"p-3 typography-ui text-[color:var(--status-error)]",children:rt}):fr?oa?s.jsx("div",{className:"h-full"}):la:js||(u&&Mn&&re==="preview"?s.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:s.jsx(Ru,{ref:Ur,xml:dl,onChange:ul},`${u.path}:${ao}`)}):u&&rn&&W==="tree"?s.jsx(Ns,{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:t("filesView.error.jsonViewerUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToTextMode")})]}),children:s.jsx("div",{className:"h-full overflow-auto",children:s.jsx(Dc,{jsonString:U,maxHeight:"100%",initiallyExpandedDepth:2})})}):u&&et&&Ge()==="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:ss,ref:Rl,children:[s.jsx(Ca,{containerRef:ui,filePath:u.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:t("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(U.length/1024)})}),s.jsx(Ns,{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:t("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToEditMode")})]}),children:s.jsx(yr,{content:U,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1,allowRawHtml:!0})})]}),!A&&s.jsx(Fa,{containerRef:ns,open:Qr,onOpenChange:ts,focusNonce:ei})]}):u&&an&&le==="preview"?hl?s.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:t("common.loading")}):s.jsx("div",{className:"h-full overflow-hidden",children:s.jsx("iframe",{src:!p.isVSCode&&_i===ws?(()=>{const n=u.path.split("/").map(o=>encodeURIComponent(o)).join("/");return ma().authenticatedAsset(`/api/fs/serve${n.startsWith("/")?n:`/${n}`}`)})():void 0,srcDoc:p.isVSCode?(()=>{const n=u.path.substring(0,u.path.lastIndexOf("/")+1);return n?U.replace(/<head([^>]*)>/i,`<head$1><base href="${n}">`):U})():void 0,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:t("filesView.editor.htmlPreviewTitle")},ml)}):u&&gs&&ne==="view"?sa(u,ie,Hi,wl):s.jsxs("div",{className:q("relative h-full",sn&&"overflow-hidden"),ref:es,children:[s.jsx("div",{className:q("h-full",sn&&"invisible"),children:s.jsx(Ba,{positionKey:Ft,value:ie,onChange:Ce,readOnly:!at,vimMode:ci==="vim",extensions:Ii,className:"h-full",blockWidgets:xl,onViewReady:n=>{Ze.current=n,Xs(o=>o+1),window.requestAnimationFrame(()=>{un(n)})},onViewDestroy:()=>{Ze.current&&(Ze.current=null),Xs(n=>n+1)},enableSearch:!0,searchOpen:ze,onSearchOpenChange:Fe,highlightLines:Z?{start:Math.min(Z.start,Z.end),end:Math.max(Z.start,Z.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(n,o,c)=>{if(!(c instanceof MouseEvent)||c.button!==0)return!1;c.preventDefault();const m=n.state.doc.lineAt(o.from).number;if(Z&&!c.shiftKey&&Math.min(Z.start,Z.end)===m&&Math.max(Z.start,Z.end)===m)return it(null),kn(),en.current=!1,kt.current=null,tn(!1),!0;if(g&&Z&&!c.shiftKey){const b=Math.min(Z.start,Z.end,m),N=Math.max(Z.start,Z.end,m);return it({start:b,end:N}),en.current=!1,kt.current=null,tn(!1),!0}if(en.current=!0,kt.current=m,tn(!0),Z&&c.shiftKey){const b=Math.min(Z.start,m),N=Math.max(Z.end,m);it({start:b,end:N})}else it({start:m,end:m});return!0},mouseover:(n,o,c)=>{if(!(c instanceof MouseEvent)||c.buttons!==1||!en.current||kt.current===null)return!1;const m=n.state.doc.lineAt(o.from).number,b=Math.min(kt.current,m),N=Math.max(kt.current,m);return it({start:b,end:N}),tn(!0),!1},mouseup:()=>(en.current=!1,kt.current=null,tn(!1),!1)}}},Ft)}),sn&&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(M,{name:"loader-4",className:"size-4 animate-spin"}),t("filesView.state.openingFileAtChange")]})})]})):s.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:t("filesView.editor.pickFileFromTree")})})})]}),Vl=!!(l&&$r[l]),ca=l?Xn[l]:null,ua=S?s.jsxs("section",{className:q("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:q("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(M,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),s.jsx(In,{ref:ae,value:K,onChange:n=>Q(n.target.value),placeholder:t("filesView.tree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),K.trim().length>0&&s.jsx("button",{type:"button","aria-label":t("filesView.tree.search.clearAria"),className:"absolute right-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{Q(""),ae.current?.focus()},children:s.jsx(M,{name:"close",className:"size-4"})})]}),s.jsxs($t,{children:[s.jsx(_t,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx($,{variant:"ghost",size:"sm",onClick:()=>Qs("createFile",{path:j,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:t("filesView.tree.actions.newFileTitle"),"aria-label":t("filesView.tree.actions.newFileTitle"),children:s.jsx(M,{name:"file-add",className:"size-4"})})})}),s.jsx(Wt,{side:"bottom",sideOffset:6,children:t("filesView.tree.actions.newFileTitle")})]}),s.jsxs($t,{children:[s.jsx(_t,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx($,{variant:"ghost",size:"sm",onClick:()=>Qs("createFolder",{path:j,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:t("filesView.tree.actions.newFolderTitle"),"aria-label":t("filesView.tree.actions.newFolderTitle"),children:s.jsx(M,{name:"folder-add",className:"size-4"})})})}),s.jsx(Wt,{side:"bottom",sideOffset:6,children:t("filesView.tree.actions.newFolderTitle")})]}),bi&&s.jsxs($t,{children:[s.jsx(_t,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx($,{variant:"ghost",size:"sm",onClick:()=>yi(l),disabled:!l||cs,className:"size-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.uploadFilesTitle"),"aria-label":t("sidebarFilesTree.actions.uploadFilesTitle"),children:s.jsx(M,{name:cs?"loader-4":"upload-2",className:q("size-4",cs&&"animate-spin")})})})}),s.jsx(Wt,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.uploadFilesTitle")})]}),s.jsxs($t,{children:[s.jsx(_t,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx($,{variant:"ghost",size:"sm",onClick:()=>{ls()},className:"size-8 p-0 flex-shrink-0",title:t("filesView.tree.actions.refreshTitle"),"aria-label":t("filesView.tree.actions.refreshTitle"),children:s.jsx(M,{name:"refresh",className:"size-4"})})})}),s.jsx(Wt,{side:"bottom",sideOffset:6,children:t("filesView.tree.actions.refreshTitle")})]})]})}),s.jsx(br,{outerClassName:"flex-1 min-h-0",className:q("py-2",g?"px-3":"px-2"),children:s.jsx("ul",{className:"flex flex-col",children:fo?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),t("filesView.tree.search.searching")]}):_r.length>0?_r.map(n=>{const o=u?.path===n.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>{Be(n)},className:q("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",o?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[io(n.path,n.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},title:n.path,children:n.relativePath??n.path})]})},n.path)}):ca?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:ca}),s.jsxs($,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{ls()},children:[s.jsx(M,{name:"refresh",className:"size-3.5"}),t("filesView.tree.actions.refreshTitle")]})]}):Vl?Ti(l,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:t("filesView.state.loading")})})})]}):null,Pl=r==="full"&&A&&u&&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 right-4 top-4 z-30",children:ra({exitFullscreenOnly:!0})}),s.jsx(br,{ref:jl,outerClassName:"h-full min-w-0",className:q("h-full min-w-0",yt&&"[overflow-anchor:none]"),children:Me||dr?R?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(M,{name:"loader-4",className:"size-4 animate-spin"}),"Loading…"]}):rt?s.jsx("div",{className:"p-4 typography-ui text-[color:var(--status-error)]",children:rt}):fr?la:js||(et&&Ge()==="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:ss,ref:El,children:[u?s.jsx(Ca,{containerRef:rs,filePath:u.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:t("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(U.length/1024)})}),s.jsx(Ns,{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:t("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToEditMode")})]}),children:s.jsx(yr,{content:U,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1,allowRawHtml:!0})})]}),s.jsx(Fa,{containerRef:rs,open:Qr,onOpenChange:ts,focusNonce:ei,className:"right-4 top-16"})]}):gs&&ne==="view"?sa(u,ie,Ki,bl):s.jsxs("div",{className:q("relative h-full",sn&&"overflow-hidden"),children:[s.jsx("div",{className:q("h-full",sn&&"invisible"),children:s.jsx(Ba,{positionKey:`${Ft}:fullscreen`,value:ie,onChange:Ce,readOnly:!at,vimMode:ci==="vim",extensions:Ii,className:"h-full",onViewReady:n=>{Ze.current=n,window.requestAnimationFrame(()=>{un(n)})},onViewDestroy:()=>{Ze.current&&(Ze.current=null)}},`${Ft}:fullscreen`)}),sn&&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(M,{name:"loader-4",className:"size-4 animate-spin"}),t("filesView.state.openingFileAtChange")]})})]}))})]})});return s.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[s.jsx(pd,{activeDialog:At,dialogData:It,dialogInputValue:Et,onDialogInputChange:Yr,isDialogSubmitting:No,onDialogSubmit:Wo,onClose:vl,inputRef:vo}),_o,Pl,g?J?pr:ua: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:pr})}):s.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[w>=700&&s.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:ua}),s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:pr})]})]})};function vd(r){return r+1}export{Om as FilesView};
|