@p4code/cli 0.9.10 → 0.9.12

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 (341) hide show
  1. package/dist/bin.mjs +1 -1
  2. package/dist/{binCli-CYcCQdSE.mjs → binCli-D9zhTalS.mjs} +9983 -6003
  3. package/dist/client/.vite/manifest.json +2080 -2027
  4. package/dist/client/assets/{2NI2N5EU-CTGx9SqE.js → 2NI2N5EU-DOvURDwM.js} +2 -2
  5. package/dist/client/assets/{4UO7MD6I-BjVL6foo.js → 4UO7MD6I-CArKQR6u.js} +2 -2
  6. package/dist/client/assets/{5B3SVYGG-Cs9CtCwM.js → 5B3SVYGG-D3yJKYTq.js} +2 -2
  7. package/dist/client/assets/{5GK6JWQ2-uCqJ5b6P.js → 5GK6JWQ2-C7D6qJvm.js} +2 -2
  8. package/dist/client/assets/{5N7A7DKN-D8xYxzg8.js → 5N7A7DKN-DDTV444t.js} +2 -2
  9. package/dist/client/assets/{5OC2THR4-B4_z8HL_.js → 5OC2THR4-CYaAiBA5.js} +2 -2
  10. package/dist/client/assets/{5S6HY5KT-BQM1ruT_.js → 5S6HY5KT-jYzQX9YI.js} +2 -2
  11. package/dist/client/assets/{6IMQ5BUJ-CkYA1m9F.js → 6IMQ5BUJ-CZSZgyOb.js} +2 -2
  12. package/dist/client/assets/{6OLKWJ4F-B7EL2QRF.js → 6OLKWJ4F-D_TpeHsd.js} +2 -2
  13. package/dist/client/assets/{74OO7NKP-3i4AYzMo.js → 74OO7NKP-VJq-BY7c.js} +2 -2
  14. package/dist/client/assets/{75O6YZUN-CFk80U2S.js → 75O6YZUN-BCik3Y9V.js} +2 -2
  15. package/dist/client/assets/{77XECAW3-DUjtpBc8.js → 77XECAW3-Ce_-nZaY.js} +2 -2
  16. package/dist/client/assets/{ABYRPUBD-BobiH6Ib.js → ABYRPUBD-C1hL61qL.js} +2 -2
  17. package/dist/client/assets/AlertDialogRoot-C6RQ4Ag-.js +2 -0
  18. package/dist/client/assets/{AnimatedHeight-Baj5Pa60.js → AnimatedHeight-DEeywxgS.js} +2 -2
  19. package/dist/client/assets/{AuthSurfaceShell-PCmsqp7T.js → AuthSurfaceShell-835o12nS.js} +2 -2
  20. package/dist/client/assets/{BB2UYUI2-DnxMKjgT.js → BB2UYUI2-DlIE2g50.js} +2 -2
  21. package/dist/client/assets/{BUM34MOA-DNTynUxx.js → BUM34MOA-D9NQPxww.js} +2 -2
  22. package/dist/client/assets/{CEQABKGZ-veHxvA1u.js → CEQABKGZ-BsiY6pPC.js} +2 -2
  23. package/dist/client/assets/{CXAC5362-BynYY6uD.js → CXAC5362-t7YfF0UQ.js} +2 -2
  24. package/dist/client/assets/{ChatGptUsageButton-D-N8-zk6.js → ChatGptUsageButton-C3xHekTe.js} +2 -2
  25. package/dist/client/assets/{ChatMarkdown-fdsQ0rQe.js → ChatMarkdown-Cw9bEYxG.js} +31 -31
  26. package/dist/client/assets/CheckboxIndicator-XdXpYxXy.js +2 -0
  27. package/dist/client/assets/{ClippedText-Bz4usJaN.js → ClippedText-C-unQqBz.js} +2 -2
  28. package/dist/client/assets/CodexSetupSection.logic-Bl5OcEqH.js +2 -0
  29. package/dist/client/assets/ComboboxClear-CBRGIQSm.js +2 -0
  30. package/dist/client/assets/{ComboboxGroupLabel-B9uepPCe.js → ComboboxGroupLabel-DVAwRoGV.js} +2 -2
  31. package/dist/client/assets/{CommandBlock-BFdf6yDf.js → CommandBlock-D6NTupaO.js} +2 -2
  32. package/dist/client/assets/{ComposerPromptEditor--x6yGPiW.js → ComposerPromptEditor-BqLNVkse.js} +60 -60
  33. package/dist/client/assets/CompositeRoot-DBS-Yo_S.js +2 -0
  34. package/dist/client/assets/{connect-agent-BJCTM1nf.js → ConnectAgentSurface-TBgGDnVI.js} +2 -2
  35. package/dist/client/assets/{ConnectionStatusDot-CpPwqzkK.js → ConnectionStatusDot-CR_qWdCU.js} +2 -2
  36. package/dist/client/assets/{DRLTVNUE-BOhroau_.js → DRLTVNUE-DkTzG_pM.js} +2 -2
  37. package/dist/client/assets/{DYY6UVD2-Bpmvecid.js → DYY6UVD2-BBRUtn6A.js} +2 -2
  38. package/dist/client/assets/DevicePanel-BS7y97f_.js +2 -0
  39. package/dist/client/assets/{DeviceSetup-CJ3rjcDw.js → DeviceSetup-TIKLCkls.js} +2 -2
  40. package/dist/client/assets/DialogTitle-DzoEjZ6h.js +2 -0
  41. package/dist/client/assets/{DiffCommentAnnotation-BkAROMry.js → DiffCommentAnnotation-y1CrEDvy.js} +3 -3
  42. package/dist/client/assets/{DiffFileTree-ERgpSLaE.js → DiffFileTree-BM7RDTEn.js} +2 -2
  43. package/dist/client/assets/DiffPanel-CAK_DAYa.js +2 -0
  44. package/dist/client/assets/{DiffWorkerPoolProvider-BrhQktrm.js → DiffWorkerPoolProvider-D2t5zRbN.js} +2 -2
  45. package/dist/client/assets/{EmbeddedDesign-DpSkJYii.js → EmbeddedDesign-_id3IQO6.js} +5 -5
  46. package/dist/client/assets/{EnvironmentMachineIcon-BrGxJPP_.js → EnvironmentMachineIcon-oObSi9GI.js} +2 -2
  47. package/dist/client/assets/{ExpandableText-auxbX5_6.js → ExpandableText-BLwIQ2BJ.js} +2 -2
  48. package/dist/client/assets/{FNOVOB4O-Mdzaj7g-.js → FNOVOB4O-B469NSHv.js} +2 -2
  49. package/dist/client/assets/FieldControl-Btl-j-6W.js +2 -0
  50. package/dist/client/assets/{FileDiff-sbzjIw4Y.js → FileDiff-CGLKzg3V.js} +2 -2
  51. package/dist/client/assets/FilePreviewPanel-DJ-LkCJ7.js +34 -0
  52. package/dist/client/assets/{FoldedSettingsSection-DN1s3P5h.js → FoldedSettingsSection-DPTJODig.js} +2 -2
  53. package/dist/client/assets/FormContext-Be16jmaZ.js +2 -0
  54. package/dist/client/assets/{HDGCDEEZ-Ylftf3gZ.js → HDGCDEEZ-BUMQl9WF.js} +2 -2
  55. package/dist/client/assets/{HSJLKHB7-BQqIHFzA.js → HSJLKHB7-C08sJAK2.js} +2 -2
  56. package/dist/client/assets/{Icons-BP6jlahF.js → Icons-2l7Ym4KO.js} +2 -2
  57. package/dist/client/assets/Input--rtZ2Jji.js +2 -0
  58. package/dist/client/assets/JZOYTAAL-PmkwTnld.js +1 -0
  59. package/dist/client/assets/{K3MD6TGW-C-WMFQa2.js → K3MD6TGW-D4RWgVJJ.js} +2 -2
  60. package/dist/client/assets/{K7RP3OMA-Bv01V4PC.js → K7RP3OMA-B8UDebPA.js} +2 -2
  61. package/dist/client/assets/{KeybindingsSettings.logic-CkmobJKX.js → KeybindingsSettings.logic-CCfOv-KZ.js} +2 -2
  62. package/dist/client/assets/{LHDIQX7Q-NSQFT8t0.js → LHDIQX7Q-DwRY1EjH.js} +2 -2
  63. package/dist/client/assets/{LUXOKEGN-URYU7c_t.js → LUXOKEGN-BTGUp3oJ.js} +2 -2
  64. package/dist/client/assets/LinkMachineSelect-DoHeQGoj.js +2 -0
  65. package/dist/client/assets/{MathTypeset-vloBebae.js → MathTypeset-DZCUnfpK.js} +2 -2
  66. package/dist/client/assets/{N3JZAHOW-B9_qgeJe.js → N3JZAHOW-C-bkdj1S.js} +2 -2
  67. package/dist/client/assets/{NUIALGQ3-CgK-ZGa2.js → NUIALGQ3-COfmKsf1.js} +2 -2
  68. package/dist/client/assets/{NoProjectsHero-Bkfsk4qc.js → NoProjectsHero-CbIPjHEJ.js} +2 -2
  69. package/dist/client/assets/{O65XPQGZ-DcczmOOs.js → O65XPQGZ-BPK2EL3_.js} +2 -2
  70. package/dist/client/assets/{O7XIQ6OM-DBN8Ta1r.js → O7XIQ6OM-qzVUZXbW.js} +2 -2
  71. package/dist/client/assets/{OFQON5FD-BAqD2M9W.js → OFQON5FD-DJVnaZou.js} +2 -2
  72. package/dist/client/assets/{P4ConnectAccountPages-kTztZndM.js → P4ConnectAccountPages-DwBbHN5Q.js} +2 -2
  73. package/dist/client/assets/P4ConnectSidebarSignIn-D7VczA30.js +2 -0
  74. package/dist/client/assets/{PJQHF43J-D1TwOPBO.js → PJQHF43J-CTXALHLE.js} +2 -2
  75. package/dist/client/assets/PanelLayoutControls-D8g6TJ8z.js +216 -0
  76. package/dist/client/assets/{PierreEntryIcon-CcaKUQ_5.js → PierreEntryIcon-CUoKY0yE.js} +2 -2
  77. package/dist/client/assets/PopoverHandle-tRSwNzqr.js +2 -0
  78. package/dist/client/assets/PreviewPanel-cYx50TF6.js +2 -0
  79. package/dist/client/assets/ProjectDefaultsSettings-G0FTRG0c.js +2 -0
  80. package/dist/client/assets/ProjectFavicon-in-OyDkg.js +3 -0
  81. package/dist/client/assets/{ProjectIconPickerDialog-DrNrdWag.js → ProjectIconPickerDialog-JCPOaZup.js} +2 -2
  82. package/dist/client/assets/{ProjectMonogram-BJooqIM-.js → ProjectMonogram-DdbScW3Y.js} +2 -2
  83. package/dist/client/assets/{ProviderAuthTerminal-BdestvKT.js → ProviderAuthTerminal-CCw2XmNz.js} +2 -2
  84. package/dist/client/assets/ProviderModelPicker-DWqfDVY9.js +2 -0
  85. package/dist/client/assets/{ProviderSettingsForm-B1ZiIcrJ.js → ProviderSettingsForm-_viBEB9w.js} +2 -2
  86. package/dist/client/assets/PullRequestCodeTab-D3ntjIAg.js +6 -0
  87. package/dist/client/assets/{RHNBAITX-AZ9q_QDP.js → RHNBAITX-BR5h8H8U.js} +2 -2
  88. package/dist/client/assets/{ReadOnlySourcePreview-CSK6ee05.js → ReadOnlySourcePreview-Bx9Jebzp.js} +2 -2
  89. package/dist/client/assets/RedactedSensitiveText-DM7Kme26.js +2 -0
  90. package/dist/client/assets/{RenderErrorBoundary-ImTUJEbS.js → RenderErrorBoundary-BeYcnW7D.js} +4 -4
  91. package/dist/client/assets/{SLD4V6NK-uXoZZAB2.js → SLD4V6NK-DfUtjUb_.js} +2 -2
  92. package/dist/client/assets/ScheduledTasksSettings-BcF7IiOl.js +4 -0
  93. package/dist/client/assets/{ScopedSwitch-IyBzdLBa.js → ScopedSwitch-CD9C3Bhs.js} +2 -2
  94. package/dist/client/assets/{ScrollAreaCorner-Bstf_gNQ.js → ScrollAreaCorner-D5JbJL5g.js} +2 -2
  95. package/dist/client/assets/{SecretInput-BTBcl8SC.js → SecretInput-ttyiYbVY.js} +2 -2
  96. package/dist/client/assets/SelectScrollUpArrow-BV1xykNQ.js +2 -0
  97. package/dist/client/assets/SelfImproveSettingsSection-Dm8NhqV7.js +2 -0
  98. package/dist/client/assets/SettingsPanels-BsyJETg8.js +46 -0
  99. package/dist/client/assets/SettingsPanels.logic-DS-Semyc.js +2 -0
  100. package/dist/client/assets/{SettingsScopeNotice-BSIkX2D-.js → SettingsScopeNotice--a-aNSRR.js} +2 -2
  101. package/dist/client/assets/{SidebarStageBackdrop-D7me9VdP.js → SidebarStageBackdrop-ntSLLOvm.js} +2 -2
  102. package/dist/client/assets/{T3PCR2KE-B4buGw24.js → T3PCR2KE-C5JeZecU.js} +2 -2
  103. package/dist/client/assets/{TKWO2OVW-B2GIBRnj.js → TKWO2OVW-B11aaxW8.js} +2 -2
  104. package/dist/client/assets/{TSHNXIZL-CwVvoBmu.js → TSHNXIZL-2800Jt5F.js} +2 -2
  105. package/dist/client/assets/{ThemeEditorPanel-Z1t7Xzva.js → ThemeEditorPanel-CTXEQSgi.js} +3 -3
  106. package/dist/client/assets/ThreadTerminalDrawer-DIUp50A3.js +5 -0
  107. package/dist/client/assets/TooltipViewport-rDmof6w5.js +2 -0
  108. package/dist/client/assets/{UQJE5E4I-Bzqu0vVG.js → UQJE5E4I-BG1U9EIM.js} +2 -2
  109. package/dist/client/assets/{USNYFO5S-C4Z9b1ks.js → USNYFO5S-d4iGw5HU.js} +2 -2
  110. package/dist/client/assets/{Virtualizer-saguDIDi.js → Virtualizer-CzClYBap.js} +2 -2
  111. package/dist/client/assets/{WEVWDWVA-C5c2236d.js → WEVWDWVA-V2MwjUCO.js} +2 -2
  112. package/dist/client/assets/{WorkspaceBreadcrumb-CQH9TmFi.js → WorkspaceBreadcrumb-Dpau2BKr.js} +2 -2
  113. package/dist/client/assets/{WorkspacePageContainer-E5ZuTsSl.js → WorkspacePageContainer-C3u06BW-.js} +2 -2
  114. package/dist/client/assets/{WorkspacePageHeader-DGopnQZ2.js → WorkspacePageHeader-MBEFb20_.js} +2 -2
  115. package/dist/client/assets/{X5RFHQXM-NygNPjev.js → X5RFHQXM-D_mIa6o9.js} +2 -2
  116. package/dist/client/assets/{X62E3GBT-qvvfx8FL.js → X62E3GBT-Cwvyi_iR.js} +2 -2
  117. package/dist/client/assets/{XBNEOJTC-DAgGRRGR.js → XBNEOJTC-sfA1U_fe.js} +2 -2
  118. package/dist/client/assets/{YHV2MVVZ-PIsz4H0c.js → YHV2MVVZ-CZoP6AAo.js} +2 -2
  119. package/dist/client/assets/{YURCZMG2-CAQz8Kb8.js → YURCZMG2-DYo6rqon.js} +2 -2
  120. package/dist/client/assets/{YVG2LODB-Crh6Gk8v.js → YVG2LODB-D8sTsTwc.js} +2 -2
  121. package/dist/client/assets/_chat-DNoJniWX.js +47 -0
  122. package/dist/client/assets/_chat.design-Nh4vxHDS.js +2 -0
  123. package/dist/client/assets/{_chat.index-ij31rX59.js → _chat.index-YNITFXX3.js} +2 -2
  124. package/dist/client/assets/_chat.new-B16PAbQN.js +4 -0
  125. package/dist/client/assets/_chat.pull-requests-DEHC0db5.js +2 -0
  126. package/dist/client/assets/{alert-CqueYfb9.js → alert-UH7IbYie.js} +2 -2
  127. package/dist/client/assets/alert-dialog-D3mCT6Vy.js +2 -0
  128. package/dist/client/assets/{assetUrls-5u2VAW_2.js → assetUrls-BNjjSBLP.js} +2 -2
  129. package/dist/client/assets/assets-CrCgj2yM.js +2 -0
  130. package/dist/client/assets/browserHistoryStore-CW_ylkPy.js +2 -0
  131. package/dist/client/assets/{browserLinkTarget-CUvZuS7D.js → browserLinkTarget-Dlnk6CC2.js} +2 -2
  132. package/dist/client/assets/{checkbox-BPr09F_k.js → checkbox-Bqcsvpsf.js} +2 -2
  133. package/dist/client/assets/circle-stop-0Wd2uKSK.js +2 -0
  134. package/dist/client/assets/{color-picker-roKqOkuS.js → color-picker-DAcpRn0k.js} +2 -2
  135. package/dist/client/assets/{combobox-CEzOq8mg.js → combobox-CoLp0McG.js} +2 -2
  136. package/dist/client/assets/{command-i_eKJj3B.js → command-cKnhWwdw.js} +2 -2
  137. package/dist/client/assets/connect-agent-CsvW078q.js +2 -0
  138. package/dist/client/assets/{connect-wndN2LD9.js → connect-rbXRyqde.js} +2 -2
  139. package/dist/client/assets/{design-Cve-RO6N.js → design-BJbd-4a9.js} +2 -2
  140. package/dist/client/assets/device-BqGYZxfg.js +2 -0
  141. package/dist/client/assets/{dialog-CKG1aUT3.js → dialog-CjB1WWbE.js} +2 -2
  142. package/dist/client/assets/{diffRendering-Dyda4rX5.js → diffRendering-JsGpyVJ1.js} +2 -2
  143. package/dist/client/assets/{dist-DP18jjts.js → dist-D4GndTOF.js} +3 -3
  144. package/dist/client/assets/{draft-input-DvNQZghL.js → draft-input-1ySc55QI.js} +2 -2
  145. package/dist/client/assets/{duoViewer-BnfAzuzK.js → duoViewer-DvlUJy5A.js} +2 -2
  146. package/dist/client/assets/dynamic-B8PD-aHj.js +3 -0
  147. package/dist/client/assets/{embeddedScripts-BMILAsdP.js → embeddedScripts-ByokzHX1.js} +2 -2
  148. package/dist/client/assets/{empty-D6SdnsPw.js → empty-CMnFXg8W.js} +2 -2
  149. package/dist/client/assets/entities-CTJ1ube2.js +2 -0
  150. package/dist/client/assets/{fileLinks-BlBUc4i_.js → fileLinks-lUzqPrjb.js} +2 -2
  151. package/dist/client/assets/{fileTreeExpansion-B8yevc-B.js → fileTreeExpansion-B6sjoSXU.js} +2 -2
  152. package/dist/client/assets/{getDiffFileInput-dJd1H35Q.js → getDiffFileInput-Bt5vSiss.js} +2 -2
  153. package/dist/client/assets/{guideRunStore-DksWd_Oc.js → guideRunStore-DFawhaj_.js} +2 -2
  154. package/dist/client/assets/{htmlRender-hlYiIm7u.js → htmlRender-DJLbbd4O.js} +2 -2
  155. package/dist/client/assets/index-CxLeDuff.js +3 -0
  156. package/dist/client/assets/{input-yNgBXsRj.js → input-CSgYZgdv.js} +2 -2
  157. package/dist/client/assets/{input-group-APyqVexM.js → input-group-a-sGQMiV.js} +2 -2
  158. package/dist/client/assets/{kbd-Cr4XEhSh.js → kbd-D3uRVBMx.js} +2 -2
  159. package/dist/client/assets/{keybindings-hzk4_Sgu.js → keybindings-B9X0TLvu.js} +2 -2
  160. package/dist/client/assets/{lazy-DILJj7Gd.js → lazy-C_hQh3dP.js} +4 -4
  161. package/dist/client/assets/{lazyRouteComponent-tnhWsSYX.js → lazyRouteComponent-GMfIUG8o.js} +2 -2
  162. package/dist/client/assets/{link-CmpZDWcG.js → link-BmkuqfGQ.js} +2 -2
  163. package/dist/client/assets/{linkedPrompt-CE3amDef.js → linkedPrompt-BNxBPorU.js} +2 -2
  164. package/dist/client/assets/main-BD4pReCY.css +2 -0
  165. package/dist/client/assets/main-DIEsHSIy.js +37 -0
  166. package/dist/client/assets/mediaReference-CVS-Yvam.js +2 -0
  167. package/dist/client/assets/mediaSource-DQsJoeCH.js +2 -0
  168. package/dist/client/assets/number-field-Bw2BDGyn.js +2 -0
  169. package/dist/client/assets/{observeResize-DjqKtKLK.js → observeResize-Br7VOcTc.js} +2 -2
  170. package/dist/client/assets/{onboarding-pqbI8W1U.js → onboarding-D6kvYnD1.js} +2 -2
  171. package/dist/client/assets/openFileInPreview-52PEk4wb.js +2 -0
  172. package/dist/client/assets/{p4ProjectFile-xLwkLebE.js → p4ProjectFile-B1qTw64E.js} +2 -2
  173. package/dist/client/assets/{pair-C4lVdDUz.js → pair-Das8G2kV.js} +2 -2
  174. package/dist/client/assets/{pendingSendStore-BoFRcmy5.js → pendingSendStore-B1MXHU-Y.js} +2 -2
  175. package/dist/client/assets/{phoneViewer-Cotavx5y.js → phoneViewer-iWL9Ocv_.js} +2 -2
  176. package/dist/client/assets/{pierre-icons-CBskVugi.js → pierre-icons-CyZxWykW.js} +2 -2
  177. package/dist/client/assets/{popover-DVeZET9D.js → popover-Cpc0L75h.js} +2 -2
  178. package/dist/client/assets/{preview-oweHYD4S.js → preview-CDQ5ceMi.js} +2 -2
  179. package/dist/client/assets/{preview-Bw-Ffmn4.js → preview-DRZGCh-w.js} +2 -2
  180. package/dist/client/assets/{previewMiniPlayerStore-DrP4x3Ce.js → previewMiniPlayerStore-Dd2KfilQ.js} +2 -2
  181. package/dist/client/assets/primary-YDhFfOF8.js +2 -0
  182. package/dist/client/assets/primaryCloudLinkState-kvnCGEBC.js +2 -0
  183. package/dist/client/assets/projectFilesQueryState-DvEcN38K.js +2 -0
  184. package/dist/client/assets/projectScriptEditor-lOSI5meb.js +2 -0
  185. package/dist/client/assets/{providerSkills-DTVLY34_.js → providerSkills-CRmME5qO.js} +2 -2
  186. package/dist/client/assets/{pullRequestDetail.logic-BLe7zsLi.js → pullRequestDetail.logic-CXEtJJcn.js} +4 -4
  187. package/dist/client/assets/{pullRequestIcons-DyEIFm1n.js → pullRequestIcons-D8Koo716.js} +2 -2
  188. package/dist/client/assets/{pullRequestReviewStore-B55CEHY9.js → pullRequestReviewStore-CpLjLBJR.js} +2 -2
  189. package/dist/client/assets/pullRequests-DKqH-UAm.js +2 -0
  190. package/dist/client/assets/queries-eqpX-CHf.js +2 -0
  191. package/dist/client/assets/query-D5Kb9u_z.js +2 -0
  192. package/dist/client/assets/radio-group-DpxVKrML.js +2 -0
  193. package/dist/client/assets/{renderScheduler-CNepEPa2.js → renderScheduler-B1rJHKDM.js} +2 -2
  194. package/dist/client/assets/{rightPanelStore-CRQRe1Cp.js → rightPanelStore-DQ1c3-Lt.js} +2 -2
  195. package/dist/client/assets/runtime-DCbEdU32.js +3 -0
  196. package/dist/client/assets/runtime-DeVKKxNz.js +6 -0
  197. package/dist/client/assets/{runtimeModeConfig-BAFMgMrE.js → runtimeModeConfig-CZCsG9b4.js} +2 -2
  198. package/dist/client/assets/{scheduledTasksSettings.logic-CTJ1Zr8Z.js → scheduledTasksSettings.logic-gN3n5v-e.js} +3 -3
  199. package/dist/client/assets/{scroll-area-DTOm0CbX.js → scroll-area-C9Jh_pl0.js} +2 -2
  200. package/dist/client/assets/{select-CML8G0wN.js → select-oshTwPZM.js} +2 -2
  201. package/dist/client/assets/{selfImproveFindings-DuRaHmql.js → selfImproveFindings-DUmfxmCO.js} +2 -2
  202. package/dist/client/assets/server-Ct4-BCZx.js +2 -0
  203. package/dist/client/assets/session-Bb7JWdWO.js +2 -0
  204. package/dist/client/assets/session-logic-D0Wb0fc2.js +26 -0
  205. package/dist/client/assets/{settings-CTpjG14a.js → settings-CQtFOh_t.js} +2 -2
  206. package/dist/client/assets/{settings.appearance-Cq56uRT4.js → settings.appearance-CqHPJVJ2.js} +2 -2
  207. package/dist/client/assets/settings.archived-DDtPGPcJ.js +2 -0
  208. package/dist/client/assets/{settings.computer-use-J2r1Wt55.js → settings.computer-use-CDrWkvkD.js} +2 -2
  209. package/dist/client/assets/settings.connections-CHXX5kH0.js +2 -0
  210. package/dist/client/assets/{settings.data-controls-Kotba8vC.js → settings.data-controls-Bd79f82M.js} +2 -2
  211. package/dist/client/assets/{settings.decisions-DghPRQ02.js → settings.decisions-B-i781li.js} +2 -2
  212. package/dist/client/assets/{settings.designs-D-0dwYo4.js → settings.designs-DpX9xXFH.js} +2 -2
  213. package/dist/client/assets/settings.diagnostics-Du6_cMwQ.js +2 -0
  214. package/dist/client/assets/{settings.general-c-32Nudd.js → settings.general-6bgZAoM7.js} +2 -2
  215. package/dist/client/assets/settings.integrations-Ct8ruO3E.js +2 -0
  216. package/dist/client/assets/{settings.keybindings-BIfUzprR.js → settings.keybindings-DzB2I9OY.js} +2 -2
  217. package/dist/client/assets/{settings.open-source-licenses-wmlqchzJ.js → settings.open-source-licenses-C-RX63iR.js} +2 -2
  218. package/dist/client/assets/{settings.plugins-C1PnlzX1.js → settings.plugins-CqpVlMrk.js} +4 -4
  219. package/dist/client/assets/settings.projects-DosfFxrs.js +4 -0
  220. package/dist/client/assets/settings.providers-DKgzTRpw.js +3 -0
  221. package/dist/client/assets/{settings.scheduled-tasks-BGGcs-KK.js → settings.scheduled-tasks-Ca4XxyAg.js} +2 -2
  222. package/dist/client/assets/settings.snap-shot-BkSOnsJ3.js +2 -0
  223. package/dist/client/assets/settings.source-control-uZ0ges0j.js +2 -0
  224. package/dist/client/assets/{settings.storage-CxA7PNjV.js → settings.storage-BkURtSS0.js} +2 -2
  225. package/dist/client/assets/settingsLayout-krWuVpsF.js +3 -0
  226. package/dist/client/assets/{sidebar-DMJE0zUg.js → sidebar-PSpwc3Zu.js} +2 -2
  227. package/dist/client/assets/{sidebarProjectGrouping-CPb438r8.js → sidebarProjectGrouping-D02jVAL6.js} +2 -2
  228. package/dist/client/assets/{skeleton-eiJFH0l9.js → skeleton-DIPW_H7N.js} +2 -2
  229. package/dist/client/assets/{sourceControl-DzD_N8hv.js → sourceControl-B9aMMjp2.js} +2 -2
  230. package/dist/client/assets/{sourceControlClients-BG_kFh61.js → sourceControlClients-XtdH6kjx.js} +2 -2
  231. package/dist/client/assets/{spinner-H4tz4lLc.js → spinner-BeAnBYcY.js} +2 -2
  232. package/dist/client/assets/{terminal-links-D7Hzce_h.js → terminal-links-CYEBYRi6.js} +2 -2
  233. package/dist/client/assets/terminalSessions-C2k3TT8f.js +2 -0
  234. package/dist/client/assets/{textarea-CkmpNgx5.js → textarea-DBTtAB2q.js} +2 -2
  235. package/dist/client/assets/{themePalette-pZ7Ys_kT.js → themePalette-Uk7bx8zb.js} +3 -3
  236. package/dist/client/assets/toast-Dkj3G-UM.js +2 -0
  237. package/dist/client/assets/{toggle-BDixfqRe.js → toggle-DYYe3Gb8.js} +2 -2
  238. package/dist/client/assets/{toggle-group-DV__8G6T.js → toggle-group-hQw0fxkT.js} +2 -2
  239. package/dist/client/assets/{tooltip-DsRaXpYk.js → tooltip-BeHmtauD.js} +2 -2
  240. package/dist/client/assets/{uiStateStore-DKTSAGd0.js → uiStateStore-Cd96D_GT.js} +2 -2
  241. package/dist/client/assets/usage-ChIGOn5O.js +2 -0
  242. package/dist/client/assets/{usageAccess-BXUmTDe1.js → usageAccess-DTKEwCKL.js} +2 -2
  243. package/dist/client/assets/{usageFormat-xrTYBhxI.js → usageFormat-D1mf8I5d.js} +2 -2
  244. package/dist/client/assets/{usageShortcuts-CQcKqXkw.js → usageShortcuts-C0jTsdR4.js} +2 -2
  245. package/dist/client/assets/{use-atom-command-BETKz9Hv.js → use-atom-command-D4TeQyNE.js} +2 -2
  246. package/dist/client/assets/{useAriaLabelledBy-DVTboZ71.js → useAriaLabelledBy-Cod6bMX5.js} +2 -2
  247. package/dist/client/assets/useHandleNewThread-CJ3yJ6tD.js +2 -0
  248. package/dist/client/assets/{useLocation--dLSTvwv.js → useLocation-DNv7cb59.js} +2 -2
  249. package/dist/client/assets/{useNavigate-DAhzXpNZ.js → useNavigate-PfhtEZbl.js} +2 -2
  250. package/dist/client/assets/{useNavigateBack-ClmMPFha.js → useNavigateBack-DUje4FcE.js} +2 -2
  251. package/dist/client/assets/{useP4ConnectAuthPrompt-BXoWBt0U.js → useP4ConnectAuthPrompt-evKe5nuS.js} +2 -2
  252. package/dist/client/assets/{useParams-D_0yPfYl.js → useParams-CzC0HF0R.js} +2 -2
  253. package/dist/client/assets/{usePermissionStatus-BGxDZxHH.js → usePermissionStatus-BUDWSxLm.js} +2 -2
  254. package/dist/client/assets/{usePullRequestActions-D0-24Gox.js → usePullRequestActions-Cxt5UQ0d.js} +3 -3
  255. package/dist/client/assets/{useRegisterFieldControl-DnspXZl4.js → useRegisterFieldControl-B4MJ2axN.js} +2 -2
  256. package/dist/client/assets/{useScopedModelAvailability-C44gQf2k.js → useScopedModelAvailability-ujoqpGuE.js} +2 -2
  257. package/dist/client/assets/useSettings-Cg0O7Ek7.js +3 -0
  258. package/dist/client/assets/utils-CcBaVOX5.js +37 -0
  259. package/dist/client/assets/vcsRefInvalidation-B5V_HlR9.js +2 -0
  260. package/dist/client/assets/welcome-DqtsIjdN.js +2 -0
  261. package/dist/client/index.html +1 -1
  262. package/dist/client/third-party-licenses.json +1 -1
  263. package/dist/{renderer-DNRW9Bfa.mjs → renderer-CmxAcIV2.mjs} +2 -2
  264. package/dist/{runtime-KPwu-Er9.mjs → runtime-CAtWuL14.mjs} +524 -54
  265. package/package.json +4 -3
  266. package/dist/client/assets/AlertDialogRoot-BDlDnUeW.js +0 -2
  267. package/dist/client/assets/CheckboxIndicator-CvUY7aCo.js +0 -2
  268. package/dist/client/assets/CodexSetupSection.logic-lS_hYW7M.js +0 -2
  269. package/dist/client/assets/ComboboxClear-BWxvz8Y9.js +0 -2
  270. package/dist/client/assets/CompositeRoot-XnJ7Nzli.js +0 -2
  271. package/dist/client/assets/ConnectionDiagnosisDetails-BiLziJiH.js +0 -2
  272. package/dist/client/assets/DevicePanel-BgToYlYg.js +0 -2
  273. package/dist/client/assets/DialogTitle-DdTujj5B.js +0 -2
  274. package/dist/client/assets/DiffPanel-DwPk2swZ.js +0 -2
  275. package/dist/client/assets/FieldControl-DfaF5AW8.js +0 -2
  276. package/dist/client/assets/FilePreviewPanel-BOnzRmKq.js +0 -34
  277. package/dist/client/assets/FormContext-B_ZMFN7l.js +0 -2
  278. package/dist/client/assets/Input-B9nob0l2.js +0 -2
  279. package/dist/client/assets/JZOYTAAL-5fSSCfug.js +0 -1
  280. package/dist/client/assets/P4ConnectSidebarSignIn-BLFNWeXr.js +0 -2
  281. package/dist/client/assets/PanelLayoutControls-BL3qZRW6.js +0 -216
  282. package/dist/client/assets/PopoverHandle-Bf0PlJ6j.js +0 -2
  283. package/dist/client/assets/PreviewPanel-CF9KdCOZ.js +0 -2
  284. package/dist/client/assets/ProjectDefaultsSettings-DC9sqe1A.js +0 -2
  285. package/dist/client/assets/ProjectFavicon-6uv-3a7b.js +0 -3
  286. package/dist/client/assets/ProviderModelPicker-Dx26TqdI.js +0 -2
  287. package/dist/client/assets/PullRequestCodeTab-5JEE8HsL.js +0 -6
  288. package/dist/client/assets/ScheduledTasksSettings-BDkh7pCI.js +0 -4
  289. package/dist/client/assets/SelectScrollUpArrow-BAwxXUi-.js +0 -2
  290. package/dist/client/assets/SelfImproveSettingsSection-DGcoA36F.js +0 -2
  291. package/dist/client/assets/SettingsPanels-BfzvtrNj.js +0 -46
  292. package/dist/client/assets/SettingsPanels.logic-xcOt84aX.js +0 -2
  293. package/dist/client/assets/ThreadTerminalDrawer-CnO3UVOq.js +0 -5
  294. package/dist/client/assets/TooltipViewport-CEOeTVyb.js +0 -2
  295. package/dist/client/assets/_chat-BO5aRu-j.js +0 -45
  296. package/dist/client/assets/_chat.design-1RXhKj_3.js +0 -2
  297. package/dist/client/assets/_chat.new-QYOVVQAv.js +0 -4
  298. package/dist/client/assets/_chat.pull-requests-B8-W4w8K.js +0 -2
  299. package/dist/client/assets/assets-dVntMNKj.js +0 -2
  300. package/dist/client/assets/browserHistoryStore-AwPHr-9a.js +0 -2
  301. package/dist/client/assets/circle-stop-F6BJYb9Y.js +0 -2
  302. package/dist/client/assets/device-ZhgWJyBN.js +0 -2
  303. package/dist/client/assets/dynamic-DXn8DtfU.js +0 -3
  304. package/dist/client/assets/entities-DCgQUDZp.js +0 -2
  305. package/dist/client/assets/index-Bxk_RxGw.js +0 -3
  306. package/dist/client/assets/main-B-tAk2zT.css +0 -2
  307. package/dist/client/assets/main-CVSzIqPv.js +0 -37
  308. package/dist/client/assets/mediaReference-DMJ5Zay3.js +0 -2
  309. package/dist/client/assets/mediaSource-UIArIbzY.js +0 -2
  310. package/dist/client/assets/number-field-DcRWl9B0.js +0 -2
  311. package/dist/client/assets/openFileInPreview-x34grdQ6.js +0 -2
  312. package/dist/client/assets/primary-CIcP7bEP.js +0 -2
  313. package/dist/client/assets/primaryCloudLinkState-Dwi-D0I7.js +0 -2
  314. package/dist/client/assets/projectFilesQueryState-02nlfyzQ.js +0 -2
  315. package/dist/client/assets/projectScriptEditor-CIDcf-KL.js +0 -2
  316. package/dist/client/assets/pullRequests-mcrrz3SF.js +0 -2
  317. package/dist/client/assets/queries-ByCVdESa.js +0 -2
  318. package/dist/client/assets/query-D-IVadFI.js +0 -2
  319. package/dist/client/assets/radio-group-DIOJb--u.js +0 -2
  320. package/dist/client/assets/runtime-CZnPVuwS.js +0 -3
  321. package/dist/client/assets/runtime-DEFP_0P0.js +0 -6
  322. package/dist/client/assets/server-BuS35bSu.js +0 -2
  323. package/dist/client/assets/session-DIw-RcNy.js +0 -2
  324. package/dist/client/assets/session-logic-B5D2SdWr.js +0 -26
  325. package/dist/client/assets/settings.archived-D2NDpNIY.js +0 -2
  326. package/dist/client/assets/settings.connections-DDjl99g3.js +0 -2
  327. package/dist/client/assets/settings.diagnostics-C1H_Oj2r.js +0 -2
  328. package/dist/client/assets/settings.integrations-BBvK_SX4.js +0 -2
  329. package/dist/client/assets/settings.projects-BmJITbPY.js +0 -4
  330. package/dist/client/assets/settings.providers-ELxTJwWk.js +0 -3
  331. package/dist/client/assets/settings.snap-shot-CvbNcoJx.js +0 -2
  332. package/dist/client/assets/settings.source-control-k2lVK3Ho.js +0 -2
  333. package/dist/client/assets/settingsLayout-BWJVQUbK.js +0 -3
  334. package/dist/client/assets/terminalSessions-BxTpBnAL.js +0 -2
  335. package/dist/client/assets/toast-rcFdQept.js +0 -2
  336. package/dist/client/assets/usage-C-EgFB5m.js +0 -2
  337. package/dist/client/assets/useHandleNewThread-BoN4NqHy.js +0 -2
  338. package/dist/client/assets/useSettings-4JwtKUFC.js +0 -3
  339. package/dist/client/assets/utils-D19Exirm.js +0 -37
  340. package/dist/client/assets/vcsRefInvalidation-aUafFWy3.js +0 -2
  341. package/dist/client/assets/welcome-DORffgtg.js +0 -2
@@ -0,0 +1,26 @@
1
+ import{Ax as e,Cx as t,FE as n,Fu as r,Hs as i,Iu as a,ME as o,Mu as s,Nu as c,Pu as l,V as u,Ws as d,ju as f,kt as p,p_ as m,u_ as ee}from"./utils-CcBaVOX5.js";import{Cn as te,Xt as h,Zt as ne,cn as re,d as g,ln as ie,qt as ae}from"./runtime-DCbEdU32.js";import{h as oe}from"./htmlRender-DJLbbd4O.js";import{n as se,t as ce}from"./mediaSource-DQsJoeCH.js";import{l as le}from"./usageFormat-D1mf8I5d.js";function _(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function v(e){if(typeof e!=`string`)return;let t=e.trim();return t.length>0?t:void 0}function ue(e,t){if(e!==`Skill`)return;let n=_(t),r=v(n?.skill);return r===void 0?void 0:{name:r,args:v(n?.args)}}function de(e){return e===`js`||e===`cua_repl.js`||e===`node_repl.js`}var fe={key:`computer-use`,name:`Computer Use`,kind:`computer`};function pe(e,t){if(e===`cua_repl.js`)return`computer`;let n=_(t)?.code;return de(e)&&typeof n==`string`&&(/\bsky\s*\./u.test(n)||/["']@oai\/sky["']/u.test(n))?`computer`:void 0}function me(e,t,n){if(de(e)){let r=v(n),i=r&&r.toLowerCase()!==`js`&&r.toLowerCase()!==e?.toLowerCase()?r:void 0;return v(_(t)?.title)??i??(pe(e,t)===`computer`?`Computer use`:`Run JavaScript`)}let r=ue(e,t);return r===void 0?void 0:`Skill: ${r.name}`}function he(e){return e!==void 0&&Object.keys(e).length>0}var ge=[`path`,`filePath`,`file_path`,`relativePath`,`filename`,`fileName`,`newPath`,`oldPath`];function _e(e,t,n,r){if(r>4||t.length>=8)return;if(Array.isArray(e)){for(let i of e)if(_e(i,t,n,r+1),t.length>=8)return;return}let i=_(e);if(i){for(let e of ge){let r=v(i[e]);if(r&&!n.has(r)&&(n.add(r),t.push(r),t.length>=8))return}for(let e of[`locations`,`item`,`input`,`result`,`rawInput`,`data`,`changes`])if(e in i&&(_e(i[e],t,n,r+1),t.length>=8))return}}function ve(e){let t=[];return _e(e,t,new Set,0),t}function ye(e){let t=v(e);if(t&&!/__|[./]/u.test(t))return t.replace(/[_\s-]/gu,``).toLowerCase()}function be(e){let t=e.itemType??void 0,n=v(e.requestKind)?.toLowerCase(),r=v(e.data?.kind)?.toLowerCase(),i=ye(v(e.data?.toolName)??v(_(e.data?.item)?.tool));return t===`command_execution`?`command`:t===`image_view`?`read`:t===`file_change`?`file_change`:t===`web_search`?`search`:n===`command`||r===`execute`?`command`:n===`file-change`||r===`edit`||r===`move`||r===`delete`||r===`write`?`file_change`:r===`search`||i===`find`||i===`grep`||i===`glob`||i===`rg`||i===`ls`?`search`:n===`file-read`||r===`read`?`read`:i===`terminal`||i===`bash`||i===`shell`?`command`:i===`read`||i===`readfile`?`read`:`other`}var xe=[`pattern`,`query`,`searchTerm`,`regex`,`grep`,`needle`],Se=[`glob`,`globPattern`,`glob_pattern`,`include`,`filePattern`,`file_pattern`],Ce=[`path`,`target_directory`,`targetDirectory`,`directory`,`cwd`,`root`];function we(e,t){if(e)for(let n of t){let t=v(e[n]);if(t)return t}}function Te(e){return[e?.rawInput,e?.input,_(e?.item)?.input].map(_).find(e=>he(e??void 0))??e}function Ee(e){if(e)return e.split(/[\\/]/u).findLast(e=>e.length>0&&e!==`.`)}function De(e){let t=Te(e),n=we(t,xe),r=we(t,Se),i=Ee(we(t,Ce));if(n&&i)return`Searched ${n} in ${i}`;if(r&&i)return`Searched files ${r} in ${i}`;if(r)return`Searched files ${r}`;if(n)return`Searched ${n}`;if(i)return`Searched in ${i}`}function Oe(e,t=0){let n=e.trim(),r=t>0?` +${t} more`:``;return n?`Read ${n}${r}`:`Read file${r}`}function y(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function b(e,t){if(typeof e!=`string`)return;let n=e.trim();return n&&n.length<=t?n:void 0}function x(e){let t=b(e,4096);if(t)try{let e=new URL(t);return e.protocol===`http:`||e.protocol===`https:`||e.protocol===`data:`?e.href:void 0}catch{return}}function ke(e){let t=b(e,4096);if(t)try{let e=new URL(t);return e.protocol===`http:`||e.protocol===`https:`?e.href:void 0}catch{return}}function Ae(e){let t=y(e),n=b(t?.appId,512);if(t?._tag===`app-id`&&n&&/^[A-Za-z0-9._-]+$/u.test(n))return{_tag:`app-id`,appId:n};let r=b(t?.displayName,160);if(t?._tag===`display-name`&&r)return{_tag:`display-name`,displayName:r}}function je(e){let t=y(e);if(t?._tag===`website`){let e=ke(t.pageUrl),n=x(t.faviconUrl),r=x(t.faviconUrlDark);if(e)return{_tag:`website`,pageUrl:e,...n?{faviconUrl:n}:{},...r?{faviconUrlDark:r}:{}}}if(t?._tag===`native-app`){let e=Ae(t.app);if(e)return{_tag:`native-app`,app:e}}if(t?._tag===`themed-logo`){let e=x(t.logoUrl),n=x(t.logoUrlDark);if(e)return{_tag:`themed-logo`,logoUrl:e,...n?{logoUrlDark:n}:{}}}}function Me(e){let t=y(e),n=b(t?.key,512),r=b(t?.name,160),i=t?.kind;if(!n||!r||i!==`browser`&&i!==`computer`&&i!==`integration`)return;let a=je(t?.icon);return{key:n,name:r,kind:i,...a?{icon:a}:{}}}function Ne(e){let t=y(e),n=Me(t?.toolSource),r=t?.toolSurface===`browser`||t?.toolSurface===`computer`?t.toolSurface:n?.kind===`computer`||n?.kind===`browser`?n.kind:t?.type===`dynamic_tool`?pe(typeof t.toolName==`string`?t.toolName:void 0,t.input):void 0,i=r===`computer`&&n?.kind!==`computer`?fe:n,a=je(t?.toolIcon),o=b(t?.viewedImagePath,4096);return{...r?{toolSurface:r}:{},...a?{toolIcon:a}:{},...i?{toolSource:i}:{},...o&&!/[\r\n]/.test(o)&&g(o)?{viewedImagePath:o}:{}}}var Pe=`2026-01-26`,S=`p4McpApp`,Fe=80,Ie=2e3,Le=32,Re=256,ze=256,Be=4096,Ve=/^(?:https?|wss?):\/\/(?:\*\.)?[a-z0-9-]+(?:\.[a-z0-9-]+)*(?::\d{1,5})?$/i;function He(e){if(!Array.isArray(e))return;let t=e.filter(e=>typeof e==`string`&&e.length<=Re&&Ve.test(e)).slice(0,Le);return t.length===0?void 0:t}function Ue(e){if(!n(e))return;let t={};for(let n of[`connectDomains`,`resourceDomains`,`frameDomains`,`baseUriDomains`]){let r=He(e[n]);r!==void 0&&(t[n]=r)}return Object.keys(t).length===0?void 0:t}var We=[`camera`,`microphone`,`geolocation`,`clipboardWrite`];function Ge(e){if(!n(e))return;let t={};for(let r of We)n(e[r])&&(t[r]={});return Object.keys(t).length===0?void 0:t}var C=e=>typeof e==`string`&&e.trim()!==``&&e.length<=ze?e:void 0;function Ke(e){if(!n(e))return;let t=C(e.attachmentId),r=C(e.server),i=C(e.tool),a=typeof e.resourceUri==`string`&&e.resourceUri.length<=Be?e.resourceUri:void 0;if(t===void 0||r===void 0||i===void 0||a===void 0||!a.startsWith(`ui://`))return;let o=Ue(e.csp),s=Ge(e.permissions);return{attachmentId:t,server:r,tool:i,resourceUri:a,...o===void 0?{}:{csp:o},...s===void 0?{}:{permissions:s},...typeof e.prefersBorder==`boolean`?{prefersBorder:e.prefersBorder}:{}}}function qe(e,t){return e.attachmentId===t.attachmentId&&e.server===t.server&&e.tool===t.tool&&e.resourceUri===t.resourceUri}function Je(e){let t=[];return e?.camera&&t.push(`camera`),e?.microphone&&t.push(`microphone`),e?.geolocation&&t.push(`geolocation`),e?.clipboardWrite&&t.push(`clipboard-write`),t.join(`; `)}function Ye(e){return Number.isFinite(e)?Math.round(Math.min(Ie,Math.max(Fe,e))):320}function Xe(e){return`${e.tool.replace(/[^\w.-]+/g,`-`).slice(0,80)||`app`}.html`}function w(e,t,n=`p4-code`,r=`${e[0]} ${e[3]}`){return{displayName:r,labels:e,icon:n,summaryAction:t}}var Ze=new Set([`p4-code`,`p4_code`,`p4code`]),T={p4_computer_use:w([`Control`,`Controlling`,`Controlled`,`a computer`],`browser`,`browser`),p4_computer_use_reset:w([`Reset`,`Resetting`,`Reset`,`Computer Use`],`browser`,`browser`),p4_computer_use_hosts:w([`List`,`Listing`,`Listed`,`Computer Use hosts`],`browser`,`browser`),p4_decide:w([`Ask`,`Asking`,`Asked`,`Decisions`],`decide`),link_pull_request:w([`Link`,`Linking`,`Linked`,`a pull request`],`link-pr`,`pull-request`),unlink_pull_request:w([`Unlink`,`Unlinking`,`Unlinked`,`a pull request`],`unlink-pr`,`pull-request`),list_thread_pull_requests:w([`Check`,`Checking`,`Checked`,`linked pull requests`],`list-prs`,`pull-request`),watch_pull_request:w([`Watch`,`Watching`,`Watching`,`a pull request`],`watch-pr`,`pull-request`),unwatch_pull_request:w([`Stop watching`,`Stopping watching`,`Stopped watching`,`a pull request`],`unwatch-pr`,`pull-request`),write_pull_request_guides:w([`Write`,`Writing`,`Started`,`review guides`],`write-pr-guides`,`pull-request`),read_pull_request_guide:w([`Read`,`Reading`,`Read`,`a review guide`],`read-pr-guide`,`pull-request`),orchestrator_capabilities:w([`Get`,`Getting`,`Got`,`orchestration capabilities`],`capabilities`),delegate_task:w([`Delegate`,`Delegating`,`Delegated`,`a child task`],`delegate`),task_status:w([`Get`,`Getting`,`Got`,`delegated task status`],`task-status`),task_cancel:w([`Cancel`,`Canceling`,`Requested cancellation of`,`delegated task`],`task-cancel`),schedule_task:w([`Schedule`,`Scheduling`,`Scheduled`,`a recurring task`],`schedule-create`),list_scheduled_tasks:w([`List`,`Listing`,`Listed`,`scheduled tasks`],`schedule-list`),update_scheduled_task:w([`Update`,`Updating`,`Updated`,`a scheduled task`],`schedule-update`),delete_scheduled_task:w([`Delete`,`Deleting`,`Requested deletion of`,`a scheduled task`],`schedule-delete`),request_secret:w([`Ask for`,`Asking for`,`Asked for`,`a secret`],`secret-request`),create_threads:w([`Create`,`Creating`,`Created`,`P4 threads`],`thread-create`),p4_thread_start:w([`Start`,`Starting`,`Started`,`a P4 Code thread`],`thread-create`),p4_thread_list:w([`List`,`Listing`,`Listed`,`P4 threads`],`thread-list`),p4_thread_read:w([`Read`,`Reading`,`Read`,`a P4 Code thread`],`thread-read`),p4_thread_send:w([`Send`,`Sending`,`Sent`,`to a P4 Code thread`],`thread-send`),p4_thread_wait:w([`Wait`,`Waiting`,`Waited`,`for a P4 Code thread`],`thread-wait`),p4_workflow_stop:w([`Stop`,`Stopping`,`Requested a stop for`,`a workflow`],`workflow-stop`),p4_thread_interrupt:w([`Interrupt`,`Interrupting`,`Requested an interrupt of`,`a P4 Code thread`],`thread-interrupt`),p4_worktree_handoff:w([`Hand off`,`Handing off`,`Handed off`,`thread to a git worktree`],`worktree-handoff`),p4_worktree_status:w([`Get`,`Getting`,`Got`,`thread worktree status`],`worktree-status`),preview_status:w([`Get`,`Getting`,`Got`,`preview browser status`],`browser`,`browser`),preview_open:w([`Open`,`Opening`,`Opened`,`a page in the preview browser`],`browser`,`browser`),preview_navigate:w([`Navigate`,`Navigating`,`Navigated`,`the preview browser`],`browser`,`browser`),preview_dialog:w([`Respond`,`Responding`,`Responded`,`to a preview browser dialog`],`browser`,`browser`),preview_snapshot:w([`Take a snapshot of`,`Taking a snapshot of`,`Took a snapshot of`,`the preview page`],`browser`,`browser`,`Snapshot the preview page`),preview_act:w([`Use`,`Using`,`Used`,`the preview browser`],`browser`,`browser`),preview_click:w([`Click`,`Clicking`,`Clicked`,`in the preview browser`],`browser`,`browser`),preview_press:w([`Press`,`Pressing`,`Pressed`,`a key in the preview browser`],`browser`,`browser`),preview_type:w([`Type`,`Typing`,`Typed`,`in the preview browser`],`browser`,`browser`),preview_hover:w([`Hover`,`Hovering`,`Hovered`,`in the preview browser`],`browser`,`browser`),preview_select:w([`Choose`,`Choosing`,`Chose`,`an option in the preview browser`],`browser`,`browser`),preview_drag:w([`Drag`,`Dragging`,`Dragged`,`in the preview browser`],`browser`,`browser`),preview_upload:w([`Upload`,`Uploading`,`Uploaded`,`files to the preview browser`],`browser`,`browser`),preview_scroll:w([`Scroll`,`Scrolling`,`Scrolled`,`the preview browser`],`browser`,`browser`),preview_resize:w([`Resize`,`Resizing`,`Resized`,`the preview browser`],`browser`,`browser`),preview_evaluate:w([`Evaluate`,`Evaluating`,`Evaluated`,`script in the preview browser`],`browser`,`browser`),preview_wait_for:w([`Wait`,`Waiting`,`Waited`,`for the preview page`],`browser`,`browser`),preview_set_appearance:w([`Set`,`Setting`,`Set`,`preview browser appearance`],`browser`,`browser`),preview_recording_start:w([`Start`,`Starting`,`Started`,`recording the preview browser`],`browser`,`browser`),preview_recording_stop:w([`Stop`,`Stopping`,`Stopped`,`recording the preview browser`],`browser`,`browser`),device_list:w([`List`,`Listing`,`Listed`,`simulators and emulators`],`device`,`device`),device_open:w([`Open`,`Opening`,`Opened`,`a device in the Device panel`],`device`,`device`),device_screenshot:w([`Take a screenshot of`,`Taking a screenshot of`,`Took a screenshot of`,`the device`],`device`,`device`),device_close:w([`Close`,`Closing`,`Closed`,`a device`],`device`,`device`),run_scheduled_task_now:w([`Run`,`Running`,`Requested a run of`,`a scheduled task`],`schedule-run`),p4_queue:w([`Manage`,`Managing`,`Managed`,`queued messages`],`queue-edit`),p4_pending_request:w([`Handle`,`Handling`,`Handled`,`pending requests`],`question-respond`),p4_queue_list:w([`List`,`Listing`,`Listed`,`queued messages`],`queue-list`),p4_queue_read:w([`Read`,`Reading`,`Read`,`a queued message`],`queue-read`),p4_queue_edit:w([`Edit`,`Editing`,`Edited`,`a queued message`],`queue-edit`),p4_queue_cancel:w([`Cancel`,`Canceling`,`Requested cancellation of`,`a queued run`],`queue-cancel`),p4_queue_reorder:w([`Reorder`,`Reordering`,`Reordered`,`a queued run`],`queue-reorder`),p4_queue_promote_to_steer:w([`Steer with`,`Steering with`,`Requested steering with`,`a queued message`],`queue-steer`),p4_pending_request_list:w([`List`,`Listing`,`Listed`,`pending requests`],`question-list`),p4_pending_request_read:w([`Read`,`Reading`,`Read`,`pending requests`],`question-read`),p4_pending_request_respond:w([`Respond to`,`Responding to`,`Responded to`,`pending requests`],`question-respond`),p4_thread_diff:w([`Read`,`Reading`,`Read`,`a thread diff`],`thread-read`),p4_thread_configuration:w([`Read`,`Reading`,`Read`,`thread configuration`],`thread-configuration`),p4_thread_configure:w([`Use`,`Using`,`Used`,`thread model settings`],`thread-configure`),p4_thread_transfer:w([`Use`,`Using`,`Used`,`thread transfers`],`thread-fork`),p4_thread_fork:w([`Fork`,`Forking`,`Requested a fork of`,`this thread`],`thread-fork`),p4_thread_merge_back:w([`Merge`,`Merging`,`Requested a merge of`,`thread context`],`thread-merge`),p4_thread_search:w([`Search`,`Searching`,`Searched`,`thread content`],`thread-search`),p4_thread_transfers:w([`Read`,`Reading`,`Read`,`thread transfers`],`thread-transfers`),p4_thread_organize:w([`Organize`,`Organizing`,`Organized`,`a thread`],`thread-organize`),p4_thread_update:w([`Update`,`Updating`,`Updated`,`P4 Code thread metadata`],`thread-update`),p4_worktree_list:w([`List`,`Listing`,`Listed`,`workspace branches`],`worktree-list`),p4_preview_list:w([`List`,`Listing`,`Listed`,`preview tabs`],`browser`,`browser`),p4_preview_close:w([`Close`,`Closing`,`Closed`,`a preview tab`],`browser`,`browser`),p4_environment_read:w([`Read`,`Reading`,`Read`,`environment preferences`],`environment-read`),p4_environment_links:w([`List`,`Listing`,`Listed`,`linked environments`],`environment-links`),p4_environment_link:w([`Ask to link`,`Asking to link`,`Asked to link`,`an environment`],`environment-link`),p4_environment_unlink:w([`Forget`,`Forgetting`,`Forgot`,`a linked environment`],`environment-unlink`),p4_environment_preferences_update:w([`Update`,`Updating`,`Updated`,`environment preferences`],`environment-update`),p4_mcp_server_list:w([`List`,`Listing`,`Listed`,`MCP servers`],`environment-read`),p4_mcp_server_set_enabled:w([`Update`,`Updating`,`Updated`,`an MCP server`],`environment-update`),p4_thread_launch:w([`Launch`,`Launching`,`Launched`,`a project thread`],`thread-create`),p4_project_list:w([`List`,`Listing`,`Listed`,`projects`],`project-list`),p4_project_read:w([`Read`,`Reading`,`Read`,`a project`],`project-read`),p4_project_create:w([`Register`,`Registering`,`Registered`,`a project`],`project-create`),p4_project_update:w([`Update`,`Updating`,`Updated`,`a project`],`project-update`),p4_project_delete:w([`Delete`,`Deleting`,`Deleted`,`a project`],`project-delete`),p4_project_clone:w([`Clone`,`Cloning`,`Cloned`,`a repository`],`project-clone`),p4_attachment_prepare_upload:w([`Prepare`,`Preparing`,`Prepared`,`an attachment upload`],`attachment-prepare`),p4_attachment_discard:w([`Discard`,`Discarding`,`Discarded`,`a pending attachment`],`attachment-discard`),p4_thread_send_attachments:w([`Send`,`Sending`,`Sent`,`attachments`],`attachment-send`),html_preview:w([`Preview`,`Previewing`,`Previewed`,`an HTML page`],`html-preview`),html_render:w([`Render`,`Rendering`,`Rendered`,`an HTML page`],`html-render`)};new Set(Object.keys(T));function Qe(e){return e.replace(/\s+(?:complete|completed)\s*$/i,``).trim()}function E(e){let t=Qe(e),n=/^mcp__(?<server>.+?)__(?<tool>.+)$/i.exec(t);if(n?.groups){let{server:e,tool:t}=n.groups;return e!==void 0&&t!==void 0&&Ze.has(e.toLowerCase())?t:null}let r=/^(?<server>p4[-_]?code)(?:[.:/]|\s*·\s*)(?<tool>.+)$/i.exec(t);if(r?.groups)return r.groups.tool??null;let i=/^(?:mcp[-_]{1,2})?p4[-_ ]?code(?:__|[-_.:/ ])(?<tool>.+)$/i.exec(t)?.groups?.tool??t;if(Object.hasOwn(T,i))return i;if(!/^p4-code-/i.test(t))return null;let a=null;for(let e of Object.keys(T))t.endsWith(`_${e}`)&&e.length>(a?.length??0)&&(a=e);return a}function $e(e){let t=e==null?null:E(e);return t!==null&&Object.hasOwn(T,t)?t:null}var et=e=>typeof e==`object`&&e?e:void 0,tt={preview_act:e=>`preview_${e}`,p4_queue:e=>`p4_queue_${e}`,p4_pending_request:e=>`p4_pending_request_${e}`,p4_thread_transfer:e=>({fork:`p4_thread_fork`,merge_back:`p4_thread_merge_back`,status:`p4_thread_transfers`})[e]};function D(e,t){let n=e==null?null:E(e);if(n===null||!Object.hasOwn(T,n))return null;let r=et(t)?.action,i=typeof r==`string`?tt[n]?.(r):void 0;return i!==void 0&&Object.hasOwn(T,i)?T[i]:T[n]}var nt={p4_thread_configure:({modelSelection:e})=>e===void 0?`thread-configuration`:`thread-configure`,schedule_task:({scheduledTaskId:e})=>e===void 0?`schedule-create`:`schedule-update`};function rt(e,t){let n=D(e,t);if(n===null)return null;let r=nt[E(e)??``],i=et(t);return(i&&r?.(i))??n.summaryAction}var it=16384,at=8192,ot=256,st=100,ct=32,lt=4,ut=128,dt=new TextEncoder;function O(e,t,r=0){if(r>lt||t.remainingNodes--<=0)return t.exceeded=!0,{failed:!1};if(typeof e==`string`){if(e.length>t.remainingBytes)return t.exceeded=!0,{failed:!1};let n=dt.encode(e).byteLength;if(n>t.remainingBytes)return t.exceeded=!0,{failed:!1};t.remainingBytes-=n;try{return O(JSON.parse(e),t,r+1)}catch{return{failed:!1}}}if(Array.isArray(e)){if(e.length>ct)return t.exceeded=!0,{failed:!1};let i,a=!1;for(let o of e){let e=n(o)?o.text:void 0,s=O(n(e)?e.text??e:e,t,r+1);if(i??=s.data,a||=s.failed,t.exceeded)break}return{...i===void 0?{}:{data:i},failed:a}}if(!n(e))return{failed:!1};let i=e.isError===!0||e.is_error===!0||e._tag===`OrchestratorMcpFailure`||e.error!=null,a=e.structuredContent??e.content;if(a!==void 0){let e=O(a,t,r+1);return{...e,failed:i||e.failed}}return{data:e,failed:i}}function k(e){if(!(typeof e!=`string`||e.length>ot||e.trim()===``))return Array.from(e).join(``)}function A(e){let t={remainingBytes:it,remainingNodes:ut,exceeded:!1},r=O(e,t),i=r.failed?{isError:!0}:{},a=t.exceeded?void 0:r.data;if(a!==void 0){for(let e of[`threadId`,`messageId`,`taskId`,`scheduledTaskId`]){let t=k(a[e]);t!==void 0&&(i[e]=t)}a.status===`rolled_back`&&(i.status=`rolled_back`);let e=oe(a.htmlRender);e!==void 0&&(i.htmlRender=e);let t=Ke(a[S]);t!==void 0&&(i[S]=t);let r=n(a.thread)?k(a.thread.threadId):void 0;if(r!==void 0&&(i.thread={threadId:r}),Array.isArray(a.threads)){let e=a.threads.length<=st,t=[];if(e)for(let r of a.threads){if(!n(r)){e=!1;break}let i=k(r.threadId),a=r.status===`rolled_back`;if(i===void 0&&!a){e=!1;break}t.push({...i===void 0?{}:{threadId:i},...a?{status:`rolled_back`}:{}})}e?i.threads=t:(delete i.threadId,delete i.status)}}let o=()=>dt.encode(JSON.stringify(i)).byteLength>at;o()&&(delete i.threads,delete i.threadId,delete i.status);let s=i[S];if(s?.csp!==void 0&&o()){let{csp:e,...t}=s;i[S]=t}return o()&&delete i[S],Object.keys(i).length===0?void 0:i}function ft(e){if($e(e.toolName)!==`html_render`)return;let t=A(e.output);return t?.isError?void 0:t?.htmlRender}function pt(e){let t=A(e.output)?.[S];return t!==void 0&&e.toolName===`${t.server}.${t.tool}`?t:void 0}function mt(e){return/file not found|no files found|enoent|no such file|commandnotfoundexception|command not found|is not recognized as the name of a cmdlet|a parameter cannot be found that matches parameter name/i.test(e)||/cannot find path/i.test(e)&&/because it does not exist/i.test(e)||/is not recognized/i.test(e)&&/the term '/i.test(e)||/<exited with exit code\s+[1-9]\d*\s*>/i.test(e)||/exit(?:ed)? with exit code\s+[1-9]\d*/i.test(e)||/exit code\s*[:\s]\s*[1-9]\d*\b/i.test(e)}function j(e){if(!n(e)||e.type!==`image`)return null;let t=n(e.source)?e.source:void 0;if(t!==void 0&&t.type!==`base64`)return null;let r=t===void 0?e.mimeType:t.media_type,i=t===void 0?e.data:t.data;if(typeof r!=`string`||!m(r))return null;let a={mimeType:r.toLowerCase()};return typeof i==`string`?{...a,data:i}:a}function ht(e){return Array.isArray(e)?e:n(e)&&Array.isArray(e.content)?e.content:[e]}Math.ceil(ee/3)*4;function gt(e){let t=[];for(let n of ht(e))if(j(n)!==null&&(t.push(n),t.length===8))break;return t}function _t(e){return gt(e).flatMap(e=>j(e)??[])}var vt=4;function M(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function yt(e){return M(e)&&e.truncated===!0&&typeof e.summary==`string`}function N(e,t){if(t>vt)return null;if(typeof e==`string`)return e;if(Array.isArray(e)){let n=e.map(e=>N(e,t+1));return n.every(e=>e!==null)?n.filter(e=>e!==``).join(`
2
+ `):null}if(!M(e))return null;if(e.type===`text`&&typeof e.text==`string`)return e.text;if(e.type===`image`)return j(e)?``:`[image]`;if(e.type===`resource_link`&&typeof e.uri==`string`)return e.uri;if(e.type===`resource`&&M(e.resource)){let t=e.resource;if(typeof t.text==`string`)return t.text;if(typeof t.uri==`string`)return t.uri}let n=Object.keys(e).filter(e=>e!==`isError`&&e!==`is_error`);if(n.length===1&&n[0]===`content`)return N(e.content,t+1);if(n.length===2&&n.includes(`content`)&&n.includes(`structuredContent`)){let n=N(e.content,t+1);return n?.trim()?n:null}return null}function P(e){try{return JSON.parse(e)}catch{return}}function bt(e){let t=e.trim();if(!/^[[{]/.test(t))return e;let n=P(t);if(n!==void 0)return JSON.stringify(n,null,2);let r=t.split(`
3
+ `).filter(e=>e.trim()).map(e=>P(e.trim()));return r.some(e=>e===void 0)?e:r.map(e=>JSON.stringify(e,null,2)).join(`
4
+
5
+ `)}function xt(e,t=!1){if(e==null||t&&M(e)&&e.type===`image`)return null;let n=N(e,0);if(n!==null)return n.trim()?bt(n):null;let r;try{r=JSON.stringify(e,null,2)}catch{return String(e)}return r===void 0||r===`{}`||r===`[]`?null:r}function F(e){if(e.command!==void 0)return{command:e.command.trim()||null,args:null,argsText:null};let t=e.args;if(M(t)&&!yt(t)){let e=Object.entries(t).flatMap(([e,t])=>t===void 0?[]:[[e,typeof t==`string`&&t!==``?t:JSON.stringify(t)??String(t)]]);return{command:null,args:e.length>0?e:null,argsText:null}}return{command:null,args:null,argsText:xt(t)}}function St(e){return e.command!==null||e.args!==null||e.argsText!==null}var Ct=new Set([`idle`,`pending`,`running`,`waiting`]);function wt(e){return Ct.has(e.status)?`live`:t(e.updatedAt)}function Tt(e){switch(e.type){case`command_execution`:return e.outputOmitted===!0;case`dynamic_tool`:return e.outputOmitted===!0||yt(e.input);default:return!1}}function Et(e){if(!e.trimStart().startsWith(`{"stdout"`))return e;let t=P(e.trim());return!M(t)||typeof t.stdout!=`string`||typeof t.stderr!=`string`||typeof t.interrupted!=`boolean`?e:[t.stdout,t.stderr].filter(e=>typeof e==`string`&&e.trim().length>0).join(`
6
+ `)}function Dt(e){switch(e.type){case`command_execution`:return e.output?.trim()&&Et(e.output)||null;case`dynamic_tool`:return e.outputOmitted===!0?null:xt(e.output,e.viewedImagePath!==void 0);case`file_search`:return e.results?.length?e.results.map(e=>[`${e.fileName}${e.line===void 0?``:`:${e.line}`}`,e.preview?.trim()].filter(Boolean).join(`
7
+ `)).join(`
8
+ `):null;case`web_search`:return e.results?.length?e.results.map(e=>[e.title?.trim()||e.url,e.title?e.url:void 0,e.snippet?.trim()].filter(Boolean).join(`
9
+ `)).join(`
10
+
11
+ `):null;default:return null}}function Ot(e){return e.type!==`dynamic_tool`||e.outputOmitted===!0?[]:_t(e.output).map((t,n)=>({_tag:`tool-output-image`,threadId:e.threadId,itemId:e.id,index:n}))}function kt(e){switch(e.type){case`reasoning`:return e.text.trim().length>0;case`command_execution`:return F({command:e.input}).command!==null||e.outputOmitted===!0||!!e.output?.trim()||e.exitCode!==void 0&&e.exitCode!==0;case`file_change`:case`checkpoint`:case`fork`:case`handoff`:return!0;case`file_search`:return(e.results?.length??0)>0||!!e.pattern?.trim();case`web_search`:return(e.results?.length??0)>0||(e.patterns?.length??0)>0;case`dynamic_tool`:return e.outputOmitted===!0||St(F({args:e.input}));case`approval_request`:return!!e.prompt?.trim();case`user_input_request`:return e.questions.length>0;case`notification`:return!!e.detail?.trim();case`system_notice`:return e.message.trim().length>0;case`error`:return e.failure.message.trim().length>0;case`proposed_plan`:return e.markdown.trim().length>0;case`todo_list`:return e.steps.length>0;case`subagent`:return e.childThreadId!==null;default:return!1}}var At=64,jt=new Set([`sh`,`bash`,`zsh`,`dash`,`ash`,`ksh`,`fish`]),Mt=new Set([`cmd`,`cmd.exe`,`powershell`,`powershell.exe`,`pwsh`,`pwsh.exe`]),Nt=new Set([`-o`,`-O`,`--rcfile`,`--init-file`]),Pt=new Set([`builtin`,`command`,`exec`]),Ft=new Set([`nocorrect`,`noglob`,`time`]),It=new Set([`pop-location`,`push-location`,`set-location`]),Lt=new Set([`-mta`,`-nologo`,`-noninteractive`,`-noprofile`,`-sta`]),Rt=new Set([`-configurationname`,`-executionpolicy`,`-inputformat`,`-outputformat`,`-version`,`-windowstyle`,`-workingdirectory`]),zt=new Set([`-confirm`,`-debug`,`-loaduserprofile`,`-nonewwindow`,`-passthru`,`-usenewenvironment`,`-verbose`,`-wait`,`-whatif`]),Bt=new Set([`-argumentlist`,`-credential`,`-environment`,`-erroraction`,`-errorvariable`,`-informationaction`,`-informationvariable`,`-outbuffer`,`-outvariable`,`-pipelinevariable`,`-progressaction`,`-redirectstandarderror`,`-redirectstandardinput`,`-redirectstandardoutput`,`-verb`,`-warningaction`,`-warningvariable`,`-windowstyle`,`-workingdirectory`]),Vt=new Set([`[`,`[[`,`test`,`true`]),Ht="<>(){}[];|&$`#!%@:",Ut="){]}`",I=new Set(`!,#,.,:,[,[[,alias,and,autoload,begin,bg,bind,bindkey,break,builtin,caller,case,catch,cd,command,compgen,complete,compopt,continue,coproc,declare,dirs,disown,do,done,elif,else,enable,end,esac,eval,exec,exit,export,false,fc,fg,fi,finally,for,foreach,function,getopts,history,if,in,jobs,let,local,logout,mapfile,nocorrect,noglob,not,or,popd,pushd,read,readarray,readonly,repeat,return,select,set,setopt,shift,shopt,source,switch,suspend,test,then,time,times,trap,try,true,type,typeset,ulimit,umask,unalias,until,unset,unsetopt,wait,while`.split(`,`)),Wt=new Set(`and.begin.break.case.catch.continue.coproc.do.done.elif.else.end.esac.eval.exec.exit.false.fi.finally.for.foreach.function.if.in.not.or.repeat.return.select.switch.then.try.until.while`.split(`.`));function Gt(e,t){for(let n=t;n<e.length;n+=1){let t=e[n];if(t===`--`||!t.startsWith(`-`))return null;if(Nt.has(t))n+=1;else if(t===`--command`||/^-[a-zA-Z]*c[a-zA-Z]*$/.test(t))return n+1}return null}var Kt={env:new Set([`-C`,`--chdir`,`-S`,`--split-string`,`-u`,`--unset`]),sudo:new Set([`-C`,`--close-from`,`-D`,`--chdir`,`-g`,`--group`,`-u`,`--user`])},qt={env:new Set([`-0`,`--null`,`-i`,`--ignore-environment`,`--debug`,`-v`]),sudo:new Set([`-A`,`--askpass`,`-b`,`--background`,`-E`,`-H`,`-i`,`-n`,`-S`])};function L(e){let t=e.trim(),n=[],r=``,i=null,a=!1,o=!1,s=0,c=0,l=!1;for(let e=0;e<t.length;e+=1){let u=t[e];if(a)r+=u,a=!1,l=!0;else if(u===`\\`&&i!==`'`){let n=t[e+1],o=i===null&&/^(?:[A-Za-z]:|\.{1,2})(?:\\[^\s]*)?$/u.test(r);if((i===`"`||o)&&n!==void 0&&n!==`"`&&n!==`\\`&&n!==`$`&&n!=="`"&&n!==`
12
+ `){r+=u,l=!0;continue}a=!0,l=!0}else if(o)r+=u,u==="`"&&(o=!1),l=!0;else if(i!==null)u===i?i=null:r+=u,l=!0;else if(u==="`")r+=u,o=!0,l=!0;else if(u===`$`&&t[e+1]===`{`)r+="${",c+=1,l=!0,e+=1;else if(u===`{`&&c>0)r+=u,c+=1,l=!0;else if(u===`}`&&c>0)r+=u,--c,l=!0;else if(u===`$`&&t[e+1]===`(`)r+=`$(`,s+=1,l=!0,e+=1;else if(u===`(`)r+=u,s+=1,l=!0;else if(u===`)`&&s>0)r+=u,--s,l=!0;else if(u===`"`||u===`'`)i=u,l=!0;else if(/\s/u.test(u)){if(s>0||c>0){r+=u,l=!0;continue}l&&=(n.push(r),r=``,!1)}else r+=u,l=!0}return i!==null||a||o||s>0||c>0?null:(l&&n.push(r),n)}function Jt(e,t,n){let r=``,i=0;for(let a of n){if(a.start>=t)break;r+=e.slice(i,a.start),i=Math.min(a.end,t)}return r+e.slice(i,t)}function Yt(e,t,n){let r=t;for(;e[r]===` `||e[r]===` `;)r+=1;let i=``,a=null,o=!1;for(;r<e.length;r+=1){let t=e[r];if(o)i+=t,o=!1;else if(t===`\\`&&a!==`'`)o=!0;else if(a!==null)t===a?a=null:i+=t;else if(t===`"`||t===`'`)a=t;else{if(/\s/u.test(t)||`;&|<>()`.includes(t))break;i+=t}}return!i||a!==null||o?null:{heredoc:{delimiter:i,stripTabs:n},end:r}}function Xt(e,t,n){let r=t;for(let t of n){let n=!1;for(;r<=e.length;){let i=e.indexOf(`
13
+ `,r),a=i===-1?e.length:i,o=e.slice(r,a).replace(/\r$/u,``),s=t.stripTabs?o.replace(/^\t+/u,``):o;if(r=i===-1?e.length:i+1,s===t.delimiter){n=!0;break}if(i===-1)break}if(!n)return null}return e.slice(r).trim()||null}function R(e){let t=null,n=null,r=!1,i=!1,a=!1,o=0,s=0,c=[],l=[],u=0,d=null;for(let f=0;f<e.length;f+=1){let p=e[f];if(n!==null){p===n&&e[f+1]===`@`&&(f===0||e[f-1]===`
14
+ `)&&(n=null,f+=1);continue}if(a){if(p!==`
15
+ `)continue;a=!1,l.push({start:u,end:f})}if(r){r=!1;continue}if(p===`\\`&&t!==`'`){r=!0;continue}if(i){p==="`"&&(i=!1);continue}if(t!==null){p===t&&(t=null);continue}if(p===`@`&&(e[f+1]===`"`||e[f+1]===`'`)&&(e[f+2]===`
16
+ `||e[f+2]===`\r`&&e[f+3]===`
17
+ `)){n=e[f+1],f+=1;continue}if(p===`"`||p===`'`){t=p;continue}if(p==="`"){i=!0;continue}if(p===`#`&&(f===0||/\s/u.test(e[f-1])||`;&|(`.includes(e[f-1]))){a=!0,u=f;continue}if(p===`$`&&e[f+1]===`{`){s+=1,f+=1;continue}if(p===`{`&&s>0){s+=1;continue}if(p===`}`&&s>0){--s;continue}if(p===`(`){o+=1;continue}if(p===`)`&&o>0){--o;continue}if(o>0||s>0)continue;if(p===`<`&&e[f+1]===`<`&&e[f+2]!==`<`){let t=e[f+2]===`-`,n=Yt(e,f+(t?3:2),t);if(n===null)return{firstCommand:e.trim(),remainingCommand:null,separator:null};c.push(n.heredoc),f=n.end-1;continue}let m=p===`&`&&e[f+1]===`&`||p===`|`&&(e[f+1]===`|`||e[f+1]===`&`),ee=p===`&`&&(e[f-1]===`>`||e[f-1]===`<`||e[f+1]===`>`);if(!m&&!`;&|
18
+ `.includes(p)||ee)continue;if(p===`
19
+ `&&c.length>0){let t=d;return{firstCommand:Jt(e,t?.index??f,l).trimStart(),remainingCommand:[t?e.slice(t.index+t.length,f).trim():``,Xt(e,f+1,c)].filter(e=>!!e).join(`
20
+ `)||null,separator:t?e.slice(t.index,t.index+t.length):`
21
+ `}}if(c.length>0){d??={index:f,length:m?2:1},m&&(f+=1);continue}let te=Jt(e,f,l).trimStart(),h=f+(m?2:1);for(;/\s/u.test(e[h]??``);)h+=1;return{firstCommand:te,remainingCommand:e.slice(h).trim()||null,separator:m?e.slice(f,f+2):p}}return a&&l.push({start:u,end:e.length}),{firstCommand:Jt(e,e.length,l).trim(),remainingCommand:null,separator:null}}function Zt(e){let t=e.trimStart();for(;t.startsWith(`#`);){let e=t.indexOf(`
22
+ `);if(e===-1)return null;t=t.slice(e+1).trimStart()}return t||null}function Qt(e){let t=``,n=null,r=!1;for(let i=0;i<e.length;i+=1){let a=e[i];if(r)t+=a,r=!1;else if(a===`\\`&&n!==`'`){if(e[i+1]===`
23
+ `){i+=1;continue}if(e[i+1]===`\r`&&e[i+2]===`
24
+ `){i+=2;continue}t+=a,r=!0}else n===null?(a===`"`||a===`'`)&&(n=a):a===n&&(n=null),t+=a}return t}function $t(e,t){let n=e[t];if(!n||/^[<>]\(/u.test(n))return null;let r=n.match(/^(?:(?:(?:\d+|\*|\{[A-Za-z_][A-Za-z0-9_]*\})?(?:<<<|<<-|<<|<>|>>|>\||<&|>&|<|>))|&>>|&>)(.*)$/u);return r?r[1]?t+1:e[t+1]===void 0?e.length+1:t+2:null}function en(e){return e.map(e=>`'${e.replaceAll(`'`,`'\\''`)}'`).join(` `)}function tn(e,t,n){if(e===`bundle`)return t[n+1]===`exec`&&t[n+2]!==void 0?n+2:null;if(e===`nohup`){let e=n+1;t[e]===`--`&&(e+=1);let r=t[e];return r&&!r.startsWith(`-`)?e:null}return e===`script`?/^-[adkpqr]+$/u.test(t[n+1]??``)&&t[n+3]!==void 0?n+3:null:e===`arch`?/^-(?:arm64|arm64e|i386|x86_64)$/u.test(t[n+1]??``)?t[n+2]===void 0?null:n+2:t[n+1]===`-arch`&&t[n+3]!==void 0?n+3:null:(e===`timeout`||e===`gtimeout`)&&/^(?:\d+(?:\.\d*)?|\.\d+)[smhd]?$/u.test(t[n+1]??``)&&t[n+2]!==void 0?n+2:null}function z(e){let t=e.trim();if(!t||/^[A-Za-z][A-Za-z0-9+.-]*:(?![\\/])/u.test(t))return null;let n=t.split(/[\\/]/u).at(-1);return!n||/\s/u.test(n)&&!/[\\/]/u.test(t)||Ht.includes(n[0]??``)||Ut.includes(n.at(-1)??``)?null:n}function nn(e){let t=e.trimStart(),n=t[0];if(n!==`"`&&n!==`'`)return z(t.match(/^\S+/u)?.[0]??``);let r=``;for(let e=1;e<t.length;e+=1){let i=t[e];if(i==="`"&&t[e+1]!==void 0)r+=t[e+1],e+=1;else{if(i===n){if(n===`'`&&t[e+1]===`'`){r+=`'`,e+=1;continue}return z(r)}r+=i}}return null}function rn(e){let t=e.match(/^\s*&\s+([\s\S]*)$/u);return t?nn(t[1]):void 0}function an(e,t,n,r){let i=e.match(/^\s*\$(?:(env|global|local|script):)?[A-Za-z_][A-Za-z0-9_]*\s*=\s*([\s\S]*)$/iu);if(!i)return{matched:!1,program:null};if(i[1]?.toLowerCase()===`env`)return{matched:!0,program:n?B(n,t,`shell`,r-1):null};let a=i[2].trim();if(/^(?:\[ordered\]\s*)?@\s*[{(]/iu.test(a))return{matched:!0,program:null};let o=rn(a);if(o!==void 0)return{matched:!0,program:o};let s=a.match(/^(?:@?\(\s*)?([A-Za-z][A-Za-z0-9_.-]*)\b/u)?.[1];return s&&!I.has(s.toLowerCase())?{matched:!0,program:B(a,t+1,`shell`,r)??s}:{matched:!0,program:n?B(n,t,`shell`,r-1):null}}function on(e,t,n,r,i,a,o){let s=e=>e?B(i&&a?`${e} ${a} ${i}`:e,r+1,`shell`,o):null;if(e===`cmd`||e===`cmd.exe`){for(let e=n;e<t.length;e+=1){let n=t[e].toLowerCase();if(n!==`/c`&&n!==`/k`)continue;let r=t[e+1];return{matched:!0,program:s(r)}}return{matched:!1,program:null}}for(let e=n;e<t.length;e+=1){let n=t[e].toLowerCase();if(n===`-command`||n===`-c`){let n=t[e+1];return{matched:!0,program:s(n)}}if(n===`-file`||n===`-f`)return{matched:!0,program:z(t[e+1]??``)};if(n===`-encodedcommand`||n===`-enc`||n===`-e`)return{matched:!0,program:null};if(Rt.has(n))e+=1;else if(!Lt.has(n)&&!n.startsWith(`-`))return{matched:!0,program:z(t[e])}}return{matched:!1,program:null}}function sn(e,t){for(let n=t;n<e.length;n+=1){let t=e[n],r=t.toLowerCase();if(r===`-filepath`)return z(e[n+1]??``);if(!zt.has(r)){if(Bt.has(r)){if(e[n+1]===void 0)return null;n+=1}else return t.startsWith(`-`)?null:z(t)}}return null}function cn(e){let t=e.match(/^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/su);if(!t)return null;let n=t[1],r=t[2].trim();if(!r||/[$`]/u.test(r))return{name:n,program:null};if(r.startsWith(`(`)&&r.endsWith(`)`))r=L(r.slice(1,-1))?.[0]??``;else if(/\s/u.test(r)&&!/[\\/]/u.test(r))return{name:n,program:null};return{name:n,program:z(r)}}function ln(e){let t=e.match(/^\$(?:([A-Za-z_][A-Za-z0-9_]*)|\{([A-Za-z_][A-Za-z0-9_]*)(?:\[@\])?\})$/u);return t?.[1]??t?.[2]??null}function un(e){let t=new Map,n=e,r=0;for(let e=0;n&&e<64;e+=1){let e=Zt(n);if(e===null)return null;let i=R(e),a=L(Qt(i.firstCommand));if(a===null)return null;let o=+(a[0]===`do`||a[0]===`then`);for(;o<a.length;){let e=$t(a,o);if(e!==null&&e<=a.length)o=e;else if(/^[A-Za-z_][A-Za-z0-9_]*\+?=/u.test(a[o]??``))o+=1;else break}let s=ln(a[o]??``),c=s?t.get(s):void 0;if(c)return c;let l=a[0];if((l===`fi`||l===`done`||l===`esac`)&&(r=Math.max(0,r-1)),(l===`if`||l===`for`||l===`while`||l===`until`||l===`select`||l===`case`)&&(r+=1),r===0&&l===`unset`)for(let e of a.slice(1))t.delete(e);let u=+(a[0]===`export`),d=a.slice(u).map(cn);if(r===0&&d.length>0&&d.every(e=>e!==null))for(let e of d)e.program?t.set(e.name,e.program):t.delete(e.name);n=i.remainingCommand}return null}function dn(e,t,n,r,i,a){let o=n;if(e===`command`)for(;o<t.length;){let e=t[o];if(e===`--`){o+=1;break}if(!e.startsWith(`-`)||e===`-`)break;if(e!==`-p`)return null;o+=1}else if(e===`builtin`){if(t[o]===`--`)o+=1;else if(t[o]?.startsWith(`-`))return null}else if(e===`exec`)for(;o<t.length;){let e=t[o];if(e===`--`){o+=1;break}if(e===`-a`){if(t[o+1]===void 0)return null;o+=2}else if(/^-a.+/u.test(e)||/^-[cl]+$/u.test(e))o+=1;else{if(e.startsWith(`-`)&&e!==`-`)return null;break}}let s=t.slice(o);if(s.length===0)return null;let c=0;for(;c<s.length;){let e=$t(s,c);if(e===null||e>s.length)break;c=e}let l=s[c];if(l&&/^[A-Za-z_][A-Za-z0-9_]*\+?=/u.test(l))return null;let u=B(en(s),r+1,e===`exec`?`exec`:`shell`,a);return u===null?e!==`exec`&&l&&l===l.toLowerCase()&&I.has(l)&&!Wt.has(l)&&i?B(i,r,`shell`,a-1):null:u}function fn(e,t,n,r){if(t>=8||r<=0)return null;let i=Zt(e);if(i===null||/^(?:catch|finally|for|foreach|function|if|param|switch|try|while)\s*[{(]/iu.test(i)||/^[A-Za-z_][A-Za-z0-9_]*\s*\(\s*\)\s*\{/u.test(i)||i.startsWith(`[[`))return null;let a=R(i);if(/^@["'](?:\r?\n)/u.test(a.firstCommand.trimStart()))return a.remainingCommand?B(a.remainingCommand,t,`shell`,r-1):null;let o=an(a.firstCommand,t,a.remainingCommand,r);if(o.matched)return o.program;let s=a.firstCommand.match(/^\s*((?:\.{1,2}|%[A-Za-z_][A-Za-z0-9_]*%|\$env:[A-Za-z_][A-Za-z0-9_]*)\\\S+)/iu)?.[1];if(s)return z(s);let c=L(Qt(a.firstCommand));if(c===null)return null;let l=a.firstCommand.trimStart()[0];if(c.length===1&&(l===`"`||l===`'`)&&/[\s()=]/u.test(c[0]??``)&&!/[\\/]/u.test(c[0]??``))return a.remainingCommand?B(a.remainingCommand,t,n,r-1):null;let u=0,d=null,f=n,p=!1,m=!1;for(;u<c.length;){let e=c[u];if(!e)return null;let n=$t(c,u);if(n!==null){if(n>c.length)return null;m=!0,u=n;continue}if(/^[A-Za-z_][A-Za-z0-9_]*\+?=/.test(e)){p=!0,u+=1;continue}if(f===`shell`&&e===`:`)return a.remainingCommand?B(a.remainingCommand,t,f,r-1):null;if(Ht.includes(e[0]??``)&&!(e.startsWith(`$`)&&e.includes(`/`)))return f===`shell`&&e.startsWith(`[`)&&a.remainingCommand?B(a.remainingCommand,t,f,r-1):null;let i=e.split(/[\\/]/).at(-1),o=e===i;if(i===`env`||i===`sudo`){d=i,f=`exec`,u+=1;continue}if(d!==null&&e===`--`){d=null,u+=1;continue}if(d!==null&&e.startsWith(`-`)){if(d===`env`&&(e===`-S`||e===`--split-string`)){let e=c[u+1];return e?B(e,t+1,f,r):null}if(d===`env`&&e.startsWith(`--split-string=`))return B(e.slice(15),t+1,f,r);if(Kt[d].has(e)){if(c[u+1]===void 0)return null;u+=2;continue}if(qt[d].has(e)){u+=1;continue}let n=e.indexOf(`=`);if(e.startsWith(`--`)&&n>2){if(!Kt[d].has(e.slice(0,n)))return null;u+=1;continue}if(/^-[A-Za-z].+/.test(e)&&!e.startsWith(`--`)){let t=!1;for(let[n,r]of e.slice(1).split(``).entries()){let i=`-${r}`;if(Kt[d].has(i)){t=n===e.length-2;break}if(!qt[d].has(i))return null}if(t&&c[u+1]===void 0)return null;u+=t?2:1;continue}return null}if(i&&jt.has(i.replace(/\.exe$/i,``).toLowerCase())){let e=Gt(c,u+1);if(e!==null){let n=c[e];return n?B(n,t+1,`shell`,r):null}}let s=i?.toLowerCase();if(s&&Mt.has(s)){let e=on(s,c,u+1,t,a.remainingCommand,a.separator,r);if(e.matched)return e.program}if(s===`start-process`){let e=sn(c,u+1);if(e!==null)return e}if(f===`shell`&&o&&i&&Ft.has(i)){if(u+=1,i===`time`&&c[u]===`-p`&&(u+=1),c[u]?.startsWith(`-`))return null}else{if(o&&i){let e=tn(i,c,u);if(e!==null){let n=B(en(c.slice(e)),t+1,`exec`,r);if(n!==null)return n}}return o&&i&&Pt.has(i)?dn(i,c,u+1,t,a.remainingCommand,r):(f===`shell`||d===`sudo`&&i&&Vt.has(i))&&o&&i&&I.has(i)&&(!Wt.has(i)||i===`false`&&a.separator!==`&&`)&&a.remainingCommand||f===`shell`&&o&&s&&It.has(s)&&a.remainingCommand?B(a.remainingCommand,t,`shell`,r-1):!i||o&&I.has(i)||Ht.includes(i[0]??``)||Ut.includes(i.at(-1)??``)||i.endsWith(`()`)||/^[A-Za-z_][A-Za-z0-9_]*\(\)\{$/u.test(i)?null:i||null}}return(p||m)&&d===null&&a.remainingCommand?B(a.remainingCommand,t,f,r-1):null}function B(e,t,n,r=At){if(r<=0)return null;let i=rn(e);return i===void 0?fn(e,t,n,r)??(n===`shell`?un(e):null):i}function pn(e,t=0){return B(e,t,`shell`,At)}var mn=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/gu;function hn(e){return yn(bn(e))}var gn=/[a-z][\w+.-]*:\/\/\S+|(?:\b[a-z]:)?[^\s"'`=,;:()<>|&]+/giu;function _n(e){if(e.includes(`://`)||/[*?[{]/u.test(e))return e;let t=e.replaceAll(`\\`,`/`).replace(/\/+$/u,``),n=t.lastIndexOf(`/`);if(n<0)return e;let r=t.slice(n+1);if(!/[a-z]/iu.test(r))return e;let i=/^(?:~|\.{1,2}|[a-z]:)?\//iu.test(t),a=/.\.[a-z0-9]+$/iu.test(r),o=t.split(`/`).length-1;return i||a||o>=2?r:e}function vn(e){return e.replace(gn,_n)}function yn(e){return e.replace(mn,e=>e===``?`␡`:String.fromCharCode(9216+e.charCodeAt(0)))}function bn(e){let t=e.trim();if(R(t).remainingCommand!==null)return t;let n=L(t),r=n?.[0]?.split(/[\\/]/u).at(-1)?.replace(/\.exe$/iu,``);if(!n||!r||!jt.has(r))return t;let i=Gt(n,1);return i===null||i!==n.length-1?t:n[i]?.trim()||t}var xn=new Set([`powershell`,`pwsh`]),Sn=new Set(`Add Approve Assert Backup Block Build Checkpoint Clear Close Compare Complete Compress Confirm Connect Convert ConvertFrom ConvertTo Copy Debug Deny Deploy Disable Disconnect Dismount Edit Enable Enter Exit Expand Export Find ForEach Format Get Grant Group Hide Import Initialize Install Invoke Join Limit Lock Measure Merge Mount Move New Open Optimize Out Ping Pop Protect Publish Push Read Receive Redo Register Remove Rename Repair Request Reset Resize Resolve Restart Restore Resume Revoke Save Search Select Send Set Show Skip Sort Split Start Step Stop Submit Suspend Switch Sync Tee Test Trace Unblock Undo Uninstall Unlock Unprotect Unpublish Unregister Update Use Wait Watch Where Write`.split(` `));function Cn(e){let t=/^([A-Z][a-z]+(?:[A-Z][a-z]+)?)-[A-Z][A-Za-z]*$/u.exec(e);return t!==null&&Sn.has(t[1])}function wn(e){let t=/^(?:&\s*)?(?:"([^"]*)"|'([^']*)'|(\S+))/u.exec(e.trim()),n=(t?.[1]??t?.[2]??t?.[3]??``).split(/[\\/]/u).at(-1)?.toLowerCase().replace(/\.exe$/u,``);return n&&xn.has(n)||Tn(e)?`powershell`:`shellscript`}function Tn(e){let t=e.trim();if(/^&\s*\S/u.test(t))return!0;for(let e=0;t&&e<At;e+=1){let{firstCommand:e,remainingCommand:n}=R(t),r=e.trim();if(/^\$(?:env|global|local|script):/iu.test(r)||/^\$[A-Za-z_]\w*\s+=/u.test(r)||Cn(r.match(/^\S+/u)?.[0]??``))return!0;t=n}return!1}var En=new Set([`cat`,`head`,`tail`,`nl`,`less`,`more`,`bat`,`sed`]),Dn=new Set([`grep`,`egrep`,`fgrep`,`rg`,`ag`]),On=new Set([`ls`,`tree`,`find`]),kn=new Set([`head`,`tail`,`wc`,`sort`,`uniq`,`cut`,`grep`,`cat`]),An={head:new Set([`-n`,`-c`]),tail:new Set([`-n`,`-c`]),sed:new Set([`-e`,`-f`]),grep:new Set([`-e`,`-f`,`-m`,`-A`,`-B`,`-C`,`--regexp`,`--file`,`--max-count`]),rg:new Set([`-e`,`-f`,`-g`,`-t`,`-T`,`-m`,`-A`,`-B`,`-C`,`-M`,`--regexp`,`--file`,`--glob`,`--iglob`,`--type`,`--type-not`,`--max-count`,`--max-columns`,`--context`,`--after-context`,`--before-context`]),ag:new Set([`-G`,`-A`,`-B`,`-C`,`-m`]),tree:new Set([`-L`,`-I`,`-P`])};function jn(e,t){let n=An[e]??new Set,r=[],i=[],a=!1;for(let e=0;e<t.length;e+=1){let o=t[e];if(/^\d*(?:>>?|<|>&)/u.test(o))/^\d*(?:>>?|<|>&)$/u.test(o)&&(e+=1);else if(!a&&o===`--`)a=!0;else if(!a&&o.startsWith(`-`)&&o!==`-`){if(n.has(o)){let n=t[e+1];(o===`-e`||o===`--regexp`)&&n!==void 0&&i.push(n),e+=1}else o.startsWith(`--regexp=`)&&i.push(o.slice(9))}else r.push(o)}return{positionals:r,patterns:i}}function Mn(e){let t=L(e);if(!t||t.length===0)return null;let n=t[0].split(`/`).at(-1),{positionals:r,patterns:i}=jn(n===`egrep`||n===`fgrep`?`grep`:n,t.slice(1));if(En.has(n)){if(n===`sed`){if(!t.includes(`-n`)||t.includes(`-i`))return null;let e=i.length>0?r:r.slice(1);return e.length>0?{kind:`read`,paths:e}:null}return r.length>0?{kind:`read`,paths:r}:null}if(Dn.has(n)){let e=i[0]??r[0];return e?{kind:`search`,query:e,targets:i.length>0?r:r.slice(1)}:null}return On.has(n)?{kind:`list`,target:n===`find`?t.slice(1).find(e=>!e.startsWith(`-`)&&e!==`(`)??null:r[0]??null}:null}function Nn(e){let t=bn(e).trim(),n=null,r=null;for(;t;){let e=R(t),i=e.firstCommand.trim();if(r===null){if(/^cd(?:\s|$)/u.test(i)&&e.separator===`&&`){t=e.remainingCommand;continue}if(r=Mn(i),r===null)return null}else{let e=L(i)?.[0]?.split(`/`).at(-1);if(n!==`|`||!e||!kn.has(e))return null}n=e.separator,t=e.remainingCommand}return r}function Pn(e){return e.replace(/[\\/]+$/u,``).split(/[\\/]/u).at(-1)||e}function Fn(e,t,n=Pn){let r=Nn(e);if(!r)return null;let i=t===`past`,a=e=>e[0]===void 0?``:`${n(e[0])}${e.length>1?` +${e.length-1} more`:``}`;switch(r.kind){case`read`:return`${i?`Read`:`Reading`} ${a(r.paths)}`;case`search`:{let e=a(r.targets);return`${i?`Searched`:`Searching`} for ${r.query}${e?` in ${e}`:``}`}case`list`:return`${i?`Listed`:`Listing`} files${r.target?` in ${a([r.target])}`:``}`}}function V(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function H(e){return typeof e==`string`&&e.trim()!==``?e:void 0}function U(e,t=0){if(t>4)return{failed:!1};if(typeof e==`string`)try{return U(JSON.parse(e),t+1)}catch{return{failed:!1}}if(Array.isArray(e)){let n,r=!1;for(let i of e){let e=V(i),a=e?.text??V(e?.content)?.text,o=U(V(a)?.text??a,t+1);n??=o.data,r||=o.failed}return{...n?{data:n}:{},failed:r}}let n=V(e);if(!n)return{failed:!1};let r=n.isError===!0||n.is_error===!0||typeof n._tag==`string`&&/(?:Error|Failure)$/.test(n._tag)||n.error!=null,i=n.structuredContent??n.content;if(i!==void 0){let e=U(i,t+1);return{...e.data?{data:e.data}:{},failed:r||e.failed}}return{data:n,failed:r}}function In(e){let t=U(e).data;return t&&typeof t.toolName==`string`?V(t.args):t}function Ln(e){return U(e).failed}function W(e){return new Set(e.filter(e=>e!==void 0)).size+e.filter(e=>e===void 0).length}function G(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function Rn(e,t){let n=t.map(e=>{let t=U(e.output);return{input:In(e.input),output:t.data,outcome:t.failed?`failed`:e.outcome}}),r=n.filter(e=>e.outcome===`completed`),i=n.filter(e=>e.outcome===`failed`).length,a=r.length>0?r:n,o=G(a.length,`time`),s=(e,t,n)=>`${r.length>0?e:`Tried to ${t}`} ${n}`,c=e=>a.map(t=>H(t.output?.[e])??H(t.input?.[e])),l=a.map(e=>H(e.output?.id)??H(e.output?.projectId)??H(e.input?.projectId)),u=a.map(e=>H(e.output?.threadId)??H(V(e.output?.thread)?.threadId)??H(e.input?.threadId)),d;switch(e){case`thread-send`:{let e=W(a.map(e=>H(e.output?.messageId))),t=u.every(e=>e!==void 0),n=new Set(u).size;d=s(`Sent`,`send`,t?e===n&&e>1?`messages to ${G(n,`thread`)}`:`${G(e,`message`)} to ${G(n,`thread`)}`:G(e,`message`));break}case`thread-create`:{let e=[];d=r.length>0&&r.every(t=>(Array.isArray(t.output?.threads)?t.output.threads:[t.output]).every(t=>{let n=V(t);if(n?.status===`rolled_back`)return!0;let r=H(n?.threadId);return r?(e.push(r),!0):!1}))?`Created ${G(new Set(e).size,`thread`)}`:`Requested thread creation ${o}`;break}case`delegate`:d=s(`Delegated`,`delegate`,G(W(c(`taskId`)),`task`));break;case`thread-read`:case`thread-wait`:{let t=u.every(e=>e!==void 0)?G(new Set(u).size,`thread`):`threads ${o}`;d=e===`thread-read`?s(`Read`,`read`,t):s(`Waited on`,`wait on`,t);break}case`thread-list`:d=s(`Listed`,`list`,`threads ${o}`);break;case`thread-interrupt`:d=s(`Requested interrupts for`,`interrupt`,G(W(u),`thread`));break;case`workflow-stop`:d=s(`Requested stops for`,`stop`,G(W(c(`subagentId`)),`workflow`));break;case`task-status`:d=s(`Checked`,`check`,`task status ${o}`);break;case`task-cancel`:d=s(`Requested cancellation of`,`cancel`,G(W(c(`taskId`)),`task`));break;case`schedule-create`:d=s(`Scheduled`,`schedule`,G(W(c(`scheduledTaskId`)),`task`));break;case`schedule-list`:d=s(`Listed`,`list`,`scheduled tasks ${o}`);break;case`schedule-update`:d=s(`Updated`,`update`,G(W(c(`scheduledTaskId`)),`scheduled task`));break;case`schedule-delete`:d=s(`Requested deletion of`,`delete`,G(W(c(`scheduledTaskId`)),`scheduled task`));break;case`schedule-run`:d=s(`Requested`,`request`,G(a.length,`scheduled task run`));break;case`thread-configuration`:d=s(`Checked`,`check`,`thread configuration ${o}`);break;case`thread-configure`:d=s(`Set`,`set`,`thread model ${o}`);break;case`thread-fork`:d=s(`Requested`,`request`,G(a.length,`thread fork`));break;case`thread-merge`:d=s(`Requested`,`request`,G(a.length,`context merge`));break;case`thread-search`:d=s(`Searched`,`search`,`threads ${o}`);break;case`thread-transfers`:d=s(`Checked`,`check`,`thread transfers ${o}`);break;case`thread-organize`:d=s(`Organized`,`organize`,`threads ${o}`);break;case`thread-update`:d=s(`Updated`,`update`,G(W(u),`thread`));break;case`queue-list`:d=s(`Listed`,`list`,`queued messages ${o}`);break;case`queue-read`:d=s(`Read`,`read`,G(W(c(`queuedRunId`)),`queued message`));break;case`queue-edit`:d=s(`Edited`,`edit`,G(W(c(`queuedRunId`)),`queued message`));break;case`queue-cancel`:d=s(`Requested cancellation of`,`cancel`,G(W(c(`queuedRunId`)),`queued run`));break;case`queue-reorder`:d=s(`Reordered`,`reorder`,G(W(c(`queuedRunId`)),`queued run`));break;case`queue-steer`:d=s(`Requested steering with`,`steer with`,G(W(c(`queuedRunId`)),`queued message`));break;case`question-list`:d=s(`Listed`,`list`,`pending requests ${o}`);break;case`question-read`:d=s(`Read`,`read`,G(W(c(`requestId`)),`pending request`));break;case`question-respond`:d=s(`Responded to`,`respond to`,G(W(c(`requestId`)),`pending request`));break;case`secret-request`:d=s(`Asked for`,`ask for`,G(a.length,`secret`));break;case`worktree-handoff`:d=s(`Handed off to`,`hand off to`,G(W(c(`worktreePath`)),`worktree`));break;case`worktree-list`:d=s(`Listed`,`list`,`workspace branches ${o}`);break;case`worktree-status`:d=s(`Checked`,`check`,`worktree status ${o}`);break;case`project-list`:d=s(`Listed`,`list`,`projects ${o}`);break;case`project-read`:d=s(`Read`,`read`,G(W(l),`project`));break;case`project-create`:d=s(`Registered`,`register`,G(W(l),`project`));break;case`project-update`:d=s(`Updated`,`update`,G(W(l),`project`));break;case`project-delete`:d=s(`Deleted`,`delete`,G(W(l),`project`));break;case`project-clone`:d=s(`Cloned`,`clone`,G(W(c(`cwd`)),`repository`,`repositories`));break;case`environment-read`:d=s(`Checked`,`check`,`environment preferences ${o}`);break;case`environment-update`:d=s(`Updated`,`update`,`environment preferences ${o}`);break;case`environment-links`:d=s(`Listed`,`list`,`linked environments ${o}`);break;case`environment-link`:d=s(`Asked to link`,`ask to link`,G(a.length,`environment`));break;case`environment-unlink`:d=s(`Forgot`,`forget`,G(W(c(`environmentId`)),`linked environment`));break;case`attachment-prepare`:d=s(`Prepared`,`prepare`,G(W(c(`attachmentId`)),`attachment upload`));break;case`attachment-discard`:d=s(`Discarded`,`discard`,G(W(c(`attachmentId`)),`pending attachment`));break;case`attachment-send`:{let e=new Map;a.forEach((t,n)=>e.set(H(t.output?.messageId)??`call-${n}`,t));let t=[...e.values()].reduce((e,t)=>e+(Array.isArray(t.input?.attachments)?t.input.attachments.length:0),0),n=[...e.values()].every(e=>Array.isArray(e.input?.attachments)&&e.input.attachments.length>0),r=u.every(e=>e!==void 0)?` to ${G(new Set(u).size,`thread`)}`:``;d=s(`Sent`,`send`,n?`${G(t,`attachment`)}${r}`:`attachments${r} ${o}`);break}case`link-pr`:d=s(`Linked`,`link`,G(a.length,`pull request`));break;case`unlink-pr`:d=s(`Unlinked`,`unlink`,G(a.length,`pull request`));break;case`watch-pr`:d=s(`Watching`,`watch`,G(a.length,`pull request`));break;case`unwatch-pr`:d=s(`Stopped watching`,`stop watching`,G(a.length,`pull request`));break;case`list-prs`:d=s(`Checked`,`check`,`linked pull requests${a.length===1?``:` ${o}`}`);break;case`write-pr-guides`:{let e=a.flatMap(e=>Array.isArray(e.output?.guides)?e.output.guides.map(e=>V(e)?.outcome):[]),t=e.filter(e=>e!==`failed`).length,n=e.length-t;i+=n,d=e.length>0&&t===0?`Could not start ${G(n,`review guide`)}`:s(`Started`,`start`,e.length===0?`review guides ${o}`:`${G(t,`review guide`)}${n>0?`, ${n} failed`:``}`);break}case`read-pr-guide`:d=s(`Read`,`read`,G(a.length,`review guide`));break;case`browser`:d=s(`Used`,`use`,`browser ${o}`);break;case`decide`:d=s(`Asked`,`ask`,`Decisions ${o}`);break;case`device`:d=s(`Used`,`use`,`device controls ${o}`);break;case`html-preview`:d=s(`Previewed`,`preview`,G(a.length,`HTML page`));break;case`html-render`:d=s(`Rendered`,`render`,G(a.length,`HTML page`));break;case`capabilities`:d=s(`Checked`,`check`,`orchestration capabilities ${o}`)}return{label:d,failedCount:i}}function zn(e){return e.status===`running`?`Compacting context`:e.beforeTokenCount!==void 0&&e.afterTokenCount!==void 0?`Context compacted ${le(e.beforeTokenCount)} → ${le(e.afterTokenCount)} tokens`:`Context compacted`}function Bn(e){return e.replace(/\s+(?:complete|completed)\s*$/i,``).trim()}function K(e){let t=e.structuredPayload;if(t?.type===`dynamic_tool`&&t.toolName)return t.toolName;let n=q(e.toolData);return typeof n?.server==`string`&&typeof n.tool==`string`?`${n.server}.${n.tool}`:typeof n?.toolName==`string`?n.toolName:D(e.toolTitle)?e.toolTitle:e.label}function Vn(e){let t=e.structuredPayload,n=q(e.toolData);return t?.type===`dynamic_tool`?t.input:n?.arguments??n?.input??n?.rawInput}function Hn(e){let t=e.structuredPayload,n=q(e.toolData);return t?.type===`dynamic_tool`?t.output:n?.output??n?.result??n?.rawOutput??n?.content}function Un(e,t,n){if(!e)return null;let[r,i,a,o]=e.labels,s=t===`inProgress`?i:t===`completed`?a:t===`failed`?`Failed to ${r.toLowerCase()}`:t===`declined`?`Declined to ${r.toLowerCase()}`:t===`stopped`?`Stopped ${i.toLowerCase()}`:i,c=e.summaryAction===`link-pr`||e.summaryAction===`unlink-pr`||e.summaryAction===`list-prs`||e.summaryAction===`watch-pr`||e.summaryAction===`unwatch-pr`?e.summaryAction:void 0,l=q(n),u=q(l?.arguments)??q(l?.input)??q(l?.rawInput),d=(typeof u?.url==`string`?te(u.url):null)?.number??u?.number;return{displayName:`${s} ${c!==void 0&&c!==`list-prs`&&typeof d==`number`&&Number.isSafeInteger(d)&&d>0?`PR #${d}`:o}`,icon:e.icon,...c===void 0?{}:{action:c}}}function Wn(e,t){return e===`failed`||e===`declined`||e===`stopped`||e===`idle`?e:t||e===`inProgress`?`inProgress`:`completed`}function Gn(e,t){let n=D(K(e),Vn(e)),r=e.toolLifecycleStatus??t;return Un(n,n&&Ln(Hn(e))?`failed`:r,e.toolData)}function q(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Kn(e){return e.tone===`tool`||e.tone===`thinking`||e.tone===`error`||e.command!==void 0&&e.command.trim().length>0||e.requestKind!==void 0||e.itemType!==void 0&&a(e.itemType)}function qn(e,t){if(e.tone===`error`||e.toolLifecycleStatus===`failed`||e.toolLifecycleStatus===`declined`)return!0;if(!Kn(e))return!1;if(D(K(e))&&Ln(Hn(e)))return!0;let n=e.structuredPayload;if(n?.type===`command_execution`&&(n.outputIndicatesFailure||n.exitCode!==void 0&&n.exitCode!==0||n.output&&mt(n.output.slice(0,32768))))return!0;let r=t?[e.detail,e.command].filter(Boolean).join(`
25
+ `):e.detail??``;return r.length>0&&mt(r)}function Jn(e){return qn(e,!0)}function Yn(e){return qn(e,!1)}function Xn(e){return e.itemType===`file_search`||e.itemType===`web_search`&&/\bgrep\b/i.test(Bn(e.toolTitle??e.label))}function J(e){if(e.itemType===`thread_created`)return`thread-create`;let t=Gn(e);if(t?.action!==void 0)return t.action;if(t?.icon===`browser`)return`browser`;if(t?.icon===`device`)return`device`;if(e.requestKind===`file-read`||e.viewedImagePath!==void 0)return`read`;if(e.itemType===`approval_request`||e.itemType===`user_input_request`)return Kn(e)?`other`:`update`;let n=e.itemType===`command_execution`&&e.command?Nn(e.command):null;if(n)return n.kind===`read`?`read`:`code-search`;let r=q(e.toolData)??{},i=e.structuredPayload?.type===`dynamic_tool`?e.structuredPayload.toolName:typeof r.toolName==`string`?r.toolName:e.toolTitle,a=be({itemType:e.itemType===`command_execution`||e.itemType===`file_change`||e.itemType===`web_search`?e.itemType:e.itemType===`dynamic_tool`?`dynamic_tool_call`:void 0,title:e.toolTitle??e.label,data:{...r,...i?{toolName:i}:{}}});return a===`read`?`read`:a===`file_change`||e.itemType===`file_change`?`edit`:a===`command`||e.itemType===`command_execution`||e.command?`command`:a===`search`?e.itemType===`web_search`&&!Xn(e)?`search`:`code-search`:Xn(e)?`code-search`:e.itemType===`web_search`?`search`:(e.changedFiles?.length??0)>0?`edit`:Kn(e)?`other`:`update`}function Zn(e){let t=e.viewedImagePath?.trim();if(t!==void 0&&!/[\r\n]/.test(t)&&g(t))return t;let n=e.detail?.trim();return J(e)===`read`&&n!==void 0&&!/[\r\n]/.test(n)&&g(n)?n:null}function Qn(e,t){let n=se(e,t.workspaceRoot??`.`);if(n._tag!==`WorkspaceFile`)return null;let r=t.workspaceRoot==null&&n.path.startsWith(`./`)?n.path.slice(2):n.path,i=ce(e,{threadId:t.threadId,workspaceRoot:t.workspaceRoot,resolvedFilePath:r});return i===null||i.access!==`environment`?null:{resource:i.resource,alt:i.name,srcFragment:i.srcFragment}}function $n(e,t){if(e!==`edit`)return t.length;let n=new Set,r=0;for(let e of t)if(!e.changedFiles||e.changedFiles.length===0)r+=1;else for(let t of e.changedFiles)n.add(t);return n.size+r}function er(e,t){switch(e){case`link-pr`:return`Linked ${t} ${t===1?`pull request`:`pull requests`}`;case`unlink-pr`:return`Unlinked ${t} ${t===1?`pull request`:`pull requests`}`;case`watch-pr`:return`Watching ${t} ${t===1?`pull request`:`pull requests`}`;case`unwatch-pr`:return`Stopped watching ${t} ${t===1?`pull request`:`pull requests`}`;case`list-prs`:return t===1?`Checked linked pull requests`:`Checked linked pull requests ${t} times`;case`read`:return`Read ${t} ${t===1?`file`:`files`}`;case`edit`:return`Changed ${t} ${t===1?`file`:`files`}`;case`command`:return`Ran ${t} ${t===1?`command`:`commands`}`;case`thread-create`:return`Created ${t} ${t===1?`thread`:`threads`}`;case`device`:return`Used device controls ${t} ${t===1?`time`:`times`}`;case`browser`:return`Used browser ${t} ${t===1?`time`:`times`}`;case`search`:return`Searched the web ${t} ${t===1?`time`:`times`}`;case`code-search`:return`Searched code ${t} ${t===1?`time`:`times`}`;case`other`:return`Used ${t} ${t===1?`tool`:`tools`}`;case`update`:return`Received ${t} ${t===1?`update`:`updates`}`}}function tr(e){return{input:Vn(e),output:Hn(e),outcome:e.toolLifecycleStatus===`failed`||e.toolLifecycleStatus===`declined`||e.tone===`error`?`failed`:e.toolLifecycleStatus===`completed`?`completed`:`unfinished`}}function nr(e){switch(e){case`command`:case`edit`:case`delegate`:case`task-cancel`:case`thread-create`:case`thread-send`:case`thread-interrupt`:case`workflow-stop`:case`schedule-create`:case`schedule-update`:case`schedule-delete`:case`schedule-run`:case`thread-configure`:case`thread-fork`:case`thread-merge`:case`thread-organize`:case`thread-update`:case`queue-edit`:case`queue-cancel`:case`queue-reorder`:case`queue-steer`:case`question-respond`:case`worktree-handoff`:case`project-create`:case`project-update`:case`project-delete`:case`project-clone`:case`environment-update`:case`attachment-prepare`:case`attachment-discard`:case`attachment-send`:return 0;case`other`:case`update`:return 2;default:return 1}}function rr(e){let t=e.filter(e=>e.itemType!==`reasoning`);if(e.length>0&&t.length===0)return{summary:e.length===1?`Thought`:`Thought (×${e.length})`,hasFailure:!1};e=t;let n=new Map,r=new Map;for(let t of e){let e=rt(K(t),tr(t).input);if(t.toolSource&&e===null){r.set(t.toolSource.key,t.toolSource);continue}let i=J(t),a=e??i,o=n.get(a);o?o.entries.push(t):n.set(a,{action:i,p4Action:e,entries:[t]})}let i=[...n].map(([e,t],n)=>({index:n,count:t.entries.length,priority:nr(e),...t.p4Action?Rn(t.p4Action,t.entries.map(tr)):{label:er(t.action,$n(t.action,t.entries)),failedCount:t.entries.filter(Yn).length}})),a=[...i].sort((e,t)=>e.priority-t.priority||e.index-t.index).slice(0,2).sort((e,t)=>e.index-t.index),o=a.map(({label:e})=>e);if(r.size>0){let e=[...r.values()],t=[...new Set(e.map(e=>e.name))],n=t.length<2?t[0]:t.length===2?t.join(` and `):`${t.slice(0,-1).join(`, `)}, and ${t.at(-1)}`,i=e.every(e=>e.kind===`integration`);o.unshift(`Used ${n}${i?` ${t.length===1?`integration`:`integrations`}`:``}`)}let s=e.filter(e=>e.toolSource!==void 0&&D(K(e))===null).length,c=e.length-s-a.reduce((e,t)=>e+t.count,0);c>0&&o.push(`Performed ${c} other ${c===1?`action`:`actions`}`);let l=o.map((e,t)=>t===0?e:e.charAt(0).toLowerCase()+e.slice(1));return{summary:l.length<3?l.join(` and `):`${l.slice(0,-1).join(`, `)}, and ${l.at(-1)}`,hasFailure:i.some(e=>e.failedCount>0)}}function ir(e){let t=e.filter(e=>e.itemType!==`reasoning`);if(e.length>0&&t.length===0)return`reasoning`;if(e=t,e.length>0&&e.every(e=>Gn(e)?.icon===`pull-request`))return`pull-request`;let n=new Set(e.map(J));if(n.size!==1)return`mixed`;let r=n.values().next().value;if(r!==`other`)return r;let i=new Set(e.map(e=>e.itemType===`dynamic_tool`?`dynamic-tool`:e.itemType===`subagent`||e.tone===`thinking`?`agent-tool`:e.tone===`tool`?`tone-tool`:`other`));return i.size===1?i.values().next().value:`mixed`}function ar(e){let t=/^\s*\*\*([^*\r\n]+)\*\*[ \t]*\r?(?:\n|$)/.exec(e)?.[1],n=(t??e).replace(/!?\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/^[ \t]*(?:#{1,6}|[-*+]|\d+\.)[ \t]+/gm,``).replace(/`+|\*\*|~~/g,``).replace(/(^|[^\w*])[*_]([^*_\n]+)[*_](?![\w*])/g,`$1$2`).replace(/\s+/g,` `).trim();if(t!==void 0)return n;let r=/[.?!]["'”’)]?(?=\s)/.exec(n);return r?n.slice(0,r.index+r[0].length):n}function or(t,n){if(t?.status!==`failed`)return null;let r=null;for(let i of n)i.type===`error`&&i.status===`failed`&&i.runId===t.id&&i.nodeId===t.rootNodeId&&(r===null||e(i.updatedAt)>e(r.updatedAt)||e(i.updatedAt)===e(r.updatedAt)&&(i.ordinal>r.ordinal||i.ordinal===r.ordinal&&i.id>r.id))&&(r=i);return r?.failure??null}function sr(e,t){let n=t!==null&&t!==e?.message?null:e;return{usageLimitResetAt:n?.class===`usage_limit`?n.resetAt??null:null,lastError:t??e?.message??null,lastErrorClass:t!==null&&t!==e?.message?null:e?.class??null}}function cr(e){let t=null;for(let n of e)n.status===`queued`||n.status===`cancelled`&&n.startedAt===null||t!==null&&!lr(n,t)||(t=n);return t}function lr(t,n){let r=t=>t.completedAt?e(t.completedAt):1/0;return r(t)===r(n)?t.ordinal>n.ordinal:r(t)>r(n)}function ur(e,t,n){let r=cr(e);return r?.status===`failed`&&sr(or(r,t),n).lastErrorClass===`usage_limit`?r:null}function dr(e,t,n){let r=ur(e,t,n);return r!==null&&e.some(e=>e.ordinal>r.ordinal)?r:null}function fr(e){let t=null;for(let n of e)(n.status!==`queued`||n.queueHeld!==!0)&&(t===null||n.ordinal>t.ordinal)&&(t=n);return t}function pr(e,t){if(e.startedAt===null)return null;let n=f(e.status)?t:e.completedAt===null?null:Date.parse(e.completedAt);if(n===null)return null;let r=Date.parse(e.startedAt);return Number.isFinite(r)&&Number.isFinite(n)?Math.max(0,n-r):null}function mr(e){if(!Number.isFinite(e)||e<0)return`0ms`;if(e<1e3)return`${Math.max(1,Math.round(e))}ms`;if(e<1e4){let t=Math.round(e/100)/10;return t>=10?`10s`:`${t.toFixed(1)}s`}if(e<6e4)return`${Math.round(e/1e3)}s`;let t=Math.round(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60,a=[];return n>0&&a.push(`${n}h`),r>0&&a.push(`${r}m`),i>0&&a.push(`${i}s`),a.join(` `)}var hr=new Set([`preparing`,`starting`,`running`,`waiting`]),gr=new Set([`preparing`,`starting`,`running`]);function _r(e,t){return e.runs.reduce((e,n)=>t(n)&&(e===null||n.ordinal>e.ordinal)?n:e,null)}function vr(e,n){let r=hr.has(n.status)?c(e.providerTurns,n.activeAttemptId)?.status:void 0;return{runId:n.id,status:n.status,requestedAt:t(n.requestedAt),startedAt:n.startedAt===null?null:t(n.startedAt),completedAt:n.completedAt===null?null:t(n.completedAt),assistantMessageId:e.messages.findLast(e=>e.runId===n.id&&e.role===`assistant`)?.id??null,...r===void 0||r===`pending`||r===`running`?{}:{turnEnded:!0},...n.sourcePlanRef===void 0?{}:{sourcePlanRef:n.sourcePlanRef}}}function yr(e){let t=e.providerSessions.findLast(t=>t.providerInstanceId===e.thread.providerInstanceId);return dr(e.runs,e.turnItems,t?.lastError??null)}function br(e){return yr(e)??fr(e.runs)}function xr(e){let t=br(e);return t===null?null:vr(e,t)}function Sr(e){let t=_r(e,e=>hr.has(e.status))??br(e);return t===null?null:vr(e,t)}function Cr(e){let t=wr(e);return t!==null&&f(t.status)?t.startedAt:null}function wr(e){if(!s(e.thread))return null;let n=e.nodes.findLast(e=>e.kind===`root_turn`&&e.runId===null);return n===void 0?null:{status:n.status,startedAt:n.startedAt===null?null:t(n.startedAt),completedAt:n.completedAt===null?null:t(n.completedAt)}}function Tr(e){return e.providerThreads.find(t=>t.id===e.thread.activeProviderThreadId&&t.providerInstanceId===e.thread.modelSelection.instanceId)?.nativeMetadata?.modelSelection??null}var Er=[`reasoningEffort`,`effort`,`reasoning`,`variant`];function Dr(e,t=[],n){let r=t.find(t=>t.slug===e.model)?.capabilities;if(!r)return null;let a=d({caps:r,selections:e.options});for(let t of Er){let r=a.find(e=>e.id===t);if(r?.type!==`select`)continue;let o=i(r,e,n);if(o)return o}return null}var Or={idle:`Idle`,pending:`Working`,running:`Working`,waiting:`Waiting`,completed:`Completed`,interrupted:`Interrupted`,failed:`Failed`,cancelled:`Cancelled`,rolled_back:`Cancelled`};function kr(e,t){if(e===null)return`Starting`;let n=Or[e.status],r=f(e.status);if(!r&&e.status!==`completed`)return n;let i=e.startedAt===null?NaN:Date.parse(e.startedAt),a=r?t:e.completedAt===null?NaN:Date.parse(e.completedAt);if(!Number.isFinite(i)||!Number.isFinite(a))return n;let o=mr(Math.max(1e3,Math.floor((a-i)/1e3)*1e3));return r?`${n} ${o}`:`${n} in ${o}`}function Ar(e){let n=xr(e),r=e.providerSessions.findLast(t=>t.providerInstanceId===e.thread.providerInstanceId),i=yr(e),a=br(e),o=Sr(e),s=_r(e,e=>hr.has(e.status)),c=re(ie({latestRun:a,providerThreads:e.providerThreads,turnItems:e.turnItems,activeProviderThreadId:e.thread.activeProviderThreadId,runs:e.runs,pullRequests:e.thread.pullRequests}));if(n===null&&e.thread.activeProviderThreadId===null&&!c)return null;let u=_r(e,e=>gr.has(e.status))?.id??null;return{status:i?`failed`:c&&a?.status!==`failed`?`idle`:o?.status??`idle`,activeRunId:u,activityStartedAt:s===null?null:t(l(s)),providerInstanceId:e.thread.providerInstanceId,providerName:r?.driver??null,...sr(or(a,e.turnItems),r?.lastError??null),updatedAt:t(e.updatedAt)}}function jr(e){return h(e)&&e?.activeRunId!==null&&e?.activeRunId!==void 0}var Y={subagent:{order:0,singular:`subagent`,plural:`subagents`},command:{order:1,singular:`command`,plural:`commands`},monitor:{order:2,singular:`monitor`,plural:`monitors`},background_task:{order:3,singular:`background task`,plural:`background tasks`}};function Mr(e){return e.length<=1?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e.at(-1)}`}function Nr(e){if(e.length===0)return null;let t=re(e),n=e.map(e=>{let t=e.description?.trim(),n=e.kind===`subagent`&&t!==void 0?ne(t).trim():t;return{taskId:e.taskId,kind:e.kind,label:n===void 0||n.length===0?Y[e.kind].singular:n,childThreadId:e.kind===`subagent`?e.childThreadId:void 0}}).sort((e,t)=>Y[e.kind].order-Y[t.kind].order),[r]=n;if(n.length===1&&r!==void 0){let e=Y[r.kind].singular,i=r.label!==e;return{title:t?i?`${r.kind===`monitor`?``:`Waiting on ${e} `}${r.label}`:`Waiting on a ${e}`:i?`Running: ${r.label}`:`Running a ${e}`,items:n,waiting:t}}let i=new Map;for(let e of n)i.set(e.kind,(i.get(e.kind)??0)+1);let a=Array.from(i,([e,t])=>{let{singular:n,plural:r}=Y[e];return`${t} ${t===1?n:r}`});return{title:`${t?`Waiting on`:`Running`} ${Mr(a)}`,items:n,waiting:t}}var Pr={active:`Pursuing goal`,paused:`Goal paused`,blocked:`Goal blocked`,usage_limited:`Goal hit a usage limit`,budget_limited:`Goal reached its token budget`,complete:`Goal complete`};function Fr(e){return e<1e3?`${e}`:e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1).replace(/\.0$/,``)}m`}function Ir(e,t){let n=[];return e.tokensUsed!==void 0&&e.tokensUsed>0&&n.push(e.tokenBudget==null?`${Fr(e.tokensUsed)} tokens`:`${Fr(e.tokensUsed)} / ${Fr(e.tokenBudget)} tokens`),e.timeUsedSeconds!==void 0&&e.timeUsedSeconds>=60&&n.push(mr(e.timeUsedSeconds*1e3)),e.checks!==void 0&&e.checks>0&&n.push(`${e.checks} ${e.checks===1?`check`:`checks`}`),{title:e.status===`active`&&!t?`Goal set`:Pr[e.status],objective:e.objective,usage:n.length===0?null:n.join(` · `),canResume:e.status!==`active`&&e.status!==`complete`}}function Lr(e){switch(e.kind){case`subagent`:case`delegated_task`:return e.childThreadId;case`command`:case`monitor`:case`background_task`:case`system`:return;default:return}}var Rr=`Preparing workspace`;function zr(e){return e.type===`command_execution`&&e.input===Rr||e.type===`error`&&e.status===`cancelled`&&e.failure.code===`workspace_preparation_failed`}function Br(e,t){let n=new Set(e.flatMap(e=>e.status===`failed`&&e.workspacePreparation!==void 0?[e.id]:[])),r=new Set;if(n.size===0)return r;for(let e of t)e.type===`error`&&e.status===`failed`&&e.failure.code===`workspace_preparation_failed`&&e.runId!==null&&n.has(e.runId)&&r.add(e.runId);return r}function Vr(e){return e.tone===`tool`||e.tone===`thinking`||e.tone===`error`||e.command!==void 0||e.requestKind!==void 0}function Hr(e){return e.itemType===`error`}function Ur(e){if(!Vr(e)||Jn(e)||e.tone===`thinking`&&e.itemType!==`reasoning`)return!1;let t=e.toolLifecycleStatus;return t!==`failed`&&t!==`declined`&&t!==`inProgress`&&t!==`stopped`&&t!==`idle`}function Wr(e){return Vr(e)&&!Jn(e)&&!Ur(e)}function Gr(e,t){return e===null||e.status===`preparing`||e.status===`queued`||e.status===`starting`||e.status===`running`||e.status===`waiting`?!1:t?.activeRunId!==e.runId}function Kr(e,t,n){return ae({latestRun:e,runtime:t})??(t?.activeRunId==null?n:null)}function qr(e){return[...e].toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt))}function Jr(e){return[...e].toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt))}function Yr(e,t){if(e===null)return null;let n=e.plans.filter(e=>e.kind===`todo_list`),r=[...n].toReversed().find(e=>e.runId===t)??n.at(-1)??null;return r===null||r.steps.length===0?null:{createdAt:X(e,r.id),runId:r.runId,explanation:r.explanation??null,steps:r.steps.map(({text:e,status:t,durationMs:n})=>({step:e,status:t===`running`?`inProgress`:t,...n===void 0?{}:{durationMs:n}}))}}function X(e,n){let r=e.turnItems.findLast(e=>(e.type===`proposed_plan`||e.type===`todo_list`)&&e.planId===n);return t(r?.updatedAt??e.updatedAt)}function Xr(e,t){let n=X(e,t.id);return{id:t.id,createdAt:n,updatedAt:n,runId:t.runId,planMarkdown:t.markdown,status:t.status}}function Zr(e,t){if(e===null)return null;let n=e.plans.filter(e=>e.kind===`proposed_plan`),r=t?n.filter(e=>e.runId===t):n,i=[...r.length>0?r:n].toSorted((t,n)=>X(e,t.id).localeCompare(X(e,n.id))||t.id.localeCompare(n.id)).at(-1);return i===void 0?null:Xr(e,i)}function Qr(e){return e?.status===`active`}var $r=new Set([`fork`,`handoff`,`run_interrupt_request`,`run_interrupt_result`,`secret_request`,`mcp_sign_in_request`,`link_request`,`subagent`]),ei=new Set([`fork`,`thread_created`,`secret_request`,`mcp_sign_in_request`,`link_request`]);function ti(e){return e.kind===`event`&&ei.has(e.projectedItem.item.type)}function Z(e){return t(e.item.startedAt??e.item.updatedAt)}function ni(e){switch(e.status){case`pending`:case`running`:case`waiting`:return`inProgress`;case`completed`:return`completed`;case`idle`:return`idle`;case`failed`:return`failed`;case`cancelled`:case`interrupted`:return`stopped`}}function ri(e){if(e.type===`error`)return`info`;if(e.type===`reasoning`)return`thinking`;switch(e.type){case`command_execution`:case`file_change`:case`file_search`:case`web_search`:case`dynamic_tool`:case`subagent`:case`thread_created`:case`user_input_request`:case`approval_request`:return`tool`;default:return`info`}}function ii(e){if(e.retry===void 0)return{label:e.failure.class===`usage_limit`?`Usage limit reached`:e.title?.trim()||`Provider error`,detail:e.failure.message};let t=e.retry.maxAttempts===null?`${e.retry.attempt}`:`${e.retry.attempt}/${e.retry.maxAttempts}`,n=e.status===`running`?`Retrying provider (${t})`:e.status===`completed`?`Provider recovered (${t} retries)`:e.status===`failed`?`${e.failure.class===`usage_limit`?`Usage limit reached`:`Provider error`} after ${t} retries`:`Provider retry stopped (${t})`,r=e.status===`running`&&e.retry.retryDelayMs!==null&&e.retry.retryDelayMs>0?e.retry.retryDelayMs<1e3?` Retrying in ${e.retry.retryDelayMs}ms.`:` Retrying in ${(e.retry.retryDelayMs/1e3).toFixed(1).replace(/\.0$/u,``)}s.`:``;return{label:n,detail:`${e.failure.message}${r}`}}function ai(e){let{item:t}=e,n=t.title?.trim()||null,i={id:t.id,createdAt:Z(e),runId:t.runId,tone:ri(t),itemType:t.type,toolLifecycleStatus:ni(t),structuredPayload:t,projectedItem:e,...Ne(t)};switch(t.type){case`thread_created`:return{...i,label:`Created thread`};case`compaction`:return{...i,label:zn(t),sourceActivityKind:`context-compaction`,...t.summary?{detail:t.summary}:{}};case`reasoning`:return{...i,label:n??`Thinking`,...t.text?{detail:t.text}:{}};case`command_execution`:return{...i,label:n??`Ran command`,command:t.input,rawCommand:t.input,toolTitle:n??`Command`,toolData:t};case`file_change`:return{...i,label:n??(t.changes!==void 0&&t.changes.length>1?`Changed ${t.changes.length} files`:`Changed ${t.fileName}`),changedFiles:t.changes?.map(e=>e.path)??[t.fileName],toolTitle:n??`File change`,toolData:t};case`file_search`:return{...i,label:n??De(t)??`Searched files`,...t.pattern?{detail:t.pattern}:{},toolTitle:n??`File search`,toolData:t};case`web_search`:return{...i,label:n??`Searched the web`,...t.patterns?.length?{detail:t.patterns.join(`, `)}:{},toolTitle:n??`Web search`,toolData:t};case`checkpoint`:return{...i,label:n??`Checkpoint captured`,changedFiles:t.files.map(e=>e.path),toolData:t};case`system_notice`:return{...i,label:t.message,...r(t)?{}:{sourceActivityKind:`runtime.warning`}};case`error`:{let e=ii(t);return{...i,...e,...t.failure.class===`usage_limit`&&t.status!==`completed`?{sourceActivityKind:`runtime.warning`}:t.retry===void 0?{sourceActivityKind:`runtime.error`}:{},toolData:t}}case`dynamic_tool`:{let e=be({itemType:`dynamic_tool_call`,data:{toolName:t.toolName??void 0,input:t.input}}),[r]=ve({input:t.input});return{...i,label:n??(e===`read`?Oe(r??``):e===`search`?De({input:t.input})??t.toolName??`Tool call`:t.toolName??`Tool call`),toolTitle:n??t.toolName??`Tool`,toolData:{input:t.input,output:t.output}}}case`approval_request`:return{...i,label:n??`Approval requested`,detail:t.prompt??t.requestKind,toolData:t};case`user_input_request`:return{...i,label:n??(t.questionAnswer?`Answered questions`:`Input requested`),...t.questionAnswer?{questionAnswer:t.questionAnswer}:{},toolData:t};default:return{...i,label:n??t.type.replaceAll(`_`,` `),toolData:t}}}function Q(e){let n=new Set,r=[],i=new Map((e.attempts??[]).map(e=>[e.rootNodeId,e])),a=new Map((e.nodes??[]).map(e=>[e.id,e])),o=new Map((e.plans??[]).map(e=>[e.id,e])),s=e=>{if(e.nodeId===null||e.runId===null)return;let t=e.nodeId,n=new Set;for(;t!==null&&!n.has(t);){n.add(t);let r=i.get(t);if(r?.runId===e.runId)return r;let o=a.get(t);if(o===void 0)return;let s=i.get(o.rootNodeId);if(s?.runId===e.runId)return s;t=o.parentNodeId}},c=new Set(e.visibleTurnItems.flatMap(({item:e})=>e.type===`user_input_request`&&e.questionAnswer?[`async-answer:${e.questionAnswer.requestId}`]:[]));for(let i of e.visibleTurnItems){let{item:a}=i;if(zr(a)&&!a.deferredWork||a.type===`todo_list`||a.type===`checkpoint`||a.type===`user_message`&&a.inputIntent===`queued_turn`&&a.status===`pending`||a.type===`user_message`&&c.has(a.messageId))continue;let l=Z(i),u=s(a),d=u===void 0?{}:{attempt:u};if(a.type===`notification`){r.push({id:a.id,kind:`work`,createdAt:l,entry:{id:a.id,createdAt:l,runId:a.runId,label:a.summary,tone:`info`,itemType:a.type,structuredPayload:a,projectedItem:i},...d});continue}if(a.type===`user_message`||a.type===`assistant_message`){let o={id:a.messageId,role:a.type===`user_message`?`user`:`assistant`,text:a.text,...a.type===`user_message`&&a.context?{context:a.context}:{},...(a.attachments?.length??0)>0?{attachments:(a.attachments??[]).map(t=>{let n=e.attachmentUrlById?.get(t.id);return n?{...t,previewUrl:n}:t})}:{},runId:a.runId,streaming:a.type===`assistant_message`&&a.streaming,...a.type===`user_message`?{createdBy:a.createdBy,creationSource:a.creationSource,...a.senderThreadId===void 0?{}:{senderThreadId:a.senderThreadId},...a.scheduledTaskId===void 0?{}:{scheduledTaskId:a.scheduledTaskId}}:{},createdAt:l,updatedAt:t(a.updatedAt),...a.type===`user_message`?{inputIntent:a.inputIntent}:{}};n.add(o.id),r.push({id:o.id,kind:`message`,createdAt:l,message:o,projectedItem:i,...d});continue}if(a.type===`proposed_plan`){let e=o.get(a.planId),n={id:a.planId,runId:a.runId,planMarkdown:a.markdown,status:e?.kind===`proposed_plan`?e.status:`active`,createdAt:l,updatedAt:t(a.updatedAt)};r.push({id:a.id,kind:`proposed-plan`,createdAt:l,proposedPlan:n,...d});continue}let f=a.type===`dynamic_tool`&&a.status===`completed`?ft(a):void 0;if(f!==void 0){r.push({id:a.id,kind:`html-render`,createdAt:l,runId:a.runId,htmlRender:f,...d});continue}let p=a.type===`dynamic_tool`&&a.status===`completed`?pt(a):void 0;p===void 0?$r.has(a.type)?r.push({id:a.id,kind:`event`,createdAt:l,projectedItem:i,...d}):r.push({id:a.id,kind:`work`,createdAt:l,entry:ai(i),...d}):r.push({id:a.id,kind:`mcp-app`,createdAt:l,runId:a.runId,sourceThreadId:i.sourceThreadId,itemId:i.sourceItemId,revision:wt(a),mcpApp:p,...d})}let l=new Set([...n,...c]);for(let t of e.anchoredMessages??[]){if(l.has(t.id))continue;l.add(t.id);let e={id:t.id,kind:`message`,createdAt:t.createdAt,message:t},n=r.findIndex(e=>e.createdAt>t.createdAt);n===-1?r.push(e):r.splice(n,0,e)}for(let t of e.optimisticMessages)t.inputIntent!==`queued_turn`&&!l.has(t.id)&&(l.add(t.id),r.push({id:t.id,kind:`message`,createdAt:t.createdAt,message:t}));return r}var $=Object.freeze([]);function oi(e){let t=new Set;for(let n of e??[]){if(!p(n))continue;let e=n.previewUrl;e?.startsWith(`blob:`)||e?.startsWith(`data:`)||t.add(n.id)}return t.size===0?$:Array.from(t,e=>({_tag:`attachment`,attachmentId:e}))}function si(e,t){if(Object.keys(t).length===0)return $;let n=new Set;for(let r of e??[])if(r.role===`user`&&t[r.id]?.length)for(let e of r.attachments??[])p(e)&&n.add(e.id);return n.size===0?$:Array.from(n,e=>({_tag:`attachment`,attachmentId:e}))}function ci(){let e=new WeakMap,t=new WeakMap;return(n,r)=>{let i=n.attachments;if(!i||i.length===0)return n;let a=e.get(i)??i,o,s=!1;for(let[e,t]of i.entries()){let n=r(t),i=`previewUrl`in t?t.previewUrl:void 0,c=a[e],l=`previewUrl`in c?c.previewUrl:void 0,u=!n||n===i?t:n===l?c:{...t,previewUrl:n};s||=u!==t,u!==c&&(o??=a.slice(),o[e]=u)}let c=s?o??a:i;if(e.set(i,c),c===i)return t.delete(n),n;let l=t.get(n);if(l?.attachments===c)return l;let u={...n,attachments:c};return t.set(n,u),u}}function li(e,t){if(e.role!==`assistant`||t.role!==`assistant`||!e.streaming||!t.streaming)return!1;let{text:n,updatedAt:r,...i}=e,{text:a,updatedAt:o,...s}=t;return u(i,s)}function ui(e,t){let{item:n,...r}=e,{item:i,...a}=t;if(n.type!==`assistant_message`||i.type!==`assistant_message`||!n.streaming||!i.streaming||!u(r,a)||Z(e)!==Z(t))return!1;let{text:s,updatedAt:c,...l}=n,{text:d,updatedAt:f,...p}=i;return o(l,p)}function di(e,t,n){return n.item.id===t.item.id&&n.item.type===t.item.type&&n.item.type!==`user_message`&&n.item.type!==`assistant_message`&&n.item.type!==`user_input_request`&&((e.anchoredMessages?.length??0)===0||Z(n)===Z(t))}function fi(e,n){let r=n.input;if(e.visibleTurnItems.length<r.visibleTurnItems.length||!u(e.optimisticMessages,r.optimisticMessages)||!u(e.anchoredMessages,r.anchoredMessages)||!u(e.attachmentUrlById,r.attachmentUrlById)||!u(e.attempts,r.attempts)||!u(e.nodes,r.nodes)||!u(e.plans,r.plans))return null;let i=e.visibleTurnItems.length>r.visibleTurnItems.length;if(i&&(e.optimisticMessages.length>0||(e.anchoredMessages?.length??0)>0)||i&&e.visibleTurnItems.slice(r.visibleTurnItems.length).some(({item:e})=>e.type===`user_input_request`&&e.questionAnswer!==void 0||e.type===`user_message`&&e.messageId.startsWith(`async-answer:`)))return null;let a=new Map,o=[];for(let t=0;t<r.visibleTurnItems.length;t+=1){let n=r.visibleTurnItems[t],i=e.visibleTurnItems[t];if(i!==n){if(ui(n,i))a.set(n,i);else{if(!di(e,n,i))return null;o.push(i)}}}let s=o.length===0?[]:Q({...e,visibleTurnItems:o,optimisticMessages:[],anchoredMessages:[]});if(s.length!==o.length||s.some((e,t)=>e.id!==o[t].item.id))return null;let c=new Map(s.map(e=>[e.id,e]));if(a.size===0&&c.size===0&&!i)return n.entries;let l=0,d=n.entries.map(e=>{let n=c.get(e.id);if(n!==void 0)return l+=1,n;let r=e.kind===`message`&&e.projectedItem!==void 0?a.get(e.projectedItem):void 0;return e.kind!==`message`||r?.item.type!==`assistant_message`?e:{...e,projectedItem:r,message:{...e.message,text:r.item.text,updatedAt:t(r.item.updatedAt)}}});return l===c.size?(i&&d.push(...Q({...e,visibleTurnItems:e.visibleTurnItems.slice(r.visibleTurnItems.length)})),d):null}function pi(e,t=null){let n=t===null?null:fi(e,t);if(n!==null)return{input:e,entries:n};let r=Q(e);if(t===null||!u(e.attachmentUrlById,t.input.attachmentUrlById))return{input:e,entries:r};let i=new Map(t.entries.flatMap(e=>e.kind===`message`?[[e.id,e]]:[]));return{input:e,entries:r.map(e=>{if(e.kind!==`message`||e.projectedItem===void 0)return e;let t=i.get(e.id);return t?.projectedItem===e.projectedItem?t.attempt===e.attempt?t:{...e,message:t.message}:e})}}function mi(e){return Object.fromEntries(e.flatMap(e=>e.runId===null?[]:[[e.runId,e.checkpointTurnCount]]))}function hi(e){let t=new Map;for(let n of e.checkpoints)n.status===`ready`&&t.set(n.runId,n);let n=new Map;for(let r of e.timelineEntries){if(r.kind!==`message`||r.message.role!==`user`||r.message.inputIntent!==`turn_start`&&r.message.inputIntent!==`queued_turn`||r.message.runId===null)continue;let e=t.get(r.message.runId);e!==void 0&&n.set(r.message.id,Math.max(0,e.checkpointTurnCount-1))}return n}function gi(e){return e===null?`disconnected`:e.status===`preparing`||e.status===`starting`||e.status===`queued`?`connecting`:e.status===`running`||e.status===`waiting`?`running`:`ready`}function _i(e,t){return e&&(gi(t)===`running`||jr(t))}export{pn as $,Dr as A,dr as B,Br as C,Cr as D,Tr as E,pr as F,Gn as G,ar as H,mr as I,ir as J,rr as K,cr as L,Lr as M,Nr as N,Sr as O,Ir as P,wn as Q,or as R,Vr as S,de as St,wr as T,Bn as U,Wn as V,Qn as W,Zn as X,Yn as Y,hn as Z,si as _,ue as _t,qr as a,kt as at,Wr as b,Oe as bt,hi as c,Dt as ct,Qr as d,Ie as dt,vn as et,mi as f,Pe as ft,ii as g,qe as gt,ui as h,Xe as ht,_i as i,wt as it,kr as j,Ar as k,pi as l,A as lt,li as m,Je as mt,Yr as n,yn as nt,Jr as o,Tt as ot,Gr as p,Ye as pt,J as q,Kr as r,F as rt,gi as s,Ot as st,ci as t,Fn as tt,Zr as u,D as ut,oi as v,ve as vt,xr as w,Hr as x,De as xt,ti as y,me as yt,fr as z};
26
+ //# sourceMappingURL=session-logic-D0Wb0fc2.js.map
@@ -1,2 +1,2 @@
1
- import{a as e,t}from"./react-BUfh6y28.js";import{n,t as r}from"./jsx-runtime-DJeoFXNw.js";import{am as i,dr as a}from"./utils-D19Exirm.js";import{t as o}from"./useLocation--dLSTvwv.js";import{t as s}from"./useNavigateBack-ClmMPFha.js";import{r as c}from"./SettingsPanels-BfzvtrNj.js";import{t as l}from"./env-wK1YYxA8.js";import{o as u}from"./sidebar-DMJE0zUg.js";import{B as d,V as f,i as p,z as m}from"./settingsLayout-BWJVQUbK.js";import{$r as h,d as g,gr as _,hr as v,mr as y,yo as b}from"./main-CVSzIqPv.js";import{t as x}from"./WorkspacePageHeader-DGopnQZ2.js";import{n as S,r as C,t as w}from"./WorkspaceBreadcrumb-CQH9TmFi.js";import{t as T}from"./SettingsScopeNotice-BSIkX2D-.js";var E=e(t()),D=n(),O=e(r(),1),k={...y,"/settings/diagnostics":`Diagnostics`,"/settings/open-source-licenses":`Open source licenses`};function A(e){return k[e.replace(/\/+$/,``)||`/`]??null}function j(e){let t=(0,D.c)(9),{pathname:n}=e,r;t[0]===n?r=t[1]:(r=A(n),t[0]=n,t[1]=r);let i=r,a;t[2]===i?a=t[3]:(a=i?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(S,{children:`Settings`}),(0,O.jsx)(C,{})]}):null,t[2]=i,t[3]=a);let o=i??`Settings`,s;t[4]===o?s=t[5]:(s=(0,O.jsx)(S,{current:!0,className:`truncate`,children:o}),t[4]=o,t[5]=s);let c;return t[6]!==a||t[7]!==s?(c=(0,O.jsxs)(w,{ariaLabel:`Settings breadcrumb`,children:[a,s]}),t[6]=a,t[7]=s,t[8]=c):c=t[8],c}function M(e){let t=(0,D.c)(6),{onRestored:n}=e,{changedSettingLabels:r,restoreDefaults:o}=c(n),s=r.length===0,l;t[0]===o?l=t[1]:(l=()=>void o(),t[0]=o,t[1]=l);let u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,O.jsx)(i,{className:`mx-1 size-3.5`}),t[2]=u):u=t[2];let d;return t[3]!==s||t[4]!==l?(d=(0,O.jsxs)(a,{size:`xs`,variant:`ghost`,disabled:s,onClick:l,children:[u,`Restore device defaults`]}),t[3]=s,t[4]=l,t[5]=d):d=t[5],d}function N(e){let t=(0,D.c)(13),{pathname:n,children:r}=e,{scope:i,connectedEnvironments:a}=f(),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={select:P},t[0]=s):s=t[0];let c=o(s),l,u;if(t[1]!==c||t[2]!==i.kind?(l=v(c),u=i.kind!==`unavailable`&&l&&!_(l.scope,i.kind),t[1]=c,t[2]=i.kind,t[3]=l,t[4]=u):(l=t[3],u=t[4]),u){let e=l.scope===`environment`||l.scope===`project`||l.scope===`checkout`?l.scope:`all`,n=`${l.title} is not available for the selected target. Choose its owning scope to continue.`,r;return t[5]!==c||t[6]!==n||t[7]!==e?(r=(0,O.jsx)(T,{target:e,targetId:c,children:n}),t[5]=c,t[6]=n,t[7]=e,t[8]=r):r=t[8],r}if(m.has(n)||n===`/settings/projects`)return r;if(i.kind===`unavailable`){let e;return t[9]===i.message?e=t[10]:(e=(0,O.jsx)(p,{children:(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i.message})}),t[9]=i.message,t[10]=e),e}if(i.kind===`environment`&&a.length===0){let e;return t[11]===i.label?e=t[12]:(e=(0,O.jsx)(p,{children:(0,O.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Reconnect `,i.label,` to change its settings.`]})}),t[11]=i.label,t[12]=e),e}return r}function P(e){return e.hash}function F(){let e=(0,D.c)(19),t=o(),n=h();s(n);let{search:r,environment:i}=f(),a;e[0]!==i?.environmentId||e[1]!==t.pathname||e[2]!==r?(a=t.pathname===`/settings/diagnostics`||t.pathname===`/settings/providers`?i?.environmentId:JSON.stringify(r),e[0]=i?.environmentId,e[1]=t.pathname,e[2]=r,e[3]=a):a=e[3];let c=a,[d,p]=(0,E.useState)(0),m,g;e[4]===t.pathname?(m=e[5],g=e[6]):(m=(0,O.jsx)(j,{pathname:t.pathname}),g=t.pathname===`/settings/general`?(0,O.jsx)(`div`,{className:`ms-auto flex shrink-0 items-center`,children:(0,O.jsx)(M,{onRestored:()=>p(I)})}):null,e[4]=t.pathname,e[5]=m,e[6]=g);let _;e[7]!==m||e[8]!==g?(_=(0,O.jsx)(x,{electron:l,children:(0,O.jsxs)(`div`,{className:`flex w-full items-center gap-3`,children:[m,g]})}),e[7]=m,e[8]=g,e[9]=_):_=e[9];let v=`${c}:${d}`,y;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,O.jsx)(b,{}),e[10]=y):y=e[10];let S;e[11]===t.pathname?S=e[12]:(S=(0,O.jsx)(N,{pathname:t.pathname,children:y}),e[11]=t.pathname,e[12]=S);let C;e[13]!==v||e[14]!==S?(C=(0,O.jsx)(`div`,{className:`min-h-0 flex flex-1 flex-col`,children:S},v),e[13]=v,e[14]=S,e[15]=C):C=e[15];let w;return e[16]!==_||e[17]!==C?(w=(0,O.jsx)(u,{className:`h-dvh min-h-0 overflow-hidden overscroll-y-none isolate`,children:(0,O.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-background text-foreground`,children:[_,C]})}),e[16]=_,e[17]=C,e[18]=w):w=e[18],w}function I(e){return e+1}function L(){let e=(0,D.c)(9),t=g.useSearch(),n=g.useNavigate(),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={select:R},e[0]=r):r=e[0];let i=o(r),a=i===`/settings/providers`||i===`/settings/plugins`,s;e[1]!==n||e[2]!==i?(s=e=>{n({to:i,search:()=>({project:e.project,machine:e.machine,checkout:e.checkout}),hash:``,resetScroll:!1})},e[1]=n,e[2]=i,e[3]=s):s=e[3];let c;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,O.jsx)(F,{}),e[4]=c):c=e[4];let l;return e[5]!==t||e[6]!==a||e[7]!==s?(l=(0,O.jsx)(d,{search:t,singleEnvironment:a,onChange:s,children:c}),e[5]=t,e[6]=a,e[7]=s,e[8]=l):l=e[8],l}function R(e){return e.pathname}export{L as component};
2
- //# sourceMappingURL=settings-CTpjG14a.js.map
1
+ import{a as e,t}from"./react-BUfh6y28.js";import{n,t as r}from"./jsx-runtime-DJeoFXNw.js";import{dm as i,fr as a}from"./utils-CcBaVOX5.js";import{t as o}from"./useLocation-DNv7cb59.js";import{t as s}from"./useNavigateBack-DUje4FcE.js";import{r as c}from"./SettingsPanels-BsyJETg8.js";import{t as l}from"./env-wK1YYxA8.js";import{o as u}from"./sidebar-PSpwc3Zu.js";import{B as d,V as f,i as p,z as m}from"./settingsLayout-krWuVpsF.js";import{Dr as h,Er as g,Or as _,To as v,d as y,ni as b}from"./main-DIEsHSIy.js";import{t as x}from"./WorkspacePageHeader-MBEFb20_.js";import{n as S,r as C,t as w}from"./WorkspaceBreadcrumb-Dpau2BKr.js";import{t as T}from"./SettingsScopeNotice--a-aNSRR.js";var E=e(t()),D=n(),O=e(r(),1),k={...g,"/settings/diagnostics":`Diagnostics`,"/settings/open-source-licenses":`Open source licenses`};function A(e){return k[e.replace(/\/+$/,``)||`/`]??null}function j(e){let t=(0,D.c)(9),{pathname:n}=e,r;t[0]===n?r=t[1]:(r=A(n),t[0]=n,t[1]=r);let i=r,a;t[2]===i?a=t[3]:(a=i?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(S,{children:`Settings`}),(0,O.jsx)(C,{})]}):null,t[2]=i,t[3]=a);let o=i??`Settings`,s;t[4]===o?s=t[5]:(s=(0,O.jsx)(S,{current:!0,className:`truncate`,children:o}),t[4]=o,t[5]=s);let c;return t[6]!==a||t[7]!==s?(c=(0,O.jsxs)(w,{ariaLabel:`Settings breadcrumb`,children:[a,s]}),t[6]=a,t[7]=s,t[8]=c):c=t[8],c}function M(e){let t=(0,D.c)(6),{onRestored:n}=e,{changedSettingLabels:r,restoreDefaults:o}=c(n),s=r.length===0,l;t[0]===o?l=t[1]:(l=()=>void o(),t[0]=o,t[1]=l);let u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,O.jsx)(i,{className:`mx-1 size-3.5`}),t[2]=u):u=t[2];let d;return t[3]!==s||t[4]!==l?(d=(0,O.jsxs)(a,{size:`xs`,variant:`ghost`,disabled:s,onClick:l,children:[u,`Restore device defaults`]}),t[3]=s,t[4]=l,t[5]=d):d=t[5],d}function N(e){let t=(0,D.c)(13),{pathname:n,children:r}=e,{scope:i,connectedEnvironments:a}=f(),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={select:P},t[0]=s):s=t[0];let c=o(s),l,u;if(t[1]!==c||t[2]!==i.kind?(l=h(c),u=i.kind!==`unavailable`&&l&&!_(l.scope,i.kind),t[1]=c,t[2]=i.kind,t[3]=l,t[4]=u):(l=t[3],u=t[4]),u){let e=l.scope===`environment`||l.scope===`project`||l.scope===`checkout`?l.scope:`all`,n=`${l.title} is not available for the selected target. Choose its owning scope to continue.`,r;return t[5]!==c||t[6]!==n||t[7]!==e?(r=(0,O.jsx)(T,{target:e,targetId:c,children:n}),t[5]=c,t[6]=n,t[7]=e,t[8]=r):r=t[8],r}if(m.has(n)||n===`/settings/projects`)return r;if(i.kind===`unavailable`){let e;return t[9]===i.message?e=t[10]:(e=(0,O.jsx)(p,{children:(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i.message})}),t[9]=i.message,t[10]=e),e}if(i.kind===`environment`&&a.length===0){let e;return t[11]===i.label?e=t[12]:(e=(0,O.jsx)(p,{children:(0,O.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Reconnect `,i.label,` to change its settings.`]})}),t[11]=i.label,t[12]=e),e}return r}function P(e){return e.hash}function F(){let e=(0,D.c)(19),t=o(),n=b();s(n);let{search:r,environment:i}=f(),a;e[0]!==i?.environmentId||e[1]!==t.pathname||e[2]!==r?(a=t.pathname===`/settings/diagnostics`||t.pathname===`/settings/providers`?i?.environmentId:JSON.stringify(r),e[0]=i?.environmentId,e[1]=t.pathname,e[2]=r,e[3]=a):a=e[3];let c=a,[d,p]=(0,E.useState)(0),m,h;e[4]===t.pathname?(m=e[5],h=e[6]):(m=(0,O.jsx)(j,{pathname:t.pathname}),h=t.pathname===`/settings/general`?(0,O.jsx)(`div`,{className:`ms-auto flex shrink-0 items-center`,children:(0,O.jsx)(M,{onRestored:()=>p(I)})}):null,e[4]=t.pathname,e[5]=m,e[6]=h);let g;e[7]!==m||e[8]!==h?(g=(0,O.jsx)(x,{electron:l,children:(0,O.jsxs)(`div`,{className:`flex w-full items-center gap-3`,children:[m,h]})}),e[7]=m,e[8]=h,e[9]=g):g=e[9];let _=`${c}:${d}`,y;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,O.jsx)(v,{}),e[10]=y):y=e[10];let S;e[11]===t.pathname?S=e[12]:(S=(0,O.jsx)(N,{pathname:t.pathname,children:y}),e[11]=t.pathname,e[12]=S);let C;e[13]!==_||e[14]!==S?(C=(0,O.jsx)(`div`,{className:`min-h-0 flex flex-1 flex-col`,children:S},_),e[13]=_,e[14]=S,e[15]=C):C=e[15];let w;return e[16]!==g||e[17]!==C?(w=(0,O.jsx)(u,{className:`h-dvh min-h-0 overflow-hidden overscroll-y-none isolate`,children:(0,O.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-background text-foreground`,children:[g,C]})}),e[16]=g,e[17]=C,e[18]=w):w=e[18],w}function I(e){return e+1}function L(){let e=(0,D.c)(9),t=y.useSearch(),n=y.useNavigate(),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={select:R},e[0]=r):r=e[0];let i=o(r),a=i===`/settings/providers`||i===`/settings/plugins`,s;e[1]!==n||e[2]!==i?(s=e=>{n({to:i,search:()=>({project:e.project,machine:e.machine,checkout:e.checkout}),hash:``,resetScroll:!1})},e[1]=n,e[2]=i,e[3]=s):s=e[3];let c;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,O.jsx)(F,{}),e[4]=c):c=e[4];let l;return e[5]!==t||e[6]!==a||e[7]!==s?(l=(0,O.jsx)(d,{search:t,singleEnvironment:a,onChange:s,children:c}),e[5]=t,e[6]=a,e[7]=s,e[8]=l):l=e[8],l}function R(e){return e.pathname}export{L as component};
2
+ //# sourceMappingURL=settings-CQtFOh_t.js.map
@@ -1,2 +1,2 @@
1
- import{a as e}from"./react-BUfh6y28.js";import{n as t,t as n}from"./jsx-runtime-DJeoFXNw.js";import{t as r}from"./SettingsPanels-BfzvtrNj.js";var i=t(),a=e(n());function o(){let e=(0,i.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,a.jsx)(r,{}),e[0]=t):t=e[0],t}export{o as component};
2
- //# sourceMappingURL=settings.appearance-Cq56uRT4.js.map
1
+ import{a as e}from"./react-BUfh6y28.js";import{n as t,t as n}from"./jsx-runtime-DJeoFXNw.js";import{t as r}from"./SettingsPanels-BsyJETg8.js";var i=t(),a=e(n());function o(){let e=(0,i.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,a.jsx)(r,{}),e[0]=t):t=e[0],t}export{o as component};
2
+ //# sourceMappingURL=settings.appearance-CqHPJVJ2.js.map
@@ -0,0 +1,2 @@
1
+ import{i as e}from"./SettingsPanels-BsyJETg8.js";var t=e;export{t as component};
2
+ //# sourceMappingURL=settings.archived-DDtPGPcJ.js.map
@@ -1,2 +1,2 @@
1
- import{a as e,t}from"./react-BUfh6y28.js";import{n,t as r}from"./jsx-runtime-DJeoFXNw.js";import{Ld as i,dr as a,id as o,jy as s,sm as c}from"./utils-D19Exirm.js";import{t as l}from"./useNavigate-DAhzXpNZ.js";import{n as u,t as d}from"./kbd-Cr4XEhSh.js";import{F as f,I as p,L as m,R as h,V as g,a as _,i as v,s as y}from"./settingsLayout-BWJVQUbK.js";import{co as b,so as x,uo as S}from"./main-CVSzIqPv.js";var C=n(),w=e(t(),1),T=e(r(),1);function E(e){let t=(0,C.c)(10),n,r;t[0]===e?(n=t[1],r=t[2]):({icon:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=(0,T.jsx)(`span`,{className:`mt-3 ml-4 flex size-10 shrink-0 items-center justify-center rounded-xl bg-muted text-muted-foreground`,children:(0,T.jsx)(n,{"aria-hidden":!0,className:`size-5`})}),t[3]=n,t[4]=i);let a;t[5]===r?a=t[6]:(a=(0,T.jsx)(_,{...r,className:`min-w-0 flex-1`}),t[5]=r,t[6]=a);let o;return t[7]!==i||t[8]!==a?(o=(0,T.jsxs)(`div`,{className:`flex items-start`,children:[i,a]}),t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function D(e){let t=(0,C.c)(9),{mode:n,chromeOpened:r}=e,i;t[0]===n?i=t[1]:(i=n===`store`?[`In the Chrome Web Store tab, click Add to Chrome.`,`Confirm with Add extension.`]:[`In Chrome, go to chrome://extensions.`,`Turn on Developer mode.`,`Click Load unpacked.`,(0,T.jsxs)(T.Fragment,{children:[`Press`,` `,(0,T.jsxs)(u,{children:[(0,T.jsx)(d,{children:`⌘`}),(0,T.jsx)(d,{children:`⇧`}),(0,T.jsx)(d,{children:`G`})]}),`, paste the copied folder path, press Return, then click Select.`]})],t[0]=n,t[1]=i);let a=i,o;t[2]===r?o=t[3]:(o=r?null:(0,T.jsx)(`li`,{children:`Open Google Chrome.`}),t[2]=r,t[3]=o);let s;t[4]===a?s=t[5]:(s=a.map(O),t[4]=a,t[5]=s);let c;return t[6]!==o||t[7]!==s?(c=(0,T.jsxs)(`ol`,{className:`list-decimal space-y-1.5 py-3 pl-5 text-xs text-muted-foreground`,role:`status`,children:[o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function O(e,t){return(0,T.jsx)(`li`,{children:e},t)}function k(){let e=l(),{search:t}=g(),n=f(),r=h(),u=m(),d=p([`decisionVisionEnabled`]),_=!!n.decisionOpenRouterKey,C=window.desktopBridge,[O,k]=(0,w.useState)([]),[A,j]=(0,w.useState)(!!C?.listComputerUsePermissionHosts),[M,N]=(0,w.useState)(``),[P,F]=(0,w.useState)(!1),[I,L]=(0,w.useState)(),[R,z]=(0,w.useState)(),[B,V]=(0,w.useState)(!1),H=new Set(O.flatMap(e=>e.permissions?.chromeProfiles??[])).size;(0,w.useEffect)(()=>{let e=!0,t=async()=>{if(C?.getComputerUseChromeStatus?.().then(t=>e&&L(t),()=>{}),C?.listComputerUsePermissionHosts&&C.requestComputerUsePermission)try{let t=await C.listComputerUsePermissionHosts(),n=await Promise.all(t.map(async e=>({...e,permissions:await C.requestComputerUsePermission({...e,action:`status`})})));e&&(k(n),N(``))}catch{e&&N(`Could not read helper status. Refresh to try again.`)}finally{e&&j(!1)}};t();let n=C?.onComputerUsePermissionHostsChanged?.(()=>void t()),r=()=>void t();return window.addEventListener(`focus`,r),()=>{e=!1,n?.(),window.removeEventListener(`focus`,r)}},[C]);let U=async e=>{F(!0),N(``);try{await e()}catch(e){N(e instanceof Error?e.message:`Computer Use setup failed.`)}finally{F(!1)}},W=(e,t)=>U(async()=>{let n=await C?.requestComputerUsePermission?.({environmentId:e.environmentId,hostId:e.hostId,action:t});n&&k(t=>t.map(t=>t.hostId===e.hostId?{...t,permissions:n}:t))});return(0,T.jsxs)(v,{children:[(0,T.jsxs)(`header`,{className:`space-y-2 px-3 sm:px-4`,children:[(0,T.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Computer Use`}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Manage how agents interact with apps and browsers on your computer.`})]}),(0,T.jsxs)(y,{title:`Control`,variant:`plain`,children:[(0,T.jsxs)(`div`,{className:`divide-y divide-border overflow-hidden rounded-2xl border border-border`,children:[(0,T.jsx)(E,{icon:o,title:`Desktop apps`,description:`Control apps through the P4 Code desktop helper. Stop active control from the menu bar.`,status:A?`Checking helper…`:O.length?`Connected`:window.desktopBridge?`No helper connected`:`Open the desktop app to set up app control.`,control:C?.revealComputerUseHelper?(0,T.jsx)(a,{size:`sm`,variant:`outline`,disabled:P,onClick:()=>void U(()=>C.revealComputerUseHelper()),children:`Reveal in Finder`}):void 0,children:O.map(e=>(0,T.jsxs)(`div`,{className:`space-y-2 py-3`,children:[(0,T.jsx)(`p`,{className:`text-xs font-medium`,children:e.label}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Allow app interaction and screenshots in macOS settings, then refresh the status.`}),(0,T.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,T.jsxs)(a,{size:`sm`,variant:`outline`,disabled:P,onClick:()=>void W(e,e.permissions?.accessibility?`open-accessibility`:`allow-accessibility`),children:[`Accessibility: `,e.permissions?.accessibility?`Allowed`:`Allow`]}),(0,T.jsxs)(a,{size:`sm`,variant:`outline`,disabled:P,onClick:()=>void W(e,e.permissions?.screenRecording?`open-screen-recording`:`allow-screen-recording`),children:[`Screen Recording: `,e.permissions?.screenRecording?`Allowed`:`Allow`]}),(0,T.jsx)(a,{size:`sm`,variant:`ghost`,disabled:P,onClick:()=>void W(e,`status`),children:`Refresh`})]})]},`${e.environmentId}:${e.hostId}`))}),(0,T.jsx)(E,{icon:i,title:`Google Chrome`,description:`Let agents use your Chrome tabs, and chat about any page from Chrome's side panel.`,status:C?.setupComputerUseChrome?B?`Bridge removed. To remove the extension too, use Remove on chrome://extensions.`:H>0?(0,T.jsxs)(`span`,{className:`flex items-center gap-1.5`,role:`status`,children:[(0,T.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-success`}),`Connected in `,H,` Chrome`,` `,H===1?`profile`:`profiles`,`.`]}):I?.bridgeInstalled&&!R?`Bridge installed. Waiting for the extension to connect.`:void 0:`Install the Chrome extension from the desktop app.`,control:C?.setupComputerUseChrome?(0,T.jsxs)(`div`,{className:`flex gap-2`,children:[I?.bridgeInstalled&&C.removeComputerUseChrome?(0,T.jsx)(a,{size:`sm`,variant:`ghost`,disabled:P,onClick:()=>void U(async()=>{await C.removeComputerUseChrome(),z(void 0),V(!0),L(await C.getComputerUseChromeStatus?.())}),children:`Remove`}):null,H===0||B?(0,T.jsx)(a,{size:`sm`,variant:`outline`,disabled:P,onClick:()=>void U(async()=>{let e=await C.setupComputerUseChrome();V(!1),z({mode:e.mode,chromeOpened:e.chromeOpened}),L(await C.getComputerUseChromeStatus?.())}),children:`Install Chrome extension`}):null]}):void 0,children:(0,T.jsx)(x,{open:R!==void 0&&H===0,children:(0,T.jsx)(b,{children:R?(0,T.jsx)(D,{...R}):null})})})]}),M?(0,T.jsx)(`p`,{className:`px-4 text-sm text-destructive`,role:`alert`,children:M}):null]}),(0,T.jsx)(y,{title:`Navigation`,variant:`plain`,children:(0,T.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border`,children:(0,T.jsx)(E,{icon:c,id:`computer-use-faster-navigation`,title:`Faster navigation`,description:`Use screenshot suggestions from Jev or Luna Decisions to find navigation targets.`,serverScoped:!0,settingKeys:[`decisionVisionEnabled`],control:(0,T.jsx)(S,{"aria-label":`Faster navigation`,checked:n.decisionVisionEnabled,mixed:d,disabled:!u,onCheckedChange:e=>r({decisionVisionEnabled:e})}),children:(0,T.jsxs)(`div`,{className:`space-y-3 py-3`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,T.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[s[n.decisionModel],` ·`,` `,_?`API key saved`:`API key needed`]}),(0,T.jsx)(a,{size:`sm`,variant:`outline`,onClick:()=>void e({to:`/settings/decisions`,search:t.machine?{machine:t.machine}:{}}),children:`Model and API key`})]}),n.decisionVisionEnabled&&!_?(0,T.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:`Add an API key in Decisions to use faster navigation.`}):null,(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`When enabled, screenshots go to the selected service. Suggestions never click by themselves.`})]})})})})]})}var A=k;export{A as component};
2
- //# sourceMappingURL=settings.computer-use-J2r1Wt55.js.map
1
+ import{a as e,t}from"./react-BUfh6y28.js";import{n,t as r}from"./jsx-runtime-DJeoFXNw.js";import{Hd as i,Ry as a,fr as o,ld as s,pm as c}from"./utils-CcBaVOX5.js";import{t as l}from"./useNavigate-PfhtEZbl.js";import{n as u,t as d}from"./kbd-D3uRVBMx.js";import{F as f,I as p,L as m,R as h,V as g,a as _,i as v,s as y}from"./settingsLayout-krWuVpsF.js";import{go as b,mo as x,po as S}from"./main-DIEsHSIy.js";var C=n(),w=e(t(),1),T=e(r(),1);function E(e){let t=(0,C.c)(10),n,r;t[0]===e?(n=t[1],r=t[2]):({icon:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=(0,T.jsx)(`span`,{className:`mt-3 ml-4 flex size-10 shrink-0 items-center justify-center rounded-xl bg-muted text-muted-foreground`,children:(0,T.jsx)(n,{"aria-hidden":!0,className:`size-5`})}),t[3]=n,t[4]=i);let a;t[5]===r?a=t[6]:(a=(0,T.jsx)(_,{...r,className:`min-w-0 flex-1`}),t[5]=r,t[6]=a);let o;return t[7]!==i||t[8]!==a?(o=(0,T.jsxs)(`div`,{className:`flex items-start`,children:[i,a]}),t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function D(e){let t=(0,C.c)(9),{mode:n,chromeOpened:r}=e,i;t[0]===n?i=t[1]:(i=n===`store`?[`In the Chrome Web Store tab, click Add to Chrome.`,`Confirm with Add extension.`]:[`In Chrome, go to chrome://extensions.`,`Turn on Developer mode.`,`Click Load unpacked.`,(0,T.jsxs)(T.Fragment,{children:[`Press`,` `,(0,T.jsxs)(u,{children:[(0,T.jsx)(d,{children:`⌘`}),(0,T.jsx)(d,{children:`⇧`}),(0,T.jsx)(d,{children:`G`})]}),`, paste the copied folder path, press Return, then click Select.`]})],t[0]=n,t[1]=i);let a=i,o;t[2]===r?o=t[3]:(o=r?null:(0,T.jsx)(`li`,{children:`Open Google Chrome.`}),t[2]=r,t[3]=o);let s;t[4]===a?s=t[5]:(s=a.map(O),t[4]=a,t[5]=s);let c;return t[6]!==o||t[7]!==s?(c=(0,T.jsxs)(`ol`,{className:`list-decimal space-y-1.5 py-3 pl-5 text-xs text-muted-foreground`,role:`status`,children:[o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function O(e,t){return(0,T.jsx)(`li`,{children:e},t)}function k(){let e=l(),{search:t}=g(),n=f(),r=h(),u=m(),d=p([`decisionVisionEnabled`]),_=!!n.decisionOpenRouterKey,C=window.desktopBridge,[O,k]=(0,w.useState)([]),[A,j]=(0,w.useState)(!!C?.listComputerUsePermissionHosts),[M,N]=(0,w.useState)(``),[P,F]=(0,w.useState)(!1),[I,L]=(0,w.useState)(),[R,z]=(0,w.useState)(),[B,V]=(0,w.useState)(!1),H=new Set(O.flatMap(e=>e.permissions?.chromeProfiles??[])).size;(0,w.useEffect)(()=>{let e=!0,t=async()=>{if(C?.getComputerUseChromeStatus?.().then(t=>e&&L(t),()=>{}),C?.listComputerUsePermissionHosts&&C.requestComputerUsePermission)try{let t=await C.listComputerUsePermissionHosts(),n=await Promise.all(t.map(async e=>({...e,permissions:await C.requestComputerUsePermission({...e,action:`status`})})));e&&(k(n),N(``))}catch{e&&N(`Could not read helper status. Refresh to try again.`)}finally{e&&j(!1)}};t();let n=C?.onComputerUsePermissionHostsChanged?.(()=>void t()),r=()=>void t();return window.addEventListener(`focus`,r),()=>{e=!1,n?.(),window.removeEventListener(`focus`,r)}},[C]);let U=async e=>{F(!0),N(``);try{await e()}catch(e){N(e instanceof Error?e.message:`Computer Use setup failed.`)}finally{F(!1)}},W=(e,t)=>U(async()=>{let n=await C?.requestComputerUsePermission?.({environmentId:e.environmentId,hostId:e.hostId,action:t});n&&k(t=>t.map(t=>t.hostId===e.hostId?{...t,permissions:n}:t))});return(0,T.jsxs)(v,{children:[(0,T.jsxs)(`header`,{className:`space-y-2 px-3 sm:px-4`,children:[(0,T.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Computer Use`}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Manage how agents interact with apps and browsers on your computer.`})]}),(0,T.jsxs)(y,{title:`Control`,variant:`plain`,children:[(0,T.jsxs)(`div`,{className:`divide-y divide-border overflow-hidden rounded-2xl border border-border`,children:[(0,T.jsx)(E,{icon:s,title:`Desktop apps`,description:`Control apps through the P4 Code desktop helper. Stop active control from the menu bar.`,status:A?`Checking helper…`:O.length?`Connected`:window.desktopBridge?`No helper connected`:`Open the desktop app to set up app control.`,control:C?.revealComputerUseHelper?(0,T.jsx)(o,{size:`sm`,variant:`outline`,disabled:P,onClick:()=>void U(()=>C.revealComputerUseHelper()),children:`Reveal in Finder`}):void 0,children:O.map(e=>(0,T.jsxs)(`div`,{className:`space-y-2 py-3`,children:[(0,T.jsx)(`p`,{className:`text-xs font-medium`,children:e.label}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Allow app interaction and screenshots in macOS settings, then refresh the status.`}),(0,T.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,T.jsxs)(o,{size:`sm`,variant:`outline`,disabled:P,onClick:()=>void W(e,e.permissions?.accessibility?`open-accessibility`:`allow-accessibility`),children:[`Accessibility: `,e.permissions?.accessibility?`Allowed`:`Allow`]}),(0,T.jsxs)(o,{size:`sm`,variant:`outline`,disabled:P,onClick:()=>void W(e,e.permissions?.screenRecording?`open-screen-recording`:`allow-screen-recording`),children:[`Screen Recording: `,e.permissions?.screenRecording?`Allowed`:`Allow`]}),(0,T.jsx)(o,{size:`sm`,variant:`ghost`,disabled:P,onClick:()=>void W(e,`status`),children:`Refresh`})]})]},`${e.environmentId}:${e.hostId}`))}),(0,T.jsx)(E,{icon:i,title:`Google Chrome`,description:`Let agents use your Chrome tabs, and chat about any page from Chrome's side panel.`,status:C?.setupComputerUseChrome?B?`Bridge removed. To remove the extension too, use Remove on chrome://extensions.`:H>0?(0,T.jsxs)(`span`,{className:`flex items-center gap-1.5`,role:`status`,children:[(0,T.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-success`}),`Connected in `,H,` Chrome`,` `,H===1?`profile`:`profiles`,`.`]}):I?.bridgeInstalled&&!R?`Bridge installed. Waiting for the extension to connect.`:void 0:`Install the Chrome extension from the desktop app.`,control:C?.setupComputerUseChrome?(0,T.jsxs)(`div`,{className:`flex gap-2`,children:[I?.bridgeInstalled&&C.removeComputerUseChrome?(0,T.jsx)(o,{size:`sm`,variant:`ghost`,disabled:P,onClick:()=>void U(async()=>{await C.removeComputerUseChrome(),z(void 0),V(!0),L(await C.getComputerUseChromeStatus?.())}),children:`Remove`}):null,H===0||B?(0,T.jsx)(o,{size:`sm`,variant:`outline`,disabled:P,onClick:()=>void U(async()=>{let e=await C.setupComputerUseChrome();V(!1),z({mode:e.mode,chromeOpened:e.chromeOpened}),L(await C.getComputerUseChromeStatus?.())}),children:`Install Chrome extension`}):null]}):void 0,children:(0,T.jsx)(S,{open:R!==void 0&&H===0,children:(0,T.jsx)(x,{children:R?(0,T.jsx)(D,{...R}):null})})})]}),M?(0,T.jsx)(`p`,{className:`px-4 text-sm text-destructive`,role:`alert`,children:M}):null]}),(0,T.jsx)(y,{title:`Navigation`,variant:`plain`,children:(0,T.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-border`,children:(0,T.jsx)(E,{icon:c,id:`computer-use-faster-navigation`,title:`Faster navigation`,description:`Use screenshot suggestions from Jev or Luna Decisions to find navigation targets.`,serverScoped:!0,settingKeys:[`decisionVisionEnabled`],control:(0,T.jsx)(b,{"aria-label":`Faster navigation`,checked:n.decisionVisionEnabled,mixed:d,disabled:!u,onCheckedChange:e=>r({decisionVisionEnabled:e})}),children:(0,T.jsxs)(`div`,{className:`space-y-3 py-3`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,T.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[a[n.decisionModel],` ·`,` `,_?`API key saved`:`API key needed`]}),(0,T.jsx)(o,{size:`sm`,variant:`outline`,onClick:()=>void e({to:`/settings/decisions`,search:t.machine?{machine:t.machine}:{}}),children:`Model and API key`})]}),n.decisionVisionEnabled&&!_?(0,T.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:`Add an API key in Decisions to use faster navigation.`}):null,(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`When enabled, screenshots go to the selected service. Suggestions never click by themselves.`})]})})})})]})}var A=k;export{A as component};
2
+ //# sourceMappingURL=settings.computer-use-CDrWkvkD.js.map
@@ -0,0 +1,2 @@
1
+ import{a as e,t}from"./react-BUfh6y28.js";import{n,t as r}from"./jsx-runtime-DJeoFXNw.js";import{t as i}from"./plus-B2sOrZDk.js";import{$_ as a,$l as o,AC as s,Bd as c,Bv as l,Cx as u,Dx as d,Kf as f,M_ as p,O_ as m,Pl as h,Px as g,Q_ as _,Qo as v,Rd as y,Rm as b,SE as x,X_ as S,Xn as C,Y_ as w,Yc as T,_s as E,aE as D,av as O,cr as k,cs as A,cv as j,dr as M,dv as N,er as P,eu as F,ev as ee,fS as I,ff as te,fr as L,fv as ne,hE as re,ir as ie,iv as ae,lr as oe,lv as R,ms as se,nb as ce,nm as le,nr as ue,ns as de,om as fe,or as z,ov as pe,pm as me,pr as he,pv as ge,q_ as _e,rr as B,rv as V,ss as ve,sv as ye,t as be,uh as H,ur as xe,uv as Se,vE as Ce,vv as we,yE as Te,yb as Ee}from"./utils-CcBaVOX5.js";import{Dt as U,Et as De,F as Oe,Ht as ke,On as Ae,Ot as W,R as je,Ut as G,W as Me,jt as K,kt as Ne,o as Pe,on as Fe,tt as Ie,w as Le,x as Re}from"./runtime-DeVKKxNz.js";import{E as ze,F as Be,Ft as Ve,Pt as q,S as He,_ as Ue,jt as We,kt as Ge,t as Ke}from"./runtime-DCbEdU32.js";import{a as qe,c as Je,o as Ye,s as Xe,t as Ze}from"./select-oshTwPZM.js";import{t as Qe}from"./spinner-BeAnBYcY.js";import{i as J,p as $e}from"./toast-Dkj3G-UM.js";import{A as et,D as tt,E as nt,O as Y,_ as rt,c as it,et as at,s as ot,y as st}from"./useSettings-Cg0O7Ek7.js";import{f as ct,h as lt,s as ut}from"./server-Ct4-BCZx.js";import{a as dt,i as ft,n as pt,o as mt,s as ht}from"./session-Bb7JWdWO.js";import{n as gt}from"./query-D5Kb9u_z.js";import{t as _t}from"./use-atom-command-D4TeQyNE.js";import{t as vt}from"./toastHelpers-DxXYm50b.js";import{i as yt,r as bt}from"./timestampFormat-wac2e_Jz.js";import{a as xt,n as St,t as Ct}from"./tooltip-BeHmtauD.js";import{t as wt}from"./textarea-DBTtAB2q.js";import{t as Tt}from"./input-CSgYZgdv.js";import{t as Et}from"./scroll-area-C9Jh_pl0.js";import{a as Dt,c as Ot,i as kt,l as At,n as jt,o as Mt,r as Nt,s as Pt,t as Ft}from"./dialog-CjB1WWbE.js";import{n as It}from"./P4ConnectAccountPages-DwBbHN5Q.js";import{a as Lt,i as Rt,o as zt,r as Bt,t as Vt}from"./empty-CMnFXg8W.js";import{t as Ht}from"./AnimatedHeight-DEeywxgS.js";import{C as Ut,_ as Wt,w as Gt,y as Kt}from"./keybindings-B9X0TLvu.js";import{i as qt,o as Jt,t as Yt}from"./popover-Cpc0L75h.js";import{a as Xt,c as Zt,i as Qt,l as $t,r as en,s as tn,t as nn,u as rn}from"./LinkMachineSelect-DoHeQGoj.js";import{t as an}from"./checkbox-Bqcsvpsf.js";import{r as on}from"./uiStateStore-Cd96D_GT.js";import{n as sn,t as cn}from"./EnvironmentMachineIcon-oObSi9GI.js";import{r as ln,t as un}from"./alert-UH7IbYie.js";import{a as dn,i as fn,n as pn,o as mn,r as hn,s as gn,t as _n}from"./alert-dialog-D3mCT6Vy.js";import{a as vn,i as yn,s as bn,u as X}from"./settingsLayout-krWuVpsF.js";import{_ as xn,b as Sn,g as Cn,h as wn,v as Tn,x as En,y as Dn}from"./command-cKnhWwdw.js";import{t as On}from"./ConnectionStatusDot-CR_qWdCU.js";import{a as kn,n as An,o as jn,s as Mn,t as Nn}from"./primary-YDhFfOF8.js";import{n as Pn,t as Fn}from"./onboarding-D6kvYnD1.js";import{$r as In,Ai as Ln,Ar as Rn,Br as zn,Ci as Bn,Di as Vn,Fi as Hn,Ii as Un,Mi as Wn,Ni as Gn,Oi as Kn,Pi as qn,Qr as Jn,Rr as Yn,Si as Xn,T as Zn,Ti as Qn,Tr as $n,Vr as er,Xr as tr,Yr as nr,an as rr,ar as ir,br as ar,cn as or,cr as sr,fr as cr,go as lr,gr as ur,hr as dr,ji as fr,ki as pr,ln as mr,lr as hr,mo as gr,or as _r,po as vr,pr as yr,sn as br,sr as xr,ur as Sr,wi as Cr,wr,zr as Tr}from"./main-DIEsHSIy.js";import{n as Er}from"./ConnectAgentSurface-TBgGDnVI.js";import{t as Dr}from"./FoldedSettingsSection-DPTJODig.js";var Z=n(),Or=[{scope:ae,title:`View environment`,description:`Read threads, status, checkpoints, and configuration.`},{scope:V,title:`Operate tasks`,description:`Start, update, and stop tasks.`},{scope:R,title:`Change environment settings`,description:`Edit environment preferences and keybindings.`},{scope:pe,title:`Manage providers`,description:`Configure, install, sign in to, and update providers and usage sources.`},{scope:_,title:`Maintain environment`,description:`Update the server and control environment processes.`},{scope:O,title:`Control previews`,description:`Open browser previews and host browser automation.`},{scope:S,title:`View diagnostics and usage`,description:`Read process diagnostics, resource history, and usage totals.`},{scope:ge,title:`View terminals`,description:`Read existing terminal output and status.`},{scope:ne,title:`Use terminals`,description:`Create terminals and send input to running shells.`},{scope:Se,title:`Change source control`,description:`Commit, push, manage branches and repositories, and change pull requests.`},{scope:a,title:`Read files`,description:`Browse host files, search workspaces, and inspect local changes.`},{scope:ee,title:`Write files`,description:`Edit workspace files and save plans to disk.`},{scope:_e,title:`View access`,description:`Inspect pairing links and authorized clients.`},{scope:w,title:`Manage access`,description:`Issue and revoke credentials for other clients.`},{scope:ye,title:`View relay`,description:`Inspect managed relay connectivity.`},{scope:j,title:`Manage relay`,description:`Change managed tunnel connectivity.`}],Q=e(r(),1);function kr(e){let t=(0,Z.c)(4),{environmentId:n,connected:r,routeContext:i}=e,a=i!==void 0&&i,o=dt(n),s;return t[0]!==r||t[1]!==a||t[2]!==o?(s=r&&!o.hasError&&!o.isPending&&o.data?.authenticated?(0,Q.jsxs)(`div`,{className:`space-y-3 py-3 text-xs`,children:[(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:a?`These permissions apply to your active route. Other routes may have different permissions.`:`These permissions apply to this client’s current connection.`}),(0,Q.jsx)(`ul`,{className:`grid gap-x-6 gap-y-2 sm:grid-cols-2`,children:Or.map(e=>{let{scope:t,title:n}=e;return(0,Q.jsxs)(`li`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsx)(`span`,{children:n}),(0,Q.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:we(o.data,t)?`Allowed`:`Not granted`})]},t)})})]}):(0,Q.jsx)(`p`,{className:`py-3 text-xs text-muted-foreground`,children:`Permissions not checked. Connect to this environment to view this session’s permissions.`}),t[0]=r,t[1]=a,t[2]=o,t[3]=s):s=t[3],s}var $=e(t(),1);function Ar(e,t){let n=new URL(e);return n.pathname=`/pair`,Ve(n,t).toString()}function jr(e,t){return new URL(e).protocol===`https:`?He({host:e,token:t}):null}function Mr(){let e=(0,Z.c)(48),t=window.desktopBridge?.setLocalEnvironmentEnabled,[n]=(0,$.useState)(Nr),[r,i]=(0,$.useState)(!1),[a,o]=(0,$.useState)(!1),[s,c]=(0,$.useState)(null);if(!t)return null;let l;e[0]===n?l=e[1]:(l=async()=>{o(!0),c(null);try{await t(!n)}catch(e){let t=e;c(t instanceof Error?t.message:`Couldn't change this setting.`),o(!1)}},e[0]=n,e[1]=l);let u=l,d;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=Rn(`local-environment`),e[2]=d):d=e[2];let f=n?`Run agents on this computer. Turn off to use P4 Code only with remote environments.`:`Turned off. Agents only run in remote environments.`,p;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>i(!0),e[3]=p):p=e[3];let m;e[4]!==n||e[5]!==a?(m=(0,Q.jsx)(lr,{checked:n,disabled:a,onCheckedChange:p,"aria-label":`Local environment`}),e[4]=n,e[5]=a,e[6]=m):m=e[6];let h;e[7]!==f||e[8]!==m?(h=(0,Q.jsx)(vn,{...d,description:f,control:m}),e[7]=f,e[8]=m,e[9]=h):h=e[9];let g;e[10]===a?g=e[11]:(g=e=>{a||(i(e),e||c(null))},e[10]=a,e[11]=g);let _=n?`Turn off local environment?`:`Turn on local environment?`,v;e[12]===_?v=e[13]:(v=(0,Q.jsx)(gn,{children:_}),e[12]=_,e[13]=v);let y=n?`P4 Code will restart without running a server on this computer. Any agents and terminals running here will stop, and other devices will no longer be able to connect to this computer. Your projects, history, and remote environments are unaffected.`:`P4 Code will restart and start running a server on this computer again.`,b;e[14]===y?b=e[15]:(b=(0,Q.jsx)(hn,{children:y}),e[14]=y,e[15]=b);let x;e[16]!==b||e[17]!==v?(x=(0,Q.jsxs)(dn,{children:[v,b]}),e[16]=b,e[17]=v,e[18]=x):x=e[18];let S;e[19]===s?S=e[20]:(S=s?(0,Q.jsx)(`p`,{className:`px-6 pb-4 text-sm text-destructive`,children:s}):null,e[19]=s,e[20]=S);let C;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(L,{variant:`outline`}),e[21]=C):C=e[21];let w;e[22]===a?w=e[23]:(w=(0,Q.jsx)(pn,{disabled:a,render:C,children:`Cancel`}),e[22]=a,e[23]=w);let T=n?`destructive`:`default`,E;e[24]===u?E=e[25]:(E=()=>void u(),e[24]=u,e[25]=E);let D;e[26]!==n||e[27]!==a?(D=a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qe,{size:`sm`}),`Restarting…`]}):n?`Restart and turn off`:`Restart and turn on`,e[26]=n,e[27]=a,e[28]=D):D=e[28];let O;e[29]!==a||e[30]!==T||e[31]!==E||e[32]!==D?(O=(0,Q.jsx)(L,{variant:T,disabled:a,onClick:E,children:D}),e[29]=a,e[30]=T,e[31]=E,e[32]=D,e[33]=O):O=e[33];let k;e[34]!==w||e[35]!==O?(k=(0,Q.jsxs)(fn,{children:[w,O]}),e[34]=w,e[35]=O,e[36]=k):k=e[36];let A;e[37]!==x||e[38]!==S||e[39]!==k?(A=(0,Q.jsxs)(mn,{children:[x,S,k]}),e[37]=x,e[38]=S,e[39]=k,e[40]=A):A=e[40];let j;e[41]!==r||e[42]!==A||e[43]!==g?(j=(0,Q.jsx)(_n,{open:r,onOpenChange:g,children:A}),e[41]=r,e[42]=A,e[43]=g,e[44]=j):j=e[44];let M;return e[45]!==j||e[46]!==h?(M=(0,Q.jsxs)(Q.Fragment,{children:[h,j]}),e[45]=j,e[46]=h,e[47]=M):M=e[47],M}function Nr(){return!Le()}function Pr(e){return e.serverConfig===null?`Connect to this environment to change its icon.`:e.serverConfig.environment.capabilities.environmentIcon===!0?e.operateAccess===`granted`?null:`Your session on this environment cannot change its settings.`:`This environment's server is too old to keep an icon. Update it to choose one.`}function Fr(e){let t=(0,Z.c)(27),{environmentId:n,serverConfig:r}=e,i=st(n),a=ft(n,`settings:write`)?`granted`:`denied`,o;t[0]!==a||t[1]!==r?(o=Pr({serverConfig:r,operateAccess:a}),t[0]=a,t[1]=r,t[2]=o):o=t[2];let s=o,c=r?.environment.platform.machine??`server`,l;t[3]===r?l=t[4]:(l=h(r),t[3]=r,t[4]=l);let u=l,d;t[5]===u?d=t[6]:(d=(0,Q.jsxs)(xe,{children:[(0,Q.jsx)(sn,{kind:u}),`Icon`]}),t[5]=u,t[6]=d);let f;t[7]===s?f=t[8]:(f=s===null?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(P,{disabled:!0,className:`whitespace-normal`,children:s}),(0,Q.jsx)(z,{})]}),t[7]=s,t[8]=f);let g;t[9]!==c||t[10]!==s||t[11]!==i?(g=e=>{s===null&&p(e)&&i({environmentIcon:e===c?null:e})},t[9]=c,t[10]=s,t[11]=i,t[12]=g):g=t[12];let _;t[13]!==c||t[14]!==s||t[15]!==r?.environment?(_=m.map(e=>(0,Q.jsx)(ie,{value:e,disabled:s!==null,children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(sn,{kind:e,className:`size-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:cn[e]}),e===c?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:r?.environment.platform.machine?`detected`:`default`}):null]})},e)),t[13]=c,t[14]=s,t[15]=r?.environment,t[16]=_):_=t[16];let v;t[17]!==u||t[18]!==g||t[19]!==_?(v=(0,Q.jsx)(B,{value:u,onValueChange:g,children:_}),t[17]=u,t[18]=g,t[19]=_,t[20]=v):v=t[20];let y;t[21]!==f||t[22]!==v?(y=(0,Q.jsxs)(oe,{children:[f,v]}),t[21]=f,t[22]=v,t[23]=y):y=t[23];let b;return t[24]!==d||t[25]!==y?(b=(0,Q.jsxs)(k,{children:[d,y]}),t[24]=d,t[25]=y,t[26]=b):b=t[26],b}function Ir(e){let t=(0,Z.c)(31),{environment:n,onAddRoute:r}=e,i=Ne(n.entry),a=i.map(Rr),[o,s]=(0,$.useState)(null),c=o!==null&&o.length===a.length&&o.some((e,t)=>e!==a[t])?[...o]:a,l=new Map(i.map(Lr)),u=c.flatMap(e=>l.get(e)??[]),d=ht(n.environmentId),f;t[0]!==n.connection||t[1]!==d._tag||t[2]!==d.value?(f=d._tag===`Some`&&n.connection.phase===`connected`?U(d.value.target):null,t[0]=n.connection,t[1]=d._tag,t[2]=d.value,t[3]=f):f=t[3];let p=f,m=_t(lt.reorderRoutes,`Reorder routes`),h=_t(lt.removeRoute,`Remove route`),g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g={activationConstraint:{distance:4}},t[4]=g):g=t[4];let _;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_={coordinateGetter:Vn},t[5]=_):_=t[5];let v=Hn(qn(Wn,g),qn(fr,_)),y;t[6]!==n.environmentId||t[7]!==h?(y=async e=>{let t=De(e);await at(`Remove ${W(e)} route?${t===null?``:`\n${t}`}`,{variant:`destructive`})===!0&&await h({environmentId:n.environmentId,routeId:U(e.target)})},t[6]=n.environmentId,t[7]=h,t[8]=y):y=t[8];let b=y,x=e=>{if(e.over===null||e.active.id===e.over.id)return;let t=Qn(c,c.indexOf(String(e.active.id)),c.indexOf(String(e.over.id)));s(t),m({environmentId:n.environmentId,routeIds:t}).then(e=>{e._tag===`Failure`&&s(null)})},S=Ln,C=Gn,w;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(w=[Bn,Xn],t[9]=w):w=t[9];let T=Cr,E=pr,D=`Routes to ${n.label}, preferred first`,O=u.map((e,t)=>(0,Q.jsx)(zr,{route:e,position:t+1,inUse:U(e.target)===p,removable:u.length>1&&!K(e),onRemove:()=>void b(e)},U(e.target))),k;t[10]!==O||t[11]!==D?(k=(0,Q.jsx)(`ol`,{"aria-label":D,children:O}),t[10]=O,t[11]=D,t[12]=k):k=t[12];let A;t[13]!==T||t[14]!==c||t[15]!==k||t[16]!==E?(A=(0,Q.jsx)(T,{items:c,strategy:E,children:k}),t[13]=T,t[14]=c,t[15]=k,t[16]=E,t[17]=A):A=t[17];let j;t[18]!==S||t[19]!==x||t[20]!==v||t[21]!==A||t[22]!==C||t[23]!==w?(j=(0,Q.jsx)(S,{sensors:v,collisionDetection:C,modifiers:w,onDragEnd:x,children:A}),t[18]=S,t[19]=x,t[20]=v,t[21]=A,t[22]=C,t[23]=w,t[24]=j):j=t[24];let M;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Q.jsx)(le,{className:`size-3`}),t[25]=M):M=t[25];let N;t[26]===r?N=t[27]:(N=(0,Q.jsx)(`div`,{className:`-ml-1.5 pt-1`,children:(0,Q.jsxs)(L,{size:`xs`,variant:`ghost-muted`,onClick:r,children:[M,`Add route`]})}),t[26]=r,t[27]=N);let P;return t[28]!==j||t[29]!==N?(P=(0,Q.jsxs)(`div`,{className:`mt-2 border-t border-border/50 py-2`,children:[j,N]}),t[28]=j,t[29]=N,t[30]=P):P=t[30],P}function Lr(e){return[U(e.target),e]}function Rr(e){return U(e.target)}function zr(e){let t=(0,Z.c)(43),{route:n,position:r,inUse:i,removable:a,onRemove:o}=e,s;t[0]===n.target?s=t[1]:(s=U(n.target),t[0]=n.target,t[1]=s);let c=s,l;t[2]===n?l=t[3]:(l=W(n),t[2]=n,t[3]=l);let u=l,d;t[4]===n?d=t[5]:(d=De(n),t[4]=n,t[5]=d);let p=d,m;t[6]===c?m=t[7]:(m={id:c},t[6]=c,t[7]=m);let{attributes:h,listeners:g,setNodeRef:_,setActivatorNodeRef:v,transform:y,transition:b,isDragging:x}=Kn(m),S;t[8]===y?S=t[9]:(S=Un.Translate.toString(y),t[8]=y,t[9]=S);let C;t[10]!==S||t[11]!==b?(C={transform:S,transition:b},t[10]=S,t[11]=b,t[12]=C):C=t[12];let w=x&&`relative z-10 rounded-md bg-background shadow-md`,T;t[13]===w?T=t[14]:(T=be(`flex items-center gap-2 py-2`,w),t[13]=w,t[14]=T);let E;t[15]===i?E=t[16]:(E=i?(0,Q.jsx)(`span`,{className:`rounded-sm bg-success/12 px-1 text-2xs font-normal text-success-foreground`,children:`In use`}):null,t[15]=i,t[16]=E);let D;t[17]!==u||t[18]!==E?(D=(0,Q.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[u,E]}),t[17]=u,t[18]=E,t[19]=D):D=t[19];let O;t[20]!==p||t[21]!==n?(O=p===null?null:(0,Q.jsxs)(`p`,{className:`truncate text-2xs text-muted-foreground`,children:[p,K(n)?` · found automatically`:``]}),t[20]=p,t[21]=n,t[22]=O):O=t[22];let k;t[23]!==D||t[24]!==O?(k=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[D,O]}),t[23]=D,t[24]=O,t[25]=k):k=t[25];let A=`Reorder ${u}, position ${r}`,j;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Q.jsx)(f,{className:`size-3.5`}),t[26]=j):j=t[26];let M;t[27]!==h||t[28]!==g||t[29]!==v||t[30]!==A?(M=(0,Q.jsx)(`button`,{type:`button`,ref:v,...h,...g,"aria-label":A,className:`flex size-6 shrink-0 cursor-grab touch-none items-center justify-center rounded text-muted-foreground/70 outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring active:cursor-grabbing`,children:j}),t[27]=h,t[28]=g,t[29]=v,t[30]=A,t[31]=M):M=t[31];let N;t[32]!==u||t[33]!==o||t[34]!==a?(N=a?(0,Q.jsxs)(Ct,{children:[(0,Q.jsx)(xt,{render:(0,Q.jsx)(L,{type:`button`,variant:`ghost-muted`,size:`icon-xs`,"aria-label":`Remove ${u} route`,onClick:o}),children:(0,Q.jsx)(H,{className:`size-3`})}),(0,Q.jsx)(St,{side:`top`,children:`Remove route`})]}):null,t[32]=u,t[33]=o,t[34]=a,t[35]=N):N=t[35];let P;return t[36]!==_||t[37]!==k||t[38]!==M||t[39]!==N||t[40]!==C||t[41]!==T?(P=(0,Q.jsxs)(`li`,{ref:_,style:C,className:T,children:[k,M,N]}),t[36]=_,t[37]=k,t[38]=M,t[39]=N,t[40]=C,t[41]=T,t[42]=P):P=t[42],P}function Br(e){let t=e.username?`${e.username}@${e.hostname}`:e.hostname;return e.port?`${t}:${e.port}`:t}function Vr(e,t=null){let{entry:n}=e;if(n.target._tag===`PrimaryConnectionTarget`)return`This machine`;let r=Ne(n);if(r.length>1){let e=t===null?void 0:r.find(e=>U(e.target)===U(t));return e===void 0?W(r[0]):`via ${W(e)}`}return e.relayManaged?`P4 Connect`:Ue(n.target)?`WSL`:n.target._tag===`SshConnectionTarget`&&Te(n.profile)&&n.profile.value._tag===`SshConnectionProfile`?`SSH ${Br(n.profile.value.target)}`:e.displayUrl??`Remote link`}function Hr(e){let t=(0,Z.c)(23),{kind:n,label:r,subtitle:i,below:a,detail:o,dimmed:s,className:c,children:l}=e,u=s!==void 0&&s&&`opacity-60`,d;t[0]!==c||t[1]!==u?(d=be(`grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-3 px-3 py-2.5 sm:px-4`,u,c),t[0]=c,t[1]=u,t[2]=d):d=t[2];let f;t[3]===n?f=t[4]:(f=(0,Q.jsx)(sn,{"aria-hidden":!0,kind:n,className:`size-4 text-muted-foreground`}),t[3]=n,t[4]=f);let p;t[5]===r?p=t[6]:(p=(0,Q.jsx)(`p`,{className:`truncate text-sm font-medium text-foreground`,children:r}),t[5]=r,t[6]=p);let m;t[7]===i?m=t[8]:(m=(0,Q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:i}),t[7]=i,t[8]=m);let h;t[9]!==a||t[10]!==p||t[11]!==m?(h=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[p,m,a]}),t[9]=a,t[10]=p,t[11]=m,t[12]=h):h=t[12];let g;t[13]===l?g=t[14]:(g=(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:l}),t[13]=l,t[14]=g);let _;t[15]===o?_=t[16]:(_=o?(0,Q.jsx)(`div`,{className:`col-span-2 col-start-2 min-w-0`,children:o}):null,t[15]=o,t[16]=_);let v;return t[17]!==d||t[18]!==f||t[19]!==h||t[20]!==g||t[21]!==_?(v=(0,Q.jsxs)(`div`,{className:d,children:[f,h,g,_]}),t[17]=d,t[18]=f,t[19]=h,t[20]=g,t[21]=_,t[22]=v):v=t[22],v}var Ur=(e,t)=>J.add(vt({type:`error`,title:e,description:t}));function Wr(e){let t=(0,Z.c)(19),{environmentId:n,environmentLabel:r,isSearchTarget:i}=e,a;t[0]===n?a=t[1]:(a=cr.list({environmentId:n,input:{}}),t[0]=n,t[1]=a);let o=gt(a),s;t[2]===n?s=t[3]:(s=cr.link.permissionAtom(n),t[2]=n,t[3]=s);let c=de(s),l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=Rn(`linked-environments`),t[4]=l):l=t[4];let u=l,d;t[5]===i?d=t[6]:(d=i?{id:u.id}:{},t[5]=i,t[6]=d);let f=r===null?u.title:`${u.title} · ${r}`,p;t[7]!==c||t[8]!==n?(p=c?(0,Q.jsx)(Kr,{environmentId:n}):null,t[7]=c,t[8]=n,t[9]=p):p=t[9];let m;t[10]!==n||t[11]!==o.data||t[12]!==o.error?(m=o.error?(0,Q.jsx)(vn,{title:`Could not load linked environments`,description:o.error}):o.data?o.data.links.length===0?(0,Q.jsx)(vn,{title:`No linked environments`,description:`Link another machine running P4 Code, such as a VPS, so agents here can launch and drive threads there.`}):o.data.links.map(e=>(0,Q.jsx)(Gr,{environmentId:n,link:e},e.environmentId)):(0,Q.jsx)(vn,{title:`Loading linked environments…`,role:`status`}),t[10]=n,t[11]=o.data,t[12]=o.error,t[13]=m):m=t[13];let h;return t[14]!==d||t[15]!==f||t[16]!==p||t[17]!==m?(h=(0,Q.jsx)(bn,{...d,title:f,headerAction:p,children:m}),t[14]=d,t[15]=f,t[16]=p,t[17]=m,t[18]=h):h=t[18],h}function Gr(e){let t=(0,Z.c)(37),{environmentId:n,link:r}=e,i=rn(),a;t[0]!==r||t[1]!==i?(a=ur(r,d(i)),t[0]=r,t[1]=i,t[2]=a):a=t[2];let o=a,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s={label:`unlink environment`},t[3]=s):s=t[3];let c=_t(cr.unlink,s),l;t[4]===n?l=t[5]:(l=cr.unlink.permissionAtom(n),t[4]=n,t[5]=l);let u=de(l),[f,p]=(0,$.useState)(!1),m;t[6]!==n||t[7]!==r.environmentId||t[8]!==r.label||t[9]!==c?(m=async()=>{if(!await(at(`Forget ${r.label}? Agents here stop working there. Revoke "P4 Code · …" in ${r.label}'s Connections to end the session there too.`,{variant:`destructive`})??Promise.resolve(!1)))return;p(!0);let e=await c({environmentId:n,input:{environmentId:r.environmentId}});p(!1),e._tag===`Failure`&&!je(e)&&Ur(`Could not forget the link`,String(Me(e)))},t[6]=n,t[7]=r.environmentId,t[8]=r.label,t[9]=c,t[10]=m):m=t[10];let h=m,g=o.kind===`expired`?`Expired. Link it again with a new pairing code.`:o.kind===`unreachable`?o.detail??`Not answering right now.`:o.kind===`failing`?o.detail:o.expiresInDays===null?`Reachable`:`Expires in ${o.expiresInDays} ${o.expiresInDays===1?`day`:`days`}. Link it again to renew.`,_=o.kind===`reachable`?o.expiresInDays===null?`bg-success`:`bg-warning`:o.kind===`expired`||o.kind===`failing`?`bg-destructive`:`bg-muted-foreground/30`,v;t[11]!==g||t[12]!==_?(v=(0,Q.jsx)(On,{tooltipText:g,dotClassName:_,pingClassName:null}),t[11]=g,t[12]=_,t[13]=v):v=t[13];let y;t[14]===r.label?y=t[15]:(y=(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:r.label}),t[14]=r.label,t[15]=y);let b;t[16]!==v||t[17]!==y?(b=(0,Q.jsxs)(`div`,{className:`flex min-h-5 items-center gap-1.5`,children:[v,y]}),t[16]=v,t[17]=y,t[18]=b):b=t[18];let x=Er[r.access],S;t[19]!==g||t[20]!==x.label?(S=(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[x.label,` · `,g]}),t[19]=g,t[20]=x.label,t[21]=S):S=t[21];let C;t[22]===r.urls?C=t[23]:(C=r.urls.join(`, `),t[22]=r.urls,t[23]=C);let w;t[24]===C?w=t[25]:(w=(0,Q.jsx)(`p`,{className:`truncate text-xs text-muted-foreground/80`,children:C}),t[24]=C,t[25]=w);let T;t[26]!==S||t[27]!==w||t[28]!==b?(T=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[b,S,w]}),t[26]=S,t[27]=w,t[28]=b,t[29]=T):T=t[29];let E;t[30]!==f||t[31]!==u||t[32]!==h?(E=u?(0,Q.jsx)(`div`,{className:`flex w-full shrink-0 items-center gap-2 sm:w-auto sm:justify-end`,children:(0,Q.jsx)(L,{size:`xs`,variant:`destructive-outline`,disabled:f,onClick:()=>void h(),children:f?`Forgetting…`:`Forget`})}):null,t[30]=f,t[31]=u,t[32]=h,t[33]=E):E=t[33];let D;return t[34]!==T||t[35]!==E?(D=(0,Q.jsx)(`div`,{className:br,children:(0,Q.jsxs)(`div`,{className:or,children:[T,E]})}),t[34]=T,t[35]=E,t[36]=D):D=t[36],D}function Kr(e){let t=(0,Z.c)(84),{environmentId:n}=e,[r,a]=(0,$.useState)(!1),o=yr(n,r),[s,c]=(0,$.useState)(null),[l,u]=(0,$.useState)(``),[d,f]=(0,$.useState)(``),[p,m]=(0,$.useState)(`approval-required`),[h,g]=(0,$.useState)(!1),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=new Set,t[0]=_):_=t[0];let[v,y]=(0,$.useState)(_),b=(0,$.useRef)(!1),x=(0,$.useId)(),S;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(S={label:`link environment`},t[1]=S):S=t[1];let C=_t(cr.link,S),T=s??(o.length===0?`another-address`:null),E;t[2]!==o||t[3]!==T?(E=o.find(e=>e.environmentId===T)??null,t[2]=o,t[3]=T,t[4]=E):E=t[4];let O=E,k=O?.environmentId??null,A=ht(k),j=ft(k,w),M;t[5]!==A||t[6]!==j||t[7]!==v||t[8]!==k?(M=k!==null&&Te(A)&&j&&!v.has(k),t[5]=A,t[6]=j,t[7]=v,t[8]=k,t[9]=M):M=t[9];let N=M,P=T===`another-address`||O?.urls.length===0,F;t[10]!==l||t[11]!==N||t[12]!==P||t[13]!==d||t[14]!==T?(F=T!==null&&(!P||l.trim().length>0)&&(N||d.trim().length>0),t[10]=l,t[11]=N,t[12]=P,t[13]=d,t[14]=T,t[15]=F):F=t[15];let ee=F,I;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(I=e=>{a(e),e||(c(null),u(``),f(``),m(`approval-required`),y(new Set))},t[16]=I):I=t[16];let te=I,ne;t[17]!==p||t[18]!==N||t[19]!==d||t[20]!==k?(ne=async()=>{if(!N||k===null)return d.trim();let e=await Xt(k,p);return D(e)?e.success:(y(e=>new Set(e).add(k)),Ur(`Could not link the environment`,ar(e.failure)),null)},t[17]=p,t[18]=N,t[19]=d,t[20]=k,t[21]=ne):ne=t[21];let re=ne,ie;t[22]!==p||t[23]!==l||t[24]!==n||t[25]!==C||t[26]!==O||t[27]!==P||t[28]!==ee||t[29]!==re?(ie=async()=>{let[e,...t]=O===null||P?[l.trim()]:O.urls;if(b.current||!ee||e===void 0)return;b.current=!0,g(!0);let r=await re(),i=r===null?null:await C({environmentId:n,input:{url:e,...t.length>0?{alternateUrls:t}:{},...O===null?{}:{expectedEnvironmentId:O.environmentId,expectedLabel:O.label},pairingCode:r,access:p}});b.current=!1,g(!1),i!==null&&(i._tag===`Success`?(J.add({type:`success`,title:`Linked ${i.value.label}`}),te(!1)):je(i)||Ur(`Could not link the environment`,String(Me(i))))},t[22]=p,t[23]=l,t[24]=n,t[25]=C,t[26]=O,t[27]=P,t[28]=ee,t[29]=re,t[30]=ie):ie=t[30];let ae=ie,oe;t[31]===h?oe=t[32]:(oe=e=>{(e||!h)&&te(e)},t[31]=h,t[32]=oe);let R;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Q.jsx)(At,{render:(0,Q.jsxs)(L,{size:`xs`,variant:`default`,children:[(0,Q.jsx)(i,{className:`size-3`}),`Link`]})}),t[33]=R):R=t[33];let se;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Q.jsxs)(Dt,{children:[(0,Q.jsx)(Ot,{children:`Link an environment`}),(0,Q.jsx)(Nt,{children:`Agents here can then launch, message and wait on threads there. It appears in that environment's Connections, where it can be revoked.`})]}),t[34]=se):se=t[34];let ce;t[35]===ae?ce=t[36]:(ce=e=>{e.preventDefault(),ae()},t[35]=ae,t[36]=ce);let le;t[37]!==h||t[38]!==o||t[39]!==T?(le=o.length>0?(0,Q.jsx)(en,{machines:o,value:T,disabled:h,onChange:c}):null,t[37]=h,t[38]=o,t[39]=T,t[40]=le):le=t[40];let ue;t[41]===O?.linked?ue=t[42]:(ue=O?.linked?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Already linked. Linking again renews it with the access you pick.`}):null,t[41]=O?.linked,t[42]=ue);let de;t[43]!==l||t[44]!==h||t[45]!==s||t[46]!==O||t[47]!==o.length||t[48]!==P?(de=P?(0,Q.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,Q.jsx)(`span`,{className:`block text-xs font-medium text-foreground`,children:`Address`}),(0,Q.jsx)(Tt,{value:l,onChange:e=>{u(e.target.value),s===null&&c(nn)},placeholder:`https://box.example.ts.net`,disabled:h,autoFocus:o.length===0,nativeInput:!0,spellCheck:!1}),O===null?null:(0,Q.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[`This app has no address for `,O.label,` that another machine can reach. Enter its https or Tailscale address.`]})]}):null,t[43]=l,t[44]=h,t[45]=s,t[46]=O,t[47]=o.length,t[48]=P,t[49]=de):de=t[49];let fe;t[50]!==h||t[51]!==N||t[52]!==O||t[53]!==d||t[54]!==T?(fe=T===null||N?null:(0,Q.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,Q.jsx)(`span`,{className:`block text-xs font-medium text-foreground`,children:`Pairing code`}),(0,Q.jsx)(Tt,{value:d,onChange:e=>f(e.target.value),placeholder:O===null?`From that environment's Connections, or p4c pair there`:`Paste the code`,disabled:h,autoComplete:`one-time-code`,nativeInput:!0,spellCheck:!1}),O===null?null:(0,Q.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[`Create a link on `,O.label,`: Settings → Connections → Create link, then paste its code here.`]})]}),t[50]=h,t[51]=N,t[52]=O,t[53]=d,t[54]=T,t[55]=fe):fe=t[55];let z;t[56]!==p||t[57]!==h?(z=(0,Q.jsx)(Qt,{value:p,onChange:m,disabled:h}),t[56]=p,t[57]=h,t[58]=z):z=t[58];let pe;t[59]!==x||t[60]!==ce||t[61]!==le||t[62]!==ue||t[63]!==de||t[64]!==fe||t[65]!==z?(pe=(0,Q.jsx)(Mt,{children:(0,Q.jsxs)(`form`,{id:x,className:`space-y-4`,autoComplete:`off`,onSubmit:ce,children:[le,ue,de,fe,z]})}),t[59]=x,t[60]=ce,t[61]=le,t[62]=ue,t[63]=de,t[64]=fe,t[65]=z,t[66]=pe):pe=t[66];let me;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,Q.jsx)(L,{variant:`outline`,type:`button`}),t[67]=me):me=t[67];let he;t[68]===h?he=t[69]:(he=(0,Q.jsx)(jt,{disabled:h,render:me,children:`Cancel`}),t[68]=h,t[69]=he);let ge=h||!ee,_e=h?`Linking…`:`Link`,B;t[70]!==x||t[71]!==ge||t[72]!==_e?(B=(0,Q.jsx)(L,{form:x,type:`submit`,disabled:ge,children:_e}),t[70]=x,t[71]=ge,t[72]=_e,t[73]=B):B=t[73];let V;t[74]!==he||t[75]!==B?(V=(0,Q.jsxs)(kt,{variant:`bare`,children:[he,B]}),t[74]=he,t[75]=B,t[76]=V):V=t[76];let ve;t[77]!==pe||t[78]!==V?(ve=(0,Q.jsxs)(Pt,{className:`max-w-md`,children:[se,pe,V]}),t[77]=pe,t[78]=V,t[79]=ve):ve=t[79];let ye;return t[80]!==r||t[81]!==ve||t[82]!==oe?(ye=(0,Q.jsxs)(Ft,{open:r,onOpenChange:oe,children:[R,ve]}),t[80]=r,t[81]=ve,t[82]=oe,t[83]=ye):ye=t[83],ye}function qr(){let e=(0,Z.c)(13),{environments:t}=nt(),n;e[0]===t?n=e[1]:(n=t.filter(Jr),e[0]=t,e[1]=n);let r=n,i=mt(r,R),a=_t(ct.updateSettings,`Linked environments beta update`),o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=Rn(`linked-environments-beta`),e[2]=o):o=e[2];let s=o;if(r.length===0)return null;let c=s.id,l=s.title,u;if(e[3]!==r||e[4]!==a||e[5]!==i){let t;e[7]!==r.length||e[8]!==a||e[9]!==i?(t=e=>(0,Q.jsx)(vn,{title:r.length>1?e.label:`Linked environments`,description:`Let agents here work on your other machines, and theirs here. Turn it on for each machine, then link them below. While it is off, nothing new starts over a link; tasks already running finish.`,control:(0,Q.jsx)(lr,{checked:e.serverConfig?.settings.linkedEnvironmentsEnabled===!0,disabled:!i.has(e.environmentId),onCheckedChange:t=>void a({environmentId:e.environmentId,input:{patch:{linkedEnvironmentsEnabled:!!t}}}),"aria-label":`Linked environments on ${e.label}`})},e.environmentId),e[7]=r.length,e[8]=a,e[9]=i,e[10]=t):t=e[10],u=r.map(t),e[3]=r,e[4]=a,e[5]=i,e[6]=u}else u=e[6];let d;return e[11]===u?d=e[12]:(d=(0,Q.jsx)(bn,{id:c,title:l,children:u}),e[11]=u,e[12]=d),d}function Jr(e){return e.connection.phase===`connected`&&e.serverConfig?.environment.capabilities.peerLinks===!0}var Yr=[{value:100,label:`Prefer`},{value:50,label:`Normal`},{value:25,label:`Less often`},{value:0,label:`Manual only`}];function Xr(e){return e===void 0||e===50?50:e===0?0:e<50?25:100}function Zr(e){return Yr.find(t=>t.value===e).label}function Qr(e,t){let n=e.flatMap(e=>{let n=Xr(t[e.environmentId]);return n===50?[]:[`${e.label} ${Zr(n).toLowerCase()}`]});return n.length===0?null:n.join(` · `)}function $r(e){let t=(0,Z.c)(27),{environments:n}=e,r=ot(),i=it(),a=rt();if(n.length<2)return null;let o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=Rn(`load-balancing`),t[0]=o):o=t[0];let{id:s,title:c}=o,l;t[1]!==n||t[2]!==r.loadBalancingEnabled||t[3]!==r.loadBalancingWeights?(l=r.loadBalancingEnabled?Qr(n,r.loadBalancingWeights):`Off`,t[1]=n,t[2]=r.loadBalancingEnabled,t[3]=r.loadBalancingWeights,t[4]=l):l=t[4];let u=!i,d;t[5]===a?d=t[6]:(d=e=>a({loadBalancingEnabled:e}),t[5]=a,t[6]=d);let f;t[7]!==r.loadBalancingEnabled||t[8]!==u||t[9]!==d?(f=(0,Q.jsx)(lr,{"aria-label":`Automatically balance load`,checked:r.loadBalancingEnabled,disabled:u,onCheckedChange:d}),t[7]=r.loadBalancingEnabled,t[8]=u,t[9]=d,t[10]=f):f=t[10];let p;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(`p`,{className:`px-3 py-2.5 text-xs text-muted-foreground sm:px-4`,children:`New threads in shared projects start on the machine with the most free CPU and memory, weighted by each machine's preference.`}),t[11]=p):p=t[11];let m;if(t[12]!==n||t[13]!==r.loadBalancingEnabled||t[14]!==r.loadBalancingWeights||t[15]!==i||t[16]!==a){let e;t[18]!==r.loadBalancingEnabled||t[19]!==r.loadBalancingWeights||t[20]!==i||t[21]!==a?(e=e=>(0,Q.jsx)(Hr,{kind:h(e.serverConfig),label:e.label,subtitle:Vr(e),children:(0,Q.jsxs)(Ze,{items:Yr,value:Xr(r.loadBalancingWeights[e.environmentId]),disabled:!i||!r.loadBalancingEnabled,onValueChange:t=>{t!==null&&a({loadBalancingWeights:{...r.loadBalancingWeights,[e.environmentId]:t}})},children:[(0,Q.jsx)(Xe,{size:`xs`,className:`w-32`,"aria-label":`${e.label} load preference`,children:(0,Q.jsx)(Je,{})}),(0,Q.jsx)(Ye,{align:`end`,alignItemWithTrigger:!1,children:Yr.map(ei)})]})},e.environmentId),t[18]=r.loadBalancingEnabled,t[19]=r.loadBalancingWeights,t[20]=i,t[21]=a,t[22]=e):e=t[22],m=n.map(e),t[12]=n,t[13]=r.loadBalancingEnabled,t[14]=r.loadBalancingWeights,t[15]=i,t[16]=a,t[17]=m}else m=t[17];let g;return t[23]!==l||t[24]!==f||t[25]!==m?(g=(0,Q.jsxs)(Dr,{id:s,title:c,summary:l,control:f,children:[p,m]}),t[23]=l,t[24]=f,t[25]=m,t[26]=g):g=t[26],g}function ei(e){let{value:t,label:n}=e;return(0,Q.jsx)(qe,{value:t,children:n},t)}var ti=[{value:`off`,label:`Off`},{value:`read`,label:`Read PRs`},{value:`read-write`,label:`Read and act`}],ni={"read-write":`read and act`,read:`read PRs`};function ri(e){let t=[`read-write`,`read`].flatMap(t=>{let n=e.filter(e=>e.permission===t);return n.length===0?[]:[`${n.map(e=>e.label).join(`, `)} ${ni[t]}`]});return t.length===0?null:t.join(` · `)}function ii(e){let t=(0,Z.c)(19),{environments:n}=e,r=de(lt.githubRoutingPermissionsValueAtom),i=de(lt.catalogValueAtom),a=_t(lt.setGitHubRoutingPermission),[o,s]=(0,$.useState)(!1);if(n.length<2)return null;let c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=Rn(`github-routing`),t[0]=c):c=t[0];let{id:l,title:u}=c,d;t[1]!==n||t[2]!==r?(d=ri(n.map(e=>({label:e.label,permission:G(e.entry,r)})))??`Off`,t[1]=n,t[2]=r,t[3]=d):d=t[3];let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(`p`,{className:`px-3 py-2.5 text-xs text-muted-foreground sm:px-4`,children:`Machines you trust here can read PR data through each other's GitHub access. Enable both machines. Read and act may use broader permissions than the machine that owns them. This applies only to this device.`}),t[4]=f):f=t[4];let p;if(t[5]!==i||t[6]!==n||t[7]!==r||t[8]!==o||t[9]!==a){let e;t[11]!==i||t[12]!==r||t[13]!==o||t[14]!==a?(e=e=>(0,Q.jsx)(Hr,{kind:h(e.serverConfig),label:e.label,subtitle:Vr(e),children:(0,Q.jsxs)(Ze,{items:ti,value:G(e.entry,r),disabled:!i.isReady||o||ke(e.entry)===null,onValueChange:t=>{t!==null&&(s(!0),a({environmentId:e.environmentId,permission:t}).then(e=>{s(!1),e._tag===`Failure`&&J.add({type:`error`,title:`Could not save GitHub routing permission`})}))},children:[(0,Q.jsx)(Xe,{size:`xs`,className:`w-32`,"aria-label":`${e.label} GitHub routing`,children:(0,Q.jsx)(Je,{})}),(0,Q.jsx)(Ye,{align:`end`,alignItemWithTrigger:!1,children:ti.map(ai)})]})},e.environmentId),t[11]=i,t[12]=r,t[13]=o,t[14]=a,t[15]=e):e=t[15],p=n.map(e),t[5]=i,t[6]=n,t[7]=r,t[8]=o,t[9]=a,t[10]=p}else p=t[10];let m;return t[16]!==d||t[17]!==p?(m=(0,Q.jsxs)(Dr,{id:l,title:u,summary:d,children:[f,p]}),t[16]=d,t[17]=p,t[18]=m):m=t[18],m}function ai(e){let{value:t,label:n}=e;return(0,Q.jsx)(qe,{value:t,children:n},t)}function oi(e){let t=(0,Z.c)(26),{environmentLabel:n,onCancel:r,onConfirm:i}=e,a=It(),[o,s]=(0,$.useState)(n);n!==null&&n!==o&&s(n);let c=a.open,l=n!==null,u;t[0]===r?u=t[1]:(u=e=>{e||r()},t[0]=r,t[1]=u);let d;t[2]===o?d=t[3]:(d=(0,Q.jsxs)(gn,{children:[`Remove `,o,` from this device?`]}),t[2]=o,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(hn,{children:`This forgets its pairing, credentials, and cached threads here.`}),t[4]=f):f=t[4];let p;t[5]!==r||t[6]!==c?(p=c?(0,Q.jsx)(he,{onClick:()=>{r(),c()},children:`P4 Connect settings`}):`P4 Connect settings`,t[5]=r,t[6]=c,t[7]=p):p=t[7];let m;t[8]===p?m=t[9]:(m=(0,Q.jsxs)(hn,{children:[`It stays on your P4 Connect account and keeps its host space. Deregister it in`,` `,p,` `,`to free it.`]}),t[8]=p,t[9]=m);let h;t[10]!==d||t[11]!==m?(h=(0,Q.jsxs)(dn,{children:[d,f,m]}),t[10]=d,t[11]=m,t[12]=h):h=t[12];let g;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(pn,{render:(0,Q.jsx)(L,{variant:`outline`}),children:`Cancel`}),t[13]=g):g=t[13];let _;t[14]===i?_=t[15]:(_=(0,Q.jsxs)(fn,{children:[g,(0,Q.jsx)(L,{variant:`destructive`,onClick:i,children:`Remove from this device`})]}),t[14]=i,t[15]=_);let v;t[16]!==h||t[17]!==_?(v=(0,Q.jsxs)(mn,{children:[h,_]}),t[16]=h,t[17]=_,t[18]=v):v=t[18];let y;t[19]!==l||t[20]!==v||t[21]!==u?(y=(0,Q.jsx)(_n,{open:l,onOpenChange:u,children:v}),t[19]=l,t[20]=v,t[21]=u,t[22]=y):y=t[22];let b;return t[23]!==a.portals||t[24]!==y?(b=(0,Q.jsxs)(Q.Fragment,{children:[y,a.portals]}),t[23]=a.portals,t[24]=y,t[25]=b):b=t[25],b}var si={pairingLinks:[],clientSessions:[]};function ci(e,t,n){let r=n(t);return[...e.filter(e=>n(e)!==r),t]}function li(e,t){switch(t.type){case`snapshot`:return t.payload;case`pairingLinkUpserted`:return{...e,pairingLinks:ci(e.pairingLinks,t.payload,e=>e.id)};case`pairingLinkRemoved`:return{...e,pairingLinks:e.pairingLinks.filter(e=>e.id!==t.payload.id)};case`clientUpserted`:return{...e,clientSessions:ci(e.clientSessions,t.payload,e=>e.sessionId)};case`clientRemoved`:return{...e,clientSessions:e.clientSessions.filter(e=>e.sessionId!==t.payload.sessionId)}}}function ui(e,t){let n=li(e,t);return[n,[{version:1,revision:t.revision,type:`snapshot`,payload:n}]]}function di(e){return{accessChanges:Oe(e,{label:`environment-data:server:auth-access-changes`,subscribe:e=>Ie(T.subscribeAuthAccess,{}).pipe(l(()=>si,ui))})}}var fi=di(Ke),pi=3e4,mi=class extends Ee()(`DesktopNetworkAccessUnavailableError`,{}){get message(){return`Desktop network access is unavailable.`}},hi=class extends Ee()(`DesktopServerExposureStateLoadError`,{cause:ce()}){get message(){return`Failed to load desktop server exposure state.`}},gi=class extends Ee()(`DesktopAdvertisedEndpointsLoadError`,{cause:ce()}){get message(){return`Failed to load advertised desktop endpoints.`}};function _i(){return typeof window>`u`?void 0:window.desktopBridge}function vi(e){let t=I(`loadDesktopNetworkAccess`)(function*(){let t=e();if(!t)return yield*new mi;let[n,r]=yield*g([s({try:()=>t.getServerExposureState(),catch:e=>new hi({cause:e})}),s({try:()=>t.getAdvertisedEndpoints(),catch:e=>new gi({cause:e})})],{concurrency:`unbounded`});return{advertisedEndpoints:r,serverExposureState:n}});return A(t()).pipe(se({staleTime:pi,revalidateOnMount:!0}),ve,E(`desktop:network-access`))}var yi=vi(_i);function bi(){v.refresh(yi)}function xi(e,t){let n=t.trim().toLowerCase();if(n.length===0)return e;let r=[],i=[];for(let t of e){let e=t.alias.toLowerCase();e.startsWith(n)?r.push(t):e.includes(n)&&i.push(t)}return[...r,...i]}var Si=class extends Ee()(`DesktopSshDiscoveryUnavailableError`,{}){get message(){return`Desktop SSH host discovery is unavailable.`}},Ci=class extends Ee()(`DesktopSshDiscoveryError`,{cause:ce()}){get message(){return`Failed to discover SSH hosts.`}};function wi(){return typeof window>`u`?void 0:window.desktopBridge}function Ti(e){let t=I(`discoverDesktopSshHosts`)(function*(){let t=e();return t?yield*s({try:()=>t.discoverSshHosts(),catch:e=>new Ci({cause:e})}):yield*new Si});return A(t()).pipe(se({staleTime:3e4,revalidateOnMount:!0}),ve,E(`desktop:ssh-hosts`))}var Ei=Ti(wi),Di=443,Oi=[],ki=[],Ai=`backend:default-wsl`,ji=`backend:wsl-off`,Mi=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`});function Ni(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:Mi.format(t)}function Pi(e){let t=(0,Z.c)(13),{scopes:n,label:r}=e,i=`${n.length} ${n.length===1?`scope`:`scopes`}`,a=`${r}: show ${i}`,o;t[0]===a?o=t[1]:(o=(0,Q.jsx)(`button`,{type:`button`,"aria-label":a,className:`cursor-help underline decoration-border underline-offset-2 outline-hidden hover:text-foreground focus-visible:text-foreground`}),t[0]=a,t[1]=o);let s;t[2]!==i||t[3]!==o?(s=(0,Q.jsx)(Jt,{openOnHover:!0,delay:250,closeDelay:100,render:o,children:i}),t[2]=i,t[3]=o,t[4]=s):s=t[4];let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(`p`,{className:`mb-1 font-medium`,children:`Granted scopes`}),t[5]=c):c=t[5];let l;t[6]===n?l=t[7]:(l=n.map(Fi),t[6]=n,t[7]=l);let u;t[8]===l?u=t[9]:(u=(0,Q.jsxs)(qt,{side:`top`,align:`start`,tooltipStyle:!0,className:`w-max max-w-80 whitespace-normal`,children:[c,(0,Q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:l})]}),t[8]=l,t[9]=u);let d;return t[10]!==s||t[11]!==u?(d=(0,Q.jsxs)(Yt,{children:[s,u]}),t[10]=s,t[11]=u,t[12]=d):d=t[12],d}function Fi(e){return(0,Q.jsx)(`code`,{className:`font-mono text-foreground/85`,children:e},e)}function Ii(e){let t=e.host.trim();if(t.length===0)throw Error(`SSH host or alias is required.`);let n=t,r=e.username.trim()||null,i=null,a=n.lastIndexOf(`@`);if(a>0){let e=n.slice(0,a).trim();n=n.slice(a+1).trim(),!r&&e.length>0&&(r=e)}let o=/^\[([^\]]+)\](?::(\d+))?$/u.exec(n);if(o)n=o[1].trim(),o[2]&&(i=Number.parseInt(o[2],10));else{let e=n.split(`:`);e.length===2&&/^\d+$/u.test(e[1]??``)&&(n=e[0].trim(),i=Number.parseInt(e[1],10))}let s=e.port.trim();if(s.length>0&&(i=Number.parseInt(s,10)),n.length===0)throw Error(`SSH host or alias is required.`);if(i!==null&&(!Number.isInteger(i)||i<=0||i>65535))throw Error(`SSH port must be between 1 and 65535.`);return{alias:n,hostname:n,username:r,port:i}}function Li(e){let t=e.trim();if(!t)return null;try{let e=/^[a-zA-Z][a-zA-Z\d+.-]*:\/\//u.test(t)||t.startsWith(`//`)?t:`https://${t}`,n=new URL(e,window.location.origin),r=ze(n);if(r)return{host:r.host,pairingCode:r.token};let i=q(n);return i?{host:n.origin,pairingCode:i}:null}catch{return null}}function Ri(e){let t=Li(e.host);if(t)return t;let n=e.host.trim(),r=e.pairingCode.trim();if(!n)throw Error(`Enter a backend host.`);if(!r)throw Error(`Enter a pairing code.`);return{host:n,pairingCode:r}}function zi(e){let t=`Failed to connect SSH host.`;return(e instanceof Error?e.message:t).replace(/^Error invoking remote method 'desktop:ensure-ssh-environment':\s*/u,``).replace(/^Ssh[A-Za-z]+Error:\s*/u,``).trim()||t}var Bi=`first:rounded-t-xl last:rounded-b-xl px-3 py-2.5 sm:px-4`;function Vi(e){return br}function Hi(e,t){return e===`endpoint-rail`?be(`relative first:rounded-t-xl last:rounded-b-xl px-3 py-3 sm:px-4`,!t&&`bg-muted/15`):be(Bi,!t&&`bg-muted/24`)}function Ui(e){return[...e].toSorted((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime())}function Wi(e,t){return[`${e.length} ${e.length===1?`client`:`clients`}`,t.length>0?`${t.length} ${t.length===1?`pairing link`:`pairing links`}`:null].filter(e=>e!==null).join(` · `)}function Gi(e){return[...e].toSorted((e,t)=>e.current===t.current?e.connected===t.connected?new Date(t.issuedAt).getTime()-new Date(e.issuedAt).getTime():e.connected?-1:1:e.current?-1:1)}function Ki(e){return{...e,scopes:e.permissions??e.scopes,createdAt:u(e.createdAt),expiresAt:u(e.expiresAt)}}function qi(e){return{...e,scopes:e.permissions??e.scopes,issuedAt:u(e.issuedAt),expiresAt:u(e.expiresAt),lastConnectedAt:e.lastConnectedAt===null?null:u(e.lastConnectedAt)}}function Ji(e,t){let n=e.filter(e=>e.status!==`unavailable`);if(t){let e=n.find(e=>Xi(e)===t);if(e)return e}return n.find(e=>e.isDefault)??n.find(e=>e.reachability!==`loopback`)??n.find(e=>e.compatibility.hostedHttpsApp===`compatible`)??null}function Yi(e){return e.id.startsWith(`tailscale-magicdns:`)}function Xi(e){if(e.id.startsWith(`desktop-loopback:`))return`desktop-core:loopback:http`;if(e.id.startsWith(`desktop-lan:`))return`desktop-core:lan:http`;if(e.id.startsWith(`tailscale-ip:`))return`tailscale:ip:http`;if(Yi(e))return`tailscale:magicdns:https`;let t=`unknown`;try{t=new URL(e.httpBaseUrl).protocol.replace(/:$/u,``)}catch{}return`${e.provider.id}:${e.reachability}:${t}:${e.label}`}function Zi(e,t){return e.compatibility.hostedHttpsApp===`compatible`?jr(e.httpBaseUrl,t)??Ar(e.httpBaseUrl,t):Ar(e.httpBaseUrl,t)}function Qi(e){let t=new URL(`/pair`,window.location.href);return Ve(t,e).toString()}function $i(e){try{let t=new URL(e);return t.pathname===`/pair`&&t.searchParams.has(`host`)}catch{return!1}}function ea(e,t){if($i(t))return`Opens the hosted app, no install needed`;switch(e.reachability){case`lan`:return`Devices on the same network`;case`private-network`:return`Devices on your private network`;case`public`:return`Reachable from anywhere`;case`loopback`:return`Clients on this machine`}}var ta=(0,$.memo)(function(e){let t=(0,Z.c)(135),{pairingLink:n,credential:r,endpointUrl:i,endpoints:a,defaultEndpointKey:o,presentation:s,revokingPairingLinkId:c,onRevoke:l,canRevoke:u}=e,d=s===void 0?`current`:s,f=X(1e3),p=new Date(n.expiresAt).getTime(),[m,h]=(0,$.useState)(!1),[g,_]=(0,$.useState)(!1),[v,y]=(0,$.useState)(null),b=(0,$.useId)(),x;t[0]===r?x=t[1]:(x=r?Qi(r):null,t[0]=r,t[1]=x);let S=x,C;t[2]!==r||t[3]!==i?(C=r&&i!=null&&i!==``?jr(i,r):null,t[2]=r,t[3]=i,t[4]=C):C=t[4];let w=C,T;if(t[5]!==r||t[6]!==o||t[7]!==a){let e=Ji(a,o);T=e&&r?Zi(e,r):null,t[5]=r,t[6]=o,t[7]=a,t[8]=T}else T=t[8];let E=T,D;if(t[9]!==r||t[10]!==a){bb0:{let e=[];if(!r){D=e;break bb0}for(let t of a){if(t.status===`unavailable`)continue;let n=Zi(t,r);e.push({id:t.id,preferenceKey:Xi(t),label:t.label,url:n,detail:ea(t,n),qrShareable:xr(t)})}D=e}t[9]=r,t[10]=a,t[11]=D}else D=t[11];let O=D,k;t[12]!==r||t[13]!==S||t[14]!==E||t[15]!==i||t[16]!==w?(k=E??(r&&i!=null&&i!==``?w??Ar(i,r):Re(window.location.hostname)?null:S),t[12]=r,t[13]=S,t[14]=E,t[15]=i,t[16]=w,t[17]=k):k=t[17];let A=k,[j,M]=(0,$.useState)(null),N=j??A??r??``,P=N!==r,F=P&&$i(N),ee=O.find(e=>e.url===N)?.qrShareable??!0,I=typeof window<`u`&&window.isSecureContext&&navigator.clipboard?.writeText!=null,te;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(te={onCopy:wa,onError:(e,t)=>{let{value:n,kind:r}=t;M(n),h(!0),J.add(vt({type:`error`,title:I?r===`hosted-link`?`Could not copy hosted app link`:r===`link`?`Could not copy pairing URL`:`Could not copy pairing code`:`Clipboard copy unavailable`,description:I?e.message:`Showing the full value instead.`}))}},t[18]=te):te=t[18];let{copyToClipboard:ne}=$e(te),re;t[19]===ne?re=t[20]:(re=(e,t)=>{ne(e,{value:e,kind:t})},t[19]=ne,t[20]=re);let ie=re,ae=Ta,oe;t[21]!==ie||t[22]!==r?(oe=()=>{r&&ie(r,`code`)},t[21]=ie,t[22]=r,t[23]=oe):oe=t[23];let R=oe,se;t[24]===n.expiresAt?se=t[25]:(se=Ni(n.expiresAt),t[24]=n.expiresAt,t[25]=se);let ce=se,le=n.label??`Pairing link`,ue;t[26]!==o||t[27]!==O||t[28]!==v?(ue=hr(O,v,o),t[26]=o,t[27]=O,t[28]=v,t[29]=ue):ue=t[29];let de=ue,z=de?.url??A,pe=de?.qrShareable??!0;if(p<=f)return null;let me;t[30]===d?me=t[31]:(me=Vi(d),t[30]=d,t[31]=me);let he;t[32]===n.createdAt?he=t[33]:(he=Ni(n.createdAt),t[32]=n.createdAt,t[33]=he);let ge=`Link created at ${he}`,_e;t[34]===ge?_e=t[35]:(_e=(0,Q.jsx)(On,{tooltipText:ge,dotClassName:`bg-warning`}),t[34]=ge,t[35]=_e);let B;t[36]===le?B=t[37]:(B=(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:le}),t[36]=le,t[37]=B);let V;t[38]!==_e||t[39]!==B?(V=(0,Q.jsxs)(`div`,{className:`flex min-h-5 items-center gap-1.5`,children:[_e,B]}),t[38]=_e,t[39]=B,t[40]=V):V=t[40];let ve;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,Q.jsx)(`span`,{}),t[41]=ve):ve=t[41];let ye;t[42]!==f||t[43]!==n.expiresAt?(ye=yt(n.expiresAt,f),t[42]=f,t[43]=n.expiresAt,t[44]=ye):ye=t[44];let H;t[45]===ye?H=t[46]:(H=(0,Q.jsx)(xt,{render:ve,children:ye}),t[45]=ye,t[46]=H);let xe;t[47]===ce?xe=t[48]:(xe=(0,Q.jsx)(St,{side:`top`,children:ce}),t[47]=ce,t[48]=xe);let Se;t[49]!==H||t[50]!==xe?(Se=(0,Q.jsxs)(Ct,{children:[H,xe]}),t[49]=H,t[50]=xe,t[51]=Se):Se=t[51];let Ce;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,Q.jsx)(`span`,{"aria-hidden":!0,children:` · `}),t[52]=Ce):Ce=t[52];let we;t[53]===n.scopes?we=t[54]:(we=(0,Q.jsx)(Pi,{scopes:n.scopes,label:`Pairing link scopes`}),t[53]=n.scopes,t[54]=we);let Te;t[55]!==Se||t[56]!==we?(Te=(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[Se,Ce,we]}),t[55]=Se,t[56]=we,t[57]=Te):Te=t[57];let Ee;t[58]!==r||t[59]!==A?(Ee=r?A===null?(0,Q.jsx)(`p`,{className:`text-2xs text-muted-foreground/70`,children:`Copy the token and pair from another client using this backend's reachable host.`}):null:(0,Q.jsx)(`p`,{className:`text-2xs text-muted-foreground/70`,children:`Create a new link to share from this client.`}),t[58]=r,t[59]=A,t[60]=Ee):Ee=t[60];let U;t[61]!==V||t[62]!==Te||t[63]!==Ee?(U=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[V,Te,Ee]}),t[61]=V,t[62]=Te,t[63]=Ee,t[64]=U):U=t[64];let De;t[65]!==g||t[66]!==b||t[67]!==A?(De=A&&I?(0,Q.jsxs)(L,{size:`xs`,variant:`outline`,"aria-expanded":g,"aria-controls":b,onClick:()=>_(Ea),children:[(0,Q.jsx)(fe,{"aria-hidden":!0}),`Share`]}):null,t[65]=g,t[66]=b,t[67]=A,t[68]=De):De=t[68];let Oe=r!==void 0&&m,ke;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(ke=e=>{h(e),e||M(null)},t[69]=ke):ke=t[69];let Ae;t[70]!==r||t[71]!==R||t[72]!==A?(Ae=r?I?A?null:(0,Q.jsx)(L,{size:`xs`,variant:`outline`,onClick:R,children:`Copy code`}):(0,Q.jsx)(At,{render:(0,Q.jsx)(L,{size:`xs`,variant:`outline`}),children:A?`Show link`:`Show code`}):null,t[70]=r,t[71]=R,t[72]=A,t[73]=Ae):Ae=t[73];let W=P?F?`Hosted app pairing link`:`Pairing link`:`Pairing code`,je;t[74]===W?je=t[75]:(je=(0,Q.jsx)(Ot,{children:W}),t[74]=W,t[75]=je);let G=P?F?`Clipboard copy is unavailable here. Open or manually copy this hosted app link on the device you want to connect.`:`Clipboard copy is unavailable here. Open or manually copy this full pairing URL on the device you want to connect.`:`Clipboard copy is unavailable here. Manually copy this code into another client.`,Me;t[76]===G?Me=t[77]:(Me=(0,Q.jsx)(Nt,{children:G}),t[76]=G,t[77]=Me);let K;t[78]!==je||t[79]!==Me?(K=(0,Q.jsxs)(Dt,{children:[je,Me]}),t[78]=je,t[79]=Me,t[80]=K):K=t[80];let Ne=P?4:3,Pe;t[81]!==N||t[82]!==Ne?(Pe=(0,Q.jsx)(wt,{readOnly:!0,value:N,rows:Ne,onFocus:Da,onClick:Oa}),t[81]=N,t[82]=Ne,t[83]=Pe):Pe=t[83];let Fe;t[84]!==ee||t[85]!==P||t[86]!==N?(Fe=P&&ee?(0,Q.jsx)(`div`,{className:`flex justify-center rounded-xl border border-border/60 bg-muted/30 p-4`,children:(0,Q.jsx)(Zn,{value:N,size:132,level:`M`,marginSize:2,title:`Pairing link — scan to open on another device`})}):null,t[84]=ee,t[85]=P,t[86]=N,t[87]=Fe):Fe=t[87];let Ie;t[88]!==Pe||t[89]!==Fe?(Ie=(0,Q.jsxs)(Mt,{children:[Pe,Fe]}),t[88]=Pe,t[89]=Fe,t[90]=Ie):Ie=t[90];let Le;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(Le=(0,Q.jsx)(L,{variant:`outline`,onClick:()=>h(!1),children:`Done`}),t[91]=Le):Le=t[91];let ze;t[92]===R?ze=t[93]:(ze=I?(0,Q.jsx)(L,{variant:`outline`,onClick:R,children:`Copy code`}):null,t[92]=R,t[93]=ze);let Be;t[94]===ze?Be=t[95]:(Be=(0,Q.jsxs)(kt,{variant:`bare`,children:[Le,ze]}),t[94]=ze,t[95]=Be);let Ve;t[96]!==K||t[97]!==Ie||t[98]!==Be?(Ve=(0,Q.jsxs)(Pt,{className:`max-w-md`,children:[K,Ie,Be]}),t[96]=K,t[97]=Ie,t[98]=Be,t[99]=Ve):Ve=t[99];let q;t[100]!==Oe||t[101]!==Ae||t[102]!==Ve?(q=(0,Q.jsxs)(Ft,{open:Oe,onOpenChange:ke,children:[Ae,Ve]}),t[100]=Oe,t[101]=Ae,t[102]=Ve,t[103]=q):q=t[103];let He=!u||c===n.id,Ue;t[104]!==l||t[105]!==n.id?(Ue=()=>void l(n.id),t[104]=l,t[105]=n.id,t[106]=Ue):Ue=t[106];let We=c===n.id?`Revoking…`:`Revoke`,Ge;t[107]!==He||t[108]!==Ue||t[109]!==We?(Ge=(0,Q.jsx)(L,{size:`xs`,variant:`destructive-outline`,disabled:He,onClick:Ue,children:We}),t[107]=He,t[108]=Ue,t[109]=We,t[110]=Ge):Ge=t[110];let Ke;t[111]!==De||t[112]!==q||t[113]!==Ge?(Ke=(0,Q.jsxs)(`div`,{className:`flex w-full shrink-0 items-center gap-2 sm:w-auto sm:justify-end`,children:[De,q,Ge]}),t[111]=De,t[112]=q,t[113]=Ge,t[114]=Ke):Ke=t[114];let qe;t[115]!==U||t[116]!==Ke?(qe=(0,Q.jsxs)(`div`,{className:or,children:[U,Ke]}),t[115]=U,t[116]=Ke,t[117]=qe):qe=t[117];let Je=g&&z!==null,Ye;t[118]!==pe||t[119]!==ie||t[120]!==O||t[121]!==R||t[122]!==z||t[123]!==b||t[124]!==de?.id?(Ye=z===null?null:(0,Q.jsxs)(`div`,{id:b,className:`mt-3 flex flex-col gap-4 border-t border-border/50 pt-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[O.length>1?(0,Q.jsxs)(`div`,{className:`space-y-1.5`,role:`radiogroup`,"aria-label":`Endpoint the pairing QR code and URL use`,children:[(0,Q.jsx)(`p`,{className:`text-2xs text-muted-foreground/70`,children:`Reach this machine via`}),O.map(e=>{let t=e.id===de?.id;return(0,Q.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,className:be(`flex w-full items-baseline gap-2 rounded-lg border px-2.5 py-1.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,t?`border-foreground/60 bg-muted/30`:`border-border/50 hover:bg-muted/20`),onClick:()=>y(e.id),children:[(0,Q.jsx)(`span`,{className:be(`text-xs font-medium`,t?`text-foreground`:`text-muted-foreground`),children:e.label}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-2xs text-muted-foreground/70`,children:e.detail})]},e.id)})]}):null,(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/60 bg-muted/30 px-2.5 py-1.5`,children:[(0,Q.jsxs)(Ct,{children:[(0,Q.jsx)(xt,{render:(0,Q.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-2xs text-muted-foreground`,children:z})}),(0,Q.jsx)(St,{side:`top`,children:z})]}),(0,Q.jsx)(L,{size:`xs`,variant:`ghost`,className:`shrink-0`,onClick:()=>ie(z,ae(z)),children:`Copy link`})]}),(0,Q.jsx)(L,{size:`xs`,variant:`ghost`,onClick:R,children:`Copy code only`})]}),pe?(0,Q.jsx)(`div`,{className:`w-fit shrink-0 self-center rounded-xl bg-white p-3 sm:self-start`,children:(0,Q.jsx)(Zn,{value:z,size:168,level:`M`,marginSize:1,title:`Pairing link — scan to open on another device`})}):(0,Q.jsx)(`div`,{className:`flex size-[192px] shrink-0 items-center justify-center self-center rounded-xl border border-border/50 p-4 sm:self-start`,children:(0,Q.jsx)(`p`,{className:`text-center text-2xs text-muted-foreground/70`,children:`No QR for this endpoint. Another device scanning a loopback link would dial itself; copy the URL for use on this machine instead.`})})]}),t[118]=pe,t[119]=ie,t[120]=O,t[121]=R,t[122]=z,t[123]=b,t[124]=de?.id,t[125]=Ye):Ye=t[125];let Xe;t[126]===Ye?Xe=t[127]:(Xe=(0,Q.jsx)(gr,{children:Ye}),t[126]=Ye,t[127]=Xe);let Ze;t[128]!==Je||t[129]!==Xe?(Ze=(0,Q.jsx)(vr,{open:Je,children:Xe}),t[128]=Je,t[129]=Xe,t[130]=Ze):Ze=t[130];let Qe;return t[131]!==me||t[132]!==qe||t[133]!==Ze?(Qe=(0,Q.jsxs)(`div`,{className:me,children:[qe,Ze]}),t[131]=me,t[132]=qe,t[133]=Ze,t[134]=Qe):Qe=t[134],Qe}),na=(0,$.memo)(function(e){let t=(0,Z.c)(54),{clientSession:n,presentation:r,revokingClientSessionId:i,onRevokeSession:a,canRevoke:o}=e,s=r===void 0?`current`:r,c=X(1e3),l=n.current||n.connected,u=n.lastConnectedAt,d;t[0]!==l||t[1]!==u||t[2]!==c?(d=l?u?`Connected for ${bt(u,c)}`:`Connected`:u?`Last connected at ${Ni(u)}`:`Not connected yet.`,t[0]=l,t[1]=u,t[2]=c,t[3]=d):d=t[3];let f=d,p;t[4]===n.client.deviceType?p=t[5]:(p=n.client.deviceType===`unknown`?null:n.client.deviceType[0]?.toUpperCase()+n.client.deviceType.slice(1),t[4]=n.client.deviceType,t[5]=p);let m=n.client.os??null,h=n.client.browser??null,g=n.client.ipAddress??null,_;t[6]!==p||t[7]!==m||t[8]!==h||t[9]!==g?(_=[p,m,h,g].filter(ka),t[6]=p,t[7]=m,t[8]=h,t[9]=g,t[10]=_):_=t[10];let v=_,y;t[11]!==n.client.browser||t[12]!==n.client.label||t[13]!==n.client.os||t[14]!==n.subject?(y=n.client.label??([n.client.os,n.client.browser].filter(Boolean).join(` · `)||n.subject),t[11]=n.client.browser,t[12]=n.client.label,t[13]=n.client.os,t[14]=n.subject,t[15]=y):y=t[15];let b=y,x;t[16]===s?x=t[17]:(x=Vi(s),t[16]=s,t[17]=x);let S=l?`bg-success`:`bg-muted-foreground/30`,C=l?`bg-success/60 duration-2000`:null,w;t[18]!==f||t[19]!==S||t[20]!==C?(w=(0,Q.jsx)(On,{tooltipText:f,dotClassName:S,pingClassName:C}),t[18]=f,t[19]=S,t[20]=C,t[21]=w):w=t[21];let T;t[22]===b?T=t[23]:(T=(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:b}),t[22]=b,t[23]=T);let E;t[24]===n.current?E=t[25]:(E=n.current?(0,Q.jsx)(`span`,{className:`text-3xs text-muted-foreground/80 rounded-md border border-border/50 bg-muted/50 px-1 py-0.5`,children:`This device`}):null,t[24]=n.current,t[25]=E);let D;t[26]!==w||t[27]!==T||t[28]!==E?(D=(0,Q.jsxs)(`div`,{className:`flex min-h-5 items-center gap-1.5`,children:[w,T,E]}),t[26]=w,t[27]=T,t[28]=E,t[29]=D):D=t[29];let O;t[30]===v?O=t[31]:(O=v.length>0?(0,Q.jsxs)(Q.Fragment,{children:[v.join(` · `),(0,Q.jsx)(`span`,{"aria-hidden":!0,children:` · `})]}):null,t[30]=v,t[31]=O);let k;t[32]===n.scopes?k=t[33]:(k=(0,Q.jsx)(Pi,{scopes:n.scopes,label:`Client scopes`}),t[32]=n.scopes,t[33]=k);let A;t[34]!==O||t[35]!==k?(A=(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[O,k]}),t[34]=O,t[35]=k,t[36]=A):A=t[36];let j;t[37]!==D||t[38]!==A?(j=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[D,A]}),t[37]=D,t[38]=A,t[39]=j):j=t[39];let M;t[40]!==o||t[41]!==n.current||t[42]!==n.sessionId||t[43]!==a||t[44]!==i?(M=n.current?null:(0,Q.jsx)(L,{size:`xs`,variant:`destructive-outline`,disabled:!o||i===n.sessionId,onClick:()=>void a(n.sessionId),children:i===n.sessionId?`Revoking…`:`Revoke`}),t[40]=o,t[41]=n.current,t[42]=n.sessionId,t[43]=a,t[44]=i,t[45]=M):M=t[45];let N;t[46]===M?N=t[47]:(N=(0,Q.jsx)(`div`,{className:`flex w-full shrink-0 items-center gap-2 sm:w-auto sm:justify-end`,children:M}),t[46]=M,t[47]=N);let P;t[48]!==j||t[49]!==N?(P=(0,Q.jsxs)(`div`,{className:or,children:[j,N]}),t[48]=j,t[49]=N,t[50]=P):P=t[50];let F;return t[51]!==P||t[52]!==x?(F=(0,Q.jsx)(`div`,{className:x,children:P}),t[51]=P,t[52]=x,t[53]=F):F=t[53],F}),ra=(0,$.memo)(function({onPairingLinkCreated:e,clientSessions:t,isRevokingOtherClients:n,onRevokeOtherClients:r,delegatableScopes:i}){let o=Y(),[s,c]=(0,$.useState)(!1),[l,u]=(0,$.useState)(``),[d,f]=(0,$.useState)([...N]),p=d.filter(e=>i.includes(e)),[m,h]=(0,$.useState)(!1),g=(0,$.useCallback)(async()=>{if(o!==null&&p.length!==0&&pt(o,`access:write`)&&p.every(e=>pt(o,e))){h(!0);try{e(await An({label:l,scopes:p})),u(``),f(N.filter(e=>i.includes(e))),c(!1)}catch(e){let t=e instanceof Error?e.message:`Failed to create pairing URL.`;J.add(vt({type:`error`,title:`Could not create pairing URL`,description:t}))}finally{h(!1)}}},[i,e,l,o,p]),_=(0,$.useCallback)((e,t)=>{f(n=>Sr(n,e,t))},[]);return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(L,{size:`xs`,variant:`destructive-outline`,disabled:n||!_r(t),onClick:()=>void r(),children:n?`Revoking…`:`Revoke others`}),(0,Q.jsxs)(Ft,{open:s,onOpenChange:e=>{c(e),e||(u(``),f(N.filter(e=>i.includes(e))))},children:[(0,Q.jsx)(At,{render:(0,Q.jsxs)(L,{size:`xs`,variant:`default`,children:[(0,Q.jsx)(le,{className:`size-3`}),`Create link`]})}),(0,Q.jsxs)(Pt,{className:`max-w-md`,children:[(0,Q.jsxs)(Dt,{children:[(0,Q.jsx)(Ot,{children:`Create pairing link`}),(0,Q.jsx)(Nt,{children:`Generate a one-time link that another device can use to pair with this backend as an authorized client.`})]}),(0,Q.jsxs)(Mt,{children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Client label (optional)`}),(0,Q.jsx)(Tt,{value:l,onChange:e=>u(e.target.value),placeholder:`e.g. Living room iPad`,disabled:m,autoFocus:!0})]}),(0,Q.jsxs)(`section`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-xs font-medium text-foreground`,children:`Permissions`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Limit what the paired client can do.`})]}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(L,{size:`xs`,variant:`outline`,disabled:m,onClick:()=>f([ae,a,S,ge].filter(e=>i.includes(e))),children:`Read only`}),(0,Q.jsx)(L,{size:`xs`,variant:`outline`,disabled:m,onClick:()=>f(N.filter(e=>i.includes(e))),children:`Standard`})]})]}),(0,Q.jsx)(`div`,{className:`divide-y divide-border/60 rounded-lg border border-input bg-muted/25`,children:Or.filter(({scope:e})=>i.includes(e)).map(({scope:e,title:t,description:n})=>(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 px-3 py-2.5 transition-colors hover:bg-muted/40`,children:[(0,Q.jsx)(an,{className:`mt-0.5`,checked:d.includes(e),disabled:m,onCheckedChange:t=>_(e,t===!0)}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block text-xs font-medium text-foreground`,children:t}),(0,Q.jsx)(`span`,{className:`block text-xs leading-snug text-muted-foreground`,children:n})]})]},e))}),p.length===0?(0,Q.jsx)(`p`,{className:`text-xs text-destructive`,children:`Select at least one permission.`}):p.includes(`access:write`)?(0,Q.jsx)(`p`,{className:`text-xs text-warning`,children:`This client can create or revoke access for other devices.`}):null]})]}),(0,Q.jsxs)(kt,{variant:`bare`,children:[(0,Q.jsx)(L,{variant:`outline`,disabled:m,onClick:()=>c(!1),children:`Cancel`}),(0,Q.jsx)(L,{disabled:m||p.length===0,onClick:()=>void g(),children:m?`Creating…`:`Create link`})]})]})]})]})}),ia=(0,$.memo)(function(e){let t=(0,Z.c)(39),{endpointUrl:n,endpoints:r,defaultEndpointKey:i,presentation:a,isLoading:o,pairingLinks:s,createdPairingCredentials:c,clientSessions:l,revokingPairingLinkId:u,revokingClientSessionId:d,onRevokePairingLink:f,onRevokeClientSession:p,canRevoke:m}=e,h=a===void 0?`current`:a,g;if(t[0]!==m||t[1]!==c||t[2]!==i||t[3]!==n||t[4]!==r||t[5]!==f||t[6]!==s||t[7]!==h||t[8]!==u){let e;t[10]!==m||t[11]!==c||t[12]!==i||t[13]!==n||t[14]!==r||t[15]!==f||t[16]!==h||t[17]!==u?(e=e=>(0,Q.jsx)(ta,{pairingLink:e,credential:c.get(e.id),endpointUrl:n,endpoints:r,defaultEndpointKey:i,presentation:h,revokingPairingLinkId:u,onRevoke:f,canRevoke:m},e.id),t[10]=m,t[11]=c,t[12]=i,t[13]=n,t[14]=r,t[15]=f,t[16]=h,t[17]=u,t[18]=e):e=t[18],g=s.map(e),t[0]=m,t[1]=c,t[2]=i,t[3]=n,t[4]=r,t[5]=f,t[6]=s,t[7]=h,t[8]=u,t[9]=g}else g=t[9];let _;if(t[19]!==m||t[20]!==l||t[21]!==p||t[22]!==h||t[23]!==d){let e;t[25]!==m||t[26]!==p||t[27]!==h||t[28]!==d?(e=e=>(0,Q.jsx)(na,{clientSession:e,presentation:h,revokingClientSessionId:d,onRevokeSession:p,canRevoke:m},e.sessionId),t[25]=m,t[26]=p,t[27]=h,t[28]=d,t[29]=e):e=t[29],_=l.map(e),t[19]=m,t[20]=l,t[21]=p,t[22]=h,t[23]=d,t[24]=_}else _=t[24];let v;t[30]!==l.length||t[31]!==o||t[32]!==s.length||t[33]!==h?(v=s.length===0&&l.length===0&&!o?(0,Q.jsx)(`div`,{className:Vi(h),children:(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:`No pairing links or client sessions.`})}):null,t[30]=l.length,t[31]=o,t[32]=s.length,t[33]=h,t[34]=v):v=t[34];let y;return t[35]!==g||t[36]!==_||t[37]!==v?(y=(0,Q.jsxs)(Q.Fragment,{children:[g,_,v]}),t[35]=g,t[36]=_,t[37]=v,t[38]=y):y=t[38],y}),aa=(0,$.memo)(function(e){let t=(0,Z.c)(50),{endpoint:n,isDefault:r,presentation:i,onSetDefault:a,onSetupTailscaleServe:o,onDisableTailscaleServe:s,isUpdatingTailscaleServe:c}=e,l=i===void 0?`current`:i,u=n.status===`available`,d;t[0]===n?d=t[1]:(d=Yi(n)&&n.status!==`available`,t[0]=n,t[1]=d);let f=d,p;t[2]===n?p=t[3]:(p=Yi(n)&&n.status===`available`,t[2]=n,t[3]=p);let m=p,h=!f,g=l===`endpoint-rail`,_;t[4]!==u||t[5]!==l?(_=Hi(l,u),t[4]=u,t[5]=l,t[6]=_):_=t[6];let v;t[7]!==r||t[8]!==g?(v=g&&r?(0,Q.jsx)(`span`,{className:`absolute inset-y-2 left-0 w-1 rounded-r-full bg-primary`,"aria-hidden":!0}):null,t[7]=r,t[8]=g,t[9]=v):v=t[9];let y;t[10]===n.label?y=t[11]:(y=(0,Q.jsx)(`h3`,{className:`shrink-0 text-sm leading-5 font-medium text-foreground`,children:n.label}),t[10]=n.label,t[11]=y);let b;t[12]!==n.httpBaseUrl||t[13]!==h?(b=h?(0,Q.jsxs)(Ct,{children:[(0,Q.jsx)(xt,{render:(0,Q.jsx)(`p`,{className:`min-w-0 truncate text-xs leading-5 text-muted-foreground`,children:n.httpBaseUrl})}),(0,Q.jsx)(St,{side:`top`,children:n.httpBaseUrl})]}):null,t[12]=n.httpBaseUrl,t[13]=h,t[14]=b):b=t[14];let x;t[15]===u?x=t[16]:(x=u?null:(0,Q.jsx)(`span`,{className:`shrink-0 rounded-md border border-border/70 px-1 py-0.5 text-3xs text-muted-foreground`,children:`Setup required`}),t[15]=u,t[16]=x);let S;t[17]!==y||t[18]!==b||t[19]!==x?(S=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-3`,children:[y,b,x]}),t[17]=y,t[18]=b,t[19]=x,t[20]=S):S=t[20];let C;t[21]===r?C=t[22]:(C=r?(0,Q.jsx)(`span`,{className:`rounded-md border border-primary/30 bg-primary/10 px-1 py-0.5 text-3xs text-primary`,children:`Default`}):null,t[21]=r,t[22]=C);let w;t[23]!==n||t[24]!==c||t[25]!==f||t[26]!==o?(w=f?(0,Q.jsx)(L,{size:`xs`,variant:`outline`,onClick:()=>o(n),disabled:c,children:c?`Restarting…`:`Setup`}):null,t[23]=n,t[24]=c,t[25]=f,t[26]=o,t[27]=w):w=t[27];let T;t[28]!==m||t[29]!==n||t[30]!==c||t[31]!==s?(T=m?(0,Q.jsx)(L,{size:`xs`,variant:`destructive-outline`,onClick:()=>s(n),disabled:c,children:c?`Restarting…`:`Disable`}):null,t[28]=m,t[29]=n,t[30]=c,t[31]=s,t[32]=T):T=t[32];let E;t[33]!==n||t[34]!==r||t[35]!==f||t[36]!==a?(E=!f&&!r?(0,Q.jsx)(L,{size:`xs`,variant:`outline`,onClick:()=>a(n),children:`Set as default`}):null,t[33]=n,t[34]=r,t[35]=f,t[36]=a,t[37]=E):E=t[37];let D;t[38]!==C||t[39]!==w||t[40]!==T||t[41]!==E?(D=(0,Q.jsxs)(`div`,{className:`ml-auto flex min-h-6 shrink-0 items-center justify-end gap-2`,children:[C,w,T,E]}),t[38]=C,t[39]=w,t[40]=T,t[41]=E,t[42]=D):D=t[42];let O;t[43]!==D||t[44]!==S?(O=(0,Q.jsxs)(`div`,{className:`flex min-h-6 min-w-0 flex-col gap-2 sm:-my-0.5 sm:flex-row sm:items-center`,children:[S,D]}),t[43]=D,t[44]=S,t[45]=O):O=t[45];let k;return t[46]!==O||t[47]!==_||t[48]!==v?(k=(0,Q.jsxs)(`div`,{className:_,children:[v,O]}),t[46]=O,t[47]=_,t[48]=v,t[49]=k):k=t[49],k});function oa(e){let t=(0,Z.c)(14),{endpoint:n,hiddenEndpointCount:r,expanded:i,onToggleExpanded:a,fallback:o}=e;if(!n)return o;let s;t[0]===n.httpBaseUrl?s=t[1]:(s=(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:n.httpBaseUrl}),t[0]=n.httpBaseUrl,t[1]=s);let c;t[2]!==i||t[3]!==r?(c=r>0?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs font-medium`,children:i?`Hide`:`+${r}`}):null,t[2]=i,t[3]=r,t[4]=c):c=t[4];let l;t[5]!==s||t[6]!==c?(l=(0,Q.jsxs)(Q.Fragment,{children:[s,c]}),t[5]=s,t[6]=c,t[7]=l):l=t[7];let u=l,d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(`span`,{className:`shrink-0`,children:`Reachable at`}),t[8]=d):d=t[8];let f;return t[9]!==i||t[10]!==r||t[11]!==a||t[12]!==u?(f=(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-baseline gap-1`,children:[d,r>0?(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex min-w-0 max-w-full items-baseline gap-2 border-b border-dotted border-muted-foreground/60 text-left text-muted-foreground underline-offset-4 hover:border-foreground hover:text-foreground`,onClick:a,"aria-expanded":i,children:u}):(0,Q.jsx)(`span`,{className:`inline-flex min-w-0 max-w-full items-baseline gap-2`,children:u})]}),t[9]=i,t[10]=r,t[11]=a,t[12]=u,t[13]=f):f=t[13],f}function sa(e){if(!e.entry.enabled&&e.connection.phase!==`unsupported`)return{text:`Off`,tone:`muted`};let{connection:t}=e;switch(t.phase){case`connected`:return{text:`Connected`,tone:`muted`};case`connecting`:return{text:`Connecting`,tone:`muted`};case`reconnecting`:return{text:t.error?`Reconnecting: ${t.error}`:`Reconnecting`,tone:`error`};case`unsupported`:return{text:`Client not supported`,tone:`muted`};case`error`:return{text:t.error?`Connection failed: ${t.error}`:`Connection failed`,tone:`error`};case`offline`:return{text:`Offline`,tone:`muted`};case`available`:return{text:`Not connected`,tone:`muted`}}}function ca(e){let t=(0,Z.c)(177),{environment:n,removingEnvironmentId:r,onSetEnabled:i,onRemove:a,onAddRoute:o}=e,[s,c]=(0,$.useState)(!1),[l,u]=(0,$.useState)(!1),[d,f]=(0,$.useState)(!1),p=n.environmentId,m=n.connection.phase===`unsupported`,g=n.entry.enabled&&!m,_=n.connection.phase===`connected`,v=r===p,b=n.connection.traceId,S;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(S={target:`trace ID`,onCopy:_a,onError:ga},t[0]=S):S=t[0];let{copyToClipboard:w}=$e(S),T;t[1]===w?T=t[2]:(T=e=>{w(e,{traceId:e})},t[1]=w,t[2]=T);let E=T,D;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(D={target:`MCP URL`,onCopy:ha,onError:ma},t[3]=D):D=t[3];let{copyToClipboard:O}=$e(D),k;t[4]===n.serverConfig?k=t[5]:(k=nr(n.serverConfig),t[4]=n.serverConfig,t[5]=k);let A=k,j;t[6]===p?j=t[7]:(j=ct.updateStateAtom(p),t[6]=p,t[7]=j);let N=de(j),F=N.status===`running`&&N.stage===`resuming`,ee;t[8]===n?ee=t[9]:(ee=sa(n),t[8]=n,t[9]=ee);let I=ee,ne=n.serverConfig?.environment.serverVersion??null,ie=et(),ae;t[10]!==p||t[11]!==ie.environments?(ae=re(ie.environments.get(p)?.status??x())?.descriptor,t[10]=p,t[11]=ie.environments,t[12]=ae):ae=t[12];let oe=ae,[R,se]=(0,$.useState)(oe);oe!==void 0&&oe!==R&&se(oe);let ce;t[13]!==p||t[14]!==ie.environments?(ce=ie.environments.get(p)?.environment.endpoint.httpBaseUrl,t[13]=p,t[14]=ie.environments,t[15]=ce):ce=t[15];let le=ce,[fe,pe]=(0,$.useState)(le);le!==void 0&&le!==fe&&pe(le);let he=_t(lt.retryNow),{diagnosis:ge,state:_e,relayOnly:B}=$t(n),V=F?null:ge,ve=ht(p),ye=_&&ve._tag===`Some`?ve.value.target:null,H=le??fe,xe;t[16]!==ye||t[17]!==n.entry||t[18]!==H?(xe=We({entry:n.entry,relayHttpBaseUrl:H,connectedTarget:ye}),t[16]=ye,t[17]=n.entry,t[18]=H,t[19]=xe):xe=t[19];let Se=xe,Ce;t[20]!==n.serverConfig||t[21]!==R?(Ce=n.serverConfig??(R===void 0?null:{environment:R}),t[20]=n.serverConfig,t[21]=R,t[22]=Ce):Ce=t[22];let we;t[23]===Ce?we=t[24]:(we=h(Ce),t[23]=Ce,t[24]=we);let Te=we,Ee;t[25]===n.entry?Ee=t[26]:(Ee=Ne(n.entry),t[25]=n.entry,t[26]=Ee);let U=Ee.length,De;t[27]!==ye||t[28]!==n?(De=Vr(n,ye),t[27]=ye,t[28]=n,t[29]=De):De=t[29];let Oe=V?null:F?`Restarting`:I.text,ke=g&&A?ne:null,Ae;t[30]!==De||t[31]!==Oe||t[32]!==ke?(Ae=[De,Oe,ke].filter(pa),t[30]=De,t[31]=Oe,t[32]=ke,t[33]=Ae):Ae=t[33];let W=Ae.join(` · `),je=g&&_&&A!==null&&(N.status===`idle`||N.status===`failed`),G;t[34]!==g||t[35]!==n.connection||t[36]!==m?(G=m?n.connection.error??Ge(n.connection):g?Ge(n.connection):`Switched off`,t[34]=g,t[35]=n.connection,t[36]=m,t[37]=G):G=t[37];let Me=`${G}${A?`\nUpdate available: ${A.serverVersion} → ${A.clientVersion}`:``}`,K=n.label,Pe=!g,Fe=g&&I.tone===`error`&&!F&&!V&&`text-destructive`,Ie;t[38]===Fe?Ie=t[39]:(Ie=be(`min-w-0 truncate`,Fe),t[38]=Fe,t[39]=Ie);let Le;t[40]===Ie?Le=t[41]:(Le=(0,Q.jsx)(`span`,{className:Ie}),t[40]=Ie,t[41]=Le);let Re;t[42]!==Me||t[43]!==W||t[44]!==Le?(Re=(0,Q.jsx)(xt,{payload:Me,render:Le,children:W}),t[42]=Me,t[43]=W,t[44]=Le,t[45]=Re):Re=t[45];let ze;t[46]===Me?ze=t[47]:(ze=(0,Q.jsx)(St,{side:`top`,className:`whitespace-pre-wrap`,children:Me}),t[46]=Me,t[47]=ze);let Ve;t[48]!==Re||t[49]!==ze?(Ve=(0,Q.jsxs)(Ct,{children:[Re,ze]}),t[48]=Re,t[49]=ze,t[50]=Ve):Ve=t[50];let q;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0`,children:`·`}),t[51]=q):q=t[51];let He;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(He=()=>c(fa),t[52]=He):He=t[52];let Ue=U===1?`Routes`:`${U} routes`,Ke=s&&`rotate-90`,qe;t[53]===Ke?qe=t[54]:(qe=be(`size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none`,Ke),t[53]=Ke,t[54]=qe);let Je;t[55]===qe?Je=t[56]:(Je=(0,Q.jsx)(y,{"aria-hidden":!0,className:qe}),t[55]=qe,t[56]=Je);let Ye;t[57]!==s||t[58]!==Ue||t[59]!==Je?(Ye=(0,Q.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:He,className:`inline-flex shrink-0 items-center gap-0.5 rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring`,children:[Ue,Je]}),t[57]=s,t[58]=Ue,t[59]=Je,t[60]=Ye):Ye=t[60];let Xe;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0`,children:`·`}),t[61]=Xe):Xe=t[61];let Ze=`remote-permissions-${p}`,Qe;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(Qe=()=>u(da),t[62]=Qe):Qe=t[62];let J=l&&`rotate-90`,tt;t[63]===J?tt=t[64]:(tt=be(`size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none`,J),t[63]=J,t[64]=tt);let nt;t[65]===tt?nt=t[66]:(nt=(0,Q.jsx)(y,{"aria-hidden":!0,className:tt}),t[65]=tt,t[66]=nt);let Y;t[67]!==l||t[68]!==Ze||t[69]!==nt?(Y=(0,Q.jsxs)(`button`,{type:`button`,"aria-expanded":l,"aria-controls":Ze,onClick:Qe,className:`inline-flex shrink-0 items-center gap-0.5 rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring`,children:[`Permissions`,nt]}),t[67]=l,t[68]=Ze,t[69]=nt,t[70]=Y):Y=t[70];let rt;t[71]!==Ve||t[72]!==Ye||t[73]!==Y?(rt=(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[Ve,q,Ye,Xe,Y]}),t[71]=Ve,t[72]=Ye,t[73]=Y,t[74]=rt):rt=t[74];let it;t[75]!==_e||t[76]!==V||t[77]!==d?(it=V?(0,Q.jsx)(Zt,{diagnosis:V,retryAt:_e.phase===`backoff`?_e.retryAt:null,attempt:_e.attempt,expanded:d,onToggle:()=>f(ua)}):null,t[75]=_e,t[76]=V,t[77]=d,t[78]=it):it=t[78];let at;t[79]===N?at=t[80]:(at=N.status===`idle`?null:(0,Q.jsx)(`div`,{className:`mt-1 max-w-md`,children:(0,Q.jsx)(zn,{state:N})}),t[79]=N,t[80]=at);let ot;t[81]!==it||t[82]!==at?(ot=(0,Q.jsxs)(Q.Fragment,{children:[it,at]}),t[81]=it,t[82]=at,t[83]=ot):ot=t[83];let st;t[84]!==V||t[85]!==d||t[86]!==n||t[87]!==p||t[88]!==o||t[89]!==B||t[90]!==he?(st=V&&d?(0,Q.jsx)(tn,{hostLabel:n.label,diagnosis:V,onRetry:()=>void he(p),onAddRoute:B?()=>o(n):null}):null,t[84]=V,t[85]=d,t[86]=n,t[87]=p,t[88]=o,t[89]=B,t[90]=he,t[91]=st):st=t[91];let ut;t[92]!==n||t[93]!==o||t[94]!==s?(ut=s&&(0,Q.jsx)(Ir,{environment:n,onAddRoute:()=>o(n)}),t[92]=n,t[93]=o,t[94]=s,t[95]=ut):ut=t[95];let dt;t[96]!==p||t[97]!==_||t[98]!==l?(dt=l&&(0,Q.jsx)(`div`,{id:`remote-permissions-${p}`,className:`mt-2 border-t border-border/50`,children:(0,Q.jsx)(kr,{environmentId:p,connected:_,routeContext:!0})}),t[96]=p,t[97]=_,t[98]=l,t[99]=dt):dt=t[99];let ft;t[100]!==st||t[101]!==ut||t[102]!==dt?(ft=(0,Q.jsxs)(Q.Fragment,{children:[st,ut,dt]}),t[100]=st,t[101]=ut,t[102]=dt,t[103]=ft):ft=t[103];let pt;t[104]!==n.entry.serverUpdateRequired||t[105]!==n.label||t[106]!==p||t[107]!==R?.serverVersion||t[108]!==N.status||t[109]!==m?(pt=m&&n.entry.serverUpdateRequired===!0&&N.status!==`running`?(0,Q.jsx)(Yn,{environmentId:p,serverLabel:`${n.label} server`,fromVersion:R?.serverVersion,targetVersion:Be,label:N.status===`failed`?`Retry update`:`Update`}):null,t[104]=n.entry.serverUpdateRequired,t[105]=n.label,t[106]=p,t[107]=R?.serverVersion,t[108]=N.status,t[109]=m,t[110]=pt):pt=t[110];let mt;t[111]!==n.label||t[112]!==n.serverConfig||t[113]!==p||t[114]!==N.status||t[115]!==je||t[116]!==A?(mt=je?(0,Q.jsx)(Tr,{environmentId:p,serverLabel:`${n.label} server`,selfUpdate:tr(n.serverConfig),installation:n.serverConfig?.environment.capabilities.serverInstallation,desktopAppUpdate:Jn(n.serverConfig),threadContinuation:In(n.serverConfig),targetVersion:A.clientVersion,label:N.status===`failed`?`Retry update`:`Update`,appearance:`icon`}):null,t[111]=n.label,t[112]=n.serverConfig,t[113]=p,t[114]=N.status,t[115]=je,t[116]=A,t[117]=mt):mt=t[117];let gt=v||m,vt=`${g?`Switch off`:`Switch on`} ${n.label}`,yt;t[118]!==p||t[119]!==i?(yt=e=>i(p,e),t[118]=p,t[119]=i,t[120]=yt):yt=t[120];let bt;t[121]!==g||t[122]!==gt||t[123]!==vt||t[124]!==yt?(bt=(0,Q.jsx)(xt,{render:(0,Q.jsx)(lr,{size:`sm`,checked:g,disabled:gt,"aria-label":vt,onCheckedChange:yt})}),t[121]=g,t[122]=gt,t[123]=vt,t[124]=yt,t[125]=bt):bt=t[125];let wt=m?`Client not supported`:g?`Switch off`:`Switch on`,Tt;t[126]===wt?Tt=t[127]:(Tt=(0,Q.jsx)(St,{side:`top`,children:wt}),t[126]=wt,t[127]=Tt);let Et;t[128]!==bt||t[129]!==Tt?(Et=(0,Q.jsxs)(Ct,{children:[bt,Tt]}),t[128]=bt,t[129]=Tt,t[130]=Et):Et=t[130];let Dt=`More actions for ${n.label}`,Ot;t[131]!==v||t[132]!==Dt?(Ot=(0,Q.jsx)(L,{type:`button`,variant:`ghost-muted`,size:`icon-xs`,disabled:v,"aria-label":Dt}),t[131]=v,t[132]=Dt,t[133]=Ot):Ot=t[133];let kt;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(kt=(0,Q.jsx)(te,{className:`size-3.5`}),t[134]=kt):kt=t[134];let At;t[135]===Ot?At=t[136]:(At=(0,Q.jsx)(M,{render:Ot,children:kt}),t[135]=Ot,t[136]=At);let jt;t[137]!==n.serverConfig||t[138]!==p?(jt=(0,Q.jsx)(Fr,{environmentId:p,serverConfig:n.serverConfig}),t[137]=n.serverConfig,t[138]=p,t[139]=jt):jt=t[139];let Mt,Nt;t[140]===Symbol.for(`react.memo_cache_sentinel`)?(Mt=()=>c(la),Nt=(0,Q.jsx)(me,{}),t[140]=Mt,t[141]=Nt):(Mt=t[140],Nt=t[141]);let Pt=s?`Hide routes`:`Routes`,Ft;t[142]===Pt?Ft=t[143]:(Ft=(0,Q.jsxs)(P,{onClick:Mt,children:[Nt,Pt]}),t[142]=Pt,t[143]=Ft);let It;t[144]!==O||t[145]!==Se?(It=Se?(0,Q.jsx)(P,{onClick:()=>O(Se,{url:Se}),children:`Copy MCP URL`}):null,t[144]=O,t[145]=Se,t[146]=It):It=t[146];let Lt;t[147]!==E||t[148]!==b?(Lt=b?(0,Q.jsx)(P,{onClick:()=>E(b),children:`Copy trace ID`}):null,t[147]=E,t[148]=b,t[149]=Lt):Lt=t[149];let Rt;t[150]===Symbol.for(`react.memo_cache_sentinel`)?(Rt=(0,Q.jsx)(z,{}),t[150]=Rt):Rt=t[150];let zt;t[151]!==n||t[152]!==a?(zt=()=>a(n),t[151]=n,t[152]=a,t[153]=zt):zt=t[153];let Bt=v?`Removing…`:`Remove from this device…`,Vt;t[154]!==zt||t[155]!==Bt?(Vt=(0,Q.jsx)(P,{variant:`destructive`,onClick:zt,children:Bt}),t[154]=zt,t[155]=Bt,t[156]=Vt):Vt=t[156];let Ht;t[157]!==jt||t[158]!==Ft||t[159]!==It||t[160]!==Lt||t[161]!==Vt?(Ht=(0,Q.jsxs)(ue,{align:`end`,children:[jt,Ft,It,Lt,Rt,Vt]}),t[157]=jt,t[158]=Ft,t[159]=It,t[160]=Lt,t[161]=Vt,t[162]=Ht):Ht=t[162];let Ut;t[163]!==At||t[164]!==Ht?(Ut=(0,Q.jsxs)(C,{children:[At,Ht]}),t[163]=At,t[164]=Ht,t[165]=Ut):Ut=t[165];let Wt;return t[166]!==n.label||t[167]!==Te||t[168]!==Pe||t[169]!==rt||t[170]!==ot||t[171]!==ft||t[172]!==pt||t[173]!==mt||t[174]!==Et||t[175]!==Ut?(Wt=(0,Q.jsxs)(Hr,{kind:Te,label:K,dimmed:Pe,subtitle:rt,below:ot,detail:ft,children:[pt,mt,Et,Ut]}),t[166]=n.label,t[167]=Te,t[168]=Pe,t[169]=rt,t[170]=ot,t[171]=ft,t[172]=pt,t[173]=mt,t[174]=Et,t[175]=Ut,t[176]=Wt):Wt=t[176],Wt}function la(e){return!e}function ua(e){return!e}function da(e){return!e}function fa(e){return!e}function pa(e){return e!==null}function ma(e){J.add(vt({type:`error`,title:`Could not copy MCP URL`,description:e.message}))}function ha(e){let{url:t}=e;J.add({type:`success`,title:`MCP URL copied`,description:`Add it to an agent, e.g. claude mcp add --transport http p4 ${t}`})}function ga(e){J.add(vt({type:`error`,title:`Could not copy trace ID`,description:e.message}))}function _a(e){let{traceId:t}=e;J.add({type:`success`,title:`Trace ID copied`,description:t})}function va(e){let t=(0,Z.c)(10),{checked:n,disabled:r,disabledReason:i,onCheckedChange:a,ariaLabel:o}=e,s=o===void 0?`Enable P4 Connect`:o,c;t[0]===a?c=t[1]:(c=a?{onCheckedChange:a}:{},t[0]=a,t[1]=c);let l;t[2]!==s||t[3]!==n||t[4]!==r||t[5]!==c?(l=(0,Q.jsx)(lr,{"aria-label":s,checked:n,disabled:r,...c}),t[2]=s,t[3]=n,t[4]=r,t[5]=c,t[6]=l):l=t[6];let u=l,d;return t[7]!==u||t[8]!==i?(d=i?(0,Q.jsxs)(Ct,{children:[(0,Q.jsx)(xt,{render:(0,Q.jsx)(`span`,{className:`inline-flex`,children:u})}),(0,Q.jsx)(St,{side:`top`,children:i})]}):u,t[7]=u,t[8]=i,t[9]=d):d=t[9],d}function ya(e){let t=(0,Z.c)(53),{canManageRelay:n}=e,r=Y(),{isSignedIn:i,linkState:a,linkRevoked:s,managedTunnelActive:c,managedTunnelOutOfSync:l,publishAgentActivity:u,holdWebhooksWhileOffline:d,operationError:f,reconcileCloudState:p}=mr(),[m,h]=(0,$.useState)(!1),[g,_]=(0,$.useState)(!1),v=i?n?null:`Your session does not have permission to manage P4 Connect access.`:`Sign in to P4 Connect to manage this environment.`,y=m||g,b=(0,$.useEffectEvent)(a.refresh),x;t[0]===b?x=t[1]:(x=()=>{let e=window.setInterval(()=>b(),3e4);return()=>window.clearInterval(e)},t[0]=b,t[1]=x);let S;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(S=[],t[2]=S):S=t[2],(0,$.useEffect)(x,S);let C=c?a.data?.reachability:void 0,w;t[3]===C?w=t[4]:(w=C?.status===`reachable`?F(C):C?.status===`unreachable`?(0,Q.jsxs)(`span`,{className:`block text-destructive`,children:[[C.reason,C.hint,`Fix: ${C.fix}`].filter(Boolean).join(` `),` `,(0,Q.jsx)(`a`,{href:o(C.cause),target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:`More info`})]}):null,t[3]=C,t[4]=w);let T=w,E;t[5]!==r||t[6]!==u||t[7]!==p?(E=async e=>{r!==null&&pt(r,`relay:write`)&&(h(!0),await p({managedTunnel:e,publish:u})&&J.add({type:`success`,title:e?`P4 Connect linked`:u?`P4 Connect tunnel disabled`:`P4 Connect unlinked`,description:e?`This environment is available through P4 Connect.`:u?`The managed tunnel was removed. Agent activity publishing stays on.`:`This environment is no longer available through P4 Connect.`}),h(!1))},t[5]=r,t[6]=u,t[7]=p,t[8]=E):E=t[8];let D=E,O;t[9]!==c||t[10]!==r||t[11]!==p?(O=async e=>{r!==null&&pt(r,`relay:write`)&&(_(!0),await p({managedTunnel:c,publish:e})&&J.add({type:`success`,title:e?`Agent activity enabled`:`Agent activity disabled`,description:e?`This environment publishes agent activity to your mobile clients.`:`This environment will stop publishing agent activity.`}),_(!1))},t[9]=c,t[10]=r,t[11]=p,t[12]=O):O=t[12];let k=O,A;t[13]!==c||t[14]!==u||t[15]!==p?(A=async e=>{_(!0),await p({managedTunnel:c,publish:u,holdWebhooksWhileOffline:e})&&J.add({type:`success`,title:e?`Webhooks held while offline`:`Webhooks no longer held`,description:e?`P4 Connect keeps webhook requests for up to 24 hours while this environment is offline.`:`Requests to an offline environment now fail. Anything already held is still delivered.`}),_(!1)},t[13]=c,t[14]=u,t[15]=p,t[16]=A):A=t[16];let j=A,M;t[17]!==n||t[18]!==v||t[19]!==y||t[20]!==i||t[21]!==s||t[22]!==c||t[23]!==l||t[24]!==f||t[25]!==a.data||t[26]!==a.error||t[27]!==a.isPending||t[28]!==C?.status||t[29]!==T||t[30]!==D?(M=window.desktopBridge?(0,Q.jsx)(vn,{title:Rn(`p4-connect`).title,description:s?`This environment was removed from P4 Connect. Turn it on to link it again.`:c?C?.status===`unreachable`?`P4 Connect is on, but other devices cannot reach this environment.`:C?.status===`reachable`?`This environment is available to your other devices through P4 Connect.`:`P4 Connect is on. Reachability has not been checked yet.`:l?`P4 Connect is out of sync. This environment is linked only to publish agent activity, so other devices cannot connect. Turn P4 Connect on to repair it.`:`Make this environment available to your other devices through P4 Connect.`,status:f??a.error??T,control:(0,Q.jsx)(va,{checked:c,disabled:!n||!i||a.data===null||a.isPending||y,disabledReason:v,onCheckedChange:e=>void D(e)})}):s?(0,Q.jsx)(vn,{title:Rn(`p4-connect`).title,description:"This environment was removed from P4 Connect. Run `p4c connect link` on the host to link it again."}):null,t[17]=n,t[18]=v,t[19]=y,t[20]=i,t[21]=s,t[22]=c,t[23]=l,t[24]=f,t[25]=a.data,t[26]=a.error,t[27]=a.isPending,t[28]=C?.status,t[29]=T,t[30]=D,t[31]=M):M=t[31];let N;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(N=Rn(`publish-agent-activity`),t[32]=N):N=t[32];let P=!n||!i||a.data===null||a.isPending||y,ee;t[33]===k?ee=t[34]:(ee=e=>void k(e),t[33]=k,t[34]=ee);let I;t[35]!==v||t[36]!==u||t[37]!==ee||t[38]!==P?(I=(0,Q.jsx)(vn,{title:N.title,description:`Send activity to mobile notifications and Live Activities without P4 Connect.`,control:(0,Q.jsx)(va,{ariaLabel:`Publish agent activity to mobile clients`,checked:u,disabled:P,disabledReason:v,onCheckedChange:ee})}),t[35]=v,t[36]=u,t[37]=ee,t[38]=P,t[39]=I):I=t[39];let te;t[40]!==n||t[41]!==v||t[42]!==d||t[43]!==y||t[44]!==i||t[45]!==c||t[46]!==a.isPending||t[47]!==j?(te=c?(0,Q.jsx)(vn,{title:Rn(`hold-webhooks-while-offline`).title,description:`Keep webhook requests for up to 24 hours while this environment is offline, then deliver them. Off: P4 Connect only forwards requests and stores nothing.`,control:(0,Q.jsx)(va,{ariaLabel:`Hold webhook requests while this environment is offline`,checked:d,disabled:!n||!i||a.isPending||y,disabledReason:v,onCheckedChange:e=>void j(e)})}):null,t[40]=n,t[41]=v,t[42]=d,t[43]=y,t[44]=i,t[45]=c,t[46]=a.isPending,t[47]=j,t[48]=te):te=t[48];let L;return t[49]!==I||t[50]!==te||t[51]!==M?(L=(0,Q.jsxs)(Q.Fragment,{children:[M,I,te]}),t[49]=I,t[50]=te,t[51]=M,t[52]=L):L=t[52],L}function ba(e){let t=(0,Z.c)(3),{canReadRelay:n,canManageRelay:r}=e;if(!Pe())return null;if(!n){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(vn,{title:`P4 Connect`,description:`To edit these settings, pair this connection with both View relay and Manage relay permissions.`}),t[0]=e):e=t[0],e}let i;return t[1]===r?i=t[2]:(i=(0,Q.jsx)(ya,{canManageRelay:r}),t[1]=r,t[2]=i),i}function xa(e){let t=(0,Z.c)(4),{cloudEnabled:n}=e,r=n===void 0||n,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(Lt,{variant:`icon`,children:(0,Q.jsx)(c,{})}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(zt,{children:`No saved remote environments`}),t[1]=a):a=t[1];let o=r?`Click “Add environment” to pair another environment, or connect one from P4 Connect.`:`Click “Add environment” to pair another environment.`,s;return t[2]===o?s=t[3]:(s=(0,Q.jsxs)(Vt,{className:`min-h-52`,children:[i,(0,Q.jsxs)(Rt,{children:[a,(0,Q.jsx)(Bt,{children:o})]})]}),t[2]=o,t[3]=s),s}function Sa(e){let t=(0,Z.c)(3),{primaryEnvironmentId:n,savedEnvironments:r}=e,i;return t[0]!==n||t[1]!==r?(i=Pe()?(0,Q.jsx)(rr,{primaryEnvironmentId:n,savedEnvironments:r,empty:(0,Q.jsx)(xa,{})}):r.length===0?(0,Q.jsx)(xa,{cloudEnabled:!1}):null,t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function Ca(){let e=window.desktopBridge,t=de(ut),{environments:n}=nt(),r=tt(),i=dr(),a=_t(Fn,{reportFailure:!1}),o=_t(Pn,{reportFailure:!1}),s=_t(lt.remove,{reportFailure:!1}),l=_t(lt.register,{reportFailure:!1}),u=et(),d=_t(lt.setEnabled,{reportFailure:!1}),f=r?.environmentId??null,p=Nn(),m=p.data?.authenticated?p.data.permissions??p.data.scopes??null:null,g=e?null:p.data?.auth.policy??null,v=(0,$.useMemo)(()=>n.filter(e=>e.entry.target._tag!==`PrimaryConnectionTarget`),[n]),x=(0,$.useMemo)(()=>v.filter(e=>!Ue(e.entry.target)),[v]),S=(0,$.useMemo)(()=>A(e=>v.map(t=>({environment:t,updateStatus:e(ct.updateStateAtom(t.environmentId)).status}))),[v]),T=de(S),E=(0,$.useMemo)(()=>T.flatMap(({environment:e,updateStatus:t})=>{let n=nr(e.serverConfig),r=tr(e.serverConfig),i=Jn(e.serverConfig);return!n||t===`running`||!e.entry.enabled||e.connection.phase!==`connected`||Ue(e.entry.target)||r===null||r===`desktop-managed`&&!i?[]:[{environmentId:e.environmentId,serverLabel:e.label,selfUpdate:r,installation:e.serverConfig?.environment.capabilities.serverInstallation,desktopAppUpdate:i,threadContinuation:In(e.serverConfig),continueThreadsAfterServerUpdate:e.serverConfig?.settings.continueThreadsAfterServerUpdate??!1,targetVersion:n.clientVersion}]}),[T]),D=(0,$.useMemo)(()=>[...r?[r]:[],...v.filter(e=>e.entry.enabled)],[r,v]),O=(0,$.useMemo)(()=>{let e=new Set;for(let t of v){let n=t.entry.profile;if(t.entry.target._tag!==`SshConnectionTarget`||Ce(n)||n.value._tag!==`SshConnectionProfile`)continue;let r=n.value.target;e.add(r.alias),e.add(Br(r))}return e},[v]),[k,N]=(0,$.useState)(null),[P,F]=(0,$.useState)(null),[ee,I]=(0,$.useState)(()=>new Map),ne=(0,$.useCallback)(e=>{I(t=>new Map(t).set(e.id,e.credential))},[]),[re,ie]=(0,$.useState)(null),[ae,oe]=(0,$.useState)(null),[R,se]=(0,$.useState)(!1),[ce,fe]=(0,$.useState)(!1),[z,pe]=(0,$.useState)(null),[me,he]=(0,$.useState)(`remote`),[ge,B]=(0,$.useState)(``),[V,ve]=(0,$.useState)(``),[H,xe]=(0,$.useState)(``),[Se,we]=(0,$.useState)(``),[Te,Ee]=(0,$.useState)(``),[U,De]=(0,$.useState)(!1),Oe=(0,$.useRef)(void 0),[ke,W]=(0,$.useState)(null),[G,K]=(0,$.useState)(!1),[Ne,Ie]=(0,$.useState)(null),[Re,ze]=(0,$.useState)(!1),[Be,Ve]=(0,$.useState)(!1),[q,He]=(0,$.useState)(!1),[We,Ge]=(0,$.useState)(!1),[Ke,$e]=(0,$.useState)(null),[Y,rt]=(0,$.useState)(null),it=Y!==null,[ot,st]=(0,$.useState)(null),[dt,mt]=(0,$.useState)(!1),[ht,yt]=(0,$.useState)(String(Di)),[bt,wt]=(0,$.useState)(null),It=r?.serverConfig??null,Lt=nr(It),Rt=de(ct.updateStateAtom(f)),[zt,Bt]=(0,$.useState)(!1),Vt=on(e=>e.defaultAdvertisedEndpointKey),qt=on(e=>e.setDefaultAdvertisedEndpointKey),Jt=ft(f,_e),Yt=ft(f,w),Xt=ft(f,ye),Zt=ft(f,_),Qt=ft(f,j),$t=!Le()&&Zt,en=gt(Jt&&f!==null?fi.accessChanges({environmentId:f,input:null}):null),tn=gt($t&&e?yi:null),nn=e!==void 0&&ce&&me===`ssh`,rn=gt(nn?Ei:null),an=rn.refresh;(0,$.useEffect)(()=>{nn&&an()},[nn,an]);let cn=gt($t&&e?wr:null),X=cn.data,On=Ke??cn.error,An=cn.isPending&&cn.data===null,Ln=rn.data??ki,Bn=(0,$.useMemo)(()=>Ln.filter(e=>{let t=Br(e);return!O.has(e.alias)&&!O.has(t)}),[Ln,O]),Vn=(0,$.useMemo)(()=>xi(Bn,H),[H,Bn]),Hn=rn.isPending&&rn.data===null,Un=rn.error,Wn=e!==void 0&&(Hn||Bn.length>0),Gn=tn.data?.serverExposureState??null,Kn=tn.data?.advertisedEndpoints??Oi,qn=k??tn.error,Yn=P??en.error,Xn=en.isPending&&en.data===null,Zn=(0,$.useMemo)(()=>{let e=en.data;return e?.type===`snapshot`?Ui(e.payload.pairingLinks.map(e=>Ki(e))):[]},[en.data]),Qn=(0,$.useMemo)(()=>{let e=en.data;return e?.type===`snapshot`?Gi(e.payload.clientSessions.map(e=>qi(e))):[]},[en.data]),rr=e?Gn?.mode===`network-accessible`:g===`remote-reachable`,ar=ht.trim(),or=Number(ar),cr=/^\d+$/u.test(ar)&&Number.isInteger(or)&&or>=1&&or<=65535,ur=(0,$.useMemo)(()=>{if(!ot)return null;if(!cr||or===Di)return ot.httpBaseUrl;try{let e=new URL(ot.httpBaseUrl);return e.port=String(or),e.toString().replace(/\/$/u,``)}catch{return ot.httpBaseUrl}},[cr,or,ot]),fr=(0,$.useCallback)(async t=>{if(e&&f!==null&&pt(f,`environment:maintain`)){ze(!0),N(null);try{await e.setServerExposureMode(t?`network-accessible`:`local-only`),bi(),Ve(!1),ze(!1)}catch(e){let t=e instanceof Error?e.message:`Failed to update network exposure.`;Ve(!1),N(t),J.add(vt({type:`error`,title:`Could not update network access`,description:t})),ze(!1)}}},[e,f]),pr=(0,$.useCallback)(()=>{bt!==null&&fr(bt===`network-accessible`)},[fr,bt]),mr=(0,$.useCallback)(async()=>{if(e&&f!==null&&pt(f,`environment:maintain`)&&cr){He(!0),N(null);try{await e.setTailscaleServeEnabled({enabled:!0,port:or}),bi(),st(null)}catch(e){let t=e instanceof Error?e.message:`Failed to configure Tailscale HTTPS.`;N(t),J.add(vt({type:`error`,title:`Could not set up Tailscale HTTPS`,description:t}))}finally{He(!1)}}},[e,cr,or,f]),hr=(0,$.useCallback)(e=>{yt(String(Gn?.tailscaleServePort??Di)),st(e)},[Gn?.tailscaleServePort]),gr=(0,$.useCallback)(async()=>{if(e&&f!==null&&pt(f,`environment:maintain`)){He(!0),N(null);try{await e.setTailscaleServeEnabled({enabled:!1,port:Gn?.tailscaleServePort??Di}),bi(),mt(!1)}catch(e){let t=e instanceof Error?e.message:`Failed to disable Tailscale HTTPS.`;N(t),J.add(vt({type:`error`,title:`Could not disable Tailscale HTTPS`,description:t}))}finally{He(!1)}}},[e,Gn,f]),_r=(0,$.useCallback)(e=>{mt(!0)},[]),vr=(0,$.useCallback)(async e=>{if(f!==null&&pt(f,`access:write`)){ie(e),F(null);try{await Mn(e)}catch(e){let t=e instanceof Error?e.message:`Failed to revoke pairing link.`;F(t),J.add(vt({type:`error`,title:`Could not revoke pairing link`,description:t}))}finally{ie(null)}}},[f]),yr=(0,$.useCallback)(async e=>{if(f!==null&&pt(f,`access:write`)){oe(e),F(null);try{await jn(e)}catch(e){let t=e instanceof Error?e.message:`Failed to revoke client access.`;F(t),J.add(vt({type:`error`,title:`Could not revoke client access`,description:t}))}finally{oe(null)}}},[f]),br=(0,$.useCallback)(async()=>{if(f!==null&&pt(f,`access:write`)){se(!0),F(null);try{let e=await kn();J.add({type:`success`,title:e===1?`Revoked 1 other client`:`Revoked ${e} clients`,description:`Other paired clients will need a new pairing link before reconnecting.`})}catch(e){let t=e instanceof Error?e.message:`Failed to revoke other clients.`;F(t),J.add(vt({type:`error`,title:`Could not revoke other clients`,description:t}))}finally{se(!1)}}},[f]),xr=(0,$.useCallback)(async e=>{K(!0),W(null);let t=await o({target:e,label:``,...z?{expectedEnvironmentId:z.environmentId}:{}});t._tag===`Failure`?(je(t)||W(zi(Me(t))),K(!1)):(B(``),ve(``),xe(``),we(``),Ee(``),fe(!1),J.add({type:`success`,title:z?`Route added`:`Environment connected`,description:z?`${z.label} can now be reached over SSH ${e.alias}.`:`${e.alias} is ready over an SSH-managed tunnel.`}),K(!1))},[o,z]),Sr=(0,$.useCallback)(async()=>{if(me===`ssh`){let e;try{e=Ii({host:H,username:Se,port:Te})}catch(e){W(zi(e));return}await xr(e);return}K(!0),W(null);let e;try{e=Ri({host:ge,pairingCode:V})}catch(e){let t=e instanceof Error?e.message:`Failed to add backend.`;W(t),J.add(vt({type:`error`,title:`Could not add backend`,description:t})),K(!1);return}let t=await a({...e,...z?{expectedEnvironmentId:z.environmentId}:{}});if(t._tag===`Failure`){if(!je(t)){let e=Me(t),n=e instanceof Error?e.message:`Failed to add backend.`;W(n),J.add(vt({type:`error`,title:`Could not add backend`,description:n}))}K(!1)}else B(``),ve(``),xe(``),we(``),Ee(``),fe(!1),J.add(z?{type:`success`,title:`Route added`,description:`${z.label} now has another way to connect.`}:{type:`success`,title:`Backend added`,description:`The environment is saved and will reconnect on app startup.`}),K(!1)},[z,a,xr,ge,me,V,H,Te,Se]),Cr=(0,$.useCallback)(e=>{e.nativeEvent.isComposing||e.keyCode===229||e.key===`Enter`&&H.trim().length>0&&(e.preventDefault(),Sr())},[Sr,H]),Er=(0,$.useCallback)(async t=>{if(G||!e)return;K(!0),W(null),xe(t.alias);let n;try{n=await e.resolveSshHost(t.alias)}catch(e){W(zi(e)),K(!1);return}we(n.username??``),Ee(n.port===null?``:String(n.port)),await xr(n)},[xr,e,G]),Z=(0,$.useCallback)(e=>{if(e.nativeEvent.isComposing||e.keyCode===229)return;let n=U&&Wn;if(n){let n=Wt(e,t,{platform:navigator.platform,context:{modelPickerOpen:!1}}),r=Gt(n??``),i=r===null?void 0:Vn[r];if(i){e.preventDefault(),e.stopPropagation(),De(!1),Er(i);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation();return}}let r=n&&Oe.current!==void 0;!e.defaultPrevented&&!r&&e.key===`Enter`&&H.trim().length>0&&(e.preventDefault(),Sr())},[Vn,Sr,Er,Wn,t,H,U]),Or=(0,$.useCallback)(async(e,t)=>{W(null);let n=await d({environmentId:e,enabled:t});if(n._tag===`Failure`&&!je(n)){let e=Me(n),r=e instanceof Error?e.message:`Failed to switch the backend ${t?`on`:`off`}.`;W(r),J.add(vt({type:`error`,title:`Could not switch backend ${t?`on`:`off`}`,description:r}))}},[d]),Ar=(0,$.useCallback)(async e=>{let t=e.environmentId;Ie(t),W(null);let n=await s(t);if(Ie(null),n._tag===`Failure`&&!je(n)){let e=Me(n),t=e instanceof Error?e.message:`Failed to remove backend.`;W(t),J.add(vt({type:`error`,title:`Could not remove backend`,description:t}))}},[s]),[jr,Nr]=(0,$.useState)(null),Pr=(0,$.useCallback)(async e=>{e.relayManaged&&Pe()?Nr(e):await at(`Remove ${e.label} from this device?\nThis forgets its pairing, credentials, and cached threads here. Switch it off instead to keep it saved.`,{variant:`destructive`})===!0&&await Ar(e)},[Ar]),Ir=Zn,Lr=(0,$.useMemo)(()=>Kn.find(Yi)??null,[Kn]),Rr=(0,$.useMemo)(()=>rr?Kn.filter(e=>!Yi(e)):[],[Kn,rr]),zr=(0,$.useMemo)(()=>Lr?[...Rr,Lr]:Rr,[Lr,Rr]),Vr=(0,$.useMemo)(()=>Ji(Rr,Vt),[Vt,Rr]),Hr=(0,$.useMemo)(()=>Vr??Ji(Lr?[Lr]:[],Vt),[Vt,Vr,Lr]),Ur=Hr?Xi(Hr):null,Gr=(0,$.useCallback)(e=>{qt(Xi(e))},[qt]),Kr=(0,$.useCallback)(e=>{let t=Li(e);t?(B(t.host),ve(t.pairingCode)):B(e)},[]),Jr=e=>{let t=me===e.mode;return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,className:be(`group flex min-h-24 items-start gap-3 rounded-lg border p-4 text-left`,t?`border-primary/50 bg-primary/5`:`border-border/60 hover:bg-muted/40`),disabled:G,onClick:()=>{he(e.mode)},children:[e.icon?(0,Q.jsx)(`span`,{className:be(`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md border`,t?`border-primary/30 bg-primary/10 text-primary`:`border-border/70 bg-background text-muted-foreground group-hover:text-foreground`),children:e.icon}):null,(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:e.title}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-muted-foreground`,children:e.description})]})]})},Yr=()=>(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_10rem]`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Host`}),(0,Q.jsx)(Tt,{value:ge,onChange:e=>Kr(e.target.value),placeholder:`backend.example.com`,disabled:G,spellCheck:!1})]}),(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Pairing code`}),(0,Q.jsx)(Tt,{value:V,onChange:e=>ve(e.target.value),placeholder:`PAIRCODE`,disabled:G,spellCheck:!1})]})]}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(`span`,{className:`mt-1 block text-2xs text-muted-foreground`,children:`Paste a full pairing URL here to fill both fields automatically.`})})]}),Xr=z!==null&&!z.relayManaged&&u.environments.has(z.environmentId)?u.environments.get(z.environmentId).environment:null,Zr=async()=>{if(Xr===null||z===null)return;K(!0);let e=await l(new Fe({target:new Ae({environmentId:Xr.environmentId,label:z.label})}));if(K(!1),e._tag===`Failure`){if(!je(e)){let t=Me(e);W(t instanceof Error?t.message:`Could not add the route.`)}}else fe(!1),J.add({type:`success`,title:`Route added`,description:`${z.label} falls back to P4 Connect when its other routes are unreachable.`})},Qr=()=>(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[Xr===null?null:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border px-3 py-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This machine is on your P4 Connect account. Use it as a fallback route.`}),(0,Q.jsx)(L,{size:`xs`,variant:`outline`,disabled:G,onClick:()=>void Zr(),children:`Add P4 Connect`})]}),Yr(),ke?(0,Q.jsx)(`p`,{className:`text-xs text-destructive`,children:ke}):null,(0,Q.jsxs)(L,{variant:`outline`,className:`w-full`,disabled:G,onClick:()=>void Sr(),children:[(0,Q.jsx)(le,{className:`size-3.5`}),G?`Adding…`:z?`Add route`:`Add environment`]})]}),ei=()=>(0,Q.jsx)(`div`,{className:`space-y-4`,children:(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`block`,children:[(0,Q.jsx)(`label`,{htmlFor:`saved-backend-ssh-host`,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`SSH host or alias`}),(0,Q.jsxs)(Cn,{items:Vn,itemToStringValue:e=>e.alias,mode:`none`,openOnInputClick:!0,open:U,onOpenChange:De,onItemHighlighted:e=>{Oe.current=e},value:H,onValueChange:(e,t)=>{if(xe(e),t.reason!==`item-press`)return;let n=Vn.find(t=>t.alias===e);n&&Er(n)},children:[(0,Q.jsx)(Tn,{id:`saved-backend-ssh-host`,onKeyDown:Z,placeholder:`Search hosts or type devbox`,disabled:G,spellCheck:!1}),Wn?(0,Q.jsx)(En,{children:Hn?(0,Q.jsx)(`div`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:`Loading hosts…`}):Vn.length>0?(0,Q.jsx)(Sn,{className:`max-h-72`,children:Vn.map((e,n)=>{let r=Br(e),i=n<9?Ut(n):null,a=i?Kt(t,i,navigator.platform):null;return(0,Q.jsxs)(Dn,{value:e,className:`h-8 min-h-8 whitespace-nowrap`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium`,children:e.alias}),r===e.alias?(0,Q.jsx)(`span`,{className:`flex-1`}):(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:r}),a?(0,Q.jsx)(wn,{className:`shrink-0`,children:a}):null]},`${e.alias}:${e.hostname}:${e.port??``}`)})}):(0,Q.jsxs)(xn,{className:`break-all`,children:[`No hosts match "`,H.trim(),`".`]})}):null]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_7rem]`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Username`}),(0,Q.jsx)(Tt,{value:Se,onChange:e=>we(e.target.value),onKeyDown:Cr,placeholder:`root`,disabled:G,spellCheck:!1})]}),(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Port`}),(0,Q.jsx)(Tt,{value:Te,onChange:e=>Ee(e.target.value),onKeyDown:Cr,placeholder:`22`,inputMode:`numeric`,disabled:G,spellCheck:!1})]})]}),ke||Un?(0,Q.jsx)(un,{variant:`error`,children:(0,Q.jsx)(ln,{children:ke??Un})}):null,(0,Q.jsxs)(L,{variant:`outline`,className:`w-full`,disabled:G,onClick:()=>void Sr(),children:[(0,Q.jsx)(le,{className:`size-3.5`}),G?`Adding…`:z?`Add route`:`Add environment`]})]})}),ti=()=>(0,Q.jsx)(lr,{checked:Gn?.mode===`network-accessible`,disabled:!Gn||Re,onCheckedChange:e=>{wt(e?`network-accessible`:`local-only`),Ve(!0)},"aria-label":`Enable network access`}),ni=e=>zt?Rr.map(t=>{let n=Xi(t);return(0,Q.jsx)(aa,{endpoint:t,isDefault:n===Ur,presentation:e,onSetDefault:Gr,onSetupTailscaleServe:hr,onDisableTailscaleServe:_r,isUpdatingTailscaleServe:q},t.id)}):null,ri=(0,$.useCallback)(async t=>{if(e&&f!==null&&pt(f,`environment:maintain`)){Ge(!0),$e(null);try{await t(),$n()}catch(e){let t=e instanceof Error?e.message:`Failed to update WSL backend.`;$e(t),J.add(vt({type:`error`,title:`Could not change WSL backend`,description:t})),$n()}finally{Ge(!1)}}},[e,f]),ai=(0,$.useCallback)(()=>{$e(null),$n()},[]),si=(0,$.useMemo)(()=>n.some(e=>Ue(e.entry.target)),[n]),ci=(0,$.useCallback)(t=>{if(!e||!X)return;let n=X.distros.find(e=>e.isDefault)?.name??null;if(t===ji){if(!X.enabled&&!X.wslOnly)return;let t=X.wslOnly;if(si||t){rt({kind:`disable`,wasWslOnly:t});return}ri(()=>e.setWslBackendEnabled(!1));return}let r=t===Ai?null:t,i=r??n;X.enabled?(X.distro??n)!==i&&(si||X.wslOnly?rt({kind:`distro`,nextDistro:r}):ri(()=>e.setWslDistro(r))):rt({kind:`enable`,nextDistro:r})},[ri,e,X,si]),li=(0,$.useCallback)(t=>{if(!e||!Y||Y.kind!==`enable`)return;let n=Y.nextDistro;rt(null);let r=X?.distro??null;ri(()=>ir({bridge:e,mode:t,nextDistro:n,persistedDistro:r}))},[ri,e,X,Y]),ui=(0,$.useCallback)(t=>{e&&X&&X.wslOnly!==t&&rt({kind:`wsl-only`,nextValue:t})},[e,X]),di=(0,$.useCallback)(()=>{if(!e||!Y)return;let t=Y;t.kind!==`enable`&&(rt(null),t.kind===`disable`?ri(async()=>{let n=await e.setWslBackendEnabled(!1);return t.wasWslOnly?await e.setWslOnly(!1):n}):t.kind===`distro`?ri(()=>e.setWslDistro(t.nextDistro)):ri(()=>e.setWslOnly(t.nextValue)))},[ri,e,Y]),pi=()=>{if(!X)return sr({state:null,error:On})&&$t?(0,Q.jsx)(vn,{...Rn(`wsl-backend`),description:`Couldn't load the WSL backend state.`,status:(0,Q.jsx)(`span`,{className:`block text-destructive`,children:On}),control:(0,Q.jsx)(L,{size:`sm`,variant:`outline`,onClick:ai,disabled:An,children:An?`Retrying…`:`Retry`})}):null;if(!sr({state:X,error:On}))return null;if(!X.available)return(0,Q.jsx)(vn,{...Rn(`wsl-backend`),description:`WSL is unavailable, so Windows is running instead. Turn WSL off to clear this preference.`,status:On?(0,Q.jsx)(`span`,{className:`block text-destructive`,children:On}):null,control:(0,Q.jsx)(L,{size:`sm`,variant:`outline`,disabled:We,onClick:()=>ci(ji),children:`Switch to Windows`})});let e=X.distros.find(e=>e.isDefault)?.name??null,t=X.enabled?X.distro??e??Ai:ji,n=t===ji?`Off`:t===Ai?`Default distro`:t;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(vn,{...Rn(`wsl-backend`),description:`Run the selected WSL distro alongside Windows. Projects remain on their current filesystem.`,status:On?(0,Q.jsx)(`span`,{className:`block text-destructive`,children:On}):X.preflightError?(0,Q.jsxs)(`span`,{className:`block text-destructive`,children:[`WSL backend couldn't start: `,X.preflightError]}):null,control:(0,Q.jsxs)(Ze,{value:t,onValueChange:e=>{typeof e==`string`&&ci(e)},children:[(0,Q.jsx)(Xe,{size:`sm`,className:`w-full sm:w-56`,"aria-label":`WSL backend`,disabled:We,children:(0,Q.jsx)(Je,{children:n})}),(0,Q.jsxs)(Ye,{align:`end`,alignItemWithTrigger:!1,children:[(0,Q.jsx)(qe,{hideIndicator:!0,value:ji,children:`Off`}),X.distros.length===0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(qe,{hideIndicator:!0,value:Ai,children:`Default distro`}),X.distro===null?null:(0,Q.jsx)(qe,{hideIndicator:!0,value:X.distro,children:X.distro})]}):X.distros.map(e=>(0,Q.jsxs)(qe,{hideIndicator:!0,value:e.name,children:[e.name,e.isDefault?` (default)`:``]},e.name))]})]})}),X.enabled?(0,Q.jsx)(vn,{title:`WSL only`,description:`Run only the WSL backend. P4 Code restarts when this changes.`,className:`bg-muted/20 pl-7 sm:pl-8`,control:(0,Q.jsx)(lr,{checked:X.wslOnly,disabled:We,onCheckedChange:e=>ui(e),"aria-label":`Run WSL only`})}):null]})},mi=()=>(0,Q.jsx)(vn,{title:Rn(`tailscale-https`).title,description:Lr?Lr.status===`available`?Lr.httpBaseUrl:`Use Tailscale Serve to expose this backend through a MagicDNS HTTPS URL.`:`Start Tailscale to set up HTTPS access through MagicDNS.`,control:Lr?(0,Q.jsx)(lr,{checked:Lr.status===`available`,disabled:q,onCheckedChange:e=>{e?hr(Lr):_r(Lr)},"aria-label":`Enable Tailscale HTTPS`}):null}),hi=e=>(0,Q.jsxs)(Q.Fragment,{children:[Yn?(0,Q.jsx)(`div`,{className:Vi(e),children:(0,Q.jsx)(`p`,{className:`text-xs text-destructive`,children:Yn})}):null,(0,Q.jsx)(ia,{endpointUrl:Gn?.endpointUrl,endpoints:zr,defaultEndpointKey:Ur,presentation:e,isLoading:Xn,pairingLinks:Ir,createdPairingCredentials:ee,clientSessions:Qn,revokingPairingLinkId:re,revokingClientSessionId:ae,onRevokePairingLink:vr,onRevokeClientSession:yr,canRevoke:Yt})]}),gi=()=>(0,Q.jsx)(vn,{title:Rn(`network-access`).title,description:rr?(0,Q.jsx)(oa,{endpoint:Vr,hiddenEndpointCount:Math.max(Rr.length-1,0),expanded:zt,onToggleExpanded:()=>Bt(e=>!e),fallback:Gn?.endpointUrl?`Reachable at ${Gn.endpointUrl}`:Gn?.advertisedHost?`Exposed on all interfaces. Pairing links use ${Gn.advertisedHost}.`:`Exposed on all interfaces.`}):Gn?`Limited to this machine.`:`Loading…`,status:qn?(0,Q.jsx)(`span`,{className:`block text-destructive`,children:qn}):null,control:ti()}),_i=()=>(0,Q.jsx)(vn,{title:Rn(`network-access`).title,description:e?`This connection cannot view or change network exposure.`:g===`remote-reachable`?`Remote access is already configured. Change network exposure where the server starts.`:g===`loopback-browser`?`Only this machine can connect. Restart with a non-loopback host for remote pairing.`:`Network exposure information is unavailable.`,control:!e&&(g===`remote-reachable`||g===`loopback-browser`)?(0,Q.jsxs)(Ct,{children:[(0,Q.jsx)(xt,{render:(0,Q.jsx)(`span`,{className:`inline-flex`,children:(0,Q.jsx)(lr,{checked:rr,disabled:!0,"aria-label":`Enable network access`})})}),(0,Q.jsx)(St,{side:`top`,children:`Network exposure changes restart the backend and must be controlled where the server process is launched.`})]}):void 0}),vi=(0,Q.jsx)(Q.Fragment,{children:f===null?(0,Q.jsxs)(bn,{...Rn(`connections-environment`),children:[(0,Q.jsx)(vn,{title:`No environment selected`,description:`Connect an environment to view its settings and access.`}),(0,Q.jsx)(Mr,{}),Xt||Qt?(0,Q.jsx)(ba,{canReadRelay:Xt,canManageRelay:Qt}):null]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(bn,{...Rn(`connections-environment`),title:r?.label??(e?`This machine`:`Primary environment`),icon:(0,Q.jsx)(sn,{"aria-hidden":!0,kind:It?h(It):`desktop`,className:`size-4`}),headerAction:f===null?null:(0,Q.jsxs)(C,{children:[(0,Q.jsx)(M,{render:(0,Q.jsx)(L,{type:`button`,variant:`ghost-muted`,size:`icon-xs`,"aria-label":`More actions for this machine`}),children:(0,Q.jsx)(te,{className:`size-3.5`})}),(0,Q.jsx)(ue,{align:`end`,children:(0,Q.jsx)(Fr,{environmentId:f,serverConfig:It})})]}),children:[(0,Q.jsx)(Mr,{}),$t?(0,Q.jsx)(vn,{title:`Version`,description:Rt.status===`idle`?[It?.environment.serverVersion??null,r?.displayUrl??null].filter(e=>e!==null).join(` · `)||`Loading…`:(0,Q.jsx)(zn,{state:Rt}),control:Lt&&f!==null&&Rt.status!==`running`?(0,Q.jsx)(Tr,{size:`sm`,environmentId:f,serverLabel:r?`${r.label} server`:`server`,selfUpdate:tr(It),installation:It?.environment.capabilities.serverInstallation,desktopAppUpdate:Jn(It),threadContinuation:In(It),targetVersion:Lt.clientVersion,label:Rt.status===`failed`?`Retry update`:`Update to ${Lt.clientVersion}`}):Rt.status===`idle`&&It?(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Up to date`}):void 0}):null,$t&&e?(0,Q.jsxs)(Q.Fragment,{children:[gi(),ni(`endpoint-rail`),mi(),pi(),Xt||Qt?(0,Q.jsx)(ba,{canReadRelay:Xt,canManageRelay:Qt}):null]}):$t?(0,Q.jsxs)(Q.Fragment,{children:[_i(),Xt||Qt?(0,Q.jsx)(ba,{canReadRelay:Xt,canManageRelay:Qt}):null]}):null,r?(0,Q.jsxs)(`details`,{className:`group px-3 sm:px-4`,children:[(0,Q.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center gap-2 rounded-md text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring [&::-webkit-details-marker]:hidden`,children:[`Permissions`,(0,Q.jsx)(y,{"aria-hidden":!0,className:`size-3 text-muted-foreground group-open:rotate-90`})]}),(0,Q.jsx)(kr,{environmentId:r.environmentId,connected:r.connection.phase===`connected`})]}):null]}),Jt||Yt?(0,Q.jsx)(Dr,{id:`authorized-clients`,title:`Authorized clients`,summary:Wi(Qn,Ir),control:Yt?(0,Q.jsx)(ra,{delegatableScopes:m??[],onPairingLinkCreated:ne,clientSessions:Jt&&en.error===null&&en.data?.type===`snapshot`?Qn:null,isRevokingOtherClients:R,onRevokeOtherClients:br}):void 0,children:(0,Q.jsx)(Et,{scrollFade:!0,chainVerticalScroll:!0,className:`max-h-[22.5rem]`,"data-testid":`authorized-clients-scroll-area`,children:Jt?hi(`current`):(0,Q.jsx)(`p`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:`This connection can create access links but cannot view authorized clients.`})})}):null,(0,Q.jsx)(_n,{open:Be&&$t,onOpenChange:e=>{Re||Ve(e)},onOpenChangeComplete:e=>{e||wt(null)},children:(0,Q.jsxs)(mn,{children:[(0,Q.jsxs)(dn,{children:[(0,Q.jsx)(gn,{children:bt===`network-accessible`?`Enable network access?`:`Disable network access?`}),(0,Q.jsx)(hn,{children:bt===`network-accessible`?`Let your other devices connect to P4 Code over the network. Pair devices to give them access. P4 Code will restart.`:`Devices connected over your local network will disconnect. Existing tunnels, such as P4 Connect or Tailscale HTTPS, keep working. P4 Code will restart.`})]}),(0,Q.jsxs)(fn,{children:[(0,Q.jsx)(pn,{disabled:Re,render:(0,Q.jsx)(L,{variant:`outline`,disabled:Re}),children:(0,Q.jsx)(`span`,{className:`[text-box:trim-both_cap_alphabetic]`,children:`Cancel`})}),(0,Q.jsxs)(L,{variant:`default`,onClick:pr,disabled:!$t||bt===null||Re,children:[Re&&(0,Q.jsx)(Qe,{size:`sm`}),(0,Q.jsx)(`span`,{className:`[text-box:trim-both_cap_alphabetic]`,children:Re?`Restarting…`:bt===`network-accessible`?`Restart and enable`:`Restart and disable`})]})]})]})}),(0,Q.jsx)(_n,{open:it&&$t,onOpenChange:e=>{We||e||rt(null)},children:(0,Q.jsxs)(mn,{children:[(0,Q.jsxs)(dn,{children:[(0,Q.jsx)(gn,{children:Y?.kind===`disable`?Y.wasWslOnly?`Turn off WSL and switch back to Windows?`:`Disable WSL backend?`:Y?.kind===`distro`?`Switch WSL distro?`:Y?.kind===`enable`?`Start the WSL backend`:Y?.nextValue?`Run only the WSL backend?`:`Re-enable the Windows backend?`}),(0,Q.jsx)(hn,{children:Y?.kind===`disable`?Y.wasWslOnly?`P4 Code will restart on the Windows backend. Threads and projects opened against WSL stay safe inside the distro and become available again when you re-enable WSL.`:`The WSL backend will stop. Threads and projects opened against WSL stay safe inside the distro, but they'll be unavailable in P4 Code until you re-enable WSL.`:Y?.kind===`distro`?`P4 Code will restart the WSL backend on the new distro. Sessions still running on the current distro will be interrupted.`:Y?.kind===`enable`?`Run the WSL backend alongside the Windows one, or stop the Windows backend and use only WSL? You can change this later from Settings.`:Y?.nextValue?`P4 Code will restart and start only the WSL backend. Your Windows-side projects won't be accessible until you turn this off again.`:`P4 Code will restart and bring the Windows backend back up alongside WSL.`})]}),(0,Q.jsxs)(fn,{children:[(0,Q.jsx)(pn,{disabled:We,render:(0,Q.jsx)(L,{variant:`outline`,disabled:We}),children:`Cancel`}),Y?.kind===`enable`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(L,{variant:`outline`,onClick:()=>li(`wsl-only`),disabled:We||!$t,children:We?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qe,{size:`sm`}),`Applying…`]}):`Use only WSL`}),(0,Q.jsx)(L,{variant:`default`,onClick:()=>li(`both`),disabled:We||!$t,children:We?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qe,{size:`sm`}),`Applying…`]}):`Run both backends`})]}):(0,Q.jsx)(L,{variant:Y?.kind===`disable`||Y?.kind===`wsl-only`&&Y.nextValue?`destructive`:`default`,onClick:di,disabled:We||!$t,children:We?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qe,{size:`sm`}),`Applying…`]}):Y?.kind===`disable`?Y.wasWslOnly?`Switch to Windows`:`Disable WSL`:Y?.kind===`distro`?`Switch distro`:Y?.nextValue?`Restart and enable`:`Restart and disable`})]})]})}),(0,Q.jsx)(_n,{open:dt&&$t,onOpenChange:e=>{q||mt(e)},children:(0,Q.jsxs)(mn,{children:[(0,Q.jsxs)(dn,{children:[(0,Q.jsx)(gn,{children:`Disable Tailscale HTTPS?`}),(0,Q.jsx)(hn,{children:`P4 Code will restart the local backend without Tailscale Serve.`})]}),(0,Q.jsxs)(fn,{children:[(0,Q.jsx)(pn,{disabled:q,render:(0,Q.jsx)(L,{variant:`outline`,disabled:q}),children:`Cancel`}),(0,Q.jsx)(L,{variant:`destructive`,onClick:()=>void gr(),disabled:q||!$t,children:q?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qe,{size:`sm`}),`Restarting…`]}):`Restart and disable`})]})]})}),(0,Q.jsx)(Ft,{open:ot!==null,onOpenChange:e=>{q||e||st(null)},children:(0,Q.jsxs)(Pt,{className:`max-w-md`,children:[(0,Q.jsxs)(Dt,{children:[(0,Q.jsx)(Ot,{children:`Set up Tailscale HTTPS?`}),(0,Q.jsx)(Nt,{children:`P4 Code will restart the local backend with Tailscale Serve enabled and ask Tailscale to proxy HTTPS traffic to this backend.`})]}),(0,Q.jsxs)(Mt,{children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:`HTTPS port`}),(0,Q.jsx)(Tt,{className:`mt-2`,type:`number`,inputMode:`numeric`,min:1,max:65535,step:1,value:ht,onChange:e=>yt(e.target.value),disabled:q})]}),cr?null:(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:`Enter a port from 1 to 65535.`}),(0,Q.jsxs)(`div`,{className:`rounded-md border border-border/70 bg-muted/20 px-3 py-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`HTTPS endpoint`}),(0,Q.jsxs)(Ct,{children:[(0,Q.jsx)(xt,{render:(0,Q.jsx)(`p`,{className:`mt-1 truncate text-sm text-foreground`,children:ur??`Pending MagicDNS endpoint`})}),ur?(0,Q.jsx)(St,{side:`top`,children:ur}):null]})]})]}),(0,Q.jsxs)(kt,{children:[(0,Q.jsx)(jt,{disabled:q,render:(0,Q.jsx)(L,{variant:`outline`,disabled:q}),children:`Cancel`}),(0,Q.jsx)(L,{onClick:()=>void mr(),disabled:q||!cr,children:q?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qe,{size:`sm`}),`Restarting…`]}):`Enable`})]})]})})]})});return(0,Q.jsxs)(yn,{children:[vi,(0,Q.jsxs)(bn,{...Rn(`remote-environments`),title:`Environments`,headerAction:(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[E.length>0?(0,Q.jsx)(er,{targets:E,variant:`ghost-muted`}):null,(0,Q.jsxs)(Ft,{open:ce,onOpenChange:e=>{fe(e),e?pe(null):W(null)},children:[(0,Q.jsxs)(Ct,{children:[(0,Q.jsx)(xt,{render:(0,Q.jsx)(At,{render:(0,Q.jsxs)(L,{size:`xs`,variant:`ghost-muted`,"aria-label":`Add environment`,children:[(0,Q.jsx)(le,{className:`size-3`}),(0,Q.jsx)(`span`,{children:`Add environment`})]})})}),(0,Q.jsx)(St,{side:`top`,children:`Add environment`})]}),(0,Q.jsxs)(Pt,{className:`max-h-[80dvh] sm:max-w-3xl`,children:[(0,Q.jsxs)(Dt,{children:[(0,Q.jsx)(Ot,{children:z?`Add a route to ${z.label}`:`Add Environment`}),(0,Q.jsx)(Nt,{children:z?`Pair this machine again over another address, such as its Tailscale name. It joins the existing routes instead of adding a second machine.`:`Pair another environment to this client.`})]}),(0,Q.jsx)(Mt,{children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Jr({mode:`remote`,title:`Remote link`,description:`Enter a backend host and pairing code.`,icon:(0,Q.jsx)(c,{"aria-hidden":!0,className:`size-4`})}),e?Jr({mode:`ssh`,title:`SSH`,description:`Use local SSH config, agent, and tunnels for the backend.`,icon:(0,Q.jsx)(b,{"aria-hidden":!0,className:`size-4`})}):null]}),(0,Q.jsx)(Ht,{children:me===`ssh`?ei():Qr()})]})})]})]})]}),children:[x.map(e=>(0,Q.jsx)(ca,{environment:e,removingEnvironmentId:Ne,onSetEnabled:Or,onRemove:Pr,onAddRoute:e=>{pe(e),W(null),fe(!0)}},e.environmentId)),(0,Q.jsx)(Sa,{primaryEnvironmentId:f,savedEnvironments:v})]}),Pe()?(0,Q.jsx)(oi,{environmentLabel:jr?.label??null,onCancel:()=>Nr(null),onConfirm:()=>{jr&&(Nr(null),Ar(jr))}}):null,(0,Q.jsx)(qr,{}),i.map((e,t)=>(0,Q.jsx)(Wr,{environmentId:e.environmentId,environmentLabel:i.length>1?e.label:null,isSearchTarget:t===0},e.environmentId)),(0,Q.jsx)($r,{environments:D}),(0,Q.jsx)(ii,{environments:D})]})}function wa(e){let{kind:t}=e;J.add({type:`success`,title:t===`hosted-link`?`Hosted app link copied`:t===`link`?`Pairing URL copied`:`Pairing code copied`,description:t===`hosted-link`?`Open it in the browser on the device you want to connect.`:t===`link`?`Open it in the client you want to pair to this environment.`:`Paste it into another client to finish pairing.`})}function Ta(e){return $i(e)?`hosted-link`:`link`}function Ea(e){return!e}function Da(e){return e.currentTarget.select()}function Oa(e){return e.currentTarget.select()}function ka(e){return e!==null}var Aa=Ca;export{Aa as component};
2
+ //# sourceMappingURL=settings.connections-CHXX5kH0.js.map