@aiworker/web 1.23.0 → 1.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/dist/assets/{CodeMirrorCommentWidgets-B1Gizi3a.js → CodeMirrorCommentWidgets-teB3HmBT.js} +1 -1
  2. package/dist/assets/DiffView-DC9RX3MF.js +4 -0
  3. package/dist/assets/{DirtyBranchSwitchDialog-aig6zJjg.js → DirtyBranchSwitchDialog-DwPkzXsS.js} +1 -1
  4. package/dist/assets/FilesView-BFZkuu4O.js +13 -0
  5. package/dist/assets/{GitView-BXsS3jG6.js → GitView-B_x52MHY.js} +4 -4
  6. package/dist/assets/{JsonTreeView-D_hpXBnF.js → JsonTreeView-cmAzUTiw.js} +1 -1
  7. package/dist/assets/{LinearIssuesView-BoUiLQG1.js → LinearIssuesView-Dehh5afm.js} +1 -1
  8. package/dist/assets/{MarkdownImageGallery-B_B_a9KS.js → MarkdownImageGallery-DgNOqqhE.js} +1 -1
  9. package/dist/assets/{MarkdownRendererImpl-xgyyLiBM.js → MarkdownRendererImpl-DusmMZ_p.js} +2 -2
  10. package/dist/assets/{OnboardingScreen-DIp84OWt.js → OnboardingScreen-B8fm1H4m.js} +1 -1
  11. package/dist/assets/{PatchDiff-8p6nLJaU.js → PatchDiff-BVr7gJU0.js} +1 -1
  12. package/dist/assets/{PierreDiffViewer-DjC8nTk9.js → PierreDiffViewer-DzLt-nel.js} +1 -1
  13. package/dist/assets/PlanView-BmQUYT_z.js +5 -0
  14. package/dist/assets/SettingsView-ChWmAcZT.js +28 -0
  15. package/dist/assets/{SettingsWindow-Cpb4hM6q.js → SettingsWindow-Dy3M6ZB9.js} +1 -1
  16. package/dist/assets/{ToolOutputDialog-DfaKZXNU.js → ToolOutputDialog-cTl_eLIH.js} +6 -6
  17. package/dist/assets/{ToolPartDiffPreview-DtZLzrSK.js → ToolPartDiffPreview-C_3iYNJQ.js} +2 -2
  18. package/dist/assets/{VirtualizedFileDiff-C8i9HpTB.js → VirtualizedFileDiff-CAWthkoy.js} +4 -4
  19. package/dist/assets/WalkthroughView-C7AHOpCA.js +4 -0
  20. package/dist/assets/{computeVirtualFileMetrics-BBI7ZwrC.js → computeVirtualFileMetrics-BkiDSlTW.js} +2 -2
  21. package/dist/assets/de-DJsQr-p7.js +10 -0
  22. package/dist/assets/es-BuYMlA9g.js +16 -0
  23. package/dist/assets/fr-ePDay33C.js +14 -0
  24. package/dist/assets/index-BD8ILbxF.js +40 -0
  25. package/dist/assets/{index-jXSK5RrB.js → index-n6O3hklM.js} +1 -1
  26. package/dist/assets/index-zhgg-SDz.css +1 -0
  27. package/dist/assets/{isDiffPlainText-B_x_rVon.js → isDiffPlainText-GMdPz-71.js} +1 -1
  28. package/dist/assets/{isFilePlainText-DW_xMer1.js → isFilePlainText-BVuH1zH9.js} +1 -1
  29. package/dist/assets/ja-BzR9xOY_.js +16 -0
  30. package/dist/assets/{ko-idhXGF8j.js → ko-BEjHAm14.js} +3 -3
  31. package/dist/assets/main-BydQ1tr_.js +930 -0
  32. package/dist/assets/{main-CzdPuL0s.js → main-D3ZDQglc.js} +2 -2
  33. package/dist/assets/{markdownCore-Cn4Tyejo.js → markdownCore-Cb2MdZnV.js} +3 -3
  34. package/dist/assets/{miniChat-CCkqKOLp.js → miniChat-d01k801U.js} +2 -2
  35. package/dist/assets/{mobile-mvxTo055.js → mobile-D7VV-Ufz.js} +2 -2
  36. package/dist/assets/patchFileDiff-CdztVMz0.js +13 -0
  37. package/dist/assets/{pl-CGZWUqZJ.js → pl-rQmpxNIF.js} +3 -3
  38. package/dist/assets/pt-BR-CorbsSW-.js +16 -0
  39. package/dist/assets/renderElectronMiniChatApp-BGG9UIlh.js +2 -0
  40. package/dist/assets/renderMobileApp-BRP3J1iv.js +25 -0
  41. package/dist/assets/runtimeEndpointReset-BhT_-c52.js +41 -0
  42. package/dist/assets/scheduledTasksApi-BEuUF_cj.js +1 -0
  43. package/dist/assets/{shikiHighlight-CRl0SUC9.js → shikiHighlight-BzXUjlby.js} +1 -1
  44. package/dist/assets/surface-COKb77Ua.js +1 -0
  45. package/dist/assets/tr-CoAMXPtI.js +7 -0
  46. package/dist/assets/uk-YlAX0rRU.js +16 -0
  47. package/dist/assets/{useAppFontEffects-CPKeOpUo.js → useAppFontEffects-Cwyhjfl5.js} +153 -155
  48. package/dist/assets/useGitComparison-BCZVefdE.js +1 -0
  49. package/dist/assets/{useInlineCommentController-BiWz4AVb.js → useInlineCommentController-DDkpBEU8.js} +2 -2
  50. package/dist/assets/{useRootScrollLock-BS4-kr7P.js → useRootScrollLock-CwjoWuC4.js} +1 -1
  51. package/dist/assets/{vendor-base-ui-DdV8vhHn.js → vendor-base-ui-BY_5qla_.js} +1 -1
  52. package/dist/assets/{vendor-codemirror-language-data-Bg4AEeCr.js → vendor-codemirror-language-data-Cb1YnICj.js} +2 -2
  53. package/dist/assets/vendor-legendapp-list-BuBPBC3R.js +1 -0
  54. package/dist/assets/{vendor-zod-BPAANqvH.js → vendor-zod-B6551dwG.js} +2 -2
  55. package/dist/assets/{web-components-z7hfnS8n.js → web-components-LV3vjTxy.js} +1 -1
  56. package/dist/assets/zh-CN-DDYg0Jl7.js +16 -0
  57. package/dist/assets/zh-TW-CQKaCayr.js +16 -0
  58. package/dist/index.html +4 -4
  59. package/dist/mini-chat.html +4 -4
  60. package/dist/mobile.html +4 -4
  61. package/package.json +1 -1
  62. package/server/index.js +3 -13
  63. package/server/lib/agent-memory/runtime.js +7 -2
  64. package/server/lib/agent-memory/runtime.test.js +22 -0
  65. package/server/lib/event-stream/DOCUMENTATION.md +3 -0
  66. package/server/lib/event-stream/global-hub.js +29 -4
  67. package/server/lib/event-stream/global-hub.test.js +22 -0
  68. package/server/lib/event-stream/global-ws-bridge.js +15 -18
  69. package/server/lib/event-stream/protocol.js +21 -7
  70. package/server/lib/event-stream/runtime.js +9 -6
  71. package/server/lib/event-stream/runtime.test.js +60 -0
  72. package/server/lib/git/DOCUMENTATION.md +10 -1
  73. package/server/lib/git/routes.js +21 -8
  74. package/server/lib/git/routes.test.js +78 -0
  75. package/server/lib/git/service.js +159 -4
  76. package/server/lib/git/service.test.js +74 -0
  77. package/server/lib/github/DOCUMENTATION.md +5 -0
  78. package/server/lib/github/routes.js +2 -2
  79. package/server/lib/message-queue/DOCUMENTATION.md +7 -0
  80. package/server/lib/message-queue/runtime.js +13 -0
  81. package/server/lib/message-queue/runtime.test.js +31 -1
  82. package/server/lib/notifications/DOCUMENTATION.md +1 -1
  83. package/server/lib/notifications/emitter-runtime.js +4 -3
  84. package/server/lib/opencode/DOCUMENTATION.md +18 -4
  85. package/server/lib/opencode/env-runtime.js +5 -1
  86. package/server/lib/opencode/env-runtime.test.js +72 -0
  87. package/server/lib/opencode/feature-routes-runtime.js +15 -1
  88. package/server/lib/opencode/lifecycle.js +4 -3
  89. package/server/lib/opencode/lifecycle.test.js +29 -0
  90. package/server/lib/opencode/managed-plugin-config.js +1 -1
  91. package/server/lib/opencode/proxy.js +33 -0
  92. package/server/lib/opencode/settings-helpers.js +3 -0
  93. package/server/lib/opencode/settings-helpers.test.js +11 -1
  94. package/server/lib/opencode/settings-registry.json +3 -0
  95. package/server/lib/opencode/settings-runtime.js +36 -9
  96. package/server/lib/opencode/settings-runtime.test.js +158 -2
  97. package/server/lib/project-context/DOCUMENTATION.md +13 -3
  98. package/server/lib/project-context/runtime.js +8 -2
  99. package/server/lib/project-context/runtime.test.js +54 -0
  100. package/server/lib/projects/DOCUMENTATION.md +2 -1
  101. package/server/lib/projects/project-config.js +38 -9
  102. package/server/lib/projects/project-config.test.js +97 -0
  103. package/server/lib/projects/project-id.js +26 -0
  104. package/server/lib/relay/DOCUMENTATION.md +20 -0
  105. package/server/lib/relay/host-client.js +7 -0
  106. package/server/lib/relay/host-client.test.js +14 -0
  107. package/server/lib/scheduled-tasks/DOCUMENTATION.md +9 -1
  108. package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +28 -0
  109. package/server/lib/scheduled-tasks/runtime.js +12 -2
  110. package/server/lib/scheduled-tasks/runtime.test.js +53 -0
  111. package/server/lib/session-assist/DOCUMENTATION.md +131 -66
  112. package/server/lib/session-assist/context.js +127 -0
  113. package/server/lib/session-assist/context.test.js +132 -0
  114. package/server/lib/session-assist/prompt.js +54 -0
  115. package/server/lib/session-assist/runtime.js +111 -257
  116. package/server/lib/session-assist/runtime.test.js +203 -0
  117. package/server/lib/walkthrough/DOCUMENTATION.md +15 -5
  118. package/server/lib/walkthrough/pr-source.test.js +21 -0
  119. package/server/lib/walkthrough/pull-request.js +7 -4
  120. package/server/lib/walkthrough/pull-request.test.js +16 -0
  121. package/server/lib/walkthrough/routes.js +19 -0
  122. package/server/lib/walkthrough/routes.test.js +26 -0
  123. package/server/lib/walkthrough/sources.js +13 -2
  124. package/server/opencode-worktree-readiness.test.js +130 -0
  125. package/dist/assets/DiffView-DXjVsEOw.js +0 -4
  126. package/dist/assets/FilesView-CJdG0-wk.js +0 -17
  127. package/dist/assets/PlanView-CJTmOF6I.js +0 -5
  128. package/dist/assets/SettingsView-DD-JqIJx.js +0 -28
  129. package/dist/assets/WalkthroughView-DeKMvZlL.js +0 -4
  130. package/dist/assets/de-DCrsQ5zS.js +0 -10
  131. package/dist/assets/es-Dwv4YfH6.js +0 -16
  132. package/dist/assets/fr-BCWg4Cnx.js +0 -14
  133. package/dist/assets/index-B68h5S5B.css +0 -1
  134. package/dist/assets/index-DVwMarHI.js +0 -39
  135. package/dist/assets/ja-Bruw3RYC.js +0 -16
  136. package/dist/assets/main-BkyaQhJX.js +0 -930
  137. package/dist/assets/patchFileDiff-Csk4iNUi.js +0 -13
  138. package/dist/assets/pt-BR-B8V7u7tA.js +0 -16
  139. package/dist/assets/renderElectronMiniChatApp-BxoyujA5.js +0 -2
  140. package/dist/assets/renderMobileApp-B48CsP4r.js +0 -25
  141. package/dist/assets/runtimeEndpointReset-Bg5gx18H.js +0 -17
  142. package/dist/assets/scheduledTasksApi-BW0Etzwz.js +0 -1
  143. package/dist/assets/surface-oMvhsog3.js +0 -1
  144. package/dist/assets/tr-BK_KiO2V.js +0 -7
  145. package/dist/assets/uk-CG74xV8N.js +0 -16
  146. package/dist/assets/useGitComparison-DH220WmO.js +0 -1
  147. package/dist/assets/vendor-legendapp-list-gg7YLRW7.js +0 -1
  148. package/dist/assets/zh-CN-T4AXofZI.js +0 -16
  149. package/dist/assets/zh-TW-Dte40sxp.js +0 -16
  150. package/server/lib/mcp-reconnect/DOCUMENTATION.md +0 -55
  151. package/server/lib/mcp-reconnect/runtime.js +0 -122
  152. package/server/lib/mcp-reconnect/runtime.test.js +0 -140
