@pi-chamber/web 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/assets/{CommitSection-BQBmpPVE.js → CommitSection-DPjTv8fA.js} +1 -1
  2. package/dist/assets/{DiagramEditor-Cp22TGpq.js → DiagramEditor-ChOor9l9.js} +1 -1
  3. package/dist/assets/{DiagramView-E4HJ4ZPU.js → DiagramView-3hAT86v_.js} +1 -1
  4. package/dist/assets/{DiffView-d23o9CKP.js → DiffView-D1dyOiw2.js} +2 -2
  5. package/dist/assets/FilesView-BCzghrc7.js +14 -0
  6. package/dist/assets/{GitView-CkUONO1-.js → GitView-CYF1E1p4.js} +4 -4
  7. package/dist/assets/{JsonTreeView-By2oGMNK.js → JsonTreeView-CrJO6LNu.js} +1 -1
  8. package/dist/assets/{MarkdownRendererImpl-DUghE55t.js → MarkdownRendererImpl-BmKjrkGD.js} +2 -2
  9. package/dist/assets/{PatchDiff-BjN6zMtK.js → PatchDiff-DgvPLx6x.js} +1 -1
  10. package/dist/assets/{PierreDiffViewer-B38_7NnU.js → PierreDiffViewer-InnT0JVA.js} +2 -2
  11. package/dist/assets/{SessionSwitcherDropdown-NbVfnqQQ.js → SessionSwitcherDropdown-C0OdvirK.js} +102 -102
  12. package/dist/assets/{SettingsView-C2dCv0r7.js → SettingsView-JAfC_cBL.js} +1 -1
  13. package/dist/assets/{SettingsWindow-DsMhdX5H.js → SettingsWindow-BBEsjcJE.js} +1 -1
  14. package/dist/assets/{ToolOutputDialog-DVesARmI.js → ToolOutputDialog-gzwcb8nI.js} +4 -4
  15. package/dist/assets/{ToolPartDiffPreview-C2N_oIO-.js → ToolPartDiffPreview-C45V5bhy.js} +1 -1
  16. package/dist/assets/{VirtualizedFileDiff-B7eVR6Pt.js → VirtualizedFileDiff-uKfnkQWb.js} +1 -1
  17. package/dist/assets/{collapsible-CPkWB1VR.js → collapsible-Bq8sDiKS.js} +1 -1
  18. package/dist/assets/{computeVirtualFileMetrics-BsZulefS.js → computeVirtualFileMetrics-BPgZ_RSe.js} +2 -2
  19. package/dist/assets/{contextFileOpenGuard-BmmlK5E3.js → contextFileOpenGuard-CydO7PkI.js} +1 -1
  20. package/dist/assets/{index-C84KrQoy.js → index-BSuNNtBh.js} +1 -1
  21. package/dist/assets/{index-BhXma4dv.js → index-CH7o4-_q.js} +1 -1
  22. package/dist/assets/index-o4Eea60G.css +1 -0
  23. package/dist/assets/{isDiffPlainText-DsuyxFXo.js → isDiffPlainText-f9b4cKNo.js} +1 -1
  24. package/dist/assets/{isFilePlainText-CCYoe7us.js → isFilePlainText-BjESb-gU.js} +1 -1
  25. package/dist/assets/{main-ClYgYVm1.js → main-B508FBXr.js} +2 -2
  26. package/dist/assets/main-nG4uFyAy.js +133 -0
  27. package/dist/assets/{markdownCore-D2uqals1.js → markdownCore-BFmf8a-O.js} +2 -2
  28. package/dist/assets/{miniChat-DmX9SjxM.js → miniChat-BTlz8IPL.js} +2 -2
  29. package/dist/assets/{mobile-C-PCxN62.js → mobile-DBkrRt80.js} +2 -2
  30. package/dist/assets/renderElectronMiniChatApp-DW3fSR5w.js +1 -0
  31. package/dist/assets/renderMobileApp-9qkroKty.js +14 -0
  32. package/dist/assets/{runtimeSurface-CouGjZ3A.js → runtimeSurface-Bec4O8FD.js} +1 -1
  33. package/dist/assets/{useInlineCommentController-buNJ3xB4.js → useInlineCommentController-CHmIm0Rr.js} +2 -2
  34. package/dist/assets/usePanelSlide-DCX8qQ4K.js +56 -0
  35. package/dist/assets/{useWindowTitle-CnF4pKz0.js → useWindowTitle-CE5N_NeU.js} +3 -3
  36. package/dist/assets/{vendor-codemirror-autocomplete-3xMyV7a2.js → vendor-codemirror-autocomplete-BS2SpSAZ.js} +1 -1
  37. package/dist/assets/{vendor-codemirror-commands-Bzf12ODH.js → vendor-codemirror-commands-RrgJ8H_6.js} +1 -1
  38. package/dist/assets/{vendor-codemirror-lang-angular-0K6s6cvb.js → vendor-codemirror-lang-angular-ADhO_TUK.js} +1 -1
  39. package/dist/assets/{vendor-codemirror-lang-cpp-B0aL03z-.js → vendor-codemirror-lang-cpp-BGCWj7Om.js} +1 -1
  40. package/dist/assets/{vendor-codemirror-lang-css-C4jEScp7.js → vendor-codemirror-lang-css-Ba8JZ6fp.js} +1 -1
  41. package/dist/assets/{vendor-codemirror-lang-go-CgrfVBPr.js → vendor-codemirror-lang-go-DyTiHXo4.js} +1 -1
  42. package/dist/assets/{vendor-codemirror-lang-html-C1Svvdey.js → vendor-codemirror-lang-html-DK27qQri.js} +1 -1
  43. package/dist/assets/{vendor-codemirror-lang-java-DNPz7_Bx.js → vendor-codemirror-lang-java-CvFfnhPQ.js} +1 -1
  44. package/dist/assets/{vendor-codemirror-lang-javascript-CrbeaEAU.js → vendor-codemirror-lang-javascript-BUlYhQ3o.js} +1 -1
  45. package/dist/assets/{vendor-codemirror-lang-jinja-DL8BR_RG.js → vendor-codemirror-lang-jinja-wBMtAEvT.js} +1 -1
  46. package/dist/assets/{vendor-codemirror-lang-json-BTvAjwkJ.js → vendor-codemirror-lang-json-CqayksDf.js} +1 -1
  47. package/dist/assets/{vendor-codemirror-lang-less-CPABt6NZ.js → vendor-codemirror-lang-less-Ct3-H1PB.js} +1 -1
  48. package/dist/assets/{vendor-codemirror-lang-liquid-BLOLOBMg.js → vendor-codemirror-lang-liquid-XspREksq.js} +1 -1
  49. package/dist/assets/{vendor-codemirror-lang-markdown-BloD9GN-.js → vendor-codemirror-lang-markdown-CvO36Y1p.js} +1 -1
  50. package/dist/assets/{vendor-codemirror-lang-php-FIZMTuWM.js → vendor-codemirror-lang-php-BlUF9cCe.js} +1 -1
  51. package/dist/assets/{vendor-codemirror-lang-python-CR2g6ukK.js → vendor-codemirror-lang-python-_2bIYTiJ.js} +1 -1
  52. package/dist/assets/{vendor-codemirror-lang-rust-lsPqn4k4.js → vendor-codemirror-lang-rust-BdTYih_U.js} +1 -1
  53. package/dist/assets/{vendor-codemirror-lang-sass-CtECMwzH.js → vendor-codemirror-lang-sass-E6MhfOFk.js} +1 -1
  54. package/dist/assets/{vendor-codemirror-lang-sql-BtmZrrZH.js → vendor-codemirror-lang-sql-B1BRhQSF.js} +1 -1
  55. package/dist/assets/{vendor-codemirror-lang-vue-Br6DrntY.js → vendor-codemirror-lang-vue-BYQJRa1Q.js} +1 -1
  56. package/dist/assets/{vendor-codemirror-lang-wast-DT7IlCnb.js → vendor-codemirror-lang-wast-D706yuyC.js} +1 -1
  57. package/dist/assets/{vendor-codemirror-lang-xml-wNr-LZOf.js → vendor-codemirror-lang-xml--MfWU6Dj.js} +1 -1
  58. package/dist/assets/{vendor-codemirror-lang-yaml-BTKFwfc2.js → vendor-codemirror-lang-yaml-CRUFIbRX.js} +1 -1
  59. package/dist/assets/{vendor-codemirror-language-BuDklWi8.js → vendor-codemirror-language-E2vgV9K3.js} +1 -1
  60. package/dist/assets/{vendor-codemirror-language-data-qBLdzwMc.js → vendor-codemirror-language-data-q1yHU1R9.js} +2 -2
  61. package/dist/assets/{vendor-codemirror-search-BzyfPoRb.js → vendor-codemirror-search-8kyQdB3f.js} +1 -1
  62. package/dist/assets/{vendor-codemirror-state-Wdz6Qsow.js → vendor-codemirror-state-CNWM3Q8V.js} +1 -1
  63. package/dist/assets/{vendor-codemirror-view-pXtfpqbT.js → vendor-codemirror-view-DSzLbZiS.js} +1 -1
  64. package/dist/assets/{vendor-replit-codemirror-vim-BUqe2Slv.js → vendor-replit-codemirror-vim-BJY5fGLS.js} +1 -1
  65. package/dist/assets/{web-components-BhO08KaW.js → web-components-CLirSfwt.js} +1 -1
  66. package/dist/index.html +4 -4
  67. package/dist/mini-chat.html +3 -3
  68. package/dist/mobile.html +3 -3
  69. package/package.json +1 -1
  70. package/dist/assets/FilesView-DIDB-xK7.js +0 -14
  71. package/dist/assets/index-BZXqJcua.css +0 -1
  72. package/dist/assets/main-CmrF_CaW.js +0 -133
  73. package/dist/assets/renderElectronMiniChatApp-BhXZtZlU.js +0 -1
  74. package/dist/assets/renderMobileApp-DUSTAPWw.js +0 -23
  75. package/dist/assets/usePanelSlide-BRwyEEzi.js +0 -47
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderMobileApp-DUSTAPWw.js","assets/vendor-react-DYyjh7Q0.js","assets/vendor-scheduler-7OC5HNn7.js","assets/vendor-katex-CHD9BdDO.js","assets/vendor-katex-Cp579UoJ.css","assets/index-BhXma4dv.js","assets/vendor-zustand-CnsBKjP5.js","assets/index-BZXqJcua.css","assets/useWindowTitle-CnF4pKz0.js","assets/SessionSwitcherDropdown-NbVfnqQQ.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/runtimeSurface-CouGjZ3A.js","assets/vendor-dnd-kit-core-GipZW2tY.js","assets/vendor-dnd-kit-utilities-CrOcp0Bp.js","assets/vendor-dnd-kit-accessibility-Cv52zwWT.js","assets/vendor-dnd-kit-sortable-Ct2QxIHb.js","assets/vendor-base-ui-DwfTg5wD.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-react-dom-sVFnuruh.js","assets/vendor-floating-ui-dom-Bkw82kL9.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-use-sync-external-store-B7OScDIw.js","assets/vendor-cmdk-BCEUzcHE.js","assets/vendor-radix-ui-react-dialog-jX3Dld8c.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-D1GnwnP9.js","assets/vendor-radix-ui-react-context-CM4yFQ2I.js","assets/vendor-radix-ui-react-id-BcxRjnbX.js","assets/vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js","assets/vendor-radix-ui-react-use-controllable-state-C_ecoh35.js","assets/vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js","assets/vendor-radix-ui-react-primitive-CfpW6_IT.js","assets/vendor-radix-ui-react-slot-BxUc3Pvz.js","assets/vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js","assets/vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js","assets/vendor-radix-ui-react-focus-scope-C2K7lNPv.js","assets/vendor-radix-ui-react-portal-xlJWBfDg.js","assets/vendor-radix-ui-react-presence-Btn-Dp7L.js","assets/vendor-radix-ui-react-focus-guards-D5MZ0nQs.js","assets/vendor-react-remove-scroll-CfeMe0DL.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-C9YRs2nU.js","assets/vendor-react-style-singleton-B1H4bWSG.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-C-AuTczP.js","assets/vendor-use-callback-ref-CJB0R85I.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BuDklWi8.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-Wdz6Qsow.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-pXtfpqbT.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-CrbeaEAU.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-3xMyV7a2.js","assets/vendor-codemirror-lang-json-BTvAjwkJ.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-C4jEScp7.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-C1Svvdey.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BloD9GN-.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-qBLdzwMc.js","assets/vendor-codemirror-lang-python-CR2g6ukK.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-Bzf12ODH.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tanstack-react-virtual-IrbCBGJ4.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-DJASDzNt.js","assets/vendor-motion-dom-DJLgZh4Q.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-sonner-dWA7qvjr.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/usePanelSlide-BRwyEEzi.js","assets/permissionStore-BRcQ9Jgt.js","assets/usePanelSlide-BV3KOtdA.css","assets/SettingsView-C2dCv0r7.js","assets/vendor-qrcode-COsmt6jn.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/collapsible-CPkWB1VR.js","assets/vendor-aparajita-capacitor-secure-storage-5IShChL0.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/CommitSection-BQBmpPVE.js","assets/PierreDiffViewer-B38_7NnU.js","assets/web-components-BhO08KaW.js","assets/computeVirtualFileMetrics-BsZulefS.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-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.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-B7eVR6Pt.js","assets/isDiffPlainText-DsuyxFXo.js","assets/vendor-diff-C3JhlQdm.js","assets/useInlineCommentController-buNJ3xB4.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/vendor-remixicon-react-CzPq62YO.js"])))=>i.map(i=>d[i]);
2
- import{_ as o}from"./vendor-vite-runtime-DD1OZmLC.js";import{c as i}from"./index-BhXma4dv.js";import"./vendor-katex-CHD9BdDO.js";import"./vendor-zustand-CnsBKjP5.js";import"./vendor-react-DYyjh7Q0.js";import"./vendor-scheduler-7OC5HNn7.js";window.__PICHAMBER_RUNTIME_APIS__=i();o(async()=>{const{renderMobileApp:r}=await import("./renderMobileApp-DUSTAPWw.js");return{renderMobileApp:r}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127])).then(({renderMobileApp:r})=>{r()});
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderMobileApp-9qkroKty.js","assets/vendor-react-DYyjh7Q0.js","assets/vendor-scheduler-7OC5HNn7.js","assets/vendor-katex-CHD9BdDO.js","assets/vendor-katex-Cp579UoJ.css","assets/index-CH7o4-_q.js","assets/vendor-zustand-CnsBKjP5.js","assets/index-o4Eea60G.css","assets/useWindowTitle-CE5N_NeU.js","assets/SessionSwitcherDropdown-C0OdvirK.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/runtimeSurface-Bec4O8FD.js","assets/vendor-dnd-kit-core-GipZW2tY.js","assets/vendor-dnd-kit-utilities-CrOcp0Bp.js","assets/vendor-dnd-kit-accessibility-Cv52zwWT.js","assets/vendor-dnd-kit-sortable-Ct2QxIHb.js","assets/vendor-base-ui-DwfTg5wD.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-react-dom-sVFnuruh.js","assets/vendor-floating-ui-dom-Bkw82kL9.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-use-sync-external-store-B7OScDIw.js","assets/vendor-cmdk-BCEUzcHE.js","assets/vendor-radix-ui-react-dialog-jX3Dld8c.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-D1GnwnP9.js","assets/vendor-radix-ui-react-context-CM4yFQ2I.js","assets/vendor-radix-ui-react-id-BcxRjnbX.js","assets/vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js","assets/vendor-radix-ui-react-use-controllable-state-C_ecoh35.js","assets/vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js","assets/vendor-radix-ui-react-primitive-CfpW6_IT.js","assets/vendor-radix-ui-react-slot-BxUc3Pvz.js","assets/vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js","assets/vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js","assets/vendor-radix-ui-react-focus-scope-C2K7lNPv.js","assets/vendor-radix-ui-react-portal-xlJWBfDg.js","assets/vendor-radix-ui-react-presence-Btn-Dp7L.js","assets/vendor-radix-ui-react-focus-guards-D5MZ0nQs.js","assets/vendor-react-remove-scroll-CfeMe0DL.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-C9YRs2nU.js","assets/vendor-react-style-singleton-B1H4bWSG.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-C-AuTczP.js","assets/vendor-use-callback-ref-CJB0R85I.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-E2vgV9K3.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-DSzLbZiS.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-BUlYhQ3o.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-BS2SpSAZ.js","assets/vendor-codemirror-lang-json-CqayksDf.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-Ba8JZ6fp.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-DK27qQri.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-CvO36Y1p.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-q1yHU1R9.js","assets/vendor-codemirror-lang-python-_2bIYTiJ.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-RrgJ8H_6.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tanstack-react-virtual-IrbCBGJ4.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-DJASDzNt.js","assets/vendor-motion-dom-DJLgZh4Q.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-sonner-dWA7qvjr.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/usePanelSlide-DCX8qQ4K.js","assets/permissionStore-BRcQ9Jgt.js","assets/usePanelSlide-BV3KOtdA.css","assets/SettingsView-JAfC_cBL.js","assets/vendor-qrcode-COsmt6jn.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/collapsible-Bq8sDiKS.js","assets/vendor-aparajita-capacitor-secure-storage-5IShChL0.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/CommitSection-DPjTv8fA.js","assets/PierreDiffViewer-InnT0JVA.js","assets/web-components-CLirSfwt.js","assets/computeVirtualFileMetrics-BPgZ_RSe.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-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.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-uKfnkQWb.js","assets/isDiffPlainText-f9b4cKNo.js","assets/vendor-diff-C3JhlQdm.js","assets/useInlineCommentController-CHmIm0Rr.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/vendor-remixicon-react-CzPq62YO.js"])))=>i.map(i=>d[i]);
2
+ import{_ as o}from"./vendor-vite-runtime-DD1OZmLC.js";import{c as i}from"./index-CH7o4-_q.js";import"./vendor-katex-CHD9BdDO.js";import"./vendor-zustand-CnsBKjP5.js";import"./vendor-react-DYyjh7Q0.js";import"./vendor-scheduler-7OC5HNn7.js";window.__PICHAMBER_RUNTIME_APIS__=i();o(async()=>{const{renderMobileApp:r}=await import("./renderMobileApp-9qkroKty.js");return{renderMobileApp:r}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127])).then(({renderMobileApp:r})=>{r()});
@@ -0,0 +1 @@
1
+ import{j as n,R as a,e as ye,r as we}from"./vendor-react-DYyjh7Q0.js";import"./vendor-katex-CHD9BdDO.js";import{l as T,Q as ge,C as U,u as Y,J as xe,q as se,o as ve,w as Se,v as Ie}from"./index-CH7o4-_q.js";import{u as be,a as je,b as De,s as Ce,c as Pe,d as Me}from"./useWindowTitle-CE5N_NeU.js";import{c$ as Ee,h,bp as ke,b as Z,a5 as f,aB as ee,d0 as _e,C as Le,K as Ne,cN as Ae,ck as Re,cY as ie,cW as Oe,I as $,cX as Be,B as ae,f as Te,cV as N,d1 as ce,d2 as ze,c1 as Ue,t as We,b5 as He,aa as Fe,ab as $e,X as Ge,ad as Ve,ae as Ke,af as qe,ah as Je,ai as Xe,d3 as Qe,cl as Ye,ap as Ze,aq as et,ar as tt}from"./SessionSwitcherDropdown-C0OdvirK.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zustand-CnsBKjP5.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./runtimeSurface-Bec4O8FD.js";import"./vendor-dnd-kit-core-GipZW2tY.js";import"./vendor-dnd-kit-utilities-CrOcp0Bp.js";import"./vendor-dnd-kit-accessibility-Cv52zwWT.js";import"./vendor-dnd-kit-sortable-Ct2QxIHb.js";import"./vendor-base-ui-DwfTg5wD.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-sVFnuruh.js";import"./vendor-floating-ui-dom-Bkw82kL9.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-B7OScDIw.js";import"./vendor-cmdk-BCEUzcHE.js";import"./vendor-radix-ui-react-dialog-jX3Dld8c.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-D1GnwnP9.js";import"./vendor-radix-ui-react-context-CM4yFQ2I.js";import"./vendor-radix-ui-react-id-BcxRjnbX.js";import"./vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js";import"./vendor-radix-ui-react-use-controllable-state-C_ecoh35.js";import"./vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js";import"./vendor-radix-ui-react-primitive-CfpW6_IT.js";import"./vendor-radix-ui-react-slot-BxUc3Pvz.js";import"./vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js";import"./vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js";import"./vendor-radix-ui-react-focus-scope-C2K7lNPv.js";import"./vendor-radix-ui-react-portal-xlJWBfDg.js";import"./vendor-radix-ui-react-presence-Btn-Dp7L.js";import"./vendor-radix-ui-react-focus-guards-D5MZ0nQs.js";import"./vendor-react-remove-scroll-CfeMe0DL.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-C9YRs2nU.js";import"./vendor-react-style-singleton-B1H4bWSG.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-C-AuTczP.js";import"./vendor-use-callback-ref-CJB0R85I.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-E2vgV9K3.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-DSzLbZiS.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-BUlYhQ3o.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BS2SpSAZ.js";import"./vendor-codemirror-lang-json-CqayksDf.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-Ba8JZ6fp.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-DK27qQri.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-CvO36Y1p.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-q1yHU1R9.js";import"./vendor-codemirror-lang-python-_2bIYTiJ.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-RrgJ8H_6.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tanstack-react-virtual-IrbCBGJ4.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-DJASDzNt.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-dWA7qvjr.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";const rt=({mode:e,children:r})=>n.jsx(Ee.Provider,{value:e,children:r}),nt=e=>{const r=typeof e=="string"?e.trim():"";if(!r)return"";const o=typeof window<"u"?window.__PICHAMBER_HOME__:"";if(o&&r===o)return"~";if(o&&r.startsWith(`${o}/`))return`~/${r.slice(o.length+1)}`;const d=r.split("/").filter(Boolean);return d.length<=3?r:`.../${d.slice(-3).join("/")}`},G=e=>{const r=typeof e=="string"?e.trim():"";if(!r)return"";const o=r.replace(/\\/g,"/");return o==="/"?"/":o.replace(/\/+$/,"")},ot=({mode:e})=>{const r=h(t=>t.currentSessionId),o=h(t=>!!t.newSessionDraft?.open),d=h(t=>t.newSessionDraft?.selectedProjectId??null),i=T(t=>t.currentDirectory),u=Z(t=>t.projects),c=Z(t=>t.getActiveProject()),M=f(t=>t.getCurrentModel),_=f(t=>t.providers),p=ee(),m=_e(r??""),E=Le(),D=Ne(t=>t.ensureStatus),k=h(t=>t.newSessionDraft?.open?G(t.newSessionDraft.directoryOverride??""):""),[w,v]=a.useState(!1),C=typeof window<"u"?window.__PICHAMBER_MACOS_MAJOR__??0:0,S=Number.isFinite(C)&&C>0,{usesFramelessChrome:x,side:A}=Ae(),s=S?C>=26?"h-12":C<=15?"h-14":"":"",g=a.useMemo(()=>r?p.find(t=>t.id===r)??null:null,[r,p]);a.useEffect(()=>{ge()&&U("desktop_get_window_pinned").then(t=>{typeof t?.pinned=="boolean"&&v(t.pinned)})},[]);const y=g?.title?.trim()||(o||e==="draft"?"New session":"Session"),I=G(g?.directory??null),V=G(i),b=I||k||V,te=nt(b);a.useEffect(()=>{b&&D(b,E.git).catch(()=>{})},[D,b,E.git]);const re=a.useMemo(()=>{const t=b;return t?u.map(l=>({...l,normalizedPath:G(l.path)})).filter(l=>l.normalizedPath&&(l.normalizedPath===t||t.startsWith(`${l.normalizedPath}/`))).sort((l,B)=>B.path.length-l.path.length)[0]??null:null},[b,u]),de=a.useMemo(()=>{const t=re??c;if(!t)return te||"PiChamber";const l=t.label?.trim();return l||(t.path.split(/[\\/]/).filter(Boolean).at(-1)??t.path)},[c,te,re]),K=Re(b||null),ne=K&&K!=="HEAD"?K:null,oe=M(),le=a.useMemo(()=>{for(let t=m.length-1;t>=0;t-=1){const l=m[t];if(l.role!=="assistant"||typeof l.providerID!="string"||typeof l.modelID!="string")continue;const F=_.find(z=>z.id===l.providerID)?.models.find(z=>z.id===l.modelID);if(F)return F}},[m,_]),W=oe?.limit?oe:le,R=W&&typeof W.limit=="object"&&W.limit!==null?W.limit:null,O=R&&typeof R.context=="number"?R.context:0,H=R&&typeof R.output=="number"?R.output:0,j=a.useMemo(()=>{if(!r||m.length===0)return null;let t,l;for(let X=m.length-1;X>=0;X-=1){const Q=m[X];if(Q.role!=="assistant")continue;const L=Q.tokens;if(!L)continue;if(L.input+L.output+L.reasoning+(L.cache?.read??0)+(L.cache?.write??0)>0){t=L,l=Q.id;break}}if(!t)return null;const B=t.input+t.output+t.reasoning+(t.cache?.read??0)+(t.cache?.write??0),F=O>0?O:2e5,z=O>0?Math.round(B/O*100):0,he=H>0?Math.round(t.output/H*100):void 0;return{totalTokens:B,percentage:z,contextLimit:O||0,outputLimit:H||void 0,normalizedOutput:he,thresholdLimit:F,lastMessageId:l}},[O,r,m,H]),[P,q]=a.useState(null),ue={WebkitAppRegion:"drag"},J={WebkitAppRegion:"no-drag"};a.useEffect(()=>{if(!r){q(t=>t===null?t:null);return}if(j&&j.totalTokens>0){q(t=>t&&t.totalTokens===j.totalTokens&&t.percentage===j.percentage&&t.contextLimit===j.contextLimit&&(t.outputLimit??0)===(j.outputLimit??0)&&(t.normalizedOutput??0)===(j.normalizedOutput??0)&&t.thresholdLimit===j.thresholdLimit&&t.lastMessageId===j.lastMessageId?t:j);return}q(t=>t===null?t:null)},[j,r]);const me=P&&P.contextLimit>0?Math.min(999,P.totalTokens/P.contextLimit*100):0,pe=a.useCallback(()=>{const t=!w;v(t),U("desktop_set_window_pinned",{pinned:t}).catch(()=>{v(!t)})},[w]),fe=a.useCallback(()=>{const t=r?{sessionId:r,directory:g?.directory??i??""}:{mode:"draft",directory:b||i||"",projectId:d};U("desktop_focus_main_window",t).then(l=>l?.focused===!0?U("desktop_close_current_window"):null)},[i,r,d,b,g]);return n.jsxs("header",{className:Te("flex items-center gap-3 bg-background pr-3",S?"pl-[5.5rem]":"pl-3",x?"h-12":s||"min-h-14"),style:ue,children:[x&&A==="left"?n.jsx(ie,{visible:!0,position:"left"}):null,n.jsx(Oe,{children:n.jsxs("button",{type:"button","aria-label":"Open session switcher",style:J,className:"flex min-w-0 max-w-full flex-col items-start rounded-md px-1 py-0.5 text-left transition-colors hover:bg-interactive-hover/60 focus-visible:outline-none focus-visible:bg-interactive-hover/60",children:[n.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:y}),n.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[n.jsx("span",{className:"truncate",children:de}),ne?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[n.jsx($,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),n.jsx("span",{className:"truncate",children:ne})]}):null]})]})}),n.jsx("div",{className:"min-w-0 flex-1"}),P&&P.totalTokens>0?n.jsx(Be,{totalTokens:P.totalTokens,percentage:me,colorPercentage:P.percentage,contextLimit:P.contextLimit,outputLimit:P.outputLimit??0,className:"h-9 shrink-0 pl-1 pr-1 typography-ui-label",valueClassName:"font-semibold leading-none",hideIcon:!0,showPercentIcon:!0,percentIconClassName:"h-4.5 w-4.5"}):null,n.jsx(ae,{type:"button",variant:"ghost",size:"icon",onClick:pe,"aria-label":w?"Unpin Mini Chat window":"Pin Mini Chat window",title:w?"Unpin window":"Pin above other windows",style:J,children:w?n.jsx($,{name:"pushpin-2-fill",className:"h-4 w-4"}):n.jsx($,{name:"pushpin-2",className:"h-4 w-4"})}),n.jsx(ae,{type:"button",variant:"ghost",size:"icon",onClick:fe,"aria-label":"Open session in main window",title:"Open in main window",style:J,children:n.jsx($,{name:"external-link",className:"h-4 w-4"})}),n.jsx(ie,{visible:x&&A==="right",position:"right"})]})},st=({mode:e,autoOpenDraft:r=!1,unavailable:o=!1})=>{const d=h(i=>i.currentSessionId);return n.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:[n.jsx(ot,{mode:e}),n.jsx("main",{className:"min-h-0 flex-1",children:o?n.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center typography-ui-label text-muted-foreground",children:n.jsxs("div",{className:"max-w-sm rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-4 py-3",children:[n.jsx("div",{className:"font-medium text-foreground",children:"Session unavailable"}),n.jsx("div",{className:"mt-1 typography-small text-muted-foreground",children:"This session could not be loaded. It may have been deleted, archived, or opened from a different project context."})]})}):n.jsx(rt,{mode:"mini-chat",children:n.jsx(ke,{autoOpenDraft:r},d??"no-session")})})]})},it=()=>{const e=Y(i=>i.shortcutOverrides),r=T(i=>i.currentDirectory),o=Z(i=>i.getActiveProject()),d=h(i=>i.openNewSessionDraft);a.useEffect(()=>{const i=c=>He(c,e),u=c=>{if(N(c,i("focus_input"))){c.preventDefault(),ce();return}if(xe()&&N(c,i("new_mini_chat"))){c.preventDefault(),U("desktop_open_draft_mini_chat_window",{directory:r||o?.path||"",projectId:o?.id??null})?.catch(p=>{console.warn("[mini-chat-shortcuts] failed to open draft mini chat window",p)});return}if(N(c,i("new_chat"))){c.preventDefault(),d({selectedProjectId:o?.id??null,directoryOverride:r||o?.path||null,preserveDirectoryOverride:!!(r||o?.path)}),ce();return}if(N(c,i("open_model_selector"))){c.preventDefault();const{isModelSelectorOpen:p,setModelSelectorOpen:m}=Y.getState();m(!p);return}if(N(c,i("cycle_thinking_variant"))){if(f.getState().getCurrentModelVariants().length===0)return;c.preventDefault(),ze(1).then(E=>{const D=h.getState().currentSessionId,k=f.getState().currentAgentName,w=f.getState().currentProviderId,v=f.getState().currentModelId;D&&k&&w&&v&&Ue.getState().saveAgentModelVariantForSession(D,k,w,v,E)}).catch(()=>{We.error("Couldn't update thinking")});return}const M=N(c,i("cycle_favorite_model_forward")),_=N(c,i("cycle_favorite_model_backward"));if(M||_){const{favoriteModels:p,addRecentModel:m}=Y.getState();if(p.length===0)return;c.preventDefault();const{currentProviderId:E,currentModelId:D,setProvider:k,setModel:w}=f.getState(),v=p.findIndex(x=>x.providerID===E&&x.modelID===D),S=p[(v+(M?1:-1)+p.length)%p.length];k(S.providerID),w(S.modelID),m(S.providerID,S.modelID)}};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[o?.id,o?.path,r,d,e])},at="pichamber:mini-chat-presence",ct=()=>{const e=typeof window<"u"?new URLSearchParams(window.location.search):new URLSearchParams,r=e.get("mode")==="session"?"session":"draft",o=e.get("sessionId")?.trim()||null,d=e.get("directory")?.trim()||null,i=e.get("projectId")?.trim()||null;return{mode:r,sessionId:o,directory:d,projectId:i}},dt=({config:e})=>{const r=ee(),o=T(s=>s.currentDirectory),d=T(s=>s.setDirectory),i=h(s=>s.currentSessionId),u=h(s=>!!s.newSessionDraft?.open),c=h(s=>s.newSessionDraft?.open?s.newSessionDraft.bootstrapPendingDirectory??s.newSessionDraft.directoryOverride??"":""),M=h(s=>s.setCurrentSession),_=h(s=>s.openNewSessionDraft),p=f(s=>s.initializeApp),m=f(s=>s.isInitialized),E=f(s=>s.isConnected),D=f(s=>s.loadProviders),k=f(s=>s.loadAgents),w=f(s=>s.providers.length),v=f(s=>s.agents.length),C=Ye();a.useEffect(()=>{p()},[p]),a.useEffect(()=>{if(m)return;let s=!0,g=0;const y=window.setInterval(()=>{if(s){if(g+=1,g>10){window.clearInterval(y);return}f.getState().isInitialized||f.getState().initializeApp()}},1e3);return()=>{s=!1,window.clearInterval(y)}},[m]);const S=a.useRef(!1);a.useEffect(()=>{if(!S.current&&e.mode==="session"&&e.directory){if(o===e.directory){S.current=!0;return}d(e.directory,{showOverlay:!1}),S.current=!0}},[e.directory,e.mode,o,d]),a.useEffect(()=>{e.mode!=="draft"||!u||i||!c||o===c||d(c,{showOverlay:!1})},[e.mode,o,i,c,u,d]),a.useEffect(()=>{E&&(w===0&&D({source:"electronMiniChat:recovery"}),v===0&&k({source:"electronMiniChat:recovery"}))},[v,E,k,D,w]);const x=a.useRef(!1);a.useEffect(()=>{if(x.current||e.mode!=="session"||!e.sessionId)return;if(i===e.sessionId){x.current=!0;return}if(i){x.current=!0;return}const s=r.find(y=>y.id===e.sessionId);if(!s){C.ensureSessionRenderable(e.sessionId);return}const g=s.directory??e.directory;M(e.sessionId,g),x.current=!0},[e,i,r,M,C]),a.useEffect(()=>{const s=g=>{const y=g.detail,I=typeof y?.sessionId=="string"?y.sessionId.trim():"";if(!I||h.getState().currentSessionId===I)return;const V=typeof y?.directory=="string"&&y.directory.trim().length>0?y.directory.trim():r.find(b=>b.id===I)?.directory??null;C.ensureSessionRenderable(I),M(I,V),x.current=!0};return window.addEventListener("pichamber:open-session",s),()=>window.removeEventListener("pichamber:open-session",s)},[r,M,C]),a.useEffect(()=>{e.mode!=="draft"||u||i||_({selectedProjectId:e.projectId,directoryOverride:e.directory,preserveDirectoryOverride:!!e.directory})},[e,i,u,_]);const A=a.useRef(!1);return a.useEffect(()=>{if(A.current||!m)return;const s=()=>{if(A.current)return;A.current=!0;const I=typeof document<"u"?document.getElementById("initial-loading"):null;I&&(I.classList.add("fade-out"),window.setTimeout(()=>I.remove(),300))},g=e.mode==="session"?i===e.sessionId:u,y=window.setTimeout(s,g?100:1500);return()=>window.clearTimeout(y)},[m,e.mode,e.sessionId,i,u]),null},lt=()=>{const e=h(o=>o.currentSessionId),r=T(o=>o.currentDirectory);return a.useEffect(()=>{if(!e||!r||typeof BroadcastChannel>"u")return;const o=new BroadcastChannel(at),d=c=>{o.postMessage({type:"mini-chat-session-presence",sessionId:e,directory:r,viewed:c})};d(!0);const i=window.setInterval(()=>d(!0),5e3),u=()=>d(!1);return window.addEventListener("beforeunload",u),()=>{window.clearInterval(i),window.removeEventListener("beforeunload",u),d(!1),o.close()}},[r,e]),null},ut=e=>{const r=ee(),o=h(u=>u.currentSessionId),[d,i]=a.useState(!1);return a.useEffect(()=>{if(e.mode!=="session"||!e.sessionId||o===e.sessionId){i(!1);return}if(r.some(c=>c.id===e.sessionId)){i(!1);return}const u=window.setTimeout(()=>i(!0),5e3);return()=>window.clearTimeout(u)},[e.mode,e.sessionId,o,r]),d};function mt({apis:e}){const r=a.useMemo(()=>ct(),[]),o=T(d=>d.currentDirectory);return a.useEffect(()=>{Fe.setDirectory(o||r.directory||void 0)},[r.directory,o]),a.useEffect(()=>(se(e),()=>se(null)),[e]),$e(),it(),be({enabled:!0}),je(),n.jsx(Ge,{children:n.jsx(Ve,{directory:o||r.directory,children:n.jsx(Ke,{apis:e,children:n.jsx(qe,{delayDuration:300,skipDelayDuration:150,children:n.jsxs("div",{className:"h-full text-foreground bg-background",children:[n.jsx(pt,{config:r}),n.jsx(Je,{}),n.jsx(Xe,{})]})})})})})}const pt=({config:e})=>{const r=ut(e);return n.jsxs(n.Fragment,{children:[n.jsx(dt,{config:e}),n.jsx(lt,{}),n.jsx(Qe,{embeddedBackgroundWorkEnabled:!0}),n.jsx(st,{mode:e.mode,autoOpenDraft:e.mode==="draft",unavailable:r})]})},ft=()=>{Se().then(()=>{Promise.all([Ie(),De()]).catch(e=>{console.error("[mini-chat-main] settings init failed:",e)}),Ce(),Pe(),Me()}).catch(e=>{console.error("[mini-chat-main] appearance init failed:",e)})};function Fr(e){const r=e??ve();if(!r)throw new Error("Runtime APIs not registered");ft();const o=document.getElementById("root");if(!o)throw new Error("Root element not found");ye.createRoot(o).render(n.jsx(we.StrictMode,{children:n.jsx(Ze,{children:n.jsx(et,{children:n.jsx(tt,{children:n.jsx(mt,{apis:r})})})})}))}export{Fr as renderElectronMiniChatApp};
@@ -0,0 +1,14 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiffView-D1dyOiw2.js","assets/vendor-react-DYyjh7Q0.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-CH7o4-_q.js","assets/vendor-zustand-CnsBKjP5.js","assets/index-o4Eea60G.css","assets/SessionSwitcherDropdown-C0OdvirK.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/runtimeSurface-Bec4O8FD.js","assets/vendor-dnd-kit-core-GipZW2tY.js","assets/vendor-dnd-kit-utilities-CrOcp0Bp.js","assets/vendor-dnd-kit-accessibility-Cv52zwWT.js","assets/vendor-dnd-kit-sortable-Ct2QxIHb.js","assets/vendor-base-ui-DwfTg5wD.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-react-dom-sVFnuruh.js","assets/vendor-floating-ui-dom-Bkw82kL9.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-use-sync-external-store-B7OScDIw.js","assets/vendor-cmdk-BCEUzcHE.js","assets/vendor-radix-ui-react-dialog-jX3Dld8c.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-D1GnwnP9.js","assets/vendor-radix-ui-react-context-CM4yFQ2I.js","assets/vendor-radix-ui-react-id-BcxRjnbX.js","assets/vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js","assets/vendor-radix-ui-react-use-controllable-state-C_ecoh35.js","assets/vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js","assets/vendor-radix-ui-react-primitive-CfpW6_IT.js","assets/vendor-radix-ui-react-slot-BxUc3Pvz.js","assets/vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js","assets/vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js","assets/vendor-radix-ui-react-focus-scope-C2K7lNPv.js","assets/vendor-radix-ui-react-portal-xlJWBfDg.js","assets/vendor-radix-ui-react-presence-Btn-Dp7L.js","assets/vendor-radix-ui-react-focus-guards-D5MZ0nQs.js","assets/vendor-react-remove-scroll-CfeMe0DL.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-C9YRs2nU.js","assets/vendor-react-style-singleton-B1H4bWSG.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-C-AuTczP.js","assets/vendor-use-callback-ref-CJB0R85I.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-E2vgV9K3.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-DSzLbZiS.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-BUlYhQ3o.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-BS2SpSAZ.js","assets/vendor-codemirror-lang-json-CqayksDf.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-Ba8JZ6fp.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-DK27qQri.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-CvO36Y1p.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-q1yHU1R9.js","assets/vendor-codemirror-lang-python-_2bIYTiJ.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-RrgJ8H_6.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tanstack-react-virtual-IrbCBGJ4.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-DJASDzNt.js","assets/vendor-motion-dom-DJLgZh4Q.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-sonner-dWA7qvjr.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/PierreDiffViewer-InnT0JVA.js","assets/web-components-CLirSfwt.js","assets/computeVirtualFileMetrics-BPgZ_RSe.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-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.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-uKfnkQWb.js","assets/isDiffPlainText-f9b4cKNo.js","assets/vendor-diff-C3JhlQdm.js","assets/usePanelSlide-DCX8qQ4K.js","assets/permissionStore-BRcQ9Jgt.js","assets/usePanelSlide-BV3KOtdA.css","assets/useInlineCommentController-CHmIm0Rr.js","assets/collapsible-Bq8sDiKS.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/contextFileOpenGuard-CydO7PkI.js","assets/FilesView-BCzghrc7.js","assets/vendor-codemirror-search-8kyQdB3f.js","assets/vendor-replit-codemirror-vim-BJY5fGLS.js","assets/JsonTreeView-CrJO6LNu.js","assets/Virtualizer-BxW2CJGB.js","assets/isFilePlainText-BjESb-gU.js","assets/DiagramEditor-ChOor9l9.js","assets/vendor-react-drawio-Boqanm0j.js","assets/vendor-capacitor-status-bar-B-N0EOVk.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-capacitor-keyboard-CYccoJjr.js","assets/vendor-capacitor-push-notifications-KNe1zSBF.js"])))=>i.map(i=>d[i]);
2
+ import{r as De,j as t,R as a,b as Fe,e as ms}from"./vendor-react-DYyjh7Q0.js";import"./vendor-katex-CHD9BdDO.js";import{u as de,a as tt,b as In,d as Ut,i as le,e as Se,s as Oe,f as Qe,r as Dn,h as ps,j as hs,k as Ln,l as _n,m as gs,n as ys,o as Et,p as bs,q as Bt,t as xs,v as Mn,w as vs}from"./index-CH7o4-_q.js";import{u as ws,a as ks,b as js,s as Ss,c as Cs,d as Es}from"./useWindowTitle-CE5N_NeU.js";import{u as $e,M as Ns,i as Rs,D as Ft,a as Ht,b as Wt,g as Ts,c as Vt,d as Ps,s as As,S as Is,e as Ds,T as Ls,P as _s,r as Ms,f as zs,h as Os,F as $s,j as Us,k as Bs,l as Fs,m as Hs,n as Ws,H as Vs,A as Ks,C as Gs,o as Xs}from"./usePanelSlide-DCX8qQ4K.js";import{u as qs,a as Ys,b as zn,c as Js,d as Qs,r as Pt,e as Zs,t as oe,o as er,I as V,P as Ce,B as re,f as K,g as On,h as ge,i as tr,j as nr,k as sr,l as rr,m as ar,S as or,n as ir,p as lr,F as $n,T as cr,q as ur,s as dr,v as At,O as fr,D as Kt,w as Gt,x as Xt,y as qt,z as Yt,A as Jt,C as Un,E as It,G as mr,H as pr,J as hr,K as ke,L as gr,M as yr,N as br,Q as xr,R as vr,U as wr,V as kr,W as jr,X as he,Y as Sr,Z as Bn,_ as Nt,$ as Fn,a0 as Cr,a1 as Qt,a2 as Er,a3 as Nr,a4 as Rr,a5 as je,a6 as Tr,a7 as Pr,a8 as Ar,a9 as Ir,aa as Dr,ab as Lr,ac as _r,ad as Mr,ae as zr,af as Or,ag as $r,ah as Ur,ai as Br,aj as Fr,ak as Hr,al as Wr,am as Vr,an as Kr,ao as Gr,ap as Xr,aq as qr,ar as Yr}from"./SessionSwitcherDropdown-C0OdvirK.js";import{p as Jr,a as Qr,S as Zr,A as ea}from"./SettingsView-JAfC_cBL.js";import{_ as be}from"./vendor-vite-runtime-DD1OZmLC.js";import{p as ta}from"./vendor-aparajita-capacitor-secure-storage-5IShChL0.js";import{Capacitor as na}from"./vendor-capacitor-core-B4EWRrHz.js";import{u as sa}from"./vendor-tanstack-react-virtual-IrbCBGJ4.js";import{C as ra}from"./CommitSection-DPjTv8fA.js";import{P as aa}from"./PierreDiffViewer-InnT0JVA.js";import{K as Zt,P as oa,d as ia,p as la,U as ca,Z as ua,Q as da,r as fa}from"./vendor-remixicon-react-CzPq62YO.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zustand-CnsBKjP5.js";import"./vendor-base-ui-DwfTg5wD.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-sVFnuruh.js";import"./vendor-floating-ui-dom-Bkw82kL9.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-B7OScDIw.js";import"./vendor-dnd-kit-core-GipZW2tY.js";import"./vendor-dnd-kit-utilities-CrOcp0Bp.js";import"./vendor-dnd-kit-accessibility-Cv52zwWT.js";import"./vendor-dnd-kit-sortable-Ct2QxIHb.js";import"./permissionStore-BRcQ9Jgt.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./runtimeSurface-Bec4O8FD.js";import"./vendor-cmdk-BCEUzcHE.js";import"./vendor-radix-ui-react-dialog-jX3Dld8c.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-D1GnwnP9.js";import"./vendor-radix-ui-react-context-CM4yFQ2I.js";import"./vendor-radix-ui-react-id-BcxRjnbX.js";import"./vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js";import"./vendor-radix-ui-react-use-controllable-state-C_ecoh35.js";import"./vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js";import"./vendor-radix-ui-react-primitive-CfpW6_IT.js";import"./vendor-radix-ui-react-slot-BxUc3Pvz.js";import"./vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js";import"./vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js";import"./vendor-radix-ui-react-focus-scope-C2K7lNPv.js";import"./vendor-radix-ui-react-portal-xlJWBfDg.js";import"./vendor-radix-ui-react-presence-Btn-Dp7L.js";import"./vendor-radix-ui-react-focus-guards-D5MZ0nQs.js";import"./vendor-react-remove-scroll-CfeMe0DL.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-C9YRs2nU.js";import"./vendor-react-style-singleton-B1H4bWSG.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-C-AuTczP.js";import"./vendor-use-callback-ref-CJB0R85I.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-E2vgV9K3.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-DSzLbZiS.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-BUlYhQ3o.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BS2SpSAZ.js";import"./vendor-codemirror-lang-json-CqayksDf.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-Ba8JZ6fp.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-DK27qQri.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-CvO36Y1p.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-q1yHU1R9.js";import"./vendor-codemirror-lang-python-_2bIYTiJ.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-RrgJ8H_6.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-framer-motion-DJASDzNt.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-sonner-dWA7qvjr.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-qrcode-COsmt6jn.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./collapsible-Bq8sDiKS.js";import"./web-components-CLirSfwt.js";import"./computeVirtualFileMetrics-BPgZ_RSe.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./VirtualizedFileDiff-uKfnkQWb.js";import"./isDiffPlainText-f9b4cKNo.js";import"./vendor-diff-C3JhlQdm.js";import"./useInlineCommentController-CHmIm0Rr.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";let Hn=null,en=!1;const ma=new Promise(e=>{Hn=e});function pa(){en||(en=!0,Hn?.())}const ha=6,ga=e=>e.parentID??null,tn=e=>{const n=e.replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||n},ya=e=>e.replace(/\\/g,"/").replace(/\/+$/,""),ba=(e,n)=>{if(!e)return"";let s=null,r=-1;for(const o of n){const i=ya(o.path);(e===i||e.startsWith(`${i}/`))&&i.length>r&&(s=o,r=i.length)}return s?s.label?.trim()||tn(s.path):tn(e)},xa=()=>{const e=qs.getState().activeSessions,n=Ys.getState().index.session.unseenCount,s=de.getState().notifyOnSubtasks,r=zn.getState().projects,o=Js.getState().ids,i=Qs.getState().rankById;let l=0;const c=[];for(const d of e){const p=ga(d)!==null,k=(n[d.id]??0)>0&&(!p||s);k&&(l+=1),p||c.push({session:d,unread:k,project:ba(Pt(d),r)})}c.sort((d,p)=>Zs(d.session,p.session,o,i));const u=c.slice(0,ha).map(({session:d,unread:p,project:x})=>({id:d.id,title:d.title??"",unread:p,project:x}));return{runtimeKey:tt(),attentionCount:l,recentSessions:u}},va="__PICHAMBER_WIDGET_SNAPSHOT__",wa=()=>{typeof window>"u"||(window[va]=()=>{try{return JSON.stringify(xa())}catch{return null}})},xt="mobile-app-update-available",nn="mobile-app-update-toast-dismissed-version",ka=()=>{const e=$e(i=>i.available),n=$e(i=>i.runtimeType),s=$e(i=>i.info?.version),r=$e(i=>i.info?.downloadUrl),o=De.useRef(new Set);return De.useEffect(()=>{if(In()!=="android"||n!=="mobile"||!e||!s||!r){oe.dismiss(xt);return}Ut().getItem(nn)!==s&&(o.current.has(s)||(o.current.add(s),oe.info("PiChamber update available",{id:xt,description:`Version ${s} is ready for Android.`,duration:1/0,icon:t.jsx(V,{name:"download",className:"h-4 w-4 text-muted-foreground"}),action:{label:"Download",onClick:()=>{er(r)}},cancel:{label:"Dismiss",onClick:()=>{Ut().setItem(nn,s),oe.dismiss(xt)}}})))},[e,r,n,s]),null},ja="Updating OpenCode configuration...",Wn=0,Vn=ja,sn=new Set;function Sa(e){return sn.add(e),e({isUpdating:Wn>0,message:Vn}),()=>{sn.delete(e)}}function Ca(){return{isUpdating:Wn>0,message:Vn}}const Ea=()=>{const[{isUpdating:e},n]=a.useState(()=>Ca());return a.useEffect(()=>Sa(n),[]),e?t.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-background/90",children:t.jsx(Ce,{width:80,height:80,isAnimated:!0})}):null},ut="pichamber.mobile.connections.v1",Na="pichamber.mobile.",rn="pichamber.mobile.deviceId",Ra=()=>{try{const e=window.localStorage.getItem(rn);if(e&&e.trim())return e.trim();const n=crypto.randomUUID();return window.localStorage.setItem(rn,n),n}catch{return crypto.randomUUID()}},an=()=>`mobile:${Ra()}`,on=()=>{try{const e=na.getPlatform();return e==="ios"||e==="android"?e:void 0}catch{return}},Kn=12,Ta=8e3,Pa=2500,Aa=3e3,dt=2500,Ia=()=>{let e=0;return{begin:()=>(e+=1,e),cancel:()=>{e+=1},isCurrent:n=>n===e}},Ke=e=>{const n=e.trim();if(!n)return"";const s=/^https?:\/\//i.test(n)?n:`http://${n}`,r=new URL(s);return r.hash="",r.search="",r.pathname=r.pathname.replace(/\/+$/,""),r.toString().replace(/\/+$/,"")},lt=e=>{try{return new URL(e).host}catch{return e}},He=e=>{try{return Ke(e)}catch{return e.trim().replace(/\/+$/g,"")}},Gn=(e,n)=>He(e)===He(n),Xn=e=>`relay:${e.serverId}@${e.relayUrl.trim()}`,Da=e=>`relay://${e.serverId}`,ht=e=>e.candidates.filter(n=>n.kind==="direct"),_e=e=>{const n=e.candidates.find(s=>s.kind==="relay");return n&&n.kind==="relay"?n.relay:null},ve=e=>{const n=ht(e)[0];if(n)return n.url;const s=_e(e);return s?Da(s):""},ie=e=>{const n=_e(e);if(n)return Xn(n);const s=ht(e)[0];return s?He(s.url):""},ft=(e,n)=>{const s=e.find(i=>i.kind==="relay"),r=s&&s.kind==="relay"?s.relay.serverId:null,o=new Set(e.filter(i=>i.kind==="direct").map(i=>He(i.url)));return n.some(i=>i.kind==="relay"?r!==null&&i.relay.serverId===r:o.has(He(i.url)))},Dt=e=>{const n=(()=>{try{return Ke(e)}catch{return""}})();return n?[{kind:"direct",url:n}]:[]},ln=e=>{if(e.candidates&&e.candidates.length>0)return e.candidates;const n=[];return typeof e.url=="string"&&e.url.trim()&&!/^relay:\/\//i.test(e.url.trim())&&n.push(...Dt(e.url)),e.relay&&n.push({kind:"relay",relay:e.relay}),n},Lt=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;const n=e;if(typeof n.relayUrl!="string"||!n.relayUrl.trim()||typeof n.serverId!="string"||!n.serverId.trim())return null;const s=n.hostEncPubJwk;if(!s||typeof s!="object"||Array.isArray(s))return null;const r=s;return r.kty!=="EC"||r.crv!=="P-256"||typeof r.x!="string"||!r.x||typeof r.y!="string"||!r.y?null:{relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:{kty:"EC",crv:"P-256",x:r.x,y:r.y}}},gt=e=>{try{return JSON.stringify(e)}catch{return String(e)}},ce=(e,n={})=>{console.info("[mobile-connect]",e,gt(n)),hs("connect",{code:e,status:typeof n.status=="number"?n.status:void 0,detail:typeof n.reason=="string"?n.reason:typeof n.result=="string"?n.result:void 0})},We=(e,n={})=>{console.info("[mobile-storage]",e,gt(n))},La=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},_a=e=>{if(typeof e!="string")return e??void 0;try{return JSON.parse(e)}catch{return e}},Ma=async(e,n)=>{if(!le())return null;try{const{CapacitorHttp:s}=await be(async()=>{const{CapacitorHttp:i}=await import("./vendor-capacitor-core-B4EWRrHz.js");return{CapacitorHttp:i}},[]),r=Object.fromEntries(new Headers(n?.headers).entries()),o=await s.request({url:e,method:n?.method||"GET",headers:r,data:_a(n?.body)});return{ok:o.status>=200&&o.status<300,status:o.status,source:"native-http",json:async()=>La(o.data)}}catch(s){return console.warn("[mobile-connect]","native-http failed",gt({url:e,error:s instanceof Error?s.message:String(s)})),null}},za=async(e,n)=>{const s=await fetch(e,n).catch(r=>(console.warn("[mobile-connect]","browser-fetch failed",gt({url:e,error:r instanceof Error?r.message:String(r)})),null));return s?{ok:s.ok,status:s.status,source:"browser-fetch",json:()=>s.json()}:null},Ne=async(e,n,s)=>{let r;const o=new Promise(i=>{r=window.setTimeout(()=>{s?.(),i(null)},e)});try{return await Promise.race([n,o])}catch{return null}finally{r!==void 0&&window.clearTimeout(r)}},Me=async(e,n,s)=>{const r=s?.totalTimeoutMs??Ta,o=Date.now(),i=await Ne(Math.min(Pa,r),Ma(e,n));if(i)return i;const l=new AbortController,c=Math.max(500,r-(Date.now()-o));return Ne(c,za(e,{...n,signal:l.signal}),()=>l.abort())},yt=async e=>{if(!e)return null;const n=await e.json().catch(()=>null);if(!n||typeof n!="object")return null;const s=n;return{authenticated:typeof s.authenticated=="boolean"?s.authenticated:void 0,disabled:typeof s.disabled=="boolean"?s.disabled:void 0,scope:typeof s.scope=="string"?s.scope:void 0}},Ze=15e3,Oa=async(e,n,s,r=Ze,o)=>{const i=Ln({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk}),l=c=>c==="ok"&&o?.keepTunnel?{outcome:c,tunnel:i}:(i.close(),{outcome:c});try{const c=n?{Authorization:`Bearer ${n}`}:void 0,u=await Ne(r,i.fetch("/auth/session",{headers:c}).catch(()=>null));if(ce("relay:session",{ok:u?.ok===!0,status:u?.status??null,hasToken:!!n}),!u)return l("unreachable");if(u.status===401)return l(n?"auth-failed":"needs-login");if(!u.ok&&u.status!==404)return l("auth-failed");const d=await yt(u);return d&&d.disabled!==!0&&d.authenticated===!1?l(n?"auth-failed":"needs-login"):l("ok")}catch(c){throw i.close(),c}},$a=(e,n,s,r,o)=>{const i=typeof window<"u"?window.location.origin:"",l={relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk,...s?{grant:s}:{}};o&&ps(l,o),Oe({apiBaseUrl:i,clientToken:n,runtimeKey:r??Xn(e),relay:l})},Ua=e=>{if(!e||typeof e!="object")return null;const n=e;if(n.kind==="direct")return typeof n.url=="string"&&n.url.trim()?{kind:"direct",url:n.url}:null;if(n.kind==="relay"){const s=Lt(n.relay);return s?{kind:"relay",relay:s}:null}return null},Ba=e=>{if(e.mode==="relay"){const n=Lt(e.relay);return n?[{kind:"relay",relay:n}]:[]}return typeof e.url=="string"?Dt(e.url):[]},ze=()=>{if(typeof window>"u")return[];let e;try{e=JSON.parse(window.localStorage.getItem(ut)||"[]")}catch{return[]}if(!Array.isArray(e))return[];const n=le();return e.flatMap(s=>{if(!s||typeof s!="object")return[];const r=s;if(typeof r.id!="string")return[];const o=Array.isArray(r.candidates)?r.candidates.map(Ua).filter(u=>!!u):Ba(r);if(o.length===0)return[];const i=typeof r.clientToken=="string"&&r.clientToken.trim()?r.clientToken:void 0,l=typeof r.label=="string"&&r.label.trim()?r.label:lt(ve({candidates:o})),c={id:r.id,label:l,candidates:o,lastUsedAt:typeof r.lastUsedAt=="number"?r.lastUsedAt:0};return n?[{...c,hasToken:!!r.hasToken||!!i}]:[{...c,clientToken:i,hasToken:!!i}]}).sort((s,r)=>r.lastUsedAt-s.lastUsedAt)},Rt=e=>e.kind==="relay"?{kind:"relay",relay:{relayUrl:e.relay.relayUrl,serverId:e.relay.serverId,hostEncPubJwk:e.relay.hostEncPubJwk}}:{kind:"direct",url:e.url},_t=e=>{if(typeof window>"u")return;const n=le(),s=e.slice(0,Kn).map(r=>{const o={id:r.id,label:r.label,candidates:r.candidates.map(Rt),lastUsedAt:r.lastUsedAt};return n?{...o,hasToken:!!(r.hasToken||r.clientToken)}:{...o,clientToken:r.clientToken}});try{window.localStorage.setItem(ut,JSON.stringify(s))}catch(r){console.warn("[mobile-storage] failed to persist connection metadata",r)}},qn=(e,n)=>{const s=e.find(i=>n.id&&i.id===n.id||ft(i.candidates,n.candidates)),r=le(),o={id:n.id||s?.id||crypto.randomUUID(),label:n.label,candidates:n.candidates,lastUsedAt:Date.now(),...r?{hasToken:n.hasToken??(!!n.clientToken||s?.hasToken||!1)}:{clientToken:n.clientToken??s?.clientToken,hasToken:!!(n.clientToken??s?.clientToken)}};return[o,...e.filter(i=>i.id!==o.id&&!ft(i.candidates,n.candidates))].slice(0,Kn)},Mt=ta,Fa=0,zt=e=>`${Na}token.${encodeURIComponent(e)}`,Ha=async(e,n)=>{let s;const r=new Promise(o=>{s=window.setTimeout(()=>o(n),Aa)});try{return await Promise.race([e.catch(()=>n),r])}finally{s!==void 0&&window.clearTimeout(s)}},Ot=async(e,n,s)=>le()?Ha(n().catch(r=>(console.warn(`[mobile-storage] ${e} failed`,r),s)),s):s,et=async e=>{We("secure:read-start",{key:e});const n=await Ot("secure:read",async()=>(await Mt.internalGetItem({prefixedKey:zt(e),sync:!1})).data,null),s=typeof n=="string"&&n.trim()?n:void 0;return We("secure:read",{key:e,hasToken:!!s}),s},Ie=async(e,n)=>{We("secure:write-start",{key:e});const s=await Ot("secure:write",async()=>(await Mt.internalSetItem({prefixedKey:zt(e),data:n,sync:!1,access:Fa}),!0),!1);return We("secure:write",{key:e,ok:s}),s},Wa=async e=>{await Ot("secure:delete",async()=>(await Mt.internalRemoveItem({prefixedKey:zt(e),sync:!1}),!0),!1)},Va=async(e,n)=>{let s=0,r=0;return{records:await Promise.all(e.map(async i=>{if(!i||typeof i!="object")return i;const l=i,c=typeof l.url=="string"?l.url:null,u=typeof l.clientToken=="string"?l.clientToken.trim():"";if(!c||!u)return i;if(!await n(c,u))return r+=1,i;s+=1;const{clientToken:d,...p}=l;return{...p,hasToken:!0}})),migrated:s,failed:r}},Yn=async()=>{if(typeof window>"u"||!le())return;let e;try{e=JSON.parse(window.localStorage.getItem(ut)||"[]")}catch{return}if(!Array.isArray(e))return;const n=e.filter(r=>!!r&&typeof r=="object"&&typeof r.url=="string"&&typeof r.clientToken=="string"&&!!r.clientToken.trim());if(n.length===0)return;We("secure:migrate-start",{count:n.length});const s=await Va(e,async(r,o)=>{const i=He(r);return await Ie(i,o)?await et(i)===o:!1});if(s.migrated>0)try{window.localStorage.setItem(ut,JSON.stringify(s.records))}catch(r){console.warn("[mobile-storage] failed to finalize secure token migration",r);return}We("secure:migrate-done",{migrated:s.migrated,failed:s.failed})},Ka=async()=>(await Yn(),ze()),mt=async e=>{const n=qn(ze(),e);return _t(n),le()&&e.clientToken&&await Ie(ie({candidates:e.candidates}),e.clientToken),n},Ga=async e=>{const n=ze(),s=n.find(o=>o.id===e)??null,r=n.filter(o=>o.id!==e);return _t(r),s&&le()&&await Wa(ie(s)),r},Xa=1500,pt=async(e,n,s)=>{const r=s?.fast?{totalTimeoutMs:dt}:void 0,o=_e({candidates:e})?.serverId??null,i=e.find(d=>d.kind==="relay")??null,l=e.filter(d=>d.kind==="direct"),c=async()=>{for(const d of l){const p=Ke(d.url)||d.url,x=n?{Authorization:`Bearer ${n}`}:void 0,k=await Me(`${p}/health`,{method:"GET"},r);if(!k?.ok)continue;if(o){const U=await k.json().catch(()=>null),F=U&&typeof U=="object"?U.serverId:null;if(typeof F=="string"&&F&&F!==o){ce("probe:server-id-mismatch",{url:p});continue}}const N=await Me(`${p}/auth/session`,{method:"GET",credentials:n?"omit":"include",headers:x},r);if(N?.status===401)return{status:"needs-login"};if(!N||!N.ok&&N.status!==404)continue;const P=await yt(N);if(P&&P.disabled!==!0&&P.authenticated===!1)return{status:"needs-login"};const R=P?.disabled===!0;return!n&&le()&&!R&&P?.scope!=="client"?{status:"needs-login"}:{status:"ok",transport:{kind:"direct",url:p}}}return{status:"unreachable"}},u=async()=>{if(!i)return{status:"unreachable"};const{outcome:d,tunnel:p}=await Oa(i.relay,n,void 0,s?.fast?dt:void 0,{keepTunnel:!0});return d==="ok"?{status:"ok",transport:{kind:"relay",relay:i.relay,tunnel:p}}:d==="needs-login"||d==="auth-failed"?{status:"needs-login"}:{status:"unreachable"}};return i?l.length===0?u():new Promise(d=>{let p=!1,x=!1,k,N=null,P=null;const R=m=>{m?.status==="ok"&&m.transport.kind==="relay"&&m.transport.tunnel?.close()},U=m=>{p||(p=!0,d(m))},F=()=>{x||p||(k!==void 0&&(window.clearTimeout(k),k=void 0),u().then(m=>{if(P=m,p||x){R(m);return}if(m.status==="ok"||m.status==="needs-login"){U(m);return}N&&U(N)}))};c().then(m=>{if(N=m,!p){if(m.status==="ok"||m.status==="needs-login"){x=!0,k!==void 0&&window.clearTimeout(k),R(P),U(m);return}if(P){U(P);return}F()}}),k=window.setTimeout(F,Xa)}):c()},Le=(e,n,s)=>{e.kind==="relay"?$a(e.relay,n,s?.grant,s?.runtimeKey,e.tunnel):Oe({apiBaseUrl:e.url,clientToken:n,runtimeKey:s?.runtimeKey}),Qn()},Xe=()=>{const e=ze()[0];return e?.label?.trim()?e.label:null},vt=async()=>{await Yn();const e=ze()[0];if(!e)return{status:"no-candidate"};let n;if(le()){if(!e.hasToken)return{status:"no-candidate"};if(n=await et(ie(e)),!n)return{status:"no-candidate"}}else if(n=e.clientToken,!n)return{status:"no-candidate"};const s=await pt(e.candidates,n,{fast:!0});return s.status==="needs-login"?{status:"needs-login",label:e.label}:s.status!=="ok"?{status:"unreachable",label:e.label}:(await mt({id:e.id,label:e.label,candidates:e.candidates}),Le(s.transport,n,{runtimeKey:ie(e)}),{status:"connected"})},qa=async(e,n)=>{let s="";try{s=Ke(e.url)}catch{return!1}if(!s)return!1;const r=e.clientToken?.trim()||void 0,o=r?{Authorization:`Bearer ${r}`}:void 0,i={totalTimeoutMs:dt};if(!(await Me(`${s}/health`,{method:"GET",headers:o},i))?.ok)return!1;const c=await Me(`${s}/auth/session`,{method:"GET",credentials:r?"omit":"include",headers:o},i);if(!c||!c.ok&&c.status!==404)return!1;const u=await yt(c);return!(u&&u.disabled!==!0&&u.authenticated===!1)},Ya=e=>[...e].sort((n,s)=>{const r=(n.priority??100)-(s.priority??100);if(r!==0)return r;const o=i=>i.type==="relay"?2:i.url.startsWith("https://")?0:1;return o(n)-o(s)}).flatMap(n=>{if(n.type==="relay"){const s=Lt({relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk});return s?[{kind:"relay",relay:s}]:[]}return Dt(n.url)}),cn=async e=>{const n=_e({candidates:e})?.serverId??null;for(const s of e){if(s.kind==="relay"){const i=Ln(s.relay),l=await Ne(Ze,i.fetch("/health").catch(()=>null));if(ce("establish:relay:health",{ok:l?.ok===!0,status:l?.status??null}),l?.ok)return{kind:"relay",relay:s.relay,tunnel:i};i.close();continue}const r=Ke(s.url)||s.url,o=await Me(`${r}/health`,{method:"GET"});if(ce("establish:direct:health",{ok:o?.ok===!0,status:o?.status??null}),!!o?.ok){if(n){const i=await o.json().catch(()=>null),l=i&&typeof i=="object"?i.serverId:null;if(typeof l=="string"&&l&&l!==n){ce("establish:server-id-mismatch",{url:r});continue}}return{kind:"direct",url:r}}}return null},Ja=async(e,n)=>{if(!Qe())return qa(e);const s=await Ne(dt,Dn("/auth/session").then(o=>o).catch(()=>null));if(!s)return!0;if(s.status===401)return!1;if(!s.ok&&s.status!==404)return!0;const r=await yt(s);return!(r&&r.disabled!==!0&&r.authenticated===!1)},Qa=e=>e.kind==="relay"?Qe():!Qe()&&Gn(e.url,Se()),Jn=()=>{const e=tt();return e?ze().find(n=>ie(n)===e)??null:null},un=e=>{const n=tt();return!!n&&ie(e)===n},ct=async()=>{const e=Jn();if(!e)return"no-connection";let n;if(le()?n=e.hasToken?await et(ie(e)):void 0:n=e.clientToken,!n)return"unreachable";const s=e.candidates.findIndex(c=>Qa(c.kind==="relay"?{kind:"relay",relay:c.relay}:{kind:"direct",url:c.url})),r=s>=0?e.candidates.slice(0,s):e.candidates,o=await pt(r,n,{fast:!0});if(o.status==="ok")return await mt({id:e.id,label:e.label,candidates:e.candidates}),Le(o.transport,n,{runtimeKey:ie(e)}),"switched";if(o.status==="needs-login")return"needs-login";if(s>=0&&await Ja({url:Se(),clientToken:n}))return Qn(),"unchanged";const i=s>=0?e.candidates.slice(s+1):[],l=await pt(i,n,{fast:!0});return l.status==="ok"?(await mt({id:e.id,label:e.label,candidates:e.candidates}),Le(l.transport,n,{runtimeKey:ie(e)}),"switched"):l.status==="needs-login"?"needs-login":"unreachable"},Za=5e3;let wt=!1;const eo=async()=>{if(wt)return"skipped";const e=Jn();if(!e)return ce("candidates:refresh-skip",{reason:"no-active-connection"}),"skipped";const n=_e(e);if(!n)return ce("candidates:refresh-skip",{reason:"no-relay-candidate"}),"skipped";wt=!0;try{const s=await Ne(Ze,Dn("/api/client-auth/connection/candidates").then(d=>d).catch(()=>null));if(!s?.ok)return ce("candidates:refresh-skip",{reason:"fetch-failed",status:s?.status??null}),"skipped";const r=await s.json().catch(()=>null);if(!r||r.serverId!==n.serverId)return ce("candidates:refresh-skip",{reason:"server-id-mismatch"}),"skipped";const o=Array.isArray(r.candidates)?r.candidates:[],i=[];for(const d of o){if(!d||typeof d!="object")continue;const p=d;if(!(p.type!=="lan"||typeof p.url!="string"))try{const x=Ke(p.url);x&&!i.includes(x)&&i.push(x)}catch{}}if(i.length===0)return ce("candidates:refresh-skip",{reason:"no-lan-reported"}),"skipped";const l=ht(e).filter(d=>d.url.startsWith("https://")),c=[...i.map(d=>({kind:"direct",url:d})),...l,{kind:"relay",relay:n}];return JSON.stringify(e.candidates.map(Rt))===JSON.stringify(c.map(Rt))?"unchanged":(ce("candidates:refreshed",{lanCount:i.length}),await mt({id:e.id,label:e.label,candidates:c}),"updated")}finally{wt=!1}},Qn=()=>{typeof window>"u"||window.setTimeout(()=>{(async()=>{const e=await eo().catch(()=>"skipped");ce("candidates:refresh-result",{result:e}),e==="updated"&&Qe()&&await ct().catch(()=>null)})()},Za)},Zn=e=>{const[n,s]=a.useState(()=>ze()),[r,o]=a.useState(null),[i,l]=a.useState(null),[c,u]=a.useState(null),d=a.useRef(n),p=a.useRef(null),x=a.useRef(Ia()),k=a.useCallback(b=>{d.current=b,s(b)},[]),N=a.useCallback(b=>{p.current=b,o(b)},[]),P=a.useCallback(b=>{p.current===b&&(p.current=null,o(null))},[]);a.useEffect(()=>{let b=!1;return Ka().then(S=>{b||k(S)}),()=>{b=!0}},[k]);const R=a.useCallback(b=>{const S=qn(d.current,b);return k(S),_t(S),S},[k]),U=a.useCallback(async b=>{l(null),N("connect");try{const S=ln(b);if(S.length===0){l("Enter a server URL.");return}const y=b.id?d.current.find(h=>h.id===b.id):d.current.find(h=>ft(h.candidates,S)),B=b.label?.trim()||y?.label||lt(ve({candidates:S})),g=b.relayGrant;let I=b.clientToken?.trim()||void 0;const w=!!I;I||(le()?y?.hasToken&&(I=await et(ie({candidates:S}))):I=y?.clientToken),ce("connect:start",{candidates:S.map(h=>h.kind),hasToken:!!I});const E=await pt(S,I);if(ce("connect:probe",{status:E.status}),E.status==="unreachable"){l("Could not reach that PiChamber server.");return}if(E.status==="needs-login"){R({id:y?.id,label:B,candidates:S}),u({id:y?.id??crypto.randomUUID(),label:B,candidates:S,relay:_e({candidates:S})??void 0,relayGrant:g});return}I&&w&&le()&&await Ie(ie({candidates:S}),I),R({id:y?.id,label:B,candidates:S,clientToken:I}),Le(E.transport,I??null,{runtimeKey:ie({candidates:S}),grant:g}),e()}catch(S){console.warn("[mobile-connect] connect threw",S),l("That server URL is not valid.")}finally{P("connect")}},[N,P,e,R]),F=a.useCallback(async b=>{if(p.current==="pairing")return;l(null),N("pairing");const S=Ya(b.candidates);let y=null,B=!1;try{if(y=await cn(S),!y){l("Could not reach that PiChamber server.");return}const g=JSON.stringify({pairingId:b.pairingId,secret:b.secret,clientLabel:"PiChamber Mobile",clientKind:"mobile",deviceName:"PiChamber Mobile",devicePlatform:on(),dedupeKey:an()}),I={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:g},w=y.kind==="relay"?await Ne(Ze,y.tunnel.fetch("/api/client-auth/pairing/redeem",I).catch(()=>null)):await Me(`${y.url}/api/client-auth/pairing/redeem`,I);if(!w?.ok){l("This server needs a password or client token.");return}const E=await w.json().catch(()=>null),h=typeof E?.clientToken=="string"?E.clientToken.trim():"";if(!h){l("This server needs a password or client token.");return}const C=typeof E?.server?.label=="string"?E.server.label:"",O=b.label||C||lt(ve({candidates:S}));if(le()&&!await Ie(ie({candidates:S}),h)){l("This server needs a password or client token.");return}R({label:O,candidates:S,clientToken:h}),Le(y.kind==="relay"?{kind:"relay",relay:y.relay,tunnel:y.tunnel}:{kind:"direct",url:y.url},h,{runtimeKey:ie({candidates:S})}),B=y.kind==="relay",e()}catch(g){console.warn("[mobile-connect] pairing threw",g),l("This server needs a password or client token.")}finally{!B&&y?.kind==="relay"&&y.tunnel.close(),P("pairing")}},[N,P,e,R]),m=a.useCallback(async b=>{if(!c||!b.trim()||p.current==="password")return;l(null),N("password");const S=x.current.begin(),y=()=>x.current.isCurrent(S),{id:B,label:g,candidates:I}=c;let w=null,E=!1;try{if(w=await cn(I),!y())return;if(!w){l("Could not reach that PiChamber server.");return}const h={method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({password:b,trustDevice:!0,issueClientToken:!0,clientLabel:"PiChamber Mobile",clientKind:"mobile",devicePlatform:on(),dedupeKey:an()})};ce("password:start",{transport:w.kind});const C=w.kind==="relay"?await Ne(Ze,w.tunnel.fetch("/auth/session",h).catch(()=>null)):await Me(`${w.url}/auth/session`,h);if(!y())return;if(ce("password:done",{ok:C?.ok===!0,status:C?.status??null}),!C?.ok){l("Could not unlock that server. Check the password.");return}const O=await C.json().catch(()=>null);if(!y())return;const q=typeof O?.clientToken=="string"?O.clientToken.trim():"";if(ce("password:token",{issued:!!q}),!q){if(w.kind==="direct"&&!le()){R({id:B,label:g,candidates:I}),u(null),Le({kind:"direct",url:w.url},null,{runtimeKey:ie({candidates:I})}),e();return}l("This server needs a password or client token.");return}if(le()&&(!y()||(await Ie(ie({candidates:I}),q),!y()))||!y()||(R({id:B,label:g,candidates:I,clientToken:q}),u(null),Le(w.kind==="relay"?{kind:"relay",relay:w.relay,tunnel:w.tunnel}:{kind:"direct",url:w.url},q,{runtimeKey:ie({candidates:I})}),E=w.kind==="relay",!y()))return;e()}catch(h){if(!y())return;console.warn("[mobile-connect] password threw",h),l("Could not unlock that server. Check the password.")}finally{!E&&w?.kind==="relay"&&w.tunnel.close(),y()&&P("password")}},[N,P,e,c,R]),v=a.useCallback(()=>{x.current.cancel(),P("password"),u(null),l(null)},[P]),L=a.useCallback(async b=>{l(null);let S=ln(b);const y=b.id?d.current.find(w=>w.id===b.id)??null:null;if(y){const w=S.filter(C=>C.kind==="direct"),E=ht(y).filter(C=>C.url.startsWith("https://")&&!w.some(O=>Gn(O.url,C.url))),h=_e(y);S=[...w,...E,...h?[{kind:"relay",relay:h}]:[]]}if(S.length===0)return l("Enter a server URL."),null;const B=b.clientToken?.trim()||void 0,g=b.label?.trim()||lt(ve({candidates:S}));if(le()){const w=ie({candidates:S});if(B)await Ie(w,B);else if(y?.hasToken){const E=ie(y);if(E&&w&&E!==w){const h=await et(E);h&&await Ie(w,h)}}}return R({id:b.id,label:g,candidates:S,clientToken:B}).find(w=>ft(w.candidates,S))??null},[R]),$=a.useCallback(async b=>{const S=d.current.find(B=>B.id===b)??null,y=await Ga(b);return k(y),S},[k]);return{connections:n,isBusy:r!==null,isPasswordBusy:r==="password",error:i,pendingConnection:c,connect:U,redeemPairingConnection:F,submitPassword:m,cancelPassword:v,saveConnection:L,removeConnection:$,setError:l}},es=()=>{if(typeof window>"u")return null;const n=window.Capacitor?.Plugins?.BarcodeScanner;return n&&(typeof n.scan=="function"||typeof n.startScan=="function")?n:null},to=()=>window.Capacitor?.getPlatform?.()==="android",ts=e=>{const n=e.trim();if(!n)return null;if(/^pichamber:\/\//i.test(n)){const s=Jr(n);return s?{pairing:s}:null}return/^https?:\/\//i.test(n)?{url:n}:null},ns=(e,n)=>{const s=ts(e);if(!s&&n?.pairingStringFallback){const r=Qr(e);if(r)return{status:"pairing",pairing:r}}return s?"pairing"in s?{status:"pairing",...s}:{status:"ok",...s}:{status:"invalid"}},no=async(e,n)=>{if(!e.startScan||!e.stopScan||!e.addListener)return{status:"unsupported"};if(n?.aborted)return{status:"cancelled"};let s,r,o=!1,i=()=>{};const l=new Promise(d=>{i=d}),c=d=>{o||(o=!0,i(d))},u=()=>c({status:"cancelled"});n?.addEventListener("abort",u,{once:!0});try{return(await Promise.allSettled([Promise.resolve(e.addListener("barcodesScanned",({barcodes:p})=>{const x=p?.[0],k=(x?.rawValue??x?.displayValue??"").trim();k&&c(ns(k,{pairingStringFallback:!0}))})).then(p=>{s=p}),Promise.resolve(e.addListener("scanError",()=>c({status:"failed"}))).then(p=>{r=p})])).some(({status:p})=>p==="rejected")?c({status:"failed"}):o||e.startScan({formats:["QR_CODE"]}).catch(()=>c({status:"failed"})),await l}finally{n?.removeEventListener("abort",u),await Promise.allSettled([Promise.resolve(s?.remove()),Promise.resolve(r?.remove()),e.stopScan()])}},Tt=()=>es()!==null,ss=async e=>{const n=es();if(!n)return{status:"unsupported"};try{if(n.requestPermissions){const l=(await n.requestPermissions())?.camera;if(l&&l!=="granted"&&l!=="limited")return{status:"permission-denied"}}if(e?.signal?.aborted)return{status:"cancelled"};if(to())return no(n,e?.signal);if(!n.scan)return{status:"unsupported"};const r=(await n.scan({formats:["QR_CODE"]}))?.barcodes?.[0],o=(r?.rawValue??r?.displayValue??"").trim();return o?ns(o):{status:"cancelled"}}catch{return{status:"failed"}}},Be={autoComplete:"off",autoCorrect:"off",spellCheck:!1},qe="h-12 w-full rounded-[16px] border border-border/70 bg-surface-elevated px-4 text-[16px] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-primary focus:ring-2 focus:ring-primary/20",rs=({onCancel:e})=>{const n=a.useRef(null);return a.useLayoutEffect(()=>{const s={value:document.documentElement.style.getPropertyValue("background-color"),priority:document.documentElement.style.getPropertyPriority("background-color")},r={value:document.body.style.getPropertyValue("background-color"),priority:document.body.style.getPropertyPriority("background-color")};document.documentElement.style.setProperty("background-color","rgba(0, 0, 0, 0)","important"),document.body.style.setProperty("background-color","rgba(0, 0, 0, 0)","important");const o=new Map,i=c=>{!(c instanceof HTMLElement)||c===n.current||o.has(c)||(o.set(c,{opacity:c.style.opacity,pointerEvents:c.style.pointerEvents}),c.style.setProperty("opacity","0"),c.style.setProperty("pointer-events","none"))};Array.from(document.body.children).forEach(i);const l=new MutationObserver(c=>{c.forEach(u=>u.addedNodes.forEach(i))});return l.observe(document.body,{childList:!0}),()=>{l.disconnect(),o.forEach((c,u)=>{u.style.opacity=c.opacity,u.style.pointerEvents=c.pointerEvents}),s.value?document.documentElement.style.setProperty("background-color",s.value,s.priority):document.documentElement.style.removeProperty("background-color"),r.value?document.body.style.setProperty("background-color",r.value,r.priority):document.body.style.removeProperty("background-color")}},[]),a.useEffect(()=>{const s=()=>{document.visibilityState==="hidden"&&e()};return document.addEventListener("visibilitychange",s),()=>document.removeEventListener("visibilitychange",s)},[e]),Fe.createPortal(t.jsxs("div",{ref:n,role:"dialog","aria-modal":"true","aria-label":"Scan QR code",className:"fixed inset-0 z-[1000] flex flex-col bg-transparent px-6 pb-[calc(var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))+24px)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+24px)] text-foreground",children:[t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-6",children:[t.jsx("div",{className:"aspect-square w-full max-w-72 rounded-[28px] border-2 border-foreground/90 shadow-[0_0_0_9999px_color-mix(in_srgb,var(--surface-background)_18%,transparent)]","aria-hidden":!0}),t.jsx("p",{className:"max-w-sm rounded-[16px] border border-border/60 bg-background px-4 py-3 text-center typography-body text-foreground shadow-sm",children:"On your computer, open «Add a device» to show a QR code, then scan it here."})]}),t.jsxs(re,{type:"button",variant:"outline",size:"lg",className:"mx-auto min-h-12 w-full max-w-sm bg-background",onClick:e,children:[t.jsx(V,{name:"close",className:"size-[18px]"}),"Cancel"]})]}),document.body)},as=()=>Fe.createPortal(t.jsxs("div",{role:"status",className:"fixed inset-0 z-[1000] flex flex-col items-center justify-center gap-5 bg-background px-6 text-foreground",children:[t.jsx(Ce,{width:96,height:96,isAnimated:!0}),t.jsxs("div",{className:"flex items-center gap-2 typography-ui-label text-muted-foreground",children:[t.jsx(V,{name:"loader-4",className:"size-[18px] animate-spin"}),t.jsx("span",{children:"Connecting..."})]})]}),document.body),so=({onConnected:e,notice:n=null})=>{const s=Zn(e),{connections:r,isBusy:o,isPasswordBusy:i,error:l,pendingConnection:c}=s,[u,d]=a.useState(""),[p,x]=a.useState(""),[k,N]=a.useState(""),[P,R]=a.useState(!1),[U,F]=a.useState(!1),m=a.useRef(null),v=a.useMemo(()=>Tt(),[]),[L,$]=a.useState(()=>!Tt()),[b,S]=a.useState(null),[y,B]=a.useState(""),g=a.useCallback(C=>{C.preventDefault(),s.connect({url:u,clientToken:k,label:p})},[k,s,p,u]),I=a.useCallback(C=>{if(/^pichamber:\/\//i.test(C.trim())){const O=ts(C);if(O){if("pairing"in O){s.redeemPairingConnection(O.pairing);return}d(O.url),O.label&&x(O.label),O.clientToken&&N(O.clientToken);return}}d(C)},[s]),w=a.useCallback(async()=>{if(m.current||o)return;s.setError(null),R(!0);const C=new AbortController;m.current=C;try{const O=await ss({signal:C.signal});switch(m.current===C&&(m.current=null,R(!1)),O.status){case"ok":F(!0),d(O.url),O.label&&x(O.label),O.clientToken&&N(O.clientToken),await s.connect({url:O.url,clientToken:O.clientToken,label:O.label});break;case"pairing":F(!0),await s.redeemPairingConnection(O.pairing);break;case"permission-denied":s.setError("Camera access is off. Enable it in Settings to scan a QR code.");break;case"invalid":s.setError("That QR code is not an PiChamber connection code.");break;case"unsupported":s.setError("QR scanning is only available in the installed mobile app.");break;case"failed":s.setError("Could not scan that QR code. Try again or enter the URL manually.");break;default:break}}finally{F(!1),m.current===C&&(m.current=null,R(!1))}},[s,o]);a.useEffect(()=>()=>m.current?.abort(),[]);const E=a.useCallback(C=>{C.preventDefault(),s.submitPassword(y)},[s,y]),h=a.useCallback(()=>{B(""),s.cancelPassword()},[s]);return t.jsxs(t.Fragment,{children:[P?t.jsx(rs,{onCancel:()=>m.current?.abort()}):null,U?t.jsx(as,{}):null,t.jsx("main",{className:"oc-keyboard-fill-screen flex min-h-dvh flex-col overflow-y-auto bg-background px-6 pb-[calc(var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))+28px)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+28px)] text-foreground",children:t.jsxs("div",{className:"m-auto flex w-full max-w-[360px] shrink-0 flex-col items-center gap-9 py-8",children:[t.jsxs("div",{className:"flex flex-col items-center gap-5 text-center",children:[t.jsx(Ce,{width:72,height:72,className:"size-[72px]"}),t.jsx("h1",{className:"typography-h2 text-foreground",children:"Connect to PiChamber"})]}),n?t.jsxs("div",{role:"status",className:"flex w-full items-center gap-3 rounded-[18px] border border-[color-mix(in_srgb,var(--status-warning)_35%,transparent)] bg-[color-mix(in_srgb,var(--status-warning)_10%,transparent)] px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-[color-mix(in_srgb,var(--status-warning)_16%,transparent)] text-[var(--status-warning)]",children:t.jsx(V,{name:n.kind==="auth-expired"?"lock":"cloud-off",className:"size-[18px]"})}),t.jsx("p",{className:"min-w-0 flex-1 typography-small text-foreground",children:n.kind==="auth-expired"?`Access to ${n.label} has expired or was revoked. Sign in again.`:`Couldn't reach ${n.label}. Check that the server is running.`})]}):null,c?t.jsxs("form",{className:"flex w-full flex-col gap-3",onSubmit:E,children:[t.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(V,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0 text-left",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:c.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:c.candidates.some(C=>C.kind==="direct")?ve(c):"via PiChamber Relay"})]})]}),t.jsx("input",{...Be,value:y,onChange:C=>B(C.target.value),placeholder:"PiChamber password","aria-label":"Password",type:"password",autoFocus:!0,className:qe}),l?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):null,t.jsx(re,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:i||!y.trim(),children:i?"Connecting...":"Unlock and connect"}),t.jsx(re,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:h,children:"Use another server"})]}):t.jsxs("div",{className:"flex w-full flex-col gap-6",children:[v?t.jsxs("div",{className:"flex w-full flex-col gap-2",children:[t.jsxs(re,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{w()},disabled:P||o,children:[t.jsx(V,{name:"scan-2",className:K("size-[18px]",P&&"animate-pulse")}),o?"Connecting...":"Scan QR code"]}),t.jsx("p",{className:"px-2 text-center typography-small text-muted-foreground",children:"On your computer, open «Add a device» to show a QR code, then scan it here."})]}):null,l&&!L?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):null,r.length>0?t.jsxs("section",{className:"flex w-full flex-col gap-2.5",children:[t.jsx("h2",{className:"text-center typography-micro uppercase tracking-[0.14em] text-muted-foreground",children:"Saved connections"}),t.jsx("div",{className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(C=>{const O=b===C.id;return t.jsxs("button",{type:"button",disabled:o,className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3.5 py-2.5 text-left last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:opacity-70",onClick:()=>{S(C.id),s.connect({id:C.id,candidates:C.candidates,clientToken:C.clientToken,label:C.label}).finally(()=>S(null))},children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(V,{name:"server",className:"size-[18px]"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:C.label}),t.jsx("span",{className:K("block truncate typography-small",O?"text-foreground":"text-muted-foreground"),children:O?"Connecting...":C.candidates.some(q=>q.kind==="direct")?ve(C):"via PiChamber Relay"})]}),O?t.jsx(V,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):t.jsx(V,{name:"arrow-right-s",className:"size-5 text-muted-foreground"})]},C.id)})})]}):null,t.jsxs("div",{className:"flex w-full flex-col",children:[v?t.jsxs("button",{type:"button",onClick:()=>$(C=>!C),"aria-expanded":L,className:"mx-auto flex items-center gap-1 rounded-full px-2 py-1 typography-small text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:[t.jsx("span",{children:"Connect by address"}),t.jsx(V,{name:"arrow-down-s",className:K("size-4 transition-transform duration-200",L&&"rotate-180")})]}):null,t.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:L?"1fr":"0fr"},children:t.jsx("div",{className:"min-h-0 overflow-hidden",children:t.jsxs("form",{className:"flex w-full flex-col gap-3 pt-3",onSubmit:g,children:[t.jsx("input",{...Be,value:u,onChange:C=>I(C.target.value),placeholder:"http://192.168.1.74:2606","aria-label":"Server URL",type:"url",inputMode:"url",autoCapitalize:"none",tabIndex:L?void 0:-1,className:K(qe,"text-center")}),t.jsx("input",{value:p,onChange:C=>x(C.target.value),placeholder:"Optional display name","aria-label":"Name",autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,tabIndex:L?void 0:-1,className:K(qe,"text-center")}),t.jsx("input",{...Be,value:k,onChange:C=>N(C.target.value),placeholder:"Paste access token","aria-label":"Client token",tabIndex:L?void 0:-1,autoCapitalize:"none",className:K(qe,"text-center")}),t.jsx("p",{className:"px-1 text-center typography-micro text-muted-foreground",children:"Only needed if your server requires a token instead of a password."}),l?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):null,t.jsx(re,{type:"submit",variant:v?"outline":"default",size:"lg",className:"h-12 w-full",disabled:o||P||!u.trim(),children:o?"Connecting...":"Connect"})]})})})]})]})]})})]})},ro=10,dn=380,ao=(e,n)=>e.title?.trim()||n,oo=({session:e,meta:n,active:s,onSelect:r})=>{const o=nr(e.id),i=sr(e.id),l=o?.type??"idle",c=l==="busy"||l==="retry",u=!c&&i>0&&!s,d=rr(e.id,c),p=c&&d,x=ar(e.time?.updated??e.time?.created??0);return t.jsxs("button",{type:"button",className:K("flex w-full items-center gap-3 rounded-xl px-2.5 py-2 text-left transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary",s&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]"),onClick:r,style:{touchAction:"manipulation"},children:[t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[t.jsx("span",{className:K("block truncate typography-ui-label",s?"text-primary":"text-foreground"),children:ao(e,"Untitled Session")}),n?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:n}):null]}),c?t.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-primary","aria-hidden":!0}):u?t.jsx(or,{label:"Session complete"}):null,p?t.jsx(ir,{sessionId:e.id,running:c,className:"typography-micro"}):u?null:x?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:x}):null]})},io=({open:e,onClose:n,anchorRef:s})=>{const r=a.useRef(null),[o,i]=a.useState(e),[l,c]=a.useState(!1),{enabled:u}=On(),d=a.useRef(null),[p,x]=a.useState(null);a.useLayoutEffect(()=>{if(!e||!u||!o)return;const m=()=>{const $=s.current?.getBoundingClientRect(),b=d.current?.getBoundingClientRect();if(!$||!b){x(null);return}const S=$.left-b.left;x(Math.min(Math.max(S,8),Math.max(8,b.width-dn-8)))};m();const v=d.current;if(typeof ResizeObserver>"u"||!v)return;const L=new ResizeObserver(m);return L.observe(v),()=>L.disconnect()},[s,u,e,o]);const k=u&&p!==null,N=ge(m=>m.currentSessionId),P=ge(m=>m.setCurrentSession),R=zn(m=>m.setActiveProjectIdOnly),U=tr(e||o,{maxParents:ro});a.useEffect(()=>{if(e){i(!0),c(!1);return}if(!o)return;c(!0);const m=window.setTimeout(()=>{i(!1),c(!1)},140);return()=>window.clearTimeout(m)},[e,o]),a.useEffect(()=>{if(!e)return;const m=v=>{v.key==="Escape"&&n()};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[n,e]),a.useEffect(()=>{if(!e)return;const m=v=>{const L=v.target;if(!(L instanceof Node)){n();return}r.current?.contains(L)||s.current?.contains(L)||n()};return document.addEventListener("pointerdown",m,!0),()=>document.removeEventListener("pointerdown",m,!0)},[s,n,e]);const F=a.useCallback(m=>{P(m.id,Pt(m)),n()},[n,P]);return o?t.jsxs("div",{ref:d,className:"fixed inset-x-0 bottom-0 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-header-height,56px))] z-20 pointer-events-none",children:[t.jsx("div",{ref:r,role:"dialog","aria-label":"Open session switcher",className:K("flex flex-col overflow-hidden rounded-[20px] border border-border/70 bg-[var(--surface-elevated)] p-2 shadow-[0_12px_32px_rgb(0_0_0_/_0.2)] will-change-transform",k?"absolute origin-top-left":"mx-3 mt-2",l?"pointer-events-none":"pointer-events-auto"),style:{animation:`${l?"session-switcher-out":"session-switcher-in"} ${l?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...k?{top:8,left:p??8,width:`min(${dn}px, calc(100% - 16px))`}:null},children:t.jsx("div",{className:"oc-hide-scrollbar min-h-0 flex-1 space-y-0.5 overflow-y-auto overscroll-contain",children:U.length===0?t.jsx("p",{className:"px-3 py-6 text-center typography-small text-muted-foreground",children:"No recent sessions"}):U.map(m=>{const v=m.node.session,L=[m.secondaryMeta?.projectLabel,m.secondaryMeta?.branchLabel].filter(Boolean).join(" · ");return t.jsx(oo,{session:v,meta:L,active:v.id===N,onSelect:()=>{m.projectId&&R(m.projectId),F(v)}},v.id)})})}),t.jsx("style",{children:`
3
+ @keyframes session-switcher-in {
4
+ from { opacity: 0; transform: translateY(-8px) scale(0.985); }
5
+ to { opacity: 1; transform: translateY(0) scale(1); }
6
+ }
7
+ @keyframes session-switcher-out {
8
+ from { opacity: 1; transform: translateY(0) scale(1); }
9
+ to { opacity: 0; transform: translateY(-6px) scale(0.985); }
10
+ }
11
+ `})]}):null},lo=({onOpenSessions:e,onOpenWorkspace:n,compactTitle:s=!1})=>{const[r,o]=a.useState(!1),[i,l]=a.useState(!1),c=a.useRef(null),u=_n(v=>v.currentDirectory),d=ge(v=>v.currentSessionId),x=ge(a.useCallback(v=>d?v.getDirectoryForSession(d):null,[d]))||u,k=lr(d),N=ge(v=>!!v.newSessionDraft?.open),R=k?.title?.trim()||(d?"Untitled session":"New session");a.useEffect(()=>{o(!1),l(!1)},[d,x]);const U=a.useCallback(()=>{o(!1),l(!1),e()},[e]),F=a.useCallback(v=>{o(L=>{const $=typeof v=="function"?v(L):v;return $&&l(!1),$})},[]),m=a.useCallback(()=>{l(v=>{const L=!v;return L&&o(!1),L})},[]);return t.jsxs(t.Fragment,{children:[t.jsx("header",{className:"oc-mobile-header relative z-30 flex shrink-0 items-center gap-1 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",style:{paddingTop:"var(--oc-safe-area-top, 0px)"},children:t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":"Open sessions and projects",onClick:U,style:{touchAction:"manipulation"},children:t.jsx(V,{name:"list-unordered",className:"size-5"})}),t.jsx("button",{ref:c,type:"button",className:K("flex min-w-0 items-center rounded-lg px-2 py-1.5 text-left transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",s?"shrink":"flex-1"),"aria-label":"Open session switcher","aria-haspopup":"dialog","aria-expanded":i,onClick:m,style:{touchAction:"manipulation"},children:t.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",children:R}),t.jsx(V,{name:"arrow-down-s",className:K("size-4 shrink-0 text-muted-foreground transition-transform duration-150",i&&"rotate-180")})]})}),s?t.jsx("div",{className:"min-w-0 flex-1"}):null,t.jsx(Ns,{open:r,onOpenChange:F,currentSessionId:d,effectiveDirectory:x,isNewSessionDraftOpen:N}),t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":"Open workspace panel",onClick:()=>{o(!1),l(!1),n()},style:{touchAction:"manipulation"},children:t.jsx(V,{name:"layout-right",className:"size-5"})})]})}),t.jsx(io,{open:i,onClose:()=>l(!1),anchorRef:c})]})},co=({onActiveConnectionDeleted:e,onConnect:n})=>{const s=Zn(n),{connections:r,isBusy:o,isPasswordBusy:i,error:l,pendingConnection:c,connect:u,submitPassword:d,cancelPassword:p,saveConnection:x,removeConnection:k,setError:N}=s,[P,R]=a.useState(null),U=P?r.find(z=>z.id===P)??null:null,[F,m]=a.useState(null),[v,L]=a.useState(""),[$,b]=a.useState(""),[S,y]=a.useState(""),[B,g]=a.useState(""),[I,w]=a.useState(!1),[E,h]=a.useState(!1),[C,O]=a.useState(!1),[q,Z]=a.useState(null),X=a.useRef(null),A=a.useMemo(()=>Tt(),[]),[G,Y]=a.useState(!1),[f,j]=a.useState(null),_=a.useCallback(()=>{R(null),L(""),b(""),y(""),N(null),Y(!1)},[N]),H=a.useCallback(z=>{z.preventDefault(),x({id:P??void 0,url:v,label:$,clientToken:S}).then(Q=>{Q&&_()})},[S,P,$,_,x,v]),te=a.useCallback(async()=>{if(X.current)return;N(null),w(!0);const z=new AbortController;X.current=z;try{const Q=await ss({signal:z.signal});switch(X.current===z&&(X.current=null,w(!1)),Q.status){case"ok":L(Q.url),Q.label&&b(Q.label),Q.clientToken&&y(Q.clientToken),Y(!0);break;case"pairing":h(!0),await s.redeemPairingConnection(Q.pairing);break;case"permission-denied":N("Camera access is off. Enable it in Settings to scan a QR code.");break;case"invalid":N("That QR code is not an PiChamber connection code.");break;case"unsupported":N("QR scanning is only available in the installed mobile app.");break;case"failed":N("Could not scan that QR code. Try again or enter the URL manually.");break;default:break}}finally{h(!1),X.current===z&&(X.current=null,w(!1))}},[s,N]);a.useEffect(()=>()=>X.current?.abort(),[]);const J=a.useCallback(z=>{z.preventDefault(),d(B)},[B,d]),ae=a.useCallback(()=>{g(""),p()},[p]),Te=a.useCallback(async()=>{if(!C){Z(null),O(!0);try{const z=await gs();Z(z==="copied"?"Diagnostics copied to the clipboard.":z==="downloaded"?"Diagnostics downloaded.":"Diagnostics ready to share.")}catch{Z("Diagnostics export was cancelled or unavailable.")}finally{O(!1)}}},[C]),ue=a.useCallback(z=>{m(Q=>Q===z?null:z)},[]),ye=a.useCallback(z=>{m(null),P===z&&_();const Q=r.length===1;k(z).then(ne=>{ne&&(Q||un(ne))&&e()})},[r.length,P,e,k,_]),se=qe;return c?t.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:t.jsx("form",{className:"flex-1 overflow-y-auto px-5 py-4",onSubmit:J,children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(V,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:c.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:c.candidates.some(z=>z.kind==="direct")?ve(c):"via PiChamber Relay"})]})]}),t.jsx("input",{...Be,value:B,onChange:z=>g(z.target.value),placeholder:"PiChamber password","aria-label":"Password",type:"password",autoFocus:!0,className:se}),l?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:l}):null,t.jsx(re,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:i||!B.trim(),children:i?"Connecting...":"Unlock and connect"}),t.jsx(re,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:ae,children:"Use another server"})]})})}):t.jsxs(t.Fragment,{children:[I?t.jsx(rs,{onCancel:()=>X.current?.abort()}):null,E?t.jsx(as,{}):null,t.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:t.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:t.jsxs("div",{className:"space-y-6",children:[r.length>0?t.jsx("div",{className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(z=>{const Q=F===z.id,ne=un(z),we=f===z.id,xe=we?"Connecting...":ne?Qe()?"Connected · Private relay":"Connected · Local network":z.candidates.some(Pe=>Pe.kind==="direct")?ve(z):"via PiChamber Relay";return t.jsxs("div",{className:K("flex items-center border-b border-border/70 transition-colors last:border-b-0",Q&&"bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]"),children:[t.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-3 px-3.5 py-3 text-left transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:opacity-60",onClick:()=>{ne||(j(z.id),u({id:z.id,candidates:z.candidates,clientToken:z.clientToken,label:z.label}).finally(()=>j(null)))},disabled:o&&!we||Q,children:[t.jsxs("span",{className:"relative flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:[t.jsx(V,{name:"server",className:"size-[18px]"}),ne?t.jsx("span",{className:"absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-[var(--surface-elevated)] bg-[var(--status-success)]","aria-hidden":!0}):null]}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:z.label}),t.jsx("span",{className:K("block truncate typography-small",ne&&!we?"text-[var(--status-success)]":"text-muted-foreground"),children:xe})]}),we?t.jsx(V,{name:"loader-4",className:"size-5 shrink-0 animate-spin text-muted-foreground"}):null]}),t.jsxs("div",{className:"flex items-center gap-0.5 pr-2",children:[Q?t.jsxs("button",{type:"button","aria-label":`Confirm deleting ${z.label}`,className:"flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-destructive px-3 text-destructive-foreground transition-opacity active:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive",onClick:()=>ye(z.id),style:{touchAction:"manipulation"},children:[t.jsx(V,{name:"delete-bin",className:"size-[18px]"}),t.jsx("span",{className:"typography-ui-label",children:"Delete"})]}):z.candidates.some(Pe=>Pe.kind==="direct")?t.jsx("button",{type:"button","aria-label":"Edit",className:"flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:()=>{R(z.id),L(ve(z)),b(z.label),y(z.clientToken||""),N(null)},style:{touchAction:"manipulation"},children:t.jsx(V,{name:"edit",className:"size-[18px]"})}):null,t.jsx("button",{type:"button","aria-label":Q?`Keep ${z.label}`:`Delete ${z.label}`,className:"flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:()=>ue(z.id),style:{touchAction:"manipulation"},children:t.jsx(V,{name:Q?"close":"delete-bin",className:"size-[18px]"})})]})]},z.id)})}):t.jsx("p",{className:"rounded-[18px] border border-dashed border-border/70 px-4 py-6 text-center typography-small text-muted-foreground",children:"No saved connections yet."}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs(re,{type:"button",variant:"outline",size:"lg",className:"h-12 w-full",onClick:()=>{Te()},disabled:C,children:[t.jsx(V,{name:"download",className:"size-[18px]"}),C?"Preparing diagnostics…":"Export diagnostics"]}),q?t.jsx("p",{className:"px-1 text-center typography-small text-muted-foreground",children:q}):null]}),!G&&!U?t.jsxs("div",{className:"space-y-2",children:[A?t.jsxs(re,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{te()},disabled:I,children:[t.jsx(V,{name:"scan-2",className:K("size-[18px]",I&&"animate-pulse")}),"Scan QR code"]}):null,t.jsxs(re,{type:"button",variant:A?"ghost":"outline",size:"lg",className:"h-12 w-full",onClick:()=>{N(null),Y(!0)},children:[t.jsx(V,{name:"add",className:"size-[18px]"}),"Add by address"]}),l?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:l}):null]}):t.jsxs("form",{className:"space-y-3",onSubmit:H,children:[t.jsxs("div",{className:"flex h-8 items-center justify-between gap-3 px-1",children:[t.jsx("h3",{className:"typography-ui-label text-foreground",children:U?"Edit instance":"Add instance"}),t.jsx(re,{type:"button",variant:"ghost",size:"xs",onClick:_,children:"Cancel"})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:"Server URL"}),t.jsx("input",{...Be,value:v,onChange:z=>L(z.target.value),placeholder:"http://192.168.1.74:2606",type:"url",inputMode:"url",autoCapitalize:"none",className:se})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:"Name"}),t.jsx("input",{value:$,onChange:z=>b(z.target.value),placeholder:"Optional display name",autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,className:se})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:"Client token"}),t.jsx("input",{...Be,value:S,onChange:z=>y(z.target.value),placeholder:"Paste access token",autoCapitalize:"none",className:se}),t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:"Only needed if your server requires a token instead of a password."})]}),l?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:l}):null,t.jsx(re,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",children:U?"Save changes":"Save instance"})]})]})})})]})},Ve=320,Re="cubic-bezier(0.22, 1, 0.36, 1)",os=({side:e,enabled:n,open:s,drawerRef:r,scrimRef:o,onClose:i,widthRatio:l,prefersReducedMotion:c})=>{a.useEffect(()=>{if(!n||!s)return;const u=r.current,d=o.current;if(!u||!d)return;let p=!1,x=!1,k=!1,N=0,P=0,R=0,U=0;const F=c?0:Ve,m=e==="left"?"translateX(-100%)":"translateX(100%)",v=()=>({drawer:F?`transform ${F}ms ${Re}`:"none",scrim:F?`opacity ${F}ms ${Re}`:"none"}),L=()=>{const w=v();u.style.transition=w.drawer,d.style.transition=w.scrim,u.style.transform="none",d.style.opacity="1",d.style.pointerEvents="auto"},$=()=>{p=!1,x=!1,k=!1},b=()=>{if(!(p||x)){$();return}L(),$()},S=w=>{if(w.touches.length!==1){(p||x)&&b();return}if(Rs(w.target,u))return;u.style.transition&&u.style.transition!=="none"&&(u.style.transition="none",d.style.transition="none");const E=w.touches[0];N=E.clientX,P=E.clientY,R=Date.now(),U=u.offsetWidth||window.innerWidth*l,U<10&&(U=window.innerWidth*l),p=!0,x=!1,k=!1},y=w=>{if(!p)return;if(w.touches.length!==1){b();return}const E=w.touches[0],h=E.clientX-N,C=E.clientY-P;if(!k){if(Math.abs(h)<Ft&&Math.abs(C)<Ft)return;if(Math.abs(C)>Math.abs(h)*Ht||!Wt(e,h)){p=!1;return}k=!0,x=!0,u.style.transition="none",d.style.transition="none"}if(!x)return;w.cancelable&&w.preventDefault();const O=Vt(e,h,U);u.style.transform=Ts(e,O),d.style.opacity=String(O)},B=(w,E,h)=>{if(!p)return;const C=w-N,O=E-P,q=Math.max(1,Date.now()-R),Z=Vt(e,C,U),X=As({side:e,dx:C,dy:O,dt:q,progress:Z,isDragging:x}),A=v();u.style.transition=A.drawer,d.style.transition=A.scrim,u.style.transform=X?m:"none",d.style.opacity=X?"0":"1",d.style.pointerEvents=X?"none":"auto",$(),X&&i()},g=w=>{const E=w.changedTouches[0];if(!E){b();return}const h=E.clientX-N,C=E.clientY-P,O=Math.abs(h)>=Ps&&Math.abs(C)<=Math.abs(h)*Ht&&Wt(e,h);p&&(x||O)&&w.cancelable&&w.preventDefault(),B(E.clientX,E.clientY)},I=()=>{b()};return u.addEventListener("touchstart",S,{passive:!0}),u.addEventListener("touchmove",y,{passive:!1}),u.addEventListener("touchend",g,{passive:!1}),u.addEventListener("touchcancel",I,{passive:!0}),()=>{try{b()}catch{}u.removeEventListener("touchstart",S),u.removeEventListener("touchmove",y),u.removeEventListener("touchend",g),u.removeEventListener("touchcancel",I)}},[r,n,i,s,c,o,e,l])},uo=16,fn=a.memo(function({open:n,onOpenChange:s,variant:r="drawer",drawerRefExternal:o,scrimRefExternal:i,rootRefExternal:l}){const c=a.useRef(null),u=a.useCallback(()=>{const y=typeof document<"u"?document.activeElement:null;y instanceof HTMLElement&&c.current?.contains(y)&&y.blur(),s(!1)},[s]),d=ge(y=>y.openNewSessionDraft),p=de(y=>y.setActiveMainTab),x=de(y=>y.setSessionSwitcherOpen),[k,N]=a.useState(!1),P=a.useRef(null),R=a.useRef(null),U=o??P,F=i??R,m=a.useCallback(y=>{c.current=y,l&&(l.current=y)},[l]),v=a.useMemo(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[]);a.useEffect(()=>{const y=c.current;if(!y||n)return;const B=document.activeElement;B&&y.contains(B)&&B.blur()},[n]),a.useEffect(()=>{if(r!=="sidebar"){if(n){const y=window.setTimeout(()=>N(!0),v?0:uo);return()=>window.clearTimeout(y)}N(!1)}},[n,v,r]),a.useEffect(()=>{if(r==="sidebar"||!n)return;const y=document.body.style.overflow;document.body.style.overflow="hidden";const B=g=>{g.key==="Escape"&&u()};return document.addEventListener("keydown",B),()=>{document.body.style.overflow=y,document.removeEventListener("keydown",B)}},[u,n,r]);const L=a.useCallback(()=>{de.getState().closeMainSurfaces(),p("chat"),x(!1),d(),u()},[u,d,p,x]),$=r==="sidebar",b=t.jsx(Is,{mobileVariant:!$,isVisible:n,allowReselect:!0,onSessionSelected:$?void 0:u,onNavigateAway:$?void 0:u});if(os({side:"left",enabled:r==="drawer",open:n,drawerRef:U,scrimRef:F,onClose:u,widthRatio:.72,prefersReducedMotion:v}),r==="sidebar")return t.jsx("aside",{className:"relative flex h-full w-full flex-col bg-sidebar",children:b});if(typeof document>"u")return null;const S=v?0:Ve;return Fe.createPortal(t.jsxs("div",{ref:m,className:"fixed inset-0 z-50",inert:!n,style:{pointerEvents:n?"auto":"none"},"data-mobile-sessions-root":"true",children:[t.jsx("button",{ref:F,type:"button",className:"absolute inset-0 cursor-default bg-black/70","aria-label":"Close sessions",onClick:u,tabIndex:n?0:-1,style:{opacity:k?1:0,transition:`opacity ${S}ms ${Re}`},"data-mobile-sessions-scrim":"true"}),t.jsx("div",{ref:U,className:K("relative z-10 flex h-full w-[72%] max-w-[72%] flex-col bg-sidebar"),style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:k?"none":"translateX(-100%)",transition:S?`transform ${S}ms ${Re}`:"none",touchAction:"pan-x pan-y"},"data-mobile-sessions-drawer":"true",children:b}),t.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 z-20 flex w-[28%] items-end justify-center",style:{paddingBottom:"calc(1rem + var(--oc-safe-area-bottom, 0px))"},children:n?t.jsx(re,{type:"button",variant:"outline",size:"lg",className:"pointer-events-auto size-12 rounded-full p-0 [corner-shape:round] supports-[corner-shape:squircle]:rounded-full",onClick:L,"aria-label":"New session",children:t.jsx(V,{name:"chat-new",className:"size-5"})}):null})]}),document.body)}),mn="mobile-surface-root",kt=16,ot=200,fo=()=>{if(typeof document>"u")return null;let e=document.getElementById(mn);return e||(e=document.createElement("div"),e.id=mn,document.body.appendChild(e)),e},jt=({open:e,onClose:n,title:s,subtitle:r,trailing:o,disableEscapeDismiss:i=!1,headerless:l=!1,noHeaderBorder:c=!1,ariaLabel:u,variant:d="fullscreen",dialogAlign:p="chat",children:x})=>{const k=a.useRef(null),[N,P]=a.useState(!1),[R,U]=a.useState(!1),F=a.useRef(null),m=a.useRef(null),v=a.useRef(n);if(a.useEffect(()=>{v.current=n},[n]),typeof document<"u"&&!k.current&&(k.current=fo()),a.useEffect(()=>{if(!e){P(!1);return}const b=window.setTimeout(()=>P(!0),kt);return()=>window.clearTimeout(b)},[e]),a.useEffect(()=>{if(!e){U(!1);return}const b=window.setTimeout(()=>U(!0),kt+ot+80);return()=>window.clearTimeout(b)},[e]),a.useEffect(()=>{if(!e)return;const b=document.body.style.overflow;m.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow="hidden";const S=()=>{const g=F.current;if(!g)return;(g.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??g).focus({preventScroll:!0})},y=window.setTimeout(S,kt),B=g=>{if(g.key==="Escape"&&!i){v.current();return}if(g.key!=="Tab")return;const I=F.current;if(!I)return;const w=Array.from(I.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(O=>!O.hasAttribute("disabled")&&O.getAttribute("aria-hidden")!=="true");if(w.length===0){g.preventDefault(),I.focus({preventScroll:!0});return}const E=w[0],h=w[w.length-1],C=document.activeElement;g.shiftKey&&C===E?(g.preventDefault(),h.focus({preventScroll:!0})):!g.shiftKey&&C===h&&(g.preventDefault(),E.focus({preventScroll:!0}))};return document.addEventListener("keydown",B),()=>{window.clearTimeout(y),document.body.style.overflow=b,document.removeEventListener("keydown",B),m.current?.focus?.({preventScroll:!0}),m.current=null}},[i,e]),!e||!k.current)return null;const L=d==="dialog",$=t.jsxs("section",{ref:F,role:"dialog","aria-modal":"true","aria-label":u,tabIndex:-1,className:K("flex flex-col bg-background text-foreground",L?"h-[min(88dvh,860px)] w-full max-w-[720px] overflow-hidden rounded-2xl border border-border/70 shadow-[0_24px_64px_rgb(0_0_0_/_0.32)]":"oc-keyboard-inset-surface fixed inset-0 z-50"),style:L?{opacity:N?1:0,transform:N?"none":"scale(0.97)",transition:`opacity ${ot}ms ease-out, transform ${ot}ms cubic-bezier(0.32, 0.72, 0, 1)`}:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:N?"none":"translateX(100%)",transition:`transform ${ot}ms cubic-bezier(0.32, 0.72, 0, 1)`},onTransitionEnd:b=>{N&&b.target===b.currentTarget&&b.propertyName==="transform"&&U(!0)},children:[l?null:t.jsxs("header",{className:K("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",!c&&"border-b border-border/70"),children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":"Close",onClick:n,style:{touchAction:"manipulation"},children:t.jsx(V,{name:"close",className:"size-5"})}),t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[s?typeof s=="string"?t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:s}):s:null,r?typeof r=="string"?t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:r}):r:null]}),o?t.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:o}):null]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:R?t.jsx("div",{className:"h-full",style:{animation:"oc-surface-content-in 200ms ease-out"},children:x}):null}),t.jsx("style",{children:"@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }"})]});return L?Fe.createPortal(t.jsx("div",{className:"oc-keyboard-inset-surface fixed inset-0 z-50 flex items-center justify-center p-4 transition-opacity duration-200 ease-out",style:{background:"rgb(0 0 0 / 0.45)",opacity:N?1:0,paddingLeft:p==="chat"?"max(1rem, var(--oc-chat-inset-left, 0px))":"1rem",paddingRight:p==="chat"?"max(1rem, var(--oc-chat-inset-right, 0px))":"1rem",paddingTop:"max(1rem, var(--oc-safe-area-top, 0px))"},onClick:n,children:t.jsx("div",{className:"flex w-full max-w-[720px] justify-center",onClick:b=>b.stopPropagation(),children:$})}),k.current):Fe.createPortal($,k.current)},is={"?":{code:"?",color:"var(--status-info)",description:"Untracked file"},A:{code:"A",color:"var(--status-success)",description:"New file"},D:{code:"D",color:"var(--status-error)",description:"Deleted file"},R:{code:"R",color:"var(--status-info)",description:"Renamed file"},C:{code:"C",color:"var(--status-info)",description:"Copied file"},M:{code:"M",color:"var(--status-warning)",description:"Modified file"}},mo=is.M;function po(e){const n=e.index?.trim(),s=e.working_dir?.trim();return n&&n!=="?"?n.charAt(0):s?s.charAt(0):n?.charAt(0)||s?.charAt(0)||"M"}function ho(e){const n=po(e);return is[n]??mo}const go=a.memo(function({file:n,actionLabel:s,actionSymbol:r,onAction:o,onViewDiff:i,onRevert:l,isReverting:c,stats:u,rowPaddingClassName:d,indentPx:p=0,actionAtStart:x=!1,showRevert:k=!0}){const N=De.useMemo(()=>ho(n),[n]),P=N.description,R=u?.insertions??0,U=u?.deletions??0,F=De.useCallback($=>{$.key===" "?($.preventDefault(),o()):$.key==="Enter"&&($.preventDefault(),i())},[o,i]),m=De.useCallback($=>{$.preventDefault(),$.stopPropagation(),o()},[o]),v=De.useCallback($=>{$.preventDefault(),$.stopPropagation(),l()},[l]),L=t.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":s,title:s,children:r});return t.jsxs("div",{className:`group flex items-center gap-2 py-1.5 cursor-pointer ${d??"px-3"}`,role:"button",tabIndex:0,onClick:i,onKeyDown:F,style:p>0?{paddingLeft:`${p}px`}:void 0,children:[x?L:null,t.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:N.color},title:P,"aria-label":P,children:N.code}),t.jsx($n,{filePath:n.path,className:"h-3.5 w-3.5 shrink-0"}),(()=>{const $=n.path.lastIndexOf("/");if($===-1)return t.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:n.path,children:n.path});const b=n.path.slice(0,$),S=n.path.slice($);return t.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:n.path,children:[t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:b}),t.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[t.jsx("span",{className:"text-muted-foreground",children:"/"}),t.jsx("span",{className:"text-foreground",children:S.slice(1)})]})]})})(),t.jsxs("span",{className:"shrink-0 typography-micro",children:[t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",R]}),t.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",U]})]}),k?t.jsxs(cr,{children:[t.jsx(ur,{asChild:!0,children:t.jsx("button",{type:"button",onClick:v,disabled:c,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50","aria-label":`Revert changes in ${n.path}`,children:c?t.jsx(V,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(V,{name:"arrow-go-back",className:"size-3.5"})})}),t.jsx(dr,{sideOffset:8,children:"Revert changes"})]}):null,x?null:L]})}),pn=14,ls=e=>e.replace(/\\/g,"/").replace(/^\/+/,"").trim(),hn=(e,n)=>({id:`dir:${e}`,path:e,name:n,children:new Map,directFiles:[],files:[]}),yo=e=>{const n=hn("","");for(const s of e){const r=ls(s.path);if(!r)continue;const i=r.split("/").filter(Boolean).slice(0,-1);let l=n;if(l.files.push(s),i.length>0){let c="";for(const u of i){c=c?`${c}/${u}`:u;const d=l.children.get(u);if(d){d.files.push(s),l=d;continue}const p=hn(c,u);p.files.push(s),l.children.set(u,p),l=p}}l.directFiles.push(s)}return n},bo=(e,n)=>{const s=[],r=(o,i)=>{const l=Array.from(o.children.values()).sort((u,d)=>u.path.localeCompare(d.path));for(const u of l)s.push({key:u.id,kind:"directory",depth:i,directory:u}),n.has(u.path)&&r(u,i+1);const c=[...o.directFiles].sort((u,d)=>u.path.localeCompare(d.path));for(const u of c)s.push({key:`file:${ls(u.path)}`,kind:"file",depth:i,file:u})};return r(e,0),s},xo=1e3,gn=34,St=30,it="pl-0 pr-2",Ct=(e,n)=>`${e} ${n}`,vo=({groups:e,diffStats:n,revertingPaths:s,isRevertingAll:r=!1,headerBackgroundClassName:o="bg-sidebar",onVisiblePathsChange:i,onRevertAll:l,onRevertDirectory:c})=>{const u=a.useRef(null),p=de(f=>f.gitChangesViewMode)==="tree",x=a.useMemo(()=>e.filter(f=>f.entries.length>0),[e]),[k,N]=a.useState(new Set),[P,R]=a.useState(new Set),[U,F]=a.useState(!1),[m,v]=a.useState(null),L=a.useMemo(()=>x.map(f=>yo(f.entries)),[x]),$=a.useMemo(()=>{const f=[];return x.forEach((j,_)=>{Array.from(L[_]?.children.values()??[]).forEach(H=>{f.push(Ct(j.id,H.path))})}),f},[L,x]);a.useEffect(()=>{p&&R(f=>{const j=new Set,_=new Set($);return f.forEach(H=>{(H.slice(H.indexOf(" ")+1).includes("/")||_.has(H))&&j.add(H)}),$.forEach(H=>j.add(H)),j})},[p,$]);const b=a.useMemo(()=>{const f=[];return x.forEach((j,_)=>{if(f.push({type:"header",key:`header:${j.id}`,groupIndex:_}),!k.has(j.id)){if(p){const H=new Set;P.forEach(J=>{J.startsWith(`${j.id} `)&&H.add(J.slice(j.id.length+1))}),bo(L[_],H).forEach(J=>{J.kind==="file"?f.push({type:"file",key:`${j.id}:${J.key}`,groupIndex:_,file:J.file,depth:J.depth}):f.push({type:"directory",key:`${j.id}:${J.key}`,groupIndex:_,directory:J.directory,depth:J.depth})});return}j.entries.forEach(H=>{f.push({type:"file",key:`${j.id}:file:${H.path}`,groupIndex:_,file:H,depth:0})})}}),l&&x.length>0&&f.push({type:"revert-all",key:"revert-all"}),f},[k,P,p,l,L,x]),S=b.length,y=S>=xo,B=sa({count:S,enabled:y,getScrollElement:()=>u.current,estimateSize:()=>gn,overscan:12,getItemKey:f=>b[f]?.key??f}),g=B.getVirtualItems(),I=a.useMemo(()=>{if(!y)return 0;const f=u.current?.scrollTop??0;return g.find(_=>_.end>f)?.index??0},[y,g,u]);a.useEffect(()=>{if(!i)return;const f=j=>j&&j.type==="file"?j.file.path:null;if(S===0){i([]);return}if(!y){const j=[];for(const _ of b)if(_.type==="file"&&(j.push(_.file.path),j.length>=St))break;i(j);return}i(b.slice(I,I+Math.ceil((u.current?.clientHeight??0)/gn)+St).map(j=>f(j)).filter(j=>!!j).slice(0,St))},[i,S,b,y,I]);const w=a.useCallback(f=>{N(j=>{const _=new Set(j);return _.has(f)?_.delete(f):_.add(f),_})},[]),E=a.useCallback((f,j)=>{R(_=>{const H=new Set(_),te=Ct(f,j);return H.has(te)?H.delete(te):H.add(te),H})},[]),h=a.useMemo(()=>{const f=new Set;return x.forEach(j=>j.entries.forEach(_=>f.add(_.path))),Array.from(f)},[x]),C=h.length,O=m?r||m.paths.some(f=>s.has(f)):!1,q=a.useCallback(async()=>{!l||r||h.length===0||(await l(h),F(!1))},[h,r,l]),Z=a.useCallback(async()=>{!c||!m||O||(await c(m.paths),v(null))},[O,c,m]),X=a.useCallback((f,j)=>{const _=k.has(f.id),H=f.entries.length;return t.jsxs("div",{className:K("sticky top-0 z-10 flex items-center gap-2 py-2",o,it,!j&&"mt-1 border-t border-border/40"),children:[t.jsx("button",{type:"button",onClick:()=>f.onActionAll(f.entries.map(te=>te.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":f.actionAllLabel,title:f.actionAllLabel,children:f.actionSymbol}),t.jsxs("button",{type:"button",onClick:()=>w(f.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":!_,children:[t.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:f.title}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:H}),t.jsx(V,{name:"arrow-down-s",className:K("size-3.5 shrink-0 text-muted-foreground transition-transform",_&&"-rotate-90")})]})]})},[k,o,w]),A=a.useCallback((f,j,_)=>{const H=P.has(Ct(f.id,j.path)),te=j.files.map(ae=>ae.path),J=r||te.some(ae=>s.has(ae));return t.jsxs("div",{className:K("group flex items-center gap-2 py-1.5",it),style:{paddingLeft:`${_*pn}px`},children:[t.jsxs("button",{type:"button",onClick:()=>E(f.id,j.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":H?`Collapse directory ${j.path}`:`Expand directory ${j.path}`,children:[H?t.jsx(V,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):t.jsx(V,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:j.path,children:j.name}),t.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:j.files.length})]}),f.showRevertActions!==!1&&c?t.jsx("button",{type:"button",onClick:()=>v({path:j.path,paths:te,count:te.length}),disabled:J,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 ${j.path}`,title:"Revert folder changes",children:J?t.jsx(V,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(V,{name:"arrow-go-back",className:"size-3.5"})}):null,t.jsx("button",{type:"button",onClick:()=>f.onActionAll(j.files.map(ae=>ae.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":f.actionSymbol==="+"?`Stage all changes in ${j.path}`:`Unstage all changes in ${j.path}`,title:f.actionSymbol==="+"?`Stage all changes in ${j.path}`:`Unstage all changes in ${j.path}`,children:f.actionSymbol})]})},[P,r,c,s,E]),G=a.useCallback((f,j)=>{if(f.type==="revert-all")return t.jsx("div",{className:K("flex justify-end py-2",it),children:t.jsxs(re,{variant:"ghost",size:"sm",onClick:()=>F(!0),disabled:r,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[t.jsx(V,{name:"arrow-go-back",className:"size-3.5"}),"Revert all"]})});const _=x[f.groupIndex];if(!_)return null;if(f.type==="header")return X(_,j);if(f.type==="directory")return A(_,f.directory,f.depth);const H=f.file;return t.jsx(go,{file:H,actionLabel:_.getActionLabel(H.path),actionSymbol:_.actionSymbol,onAction:()=>_.onActionFile(H.path),stats:n?.[H.path],onViewDiff:()=>_.onViewDiff(H.path),onRevert:()=>_.onRevertFile(H.path),isReverting:s.has(H.path)||r,rowPaddingClassName:it,indentPx:f.depth*pn,actionAtStart:!p,showRevert:_.showRevertActions!==!1})},[n,r,p,A,X,s,x]),Y=a.useCallback(f=>{const j=b[f],_=b[f-1];return!j||!_||j.type!=="file"&&j.type!=="directory"||_.type!=="file"&&_.type!=="directory"?!1:_.groupIndex===j.groupIndex},[b]);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[t.jsx(At,{ref:u,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:y?t.jsx("div",{style:{height:B.getTotalSize(),position:"relative"},children:g.map(f=>{const j=b[f.index];return j?t.jsx("div",{"data-index":f.index,ref:B.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${f.start}px)`},className:K(Y(f.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:G(j,f.index===0)},j.key):null})}):t.jsx("div",{role:"list","aria-label":"Changed files",children:b.map((f,j)=>t.jsx("div",{className:K("relative",Y(j)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:G(f,j===0)},f.key))})}),t.jsx(fr,{containerRef:u,disableHorizontal:!0})]}),t.jsx(Kt,{open:U,onOpenChange:f=>{!r&&!f&&F(!1)},children:t.jsxs(Gt,{className:"max-w-md",children:[t.jsxs(Xt,{children:[t.jsx(qt,{children:"Revert all changes?"}),t.jsx(Yt,{children:C===1?`Revert ${C} changed file? This cannot be undone.`:`Revert ${C} changed files? This cannot be undone.`})]}),t.jsxs(Jt,{children:[t.jsx(re,{variant:"outline",size:"sm",onClick:()=>F(!1),disabled:r,children:"Cancel"}),t.jsx(re,{variant:"destructive",size:"sm",onClick:()=>{q()},disabled:r,children:r?"Reverting...":"Revert all"})]})]})}),t.jsx(Kt,{open:!!m,onOpenChange:f=>{!O&&!f&&v(null)},children:t.jsxs(Gt,{className:"max-w-md",children:[t.jsxs(Xt,{children:[t.jsx(qt,{children:"Revert folder changes?"}),t.jsx(Yt,{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})]}),t.jsxs(Jt,{children:[t.jsx(re,{variant:"outline",size:"sm",onClick:()=>v(null),disabled:O,children:"Cancel"}),t.jsx(re,{variant:"destructive",size:"sm",onClick:()=>{Z()},disabled:O||!m,children:O?"Reverting...":"Revert folder"})]})]})})]})},wo=wr(()=>be(()=>import("./DiffView-D1dyOiw2.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118])).then(e=>({default:e.DiffView}))),ko=e=>(e||"").replace(/\\/g,"/").replace(/\/+$/g,""),jo=e=>{const n=e.index?.trim();return!!(n&&n!=="?")},So=e=>{const n=e.working_dir?.trim(),s=e.index?.trim();return!!(n||s==="?")},yn=(e,n)=>n?`${e}\0staged`:e,Co=({onClose:e,initialDiffPath:n,initialDiffStaged:s=!1})=>{const{git:r}=Un(),o=ko(It()??null),i=mr(o||null),l=pr(o||null),c=hr(o||null),u=ke(T=>T.setActiveDirectory),d=ke(T=>T.ensureAll),p=ke(T=>T.fetchStatus),x=ke(T=>T.fetchBranches),k=ke(T=>T.prefetchDiffs),N=ke(T=>T.getDiff),P=ke(T=>T.setDiff),[R,U]=a.useState(()=>n?{type:"diff",path:n,staged:s}:{type:"list"});a.useEffect(()=>{n&&U(T=>T.type==="diff"&&T.path===n&&T.staged===s?T:{type:"diff",path:n,staged:s})},[n,s]);const[F,m]=a.useState(null),[v,L]=a.useState(null),[$,b]=a.useState(""),[S,y]=a.useState(new Set),[B,g]=a.useState(!1),[I,w]=a.useState(!1),[E,h]=a.useState([]),[C,O]=a.useState([]),[q,Z]=a.useState([]),[X,A]=a.useState(null),[G,Y]=a.useState(null),[f,j]=a.useState(0),_=a.useMemo(()=>{const T=i?.files??[],M=new Map;for(const W of T)M.set(W.path,W);return Array.from(M.values()).sort((W,ee)=>W.path.localeCompare(ee.path))},[i?.files]),H=a.useMemo(()=>_.filter(jo),[_]),te=a.useMemo(()=>_.filter(So),[_]),J=a.useMemo(()=>{if(q.length>0)return q;const T=i?.tracking?.includes("/")?i.tracking.split("/")[0]:null;return T||X?[{name:T||"origin",fetchUrl:X??"",pushUrl:X??""}]:[]},[X,q,i?.tracking]),ae=ke(a.useCallback(T=>!o||R.type!=="diff"?null:T.directories.get(o)?.diffCache.get(yn(R.path,R.staged))??null,[o,R])),Te=a.useMemo(()=>R.type!=="diff"?null:_.find(T=>T.path===R.path)??null,[_,R]),ue=a.useCallback(async(T=!0)=>{if(o)try{await Promise.all([p(o,r),x(o,r)])}catch(M){T&&oe.error(M instanceof Error?M.message:"Failed to refresh repository")}},[o,x,p,r]),ye=a.useCallback(async()=>{if(!o){Z([]),A(null);return}try{const[T,M]=await Promise.all([r.getRemotes(o).catch(()=>[]),r.getRemoteUrl?r.getRemoteUrl(o).catch(()=>null):Promise.resolve(null)]);Z(T),A(M)}catch{Z([]),A(null)}},[o,r]);a.useEffect(()=>{o&&(u(o),d(o,r))},[o,d,r,u]),a.useEffect(()=>{ye()},[ye]),a.useEffect(()=>{if(!o||_.length===0)return;const T=Array.from(new Set([...H.map(W=>W.path),...C,..._.slice(0,20).map(W=>W.path)])).filter(Boolean);if(T.length===0)return;const M=window.setTimeout(()=>{k(o,r,T,{maxFiles:40})},120);return()=>window.clearTimeout(M)},[_,o,r,k,H,C]),a.useEffect(()=>{if(R.type!=="diff"){Y(null);return}const T=yn(R.path,R.staged);if(!o||N(o,T)){Y(null);return}let M=!1;const W=tt();return Y(null),r.getGitFileDiff(o,{path:R.path,staged:R.staged||void 0}).then(ee=>{M||P(o,T,{original:ee.original??"",modified:ee.modified??"",isBinary:ee.isBinary},W)}).catch(ee=>{M||Y(ee instanceof Error?ee.message:String(ee))}),()=>{M=!0}},[o,f,N,r,R,P]);const se=async(T,M)=>{if(o){m(T);try{const W=ee=>{const D=`${ee.name}/`,me=i?.tracking?.startsWith(D)?i.tracking.slice(D.length):void 0;return{remote:ee.name,branch:me,rebase:!0}};if(T==="fetch"){if(!M)throw new Error("No remote available");await r.gitFetch(o,{remote:M.name}),oe.success(`Fetched from ${M.name}`)}else if(T==="sync"){if(!M)throw new Error("No remote available");await r.gitFetch(o,{remote:M.name});const ee=await r.getGitStatus(o);if((ee.behind??0)>0){if((ee.files?.length??0)>0){oe.error("Commit or stash your changes before syncing");return}await r.gitPull(o,W(M))}((await r.getGitStatus(o)).ahead??0)>0&&await r.gitPush(o),oe.success("Already up to date")}await ue(!1),await ye()}catch(W){oe.error(W instanceof Error?W.message:"Sync Changes failed")}finally{m(null)}}},z=a.useCallback(async(T,M)=>{if(!(!o||T.length===0))try{M==="stage"?T.length>1?await gr(o,T):await yr(o,T[0]):T.length>1?await br(o,T):await xr(o,T[0]),await ue(!1)}catch(W){oe.error(W instanceof Error?W.message:M==="stage"?"Failed to stage changes":"Failed to unstage changes")}},[o,ue]),Q=a.useCallback((T,M=!1)=>{U({type:"diff",path:T,staged:M})},[]),ne=a.useCallback(async T=>{if(o){y(M=>new Set(M).add(T));try{await r.revertGitFile(o,T),oe.success(`Reverted ${T}`),await ue(!1)}catch(M){oe.error(M instanceof Error?M.message:"Failed to revert changes")}finally{y(M=>{const W=new Set(M);return W.delete(T),W})}}},[o,r,ue]),we=a.useCallback(async T=>{if(!o||T.length===0||B)return;const M=Array.from(new Set(T));g(!0),y(new Set(M));try{await Promise.all(M.map(W=>r.revertGitFile(o,W))),await ue(!1),oe.success(M.length===1?`Reverted ${M.length} file`:`Reverted ${M.length} files`)}catch(W){oe.error(W instanceof Error?W.message:"Failed to revert changes")}finally{y(new Set),g(!1)}},[o,r,B,ue]),xe=a.useCallback(T=>{const M=T.map(W=>W.trim()).filter(Boolean);if(M.length===0){h([]);return}b(W=>`${W.trim()}${W.trim()?`
12
+
13
+ `:""}${M.join(`
14
+ `)}`.trim()),h([])},[]),Pe=a.useCallback(async()=>{if(!o)return;const T=H.map(M=>M.path).sort();if(T.length===0){oe.error("Select at least one file to describe");return}w(!0);try{const{message:M}=await vr(o,T);b(M.subject?.trim()??""),h(Array.isArray(M.highlights)?M.highlights:[])}catch(M){oe.error(M instanceof Error?M.message:"Failed to generate commit message")}finally{w(!1)}},[o,H]),st=async(T={})=>{if(!o)return;if(!$.trim()){oe.error("Enter a commit message");return}const M=H.map(W=>W.path).sort();if(M.length===0){oe.error("Select at least one file to commit");return}L(T.pushAfter?"commitAndPush":"commit");try{if(await r.createGitCommit(o,$.trim(),{files:M}),oe.success("Commit created"),b(""),h([]),T.pushAfter){const W=i?.tracking?.split("/")[0],ee=J.find(at=>at.name===W)??J[0];if(!ee)throw new Error("No remote available");m("sync");const D=`${ee.name}/`,me=i?.tracking?.startsWith(D)?i.tracking.slice(D.length):void 0;await r.gitFetch(o,{remote:ee.name}),((await r.getGitStatus(o)).behind??0)>0&&await r.gitPull(o,{remote:ee.name,branch:me,rebase:!0}),((await r.getGitStatus(o)).ahead??0)>0&&await r.gitPush(o),await ue(!1),await ye()}else await ue(!1)}catch(W){oe.error(W instanceof Error?W.message:"Failed to create commit")}finally{L(null),T.pushAfter&&m(null)}},bt=a.useMemo(()=>{const T=[];return H.length>0&&T.push({id:"staged",title:"Staged",entries:H,actionSymbol:"-",actionAllLabel:"Unstage all changes",getActionLabel:M=>`Unstage ${M}`,onActionFile:M=>{z([M],"unstage")},onActionAll:M=>{z(M,"unstage")},onViewDiff:M=>Q(M,!0),onRevertFile:ne,showRevertActions:!1,accent:!0}),te.length>0&&T.push({id:"unstaged",title:"Changes",entries:te,actionSymbol:"+",actionAllLabel:"Stage all changes",getActionLabel:M=>`Stage ${M}`,onActionFile:M=>{z([M],"stage")},onActionAll:M=>{z(M,"stage")},onViewDiff:M=>Q(M,!1),onRevertFile:ne}),T},[ne,Q,z,H,te]),Ge=T=>t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-transparent text-foreground",children:[t.jsx("div",{className:"flex shrink-0 items-center gap-2 px-3 py-2",children:t.jsx("p",{className:"min-w-0 flex-1 truncate typography-ui-label text-muted-foreground",children:i?.current||o||""})}),t.jsx("div",{className:"min-h-0 flex-1",children:T})]});return o?c&&l===null?Ge(t.jsx(Ee,{loading:!0,message:"Checking repository..."})):l===!1?Ge(t.jsx(a.Suspense,{fallback:t.jsx(Ee,{loading:!0,message:"Loading last turn changes..."}),children:t.jsx(wo,{diffScope:"turn",hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,flushContent:!0})})):R.type==="diff"?t.jsx(Eo,{path:R.path,diff:ae,fileExists:!!Te,error:G,onBack:()=>U({type:"list"}),onRetry:()=>j(T=>T+1)}):t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-transparent text-foreground",children:[t.jsxs("div",{className:"flex shrink-0 items-center gap-2 px-3 py-2",children:[e?t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":"Close",onClick:e,style:{touchAction:"manipulation"},children:t.jsx(V,{name:"close",className:"size-4"})}):null,t.jsx("p",{className:"min-w-0 flex-1 truncate typography-ui-label text-muted-foreground",children:i?.current||o}),t.jsx(Ds,{syncAction:F,remotes:J,onFetch:T=>{se("fetch",T)},onSync:T=>{se("sync",T)},disabled:v!==null||c,aheadCount:i?.ahead??0,behindCount:i?.behind??0,trackingRemoteName:i?.tracking?.split("/")[0],hasUncommittedChanges:_.length>0})]}),_.length>0?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden px-3 pt-2",children:t.jsx(vo,{groups:bt,diffStats:i?.diffStats,revertingPaths:S,onRevertAll:we,isRevertingAll:B,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:O})}),t.jsx("div",{className:"shrink-0 border-t border-border/40 px-3 pb-3 pt-3",children:t.jsx(ra,{stagedCount:H.length,commitMessage:$,onCommitMessageChange:b,generatedHighlights:E,onInsertHighlights:xe,onGenerateMessage:Pe,isGeneratingMessage:I,onCommit:()=>{st({pushAfter:!1})},onCommitAndPush:()=>{st({pushAfter:!0})},commitAction:v,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(Ee,{icon:!0,message:"Working tree clean",description:"There are no changed files in this workspace."})})]}):Ge(t.jsx(Ee,{message:"Select a session or directory to view Git status"}))},Ee=({message:e,description:n,loading:s=!1,icon:r=!1})=>t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[s?t.jsx(V,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,r?t.jsx(V,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:e}),n?t.jsx("p",{className:"typography-meta text-muted-foreground",children:n}):null]})}),Eo=({path:e,diff:n,fileExists:s,error:r,onBack:o,onRetry:i})=>{const l=a.useMemo(()=>kr(e)||"text",[e]);return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-transparent text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-1 px-2 text-foreground",children:[t.jsx("button",{type:"button",className:"flex size-9 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:o,children:t.jsx(V,{name:"arrow-left",className:"size-4"})}),t.jsx("div",{className:"min-w-0 flex-1 px-2",children:t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:e})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:s?r?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:"Failed to load diff"}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:r}),t.jsx(re,{type:"button",size:"sm",variant:"outline",onClick:i,children:"Retry"})]})}):n?n.isBinary?t.jsx(Ee,{icon:!0,message:"Content of this file cannot be viewed."}):jr(e)?t.jsx(Ee,{icon:!0,message:"Image diffs are not available in mobile Changes yet."}):t.jsx(At,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:t.jsx(aa,{original:n.original,modified:n.modified,language:l,fileName:e,renderSideBySide:!1,wrapLines:!0,layout:"inline"})}):t.jsx(Ee,{loading:!0,message:"Loading diff..."}):t.jsx(Ee,{icon:!0,message:"File is no longer changed",description:"Go back to Changes and refresh the list."})})]})},fe=e=>(e||"").replace(/\\/g,"/").replace(/\/+$/g,""),Ue=e=>{const n=fe(e);return!n||n==="/"?n||"/":n.split("/").filter(Boolean).at(-1)??n},cs=e=>{const n=fe(e);if(!n||n==="/")return null;const s=n.lastIndexOf("/");if(s<0)return null;if(s===0)return"/";const r=n.slice(0,s);return/^[A-Za-z]:$/.test(r)?`${r}/`:r},bn=(e,n)=>{const s=fe(e),r=fe(n);return!s||!r?!1:s===r||s.startsWith(`${r}/`)},xn=(e,n)=>{const s=fe(e);if(!s)return fe(n);if(s.startsWith("/")||/^[A-Za-z]:(\/|$)/.test(s))return s;const r=fe(n);return r?`${r}/${s}`:s},No=(e,n)=>{const s=fe(e),r=fe(n);if(!s||s===r)return!1;const o=cs(s);return o?r&&bn(s,r)?bn(o,r):!0:!1},Ro=a.lazy(()=>be(()=>import("./FilesView-BCzghrc7.js"),__vite__mapDeps([119,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,111,112,113,120,121,122,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,123,124,116,117,125,126,114,115])).then(e=>({default:e.FilesView}))),To=(e,n)=>{const s=fe(e),r=fe(n);return!r||s===r?Ue(s):s.startsWith(`${r}/`)?s.slice(r.length+1):s},Po=e=>{if(typeof e!="number"||!Number.isFinite(e)||e<0)return"";if(e<1024)return`${e} B`;const n=["KB","MB","GB"];let s=e/1024;for(const r of n){if(s<1024||r===n[n.length-1])return`${s.toFixed(s>=10?0:1)} ${r}`;s/=1024}return""},Ao=({onClose:e})=>{const{files:n}=Un(),s=ys(h=>h.setSelectedPath),r=fe(It()??null),[o,i]=a.useState(()=>({type:"browser",directory:r})),[l,c]=a.useState([]),[u,d]=a.useState(!1),[p,x]=a.useState(null),[k,N]=a.useState(""),[P,R]=a.useState([]),[U,F]=a.useState(!1),m=a.useRef(0);a.useEffect(()=>{r&&i(h=>h.type==="browser"&&h.directory?h:{type:"browser",directory:r})},[r]);const v=o.type==="browser"?o.directory:o.returnDirectory,L=a.useCallback(async h=>{if(!h)return;const C=m.current+1;m.current=C,d(!0),x(null);try{const O=await n.listDirectory(h);if(m.current!==C)return;c(O.entries.slice().sort((Z,X)=>Z.isDirectory!==X.isDirectory?Z.isDirectory?-1:1:Z.name.localeCompare(X.name)));const q=fe(O.directory);q&&q!==fe(h)&&i(Z=>Z.type==="browser"&&Z.directory!==q?{type:"browser",directory:q}:Z)}catch(O){if(m.current!==C)return;c([]),x(O instanceof Error?O.message:"Failed to load files")}finally{m.current===C&&d(!1)}},[n]);a.useEffect(()=>{o.type==="browser"&&L(o.directory)},[L,o]),a.useEffect(()=>{if(o.type!=="browser")return;const h=k.trim();if(!h){R([]),F(!1);return}let C=!1;const O=window.setTimeout(()=>{F(!0),n.search({directory:o.directory,query:h,maxResults:40}).then(q=>{C||R(q)}).catch(()=>{C||R([])}).finally(()=>{C||F(!1)})},250);return()=>{C=!0,window.clearTimeout(O)}},[n,k,o]);const $=h=>{N(""),i({type:"browser",directory:h})},b=h=>{s(r,h),i({type:"file",path:h,returnDirectory:v||r})},S=de(h=>h.pendingFileFocusPath),y=de(h=>h.pendingFileNavigation);if(a.useEffect(()=>{const h=fe(y?.path??S??"");!h||!r||h!==r&&!h.startsWith(`${r}/`)||(s(r,h),i({type:"file",path:h,returnDirectory:r}),S&&de.getState().setPendingFileFocusPath(null))},[S,y,r,s]),!r)return t.jsx(Je,{message:"Select a project to browse files."});if(o.type==="file")return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-transparent text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-1 px-2 text-foreground",children:[t.jsx("button",{type:"button",className:"flex size-9 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:()=>i({type:"browser",directory:o.returnDirectory}),style:{touchAction:"manipulation"},children:t.jsx(Zt,{className:"size-4"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:Ue(o.path)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(he,{children:t.jsx(a.Suspense,{fallback:t.jsx(Je,{loading:!0,message:"Loading..."}),children:t.jsx(Ro,{mode:"editor-only"})})})})]});const B=o.directory===r?"Project files":Ue(o.directory),g=k.trim()?P:[],I=No(o.directory,r)?cs(o.directory):null,w=!!I&&!k.trim(),E=I===r?"Project files":Ue(I??"");return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-transparent text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-1 px-2 text-foreground",children:[e?t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":"Close",onClick:e,style:{touchAction:"manipulation"},children:t.jsx(oa,{className:"size-4"})}):null,w&&I?t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":`Back to ${Ue(I)}`,onClick:()=>$(I),style:{touchAction:"manipulation"},children:t.jsx(Zt,{className:"size-4"})}):null,t.jsx("div",{className:"min-w-0 flex-1 px-1",children:t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:B})}),t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":"Refresh files",onClick:()=>{L(o.directory)},style:{touchAction:"manipulation"},children:t.jsx(ia,{className:K("size-4",u&&"animate-spin")})})]}),t.jsx("div",{className:"shrink-0 px-3 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(la,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(Sr,{value:k,onChange:h=>N(h.target.value),placeholder:"Search files",className:"h-11 pl-9"})]})}),t.jsx(At,{className:"min-h-0 w-full flex-1 overflow-y-auto pb-3",children:p?t.jsx(Je,{message:p}):k.trim()?t.jsx(Io,{results:g,isSearching:U,onOpenFile:b}):t.jsxs("div",{className:"flex w-full min-w-0 flex-col",children:[w&&I?t.jsxs("button",{type:"button",className:Bn,"aria-label":`Up one level to ${E}`,onClick:()=>$(I),style:{touchAction:"manipulation"},children:[t.jsx(V,{name:"arrow-left",className:K(Nt(!0),"text-muted-foreground")}),t.jsx("span",{className:K(Fn(!0),"flex-1 text-muted-foreground"),children:"Up one level"})]}):null,l.length===0&&!u?t.jsx("div",{className:"px-3 py-8 text-center typography-ui-label text-muted-foreground",children:"This directory is empty."}):null,l.map(h=>t.jsx(us,{name:h.name,path:h.path,directory:h.isDirectory,meta:h.isDirectory?void 0:Po(h.size),onClick:()=>h.isDirectory?$(xn(h.path,o.directory||r)):b(xn(h.path,o.directory||r))},h.path))]})})]})},us=({name:e,path:n,directory:s,meta:r,onClick:o})=>t.jsxs("button",{type:"button",className:Bn,onClick:o,style:{touchAction:"manipulation"},children:[s?t.jsx(da,{className:K(Nt(!0),"text-primary/80")}):t.jsx($n,{filePath:n,className:Nt(!0)}),t.jsx("span",{className:K(Fn(!0),"flex-1 text-foreground"),children:e}),r?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:r}):null,s?t.jsx(fa,{className:"size-4 shrink-0 text-muted-foreground/60"}):null]}),Io=({results:e,isSearching:n,onOpenFile:s})=>{const r=fe(It()??null);return n?t.jsx(Je,{loading:!0,message:"Loading..."}):e.length===0?t.jsx(Je,{message:"No files found."}):t.jsx("div",{className:"flex w-full min-w-0 flex-col",children:e.map(o=>t.jsx(us,{name:Ue(o.path),path:o.path,directory:!1,meta:To(o.path,r),onClick:()=>s(o.path)},o.path))})},Je=({message:e,loading:n=!1})=>t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[n?t.jsx(ca,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(ua,{className:"size-6 text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:e})]})}),vn="mobile-surface-root",Do=16,Lo=[{id:"changes",label:"Changes",icon:"git-branch"},{id:"files",label:"Files",icon:"file-text"},{id:"terminal",label:"Terminal",icon:"terminal"},{id:"notes",label:"Notes",icon:"sticky-note"}],wn=a.memo(function({open:n,onClose:s,tab:r,onTabChange:o,pendingChangesDiff:i,variant:l="drawer",drawerRefExternal:c,scrimRefExternal:u,rootRefExternal:d}){const p=a.useRef(null),x=a.useRef(null),k=a.useRef(null),N=a.useRef(null),P=c??x,R=u??k,U=d??N,F=a.useCallback(E=>{N.current=E,d&&(d.current=E)},[d]),m=a.useCallback(()=>{const E=typeof document<"u"?document.activeElement:null;E instanceof HTMLElement&&U.current?.contains(E)&&E.blur(),s()},[s]),[v,L]=a.useState(!1),[$,b]=a.useState(n),S=a.useMemo(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[]),[y,B]=a.useState(()=>new Set);if(a.useEffect(()=>{n&&B(E=>{if(E.has(r))return E;const h=new Set(E);return h.add(r),h})},[n,r]),typeof document<"u"&&!p.current){let E=document.getElementById(vn);E||(E=document.createElement("div"),E.id=vn,document.body.appendChild(E)),p.current=E}if(a.useEffect(()=>{if(n){b(!0);const h=window.setTimeout(()=>L(!0),S?0:Do);return()=>window.clearTimeout(h)}L(!1);const E=window.setTimeout(()=>b(!1),Ve+40);return()=>window.clearTimeout(E)},[n,S]),a.useEffect(()=>{if(!n)return;const E=document.body.style.overflow;l==="drawer"&&(document.body.style.overflow="hidden");const h=C=>{C.key==="Escape"&&r!=="terminal"&&m()};return document.addEventListener("keydown",h),()=>{l==="drawer"&&(document.body.style.overflow=E),document.removeEventListener("keydown",h)}},[m,n,r,l]),a.useEffect(()=>{const E=U.current;if(!E||n||l!=="drawer")return;const h=document.activeElement;h&&E.contains(h)&&h.blur()},[n,l]),os({side:"right",enabled:l==="drawer",open:n,drawerRef:P,scrimRef:R,onClose:m,widthRatio:1,prefersReducedMotion:S}),l==="drawer"&&!p.current)return null;const g=S?0:Ve,I=t.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto",role:"tablist","aria-label":"Workspace","data-no-drawer-swipe":"true",children:Lo.map(E=>{const h=r===E.id;return t.jsxs("button",{type:"button",role:"tab","aria-selected":h,onClick:()=>o(E.id),className:K("flex min-w-0 flex-1 items-center justify-center gap-1 rounded-lg px-1.5 py-2 typography-ui-label transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",h?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[t.jsx(V,{name:E.icon,className:"size-4 shrink-0"}),t.jsx("span",{className:"truncate",children:E.label})]},E.id)})}),w=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-2",children:[I,t.jsx("button",{type:"button",onClick:m,"aria-label":"Close workspace panel",className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:t.jsx(V,{name:"close",className:"size-4"})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[y.has("changes")?t.jsx("div",{className:K("h-full",r!=="changes"&&"hidden"),children:t.jsx(he,{children:t.jsx(Co,{initialDiffPath:i?.path??null,initialDiffStaged:i?.staged===!0})})},i?`changes:${i.path}:${i.staged}`:"changes"):null,y.has("files")?t.jsx("div",{className:K("h-full",r!=="files"&&"hidden"),children:t.jsx(he,{children:t.jsx(Ao,{})})}):null,y.has("terminal")?t.jsx("div",{className:K("h-full",r!=="terminal"&&"hidden"),children:t.jsx(he,{children:t.jsx(Ls,{visible:n&&r==="terminal"})})}):null,y.has("notes")?t.jsx("div",{className:K("h-full",r!=="notes"&&"hidden"),children:t.jsx(he,{children:t.jsx(_s,{onActionComplete:m})})}):null]})]});return l==="panel"?t.jsx("div",{className:"flex h-full min-h-0 flex-col bg-sidebar",children:w}):Fe.createPortal(t.jsxs("div",{ref:F,className:"fixed inset-0 z-50",inert:!n,style:{pointerEvents:n?"auto":"none",visibility:$?"visible":"hidden"},"data-mobile-workspace-root":"true",children:[t.jsx("button",{ref:R,type:"button",className:"absolute inset-0 cursor-default bg-black/70","aria-label":"Close workspace panel",onClick:m,tabIndex:n?0:-1,style:{opacity:v?1:0,transition:g?`opacity ${g}ms ${Re}`:"none"},"data-mobile-workspace-scrim":"true"}),t.jsx("section",{ref:P,role:"dialog","aria-modal":"true","aria-label":"Open workspace panel",className:"oc-keyboard-inset-surface absolute inset-y-0 right-0 z-10 flex h-full w-full flex-col bg-sidebar",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:v?"none":"translateX(100%)",transition:g?`transform ${g}ms ${Re}`:"none",touchAction:"pan-x pan-y"},"data-mobile-workspace-drawer":"true",children:w})]}),p.current)}),nt=()=>typeof window>"u"?!1:window.Capacitor?.isNativePlatform?.()===!0?!0:window.location.protocol==="capacitor:",_o=()=>{a.useEffect(()=>{if(!nt())return;let e=!1;const n=[],s=document.documentElement;s.classList.add("oc-capacitor-app"),window.Capacitor?.getPlatform?.()==="android"&&s.classList.add("oc-platform-android"),n.push(Cr());const o=i=>{s.style.setProperty("--oc-keyboard-inset",`${Math.max(0,Math.round(i))}px`)};return be(()=>import("./vendor-capacitor-status-bar-B-N0EOVk.js"),__vite__mapDeps([127,128])).then(async({StatusBar:i,Style:l})=>{if(e)return;const c=window.Capacitor?.getPlatform?.(),u=async()=>{if(c==="android"){const k=document.documentElement.classList.contains("dark"),N=(k?localStorage.getItem("splashBgDark"):localStorage.getItem("splashBgLight"))||(k?"#171515":"#fffdf4");await i.setOverlaysWebView({overlay:!1}).catch(()=>{}),await i.setBackgroundColor({color:N}).catch(()=>{}),await i.setStyle({style:k?l.Dark:l.Light}).catch(()=>{}),await i.show().catch(()=>{});return}await i.setStyle({style:l.Default}).catch(()=>{}),await i.setOverlaysWebView({overlay:!0}).catch(()=>{}),await i.show().catch(()=>{})};await u();const d=window.setTimeout(()=>{u()},400);n.push(()=>window.clearTimeout(d));const{App:p}=await be(async()=>{const{App:k}=await import("./vendor-capacitor-app-BrDJj9I_.js");return{App:k}},__vite__mapDeps([129,8,128])),x=await p.addListener("appStateChange",({isActive:k})=>{k&&u()});if(e){x.remove();return}n.push(()=>{x.remove()})}).catch(()=>{}),be(()=>import("./vendor-capacitor-keyboard-CYccoJjr.js"),__vite__mapDeps([130,128])).then(async({Keyboard:i})=>{if(e)return;if(window.Capacitor?.getPlatform?.()==="android"){const g=await i.addListener("keyboardWillShow",C=>{Qt(C.keyboardHeight),s.classList.add("oc-keyboard-open"),window.dispatchEvent(new CustomEvent("oc:keyboard-settled",{detail:{open:!0}}))}),I=await i.addListener("keyboardDidShow",()=>{window.dispatchEvent(new CustomEvent("oc:keyboard-settled",{detail:{open:!0}}))}),w=await i.addListener("keyboardWillHide",()=>{window.dispatchEvent(new CustomEvent("oc:keyboard-intent",{detail:{open:!1}})),s.classList.remove("oc-keyboard-open")}),E=await i.addListener("keyboardDidHide",()=>{window.dispatchEvent(new CustomEvent("oc:keyboard-settled",{detail:{open:!1}}))}),h=()=>{g.remove(),I.remove(),w.remove(),E.remove()};if(e){h();return}n.push(h);return}await i.setAccessoryBarVisible({isVisible:!1}).catch(()=>{});const c=250,u=200,d="cubic-bezier(0.38, 0.7, 0.125, 1)";let p=null,x=null,k=0,N=!1,P=0,R=!1;const U=(g,I)=>{s.style.setProperty(g,`${Math.max(0,Math.round(I))}px`)},F=()=>{p!==null&&(window.clearTimeout(p),p=null)},m=(g,I)=>{window.dispatchEvent(new CustomEvent(g,{detail:I}))},v=()=>{const g=[],I=document.querySelector(".oc-mobile-composer");I&&g.push({el:I,factor:1});const w=document.querySelector(".oc-draft-center");return w&&g.push({el:w,factor:.5}),g},L=()=>{for(const{el:g}of v())g.style.transition="",g.style.transform=""},$=await i.addListener("keyboardWillShow",g=>{if(F(),Qt(g.keyboardHeight),R=!0,k=g.keyboardHeight,!N){const w=document.querySelector(".oc-mobile-app-shell");P=w&&parseFloat(getComputedStyle(w).paddingBottom)||0}const I=Math.max(0,k-P);s.classList.remove("oc-kb-hide"),x!==null&&(window.clearTimeout(x),x=null),s.classList.add("oc-keyboard-open","oc-kb-animating","oc-kb-caret-hold"),o(k);for(const{el:w,factor:E}of v())w.style.transition=`transform ${c}ms ${d}`,w.style.transform=`translateY(${-I*E}px)`;U("--oc-kb-scroll-inset",I),m("oc:keyboard-settled",{open:!0}),m("oc:keyboard-anim",{phase:"show",slide:I,durationMs:c,easing:d}),p=window.setTimeout(()=>{p=null,s.classList.remove("oc-kb-animating"),U("--oc-kb-layout",k),N=!0,L(),m("oc:keyboard-settled",{open:!0}),x=window.setTimeout(()=>{x=null,s.classList.remove("oc-kb-caret-hold")},250)},c+20)}),b=()=>{if(!R)return;R=!1,F(),m("oc:keyboard-intent",{open:!1}),x!==null&&(window.clearTimeout(x),x=null),s.classList.remove("oc-kb-caret-hold");const g=Math.max(0,k-P);if(s.classList.remove("oc-keyboard-open"),o(0),U("--oc-kb-scroll-inset",0),N){s.classList.remove("oc-kb-animating"),U("--oc-kb-layout",0),N=!1;for(const{el:I,factor:w}of v())I.style.transition="none",I.style.transform=`translateY(${-g*w}px)`;document.querySelector(".oc-mobile-app-shell")?.offsetHeight}m("oc:keyboard-anim",{phase:"hide",slide:g,durationMs:u,easing:d}),s.classList.add("oc-kb-animating","oc-kb-hide");for(const{el:I}of v())I.style.transition=`transform ${u}ms ${d}`,I.style.transform="translateY(0px)";p=window.setTimeout(()=>{p=null,s.classList.remove("oc-kb-animating","oc-kb-hide"),L(),m("oc:keyboard-settled",{open:!1})},u+20)},S=await i.addListener("keyboardWillHide",b),y=g=>g instanceof HTMLElement&&(g.tagName==="TEXTAREA"||g.tagName==="INPUT"||g.isContentEditable),B=g=>{R&&y(g.target)&&(y(g.relatedTarget)||window.setTimeout(()=>{R&&(y(document.activeElement)||b())},0))};if(document.addEventListener("focusout",B,!0),e){F(),document.removeEventListener("focusout",B,!0),$.remove(),S.remove();return}n.push(F,()=>{x!==null&&(window.clearTimeout(x),x=null)},()=>document.removeEventListener("focusout",B,!0),()=>{$.remove()},()=>{S.remove()})}).catch(()=>{}),()=>{e=!0,n.forEach(i=>i()),Er(),s.classList.remove("oc-capacitor-app","oc-keyboard-open","oc-kb-animating","oc-kb-hide","oc-kb-caret-hold","oc-platform-android"),s.style.removeProperty("--oc-keyboard-inset"),s.style.removeProperty("--oc-kb-shift"),s.style.removeProperty("--oc-kb-layout"),s.style.removeProperty("--oc-kb-scroll-inset")}},[])},Mo=e=>{const n=a.useRef(!1);a.useEffect(()=>{if(!nt())return;let s=!1;const r=[],o=()=>{n.current&&(n.current=!1,e())},i=()=>{if(document.visibilityState==="hidden"){n.current=!0;return}o()};return document.addEventListener("visibilitychange",i),r.push(()=>document.removeEventListener("visibilitychange",i)),be(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([129,8,128])).then(async({App:l})=>{if(s)return;const c=await l.addListener("appStateChange",({isActive:d})=>{if(document.documentElement.classList.toggle("oc-native-app-active",d),!d){n.current=!0;return}o()}),u=await l.addListener("resume",o);if(s){c.remove(),u.remove();return}r.push(()=>{c.remove()},()=>{u.remove()})}).catch(()=>{}),()=>{s=!0,r.forEach(l=>l())}},[e])},zo=e=>{a.useEffect(()=>{if(!nt())return;let n=!1,s=null;return be(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([129,8,128])).then(async({App:r})=>{if(n)return;const o=await r.addListener("backButton",()=>{e()||r.minimizeApp().catch(()=>{})});if(n){o.remove();return}s=()=>{o.remove()}}).catch(()=>{}),()=>{n=!0,s?.()}},[e])};function Oo(e=2500){const{uiFont:n}=Nr(),[s,r]=a.useState(!1);return a.useEffect(()=>{let o=!1;const i=()=>{o||r(!0)},l=()=>{requestAnimationFrame(()=>requestAnimationFrame(i))},c=Promise.all([Rr(n).catch(()=>{}),document.fonts?.ready?.then(()=>{}).catch(()=>{})??Promise.resolve(),ma.catch(()=>{})]).then(()=>{}),u=new Promise(d=>{window.setTimeout(d,e)});return Promise.race([c,u]).then(l),()=>{o=!0}},[n,e]),s}const $o="pichamber",Uo=e=>e.replace(/^\/+|\/+$/g,""),Bo=e=>{const n=Uo(e.pathname).split("/").filter(Boolean);return e.host?[e.host,...n]:n};function Fo(e){if(typeof e!="string"||e.length===0)return null;let n;try{n=new URL(e)}catch{return null}if(n.protocol!==`${$o}:`)return null;const s=Bo(n),r=(s[0]??"").toLowerCase(),o=s.slice(1),i=n.searchParams;switch(r){case"session":{const l=o[0]||i.get("id")||"";return l?{type:"session",sessionId:l,directory:i.get("dir")??void 0}:null}case"new":case"new-session":return{type:"new-session",directory:i.get("dir")??void 0,projectId:i.get("project")??void 0,agent:i.get("agent")??void 0,model:i.get("model")??void 0};case"sessions":{const l=i.get("filter");return{type:"sessions",filter:l==="attention"||l==="recent"||l==="all"?l:void 0}}case"status":return{type:"status"};case"settings":return{type:"settings",section:o[0]||i.get("section")||void 0};case"changes":return{type:"changes",path:o.join("/")||i.get("path")||void 0,staged:i.get("staged")==="true"};case"view":{const l=(o[0]||"").toLowerCase();return l==="changes"?{type:"changes"}:l==="files"||l==="mcp"||l==="instances"||l==="update"?{type:"view",target:l}:null}default:return null}}let pe={},ds=!1,Ye=null;const Ho=e=>{switch(e.type){case"session":return ge.getState().setCurrentSession(e.sessionId,e.directory??null),!0;case"new-session":{const n=ge.getState();return n.openNewSessionDraft(),(e.directory||e.projectId)&&n.setNewSessionDraftTarget({directoryOverride:e.directory??null,projectId:e.projectId??null,selectedProjectId:e.projectId??null}),!0}case"sessions":return pe.openSessions?(pe.openSessions(e.filter),!0):!1;case"status":return pe.openSessions?(pe.openSessions(),!0):!1;case"view":return pe.openView?(pe.openView(e.target),!0):!1;case"changes":return pe.openChanges?(pe.openChanges({path:e.path,staged:e.staged}),!0):!1;case"settings":return pe.openSettings?(pe.openSettings(e.section),!0):!1}},$t=()=>{if(!ds||!Ye)return;const e=Ye;Ye=null,Ho(e)||(Ye=e)},fs=e=>{Ye=e,$t()},kn=e=>{const n=Fo(e);n&&fs(n)},Wo=e=>{ds=e,$t()},Vo=e=>{a.useEffect(()=>(pe=e,$t(),()=>{pe===e&&(pe={})}),[e])},Ko=e=>{const{ready:n}=e;a.useEffect(()=>{Wo(n)},[n]),a.useEffect(()=>{if(!le())return;let s=!1;const r=[];return be(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([129,8,128])).then(async({App:o})=>{if(s)return;const i=await o.addListener("appUrlOpen",l=>{kn(l?.url)});if(s){i.remove();return}r.push(()=>{i.remove()})}).catch(()=>{}),be(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([131,128])).then(async({PushNotifications:o})=>{if(s)return;const i=await o.addListener("pushNotificationActionPerformed",l=>{const c=l?.notification?.data,u=typeof c?.url=="string"?c.url:typeof c?.deeplink=="string"?c.deeplink:void 0;if(u){kn(u);return}const d=typeof c?.sessionId=="string"?c.sessionId:void 0;d&&fs({type:"session",sessionId:d})});if(s){i.remove();return}r.push(()=>{i.remove()})}).catch(()=>{}),()=>{s=!0,r.forEach(o=>o())}},[])},jn=e=>{const n=e.drawer.current,s=e.scrim.current,r=e.root.current;r&&(r.style.pointerEvents="auto",r.style.visibility="visible"),n&&(n.style.transition="none"),s&&(s.style.transition="none")},Sn=(e,n,s)=>{const r=e.drawer.current,o=e.scrim.current;if(r&&(r.style.transform=s>=.999?"none":`translateX(${(n==="left"?s-1:1-s)*100}%)`),o){o.style.opacity=String(s);const i=s>.01?"auto":"none";o.style.pointerEvents!==i&&(o.style.pointerEvents=i)}},Cn=(e,n,s)=>{const r=s.drawer.current,o=s.scrim.current,i=s.root.current;r&&(r.style.transition=`transform ${Ve}ms ${Re}`,r.style.transform=n?"none":e==="left"?"translateX(-100%)":"translateX(100%)"),o&&(o.style.transition=`opacity ${Ve}ms ${Re}`,o.style.opacity=n?"1":"0",o.style.pointerEvents=n?"auto":"none"),i&&(i.style.pointerEvents=n?"auto":"none",i.style.visibility=n?"visible":"")},En=e=>{const n=e.shell.current,s=e.inner.current;n&&(n.style.overflow="visible"),s&&(s.style.transition="none")},Nn=(e,n,s,r)=>{const o=e.inner.current;if(!o)return;const i=r==="left"?(n-1)*s:(1-n)*s;o.style.transform=n>=.999?"translateX(0)":`translateX(${i}px)`},Rn=(e,n,s,r,o)=>{const i=e.shell.current,l=e.inner.current;return!i||!l?void 0:(l.style.transition="transform 200ms cubic-bezier(0.22, 1, 0.36, 1)",l.style.transform=n?"translateX(0)":`translateX(${r==="left"?-s:s}px)`,window.setTimeout(()=>{l.style.transition="",l.style.transform="",i.style.overflow=""},220))},Go=()=>{if(typeof window>"u")return;const e=window.__PICHAMBER_APNS_ENV__;if(e==="development")return"sandbox";if(e==="production")return"production"},Xo=()=>{if(typeof window>"u")return!1;const n=window.Capacitor?.getPlatform?.();return n==="ios"||n==="android"},qo=e=>{const{enabled:n}=e,s=de(o=>o.nativeNotificationsEnabled),r=a.useRef(null);a.useEffect(()=>{if(!n||!s||!Xo())return;let o=!1;const i=[];return be(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([131,128])).then(async({PushNotifications:l})=>{if(o)return;let c=await l.checkPermissions().catch(()=>null);if(c?.receive!=="granted"&&(c=await l.requestPermissions().catch(()=>null)),c?.receive!=="granted")return;const u=await l.addListener("registration",p=>{r.current=p.value,Et()?.push?.registerApnsToken?.({token:p.value,platform:In(),environment:Go()})}),d=await l.addListener("registrationError",p=>{console.warn("[Push] APNs registration error:",p)});if(await l.register().catch(()=>{}),o){u.remove(),d.remove();return}i.push(()=>{u.remove()},()=>{d.remove()})}).catch(()=>{}),()=>{o=!0,i.forEach(l=>l())}},[n,s]),a.useEffect(()=>{if(s)return;const o=r.current;if(!o)return;r.current=null,Et()?.push?.unregisterApnsToken?.({token:o})},[s])},Tn=({side:e,isResizing:n,ariaLabel:s,handleProps:r})=>t.jsx("div",{className:K("absolute inset-y-0 z-50 w-6 cursor-col-resize touch-none",e==="left"?"right-0":"left-0"),role:"separator","aria-orientation":"vertical","aria-label":s,...r,children:t.jsx("div",{className:K("absolute inset-y-0 w-[3px] transition-colors",e==="left"?"right-0":"left-0",n&&"bg-[var(--interactive-border)]")})}),Yo=320,Jo=380,Pn=280,Qo=560,Zo=900;function An(e,n,s,r=Qo){const o=a.useRef(null),[i,l]=a.useState(()=>{if(typeof window>"u")return s;const v=Number.parseInt(window.localStorage.getItem(n)??"",10);return Number.isFinite(v)?Math.min(r,Math.max(Pn,v)):s}),[c,u]=a.useState(!1),d=a.useRef(0),p=a.useRef(i),x=a.useRef(null),k=a.useRef(null),N=a.useCallback(v=>Math.min(r,Math.max(Pn,Math.round(v))),[r]),P=a.useCallback(v=>{const L=o.current;L&&(L.style.width=`${v}px`,L.style.minWidth=`${v}px`,L.style.maxWidth=`${v}px`,L.style.setProperty("--oc-ipad-sidebar-width",`${v}px`))},[]),R=a.useCallback(v=>{try{v.currentTarget.setPointerCapture(v.pointerId)}catch{}k.current=v.pointerId,d.current=v.clientX,p.current=i,x.current=i,u(!0),v.preventDefault()},[i]),U=a.useCallback(v=>{if(k.current!==v.pointerId)return;const L=v.clientX-d.current,$=N(p.current+(e==="left"?L:-L));x.current!==$&&(x.current=$,P($))},[P,N,e]),F=a.useCallback(v=>{if(k.current!==v.pointerId)return;try{v.currentTarget.releasePointerCapture(v.pointerId)}catch{}const L=N(x.current??p.current);k.current=null,x.current=null,u(!1),l(L);try{window.localStorage.setItem(n,String(L))}catch{}},[N,n]),m=a.useMemo(()=>({onPointerDown:R,onPointerMove:U,onPointerUp:F,onPointerCancel:F}),[R,F,U]);return{asideRef:o,width:i,isResizing:c,handleProps:m}}const ei=1e3,ti=a.memo(Gs),ni=({onActiveConnectionDeleted:e})=>{const[n,s]=a.useState(!1),[r,o]=a.useState(null),[i,l]=a.useState(!1),[c,u]=a.useState("changes"),[d,p]=a.useState("nav"),[x,k]=a.useState(null),N=a.useRef([]),P=a.useCallback(()=>{N.current.forEach(D=>window.clearTimeout(D)),N.current=[]},[]);a.useEffect(()=>()=>P(),[P]);const R=a.useRef(null),U=a.useRef(null),F=a.useRef(null),m=a.useRef(null),v=a.useRef(null),L=a.useRef(null),$=a.useRef(null),b=a.useRef(null),S=a.useRef(0),y=a.useRef(0),B=a.useCallback(D=>{P(),s(D)},[P]),g=a.useCallback(D=>{P(),l(D)},[P]),I=de(D=>D.setSettingsPage),w=de(D=>D.isArchivePageOpen),E=de(D=>D.setArchivePageOpen),h=de(D=>D.wideChatLayoutEnabled),C=$e(D=>D.available),O=$e(D=>D.runtimeType),q=a.useMemo(()=>nt(),[]),Z=!q&&C&&(O==="desktop"||O==="web"),X=a.useCallback(()=>{o(null)},[]),A=a.useCallback(D=>{o(D)},[]),G=a.useCallback(()=>{g(!1)},[g]),Y=a.useCallback(D=>{p(D),A("settings")},[A]),{enabled:f,roomyForPanels:j}=On(),H=Fr()==="portrait",te=Hr(),J=de(D=>D.setSidebarOpen),ae=de(D=>D.isSidebarOpen),Te=a.useRef(!1);a.useLayoutEffect(()=>{f&&!Te.current&&J(Wr().roomyForPanels),!f&&Te.current&&J(!1),Te.current=f},[f,J]);const ue=a.useCallback(()=>{k(null),u("files"),g(!0)},[g]),ye=a.useCallback((D=null)=>{k(D),u("changes"),g(!0)},[g]),se=An("left","pichamber.ipad.leftSidebarWidth",Yo),z=An("right","pichamber.ipad.rightSidebarWidth",Jo,Zo),Q=j,ne=Q&&i?z.width:0,we=Fs(f&&ae),xe=f&&ae?se.width:0,Pe=a.useCallback(D=>{i&&c===D?g(!1):(u(D),g(!0))},[i,c,g]),st=a.useCallback(()=>{g(!i)},[i,g]),bt=a.useCallback(D=>{!D&&!j&&J(!1)},[j,J]);a.useEffect(()=>{if(typeof document>"u")return;const D=document.documentElement;return D.style.setProperty("--oc-chat-inset-left",`${xe}px`),D.style.setProperty("--oc-chat-inset-right",`${ne}px`),()=>{D.style.removeProperty("--oc-chat-inset-left"),D.style.removeProperty("--oc-chat-inset-right")}},[xe,ne]),a.useEffect(()=>{if(typeof document>"u")return;const D=document.documentElement;return D.classList.toggle("wide-chat-layout",h),()=>D.classList.remove("wide-chat-layout")},[h]),a.useEffect(()=>{if(typeof document>"u")return;const D=f&&(H||te),me=document.documentElement;return me.classList.toggle("oc-keep-draft-starters",D),()=>me.classList.remove("oc-keep-draft-starters")},[te,f,H]);const Ge=a.useMemo(()=>({openChanges:({diffPath:D,staged:me}={})=>{ye(D?{path:D,staged:me===!0}:null)},openFiles:()=>ue(),openSettings:()=>Y("nav"),openInstances:q?()=>A("instances"):void 0,instanceLabel:q?Xe():null,openUpdate:Z?()=>A("update"):void 0}),[ye,ue,Y,A,q,Z]),T=a.useMemo(()=>({openSessions:()=>{f?J(!0):B(!0)},openView:D=>{if(D==="files"){ue();return}(D==="instances"||D==="update"||D==="mcp")&&A(D)},openChanges:({path:D,staged:me}={})=>{ye(D?{path:D,staged:me===!0}:null)},openSettings:D=>{D&&I(D),Y(D?"page-content":"nav")}}),[f,ye,ue,Y,A,I,B,J]);Vo(T);const M=a.useRef(null);Hs(M,{leftOpen:f?ae:n,rightOpen:i,leftWidth:()=>f?se.width:R.current?.offsetWidth||window.innerWidth*.72,rightWidth:()=>f?z.width:m.current?.offsetWidth||window.innerWidth,onLeftProgress:D=>{if(S.current=D,f){Nn({inner:$},D,se.width,"left");return}Sn({drawer:R,scrim:U},"left",D)},onRightProgress:D=>{if(y.current=D,f&&j){Nn({inner:b},D,z.width,"right");return}Sn({drawer:m,scrim:v},"right",D)},onLeftOpen:()=>{f?J(!0):B(!0)},onLeftClose:()=>{f?J(!1):B(!1)},onRightOpen:()=>g(!0),onRightClose:()=>g(!1),onDragStart:D=>{if(P(),D==="left"){S.current=f?ae?1:0:n?1:0,f?En({shell:se.asideRef,inner:$}):jn({drawer:R,scrim:U,root:F});return}y.current=i?1:0,f&&j?En({shell:z.asideRef,inner:b}):jn({drawer:m,scrim:v,root:L})},onDragEnd:(D,me)=>{if(D==="left"){const Ae=typeof me=="boolean"?me:S.current>.5;if(S.current=Ae?1:0,f){const at=Rn({shell:se.asideRef,inner:$},Ae,se.width,"left");at!==void 0&&N.current.push(at)}else Cn("left",Ae,{drawer:R,scrim:U,root:F});return}const rt=typeof me=="boolean"?me:y.current>.5;if(y.current=rt?1:0,f&&j){const Ae=Rn({shell:z.asideRef,inner:b},rt,z.width,"right");Ae!==void 0&&N.current.push(Ae)}else Cn("right",rt,{drawer:m,scrim:v,root:L})}});const W=a.useCallback(()=>w?(E(!1),!0):r?(X(),!0):i?(G(),!0):n?(B(!1),!0):!1,[r,X,G,w,n,E,B,i]);zo(W);const ee=f?"dialog":"fullscreen";return t.jsx(Vr,{actions:Ge,children:t.jsxs("div",{className:"oc-mobile-app-shell main-content-safe-area relative flex h-[100dvh] flex-row bg-background text-foreground","data-page-scroll-lock":"true",children:[f?t.jsxs("aside",{ref:se.asideRef,className:K("relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/70 bg-sidebar motion-reduce:transition-none",!ae&&"border-r-0"),style:{width:xe,minWidth:xe,maxWidth:xe,"--oc-ipad-sidebar-width":`${se.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)"},inert:!ae,"data-page-scroll-lock":"true",children:[t.jsx("div",{ref:$,className:K("flex h-full shrink-0 flex-col",se.isResizing&&"pointer-events-none",!ae&&"pointer-events-none select-none"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden",transform:se.isResizing||we.slidIn?"translateX(0)":"translateX(-100%)",transition:se.isResizing?"none":"transform 200ms cubic-bezier(0.22, 1, 0.36, 1)"},children:t.jsx(he,{children:t.jsx(fn,{open:ae,variant:"sidebar",onOpenChange:bt})})}),ae?t.jsx(Tn,{side:"left",isResizing:se.isResizing,ariaLabel:"Resize left panel",handleProps:se.handleProps}):null]}):null,t.jsxs("div",{className:"relative flex h-full min-w-0 flex-1 flex-col","data-page-scroll-lock":"true",children:[f?t.jsxs(t.Fragment,{children:[t.jsx(Ws,{}),t.jsx(Vs,{onToggleRightDrawer:st,rightDrawerOpen:i,tabletWorkspaceTab:c,onSelectTabletWorkspaceTab:Pe})]}):t.jsx(lo,{onOpenSessions:()=>B(!0),onOpenWorkspace:()=>g(!0)}),t.jsx("main",{ref:M,className:"relative min-h-0 flex-1 overflow-hidden","data-page-scroll-lock":"true",style:{touchAction:"pan-x pan-y"},children:t.jsx("div",{className:"h-full w-full",children:t.jsx(he,{children:t.jsx(ti,{})})})})]}),f?null:t.jsx(fn,{open:n,onOpenChange:B,drawerRefExternal:R,scrimRefExternal:U,rootRefExternal:F}),f?t.jsxs("aside",{ref:z.asideRef,className:K("relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/70 bg-background motion-reduce:transition-none",!ne&&"border-l-0"),style:{width:ne,minWidth:ne,maxWidth:ne,"--oc-ipad-sidebar-width":`${z.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)"},inert:!ne,"data-page-scroll-lock":"true",children:[t.jsx("div",{ref:b,className:K("flex h-full min-h-0 shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",z.isResizing&&"pointer-events-none",!ne&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden",transform:ne?"translateX(0)":"translateX(100%)",transition:z.isResizing?"none":"transform 200ms cubic-bezier(0.22, 1, 0.36, 1), opacity 200ms cubic-bezier(0.22, 1, 0.36, 1)"},children:t.jsx(he,{children:t.jsx(wn,{open:i,onClose:G,tab:c,onTabChange:u,pendingChangesDiff:x,variant:Q?"panel":"drawer",drawerRefExternal:m,scrimRefExternal:v,rootRefExternal:L})})}),ne?t.jsx(Tn,{side:"right",isResizing:z.isResizing,ariaLabel:"Resize right panel",handleProps:z.handleProps}):null]}):t.jsx(wn,{open:i,onClose:G,tab:c,onTabChange:u,pendingChangesDiff:x,drawerRefExternal:m,scrimRefExternal:v,rootRefExternal:L}),r==="instances"&&q?t.jsx(jt,{open:!0,variant:ee,dialogAlign:"app",onClose:X,ariaLabel:"Instances",title:"Instances",children:t.jsx(co,{onConnect:X,onActiveConnectionDeleted:e})}):null,r==="settings"?t.jsx(jt,{open:!0,variant:ee,dialogAlign:"app",onClose:X,ariaLabel:"Settings",headerless:!0,children:t.jsx(he,{children:t.jsx(Zr,{forceMobile:!f,isWindowed:!0,initialMobileStage:d,onClose:X})})}):null,r==="update"?t.jsx(jt,{open:!0,variant:ee,dialogAlign:"app",onClose:X,ariaLabel:"Update",title:"Update",children:t.jsx(he,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(ea,{initialUpdateDialogOpen:!0})})})}):null,t.jsx(he,{children:t.jsx(Ks,{})})]})})};function si({apis:e}){const n=je(A=>A.initializeApp),s=je(A=>A.isInitialized),r=je(A=>A.isConnected),o=je(A=>A.connectionPhase),i=je(A=>A.providers.length),l=je(A=>A.agents.length),c=je(A=>A.loadProviders),u=je(A=>A.loadAgents),d=_n(A=>A.currentDirectory),p=ge(A=>A.error),x=ge(A=>A.clearError),k=de(A=>A.setIsMobile),N=Tr(A=>A.refreshStatus),[P,R]=a.useState(0),[U,F]=a.useState(0),[m,v]=a.useState(!1),[L,$]=a.useState("pending"),[b,S]=a.useState(null),y=a.useMemo(()=>Xe(),[]),[,B]=a.useReducer(A=>A+1,0),g=a.useMemo(()=>nt(),[]),I=a.useRef(0),w=a.useRef(0),E=a.useCallback(()=>{const A=Se(),G=w.current+1;if(w.current=G,!A){vt();return}const Y=()=>{n(),N(e.github,{force:!0}),i===0&&c({source:"mobileApp:nativeResume"}),l===0&&u({source:"mobileApp:nativeResume"})},f=()=>{Oe({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),R(_=>_+1)};ct().then(_=>{if(w.current===G){if(_==="no-connection"){f();return}if(_==="needs-login"){S({kind:"auth-expired",label:Xe()??""}),f();return}if(_==="unreachable"){window.setTimeout(()=>{w.current===G&&ct().then(H=>{if(w.current===G&&H!=="switched"){if(H==="unchanged"){Y();return}H==="needs-login"&&S({kind:"auth-expired",label:Xe()??""}),f()}})},4e3);return}_!=="switched"&&Y()}});const j=Date.now();j-I.current>=ei&&(I.current=j,window.dispatchEvent(new Event("pichamber:system-resume")))},[l,e.github,n,u,c,i,N]);_o(),Mo(E),a.useEffect(()=>bs(),[]),a.useEffect(()=>{if(!g)return;let A;const G=()=>{window.clearTimeout(A),A=window.setTimeout(()=>E(),1500)};return window.addEventListener("online",G),()=>{window.removeEventListener("online",G),window.clearTimeout(A)}},[g,E]),a.useEffect(()=>(Bt(e),()=>Bt(null)),[e]),a.useEffect(()=>xs(A=>{if(!!A.runtimeKey&&A.runtimeKey===A.previousRuntimeKey){Ms(),B();return}zs(A),F(Y=>Y+1),R(Y=>Y+1)}),[]),a.useEffect(()=>{Mn()},[U]),a.useEffect(()=>{if(!g||r||Se()){$("done");return}let A=!1;return $("attempting"),vt().catch(()=>({status:"no-candidate"})).then(G=>{A||(G.status==="unreachable"?S({kind:"unreachable",label:G.label}):G.status==="needs-login"&&S({kind:"auth-expired",label:G.label}),$("done"))}),()=>{A=!0}},[]),a.useEffect(()=>{if(!g||!Se())return;let A=!1;const G=Y=>{Y&&S(Y),Oe({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),R(f=>f+1)};return ct().then(async Y=>{if(A||Y==="switched"||Y==="unchanged")return;const f=Xe();if(Y==="needs-login"){G({kind:"auth-expired",label:f??""});return}if(Y==="unreachable"){G(f?{kind:"unreachable",label:f}:null);return}const j=await vt().catch(()=>({status:"no-candidate"}));A||j.status==="connected"||(j.status==="needs-login"?G({kind:"auth-expired",label:j.label}):j.status==="unreachable"?G({kind:"unreachable",label:j.label}):G(null))}),()=>{A=!0}},[]),a.useEffect(()=>{k(!0)},[k]),a.useEffect(()=>{g&&!Se()||n()},[P,n,g]),a.useEffect(()=>{r&&(i===0&&c({source:"mobileApp:recovery"}),l===0&&u({source:"mobileApp:recovery"}))},[l,r,u,c,i]);const h=a.useRef(!1),[C,O]=a.useState(g);a.useEffect(()=>{if(!g||!r||h.current)return;if(ge.getState().currentSessionId){h.current=!0,O(!1);return}const A=tt(),G=Pr(A);if(!G){h.current=!0,O(!1);return}let Y=!1;const f=window.setTimeout(()=>O(!1),6e3);return(async()=>{const j=await Ar().catch(()=>null);if(Y)return;if(!j){O(!1);return}h.current=!0;const _=j.activeSessions.find(te=>te.id===G.sessionId);if(!_){Ir(A),O(!1);return}const H=ge.getState();H.currentSessionId||H.setCurrentSession(_.id,Pt(_)??G.directory??void 0),O(!1)})(),()=>{Y=!0,window.clearTimeout(f)}},[P,r,g]),a.useEffect(()=>{r&&Dr.setDirectory(d)},[d,r]),a.useEffect(()=>{r&&N(e.github,{force:!0})},[e.github,r,N]),a.useEffect(()=>{if(!p)return;const A=window.setTimeout(()=>x(),5e3);return()=>window.clearTimeout(A)},[x,p]),a.useEffect(()=>{if(!(!r&&(g?!!Se():!0))){v(!1);return}const G=window.setTimeout(()=>{v(!0)},g?4e3:8e3);return()=>window.clearTimeout(G)},[r,g,P,U]),Lr(),ws({enabled:!0}),ks(),Os(),qo({enabled:g&&r}),Ko({ready:g&&r&&s});const q=Oo(),Z=!r&&o==="reconnecting";if(!q)return t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background text-foreground",children:t.jsx(Ce,{width:120,height:120,isAnimated:!0})});const X=!!Se();return g&&(!X||!r&&!Z)?X?t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-4",children:[t.jsx(Ce,{width:120,height:120,isAnimated:!m}),m?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:"Unable to reach server"}),t.jsx("p",{className:"typography-body text-muted-foreground",children:"Could not connect to the saved server. Check that it is running, or pick another instance."})]}),t.jsx(re,{type:"button",variant:"outline",onClick:()=>{Oe({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),R(A=>A+1)},children:"Use another server"})]}):null]})}):L!=="done"?t.jsxs("main",{className:"relative flex min-h-dvh items-center justify-center bg-background text-foreground",children:[t.jsx(Ce,{width:120,height:120,isAnimated:!0}),y?t.jsxs("div",{className:"absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center",children:[t.jsx("p",{className:"typography-small text-muted-foreground",children:"Connecting to device:"}),t.jsxs("p",{className:"typography-small text-foreground",children:[y,t.jsx(_r,{})]})]}):null]}):t.jsx(t.Fragment,{children:t.jsx(so,{onConnected:()=>R(A=>A+1),notice:b})}):!r&&!Z?m?t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground",children:t.jsxs("div",{className:"max-w-sm space-y-3",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:"Unable to reach server"}),t.jsx("p",{className:"typography-body text-muted-foreground",children:"We could not verify the UI session. If you're opening PiChamber from another device on your local network, make sure Desktop Network Access is enabled on the desktop app and use the LAN address shown in Settings."})]})}):t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background text-foreground",children:t.jsx(Ce,{width:120,height:120,isAnimated:!0})}):t.jsx(he,{children:t.jsx(Mr,{children:t.jsx(zr,{apis:e,children:t.jsx(Or,{delayDuration:300,skipDelayDuration:150,children:t.jsxs($s,{children:[t.jsx(Us,{}),t.jsxs("div",{className:"h-full bg-background text-foreground",children:[g&&C?t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background",children:t.jsx(Ce,{width:120,height:120,isAnimated:!0})}):null,t.jsx($r,{embeddedBackgroundWorkEnabled:s}),t.jsx(ka,{}),t.jsx(ni,{onActiveConnectionDeleted:()=>{Oe({apiBaseUrl:"",clientToken:null,runtimeKey:"mobile-disconnected"}),R(A=>A+1)}}),t.jsx(Bs,{}),t.jsx(Ur,{position:"top-center",offset:"calc(var(--oc-safe-area-top, 0px) + 16px)"}),t.jsx(Br,{}),s?t.jsx(Ea,{}):null]})]})})})},U)})}const ri=()=>{vs().then(()=>{Promise.all([Mn(),js()]).catch(e=>{console.error("[mobile-main] settings init failed:",e)}),Ss(),Cs(),Es()}).catch(e=>{console.error("[mobile-main] appearance init failed:",e)}).finally(()=>{pa()})};function wc(e){window.__PICHAMBER_SURFACE__="mobile",Kr(),ri(),wa(),Gr();const n=document.getElementById("root");if(!n)throw new Error("Root element not found");const r=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",o=e??Et();if(!o)throw new Error("Runtime APIs not registered");const i=r?{...o,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:o,l=t.jsx(si,{apis:i});ms.createRoot(n).render(t.jsx(De.StrictMode,{children:t.jsx(Xr,{children:t.jsx(qr,{children:t.jsx(Xs,{children:r?l:t.jsx(Yr,{children:l})})})})}))}export{wc as renderMobileApp};
@@ -1 +1 @@
1
- import{i,K as s}from"./index-BhXma4dv.js";const n="pichamber-mobile-layout",a=e=>e==="default"?"default":"new",c=()=>{if(typeof window>"u")return"new";try{return a(window.localStorage.getItem(n))}catch{return"new"}},l=e=>{if(typeof window>"u")return!1;try{return window.localStorage.setItem(n,e),!0}catch{return!1}},d=768,u=()=>{if(typeof window>"u")return!1;const e=typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)").matches||window.matchMedia("(hover: none)").matches:!1,t=typeof navigator<"u"?navigator.maxTouchPoints??0:0;return e||t>0},r=()=>{if(typeof window>"u")return"desktop";const e=window.__PICHAMBER_SURFACE__;if(e==="mobile"||e==="desktop")return e;const t=new URLSearchParams(window.location.search).get("surface");if(t==="mobile"||t==="desktop")return t;if(i())return"mobile";if(s())return"desktop";const o=Math.min(window.innerWidth||Number.POSITIVE_INFINITY,window.screen?.width||Number.POSITIVE_INFINITY);return Number.isFinite(o)&&o<=d&&u()&&c()==="new"?"mobile":"desktop"},m=()=>{const e=r();return typeof window<"u"&&(window.__PICHAMBER_SURFACE__=e),e},h=()=>r()==="mobile";export{c as g,h as i,m as r,l as s};
1
+ import{i,K as s}from"./index-CH7o4-_q.js";const n="pichamber-mobile-layout",a=e=>e==="default"?"default":"new",c=()=>{if(typeof window>"u")return"new";try{return a(window.localStorage.getItem(n))}catch{return"new"}},l=e=>{if(typeof window>"u")return!1;try{return window.localStorage.setItem(n,e),!0}catch{return!1}},d=768,u=()=>{if(typeof window>"u")return!1;const e=typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)").matches||window.matchMedia("(hover: none)").matches:!1,t=typeof navigator<"u"?navigator.maxTouchPoints??0:0;return e||t>0},r=()=>{if(typeof window>"u")return"desktop";const e=window.__PICHAMBER_SURFACE__;if(e==="mobile"||e==="desktop")return e;const t=new URLSearchParams(window.location.search).get("surface");if(t==="mobile"||t==="desktop")return t;if(i())return"mobile";if(s())return"desktop";const o=Math.min(window.innerWidth||Number.POSITIVE_INFINITY,window.screen?.width||Number.POSITIVE_INFINITY);return Number.isFinite(o)&&o<=d&&u()&&c()==="new"?"mobile":"desktop"},m=()=>{const e=r();return typeof window<"u"&&(window.__PICHAMBER_SURFACE__=e),e},h=()=>r()==="mobile";export{c as g,h as i,m as r,l as s};
@@ -1,2 +1,2 @@
1
- import{r as N,j as t,R as c}from"./vendor-react-DYyjh7Q0.js";import{bj as U,f as F,B as E,I as j,aw as H,ax as Q,ay as Z,aD as B,aW as ee,m as O,L as te,aR as R,eJ as se,eK as Y,t as ne}from"./SessionSwitcherDropdown-NbVfnqQQ.js";import{h as oe,i as re,j as ae,k as q,y as ie}from"./usePanelSlide-BRwyEEzi.js";import{C as ce,a as le,b as de}from"./collapsible-CPkWB1VR.js";import{a as me}from"./index-BhXma4dv.js";function Ce({draft:n,onEdit:a,onDelete:r,className:h,maxWidth:d}){const p=U()?.currentTheme,[m,w]=N.useState(!1),[I,f]=N.useState(!1),u=typeof n.text=="string"?n.text:"",i=u.length>150||u.split(`
2
- `).length>3;return t.jsxs(oe,{open:I,onOpenChange:f,children:[t.jsx(re,{render:t.jsx("div",{className:F("rounded-lg border shadow-none w-full max-w-[min(100%,calc(var(--oc-context-panel-width,100vw)-var(--oc-editor-gutter-width,0px)))] overflow-hidden transition-all duration-200",h),style:{backgroundColor:p?.colors?.surface?.elevated,borderColor:p?.colors?.interactive?.border,maxWidth:d?`${Math.max(200,Math.floor(d))}px`:void 0},"data-comment-card":"true",onContextMenu:b=>{b.preventDefault(),f(!0)}}),children:t.jsxs("div",{className:"flex items-start justify-between gap-2 p-3",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground mb-1.5",children:[t.jsx("span",{className:"truncate max-w-[200px]",title:n.fileLabel,children:n.fileLabel}),t.jsx("span",{children:"•"}),t.jsx("span",{children:`Lines ${n.startLine}-${n.endLine}`}),n.side&&t.jsxs("span",{children:["(",n.side,")"]})]}),t.jsxs(ce,{open:m||!i,onOpenChange:w,children:[t.jsx("div",{className:F("text-sm whitespace-pre-wrap break-words leading-relaxed",!m&&i&&"line-clamp-3"),children:u}),i&&t.jsx(le,{asChild:!0,children:t.jsx(E,{variant:"ghost",size:"sm",className:"h-6 px-0 mt-1 text-xs text-muted-foreground hover:text-foreground w-full justify-start",children:m?t.jsxs(t.Fragment,{children:[t.jsx(j,{name:"arrow-up-s",className:"size-3 mr-1"}),"Show less"]}):t.jsxs(t.Fragment,{children:[t.jsx(j,{name:"arrow-down-s",className:"size-3 mr-1"}),"Show more"]})})}),t.jsx(de,{})]})]}),t.jsxs(H,{children:[t.jsx(Q,{asChild:!0,children:t.jsx(E,{variant:"ghost",size:"icon",className:"h-6 w-6 -mr-1 text-muted-foreground hover:text-foreground",children:t.jsx(j,{name:"more",className:"size-4"})})}),t.jsxs(Z,{align:"end",children:[t.jsxs(B,{onClick:a,children:[t.jsx(j,{name:"edit",className:"size-4 mr-2"}),"Edit comment"]}),t.jsxs(B,{onClick:r,className:"text-destructive",children:[t.jsx(j,{name:"delete-bin",className:"size-4 mr-2"}),"Delete comment"]})]})]})]})}),t.jsxs(ae,{children:[t.jsxs(q,{onClick:a,children:[t.jsx(j,{name:"edit",className:"size-4 mr-2"}),"Edit comment"]}),t.jsxs(q,{onClick:r,className:"text-destructive focus:text-destructive",children:[t.jsx(j,{name:"delete-bin",className:"size-4 mr-2"}),"Delete comment"]})]})]})}function ve({initialText:n="",onTextChange:a,onSave:r,onCancel:h,fileLabel:d,lineRange:l,isEditing:p=!1,className:m,maxWidth:w}){const f=U()?.currentTheme,{isMobile:u}=ee(),[i,b]=c.useState(n),D=N.useRef(null),M=e=>{b(e),a?.(e)},L=N.useRef(l);N.useEffect(()=>{l&&(L.current=l)},[l]);const v=e=>{if(!e)return;const o=Math.min(e.start,e.end),g=Math.max(e.start,e.end);return{...e,start:o,end:g}},x=v(l);N.useEffect(()=>{const e=D.current;if(!e)return;const o=e.closest(".overlay-scrollbar-container"),g=o?.scrollTop??window.scrollY,k=o?.scrollLeft??window.scrollX;if(u){e.scrollIntoView({behavior:"auto",block:"nearest"});try{e.focus({preventScroll:!0})}catch{e.focus()}return}try{e.focus({preventScroll:!0})}catch{e.focus()}const z=e.value.length;try{e.setSelectionRange(z,z)}catch{}requestAnimationFrame(()=>{o?(o.scrollTop=g,o.scrollLeft=k):window.scrollTo({top:g,left:k})})},[u]);const T=e=>{(e.metaKey||e.ctrlKey)&&e.key==="Enter"?(e.preventDefault(),i.trim()&&r(i,v(L.current))):e.key==="Escape"&&(e.preventDefault(),h())},y=e=>{e.stopPropagation(),i.trim()&&r(i,v(L.current))};return t.jsx("div",{className:F("rounded-lg border shadow-none w-full max-w-[min(100%,calc(var(--oc-context-panel-width,100vw)-var(--oc-editor-gutter-width,0px)))] overflow-hidden animate-in fade-in zoom-in-95 duration-200",m),style:{backgroundColor:f?.colors?.surface?.elevated,borderColor:f?.colors?.interactive?.border,maxWidth:w?`${Math.max(200,Math.floor(w))}px`:void 0},"data-comment-input":"true",onPointerDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:t.jsxs("div",{className:"p-3",children:[(d||l)&&t.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground mb-2",children:[d&&t.jsx("span",{className:"truncate max-w-[200px]",children:d}),d&&l&&t.jsx("span",{children:"•"}),x&&t.jsx("span",{children:`Lines ${x.start}-${x.end}`})]}),t.jsx(ie,{simple:!0,ref:D,value:i,onChange:e=>M(e.target.value),onKeyDown:T,placeholder:u?"Add a comment...":"Add a comment... (Cmd+Enter to save)",outerClassName:"rounded-[var(--radius-xl)] bg-[var(--surface-subtle)] ring-1 ring-inset ring-border/60 focus-within:ring-2 focus-within:ring-[var(--interactive-focus-ring)]",className:"min-h-[80px] px-3 py-2.5 text-sm resize-y"}),t.jsxs("div",{className:"flex items-center justify-end gap-2 mt-3",children:[t.jsx(E,{variant:"ghost",size:"sm",onClick:h,onPointerDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),className:"h-8 text-muted-foreground hover:text-foreground",children:"Cancel"}),t.jsx(E,{size:"sm",onClick:y,onPointerDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),disabled:!i.trim(),className:"h-8 min-w-[80px]",style:{backgroundColor:f?.colors?.status?.success,color:f?.colors?.status?.successForeground},children:p?"Save":"Comment"})]})]})})}const ue=n=>{const a=Math.min(n.startLine,n.endLine),r=Math.max(n.startLine,n.endLine);return{...n,startLine:a,endLine:r}},J=n=>{const a=Math.min(n.start,n.end),r=Math.max(n.start,n.end);return{...n,start:a,end:r}};function je(n){const{source:a,fileLabel:r,language:h,getCodeForRange:d,toStoreRange:l,fromDraftRange:p}=n,m=O(s=>s.currentSessionId),w=O(s=>s.newSessionDraft?.open),I=te(),f=O(c.useCallback(s=>m?s.getDirectoryForSession(m):null,[m])),u=R(s=>s.addDraft),i=R(s=>s.updateDraft),b=R(s=>s.removeDraft),[D,M]=c.useState(null),[L,v]=c.useState(""),[x,T]=c.useState(null),y=m??(w?"draft":null),e=f??I,o=c.useMemo(()=>!y||!e?null:{directory:e,sessionKey:y},[e,y]),g=o?se(me(),o.directory,o.sessionKey):null,k=R(c.useCallback(s=>g?s.drafts[g]??Y:Y,[g])),z=c.useMemo(()=>!o||!r?[]:k.filter(s=>s.source===a&&s.fileLabel===r),[r,k,a,o]),C=c.useCallback(()=>{M(null),v(""),T(null)},[]),V=c.useCallback(()=>{C()},[C]),W=c.useCallback(s=>{const P=J(p(s));M(P),v(s.text),T(s.id)},[p]),X=c.useCallback(s=>{o&&(b(o,s.id),x===s.id&&C())},[x,b,C,o]),G=c.useCallback((s,P)=>{const $=P??D,K=s.trim();if(!$||!K||!r)return;if(!o){ne.error("Select a session to save comment");return}const A=J($),S=ue(l(A)),_=d(A);x?i(o,x,{fileLabel:r,startLine:S.startLine,endLine:S.endLine,side:S.side,code:_,language:h,text:K}):u(o,{source:a,fileLabel:r,startLine:S.startLine,endLine:S.endLine,side:S.side,code:_,language:h,text:K}),C()},[u,x,r,d,h,C,D,a,o,l,i]);return{sessionKey:y,drafts:z,selection:D,setSelection:M,commentText:L,setCommentText:v,editingDraftId:x,setEditingDraftId:T,reset:C,cancel:V,startEdit:W,deleteDraft:X,saveComment:G,fromDraftRange:p}}export{ve as I,Ce as a,J as n,je as u};
1
+ import{r as N,j as t,R as c}from"./vendor-react-DYyjh7Q0.js";import{bi as G,f as F,B as E,I as w,as as J,at as W,au as Z,az as q,aV as ee,h as O,E as te,aQ as R,eG as se,eH as B,t as ne}from"./SessionSwitcherDropdown-C0OdvirK.js";import{p as oe,q as re,t as ae,v as V,N as ie}from"./usePanelSlide-DCX8qQ4K.js";import{C as ce,a as le,b as de}from"./collapsible-Bq8sDiKS.js";import{a as me}from"./index-CH7o4-_q.js";function Ce({draft:n,onEdit:a,onDelete:r,className:h,maxWidth:d}){const p=G()?.currentTheme,[m,j]=N.useState(!1),[k,f]=N.useState(!1),u=typeof n.text=="string"?n.text:"",i=u.length>150||u.split(`
2
+ `).length>3;return t.jsxs(oe,{open:k,onOpenChange:f,children:[t.jsx(re,{render:t.jsx("div",{className:F("rounded-lg border shadow-none w-full max-w-[min(100%,calc(var(--oc-context-panel-width,100vw)-var(--oc-editor-gutter-width,0px)))] overflow-hidden transition-all duration-200",h),style:{backgroundColor:p?.colors?.surface?.elevated,borderColor:p?.colors?.interactive?.border,maxWidth:d?`${Math.max(200,Math.floor(d))}px`:void 0},"data-comment-card":"true",onContextMenu:b=>{b.preventDefault(),f(!0)}}),children:t.jsxs("div",{className:"flex items-start justify-between gap-2 p-3",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground mb-1.5",children:[t.jsx("span",{className:"truncate max-w-[200px]",title:n.fileLabel,children:n.fileLabel}),t.jsx("span",{children:"•"}),t.jsx("span",{children:`Lines ${n.startLine}-${n.endLine}`}),n.side&&t.jsxs("span",{children:["(",n.side,")"]})]}),t.jsxs(ce,{open:m||!i,onOpenChange:j,children:[t.jsx("div",{className:F("text-sm whitespace-pre-wrap break-words leading-relaxed",!m&&i&&"line-clamp-3"),children:u}),i&&t.jsx(le,{asChild:!0,children:t.jsx(E,{variant:"ghost",size:"sm",className:"h-6 px-0 mt-1 text-xs text-muted-foreground hover:text-foreground w-full justify-start",children:m?t.jsxs(t.Fragment,{children:[t.jsx(w,{name:"arrow-up-s",className:"size-3 mr-1"}),"Show less"]}):t.jsxs(t.Fragment,{children:[t.jsx(w,{name:"arrow-down-s",className:"size-3 mr-1"}),"Show more"]})})}),t.jsx(de,{})]})]}),t.jsxs(J,{children:[t.jsx(W,{asChild:!0,children:t.jsx(E,{variant:"ghost",size:"icon",className:"h-6 w-6 -mr-1 text-muted-foreground hover:text-foreground",children:t.jsx(w,{name:"more",className:"size-4"})})}),t.jsxs(Z,{align:"end",children:[t.jsxs(q,{onClick:a,children:[t.jsx(w,{name:"edit",className:"size-4 mr-2"}),"Edit comment"]}),t.jsxs(q,{onClick:r,className:"text-destructive",children:[t.jsx(w,{name:"delete-bin",className:"size-4 mr-2"}),"Delete comment"]})]})]})]})}),t.jsxs(ae,{children:[t.jsxs(V,{onClick:a,children:[t.jsx(w,{name:"edit",className:"size-4 mr-2"}),"Edit comment"]}),t.jsxs(V,{onClick:r,className:"text-destructive focus:text-destructive",children:[t.jsx(w,{name:"delete-bin",className:"size-4 mr-2"}),"Delete comment"]})]})]})}function ve({initialText:n="",onTextChange:a,onSave:r,onCancel:h,fileLabel:d,lineRange:l,isEditing:p=!1,className:m,maxWidth:j}){const f=G()?.currentTheme,{isMobile:u}=ee(),[i,b]=c.useState(n),D=N.useRef(null),M=e=>{b(e),a?.(e)},L=N.useRef(l);N.useEffect(()=>{l&&(L.current=l)},[l]);const v=e=>{if(!e)return;const o=Math.min(e.start,e.end),g=Math.max(e.start,e.end);return{...e,start:o,end:g}},x=v(l);N.useEffect(()=>{const e=D.current;if(!e)return;const o=e.closest(".overlay-scrollbar-container"),g=o?.scrollTop??window.scrollY,I=o?.scrollLeft??window.scrollX;if(u){e.scrollIntoView({behavior:"auto",block:"nearest"});try{e.focus({preventScroll:!0})}catch{e.focus()}return}try{e.focus({preventScroll:!0})}catch{e.focus()}const z=e.value.length;try{e.setSelectionRange(z,z)}catch{}requestAnimationFrame(()=>{o?(o.scrollTop=g,o.scrollLeft=I):window.scrollTo({top:g,left:I})})},[u]);const T=e=>{(e.metaKey||e.ctrlKey)&&e.key==="Enter"?(e.preventDefault(),i.trim()&&r(i,v(L.current))):e.key==="Escape"&&(e.preventDefault(),h())},y=e=>{e.stopPropagation(),i.trim()&&r(i,v(L.current))};return t.jsx("div",{className:F("rounded-lg border shadow-none w-full max-w-[min(100%,calc(var(--oc-context-panel-width,100vw)-var(--oc-editor-gutter-width,0px)))] overflow-hidden animate-in fade-in zoom-in-95 duration-200",m),style:{backgroundColor:f?.colors?.surface?.elevated,borderColor:f?.colors?.interactive?.border,maxWidth:j?`${Math.max(200,Math.floor(j))}px`:void 0},"data-comment-input":"true",onPointerDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:t.jsxs("div",{className:"p-3",children:[(d||l)&&t.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground mb-2",children:[d&&t.jsx("span",{className:"truncate max-w-[200px]",children:d}),d&&l&&t.jsx("span",{children:"•"}),x&&t.jsx("span",{children:`Lines ${x.start}-${x.end}`})]}),t.jsx(ie,{simple:!0,ref:D,value:i,onChange:e=>M(e.target.value),onKeyDown:T,placeholder:u?"Add a comment...":"Add a comment... (Cmd+Enter to save)",outerClassName:"rounded-[var(--radius-xl)] bg-[var(--surface-subtle)] ring-1 ring-inset ring-border/60 focus-within:ring-2 focus-within:ring-[var(--interactive-focus-ring)]",className:"min-h-[80px] px-3 py-2.5 text-sm resize-y"}),t.jsxs("div",{className:"flex items-center justify-end gap-2 mt-3",children:[t.jsx(E,{variant:"ghost",size:"sm",onClick:h,onPointerDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),className:"h-8 text-muted-foreground hover:text-foreground",children:"Cancel"}),t.jsx(E,{size:"sm",onClick:y,onPointerDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),disabled:!i.trim(),className:"h-8 min-w-[80px]",style:{backgroundColor:f?.colors?.status?.success,color:f?.colors?.status?.successForeground},children:p?"Save":"Comment"})]})]})})}const ue=n=>{const a=Math.min(n.startLine,n.endLine),r=Math.max(n.startLine,n.endLine);return{...n,startLine:a,endLine:r}},Y=n=>{const a=Math.min(n.start,n.end),r=Math.max(n.start,n.end);return{...n,start:a,end:r}};function we(n){const{source:a,fileLabel:r,language:h,getCodeForRange:d,toStoreRange:l,fromDraftRange:p}=n,m=O(s=>s.currentSessionId),j=O(s=>s.newSessionDraft?.open),k=te(),f=O(c.useCallback(s=>m?s.getDirectoryForSession(m):null,[m])),u=R(s=>s.addDraft),i=R(s=>s.updateDraft),b=R(s=>s.removeDraft),[D,M]=c.useState(null),[L,v]=c.useState(""),[x,T]=c.useState(null),y=m??(j?"draft":null),e=f??k,o=c.useMemo(()=>!y||!e?null:{directory:e,sessionKey:y},[e,y]),g=o?se(me(),o.directory,o.sessionKey):null,I=R(c.useCallback(s=>g?s.drafts[g]??B:B,[g])),z=c.useMemo(()=>!o||!r?[]:I.filter(s=>s.source===a&&s.fileLabel===r),[r,I,a,o]),C=c.useCallback(()=>{M(null),v(""),T(null)},[]),H=c.useCallback(()=>{C()},[C]),Q=c.useCallback(s=>{const P=Y(p(s));M(P),v(s.text),T(s.id)},[p]),U=c.useCallback(s=>{o&&(b(o,s.id),x===s.id&&C())},[x,b,C,o]),X=c.useCallback((s,P)=>{const $=P??D,K=s.trim();if(!$||!K||!r)return;if(!o){ne.error("Select a session to save comment");return}const A=Y($),S=ue(l(A)),_=d(A);x?i(o,x,{fileLabel:r,startLine:S.startLine,endLine:S.endLine,side:S.side,code:_,language:h,text:K}):u(o,{source:a,fileLabel:r,startLine:S.startLine,endLine:S.endLine,side:S.side,code:_,language:h,text:K}),C()},[u,x,r,d,h,C,D,a,o,l,i]);return{sessionKey:y,drafts:z,selection:D,setSelection:M,commentText:L,setCommentText:v,editingDraftId:x,setEditingDraftId:T,reset:C,cancel:H,startEdit:Q,deleteDraft:U,saveComment:X,fromDraftRange:p}}export{ve as I,Ce as a,Y as n,we as u};