@openchamber/web 1.19.0 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/dist/assets/{CodeMirrorCommentWidgets-DAvopJvy.js → CodeMirrorCommentWidgets-C36E738Y.js} +1 -1
  2. package/dist/assets/{CommitSection-D9cV-qR9.js → CommitSection-C-F3AX6D.js} +1 -1
  3. package/dist/assets/{DiagramEditor-B9NCadU7.js → DiagramEditor-BPECg1jS.js} +1 -1
  4. package/dist/assets/DiagramView-D0YNMix8.js +1 -0
  5. package/dist/assets/DiffView-BHWaMYCC.js +4 -0
  6. package/dist/assets/FilesView-NMBCW2Tm.js +14 -0
  7. package/dist/assets/{GitView-DsWXqWx3.js → GitView-Rp8P1KEI.js} +4 -4
  8. package/dist/assets/{JsonTreeView-h4dHASlq.js → JsonTreeView-KnXFN2A-.js} +1 -1
  9. package/dist/assets/{MarkdownImageGallery-n0ikH-xm.js → MarkdownImageGallery-BMn3mtor.js} +1 -1
  10. package/dist/assets/MarkdownRendererImpl-kD6N03pH.js +12 -0
  11. package/dist/assets/{OnboardingScreen-CDjgzxEe.js → OnboardingScreen-CenIeD4v.js} +1 -1
  12. package/dist/assets/{PatchDiff-jPKTJje5.js → PatchDiff-BzVOVog8.js} +1 -1
  13. package/dist/assets/{PierreDiffViewer-D_Gt4A_6.js → PierreDiffViewer-Dlby4XqT.js} +2 -2
  14. package/dist/assets/PlanView-Czu1KMJa.js +4 -0
  15. package/dist/assets/SessionSwitcherDropdown-IETz58DB.js +1 -0
  16. package/dist/assets/SettingsView-B6vmuf-c.js +28 -0
  17. package/dist/assets/SettingsWindow-CauZpdD3.js +1 -0
  18. package/dist/assets/ToolOutputDialog-BB1c--Zr.js +15 -0
  19. package/dist/assets/ToolPartDiffPreview-DaOIDISD.js +8 -0
  20. package/dist/assets/{VirtualizedFileDiff-B37yB9jZ.js → VirtualizedFileDiff-lESMT-2b.js} +4 -4
  21. package/dist/assets/{WalkthroughView-Bxun3k66.js → WalkthroughView-CaSYE0lw.js} +1 -1
  22. package/dist/assets/{computeVirtualFileMetrics-DYFv_yZS.js → computeVirtualFileMetrics-DkRR5b75.js} +2 -2
  23. package/dist/assets/{contextPanelEmbeddedChat-BO1wRpaN.js → contextPanelEmbeddedChat-BEARQjgn.js} +1 -1
  24. package/dist/assets/de-DFdX3ABv.js +9 -0
  25. package/dist/assets/es-iC-FKvV9.js +15 -0
  26. package/dist/assets/fr-BBbi_1AL.js +13 -0
  27. package/dist/assets/{index-BSvmTvZl.js → index-BiEgzzkg.js} +1 -1
  28. package/dist/assets/index-Cwmuwk3V.js +7 -0
  29. package/dist/assets/index-GNm1wgUH.css +1 -0
  30. package/dist/assets/{isDiffPlainText-DwHKxDYc.js → isDiffPlainText-BG53Ixxy.js} +1 -1
  31. package/dist/assets/{isFilePlainText-Dwq6ILxo.js → isFilePlainText-BbV-39jl.js} +1 -1
  32. package/dist/assets/ja-DQLQJL2J.js +15 -0
  33. package/dist/assets/ko-BeElEB4Y.js +15 -0
  34. package/dist/assets/main-Dpzo18z7.js +2 -0
  35. package/dist/assets/main-WMjtYzJs.js +921 -0
  36. package/dist/assets/markdownCore--tDmyI_v.js +2 -0
  37. package/dist/assets/miniChat-ldEghBLB.js +2 -0
  38. package/dist/assets/mobile-Dk-VGreF.js +2 -0
  39. package/dist/assets/{patchFileDiff-BEDPDypx.js → patchFileDiff-BcFaMtMu.js} +2 -2
  40. package/dist/assets/pl-CLHt2_vV.js +15 -0
  41. package/dist/assets/pt-BR-C_MPUq7e.js +15 -0
  42. package/dist/assets/renderElectronMiniChatApp-DIgCOmXY.js +2 -0
  43. package/dist/assets/{renderMobileApp-BiMbzPq9.js → renderMobileApp-CDfHS5rr.js} +7 -7
  44. package/dist/assets/runtimeEndpointReset-ovNbaZ-x.js +15 -0
  45. package/dist/assets/{scheduledTasksApi-01zzfzqH.js → scheduledTasksApi-BFSlqgnG.js} +1 -1
  46. package/dist/assets/{shikiHighlight-DXYW46vW.js → shikiHighlight-DCT2Sq_z.js} +1 -1
  47. package/dist/assets/uk-PhsC-c4-.js +15 -0
  48. package/dist/assets/{useAppFontEffects-CbzHzFop.js → useAppFontEffects-B53Rb6m7.js} +166 -159
  49. package/dist/assets/useInlineCommentController-DSfrIBKT.js +2 -0
  50. package/dist/assets/{vendor-base-ui-BYlZTzrw.js → vendor-base-ui-DsHmyMwp.js} +1 -1
  51. package/dist/assets/{vendor-codemirror-language-data-CiAYDJXN.js → vendor-codemirror-language-data-vch3tJ4c.js} +2 -2
  52. package/dist/assets/vendor-zod-C9ioTTSo.js +39 -0
  53. package/dist/assets/{web-components-DCLjCO9n.js → web-components-pcwCTWjC.js} +4 -4
  54. package/dist/assets/zh-CN-wF-NOFHM.js +15 -0
  55. package/dist/assets/zh-TW-4m4-A7rT.js +15 -0
  56. package/dist/index.html +5 -4
  57. package/dist/mini-chat.html +4 -3
  58. package/dist/mobile.html +4 -3
  59. package/package.json +3 -5
  60. package/server/index.js +36 -0
  61. package/server/lib/agent-memory/project-resolution.js +10 -1
  62. package/server/lib/agent-memory/project-resolution.test.js +9 -0
  63. package/server/lib/agent-memory/runtime.js +7 -2
  64. package/server/lib/dictation/DOCUMENTATION.md +32 -8
  65. package/server/lib/dictation/local/sherpa-recognizer.js +35 -78
  66. package/server/lib/dictation/local/worker-process.js +2 -2
  67. package/server/lib/dictation/openai-compatible-session.js +3 -2
  68. package/server/lib/dictation/stream-manager.js +77 -34
  69. package/server/lib/dictation/stream-manager.test.js +60 -2
  70. package/server/lib/fs/routes.test.js +76 -0
  71. package/server/lib/git/routes.js +43 -0
  72. package/server/lib/git/service.js +85 -5
  73. package/server/lib/git/service.test.js +93 -0
  74. package/server/lib/opencode/DOCUMENTATION.md +6 -2
  75. package/server/lib/opencode/feature-routes-runtime.js +5 -9
  76. package/server/lib/opencode/lifecycle.js +202 -26
  77. package/server/lib/opencode/lifecycle.test.js +179 -1
  78. package/server/lib/opencode/providers.js +9 -4
  79. package/server/lib/opencode/providers.test.js +27 -0
  80. package/server/lib/opencode/restart-session-recovery.test.js +59 -0
  81. package/server/lib/opencode/session-runtime.js +39 -2
  82. package/server/lib/opencode/session-runtime.test.js +74 -0
  83. package/server/lib/opencode/settings-helpers.js +15 -0
  84. package/server/lib/opencode/settings-helpers.test.js +22 -0
  85. package/server/lib/opencode/settings-normalization-runtime.js +3 -0
  86. package/server/lib/opencode/settings-normalization-runtime.test.js +16 -0
  87. package/server/lib/opencode/settings-runtime.js +32 -10
  88. package/server/lib/opencode/settings-runtime.test.js +85 -0
  89. package/server/lib/opencode/skill-routes.js +29 -73
  90. package/server/lib/opencode/skill-routes.test.js +2 -5
  91. package/server/lib/project-context/DOCUMENTATION.md +2 -0
  92. package/server/lib/project-context/runtime.js +7 -2
  93. package/server/lib/projects/project-config.js +7 -2
  94. package/server/lib/quota/DOCUMENTATION.md +1 -1
  95. package/server/lib/quota/providers/claude/index.js +2 -2
  96. package/server/lib/quota/providers/command-code.js +1 -1
  97. package/server/lib/quota/providers/command-code.test.js +13 -0
  98. package/server/lib/quota/providers/index.js +12 -4
  99. package/server/lib/quota/providers/zai.js +26 -6
  100. package/server/lib/quota/providers/zai.test.js +33 -0
  101. package/server/lib/session-knowledge/DOCUMENTATION.md +2 -0
  102. package/server/lib/skills-catalog/DOCUMENTATION.md +18 -45
  103. package/server/lib/skills-catalog/cache.js +120 -1
  104. package/server/lib/skills-catalog/cache.test.js +77 -0
  105. package/server/lib/skills-catalog/curated-sources.js +21 -5
  106. package/server/lib/skills-catalog/curated-sources.test.js +4 -4
  107. package/server/lib/skills-catalog/disk-cache.js +52 -0
  108. package/server/lib/skills-catalog/github-meta.js +139 -0
  109. package/server/lib/skills-catalog/github-meta.test.js +71 -0
  110. package/server/lib/skills-catalog/source.js +0 -5
  111. package/server/lib/small-model/DOCUMENTATION.md +74 -6
  112. package/server/lib/small-model/call.js +46 -12
  113. package/server/lib/small-model/call.test.js +79 -0
  114. package/server/lib/small-model/index.js +51 -8
  115. package/server/lib/small-model/index.test.js +73 -3
  116. package/server/lib/small-model/routes.js +1 -1
  117. package/server/lib/small-model/runtime-providers.js +156 -0
  118. package/server/lib/small-model/runtime-providers.test.js +112 -0
  119. package/dist/assets/DiagramView-LKGBwf4G.js +0 -1
  120. package/dist/assets/DiffView-BWNq-0ov.js +0 -4
  121. package/dist/assets/FilesView-DB-Q0Gkz.js +0 -14
  122. package/dist/assets/MarkdownRendererImpl-CT2mjx-s.js +0 -12
  123. package/dist/assets/PlanView-UvuxIl9-.js +0 -4
  124. package/dist/assets/SessionSwitcherDropdown-xKU4LRuQ.js +0 -1
  125. package/dist/assets/SettingsView-3B9VN6Ys.js +0 -28
  126. package/dist/assets/SettingsWindow-CqQNDKNd.js +0 -1
  127. package/dist/assets/ToolOutputDialog-PmjlAxVE.js +0 -15
  128. package/dist/assets/ToolPartDiffPreview-B34Xw9wq.js +0 -8
  129. package/dist/assets/de-DbV6CLxv.js +0 -9
  130. package/dist/assets/es-CVDlyzZ4.js +0 -15
  131. package/dist/assets/fr-Czc-p0g-.js +0 -13
  132. package/dist/assets/index-1OhiMDBz.css +0 -1
  133. package/dist/assets/index-DzriVon2.js +0 -7
  134. package/dist/assets/ja-dwc9NM_S.js +0 -15
  135. package/dist/assets/ko-Ds1DZ8FX.js +0 -15
  136. package/dist/assets/main-BF51IOVF.js +0 -921
  137. package/dist/assets/main-D7UPARut.js +0 -2
  138. package/dist/assets/markdownCore-BgeBDwD3.js +0 -2
  139. package/dist/assets/miniChat-BISXSGOo.js +0 -2
  140. package/dist/assets/mobile-BnYxVuvw.js +0 -2
  141. package/dist/assets/pl-CLiTO7i-.js +0 -15
  142. package/dist/assets/pt-BR-GIimJgpK.js +0 -15
  143. package/dist/assets/renderElectronMiniChatApp-BaOy72Gi.js +0 -2
  144. package/dist/assets/runtimeEndpointReset-BMBRhIbf.js +0 -15
  145. package/dist/assets/uk-DLfgD1ki.js +0 -15
  146. package/dist/assets/useInlineCommentController-CegKdDXi.js +0 -2
  147. package/dist/assets/vendor-zod-adaMkgkm.js +0 -39
  148. package/dist/assets/zh-CN-DkeP5awK.js +0 -15
  149. package/dist/assets/zh-TW-BocaFm3d.js +0 -15
  150. package/server/lib/skills-catalog/clawdhub/api.js +0 -126
  151. package/server/lib/skills-catalog/clawdhub/install.js +0 -238
  152. package/server/lib/skills-catalog/clawdhub/install.test.js +0 -100
  153. package/server/lib/skills-catalog/clawdhub/scan.js +0 -61
