@pi-chamber/web 0.7.2 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/assets/{DiagramEditor-TeJ1G_NN.js → DiagramEditor-D_3eJVSw.js} +1 -1
- package/dist/assets/DiagramView-pGYm0-DR.js +1 -0
- package/dist/assets/DiffView-BApPTLGp.js +18 -0
- package/dist/assets/FilesView-CiPpuGiF.js +6 -0
- package/dist/assets/GitView-uW3w_LlQ.js +8 -0
- package/dist/assets/JsonTreeView-CpgqCk9_.js +1 -0
- package/dist/assets/MarkdownRendererImpl-fI6n3kqT.js +12 -0
- package/dist/assets/PatchDiff-BRloGXPs.js +1 -0
- package/dist/assets/SessionSwitcherContent-BQc-vW4s.js +1 -0
- package/dist/assets/SessionSwitcherDropdown-v_8TaIZm.js +2 -0
- package/dist/assets/SessionUnreadDot-A7vSfll2.js +1 -0
- package/dist/assets/SettingsView-CphlZvfd.js +2 -0
- package/dist/assets/SettingsWindow-D7UDhYd4.js +1 -0
- package/dist/assets/ToolOutputDialog-wpU0ylYS.js +8 -0
- package/dist/assets/ToolPartDiffPreview-BvoQK5Gm.js +1 -0
- package/dist/assets/{VirtualizedFileDiff-sRc4lN0B.js → VirtualizedFileDiff-DdPbLdh7.js} +4 -4
- package/dist/assets/{Virtualizer-BxW2CJGB.js → Virtualizer-BSHVMKgK.js} +1 -1
- package/dist/assets/{appThemeRegistry-BK0dHKa6.js → appThemeRegistry-gegrE2dq.js} +1 -1
- package/dist/assets/collapsible-BO6FIjvn.js +1 -0
- package/dist/assets/computeVirtualFileMetrics-DMvXzUJh.js +3 -0
- package/dist/assets/contextFileOpenGuard-BwXQVjtS.js +1 -0
- package/dist/assets/gitStatusPredicates-CgNk6M2_.js +134 -0
- package/dist/assets/index-BebQicw3.css +1 -0
- package/dist/assets/index-Bkz23mZq.js +8 -0
- package/dist/assets/index-C3SyF-cA.js +1 -0
- package/dist/assets/isDiffPlainText-BboRbmcm.js +1 -0
- package/dist/assets/isFilePlainText-BpTnLRyI.js +1 -0
- package/dist/assets/main-CMOAwZnJ.js +135 -0
- package/dist/assets/main-xLwCWLu-.js +2 -0
- package/dist/assets/{markdownCore-BfuFM7mg.js → markdownCore-CmFv4H-w.js} +2 -2
- package/dist/assets/miniChat-Vwo4K1IK.js +2 -0
- package/dist/assets/mobile-BRaxtEoC.js +2 -0
- package/dist/assets/{permissionStore-BRcQ9Jgt.js → permissionStore-iKN1K2_x.js} +1 -1
- package/dist/assets/registerCustomTheme-DmolaWWZ.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-DM4rRUUz.js +2 -0
- package/dist/assets/renderMobileApp-DWWewNhc.js +11 -0
- package/dist/assets/runtimeEndpointReset-BF60eHSx.js +54 -0
- package/dist/assets/{runtimeSurface-DF3VwUlO.js → runtimeSurface-SmPSdfop.js} +1 -1
- package/dist/assets/themeResolver-yJ9XpNMI.js +1 -0
- package/dist/assets/{WindowsWindowControls-CCnU0ckO.js → useAppFontEffects-Bg-8jtrQ.js} +127 -500
- package/dist/assets/useFilesViewSearch-GLcYNIUV.js +7 -0
- package/dist/assets/usePushVisibilityBeacon-VSYBfNoY.js +10 -0
- package/dist/assets/useSwitcherItems-BkEt9K-N.js +1 -0
- package/dist/assets/vendor-base-ui-vkqQ2P9o.js +1 -0
- package/dist/assets/{vendor-beautiful-mermaid-r4GK_usS.js → vendor-beautiful-mermaid-DneUawHp.js} +1 -1
- package/dist/assets/{vendor-cmdk-BCEUzcHE.js → vendor-cmdk-zXx6sGnS.js} +1 -1
- package/dist/assets/{vendor-codemirror-autocomplete-BS2SpSAZ.js → vendor-codemirror-autocomplete-wd6iRebq.js} +1 -1
- package/dist/assets/{vendor-codemirror-commands-RrgJ8H_6.js → vendor-codemirror-commands-DYppkHEk.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-angular-ADhO_TUK.js → vendor-codemirror-lang-angular-DU_4KiiW.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp-BGCWj7Om.js → vendor-codemirror-lang-cpp-CmIT9Z5_.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-Ba8JZ6fp.js → vendor-codemirror-lang-css-djiuoTi8.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-DyTiHXo4.js → vendor-codemirror-lang-go-COZSwZYW.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-html-DK27qQri.js → vendor-codemirror-lang-html-CKHqhW5R.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-java-CvFfnhPQ.js → vendor-codemirror-lang-java-CNMP5hyC.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-javascript-BUlYhQ3o.js → vendor-codemirror-lang-javascript-DuOEwJ3f.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-jinja-wBMtAEvT.js → vendor-codemirror-lang-jinja-DaKn_b1k.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-CqayksDf.js → vendor-codemirror-lang-json-CZ07HmNC.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-Ct3-H1PB.js → vendor-codemirror-lang-less-wJdQiDBf.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-XspREksq.js → vendor-codemirror-lang-liquid-0z48Roi8.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-markdown-CvO36Y1p.js → vendor-codemirror-lang-markdown-DtcZDGqe.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-php-BlUF9cCe.js → vendor-codemirror-lang-php-W8plS-JQ.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-python-_2bIYTiJ.js → vendor-codemirror-lang-python-DzzokVau.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-rust-BdTYih_U.js → vendor-codemirror-lang-rust-C4ulBVpf.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-E6MhfOFk.js → vendor-codemirror-lang-sass-BkZJYEwS.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-B1BRhQSF.js → vendor-codemirror-lang-sql-HpQWHJjv.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-BYQJRa1Q.js → vendor-codemirror-lang-vue-DiBPljCc.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-D706yuyC.js → vendor-codemirror-lang-wast-DoABsogh.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-xml--MfWU6Dj.js → vendor-codemirror-lang-xml-BhLJhOCH.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-yaml-CRUFIbRX.js → vendor-codemirror-lang-yaml-D95i1Y5R.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-E2vgV9K3.js → vendor-codemirror-language-BByA_dGF.js} +2 -2
- package/dist/assets/{vendor-codemirror-language-data-C7_BPMCr.js → vendor-codemirror-language-data-B5cJDWBR.js} +2 -2
- package/dist/assets/{vendor-codemirror-search-8kyQdB3f.js → vendor-codemirror-search-BV44140v.js} +1 -1
- package/dist/assets/{vendor-codemirror-view-DSzLbZiS.js → vendor-codemirror-view-Ct4T37Ue.js} +1 -1
- package/dist/assets/{vendor-dnd-kit-accessibility-Cv52zwWT.js → vendor-dnd-kit-accessibility-DZKKhs9S.js} +1 -1
- package/dist/assets/{vendor-dnd-kit-core-GipZW2tY.js → vendor-dnd-kit-core-CP8ck10N.js} +1 -1
- package/dist/assets/{vendor-dnd-kit-sortable-Ct2QxIHb.js → vendor-dnd-kit-sortable-B-Icjoj4.js} +1 -1
- package/dist/assets/{vendor-dnd-kit-utilities-CrOcp0Bp.js → vendor-dnd-kit-utilities-DTY1C6ST.js} +1 -1
- package/dist/assets/{vendor-elkjs-CRCLNXjf.js → vendor-elkjs-mzfkf0ML.js} +1 -1
- package/dist/assets/{vendor-floating-ui-dom-Bkw82kL9.js → vendor-floating-ui-dom-WyXykhNi.js} +1 -1
- package/dist/assets/{vendor-floating-ui-react-dom-sVFnuruh.js → vendor-floating-ui-react-dom-BZOGXAGe.js} +1 -1
- package/dist/assets/vendor-framer-motion-CfplGuM0.js +1 -0
- package/dist/assets/{vendor-heic2any-L8hyfc24.js → vendor-heic2any-BHsbokcA.js} +1 -1
- package/dist/assets/{vendor-lru_map-B-cPXHXW.js → vendor-lru_map-Cy8fTs3_.js} +1 -1
- package/dist/assets/{vendor-motion-dom-DJLgZh4Q.js → vendor-motion-dom-DhJ-sYS5.js} +1 -1
- package/dist/assets/{vendor-motion-utils-BGh8QBgx.js → vendor-motion-utils-CKEGc_YG.js} +1 -1
- package/dist/assets/{vendor-pierre-theming-C6Z4M5_u.js → vendor-pierre-theming-Dgp7B_O4.js} +1 -1
- package/dist/assets/{vendor-qrcode-COsmt6jn.js → vendor-qrcode-B0KNSajT.js} +1 -1
- package/dist/assets/{vendor-radix-ui-react-compose-refs-D1GnwnP9.js → vendor-radix-ui-react-compose-refs-8xy6TJML.js} +1 -1
- package/dist/assets/{vendor-radix-ui-react-context-CM4yFQ2I.js → vendor-radix-ui-react-context-CFsX-AUC.js} +1 -1
- package/dist/assets/{vendor-radix-ui-react-dialog-jX3Dld8c.js → vendor-radix-ui-react-dialog-D2yhEu2p.js} +1 -1
- package/dist/assets/{vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js → vendor-radix-ui-react-dismissable-layer-DrorBNg9.js} +1 -1
- package/dist/assets/{vendor-radix-ui-react-focus-guards-D5MZ0nQs.js → vendor-radix-ui-react-focus-guards-BfdFmL7c.js} +1 -1
- package/dist/assets/{vendor-radix-ui-react-focus-scope-C2K7lNPv.js → vendor-radix-ui-react-focus-scope-D2BkImwt.js} +1 -1
- package/dist/assets/{vendor-radix-ui-react-id-BcxRjnbX.js → vendor-radix-ui-react-id-D2kS9K1j.js} +1 -1
- package/dist/assets/vendor-radix-ui-react-portal-YgCRIyi7.js +1 -0
- package/dist/assets/{vendor-radix-ui-react-presence-Btn-Dp7L.js → vendor-radix-ui-react-presence-D432pCMB.js} +1 -1
- package/dist/assets/{vendor-radix-ui-react-primitive-CfpW6_IT.js → vendor-radix-ui-react-primitive-DkH8dMOR.js} +1 -1
- package/dist/assets/{vendor-radix-ui-react-slot-BxUc3Pvz.js → vendor-radix-ui-react-slot-BIDFZX0-.js} +1 -1
- package/dist/assets/{vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js → vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js} +1 -1
- package/dist/assets/{vendor-radix-ui-react-use-controllable-state-C_ecoh35.js → vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js} +1 -1
- package/dist/assets/vendor-radix-ui-react-use-effect-event-D94va83M.js +1 -0
- package/dist/assets/{vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js → vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js} +1 -1
- package/dist/assets/vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js +1 -0
- package/dist/assets/{vendor-react-DYyjh7Q0.js → vendor-react-B5Z1Mdn3.js} +1 -1
- package/dist/assets/{vendor-react-drawio-Boqanm0j.js → vendor-react-drawio-BYDptOsj.js} +1 -1
- package/dist/assets/{vendor-react-remove-scroll-bar-C9YRs2nU.js → vendor-react-remove-scroll-bar-CSAHp1YF.js} +1 -1
- package/dist/assets/{vendor-react-remove-scroll-CfeMe0DL.js → vendor-react-remove-scroll-vR1dy1aP.js} +1 -1
- package/dist/assets/{vendor-react-style-singleton-B1H4bWSG.js → vendor-react-style-singleton-Ctw6HnYx.js} +1 -1
- package/dist/assets/{vendor-replit-codemirror-vim-BJY5fGLS.js → vendor-replit-codemirror-vim-CGHHNQxC.js} +1 -1
- package/dist/assets/{vendor-sonner-CW8w438f.js → vendor-sonner-BDtm25td.js} +1 -1
- package/dist/assets/{vendor-tanstack-react-virtual-IrbCBGJ4.js → vendor-tanstack-react-virtual-2skouoFw.js} +1 -1
- package/dist/assets/{vendor-use-callback-ref-CJB0R85I.js → vendor-use-callback-ref-CVVuCyLj.js} +1 -1
- package/dist/assets/{vendor-use-sidecar-C-AuTczP.js → vendor-use-sidecar-Vv4V8Nd1.js} +1 -1
- package/dist/assets/{vendor-use-sync-external-store-B7OScDIw.js → vendor-use-sync-external-store-D0AXkdQC.js} +1 -1
- package/dist/assets/{vendor-zustand-CnsBKjP5.js → vendor-zustand-GVb4H8HE.js} +1 -1
- package/dist/assets/{web-components-BYNCGylQ.js → web-components-0H9kvZwn.js} +2 -2
- package/dist/index.html +6 -6
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +5 -5
- package/package.json +1 -1
- package/server/lib/git/DOCUMENTATION.md +3 -2
- package/server/lib/git/routes.js +27 -0
- package/server/lib/git/routes.test.js +41 -0
- package/server/lib/git/service.js +7 -1
- package/server/lib/git/service.test.js +23 -0
- package/server/lib/pi/routes.js +263 -6
- package/server/lib/pi/routes.test.js +314 -1
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +2 -2
- package/server/lib/pi/session-daemon/prompt-operations.test.js +318 -0
- package/server/lib/pi/session-daemon/session-daemon.js +309 -25
- package/server/lib/pi/session-daemon/session-daemon.test.js +137 -0
- package/server/lib/pi/session-daemon/supervisor.test.js +1 -1
- package/server/lib/pi/snippets-store.js +400 -0
- package/server/lib/pi/snippets-store.test.js +252 -0
- package/server/lib/relay/host-client.test.js +79 -15
- package/server/lib/server/cors.js +4 -0
- package/server/lib/server/cors.test.js +8 -5
- package/dist/assets/CommitSection-DfAlM30E.js +0 -1
- package/dist/assets/DiagramView-DKLIwNth.js +0 -1
- package/dist/assets/DiffView-CZyqSs5W.js +0 -18
- package/dist/assets/FilesView-rftA7fEL.js +0 -14
- package/dist/assets/GitView-D5LMTT2M.js +0 -6
- package/dist/assets/JsonTreeView-DMI3-Smy.js +0 -1
- package/dist/assets/MarkdownRendererImpl-gdd-5n9J.js +0 -12
- package/dist/assets/PatchDiff-GNB1NlAN.js +0 -1
- package/dist/assets/PierreDiffViewer-DmJv2AoJ.js +0 -136
- package/dist/assets/SessionSwitcherContent-CWdDPll7.js +0 -1
- package/dist/assets/SessionSwitcherDropdown-Cx-Jfmvo.js +0 -2
- package/dist/assets/SessionUnreadDot-CKe4uVcf.js +0 -1
- package/dist/assets/SettingsView-DaxkNy5C.js +0 -4
- package/dist/assets/SettingsWindow-D1M_rRDo.js +0 -1
- package/dist/assets/ToolOutputDialog-CUKcp77A.js +0 -15
- package/dist/assets/ToolPartDiffPreview-CkzwXAC5.js +0 -8
- package/dist/assets/collapsible-B0cIItyf.js +0 -1
- package/dist/assets/computeVirtualFileMetrics-B1uVA58l.js +0 -3
- package/dist/assets/contextFileOpenGuard-BuedQ5EQ.js +0 -1
- package/dist/assets/index-BA67uOfZ.js +0 -1
- package/dist/assets/index-CcbDTf8Q.js +0 -8
- package/dist/assets/index-Cl3XbCeC.css +0 -1
- package/dist/assets/isDiffPlainText-DLDFLL6P.js +0 -1
- package/dist/assets/isFilePlainText-B2wwrpRU.js +0 -1
- package/dist/assets/main-B5k0qpHJ.js +0 -133
- package/dist/assets/main-Bepu8Jr9.js +0 -2
- package/dist/assets/miniChat-Co0Snpgl.js +0 -2
- package/dist/assets/mobile-CSvL_Zyu.js +0 -2
- package/dist/assets/registerCustomTheme-BBXUCRnG.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-DrMJ1RXX.js +0 -2
- package/dist/assets/renderMobileApp-B2toAnMW.js +0 -14
- package/dist/assets/themeResolver-BmJyTmjJ.js +0 -1
- package/dist/assets/useInlineCommentController-CxMP78jg.js +0 -2
- package/dist/assets/usePanelSlide-DUuoQt5X.js +0 -56
- package/dist/assets/usePushVisibilityBeacon-CSPdFBaA.js +0 -10
- package/dist/assets/useSwitcherItems-zOeC2Cta.js +0 -1
- package/dist/assets/vendor-base-ui-DL8r2fgQ.js +0 -1
- package/dist/assets/vendor-framer-motion-DJASDzNt.js +0 -1
- package/dist/assets/vendor-radix-ui-react-portal-xlJWBfDg.js +0 -1
- package/dist/assets/vendor-radix-ui-react-use-effect-event-DkJl_Rn_.js +0 -1
- package/dist/assets/vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js +0 -1
- package/dist/assets/vendor-remixicon-react-CzPq62YO.js +0 -1
- /package/dist/assets/{usePanelSlide-BV3KOtdA.css → runtimeEndpointReset-BV3KOtdA.css} +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiffView-BApPTLGp.js","assets/vendor-react-B5Z1Mdn3.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-Bkz23mZq.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-BebQicw3.css","assets/useAppFontEffects-Bg-8jtrQ.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-SmPSdfop.js","assets/vendor-dnd-kit-core-CP8ck10N.js","assets/vendor-dnd-kit-utilities-DTY1C6ST.js","assets/vendor-dnd-kit-accessibility-DZKKhs9S.js","assets/vendor-dnd-kit-sortable-B-Icjoj4.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-B5cJDWBR.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-CgNk6M2_.js","assets/web-components-0H9kvZwn.js","assets/computeVirtualFileMetrics-DMvXzUJh.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-DdPbLdh7.js","assets/isDiffPlainText-BboRbmcm.js","assets/vendor-diff-C3JhlQdm.js","assets/runtimeEndpointReset-BF60eHSx.js","assets/SessionUnreadDot-A7vSfll2.js","assets/permissionStore-iKN1K2_x.js","assets/runtimeEndpointReset-BV3KOtdA.css","assets/appThemeRegistry-gegrE2dq.js","assets/registerCustomTheme-DmolaWWZ.js","assets/contextFileOpenGuard-BwXQVjtS.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as gs}from"./vendor-vite-runtime-DD1OZmLC.js";import{R as n,j as e,r as Ge}from"./vendor-react-B5Z1Mdn3.js";import{j as ot,k as $t,bv as Xt,aQ as ve,aR as we,bi as Ce,I,bj as Ne,bk as Fe,U as T,t as S,E as Pe,F as Ae,G as ze,D as xs,a as bs,b as ys,bm as Dn,aP as js,bC as Bn,ao as Tn,cd as Gn,ce as On,cf as _n,cg as Hn,ch as Un,bM as vs,bN as ws,bO as Cs,bP as Ns,bQ as Pt,bR as At,ci as Vn,bl as _e,bg as Zt,cj as Wn,ck as Kn,b9 as qn,af as Yn,b6 as Jn,bh as Ss,cl as Qn,bD as ks,p as Xn,aB as Zn,ba as ea,bb as ta,cm as sa,cn as na,co as aa,bc as ra,cp as ia,Q as oa,L as la,be as ca}from"./useAppFontEffects-Bg-8jtrQ.js";import{K as da,L as ua,N as ha,O as ma}from"./runtimeEndpointReset-BF60eHSx.js";import{u as es}from"./vendor-zustand-GVb4H8HE.js";import{u as lt,ae as fa,c as ee,n as st}from"./index-Bkz23mZq.js";import{C as pa,a as ga,b as xa}from"./collapsible-BO6FIjvn.js";import{P as Rs,d as ba,i as ts,a as ya}from"./gitStatusPredicates-CgNk6M2_.js";import{u as ja}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-SmPSdfop.js";import"./vendor-dnd-kit-core-CP8ck10N.js";import"./vendor-dnd-kit-utilities-DTY1C6ST.js";import"./vendor-dnd-kit-accessibility-DZKKhs9S.js";import"./vendor-dnd-kit-sortable-B-Icjoj4.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-B5cJDWBR.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-A7vSfll2.js";import"./permissionStore-iKN1K2_x.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./web-components-0H9kvZwn.js";import"./computeVirtualFileMetrics-DMvXzUJh.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-DdPbLdh7.js";import"./isDiffPlainText-BboRbmcm.js";import"./vendor-diff-C3JhlQdm.js";import"./appThemeRegistry-gegrE2dq.js";import"./registerCustomTheme-DmolaWWZ.js";const Es="gitmojiCache",va=1e3*60*60*24*7,Fs="1",wa="https://raw.githubusercontent.com/carloscuesta/gitmoji/master/packages/gitmojis/src/gitmojis.json",Is=r=>{if(!r||typeof r!="object")return!1;const s=r;return typeof s.emoji=="string"&&typeof s.code=="string"&&typeof s.description=="string"},Et=()=>{if(typeof window>"u")return null;try{const r=window.localStorage.getItem(Es);if(!r)return null;const s=JSON.parse(r);return!s||s.version!==Fs||typeof s.fetchedAt!="number"||!Array.isArray(s.gitmojis)?null:{gitmojis:s.gitmojis.filter(Is),fetchedAt:s.fetchedAt,version:s.version}}catch{return null}},Ca=r=>{if(!(typeof window>"u"))try{const s={gitmojis:r,fetchedAt:Date.now(),version:Fs};window.localStorage.setItem(Es,JSON.stringify(s))}catch{return}},ss=r=>Date.now()-r.fetchedAt<va;let nt=null;const Oe=new Set,ns=async()=>{if(nt)return nt;const r=(async()=>{try{const s=await fetch(wa);if(!s.ok)throw new Error(`Failed to load gitmojis: ${s.statusText}`);const c=await s.json(),h=Array.isArray(c.gitmojis)?c.gitmojis.filter(Is):[];return Ca(h),Oe.forEach(a=>a(h)),h}catch(s){console.warn("Failed to load gitmoji list:",s);const c=[];return Oe.forEach(h=>h(c)),c}finally{nt=null}})();return nt=r,r},Na=r=>{const[s,c]=n.useState(()=>r?Et()?.gitmojis??[]:[]),[h,a]=n.useState(!1),t=n.useRef(r);t.current=r,n.useEffect(()=>{if(!r){Oe.delete(c),c([]),a(!1);return}const b=Et();if(b&&(c(b.gitmojis),ss(b)))return;Oe.add(c),a(!0);let d=!1;return ns().finally(()=>{!d&&t.current&&a(!1)}),()=>{d=!0,Oe.delete(c)}},[r]);const m=n.useCallback(async()=>{if(!t.current)return[];if(s.length>0)return s;const b=Et();return b&&ss(b)?b.gitmojis:ns()},[s]);return{gitmojis:s,isLoading:h,ensureLoaded:m}},Sa=({open:r,onOpenChange:s,conflictFiles:c=[],directory:h,operation:a,onAbort:t,onClearState:m})=>{const{git:b}=ot(),d=$t(x=>x.openNewSessionDraft),y=$t(x=>x.currentSessionId),C=Xt(x=>x.setPendingInputText),k=Xt(x=>x.setPendingSyntheticParts),j=lt(x=>x.setActiveMainTab),[p,o]=n.useState(!1),[w,R]=n.useState(null),[E,M]=n.useState(null);n.useEffect(()=>{!r||!h||(o(!0),M(null),R(null),b.getConflictDetails(h).then(x=>{R(x)}).catch(x=>{const D=x instanceof Error?x.message:"Failed to load conflict details";M(D)}).finally(()=>{o(!1)}))},[h,b,r]);const U=n.useCallback(async()=>{if(!w)return null;const x=a==="merge"?"merge":"rebase",D=w.headInfo||(a==="merge"?"MERGE_HEAD":"REBASE_HEAD"),J=a==="merge"?"git commit --no-edit":"git rebase --continue",X=`Investigate the ${x} conflicts and concisely report the intended resolution strategy without making modifications. Wait for confirmation before resolving, staging, or continuing the ${x}. Preserve the intent of changes from ${D}.`,te=`Git ${x} operation is in progress with conflicts.
|
|
3
|
+
- Directory: ${h}
|
|
4
|
+
- Operation: ${a}
|
|
5
|
+
- Head Info: ${w.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 ${J}. After confirmation, remove all conflict markers, preserve intent from both sides, verify syntax, and complete the ${x}.`,q=`${x} conflict context (JSON)
|
|
8
|
+
${JSON.stringify({directory:h,operation:w.operation,headInfo:w.headInfo,statusPorcelain:w.statusPorcelain,unmergedFiles:w.unmergedFiles,diff:w.diff},null,2)}`;return{visibleText:X,instructionsText:te,payloadText:q}},[w,h,a]),V=()=>{t(),s(!1)},G=()=>{m?.(),s(!1)},P=async()=>{const x=await U();if(!x){S.error("No conflict details available");return}if(!y){S.error("No active session",{description:"Open or create a session to resolve conflicts."});return}C(x.visibleText,"replace"),k([{text:x.instructionsText,synthetic:!0},{text:x.payloadText,synthetic:!0}]),j("chat"),m?.(),s(!1)},A=async()=>{const x=await U();if(!x){S.error("No conflict details available");return}d({directoryOverride:h,initialPrompt:x.visibleText,syntheticParts:[{text:x.instructionsText,synthetic:!0},{text:x.payloadText,synthetic:!0}]}),j("chat"),m?.(),s(!1)},$=a==="merge"?"Merge":"Rebase",z=w?.unmergedFiles||c;return e.jsx(ve,{open:r,onOpenChange:s,children:e.jsx(we,{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(I,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),e.jsx(Ne,{children:`${$} conflicts detected`})]}),e.jsx(Fe,{children:`Resolve the ${a} conflicts to continue.`})]}),p&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-muted-foreground",children:[e.jsx(I,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"typography-meta",children:"Loading conflict details..."})]}),E&&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: ${E}`}),z.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:z.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:z.map(x=>e.jsx("li",{className:"typography-micro text-foreground font-mono truncate block",title:x,children:x},x))})})]}),w?.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:w.headInfo})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-2",children:[e.jsxs(T,{variant:"default",onClick:()=>{A()},disabled:p||!w,className:"w-full gap-2",children:[p?e.jsx(I,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(I,{name:"add",className:"size-4"}),"Resolve in new session"]}),e.jsxs(T,{variant:"outline",onClick:()=>{P()},disabled:p||!w||!y,className:"w-full gap-2",children:[p?e.jsx(I,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(I,{name:"chat-1",className:"size-4"}),"Resolve in current session"]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(T,{variant:"ghost",size:"sm",onClick:G,className:"flex-1",children:"Continue later"}),e.jsx(T,{variant:"destructive",size:"sm",onClick:V,className:"flex-1",children:`Abort ${$}`})]})]})]})})})},Re=8,ka=({laned:r,totalLanes:s,isExpanded:c})=>{const{lane:h,color:a,connectors:t}=r,b=Math.max(s,h+1)*Re+Re/2,d=n.useRef(null),y=n.useRef(null);return n.useLayoutEffect(()=>{const C=d.current,k=y.current;if(!C||!k)return;const j=C.offsetHeight;if(j===0)return;const p=window.devicePixelRatio||1;k.width=b*p,k.height=j*p;const o=k.getContext("2d");if(!o)return;o.scale(p,p),o.clearRect(0,0,b,j);const w=j/2,R=h*Re+Re/2,E=getComputedStyle(k),M=E.getPropertyValue("--surface-muted-foreground").trim()||E.color,U=P=>{if(!P.startsWith("var("))return P;const A=P.slice(4,-1).trim();return E.getPropertyValue(A).trim()||M},V=[...t].sort((P,A)=>{const $=z=>z==="branch-out"||z==="merge-in";return($(P.type)?1:0)-($(A.type)?1:0)});for(const P of V){const A=P.fromLane*Re+Re/2,$=P.toLane*Re+Re/2,z=P.type==="passing"?.72:P.type==="branch-out"||P.type==="merge-in"?.95:1;switch(o.beginPath(),o.strokeStyle=U(P.color),o.globalAlpha=z,o.lineWidth=1.25,o.lineCap="round",P.type){case"passing":case"commit-lane":o.moveTo(A,0),o.lineTo(A,j);break;case"top-stub":o.moveTo(A,0),o.lineTo(A,w);break;case"bottom-stub":o.moveTo(A,w),o.lineTo(A,j);break;case"branch-out":{const x=(w+j)/2;o.moveTo(R,w),o.bezierCurveTo(R,x,$,x,$,j);break}case"merge-in":{const x=w/2;o.moveTo(A,0),o.bezierCurveTo(A,x,R,x,R,w);break}default:continue}o.stroke(),o.globalAlpha=1}const G=E.getPropertyValue("--background").trim()||E.getPropertyValue("--surface-background").trim();o.beginPath(),o.arc(R,w,4,0,Math.PI*2),o.fillStyle=U(a),o.fill(),o.beginPath(),o.arc(R,w,5,0,Math.PI*2),o.strokeStyle=G||M,o.lineWidth=2,o.stroke()},[r,h,a,t,s,c,b]),e.jsx("div",{ref:d,style:{width:b,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"}})})},as=15e3,rs=500,is=12,os=8*1024*1024,ls=r=>typeof r=="string"?0:(r.original?.length??0)+(r.modified?.length??0),cs=r=>{if(r.size<=is){let a=0;for(const t of r.values())a+=ls(t);if(a<=os)return r}const s=Array.from(r.entries()).reverse(),c=new Map;let h=0;for(const[a,t]of s){if(c.size>=is)continue;const m=ls(t);h+m>os&&c.size>0||(c.set(a,t),h+=m)}return new Map(Array.from(c.entries()).reverse())};function ds(r,s){const c=new Date(r);return Number.isNaN(c.getTime())?r:Bn(c,s,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Ra(r){switch(r){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 Ea(r){return r?r.split(",").map(s=>s.trim()).filter(Boolean).map(s=>{const c=s.startsWith("HEAD ->");return{label:c?s.replace("HEAD -> ",""):s.replace("tag: ",""),isHead:c,isTag:s.startsWith("tag: ")}}):[]}const Fa=n.memo(({entry:r,mode:s="history",laned:c,totalLanes:h,isExpanded:a,onToggle:t,files:m,isLoadingFiles:b,onCopyHash:d,directory:y,onConflict:C,onActionSuccess:k})=>{const{git:j}=ot(),p=lt(l=>l.timeFormatPreference),o=s==="graph",w={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."},R={soft:"Soft — keep staged",mixed:"Mixed — unstage changes",hard:"Hard — discard all changes"},[E,M]=n.useState(null),[U,V]=n.useState(!1),[G,P]=n.useState(""),[A,$]=n.useState(null),[z,x]=n.useState(new Set),[D,J]=n.useState(new Map),[X,te]=n.useState(new Set),q=async()=>{if(y){M("checkout");try{await j.checkoutCommit(y,r.hash),S.success("Checked out (detached HEAD)"),k?.()}catch(l){S.error(String(l.message))}finally{M(null)}}},_=async()=>{if(!(!y||!G.trim())){M("createBranch");try{await j.createBranch(y,G.trim(),r.hash),V(!1),P(""),k?.()}catch(l){S.error(String(l.message))}finally{M(null)}}},re=async()=>{if(y){M("cherryPick");try{const l=await j.cherryPick(y,r.hash);l.conflict?C?.({conflict:!0,conflictFiles:l.conflictFiles,operation:"cherry-pick"}):k?.()}catch(l){S.error(String(l.message))}finally{M(null)}}},ie=async()=>{if(y){M("revert");try{const l=await j.revertCommit(y,r.hash);l.conflict?C?.({conflict:!0,conflictFiles:l.conflictFiles,operation:"revert"}):k?.()}catch(l){S.error(String(l.message))}finally{M(null)}}},oe=async(l,F=!1)=>{if(!(!y||E!==null)){M("reset");try{await j.resetToCommit(y,r.hash,l,F),k?.()}catch(W){S.error(String(W.message))}finally{M(null)}}},H=async()=>{if(!A)return;const l=A;switch($(null),l){case"checkout":return q();case"cherryPick":return re();case"revert":return ie();case"merge":return O();case"rebase":return B();case"resetSoft":return oe("soft");case"resetMixed":return oe("mixed");case"resetHard":return oe("hard",!0)}},O=async()=>{if(y){M("merge");try{const l=await j.merge(y,{branch:r.hash});l.conflict?C?.({conflict:!0,conflictFiles:l.conflictFiles,operation:"merge"}):k?.()}catch(l){S.error(String(l.message))}finally{M(null)}}},B=async()=>{if(y){M("rebase");try{const l=await j.rebase(y,{onto:r.hash});l.conflict?C?.({conflict:!0,conflictFiles:l.conflictFiles,operation:"rebase"}):k?.()}catch(l){S.error(String(l.message))}finally{M(null)}}},v=n.useCallback(async l=>{const F=l.path;if(!y){J(W=>new Map(W).set(F,"error"));return}J(W=>cs(new Map(W).set(F,"loading")));try{const Z=(j.getCommitFileDiff??fa)(y,r.hash,l.path,!1),ue=new Promise((se,De)=>{setTimeout(()=>De(new Error(`Timed out after ${as}ms`)),as)}),le=await Promise.race([Z,ue]);J(se=>cs(new Map(se).set(F,le)))}catch{J(W=>new Map(W).set(F,"error"))}},[y,r.hash,j.getCommitFileDiff]),N=n.useCallback(async l=>{const F=l.path;if(l.changeType==="R"||l.isBinary){x(le=>{const se=new Set(le);return se.has(F)?se.delete(F):se.add(F),se});return}const W=D.get(F);if(z.has(F)&&W&&W!=="error"){x(le=>{const se=new Set(le);return se.delete(F),se});return}x(le=>{const se=new Set(le);return se.add(F),se}),!(W&&W!=="error"||l.insertions+l.deletions>rs&&!X.has(F))&&await v(l)},[D,X,v,z]);return e.jsxs("li",{children:[e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":a,onClick:t,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),t())},className:ee("w-full flex items-start gap-3 px-3 py-2 text-left transition-colors",o?"hover:bg-[var(--interactive-hover)]/40":a?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[o&&c&&h!==void 0?e.jsx("div",{className:"-my-2 shrink-0 self-stretch",children:e.jsx(ka,{laned:c,totalLanes:h,isExpanded:a})}):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:[o?(()=>{const l=Ea(r.refs);return l.length>0?e.jsx("div",{className:"flex flex-wrap gap-1 mb-0.5",children:l.map(F=>e.jsx("span",{className:ee("inline-flex items-center px-1.5 py-0 typography-micro rounded font-medium",F.isHead?"bg-[var(--chart-1)] text-[var(--primary-foreground)]":F.isTag?"bg-[var(--chart-5)] text-[var(--primary-foreground)]":"bg-[var(--interactive-hover)] text-[var(--foreground)]"),children:F.label},F.label))}):null})():null,e.jsx("p",{className:"typography-ui-label font-medium text-foreground line-clamp-1",children:r.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:r.author_name,children:r.author_name}),e.jsx("span",{className:"shrink-0",children:"·"}),e.jsx("span",{className:"truncate min-w-0",title:ds(r.date,p),children:ds(r.date,p)})]}),e.jsx("span",{className:"shrink-0",children:"·"}),e.jsx("code",{className:"shrink-0 font-mono",children:r.hash.slice(0,8)}),e.jsxs(Pe,{children:[e.jsx(Ae,{asChild:!0,children:e.jsx(T,{variant:"ghost",size:"sm",className:"h-5 px-1 shrink-0",onClick:l=>{l.stopPropagation(),d(r.hash)},children:e.jsx(I,{name:"file-copy",className:"size-3"})})}),e.jsx(ze,{sideOffset:8,children:"Copy SHA"})]})]})]})]}),a&&e.jsxs("div",{className:"px-3 pb-2 pl-8 border-t border-border/40",children:[o&&A?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:w[A]}),e.jsxs(T,{variant:"destructive",size:"xs",className:"h-6 shrink-0",disabled:E!==null,onClick:l=>{l.stopPropagation(),H()},children:[E!==null?e.jsx(I,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,"Confirm"]}),e.jsx(T,{variant:"ghost",size:"xs",className:"h-6 shrink-0",disabled:E!==null,onClick:l=>{l.stopPropagation(),$(null)},children:"Cancel"})]}):o?e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 py-2 border-b border-border/30 mb-2",children:[e.jsx(T,{variant:"outline",size:"xs",className:"h-6",disabled:E!==null,onClick:l=>{l.stopPropagation(),$("checkout")},children:"Checkout"}),U?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{autoFocus:!0,value:G,onChange:l=>P(l.target.value),onKeyDown:l=>{l.key==="Enter"&&_(),l.key==="Escape"&&(V(!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(T,{variant:"outline",size:"xs",className:"h-6",disabled:!G.trim()||E!==null,onClick:l=>{l.stopPropagation(),_()},children:[E==="createBranch"?e.jsx(I,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,"Create"]})]}):e.jsx(T,{variant:"outline",size:"xs",className:"h-6",onClick:l=>{l.stopPropagation(),V(!0)},children:"Create branch here"}),e.jsx(T,{variant:"outline",size:"xs",className:"h-6",disabled:E!==null,onClick:l=>{l.stopPropagation(),$("cherryPick")},children:"Cherry-pick"}),e.jsx(T,{variant:"outline",size:"xs",className:"h-6",disabled:E!==null,onClick:l=>{l.stopPropagation(),$("revert")},children:"Revert"}),e.jsxs(xs,{children:[e.jsx(bs,{asChild:!0,children:e.jsxs(T,{variant:"outline",size:"xs",className:"h-6",disabled:E!==null,onClick:l=>l.stopPropagation(),children:[E==="reset"?e.jsx(I,{name:"loader-4",className:"size-3 animate-spin mr-1"}):null,"Reset..."]})}),e.jsx(ys,{align:"start",className:"min-w-max",children:["soft","mixed","hard"].map(l=>e.jsx(Dn,{disabled:E!==null,onSelect:F=>{F.stopPropagation(),$(`reset${l.charAt(0).toUpperCase()+l.slice(1)}`)},children:R[l]},l))})]}),e.jsx(T,{variant:"outline",size:"xs",className:"h-6",disabled:E!==null,onClick:l=>{l.stopPropagation(),$("merge")},children:"Merge into current"}),e.jsx(T,{variant:"outline",size:"xs",className:"h-6",disabled:E!==null,onClick:l=>{l.stopPropagation(),$("rebase")},children:"Rebase onto this"})]}):null,b?e.jsxs("div",{className:"flex items-center gap-2 py-2",children:[e.jsx(I,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}),e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Loading files..."})]}):m.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:m.map(l=>e.jsxs("li",{children:[e.jsxs("button",{type:"button",onClick:()=>N(l),className:ee("w-full flex items-center gap-2 typography-micro text-left cursor-pointer transition-colors rounded px-1",z.has(l.path)?"bg-sidebar/90":"hover:bg-sidebar/40"),children:[e.jsx("span",{className:ee("font-semibold w-3 text-center shrink-0",Ra(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(I,{name:z.has(l.path)?"arrow-down-s":"arrow-right-s",className:"size-3 shrink-0 text-muted-foreground"})]}),z.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 F=l.insertions+l.deletions;if(!X.has(l.path)&&F>rs)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 (${F} 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(T,{type:"button",variant:"ghost",size:"xs",className:"h-6 px-0 text-primary hover:bg-transparent hover:underline",onClick:()=>{te(Z=>new Set(Z).add(l.path)),v(l)},children:"Render anyway"})]});const W=D.get(l.path);return W==="loading"||W===void 0?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Loading diff..."}):W==="error"?e.jsx("button",{type:"button",onClick:()=>N(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(Rs,{original:W.original,modified:W.modified,language:js(l.path)||"",fileName:l.path,renderSideBySide:!1,layout:"inline"})})()})]},l.path))})]})]})}),us=["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 at(r){return us[r%us.length]}function Ia(r){if(r.length===0)return[];const s=[],c=[];for(let h=0;h<r.length;h++){const a=r[h],t=[];for(let p=0;p<s.length;p++)s[p]===a.hash&&t.push(p);let m=t.length>0?t[0]:-1;if(m===-1){const p=s.indexOf(null);p!==-1?m=p:(m=s.length,s.push(null))}const b=t.slice(1),d=at(m),y=s[m]===a.hash,C=a.parents.length>0;C?s[m]=a.parents[0]:s[m]=null;const k=[];for(let p=1;p<a.parents.length;p++){const o=a.parents[p],w=s.indexOf(o);if(w!==-1)k.push(w);else{const R=s.indexOf(null),E=R!==-1?R:s.length;s[E]=o,E===s.length&&s.push(o),k.push(E)}}const j=[];y&&C?j.push({fromLane:m,toLane:m,color:d,type:"commit-lane"}):y&&!C?j.push({fromLane:m,toLane:m,color:d,type:"top-stub"}):!y&&C&&j.push({fromLane:m,toLane:m,color:d,type:"bottom-stub"});for(const p of b)j.push({fromLane:p,toLane:m,color:at(p),type:"merge-in"}),s[p]=null;for(const p of k)j.push({fromLane:m,toLane:p,color:at(p),type:"branch-out"});for(let p=0;p<s.length;p++)s[p]!==null&&p!==m&&(k.includes(p)||j.push({fromLane:p,toLane:p,color:at(p),type:"passing"}));c.push({commit:a,lane:m,color:d,connectors:j})}return c}const Ma=[{label:"25 commits",value:25},{label:"50 commits",value:50},{label:"100 commits",value:100}],La=({mode:r="history",log:s,isLogLoading:c,logMaxCount:h,onLogMaxCountChange:a,expandedCommitHashes:t,onToggleCommit:m,commitFilesMap:b,loadingCommitHashes:d,onCopyHash:y,directory:C,showHeader:k=!0,contentMaxHeightClassName:j="max-h-[50vh]",branchDivider:p=null,onConflict:o,onActionSuccess:w})=>{const[R,E]=n.useState(!0),M=r==="graph",U=n.useMemo(()=>M&&s?Ia(s.all):[],[M,s]),V=n.useMemo(()=>Math.max(1,...U.map(q=>q.lane+1)),[U]),G=n.useMemo(()=>new Map(U.map(q=>[q.commit.hash,q])),[U]);if(!s)return null;const P=p!==null&&p.insertBeforeIndex>0&&p.insertBeforeIndex<s.all.length,A=p!==null&&p.insertBeforeIndex===s.all.length,$=P||A,z=P?s.all.slice(0,p.insertBeforeIndex):A?s.all:[],x=P?s.all.slice(p.insertBeforeIndex):[],D=p?.direction==="down"?e.jsx(I,{name:"arrow-down-s",className:"size-3.5"}):e.jsx(I,{name:"arrow-up",className:"size-3.5"}),J=q=>e.jsx("ul",{className:"divide-y divide-border/60",children:q.map(_=>e.jsx(Fa,{entry:_,mode:r,laned:M?G.get(_.hash):void 0,totalLanes:M?V:void 0,isExpanded:t.has(_.hash),onToggle:()=>m(_.hash),files:b.get(_.hash)??[],isLoadingFiles:d.has(_.hash),onCopyHash:y,directory:C,onConflict:o,onActionSuccess:w},_.hash))}),X=s.all.length>=h?e.jsx("div",{className:"flex justify-center py-2 border-t border-border/40",children:e.jsx(T,{type:"button",variant:"ghost",size:"xs",onClick:()=>a(h+25),disabled:c,className:"px-3 text-muted-foreground hover:text-foreground",children:c?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(I,{name:"loader-4",className:"size-3 animate-spin"}),"Loading..."]}):"Load more"})}):null,te=e.jsx(Tn,{outerClassName:`min-h-0 ${j}`,className:"h-full w-full",children:s.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"})}):$&&p?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-0",children:[z.length>0?e.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:J(z)}):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}),D]}),e.jsx("span",{className:"h-px flex-1 bg-border/60"})]}),x.length>0?e.jsx("div",{className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:J(x)}):null]}),X]}):e.jsxs(e.Fragment,{children:[J(s.all),X]})});return k?e.jsxs(pa,{open:R,onOpenChange:E,className:"rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[e.jsxs(ga,{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:[R&&e.jsx("div",{onClick:q=>q.stopPropagation(),onPointerDown:q=>q.stopPropagation(),children:e.jsxs(Gn,{value:String(h),onValueChange:q=>a(Number(q)),disabled:c,children:[e.jsx(On,{size:"sm",className:"w-auto",disabled:c,children:e.jsx(_n,{placeholder:"Commits"})}),e.jsx(Hn,{children:Ma.map(q=>e.jsx(Un,{value:String(q.value),children:q.label},q.value))})]})}),R?e.jsx(I,{name:"arrow-up-s",className:"size-4 text-muted-foreground"}):e.jsx(I,{name:"arrow-down-s",className:"size-4 text-muted-foreground"})]})]}),e.jsx(xa,{children:te})]}):$?e.jsx("section",{className:"h-full min-h-0",children:te}):e.jsx("section",{className:"h-full min-h-0 rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:te})},$a=n.memo(function({mode:s,onOpenChange:c,onRefresh:h,isRefreshing:a,log:t,maxCount:m,onMaxCountChange:b,expandedCommitHashes:d,onToggleCommit:y,commitFilesMap:C,loadingCommitHashes:k,onCopyHash:j,directory:p,branchDivider:o,onConflict:w,onActionSuccess:R}){return s?e.jsx(ve,{open:s!==null,onOpenChange:c,children:e.jsxs(we,{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(Ne,{children:s==="graph"?"Graph":"History"}),e.jsxs(T,{type:"button",variant:"ghost",size:"sm",className:"mr-6 h-7 shrink-0 gap-1.5 px-2",onClick:h,disabled:a,title:"Refresh","aria-label":"Refresh",children:[e.jsx(I,{name:"refresh",className:ee("size-4",a&&"animate-spin")}),"Refresh"]})]}),e.jsx(Fe,{children:"Browse recent commits and inspect changed files."})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(La,{mode:s==="graph"?"graph":"history",log:t,isLogLoading:a,logMaxCount:m,onLogMaxCountChange:b,expandedCommitHashes:d,onToggleCommit:y,commitFilesMap:C,loadingCommitHashes:k,onCopyHash:j,directory:p,showHeader:!1,contentMaxHeightClassName:"h-full max-h-none",branchDivider:s==="graph"?null:o,onConflict:s==="graph"?w:void 0,onActionSuccess:s==="graph"?R:void 0})})]})}):null}),Pa=n.memo(function({open:s,onOpenChange:c,gitmojis:h,onSelect:a}){const[t,m]=Ge.useState(""),b=n.useMemo(()=>{if(h.length===0)return[];const d=t.trim().toLowerCase();return d?h.filter(y=>y.emoji.includes(d)||y.code.toLowerCase().includes(d)||y.description.toLowerCase().includes(d)):h},[h,t]);return e.jsx(ve,{open:s,onOpenChange:c,children:e.jsxs(we,{className:"max-w-md p-0 overflow-hidden",children:[e.jsx(Ce,{className:"px-4 pt-4",children:e.jsx(Ne,{children:"Insert gitmoji"})}),e.jsxs(vs,{className:"h-[420px]",children:[e.jsx(ws,{placeholder:"Search gitmoji...",value:t,onValueChange:m}),e.jsxs(Cs,{children:[e.jsx(Ns,{children:"No gitmoji found"}),e.jsx(Pt,{children:b.map(d=>e.jsxs(At,{onSelect:()=>a(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))})]})]})]})})}),Aa=({open:r,onOpenChange:s,operation:c,targetBranch:h,onConfirm:a})=>{const[t,m]=n.useState(!0),[b,d]=n.useState(!1),y=c==="merge"?"Merge":"Rebase",C=async()=>{d(!0);try{await a(t),s(!1)}catch(j){const p=j instanceof Error?j.message:`Failed to ${c}`;S.error(p)}finally{d(!1)}},k=()=>{b||s(!1)};return e.jsx(ve,{open:r,onOpenChange:b?void 0:s,children:e.jsxs(we,{className:"max-w-md",children:[e.jsxs(Ce,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{name:"alert",className:"size-5 text-[var(--status-warning)]"}),e.jsx(Ne,{children:"Uncommitted Changes"})]}),e.jsx(Fe,{children:`Stash your local changes before starting the ${c}.`})]}),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:[c==="merge"?"Merge":"Rebase"," ",c==="merge"?"with":"onto"," ",e.jsx("span",{className:"font-mono text-primary",children:h})]}),t&&e.jsx("li",{children:"Restore your stashed changes"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 py-2",children:[e.jsx(Vn,{checked:t,onChange:m,disabled:b,ariaLabel:"Restore stashed changes after operation"}),e.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!b&&m(!t),children:`Restore stashed changes after ${c}`})]}),e.jsxs(_e,{className:"gap-2",children:[e.jsx(T,{variant:"ghost",size:"sm",onClick:k,disabled:b,children:"Cancel"}),e.jsx(T,{variant:"default",size:"sm",onClick:C,disabled:b,className:"gap-1.5",children:b?e.jsxs(e.Fragment,{children:[e.jsx(I,{name:"loader-4",className:"size-4 animate-spin"}),"Processing..."]}):`${y}`})]})]})})},za=({open:r,onOpenChange:s,directory:c,hasUncommittedChanges:h,hasStagedChanges:a=!1,uncommittedFileCount:t,onChanged:m})=>{const{git:b}=ot(),[d,y]=n.useState([]),[C,k]=n.useState(!1),[j,p]=n.useState(""),[o,w]=n.useState(""),[R,E]=n.useState(null),[M,U]=n.useState({}),V=n.useCallback(async()=>{if(c){k(!0);try{const x=await b.listGitStashes(c);y(x.stashes),U({})}catch(x){S.error(x instanceof Error?x.message:"Failed to load stashes")}finally{k(!1)}}},[c,b]);n.useEffect(()=>{r&&V()},[V,r]),n.useEffect(()=>{if(!r||!c||d.length===0)return;let x=!1;const D=d.map(J=>J.ref);return b.countGitStashFiles(c,D).then(J=>{x||U(J.counts)}).catch(()=>{}),()=>{x=!0}},[c,b,r,d]);const G=n.useMemo(()=>{const x=j.trim().toLowerCase();return x?d.filter(D=>`${D.ref} ${D.message} ${D.relativeTime}`.toLowerCase().includes(x)):d},[j,d]),P=n.useCallback(async x=>{await V(),await m?.(x)},[V,m]),A=async()=>{if(!(!c||R)){E("create");try{const x=await b.stashGitChanges(c,{message:o.trim()||void 0});x.created?(S.success("Changes stashed"),w("")):S.info("No local changes to stash"),await P({affectsIndex:!!(x.created&&a)})}catch(x){S.error(x instanceof Error?x.message:"Failed to stash changes")}finally{E(null)}}},$=async(x,D)=>{if(!(!c||R)&&!(D==="drop"&&!window.confirm(`Drop ${x.ref}?`))){E(`${D}:${x.ref}`);try{D==="apply"&&await b.applyGitStash(c,{ref:x.ref}),D==="pop"&&await b.popGitStash(c,{ref:x.ref}),D==="drop"&&await b.dropGitStash(c,{ref:x.ref});const J=D==="apply"?"Stash applied":D==="pop"?"Stash popped":"Stash dropped";S.success(J),await P({affectsIndex:D!=="drop"})}catch(J){const X=D==="apply"?"Failed to apply stash":D==="pop"?"Failed to pop stash":"Failed to drop stash";S.error(J instanceof Error?J.message:X),await P({affectsIndex:D!=="drop"})}finally{E(null)}}},z=R!==null;return e.jsx(ve,{open:r,onOpenChange:s,children:e.jsxs(we,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[e.jsxs(Ce,{children:[e.jsxs(Ne,{className:"flex items-center gap-2",children:[e.jsx(I,{name:"archive-stack",className:"h-5 w-5"}),"Stashes"]}),e.jsx(Fe,{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(Zt,{value:o,onChange:x=>w(x.target.value),placeholder:"Stash name",disabled:z||!h,className:"flex-1"}),e.jsxs(T,{onClick:A,disabled:!h||z||!c,children:[R==="create"?e.jsx(I,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(I,{name:"inbox-archive",className:"size-4"}),`Stash ${t} 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(I,{name:"search",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Zt,{value:j,onChange:x=>p(x.target.value),placeholder:"Search stashes",className:"pl-9"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:C?e.jsx("div",{className:"flex items-center justify-center py-10 text-muted-foreground",children:e.jsx(I,{name:"loader-4",className:"size-5 animate-spin"})}):G.length===0?e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:j?"No matching stashes.":"No stashes yet."}):G.map((x,D)=>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:x.message||"Untitled stash"}),e.jsxs("p",{className:"typography-meta truncate text-muted-foreground",children:[e.jsxs(Pe,{children:[e.jsx(Ae,{asChild:!0,children:e.jsx("span",{children:D===0&&!j.trim()?"Latest":`#${D+1}`})}),e.jsx(ze,{sideOffset:6,children:x.ref})]})," · ",x.relativeTime," · ",typeof M[x.ref]=="number"?`${M[x.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(Ft,{label:"Apply",loading:R===`apply:${x.ref}`,onClick:()=>$(x,"apply"),disabled:z,children:e.jsx(I,{name:"inbox-unarchive",className:"size-4"})}),e.jsx(Ft,{label:"Pop",loading:R===`pop:${x.ref}`,onClick:()=>$(x,"pop"),disabled:z,children:e.jsx(I,{name:"inbox-unarchive-fill",className:"size-4"})}),e.jsx(Ft,{label:"Drop",loading:R===`drop:${x.ref}`,onClick:()=>$(x,"drop"),disabled:z,destructive:!0,children:e.jsx(I,{name:"delete-bin",className:"size-4"})})]})]},x.ref))})]})})},Ft=({label:r,loading:s,disabled:c,destructive:h,onClick:a,children:t})=>e.jsxs(Pe,{children:[e.jsx(Ae,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":r,"aria-busy":s||void 0,className:ee("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:a,disabled:c,children:s?e.jsx(I,{name:"loader-4",className:"size-4 animate-spin"}):t})}),e.jsx(ze,{sideOffset:6,children:r})]}),Da=({currentBranch:r,localBranches:s,remoteBranches:c,onMerge:h,onRebase:a,disabled:t=!1,isOperating:m=!1,operationLogs:b=[],onOperationComplete:d,mode:y="dialog",defaultTargetBranch:C})=>{const[k,j]=n.useState(!1),[p,o]=n.useState("merge"),[w,R]=n.useState(null),[E,M]=n.useState(!1),[U,V]=n.useState(""),G=n.useRef(null),P=n.useRef(null),A=t||m,$=r||"current branch",z=b.length>0&&b.every(B=>B.status==="done"||B.status==="error"),x=b.some(B=>B.status==="error");n.useEffect(()=>{P.current&&(P.current.scrollTop=P.current.scrollHeight)},[b]);const D=n.useMemo(()=>{const B=U.toLowerCase(),v=new Set(c.map(l=>l.slice(l.indexOf("/")+1)).filter(Boolean)),N=s.filter(l=>l!==r&&!v.has(l));return B?N.filter(l=>l.toLowerCase().includes(B)):N},[U,s,r,c]),J=n.useMemo(()=>{const B=U.toLowerCase();return B?c.filter(v=>v.toLowerCase().includes(B)):c},[U,c]),X=n.useCallback(()=>C&&(c.includes(C)||s.includes(C))?C:null,[C,s,c]),te=()=>{j(!0),R(X()),o("merge"),V("")},q=B=>{R(B),M(!1),V("")},_=()=>{w&&(p==="merge"?h(w):a(w))},re=()=>{m||(R(null),o("merge"),V(""),j(!1))},ie=()=>{m&&!z||(z&&d?.(),R(null),o("merge"),V(""),j(!1))};n.useEffect(()=>{E||V("")},[E]),n.useEffect(()=>{y==="dialog"||w||R(X())},[y,X,w]);const O=m?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:b.map((B,v)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"mt-0.5 shrink-0",children:[B.status==="running"&&e.jsx(I,{name:"loader-4",className:"size-3.5 animate-spin text-primary"}),B.status==="done"&&e.jsx(I,{name:"check",className:"size-3.5 text-success"}),B.status==="error"&&e.jsx(I,{name:"close",className:"size-3.5 text-destructive"}),B.status==="pending"&&e.jsx("div",{className:"size-3.5 rounded-full border border-muted-foreground/30"})]}),e.jsx("span",{className:ee("typography-micro",B.status==="error"&&"text-destructive",B.status==="done"&&"text-muted-foreground",B.status==="running"&&"text-foreground",B.status==="pending"&&"text-muted-foreground/60"),children:B.message})]},v))})}),z?y==="dialog"?e.jsx(_e,{children:e.jsx(T,{variant:"default",size:"sm",onClick:ie,children:x?"Close":"Done"})}):e.jsx("div",{className:"flex justify-end",children:e.jsx(T,{variant:"default",size:"sm",onClick:ie,children:x?"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:()=>o("merge"),className:ee("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(I,{name:"git-merge",className:ee("size-4",p==="merge"?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:ee("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:()=>o("rebase"),className:ee("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(I,{name:"git-branch",className:ee("size-4",p==="rebase"?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:ee("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 ${$}`:"Branch to rebase onto"}),e.jsxs(xs,{open:E,onOpenChange:M,modal:!1,children:[e.jsx(bs,{asChild:!0,children:e.jsxs("button",{type:"button",className:ee(Wn({size:"default"}),"w-full"),children:[e.jsx("span",{className:ee("truncate",!w&&"text-muted-foreground"),children:w||"Select Branch"}),e.jsx(I,{name:"arrow-down-s",className:"size-4 opacity-60 shrink-0"})]})}),e.jsx(ys,{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(vs,{className:"h-full min-h-0",children:[e.jsx(ws,{ref:G,placeholder:"Search branches...",value:U,onValueChange:V,onKeyDown:B=>B.stopPropagation()}),e.jsxs(Cs,{className:"h-full min-h-0",disableHorizontal:!0,children:[e.jsx(Ns,{children:"No branches found."}),D.length>0&&e.jsx(Pt,{heading:"Local branches",children:D.map(B=>e.jsx(At,{onSelect:()=>q(B),children:e.jsx("span",{className:"typography-ui-label text-foreground truncate",children:B})},`local-${B}`))}),D.length>0&&J.length>0?e.jsx(Kn,{}):null,J.length>0&&e.jsx(Pt,{heading:"Remote branches",children:J.map(B=>e.jsx(At,{onSelect:()=>q(B),children:e.jsx("span",{className:"typography-ui-label text-foreground truncate",children:B})},`remote-${B}`))})]})]})})]})]}),w?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:w})," ","into"," ",e.jsx("span",{className:"font-mono text-foreground",children:$})]}):e.jsxs(e.Fragment,{children:["This will rebase"," ",e.jsx("span",{className:"font-mono text-foreground",children:$})," ","onto"," ",e.jsx("span",{className:"font-mono text-foreground",children:w})]})})}):null,y==="dialog"?e.jsxs(_e,{className:"gap-2 pt-1",children:[e.jsx(T,{variant:"ghost",size:"sm",onClick:re,children:"Cancel"}),e.jsx(T,{variant:"default",size:"sm",onClick:_,disabled:!w,className:"gap-1.5",children:p==="merge"?e.jsxs(e.Fragment,{children:[e.jsx(I,{name:"git-merge",className:"size-4"}),"Merge"]}):e.jsxs(e.Fragment,{children:[e.jsx(I,{name:"git-branch",className:"size-4"}),"Rebase"]})})]}):e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(T,{variant:"destructive",size:"sm",onClick:re,disabled:A,children:"Reset"}),e.jsx("div",{className:"flex-1"}),e.jsx(T,{variant:"default",size:"sm",onClick:_,disabled:A||!w,children:p==="merge"?"Merge":"Rebase"})]})]});return y==="bare"?O: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:$}),"."]})]})}),e.jsx("div",{className:"pt-3",children:O})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Ae,{asChild:!0,children:e.jsxs(T,{variant:"outline",size:"sm",className:"gap-1.5",onClick:te,disabled:A,children:[m?e.jsx(I,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(I,{name:"git-merge",className:"size-4"}),e.jsx("span",{children:"Merge/Rebase"})]})}),e.jsx(ze,{sideOffset:8,children:"Update this branch from another branch."})]}),e.jsx(ve,{open:k,onOpenChange:B=>{B?j(!0):ie()},children:e.jsxs(we,{className:"max-w-md",children:[e.jsxs(Ce,{children:[e.jsx(Ne,{children:"Update branch"}),e.jsx(Fe,{children:m?z?x?"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:$}),"."]})})]}),O]})})]})},Ba=n.memo(function({open:s,onOpenChange:c,branchOperation:h,currentBranch:a,localBranches:t,remoteBranches:m,defaultTargetBranch:b,onMerge:d,onRebase:y,disabled:C,operationLogs:k,onOperationComplete:j,canShowBranchWorkflows:p}){return e.jsx(ve,{open:s,onOpenChange:o=>{!o&&h!==null||c(o)},children:e.jsxs(we,{className:"max-w-2xl min-h-[26rem]",children:[e.jsxs(Ce,{children:[e.jsx(Ne,{children:"Update branch"}),e.jsxs(Fe,{children:["Bring the latest changes into"," ",e.jsx("span",{className:"font-mono text-foreground",children:a??""}),"."]})]}),p?e.jsx(Da,{mode:"bare",currentBranch:a,localBranches:t,remoteBranches:m,defaultTargetBranch:b??void 0,onMerge:d,onRebase:y,disabled:C,isOperating:h!==null,operationLogs:k,onOperationComplete:j}):e.jsx("p",{className:"typography-meta text-muted-foreground",children:"Branch actions unavailable in this repository state"})]})})}),Ta=({currentDirectory:r,isUpdateBranchDialogOpen:s,setIsUpdateBranchDialogOpen:c,branchOperation:h,currentBranch:a,localBranches:t,remoteBranches:m,updateTargetBranch:b,onMerge:d,onRebase:y,isBusy:C,operationLogs:k,onOperationComplete:j,canShowBranchWorkflows:p,gitLogDialogMode:o,setGitLogDialogMode:w,onRefreshHistory:R,isLogRefreshing:E,log:M,maxCount:U,onMaxCountChange:V,expandedCommitHashes:G,onToggleCommit:P,commitFilesMap:A,loadingCommitHashes:$,onCopyHash:z,historyBranchDivider:x,onConflict:D,onActionSuccess:J,isStashesDialogOpen:X,setIsStashesDialogOpen:te,hasUncommittedChanges:q,hasStagedChanges:_,uncommittedFileCount:re,onStashesChanged:ie,isGitmojiPickerOpen:oe,setIsGitmojiPickerOpen:H,gitmojiEmojis:O,onSelectGitmoji:B,conflictDialogOpen:v,setConflictDialogOpen:N,conflictFiles:l,conflictOperation:F,onAbortConflict:W,onClearConflictState:Z,stashDialogOpen:ue,setStashDialogOpen:le,stashDialogOperation:se,stashDialogBranch:De,onConfirmStashAndRetry:Be})=>e.jsxs(e.Fragment,{children:[e.jsx(Ba,{open:s,onOpenChange:c,branchOperation:h,currentBranch:a,localBranches:t,remoteBranches:m,defaultTargetBranch:b,onMerge:d,onRebase:y,disabled:C,operationLogs:k,onOperationComplete:j,canShowBranchWorkflows:p}),e.jsx($a,{mode:o,onOpenChange:He=>{He||w(null)},onRefresh:R,isRefreshing:E,log:M,maxCount:U,onMaxCountChange:V,expandedCommitHashes:G,onToggleCommit:P,commitFilesMap:A,loadingCommitHashes:$,onCopyHash:z,directory:r??void 0,branchDivider:x,onConflict:D,onActionSuccess:J}),e.jsx(za,{open:X,onOpenChange:te,directory:r,hasUncommittedChanges:q,hasStagedChanges:_,uncommittedFileCount:re,onChanged:ie}),e.jsx(Pa,{open:oe,onOpenChange:H,gitmojis:O,onSelect:B}),r&&e.jsx(Sa,{open:v,onOpenChange:N,conflictFiles:l,directory:r,operation:F,onAbort:W,onClearState:Z}),e.jsx(Aa,{open:ue,onOpenChange:le,operation:se,targetBranch:De,onConfirm:Be})]}),Ga=20,$e=new Map;function Oa(r){return $e.get(r)??null}function _a(r,s){if($e.delete(r),$e.set(r,s),$e.size>Ga){const c=$e.keys().next().value;c!==void 0&&$e.delete(c)}}const It=38,rt=200,Ha=({value:r,onChange:s,placeholder:c,disabled:h=!1,hasTouchInput:a=!1,isMobile:t=!1})=>{const m=n.useRef(null),b=lt(d=>d.inputSpellcheckEnabled);return n.useLayoutEffect(()=>{const d=m.current;if(!d)return;const y=document.activeElement===d,C=()=>{d.style.height=`${It}px`;const j=d.scrollHeight,p=Math.min(Math.max(j,It),rt);d.style.height=`${p}px`,d.style.overflowY=j>rt?"auto":"hidden",j>rt&&!y&&(d.scrollTop=d.scrollHeight)};C();const k=window.requestAnimationFrame(C);return()=>{window.cancelAnimationFrame(k)}},[r]),e.jsx("textarea",{ref:m,value:r,onChange:d=>s(d.target.value),placeholder:c??"Commit message",rows:1,disabled:h,autoCorrect:a?"on":"off",autoCapitalize:a?"sentences":"off",spellCheck:t||b,className:ee("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:It,maxHeight:rt}})},Ms=({stagedCount:r,commitMessage:s,onCommitMessageChange:c,onCommit:h,onCommitAndPush:a,commitAction:t,hasPendingIndexMutation:m=!1,gitmojiEnabled:b,onOpenGitmojiPicker:d})=>{const y=r>0,C=s.trim()&&y&&t===null&&!m,{isMobile:k,hasTouchInput:j}=qn();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(Ha,{value:s,onChange:c,placeholder:"Commit message",disabled:t!==null,hasTouchInput:j,isMobile:k}),b&&e.jsxs(T,{variant:"outline",size:"sm",onClick:d,className:"w-fit",type:"button",children:[e.jsx(I,{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(T,{size:"sm",variant:"outline",onClick:h,disabled:!C,className:"commit-actions__btn whitespace-nowrap","aria-label":"Commit aria label",children:t==="commit"?e.jsxs(e.Fragment,{children:[e.jsx(I,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"commit-actions__label",children:"Committing..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(I,{name:"git-commit",className:"size-4"}),e.jsx("span",{className:"commit-actions__label",children:"Commit"})]})}),k?e.jsxs(Pe,{children:[e.jsx(Ae,{asChild:!0,children:e.jsx(T,{variant:"default",size:"sm",onClick:()=>a(),disabled:!C,className:"h-7 w-7 p-0","aria-label":"Commit and sync",children:t==="commitAndPush"?e.jsx(I,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(I,{name:"arrow-up",className:"size-3.5"})})}),e.jsx(ze,{side:"top",children:e.jsx("p",{children:"Commit & sync"})})]}):e.jsx(T,{size:"sm",variant:"default",onClick:()=>a(),disabled:!C,className:"commit-actions__btn","aria-label":"Commit and sync",children:t==="commitAndPush"?e.jsxs(e.Fragment,{children:[e.jsx(I,{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(I,{name:"arrow-up",className:"size-3.5"}),e.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:"Commit & sync"})]})})]})]})]})},Ua=({onOpenStashes:r})=>e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center",children:[e.jsx(I,{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"}),r?e.jsxs(T,{type:"button",variant:"outline",size:"sm",onClick:r,className:"gap-1.5",children:[e.jsx(I,{name:"archive-stack",className:"size-4"}),"Stashes"]}):null]}),Va=({mergeInProgress:r,rebaseInProgress:s,onContinue:c,onAbort:h,onResolveWithAI:a,conflictCount:t=0,isLoading:m=!1})=>{const[b,d]=n.useState(null),y=r&&r.head,C=s&&(s.headName||s.onto),k=y?"merge":C?"rebase":null;if(!k)return null;const j=async()=>{d("continue");try{await c()}finally{d(null)}},p=async()=>{d("abort");try{await h()}finally{d(null)}},o=b!==null,w=t>0,R=k==="merge"?"Merge":"Rebase";let E="";r?E=r.message?`Merging: ${r.message}`:`Merging ${r.head}`:s&&(E=s.headName?`Rebasing ${s.headName} onto ${s.onto||""}`:"Rebase in progress");const M=w?t===1?`${R} in progress: ${t} conflict`:`${R} in progress: ${t} conflicts`:`${R} in progress`,U=w?"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:M}),E&&e.jsx("p",{className:"typography-micro break-words text-muted-foreground",children:E})]}),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:U}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(T,{variant:"ghost",size:"sm",onClick:p,disabled:o||m,className:"gap-1.5",children:[b==="abort"?e.jsx(I,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(I,{name:"close",className:"size-4"}),"Abort"]}),w?a&&e.jsx(T,{variant:"default",size:"sm",onClick:a,disabled:o||m,children:"Resolve with AI"}):e.jsxs(T,{variant:"default",size:"sm",onClick:j,disabled:o||m,className:"gap-1.5",children:[b==="continue"?e.jsx(I,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(I,{name:"check",className:"size-4"}),"Continue"]})]})]})]})})};function Wa(r,s){const[c,h]=n.useState(new Set),[a,t]=n.useState(new Map),[m,b]=n.useState(new Set),d=n.useRef(a),y=n.useRef(m),C=n.useCallback(j=>{Yn(j).then(p=>{if(p.ok){S.success("Commit hash copied");return}S.error("Failed to copy")})},[]),k=n.useCallback(j=>{h(p=>{const o=new Set(p);return o.has(j)?o.delete(j):o.add(j),o})},[]);return n.useEffect(()=>{d.current=a},[a]),n.useEffect(()=>{y.current=m},[m]),n.useEffect(()=>{if(!r||!s)return;const j=Array.from(c).filter(o=>!d.current.has(o)&&!y.current.has(o));if(j.length===0)return;let p=!1;return b(o=>{const w=new Set(o);for(const R of j)w.add(R);return y.current=w,w}),Promise.all(j.map(o=>s.getCommitFiles(r,o).then(w=>({hash:o,files:w.files})).catch(w=>(console.error("Failed to fetch commit files:",w),{hash:o,files:[]})))).then(o=>{p||(t(w=>{const R=new Map(w);for(const{hash:E,files:M}of o)R.set(E,M);return d.current=R,R}),b(w=>{const R=new Set(w);for(const{hash:E}of o)R.delete(E);return y.current=R,R}))}),()=>{p=!0,b(o=>{let w=!1;const R=new Set(o);for(const E of j)R.delete(E)&&(w=!0);return w?(y.current=R,R):o})}},[c,r,s]),{expandedCommitHashes:c,commitFilesMap:a,loadingCommitHashes:m,handleCopyCommitHash:C,handleToggleCommit:k}}const Ka=r=>{const{remoteNames:s,localBranches:c,worktreeCreatedFromBranch:h,rootBranchHint:a,defaultBranch:t,headBranch:m}=r,b=typeof m=="string"?m.trim():"",d=p=>{if(!p)return"";let o=p.trim();if(!o||o==="HEAD")return"";if(c.includes(o))return o;o.startsWith("refs/heads/")&&(o=o.slice(11)),o.startsWith("heads/")&&(o=o.slice(6)),o.startsWith("remotes/")&&(o=o.slice(8));const w=o.indexOf("/");if(w>0){const R=o.slice(0,w);if(s.has(R)){const E=o.slice(w+1).trim();E&&(o=E)}}return o},y=p=>{const o=d(typeof p=="string"?p:"");return o&&o!==b?o:""},C=y(h);if(C)return C;const k=y(a);if(k)return k;const j=y(t);return j||(c.includes("main")?"main":c.includes("master")?"master":c.includes("develop")?"develop":"main")},qa=r=>{const{baseBranch:s,localBranches:c,remoteBranches:h}=r;return c.includes(s)?!0:h.some(a=>{const t=a.indexOf("/");return t>0&&a.slice(t+1)===s})},Ya=r=>r?r.filter(s=>!s.startsWith("remotes/")).sort():[],Ja=r=>r?r.filter(s=>s.startsWith("remotes/")).map(s=>s.replace(/^remotes\//,"")).sort():[],Qa=(r,s,c,h)=>{if(r.length>0)return r;const a=new Set,t=c?.trim();t&&t.includes("/")&&a.add(t.split("/")[0]);for(const m of s){const b=m.indexOf("/");b>0&&a.add(m.slice(0,b))}return a.size===0&&h&&a.add("origin"),Array.from(a).map(m=>({name:m,fetchUrl:h??"",pushUrl:h??""}))},Xa=(r,s)=>{const c=s?.trim().split("/")[0];return(c&&r?.[c])??r?.origin},Za=(r,s,c)=>c?r.map(t=>t.name).map(t=>`${t}/${c}`).find(t=>s.includes(t))??c:null;function er({branches:r,status:s,remotes:c,remoteUrl:h,git:a}){const t=n.useMemo(()=>Ya(r?.all),[r?.all]),m=n.useMemo(()=>Ja(r?.all),[r?.all]),b=n.useMemo(()=>Qa(c,m,s?.tracking,h),[c,m,h,s?.tracking]),d=s?.current??null,y=n.useMemo(()=>Xa(r?.defaultBranches,s?.tracking),[r?.defaultBranches,s?.tracking]),C=n.useMemo(()=>Ka({remoteNames:new Set(b.map(p=>p.name)),localBranches:t,defaultBranch:y,headBranch:d}),[d,y,b,t]),k=!!(d&&C&&d!==C&&(s?.tracking||b.length>0)&&typeof a?.getGitRangeDiff=="function"&&qa({baseBranch:C,localBranches:t,remoteBranches:m})),j=n.useMemo(()=>Za(b,m,C),[C,b,m]);return{localBranches:t,remoteBranches:m,effectiveRemotes:b,currentBranch:d,defaultBranch:y,baseBranch:C,branchScopeAvailable:k,updateTargetBranch:j}}const tr=r=>{if(!r)return null;try{let s=r.trim();s.startsWith("git@")&&(s=`https://${s.slice(4).replace(":","/")}`),s.endsWith(".git")&&(s=s.slice(0,-4));const c=new URL(s);return c.hostname+c.pathname}catch{return null}},sr=(r,s,c)=>{const h=new Map;s&&h.set(s.id,s);const a=tr(c);for(const t of r){if(t.authType!=="token"){h.set(t.id,t);continue}const m=t.host;if(!m){h.set(t.id,t);continue}if(!m.includes("/")){h.set(t.id,t);continue}a&&a===m&&h.set(t.id,t)}return Array.from(h.values())},nr=(r,s,c)=>{if(r?.userName&&r?.userEmail){const h=s.find(a=>a.userName===r.userName&&a.userEmail===r.userEmail);return h||(c&&c.userName===r.userName&&c.userEmail===r.userEmail?c:{id:"local-config",name:r.userName,userName:r.userName,userEmail:r.userEmail,sshKey:r.sshCommand?.replace("ssh -i ","")??null,color:"info",icon:"user"})}return c??null};function ar({profiles:r,globalIdentity:s,currentIdentity:c,remoteUrl:h}){const a=n.useMemo(()=>sr(r,s,h),[r,s,h]),t=n.useMemo(()=>nr(c,r,s),[c,r,s]);return{availableIdentities:a,activeIdentityProfile:t}}function rr({currentSessionId:r,currentDirectory:s}){const[c,h]=n.useState(!1),[a,t]=n.useState([]),[m,b]=n.useState("merge"),d=n.useMemo(()=>r?`pichamber.conflict:${r}`:null,[r]),y=n.useCallback((k,j,p)=>{if(!d||typeof window>"u")return;const o={directory:k,conflictFiles:j,operation:p};window.localStorage.setItem(d,JSON.stringify(o))},[d]),C=n.useCallback(()=>{!d||typeof window>"u"||window.localStorage.removeItem(d)},[d]);return n.useEffect(()=>{if(!d||typeof window>"u"||!s)return;const k=window.localStorage.getItem(d);if(k)try{const j=JSON.parse(k);if(j.directory!==s){window.localStorage.removeItem(d);return}t(j.conflictFiles??[]),b(j.operation??"merge"),h(!0)}catch{window.localStorage.removeItem(d)}},[d,s]),{conflictDialogOpen:c,setConflictDialogOpen:h,conflictFiles:a,setConflictFiles:t,conflictOperation:m,setConflictOperation:b,persistConflictState:y,clearConflictState:C}}const ir=({runMutation:r,onMutationComplete:s,onMutationError:c,onPathsComplete:h,scheduleFlush:a})=>{const t=[];let m=!1;return{enqueue:d=>{const y=t[t.length-1];if(y?.directory===d.directory&&y.direction===d.direction){d.paths.forEach(C=>y.paths.add(C));return}t.push(d)},flush:()=>{if(m)return;const d=t.shift();if(!d)return;m=!0;const y={directory:d.directory,direction:d.direction,paths:Array.from(d.paths),rollback:d.rollback};(async()=>{try{await r(y),s(y)}catch(C){c(y,C)}finally{h(y.paths),m=!1,t.length>0&&a()}})()},clear:()=>{t.length=0},size:()=>t.length,isRunning:()=>m}},or=n.memo(function({file:s,actionLabel:c,actionSymbol:h,onAction:a,onViewDiff:t,onRevert:m,isReverting:b,stats:d,rowPaddingClassName:y,indentPx:C=0,actionAtStart:k=!1,showRevert:j=!0}){const p=Ge.useMemo(()=>ba(s),[s]),o=p.description,w=d?.insertions??0,R=d?.deletions??0,E=Ge.useCallback(G=>{G.key===" "?(G.preventDefault(),a()):G.key==="Enter"&&(G.preventDefault(),t())},[a,t]),M=Ge.useCallback(G=>{G.preventDefault(),G.stopPropagation(),a()},[a]),U=Ge.useCallback(G=>{G.preventDefault(),G.stopPropagation(),m()},[m]),V=e.jsx("button",{type:"button",onClick:M,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,title:c,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:t,onKeyDown:E,style:C>0?{paddingLeft:`${C}px`}:void 0,children:[k?V:null,e.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:p.color},title:o,"aria-label":o,children:p.code}),e.jsx(Jn,{filePath:s.path,className:"h-3.5 w-3.5 shrink-0"}),(()=>{const G=s.path.lastIndexOf("/");if(G===-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:s.path,children:s.path});const P=s.path.slice(0,G),A=s.path.slice(G);return e.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:s.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:A.slice(1)})]})]})})(),e.jsxs("span",{className:"shrink-0 typography-micro",children:[e.jsxs("span",{style:{color:"var(--status-success)"},children:["+",w]}),e.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),e.jsxs("span",{style:{color:"var(--status-error)"},children:["-",R]})]}),j?e.jsxs(Pe,{children:[e.jsx(Ae,{asChild:!0,children:e.jsx("button",{type:"button",onClick:U,disabled:b,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 ${s.path}`,children:b?e.jsx(I,{name:"loader-4",className:"size-3.5 animate-spin"}):e.jsx(I,{name:"arrow-go-back",className:"size-3.5"})})}),e.jsx(ze,{sideOffset:8,children:"Revert changes"})]}):null,k?null:V]})}),hs=14,Ls=r=>r.replace(/\\/g,"/").replace(/^\/+/,"").trim(),ms=(r,s)=>({id:`dir:${r}`,path:r,name:s,children:new Map,directFiles:[],files:[]}),lr=r=>{const s=ms("","");for(const c of r){const h=Ls(c.path);if(!h)continue;const t=h.split("/").filter(Boolean).slice(0,-1);let m=s;if(m.files.push(c),t.length>0){let b="";for(const d of t){b=b?`${b}/${d}`:d;const y=m.children.get(d);if(y){y.files.push(c),m=y;continue}const C=ms(b,d);C.files.push(c),m.children.set(d,C),m=C}}m.directFiles.push(c)}return s},cr=(r,s)=>{const c=[],h=(a,t)=>{const m=Array.from(a.children.values()).sort((d,y)=>d.path.localeCompare(y.path));for(const d of m)c.push({key:d.id,kind:"directory",depth:t,directory:d}),s.has(d.path)&&h(d,t+1);const b=[...a.directFiles].sort((d,y)=>d.path.localeCompare(y.path));for(const d of b)c.push({key:`file:${Ls(d.path)}`,kind:"file",depth:t,file:d})};return h(r,0),c},dr=1e3,fs=34,Mt=30,it="pl-0 pr-2",Lt=(r,s)=>`${r} ${s}`,ur=({groups:r,diffStats:s,revertingPaths:c,isRevertingAll:h=!1,headerBackgroundClassName:a="bg-sidebar",onVisiblePathsChange:t,onRevertAll:m,onRevertDirectory:b})=>{const d=n.useRef(null),C=lt(v=>v.gitChangesViewMode)==="tree",k=n.useMemo(()=>r.filter(v=>v.entries.length>0),[r]),[j,p]=n.useState(new Set),[o,w]=n.useState(new Set),[R,E]=n.useState(!1),[M,U]=n.useState(null),V=n.useMemo(()=>k.map(v=>lr(v.entries)),[k]),G=n.useMemo(()=>{const v=[];return k.forEach((N,l)=>{Array.from(V[l]?.children.values()??[]).forEach(F=>{v.push(Lt(N.id,F.path))})}),v},[V,k]);n.useEffect(()=>{C&&w(v=>{const N=new Set,l=new Set(G);return v.forEach(F=>{(F.slice(F.indexOf(" ")+1).includes("/")||l.has(F))&&N.add(F)}),G.forEach(F=>N.add(F)),N})},[C,G]);const P=n.useMemo(()=>{const v=[];return k.forEach((N,l)=>{if(v.push({type:"header",key:`header:${N.id}`,groupIndex:l}),!j.has(N.id)){if(C){const F=new Set;o.forEach(Z=>{Z.startsWith(`${N.id} `)&&F.add(Z.slice(N.id.length+1))}),cr(V[l],F).forEach(Z=>{Z.kind==="file"?v.push({type:"file",key:`${N.id}:${Z.key}`,groupIndex:l,file:Z.file,depth:Z.depth}):v.push({type:"directory",key:`${N.id}:${Z.key}`,groupIndex:l,directory:Z.directory,depth:Z.depth})});return}N.entries.forEach(F=>{v.push({type:"file",key:`${N.id}:file:${F.path}`,groupIndex:l,file:F,depth:0})})}}),m&&k.length>0&&v.push({type:"revert-all",key:"revert-all"}),v},[j,o,C,m,V,k]),A=P.length,$=A>=dr,z=ja({count:A,enabled:$,getScrollElement:()=>d.current,estimateSize:()=>fs,overscan:12,getItemKey:v=>P[v]?.key??v}),x=z.getVirtualItems(),D=n.useMemo(()=>{if(!$)return 0;const v=d.current?.scrollTop??0;return x.find(l=>l.end>v)?.index??0},[$,x,d]);n.useEffect(()=>{if(!t)return;const v=N=>N&&N.type==="file"?N.file.path:null;if(A===0){t([]);return}if(!$){const N=[];for(const l of P)if(l.type==="file"&&(N.push(l.file.path),N.length>=Mt))break;t(N);return}t(P.slice(D,D+Math.ceil((d.current?.clientHeight??0)/fs)+Mt).map(N=>v(N)).filter(N=>!!N).slice(0,Mt))},[t,A,P,$,D]);const J=n.useCallback(v=>{p(N=>{const l=new Set(N);return l.has(v)?l.delete(v):l.add(v),l})},[]),X=n.useCallback((v,N)=>{w(l=>{const F=new Set(l),W=Lt(v,N);return F.has(W)?F.delete(W):F.add(W),F})},[]),te=n.useMemo(()=>{const v=new Set;return k.forEach(N=>N.entries.forEach(l=>v.add(l.path))),Array.from(v)},[k]),q=te.length,_=M?h||M.paths.some(v=>c.has(v)):!1,re=n.useCallback(async()=>{!m||h||te.length===0||(await m(te),E(!1))},[te,h,m]),ie=n.useCallback(async()=>{!b||!M||_||(await b(M.paths),U(null))},[_,b,M]),oe=n.useCallback((v,N)=>{const l=j.has(v.id),F=v.entries.length;return e.jsxs("div",{className:ee("sticky top-0 z-10 flex items-center gap-2 py-2",a,it,!N&&"mt-1 border-t border-border/40"),children:[e.jsx("button",{type:"button",onClick:()=>v.onActionAll(v.entries.map(W=>W.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":v.actionAllLabel,title:v.actionAllLabel,children:v.actionSymbol}),e.jsxs("button",{type:"button",onClick:()=>J(v.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:v.title}),e.jsx("span",{className:"typography-meta text-muted-foreground",children:F}),e.jsx(I,{name:"arrow-down-s",className:ee("size-3.5 shrink-0 text-muted-foreground transition-transform",l&&"-rotate-90")})]})]})},[j,a,J]),H=n.useCallback((v,N,l)=>{const F=o.has(Lt(v.id,N.path)),W=N.files.map(ue=>ue.path),Z=h||W.some(ue=>c.has(ue));return e.jsxs("div",{className:ee("group flex items-center gap-2 py-1.5",it),style:{paddingLeft:`${l*hs}px`},children:[e.jsxs("button",{type:"button",onClick:()=>X(v.id,N.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":F?`Collapse directory ${N.path}`:`Expand directory ${N.path}`,children:[F?e.jsx(I,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):e.jsx(I,{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:N.path,children:N.name}),e.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:N.files.length})]}),v.showRevertActions!==!1&&b?e.jsx("button",{type:"button",onClick:()=>U({path:N.path,paths:W,count:W.length}),disabled:Z,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 ${N.path}`,title:"Revert folder changes",children:Z?e.jsx(I,{name:"loader-4",className:"size-3.5 animate-spin"}):e.jsx(I,{name:"arrow-go-back",className:"size-3.5"})}):null,e.jsx("button",{type:"button",onClick:()=>v.onActionAll(N.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":v.actionSymbol==="+"?`Stage all changes in ${N.path}`:`Unstage all changes in ${N.path}`,title:v.actionSymbol==="+"?`Stage all changes in ${N.path}`:`Unstage all changes in ${N.path}`,children:v.actionSymbol})]})},[o,h,b,c,X]),O=n.useCallback((v,N)=>{if(v.type==="revert-all")return e.jsx("div",{className:ee("flex justify-end py-2",it),children:e.jsxs(T,{variant:"ghost",size:"sm",onClick:()=>E(!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(I,{name:"arrow-go-back",className:"size-3.5"}),"Revert all"]})});const l=k[v.groupIndex];if(!l)return null;if(v.type==="header")return oe(l,N);if(v.type==="directory")return H(l,v.directory,v.depth);const F=v.file;return e.jsx(or,{file:F,actionLabel:l.getActionLabel(F.path),actionSymbol:l.actionSymbol,onAction:()=>l.onActionFile(F.path),stats:s?.[F.path],onViewDiff:()=>l.onViewDiff(F.path),onRevert:()=>l.onRevertFile(F.path),isReverting:c.has(F.path)||h,rowPaddingClassName:it,indentPx:v.depth*hs,actionAtStart:!C,showRevert:l.showRevertActions!==!1})},[s,h,C,H,oe,c,k]),B=n.useCallback(v=>{const N=P[v],l=P[v-1];return!N||!l||N.type!=="file"&&N.type!=="directory"||l.type!=="file"&&l.type!=="directory"?!1:l.groupIndex===N.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(Ss,{ref:d,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:$?e.jsx("div",{style:{height:z.getTotalSize(),position:"relative"},children:x.map(v=>{const N=P[v.index];return N?e.jsx("div",{"data-index":v.index,ref:z.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${v.start}px)`},className:ee(B(v.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:O(N,v.index===0)},N.key):null})}):e.jsx("div",{role:"list","aria-label":"Changed files",children:P.map((v,N)=>e.jsx("div",{className:ee("relative",B(N)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:O(v,N===0)},v.key))})}),e.jsx(Qn,{containerRef:d,disableHorizontal:!0})]}),e.jsx(ve,{open:R,onOpenChange:v=>{!h&&!v&&E(!1)},children:e.jsxs(we,{className:"max-w-md",children:[e.jsxs(Ce,{children:[e.jsx(Ne,{children:"Revert all changes?"}),e.jsx(Fe,{children:q===1?`Revert ${q} changed file? This cannot be undone.`:`Revert ${q} changed files? This cannot be undone.`})]}),e.jsxs(_e,{children:[e.jsx(T,{variant:"outline",size:"sm",onClick:()=>E(!1),disabled:h,children:"Cancel"}),e.jsx(T,{variant:"destructive",size:"sm",onClick:()=>{re()},disabled:h,children:h?"Reverting...":"Revert all"})]})]})}),e.jsx(ve,{open:!!M,onOpenChange:v=>{!_&&!v&&U(null)},children:e.jsxs(we,{className:"max-w-md",children:[e.jsxs(Ce,{children:[e.jsx(Ne,{children:"Revert folder changes?"}),e.jsx(Fe,{children:M?M.count===1?`This will discard local changes in ${M.count} file under ${M.path}.`:`This will discard local changes in ${M.count} files under ${M.path}.`:null})]}),e.jsxs(_e,{children:[e.jsx(T,{variant:"outline",size:"sm",onClick:()=>U(null),disabled:_,children:"Cancel"}),e.jsx(T,{variant:"destructive",size:"sm",onClick:()=>{ie()},disabled:_||!M,children:_?"Reverting...":"Revert folder"})]})]})})]})},hr=ks(()=>gs(()=>import("./DiffView-BApPTLGp.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])).then(r=>({default:r.DiffView}))),mr=({currentDirectory:r,status:s,isGitRepo:c,isLoadingStatus:h,changeEntries:a,stagedChangeEntries:t,unstagedChangeEntries:m,effectiveRemotes:b,syncAction:d,commitAction:y,commitMessage:C,hasPendingIndexMutation:k,revertingPaths:j,isRevertingAll:p,initialDiffPath:o,initialDiffStaged:w=!1,onSyncAction:R,onMoveChangePaths:E,onRevertFile:M,onRevertAll:U,onCommitMessageChange:V,onCommit:G,onVisiblePathsChange:P,loadDiff:A})=>{const[$,z]=n.useState(()=>o?{type:"diff",path:o,staged:w}:{type:"list"}),[x,D]=n.useState(null),[J,X]=n.useState(null),[te,q]=n.useState(0);n.useEffect(()=>{o&&z(H=>H.type==="diff"&&H.path===o&&H.staged===w?H:{type:"diff",path:o,staged:w})},[o,w]);const _=n.useMemo(()=>$.type==="diff"&&a.some(H=>H.path===$.path),[a,$]);n.useEffect(()=>{if($.type!=="diff"||!_){D(null),X(null);return}let H=!1;return D(null),X(null),A($.path,$.staged).then(O=>{H||D(O)}).catch(O=>{H||X(O instanceof Error?O.message:String(O))}),()=>{H=!0}},[te,A,$,_]);const re=n.useCallback((H,O=!1)=>{z({type:"diff",path:H,staged:O})},[]),ie=n.useMemo(()=>{const H=[];return t.length>0&&H.push({id:"staged",title:"Staged",entries:t,actionSymbol:"-",actionAllLabel:"Unstage all changes",getActionLabel:O=>`Unstage ${O}`,onActionFile:O=>E([O],"unstage"),onActionAll:O=>E(O,"unstage"),onViewDiff:O=>re(O,!0),onRevertFile:M,showRevertActions:!1,accent:!0}),m.length>0&&H.push({id:"unstaged",title:"Changes",entries:m,actionSymbol:"+",actionAllLabel:"Stage all changes",getActionLabel:O=>`Stage ${O}`,onActionFile:O=>E([O],"stage"),onActionAll:O=>E(O,"stage"),onViewDiff:O=>re(O,!1),onRevertFile:M}),H},[re,E,M,t,m]),oe=n.useCallback(H=>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:s?.current||r||""})}),e.jsx("div",{className:"min-h-0 flex-1",children:H})]}),[r,s]);return r?c===null||c===!0&&!s?oe(e.jsx(Ee,{loading:!0,message:"Checking repository..."})):c===!1?oe(e.jsx(n.Suspense,{fallback:e.jsx(Ee,{loading:!0,message:"Loading last turn changes..."}),children:e.jsx(hr,{diffScope:"turn",hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,flushContent:!0})})):$.type==="diff"?e.jsx(fr,{path:$.path,diff:x,fileExists:_,error:J,onBack:()=>z({type:"list"}),onRetry:()=>q(H=>H+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:s?.current||r}),e.jsx(da,{syncAction:d,remotes:b,onFetch:H=>R("fetch",H),onSync:H=>R("sync",H),disabled:y!==null||h,aheadCount:s?.ahead??0,behindCount:s?.behind??0,trackingRemoteName:s?.tracking?.split("/")[0],hasUncommittedChanges:a.length>0})]}),a.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(ur,{groups:ie,diffStats:s?.diffStats,revertingPaths:j,onRevertAll:U,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(Ms,{stagedCount:t.length,commitMessage:C,onCommitMessageChange:V,onCommit:()=>{if(!C.trim()){S.error("Enter a commit message");return}if(t.length===0){S.error("Select at least one file to commit");return}G({pushAfter:!1})},onCommitAndPush:()=>{if(!C.trim()){S.error("Enter a commit message");return}if(t.length===0){S.error("Select at least one file to commit");return}G({pushAfter:!0})},commitAction:y,hasPendingIndexMutation:k,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(Ee,{icon:!0,message:"Working tree clean",description:"There are no changed files in this workspace."})})]}):oe(e.jsx(Ee,{message:"Select a session or directory to view Git status"}))},Ee=({message:r,description:s,loading:c=!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:[c?e.jsx(I,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,h?e.jsx(I,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:r}),s?e.jsx("p",{className:"typography-meta text-muted-foreground",children:s}):null]})}),fr=({path:r,diff:s,fileExists:c,error:h,onBack:a,onRetry:t})=>{const m=n.useMemo(()=>js(r)||"text",[r]);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:a,children:e.jsx(I,{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:r})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:c?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(T,{type:"button",size:"sm",variant:"outline",onClick:t,children:"Retry"})]})}):s?s.isBinary?e.jsx(Ee,{icon:!0,message:"Content of this file cannot be viewed."}):Xn(r)?e.jsx(Ee,{icon:!0,message:"Image diffs are not available in mobile Changes yet."}):e.jsx(Ss,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:e.jsx(Rs,{original:s.original,modified:s.modified,language:m,fileName:r,renderSideBySide:!1,wrapLines:!0,layout:"inline"})}):e.jsx(Ee,{loading:!0,message:"Loading diff..."}):e.jsx(Ee,{icon:!0,message:"File is no longer changed",description:"Go back to Changes and refresh the list."})})]})},ps=ks(()=>gs(()=>import("./DiffView-BApPTLGp.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])).then(r=>({default:r.DiffView}))),pr=15e3,gr=40,xr=20,Ro=({isActive:r,chrome:s="desktop",initialDiffPath:c=null,initialDiffStaged:h=!1})=>{const{git:a}=ot(),t=Zn(),m=$t(i=>i.currentSessionId),{profiles:b,globalIdentity:d,defaultGitIdentityId:y,loadProfiles:C,loadGlobalIdentity:k,loadDefaultGitIdentityId:j}=ua(es(i=>({profiles:i.profiles,globalIdentity:i.globalIdentity,defaultGitIdentityId:i.defaultGitIdentityId,loadProfiles:i.loadProfiles,loadGlobalIdentity:i.loadGlobalIdentity,loadDefaultGitIdentityId:i.loadDefaultGitIdentityId}))),p=ea(t??null),o=ta(t??null),w=sa(t??null),R=na(t??null),E=aa(t??null),M=ra(t??null),U=ia(t??null),{setActiveDirectory:V,fetchAll:G,ensureAll:P,fetchStatus:A,fetchBranches:$,fetchLog:z,setLogMaxCount:x,fetchIdentity:D,prefetchDiffs:J,clearDiffCache:X,moveStatusPathsOptimistically:te,restoreStatus:q,bumpIndexRevision:_}=oa(es(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})));n.useRef(null);const re=n.useRef(null),ie=n.useRef(null),oe=n.useRef(null),H=n.useRef(!0);n.useEffect(()=>()=>{H.current=!1},[]);const O=n.useCallback(()=>{re.current!==null&&(window.clearTimeout(re.current),re.current=null)},[]),B=n.useCallback(i=>{O(),re.current=window.setTimeout(()=>{re.current=null,st(i)===st(t)&&A(i,a,{silent:!0})},pr)},[O,t,A,a]);n.useEffect(()=>O,[O]);const v=n.useCallback(()=>{ie.current!==null&&(window.clearTimeout(ie.current),ie.current=null)},[]),N=n.useCallback(()=>{ie.current===null&&(ie.current=window.setTimeout(()=>{ie.current=null,oe.current?.()},0))},[]),l=n.useCallback(async(i,u,f)=>{if(u==="stage"){if(a.stageGitFiles){await a.stageGitFiles(i,f);return}await Promise.all(f.map(g=>a.stageGitFile(i,g)));return}if(a.unstageGitFiles){await a.unstageGitFiles(i,f);return}await Promise.all(f.map(g=>a.unstageGitFile(i,g)))},[a]),F=n.useMemo(()=>ir({runMutation:({directory:i,direction:u,paths:f})=>l(i,u,f),onMutationComplete:({directory:i})=>{_(i),B(i)},onMutationError:({directory:i,direction:u,rollback:f},g)=>{f?.(),_(i),B(i);const L=u==="stage"?"Failed to stage changes":"Failed to unstage changes";S.error(g instanceof Error?g.message:L)},onPathsComplete:i=>{Tt(u=>{const f=new Set(u);return i.forEach(g=>f.delete(g)),f})},scheduleFlush:N}),[_,l,N,B]);n.useEffect(()=>(oe.current=F.flush,()=>{oe.current=null}),[F]),n.useEffect(()=>()=>F.clear(),[F]),n.useEffect(()=>v,[v]);const W=n.useMemo(()=>t?Oa(t):null,[t]),Z=la(i=>i.settingsGitmojiEnabled),{gitmojis:ue}=Na(Z),[le,se]=n.useState(W?.commitMessage??""),[De,Be]=n.useState(!1),He=n.useRef(null),[ct,Ue]=n.useState(null),[$s,dt]=n.useState(!1),[ut,zt]=n.useState(null),[pe,Ps]=n.useState(25),[As,Dt]=n.useState(!1),{triggerFireworks:zs}=ha(),Bt=n.useRef(new Map),Ve=n.useRef(0),ht=n.useCallback(()=>{Ve.current+=1,H.current&&Dt(!0)},[]),mt=n.useCallback(()=>{Ve.current=Math.max(0,Ve.current-1),H.current&&Ve.current===0&&Dt(!1)},[]),[ft,We]=n.useState(new Set),[Ds,Tt]=n.useState(new Set),[pt,Gt]=n.useState(!1),[Ot,Bs]=n.useState([]),[br,Ts]=n.useState(0),[Gs,_t]=n.useState(!1),Ht=Ds.size>0||F.size()>0||F.isRunning();n.useCallback(()=>{const i=He.current;i&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{i.scrollTo({top:i.scrollHeight,behavior:"smooth"})})})},[]);const{expandedCommitHashes:Os,commitFilesMap:_s,loadingCommitHashes:Hs,handleCopyCommitHash:Us,handleToggleCommit:Vs}=Wa(t,a),{conflictDialogOpen:Ws,setConflictDialogOpen:ge,conflictFiles:Ks,setConflictFiles:xe,conflictOperation:Ke,setConflictOperation:be,persistConflictState:ye,clearConflictState:he}=rr({currentSessionId:m,currentDirectory:t}),[qs,gt]=n.useState([]),[Ut,xt]=n.useState(null),[Ys,Vt]=n.useState(null),[Js,bt]=n.useState(null),[Qs,qe]=n.useState([]),[Xs,yt]=n.useState(null),[Zs,Wt]=n.useState(!1),[jt,en]=n.useState(100),[tn,sn]=n.useState(0),[me,Ye]=n.useState(null),[nn,Me]=n.useState(null),[an,vt]=n.useState(!1),[wt,Kt]=n.useState("merge"),[Ct,qt]=n.useState("");n.useEffect(()=>{t&&_a(t,{directory:t,commitMessage:le})},[le,t]),n.useEffect(()=>{r&&(C(),k(),j())},[r,C,k,j]),n.useEffect(()=>{if(!r)return;if(!t||!a?.getRemoteUrl){xt(null);return}let i=!1;return a.getRemoteUrl(t).then(u=>{i||xt(u)}).catch(()=>{i||xt(null)}),()=>{i=!0}},[r,t,a]);const Je=n.useCallback(async()=>{if(!t||!a?.getRemotes){gt([]);return}try{const i=await a.getRemotes(t);H.current&>(i)}catch{H.current&>([])}},[t,a]);n.useEffect(()=>{r&&Je()},[r,Je]),n.useEffect(()=>{r&&t&&(V(t),P(t,a))},[r,t,V,P,a]),n.useEffect(()=>{if(r&&t)return ca.onGitRefreshHint(i=>{st(i.directory)===st(t)&&(i.paths?.length&&X(t,i.paths),A(t,a,{silent:!0}))})},[r,X,t,A,a]);const Q=n.useCallback(async(i=!0)=>{if(t)try{await Promise.all([A(t,a),$(t,a)])}catch(u){if(i){const f=u instanceof Error?u.message:"Failed to refresh repository";S.error(f)}}},[t,a,A,$]),ne=n.useCallback(async()=>{t&&await z(t,a,pe)},[t,a,z,pe]),Nt=n.useCallback(async()=>{t&&await D(t,a)},[t,a,D]);n.useEffect(()=>{if(!r||!t||!a?.hasLocalIdentity||p!==!0)return;const i=typeof y=="string"?y.trim():"";if(!i||i==="global"||Bt.current.get(t)===i)return;let f=!1;return(async()=>{try{const L=await a.hasLocalIdentity?.(t);if(f||L===!0)return;ht(),await a.setGitIdentity(t,i),Bt.current.set(t,i),await Nt()}catch(L){console.warn("Failed to auto-apply default git identity:",L)}finally{f||mt()}})(),()=>{f=!0}},[r,ht,t,y,mt,a,p,Nt]);const fe=n.useMemo(()=>o?[...o.files??[]].sort((u,f)=>u.path.localeCompare(f.path)):[],[o]),Se=n.useMemo(()=>fe.filter(ts),[fe]),rn=n.useMemo(()=>fe.filter(ya),[fe]);n.useEffect(()=>{if(!t||fe.length===0)return;const i=[],u=new Set,f=L=>{!L||u.has(L)||(u.add(L),i.push(L))};if(Se.forEach(L=>f(L.path)),s==="mobile"&&Ot.forEach(f),fe.slice(0,xr).forEach(L=>f(L.path)),i.length===0)return;const g=window.setTimeout(()=>{J(t,a,i,{maxFiles:gr})},120);return()=>{window.clearTimeout(g)}},[fe,s,t,a,Ot,J,Se]);const Yt=i=>i?.pushed[0]?.remote||o?.tracking?.split("/")[0]||je.find(u=>u.name==="origin")?.name||je[0]?.name||"origin",St=async(i,u)=>{if(t){Ue(i);try{const f=g=>{const L=`${g.name}/`,K=o?.tracking?.startsWith(L)?o.tracking.slice(L.length):void 0;return{remote:g.name,branch:K,rebase:!0}};if(i==="fetch"){if(!u)throw new Error("No remote available for fetch");await a.gitFetch(t,{remote:u.name}),S.success(`Fetched from ${u.name}`)}else if(i==="pull"){if(!u)throw new Error("No remote available for pull");const g=await a.gitPull(t,f(u));S.success(g.files.length===1?`Pulled ${g.files.length} file from ${u.name}`:`Pulled ${g.files.length} files from ${u.name}`)}else if(i==="push"){const g=await a.gitPush(t);S.success(`Pushed to ${Yt(g)}`)}else if(i==="sync"){if(!u)throw new Error("No remote available for sync");let g=0,L=!1;await a.gitFetch(t,{remote:u.name});const K=await a.getGitStatus(t);if((K.behind??0)>0){if((K.files?.length??0)>0){S.error("Commit or stash your changes before syncing");return}g=(await a.gitPull(t,f(u))).files.length}((await a.getGitStatus(t)).ahead??0)>0&&(await a.gitPush(t),L=!0),g>0&&L?S.success(g===1?`Pulled ${g} file from ${u.name} and pushed to upstream`:`Pulled ${g} files from ${u.name} and pushed to upstream`):g>0?S.success(g===1?`Pulled ${g} file from ${u.name}`:`Pulled ${g} files from ${u.name}`):L?S.success(`Pushed to ${u.name}`):S.success("Already up to date")}await Q(!1),await ne()}catch(f){const g=f instanceof Error?f.message:`${i==="sync"?"Sync Changes":i==="pull"?"Pull":i} failed`;S.error(g)}finally{Ue(null)}}},on=n.useCallback(async(i,u)=>{if(!t)throw new Error("No active directory");const f=await a.getGitFileDiff(t,{path:i,staged:u||void 0});return{original:f.original??"",modified:f.modified??"",isBinary:f.isBinary}},[t,a]),ln=n.useCallback(async i=>{if(!t)return;const u=i.name.trim();if(!u){S.error("Remote name is required");return}if(u==="origin"){S.error("Cannot remove the origin remote");return}Vt(u);try{await a.removeRemote(t,{remote:u}),S.success(`Removed remote ${u}`),await Promise.all([Q(!1),Je()])}catch(f){const g=f instanceof Error?f.message:`Failed to remove ${u}`;S.error(g)}finally{Vt(null)}},[t,a,Je,Q]),kt=async(i={})=>{if(!t)return;if(!le.trim()){S.error("Enter a commit message");return}const u=Se.map(g=>g.path).sort();if(u.length===0){S.error("Stage at least one file to commit");return}const f=i.pushAfter?"commitAndPush":"commit";zt(f);try{if(await a.createGitCommit(t,le.trim(),{files:u,stageFiles:[]}),_(t),S.success("Commit created"),se(""),await Q(),i.pushAfter){const g=o?.tracking?.split("/")[0],L=je.find(zn=>zn.name===g)??je[0];if(!L)throw new Error("No remote available");Ue("sync");const K=`${L.name}/`,ae=o?.tracking?.startsWith(K)?o.tracking.slice(K.length):void 0;await a.gitFetch(t,{remote:L.name});const Y=await a.getGitStatus(t);if((Y.behind??0)>0){if((Y.files?.length??0)>0){S.error("Commit or stash your changes before syncing"),await Q(!1);return}await a.gitPull(t,{remote:L.name,branch:ae,rebase:!0})}const de=await a.getGitStatus(t);let Le;(de.ahead??0)>0&&(Le=await a.gitPush(t)),S.success(`Pushed to ${Yt(Le)}`),s!=="mobile"&&zs(),await Q(!1)}else await Q(!1);await ne(),Ts(g=>g+1)}catch(g){const L=g instanceof Error?g.message:"Failed to create commit";S.error(L)}finally{zt(null),i.pushAfter&&Ue(null)}},cn=async(i,u)=>{if(!t||!o)return;const f=o.current??null,g=u?.name??"origin";try{await a.createBranch(t,i,f??"HEAD"),S.success(`Created branch ${i}`),await a.checkoutBranch(t,i);let L=!1;try{await a.gitPush(t,{remote:g,branch:i,options:["--set-upstream"]}),L=!0}catch(K){const ae=K instanceof Error?K.message:`Unable to push new branch to ${g}.`;S.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: ",ae]})})}await Q(),await ne(),L&&S.success(`Set upstream for ${i} to ${g}`)}catch(L){const K=L instanceof Error?L.message:"Failed to create branch";throw S.error(K),L}},dn=async(i,u)=>{if(t)try{await a.renameBranch(t,i,u),S.success(`Renamed ${i} to ${u}`),await Q(),await ne()}catch(f){const g=f instanceof Error?f.message:`Failed to rename ${i} to ${u}`;S.error(g)}},un=async i=>{if(!t)return;const u=i.replace(/^remotes\//,"");if(o?.current!==u)try{await a.checkoutBranch(t,u),S.success(`Checked out ${u}`),await Q(),await ne()}catch(f){const g=f instanceof Error?f.message:`Failed to checkout ${u}`;S.error(g)}},hn=async i=>{if(t){ht();try{await a.setGitIdentity(t,i.id),S.success(`Applied identity: ${i.name}`),await Nt()}catch(u){const f=u instanceof Error?u.message:"Failed to apply identity";S.error(f)}finally{mt()}}},{localBranches:Jt,remoteBranches:Qe,effectiveRemotes:je,currentBranch:Ie,baseBranch:Te,branchScopeAvailable:Rt,updateTargetBranch:mn}=er({branches:w,status:o,remotes:qs,remoteUrl:Ut,git:a}),{availableIdentities:fn,activeIdentityProfile:pn}=ar({profiles:b,globalIdentity:d,currentIdentity:E,remoteUrl:Ut}),gn=Se.length,xn=M||ct!==null||ut!==null,Qt=!!Ie;n.useEffect(()=>{if(!t||!a||!R?.all?.length||!Ie||!Te||Ie===Te){Me(null);return}let i=!1;return(async()=>{try{const f=await a.getGitLog(t,{from:Te,to:"HEAD",maxCount:pe});if(i)return;const g=new Set((f?.all??[]).map(K=>K.hash).filter(K=>typeof K=="string"&&K.length>0));if(g.size===0){Me(null);return}const L=R.all.findIndex(K=>!g.has(K.hash));if(L===0){Me(null);return}if(L===-1){Me({insertBeforeIndex:R.all.length,branchName:Ie,direction:"up"});return}Me({insertBeforeIndex:L,branchName:Ie,direction:"up"})}catch{i||Me(null)}})(),()=>{i=!0}},[Te,Ie,t,a,R,pe]),n.useEffect(()=>{yt(null)},[t]),n.useEffect(()=>{if(me!=="graph"||!t){me!=="graph"&&yt(null);return}let i=!1;return Wt(!0),a.getGitLog(t,{maxCount:jt,all:!0}).then(u=>{i||yt(u)}).catch(u=>{console.error("Failed to fetch graph log:",u)}).finally(()=>{i||Wt(!1)}),()=>{i=!0}},[me,t,jt,tn,a]);const bn=n.useCallback((i,u)=>{if(!t||i.length===0)return;const f=Array.from(new Set(i));Tt(L=>{const K=new Set(L);return f.forEach(ae=>K.add(ae)),K});const g=te(t,f,u);F.enqueue({directory:t,direction:u,paths:new Set(f),rollback:()=>q(t,g)}),N()},[t,F,te,q,N]),yn=n.useCallback(async i=>{if(t){We(u=>{const f=new Set(u);return f.add(i),f});try{await a.revertGitFile(t,i,{scope:"working"}),S.success(`Reverted ${i}`),await Q(!1)}catch(u){const f=u instanceof Error?u.message:"Failed to revert changes";S.error(f)}finally{We(u=>{const f=new Set(u);return f.delete(i),f})}}},[t,Q,a]),Xe=n.useCallback(async(i,u,f="all")=>{if(!t||i.length===0)return;const g=Array.from(new Set(i));if(pt||g.some(Y=>ft.has(Y)))return;const L=new Set(Se.map(Y=>Y.path)),K=f==="all"&&g.some(Y=>L.has(Y));u&&Gt(!0),We(Y=>{const de=new Set(Y);return g.forEach(Le=>de.add(Le)),de});const ae=[];try{if(await Promise.all(g.map(async Y=>{try{await a.revertGitFile(t,Y,{scope:f})}catch(de){ae.push({path:Y,message:de instanceof Error?de.message:"Failed to revert changes"})}})),K&&ae.length<g.length&&_(t),await Q(!1),ae.length===0)S.success(g.length===1?`Reverted ${g.length} file`:`Reverted ${g.length} files`);else if(ae.length===g.length)S.error(ae[0]?.message||"Failed to revert changes");else{const Y=g.length-ae.length;S.warning(Y===1?`Reverted ${Y} file, ${ae.length} failed`:`Reverted ${Y} files, ${ae.length} failed`)}}finally{We(Y=>{const de=new Set(Y);return g.forEach(Le=>de.delete(Le)),de}),u&&Gt(!1)}},[_,t,a,pt,Q,ft,Se]),jn=n.useCallback(async i=>{await Xe(i,!0)},[Xe]);n.useCallback(async i=>{await Xe(i,!1,"working")},[Xe]);const vn=n.useCallback(()=>dt(!0),[]),wn=n.useCallback((i,u)=>{const f=u||i;se(g=>{const L=g.trimStart();return L.startsWith(i)||u&&L.startsWith(u)?g:`${f.endsWith(" ")?f:`${f} `}${g}`.trimStart()}),Be(!1)},[]),Ze=n.useCallback(i=>{const u=i instanceof Error?i.message.toLowerCase():"";return u.includes("uncommitted changes")||u.includes("local changes")||u.includes("your local changes would be overwritten")||u.includes("please commit your changes or stash them")||u.includes("cannot rebase: you have unstaged changes")||u.includes("error: cannot pull with rebase")},[]),ke=n.useCallback((i,u)=>{qe(f=>[...f,{message:i,status:u,timestamp:Date.now()}])},[]),ce=n.useCallback((i,u)=>{qe(f=>{if(f.length===0)return f;const g=[...f];return g[g.length-1]={...g[g.length-1],status:i,...u?{message:u}:{}},g})},[]),et=n.useCallback(()=>{qe([])},[]),Cn=n.useCallback(()=>{qe([]),bt(null)},[]),tt=n.useCallback(i=>{const u=i.trim(),f=new Set(je.map(L=>L.name)),g=u.indexOf("/");if(g>0){const L=u.slice(0,g),K=u.slice(g+1);if(f.has(L)&&K)return{branch:u,remote:L,remoteBranch:K}}for(const L of je){const K=`${L.name}/${u}`;if(Qe.includes(K))return{branch:K,remote:L.name,remoteBranch:u}}return{branch:u,remote:null,remoteBranch:null}},[je,Qe]),Nn=n.useCallback(async i=>{if(!t)return;bt("merge"),et();const u=o?.current,f=tt(i);try{f.remote&&f.remoteBranch&&(ke(`Fetching ${f.remote}/${f.remoteBranch}...`,"running"),await a.gitFetch(t,{remote:f.remote,branch:f.remoteBranch}),ce("done",`Fetched ${f.remote}/${f.remoteBranch}`)),ke(`Merging ${f.branch} into ${u}...`,"running");const g=await a.merge(t,{branch:f.branch});g.conflict?(ce("error","Merge conflicts detected"),xe(g.conflictFiles??[]),be("merge"),ge(!0),ye(t,g.conflictFiles??[],"merge")):(ce("done",`Merged ${f.branch} into ${u}`),he(),ke("Refreshing repository status...","running"),await Q(),await ne(),ce("done","Repository status updated"))}catch(g){if(Ze(g))ce("error","Uncommitted changes detected"),Kt("merge"),qt(f.branch),vt(!0);else{const L=g instanceof Error?g.message:`Failed to merge ${f.branch}`;ce("error",L)}}},[t,a,o,tt,Q,ne,Ze,ye,he,ke,ce,et]),Sn=n.useCallback(async i=>{if(!t)return;bt("rebase"),et();const u=o?.current,f=tt(i);try{f.remote&&f.remoteBranch&&(ke(`Fetching ${f.remote}/${f.remoteBranch}...`,"running"),await a.gitFetch(t,{remote:f.remote,branch:f.remoteBranch}),ce("done",`Fetched ${f.remote}/${f.remoteBranch}`)),ke(`Rebasing ${u} onto ${f.branch}...`,"running");const g=await a.rebase(t,{onto:f.branch});g.conflict?(ce("error","Rebase conflicts detected"),xe(g.conflictFiles??[]),be("rebase"),ge(!0),ye(t,g.conflictFiles??[],"rebase")):(ce("done",`Rebased ${u} onto ${f.branch}`),he(),ke("Refreshing repository status...","running"),await Q(),await ne(),ce("done","Repository status updated"))}catch(g){if(Ze(g))ce("error","Uncommitted changes detected"),Kt("rebase"),qt(f.branch),vt(!0);else{const L=g instanceof Error?g.message:`Failed to rebase onto ${f.branch}`;ce("error",L)}}},[t,a,o,tt,Q,ne,Ze,ye,he,ke,ce,et]),kn=n.useCallback(async()=>{if(t)try{Ke==="merge"?(await a.abortMerge(t),S.success("Merge aborted")):(await a.abortRebase(t),S.success("Rebase aborted")),he(),await Q(),await ne()}catch(i){const u=i instanceof Error?i.message:`Failed to abort ${Ke}`;S.error(u)}},[t,a,Ke,Q,ne,he]),Rn=n.useMemo(()=>o?.files?o.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,[o?.files]),En=n.useCallback(async()=>{if(t)try{const i=!!o?.mergeInProgress?.head,u=!!(o?.rebaseInProgress?.headName||o?.rebaseInProgress?.onto);if(i){const f=await a.continueMerge(t);f.conflict?(xe(f.conflictFiles??[]),be("merge"),ge(!0),ye(t,f.conflictFiles??[],"merge"),S.error("Merge conflicts detected")):(he(),S.success("Merge completed"),await Q(),await ne())}else if(u){const f=await a.continueRebase(t);f.conflict?(xe(f.conflictFiles??[]),be("rebase"),ge(!0),ye(t,f.conflictFiles??[],"rebase"),S.error("Rebase conflicts detected")):(he(),S.success("Rebase step completed"),await Q(),await ne())}}catch(i){const u=i instanceof Error?i.message:"Failed to continue operation";S.error(u)}},[t,a,o,Q,ne,ye,he]),Fn=n.useCallback(async()=>{if(t)try{!!o?.mergeInProgress?.head?(await a.abortMerge(t),S.success("Merge aborted")):(await a.abortRebase(t),S.success("Rebase aborted")),he(),await Q(),await ne()}catch(i){const u=i instanceof Error?i.message:"Failed to abort operation";S.error(u)}},[t,a,o,Q,ne,he]),In=n.useCallback(()=>{if(!t)return;const u=!!o?.mergeInProgress?.head?"merge":"rebase",f=o?.files?.filter(g=>g.index==="U"||g.working_dir==="U").map(g=>g.path)??[];f.length>0&&xe(f),be(u),ge(!0)},[t,o]),Mn=n.useCallback(async i=>{if(!t)return;const u=o?.current,f=wt,g=Ct,L=(o?.files??[]).some(ts);try{await a.stash(t,{message:`Auto-stash before ${f} with ${g}`,includeUntracked:!0}),L&&_(t)}catch(Y){const de=Y instanceof Error?Y.message:"Failed to stash changes";S.error(de);return}let K=!1,ae=!1;try{if(f==="merge"){const Y=await a.merge(t,{branch:g});Y.conflict?(ae=!0,xe(Y.conflictFiles??[]),be("merge"),ge(!0)):(K=!0,S.success(`Merged ${g} into ${u||""}`))}else{const Y=await a.rebase(t,{onto:g});Y.conflict?(ae=!0,xe(Y.conflictFiles??[]),be("rebase"),ge(!0)):(K=!0,S.success(`Rebased ${u||""} onto ${g}`))}if(i&&K)try{await a.stashPop(t),_(t),S.success("Stashed changes restored")}catch(Y){const de=Y instanceof Error?Y.message:"Failed to restore stash";S.error(de)}else i&&ae&&S.info("Stash restored manually required");await Q(),await ne()}catch(Y){if(i)try{await a.stashPop(t),_(t)}catch{}throw Y}},[_,t,a,o,wt,Ct,Q,ne]),Ln=n.useCallback(i=>{Ps(i),t&&(x(t,i),z(t,a,i))},[t,z,a,x]),$n=n.useCallback(i=>{en(i)},[]),Pn=n.useCallback(()=>{Ye(null),t&&(A(t,a),$(t,a),z(t,a,pe))},[t,A,$,z,pe,a]),An=n.useCallback(i=>{if(i.conflict){if(i.operation==="cherry-pick"||i.operation==="revert"){S.error("Conflict",{description:`Conflicts in: ${i.conflictFiles?.join(", ")??"unknown files"}. Resolve manually and commit, or abort with git cherry-pick/revert --abort.`}),t&&(A(t,a),$(t,a),z(t,a,pe));return}xe(i.conflictFiles??[]),be(i.operation),ge(!0),t&&ye(t,i.conflictFiles??[],i.operation)}},[xe,be,ge,ye,t,A,$,z,pe,a]);return s==="mobile"?e.jsx(mr,{currentDirectory:t??null,status:o,isGitRepo:p,isLoadingStatus:M,changeEntries:fe,stagedChangeEntries:Se,unstagedChangeEntries:rn,effectiveRemotes:je,syncAction:ct,commitAction:ut,commitMessage:le,hasPendingIndexMutation:Ht,revertingPaths:ft,isRevertingAll:pt,initialDiffPath:c,initialDiffStaged:h,onSyncAction:(i,u)=>{St(i,u)},onMoveChangePaths:bn,onRevertFile:i=>{yn(i)},onRevertAll:jn,onCommitMessageChange:se,onCommit:i=>{kt(i)},onVisiblePathsChange:Bs,loadDiff:on}):t?p===null||p===!0&&!o?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(I,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"typography-ui-label",children:"Checking repository..."})]})}):p===!1?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(n.Suspense,{fallback:null,children:e.jsx(ps,{diffScope:"turn",hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,flushContent:!0})})}):e.jsxs("div",{className:ee("flex h-full flex-col overflow-hidden"),children:[e.jsx(ma,{status:o,localBranches:Jt,remoteBranches:Qe,branchInfo:w?.branches,syncAction:ct,remotes:je,onFetch:i=>St("fetch",i),onSync:i=>St("sync",i),onRemoveRemote:ln,removingRemoteName:Ys,onCheckoutBranch:un,onCreateBranch:cn,onRenameBranch:dn,activeIdentityProfile:pn,availableIdentities:fn,onSelectIdentity:hn,isApplyingIdentity:As,isWorktreeMode:!1,onOpenHistory:()=>Ye("history"),onOpenGraph:()=>Ye("graph"),onOpenStashes:vn,onOpenUpdateBranch:Qt?()=>_t(!0):void 0,pullRequest:null,prChecks:null}),t&&(o?.mergeInProgress?.head||o?.rebaseInProgress?.headName||o?.rebaseInProgress?.onto)&&e.jsx(Va,{mergeInProgress:o?.mergeInProgress,rebaseInProgress:o?.rebaseInProgress,onContinue:En,onAbort:Fn,onResolveWithAI:In,conflictCount:Rn,isLoading:M}),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:(fe?.length??0)>0||Rt?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(n.Suspense,{fallback:null,children:e.jsx(ps,{diffScope:fe.length>0?"all":"branch",branchBase:Rt?Te:null,branchHead:Rt?Ie:null,showOpenInEditorAction:!0,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,flushContent:!0})})}),fe.length>0?e.jsx("div",{ref:He,className:"shrink-0 px-4 pb-4 pt-2",children:e.jsx(Ms,{stagedCount:gn,commitMessage:le,onCommitMessageChange:se,onCommit:()=>kt({pushAfter:!1}),onCommitAndPush:()=>kt({pushAfter:!0}),commitAction:ut,hasPendingIndexMutation:Ht,gitmojiEnabled:Z,onOpenGitmojiPicker:()=>Be(!0)})}):null]}):e.jsx(Ua,{onOpenStashes:()=>dt(!0)})})}),e.jsx(Ta,{currentDirectory:t,isUpdateBranchDialogOpen:Gs,setIsUpdateBranchDialogOpen:_t,branchOperation:Js,currentBranch:o?.current,localBranches:Jt,remoteBranches:Qe,updateTargetBranch:mn,onMerge:Nn,onRebase:Sn,isBusy:xn,operationLogs:Qs,onOperationComplete:Cn,canShowBranchWorkflows:Qt,gitLogDialogMode:me,setGitLogDialogMode:Ye,onRefreshHistory:()=>{if(me==="graph"){sn(i=>i+1);return}t&&z(t,a,pe)},isLogRefreshing:me==="graph"?Zs:U,log:me==="graph"?Xs??R:R,maxCount:me==="graph"?jt:pe,onMaxCountChange:me==="graph"?$n:Ln,expandedCommitHashes:Os,onToggleCommit:Vs,commitFilesMap:_s,loadingCommitHashes:Hs,onCopyHash:Us,historyBranchDivider:nn,onConflict:me==="graph"?An:void 0,onActionSuccess:me==="graph"?Pn:void 0,isStashesDialogOpen:$s,setIsStashesDialogOpen:dt,hasUncommittedChanges:(o?.files?.length??0)>0,hasStagedChanges:Se.length>0,uncommittedFileCount:o?.files?.length??0,onStashesChanged:async i=>{t&&i?.affectsIndex&&_(t),await Q(!1),await ne()},isGitmojiPickerOpen:De,setIsGitmojiPickerOpen:Be,gitmojiEmojis:ue,onSelectGitmoji:wn,conflictDialogOpen:Ws,setConflictDialogOpen:ge,conflictFiles:Ks,conflictOperation:Ke,onAbortConflict:kn,onClearConflictState:he,stashDialogOpen:an,setStashDialogOpen:vt,stashDialogOperation:wt,stashDialogBranch:Ct,onConfirmStashAndRetry:Mn})]}):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{Ro as GitView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as H,aE as Z,aF as Fe,ab as Ce,aG as ke,aH as Ie,aI as ze,aJ as Ne,ac as Oe,U as ee,I as te,aK as Ve}from"./useAppFontEffects-Bg-8jtrQ.js";import{b as ie,s as Pe,c as Se,d as ne,e as ve,f as Be,h as re,g as I,i as De,j as Ue,k as _e,l as We,R as Ge,I as je,p as se,m as $e,n as Ke,o as qe,q as Je,w as Ye,r as ae,u as Xe,t as Qe,v as Ze,x as et,y as oe,S as tt,z as it,A as nt,B as rt,a as ye,C as he,F as st}from"./web-components-0H9kvZwn.js";import{G as at,u as ot,W as ht,a as lt,b as dt,n as le,t as ct}from"./Virtualizer-BSHVMKgK.js";import{j as C,r as k,R as L}from"./vendor-react-B5Z1Mdn3.js";import{o as ut,g as j,l as A,h as ft,q as de,s as pt,t as ce,j as gt,u as ue,a as mt,w as B,x as fe}from"./computeVirtualFileMetrics-DMvXzUJh.js";import{a as F,i as q,l as pe,h as Ct,r as St}from"./isFilePlainText-BpTnLRyI.js";import{t as M}from"./vendor-hast-util-to-html-BKBhbTDb.js";let vt=-1;var yt=class{options;onRenderUpdate;workerManager;__id=`file-renderer:${++vt}`;highlighter;renderCache;computedLang="text";lineAnnotations={};lineCache;textDoucmentCache=new WeakMap;constructor(i={theme:H},e,t){this.options=i,this.onRenderUpdate=e,this.workerManager=t,t?.isWorkingPool()!==!0&&(this.highlighter=ie(i.theme??H)?ut():void 0)}setOptions(i){this.options=i}mergeOptions(i){this.options={...this.options,...i}}setLineAnnotations(i){this.lineAnnotations={};for(const e of i){const t=this.lineAnnotations[e.lineNumber]??[];this.lineAnnotations[e.lineNumber]=t,t.push(e)}}cleanUp(){this.recycle(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.clearRenderCache(),this.highlighter=void 0,this.workerManager?.cleanUpTasks(this),this.lineCache=void 0}clearRenderCache(){const i=this.renderCache;this.renderCache=void 0,i!=null&&i.isDirty===!0&&i.file.cacheKey!=null&&this.workerManager?.evictFileFromCache(i.file.cacheKey)}hydrate(i){const{options:e}=this.getRenderOptions(i),t=$(this.getOrCreateLineCache(i).length,this.getTokenizeMaxLength());let n=this.workerManager?.getFileResultCache(i);n!=null&&!F(e,n.options)&&(n=void 0),this.renderCache??={file:i,options:e,highlighted:!t&&!q(i),result:t?void 0:n?.result,renderRange:void 0},this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!t&&this.workerManager.highlightFileAST(this,i):this.highlighter==null&&(this.computedLang=i.lang??j(i.name),this.initializeHighlighter())}getRenderOptions(i){const e=(()=>{if(this.workerManager?.isWorkingPool()===!0)return this.workerManager.getFileRenderOptions();const{theme:n=H,tokenizeMaxLineLength:r=1e3}=this.options;return{theme:n,useTokenTransformer:Pe(this.options),tokenizeMaxLineLength:r}})(),{renderCache:t}=this;return t?.result==null?{options:e,forceHighlight:!0}:!A(i,t.file)||!F(e,t.options)?{options:e,forceHighlight:!0}:{options:e,forceHighlight:!1}}getOrCreateLineCache(i){if(i.cacheKey==null)return this.lineCache=void 0,pe(i.contents);let{lineCache:e}=this;return(e==null||e.cacheKey!==i.cacheKey)&&(e={cacheKey:i.cacheKey,lines:pe(i.contents)}),this.lineCache=e,e.lines}getLineCount(i){return this.textDoucmentCache.get(i)?.lineCount??this.getOrCreateLineCache(i).length}updateRenderCache(i,e){if(this.renderCache==null)return;const{result:t}=this.renderCache;if(t!=null){for(const[n,r]of i)t.code[n]={type:"element",tagName:"div",properties:{"data-line":n+1,"data-line-type":"context","data-line-index":n},children:r.map(([s,a,o])=>s===0&&a===""?o===""?{type:"element",tagName:"br",properties:{},children:[]}:{type:"text",value:o}:{type:"element",tagName:"span",properties:{"data-char":s,style:`--diffs-token-${e}:${a};`},children:[{type:"text",value:o}]})};t.baseThemeType=e,this.renderCache.isDirty=!0}}applyDocumentChange(i){if(this.renderCache==null)return;const{file:e,result:t}=this.renderCache;if(t!=null&&t.code.length!==i.lineCount){t.code.length=Math.min(t.code.length,i.lineCount);for(let n=t.code.length;n<i.lineCount;n++)t.code.push({type:"element",tagName:"div",properties:{"data-line":n+1,"data-line-type":"context","data-line-index":n},children:[{type:"element",tagName:"span",properties:{"data-char":0},children:[{type:"text",value:i.getLineText(n)}]}]});this.renderCache.isDirty=!0}this.textDoucmentCache.set(e,i)}renderFile(i=this.renderCache?.file,e=Z){if(i==null)return;let{options:t,forceHighlight:n}=this.getRenderOptions(i);const r=this.getMatchingWorkerResultCache(i,t);r!=null&&!this.hasHighlightedRenderCache(i,t)&&(this.renderCache={file:i,highlighted:!0,renderRange:void 0,...r},n=!1),this.renderCache??={file:i,highlighted:!1,options:t,result:void 0,renderRange:void 0};const s=this.getOrCreateLineCache(i),a=i.contents.length>0,o=!a||q(i)||$(s.length,this.getTokenizeMaxLength()),h=!A(i,this.renderCache.file),d=!Se(this.renderCache.renderRange,e);if(this.workerManager?.isWorkingPool()===!0)(o||this.renderCache.result==null||!this.renderCache.highlighted&&(h||d))&&(this.renderCache.file=i,this.renderCache.options=t,this.renderCache.highlighted=!1,(this.renderCache.result==null||h||d||n)&&(this.renderCache.result=this.workerManager.getPlainFileAST(i,e.startingLine,e.totalLines,s)),this.renderCache.renderRange=e),!o&&a&&(!this.renderCache.highlighted||n)&&this.workerManager.highlightFileAST(this,i);else{this.computedLang=i.lang??j(i.name);const l=this.highlighter!=null&&ie(t.theme),c=this.highlighter!=null&&ne(this.computedLang),u=!o&&c;if(this.highlighter!=null&&l&&(n||o||!this.renderCache.highlighted&&u||this.renderCache.result==null)){const{result:p,options:f}=this.renderFileWithHighlighter(i,this.highlighter,o||!c);this.renderCache={file:i,options:f,highlighted:u,result:p,renderRange:void 0}}(!l||!o&&!c)&&this.asyncHighlight(i).then(({result:p,options:f})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.onHighlightSuccess(i,p,f,!o)})}return this.renderCache.result!=null?this.processFileResult(this.renderCache.file,e,this.renderCache.result):void 0}async asyncRender(i,e=Z){const{result:t}=await this.asyncHighlight(i);return this.processFileResult(i,e,t)}async asyncHighlight(i){const e=$(this.getOrCreateLineCache(i).length,this.getTokenizeMaxLength());this.computedLang=e?"text":i.lang??j(i.name);const t=this.highlighter!=null&&Ct(ft(this.options.theme)),n=e||this.highlighter!=null&&ne(this.computedLang);return(this.highlighter==null||!t||!n)&&(this.highlighter=await this.initializeHighlighter()),this.renderFileWithHighlighter(i,this.highlighter,e)}renderFileWithHighlighter(i,e,t=!1){const{options:n}=this.getRenderOptions(i);return{result:St(i,e,n,{forcePlainText:t}),options:n}}processFileResult(i,e,{code:t,themeStyles:n,baseThemeType:r}){const s=this.getLineCount(i),{disableFileHeader:a=!1}=this.options,o=[],h=ue(),d=Math.min(e.startingLine+e.totalLines,s);let l=0;const c=ve(e)?Be(this.lineAnnotations):void 0;c!=null&&(h.children.push(de("context","annotation",1)),o.push(re({hunkIndex:-1,lineIndex:-1,annotations:c.map(u=>I(u))})),l++);for(let u=e.startingLine;u<d;u++){const p=u+1,f=t[u];if(f==null){const g="FileRenderer.processFileResult: Line doesnt exist";throw console.error(g,{name:i.name,lineIndex:u,lineNumber:p}),new Error(g)}h.children.push(pt("context",p,`${u}`)),o.push(f),l++;const S=this.lineAnnotations[p];S!=null&&(h.children.push(de("context","annotation",1)),o.push(re({hunkIndex:0,lineIndex:p,annotations:S.map(g=>I(g))})),l++)}return h.properties.style=`grid-row: span ${l}`,{gutterAST:h.children??[],contentAST:o,preAST:this.createPreElement(s),headerAST:a?void 0:this.renderHeader(i),totalLines:s,rowCount:l,themeStyles:n,baseThemeType:r,bufferBefore:e.bufferBefore,bufferAfter:e.bufferAfter,css:""}}renderHeader(i){const{headerRenderMode:e="default",stickyHeader:t=!1}=this.options;return De({fileOrDiff:i,mode:e,stickyHeader:t})}renderFullHTML(i){return M(this.renderFullAST(i))}renderFullAST(i,e=[]){return e.push(ce({tagName:"code",children:this.renderCodeAST(i),properties:{"data-code":""}})),{...i.preAST,children:e}}renderCodeAST(i){const e=ue();return e.children=i.gutterAST,e.properties.style=`grid-row: span ${i.rowCount}`,[e,Ue(i.contentAST,i.rowCount)]}renderPartialHTML(i,e=!1){return e?M(ce({tagName:"code",children:i,properties:{"data-code":""}})):M(i)}async initializeHighlighter(){return this.highlighter=await gt(_e(this.computedLang,this.options)),this.highlighter}onHighlightSuccess(i,e,t,n=!0){if(this.renderCache==null)return;const r=!A(i,this.renderCache.file)||!this.renderCache.highlighted||!F(t,this.renderCache.options);this.renderCache={file:i,options:t,highlighted:n,result:e,renderRange:void 0},r&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(i,e){const t=this.workerManager?.getFileResultCache(i);if(!(t==null||!F(e,t.options)))return t}hasHighlightedRenderCache(i,e){const{renderCache:t}=this;return t?.result!=null&&t.highlighted&&A(i,t.file)&&F(e,t.options)}onHighlightError(i){console.error(i)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}createPreElement(i){const{disableLineNumbers:e=!1,overflow:t="scroll"}=this.options;return We({type:"file",diffIndicators:"none",disableBackground:!0,disableLineNumbers:e,overflow:t,split:!1,totalLines:i})}};function $(i,e){return i>e}function Tt(i,e){return i.lineNumber===e.lineNumber&&i.metadata===e.metadata}function ge(i){return{theme:i?.theme,disableLineNumbers:i?.disableLineNumbers,overflow:i?.overflow,themeType:i?.themeType,collapsed:i?.collapsed,disableFileHeader:i?.disableFileHeader,disableVirtualizationBuffers:i?.disableVirtualizationBuffers,stickyHeader:i?.stickyHeader,preferredHighlighter:i?.preferredHighlighter,useCSSClasses:i?.useCSSClasses,useTokenTransformer:i?.useTokenTransformer,tokenizeMaxLineLength:i?.tokenizeMaxLineLength,tokenizeMaxLength:i?.tokenizeMaxLength,unsafeCSS:i?.unsafeCSS,headerRenderMode:i?.renderCustomHeader!=null?"custom":"default"}}const bt=[""];let Rt=-1;var Te=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file:${++Rt}`;type="file";fileContainer;spriteSVG;pre;code;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;errorWrapper;placeHolder;lastRenderedHeaderHTML;cachedHeaderHTML;appliedPreAttributes;lastRowCount;mounted=!1;headerElement;headerCustom;headerPrefix;headerFilenameSuffix;headerMetadata;fileRenderer;resizeManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;file;renderRange;enabled=!0;editor;constructor(e={theme:H},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new yt(e,this.handleHighlightRender,this.workerManager),this.resizeManager=new Ge,this.interactionManager=new je("file",se(e)),this.workerManager?.subscribeToThemeChanges(this)}handleHighlightRender=()=>{this.rerender()};rerender(){!this.enabled||this.file==null||this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(se(this.options))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??"system")!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme=="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;const t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType===t?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!mt(this.appliedThemeCSS.theme,this.options.theme??H)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}const{overflow:e="scroll"}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,e==="wrap"),this.managersDirty=!1}cleanUp(e=!1){this.emitPostRender(!0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.annotationCache.clear(),this.pre=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.placeHolder=void 0,this.unsafeCSSStyle=void 0,e?this.fileRenderer.recycle():(this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0),this.enabled=!1,this.editor?.cleanUp(),this.editor=void 0}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){const{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,file:s,lineAnnotations:a}=e;this.hydrateElements(t,n),Lt(this.pre,s,this.options.collapsed)||At(this.headerElement,s,this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({file:s,lineAnnotations:a}),r||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),$e(e,t);for(const n of Array.from(e.shadowRoot?.children??[])){if(n instanceof SVGElement){this.spriteSVG=n;continue}if(n instanceof HTMLElement){if(n instanceof HTMLPreElement){this.pre=n,this.appliedPreAttributes=void 0;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-theme-css")){this.themeCSSStyle=n;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-unsafe-css")){this.unsafeCSSStyle=n,this.appliedUnsafeCSS=n.textContent;continue}if("diffsHeader"in n.dataset){this.headerElement=n,this.lastRenderedHeaderHTML=void 0;continue}}}this.pre!=null&&(this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute("data-dehydrated")),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({file:e,lineAnnotations:t}){this.lineAnnotations=t??this.lineAnnotations,this.file=e,this.fileRenderer.setOptions(ge(this.options)),this.syncInteractionOptions(),this.pre!=null&&(this.fileRenderer.hydrate(e),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}getOrCreateLineCache(e=this.file){return e!=null?this.fileRenderer.getOrCreateLineCache(e):bt}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}syncRenderViewToEditor(){const e=this.editor,t=this.fileContainer,n=this.file;e!=null&&t!=null&&n!=null&&this.fileRenderer.initializeHighlighter().then(r=>{e.__syncRenderView(r,t,n,this.lineAnnotations,this.renderRange)})}attachEditor(e){return this.editor?.cleanUp(),this.editor=e,this.interactionManager.setEditorAttached(!0),this.syncRenderViewToEditor(),()=>{this.editor=void 0,this.interactionManager.setEditorAttached(!1)}}applyDocumentChange(e,t){this.fileRenderer.applyDocumentChange(e),t!=null&&t!==this.lineAnnotations&&this.file!=null&&(this.setLineAnnotations(t),this.fileRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations())}updateRenderCache(e,t){this.fileRenderer.updateRenderCache(e,t)}render({file:e,fileContainer:t,forceRender:n=!1,preventEmit:r=!1,containerWrapper:s,deferManagers:a=!1,lineAnnotations:o,renderRange:h}){if(!this.enabled)throw new Error("File.render: attempting to call render after cleaned up");this.editor?.__postponeBackgroundTokenizeToNextFrame();const{collapsed:d=!1,themeType:l="system"}=this.options,c=d?void 0:h,u=this.renderRange,p=this.hasThemeChanged(),f=o!=null&&(o.length>0||this.lineAnnotations.length>0)?o!==this.lineAnnotations:!1,S=!A(this.file,e);if(!d&&!n&&Se(c,this.renderRange)&&!S&&!f&&!p)return this.applyCachedThemeState(l);this.renderRange=c,S&&(this.cachedHeaderHTML=void 0),this.file=e,this.fileRenderer.setOptions(ge(this.options)),this.syncInteractionOptions(),o!=null&&this.setLineAnnotations(o),this.fileRenderer.setLineAnnotations(this.lineAnnotations);const{disableErrorHandling:g=!1,disableFileHeader:y=!1}=this.options;if(y&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),t=this.getOrCreateFileContainerNode(t,s),this.applyCachedThemeState(l),d){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{const m=this.fileRenderer.renderFile(e,Fe);m!=null&&this.applyThemeState(t,m.themeStyles,l,m.baseThemeType),m?.headerAST!=null&&this.applyHeaderToDOM(m.headerAST,t),this.injectUnsafeCSS()}catch(m){if(g)throw m;console.error(m),m instanceof Error&&this.applyErrorToDOM(m,t)}return r||this.emitPostRender(),!0}try{const m=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,f,S||p)||!this.applyPartialRender(u,c)){const v=this.fileRenderer.renderFile(e,c);if(v==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(t,v.themeStyles,l,v.baseThemeType),v.headerAST!=null&&this.applyHeaderToDOM(v.headerAST,t),this.applyFullRender(v,m)}this.applyBuffers(m,c),this.injectUnsafeCSS(),this.managersDirty=!0,a||this.flushManagers(),this.renderAnnotations(),this.renderGutterUtility(),this.editor!=null&&this.syncRenderViewToEditor()}catch(m){if(g)throw m;console.error(m),m instanceof Error&&this.applyErrorToDOM(m,t)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){const{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;n?.(t,this,"unmount");return}if(t==null)return;const r=this.mounted?"update":"mount";this.mounted=!0,n?.(t,this,r)}removeRenderedCode(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.code?.remove(),this.code=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(const{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(e,t,n){return!(e||t||n)}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){const t=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",t.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${e}px`),!0}primeHighlightCache(){const{file:e,workerManager:t}=this;e==null||e.cacheKey==null||t==null||q(e)||this.fileRenderer.getOrCreateLineCache(e).length>(this.options.tokenizeMaxLength??1e5)||t.primeFileHighlightCache(e)}cleanChildNodes(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.code?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.gutterUtilityContent?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.code=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.gutterUtilityContent=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(const{element:n}of this.annotationCache.values())n.remove();this.annotationCache.clear();return}const e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(const[n,r]of this.lineAnnotations.entries()){const s=`${n}-${I(r)}`;let a=this.annotationCache.get(s);if(a==null||!Tt(r,a.annotation)){a?.element.remove();const o=t(r);if(o==null)continue;a={element:Ke(I(r)),annotation:r},a.element.appendChild(o),this.fileContainer.appendChild(a.element),this.annotationCache.set(s,a)}e.delete(s)}for(const[n,{element:r}]of e.entries())this.annotationCache.delete(n),r.remove()}renderGutterUtility(){const{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const n=qe();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){const{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===""){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??=Je(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=Ye(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){const s=e.shadowRoot??e.attachShadow({mode:"open"}),a=r??n,o=this.options.theme??H,h=typeof o=="string"?o:{...o},d=ae(s);if(this.themeCSSStyle?.parentNode===s&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===d){this.appliedThemeCSS.theme=h;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===s){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:h,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:d};return}this.themeCSSStyle=Xe({shadowRoot:s,currentNode:this.themeCSSStyle,themeCSS:Qe(t,a,d)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:h,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:d}:void 0}hydrateMeasuredScrollbar(){const e=this.fileContainer?.shadowRoot;e==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=Ze(this.themeCSSStyle.textContent??"",ae(e)))}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e),this.code=et({code:this.code});const n=this.fileRenderer.renderCodeAST(e);if(this.code.childElementCount>=2)for(let r=0;r<2;r++){const s=this.code.children[r],a=n[r];s.innerHTML=M(a.children),s.style.cssText=a.properties.style}else this.code.innerHTML=M(n);t.contains(this.code)||t.replaceChildren(this.code),this.lastRowCount=e.rowCount}applyPartialRender(e,t){if(e==null||t==null)return!1;const{file:n,code:r}=this,s=r!=null?this.getColumns(r):void 0;if(n==null||r==null||s==null)return!1;const a=e.startingLine,o=t.startingLine,h=e.totalLines===1/0?Number.POSITIVE_INFINITY:a+e.totalLines,d=t.totalLines===1/0?Number.POSITIVE_INFINITY:o+t.totalLines,l=Math.max(a,o),c=Math.min(h,d);if(c<=l||!this.trimDOMToOverlap(s.gutter,l,c)||!this.trimDOMToOverlap(s.content,l,c))return!1;let{length:u}=s.content.children;const p=(y,m)=>{if(!(m<=0))return this.fileRenderer.renderFile(n,{startingLine:y,totalLines:m,bufferBefore:0,bufferAfter:0})},f=o<l?p(o,l-o):void 0;if(f===void 0&&o<l)return!1;const S=d===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:Math.max(0,d-c),g=d>c?p(c,S):void 0;return g===void 0&&d>c?!1:(this.cleanupErrorWrapper(),f!=null&&(s.gutter.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(f.gutterAST)),s.content.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(f.contentAST)),u+=f.rowCount),g!=null&&(s.gutter.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(g.gutterAST)),s.content.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(g.contentAST)),u+=g.rowCount),this.lastRowCount!==u&&(s.gutter.style.setProperty("grid-row",`span ${u}`),s.content.style.setProperty("grid-row",`span ${u}`),this.lastRowCount=u),!0)}getColumns(e){const t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}trimDOMToOverlap(e,t,n){const r=this.getDOMBoundaryIndices(e,[t,n]),s=r.get(t)??e.children.length,a=r.get(n)??e.children.length;if(s>a)return!1;for(let o=e.children.length-1;o>=a;o-=1)e.children[o]?.remove();for(let o=s-1;o>=0;o-=1)e.children[o]?.remove();return!0}getDOMBoundaryIndices(e,t){const n=[...new Set(t)].sort((h,d)=>h-d),r=new Map;if(n.length===0)return r;let s=0,a=n[s];const{children:o}=e;a===0&&(r.set(0,0),s+=1,a=n[s]);for(let h=0;h<o.length;h+=1){const d=o[h];if(!(d instanceof HTMLElement))continue;const l=this.getLineIndexFromDOMNode(d);if(l!=null){for(;a!=null&&l>=a;)r.set(a,h),s+=1,a=n[s];if(s>=n.length)break}}for(const h of n)r.has(h)||r.set(h,o.length);return r}getLineIndexFromDOMNode(e){const t=e.dataset.lineIndex;if(t==null)return;const n=Number(t);return Number.isNaN(n)?void 0:n}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore==null&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter==null&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyHeaderToDOM(e,t){const{file:n}=this;if(n==null)return;this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;const r=this.cachedHeaderHTML??M(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){const d=document.createElement("div");d.innerHTML=r;const l=d.firstElementChild;if(!(l instanceof HTMLElement))return;this.headerElement!=null?t.shadowRoot?.replaceChild(l,this.headerElement):t.shadowRoot?.prepend(l),this.headerElement=l,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged)return;const{renderHeaderPrefix:s,renderHeaderFilenameSuffix:a,renderCustomHeader:o,renderHeaderMetadata:h}=this.options;if(o!=null){const d=o(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,Ce,d),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0}else{const d=s?.(n)??void 0,l=a?.(n)??void 0,c=h?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,ke,d),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,Ie,l),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,ze,c),this.headerCustom?.remove(),this.headerCustom=void 0}}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}const s=t??this.createHeaderSlotElement(n);return t==null&&e.appendChild(s),this.replaceHeaderSlotContent(s,r),s}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){const t=document.createElement("div");return t.slot=e,t}getOrCreateFileContainerNode(e,t){const{fileContainer:n}=this,r=e??n??document.createElement("diffs-container"),s=n!==r;return s&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&s&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),s&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){const{shadowRoot:t}=e;if(t!=null)for(const n of t.children)n instanceof SVGElement?this.spriteSVG??=n:oe(n)&&n.hasAttribute("data-theme-css")?(this.themeCSSStyle??=n,this.hasAdoptedThemeCSS=!0):oe(n)&&n.hasAttribute("data-unsafe-css")&&(this.unsafeCSSStyle??=n,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.spriteSVG==null){const n=document.createElement("div");n.innerHTML=tt;const r=n.firstChild;r instanceof SVGElement&&(this.spriteSVG=r)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});return this.pre==null?(this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.code=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(e.shadowRoot?.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(e){this.code=void 0;for(const t of Array.from(e.children))if(t instanceof HTMLElement&&t.hasAttribute("data-code")){this.code=t;return}}applyPreNodeAttributes(e,{totalLines:t}){const{overflow:n="scroll",disableLineNumbers:r=!1}=this.options,s={type:"file",split:!1,overflow:n,disableLineNumbers:r,diffIndicators:"none",disableBackground:!0,totalLines:t};it(s,this.appliedPreAttributes)||(nt(e,s),this.appliedPreAttributes=s)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;const n=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??=document.createElement("div"),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.textContent="",n.appendChild(this.errorWrapper);const r=document.createElement("div");r.dataset.errorMessage="",r.innerText=e.message,this.errorWrapper.appendChild(r);const s=document.createElement("pre");s.dataset.errorStack="",s.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(s)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function Lt(i,e,t=!1){return!t&&i==null&&e!=null}function At(i,e,t=!1){return i==null&&e!=null&&!t}const Ht=5e3;let Mt=-1;function xt(i,e){return(i.overflow??"scroll")!==(e.overflow??"scroll")||(i.collapsed??!1)!==(e.collapsed??!1)||(i.disableLineNumbers??!1)!==(e.disableLineNumbers??!1)||(i.disableFileHeader??!1)!==(e.disableFileHeader??!1)||i.unsafeCSS!==e.unsafeCSS}var wt=class extends Te{virtualizer;metrics;__id=`virtualized-file:${++Mt}`;top;height=0;cache={heights:new Map,checkpoints:[],fileAnnotationHeight:0};isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(i,e,t=Ne,n,r=!1){super(i,n,r),this.virtualizer=e,this.metrics=t}setMetrics(i,e=!1){!e&&rt(this.metrics,i)||(this.metrics=i,this.resetLayoutCache())}setLineAnnotations(i){this.syncLineAnnotations(i)&&this.resetLayoutCache()}syncLineAnnotations(i){return i==null||i===this.lineAnnotations||i.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(i),!0)}hasLineAnnotations(){return this.lineAnnotations.some(i=>i.lineNumber>0)}getLineHeight(i,e=!1){const t=this.cache.heights.get(i);if(t!=null)return t;const n=e?2:1;return this.metrics.lineHeight*n}setOptions(i){if(this.isAdvancedMode())throw new Error("VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.");if(i==null)return;const{options:e}=this,t=!ye(e,i),n=xt(e,i);super.setOptions(i),n&&this.resetLayoutCache(!0),t&&(this.forceRenderOverride=!0),t&&this.virtualizer.instanceChanged(this,n)}setThemeType(i){if(this.isAdvancedMode())throw new Error("VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.");super.setThemeType(i)}resetLayoutCache(i=!1){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heights.size>0&&this.cache.heights.clear(),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.renderRange!=null&&(this.renderRange=void 0),i&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let i=!1;if(this.fileContainer==null||this.file==null)return this.height!==0&&(i=!0),this.height=0,i;const{overflow:e="scroll"}=this.options;if(this.top=this.getVirtualizedTop(),e==="scroll"&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled()||this.code==null)return i;const t=this.code.children[1];if(!(t instanceof HTMLElement))return i;const n=he(this.lineAnnotations);if(this.renderRange!=null&&n&&ve(this.renderRange)){const r=Et(t)??0;r!==this.cache.fileAnnotationHeight&&(this.cache.fileAnnotationHeight=r,i=!0)}else!n&&this.cache.fileAnnotationHeight!==0&&(this.cache.fileAnnotationHeight=0,i=!0);for(const r of t.children){if(!(r instanceof HTMLElement))continue;const s=r.dataset.lineIndex;if(s==null)continue;const a=Number(s);let o=r.getBoundingClientRect().height,h=!1;r.nextElementSibling instanceof HTMLElement&&("lineAnnotation"in r.nextElementSibling.dataset||"noNewline"in r.nextElementSibling.dataset)&&("noNewline"in r.nextElementSibling.dataset&&(h=!0),o+=r.nextElementSibling.getBoundingClientRect().height);const d=this.getLineHeight(a,h);o!==d&&(i=!0,o===this.metrics.lineHeight*(h?2:1)?this.cache.heights.delete(a):this.cache.heights.set(a,o))}return(i||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),i}onRender=i=>this.fileContainer==null||this.file==null?!1:(i&&(this.top=this.getVirtualizedTop()),this.render({file:this.file}));prepareCodeViewItem(i,e,t,n){const r=this.syncLineAnnotations(n);let s=t?.resetFileLayoutCache===!0||r;t?.metrics!=null&&(this.metrics=t.metrics,s=!0);const{collapsed:a=!1}=this.options;return this.currentCollapsed!==a&&(this.currentCollapsed=a,s=!0),s&&this.resetLayoutCache(),this.file!==i&&(this.layoutDirty=!0),this.file=i,this.top=e,this.computeApproximateSize(),this.height}getLinePosition(i){if(this.file==null||i<1)return;const{disableFileHeader:e=!1,collapsed:t=!1}=this.options,n=this.fileRenderer.getLineCount(this.file)-1;let r=B(this.metrics,e);if(t||n<0)return{top:r,height:0};const s=Math.min(Math.max(i-1,0),n),{overflow:a="scroll"}=this.options,{lineHeight:o}=this.metrics;if(r+=this.cache.fileAnnotationHeight,a==="scroll"&&!this.hasLineAnnotations())return{top:r+s*o,height:o};const h=this.getLayoutCheckpointBeforeLineIndex(s);r=h?.top??r;for(let d=h?.lineIndex??0;d<s;d++)r+=this.getLineHeight(d,!1);return{top:r,height:this.getLineHeight(s,!1)}}getNumericScrollAnchor(i){if(this.file==null||this.renderRange==null)return;const{disableFileHeader:e=!1,collapsed:t=!1,overflow:n="scroll"}=this.options;if(t||this.renderRange.totalLines<=0)return;const r=this.fileRenderer.getLineCount(this.file)-1;if(r<0)return;const s=B(this.metrics,e),a=Math.min(this.renderRange.startingLine,r),o=Math.min(a+this.renderRange.totalLines-1,r);if(o<a)return;const{fileAnnotationHeight:h}=this.cache;if(n==="scroll"&&!this.hasLineAnnotations()){const{lineHeight:l}=this.metrics,c=s+(a===0?h:this.renderRange.bufferBefore),u=a+Math.max(Math.ceil((i-c)/l),0);return u>o?void 0:{lineNumber:u+1,top:s+h+u*l}}let d=s+(a===0?h:this.renderRange.bufferBefore);for(let l=a;l<=o;l++){if(d>=i)return{lineNumber:l+1,top:d};d+=this.getLineHeight(l)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(i){if(this.top==null||this.file==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};const e=i!=null?this.computeRenderRangeFromWindow(this.file,this.top,i):this.renderRange;if(e==null)return;const{bufferBefore:t,bufferAfter:n,totalLines:r}=e;let s=0;if(r===0){const a=i??this.virtualizer.getWindowSpecs();this.top<a.top&&(s=n)}return{topOffset:this.top+t+s,height:this.height-(t+n)}}cleanUp(i=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),i||this.resetLayoutCache(),this.isSetup=!1,super.cleanUp(i)}computeApproximateSize(i=!1){const e=this.isResizeDebuggingEnabled();if(!i&&!this.layoutDirty&&!e)return;const t=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.file==null){this.layoutDirty=!1;return}const{disableFileHeader:n=!1,collapsed:r=!1,overflow:s="scroll"}=this.options,{lineHeight:a}=this.metrics,o=this.fileRenderer.getLineCount(this.file),h=B(this.metrics,n),d=fe(this.metrics);if(this.height+=h,r){this.layoutDirty=!1;return}if(this.height+=this.cache.fileAnnotationHeight,s==="scroll"&&!this.hasLineAnnotations())this.height+=o*a;else for(let l=0;l<o;l++)this.addLayoutCheckpoint(l,this.height),this.height+=this.getLineHeight(l,!1);if(o>0&&(this.height+=d),this.fileContainer!=null&&e&&!t){const l=this.fileContainer.getBoundingClientRect();l.height!==this.height?console.log("VirtualizedFile.computeApproximateSize: computed height doesnt match",{name:this.file.name,elementHeight:l.height,computedHeight:this.height}):console.log("VirtualizedFile.computeApproximateSize: computed height IS CORRECT")}this.layoutDirty=!1}setVisibility(i){this.isAdvancedMode()||this.fileContainer==null||(i&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!i&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.file==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(i,e,t=!1){const{heights:n,checkpoints:r}=this.cache,s=this.renderRange;if(super.applyDocumentChange(i,e),this.getSimpleVirtualizer()?.markDOMDirty(),this.layoutDirty=!0,n.size>0&&n.clear(),r.length>0&&(r.length=0),this.isSimpleMode()&&this.computeApproximateSize(),t&&s!==void 0&&this.file!==void 0){const a=this.virtualizer.getWindowSpecs(),o=this.computeRenderRangeFromWindow(this.file,this.top??0,a);o.bufferAfter!==s.bufferAfter&&this.updateBuffers(o)}}render({fileContainer:i,file:e,forceRender:t=!1,lineAnnotations:n,...r}){const s=this.file==null||!A(this.file,e),{forceRenderOverride:a,isSetup:o}=this;this.forceRenderOverride=void 0;const h=this.syncLineAnnotations(n);if(h&&this.resetLayoutCache(),this.file=e,i=this.getOrCreateFileContainerNode(i),this.file==null)return console.error("VirtualizedFile.render: attempting to virtually render when we dont have file"),!1;if(o)this.top??=this.getVirtualizedTop(),s&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(!0));else{this.computeApproximateSize();const u=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(u==null)throw new Error("VirtualizedFile.render: simple virtualizer is not available");u.connect(i,this),this.isVisible=u.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode())return this.renderPlaceholder(this.height);const d=this.virtualizer.getWindowSpecs(),l=this.top??0,c=this.computeRenderRangeFromWindow(this.file,l,d);return super.render({file:this.file,fileContainer:i,renderRange:c,lineAnnotations:n,forceRender:(a??t)||h,...r})}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}isSimpleMode(){return this.virtualizer.type==="simple"}isAdvancedMode(){return this.virtualizer.type==="advanced"}addLayoutCheckpoint(i,e){i%Ht===0&&this.cache.checkpoints.push({lineIndex:i,top:e})}getLayoutCheckpointBeforeLineIndex(i){if(i<=0||this.cache.checkpoints.length===0)return;let e=0,t=this.cache.checkpoints.length-1,n;for(;e<=t;){const r=e+t>>1,s=this.cache.checkpoints[r];if(s==null)throw new Error("VirtualizedFile: invalid checkpoint index");s.lineIndex<=i?(n=s,e=r+1):t=r-1}return n}getLayoutCheckpointBeforeTop(i,e){let t=0,n=this.cache.checkpoints.length-1,r=-1;for(;t<=n;){const s=t+n>>1,a=this.cache.checkpoints[s];if(a==null)throw new Error("VirtualizedFile: invalid checkpoint index");a.top<=i?(r=s,t=s+1):n=s-1}if(e==null)return r>=0?this.cache.checkpoints[r]:void 0;for(let s=r;s>=0;s--){const a=this.cache.checkpoints[s];if(a==null)throw new Error("VirtualizedFile: invalid checkpoint index");if(a.lineIndex%e===0)return a}}getVirtualizedTop(){return this.virtualizer.type==="advanced"?this.virtualizer.getLocalTopForInstance(this):this.fileContainer!=null?this.virtualizer.getOffsetInScrollContainer(this.fileContainer):0}getSimpleVirtualizer(){return this.virtualizer.type==="simple"?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}computeRenderRangeFromWindow(i,e,{top:t,bottom:n}){const{disableFileHeader:r=!1,overflow:s="scroll"}=this.options,{hunkLineCount:a,lineHeight:o}=this.metrics,h=this.fileRenderer.getLineCount(i),d=this.height,l=B(this.metrics,r),c=h>0?fe(this.metrics):0,{fileAnnotationHeight:u}=this.cache,p=l+u,f=Math.max(0,d-l-u-c),S=he(this.lineAnnotations),g=e+l,y=u>0&&S&&g<n&&g+u>t;if(e<t-d||e>n)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-l-c};if(h<=a)return{startingLine:0,totalLines:a,bufferBefore:0,bufferAfter:0};const m=Math.ceil(Math.max(n-t,0)/o),v=Math.ceil(m/a)*a+a*2,z=v/a,D=(t+n)/2;if(s==="scroll"&&!this.hasLineAnnotations()){const R=e+p,P=R+f;if(!y&&!(R<n&&P>t))return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-l-c};const w=Math.floor(y&&D<e+p?0:(D-(e+p))/o),b=Math.floor(w/a)-Math.floor(z/2),xe=Math.ceil(h/a),E=Math.max(0,Math.min(b,xe))*a,Q=b<0?v+b*a:v,we=E===0?0:u+E*o,Ee=Math.min(Q,h-E);return{startingLine:E,totalLines:Q,bufferBefore:we,bufferAfter:Math.max(0,(h-E-Ee)*o)}}const be=z,N=[],U=this.getLayoutCheckpointBeforeTop(Math.max(0,t-e-v*o*2),a);let T=e+(U?.top??p),_=U?.lineIndex??0,O,V,x;const Re=U?.lineIndex??0;for(let R=Re;R<h;R++){const P=_%a===0,w=Math.floor(_/a);if(P&&(N[w]=T-(e+p),x!=null)){if(x<=0)break;x--}const b=this.getLineHeight(R,!1);T>t-b&&T<n&&(O??=w),T+b>D&&(V??=w),x==null&&T>=n&&P&&(x=be),_++,T+=b}if(O==null)if(y)O=0,V=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-l-c};V??=O;const W=Math.round(V-z/2),Le=Math.max(0,Math.ceil(h/a)-z),G=Math.max(0,Math.min(W,Le)),J=G*a,Y=W<0?v+W*a:v,Ae=N[G]??0,He=J===0?0:u+Ae,X=G+Y/a,Me=X<N.length?f-N[X]:f-(T-e-p);return{startingLine:J,totalLines:Y,bufferBefore:He,bufferAfter:Math.max(0,Me)}}};function Et(i){let e;for(const t of i.children)t instanceof HTMLElement&&t.dataset.lineAnnotation===st&&(e=Math.max(e??0,t.getBoundingClientRect().height));return e}function Ft({file:i,renderCustomHeader:e,renderHeaderPrefix:t,renderHeaderFilenameSuffix:n,renderHeaderMetadata:r,renderAnnotation:s,lineAnnotations:a,renderGutterUtility:o,getHoveredLine:h}){const d=e?.(i),l=t?.(i),c=n?.(i),u=r?.(i);return C.jsxs(C.Fragment,{children:[d!=null?C.jsx("div",{slot:Ce,children:d}):C.jsxs(C.Fragment,{children:[l!=null&&C.jsx("div",{slot:"header-prefix",children:l}),c!=null&&C.jsx("div",{slot:"header-filename-suffix",children:c}),u!=null&&C.jsx("div",{slot:"header-metadata",children:u})]}),s!=null&&a?.map((p,f)=>C.jsx("div",{slot:I(p),children:s(p)},f)),o!=null&&C.jsx("div",{slot:"gutter-utility-slot",style:at,children:o(h)})]})}const me=typeof window>"u"?k.useEffect:k.useLayoutEffect;function kt({file:i,options:e,lineAnnotations:t,selectedLines:n,prerenderedHTML:r,metrics:s,hasGutterRenderUtility:a,hasCustomHeader:o,disableWorkerPool:h,contentEditable:d}){const l=ot(),c=n!==void 0,u=k.useContext(ht),p=lt(),f=k.useRef(null),S=dt(g=>{if(g!=null){if(f.current!=null)throw new Error("File: An instance should not already exist when a node is created");l!=null?f.current=new wt(K({controlledSelection:c,contentEditable:d,hasCustomHeader:o,hasEditor:p!==void 0,hasGutterRenderUtility:a,options:e}),l,s,h?void 0:u,!0):f.current=new Te(K({controlledSelection:c,contentEditable:d,hasCustomHeader:o,hasEditor:p!==void 0,hasGutterRenderUtility:a,options:e}),h?void 0:u,!0),f.current.hydrate({file:i,fileContainer:g,lineAnnotations:t,prerenderedHTML:r})}else{if(f.current==null)throw new Error("File: A File instance should exist when unmounting");f.current.cleanUp(),f.current=null}});return me(()=>{if(f.current==null)return;const g=K({controlledSelection:c,contentEditable:d,hasCustomHeader:o,hasEditor:p!==void 0,hasGutterRenderUtility:a,options:e}),y=!ye(f.current.options,g);f.current.setOptions(g),f.current.render({file:i,lineAnnotations:t,forceRender:y}),n!==void 0&&f.current.setSelectedLines(n)}),me(()=>{if(d&&f.current!=null){if(p===void 0)throw new Error("File: Editor is not attached");return p.edit(f.current)}},[d,p]),{ref:S,getHoveredLine:k.useCallback(()=>f.current?.getHoveredLine(),[])}}function K({options:i,controlledSelection:e,contentEditable:t,hasCustomHeader:n,hasEditor:r,hasGutterRenderUtility:s}){const a=t&&r,o=e||s||n;if(!o&&!a)return i;let h={...i};return o&&(h={...h,controlledSelection:e,renderCustomHeader:n?le:i?.renderCustomHeader,renderGutterUtility:s?le:i?.renderGutterUtility}),a&&(h={...h,useTokenTransformer:!0,enableGutterUtility:!1,enableLineSelection:!1,lineHoverHighlight:"disabled"}),h}function Ut({file:i,lineAnnotations:e,selectedLines:t,options:n,metrics:r,className:s,style:a,renderAnnotation:o,renderCustomHeader:h,renderHeaderPrefix:d,renderHeaderFilenameSuffix:l,renderHeaderMetadata:c,prerenderedHTML:u,renderGutterUtility:p,disableWorkerPool:f=!1,contentEditable:S=!1}){const{ref:g,getHoveredLine:y}=kt({file:i,options:n,metrics:r,lineAnnotations:e,selectedLines:t,prerenderedHTML:u,hasGutterRenderUtility:p!=null,hasCustomHeader:h!=null,disableWorkerPool:f,contentEditable:S});return C.jsx(Oe,{ref:g,className:s,style:a,children:ct(Ft({file:i,renderAnnotation:o,renderCustomHeader:h,renderHeaderPrefix:d,renderHeaderFilenameSuffix:l,renderHeaderMetadata:c,renderGutterUtility:p,lineAnnotations:e,getHoveredLine:y}),u)})}const _t=L.memo(function({jsonString:e,className:t,maxHeight:n="100%",initiallyExpandedDepth:r=2}){const s=L.useRef(null),[a,o]=L.useState(null),h=L.useMemo(()=>{try{const c=e.trim();if(!c)return o("Empty JSON content"),null;const u=JSON.parse(c);return o(null),u}catch(c){return o(c instanceof Error?c.message:"Invalid JSON"),null}},[e]),d=L.useCallback(()=>{s.current?.expandAll()},[]),l=L.useCallback(()=>{s.current?.collapseAll()},[]);return a?C.jsx("div",{className:t,children:C.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] bg-[var(--syntax-base-background)] p-4",children:[C.jsx("div",{className:"mb-1 font-medium text-[var(--surface-foreground)]",children:"Invalid JSON"}),C.jsx("div",{className:"font-mono text-xs text-[var(--surface-mutedForeground)]",children:a})]})}):h===null?null:C.jsxs("div",{className:t,children:[C.jsxs("div",{className:"flex items-center gap-1 border-b border-[var(--interactive-border)] px-2 py-1",children:[C.jsxs(ee,{variant:"ghost",size:"xs",onClick:d,className:"gap-1 text-xs text-muted-foreground",children:[C.jsx(te,{name:"arrow-down-s",className:"h-3 w-3"}),"Expand All"]}),C.jsxs(ee,{variant:"ghost",size:"xs",onClick:l,className:"gap-1 text-xs text-muted-foreground",children:[C.jsx(te,{name:"arrow-up-s",className:"h-3 w-3"}),"Collapse All"]})]}),C.jsx("div",{className:"bg-[var(--syntax-base-background)] py-1",style:{maxHeight:n,overflow:"auto"},children:C.jsx(Ve,{ref:s,data:h,maxHeight:n,initiallyExpandedDepth:r})})]})});export{Ut as F,_t as J};
|
|
@@ -0,0 +1,12 @@
|
|
|
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,C as Ge,u as T,r as Ye,D as te,E as Je,c as X,g as re}from"./index-Bkz23mZq.js";import{ap as ve,aq as Qe,ar as et,af as H,as as tt,at as rt,au as nt,av as ot,aw as at,ax as ne,ay as it,az as st,aA as lt,j as ke,aB as Ce,aC as Ee,aD as ct,i as dt}from"./useAppFontEffects-Bg-8jtrQ.js";import{r as mt,s as ut,i as pt,a as ft,b as ht}from"./markdownCore-CmFv4H-w.js";import{r as gt}from"./registerCustomTheme-DmolaWWZ.js";import{i as bt}from"./runtimeSurface-SmPSdfop.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-CP8ck10N.js";import"./vendor-dnd-kit-utilities-DTY1C6ST.js";import"./vendor-dnd-kit-accessibility-DZKKhs9S.js";import"./vendor-dnd-kit-sortable-B-Icjoj4.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-B5cJDWBR.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{aa as j,ab as y,ac as D}from"./useAppFontEffects-Bg-8jtrQ.js";import{g as k,a as C}from"./web-components-0H9kvZwn.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-DdPbLdh7.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:b(n,e.startContentIndex)}}function b(e,t){let n=e.unifiedLineStart;for(let l=0;l<t;l++){const o=e.hunkContent[l];n+=o.type==="context"?o.lines:o.deletions+o.additions}return n}function z(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 U({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:l,renderHeaderFilenameSuffix:o,renderHeaderMetadata:x,renderAnnotation:d,renderGutterUtility:u,renderMergeConflictUtility:s,lineAnnotations:f,getHoveredLine:p,getInstance:m}){const g=n?.(e),c=l?.(e),i=o?.(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&&s!=null&&m!=null&&t.map(r=>{if(r==null)return;const h=$(r,e);return a.jsx("div",{slot:h,style:P,children:s(r,m)},h)}),u!=null&&a.jsx("div",{slot:"gutter-utility-slot",style:O,children:u(p)})]})}function $(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:o,metrics:x,hasGutterRenderUtility:d,hasCustomHeader:u,disableWorkerPool:s,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,s?void 0:g,!0):i.current=new N(E({controlledSelection:m,contentEditable:f,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:d,options:t}),s?void 0:g,!0),i.current.hydrate({fileDiff:e,fileContainer:r,lineAnnotations:n,prerenderedHTML:o})}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:o,hasGutterRenderUtility:x}){const d=n&&o,u=t||x||l;if(!u&&!d)return e;let s={...e};return u&&(s={...s,controlledSelection:t,renderCustomHeader:l?F:e?.renderCustomHeader,renderGutterUtility:x?F:e?.renderGutterUtility}),d&&(s={...s,useTokenTransformer:!0,enableGutterUtility:!1,enableLineSelection:!1,expandUnchanged:!0,lineHoverHighlight:"disabled"}),s}function X({patch:e,options:t,metrics:n,lineAnnotations:l,selectedLines:o,className:x,style:d,prerenderedHTML:u,renderAnnotation:s,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:o,prerenderedHTML:u,hasGutterRenderUtility:c!=null,hasCustomHeader:f!=null,disableWorkerPool:i,contentEditable:v});return a.jsx(D,{ref:h,className:x,style:d,children:H(U({fileDiff:r,renderCustomHeader:f,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:g,renderAnnotation:s,lineAnnotations:l,renderGutterUtility:c,getHoveredLine:I}),u)})}function q(e){return w.useMemo(()=>z(e),[e])}export{X as P};
|