@aiworker/web 1.22.2 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/bin/cli.js +7 -0
  2. package/dist/assets/{CodeMirrorCommentWidgets-CSICpWQD.js → CodeMirrorCommentWidgets-B1Gizi3a.js} +1 -1
  3. package/dist/assets/DiffView-DXjVsEOw.js +4 -0
  4. package/dist/assets/{DirtyBranchSwitchDialog-C22HdWj4.js → DirtyBranchSwitchDialog-aig6zJjg.js} +1 -1
  5. package/dist/assets/FilesView-CJdG0-wk.js +17 -0
  6. package/dist/assets/{GitView-VQQkYuUw.js → GitView-BXsS3jG6.js} +4 -4
  7. package/dist/assets/{JsonTreeView-6lrhwD3q.js → JsonTreeView-D_hpXBnF.js} +1 -1
  8. package/dist/assets/{LinearIssuesView-Ba6Q9569.js → LinearIssuesView-BoUiLQG1.js} +1 -1
  9. package/dist/assets/MarkdownImageGallery-B_B_a9KS.js +1 -0
  10. package/dist/assets/MarkdownRendererImpl-xgyyLiBM.js +12 -0
  11. package/dist/assets/OnboardingScreen-DIp84OWt.js +1 -0
  12. package/dist/assets/{PatchDiff-BzcZPlOq.js → PatchDiff-8p6nLJaU.js} +1 -1
  13. package/dist/assets/PierreDiffViewer-DjC8nTk9.js +161 -0
  14. package/dist/assets/{PlanView-DyDt_nZ_.js → PlanView-CJTmOF6I.js} +2 -2
  15. package/dist/assets/SettingsView-DD-JqIJx.js +28 -0
  16. package/dist/assets/{SettingsWindow-DDQYaKWQ.js → SettingsWindow-Cpb4hM6q.js} +1 -1
  17. package/dist/assets/SymbolsNerdFontMono-Regular-aK5vsLov.woff2 +0 -0
  18. package/dist/assets/{ToolOutputDialog-iYF8Y2bz.js → ToolOutputDialog-DfaKZXNU.js} +6 -6
  19. package/dist/assets/{ToolPartDiffPreview-CdjbOVMM.js → ToolPartDiffPreview-DtZLzrSK.js} +2 -2
  20. package/dist/assets/{VirtualizedFileDiff-fFFm2QgH.js → VirtualizedFileDiff-C8i9HpTB.js} +1 -1
  21. package/dist/assets/WalkthroughView-DeKMvZlL.js +4 -0
  22. package/dist/assets/{computeVirtualFileMetrics-CzgLum_K.js → computeVirtualFileMetrics-BBI7ZwrC.js} +2 -2
  23. package/dist/assets/contextPanelEmbeddedChat-BdA6bdky.js +1 -0
  24. package/dist/assets/de-DCrsQ5zS.js +10 -0
  25. package/dist/assets/es-Dwv4YfH6.js +16 -0
  26. package/dist/assets/fr-BCWg4Cnx.js +14 -0
  27. package/dist/assets/ghostty-vt-DdA0Zryv.wasm +0 -0
  28. package/dist/assets/index-B68h5S5B.css +1 -0
  29. package/dist/assets/index-DVwMarHI.js +39 -0
  30. package/dist/assets/{index-Bl3LSbjn.js → index-jXSK5RrB.js} +1 -1
  31. package/dist/assets/{isDiffPlainText-Dx-dB_8l.js → isDiffPlainText-B_x_rVon.js} +1 -1
  32. package/dist/assets/{isFilePlainText-CWFPwmnU.js → isFilePlainText-DW_xMer1.js} +1 -1
  33. package/dist/assets/ja-Bruw3RYC.js +16 -0
  34. package/dist/assets/ko-idhXGF8j.js +16 -0
  35. package/dist/assets/main-BkyaQhJX.js +930 -0
  36. package/dist/assets/{main-DnBAoktx.js → main-CzdPuL0s.js} +2 -2
  37. package/dist/assets/markdownCore-Cn4Tyejo.js +5 -0
  38. package/dist/assets/{miniChat-BKyvLseN.js → miniChat-CCkqKOLp.js} +2 -2
  39. package/dist/assets/{mobile-DKjeFgMN.js → mobile-mvxTo055.js} +2 -2
  40. package/dist/assets/patchFileDiff-Csk4iNUi.js +13 -0
  41. package/dist/assets/pl-CGZWUqZJ.js +16 -0
  42. package/dist/assets/pt-BR-B8V7u7tA.js +16 -0
  43. package/dist/assets/renderElectronMiniChatApp-BxoyujA5.js +2 -0
  44. package/dist/assets/renderMobileApp-B48CsP4r.js +25 -0
  45. package/dist/assets/runtimeEndpointReset-Bg5gx18H.js +17 -0
  46. package/dist/assets/scheduledTasksApi-BW0Etzwz.js +1 -0
  47. package/dist/assets/{shikiHighlight-TEQCmzW8.js → shikiHighlight-CRl0SUC9.js} +1 -1
  48. package/dist/assets/surface-oMvhsog3.js +1 -0
  49. package/dist/assets/tr-BK_KiO2V.js +7 -0
  50. package/dist/assets/uk-CG74xV8N.js +16 -0
  51. package/dist/assets/{useAppFontEffects-D7sNpuL2.js → useAppFontEffects-CPKeOpUo.js} +160 -157
  52. package/dist/assets/useGitComparison-DH220WmO.js +1 -0
  53. package/dist/assets/useInlineCommentController-BiWz4AVb.js +2 -0
  54. package/dist/assets/useRootScrollLock-BS4-kr7P.js +1 -0
  55. package/dist/assets/{vendor-base-ui-BeMD8X_w.js → vendor-base-ui-DdV8vhHn.js} +1 -1
  56. package/dist/assets/{vendor-codemirror-language-data-Dp3KMRQG.js → vendor-codemirror-language-data-Bg4AEeCr.js} +2 -2
  57. package/dist/assets/vendor-zod-BPAANqvH.js +39 -0
  58. package/dist/assets/{web-components-_mNEMjFY.js → web-components-z7hfnS8n.js} +1 -1
  59. package/dist/assets/zh-CN-T4AXofZI.js +16 -0
  60. package/dist/assets/zh-TW-Dte40sxp.js +16 -0
  61. package/dist/index.html +5 -43
  62. package/dist/mini-chat.html +4 -4
  63. package/dist/mobile.html +4 -4
  64. package/package.json +2 -3
  65. package/server/index.d.ts +15 -0
  66. package/server/index.js +45 -9
  67. package/server/lib/data-dir-migration.js +40 -0
  68. package/server/lib/data-dir-migration.test.js +59 -0
  69. package/server/lib/event-stream/runtime.test.js +12 -12
  70. package/server/lib/fs/DOCUMENTATION.md +3 -0
  71. package/server/lib/fs/routes.js +31 -0
  72. package/server/lib/fs/routes.test.js +110 -1
  73. package/server/lib/git/DOCUMENTATION.md +29 -5
  74. package/server/lib/git/routes.js +24 -4
  75. package/server/lib/git/service.js +184 -198
  76. package/server/lib/git/service.test.js +422 -25
  77. package/server/lib/inherited-env.js +16 -9
  78. package/server/lib/inherited-env.test.js +8 -9
  79. package/server/lib/message-queue/DOCUMENTATION.md +4 -1
  80. package/server/lib/network-defaults.js +23 -0
  81. package/server/lib/network-defaults.test.js +52 -0
  82. package/server/lib/opencode/DOCUMENTATION.md +17 -1
  83. package/server/lib/opencode/bootstrap-runtime.js +2 -0
  84. package/server/lib/opencode/feature-routes-runtime.js +2 -0
  85. package/server/lib/opencode/openchamber-routes.js +64 -4
  86. package/server/lib/opencode/openchamber-routes.test.js +128 -1
  87. package/server/lib/opencode/routes.js +5 -3
  88. package/server/lib/opencode/settings-files.js +214 -0
  89. package/server/lib/opencode/settings-helpers.js +85 -41
  90. package/server/lib/opencode/settings-helpers.test.js +166 -1
  91. package/server/lib/opencode/settings-registry.json +747 -0
  92. package/server/lib/opencode/settings-runtime.js +139 -18
  93. package/server/lib/opencode/settings-runtime.test.js +163 -5
  94. package/server/lib/project-context/DOCUMENTATION.md +25 -1
  95. package/server/lib/project-context/routes.http.test.js +18 -0
  96. package/server/lib/project-context/routes.js +15 -0
  97. package/server/lib/project-context/runtime.js +248 -23
  98. package/server/lib/project-context/runtime.test.js +106 -3
  99. package/server/lib/projects/DOCUMENTATION.md +76 -0
  100. package/server/lib/projects/project-config.js +142 -9
  101. package/server/lib/projects/project-id.js +17 -0
  102. package/server/lib/projects/project-setup.js +409 -0
  103. package/server/lib/projects/project-setup.test.js +557 -0
  104. package/server/lib/projects/routes.js +59 -0
  105. package/server/lib/quota/DOCUMENTATION.md +31 -1
  106. package/server/lib/quota/providers/cline-pass.js +125 -0
  107. package/server/lib/quota/providers/cline-pass.test.js +103 -0
  108. package/server/lib/quota/providers/index.js +7 -0
  109. package/server/lib/quota/providers/neuralwatt.js +3 -6
  110. package/server/lib/quota/providers/neuralwatt.test.js +7 -7
  111. package/server/lib/quota/providers/ollama-cloud.js +31 -0
  112. package/server/lib/quota/providers/ollama-cloud.test.js +33 -1
  113. package/server/lib/quota/providers/opencode-go.js +1 -1
  114. package/server/lib/quota/providers/opencode-go.test.js +26 -1
  115. package/server/lib/quota/providers/openrouter.js +119 -24
  116. package/server/lib/quota/providers/openrouter.test.js +330 -0
  117. package/server/lib/relay/DOCUMENTATION.md +55 -0
  118. package/server/lib/relay/cross-compat.test.js +26 -0
  119. package/server/lib/relay/downstream-scheduler.js +154 -0
  120. package/server/lib/relay/downstream-scheduler.test.js +162 -0
  121. package/server/lib/relay/e2ee.js +10 -8
  122. package/server/lib/relay/flow-control.test.js +177 -0
  123. package/server/lib/relay/host-client.js +37 -8
  124. package/server/lib/relay/tunnel-codec.js +9 -0
  125. package/server/lib/relay/tunnel-host.js +66 -17
  126. package/server/lib/session-assist/runtime.js +6 -10
  127. package/server/lib/session-goal/runtime.js +4 -9
  128. package/server/lib/small-model/DOCUMENTATION.md +3 -2
  129. package/server/lib/small-model/call.js +9 -4
  130. package/server/lib/small-model/call.test.js +29 -0
  131. package/server/lib/small-model/index.js +5 -10
  132. package/server/lib/small-model/runtime-providers.js +15 -7
  133. package/server/lib/small-model/runtime-providers.test.js +7 -1
  134. package/server/lib/terminal/DOCUMENTATION.md +4 -4
  135. package/server/lib/terminal/runtime.js +11 -6
  136. package/server/lib/terminal/runtime.test.js +20 -13
  137. package/server/lib/walkthrough/DOCUMENTATION.md +33 -14
  138. package/server/lib/walkthrough/model-settings.js +8 -12
  139. package/server/lib/walkthrough/prompt.js +3 -1
  140. package/server/lib/walkthrough/sources.js +23 -2
  141. package/dist/assets/DiffView-hDBKesA_.js +0 -4
  142. package/dist/assets/FilesView-CdWzeOp9.js +0 -17
  143. package/dist/assets/MarkdownImageGallery-Czv_mhvS.js +0 -1
  144. package/dist/assets/MarkdownRendererImpl-BrMcswiy.js +0 -12
  145. package/dist/assets/OnboardingScreen-ChxQoAkx.js +0 -1
  146. package/dist/assets/PierreDiffViewer-BchBtZlp.js +0 -157
  147. package/dist/assets/SettingsView-BKf5xBsP.js +0 -28
  148. package/dist/assets/WalkthroughView-DOeCsMju.js +0 -4
  149. package/dist/assets/contextPanelEmbeddedChat-C0ZLAepL.js +0 -1
  150. package/dist/assets/de-B5JaA3SA.js +0 -10
  151. package/dist/assets/es-EPIH88ii.js +0 -16
  152. package/dist/assets/fr-CAMfxUdZ.js +0 -14
  153. package/dist/assets/index-DF5kMP-i.js +0 -39
  154. package/dist/assets/index-Dl3xbAB_.css +0 -1
  155. package/dist/assets/ja-CifOE1VN.js +0 -16
  156. package/dist/assets/ko-BBDyAyYQ.js +0 -16
  157. package/dist/assets/main-MhSaOZoB.js +0 -930
  158. package/dist/assets/markdownCore-BrBwOOMn.js +0 -3
  159. package/dist/assets/patchFileDiff-o8ms1me8.js +0 -10
  160. package/dist/assets/pl-DgEHYfFM.js +0 -16
  161. package/dist/assets/pt-BR-DuWHojUw.js +0 -16
  162. package/dist/assets/renderElectronMiniChatApp-CDgBwwCS.js +0 -2
  163. package/dist/assets/renderMobileApp-DJIKIK1r.js +0 -25
  164. package/dist/assets/runtimeEndpointReset-CYJ9O_xX.js +0 -17
  165. package/dist/assets/scheduledTasksApi-D8yamh1b.js +0 -1
  166. package/dist/assets/tr-D5m2yIWL.js +0 -7
  167. package/dist/assets/uk-D_q60oog.js +0 -16
  168. package/dist/assets/useInlineCommentController-Brz_cLcQ.js +0 -2
  169. package/dist/assets/useRootScrollLock-lXEnWlaU.js +0 -1
  170. package/dist/assets/vendor-ghostty-web-CrxinGGH.js +0 -13
  171. package/dist/assets/vendor-zod-CK21ihK-.js +0 -39
  172. package/dist/assets/zh-CN-D8QvsVeg.js +0 -16
  173. package/dist/assets/zh-TW-B9t7rQQO.js +0 -16