@@ -1,14 +0,0 @@
1
- import{R as n,j as s,f as Gt}from"./vendor-react-BUCujlKS.js";import{Q as Kn,R as Hn,S as qn,T as _n,ai as vi,n as ze,u as he,cT as Xn,B as wi,v as Jn,r as bi,V as yi,e as Qn,cR as Yn,aH as Zn,cS as ea,a as ta}from"./index-DzriVon2.js";import{f as Ds,S as Ts,B as S,h as O,V as sa,L as ra,aV as ia,a0 as na,a1 as aa,b_ as oa,gX as ji,gs as la,t as I,l as Fi,aa as sr,bV as Fs,cq as ca,b as da,gY as rr,ab as Ni,gZ as Ci,bW as Si,bX as ua,fO as fa,g_ as ma,br as ha,g$ as pa,bs as Ii,bt as Oi,bu as Bi,bv as $i,bw as Wi,bx as Ui,I as g,aU as cr,aR as dr,ad as Cs,aT as ur,aQ as Ss,aX as ht,aY as pt,aZ as gt,bU as ir,ac as nr,bQ as ki,by as ga,bz as xa,gq as ar,g as Vs,aS as va,a_ as wa}from"./useAppFontEffects-CbzHzFop.js";import{w as ba,x as ya,y as ja,z as Fa,A as Na}from"./runtimeEndpointReset-BMBRhIbf.js";import{c as Ti,s as Ca,C as Vi,P as or}from"./shikiHighlight-DXYW46vW.js";import{a as Sa}from"./vendor-codemirror-state-C9awkmn-.js";import{E as kt}from"./vendor-codemirror-view-CiLROUVV.js";import{F as ka,J as Ta}from"./JsonTreeView-h4dHASlq.js";import{ensurePierreThemeRegistered as Di,getResolvedShikiTheme as Va}from"./appThemeRegistry-BK0dHKa6.js";import{u as Ns,c as Da,e as Ea}from"./scheduledTasksApi-01zzfzqH.js";import{D as Ra}from"./DiagramEditor-B9NCadU7.js";import{u as Pa,n as Ma}from"./useInlineCommentController-CegKdDXi.js";import{b as za}from"./CodeMirrorCommentWidgets-DAvopJvy.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-BYlZTzrw.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-BO1wRpaN.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-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-CiAYDJXN.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-zod-adaMkgkm.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-DCLjCO9n.js";import"./computeVirtualFileMetrics-DYFv_yZS.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"./Virtualizer-X_7XPoTH.js";import"./isFilePlainText-Dwq6ILxo.js";import"./registerCustomTheme-BBXUCRnG.js";import"./vendor-react-drawio-Ct3Q0DsD.js";const La=(d,e)=>{if(!e)return null;const r=Number.parseInt(d.trim(),10);return!Number.isFinite(r)||r<1?null:Math.min(r,e.state.doc.lines)},Ei=(d,e)=>{const r=d.state.doc.lineAt(e.main.head);return{lineNumber:r.number,character:e.main.head-r.from+1,selection:e}},Ri=(d,e,r)=>{const m=d.state.doc.line(e),x=Math.max(1,Math.min(r,m.length+1)),v=m.from+x-1;d.dispatch({selection:Sa.cursor(v),effects:kt.scrollIntoView(v,{y:"center"})})};function Aa({open:d,onOpenChange:e,view:r,variant:m="overlay"}){const{t:x}=Ds(),[v,y]=n.useState(""),b=n.useRef(null),h=n.useRef(!1),j=n.useRef(null),p=n.useRef(null),F=n.useMemo(()=>La(v,r),[v,r]);n.useEffect(()=>{!d||!r||(h.current=!1,b.current=Ei(r,r.state.selection),y(""))},[d,r]),n.useEffect(()=>{d&&window.requestAnimationFrame(()=>{p.current?.focus(),p.current?.select()})},[d]),n.useEffect(()=>{if(!(!d||!r||!b.current)){if(F===null){const{selection:o}=b.current;r.dispatch({selection:o,effects:kt.scrollIntoView(o.main.from,{y:"center"})});return}Ri(r,F,b.current.character)}},[F,d,r]);const z=n.useCallback(()=>{if(!r||h.current||!b.current)return;const{selection:o}=b.current;r.dispatch({selection:o,effects:kt.scrollIntoView(o.main.from,{y:"center"})})},[r]),E=n.useCallback(o=>{o||z(),e(o)},[e,z]),N=n.useCallback(()=>{!r||F===null||!b.current||(h.current=!0,Ri(r,F,b.current.character),e(!1),r.focus())},[F,e,r]);n.useEffect(()=>{if(!d)return;const o=W=>{const _=j.current,L=W.target;!_||!(L instanceof Node)||_.contains(L)||E(!1)},q=W=>{W.key==="Escape"&&(W.preventDefault(),E(!1))};return document.addEventListener("pointerdown",o,!0),document.addEventListener("keydown",q,!0),()=>{document.removeEventListener("pointerdown",o,!0),document.removeEventListener("keydown",q,!0)}},[E,d,m]);const R=n.useMemo(()=>{if(!r)return x("goToLineDialog.helper.editorUnavailable");if(F===null){const o=b.current??Ei(r,r.state.selection);return x("goToLineDialog.helper.currentLineRange",{current:o.lineNumber,max:r.state.doc.lines})}return x("goToLineDialog.helper.goToLine",{line:F})},[F,x,r]);return m==="inline"?d?s.jsxs("div",{ref:j,className:"ml-1 flex h-6 items-center gap-1",children:[s.jsx(Ts,{ref:p,type:"number",min:1,step:1,inputMode:"numeric",value:v,onChange:o=>y(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),N())},placeholder:x("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),s.jsx(S,{variant:"outline",size:"xs",onClick:N,disabled:!r||F===null,className:"h-6 px-2",children:x("goToLineDialog.actions.go")})]}):null:s.jsx("div",{ref:j,className:O("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",d?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:s.jsxs("div",{className:"min-w-0",children:[s.jsx(Ts,{ref:p,type:"number",min:1,step:1,inputMode:"numeric",value:v,onChange:o=>y(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),N())},placeholder:x("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-background/60 typography-ui-label"}),s.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:R})]})})}function Ia(d){return!(!d.autoSaveEnabled||!d.isDirty||!d.canWrite||d.isSaving||d.fileLoading||d.isNonEditableBinary||!d.selectedFilePath||d.loadedFilePath!==d.selectedFilePath)}function Oa(d){return d.selectedFilePath?d.isDirty?!(d.fileLoading||d.loadedFilePath!==d.selectedFilePath||d.isNonEditableBinary||d.draftContent===""&&d.fileContent!==""&&d.loadedFilePath!==d.selectedFilePath):!0:!1}const Ba=d=>{const e=M(d);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 m=e.slice(0,r);return/^[A-Za-z]:$/.test(m)?`${m}/`:m},$a=d=>{const e=Gt.c(8),{label:r,iconDataUrl:m}=d,[x,v]=n.useState(!1);let y;e[0]!==r?(y=r.trim().slice(0,1).toUpperCase()||"?",e[0]=r,e[1]=y):y=e[1];const b=y;if(m&&!x){let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>v(!0),e[2]=p):p=e[2];let F;return e[3]!==m?(F=s.jsx("img",{src:m,alt:"",className:"size-4 rounded-sm",onError:p}),e[3]=m,e[4]=F):F=e[4],F}let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=O("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=h):h=e[5];let j;return e[6]!==b?(j=s.jsx("span",{className:h,children:b}),e[6]=b,e[7]=j):j=e[7],j},Wa=d=>d.slice().sort((e,r)=>e.type!==r.type?e.type==="directory"?-1:1:e.name.localeCompare(r.name)),M=d=>{if(!d)return"";const e=d.replace(/\\/g,"/"),r=e.startsWith("//");let m=e.replace(/\/+/g,"/");r&&!m.startsWith("//")&&(m=`/${m}`);const x=m==="/",v=/^[A-Za-z]:\/$/.test(m);return!x&&!v&&(m=m.replace(/\/+$/,"")),m},Ua=d=>d.startsWith("/")||d.startsWith("//")||/^[A-Za-z]:\//.test(d),Ut=d=>/^[A-Za-z]:\//.test(d)?d.toLowerCase():d,is=(d,e)=>{const r=M(e),m=M(d);if(!r||!m)return!1;const x=Ut(r),v=Ut(m);return v===x||v.startsWith(`${x}/`)},Pi=(d,e)=>{const r=M(e),m=M(d);if(!is(m,r))return[];const v=m.slice(r.length).replace(/^\//,"").split("/"),y=[];let b=r;for(let h=0;h<v.length-1;h++)b=b?`${b}/${v[h]}`:v[h],y.push(b);return y},ks=(d,e)=>{if(!e)return"";const r=M(e);if(!d||!is(r,d))return r;const m=r.slice(d.length);return m.startsWith("/")?m.slice(1):m},Ga=new Set(["node_modules"]),Ka=d=>{const e=Gt.c(3),{status:r}=d;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={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]=m):m=e[0];const x=m[r];let v;return e[1]!==x?(v=s.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:x}}),e[1]=x,e[2]=v):v=e[2],v},Mi=d=>{const e=Gt.c(11),{name:r}=d,m=n.useRef(null),x=n.useRef(null),[v,y]=n.useState(!1);let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{const z=m.current,E=x.current;if(!z||!E)return;const N=()=>{y(E.scrollWidth>z.clientWidth+1)};N();const R=new ResizeObserver(N);return R.observe(z),R.observe(E),()=>{R.disconnect()}},e[0]=b):b=e[0];let h;e[1]!==r?(h=[r],e[1]=r,e[2]=h):h=e[2],n.useLayoutEffect(b,h);let j;e[3]!==r?(j=s.jsx("span",{ref:x,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:r}),e[3]=r,e[4]=j):j=e[4];let p;e[5]!==r||e[6]!==v?(p=v?s.jsxs("span",{className:"open-file-name-marquee-track",children:[s.jsx("span",{className:"open-file-name-marquee-item",children:r}),s.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:r})]}):s.jsx("span",{className:"block min-w-0 truncate",children:r}),e[5]=r,e[6]=v,e[7]=p):p=e[7];let F;return e[8]!==j||e[9]!==p?(F=s.jsxs("span",{ref:m,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[j,p]}),e[8]=j,e[9]=p,e[10]=F):F=e[10],F},Ha=d=>Ga.has(d),qa=d=>{const e=M(d);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},_a=d=>{const r=(d instanceof Error?d.message:String(d??"")).toLowerCase();return r.includes("is a directory")||r.includes("eisdir")},zi=d=>{const r=(d instanceof Error?d.message:String(d??"")).toLowerCase();return r.includes("file not found")||r.includes("enoent")||r.includes("no such file")||r.includes("does not exist")},rs=2e5,Xa=d=>{let e=0,r=0;for(let m=0;m<d.length;m+=1)d.charCodeAt(m)===10&&(m>0&&d.charCodeAt(m-1)===13?e+=1:r+=1);return e>r?`\r
2
- `:`
3
- `},Gi=d=>d.replace(/\r\n/g,`
4
- `).replace(/\r/g,`
5
- `),Ja=(d,e)=>{const r=Gi(d);return e===`\r
6
- `?r.replace(/\n/g,`\r
7
- `):r},Ki=(d,e)=>s.jsx(Cs,{filePath:d,extension:e}),Li=d=>{if(!d)return!1;const e=d.toLowerCase().split(".").pop();return e==="md"||e==="markdown"},Qa=d=>{if(!d)return!1;const e=d.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},lr=d=>{if(!d)return!1;const e=d.toLowerCase().split(".").pop();return e==="html"||e==="htm"},Ya=d=>{const e=Gt.c(76),{node:r,root:m,isExpanded:x,isActive:v,isMobile:y,isBrowserClient:b,alwaysShowActions:h,status:j,badge:p,permissions:F,downloadFile:z,contextMenuPath:E,setContextMenuPath:N,rightClickMenuPath:R,setRightClickMenuPath:o,onSelect:q,onToggle:W,onRevealPath:_,onOpenDialog:L}=d,{t:T}=Ds(),V=r.type==="directory",{canRename:le,canCreateFile:Y,canCreateFolder:Z,canDelete:A,canReveal:ce}=F,Le=!V&&!!z,U=ce&&!b,X=le||Y||Z||A||Le||U;let ee;e[0]!==X||e[1]!==r.path||e[2]!==o?(ee=fe=>{X&&(fe?.preventDefault(),o(r.path))},e[0]=X,e[1]=r.path,e[2]=o,e[3]=ee):ee=e[3];const pe=ee;let te;e[4]!==V||e[5]!==r||e[6]!==q||e[7]!==W?(te=()=>{V?W(r.path):q(r)},e[4]=V,e[5]=r,e[6]=q,e[7]=W,e[8]=te):te=e[8];const ge=te;let de;e[9]!==r.path||e[10]!==N||e[11]!==o?(de=fe=>{fe.stopPropagation(),o(null),N(r.path)},e[9]=r.path,e[10]=N,e[11]=o,e[12]=de):de=e[12];const rt=de;let Tt;e[13]!==Y||e[14]!==Z||e[15]!==A||e[16]!==le||e[17]!==U||e[18]!==z||e[19]!==b||e[20]!==V||e[21]!==r||e[22]!==L||e[23]!==_||e[24]!==m||e[25]!==T?(Tt=fe=>{const{Item:ve,Separator:wt}=fe;return s.jsxs(s.Fragment,{children:[le&&s.jsxs(ve,{onClick:C=>{C.stopPropagation(),L("rename",r)},children:[s.jsx(g,{name:"edit",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.rename")]}),s.jsxs(ve,{onClick:C=>{C.stopPropagation(),Vs(r.path).then(we=>{if(we.ok){I.success(T("sidebarFilesTree.toast.pathCopied"));return}I.error(T("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(g,{name:"file-copy",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.copyPath")]}),s.jsxs(ve,{onClick:C=>{C.stopPropagation();const we=ks(m,r.path)||r.path;Vs(we).then(Je=>{if(Je.ok){I.success(T("filesView.toast.relativePathCopied"));return}I.error(T("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(g,{name:"file-copy-2",className:"mr-2 size-4"})," ",T("filesView.tree.menu.copyRelativePath")]}),!V&&z&&s.jsxs(ve,{onClick:C=>{C.stopPropagation(),z(r.path).catch(we=>{console.error("Download failed:",we),I.error(T("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(g,{name:"download",className:"mr-2 size-4"})," ",T(b?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),U&&s.jsxs(ve,{onClick:C=>{C.stopPropagation(),_(r.path)},children:[s.jsx(g,{name:"folder-received",className:"mr-2 size-4"})," ",T(wa())]}),V&&(Y||Z)&&s.jsxs(s.Fragment,{children:[s.jsx(wt,{}),Y&&s.jsxs(ve,{onClick:C=>{C.stopPropagation(),L("createFile",r)},children:[s.jsx(g,{name:"file-add",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.newFile")]}),Z&&s.jsxs(ve,{onClick:C=>{C.stopPropagation(),L("createFolder",r)},children:[s.jsx(g,{name:"folder-add",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.newFolder")]})]}),A&&s.jsxs(s.Fragment,{children:[s.jsx(wt,{}),s.jsxs(ve,{onClick:C=>{C.stopPropagation(),L("delete",r)},className:"text-destructive focus:text-destructive",children:[s.jsx(g,{name:"delete-bin",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.delete")]})]})]})},e[13]=Y,e[14]=Z,e[15]=A,e[16]=le,e[17]=U,e[18]=z,e[19]=b,e[20]=V,e[21]=r,e[22]=L,e[23]=_,e[24]=m,e[25]=T,e[26]=Tt):Tt=e[26];const Xe=Tt,G=R===r.path;let Fe;e[27]!==r.path||e[28]!==o?(Fe=fe=>o(fe?r.path:null),e[27]=r.path,e[28]=o,e[29]=Fe):Fe=e[29];const xt=y?void 0:pe;let Ae;e[30]!==xt?(Ae=s.jsx("div",{className:"group relative flex items-center",onContextMenu:xt}),e[30]=xt,e[31]=Ae):Ae=e[31];const Ie=y?void 0:pe,vt=v?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let xe;e[32]!==vt?(xe=O("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",vt),e[32]=vt,e[33]=xe):xe=e[33];let Oe;e[34]!==V||e[35]!==x||e[36]!==r.extension||e[37]!==r.path?(Oe=V?x?s.jsx(g,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):s.jsx(g,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):Ki(r.path,r.extension),e[34]=V,e[35]=x,e[36]=r.extension,e[37]=r.path,e[38]=Oe):Oe=e[38];let ue;e[39]!==r.name||e[40]!==r.path?(ue=s.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]=ue):ue=e[41];let Ne;e[42]!==V||e[43]!==j?(Ne=!V&&j&&s.jsx(Ka,{status:j}),e[42]=V,e[43]=j,e[44]=Ne):Ne=e[44];let it;e[45]!==p||e[46]!==V?(it=V&&p&&s.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[p.modified>0&&s.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",p.modified]}),p.added>0&&s.jsxs("span",{className:"text-[var(--status-success)]",children:["+",p.added]})]}),e[45]=p,e[46]=V,e[47]=it):it=e[47];let nt;e[48]!==ge||e[49]!==xe||e[50]!==Oe||e[51]!==ue||e[52]!==Ne||e[53]!==it||e[54]!==Ie?(nt=s.jsxs("button",{type:"button",onClick:ge,onContextMenu:Ie,className:xe,children:[Oe,ue,Ne,it]}),e[48]=ge,e[49]=xe,e[50]=Oe,e[51]=ue,e[52]=Ne,e[53]=it,e[54]=Ie,e[55]=nt):nt=e[55];let Be;e[56]!==h||e[57]!==E||e[58]!==rt||e[59]!==X||e[60]!==y||e[61]!==r.path||e[62]!==Xe||e[63]!==N?(Be=X&&s.jsx("div",{className:O("absolute right-1 top-1/2 -translate-y-1/2",h?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:s.jsxs(cr,{open:E===r.path,onOpenChange:fe=>N(fe?r.path:null),children:[s.jsx(dr,{asChild:!0,children:s.jsx(S,{variant:"ghost",size:"icon",className:"size-6",onClick:rt,children:s.jsx(g,{name:"more-2-fill",className:"size-4"})})}),s.jsx(ur,{align:"end",side:"bottom",onCloseAutoFocus:()=>N(null),children:Xe({Item:Ss,Separator:va})})]})}),e[56]=h,e[57]=E,e[58]=rt,e[59]=X,e[60]=y,e[61]=r.path,e[62]=Xe,e[63]=N,e[64]=Be):Be=e[64];let $e;e[65]!==nt||e[66]!==Be||e[67]!==Ae?($e=s.jsxs(Fa,{render:Ae,children:[nt,Be]}),e[65]=nt,e[66]=Be,e[67]=Ae,e[68]=$e):$e=e[68];let We;e[69]!==Xe?(We=s.jsx(ba,{className:"min-w-[180px]",children:Xe({Item:ja,Separator:ya})}),e[69]=Xe,e[70]=We):We=e[70];let at;return e[71]!==$e||e[72]!==We||e[73]!==G||e[74]!==Fe?(at=s.jsxs(Na,{open:G,onOpenChange:Fe,children:[$e,We]}),e[71]=$e,e[72]=We,e[73]=G,e[74]=Fe,e[75]=at):at=e[75],at},Za=d=>{const e=Gt.c(83),{activeDialog:r,dialogData:m,dialogInputValue:x,onDialogInputChange:v,isDialogSubmitting:y,onDialogSubmit:b,onClose:h,inputRef:j}=d,{t:p}=Ds(),F=!!r;let z;e[0]!==h?(z=de=>!de&&h(),e[0]=h,e[1]=z):z=e[1];let E;e[2]!==r||e[3]!==p?(E=r==="createFile"&&p("filesView.dialog.createFile.title"),e[2]=r,e[3]=p,e[4]=E):E=e[4];let N;e[5]!==r||e[6]!==p?(N=r==="createFolder"&&p("filesView.dialog.createFolder.title"),e[5]=r,e[6]=p,e[7]=N):N=e[7];let R;e[8]!==r||e[9]!==p?(R=r==="rename"&&p("filesView.dialog.rename.title"),e[8]=r,e[9]=p,e[10]=R):R=e[10];let o;e[11]!==r||e[12]!==p?(o=r==="delete"&&p("filesView.dialog.delete.title"),e[11]=r,e[12]=p,e[13]=o):o=e[13];let q;e[14]!==E||e[15]!==N||e[16]!==R||e[17]!==o?(q=s.jsxs($i,{children:[E,N,R,o]}),e[14]=E,e[15]=N,e[16]=R,e[17]=o,e[18]=q):q=e[18];let W;e[19]!==r||e[20]!==m?.path||e[21]!==p?(W=r==="createFile"&&p("filesView.dialog.createFile.description",{path:m?.path??p("filesView.dialog.rootFallback")}),e[19]=r,e[20]=m?.path,e[21]=p,e[22]=W):W=e[22];let _;e[23]!==r||e[24]!==m?.path||e[25]!==p?(_=r==="createFolder"&&p("filesView.dialog.createFolder.description",{path:m?.path??p("filesView.dialog.rootFallback")}),e[23]=r,e[24]=m?.path,e[25]=p,e[26]=_):_=e[26];let L;e[27]!==r||e[28]!==m?.name||e[29]!==p?(L=r==="rename"&&p("filesView.dialog.rename.description",{name:m?.name??""}),e[27]=r,e[28]=m?.name,e[29]=p,e[30]=L):L=e[30];let T;e[31]!==r||e[32]!==m?.name||e[33]!==p?(T=r==="delete"&&p("filesView.dialog.delete.description",{name:m?.name??""}),e[31]=r,e[32]=m?.name,e[33]=p,e[34]=T):T=e[34];let V;e[35]!==L||e[36]!==T||e[37]!==W||e[38]!==_?(V=s.jsxs(Wi,{children:[W,_,L,T]}),e[35]=L,e[36]=T,e[37]=W,e[38]=_,e[39]=V):V=e[39];let le;e[40]!==V||e[41]!==q?(le=s.jsxs(Bi,{children:[q,V]}),e[40]=V,e[41]=q,e[42]=le):le=e[42];let Y;e[43]!==r||e[44]!==x||e[45]!==j||e[46]!==v||e[47]!==b||e[48]!==p?(Y=r!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(Ts,{value:x,onChange:de=>v(de.target.value),placeholder:p(r==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:de=>{de.key==="Enter"&&b()},ref:j})}),e[43]=r,e[44]=x,e[45]=j,e[46]=v,e[47]=b,e[48]=p,e[49]=Y):Y=e[49];let Z;e[50]!==p?(Z=p("filesView.dialog.cancel"),e[50]=p,e[51]=Z):Z=e[51];let A;e[52]!==y||e[53]!==h||e[54]!==Z?(A=s.jsx(S,{variant:"outline",onClick:h,disabled:y,children:Z}),e[52]=y,e[53]=h,e[54]=Z,e[55]=A):A=e[55];const ce=r==="delete"?"destructive":"default";let Le;e[56]!==b?(Le=()=>{b()},e[56]=b,e[57]=Le):Le=e[57];let U;e[58]!==r||e[59]!==x||e[60]!==y?(U=y||r!=="delete"&&!x.trim(),e[58]=r,e[59]=x,e[60]=y,e[61]=U):U=e[61];let X;e[62]!==r||e[63]!==y||e[64]!==p?(X=y?s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}):p(r==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=r,e[63]=y,e[64]=p,e[65]=X):X=e[65];let ee;e[66]!==ce||e[67]!==Le||e[68]!==U||e[69]!==X?(ee=s.jsx(S,{variant:ce,onClick:Le,disabled:U,children:X}),e[66]=ce,e[67]=Le,e[68]=U,e[69]=X,e[70]=ee):ee=e[70];let pe;e[71]!==A||e[72]!==ee?(pe=s.jsxs(Ui,{children:[A,ee]}),e[71]=A,e[72]=ee,e[73]=pe):pe=e[73];let te;e[74]!==j||e[75]!==le||e[76]!==Y||e[77]!==pe?(te=s.jsxs(Oi,{initialFocus:j,children:[le,Y,pe]}),e[74]=j,e[75]=le,e[76]=Y,e[77]=pe,e[78]=te):te=e[78];let ge;return e[79]!==F||e[80]!==z||e[81]!==te?(ge=s.jsx(Ii,{open:F,onOpenChange:z,children:te}),e[79]=F,e[80]=z,e[81]=te,e[82]=ge):ge=e[82],ge},Ai=(d,e,r)=>{const m=Gt.c(8),[x,v]=n.useState(""),[y,b]=n.useState(0);let h,j;m[0]!==d||m[1]!==r||m[2]!==e?(h=()=>{if(!d){v("");return}let F=!1;v("");const z=Qn(),E=Yn(z);Zn(z).then(R=>{F||!R||(v(d),e(null))}).catch(R=>{F||(e(R instanceof Error?R.message:r),v(d))});const N=ea(()=>{F||(v(d),b(eo),e(null))});return()=>{F=!0,E(),N()}},j=[d,e,r],m[0]=d,m[1]=r,m[2]=e,m[3]=h,m[4]=j):(h=m[3],j=m[4]),n.useEffect(h,j);let p;return m[5]!==y||m[6]!==x?(p={readyKey:x,nonce:y},m[5]=y,m[6]=x,m[7]=p):p=m[7],p},wc=({mode:d="full"})=>{const{t:e}=Ds(),{files:r,runtime:m}=sa(),{currentTheme:x,availableThemes:v,lightThemeId:y,darkThemeId:b}=ra(),{isMobile:h,isTablet:j,screenWidth:p}=ia(),F=Kn(m.platform),z=h||j,E=Hn(),N=qn(),R=na()??"",o=M(R.trim()),q=d!=="editor-only",W=d==="editor-only"&&!h,_=_n(t=>t.searchFiles),L=aa(R),[T,V]=n.useState(""),le=oa(T,200),Y=n.useRef(null),[Z,A]=n.useState(!1),[ce,Le]=n.useState(!0),[U,X]=n.useState(!1),[ee,pe]=n.useState(!1),[te,ge]=n.useState(!1),de=n.useRef(null),rt=n.useRef(0),Tt=n.useCallback(t=>{rt.current=Math.max(0,rt.current+(t?1:-1))},[]),Xe=n.useCallback(t=>t instanceof Element?t.closest('[data-slot="dropdown-menu-content"], [data-slot="dropdown-menu-item"]')!==null:!1,[]);n.useEffect(()=>{if(!te)return;const t=i=>{rt.current>0||Xe(i.target)||de.current&&!de.current.contains(i.target)&&ge(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[Xe,te]);const[G,Fe]=n.useState("edit"),[xt,Ae]=n.useState("edit"),[Ie,vt]=n.useState("tree"),[xe,Oe]=n.useState("edit"),[ue,Ne]=n.useState("preview"),[it,nt]=n.useState(0),Be=n.useRef({}),$e=n.useRef({}),We=n.useRef({}),at=n.useRef({}),fe=n.useMemo(()=>v.find(t=>t.metadata.id===y)??vi(!1),[v,y]),ve=n.useMemo(()=>v.find(t=>t.metadata.id===b)??vi(!0),[v,b]);n.useEffect(()=>{Di(fe),Di(ve)},[fe,ve]);const wt=n.useMemo(()=>[],[]),C=ze(t=>o?t.byRoot[o]?.openPaths??wt:wt),we=ze(t=>o?t.byRoot[o]?.selectedPath??null:null),Je=ze(t=>o?t.byRoot[o]?.expandedPaths??wt:wt),Vt=ze(t=>t.removeOpenPath),ot=ze(t=>t.removeOpenPathsByPrefix),fr=ze(t=>t.removeExpandedPathsByPrefix),se=ze(t=>t.setSelectedPath),mr=ze(t=>t.toggleExpandedPath),ns=ze(t=>t.expandPaths),Dt=n.useCallback(t=>{const i=M(t),a=i.split("/"),c=a[a.length-1]||i,u=c.includes(".")?c.split(".").pop()?.toLowerCase():void 0;return{name:c,path:i,type:"file",extension:u}},[]),Et=n.useMemo(()=>C.map(Dt),[C,Dt]),Es=n.useMemo(()=>{if(we){const t=Ut(we);if(C.some(i=>Ut(i)===t))return we}return C[0]??null},[C,we]),l=n.useMemo(()=>Es?Dt(Es):null,[Es,Dt]),Ue=l?.path??"";n.useEffect(()=>{if(!o||!we)return;const t=Ut(we);C.some(a=>Ut(a)===t)||se(o,C[0]??null)},[C,o,we,se]);const as=!!(o&&Ue&&!is(Ue,o)),hr=as?ji(Ue):void 0,Ce=n.useMemo(()=>({allowOutsideWorkspace:d==="editor-only"&&as,outsideFileGrant:hr,directory:o||void 0}),[d,as,hr,o]),Rs=n.useRef(null),[pr,Hi]=n.useState({left:!1,right:!1}),gr=n.useCallback(()=>{const t=Rs.current;t&&Hi({left:t.scrollLeft>2,right:t.scrollLeft+t.clientWidth<t.scrollWidth-2})},[]),xr=n.useRef(gr);xr.current=gr,n.useEffect(()=>{const t=Rs.current;if(!t)return;const i=()=>xr.current();i(),t.addEventListener("scroll",i,{passive:!0});const a=new ResizeObserver(i);return a.observe(t),()=>{t.removeEventListener("scroll",i),a.disconnect()}},[Et.length]);const[vr,Ps]=n.useState({}),[os,Kt]=n.useState({}),Se=n.useRef(new Set),ke=n.useRef(new Set),Qe=n.useRef(new Map),wr=n.useRef(0),[br,ls]=n.useState([]),[qi,cs]=n.useState(!1),[k,H]=n.useState(""),{isPlaying:ds,play:_i,stop:Xi}=la(),[Re,Ye]=n.useState(!1),[Ze,J]=n.useState(null),[Ji,Te]=n.useState(""),[be,K]=n.useState(null),[B,Q]=n.useState(""),[Rt,Ms]=n.useState(!1),[yr,Qi]=n.useState(`
8
- `),Yi=n.useRef(null),Ge=n.useRef(null),ye=n.useRef(null),lt=n.useRef(""),Ht=n.useRef(""),et=n.useRef(null),jr=n.useRef(null),Ke=n.useRef(null),qt=n.useRef(0),Pt=n.useRef(null),[us,Zi]=n.useState(0),[en,Mt]=n.useState("idle"),[tn,fs]=n.useState(!1),[_t,Fr]=n.useState(!1),re=he(t=>t.autoSaveEnabled),sn=he(t=>t.setAutoSaveEnabled),[zs,zt]=n.useState(!1),Lt=n.useRef(null),Xt=n.useRef(null),Jt=n.useRef(null),bt=n.useRef(!1),Qt=n.useRef(null),Yt=n.useRef(null),Pe=n.useRef(null),rn=n.useRef(null),[nn,Ls]=n.useState(0),At=n.useRef(null),yt=n.useRef({key:"",attempts:0});n.useEffect(()=>()=>{At.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(At.current),At.current=null)},[]);const[jt,As]=n.useState(null),[Ft,an]=n.useState(null),[ct,Nr]=n.useState(""),[on,Is]=n.useState(!1),[ln,cn]=n.useState(null),[dn,un]=n.useState(null),[fn,Cr]=n.useState(!1),[mn,Sr]=n.useState(!1),[hn,Os]=n.useState(!1),kr=!!r.writeFile,Tr=!!r.createDirectory,Vr=!!r.rename,Dr=!!r.delete,Er=!!r.revealPath,pn=Ns(t=>t.availableApps),gn=Ns(t=>t.isCacheStale),Rr=Ns(t=>t.initialize),xn=Ns(t=>t.loadInstalledApps);n.useEffect(()=>{Rr()},[Rr]);const vn=n.useCallback(t=>{r.revealPath&&r.revealPath(t).catch(()=>{I.error(e("sidebarFilesTree.toast.revealFailed"))})},[r,e]),wn=n.useCallback(async t=>{if(!l?.path||await Xn(l.path,t.id,t.appName)||await wi(l.path,t.appName))return;const c=Ba(l.path)||o;c&&await wi(c,t.appName)||I.error(e("filesView.toast.openInAppFailed",{app:t.appName}))},[o,l?.path,e]),Bs=n.useCallback((t,i)=>{As(t),an(i),Nr(t==="rename"&&i.name||""),Is(!1)},[]),[P,Me]=n.useState(null),It=n.useRef(!1),dt=n.useRef(null),[Pr,Ot]=n.useState(!1),He=he(t=>t.setMainTabGuard),qe=he(t=>t.pendingFileNavigation),ms=he(t=>t.setPendingFileNavigation),$s=he(t=>t.pendingFileFocusPath),Ws=he(t=>t.setPendingFileFocusPath),Mr=he(t=>t.shortcutOverrides),zr=he(t=>t.fileEditorKeymap),Zt=Fi(t=>t.settingsDefaultFileViewerPreview),bn=Fi(t=>t.showMessageTTSButtons),Lr=he(t=>t.expandedEditorToolbar);n.useEffect(()=>{const t=()=>{It.current=!1,dt.current=null,Ot(!1)};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]),n.useEffect(()=>()=>{Qt.current!==null&&window.clearTimeout(Qt.current),Yt.current!==null&&window.clearTimeout(Yt.current)},[]);const yn=n.useCallback((t,i)=>{const a=t.split(`
9
- `),c=Math.max(1,i.start),u=Math.min(a.length,i.end);return c>u?"":a.slice(c-1,u).join(`
10
- `)},[]),jn=Pa({source:"file",fileLabel:l?.path??null,language:l?.path&&sr(l.path)||"text",getCodeForRange:t=>yn(k,Ma(t)),toStoreRange:t=>({startLine:t.start,endLine:t.end}),fromDraftRange:t=>({start:t.startLine,end:t.endLine})}),{drafts:Ar,commentText:hs,setCommentText:Ir,editingDraftId:ps,setSelection:Or,saveComment:Br,cancel:es,reset:$r,startEdit:Wr,deleteDraft:Ur}=jn;n.useEffect(()=>{Me(null),$r(),He(null),Q(""),Ms(!1)},[l?.path,$r,He]),n.useEffect(()=>{Or(P)},[P,Or]),n.useEffect(()=>{if(!P&&!ps)return;const t=a=>{const c=a.target;c.closest('[data-comment-input="true"]')||c.closest('[data-comment-card="true"]')||c.closest(".cm-gutterElement")||c.closest("[data-sonner-toast]")||c.closest("[data-sonner-toaster]")||hs.trim()||(Me(null),es())},i=setTimeout(()=>{document.addEventListener("click",t)},100);return()=>{clearTimeout(i),document.removeEventListener("click",t)}},[es,hs,ps,P]);const Gr=n.useCallback((t,i)=>{const a=i??P??void 0;i&&Me(i),Br(t,a),Me(null)},[P,Br]),Kr=n.useCallback((t,i)=>{const a=[];for(const c of i){if(!(c&&typeof c.name=="string"&&c.name.length>0)||!E&&c.name.startsWith(".")||!N&&Ha(c.name))continue;const u=c.name,f=M(c.path||""),w=f?Ua(f)?f:M(`${t}/${f}`):M(`${t}/${u}`),D=c.isDirectory?"directory":"file",$=D==="file"&&u.includes(".")?u.split(".").pop()?.toLowerCase():void 0;a.push({name:u,path:w,type:D,extension:$})}return Wa(a)},[N,E]),Ve=n.useCallback(async t=>{const i=M(t.trim());if(!i||Se.current.has(i)||ke.current.has(i))return;ke.current=new Set(ke.current),ke.current.add(i);const a=wr.current+1;wr.current=a,Qe.current=new Map(Qe.current),Qe.current.set(i,a);const c=()=>Qe.current.get(i)===a;await(r.listDirectory?r.listDirectory(i).then(f=>f.entries.map(w=>({name:w.name,path:w.path,isDirectory:w.isDirectory}))):Jn.listLocalDirectory(i).then(f=>f.map(w=>({name:w.name,path:w.path,isDirectory:w.isDirectory})))).then(f=>{if(!c())return;const w=Kr(i,f);Se.current=new Set(Se.current),Se.current.add(i),Kt(D=>{if(!D[i])return D;const $={...D};return delete $[i],$}),Ps(D=>({...D,[i]:w}))}).catch(f=>{if(!c())return;const w=f instanceof Error?f.message:String(f??"");if(w==="Directory not found"&&o&&i!==o){fr(o,i),Kt(D=>{if(!D[i])return D;const $={...D};return delete $[i],$});return}console.error("Failed to load files directory:",f),Kt(D=>({...D,[i]:w}))}).finally(()=>{c()&&(Qe.current=new Map(Qe.current),Qe.current.delete(i),ke.current=new Set(ke.current),ke.current.delete(i))})},[r,Kr,fr,o]),gs=n.useCallback(async()=>{o&&(Se.current=new Set,ke.current=new Set,Qe.current=new Map,Kt({}),Ps(t=>Object.keys(t).length===0?t:{}),await Ve(o))},[Ve,o]),_e=n.useCallback(async t=>{if(!t){await gs();return}const i=M(t);Se.current=new Set(Se.current),Se.current.delete(i),ke.current=new Set(ke.current),ke.current.delete(i),await Ve(i)},[Ve,gs]),Hr=n.useRef(""),qr=n.useRef("");n.useEffect(()=>{if(!o)return;const t=`${o}|h${E?"1":"0"}|g${N?"1":"0"}`,i=Hr.current!==o,a=qr.current!==t;!i&&!a||(i&&(Hr.current=o,H(""),J(null),Te(""),K(null),A(!1)),a&&(qr.current=t,Se.current=new Set,ke.current=new Set,Qe.current=new Map,Kt({}),Ps(c=>Object.keys(c).length===0?c:{}),Ve(o)))},[Ve,o,N,E]),n.useEffect(()=>{if(!r.listDirectory)return;const t=()=>{if(!document.hidden&&Je.length>0)for(const i of Je)_e(i)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[Je,r.listDirectory,_e]),n.useEffect(()=>{if(!r.listDirectory||Je.length===0)return;const t=setInterval(()=>{if(!document.hidden)for(const i of Je)_e(i)},8e3);return()=>clearInterval(t)},[Je,r.listDirectory,_e]);const Fn=n.useCallback(async t=>{if(t?.preventDefault(),!Ft||!jt)return;Is(!0);const i=()=>{As(null)},a=u=>{I.error(u)},c=()=>{Is(!1)};if(jt==="createFile"){if(!ct.trim()){a(e("sidebarFilesTree.toast.filenameRequired")),c();return}if(!r.writeFile){a(e("sidebarFilesTree.toast.writeNotSupported")),c();return}const u=Ft.path,f=u?`${u}/`:"",w=M(`${f}${ct.trim()}`);await r.writeFile(w,"").then(async D=>{D.success&&(I.success(e("sidebarFilesTree.toast.fileCreated")),await _e(u)),i()}).catch(()=>a(e("sidebarFilesTree.toast.operationFailed"))).finally(c);return}if(jt==="createFolder"){if(!ct.trim()){a(e("sidebarFilesTree.toast.folderNameRequired")),c();return}const u=Ft.path,f=u?`${u}/`:"",w=M(`${f}${ct.trim()}`);await r.createDirectory(w).then(async D=>{D.success&&(I.success(e("sidebarFilesTree.toast.folderCreated")),await _e(u)),i()}).catch(()=>a(e("sidebarFilesTree.toast.operationFailed"))).finally(c);return}if(jt==="rename"){if(!ct.trim()){a(e("sidebarFilesTree.toast.nameRequired")),c();return}if(!r.rename){a(e("sidebarFilesTree.toast.renameNotSupported")),c();return}const u=Ft.path,f=u.split("/").slice(0,-1).join("/"),w=f?`${f}/`:"",D=M(`${w}${ct.trim()}`);await r.rename(u,D).then(async $=>{$.success&&(I.success(e("sidebarFilesTree.toast.renamedSuccessfully")),await _e(f),o&&ot(o,u),(l?.path===u||l?.path.startsWith(`${u}/`))&&(o&&se(o,null),H(""),J(null),Te(""),K(null),h&&A(!1))),i()}).catch(()=>a(e("sidebarFilesTree.toast.operationFailed"))).finally(c);return}if(jt==="delete"){if(!r.delete){a(e("sidebarFilesTree.toast.deleteNotSupported")),c();return}const u=Ft.path,f=u.split("/").slice(0,-1).join("/");await r.delete(u).then(async w=>{w.success&&(I.success(e("sidebarFilesTree.toast.deletedSuccessfully")),await _e(f),o&&ot(o,u),(l?.path===u||l?.path.startsWith(`${u}/`))&&(o&&se(o,null),H(""),J(null),Te(""),K(null),h&&A(!1))),i()}).catch(()=>a(e("sidebarFilesTree.toast.operationFailed"))).finally(c);return}c()},[jt,Ft,ct,r,_e,h,ot,o,l?.path,se,e]);n.useEffect(()=>{if(!R){ls([]),cs(!1);return}const t=le.trim();if(!t){ls([]),cs(!1);return}let i=!1;return cs(!0),_(R,t,150,{includeHidden:E,respectGitignore:!N,type:"file"}).then(a=>{if(i)return;const u=a.filter(f=>N||!qa(f.path)).map(f=>({name:f.name,path:M(f.path),type:"file",extension:f.extension,relativePath:f.relativePath}));ls(u)}).catch(()=>{i||ls([])}).finally(()=>{i||cs(!1)}),()=>{i=!0}},[R,le,_,E,N]);const _r=n.useCallback(async(t,i)=>{if(r.readFile)return(await r.readFile(t,{...i??{},directory:o||void 0})).content??"";const a=new URLSearchParams({path:t});i?.allowOutsideWorkspace&&a.set("allowOutsideWorkspace","true"),i?.outsideFileGrant&&a.set("outsideFileGrant",i.outsideFileGrant),i?.optional&&a.set("optional","true"),o&&a.set("directory",o);const c=await bi(`/api/fs/read?${a.toString()}`,{cache:i?.optional?"no-store":"default"});if(!c.ok){const u=await c.json().catch(()=>({error:c.statusText}));throw new Error(u.error||e("filesView.error.readFileFailed"))}return c.text()},[r,o,e]),ut=n.useCallback(async(t,i)=>{if(r.statFile){const a=await r.statFile(t,{...i??{},directory:o||void 0});return{path:a.path,size:a.size,mtimeMs:a.mtimeMs}}return null},[r,o]);n.useEffect(()=>{if(!o||!r.statFile||C.length===0)return;let t=!1;const i=[...C];return Promise.all(i.map(async a=>{try{const c=await r.statFile?.(a,{directory:o||void 0});!t&&c&&!c.isFile&&ot(o,a)}catch(c){!t&&zi(c)&&ot(o,a)}})),()=>{t=!0}},[r,C,ot,o]);const Us=n.useMemo(()=>k.length>rs?`${k.slice(0,rs)}
11
-
12
- … truncated …`:k,[k]),ie=B!==Us,Nt=n.useCallback(async()=>{if(!l||!r.writeFile)return I.error(e("filesView.toast.savingNotSupported")),!1;const t=Fs(l.path)||_t;if(!Oa({selectedFilePath:l.path,loadedFilePath:be,fileLoading:Re,isDirty:ie,draftContent:B,fileContent:k,isNonEditableBinary:t}))return t?console.warn(`[saveDraft] refusing to save binary file "${l.path}".`):B===""&&k!==""&&be!==l.path&&console.warn(`[saveDraft] refusing to save empty draft for "${l.path}" (${k.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(!ie)return!0;Ms(!0);try{const i=Ja(B,yr);if(!(await r.writeFile(l.path,i))?.success)return I.error(e("filesView.toast.writeFileFailed")),!1;if(H(B),o&&is(l.path,o)){const c=ks(o,l.path);c&&ca.requestGitRefresh({directory:o,paths:[c]})}if(o&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(M(l.path))){const c=da.getState().projects.find(u=>M(u.path)===M(o));if(c)try{await Da(c.id)}catch{I.error(e("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return l?.path&&rr(l.path)&&(lt.current=B,Ht.current=B),ut(l.path).then(c=>{c&&(Ke.current=c)}).catch(()=>{}),!0}catch(i){return I.error(i instanceof Error?i.message:e("filesView.toast.saveFailed")),!1}finally{Ms(!1)}},[_t,B,k,Re,r,ie,yr,be,ut,o,l,e]);n.useEffect(()=>{if(!ie){He(null);return}const t=i=>bt.current?(bt.current=!1,!0):(zt(!0),Xt.current=i,!1);return He(t),()=>{he.getState().mainTabGuard===t&&He(null)}},[ie,He]),n.useEffect(()=>{re||(Mt("idle"),Ge.current&&(clearTimeout(Ge.current),Ge.current=null))},[re]);const Xr=1500;n.useEffect(()=>{const t=!!(l&&r.writeFile),i=!!(l?.path&&(Fs(l.path)||_t));if(Ia({autoSaveEnabled:re,isDirty:ie,canWrite:t,isSaving:Rt,fileLoading:Re,selectedFilePath:l?.path,loadedFilePath:be,isNonEditableBinary:i}))return Ge.current=setTimeout(()=>{Nt().then(a=>{a&&(Mt("saved"),setTimeout(()=>Mt("idle"),2e3))})},Xr),()=>{Ge.current&&(clearTimeout(Ge.current),Ge.current=null)}},[re,_t,B,Re,ie,be,l,r.writeFile,Rt,Nt]),n.useEffect(()=>{Mt("idle")},[l?.path]),n.useEffect(()=>{const t=i=>{ga(i)&&(i.key.toLowerCase()==="s"?(i.preventDefault(),Ge.current&&(clearTimeout(Ge.current),Ge.current=null),Rt||Nt().then(a=>{a&&(Mt("saved"),setTimeout(()=>Mt("idle"),2e3))})):i.key.toLowerCase()==="f"&&(i.preventDefault(),pe(!0)))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[Rt,Nt]);const Jr=n.useCallback(async t=>{const i=qt.current+1;qt.current=i;const a=()=>{if(!o)return!1;const je=ze.getState().byRoot[o],oe=je?.selectedPath??je?.openPaths[0]??null;return qt.current===i&&oe===t.path};J(null),Te(""),K(null),Fr(!1);const c=Ni(t.path),u=Ci(t.path),f=Si(t.path),w=Fs(t.path);if(h&&A(!0),m.isDesktop&&c&&!u){H(""),Q(""),Ye(!0);return}if(!m.isDesktop&&c&&!u){H(""),Q(""),K(t.path),Ye(!1);return}if(f){H(""),Q(""),K(t.path),Ye(!1);return}if(w){H(""),Q(""),K(t.path),Ye(!1);return}Ye(!0);const D=ji(t.path),$={allowOutsideWorkspace:d==="editor-only"&&!!o&&!is(t.path,o),outsideFileGrant:D};await _r(t.path,$).then(je=>{if(!a())return;if(ua(je)){Fr(!0),H(""),Q(""),K(t.path);return}const oe=Gi(je);Qi(Xa(je)),H(oe),lt.current=oe,Ht.current=oe,Q(oe.length>rs?`${oe.slice(0,rs)}
13
-
14
- … truncated …`:oe),K(t.path),ut(t.path,$).then(Ct=>{Ct&&a()&&(Ke.current=Ct)}).catch(()=>{})}).catch(je=>{if(a()){if(_a(je)){if(Ye(!1),o&&se(o,null),J(null),H(""),Q(""),K(null),Ke.current=null,T.trim().length>0&&V(""),h&&A(!1),o){const Ct=[...Pi(t.path,o),t.path];Ct.length>0&&ns(o,Ct);for(const er of Ct)Se.current.has(er)||Ve(er)}return}if(zi(je)){o&&ot(o,t.path),H(""),Q(""),J(null),Ke.current=null,h&&A(!1);return}H(""),Q(""),J(je instanceof Error?je.message:e("filesView.error.readFileFailed")),Ke.current=null}}).finally(()=>{a()&&Ye(!1)})},[ns,h,Ve,d,_r,ut,ot,o,m.isDesktop,T,se,e]),xs=n.useCallback(async(t,i)=>{if(!o)return;const a=Pi(t,o),c=i?[...a,t]:a;c.length>0&&ns(o,c);const u=c.map(f=>{if(!Se.current.has(f))return Ve(f)}).filter(Boolean);await Promise.all(u)},[ns,Ve,o]),Qr=n.useCallback((t,i)=>{const a=i.findIndex(c=>c.path===t);return a===-1||i.length<=1?null:i[a+1]??i[a-1]??null},[]),me=n.useCallback(async t=>{if(bt.current)bt.current=!1;else if(ie){zt(!0),Lt.current=t;return}o&&(se(o,t.path),xs(t.path,!1)),J(null),Te(""),H(""),lt.current="",Ht.current="",Q(""),K(null),h&&A(!0)},[xs,ie,h,o,se]);n.useEffect(()=>{l?.path&&xs(l.path,!1)},[xs,l?.path]),n.useEffect(()=>{if(!l){qt.current+=1,Pt.current=null,Ye(!1);return}if(be===l.path||Pt.current===l.path)return;const t=l.path;Pt.current=t,Jr(l).finally(()=>{Pt.current===t&&(Pt.current=null)})},[us,Jr,be,l]);const Gs=n.useRef(ie);Gs.current=ie,n.useEffect(()=>Ea(({runtimeKey:t,paths:i})=>{const a=l?.path;t!==ta()||!a||Gs.current||!i.includes(M(a))||(qt.current+=1,Pt.current=null,Ke.current=null,Te(""),J(null),K(null),Zi(c=>c+1))}),[l?.path]),n.useEffect(()=>{if(!l?.path||be!==l.path)return;let t=!1;const i=window.setInterval(()=>{document.hidden||ut(l.path,Ce).then(a=>{if(t||!a)return;const c=Ke.current;if(!c||c.path!==l.path){Ke.current=a;return}const u=a.mtimeMs!==void 0&&c.mtimeMs!==void 0&&a.mtimeMs!==c.mtimeMs,f=a.size!==c.size;!u&&!f||Gs.current||(Ke.current=a,K(null))}).catch(()=>{})},2e3);return()=>{t=!0,window.clearInterval(i)}},[be,ut,l?.path,Ce]);const Nn=n.useCallback(()=>{const t=Lt.current,i=Xt.current,a=Jt.current;if(Lt.current=null,Xt.current=null,Jt.current=null,bt.current=!0,zt(!1),Q(Us),a){o&&Vt(o,a),l?.path===a&&(t?me(t):(o&&se(o,null),H(""),J(null),Te(""),K(null),h&&A(!1)));return}if(t){me(t);return}i&&(He(null),he.getState().setActiveMainTab(i))},[Us,me,h,Vt,o,l?.path,He,se]),Cn=n.useCallback(async()=>{const t=Lt.current,i=Xt.current,a=Jt.current;if(!await Nt()){bt.current=!1;return}if(Lt.current=null,Xt.current=null,Jt.current=null,bt.current=!0,zt(!1),a){o&&Vt(o,a),l?.path===a&&(t?await me(t):(o&&se(o,null),H(""),J(null),Te(""),K(null),h&&A(!1)));return}if(t){await me(t);return}i&&(He(null),he.getState().setActiveMainTab(i))},[me,h,Vt,o,Nt,l?.path,He,se]),Yr=n.useCallback(t=>{const i=l?.path===t,a=Qr(t,Et);if(i&&ie){zt(!0),Lt.current=a,Jt.current=t;return}if(o&&Vt(o,t),!!i){if(a){me(a);return}o&&se(o,null),H(""),J(null),Te(""),K(null),h&&A(!1)}},[Qr,me,ie,h,Et,Vt,o,l?.path,se]),Sn=n.useCallback(t=>{if(C.includes(t))return"open";if(L?.files){const i=t.startsWith(o+"/")?t.slice(o.length+1):t,a=L.files.find(c=>c.path===i);if(a){if(a.index==="A"||a.working_dir==="?")return"git-added";if(a.index==="D")return"git-deleted";if(a.index==="M"||a.working_dir==="M")return"git-modified"}}return null},[C,L,o]),kn=n.useCallback(t=>{if(!L?.files)return null;const i=t.startsWith(o+"/")?t.slice(o.length+1):t,a=i?`${i}/`:"";let c=0,u=0;for(const f of L.files)f.path.startsWith(a)&&((f.index==="M"||f.working_dir==="M")&&c++,(f.index==="A"||f.working_dir==="?")&&u++);return c+u>0?{modified:c,added:u}:null},[L,o]),Tn=n.useCallback(async t=>{const i=M(t);o&&(mr(o,i),Se.current.has(i)||await Ve(i))},[Ve,o,mr]),Vn=n.useMemo(()=>({canRename:Vr,canCreateFile:kr,canCreateFolder:Tr,canDelete:Dr,canReveal:Er}),[Vr,kr,Tr,Dr,Er]);function Zr(t,i){const a=vr[t]??[];return a.map((c,u)=>{const f=c.type==="directory",w=f&&Je.includes(c.path),D=l?.path===c.path,$=u===a.length-1;return s.jsxs("li",{className:"relative",children:[i>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),$&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),s.jsx(Ya,{node:c,root:o,isExpanded:w,isActive:D,isMobile:h,isBrowserClient:F,alwaysShowActions:z,status:f?void 0:Sn(c.path),badge:f?kn(c.path):void 0,permissions:Vn,downloadFile:r.downloadFile,contextMenuPath:ln,setContextMenuPath:cn,rightClickMenuPath:dn,setRightClickMenuPath:un,onSelect:me,onToggle:Tn,onRevealPath:vn,onOpenDialog:Bs}),f&&w&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[os[c.path]?s.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:os[c.path],children:os[c.path]}),s.jsxs(S,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{_e(c.path)},children:[s.jsx(g,{name:"refresh",className:"size-3.5"}),e("filesView.tree.actions.refreshTitle")]})]}):null,Zr(c.path,i+1)]})]},c.path)})}const ne=!!(l?.path&&Ni(l.path)),vs=!!(l?.path&&Ci(l.path)),De=!!(l?.path&&Si(l.path)),Ks=!!(l?.path&&(Fs(l.path)||_t)),tt=Ks&&!ne&&!De,ei=n.useMemo(()=>M(qe?.path??""),[qe?.path]),Bt=!!(qe&&ei&&Ue&&Ue===ei&&!Re&&!Ze&&!ne&&!De&&!tt),ft=n.useMemo(()=>ks(o,Ue),[Ue,o]),Dn=!!(l&&(!ne||vs)&&!De&&!tt&&k.length>0),En=!!(l&&ft.length>0),Ee=!!(l&&!as&&!Ks&&!ne&&r.writeFile&&k.length<=rs),mt=!!(l?.path&&Li(l.path)),ts=!!(l?.path&&Qa(l.path)),$t=!!(l?.path&&lr(l.path)),ss=!!(l?.path&&rr(l.path)),Hs=!!(l&&!Ks&&!ne)&&!mt&&!ss&&!($t&&xe==="preview"),Rn=mt&&xt==="edit"||$t&&xe==="edit"||ts&&Ie==="text"||!mt&&!$t&&!ts&&G==="edit",ws=n.useMemo(()=>Ue?fa(Ue):null,[Ue]),[ti,qs]=n.useState(null);n.useEffect(()=>{let t=!1;const i=l?.path;if(!i||ws){qs(null);return}return qs(null),ma(i).then(a=>{t||qs(a)}),()=>{t=!0}},[l?.path,ws]),n.useEffect(()=>{!Ee&&G==="edit"&&Fe("view")},[Ee,G]);const _s="openchamber:files:md-viewer-mode",Xs="openchamber:files:html-viewer-mode",Js="openchamber:files:json-viewer-mode";n.useEffect(()=>{const t=l?.path;if(!t)return;Fe(Be.current[t]??"edit");let i=Zt?"preview":"edit";try{const u=localStorage.getItem(_s);(u==="preview"||u==="edit")&&(i=u)}catch{}Ae($e.current[t]??i);let a=Zt?"preview":"edit";try{const u=localStorage.getItem(Xs);(u==="preview"||u==="edit")&&(a=u)}catch{}Oe(We.current[t]??a),Ne(at.current[t]??(Zt?"preview":"edit"));let c=Zt?"tree":"text";try{const u=localStorage.getItem(Js);(u==="tree"||u==="text")&&(c=u)}catch{}vt(c)},[l?.path,Zt]);const Pn=n.useCallback(t=>{const i=l?.path;i&&(Be.current[i]=t),Fe(t)},[l?.path]),si=n.useCallback(t=>{const i=l?.path;i&&($e.current[i]=t),Ae(t);try{localStorage.setItem(_s,t)}catch{}},[l?.path]),ae=n.useCallback(()=>xt,[xt]),Mn=n.useCallback(t=>{vt(t);try{localStorage.setItem(Js,t)}catch{}},[]),zn=n.useCallback(t=>{const i=l?.path;i&&(We.current[i]=t),Oe(t);try{localStorage.setItem(Xs,t)}catch{}},[l?.path]),Ln=n.useCallback(t=>{const i=l?.path;if(i&&(at.current[i]=t),ye.current&&(clearTimeout(ye.current),ye.current=null),et.current!==null&&(cancelAnimationFrame(et.current),et.current=null),t==="edit")Q(lt.current||k),Ne(t);else{lt.current=B;const a=i;Ne("edit"),et.current=requestAnimationFrame(()=>{et.current=requestAnimationFrame(()=>{et.current=null,!(o&&a&&ze.getState().byRoot[o]?.selectedPath!==a)&&(nt(c=>c+1),Ne("preview"))})});return}},[B,k,o,l?.path]),Qs=n.useCallback(async(t,i)=>{if(!r.writeFile||i===Ht.current)return!1;if(!(await r.writeFile(t,i))?.success)return I.error(e("filesView.toast.writeFileFailed")),!1;lt.current=i,Ht.current=i,Q(i);const c=await ut(t,Ce).catch(()=>null);return c&&(Ke.current=c),!0},[r,ut,Ce,e]);n.useEffect(()=>()=>{ye.current&&(clearTimeout(ye.current),ye.current=null),et.current!==null&&(cancelAnimationFrame(et.current),et.current=null)},[ue,l?.path]);const An=n.useCallback(t=>{if(lt.current=t,!re||!l?.path||ue!=="preview"||!r.writeFile)return;ye.current&&clearTimeout(ye.current);const i=l.path;ye.current=setTimeout(()=>{ye.current=null,Qs(i,t).then(a=>{a&&(fs(!0),setTimeout(()=>fs(!1),1500))}).catch(a=>{I.error(a instanceof Error?a.message:e("filesView.toast.saveFailed"))})},Xr)},[re,ue,r.writeFile,Qs,l?.path,e]),In=n.useMemo(()=>ss&&(lt.current||B)||k,[B,k,ss]),ri=n.useCallback(()=>xe,[xe]);n.useEffect(()=>{const t=a=>{const c=a?"preview":"edit",u=a?"tree":"text";for(const f of C)Be.current[f]="edit",Li(f)&&($e.current[f]=c),lr(f)&&(We.current[f]=c),rr(f)&&(at.current[f]=c);Fe("edit"),Ae(c),Oe(c),Ne(c),vt(u);try{localStorage.setItem(_s,c),localStorage.setItem(Xs,c),localStorage.setItem(Js,u)}catch{}},i=a=>{const c=!!a.detail?.enabled;t(c)};return window.addEventListener("openchamber:file-viewer-preview-mode-changed",i),()=>{window.removeEventListener("openchamber:file-viewer-preview-mode-changed",i)}},[C]),n.useEffect(()=>{if(!qe||!o)return;const t=()=>{typeof window>"u"||At.current===null&&(At.current=window.requestAnimationFrame(()=>{At.current=null,Ls(st=>st+1)}))},i=(st,St)=>{if(st.state.doc.length!==St.length)return!1;if(St.length===0)return!0;const tr=Math.min(128,St.length);if(st.state.sliceDoc(0,tr)!==St.slice(0,tr))return!1;const xi=Math.max(0,St.length-tr);return st.state.sliceDoc(xi,St.length)===St.slice(xi)},a=M(qe.path);if(!a){ms(null),yt.current={key:"",attempts:0};return}const c=`${a}:${qe.line}:${qe.column??1}`;if(yt.current.key!==c&&(yt.current={key:c,attempts:0}),l?.path!==a){if(zs)return;me(Dt(a));return}if(Re||be!==a)return;if(Ze||ne||De||tt){ms(null),yt.current={key:"",attempts:0};return}if(!Ee)return;if(G!=="edit"){Fe("edit");return}const u=Pe.current;if(!u){t();return}if(!i(u,B)){t();return}const f=Math.max(1,Math.min(qe.line,u.state.doc.lines)),w=u.state.doc.line(f),D=Math.max(1,qe.column||1),$=Math.max(0,w.to-w.from),je=Math.min($,D-1),oe=w.from+je;if(!(u.state.selection.main.head===oe)||yt.current.attempts===0){yt.current.attempts+=1,u.dispatch({selection:{anchor:oe},effects:kt.scrollIntoView(oe,{y:"center"})}),u.focus(),t();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const st=Pe.current;st&&(st.dispatch({selection:{anchor:oe},effects:kt.scrollIntoView(oe,{y:"center"})}),st.focus())}),ms(null),yt.current={key:"",attempts:0}},[Ee,zs,B,nn,Ze,Re,ne,De,tt,be,me,qe,o,l?.path,ms,G,Dt]),n.useEffect(()=>{if(!$s||!o)return;const t=M($s);if(!t){Ws(null);return}l?.path===t&&(Re||be!==t||(!Ze&&!ne&&!De&&!tt&&Ee&&G==="edit"&&Pe.current?.focus(),Ws(null)))},[Ee,Ze,Re,ne,De,tt,be,$s,o,l?.path,Ws,G]);const Wt=n.useCallback(t=>{if(!h||!t||!t.hasFocus||typeof window>"u")return;const i=window.visualViewport;if(!i)return;const a=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,a-(i.offsetTop+i.height))<=0)return;const u=t.state.selection.main.head,f=t.coordsAtPos(u);if(!f)return;const w=Math.round(i.offsetTop+i.height),$=f.bottom+20-w;$<=0||(t.scrollDOM.scrollTop+=$)},[h]);n.useEffect(()=>{if(!h||typeof window>"u")return;const t=()=>{window.requestAnimationFrame(()=>{Wt(Pe.current)})},i=window.visualViewport;return i?.addEventListener("resize",t),i?.addEventListener("scroll",t,{passive:!0}),document.addEventListener("selectionchange",t),()=>{i?.removeEventListener("resize",t),i?.removeEventListener("scroll",t),document.removeEventListener("selectionchange",t)}},[h,Wt]),n.useEffect(()=>{if(!Ee||G!=="edit"||h)return;const t=ha("open_go_to_line",Mr),i=a=>{const c=a.target;if(c?.closest('[role="dialog"]'))return;const u=!!c?.closest(".cm-editor");c?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!u||!document.activeElement?.closest(".cm-editor")||xa(a,t)&&(a.preventDefault(),Os(!0))};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[Ee,h,Mr,G]);const bs=he(t=>t.editorFontSize),ii=n.useMemo(()=>{if(!l?.path)return[Ti(x,{fontSize:bs})];const t=sr(l.path),i=[Ti(x,t?{syntaxColors:!1,fontSize:bs}:{fontSize:bs})],a=ws??ti;return a&&i.push(a),t&&i.push(Ca({language:t,themeName:x.metadata.id,theme:Va(x)})),ce&&i.push(kt.lineWrapping),h&&i.push(kt.updateListener.of(c=>{c.view.hasFocus&&(c.selectionSet||c.focusChanged||c.viewportChanged||c.geometryChanged)&&window.requestAnimationFrame(()=>{Wt(c.view)})})),i},[x,l?.path,ws,ti,ce,h,Wt,bs]),ni=n.useMemo(()=>({light:fe.metadata.id,dark:ve.metadata.id}),[fe.metadata.id,ve.metadata.id]),ys=l?.path&&De?`${l.path}|${Ce.allowOutsideWorkspace?"outside":"workspace"}|${Ce.outsideFileGrant??""}|${us}`:"",js=l?.path&&$t&&xe==="preview"&&!m.isVSCode?`${l.path}|${us}`:"",ai=e("filesView.error.readFileFailed"),{readyKey:oi,nonce:On}=Ai(js,J,ai),{readyKey:li,nonce:ci}=Ai(ys,J,ai),Bn=!!(js&&oi!==js),di=!!(ys&&li!==ys),ui=l?.path&&ne?vs?`data:${pa(l.path)};utf8,${encodeURIComponent(k)}`:Ji:"",fi=l?.path&&De&&li===ys?yi().authenticatedAsset("/api/fs/raw",{path:l.path,allowOutsideWorkspace:Ce.allowOutsideWorkspace?"true":void 0,outsideFileGrant:Ce.outsideFileGrant,directory:o||void 0}):"",mi=n.useCallback(t=>s.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:s.jsx("iframe",{src:fi,className:"h-full w-full border-0",title:t.name},ci)}),[fi,ci]);n.useEffect(()=>{let t=!1,i="";return(async()=>{if(!l?.path||!ne||vs){Te("");return}J(null),await(r.readFileBinary?r.readFileBinary(l.path,Ce).then(u=>u.dataUrl):(async()=>{const u=await bi("/api/fs/raw",{query:{path:l.path,allowOutsideWorkspace:Ce.allowOutsideWorkspace?"true":void 0,outsideFileGrant:Ce.outsideFileGrant,directory:o||void 0}});if(!u.ok)throw new Error(e("filesView.error.readFileFailed"));const f=await u.blob();return i=URL.createObjectURL(f),t?(URL.revokeObjectURL(i),i="",""):i})()).then(u=>{t||(Te(u),K(l.path))}).catch(u=>{t||(Te(""),J(u instanceof Error?u.message:e("filesView.error.readFileFailed")),K(null))}).finally(()=>{t||Ye(!1)})})(),()=>{t=!0,i&&URL.revokeObjectURL(i)}},[us,r,ne,vs,o,l?.path,Ce,e]);const $n=n.useCallback(()=>As(null),[]),Wn=n.useMemo(()=>za({drafts:Ar,editingDraftId:ps,commentText:hs,onTextChange:Ir,selection:P,isDragging:Pr,fileLabel:l?.path??"",newWidgetId:"files-new-comment-input",mapDraftToRange:t=>({start:t.startLine,end:t.endLine}),onSave:Gr,onCancel:()=>{Me(null),es()},onEdit:t=>{Wr(t),Me({start:t.startLine,end:t.endLine})},onDelete:Ur}),[es,hs,Ur,ps,Ar,Gr,Pr,P,l?.path,Ir,Wr]),hi=n.useCallback((t,i)=>s.jsx("div",{className:"h-full",children:s.jsx(ka,{file:{name:t.name,contents:i,lang:sr(t.path)||void 0},options:{disableFileHeader:!0,overflow:ce?"wrap":"scroll",theme:ni,themeType:x.metadata.variant==="dark"?"dark":"light"},className:"block h-full w-full",style:{height:"100%"}})}),[x.metadata.variant,ni,ce]),Ys=({exitFullscreenOnly:t=!1,layout:i="floating"}={})=>{if(!l)return null;const c=i==="docked"?"pointer-events-auto flex flex-wrap items-center gap-1":"pointer-events-auto flex items-center gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-sm",u=(f,w)=>s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:w})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:f})]});return s.jsxs("div",{className:c,children:[Ee&&Rn&&s.jsxs(s.Fragment,{children:[Rt?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[s.jsx(g,{name:"loader-4",className:"size-3.5 animate-spin"}),e("filesView.editor.saving")]}):re&&en==="saved"&&!ie?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[s.jsx(g,{name:"check",className:"size-3.5"}),e("filesView.editor.saved")]}):ie?u(e(re?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:`${ar()}+S`}),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>{Nt()},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:e(re?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:`${ar()}+S`}),"aria-label":e("filesView.editor.saveAria",{shortcut:`${ar()}+S`}),children:s.jsx(g,{name:"save-3",className:"size-4"})})):null,u(e(re?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>sn(!re),className:O("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",re?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(re?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),"aria-label":e(re?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),children:re?s.jsx(g,{name:"file-check-fill",className:"size-4"}):s.jsx(g,{name:"file-check",className:"size-4"})}))]}),s.jsxs(cr,{onOpenChange:Tt,children:[s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(dr,{asChild:!0,children:s.jsx(S,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.openInDesktopApp"),"aria-label":e("filesView.editor.openInDesktopApp"),children:s.jsx(g,{name:"file-transfer",className:"size-4"})})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e("filesView.editor.openInDesktopApp")})]}),s.jsxs(ur,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[pn.map(f=>s.jsxs(Ss,{className:"flex items-center gap-2",onClick:()=>{wn(f)},children:[s.jsx($a,{label:f.label,iconDataUrl:f.iconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:f.label})]},f.id)),gn?s.jsxs(Ss,{className:"flex items-center gap-2",onClick:()=>{xn(!0)},children:[s.jsx(g,{name:"refresh",className:"size-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:e("filesView.editor.refreshApps")})]}):null]})]}),!ne&&!De&&!tt&&s.jsxs(s.Fragment,{children:[u(e(ce?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>Le(!ce),className:O("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",ce?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(ce?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),children:s.jsx(g,{name:"text-wrap",className:"size-4"})})),G==="edit"&&s.jsxs(s.Fragment,{children:[u(e("filesView.editor.findInFile"),s.jsx(S,{variant:"ghost",size:"sm",onClick:f=>{pe(!ee),f.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.findInFile"),children:s.jsx(g,{name:"search",className:"size-4"})})),u(e("filesView.editor.goToLine"),s.jsx(S,{variant:"ghost",size:"sm",onClick:f=>{Os(w=>!w),f.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.goToLine"),children:s.jsx(g,{name:"menu-fold-2",className:"size-4"})})),s.jsx(Aa,{open:hn,onOpenChange:Os,view:Pe.current,variant:"inline"})]})]}),Hs&&Ee&&!ts&&!$t&&s.jsx(or,{currentMode:G==="view"?"preview":"edit",onToggle:()=>{Pn(G==="view"?"edit":"view")}}),mt&&u(e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>si(ae()==="preview"?"edit":"preview"),className:O("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:e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),"aria-label":e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:s.jsx(g,{name:ae()==="preview"?"eye":"eye-off",className:"size-4"})})),lr(l?.path??"")&&s.jsx(or,{currentMode:ri(),onToggle:()=>{zn(ri()==="preview"?"edit":"preview")}}),mt&&ae()==="preview"&&bn&&s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx(S,{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":e(ds?"filesView.tts.stopSpeaking":"filesView.tts.readAloud"),onClick:()=>{ds?Xi():k.trim()&&_i(k)},children:ds?s.jsx(g,{name:"stop",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(g,{name:"volume-up",className:"size-4"})})}),s.jsx(gt,{sideOffset:8,children:e(ds?"filesView.tts.stopSpeaking":"filesView.tts.readAloud")})]}),ss&&s.jsxs(s.Fragment,{children:[s.jsx(or,{currentMode:ue,onToggle:()=>Ln(ue==="preview"?"edit":"preview")}),ue==="preview"&&s.jsx(S,{variant:"ghost",size:"sm",onClick:async()=>{const f=jr.current?.getXml();if(ye.current&&(clearTimeout(ye.current),ye.current=null),l?.path&&f){if(!await Qs(l.path,f))return;fs(!0),setTimeout(()=>fs(!1),1500)}},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.diagram.saveDiagram"),children:tn?s.jsx(g,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(g,{name:"save-3",className:"size-4"})})]}),ts&&u(e(Ie==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>Mn(Ie==="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:e(Ie==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),children:Ie==="tree"?s.jsx(g,{name:"code-sslash",className:"size-4"}):s.jsx(g,{name:"node-tree",className:"size-4"})})),Dn&&u(e("filesView.editor.copyFileContents"),s.jsx(S,{variant:"ghost",size:"sm",onClick:async()=>{(await Vs(k)).ok?(Cr(!0),Qt.current!==null&&window.clearTimeout(Qt.current),Qt.current=window.setTimeout(()=>{Cr(!1)},1200)):I.error(e("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.copyFileContents"),"aria-label":e("filesView.editor.copyFileContents"),children:fn?s.jsx(g,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(g,{name:"clipboard",className:"size-4"})})),En&&u(e("filesView.editor.copyFilePathTitle",{path:ft}),s.jsx(S,{variant:"ghost",size:"sm",onClick:async()=>{(await Vs(ft)).ok?(Sr(!0),Yt.current!==null&&window.clearTimeout(Yt.current),Yt.current=window.setTimeout(()=>{Sr(!1)},1200)):I.error(e("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.copyFilePathTitle",{path:ft}),"aria-label":e("filesView.editor.copyFilePathTitle",{path:ft}),children:mn?s.jsx(g,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(g,{name:"file-copy-2",className:"size-4"})})),r.downloadFile&&u(e("filesView.editor.saveFile"),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>{const f=r.downloadFile;f&&f(l.path).catch(w=>{console.error("Download failed:",w),I.error(e("sidebarFilesTree.toast.operationFailed"))})},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.saveFile"),"aria-label":e("filesView.editor.saveFile"),children:s.jsx(g,{name:"download",className:"size-4"})})),t?u(e("filesView.editor.exitFullscreen"),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>X(!1),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.exitFullscreen"),"aria-label":e("filesView.editor.exitFullscreen"),children:s.jsx(g,{name:"fullscreen-exit",className:"size-4"})})):!h&&d==="full"&&u(e(U?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>X(!U),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e(U?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),"aria-label":e(U?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),children:U?s.jsx(g,{name:"fullscreen-exit",className:"size-4"}):s.jsx(g,{name:"fullscreen",className:"size-4"})}))]})},Zs=s.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[s.jsx(Ii,{open:zs,onOpenChange:t=>{t||zt(!0)},children:s.jsxs(Oi,{showCloseButton:!1,className:"max-w-md",children:[s.jsxs(Bi,{children:[s.jsx($i,{children:e("filesView.unsaved.title")}),s.jsx(Wi,{children:e("filesView.unsaved.description")})]}),s.jsxs(Ui,{children:[s.jsx(S,{variant:"outline",onClick:()=>{Cn()},disabled:Rt,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:e("filesView.unsaved.saveChanges")}),s.jsx(S,{variant:"destructive",onClick:Nn,children:e("filesView.unsaved.discard")})]})]})}),s.jsxs("div",{className:O("flex flex-col flex-shrink-0",q&&"border-b border-border/40"),children:[q?s.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[h&&Z&&s.jsx("button",{type:"button",onClick:()=>A(!1),"aria-label":e("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:s.jsx(g,{name:"arrow-left-s",className:"size-5"})}),h?l?s.jsxs(cr,{children:[s.jsx(dr,{asChild:!0,children:s.jsxs("button",{type:"button",className:"inline-flex min-w-0 max-w-full items-center gap-1 text-left typography-ui-label font-medium","aria-label":e("filesView.editor.openFilesAria"),children:[s.jsx(Cs,{filePath:l.path,extension:l.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(Mi,{name:l.name}),s.jsx(g,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),s.jsx(ur,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:Et.map(t=>{const i=l?.path===t.path;return s.jsxs(Ss,{onSelect:a=>{if(a.target.closest("[data-close-open-file]")){a.preventDefault();return}i||me(t)},className:O("flex min-w-0 items-center justify-between gap-2 overflow-hidden",i&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[s.jsx(Cs,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(Mi,{name:t.name})]}),s.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:a=>{a.preventDefault(),a.stopPropagation()},onClick:a=>{a.preventDefault(),a.stopPropagation(),Yr(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":e("filesView.editor.closeFileAria",{name:t.name}),children:s.jsx(g,{name:"close",className:"size-3.5"})})]},t.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:e("filesView.editor.selectFile")}):Et.length>0?s.jsxs("div",{className:"relative min-w-0 flex-1",children:[pr.left&&s.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r from-background to-transparent"}),pr.right&&s.jsx("div",{className:"pointer-events-none absolute right-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l from-background to-transparent"}),s.jsx("div",{ref:Rs,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:Et.map(t=>{const i=l?.path===t.path;return s.jsxs("div",{title:ks(o,t.path),className:O("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",i?"bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]":"bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]"),children:[s.jsx(Cs,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),s.jsx("button",{type:"button",onClick:()=>{i||me(t)},className:"max-w-[12rem] truncate text-left",children:t.name}),s.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),Yr(t.path)},className:O("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!i&&!z&&"opacity-0 group-hover:opacity-100"),"aria-label":e("filesView.editor.closeFileAria",{name:t.name}),children:s.jsx(g,{name:"close",className:"size-3.5"})})]},t.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:e("filesView.editor.selectFile")})]}):null,(Lr||h)&&l?s.jsxs("div",{className:"flex min-w-0 items-center gap-3 border-t border-border/40 bg-[var(--surface-subtle)] px-3 py-1",children:[ft&&!h?s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:ft,children:ft}):null,s.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:Ys({layout:"docked"})})]}):null]}),s.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[l&&!ee&&!(Lr||h)&&s.jsx("div",{ref:de,className:"absolute right-3 top-3 z-30",onMouseLeave:()=>{rt.current>0||ge(!1)},children:te?Ys():s.jsxs("div",{className:"flex items-center gap-1",children:[mt?s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>si(ae()==="preview"?"edit":"preview"),className:O("size-8 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-0 shadow-sm transition-colors",ae()==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)]":"text-muted-foreground hover:text-foreground"),"aria-label":e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),title:e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:s.jsx(g,{name:ae()==="preview"?"eye":"eye-off",className:"size-4"})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode")})]}):null,s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",onMouseEnter:()=>ge(!0),children:s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>ge(!0),className:"size-8 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-0 text-muted-foreground shadow-sm hover:text-foreground","aria-label":e("filesView.editor.showControlsAria"),title:e("filesView.editor.controlsTitle"),children:s.jsx(g,{name:"more-2-fill",className:"size-4"})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e("filesView.editor.controlsTitle")})]})]})}),s.jsx(ir,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:l?Re||di?W?s.jsx("div",{className:"p-3"}):s.jsxs("div",{className:"p-3 flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.loading")]}):Ze?s.jsx("div",{className:"p-3 typography-ui text-[color:var(--status-error)]",children:Ze}):ne?s.jsx("div",{className:"flex h-full items-center justify-center p-3",children:s.jsx("img",{src:ui,alt:l?.name??e("filesView.editor.imageAltFallback"),className:"max-w-full max-h-[70vh] object-contain rounded-md border border-border/30 bg-primary/10"},l.path)}):De?mi(l):tt?s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx("div",{className:"typography-ui-header text-foreground",children:e("filesView.editor.cannotPreviewBinary")}),s.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:e("filesView.editor.binaryFileDescription")}),r.downloadFile?s.jsxs(S,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=r.downloadFile;!t||!l||t(l.path).catch(i=>{console.error("Download failed:",i),I.error(e("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(g,{name:"download",className:"mr-2 size-4"}),e("filesView.editor.saveFile")]}):null]}):l&&ss&&ue==="preview"?s.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:s.jsx(Ra,{ref:jr,xml:In,onChange:An},`${l.path}:${it}`)}):l&&ts&&Ie==="tree"?s.jsx(nr,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.jsonViewerUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToTextMode")})]}),children:s.jsx("div",{className:"h-full overflow-auto",children:s.jsx(Ta,{jsonString:k,maxHeight:"100%",initiallyExpandedDepth:2})})}):l&&mt&&ae()==="preview"?s.jsxs("div",{className:"h-full overflow-auto p-3",children:[k.length>500*1024&&s.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:e("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(k.length/1024)})}),s.jsx(nr,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToEditMode")})]}),children:s.jsx(ki,{content:k,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}):l&&$t&&xe==="preview"?Bn?s.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:e("common.loading")}):s.jsx("div",{className:"h-full overflow-hidden",children:s.jsx("iframe",{src:!m.isVSCode&&oi===js?(()=>{const t=l.path.split("/").map(i=>encodeURIComponent(i)).join("/");return yi().authenticatedAsset(`/api/fs/serve${t.startsWith("/")?t:`/${t}`}`)})():void 0,srcDoc:m.isVSCode?(()=>{const t=l.path.substring(0,l.path.lastIndexOf("/")+1);return t?k.replace(/<head([^>]*)>/i,`<head$1><base href="${t}">`):k})():void 0,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:e("filesView.editor.htmlPreviewTitle")},On)}):l&&Hs&&G==="view"?hi(l,B):s.jsxs("div",{className:O("relative h-full",Bt&&"overflow-hidden"),ref:rn,children:[s.jsx("div",{className:O("h-full",Bt&&"invisible"),children:s.jsx(Vi,{value:B,onChange:Q,readOnly:!Ee,vimMode:zr==="vim",extensions:ii,className:"h-full",blockWidgets:Wn,onViewReady:t=>{Pe.current=t,Ls(i=>i+1),window.requestAnimationFrame(()=>{Wt(t)})},onViewDestroy:()=>{Pe.current&&(Pe.current=null),Ls(t=>t+1)},enableSearch:!0,searchOpen:ee,onSearchOpenChange:pe,highlightLines:P?{start:Math.min(P.start,P.end),end:Math.max(P.start,P.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(t,i,a)=>{if(!(a instanceof MouseEvent)||a.button!==0)return!1;a.preventDefault();const c=t.state.doc.lineAt(i.from).number;if(P&&!a.shiftKey&&Math.min(P.start,P.end)===c&&Math.max(P.start,P.end)===c)return Me(null),es(),It.current=!1,dt.current=null,Ot(!1),!0;if(h&&P&&!a.shiftKey){const u=Math.min(P.start,P.end,c),f=Math.max(P.start,P.end,c);return Me({start:u,end:f}),It.current=!1,dt.current=null,Ot(!1),!0}if(It.current=!0,dt.current=c,Ot(!0),P&&a.shiftKey){const u=Math.min(P.start,c),f=Math.max(P.end,c);Me({start:u,end:f})}else Me({start:c,end:c});return!0},mouseover:(t,i,a)=>{if(!(a instanceof MouseEvent)||a.buttons!==1||!It.current||dt.current===null)return!1;const c=t.state.doc.lineAt(i.from).number,u=Math.min(dt.current,c),f=Math.max(dt.current,c);return Me({start:u,end:f}),Ot(!0),!1},mouseup:()=>(It.current=!1,dt.current=null,Ot(!1),!1)}}})}),Bt&&s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:s.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.openingFileAtChange")]})})]}):s.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:e("filesView.editor.pickFileFromTree")})})]})]}),Un=!!(o&&vr[o]),pi=o?os[o]:null,gi=s.jsxs("section",{className:O("flex min-h-0 flex-col overflow-hidden",h?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[s.jsx("div",{className:O("flex flex-col gap-2 py-2",h?"px-3":"px-2"),children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1 min-w-0",children:[s.jsx(g,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),s.jsx(Ts,{ref:Y,value:T,onChange:t=>V(t.target.value),placeholder:e("filesView.tree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),T.trim().length>0&&s.jsx("button",{type:"button","aria-label":e("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:()=>{V(""),Y.current?.focus()},children:s.jsx(g,{name:"close",className:"size-4"})})]}),s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>Bs("createFile",{path:R,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.newFileTitle"),"aria-label":e("filesView.tree.actions.newFileTitle"),children:s.jsx(g,{name:"file-add",className:"size-4"})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.newFileTitle")})]}),s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>Bs("createFolder",{path:R,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.newFolderTitle"),"aria-label":e("filesView.tree.actions.newFolderTitle"),children:s.jsx(g,{name:"folder-add",className:"size-4"})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.newFolderTitle")})]}),s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>{gs()},className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.refreshTitle"),"aria-label":e("filesView.tree.actions.refreshTitle"),children:s.jsx(g,{name:"refresh",className:"size-4"})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.refreshTitle")})]})]})}),s.jsx(ir,{outerClassName:"flex-1 min-h-0",className:O("py-2",h?"px-3":"px-2"),children:s.jsx("ul",{className:"flex flex-col",children:qi?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.tree.search.searching")]}):br.length>0?br.map(t=>{const i=l?.path===t.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>{me(t)},className:O("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[Ki(t.path,t.extension),s.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)}):pi?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"text-[var(--status-error)]",children:pi}),s.jsxs(S,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{gs()},children:[s.jsx(g,{name:"refresh",className:"size-3.5"}),e("filesView.tree.actions.refreshTitle")]})]}):Un?Zr(o,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:e("filesView.state.loading")})})})]}),Gn=d==="full"&&U&&l&&s.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:s.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[s.jsx("div",{className:"absolute right-4 top-4 z-30",children:Ys({exitFullscreenOnly:!0})}),s.jsx(ir,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:Re||di?W?s.jsx("div",{className:"p-4"}):s.jsxs("div",{className:"p-4 flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}),"Loading…"]}):Ze?s.jsx("div",{className:"p-4 typography-ui text-[color:var(--status-error)]",children:Ze}):ne?s.jsx("div",{className:"flex h-full items-center justify-center p-4",children:s.jsx("img",{src:ui,alt:l.name,className:"max-w-full max-h-full object-contain rounded-md border border-border/30 bg-primary/10"},l.path)}):De?mi(l):tt?s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx("div",{className:"typography-ui-header text-foreground",children:e("filesView.editor.cannotPreviewBinary")}),s.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:e("filesView.editor.binaryFileDescription")}),r.downloadFile?s.jsxs(S,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=r.downloadFile;!t||!l||t(l.path).catch(i=>{console.error("Download failed:",i),I.error(e("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(g,{name:"download",className:"mr-2 size-4"}),e("filesView.editor.saveFile")]}):null]}):mt&&ae()==="preview"?s.jsxs("div",{className:"h-full overflow-auto p-4",children:[k.length>500*1024&&s.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:e("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(k.length/1024)})}),s.jsx(nr,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToEditMode")})]}),children:s.jsx(ki,{content:k,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}):Hs&&G==="view"?hi(l,B):s.jsxs("div",{className:O("relative h-full",Bt&&"overflow-hidden"),children:[s.jsx("div",{className:O("h-full",Bt&&"invisible"),children:s.jsx(Vi,{value:B,onChange:Q,readOnly:!Ee,vimMode:zr==="vim",extensions:ii,className:"h-full",onViewReady:t=>{Pe.current=t,window.requestAnimationFrame(()=>{Wt(t)})},onViewDestroy:()=>{Pe.current&&(Pe.current=null)}})}),Bt&&s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:s.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.openingFileAtChange")]})})]})})]})});return s.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[s.jsx(Za,{activeDialog:jt,dialogData:Ft,dialogInputValue:ct,onDialogInputChange:Nr,isDialogSubmitting:on,onDialogSubmit:Fn,onClose:$n,inputRef:Yi}),Gn,h?Z?Zs:gi:d==="editor-only"?s.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:Zs})}):s.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[p>=700&&s.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:gi}),s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:Zs})]})]})};function eo(d){return d+1}export{wc as FilesView};
@@ -1,12 +0,0 @@
1
- import{R as _,f as V,j as ee}from"./vendor-react-BUCujlKS.js";import{m as lt}from"./vendor-morphdom-B7dS_VPB.js";import{r as ct,a as dt}from"./vendor-beautiful-mermaid-DztCUpLZ.js";import{f3 as De,f4 as mt,f5 as ut,g as de,d3 as pt,d4 as ft,f6 as ht,f7 as gt,V as We,a0 as qe,f8 as $e,h as Be,d_ as bt,f as wt,f9 as yt,o as vt,fa as be,fb as At,fc as kt,fd as Et}from"./useAppFontEffects-CbzHzFop.js";import{H as we,cg as Ct,u as X,ai as ye,E as ze,y as St,z as Lt,r as Mt}from"./index-DzriVon2.js";import{h as Nt}from"./contextPanelEmbeddedChat-BO1wRpaN.js";import{renderMarkdownSync as Rt,renderMarkdownBlocks as xt}from"./markdownCore-BgeBDwD3.js";import{r as _t}from"./registerCustomTheme-BBXUCRnG.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-elkjs-BRwcR927.js";import"./vendor-entities-C3BA0AJP.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-base-ui-BYlZTzrw.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.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-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-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.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-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-CiAYDJXN.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-zod-adaMkgkm.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-marked-CX41MkDF.js";import"./vendor-remend-BWYYytN3.js";import"./vendor-katex-k3Ppq1Ha.js";import"./vendor-dompurify-r8glNMJW.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.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";const Ve="openchamber-md",Tt={name:Ve,colors:{"editor.background":"transparent","editor.foreground":"var(--md-syntax-foreground)"},tokenColors:[{scope:["comment","punctuation.definition.comment","string.comment"],settings:{foreground:"var(--md-syntax-comment)",fontStyle:"italic"}},{scope:["string","punctuation.definition.string","string.template"],settings:{foreground:"var(--md-syntax-string)"}},{scope:["constant.numeric","constant.language","constant.character","constant"],settings:{foreground:"var(--md-syntax-number)"}},{scope:["keyword","storage","storage.type","storage.modifier","keyword.control"],settings:{foreground:"var(--md-syntax-keyword)"}},{scope:["keyword.operator","punctuation.separator","punctuation.terminator"],settings:{foreground:"var(--md-syntax-operator)"}},{scope:["entity.name.function","support.function","meta.function-call"],settings:{foreground:"var(--md-syntax-function)"}},{scope:["entity.name.type","entity.name.class","support.type","support.class","entity.other.inherited-class"],settings:{foreground:"var(--md-syntax-type)"}},{scope:["variable","variable.other","variable.parameter","meta.definition.variable"],settings:{foreground:"var(--md-syntax-variable)"}},{scope:["variable.other.property","meta.property-name","support.type.property-name"],settings:{foreground:"var(--md-syntax-property)"}},{scope:["entity.name.tag","punctuation.definition.tag"],settings:{foreground:"var(--md-syntax-keyword)"}},{scope:["entity.other.attribute-name"],settings:{foreground:"var(--md-syntax-property)"}},{scope:["markup.bold","punctuation.definition.bold"],settings:{fontStyle:"bold"}},{scope:["markup.italic","punctuation.definition.italic"],settings:{fontStyle:"italic"}},{scope:["markup.heading","markup.heading entity.name"],settings:{foreground:"var(--md-syntax-keyword)",fontStyle:"bold"}},{scope:["markup.inserted","punctuation.definition.inserted"],settings:{foreground:"var(--md-syntax-inserted)"}},{scope:["markup.deleted","punctuation.definition.deleted"],settings:{foreground:"var(--md-syntax-deleted)"}},{scope:["invalid","invalid.illegal"],settings:{foreground:"var(--md-syntax-deleted)"}}]};let ve=!1;const Pt=()=>{ve||(ve=!0,_t(Ve,()=>Promise.resolve(Tt)))},x=t=>Number.isFinite(t)&&t>0,Ae=t=>{if(typeof t=="number")return x(t)?t:null;if(typeof t!="string")return null;const e=t.trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!e)return null;const r=Number(e[1]);return x(r)?r:null},me=(t,e,r)=>Math.min(r,Math.max(e,t)),Ft=6,ke=1.25,It=1.0015,Ot=.5,Dt=12,Ee=3,Wt=400,te='[data-markdown="mermaid-block"]',$=t=>t.querySelector(te)!==null,qt=t=>[t.x,t.y,t.width,t.height].map(e=>{const r=Number(e.toFixed(Ft));return Object.is(r,-0)?"0":String(r)}).join(" "),$t=t=>{const e=t.viewBox?.trim().split(/[\s,]+/).map(a=>Number.parseFloat(a));if(e?.length===4){const[a,i,s,o]=e;if(Number.isFinite(a)&&Number.isFinite(i)&&x(s)&&x(o))return{x:a,y:i,width:s,height:o}}const r=Ae(t.width),n=Ae(t.height);return r===null||n===null?null:{x:0,y:0,width:r,height:n}},Bt=t=>{let e=2166136261;for(let r=0;r<t.length;r+=1)e^=t.charCodeAt(r),e=Math.imul(e,16777619);return(e>>>0).toString(36)},zt=t=>{const e=t.renderMode||"unknown",r=t.svgMarkup??"";if(!r){const n=[t.viewBox??"",t.width??"",t.height??""];return n.some(a=>a!=="")?`${e}:bounds:${n.join(":")}`:`${e}:no-svg`}return[e,Bt(r)].join(":")},He=(t,e)=>{if(!x(e.width)||!x(e.height))return t;const r=t.width/t.height,n=e.width/e.height;if(r>n){const i=t.width/n;return{x:t.x,y:t.y-(i-t.height)/2,width:t.width,height:i}}const a=t.height*n;return{x:t.x-(a-t.width)/2,y:t.y,width:a,height:t.height}},Vt=({currentBox:t,viewport:e,delta:r})=>!x(e.width)||!x(e.height)||!x(t.width)||!x(t.height)?t:{x:t.x-r.x/e.width*t.width,y:t.y-r.y/e.height*t.height,width:t.width,height:t.height},Ht=(t,e)=>{const r=e.x-t.x,n=e.y-t.y;return r*r+n*n>Ee*Ee},Kt=({currentBox:t,contentBox:e,viewport:r,pointer:n,zoomFactor:a,minScale:i,maxScale:s})=>{if(!x(r.width)||!x(r.height)||!x(a)||!x(t.width)||!x(t.height)||!x(e.width)||!x(e.height)||!x(i)||!x(s))return t;const o=Math.min(i,s),l=Math.max(i,s),c=He(e,r),d=c.width/t.width,f=me(d*a,o,l),m=c.width/f,u=m/(t.width/t.height),g=me(n.x/r.width,0,1),k=me(n.y/r.height,0,1),E=t.x+g*t.width,v=t.y+k*t.height;return{x:E-g*m,y:v-k*u,width:m,height:u}},he=new WeakMap,jt=t=>t instanceof HTMLElement?he.get(t)??null:null,Ut=t=>t.querySelector('[data-markdown="mermaid-viewport"]')??t.querySelector('[data-markdown="mermaid"]'),Ce=t=>{const e=t.querySelector('[data-markdown="mermaid"] svg'),r=t.querySelector('[data-markdown="mermaid"]');return zt({renderMode:t.getAttribute("data-mermaid-render"),svgMarkup:r?.getAttribute("data-md-original-svg")??e?.outerHTML??null,viewBox:e?.getAttribute("viewBox"),width:e?.getAttribute("width"),height:e?.getAttribute("height")})},Q=t=>{const e=t.getBoundingClientRect();return{width:e.width,height:e.height}},Zt=(t,e)=>{const r=e.getBoundingClientRect();return{x:t.clientX-r.left,y:t.clientY-r.top}},Xt=t=>t instanceof Element&&!!t.closest('button, a, [role="button"]'),Gt=t=>{const e=Ut(t),r=t.querySelector('[data-markdown="mermaid"] svg');if(!e||!r)return null;const n=$t({viewBox:r.getAttribute("viewBox"),width:r.getAttribute("width"),height:r.getAttribute("height")});if(!n)return null;let a=n,i=null,s=null,o=null,l=null;const c=p=>{a=p,r.setAttribute("viewBox",qt(p)),r.removeAttribute("width"),r.removeAttribute("height")},d=()=>{c(He(n,Q(e)))},f=(p,C)=>{c(Kt({currentBox:a,contentBox:n,viewport:Q(e),pointer:p,zoomFactor:C,minScale:Ot,maxScale:Dt}))},m=()=>{const p=Q(e);f({x:p.width/2,y:p.height/2},ke)},u=()=>{const p=Q(e);f({x:p.width/2,y:p.height/2},1/ke)},g=p=>{!p.ctrlKey&&!p.metaKey||(p.preventDefault(),p.stopPropagation(),f(Zt(p,e),Math.pow(It,-p.deltaY)))},k=p=>{p.button!==0||Xt(p.target)||(i=p.pointerId,s={x:p.clientX,y:p.clientY},o=s,l!==null&&(window.clearTimeout(l),l=null),t.removeAttribute("data-mermaid-suppress-click"),e.setPointerCapture?.(p.pointerId),t.setAttribute("data-mermaid-panning","true"),p.preventDefault())},E=p=>{if(i!==p.pointerId||!o)return;const C={x:p.clientX,y:p.clientY};c(Vt({currentBox:a,viewport:Q(e),delta:{x:C.x-o.x,y:C.y-o.y}})),o=C,s&&Ht(s,C)&&t.setAttribute("data-mermaid-suppress-click","true"),p.preventDefault()},v=p=>{i===p.pointerId&&(e.releasePointerCapture?.(p.pointerId),i=null,s=null,o=null,t.removeAttribute("data-mermaid-panning"),t.hasAttribute("data-mermaid-suppress-click")&&(l=window.setTimeout(()=>{t.removeAttribute("data-mermaid-suppress-click"),l=null},Wt)))},S=()=>{d()};e.addEventListener("wheel",g,{passive:!1}),e.addEventListener("pointerdown",k),e.addEventListener("pointermove",E),e.addEventListener("pointerup",v),e.addEventListener("pointercancel",v),window.addEventListener("resize",S);const M=typeof ResizeObserver>"u"?null:new ResizeObserver(S);return M?.observe(e),d(),{zoomIn:m,zoomOut:u,fit:d,cleanup:()=>{e.removeEventListener("wheel",g),e.removeEventListener("pointerdown",k),e.removeEventListener("pointermove",E),e.removeEventListener("pointerup",v),e.removeEventListener("pointercancel",v),window.removeEventListener("resize",S),M?.disconnect(),l!==null&&window.clearTimeout(l),t.removeAttribute("data-mermaid-panning"),t.removeAttribute("data-mermaid-suppress-click"),he.delete(t)}}},Yt=t=>{const e=new Map,r=new Map,n=()=>{for(const[i,s]of Array.from(e.entries())){const o=Ce(i);(!t.contains(i)||o!==r.get(i))&&(s.cleanup(),e.delete(i),r.delete(i))}for(const i of Array.from(t.querySelectorAll(te))){if(e.has(i)||i.querySelector('[data-markdown="mermaid"] svg')===null)continue;const s=Gt(i);s&&(e.set(i,s),r.set(i,Ce(i)),he.set(i,s))}},a=()=>{for(const i of e.values())i.cleanup();e.clear(),r.clear()};return n(),{refresh:n,cleanup:a}},q=t=>`<svg class="remixicon size-3.5" viewBox="0 0 24 24" aria-hidden="true"><use href="#oc-${t}"></use></svg>`,re={copy:q("file-copy"),check:q("check"),download:q("download"),zoomIn:q("add"),zoomOut:q("subtract"),fit:q("refresh"),textWrap:q("text-wrap"),image:q("file-image")},Ke="p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--interactive-focus-ring)]",ne=(t,e)=>{t.innerHTML=e},Jt=t=>{for(const e of Array.from(t.querySelectorAll('[data-openchamber-markdown-image-label="true"]'))){if(e.querySelector("[data-openchamber-markdown-image-label-icon]"))continue;const r=document.createElement("span");r.className="inline-flex shrink-0",r.setAttribute("aria-hidden","true"),r.setAttribute("data-openchamber-markdown-image-label-icon","true"),ne(r,re.image),e.prepend(r)}},D=(t,e,r)=>{const n=document.createElement("button");return n.type="button",n.className=Ke,n.setAttribute("data-md-action",r),n.setAttribute("title",e),n.setAttribute("aria-label",e),ne(n,re[t]),n},je=(t,e,r)=>{const n=t.querySelector("[data-md-code-body]"),a=t.querySelector("pre"),i=t.querySelector("pre code"),s=t.querySelectorAll("[data-md-code-line-content]"),o=t.querySelector('[data-md-action="toggle-code-wrap"]');t.setAttribute("data-code-wrap",e?"true":"false"),n?.classList.toggle("overflow-x-auto",!e),n?.classList.toggle("overflow-x-hidden",e),a?.classList.toggle("whitespace-pre-wrap",e),a?.classList.toggle("break-words",e),i?.classList.toggle("whitespace-pre-wrap",e),i?.classList.toggle("break-words",e),a&&(a.style.whiteSpace=e?"pre-wrap":"pre",a.style.overflowWrap=e?"anywhere":"normal"),i&&(i.style.whiteSpace=e?"pre-wrap":"pre",i.style.overflowWrap=e?"anywhere":"normal");for(const l of Array.from(s))l.style.whiteSpace=e?"pre-wrap":"pre",l.style.overflowWrap=e?"anywhere":"normal";if(o){const l=e?r.disableCodeWrap:r.enableCodeWrap;o.setAttribute("title",l),o.setAttribute("aria-label",l),o.classList.toggle("text-foreground",e),o.classList.toggle("opacity-100",e),o.classList.toggle("text-muted-foreground",!e),o.classList.toggle("opacity-65",!e),o.setAttribute("aria-pressed",e?"true":"false")}},Ue=t=>{const e=t.querySelector(":scope > code");if(!e||e.hasAttribute("data-md-code-lines"))return;const r=e.textContent??"",n=r.endsWith(`
2
- `),a=n?r.slice(0,-1).split(`
3
- `):r.split(`
4
- `),i=a.length>0?a:[""],s=Array.from(e.children).filter(c=>c.classList.contains("line"));n&&s.length===i.length+1&&s.at(-1)?.textContent===""&&s.pop();const o=s.length===i.length,l=document.createDocumentFragment();i.forEach((c,d)=>{const f=document.createElement("span");f.setAttribute("data-md-code-line","");const m=document.createElement("span");m.setAttribute("data-md-code-line-number",""),m.setAttribute("aria-hidden","true"),m.textContent=String(d+1);const u=document.createElement("span");if(u.setAttribute("data-md-code-line-content",""),o){const g=s[d];g&&u.append(...Array.from(g.childNodes))}else u.textContent=c;if(f.append(m,u),l.appendChild(f),d<i.length-1||n){const g=document.createElement("span");g.setAttribute("data-md-code-line-break",""),g.textContent=`
5
- `,l.appendChild(g)}}),e.replaceChildren(l),e.setAttribute("data-md-code-lines",""),e.toggleAttribute("data-md-code-trailing-newline",n)},Ze=t=>{const e=Array.from(t.querySelectorAll("[data-md-code-line-content]"));if(e.length===0)return t.textContent??"";const r=e.map(n=>n.textContent??"").join(`
6
- `);return t.hasAttribute("data-md-code-trailing-newline")?`${r}
7
- `:r},Qt=(t,e,r)=>{const n=t.querySelectorAll('[data-component="markdown-code"]');for(const a of Array.from(n)){const i=a.querySelector("pre");i&&Ue(i),je(a,e,r)}},Se=(t,e,r,n)=>{ne(t,re.check),t.setAttribute("title",e),t.setAttribute("aria-label",e),window.setTimeout(()=>{ne(t,re[r]),t.setAttribute("title",n),t.setAttribute("aria-label",n)},2e3)},er=t=>{const e=t.querySelectorAll(":not(pre) > code");for(const r of Array.from(e))r.getAttribute("data-markdown")!=="inline-code"&&r.setAttribute("data-markdown","inline-code")},tr=(t,e)=>{const r=t.querySelectorAll("pre");for(const n of Array.from(r)){if(n.querySelector("code.language-mermaid"))continue;const a=n.parentElement;if(!a||a.closest('[data-component="markdown-code"]'))continue;const i=n.querySelector("code")?.className.match(/language-([\w+#.-]+)/)?.[1],s=n.getAttribute("data-md-lang")??i??"text",o=document.createElement("div");o.setAttribute("data-component","markdown-code"),o.className="my-4 group overflow-hidden rounded-2xl border border-border/80 bg-[var(--surface-elevated)]";const l=document.createElement("div");l.className="flex items-center justify-between border-b border-border/70 px-3 py-1.5";const c=document.createElement("span");c.className="font-mono text-[13px] text-muted-foreground",c.textContent=s;const d=D("copy",e.labels.copy,"copy-code"),f=D("textWrap",e.codeBlockLineWrap?e.labels.disableCodeWrap:e.labels.enableCodeWrap,"toggle-code-wrap");l.appendChild(c);const m=document.createElement("div");m.className="flex items-center gap-1",m.setAttribute("data-md-code-actions",""),m.appendChild(f),m.appendChild(d),l.appendChild(m);const u=document.createElement("div");u.setAttribute("data-md-code-body",""),u.className="px-3 py-2.5 overflow-x-auto",a.replaceChild(o,n),n.style.margin="0",n.style.background="transparent",n.classList.add("min-w-0","w-full","flex-1"),e.deferCodeLineNumberSync||Ue(n),u.appendChild(n),o.appendChild(l),o.appendChild(u),je(o,e.codeBlockLineWrap,e.labels)}},Le=t=>{const e=[],r=[],n=t.querySelectorAll("thead th");for(const i of Array.from(n))e.push((i.textContent??"").trim());const a=t.querySelectorAll("tbody tr");for(const i of Array.from(a)){const s=Array.from(i.querySelectorAll("td")).map(o=>(o.textContent??"").trim());s.length>0&&r.push(s)}return{headers:e,rows:r}},rr=t=>/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t,Me=({headers:t,rows:e})=>[t,...e].map(r=>r.map(rr).join(",")).join(`
8
- `),nr=({headers:t,rows:e})=>[t,...e].map(r=>r.join(" ")).join(`
9
- `),Ne=({headers:t,rows:e})=>{const r=`| ${t.join(" | ")} |`,n=`| ${t.map(()=>"---").join(" | ")} |`,a=e.map(i=>`| ${i.join(" | ")} |`).join(`
10
- `);return`${r}
11
- ${n}
12
- ${a}`},Re=(t,e)=>{const r=document.createElement("div");r.className=`absolute top-full right-0 mt-1 hidden ${pt}`,r.style.backgroundColor="var(--surface-elevated)",r.style.color="var(--surface-elevated-foreground)",r.setAttribute("data-md-menu",t);for(const n of e){const a=document.createElement("button");a.type="button",a.className=`w-full text-left ${ft}`,a.setAttribute("data-md-action",`${t}-${n.key}`),a.textContent=n.label,r.appendChild(a)}return r},or=(t,e)=>{const r=t.querySelectorAll("table");for(const n of Array.from(r)){if(n.closest('[data-markdown="table-wrapper"]'))continue;const i=document.createElement("div");i.className="group my-4 flex flex-col space-y-2",i.setAttribute("data-markdown","table-wrapper");const s=document.createElement("div");s.className="flex items-center justify-end gap-1";const o=document.createElement("div");o.className="relative",o.appendChild(D("copy",e.copyTable,"table-copy-toggle")),o.appendChild(Re("table-copy",[{key:"csv",label:"CSV"},{key:"tsv",label:"TSV"},{key:"markdown",label:"Markdown"}]));const l=document.createElement("div");l.className="relative",l.appendChild(D("download",e.downloadTable,"table-download-toggle")),l.appendChild(Re("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),s.appendChild(o),s.appendChild(l);const c=document.createElement("div");c.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const d=n.parentElement;if(!d)continue;d.replaceChild(i,n),n.setAttribute("data-markdown","table"),n.classList.add("w-full","border-collapse","text-sm");for(const m of Array.from(n.querySelectorAll("tr")))m.classList.add("border-b","border-border/60");const f=n.querySelector("tbody tr:last-child");f?.classList.remove("border-b"),f?.classList.add("border-0");for(const m of Array.from(n.querySelectorAll("th")))m.classList.add("border-r","border-border/60","px-4","py-2.5","text-left","align-middle","font-semibold","text-foreground","last:border-r-0");for(const m of Array.from(n.querySelectorAll("td")))m.classList.add("border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground/90","last:border-r-0");c.appendChild(n),i.appendChild(s),i.appendChild(c)}},ir=(t,e)=>{const r=t.querySelectorAll("pre > code.language-mermaid");for(const n of Array.from(r)){const a=n.parentElement;if(!a)continue;const i=(n.textContent??"").replace(/\s+$/,""),s=e.renderMermaid(i),o=document.createElement("div");o.setAttribute("data-markdown","mermaid-block"),o.setAttribute("data-md-source",i),o.className="group relative";const l=document.createElement("div");l.setAttribute("data-markdown","mermaid-scroll");const c=document.createElement("div");if(c.setAttribute("data-markdown","mermaid-toolbar"),c.className="absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity",s.svg){o.setAttribute("data-mermaid-render","svg");const f=document.createElement("div");f.setAttribute("data-markdown","mermaid-viewport");const m=document.createElement("div");if(m.setAttribute("data-markdown","mermaid"),m.setAttribute("data-md-original-svg",s.svg),m.innerHTML=s.svg,f.appendChild(m),l.appendChild(f),e.mermaidControls.showPanZoomControls&&(c.appendChild(D("zoomIn",e.labels.zoomInDiagram,"mermaid-zoom-in")),c.appendChild(D("zoomOut",e.labels.zoomOutDiagram,"mermaid-zoom-out")),c.appendChild(D("fit",e.labels.resetDiagramView,"mermaid-fit"))),e.mermaidControls.copy){const u=D("copy",e.labels.copyDiagram,"mermaid-copy");u.setAttribute("data-md-source",i),c.appendChild(u)}if(e.mermaidControls.download){const u=D("download",e.labels.downloadDiagram,"mermaid-download");u.setAttribute("data-md-svg","1"),c.appendChild(u)}}else{o.setAttribute("data-mermaid-render","ascii");const f=document.createElement("pre");if(f.setAttribute("data-markdown","mermaid-ascii"),f.textContent=s.ascii||i,l.appendChild(f),e.mermaidControls.copy){const m=D("copy",e.labels.copyDiagram,"mermaid-copy");m.setAttribute("data-md-source",s.ascii||i),c.appendChild(m)}}o.appendChild(l),o.appendChild(c);const d=a.parentElement;d&&d.replaceChild(o,a)}},ar=(t,e)=>{const r=t.querySelectorAll("a[href]");for(const n of Array.from(r)){if(n.getAttribute("data-md-link-decorated")==="true"||n.getAttribute("data-openchamber-file-link")==="true")continue;const a=n.getAttribute("href")??"";if(!De(a))continue;n.setAttribute("data-md-link-decorated","true");const i=mt(a);if(i){const s=document.createElement("span");s.className="mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle";const o=document.createElement("img");o.src=i,o.alt="",o.setAttribute("aria-hidden","true"),o.loading="lazy",o.decoding="async",o.className="size-3.5 rounded-sm",o.addEventListener("error",()=>s.remove(),{once:!0}),s.appendChild(o),n.parentNode?.insertBefore(s,n)}if(e.onPreviewLoopback&&ut(a)){const s=document.createElement("button");s.type="button",s.className=`ml-1 align-middle ${Ke}`,s.setAttribute("data-md-action","preview-loopback"),s.setAttribute("data-md-url",a),s.setAttribute("title",e.labels.previewTitle),s.setAttribute("aria-label",e.labels.previewLabel),ne(s,re.download),n.parentNode?.insertBefore(s,n.nextSibling)}}},xe=(t,e)=>{Jt(t),er(t),ir(t,e),tr(t,e),or(t,e.labels),ar(t,e)},_e=(t,e,r)=>{const n=new Blob([e],{type:r}),a=URL.createObjectURL(n),i=document.createElement("a");i.href=a,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(a)},ae=t=>{for(const e of Array.from(t.querySelectorAll("[data-md-menu]")))e.classList.add("hidden")},sr=(t,e)=>{const r=n=>{const a=n.target;if(!(a instanceof Element))return;const i=a.closest("[data-md-action]");if(!i){ae(t);return}const s=i.getAttribute("data-md-action")??"";if(s==="copy-code"){const o=i.closest('[data-component="markdown-code"]')?.querySelector("code"),l=o?Ze(o):"";l&&de(l).then(()=>Se(i,e.labels.copied,"copy",e.labels.copy));return}if(s==="toggle-code-wrap"){n.preventDefault(),e.onToggleCodeBlockLineWrap?.();return}if(s==="table-copy-toggle"||s==="table-download-toggle"){n.preventDefault();const o=i.parentElement?.querySelector("[data-md-menu]")??null,l=o?.classList.contains("hidden")??!1;ae(t),o&&l&&o.classList.remove("hidden");return}if(s.startsWith("table-copy-")){const o=s.replace("table-copy-",""),l=i.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(l instanceof HTMLTableElement){const c=Le(l),d=o==="csv"?Me(c):o==="tsv"?nr(c):Ne(c);de(d)}ae(t);return}if(s.startsWith("table-download-")){const o=s.replace("table-download-",""),l=i.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(l instanceof HTMLTableElement){const c=Le(l),d=o==="csv"?Me(c):Ne(c);_e(o==="csv"?"table.csv":"table.md",d,o==="csv"?"text/csv":"text/markdown")}ae(t);return}if(s==="mermaid-copy"){const o=i.getAttribute("data-md-source")??"";o&&de(o).then(()=>Se(i,e.labels.copied,"copy",e.labels.copyDiagram));return}if(s==="mermaid-zoom-in"||s==="mermaid-zoom-out"||s==="mermaid-fit"){n.preventDefault();const o=i.closest('[data-markdown="mermaid-block"]'),l=jt(o);s==="mermaid-zoom-in"?l?.zoomIn():s==="mermaid-zoom-out"?l?.zoomOut():l?.fit();return}if(s==="mermaid-download"){const o=i.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]'),l=o?.getAttribute("data-md-original-svg")??o?.innerHTML??"";l&&_e("diagram.svg",l,"image/svg+xml;charset=utf-8");return}if(s==="preview-loopback"){n.preventDefault();const o=i.getAttribute("data-md-url")??"";o&&e.onPreviewLoopback?.(o);return}};return t.addEventListener("click",r),()=>t.removeEventListener("click",r)},Te=(t,e,r)=>{let n=0;for(const i of t){const s=n+i.data.length;if(e<s||e===s&&r==="left")return{node:i,offset:Math.max(0,e-n)};n=s}const a=t.at(-1);return a?{node:a,offset:a.data.length}:null},lr=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),Pe=Array.from(lr).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),cr=t=>gt(t),dr=t=>ht(t),mr=t=>{let e;try{e=new URL(t.trim())}catch{return null}if(e.protocol!=="file:"||e.hostname&&e.hostname!=="localhost")return null;try{const r=decodeURIComponent(e.pathname);return/^\/[A-Za-z]:\//.test(r)?r.slice(1):r.startsWith("/")?r:null}catch{return null}},ce=t=>{let e=(t||"").trim();return e?((e.startsWith("`")&&e.endsWith("`")||e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1).trim()),e=e.replace(/[.,;!?]+$/g,""),e.endsWith(")")&&!e.includes("(")&&(e=e.slice(0,-1)),e.endsWith("]")&&!e.includes("[")&&(e=e.slice(0,-1)),e):""},se=t=>{let e=ce(t);if(!e)return"";const r=e.indexOf(";");r>=0&&(e=e.slice(0,r)),e=e.replace(/#.*$/,"");const n=e.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);n&&(e=n[1]??e);const a=Pe.length>0?e.match(new RegExp(`^(.*(?:/|^)(${Pe})):.*$`,"i")):null;return a&&(e=a[1]??e),ce(e)},Xe=t=>{const e=ce(t);if(!e)return null;const r=e.indexOf(";"),n=r>=0?ce(e.slice(0,r)):e;if(!n)return null;const a=n.match(/^(.*?):(\d+)-(\d+)$/);if(a){const l=se(a[1]??""),c=Number.parseInt(a[2]??"",10),d=Number.parseInt(a[3]??"",10);return!l||!Number.isFinite(c)||!Number.isFinite(d)||d<c?null:{path:l,line:c,endLine:d}}const i=n.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(i){const l=se(i[1]??""),c=Number.parseInt(i[2]??"",10),d=i[3]?Number.parseInt(i[3],10):void 0;return!l||!Number.isFinite(c)?null:{path:l,line:c,column:Number.isFinite(d??Number.NaN)?d:void 0}}const s=n.match(/^(.*?):(\d+)(?::(\d+))?$/);if(s){const l=se(s[1]??""),c=Number.parseInt(s[2]??"",10),d=s[3]?Number.parseInt(s[3],10):void 0;return!l||!Number.isFinite(c)?null:{path:l,line:c,column:Number.isFinite(d??Number.NaN)?d:void 0}}const o=se(n);return o?{path:o}:null},ue=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+(?:-\d+)?(?::\d+)?)?/g,Ge=()=>{const t=V.c(4),e=bt();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=ye(!1),t[0]=r):r=t[0];const n=r;let a;t[1]===Symbol.for("react.memo_cache_sentinel")?(a=ye(!0),t[1]=a):a=t[1];const i=a;let s;return t[2]!==e?.currentTheme?(s=e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?i:n),t[2]=e?.currentTheme,t[3]=s):s=t[3],s},Ye=t=>{const e=V.c(4),{containerRef:r,enabled:n}=t;let a,i;e[0]!==r||e[1]!==n?(a=()=>{if(n===!1)return;const s=r.current;if(!s)return;const o=Fr;return s.addEventListener("click",o),()=>{s.removeEventListener("click",o)}},i=[r,n],e[0]=r,e[1]=n,e[2]=a,e[3]=i):(a=e[2],i=e[3]),_.useEffect(a,i)},Y={download:!0,copy:!0,showPanZoomControls:!0},Je=!0,ur=t=>{const e=t.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return e?t.slice(e[0].length):t},Fe='[data-openchamber-file-link="true"]',Qe="data-openchamber-block-path-token",et=`[${Qe}]`,G="data-openchamber-block-paths-scanned",pr=2e5,fr=4,hr=1e3,gr=200,br=80,wr=40,Ie=160,B=new Map;let le=0;const Oe=[],yr=()=>ze()?gr:hr,vr=()=>ze()?wr:br,Ar=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),ge=t=>cr(t),kr=t=>dr(t),Er=(t,e)=>Et(t,e),Cr=t=>{const e=t.split("/").filter(Boolean).pop()??"";return!e||e.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(e)},tt=t=>{if(!t||t.startsWith("--")||t.includes("://")||/[<>]/.test(t)||/\s{2,}/.test(t))return!1;const e=ge(t),r=e.split("/").filter(Boolean).pop()??e;if(!r||r==="."||r==="..")return!1;const n=r.toLowerCase();return Ar.has(n)||n.startsWith(".")&&n.length>1?!0:Cr(e)},rt=t=>{const e=Xe(t);return e?tt(e.path):!1},Sr=t=>{const e=t.querySelectorAll(et);for(const n of Array.from(e))n.replaceWith(t.ownerDocument.createTextNode(n.textContent??""));const r=t.querySelectorAll(`code[${G}]`);for(const n of Array.from(r))n.removeAttribute(G),n.normalize()},pe=t=>{if(t.tagName.toLowerCase()==="a"){const e=t.getAttribute("href")?.trim(),r=e?mr(e):null;if(r)return r;if(e&&rt(e))return e}return(t.textContent||"").trim()},Lr=t=>{const e=t.querySelectorAll("pre code");if(e.length===0)return;const r=t.ownerDocument;if(r)for(const n of Array.from(e)){if(n.getAttribute(G)==="true")continue;if((n.textContent??"").length>pr){n.setAttribute(G,"true");continue}const a=r.createTreeWalker(n,NodeFilter.SHOW_TEXT),i=[];let s=a.nextNode();for(;s;){const d=s;d.parentElement?.closest("[data-md-code-line-number]")||i.push(d),s=a.nextNode()}const o=Ze(n);if(!o.includes(".")){n.setAttribute(G,"true");continue}ue.lastIndex=0;const l=[];let c=ue.exec(o);for(;c;){const d=c[0];d&&rt(d)&&l.push({start:c.index,end:c.index+d.length,raw:d}),c=ue.exec(o)}for(const{start:d,end:f,raw:m}of l.reverse()){const u=Te(i,d,"right"),g=Te(i,f,"left");if(!u||!g)continue;const k=r.createRange();k.setStart(u.node,u.offset),k.setEnd(g.node,g.offset);const E=r.createElement("span");E.setAttribute(Qe,"true"),E.textContent=m,k.deleteContents(),k.insertNode(E)}n.setAttribute(G,"true")}},fe=(t,e)=>{const r=Xe(t);if(!r||!tt(r.path))return null;const n=kr(r.path)?ge(r.path):Er(e,r.path);return n?{...r,resolvedPath:n}:null},Mr=t=>{const e=ge(t);if(!e)return Promise.resolve(!1);const r=B.get(e);if(r)return B.delete(e),B.set(e,r),r;const n=new Promise(i=>{const s=()=>{le+=1,Mt(`/api/fs/stat?path=${encodeURIComponent(e)}&optional=true`,{method:"GET",cache:"no-store"}).then(async o=>{if(!o.ok){i(!1);return}const l=await o.json().catch(()=>null);i(l?.exists!==!1)}).catch(()=>i(!1)).finally(()=>{le=Math.max(0,le-1),Oe.shift()?.()})};if(le<fr){s();return}Oe.push(s)}),a=yr();for(;B.size>=a;){const i=B.keys().next().value;if(typeof i!="string")break;B.delete(i)}return B.set(e,n),n},Nr=(t,e)=>t||kt(t,e),nt=t=>{const e=V.c(7),{containerRef:r,effectiveDirectory:n,editor:a,preferRuntimeEditor:i,enabled:s}=t,o=_.useRef(null);let l,c;e[0]!==r||e[1]!==a||e[2]!==n||e[3]!==s||e[4]!==i?(l=()=>{const d=r.current;if(!d)return;let f=!1;const m=vr(),u=s&&!Nt(),g=Ir,k=()=>{const w=d.querySelectorAll(Fe);for(const b of Array.from(w))g(b);Sr(d)};if(!u){k();return}const E=w=>{const b=w;if(o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),typeof window>"u"){v();return}o.current=window.setTimeout(()=>{o.current=null,window.requestAnimationFrame(()=>{f||v()})},b)},v=()=>{u&&Lr(d);const w=d.querySelectorAll(`[data-markdown="inline-code"], a, ${et}`);let b=0;for(const h of Array.from(w)){const y=pe(h),A=fe(y,n);if(g(h),!A||b>=m)continue;b=b+1,(St()&&Lt()&&!be(A.resolvedPath,n)?Promise.resolve(!0):Mr(A.resolvedPath)).then(I=>{if(f||!I||!d.contains(h))return;const O=pe(h),T=fe(O,n);!T||T.resolvedPath!==A.resolvedPath||(h.setAttribute("data-openchamber-file-link","true"),h.setAttribute("data-openchamber-file-ref",O),h.setAttribute("data-openchamber-file-path",T.resolvedPath),h.setAttribute("title","Open file"),h.tagName.toLowerCase()!=="a"&&(h.setAttribute("role","button"),h.setAttribute("tabindex","0")))})}},S=async w=>{const b=w.getAttribute("data-openchamber-file-ref")||pe(w),h=fe(b,n);if(!h)return;const y=Nr(n,h.resolvedPath);if(i&&a){a.openFile(h.resolvedPath,Number.isFinite(h.line??Number.NaN)?Math.max(1,Math.trunc(h.line)):void 0,Number.isFinite(h.column??Number.NaN)?Math.max(1,Math.trunc(h.column)):void 0);return}be(h.resolvedPath,n)||await At(h.resolvedPath,n);const A=X.getState();Number.isFinite(h.line??Number.NaN)?A.openContextFileAtLine(y,h.resolvedPath,Math.max(1,Math.trunc(h.line)),Number.isFinite(h.column??Number.NaN)?Math.max(1,Math.trunc(h.column)):1):A.openContextFile(y,h.resolvedPath)},M=w=>{const b=w.target;if(!(b instanceof Element))return;const h=b.closest(Fe);h instanceof HTMLElement&&(w.preventDefault(),w.stopPropagation(),S(h))},p=w=>{if(w.key!=="Enter"&&w.key!==" ")return;const b=w.target;!(b instanceof HTMLElement)||b.getAttribute("data-openchamber-file-link")!=="true"||(w.preventDefault(),w.stopPropagation(),S(b))};E(Ie);const C=new MutationObserver(()=>{E(Ie)});return C.observe(d,{childList:!0,subtree:!0}),d.addEventListener("click",M),d.addEventListener("keydown",p),()=>{f=!0,o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),o.current=null,C.disconnect(),d.removeEventListener("click",M),d.removeEventListener("keydown",p)}},c=[r,a,n,i,s],e[0]=r,e[1]=a,e[2]=n,e[3]=s,e[4]=i,e[5]=l,e[6]=c):(l=e[5],c=e[6]),_.useEffect(l,c)},ot=t=>{const e=V.c(7),{containerRef:r,onShowPopup:n,enableFullscreen:a,enablePanZoom:i,allowMermaidWheelEvents:s}=t;let o,l;e[0]!==s||e[1]!==r||e[2]!==a||e[3]!==i||e[4]!==n?(o=()=>{const c=r.current;if(!c)return;const d=m=>{if(!a||!n)return;const u=m.target;if(!(u instanceof Element)||u.closest('button, a, [role="button"]'))return;const g=u.closest(te);if(!g)return;if(g instanceof HTMLElement&&g.hasAttribute("data-mermaid-suppress-click")){g.removeAttribute("data-mermaid-suppress-click");return}const E=Array.from(c.querySelectorAll(te)).indexOf(g);if(E<0)return;const v=g instanceof HTMLElement?g.getAttribute("data-md-source"):null;if(!v||v.trim().length===0)return;const S=`Diagram ${E+1}`;n({open:!0,title:S,content:"",metadata:{tool:"mermaid-preview",filename:S},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(v)}`,source:v,filename:S}})},f=m=>{if(s||(m.ctrlKey||m.metaKey)&&i)return;const u=m.target;!(u instanceof Element)||!u.closest(te)||m.stopPropagation()};return c.addEventListener("click",d),c.addEventListener("wheel",f,{capture:!0,passive:!0}),()=>{c.removeEventListener("click",d),c.removeEventListener("wheel",f,!0)}},l=[s,r,a,i,n],e[0]=s,e[1]=r,e[2]=a,e[3]=i,e[4]=n,e[5]=o,e[6]=l):(o=e[5],l=e[6]),_.useEffect(o,l)},z=new Map,Rr=100,xr=(t,e)=>{const r=z.get(t);if(r)return z.delete(t),z.set(t,r),r;const n=e();if(z.set(t,n),z.size>Rr){const a=z.keys().next().value;a&&z.delete(a)}return n},_r=t=>({bg:t.colors.surface.elevated,fg:t.colors.surface.foreground,line:t.colors.interactive.border,accent:t.colors.primary.base,muted:t.colors.surface.mutedForeground,surface:t.colors.surface.muted,border:t.colors.interactive.border,transparent:!0,font:"system-ui, sans-serif"}),it=(t,e,r,n=Y)=>{const{t:a}=wt(),i=_.useMemo(()=>({copy:a("markdownRenderer.code.actions.copyTitle"),copied:a("markdownRenderer.code.actions.copiedTitle"),enableCodeWrap:a("markdownRenderer.code.actions.enableWrapTitle"),disableCodeWrap:a("markdownRenderer.code.actions.disableWrapTitle"),copyTable:a("markdownRenderer.table.actions.copyTitle"),downloadTable:a("markdownRenderer.table.actions.downloadTitle"),copyDiagram:a("markdownRenderer.mermaid.actions.copySourceTitle"),downloadDiagram:a("markdownRenderer.mermaid.actions.downloadSvgTitle"),zoomInDiagram:a("markdownRenderer.mermaid.actions.zoomInTitle"),zoomOutDiagram:a("markdownRenderer.mermaid.actions.zoomOutTitle"),resetDiagramView:a("markdownRenderer.mermaid.actions.resetViewTitle"),previewLabel:a("terminalView.preview.open"),previewTitle:a("terminalView.preview.openTitle")}),[a]),s=X(c=>c.codeBlockLineWrap),o=X(c=>c.setCodeBlockLineWrap),l=_.useCallback(()=>{o(!X.getState().codeBlockLineWrap)},[o]);return _.useMemo(()=>{const c=_r(t),d=X.getState().mermaidRenderingMode,f=t.metadata?.id??"theme";return{labels:i,mermaidControls:n,codeBlockLineWrap:s,deferCodeLineNumberSync:e,onToggleCodeBlockLineWrap:l,renderMermaid:u=>xr(`${f}:${d}:${u}`,()=>{try{return d==="ascii"?{ascii:ct(u)}:{svg:dt(u,c)}}catch{return{}}}),onPreviewLoopback:r}},[t,i,n,s,e,l,r])},at=t=>{const e=V.c(34),{containerRef:r,text:n,streaming:a,imageMode:i,syntaxVars:s,ctx:o}=t,l=i===void 0?"inline":i;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0],_.useEffect(Or,c);const d=_.useRef(null);let f;e[1]!==r?(f=()=>{const y=r.current;if(y){if(!d.current){if(!$(y))return;d.current=Yt(y);return}d.current.refresh()}},e[1]=r,e[2]=f):f=e[2];const m=f;let u,g;e[3]!==r||e[4]!==o||e[5]!==l||e[6]!==m||e[7]!==n?(u=()=>{const y=r.current,A=y?.querySelector("[data-markdown-content]")??y;if(A&&n&&A.childNodes.length===0){const L=document.createElement("div");L.setAttribute("data-md-block",""),L.style.display="contents",L.innerHTML=Rt(n,l),xe(L,o),A.appendChild(L),$(L)&&m()}},g=[r,n,l,o,m],e[3]=r,e[4]=o,e[5]=l,e[6]=m,e[7]=n,e[8]=u,e[9]=g):(u=e[8],g=e[9]),_.useLayoutEffect(u,g);let k,E;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=()=>()=>{d.current?.cleanup(),d.current=null},E=[],e[10]=k,e[11]=E):(k=e[10],E=e[11]),_.useEffect(k,E);let v,S;e[12]!==r||e[13]!==o||e[14]!==l||e[15]!==m||e[16]!==a||e[17]!==n?(v=()=>{const y=r.current;if(!y)return;const A=y.querySelector("[data-markdown-content]")??y;let L=!0;return xt(n,a,l).then(F=>{if(!L)return;const I=Array.from(A.children);F.forEach((N,P)=>{let R=I[P];if(R||(R=document.createElement("div"),R.setAttribute("data-md-block",""),R.style.display="contents",A.appendChild(R)),R.getAttribute("data-md-id")===N.id)return;const W=document.createElement("div");W.innerHTML=N.html,xe(W,o);const J=$(R),H=$(W);lt(R,W,{childrenOnly:!0,onBeforeElUpdated:Dr}),R.setAttribute("data-md-id",N.id),(J||H||$(R))&&m()});const O=$(A);let T=!1;for(let N=I.length-1;N>=F.length;N=N-1,N){const P=I[N];P&&$(P)&&(T=!0),P?.remove()}(T||I.length>F.length&&O)&&m()}),()=>{L=!1}},S=[r,n,a,l,o,m],e[12]=r,e[13]=o,e[14]=l,e[15]=m,e[16]=a,e[17]=n,e[18]=v,e[19]=S):(v=e[18],S=e[19]),_.useEffect(v,S);let M,p;e[20]!==r||e[21]!==o?(M=()=>{const y=r.current;if(y)return sr(y,o)},p=[r,o],e[20]=r,e[21]=o,e[22]=M,e[23]=p):(M=e[22],p=e[23]),_.useEffect(M,p);let C,w;e[24]!==r||e[25]!==s?(C=()=>{const y=r.current,A=y?.querySelector("[data-markdown-content]")??y;if(A)for(const[L,F]of Object.entries(s))A.style.setProperty(L,F)},w=[r,s],e[24]=r,e[25]=s,e[26]=C,e[27]=w):(C=e[26],w=e[27]),_.useEffect(C,w);let b,h;e[28]!==r||e[29]!==o.codeBlockLineWrap||e[30]!==o.deferCodeLineNumberSync||e[31]!==o.labels?(b=()=>{const y=r.current,A=y?.querySelector("[data-markdown-content]")??y;A&&(o.deferCodeLineNumberSync||Qt(A,o.codeBlockLineWrap,o.labels))},h=[r,o.codeBlockLineWrap,o.deferCodeLineNumberSync,o.labels],e[28]=r,e[29]=o.codeBlockLineWrap,e[30]=o.deferCodeLineNumberSync,e[31]=o.labels,e[32]=b,e[33]=h):(b=e[32],h=e[33]),_.useEffect(b,h)},st=t=>t==="tool"?"markdown-content markdown-tool":t==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",Tr=t=>{const e=V.c(32),{content:r,part:n,messageId:a,isAnimated:i,skipFadeIn:s,className:o,isStreaming:l,disableStreamAnimation:c,variant:d,onShowPopup:f,enableFileReferences:m}=t,u=i===void 0?!0:i,g=s===void 0?!1:s,k=l===void 0?!1:l,E=c===void 0?!1:c,v=d===void 0?"assistant":d,S=m===void 0?!0:m;we("ui.markdown_renderer.render"),k&&we("ui.markdown_renderer.render.streaming"),Ct("ui.markdown_renderer.content_len",r.length);const M=Ge(),{editor:p,runtime:C}=We(),w=_.useRef(null),b=qe()??"",h=X(Wr);let y;e[0]!==b||e[1]!==h?(y=Z=>{b&&h(b,Z)},e[0]=b,e[1]=h,e[2]=y):y=e[2];const A=y,L=k&&!E;let F;e[3]!==f?(F={containerRef:w,onShowPopup:f,enableFullscreen:Je,enablePanZoom:Y.showPanZoomControls},e[3]=f,e[4]=F):F=e[4],ot(F);const I=S&&!k;let O;e[5]!==p||e[6]!==b||e[7]!==C.isVSCode||e[8]!==I?(O={containerRef:w,effectiveDirectory:b,editor:p,preferRuntimeEditor:C.isVSCode,enabled:I},e[5]=p,e[6]=b,e[7]=C.isVSCode,e[8]=I,e[9]=O):O=e[9],nt(O);let T;e[10]===Symbol.for("react.memo_cache_sentinel")?(T={containerRef:w},e[10]=T):T=e[10],Ye(T);let N;e[11]!==M?(N=$e(M),e[11]=M,e[12]=N):N=e[12];const P=N,R=it(M,L,b?A:void 0,Y),W=`markdown-${n?.id?`part-${n.id}`:`message-${a}`}`,J=v==="assistant"?"label":"inline";let H;e[13]!==r||e[14]!==R||e[15]!==L||e[16]!==P||e[17]!==J?(H={containerRef:w,text:r,streaming:L,imageMode:J,syntaxVars:P,ctx:R},e[13]=r,e[14]=R,e[15]=L,e[16]=P,e[17]=J,e[18]=H):H=e[18],at(H);let K;e[19]!==o?(K=Be("break-words w-full min-w-0",o),e[19]=o,e[20]=K):K=e[20];let j;e[21]!==v?(j=st(v),e[21]=v,e[22]=j):j=e[22];let U;e[23]!==j?(U=ee.jsx("div",{className:j,"data-markdown-content":!0}),e[23]=j,e[24]=U):U=e[24];let oe;e[25]!==K||e[26]!==U?(oe=ee.jsx("div",{className:K,ref:w,children:U}),e[25]=K,e[26]=U,e[27]=oe):oe=e[27];const ie=oe;if(u){let Z;return e[28]!==W||e[29]!==ie||e[30]!==g?(Z=ee.jsx(yt,{skipAnimation:g,children:ie},W),e[28]=W,e[29]=ie,e[30]=g,e[31]=Z):Z=e[31],Z}return ie},qo=_.memo(Tr,(t,e)=>t.content===e.content&&t.isStreaming===e.isStreaming&&t.disableStreamAnimation===e.disableStreamAnimation&&t.variant===e.variant&&t.isAnimated===e.isAnimated&&t.skipFadeIn===e.skipFadeIn&&t.className===e.className&&t.messageId===e.messageId&&t.onShowPopup===e.onShowPopup&&t.enableFileReferences===e.enableFileReferences&&t.part?.id===e.part?.id),Pr=t=>{const e=V.c(29),{content:r,className:n,variant:a,disableLinkSafety:i,stripFrontmatter:s,onShowPopup:o,mermaidControls:l,allowMermaidWheelEvents:c,enableFileReferences:d}=t,f=a===void 0?"assistant":a,m=s===void 0?!1:s,u=l===void 0?Y:l,g=c===void 0?!1:c,k=d===void 0?!0:d,{editor:E,runtime:v}=We(),S=Ge(),M=_.useRef(null),p=qe()??"";let C;e[0]!==r||e[1]!==m?(C=m?ur(r):r,e[0]=r,e[1]=m,e[2]=C):C=e[2];const w=C;let b;e[3]!==g||e[4]!==u.showPanZoomControls||e[5]!==o?(b={containerRef:M,onShowPopup:o,enableFullscreen:Je,enablePanZoom:u.showPanZoomControls,allowMermaidWheelEvents:g},e[3]=g,e[4]=u.showPanZoomControls,e[5]=o,e[6]=b):b=e[6],ot(b);let h;e[7]!==E||e[8]!==p||e[9]!==k||e[10]!==v.isVSCode?(h={containerRef:M,effectiveDirectory:p,editor:E,preferRuntimeEditor:v.isVSCode,enabled:k},e[7]=E,e[8]=p,e[9]=k,e[10]=v.isVSCode,e[11]=h):h=e[11],nt(h);const y=!i;let A;e[12]!==y?(A={containerRef:M,enabled:y},e[12]=y,e[13]=A):A=e[13],Ye(A);let L;e[14]!==S?(L=$e(S),e[14]=S,e[15]=L):L=e[15];const F=L,I=it(S,!1,void 0,u);let O;e[16]!==I||e[17]!==w||e[18]!==F?(O={containerRef:M,text:w,streaming:!1,syntaxVars:F,ctx:I},e[16]=I,e[17]=w,e[18]=F,e[19]=O):O=e[19],at(O);let T;e[20]!==n?(T=Be("break-words w-full min-w-0",n),e[20]=n,e[21]=T):T=e[21];let N;e[22]!==f?(N=st(f),e[22]=f,e[23]=N):N=e[23];let P;e[24]!==N?(P=ee.jsx("div",{className:N,"data-markdown-content":!0}),e[24]=N,e[25]=P):P=e[25];let R;return e[26]!==T||e[27]!==P?(R=ee.jsx("div",{className:T,ref:M,children:P}),e[26]=T,e[27]=P,e[28]=R):R=e[28],R},$o=_.memo(Pr,(t,e)=>{const r=t.mermaidControls??Y,n=e.mermaidControls??Y;return t.content===e.content&&t.variant===e.variant&&t.className===e.className&&t.disableLinkSafety===e.disableLinkSafety&&t.stripFrontmatter===e.stripFrontmatter&&t.onShowPopup===e.onShowPopup&&r.download===n.download&&r.copy===n.copy&&r.showPanZoomControls===n.showPanZoomControls&&t.allowMermaidWheelEvents===e.allowMermaidWheelEvents&&t.enableFileReferences===e.enableFileReferences});function Fr(t){if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.altKey||t.shiftKey)return;const e=t.target;if(!(e instanceof Element))return;const r=e.closest("a[href]");if(!(r instanceof HTMLAnchorElement)||r.getAttribute("data-openchamber-file-link")==="true")return;const n=r.getAttribute("href")??"";De(n)&&(t.preventDefault(),t.stopPropagation(),vt(n))}function Ir(t){t.removeAttribute("data-openchamber-file-link"),t.removeAttribute("data-openchamber-file-ref"),t.removeAttribute("data-openchamber-file-path"),t.getAttribute("title")==="Open file"&&t.removeAttribute("title"),t.tagName.toLowerCase()!=="a"&&(t.removeAttribute("role"),t.removeAttribute("tabindex"))}function Or(){Pt()}function Dr(t,e){return!t.isEqualNode(e)}function Wr(t){return t.openContextPreview}export{qo as MarkdownRenderer,$o as SimpleMarkdownRenderer};
@@ -1,4 +0,0 @@
1
- import{R as s,j as r}from"./vendor-react-BUCujlKS.js";import{m as it,u as re,r as Ae,o as ot}from"./index-DzriVon2.js";import{c as at,s as lt,P as ct,C as ut}from"./shikiHighlight-DXYW46vW.js";import{f as mt,y as O,c0 as dt,ak as pt,b as $e,a4 as ft,a0 as ht,V as wt,aV as gt,L as vt,eL as St,gs as xt,l as ze,eN as yt,aa as We,fO as bt,cR as Oe,eP as jt,eQ as Ct,m as Mt,gt as Tt,aU as _e,aX as ne,aY as se,aR as Be,B as J,I,aZ as ie,aT as Ge,aQ as Q,g as Nt,bU as kt,ac as Et,bQ as Pt,gu as Vt}from"./useAppFontEffects-CbzHzFop.js";import{u as Dt,n as Rt}from"./useInlineCommentController-CegKdDXi.js";import{b as Ft}from"./CodeMirrorCommentWidgets-DAvopJvy.js";import{getResolvedShikiTheme as It}from"./appThemeRegistry-BK0dHKa6.js";import{E as Lt}from"./vendor-codemirror-view-CiLROUVV.js";import{R as At}from"./runtimeEndpointReset-BMBRhIbf.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-commands-B7H_j0iU.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-search-BmS-GmcX.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-BYlZTzrw.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-BO1wRpaN.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-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-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-w3c-keyname-Vcq4gwWv.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-CiAYDJXN.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-zod-adaMkgkm.js";import"./registerCustomTheme-BBXUCRnG.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.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";const y=m=>{if(!m)return"";const l=m.replace(/\\/g,"/");return l==="/"?"/":l.replace(/\/+$/,"")},oe=(m,l)=>{const a=y(m),t=l.replace(/\\/g,"/").replace(/^\/+/,"").replace(/\/+$/,"");return!a||a==="/"?`/${t}`:`${a}/${t}`},$t=(m,l,a)=>oe(oe(oe(m,".opencode"),"plans"),`${l}-${a}.md`),zt=(m,l)=>`~/.opencode/plans/${m}-${l}.md`,Wt=(m,l)=>{const a=m.trim();return a.startsWith("~")?a==="~"?l||a:(a.startsWith("~/")||a.startsWith("~\\"))&&l?`${l}${a.slice(1)}`:a:a},Ot=(m,l)=>{const a=y(l.currentDirectory),t=y(l.homeDirectory),w=y(m);return a&&w.startsWith(a+"/")?w.slice(a.length+1):t&&w===t?"~":t&&w.startsWith(t+"/")?`~${w.slice(t.length)}`:w},_t=(m,l,a)=>{const t=y(m.trim());if(!t)return null;const w=a?l.find(g=>g.id===a)??null:null;if(w?.path){const g=y(w.path);if(t===g||t.startsWith(`${g}/`))return{id:w.id,path:w.path}}const P=l.filter(g=>{const N=y(g.path);return t===N||t.startsWith(`${N}/`)}).sort((g,N)=>y(N.path).length-y(g.path).length)[0];return P?{id:P.id,path:P.path}:null},On=({targetPath:m=null,projectPlanId:l=null,onNavigatedToChat:a})=>{const{t}=mt(),w=O(e=>e.currentSessionId),P=O(e=>e.createSession),g=O(e=>e.initializeNewOpenChamberSession),N=O(e=>e.sendMessage),ae=O(e=>e.setCurrentSession),le=dt(),L=it(e=>e.homeDirectory),ce=pt(e=>e.planModeEnabled),ue=$e(e=>e.projects),me=$e(e=>e.activeProjectId),de=ft(e=>e.directories),pe=ht()??"",fe=re(e=>e.setActiveMainTab),he=re(e=>e.setSessionSwitcherOpen),V=wt(),{isMobile:we}=gt(),{currentTheme:_}=vt(),v=s.useMemo(()=>w?le.find(e=>e.id===w)??null:null,[w,le]),j=s.useMemo(()=>{const e=typeof v?.directory=="string"?v.directory:"";return y(e||"")},[v?.directory]),ge=s.useMemo(()=>y(pe||j),[pe,j]),h=s.useMemo(()=>_t(ge,ue,me),[me,ge,ue]),B=s.useMemo(()=>h?de.get(h.path)?.isGitRepo===!0:!1,[h,de]),[k,D]=s.useState(null),[ve,Se]=s.useState(!1),[d,C]=s.useState(null),[A,Y]=s.useState(null),xe=St(e=>e.savePlan),Ue=!!d||!!A,X=s.useMemo(()=>!d||!j||!L?d:Ot(d,{currentDirectory:j,homeDirectory:L}),[d,j,L]),[f,b]=s.useState(""),{isPlaying:G,play:He,stop:Ke}=xt(),Je=ze(e=>e.showMessageTTSButtons),[ye,$]=s.useState(null),Z=s.useMemo(()=>X&&X.split("/").pop()||t("planView.file.defaultName"),[X,t]),q=s.useMemo(()=>f.trim()?yt(f,t("planView.title.default")).title:t("planView.title.default"),[f,t]),U=s.useMemo(()=>q.trim()||t("planView.title.default"),[q,t]),[Qe,E]=s.useState(!1),[Ye,be]=s.useState(!1),[H,je]=s.useState("edit"),z=s.useRef(null),[o,S]=s.useState(null),Ce=s.useRef(null),Xe=s.useRef(null),Me="openchamber:plan:md-viewer-mode";s.useEffect(()=>{try{const e=localStorage.getItem(Me);if(!e)return;const i=JSON.parse(e);(i==="preview"||i==="edit")&&je(i)}catch{}},[]);const Ze=s.useCallback(e=>{je(e);try{localStorage.setItem(Me,JSON.stringify(e))}catch{}},[]),R=s.useRef(!1),M=s.useRef(null),[Te,F]=s.useState(!1);s.useEffect(()=>{const e=()=>{R.current=!1,M.current=null,F(!1)};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[]);const qe=s.useCallback((e,i)=>{const u=e.split(`
2
- `),n=Math.max(1,i.start),c=Math.min(u.length,i.end);return n>c?"":u.slice(n-1,c).join(`
3
- `)},[]),et=Dt({source:"plan",fileLabel:Z,language:d&&We(d)||"markdown",getCodeForRange:e=>qe(f,Rt(e)),toStoreRange:e=>({startLine:e.start,endLine:e.end}),fromDraftRange:e=>({start:e.startLine,end:e.endLine})}),{drafts:Ne,commentText:K,setCommentText:ke,editingDraftId:ee,setSelection:Ee,saveComment:Pe,cancel:W,reset:Ve,startEdit:De,deleteDraft:Re}=et;s.useEffect(()=>{S(null),Ve()},[f,Ve]),s.useEffect(()=>{Ee(o)},[o,Ee]);const Fe=s.useCallback(()=>{S(null),W()},[W]),Ie=s.useCallback((e,i)=>{i&&S(i),Pe(e,i??o??void 0),S(null)},[o,Pe]);s.useEffect(()=>{if(!o)return;const e=u=>{const n=u.target;n.closest('[data-comment-card="true"]')||n.closest('[data-comment-input="true"]')||n.closest(".oc-block-widget")||n.closest(".cm-gutterElement")||n.closest("[data-sonner-toast]")||n.closest("[data-sonner-toaster]")||K.trim()||(S(null),W())},i=window.setTimeout(()=>{document.addEventListener("click",e)},100);return()=>{window.clearTimeout(i),document.removeEventListener("click",e)}},[W,K,ee,we,o]);const te=re(e=>e.editorFontSize),tt=s.useMemo(()=>{const e=d?We(d):null,i=!!e&&e!=="markdown",u=[at(_,i?{syntaxColors:!1,fontSize:te}:{fontSize:te})],n=bt(d||"plan.md");return n&&u.push(n),i&&e&&u.push(lt({language:e,themeName:_.metadata.id,theme:It(_)})),u.push(Lt.lineWrapping),u},[_,d,te]);s.useEffect(()=>{if(!ce&&!m&&!l){C(null),Y(null),b(""),E(!1);return}let e=!1;const i=async n=>{if(V.files?.readFile)return(await V.files.readFile(n))?.content??"";const c=ot()?.files;if(c?.readFile)return(await c.readFile(n,{optional:!0}))?.content??"";const p=await Ae(`/api/fs/read?path=${encodeURIComponent(n)}&optional=true`,{cache:"no-store"});if(!p.ok)throw new Error(`Failed to read plan file (${p.status})`);return p.text()};return(async()=>{if(C(null),Y(null),b(""),$(null),l){if(!h)return;E(!0);try{const n=await Vt(h,l);if(e)return;if(!n){$(t("planView.error.loadFailed"));return}b(n.raw),Y(l)}catch(n){if(e)return;$(n instanceof Error?n.message:t("planView.error.loadFailed"))}finally{e||E(!1)}return}if(m){E(!0);try{const n=await i(m);if(e)return;C(m),b(n)}catch{if(e)return;C(null),b("")}finally{e||E(!1)}return}if(!v?.slug||!v?.time?.created||!j){C(null),b("");return}E(!0);try{const n=$t(j,v.time.created,v.slug),c=Wt(zt(v.time.created,v.slug),L||null);let p=null,x=null;try{x=await i(n),p=n}catch{}if(!p)try{x=await i(c),p=c}catch{}if(e)return;if(!p||x===null){C(null),b("");return}C(p),b(x)}catch{if(e)return;C(null),b("")}finally{e||E(!1)}})(),()=>{e=!0}},[h,L,ce,l,V.files,j,v?.slug,v?.time?.created,t,m]),s.useEffect(()=>{if(!d&&!A)return;const e=window.setTimeout(async()=>{$(null);try{if(A){if(!h)throw new Error(t("planView.error.writeFailed"));if(!await xe(h,A,f))throw new Error(t("planView.error.writeFailed"));return}if(!d)return;if(V.files?.writeFile){if(!(await V.files.writeFile(d,f))?.success)throw new Error(t("planView.error.writeFailed"))}else{const i=await Ae("/api/fs/write",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:d,content:f})});if(!i.ok)throw new Error(t("planView.error.writePlanFileFailed",{status:i.status}))}}catch(i){$(i instanceof Error?i.message:t("planView.error.saveFailed"))}},350);return()=>{window.clearTimeout(e)}},[f,h,A,d,V.files,xe,t]),s.useEffect(()=>()=>{z.current!==null&&window.clearTimeout(z.current)},[]);const Le=s.useCallback(()=>{fe("chat"),he(!1),a?.()},[a,fe,he]),rt=s.useCallback(async e=>{if(!h||!k)return;const i=await Oe(k.action==="improve"?"plan.improve.visible":"plan.implement.visible",{plan_title:U}),n=[{synthetic:!0,text:await Oe(k.action==="improve"?"plan.improve.instructions":"plan.implement.instructions",{plan_title:U,plan_path:d??""})}];Se(!0);try{Le();let c=null,p=h.path;if(k.target==="worktree"){if(!B)return;const T=await jt(h.path,Ct());if(!T?.id)return;c=T.id,p=T.path}else{const T=await P(void 0,h.path,null);if(!T?.id)return;c=T.id,p=T.directory??h.path,g(T.id,ze.getState().agents??[])}if(!c)return;const x=Mt.getState();x.saveSessionModelSelection(c,e.providerID,e.modelID),e.agent.trim()&&(x.saveSessionAgentSelection(c,e.agent),x.saveAgentModelForSession(c,e.agent,e.providerID,e.modelID),x.saveAgentModelVariantForSession(c,e.agent,e.providerID,e.modelID,e.variant||void 0)),ae(c,p);const st=e.runAsGoal===!0?[`Implement the plan "${U}" end-to-end${d?` (plan file: ${d})`:""}.`,"Re-read that file for full details — it is the source of truth.","",f].join(`
4
- `):null;Tt.getState().setArmed(e.runAsGoal===!0,st),await N(i,e.providerID,e.modelID,e.agent.trim()||void 0,void 0,void 0,n,e.variant||void 0),D(null)}finally{Se(!1)}},[B,f,P,h,g,k,d,Le,N,U,ae]),nt=s.useMemo(()=>Ft({drafts:Ne,editingDraftId:ee,commentText:K,onTextChange:ke,selection:o,isDragging:Te,fileLabel:Z,newWidgetId:"plan-new-comment-input",mapDraftToRange:e=>({start:e.startLine,end:e.endLine}),onSave:Ie,onCancel:Fe,onEdit:e=>{De(e),S({start:e.startLine,end:e.endLine})},onDelete:Re}),[K,Re,ee,Fe,Ie,Te,o,Ne,Z,ke,De]);return r.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden bg-background",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2 border-b border-border/40 px-3 py-1.5 flex-shrink-0",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"typography-ui-label font-medium truncate",children:q}),ye?r.jsx("div",{className:"typography-micro text-[color:var(--status-error)] truncate",title:ye,children:t("planView.error.saveFailed")}):null]}),Ue?r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsxs(_e,{children:[r.jsxs(ne,{children:[r.jsx(se,{asChild:!0,children:r.jsx(Be,{asChild:!0,children:r.jsx(J,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0","aria-label":t("planView.actions.improvePlanAria"),disabled:!f.trim(),children:r.jsx(I,{name:"loop-right-ai",className:"size-4"})})})}),r.jsx(ie,{sideOffset:8,children:t("planView.actions.improve")})]}),r.jsxs(Ge,{align:"end",children:[r.jsx(Q,{onClick:()=>D({action:"improve",target:"session"}),children:t("planView.actions.sendToNewSession")}),r.jsx(Q,{onClick:()=>D({action:"improve",target:"worktree"}),disabled:!B,children:t("planView.actions.sendToNewWorktreeSession")})]})]}),r.jsxs(_e,{children:[r.jsxs(ne,{children:[r.jsx(se,{asChild:!0,children:r.jsx(Be,{asChild:!0,children:r.jsx(J,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0","aria-label":t("planView.actions.implementPlanAria"),disabled:!f.trim(),children:r.jsx(I,{name:"code-ai",className:"size-4"})})})}),r.jsx(ie,{sideOffset:8,children:t("planView.actions.implement")})]}),r.jsxs(Ge,{align:"end",children:[r.jsx(Q,{onClick:()=>D({action:"implement",target:"session"}),children:t("planView.actions.sendToNewSession")}),r.jsx(Q,{onClick:()=>D({action:"implement",target:"worktree"}),disabled:!B,children:t("planView.actions.sendToNewWorktreeSession")})]})]}),r.jsx(ct,{currentMode:H,onToggle:()=>Ze(H==="preview"?"edit":"preview")}),H==="preview"&&Je&&r.jsxs(ne,{children:[r.jsx(se,{asChild:!0,children:r.jsx(J,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0","aria-label":t(G?"planView.tts.stopSpeaking":"planView.tts.readAloud"),onClick:()=>{G?Ke():f.trim()&&He(f)},children:G?r.jsx(I,{name:"stop",className:"h-4 w-4 text-[color:var(--status-success)]"}):r.jsx(I,{name:"volume-up",className:"h-4 w-4"})})}),r.jsx(ie,{sideOffset:8,children:t(G?"planView.tts.stopSpeaking":"planView.tts.readAloud")})]}),r.jsx(J,{variant:"ghost",size:"sm",onClick:async()=>{(await Nt(f)).ok&&(be(!0),z.current!==null&&window.clearTimeout(z.current),z.current=window.setTimeout(()=>{be(!1)},1200))},className:"h-5 w-5 p-0",title:t("planView.actions.copyPlanContents"),"aria-label":t("planView.actions.copyPlanContents"),children:Ye?r.jsx(I,{name:"check",className:"h-4 w-4 text-[color:var(--status-success)]"}):r.jsx(I,{name:"clipboard",className:"h-4 w-4"})})]}):null]}),r.jsx(At,{open:k!==null,onOpenChange:e=>{!e&&!ve&&D(null)},target:k?.target??"session",projectDirectory:h?.path??null,submitting:ve,allowRunAsGoal:!0,onConfirm:rt}),r.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:r.jsx(kt,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:Qe?r.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:t("planView.state.loading")}):r.jsx("div",{className:"relative h-full",children:r.jsx("div",{className:"h-full",children:H==="preview"?r.jsx("div",{className:"h-full overflow-auto p-3",children:r.jsx(Et,{fallback:r.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[r.jsx("div",{className:"mb-1 font-medium text-destructive",children:t("planView.error.previewUnavailable")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:t("planView.error.switchToEditMode")})]}),children:r.jsx(Pt,{content:f,className:"typography-markdown-body",enableFileReferences:!1})})}):r.jsx("div",{className:"relative h-full",ref:Xe,children:r.jsx(ut,{value:f,onChange:b,readOnly:!1,className:"h-full",extensions:tt,onViewReady:e=>{Ce.current=e},onViewDestroy:()=>{Ce.current=null},blockWidgets:nt,highlightLines:o?{start:Math.min(o.start,o.end),end:Math.max(o.start,o.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(e,i,u)=>{if(!(u instanceof MouseEvent)||u.button!==0)return!1;u.preventDefault();const n=e.state.doc.lineAt(i.from).number;if(o&&!u.shiftKey&&Math.min(o.start,o.end)===n&&Math.max(o.start,o.end)===n)return S(null),W(),R.current=!1,M.current=null,F(!1),!0;if(we&&o&&!u.shiftKey){const c=Math.min(o.start,o.end,n),p=Math.max(o.start,o.end,n);return S({start:c,end:p}),R.current=!1,M.current=null,F(!1),!0}if(R.current=!0,M.current=n,F(!0),o&&u.shiftKey){const c=Math.min(o.start,n),p=Math.max(o.end,n);S({start:c,end:p})}else S({start:n,end:n});return!0},mouseover:(e,i,u)=>{if(!(u instanceof MouseEvent)||u.buttons!==1||!R.current||M.current===null)return!1;const n=e.state.doc.lineAt(i.from).number,c=Math.min(M.current,n),p=Math.max(M.current,n);return S({start:c,end:p}),F(!0),!1},mouseup:()=>(R.current=!1,M.current=null,F(!1),!1)}}})})})})})})]})};export{On as PlanView};
@@ -1 +0,0 @@
1
- import{f as oe,R as ze,j as s,r as Pe}from"./vendor-react-BUCujlKS.js";import{u as _e,au as $e,av as Ue,aw as Ee,M as ce}from"./index-DzriVon2.js";import{a$ as Le,f as Se,h as H,aZ as Oe,w as We,x as Ae,I as G,M as Be,aY as Re,aX as Ge,aR as He,aT as Ye,aU as Ke,z as Xe,y as Ie,A as Ze,C as qe,E as Je,r as Qe}from"./useAppFontEffects-CbzHzFop.js";import{d as Me}from"./vendor-base-ui-BYlZTzrw.js";function St(){const n=oe.c(5),e=_e(Ve);let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=$e(),n[0]=t):t=n[0];const c=t;let a;n[1]!==e?(a=Ue(e),n[1]=e,n[2]=a):a=n[2];const l=a;let i;return n[3]!==l?(i={usesFramelessChrome:c,side:l},n[3]=l,n[4]=i):i=n[4],i}function Ve(n){return n.desktopWindowControlsPosition}const Fe=n=>!Number.isFinite(n)||n<=0?new Intl.NumberFormat(Le(),{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(0):new Intl.NumberFormat(Le(),{style:"currency",currency:"USD",minimumFractionDigits:n<.01?4:2,maximumFractionDigits:n<.01?4:2}).format(n),kt=n=>{const e=oe.c(144),{totalTokens:t,percentage:c,colorPercentage:a,contextLimit:l,outputLimit:i,cost:d,size:x,isMobile:m,hideIcon:o,showPercentIcon:u,className:p,valueClassName:f,percentIconClassName:g,onClick:h,pressed:w}=n,v=d===void 0?null:d,_=x===void 0?"default":x,b=m===void 0?!1:m,C=o===void 0?!1:o,S=u===void 0?!1:u,k=w===void 0?!1:w,{t:r}=Se(),[y,D]=ze.useState(!1),N=typeof a=="number"?a:c;let j,L,M,T,I,P,$,ee,F,Y;if(e[0]!==N||e[1]!==l||e[2]!==v||e[3]!==C||e[4]!==b||e[5]!==h||e[6]!==i||e[7]!==g||e[8]!==c||e[9]!==S||e[10]!==r||e[11]!==t||e[12]!==f){const z=We(c)??0,ne=Ae(N),re=ne==="critical"?"var(--status-error)":ne==="warn"?"var(--status-warning)":"var(--status-success)";j=et,L=tt;const ie=2*Math.PI*8.5,le=ie*(1-z/100);P=typeof i=="number"?Math.max(i,0):0,I=v??0;let Q;e[23]!==I?(Q=I>0&&Number.isFinite(I),e[23]=I,e[24]=Q):Q=e[24],M=Q;let W;e[25]!==r||e[26]!==t?(W=r("contextUsage.tooltip.usedTokens",{tokens:j(t)}),e[25]=r,e[26]=t,e[27]=W):W=e[27];let A;e[28]!==l||e[29]!==r?(A=r("contextUsage.tooltip.contextLimit",{tokens:j(l)}),e[28]=l,e[29]=r,e[30]=A):A=e[30];let B;e[31]!==P||e[32]!==r?(B=r("contextUsage.tooltip.outputLimit",{tokens:j(P)}),e[31]=P,e[32]=r,e[33]=B):B=e[33];let R;e[34]!==M||e[35]!==I||e[36]!==r?(R=M?[r("contextUsage.tooltip.cost",{cost:Fe(I)})]:[],e[34]=M,e[35]=I,e[36]=r,e[37]=R):R=e[37];let V;e[38]!==W||e[39]!==A||e[40]!==B||e[41]!==R?(V=[W,A,B,...R],e[38]=W,e[39]=A,e[40]=B,e[41]=R,e[42]=V):V=e[42],Y=V,T=!b&&typeof h=="function",e[43]!==C||e[44]!==b?(F=!b&&!C&&s.jsx(G,{name:"donut-chart",className:"h-4 w-4 flex-shrink-0"}),e[43]=C,e[44]=b,e[45]=F):F=e[45],e[46]!==f?($=H("font-medium inline-flex items-center gap-1.5",f),e[46]=f,e[47]=$):$=e[47],ee=S?s.jsxs(s.Fragment,{children:[s.jsxs("svg",{viewBox:"0 0 20 20",className:H("h-3.5 w-3.5 -rotate-90",g),role:"progressbar","aria-valuenow":Math.round(z),"aria-valuemin":0,"aria-valuemax":100,children:[s.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),s.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:re,strokeWidth:3,strokeLinecap:"round",strokeDasharray:ie,strokeDashoffset:le,className:"transition-[stroke-dashoffset,stroke] duration-300"})]}),s.jsxs("span",{className:"text-foreground",children:[Math.min(c,999).toFixed(1),"%"]})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:L(N),children:Math.min(c,999).toFixed(1)}),"%"]}),e[0]=N,e[1]=l,e[2]=v,e[3]=C,e[4]=b,e[5]=h,e[6]=i,e[7]=g,e[8]=c,e[9]=S,e[10]=r,e[11]=t,e[12]=f,e[13]=j,e[14]=L,e[15]=M,e[16]=T,e[17]=I,e[18]=P,e[19]=$,e[20]=ee,e[21]=F,e[22]=Y}else j=e[13],L=e[14],M=e[15],T=e[16],I=e[17],P=e[18],$=e[19],ee=e[20],F=e[21],Y=e[22];let te;e[48]!==$||e[49]!==ee?(te=s.jsx("span",{className:$,children:ee}),e[48]=$,e[49]=ee,e[50]=te):te=e[50];let K;e[51]!==te||e[52]!==F?(K=s.jsxs(s.Fragment,{children:[F,te]}),e[51]=te,e[52]=F,e[53]=K):K=e[53];const X=K,ae=_==="compact"?"typography-micro":"typography-meta";let Z;e[54]!==p||e[55]!==T||e[56]!==ae?(Z=H("app-region-no-drag flex items-center gap-1.5 select-none",ae,T?H("rounded-md px-2 py-1.5 text-foreground transition-colors","hover:bg-interactive-hover","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"):"text-muted-foreground/60",p),e[54]=p,e[55]=T,e[56]=ae,e[57]=Z):Z=e[57];const q=Z;let J;e[58]!==X||e[59]!==T||e[60]!==b||e[61]!==h||e[62]!==k||e[63]!==q||e[64]!==r?(J=T?s.jsx("button",{type:"button",className:q,"aria-label":r("contextUsage.aria.label"),"aria-pressed":k,onClick:h,children:X}):s.jsx("div",{className:q,"aria-label":r("contextUsage.aria.label"),onClick:b?()=>D(!0):void 0,children:X}),e[58]=X,e[59]=T,e[60]=b,e[61]=h,e[62]=k,e[63]=q,e[64]=r,e[65]=J):J=e[65];const U=J;if(b){let z;e[66]===Symbol.for("react.memo_cache_sentinel")?(z=()=>D(!1),e[66]=z):z=e[66];let ne;e[67]!==r?(ne=r("contextUsage.mobile.title"),e[67]=r,e[68]=ne):ne=e[68];let re;e[69]!==r?(re=r("contextUsage.mobile.usedTokens"),e[69]=r,e[70]=re):re=e[70];let ie;e[71]!==re?(ie=s.jsx("span",{className:"typography-meta text-muted-foreground",children:re}),e[71]=re,e[72]=ie):ie=e[72];let le;e[73]!==j||e[74]!==t?(le=j(t),e[73]=j,e[74]=t,e[75]=le):le=e[75];let Q;e[76]!==le?(Q=s.jsx("span",{className:"typography-meta text-foreground font-medium",children:le}),e[76]=le,e[77]=Q):Q=e[77];let W;e[78]!==ie||e[79]!==Q?(W=s.jsxs("div",{className:"flex justify-between items-center",children:[ie,Q]}),e[78]=ie,e[79]=Q,e[80]=W):W=e[80];let A;e[81]!==r?(A=r("contextUsage.mobile.contextLimit"),e[81]=r,e[82]=A):A=e[82];let B;e[83]!==A?(B=s.jsx("span",{className:"typography-meta text-muted-foreground",children:A}),e[83]=A,e[84]=B):B=e[84];let R;e[85]!==l||e[86]!==j?(R=j(l),e[85]=l,e[86]=j,e[87]=R):R=e[87];let V;e[88]!==R?(V=s.jsx("span",{className:"typography-meta text-foreground font-medium",children:R}),e[88]=R,e[89]=V):V=e[89];let de;e[90]!==B||e[91]!==V?(de=s.jsxs("div",{className:"flex justify-between items-center",children:[B,V]}),e[90]=B,e[91]=V,e[92]=de):de=e[92];let me;e[93]!==r?(me=r("contextUsage.mobile.outputLimit"),e[93]=r,e[94]=me):me=e[94];let ue;e[95]!==me?(ue=s.jsx("span",{className:"typography-meta text-muted-foreground",children:me}),e[95]=me,e[96]=ue):ue=e[96];let fe;e[97]!==j||e[98]!==P?(fe=j(P),e[97]=j,e[98]=P,e[99]=fe):fe=e[99];let pe;e[100]!==fe?(pe=s.jsx("span",{className:"typography-meta text-foreground font-medium",children:fe}),e[100]=fe,e[101]=pe):pe=e[101];let he;e[102]!==ue||e[103]!==pe?(he=s.jsxs("div",{className:"flex justify-between items-center",children:[ue,pe]}),e[102]=ue,e[103]=pe,e[104]=he):he=e[104];let xe;e[105]!==M||e[106]!==I||e[107]!==r?(xe=M?s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:r("contextUsage.mobile.cost")}),s.jsx("span",{className:"typography-meta text-foreground font-medium",children:Fe(I)})]}):null,e[105]=M,e[106]=I,e[107]=r,e[108]=xe):xe=e[108];let ge;e[109]!==r?(ge=r("contextUsage.mobile.usage"),e[109]=r,e[110]=ge):ge=e[110];let we;e[111]!==ge?(we=s.jsx("span",{className:"typography-meta text-muted-foreground",children:ge}),e[111]=ge,e[112]=we):we=e[112];let be;e[113]!==N||e[114]!==L?(be=H("typography-meta font-semibold",L(N)),e[113]=N,e[114]=L,e[115]=be):be=e[115];const De=Math.min(c,999);let ye;e[116]!==De?(ye=De.toFixed(1),e[116]=De,e[117]=ye):ye=e[117];let je;e[118]!==be||e[119]!==ye?(je=s.jsxs("span",{className:be,children:[ye,"%"]}),e[118]=be,e[119]=ye,e[120]=je):je=e[120];let ve;e[121]!==we||e[122]!==je?(ve=s.jsxs("div",{className:"flex justify-between items-center pt-1 border-t border-border/40",children:[we,je]}),e[121]=we,e[122]=je,e[123]=ve):ve=e[123];let Ne;e[124]!==W||e[125]!==de||e[126]!==he||e[127]!==xe||e[128]!==ve?(Ne=s.jsx("div",{className:"flex flex-col gap-1.5",children:s.jsxs("div",{className:"rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1",children:[W,de,he,xe,ve]})}),e[124]=W,e[125]=de,e[126]=he,e[127]=xe,e[128]=ve,e[129]=Ne):Ne=e[129];let Ce;e[130]!==y||e[131]!==ne||e[132]!==Ne?(Ce=s.jsx(Be,{open:y,onClose:z,title:ne,children:Ne}),e[130]=y,e[131]=ne,e[132]=Ne,e[133]=Ce):Ce=e[133];let ke;return e[134]!==U||e[135]!==Ce?(ke=s.jsxs(s.Fragment,{children:[U,Ce]}),e[134]=U,e[135]=Ce,e[136]=ke):ke=e[136],ke}let E;e[137]!==U?(E=s.jsx(Re,{asChild:!0,children:U}),e[137]=U,e[138]=E):E=e[138];let O;e[139]!==Y?(O=s.jsx(Oe,{children:s.jsx("div",{className:"space-y-0.5",children:Y.map(st)})}),e[139]=Y,e[140]=O):O=e[140];let se;return e[141]!==E||e[142]!==O?(se=s.jsxs(Ge,{children:[E,O]}),e[141]=E,e[142]=O,e[143]=se):se=e[143],se};function et(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:n.toFixed(1).replace(/\.0$/,"")}function tt(n){return n>=90?"text-status-error":n>=75?"text-status-warning":"text-status-success"}function st(n){return s.jsx("p",{className:"typography-micro leading-tight",children:n},n)}const nt={close:"#FF5F57",minimize:"#FEBC2E",maximize:"#28C940"},it="rgba(0, 0, 0, 0.7)",ot=n=>{const e=oe.c(3),{action:t}=n;if(t==="close"){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsx(G,{name:"close",className:"size-[10px]"}),e[0]=a):a=e[0],a}if(t==="minimize"){let a;return e[1]===Symbol.for("react.memo_cache_sentinel")?(a=s.jsx(G,{name:"subtract",className:"size-[10px]"}),e[1]=a):a=e[1],a}let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(G,{name:"add",className:"size-[10px]"}),e[2]=c):c=e[2],c},rt=n=>{const e=oe.c(18),{action:t,isMaximized:c,onActivate:a}=n,{t:l}=Se(),i=nt[t];let d;e[0]!==t||e[1]!==c||e[2]!==l?(d=l(t==="close"?"header.windowControls.close":t==="minimize"?"header.windowControls.minimize":c?"header.windowControls.restore":"header.windowControls.maximize"),e[0]=t,e[1]=c,e[2]=l,e[3]=d):d=e[3];const x=d;let m;e[4]!==t||e[5]!==a?(m=()=>a(t),e[4]=t,e[5]=a,e[6]=m):m=e[6];let o;e[7]!==i?(o={backgroundColor:i,color:it},e[7]=i,e[8]=o):o=e[8];let u;e[9]!==t?(u=s.jsx("span",{className:"flex items-center justify-center opacity-0 transition-opacity duration-75 group-hover/wctl:opacity-100",children:s.jsx(ot,{action:t})}),e[9]=t,e[10]=u):u=e[10];let p;e[11]!==o||e[12]!==u?(p=s.jsx("span",{className:"flex size-3.5 items-center justify-center rounded-full shadow-[inset_0_0_0_0.5px_rgba(0,0,0,0.28)] transition-[filter] duration-75 active:brightness-90",style:o,children:u}),e[11]=o,e[12]=u,e[13]=p):p=e[13];let f;return e[14]!==x||e[15]!==m||e[16]!==p?(f=s.jsx("button",{type:"button",onClick:m,title:x,"aria-label":x,className:"app-region-no-drag flex h-8 w-[24px] items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:p}),e[14]=x,e[15]=m,e[16]=p,e[17]=f):f=e[17],f},zt=ze.memo(function(e){const t=oe.c(25),{visible:c,position:a}=e,l=a===void 0?"right":a,{t:i}=Se(),[d,x]=ze.useState(!1),m=_e(lt);let o,u;if(t[0]!==c?(o=()=>{if(!c)return;let _=!1;ce("desktop_get_current_window_state").then(C=>{_||x(!!C?.maximized)}).catch(at);const b=C=>{const S=C.detail;x(!!S?.maximized)};return window.addEventListener("openchamber:window-maximized-changed",b),()=>{_=!0,window.removeEventListener("openchamber:window-maximized-changed",b)}},u=[c],t[0]=c,t[1]=o,t[2]=u):(o=t[1],u=t[2]),Pe.useEffect(o,u),!c)return null;const p=l==="left";let f,g,h,w;if(t[3]!==m||t[4]!==p||t[5]!==d||t[6]!==l||t[7]!==i){w=Symbol.for("react.early_return_sentinel");e:{const _=Ee(l);let b;t[12]===Symbol.for("react.memo_cache_sentinel")?(b=y=>{if(y==="close"){ce("desktop_close_current_window");return}if(y==="minimize"){ce("desktop_minimize_current_window");return}ce("desktop_toggle_current_window_maximized").then(D=>x(!!D?.maximized)).catch(ct)},t[12]=b):b=t[12];const C=b;if(m==="traffic-lights"){const y=p?"mr-1":"ml-1";let D;t[13]!==y?(D=H("app-region-no-drag group/wctl flex h-8 shrink-0 items-center",y),t[13]=y,t[14]=D):D=t[14];let N;t[15]!==i?(N=i("header.windowControls.groupAria"),t[15]=i,t[16]=N):N=t[16];let j;t[17]!==d?(j=L=>s.jsx(rt,{action:L,isMaximized:d,onActivate:C},L),t[17]=d,t[18]=j):j=t[18],w=s.jsx("div",{className:D,"aria-label":N,children:_.map(j)});break e}const S=H("app-region-no-drag inline-flex items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",p?"h-8 w-8 rounded-md":"h-12 w-11"),k=p?"app-region-no-drag mr-1 flex h-8 shrink-0 items-center":"app-region-no-drag ml-1 flex h-12 shrink-0 items-center",r=y=>y==="minimize"?s.jsx("button",{type:"button",className:S,onClick:dt,title:i("header.windowControls.minimize"),"aria-label":i("header.windowControls.minimize"),children:s.jsx(G,{name:"subtract",className:"h-4 w-4"})},"minimize"):y==="maximize"?s.jsx("button",{type:"button",className:S,onClick:()=>{ce("desktop_toggle_current_window_maximized").then(D=>x(!!D?.maximized)).catch(mt)},title:i(d?"header.windowControls.restore":"header.windowControls.maximize"),"aria-label":i(d?"header.windowControls.restore":"header.windowControls.maximize"),children:s.jsx(G,{name:d?"fullscreen-exit":"checkbox-blank",className:"h-3.5 w-3.5"})},"maximize"):s.jsx("button",{type:"button",className:H(S,"hover:bg-status-error hover:text-status-error-foreground"),onClick:ut,title:i("header.windowControls.close"),"aria-label":i("header.windowControls.close"),children:s.jsx(G,{name:"close",className:"h-4 w-4"})},"close");f=k,t[19]!==i?(g=i("header.windowControls.groupAria"),t[19]=i,t[20]=g):g=t[20],h=_.map(r)}t[3]=m,t[4]=p,t[5]=d,t[6]=l,t[7]=i,t[8]=f,t[9]=g,t[10]=h,t[11]=w}else f=t[8],g=t[9],h=t[10],w=t[11];if(w!==Symbol.for("react.early_return_sentinel"))return w;let v;return t[21]!==f||t[22]!==g||t[23]!==h?(v=s.jsx("div",{className:f,"aria-label":g,children:h}),t[21]=f,t[22]=g,t[23]=h,t[24]=v):v=t[24],v});function lt(n){return n.desktopWindowControlsStyle}function at(){}function ct(){}function dt(){ce("desktop_minimize_current_window")}function mt(){}function ut(){ce("desktop_close_current_window")}function Dt(n){const e=oe.c(18),{children:t,variant:c,scopeProjectId:a,align:l}=n,i=c===void 0?"default":c,d=a===void 0?null:a,x=l===void 0?"start":l,m=_e(pt),o=_e(ft);let u;e[0]!==t?(u=s.jsx(He,{asChild:!0,children:t}),e[0]=t,e[1]=u):u=e[1];const p=i==="compact"?"w-[280px]":"w-[360px]";let f;e[2]!==p?(f=H("overflow-hidden p-1 max-w-[calc(100vw-32px)]",p),e[2]=p,e[3]=f):f=e[3];let g;e[4]!==m||e[5]!==d||e[6]!==o||e[7]!==i?(g=m?s.jsx(ht,{onSelect:()=>o(!1),variant:i,scopeProjectId:d}):null,e[4]=m,e[5]=d,e[6]=o,e[7]=i,e[8]=g):g=e[8];let h;e[9]!==x||e[10]!==f||e[11]!==g?(h=s.jsx(Ye,{align:x,sideOffset:6,className:f,children:g}),e[9]=x,e[10]=f,e[11]=g,e[12]=h):h=e[12];let w;return e[13]!==m||e[14]!==o||e[15]!==u||e[16]!==h?(w=s.jsxs(Ke,{open:m,onOpenChange:o,modal:!1,children:[u,h]}),e[13]=m,e[14]=o,e[15]=u,e[16]=h,e[17]=w):w=e[17],w}function ft(n){return n.setSessionDropdownOpen}function pt(n){return n.isSessionDropdownOpen}function ht(n){const e=oe.c(26),{onSelect:t,variant:c,scopeProjectId:a}=n;let l;e[0]!==a?(l={scopeProjectId:a},e[0]=a,e[1]=l):l=e[1];const i=Xe(!0,l),d=Ie(gt),x=_e(xt),{t:m}=Se();let o;e[2]!==t||e[3]!==d||e[4]!==x?(o=()=>{x("chat"),t(),d()},e[2]=t,e[3]=d,e[4]=x,e[5]=o):o=e[5];const u=o;let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=new Set,e[6]=p):p=e[6];const[f,g]=ze.useState(p);let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h=y=>{g(D=>{const N=new Set(D);return N.has(y)?N.delete(y):N.add(y),N})},e[7]=h):h=e[7];const w=h;let v,_;e[8]===Symbol.for("react.memo_cache_sentinel")?(v=H("group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),_=s.jsx(G,{name:"chat-new",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),e[8]=v,e[9]=_):(v=e[8],_=e[9]);let b;e[10]!==m?(b=m("sessions.sidebar.header.actions.newSession"),e[10]=m,e[11]=b):b=e[11];let C;e[12]!==b?(C=s.jsx("span",{className:"truncate text-[14px] font-normal leading-tight text-foreground",children:b}),e[12]=b,e[13]=C):C=e[13];let S;e[14]!==u||e[15]!==C?(S=s.jsxs(Me,{onClick:u,className:v,children:[_,C]}),e[14]=u,e[15]=C,e[16]=S):S=e[16];let k;e[17]!==f||e[18]!==i||e[19]!==t||e[20]!==m||e[21]!==c?(k=i.length===0?s.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:m("sessions.switcher.empty")}):i.map(y=>s.jsx(Te,{item:y,depth:0,variant:c,expandedParents:f,toggleParent:w,closeDropdown:t},y.node.session.id)),e[17]=f,e[18]=i,e[19]=t,e[20]=m,e[21]=c,e[22]=k):k=e[22];let r;return e[23]!==k||e[24]!==S?(r=s.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:s.jsxs("div",{className:"space-y-0.5",children:[S,k]})}),e[23]=k,e[24]=S,e[25]=r):r=e[25],r}function xt(n){return n.setActiveMainTab}function gt(n){return n.openNewSessionDraft}function Te(n){const e=oe.c(31),{item:t,depth:c,variant:a,expandedParents:l,toggleParent:i,closeDropdown:d}=n,{node:x,secondaryMeta:m}=t,o=x.session,u=x.children.length>0;let p;e[0]!==l||e[1]!==o.id?(p=l.has(o.id),e[0]=l,e[1]=o.id,e[2]=p):p=e[2];const f=p;let g;e[3]!==u||e[4]!==o.id||e[5]!==i?(g=u?()=>i(o.id):void 0,e[3]=u,e[4]=o.id,e[5]=i,e[6]=g):g=e[6];let h;e[7]!==d||e[8]!==c||e[9]!==u||e[10]!==f||e[11]!==m||e[12]!==o||e[13]!==g||e[14]!==a?(h=s.jsx(wt,{session:o,depth:c,variant:a,secondaryMeta:m,hasChildren:u,isExpanded:f,onToggleExpand:g,closeDropdown:d}),e[7]=d,e[8]=c,e[9]=u,e[10]=f,e[11]=m,e[12]=o,e[13]=g,e[14]=a,e[15]=h):h=e[15];let w;e[16]!==d||e[17]!==c||e[18]!==l||e[19]!==u||e[20]!==f||e[21]!==t.groupDirectory||e[22]!==t.projectId||e[23]!==x.children||e[24]!==m||e[25]!==i||e[26]!==a?(w=u&&f?x.children.map(_=>s.jsx(Te,{item:{node:_,projectId:t.projectId,groupDirectory:t.groupDirectory,secondaryMeta:m},depth:c+1,variant:a,expandedParents:l,toggleParent:i,closeDropdown:d},_.session.id)):null,e[16]=d,e[17]=c,e[18]=l,e[19]=u,e[20]=f,e[21]=t.groupDirectory,e[22]=t.projectId,e[23]=x.children,e[24]=m,e[25]=i,e[26]=a,e[27]=w):w=e[27];let v;return e[28]!==h||e[29]!==w?(v=s.jsxs(s.Fragment,{children:[h,w]}),e[28]=h,e[29]=w,e[30]=v):v=e[30],v}function wt(n){const e=oe.c(57),{session:t,depth:c,variant:a,secondaryMeta:l,hasChildren:i,isExpanded:d,onToggleExpand:x,closeDropdown:m}=n,{t:o}=Se(),u=Ie(jt),p=Ie(yt),f=_e(bt),g=Ze(t.id),h=qe(t.id),w=u===t.id;let v;e[0]!==t.title||e[1]!==o?(v=t.title?.trim()||o("sessions.sidebar.session.untitled"),e[0]=t.title,e[1]=o,e[2]=v):v=e[2];const _=v,b=!!t.parentID,C=h>0&&(!b||f),S=g?.type??"idle",k=S==="busy"||S==="retry",r=!k&&C&&!w;let y;e[3]!==t.time?.created||e[4]!==t.time?.updated?(y=t.time?.updated||t.time?.created||Date.now(),e[3]=t.time?.created,e[4]=t.time?.updated,e[5]=y):y=e[5];const D=y;let N;e[6]!==D?(N=Je(D),e[6]=D,e[7]=N):N=e[7];const j=N;let L;e[8]!==l?.projectLabel?(L=l?.projectLabel?.trim()||null,e[8]=l?.projectLabel,e[9]=L):L=e[9];const M=L;let T;e[10]!==l?.branchLabel?(T=l?.branchLabel?.trim()||null,e[10]=l?.branchLabel,e[11]=T):T=e[11];const I=T,P=I&&I!=="HEAD"?I:null;let $;e[12]!==m||e[13]!==w||e[14]!==t||e[15]!==p?($=()=>{if(w){m();return}const z=Qe(t);p(t.id,z??null),m()},e[12]=m,e[13]=w,e[14]=t,e[15]=p,e[16]=$):$=e[16];const ee=$;let F;e[17]!==ee?(F=z=>{if(z.target?.closest("[data-switcher-expand]")){z.preventDefault();return}ee()},e[17]=ee,e[18]=F):F=e[18];let Y;e[19]===Symbol.for("react.memo_cache_sentinel")?(Y=H("group relative flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),e[19]=Y):Y=e[19];const te=8+c*12;let K;e[20]!==te?(K={paddingLeft:te},e[20]=te,e[21]=K):K=e[21];let X;e[22]!==i||e[23]!==d||e[24]!==x||e[25]!==o||e[26]!==a?(X=a==="compact"&&i?s.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:z=>{z.preventDefault(),z.stopPropagation(),x?.()},className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":o(d?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:d?s.jsx(G,{name:"arrow-down-s",className:"h-3.5 w-3.5"}):s.jsx(G,{name:"arrow-right-s",className:"h-3.5 w-3.5"})}):null,e[22]=i,e[23]=d,e[24]=x,e[25]=o,e[26]=a,e[27]=X):X=e[27];const ae=w?"text-primary":"text-foreground";let Z;e[28]!==ae?(Z=H("truncate text-[14px] font-normal leading-tight",ae),e[28]=ae,e[29]=Z):Z=e[29];let q;e[30]!==_||e[31]!==Z?(q=s.jsx("span",{className:Z,children:_}),e[30]=_,e[31]=Z,e[32]=q):q=e[32];let J;e[33]!==X||e[34]!==q?(J=s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[X,q]}),e[33]=X,e[34]=q,e[35]=J):J=e[35];let U;e[36]!==P||e[37]!==i||e[38]!==d||e[39]!==x||e[40]!==M||e[41]!==o||e[42]!==j||e[43]!==a?(U=a==="default"?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 truncate text-muted-foreground/70 leading-tight",style:{fontSize:"calc(var(--text-ui-label) * 0.85)"},children:[i?s.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:z=>{z.preventDefault(),z.stopPropagation(),x?.()},className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":o(d?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:d?s.jsx(G,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(G,{name:"arrow-right-s",className:"h-3 w-3"})}):null,s.jsx("span",{className:"flex-shrink-0",children:j}),M?s.jsx("span",{className:"truncate",children:M}):null,P?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(G,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:P})]}):null]}):null,e[36]=P,e[37]=i,e[38]=d,e[39]=x,e[40]=M,e[41]=o,e[42]=j,e[43]=a,e[44]=U):U=e[44];let E;e[45]!==J||e[46]!==U?(E=s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[J,U]}),e[45]=J,e[46]=U,e[47]=E):E=e[47];let O;e[48]!==k||e[49]!==r||e[50]!==o?(O=k||r?s.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:k?s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse","aria-label":o("sessions.sidebar.session.status.active"),title:o("sessions.sidebar.session.status.active")}):s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--status-info)]","aria-label":o("sessions.sidebar.session.status.unread"),title:o("sessions.sidebar.session.status.unread")})}):null,e[48]=k,e[49]=r,e[50]=o,e[51]=O):O=e[51];let se;return e[52]!==K||e[53]!==E||e[54]!==O||e[55]!==F?(se=s.jsxs(Me,{onClick:F,"data-slot":"session-switcher-item",className:Y,style:K,children:[E,O]}),e[52]=K,e[53]=E,e[54]=O,e[55]=F,e[56]=se):se=e[56],se}function bt(n){return n.notifyOnSubtasks}function yt(n){return n.setCurrentSession}function jt(n){return n.currentSessionId}export{kt as C,Dt as S,zt as W,Fe as f,St as u};