@pi-chamber/web 0.9.4 → 0.9.6

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 (107) hide show
  1. package/README.md +15 -0
  2. package/dist/assets/DiagramView-0Iq1ak1I.js +1 -0
  3. package/dist/assets/{DiffView-CBOrV4hS.js → DiffView-DD1AFRi3.js} +2 -2
  4. package/dist/assets/FileSaveConflictDialog-CoKwDovb.js +3 -0
  5. package/dist/assets/FilesView-B_BF39ef.js +6 -0
  6. package/dist/assets/GitView-LFEpCasf.js +8 -0
  7. package/dist/assets/{JsonTreeView-CKWGm5MS.js → JsonTreeView-Cwjgvh4g.js} +1 -1
  8. package/dist/assets/MarkdownRendererImpl-_7kV1yNw.js +12 -0
  9. package/dist/assets/PatchDiff-DG43C1HW.js +1 -0
  10. package/dist/assets/{SessionSwitcherContent-z9VYCXrT.js → SessionSwitcherContent-DCFXPY3d.js} +1 -1
  11. package/dist/assets/SessionSwitcherDropdown-QY7FKuEQ.js +2 -0
  12. package/dist/assets/SessionUnreadDot-DGT31A3z.js +1 -0
  13. package/dist/assets/SettingsView-eG-wN-yY.js +2 -0
  14. package/dist/assets/SettingsWindow-Dvnp8YrA.js +1 -0
  15. package/dist/assets/ToolOutputDialog-IlCrS6BR.js +8 -0
  16. package/dist/assets/ToolPartDiffPreview-D68JV0rR.js +1 -0
  17. package/dist/assets/{VirtualizedFileDiff-DfaXovGB.js → VirtualizedFileDiff-Bl-rAYeh.js} +3 -3
  18. package/dist/assets/collapsible-BjniCdZ5.js +1 -0
  19. package/dist/assets/computeVirtualFileMetrics-FSOm2VrW.js +3 -0
  20. package/dist/assets/contextFileOpenGuard-Bxb6AIPa.js +1 -0
  21. package/dist/assets/gitStatusPredicates-DxolDpMd.js +134 -0
  22. package/dist/assets/index-BpmGBboM.css +1 -0
  23. package/dist/assets/index-DZnzXhTs.js +8 -0
  24. package/dist/assets/index-Dh58uD3I.js +1 -0
  25. package/dist/assets/isDiffPlainText-D3_04XCh.js +1 -0
  26. package/dist/assets/isFilePlainText-CHouYQhH.js +1 -0
  27. package/dist/assets/{main-DG1oZ0Wj.js → main-CH3EqGJI.js} +2 -2
  28. package/dist/assets/main-HzTrVvbB.js +135 -0
  29. package/dist/assets/{markdownCore-DUjQU2i0.js → markdownCore-DJU4KvHP.js} +2 -2
  30. package/dist/assets/{miniChat-BEAtOkr9.js → miniChat-Ca3TpaaA.js} +2 -2
  31. package/dist/assets/{mobile-DOFBBQg2.js → mobile-lj4gpGsO.js} +2 -2
  32. package/dist/assets/renderElectronMiniChatApp-rUFfaD-T.js +2 -0
  33. package/dist/assets/renderMobileApp-CcWQ1sCf.js +11 -0
  34. package/dist/assets/runtimeEndpointReset-D2MmSbDk.js +53 -0
  35. package/dist/assets/{runtimeSurface-CySRuLbN.js → runtimeSurface-CE_VNjdH.js} +1 -1
  36. package/dist/assets/{useAppFontEffects-C4JL1x7k.js → useAppFontEffects-BvFAP9zG.js} +102 -103
  37. package/dist/assets/useFilesViewSearch-BD79p3A2.js +7 -0
  38. package/dist/assets/usePushVisibilityBeacon-CWg0j-Wg.js +10 -0
  39. package/dist/assets/useSwitcherItems-CazJ6Yox.js +1 -0
  40. package/dist/assets/{vendor-base-ui-vkqQ2P9o.js → vendor-base-ui-CdaWtC7e.js} +1 -1
  41. package/dist/assets/vendor-beautiful-mermaid-D3YCkKz7.js +111 -0
  42. package/dist/assets/{vendor-codemirror-commands-DYppkHEk.js → vendor-codemirror-commands-CNlncqrr.js} +1 -1
  43. package/dist/assets/{vendor-codemirror-language-data-C493X_9w.js → vendor-codemirror-language-data-CP3j3-xu.js} +2 -2
  44. package/dist/assets/{vendor-replit-codemirror-vim-CGHHNQxC.js → vendor-replit-codemirror-vim-DaSwPsXt.js} +1 -1
  45. package/dist/assets/{web-components-B2Rw__yK.js → web-components-DWuadqra.js} +3 -3
  46. package/dist/index.html +4 -4
  47. package/dist/mini-chat.html +3 -3
  48. package/dist/mobile.html +3 -3
  49. package/package.json +2 -2
  50. package/server/lib/fs/DOCUMENTATION.md +15 -3
  51. package/server/lib/fs/routes.js +369 -51
  52. package/server/lib/fs/routes.test.js +565 -3
  53. package/server/lib/fs/search.js +74 -29
  54. package/server/lib/pi/routes.js +56 -3
  55. package/server/lib/pi/routes.test.js +165 -0
  56. package/server/lib/pi/session-daemon/DOCUMENTATION.md +19 -6
  57. package/server/lib/pi/session-daemon/prompt-operations.test.js +151 -3
  58. package/server/lib/pi/session-daemon/prompt-preflight.test.js +556 -0
  59. package/server/lib/pi/session-daemon/sdk-upgrade.test.js +157 -0
  60. package/server/lib/pi/session-daemon/send-operation-dedup.test.js +331 -0
  61. package/server/lib/pi/session-daemon/send-operation-registry.js +264 -0
  62. package/server/lib/pi/session-daemon/send-operation-registry.test.js +205 -0
  63. package/server/lib/pi/session-daemon/session-daemon-extensions.e2e.test.js +16 -5
  64. package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +3 -1
  65. package/server/lib/pi/session-daemon/session-daemon.js +514 -107
  66. package/server/lib/pi/session-daemon/session-daemon.test.js +37 -13
  67. package/server/lib/pi/session-daemon/session-idle-residency.test.js +749 -0
  68. package/server/lib/pi/session-daemon/session-replay.js +98 -0
  69. package/server/lib/pi/session-daemon/session-replay.test.js +628 -0
  70. package/server/lib/pi/ui-settings-store.js +16 -10
  71. package/server/lib/pi/ui-settings-store.test.js +91 -0
  72. package/server/lib/server/cors.js +6 -0
  73. package/server/lib/server/cors.test.js +3 -0
  74. package/server/lib/stt/DOCUMENTATION.md +1 -1
  75. package/server/lib/stt/local/worker-client.js +11 -3
  76. package/server/lib/stt/local/worker-client.test.js +255 -0
  77. package/server/lib/workspace/host.js +6 -2
  78. package/server/lib/workspace/host.test.js +15 -0
  79. package/dist/assets/DiagramEditor-DuGmiPZ5.js +0 -1
  80. package/dist/assets/DiagramView-CHy1Glsl.js +0 -1
  81. package/dist/assets/FilesView-CK2YVs_W.js +0 -6
  82. package/dist/assets/GitView-BEFLOv_7.js +0 -8
  83. package/dist/assets/MarkdownRendererImpl-hE_nmSqe.js +0 -12
  84. package/dist/assets/PatchDiff-BagRxMON.js +0 -1
  85. package/dist/assets/SessionSwitcherDropdown-icxJk_lT.js +0 -2
  86. package/dist/assets/SessionUnreadDot-Bv-5KguB.js +0 -1
  87. package/dist/assets/SettingsView-Ck0qxtKP.js +0 -2
  88. package/dist/assets/SettingsWindow-GQRL2CdD.js +0 -1
  89. package/dist/assets/ToolOutputDialog-CxJUXVZW.js +0 -8
  90. package/dist/assets/ToolPartDiffPreview-BXuLRWHT.js +0 -1
  91. package/dist/assets/collapsible-szfZ0Syc.js +0 -1
  92. package/dist/assets/computeVirtualFileMetrics-DG_E6iaN.js +0 -3
  93. package/dist/assets/contextFileOpenGuard-DPBE3ELv.js +0 -1
  94. package/dist/assets/gitStatusPredicates-OljV4Bb2.js +0 -134
  95. package/dist/assets/index-DNoEeZ2U.css +0 -1
  96. package/dist/assets/index-DmexVlTQ.js +0 -1
  97. package/dist/assets/index-KIdiBFJs.js +0 -8
  98. package/dist/assets/isDiffPlainText-aikgiqLb.js +0 -1
  99. package/dist/assets/isFilePlainText-D-Dl6LqX.js +0 -1
  100. package/dist/assets/main-BXdraZTZ.js +0 -135
  101. package/dist/assets/renderElectronMiniChatApp-B0K72YnS.js +0 -2
  102. package/dist/assets/renderMobileApp-Ca_BO_s4.js +0 -11
  103. package/dist/assets/runtimeEndpointReset-Cx2tsgTo.js +0 -54
  104. package/dist/assets/useFilesViewSearch-Du0DnmKs.js +0 -7
  105. package/dist/assets/usePushVisibilityBeacon-BnHxIv4r.js +0 -10
  106. package/dist/assets/useSwitcherItems-C91mwPJD.js +0 -1
  107. package/dist/assets/vendor-beautiful-mermaid-DneUawHp.js +0 -119