package/bin/cli.js CHANGED
@@ -72,6 +72,13 @@ import {
72
72
  printJson,
73
73
  logStatus,
74
74
  } from './cli-output.js';
75
+ import { applyConnectAttemptTimeout } from '../server/lib/network-defaults.js';
76
+
77
+ // The CLI process performs provider fetches (quota/usage, update notes) under
78
+ // Node/undici, whose happy-eyeballs default aborts each connect attempt after
79
+ // 250ms — distant provider endpoints routinely need longer handshakes, surfacing
80
+ // as "fetch failed" (#3399). No-op on runtimes without the setter.
81
+ applyConnectAttemptTimeout();
75
82
 
76
83
  const __filename = fileURLToPath(import.meta.url);
77
84
  const __dirname = path.dirname(__filename);
@@ -1 +1 @@
1
- import{j as a}from"./vendor-react-BUCujlKS.js";import{I as l,a as I}from"./useInlineCommentController-Brz_cLcQ.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-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};
@@ -0,0 +1,4 @@
1
+ import{R as i,f as $e,j as n}from"./vendor-react-BUCujlKS.js";import{u as le,K as Ae,a as Ne}from"./index-DVwMarHI.js";import{b as bn,u as vn,a as jn,B as Sn,C as Nn,h as kn,e as Cn,g as Rn,i as Fn,f as Dn}from"./patchFileDiff-Csk4iNUi.js";import{c as An,b as Vn,i as En,u as Ln,a as Tn,d as Mn}from"./useGitComparison-DH220WmO.js";import{f as Te,B as ke,I as M,h as xe,W as It,ac as Bn,ad as In,bb as Pn,ag as On,ae as zn,ah as _n,ai as ce,y as Rt,k as Hn,cK as Pt,t as Ke,i1 as Kn,av as Ge,a7 as Gn,a8 as $n,a9 as Wn,hS as Ot,i2 as qn,aw as zt,fP as Un,at as nt,au as Jn,bR as _t,ap as Xn,ar as Yn,as as Qn,ao as Zn}from"./useAppFontEffects-CPKeOpUo.js";import{c as es,b as ts}from"./runtimeEndpointReset-Bg5gx18H.js";import{P as ns}from"./PierreDiffViewer-DjC8nTk9.js";import{u as ss,v as rs,g as is,W as os}from"./main-BkyaQhJX.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-zod-BPAANqvH.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./VirtualizedFileDiff-C8i9HpTB.js";import"./web-components-z7hfnS8n.js";import"./computeVirtualFileMetrics-BBI7ZwrC.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-B_x_rVon.js";import"./vendor-diff-C3JhlQdm.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-DdV8vhHn.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-Bg4AEeCr.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-gg7YLRW7.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-BiWz4AVb.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./useRootScrollLock-BS4-kr7P.js";import"./scheduledTasksApi-BW0Etzwz.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";const as=i.memo(function(e){const s=$e.c(13),{index:l,staged:p,busyHunk:f,disabled:y,onAction:S}=e,{t:u}=Te();let g;s[0]!==p?(g=p?["unstage"]:["discard","stage"],s[0]=p,s[1]=g):g=s[1];const N=g;let d;s[2]===Symbol.for("react.memo_cache_sentinel")?(d={top:"var(--oc-hunk-action-offset, 0.25rem)"},s[2]=d):d=s[2];let D;s[3]!==N||s[4]!==f||s[5]!==y||s[6]!==l||s[7]!==S||s[8]!==u?(D=n.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:N.map(k=>{const m=u(k==="stage"?"diffView.hunk.stageTitle":k==="unstage"?"diffView.hunk.unstageTitle":"diffView.hunk.discardTitle",{index:l+1}),A=f?.index===l&&f.action===k;return n.jsx(ke,{variant:"ghost",size:"xs",className:xe("rounded-full bg-transparent text-muted-foreground hover:bg-transparent hover:text-foreground",k==="discard"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",k==="stage"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:y||f!==null,title:m,"aria-label":m,onPointerDown:ls,onClick:ne=>{ne.stopPropagation(),S(l,k)},children:n.jsx(M,{name:A?"loader-4":k==="stage"?"add":"arrow-go-back",className:xe(k==="stage"?"size-4":"size-3.5",A&&"animate-spin")})},k)})}),s[3]=N,s[4]=f,s[5]=y,s[6]=l,s[7]=S,s[8]=u,s[9]=D):D=s[9];let w;return s[10]!==l||s[11]!==D?(w=n.jsx("div",{className:"pointer-events-none absolute right-3 z-20",style:d,"data-hunk-actions":l,children:D}),s[10]=l,s[11]=D,s[12]=w):w=s[12],w});function ls(a){return a.stopPropagation()}const Ft=(a,e)=>{if(e.length===0)return null;let s=null,l=null;for(const f of e)f.top<=a?(!s||f.top>s.top)&&(s=f):(!l||f.top<l.top)&&(l=f);const p=s??l;return p?{path:p.path,topOffset:p.top-a}:null},cs=(a,e,s,l)=>Math.min(Math.max(0,l),Math.max(0,a+s-e)),Dt=a=>{if(!a)return null;const e=a.split(`
2
+ `);let s=null;for(const l of e){const p=l.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(p){const f=Number.parseInt(p[1]??"",10);s=Number.isFinite(f)&&f>=1?f:null;continue}if(s!==null){if(l.startsWith(" ")){s+=1;continue}if(l.startsWith("+"))return s;if(l.startsWith("-"))return Math.max(1,s)}}return null},us=1100,ds=15e3,At=500,Vt=300,Ht=1e6,ft=3,fs=a=>a<=6?a:a<=12?6:a<=25?4:2,Et={status:"loading"},ms=3,ps=i.memo(()=>{const a=$e.c(4),{t:e}=Te();let s;a[0]!==e?(s=e("diffView.binary.unavailable"),a[0]=e,a[1]=s):s=a[1];let l;return a[2]!==s?(l=n.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:n.jsx("div",{className:"typography-meta text-muted-foreground",children:s})}),a[2]=s,a[3]=l):l=a[3],l}),Kt={"?":{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"}},hs=Kt.M,gs=a=>{const e=a.index?.trim(),s=a.working_dir?.trim();return e&&e!=="?"?e.charAt(0):s?s.charAt(0):e?.charAt(0)||s?.charAt(0)||"M"},Gt=a=>{const e=gs(a);return Kt[e]??hs},xs=a=>{const{index:e,working_dir:s}=a;return e==="A"||s==="A"||e==="?"||s==="?"},Lt=a=>{const e=a.index?.trim();return!!(e&&e!=="?")},Tt=a=>!!a.working_dir?.trim()||a.index==="?",ys=(a,e)=>Un(a,e),Mt=a=>(a||"").replace(/\\/g,"/").replace(/\/+$/,""),Bt=(a,e)=>{const s=a.split(`
3
+ `),l=e.split(`
4
+ `),p=Math.min(s.length,l.length);for(let f=0;f<p;f+=1)if(s[f]!==l[f])return f+1;return l.length>s.length?s.length+1:s.length>l.length?Math.max(1,l.length):1},ws=a=>Array.isArray(a)?a.filter(e=>!e||typeof e!="object"?!1:typeof e.file=="string"):[],bs=a=>a==="added"?"A":a==="deleted"?"D":"M",mt=(a,e,s)=>Fn(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:s}:{original:"",modified:"",patch:e,fileDiff:Dn(a,e),contextMode:s},$t=(a,e,s)=>{const l=a??0,p=e??0;return!l&&!p?null:n.jsxs("span",{className:xe("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",s?.className),children:[l?n.jsxs("span",{style:{color:"var(--status-success)"},children:["+",l]}):null,p?n.jsxs("span",{style:{color:"var(--status-error)"},children:["-",p]}):null]})},vs=i.memo(a=>{const e=$e.c(63),{scope:s,workingCount:l,stagedCount:p,turnCount:f,branchCount:y,commitCount:S,showCommitOption:u,showBranchOption:g,onScopeChange:N}=a,{t:d}=Te(),[D,w]=i.useState(!1),k=s==="staged"?p:s==="turn"?f:s==="branch"?y??0:s==="commit"?S??0:l;let m;e[0]!==s||e[1]!==d?(m=d(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]=m):m=e[2];const A=m;let ne;e[3]!==d?(ne=d("diffView.scope.selectorAria"),e[3]=d,e[4]=ne):ne=e[4];let X;e[5]!==k?(X=n.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",k]}),e[5]=k,e[6]=X):X=e[6];let ue;e[7]!==A||e[8]!==X?(ue=n.jsxs("span",{className:"whitespace-nowrap",children:[A,X]}),e[7]=A,e[8]=X,e[9]=ue):ue=e[9];let F;e[10]===Symbol.for("react.memo_cache_sentinel")?(F=n.jsx(M,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=F):F=e[10];let b;e[11]!==ne||e[12]!==ue?(b=n.jsx(Xn,{asChild:!0,children:n.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":ne,children:[ue,F]})}),e[11]=ne,e[12]=ue,e[13]=b):b=e[13];let z;e[14]!==N?(z=q=>{(q==="working"||q==="staged"||q==="turn"||q==="branch"||q==="commit")&&(N?.(q),w(!1))},e[14]=N,e[15]=z):z=e[15];let se;e[16]!==d?(se=d("diffView.scope.changed"),e[16]=d,e[17]=se):se=e[17];let re;e[18]!==se?(re=n.jsx("span",{children:se}),e[18]=se,e[19]=re):re=e[19];let pe;e[20]!==l?(pe=n.jsx("span",{className:"typography-meta text-muted-foreground",children:l}),e[20]=l,e[21]=pe):pe=e[21];let Y;e[22]!==pe||e[23]!==re?(Y=n.jsx(nt,{value:"working",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[re,pe]})}),e[22]=pe,e[23]=re,e[24]=Y):Y=e[24];let de;e[25]!==d?(de=d("diffView.scope.staged"),e[25]=d,e[26]=de):de=e[26];let Q;e[27]!==de?(Q=n.jsx("span",{children:de}),e[27]=de,e[28]=Q):Q=e[28];let $;e[29]!==p?($=n.jsx("span",{className:"typography-meta text-muted-foreground",children:p}),e[29]=p,e[30]=$):$=e[30];let I;e[31]!==Q||e[32]!==$?(I=n.jsx(nt,{value:"staged",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[Q,$]})}),e[31]=Q,e[32]=$,e[33]=I):I=e[33];let P;e[34]!==d?(P=d("diffView.scope.lastTurn"),e[34]=d,e[35]=P):P=e[35];let T;e[36]!==P?(T=n.jsx("span",{children:P}),e[36]=P,e[37]=T):T=e[37];let B;e[38]!==f?(B=n.jsx("span",{className:"typography-meta text-muted-foreground",children:f}),e[38]=f,e[39]=B):B=e[39];let Z;e[40]!==T||e[41]!==B?(Z=n.jsx(nt,{value:"turn",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[T,B]})}),e[40]=T,e[41]=B,e[42]=Z):Z=e[42];let ee;e[43]!==y||e[44]!==g||e[45]!==d?(ee=g?n.jsx(nt,{value:"branch",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:d("diffView.scope.branch")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:y??"…"})]})}):null,e[43]=y,e[44]=g,e[45]=d,e[46]=ee):ee=e[46];let V;e[47]!==S||e[48]!==u||e[49]!==d?(V=u&&n.jsx(nt,{value:"commit",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:d("commitComparison.mode")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:S??"…"})]})}),e[47]=S,e[48]=u,e[49]=d,e[50]=V):V=e[50];let W;e[51]!==s||e[52]!==Y||e[53]!==I||e[54]!==Z||e[55]!==ee||e[56]!==V||e[57]!==z?(W=n.jsx(Yn,{align:"start",className:"w-40",children:n.jsxs(Qn,{value:s,onValueChange:z,children:[Y,I,Z,ee,V]})}),e[51]=s,e[52]=Y,e[53]=I,e[54]=Z,e[55]=ee,e[56]=V,e[57]=z,e[58]=W):W=e[58];let he;return e[59]!==D||e[60]!==W||e[61]!==b?(he=n.jsxs(Zn,{open:D,onOpenChange:w,children:[b,W]}),e[59]=D,e[60]=W,e[61]=b,e[62]=he):he=e[62],he}),js=i.memo(a=>{const e=$e.c(11),{changedFiles:s,selectedFile:l,onSelectFile:p}=a,{t:f}=Te();if(s.length===0)return null;let y;if(e[0]!==s||e[1]!==p||e[2]!==l||e[3]!==f){let u;e[5]!==p||e[6]!==l||e[7]!==f?(u=g=>{const N=Gt(g),d=l===g.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>p(g.path),className:xe("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",d?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[n.jsx(zt,{filePath:g.path,className:"h-3.5 w-3.5 flex-shrink-0"}),n.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:N.color},title:f(N.descriptionKey),"aria-label":f(N.descriptionKey),children:N.code}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:g.path,children:g.path}),$t(g.insertions,g.deletions)]})},g.path)},e[5]=p,e[6]=l,e[7]=f,e[8]=u):u=e[8],y=s.map(u),e[0]=s,e[1]=p,e[2]=l,e[3]=f,e[4]=y}else y=e[4];let S;return e[9]!==y?(S=n.jsx(_t,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:n.jsx("ul",{className:"flex flex-col gap-1",children:y})}),e[9]=y,e[10]=S):S=e[10],S}),Ss=i.memo(a=>{const e=$e.c(20),{filePath:s,diff:l,renderSideBySide:p}=a,{t:f}=Te(),y=l.original.length>0,S=l.modified.length>0,u=p?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",g=p?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N={contain:"layout"},e[0]=N):N=e[0];let d;e[1]!==l.original||e[2]!==s||e[3]!==y||e[4]!==g||e[5]!==p||e[6]!==f?(d=y&&n.jsxs("div",{className:g,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:f("diffView.image.original")}),n.jsx("img",{src:l.original,alt:f("diffView.image.originalAlt",{path:s}),className:p?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=l.original,e[2]=s,e[3]=y,e[4]=g,e[5]=p,e[6]=f,e[7]=d):d=e[7];let D;e[8]!==l.modified||e[9]!==s||e[10]!==S||e[11]!==y||e[12]!==g||e[13]!==p||e[14]!==f?(D=S&&n.jsxs("div",{className:g,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:f(y?"diffView.image.modified":"diffView.image.new")}),n.jsx("img",{src:l.modified,alt:f("diffView.image.modifiedAlt",{path:s}),className:p?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=l.modified,e[9]=s,e[10]=S,e[11]=y,e[12]=g,e[13]=p,e[14]=f,e[15]=D):D=e[15];let w;return e[16]!==u||e[17]!==d||e[18]!==D?(w=n.jsx("div",{className:"w-full overflow-auto p-4",style:N,children:n.jsxs("div",{className:u,children:[d,D]})}),e[16]=u,e[17]=d,e[18]=D,e[19]=w):w=e[19],w}),Ns=i.memo(a=>{const e=$e.c(17),{filePath:s,diff:l,renderSideBySide:p,wrapLines:f,hunkActions:y}=a;let S;e[0]!==s?(S=Jn(s)||"text",e[0]=s,e[1]=S):S=e[1];const u=S;if(l.isBinary){let d;return e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(ps,{}),e[2]=d):d=e[2],d}if(Ge(s)){let d;return e[3]!==l||e[4]!==s||e[5]!==p?(d=n.jsx(Ss,{filePath:s,diff:l,renderSideBySide:p}),e[3]=l,e[4]=s,e[5]=p,e[6]=d):d=e[6],d}let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g={contain:"layout"},e[7]=g):g=e[7];let N;return e[8]!==l.fileDiff||e[9]!==l.modified||e[10]!==l.original||e[11]!==s||e[12]!==y||e[13]!==u||e[14]!==p||e[15]!==f?(N=n.jsx("div",{className:"w-full",style:g,children:n.jsx(ns,{original:l.original,modified:l.modified,fileDiff:l.fileDiff,language:u,fileName:s,renderSideBySide:p,wrapLines:f,layout:"inline",hunkActions:y})}),e[8]=l.fileDiff,e[9]=l.modified,e[10]=l.original,e[11]=s,e[12]=y,e[13]=u,e[14]=p,e[15]=f,e[16]=N):N=e[16],N}),ks=i.memo(({directory:a,file:e,layout:s,wrapLines:l,isSelected:p,isExpanded:f,isMounted:y,onSelect:S,onExpandedChange:u,registerSectionRef:g,showOpenInEditorAction:N=!1,isOpeningInEditor:d=!1,onOpenInEditor:D,staged:w=!1,loadFullFiles:k=!1,initialDiffData:m=null,comparisonDiff:A,onRetryComparisonDiff:ne,readOnlyActions:X=!1,hunkActionsEnabled:ue=!1})=>{const{t:F}=Te(),{git:b}=It(),z=ce(i.useCallback(x=>x.directories.get(a)?.diffCache.get(e.path)??null,[a,e.path])),se=ce(x=>x.setDiff),re=ce(x=>x.fetchStatus),pe=le(x=>x.setDiffFileLayout),[Y,de]=i.useState(0),[Q,$]=i.useState(null),[I,P]=i.useState(!1),T=A?A.status==="error"?A.message:null:Q,B=A?A.status==="loading":I,[Z,ee]=i.useState(null),V=i.useRef(!1),[W,he]=i.useState(null),[q,fe]=i.useState(!1),[We,qe]=i.useState(null),[Me,Ve]=i.useState(null),ye=i.useRef(null),ot=i.useRef(null),Ce=i.useMemo(()=>Gt(e),[e]),Be=s==="side-by-side",Ee=k?"full":"patch",c=`${e.index}:${e.working_dir}:${e.insertions}:${e.deletions}`,_=ue&&!X&&!m&&!A&&!Ge(e.path),we=JSON.stringify([Ne(),a,e.path,w,c,Y]),H=W?.scope===we?W.patch:null,K=i.useMemo(()=>A?A.status==="ready"?A.data:null:m||(w?Me:We||(z?{original:z.original,modified:z.modified,isBinary:z.isBinary,contextMode:"full"}:null)),[A,z,m,We,w,Me]),Ue=K?.contextMode===Ee,Je=i.useCallback(x=>{ot.current=x,g(e.path,x)},[e.path,g]),Xe=i.useCallback(x=>{u(e.path,x)},[e.path,u]),Ye=i.useCallback(()=>{S(e.path)},[e.path,S]);i.useEffect(()=>{w?Ve(null):qe(null),$(null),ye.current=null},[c,w]),i.useEffect(()=>{if(!f||!y||Q)return;if(!a||A||m||K&&Ue&&(!_||H!==null)){ye.current=null,P(!1);return}const x=`${a}::${e.path}::${w?"staged":"unstaged"}::${c}::${Ee}::${Y}`;if(ye.current===x)return;ye.current=x,$(null),P(!0);let E=!1;const ie=Ne(),Oe=k?Ht:ft,U=Ge(e.path)?b.getGitFileDiff(a,{path:e.path,staged:w}):!k&&H!==null?Promise.resolve({diff:H}):b.getGitDiff(a,{path:e.path,staged:w,contextLines:Oe}),at=_&&k&&H===null?b.getGitDiff(a,{path:e.path,staged:w,contextLines:ft}).then(C=>C.diff):Promise.resolve(H),Re=Promise.all([U,at]),Fe=ds;let me;const O=new Promise((C,oe)=>{me=setTimeout(()=>oe(new Error(`Timed out after ${Fe}ms`)),Fe)});return Promise.race([Re,O]).then(([C,oe])=>{if(E||ie!==Ne())return;const be="diff"in C&&!k?C.diff:oe;if(_&&k&&be!==null&&/^@@\s/m.test(be)&&"diff"in C&&C.diff!==be&&!kn(C.diff,be))throw he(null),new Error(F("diffView.hunk.unavailable"));if(_&&be!==null&&he({scope:we,patch:be}),"diff"in C){const ve=mt(e.path,C.diff,Ee);w?Ve(ve):qe(ve)}else{const ve={original:C.original??"",modified:C.modified??"",isBinary:C.isBinary,contextMode:"full"};w?Ve(ve):se(a,e.path,ve,ie)}P(!1)}).catch(C=>{if(E||ie!==Ne())return;const oe=C instanceof Error?C.message:String(C);$(oe),P(!1)}).finally(()=>clearTimeout(me)),()=>{E=!0,clearTimeout(me),ye.current===x&&(ye.current=null)}},[H,_,we,A,Ee,K,Ue,Y,a,e.path,c,b,m,f,y,k,Q,se,w,F]);const Qe=i.useCallback(()=>{Xe(!f),Ye()},[Xe,Ye,f]),Ie=i.useCallback(()=>{$(null),he(null),qe(null),Ve(null),ye.current=null,de(x=>x+1)},[]),Ze=i.useCallback(async(x,E)=>{if(!a||!_||B||T||V.current||Z!==null)return;const ie=H?Cn(H,x):null;if(!ie){Ke.error(F("diffView.hunk.unavailable"));return}if(w&&E!=="unstage"||!w&&E==="unstage")return;V.current=!0;const Oe=Ne();ee({index:x,action:E});try{const U=E==="stage"?b.stageGitHunk:E==="unstage"?b.unstageGitHunk:b.revertGitHunk;if(!U){Ke.error(F("diffView.hunk.unsupported"));return}if(await U(a,e.path,ie),Oe!==Ne())return;Ie(),Pt.requestGitRefresh({directory:a,paths:[e.path]}),await re(a,b)}catch(U){if(Oe!==Ne())return;Ie(),Ke.error(U instanceof Error&&U.message?U.message:F("diffView.hunk.unavailable"))}finally{V.current=!1,ee(U=>U?.index===x&&U.action===E?null:U)}},[H,_,B,T,a,re,e.path,b,Z,Ie,w,F]),ge=i.useMemo(()=>_&&H!==null?Rn(H):[],[H,_]),Pe=i.useCallback(x=>n.jsx(as,{index:x,staged:w,busyHunk:Z,disabled:B||!!T,onAction:Ze}),[T,Ze,Z,B,w]),et=i.useMemo(()=>ge.length>0?{anchors:ge,render:Pe}:void 0,[ge,Pe]);return n.jsxs("div",{ref:Je,className:"scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0",children:[n.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:n.jsxs("div",{role:"button",tabIndex:0,onClick:Qe,onKeyDown:x=>{x.target===x.currentTarget&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),Qe())},className:xe("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",p?"bg-[var(--interactive-selection)]/35":null),children:[n.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),n.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:f?n.jsx(M,{name:"arrow-down-s",className:"size-4"}):n.jsx(M,{name:"arrow-right-s",className:"size-4"})}),n.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:Ce.color},title:F(Ce.descriptionKey),"aria-label":F(Ce.descriptionKey),children:Ce.code}),n.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:e.path,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(zt,{filePath:e.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const x=e.path.lastIndexOf("/");if(x===-1)return n.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:e.path});const E=e.path.slice(0,x),ie=e.path.slice(x+1);return n.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[n.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:E}),n.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[n.jsx("span",{className:"text-muted-foreground",children:"/"}),n.jsx("span",{className:"text-foreground",children:ie})]})]})})()]})})]}),n.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[$t(e.insertions,e.deletions),N&&D?n.jsx(ke,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:F("diffView.actions.openFileInEditorAtChange"),onClick:x=>{x.stopPropagation(),D(e.path,K)},disabled:d,children:d?n.jsx(M,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(M,{name:"edit",className:"size-3.5"})}):null,n.jsx(Ot,{mode:Be?"side-by-side":"unified",onModeChange:x=>{const E=x==="side-by-side"?"side-by-side":"inline";pe(e.path,E)},className:"opacity-70"})]})]})}),f&&n.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!y&&!T?n.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,T?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:F("diffView.state.failedToLoadDiff")}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:T}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>A?ne?.():Ie(),children:F("diffView.actions.retry")})]}):null,y&&B&&!K&&!T?n.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),F("diffView.state.loadingDiff")]}):null,y&&K&&!q&&e.insertions+e.deletions>At?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:F("diffView.state.largeDiff",{count:e.insertions+e.deletions})}),n.jsx("div",{className:"typography-meta text-muted-foreground",children:F("diffView.state.largeDiffDescription")}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>fe(!0),children:F("diffView.actions.renderAnyway")})]}):null,y&&K&&(q||e.insertions+e.deletions<=At)?n.jsx(n.Fragment,{children:n.jsx(Ns,{filePath:e.path,diff:K,renderSideBySide:Be,wrapLines:l,hunkActions:et})}):null]})]})}),Hi=({hideStackedFileSidebar:a=!1,stackedDefaultCollapsedAll:e=!1,pinSelectedFileHeaderToTopOnNavigate:s=!1,showOpenInEditorAction:l=!1,diffScope:p="all",onDiffScopeChange:f,targetFilePath:y=null,flushContent:S=!1})=>{const{t:u}=Te(),{git:g,files:N}=It(),d=Bn(),{rootIsGitRepo:D,gitDirectory:w,nestedRepos:k}=In(d??null),m=w??d,A=le(t=>t.openContextSurface),ne=ss(t=>t.requestSource),{screenWidth:X,isMobile:ue}=Pn(),F=On(m??null),b=zn(m??null),z=_n(m??null),se=ce(t=>t.setActiveDirectory),re=ce(t=>t.ensureStatus),pe=ce(t=>t.selectNestedRepo),Y=ce(t=>t.fetchStatus),de=ce(t=>t.fetchBranches),Q=ce(t=>t.clearDiffCache),$=ce(t=>t.setDiff),[I,P]=i.useState(null),[T,B]=i.useState(!1),[Z,ee]=i.useState(null),[V,W]=i.useState(()=>new Set),[he,q]=i.useState(()=>new Set),[fe,We]=i.useState(!1),[qe,Me]=i.useState(0),[Ve,ye]=i.useState(()=>new Map),[ot,Ce]=i.useState(!1),[Be,Ee]=i.useState(!1),[c,_]=i.useState(p);i.useEffect(()=>{_(p)},[p]);const we=le(t=>t.pendingDiffFile),H=le(t=>t.pendingDiffStaged),K=le(t=>t.pendingDiffScope),Ue=le(t=>t.setPendingDiffFile),Je=le(t=>t.diffLayoutPreference),Xe=le(t=>t.diffFileLayout),Ye=le(t=>t.setDiffFileLayout),Qe=le(t=>t.diffWrapLines),Ie=le(t=>t.setDiffWrapLines),Ze=le(t=>t.openContextFileAtLine),ge=Rt(t=>t.currentSessionId),Pe=Hn(ge??"",d??void 0),et=Qe,x=c==="staged"?!0:c==="working"?!1:null,E=x??T,ie=ue||X<=768,Oe=!!ge&&c!=="turn"&&c!=="commit"&&!ie&&!Ae(),U=c!=="turn"&&!ie&&!Ae(),at=!a&&!ie&&X>=1024,Re=i.useRef(null),Fe=i.useRef(new Map),me=i.useRef(null),O=i.useRef(null),C=i.useRef(!1),oe=i.useRef(null),be=i.useRef(null),ve=i.useRef(null),lt=i.useRef(null),pt=i.useCallback(()=>{const t=Re.current;if(!t)return null;const r=t.getBoundingClientRect().top,o=[];for(const[h,v]of Fe.current)v&&o.push({path:h,top:v.getBoundingClientRect().top});return Ft(r,o)},[]),ze=i.useCallback(()=>{me.current=null,C.current=!1,ee(null),O.current!==null&&(window.cancelAnimationFrame(O.current),O.current=null)},[]),_e=i.useCallback(t=>{W(r=>{if(r.has(t))return r;const o=new Set(r);return o.add(t),o})},[]),tt=i.useMemo(()=>{for(let t=Pe.length-1;t>=0;t-=1){const r=Pe[t];if(r.role==="user")return ws(r.summary?.diffs)}return[]},[Pe]),Wt=i.useMemo(()=>{const t=new Map;for(const r of tt)if(r.file){if(typeof r.patch=="string"){t.set(r.file,mt(r.file,r.patch,"patch"));continue}t.set(r.file,{original:r.before??"",modified:r.after??"",contextMode:"full"})}return t},[tt]),qt=i.useMemo(()=>b?.files?b.files.filter(Tt).length:0,[b]),Ut=i.useMemo(()=>b?.files?b.files.filter(Lt).length:0,[b]),Jt=tt.length,J=b?.current??null,De=bn(m??null,J,c==="commit"&&!Ae()),Le=De.selectedCommit?.hash??null;i.useEffect(()=>{c==="commit"&&Ae()&&(_("working"),f?.("working"))},[c,f]);const He=ce(t=>m?t.directories.get(m)?.branches??null:null),Xt=ce(t=>m?t.directories.get(m)?.isLoadingBranches??!1:!1),Yt=i.useCallback(()=>{m&&de(m,g)},[m,de,g]),Qt=An(m??null,F!==!1,Xt,!!He,Yt,ms),ht=i.useMemo(()=>{const t=b?.tracking?.trim().split("/")[0];return(t&&He?.defaultBranches?.[t])??He?.defaultBranches?.origin??null},[He,b?.tracking]),gt=!Ae()&&Vn(J,ht),Zt=b!==null,xt=Ae()||Qt||En(J,ht,Zt,He!==null),en=vn(t=>t.setOverride),{base:je,resolved:tn,revision:yt}=jn(m??null,J,gt&&c==="branch"),[nn,sn]=i.useState(0);i.useEffect(()=>{const t=Mn(c,!xt);t!==c&&(_(t),t==="working"&&f?.("working"))},[c,xt,f]);const rn=i.useMemo(()=>c==="commit"&&Le?{kind:"commit",hash:Le}:c==="branch"&&je&&J?{kind:"branch",baseRef:je,headRef:J}:null,[c,je,J,Le]),Se=Ln(m??null,rn,!Ae(),c==="branch"?yt:""),{fetchDiff:wt}=Se,st=c==="commit"?Se.files:null,bt=c==="commit"?Se.error:null,rt=c==="branch"?Se.files:null,vt=c==="branch"?Se.error:null,jt=Se.files?Se.key:null,on=i.useMemo(()=>c==="branch"||c==="commit"?Array.from(V).sort().join("\0"):"",[c,V]),an=i.useCallback(async t=>{try{const r=await wt(t,fe?Ht:ft);return{status:"ready",data:mt(t,r.diff,fe?"full":"patch")}}catch(r){return{status:"error",message:r instanceof Error?r.message:u("diffView.state.failedToLoadDiff")}}},[wt,fe,u]),ln=Tn(jt,on,jt?an:null,Et,JSON.stringify([c==="branch"?yt:"",nn,fe])),cn=rt?.length??null,j=i.useMemo(()=>{if(c==="commit")return(st??[]).map(o=>({path:o.path,index:"",working_dir:o.status,insertions:o.insertions,deletions:o.deletions,isNew:o.status==="A"}));if(c==="branch")return(rt??[]).map(o=>({path:o.path,index:"",working_dir:o.status,insertions:0,deletions:0,isNew:o.status==="A"})).sort((o,h)=>o.path.localeCompare(h.path));if(c==="turn")return tt.map(o=>({path:o.file??"",index:"",working_dir:bs(o.status),insertions:o.additions??0,deletions:o.deletions??0,isNew:o.status==="added"})).filter(o=>o.path).sort((o,h)=>o.path.localeCompare(h.path));if(!b?.files)return[];const t=b.diffStats??{},r=c==="staged"?Lt:c==="working"?Tt:()=>!0;return b.files.filter(r).map(o=>({...o,insertions:t[o.path]?.insertions??0,deletions:t[o.path]?.deletions??0,isNew:xs(o)})).sort((o,h)=>o.path.localeCompare(h.path))},[c,rt,st,tt,b]),ct=i.useMemo(()=>j.map(t=>t.path).join("\0"),[j]);i.useEffect(()=>{const t=ct?ct.split("\0"):[],r=new Set(t),o=`${m??""}:${c}:${e?"collapsed":"default"}`,h=be.current!==o;be.current=o,W(v=>{if(h){const L=e?0:fs(t.length);return new Set(t.slice(0,L))}let G=!1;const R=new Set;for(const L of v){if(!r.has(L)){G=!0;continue}R.add(L)}return G?R:v}),q(v=>{if(h)return new Set;let G=!1;const R=new Set;for(const L of v){if(!r.has(L)){G=!0;continue}R.add(L)}return G?R:v})},[c,ct,m,e]);const St=i.useCallback(()=>{oe.current=null;const t=Re.current;if(!t)return;const r=t.getBoundingClientRect(),o=r.top-Vt,h=r.bottom+Vt,v={},G=[];for(const[R,L]of Fe.current){if(!L)continue;const te=L.getBoundingClientRect();G.push({path:R,top:te.top}),V.has(R)&&(te.bottom<o||te.top>h||(v[R]=!0))}ve.current=Ft(r.top,G),q(R=>{let L=!1;const te=new Set(R);for(const Ct of Object.keys(v))te.has(Ct)||(te.add(Ct),L=!0);return L?te:R})},[V]),ae=i.useCallback(()=>{typeof window>"u"||oe.current===null&&(oe.current=window.requestAnimationFrame(St))},[St]);i.useEffect(()=>{const t=Re.current;if(t)return ae(),t.addEventListener("scroll",ae,{passive:!0}),window.addEventListener("resize",ae),()=>{t.removeEventListener("scroll",ae),window.removeEventListener("resize",ae),oe.current!==null&&(window.cancelAnimationFrame(oe.current),oe.current=null)}},[j,V,ae]);const ut=i.useCallback(t=>{const r=Xe[t.path];if(r)return r;if(Je==="inline")return"inline";if(Je==="side-by-side")return"side-by-side";const o=X<us;return t.isNew||o?"inline":"side-by-side"},[Xe,Je,X]),Nt=i.useMemo(()=>j.length===0?null:j.every(t=>ut(t)==="side-by-side")?"side-by-side":"inline",[j,ut]);i.useEffect(()=>{m&&(se(m),re(m,g))},[m,se,re,g]),i.useEffect(()=>{if(m)return Pt.onGitRefreshHint(t=>{Mt(t.directory)===Mt(m)&&(t.paths?.length&&(lt.current=pt()??ve.current,Q(m,t.paths),ye(r=>{const o=new Map(r);for(const h of t.paths??[])o.set(h,(o.get(h)??0)+1);return o})),Y(m,g,{silent:!0}))})},[pt,Q,m,Y,g]),i.useLayoutEffect(()=>{const t=lt.current;if(!t)return;lt.current=null;const r=Re.current,o=Fe.current.get(t.path);if(!r||!o)return;const h=r.getBoundingClientRect().top,v=o.getBoundingClientRect().top-h;r.scrollTop=cs(r.scrollTop,t.topOffset,v,r.scrollHeight-r.clientHeight),ve.current=t},[Ve]),i.useEffect(()=>{c!=="all"&&!K||we&&(K&&_(K),P(we),B(K==="staged"||!K&&H),Ue(null),C.current=!0,me.current=we,_e(we),Me(t=>t+1))},[c,_e,we,K,H,Ue]),i.useEffect(()=>{if(c==="all")return;const t=y?.trim();t&&(P(t),B(c==="staged"),C.current=!0,me.current=t,_e(t),Me(r=>r+1))},[c,_e,y]),i.useEffect(()=>{if(!I)return;j.some(r=>r.path===I)||(P(null),B(!1))},[j,I]);const un=i.useCallback((t,r)=>{const o=Fe.current;r?o.set(t,r):o.delete(t),ae()},[ae]),dn=i.useCallback((t,r)=>{ze(),W(o=>{const h=o.has(t);if(r===h)return o;const v=new Set(o);return r?v.add(t):v.delete(t),v}),r||q(o=>{if(!o.has(t))return o;const h=new Set(o);return h.delete(t),h}),ae()},[ze,ae]),fn=i.useCallback(()=>{ze(),W(t=>t.size>0?new Set:new Set(j.map(r=>r.path))),q(new Set),ae()},[ze,j,ae]),mn=i.useCallback(async t=>{if(!ge)return;const r=Rt.getState().getDirectoryForSession(ge)||d||"";if(!r){Ke.error(u("diffView.reviewDialog.toast.noSessionDirectory"));return}Ee(!0);try{await Kn({originalSessionID:ge,directory:r,providerID:t.providerID,modelID:t.modelID,agent:t.agent||void 0,variant:t.variant||void 0,generateHandoff:t.generateHandoff,returnAfterHandoffRequest:t.generateHandoff,autoReview:t.autoReview}),Ce(!1)}catch(o){console.error("[review-flow] failed to start review flow",o),Ke.error(o instanceof Error?o.message:u("diffView.reviewDialog.toast.startFailed"))}finally{Ee(!1)}},[ge,d,u]),it=i.useCallback(t=>{const r=Fe.current.get(t),o=Re.current;if(!r||!o)return!1;const h=r.getBoundingClientRect().top-o.getBoundingClientRect().top;return o.scrollTo({top:o.scrollTop+h,behavior:"auto"}),!0},[]);i.useEffect(()=>{if(!me.current)return;let r=0;const o=20;let h=!1;const v=(R=!0)=>{h||(h=!0,me.current=null,C.current=!1,R&&ee(null),O.current!==null&&(window.cancelAnimationFrame(O.current),O.current=null))},G=()=>{if(h){O.current=null;return}const R=me.current;if(!R){v(),O.current=null;return}if(!it(R)){r+=1,r<o?O.current=window.requestAnimationFrame(G):(v(),O.current=null);return}if(s&&C.current){ee(R),v(!1);return}v()};return O.current=window.requestAnimationFrame(G),()=>{h=!0,O.current!==null&&(window.cancelAnimationFrame(O.current),O.current=null)}},[s,qe,it]);const pn=i.useCallback(t=>{},[]),dt=i.useCallback(t=>{ze(),P(t),B(!1),C.current=!0,me.current=t,_e(t),Me(r=>r+1),it(t)},[ze,_e,it]);i.useEffect(()=>{const t=r=>{if(!r.altKey||r.metaKey||r.ctrlKey||r.shiftKey||r.key!=="ArrowDown"&&r.key!=="ArrowUp")return;const o=r.target;if(o instanceof HTMLElement&&(o.isContentEditable||o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.closest('[role="dialog"]'))||j.length===0)return;const h=r.key==="ArrowDown"?1:-1,v=I?j.findIndex(L=>L.path===I):-1,G=v===-1?h>0?0:j.length-1:v+h,R=j[G];R&&(r.preventDefault(),dt(R.path))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[j,I,dt]);const hn=i.useCallback(t=>{const r=t==="side-by-side"?"side-by-side":"inline";j.forEach(o=>{Ye(o.path,r)})},[j,Ye]),[gn,kt]=i.useState(null),xn=i.useCallback(async(t,r)=>{if(!m||!t)return;kt(t);const o=Ne();try{let h=null;if(r?.patch&&!r.isBinary&&!Ge(t)?h=Dt(r.patch):r&&r.contextMode==="full"&&!r.isBinary&&!Ge(t)&&(h=Bt(r.original,r.modified)),h===null)try{const te=await g.getGitDiff(m,{path:t,staged:E,contextLines:3});h=Dt(te.diff)}catch{h=null}let v=r;if(h===null||!v){const te=await g.getGitFileDiff(m,{path:t,staged:E});v={original:te.original??"",modified:te.modified??"",isBinary:te.isBinary},E||$(m,t,v,o)}const G=h??(v.isBinary||Ge(t)?1:Bt(v.original,v.modified)),R=ys(m,t),L=await rs(N,R,{directory:m});if(!L.ok){Ke.error(is(L.reason));return}Ze(m,R,G,1)}finally{kt(h=>h===t?null:h)}},[E,m,N,g,Ze,$]),yn=()=>{if(!m)return null;const t=r=>x!==null?x:T&&r===I;return n.jsxs("div",{className:xe("flex min-w-0 flex-1 min-h-0 h-full",S?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[at&&n.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[n.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:u("diffView.section.files")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:j.length})]}),n.jsx(js,{changedFiles:j,selectedFile:null,onSelectFile:dt})]}),n.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:n.jsx(_t,{ref:Re,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:n.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:j.map(r=>n.jsx(ks,{directory:m,file:r,layout:ut(r),wrapLines:et,isSelected:!1,isExpanded:V.has(r.path),isMounted:he.has(r.path)||r.path===Z,onSelect:pn,onExpandedChange:dn,registerSectionRef:un,showOpenInEditorAction:l&&c!=="turn",isOpeningInEditor:gn===r.path,onOpenInEditor:(o,h)=>{xn(o,h)},staged:t(r.path),loadFullFiles:fe,readOnlyActions:c==="branch"||c==="commit",hunkActionsEnabled:c==="all"||c==="working"||c==="staged",comparisonDiff:c==="branch"||c==="commit"?ln.get(r.path)??Et:void 0,onRetryComparisonDiff:()=>sn(o=>o+1),initialDiffData:c==="turn"?Wt.get(r.path)??null:null},`${Ne()}:${m}:${r.path}:${Ve.get(r.path)??0}`))})})})]})},wn=()=>{if(!m)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:u("diffView.state.selectSessionDirectory")});if(c!=="turn"&&z&&!b)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),u("diffView.state.loadingRepositoryStatus")]});if(c!=="turn"&&F===!1)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:u("diffView.state.notGitRepository")});if(c==="commit"){if(bt)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("p",{className:"typography-meta text-muted-foreground",children:bt}),n.jsx(ke,{variant:"outline",size:"sm",onClick:()=>{Se.refresh()},children:u("diffView.actions.retry")})]});if(!Le&&!De.loading)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:De.error??u("commitComparison.noCommits")});if(!st)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),u("diffView.state.loadingDiff")]})}if(c==="branch"){if(!tn)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),u("diffView.branch.resolvingBase")]});if(!je)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[n.jsx(M,{name:"git-branch",className:"size-6 text-muted-foreground"}),n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:u("diffView.branch.noBaseTitle")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:u("gitView.pr.toast.baseBranchRequired")})]});if(vt)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:u("diffView.branch.loadError")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:vt}),n.jsx(ke,{variant:"outline",size:"sm",onClick:()=>{Se.refresh()},children:u("diffView.actions.retry")})]});if(rt===null)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),u("diffView.branch.loadingFiles")]})}return j.length===0?n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:c==="turn"?u("diffView.state.noLastTurnChanges"):c==="commit"?u("commitComparison.emptyDiff"):c==="branch"&&je?u("diffView.branch.empty",{base:ts(je)}):u("diffView.state.cleanWorkingTree")}):yn()};return n.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[n.jsxs("div",{className:"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[D===!1&&Array.isArray(k)&&k.length>0?n.jsx(es,{repositories:k,selectedRepository:w??null,onSelectRepository:t=>{d&&pe(d,t)},repositoryRoot:d??void 0}):null,!ue&&(c!=="all"?n.jsx(vs,{scope:c,workingCount:qt,stagedCount:Ut,turnCount:Jt,branchCount:cn,commitCount:st?.length??null,showCommitOption:!Ae(),showBranchOption:gt,onScopeChange:t=>{_(t),f?.(t)}}):n.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:n.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:z&&!b?u("diffView.state.loadingChanges"):j.length===1?u("diffView.summary.changedFilesSingle",{count:j.length}):u("diffView.summary.changedFilesPlural",{count:j.length})})})),c==="branch"&&n.jsx(Sn,{branches:He?.all??[],currentBranch:J,base:je,onSelect:t=>{m&&J&&en(m,J,t)}},JSON.stringify([m,J])),c==="commit"&&n.jsx(Nn,{commits:De.commits,selectedHash:Le,loading:De.loading,error:De.error,onSelect:De.select,onRefresh:()=>{De.refresh()}},JSON.stringify([m,J])),j.length>0&&n.jsxs(ke,{variant:"ghost",size:"sm",onClick:fn,className:xe("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:V.size>0?u("diffView.actions.collapseAll"):u("diffView.actions.expandAll"),children:[n.jsx(M,{name:"expand-up-down",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:V.size>0?u("diffView.actions.collapseAll"):u("diffView.actions.expandAll")})]}),j.length>0&&Oe&&n.jsxs(ke,{variant:"default",size:"sm",onClick:()=>Ce(!0),disabled:Be,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":u("diffView.actions.reviewAria"),children:[Be?n.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(M,{name:"search-eye",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:u("diffView.actions.review")})]}),j.length>0&&U&&n.jsxs(ke,{variant:"outline",size:"sm",onClick:()=>{const t=m??"";ne(t,c==="commit"&&Le?{kind:"commit",hash:Le}:c==="branch"&&je&&J?{kind:"branch",baseRef:je,headRef:J}:{kind:"working-tree",scope:c==="staged"||c==="working"?c:"all"}),A(t,"walkthrough")},className:xe("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",os),"aria-label":u("walkthrough.action.open"),children:[n.jsx(M,{name:"route",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:u("walkthrough.action.open")})]}),j.length>0&&n.jsxs(Gn,{children:[n.jsx($n,{asChild:!0,children:n.jsx(ke,{variant:"ghost",size:"sm",onClick:()=>We(t=>!t),"aria-pressed":fe,"aria-label":u(fe?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles"),className:xe("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",fe&&"bg-interactive-selection text-interactive-selection-foreground"),children:n.jsx(M,{name:"file-download",className:"size-4"})})}),n.jsx(Wn,{children:n.jsx("p",{children:u(fe?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles")})})]}),j.length>0&&n.jsx(ke,{variant:"ghost",size:"sm",onClick:()=>Ie(!Qe),className:xe("h-5 w-5 p-0 transition-opacity",et?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:u(et?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:n.jsx(M,{name:"text-wrap",className:"size-4"})}),Nt&&n.jsx(Ot,{mode:Nt==="side-by-side"?"side-by-side":"unified",onModeChange:hn})]}),n.jsx(qn,{open:ot,onOpenChange:Ce,projectDirectory:m??null,submitting:Be,onConfirm:mn}),wn()]})};export{Hi as DiffView,ks 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 Q,ar as Ee,a7 as be,a8 as ye,I as E,a9 as we,h as Z,B as Y,a2 as Ie,h4 as Te,bF as fe,bG as ue,bH as pe,bI as ge,bJ as xe,bK as ve,b7 as Me,b_ as Fe,t as ae}from"./useAppFontEffects-D7sNpuL2.js";import{u as ke}from"./index-DF5kMP-i.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 He(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 Pe(p){const e=He(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=Pe(r),t[0]=r,t[1]=c):c=t[1];const u=c,{t:T}=Q(),P=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 I=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 H=L,X=`group flex items-center gap-2 py-1.5 cursor-pointer ${f??"px-3"}`;let F;t[13]!==v?(F=v>0?{paddingLeft:`${v}px`}:void 0,t[13]=v,t[14]=F):F=t[14];const q=o?H:null;let K;t[15]!==u.color?(K={color:u.color},t[15]=u.color,t[16]=K):K=t[16];let G;t[17]!==u.code||t[18]!==P||t[19]!==K?(G=s.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:K,title:P,"aria-label":P,children:u.code}),t[17]=u.code,t[18]=P,t[19]=K,t[20]=G):G=t[20];let O;t[21]!==r.path?(O=s.jsx(Ee,{filePath:r.path,className:"h-3.5 w-3.5 shrink-0"}),t[21]=r.path,t[22]=O):O=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 J;t[30]===Symbol.for("react.memo_cache_sentinel")?(J={color:"var(--status-success)"},t[30]=J):J=t[30];let i;t[31]!==R?(i=s.jsxs("span",{style:J,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]!==T?(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":T("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:T("gitView.changes.revertFileTooltip")})]}):null,t[40]=r.path,t[41]=W,t[42]=h,t[43]=j,t[44]=T,t[45]=C):C=t[45];const B=o?null:H;let ee;return t[46]!==I||t[47]!==d||t[48]!==F||t[49]!==q||t[50]!==G||t[51]!==O||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:I,style:F,children:[q,G,O,_,D,C,B]}),t[46]=I,t[47]=d,t[48]=F,t[49]=q,t[50]=G,t[51]=O,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},Ge=(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},Oe=1e3,Ce=34,de=30,le="pl-0 pr-2",me=(p,e)=>`${p} ${e}`,Je=({groups:p,diffStats:e,revertingPaths:t,isRevertingAll:r=!1,headerBackgroundClassName:w="bg-sidebar",onVisiblePathsChange:x,onRevertAll:g,onRevertDirectory:d})=>{const{t:a}=Q(),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,T]=N.useState(null),P=N.useMemo(()=>b.map(i=>Le(i.entries)),[b]),R=N.useMemo(()=>{const i=[];return b.forEach((n,l)=>{Array.from(P[l]?.children.values()??[]).forEach(m=>{i.push(me(n.id,m.path))})}),i},[P,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))}),Ge(P[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,P,b]),z=A.length,I=z>=Oe,M=ze({count:z,enabled:I,getScrollElement:()=>h.current,estimateSize:()=>Ce,overscan:12,getItemKey:i=>A[i]?.key??i}),y=M.getVirtualItems(),$=N.useMemo(()=>{if(!I)return 0;const i=h.current?.scrollTop??0;return y.find(l=>l.end>i)?.index??0},[I,y,h]);N.useEffect(()=>{if(!x)return;const i=n=>n&&n.type==="file"?n.file.path:null;if(z===0){x([]);return}if(!I){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,I,$]);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})},[]),H=N.useMemo(()=>{const i=new Set;return b.forEach(n=>n.entries.forEach(l=>i.add(l.path))),Array.from(i)},[b]),X=H.length,F=u?r||u.paths.some(i=>t.has(i)):!1,q=N.useCallback(async()=>{!g||r||H.length===0||(await g(H),c(!1))},[H,r,g]),K=N.useCallback(async()=>{!d||!u||F||(await d(u.paths),T(null))},[F,d,u]),G=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]),O=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:()=>T({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 G(l,n);if(i.type==="directory")return O(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,O,G,t,a,b]),J=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(Ie,{ref:h,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:I?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(J(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",J(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(Te,{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=>{!F&&!i&&T(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:()=>T(null),disabled:F,children:a("gitView.common.cancel")}),s.jsx(Y,{variant:"destructive",size:"sm",onClick:()=>{K()},disabled:F||!u,children:a(F?"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}=Q(),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 H=y.scrollHeight,X=Math.min(Math.max(H,he),re);y.style.height=`${X}px`,y.style.overflowY=H>re?"auto":"hidden",H>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 T=S?"on":"off",P=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 I;e[12]===Symbol.for("react.memo_cache_sentinel")?(I={minHeight:he,maxHeight:re},e[12]=I):I=e[12];let M;return e[13]!==h||e[14]!==P||e[15]!==R||e[16]!==z||e[17]!==j||e[18]!==c||e[19]!==u||e[20]!==T||e[21]!==t?(M=s.jsx("textarea",{ref:V,value:t,onChange:j,onKeyDown:c,placeholder:u,rows:1,disabled:h,autoCorrect:T,autoCapitalize:P,spellCheck:R,className:z,style:I}),e[13]=h,e[14]=P,e[15]=R,e[16]=z,e[17]=j,e[18]=c,e[19]=u,e[20]=T,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}=Q();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}=Q(),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:T,hasTouchInput:P}=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 I;e[12]!==A||e[13]!==z?(I=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]=I):I=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]!==P||e[26]!==T||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:P,isMobile:T}),e[24]=r,e[25]=P,e[26]=T,e[27]=w,e[28]=W,e[29]=y,e[30]=$,e[31]=L):L=e[31];let H;e[32]!==V||e[33]!==k||e[34]!==o?(H=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]=H):H=e[35];const X=a||f!==null||v||t===0;let F;e[36]!==o?(F=o("gitView.commit.generateAria"),e[36]=o,e[37]=F):F=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 G;e[42]!==K?(G=s.jsx("span",{className:"commit-actions__label",children:K}),e[42]=K,e[43]=G):G=e[43];let O;e[44]!==d||e[45]!==X||e[46]!==F||e[47]!==q||e[48]!==G?(O=s.jsxs(Y,{variant:"outline",size:"sm",onClick:d,disabled:X,type:"button","aria-label":F,className:"commit-actions__btn",children:[q,G]}),e[44]=d,e[45]=X,e[46]=F,e[47]=q,e[48]=G,e[49]=O):O=e[49];let _;e[50]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx("div",{className:"flex-1"}),e[50]=_):_=e[50];const J=!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]!==J||e[58]!==i||e[59]!==n?(l=s.jsx(Y,{size:"sm",variant:"outline",onClick:h,disabled:J,className:"commit-actions__btn whitespace-nowrap","aria-label":i,children:n}),e[56]=h,e[57]=J,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]!==T||e[65]!==S||e[66]!==o?(m=T?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]=T,e[65]=S,e[66]=o,e[67]=m):m=e[67];let D;e[68]!==O||e[69]!==l||e[70]!==m?(D=s.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[O,_,l,m]}),e[68]=O,e[69]=l,e[70]=m,e[71]=D):D=e[71];let C;e[72]!==L||e[73]!==H||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,H,D]}),e[72]=L,e[73]=H,e[74]=D,e[75]=M,e[76]=C):C=e[76];let B;return e[77]!==C||e[78]!==I?(B=s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[I,C]}),e[77]=C,e[78]=I,e[79]=B):B=e[79],B},Qe=({open:p,onOpenChange:e,targetBranch:t,changedFileCount:r,onCommitAndSwitch:w,onGenerateMessage:x,onRevertAndSwitch:g})=>{const{t:d}=Q(),[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(Fe,{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{Je as C,Qe 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,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};