@@ -1 +1 @@
1
- import{j as a}from"./vendor-react-BUCujlKS.js";import{I as l,a as I}from"./useInlineCommentController-BiWz4AVb.js";function E(g){const{drafts:x,editingDraftId:d,commentText:o,onTextChange:r,selection:n,isDragging:u,fileLabel:s,newWidgetId:f,mapDraftToRange:p,onSave:m,onCancel:c,onEdit:C,onDelete:h}=g,t=[];for(const e of x){const i=p(e);if(e.id===d){t.push({afterLine:i.end,id:`edit-${e.id}`,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:i,isEditing:!0,onSave:m,onCancel:c},`edit-${e.id}`)});continue}t.push({afterLine:i.end,id:`card-${e.id}`,content:a.jsx(I,{draft:e,onEdit:()=>C(e),onDelete:()=>h(e)},`card-${e.id}`)})}if(n&&!d&&!u){const e={...n,start:Math.min(n.start,n.end),end:Math.max(n.start,n.end)};t.push({afterLine:e.end,id:f,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:e,isEditing:!1,onSave:m,onCancel:c},f)})}return t}export{E as b};
1
+ import{j as a}from"./vendor-react-BUCujlKS.js";import{I as l,a as I}from"./useInlineCommentController-DDkpBEU8.js";function E(g){const{drafts:x,editingDraftId:d,commentText:o,onTextChange:r,selection:n,isDragging:u,fileLabel:s,newWidgetId:f,mapDraftToRange:p,onSave:m,onCancel:c,onEdit:C,onDelete:h}=g,t=[];for(const e of x){const i=p(e);if(e.id===d){t.push({afterLine:i.end,id:`edit-${e.id}`,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:i,isEditing:!0,onSave:m,onCancel:c},`edit-${e.id}`)});continue}t.push({afterLine:i.end,id:`card-${e.id}`,content:a.jsx(I,{draft:e,onEdit:()=>C(e),onDelete:()=>h(e)},`card-${e.id}`)})}if(n&&!d&&!u){const e={...n,start:Math.min(n.start,n.end),end:Math.max(n.start,n.end)};t.push({afterLine:e.end,id:f,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:e,isEditing:!1,onSave:m,onCancel:c},f)})}return t}export{E as b};
@@ -0,0 +1,4 @@
1
+ import{R as i,f as Ye,j as t}from"./vendor-react-BUCujlKS.js";import{u as le,K as Fe,a as De}from"./index-BD8ILbxF.js";import{c as Fn,b as Dn,u as An,a as Vn,B as En,C as Ln,P as Tt,h as Tn,e as Mn,g as Bn,i as In,f as Pn}from"./patchFileDiff-CdztVMz0.js";import{c as On,b as zn,i as _n,u as Kn,a as Hn,d as Gn}from"./useGitComparison-BCZVefdE.js";import{f as Pe,B as he,I as V,h as je,Y as $t,ae as $n,J as ee,af as qn,bd as Wn,H as Un,ag as Jn,ai as Xn,y as Mt,k as Yn,cO as qt,t as Je,ic as Qn,av as Xe,a9 as Zn,aa as es,ab as ts,i2 as Wt,id as ns,aw as Ut,f_ as ss,at as Ue,au as rs,bT as Jt,ap as is,ar as os,as,ao as ls}from"./useAppFontEffects-Cwyhjfl5.js";import{d as cs,b as us}from"./runtimeEndpointReset-BhT_-c52.js";import{P as fs}from"./PierreDiffViewer-DzLt-nel.js";import{u as ds,v as ms,g as ps,W as hs}from"./main-BydQ1tr_.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-B6551dwG.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./VirtualizedFileDiff-CAWthkoy.js";import"./web-components-LV3vjTxy.js";import"./computeVirtualFileMetrics-BkiDSlTW.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isDiffPlainText-GMdPz-71.js";import"./vendor-diff-C3JhlQdm.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-BY_5qla_.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-BdA6bdky.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-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-Cb1YnICj.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-DDkpBEU8.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./useRootScrollLock-CwjoWuC4.js";import"./scheduledTasksApi-BEuUF_cj.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";const gs=i.memo(function(e){const s=Ye.c(13),{index:u,staged:h,busyHunk:m,disabled:x,onAction:j}=e,{t:C}=Pe();let c;s[0]!==h?(c=h?["unstage"]:["discard","stage"],s[0]=h,s[1]=c):c=s[1];const w=c;let v;s[2]===Symbol.for("react.memo_cache_sentinel")?(v={top:"var(--oc-hunk-action-offset, 0.25rem)"},s[2]=v):v=s[2];let d;s[3]!==w||s[4]!==m||s[5]!==x||s[6]!==u||s[7]!==j||s[8]!==C?(d=t.jsx("div",{className:"pointer-events-auto flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:w.map(b=>{const _=C(b==="stage"?"diffView.hunk.stageTitle":b==="unstage"?"diffView.hunk.unstageTitle":"diffView.hunk.discardTitle",{index:u+1}),P=m?.index===u&&m.action===b;return t.jsx(he,{variant:"ghost",size:"xs",className:je("rounded-full bg-transparent text-muted-foreground hover:bg-transparent hover:text-foreground",b==="discard"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",b==="stage"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:x||m!==null,title:_,"aria-label":_,onPointerDown:xs,onClick:f=>{f.stopPropagation(),j(u,b)},children:t.jsx(V,{name:P?"loader-4":b==="stage"?"add":"arrow-go-back",className:je(b==="stage"?"size-4":"size-3.5",P&&"animate-spin")})},b)})}),s[3]=w,s[4]=m,s[5]=x,s[6]=u,s[7]=j,s[8]=C,s[9]=d):d=s[9];let E;return s[10]!==u||s[11]!==d?(E=t.jsx("div",{className:"pointer-events-none absolute right-3 z-20",style:v,"data-hunk-actions":u,children:d}),s[10]=u,s[11]=d,s[12]=E):E=s[12],E});function xs(o){return o.stopPropagation()}const Bt=(o,e)=>{if(e.length===0)return null;let s=null,u=null;for(const m of e)m.top<=o?(!s||m.top>s.top)&&(s=m):(!u||m.top<u.top)&&(u=m);const h=s??u;return h?{path:h.path,topOffset:h.top-o}:null},ys=(o,e,s,u)=>Math.min(Math.max(0,u),Math.max(0,o+s-e)),It=o=>{if(!o)return null;const e=o.split(`
2
+ `);let s=null;for(const u of e){const h=u.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(h){const m=Number.parseInt(h[1]??"",10);s=Number.isFinite(m)&&m>=1?m:null;continue}if(s!==null){if(u.startsWith(" ")){s+=1;continue}if(u.startsWith("+"))return s;if(u.startsWith("-"))return Math.max(1,s)}}return null},ws=1100,bs=15e3,Pt=500,Ot=300,Xt=1e6,xt=3,js=o=>o<=6?o:o<=12?6:o<=25?4:2,zt={status:"loading"},vs=3,Ss=i.memo(()=>{const o=Ye.c(4),{t:e}=Pe();let s;o[0]!==e?(s=e("diffView.binary.unavailable"),o[0]=e,o[1]=s):s=o[1];let u;return o[2]!==s?(u=t.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:t.jsx("div",{className:"typography-meta text-muted-foreground",children:s})}),o[2]=s,o[3]=u):u=o[3],u}),Yt={"?":{code:"?",color:"var(--status-info)",descriptionKey:"diffView.change.untracked"},A:{code:"A",color:"var(--status-success)",descriptionKey:"diffView.change.new"},D:{code:"D",color:"var(--status-error)",descriptionKey:"diffView.change.deleted"},R:{code:"R",color:"var(--status-info)",descriptionKey:"diffView.change.renamed"},C:{code:"C",color:"var(--status-info)",descriptionKey:"diffView.change.copied"},M:{code:"M",color:"var(--status-warning)",descriptionKey:"diffView.change.modified"}},Ns=Yt.M,ks=o=>{const e=o.index?.trim(),s=o.working_dir?.trim();return e&&e!=="?"?e.charAt(0):s?s.charAt(0):e?.charAt(0)||s?.charAt(0)||"M"},Qt=o=>{const e=ks(o);return Yt[e]??Ns},Cs=o=>{const{index:e,working_dir:s}=o;return e==="A"||s==="A"||e==="?"||s==="?"},_t=o=>{const e=o.index?.trim();return!!(e&&e!=="?")},Kt=o=>!!o.working_dir?.trim()||o.index==="?",Rs=(o,e)=>ss(o,e),Ht=o=>(o||"").replace(/\\/g,"/").replace(/\/+$/,""),Gt=(o,e)=>{const s=o.split(`
3
+ `),u=e.split(`
4
+ `),h=Math.min(s.length,u.length);for(let m=0;m<h;m+=1)if(s[m]!==u[m])return m+1;return u.length>s.length?s.length+1:s.length>u.length?Math.max(1,u.length):1},Fs=o=>Array.isArray(o)?o.filter(e=>!e||typeof e!="object"?!1:typeof e.file=="string"):[],Ds=o=>o==="added"?"A":o==="deleted"?"D":"M",yt=(o,e,s)=>In(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:s}:{original:"",modified:"",patch:e,fileDiff:Pn(o,e),contextMode:s},Zt=(o,e,s)=>{const u=o??0,h=e??0;return!u&&!h?null:t.jsxs("span",{className:je("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",s?.className),children:[u?t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",u]}):null,h?t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",h]}):null]})},As=i.memo(o=>{const e=Ye.c(68),{scope:s,workingCount:u,stagedCount:h,turnCount:m,branchCount:x,commitCount:j,prCount:C,showCommitOption:c,showBranchOption:w,onScopeChange:v}=o,{t:d}=Pe(),[E,b]=i.useState(!1),_=s==="pr"?C??0:s==="staged"?h:s==="turn"?m:s==="branch"?x??0:s==="commit"?j??0:u;let P;e[0]!==s||e[1]!==d?(P=d(s==="pr"?"session.githubIntegration.tabs.pullRequests":s==="staged"?"diffView.scope.staged":s==="turn"?"diffView.scope.lastTurn":s==="branch"?"diffView.scope.branch":s==="commit"?"commitComparison.mode":"diffView.scope.changed"),e[0]=s,e[1]=d,e[2]=P):P=e[2];const f=P;let ge;e[3]!==d?(ge=d("diffView.scope.selectorAria"),e[3]=d,e[4]=ge):ge=e[4];let xe;e[5]!==_?(xe=t.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",_]}),e[5]=_,e[6]=xe):xe=e[6];let Y;e[7]!==f||e[8]!==xe?(Y=t.jsxs("span",{className:"whitespace-nowrap",children:[f,xe]}),e[7]=f,e[8]=xe,e[9]=Y):Y=e[9];let F;e[10]===Symbol.for("react.memo_cache_sentinel")?(F=t.jsx(V,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=F):F=e[10];let L;e[11]!==ge||e[12]!==Y?(L=t.jsx(is,{asChild:!0,children:t.jsxs("button",{type:"button",className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring","aria-label":ge,children:[Y,F]})}),e[11]=ge,e[12]=Y,e[13]=L):L=e[13];let S;e[14]!==v?(S=J=>{(J==="working"||J==="staged"||J==="turn"||J==="branch"||J==="commit"||J==="pr")&&(v?.(J),b(!1))},e[14]=v,e[15]=S):S=e[15];let te;e[16]!==d?(te=d("diffView.scope.changed"),e[16]=d,e[17]=te):te=e[17];let ne;e[18]!==te?(ne=t.jsx("span",{children:te}),e[18]=te,e[19]=ne):ne=e[19];let ce;e[20]!==u?(ce=t.jsx("span",{className:"typography-meta text-muted-foreground",children:u}),e[20]=u,e[21]=ce):ce=e[21];let se;e[22]!==ce||e[23]!==ne?(se=t.jsx(Ue,{value:"working",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[ne,ce]})}),e[22]=ce,e[23]=ne,e[24]=se):se=e[24];let ue;e[25]!==d?(ue=d("diffView.scope.staged"),e[25]=d,e[26]=ue):ue=e[26];let Q;e[27]!==ue?(Q=t.jsx("span",{children:ue}),e[27]=ue,e[28]=Q):Q=e[28];let W;e[29]!==h?(W=t.jsx("span",{className:"typography-meta text-muted-foreground",children:h}),e[29]=h,e[30]=W):W=e[30];let fe;e[31]!==Q||e[32]!==W?(fe=t.jsx(Ue,{value:"staged",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[Q,W]})}),e[31]=Q,e[32]=W,e[33]=fe):fe=e[33];let T;e[34]!==d?(T=d("diffView.scope.lastTurn"),e[34]=d,e[35]=T):T=e[35];let A;e[36]!==T?(A=t.jsx("span",{children:T}),e[36]=T,e[37]=A):A=e[37];let $;e[38]!==m?($=t.jsx("span",{className:"typography-meta text-muted-foreground",children:m}),e[38]=m,e[39]=$):$=e[39];let K;e[40]!==A||e[41]!==$?(K=t.jsx(Ue,{value:"turn",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[A,$]})}),e[40]=A,e[41]=$,e[42]=K):K=e[42];let de;e[43]!==x||e[44]!==w||e[45]!==d?(de=w?t.jsx(Ue,{value:"branch",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:d("diffView.scope.branch")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:x??"…"})]})}):null,e[43]=x,e[44]=w,e[45]=d,e[46]=de):de=e[46];let U;e[47]!==j||e[48]!==c||e[49]!==d?(U=c&&t.jsx(Ue,{value:"commit",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:d("commitComparison.mode")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:j??"…"})]})}),e[47]=j,e[48]=c,e[49]=d,e[50]=U):U=e[50];let O;e[51]!==C||e[52]!==c||e[53]!==d?(O=c&&t.jsx(Ue,{value:"pr",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:d("session.githubIntegration.tabs.pullRequests")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:C??"…"})]})}),e[51]=C,e[52]=c,e[53]=d,e[54]=O):O=e[54];let q;e[55]!==s||e[56]!==se||e[57]!==fe||e[58]!==K||e[59]!==de||e[60]!==U||e[61]!==O||e[62]!==S?(q=t.jsx(os,{align:"start",className:"w-40",children:t.jsxs(as,{value:s,onValueChange:S,children:[se,fe,K,de,U,O]})}),e[55]=s,e[56]=se,e[57]=fe,e[58]=K,e[59]=de,e[60]=U,e[61]=O,e[62]=S,e[63]=q):q=e[63];let ve;return e[64]!==E||e[65]!==q||e[66]!==L?(ve=t.jsxs(ls,{open:E,onOpenChange:b,children:[L,q]}),e[64]=E,e[65]=q,e[66]=L,e[67]=ve):ve=e[67],ve}),Vs=i.memo(o=>{const e=Ye.c(11),{changedFiles:s,selectedFile:u,onSelectFile:h}=o,{t:m}=Pe();if(s.length===0)return null;let x;if(e[0]!==s||e[1]!==h||e[2]!==u||e[3]!==m){let C;e[5]!==h||e[6]!==u||e[7]!==m?(C=c=>{const w=Qt(c),v=u===c.path;return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>h(c.path),className:je("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",v?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[t.jsx(Ut,{filePath:c.path,className:"h-3.5 w-3.5 flex-shrink-0"}),t.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:w.color},title:m(w.descriptionKey),"aria-label":m(w.descriptionKey),children:w.code}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:c.path,children:c.path}),Zt(c.insertions,c.deletions)]})},c.path)},e[5]=h,e[6]=u,e[7]=m,e[8]=C):C=e[8],x=s.map(C),e[0]=s,e[1]=h,e[2]=u,e[3]=m,e[4]=x}else x=e[4];let j;return e[9]!==x?(j=t.jsx(Jt,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:t.jsx("ul",{className:"flex flex-col gap-1",children:x})}),e[9]=x,e[10]=j):j=e[10],j}),Es=i.memo(o=>{const e=Ye.c(20),{filePath:s,diff:u,renderSideBySide:h}=o,{t:m}=Pe(),x=u.original.length>0,j=u.modified.length>0,C=h?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",c=h?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={contain:"layout"},e[0]=w):w=e[0];let v;e[1]!==u.original||e[2]!==s||e[3]!==x||e[4]!==c||e[5]!==h||e[6]!==m?(v=x&&t.jsxs("div",{className:c,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:m("diffView.image.original")}),t.jsx("img",{src:u.original,alt:m("diffView.image.originalAlt",{path:s}),className:h?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=u.original,e[2]=s,e[3]=x,e[4]=c,e[5]=h,e[6]=m,e[7]=v):v=e[7];let d;e[8]!==u.modified||e[9]!==s||e[10]!==j||e[11]!==x||e[12]!==c||e[13]!==h||e[14]!==m?(d=j&&t.jsxs("div",{className:c,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:m(x?"diffView.image.modified":"diffView.image.new")}),t.jsx("img",{src:u.modified,alt:m("diffView.image.modifiedAlt",{path:s}),className:h?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=u.modified,e[9]=s,e[10]=j,e[11]=x,e[12]=c,e[13]=h,e[14]=m,e[15]=d):d=e[15];let E;return e[16]!==C||e[17]!==v||e[18]!==d?(E=t.jsx("div",{className:"w-full overflow-auto p-4",style:w,children:t.jsxs("div",{className:C,children:[v,d]})}),e[16]=C,e[17]=v,e[18]=d,e[19]=E):E=e[19],E}),Ls=i.memo(o=>{const e=Ye.c(17),{filePath:s,diff:u,renderSideBySide:h,wrapLines:m,hunkActions:x}=o;let j;e[0]!==s?(j=rs(s)||"text",e[0]=s,e[1]=j):j=e[1];const C=j;if(u.isBinary){let v;return e[2]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(Ss,{}),e[2]=v):v=e[2],v}if(Xe(s)){let v;return e[3]!==u||e[4]!==s||e[5]!==h?(v=t.jsx(Es,{filePath:s,diff:u,renderSideBySide:h}),e[3]=u,e[4]=s,e[5]=h,e[6]=v):v=e[6],v}let c;e[7]===Symbol.for("react.memo_cache_sentinel")?(c={contain:"layout"},e[7]=c):c=e[7];let w;return e[8]!==u.fileDiff||e[9]!==u.modified||e[10]!==u.original||e[11]!==s||e[12]!==x||e[13]!==C||e[14]!==h||e[15]!==m?(w=t.jsx("div",{className:"w-full",style:c,children:t.jsx(fs,{original:u.original,modified:u.modified,fileDiff:u.fileDiff,language:C,fileName:s,renderSideBySide:h,wrapLines:m,layout:"inline",hunkActions:x})}),e[8]=u.fileDiff,e[9]=u.modified,e[10]=u.original,e[11]=s,e[12]=x,e[13]=C,e[14]=h,e[15]=m,e[16]=w):w=e[16],w}),Ts=i.memo(({visible:o=!0,directory:e,file:s,layout:u,wrapLines:h,isSelected:m,isExpanded:x,isMounted:j,onSelect:C,onExpandedChange:c,registerSectionRef:w,showOpenInEditorAction:v=!1,isOpeningInEditor:d=!1,onOpenInEditor:E,staged:b=!1,loadFullFiles:_=!1,initialDiffData:P=null,comparisonDiff:f,onRetryComparisonDiff:ge,readOnlyActions:xe=!1,hunkActionsEnabled:Y=!1})=>{const{t:F}=Pe(),{git:L}=$t(),S=ee(i.useCallback(g=>g.directories.get(e)?.diffCache.get(s.path)??null,[e,s.path])),te=ee(g=>g.setDiff),ne=ee(g=>g.fetchStatus),ce=le(g=>g.setDiffFileLayout),[se,ue]=i.useState(0),[Q,W]=i.useState(null),[fe,T]=i.useState(!1),A=f?f.status==="error"?f.message:null:Q,$=f?f.status==="loading":fe,[K,de]=i.useState(null),U=i.useRef(!1),[O,q]=i.useState(null),[ve,J]=i.useState(!1),[re,Qe]=i.useState(null),[it,Ae]=i.useState(null),ye=i.useRef(null),ut=i.useRef(null),Oe=i.useMemo(()=>Qt(s),[s]),ze=u==="side-by-side",Ve=_?"full":"patch",we=`${s.index}:${s.working_dir}:${s.insertions}:${s.deletions}`,a=Y&&!xe&&!P&&!f&&!Xe(s.path),Se=JSON.stringify([De(),e,s.path,b,we,se]),z=O?.scope===Se?O.patch:null,me=i.useMemo(()=>f?f.status==="ready"?f.data:null:P||(b?it:re||(S?{original:S.original,modified:S.modified,isBinary:S.isBinary,contextMode:"full"}:null)),[f,S,P,re,b,it]),Ne=me?.contextMode===Ve,ot=i.useCallback(g=>{ut.current=g,w(s.path,g)},[s.path,w]),_e=i.useCallback(g=>{c(s.path,g)},[s.path,c]),Ze=i.useCallback(()=>{C(s.path)},[s.path,C]),et=i.useRef({fileStatusKey:we,staged:b});i.useEffect(()=>{if(!o)return;const g=et.current;g.fileStatusKey===we&&g.staged===b||(et.current={fileStatusKey:we,staged:b},b?Ae(null):Qe(null),W(null),ye.current=null)},[we,b,o]),i.useEffect(()=>{if(!o||!x||!j||Q)return;if(!e||f||P||me&&Ne&&(!a||z!==null)){ye.current=null,T(!1);return}const g=`${e}::${s.path}::${b?"staged":"unstaged"}::${we}::${Ve}::${se}`;if(ye.current===g)return;ye.current=g,W(null),T(!0);let M=!1;const ie=De(),Ge=_?Xt:xt,X=Xe(s.path)?L.getGitFileDiff(e,{path:s.path,staged:b}):!_&&z!==null?Promise.resolve({diff:z}):L.getGitDiff(e,{path:s.path,staged:b,contextLines:Ge}),ft=a&&_&&z===null?L.getGitDiff(e,{path:s.path,staged:b,contextLines:xt}).then(R=>R.diff):Promise.resolve(z),Ee=Promise.all([X,ft]),Le=bs;let pe;const H=new Promise((R,oe)=>{pe=setTimeout(()=>oe(new Error(`Timed out after ${Le}ms`)),Le)});return Promise.race([Ee,H]).then(([R,oe])=>{if(M||ie!==De())return;const ke="diff"in R&&!_?R.diff:oe;if(a&&_&&ke!==null&&/^@@\s/m.test(ke)&&"diff"in R&&R.diff!==ke&&!Tn(R.diff,ke))throw q(null),new Error(F("diffView.hunk.unavailable"));if(a&&ke!==null&&q({scope:Se,patch:ke}),"diff"in R){const Ce=yt(s.path,R.diff,Ve);b?Ae(Ce):Qe(Ce)}else{const Ce={original:R.original??"",modified:R.modified??"",isBinary:R.isBinary,contextMode:"full"};b?Ae(Ce):te(e,s.path,Ce,ie)}T(!1)}).catch(R=>{if(M||ie!==De())return;const oe=R instanceof Error?R.message:String(R);W(oe),T(!1)}).finally(()=>clearTimeout(pe)),()=>{M=!0,clearTimeout(pe),ye.current===g&&(ye.current=null)}},[z,a,Se,f,Ve,me,Ne,se,e,s.path,we,L,P,x,j,_,Q,te,b,F,o]);const tt=i.useCallback(()=>{_e(!x),Ze()},[_e,Ze,x]),Ke=i.useCallback(()=>{W(null),q(null),Qe(null),Ae(null),ye.current=null,ue(g=>g+1)},[]),nt=i.useCallback(async(g,M)=>{if(!e||!a||$||A||U.current||K!==null)return;const ie=z?Mn(z,g):null;if(!ie){Je.error(F("diffView.hunk.unavailable"));return}if(b&&M!=="unstage"||!b&&M==="unstage")return;U.current=!0;const Ge=De();de({index:g,action:M});try{const X=M==="stage"?L.stageGitHunk:M==="unstage"?L.unstageGitHunk:L.revertGitHunk;if(!X){Je.error(F("diffView.hunk.unsupported"));return}if(await X(e,s.path,ie),Ge!==De())return;Ke(),qt.requestGitRefresh({directory:e,paths:[s.path]}),await ne(e,L)}catch(X){if(Ge!==De())return;Ke(),Je.error(X instanceof Error&&X.message?X.message:F("diffView.hunk.unavailable"))}finally{U.current=!1,de(X=>X?.index===g&&X.action===M?null:X)}},[z,a,$,A,e,ne,s.path,L,K,Ke,b,F]),be=i.useMemo(()=>a&&z!==null?Bn(z):[],[z,a]),He=i.useCallback(g=>t.jsx(gs,{index:g,staged:b,busyHunk:K,disabled:$||!!A,onAction:nt}),[A,nt,K,$,b]),st=i.useMemo(()=>be.length>0?{anchors:be,render:He}:void 0,[be,He]);return t.jsxs("div",{ref:ot,className:"scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0",children:[t.jsx("div",{className:"sticky top-0 z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80",children:t.jsxs("div",{role:"button",tabIndex:0,onClick:tt,onKeyDown:g=>{g.target===g.currentTarget&&(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),tt())},className:je("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",m?"bg-[var(--interactive-selection)]/35":null),children:[t.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),t.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:x?t.jsx(V,{name:"arrow-down-s",className:"size-4"}):t.jsx(V,{name:"arrow-right-s",className:"size-4"})}),t.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:Oe.color},title:F(Oe.descriptionKey),"aria-label":F(Oe.descriptionKey),children:Oe.code}),t.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:s.path,children:t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ut,{filePath:s.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const g=s.path.lastIndexOf("/");if(g===-1)return t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:s.path});const M=s.path.slice(0,g),ie=s.path.slice(g+1);return t.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:M}),t.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[t.jsx("span",{className:"text-muted-foreground",children:"/"}),t.jsx("span",{className:"text-foreground",children:ie})]})]})})()]})})]}),t.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[Zt(s.insertions,s.deletions),v&&E?t.jsx(he,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:F("diffView.actions.openFileInEditorAtChange"),onClick:g=>{g.stopPropagation(),E(s.path,me)},disabled:d,children:d?t.jsx(V,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(V,{name:"edit",className:"size-3.5"})}):null,t.jsx(Wt,{mode:ze?"side-by-side":"unified",onModeChange:g=>{const M=g==="side-by-side"?"side-by-side":"inline";ce(s.path,M)},className:"opacity-70"})]})]})}),x&&t.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!j&&!A?t.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,A?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:F("diffView.state.failedToLoadDiff")}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:A}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>f?ge?.():Ke(),children:F("diffView.actions.retry")})]}):null,j&&$&&!me&&!A?t.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}),F("diffView.state.loadingDiff")]}):null,j&&me&&!ve&&s.insertions+s.deletions>Pt?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:F("diffView.state.largeDiff",{count:s.insertions+s.deletions})}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:F("diffView.state.largeDiffDescription")}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>J(!0),children:F("diffView.actions.renderAnyway")})]}):null,j&&me&&(ve||s.insertions+s.deletions<=Pt)?t.jsx(t.Fragment,{children:t.jsx(Ls,{filePath:s.path,diff:me,renderSideBySide:ze,wrapLines:h,hunkActions:st})}):null]})]})}),Yi=({visible:o=!0,hideStackedFileSidebar:e=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:u=!1,showOpenInEditorAction:h=!1,diffScope:m="all",onDiffScopeChange:x,targetFilePath:j=null,flushContent:C=!1})=>{const{t:c}=Pe(),{git:w,files:v}=$t(),d=$n(),E=ee(n=>n.runtimeKey),{rootIsGitRepo:b,gitDirectory:_,nestedRepos:P}=qn(d??null,{enabled:o}),f=_??d,ge=le(n=>n.openContextSurface),xe=ds(n=>n.requestSource),{screenWidth:Y,isMobile:F}=Wn(),L=Un(f??null),S=Jn(f??null),te=Xn(f??null),ne=ee(n=>n.setActiveDirectory),ce=ee(n=>n.ensureStatus),se=ee(n=>n.selectNestedRepo),ue=ee(n=>n.fetchStatus),Q=ee(n=>n.fetchBranches),W=ee(n=>n.clearDiffCache),fe=ee(n=>n.setDiff),[T,A]=i.useState(null),[$,K]=i.useState(!1),[de,U]=i.useState(null),[O,q]=i.useState(()=>new Set),[ve,J]=i.useState(()=>new Set),[re,Qe]=i.useState(!1),[it,Ae]=i.useState(0),[ye,ut]=i.useState(()=>new Map),[Oe,ze]=i.useState(!1),[Ve,we]=i.useState(!1),[a,Se]=i.useState(m);i.useEffect(()=>{Se(m)},[m]);const z=le(n=>n.pendingDiffFile),me=le(n=>n.pendingDiffStaged),Ne=le(n=>n.pendingDiffScope),ot=le(n=>n.setPendingDiffFile),_e=le(n=>n.diffLayoutPreference),Ze=le(n=>n.diffFileLayout),et=le(n=>n.setDiffFileLayout),tt=le(n=>n.diffWrapLines),Ke=le(n=>n.setDiffWrapLines),nt=le(n=>n.openContextFileAtLine),be=Mt(n=>n.currentSessionId),He=Yn(a==="turn"?be??"":"",d??void 0),st=tt,g=a==="staged"?!0:a==="working"?!1:null,M=g??$,ie=F||Y<=768,Ge=!!be&&a!=="turn"&&a!=="commit"&&a!=="pr"&&!ie&&!Fe(),X=a!=="turn"&&!ie&&!Fe(),ft=!e&&!ie&&Y>=1024,Ee=i.useRef(null),Le=i.useRef(new Map),pe=i.useRef(null),H=i.useRef(null),R=i.useRef(!1),oe=i.useRef(null),ke=i.useRef(null),Ce=i.useRef(null),dt=i.useRef(null),wt=i.useCallback(()=>{const n=Ee.current;if(!n)return null;const r=n.getBoundingClientRect().top,l=[];for(const[p,y]of Le.current)y&&l.push({path:p,top:y.getBoundingClientRect().top});return Bt(r,l)},[]),$e=i.useCallback(()=>{pe.current=null,R.current=!1,U(null),H.current!==null&&(window.cancelAnimationFrame(H.current),H.current=null)},[]),qe=i.useCallback(n=>{q(r=>{if(r.has(n))return r;const l=new Set(r);return l.add(n),l})},[]),rt=i.useMemo(()=>{for(let n=He.length-1;n>=0;n-=1){const r=He[n];if(r.role==="user")return Fs(r.summary?.diffs)}return[]},[He]),en=i.useMemo(()=>{const n=new Map;for(const r of rt)if(r.file){if(typeof r.patch=="string"){n.set(r.file,yt(r.file,r.patch,"patch"));continue}n.set(r.file,{original:r.before??"",modified:r.after??"",contextMode:"full"})}return n},[rt]),tn=i.useMemo(()=>S?.files?S.files.filter(Kt).length:0,[S]),nn=i.useMemo(()=>S?.files?S.files.filter(_t).length:0,[S]),sn=rt.length,G=S?.current??null,Te=Fn(f??null,G,o&&a==="pr"&&!Fe()),Me=Te.selectedSource,Be=Dn(f??null,G,o&&a==="commit"&&!Fe()),Ie=Be.selectedCommit?.hash??null;i.useEffect(()=>{(a==="commit"||a==="pr")&&Fe()&&(Se("working"),x?.("working"))},[a,x]);const We=ee(n=>f?n.directories.get(f)?.branches??null:null),rn=ee(n=>f?n.directories.get(f)?.isLoadingBranches??!1:!1),on=i.useCallback(()=>{f&&Q(f,w)},[f,Q,w]),an=On(f??null,o&&L!==!1,rn,!!We,on,vs),bt=i.useMemo(()=>{const n=S?.tracking?.trim().split("/")[0];return(n&&We?.defaultBranches?.[n])??We?.defaultBranches?.origin??null},[We,S?.tracking]),jt=!Fe()&&zn(G,bt),ln=S!==null,vt=Fe()||an||_n(G,bt,ln,We!==null),cn=An(n=>n.setOverride),{base:Re,resolved:un,revision:St}=Vn(f??null,G,o&&jt&&a==="branch"),[fn,dn]=i.useState(0);i.useEffect(()=>{const n=Gn(a,!vt);n!==a&&(Se(n),n==="working"&&x?.("working"))},[a,vt,x]);const mn=i.useMemo(()=>a==="pr"?Me:a==="commit"&&Ie?{kind:"commit",hash:Ie}:a==="branch"&&Re&&G?{kind:"branch",baseRef:Re,headRef:G}:null,[a,Re,G,Ie,Me]),D=Kn(f??null,mn,o&&!Fe(),a==="branch"?St:""),{fetchDiff:Nt}=D,kt=a==="commit"?D.files:null,Ct=a==="commit"?D.error:null,at=a==="branch"?D.files:null,Rt=a==="branch"?D.error:null,Ft=D.files?a==="pr"?JSON.stringify([D.key,D.revision]):D.key:null,pn=i.useMemo(()=>a==="branch"||a==="commit"||a==="pr"?Array.from(O).sort().join("\0"):"",[a,O]),hn=i.useCallback(async n=>{try{const r=re&&a!=="pr",l=await Nt(n,r?Xt:xt);return{status:"ready",data:yt(n,l.diff,r?"full":"patch")}}catch(r){return{status:"error",message:r instanceof Error?r.message:c("diffView.state.failedToLoadDiff")}}},[a,Nt,re,c]),gn=Hn(Ft,o?pn:"",Ft?hn:null,zt,JSON.stringify([a==="branch"?St:"",a==="pr"?D.revision:0,fn,re])),xn=at?.length??null,N=i.useMemo(()=>{if(a==="commit"||a==="pr")return(D.files??[]).map(l=>({path:l.path,index:"",working_dir:l.status,insertions:l.insertions,deletions:l.deletions,isNew:l.status==="A"}));if(a==="branch")return(at??[]).map(l=>({path:l.path,index:"",working_dir:l.status,insertions:0,deletions:0,isNew:l.status==="A"})).sort((l,p)=>l.path.localeCompare(p.path));if(a==="turn")return rt.map(l=>({path:l.file??"",index:"",working_dir:Ds(l.status),insertions:l.additions??0,deletions:l.deletions??0,isNew:l.status==="added"})).filter(l=>l.path).sort((l,p)=>l.path.localeCompare(p.path));if(!S?.files)return[];const n=S.diffStats??{},r=a==="staged"?_t:a==="working"?Kt:()=>!0;return S.files.filter(r).map(l=>({...l,insertions:n[l.path]?.insertions??0,deletions:n[l.path]?.deletions??0,isNew:Cs(l)})).sort((l,p)=>l.path.localeCompare(p.path))},[a,at,D.files,rt,S]),mt=i.useMemo(()=>N.map(n=>n.path).join("\0"),[N]);i.useEffect(()=>{const n=mt?mt.split("\0"):[],r=new Set(n),l=`${f??""}:${a}:${s?"collapsed":"default"}`,p=ke.current!==l;ke.current=l,q(y=>{if(p){const I=s?0:js(n.length);return new Set(n.slice(0,I))}let B=!1;const k=new Set;for(const I of y){if(!r.has(I)){B=!0;continue}k.add(I)}return B?k:y}),J(y=>{if(p)return new Set;let B=!1;const k=new Set;for(const I of y){if(!r.has(I)){B=!0;continue}k.add(I)}return B?k:y})},[a,mt,f,s]);const Dt=i.useCallback(()=>{if(oe.current=null,!o)return;const n=Ee.current;if(!n)return;const r=n.getBoundingClientRect(),l=r.top-Ot,p=r.bottom+Ot,y={},B=[];for(const[k,I]of Le.current){if(!I)continue;const Z=I.getBoundingClientRect();B.push({path:k,top:Z.top}),O.has(k)&&(Z.bottom<l||Z.top>p||(y[k]=!0))}Ce.current=Bt(r.top,B),J(k=>{let I=!1;const Z=new Set(k);for(const Lt of Object.keys(y))Z.has(Lt)||(Z.add(Lt),I=!0);return I?Z:k})},[O,o]),ae=i.useCallback(()=>{o&&(typeof window>"u"||oe.current===null&&(oe.current=window.requestAnimationFrame(Dt)))},[Dt,o]);i.useEffect(()=>{const n=Ee.current;if(!(!o||!n))return ae(),n.addEventListener("scroll",ae,{passive:!0}),window.addEventListener("resize",ae),()=>{n.removeEventListener("scroll",ae),window.removeEventListener("resize",ae),oe.current!==null&&(window.cancelAnimationFrame(oe.current),oe.current=null)}},[N,O,ae,o]);const pt=i.useCallback(n=>{const r=Ze[n.path];if(r)return r;if(_e==="inline")return"inline";if(_e==="side-by-side")return"side-by-side";const l=Y<ws;return n.isNew||l?"inline":"side-by-side"},[Ze,_e,Y]),At=i.useMemo(()=>N.length===0?null:N.every(n=>pt(n)==="side-by-side")?"side-by-side":"inline",[N,pt]);i.useEffect(()=>{o&&f&&(ne(f),ce(f,w))},[f,ne,ce,w,o]);const lt=JSON.stringify([E,f]),ht=i.useRef({scope:lt,paths:new Set,dirty:!1}),Vt=i.useRef(o);i.useEffect(()=>{const n=o&&!Vt.current;if(Vt.current=o,ht.current.scope!==lt&&(ht.current={scope:lt,paths:new Set,dirty:!1}),!f)return;const r=p=>{p?.length&&(dt.current=wt()??Ce.current,W(f,p),ut(y=>{const B=new Map(y);for(const k of p)B.set(k,(B.get(k)??0)+1);return B})),ue(f,w,{silent:!0})},l=ht.current;return o&&(n||l.dirty)&&(r([...l.paths]),l.paths.clear(),l.dirty=!1),qt.onGitRefreshHint(p=>{if(Ht(p.directory)===Ht(f)){if(!o){l.dirty=!0;for(const y of p.paths??[])l.paths.add(y);return}r(p.paths)}})},[wt,W,f,ue,w,lt,o]),i.useLayoutEffect(()=>{const n=dt.current;if(!n)return;dt.current=null;const r=Ee.current,l=Le.current.get(n.path);if(!r||!l)return;const p=r.getBoundingClientRect().top,y=l.getBoundingClientRect().top-p;r.scrollTop=ys(r.scrollTop,n.topOffset,y,r.scrollHeight-r.clientHeight),Ce.current=n},[ye]),i.useEffect(()=>{!o||a!=="all"&&!Ne||z&&(Ne&&Se(Ne),A(z),K(Ne==="staged"||!Ne&&me),ot(null),R.current=!0,pe.current=z,qe(z),Ae(n=>n+1))},[a,qe,z,Ne,me,ot,o]),i.useEffect(()=>{if(a==="all")return;const n=j?.trim();n&&(A(n),K(a==="staged"),R.current=!0,pe.current=n,qe(n),Ae(r=>r+1))},[a,qe,j]),i.useEffect(()=>{if(!T)return;N.some(r=>r.path===T)||(A(null),K(!1))},[N,T]);const yn=i.useCallback((n,r)=>{const l=Le.current;r?l.set(n,r):l.delete(n),ae()},[ae]),wn=i.useCallback((n,r)=>{$e(),q(l=>{const p=l.has(n);if(r===p)return l;const y=new Set(l);return r?y.add(n):y.delete(n),y}),r||J(l=>{if(!l.has(n))return l;const p=new Set(l);return p.delete(n),p}),ae()},[$e,ae]),bn=i.useCallback(()=>{$e(),q(n=>n.size>0?new Set:new Set(N.map(r=>r.path))),J(new Set),ae()},[$e,N,ae]),jn=i.useCallback(async n=>{if(!be)return;const r=Mt.getState().getDirectoryForSession(be)||d||"";if(!r){Je.error(c("diffView.reviewDialog.toast.noSessionDirectory"));return}we(!0);try{await Qn({originalSessionID:be,directory:r,providerID:n.providerID,modelID:n.modelID,agent:n.agent||void 0,variant:n.variant||void 0,generateHandoff:n.generateHandoff,returnAfterHandoffRequest:n.generateHandoff,autoReview:n.autoReview}),ze(!1)}catch(l){console.error("[review-flow] failed to start review flow",l),Je.error(l instanceof Error?l.message:c("diffView.reviewDialog.toast.startFailed"))}finally{we(!1)}},[be,d,c]),ct=i.useCallback(n=>{const r=Le.current.get(n),l=Ee.current;if(!r||!l)return!1;const p=r.getBoundingClientRect().top-l.getBoundingClientRect().top;return l.scrollTo({top:l.scrollTop+p,behavior:"auto"}),!0},[]);i.useEffect(()=>{const n=pe.current;if(!o||!n)return;let r=0;const l=20;let p=!1;const y=(k=!0)=>{p||(p=!0,pe.current=null,R.current=!1,k&&U(null),H.current!==null&&(window.cancelAnimationFrame(H.current),H.current=null))},B=()=>{if(p){H.current=null;return}const k=pe.current;if(!k){y(),H.current=null;return}if(!ct(k)){r+=1,r<l?H.current=window.requestAnimationFrame(B):(y(),H.current=null);return}if(u&&R.current){U(k),y(!1);return}y()};return H.current=window.requestAnimationFrame(B),()=>{p=!0,H.current!==null&&(window.cancelAnimationFrame(H.current),H.current=null)}},[u,it,ct,o]);const vn=i.useCallback(n=>{},[]),gt=i.useCallback(n=>{$e(),A(n),K(!1),R.current=!0,pe.current=n,qe(n),Ae(r=>r+1),ct(n)},[$e,qe,ct]);i.useEffect(()=>{const n=r=>{if(!o||!r.altKey||r.metaKey||r.ctrlKey||r.shiftKey||r.key!=="ArrowDown"&&r.key!=="ArrowUp")return;const l=r.target;if(l instanceof HTMLElement&&(l.isContentEditable||l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.closest('[role="dialog"]'))||N.length===0)return;const p=r.key==="ArrowDown"?1:-1,y=T?N.findIndex(I=>I.path===T):-1,B=y===-1?p>0?0:N.length-1:y+p,k=N[B];k&&(r.preventDefault(),gt(k.path))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[N,T,gt,o]);const Sn=i.useCallback(n=>{const r=n==="side-by-side"?"side-by-side":"inline";N.forEach(l=>{et(l.path,r)})},[N,et]),[Nn,Et]=i.useState(null),kn=i.useCallback(async(n,r)=>{if(!f||!n)return;Et(n);const l=De();try{let p=null;if(r?.patch&&!r.isBinary&&!Xe(n)?p=It(r.patch):r&&r.contextMode==="full"&&!r.isBinary&&!Xe(n)&&(p=Gt(r.original,r.modified)),p===null)try{const Z=await w.getGitDiff(f,{path:n,staged:M,contextLines:3});p=It(Z.diff)}catch{p=null}let y=r;if(p===null||!y){const Z=await w.getGitFileDiff(f,{path:n,staged:M});y={original:Z.original??"",modified:Z.modified??"",isBinary:Z.isBinary},M||fe(f,n,y,l)}const B=p??(y.isBinary||Xe(n)?1:Gt(y.original,y.modified)),k=Rs(f,n),I=await ms(v,k,{directory:f});if(!I.ok){Je.error(ps(I.reason));return}nt(f,k,B,1)}finally{Et(p=>p===n?null:p)}},[M,f,v,w,nt,fe]),Cn=()=>{if(!f)return null;const n=r=>g!==null?g:$&&r===T;return t.jsxs("div",{className:je("flex min-w-0 flex-1 min-h-0 h-full",C?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[ft&&t.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[t.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:c("diffView.section.files")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:N.length})]}),t.jsx(Vs,{changedFiles:N,selectedFile:null,onSelectFile:gt})]}),t.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:t.jsx(Jt,{ref:Ee,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:t.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:N.map(r=>t.jsx(Ts,{visible:o,directory:f,file:r,layout:pt(r),wrapLines:st,isSelected:!1,isExpanded:O.has(r.path),isMounted:ve.has(r.path)||r.path===de,onSelect:vn,onExpandedChange:wn,registerSectionRef:yn,showOpenInEditorAction:h&&a!=="turn",isOpeningInEditor:Nn===r.path,onOpenInEditor:(l,p)=>{kn(l,p)},staged:n(r.path),loadFullFiles:re&&a!=="pr",readOnlyActions:a==="branch"||a==="commit"||a==="pr",hunkActionsEnabled:a==="all"||a==="working"||a==="staged",comparisonDiff:a==="branch"||a==="commit"||a==="pr"?gn.get(r.path)??zt:void 0,onRetryComparisonDiff:()=>dn(l=>l+1),initialDiffData:a==="turn"?en.get(r.path)??null:null},`${De()}:${f}:${r.path}:${ye.get(r.path)??0}`))})})})]})},Rn=()=>{if(!f)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:c("diffView.state.selectSessionDirectory")});if(a!=="turn"&&te&&!S)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.state.loadingRepositoryStatus")]});if(a!=="turn"&&L===!1)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:c("diffView.state.notGitRepository")});if(a==="pr"){if(!Me||D.error)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:D.error??Te.error??(Te.loading?c("session.githubPrPicker.loading.pullRequests"):c("pullRequestComparison.select"))}),(D.error||Te.error)&&t.jsx(he,{variant:"outline",size:"sm",onClick:()=>{Me?D.refresh():Te.refresh()},children:c("diffView.actions.retry")}),!Me&&!Te.loading&&t.jsx(Tt,{comparison:Te})]});if(!D.files)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 typography-meta text-muted-foreground",children:[t.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.state.loadingDiff")]})}if(a==="commit"){if(Ct)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:Ct}),t.jsx(he,{variant:"outline",size:"sm",onClick:()=>{D.refresh()},children:c("diffView.actions.retry")})]});if(!Ie&&!Be.loading)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:Be.error??c("commitComparison.noCommits")});if(!kt)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.state.loadingDiff")]})}if(a==="branch"){if(!un)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.branch.resolvingBase")]});if(!Re)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(V,{name:"git-branch",className:"size-6 text-muted-foreground"}),t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:c("diffView.branch.noBaseTitle")}),t.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:c("gitView.pr.toast.baseBranchRequired")})]});if(Rt)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:c("diffView.branch.loadError")}),t.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Rt}),t.jsx(he,{variant:"outline",size:"sm",onClick:()=>{D.refresh()},children:c("diffView.actions.retry")})]});if(at===null)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.branch.loadingFiles")]})}return N.length===0?t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:a==="turn"?c("diffView.state.noLastTurnChanges"):a==="pr"?c("walkthrough.blocked.emptyDiff.description"):a==="commit"?c("commitComparison.emptyDiff"):a==="branch"&&Re?c("diffView.branch.empty",{base:us(Re)}):c("diffView.state.cleanWorkingTree")}):Cn()};return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[t.jsxs("div",{className:"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[b===!1&&Array.isArray(P)&&P.length>0?t.jsx(cs,{repositories:P,selectedRepository:_??null,onSelectRepository:n=>{d&&se(d,n)},repositoryRoot:d??void 0}):null,!F&&(a!=="all"?t.jsx(As,{scope:a,workingCount:tn,stagedCount:nn,turnCount:sn,branchCount:xn,commitCount:a==="commit"?kt?.length??null:null,prCount:a==="pr"?D.files?.length??null:null,showCommitOption:!Fe(),showBranchOption:jt,onScopeChange:n=>{Se(n),x?.(n)}}):t.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:t.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:te&&!S?c("diffView.state.loadingChanges"):N.length===1?c("diffView.summary.changedFilesSingle",{count:N.length}):c("diffView.summary.changedFilesPlural",{count:N.length})})})),a==="branch"&&t.jsx(En,{branches:We?.all??[],currentBranch:G,base:Re,onSelect:n=>{f&&G&&cn(f,G,n)}},JSON.stringify([f,G])),a==="commit"&&t.jsx(Ln,{commits:Be.commits,selectedHash:Ie,loading:Be.loading,error:Be.error,onSelect:Be.select,onRefresh:()=>{Be.refresh()}},JSON.stringify([f,G])),a==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(Tt,{comparison:Te},JSON.stringify([E,f,G])),Me&&t.jsx(he,{variant:"ghost",size:"sm",disabled:D.loading,"aria-label":c("session.githubIssuePicker.actions.refresh"),title:c("session.githubIssuePicker.actions.refresh"),onClick:()=>{D.refresh()},children:t.jsx(V,{name:"refresh",className:"size-4"})})]}),N.length>0&&t.jsxs(he,{variant:"ghost",size:"sm",onClick:bn,className:je("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:O.size>0?c("diffView.actions.collapseAll"):c("diffView.actions.expandAll"),children:[t.jsx(V,{name:"expand-up-down",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:O.size>0?c("diffView.actions.collapseAll"):c("diffView.actions.expandAll")})]}),N.length>0&&Ge&&t.jsxs(he,{variant:"default",size:"sm",onClick:()=>ze(!0),disabled:Ve,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":c("diffView.actions.reviewAria"),children:[Ve?t.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(V,{name:"search-eye",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:c("diffView.actions.review")})]}),N.length>0&&X&&t.jsxs(he,{variant:"outline",size:"sm",onClick:()=>{const n=f??"";xe(n,a==="pr"&&Me?Me:a==="commit"&&Ie?{kind:"commit",hash:Ie}:a==="branch"&&Re&&G?{kind:"branch",baseRef:Re,headRef:G}:{kind:"working-tree",scope:a==="staged"||a==="working"?a:"all"}),ge(d??n,"walkthrough")},className:je("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",hs),"aria-label":c("walkthrough.action.open"),children:[t.jsx(V,{name:"route",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:c("walkthrough.action.open")})]}),N.length>0&&a!=="pr"&&t.jsxs(Zn,{children:[t.jsx(es,{asChild:!0,children:t.jsx(he,{variant:"ghost",size:"sm",onClick:()=>Qe(n=>!n),"aria-pressed":re,"aria-label":c(re?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles"),className:je("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",re&&"bg-interactive-selection text-interactive-selection-foreground"),children:t.jsx(V,{name:"file-download",className:"size-4"})})}),t.jsx(ts,{children:t.jsx("p",{children:c(re?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles")})})]}),N.length>0&&t.jsx(he,{variant:"ghost",size:"sm",onClick:()=>Ke(!tt),className:je("h-5 w-5 p-0 transition-opacity",st?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:c(st?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:t.jsx(V,{name:"text-wrap",className:"size-4"})}),At&&t.jsx(Wt,{mode:At==="side-by-side"?"side-by-side":"unified",onModeChange:Sn})]}),t.jsx(ns,{open:Oe,onOpenChange:ze,projectDirectory:f??null,submitting:Ve,onConfirm:jn}),Rn()]})};export{Yi as DiffView,Ts as MultiFileDiffEntry};
@@ -1 +1 @@
1
- import{R as N,f as oe,j as s}from"./vendor-react-BUCujlKS.js";import{u as ze}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{f as J,aw as Ee,a7 as be,a8 as ye,I as E,a9 as we,h as Z,B as Y,a2 as Te,hc as Ie,bL as fe,bM as ue,bN as pe,bO as ge,bP as xe,bQ as ve,bb as Me,c5 as Pe,t as ae}from"./useAppFontEffects-CPKeOpUo.js";import{u as ke}from"./index-DVwMarHI.js";const Se={"?":{code:"?",color:"var(--status-info)",description:"Untracked file"},A:{code:"A",color:"var(--status-success)",description:"New file"},D:{code:"D",color:"var(--status-error)",description:"Deleted file"},R:{code:"R",color:"var(--status-info)",description:"Renamed file"},C:{code:"C",color:"var(--status-info)",description:"Copied file"},M:{code:"M",color:"var(--status-warning)",description:"Modified file"}},Re=Se.M;function Fe(p){const e=p.index?.trim(),t=p.working_dir?.trim();return e&&e!=="?"?e.charAt(0):t?t.charAt(0):e?.charAt(0)||t?.charAt(0)||"M"}function He(p){const e=Fe(p);return Se[e]??Re}const $e=N.memo(function(e){const t=oe.c(58),{file:r,actionLabel:w,actionSymbol:x,onAction:g,onViewDiff:d,onRevert:a,isReverting:h,stats:S,rowPaddingClassName:f,indentPx:b,actionAtStart:V,showRevert:k}=e,v=b===void 0?0:b,o=V===void 0?!1:V,j=k===void 0?!0:k;let c;t[0]!==r?(c=He(r),t[0]=r,t[1]=c):c=t[1];const u=c,{t:I}=J(),H=u.description,R=S?.insertions??0,A=S?.deletions??0;let z;t[2]!==g||t[3]!==d?(z=U=>{U.key===" "?(U.preventDefault(),g()):U.key==="Enter"&&(U.preventDefault(),d())},t[2]=g,t[3]=d,t[4]=z):z=t[4];const T=z;let M;t[5]!==g?(M=U=>{U.preventDefault(),U.stopPropagation(),g()},t[5]=g,t[6]=M):M=t[6];const y=M;let $;t[7]!==a?($=U=>{U.preventDefault(),U.stopPropagation(),a()},t[7]=a,t[8]=$):$=t[8];const W=$;let L;t[9]!==w||t[10]!==x||t[11]!==y?(L=s.jsx("button",{type:"button",onClick:y,className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":w,title:w,children:x}),t[9]=w,t[10]=x,t[11]=y,t[12]=L):L=t[12];const F=L,X=`group flex items-center gap-2 py-1.5 cursor-pointer ${f??"px-3"}`;let P;t[13]!==v?(P=v>0?{paddingLeft:`${v}px`}:void 0,t[13]=v,t[14]=P):P=t[14];const q=o?F:null;let K;t[15]!==u.color?(K={color:u.color},t[15]=u.color,t[16]=K):K=t[16];let O;t[17]!==u.code||t[18]!==H||t[19]!==K?(O=s.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:K,title:H,"aria-label":H,children:u.code}),t[17]=u.code,t[18]=H,t[19]=K,t[20]=O):O=t[20];let G;t[21]!==r.path?(G=s.jsx(Ee,{filePath:r.path,className:"h-3.5 w-3.5 shrink-0"}),t[21]=r.path,t[22]=G):G=t[22];let _;if(t[23]!==r.path){e:{const U=r.path.lastIndexOf("/");if(U===-1){let ne;t[25]===Symbol.for("react.memo_cache_sentinel")?(ne={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[25]=ne):ne=t[25],_=s.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:ne,title:r.path,children:r.path});break e}const Ae=r.path.slice(0,U),De=r.path.slice(U);let te;t[26]===Symbol.for("react.memo_cache_sentinel")?(te={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[26]=te):te=t[26];let se;t[27]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx("span",{className:"text-muted-foreground",children:"/"}),t[27]=se):se=t[27];const ce=s.jsx("span",{className:"text-foreground",children:De.slice(1)});let ie;t[28]!==ce?(ie=s.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[se,ce]}),t[28]=ce,t[29]=ie):ie=t[29],_=s.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:r.path,children:[s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:te,children:Ae}),ie]})}t[23]=r.path,t[24]=_}else _=t[24];let Q;t[30]===Symbol.for("react.memo_cache_sentinel")?(Q={color:"var(--status-success)"},t[30]=Q):Q=t[30];let i;t[31]!==R?(i=s.jsxs("span",{style:Q,children:["+",R]}),t[31]=R,t[32]=i):i=t[32];let n,l;t[33]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),l={color:"var(--status-error)"},t[33]=n,t[34]=l):(n=t[33],l=t[34]);let m;t[35]!==A?(m=s.jsxs("span",{style:l,children:["-",A]}),t[35]=A,t[36]=m):m=t[36];let D;t[37]!==i||t[38]!==m?(D=s.jsxs("span",{className:"shrink-0 typography-micro",children:[i,n,m]}),t[37]=i,t[38]=m,t[39]=D):D=t[39];let C;t[40]!==r.path||t[41]!==W||t[42]!==h||t[43]!==j||t[44]!==I?(C=j?s.jsxs(be,{children:[s.jsx(ye,{asChild:!0,children:s.jsx("button",{type:"button",onClick:W,disabled:h,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50","aria-label":I("gitView.changes.revertFileAria",{path:r.path}),children:h?s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(E,{name:"arrow-go-back",className:"size-3.5"})})}),s.jsx(we,{sideOffset:8,children:I("gitView.changes.revertFileTooltip")})]}):null,t[40]=r.path,t[41]=W,t[42]=h,t[43]=j,t[44]=I,t[45]=C):C=t[45];const B=o?null:F;let ee;return t[46]!==T||t[47]!==d||t[48]!==P||t[49]!==q||t[50]!==O||t[51]!==G||t[52]!==_||t[53]!==D||t[54]!==C||t[55]!==B||t[56]!==X?(ee=s.jsxs("div",{className:X,role:"button",tabIndex:0,onClick:d,onKeyDown:T,style:P,children:[q,O,G,_,D,C,B]}),t[46]=T,t[47]=d,t[48]=P,t[49]=q,t[50]=O,t[51]=G,t[52]=_,t[53]=D,t[54]=C,t[55]=B,t[56]=X,t[57]=ee):ee=t[57],ee}),je=14,Ve=p=>p.replace(/\\/g,"/").replace(/^\/+/,"").trim(),Ne=(p,e)=>({id:`dir:${p}`,path:p,name:e,children:new Map,directFiles:[],files:[]}),Le=p=>{const e=Ne("","");for(const t of p){const r=Ve(t.path);if(!r)continue;const x=r.split("/").filter(Boolean).slice(0,-1);let g=e;if(g.files.push(t),x.length>0){let d="";for(const a of x){d=d?`${d}/${a}`:a;const h=g.children.get(a);if(h){h.files.push(t),g=h;continue}const S=Ne(d,a);S.files.push(t),g.children.set(a,S),g=S}}g.directFiles.push(t)}return e},Oe=(p,e)=>{const t=[],r=(w,x)=>{const g=Array.from(w.children.values()).sort((a,h)=>a.path.localeCompare(h.path));for(const a of g)t.push({key:a.id,kind:"directory",depth:x,directory:a}),e.has(a.path)&&r(a,x+1);const d=[...w.directFiles].sort((a,h)=>a.path.localeCompare(h.path));for(const a of d)t.push({key:`file:${Ve(a.path)}`,kind:"file",depth:x,file:a})};return r(p,0),t},Ge=1e3,Ce=34,de=30,le="pl-0 pr-2",me=(p,e)=>`${p} ${e}`,Qe=({groups:p,diffStats:e,revertingPaths:t,isRevertingAll:r=!1,headerBackgroundClassName:w="bg-sidebar",onVisiblePathsChange:x,onRevertAll:g,onRevertDirectory:d})=>{const{t:a}=J(),h=N.useRef(null),f=ke(i=>i.gitChangesViewMode)==="tree",b=N.useMemo(()=>p.filter(i=>i.entries.length>0),[p]),[V,k]=N.useState(new Set),[v,o]=N.useState(new Set),[j,c]=N.useState(!1),[u,I]=N.useState(null),H=N.useMemo(()=>b.map(i=>Le(i.entries)),[b]),R=N.useMemo(()=>{const i=[];return b.forEach((n,l)=>{Array.from(H[l]?.children.values()??[]).forEach(m=>{i.push(me(n.id,m.path))})}),i},[H,b]);N.useEffect(()=>{f&&o(i=>{const n=new Set,l=new Set(R);return i.forEach(m=>{(m.slice(m.indexOf(" ")+1).includes("/")||l.has(m))&&n.add(m)}),R.forEach(m=>n.add(m)),n})},[f,R]);const A=N.useMemo(()=>{const i=[];return b.forEach((n,l)=>{if(i.push({type:"header",key:`header:${n.id}`,groupIndex:l}),!V.has(n.id)){if(f){const m=new Set;v.forEach(C=>{C.startsWith(`${n.id} `)&&m.add(C.slice(n.id.length+1))}),Oe(H[l],m).forEach(C=>{C.kind==="file"?i.push({type:"file",key:`${n.id}:${C.key}`,groupIndex:l,file:C.file,depth:C.depth}):i.push({type:"directory",key:`${n.id}:${C.key}`,groupIndex:l,directory:C.directory,depth:C.depth})});return}n.entries.forEach(m=>{i.push({type:"file",key:`${n.id}:file:${m.path}`,groupIndex:l,file:m,depth:0})})}}),g&&b.length>0&&i.push({type:"revert-all",key:"revert-all"}),i},[V,v,f,g,H,b]),z=A.length,T=z>=Ge,M=ze({count:z,enabled:T,getScrollElement:()=>h.current,estimateSize:()=>Ce,overscan:12,getItemKey:i=>A[i]?.key??i}),y=M.getVirtualItems(),$=N.useMemo(()=>{if(!T)return 0;const i=h.current?.scrollTop??0;return y.find(l=>l.end>i)?.index??0},[T,y,h]);N.useEffect(()=>{if(!x)return;const i=n=>n&&n.type==="file"?n.file.path:null;if(z===0){x([]);return}if(!T){const n=[];for(const l of A)if(l.type==="file"&&(n.push(l.file.path),n.length>=de))break;x(n);return}x(A.slice($,$+Math.ceil((h.current?.clientHeight??0)/Ce)+de).map(n=>i(n)).filter(n=>!!n).slice(0,de))},[x,z,A,T,$]);const W=N.useCallback(i=>{k(n=>{const l=new Set(n);return l.has(i)?l.delete(i):l.add(i),l})},[]),L=N.useCallback((i,n)=>{o(l=>{const m=new Set(l),D=me(i,n);return m.has(D)?m.delete(D):m.add(D),m})},[]),F=N.useMemo(()=>{const i=new Set;return b.forEach(n=>n.entries.forEach(l=>i.add(l.path))),Array.from(i)},[b]),X=F.length,P=u?r||u.paths.some(i=>t.has(i)):!1,q=N.useCallback(async()=>{!g||r||F.length===0||(await g(F),c(!1))},[F,r,g]),K=N.useCallback(async()=>{!d||!u||P||(await d(u.paths),I(null))},[P,d,u]),O=N.useCallback((i,n)=>{const l=V.has(i.id),m=i.entries.length;return s.jsxs("div",{className:Z("sticky top-0 z-10 flex items-center gap-2 py-2",w,le,!n&&"mt-1 border-t border-border/40"),children:[s.jsx("button",{type:"button",onClick:()=>i.onActionAll(i.entries.map(D=>D.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":i.actionAllLabel,title:i.actionAllLabel,children:i.actionSymbol}),s.jsxs("button",{type:"button",onClick:()=>W(i.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-expanded":!l,children:[s.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:i.title}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:m}),s.jsx(E,{name:"arrow-down-s",className:Z("size-3.5 shrink-0 text-muted-foreground transition-transform",l&&"-rotate-90")})]})]})},[V,w,W]),G=N.useCallback((i,n,l)=>{const m=v.has(me(i.id,n.path)),D=n.files.map(B=>B.path),C=r||D.some(B=>t.has(B));return s.jsxs("div",{className:Z("group flex items-center gap-2 py-1.5",le),style:{paddingLeft:`${l*je}px`},children:[s.jsxs("button",{type:"button",onClick:()=>L(i.id,n.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":m?a("gitView.changes.collapseDirectoryAria",{path:n.path}):a("gitView.changes.expandDirectoryAria",{path:n.path}),children:[m?s.jsx(E,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):s.jsx(E,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:n.path,children:n.name}),s.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:n.files.length})]}),i.showRevertActions!==!1&&d?s.jsx("button",{type:"button",onClick:()=>I({path:n.path,paths:D,count:D.length}),disabled:C,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":a("gitView.changes.revertDirectoryAria",{path:n.path}),title:a("gitView.changes.revertDirectoryTooltip"),children:C?s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(E,{name:"arrow-go-back",className:"size-3.5"})}):null,s.jsx("button",{type:"button",onClick:()=>i.onActionAll(n.files.map(B=>B.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":a(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),title:a(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),children:i.actionSymbol})]})},[v,r,d,t,a,L]),_=N.useCallback((i,n)=>{if(i.type==="revert-all")return s.jsx("div",{className:Z("flex justify-end py-2",le),children:s.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>c(!0),disabled:r,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[s.jsx(E,{name:"arrow-go-back",className:"size-3.5"}),a("gitView.changes.revertAll")]})});const l=b[i.groupIndex];if(!l)return null;if(i.type==="header")return O(l,n);if(i.type==="directory")return G(l,i.directory,i.depth);const m=i.file;return s.jsx($e,{file:m,actionLabel:l.getActionLabel(m.path),actionSymbol:l.actionSymbol,onAction:()=>l.onActionFile(m.path),stats:e?.[m.path],onViewDiff:()=>l.onViewDiff(m.path),onRevert:()=>l.onRevertFile(m.path),isReverting:t.has(m.path)||r,rowPaddingClassName:le,indentPx:i.depth*je,actionAtStart:!f,showRevert:l.showRevertActions!==!1})},[e,r,f,G,O,t,a,b]),Q=N.useCallback(i=>{const n=A[i],l=A[i-1];return!n||!l||n.type!=="file"&&n.type!=="directory"||l.type!=="file"&&l.type!=="directory"?!1:l.groupIndex===n.groupIndex},[A]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[s.jsx(Te,{ref:h,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:T?s.jsx("div",{style:{height:M.getTotalSize(),position:"relative"},children:y.map(i=>{const n=A[i.index];return n?s.jsx("div",{"data-index":i.index,ref:M.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${i.start}px)`},className:Z(Q(i.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:_(n,i.index===0)},n.key):null})}):s.jsx("div",{role:"list","aria-label":a("gitView.changes.changedFilesAria"),children:A.map((i,n)=>s.jsx("div",{className:Z("relative",Q(n)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:_(i,n===0)},i.key))})}),s.jsx(Ie,{containerRef:h,disableHorizontal:!0})]}),s.jsx(fe,{open:j,onOpenChange:i=>{!r&&!i&&c(!1)},children:s.jsxs(ue,{className:"max-w-md",children:[s.jsxs(pe,{children:[s.jsx(ge,{children:a("gitView.changes.revertAllDialogTitle")}),s.jsx(xe,{children:X===1?a("gitView.changes.revertAllDescriptionSingle",{count:X}):a("gitView.changes.revertAllDescriptionPlural",{count:X})})]}),s.jsxs(ve,{children:[s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>c(!1),disabled:r,children:a("gitView.common.cancel")}),s.jsx(Y,{variant:"destructive",size:"sm",onClick:()=>{q()},disabled:r,children:a(r?"gitView.changes.reverting":"gitView.changes.revertAll")})]})]})}),s.jsx(fe,{open:!!u,onOpenChange:i=>{!P&&!i&&I(null)},children:s.jsxs(ue,{className:"max-w-md",children:[s.jsxs(pe,{children:[s.jsx(ge,{children:a("gitView.changes.revertDirectoryDialogTitle")}),s.jsx(xe,{children:u?u.count===1?a("gitView.changes.revertDirectoryDescriptionSingle",{count:u.count,path:u.path}):a("gitView.changes.revertDirectoryDescriptionPlural",{count:u.count,path:u.path}):null})]}),s.jsxs(ve,{children:[s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>I(null),disabled:P,children:a("gitView.common.cancel")}),s.jsx(Y,{variant:"destructive",size:"sm",onClick:()=>{K()},disabled:P||!u,children:a(P?"gitView.changes.reverting":"gitView.changes.revertDirectory")})]})]})})]})},he=38,re=200,Ke=p=>{const e=oe.c(23),{value:t,onChange:r,onSubmit:w,placeholder:x,disabled:g,hasTouchInput:d,isMobile:a}=p,h=g===void 0?!1:g,S=d===void 0?!1:d,f=a===void 0?!1:a,{t:b}=J(),V=N.useRef(null),k=ke(_e);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{const y=V.current;if(!y)return;const $=document.activeElement===y,W=()=>{y.style.height=`${he}px`;const F=y.scrollHeight,X=Math.min(Math.max(F,he),re);y.style.height=`${X}px`,y.style.overflowY=F>re?"auto":"hidden",F>re&&!$&&(y.scrollTop=y.scrollHeight)};W();const L=window.requestAnimationFrame(W);return()=>{window.cancelAnimationFrame(L)}},e[0]=v):v=e[0];let o;e[1]!==t?(o=[t],e[1]=t,e[2]=o):o=e[2],N.useLayoutEffect(v,o);let j;e[3]!==r?(j=y=>r(y.target.value),e[3]=r,e[4]=j):j=e[4];let c;e[5]!==w?(c=y=>{y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&!y.shiftKey&&!y.altKey&&(y.preventDefault(),w?.())},e[5]=w,e[6]=c):c=e[6];let u;e[7]!==x||e[8]!==b?(u=x??b("gitView.commit.messagePlaceholder"),e[7]=x,e[8]=b,e[9]=u):u=e[9];const I=S?"on":"off",H=S?"sentences":"off",R=f||k,A=h&&"opacity-50";let z;e[10]!==A?(z=Z("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",A),e[10]=A,e[11]=z):z=e[11];let T;e[12]===Symbol.for("react.memo_cache_sentinel")?(T={minHeight:he,maxHeight:re},e[12]=T):T=e[12];let M;return e[13]!==h||e[14]!==H||e[15]!==R||e[16]!==z||e[17]!==j||e[18]!==c||e[19]!==u||e[20]!==I||e[21]!==t?(M=s.jsx("textarea",{ref:V,value:t,onChange:j,onKeyDown:c,placeholder:u,rows:1,disabled:h,autoCorrect:I,autoCapitalize:H,spellCheck:R,className:z,style:T}),e[13]=h,e[14]=H,e[15]=R,e[16]=z,e[17]=j,e[18]=c,e[19]=u,e[20]=I,e[21]=t,e[22]=M):M=e[22],M};function _e(p){return p.inputSpellcheckEnabled}const Be=p=>{const e=oe.c(30),{highlights:t,onInsert:r}=p,{t:w}=J();if(t.length===0)return null;let x;e[0]!==t||e[1]!==r?(x=()=>{r(t)},e[0]=t,e[1]=r,e[2]=x):x=e[2];const g=x;let d;e[3]!==w?(d=w("gitView.commit.aiHighlights.title"),e[3]=w,e[4]=d):d=e[4];let a;e[5]!==d?(a=s.jsx("p",{className:"typography-micro text-muted-foreground",children:d}),e[5]=d,e[6]=a):a=e[6];let h;e[7]!==w?(h=w("gitView.commit.aiHighlights.insertAria"),e[7]=w,e[8]=h):h=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(E,{name:"arrow-down",className:"size-4"}),e[9]=S):S=e[9];let f;e[10]!==g||e[11]!==h?(f=s.jsx(ye,{asChild:!0,children:s.jsx(Y,{variant:"ghost",size:"icon",className:"size-6",onClick:g,"aria-label":h,children:S})}),e[10]=g,e[11]=h,e[12]=f):f=e[12];let b;e[13]!==w?(b=w("gitView.commit.aiHighlights.insertTooltip"),e[13]=w,e[14]=b):b=e[14];let V;e[15]!==b?(V=s.jsx(we,{sideOffset:8,children:b}),e[15]=b,e[16]=V):V=e[16];let k;e[17]!==f||e[18]!==V?(k=s.jsxs(be,{children:[f,V]}),e[17]=f,e[18]=V,e[19]=k):k=e[19];let v;e[20]!==a||e[21]!==k?(v=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a,k]}),e[20]=a,e[21]=k,e[22]=v):v=e[22];let o;e[23]!==t?(o=t.map(Ue),e[23]=t,e[24]=o):o=e[24];let j;e[25]!==o?(j=s.jsx("ul",{className:"space-y-1",children:o}),e[25]=o,e[26]=j):j=e[26];let c;return e[27]!==v||e[28]!==j?(c=s.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[v,j]}),e[27]=v,e[28]=j,e[29]=c):c=e[29],c};function Ue(p,e){return s.jsx("li",{className:"typography-meta text-foreground",children:p},`${p}-${e}`)}const Ze=p=>{const e=oe.c(80),{stagedCount:t,commitMessage:r,onCommitMessageChange:w,generatedHighlights:x,onInsertHighlights:g,onGenerateMessage:d,isGeneratingMessage:a,onCommit:h,onCommitAndPush:S,commitAction:f,hasPendingIndexMutation:b,gitmojiEnabled:V,onOpenGitmojiPicker:k}=p,v=b===void 0?!1:b,{t:o}=J(),j=t>0;let c;e[0]!==f||e[1]!==r||e[2]!==v||e[3]!==j?(c=r.trim()&&j&&f===null&&!v,e[0]=f,e[1]=r,e[2]=v,e[3]=j,e[4]=c):c=e[4];const u=c,{isMobile:I,hasTouchInput:H}=Me();let R;e[5]!==o?(R=o("gitView.commit.title"),e[5]=o,e[6]=R):R=e[6];let A;e[7]!==R?(A=s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:R}),e[7]=R,e[8]=A):A=e[8];let z;e[9]!==j||e[10]!==o?(z=j?null:s.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:o("gitView.commit.stageFilesHint")}),e[9]=j,e[10]=o,e[11]=z):z=e[11];let T;e[12]!==A||e[13]!==z?(T=s.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[A,z]}),e[12]=A,e[13]=z,e[14]=T):T=e[14];let M;e[15]!==x||e[16]!==g?(M=s.jsx(Be,{highlights:x,onInsert:g}),e[15]=x,e[16]=g,e[17]=M):M=e[17];let y;e[18]!==u||e[19]!==a||e[20]!==h?(y=()=>{u&&!a&&h()},e[18]=u,e[19]=a,e[20]=h,e[21]=y):y=e[21];let $;e[22]!==o?($=o("gitView.commit.messagePlaceholder"),e[22]=o,e[23]=$):$=e[23];const W=f!==null;let L;e[24]!==r||e[25]!==H||e[26]!==I||e[27]!==w||e[28]!==W||e[29]!==y||e[30]!==$?(L=s.jsx(Ke,{value:r,onChange:w,onSubmit:y,placeholder:$,disabled:W,hasTouchInput:H,isMobile:I}),e[24]=r,e[25]=H,e[26]=I,e[27]=w,e[28]=W,e[29]=y,e[30]=$,e[31]=L):L=e[31];let F;e[32]!==V||e[33]!==k||e[34]!==o?(F=V&&s.jsxs(Y,{variant:"outline",size:"sm",onClick:k,className:"w-fit",type:"button",children:[s.jsx(E,{name:"emotion-happy",className:"size-4"}),o("gitView.commit.addGitmoji")]}),e[32]=V,e[33]=k,e[34]=o,e[35]=F):F=e[35];const X=a||f!==null||v||t===0;let P;e[36]!==o?(P=o("gitView.commit.generateAria"),e[36]=o,e[37]=P):P=e[37];let q;e[38]!==a?(q=a?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4 text-primary"}),e[38]=a,e[39]=q):q=e[39];let K;e[40]!==o?(K=o("gitView.commit.generate"),e[40]=o,e[41]=K):K=e[41];let O;e[42]!==K?(O=s.jsx("span",{className:"commit-actions__label",children:K}),e[42]=K,e[43]=O):O=e[43];let G;e[44]!==d||e[45]!==X||e[46]!==P||e[47]!==q||e[48]!==O?(G=s.jsxs(Y,{variant:"outline",size:"sm",onClick:d,disabled:X,type:"button","aria-label":P,className:"commit-actions__btn",children:[q,O]}),e[44]=d,e[45]=X,e[46]=P,e[47]=q,e[48]=O,e[49]=G):G=e[49];let _;e[50]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx("div",{className:"flex-1"}),e[50]=_):_=e[50];const Q=!u||a;let i;e[51]!==o?(i=o("gitView.commit.commitAria"),e[51]=o,e[52]=i):i=e[52];let n;e[53]!==f||e[54]!==o?(n=f==="commit"?s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.committing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"git-commit",className:"size-4"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.commit")})]}),e[53]=f,e[54]=o,e[55]=n):n=e[55];let l;e[56]!==h||e[57]!==Q||e[58]!==i||e[59]!==n?(l=s.jsx(Y,{size:"sm",variant:"outline",onClick:h,disabled:Q,className:"commit-actions__btn whitespace-nowrap","aria-label":i,children:n}),e[56]=h,e[57]=Q,e[58]=i,e[59]=n,e[60]=l):l=e[60];let m;e[61]!==u||e[62]!==f||e[63]!==a||e[64]!==I||e[65]!==S||e[66]!==o?(m=I?s.jsxs(be,{children:[s.jsx(ye,{asChild:!0,children:s.jsx(Y,{variant:"default",size:"sm",onClick:()=>S(),disabled:!u||a,className:"h-7 w-7 p-0","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"arrow-up",className:"size-3.5"})})}),s.jsx(we,{side:"top",children:s.jsx("p",{children:o("gitView.commit.push")})})]}):s.jsx(Y,{size:"sm",variant:"default",onClick:()=>S(),disabled:!u||a,className:"commit-actions__btn","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.pushing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"arrow-up",className:"size-3.5"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.push")})]})}),e[61]=u,e[62]=f,e[63]=a,e[64]=I,e[65]=S,e[66]=o,e[67]=m):m=e[67];let D;e[68]!==G||e[69]!==l||e[70]!==m?(D=s.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[G,_,l,m]}),e[68]=G,e[69]=l,e[70]=m,e[71]=D):D=e[71];let C;e[72]!==L||e[73]!==F||e[74]!==D||e[75]!==M?(C=s.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[M,L,F,D]}),e[72]=L,e[73]=F,e[74]=D,e[75]=M,e[76]=C):C=e[76];let B;return e[77]!==C||e[78]!==T?(B=s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[T,C]}),e[77]=C,e[78]=T,e[79]=B):B=e[79],B},Je=({open:p,onOpenChange:e,targetBranch:t,changedFileCount:r,onCommitAndSwitch:w,onGenerateMessage:x,onRevertAndSwitch:g})=>{const{t:d}=J(),[a,h]=N.useState(""),[S,f]=N.useState(null),[b,V]=N.useState(!1),k=S!==null;N.useEffect(()=>{p||(h(""),V(!1))},[p]);const v=async()=>{f("generate");try{const c=await x();c&&h(c)}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}},o=async()=>{f("commit");try{let c=a.trim();if(!c){if(c=(await x()).trim(),!c){ae.error(d("gitView.toast.enterCommitMessage"));return}h(c)}await w(c,b)}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}},j=async()=>{f("revert");try{await g()}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}};return s.jsx(fe,{open:p,onOpenChange:c=>{k||e(c)},children:s.jsx(ue,{className:"max-w-md w-[calc(100vw-2rem)]",children:s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsxs(pe,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(E,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),s.jsx(ge,{children:d("gitView.dirtySwitch.title")})]}),s.jsx(xe,{children:r===1?d("gitView.dirtySwitch.descriptionSingle",{branch:t}):d("gitView.dirtySwitch.descriptionPlural",{branch:t,count:r})})]}),s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border/60 px-3 py-2 focus-within:border-border",children:[s.jsx("input",{value:a,onChange:c=>h(c.target.value),placeholder:d("gitView.commit.messagePlaceholder"),disabled:k,onKeyDown:c=>{c.key==="Enter"&&!k&&(c.preventDefault(),o())},className:"min-w-0 flex-1 bg-transparent typography-meta text-foreground outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"button",onClick:()=>{v()},disabled:k,"aria-label":d("gitView.commit.generate"),title:d("gitView.commit.generate"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:S==="generate"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4 text-primary"})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Pe,{checked:b,onChange:V,disabled:k,ariaLabel:d("gitView.dirtySwitch.pushAfterCommit")}),s.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!k&&V(!b),children:d("gitView.dirtySwitch.pushAfterCommit")})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[s.jsxs(Y,{variant:"destructive",size:"sm",onClick:()=>{j()},disabled:k,className:"gap-2",children:[S==="revert"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):null,d("gitView.dirtySwitch.revertAndSwitch")]}),s.jsxs(Y,{variant:"default",size:"sm",onClick:()=>{o()},disabled:k,className:"gap-2",children:[S==="commit"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):null,d("gitView.dirtySwitch.commitAndSwitch")]})]})]})})})};export{Qe as C,Je as D,Ze as a};
1
+ import{R as N,f as oe,j as s}from"./vendor-react-BUCujlKS.js";import{u as ze}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{f as J,aw as Ee,a9 as be,aa as ye,I as E,ab as we,h as Z,B as Y,a4 as Te,hn as Ie,bN as fe,bO as ue,bP as pe,bQ as ge,bR as xe,bS as ve,bd as Me,c9 as Re,t as ae}from"./useAppFontEffects-Cwyhjfl5.js";import{u as ke}from"./index-BD8ILbxF.js";const Se={"?":{code:"?",color:"var(--status-info)",description:"Untracked file"},A:{code:"A",color:"var(--status-success)",description:"New file"},D:{code:"D",color:"var(--status-error)",description:"Deleted file"},R:{code:"R",color:"var(--status-info)",description:"Renamed file"},C:{code:"C",color:"var(--status-info)",description:"Copied file"},M:{code:"M",color:"var(--status-warning)",description:"Modified file"}},Pe=Se.M;function Fe(p){const e=p.index?.trim(),t=p.working_dir?.trim();return e&&e!=="?"?e.charAt(0):t?t.charAt(0):e?.charAt(0)||t?.charAt(0)||"M"}function He(p){const e=Fe(p);return Se[e]??Pe}const $e=N.memo(function(e){const t=oe.c(58),{file:r,actionLabel:w,actionSymbol:x,onAction:g,onViewDiff:d,onRevert:a,isReverting:h,stats:S,rowPaddingClassName:f,indentPx:b,actionAtStart:V,showRevert:k}=e,v=b===void 0?0:b,o=V===void 0?!1:V,j=k===void 0?!0:k;let c;t[0]!==r?(c=He(r),t[0]=r,t[1]=c):c=t[1];const u=c,{t:I}=J(),H=u.description,P=S?.insertions??0,A=S?.deletions??0;let z;t[2]!==g||t[3]!==d?(z=U=>{U.key===" "?(U.preventDefault(),g()):U.key==="Enter"&&(U.preventDefault(),d())},t[2]=g,t[3]=d,t[4]=z):z=t[4];const T=z;let M;t[5]!==g?(M=U=>{U.preventDefault(),U.stopPropagation(),g()},t[5]=g,t[6]=M):M=t[6];const y=M;let $;t[7]!==a?($=U=>{U.preventDefault(),U.stopPropagation(),a()},t[7]=a,t[8]=$):$=t[8];const W=$;let L;t[9]!==w||t[10]!==x||t[11]!==y?(L=s.jsx("button",{type:"button",onClick:y,className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":w,title:w,children:x}),t[9]=w,t[10]=x,t[11]=y,t[12]=L):L=t[12];const F=L,X=`group flex items-center gap-2 py-1.5 cursor-pointer ${f??"px-3"}`;let R;t[13]!==v?(R=v>0?{paddingLeft:`${v}px`}:void 0,t[13]=v,t[14]=R):R=t[14];const q=o?F:null;let K;t[15]!==u.color?(K={color:u.color},t[15]=u.color,t[16]=K):K=t[16];let O;t[17]!==u.code||t[18]!==H||t[19]!==K?(O=s.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:K,title:H,"aria-label":H,children:u.code}),t[17]=u.code,t[18]=H,t[19]=K,t[20]=O):O=t[20];let G;t[21]!==r.path?(G=s.jsx(Ee,{filePath:r.path,className:"h-3.5 w-3.5 shrink-0"}),t[21]=r.path,t[22]=G):G=t[22];let _;if(t[23]!==r.path){e:{const U=r.path.lastIndexOf("/");if(U===-1){let ne;t[25]===Symbol.for("react.memo_cache_sentinel")?(ne={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[25]=ne):ne=t[25],_=s.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:ne,title:r.path,children:r.path});break e}const Ae=r.path.slice(0,U),De=r.path.slice(U);let te;t[26]===Symbol.for("react.memo_cache_sentinel")?(te={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[26]=te):te=t[26];let se;t[27]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx("span",{className:"text-muted-foreground",children:"/"}),t[27]=se):se=t[27];const ce=s.jsx("span",{className:"text-foreground",children:De.slice(1)});let ie;t[28]!==ce?(ie=s.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[se,ce]}),t[28]=ce,t[29]=ie):ie=t[29],_=s.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:r.path,children:[s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:te,children:Ae}),ie]})}t[23]=r.path,t[24]=_}else _=t[24];let Q;t[30]===Symbol.for("react.memo_cache_sentinel")?(Q={color:"var(--status-success)"},t[30]=Q):Q=t[30];let i;t[31]!==P?(i=s.jsxs("span",{style:Q,children:["+",P]}),t[31]=P,t[32]=i):i=t[32];let n,l;t[33]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),l={color:"var(--status-error)"},t[33]=n,t[34]=l):(n=t[33],l=t[34]);let m;t[35]!==A?(m=s.jsxs("span",{style:l,children:["-",A]}),t[35]=A,t[36]=m):m=t[36];let D;t[37]!==i||t[38]!==m?(D=s.jsxs("span",{className:"shrink-0 typography-micro",children:[i,n,m]}),t[37]=i,t[38]=m,t[39]=D):D=t[39];let C;t[40]!==r.path||t[41]!==W||t[42]!==h||t[43]!==j||t[44]!==I?(C=j?s.jsxs(be,{children:[s.jsx(ye,{asChild:!0,children:s.jsx("button",{type:"button",onClick:W,disabled:h,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50","aria-label":I("gitView.changes.revertFileAria",{path:r.path}),children:h?s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(E,{name:"arrow-go-back",className:"size-3.5"})})}),s.jsx(we,{sideOffset:8,children:I("gitView.changes.revertFileTooltip")})]}):null,t[40]=r.path,t[41]=W,t[42]=h,t[43]=j,t[44]=I,t[45]=C):C=t[45];const B=o?null:F;let ee;return t[46]!==T||t[47]!==d||t[48]!==R||t[49]!==q||t[50]!==O||t[51]!==G||t[52]!==_||t[53]!==D||t[54]!==C||t[55]!==B||t[56]!==X?(ee=s.jsxs("div",{className:X,role:"button",tabIndex:0,onClick:d,onKeyDown:T,style:R,children:[q,O,G,_,D,C,B]}),t[46]=T,t[47]=d,t[48]=R,t[49]=q,t[50]=O,t[51]=G,t[52]=_,t[53]=D,t[54]=C,t[55]=B,t[56]=X,t[57]=ee):ee=t[57],ee}),je=14,Ve=p=>p.replace(/\\/g,"/").replace(/^\/+/,"").trim(),Ne=(p,e)=>({id:`dir:${p}`,path:p,name:e,children:new Map,directFiles:[],files:[]}),Le=p=>{const e=Ne("","");for(const t of p){const r=Ve(t.path);if(!r)continue;const x=r.split("/").filter(Boolean).slice(0,-1);let g=e;if(g.files.push(t),x.length>0){let d="";for(const a of x){d=d?`${d}/${a}`:a;const h=g.children.get(a);if(h){h.files.push(t),g=h;continue}const S=Ne(d,a);S.files.push(t),g.children.set(a,S),g=S}}g.directFiles.push(t)}return e},Oe=(p,e)=>{const t=[],r=(w,x)=>{const g=Array.from(w.children.values()).sort((a,h)=>a.path.localeCompare(h.path));for(const a of g)t.push({key:a.id,kind:"directory",depth:x,directory:a}),e.has(a.path)&&r(a,x+1);const d=[...w.directFiles].sort((a,h)=>a.path.localeCompare(h.path));for(const a of d)t.push({key:`file:${Ve(a.path)}`,kind:"file",depth:x,file:a})};return r(p,0),t},Ge=1e3,Ce=34,de=30,le="pl-0 pr-2",me=(p,e)=>`${p} ${e}`,Qe=({groups:p,diffStats:e,revertingPaths:t,isRevertingAll:r=!1,headerBackgroundClassName:w="bg-sidebar",onVisiblePathsChange:x,onRevertAll:g,onRevertDirectory:d})=>{const{t:a}=J(),h=N.useRef(null),f=ke(i=>i.gitChangesViewMode)==="tree",b=N.useMemo(()=>p.filter(i=>i.entries.length>0),[p]),[V,k]=N.useState(new Set),[v,o]=N.useState(new Set),[j,c]=N.useState(!1),[u,I]=N.useState(null),H=N.useMemo(()=>b.map(i=>Le(i.entries)),[b]),P=N.useMemo(()=>{const i=[];return b.forEach((n,l)=>{Array.from(H[l]?.children.values()??[]).forEach(m=>{i.push(me(n.id,m.path))})}),i},[H,b]);N.useEffect(()=>{f&&o(i=>{const n=new Set,l=new Set(P);return i.forEach(m=>{(m.slice(m.indexOf(" ")+1).includes("/")||l.has(m))&&n.add(m)}),P.forEach(m=>n.add(m)),n})},[f,P]);const A=N.useMemo(()=>{const i=[];return b.forEach((n,l)=>{if(i.push({type:"header",key:`header:${n.id}`,groupIndex:l}),!V.has(n.id)){if(f){const m=new Set;v.forEach(C=>{C.startsWith(`${n.id} `)&&m.add(C.slice(n.id.length+1))}),Oe(H[l],m).forEach(C=>{C.kind==="file"?i.push({type:"file",key:`${n.id}:${C.key}`,groupIndex:l,file:C.file,depth:C.depth}):i.push({type:"directory",key:`${n.id}:${C.key}`,groupIndex:l,directory:C.directory,depth:C.depth})});return}n.entries.forEach(m=>{i.push({type:"file",key:`${n.id}:file:${m.path}`,groupIndex:l,file:m,depth:0})})}}),g&&b.length>0&&i.push({type:"revert-all",key:"revert-all"}),i},[V,v,f,g,H,b]),z=A.length,T=z>=Ge,M=ze({count:z,enabled:T,getScrollElement:()=>h.current,estimateSize:()=>Ce,overscan:12,getItemKey:i=>A[i]?.key??i}),y=M.getVirtualItems(),$=N.useMemo(()=>{if(!T)return 0;const i=h.current?.scrollTop??0;return y.find(l=>l.end>i)?.index??0},[T,y,h]);N.useEffect(()=>{if(!x)return;const i=n=>n&&n.type==="file"?n.file.path:null;if(z===0){x([]);return}if(!T){const n=[];for(const l of A)if(l.type==="file"&&(n.push(l.file.path),n.length>=de))break;x(n);return}x(A.slice($,$+Math.ceil((h.current?.clientHeight??0)/Ce)+de).map(n=>i(n)).filter(n=>!!n).slice(0,de))},[x,z,A,T,$]);const W=N.useCallback(i=>{k(n=>{const l=new Set(n);return l.has(i)?l.delete(i):l.add(i),l})},[]),L=N.useCallback((i,n)=>{o(l=>{const m=new Set(l),D=me(i,n);return m.has(D)?m.delete(D):m.add(D),m})},[]),F=N.useMemo(()=>{const i=new Set;return b.forEach(n=>n.entries.forEach(l=>i.add(l.path))),Array.from(i)},[b]),X=F.length,R=u?r||u.paths.some(i=>t.has(i)):!1,q=N.useCallback(async()=>{!g||r||F.length===0||(await g(F),c(!1))},[F,r,g]),K=N.useCallback(async()=>{!d||!u||R||(await d(u.paths),I(null))},[R,d,u]),O=N.useCallback((i,n)=>{const l=V.has(i.id),m=i.entries.length;return s.jsxs("div",{className:Z("sticky top-0 z-10 flex items-center gap-2 py-2",w,le,!n&&"mt-1 border-t border-border/40"),children:[s.jsx("button",{type:"button",onClick:()=>i.onActionAll(i.entries.map(D=>D.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":i.actionAllLabel,title:i.actionAllLabel,children:i.actionSymbol}),s.jsxs("button",{type:"button",onClick:()=>W(i.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-expanded":!l,children:[s.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:i.title}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:m}),s.jsx(E,{name:"arrow-down-s",className:Z("size-3.5 shrink-0 text-muted-foreground transition-transform",l&&"-rotate-90")})]})]})},[V,w,W]),G=N.useCallback((i,n,l)=>{const m=v.has(me(i.id,n.path)),D=n.files.map(B=>B.path),C=r||D.some(B=>t.has(B));return s.jsxs("div",{className:Z("group flex items-center gap-2 py-1.5",le),style:{paddingLeft:`${l*je}px`},children:[s.jsxs("button",{type:"button",onClick:()=>L(i.id,n.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":m?a("gitView.changes.collapseDirectoryAria",{path:n.path}):a("gitView.changes.expandDirectoryAria",{path:n.path}),children:[m?s.jsx(E,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):s.jsx(E,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:n.path,children:n.name}),s.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:n.files.length})]}),i.showRevertActions!==!1&&d?s.jsx("button",{type:"button",onClick:()=>I({path:n.path,paths:D,count:D.length}),disabled:C,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":a("gitView.changes.revertDirectoryAria",{path:n.path}),title:a("gitView.changes.revertDirectoryTooltip"),children:C?s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(E,{name:"arrow-go-back",className:"size-3.5"})}):null,s.jsx("button",{type:"button",onClick:()=>i.onActionAll(n.files.map(B=>B.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":a(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),title:a(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),children:i.actionSymbol})]})},[v,r,d,t,a,L]),_=N.useCallback((i,n)=>{if(i.type==="revert-all")return s.jsx("div",{className:Z("flex justify-end py-2",le),children:s.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>c(!0),disabled:r,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[s.jsx(E,{name:"arrow-go-back",className:"size-3.5"}),a("gitView.changes.revertAll")]})});const l=b[i.groupIndex];if(!l)return null;if(i.type==="header")return O(l,n);if(i.type==="directory")return G(l,i.directory,i.depth);const m=i.file;return s.jsx($e,{file:m,actionLabel:l.getActionLabel(m.path),actionSymbol:l.actionSymbol,onAction:()=>l.onActionFile(m.path),stats:e?.[m.path],onViewDiff:()=>l.onViewDiff(m.path),onRevert:()=>l.onRevertFile(m.path),isReverting:t.has(m.path)||r,rowPaddingClassName:le,indentPx:i.depth*je,actionAtStart:!f,showRevert:l.showRevertActions!==!1})},[e,r,f,G,O,t,a,b]),Q=N.useCallback(i=>{const n=A[i],l=A[i-1];return!n||!l||n.type!=="file"&&n.type!=="directory"||l.type!=="file"&&l.type!=="directory"?!1:l.groupIndex===n.groupIndex},[A]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[s.jsx(Te,{ref:h,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:T?s.jsx("div",{style:{height:M.getTotalSize(),position:"relative"},children:y.map(i=>{const n=A[i.index];return n?s.jsx("div",{"data-index":i.index,ref:M.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${i.start}px)`},className:Z(Q(i.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:_(n,i.index===0)},n.key):null})}):s.jsx("div",{role:"list","aria-label":a("gitView.changes.changedFilesAria"),children:A.map((i,n)=>s.jsx("div",{className:Z("relative",Q(n)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:_(i,n===0)},i.key))})}),s.jsx(Ie,{containerRef:h,disableHorizontal:!0})]}),s.jsx(fe,{open:j,onOpenChange:i=>{!r&&!i&&c(!1)},children:s.jsxs(ue,{className:"max-w-md",children:[s.jsxs(pe,{children:[s.jsx(ge,{children:a("gitView.changes.revertAllDialogTitle")}),s.jsx(xe,{children:X===1?a("gitView.changes.revertAllDescriptionSingle",{count:X}):a("gitView.changes.revertAllDescriptionPlural",{count:X})})]}),s.jsxs(ve,{children:[s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>c(!1),disabled:r,children:a("gitView.common.cancel")}),s.jsx(Y,{variant:"destructive",size:"sm",onClick:()=>{q()},disabled:r,children:a(r?"gitView.changes.reverting":"gitView.changes.revertAll")})]})]})}),s.jsx(fe,{open:!!u,onOpenChange:i=>{!R&&!i&&I(null)},children:s.jsxs(ue,{className:"max-w-md",children:[s.jsxs(pe,{children:[s.jsx(ge,{children:a("gitView.changes.revertDirectoryDialogTitle")}),s.jsx(xe,{children:u?u.count===1?a("gitView.changes.revertDirectoryDescriptionSingle",{count:u.count,path:u.path}):a("gitView.changes.revertDirectoryDescriptionPlural",{count:u.count,path:u.path}):null})]}),s.jsxs(ve,{children:[s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>I(null),disabled:R,children:a("gitView.common.cancel")}),s.jsx(Y,{variant:"destructive",size:"sm",onClick:()=>{K()},disabled:R||!u,children:a(R?"gitView.changes.reverting":"gitView.changes.revertDirectory")})]})]})})]})},he=38,re=200,Ke=p=>{const e=oe.c(23),{value:t,onChange:r,onSubmit:w,placeholder:x,disabled:g,hasTouchInput:d,isMobile:a}=p,h=g===void 0?!1:g,S=d===void 0?!1:d,f=a===void 0?!1:a,{t:b}=J(),V=N.useRef(null),k=ke(_e);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{const y=V.current;if(!y)return;const $=document.activeElement===y,W=()=>{y.style.height=`${he}px`;const F=y.scrollHeight,X=Math.min(Math.max(F,he),re);y.style.height=`${X}px`,y.style.overflowY=F>re?"auto":"hidden",F>re&&!$&&(y.scrollTop=y.scrollHeight)};W();const L=window.requestAnimationFrame(W);return()=>{window.cancelAnimationFrame(L)}},e[0]=v):v=e[0];let o;e[1]!==t?(o=[t],e[1]=t,e[2]=o):o=e[2],N.useLayoutEffect(v,o);let j;e[3]!==r?(j=y=>r(y.target.value),e[3]=r,e[4]=j):j=e[4];let c;e[5]!==w?(c=y=>{y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&!y.shiftKey&&!y.altKey&&(y.preventDefault(),w?.())},e[5]=w,e[6]=c):c=e[6];let u;e[7]!==x||e[8]!==b?(u=x??b("gitView.commit.messagePlaceholder"),e[7]=x,e[8]=b,e[9]=u):u=e[9];const I=S?"on":"off",H=S?"sentences":"off",P=f||k,A=h&&"opacity-50";let z;e[10]!==A?(z=Z("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",A),e[10]=A,e[11]=z):z=e[11];let T;e[12]===Symbol.for("react.memo_cache_sentinel")?(T={minHeight:he,maxHeight:re},e[12]=T):T=e[12];let M;return e[13]!==h||e[14]!==H||e[15]!==P||e[16]!==z||e[17]!==j||e[18]!==c||e[19]!==u||e[20]!==I||e[21]!==t?(M=s.jsx("textarea",{ref:V,value:t,onChange:j,onKeyDown:c,placeholder:u,rows:1,disabled:h,autoCorrect:I,autoCapitalize:H,spellCheck:P,className:z,style:T}),e[13]=h,e[14]=H,e[15]=P,e[16]=z,e[17]=j,e[18]=c,e[19]=u,e[20]=I,e[21]=t,e[22]=M):M=e[22],M};function _e(p){return p.inputSpellcheckEnabled}const Be=p=>{const e=oe.c(30),{highlights:t,onInsert:r}=p,{t:w}=J();if(t.length===0)return null;let x;e[0]!==t||e[1]!==r?(x=()=>{r(t)},e[0]=t,e[1]=r,e[2]=x):x=e[2];const g=x;let d;e[3]!==w?(d=w("gitView.commit.aiHighlights.title"),e[3]=w,e[4]=d):d=e[4];let a;e[5]!==d?(a=s.jsx("p",{className:"typography-micro text-muted-foreground",children:d}),e[5]=d,e[6]=a):a=e[6];let h;e[7]!==w?(h=w("gitView.commit.aiHighlights.insertAria"),e[7]=w,e[8]=h):h=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(E,{name:"arrow-down",className:"size-4"}),e[9]=S):S=e[9];let f;e[10]!==g||e[11]!==h?(f=s.jsx(ye,{asChild:!0,children:s.jsx(Y,{variant:"ghost",size:"icon",className:"size-6",onClick:g,"aria-label":h,children:S})}),e[10]=g,e[11]=h,e[12]=f):f=e[12];let b;e[13]!==w?(b=w("gitView.commit.aiHighlights.insertTooltip"),e[13]=w,e[14]=b):b=e[14];let V;e[15]!==b?(V=s.jsx(we,{sideOffset:8,children:b}),e[15]=b,e[16]=V):V=e[16];let k;e[17]!==f||e[18]!==V?(k=s.jsxs(be,{children:[f,V]}),e[17]=f,e[18]=V,e[19]=k):k=e[19];let v;e[20]!==a||e[21]!==k?(v=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a,k]}),e[20]=a,e[21]=k,e[22]=v):v=e[22];let o;e[23]!==t?(o=t.map(Ue),e[23]=t,e[24]=o):o=e[24];let j;e[25]!==o?(j=s.jsx("ul",{className:"space-y-1",children:o}),e[25]=o,e[26]=j):j=e[26];let c;return e[27]!==v||e[28]!==j?(c=s.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[v,j]}),e[27]=v,e[28]=j,e[29]=c):c=e[29],c};function Ue(p,e){return s.jsx("li",{className:"typography-meta text-foreground",children:p},`${p}-${e}`)}const Ze=p=>{const e=oe.c(80),{stagedCount:t,commitMessage:r,onCommitMessageChange:w,generatedHighlights:x,onInsertHighlights:g,onGenerateMessage:d,isGeneratingMessage:a,onCommit:h,onCommitAndPush:S,commitAction:f,hasPendingIndexMutation:b,gitmojiEnabled:V,onOpenGitmojiPicker:k}=p,v=b===void 0?!1:b,{t:o}=J(),j=t>0;let c;e[0]!==f||e[1]!==r||e[2]!==v||e[3]!==j?(c=r.trim()&&j&&f===null&&!v,e[0]=f,e[1]=r,e[2]=v,e[3]=j,e[4]=c):c=e[4];const u=c,{isMobile:I,hasTouchInput:H}=Me();let P;e[5]!==o?(P=o("gitView.commit.title"),e[5]=o,e[6]=P):P=e[6];let A;e[7]!==P?(A=s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:P}),e[7]=P,e[8]=A):A=e[8];let z;e[9]!==j||e[10]!==o?(z=j?null:s.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:o("gitView.commit.stageFilesHint")}),e[9]=j,e[10]=o,e[11]=z):z=e[11];let T;e[12]!==A||e[13]!==z?(T=s.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[A,z]}),e[12]=A,e[13]=z,e[14]=T):T=e[14];let M;e[15]!==x||e[16]!==g?(M=s.jsx(Be,{highlights:x,onInsert:g}),e[15]=x,e[16]=g,e[17]=M):M=e[17];let y;e[18]!==u||e[19]!==a||e[20]!==h?(y=()=>{u&&!a&&h()},e[18]=u,e[19]=a,e[20]=h,e[21]=y):y=e[21];let $;e[22]!==o?($=o("gitView.commit.messagePlaceholder"),e[22]=o,e[23]=$):$=e[23];const W=f!==null;let L;e[24]!==r||e[25]!==H||e[26]!==I||e[27]!==w||e[28]!==W||e[29]!==y||e[30]!==$?(L=s.jsx(Ke,{value:r,onChange:w,onSubmit:y,placeholder:$,disabled:W,hasTouchInput:H,isMobile:I}),e[24]=r,e[25]=H,e[26]=I,e[27]=w,e[28]=W,e[29]=y,e[30]=$,e[31]=L):L=e[31];let F;e[32]!==V||e[33]!==k||e[34]!==o?(F=V&&s.jsxs(Y,{variant:"outline",size:"sm",onClick:k,className:"w-fit",type:"button",children:[s.jsx(E,{name:"emotion-happy",className:"size-4"}),o("gitView.commit.addGitmoji")]}),e[32]=V,e[33]=k,e[34]=o,e[35]=F):F=e[35];const X=a||f!==null||v||t===0;let R;e[36]!==o?(R=o("gitView.commit.generateAria"),e[36]=o,e[37]=R):R=e[37];let q;e[38]!==a?(q=a?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4 text-primary"}),e[38]=a,e[39]=q):q=e[39];let K;e[40]!==o?(K=o("gitView.commit.generate"),e[40]=o,e[41]=K):K=e[41];let O;e[42]!==K?(O=s.jsx("span",{className:"commit-actions__label",children:K}),e[42]=K,e[43]=O):O=e[43];let G;e[44]!==d||e[45]!==X||e[46]!==R||e[47]!==q||e[48]!==O?(G=s.jsxs(Y,{variant:"outline",size:"sm",onClick:d,disabled:X,type:"button","aria-label":R,className:"commit-actions__btn",children:[q,O]}),e[44]=d,e[45]=X,e[46]=R,e[47]=q,e[48]=O,e[49]=G):G=e[49];let _;e[50]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx("div",{className:"flex-1"}),e[50]=_):_=e[50];const Q=!u||a;let i;e[51]!==o?(i=o("gitView.commit.commitAria"),e[51]=o,e[52]=i):i=e[52];let n;e[53]!==f||e[54]!==o?(n=f==="commit"?s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.committing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"git-commit",className:"size-4"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.commit")})]}),e[53]=f,e[54]=o,e[55]=n):n=e[55];let l;e[56]!==h||e[57]!==Q||e[58]!==i||e[59]!==n?(l=s.jsx(Y,{size:"sm",variant:"outline",onClick:h,disabled:Q,className:"commit-actions__btn whitespace-nowrap","aria-label":i,children:n}),e[56]=h,e[57]=Q,e[58]=i,e[59]=n,e[60]=l):l=e[60];let m;e[61]!==u||e[62]!==f||e[63]!==a||e[64]!==I||e[65]!==S||e[66]!==o?(m=I?s.jsxs(be,{children:[s.jsx(ye,{asChild:!0,children:s.jsx(Y,{variant:"default",size:"sm",onClick:()=>S(),disabled:!u||a,className:"h-7 w-7 p-0","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"arrow-up",className:"size-3.5"})})}),s.jsx(we,{side:"top",children:s.jsx("p",{children:o("gitView.commit.push")})})]}):s.jsx(Y,{size:"sm",variant:"default",onClick:()=>S(),disabled:!u||a,className:"commit-actions__btn","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.pushing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"arrow-up",className:"size-3.5"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.push")})]})}),e[61]=u,e[62]=f,e[63]=a,e[64]=I,e[65]=S,e[66]=o,e[67]=m):m=e[67];let D;e[68]!==G||e[69]!==l||e[70]!==m?(D=s.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[G,_,l,m]}),e[68]=G,e[69]=l,e[70]=m,e[71]=D):D=e[71];let C;e[72]!==L||e[73]!==F||e[74]!==D||e[75]!==M?(C=s.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[M,L,F,D]}),e[72]=L,e[73]=F,e[74]=D,e[75]=M,e[76]=C):C=e[76];let B;return e[77]!==C||e[78]!==T?(B=s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[T,C]}),e[77]=C,e[78]=T,e[79]=B):B=e[79],B},Je=({open:p,onOpenChange:e,targetBranch:t,changedFileCount:r,onCommitAndSwitch:w,onGenerateMessage:x,onRevertAndSwitch:g})=>{const{t:d}=J(),[a,h]=N.useState(""),[S,f]=N.useState(null),[b,V]=N.useState(!1),k=S!==null;N.useEffect(()=>{p||(h(""),V(!1))},[p]);const v=async()=>{f("generate");try{const c=await x();c&&h(c)}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}},o=async()=>{f("commit");try{let c=a.trim();if(!c){if(c=(await x()).trim(),!c){ae.error(d("gitView.toast.enterCommitMessage"));return}h(c)}await w(c,b)}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}},j=async()=>{f("revert");try{await g()}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}};return s.jsx(fe,{open:p,onOpenChange:c=>{k||e(c)},children:s.jsx(ue,{className:"max-w-md w-[calc(100vw-2rem)]",children:s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsxs(pe,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(E,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),s.jsx(ge,{children:d("gitView.dirtySwitch.title")})]}),s.jsx(xe,{children:r===1?d("gitView.dirtySwitch.descriptionSingle",{branch:t}):d("gitView.dirtySwitch.descriptionPlural",{branch:t,count:r})})]}),s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border/60 px-3 py-2 focus-within:border-border",children:[s.jsx("input",{value:a,onChange:c=>h(c.target.value),placeholder:d("gitView.commit.messagePlaceholder"),disabled:k,onKeyDown:c=>{c.key==="Enter"&&!k&&(c.preventDefault(),o())},className:"min-w-0 flex-1 bg-transparent typography-meta text-foreground outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"button",onClick:()=>{v()},disabled:k,"aria-label":d("gitView.commit.generate"),title:d("gitView.commit.generate"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:S==="generate"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4 text-primary"})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Re,{checked:b,onChange:V,disabled:k,ariaLabel:d("gitView.dirtySwitch.pushAfterCommit")}),s.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!k&&V(!b),children:d("gitView.dirtySwitch.pushAfterCommit")})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[s.jsxs(Y,{variant:"destructive",size:"sm",onClick:()=>{j()},disabled:k,className:"gap-2",children:[S==="revert"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):null,d("gitView.dirtySwitch.revertAndSwitch")]}),s.jsxs(Y,{variant:"default",size:"sm",onClick:()=>{o()},disabled:k,className:"gap-2",children:[S==="commit"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):null,d("gitView.dirtySwitch.commitAndSwitch")]})]})]})})})};export{Qe as C,Je as D,Ze as a};
@@ -0,0 +1,13 @@
1
+ import{f as ut,R as s,c as ei,j as n,r as ct}from"./vendor-react-BUCujlKS.js";import{Z as Ua,_ as Ka,$ as qa,a0 as Ha,t as Ye,a as lt,u as wt,dD as Ga,G as ti,A as Xa,h as ri,a5 as ni,e as Ja,dB as Ya,a4 as Qa,dC as Za}from"./index-BD8ILbxF.js";import{f as tr,y as si,ae as Si,b_ as eo,h as q,hU as to,fx as ro,V as gr,B as I,I as F,Y as no,R as so,bd as io,J as ao,ag as oo,ch as lo,en as ii,hV as ai,hW as co,hh as uo,fI as fo,t as J,l as oi,au as Cn,cc as hr,cO as mo,b as ho,hX as pr,bM as po,av as Sn,hY as li,cd as ci,ce as ui,gx as go,hZ as vo,h_ as xo,h$ as wo,bN as ki,bO as Ri,bP as Ti,bQ as Ei,bR as Vi,bS as Pi,ao as Pn,ap as Dn,aw as Gr,ar as Mn,bb as Xr,bT as kn,ax as Rn,c8 as di,a9 as Xt,aa as Jt,ab as Yt,bK as bo,bL as yo,g as Yr,bc as jo,bn as Fo}from"./useAppFontEffects-Cwyhjfl5.js";import{aa as No,K as Co,L as So,M as ko,Q as Ro,R as To}from"./runtimeEndpointReset-BhT_-c52.js";import{c as fi,s as Eo,P as Tn,C as Vo}from"./shikiHighlight-BzXUjlby.js";import{a as Po}from"./vendor-codemirror-state-C9awkmn-.js";import{E as Tt}from"./vendor-codemirror-view-CiLROUVV.js";import{V as Do,J as Mo,F as zo}from"./JsonTreeView-cmAzUTiw.js";import{ensurePierreThemeRegistered as mi,getResolvedShikiTheme as Lo}from"./appThemeRegistry-BK0dHKa6.js";import{V as Ao,W as Io}from"./Virtualizer-CZlLSacm.js";import{V as Oo}from"./Virtualizer-D_a8gKmg.js";import{a as Bo,u as Kr,b as $o,g as _o,h as Wo,i as Uo}from"./scheduledTasksApi-BEuUF_cj.js";import{D as Ko}from"./vendor-react-drawio-Ct3Q0DsD.js";import{I as qo,u as Ho,n as Go}from"./useInlineCommentController-DDkpBEU8.js";import{b as Xo}from"./CodeMirrorCommentWidgets-teB3HmBT.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-B6551dwG.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-BY_5qla_.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-BdA6bdky.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-Cb1YnICj.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./web-components-LV3vjTxy.js";import"./computeVirtualFileMetrics-BkiDSlTW.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isFilePlainText-BVuH1zH9.js";import"./registerCustomTheme-BBXUCRnG.js";function hi(i){const e=ut.c(41),{containerRef:r,filePath:o,fileContent:w}=i,{t:p}=tr(),b=si(nl),x=si(rl),v=Si(),m=eo(tl),[f,j]=s.useState(null),[N,R]=s.useState(""),[S,E]=s.useState(!1),y=s.useRef(!1),c=s.useRef(null),D=s.useRef(null),[T,M]=s.useState(null);let P;e[0]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{j(null),R(""),E(!1),y.current=!1,D.current=null,M(null)},e[0]=P):P=e[0];const V=P;let k,L;e[1]!==r?(k=()=>{const K=r.current;if(!K)return;const X=()=>{if(y.current)return;const re=window.getSelection(),ge=re?.toString().trim()??"";if(!re||!ge||re.rangeCount===0){V();return}const ne=re.getRangeAt(0);if(!K.contains(ne.commonAncestorContainer)){V();return}const Z=ne.getBoundingClientRect();D.current=ne.cloneRange(),R(ge),j({x:Z.left+Z.width/2,y:Z.top-10})},_=re=>{c.current?.contains(re.target)||y.current&&V()};return document.addEventListener("selectionchange",X),document.addEventListener("pointerdown",_),()=>{document.removeEventListener("selectionchange",X),document.removeEventListener("pointerdown",_)}},L=[r,V],e[1]=r,e[2]=k,e[3]=L):(k=e[2],L=e[3]),s.useEffect(k,L);let B;e[4]!==w?(B=K=>{const X=fe=>w.slice(0,fe).split(`
2
+ `).length,_=Zo,re=(fe,xe)=>{for(const Re of _(fe)){const Ue=w.indexOf(Re,xe);if(Ue>=0)return Ue}return-1},ge=K.length>=8?w.indexOf(K):-1;if(ge>=0){const fe=X(ge);return{start:fe,end:fe+K.split(`
3
+ `).length-1}}const ne=K.split(`
4
+ `).map(Qo).filter(Boolean);if(ne.length===0)return null;const Z=re(ne[0],0);if(Z<0)return null;const ye=X(Z);if(ne.length===1)return{start:ye,end:ye};const ve=re(ne[ne.length-1],Z);return ve<0?null:{start:ye,end:Math.max(ye,X(ve))}},e[4]=w,e[5]=B):B=e[5];const $=B;let ue;e[6]===Symbol.for("react.memo_cache_sentinel")?(ue=()=>{const K=D.current;if(!K){M(null);return}M(to(K))},e[6]=ue):ue=e[6];const de=ue;let Y,Q;e[7]!==S?(Y=()=>{if(!S)return;let K=null;const X=()=>{K===null&&(K=window.requestAnimationFrame(()=>{K=null,de()}))};return document.addEventListener("scroll",X,{capture:!0,passive:!0}),window.addEventListener("resize",X),()=>{K!==null&&window.cancelAnimationFrame(K),document.removeEventListener("scroll",X,{capture:!0}),window.removeEventListener("resize",X)}},Q=[S,de],e[7]=S,e[8]=Y,e[9]=Q):(Y=e[8],Q=e[9]),s.useEffect(Y,Q);let ae;e[10]!==N?(ae=()=>{N&&(E(!0),y.current=!0,de(),window.getSelection()?.removeAllRanges())},e[10]=N,e[11]=ae):ae=e[11];const he=ae;let oe;e[12]!==m||e[13]!==b||e[14]!==v||e[15]!==o||e[16]!==x||e[17]!==$||e[18]!==N?(oe=K=>{const X=b??(x?"draft":null);if(!N||!X||!v){V();return}const _=$(N);m({directory:v,sessionKey:X},{source:"file-quote",fileLabel:o,startLine:_?.start??0,endLine:_?.end??0,code:N,language:"",text:K.trim()}),V(),queueMicrotask(Yo)},e[12]=m,e[13]=b,e[14]=v,e[15]=o,e[16]=x,e[17]=$,e[18]=N,e[19]=oe):oe=e[19];const H=oe;if(!f)return null;let G;e[20]!==S||e[21]!==$||e[22]!==N?(G=S?$(N):null,e[20]=S,e[21]=$,e[22]=N,e[23]=G):G=e[23];const We=G;let te;e[24]!==f.x||e[25]!==f.y?(te={left:f.x,top:f.y,transform:"translate(-50%, -100%)"},e[24]=f.x,e[25]=f.y,e[26]=te):te=e[26];let pe;e[27]!==S||e[28]!==T?(pe=S&&T&&T.length>0?ei.createPortal(n.jsx("div",{className:"pointer-events-none fixed inset-0 z-40",children:T.map(Jo)}),document.body):null,e[27]=S,e[28]=T,e[29]=pe):pe=e[29];let De;e[30]!==S||e[31]!==o||e[32]!==We||e[33]!==he||e[34]!==H||e[35]!==p?(De=S?n.jsx("div",{className:"w-[min(420px,80vw)]",children:n.jsx(qo,{fileLabel:o,lineRange:We?{start:We.start,end:We.end}:void 0,onSave:H,onCancel:V})}):n.jsx("div",{className:q("flex items-center whitespace-nowrap","oc-glass-popover rounded-full border border-[var(--interactive-border)]","shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]","p-1"),children:n.jsx("button",{type:"button",onClick:he,className:q("px-3.5 py-1.5 rounded-full","text-sm font-medium","text-[var(--surface-foreground)]","hover:bg-[var(--interactive-hover)]","transition-colors duration-150"),title:p("chat.textSelection.title.commentOnSelection"),children:p("chat.textSelection.actions.comment")})}),e[30]=S,e[31]=o,e[32]=We,e[33]=he,e[34]=H,e[35]=p,e[36]=De):De=e[36];let be;return e[37]!==te||e[38]!==pe||e[39]!==De?(be=ei.createPortal(n.jsxs("div",{ref:c,className:"fixed z-50",style:te,children:[pe,De]}),document.body),e[37]=te,e[38]=pe,e[39]=De,e[40]=be):be=e[40],be}function Jo(i,e){return n.jsx("div",{className:"oc-chat-comment-rect absolute",style:{left:i.left,top:i.top,width:i.width,height:i.height}},e)}function Yo(){ro()}function Qo(i){return i.trim()}function Zo(i){const e=i.trim();return[e,e.slice(0,32),e.split(" ").slice(0,4).join(" ")].filter(el)}function el(i){return i.length>=8}function tl(i){return i.addDraft}function rl(i){return i.newSessionDraft?.open}function nl(i){return i.currentSessionId}const sl=(i,e)=>{if(!e)return null;const r=Number.parseInt(i.trim(),10);return!Number.isFinite(r)||r<1?null:Math.min(r,e.state.doc.lines)},pi=(i,e)=>{const r=i.state.doc.lineAt(e.main.head);return{lineNumber:r.number,character:e.main.head-r.from+1,selection:e}},gi=(i,e,r)=>{const o=i.state.doc.line(e),w=Math.max(1,Math.min(r,o.length+1)),p=o.from+w-1;i.dispatch({selection:Po.cursor(p),effects:Tt.scrollIntoView(p,{y:"center"})})};function il({open:i,onOpenChange:e,view:r,variant:o="overlay"}){const{t:w}=tr(),[p,b]=s.useState(""),x=s.useRef(null),v=s.useRef(!1),m=s.useRef(null),f=s.useRef(null),j=s.useMemo(()=>sl(p,r),[p,r]);s.useEffect(()=>{!i||!r||(v.current=!1,x.current=pi(r,r.state.selection),b(""))},[i,r]),s.useEffect(()=>{i&&window.requestAnimationFrame(()=>{f.current?.focus(),f.current?.select()})},[i]),s.useEffect(()=>{if(!(!i||!r||!x.current)){if(j===null){const{selection:y}=x.current;r.dispatch({selection:y,effects:Tt.scrollIntoView(y.main.from,{y:"center"})});return}gi(r,j,x.current.character)}},[j,i,r]);const N=s.useCallback(()=>{if(!r||v.current||!x.current)return;const{selection:y}=x.current;r.dispatch({selection:y,effects:Tt.scrollIntoView(y.main.from,{y:"center"})})},[r]),R=s.useCallback(y=>{y||N(),e(y)},[e,N]),S=s.useCallback(()=>{!r||j===null||!x.current||(v.current=!0,gi(r,j,x.current.character),e(!1),r.focus())},[j,e,r]);s.useEffect(()=>{if(!i)return;const y=D=>{const T=m.current,M=D.target;!T||!(M instanceof Node)||T.contains(M)||R(!1)},c=D=>{D.key==="Escape"&&(D.preventDefault(),R(!1))};return document.addEventListener("pointerdown",y,!0),document.addEventListener("keydown",c,!0),()=>{document.removeEventListener("pointerdown",y,!0),document.removeEventListener("keydown",c,!0)}},[R,i,o]);const E=s.useMemo(()=>{if(!r)return w("goToLineDialog.helper.editorUnavailable");if(j===null){const y=x.current??pi(r,r.state.selection);return w("goToLineDialog.helper.currentLineRange",{current:y.lineNumber,max:r.state.doc.lines})}return w("goToLineDialog.helper.goToLine",{line:j})},[j,w,r]);return o==="inline"?i?n.jsxs("div",{ref:m,className:"ml-1 flex h-6 items-center gap-1",children:[n.jsx(gr,{ref:f,type:"number",min:1,step:1,inputMode:"numeric",value:p,onChange:y=>b(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),S())},placeholder:w("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),n.jsx(I,{variant:"outline",size:"xs",onClick:S,disabled:!r||j===null,className:"h-6 px-2",children:w("goToLineDialog.actions.go")})]}):null:n.jsx("div",{ref:m,className:q("absolute left-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",i?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:n.jsxs("div",{className:"min-w-0",children:[n.jsx(gr,{ref:f,type:"number",min:1,step:1,inputMode:"numeric",value:p,onChange:y=>b(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),S())},placeholder:w("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-background/60 typography-ui-label"}),n.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:E})]})})}const al=(i,e)=>{const r=e.trim().toLowerCase(),o=[];if(!r)return o;const w=i.toLowerCase();let p=0;for(;;){const b=w.indexOf(r,p);if(b===-1)break;o.push({start:b,end:b+r.length}),p=b+r.length}return o},Zr="data-md-find",En="data-md-find-current",Di="rounded-[2px] bg-status-warning/30 text-foreground",ol="rounded-[2px] bg-status-warning/60 text-foreground",ll=120,cl=i=>i instanceof Element&&i.hasAttribute(Zr),ul=i=>i.target instanceof Element&&i.target.hasAttribute(Zr)?!0:[...i.addedNodes].some(e=>cl(e)),Mi=i=>{const e=new Set;i.querySelectorAll(`mark[${Zr}]`).forEach(r=>{const o=r.parentNode;o&&(o.replaceChild(document.createTextNode(r.textContent??""),r),e.add(o))}),e.forEach(r=>r.normalize())},dl=(i,e)=>{Mi(i);const r=e.trim().toLowerCase();if(!r)return[];const o=[],w=document.createTreeWalker(i,NodeFilter.SHOW_TEXT,{acceptNode(b){const x=b.parentElement;return!x||x.closest("svg, script, style")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),p=[];for(;w.nextNode();){const b=w.currentNode;b instanceof Text&&p.push(b)}for(const b of p){const x=b.nodeValue??"";if(!x)continue;const v=al(x,r);if(v.length===0)continue;const m=b.parentNode;if(!m)continue;const f=document.createDocumentFragment();let j=0;for(const N of v){N.start>j&&f.appendChild(document.createTextNode(x.slice(j,N.start)));const R=document.createElement("mark");R.setAttribute(Zr,""),R.className=Di,R.textContent=x.slice(N.start,N.end),f.appendChild(R),o.push(R),j=N.end}j<x.length&&f.appendChild(document.createTextNode(x.slice(j))),m.replaceChild(f,b)}return o},vi=({containerRef:i,open:e,onOpenChange:r,focusNonce:o,className:w})=>{const{t:p}=tr(),[b,x]=s.useState(""),[v,m]=s.useState(0),[f,j]=s.useState(0),N=s.useRef(null),R=s.useRef([]),S=s.useRef(b);S.current=b;const E=s.useRef(null),y=s.useRef(null),c=s.useCallback((k,L=!1)=>{const B=i.current;if(!B){R.current=[],m(0),j(0);return}R.current=dl(B,k);const $=R.current.length;m($),j(ue=>!L||$===0?0:Math.min(ue,$-1))},[i]),D=s.useCallback((k,L=!1)=>{E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{E.current=null,c(k,L)},ll)},[c]);s.useEffect(()=>()=>{E.current&&clearTimeout(E.current)},[]);const T=s.useCallback(()=>{r(!1);const k=y.current;y.current=null,k?.isConnected&&k.focus()},[r]);s.useEffect(()=>{const k=i.current;if(!e||!k)return;const L=new MutationObserver(B=>{!S.current.trim()||!B.some(ue=>!ul(ue))||D(S.current,!0)});return L.observe(k,{childList:!0,subtree:!0,characterData:!0}),()=>{L.disconnect(),Mi(k)}},[i,e,D]),s.useEffect(()=>{if(!e)return;const k=document.activeElement;k instanceof HTMLElement&&!y.current&&(y.current=k),N.current?.focus()},[e]),s.useEffect(()=>{e&&o>0&&(N.current?.focus(),N.current?.select())},[e,o]),s.useEffect(()=>{const k=i.current;if(!k||(k.querySelectorAll(`mark[${En}]`).forEach(B=>{B.removeAttribute(En),B.className=Di}),v===0))return;const L=R.current[Math.min(Math.max(f,0),v-1)];L&&(L.setAttribute(En,""),L.className=ol,L.scrollIntoView({block:"nearest"}))},[i,f,v]);const M=s.useCallback(()=>{j(k=>v===0?0:(k+1)%v)},[v]),P=s.useCallback(()=>{j(k=>v===0?0:(k-1+v)%v)},[v]),V=s.useCallback(k=>{k.key==="Enter"?(k.preventDefault(),k.shiftKey?P():M()):k.key==="Escape"&&(k.preventDefault(),T())},[T,M,P]);return e?n.jsxs("div",{className:q("absolute right-3 top-3 z-10 flex items-center gap-1 rounded-lg border border-border/60 bg-[var(--surface-elevated)] px-1.5 py-1 shadow-lg",w),children:[n.jsx(F,{name:"search",className:"ml-0.5 size-3.5 text-muted-foreground"}),n.jsx(gr,{ref:N,value:b,onChange:k=>{x(k.target.value),D(k.target.value)},onKeyDown:V,placeholder:p("filesView.preview.find.placeholder"),"aria-label":p("filesView.preview.find.placeholder"),className:"h-7 w-40 rounded-md px-2 py-0 text-sm md:w-56"}),n.jsx("span",{className:"min-w-12 px-1 text-center typography-micro text-muted-foreground tabular-nums","aria-live":"polite","aria-label":v>0?p("filesView.preview.find.countAria",{current:f+1,total:v}):p("filesView.preview.find.noMatches"),children:b.trim()&&v===0?p("filesView.preview.find.noMatches"):v>0?`${f+1}/${v}`:""}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:P,title:p("filesView.preview.find.previousAria"),"aria-label":p("filesView.preview.find.previousAria"),disabled:v===0,children:n.jsx(F,{name:"arrow-up",className:"size-3.5"})}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:M,title:p("filesView.preview.find.nextAria"),"aria-label":p("filesView.preview.find.nextAria"),disabled:v===0,children:n.jsx(F,{name:"arrow-down",className:"size-3.5"})}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:T,title:p("filesView.preview.find.closeAria"),"aria-label":p("filesView.preview.find.closeAria"),children:n.jsx(F,{name:"close",className:"size-3.5"})})]}):null},fl=i=>{let e=!0;return{poll:async()=>{if(!e||i.isDirty())return!1;const r=i.getLoadedContent(),o=i.getLoadedRevision();try{const w=await i.readContent();if(!e||i.isDirty()||o!==i.getLoadedRevision())return!1;if(w===r)return!0;const p=await i.readContent();return!e||i.isDirty()||p!==w||o!==i.getLoadedRevision()?!1:(i.applyContent(w),!0)}catch{return!1}},dispose:()=>{e=!1}}},ml=1,hl=(i,e)=>e.size!==i.size||e.mtimeMs!==void 0&&i.mtimeMs!==void 0&&Math.abs(e.mtimeMs-i.mtimeMs)>=ml;function xi(){const i=ut.c(8),[e]=ct.useState(pl),r=ct.useRef(!1);let o;i[0]!==e?(o=v=>{if(v==null){e.cleanUp(),r.current=!1;return}r.current||(r.current=!0,e.setup(v,v.firstElementChild??void 0))},i[0]=e,i[1]=o):o=i[1];const w=o;let p,b;i[2]!==e?(p=()=>()=>{r.current=!1,e.cleanUp()},b=[e],i[2]=e,i[3]=p,i[4]=b):(p=i[3],b=i[4]),ct.useLayoutEffect(p,b);let x;return i[5]!==w||i[6]!==e?(x={virtualizer:e,setScroller:w},i[5]=w,i[6]=e,i[7]=x):x=i[7],x}function pl(){return new Oo}const Qt=new Map,gl=100;function qr(i){const[e,r]=ct.useState(null),o=ct.useRef(null),w=ct.useRef(null),p=ct.useRef(null),b=ct.useCallback((x,v)=>{x&&v instanceof Do&&(p.current={key:i,file:v,node:x});const m=o.current,f=w.current,j=()=>{o.current===m&&(m?.(),f?.())};v?queueMicrotask(j):j()},[i]);return ct.useLayoutEffect(()=>{if(!e||!i)return;const x=Qt.get(i)??{top:0,left:0};let v=!0;const m=()=>p.current?.key===i?p.current.file:null,f=c=>p.current?.key===i?p.current.node.shadowRoot?.querySelector(`[data-line][data-line-index="${c-1}"]`):null,j=()=>{R.disconnect(),S.disconnect()},N=()=>{if(!v)return;const c=m(),D=x.line&&c?.getLinePosition(x.line.number),T=x.line&&f(x.line.number);let M=x.top;x.line&&D&&(M=(c?.top??0)+D.top-x.line.offset),x.line&&T&&(M=e.scrollTop+T.getBoundingClientRect().top-e.getBoundingClientRect().top-x.line.offset),e.scrollTop=M,e.scrollLeft=x.left,(!x.line||T)&&Math.abs(e.scrollTop-M)<1&&Math.abs(e.scrollLeft-x.left)<1&&(v=!1,j())},R=new ResizeObserver(N),S=new MutationObserver(()=>{if(v){for(const c of e.children)R.observe(c);N()}});R.observe(e);for(const c of e.children)R.observe(c);S.observe(e,{childList:!0,subtree:!0});const E=()=>{if(v)return;const c=m(),D=c?.getNumericScrollAnchor(e.scrollTop-(c.top??0)),T=D&&f(D.lineNumber),M=T?T.getBoundingClientRect().top-e.getBoundingClientRect().top:null;if(Qt.delete(i),Qt.set(i,{top:e.scrollTop,left:e.scrollLeft,line:D&&M!==null&&M>=0&&M<e.clientHeight?{number:D.lineNumber,offset:M}:void 0}),Qt.size>gl){const P=Qt.keys().next().value;P!==void 0&&Qt.delete(P)}},y=()=>{v=!1,j()};return o.current=N,w.current=E,N(),e.addEventListener("scroll",E,{passive:!0}),e.addEventListener("wheel",y,{passive:!0}),e.addEventListener("touchstart",y,{passive:!0}),e.addEventListener("pointerdown",y,{passive:!0}),e.addEventListener("keydown",y),()=>{o.current=null,w.current=null,p.current?.key===i&&(p.current=null),j(),e.removeEventListener("scroll",E),e.removeEventListener("wheel",y),e.removeEventListener("touchstart",y),e.removeEventListener("pointerdown",y),e.removeEventListener("keydown",y)}},[i,e]),{setScroller:r,restore:b}}function vl(i){return!(!i.autoSaveEnabled||!i.isDirty||!i.canWrite||i.isSaving||i.fileLoading||i.isNonEditableBinary||!i.selectedFilePath||i.loadedFilePath!==i.selectedFilePath)}function xl(i){return i.selectedFilePath?i.isDirty?!(i.fileLoading||i.loadedFilePath!==i.selectedFilePath||i.isNonEditableBinary||i.draftContent===""&&i.fileContent!==""&&i.loadedFilePath!==i.selectedFilePath):!0:!1}const zi=2e5,wl=i=>{let e=0,r=0;for(let o=0;o<i.length;o++)i.charCodeAt(o)===10&&(o>0&&i.charCodeAt(o-1)===13?e++:r++);return e>r?`\r
5
+ `:`
6
+ `},Li=i=>i.replace(/\r\n/g,`
7
+ `).replace(/\r/g,`
8
+ `),bl=i=>({content:Li(i),lineEnding:wl(i)}),yl=(i,e)=>{const r=Li(i);return e===`\r
9
+ `?r.replace(/\n/g,`\r
10
+ `):r},jl=(i,e)=>e??(i.length>zi?"view":"edit"),Fl=i=>{let e=2166136261;for(let r=0;r<i.length;r++)e^=i.charCodeAt(r),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return`${i.length}:${e.toString(16)}`},Nl='<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>';function wi(){if(typeof document>"u")return!1;const i=document.documentElement.getAttribute("data-theme");return i==="dark"||!i&&window.matchMedia("(prefers-color-scheme: dark)").matches}const Cl=s.forwardRef(function({xml:e,readOnly:r,className:o,onChange:w},p){const b=s.useRef(e),x=s.useRef(null),v=s.useRef(!1),[m,f]=s.useState(wi),j=s.useRef(e),N=s.useRef(e);N.current!==e&&(N.current=e,j.current=e,b.current=e);const R=s.useRef(m);R.current!==m&&(R.current=m,j.current=b.current);const S=s.useRef(null);s.useEffect(()=>{const c=()=>f(wi());c();const D=new MutationObserver(c);return D.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>D.disconnect()},[]),s.useEffect(()=>{const c=setTimeout(()=>{S.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(c)},[]),s.useImperativeHandle(p,()=>({getXml:()=>b.current}));const E=s.useCallback(()=>{!e&&!v.current&&(v.current=!0,setTimeout(()=>{x.current?.template({})},500))},[e]),y=s.useCallback(c=>{b.current=c.xml,w?.(c.xml)},[w]);return n.jsx("div",{ref:S,className:q("h-full w-full",o),children:n.jsx(Ko,{ref:x,xml:j.current||Nl,autosave:!0,urlParameters:{ui:r?"simple":m?"dark":"kennedy",spin:!0,libraries:!r,chrome:r,nav:r,layers:r,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:E,onAutoSave:y},m?"dark":"light")})}),Sl=i=>{const e=U(i);if(!e)return"";if(e==="/"||/^[A-Za-z]:\/$/.test(e))return e;const r=e.lastIndexOf("/");if(r<0)return e;if(r===0)return"/";const o=e.slice(0,r);return/^[A-Za-z]:$/.test(o)?`${o}/`:o},kl=i=>{const e=ut.c(8),{label:r,iconDataUrl:o}=i,[w,p]=s.useState(!1);let b;e[0]!==r?(b=r.trim().slice(0,1).toUpperCase()||"?",e[0]=r,e[1]=b):b=e[1];const x=b;if(o&&!w){let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f=()=>p(!0),e[2]=f):f=e[2];let j;return e[3]!==o?(j=n.jsx("img",{src:o,alt:"",className:"size-4 rounded-sm",onError:f}),e[3]=o,e[4]=j):j=e[4],j}let v;e[5]===Symbol.for("react.memo_cache_sentinel")?(v=q("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=v):v=e[5];let m;return e[6]!==x?(m=n.jsx("span",{className:v,children:x}),e[6]=x,e[7]=m):m=e[7],m},Rl=i=>i.slice().sort((e,r)=>e.type!==r.type?e.type==="directory"?-1:1:e.name.localeCompare(r.name)),U=i=>{if(!i)return"";const e=i.replace(/\\/g,"/"),r=e.startsWith("//");let o=e.replace(/\/+/g,"/");r&&!o.startsWith("//")&&(o=`/${o}`);const w=o==="/",p=/^[A-Za-z]:\/$/.test(o);return!w&&!p&&(o=o.replace(/\/+$/,"")),o},Tl=i=>i.startsWith("/")||i.startsWith("//")||/^[A-Za-z]:\//.test(i),er=i=>/^[A-Za-z]:\//.test(i)?i.toLowerCase():i,Qr=(i,e)=>{const r=U(e),o=U(i);if(!r||!o)return!1;const w=er(r),p=er(o);return p===w||p.startsWith(`${w}/`)},bi=(i,e)=>{const r=U(e),o=U(i);if(!Qr(o,r))return[];const p=o.slice(r.length).replace(/^\//,"").split("/"),b=[];let x=r;for(let v=0;v<p.length-1;v++)x=x?`${x}/${p[v]}`:p[v],b.push(x);return b},Jr=(i,e)=>{if(!e)return"";const r=U(e);if(!i||!Qr(r,i))return r;const o=r.slice(i.length);return o.startsWith("/")?o.slice(1):o},El=new Set(["node_modules"]),Vl=i=>{const e=ut.c(3),{status:r}=i;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=o):o=e[0];const w=o[r];let p;return e[1]!==w?(p=n.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:w}}),e[1]=w,e[2]=p):p=e[2],p},yi=i=>{const e=ut.c(11),{name:r}=i,o=s.useRef(null),w=s.useRef(null),[p,b]=s.useState(!1);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{const N=o.current,R=w.current;if(!N||!R)return;const S=()=>{b(R.scrollWidth>N.clientWidth+1)};S();const E=new ResizeObserver(S);return E.observe(N),E.observe(R),()=>{E.disconnect()}},e[0]=x):x=e[0];let v;e[1]!==r?(v=[r],e[1]=r,e[2]=v):v=e[2],s.useLayoutEffect(x,v);let m;e[3]!==r?(m=n.jsx("span",{ref:w,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:r}),e[3]=r,e[4]=m):m=e[4];let f;e[5]!==r||e[6]!==p?(f=p?n.jsxs("span",{className:"open-file-name-marquee-track",children:[n.jsx("span",{className:"open-file-name-marquee-item",children:r}),n.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:r})]}):n.jsx("span",{className:"block min-w-0 truncate",children:r}),e[5]=r,e[6]=p,e[7]=f):f=e[7];let j;return e[8]!==m||e[9]!==f?(j=n.jsxs("span",{ref:o,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[m,f]}),e[8]=m,e[9]=f,e[10]=j):j=e[10],j},Pl=i=>El.has(i),Dl=i=>{const e=U(i);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},Ml=i=>{const r=(i instanceof Error?i.message:String(i??"")).toLowerCase();return r.includes("is a directory")||r.includes("eisdir")},ji=i=>{const r=(i instanceof Error?i.message:String(i??"")).toLowerCase();return r.includes("file not found")||r.includes("enoent")||r.includes("no such file")||r.includes("does not exist")},zl=2e5,Ai=(i,e)=>n.jsx(Gr,{filePath:i,extension:e}),Vn=i=>{if(!i)return!1;const e=i.toLowerCase().split(".").pop();return e==="md"||e==="markdown"},Fi=i=>{if(!i)return!1;const e=i.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},Hr=i=>{if(!i)return!1;const e=i.toLowerCase().split(".").pop();return e==="html"||e==="htm"},Ll=i=>{const e=ut.c(76),{node:r,root:o,isExpanded:w,isActive:p,isMobile:b,isBrowserClient:x,alwaysShowActions:v,status:m,badge:f,permissions:j,downloadFile:N,contextMenuPath:R,setContextMenuPath:S,rightClickMenuPath:E,setRightClickMenuPath:y,onSelect:c,onToggle:D,onRevealPath:T,onOpenDialog:M}=i,{t:P}=tr(),V=r.type==="directory",{canRename:k,canCreateFile:L,canCreateFolder:B,canDelete:$,canReveal:ue}=j,de=!V&&!!N,Y=ue&&!x,Q=k||L||B||$||de||Y;let ae;e[0]!==Q||e[1]!==r.path||e[2]!==y?(ae=Te=>{Q&&(Te?.preventDefault(),y(r.path))},e[0]=Q,e[1]=r.path,e[2]=y,e[3]=ae):ae=e[3];const he=ae;let oe;e[4]!==V||e[5]!==r||e[6]!==c||e[7]!==D?(oe=()=>{V?D(r.path):c(r)},e[4]=V,e[5]=r,e[6]=c,e[7]=D,e[8]=oe):oe=e[8];const H=oe;let G;e[9]!==r.path||e[10]!==S||e[11]!==y?(G=Te=>{Te.stopPropagation(),y(null),S(r.path)},e[9]=r.path,e[10]=S,e[11]=y,e[12]=G):G=e[12];const We=G;let te;e[13]!==L||e[14]!==B||e[15]!==$||e[16]!==k||e[17]!==Y||e[18]!==N||e[19]!==x||e[20]!==V||e[21]!==r||e[22]!==M||e[23]!==T||e[24]!==o||e[25]!==P?(te=Te=>{const{Item:Ie,Separator:Vt}=Te;return n.jsxs(n.Fragment,{children:[k&&n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),M("rename",r)},children:[n.jsx(F,{name:"edit",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.rename")]}),n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),Yr(r.path).then(Qe=>{if(Qe.ok){J.success(P("sidebarFilesTree.toast.pathCopied"));return}J.error(P("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(F,{name:"file-copy",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.copyPath")]}),n.jsxs(Ie,{onClick:le=>{le.stopPropagation();const Qe=Jr(o,r.path)||r.path;Yr(Qe).then(Pt=>{if(Pt.ok){J.success(P("filesView.toast.relativePathCopied"));return}J.error(P("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(F,{name:"file-copy-2",className:"mr-2 size-4"})," ",P("filesView.tree.menu.copyRelativePath")]}),!V&&N&&n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),N(r.path).catch(Qe=>{console.error("Download failed:",Qe),J.error(P("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(F,{name:"download",className:"mr-2 size-4"})," ",P(x?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),Y&&n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),T(r.path)},children:[n.jsx(F,{name:"folder-received",className:"mr-2 size-4"})," ",P(Fo())]}),V&&(L||B)&&n.jsxs(n.Fragment,{children:[n.jsx(Vt,{}),L&&n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),M("createFile",r)},children:[n.jsx(F,{name:"file-add",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.newFile")]}),B&&n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),M("createFolder",r)},children:[n.jsx(F,{name:"folder-add",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.newFolder")]})]}),$&&n.jsxs(n.Fragment,{children:[n.jsx(Vt,{}),n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),M("delete",r)},className:"text-destructive focus:text-destructive",children:[n.jsx(F,{name:"delete-bin",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.delete")]})]})]})},e[13]=L,e[14]=B,e[15]=$,e[16]=k,e[17]=Y,e[18]=N,e[19]=x,e[20]=V,e[21]=r,e[22]=M,e[23]=T,e[24]=o,e[25]=P,e[26]=te):te=e[26];const pe=te,De=E===r.path;let be;e[27]!==r.path||e[28]!==y?(be=Te=>y(Te?r.path:null),e[27]=r.path,e[28]=y,e[29]=be):be=e[29];const K=b?void 0:he;let X;e[30]!==K?(X=n.jsx("div",{className:"group relative flex items-center",onContextMenu:K}),e[30]=K,e[31]=X):X=e[31];const _=b?void 0:he,re=p?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let ge;e[32]!==re?(ge=q("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",re),e[32]=re,e[33]=ge):ge=e[33];let ne;e[34]!==V||e[35]!==w||e[36]!==r.extension||e[37]!==r.path?(ne=V?w?n.jsx(F,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):n.jsx(F,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):Ai(r.path,r.extension),e[34]=V,e[35]=w,e[36]=r.extension,e[37]=r.path,e[38]=ne):ne=e[38];let Z;e[39]!==r.name||e[40]!==r.path?(Z=n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:r.path,children:r.name}),e[39]=r.name,e[40]=r.path,e[41]=Z):Z=e[41];let ye;e[42]!==V||e[43]!==m?(ye=!V&&m&&n.jsx(Vl,{status:m}),e[42]=V,e[43]=m,e[44]=ye):ye=e[44];let ve;e[45]!==f||e[46]!==V?(ve=V&&f&&n.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[f.modified>0&&n.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",f.modified]}),f.added>0&&n.jsxs("span",{className:"text-[var(--status-success)]",children:["+",f.added]})]}),e[45]=f,e[46]=V,e[47]=ve):ve=e[47];let fe;e[48]!==H||e[49]!==ge||e[50]!==ne||e[51]!==Z||e[52]!==ye||e[53]!==ve||e[54]!==_?(fe=n.jsxs("button",{type:"button",onClick:H,onContextMenu:_,className:ge,children:[ne,Z,ye,ve]}),e[48]=H,e[49]=ge,e[50]=ne,e[51]=Z,e[52]=ye,e[53]=ve,e[54]=_,e[55]=fe):fe=e[55];let xe;e[56]!==v||e[57]!==R||e[58]!==We||e[59]!==Q||e[60]!==b||e[61]!==r.path||e[62]!==pe||e[63]!==S?(xe=Q&&n.jsx("div",{className:q("absolute right-1 top-1/2 -translate-y-1/2",v?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:n.jsxs(Pn,{open:R===r.path,onOpenChange:Te=>S(Te?r.path:null),children:[n.jsx(Dn,{asChild:!0,children:n.jsx(I,{variant:"ghost",size:"icon",className:"size-6",onClick:We,children:n.jsx(F,{name:"more-2-fill",className:"size-4"})})}),n.jsx(Mn,{align:"end",side:"bottom",onCloseAutoFocus:()=>S(null),children:pe({Item:Xr,Separator:jo})})]})}),e[56]=v,e[57]=R,e[58]=We,e[59]=Q,e[60]=b,e[61]=r.path,e[62]=pe,e[63]=S,e[64]=xe):xe=e[64];let Re;e[65]!==fe||e[66]!==xe||e[67]!==X?(Re=n.jsxs(Ro,{render:X,children:[fe,xe]}),e[65]=fe,e[66]=xe,e[67]=X,e[68]=Re):Re=e[68];let Ue;e[69]!==pe?(Ue=n.jsx(Co,{className:"min-w-[180px]",children:pe({Item:ko,Separator:So})}),e[69]=pe,e[70]=Ue):Ue=e[70];let Et;return e[71]!==Re||e[72]!==Ue||e[73]!==De||e[74]!==be?(Et=n.jsxs(To,{open:De,onOpenChange:be,children:[Re,Ue]}),e[71]=Re,e[72]=Ue,e[73]=De,e[74]=be,e[75]=Et):Et=e[75],Et},Al=i=>{const e=ut.c(83),{activeDialog:r,dialogData:o,dialogInputValue:w,onDialogInputChange:p,isDialogSubmitting:b,onDialogSubmit:x,onClose:v,inputRef:m}=i,{t:f}=tr(),j=!!r;let N;e[0]!==v?(N=G=>!G&&v(),e[0]=v,e[1]=N):N=e[1];let R;e[2]!==r||e[3]!==f?(R=r==="createFile"&&f("filesView.dialog.createFile.title"),e[2]=r,e[3]=f,e[4]=R):R=e[4];let S;e[5]!==r||e[6]!==f?(S=r==="createFolder"&&f("filesView.dialog.createFolder.title"),e[5]=r,e[6]=f,e[7]=S):S=e[7];let E;e[8]!==r||e[9]!==f?(E=r==="rename"&&f("filesView.dialog.rename.title"),e[8]=r,e[9]=f,e[10]=E):E=e[10];let y;e[11]!==r||e[12]!==f?(y=r==="delete"&&f("filesView.dialog.delete.title"),e[11]=r,e[12]=f,e[13]=y):y=e[13];let c;e[14]!==R||e[15]!==S||e[16]!==E||e[17]!==y?(c=n.jsxs(Ei,{children:[R,S,E,y]}),e[14]=R,e[15]=S,e[16]=E,e[17]=y,e[18]=c):c=e[18];let D;e[19]!==r||e[20]!==o?.path||e[21]!==f?(D=r==="createFile"&&f("filesView.dialog.createFile.description",{path:o?.path??f("filesView.dialog.rootFallback")}),e[19]=r,e[20]=o?.path,e[21]=f,e[22]=D):D=e[22];let T;e[23]!==r||e[24]!==o?.path||e[25]!==f?(T=r==="createFolder"&&f("filesView.dialog.createFolder.description",{path:o?.path??f("filesView.dialog.rootFallback")}),e[23]=r,e[24]=o?.path,e[25]=f,e[26]=T):T=e[26];let M;e[27]!==r||e[28]!==o?.name||e[29]!==f?(M=r==="rename"&&f("filesView.dialog.rename.description",{name:o?.name??""}),e[27]=r,e[28]=o?.name,e[29]=f,e[30]=M):M=e[30];let P;e[31]!==r||e[32]!==o?.name||e[33]!==f?(P=r==="delete"&&f("filesView.dialog.delete.description",{name:o?.name??""}),e[31]=r,e[32]=o?.name,e[33]=f,e[34]=P):P=e[34];let V;e[35]!==M||e[36]!==P||e[37]!==D||e[38]!==T?(V=n.jsxs(Vi,{children:[D,T,M,P]}),e[35]=M,e[36]=P,e[37]=D,e[38]=T,e[39]=V):V=e[39];let k;e[40]!==V||e[41]!==c?(k=n.jsxs(Ti,{children:[c,V]}),e[40]=V,e[41]=c,e[42]=k):k=e[42];let L;e[43]!==r||e[44]!==w||e[45]!==m||e[46]!==p||e[47]!==x||e[48]!==f?(L=r!=="delete"&&n.jsx("div",{className:"py-4",children:n.jsx(gr,{value:w,onChange:G=>p(G.target.value),placeholder:f(r==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:G=>{G.key==="Enter"&&x()},ref:m})}),e[43]=r,e[44]=w,e[45]=m,e[46]=p,e[47]=x,e[48]=f,e[49]=L):L=e[49];let B;e[50]!==f?(B=f("filesView.dialog.cancel"),e[50]=f,e[51]=B):B=e[51];let $;e[52]!==b||e[53]!==v||e[54]!==B?($=n.jsx(I,{variant:"outline",onClick:v,disabled:b,children:B}),e[52]=b,e[53]=v,e[54]=B,e[55]=$):$=e[55];const ue=r==="delete"?"destructive":"default";let de;e[56]!==x?(de=()=>{x()},e[56]=x,e[57]=de):de=e[57];let Y;e[58]!==r||e[59]!==w||e[60]!==b?(Y=b||r!=="delete"&&!w.trim(),e[58]=r,e[59]=w,e[60]=b,e[61]=Y):Y=e[61];let Q;e[62]!==r||e[63]!==b||e[64]!==f?(Q=b?n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):f(r==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=r,e[63]=b,e[64]=f,e[65]=Q):Q=e[65];let ae;e[66]!==ue||e[67]!==de||e[68]!==Y||e[69]!==Q?(ae=n.jsx(I,{variant:ue,onClick:de,disabled:Y,children:Q}),e[66]=ue,e[67]=de,e[68]=Y,e[69]=Q,e[70]=ae):ae=e[70];let he;e[71]!==$||e[72]!==ae?(he=n.jsxs(Pi,{children:[$,ae]}),e[71]=$,e[72]=ae,e[73]=he):he=e[73];let oe;e[74]!==m||e[75]!==k||e[76]!==L||e[77]!==he?(oe=n.jsxs(Ri,{initialFocus:m,children:[k,L,he]}),e[74]=m,e[75]=k,e[76]=L,e[77]=he,e[78]=oe):oe=e[78];let H;return e[79]!==j||e[80]!==N||e[81]!==oe?(H=n.jsx(ki,{open:j,onOpenChange:N,children:oe}),e[79]=j,e[80]=N,e[81]=oe,e[82]=H):H=e[82],H},Zt=new Map,Il=100,Ni=i=>{const e=ut.c(13);let r,o,w;e[0]!==i?({positionKey:o,onViewReady:r,...w}=i,e[0]=i,e[1]=r,e[2]=o,e[3]=w):(r=e[1],o=e[2],w=e[3]);const p=s.useRef(null);let b,x;e[4]!==o?(b=()=>()=>{const f=p.current;if(!f)return;const{anchor:j,head:N}=f.state.selection.main;if(Zt.delete(o),Zt.set(o,{scroll:f.scrollSnapshot(),anchor:j,head:N}),Zt.size>Il){const R=Zt.keys().next().value;R!==void 0&&Zt.delete(R)}},x=[o],e[4]=o,e[5]=b,e[6]=x):(b=e[5],x=e[6]),s.useLayoutEffect(b,x);let v;e[7]!==r||e[8]!==o?(v=f=>{p.current=f;const j=Zt.get(o);j&&f.dispatch({selection:{anchor:Math.min(j.anchor,f.state.doc.length),head:Math.min(j.head,f.state.doc.length)},effects:j.scroll}),r?.(f)},e[7]=r,e[8]=o,e[9]=v):v=e[9];let m;return e[10]!==w||e[11]!==v?(m=n.jsx(Vo,{...w,onViewReady:v}),e[10]=w,e[11]=v,e[12]=m):m=e[12],m},Ci=(i,e,r)=>{const o=ut.c(8),[w,p]=s.useState(""),[b,x]=s.useState(0);let v,m;o[0]!==i||o[1]!==r||o[2]!==e?(v=()=>{if(!i){p("");return}let j=!1;p("");const N=Ja(),R=Ya(N);Qa(N).then(E=>{j||!E||(p(i),e(null))}).catch(E=>{j||(e(E instanceof Error?E.message:r),p(i))});const S=Za(()=>{j||(p(i),x(Ol),e(null))});return()=>{j=!0,R(),S()}},m=[i,e,r],o[0]=i,o[1]=r,o[2]=e,o[3]=v,o[4]=m):(v=o[3],m=o[4]),s.useEffect(v,m);let f;return o[5]!==b||o[6]!==w?(f={readyKey:w,nonce:b},o[5]=b,o[6]=w,o[7]=f):f=o[7],f},sd=({mode:i="full",visible:e=!0})=>{const{t:r}=tr(),{files:o,runtime:w}=no(),{currentTheme:p,availableThemes:b,lightThemeId:x,darkThemeId:v}=so(),{isMobile:m,isTablet:f,screenWidth:j}=io(),N=Ua(w.platform),R=m||f,S=Ka(),E=qa(),y=Si()??"",c=U(y.trim()),D=m||i==="full",T=D&&e,M=ao(t=>t.runtimeKey),P=JSON.stringify([M,c]),V=s.useRef(P);V.current=P;const k=JSON.stringify([M,c,S,E]),L=s.useRef(k);L.current=k;const B=i!=="editor-only",$=i==="editor-only"&&!m,ue=Ha(t=>t.searchFiles),de=oo(T?y:null),[Y,Q]=s.useState(""),ae=lo(Y,200),he=s.useRef(null),[oe,H]=s.useState(!1),[G,We]=s.useState(!0),[te,pe]=s.useState(!1),[De,be]=s.useState(!1),K=s.useRef(0),X=s.useCallback(t=>{K.current=Math.max(0,K.current+(t?1:-1))},[]),[_,re]=s.useState("edit"),[ge,ne]=s.useState("edit"),[Z,ye]=s.useState("tree"),[ve,fe]=s.useState("edit"),[xe,Re]=s.useState("preview"),[Ue,Et]=s.useState(0),Te=s.useRef({}),Ie=s.useRef({}),Vt=s.useRef({}),le=s.useRef({}),Qe=s.useMemo(()=>b.find(t=>t.metadata.id===x)??ii(!1),[b,x]),Pt=s.useMemo(()=>b.find(t=>t.metadata.id===v)??ii(!0),[b,v]);s.useEffect(()=>{mi(Qe),mi(Pt)},[Qe,Pt]);const vr=s.useMemo(()=>[],[]),je=Ye(t=>c?t.byRoot[c]?.openPaths??vr:vr),bt=Ye(t=>c?t.byRoot[c]?.selectedPath??null:null),Ze=Ye(t=>c?t.byRoot[c]?.expandedPaths??vr:vr),Ii=s.useMemo(()=>new Set(Ze),[Ze]),Dt=Ye(t=>t.removeOpenPath),dt=Ye(t=>t.removeOpenPathsByPrefix),zn=Ye(t=>t.removeExpandedPathsByPrefix),Fe=Ye(t=>t.setSelectedPath),Ln=Ye(t=>t.toggleExpandedPath),xr=Ye(t=>t.expandPaths),Mt=s.useCallback(t=>{const a=U(t),l=a.split("/"),d=l[l.length-1]||a,h=d.includes(".")?d.split(".").pop()?.toLowerCase():void 0;return{name:d,path:a,type:"file",extension:h}},[]),zt=s.useMemo(()=>je.map(Mt),[je,Mt]),en=s.useMemo(()=>{if(bt){const t=er(bt);if(je.some(a=>er(a)===t))return bt}return je[0]??null},[je,bt]),u=s.useMemo(()=>en?Mt(en):null,[en,Mt]),Ke=u?.path??"",[,Oi]=s.useState(0);s.useEffect(()=>{if(!c||!bt)return;const t=er(bt);je.some(l=>er(l)===t)||Fe(c,je[0]??null)},[je,c,bt,Fe]);const wr=!!(c&&Ke&&!Qr(Ke,c)),An=wr?ai(Ke):void 0,yt=s.useMemo(()=>({allowOutsideWorkspace:i==="editor-only"&&wr,outsideFileGrant:An,directory:c||void 0}),[i,wr,An,c]),et=s.useCallback(async t=>{const a=ai(t),l=await co(t,c,i==="editor-only");return l.outsideFileGrant&&l.outsideFileGrant!==a&&Oi(d=>d+1),l},[i,c]),tn=s.useRef(null),[In,Bi]=s.useState({left:!1,right:!1}),On=s.useCallback(()=>{const t=tn.current;t&&Bi({left:t.scrollLeft>2,right:t.scrollLeft+t.clientWidth<t.scrollWidth-2})},[]),Bn=s.useRef(On);Bn.current=On,s.useEffect(()=>{const t=tn.current;if(!t)return;const a=()=>Bn.current();a(),t.addEventListener("scroll",a,{passive:!0});const l=new ResizeObserver(a);return l.observe(t),()=>{t.removeEventListener("scroll",a),l.disconnect()}},[zt.length]);const[$n,rn]=s.useState({}),[br,rr]=s.useState({}),Oe=s.useRef(new Set),Ee=s.useMemo(()=>new Bo,[]);s.useEffect(()=>()=>Ee.clear(),[Ee]);const[_n,yr]=s.useState([]),[$i,jr]=s.useState(!1),[O,me]=s.useState(""),{isPlaying:Fr,play:_i,stop:Wi}=uo(),[Me,ft]=s.useState(!1),[tt,we]=s.useState(null),[Ui,Be]=s.useState(""),[Ne,ce]=s.useState(null),mt=JSON.stringify([lt(),c,Ne]),[ee,Ce]=s.useState(""),[nr,nn]=s.useState(!1),[Wn,Ki]=s.useState(`
11
+ `),qi=s.useRef(null),rt=s.useRef(null),ze=s.useRef(null),ht=s.useRef(""),sr=s.useRef(""),st=s.useRef(null),Un=s.useRef(null),qe=s.useRef(null),sn=s.useRef(""),an=s.useRef(0),Lt=s.useRef(0),jt=s.useRef(null),[Nr,Hi]=s.useState(0),[Gi,At]=s.useState("idle"),[Xi,Cr]=s.useState(!1),[Ft,Kn]=s.useState(!1),Se=wt(t=>t.autoSaveEnabled),Ji=wt(t=>t.setAutoSaveEnabled),[on,ir]=s.useState(!1),It=s.useRef(null),ar=s.useRef(null),or=s.useRef(!1),lr=s.useRef(null),cr=s.useRef(null),He=s.useRef(null),Sr=s.useRef(null),[Yi,ln]=s.useState(0),Ot=s.useRef(null),Nt=s.useRef({key:"",attempts:0});s.useEffect(()=>()=>{Ot.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(Ot.current),Ot.current=null)},[]);const[Ct,cn]=s.useState(null),[St,Qi]=s.useState(null),[pt,qn]=s.useState(""),[Zi,un]=s.useState(!1),[ea,ta]=s.useState(null),[ra,na]=s.useState(null),[sa,Hn]=s.useState(!1),[ia,Gn]=s.useState(!1),[aa,dn]=s.useState(!1),[Xn,kr]=s.useState(!1),[Jn,Yn]=s.useState(0),Rr=s.useRef(null),Tr=s.useCallback(t=>{const a=t?.currentTarget??Rr.current;if(!a)return;const l=document.activeElement;l&&l!==document.body&&l!==a&&(fo(l)||a.contains(l))||a.focus({preventScroll:!0})},[]),Er=s.useRef(null),Qn=!!o.writeFile,Zn=!!o.createDirectory,es=!!o.rename,ts=!!o.delete,rs=!!o.revealPath,oa=Kr(t=>t.availableApps),la=Kr(t=>t.isCacheStale),ns=Kr(t=>t.initialize),ca=Kr(t=>t.loadInstalledApps);s.useEffect(()=>{ns()},[ns]);const ua=s.useCallback(t=>{o.revealPath&&o.revealPath(t).catch(()=>{J.error(r("sidebarFilesTree.toast.revealFailed"))})},[o,r]),da=s.useCallback(async t=>{if(!u?.path||await Ga(u.path,t.id,t.appName)||await ti(u.path,t.appName))return;const d=Sl(u.path)||c;d&&await ti(d,t.appName)||J.error(r("filesView.toast.openInAppFailed",{app:t.appName}))},[c,u?.path,r]),fn=s.useCallback((t,a)=>{cn(t),Qi(a),qn(t==="rename"&&a.name||""),un(!1)},[]),[W,Ge]=s.useState(null),Bt=s.useRef(!1),gt=s.useRef(null),[ss,$t]=s.useState(!1),nt=wt(t=>t.pendingFileNavigation),Vr=wt(t=>t.setPendingFileNavigation),mn=wt(t=>t.pendingFileFocusPath),hn=wt(t=>t.setPendingFileFocusPath),is=wt(t=>t.fileEditorKeymap),ur=oi(t=>t.settingsDefaultFileViewerPreview),fa=oi(t=>t.showMessageTTSButtons);s.useEffect(()=>{const t=()=>{Bt.current=!1,gt.current=null,$t(!1)};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]),s.useEffect(()=>()=>{lr.current!==null&&window.clearTimeout(lr.current),cr.current!==null&&window.clearTimeout(cr.current)},[]);const ma=s.useCallback((t,a)=>{const l=t.split(`
12
+ `),d=Math.max(1,a.start),h=Math.min(l.length,a.end);return d>h?"":l.slice(d-1,h).join(`
13
+ `)},[]),as=s.useRef(null),ha=Ho({source:"file",fileLabel:u?.path??null,language:u?.path&&Cn(u.path)||"text",getCodeForRange:t=>ma(O,Go(t)),toStoreRange:t=>({startLine:t.start,endLine:t.end}),fromDraftRange:t=>({start:t.startLine,end:t.endLine})}),{drafts:os,commentText:Pr,setCommentText:ls,editingDraftId:Dr,setSelection:cs,saveComment:us,cancel:dr,reset:ds,startEdit:fs,deleteDraft:ms}=ha;s.useEffect(()=>{Ge(null),ds(),Ce(""),nn(!1)},[u?.path,ds]),s.useEffect(()=>{cs(W)},[W,cs]),s.useEffect(()=>{if(!W&&!Dr)return;const t=l=>{const d=l.target;d.closest('[data-comment-input="true"]')||d.closest('[data-comment-card="true"]')||d.closest(".cm-gutterElement")||d.closest("[data-sonner-toast]")||d.closest("[data-sonner-toaster]")||Pr.trim()||(Ge(null),dr())},a=setTimeout(()=>{document.addEventListener("click",t)},100);return()=>{clearTimeout(a),document.removeEventListener("click",t)}},[dr,Pr,Dr,W]);const hs=s.useCallback((t,a)=>{const l=a??W??void 0;a&&Ge(a),us(t,l),Ge(null)},[W,us]),ps=s.useCallback((t,a)=>{const l=[];for(const d of a){if(!(d&&typeof d.name=="string"&&d.name.length>0)||!S&&d.name.startsWith(".")||!E&&Pl(d.name))continue;const h=d.name,g=U(d.path||""),C=g?Tl(g)?g:U(`${t}/${g}`):U(`${t}/${h}`),A=d.isDirectory?"directory":"file",se=A==="file"&&h.includes(".")?h.split(".").pop()?.toLowerCase():void 0;l.push({name:h,path:C,type:A,extension:se})}return Rl(l)},[E,S]),Ve=s.useCallback(async(t,a=!1)=>{if(!T)return;const l=U(t.trim());if(!l||!a&&Oe.current.has(l))return;const d=L.current,h=lt();return Ee.run(l,async g=>{const C=()=>g()&&L.current===d&&lt()===h;try{const A=o.listDirectory?(await o.listDirectory(l)).entries:await Xa.listLocalDirectory(l);if(!C())return;const se=ps(l,A);Oe.current=new Set(Oe.current),Oe.current.add(l),rr(z=>{if(!z[l])return z;const ie={...z};return delete ie[l],ie}),rn(z=>z[l]&&$o(z[l],se)?z:{...z,[l]:se})}catch(A){if(!C())return;const se=A instanceof Error?A.message:String(A??"");if(se==="Directory not found"&&c&&l!==c){zn(c,l),rr(z=>{if(!z[l])return z;const ie={...z};return delete ie[l],ie});return}console.error("Failed to load files directory:",A),rr(z=>({...z,[l]:se}))}},a)},[Ee,o,ps,zn,c,T]),Mr=s.useCallback(async()=>{c&&(Oe.current=new Set,Ee.clear(),rr({}),rn(t=>Object.keys(t).length===0?t:{}),await Ve(c))},[Ee,Ve,c]),$e=s.useCallback(async t=>{if(!t){await Mr();return}const a=U(t);Oe.current=new Set(Oe.current),Oe.current.delete(a),await Ve(a,!0)},[Ve,Mr]),gs=s.useRef(""),vs=s.useRef("");s.useEffect(()=>{if(!c)return;const t=k,a=gs.current!==P,l=vs.current!==t;!a&&!l||(a&&(gs.current=P,Lt.current+=1,jt.current=null,me(""),we(null),Be(""),ce(null),H(!1)),l&&(vs.current=t,Oe.current=new Set,Ee.clear(),rr({}),rn(d=>Object.keys(d).length===0?d:{}),Ve(c)))},[Ee,P,Ve,c,k]),s.useEffect(()=>{if(!T||!o.listDirectory)return;const t=()=>{if(!document.hidden&&Ze.length>0)for(const a of Ze)Ee.has(a)||$e(a)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[Ee,Ze,o.listDirectory,$e,T]);const xs=s.useRef(!1);s.useEffect(()=>{const t=T&&!xs.current;if(xs.current=T,!(!T||!c)&&(Ve(c),t))for(const a of Ze)Ee.has(a)||$e(a)},[Ee,Ze,Ve,$e,c,T]),s.useEffect(()=>{if(!T||!o.listDirectory||Ze.length===0)return;const t=setInterval(()=>{if(!document.hidden)for(const a of Ze)Ee.has(a)||$e(a)},8e3);return()=>clearInterval(t)},[Ee,Ze,o.listDirectory,$e,T]);const pa=s.useCallback(async t=>{if(t?.preventDefault(),!St||!Ct)return;un(!0);const a=()=>{cn(null)},l=h=>{J.error(h)},d=()=>{un(!1)};if(Ct==="createFile"){if(!pt.trim()){l(r("sidebarFilesTree.toast.filenameRequired")),d();return}if(!o.writeFile){l(r("sidebarFilesTree.toast.writeNotSupported")),d();return}const h=St.path,g=h?`${h}/`:"",C=U(`${g}${pt.trim()}`);await o.writeFile(C,"").then(async A=>{A.success&&(J.success(r("sidebarFilesTree.toast.fileCreated")),await $e(h)),a()}).catch(()=>l(r("sidebarFilesTree.toast.operationFailed"))).finally(d);return}if(Ct==="createFolder"){if(!pt.trim()){l(r("sidebarFilesTree.toast.folderNameRequired")),d();return}const h=St.path,g=h?`${h}/`:"",C=U(`${g}${pt.trim()}`);await o.createDirectory(C).then(async A=>{A.success&&(J.success(r("sidebarFilesTree.toast.folderCreated")),await $e(h)),a()}).catch(()=>l(r("sidebarFilesTree.toast.operationFailed"))).finally(d);return}if(Ct==="rename"){if(!pt.trim()){l(r("sidebarFilesTree.toast.nameRequired")),d();return}if(!o.rename){l(r("sidebarFilesTree.toast.renameNotSupported")),d();return}const h=St.path,g=h.split("/").slice(0,-1).join("/"),C=g?`${g}/`:"",A=U(`${C}${pt.trim()}`);await o.rename(h,A).then(async se=>{se.success&&(J.success(r("sidebarFilesTree.toast.renamedSuccessfully")),await $e(g),c&&dt(c,h),(u?.path===h||u?.path.startsWith(`${h}/`))&&(c&&Fe(c,null),me(""),we(null),Be(""),ce(null),m&&H(!1))),a()}).catch(()=>l(r("sidebarFilesTree.toast.operationFailed"))).finally(d);return}if(Ct==="delete"){if(!o.delete){l(r("sidebarFilesTree.toast.deleteNotSupported")),d();return}const h=St.path,g=h.split("/").slice(0,-1).join("/");await o.delete(h).then(async C=>{C.success&&(J.success(r("sidebarFilesTree.toast.deletedSuccessfully")),await $e(g),c&&dt(c,h),(u?.path===h||u?.path.startsWith(`${h}/`))&&(c&&Fe(c,null),me(""),we(null),Be(""),ce(null),m&&H(!1))),a()}).catch(()=>l(r("sidebarFilesTree.toast.operationFailed"))).finally(d);return}d()},[Ct,St,pt,o,$e,m,dt,c,u?.path,Fe,r]);s.useEffect(()=>{if(!y){yr([]),jr(!1);return}const t=ae.trim();if(!t){yr([]),jr(!1);return}let a=!1;return jr(!0),ue(y,t,150,{includeHidden:S,respectGitignore:!E,type:"file"}).then(l=>{if(a)return;const h=l.filter(g=>E||!Dl(g.path)).map(g=>({name:g.name,path:U(g.path),type:"file",extension:g.extension,relativePath:g.relativePath}));yr(h)}).catch(()=>{a||yr([])}).finally(()=>{a||jr(!1)}),()=>{a=!0}},[y,ae,ue,S,E]);const zr=s.useCallback(async(t,a)=>{const l=await et(t);if(o.readFile)return(await o.readFile(t,{...l,directory:c||void 0,...a})).content??"";const d=new URLSearchParams({path:t});l.allowOutsideWorkspace&&d.set("allowOutsideWorkspace","true"),l.outsideFileGrant&&d.set("outsideFileGrant",l.outsideFileGrant),c&&d.set("directory",c);const h=await ri(`/api/fs/read?${d.toString()}`,a?.fresh?{cache:"no-store"}:void 0);if(!h.ok){const g=await h.json().catch(()=>({error:h.statusText}));throw new Error(g.error||r("filesView.error.readFileFailed"))}return h.text()},[o,et,c,r]),vt=s.useCallback(async t=>{if(o.statFile){const a=await et(t),l=await o.statFile(t,{...a,directory:c||void 0});return{path:l.path,size:l.size,mtimeMs:l.mtimeMs}}return null},[o,et,c]);s.useEffect(()=>{if(!c||!o.statFile||je.length===0)return;let t=!1;const a=[...je];return Promise.all(a.map(async l=>{try{const d=await et(l),h=await o.statFile?.(l,{...d,directory:c||void 0});!t&&h&&!h.isFile&&dt(c,l)}catch(d){!t&&ji(d)&&dt(c,l)}})),()=>{t=!0}},[o,je,dt,et,c]);const Le=ee!==O,_t=s.useCallback(async()=>{if(!u||!o.writeFile)return J.error(r("filesView.toast.savingNotSupported")),!1;const t=hr(u.path)||Ft;if(!xl({selectedFilePath:u.path,loadedFilePath:Ne,fileLoading:Me,isDirty:Le,draftContent:ee,fileContent:O,isNonEditableBinary:t}))return t?console.warn(`[saveDraft] refusing to save binary file "${u.path}".`):ee===""&&O!==""&&Ne!==u.path&&console.warn(`[saveDraft] refusing to save empty draft for "${u.path}" (${O.length} bytes were expected). The file may have been read during a concurrent write (O_TRUNC race). Try again after content finishes loading if the save was intentional.`),!1;if(!Le)return!0;nn(!0);try{const a=yl(ee,Wn);if(!(await o.writeFile(u.path,a))?.success)return J.error(r("filesView.toast.writeFileFailed")),!1;if(me(ee),sn.current=a,an.current+=1,c&&Qr(u.path,c)){const d=Jr(c,u.path);d&&mo.requestGitRefresh({directory:c,paths:[d]})}if(c&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(U(u.path))){const d=ho.getState().projects.find(h=>U(h.path)===U(c));if(d)try{await _o(d.id)}catch{J.error(r("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return u?.path&&pr(u.path)&&(ht.current=ee,sr.current=ee),vt(u.path).then(d=>{d&&(qe.current=d)}).catch(()=>{}),!0}catch(a){return J.error(a instanceof Error?a.message:r("filesView.toast.saveFailed")),!1}finally{nn(!1)}},[Ft,ee,O,Me,o,Le,Wn,Ne,vt,c,u,r]);s.useEffect(()=>{Se||(At("idle"),rt.current&&(clearTimeout(rt.current),rt.current=null))},[Se]);const ws=1500;s.useEffect(()=>{const t=!!(u&&o.writeFile),a=!!(u?.path&&(hr(u.path)||Ft));if(vl({autoSaveEnabled:Se,isDirty:Le,canWrite:t,isSaving:nr,fileLoading:Me,selectedFilePath:u?.path,loadedFilePath:Ne,isNonEditableBinary:a}))return rt.current=setTimeout(()=>{_t().then(l=>{l&&(At("saved"),setTimeout(()=>At("idle"),2e3))})},ws),()=>{rt.current&&(clearTimeout(rt.current),rt.current=null)}},[Se,Ft,ee,Me,Le,Ne,u,o.writeFile,nr,_t]),s.useEffect(()=>{At("idle")},[u?.path]),po({save_file:t=>{if(!(t.target instanceof Node)||!Sr.current?.contains(t.target))return!1;rt.current&&(clearTimeout(rt.current),rt.current=null),nr||_t().then(a=>{a&&(At("saved"),setTimeout(()=>At("idle"),2e3))})},find_in_file:t=>{if(!(t.target instanceof Node))return!1;if(Je&&Ae()==="preview"){if(m||!(te?Er.current:Rr.current)?.contains(t.target))return!1;kr(!0),Yn(l=>l+1);return}if(!Sr.current?.contains(t.target))return!1;be(!0)}});const Wt=s.useCallback(t=>{const{content:a,lineEnding:l}=bl(t);return sn.current=t,an.current+=1,Ki(l),me(a),ht.current=a,sr.current=a,Ce(a),a},[]),bs=s.useCallback(async t=>{const a=Lt.current+1;Lt.current=a;const l=lt(),d=V.current,h=()=>{if(!c||lt()!==l||V.current!==d)return!1;const z=Ye.getState().byRoot[c],ie=z?.selectedPath??z?.openPaths[0]??null;return Lt.current===a&&ie===t.path};if(we(null),Be(""),ce(null),Kn(!1),ft(!0),await et(t.path),!h())return;const g=Sn(t.path),C=li(t.path),A=ci(t.path),se=hr(t.path);if(m&&H(!0),w.isDesktop&&g&&!C){me(""),Ce("");return}if(!w.isDesktop&&g&&!C){me(""),Ce(""),ce(t.path),ft(!1);return}if(A){me(""),Ce(""),ce(t.path),ft(!1);return}if(se){me(""),Ce(""),ce(t.path),ft(!1);return}await zr(t.path).then(z=>{if(!h())return;if(ui(z)){Kn(!0),me(""),Ce(""),ce(t.path);return}const ie=Wt(z),kt=Vn(t.path)||Hr(t.path)||Fi(t.path)||pr(t.path);re(kt?"edit":jl(ie,Te.current[t.path])),ce(t.path),vt(t.path).then(Gt=>{Gt&&h()&&(qe.current=Gt)}).catch(()=>{})}).catch(z=>{if(h()){if(Ml(z)){if(ft(!1),c&&Fe(c,null),we(null),me(""),Ce(""),ce(null),qe.current=null,Y.trim().length>0&&Q(""),m&&H(!1),c){const kt=[...bi(t.path,c),t.path];kt.length>0&&xr(c,kt);for(const Gt of kt)Oe.current.has(Gt)||Ve(Gt)}return}if(ji(z)){c&&dt(c,t.path),me(""),Ce(""),we(null),qe.current=null,m&&H(!1);return}me(""),Ce(""),we(z instanceof Error?z.message:r("filesView.error.readFileFailed")),qe.current=null}}).finally(()=>{h()&&ft(!1)})},[Wt,xr,m,Ve,zr,vt,dt,et,c,w.isDesktop,Y,Fe,r]),Lr=s.useCallback(async(t,a)=>{if(!e||!c)return;const l=bi(t,c),d=a?[...l,t]:l;if(d.length>0&&xr(c,d),!T)return;const h=d.map(g=>{if(!Oe.current.has(g))return Ve(g)}).filter(Boolean);await Promise.all(h)},[xr,Ve,c,T,e]),ys=s.useCallback((t,a)=>{const l=a.findIndex(d=>d.path===t);return l===-1||a.length<=1?null:a[l+1]??a[l-1]??null},[]),Pe=s.useCallback(async t=>{if(or.current)or.current=!1;else if(Le){ir(!0),It.current=t;return}c&&(Fe(c,t.path),Lr(t.path,!1)),we(null),Be(""),me(""),ht.current="",sr.current="",Ce(""),ce(null),m&&H(!0)},[Lr,Le,m,c,Fe]);s.useEffect(()=>{u?.path&&Lr(u.path,!1)},[Lr,u?.path]),s.useEffect(()=>{if(!e)return;if(!u){Lt.current+=1,jt.current=null,ft(!1);return}if(Ne===u.path||jt.current===u.path)return;const t=u.path;jt.current=t,bs(u).finally(()=>{jt.current===t&&(jt.current=null)})},[Nr,bs,Ne,u,e]);const Ar=s.useRef(Le);Ar.current=Le,s.useEffect(()=>Wo(({runtimeKey:t,paths:a})=>{const l=u?.path;t!==lt()||!l||Ar.current||!a.includes(U(l))||(Lt.current+=1,jt.current=null,qe.current=null,Be(""),we(null),ce(null),Hi(d=>d+1))}),[u?.path]),s.useEffect(()=>{if(!e||!u?.path||Ne!==u.path)return;const t=u.path,a=lt(),l=V.current,d=()=>Ar.current||pr(t)&&ht.current!==sr.current,h=!hr(t)&&!Sn(t)&&!Ft?fl({readContent:()=>zr(t,{fresh:!0}),getLoadedContent:()=>sn.current,getLoadedRevision:()=>an.current,isDirty:d,applyContent:z=>{if(!(g||lt()!==a||V.current!==l)){if(ui(z)){ce(null);return}Wt(z)}}}):null;let g=!1,C=!1;const A=()=>{document.hidden||C||(C=!0,vt(t).then(async z=>{if(g||lt()!==a||V.current!==l||!z)return;const ie=qe.current;if(!ie||ie.path!==t){qe.current=z;return}if(hl(ie,z)){if(h&&z.size<=zl){await h.poll()&&!g&&(qe.current=z);return}Ar.current||(qe.current=z,ce(null))}}).catch(()=>{}).finally(()=>{C=!1}))};A();const se=window.setInterval(A,2e3);return()=>{g=!0,h?.dispose(),window.clearInterval(se)}},[Wt,Ft,Ne,zr,vt,u?.path,e]);const ga=s.useCallback(()=>{const t=It.current,a=ar.current;if(It.current=null,ar.current=null,or.current=!0,ir(!1),Ce(O),a){c&&Dt(c,a),u?.path===a&&(t?Pe(t):(c&&Fe(c,null),me(""),we(null),Be(""),ce(null),m&&H(!1)));return}if(t){Pe(t);return}},[O,Pe,m,Dt,c,u?.path,Fe]),va=s.useCallback(async()=>{const t=It.current,a=ar.current;if(!await _t()){or.current=!1;return}if(It.current=null,ar.current=null,or.current=!0,ir(!1),a){c&&Dt(c,a),u?.path===a&&(t?await Pe(t):(c&&Fe(c,null),me(""),we(null),Be(""),ce(null),m&&H(!1)));return}if(t){await Pe(t);return}},[Pe,m,Dt,c,_t,u?.path,Fe]),js=s.useCallback(t=>{const a=u?.path===t,l=ys(t,zt);if(a&&Le){ir(!0),It.current=l,ar.current=t;return}if(c&&Dt(c,t),!!a){if(l){Pe(l);return}c&&Fe(c,null),me(""),we(null),Be(""),ce(null),m&&H(!1)}},[ys,Pe,Le,m,zt,Dt,c,u?.path,Fe]),Fs=s.useMemo(()=>new Set(je),[je]),Ir=s.useMemo(()=>Uo(D?de?.files??[]:[]),[de?.files,D]),xa=s.useCallback(t=>{if(Fs.has(t))return"open";const a=t.startsWith(c+"/")?t.slice(c.length+1):t;return Ir.statusByPath.get(a)??null},[Fs,Ir,c]),wa=s.useCallback(t=>{if(!de?.files)return null;const a=t.startsWith(c+"/")?t.slice(c.length+1):t;return Ir.badgeByDir.get(a)??null},[de,Ir,c]),ba=s.useCallback(async t=>{const a=U(t);c&&(Ln(c,a),Oe.current.has(a)||await Ve(a))},[Ve,c,Ln]),ya=s.useMemo(()=>({canRename:es,canCreateFile:Qn,canCreateFolder:Zn,canDelete:ts,canReveal:rs}),[es,Qn,Zn,ts,rs]);function Ns(t,a){const l=$n[t]??[];return l.map((d,h)=>{const g=d.type==="directory",C=g&&Ii.has(d.path),A=u?.path===d.path,se=h===l.length-1;return n.jsxs("li",{className:"relative",children:[a>0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),se&&n.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),n.jsx(Ll,{node:d,root:c,isExpanded:C,isActive:A,isMobile:m,isBrowserClient:N,alwaysShowActions:R,status:g?void 0:xa(d.path),badge:g?wa(d.path):void 0,permissions:ya,downloadFile:o.downloadFile,contextMenuPath:ea,setContextMenuPath:ta,rightClickMenuPath:ra,setRightClickMenuPath:na,onSelect:Pe,onToggle:ba,onRevealPath:ua,onOpenDialog:fn}),g&&C&&n.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[br[d.path]?n.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:br[d.path],children:br[d.path]}),n.jsxs(I,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{$e(d.path)},children:[n.jsx(F,{name:"refresh",className:"size-3.5"}),r("filesView.tree.actions.refreshTitle")]})]}):null,Ns(d.path,a+1)]})]},d.path)})}const ke=!!(u?.path&&Sn(u.path)),Or=!!(u?.path&&li(u.path)),_e=!!(u?.path&&ci(u.path)),pn=!!(u?.path&&(hr(u.path)||Ft)),it=pn&&!ke&&!_e,Cs=s.useMemo(()=>U(nt?.path??""),[nt?.path]),Ut=!!(nt&&Cs&&Ke&&Ke===Cs&&!Me&&!tt&&!ke&&!_e&&!it),xt=s.useMemo(()=>Jr(c,Ke),[Ke,c]),ja=!!(u&&(!ke||Or)&&!_e&&!it&&O.length>0),Fa=!!(u&&xt.length>0),Xe=!!(u&&!wr&&!pn&&!ke&&o.writeFile),Je=!!(u?.path&&Vn(u.path)),Kt=!!(u?.path&&Fi(u.path)),qt=!!(u?.path&&Hr(u.path)),fr=!!(u?.path&&pr(u.path)),Br=!!(u&&!pn&&!ke)&&!Je&&!fr&&!(qt&&ve==="preview"),Na=Je&&ge==="edit"||qt&&ve==="edit"||Kt&&Z==="text"||!Je&&!qt&&!Kt&&_==="edit",$r=s.useMemo(()=>Ke?go(Ke):null,[Ke]),[Ss,gn]=s.useState(null);s.useEffect(()=>{let t=!1;const a=u?.path;if(!a||$r){gn(null);return}return gn(null),vo(a).then(l=>{t||gn(l)}),()=>{t=!0}},[u?.path,$r]),s.useEffect(()=>{!Xe&&_==="edit"&&re("view")},[Xe,_]);const vn="aiworker:files:md-viewer-mode",xn="aiworker:files:html-viewer-mode",wn="aiworker:files:json-viewer-mode";s.useEffect(()=>{const t=u?.path;if(!t)return;re(Te.current[t]??"edit");let a=ur?"preview":"edit";try{const h=localStorage.getItem(vn);(h==="preview"||h==="edit")&&(a=h)}catch{}ne(Ie.current[t]??a);let l=ur?"preview":"edit";try{const h=localStorage.getItem(xn);(h==="preview"||h==="edit")&&(l=h)}catch{}fe(Vt.current[t]??l),Re(le.current[t]??(ur?"preview":"edit"));let d=ur?"tree":"text";try{const h=localStorage.getItem(wn);(h==="tree"||h==="text")&&(d=h)}catch{}ye(d)},[u?.path,ur]);const Ca=s.useCallback(t=>{const a=u?.path;a&&(Te.current[a]=t),re(t)},[u?.path]),Sa=s.useCallback(t=>{const a=u?.path;a&&(Ie.current[a]=t),ne(t);try{localStorage.setItem(vn,t)}catch{}},[u?.path]),Ae=s.useCallback(()=>ge,[ge]),ks=u&&Je&&Ae()==="preview"&&!Me?u.path:null;s.useEffect(()=>{!ks||m||Tr()},[Tr,te,m,ks]);const ka=s.useCallback(t=>{ye(t);try{localStorage.setItem(wn,t)}catch{}},[]),Ra=s.useCallback(t=>{const a=u?.path;a&&(Vt.current[a]=t),fe(t);try{localStorage.setItem(xn,t)}catch{}},[u?.path]),Ta=s.useCallback(t=>{const a=u?.path;if(a&&(le.current[a]=t),ze.current&&(clearTimeout(ze.current),ze.current=null),st.current!==null&&(cancelAnimationFrame(st.current),st.current=null),t==="edit")Ce(ht.current||O),Re(t);else{ht.current=ee;const l=a;Re("edit"),st.current=requestAnimationFrame(()=>{st.current=requestAnimationFrame(()=>{st.current=null,!(c&&l&&Ye.getState().byRoot[c]?.selectedPath!==l)&&(Et(d=>d+1),Re("preview"))})});return}},[ee,O,c,u?.path]),bn=s.useCallback(async(t,a)=>{if(!o.writeFile||a===sr.current)return!1;if(!(await o.writeFile(t,a))?.success)return J.error(r("filesView.toast.writeFileFailed")),!1;Wt(a);const d=await vt(t).catch(()=>null);return d&&(qe.current=d),!0},[Wt,o,vt,r]);s.useEffect(()=>()=>{ze.current&&(clearTimeout(ze.current),ze.current=null),st.current!==null&&(cancelAnimationFrame(st.current),st.current=null)},[xe,u?.path]);const Ea=s.useCallback(t=>{if(ht.current=t,!Se||!u?.path||xe!=="preview"||!o.writeFile)return;ze.current&&clearTimeout(ze.current);const a=u.path;ze.current=setTimeout(()=>{ze.current=null,bn(a,t).then(l=>{l&&(Cr(!0),setTimeout(()=>Cr(!1),1500))}).catch(l=>{J.error(l instanceof Error?l.message:r("filesView.toast.saveFailed"))})},ws)},[Se,xe,o.writeFile,bn,u?.path,r]),Va=s.useMemo(()=>fr&&(ht.current||ee)||O,[ee,O,fr]),Rs=s.useCallback(()=>ve,[ve]);s.useEffect(()=>{const t=l=>{const d=l?"preview":"edit",h=l?"tree":"text";for(const g of je)Te.current[g]="edit",Vn(g)&&(Ie.current[g]=d),Hr(g)&&(Vt.current[g]=d),pr(g)&&(le.current[g]=d);re("edit"),ne(d),fe(d),Re(d),ye(h);try{localStorage.setItem(vn,d),localStorage.setItem(xn,d),localStorage.setItem(wn,h)}catch{}},a=l=>{const d=!!l.detail?.enabled;t(d)};return window.addEventListener("aiworker:file-viewer-preview-mode-changed",a),()=>{window.removeEventListener("aiworker:file-viewer-preview-mode-changed",a)}},[je]),s.useEffect(()=>{if(!nt||!c)return;const t=()=>{typeof window>"u"||Ot.current===null&&(Ot.current=window.requestAnimationFrame(()=>{Ot.current=null,ln(ot=>ot+1)}))},a=(ot,Rt)=>{if(ot.state.doc.length!==Rt.length)return!1;if(Rt.length===0)return!0;const Nn=Math.min(128,Rt.length);if(ot.state.sliceDoc(0,Nn)!==Rt.slice(0,Nn))return!1;const Zs=Math.max(0,Rt.length-Nn);return ot.state.sliceDoc(Zs,Rt.length)===Rt.slice(Zs)},l=U(nt.path);if(!l){Vr(null),Nt.current={key:"",attempts:0};return}const d=`${l}:${nt.line}:${nt.column??1}`;if(Nt.current.key!==d&&(Nt.current={key:d,attempts:0}),u?.path!==l){if(on)return;Pe(Mt(l));return}if(Me||Ne!==l)return;if(tt||ke||_e||it){Vr(null),Nt.current={key:"",attempts:0};return}if(!Xe)return;if(_!=="edit"){re("edit");return}const h=He.current;if(!h){t();return}if(!a(h,ee)){t();return}const g=Math.max(1,Math.min(nt.line,h.state.doc.lines)),C=h.state.doc.line(g),A=Math.max(1,nt.column||1),se=Math.max(0,C.to-C.from),z=Math.min(se,A-1),ie=C.from+z;if(!(h.state.selection.main.head===ie)||Nt.current.attempts===0){Nt.current.attempts+=1,h.dispatch({selection:{anchor:ie},effects:Tt.scrollIntoView(ie,{y:"center"})}),h.focus(),t();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const ot=He.current;ot&&(ot.dispatch({selection:{anchor:ie},effects:Tt.scrollIntoView(ie,{y:"center"})}),ot.focus())}),Vr(null),Nt.current={key:"",attempts:0}},[Xe,on,ee,Yi,tt,Me,ke,_e,it,Ne,Pe,nt,c,u?.path,Vr,_,Mt]),s.useEffect(()=>{if(!mn||!c)return;const t=U(mn);if(!t){hn(null);return}u?.path===t&&(Me||Ne!==t||(!tt&&!ke&&!_e&&!it&&Xe&&_==="edit"&&He.current?.focus(),hn(null)))},[Xe,tt,Me,ke,_e,it,Ne,mn,c,u?.path,hn,_]);const Ht=s.useCallback(t=>{if(!m||!t||!t.hasFocus||typeof window>"u")return;const a=window.visualViewport;if(!a)return;const l=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,l-(a.offsetTop+a.height))<=0)return;const h=t.state.selection.main.head,g=t.coordsAtPos(h);if(!g)return;const C=Math.round(a.offsetTop+a.height),se=g.bottom+20-C;se<=0||(t.scrollDOM.scrollTop+=se)},[m]);s.useEffect(()=>{if(!m||typeof window>"u")return;const t=()=>{window.requestAnimationFrame(()=>{Ht(He.current)})},a=window.visualViewport;return a?.addEventListener("resize",t),a?.addEventListener("scroll",t,{passive:!0}),document.addEventListener("selectionchange",t),()=>{a?.removeEventListener("resize",t),a?.removeEventListener("scroll",t),document.removeEventListener("selectionchange",t)}},[m,Ht]),xo("open_go_to_line",t=>{if(!Xe||_!=="edit"||m)return!1;const a=t.target;if(a?.closest('[role="dialog"]')||!(a instanceof Node)||!Sr.current?.contains(a))return!1;const l=!!a?.closest(".cm-editor");if(!!a?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!l)return!1;dn(!0)});const _r=wt(t=>t.editorFontSize),Ts=s.useMemo(()=>{if(!u?.path)return[fi(p,{fontSize:_r})];const t=Cn(u.path),a=[fi(p,t?{syntaxColors:!1,fontSize:_r}:{fontSize:_r})],l=$r??Ss;return l&&a.push(l),t&&a.push(Eo({language:t,themeName:p.metadata.id,theme:Lo(p)})),G&&a.push(Tt.lineWrapping),m&&a.push(Tt.updateListener.of(d=>{d.view.hasFocus&&(d.selectionSet||d.focusChanged||d.viewportChanged||d.geometryChanged)&&window.requestAnimationFrame(()=>{Ht(d.view)})})),a},[p,u?.path,$r,Ss,G,m,Ht,_r]),Es=s.useMemo(()=>({light:Qe.metadata.id,dark:Pt.metadata.id}),[Qe.metadata.id,Pt.metadata.id]),mr=u?.path&&_e&&(!yt.allowOutsideWorkspace||yt.outsideFileGrant)?`${u.path}|${yt.allowOutsideWorkspace?"outside":"workspace"}|${yt.outsideFileGrant??""}|${Nr}`:"",Wr=u?.path&&qt&&ve==="preview"&&!w.isVSCode?`${u.path}|${Nr}`:"",Vs=r("filesView.error.readFileFailed"),{readyKey:Ps,nonce:Pa}=Ci(Wr,we,Vs),{readyKey:Ds,nonce:Ms}=Ci(mr,we,Vs),Da=!!(Wr&&Ps!==Wr),zs=!!(mr&&Ds!==mr),Ls=u?.path&&ke?Or?`data:${wo(u.path)};utf8,${encodeURIComponent(O)}`:Ui:"",As=u?.path&&_e&&mr&&Ds===mr?ni().authenticatedAsset("/api/fs/raw",{path:u.path,allowOutsideWorkspace:yt.allowOutsideWorkspace?"true":void 0,outsideFileGrant:yt.outsideFileGrant,directory:c||void 0}):"",Is=s.useCallback(t=>n.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:n.jsx("iframe",{src:As,className:"h-full w-full border-0",title:t.name},Ms)}),[As,Ms]);s.useEffect(()=>{let t=!1,a="";return(async()=>{if(!u?.path||!ke||Or){Be("");return}we(null);const d=await et(u.path);if(t)return;await(o.readFileBinary?o.readFileBinary(u.path,d).then(g=>g.dataUrl):(async()=>{const g=await ri("/api/fs/raw",{query:{path:u.path,allowOutsideWorkspace:d.allowOutsideWorkspace?"true":void 0,outsideFileGrant:d.outsideFileGrant,directory:c||void 0}});if(!g.ok)throw new Error(r("filesView.error.readFileFailed"));const C=await g.blob();return a=URL.createObjectURL(C),t?(URL.revokeObjectURL(a),a="",""):a})()).then(g=>{t||(Be(g),ce(u.path))}).catch(g=>{t||(Be(""),we(g instanceof Error?g.message:r("filesView.error.readFileFailed")),ce(null))}).finally(()=>{t||ft(!1)})})(),()=>{t=!0,a&&URL.revokeObjectURL(a)}},[Nr,o,ke,Or,et,c,u?.path,yt,r]);const Ma=s.useCallback(()=>cn(null),[]),za=s.useMemo(()=>Xo({drafts:os,editingDraftId:Dr,commentText:Pr,onTextChange:ls,selection:W,isDragging:ss,fileLabel:u?.path??"",newWidgetId:"files-new-comment-input",mapDraftToRange:t=>({start:t.startLine,end:t.endLine}),onSave:hs,onCancel:()=>{Ge(null),dr()},onEdit:t=>{fs(t),Ge({start:t.startLine,end:t.endLine})},onDelete:ms}),[dr,Pr,ms,Dr,os,hs,ss,W,u?.path,ls,fs]),Os=xi(),Bs=xi(),$s=!Me&&!tt&&Ne===Ke,Ur=$s&&Br&&_==="view"&&!(Kt&&Z==="tree"),_s=$s&&Je&&Ae()==="preview",{setScroller:Ws,restore:La}=qr(Ur?`${mt}:code`:null),{setScroller:Us,restore:Aa}=qr(Ur?`${mt}:code:fullscreen`:null),{setScroller:Ks}=qr(_s?`${mt}:markdown`:null),{setScroller:qs}=qr(_s?`${mt}:markdown:fullscreen`:null),{setScroller:Hs}=Os,{setScroller:Gs}=Bs,Ia=s.useCallback(t=>{Hs(t),Ws(t)},[Hs,Ws]),Oa=s.useCallback(t=>{Gs(t),Us(t)},[Gs,Us]),Ba=s.useCallback(t=>{as.current=t,Rr.current=t,Ks(t)},[Ks]),$a=s.useCallback(t=>{Er.current=t,qs(t)},[qs]),yn=No("unified"),at=ee.length>zi,jn=s.useMemo(()=>at&&Ur?Fl(ee):void 0,[Ur,ee,at]),Xs=s.useCallback((t,a,l,d)=>{const h={name:t.name,contents:a,lang:Cn(t.path)||void 0},g=C=>n.jsx(zo,{file:at&&jn?{...h,cacheKey:`${t.path}:${jn}`}:h,options:{disableFileHeader:!0,overflow:G?"wrap":"scroll",theme:Es,themeType:p.metadata.variant==="dark"?"dark":"light",onPostRender:d},className:at?"block w-full":"block h-full w-full",style:at?void 0:{height:"100%"}},C);return at?n.jsx("div",{className:"h-full",children:n.jsx(Ao.Provider,{value:l.virtualizer,children:n.jsx(Io.Provider,{value:yn,children:g(`${t.path}:${yn?"pool":"pending"}`)})})}):n.jsx("div",{className:"h-full",children:g(t.path)})},[p.metadata.variant,at,jn,Es,yn,G]),Js=({exitFullscreenOnly:t=!1,layout:a="floating"}={})=>{if(!u)return null;const l=a==="docked",d=bo(yo("save_file")),h=l?"pointer-events-auto flex flex-wrap items-center gap-1":"pointer-events-auto flex items-center gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-sm",g=(C,A)=>n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:A})}),n.jsx(Yt,{side:"bottom",sideOffset:6,children:C})]});return n.jsxs("div",{className:h,children:[Xe&&Na&&n.jsxs(n.Fragment,{children:[nr?n.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[n.jsx(F,{name:"loader-4",className:"size-3.5 animate-spin"}),r("filesView.editor.saving")]}):Se&&Gi==="saved"&&!Le?n.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[n.jsx(F,{name:"check",className:"size-3.5"}),r("filesView.editor.saved")]}):Le?g(r(Se?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:d}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{_t()},className:"h-6 gap-1 px-1 text-muted-foreground opacity-80 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:r(Se?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:d}),"aria-label":r("filesView.editor.saveAria",{shortcut:d}),children:n.jsx(F,{name:"save-3",className:"size-4"})})):null,g(r(Se?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>Ji(!Se),className:q("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",Se?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:r(Se?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),"aria-label":r(Se?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),children:Se?n.jsx(F,{name:"file-check-fill",className:"size-4"}):n.jsx(F,{name:"file-check",className:"size-4"})}))]}),n.jsxs(Pn,{onOpenChange:X,children:[n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:n.jsx(Dn,{asChild:!0,children:n.jsx(I,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.openInDesktopApp"),"aria-label":r("filesView.editor.openInDesktopApp"),children:n.jsx(F,{name:"file-transfer",className:"size-4"})})})})}),n.jsx(Yt,{side:"bottom",sideOffset:6,children:r("filesView.editor.openInDesktopApp")})]}),n.jsxs(Mn,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[oa.map(C=>n.jsxs(Xr,{className:"flex items-center gap-2",onClick:()=>{da(C)},children:[n.jsx(kl,{label:C.label,iconDataUrl:C.iconDataUrl}),n.jsx("span",{className:"typography-ui-label text-foreground",children:C.label})]},C.id)),la?n.jsxs(Xr,{className:"flex items-center gap-2",onClick:()=>{ca(!0)},children:[n.jsx(F,{name:"refresh",className:"size-4"}),n.jsx("span",{className:"typography-ui-label text-foreground",children:r("filesView.editor.refreshApps")})]}):null]})]}),!ke&&!_e&&!it&&n.jsxs(n.Fragment,{children:[g(r(G?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>We(!G),className:q("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",G?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:r(G?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),children:n.jsx(F,{name:"text-wrap",className:"size-4"})})),_==="edit"&&n.jsxs(n.Fragment,{children:[g(r("filesView.editor.findInFile"),n.jsx(I,{variant:"ghost",size:"sm",onClick:C=>{be(!De),C.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.findInFile"),children:n.jsx(F,{name:"search",className:"size-4"})})),g(r("filesView.editor.goToLine"),n.jsx(I,{variant:"ghost",size:"sm",onClick:C=>{dn(A=>!A),C.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.goToLine"),children:n.jsx(F,{name:"menu-fold-2",className:"size-4"})})),n.jsx(il,{open:aa,onOpenChange:dn,view:He.current,variant:"inline"})]})]}),Br&&Xe&&!Kt&&!qt&&n.jsx(Tn,{currentMode:_==="view"?"preview":"edit",onToggle:()=>{Ca(_==="view"?"edit":"view")}}),Je&&g(r(Ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>Sa(Ae()==="preview"?"edit":"preview"),className:q("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",Ae()==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)] focus-visible:bg-[var(--interactive-selection)] active:bg-[var(--interactive-selection)]":"text-muted-foreground opacity-65 hover:opacity-100"),title:r(Ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),"aria-label":r(Ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:n.jsx(F,{name:Ae()==="preview"?"eye":"eye-off",className:"size-4"})})),Hr(u?.path??"")&&n.jsx(Tn,{currentMode:Rs(),onToggle:()=>{Ra(Rs()==="preview"?"edit":"preview")}}),Je&&Ae()==="preview"&&g(r("filesView.editor.findInFile"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{kr(!0),Yn(C=>C+1)},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.findInFile"),children:n.jsx(F,{name:"search",className:"size-4"})})),Je&&Ae()==="preview"&&fa&&n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx(I,{variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent","aria-label":r(Fr?"filesView.tts.stopSpeaking":"filesView.tts.readAloud"),onClick:()=>{Fr?Wi():O.trim()&&_i(O)},children:Fr?n.jsx(F,{name:"stop",className:"size-4 text-[color:var(--status-success)]"}):n.jsx(F,{name:"volume-up",className:"size-4"})})}),n.jsx(Yt,{sideOffset:8,children:r(Fr?"filesView.tts.stopSpeaking":"filesView.tts.readAloud")})]}),fr&&n.jsxs(n.Fragment,{children:[n.jsx(Tn,{currentMode:xe,onToggle:()=>Ta(xe==="preview"?"edit":"preview")}),xe==="preview"&&n.jsx(I,{variant:"ghost",size:"sm",onClick:async()=>{const C=Un.current?.getXml();if(ze.current&&(clearTimeout(ze.current),ze.current=null),u?.path&&C){if(!await bn(u.path,C))return;Cr(!0),setTimeout(()=>Cr(!1),1500)}},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.diagram.saveDiagram"),children:Xi?n.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):n.jsx(F,{name:"save-3",className:"size-4"})})]}),Kt&&g(r(Z==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>ka(Z==="tree"?"text":"tree"),className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:r(Z==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),children:Z==="tree"?n.jsx(F,{name:"code-sslash",className:"size-4"}):n.jsx(F,{name:"node-tree",className:"size-4"})})),ja&&g(r("filesView.editor.copyFileContents"),n.jsx(I,{variant:"ghost",size:"sm",onClick:async()=>{(await Yr(O)).ok?(Hn(!0),lr.current!==null&&window.clearTimeout(lr.current),lr.current=window.setTimeout(()=>{Hn(!1)},1200)):J.error(r("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.copyFileContents"),"aria-label":r("filesView.editor.copyFileContents"),children:sa?n.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):n.jsx(F,{name:"clipboard",className:"size-4"})})),Fa&&g(r("filesView.editor.copyFilePathTitle",{path:xt}),n.jsx(I,{variant:"ghost",size:"sm",onClick:async()=>{(await Yr(xt)).ok?(Gn(!0),cr.current!==null&&window.clearTimeout(cr.current),cr.current=window.setTimeout(()=>{Gn(!1)},1200)):J.error(r("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.copyFilePathTitle",{path:xt}),"aria-label":r("filesView.editor.copyFilePathTitle",{path:xt}),children:ia?n.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):n.jsx(F,{name:"file-copy-2",className:"size-4"})})),o.downloadFile&&g(r("filesView.editor.saveFile"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{const C=o.downloadFile;C&&C(u.path).catch(A=>{console.error("Download failed:",A),J.error(r("sidebarFilesTree.toast.operationFailed"))})},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.saveFile"),"aria-label":r("filesView.editor.saveFile"),children:n.jsx(F,{name:"download",className:"size-4"})})),t?g(r("filesView.editor.exitFullscreen"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>pe(!1),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.exitFullscreen"),"aria-label":r("filesView.editor.exitFullscreen"),children:n.jsx(F,{name:"fullscreen-exit",className:"size-4"})})):!m&&i==="full"&&g(r(te?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>pe(!te),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r(te?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),"aria-label":r(te?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),children:te?n.jsx(F,{name:"fullscreen-exit",className:"size-4"}):n.jsx(F,{name:"fullscreen",className:"size-4"})}))]})},Fn=n.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[n.jsx(ki,{open:on,onOpenChange:t=>{t||ir(!0)},children:n.jsxs(Ri,{showCloseButton:!1,className:"max-w-md",children:[n.jsxs(Ti,{children:[n.jsx(Ei,{children:r("filesView.unsaved.title")}),n.jsx(Vi,{children:r("filesView.unsaved.description")})]}),n.jsxs(Pi,{children:[n.jsx(I,{variant:"outline",onClick:()=>{va()},disabled:nr,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:r("filesView.unsaved.saveChanges")}),n.jsx(I,{variant:"destructive",onClick:ga,children:r("filesView.unsaved.discard")})]})]})}),n.jsxs("div",{className:q("flex flex-col flex-shrink-0",B&&"border-b border-border/40"),children:[B?n.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[m&&oe&&n.jsx("button",{type:"button",onClick:()=>H(!1),"aria-label":r("filesView.editor.back"),className:"inline-flex size-7 flex-shrink-0 items-center justify-center mr-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:n.jsx(F,{name:"arrow-left-s",className:"size-5"})}),m?u?n.jsxs(Pn,{children:[n.jsx(Dn,{asChild:!0,children:n.jsxs("button",{type:"button",className:"inline-flex min-w-0 max-w-full items-center gap-1 text-left typography-ui-label font-medium","aria-label":r("filesView.editor.openFilesAria"),children:[n.jsx(Gr,{filePath:u.path,extension:u.extension,className:"size-3.5 flex-shrink-0"}),n.jsx(yi,{name:u.name}),n.jsx(F,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),n.jsx(Mn,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:zt.map(t=>{const a=u?.path===t.path;return n.jsxs(Xr,{onSelect:l=>{if(l.target.closest("[data-close-open-file]")){l.preventDefault();return}a||Pe(t)},className:q("flex min-w-0 items-center justify-between gap-2 overflow-hidden",a&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[n.jsx(Gr,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),n.jsx(yi,{name:t.name})]}),n.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:l=>{l.preventDefault(),l.stopPropagation()},onClick:l=>{l.preventDefault(),l.stopPropagation(),js(t.path)},className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]","aria-label":r("filesView.editor.closeFileAria",{name:t.name}),children:n.jsx(F,{name:"close",className:"size-3.5"})})]},t.path)})})]}):n.jsx("div",{className:"typography-ui-label font-medium truncate",children:r("filesView.editor.selectFile")}):zt.length>0?n.jsxs("div",{className:"relative min-w-0 flex-1",children:[In.left&&n.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r from-background to-transparent"}),In.right&&n.jsx("div",{className:"pointer-events-none absolute right-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l from-background to-transparent"}),n.jsx("div",{ref:tn,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:zt.map(t=>{const a=u?.path===t.path;return n.jsxs("div",{title:Jr(c,t.path),className:q("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",a?"bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]":"bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]"),children:[n.jsx(Gr,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),n.jsx("button",{type:"button",onClick:()=>{a||Pe(t)},className:"max-w-[12rem] truncate text-left",children:t.name}),n.jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),js(t.path)},className:q("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!a&&!R&&"opacity-0 group-hover:opacity-100"),"aria-label":r("filesView.editor.closeFileAria",{name:t.name}),children:n.jsx(F,{name:"close",className:"size-3.5"})})]},t.path)})})]}):n.jsx("div",{className:"typography-ui-label font-medium truncate",children:r("filesView.editor.selectFile")})]}):null,u?n.jsxs("div",{className:"flex min-w-0 items-center gap-3 border-t border-border/40 bg-[var(--surface-subtle)] px-3 py-1",children:[xt&&!m?n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:xt,children:xt}):null,n.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:Js({layout:"docked"})})]}):null]}),n.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:n.jsx(kn,{ref:Ia,outerClassName:"h-full min-w-0",className:q("h-full min-w-0",at&&"[overflow-anchor:none]"),children:u?Me||zs?$?n.jsx("div",{className:"p-3"}):n.jsxs("div",{className:"p-3 flex items-center gap-2 typography-ui text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),r("filesView.state.loading")]}):tt?n.jsx("div",{className:"p-3 typography-ui text-[color:var(--status-error)]",children:tt}):ke?n.jsx("div",{className:"flex h-full items-center justify-center p-3",children:n.jsx("img",{src:Ls,alt:u?.name??r("filesView.editor.imageAltFallback"),className:"max-w-full max-h-[70vh] object-contain rounded-md border border-border/30 bg-primary/10"},u.path)}):_e?Is(u):it?n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("div",{className:"typography-ui-header text-foreground",children:r("filesView.editor.cannotPreviewBinary")}),n.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:r("filesView.editor.binaryFileDescription")}),o.downloadFile?n.jsxs(I,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=o.downloadFile;!t||!u||t(u.path).catch(a=>{console.error("Download failed:",a),J.error(r("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(F,{name:"download",className:"mr-2 size-4"}),r("filesView.editor.saveFile")]}):null]}):u&&fr&&xe==="preview"?n.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:n.jsx(Cl,{ref:Un,xml:Va,onChange:Ea},`${u.path}:${Ue}`)}):u&&Kt&&Z==="tree"?n.jsx(Rn,{fallback:n.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 font-medium text-destructive",children:r("filesView.error.jsonViewerUnavailable")}),n.jsx("div",{className:"text-sm text-muted-foreground",children:r("filesView.error.switchToTextMode")})]}),children:n.jsx("div",{className:"h-full overflow-auto",children:n.jsx(Mo,{jsonString:O,maxHeight:"100%",initiallyExpandedDepth:2})})}):u&&Je&&Ae()==="preview"?n.jsxs("div",{className:"relative h-full min-h-0",children:[n.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-3 outline-none",tabIndex:-1,onMouseDown:Tr,ref:Ba,children:[n.jsx(hi,{containerRef:as,filePath:u.path,fileContent:O}),O.length>500*1024&&n.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:r("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(O.length/1024)})}),n.jsx(Rn,{fallback:n.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 font-medium text-destructive",children:r("filesView.error.previewUnavailable")}),n.jsx("div",{className:"text-sm text-muted-foreground",children:r("filesView.error.switchToEditMode")})]}),children:n.jsx(di,{content:O,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}),!te&&n.jsx(vi,{containerRef:Rr,open:Xn,onOpenChange:kr,focusNonce:Jn})]}):u&&qt&&ve==="preview"?Da?n.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:r("common.loading")}):n.jsx("div",{className:"h-full overflow-hidden",children:n.jsx("iframe",{src:!w.isVSCode&&Ps===Wr?(()=>{const t=u.path.split("/").map(a=>encodeURIComponent(a)).join("/");return ni().authenticatedAsset(`/api/fs/serve${t.startsWith("/")?t:`/${t}`}`)})():void 0,srcDoc:w.isVSCode?(()=>{const t=u.path.substring(0,u.path.lastIndexOf("/")+1);return t?O.replace(/<head([^>]*)>/i,`<head$1><base href="${t}">`):O})():void 0,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:r("filesView.editor.htmlPreviewTitle")},Pa)}):u&&Br&&_==="view"?Xs(u,ee,Os,La):n.jsxs("div",{className:q("relative h-full",Ut&&"overflow-hidden"),ref:Sr,children:[n.jsx("div",{className:q("h-full",Ut&&"invisible"),children:n.jsx(Ni,{positionKey:mt,value:ee,onChange:Ce,readOnly:!Xe,vimMode:is==="vim",extensions:Ts,className:"h-full",blockWidgets:za,onViewReady:t=>{He.current=t,ln(a=>a+1),window.requestAnimationFrame(()=>{Ht(t)})},onViewDestroy:()=>{He.current&&(He.current=null),ln(t=>t+1)},enableSearch:!0,searchOpen:De,onSearchOpenChange:be,highlightLines:W?{start:Math.min(W.start,W.end),end:Math.max(W.start,W.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(t,a,l)=>{if(!(l instanceof MouseEvent)||l.button!==0)return!1;l.preventDefault();const d=t.state.doc.lineAt(a.from).number;if(W&&!l.shiftKey&&Math.min(W.start,W.end)===d&&Math.max(W.start,W.end)===d)return Ge(null),dr(),Bt.current=!1,gt.current=null,$t(!1),!0;if(m&&W&&!l.shiftKey){const h=Math.min(W.start,W.end,d),g=Math.max(W.start,W.end,d);return Ge({start:h,end:g}),Bt.current=!1,gt.current=null,$t(!1),!0}if(Bt.current=!0,gt.current=d,$t(!0),W&&l.shiftKey){const h=Math.min(W.start,d),g=Math.max(W.end,d);Ge({start:h,end:g})}else Ge({start:d,end:d});return!0},mouseover:(t,a,l)=>{if(!(l instanceof MouseEvent)||l.buttons!==1||!Bt.current||gt.current===null)return!1;const d=t.state.doc.lineAt(a.from).number,h=Math.min(gt.current,d),g=Math.max(gt.current,d);return Ge({start:h,end:g}),$t(!0),!1},mouseup:()=>(Bt.current=!1,gt.current=null,$t(!1),!1)}}},mt)}),Ut&&n.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:n.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),r("filesView.state.openingFileAtChange")]})})]}):n.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:r("filesView.editor.pickFileFromTree")})})})]}),_a=!!(c&&$n[c]),Ys=c?br[c]:null,Qs=D?n.jsxs("section",{className:q("flex min-h-0 flex-col overflow-hidden",m?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[n.jsx("div",{className:q("flex flex-col gap-2 py-2",m?"px-3":"px-2"),children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"relative flex-1 min-w-0",children:[n.jsx(F,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),n.jsx(gr,{ref:he,value:Y,onChange:t=>Q(t.target.value),placeholder:r("filesView.tree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),Y.trim().length>0&&n.jsx("button",{type:"button","aria-label":r("filesView.tree.search.clearAria"),className:"absolute right-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{Q(""),he.current?.focus()},children:n.jsx(F,{name:"close",className:"size-4"})})]}),n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>fn("createFile",{path:y,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:r("filesView.tree.actions.newFileTitle"),"aria-label":r("filesView.tree.actions.newFileTitle"),children:n.jsx(F,{name:"file-add",className:"size-4"})})})}),n.jsx(Yt,{side:"bottom",sideOffset:6,children:r("filesView.tree.actions.newFileTitle")})]}),n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>fn("createFolder",{path:y,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:r("filesView.tree.actions.newFolderTitle"),"aria-label":r("filesView.tree.actions.newFolderTitle"),children:n.jsx(F,{name:"folder-add",className:"size-4"})})})}),n.jsx(Yt,{side:"bottom",sideOffset:6,children:r("filesView.tree.actions.newFolderTitle")})]}),n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{Mr()},className:"size-8 p-0 flex-shrink-0",title:r("filesView.tree.actions.refreshTitle"),"aria-label":r("filesView.tree.actions.refreshTitle"),children:n.jsx(F,{name:"refresh",className:"size-4"})})})}),n.jsx(Yt,{side:"bottom",sideOffset:6,children:r("filesView.tree.actions.refreshTitle")})]})]})}),n.jsx(kn,{outerClassName:"flex-1 min-h-0",className:q("py-2",m?"px-3":"px-2"),children:n.jsx("ul",{className:"flex flex-col",children:$i?n.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),r("filesView.tree.search.searching")]}):_n.length>0?_n.map(t=>{const a=u?.path===t.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>{Pe(t)},className:q("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",a?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[Ai(t.path,t.extension),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},title:t.path,children:t.relativePath??t.path})]})},t.path)}):Ys?n.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{className:"text-[var(--status-error)]",children:Ys}),n.jsxs(I,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{Mr()},children:[n.jsx(F,{name:"refresh",className:"size-3.5"}),r("filesView.tree.actions.refreshTitle")]})]}):_a?Ns(c,0):n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:r("filesView.state.loading")})})})]}):null,Wa=i==="full"&&te&&u&&n.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:n.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[n.jsx("div",{className:"absolute right-4 top-4 z-30",children:Js({exitFullscreenOnly:!0})}),n.jsx(kn,{ref:Oa,outerClassName:"h-full min-w-0",className:q("h-full min-w-0",at&&"[overflow-anchor:none]"),children:Me||zs?$?n.jsx("div",{className:"p-4"}):n.jsxs("div",{className:"p-4 flex items-center gap-2 typography-ui text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),"Loading…"]}):tt?n.jsx("div",{className:"p-4 typography-ui text-[color:var(--status-error)]",children:tt}):ke?n.jsx("div",{className:"flex h-full items-center justify-center p-4",children:n.jsx("img",{src:Ls,alt:u.name,className:"max-w-full max-h-full object-contain rounded-md border border-border/30 bg-primary/10"},u.path)}):_e?Is(u):it?n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("div",{className:"typography-ui-header text-foreground",children:r("filesView.editor.cannotPreviewBinary")}),n.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:r("filesView.editor.binaryFileDescription")}),o.downloadFile?n.jsxs(I,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=o.downloadFile;!t||!u||t(u.path).catch(a=>{console.error("Download failed:",a),J.error(r("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(F,{name:"download",className:"mr-2 size-4"}),r("filesView.editor.saveFile")]}):null]}):Je&&Ae()==="preview"?n.jsxs("div",{className:"relative h-full min-h-0",children:[n.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-4 outline-none",tabIndex:-1,onMouseDown:Tr,ref:$a,children:[u?n.jsx(hi,{containerRef:Er,filePath:u.path,fileContent:O}):null,O.length>500*1024&&n.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:r("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(O.length/1024)})}),n.jsx(Rn,{fallback:n.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 font-medium text-destructive",children:r("filesView.error.previewUnavailable")}),n.jsx("div",{className:"text-sm text-muted-foreground",children:r("filesView.error.switchToEditMode")})]}),children:n.jsx(di,{content:O,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}),n.jsx(vi,{containerRef:Er,open:Xn,onOpenChange:kr,focusNonce:Jn,className:"right-4 top-16"})]}):Br&&_==="view"?Xs(u,ee,Bs,Aa):n.jsxs("div",{className:q("relative h-full",Ut&&"overflow-hidden"),children:[n.jsx("div",{className:q("h-full",Ut&&"invisible"),children:n.jsx(Ni,{positionKey:`${mt}:fullscreen`,value:ee,onChange:Ce,readOnly:!Xe,vimMode:is==="vim",extensions:Ts,className:"h-full",onViewReady:t=>{He.current=t,window.requestAnimationFrame(()=>{Ht(t)})},onViewDestroy:()=>{He.current&&(He.current=null)}},`${mt}:fullscreen`)}),Ut&&n.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:n.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),r("filesView.state.openingFileAtChange")]})})]})})]})});return n.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[n.jsx(Al,{activeDialog:Ct,dialogData:St,dialogInputValue:pt,onDialogInputChange:qn,isDialogSubmitting:Zi,onDialogSubmit:pa,onClose:Ma,inputRef:qi}),Wa,m?oe?Fn:Qs:i==="editor-only"?n.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:n.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:Fn})}):n.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[j>=700&&n.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:Qs}),n.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:Fn})]})]})};function Ol(i){return i+1}export{sd as FilesView};