@aiworker/web 1.22.2 → 1.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +7 -0
- package/dist/assets/{CodeMirrorCommentWidgets-CSICpWQD.js → CodeMirrorCommentWidgets-teB3HmBT.js} +1 -1
- package/dist/assets/DiffView-DC9RX3MF.js +4 -0
- package/dist/assets/{DirtyBranchSwitchDialog-C22HdWj4.js → DirtyBranchSwitchDialog-DwPkzXsS.js} +1 -1
- package/dist/assets/FilesView-BFZkuu4O.js +13 -0
- package/dist/assets/{GitView-VQQkYuUw.js → GitView-B_x52MHY.js} +4 -4
- package/dist/assets/{JsonTreeView-6lrhwD3q.js → JsonTreeView-cmAzUTiw.js} +1 -1
- package/dist/assets/{LinearIssuesView-Ba6Q9569.js → LinearIssuesView-Dehh5afm.js} +1 -1
- package/dist/assets/MarkdownImageGallery-DgNOqqhE.js +1 -0
- package/dist/assets/MarkdownRendererImpl-DusmMZ_p.js +12 -0
- package/dist/assets/OnboardingScreen-B8fm1H4m.js +1 -0
- package/dist/assets/{PatchDiff-BzcZPlOq.js → PatchDiff-BVr7gJU0.js} +1 -1
- package/dist/assets/PierreDiffViewer-DzLt-nel.js +161 -0
- package/dist/assets/PlanView-BmQUYT_z.js +5 -0
- package/dist/assets/SettingsView-ChWmAcZT.js +28 -0
- package/dist/assets/{SettingsWindow-DDQYaKWQ.js → SettingsWindow-Dy3M6ZB9.js} +1 -1
- package/dist/assets/SymbolsNerdFontMono-Regular-aK5vsLov.woff2 +0 -0
- package/dist/assets/{ToolOutputDialog-iYF8Y2bz.js → ToolOutputDialog-cTl_eLIH.js} +5 -5
- package/dist/assets/{ToolPartDiffPreview-CdjbOVMM.js → ToolPartDiffPreview-C_3iYNJQ.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-fFFm2QgH.js → VirtualizedFileDiff-CAWthkoy.js} +4 -4
- package/dist/assets/WalkthroughView-C7AHOpCA.js +4 -0
- package/dist/assets/{computeVirtualFileMetrics-CzgLum_K.js → computeVirtualFileMetrics-BkiDSlTW.js} +2 -2
- package/dist/assets/contextPanelEmbeddedChat-BdA6bdky.js +1 -0
- package/dist/assets/de-DJsQr-p7.js +10 -0
- package/dist/assets/es-BuYMlA9g.js +16 -0
- package/dist/assets/fr-ePDay33C.js +14 -0
- package/dist/assets/ghostty-vt-DdA0Zryv.wasm +0 -0
- package/dist/assets/index-BD8ILbxF.js +40 -0
- package/dist/assets/{index-Bl3LSbjn.js → index-n6O3hklM.js} +1 -1
- package/dist/assets/index-zhgg-SDz.css +1 -0
- package/dist/assets/{isDiffPlainText-Dx-dB_8l.js → isDiffPlainText-GMdPz-71.js} +1 -1
- package/dist/assets/{isFilePlainText-CWFPwmnU.js → isFilePlainText-BVuH1zH9.js} +1 -1
- package/dist/assets/ja-BzR9xOY_.js +16 -0
- package/dist/assets/ko-BEjHAm14.js +16 -0
- package/dist/assets/main-BydQ1tr_.js +930 -0
- package/dist/assets/{main-DnBAoktx.js → main-D3ZDQglc.js} +2 -2
- package/dist/assets/markdownCore-Cb2MdZnV.js +5 -0
- package/dist/assets/{miniChat-BKyvLseN.js → miniChat-d01k801U.js} +2 -2
- package/dist/assets/{mobile-DKjeFgMN.js → mobile-D7VV-Ufz.js} +2 -2
- package/dist/assets/patchFileDiff-CdztVMz0.js +13 -0
- package/dist/assets/pl-rQmpxNIF.js +16 -0
- package/dist/assets/pt-BR-CorbsSW-.js +16 -0
- package/dist/assets/renderElectronMiniChatApp-BGG9UIlh.js +2 -0
- package/dist/assets/renderMobileApp-BRP3J1iv.js +25 -0
- package/dist/assets/runtimeEndpointReset-BhT_-c52.js +41 -0
- package/dist/assets/scheduledTasksApi-BEuUF_cj.js +1 -0
- package/dist/assets/{shikiHighlight-TEQCmzW8.js → shikiHighlight-BzXUjlby.js} +1 -1
- package/dist/assets/surface-COKb77Ua.js +1 -0
- package/dist/assets/tr-CoAMXPtI.js +7 -0
- package/dist/assets/uk-YlAX0rRU.js +16 -0
- package/dist/assets/{useAppFontEffects-D7sNpuL2.js → useAppFontEffects-Cwyhjfl5.js} +141 -140
- package/dist/assets/useGitComparison-BCZVefdE.js +1 -0
- package/dist/assets/useInlineCommentController-DDkpBEU8.js +2 -0
- package/dist/assets/useRootScrollLock-CwjoWuC4.js +1 -0
- package/dist/assets/{vendor-base-ui-BeMD8X_w.js → vendor-base-ui-BY_5qla_.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-Dp3KMRQG.js → vendor-codemirror-language-data-Cb1YnICj.js} +2 -2
- package/dist/assets/vendor-legendapp-list-BuBPBC3R.js +1 -0
- package/dist/assets/vendor-zod-B6551dwG.js +39 -0
- package/dist/assets/{web-components-_mNEMjFY.js → web-components-LV3vjTxy.js} +1 -1
- package/dist/assets/zh-CN-DDYg0Jl7.js +16 -0
- package/dist/assets/zh-TW-CQKaCayr.js +16 -0
- package/dist/index.html +5 -43
- package/dist/mini-chat.html +4 -4
- package/dist/mobile.html +4 -4
- package/package.json +2 -3
- package/server/index.d.ts +15 -0
- package/server/index.js +48 -22
- package/server/lib/agent-memory/runtime.js +7 -2
- package/server/lib/agent-memory/runtime.test.js +22 -0
- package/server/lib/data-dir-migration.js +40 -0
- package/server/lib/data-dir-migration.test.js +59 -0
- package/server/lib/event-stream/DOCUMENTATION.md +3 -0
- package/server/lib/event-stream/global-hub.js +29 -4
- package/server/lib/event-stream/global-hub.test.js +22 -0
- package/server/lib/event-stream/global-ws-bridge.js +15 -18
- package/server/lib/event-stream/protocol.js +21 -7
- package/server/lib/event-stream/runtime.js +9 -6
- package/server/lib/event-stream/runtime.test.js +72 -12
- package/server/lib/fs/DOCUMENTATION.md +3 -0
- package/server/lib/fs/routes.js +31 -0
- package/server/lib/fs/routes.test.js +110 -1
- package/server/lib/git/DOCUMENTATION.md +39 -6
- package/server/lib/git/routes.js +45 -12
- package/server/lib/git/routes.test.js +78 -0
- package/server/lib/git/service.js +343 -202
- package/server/lib/git/service.test.js +496 -25
- package/server/lib/github/DOCUMENTATION.md +5 -0
- package/server/lib/github/routes.js +2 -2
- package/server/lib/inherited-env.js +16 -9
- package/server/lib/inherited-env.test.js +8 -9
- package/server/lib/message-queue/DOCUMENTATION.md +11 -1
- package/server/lib/message-queue/runtime.js +13 -0
- package/server/lib/message-queue/runtime.test.js +31 -1
- package/server/lib/network-defaults.js +23 -0
- package/server/lib/network-defaults.test.js +52 -0
- package/server/lib/notifications/DOCUMENTATION.md +1 -1
- package/server/lib/notifications/emitter-runtime.js +4 -3
- package/server/lib/opencode/DOCUMENTATION.md +35 -5
- package/server/lib/opencode/bootstrap-runtime.js +2 -0
- package/server/lib/opencode/env-runtime.js +5 -1
- package/server/lib/opencode/env-runtime.test.js +72 -0
- package/server/lib/opencode/feature-routes-runtime.js +17 -1
- package/server/lib/opencode/lifecycle.js +4 -3
- package/server/lib/opencode/lifecycle.test.js +29 -0
- package/server/lib/opencode/managed-plugin-config.js +1 -1
- package/server/lib/opencode/openchamber-routes.js +64 -4
- package/server/lib/opencode/openchamber-routes.test.js +128 -1
- package/server/lib/opencode/proxy.js +33 -0
- package/server/lib/opencode/routes.js +5 -3
- package/server/lib/opencode/settings-files.js +214 -0
- package/server/lib/opencode/settings-helpers.js +88 -41
- package/server/lib/opencode/settings-helpers.test.js +176 -1
- package/server/lib/opencode/settings-registry.json +750 -0
- package/server/lib/opencode/settings-runtime.js +175 -27
- package/server/lib/opencode/settings-runtime.test.js +321 -7
- package/server/lib/project-context/DOCUMENTATION.md +38 -4
- package/server/lib/project-context/routes.http.test.js +18 -0
- package/server/lib/project-context/routes.js +15 -0
- package/server/lib/project-context/runtime.js +256 -25
- package/server/lib/project-context/runtime.test.js +160 -3
- package/server/lib/projects/DOCUMENTATION.md +77 -0
- package/server/lib/projects/project-config.js +179 -17
- package/server/lib/projects/project-config.test.js +97 -0
- package/server/lib/projects/project-id.js +43 -0
- package/server/lib/projects/project-setup.js +409 -0
- package/server/lib/projects/project-setup.test.js +557 -0
- package/server/lib/projects/routes.js +59 -0
- package/server/lib/quota/DOCUMENTATION.md +31 -1
- package/server/lib/quota/providers/cline-pass.js +125 -0
- package/server/lib/quota/providers/cline-pass.test.js +103 -0
- package/server/lib/quota/providers/index.js +7 -0
- package/server/lib/quota/providers/neuralwatt.js +3 -6
- package/server/lib/quota/providers/neuralwatt.test.js +7 -7
- package/server/lib/quota/providers/ollama-cloud.js +31 -0
- package/server/lib/quota/providers/ollama-cloud.test.js +33 -1
- package/server/lib/quota/providers/opencode-go.js +1 -1
- package/server/lib/quota/providers/opencode-go.test.js +26 -1
- package/server/lib/quota/providers/openrouter.js +119 -24
- package/server/lib/quota/providers/openrouter.test.js +330 -0
- package/server/lib/relay/DOCUMENTATION.md +75 -0
- package/server/lib/relay/cross-compat.test.js +26 -0
- package/server/lib/relay/downstream-scheduler.js +154 -0
- package/server/lib/relay/downstream-scheduler.test.js +162 -0
- package/server/lib/relay/e2ee.js +10 -8
- package/server/lib/relay/flow-control.test.js +177 -0
- package/server/lib/relay/host-client.js +44 -8
- package/server/lib/relay/host-client.test.js +14 -0
- package/server/lib/relay/tunnel-codec.js +9 -0
- package/server/lib/relay/tunnel-host.js +66 -17
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +9 -1
- package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +28 -0
- package/server/lib/scheduled-tasks/runtime.js +12 -2
- package/server/lib/scheduled-tasks/runtime.test.js +53 -0
- package/server/lib/session-assist/DOCUMENTATION.md +131 -66
- package/server/lib/session-assist/context.js +127 -0
- package/server/lib/session-assist/context.test.js +132 -0
- package/server/lib/session-assist/prompt.js +54 -0
- package/server/lib/session-assist/runtime.js +117 -267
- package/server/lib/session-assist/runtime.test.js +203 -0
- package/server/lib/session-goal/runtime.js +4 -9
- package/server/lib/small-model/DOCUMENTATION.md +3 -2
- package/server/lib/small-model/call.js +9 -4
- package/server/lib/small-model/call.test.js +29 -0
- package/server/lib/small-model/index.js +5 -10
- package/server/lib/small-model/runtime-providers.js +15 -7
- package/server/lib/small-model/runtime-providers.test.js +7 -1
- package/server/lib/terminal/DOCUMENTATION.md +4 -4
- package/server/lib/terminal/runtime.js +11 -6
- package/server/lib/terminal/runtime.test.js +20 -13
- package/server/lib/walkthrough/DOCUMENTATION.md +49 -20
- package/server/lib/walkthrough/model-settings.js +8 -12
- package/server/lib/walkthrough/pr-source.test.js +21 -0
- package/server/lib/walkthrough/prompt.js +3 -1
- package/server/lib/walkthrough/pull-request.js +7 -4
- package/server/lib/walkthrough/pull-request.test.js +16 -0
- package/server/lib/walkthrough/routes.js +19 -0
- package/server/lib/walkthrough/routes.test.js +26 -0
- package/server/lib/walkthrough/sources.js +36 -4
- package/server/opencode-worktree-readiness.test.js +130 -0
- package/dist/assets/DiffView-hDBKesA_.js +0 -4
- package/dist/assets/FilesView-CdWzeOp9.js +0 -17
- package/dist/assets/MarkdownImageGallery-Czv_mhvS.js +0 -1
- package/dist/assets/MarkdownRendererImpl-BrMcswiy.js +0 -12
- package/dist/assets/OnboardingScreen-ChxQoAkx.js +0 -1
- package/dist/assets/PierreDiffViewer-BchBtZlp.js +0 -157
- package/dist/assets/PlanView-DyDt_nZ_.js +0 -5
- package/dist/assets/SettingsView-BKf5xBsP.js +0 -28
- package/dist/assets/WalkthroughView-DOeCsMju.js +0 -4
- package/dist/assets/contextPanelEmbeddedChat-C0ZLAepL.js +0 -1
- package/dist/assets/de-B5JaA3SA.js +0 -10
- package/dist/assets/es-EPIH88ii.js +0 -16
- package/dist/assets/fr-CAMfxUdZ.js +0 -14
- package/dist/assets/index-DF5kMP-i.js +0 -39
- package/dist/assets/index-Dl3xbAB_.css +0 -1
- package/dist/assets/ja-CifOE1VN.js +0 -16
- package/dist/assets/ko-BBDyAyYQ.js +0 -16
- package/dist/assets/main-MhSaOZoB.js +0 -930
- package/dist/assets/markdownCore-BrBwOOMn.js +0 -3
- package/dist/assets/patchFileDiff-o8ms1me8.js +0 -10
- package/dist/assets/pl-DgEHYfFM.js +0 -16
- package/dist/assets/pt-BR-DuWHojUw.js +0 -16
- package/dist/assets/renderElectronMiniChatApp-CDgBwwCS.js +0 -2
- package/dist/assets/renderMobileApp-DJIKIK1r.js +0 -25
- package/dist/assets/runtimeEndpointReset-CYJ9O_xX.js +0 -17
- package/dist/assets/scheduledTasksApi-D8yamh1b.js +0 -1
- package/dist/assets/tr-D5m2yIWL.js +0 -7
- package/dist/assets/uk-D_q60oog.js +0 -16
- package/dist/assets/useInlineCommentController-Brz_cLcQ.js +0 -2
- package/dist/assets/useRootScrollLock-lXEnWlaU.js +0 -1
- package/dist/assets/vendor-ghostty-web-CrxinGGH.js +0 -13
- package/dist/assets/vendor-legendapp-list-gg7YLRW7.js +0 -1
- package/dist/assets/vendor-zod-CK21ihK-.js +0 -39
- package/dist/assets/zh-CN-D8QvsVeg.js +0 -16
- package/dist/assets/zh-TW-B9t7rQQO.js +0 -16
- package/server/lib/mcp-reconnect/DOCUMENTATION.md +0 -55
- package/server/lib/mcp-reconnect/runtime.js +0 -122
- package/server/lib/mcp-reconnect/runtime.test.js +0 -140
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{f as ut,R as s,c as ei,j as n,r as ct}from"./vendor-react-BUCujlKS.js";import{Z as Ua,_ as Ka,$ as qa,a0 as Ha,t as Ye,a as lt,u as wt,dD as Ga,G as ti,A as Xa,h as ri,a5 as ni,e as Ja,dB as Ya,a4 as Qa,dC as Za}from"./index-BD8ILbxF.js";import{f as tr,y as si,ae as Si,b_ as eo,h as q,hU as to,fx as ro,V as gr,B as I,I as F,Y as no,R as so,bd as io,J as ao,ag as oo,ch as lo,en as ii,hV as ai,hW as co,hh as uo,fI as fo,t as J,l as oi,au as Cn,cc as hr,cO as mo,b as ho,hX as pr,bM as po,av as Sn,hY as li,cd as ci,ce as ui,gx as go,hZ as vo,h_ as xo,h$ as wo,bN as ki,bO as Ri,bP as Ti,bQ as Ei,bR as Vi,bS as Pi,ao as Pn,ap as Dn,aw as Gr,ar as Mn,bb as Xr,bT as kn,ax as Rn,c8 as di,a9 as Xt,aa as Jt,ab as Yt,bK as bo,bL as yo,g as Yr,bc as jo,bn as Fo}from"./useAppFontEffects-Cwyhjfl5.js";import{aa as No,K as Co,L as So,M as ko,Q as Ro,R as To}from"./runtimeEndpointReset-BhT_-c52.js";import{c as fi,s as Eo,P as Tn,C as Vo}from"./shikiHighlight-BzXUjlby.js";import{a as Po}from"./vendor-codemirror-state-C9awkmn-.js";import{E as Tt}from"./vendor-codemirror-view-CiLROUVV.js";import{V as Do,J as Mo,F as zo}from"./JsonTreeView-cmAzUTiw.js";import{ensurePierreThemeRegistered as mi,getResolvedShikiTheme as Lo}from"./appThemeRegistry-BK0dHKa6.js";import{V as Ao,W as Io}from"./Virtualizer-CZlLSacm.js";import{V as Oo}from"./Virtualizer-D_a8gKmg.js";import{a as Bo,u as Kr,b as $o,g as _o,h as Wo,i as Uo}from"./scheduledTasksApi-BEuUF_cj.js";import{D as Ko}from"./vendor-react-drawio-Ct3Q0DsD.js";import{I as qo,u as Ho,n as Go}from"./useInlineCommentController-DDkpBEU8.js";import{b as Xo}from"./CodeMirrorCommentWidgets-teB3HmBT.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-B6551dwG.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-BY_5qla_.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-BdA6bdky.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-Cb1YnICj.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"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./web-components-LV3vjTxy.js";import"./computeVirtualFileMetrics-BkiDSlTW.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-BVuH1zH9.js";import"./registerCustomTheme-BBXUCRnG.js";function hi(i){const e=ut.c(41),{containerRef:r,filePath:o,fileContent:w}=i,{t:p}=tr(),b=si(nl),x=si(rl),v=Si(),m=eo(tl),[f,j]=s.useState(null),[N,R]=s.useState(""),[S,E]=s.useState(!1),y=s.useRef(!1),c=s.useRef(null),D=s.useRef(null),[T,M]=s.useState(null);let P;e[0]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{j(null),R(""),E(!1),y.current=!1,D.current=null,M(null)},e[0]=P):P=e[0];const V=P;let k,L;e[1]!==r?(k=()=>{const K=r.current;if(!K)return;const X=()=>{if(y.current)return;const re=window.getSelection(),ge=re?.toString().trim()??"";if(!re||!ge||re.rangeCount===0){V();return}const ne=re.getRangeAt(0);if(!K.contains(ne.commonAncestorContainer)){V();return}const Z=ne.getBoundingClientRect();D.current=ne.cloneRange(),R(ge),j({x:Z.left+Z.width/2,y:Z.top-10})},_=re=>{c.current?.contains(re.target)||y.current&&V()};return document.addEventListener("selectionchange",X),document.addEventListener("pointerdown",_),()=>{document.removeEventListener("selectionchange",X),document.removeEventListener("pointerdown",_)}},L=[r,V],e[1]=r,e[2]=k,e[3]=L):(k=e[2],L=e[3]),s.useEffect(k,L);let B;e[4]!==w?(B=K=>{const X=fe=>w.slice(0,fe).split(`
|
|
2
|
+
`).length,_=Zo,re=(fe,xe)=>{for(const Re of _(fe)){const Ue=w.indexOf(Re,xe);if(Ue>=0)return Ue}return-1},ge=K.length>=8?w.indexOf(K):-1;if(ge>=0){const fe=X(ge);return{start:fe,end:fe+K.split(`
|
|
3
|
+
`).length-1}}const ne=K.split(`
|
|
4
|
+
`).map(Qo).filter(Boolean);if(ne.length===0)return null;const Z=re(ne[0],0);if(Z<0)return null;const ye=X(Z);if(ne.length===1)return{start:ye,end:ye};const ve=re(ne[ne.length-1],Z);return ve<0?null:{start:ye,end:Math.max(ye,X(ve))}},e[4]=w,e[5]=B):B=e[5];const $=B;let ue;e[6]===Symbol.for("react.memo_cache_sentinel")?(ue=()=>{const K=D.current;if(!K){M(null);return}M(to(K))},e[6]=ue):ue=e[6];const de=ue;let Y,Q;e[7]!==S?(Y=()=>{if(!S)return;let K=null;const X=()=>{K===null&&(K=window.requestAnimationFrame(()=>{K=null,de()}))};return document.addEventListener("scroll",X,{capture:!0,passive:!0}),window.addEventListener("resize",X),()=>{K!==null&&window.cancelAnimationFrame(K),document.removeEventListener("scroll",X,{capture:!0}),window.removeEventListener("resize",X)}},Q=[S,de],e[7]=S,e[8]=Y,e[9]=Q):(Y=e[8],Q=e[9]),s.useEffect(Y,Q);let ae;e[10]!==N?(ae=()=>{N&&(E(!0),y.current=!0,de(),window.getSelection()?.removeAllRanges())},e[10]=N,e[11]=ae):ae=e[11];const he=ae;let oe;e[12]!==m||e[13]!==b||e[14]!==v||e[15]!==o||e[16]!==x||e[17]!==$||e[18]!==N?(oe=K=>{const X=b??(x?"draft":null);if(!N||!X||!v){V();return}const _=$(N);m({directory:v,sessionKey:X},{source:"file-quote",fileLabel:o,startLine:_?.start??0,endLine:_?.end??0,code:N,language:"",text:K.trim()}),V(),queueMicrotask(Yo)},e[12]=m,e[13]=b,e[14]=v,e[15]=o,e[16]=x,e[17]=$,e[18]=N,e[19]=oe):oe=e[19];const H=oe;if(!f)return null;let G;e[20]!==S||e[21]!==$||e[22]!==N?(G=S?$(N):null,e[20]=S,e[21]=$,e[22]=N,e[23]=G):G=e[23];const We=G;let te;e[24]!==f.x||e[25]!==f.y?(te={left:f.x,top:f.y,transform:"translate(-50%, -100%)"},e[24]=f.x,e[25]=f.y,e[26]=te):te=e[26];let pe;e[27]!==S||e[28]!==T?(pe=S&&T&&T.length>0?ei.createPortal(n.jsx("div",{className:"pointer-events-none fixed inset-0 z-40",children:T.map(Jo)}),document.body):null,e[27]=S,e[28]=T,e[29]=pe):pe=e[29];let De;e[30]!==S||e[31]!==o||e[32]!==We||e[33]!==he||e[34]!==H||e[35]!==p?(De=S?n.jsx("div",{className:"w-[min(420px,80vw)]",children:n.jsx(qo,{fileLabel:o,lineRange:We?{start:We.start,end:We.end}:void 0,onSave:H,onCancel:V})}):n.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:n.jsx("button",{type:"button",onClick:he,className:q("px-3.5 py-1.5 rounded-full","text-sm font-medium","text-[var(--surface-foreground)]","hover:bg-[var(--interactive-hover)]","transition-colors duration-150"),title:p("chat.textSelection.title.commentOnSelection"),children:p("chat.textSelection.actions.comment")})}),e[30]=S,e[31]=o,e[32]=We,e[33]=he,e[34]=H,e[35]=p,e[36]=De):De=e[36];let be;return e[37]!==te||e[38]!==pe||e[39]!==De?(be=ei.createPortal(n.jsxs("div",{ref:c,className:"fixed z-50",style:te,children:[pe,De]}),document.body),e[37]=te,e[38]=pe,e[39]=De,e[40]=be):be=e[40],be}function Jo(i,e){return n.jsx("div",{className:"oc-chat-comment-rect absolute",style:{left:i.left,top:i.top,width:i.width,height:i.height}},e)}function Yo(){ro()}function Qo(i){return i.trim()}function Zo(i){const e=i.trim();return[e,e.slice(0,32),e.split(" ").slice(0,4).join(" ")].filter(el)}function el(i){return i.length>=8}function tl(i){return i.addDraft}function rl(i){return i.newSessionDraft?.open}function nl(i){return i.currentSessionId}const sl=(i,e)=>{if(!e)return null;const r=Number.parseInt(i.trim(),10);return!Number.isFinite(r)||r<1?null:Math.min(r,e.state.doc.lines)},pi=(i,e)=>{const r=i.state.doc.lineAt(e.main.head);return{lineNumber:r.number,character:e.main.head-r.from+1,selection:e}},gi=(i,e,r)=>{const o=i.state.doc.line(e),w=Math.max(1,Math.min(r,o.length+1)),p=o.from+w-1;i.dispatch({selection:Po.cursor(p),effects:Tt.scrollIntoView(p,{y:"center"})})};function il({open:i,onOpenChange:e,view:r,variant:o="overlay"}){const{t:w}=tr(),[p,b]=s.useState(""),x=s.useRef(null),v=s.useRef(!1),m=s.useRef(null),f=s.useRef(null),j=s.useMemo(()=>sl(p,r),[p,r]);s.useEffect(()=>{!i||!r||(v.current=!1,x.current=pi(r,r.state.selection),b(""))},[i,r]),s.useEffect(()=>{i&&window.requestAnimationFrame(()=>{f.current?.focus(),f.current?.select()})},[i]),s.useEffect(()=>{if(!(!i||!r||!x.current)){if(j===null){const{selection:y}=x.current;r.dispatch({selection:y,effects:Tt.scrollIntoView(y.main.from,{y:"center"})});return}gi(r,j,x.current.character)}},[j,i,r]);const N=s.useCallback(()=>{if(!r||v.current||!x.current)return;const{selection:y}=x.current;r.dispatch({selection:y,effects:Tt.scrollIntoView(y.main.from,{y:"center"})})},[r]),R=s.useCallback(y=>{y||N(),e(y)},[e,N]),S=s.useCallback(()=>{!r||j===null||!x.current||(v.current=!0,gi(r,j,x.current.character),e(!1),r.focus())},[j,e,r]);s.useEffect(()=>{if(!i)return;const y=D=>{const T=m.current,M=D.target;!T||!(M instanceof Node)||T.contains(M)||R(!1)},c=D=>{D.key==="Escape"&&(D.preventDefault(),R(!1))};return document.addEventListener("pointerdown",y,!0),document.addEventListener("keydown",c,!0),()=>{document.removeEventListener("pointerdown",y,!0),document.removeEventListener("keydown",c,!0)}},[R,i,o]);const E=s.useMemo(()=>{if(!r)return w("goToLineDialog.helper.editorUnavailable");if(j===null){const y=x.current??pi(r,r.state.selection);return w("goToLineDialog.helper.currentLineRange",{current:y.lineNumber,max:r.state.doc.lines})}return w("goToLineDialog.helper.goToLine",{line:j})},[j,w,r]);return o==="inline"?i?n.jsxs("div",{ref:m,className:"ml-1 flex h-6 items-center gap-1",children:[n.jsx(gr,{ref:f,type:"number",min:1,step:1,inputMode:"numeric",value:p,onChange:y=>b(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),S())},placeholder:w("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),n.jsx(I,{variant:"outline",size:"xs",onClick:S,disabled:!r||j===null,className:"h-6 px-2",children:w("goToLineDialog.actions.go")})]}):null:n.jsx("div",{ref:m,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",i?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:n.jsxs("div",{className:"min-w-0",children:[n.jsx(gr,{ref:f,type:"number",min:1,step:1,inputMode:"numeric",value:p,onChange:y=>b(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),S())},placeholder:w("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-background/60 typography-ui-label"}),n.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:E})]})})}const al=(i,e)=>{const r=e.trim().toLowerCase(),o=[];if(!r)return o;const w=i.toLowerCase();let p=0;for(;;){const b=w.indexOf(r,p);if(b===-1)break;o.push({start:b,end:b+r.length}),p=b+r.length}return o},Zr="data-md-find",En="data-md-find-current",Di="rounded-[2px] bg-status-warning/30 text-foreground",ol="rounded-[2px] bg-status-warning/60 text-foreground",ll=120,cl=i=>i instanceof Element&&i.hasAttribute(Zr),ul=i=>i.target instanceof Element&&i.target.hasAttribute(Zr)?!0:[...i.addedNodes].some(e=>cl(e)),Mi=i=>{const e=new Set;i.querySelectorAll(`mark[${Zr}]`).forEach(r=>{const o=r.parentNode;o&&(o.replaceChild(document.createTextNode(r.textContent??""),r),e.add(o))}),e.forEach(r=>r.normalize())},dl=(i,e)=>{Mi(i);const r=e.trim().toLowerCase();if(!r)return[];const o=[],w=document.createTreeWalker(i,NodeFilter.SHOW_TEXT,{acceptNode(b){const x=b.parentElement;return!x||x.closest("svg, script, style")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),p=[];for(;w.nextNode();){const b=w.currentNode;b instanceof Text&&p.push(b)}for(const b of p){const x=b.nodeValue??"";if(!x)continue;const v=al(x,r);if(v.length===0)continue;const m=b.parentNode;if(!m)continue;const f=document.createDocumentFragment();let j=0;for(const N of v){N.start>j&&f.appendChild(document.createTextNode(x.slice(j,N.start)));const R=document.createElement("mark");R.setAttribute(Zr,""),R.className=Di,R.textContent=x.slice(N.start,N.end),f.appendChild(R),o.push(R),j=N.end}j<x.length&&f.appendChild(document.createTextNode(x.slice(j))),m.replaceChild(f,b)}return o},vi=({containerRef:i,open:e,onOpenChange:r,focusNonce:o,className:w})=>{const{t:p}=tr(),[b,x]=s.useState(""),[v,m]=s.useState(0),[f,j]=s.useState(0),N=s.useRef(null),R=s.useRef([]),S=s.useRef(b);S.current=b;const E=s.useRef(null),y=s.useRef(null),c=s.useCallback((k,L=!1)=>{const B=i.current;if(!B){R.current=[],m(0),j(0);return}R.current=dl(B,k);const $=R.current.length;m($),j(ue=>!L||$===0?0:Math.min(ue,$-1))},[i]),D=s.useCallback((k,L=!1)=>{E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{E.current=null,c(k,L)},ll)},[c]);s.useEffect(()=>()=>{E.current&&clearTimeout(E.current)},[]);const T=s.useCallback(()=>{r(!1);const k=y.current;y.current=null,k?.isConnected&&k.focus()},[r]);s.useEffect(()=>{const k=i.current;if(!e||!k)return;const L=new MutationObserver(B=>{!S.current.trim()||!B.some(ue=>!ul(ue))||D(S.current,!0)});return L.observe(k,{childList:!0,subtree:!0,characterData:!0}),()=>{L.disconnect(),Mi(k)}},[i,e,D]),s.useEffect(()=>{if(!e)return;const k=document.activeElement;k instanceof HTMLElement&&!y.current&&(y.current=k),N.current?.focus()},[e]),s.useEffect(()=>{e&&o>0&&(N.current?.focus(),N.current?.select())},[e,o]),s.useEffect(()=>{const k=i.current;if(!k||(k.querySelectorAll(`mark[${En}]`).forEach(B=>{B.removeAttribute(En),B.className=Di}),v===0))return;const L=R.current[Math.min(Math.max(f,0),v-1)];L&&(L.setAttribute(En,""),L.className=ol,L.scrollIntoView({block:"nearest"}))},[i,f,v]);const M=s.useCallback(()=>{j(k=>v===0?0:(k+1)%v)},[v]),P=s.useCallback(()=>{j(k=>v===0?0:(k-1+v)%v)},[v]),V=s.useCallback(k=>{k.key==="Enter"?(k.preventDefault(),k.shiftKey?P():M()):k.key==="Escape"&&(k.preventDefault(),T())},[T,M,P]);return e?n.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",w),children:[n.jsx(F,{name:"search",className:"ml-0.5 size-3.5 text-muted-foreground"}),n.jsx(gr,{ref:N,value:b,onChange:k=>{x(k.target.value),D(k.target.value)},onKeyDown:V,placeholder:p("filesView.preview.find.placeholder"),"aria-label":p("filesView.preview.find.placeholder"),className:"h-7 w-40 rounded-md px-2 py-0 text-sm md:w-56"}),n.jsx("span",{className:"min-w-12 px-1 text-center typography-micro text-muted-foreground tabular-nums","aria-live":"polite","aria-label":v>0?p("filesView.preview.find.countAria",{current:f+1,total:v}):p("filesView.preview.find.noMatches"),children:b.trim()&&v===0?p("filesView.preview.find.noMatches"):v>0?`${f+1}/${v}`:""}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:P,title:p("filesView.preview.find.previousAria"),"aria-label":p("filesView.preview.find.previousAria"),disabled:v===0,children:n.jsx(F,{name:"arrow-up",className:"size-3.5"})}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:M,title:p("filesView.preview.find.nextAria"),"aria-label":p("filesView.preview.find.nextAria"),disabled:v===0,children:n.jsx(F,{name:"arrow-down",className:"size-3.5"})}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:T,title:p("filesView.preview.find.closeAria"),"aria-label":p("filesView.preview.find.closeAria"),children:n.jsx(F,{name:"close",className:"size-3.5"})})]}):null},fl=i=>{let e=!0;return{poll:async()=>{if(!e||i.isDirty())return!1;const r=i.getLoadedContent(),o=i.getLoadedRevision();try{const w=await i.readContent();if(!e||i.isDirty()||o!==i.getLoadedRevision())return!1;if(w===r)return!0;const p=await i.readContent();return!e||i.isDirty()||p!==w||o!==i.getLoadedRevision()?!1:(i.applyContent(w),!0)}catch{return!1}},dispose:()=>{e=!1}}},ml=1,hl=(i,e)=>e.size!==i.size||e.mtimeMs!==void 0&&i.mtimeMs!==void 0&&Math.abs(e.mtimeMs-i.mtimeMs)>=ml;function xi(){const i=ut.c(8),[e]=ct.useState(pl),r=ct.useRef(!1);let o;i[0]!==e?(o=v=>{if(v==null){e.cleanUp(),r.current=!1;return}r.current||(r.current=!0,e.setup(v,v.firstElementChild??void 0))},i[0]=e,i[1]=o):o=i[1];const w=o;let p,b;i[2]!==e?(p=()=>()=>{r.current=!1,e.cleanUp()},b=[e],i[2]=e,i[3]=p,i[4]=b):(p=i[3],b=i[4]),ct.useLayoutEffect(p,b);let x;return i[5]!==w||i[6]!==e?(x={virtualizer:e,setScroller:w},i[5]=w,i[6]=e,i[7]=x):x=i[7],x}function pl(){return new Oo}const Qt=new Map,gl=100;function qr(i){const[e,r]=ct.useState(null),o=ct.useRef(null),w=ct.useRef(null),p=ct.useRef(null),b=ct.useCallback((x,v)=>{x&&v instanceof Do&&(p.current={key:i,file:v,node:x});const m=o.current,f=w.current,j=()=>{o.current===m&&(m?.(),f?.())};v?queueMicrotask(j):j()},[i]);return ct.useLayoutEffect(()=>{if(!e||!i)return;const x=Qt.get(i)??{top:0,left:0};let v=!0;const m=()=>p.current?.key===i?p.current.file:null,f=c=>p.current?.key===i?p.current.node.shadowRoot?.querySelector(`[data-line][data-line-index="${c-1}"]`):null,j=()=>{R.disconnect(),S.disconnect()},N=()=>{if(!v)return;const c=m(),D=x.line&&c?.getLinePosition(x.line.number),T=x.line&&f(x.line.number);let M=x.top;x.line&&D&&(M=(c?.top??0)+D.top-x.line.offset),x.line&&T&&(M=e.scrollTop+T.getBoundingClientRect().top-e.getBoundingClientRect().top-x.line.offset),e.scrollTop=M,e.scrollLeft=x.left,(!x.line||T)&&Math.abs(e.scrollTop-M)<1&&Math.abs(e.scrollLeft-x.left)<1&&(v=!1,j())},R=new ResizeObserver(N),S=new MutationObserver(()=>{if(v){for(const c of e.children)R.observe(c);N()}});R.observe(e);for(const c of e.children)R.observe(c);S.observe(e,{childList:!0,subtree:!0});const E=()=>{if(v)return;const c=m(),D=c?.getNumericScrollAnchor(e.scrollTop-(c.top??0)),T=D&&f(D.lineNumber),M=T?T.getBoundingClientRect().top-e.getBoundingClientRect().top:null;if(Qt.delete(i),Qt.set(i,{top:e.scrollTop,left:e.scrollLeft,line:D&&M!==null&&M>=0&&M<e.clientHeight?{number:D.lineNumber,offset:M}:void 0}),Qt.size>gl){const P=Qt.keys().next().value;P!==void 0&&Qt.delete(P)}},y=()=>{v=!1,j()};return o.current=N,w.current=E,N(),e.addEventListener("scroll",E,{passive:!0}),e.addEventListener("wheel",y,{passive:!0}),e.addEventListener("touchstart",y,{passive:!0}),e.addEventListener("pointerdown",y,{passive:!0}),e.addEventListener("keydown",y),()=>{o.current=null,w.current=null,p.current?.key===i&&(p.current=null),j(),e.removeEventListener("scroll",E),e.removeEventListener("wheel",y),e.removeEventListener("touchstart",y),e.removeEventListener("pointerdown",y),e.removeEventListener("keydown",y)}},[i,e]),{setScroller:r,restore:b}}function vl(i){return!(!i.autoSaveEnabled||!i.isDirty||!i.canWrite||i.isSaving||i.fileLoading||i.isNonEditableBinary||!i.selectedFilePath||i.loadedFilePath!==i.selectedFilePath)}function xl(i){return i.selectedFilePath?i.isDirty?!(i.fileLoading||i.loadedFilePath!==i.selectedFilePath||i.isNonEditableBinary||i.draftContent===""&&i.fileContent!==""&&i.loadedFilePath!==i.selectedFilePath):!0:!1}const zi=2e5,wl=i=>{let e=0,r=0;for(let o=0;o<i.length;o++)i.charCodeAt(o)===10&&(o>0&&i.charCodeAt(o-1)===13?e++:r++);return e>r?`\r
|
|
5
|
+
`:`
|
|
6
|
+
`},Li=i=>i.replace(/\r\n/g,`
|
|
7
|
+
`).replace(/\r/g,`
|
|
8
|
+
`),bl=i=>({content:Li(i),lineEnding:wl(i)}),yl=(i,e)=>{const r=Li(i);return e===`\r
|
|
9
|
+
`?r.replace(/\n/g,`\r
|
|
10
|
+
`):r},jl=(i,e)=>e??(i.length>zi?"view":"edit"),Fl=i=>{let e=2166136261;for(let r=0;r<i.length;r++)e^=i.charCodeAt(r),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return`${i.length}:${e.toString(16)}`},Nl='<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 wi(){if(typeof document>"u")return!1;const i=document.documentElement.getAttribute("data-theme");return i==="dark"||!i&&window.matchMedia("(prefers-color-scheme: dark)").matches}const Cl=s.forwardRef(function({xml:e,readOnly:r,className:o,onChange:w},p){const b=s.useRef(e),x=s.useRef(null),v=s.useRef(!1),[m,f]=s.useState(wi),j=s.useRef(e),N=s.useRef(e);N.current!==e&&(N.current=e,j.current=e,b.current=e);const R=s.useRef(m);R.current!==m&&(R.current=m,j.current=b.current);const S=s.useRef(null);s.useEffect(()=>{const c=()=>f(wi());c();const D=new MutationObserver(c);return D.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>D.disconnect()},[]),s.useEffect(()=>{const c=setTimeout(()=>{S.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(c)},[]),s.useImperativeHandle(p,()=>({getXml:()=>b.current}));const E=s.useCallback(()=>{!e&&!v.current&&(v.current=!0,setTimeout(()=>{x.current?.template({})},500))},[e]),y=s.useCallback(c=>{b.current=c.xml,w?.(c.xml)},[w]);return n.jsx("div",{ref:S,className:q("h-full w-full",o),children:n.jsx(Ko,{ref:x,xml:j.current||Nl,autosave:!0,urlParameters:{ui:r?"simple":m?"dark":"kennedy",spin:!0,libraries:!r,chrome:r,nav:r,layers:r,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:E,onAutoSave:y},m?"dark":"light")})}),Sl=i=>{const e=U(i);if(!e)return"";if(e==="/"||/^[A-Za-z]:\/$/.test(e))return e;const r=e.lastIndexOf("/");if(r<0)return e;if(r===0)return"/";const o=e.slice(0,r);return/^[A-Za-z]:$/.test(o)?`${o}/`:o},kl=i=>{const e=ut.c(8),{label:r,iconDataUrl:o}=i,[w,p]=s.useState(!1);let b;e[0]!==r?(b=r.trim().slice(0,1).toUpperCase()||"?",e[0]=r,e[1]=b):b=e[1];const x=b;if(o&&!w){let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f=()=>p(!0),e[2]=f):f=e[2];let j;return e[3]!==o?(j=n.jsx("img",{src:o,alt:"",className:"size-4 rounded-sm",onError:f}),e[3]=o,e[4]=j):j=e[4],j}let v;e[5]===Symbol.for("react.memo_cache_sentinel")?(v=q("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=v):v=e[5];let m;return e[6]!==x?(m=n.jsx("span",{className:v,children:x}),e[6]=x,e[7]=m):m=e[7],m},Rl=i=>i.slice().sort((e,r)=>e.type!==r.type?e.type==="directory"?-1:1:e.name.localeCompare(r.name)),U=i=>{if(!i)return"";const e=i.replace(/\\/g,"/"),r=e.startsWith("//");let o=e.replace(/\/+/g,"/");r&&!o.startsWith("//")&&(o=`/${o}`);const w=o==="/",p=/^[A-Za-z]:\/$/.test(o);return!w&&!p&&(o=o.replace(/\/+$/,"")),o},Tl=i=>i.startsWith("/")||i.startsWith("//")||/^[A-Za-z]:\//.test(i),er=i=>/^[A-Za-z]:\//.test(i)?i.toLowerCase():i,Qr=(i,e)=>{const r=U(e),o=U(i);if(!r||!o)return!1;const w=er(r),p=er(o);return p===w||p.startsWith(`${w}/`)},bi=(i,e)=>{const r=U(e),o=U(i);if(!Qr(o,r))return[];const p=o.slice(r.length).replace(/^\//,"").split("/"),b=[];let x=r;for(let v=0;v<p.length-1;v++)x=x?`${x}/${p[v]}`:p[v],b.push(x);return b},Jr=(i,e)=>{if(!e)return"";const r=U(e);if(!i||!Qr(r,i))return r;const o=r.slice(i.length);return o.startsWith("/")?o.slice(1):o},El=new Set(["node_modules"]),Vl=i=>{const e=ut.c(3),{status:r}=i;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={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]=o):o=e[0];const w=o[r];let p;return e[1]!==w?(p=n.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:w}}),e[1]=w,e[2]=p):p=e[2],p},yi=i=>{const e=ut.c(11),{name:r}=i,o=s.useRef(null),w=s.useRef(null),[p,b]=s.useState(!1);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{const N=o.current,R=w.current;if(!N||!R)return;const S=()=>{b(R.scrollWidth>N.clientWidth+1)};S();const E=new ResizeObserver(S);return E.observe(N),E.observe(R),()=>{E.disconnect()}},e[0]=x):x=e[0];let v;e[1]!==r?(v=[r],e[1]=r,e[2]=v):v=e[2],s.useLayoutEffect(x,v);let m;e[3]!==r?(m=n.jsx("span",{ref:w,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:r}),e[3]=r,e[4]=m):m=e[4];let f;e[5]!==r||e[6]!==p?(f=p?n.jsxs("span",{className:"open-file-name-marquee-track",children:[n.jsx("span",{className:"open-file-name-marquee-item",children:r}),n.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:r})]}):n.jsx("span",{className:"block min-w-0 truncate",children:r}),e[5]=r,e[6]=p,e[7]=f):f=e[7];let j;return e[8]!==m||e[9]!==f?(j=n.jsxs("span",{ref:o,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[m,f]}),e[8]=m,e[9]=f,e[10]=j):j=e[10],j},Pl=i=>El.has(i),Dl=i=>{const e=U(i);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},Ml=i=>{const r=(i instanceof Error?i.message:String(i??"")).toLowerCase();return r.includes("is a directory")||r.includes("eisdir")},ji=i=>{const r=(i instanceof Error?i.message:String(i??"")).toLowerCase();return r.includes("file not found")||r.includes("enoent")||r.includes("no such file")||r.includes("does not exist")},zl=2e5,Ai=(i,e)=>n.jsx(Gr,{filePath:i,extension:e}),Vn=i=>{if(!i)return!1;const e=i.toLowerCase().split(".").pop();return e==="md"||e==="markdown"},Fi=i=>{if(!i)return!1;const e=i.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},Hr=i=>{if(!i)return!1;const e=i.toLowerCase().split(".").pop();return e==="html"||e==="htm"},Ll=i=>{const e=ut.c(76),{node:r,root:o,isExpanded:w,isActive:p,isMobile:b,isBrowserClient:x,alwaysShowActions:v,status:m,badge:f,permissions:j,downloadFile:N,contextMenuPath:R,setContextMenuPath:S,rightClickMenuPath:E,setRightClickMenuPath:y,onSelect:c,onToggle:D,onRevealPath:T,onOpenDialog:M}=i,{t:P}=tr(),V=r.type==="directory",{canRename:k,canCreateFile:L,canCreateFolder:B,canDelete:$,canReveal:ue}=j,de=!V&&!!N,Y=ue&&!x,Q=k||L||B||$||de||Y;let ae;e[0]!==Q||e[1]!==r.path||e[2]!==y?(ae=Te=>{Q&&(Te?.preventDefault(),y(r.path))},e[0]=Q,e[1]=r.path,e[2]=y,e[3]=ae):ae=e[3];const he=ae;let oe;e[4]!==V||e[5]!==r||e[6]!==c||e[7]!==D?(oe=()=>{V?D(r.path):c(r)},e[4]=V,e[5]=r,e[6]=c,e[7]=D,e[8]=oe):oe=e[8];const H=oe;let G;e[9]!==r.path||e[10]!==S||e[11]!==y?(G=Te=>{Te.stopPropagation(),y(null),S(r.path)},e[9]=r.path,e[10]=S,e[11]=y,e[12]=G):G=e[12];const We=G;let te;e[13]!==L||e[14]!==B||e[15]!==$||e[16]!==k||e[17]!==Y||e[18]!==N||e[19]!==x||e[20]!==V||e[21]!==r||e[22]!==M||e[23]!==T||e[24]!==o||e[25]!==P?(te=Te=>{const{Item:Ie,Separator:Vt}=Te;return n.jsxs(n.Fragment,{children:[k&&n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),M("rename",r)},children:[n.jsx(F,{name:"edit",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.rename")]}),n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),Yr(r.path).then(Qe=>{if(Qe.ok){J.success(P("sidebarFilesTree.toast.pathCopied"));return}J.error(P("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(F,{name:"file-copy",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.copyPath")]}),n.jsxs(Ie,{onClick:le=>{le.stopPropagation();const Qe=Jr(o,r.path)||r.path;Yr(Qe).then(Pt=>{if(Pt.ok){J.success(P("filesView.toast.relativePathCopied"));return}J.error(P("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(F,{name:"file-copy-2",className:"mr-2 size-4"})," ",P("filesView.tree.menu.copyRelativePath")]}),!V&&N&&n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),N(r.path).catch(Qe=>{console.error("Download failed:",Qe),J.error(P("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(F,{name:"download",className:"mr-2 size-4"})," ",P(x?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),Y&&n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),T(r.path)},children:[n.jsx(F,{name:"folder-received",className:"mr-2 size-4"})," ",P(Fo())]}),V&&(L||B)&&n.jsxs(n.Fragment,{children:[n.jsx(Vt,{}),L&&n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),M("createFile",r)},children:[n.jsx(F,{name:"file-add",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.newFile")]}),B&&n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),M("createFolder",r)},children:[n.jsx(F,{name:"folder-add",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.newFolder")]})]}),$&&n.jsxs(n.Fragment,{children:[n.jsx(Vt,{}),n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),M("delete",r)},className:"text-destructive focus:text-destructive",children:[n.jsx(F,{name:"delete-bin",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.delete")]})]})]})},e[13]=L,e[14]=B,e[15]=$,e[16]=k,e[17]=Y,e[18]=N,e[19]=x,e[20]=V,e[21]=r,e[22]=M,e[23]=T,e[24]=o,e[25]=P,e[26]=te):te=e[26];const pe=te,De=E===r.path;let be;e[27]!==r.path||e[28]!==y?(be=Te=>y(Te?r.path:null),e[27]=r.path,e[28]=y,e[29]=be):be=e[29];const K=b?void 0:he;let X;e[30]!==K?(X=n.jsx("div",{className:"group relative flex items-center",onContextMenu:K}),e[30]=K,e[31]=X):X=e[31];const _=b?void 0:he,re=p?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let ge;e[32]!==re?(ge=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",re),e[32]=re,e[33]=ge):ge=e[33];let ne;e[34]!==V||e[35]!==w||e[36]!==r.extension||e[37]!==r.path?(ne=V?w?n.jsx(F,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):n.jsx(F,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):Ai(r.path,r.extension),e[34]=V,e[35]=w,e[36]=r.extension,e[37]=r.path,e[38]=ne):ne=e[38];let Z;e[39]!==r.name||e[40]!==r.path?(Z=n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:r.path,children:r.name}),e[39]=r.name,e[40]=r.path,e[41]=Z):Z=e[41];let ye;e[42]!==V||e[43]!==m?(ye=!V&&m&&n.jsx(Vl,{status:m}),e[42]=V,e[43]=m,e[44]=ye):ye=e[44];let ve;e[45]!==f||e[46]!==V?(ve=V&&f&&n.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[f.modified>0&&n.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",f.modified]}),f.added>0&&n.jsxs("span",{className:"text-[var(--status-success)]",children:["+",f.added]})]}),e[45]=f,e[46]=V,e[47]=ve):ve=e[47];let fe;e[48]!==H||e[49]!==ge||e[50]!==ne||e[51]!==Z||e[52]!==ye||e[53]!==ve||e[54]!==_?(fe=n.jsxs("button",{type:"button",onClick:H,onContextMenu:_,className:ge,children:[ne,Z,ye,ve]}),e[48]=H,e[49]=ge,e[50]=ne,e[51]=Z,e[52]=ye,e[53]=ve,e[54]=_,e[55]=fe):fe=e[55];let xe;e[56]!==v||e[57]!==R||e[58]!==We||e[59]!==Q||e[60]!==b||e[61]!==r.path||e[62]!==pe||e[63]!==S?(xe=Q&&n.jsx("div",{className:q("absolute right-1 top-1/2 -translate-y-1/2",v?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:n.jsxs(Pn,{open:R===r.path,onOpenChange:Te=>S(Te?r.path:null),children:[n.jsx(Dn,{asChild:!0,children:n.jsx(I,{variant:"ghost",size:"icon",className:"size-6",onClick:We,children:n.jsx(F,{name:"more-2-fill",className:"size-4"})})}),n.jsx(Mn,{align:"end",side:"bottom",onCloseAutoFocus:()=>S(null),children:pe({Item:Xr,Separator:jo})})]})}),e[56]=v,e[57]=R,e[58]=We,e[59]=Q,e[60]=b,e[61]=r.path,e[62]=pe,e[63]=S,e[64]=xe):xe=e[64];let Re;e[65]!==fe||e[66]!==xe||e[67]!==X?(Re=n.jsxs(Ro,{render:X,children:[fe,xe]}),e[65]=fe,e[66]=xe,e[67]=X,e[68]=Re):Re=e[68];let Ue;e[69]!==pe?(Ue=n.jsx(Co,{className:"min-w-[180px]",children:pe({Item:ko,Separator:So})}),e[69]=pe,e[70]=Ue):Ue=e[70];let Et;return e[71]!==Re||e[72]!==Ue||e[73]!==De||e[74]!==be?(Et=n.jsxs(To,{open:De,onOpenChange:be,children:[Re,Ue]}),e[71]=Re,e[72]=Ue,e[73]=De,e[74]=be,e[75]=Et):Et=e[75],Et},Al=i=>{const e=ut.c(83),{activeDialog:r,dialogData:o,dialogInputValue:w,onDialogInputChange:p,isDialogSubmitting:b,onDialogSubmit:x,onClose:v,inputRef:m}=i,{t:f}=tr(),j=!!r;let N;e[0]!==v?(N=G=>!G&&v(),e[0]=v,e[1]=N):N=e[1];let R;e[2]!==r||e[3]!==f?(R=r==="createFile"&&f("filesView.dialog.createFile.title"),e[2]=r,e[3]=f,e[4]=R):R=e[4];let S;e[5]!==r||e[6]!==f?(S=r==="createFolder"&&f("filesView.dialog.createFolder.title"),e[5]=r,e[6]=f,e[7]=S):S=e[7];let E;e[8]!==r||e[9]!==f?(E=r==="rename"&&f("filesView.dialog.rename.title"),e[8]=r,e[9]=f,e[10]=E):E=e[10];let y;e[11]!==r||e[12]!==f?(y=r==="delete"&&f("filesView.dialog.delete.title"),e[11]=r,e[12]=f,e[13]=y):y=e[13];let c;e[14]!==R||e[15]!==S||e[16]!==E||e[17]!==y?(c=n.jsxs(Ei,{children:[R,S,E,y]}),e[14]=R,e[15]=S,e[16]=E,e[17]=y,e[18]=c):c=e[18];let D;e[19]!==r||e[20]!==o?.path||e[21]!==f?(D=r==="createFile"&&f("filesView.dialog.createFile.description",{path:o?.path??f("filesView.dialog.rootFallback")}),e[19]=r,e[20]=o?.path,e[21]=f,e[22]=D):D=e[22];let T;e[23]!==r||e[24]!==o?.path||e[25]!==f?(T=r==="createFolder"&&f("filesView.dialog.createFolder.description",{path:o?.path??f("filesView.dialog.rootFallback")}),e[23]=r,e[24]=o?.path,e[25]=f,e[26]=T):T=e[26];let M;e[27]!==r||e[28]!==o?.name||e[29]!==f?(M=r==="rename"&&f("filesView.dialog.rename.description",{name:o?.name??""}),e[27]=r,e[28]=o?.name,e[29]=f,e[30]=M):M=e[30];let P;e[31]!==r||e[32]!==o?.name||e[33]!==f?(P=r==="delete"&&f("filesView.dialog.delete.description",{name:o?.name??""}),e[31]=r,e[32]=o?.name,e[33]=f,e[34]=P):P=e[34];let V;e[35]!==M||e[36]!==P||e[37]!==D||e[38]!==T?(V=n.jsxs(Vi,{children:[D,T,M,P]}),e[35]=M,e[36]=P,e[37]=D,e[38]=T,e[39]=V):V=e[39];let k;e[40]!==V||e[41]!==c?(k=n.jsxs(Ti,{children:[c,V]}),e[40]=V,e[41]=c,e[42]=k):k=e[42];let L;e[43]!==r||e[44]!==w||e[45]!==m||e[46]!==p||e[47]!==x||e[48]!==f?(L=r!=="delete"&&n.jsx("div",{className:"py-4",children:n.jsx(gr,{value:w,onChange:G=>p(G.target.value),placeholder:f(r==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:G=>{G.key==="Enter"&&x()},ref:m})}),e[43]=r,e[44]=w,e[45]=m,e[46]=p,e[47]=x,e[48]=f,e[49]=L):L=e[49];let B;e[50]!==f?(B=f("filesView.dialog.cancel"),e[50]=f,e[51]=B):B=e[51];let $;e[52]!==b||e[53]!==v||e[54]!==B?($=n.jsx(I,{variant:"outline",onClick:v,disabled:b,children:B}),e[52]=b,e[53]=v,e[54]=B,e[55]=$):$=e[55];const ue=r==="delete"?"destructive":"default";let de;e[56]!==x?(de=()=>{x()},e[56]=x,e[57]=de):de=e[57];let Y;e[58]!==r||e[59]!==w||e[60]!==b?(Y=b||r!=="delete"&&!w.trim(),e[58]=r,e[59]=w,e[60]=b,e[61]=Y):Y=e[61];let Q;e[62]!==r||e[63]!==b||e[64]!==f?(Q=b?n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):f(r==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=r,e[63]=b,e[64]=f,e[65]=Q):Q=e[65];let ae;e[66]!==ue||e[67]!==de||e[68]!==Y||e[69]!==Q?(ae=n.jsx(I,{variant:ue,onClick:de,disabled:Y,children:Q}),e[66]=ue,e[67]=de,e[68]=Y,e[69]=Q,e[70]=ae):ae=e[70];let he;e[71]!==$||e[72]!==ae?(he=n.jsxs(Pi,{children:[$,ae]}),e[71]=$,e[72]=ae,e[73]=he):he=e[73];let oe;e[74]!==m||e[75]!==k||e[76]!==L||e[77]!==he?(oe=n.jsxs(Ri,{initialFocus:m,children:[k,L,he]}),e[74]=m,e[75]=k,e[76]=L,e[77]=he,e[78]=oe):oe=e[78];let H;return e[79]!==j||e[80]!==N||e[81]!==oe?(H=n.jsx(ki,{open:j,onOpenChange:N,children:oe}),e[79]=j,e[80]=N,e[81]=oe,e[82]=H):H=e[82],H},Zt=new Map,Il=100,Ni=i=>{const e=ut.c(13);let r,o,w;e[0]!==i?({positionKey:o,onViewReady:r,...w}=i,e[0]=i,e[1]=r,e[2]=o,e[3]=w):(r=e[1],o=e[2],w=e[3]);const p=s.useRef(null);let b,x;e[4]!==o?(b=()=>()=>{const f=p.current;if(!f)return;const{anchor:j,head:N}=f.state.selection.main;if(Zt.delete(o),Zt.set(o,{scroll:f.scrollSnapshot(),anchor:j,head:N}),Zt.size>Il){const R=Zt.keys().next().value;R!==void 0&&Zt.delete(R)}},x=[o],e[4]=o,e[5]=b,e[6]=x):(b=e[5],x=e[6]),s.useLayoutEffect(b,x);let v;e[7]!==r||e[8]!==o?(v=f=>{p.current=f;const j=Zt.get(o);j&&f.dispatch({selection:{anchor:Math.min(j.anchor,f.state.doc.length),head:Math.min(j.head,f.state.doc.length)},effects:j.scroll}),r?.(f)},e[7]=r,e[8]=o,e[9]=v):v=e[9];let m;return e[10]!==w||e[11]!==v?(m=n.jsx(Vo,{...w,onViewReady:v}),e[10]=w,e[11]=v,e[12]=m):m=e[12],m},Ci=(i,e,r)=>{const o=ut.c(8),[w,p]=s.useState(""),[b,x]=s.useState(0);let v,m;o[0]!==i||o[1]!==r||o[2]!==e?(v=()=>{if(!i){p("");return}let j=!1;p("");const N=Ja(),R=Ya(N);Qa(N).then(E=>{j||!E||(p(i),e(null))}).catch(E=>{j||(e(E instanceof Error?E.message:r),p(i))});const S=Za(()=>{j||(p(i),x(Ol),e(null))});return()=>{j=!0,R(),S()}},m=[i,e,r],o[0]=i,o[1]=r,o[2]=e,o[3]=v,o[4]=m):(v=o[3],m=o[4]),s.useEffect(v,m);let f;return o[5]!==b||o[6]!==w?(f={readyKey:w,nonce:b},o[5]=b,o[6]=w,o[7]=f):f=o[7],f},sd=({mode:i="full",visible:e=!0})=>{const{t:r}=tr(),{files:o,runtime:w}=no(),{currentTheme:p,availableThemes:b,lightThemeId:x,darkThemeId:v}=so(),{isMobile:m,isTablet:f,screenWidth:j}=io(),N=Ua(w.platform),R=m||f,S=Ka(),E=qa(),y=Si()??"",c=U(y.trim()),D=m||i==="full",T=D&&e,M=ao(t=>t.runtimeKey),P=JSON.stringify([M,c]),V=s.useRef(P);V.current=P;const k=JSON.stringify([M,c,S,E]),L=s.useRef(k);L.current=k;const B=i!=="editor-only",$=i==="editor-only"&&!m,ue=Ha(t=>t.searchFiles),de=oo(T?y:null),[Y,Q]=s.useState(""),ae=lo(Y,200),he=s.useRef(null),[oe,H]=s.useState(!1),[G,We]=s.useState(!0),[te,pe]=s.useState(!1),[De,be]=s.useState(!1),K=s.useRef(0),X=s.useCallback(t=>{K.current=Math.max(0,K.current+(t?1:-1))},[]),[_,re]=s.useState("edit"),[ge,ne]=s.useState("edit"),[Z,ye]=s.useState("tree"),[ve,fe]=s.useState("edit"),[xe,Re]=s.useState("preview"),[Ue,Et]=s.useState(0),Te=s.useRef({}),Ie=s.useRef({}),Vt=s.useRef({}),le=s.useRef({}),Qe=s.useMemo(()=>b.find(t=>t.metadata.id===x)??ii(!1),[b,x]),Pt=s.useMemo(()=>b.find(t=>t.metadata.id===v)??ii(!0),[b,v]);s.useEffect(()=>{mi(Qe),mi(Pt)},[Qe,Pt]);const vr=s.useMemo(()=>[],[]),je=Ye(t=>c?t.byRoot[c]?.openPaths??vr:vr),bt=Ye(t=>c?t.byRoot[c]?.selectedPath??null:null),Ze=Ye(t=>c?t.byRoot[c]?.expandedPaths??vr:vr),Ii=s.useMemo(()=>new Set(Ze),[Ze]),Dt=Ye(t=>t.removeOpenPath),dt=Ye(t=>t.removeOpenPathsByPrefix),zn=Ye(t=>t.removeExpandedPathsByPrefix),Fe=Ye(t=>t.setSelectedPath),Ln=Ye(t=>t.toggleExpandedPath),xr=Ye(t=>t.expandPaths),Mt=s.useCallback(t=>{const a=U(t),l=a.split("/"),d=l[l.length-1]||a,h=d.includes(".")?d.split(".").pop()?.toLowerCase():void 0;return{name:d,path:a,type:"file",extension:h}},[]),zt=s.useMemo(()=>je.map(Mt),[je,Mt]),en=s.useMemo(()=>{if(bt){const t=er(bt);if(je.some(a=>er(a)===t))return bt}return je[0]??null},[je,bt]),u=s.useMemo(()=>en?Mt(en):null,[en,Mt]),Ke=u?.path??"",[,Oi]=s.useState(0);s.useEffect(()=>{if(!c||!bt)return;const t=er(bt);je.some(l=>er(l)===t)||Fe(c,je[0]??null)},[je,c,bt,Fe]);const wr=!!(c&&Ke&&!Qr(Ke,c)),An=wr?ai(Ke):void 0,yt=s.useMemo(()=>({allowOutsideWorkspace:i==="editor-only"&&wr,outsideFileGrant:An,directory:c||void 0}),[i,wr,An,c]),et=s.useCallback(async t=>{const a=ai(t),l=await co(t,c,i==="editor-only");return l.outsideFileGrant&&l.outsideFileGrant!==a&&Oi(d=>d+1),l},[i,c]),tn=s.useRef(null),[In,Bi]=s.useState({left:!1,right:!1}),On=s.useCallback(()=>{const t=tn.current;t&&Bi({left:t.scrollLeft>2,right:t.scrollLeft+t.clientWidth<t.scrollWidth-2})},[]),Bn=s.useRef(On);Bn.current=On,s.useEffect(()=>{const t=tn.current;if(!t)return;const a=()=>Bn.current();a(),t.addEventListener("scroll",a,{passive:!0});const l=new ResizeObserver(a);return l.observe(t),()=>{t.removeEventListener("scroll",a),l.disconnect()}},[zt.length]);const[$n,rn]=s.useState({}),[br,rr]=s.useState({}),Oe=s.useRef(new Set),Ee=s.useMemo(()=>new Bo,[]);s.useEffect(()=>()=>Ee.clear(),[Ee]);const[_n,yr]=s.useState([]),[$i,jr]=s.useState(!1),[O,me]=s.useState(""),{isPlaying:Fr,play:_i,stop:Wi}=uo(),[Me,ft]=s.useState(!1),[tt,we]=s.useState(null),[Ui,Be]=s.useState(""),[Ne,ce]=s.useState(null),mt=JSON.stringify([lt(),c,Ne]),[ee,Ce]=s.useState(""),[nr,nn]=s.useState(!1),[Wn,Ki]=s.useState(`
|
|
11
|
+
`),qi=s.useRef(null),rt=s.useRef(null),ze=s.useRef(null),ht=s.useRef(""),sr=s.useRef(""),st=s.useRef(null),Un=s.useRef(null),qe=s.useRef(null),sn=s.useRef(""),an=s.useRef(0),Lt=s.useRef(0),jt=s.useRef(null),[Nr,Hi]=s.useState(0),[Gi,At]=s.useState("idle"),[Xi,Cr]=s.useState(!1),[Ft,Kn]=s.useState(!1),Se=wt(t=>t.autoSaveEnabled),Ji=wt(t=>t.setAutoSaveEnabled),[on,ir]=s.useState(!1),It=s.useRef(null),ar=s.useRef(null),or=s.useRef(!1),lr=s.useRef(null),cr=s.useRef(null),He=s.useRef(null),Sr=s.useRef(null),[Yi,ln]=s.useState(0),Ot=s.useRef(null),Nt=s.useRef({key:"",attempts:0});s.useEffect(()=>()=>{Ot.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(Ot.current),Ot.current=null)},[]);const[Ct,cn]=s.useState(null),[St,Qi]=s.useState(null),[pt,qn]=s.useState(""),[Zi,un]=s.useState(!1),[ea,ta]=s.useState(null),[ra,na]=s.useState(null),[sa,Hn]=s.useState(!1),[ia,Gn]=s.useState(!1),[aa,dn]=s.useState(!1),[Xn,kr]=s.useState(!1),[Jn,Yn]=s.useState(0),Rr=s.useRef(null),Tr=s.useCallback(t=>{const a=t?.currentTarget??Rr.current;if(!a)return;const l=document.activeElement;l&&l!==document.body&&l!==a&&(fo(l)||a.contains(l))||a.focus({preventScroll:!0})},[]),Er=s.useRef(null),Qn=!!o.writeFile,Zn=!!o.createDirectory,es=!!o.rename,ts=!!o.delete,rs=!!o.revealPath,oa=Kr(t=>t.availableApps),la=Kr(t=>t.isCacheStale),ns=Kr(t=>t.initialize),ca=Kr(t=>t.loadInstalledApps);s.useEffect(()=>{ns()},[ns]);const ua=s.useCallback(t=>{o.revealPath&&o.revealPath(t).catch(()=>{J.error(r("sidebarFilesTree.toast.revealFailed"))})},[o,r]),da=s.useCallback(async t=>{if(!u?.path||await Ga(u.path,t.id,t.appName)||await ti(u.path,t.appName))return;const d=Sl(u.path)||c;d&&await ti(d,t.appName)||J.error(r("filesView.toast.openInAppFailed",{app:t.appName}))},[c,u?.path,r]),fn=s.useCallback((t,a)=>{cn(t),Qi(a),qn(t==="rename"&&a.name||""),un(!1)},[]),[W,Ge]=s.useState(null),Bt=s.useRef(!1),gt=s.useRef(null),[ss,$t]=s.useState(!1),nt=wt(t=>t.pendingFileNavigation),Vr=wt(t=>t.setPendingFileNavigation),mn=wt(t=>t.pendingFileFocusPath),hn=wt(t=>t.setPendingFileFocusPath),is=wt(t=>t.fileEditorKeymap),ur=oi(t=>t.settingsDefaultFileViewerPreview),fa=oi(t=>t.showMessageTTSButtons);s.useEffect(()=>{const t=()=>{Bt.current=!1,gt.current=null,$t(!1)};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]),s.useEffect(()=>()=>{lr.current!==null&&window.clearTimeout(lr.current),cr.current!==null&&window.clearTimeout(cr.current)},[]);const ma=s.useCallback((t,a)=>{const l=t.split(`
|
|
12
|
+
`),d=Math.max(1,a.start),h=Math.min(l.length,a.end);return d>h?"":l.slice(d-1,h).join(`
|
|
13
|
+
`)},[]),as=s.useRef(null),ha=Ho({source:"file",fileLabel:u?.path??null,language:u?.path&&Cn(u.path)||"text",getCodeForRange:t=>ma(O,Go(t)),toStoreRange:t=>({startLine:t.start,endLine:t.end}),fromDraftRange:t=>({start:t.startLine,end:t.endLine})}),{drafts:os,commentText:Pr,setCommentText:ls,editingDraftId:Dr,setSelection:cs,saveComment:us,cancel:dr,reset:ds,startEdit:fs,deleteDraft:ms}=ha;s.useEffect(()=>{Ge(null),ds(),Ce(""),nn(!1)},[u?.path,ds]),s.useEffect(()=>{cs(W)},[W,cs]),s.useEffect(()=>{if(!W&&!Dr)return;const t=l=>{const d=l.target;d.closest('[data-comment-input="true"]')||d.closest('[data-comment-card="true"]')||d.closest(".cm-gutterElement")||d.closest("[data-sonner-toast]")||d.closest("[data-sonner-toaster]")||Pr.trim()||(Ge(null),dr())},a=setTimeout(()=>{document.addEventListener("click",t)},100);return()=>{clearTimeout(a),document.removeEventListener("click",t)}},[dr,Pr,Dr,W]);const hs=s.useCallback((t,a)=>{const l=a??W??void 0;a&&Ge(a),us(t,l),Ge(null)},[W,us]),ps=s.useCallback((t,a)=>{const l=[];for(const d of a){if(!(d&&typeof d.name=="string"&&d.name.length>0)||!S&&d.name.startsWith(".")||!E&&Pl(d.name))continue;const h=d.name,g=U(d.path||""),C=g?Tl(g)?g:U(`${t}/${g}`):U(`${t}/${h}`),A=d.isDirectory?"directory":"file",se=A==="file"&&h.includes(".")?h.split(".").pop()?.toLowerCase():void 0;l.push({name:h,path:C,type:A,extension:se})}return Rl(l)},[E,S]),Ve=s.useCallback(async(t,a=!1)=>{if(!T)return;const l=U(t.trim());if(!l||!a&&Oe.current.has(l))return;const d=L.current,h=lt();return Ee.run(l,async g=>{const C=()=>g()&&L.current===d&<()===h;try{const A=o.listDirectory?(await o.listDirectory(l)).entries:await Xa.listLocalDirectory(l);if(!C())return;const se=ps(l,A);Oe.current=new Set(Oe.current),Oe.current.add(l),rr(z=>{if(!z[l])return z;const ie={...z};return delete ie[l],ie}),rn(z=>z[l]&&$o(z[l],se)?z:{...z,[l]:se})}catch(A){if(!C())return;const se=A instanceof Error?A.message:String(A??"");if(se==="Directory not found"&&c&&l!==c){zn(c,l),rr(z=>{if(!z[l])return z;const ie={...z};return delete ie[l],ie});return}console.error("Failed to load files directory:",A),rr(z=>({...z,[l]:se}))}},a)},[Ee,o,ps,zn,c,T]),Mr=s.useCallback(async()=>{c&&(Oe.current=new Set,Ee.clear(),rr({}),rn(t=>Object.keys(t).length===0?t:{}),await Ve(c))},[Ee,Ve,c]),$e=s.useCallback(async t=>{if(!t){await Mr();return}const a=U(t);Oe.current=new Set(Oe.current),Oe.current.delete(a),await Ve(a,!0)},[Ve,Mr]),gs=s.useRef(""),vs=s.useRef("");s.useEffect(()=>{if(!c)return;const t=k,a=gs.current!==P,l=vs.current!==t;!a&&!l||(a&&(gs.current=P,Lt.current+=1,jt.current=null,me(""),we(null),Be(""),ce(null),H(!1)),l&&(vs.current=t,Oe.current=new Set,Ee.clear(),rr({}),rn(d=>Object.keys(d).length===0?d:{}),Ve(c)))},[Ee,P,Ve,c,k]),s.useEffect(()=>{if(!T||!o.listDirectory)return;const t=()=>{if(!document.hidden&&Ze.length>0)for(const a of Ze)Ee.has(a)||$e(a)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[Ee,Ze,o.listDirectory,$e,T]);const xs=s.useRef(!1);s.useEffect(()=>{const t=T&&!xs.current;if(xs.current=T,!(!T||!c)&&(Ve(c),t))for(const a of Ze)Ee.has(a)||$e(a)},[Ee,Ze,Ve,$e,c,T]),s.useEffect(()=>{if(!T||!o.listDirectory||Ze.length===0)return;const t=setInterval(()=>{if(!document.hidden)for(const a of Ze)Ee.has(a)||$e(a)},8e3);return()=>clearInterval(t)},[Ee,Ze,o.listDirectory,$e,T]);const pa=s.useCallback(async t=>{if(t?.preventDefault(),!St||!Ct)return;un(!0);const a=()=>{cn(null)},l=h=>{J.error(h)},d=()=>{un(!1)};if(Ct==="createFile"){if(!pt.trim()){l(r("sidebarFilesTree.toast.filenameRequired")),d();return}if(!o.writeFile){l(r("sidebarFilesTree.toast.writeNotSupported")),d();return}const h=St.path,g=h?`${h}/`:"",C=U(`${g}${pt.trim()}`);await o.writeFile(C,"").then(async A=>{A.success&&(J.success(r("sidebarFilesTree.toast.fileCreated")),await $e(h)),a()}).catch(()=>l(r("sidebarFilesTree.toast.operationFailed"))).finally(d);return}if(Ct==="createFolder"){if(!pt.trim()){l(r("sidebarFilesTree.toast.folderNameRequired")),d();return}const h=St.path,g=h?`${h}/`:"",C=U(`${g}${pt.trim()}`);await o.createDirectory(C).then(async A=>{A.success&&(J.success(r("sidebarFilesTree.toast.folderCreated")),await $e(h)),a()}).catch(()=>l(r("sidebarFilesTree.toast.operationFailed"))).finally(d);return}if(Ct==="rename"){if(!pt.trim()){l(r("sidebarFilesTree.toast.nameRequired")),d();return}if(!o.rename){l(r("sidebarFilesTree.toast.renameNotSupported")),d();return}const h=St.path,g=h.split("/").slice(0,-1).join("/"),C=g?`${g}/`:"",A=U(`${C}${pt.trim()}`);await o.rename(h,A).then(async se=>{se.success&&(J.success(r("sidebarFilesTree.toast.renamedSuccessfully")),await $e(g),c&&dt(c,h),(u?.path===h||u?.path.startsWith(`${h}/`))&&(c&&Fe(c,null),me(""),we(null),Be(""),ce(null),m&&H(!1))),a()}).catch(()=>l(r("sidebarFilesTree.toast.operationFailed"))).finally(d);return}if(Ct==="delete"){if(!o.delete){l(r("sidebarFilesTree.toast.deleteNotSupported")),d();return}const h=St.path,g=h.split("/").slice(0,-1).join("/");await o.delete(h).then(async C=>{C.success&&(J.success(r("sidebarFilesTree.toast.deletedSuccessfully")),await $e(g),c&&dt(c,h),(u?.path===h||u?.path.startsWith(`${h}/`))&&(c&&Fe(c,null),me(""),we(null),Be(""),ce(null),m&&H(!1))),a()}).catch(()=>l(r("sidebarFilesTree.toast.operationFailed"))).finally(d);return}d()},[Ct,St,pt,o,$e,m,dt,c,u?.path,Fe,r]);s.useEffect(()=>{if(!y){yr([]),jr(!1);return}const t=ae.trim();if(!t){yr([]),jr(!1);return}let a=!1;return jr(!0),ue(y,t,150,{includeHidden:S,respectGitignore:!E,type:"file"}).then(l=>{if(a)return;const h=l.filter(g=>E||!Dl(g.path)).map(g=>({name:g.name,path:U(g.path),type:"file",extension:g.extension,relativePath:g.relativePath}));yr(h)}).catch(()=>{a||yr([])}).finally(()=>{a||jr(!1)}),()=>{a=!0}},[y,ae,ue,S,E]);const zr=s.useCallback(async(t,a)=>{const l=await et(t);if(o.readFile)return(await o.readFile(t,{...l,directory:c||void 0,...a})).content??"";const d=new URLSearchParams({path:t});l.allowOutsideWorkspace&&d.set("allowOutsideWorkspace","true"),l.outsideFileGrant&&d.set("outsideFileGrant",l.outsideFileGrant),c&&d.set("directory",c);const h=await ri(`/api/fs/read?${d.toString()}`,a?.fresh?{cache:"no-store"}:void 0);if(!h.ok){const g=await h.json().catch(()=>({error:h.statusText}));throw new Error(g.error||r("filesView.error.readFileFailed"))}return h.text()},[o,et,c,r]),vt=s.useCallback(async t=>{if(o.statFile){const a=await et(t),l=await o.statFile(t,{...a,directory:c||void 0});return{path:l.path,size:l.size,mtimeMs:l.mtimeMs}}return null},[o,et,c]);s.useEffect(()=>{if(!c||!o.statFile||je.length===0)return;let t=!1;const a=[...je];return Promise.all(a.map(async l=>{try{const d=await et(l),h=await o.statFile?.(l,{...d,directory:c||void 0});!t&&h&&!h.isFile&&dt(c,l)}catch(d){!t&&ji(d)&&dt(c,l)}})),()=>{t=!0}},[o,je,dt,et,c]);const Le=ee!==O,_t=s.useCallback(async()=>{if(!u||!o.writeFile)return J.error(r("filesView.toast.savingNotSupported")),!1;const t=hr(u.path)||Ft;if(!xl({selectedFilePath:u.path,loadedFilePath:Ne,fileLoading:Me,isDirty:Le,draftContent:ee,fileContent:O,isNonEditableBinary:t}))return t?console.warn(`[saveDraft] refusing to save binary file "${u.path}".`):ee===""&&O!==""&&Ne!==u.path&&console.warn(`[saveDraft] refusing to save empty draft for "${u.path}" (${O.length} bytes were expected). The file may have been read during a concurrent write (O_TRUNC race). Try again after content finishes loading if the save was intentional.`),!1;if(!Le)return!0;nn(!0);try{const a=yl(ee,Wn);if(!(await o.writeFile(u.path,a))?.success)return J.error(r("filesView.toast.writeFileFailed")),!1;if(me(ee),sn.current=a,an.current+=1,c&&Qr(u.path,c)){const d=Jr(c,u.path);d&&mo.requestGitRefresh({directory:c,paths:[d]})}if(c&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(U(u.path))){const d=ho.getState().projects.find(h=>U(h.path)===U(c));if(d)try{await _o(d.id)}catch{J.error(r("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return u?.path&&pr(u.path)&&(ht.current=ee,sr.current=ee),vt(u.path).then(d=>{d&&(qe.current=d)}).catch(()=>{}),!0}catch(a){return J.error(a instanceof Error?a.message:r("filesView.toast.saveFailed")),!1}finally{nn(!1)}},[Ft,ee,O,Me,o,Le,Wn,Ne,vt,c,u,r]);s.useEffect(()=>{Se||(At("idle"),rt.current&&(clearTimeout(rt.current),rt.current=null))},[Se]);const ws=1500;s.useEffect(()=>{const t=!!(u&&o.writeFile),a=!!(u?.path&&(hr(u.path)||Ft));if(vl({autoSaveEnabled:Se,isDirty:Le,canWrite:t,isSaving:nr,fileLoading:Me,selectedFilePath:u?.path,loadedFilePath:Ne,isNonEditableBinary:a}))return rt.current=setTimeout(()=>{_t().then(l=>{l&&(At("saved"),setTimeout(()=>At("idle"),2e3))})},ws),()=>{rt.current&&(clearTimeout(rt.current),rt.current=null)}},[Se,Ft,ee,Me,Le,Ne,u,o.writeFile,nr,_t]),s.useEffect(()=>{At("idle")},[u?.path]),po({save_file:t=>{if(!(t.target instanceof Node)||!Sr.current?.contains(t.target))return!1;rt.current&&(clearTimeout(rt.current),rt.current=null),nr||_t().then(a=>{a&&(At("saved"),setTimeout(()=>At("idle"),2e3))})},find_in_file:t=>{if(!(t.target instanceof Node))return!1;if(Je&&Ae()==="preview"){if(m||!(te?Er.current:Rr.current)?.contains(t.target))return!1;kr(!0),Yn(l=>l+1);return}if(!Sr.current?.contains(t.target))return!1;be(!0)}});const Wt=s.useCallback(t=>{const{content:a,lineEnding:l}=bl(t);return sn.current=t,an.current+=1,Ki(l),me(a),ht.current=a,sr.current=a,Ce(a),a},[]),bs=s.useCallback(async t=>{const a=Lt.current+1;Lt.current=a;const l=lt(),d=V.current,h=()=>{if(!c||lt()!==l||V.current!==d)return!1;const z=Ye.getState().byRoot[c],ie=z?.selectedPath??z?.openPaths[0]??null;return Lt.current===a&&ie===t.path};if(we(null),Be(""),ce(null),Kn(!1),ft(!0),await et(t.path),!h())return;const g=Sn(t.path),C=li(t.path),A=ci(t.path),se=hr(t.path);if(m&&H(!0),w.isDesktop&&g&&!C){me(""),Ce("");return}if(!w.isDesktop&&g&&!C){me(""),Ce(""),ce(t.path),ft(!1);return}if(A){me(""),Ce(""),ce(t.path),ft(!1);return}if(se){me(""),Ce(""),ce(t.path),ft(!1);return}await zr(t.path).then(z=>{if(!h())return;if(ui(z)){Kn(!0),me(""),Ce(""),ce(t.path);return}const ie=Wt(z),kt=Vn(t.path)||Hr(t.path)||Fi(t.path)||pr(t.path);re(kt?"edit":jl(ie,Te.current[t.path])),ce(t.path),vt(t.path).then(Gt=>{Gt&&h()&&(qe.current=Gt)}).catch(()=>{})}).catch(z=>{if(h()){if(Ml(z)){if(ft(!1),c&&Fe(c,null),we(null),me(""),Ce(""),ce(null),qe.current=null,Y.trim().length>0&&Q(""),m&&H(!1),c){const kt=[...bi(t.path,c),t.path];kt.length>0&&xr(c,kt);for(const Gt of kt)Oe.current.has(Gt)||Ve(Gt)}return}if(ji(z)){c&&dt(c,t.path),me(""),Ce(""),we(null),qe.current=null,m&&H(!1);return}me(""),Ce(""),we(z instanceof Error?z.message:r("filesView.error.readFileFailed")),qe.current=null}}).finally(()=>{h()&&ft(!1)})},[Wt,xr,m,Ve,zr,vt,dt,et,c,w.isDesktop,Y,Fe,r]),Lr=s.useCallback(async(t,a)=>{if(!e||!c)return;const l=bi(t,c),d=a?[...l,t]:l;if(d.length>0&&xr(c,d),!T)return;const h=d.map(g=>{if(!Oe.current.has(g))return Ve(g)}).filter(Boolean);await Promise.all(h)},[xr,Ve,c,T,e]),ys=s.useCallback((t,a)=>{const l=a.findIndex(d=>d.path===t);return l===-1||a.length<=1?null:a[l+1]??a[l-1]??null},[]),Pe=s.useCallback(async t=>{if(or.current)or.current=!1;else if(Le){ir(!0),It.current=t;return}c&&(Fe(c,t.path),Lr(t.path,!1)),we(null),Be(""),me(""),ht.current="",sr.current="",Ce(""),ce(null),m&&H(!0)},[Lr,Le,m,c,Fe]);s.useEffect(()=>{u?.path&&Lr(u.path,!1)},[Lr,u?.path]),s.useEffect(()=>{if(!e)return;if(!u){Lt.current+=1,jt.current=null,ft(!1);return}if(Ne===u.path||jt.current===u.path)return;const t=u.path;jt.current=t,bs(u).finally(()=>{jt.current===t&&(jt.current=null)})},[Nr,bs,Ne,u,e]);const Ar=s.useRef(Le);Ar.current=Le,s.useEffect(()=>Wo(({runtimeKey:t,paths:a})=>{const l=u?.path;t!==lt()||!l||Ar.current||!a.includes(U(l))||(Lt.current+=1,jt.current=null,qe.current=null,Be(""),we(null),ce(null),Hi(d=>d+1))}),[u?.path]),s.useEffect(()=>{if(!e||!u?.path||Ne!==u.path)return;const t=u.path,a=lt(),l=V.current,d=()=>Ar.current||pr(t)&&ht.current!==sr.current,h=!hr(t)&&!Sn(t)&&!Ft?fl({readContent:()=>zr(t,{fresh:!0}),getLoadedContent:()=>sn.current,getLoadedRevision:()=>an.current,isDirty:d,applyContent:z=>{if(!(g||lt()!==a||V.current!==l)){if(ui(z)){ce(null);return}Wt(z)}}}):null;let g=!1,C=!1;const A=()=>{document.hidden||C||(C=!0,vt(t).then(async z=>{if(g||lt()!==a||V.current!==l||!z)return;const ie=qe.current;if(!ie||ie.path!==t){qe.current=z;return}if(hl(ie,z)){if(h&&z.size<=zl){await h.poll()&&!g&&(qe.current=z);return}Ar.current||(qe.current=z,ce(null))}}).catch(()=>{}).finally(()=>{C=!1}))};A();const se=window.setInterval(A,2e3);return()=>{g=!0,h?.dispose(),window.clearInterval(se)}},[Wt,Ft,Ne,zr,vt,u?.path,e]);const ga=s.useCallback(()=>{const t=It.current,a=ar.current;if(It.current=null,ar.current=null,or.current=!0,ir(!1),Ce(O),a){c&&Dt(c,a),u?.path===a&&(t?Pe(t):(c&&Fe(c,null),me(""),we(null),Be(""),ce(null),m&&H(!1)));return}if(t){Pe(t);return}},[O,Pe,m,Dt,c,u?.path,Fe]),va=s.useCallback(async()=>{const t=It.current,a=ar.current;if(!await _t()){or.current=!1;return}if(It.current=null,ar.current=null,or.current=!0,ir(!1),a){c&&Dt(c,a),u?.path===a&&(t?await Pe(t):(c&&Fe(c,null),me(""),we(null),Be(""),ce(null),m&&H(!1)));return}if(t){await Pe(t);return}},[Pe,m,Dt,c,_t,u?.path,Fe]),js=s.useCallback(t=>{const a=u?.path===t,l=ys(t,zt);if(a&&Le){ir(!0),It.current=l,ar.current=t;return}if(c&&Dt(c,t),!!a){if(l){Pe(l);return}c&&Fe(c,null),me(""),we(null),Be(""),ce(null),m&&H(!1)}},[ys,Pe,Le,m,zt,Dt,c,u?.path,Fe]),Fs=s.useMemo(()=>new Set(je),[je]),Ir=s.useMemo(()=>Uo(D?de?.files??[]:[]),[de?.files,D]),xa=s.useCallback(t=>{if(Fs.has(t))return"open";const a=t.startsWith(c+"/")?t.slice(c.length+1):t;return Ir.statusByPath.get(a)??null},[Fs,Ir,c]),wa=s.useCallback(t=>{if(!de?.files)return null;const a=t.startsWith(c+"/")?t.slice(c.length+1):t;return Ir.badgeByDir.get(a)??null},[de,Ir,c]),ba=s.useCallback(async t=>{const a=U(t);c&&(Ln(c,a),Oe.current.has(a)||await Ve(a))},[Ve,c,Ln]),ya=s.useMemo(()=>({canRename:es,canCreateFile:Qn,canCreateFolder:Zn,canDelete:ts,canReveal:rs}),[es,Qn,Zn,ts,rs]);function Ns(t,a){const l=$n[t]??[];return l.map((d,h)=>{const g=d.type==="directory",C=g&&Ii.has(d.path),A=u?.path===d.path,se=h===l.length-1;return n.jsxs("li",{className:"relative",children:[a>0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),se&&n.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),n.jsx(Ll,{node:d,root:c,isExpanded:C,isActive:A,isMobile:m,isBrowserClient:N,alwaysShowActions:R,status:g?void 0:xa(d.path),badge:g?wa(d.path):void 0,permissions:ya,downloadFile:o.downloadFile,contextMenuPath:ea,setContextMenuPath:ta,rightClickMenuPath:ra,setRightClickMenuPath:na,onSelect:Pe,onToggle:ba,onRevealPath:ua,onOpenDialog:fn}),g&&C&&n.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[br[d.path]?n.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:br[d.path],children:br[d.path]}),n.jsxs(I,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{$e(d.path)},children:[n.jsx(F,{name:"refresh",className:"size-3.5"}),r("filesView.tree.actions.refreshTitle")]})]}):null,Ns(d.path,a+1)]})]},d.path)})}const ke=!!(u?.path&&Sn(u.path)),Or=!!(u?.path&&li(u.path)),_e=!!(u?.path&&ci(u.path)),pn=!!(u?.path&&(hr(u.path)||Ft)),it=pn&&!ke&&!_e,Cs=s.useMemo(()=>U(nt?.path??""),[nt?.path]),Ut=!!(nt&&Cs&&Ke&&Ke===Cs&&!Me&&!tt&&!ke&&!_e&&!it),xt=s.useMemo(()=>Jr(c,Ke),[Ke,c]),ja=!!(u&&(!ke||Or)&&!_e&&!it&&O.length>0),Fa=!!(u&&xt.length>0),Xe=!!(u&&!wr&&!pn&&!ke&&o.writeFile),Je=!!(u?.path&&Vn(u.path)),Kt=!!(u?.path&&Fi(u.path)),qt=!!(u?.path&&Hr(u.path)),fr=!!(u?.path&&pr(u.path)),Br=!!(u&&!pn&&!ke)&&!Je&&!fr&&!(qt&&ve==="preview"),Na=Je&&ge==="edit"||qt&&ve==="edit"||Kt&&Z==="text"||!Je&&!qt&&!Kt&&_==="edit",$r=s.useMemo(()=>Ke?go(Ke):null,[Ke]),[Ss,gn]=s.useState(null);s.useEffect(()=>{let t=!1;const a=u?.path;if(!a||$r){gn(null);return}return gn(null),vo(a).then(l=>{t||gn(l)}),()=>{t=!0}},[u?.path,$r]),s.useEffect(()=>{!Xe&&_==="edit"&&re("view")},[Xe,_]);const vn="aiworker:files:md-viewer-mode",xn="aiworker:files:html-viewer-mode",wn="aiworker:files:json-viewer-mode";s.useEffect(()=>{const t=u?.path;if(!t)return;re(Te.current[t]??"edit");let a=ur?"preview":"edit";try{const h=localStorage.getItem(vn);(h==="preview"||h==="edit")&&(a=h)}catch{}ne(Ie.current[t]??a);let l=ur?"preview":"edit";try{const h=localStorage.getItem(xn);(h==="preview"||h==="edit")&&(l=h)}catch{}fe(Vt.current[t]??l),Re(le.current[t]??(ur?"preview":"edit"));let d=ur?"tree":"text";try{const h=localStorage.getItem(wn);(h==="tree"||h==="text")&&(d=h)}catch{}ye(d)},[u?.path,ur]);const Ca=s.useCallback(t=>{const a=u?.path;a&&(Te.current[a]=t),re(t)},[u?.path]),Sa=s.useCallback(t=>{const a=u?.path;a&&(Ie.current[a]=t),ne(t);try{localStorage.setItem(vn,t)}catch{}},[u?.path]),Ae=s.useCallback(()=>ge,[ge]),ks=u&&Je&&Ae()==="preview"&&!Me?u.path:null;s.useEffect(()=>{!ks||m||Tr()},[Tr,te,m,ks]);const ka=s.useCallback(t=>{ye(t);try{localStorage.setItem(wn,t)}catch{}},[]),Ra=s.useCallback(t=>{const a=u?.path;a&&(Vt.current[a]=t),fe(t);try{localStorage.setItem(xn,t)}catch{}},[u?.path]),Ta=s.useCallback(t=>{const a=u?.path;if(a&&(le.current[a]=t),ze.current&&(clearTimeout(ze.current),ze.current=null),st.current!==null&&(cancelAnimationFrame(st.current),st.current=null),t==="edit")Ce(ht.current||O),Re(t);else{ht.current=ee;const l=a;Re("edit"),st.current=requestAnimationFrame(()=>{st.current=requestAnimationFrame(()=>{st.current=null,!(c&&l&&Ye.getState().byRoot[c]?.selectedPath!==l)&&(Et(d=>d+1),Re("preview"))})});return}},[ee,O,c,u?.path]),bn=s.useCallback(async(t,a)=>{if(!o.writeFile||a===sr.current)return!1;if(!(await o.writeFile(t,a))?.success)return J.error(r("filesView.toast.writeFileFailed")),!1;Wt(a);const d=await vt(t).catch(()=>null);return d&&(qe.current=d),!0},[Wt,o,vt,r]);s.useEffect(()=>()=>{ze.current&&(clearTimeout(ze.current),ze.current=null),st.current!==null&&(cancelAnimationFrame(st.current),st.current=null)},[xe,u?.path]);const Ea=s.useCallback(t=>{if(ht.current=t,!Se||!u?.path||xe!=="preview"||!o.writeFile)return;ze.current&&clearTimeout(ze.current);const a=u.path;ze.current=setTimeout(()=>{ze.current=null,bn(a,t).then(l=>{l&&(Cr(!0),setTimeout(()=>Cr(!1),1500))}).catch(l=>{J.error(l instanceof Error?l.message:r("filesView.toast.saveFailed"))})},ws)},[Se,xe,o.writeFile,bn,u?.path,r]),Va=s.useMemo(()=>fr&&(ht.current||ee)||O,[ee,O,fr]),Rs=s.useCallback(()=>ve,[ve]);s.useEffect(()=>{const t=l=>{const d=l?"preview":"edit",h=l?"tree":"text";for(const g of je)Te.current[g]="edit",Vn(g)&&(Ie.current[g]=d),Hr(g)&&(Vt.current[g]=d),pr(g)&&(le.current[g]=d);re("edit"),ne(d),fe(d),Re(d),ye(h);try{localStorage.setItem(vn,d),localStorage.setItem(xn,d),localStorage.setItem(wn,h)}catch{}},a=l=>{const d=!!l.detail?.enabled;t(d)};return window.addEventListener("aiworker:file-viewer-preview-mode-changed",a),()=>{window.removeEventListener("aiworker:file-viewer-preview-mode-changed",a)}},[je]),s.useEffect(()=>{if(!nt||!c)return;const t=()=>{typeof window>"u"||Ot.current===null&&(Ot.current=window.requestAnimationFrame(()=>{Ot.current=null,ln(ot=>ot+1)}))},a=(ot,Rt)=>{if(ot.state.doc.length!==Rt.length)return!1;if(Rt.length===0)return!0;const Nn=Math.min(128,Rt.length);if(ot.state.sliceDoc(0,Nn)!==Rt.slice(0,Nn))return!1;const Zs=Math.max(0,Rt.length-Nn);return ot.state.sliceDoc(Zs,Rt.length)===Rt.slice(Zs)},l=U(nt.path);if(!l){Vr(null),Nt.current={key:"",attempts:0};return}const d=`${l}:${nt.line}:${nt.column??1}`;if(Nt.current.key!==d&&(Nt.current={key:d,attempts:0}),u?.path!==l){if(on)return;Pe(Mt(l));return}if(Me||Ne!==l)return;if(tt||ke||_e||it){Vr(null),Nt.current={key:"",attempts:0};return}if(!Xe)return;if(_!=="edit"){re("edit");return}const h=He.current;if(!h){t();return}if(!a(h,ee)){t();return}const g=Math.max(1,Math.min(nt.line,h.state.doc.lines)),C=h.state.doc.line(g),A=Math.max(1,nt.column||1),se=Math.max(0,C.to-C.from),z=Math.min(se,A-1),ie=C.from+z;if(!(h.state.selection.main.head===ie)||Nt.current.attempts===0){Nt.current.attempts+=1,h.dispatch({selection:{anchor:ie},effects:Tt.scrollIntoView(ie,{y:"center"})}),h.focus(),t();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const ot=He.current;ot&&(ot.dispatch({selection:{anchor:ie},effects:Tt.scrollIntoView(ie,{y:"center"})}),ot.focus())}),Vr(null),Nt.current={key:"",attempts:0}},[Xe,on,ee,Yi,tt,Me,ke,_e,it,Ne,Pe,nt,c,u?.path,Vr,_,Mt]),s.useEffect(()=>{if(!mn||!c)return;const t=U(mn);if(!t){hn(null);return}u?.path===t&&(Me||Ne!==t||(!tt&&!ke&&!_e&&!it&&Xe&&_==="edit"&&He.current?.focus(),hn(null)))},[Xe,tt,Me,ke,_e,it,Ne,mn,c,u?.path,hn,_]);const Ht=s.useCallback(t=>{if(!m||!t||!t.hasFocus||typeof window>"u")return;const a=window.visualViewport;if(!a)return;const l=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,l-(a.offsetTop+a.height))<=0)return;const h=t.state.selection.main.head,g=t.coordsAtPos(h);if(!g)return;const C=Math.round(a.offsetTop+a.height),se=g.bottom+20-C;se<=0||(t.scrollDOM.scrollTop+=se)},[m]);s.useEffect(()=>{if(!m||typeof window>"u")return;const t=()=>{window.requestAnimationFrame(()=>{Ht(He.current)})},a=window.visualViewport;return a?.addEventListener("resize",t),a?.addEventListener("scroll",t,{passive:!0}),document.addEventListener("selectionchange",t),()=>{a?.removeEventListener("resize",t),a?.removeEventListener("scroll",t),document.removeEventListener("selectionchange",t)}},[m,Ht]),xo("open_go_to_line",t=>{if(!Xe||_!=="edit"||m)return!1;const a=t.target;if(a?.closest('[role="dialog"]')||!(a instanceof Node)||!Sr.current?.contains(a))return!1;const l=!!a?.closest(".cm-editor");if(!!a?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!l)return!1;dn(!0)});const _r=wt(t=>t.editorFontSize),Ts=s.useMemo(()=>{if(!u?.path)return[fi(p,{fontSize:_r})];const t=Cn(u.path),a=[fi(p,t?{syntaxColors:!1,fontSize:_r}:{fontSize:_r})],l=$r??Ss;return l&&a.push(l),t&&a.push(Eo({language:t,themeName:p.metadata.id,theme:Lo(p)})),G&&a.push(Tt.lineWrapping),m&&a.push(Tt.updateListener.of(d=>{d.view.hasFocus&&(d.selectionSet||d.focusChanged||d.viewportChanged||d.geometryChanged)&&window.requestAnimationFrame(()=>{Ht(d.view)})})),a},[p,u?.path,$r,Ss,G,m,Ht,_r]),Es=s.useMemo(()=>({light:Qe.metadata.id,dark:Pt.metadata.id}),[Qe.metadata.id,Pt.metadata.id]),mr=u?.path&&_e&&(!yt.allowOutsideWorkspace||yt.outsideFileGrant)?`${u.path}|${yt.allowOutsideWorkspace?"outside":"workspace"}|${yt.outsideFileGrant??""}|${Nr}`:"",Wr=u?.path&&qt&&ve==="preview"&&!w.isVSCode?`${u.path}|${Nr}`:"",Vs=r("filesView.error.readFileFailed"),{readyKey:Ps,nonce:Pa}=Ci(Wr,we,Vs),{readyKey:Ds,nonce:Ms}=Ci(mr,we,Vs),Da=!!(Wr&&Ps!==Wr),zs=!!(mr&&Ds!==mr),Ls=u?.path&&ke?Or?`data:${wo(u.path)};utf8,${encodeURIComponent(O)}`:Ui:"",As=u?.path&&_e&&mr&&Ds===mr?ni().authenticatedAsset("/api/fs/raw",{path:u.path,allowOutsideWorkspace:yt.allowOutsideWorkspace?"true":void 0,outsideFileGrant:yt.outsideFileGrant,directory:c||void 0}):"",Is=s.useCallback(t=>n.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:n.jsx("iframe",{src:As,className:"h-full w-full border-0",title:t.name},Ms)}),[As,Ms]);s.useEffect(()=>{let t=!1,a="";return(async()=>{if(!u?.path||!ke||Or){Be("");return}we(null);const d=await et(u.path);if(t)return;await(o.readFileBinary?o.readFileBinary(u.path,d).then(g=>g.dataUrl):(async()=>{const g=await ri("/api/fs/raw",{query:{path:u.path,allowOutsideWorkspace:d.allowOutsideWorkspace?"true":void 0,outsideFileGrant:d.outsideFileGrant,directory:c||void 0}});if(!g.ok)throw new Error(r("filesView.error.readFileFailed"));const C=await g.blob();return a=URL.createObjectURL(C),t?(URL.revokeObjectURL(a),a="",""):a})()).then(g=>{t||(Be(g),ce(u.path))}).catch(g=>{t||(Be(""),we(g instanceof Error?g.message:r("filesView.error.readFileFailed")),ce(null))}).finally(()=>{t||ft(!1)})})(),()=>{t=!0,a&&URL.revokeObjectURL(a)}},[Nr,o,ke,Or,et,c,u?.path,yt,r]);const Ma=s.useCallback(()=>cn(null),[]),za=s.useMemo(()=>Xo({drafts:os,editingDraftId:Dr,commentText:Pr,onTextChange:ls,selection:W,isDragging:ss,fileLabel:u?.path??"",newWidgetId:"files-new-comment-input",mapDraftToRange:t=>({start:t.startLine,end:t.endLine}),onSave:hs,onCancel:()=>{Ge(null),dr()},onEdit:t=>{fs(t),Ge({start:t.startLine,end:t.endLine})},onDelete:ms}),[dr,Pr,ms,Dr,os,hs,ss,W,u?.path,ls,fs]),Os=xi(),Bs=xi(),$s=!Me&&!tt&&Ne===Ke,Ur=$s&&Br&&_==="view"&&!(Kt&&Z==="tree"),_s=$s&&Je&&Ae()==="preview",{setScroller:Ws,restore:La}=qr(Ur?`${mt}:code`:null),{setScroller:Us,restore:Aa}=qr(Ur?`${mt}:code:fullscreen`:null),{setScroller:Ks}=qr(_s?`${mt}:markdown`:null),{setScroller:qs}=qr(_s?`${mt}:markdown:fullscreen`:null),{setScroller:Hs}=Os,{setScroller:Gs}=Bs,Ia=s.useCallback(t=>{Hs(t),Ws(t)},[Hs,Ws]),Oa=s.useCallback(t=>{Gs(t),Us(t)},[Gs,Us]),Ba=s.useCallback(t=>{as.current=t,Rr.current=t,Ks(t)},[Ks]),$a=s.useCallback(t=>{Er.current=t,qs(t)},[qs]),yn=No("unified"),at=ee.length>zi,jn=s.useMemo(()=>at&&Ur?Fl(ee):void 0,[Ur,ee,at]),Xs=s.useCallback((t,a,l,d)=>{const h={name:t.name,contents:a,lang:Cn(t.path)||void 0},g=C=>n.jsx(zo,{file:at&&jn?{...h,cacheKey:`${t.path}:${jn}`}:h,options:{disableFileHeader:!0,overflow:G?"wrap":"scroll",theme:Es,themeType:p.metadata.variant==="dark"?"dark":"light",onPostRender:d},className:at?"block w-full":"block h-full w-full",style:at?void 0:{height:"100%"}},C);return at?n.jsx("div",{className:"h-full",children:n.jsx(Ao.Provider,{value:l.virtualizer,children:n.jsx(Io.Provider,{value:yn,children:g(`${t.path}:${yn?"pool":"pending"}`)})})}):n.jsx("div",{className:"h-full",children:g(t.path)})},[p.metadata.variant,at,jn,Es,yn,G]),Js=({exitFullscreenOnly:t=!1,layout:a="floating"}={})=>{if(!u)return null;const l=a==="docked",d=bo(yo("save_file")),h=l?"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",g=(C,A)=>n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:A})}),n.jsx(Yt,{side:"bottom",sideOffset:6,children:C})]});return n.jsxs("div",{className:h,children:[Xe&&Na&&n.jsxs(n.Fragment,{children:[nr?n.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[n.jsx(F,{name:"loader-4",className:"size-3.5 animate-spin"}),r("filesView.editor.saving")]}):Se&&Gi==="saved"&&!Le?n.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[n.jsx(F,{name:"check",className:"size-3.5"}),r("filesView.editor.saved")]}):Le?g(r(Se?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:d}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{_t()},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:r(Se?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:d}),"aria-label":r("filesView.editor.saveAria",{shortcut:d}),children:n.jsx(F,{name:"save-3",className:"size-4"})})):null,g(r(Se?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>Ji(!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:r(Se?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),"aria-label":r(Se?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),children:Se?n.jsx(F,{name:"file-check-fill",className:"size-4"}):n.jsx(F,{name:"file-check",className:"size-4"})}))]}),n.jsxs(Pn,{onOpenChange:X,children:[n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:n.jsx(Dn,{asChild:!0,children:n.jsx(I,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.openInDesktopApp"),"aria-label":r("filesView.editor.openInDesktopApp"),children:n.jsx(F,{name:"file-transfer",className:"size-4"})})})})}),n.jsx(Yt,{side:"bottom",sideOffset:6,children:r("filesView.editor.openInDesktopApp")})]}),n.jsxs(Mn,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[oa.map(C=>n.jsxs(Xr,{className:"flex items-center gap-2",onClick:()=>{da(C)},children:[n.jsx(kl,{label:C.label,iconDataUrl:C.iconDataUrl}),n.jsx("span",{className:"typography-ui-label text-foreground",children:C.label})]},C.id)),la?n.jsxs(Xr,{className:"flex items-center gap-2",onClick:()=>{ca(!0)},children:[n.jsx(F,{name:"refresh",className:"size-4"}),n.jsx("span",{className:"typography-ui-label text-foreground",children:r("filesView.editor.refreshApps")})]}):null]})]}),!ke&&!_e&&!it&&n.jsxs(n.Fragment,{children:[g(r(G?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>We(!G),className:q("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",G?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:r(G?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),children:n.jsx(F,{name:"text-wrap",className:"size-4"})})),_==="edit"&&n.jsxs(n.Fragment,{children:[g(r("filesView.editor.findInFile"),n.jsx(I,{variant:"ghost",size:"sm",onClick:C=>{be(!De),C.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.findInFile"),children:n.jsx(F,{name:"search",className:"size-4"})})),g(r("filesView.editor.goToLine"),n.jsx(I,{variant:"ghost",size:"sm",onClick:C=>{dn(A=>!A),C.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.goToLine"),children:n.jsx(F,{name:"menu-fold-2",className:"size-4"})})),n.jsx(il,{open:aa,onOpenChange:dn,view:He.current,variant:"inline"})]})]}),Br&&Xe&&!Kt&&!qt&&n.jsx(Tn,{currentMode:_==="view"?"preview":"edit",onToggle:()=>{Ca(_==="view"?"edit":"view")}}),Je&&g(r(Ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>Sa(Ae()==="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)]",Ae()==="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:r(Ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),"aria-label":r(Ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:n.jsx(F,{name:Ae()==="preview"?"eye":"eye-off",className:"size-4"})})),Hr(u?.path??"")&&n.jsx(Tn,{currentMode:Rs(),onToggle:()=>{Ra(Rs()==="preview"?"edit":"preview")}}),Je&&Ae()==="preview"&&g(r("filesView.editor.findInFile"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{kr(!0),Yn(C=>C+1)},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.findInFile"),children:n.jsx(F,{name:"search",className:"size-4"})})),Je&&Ae()==="preview"&&fa&&n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx(I,{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":r(Fr?"filesView.tts.stopSpeaking":"filesView.tts.readAloud"),onClick:()=>{Fr?Wi():O.trim()&&_i(O)},children:Fr?n.jsx(F,{name:"stop",className:"size-4 text-[color:var(--status-success)]"}):n.jsx(F,{name:"volume-up",className:"size-4"})})}),n.jsx(Yt,{sideOffset:8,children:r(Fr?"filesView.tts.stopSpeaking":"filesView.tts.readAloud")})]}),fr&&n.jsxs(n.Fragment,{children:[n.jsx(Tn,{currentMode:xe,onToggle:()=>Ta(xe==="preview"?"edit":"preview")}),xe==="preview"&&n.jsx(I,{variant:"ghost",size:"sm",onClick:async()=>{const C=Un.current?.getXml();if(ze.current&&(clearTimeout(ze.current),ze.current=null),u?.path&&C){if(!await bn(u.path,C))return;Cr(!0),setTimeout(()=>Cr(!1),1500)}},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.diagram.saveDiagram"),children:Xi?n.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):n.jsx(F,{name:"save-3",className:"size-4"})})]}),Kt&&g(r(Z==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>ka(Z==="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:r(Z==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),children:Z==="tree"?n.jsx(F,{name:"code-sslash",className:"size-4"}):n.jsx(F,{name:"node-tree",className:"size-4"})})),ja&&g(r("filesView.editor.copyFileContents"),n.jsx(I,{variant:"ghost",size:"sm",onClick:async()=>{(await Yr(O)).ok?(Hn(!0),lr.current!==null&&window.clearTimeout(lr.current),lr.current=window.setTimeout(()=>{Hn(!1)},1200)):J.error(r("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.copyFileContents"),"aria-label":r("filesView.editor.copyFileContents"),children:sa?n.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):n.jsx(F,{name:"clipboard",className:"size-4"})})),Fa&&g(r("filesView.editor.copyFilePathTitle",{path:xt}),n.jsx(I,{variant:"ghost",size:"sm",onClick:async()=>{(await Yr(xt)).ok?(Gn(!0),cr.current!==null&&window.clearTimeout(cr.current),cr.current=window.setTimeout(()=>{Gn(!1)},1200)):J.error(r("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.copyFilePathTitle",{path:xt}),"aria-label":r("filesView.editor.copyFilePathTitle",{path:xt}),children:ia?n.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):n.jsx(F,{name:"file-copy-2",className:"size-4"})})),o.downloadFile&&g(r("filesView.editor.saveFile"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{const C=o.downloadFile;C&&C(u.path).catch(A=>{console.error("Download failed:",A),J.error(r("sidebarFilesTree.toast.operationFailed"))})},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.saveFile"),"aria-label":r("filesView.editor.saveFile"),children:n.jsx(F,{name:"download",className:"size-4"})})),t?g(r("filesView.editor.exitFullscreen"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>pe(!1),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.exitFullscreen"),"aria-label":r("filesView.editor.exitFullscreen"),children:n.jsx(F,{name:"fullscreen-exit",className:"size-4"})})):!m&&i==="full"&&g(r(te?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>pe(!te),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r(te?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),"aria-label":r(te?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),children:te?n.jsx(F,{name:"fullscreen-exit",className:"size-4"}):n.jsx(F,{name:"fullscreen",className:"size-4"})}))]})},Fn=n.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[n.jsx(ki,{open:on,onOpenChange:t=>{t||ir(!0)},children:n.jsxs(Ri,{showCloseButton:!1,className:"max-w-md",children:[n.jsxs(Ti,{children:[n.jsx(Ei,{children:r("filesView.unsaved.title")}),n.jsx(Vi,{children:r("filesView.unsaved.description")})]}),n.jsxs(Pi,{children:[n.jsx(I,{variant:"outline",onClick:()=>{va()},disabled:nr,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:r("filesView.unsaved.saveChanges")}),n.jsx(I,{variant:"destructive",onClick:ga,children:r("filesView.unsaved.discard")})]})]})}),n.jsxs("div",{className:q("flex flex-col flex-shrink-0",B&&"border-b border-border/40"),children:[B?n.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[m&&oe&&n.jsx("button",{type:"button",onClick:()=>H(!1),"aria-label":r("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-primary",children:n.jsx(F,{name:"arrow-left-s",className:"size-5"})}),m?u?n.jsxs(Pn,{children:[n.jsx(Dn,{asChild:!0,children:n.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":r("filesView.editor.openFilesAria"),children:[n.jsx(Gr,{filePath:u.path,extension:u.extension,className:"size-3.5 flex-shrink-0"}),n.jsx(yi,{name:u.name}),n.jsx(F,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),n.jsx(Mn,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:zt.map(t=>{const a=u?.path===t.path;return n.jsxs(Xr,{onSelect:l=>{if(l.target.closest("[data-close-open-file]")){l.preventDefault();return}a||Pe(t)},className:q("flex min-w-0 items-center justify-between gap-2 overflow-hidden",a&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[n.jsx(Gr,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),n.jsx(yi,{name:t.name})]}),n.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:l=>{l.preventDefault(),l.stopPropagation()},onClick:l=>{l.preventDefault(),l.stopPropagation(),js(t.path)},className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]","aria-label":r("filesView.editor.closeFileAria",{name:t.name}),children:n.jsx(F,{name:"close",className:"size-3.5"})})]},t.path)})})]}):n.jsx("div",{className:"typography-ui-label font-medium truncate",children:r("filesView.editor.selectFile")}):zt.length>0?n.jsxs("div",{className:"relative min-w-0 flex-1",children:[In.left&&n.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"}),In.right&&n.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"}),n.jsx("div",{ref:tn,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:zt.map(t=>{const a=u?.path===t.path;return n.jsxs("div",{title:Jr(c,t.path),className:q("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",a?"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:[n.jsx(Gr,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),n.jsx("button",{type:"button",onClick:()=>{a||Pe(t)},className:"max-w-[12rem] truncate text-left",children:t.name}),n.jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),js(t.path)},className:q("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!a&&!R&&"opacity-0 group-hover:opacity-100"),"aria-label":r("filesView.editor.closeFileAria",{name:t.name}),children:n.jsx(F,{name:"close",className:"size-3.5"})})]},t.path)})})]}):n.jsx("div",{className:"typography-ui-label font-medium truncate",children:r("filesView.editor.selectFile")})]}):null,u?n.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:[xt&&!m?n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:xt,children:xt}):null,n.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:Js({layout:"docked"})})]}):null]}),n.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:n.jsx(kn,{ref:Ia,outerClassName:"h-full min-w-0",className:q("h-full min-w-0",at&&"[overflow-anchor:none]"),children:u?Me||zs?$?n.jsx("div",{className:"p-3"}):n.jsxs("div",{className:"p-3 flex items-center gap-2 typography-ui text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),r("filesView.state.loading")]}):tt?n.jsx("div",{className:"p-3 typography-ui text-[color:var(--status-error)]",children:tt}):ke?n.jsx("div",{className:"flex h-full items-center justify-center p-3",children:n.jsx("img",{src:Ls,alt:u?.name??r("filesView.editor.imageAltFallback"),className:"max-w-full max-h-[70vh] object-contain rounded-md border border-border/30 bg-primary/10"},u.path)}):_e?Is(u):it?n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("div",{className:"typography-ui-header text-foreground",children:r("filesView.editor.cannotPreviewBinary")}),n.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:r("filesView.editor.binaryFileDescription")}),o.downloadFile?n.jsxs(I,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=o.downloadFile;!t||!u||t(u.path).catch(a=>{console.error("Download failed:",a),J.error(r("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(F,{name:"download",className:"mr-2 size-4"}),r("filesView.editor.saveFile")]}):null]}):u&&fr&&xe==="preview"?n.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:n.jsx(Cl,{ref:Un,xml:Va,onChange:Ea},`${u.path}:${Ue}`)}):u&&Kt&&Z==="tree"?n.jsx(Rn,{fallback:n.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 font-medium text-destructive",children:r("filesView.error.jsonViewerUnavailable")}),n.jsx("div",{className:"text-sm text-muted-foreground",children:r("filesView.error.switchToTextMode")})]}),children:n.jsx("div",{className:"h-full overflow-auto",children:n.jsx(Mo,{jsonString:O,maxHeight:"100%",initiallyExpandedDepth:2})})}):u&&Je&&Ae()==="preview"?n.jsxs("div",{className:"relative h-full min-h-0",children:[n.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-3 outline-none",tabIndex:-1,onMouseDown:Tr,ref:Ba,children:[n.jsx(hi,{containerRef:as,filePath:u.path,fileContent:O}),O.length>500*1024&&n.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:r("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(O.length/1024)})}),n.jsx(Rn,{fallback:n.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 font-medium text-destructive",children:r("filesView.error.previewUnavailable")}),n.jsx("div",{className:"text-sm text-muted-foreground",children:r("filesView.error.switchToEditMode")})]}),children:n.jsx(di,{content:O,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}),!te&&n.jsx(vi,{containerRef:Rr,open:Xn,onOpenChange:kr,focusNonce:Jn})]}):u&&qt&&ve==="preview"?Da?n.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:r("common.loading")}):n.jsx("div",{className:"h-full overflow-hidden",children:n.jsx("iframe",{src:!w.isVSCode&&Ps===Wr?(()=>{const t=u.path.split("/").map(a=>encodeURIComponent(a)).join("/");return ni().authenticatedAsset(`/api/fs/serve${t.startsWith("/")?t:`/${t}`}`)})():void 0,srcDoc:w.isVSCode?(()=>{const t=u.path.substring(0,u.path.lastIndexOf("/")+1);return t?O.replace(/<head([^>]*)>/i,`<head$1><base href="${t}">`):O})():void 0,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:r("filesView.editor.htmlPreviewTitle")},Pa)}):u&&Br&&_==="view"?Xs(u,ee,Os,La):n.jsxs("div",{className:q("relative h-full",Ut&&"overflow-hidden"),ref:Sr,children:[n.jsx("div",{className:q("h-full",Ut&&"invisible"),children:n.jsx(Ni,{positionKey:mt,value:ee,onChange:Ce,readOnly:!Xe,vimMode:is==="vim",extensions:Ts,className:"h-full",blockWidgets:za,onViewReady:t=>{He.current=t,ln(a=>a+1),window.requestAnimationFrame(()=>{Ht(t)})},onViewDestroy:()=>{He.current&&(He.current=null),ln(t=>t+1)},enableSearch:!0,searchOpen:De,onSearchOpenChange:be,highlightLines:W?{start:Math.min(W.start,W.end),end:Math.max(W.start,W.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(t,a,l)=>{if(!(l instanceof MouseEvent)||l.button!==0)return!1;l.preventDefault();const d=t.state.doc.lineAt(a.from).number;if(W&&!l.shiftKey&&Math.min(W.start,W.end)===d&&Math.max(W.start,W.end)===d)return Ge(null),dr(),Bt.current=!1,gt.current=null,$t(!1),!0;if(m&&W&&!l.shiftKey){const h=Math.min(W.start,W.end,d),g=Math.max(W.start,W.end,d);return Ge({start:h,end:g}),Bt.current=!1,gt.current=null,$t(!1),!0}if(Bt.current=!0,gt.current=d,$t(!0),W&&l.shiftKey){const h=Math.min(W.start,d),g=Math.max(W.end,d);Ge({start:h,end:g})}else Ge({start:d,end:d});return!0},mouseover:(t,a,l)=>{if(!(l instanceof MouseEvent)||l.buttons!==1||!Bt.current||gt.current===null)return!1;const d=t.state.doc.lineAt(a.from).number,h=Math.min(gt.current,d),g=Math.max(gt.current,d);return Ge({start:h,end:g}),$t(!0),!1},mouseup:()=>(Bt.current=!1,gt.current=null,$t(!1),!1)}}},mt)}),Ut&&n.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:n.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),r("filesView.state.openingFileAtChange")]})})]}):n.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:r("filesView.editor.pickFileFromTree")})})})]}),_a=!!(c&&$n[c]),Ys=c?br[c]:null,Qs=D?n.jsxs("section",{className:q("flex min-h-0 flex-col overflow-hidden",m?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[n.jsx("div",{className:q("flex flex-col gap-2 py-2",m?"px-3":"px-2"),children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"relative flex-1 min-w-0",children:[n.jsx(F,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),n.jsx(gr,{ref:he,value:Y,onChange:t=>Q(t.target.value),placeholder:r("filesView.tree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),Y.trim().length>0&&n.jsx("button",{type:"button","aria-label":r("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(""),he.current?.focus()},children:n.jsx(F,{name:"close",className:"size-4"})})]}),n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>fn("createFile",{path:y,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:r("filesView.tree.actions.newFileTitle"),"aria-label":r("filesView.tree.actions.newFileTitle"),children:n.jsx(F,{name:"file-add",className:"size-4"})})})}),n.jsx(Yt,{side:"bottom",sideOffset:6,children:r("filesView.tree.actions.newFileTitle")})]}),n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>fn("createFolder",{path:y,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:r("filesView.tree.actions.newFolderTitle"),"aria-label":r("filesView.tree.actions.newFolderTitle"),children:n.jsx(F,{name:"folder-add",className:"size-4"})})})}),n.jsx(Yt,{side:"bottom",sideOffset:6,children:r("filesView.tree.actions.newFolderTitle")})]}),n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{Mr()},className:"size-8 p-0 flex-shrink-0",title:r("filesView.tree.actions.refreshTitle"),"aria-label":r("filesView.tree.actions.refreshTitle"),children:n.jsx(F,{name:"refresh",className:"size-4"})})})}),n.jsx(Yt,{side:"bottom",sideOffset:6,children:r("filesView.tree.actions.refreshTitle")})]})]})}),n.jsx(kn,{outerClassName:"flex-1 min-h-0",className:q("py-2",m?"px-3":"px-2"),children:n.jsx("ul",{className:"flex flex-col",children:$i?n.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),r("filesView.tree.search.searching")]}):_n.length>0?_n.map(t=>{const a=u?.path===t.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>{Pe(t)},className:q("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",a?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[Ai(t.path,t.extension),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},title:t.path,children:t.relativePath??t.path})]})},t.path)}):Ys?n.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{className:"text-[var(--status-error)]",children:Ys}),n.jsxs(I,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{Mr()},children:[n.jsx(F,{name:"refresh",className:"size-3.5"}),r("filesView.tree.actions.refreshTitle")]})]}):_a?Ns(c,0):n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:r("filesView.state.loading")})})})]}):null,Wa=i==="full"&&te&&u&&n.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:n.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[n.jsx("div",{className:"absolute right-4 top-4 z-30",children:Js({exitFullscreenOnly:!0})}),n.jsx(kn,{ref:Oa,outerClassName:"h-full min-w-0",className:q("h-full min-w-0",at&&"[overflow-anchor:none]"),children:Me||zs?$?n.jsx("div",{className:"p-4"}):n.jsxs("div",{className:"p-4 flex items-center gap-2 typography-ui text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),"Loading…"]}):tt?n.jsx("div",{className:"p-4 typography-ui text-[color:var(--status-error)]",children:tt}):ke?n.jsx("div",{className:"flex h-full items-center justify-center p-4",children:n.jsx("img",{src:Ls,alt:u.name,className:"max-w-full max-h-full object-contain rounded-md border border-border/30 bg-primary/10"},u.path)}):_e?Is(u):it?n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("div",{className:"typography-ui-header text-foreground",children:r("filesView.editor.cannotPreviewBinary")}),n.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:r("filesView.editor.binaryFileDescription")}),o.downloadFile?n.jsxs(I,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=o.downloadFile;!t||!u||t(u.path).catch(a=>{console.error("Download failed:",a),J.error(r("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(F,{name:"download",className:"mr-2 size-4"}),r("filesView.editor.saveFile")]}):null]}):Je&&Ae()==="preview"?n.jsxs("div",{className:"relative h-full min-h-0",children:[n.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-4 outline-none",tabIndex:-1,onMouseDown:Tr,ref:$a,children:[u?n.jsx(hi,{containerRef:Er,filePath:u.path,fileContent:O}):null,O.length>500*1024&&n.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:r("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(O.length/1024)})}),n.jsx(Rn,{fallback:n.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 font-medium text-destructive",children:r("filesView.error.previewUnavailable")}),n.jsx("div",{className:"text-sm text-muted-foreground",children:r("filesView.error.switchToEditMode")})]}),children:n.jsx(di,{content:O,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}),n.jsx(vi,{containerRef:Er,open:Xn,onOpenChange:kr,focusNonce:Jn,className:"right-4 top-16"})]}):Br&&_==="view"?Xs(u,ee,Bs,Aa):n.jsxs("div",{className:q("relative h-full",Ut&&"overflow-hidden"),children:[n.jsx("div",{className:q("h-full",Ut&&"invisible"),children:n.jsx(Ni,{positionKey:`${mt}:fullscreen`,value:ee,onChange:Ce,readOnly:!Xe,vimMode:is==="vim",extensions:Ts,className:"h-full",onViewReady:t=>{He.current=t,window.requestAnimationFrame(()=>{Ht(t)})},onViewDestroy:()=>{He.current&&(He.current=null)}},`${mt}:fullscreen`)}),Ut&&n.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:n.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),r("filesView.state.openingFileAtChange")]})})]})})]})});return n.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[n.jsx(Al,{activeDialog:Ct,dialogData:St,dialogInputValue:pt,onDialogInputChange:qn,isDialogSubmitting:Zi,onDialogSubmit:pa,onClose:Ma,inputRef:qi}),Wa,m?oe?Fn:Qs:i==="editor-only"?n.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:n.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:Fn})}):n.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[j>=700&&n.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:Qs}),n.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:Fn})]})]})};function Ol(i){return i+1}export{sd as FilesView};
|