@@ -1,8 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiffView-CBOrV4hS.js","assets/vendor-react-B5Z1Mdn3.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-KIdiBFJs.js","assets/vendor-zustand-GVb4H8HE.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-DNoEeZ2U.css","assets/useAppFontEffects-C4JL1x7k.js","assets/vendor-base-ui-vkqQ2P9o.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-react-dom-BZOGXAGe.js","assets/vendor-floating-ui-dom-WyXykhNi.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-use-sync-external-store-D0AXkdQC.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-sonner-BDtm25td.js","assets/vendor-codemirror-view-Ct4T37Ue.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/runtimeSurface-CySRuLbN.js","assets/vendor-dnd-kit-core-C9qcAm_1.js","assets/vendor-dnd-kit-utilities-DTY1C6ST.js","assets/vendor-dnd-kit-accessibility-DZKKhs9S.js","assets/vendor-dnd-kit-sortable-D8ozj8M-.js","assets/vendor-cmdk-zXx6sGnS.js","assets/vendor-radix-ui-react-dialog-D2yhEu2p.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-8xy6TJML.js","assets/vendor-radix-ui-react-context-CFsX-AUC.js","assets/vendor-radix-ui-react-id-D2kS9K1j.js","assets/vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js","assets/vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js","assets/vendor-radix-ui-react-dismissable-layer-DrorBNg9.js","assets/vendor-radix-ui-react-primitive-DkH8dMOR.js","assets/vendor-radix-ui-react-slot-BIDFZX0-.js","assets/vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js","assets/vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js","assets/vendor-radix-ui-react-focus-scope-D2BkImwt.js","assets/vendor-radix-ui-react-portal-YgCRIyi7.js","assets/vendor-radix-ui-react-presence-D432pCMB.js","assets/vendor-radix-ui-react-focus-guards-BfdFmL7c.js","assets/vendor-react-remove-scroll-vR1dy1aP.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-CSAHp1YF.js","assets/vendor-react-style-singleton-Ctw6HnYx.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-Vv4V8Nd1.js","assets/vendor-use-callback-ref-CVVuCyLj.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BByA_dGF.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-DuOEwJ3f.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-wd6iRebq.js","assets/vendor-codemirror-lang-json-CZ07HmNC.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-djiuoTi8.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CKHqhW5R.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-DtcZDGqe.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-C493X_9w.js","assets/vendor-codemirror-lang-python-DzzokVau.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-DYppkHEk.js","assets/vendor-tanstack-react-virtual-2skouoFw.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-CfplGuM0.js","assets/vendor-motion-dom-DhJ-sYS5.js","assets/vendor-motion-utils-CKEGc_YG.js","assets/gitStatusPredicates-OljV4Bb2.js","assets/web-components-B2Rw__yK.js","assets/computeVirtualFileMetrics-DG_E6iaN.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-yJ9XpNMI.js","assets/vendor-pierre-theming-Dgp7B_O4.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/VirtualizedFileDiff-DfaXovGB.js","assets/isDiffPlainText-aikgiqLb.js","assets/vendor-diff-C3JhlQdm.js","assets/runtimeEndpointReset-Cx2tsgTo.js","assets/SessionUnreadDot-Bv-5KguB.js","assets/vendor-xterm-xterm-CrXqRur4.js","assets/vendor-xterm-xterm-DDGTF8rc.css","assets/permissionStore-iKN1K2_x.js","assets/runtimeEndpointReset-BV3KOtdA.css","assets/appThemeRegistry-gegrE2dq.js","assets/registerCustomTheme-DmolaWWZ.js","assets/contextFileOpenGuard-DPBE3ELv.js"])))=>i.map(i=>d[i]);
2
- import{_ as Ds}from"./vendor-vite-runtime-DD1OZmLC.js";import{R as a,j as e,r as He,b as Zn}from"./vendor-react-B5Z1Mdn3.js";import{D as We,S as ke,U as Re,a as Ke,a4 as _,I as w,V as Ee,b as qe,c8 as Ht,c9 as Ut,ca as Vt,cb as Wt,cc as Ge,cd as Me,cf as Ot,bo as pe,bp as Qn,j as ft,k as _t,bU as gs,aU as we,aV as Ne,bk as Ce,bl as Se,bm as Le,t as R,aT as Ls,b_ as Xn,as as ea,cg as ta,ch as sa,ci as na,cj as aa,ck as ra,cl as ia,bn as Ve,bi as xs,cm as oa,b8 as la,A as ca,b5 as da,bj as Ps,cn as ua,b$ as As,p as ha,aF as ma,b9 as fa,ba as pa,co as ga,cp as xa,cq as ba,bb as ya,cr as ja,a0 as va,Z as wa,bd as Na}from"./useAppFontEffects-C4JL1x7k.js";import{I as Ca,J as Sa,K as ka}from"./runtimeEndpointReset-Cx2tsgTo.js";import{u as bs}from"./vendor-zustand-GVb4H8HE.js";import{c as te,u as pt,ac as Ra,n as ct}from"./index-KIdiBFJs.js";import{C as Ea,P as Ts,d as Fa,i as ys,a as za}from"./gitStatusPredicates-OljV4Bb2.js";import{C as Ia,a as $a,b as Ma}from"./collapsible-szfZ0Syc.js";import{u as Da}from"./vendor-tanstack-react-virtual-2skouoFw.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-base-ui-vkqQ2P9o.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-BZOGXAGe.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-D0AXkdQC.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-sonner-BDtm25td.js";import"./vendor-codemirror-view-Ct4T37Ue.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./runtimeSurface-CySRuLbN.js";import"./vendor-dnd-kit-core-C9qcAm_1.js";import"./vendor-dnd-kit-utilities-DTY1C6ST.js";import"./vendor-dnd-kit-accessibility-DZKKhs9S.js";import"./vendor-dnd-kit-sortable-D8ozj8M-.js";import"./vendor-cmdk-zXx6sGnS.js";import"./vendor-radix-ui-react-dialog-D2yhEu2p.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-8xy6TJML.js";import"./vendor-radix-ui-react-context-CFsX-AUC.js";import"./vendor-radix-ui-react-id-D2kS9K1j.js";import"./vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js";import"./vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js";import"./vendor-radix-ui-react-dismissable-layer-DrorBNg9.js";import"./vendor-radix-ui-react-primitive-DkH8dMOR.js";import"./vendor-radix-ui-react-slot-BIDFZX0-.js";import"./vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js";import"./vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js";import"./vendor-radix-ui-react-focus-scope-D2BkImwt.js";import"./vendor-radix-ui-react-portal-YgCRIyi7.js";import"./vendor-radix-ui-react-presence-D432pCMB.js";import"./vendor-radix-ui-react-focus-guards-BfdFmL7c.js";import"./vendor-react-remove-scroll-vR1dy1aP.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-CSAHp1YF.js";import"./vendor-react-style-singleton-Ctw6HnYx.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-Vv4V8Nd1.js";import"./vendor-use-callback-ref-CVVuCyLj.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BByA_dGF.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-DuOEwJ3f.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-wd6iRebq.js";import"./vendor-codemirror-lang-json-CZ07HmNC.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-djiuoTi8.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CKHqhW5R.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-DtcZDGqe.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-C493X_9w.js";import"./vendor-codemirror-lang-python-DzzokVau.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-DYppkHEk.js";import"./vendor-framer-motion-CfplGuM0.js";import"./vendor-motion-dom-DhJ-sYS5.js";import"./vendor-motion-utils-CKEGc_YG.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./SessionUnreadDot-Bv-5KguB.js";import"./vendor-xterm-xterm-CrXqRur4.js";import"./permissionStore-iKN1K2_x.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./web-components-B2Rw__yK.js";import"./computeVirtualFileMetrics-DG_E6iaN.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-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.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"./VirtualizedFileDiff-DfaXovGB.js";import"./isDiffPlainText-aikgiqLb.js";import"./vendor-diff-C3JhlQdm.js";import"./appThemeRegistry-gegrE2dq.js";import"./registerCustomTheme-DmolaWWZ.js";const Bs="gitmojiCache",La=1e3*60*60*24*7,Gs="1",Pa="https://raw.githubusercontent.com/carloscuesta/gitmoji/master/packages/gitmojis/src/gitmojis.json",Os=s=>{if(!s||typeof s!="object")return!1;const r=s;return typeof r.emoji=="string"&&typeof r.code=="string"&&typeof r.description=="string"},Pt=()=>{if(typeof window>"u")return null;try{const s=window.localStorage.getItem(Bs);if(!s)return null;const r=JSON.parse(s);return!r||r.version!==Gs||typeof r.fetchedAt!="number"||!Array.isArray(r.gitmojis)?null:{gitmojis:r.gitmojis.filter(Os),fetchedAt:r.fetchedAt,version:r.version}}catch{return null}},Aa=s=>{if(!(typeof window>"u"))try{const r={gitmojis:s,fetchedAt:Date.now(),version:Gs};window.localStorage.setItem(Bs,JSON.stringify(r))}catch{return}},js=s=>Date.now()-s.fetchedAt<La;let dt=null;const Ue=new Set,vs=async()=>{if(dt)return dt;const s=(async()=>{try{const r=await fetch(Pa);if(!r.ok)throw new Error(`Failed to load gitmojis: ${r.statusText}`);const o=await r.json(),h=Array.isArray(o.gitmojis)?o.gitmojis.filter(Os):[];return Aa(h),Ue.forEach(m=>m(h)),h}catch(r){console.warn("Failed to load gitmoji list:",r);const o=[];return Ue.forEach(h=>h(o)),o}finally{dt=null}})();return dt=s,s},Ta=s=>{const[r,o]=a.useState(()=>s?Pt()?.gitmojis??[]:[]),[h,m]=a.useState(!1),n=a.useRef(s);n.current=s,a.useEffect(()=>{if(!s){Ue.delete(o),o([]),m(!1);return}const x=Pt();if(x&&(o(x.gitmojis),js(x)))return;Ue.add(o),m(!0);let d=!1;return vs().finally(()=>{!d&&n.current&&m(!1)}),()=>{d=!0,Ue.delete(o)}},[s]);const t=a.useCallback(async()=>{if(!n.current)return[];if(r.length>0)return r;const x=Pt();return x&&js(x)?x.gitmojis:vs()},[r]);return{gitmojis:r,isLoading:h,ensureLoaded:t}},Ba=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),Ga=({currentBranch:s,localBranches:r,remoteBranches:o,branchInfo:h,onCheckout:m,onCreate:n,remotes:t=[],disabled:x=!1})=>{const[d,y]=a.useState(!1),[N,S]=a.useState(""),[v,p]=a.useState(!1),[c,u]=a.useState(!1),[E,k]=a.useState(""),[$,B]=a.useState(!1),H=a.useRef(null),A=a.useCallback(I=>{I.stopPropagation()},[]),P=t.length>1,M=a.useMemo(()=>Ba(E),[E]),z=a.useMemo(()=>{const I=N.toLowerCase();return I?r.filter(X=>X.toLowerCase().includes(I)):r},[N,r]),G=a.useMemo(()=>{const I=N.toLowerCase();return I?o.filter(X=>X.toLowerCase().includes(I)):o},[N,o]),b=I=>{if(I===s){y(!1);return}m(I),y(!1),S("")},T=()=>{p(!0),setTimeout(()=>H.current?.focus(),50)},q=async()=>{if(!(!M||$)){if(P){u(!0);return}B(!0);try{await n(M,t[0]),k(""),p(!1),y(!1)}finally{B(!1)}}},Q=async I=>{if(!(!M||$)){B(!0);try{await n(M,I),k(""),p(!1),u(!1),y(!1)}finally{B(!1)}}},U=()=>{u(!1)},W=()=>{k(""),p(!1),u(!1)};return a.useEffect(()=>{d||(S(""),p(!1),u(!1),k(""))},[d]),e.jsxs(We,{open:d,onOpenChange:y,children:[e.jsxs(ke,{children:[e.jsx(Re,{asChild:!0,children:e.jsx(Ke,{asChild:!0,children:e.jsxs(_,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-full justify-start gap-1.5 px-2 py-1",disabled:x,children:[e.jsx(w,{name:"git-branch",className:"size-4 text-primary"}),e.jsx("span",{className:"min-w-0 truncate font-medium text-left",children:s||"Detached HEAD"}),e.jsx(w,{name:"arrow-down-s",className:"size-4 opacity-60"})]})})}),e.jsx(Ee,{sideOffset:8,children:"Current branch"})]}),e.jsx(qe,{align:"start",className:"w-72 p-0 max-h-[60vh] flex flex-col",children:e.jsxs(Ht,{className:"h-full min-h-0",children:[e.jsx(Ut,{placeholder:"Search branches...",value:N,onValueChange:S,onKeyDown:A}),e.jsxs(Vt,{scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[e.jsx(Wt,{children:"No branches found."}),e.jsx(Ge,{children:c?e.jsxs("div",{className:"px-2 py-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("button",{type:"button",onClick:U,disabled:$,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:e.jsx(w,{name:"arrow-left",className:"size-4"})}),e.jsxs("span",{className:"typography-meta text-muted-foreground",children:["Push To Prefix"," ",e.jsx("span",{className:"text-foreground font-medium",children:M})," ","Push To Suffix"]})]}),e.jsx("div",{className:"flex flex-col gap-1",children:t.map(I=>e.jsxs("button",{type:"button",onClick:()=>Q(I),disabled:$,className:"flex flex-col items-start gap-0.5 px-2 py-1.5 rounded-md text-left hover:bg-accent disabled:opacity-50",children:[e.jsxs("span",{className:"typography-ui-label text-foreground",children:[$?e.jsx(w,{name:"loader-4",className:"inline size-3 mr-1.5 animate-spin"}):null,I.name]}),e.jsx("span",{className:"typography-micro text-muted-foreground truncate max-w-full",children:I.pushUrl})]},I.name))})]}):v?e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg",children:[e.jsx("input",{ref:H,placeholder:"New branch name",value:E,onChange:I=>k(I.target.value),onClick:I=>I.stopPropagation(),onKeyDown:I=>{A(I),I.key==="Enter"?(I.preventDefault(),q()):I.key==="Escape"&&(I.preventDefault(),W())},className:"flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground"}),e.jsx("button",{type:"button",onClick:q,disabled:!M||$,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:$?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(w,{name:"add",className:"size-4"})}),e.jsx("button",{type:"button",onClick:W,disabled:$,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:e.jsx(w,{name:"close",className:"size-4"})})]}):e.jsxs(Me,{onSelect:T,children:[e.jsx(w,{name:"add",className:"size-4"}),e.jsx("span",{children:"Create new branch..."})]})}),e.jsx(Ot,{}),e.jsxs(Ge,{heading:"Local branches",children:[z.map(I=>e.jsxs(Me,{onSelect:()=>b(I),children:[e.jsxs("span",{className:"flex flex-1 flex-col",children:[e.jsx("span",{className:"typography-ui-label text-foreground",children:I}),(h?.[I]?.ahead||h?.[I]?.behind)&&e.jsxs("span",{className:"typography-micro text-muted-foreground",children:[h[I].ahead||0," ahead ·"," ",h[I].behind||0," behind"]})]}),s===I&&e.jsx("span",{className:"typography-micro text-primary",children:"Current"})]},`local-${I}`)),z.length===0&&e.jsx(Me,{disabled:!0,className:"justify-center",children:e.jsx("span",{className:"typography-meta text-muted-foreground",children:"No local branches"})})]}),e.jsx(Ot,{}),e.jsxs(Ge,{heading:"Remote branches",children:[G.map(I=>e.jsx(Me,{onSelect:()=>b(I),children:e.jsx("span",{className:"typography-ui-label text-foreground",children:I})},`remote-${I}`)),G.length===0&&e.jsx(Me,{disabled:!0,className:"justify-center",children:e.jsx("span",{className:"typography-meta text-muted-foreground",children:"No remote branches"})})]})]})]})})]})},Oa=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),_a=({currentBranch:s,onRename:r,showEditButton:o=!0})=>{const[h,m]=a.useState(!1),[n,t]=a.useState(s||""),[x,d]=a.useState(!1),y=a.useRef(null),N=()=>{!s||!r||(t(s),m(!0),setTimeout(()=>y.current?.focus(),0))},S=async()=>{if(!s||!r||!n.trim())return;const c=Oa(n);if(c===s){m(!1);return}d(!0);try{await r(s,c),m(!1),t("")}finally{d(!1)}},v=()=>{m(!1),t("")},p=c=>{c.key==="Enter"?(c.preventDefault(),S()):c.key==="Escape"&&(c.preventDefault(),v())};return h?e.jsx("div",{className:"flex items-center gap-2 rounded-md bg-primary/12 px-2 py-1 h-8",children:e.jsxs("form",{className:"flex w-full items-center gap-2",onSubmit:c=>{c.preventDefault(),S()},children:[e.jsx(w,{name:"git-branch",className:"size-4 text-primary"}),e.jsx("input",{ref:y,value:n,onChange:c=>t(c.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",placeholder:"Branch name",onKeyDown:p,autoFocus:!0}),e.jsx("button",{type:"submit",disabled:x,"aria-label":x?"Saving branch name":"Save branch name",title:x?"Saving branch name":"Save branch name",className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:x?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(w,{name:"check",className:"size-4"})}),e.jsx("button",{type:"button",onClick:v,disabled:x,"aria-label":"Cancel branch rename",title:"Cancel branch rename",className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:e.jsx(w,{name:"close",className:"size-4"})})]})}):e.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1.5 px-2 py-1 h-8",children:[e.jsx(w,{name:"git-branch",className:"size-4 text-primary shrink-0"}),e.jsxs("div",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[e.jsx("span",{className:"truncate typography-ui-label font-normal text-foreground",children:s||"Detached HEAD"}),o&&r&&s&&e.jsx(_,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:N,title:"Rename branch",children:e.jsx(w,{name:"edit",className:"size-4"})})]})]})},_s=({syncAction:s,remotes:r=[],onFetch:o,onSync:h,onRemoveRemote:m,disabled:n,removingRemoteName:t=null,aheadCount:x=0,behindCount:d=0,trackingRemoteName:y,hasUncommittedChanges:N=!1,iconOnly:S=!1,upstreamTarget:v=null})=>{const p=a.useRef(!1),c=!!t,u=r.find(M=>M.name===y)??r[0],E=d>0&&N,k=n||s!==null||c||!u||E,$=n||s!==null||c||r.length===0,B=x>0||d>0,H=["sync",d>0?`↓${d}`:null,x>0?`↑${x}`:null].filter(Boolean).join(" "),A=E?"Commit or stash your changes before syncing":u?[B?`Sync Changes (${d} down, ${x} up)`:"Sync Changes",v?`Compared with ${v}`:null].filter(Boolean).join(". "):"No remotes configured",P=()=>{u&&h(u)};return e.jsxs("div",{className:"inline-flex items-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] border border-border/60 bg-[var(--surface-elevated)] overflow-hidden",children:[e.jsxs(ke,{children:[e.jsx(Re,{asChild:!0,children:e.jsx("span",{className:"inline-flex",tabIndex:E?0:void 0,children:e.jsxs("button",{type:"button",onClick:P,disabled:k,className:te("inline-flex h-7 items-center gap-1.5 px-2 typography-ui-label font-medium text-foreground","transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"),"aria-label":"Sync Changes",children:[s==="sync"?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(w,{name:"refresh",className:"size-4"}),S?B?e.jsx("span",{className:"whitespace-nowrap tabular-nums",children:[d>0?`↓${d}`:null,x>0?`↑${x}`:null].filter(Boolean).join(" ")}):null:e.jsx("span",{className:"whitespace-nowrap tabular-nums",children:H})]})})}),e.jsx(Ee,{sideOffset:8,children:A})]}),e.jsxs(We,{children:[e.jsx(Ke,{asChild:!0,children:e.jsx("button",{type:"button",className:te("inline-flex h-7 w-6 items-center justify-center border-l border-[var(--interactive-border)] text-muted-foreground","transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"),disabled:$,"aria-label":"More sync actions",children:e.jsx(w,{name:"arrow-down-s",className:"size-4"})})}),e.jsx(qe,{align:"start",alignOffset:-40,className:"w-[min(360px,calc(100vw-2rem))] max-h-[320px] overflow-y-auto",children:r.map(M=>e.jsx(pe,{onSelect:z=>{if(p.current){z.preventDefault(),p.current=!1;return}o(M)},children:e.jsxs("div",{className:"flex w-full items-center gap-2",children:[e.jsx(w,{name:"refresh",className:"size-4 text-muted-foreground"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"typography-ui-label text-foreground",children:`Fetch from ${M.name}`}),e.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:M.fetchUrl})]})}),m&&M.name!==y?e.jsx(_,{type:"button",variant:"destructive",size:"xs",className:"h-6 w-6 px-0",disabled:s!==null||c,onPointerDown:z=>{p.current=!0,z.preventDefault(),z.stopPropagation()},onClick:z=>{p.current=!0,z.preventDefault(),z.stopPropagation(),m(M)},"aria-label":`Remove remote ${M.name}`,title:`Remove remote ${M.name}`,children:t===M.name?e.jsx(w,{name:"loader-4",className:"size-3.5 animate-spin"}):e.jsx(w,{name:"close",className:"size-3.5"})}):null]})},M.name))})]})]})},Ha=({status:s,localBranches:r,remoteBranches:o,branchInfo:h,syncAction:m,remotes:n,onFetch:t,onSync:x,onRemoveRemote:d,removingRemoteName:y,onCheckoutBranch:N,onCreateBranch:S,onRenameBranch:v,activeIdentityProfile:p,availableIdentities:c,onSelectIdentity:u,isApplyingIdentity:E,isWorktreeMode:k,upstreamTarget:$,onOpenHistory:B,onOpenGraph:H,onOpenStashes:A,onOpenUpdateBranch:P,onOpenReintegrateCommits:M,diffScope:z,onDiffScopeChange:G,allCount:b,workingCount:T,stagedCount:q,branchAvailable:Q,diffHeaderState:U})=>{const W=B||H||A||P||M,I=(U?.totalCount??0)>0,X=z!=="turn"&&z!=="branch",re=W||U!==null;return e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:[e.jsx("div",{className:"min-w-0 flex-shrink",children:k?e.jsx(_a,{currentBranch:s.current,onRename:v}):e.jsx(Ga,{currentBranch:s.current,localBranches:r,remoteBranches:o,branchInfo:h,onCheckout:N,onCreate:S,remotes:n})}),e.jsx("div",{className:"shrink-0",children:e.jsx(Ca,{activeProfile:p,identities:c,onSelect:u,isApplying:E,iconOnly:!0})}),e.jsx("div",{className:"min-w-0 shrink-0",children:e.jsx(Ea,{scope:z,isGitRepo:!0,branchAvailable:Q,allCount:b,workingCount:T,stagedCount:q,turnCount:U?.turnCount??0,branchCount:U?.branchCount??0,onScopeChange:G})}),e.jsx("div",{className:"min-w-0 flex-1"}),e.jsx("div",{className:"shrink-0",children:e.jsx(_s,{syncAction:m,remotes:n,onFetch:t,onSync:x,onRemoveRemote:d,removingRemoteName:y,disabled:!s,iconOnly:!0,aheadCount:s.ahead,behindCount:s.behind,trackingRemoteName:s.tracking?.split("/")[0],hasUncommittedChanges:(s.files?.length??0)>0,upstreamTarget:$})}),re?e.jsx("div",{className:"shrink-0",children:e.jsxs(We,{children:[e.jsxs(ke,{children:[e.jsx(Re,{asChild:!0,children:e.jsx(Ke,{asChild:!0,children:e.jsx(_,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0","aria-label":"Repository views",children:e.jsx(w,{name:"more-fill",className:"size-4"})})})}),e.jsx(Ee,{sideOffset:8,children:"Repository views"})]}),e.jsxs(qe,{align:"end",children:[B?e.jsxs(pe,{onSelect:B,children:[e.jsx(w,{name:"history",className:"size-4"}),"History"]}):null,H?e.jsxs(pe,{onSelect:H,children:[e.jsx(w,{name:"git-branch",className:"size-4"}),"Graph"]}):null,A?e.jsxs(pe,{onSelect:A,children:[e.jsx(w,{name:"archive-stack",className:"size-4"}),"Stashes"]}):null,P?e.jsxs(pe,{onSelect:P,children:[e.jsx(w,{name:"git-merge",className:"size-4"}),"Update branch"]}):null,M?e.jsxs(pe,{onSelect:M,children:[e.jsx(w,{name:"split-cells-horizontal",className:"size-4"}),"Re-integrate commits"]}):null,W&&U!==null?e.jsx(Qn,{}):null,U!==null?e.jsxs(pe,{disabled:!I,onSelect:U.onExpandOrCollapseAll,children:[e.jsx(w,{name:"expand-up-down",className:"size-4"}),U.expandedCount>0?"Collapse all":"Expand all"]}):null,U!==null?e.jsxs(pe,{disabled:!I||!X,onSelect:U.onToggleLoadFullFiles,children:[e.jsx(w,{name:"file-download",className:"size-4"}),e.jsx("span",{className:"flex-1",children:"Load full files"}),U.loadFullFiles?e.jsx(w,{name:"check",className:"size-4"}):null]}):null,U!==null?e.jsxs(pe,{disabled:!I,onSelect:U.onToggleWrapLines,children:[e.jsx(w,{name:"text-wrap",className:"size-4"}),e.jsx("span",{className:"flex-1",children:"Wrap lines"}),U.wrapLines?e.jsx(w,{name:"check",className:"size-4"}):null]}):null,U!==null?e.jsxs(pe,{disabled:U.layoutMode===null,onSelect:U.onToggleLayout,children:[e.jsx(w,{name:U.layoutMode==="side-by-side"?"layout-column":"align-justify",className:"size-4"}),U.layoutMode==="side-by-side"?"Switch to unified view":"Switch to side-by-side view"]}):null]})]})}):null]})},Ua=({open:s,onOpenChange:r,conflictFiles:o=[],directory:h,operation:m,onAbort:n,onClearState:t})=>{const{git:x}=ft(),d=_t(b=>b.openNewSessionDraft),y=_t(b=>b.currentSessionId),N=gs(b=>b.setPendingInputText),S=gs(b=>b.setPendingSyntheticParts),v=pt(b=>b.setActiveMainTab),[p,c]=a.useState(!1),[u,E]=a.useState(null),[k,$]=a.useState(null);a.useEffect(()=>{!s||!h||(c(!0),$(null),E(null),x.getConflictDetails(h).then(b=>{E(b)}).catch(b=>{const T=b instanceof Error?b.message:"Failed to load conflict details";$(T)}).finally(()=>{c(!1)}))},[h,x,s]);const B=a.useCallback(async()=>{if(!u)return null;const b=m==="merge"?"merge":"rebase",T=u.headInfo||(m==="merge"?"MERGE_HEAD":"REBASE_HEAD"),q=m==="merge"?"git commit --no-edit":"git rebase --continue",Q=`Investigate the ${b} conflicts and concisely report the intended resolution strategy without making modifications. Wait for confirmation before resolving, staging, or continuing the ${b}. Preserve the intent of changes from ${T}.`,U=`Git ${b} operation is in progress with conflicts.
3
- - Directory: ${h}
4
- - Operation: ${m}
5
- - Head Info: ${u.headInfo||"N/A"}
6
-
7
- Inspect each conflicted file and both sides of every conflict. Report a concise per-file resolution strategy and any assumptions or tradeoffs. Wait for explicit user confirmation before editing, staging, or running ${q}. After confirmation, remove all conflict markers, preserve intent from both sides, verify syntax, and complete the ${b}.`,W=`${b} conflict context (JSON)
8
- ${JSON.stringify({directory:h,operation:u.operation,headInfo:u.headInfo,statusPorcelain:u.statusPorcelain,unmergedFiles:u.unmergedFiles,diff:u.diff},null,2)}`;return{visibleText:Q,instructionsText:U,payloadText:W}},[u,h,m]),H=()=>{n(),r(!1)},A=()=>{t?.(),r(!1)},P=async()=>{const b=await B();if(!b){R.error("No conflict details available");return}if(!y){R.error("No active session",{description:"Open or create a session to resolve conflicts."});return}N(b.visibleText,"replace"),S([{text:b.instructionsText,synthetic:!0},{text:b.payloadText,synthetic:!0}]),v("chat"),t?.(),r(!1)},M=async()=>{const b=await B();if(!b){R.error("No conflict details available");return}d({directoryOverride:h,initialPrompt:b.visibleText,syntheticParts:[{text:b.instructionsText,synthetic:!0},{text:b.payloadText,synthetic:!0}]}),v("chat"),t?.(),r(!1)},z=m==="merge"?"Merge":"Rebase",G=u?.unmergedFiles||o;return e.jsx(we,{open:s,onOpenChange:r,children:e.jsx(Ne,{className:"max-w-md w-[calc(100vw-2rem)]",children:e.jsxs("div",{className:"flex flex-col gap-4 overflow-hidden",children:[e.jsxs(Ce,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),e.jsx(Se,{children:`${z} conflicts detected`})]}),e.jsx(Le,{children:`Resolve the ${m} conflicts to continue.`})]}),p&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-muted-foreground",children:[e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"typography-meta",children:"Loading conflict details..."})]}),k&&e.jsx("div",{className:"rounded-lg bg-[var(--status-error-bg)] p-3 text-[var(--status-error)] typography-meta break-words",children:`Failed to load conflict details: ${k}`}),G.length>0&&e.jsxs("div",{className:"space-y-2 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"typography-meta text-muted-foreground",children:"Conflicted files:"}),e.jsx("span",{className:"typography-micro px-1.5 py-0.5 rounded bg-[var(--surface-elevated)] text-muted-foreground",children:G.length})]}),e.jsx("div",{className:"bg-[var(--surface-elevated)] rounded-lg p-3 max-h-40 overflow-y-auto overflow-x-hidden",children:e.jsx("ul",{className:"space-y-1",children:G.map(b=>e.jsx("li",{className:"typography-micro text-foreground font-mono truncate block",title:b,children:b},b))})})]}),u?.headInfo&&e.jsxs("div",{className:"space-y-1 overflow-hidden",children:[e.jsx("p",{className:"typography-meta text-muted-foreground",children:"HEAD information:"}),e.jsx("div",{className:"typography-micro text-foreground font-mono bg-[var(--surface-elevated)] rounded-lg p-3 max-h-24 overflow-y-auto break-words whitespace-pre-wrap",children:u.headInfo})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-2",children:[e.jsxs(_,{variant:"default",onClick:()=>{M()},disabled:p||!u,className:"w-full gap-2",children:[p?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(w,{name:"add",className:"size-4"}),"Resolve in new session"]}),e.jsxs(_,{variant:"outline",onClick:()=>{P()},disabled:p||!u||!y,className:"w-full gap-2",children:[p?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(w,{name:"chat-1",className:"size-4"}),"Resolve in current session"]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(_,{variant:"ghost",size:"sm",onClick:A,className:"flex-1",children:"Continue later"}),e.jsx(_,{variant:"destructive",size:"sm",onClick:H,className:"flex-1",children:`Abort ${z}`})]})]})]})})})},$e=8,Va=({laned:s,totalLanes:r,isExpanded:o})=>{const{lane:h,color:m,connectors:n}=s,x=Math.max(r,h+1)*$e+$e/2,d=a.useRef(null),y=a.useRef(null);return a.useLayoutEffect(()=>{const N=d.current,S=y.current;if(!N||!S)return;const v=N.offsetHeight;if(v===0)return;const p=window.devicePixelRatio||1;S.width=x*p,S.height=v*p;const c=S.getContext("2d");if(!c)return;c.scale(p,p),c.clearRect(0,0,x,v);const u=v/2,E=h*$e+$e/2,k=getComputedStyle(S),$=k.getPropertyValue("--surface-muted-foreground").trim()||k.color,B=P=>{if(!P.startsWith("var("))return P;const M=P.slice(4,-1).trim();return k.getPropertyValue(M).trim()||$},H=[...n].sort((P,M)=>{const z=G=>G==="branch-out"||G==="merge-in";return(z(P.type)?1:0)-(z(M.type)?1:0)});for(const P of H){const M=P.fromLane*$e+$e/2,z=P.toLane*$e+$e/2,G=P.type==="passing"?.72:P.type==="branch-out"||P.type==="merge-in"?.95:1;switch(c.beginPath(),c.strokeStyle=B(P.color),c.globalAlpha=G,c.lineWidth=1.25,c.lineCap="round",P.type){case"passing":case"commit-lane":c.moveTo(M,0),c.lineTo(M,v);break;case"top-stub":c.moveTo(M,0),c.lineTo(M,u);break;case"bottom-stub":c.moveTo(M,u),c.lineTo(M,v);break;case"branch-out":{const b=(u+v)/2;c.moveTo(E,u),c.bezierCurveTo(E,b,z,b,z,v);break}case"merge-in":{const b=u/2;c.moveTo(M,0),c.bezierCurveTo(M,b,E,b,E,u);break}default:continue}c.stroke(),c.globalAlpha=1}const A=k.getPropertyValue("--background").trim()||k.getPropertyValue("--surface-background").trim();c.beginPath(),c.arc(E,u,4,0,Math.PI*2),c.fillStyle=B(m),c.fill(),c.beginPath(),c.arc(E,u,5,0,Math.PI*2),c.strokeStyle=A||$,c.lineWidth=2,c.stroke()},[s,h,m,n,r,o,x]),e.jsx("div",{ref:d,style:{width:x,height:"100%",position:"relative",flexShrink:0,overflow:"hidden"},children:e.jsx("canvas",{ref:y,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block"}})})},ws=15e3,Ns=500,Cs=12,Ss=8*1024*1024,ks=s=>typeof s=="string"?0:(s.original?.length??0)+(s.modified?.length??0),Rs=s=>{if(s.size<=Cs){let m=0;for(const n of s.values())m+=ks(n);if(m<=Ss)return s}const r=Array.from(s.entries()).reverse(),o=new Map;let h=0;for(const[m,n]of r){if(o.size>=Cs)continue;const t=ks(n);h+t>Ss&&o.size>0||(o.set(m,n),h+=t)}return new Map(Array.from(o.entries()).reverse())};function Es(s,r){const o=new Date(s);return Number.isNaN(o.getTime())?s:Xn(o,r,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Wa(s){switch(s){case"A":return"text-[var(--status-success)]";case"D":return"text-[var(--status-error)]";case"M":return"text-[var(--status-warning)]";case"R":return"text-[var(--status-info)]";default:return"text-muted-foreground"}}function Ka(s){return s?s.split(",").map(r=>r.trim()).filter(Boolean).map(r=>{const o=r.startsWith("HEAD ->");return{label:o?r.replace("HEAD -> ",""):r.replace("tag: ",""),isHead:o,isTag:r.startsWith("tag: ")}}):[]}const qa=a.memo(({entry:s,mode:r="history",laned:o,totalLanes:h,isExpanded:m,onToggle:n,files:t,isLoadingFiles:x,onCopyHash:d,directory:y,onConflict:N,onActionSuccess:S})=>{const{git:v}=ft(),p=pt(l=>l.timeFormatPreference),c=r==="graph",u={checkout:"Check out this commit as detached HEAD?",cherryPick:"Cherry-pick this commit onto the current branch?",revert:"Stage a revert of this commit?",merge:"Merge this commit into the current branch?",rebase:"Rebase current branch onto this commit?",resetSoft:"Soft reset — HEAD moves, staged changes preserved.",resetMixed:"Mixed reset — HEAD moves, changes unstaged.",resetHard:"Hard reset — HEAD moves, all uncommitted changes permanently discarded."},E={soft:"Soft — keep staged",mixed:"Mixed — unstage changes",hard:"Hard — discard all changes"},[k,$]=a.useState(null),[B,H]=a.useState(!1),[A,P]=a.useState(""),[M,z]=a.useState(null),[G,b]=a.useState(new Set),[T,q]=a.useState(new Map),[Q,U]=a.useState(new Set),W=async()=>{if(y){$("checkout");try{await v.checkoutCommit(y,s.hash),R.success("Checked out (detached HEAD)"),S?.()}catch(l){R.error(String(l.message))}finally{$(null)}}},I=async()=>{if(!(!y||!A.trim())){$("createBranch");try{await v.createBranch(y,A.trim(),s.hash),H(!1),P(""),S?.()}catch(l){R.error(String(l.message))}finally{$(null)}}},X=async()=>{if(y){$("cherryPick");try{const l=await v.cherryPick(y,s.hash);l.conflict?N?.({conflict:!0,conflictFiles:l.conflictFiles,operation:"cherry-pick"}):S?.()}catch(l){R.error(String(l.message))}finally{$(null)}}},re=async()=>{if(y){$("revert");try{const l=await v.revertCommit(y,s.hash);l.conflict?N?.({conflict:!0,conflictFiles:l.conflictFiles,operation:"revert"}):S?.()}catch(l){R.error(String(l.message))}finally{$(null)}}},ae=async(l,D=!1)=>{if(!(!y||k!==null)){$("reset");try{await v.resetToCommit(y,s.hash,l,D),S?.()}catch(V){R.error(String(V.message))}finally{$(null)}}},Y=async()=>{if(!M)return;const l=M;switch(z(null),l){case"checkout":return W();case"cherryPick":return X();case"revert":return re();case"merge":return K();case"rebase":return O();case"resetSoft":return ae("soft");case"resetMixed":return ae("mixed");case"resetHard":return ae("hard",!0)}},K=async()=>{if(y){$("merge");try{const l=await v.merge(y,{branch:s.hash});l.conflict?N?.({conflict:!0,conflictFiles:l.conflictFiles,operation:"merge"}):S?.()}catch(l){R.error(String(l.message))}finally{$(null)}}},O=async()=>{if(y){$("rebase");try{const l=await v.rebase(y,{onto:s.hash});l.conflict?N?.({conflict:!0,conflictFiles:l.conflictFiles,operation:"rebase"}):S?.()}catch(l){R.error(String(l.message))}finally{$(null)}}},C=a.useCallback(async l=>{const D=l.path;if(!y){q(V=>new Map(V).set(D,"error"));return}q(V=>Rs(new Map(V).set(D,"loading")));try{const se=(v.getCommitFileDiff??Ra)(y,s.hash,l.path,!1),ue=new Promise((ne,Fe)=>{setTimeout(()=>Fe(new Error(`Timed out after ${ws}ms`)),ws)}),me=await Promise.race([se,ue]);q(ne=>Rs(new Map(ne).set(D,me)))}catch{q(V=>new Map(V).set(D,"error"))}},[y,s.hash,v.getCommitFileDiff]),F=a.useCallback(async l=>{const D=l.path;if(l.changeType==="R"||l.isBinary){b(me=>{const ne=new Set(me);return ne.has(D)?ne.delete(D):ne.add(D),ne});return}const V=T.get(D);if(G.has(D)&&V&&V!=="error"){b(me=>{const ne=new Set(me);return ne.delete(D),ne});return}b(me=>{const ne=new Set(me);return ne.add(D),ne}),!(V&&V!=="error"||l.insertions+l.deletions>Ns&&!Q.has(D))&&await C(l)},[T,Q,C,G]);return e.jsxs("li",{children:[e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":m,onClick:n,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),n())},className:te("w-full flex items-start gap-3 px-3 py-2 text-left transition-colors",c?"hover:bg-[var(--interactive-hover)]/40":m?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[c&&o&&h!==void 0?e.jsx("div",{className:"-my-2 shrink-0 self-stretch",children:e.jsx(Va,{laned:o,totalLanes:h,isExpanded:m})}):e.jsx("div",{className:"h-2 w-2 translate-y-2 rounded-full shrink-0",style:{backgroundColor:"var(--status-success)"},"aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 flex-1",children:[c?(()=>{const l=Ka(s.refs);return l.length>0?e.jsx("div",{className:"flex flex-wrap gap-1 mb-0.5",children:l.map(D=>e.jsx("span",{className:te("inline-flex items-center px-1.5 py-0 typography-micro rounded font-medium",D.isHead?"bg-[var(--chart-1)] text-[var(--primary-foreground)]":D.isTag?"bg-[var(--chart-5)] text-[var(--primary-foreground)]":"bg-[var(--interactive-hover)] text-[var(--foreground)]"),children:D.label},D.label))}):null})():null,e.jsx("p",{className:"typography-ui-label font-medium text-foreground line-clamp-1",children:s.message}),e.jsxs("div",{className:"flex items-center gap-1 typography-meta text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1 min-w-0 truncate",children:[e.jsx("span",{className:"truncate min-w-[3ch]",title:s.author_name,children:s.author_name}),e.jsx("span",{className:"shrink-0",children:"·"}),e.jsx("span",{className:"truncate min-w-0",title:Es(s.date,p),children:Es(s.date,p)})]}),e.jsx("span",{className:"shrink-0",children:"·"}),e.jsx("code",{className:"shrink-0 font-mono",children:s.hash.slice(0,8)}),e.jsxs(ke,{children:[e.jsx(Re,{asChild:!0,children:e.jsx(_,{variant:"ghost",size:"sm",className:"h-5 px-1 shrink-0",onClick:l=>{l.stopPropagation(),d(s.hash)},children:e.jsx(w,{name:"file-copy",className:"size-3"})})}),e.jsx(Ee,{sideOffset:8,children:"Copy SHA"})]})]})]})]}),m&&e.jsxs("div",{className:"px-3 pb-2 pl-8 border-t border-border/40",children:[c&&M?e.jsxs("div",{className:"flex items-center gap-2 py-2 border-b border-border/30 mb-2",children:[e.jsx("span",{className:"typography-micro text-muted-foreground flex-1 min-w-0",children:u[M]}),e.jsxs(_,{variant:"destructive",size:"xs",className:"h-6 shrink-0",disabled:k!==null,onClick:l=>{l.stopPropagation(),Y()},children:[k!==null?e.jsx(w,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,"Confirm"]}),e.jsx(_,{variant:"ghost",size:"xs",className:"h-6 shrink-0",disabled:k!==null,onClick:l=>{l.stopPropagation(),z(null)},children:"Cancel"})]}):c?e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 py-2 border-b border-border/30 mb-2",children:[e.jsx(_,{variant:"outline",size:"xs",className:"h-6",disabled:k!==null,onClick:l=>{l.stopPropagation(),z("checkout")},children:"Checkout"}),B?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{autoFocus:!0,value:A,onChange:l=>P(l.target.value),onKeyDown:l=>{l.key==="Enter"&&I(),l.key==="Escape"&&(H(!1),P(""))},placeholder:"Branch name",className:"h-6 text-xs px-2 rounded border border-border/60 bg-background min-w-0 w-32"}),e.jsxs(_,{variant:"outline",size:"xs",className:"h-6",disabled:!A.trim()||k!==null,onClick:l=>{l.stopPropagation(),I()},children:[k==="createBranch"?e.jsx(w,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,"Create"]})]}):e.jsx(_,{variant:"outline",size:"xs",className:"h-6",onClick:l=>{l.stopPropagation(),H(!0)},children:"Create branch here"}),e.jsx(_,{variant:"outline",size:"xs",className:"h-6",disabled:k!==null,onClick:l=>{l.stopPropagation(),z("cherryPick")},children:"Cherry-pick"}),e.jsx(_,{variant:"outline",size:"xs",className:"h-6",disabled:k!==null,onClick:l=>{l.stopPropagation(),z("revert")},children:"Revert"}),e.jsxs(We,{children:[e.jsx(Ke,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"xs",className:"h-6",disabled:k!==null,onClick:l=>l.stopPropagation(),children:[k==="reset"?e.jsx(w,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,"Reset..."]})}),e.jsx(qe,{align:"start",className:"min-w-max",children:["soft","mixed","hard"].map(l=>e.jsx(pe,{disabled:k!==null,onSelect:D=>{D.stopPropagation(),z(`reset${l.charAt(0).toUpperCase()+l.slice(1)}`)},children:E[l]},l))})]}),e.jsx(_,{variant:"outline",size:"xs",className:"h-6",disabled:k!==null,onClick:l=>{l.stopPropagation(),z("merge")},children:"Merge into current"}),e.jsx(_,{variant:"outline",size:"xs",className:"h-6",disabled:k!==null,onClick:l=>{l.stopPropagation(),z("rebase")},children:"Rebase onto this"})]}):null,x?e.jsxs("div",{className:"flex items-center gap-2 py-2",children:[e.jsx(w,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}),e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Loading files..."})]}):t.length===0?e.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:"No files"}):e.jsx("ul",{className:"space-y-0.5 py-2",children:t.map(l=>e.jsxs("li",{children:[e.jsxs("button",{type:"button",onClick:()=>F(l),className:te("w-full flex items-center gap-2 typography-micro text-left cursor-pointer transition-colors rounded px-1",G.has(l.path)?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[e.jsx("span",{className:te("font-semibold w-3 text-center shrink-0",Wa(l.changeType)),children:l.changeType}),e.jsx("span",{className:"truncate text-foreground min-w-0",title:l.path,children:l.path}),!l.isBinary&&e.jsxs("span",{className:"shrink-0",children:[e.jsxs("span",{style:{color:"var(--status-success)"},children:["+",l.insertions]}),e.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),e.jsxs("span",{style:{color:"var(--status-error)"},children:["-",l.deletions]})]}),l.isBinary&&e.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:"Binary"}),e.jsx(w,{name:G.has(l.path)?"arrow-down-s":"arrow-right-s",className:"size-3 shrink-0 text-muted-foreground"})]}),G.has(l.path)&&e.jsx("div",{className:"max-h-[400px] overflow-y-auto rounded border border-border/40 mx-2 mb-1","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:l.changeType==="R"?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Renamed file — diff not supported"}):l.isBinary?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Binary file — no diff available"}):(()=>{const D=l.insertions+l.deletions;if(!Q.has(l.path)&&D>Ns)return e.jsxs("div",{className:"flex flex-col items-start gap-1 px-3 py-2 text-sm text-muted-foreground",children:[e.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:`Large diff (${D} changed lines)`}),e.jsx("div",{className:"typography-meta text-muted-foreground",children:"Rendering may be slow. You can still view the diff by clicking below."}),e.jsx(_,{type:"button",variant:"ghost",size:"xs",className:"h-6 px-0 text-primary hover:bg-transparent hover:underline",onClick:()=>{U(se=>new Set(se).add(l.path)),C(l)},children:"Render anyway"})]});const V=T.get(l.path);return V==="loading"||V===void 0?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Loading diff..."}):V==="error"?e.jsx("button",{type:"button",onClick:()=>F(l),className:"w-full text-left px-3 py-2 text-sm text-muted-foreground hover:bg-[var(--interactive-hover)] transition-colors",children:"Failed to load diff. Click to retry."}):e.jsx(Ts,{original:V.original,modified:V.modified,language:Ls(l.path)||"",fileName:l.path,renderSideBySide:!1,layout:"inline"})})()})]},l.path))})]})]})}),Fs=["var(--chart-1)","var(--chart-2)","var(--chart-3)","var(--chart-4)","var(--chart-5)","var(--syntax-keyword)","var(--syntax-string)","var(--status-info)"];function ut(s){return Fs[s%Fs.length]}function Ya(s){if(s.length===0)return[];const r=[],o=[];for(let h=0;h<s.length;h++){const m=s[h],n=[];for(let p=0;p<r.length;p++)r[p]===m.hash&&n.push(p);let t=n.length>0?n[0]:-1;if(t===-1){const p=r.indexOf(null);p!==-1?t=p:(t=r.length,r.push(null))}const x=n.slice(1),d=ut(t),y=r[t]===m.hash,N=m.parents.length>0;N?r[t]=m.parents[0]:r[t]=null;const S=[];for(let p=1;p<m.parents.length;p++){const c=m.parents[p],u=r.indexOf(c);if(u!==-1)S.push(u);else{const E=r.indexOf(null),k=E!==-1?E:r.length;r[k]=c,k===r.length&&r.push(c),S.push(k)}}const v=[];y&&N?v.push({fromLane:t,toLane:t,color:d,type:"commit-lane"}):y&&!N?v.push({fromLane:t,toLane:t,color:d,type:"top-stub"}):!y&&N&&v.push({fromLane:t,toLane:t,color:d,type:"bottom-stub"});for(const p of x)v.push({fromLane:p,toLane:t,color:ut(p),type:"merge-in"}),r[p]=null;for(const p of S)v.push({fromLane:t,toLane:p,color:ut(p),type:"branch-out"});for(let p=0;p<r.length;p++)r[p]!==null&&p!==t&&(S.includes(p)||v.push({fromLane:p,toLane:p,color:ut(p),type:"passing"}));o.push({commit:m,lane:t,color:d,connectors:v})}return o}const Ja=[{label:"25 commits",value:25},{label:"50 commits",value:50},{label:"100 commits",value:100}],Za=({mode:s="history",log:r,isLogLoading:o,logMaxCount:h,onLogMaxCountChange:m,expandedCommitHashes:n,onToggleCommit:t,commitFilesMap:x,loadingCommitHashes:d,onCopyHash:y,directory:N,showHeader:S=!0,contentMaxHeightClassName:v="max-h-[50vh]",branchDivider:p=null,onConflict:c,onActionSuccess:u})=>{const[E,k]=a.useState(!0),$=s==="graph",B=a.useMemo(()=>$&&r?Ya(r.all):[],[$,r]),H=a.useMemo(()=>Math.max(1,...B.map(W=>W.lane+1)),[B]),A=a.useMemo(()=>new Map(B.map(W=>[W.commit.hash,W])),[B]);if(!r)return null;const P=p!==null&&p.insertBeforeIndex>0&&p.insertBeforeIndex<r.all.length,M=p!==null&&p.insertBeforeIndex===r.all.length,z=P||M,G=P?r.all.slice(0,p.insertBeforeIndex):M?r.all:[],b=P?r.all.slice(p.insertBeforeIndex):[],T=p?.direction==="down"?e.jsx(w,{name:"arrow-down-s",className:"size-3.5"}):e.jsx(w,{name:"arrow-up",className:"size-3.5"}),q=W=>e.jsx("ul",{className:"divide-y divide-border/60",children:W.map(I=>e.jsx(qa,{entry:I,mode:s,laned:$?A.get(I.hash):void 0,totalLanes:$?H:void 0,isExpanded:n.has(I.hash),onToggle:()=>t(I.hash),files:x.get(I.hash)??[],isLoadingFiles:d.has(I.hash),onCopyHash:y,directory:N,onConflict:c,onActionSuccess:u},I.hash))}),Q=r.all.length>=h?e.jsx("div",{className:"flex justify-center py-2 border-t border-border/40",children:e.jsx(_,{type:"button",variant:"ghost",size:"xs",onClick:()=>m(h+25),disabled:o,className:"px-3 text-muted-foreground hover:text-foreground",children:o?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(w,{name:"loader-4",className:"size-3 animate-spin"}),"Loading..."]}):"Load more"})}):null,U=e.jsx(ea,{outerClassName:`min-h-0 ${v}`,className:"h-full w-full",children:r.all.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-4",children:e.jsx("p",{className:"typography-ui-label text-muted-foreground",children:"No commits found"})}):z&&p?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-0",children:[G.length>0?e.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:q(G)}):null,e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5","aria-hidden":!0,children:[e.jsx("span",{className:"h-px flex-1 bg-border/60"}),e.jsxs("span",{className:"inline-flex max-w-[80%] items-center gap-1 typography-micro text-muted-foreground",children:[e.jsx("span",{className:"truncate",title:p.branchName,children:p.branchName}),T]}),e.jsx("span",{className:"h-px flex-1 bg-border/60"})]}),b.length>0?e.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:q(b)}):null]}),Q]}):e.jsxs(e.Fragment,{children:[q(r.all),Q]})});return S?e.jsxs(Ia,{open:E,onOpenChange:k,className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[e.jsxs($a,{className:"flex w-full items-center justify-between px-3 h-10 hover:bg-transparent",children:[e.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:"History"}),e.jsxs("div",{className:"flex items-center gap-2",children:[E&&e.jsx("div",{onClick:W=>W.stopPropagation(),onPointerDown:W=>W.stopPropagation(),children:e.jsxs(ta,{value:String(h),onValueChange:W=>m(Number(W)),disabled:o,children:[e.jsx(sa,{size:"sm",className:"w-auto",disabled:o,children:e.jsx(na,{placeholder:"Commits"})}),e.jsx(aa,{children:Ja.map(W=>e.jsx(ra,{value:String(W.value),children:W.label},W.value))})]})}),E?e.jsx(w,{name:"arrow-up-s",className:"size-4 text-muted-foreground"}):e.jsx(w,{name:"arrow-down-s",className:"size-4 text-muted-foreground"})]})]}),e.jsx(Ma,{children:U})]}):z?e.jsx("section",{className:"h-full min-h-0",children:U}):e.jsx("section",{className:"h-full min-h-0 rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:U})},Qa=a.memo(function({mode:r,onOpenChange:o,onRefresh:h,isRefreshing:m,log:n,maxCount:t,onMaxCountChange:x,expandedCommitHashes:d,onToggleCommit:y,commitFilesMap:N,loadingCommitHashes:S,onCopyHash:v,directory:p,branchDivider:c,onConflict:u,onActionSuccess:E}){return r?e.jsx(we,{open:r!==null,onOpenChange:o,children:e.jsxs(Ne,{className:"max-w-5xl h-[90vh] max-h-[90vh] flex flex-col overflow-hidden",children:[e.jsxs(Ce,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(Se,{children:r==="graph"?"Graph":"History"}),e.jsxs(_,{type:"button",variant:"ghost",size:"sm",className:"mr-6 h-7 shrink-0 gap-1.5 px-2",onClick:h,disabled:m,title:"Refresh","aria-label":"Refresh",children:[e.jsx(w,{name:"refresh",className:te("size-4",m&&"animate-spin")}),"Refresh"]})]}),e.jsx(Le,{children:"Browse recent commits and inspect changed files."})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Za,{mode:r==="graph"?"graph":"history",log:n,isLogLoading:m,logMaxCount:t,onLogMaxCountChange:x,expandedCommitHashes:d,onToggleCommit:y,commitFilesMap:N,loadingCommitHashes:S,onCopyHash:v,directory:p,showHeader:!1,contentMaxHeightClassName:"h-full max-h-none",branchDivider:r==="graph"?null:c,onConflict:r==="graph"?u:void 0,onActionSuccess:r==="graph"?E:void 0})})]})}):null}),Xa=a.memo(function({open:r,onOpenChange:o,gitmojis:h,onSelect:m}){const[n,t]=He.useState(""),x=a.useMemo(()=>{if(h.length===0)return[];const d=n.trim().toLowerCase();return d?h.filter(y=>y.emoji.includes(d)||y.code.toLowerCase().includes(d)||y.description.toLowerCase().includes(d)):h},[h,n]);return e.jsx(we,{open:r,onOpenChange:o,children:e.jsxs(Ne,{className:"max-w-md p-0 overflow-hidden",children:[e.jsx(Ce,{className:"px-4 pt-4",children:e.jsx(Se,{children:"Insert gitmoji"})}),e.jsxs(Ht,{className:"h-[420px]",children:[e.jsx(Ut,{placeholder:"Search gitmoji...",value:n,onValueChange:t}),e.jsxs(Vt,{children:[e.jsx(Wt,{children:"No gitmoji found"}),e.jsx(Ge,{children:x.map(d=>e.jsxs(Me,{onSelect:()=>m(d.emoji,d.code),children:[e.jsx("span",{className:"text-lg",children:d.emoji}),e.jsx("span",{className:"typography-ui-label text-foreground",children:d.code}),e.jsx("span",{className:"typography-meta text-muted-foreground",children:d.description})]},d.code))})]})]})]})})}),er=({open:s,onOpenChange:r,operation:o,targetBranch:h,onConfirm:m})=>{const[n,t]=a.useState(!0),[x,d]=a.useState(!1),y=o==="merge"?"Merge":"Rebase",N=async()=>{d(!0);try{await m(n),r(!1)}catch(v){const p=v instanceof Error?v.message:`Failed to ${o}`;R.error(p)}finally{d(!1)}},S=()=>{x||r(!1)};return e.jsx(we,{open:s,onOpenChange:x?void 0:r,children:e.jsxs(Ne,{className:"max-w-md",children:[e.jsxs(Ce,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{name:"alert",className:"size-5 text-[var(--status-warning)]"}),e.jsx(Se,{children:"Uncommitted Changes"})]}),e.jsx(Le,{children:`Stash your local changes before starting the ${o}.`})]}),e.jsxs("div",{className:"py-2",children:[e.jsx("p",{className:"typography-meta text-muted-foreground mb-3",children:"This will:"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 typography-meta text-foreground",children:[e.jsx("li",{children:"Stash your uncommitted changes"}),e.jsxs("li",{children:[o==="merge"?"Merge":"Rebase"," ",o==="merge"?"with":"onto"," ",e.jsx("span",{className:"font-mono text-primary",children:h})]}),n&&e.jsx("li",{children:"Restore your stashed changes"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 py-2",children:[e.jsx(ia,{checked:n,onChange:t,disabled:x,ariaLabel:"Restore stashed changes after operation"}),e.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!x&&t(!n),children:`Restore stashed changes after ${o}`})]}),e.jsxs(Ve,{className:"gap-2",children:[e.jsx(_,{variant:"ghost",size:"sm",onClick:S,disabled:x,children:"Cancel"}),e.jsx(_,{variant:"default",size:"sm",onClick:N,disabled:x,className:"gap-1.5",children:x?e.jsxs(e.Fragment,{children:[e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}),"Processing..."]}):`${y}`})]})]})})},tr=({open:s,onOpenChange:r,directory:o,hasUncommittedChanges:h,hasStagedChanges:m=!1,uncommittedFileCount:n,onChanged:t})=>{const{git:x}=ft(),[d,y]=a.useState([]),[N,S]=a.useState(!1),[v,p]=a.useState(""),[c,u]=a.useState(""),[E,k]=a.useState(null),[$,B]=a.useState({}),H=a.useCallback(async()=>{if(o){S(!0);try{const b=await x.listGitStashes(o);y(b.stashes),B({})}catch(b){R.error(b instanceof Error?b.message:"Failed to load stashes")}finally{S(!1)}}},[o,x]);a.useEffect(()=>{s&&H()},[H,s]),a.useEffect(()=>{if(!s||!o||d.length===0)return;let b=!1;const T=d.map(q=>q.ref);return x.countGitStashFiles(o,T).then(q=>{b||B(q.counts)}).catch(()=>{}),()=>{b=!0}},[o,x,s,d]);const A=a.useMemo(()=>{const b=v.trim().toLowerCase();return b?d.filter(T=>`${T.ref} ${T.message} ${T.relativeTime}`.toLowerCase().includes(b)):d},[v,d]),P=a.useCallback(async b=>{await H(),await t?.(b)},[H,t]),M=async()=>{if(!(!o||E)){k("create");try{const b=await x.stashGitChanges(o,{message:c.trim()||void 0});b.created?(R.success("Changes stashed"),u("")):R.info("No local changes to stash"),await P({affectsIndex:!!(b.created&&m)})}catch(b){R.error(b instanceof Error?b.message:"Failed to stash changes")}finally{k(null)}}},z=async(b,T)=>{if(!(!o||E)&&!(T==="drop"&&!window.confirm(`Drop ${b.ref}?`))){k(`${T}:${b.ref}`);try{T==="apply"&&await x.applyGitStash(o,{ref:b.ref}),T==="pop"&&await x.popGitStash(o,{ref:b.ref}),T==="drop"&&await x.dropGitStash(o,{ref:b.ref});const q=T==="apply"?"Stash applied":T==="pop"?"Stash popped":"Stash dropped";R.success(q),await P({affectsIndex:T!=="drop"})}catch(q){const Q=T==="apply"?"Failed to apply stash":T==="pop"?"Failed to pop stash":"Failed to drop stash";R.error(q instanceof Error?q.message:Q),await P({affectsIndex:T!=="drop"})}finally{k(null)}}},G=E!==null;return e.jsx(we,{open:s,onOpenChange:r,children:e.jsxs(Ne,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[e.jsxs(Ce,{children:[e.jsxs(Se,{className:"flex items-center gap-2",children:[e.jsx(w,{name:"archive-stack",className:"h-5 w-5"}),"Stashes"]}),e.jsx(Le,{children:"Save, restore, and clean up Git stashes for this repository."})]}),e.jsxs("div",{className:"mt-2 rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-3",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(xs,{value:c,onChange:b=>u(b.target.value),placeholder:"Stash name",disabled:G||!h,className:"flex-1"}),e.jsxs(_,{onClick:M,disabled:!h||G||!o,children:[E==="create"?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(w,{name:"inbox-archive",className:"size-4"}),`Stash ${n} files`]})]}),e.jsx("p",{className:"typography-meta mt-2 text-muted-foreground",children:"Untracked files are included automatically."})]}),e.jsxs("div",{className:"relative mt-2",children:[e.jsx(w,{name:"search",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(xs,{value:v,onChange:b=>p(b.target.value),placeholder:"Search stashes",className:"pl-9"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:N?e.jsx("div",{className:"flex items-center justify-center py-10 text-muted-foreground",children:e.jsx(w,{name:"loader-4",className:"size-5 animate-spin"})}):A.length===0?e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:v?"No matching stashes.":"No stashes yet."}):A.map((b,T)=>e.jsxs("div",{className:"group flex items-center gap-2 rounded py-1.5 transition-colors hover:bg-interactive-hover/30",children:[e.jsxs("div",{className:"min-w-0 flex-1 pl-2",children:[e.jsx("p",{className:"typography-small truncate text-foreground",children:b.message||"Untitled stash"}),e.jsxs("p",{className:"typography-meta truncate text-muted-foreground",children:[e.jsxs(ke,{children:[e.jsx(Re,{asChild:!0,children:e.jsx("span",{children:T===0&&!v.trim()?"Latest":`#${T+1}`})}),e.jsx(Ee,{sideOffset:6,children:b.ref})]})," · ",b.relativeTime," · ",typeof $[b.ref]=="number"?`${$[b.ref]} files`:"counting files..."]})]}),e.jsxs("div",{className:"mr-2 flex shrink-0 items-center gap-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100",children:[e.jsx(At,{label:"Apply",loading:E===`apply:${b.ref}`,onClick:()=>z(b,"apply"),disabled:G,children:e.jsx(w,{name:"inbox-unarchive",className:"size-4"})}),e.jsx(At,{label:"Pop",loading:E===`pop:${b.ref}`,onClick:()=>z(b,"pop"),disabled:G,children:e.jsx(w,{name:"inbox-unarchive-fill",className:"size-4"})}),e.jsx(At,{label:"Drop",loading:E===`drop:${b.ref}`,onClick:()=>z(b,"drop"),disabled:G,destructive:!0,children:e.jsx(w,{name:"delete-bin",className:"size-4"})})]})]},b.ref))})]})})},At=({label:s,loading:r,disabled:o,destructive:h,onClick:m,children:n})=>e.jsxs(ke,{children:[e.jsx(Re,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":s,"aria-busy":r||void 0,className:te("flex h-6 w-6 items-center justify-center transition-colors disabled:opacity-50",h?"text-[var(--status-error)] hover:text-[var(--status-error)]":"text-muted-foreground hover:text-foreground"),onClick:m,disabled:o,children:r?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):n})}),e.jsx(Ee,{sideOffset:6,children:s})]}),sr=({currentBranch:s,localBranches:r,remoteBranches:o,onMerge:h,onRebase:m,disabled:n=!1,isOperating:t=!1,operationLogs:x=[],onOperationComplete:d,mode:y="dialog",defaultTargetBranch:N})=>{const[S,v]=a.useState(!1),[p,c]=a.useState("merge"),[u,E]=a.useState(null),[k,$]=a.useState(!1),[B,H]=a.useState(""),A=a.useRef(null),P=a.useRef(null),M=n||t,z=s||"current branch",G=x.length>0&&x.every(O=>O.status==="done"||O.status==="error"),b=x.some(O=>O.status==="error");a.useEffect(()=>{P.current&&(P.current.scrollTop=P.current.scrollHeight)},[x]);const T=a.useMemo(()=>{const O=B.toLowerCase(),C=new Set(o.map(l=>l.slice(l.indexOf("/")+1)).filter(Boolean)),F=r.filter(l=>l!==s&&!C.has(l));return O?F.filter(l=>l.toLowerCase().includes(O)):F},[B,r,s,o]),q=a.useMemo(()=>{const O=B.toLowerCase();return O?o.filter(C=>C.toLowerCase().includes(O)):o},[B,o]),Q=a.useCallback(()=>N&&(o.includes(N)||r.includes(N))?N:null,[N,r,o]),U=()=>{v(!0),E(Q()),c("merge"),H("")},W=O=>{E(O),$(!1),H("")},I=()=>{u&&(p==="merge"?h(u):m(u))},X=()=>{t||(E(null),c("merge"),H(""),v(!1))},re=()=>{t&&!G||(G&&d?.(),E(null),c("merge"),H(""),v(!1))};a.useEffect(()=>{k||H("")},[k]),a.useEffect(()=>{y==="dialog"||u||E(Q())},[y,Q,u]);const K=t?e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{ref:P,className:"rounded-lg border border-border bg-muted/30 p-3 max-h-48 overflow-y-auto",children:e.jsx("div",{className:"space-y-2",children:x.map((O,C)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"mt-0.5 shrink-0",children:[O.status==="running"&&e.jsx(w,{name:"loader-4",className:"size-3.5 animate-spin text-primary"}),O.status==="done"&&e.jsx(w,{name:"check",className:"size-3.5 text-success"}),O.status==="error"&&e.jsx(w,{name:"close",className:"size-3.5 text-destructive"}),O.status==="pending"&&e.jsx("div",{className:"size-3.5 rounded-full border border-muted-foreground/30"})]}),e.jsx("span",{className:te("typography-micro",O.status==="error"&&"text-destructive",O.status==="done"&&"text-muted-foreground",O.status==="running"&&"text-foreground",O.status==="pending"&&"text-muted-foreground/60"),children:O.message})]},C))})}),G?y==="dialog"?e.jsx(Ve,{children:e.jsx(_,{variant:"default",size:"sm",onClick:re,children:b?"Close":"Done"})}):e.jsx("div",{className:"flex justify-end",children:e.jsx(_,{variant:"default",size:"sm",onClick:re,children:b?"Close":"Done"})}):null]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"typography-meta text-muted-foreground",children:"Operation"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>c("merge"),className:te("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",p==="merge"?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{name:"git-merge",className:te("size-4",p==="merge"?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:te("typography-ui-label",p==="merge"?"text-foreground":"text-muted-foreground"),children:"Merge"})]}),e.jsx("p",{className:"typography-micro text-muted-foreground",children:"Create a merge commit and preserve branch history."})]}),e.jsxs("button",{type:"button",onClick:()=>c("rebase"),className:te("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",p==="rebase"?"border-primary bg-primary/5":"border-border hover:border-border/80 hover:bg-muted/50"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{name:"git-branch",className:te("size-4",p==="rebase"?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:te("typography-ui-label",p==="rebase"?"text-foreground":"text-muted-foreground"),children:"Rebase"})]}),e.jsx("p",{className:"typography-micro text-muted-foreground",children:"Replay your commits on top of the selected branch."})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("p",{className:"typography-meta text-muted-foreground",children:p==="merge"?`Branch to merge into ${z}`:"Branch to rebase onto"}),e.jsxs(We,{open:k,onOpenChange:$,modal:!1,children:[e.jsx(Ke,{asChild:!0,children:e.jsxs("button",{type:"button",className:te(oa({size:"default"}),"w-full"),children:[e.jsx("span",{className:te("truncate",!u&&"text-muted-foreground"),children:u||"Select Branch"}),e.jsx(w,{name:"arrow-down-s",className:"size-4 opacity-60 shrink-0"})]})}),e.jsx(qe,{align:"start",sideOffset:6,className:"w-[var(--anchor-width)] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",children:e.jsxs(Ht,{className:"h-full min-h-0",children:[e.jsx(Ut,{ref:A,placeholder:"Search branches...",value:B,onValueChange:H,onKeyDown:O=>O.stopPropagation()}),e.jsxs(Vt,{className:"h-full min-h-0",disableHorizontal:!0,children:[e.jsx(Wt,{children:"No branches found."}),T.length>0&&e.jsx(Ge,{heading:"Local branches",children:T.map(O=>e.jsx(Me,{onSelect:()=>W(O),children:e.jsx("span",{className:"typography-ui-label text-foreground truncate",children:O})},`local-${O}`))}),T.length>0&&q.length>0?e.jsx(Ot,{}):null,q.length>0&&e.jsx(Ge,{heading:"Remote branches",children:q.map(O=>e.jsx(Me,{onSelect:()=>W(O),children:e.jsx("span",{className:"typography-ui-label text-foreground truncate",children:O})},`remote-${O}`))})]})]})})]})]}),u?e.jsx("div",{className:"rounded-lg bg-muted/50 p-3",children:e.jsx("p",{className:"typography-meta text-muted-foreground",children:p==="merge"?e.jsxs(e.Fragment,{children:["This will merge"," ",e.jsx("span",{className:"font-mono text-foreground",children:u})," ","into"," ",e.jsx("span",{className:"font-mono text-foreground",children:z})]}):e.jsxs(e.Fragment,{children:["This will rebase"," ",e.jsx("span",{className:"font-mono text-foreground",children:z})," ","onto"," ",e.jsx("span",{className:"font-mono text-foreground",children:u})]})})}):null,y==="dialog"?e.jsxs(Ve,{className:"gap-2 pt-1",children:[e.jsx(_,{variant:"ghost",size:"sm",onClick:X,children:"Cancel"}),e.jsx(_,{variant:"default",size:"sm",onClick:I,disabled:!u,className:"gap-1.5",children:p==="merge"?e.jsxs(e.Fragment,{children:[e.jsx(w,{name:"git-merge",className:"size-4"}),"Merge"]}):e.jsxs(e.Fragment,{children:[e.jsx(w,{name:"git-branch",className:"size-4"}),"Rebase"]})})]}):e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(_,{variant:"destructive",size:"sm",onClick:X,disabled:M,children:"Reset"}),e.jsx("div",{className:"flex-1"}),e.jsx(_,{variant:"default",size:"sm",onClick:I,disabled:M||!u,children:p==="merge"?"Merge":"Rebase"})]})]});return y==="bare"?K:y==="inline"?e.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[e.jsx("header",{className:"border-b border-border/40 px-0 py-3",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:"Update branch"}),e.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Bring the latest changes into"," ",e.jsx("span",{className:"font-mono text-foreground",children:z}),"."]})]})}),e.jsx("div",{className:"pt-3",children:K})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ke,{children:[e.jsx(Re,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",className:"gap-1.5",onClick:U,disabled:M,children:[t?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(w,{name:"git-merge",className:"size-4"}),e.jsx("span",{children:"Merge/Rebase"})]})}),e.jsx(Ee,{sideOffset:8,children:"Update this branch from another branch."})]}),e.jsx(we,{open:S,onOpenChange:O=>{O?v(!0):re()},children:e.jsxs(Ne,{className:"max-w-md",children:[e.jsxs(Ce,{children:[e.jsx(Se,{children:"Update branch"}),e.jsx(Le,{children:t?G?b?"Operation Failed":"Operation Completed":p==="merge"?"Merging In Progress":"Rebasing In Progress":e.jsxs(e.Fragment,{children:["Choose how to bring another branch into"," ",e.jsx("span",{className:"font-mono text-foreground",children:z}),"."]})})]}),K]})})]})},nr=a.memo(function({open:r,onOpenChange:o,branchOperation:h,currentBranch:m,localBranches:n,remoteBranches:t,defaultTargetBranch:x,onMerge:d,onRebase:y,disabled:N,operationLogs:S,onOperationComplete:v,canShowBranchWorkflows:p}){return e.jsx(we,{open:r,onOpenChange:c=>{!c&&h!==null||o(c)},children:e.jsxs(Ne,{className:"max-w-2xl min-h-[26rem]",children:[e.jsxs(Ce,{children:[e.jsx(Se,{children:"Update branch"}),e.jsxs(Le,{children:["Bring the latest changes into"," ",e.jsx("span",{className:"font-mono text-foreground",children:m??""}),"."]})]}),p?e.jsx(sr,{mode:"bare",currentBranch:m,localBranches:n,remoteBranches:t,defaultTargetBranch:x??void 0,onMerge:d,onRebase:y,disabled:N,isOperating:h!==null,operationLogs:S,onOperationComplete:v}):e.jsx("p",{className:"typography-meta text-muted-foreground",children:"Branch actions unavailable in this repository state"})]})})}),ar=({currentDirectory:s,isUpdateBranchDialogOpen:r,setIsUpdateBranchDialogOpen:o,branchOperation:h,currentBranch:m,localBranches:n,remoteBranches:t,updateTargetBranch:x,onMerge:d,onRebase:y,isBusy:N,operationLogs:S,onOperationComplete:v,canShowBranchWorkflows:p,gitLogDialogMode:c,setGitLogDialogMode:u,onRefreshHistory:E,isLogRefreshing:k,log:$,maxCount:B,onMaxCountChange:H,expandedCommitHashes:A,onToggleCommit:P,commitFilesMap:M,loadingCommitHashes:z,onCopyHash:G,historyBranchDivider:b,onConflict:T,onActionSuccess:q,isStashesDialogOpen:Q,setIsStashesDialogOpen:U,hasUncommittedChanges:W,hasStagedChanges:I,uncommittedFileCount:X,onStashesChanged:re,isGitmojiPickerOpen:ae,setIsGitmojiPickerOpen:Y,gitmojiEmojis:K,onSelectGitmoji:O,conflictDialogOpen:C,setConflictDialogOpen:F,conflictFiles:l,conflictOperation:D,onAbortConflict:V,onClearConflictState:se,stashDialogOpen:ue,setStashDialogOpen:me,stashDialogOperation:ne,stashDialogBranch:Fe,onConfirmStashAndRetry:gt})=>e.jsxs(e.Fragment,{children:[e.jsx(nr,{open:r,onOpenChange:o,branchOperation:h,currentBranch:m,localBranches:n,remoteBranches:t,defaultTargetBranch:x,onMerge:d,onRebase:y,disabled:N,operationLogs:S,onOperationComplete:v,canShowBranchWorkflows:p}),e.jsx(Qa,{mode:c,onOpenChange:Oe=>{Oe||u(null)},onRefresh:E,isRefreshing:k,log:$,maxCount:B,onMaxCountChange:H,expandedCommitHashes:A,onToggleCommit:P,commitFilesMap:M,loadingCommitHashes:z,onCopyHash:G,directory:s??void 0,branchDivider:b,onConflict:T,onActionSuccess:q}),e.jsx(tr,{open:Q,onOpenChange:U,directory:s,hasUncommittedChanges:W,hasStagedChanges:I,uncommittedFileCount:X,onChanged:re}),e.jsx(Xa,{open:ae,onOpenChange:Y,gitmojis:K,onSelect:O}),s&&e.jsx(Ua,{open:C,onOpenChange:F,conflictFiles:l,directory:s,operation:D,onAbort:V,onClearState:se}),e.jsx(er,{open:ue,onOpenChange:me,operation:ne,targetBranch:Fe,onConfirm:gt})]}),rr=20,Be=new Map;function ir(s){return Be.get(s)??null}function or(s,r){if(Be.delete(s),Be.set(s,r),Be.size>rr){const o=Be.keys().next().value;o!==void 0&&Be.delete(o)}}const Tt=38,ht=200,lr=({value:s,onChange:r,placeholder:o,disabled:h=!1,hasTouchInput:m=!1,isMobile:n=!1})=>{const t=a.useRef(null),x=pt(d=>d.inputSpellcheckEnabled);return a.useLayoutEffect(()=>{const d=t.current;if(!d)return;const y=document.activeElement===d,N=()=>{d.style.height=`${Tt}px`;const v=d.scrollHeight,p=Math.min(Math.max(v,Tt),ht);d.style.height=`${p}px`,d.style.overflowY=v>ht?"auto":"hidden",v>ht&&!y&&(d.scrollTop=d.scrollHeight)};N();const S=window.requestAnimationFrame(N);return()=>{window.cancelAnimationFrame(S)}},[s]),e.jsx("textarea",{ref:t,value:s,onChange:d=>r(d.target.value),placeholder:o??"Commit message",rows:1,disabled:h,autoCorrect:m?"on":"off",autoCapitalize:m?"sentences":"off",spellCheck:n||x,className:te("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)]",h&&"opacity-50"),style:{minHeight:Tt,maxHeight:ht}})},Hs=({stagedCount:s,commitMessage:r,onCommitMessageChange:o,onCommit:h,onCommitAndPush:m,commitAction:n,hasPendingIndexMutation:t=!1,gitmojiEnabled:x,onOpenGitmojiPicker:d})=>{const y=s>0,N=r.trim()&&y&&n===null&&!t,{isMobile:S,hasTouchInput:v}=la();return e.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[e.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[e.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:"Commit"}),y?null:e.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:"Stage files to enable commit."})]}),e.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[e.jsx(lr,{value:r,onChange:o,placeholder:"Commit message",disabled:n!==null,hasTouchInput:v,isMobile:S}),x&&e.jsxs(_,{variant:"outline",size:"sm",onClick:d,className:"w-fit",type:"button",children:[e.jsx(w,{name:"emotion-happy",className:"size-4"}),"Add gitmoji"]}),e.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"flex-1"}),e.jsx(_,{size:"sm",variant:"outline",onClick:h,disabled:!N,className:"commit-actions__btn whitespace-nowrap","aria-label":"Commit aria label",children:n==="commit"?e.jsxs(e.Fragment,{children:[e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"commit-actions__label",children:"Committing..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(w,{name:"git-commit",className:"size-4"}),e.jsx("span",{className:"commit-actions__label",children:"Commit"})]})}),S?e.jsxs(ke,{children:[e.jsx(Re,{asChild:!0,children:e.jsx(_,{variant:"default",size:"sm",onClick:()=>m(),disabled:!N,className:"h-7 w-7 p-0","aria-label":"Commit and sync",children:n==="commitAndPush"?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(w,{name:"arrow-up",className:"size-3.5"})})}),e.jsx(Ee,{side:"top",children:e.jsx("p",{children:"Commit & sync"})})]}):e.jsx(_,{size:"sm",variant:"default",onClick:()=>m(),disabled:!N,className:"commit-actions__btn","aria-label":"Commit and sync",children:n==="commitAndPush"?e.jsxs(e.Fragment,{children:[e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:"Syncing..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(w,{name:"arrow-up",className:"size-3.5"}),e.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:"Commit & sync"})]})})]})]})]})},cr=({onOpenStashes:s})=>e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center",children:[e.jsx(w,{name:"git-commit",className:"size-10 text-muted-foreground/70 mb-4"}),e.jsx("p",{className:"typography-ui-label font-semibold text-foreground mb-1",children:"Working tree clean"}),e.jsx("p",{className:"typography-meta text-muted-foreground mb-4",children:"All changes have been committed"}),s?e.jsxs(_,{type:"button",variant:"outline",size:"sm",onClick:s,className:"gap-1.5",children:[e.jsx(w,{name:"archive-stack",className:"size-4"}),"Stashes"]}):null]}),dr=({mergeInProgress:s,rebaseInProgress:r,onContinue:o,onAbort:h,onResolveWithAI:m,conflictCount:n=0,isLoading:t=!1})=>{const[x,d]=a.useState(null),y=s&&s.head,N=r&&(r.headName||r.onto),S=y?"merge":N?"rebase":null;if(!S)return null;const v=async()=>{d("continue");try{await o()}finally{d(null)}},p=async()=>{d("abort");try{await h()}finally{d(null)}},c=x!==null,u=n>0,E=S==="merge"?"Merge":"Rebase";let k="";s?k=s.message?`Merging: ${s.message}`:`Merging ${s.head}`:r&&(k=r.headName?`Rebasing ${r.headName} onto ${r.onto||""}`:"Rebase in progress");const $=u?n===1?`${E} in progress: ${n} conflict`:`${E} in progress: ${n} conflicts`:`${E} in progress`,B=u?"Resolve conflicts, then continue the operation.":"All conflicts resolved. Continue to finish the operation.";return e.jsx("div",{className:"mx-4 mt-3 overflow-hidden rounded-lg border border-[var(--status-warning-border)]",children:e.jsxs("div",{className:"flex flex-col gap-3 p-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"typography-label text-[var(--status-warning)]",children:$}),k&&e.jsx("p",{className:"typography-micro break-words text-muted-foreground",children:k})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("p",{className:"typography-micro min-w-0 flex-1 text-muted-foreground",children:B}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(_,{variant:"ghost",size:"sm",onClick:p,disabled:c||t,className:"gap-1.5",children:[x==="abort"?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(w,{name:"close",className:"size-4"}),"Abort"]}),u?m&&e.jsx(_,{variant:"default",size:"sm",onClick:m,disabled:c||t,children:"Resolve with AI"}):e.jsxs(_,{variant:"default",size:"sm",onClick:v,disabled:c||t,className:"gap-1.5",children:[x==="continue"?e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(w,{name:"check",className:"size-4"}),"Continue"]})]})]})]})})};function ur(s,r){const[o,h]=a.useState(new Set),[m,n]=a.useState(new Map),[t,x]=a.useState(new Set),d=a.useRef(m),y=a.useRef(t),N=a.useCallback(v=>{ca(v).then(p=>{if(p.ok){R.success("Commit hash copied");return}R.error("Failed to copy")})},[]),S=a.useCallback(v=>{h(p=>{const c=new Set(p);return c.has(v)?c.delete(v):c.add(v),c})},[]);return a.useEffect(()=>{d.current=m},[m]),a.useEffect(()=>{y.current=t},[t]),a.useEffect(()=>{if(!s||!r)return;const v=Array.from(o).filter(c=>!d.current.has(c)&&!y.current.has(c));if(v.length===0)return;let p=!1;return x(c=>{const u=new Set(c);for(const E of v)u.add(E);return y.current=u,u}),Promise.all(v.map(c=>r.getCommitFiles(s,c).then(u=>({hash:c,files:u.files})).catch(u=>(console.error("Failed to fetch commit files:",u),{hash:c,files:[]})))).then(c=>{p||(n(u=>{const E=new Map(u);for(const{hash:k,files:$}of c)E.set(k,$);return d.current=E,E}),x(u=>{const E=new Set(u);for(const{hash:k}of c)E.delete(k);return y.current=E,E}))}),()=>{p=!0,x(c=>{let u=!1;const E=new Set(c);for(const k of v)E.delete(k)&&(u=!0);return u?(y.current=E,E):c})}},[o,s,r]),{expandedCommitHashes:o,commitFilesMap:m,loadingCommitHashes:t,handleCopyCommitHash:N,handleToggleCommit:S}}const hr=s=>{const{remoteNames:r,localBranches:o,worktreeCreatedFromBranch:h,rootBranchHint:m,defaultBranch:n,headBranch:t}=s,x=typeof t=="string"?t.trim():"",d=p=>{if(!p)return"";let c=p.trim();if(!c||c==="HEAD")return"";if(o.includes(c))return c;c.startsWith("refs/heads/")&&(c=c.slice(11)),c.startsWith("heads/")&&(c=c.slice(6)),c.startsWith("remotes/")&&(c=c.slice(8));const u=c.indexOf("/");if(u>0){const E=c.slice(0,u);if(r.has(E)){const k=c.slice(u+1).trim();k&&(c=k)}}return c},y=p=>{const c=d(typeof p=="string"?p:"");return c&&c!==x?c:""},N=y(h);if(N)return N;const S=y(m);if(S)return S;const v=y(n);return v||(o.includes("main")?"main":o.includes("master")?"master":o.includes("develop")?"develop":"main")},mr=s=>{const{baseBranch:r,localBranches:o,remoteBranches:h}=s;return o.includes(r)?!0:h.some(m=>{const n=m.indexOf("/");return n>0&&m.slice(n+1)===r})},fr=s=>s?s.filter(r=>!r.startsWith("remotes/")).sort():[],pr=s=>s?s.filter(r=>r.startsWith("remotes/")).map(r=>r.replace(/^remotes\//,"")).sort():[],gr=(s,r,o,h)=>{if(s.length>0)return s;const m=new Set,n=o?.trim();n&&n.includes("/")&&m.add(n.split("/")[0]);for(const t of r){const x=t.indexOf("/");x>0&&m.add(t.slice(0,x))}return m.size===0&&h&&m.add("origin"),Array.from(m).map(t=>({name:t,fetchUrl:h??"",pushUrl:h??""}))},xr=(s,r)=>{const o=r?.trim().split("/")[0];return(o&&s?.[o])??s?.origin},br=(s,r,o)=>o?s.map(n=>n.name).map(n=>`${n}/${o}`).find(n=>r.includes(n))??o:null;function yr({branches:s,status:r,remotes:o,remoteUrl:h,git:m}){const n=a.useMemo(()=>fr(s?.all),[s?.all]),t=a.useMemo(()=>pr(s?.all),[s?.all]),x=a.useMemo(()=>gr(o,t,r?.tracking,h),[o,t,h,r?.tracking]),d=r?.current??null,y=a.useMemo(()=>xr(s?.defaultBranches,r?.tracking),[s?.defaultBranches,r?.tracking]),N=a.useMemo(()=>hr({remoteNames:new Set(x.map(p=>p.name)),localBranches:n,defaultBranch:y,headBranch:d}),[d,y,x,n]),S=!!(d&&N&&d!==N&&(r?.tracking||x.length>0)&&typeof m?.getGitRangeDiff=="function"&&mr({baseBranch:N,localBranches:n,remoteBranches:t})),v=a.useMemo(()=>br(x,t,N),[N,x,t]);return{localBranches:n,remoteBranches:t,effectiveRemotes:x,currentBranch:d,defaultBranch:y,baseBranch:N,branchScopeAvailable:S,updateTargetBranch:v}}const jr=s=>{if(!s)return null;try{let r=s.trim();r.startsWith("git@")&&(r=`https://${r.slice(4).replace(":","/")}`),r.endsWith(".git")&&(r=r.slice(0,-4));const o=new URL(r);return o.hostname+o.pathname}catch{return null}},vr=(s,r,o)=>{const h=new Map;r&&h.set(r.id,r);const m=jr(o);for(const n of s){if(n.authType!=="token"){h.set(n.id,n);continue}const t=n.host;if(!t){h.set(n.id,n);continue}if(!t.includes("/")){h.set(n.id,n);continue}m&&m===t&&h.set(n.id,n)}return Array.from(h.values())},wr=(s,r,o)=>{if(s?.userName&&s?.userEmail){const h=r.find(m=>m.userName===s.userName&&m.userEmail===s.userEmail);return h||(o&&o.userName===s.userName&&o.userEmail===s.userEmail?o:{id:"local-config",name:s.userName,userName:s.userName,userEmail:s.userEmail,sshKey:s.sshCommand?.replace("ssh -i ","")??null,color:"info",icon:"user"})}return o??null};function Nr({profiles:s,globalIdentity:r,currentIdentity:o,remoteUrl:h}){const m=a.useMemo(()=>vr(s,r,h),[s,r,h]),n=a.useMemo(()=>wr(o,s,r),[o,s,r]);return{availableIdentities:m,activeIdentityProfile:n}}function Cr({currentSessionId:s,currentDirectory:r}){const[o,h]=a.useState(!1),[m,n]=a.useState([]),[t,x]=a.useState("merge"),d=a.useMemo(()=>s?`pichamber.conflict:${s}`:null,[s]),y=a.useCallback((S,v,p)=>{if(!d||typeof window>"u")return;const c={directory:S,conflictFiles:v,operation:p};window.localStorage.setItem(d,JSON.stringify(c))},[d]),N=a.useCallback(()=>{!d||typeof window>"u"||window.localStorage.removeItem(d)},[d]);return a.useEffect(()=>{if(!d||typeof window>"u"||!r)return;const S=window.localStorage.getItem(d);if(S)try{const v=JSON.parse(S);if(v.directory!==r){window.localStorage.removeItem(d);return}n(v.conflictFiles??[]),x(v.operation??"merge"),h(!0)}catch{window.localStorage.removeItem(d)}},[d,r]),{conflictDialogOpen:o,setConflictDialogOpen:h,conflictFiles:m,setConflictFiles:n,conflictOperation:t,setConflictOperation:x,persistConflictState:y,clearConflictState:N}}const Sr=({runMutation:s,onMutationComplete:r,onMutationError:o,onPathsComplete:h,scheduleFlush:m})=>{const n=[];let t=!1;return{enqueue:d=>{const y=n[n.length-1];if(y?.directory===d.directory&&y.direction===d.direction){d.paths.forEach(N=>y.paths.add(N));return}n.push(d)},flush:()=>{if(t)return;const d=n.shift();if(!d)return;t=!0;const y={directory:d.directory,direction:d.direction,paths:Array.from(d.paths),rollback:d.rollback};(async()=>{try{await s(y),r(y)}catch(N){o(y,N)}finally{h(y.paths),t=!1,n.length>0&&m()}})()},clear:()=>{n.length=0},size:()=>n.length,isRunning:()=>t}},kr=a.memo(function({file:r,actionLabel:o,actionSymbol:h,onAction:m,onViewDiff:n,onRevert:t,isReverting:x,stats:d,rowPaddingClassName:y,indentPx:N=0,actionAtStart:S=!1,showRevert:v=!0}){const p=He.useMemo(()=>Fa(r),[r]),c=p.description,u=d?.insertions??0,E=d?.deletions??0,k=He.useCallback(A=>{A.key===" "?(A.preventDefault(),m()):A.key==="Enter"&&(A.preventDefault(),n())},[m,n]),$=He.useCallback(A=>{A.preventDefault(),A.stopPropagation(),m()},[m]),B=He.useCallback(A=>{A.preventDefault(),A.stopPropagation(),t()},[t]),H=e.jsx("button",{type:"button",onClick:$,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":o,title:o,children:h});return e.jsxs("div",{className:`group flex items-center gap-2 py-1.5 cursor-pointer ${y??"px-3"}`,role:"button",tabIndex:0,onClick:n,onKeyDown:k,style:N>0?{paddingLeft:`${N}px`}:void 0,children:[S?H:null,e.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:p.color},title:c,"aria-label":c,children:p.code}),e.jsx(da,{filePath:r.path,className:"h-3.5 w-3.5 shrink-0"}),(()=>{const A=r.path.lastIndexOf("/");if(A===-1)return e.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:r.path,children:r.path});const P=r.path.slice(0,A),M=r.path.slice(A);return e.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:r.path,children:[e.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:P}),e.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[e.jsx("span",{className:"text-muted-foreground",children:"/"}),e.jsx("span",{className:"text-foreground",children:M.slice(1)})]})]})})(),e.jsxs("span",{className:"shrink-0 typography-micro",children:[e.jsxs("span",{style:{color:"var(--status-success)"},children:["+",u]}),e.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),e.jsxs("span",{style:{color:"var(--status-error)"},children:["-",E]})]}),v?e.jsxs(ke,{children:[e.jsx(Re,{asChild:!0,children:e.jsx("button",{type:"button",onClick:B,disabled:x,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":`Revert changes in ${r.path}`,children:x?e.jsx(w,{name:"loader-4",className:"size-3.5 animate-spin"}):e.jsx(w,{name:"arrow-go-back",className:"size-3.5"})})}),e.jsx(Ee,{sideOffset:8,children:"Revert changes"})]}):null,S?null:H]})}),zs=14,Us=s=>s.replace(/\\/g,"/").replace(/^\/+/,"").trim(),Is=(s,r)=>({id:`dir:${s}`,path:s,name:r,children:new Map,directFiles:[],files:[]}),Rr=s=>{const r=Is("","");for(const o of s){const h=Us(o.path);if(!h)continue;const n=h.split("/").filter(Boolean).slice(0,-1);let t=r;if(t.files.push(o),n.length>0){let x="";for(const d of n){x=x?`${x}/${d}`:d;const y=t.children.get(d);if(y){y.files.push(o),t=y;continue}const N=Is(x,d);N.files.push(o),t.children.set(d,N),t=N}}t.directFiles.push(o)}return r},Er=(s,r)=>{const o=[],h=(m,n)=>{const t=Array.from(m.children.values()).sort((d,y)=>d.path.localeCompare(y.path));for(const d of t)o.push({key:d.id,kind:"directory",depth:n,directory:d}),r.has(d.path)&&h(d,n+1);const x=[...m.directFiles].sort((d,y)=>d.path.localeCompare(y.path));for(const d of x)o.push({key:`file:${Us(d.path)}`,kind:"file",depth:n,file:d})};return h(s,0),o},Fr=1e3,$s=34,Bt=30,mt="pl-0 pr-2",Gt=(s,r)=>`${s} ${r}`,zr=({groups:s,diffStats:r,revertingPaths:o,isRevertingAll:h=!1,headerBackgroundClassName:m="bg-sidebar",onVisiblePathsChange:n,onRevertAll:t,onRevertDirectory:x})=>{const d=a.useRef(null),N=pt(C=>C.gitChangesViewMode)==="tree",S=a.useMemo(()=>s.filter(C=>C.entries.length>0),[s]),[v,p]=a.useState(new Set),[c,u]=a.useState(new Set),[E,k]=a.useState(!1),[$,B]=a.useState(null),H=a.useMemo(()=>S.map(C=>Rr(C.entries)),[S]),A=a.useMemo(()=>{const C=[];return S.forEach((F,l)=>{Array.from(H[l]?.children.values()??[]).forEach(D=>{C.push(Gt(F.id,D.path))})}),C},[H,S]);a.useEffect(()=>{N&&u(C=>{const F=new Set,l=new Set(A);return C.forEach(D=>{(D.slice(D.indexOf(" ")+1).includes("/")||l.has(D))&&F.add(D)}),A.forEach(D=>F.add(D)),F})},[N,A]);const P=a.useMemo(()=>{const C=[];return S.forEach((F,l)=>{if(C.push({type:"header",key:`header:${F.id}`,groupIndex:l}),!v.has(F.id)){if(N){const D=new Set;c.forEach(se=>{se.startsWith(`${F.id} `)&&D.add(se.slice(F.id.length+1))}),Er(H[l],D).forEach(se=>{se.kind==="file"?C.push({type:"file",key:`${F.id}:${se.key}`,groupIndex:l,file:se.file,depth:se.depth}):C.push({type:"directory",key:`${F.id}:${se.key}`,groupIndex:l,directory:se.directory,depth:se.depth})});return}F.entries.forEach(D=>{C.push({type:"file",key:`${F.id}:file:${D.path}`,groupIndex:l,file:D,depth:0})})}}),t&&S.length>0&&C.push({type:"revert-all",key:"revert-all"}),C},[v,c,N,t,H,S]),M=P.length,z=M>=Fr,G=Da({count:M,enabled:z,getScrollElement:()=>d.current,estimateSize:()=>$s,overscan:12,getItemKey:C=>P[C]?.key??C}),b=G.getVirtualItems(),T=a.useMemo(()=>{if(!z)return 0;const C=d.current?.scrollTop??0;return b.find(l=>l.end>C)?.index??0},[z,b,d]);a.useEffect(()=>{if(!n)return;const C=F=>F&&F.type==="file"?F.file.path:null;if(M===0){n([]);return}if(!z){const F=[];for(const l of P)if(l.type==="file"&&(F.push(l.file.path),F.length>=Bt))break;n(F);return}n(P.slice(T,T+Math.ceil((d.current?.clientHeight??0)/$s)+Bt).map(F=>C(F)).filter(F=>!!F).slice(0,Bt))},[n,M,P,z,T]);const q=a.useCallback(C=>{p(F=>{const l=new Set(F);return l.has(C)?l.delete(C):l.add(C),l})},[]),Q=a.useCallback((C,F)=>{u(l=>{const D=new Set(l),V=Gt(C,F);return D.has(V)?D.delete(V):D.add(V),D})},[]),U=a.useMemo(()=>{const C=new Set;return S.forEach(F=>F.entries.forEach(l=>C.add(l.path))),Array.from(C)},[S]),W=U.length,I=$?h||$.paths.some(C=>o.has(C)):!1,X=a.useCallback(async()=>{!t||h||U.length===0||(await t(U),k(!1))},[U,h,t]),re=a.useCallback(async()=>{!x||!$||I||(await x($.paths),B(null))},[I,x,$]),ae=a.useCallback((C,F)=>{const l=v.has(C.id),D=C.entries.length;return e.jsxs("div",{className:te("sticky top-0 z-10 flex items-center gap-2 py-2",m,mt,!F&&"mt-1 border-t border-border/40"),children:[e.jsx("button",{type:"button",onClick:()=>C.onActionAll(C.entries.map(V=>V.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":C.actionAllLabel,title:C.actionAllLabel,children:C.actionSymbol}),e.jsxs("button",{type:"button",onClick:()=>q(C.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:[e.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:C.title}),e.jsx("span",{className:"typography-meta text-muted-foreground",children:D}),e.jsx(w,{name:"arrow-down-s",className:te("size-3.5 shrink-0 text-muted-foreground transition-transform",l&&"-rotate-90")})]})]})},[v,m,q]),Y=a.useCallback((C,F,l)=>{const D=c.has(Gt(C.id,F.path)),V=F.files.map(ue=>ue.path),se=h||V.some(ue=>o.has(ue));return e.jsxs("div",{className:te("group flex items-center gap-2 py-1.5",mt),style:{paddingLeft:`${l*zs}px`},children:[e.jsxs("button",{type:"button",onClick:()=>Q(C.id,F.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":D?`Collapse directory ${F.path}`:`Expand directory ${F.path}`,children:[D?e.jsx(w,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):e.jsx(w,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:F.path,children:F.name}),e.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:F.files.length})]}),C.showRevertActions!==!1&&x?e.jsx("button",{type:"button",onClick:()=>B({path:F.path,paths:V,count:V.length}),disabled:se,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":`Revert changes in ${F.path}`,title:"Revert folder changes",children:se?e.jsx(w,{name:"loader-4",className:"size-3.5 animate-spin"}):e.jsx(w,{name:"arrow-go-back",className:"size-3.5"})}):null,e.jsx("button",{type:"button",onClick:()=>C.onActionAll(F.files.map(ue=>ue.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":C.actionSymbol==="+"?`Stage all changes in ${F.path}`:`Unstage all changes in ${F.path}`,title:C.actionSymbol==="+"?`Stage all changes in ${F.path}`:`Unstage all changes in ${F.path}`,children:C.actionSymbol})]})},[c,h,x,o,Q]),K=a.useCallback((C,F)=>{if(C.type==="revert-all")return e.jsx("div",{className:te("flex justify-end py-2",mt),children:e.jsxs(_,{variant:"ghost",size:"sm",onClick:()=>k(!0),disabled:h,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[e.jsx(w,{name:"arrow-go-back",className:"size-3.5"}),"Revert all"]})});const l=S[C.groupIndex];if(!l)return null;if(C.type==="header")return ae(l,F);if(C.type==="directory")return Y(l,C.directory,C.depth);const D=C.file;return e.jsx(kr,{file:D,actionLabel:l.getActionLabel(D.path),actionSymbol:l.actionSymbol,onAction:()=>l.onActionFile(D.path),stats:r?.[D.path],onViewDiff:()=>l.onViewDiff(D.path),onRevert:()=>l.onRevertFile(D.path),isReverting:o.has(D.path)||h,rowPaddingClassName:mt,indentPx:C.depth*zs,actionAtStart:!N,showRevert:l.showRevertActions!==!1})},[r,h,N,Y,ae,o,S]),O=a.useCallback(C=>{const F=P[C],l=P[C-1];return!F||!l||F.type!=="file"&&F.type!=="directory"||l.type!=="file"&&l.type!=="directory"?!1:l.groupIndex===F.groupIndex},[P]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[e.jsx(Ps,{ref:d,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:z?e.jsx("div",{style:{height:G.getTotalSize(),position:"relative"},children:b.map(C=>{const F=P[C.index];return F?e.jsx("div",{"data-index":C.index,ref:G.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${C.start}px)`},className:te(O(C.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:K(F,C.index===0)},F.key):null})}):e.jsx("div",{role:"list","aria-label":"Changed files",children:P.map((C,F)=>e.jsx("div",{className:te("relative",O(F)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:K(C,F===0)},C.key))})}),e.jsx(ua,{containerRef:d,disableHorizontal:!0})]}),e.jsx(we,{open:E,onOpenChange:C=>{!h&&!C&&k(!1)},children:e.jsxs(Ne,{className:"max-w-md",children:[e.jsxs(Ce,{children:[e.jsx(Se,{children:"Revert all changes?"}),e.jsx(Le,{children:W===1?`Revert ${W} changed file? This cannot be undone.`:`Revert ${W} changed files? This cannot be undone.`})]}),e.jsxs(Ve,{children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>k(!1),disabled:h,children:"Cancel"}),e.jsx(_,{variant:"destructive",size:"sm",onClick:()=>{X()},disabled:h,children:h?"Reverting...":"Revert all"})]})]})}),e.jsx(we,{open:!!$,onOpenChange:C=>{!I&&!C&&B(null)},children:e.jsxs(Ne,{className:"max-w-md",children:[e.jsxs(Ce,{children:[e.jsx(Se,{children:"Revert folder changes?"}),e.jsx(Le,{children:$?$.count===1?`This will discard local changes in ${$.count} file under ${$.path}.`:`This will discard local changes in ${$.count} files under ${$.path}.`:null})]}),e.jsxs(Ve,{children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>B(null),disabled:I,children:"Cancel"}),e.jsx(_,{variant:"destructive",size:"sm",onClick:()=>{re()},disabled:I||!$,children:I?"Reverting...":"Revert folder"})]})]})})]})},Ir=As(()=>Ds(()=>import("./DiffView-CBOrV4hS.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119])).then(s=>({default:s.DiffView}))),$r=({currentDirectory:s,status:r,isGitRepo:o,isLoadingStatus:h,changeEntries:m,stagedChangeEntries:n,unstagedChangeEntries:t,effectiveRemotes:x,syncAction:d,commitAction:y,commitMessage:N,hasPendingIndexMutation:S,revertingPaths:v,isRevertingAll:p,initialDiffPath:c,initialDiffStaged:u=!1,onSyncAction:E,onMoveChangePaths:k,onRevertFile:$,onRevertAll:B,onCommitMessageChange:H,onCommit:A,onVisiblePathsChange:P,loadDiff:M})=>{const[z,G]=a.useState(()=>c?{type:"diff",path:c,staged:u}:{type:"list"}),[b,T]=a.useState(null),[q,Q]=a.useState(null),[U,W]=a.useState(0);a.useEffect(()=>{c&&G(Y=>Y.type==="diff"&&Y.path===c&&Y.staged===u?Y:{type:"diff",path:c,staged:u})},[c,u]);const I=a.useMemo(()=>z.type==="diff"&&m.some(Y=>Y.path===z.path),[m,z]);a.useEffect(()=>{if(z.type!=="diff"||!I){T(null),Q(null);return}let Y=!1;return T(null),Q(null),M(z.path,z.staged).then(K=>{Y||T(K)}).catch(K=>{Y||Q(K instanceof Error?K.message:String(K))}),()=>{Y=!0}},[U,M,z,I]);const X=a.useCallback((Y,K=!1)=>{G({type:"diff",path:Y,staged:K})},[]),re=a.useMemo(()=>{const Y=[];return n.length>0&&Y.push({id:"staged",title:"Staged",entries:n,actionSymbol:"-",actionAllLabel:"Unstage all changes",getActionLabel:K=>`Unstage ${K}`,onActionFile:K=>k([K],"unstage"),onActionAll:K=>k(K,"unstage"),onViewDiff:K=>X(K,!0),onRevertFile:$,showRevertActions:!1,accent:!0}),t.length>0&&Y.push({id:"unstaged",title:"Changes",entries:t,actionSymbol:"+",actionAllLabel:"Stage all changes",getActionLabel:K=>`Stage ${K}`,onActionFile:K=>k([K],"stage"),onActionAll:K=>k(K,"stage"),onViewDiff:K=>X(K,!1),onRevertFile:$}),Y},[X,k,$,n,t]),ae=a.useCallback(Y=>e.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-transparent text-foreground",children:[e.jsx("div",{className:"flex shrink-0 items-center gap-2 px-3 py-2",children:e.jsx("p",{className:"min-w-0 flex-1 truncate typography-ui-label text-muted-foreground",children:r?.current||s||""})}),e.jsx("div",{className:"min-h-0 flex-1",children:Y})]}),[s,r]);return s?o===null||o===!0&&!r?ae(e.jsx(De,{loading:!0,message:"Checking repository..."})):o===!1?ae(e.jsx(a.Suspense,{fallback:e.jsx(De,{loading:!0,message:"Loading last turn changes..."}),children:e.jsx(Ir,{diffScope:"turn",hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,flushContent:!0})})):z.type==="diff"?e.jsx(Mr,{path:z.path,diff:b,fileExists:I,error:q,onBack:()=>G({type:"list"}),onRetry:()=>W(Y=>Y+1)}):e.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-transparent text-foreground",children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-2 px-3 py-2",children:[e.jsx("p",{className:"min-w-0 flex-1 truncate typography-ui-label text-muted-foreground",children:r?.current||s}),e.jsx(_s,{syncAction:d,remotes:x,onFetch:Y=>E("fetch",Y),onSync:Y=>E("sync",Y),disabled:y!==null||h,aheadCount:r?.ahead??0,behindCount:r?.behind??0,trackingRemoteName:r?.tracking?.split("/")[0],hasUncommittedChanges:m.length>0})]}),m.length>0?e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden px-3 pt-2",children:e.jsx(zr,{groups:re,diffStats:r?.diffStats,revertingPaths:v,onRevertAll:B,isRevertingAll:p,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:P})}),e.jsx("div",{className:"shrink-0 border-t border-border/40 px-3 pb-3 pt-3",children:e.jsx(Hs,{stagedCount:n.length,commitMessage:N,onCommitMessageChange:H,onCommit:()=>{if(!N.trim()){R.error("Enter a commit message");return}if(n.length===0){R.error("Select at least one file to commit");return}A({pushAfter:!1})},onCommitAndPush:()=>{if(!N.trim()){R.error("Enter a commit message");return}if(n.length===0){R.error("Select at least one file to commit");return}A({pushAfter:!0})},commitAction:y,hasPendingIndexMutation:S,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(De,{icon:!0,message:"Working tree clean",description:"There are no changed files in this workspace."})})]}):ae(e.jsx(De,{message:"Select a session or directory to view Git status"}))},De=({message:s,description:r,loading:o=!1,icon:h=!1})=>e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[o?e.jsx(w,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,h?e.jsx(w,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),r?e.jsx("p",{className:"typography-meta text-muted-foreground",children:r}):null]})}),Mr=({path:s,diff:r,fileExists:o,error:h,onBack:m,onRetry:n})=>{const t=a.useMemo(()=>Ls(s)||"text",[s]);return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-transparent text-foreground",children:[e.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-1 px-2 text-foreground",children:[e.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":"Back",onClick:m,children:e.jsx(w,{name:"arrow-left",className:"size-5"})}),e.jsx("div",{className:"min-w-0 flex-1 px-2",children:e.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:s})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:o?h?e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[e.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:"Failed to load diff"}),e.jsx("p",{className:"typography-meta text-muted-foreground",children:h}),e.jsx(_,{type:"button",size:"sm",variant:"outline",onClick:n,children:"Retry"})]})}):r?r.isBinary?e.jsx(De,{icon:!0,message:"Content of this file cannot be viewed."}):ha(s)?e.jsx(De,{icon:!0,message:"Image diffs are not available in mobile Changes yet."}):e.jsx(Ps,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:e.jsx(Ts,{original:r.original,modified:r.modified,language:t,fileName:s,renderSideBySide:!1,wrapLines:!0,layout:"inline"})}):e.jsx(De,{loading:!0,message:"Loading diff..."}):e.jsx(De,{icon:!0,message:"File is no longer changed",description:"Go back to Changes and refresh the list."})})]})},Ms=As(()=>Ds(()=>import("./DiffView-CBOrV4hS.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119])).then(s=>({default:s.DiffView}))),Dr=15e3,Lr=40,Pr=20,Ko=({isActive:s,chrome:r="desktop",initialDiffPath:o=null,initialDiffStaged:h=!1,gitHeaderSlot:m=null})=>{const{git:n}=ft(),t=ma(),x=_t(i=>i.currentSessionId),{profiles:d,globalIdentity:y,defaultGitIdentityId:N,loadProfiles:S,loadGlobalIdentity:v,loadDefaultGitIdentityId:p}=Sa(bs(i=>({profiles:i.profiles,globalIdentity:i.globalIdentity,defaultGitIdentityId:i.defaultGitIdentityId,loadProfiles:i.loadProfiles,loadGlobalIdentity:i.loadGlobalIdentity,loadDefaultGitIdentityId:i.loadDefaultGitIdentityId}))),c=fa(t??null),u=pa(t??null),E=ga(t??null),k=xa(t??null),$=ba(t??null),B=ya(t??null),H=ja(t??null),{setActiveDirectory:A,fetchAll:P,ensureAll:M,fetchStatus:z,fetchBranches:G,fetchLog:b,setLogMaxCount:T,fetchIdentity:q,prefetchDiffs:Q,clearDiffCache:U,moveStatusPathsOptimistically:W,restoreStatus:I,bumpIndexRevision:X}=va(bs(i=>({setActiveDirectory:i.setActiveDirectory,fetchAll:i.fetchAll,ensureAll:i.ensureAll,fetchStatus:i.fetchStatus,fetchBranches:i.fetchBranches,fetchLog:i.fetchLog,setLogMaxCount:i.setLogMaxCount,fetchIdentity:i.fetchIdentity,prefetchDiffs:i.prefetchDiffs,clearDiffCache:i.clearDiffCache,moveStatusPathsOptimistically:i.moveStatusPathsOptimistically,restoreStatus:i.restoreStatus,bumpIndexRevision:i.bumpIndexRevision})));a.useRef(null);const re=a.useRef(null),ae=a.useRef(null),Y=a.useRef(null),K=a.useRef(!0);a.useEffect(()=>()=>{K.current=!1},[]);const O=a.useCallback(()=>{re.current!==null&&(window.clearTimeout(re.current),re.current=null)},[]),C=a.useCallback(i=>{O(),re.current=window.setTimeout(()=>{re.current=null,ct(i)===ct(t)&&z(i,n,{silent:!0})},Dr)},[O,t,z,n]);a.useEffect(()=>O,[O]);const F=a.useCallback(()=>{ae.current!==null&&(window.clearTimeout(ae.current),ae.current=null)},[]),l=a.useCallback(()=>{ae.current===null&&(ae.current=window.setTimeout(()=>{ae.current=null,Y.current?.()},0))},[]),D=a.useCallback(async(i,f,g)=>{if(f==="stage"){if(n.stageGitFiles){await n.stageGitFiles(i,g);return}await Promise.all(g.map(j=>n.stageGitFile(i,j)));return}if(n.unstageGitFiles){await n.unstageGitFiles(i,g);return}await Promise.all(g.map(j=>n.unstageGitFile(i,j)))},[n]),V=a.useMemo(()=>Sr({runMutation:({directory:i,direction:f,paths:g})=>D(i,f,g),onMutationComplete:({directory:i})=>{X(i),C(i)},onMutationError:({directory:i,direction:f,rollback:g},j)=>{g?.(),X(i),C(i);const L=f==="stage"?"Failed to stage changes":"Failed to unstage changes";R.error(j instanceof Error?j.message:L)},onPathsComplete:i=>{Zt(f=>{const g=new Set(f);return i.forEach(j=>g.delete(j)),g})},scheduleFlush:l}),[X,D,l,C]);a.useEffect(()=>(Y.current=V.flush,()=>{Y.current=null}),[V]),a.useEffect(()=>()=>V.clear(),[V]),a.useEffect(()=>F,[F]);const se=a.useMemo(()=>t?ir(t):null,[t]),ue=wa(i=>i.settingsGitmojiEnabled),{gitmojis:me}=Ta(ue),[ne,Fe]=a.useState(se?.commitMessage??""),[gt,Oe]=a.useState(!1),Kt=a.useRef(null),[xt,Ye]=a.useState(null),[Vs,bt]=a.useState(!1),[yt,qt]=a.useState(null),[ge,Ws]=a.useState(25),[Ks,Yt]=a.useState(!1),{triggerFireworks:qs}=ka(),Jt=a.useRef(new Map),Je=a.useRef(0),jt=a.useCallback(()=>{Je.current+=1,K.current&&Yt(!0)},[]),vt=a.useCallback(()=>{Je.current=Math.max(0,Je.current-1),K.current&&Je.current===0&&Yt(!1)},[]),[wt,Ze]=a.useState(new Set),[Ys,Zt]=a.useState(new Set),[Nt,Qt]=a.useState(!1),[Xt,Js]=a.useState([]),[Ar,Zs]=a.useState(0),[Qs,es]=a.useState(!1),ts=Ys.size>0||V.size()>0||V.isRunning();a.useCallback(()=>{const i=Kt.current;i&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{i.scrollTo({top:i.scrollHeight,behavior:"smooth"})})})},[]);const{expandedCommitHashes:Xs,commitFilesMap:en,loadingCommitHashes:tn,handleCopyCommitHash:sn,handleToggleCommit:nn}=ur(t,n),{conflictDialogOpen:an,setConflictDialogOpen:xe,conflictFiles:rn,setConflictFiles:be,conflictOperation:Qe,setConflictOperation:ye,persistConflictState:je,clearConflictState:he}=Cr({currentSessionId:x,currentDirectory:t}),[on,Ct]=a.useState([]),[ss,St]=a.useState(null),[ln,ns]=a.useState(null),[cn,kt]=a.useState(null),[dn,Xe]=a.useState([]),[un,Rt]=a.useState(null),[hn,as]=a.useState(!1),[Et,mn]=a.useState(100),[fn,pn]=a.useState(0),[fe,et]=a.useState(null),[gn,Ae]=a.useState(null),[xn,Ft]=a.useState(!1),[zt,rs]=a.useState("merge"),[It,is]=a.useState("");a.useEffect(()=>{t&&or(t,{directory:t,commitMessage:ne})},[ne,t]),a.useEffect(()=>{s&&(S(),v(),p())},[s,S,v,p]),a.useEffect(()=>{if(!s)return;if(!t||!n?.getRemoteUrl){St(null);return}let i=!1;return n.getRemoteUrl(t).then(f=>{i||St(f)}).catch(()=>{i||St(null)}),()=>{i=!0}},[s,t,n]);const tt=a.useCallback(async()=>{if(!t||!n?.getRemotes){Ct([]);return}try{const i=await n.getRemotes(t);K.current&&Ct(i)}catch{K.current&&Ct([])}},[t,n]);a.useEffect(()=>{s&&tt()},[s,tt]),a.useEffect(()=>{s&&t&&(A(t),M(t,n))},[s,t,A,M,n]),a.useEffect(()=>{if(s&&t)return Na.onGitRefreshHint(i=>{ct(i.directory)===ct(t)&&(i.paths?.length&&U(t,i.paths),z(t,n,{silent:!0}))})},[s,U,t,z,n]);const ee=a.useCallback(async(i=!0)=>{if(t)try{await Promise.all([z(t,n),G(t,n)])}catch(f){if(i){const g=f instanceof Error?f.message:"Failed to refresh repository";R.error(g)}}},[t,n,z,G]),ie=a.useCallback(async()=>{t&&await b(t,n,ge)},[t,n,b,ge]),$t=a.useCallback(async()=>{t&&await q(t,n)},[t,n,q]);a.useEffect(()=>{if(!s||!t||!n?.hasLocalIdentity||c!==!0)return;const i=typeof N=="string"?N.trim():"";if(!i||i==="global"||Jt.current.get(t)===i)return;let g=!1;return(async()=>{try{const L=await n.hasLocalIdentity?.(t);if(g||L===!0)return;jt(),await n.setGitIdentity(t,i),Jt.current.set(t,i),await $t()}catch(L){console.warn("Failed to auto-apply default git identity:",L)}finally{g||vt()}})(),()=>{g=!0}},[s,jt,t,N,vt,n,c,$t]);const le=a.useMemo(()=>u?[...u.files??[]].sort((f,g)=>f.path.localeCompare(g.path)):[],[u]),ze=a.useMemo(()=>le.filter(ys),[le]),os=a.useMemo(()=>le.filter(za),[le]);a.useEffect(()=>{if(!t||le.length===0)return;const i=[],f=new Set,g=L=>{!L||f.has(L)||(f.add(L),i.push(L))};if(ze.forEach(L=>g(L.path)),r==="mobile"&&Xt.forEach(g),le.slice(0,Pr).forEach(L=>g(L.path)),i.length===0)return;const j=window.setTimeout(()=>{Q(t,n,i,{maxFiles:Lr})},120);return()=>{window.clearTimeout(j)}},[le,r,t,n,Xt,Q,ze]);const ls=i=>i?.pushed[0]?.remote||u?.tracking?.split("/")[0]||ve.find(f=>f.name==="origin")?.name||ve[0]?.name||"origin",Mt=async(i,f)=>{if(t){Ye(i);try{const g=j=>{const L=`${j.name}/`,J=u?.tracking?.startsWith(L)?u.tracking.slice(L.length):void 0;return{remote:j.name,branch:J,rebase:!0}};if(i==="fetch"){if(!f)throw new Error("No remote available for fetch");await n.gitFetch(t,{remote:f.name}),R.success(`Fetched from ${f.name}`)}else if(i==="pull"){if(!f)throw new Error("No remote available for pull");const j=await n.gitPull(t,g(f));R.success(j.files.length===1?`Pulled ${j.files.length} file from ${f.name}`:`Pulled ${j.files.length} files from ${f.name}`)}else if(i==="push"){const j=await n.gitPush(t);R.success(`Pushed to ${ls(j)}`)}else if(i==="sync"){if(!f)throw new Error("No remote available for sync");let j=0,L=!1;await n.gitFetch(t,{remote:f.name});const J=await n.getGitStatus(t);if((J.behind??0)>0){if((J.files?.length??0)>0){R.error("Commit or stash your changes before syncing");return}j=(await n.gitPull(t,g(f))).files.length}((await n.getGitStatus(t)).ahead??0)>0&&(await n.gitPush(t),L=!0),j>0&&L?R.success(j===1?`Pulled ${j} file from ${f.name} and pushed to upstream`:`Pulled ${j} files from ${f.name} and pushed to upstream`):j>0?R.success(j===1?`Pulled ${j} file from ${f.name}`:`Pulled ${j} files from ${f.name}`):L?R.success(`Pushed to ${f.name}`):R.success("Already up to date")}await ee(!1),await ie()}catch(g){const j=g instanceof Error?g.message:`${i==="sync"?"Sync Changes":i==="pull"?"Pull":i} failed`;R.error(j)}finally{Ye(null)}}},bn=a.useCallback(async(i,f)=>{if(!t)throw new Error("No active directory");const g=await n.getGitFileDiff(t,{path:i,staged:f||void 0});return{original:g.original??"",modified:g.modified??"",isBinary:g.isBinary}},[t,n]),yn=a.useCallback(async i=>{if(!t)return;const f=i.name.trim();if(!f){R.error("Remote name is required");return}if(f==="origin"){R.error("Cannot remove the origin remote");return}ns(f);try{await n.removeRemote(t,{remote:f}),R.success(`Removed remote ${f}`),await Promise.all([ee(!1),tt()])}catch(g){const j=g instanceof Error?g.message:`Failed to remove ${f}`;R.error(j)}finally{ns(null)}},[t,n,tt,ee]),Dt=async(i={})=>{if(!t)return;if(!ne.trim()){R.error("Enter a commit message");return}const f=ze.map(j=>j.path).sort();if(f.length===0){R.error("Stage at least one file to commit");return}const g=i.pushAfter?"commitAndPush":"commit";qt(g);try{if(await n.createGitCommit(t,ne.trim(),{files:f,stageFiles:[]}),X(t),R.success("Commit created"),Fe(""),await ee(),i.pushAfter){const j=u?.tracking?.split("/")[0],L=ve.find(Jn=>Jn.name===j)??ve[0];if(!L)throw new Error("No remote available");Ye("sync");const J=`${L.name}/`,oe=u?.tracking?.startsWith(J)?u.tracking.slice(J.length):void 0;await n.gitFetch(t,{remote:L.name});const Z=await n.getGitStatus(t);if((Z.behind??0)>0){if((Z.files?.length??0)>0){R.error("Commit or stash your changes before syncing"),await ee(!1);return}await n.gitPull(t,{remote:L.name,branch:oe,rebase:!0})}const de=await n.getGitStatus(t);let Te;(de.ahead??0)>0&&(Te=await n.gitPush(t)),R.success(`Pushed to ${ls(Te)}`),r!=="mobile"&&qs(),await ee(!1)}else await ee(!1);await ie(),Zs(j=>j+1)}catch(j){const L=j instanceof Error?j.message:"Failed to create commit";R.error(L)}finally{qt(null),i.pushAfter&&Ye(null)}},jn=async(i,f)=>{if(!t||!u)return;const g=u.current??null,j=f?.name??"origin";try{await n.createBranch(t,i,g??"HEAD"),R.success(`Created branch ${i}`),await n.checkoutBranch(t,i);let L=!1;try{await n.gitPush(t,{remote:j,branch:i,options:["--set-upstream"]}),L=!0}catch(J){const oe=J instanceof Error?J.message:`Unable to push new branch to ${j}.`;R.warning("Branch created locally, but failed to set upstream.",{description:e.jsxs("span",{className:"text-foreground/80 dark:text-foreground/70",children:["Upstream setup failed: ",oe]})})}await ee(),await ie(),L&&R.success(`Set upstream for ${i} to ${j}`)}catch(L){const J=L instanceof Error?L.message:"Failed to create branch";throw R.error(J),L}},vn=async(i,f)=>{if(t)try{await n.renameBranch(t,i,f),R.success(`Renamed ${i} to ${f}`),await ee(),await ie()}catch(g){const j=g instanceof Error?g.message:`Failed to rename ${i} to ${f}`;R.error(j)}},wn=async i=>{if(!t)return;const f=i.replace(/^remotes\//,"");if(u?.current!==f)try{await n.checkoutBranch(t,f),R.success(`Checked out ${f}`),await ee(),await ie()}catch(g){const j=g instanceof Error?g.message:`Failed to checkout ${f}`;R.error(j)}},Nn=async i=>{if(t){jt();try{await n.setGitIdentity(t,i.id),R.success(`Applied identity: ${i.name}`),await $t()}catch(f){const g=f instanceof Error?f.message:"Failed to apply identity";R.error(g)}finally{vt()}}},{localBranches:cs,remoteBranches:st,effectiveRemotes:ve,currentBranch:Pe,baseBranch:_e,branchScopeAvailable:nt,updateTargetBranch:Cn}=yr({branches:E,status:u,remotes:on,remoteUrl:ss,git:n}),{availableIdentities:Sn,activeIdentityProfile:kn}=Nr({profiles:d,globalIdentity:y,currentIdentity:$,remoteUrl:ss}),ds=ze.length,Rn=B||xt!==null||yt!==null,us=!!Pe;a.useEffect(()=>{if(!t||!n||!k?.all?.length||!Pe||!_e||Pe===_e){Ae(null);return}let i=!1;return(async()=>{try{const g=await n.getGitLog(t,{from:_e,to:"HEAD",maxCount:ge});if(i)return;const j=new Set((g?.all??[]).map(J=>J.hash).filter(J=>typeof J=="string"&&J.length>0));if(j.size===0){Ae(null);return}const L=k.all.findIndex(J=>!j.has(J.hash));if(L===0){Ae(null);return}if(L===-1){Ae({insertBeforeIndex:k.all.length,branchName:Pe,direction:"up"});return}Ae({insertBeforeIndex:L,branchName:Pe,direction:"up"})}catch{i||Ae(null)}})(),()=>{i=!0}},[_e,Pe,t,n,k,ge]),a.useEffect(()=>{Rt(null)},[t]),a.useEffect(()=>{if(fe!=="graph"||!t){fe!=="graph"&&Rt(null);return}let i=!1;return as(!0),n.getGitLog(t,{maxCount:Et,all:!0}).then(f=>{i||Rt(f)}).catch(f=>{console.error("Failed to fetch graph log:",f)}).finally(()=>{i||as(!1)}),()=>{i=!0}},[fe,t,Et,fn,n]);const En=a.useCallback((i,f)=>{if(!t||i.length===0)return;const g=Array.from(new Set(i));Zt(L=>{const J=new Set(L);return g.forEach(oe=>J.add(oe)),J});const j=W(t,g,f);V.enqueue({directory:t,direction:f,paths:new Set(g),rollback:()=>I(t,j)}),l()},[t,V,W,I,l]),Fn=a.useCallback(async i=>{if(t){Ze(f=>{const g=new Set(f);return g.add(i),g});try{await n.revertGitFile(t,i,{scope:"working"}),R.success(`Reverted ${i}`),await ee(!1)}catch(f){const g=f instanceof Error?f.message:"Failed to revert changes";R.error(g)}finally{Ze(f=>{const g=new Set(f);return g.delete(i),g})}}},[t,ee,n]),at=a.useCallback(async(i,f,g="all")=>{if(!t||i.length===0)return;const j=Array.from(new Set(i));if(Nt||j.some(Z=>wt.has(Z)))return;const L=new Set(ze.map(Z=>Z.path)),J=g==="all"&&j.some(Z=>L.has(Z));f&&Qt(!0),Ze(Z=>{const de=new Set(Z);return j.forEach(Te=>de.add(Te)),de});const oe=[];try{if(await Promise.all(j.map(async Z=>{try{await n.revertGitFile(t,Z,{scope:g})}catch(de){oe.push({path:Z,message:de instanceof Error?de.message:"Failed to revert changes"})}})),J&&oe.length<j.length&&X(t),await ee(!1),oe.length===0)R.success(j.length===1?`Reverted ${j.length} file`:`Reverted ${j.length} files`);else if(oe.length===j.length)R.error(oe[0]?.message||"Failed to revert changes");else{const Z=j.length-oe.length;R.warning(Z===1?`Reverted ${Z} file, ${oe.length} failed`:`Reverted ${Z} files, ${oe.length} failed`)}}finally{Ze(Z=>{const de=new Set(Z);return j.forEach(Te=>de.delete(Te)),de}),f&&Qt(!1)}},[X,t,n,Nt,ee,wt,ze]),zn=a.useCallback(async i=>{await at(i,!0)},[at]);a.useCallback(async i=>{await at(i,!1,"working")},[at]);const In=a.useCallback(()=>bt(!0),[]),$n=a.useCallback((i,f)=>{const g=f||i;Fe(j=>{const L=j.trimStart();return L.startsWith(i)||f&&L.startsWith(f)?j:`${g.endsWith(" ")?g:`${g} `}${j}`.trimStart()}),Oe(!1)},[]),rt=a.useCallback(i=>{const f=i instanceof Error?i.message.toLowerCase():"";return f.includes("uncommitted changes")||f.includes("local changes")||f.includes("your local changes would be overwritten")||f.includes("please commit your changes or stash them")||f.includes("cannot rebase: you have unstaged changes")||f.includes("error: cannot pull with rebase")},[]),Ie=a.useCallback((i,f)=>{Xe(g=>[...g,{message:i,status:f,timestamp:Date.now()}])},[]),ce=a.useCallback((i,f)=>{Xe(g=>{if(g.length===0)return g;const j=[...g];return j[j.length-1]={...j[j.length-1],status:i,...f?{message:f}:{}},j})},[]),it=a.useCallback(()=>{Xe([])},[]),Mn=a.useCallback(()=>{Xe([]),kt(null)},[]),ot=a.useCallback(i=>{const f=i.trim(),g=new Set(ve.map(L=>L.name)),j=f.indexOf("/");if(j>0){const L=f.slice(0,j),J=f.slice(j+1);if(g.has(L)&&J)return{branch:f,remote:L,remoteBranch:J}}for(const L of ve){const J=`${L.name}/${f}`;if(st.includes(J))return{branch:J,remote:L.name,remoteBranch:f}}return{branch:f,remote:null,remoteBranch:null}},[ve,st]),Dn=a.useCallback(async i=>{if(!t)return;kt("merge"),it();const f=u?.current,g=ot(i);try{g.remote&&g.remoteBranch&&(Ie(`Fetching ${g.remote}/${g.remoteBranch}...`,"running"),await n.gitFetch(t,{remote:g.remote,branch:g.remoteBranch}),ce("done",`Fetched ${g.remote}/${g.remoteBranch}`)),Ie(`Merging ${g.branch} into ${f}...`,"running");const j=await n.merge(t,{branch:g.branch});j.conflict?(ce("error","Merge conflicts detected"),be(j.conflictFiles??[]),ye("merge"),xe(!0),je(t,j.conflictFiles??[],"merge")):(ce("done",`Merged ${g.branch} into ${f}`),he(),Ie("Refreshing repository status...","running"),await ee(),await ie(),ce("done","Repository status updated"))}catch(j){if(rt(j))ce("error","Uncommitted changes detected"),rs("merge"),is(g.branch),Ft(!0);else{const L=j instanceof Error?j.message:`Failed to merge ${g.branch}`;ce("error",L)}}},[t,n,u,ot,ee,ie,rt,je,he,Ie,ce,it]),Ln=a.useCallback(async i=>{if(!t)return;kt("rebase"),it();const f=u?.current,g=ot(i);try{g.remote&&g.remoteBranch&&(Ie(`Fetching ${g.remote}/${g.remoteBranch}...`,"running"),await n.gitFetch(t,{remote:g.remote,branch:g.remoteBranch}),ce("done",`Fetched ${g.remote}/${g.remoteBranch}`)),Ie(`Rebasing ${f} onto ${g.branch}...`,"running");const j=await n.rebase(t,{onto:g.branch});j.conflict?(ce("error","Rebase conflicts detected"),be(j.conflictFiles??[]),ye("rebase"),xe(!0),je(t,j.conflictFiles??[],"rebase")):(ce("done",`Rebased ${f} onto ${g.branch}`),he(),Ie("Refreshing repository status...","running"),await ee(),await ie(),ce("done","Repository status updated"))}catch(j){if(rt(j))ce("error","Uncommitted changes detected"),rs("rebase"),is(g.branch),Ft(!0);else{const L=j instanceof Error?j.message:`Failed to rebase onto ${g.branch}`;ce("error",L)}}},[t,n,u,ot,ee,ie,rt,je,he,Ie,ce,it]),Pn=a.useCallback(async()=>{if(t)try{Qe==="merge"?(await n.abortMerge(t),R.success("Merge aborted")):(await n.abortRebase(t),R.success("Rebase aborted")),he(),await ee(),await ie()}catch(i){const f=i instanceof Error?i.message:`Failed to abort ${Qe}`;R.error(f)}},[t,n,Qe,ee,ie,he]),An=a.useMemo(()=>u?.files?u.files.filter(i=>i.index==="U"||i.working_dir==="U"||i.index==="A"&&i.working_dir==="A"||i.index==="D"&&i.working_dir==="D").length:0,[u?.files]),Tn=a.useCallback(async()=>{if(t)try{const i=!!u?.mergeInProgress?.head,f=!!(u?.rebaseInProgress?.headName||u?.rebaseInProgress?.onto);if(i){const g=await n.continueMerge(t);g.conflict?(be(g.conflictFiles??[]),ye("merge"),xe(!0),je(t,g.conflictFiles??[],"merge"),R.error("Merge conflicts detected")):(he(),R.success("Merge completed"),await ee(),await ie())}else if(f){const g=await n.continueRebase(t);g.conflict?(be(g.conflictFiles??[]),ye("rebase"),xe(!0),je(t,g.conflictFiles??[],"rebase"),R.error("Rebase conflicts detected")):(he(),R.success("Rebase step completed"),await ee(),await ie())}}catch(i){const f=i instanceof Error?i.message:"Failed to continue operation";R.error(f)}},[t,n,u,ee,ie,je,he]),Bn=a.useCallback(async()=>{if(t)try{!!u?.mergeInProgress?.head?(await n.abortMerge(t),R.success("Merge aborted")):(await n.abortRebase(t),R.success("Rebase aborted")),he(),await ee(),await ie()}catch(i){const f=i instanceof Error?i.message:"Failed to abort operation";R.error(f)}},[t,n,u,ee,ie,he]),Gn=a.useCallback(()=>{if(!t)return;const f=!!u?.mergeInProgress?.head?"merge":"rebase",g=u?.files?.filter(j=>j.index==="U"||j.working_dir==="U").map(j=>j.path)??[];g.length>0&&be(g),ye(f),xe(!0)},[t,u]),On=a.useCallback(async i=>{if(!t)return;const f=u?.current,g=zt,j=It,L=(u?.files??[]).some(ys);try{await n.stash(t,{message:`Auto-stash before ${g} with ${j}`,includeUntracked:!0}),L&&X(t)}catch(Z){const de=Z instanceof Error?Z.message:"Failed to stash changes";R.error(de);return}let J=!1,oe=!1;try{if(g==="merge"){const Z=await n.merge(t,{branch:j});Z.conflict?(oe=!0,be(Z.conflictFiles??[]),ye("merge"),xe(!0)):(J=!0,R.success(`Merged ${j} into ${f||""}`))}else{const Z=await n.rebase(t,{onto:j});Z.conflict?(oe=!0,be(Z.conflictFiles??[]),ye("rebase"),xe(!0)):(J=!0,R.success(`Rebased ${f||""} onto ${j}`))}if(i&&J)try{await n.stashPop(t),X(t),R.success("Stashed changes restored")}catch(Z){const de=Z instanceof Error?Z.message:"Failed to restore stash";R.error(de)}else i&&oe&&R.info("Stash restored manually required");await ee(),await ie()}catch(Z){if(i)try{await n.stashPop(t),X(t)}catch{}throw Z}},[X,t,n,u,zt,It,ee,ie]),_n=a.useCallback(i=>{Ws(i),t&&(T(t,i),b(t,n,i))},[t,b,n,T]),Hn=a.useCallback(i=>{mn(i)},[]),Un=a.useCallback(()=>{et(null),t&&(z(t,n),G(t,n),b(t,n,ge))},[t,z,G,b,ge,n]),Vn=a.useCallback(i=>{if(i.conflict){if(i.operation==="cherry-pick"||i.operation==="revert"){R.error("Conflict",{description:`Conflicts in: ${i.conflictFiles?.join(", ")??"unknown files"}. Resolve manually and commit, or abort with git cherry-pick/revert --abort.`}),t&&(z(t,n),G(t,n),b(t,n,ge));return}be(i.conflictFiles??[]),ye(i.operation),xe(!0),t&&je(t,i.conflictFiles??[],i.operation)}},[be,ye,xe,je,t,z,G,b,ge,n]),[hs,ms]=a.useState(()=>le.length>0?"all":"branch"),[Wn,Kn]=a.useState(null),lt=`${t??""}:${le.length>0?"nonempty":"empty"}`,fs=a.useRef(lt);a.useEffect(()=>{fs.current!==lt&&(fs.current=lt,ms(le.length>0?"all":"branch"))},[le.length,lt]);const ps=a.useCallback(i=>{ms(i)},[]),qn=a.useCallback(i=>{Kn(i)},[]),Lt=c===!0&&u?e.jsx(Ha,{status:u,localBranches:cs,remoteBranches:st,branchInfo:E?.branches,syncAction:xt,remotes:ve,onFetch:i=>Mt("fetch",i),onSync:i=>Mt("sync",i),onRemoveRemote:yn,removingRemoteName:ln,onCheckoutBranch:wn,onCreateBranch:jn,onRenameBranch:vn,activeIdentityProfile:kn,availableIdentities:Sn,onSelectIdentity:Nn,isApplyingIdentity:Ks,isWorktreeMode:!1,upstreamTarget:u.upstreamComparison?`${u.upstreamComparison.remote}/${u.upstreamComparison.branch}`:null,onOpenHistory:()=>et("history"),onOpenGraph:()=>et("graph"),onOpenStashes:In,onOpenUpdateBranch:us?()=>es(!0):void 0,diffScope:hs,onDiffScopeChange:ps,allCount:le.length,workingCount:os.length,stagedCount:ds,branchAvailable:nt,diffHeaderState:Wn}):null,Yn=Lt?m?Zn.createPortal(e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:Lt}),m):e.jsx("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b border-border px-2",children:Lt}):null;return r==="mobile"?e.jsx($r,{currentDirectory:t??null,status:u,isGitRepo:c,isLoadingStatus:B,changeEntries:le,stagedChangeEntries:ze,unstagedChangeEntries:os,effectiveRemotes:ve,syncAction:xt,commitAction:yt,commitMessage:ne,hasPendingIndexMutation:ts,revertingPaths:wt,isRevertingAll:Nt,initialDiffPath:o,initialDiffStaged:h,onSyncAction:(i,f)=>{Mt(i,f)},onMoveChangePaths:En,onRevertFile:i=>{Fn(i)},onRevertAll:zn,onCommitMessageChange:Fe,onCommit:i=>{Dt(i)},onVisiblePathsChange:Js,loadDiff:bn}):t?c===null||c===!0&&!u?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"typography-ui-label",children:"Checking repository..."})]})}):c===!1?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(a.Suspense,{fallback:null,children:e.jsx(Ms,{diffScope:"turn",hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,flushContent:!0,toolbarSlot:m})})}):e.jsxs("div",{className:te("flex h-full flex-col overflow-hidden"),children:[Yn,t&&(u?.mergeInProgress?.head||u?.rebaseInProgress?.headName||u?.rebaseInProgress?.onto)&&e.jsx(dr,{mergeInProgress:u?.mergeInProgress,rebaseInProgress:u?.rebaseInProgress,onContinue:Tn,onAbort:Bn,onResolveWithAI:Gn,conflictCount:An,isLoading:B}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx("div",{className:"flex h-full min-h-0 flex-col",children:(le?.length??0)>0||nt?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:null,children:e.jsx(Ms,{diffScope:hs,onDiffScopeChange:ps,branchBase:nt?_e:null,branchHead:nt?Pe:null,showOpenInEditorAction:!0,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,flushContent:!0,hideToolbar:!0,onHeaderControlsStateChange:qn})})}),le.length>0?e.jsx("div",{ref:Kt,className:"shrink-0 px-4 pb-4 pt-2",children:e.jsx(Hs,{stagedCount:ds,commitMessage:ne,onCommitMessageChange:Fe,onCommit:()=>Dt({pushAfter:!1}),onCommitAndPush:()=>Dt({pushAfter:!0}),commitAction:yt,hasPendingIndexMutation:ts,gitmojiEnabled:ue,onOpenGitmojiPicker:()=>Oe(!0)})}):null]}):e.jsx(cr,{onOpenStashes:()=>bt(!0)})})}),e.jsx(ar,{currentDirectory:t,isUpdateBranchDialogOpen:Qs,setIsUpdateBranchDialogOpen:es,branchOperation:cn,currentBranch:u?.current,localBranches:cs,remoteBranches:st,updateTargetBranch:Cn,onMerge:Dn,onRebase:Ln,isBusy:Rn,operationLogs:dn,onOperationComplete:Mn,canShowBranchWorkflows:us,gitLogDialogMode:fe,setGitLogDialogMode:et,onRefreshHistory:()=>{if(fe==="graph"){pn(i=>i+1);return}t&&b(t,n,ge)},isLogRefreshing:fe==="graph"?hn:H,log:fe==="graph"?un??k:k,maxCount:fe==="graph"?Et:ge,onMaxCountChange:fe==="graph"?Hn:_n,expandedCommitHashes:Xs,onToggleCommit:nn,commitFilesMap:en,loadingCommitHashes:tn,onCopyHash:sn,historyBranchDivider:gn,onConflict:fe==="graph"?Vn:void 0,onActionSuccess:fe==="graph"?Un:void 0,isStashesDialogOpen:Vs,setIsStashesDialogOpen:bt,hasUncommittedChanges:(u?.files?.length??0)>0,hasStagedChanges:ze.length>0,uncommittedFileCount:u?.files?.length??0,onStashesChanged:async i=>{t&&i?.affectsIndex&&X(t),await ee(!1),await ie()},isGitmojiPickerOpen:gt,setIsGitmojiPickerOpen:Oe,gitmojiEmojis:me,onSelectGitmoji:$n,conflictDialogOpen:an,setConflictDialogOpen:xe,conflictFiles:rn,conflictOperation:Qe,onAbortConflict:Pn,onClearConflictState:he,stashDialogOpen:xn,setStashDialogOpen:Ft,stashDialogOperation:zt,stashDialogBranch:It,onConfirmStashAndRetry:On})]}):e.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center",children:e.jsx("p",{className:"typography-ui-label text-muted-foreground",children:"Select a session or directory to view Git status"})})};export{Ko as GitView};
@@ -1,12 +0,0 @@
1
- import{R as y,j as _}from"./vendor-react-B5Z1Mdn3.js";import{m as Ke}from"./vendor-morphdom-B7dS_VPB.js";import{r as Ue,a as Ze}from"./vendor-beautiful-mermaid-DneUawHp.js";import{b as Xe,A as Ge,u as T,r as Ye,B as te,C as Je,c as X,g as re}from"./index-KIdiBFJs.js";import{at as ve,au as Qe,av as et,A as H,aw as tt,ax as rt,ay as nt,az as ot,aA as at,aB as ne,aC as it,aD as st,aE as lt,j as ke,aF as Ce,aG as Ee,aH as ct,i as dt}from"./useAppFontEffects-C4JL1x7k.js";import{r as mt,s as ut,i as pt,a as ft,b as ht}from"./markdownCore-DUjQU2i0.js";import{r as gt}from"./registerCustomTheme-DmolaWWZ.js";import{i as bt}from"./runtimeSurface-CySRuLbN.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-elkjs-mzfkf0ML.js";import"./vendor-entities-C3BA0AJP.js";import"./vendor-zustand-GVb4H8HE.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-base-ui-vkqQ2P9o.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-BZOGXAGe.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-D0AXkdQC.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-sonner-BDtm25td.js";import"./vendor-codemirror-view-Ct4T37Ue.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-dnd-kit-core-C9qcAm_1.js";import"./vendor-dnd-kit-utilities-DTY1C6ST.js";import"./vendor-dnd-kit-accessibility-DZKKhs9S.js";import"./vendor-dnd-kit-sortable-D8ozj8M-.js";import"./vendor-cmdk-zXx6sGnS.js";import"./vendor-radix-ui-react-dialog-D2yhEu2p.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-8xy6TJML.js";import"./vendor-radix-ui-react-context-CFsX-AUC.js";import"./vendor-radix-ui-react-id-D2kS9K1j.js";import"./vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js";import"./vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js";import"./vendor-radix-ui-react-dismissable-layer-DrorBNg9.js";import"./vendor-radix-ui-react-primitive-DkH8dMOR.js";import"./vendor-radix-ui-react-slot-BIDFZX0-.js";import"./vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js";import"./vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js";import"./vendor-radix-ui-react-focus-scope-D2BkImwt.js";import"./vendor-radix-ui-react-portal-YgCRIyi7.js";import"./vendor-radix-ui-react-presence-D432pCMB.js";import"./vendor-radix-ui-react-focus-guards-BfdFmL7c.js";import"./vendor-react-remove-scroll-vR1dy1aP.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-CSAHp1YF.js";import"./vendor-react-style-singleton-Ctw6HnYx.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-Vv4V8Nd1.js";import"./vendor-use-callback-ref-CVVuCyLj.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BByA_dGF.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-DuOEwJ3f.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-wd6iRebq.js";import"./vendor-codemirror-lang-json-CZ07HmNC.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-djiuoTi8.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CKHqhW5R.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-DtcZDGqe.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-C493X_9w.js";import"./vendor-codemirror-lang-python-DzzokVau.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-DYppkHEk.js";import"./vendor-tanstack-react-virtual-2skouoFw.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CfplGuM0.js";import"./vendor-motion-dom-DhJ-sYS5.js";import"./vendor-motion-utils-CKEGc_YG.js";import"./vendor-marked-CX41MkDF.js";import"./vendor-dompurify-r8glNMJW.js";import"./vendor-remend-BWYYytN3.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";const Le="pichamber-md",wt={name:Le,colors:{"editor.background":"transparent","editor.foreground":"var(--md-syntax-foreground)"},tokenColors:[{scope:["comment","punctuation.definition.comment","string.comment"],settings:{foreground:"var(--md-syntax-comment)",fontStyle:"italic"}},{scope:["string","punctuation.definition.string","string.template"],settings:{foreground:"var(--md-syntax-string)"}},{scope:["constant.numeric","constant.language","constant.character","constant"],settings:{foreground:"var(--md-syntax-number)"}},{scope:["keyword","storage","storage.type","storage.modifier","keyword.control"],settings:{foreground:"var(--md-syntax-keyword)"}},{scope:["keyword.operator","punctuation.separator","punctuation.terminator"],settings:{foreground:"var(--md-syntax-operator)"}},{scope:["entity.name.function","support.function","meta.function-call"],settings:{foreground:"var(--md-syntax-function)"}},{scope:["entity.name.type","entity.name.class","support.type","support.class","entity.other.inherited-class"],settings:{foreground:"var(--md-syntax-type)"}},{scope:["variable","variable.other","variable.parameter","meta.definition.variable"],settings:{foreground:"var(--md-syntax-variable)"}},{scope:["variable.other.property","meta.property-name","support.type.property-name"],settings:{foreground:"var(--md-syntax-property)"}},{scope:["entity.name.tag","punctuation.definition.tag"],settings:{foreground:"var(--md-syntax-keyword)"}},{scope:["entity.other.attribute-name"],settings:{foreground:"var(--md-syntax-property)"}},{scope:["markup.bold","punctuation.definition.bold"],settings:{fontStyle:"bold"}},{scope:["markup.italic","punctuation.definition.italic"],settings:{fontStyle:"italic"}},{scope:["markup.heading","markup.heading entity.name"],settings:{foreground:"var(--md-syntax-keyword)",fontStyle:"bold"}},{scope:["markup.inserted","punctuation.definition.inserted"],settings:{foreground:"var(--md-syntax-inserted)"}},{scope:["markup.deleted","punctuation.definition.deleted"],settings:{foreground:"var(--md-syntax-deleted)"}},{scope:["invalid","invalid.illegal"],settings:{foreground:"var(--md-syntax-deleted)"}}]};let oe=!1;const yt=()=>{oe||(oe=!0,gt(Le,()=>Promise.resolve(wt)))},k=t=>Number.isFinite(t)&&t>0,ae=t=>{if(typeof t=="number")return k(t)?t:null;if(typeof t!="string")return null;const e=t.trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!e)return null;const n=Number(e[1]);return k(n)?n:null},j=(t,e,n)=>Math.min(n,Math.max(e,t)),At=6,ie=1.25,vt=1.0015,kt=.5,Ct=12,se=3,Et=400,F='[data-markdown="mermaid-block"]',S=t=>t.querySelector(F)!==null,Lt=t=>[t.x,t.y,t.width,t.height].map(e=>{const n=Number(e.toFixed(At));return Object.is(n,-0)?"0":String(n)}).join(" "),St=t=>{const e=t.viewBox?.trim().split(/[\s,]+/).map(s=>Number.parseFloat(s));if(e?.length===4){const[s,o,a,i]=e;if(Number.isFinite(s)&&Number.isFinite(o)&&k(a)&&k(i))return{x:s,y:o,width:a,height:i}}const n=ae(t.width),r=ae(t.height);return n===null||r===null?null:{x:0,y:0,width:n,height:r}},Mt=t=>{let e=2166136261;for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return(e>>>0).toString(36)},Nt=t=>{const e=t.renderMode||"unknown",n=t.svgMarkup??"";if(!n){const r=[t.viewBox??"",t.width??"",t.height??""];return r.some(s=>s!=="")?`${e}:bounds:${r.join(":")}`:`${e}:no-svg`}return[e,Mt(n)].join(":")},Se=(t,e)=>{if(!k(e.width)||!k(e.height))return t;const n=t.width/t.height,r=e.width/e.height;if(n>r){const o=t.width/r;return{x:t.x,y:t.y-(o-t.height)/2,width:t.width,height:o}}const s=t.height*r;return{x:t.x-(s-t.width)/2,y:t.y,width:s,height:t.height}},xt=({currentBox:t,viewport:e,delta:n})=>!k(e.width)||!k(e.height)||!k(t.width)||!k(t.height)?t:{x:t.x-n.x/e.width*t.width,y:t.y-n.y/e.height*t.height,width:t.width,height:t.height},Tt=(t,e)=>{const n=e.x-t.x,r=e.y-t.y;return n*n+r*r>se*se},Pt=({currentBox:t,contentBox:e,viewport:n,pointer:r,zoomFactor:s,minScale:o,maxScale:a})=>{if(!k(n.width)||!k(n.height)||!k(s)||!k(t.width)||!k(t.height)||!k(e.width)||!k(e.height)||!k(o)||!k(a))return t;const i=Math.min(o,a),l=Math.max(o,a),d=Se(e,n),c=d.width/t.width,p=j(c*s,i,l),u=d.width/p,f=u/(t.width/t.height),h=j(r.x/n.width,0,1),A=j(r.y/n.height,0,1),v=t.x+h*t.width,w=t.y+A*t.height;return{x:v-h*u,y:w-A*f,width:u,height:f}},G=new WeakMap,Rt=t=>t instanceof HTMLElement?G.get(t)??null:null,It=t=>t.querySelector('[data-markdown="mermaid-viewport"]')??t.querySelector('[data-markdown="mermaid"]'),le=t=>{const e=t.querySelector('[data-markdown="mermaid"] svg'),n=t.querySelector('[data-markdown="mermaid"]');return Nt({renderMode:t.getAttribute("data-mermaid-render"),svgMarkup:n?.getAttribute("data-md-original-svg")??e?.outerHTML??null,viewBox:e?.getAttribute("viewBox"),width:e?.getAttribute("width"),height:e?.getAttribute("height")})},I=t=>{const e=t.getBoundingClientRect();return{width:e.width,height:e.height}},_t=(t,e)=>{const n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}},Ft=t=>t instanceof Element&&!!t.closest('button, a, [role="button"]'),Ot=t=>{const e=It(t),n=t.querySelector('[data-markdown="mermaid"] svg');if(!e||!n)return null;const r=St({viewBox:n.getAttribute("viewBox"),width:n.getAttribute("width"),height:n.getAttribute("height")});if(!r)return null;let s=r,o=null,a=null,i=null,l=null;const d=m=>{s=m,n.setAttribute("viewBox",Lt(m)),n.removeAttribute("width"),n.removeAttribute("height")},c=()=>{d(Se(r,I(e)))},p=(m,C)=>{d(Pt({currentBox:s,contentBox:r,viewport:I(e),pointer:m,zoomFactor:C,minScale:kt,maxScale:Ct}))},u=()=>{const m=I(e);p({x:m.width/2,y:m.height/2},ie)},f=()=>{const m=I(e);p({x:m.width/2,y:m.height/2},1/ie)},h=m=>{!m.ctrlKey&&!m.metaKey||(m.preventDefault(),m.stopPropagation(),p(_t(m,e),Math.pow(vt,-m.deltaY)))},A=m=>{m.button!==0||Ft(m.target)||(o=m.pointerId,a={x:m.clientX,y:m.clientY},i=a,l!==null&&(window.clearTimeout(l),l=null),t.removeAttribute("data-mermaid-suppress-click"),e.setPointerCapture?.(m.pointerId),t.setAttribute("data-mermaid-panning","true"),m.preventDefault())},v=m=>{if(o!==m.pointerId||!i)return;const C={x:m.clientX,y:m.clientY};d(xt({currentBox:s,viewport:I(e),delta:{x:C.x-i.x,y:C.y-i.y}})),i=C,a&&Tt(a,C)&&t.setAttribute("data-mermaid-suppress-click","true"),m.preventDefault()},w=m=>{o===m.pointerId&&(e.releasePointerCapture?.(m.pointerId),o=null,a=null,i=null,t.removeAttribute("data-mermaid-panning"),t.hasAttribute("data-mermaid-suppress-click")&&(l=window.setTimeout(()=>{t.removeAttribute("data-mermaid-suppress-click"),l=null},Et)))},g=()=>{c()};e.addEventListener("wheel",h,{passive:!1}),e.addEventListener("pointerdown",A),e.addEventListener("pointermove",v),e.addEventListener("pointerup",w),e.addEventListener("pointercancel",w),window.addEventListener("resize",g);const b=typeof ResizeObserver>"u"?null:new ResizeObserver(g);return b?.observe(e),c(),{zoomIn:u,zoomOut:f,fit:c,cleanup:()=>{e.removeEventListener("wheel",h),e.removeEventListener("pointerdown",A),e.removeEventListener("pointermove",v),e.removeEventListener("pointerup",w),e.removeEventListener("pointercancel",w),window.removeEventListener("resize",g),b?.disconnect(),l!==null&&window.clearTimeout(l),t.removeAttribute("data-mermaid-panning"),t.removeAttribute("data-mermaid-suppress-click"),G.delete(t)}}},Dt=t=>{const e=new Map,n=new Map,r=()=>{for(const[o,a]of Array.from(e.entries())){const i=le(o);(!t.contains(o)||i!==n.get(o))&&(a.cleanup(),e.delete(o),n.delete(o))}for(const o of Array.from(t.querySelectorAll(F))){if(e.has(o)||o.querySelector('[data-markdown="mermaid"] svg')===null)continue;const a=Ot(o);a&&(e.set(o,a),n.set(o,le(o)),G.set(o,a))}},s=()=>{for(const o of e.values())o.cleanup();e.clear(),n.clear()};return r(),{refresh:r,cleanup:s}},M=t=>`<svg class="remixicon size-3.5" viewBox="0 0 24 24" aria-hidden="true"><use href="#oc-${t}"></use></svg>`,q={copy:M("file-copy"),check:M("check"),download:M("download"),zoomIn:M("add"),zoomOut:M("subtract"),fit:M("refresh"),textWrap:M("text-wrap")},Me="p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--interactive-focus-ring)]",B=(t,e)=>{t.innerHTML=e},L=(t,e,n)=>{const r=document.createElement("button");return r.type="button",r.className=Me,r.setAttribute("data-md-action",n),r.setAttribute("title",e),r.setAttribute("aria-label",e),B(r,q[t]),r},Ne=(t,e,n)=>{const r=t.querySelector("[data-md-code-body]"),s=t.querySelector("pre"),o=t.querySelector("pre code"),a=t.querySelectorAll("[data-md-code-line-content]"),i=t.querySelector('[data-md-action="toggle-code-wrap"]');t.setAttribute("data-code-wrap",e?"true":"false"),r?.classList.toggle("overflow-x-auto",!e),r?.classList.toggle("overflow-x-hidden",e),s?.classList.toggle("whitespace-pre-wrap",e),s?.classList.toggle("break-words",e),o?.classList.toggle("whitespace-pre-wrap",e),o?.classList.toggle("break-words",e),s&&(s.style.whiteSpace=e?"pre-wrap":"pre",s.style.overflowWrap=e?"anywhere":"normal"),o&&(o.style.whiteSpace=e?"pre-wrap":"pre",o.style.overflowWrap=e?"anywhere":"normal");for(const l of Array.from(a))l.style.whiteSpace=e?"pre-wrap":"pre",l.style.overflowWrap=e?"anywhere":"normal";if(i){const l=e?n.disableCodeWrap:n.enableCodeWrap;i.setAttribute("title",l),i.setAttribute("aria-label",l),i.classList.toggle("text-foreground",e),i.classList.toggle("opacity-100",e),i.classList.toggle("text-muted-foreground",!e),i.classList.toggle("opacity-65",!e),i.setAttribute("aria-pressed",e?"true":"false")}},xe=t=>{const e=t.querySelector(":scope > code");if(!e||e.hasAttribute("data-md-code-lines"))return;const n=e.textContent??"",r=n.endsWith(`
2
- `),s=r?n.slice(0,-1).split(`
3
- `):n.split(`
4
- `),o=s.length>0?s:[""],a=Array.from(e.children).filter(d=>d.classList.contains("line"));r&&a.length===o.length+1&&a.at(-1)?.textContent===""&&a.pop();const i=a.length===o.length,l=document.createDocumentFragment();o.forEach((d,c)=>{const p=document.createElement("span");p.setAttribute("data-md-code-line","");const u=document.createElement("span");u.setAttribute("data-md-code-line-number",""),u.setAttribute("aria-hidden","true"),u.textContent=String(c+1);const f=document.createElement("span");if(f.setAttribute("data-md-code-line-content",""),i){const h=a[c];h&&f.append(...Array.from(h.childNodes))}else f.textContent=d;if(p.append(u,f),l.appendChild(p),c<o.length-1||r){const h=document.createElement("span");h.setAttribute("data-md-code-line-break",""),h.textContent=`
5
- `,l.appendChild(h)}}),e.replaceChildren(l),e.setAttribute("data-md-code-lines",""),e.toggleAttribute("data-md-code-trailing-newline",r)},Te=t=>{const e=Array.from(t.querySelectorAll("[data-md-code-line-content]"));if(e.length===0)return t.textContent??"";const n=e.map(r=>r.textContent??"").join(`
6
- `);return t.hasAttribute("data-md-code-trailing-newline")?`${n}
7
- `:n},Wt=(t,e,n)=>{const r=t.querySelectorAll('[data-component="markdown-code"]');for(const s of Array.from(r)){const o=s.querySelector("pre");o&&xe(o),Ne(s,e,n)}},ce=(t,e,n,r)=>{B(t,q.check),t.setAttribute("title",e),t.setAttribute("aria-label",e),window.setTimeout(()=>{B(t,q[n]),t.setAttribute("title",r),t.setAttribute("aria-label",r)},2e3)},qt=t=>{const e=t.querySelectorAll(":not(pre) > code");for(const n of Array.from(e))n.getAttribute("data-markdown")!=="inline-code"&&n.setAttribute("data-markdown","inline-code")},Bt=(t,e)=>{const n=t.querySelectorAll("pre");for(const r of Array.from(n)){if(r.querySelector("code.language-mermaid"))continue;const s=r.parentElement;if(!s||s.closest('[data-component="markdown-code"]'))continue;const o=r.querySelector("code")?.className.match(/language-([\w+#.-]+)/)?.[1],a=r.getAttribute("data-md-lang")??o??"text",i=document.createElement("div");i.setAttribute("data-component","markdown-code"),i.className="my-4 group overflow-hidden rounded-2xl border border-border/80 bg-[var(--surface-elevated)]";const l=document.createElement("div");l.className="flex items-center justify-between border-b border-border/70 px-3 py-1.5";const d=document.createElement("span");d.className="font-mono text-[13px] text-muted-foreground",d.textContent=a;const c=L("copy",e.labels.copy,"copy-code"),p=L("textWrap",e.codeBlockLineWrap?e.labels.disableCodeWrap:e.labels.enableCodeWrap,"toggle-code-wrap");l.appendChild(d);const u=document.createElement("div");u.className="flex items-center gap-1",u.setAttribute("data-md-code-actions",""),u.appendChild(p),u.appendChild(c),l.appendChild(u);const f=document.createElement("div");f.setAttribute("data-md-code-body",""),f.className="px-3 py-2.5 overflow-x-auto",s.replaceChild(i,r),r.style.margin="0",r.style.background="transparent",r.classList.add("min-w-0","w-full","flex-1"),e.deferCodeLineNumberSync||xe(r),f.appendChild(r),i.appendChild(l),i.appendChild(f),Ne(i,e.codeBlockLineWrap,e.labels)}},de=t=>{const e=[],n=[],r=t.querySelectorAll("thead th");for(const o of Array.from(r))e.push((o.textContent??"").trim());const s=t.querySelectorAll("tbody tr");for(const o of Array.from(s)){const a=Array.from(o.querySelectorAll("td")).map(i=>(i.textContent??"").trim());a.length>0&&n.push(a)}return{headers:e,rows:n}},$t=t=>/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t,me=({headers:t,rows:e})=>[t,...e].map(n=>n.map($t).join(",")).join(`
8
- `),zt=({headers:t,rows:e})=>[t,...e].map(n=>n.join(" ")).join(`
9
- `),ue=({headers:t,rows:e})=>{const n=`| ${t.join(" | ")} |`,r=`| ${t.map(()=>"---").join(" | ")} |`,s=e.map(o=>`| ${o.join(" | ")} |`).join(`
10
- `);return`${n}
11
- ${r}
12
- ${s}`},pe=(t,e)=>{const n=document.createElement("div");n.className=`absolute top-full right-0 mt-1 hidden ${tt}`,n.style.backgroundColor="var(--surface-elevated)",n.style.color="var(--surface-elevated-foreground)",n.setAttribute("data-md-menu",t);for(const r of e){const s=document.createElement("button");s.type="button",s.className=`w-full text-left ${rt}`,s.setAttribute("data-md-action",`${t}-${r.key}`),s.textContent=r.label,n.appendChild(s)}return n},Ht=(t,e)=>{const n=t.querySelectorAll("table");for(const r of Array.from(n)){if(r.closest('[data-markdown="table-wrapper"]'))continue;const o=document.createElement("div");o.className="group my-4 flex flex-col space-y-2",o.setAttribute("data-markdown","table-wrapper");const a=document.createElement("div");a.className="flex items-center justify-end gap-1";const i=document.createElement("div");i.className="relative",i.appendChild(L("copy",e.copyTable,"table-copy-toggle")),i.appendChild(pe("table-copy",[{key:"csv",label:"CSV"},{key:"tsv",label:"TSV"},{key:"markdown",label:"Markdown"}]));const l=document.createElement("div");l.className="relative",l.appendChild(L("download",e.downloadTable,"table-download-toggle")),l.appendChild(pe("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),a.appendChild(i),a.appendChild(l);const d=document.createElement("div");d.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const c=r.parentElement;if(!c)continue;c.replaceChild(o,r),r.setAttribute("data-markdown","table"),r.classList.add("w-full","border-collapse","text-sm");for(const u of Array.from(r.querySelectorAll("tr")))u.classList.add("border-b","border-border/60");const p=r.querySelector("tbody tr:last-child");p?.classList.remove("border-b"),p?.classList.add("border-0");for(const u of Array.from(r.querySelectorAll("th")))u.classList.add("border-r","border-border/60","px-4","py-2.5","text-left","align-middle","font-semibold","text-foreground","last:border-r-0");for(const u of Array.from(r.querySelectorAll("td")))u.classList.add("border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground/90","last:border-r-0");d.appendChild(r),o.appendChild(a),o.appendChild(d)}},jt=(t,e)=>{const n=t.querySelectorAll("pre > code.language-mermaid");for(const r of Array.from(n)){const s=r.parentElement;if(!s)continue;const o=(r.textContent??"").replace(/\s+$/,""),a=e.renderMermaid(o),i=document.createElement("div");i.setAttribute("data-markdown","mermaid-block"),i.setAttribute("data-md-source",o),i.className="group relative";const l=document.createElement("div");l.setAttribute("data-markdown","mermaid-scroll");const d=document.createElement("div");if(d.setAttribute("data-markdown","mermaid-toolbar"),d.className="absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity",a.svg){i.setAttribute("data-mermaid-render","svg");const p=document.createElement("div");p.setAttribute("data-markdown","mermaid-viewport");const u=document.createElement("div");if(u.setAttribute("data-markdown","mermaid"),u.setAttribute("data-md-original-svg",a.svg),u.innerHTML=a.svg,p.appendChild(u),l.appendChild(p),e.mermaidControls.showPanZoomControls&&(d.appendChild(L("zoomIn",e.labels.zoomInDiagram,"mermaid-zoom-in")),d.appendChild(L("zoomOut",e.labels.zoomOutDiagram,"mermaid-zoom-out")),d.appendChild(L("fit",e.labels.resetDiagramView,"mermaid-fit"))),e.mermaidControls.copy){const f=L("copy",e.labels.copyDiagram,"mermaid-copy");f.setAttribute("data-md-source",o),d.appendChild(f)}if(e.mermaidControls.download){const f=L("download",e.labels.downloadDiagram,"mermaid-download");f.setAttribute("data-md-svg","1"),d.appendChild(f)}}else{i.setAttribute("data-mermaid-render","ascii");const p=document.createElement("pre");if(p.setAttribute("data-markdown","mermaid-ascii"),p.textContent=a.ascii||o,l.appendChild(p),e.mermaidControls.copy){const u=L("copy",e.labels.copyDiagram,"mermaid-copy");u.setAttribute("data-md-source",a.ascii||o),d.appendChild(u)}}i.appendChild(l),i.appendChild(d);const c=s.parentElement;c&&c.replaceChild(i,s)}},Vt=(t,e)=>{const n=t.querySelectorAll("a[href]");for(const r of Array.from(n)){if(r.getAttribute("data-md-link-decorated")==="true"||r.getAttribute("data-pichamber-file-link")==="true")continue;const s=r.getAttribute("href")??"";if(!ve(s))continue;r.setAttribute("data-md-link-decorated","true");const o=Qe(s);if(o){const a=document.createElement("span");a.className="mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle";const i=document.createElement("img");i.src=o,i.alt="",i.setAttribute("aria-hidden","true"),i.loading="lazy",i.decoding="async",i.className="size-3.5 rounded-sm",i.addEventListener("error",()=>a.remove(),{once:!0}),a.appendChild(i),r.parentNode?.insertBefore(a,r)}if(e.onPreviewLoopback&&et(s)){const a=document.createElement("button");a.type="button",a.className=`ml-1 align-middle ${Me}`,a.setAttribute("data-md-action","preview-loopback"),a.setAttribute("data-md-url",s),a.setAttribute("title",e.labels.previewTitle),a.setAttribute("aria-label",e.labels.previewLabel),B(a,q.download),r.parentNode?.insertBefore(a,r.nextSibling)}}},fe=(t,e)=>{qt(t),jt(t,e),Bt(t,e),Ht(t,e.labels),Vt(t,e)},he=(t,e,n)=>{const r=new Blob([e],{type:n}),s=URL.createObjectURL(r),o=document.createElement("a");o.href=s,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(s)},O=t=>{for(const e of Array.from(t.querySelectorAll("[data-md-menu]")))e.classList.add("hidden")},Kt=(t,e)=>{const n=r=>{const s=r.target;if(!(s instanceof Element))return;const o=s.closest("[data-md-action]");if(!o){O(t);return}const a=o.getAttribute("data-md-action")??"";if(a==="copy-code"){const i=o.closest('[data-component="markdown-code"]')?.querySelector("code"),l=i?Te(i):"";l&&H(l).then(()=>ce(o,e.labels.copied,"copy",e.labels.copy));return}if(a==="toggle-code-wrap"){r.preventDefault(),e.onToggleCodeBlockLineWrap?.();return}if(a==="table-copy-toggle"||a==="table-download-toggle"){r.preventDefault();const i=o.parentElement?.querySelector("[data-md-menu]")??null,l=i?.classList.contains("hidden")??!1;O(t),i&&l&&i.classList.remove("hidden");return}if(a.startsWith("table-copy-")){const i=a.replace("table-copy-",""),l=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(l instanceof HTMLTableElement){const d=de(l),c=i==="csv"?me(d):i==="tsv"?zt(d):ue(d);H(c)}O(t);return}if(a.startsWith("table-download-")){const i=a.replace("table-download-",""),l=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(l instanceof HTMLTableElement){const d=de(l),c=i==="csv"?me(d):ue(d);he(i==="csv"?"table.csv":"table.md",c,i==="csv"?"text/csv":"text/markdown")}O(t);return}if(a==="mermaid-copy"){const i=o.getAttribute("data-md-source")??"";i&&H(i).then(()=>ce(o,e.labels.copied,"copy",e.labels.copyDiagram));return}if(a==="mermaid-zoom-in"||a==="mermaid-zoom-out"||a==="mermaid-fit"){r.preventDefault();const i=o.closest('[data-markdown="mermaid-block"]'),l=Rt(i);a==="mermaid-zoom-in"?l?.zoomIn():a==="mermaid-zoom-out"?l?.zoomOut():l?.fit();return}if(a==="mermaid-download"){const i=o.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]'),l=i?.getAttribute("data-md-original-svg")??i?.innerHTML??"";l&&he("diagram.svg",l,"image/svg+xml;charset=utf-8");return}if(a==="preview-loopback"){r.preventDefault();const i=o.getAttribute("data-md-url")??"";i&&e.onPreviewLoopback?.(i);return}};return t.addEventListener("click",n),()=>t.removeEventListener("click",n)},ge=(t,e,n)=>{let r=0;for(const o of t){const a=r+o.data.length;if(e<a||e===a&&n==="left")return{node:o,offset:Math.max(0,e-r)};r=a}const s=t.at(-1);return s?{node:s,offset:s.data.length}:null},Ut=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),be=Array.from(Ut).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),Zt=t=>ot(t),Xt=t=>nt(t),$=t=>{let e=(t||"").trim();return e?((e.startsWith("`")&&e.endsWith("`")||e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1).trim()),e=e.replace(/[.,;!?]+$/g,""),e.endsWith(")")&&!e.includes("(")&&(e=e.slice(0,-1)),e.endsWith("]")&&!e.includes("[")&&(e=e.slice(0,-1)),e):""},D=t=>{let e=$(t);if(!e)return"";const n=e.indexOf(";");n>=0&&(e=e.slice(0,n)),e=e.replace(/#.*$/,"");const r=e.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);r&&(e=r[1]??e);const s=be.length>0?e.match(new RegExp(`^(.*(?:/|^)(${be})):.*$`,"i")):null;return s&&(e=s[1]??e),$(e)},Pe=t=>{const e=$(t);if(!e)return null;const n=e.indexOf(";"),r=n>=0?$(e.slice(0,n)):e;if(!r)return null;const s=r.match(/^(.*?):(\d+)-(\d+)$/);if(s){const l=D(s[1]??""),d=Number.parseInt(s[2]??"",10),c=Number.parseInt(s[3]??"",10);return!l||!Number.isFinite(d)||!Number.isFinite(c)||c<d?null:{path:l,line:d,endLine:c}}const o=r.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(o){const l=D(o[1]??""),d=Number.parseInt(o[2]??"",10),c=o[3]?Number.parseInt(o[3],10):void 0;return!l||!Number.isFinite(d)?null:{path:l,line:d,column:Number.isFinite(c??Number.NaN)?c:void 0}}const a=r.match(/^(.*?):(\d+)(?::(\d+))?$/);if(a){const l=D(a[1]??""),d=Number.parseInt(a[2]??"",10),c=a[3]?Number.parseInt(a[3],10):void 0;return!l||!Number.isFinite(d)?null:{path:l,line:d,column:Number.isFinite(c??Number.NaN)?c:void 0}}const i=D(r);return i?{path:i}:null},V=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+(?:-\d+)?(?::\d+)?)?/g,Re=({containerRef:t,enabled:e})=>{y.useEffect(()=>{if(e===!1)return;const n=t.current;if(!n)return;const r=s=>{if(s.defaultPrevented||s.button!==0||s.metaKey||s.ctrlKey||s.altKey||s.shiftKey)return;const o=s.target;if(!(o instanceof Element))return;const a=o.closest("a[href]");if(!(a instanceof HTMLAnchorElement)||a.getAttribute("data-pichamber-file-link")==="true")return;const i=a.getAttribute("href")??"";ve(i)&&(s.preventDefault(),s.stopPropagation(),at(i))};return n.addEventListener("click",r),()=>{n.removeEventListener("click",r)}},[t,e])},we='[data-pichamber-file-link="true"]',Ie="data-pichamber-block-path-token",_e=`[${Ie}]`,P="data-pichamber-block-paths-scanned",Gt=2e5,Yt=4,Jt=1e3,Qt=80,ye=160,N=new Map;let W=0;const Ae=[],er=()=>Jt,tr=()=>Qt,rr=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),Y=t=>Zt(t),nr=t=>Xt(t),or=(t,e)=>lt(t,e),ar=t=>{const e=t.split("/").filter(Boolean).pop()??"";return!e||e.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(e)},Fe=t=>{if(!t||t.startsWith("--")||t.includes("://")||/[<>]/.test(t)||/\s{2,}/.test(t))return!1;const e=Y(t),n=e.split("/").filter(Boolean).pop()??e;if(!n||n==="."||n==="..")return!1;const r=n.toLowerCase();return rr.has(r)||r.startsWith(".")&&r.length>1?!0:ar(e)},Oe=t=>{const e=Pe(t);return e?Fe(e.path):!1},ir=t=>{const e=t.querySelectorAll(_e);for(const r of Array.from(e))r.replaceWith(t.ownerDocument.createTextNode(r.textContent??""));const n=t.querySelectorAll(`code[${P}]`);for(const r of Array.from(n))r.removeAttribute(P),r.normalize()},K=t=>{if(t.tagName.toLowerCase()==="a"){const e=t.getAttribute("href")?.trim();if(e&&Oe(e))return e}return(t.textContent||"").trim()},sr=t=>{const e=t.querySelectorAll("pre code");if(e.length===0)return;const n=t.ownerDocument;if(n)for(const r of Array.from(e)){if(r.getAttribute(P)==="true")continue;if((r.textContent??"").length>Gt){r.setAttribute(P,"true");continue}const s=n.createTreeWalker(r,NodeFilter.SHOW_TEXT),o=[];let a=s.nextNode();for(;a;){const c=a;c.parentElement?.closest("[data-md-code-line-number]")||o.push(c),a=s.nextNode()}const i=Te(r);if(!i.includes(".")){r.setAttribute(P,"true");continue}V.lastIndex=0;const l=[];let d=V.exec(i);for(;d;){const c=d[0];c&&Oe(c)&&l.push({start:d.index,end:d.index+c.length,raw:c}),d=V.exec(i)}for(const{start:c,end:p,raw:u}of l.reverse()){const f=ge(o,c,"right"),h=ge(o,p,"left");if(!f||!h)continue;const A=n.createRange();A.setStart(f.node,f.offset),A.setEnd(h.node,h.offset);const v=n.createElement("span");v.setAttribute(Ie,"true"),v.textContent=u,A.deleteContents(),A.insertNode(v)}r.setAttribute(P,"true")}},U=(t,e)=>{const n=Pe(t);if(!n||!Fe(n.path))return null;const r=nr(n.path)?Y(n.path):or(e,n.path);return r?{...n,resolvedPath:r}:null},lr=t=>{const e=Y(t);if(!e)return Promise.resolve(!1);const n=N.get(e);if(n)return N.delete(e),N.set(e,n),n;const r=new Promise(o=>{const a=()=>{W+=1,Ye(`/api/fs/stat?path=${encodeURIComponent(e)}&optional=true`,{method:"GET",cache:"no-store"}).then(async i=>{if(!i.ok){o(!1);return}const l=await i.json().catch(()=>null);o(l?.exists!==!1)}).catch(()=>o(!1)).finally(()=>{W=Math.max(0,W-1),Ae.shift()?.()})};if(W<Yt){a();return}Ae.push(a)}),s=er();for(;N.size>=s;){const o=N.keys().next().value;if(typeof o!="string")break;N.delete(o)}return N.set(e,r),r},cr=(t,e)=>t||st(t,e),De=({containerRef:t,effectiveDirectory:e,editor:n,preferRuntimeEditor:r,enabled:s})=>{const o=y.useRef(null);y.useEffect(()=>{const a=t.current;if(!a)return;let i=!1;const l=tr(),d=s&&!bt(),c=g=>{g.removeAttribute("data-pichamber-file-link"),g.removeAttribute("data-pichamber-file-ref"),g.removeAttribute("data-pichamber-file-path"),g.getAttribute("title")==="Open file"&&g.removeAttribute("title"),g.tagName.toLowerCase()!=="a"&&(g.removeAttribute("role"),g.removeAttribute("tabindex"))},p=()=>{const g=a.querySelectorAll(we);for(const b of Array.from(g))c(b);ir(a)};if(!d){p();return}const u=(g=0)=>{if(o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),typeof window>"u"){f();return}o.current=window.setTimeout(()=>{o.current=null,window.requestAnimationFrame(()=>{i||f()})},g)},f=()=>{d&&sr(a);const g=a.querySelectorAll(`[data-markdown="inline-code"], a, ${_e}`);let b=0;for(const m of Array.from(g)){const C=K(m),E=U(C,e);if(c(m),!E||b>=l)continue;b+=1,(Xe()&&Ge()&&!ne(E.resolvedPath,e)?Promise.resolve(!0):lr(E.resolvedPath)).then(Ve=>{if(i||!Ve||!a.contains(m))return;const ee=K(m),z=U(ee,e);!z||z.resolvedPath!==E.resolvedPath||(m.setAttribute("data-pichamber-file-link","true"),m.setAttribute("data-pichamber-file-ref",ee),m.setAttribute("data-pichamber-file-path",z.resolvedPath),m.setAttribute("title","Open file"),m.tagName.toLowerCase()!=="a"&&(m.setAttribute("role","button"),m.setAttribute("tabindex","0")))})}},h=async g=>{const b=g.getAttribute("data-pichamber-file-ref")||K(g),m=U(b,e);if(!m)return;const C=cr(e,m.resolvedPath);ne(m.resolvedPath,e)||await it(m.resolvedPath,e);const E=T.getState();Number.isFinite(m.line??Number.NaN)?E.openContextFileAtLine(C,m.resolvedPath,Math.max(1,Math.trunc(m.line)),Number.isFinite(m.column??Number.NaN)?Math.max(1,Math.trunc(m.column)):1):E.openContextFile(C,m.resolvedPath)},A=g=>{const b=g.target;if(!(b instanceof Element))return;const m=b.closest(we);m instanceof HTMLElement&&(g.preventDefault(),g.stopPropagation(),h(m))},v=g=>{if(g.key!=="Enter"&&g.key!==" ")return;const b=g.target;!(b instanceof HTMLElement)||b.getAttribute("data-pichamber-file-link")!=="true"||(g.preventDefault(),g.stopPropagation(),h(b))};u(ye);const w=new MutationObserver(()=>{u(ye)});return w.observe(a,{childList:!0,subtree:!0}),a.addEventListener("click",A),a.addEventListener("keydown",v),()=>{i=!0,o.current!==null&&typeof window<"u"&&window.clearTimeout(o.current),o.current=null,w.disconnect(),a.removeEventListener("click",A),a.removeEventListener("keydown",v)}},[t,n,e,r,s])},R={download:!0,copy:!0,showPanZoomControls:!0},We=!0,qe=({containerRef:t,onShowPopup:e,enableFullscreen:n,enablePanZoom:r,allowMermaidWheelEvents:s})=>{y.useEffect(()=>{const o=t.current;if(!o)return;const a=l=>{if(!e)return;const d=l.target;if(!(d instanceof Element)||d.closest('button, a, [role="button"]'))return;const c=d.closest(F);if(!c)return;if(c instanceof HTMLElement&&c.hasAttribute("data-mermaid-suppress-click")){c.removeAttribute("data-mermaid-suppress-click");return}const u=Array.from(o.querySelectorAll(F)).indexOf(c);if(u<0)return;const f=c instanceof HTMLElement?c.getAttribute("data-md-source"):null;if(!f||f.trim().length===0)return;const h=`Diagram ${u+1}`;e({open:!0,title:h,content:"",metadata:{tool:"mermaid-preview",filename:h},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(f)}`,source:f,filename:h}})},i=l=>{if(s||(l.ctrlKey||l.metaKey)&&r)return;const d=l.target;!(d instanceof Element)||!d.closest(F)||l.stopPropagation()};return o.addEventListener("click",a),o.addEventListener("wheel",i,{capture:!0,passive:!0}),()=>{o.removeEventListener("click",a),o.removeEventListener("wheel",i,!0)}},[s,t,n,r,e])},x=new Map,dr=100,mr=(t,e)=>{const n=x.get(t);if(n)return x.delete(t),x.set(t,n),n;const r=e();if(x.set(t,r),x.size>dr){const s=x.keys().next().value;s&&x.delete(s)}return r},ur=t=>({bg:t.colors.surface.elevated,fg:t.colors.surface.foreground,line:t.colors.interactive.border,accent:t.colors.primary.base,muted:t.colors.surface.mutedForeground,surface:t.colors.surface.muted,border:t.colors.interactive.border,transparent:!0,font:"system-ui, sans-serif"}),Be=()=>{const t=dt(),e=re(!1),n=re(!0);return t?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?n:e)},pr=t=>{const e=t.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return e?t.slice(e[0].length):t},$e=(t,e,n,r=R)=>{const s=y.useMemo(()=>({copy:"Copy code",copied:"Copied",enableCodeWrap:"Enable line wrap",disableCodeWrap:"Disable line wrap",copyTable:"Copy table",downloadTable:"Download table",copyDiagram:"Copy source",downloadDiagram:"Download SVG",zoomInDiagram:"Zoom in",zoomOutDiagram:"Zoom out",resetDiagramView:"Reset view",previewLabel:"Preview",previewTitle:"Open preview pane"}),[]),o=T(l=>l.codeBlockLineWrap),a=T(l=>l.setCodeBlockLineWrap),i=y.useCallback(()=>{a(!T.getState().codeBlockLineWrap)},[a]);return y.useMemo(()=>{const l=ur(t),d=T.getState().mermaidRenderingMode,c=t.metadata?.id??"theme";return{labels:s,mermaidControls:r,codeBlockLineWrap:o,deferCodeLineNumberSync:e,onToggleCodeBlockLineWrap:i,renderMermaid:u=>mr(`${c}:${d}:${u}`,()=>{try{return d==="ascii"?{ascii:Ue(u)}:{svg:Ze(u,l)}}catch{return{}}}),onPreviewLoopback:n}},[t,s,r,o,e,i,n])},ze=t=>{t.style.display="contents",t.style.width="",t.style.minWidth="",t.style.maxWidth=""},Z=(t,e)=>{ze(t);const n=ht(e);let r=t.querySelector(":scope > [data-md-live]");const s=r?.hasAttribute("data-md-live-pre")===!0;(!r||s!==n)&&(t.replaceChildren(),r=document.createElement(n?"div":"p"),r.setAttribute("data-md-live",""),n&&r.setAttribute("data-md-live-pre",""),r.className=n?"w-full min-w-0 whitespace-pre-wrap break-words":"w-full min-w-0 break-words",r.appendChild(document.createTextNode("")),t.appendChild(r));const o=r.firstChild;if(!(o instanceof globalThis.Text)){r.replaceChildren(document.createTextNode(e));return}if(e.startsWith(o.data)){const a=e.slice(o.data.length);a.length>0&&o.appendData(a);return}o.data=e},He=({containerRef:t,text:e,streaming:n,cacheKey:r,syntaxVars:s,ctx:o})=>{y.useEffect(()=>{yt()},[]);const a=y.useRef(null),i=y.useRef(null),l=y.useRef(r);l.current!==r&&(l.current=r,i.current=null);const d=y.useCallback(()=>{const c=t.current;if(c){if(!a.current){if(!S(c))return;a.current=Dt(c);return}a.current.refresh()}},[t]);y.useLayoutEffect(()=>{const c=t.current,p=c?.querySelector("[data-markdown-content]")??c;if(p&&e&&p.childNodes.length===0){const u=document.createElement("div");if(u.setAttribute("data-md-block",""),u.style.display="contents",n){Z(u,e),p.appendChild(u);return}u.innerHTML=mt(e),fe(u,o),p.appendChild(u),S(u)&&d()}},[t,e,n,o,d]),y.useEffect(()=>()=>{a.current?.cleanup(),a.current=null},[]),y.useEffect(()=>{const c=t.current;if(!c)return;const p=c.querySelector("[data-markdown-content]")??c;let u=!0;if(n&&i.current){const f=ut(r).update(e);if(pt(i.current,f)){const h=f[f.length-1],A=p.querySelectorAll(":scope > [data-md-block]")[f.length-1];if(h&&A){Z(A,h.raw),A.setAttribute("data-md-id",`live:${f.length-1}`),i.current=i.current.map((v,w)=>w===f.length-1?{...v,raw:h.raw,id:`live:${w}`,mode:"live"}:v);return}}}return ft(e,n,r).then(f=>{if(!u)return;const h=Array.from(p.querySelectorAll(":scope > [data-md-block]"));f.forEach((w,g)=>{let b=h[g];if(b||(b=document.createElement("div"),b.setAttribute("data-md-block",""),b.style.display="contents",p.appendChild(b)),w.mode==="live"){Z(b,w.raw),b.setAttribute("data-md-id",w.id);return}if(ze(b),b.getAttribute("data-md-id")===w.id)return;const m=document.createElement("div");m.innerHTML=w.html,fe(m,o);const C=S(b),E=S(m);Ke(b,m,{childrenOnly:!0,onBeforeElUpdated:(J,Q)=>!J.isEqualNode(Q)}),b.setAttribute("data-md-id",w.id),(C||E||S(b))&&d()});const A=S(p);let v=!1;for(let w=h.length-1;w>=f.length;w-=1){const g=h[w];g&&S(g)&&(v=!0),g?.remove()}(v||h.length>f.length&&A)&&d(),i.current=f}),()=>{u=!1}},[t,e,n,r,o,d]),y.useEffect(()=>{const c=t.current;if(c)return Kt(c,o)},[t,o]),y.useEffect(()=>{const c=t.current,p=c?.querySelector("[data-markdown-content]")??c;if(p)for(const[u,f]of Object.entries(s))p.style.setProperty(u,f)},[t,s]),y.useEffect(()=>{const c=t.current,p=c?.querySelector("[data-markdown-content]")??c;p&&(o.deferCodeLineNumberSync||Wt(p,o.codeBlockLineWrap,o.labels))},[t,o.codeBlockLineWrap,o.deferCodeLineNumberSync,o.labels])},je=(t,e)=>X("w-full min-w-0",t==="tool"?"markdown-content markdown-tool":t==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",e&&"markdown-streaming"),fr=({content:t,part:e,messageId:n,isAnimated:r=!0,skipFadeIn:s=!1,className:o,isStreaming:a=!1,disableStreamAnimation:i=!1,variant:l="assistant",onShowPopup:d,enableFileReferences:c=!0})=>{te("ui.markdown_renderer.render"),a&&te("ui.markdown_renderer.render.streaming"),Je("ui.markdown_renderer.content_len",t.length);const p=Be(),{editor:u}=ke(),f=y.useRef(null),h=Ce()??"",A=T(E=>E.openContextPreview),v=y.useCallback(E=>{h&&A(h,E)},[h,A]),w=a&&!i;qe({containerRef:f,onShowPopup:d,enableFullscreen:We,enablePanZoom:R.showPanZoomControls}),De({containerRef:f,effectiveDirectory:h,editor:u,preferRuntimeEditor:!1,enabled:c&&!a}),Re({containerRef:f});const g=y.useMemo(()=>Ee(p),[p]),b=$e(p,w,h?v:void 0,R),m=`markdown-${e?.id?`part-${e.id}`:`message-${n}`}`;He({containerRef:f,text:t,streaming:w,cacheKey:m,syntaxVars:g,ctx:b});const C=_.jsx("div",{className:X("break-words w-full min-w-0",o),ref:f,children:_.jsx("div",{className:je(l,w),"data-markdown-content":!0})});return r?_.jsx(ct,{skipAnimation:s,children:C},m):C},po=y.memo(fr,(t,e)=>t.content===e.content&&t.isStreaming===e.isStreaming&&t.disableStreamAnimation===e.disableStreamAnimation&&t.variant===e.variant&&t.isAnimated===e.isAnimated&&t.skipFadeIn===e.skipFadeIn&&t.className===e.className&&t.messageId===e.messageId&&t.onShowPopup===e.onShowPopup&&t.enableFileReferences===e.enableFileReferences&&t.part?.id===e.part?.id),hr=({content:t,className:e,variant:n="assistant",disableLinkSafety:r,stripFrontmatter:s=!1,onShowPopup:o,mermaidControls:a=R,allowMermaidWheelEvents:i=!1,enableFileReferences:l=!0})=>{const{editor:d}=ke(),c=Be(),p=y.useRef(null),u=Ce()??"",f=y.useMemo(()=>s?pr(t):t,[t,s]);qe({containerRef:p,onShowPopup:o,enableFullscreen:We,enablePanZoom:a.showPanZoomControls,allowMermaidWheelEvents:i}),De({containerRef:p,effectiveDirectory:u,editor:d,preferRuntimeEditor:!1,enabled:l}),Re({containerRef:p,enabled:!r});const h=y.useMemo(()=>Ee(c),[c]),A=$e(c,!1,void 0,a);return He({containerRef:p,text:f,streaming:!1,cacheKey:`simple:${n}`,syntaxVars:h,ctx:A}),_.jsx("div",{className:X("break-words w-full min-w-0",e),ref:p,children:_.jsx("div",{className:je(n),"data-markdown-content":!0})})},fo=y.memo(hr,(t,e)=>{const n=t.mermaidControls??R,r=e.mermaidControls??R;return t.content===e.content&&t.variant===e.variant&&t.className===e.className&&t.disableLinkSafety===e.disableLinkSafety&&t.stripFrontmatter===e.stripFrontmatter&&t.onShowPopup===e.onShowPopup&&n.download===r.download&&n.copy===r.copy&&n.showPanZoomControls===r.showPanZoomControls&&t.allowMermaidWheelEvents===e.allowMermaidWheelEvents&&t.enableFileReferences===e.enableFileReferences});export{po as MarkdownRenderer,fo as SimpleMarkdownRenderer};
@@ -1 +0,0 @@
1
- import{am as j,an as y,ao as D}from"./useAppFontEffects-C4JL1x7k.js";import{g as k,a as C}from"./web-components-B2Rw__yK.js";import{M as P,G as O,u as L,W as A,a as M,b as R,n as F,t as H}from"./Virtualizer-BSHVMKgK.js";import{j as a,r as w}from"./vendor-react-B5Z1Mdn3.js";import{V as _,F as N}from"./VirtualizedFileDiff-DfaXovGB.js";function T({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function V(e,t){const n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:z(n,e.startContentIndex)}}function z(e,t){let n=e.unifiedLineStart;for(let l=0;l<t;l++){const s=e.hunkContent[l];n+=s.type==="context"?s.lines:s.deletions+s.additions}return n}function U(e){const t=j(e);if(t.length!==1)throw console.error(t),new Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");const{files:n}=t[0];if(n.length!==1)throw console.error(n),new Error("FileDiff: Provided patch must contain exactly 1 file diff");return n[0]}function $({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:l,renderHeaderFilenameSuffix:s,renderHeaderMetadata:x,renderAnnotation:d,renderGutterUtility:u,renderMergeConflictUtility:o,lineAnnotations:f,getHoveredLine:p,getInstance:m}){const g=n?.(e),c=l?.(e),i=s?.(e),v=x?.(e);return a.jsxs(a.Fragment,{children:[g!=null?a.jsx("div",{slot:y,children:g}):a.jsxs(a.Fragment,{children:[c!=null&&a.jsx("div",{slot:"header-prefix",children:c}),i!=null&&a.jsx("div",{slot:"header-filename-suffix",children:i}),v!=null&&a.jsx("div",{slot:"header-metadata",children:v})]}),d!=null&&f?.map((r,h)=>a.jsx("div",{slot:k(r),children:d(r)},h)),t!=null&&o!=null&&m!=null&&t.map(r=>{if(r==null)return;const h=b(r,e);return a.jsx("div",{slot:h,style:P,children:o(r,m)},h)}),u!=null&&a.jsx("div",{slot:"gutter-utility-slot",style:O,children:u(p)})]})}function b(e,t){const n=V(e,t);return n!=null?T({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex}):void 0}const S=typeof window>"u"?w.useEffect:w.useLayoutEffect;function G({fileDiff:e,options:t,lineAnnotations:n,selectedLines:l,prerenderedHTML:s,metrics:x,hasGutterRenderUtility:d,hasCustomHeader:u,disableWorkerPool:o,contentEditable:f}){const p=L(),m=l!==void 0,g=w.useContext(A),c=M(),i=w.useRef(null),v=R(r=>{if(r!=null){if(i.current!=null)throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");p!=null?i.current=new _(E({controlledSelection:m,contentEditable:f,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:d,options:t}),p,x,o?void 0:g,!0):i.current=new N(E({controlledSelection:m,contentEditable:f,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:d,options:t}),o?void 0:g,!0),i.current.hydrate({fileDiff:e,fileContainer:r,lineAnnotations:n,prerenderedHTML:s})}else{if(i.current==null)throw new Error("useFileDiffInstance: A FileDiff instance should exist when unmounting");i.current.cleanUp(),i.current=null}});return S(()=>{const{current:r}=i;if(r==null)return;const h=E({controlledSelection:m,contentEditable:f,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:d,options:t}),I=!C(r.options,h);r.setOptions(h),r.render({forceRender:I,fileDiff:e,lineAnnotations:n}),l!==void 0&&r.setSelectedLines(l)}),S(()=>{if(f&&i.current!=null){if(c===void 0)throw new Error("FileDiff: Editor is not attached");return c.edit(i.current)}},[f,c]),{ref:v,getHoveredLine:w.useCallback(()=>i.current?.getHoveredLine(),[])}}function E({options:e,controlledSelection:t,contentEditable:n,hasCustomHeader:l,hasEditor:s,hasGutterRenderUtility:x}){const d=n&&s,u=t||x||l;if(!u&&!d)return e;let o={...e};return u&&(o={...o,controlledSelection:t,renderCustomHeader:l?F:e?.renderCustomHeader,renderGutterUtility:x?F:e?.renderGutterUtility}),d&&(o={...o,useTokenTransformer:!0,enableGutterUtility:!1,enableLineSelection:!1,expandUnchanged:!0,lineHoverHighlight:"disabled"}),o}function X({patch:e,options:t,metrics:n,lineAnnotations:l,selectedLines:s,className:x,style:d,prerenderedHTML:u,renderAnnotation:o,renderCustomHeader:f,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:g,renderGutterUtility:c,disableWorkerPool:i=!1,contentEditable:v=!1}){const r=q(e),{ref:h,getHoveredLine:I}=G({fileDiff:r,options:t,metrics:n,lineAnnotations:l,selectedLines:s,prerenderedHTML:u,hasGutterRenderUtility:c!=null,hasCustomHeader:f!=null,disableWorkerPool:i,contentEditable:v});return a.jsx(D,{ref:h,className:x,style:d,children:H($({fileDiff:r,renderCustomHeader:f,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:g,renderAnnotation:o,lineAnnotations:l,renderGutterUtility:c,getHoveredLine:I}),u)})}function q(e){return w.useMemo(()=>U(e),[e])}export{X as P};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionSwitcherContent-z9VYCXrT.js","assets/vendor-react-B5Z1Mdn3.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-C4JL1x7k.js","assets/vendor-zustand-GVb4H8HE.js","assets/index-KIdiBFJs.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-DNoEeZ2U.css","assets/vendor-base-ui-vkqQ2P9o.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-react-dom-BZOGXAGe.js","assets/vendor-floating-ui-dom-WyXykhNi.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-use-sync-external-store-D0AXkdQC.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-sonner-BDtm25td.js","assets/vendor-codemirror-view-Ct4T37Ue.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/runtimeSurface-CySRuLbN.js","assets/vendor-dnd-kit-core-C9qcAm_1.js","assets/vendor-dnd-kit-utilities-DTY1C6ST.js","assets/vendor-dnd-kit-accessibility-DZKKhs9S.js","assets/vendor-dnd-kit-sortable-D8ozj8M-.js","assets/vendor-cmdk-zXx6sGnS.js","assets/vendor-radix-ui-react-dialog-D2yhEu2p.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-8xy6TJML.js","assets/vendor-radix-ui-react-context-CFsX-AUC.js","assets/vendor-radix-ui-react-id-D2kS9K1j.js","assets/vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js","assets/vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js","assets/vendor-radix-ui-react-dismissable-layer-DrorBNg9.js","assets/vendor-radix-ui-react-primitive-DkH8dMOR.js","assets/vendor-radix-ui-react-slot-BIDFZX0-.js","assets/vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js","assets/vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js","assets/vendor-radix-ui-react-focus-scope-D2BkImwt.js","assets/vendor-radix-ui-react-portal-YgCRIyi7.js","assets/vendor-radix-ui-react-presence-D432pCMB.js","assets/vendor-radix-ui-react-focus-guards-BfdFmL7c.js","assets/vendor-react-remove-scroll-vR1dy1aP.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-CSAHp1YF.js","assets/vendor-react-style-singleton-Ctw6HnYx.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-Vv4V8Nd1.js","assets/vendor-use-callback-ref-CVVuCyLj.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BByA_dGF.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-DuOEwJ3f.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-wd6iRebq.js","assets/vendor-codemirror-lang-json-CZ07HmNC.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-djiuoTi8.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CKHqhW5R.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-DtcZDGqe.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-C493X_9w.js","assets/vendor-codemirror-lang-python-DzzokVau.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-DYppkHEk.js","assets/vendor-tanstack-react-virtual-2skouoFw.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-CfplGuM0.js","assets/vendor-motion-dom-DhJ-sYS5.js","assets/vendor-motion-utils-CKEGc_YG.js","assets/useSwitcherItems-C91mwPJD.js","assets/SessionUnreadDot-Bv-5KguB.js"])))=>i.map(i=>d[i]);
2
- import{_ as a}from"./vendor-vite-runtime-DD1OZmLC.js";import{j as o,r as c,R as d}from"./vendor-react-B5Z1Mdn3.js";import{D as l,a as x,b as u}from"./useAppFontEffects-C4JL1x7k.js";import{u as m,c as f}from"./index-KIdiBFJs.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zustand-GVb4H8HE.js";import"./vendor-base-ui-vkqQ2P9o.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-BZOGXAGe.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-D0AXkdQC.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-sonner-BDtm25td.js";import"./vendor-codemirror-view-Ct4T37Ue.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./runtimeSurface-CySRuLbN.js";import"./vendor-dnd-kit-core-C9qcAm_1.js";import"./vendor-dnd-kit-utilities-DTY1C6ST.js";import"./vendor-dnd-kit-accessibility-DZKKhs9S.js";import"./vendor-dnd-kit-sortable-D8ozj8M-.js";import"./vendor-cmdk-zXx6sGnS.js";import"./vendor-radix-ui-react-dialog-D2yhEu2p.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-8xy6TJML.js";import"./vendor-radix-ui-react-context-CFsX-AUC.js";import"./vendor-radix-ui-react-id-D2kS9K1j.js";import"./vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js";import"./vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js";import"./vendor-radix-ui-react-dismissable-layer-DrorBNg9.js";import"./vendor-radix-ui-react-primitive-DkH8dMOR.js";import"./vendor-radix-ui-react-slot-BIDFZX0-.js";import"./vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js";import"./vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js";import"./vendor-radix-ui-react-focus-scope-D2BkImwt.js";import"./vendor-radix-ui-react-portal-YgCRIyi7.js";import"./vendor-radix-ui-react-presence-D432pCMB.js";import"./vendor-radix-ui-react-focus-guards-BfdFmL7c.js";import"./vendor-react-remove-scroll-vR1dy1aP.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-CSAHp1YF.js";import"./vendor-react-style-singleton-Ctw6HnYx.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-Vv4V8Nd1.js";import"./vendor-use-callback-ref-CVVuCyLj.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BByA_dGF.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-DuOEwJ3f.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-wd6iRebq.js";import"./vendor-codemirror-lang-json-CZ07HmNC.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-djiuoTi8.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CKHqhW5R.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-DtcZDGqe.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-C493X_9w.js";import"./vendor-codemirror-lang-python-DzzokVau.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-DYppkHEk.js";import"./vendor-tanstack-react-virtual-2skouoFw.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CfplGuM0.js";import"./vendor-motion-dom-DhJ-sYS5.js";import"./vendor-motion-utils-CKEGc_YG.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";const w=d.lazy(()=>a(()=>import("./SessionSwitcherContent-z9VYCXrT.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81])));function Bo({children:e,variant:r="default",scopeProjectId:s=null,align:n="start"}){const p=m(t=>t.isSessionDropdownOpen),i=m(t=>t.setSessionDropdownOpen);return o.jsxs(l,{open:p,onOpenChange:i,modal:!1,children:[o.jsx(x,{asChild:!0,children:e}),o.jsx(u,{align:n,sideOffset:6,className:f("overflow-hidden p-1 max-w-[calc(100vw-32px)]",r==="compact"?"w-[280px]":"w-[360px]"),children:p?o.jsx(c.Suspense,{fallback:o.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:"Loading…"}),children:o.jsx(w,{onSelect:()=>i(!1),variant:r,scopeProjectId:s})}):null})]})}export{Bo as SessionSwitcherDropdown};
@@ -1 +0,0 @@
1
- import{n as m,c as h}from"./index-KIdiBFJs.js";import{j as g}from"./vendor-react-B5Z1Mdn3.js";import{M as y,N as D,O as w}from"./useAppFontEffects-C4JL1x7k.js";const S="Awaiting first prompt";function F(e,t="Untitled Session"){const o=e?.title?.trim();return o||(e?.messageCount===0?S:t)}const I=(e,t,o)=>{const a=`${o}:`,r=new Set([...t].filter(s=>s.startsWith(a)));return e.size===r.size&&[...r].every(s=>e.has(s))?e:r},R=(e,t)=>{const o=new Set(e);return o.has(t)?o.delete(t):o.add(t),o},b=e=>{const t=new Date(e),o=new Date,a=(n,i)=>n.getFullYear()===i.getFullYear()&&n.getMonth()===i.getMonth()&&n.getDate()===i.getDate(),r=new Date(o);return r.setDate(o.getDate()-1),a(t,o)?"Today":a(t,r)?"Yesterday":t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}).replace(",","")},T=e=>{const t=new Date,o=new Date(e);if(((r,s)=>r.getFullYear()===s.getFullYear()&&r.getMonth()===s.getMonth()&&r.getDate()===s.getDate())(o,t)){const r=Date.now()-e;return r<6e4?"Just now":r<36e5?`${Math.floor(r/6e4)}min ago`:`${Math.floor(r/36e5)}h ago`}return b(e)},k=e=>{const t=Math.max(0,Date.now()-e),o=6e4,a=60*o,r=24*a,s=7*r,n=30*r,i=365*r;return t<a?`${Math.max(1,Math.floor(t/o))}m`:t<r?`${Math.floor(t/a)}h`:t<s?`${Math.floor(t/r)}d ago`:t<5*s?`${Math.floor(t/s)}w ago`:t<i?`${Math.floor(t/n)}mo`:`${Math.floor(t/i)}y ago`},d=e=>e.toLowerCase().replace(/[-_]/g,"").trim(),E=(e,t)=>e?d(e)!==d(t):!1,z=e=>{const t=new Map;return e.forEach(o=>{t.set(o.id,o)}),Array.from(t.values())},P=e=>`__archived__:${e}`,U=(e,t)=>{const o=m(e.directory??null),a=m(e.project?.worktree??null),r=o??a;if(!r)return"unassigned";if(t&&r===t)return"project root";const n=(t&&r.startsWith(`${t}/`)?r.slice(t.length+1):r).split("/").filter(Boolean);return n[n.length-1]??"unassigned"},j=e=>e.replace(/[-_]/g," ").replace(/\b\w/g,t=>t.toUpperCase()),B="0.75rem",M="size-4 shrink-0",p="min-w-0 truncate typography-ui-label font-normal",x=M,v=p,$="group relative my-0.5 flex w-full cursor-pointer items-center gap-1.5 rounded-xl px-3 py-2 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",Y=$,K=e=>e?x:M,O=e=>e?v:p,u=1e3,c=60*u,l=60*c,C=e=>{const t=Math.max(0,e);return t<c?`${Math.floor(t/u)}s`:t<l?`${Math.floor(t/c)}m ${Math.floor(t%c/u)}s`:`${Math.floor(t/l)}h ${Math.floor(t%l/c)}m`},N=1e3,W=({sessionId:e,running:t,className:o})=>{const a=y(e),r=D(e),s=w(t,N),n=t?Math.max(0,s-(a??s)):r;if(n===void 0)return null;const i=C(n),f=t?`Active for ${i}`:`Last turn took ${i}`;return g.jsx("span",{className:h("shrink-0 tabular-nums",t?"text-primary":"text-[var(--status-info)]",o),"aria-label":f,title:f,children:i})};function G({label:e,className:t}){return g.jsx("span",{className:h("size-1.5 shrink-0 rounded-full bg-foreground",t),"aria-label":e,title:e})}export{W as S,G as a,K as b,O as c,T as d,P as e,k as f,F as g,z as h,M as i,p as j,$ as k,E as l,B as m,j as n,I as o,U as r,Y as s,R as t};