@microvac/ui 0.1.0-rc.14 → 0.1.0-rc.15

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 (280) hide show
  1. package/dist/assets/{ActiveAgentsPanel-C9AP9hJu.js → ActiveAgentsPanel-BEx06tMt.js} +1 -1
  2. package/dist/assets/{AdapterManager-CmxTUKJH.js → AdapterManager-3kEEQWFJ.js} +1 -1
  3. package/dist/assets/{AdvancedToolsRoute-CXsQnTei.js → AdvancedToolsRoute-CgS6B-oh.js} +1 -1
  4. package/dist/assets/{AgentActionButtons-DWq2OuVK.js → AgentActionButtons-Cz3jCEd7.js} +1 -1
  5. package/dist/assets/{AgentAdvancedTab-dhBDxF-H.js → AgentAdvancedTab-BG6ZIAuN.js} +1 -1
  6. package/dist/assets/{AgentBulkSettingsSheet-DYT4ovDg.js → AgentBulkSettingsSheet-BrrbvspS.js} +1 -1
  7. package/dist/assets/{AgentChat-r0TPOfPK.js → AgentChat-Dw9iXD6H.js} +1 -1
  8. package/dist/assets/{AgentDetailPage-Bc_okBuS.js → AgentDetailPage-CuVIHv_q.js} +3 -3
  9. package/dist/assets/{AgentIdentityChip-CB2NBXkZ.js → AgentIdentityChip-BrVCcuHQ.js} +1 -1
  10. package/dist/assets/{AgentRosterFilters-b7qMLv8-.js → AgentRosterFilters-GQ2bdXfW.js} +2 -2
  11. package/dist/assets/{Agents-BsvXy3pZ.js → Agents-clrVQnvc.js} +2 -2
  12. package/dist/assets/{Agents.production-BeOZmzaF.js → Agents.production-DTopo7XB.js} +2 -2
  13. package/dist/assets/{AnimatedDialogContent-CWshmxP2.js → AnimatedDialogContent-CDLfw-dJ.js} +1 -1
  14. package/dist/assets/{AppDetail-DbqENTF_.js → AppDetail-BcWBg5yW.js} +1 -1
  15. package/dist/assets/{AppNotConnected-BhnCqL0F.js → AppNotConnected-NgfyHZ4L.js} +1 -1
  16. package/dist/assets/{ApprovalDetail-B2KiYLTj.js → ApprovalDetail-Dm_1V4tC.js} +1 -1
  17. package/dist/assets/{Approvals-j-wRmqKj.js → Approvals-i5AB3JPj.js} +1 -1
  18. package/dist/assets/{AppsConnect-CcPVEZ0C.js → AppsConnect-D660Tpuo.js} +1 -1
  19. package/dist/assets/{AppsReview-B8eWvKkS.js → AppsReview-DdTqOisY.js} +1 -1
  20. package/dist/assets/{ArtifactEmptyGraphic-5mdkS5jj.js → ArtifactEmptyGraphic-DzxCruYA.js} +1 -1
  21. package/dist/assets/{Artifacts-Bz7Oo6VX.js → Artifacts-CkXBz6nh.js} +1 -1
  22. package/dist/assets/{AssigneePickerInner-DdpF7hck.js → AssigneePickerInner-BNjyABBe.js} +1 -1
  23. package/dist/assets/{AssistantConnection-BpaaJDc_.js → AssistantConnection-CNF6mDmO.js} +1 -1
  24. package/dist/assets/{AttentionInlineVerbs-DlPQVCO-.js → AttentionInlineVerbs-BiyZ1ekZ.js} +1 -1
  25. package/dist/assets/{AttentionQueueRow-BC6ezctS.js → AttentionQueueRow-Bh0dKHpF.js} +1 -1
  26. package/dist/assets/{AuditHub-BVP7LKL9.js → AuditHub-BK848cb4.js} +1 -1
  27. package/dist/assets/{AuditRuns-DqizHgX1.js → AuditRuns-CUdlbP7S.js} +1 -1
  28. package/dist/assets/{Auth-DOF0snjp.js → Auth-DDqxm5gD.js} +1 -1
  29. package/dist/assets/{BoardChat-BYAbDtfd.js → BoardChat-fvKqk0R7.js} +1 -1
  30. package/dist/assets/{BoardClaim-7y41Pr8e.js → BoardClaim-BEC5BZfz.js} +1 -1
  31. package/dist/assets/{BootstrapSetupUxLab-BftH1vOv.js → BootstrapSetupUxLab-CXzErrin.js} +1 -1
  32. package/dist/assets/{Browse-Ck01W1Yl.js → Browse-DoovSMuF.js} +1 -1
  33. package/dist/assets/{BudgetPolicyCard-CKhrzfgy.js → BudgetPolicyCard-BYMlczCq.js} +1 -1
  34. package/dist/assets/{CaseDetail-qlXKJ66D.js → CaseDetail-UMAcSH_x.js} +1 -1
  35. package/dist/assets/{CaseStatus-B3RiZVDH.js → CaseStatus-BI0aMl9l.js} +1 -1
  36. package/dist/assets/{Cases-CFV3V-5X.js → Cases-CMTkGghU.js} +1 -1
  37. package/dist/assets/{ChatEndpointDetail-7Hi5TJNt.js → ChatEndpointDetail-CocNEInH.js} +1 -1
  38. package/dist/assets/{ChatEndpointSetup-CtwgH6sg.js → ChatEndpointSetup-Cyi2tI9K.js} +1 -1
  39. package/dist/assets/{ChatIdentityConfirm-CXjksBwX.js → ChatIdentityConfirm-Ba3JuTX1.js} +1 -1
  40. package/dist/assets/{CliAuth-KVjrGMfZ.js → CliAuth-D2jnueGH.js} +1 -1
  41. package/dist/assets/{Companies-oeJem3De.js → Companies-K75I9dJs.js} +1 -1
  42. package/dist/assets/{CompanyAccess-vWT6G-n_.js → CompanyAccess-Cw6nLUhE.js} +1 -1
  43. package/dist/assets/{CompanyActivity-zOzzeN1B.js → CompanyActivity-BsgmVpWS.js} +1 -1
  44. package/dist/assets/CompanyActivity.production-w-KGxvo6.js +1 -0
  45. package/dist/assets/{CompanyConnections-llSEaVa2.js → CompanyConnections-yRPYSdm7.js} +1 -1
  46. package/dist/assets/{CompanyEnvironments-DNyyGC_S.js → CompanyEnvironments-BA7kWdOJ.js} +1 -1
  47. package/dist/assets/{CompanyExport-CFa-F8Es.js → CompanyExport-DfsK4b9c.js} +1 -1
  48. package/dist/assets/{CompanyImport-DG6qwQ8F.js → CompanyImport-DJHAsmSF.js} +1 -1
  49. package/dist/assets/{CompanySettings-Dv5Z3ZQi.js → CompanySettings-DwzHGXec.js} +1 -1
  50. package/dist/assets/{CompanySettingsPluginPage-CZk1d_0d.js → CompanySettingsPluginPage-Bpa81PF3.js} +1 -1
  51. package/dist/assets/{CompanySkills-CdzWhJfQ.js → CompanySkills-eTqgbqQN.js} +1 -1
  52. package/dist/assets/{CompanySkills.production-IoCRW5FQ.js → CompanySkills.production-CQSWfH0r.js} +1 -1
  53. package/dist/assets/{ConfigureBuiltInAgentModal-BwW7XQ1O.js → ConfigureBuiltInAgentModal-DgeD7t_i.js} +1 -1
  54. package/dist/assets/{CopyableGatewayUrl-PTn061ft.js → CopyableGatewayUrl-B6K3rOal.js} +1 -1
  55. package/dist/assets/{CordisPluginSettings-C_BeeGEc.js → CordisPluginSettings-DD3AnD2G.js} +1 -1
  56. package/dist/assets/{Costs-DhuNxwSj.js → Costs-orBM8T-a.js} +1 -1
  57. package/dist/assets/{CrossIssueCollaborationUxLab-ZaAXq46r.js → CrossIssueCollaborationUxLab-Bv9y9-NE.js} +1 -1
  58. package/dist/assets/{Dashboard-BaDnqiKo.js → Dashboard-CrSBNKX1.js} +1 -1
  59. package/dist/assets/{DashboardLive-D-Ed7osd.js → DashboardLive-Cg8C9RiS.js} +1 -1
  60. package/dist/assets/{DecisionDateChips-D3pl_mLn.js → DecisionDateChips-BLZKZH71.js} +1 -1
  61. package/dist/assets/{DecisionHistoryPanel-D5MzyrOh.js → DecisionHistoryPanel-yK-CP7Qg.js} +1 -1
  62. package/dist/assets/{DecisionQueuePage-D3UZ9oRk.js → DecisionQueuePage-BKXbERai.js} +1 -1
  63. package/dist/assets/{DesignGuide-COTo7ICj.js → DesignGuide-2FswNsXz.js} +1 -1
  64. package/dist/assets/{DesignSandboxTaskThread-CMeCSQid.js → DesignSandboxTaskThread-CGU--FXR.js} +1 -1
  65. package/dist/assets/{EmailConnectionAccess-kCL7obSr.js → EmailConnectionAccess-CZ5QRKyg.js} +1 -1
  66. package/dist/assets/{EmailEndpointSetup-BGrksR_u.js → EmailEndpointSetup-BI2vsd8Y.js} +1 -1
  67. package/dist/assets/{EnforcementBanner-_Eb_nK3M.js → EnforcementBanner-B-iX466h.js} +1 -1
  68. package/dist/assets/{EntityRow-gpsOgEtu.js → EntityRow-BsICt6pd.js} +1 -1
  69. package/dist/assets/{ExecutionWorkspaceDetail-DwGkH6d3.js → ExecutionWorkspaceDetail-CMqR9puh.js} +1 -1
  70. package/dist/assets/{ExternalAgentInviteDialog-CGid6pM9.js → ExternalAgentInviteDialog-De30ZrLP.js} +1 -1
  71. package/dist/assets/{FilterBar-1D-VhrvG.js → FilterBar-rCmsTtG4.js} +1 -1
  72. package/dist/assets/{FolderControls-CQ6kef3c.js → FolderControls-CmnB7Ap-.js} +1 -1
  73. package/dist/assets/{GatewayDetail-CCqekM1J.js → GatewayDetail-Duw9pJ10.js} +1 -1
  74. package/dist/assets/{GatewaysList-nFsRcszh.js → GatewaysList-BBhVGhRq.js} +1 -1
  75. package/dist/assets/{GitHubConnectionRecovery-B9sFWJup.js → GitHubConnectionRecovery-6VshLoNV.js} +1 -1
  76. package/dist/assets/{GoalDetail-BQ8y55P-.js → GoalDetail-CahntjlI.js} +1 -1
  77. package/dist/assets/{GoalTree-laRjXp0P.js → GoalTree-CU4GBFCh.js} +1 -1
  78. package/dist/assets/{Goals-Cm14EaeP.js → Goals-CzM2NDFR.js} +1 -1
  79. package/dist/assets/{InstanceAccess-DxQ-Akt_.js → InstanceAccess-CZzkE65W.js} +1 -1
  80. package/dist/assets/{InstanceExperimentalSettings-BxwqbXNw.js → InstanceExperimentalSettings-DWumKtOK.js} +1 -1
  81. package/dist/assets/{InviteLanding-Cf0L_u6s.js → InviteLanding-BIy2z50u.js} +1 -1
  82. package/dist/assets/{IssueChatLongThreadPerf-BfsF6FdF.js → IssueChatLongThreadPerf-D4DJvdOG.js} +1 -1
  83. package/dist/assets/{JoinRequestQueue-BXCdTFG_.js → JoinRequestQueue-C5rauGYm.js} +1 -1
  84. package/dist/assets/{Layout.production-CqzU0qMi.js → Layout.production-BSDWnupa.js} +1 -1
  85. package/dist/assets/{McpConnect-COWnZ9Eb.js → McpConnect-BN8ST0RS.js} +1 -1
  86. package/dist/assets/{MembershipAction-C9i9Sdmi.js → MembershipAction-DTjhGn-L.js} +1 -1
  87. package/dist/assets/{MetricCard-Bwnt3_p3.js → MetricCard-CeL9Pdn5.js} +1 -1
  88. package/dist/assets/{MissingPluginTabPlaceholder-B0Zxv1Kx.js → MissingPluginTabPlaceholder-CbQiSVnZ.js} +1 -1
  89. package/dist/assets/{NewAgent-BIlJ5Dyt.js → NewAgent-BszrNpQk.js} +1 -1
  90. package/dist/assets/{NewAgentDialog-CJdMxxYL.js → NewAgentDialog-U9qAcTzc.js} +1 -1
  91. package/dist/assets/{NewGoalDialog-B8izfKLm.js → NewGoalDialog-DqKbk4-i.js} +1 -1
  92. package/dist/assets/{NewProjectDialog-DXqjTYFK.js → NewProjectDialog-DrlUAF-N.js} +1 -1
  93. package/dist/assets/{OnboardingPrimitives-DHYBqn_0.js → OnboardingPrimitives-BkgPF4Mu.js} +1 -1
  94. package/dist/assets/{OnboardingWizard-DqSfZ13V.js → OnboardingWizard-CMBMcuXv.js} +1 -1
  95. package/dist/assets/{OrgChart.production-DrSFUf7i.js → OrgChart.production-BLczTjRj.js} +1 -1
  96. package/dist/assets/{PaperclipCloudOAuthHandoff-jPUvjJ8q.js → PaperclipCloudOAuthHandoff-BTtF8UPD.js} +1 -1
  97. package/dist/assets/{PluginManager-h3LFPaUq.js → PluginManager-CCcqlfgK.js} +1 -1
  98. package/dist/assets/{PluginPage-E5Im4454.js → PluginPage-B1empV69.js} +1 -1
  99. package/dist/assets/{PluginSettings-BBO0jAgo.js → PluginSettings-DtopaRqR.js} +1 -1
  100. package/dist/assets/{ProfileDetailRoute-CQBD7fms.js → ProfileDetailRoute-BqvVpBZi.js} +1 -1
  101. package/dist/assets/{ProfileSettings-BwnVEHLp.js → ProfileSettings-5__tVfGi.js} +1 -1
  102. package/dist/assets/{ProfileWizardRoute-By_SC6Gn.js → ProfileWizardRoute-vt-MRLuD.js} +1 -1
  103. package/dist/assets/{ProjectDetail-CbiwFBAE.js → ProjectDetail-DJ4zjube.js} +1 -1
  104. package/dist/assets/{ProjectRepositoryInput-DZF9bX4E.js → ProjectRepositoryInput-BJcnj3At.js} +1 -1
  105. package/dist/assets/{ProjectWorkspaceDetail-DPsl_4bD.js → ProjectWorkspaceDetail-DEAO3q6v.js} +1 -1
  106. package/dist/assets/{ProjectWorkspacesContent-COH4dOWK.js → ProjectWorkspacesContent-CZvO7p0i.js} +1 -1
  107. package/dist/assets/{Projects-Ch9Qu7sn.js → Projects-Dm7-zXUH.js} +1 -1
  108. package/dist/assets/{QuotaBar-DIFOT9Uh.js → QuotaBar-Drp3CaxX.js} +1 -1
  109. package/dist/assets/{RepositoryEditor-DHB1bqId.js → RepositoryEditor-BT_VAkJu.js} +1 -1
  110. package/dist/assets/{Responsibilities-C5O0JXXG.js → Responsibilities-DbUEtGZu.js} +1 -1
  111. package/dist/assets/{ResponsibilityDetail-D6NpZpkm.js → ResponsibilityDetail--S8_GOkb.js} +1 -1
  112. package/dist/assets/{ResponsibleUserDenialUxLab-CFrIWYwe.js → ResponsibleUserDenialUxLab-1PB3JNG0.js} +1 -1
  113. package/dist/assets/{ReviewQueueCard-BPC4Lm67.js → ReviewQueueCard-B8w9aXKU.js} +1 -1
  114. package/dist/assets/{RoutineAuditActivity-sKyzMajz.js → RoutineAuditActivity-BCo7pYe5.js} +1 -1
  115. package/dist/assets/{RoutineDetail-CG8HF5fp.js → RoutineDetail-C9Dwn5G9.js} +1 -1
  116. package/dist/assets/{RoutineRunVariablesDialog-CKh3CmLD.js → RoutineRunVariablesDialog-Baomcbe3.js} +1 -1
  117. package/dist/assets/{Routines-tF2qfUKo.js → Routines-Dkv4gJno.js} +1 -1
  118. package/dist/assets/{Routines.production-BTyj1Ljr.js → Routines.production-Cs2Y-lpt.js} +1 -1
  119. package/dist/assets/{RoutinesToolbar-CvUFVCGN.js → RoutinesToolbar-BNKfCrTo.js} +1 -1
  120. package/dist/assets/{Search-Z9D0NuS1.js → Search-CVx4cl2o.js} +1 -1
  121. package/dist/assets/{Secrets-DgmbLOJK.js → Secrets-C2qv2HKZ.js} +1 -1
  122. package/dist/assets/{SkillBinaryFile-F3_9qcaM.js → SkillBinaryFile-DDkhLlfC.js} +1 -1
  123. package/dist/assets/{SkillCardIcon-CXHUCMej.js → SkillCardIcon-Cp_hws0N.js} +1 -1
  124. package/dist/assets/{SkillFolderTree-CB3lrTIE.js → SkillFolderTree-Cv0CmfYx.js} +1 -1
  125. package/dist/assets/{SkillSourceTree-BbuciCo6.js → SkillSourceTree-DmjlUswf.js} +1 -1
  126. package/dist/assets/{SkillSources-Dlo6Cew3.js → SkillSources-nmlYypUU.js} +1 -1
  127. package/dist/assets/{SkillStudio-ZO-Nf7eI.js → SkillStudio-BK3y_3zr.js} +1 -1
  128. package/dist/assets/{SkillsNavigationTabs-B9Iqnlqt.js → SkillsNavigationTabs-DRwMP1eu.js} +1 -1
  129. package/dist/assets/{SpekoPhoneCallback-C4VnMiZh.js → SpekoPhoneCallback-Cqi7AIyH.js} +1 -1
  130. package/dist/assets/{SpekoProviderSetup-I4evPZb3.js → SpekoProviderSetup-CJI4oXk5.js} +1 -1
  131. package/dist/assets/{StatusCards-D0MVzbsw.js → StatusCards-DKyyY81S.js} +1 -1
  132. package/dist/assets/{SummarySlotCard-DUXgZPxG.js → SummarySlotCard-f3RomdZS.js} +1 -1
  133. package/dist/assets/{TailscaleConnector-CMhT73gj.js → TailscaleConnector-yQWLR1Ra.js} +1 -1
  134. package/dist/assets/{TaskChatLab-D9-KAE-7.js → TaskChatLab-Dsr7eyj4.js} +1 -1
  135. package/dist/assets/{TaskSummaryList-CUxieFNe.js → TaskSummaryList-eFDfK_QH.js} +1 -1
  136. package/dist/assets/{Timeline-BNMoRbtK.js → Timeline-BWA9dyk6.js} +1 -1
  137. package/dist/assets/{ToolsAdminGate-CEr0zy2T.js → ToolsAdminGate-DpBg30hQ.js} +1 -1
  138. package/dist/assets/{TrustPresetSection-B9YXZtkh.js → TrustPresetSection-DtWjK9Kp.js} +1 -1
  139. package/dist/assets/{UserProfile-D-tnW96X.js → UserProfile-C66UI5xx.js} +1 -1
  140. package/dist/assets/{WebhookUrlWarning-Ba_DixKh.js → WebhookUrlWarning-CDygVnDH.js} +1 -1
  141. package/dist/assets/{WhatNeedsMe-B-Jzj8_M.js → WhatNeedsMe-BQ82RHus.js} +1 -1
  142. package/dist/assets/{Workspaces-BqhDI_Bl.js → Workspaces-DrjJes30.js} +1 -1
  143. package/dist/assets/{abnfDiagram-YUKMZFIV-Bn9P-nUW.js → abnfDiagram-YUKMZFIV-Crkksu2D.js} +1 -1
  144. package/dist/assets/{architecture-WOLXFQ4H-V1ldsZlt.js → architecture-WOLXFQ4H-bHU8FW0c.js} +1 -1
  145. package/dist/assets/{architectureDiagram-47P4ROYG-BkYxt-Gc.js → architectureDiagram-47P4ROYG-Bj5Styf9.js} +1 -1
  146. package/dist/assets/{arrow-down-left-o81ENfeW.js → arrow-down-left-Ck9VQyqQ.js} +1 -1
  147. package/dist/assets/{blockDiagram-E7TT5TSB-BO7pPYbp.js → blockDiagram-E7TT5TSB-OeHpNCQ-.js} +1 -1
  148. package/dist/assets/{budgets-0Dw6TH1A.js → budgets-CAWPqcn4.js} +1 -1
  149. package/dist/assets/{building-complex-DciZTnys.js → building-complex-Dxiyk_pH.js} +1 -1
  150. package/dist/assets/{c4Diagram-CRA5TL53-D4EpmmzV.js → c4Diagram-CRA5TL53-QbK5p76P.js} +1 -1
  151. package/dist/assets/channel-BSmZkKA8.js +1 -0
  152. package/dist/assets/{chat-channels-DWyry-9M.js → chat-channels-CzTZV2fr.js} +1 -1
  153. package/dist/assets/{chunk-2BW5OAIV-DFXIyCJy.js → chunk-2BW5OAIV-Ckr4HfBO.js} +1 -1
  154. package/dist/assets/{chunk-3YJQHVM4-Dj5wEKIw.js → chunk-3YJQHVM4-C_uoPpLR.js} +1 -1
  155. package/dist/assets/{chunk-4EA7E6EY-5XiUVgzK.js → chunk-4EA7E6EY-BeMEfIRS.js} +1 -1
  156. package/dist/assets/{chunk-7TKQ45FW-D0opKcsy.js → chunk-7TKQ45FW-DiwqWHvN.js} +1 -1
  157. package/dist/assets/{chunk-AW2ZBBNX-DnjsTe04.js → chunk-AW2ZBBNX-Cf57K3PO.js} +1 -1
  158. package/dist/assets/{chunk-DBDB3WZW-DNqSQPZ0.js → chunk-DBDB3WZW-B2qouVQO.js} +1 -1
  159. package/dist/assets/{chunk-E2ZNV5FY-cjSf_BTz.js → chunk-E2ZNV5FY-DG8wQ_NS.js} +1 -1
  160. package/dist/assets/{chunk-EU5HNXII-CZYBiaSw.js → chunk-EU5HNXII-cxRrXRGV.js} +1 -1
  161. package/dist/assets/{chunk-FVRAUYC3-DSc0-wJA.js → chunk-FVRAUYC3-Dizswk0V.js} +1 -1
  162. package/dist/assets/{chunk-HJ2JQQFS-MXK0gYSP.js → chunk-HJ2JQQFS-DL4lnpSv.js} +1 -1
  163. package/dist/assets/{chunk-HTAEGDNF-BjDZm_5k.js → chunk-HTAEGDNF-Zxjdb6kj.js} +1 -1
  164. package/dist/assets/{chunk-KQW6MTUR-Bfj0tDmO.js → chunk-KQW6MTUR-BsVaJdnu.js} +1 -1
  165. package/dist/assets/{chunk-NTY3LDVX-Bpz5TkVb.js → chunk-NTY3LDVX-DyT9N5sM.js} +1 -1
  166. package/dist/assets/{chunk-VPRB5NB3-CfeHjtbb.js → chunk-VPRB5NB3-BNz5CtBn.js} +1 -1
  167. package/dist/assets/{chunk-XC4XBNZT-FBCWmi6K.js → chunk-XC4XBNZT-CCgIhjYS.js} +1 -1
  168. package/dist/assets/{circle-slash-DqKFFqfb.js → circle-slash-uNv_ha0X.js} +1 -1
  169. package/dist/assets/{classDiagram-v2-K4WV4PDN-DbC_J0kK.js → classDiagram-v2-K4WV4PDN-Cdh3CEl4.js} +1 -1
  170. package/dist/assets/{coins-BztUbqyl.js → coins-BDAh8hDQ.js} +1 -1
  171. package/dist/assets/{collections-BxrcELwt.js → collections-B58p51lw.js} +1 -1
  172. package/dist/assets/{connection-owner-D-ikSHyR.js → connection-owner-D8fNrFqC.js} +1 -1
  173. package/dist/assets/{cynefin-EF2NZ3EQ-COwSJ4qP.js → cynefin-EF2NZ3EQ-BkwhfqJ0.js} +1 -1
  174. package/dist/assets/{cynefinDiagram-3GCD6N5R-diaEJq9Y.js → cynefinDiagram-3GCD6N5R-DuGb_wq2.js} +1 -1
  175. package/dist/assets/{dagre-W4DXFKR2-BPAMRuIj.js → dagre-W4DXFKR2-Bxq_Mhia.js} +1 -1
  176. package/dist/assets/{diagram-2UJZ2QOL-BvRnO1Id.js → diagram-2UJZ2QOL-B-P_hrXV.js} +1 -1
  177. package/dist/assets/{diagram-OVF4WLC6-CDgBeD0m.js → diagram-OVF4WLC6-Ds0BqQWH.js} +1 -1
  178. package/dist/assets/{diagram-PFPMY2P6-DAw9lREG.js → diagram-PFPMY2P6-Dpqb2-Cb.js} +1 -1
  179. package/dist/assets/{diagram-UMYRVEAY-ZQqQn22t.js → diagram-UMYRVEAY-BJSoxjiu.js} +1 -1
  180. package/dist/assets/{diagram-YEKJPTXX-CoJtGgWs.js → diagram-YEKJPTXX-BxaG_9tT.js} +1 -1
  181. package/dist/assets/{diagram-ZIFT7M5P-qW_Zn_bO.js → diagram-ZIFT7M5P-6acvVOtc.js} +1 -1
  182. package/dist/assets/{dist-B2E6oBK1.js → dist-0EWXio4m.js} +1 -1
  183. package/dist/assets/{dist-IcdxEhjC.js → dist-BGvZP_Cl.js} +1 -1
  184. package/dist/assets/{dist-DXjkgaZX.js → dist-BZ7AbEhN.js} +1 -1
  185. package/dist/assets/{dist-_EtfntKJ.js → dist-BlosHr86.js} +1 -1
  186. package/dist/assets/{dist-DylHAy-6.js → dist-Bmr4uhSk.js} +1 -1
  187. package/dist/assets/{dist-DML0cJH3.js → dist-C6yMfMNS.js} +1 -1
  188. package/dist/assets/{dist-Dl94YqeS.js → dist-CMZQedYl.js} +1 -1
  189. package/dist/assets/{dist-DKyBHaH2.js → dist-C_N_-eaT.js} +1 -1
  190. package/dist/assets/{dist-CvRpZH53.js → dist-CaUbG4Hl.js} +1 -1
  191. package/dist/assets/{dist-ptDa9fKh.js → dist-Cn7-nxjU.js} +1 -1
  192. package/dist/assets/{dist-CG-phytt.js → dist-Cnj95_pX.js} +1 -1
  193. package/dist/assets/{dist-DbXGl-wj.js → dist-D9DR7k9k.js} +1 -1
  194. package/dist/assets/{dist-CjRqeLFz.js → dist-DIwsVdS2.js} +1 -1
  195. package/dist/assets/{dist-BCJybC91.js → dist-DVE0lLId.js} +1 -1
  196. package/dist/assets/{dist-CPgRB-NQ.js → dist-DkAPL4CQ.js} +1 -1
  197. package/dist/assets/{dist-CeSzCyeG.js → dist-Dl6N3kpQ.js} +1 -1
  198. package/dist/assets/{dist-DZruZxAk.js → dist-DmBvXBzK.js} +1 -1
  199. package/dist/assets/{dist-CdmdXwCZ.js → dist-DpgXK0aZ.js} +1 -1
  200. package/dist/assets/{dist-CYRzGbSY.js → dist-gMRyU9GJ.js} +1 -1
  201. package/dist/assets/{dist-CG6fC1Db.js → dist-jQQX2kOU.js} +1 -1
  202. package/dist/assets/{dist-DZIxMHOT.js → dist-lUaUoFTq.js} +1 -1
  203. package/dist/assets/{dist-CuwPDbnL.js → dist-qw1ZF2vD.js} +1 -1
  204. package/dist/assets/{dist-B6Qde8KJ.js → dist-rH4qrNAn.js} +1 -1
  205. package/dist/assets/{ebnfDiagram-VR2GEFS7-DA4UvKXV.js → ebnfDiagram-VR2GEFS7-Ytj3Z5qC.js} +1 -1
  206. package/dist/assets/{elk-IJKZMXRS-CM74d3mJ.js → elk-IJKZMXRS-CJurNqqK.js} +1 -1
  207. package/dist/assets/{erDiagram-O2IAPWRE-d869V0qL.js → erDiagram-O2IAPWRE-hyXckW2d.js} +1 -1
  208. package/dist/assets/{eventmodeling-K75KTNOO-C-oz_eyI.js → eventmodeling-K75KTNOO-D3xQujrh.js} +1 -1
  209. package/dist/assets/flowDiagram-OXPTDLAJ-D4ojBTuY.js +1 -0
  210. package/dist/assets/{folder-plus-CxWXoYCi.js → folder-plus-BJZSMzuj.js} +1 -1
  211. package/dist/assets/{ganttDiagram-R7TSEDQI-BBul4Kpm.js → ganttDiagram-R7TSEDQI-C8U_ITl4.js} +1 -1
  212. package/dist/assets/{gitGraph-VSP46ZUC-BriEZgAq.js → gitGraph-VSP46ZUC-CDeq3yKT.js} +1 -1
  213. package/dist/assets/{gitGraphDiagram-XJZIOB7I-I12rg8s1.js → gitGraphDiagram-XJZIOB7I-CST3EWE9.js} +1 -1
  214. package/dist/assets/{goals-CvMWzjH4.js → goals-BNJZ4nzg.js} +1 -1
  215. package/dist/assets/{index-Bt31d8ga.js → index-BJtnP7H1.js} +8 -8
  216. package/dist/assets/{info-OHQRW6UA-CxrcGiem.js → info-OHQRW6UA-CPvTWk7J.js} +1 -1
  217. package/dist/assets/{infoDiagram-5W2HQ5XZ-4Sm0LiOu.js → infoDiagram-5W2HQ5XZ-BPUiNdxI.js} +1 -1
  218. package/dist/assets/{ishikawaDiagram-K3B6WC7H-CKXvKV-s.js → ishikawaDiagram-K3B6WC7H-D5Z3rmaA.js} +1 -1
  219. package/dist/assets/{issue-detail-4PCbYpdv.js → issue-detail-CZfjXs0M.js} +3 -3
  220. package/dist/assets/{journeyDiagram-COXZFDF6-BHsrZLvQ.js → journeyDiagram-COXZFDF6-CEkwEYdR.js} +1 -1
  221. package/dist/assets/{kanban-definition-P3RFRI5V-8HhnIs_l.js → kanban-definition-P3RFRI5V-8h_R6Qjq.js} +1 -1
  222. package/dist/assets/{line-rrKrpB-b.js → line-Ljt_vfsb.js} +1 -1
  223. package/dist/assets/{link-BecLzmfo.js → link-DvgFK0mz.js} +1 -1
  224. package/dist/assets/{list-filter-BC3D4IoX.js → list-filter-BR4_dvwm.js} +1 -1
  225. package/dist/assets/{log-in-BJCGwGGT.js → log-in-Dvx9-FMC.js} +1 -1
  226. package/dist/assets/{mcpSkills-DRs3pGKn.js → mcpSkills-76szK_k1.js} +1 -1
  227. package/dist/assets/{mermaid-parser.core-DmG0b4S0.js → mermaid-parser.core-BjFu937m.js} +3 -3
  228. package/dist/assets/{mermaid.core-D1vILTuF.js → mermaid.core-B0t95EIS.js} +4 -4
  229. package/dist/assets/{mindmap-definition-LZFPQGKD-DIMpL0de.js → mindmap-definition-LZFPQGKD-TVnHYUR4.js} +1 -1
  230. package/dist/assets/{packet-JDAUHWVQ-BnbYht3G.js → packet-JDAUHWVQ-aNGiRWLy.js} +1 -1
  231. package/dist/assets/{pegDiagram-BGZESJAR-BUjtJVjT.js → pegDiagram-BGZESJAR-DDadxqWQ.js} +1 -1
  232. package/dist/assets/{pie-XZMESJXO-CM4VXUb-.js → pie-XZMESJXO-CydFP1hd.js} +1 -1
  233. package/dist/assets/{pieDiagram-CAPJLFHJ-B3v8ryvG.js → pieDiagram-CAPJLFHJ-KhdUDwDS.js} +1 -1
  234. package/dist/assets/{power-0mw59G-l.js → power-sYV-WuqQ.js} +1 -1
  235. package/dist/assets/{profile-summary-B5rPf8v-.js → profile-summary-D4LPX-Dv.js} +1 -1
  236. package/dist/assets/{quadrantDiagram-GDMTTRAM-Cv-dS2Rn.js → quadrantDiagram-GDMTTRAM-B1X8K2Fs.js} +1 -1
  237. package/dist/assets/{radar-ABXABTNO-v6yZj4Fk.js → radar-ABXABTNO-BqodkLpx.js} +1 -1
  238. package/dist/assets/{railroad-I3PHUGI6-D-U8Cs0m.js → railroad-I3PHUGI6-HmRKXDJj.js} +1 -1
  239. package/dist/assets/{railroad-abnf-LNEFI6M7-Dw3fkrVy.js → railroad-abnf-LNEFI6M7-CkBttaHp.js} +1 -1
  240. package/dist/assets/{railroad-ebnf-DWYD2UWJ-_ln-e3Tx.js → railroad-ebnf-DWYD2UWJ-C6DBawFA.js} +1 -1
  241. package/dist/assets/{railroad-peg-JR7BVNR7-Bf8u1-RZ.js → railroad-peg-JR7BVNR7-Z9df3u5o.js} +1 -1
  242. package/dist/assets/{railroadDiagram-SM67HX2B-Drr5UhQI.js → railroadDiagram-SM67HX2B-2vDUUppL.js} +1 -1
  243. package/dist/assets/{requirementDiagram-X7JNWC4A-D5ef6_ac.js → requirementDiagram-X7JNWC4A-DAuP39Hc.js} +1 -1
  244. package/dist/assets/{sankeyDiagram-UM26HJRW-DncJWIz_.js → sankeyDiagram-UM26HJRW-ByS54QZK.js} +1 -1
  245. package/dist/assets/{saved-permissions-CizWg8-P.js → saved-permissions-CPiYtxkZ.js} +1 -1
  246. package/dist/assets/{scroll-text-Ck6HB7eM.js → scroll-text-CVSt6aO2.js} +1 -1
  247. package/dist/assets/{sdk-CWyUlmcn.js → sdk-vrG4HtB4.js} +1 -1
  248. package/dist/assets/{search-DkTqg7ab.js → search-CG-QtPVH.js} +1 -1
  249. package/dist/assets/{send-CYVi50sh.js → send-CH-0xdLm.js} +1 -1
  250. package/dist/assets/{sequenceDiagram-ZO4K6R2Y-Cs0nGCCg.js → sequenceDiagram-ZO4K6R2Y-DvWxKTLK.js} +1 -1
  251. package/dist/assets/{shared-CIwISWMj.js → shared-D37zfckm.js} +1 -1
  252. package/dist/assets/{smoke-lab-matrix-A7ubFpfk.js → smoke-lab-matrix-C5gR81E3.js} +1 -1
  253. package/dist/assets/{stateDiagram-v2-TBUQTH76-Dpp3m5Wq.js → stateDiagram-v2-TBUQTH76-DtiiZIXq.js} +1 -1
  254. package/dist/assets/{swimlanes-N4OXWK64-NXVbx1w8.js → swimlanes-N4OXWK64-BWSEtCbX.js} +1 -1
  255. package/dist/assets/swimlanesDiagram-K3J5GTZL-Bl_9DvHU.js +8 -0
  256. package/dist/assets/{timeline-definition-YOQAKGHF-DqI-Mv2e.js → timeline-definition-YOQAKGHF-U4QcniMh.js} +1 -1
  257. package/dist/assets/{treeView-D4JQ5SDB-CZBlE7ya.js → treeView-D4JQ5SDB-B2tdrtsj.js} +1 -1
  258. package/dist/assets/{treemap-SAJKECNS-BlueznID.js → treemap-SAJKECNS-DodN8j4n.js} +1 -1
  259. package/dist/assets/{useAgentlessOnboardingAutoOpen-CnFwEQ-H.js → useAgentlessOnboardingAutoOpen-DSWW7Juw.js} +1 -1
  260. package/dist/assets/{useAuthorizationWindow-DnFQsiFj.js → useAuthorizationWindow-tg3aKEU7.js} +1 -1
  261. package/dist/assets/{useDateRange-9EbqkWXy.js → useDateRange-CnZQr2KO.js} +1 -1
  262. package/dist/assets/{useFastResponsesEnabled-D8dunm4j.js → useFastResponsesEnabled-B8tHSJ1y.js} +1 -1
  263. package/dist/assets/{usePageView-BiX5i8ck.js → usePageView-CtFMs34g.js} +1 -1
  264. package/dist/assets/{useProfilesData-0VYQ4lAT.js → useProfilesData-CWHdMSuL.js} +1 -1
  265. package/dist/assets/{useReviewCount-WBWxwKI3.js → useReviewCount-W_bCZ2Hz.js} +1 -1
  266. package/dist/assets/{useRoutineFormOptions-DnX5DBn1.js → useRoutineFormOptions-CCLMmVSF.js} +1 -1
  267. package/dist/assets/{useSummaryDraftStream-DPQRvaXT.js → useSummaryDraftStream-NVNYNt72.js} +1 -1
  268. package/dist/assets/{useTailscaleConnections-BDff6dWx.js → useTailscaleConnections-Dy52nCY3.js} +1 -1
  269. package/dist/assets/{usecaseDiagram-VIAY4XPW-BSDn8OaJ.js → usecaseDiagram-VIAY4XPW-kEHhqgOj.js} +1 -1
  270. package/dist/assets/{vennDiagram-BLWOH2XV-BBSA9KNN.js → vennDiagram-BLWOH2XV-NPJU0aCU.js} +1 -1
  271. package/dist/assets/{wardley-7MLQ67FV-CsT-rTZ9.js → wardley-7MLQ67FV-bUGKvIPT.js} +1 -1
  272. package/dist/assets/{wardleyDiagram-YMQ3BMBF-BLClsIjw.js → wardleyDiagram-YMQ3BMBF-qtUDHfhb.js} +1 -1
  273. package/dist/assets/{xychartDiagram-TAQBALBS-2x4wB0gq.js → xychartDiagram-TAQBALBS-C-z57aZj.js} +1 -1
  274. package/dist/index.html +4 -4
  275. package/dist/sw.js +1 -1
  276. package/package.json +1 -1
  277. package/dist/assets/CompanyActivity.production-DbaFBsM0.js +0 -1
  278. package/dist/assets/channel-BQh2vFIU.js +0 -1
  279. package/dist/assets/flowDiagram-OXPTDLAJ-Be1xLbJu.js +0 -1
  280. package/dist/assets/swimlanesDiagram-K3J5GTZL-Ct3LnXZt.js +0 -8
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/runtime-IAg0vdY9.js","assets/model-DL5biheO.js"])))=>i.map(i=>d[i]);
2
- var vi=Object.defineProperty;var i=(t,d)=>vi(t,"name",{value:d,configurable:!0});import{a as bo}from"./rolldown-runtime-DhZMWcEn.js";import{en as kr,nn as xi,tn as gn}from"./issue-detail-4PCbYpdv.js";import{S as Ua}from"./collections-BxrcELwt.js";import{a as Ci,i as Si,n as _i,o as Ai,r as wi}from"./OnboardingPrimitives-DHYBqn_0.js";import{$A as Ei,$u as Ha,AA as Ii,Ar as Ri,BA as Xe,Cd as Ni,Cf as Li,Dd as Pn,Df as me,EA as zt,EC as Oi,Ed as za,Ef as ji,Ey as Ti,FA as ki,FD as Pi,GS as N,GT as Di,H_ as Mi,Hl as Va,IA as $t,ID as Ki,Id as Zn,JD as Pr,Jl as Fi,Ju as $a,KS as qi,Kd as Bi,Kv as Kt,LS as Ui,ME as Hi,MT as vo,Md as zi,Mr as Vi,NA as Qa,NE as Ne,Nd as $i,Nr as Qi,OA as Gi,Of as Yi,Pd as Wi,QO as Ji,Qp as Ga,Rf as Zi,Sd as Xi,Sf as es,Sl as ns,Sy as ts,Tc as rs,Td as Ya,Tf as as,US as os,Vb as is,Vl as ss,WD as ls,Xu as Wa,YD as Hr,Yb as cs,Yl as ds,Zp as Ft,_D as Ja,__ as zr,_d as Za,_f as Xa,_w as Dr,_y as us,aE as ps,ad as fs,al as ms,bd as Dn,bl as gs,cT as ys,cf as hs,ck as hn,dO as bs,dd as vs,ed as eo,fd as xs,fy as Cs,gD as Z,gd as Mr,gl as Ss,hE as _s,hd as As,id as ws,if as Es,jb as Is,jd as Rs,jr as no,kA as Ns,kd as to,ld as Ls,ly as Os,md as qt,my as js,nE as Ts,nb as ro,nd as yn,nj as ks,od as Ps,ol as Ds,op as ao,pE as oo,pd as Ms,pl as Ks,py as Fs,qp as qs,rb as z,rd as Bs,rw as Us,sE as io,sd as Hs,sl as zs,sy as xo,td as so,ub as Vs,ud as $s,ul as Bt,uy as Qs,vd as Gs,vf as Ys,wd as Ws,wf as Js,xE as ve,xd as Kr,xf as Zs,xl as Xs,yd as lo,yf as Ut,yl as el,zE as Xn}from"./index-Bt31d8ga.js";import{t as nl}from"./palette-tokens-CL5ZDrEd.js";import{n as Qt,r as tl}from"./onboarding-state-C5_mIw3o.js";var rl=["subscription","api_key"],al="openrouter/openai/gpt-6-luna";function co(t){const d=t?.trim();return d?d.startsWith("openrouter/")?d:`openrouter/${d}`:al}i(co,"resolveCloudTrialModel");var Vl=$t({connectionId:Xe().uuid(),grantId:Xe().uuid(),provider:zt(bs),method:zt(rl),ownership:zt(["personal","shared"]).default("personal"),model:Xe().trim().min(1).max(200).optional(),agentIds:Gi(Xe().uuid()).max(200).optional(),resumeBlockedWork:Ns().default(!0)}).strict(),$l=Ii("event",[$t({event:Qa("onboarding_exposure"),surface:zt(["onboarding_wizard","onboarding_seed"]).default("onboarding_wizard")}).strict(),$t({event:Qa("modal_shown"),trialAgentCount:ki().int().nonnegative().max(1e3)}).strict()]),Ql=$t({adapterType:Xe().trim().min(1).max(100).optional(),runnerProvider:Xe().trim().min(1).max(100).optional(),acpxAgent:Xe().trim().min(1).max(100).optional(),model:Xe().trim().min(1).max(200).optional()}).strict(),ol=12e4;function Fr(t){return t.status==="fail"?!0:t.checks.some(d=>d.code===Ji)}i(Fr,"blocksAgentCreate");async function il(t){const d=new AbortController;let b;const g=new Promise((y,x)=>{b=setTimeout(()=>{const m=new Error("The connection test took too long. Try connecting again.");x(m),d.abort(m)},ol)});try{return await Promise.race([t(d.signal),g])}finally{clearTimeout(b)}}i(il,"runOnboardingConnectionTest");var o=bo(ks(),1),n=bo(Ei(),1);function sl({companyId:t,agentId:d,environmentId:b,adapterType:g,disabled:y,className:x,onComplete:m}){const[k,D]=(0,o.useState)(!1);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(Ne,{type:"button",variant:"ghost",className:x,disabled:y,onClick:i(()=>D(!0),"onClick"),children:"Use a custom gateway"}),(0,n.jsx)(xo,{open:k,onOpenChange:D,children:(0,n.jsxs)(Os,{className:"max-h-(--sz-85vh) overflow-y-auto sm:max-w-2xl",onKeyDown:i(_=>_.stopPropagation(),"onKeyDown"),children:[(0,n.jsxs)(Cs,{children:[(0,n.jsx)(js,{children:"Custom gateway connection"}),(0,n.jsx)(Qs,{children:"Save the connection, then choose a model and test it with your agent."})]}),(0,n.jsx)(rs,{companyId:t,agentId:d,environmentId:b,initialProvider:"gateway",initialProtocol:g==="codex_local"?"responses":"messages",submitLabel:"Save connection",onCancel:i(()=>D(!1),"onCancel"),onComplete:i(_=>{D(!1),m(_)},"onComplete")})]})})]})}i(sl,"OnboardingGatewaySetup");var qr="sleepy",Br="idle";function ll(t){const d=t.animations.map(x=>x.id),b=t.animations.find(x=>!x.loop)?.id,g=d.includes(qr)?qr:void 0,y=d.includes(Br)?Br:void 0;if(!b||!g||!y)throw new Error(`Onboarding character export needs a looping "${qr}", a looping "${Br}" and one non-looping wake animation; found: ${d.join(", ")||"none"}`);return{asleep:g,wake:b,awake:y}}i(ll,"resolveOnboardingSequences");function cl(t,d){const b=t.animations.find(g=>g.id===d);return b?b.steps.reduce((g,y)=>g+(Number.isFinite(y.duration)?Math.max(.2,y.duration):1),0)/(Number.isFinite(t.character.speed)&&t.character.speed>0?t.character.speed:1):0}i(cl,"sequenceDuration");function Ur(t,d){const b=t.animations.find(V=>V.id===d),g=b?.steps[0],y=g&&t.expressions.find(V=>V.id===g.expressionId),x=y?.beats[0];if(!b||!g||!y||!x)return 0;const m=i(V=>Number.isFinite(V)?Math.max(.2,V):1,"safe"),k=y.beats.reduce((V,se)=>V+m(se.duration),0),D=Math.min(.45,m(x.duration)*.4),_=Number.isFinite(t.character.speed)&&t.character.speed>0?t.character.speed:1;return D*m(g.duration)/k/_}i(Ur,"sequenceLeadIn");function uo(t,d,b){const g=b?"muted-dream":d.paletteId,y=nl[g];return{...t,character:{...t.character,color:y.a,color2:y.b}}}i(uo,"colorOnboardingDefinition");function dl({appearance:t,awake:d,className:b}){const g=Hr(t),y=(0,o.useRef)(null),x=(0,o.useRef)(null),m=(0,o.useRef)({base:null,overlay:null}),k=(0,o.useRef)(null),D=(0,o.useRef)(d?"awake":"asleep"),_=(0,o.useRef)(null),V=(0,o.useRef)([]),[se,xe]=(0,o.useState)(!1),[De,Ce]=(0,o.useState)(!1),[Yt,Mn]=(0,o.useState)(d),[C,en]=(0,o.useState)(0),Le=i(()=>{for(const I of V.current)window.clearTimeout(I);V.current=[]},"clearTimers"),X=i(I=>{m.current[I]?.destroy(),m.current[I]=null},"destroy"),Me=i(()=>{Le(),X("overlay"),X("base"),xe(!1),Ce(!0)},"fail"),Kn=i(()=>typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,"reducedMotion"),l={followCursor:!1,followRotation:!0,trackingScope:"page",displaySize:160};function B(I){const F=k.current;if(!F||!y.current||!x.current)return;Le(),X("overlay"),X("base");const Se=I==="asleep"?F.sequences.asleep:F.sequences.awake,le=Ur(F.definition,Se),M=F.create(y.current,uo(F.definition,g,I==="asleep"),{animation:Se,...l,onError:Me});if(m.current.base=M,M.seek(le),m.current.base===M){if(I==="asleep"){const $=F.create(x.current,uo(F.definition,g,!1),{animation:Se,...l,onError:Me});if(m.current.overlay=$,$.seek(le),m.current.overlay!==$)return}D.current=I,_.current=g.paletteId,Mn(I==="awake")}}i(B,"mount");function Ke(){const I=k.current,F=m.current.base,Se=m.current.overlay;if(!I||!F||!Se||Kn()){B("awake");return}Le();const le=Ur(I.definition,I.sequences.wake),M=Math.max(0,cl(I.definition,I.sequences.wake)-le);en(M);for(const $ of[F,Se]){if($.setAnimation(I.sequences.wake),m.current.base!==F||($.seek(le),m.current.base!==F))return;$.play()}D.current="awake",V.current.push(window.setTimeout(()=>Mn(!0),0)),V.current.push(window.setTimeout(()=>{X("base"),m.current.base=m.current.overlay,m.current.overlay=null,m.current.base?.setAnimation(I.sequences.awake),m.current.base?.seek(Ur(I.definition,I.sequences.awake))},Math.ceil(M*1e3)+50))}i(Ke,"wake"),(0,o.useEffect)(()=>{if(typeof IntersectionObserver!="function"||typeof ResizeObserver!="function"||typeof WebGLRenderingContext>"u"){Ce(!0);return}let I=!1;return xe(!1),Promise.all([io(()=>import("./runtime-IAg0vdY9.js"),__vite__mapDeps([0,1])),io(()=>import("./character-CguPM7IG.js"),[])]).then(([F,Se])=>{if(I)return;const le=Se.PAPERCLIP_CHARACTER;k.current={create:F.createCharacter,definition:le,sequences:ll(le)},B(D.current),m.current.base&&xe(!0)}).catch(F=>{I||Me()}),()=>{I=!0,Le(),X("overlay"),X("base"),k.current=null,xe(!1)}},[]),(0,o.useEffect)(()=>{if(!(!se||!k.current||_.current===g.paletteId))try{B(D.current)}catch{Me()}},[g.paletteId,se]),(0,o.useEffect)(()=>{if(!se||!k.current||!m.current.base)return;const I=d?"awake":"asleep";if(I!==D.current)try{I==="awake"?Ke():B("asleep")}catch{Me()}},[d,se]);const Wt=se&&!De;return(0,n.jsxs)("span",{className:Xn("relative inline-block",b),"aria-hidden":"true",children:[(0,n.jsx)(Is,{appearance:g,size:256,pose:d?"rest":"sleepy",muted:!d,className:Xn("size-full",Wt&&"invisible")}),(0,n.jsx)("span",{ref:y,className:"absolute inset-0"}),(0,n.jsx)("span",{ref:x,className:"absolute inset-0 transition-opacity ease-linear motion-reduce:transition-none",style:{opacity:Yt?1:0,transitionDuration:`${Math.max(0,C)}s`}})]})}i(dl,"OnboardingCharacter");var ul=["Create your first agent","Connect a model","Review"],Vr=[3,4,5],Vt=[1,3,4,5],pl=["Name your organization","Create your first agent","Connect a model","Review"];function fl(t){return Vt.filter(d=>d<=t).length}i(fl,"onboardingStepPositionFor");function po(t){const d=Vr.indexOf(t);return d===-1?null:d+1}i(po,"agentArcStepFor");function fo({step:t,total:d=3,labels:b=ul,canJumpToStep:g,onJumpToStep:y}){return(0,n.jsxs)("div",{className:"mb-11 flex items-center justify-center",children:[Array.from({length:d},(x,m)=>m+1).map(x=>{const m=!!(g?.(x)&&y);return(0,n.jsx)("button",{type:"button","aria-label":b[x-1]??`Step ${x}`,"aria-current":x===t?"step":void 0,disabled:!m,onClick:i(()=>m&&y?.(x),"onClick"),className:Xn("grid h-1.5 w-3.5 shrink-0 place-items-center rounded-full",m?"cursor-pointer":"cursor-default"),children:(0,n.jsx)("span",{"aria-hidden":"true",className:Xn("size-1.5 rounded-full transition-colors",x<=t?"bg-foreground":"bg-border")})},x)}),(0,n.jsxs)("span",{className:"sr-only",children:["Step ",t," of ",d]})]})}i(fo,"Stepper");function ml({agentName:t,agentRole:d}){const b=!!(t||d);return(0,n.jsx)(me.div,{className:"overflow-hidden",initial:!1,animate:{height:b?"auto":0},transition:{duration:Mr,ease:lo},children:(0,n.jsxs)(me.div,{className:"mt-1 flex flex-col items-center gap-1",initial:!1,animate:{opacity:b?1:0},transition:{duration:Mr,ease:lo,delay:b?Mr*.25:0},children:[(0,n.jsx)("span",{className:"flex h-6 items-center text-base font-semibold tracking-tight text-foreground",children:t||" "}),(0,n.jsx)("span",{className:"flex h-4 items-center text-xs text-muted-foreground",children:d||" "})]})})}i(ml,"AgentPreview");var Co="(min-width: 40rem)";function gl(t){const d=window.matchMedia?.(Co);return d?.addEventListener("change",t),()=>d?.removeEventListener("change",t)}i(gl,"subscribeToViewport");function yl(){return(0,o.useSyncExternalStore)(gl,()=>window.matchMedia?.(Co).matches===!1,()=>!1)}i(yl,"useMobileOnboardingViewport");function hl({destination:t,onDismiss:d}){const b=(0,o.useId)(),g=(0,o.useId)(),y=(0,o.useId)(),x=(0,o.useRef)(null),m=(0,o.useRef)(null),[k,D]=(0,o.useState)(!1),[_,V]=(0,o.useState)("idle");(0,o.useEffect)(()=>{k&&m.current?.scrollIntoView({block:"nearest"})},[k]);async function se(){try{await qs(t),V("copied")}catch{V("manual"),x.current?.focus(),x.current?.select()}}return i(se,"copyLink"),(0,n.jsxs)("section",{"aria-labelledby":b,className:"flex flex-col gap-3 rounded-lg border bg-muted/40 p-3 text-left sm:hidden",children:[(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)(Us,{className:"size-5 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,n.jsxs)("div",{className:"flex min-w-0 flex-col gap-1",children:[(0,n.jsx)("h2",{id:b,className:"text-sm font-medium text-foreground",children:"Setup is easier on desktop"}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Especially if you need to sign in or paste a key."})]})]}),(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-1",children:[(0,n.jsx)(Ne,{type:"button",variant:"outline",className:"h-(--sz-44px) px-2","aria-controls":g,"aria-expanded":k,onClick:i(()=>D(xe=>!xe),"onClick"),children:"Continue on desktop"}),(0,n.jsx)(Ne,{type:"button",variant:"ghost",className:"h-(--sz-44px) px-2",onClick:d,children:"Keep going here"})]}),(0,n.jsx)("div",{id:g,ref:m,hidden:!k,children:k&&(0,n.jsxs)("div",{className:"flex flex-col gap-2 border-t pt-3",children:[(0,n.jsx)("label",{htmlFor:y,className:"text-sm text-muted-foreground",children:"Open this link on your computer and sign in with the same account. You may need to re-enter setup choices."}),(0,n.jsx)(zr,{id:y,ref:x,readOnly:!0,value:t,"aria-label":"Desktop setup link",className:"text-base",onFocus:i(xe=>xe.currentTarget.select(),"onFocus")}),(0,n.jsxs)(Ne,{type:"button",variant:"outline",className:"h-(--sz-44px) self-start",onClick:i(()=>{se()},"onClick"),children:[_==="copied"?(0,n.jsx)(vo,{"aria-hidden":"true"}):(0,n.jsx)(ys,{"aria-hidden":"true"}),_==="copied"?"Link copied":"Copy setup link"]}),(0,n.jsx)("span",{role:"status",className:"sr-only",children:_==="copied"?"Desktop setup link copied.":""}),_==="manual"&&(0,n.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Automatic copy is unavailable. Copy the selected link manually."})]})})]})}i(hl,"MobileDesktopNudge");function mo(t){if(!t)return null;try{const d=new URL(t);return d.username||d.password||d.pathname!=="/"||d.search||d.hash?null:d}catch{return null}}i(mo,"parseOrigin");function bl(t){const d=t.hostname.replace(/\.$/,"");return d==="localhost"||d.endsWith(".localhost")||/^127\.[\d.]+$/.test(d)||d==="[::1]"}i(bl,"isLoopback");function vl(t,d){const b=us(t.cloudBaseUrl,"/"),g=b?new URL(b).origin:null,y=i(k=>k?.protocol==="https:"&&!bl(k)&&k.origin!==g,"usableTenantOrigin"),x=mo(t.runtimeIdentity?.canonicalOrigin);if(x&&y(x))return new URL("/onboarding",x).href;const m=mo(d);return m&&y(m)?new URL("/onboarding",m).href:null}i(vl,"cloudDesktopOnboardingUrl");var xl="general",Cl="Chief of staff",Gl=new Set([Cl,...Object.values(hn)]);function Sl(t){return t.setupError?{label:"Retry",icon:"arrow",disabled:!1}:t.retryLogin?{label:"Retry sign-in",icon:"arrow",disabled:!1}:t.localLoginAction?.kind==="connecting"||t.connectPhase==="connecting"?{label:"Connecting…",icon:"spinner",disabled:!0}:t.passiveSubscriptionFooter?{label:"Next",icon:"arrow",disabled:!0}:t.connectProgress?{label:t.adapterEnvLoading?"Testing…":t.connectProgress,icon:"spinner",disabled:!0}:(t.connectPhase==="ready"||t.connectPhase==="waiting")&&t.hasSubmitLoginCode?{label:"Submit code",icon:"arrow",disabled:!1}:t.connectPhase==="waiting"?{label:t.adapterType==="codex_local"?"Waiting for auth…":"Waiting for code…",icon:"spinner",disabled:!0}:t.connectPhase!=="ready"?{label:"Next",icon:"arrow",disabled:!0}:t.connectStepNeedsLogin?{label:`Sign in to ${t.connectSourceLabel}`,icon:"none",disabled:!t.connectAuthUrl}:t.localLoginAction?{label:t.localLoginAction.label,icon:t.localLoginAction.icon,disabled:t.localLoginAction.disabled}:{label:"Connect",icon:"arrow",disabled:t.connectDisabled}}i(Sl,"resolveOnboardingConnectCta");var Ht=new Set(["claude_local","codex_local"]);function _l(t,d,b){return t==="paperclip_runner"&&d==="pi"?"pi_local":t==="paperclip_runner"&&d==="opencode"?"opencode_local":t==="paperclip_runner"&&b!==!0&&(d===void 0||d==="codex")?"codex_local":typeof t=="string"&&t!=="paperclip_runner"?t:"claude_local"}i(_l,"restoreOnboardingAdapterType");function Gt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}i(Gt,"isEnvRecord");var So="ANTHROPIC_API_KEY";function Al(t){if(!Gt(t.env))return!1;const d=t.env[So];return typeof d=="string"?d.trim().length>0:Gt(d)?d.type==="plain"?typeof d.value=="string"&&d.value.trim().length>0:d.type==="secret_ref"||d.type==="user_secret_ref":!1}i(Al,"adapterConfigHasAnthropicApiKey");var wl={claude_local:"/brands/claude-color.svg"};function El({className:t}){return(0,n.jsx)("svg",{viewBox:"114 114 488 488",className:t,fill:"none","aria-hidden":!0,children:(0,n.jsx)("path",{fill:"currentColor",d:"M508.749 317.399C516.777 287.314 508.991 253.884 485.389 230.282C461.788 206.681 428.36 198.895 398.273 206.923C376.231 184.928 343.39 174.956 311.148 183.596C278.906 192.234 255.45 217.292 247.36 247.361C217.291 255.451 192.233 278.91 183.595 311.149C174.957 343.391 184.927 376.232 206.924 398.274C198.896 428.359 206.683 461.789 230.284 485.391C253.885 508.992 287.313 516.779 317.401 508.75C339.442 530.745 372.286 540.717 404.525 532.079C436.767 523.441 460.223 498.384 468.313 468.315C498.383 460.224 523.44 436.766 532.078 404.526C540.716 372.285 530.747 339.443 508.749 317.402V317.399ZM470.899 244.776C486.892 260.77 493.488 282.601 490.687 303.412L415.577 260.046C412.411 258.218 408.509 258.218 405.345 260.046L317.401 310.82V277.526C317.401 275.191 318.652 273.005 320.676 271.837L387.644 233.174C414.178 218.353 448.346 222.223 470.901 244.776H470.899ZM357.837 311.144L398.275 334.491V381.185L357.837 404.532L317.398 381.185V334.491L357.837 311.144ZM264.776 269.693C265.207 239.305 285.644 211.649 316.453 203.393C338.3 197.54 360.505 202.744 377.127 215.573L302.014 258.937C298.848 260.764 296.898 264.144 296.898 267.798V369.346L268.065 352.699C266.043 351.531 264.776 349.353 264.776 347.017V269.691V269.693ZM203.391 316.454C209.244 294.608 224.854 277.978 244.276 269.999V356.73C244.276 360.384 246.226 363.763 249.392 365.591L337.337 416.365L308.503 433.013C306.481 434.181 303.961 434.188 301.939 433.02L234.971 394.357C208.868 378.789 195.138 347.261 203.391 316.454ZM244.775 470.9C228.781 454.906 222.186 433.075 224.986 412.264L300.096 455.63C303.263 457.457 307.164 457.457 310.328 455.63L398.273 404.856V438.149C398.273 440.485 397.022 442.671 394.997 443.839L328.029 482.502C301.495 497.322 267.327 493.452 244.772 470.9H244.775ZM450.897 445.982C450.466 476.371 430.029 504.027 399.22 512.283C377.373 518.136 355.168 512.932 338.547 500.102L413.659 456.738C416.826 454.911 418.775 451.532 418.775 447.877V346.329L447.609 362.977C449.631 364.145 450.897 366.323 450.897 368.659V445.985V445.982ZM512.282 399.221C506.429 421.068 490.819 437.697 471.397 445.676V358.946C471.397 355.292 469.448 351.912 466.281 350.085L378.336 299.311L407.17 282.663C409.192 281.495 411.712 281.487 413.734 282.655L480.702 321.318C506.805 336.887 520.536 368.415 512.282 399.221Z"})})}i(El,"OpenAiBlossom");var Il={codex_local:El},Rl={claude_local:So,codex_local:"OPENAI_API_KEY"};function fe(t){return Rl[t]??"API_KEY"}i(fe,"apiKeyEnvKeyFor");function go({type:t,Fallback:d}){const b=Il[t];if(b)return(0,n.jsx)(b,{className:"size-full"});const g=wl[t];return g?(0,n.jsx)("img",{src:g,alt:"",className:"size-full"}):(0,n.jsx)(d,{className:"size-full"})}i(go,"ModelSourceMark");var yo="Onboarding state is incomplete. Please restart onboarding and try again.";function Yl(){const t=(0,o.useMemo)(()=>{const D=Qt.read();if(D)try{return JSON.parse(D)}catch{return null}},[]),[d,b]=(0,o.useState)(t==null),g=os({staleTime:0,enabled:t!=null}),y=g.isSuccess&&g.data!==void 0&&!g.data.unauthorized,{saved:x,staleStateDetected:m}=(0,o.useMemo)(()=>{if(t===void 0)return{saved:null,staleStateDetected:!1};if(t===null)return{saved:null,staleStateDetected:!0};if(!y)return{saved:null,staleStateDetected:!1};const D=tl(t,g.data.companies);return{saved:D,staleStateDetected:D===null}},[t,y,g.data]);(0,o.useEffect)(()=>{m&&Qt.clear()},[m]);const k=!d&&t!==void 0&&g.isFetching;return(0,o.useEffect)(()=>{!d&&y&&!g.isFetching&&b(!0)},[d,y,g.isFetching]),k?null:(0,n.jsx)(Nl,{saved:x})}i(Yl,"OnboardingWizard");function Nl({saved:t}){const{onboardingOpen:d,onboardingOptions:b,closeOnboarding:g,onboardingRouteDismissed:y,setOnboardingRouteDismissed:x}=Ti(),{companies:m,setSelectedCompanyId:k,loading:D}=Ui(),_=Hi(),V=cs(),se=Ts(),{companyPrefix:xe}=ps(),De=xe??Vi(se.pathname),Ce=ts(),Yt=yl();De&&!D&&m.find(e=>e.issuePrefix.toUpperCase()===De.toUpperCase())?.id;const Mn=De&&D?null:Qi({pathname:se.pathname,companyPrefix:De,companies:m,cloudManaged:!!Ce}),C=d||Mn!==null&&!y,en=d?b:Mn??{},Le=Xs({enabled:C}),X=gs({enabled:C}),Me=en.initialStep??1,Kn=en.companyId,[l,B]=(0,o.useState)(t?.step??Me),[Ke,Wt]=(0,o.useState)(t?.step??Me),I=Ke===3&&Dn(1)>0,[F,Se]=(0,o.useState)(!I);(0,o.useEffect)(()=>{if(F)return;const e=requestAnimationFrame(()=>Se(!0));return()=>cancelAnimationFrame(e)},[F]);const le=(0,o.useRef)(l);(0,o.useEffect)(()=>{le.current=l},[l]);const[M,$]=(0,o.useState)(!1),[$r,L]=(0,o.useState)(null),[_o,Ao]=(0,o.useState)(!1),[Qr,Ll]=(0,o.useState)(""),[Oe,et]=(0,o.useState)(t?.companyName??""),[U,Fn]=(0,o.useState)(t?.agentName??""),[Fe,nt]=(0,o.useState)(()=>ls.safeParse(t?.agentAppearance).data??Pr()),[ce,Gr]=(0,o.useState)(t?.agentRole||"general"),Jt=t?.adapterType==="paperclip_runner"&&t?.onboardingCopilot===!0,[r,qn]=(0,o.useState)(()=>_l(t?.adapterType,t?.runnerProvider,t?.onboardingCopilot)),[j,tt]=(0,o.useState)(()=>Jt?"auto":t?.runner==="legacy"||t?.runner==="paperclip"?t.runner:t?.adapterType==="paperclip_runner"&&(t?.runnerProvider===void 0||["codex","claude","acpx","opencode","pi"].includes(String(t?.runnerProvider)))?"paperclip":"auto"),[qe,Bn]=(0,o.useState)(()=>t?.step===4&&t.adapterType==="claude_local"&&t.credentialMode==="subscription"&&typeof t.createdCompanyId=="string"&&(!Kn||Kn===t.createdCompanyId)&&typeof t.openedClaudeSessionId=="string"?t.openedClaudeSessionId:null),[bn,nn]=(0,o.useState)(!!qe),[wo,Eo]=(0,o.useState)(null),Yr=(0,o.useRef)(null),[Wr,Io]=(0,o.useState)(null),[tn,rt]=(0,o.useState)(),Ro=t?.adapterType==="paperclip_runner"&&!Jt,[Jr,Ol]=(0,o.useState)(t?.cwd??""),[G,te]=(0,o.useState)(Jt||Ro&&t?.runnerProvider!==void 0&&!["codex","claude","acpx","opencode","pi"].includes(String(t.runnerProvider))?"":t?.model??""),[Be,Zt]=(0,o.useState)(t?.adapterType==="paperclip_runner"?"":t?.command??""),[rn,Xt]=(0,o.useState)(t?.adapterType==="paperclip_runner"?"":t?.args??""),[Ue,at]=(0,o.useState)(t?.adapterType==="paperclip_runner"?"":t?.url??""),[re,er]=(0,o.useState)(null),[No,an]=(0,o.useState)(null),[He,vn]=(0,o.useState)(!1),[Lo,Zr]=(0,o.useState)(!1),[nr,tr]=(0,o.useState)(!1),[jl,Tl]=(0,o.useState)(!1),[rr,ot]=(0,o.useState)((t?.credentialModeChoice!==void 0?t.credentialModeChoice:t?.credentialMode)??null),[h,W]=(0,o.useState)(qe?"ready":"idle"),[it,xn]=(0,o.useState)(null),[on,ar]=(0,o.useState)(null),[st,or]=(0,o.useState)(null),[_e,ir]=(0,o.useState)(""),[kl,Xr]=(0,o.useState)(null),[a,lt]=(0,o.useState)(Kn??t?.createdCompanyId??null),q=ji(a,fe(r),C&&l===4),ee=q.subscriptions.find(e=>e.aiConnection?.mode==="responsible_user")??(q.subscriptions.length===1?q.subscriptions[0]:void 0),[Ae,sr]=(0,o.useState)(null),Oo=Ae?.companyId===a&&Ae?.envKey===fe(r)?Ae.id:q.options[0]?.id,Y=q.options.find(e=>e.id===Oo),f=rr??(q.subscriptions.length>0||r==="claude_local"&&q.storedLogin.data?"subscription":q.options.length||r==="opencode_local"?"api":"subscription"),lr=xi({open:C,step:l,connectOutcome:f==="api"?"api_key":"subscription"}),[Un,ct]=(0,o.useState)(t?.createdCompanyPrefix??null),[v,sn]=(0,o.useState)(t?.createdAgentId??null),[K,ln]=(0,o.useState)(t?.setupAgentId??null),[ge,Hn]=(0,o.useState)(!1),[ze,dt]=(0,o.useState)(!1),[jo,ut]=(0,o.useState)(0),je=(0,o.useRef)(new Set),ea=(0,o.useRef)(new Set),[T,na]=(0,o.useState)(null),Cn=(0,o.useRef)(Promise.resolve()),[ta,ra]=(0,o.useState)(t?.createdCompanyGoalId??null),cr=(0,o.useRef)(null),Sn=(0,o.useRef)(null),dr=(0,o.useRef)(!1),Ve=(0,o.useRef)(null),zn=(0,o.useRef)(0),cn=(0,o.useRef)(!1),pt=(0,o.useRef)(!1),de=(0,o.useRef)(null),Te=(0,o.useRef)(null),ft=(0,o.useRef)(new Map),O=hs(r),$e=O==="anthropic"||O==="openai"||O==="xai"||O==="google"&&r==="antigravity_runtime"?O:void 0;function Q(){if(f==="api"&&tn?.companyId===a&&tn.adapterType===r)return tn.binding;const e=T?.companyId===a&&Z(T.adapterType,T.adapterConfig)===Z(r,{})?T.runtimeConfig?.aiConnection:void 0;if(!Ae&&!_e.trim()){if(e?.method===(f==="api"?"api_key":"subscription"))return e;if((T?.companyId===a&&Z(T.adapterType,T.adapterConfig)===Z(r,{})?T.adapterConfig.env:void 0)?.[f==="api"?fe(r):"CODEX_HOME"])return}return f==="api"?Y?.aiConnection??(!Y&&de.current?.companyId===a&&de.current.envKey===fe(r)?de.current.aiConnection:void 0):ee?.aiConnection??(Te.current?.companyId===a&&Te.current.binding.provider===O?Te.current.binding:void 0)}i(Q,"managedBindingForStep");const Qe=Zs(C&&l===4&&f==="api"?a:null,Q(),r),ae=Qe.connectionModels,ke=f==="api"&&tn?.companyId===a&&tn.adapterType===r,aa=JSON.stringify([a,r,j,G,Be,rn,Ue,f,_e,Ae,tn]),mt=(0,o.useRef)(null);function ur(e){mt.current={agentId:e,selection:aa,defaultRevision:ft.current.get(JSON.stringify([a,O]))?.revision??0}}i(ur,"rememberConnectedSelection"),v&&mt.current?.agentId!==v&&ur(v);const To=ke&&!Qe.refreshing&&!!(Qe.error||!ae&&!Qe.loading),oa=!ke&&!ae||!!(ae&&(!ke||!Qe.error&&!Qe.refreshing)&&G.trim()&&(ae.models.length===0||ae.models.some(e=>e.id===G.trim())));Sn.current=a;const _n=(0,o.useRef)(void 0);_n.current=en.initialStep;const ia=(0,o.useRef)(null);function sa(){qe&&(Bn(null),nn(!1),W("idle")),na(null),rt(void 0),nt(Pr()),ct(null),et(""),ra(null),sn(null),ln(null),Hn(!1),dt(!1)}i(sa,"clearCompanyScopedState"),(0,o.useEffect)(()=>{const e=en.companyId??null,s=ia.current;if(ia.current={open:C,companyId:e,hasOpened:s?.hasOpened===!0||C},!C||s?.open&&s.companyId===e)return;const c=s?.hasOpened!==!0,p=c&&!d&&t!==null&&typeof t.step=="number"&&t.step>=1&&t.step<=5&&(e?e===t.createdCompanyId:!De);if(_n.current&&!p&&(B(_n.current),Wt(_n.current)),s?.open||lr.opened(_n.current&&!p?_n.current:l,l),e){(e!==Sn.current||c&&typeof t?.createdCompanyId=="string"&&e!==t.createdCompanyId)&&(lt(e),sa()),cr.current=e;return}(cr.current||c&&De&&t?.createdCompanyId)&&(lt(null),cr.current=null,sa())},[C,en.companyId]),(0,o.useEffect)(()=>{if(!C||!a||Un)return;const e=m.find(s=>s.id===a);e&&ct(e.issuePrefix)},[C,a,Un,m]),(0,o.useEffect)(()=>{if(!C||l===1||!a||Oe)return;const e=m.find(s=>s.id===a);e&&et(e.name)},[C,l,a,Oe,m]),(0,o.useEffect)(()=>{if(!C)return;const e={step:l,companyName:Oe,agentName:U,agentAppearance:Fe,agentRole:ce,adapterType:r,runner:j,cwd:Jr,model:G,command:Be,args:rn,url:Ue,credentialMode:f,credentialModeChoice:rr,openedClaudeSessionId:qe,createdCompanyId:a,createdCompanyPrefix:Un,createdAgentId:v,setupAgentId:K,createdCompanyGoalId:ta};Qt.write(JSON.stringify(e))},[C,l,Oe,U,Fe,ce,r,j,Jr,G,Be,rn,Ue,f,rr,qe,a,Un,v,K,ta]);const Pe=el()(r),{data:An=[],isSuccess:ko,isFetching:la,isError:Po,refetch:Do}=ve({queryKey:a?N.environments.list(a):["environments","none"],queryFn:i(()=>Zn.list(a),"queryFn"),enabled:!!a&&C&&l===4}),{data:gt,isSuccess:Mo,isFetching:ca,isError:Ko,refetch:Fo}=ve({queryKey:N.instance.settings,queryFn:i(()=>Kt.get(),"queryFn"),enabled:C&&l===4}),{data:yt,isSuccess:qo,isFetching:da,isError:Bo,refetch:Uo}=ve({queryKey:N.instance.experimentalSettings,queryFn:i(()=>Kt.getExperimental(),"queryFn"),enabled:C&&l>=3&&l<=5}),ua=yt?.enableCloudTrialInference===!0,{data:Vn}=ve({queryKey:N.cloudInference.status(a??"__none__"),queryFn:i(()=>Ga.getStatus(a),"queryFn"),enabled:C&&l===4&&!!a&&ua}),Ho=ua&&!!Vn&&(Vn?.status==="not_issued"||Vn?.status==="active"),[pr,pa]=(0,o.useState)(!1),fa=(0,o.useRef)(new Set);(0,o.useEffect)(()=>{!C||l!==4||!a||fa.current.has(a)||(fa.current.add(a),Ga.trackTelemetry(a,{event:"onboarding_exposure",surface:"onboarding_wizard"}).catch(()=>{}))},[C,l,a]);async function zo(){if(!(!a||pr||M)){pa(!0),L(null);try{const e=U.trim()||hn[ce],s=co(Vn?.defaultModel);await Cn.current.catch(()=>{});const c=await z.hire(a,{...K?{setupAgentId:K}:{},name:e,appearance:Fe,role:ce,...T?.companyId===a?{reportsTo:T.reportsTo}:{},adapterType:"paperclip_runner",adapterConfig:{provider:"opencode",model:s},onboardingFirstAgent:!0,...T?.companyId===a&&T.defaultEnvironmentId?{defaultEnvironmentId:P}:{},runtimeConfig:{...Bt({heartbeatEnabled:!1}),cloudTrialInference:!0}});c.approval&&(await Ua.approve(c.approval.id,"Approved during onboarding starter-credit setup."),_.invalidateQueries({queryKey:N.approvals.list(a)})),_.invalidateQueries({queryKey:N.agents.list(a)}),_.invalidateQueries({queryKey:N.cloudInference.status(a)}),sn(c.agent.id),B(5)}catch(e){L(e instanceof Error?e.message:"Could not start right away")}finally{pa(!1)}}}i(zo,"handleStartWithCloudTrial");const P=(0,o.useMemo)(()=>{try{return{environmentId:Ha({agentDefaultEnvironmentId:T?.companyId===a?T.defaultEnvironmentId:null,instanceDefaultEnvironmentId:gt?.defaultEnvironmentId??null,localDefaultEnvironmentId:eo(An),managedSandboxOnly:yt?.enableManagedSandboxOnly===!0,managedSandboxEnvironmentId:so(An),visibleEnvironmentIds:An.map(e=>e.id)}),error:null}}catch(e){return{environmentId:null,error:e instanceof Error?e.message:"Could not resolve the execution environment."}}},[T,a,gt?.defaultEnvironmentId,An,yt?.enableManagedSandboxOnly]).environmentId,fr=ko&&Mo&&qo&&!la&&!ca&&!da,Ge=ve({queryKey:N.adapters.availability(a,P),queryFn:i(()=>Ut.list({companyId:a,environmentId:P}),"queryFn"),enabled:!!a&&C&&l===4&&fr}),Vo=Vs(Ge),{data:ht,error:mr,isLoading:$o,isFetching:Qo}=ve({queryKey:a?N.agents.adapterModels(a,r,null):["agents","none","adapter-models",r,null],queryFn:i(()=>z.adapterModels(a,r,{environmentId:null}),"queryFn"),enabled:!!a&&C&&l===4&&Ht.has(r)}),bt=["codex_local","claude_local","opencode_local","pi_local"].includes(r)&&j==="auto",$n=j==="auto"?Ge.data?.find(e=>e.type===r)?.defaultRunner:j,dn=!bt||fr&&Ge.isSuccess&&!Ge.isFetching&&$n!==void 0,ma=bt&&(Po||Ko||Bo)?"Could not load execution environment settings. Retry setup.":bt&&Vo.kind==="error"?"Could not load runner availability. Retry setup.":bt&&Ge.isSuccess&&$n===void 0?"Runner availability is missing for this harness. Retry setup.":null;async function Go(){fr?await Ge.refetch():await Promise.all([Do(),Fo(),Uo()])}i(Go,"retryRunnerAvailability");const vt=No??ma,gr=JSON.stringify([a,P,r,j,r==="codex_local"&&j==="auto"?void 0:$n]),ga=(0,o.useRef)(gr);ga.current=gr;const Ye=(0,o.useMemo)(()=>An.find(e=>e.id===P)??null,[An,P]),xt=JSON.stringify([a,r,j,$n,G,Be,rn,Ue,f,_e,Ae,Y?.binding,ee?.binding,P,Ye?.config]),yr=(0,o.useRef)(xt);yr.current=xt;const Qn=(0,o.useRef)(null);(0,o.useEffect)(()=>{const e=Qn.current;!e||e.selection===xt||(Qn.current=null,zn.current++,Ve.current=null,cn.current=!0,$(!1),vn(!1),L("Configuration changed during setup. Connect again to test the current settings."))},[xt]);const Ct=(0,o.useRef)(""),hr=(0,o.useRef)(null);Ct.current=r==="codex_local"&&j==="auto"&&Ye?.driver==="sandbox"?JSON.stringify([a,r,j,G,Be,rn,Ue,f,_e,Ae,Y?.binding,ee?.binding,P,Ye.config]):"";const{data:Yo}=ve({queryKey:a?N.environments.capabilities(a):["environment-capabilities","none"],queryFn:i(()=>Zn.capabilities(a),"queryFn"),enabled:!!a&&Pe.login!=null&&C&&l===4}),Wo=Ki(Ye,Yo,r),wn=ve({queryKey:N.health,queryFn:is.get}),br=!!(wn.data?.localAiLoginSupported??wn.data?.deploymentMode==="local_trusted"),ya=!!wn.data?.hostedGoogleAiLoginSupported,En=!!$e&&($e==="google"&&ya||Ye?.driver==="local"&&br),Jo=$e==="google"&&ya?br?"optional":!0:!1,ue=Zi(a,{provider:$e??"anthropic",method:"subscription",name:`My ${yn[r]??O} subscription`,ownership:"personal",agentIds:[],allAgents:!0},bn&&(ge||!!v)&&C&&l===4&&En&&f!=="api"&&!!O&&!ee&&!q.storedLogin.data&&!Q(),r==="claude_local"?qe:null);(0,o.useEffect)(()=>(cn.current=!1,Ve.current=null,l===4&&($(!1),vn(!1)),()=>{zn.current++}),[C,a,r,f,l]);const un=!!(Pe.login!=null&&P&&a&&Wo),In=un&&Pi(Ye),Rn=v??K,St=ve({queryKey:N.agents.detail(Rn??"none"),queryFn:i(()=>z.get(Rn,a),"queryFn"),enabled:In&&!!Rn&&f!=="api"&&C&&l===4,refetchInterval:i(e=>{const s=e.state.data;if(e.state.status==="error")return!1;const c=gt?.defaultEnvironmentId??null;return s&&(s.lifecycleError||Si(s,P,c)||wi(s,P,c))?!1:1e3},"refetchInterval")}),_t=St.data?.id===Rn?St.data:null,ha=Ci({required:In,agent:_t,environmentId:P,instanceDefaultEnvironmentId:gt?.defaultEnvironmentId??null}),At=ha.ready,ba=In&&ha.ownComputer,vr=In&&!At&&St.isError,xr=!In||At?null:vr?"Could not check your agent's computer.":_t?.lifecycleError??null,[va,xa]=(0,o.useState)(!1);async function Zo(){if(!(!a||va)){xa(!0);try{if(vr||!_t){await St.refetch();return}const e=await z.retryLifecycle(_t.id,a);_.setQueryData(N.agents.detail(e.id),e),L(null)}catch(e){L(e instanceof Error?e.message:"Could not retry preparing your agent's computer.")}finally{xa(!1)}}}i(Zo,"retryLoginComputer");const Nn=ve({queryKey:a?N.agents.authSignal(a,r,P):["agents","none","auth-signal",r,P],queryFn:i(()=>z.getAdapterAuthSignal(a,r,P??void 0),"queryFn"),enabled:!!a&&C&&l===4&&un}).data?.status??null,Xo=un&&(Nn==="absent"||Nn==="unknown"),Ca=$e?{provider:$e,method:"subscription",name:`My ${yn[r]??O} subscription`,ownership:"personal",agentIds:[],allAgents:!0}:void 0,Sa={environmentId:P??"",aiConnection:Ca},wt=(0,o.useRef)(new Set),Et=JSON.stringify([a,r]),_a=ve({queryKey:a?N.agents.activeLoginSession(a,r):["agents","none","active-login-session",r],queryFn:i(async({signal:e})=>{try{const s=Pe.login?.panelMode==="submitted_browser_code"?await z.getActiveClaudeSetupTokenLoginSession(a,{signal:e}):await z.getActiveAdapterAuthLoginSession(a,r,{signal:e});return s&&wt.current.has(Et)?(Js(s,Sa)&&await es(a,r,Pe.login?.panelMode==="submitted_browser_code",s.sessionId),null):s}catch(s){if(s instanceof oo&&s.status===404)return null;throw s}},"queryFn"),enabled:!!a&&C&&l===4&&un&&!wt.current.has(Et)});(0,o.useEffect)(()=>{wt.current.has(Et)||!_a.data||f==="api"||ee||q.storedLogin.data||(nn(!0),W(e=>e==="idle"?"loading":e))},[_a.data,f,ee,q.storedLogin.data]);const ei=un&&Nn===null,Aa=Pe.supportsInstructionsBundle||Pe.supportsSkills||Pe.supportsLocalAgentJwt||r==="claude_local"||r==="codex_local"||r==="gemini_local"||r==="kimi_local"||r==="opencode_local"||r==="pi_local"||r==="cursor",{recommendedAdapters:We,moreAdapters:wa}=(0,o.useMemo)(()=>{const e=ds().filter(s=>Ht.has(s.type)&&!Le.has(s.type)&&ns(s.type)).map(s=>({...Bi(s.type),type:s.type}));return{recommendedAdapters:e.filter(s=>s.recommended),moreAdapters:e.filter(s=>!s.recommended)}},[Le]),oe=bn&&We.some(e=>e.type===r),Ln=!!(ee||q.storedLogin.data||f!=="api"&&Q()),It=f!=="api"&&!un&&!ei,Cr=It&&!Ln&&ue.status!=="ready"&&!(En&&O),ni=T?.companyId===a&&Z(T.adapterType,T.adapterConfig)===Z(r)&&!Ae&&T.adapterConfig.env?.[fe(r)],Rt=!!(ge||v)&&oe&&!He&&!q.loading&&dn&&!Cr&&oa,Sr=Ce&&Yt?vl(Ce,window.location.origin):null,pn=!!(Sr&&a&&!bn&&!K&&!v&&wo!==a),_r=(0,o.useRef)(pn);_r.current=pn,(0,o.useEffect)(()=>{if(l!==3||!a||!K||v||ge||je.current.has(a)||ze)return;const e=a,s=K;je.current.add(e),z.get(s,e).then(c=>{!ye(e)||c.id!==s||c.companyId!==e||c.pauseReason!=="setup"||c.metadata?.setupAdapterPending!==!0||(c.name!==hn[c.role]&&Fn(p=>p.trim()?p:c.name),Hn(!0))}).catch(()=>{}).finally(()=>{je.current.delete(e),ut(c=>c+1)})},[l,a,K,v,ge,ze]),(0,o.useEffect)(()=>{if(l!==3||!a||!X||K||v||ge||je.current.has(a)||ea.current.has(a)||ze||pn)return;const e=a;ea.current.add(e),je.current.add(e);const s=crypto.randomUUID();(async()=>{if((await z.list(e)).some(p=>p.status!=="terminated"))return null;const c=Le.has("process")?We[0]?.type:"process";return!c||!ye(e)||_r.current?null:(ln(s),z.create(e,{setupId:s,name:hn[ce],appearance:Fe,role:ce,adapterType:c,adapterConfig:{},metadata:{setupAdapterPending:!0},onboardingFirstAgent:!0,runtimeConfig:Bt({heartbeatEnabled:!1})}))})().then(c=>{!c||!ye(e)||(ln(c.id),c.pauseReason!=="setup"&&c.status!=="pending_approval"&&sn(c.id),Hn(!0),_.invalidateQueries({queryKey:N.agents.list(e)}))}).catch(()=>{ye(e)&&ln(c=>c===s?null:c)}).finally(()=>{je.current.delete(e),ut(c=>c+1)})},[l,a,X,K,v,ge,ze,pn]),(0,o.useEffect)(()=>{if(l!==4||!a||!U.trim()||!X||pn||v||ge||je.current.has(a)||ze||!oe&&Wr===JSON.stringify([a,U.trim().toLowerCase()]))return;const e=a;je.current.add(e);const s=K??crypto.randomUUID();let c=!!K;(async()=>{if(!K){const A=(await z.list(e)).filter(E=>E.status!=="terminated"&&E.pauseReason!=="setup"&&E.name.trim().toLowerCase()===U.trim().toLowerCase()),w=oe?A.find(E=>Z(E.adapterType,E.adapterConfig)===Z(r)):void 0;if(w)return c=!0,w;if(!oe&&A.length)return Io(JSON.stringify([e,U.trim().toLowerCase()])),null}const p=Le.has("process")?We[0]?.type:"process";if(!oe&&!p)throw new Error("No agent adapters are available on this instance.");const u=oe?r:p;return!ye(e)||_r.current?null:(ln(s),z.create(e,{setupId:s,name:U.trim()||hn[ce],appearance:Fe,role:ce,adapterType:u,...oe?{runner:j}:{},adapterConfig:{},metadata:{setupAdapterPending:!oe},onboardingFirstAgent:!0,runtimeConfig:Bt({heartbeatEnabled:!1})}))})().then(p=>{if(!(!p||!ye(e))){if(p.pauseReason==="setup"||p.status==="pending_approval"){if(ln(p.id),!c&&p.name&&Fn(u=>u.trim()===U.trim()?p.name:u),c&&p.adapterConfig){na(p),p.metadata?.setupAdapterPending===!0&&U.trim()||(Fn(p.name),Gr(p.role),nt(Hr(p.appearance,p.id)));const u=p.adapterConfig;if(p.metadata?.setupAdapterPending===!0)tt("auto"),te(""),Zt(""),Xt(""),at("");else{qn(Z(p.adapterType,u)),te(typeof u.model=="string"?u.model:""),Zt(typeof u.command=="string"?u.command:""),Xt(Array.isArray(u.args)?u.args.join(" "):""),at(typeof u.url=="string"?u.url:""),tt(Ht.has(Z(p.adapterType,u))?p.adapterType==="paperclip_runner"?"paperclip":"legacy":"auto");const A=p.runtimeConfig?.aiConnection;A?ot(A.method==="api_key"?"api":"subscription"):u.env?.[fe(r)]?ot("api"):(u.env?.CLAUDE_CODE_OAUTH_TOKEN||u.env?.CODEX_HOME)&&ot("subscription")}}}else sn(p.id);Hn(!0),_.invalidateQueries({queryKey:N.agents.list(e)})}}).catch(p=>{ye(e)&&(dt(!0),L(p instanceof Error?p.message:"Could not create agent setup."))}).finally(()=>{je.current.delete(e),ut(p=>p+1)})},[l,a,U,X,oe,Wr,dn,v,ge,jo,pn]);const pe=!!(f!=="api"&&(it||Xo&&!ee&&!(r==="claude_local"&&q.storedLogin.data))&&!q.loading&&a&&P);Pe.login?.panelMode;const ti=h!=="idle"&&h!=="unwindRow"&&oe,Gn=oe&&!ge&&!v&&!ze?"Creating your agent…":pe&&!At&&!xr?"Preparing your agent's computer…":He?"Testing connection…":M?"Connecting…":null,Ea=f==="api"||pe||It||!!Gn,Je=Ea&&(h==="loading"||h==="ready"||h==="waiting"||h==="connecting"),Nt=Je||Ea&&h==="unwindCard",Ia=Nt||h==="unwindRoom",ri=h==="idle"||h==="collapsing"||h==="unwindRoom"||h==="unwindRow",Ra=h==="idle"||h==="unwindRow",we=(0,o.useRef)(null),[Yn,On]=(0,o.useState)(!1),Na=(0,o.useRef)("waiting"),Ar=pe&&h!=="idle"&&h!=="connecting"||bn&&En&&f==="subscription"&&!Ln&&!Q()&&ue.status!=="ready";(0,o.useEffect)(()=>{!C||l!==4||h!=="ready"||!Rt||pe||Yn||f!=="subscription"||r!=="claude_local"&&r!=="codex_local"||!Ln&&ue.status!=="ready"&&Nn!=="present"||M||cn.current||(cn.current=!0,Or())},[C,l,h,Rt,pe,Yn,f,r,Ln,ue.status,Nn,M]),(0,o.useEffect)(()=>{if(l===4){if(h==="collapsing"){const e=setTimeout(()=>W(f==="api"||!pe?"ready":"loading"),Dn(Za));return()=>clearTimeout(e)}if(h==="connecting"){if(!Yn||!dn)return;const e=we.current===null?0:Date.now()-we.current,s=setTimeout(()=>{Or()},Math.max(0,Ms-e));return()=>clearTimeout(s)}if(h==="unwindCard"){const e=setTimeout(()=>W("unwindRoom"),Dn(xs));return()=>clearTimeout(e)}if(h==="unwindRoom"){const e=setTimeout(()=>W("unwindRow"),Dn(As));return()=>clearTimeout(e)}if(h==="unwindRow"){nn(!1);const e=setTimeout(()=>W("idle"),Dn(Za));return()=>clearTimeout(e)}}},[l,h,f,pe,Yn,dn]);const Lt=f==="api"&&!Y&&!ke&&!ae&&(r==="claude_local"||r==="codex_local"),La=oe&&Ia&&!Gn&&f==="api"&&a&&(r==="codex_local"||r==="claude_local"),Oa=yn[r]??r,Ot=f==="subscription"&&(r==="claude_local"||r==="codex_local");function ja(){Bn(null),cn.current=!1,L(null)}i(ja,"prepareLocalLoginRetry");const jt=Ls({enabled:bn&&h==="ready"&&En&&!!O&&f==="subscription"&&!Ln&&!Q()&&It&&!pe,adapterType:r,login:ue,onBeforeRetry:ja}),Tt=jt.action,kt=Sl({passiveSubscriptionFooter:Ot&&(!!on||Tt?.kind==="retry"||!$r&&!vt),setupError:ze,retryLogin:!Ot&&!!on,connectProgress:Gn,adapterEnvLoading:He,connectPhase:h,hasSubmitLoginCode:!!st,adapterType:r,connectStepNeedsLogin:pe,connectSourceLabel:Oa,connectAuthUrl:it,localLoginAction:Tt,connectDisabled:!Rt||Ar||f==="api"&&!_e.trim()&&!Y&&!ni&&!Q()});function ai(){Bn(null),ue.cancel(),jt.resetSubmitting(),wt.current.add(Et),a&&(_.cancelQueries({queryKey:N.agents.activeLoginSession(a,r)}),un&&f!=="api"&&Li(a,r,Pe.login?.panelMode==="submitted_browser_code",Sa)),zn.current++,Ve.current=null,$(!1),vn(!1),xn(null),or(null),ar(null),we.current=null,On(!1),W(Je?"unwindCard":"unwindRow")}i(ai,"unwindConnectStep");function Ta(){h!=="ready"&&h!=="waiting"||!it||on||(window.open(it,"_blank","noreferrer,noopener"),W("waiting"))}i(Ta,"openConnectAuthorization");function Pt(){if(ze){dt(!1),ut(e=>e+1),L(null);return}if(!Cr){if(on){xn(null),or(null),ar(null),we.current=null,On(!1),W("loading"),on();return}if((h==="ready"||h==="waiting")&&st){st();return}if(h==="ready"&&pe){Ta();return}jt.runPrimary()||h!=="connecting"&&(Ar||Or())}}i(Pt,"handleConnectStepPrimary"),(0,o.useEffect)(()=>{if(!X)return;const e=[...We,...wa].filter(c=>!c.comingSoon);if(e.length===0){Ht.has(r)||(qn("claude_local"),te(""),nn(!1));return}if(e.some(c=>c.type===r))return;const s=e[0].type;if(qn(s),nn(!1),s==="opencode_local"){te(Rs);return}if(s==="gemini_local"){te($i);return}if(s==="cursor"){te(Wi);return}te("")},[X,We,wa,r]);const jn=Be.trim()||({claude_local:"claude",codex_local:"codex",gemini_local:"gemini",kimi_local:"kimi",pi_local:"pi",cursor:"agent",opencode_local:"opencode"}[r]??r.replace(/_local$/,""));(0,o.useEffect)(()=>{l===4&&(er(null),pt.current=!1,hr.current!==Ct.current&&an(null))},[l,r,j,G,Be,rn,Ue,f,_e,Ae,Y?.id,ee?.id,a,tn,P,j==="auto"?Ge.data?.find(e=>e.type===r)?.defaultRunner:void 0]),(0,o.useEffect)(()=>{l!==4&&(Bn(null),W("idle"),xn(null),nn(!1),we.current=null,On(!1))},[l]),(ht??[]).find(e=>e.id===G);const oi=re?.checks.some(e=>e.code==="claude_anthropic_api_key_overrides_subscription")??!1,ii=r==="claude_local"&&re?.status==="fail"&&oi,wr=(0,o.useMemo)(()=>{const e=Qr.trim().toLowerCase();return(ht??[]).filter(s=>{if(!e)return!0;const c=Wa(s.id,"");return s.id.toLowerCase().includes(e)||s.label.toLowerCase().includes(e)||c.toLowerCase().includes(e)})},[ht,Qr]);(0,o.useMemo)(()=>{if(r!=="opencode_local")return[{provider:"models",entries:[...wr].sort((s,c)=>s.id.localeCompare(c.id))}];const e=new Map;for(const s of wr){const c=Wa(s.id),p=e.get(c)??[];p.push(s),e.set(c,p)}return Array.from(e.entries()).sort(([s],[c])=>s.localeCompare(c)).map(([s,c])=>({provider:s,entries:[...c].sort((p,u)=>p.id.localeCompare(u.id))}))},[wr,r]);function ka(){Qt.clear(),B(1),$(!1),L(null),et(""),Fn(""),nt(Pr()),Gr(xl),qn("claude_local"),tt("auto"),te(""),Zt(""),Xt(""),at(""),er(null),pt.current=!1,an(null),vn(!1),Zr(!1),tr(!1),Xr(null),lt(null),ct(null),sn(null),ln(null),Hn(!1),dt(!1),ra(null)}i(ka,"reset");function si(){lr.dismissed(l),ka(),g(),x(!0)}i(si,"handleClose");function ye(e){return Sn.current===e}i(ye,"stillTheSameCompany");function li(e,s){const c=Sn.current;return c===e||c===s?!0:(L("Organization created, but onboarding switched to another organization."),!1)}i(li,"canCommitCreatedCompany");const Dt=(0,o.useRef)(void 0),Er=(0,o.useCallback)((e,s)=>{const c=`${e}:${s}`,p=Dt.current;if(p?.key===c)return p;const u={key:c,issue:ro.startOnboarding(e,s),warming:!1};return Dt.current=u,u.issue.catch(()=>{Dt.current===u&&(Dt.current=void 0)}),u},[]);(0,o.useEffect)(()=>{if(!C||l!==5||!a||!v)return;const e=Er(a,v);e.warming||(e.warming=!0,e.issue.then(()=>ro.greet(a,v)).catch(()=>{}))},[C,l,a,v,Er]);async function Pa(){if(!a||!v){L(yo);return}$(!0),L(null),kr("review");try{if(await Er(a,v).issue,kr("launch","succeeded"),!ye(a))return;lr.finished();const e=Un,s=v;k(a,{source:"route_sync"}),ka(),g(),V(`${e?`/${e}`:""}/chats/${s}`,{state:{onboardingWelcome:!0}})}catch(e){kr("launch","failed"),gn({step:"launch",reason:"launch_failed"}),L(e instanceof Error?e.message:"Failed to open your chat. Please try again.")}finally{$(!1)}}i(Pa,"handleLaunchToChat");async function ci(e,s=()=>!0){const c=_e.trim(),p=fe(r),u=de.current?.key===c&&de.current.companyId===e&&de.current.envKey===p?de.current:null;if(u?.binding)return!0;try{if(O){const w=u?.grantId??(await Ft.create(e,{provider:O,method:"api_key",name:`My ${yn[r]??O} API`,ownership:"personal",apiKey:c,agentIds:[],allAgents:!0})).grantId;return de.current={key:c,companyId:e,envKey:p,grantId:w},!s()||!await Ir(e,O,w,s)?!1:(de.current={key:c,companyId:e,envKey:p,grantId:w,aiConnection:{provider:O,method:"api_key",mode:"responsible_user"}},!0)}const A=await Es(e,p,c);return de.current={key:c,companyId:e,envKey:p,binding:A.binding},!0}catch(A){return s()&&(gn({step:"connect_model",reason:"api_key_save_failed",provider:O??r,method:"api_key"}),L(A instanceof Error?`Could not store the API key: ${_s(A).body}`:"Could not store the API key.")),!1}}i(ci,"storeApiKeyUserSecret");function Ir(e,s,c,p,u){const A=JSON.stringify([e,s]);let w=ft.current.get(A);w||(w={pending:Promise.resolve(),queued:0,revision:0},ft.current.set(A,w));const E=w;E.revision++,E.queued++;const S=E.pending.then(async()=>{if(!p())return!1;if(u===c&&(E.grantId===void 0||E.grantId===c))return!0;E.grantId=null;try{await Ft.setDefault(e,c),E.grantId=c}finally{_.invalidateQueries({queryKey:["ai-connections",e]})}return p()}).finally(()=>{E.queued--});return E.pending=S.catch(()=>{}),S}i(Ir,"selectManagedDefault");async function di(e,s){const c=Q();if(c?.mode!=="responsible_user")return;const p=Te.current?.companyId===e&&Te.current.binding.provider===c.provider?Te.current:null;let u=p?.grantId;!u&&p?.sessionId&&(u=(await Ft.loginResult(e,p.sessionId)).grantId);const A=ee?.aiConnection?.mode==="responsible_user"&&ee.id.startsWith("ai:")?ee.id.slice(3):void 0;if(u??=A,!u){const w=await Ft.list(e);if(!s())return;const E=w.connections.filter(S=>S.provider===c.provider&&S.method==="subscription"&&S.ownership==="personal"&&S.ownerUserId===w.currentUserId&&S.status==="connected");u=(E.find(S=>S.isDefault)??(E.length===1?E[0]:void 0))?.grantId}if(s()){if(!u)throw new Error("Choose a subscription account in Connections, then retry setup.");Te.current={companyId:e,binding:c,grantId:u},await Ir(e,c.provider,u,s,A)}}i(di,"selectManagedSubscription");function Wn(e=!1,s,c){const p=Fi(r),u=c??T,A=u?.companyId===a&&Z(u.adapterType,u.adapterConfig)===Z(r)?u.adapterConfig:{},w=p.buildAdapterConfig({...$a,adapterType:r,runner:j,...r==="pi_local"?{adapterSchemaValues:A}:{},resolvedRunner:s??$n,model:r==="gemini_local"?G||"auto":r==="kimi_local"?G||"kimi-code/kimi-for-coding":r==="cursor"?G||"auto":r==="opencode_local"?G||"openai/gpt-5.2-codex":G,command:Be,args:rn,url:Ue,dangerouslySkipPermissions:r==="claude_local"||r==="opencode_local",dangerouslyBypassSandbox:r==="codex_local"?j==="legacy"&&!0:$a.dangerouslyBypassSandbox}),E={...A.env??{}};r==="codex_local"&&(c||Q())&&((f==="api"||Q())&&delete E.CODEX_HOME,(f==="subscription"||Q())&&delete E.OPENAI_API_KEY),r==="claude_local"&&((f==="api"||Q())&&delete E[ss],(f==="subscription"||Q())&&(delete E.ANTHROPIC_API_KEY,delete E.ANTHROPIC_AUTH_TOKEN));const S={...A,...w,...A.env||w.env?{env:{...E,...w.env??{}}}:{}};if(r==="claude_local"&&Lo){const H=typeof S.env=="object"&&S.env!==null&&!Array.isArray(S.env)?{...S.env}:{};H.ANTHROPIC_API_KEY={type:"plain",value:""},S.env=H}if(!Q()&&f==="api"&&(e||Y)&&(!A.env?.[fe(r)]||Ae||_e.trim())){const H=typeof S.env=="object"&&S.env!==null&&!Array.isArray(S.env)?{...S.env}:{};H[fe(r)]=Y?.binding??de.current?.binding,S.env=H}return f==="subscription"&&ee?.binding&&!A.env?.CODEX_HOME&&(S.env={...S.env??{},CODEX_HOME:ee.binding}),S}i(Wn,"buildAdapterConfig");function Rr(e,s){const c=s??T,{aiConnection:p,...u}=c?.companyId===a?c.runtimeConfig:{},A=Q();return{...u,...s?{}:Bt({heartbeatEnabled:e}),...A?{aiConnection:A}:{}}}i(Rr,"buildSetupRuntimeConfig");const Nr=(l===3||l===4)&&ge&&K&&!v&&!M?JSON.stringify({name:U.trim()||hn[ce],appearance:Fe,...oe&&dn?{adapterType:r,runner:j,adapterConfig:Wn(!!de.current?.binding),defaultEnvironmentId:P,runtimeConfig:Rr(!1),metadata:{...T?.metadata,setupAdapterPending:!1}}:{}}):null;(0,o.useEffect)(()=>{if(!Nr||!K||!a)return;const e=a,s=K,c=i(()=>{Cn.current=Cn.current.catch(()=>{}).then(async()=>{!ye(e)||Ve.current!==null||await z.update(s,JSON.parse(Nr),e)}),Cn.current.catch(u=>{ye(e)&&L(u instanceof Error?u.message:"Could not save agent setup.")})},"save");if(l!==3){c();return}const p=setTimeout(c,400);return()=>clearTimeout(p)},[Nr,K,a,l]);async function Da(e,s=!1,c=()=>!0,p,u){if(!dn)return null;if(!a)return an("Create or select an organization before testing adapter environment."),null;const A=Ct.current,w=u??T,E=u&&j==="auto"&&Z(u.adapterType,u.adapterConfig)===r?Ja(u.adapterType):j,S=i(()=>c()&&Ct.current===A,"selectionIsCurrent");hr.current=null,vn(!0),an(null);try{return await il(async H=>{const ne=i(()=>S()&&!H.aborted,"testIsCurrent");let he,fn,Ze;try{const[J,kn,Re]=await Promise.all([_.ensureQueryData({queryKey:N.environments.list(a),queryFn:i(()=>Zn.list(a),"queryFn")}),_.ensureQueryData({queryKey:N.instance.settings,queryFn:i(()=>Kt.get(),"queryFn")}),_.ensureQueryData({queryKey:N.instance.experimentalSettings,queryFn:i(()=>Kt.getExperimental(),"queryFn")})]);he=J,fn=kn,Ze=Re?.enableManagedSandboxOnly===!0}catch{return ne()&&(gn({step:"connect_model",reason:"environment_test_failed",provider:O??r,method:f==="api"?"api_key":"subscription"}),an("Could not load environment settings to determine which environment to test in. Retry the test.")),null}const ie=Ha({agentDefaultEnvironmentId:w?.companyId===a?w.defaultEnvironmentId:null,instanceDefaultEnvironmentId:fn?.defaultEnvironmentId??null,localDefaultEnvironmentId:eo(he),managedSandboxOnly:Ze,managedSandboxEnvironmentId:so(he),visibleEnvironmentIds:he.map(J=>J.id)});if(!ne())return null;const Mt=he.find(J=>J.id===ie),Ee=Mt?.config;if(!v&&r==="codex_local"&&j==="auto"&&Mt?.driver==="sandbox"&&typeof Ee?.image=="string"&&/^[^\s@]+@sha256:[a-f0-9]{64}$/.test(Ee.image)&&!Ee.snapshot&&!Ee.template&&!Ee.templateRef){const J=N.adapters.availability(a,ie),kn=await _.fetchQuery({queryKey:J,staleTime:0,queryFn:i(()=>Ut.list({companyId:a,environmentId:ie},{signal:H}),"queryFn")});if(!ne())return null;const Re=kn.find(be=>be.type==="codex_local"),qa=kn.find(be=>be.type==="paperclip_runner");if(!Re||Re.defaultRunner!=="paperclip"&&Re.defaultRunner!=="legacy"||!Re.supportedRunners?.includes(Re.defaultRunner))throw new Error("Could not confirm Codex runner availability for this environment. Retry setup.");if(Re.defaultRunner!=="paperclip"&&!Re?.disabled&&!Re?.overriddenBuiltin&&!qa?.disabled&&!qa?.overriddenBuiltin){const be=await Zn.probe(ie,a,{signal:H});if(!ne())return null;if(be.ok!==!0||be.details?.platformQualificationRecorded!==!0||typeof be.details.leaseId!="string"||!be.details.leaseId)throw new Error(typeof be.details?.platformQualificationDiagnostic=="string"?be.details.platformQualificationDiagnostic:be.summary||"The environment's platform qualification could not be confirmed. Retry the connection probe.");const hi=await _.fetchQuery({queryKey:J,staleTime:0,queryFn:i(()=>Ut.list({companyId:a,environmentId:ie},{signal:H}),"queryFn")});if(!ne())return null;const Ba=hi.find(bi=>bi.type==="codex_local"),Tr=Ba?.defaultRunner;if(Tr!=="paperclip"&&Tr!=="legacy"||!Ba?.supportedRunners?.includes(Tr))throw new Error("Could not confirm the environment's default runner. Retry setup.")}}if(!ne())return null;const Tn={adapterType:r,runner:j,savedAgentId:v,environment:he.find(J=>J.id===ie)},mn=await Ys({...Tn,readAdapters:i(()=>Ut.list({companyId:a,environmentId:ie},{signal:H}),"readAdapters"),probeEnvironment:i(()=>Zn.probe(ie,a,{signal:H}),"probeEnvironment"),isCurrent:ne});if(!ne()||Xa(Tn)&&!mn)return null;let R=e??Wn();mn&&(R=Wn(!0,mn.runner),s&&(R.env={...Gt(R.env)?R.env:{},...Va()}),p?.(R,mn.adapters,ie));const Ie=await z.testEnvironment(a,r,{adapterConfig:R,...w?.companyId===a?{agentId:w.id}:{},...["codex_local","claude_local","opencode_local","pi_local"].includes(r)&&E!=="auto"?{runner:E}:{},...Q()?{aiConnection:Q()}:{},environmentId:ie},{signal:H});return ne()?(Fr(Ie)&&gn({step:"connect_model",reason:"environment_test_failed",provider:O??r,method:f==="api"?"api_key":"subscription"}),er(Ie),pt.current=s,Ie):null})}catch(H){return S()&&(gn({step:"connect_model",reason:"environment_test_failed",provider:O??r,method:f==="api"?"api_key":"subscription"}),hr.current=A||null,an(H instanceof Error?H.message:"Adapter environment test failed")),null}finally{c()&&vn(!1)}}i(Da,"runAdapterEnvironmentTest");async function Lr(){if(a){B(3);return}if(dr.current)return;dr.current=!0,$(!0),L(null);const e=Sn.current;try{const s=await qi.create({name:Oe.trim()});if(_.invalidateQueries({queryKey:N.companies.all}),!li(e,s.id))return;lt(s.id),Sn.current=s.id,ct(s.issuePrefix),k(s.id),B(3)}catch(s){L(s instanceof Error?s.message:"Failed to create organization")}finally{dr.current=!1,$(!1)}}i(Lr,"handleCreateCompany");async function Or(){if(!a||!ge&&!v)return;if(!oa){L("Choose a model for this gateway connection before connecting your agent.");return}const e=ft.current.get(JSON.stringify([a,O]));if(v&&mt.current?.selection===aa&&!e?.queued&&mt.current.defaultRevision===(e?.revision??0)){B(5);return}if(!dn||Ve.current!==null)return;const s=++zn.current,c=r==="claude_local"&&j==="auto",p=yr.current;Qn.current=c?{attempt:s,selection:p}:null;const u=i(()=>zn.current===s&&ye(a)&&ga.current===gr&&(!c||yr.current===p),"isCurrent");Ve.current=s,cn.current=!0,$(!0),L(null);let A;try{if(r==="opencode_local"){const R=G.trim();if(!zi(R)){L("OpenCode requires an explicit model in provider/model format.");return}if(mr){L(mr instanceof Error?mr.message:"Failed to load OpenCode models.");return}if($o||Qo){L("OpenCode models are still loading. Please wait and try again.");return}const Ie=ht??[];if(!Ie.some(J=>J.id===R)){L(Ie.length===0?"No OpenCode models discovered. Run `opencode models` and authenticate providers.":`Configured OpenCode model is unavailable: ${R}`);return}}let w=!1;if(f==="api"&&!Y&&_e.trim()&&(w=await ci(a,u),!w||!u()))return;if(f==="api"&&Y?.aiConnection?.mode==="responsible_user"){const R=Y.id.startsWith("ai:")?Y.id.slice(3):void 0;if(!R)throw new Error("Choose a connected API account before continuing.");if(!await Ir(a,Y.aiConnection.provider,R,u,R))return}if(f!=="api"&&En&&O&&!Q()&&!ee&&!q.storedLogin.data){const R=await ue.connect();if(!u())return;Te.current={companyId:a,binding:{provider:O,method:"subscription",mode:"responsible_user"},grantId:R.grantId}}if(f==="subscription"&&await di(a,u),!u())return;const E=Q(),S=v?await z.get(v,a):void 0;if(!u())return;if(S?.runtimeConfig.aiConnection&&f==="api"&&Y?.binding&&!E)throw new Error("Choose a connected API account or Enter a new API key to replace this agent’s connected account.");const H=S&&j==="auto"&&Z(S.adapterType,S.adapterConfig)===r?Ja(S.adapterType):void 0,ne=Wn(w,H,S);let he=null;if(!E&&r==="claude_local"&&!Al(ne)){try{he=await z.getClaudeOAuthTokenStatus(a)}catch(R){if(!(R instanceof oo)||R.status!==404)throw R;he=null}if(!u())return;Xr(he)}const fn=he!==null;let Ze=fn?{...ne,env:{...Gt(ne.env)?ne.env:{},...Va()}}:ne;if(Aa){const R=(!Xa({adapterType:r,runner:j,savedAgentId:v,environment:Ye})&&re&&pt.current===fn&&!Fr(re)?re:null)??await Da(Ze,fn,u,(Ie,J,kn)=>{Ze=Ie,A={adapters:J,environmentId:kn}},S);if(!R||!u())return;if(Fr(R)){const Ie=r==="codex_local"&&R.adapterType==="paperclip_runner"?R.checks.find(J=>J.level==="error")?.message:void 0;L(Ie||(R.status==="fail"?Ce?"Microvac couldn't finish connecting this agent. Try connecting again.":"The environment test failed. Fix the reported checks before you hire this agent.":"No working authentication was found. Fix the reported checks before you hire this agent."));return}}if(!ce||!u())return;const ie=U.trim()||hn[ce];if(v&&S){if(await Cn.current.catch(()=>{}),!u()||(await z.update(v,{adapterType:r,adapterConfig:Ze,...["codex_local","claude_local","opencode_local","pi_local"].includes(r)&&(j!=="auto"||H)?{runner:H??j}:{},runtimeConfig:Rr(!0,S)},a),!u()))return;ur(v),_.invalidateQueries({queryKey:N.agents.list(a)}),_.invalidateQueries({queryKey:N.agents.detail(v)}),B(5);return}const Mt=K?null:await z.list(a).catch(()=>null);if(!u())return;const Ee=Mt?.find(R=>R.id!==K&&R.name.trim().toLowerCase()===ie.toLowerCase()&&Z(R.adapterType,R.adapterConfig)===Z(r,Ze));if(Ee){if(!u())return;sn(Ee.id),nt(Hr(Ee.appearance,Ee.id)),_.invalidateQueries({queryKey:N.agents.list(a)}),B(5);return}if(await Cn.current.catch(()=>{}),!u())return;const Tn=await z.hire(a,{...K?{setupAgentId:K}:{},name:ie,appearance:Fe,role:ce,...T?.companyId===a?{reportsTo:T.reportsTo}:{},adapterType:r,adapterConfig:Ze,...["codex_local","claude_local","opencode_local","pi_local"].includes(r)&&j!=="auto"?{runner:j}:{},...fn?{applyStoredClaudeLogin:!0}:{},onboardingFirstAgent:!0,...T?.companyId===a&&T.defaultEnvironmentId?{defaultEnvironmentId:P}:{},runtimeConfig:Rr(!0)});if(!u())return;Tn.approval&&(await Ua.approve(Tn.approval.id,"Approved during onboarding first-agent setup."),_.invalidateQueries({queryKey:N.approvals.list(a)}));const mn=Tn.agent;if(_.invalidateQueries({queryKey:N.agents.list(a)}),!u())return;sn(mn.id),ur(mn.id),B(5)}catch(w){if(!u())return;gn({step:"connect_model",reason:"agent_create_failed",provider:O??r,method:f==="api"?"api_key":"subscription"}),L(w instanceof Error?w.message:"Failed to create agent")}finally{Ve.current===s&&(Ve.current=null),Qn.current?.attempt===s&&(Qn.current=null),u()&&(A&&_.setQueryData(N.adapters.availability(a,A.environmentId),A.adapters),$(!1)),Yn&&u()&&(we.current=null,xn(null),W(w=>w==="connecting"?"ready":w))}}i(Or,"handleGiveHeartbeat");async function ui(){if(!a||nr)return;tr(!0),L(null),an(null),Zr(!0);const e=(()=>{const s=Wn(),c=typeof s.env=="object"&&s.env!==null&&!Array.isArray(s.env)?{...s.env}:{};return c.ANTHROPIC_API_KEY={type:"plain",value:""},s.env=c,s})();try{v&&(await z.update(v,{adapterConfig:e},a),_.invalidateQueries({queryKey:N.agents.list(a)})),(await Da(e))?.status==="fail"&&L("Retried with ANTHROPIC_API_KEY unset in adapter config, but the environment test is still failing.")}catch(s){L(s instanceof Error?s.message:"Failed to unset ANTHROPIC_API_KEY and retry.")}finally{tr(!1)}}i(ui,"handleUnsetAnthropicApiKey");function pi(e){if(!e.defaultPrevented&&e.key==="Enter"&&(e.metaKey||e.ctrlKey)){if(e.preventDefault(),M)return;l===1&&Oe.trim()?Lr():l===3&&U.trim()?B(4):l===4&&!kt.disabled&&U.trim()&&Rt&&(on||st||Tt&&!Tt.disabled||!Ar)?Pt():l===5&&Pa()}}if(i(pi,"handleKeyDown"),!C)return null;function fi(e){return e===3?1:e-1}i(fi,"backStepFrom");const jr=po(l)!==null,mi=yt?.enableManagedSandboxOnly===!0,Ma=jr&&Ke>=3&&!mi,Ka=l===5&&(!a||!v),Jn=Dn(1)>0,gi=l===1||!F?Ya.closed:I&&le.current===Ke?Ws:Ya.open,yi=l===1||!F?Ni:l===3&&Jn&&le.current===1?Xi:Kr.animate,Fa=$r??(Ka?yo:null);return(0,n.jsx)(xo,{open:C,onOpenChange:i(e=>{e||si()},"onOpenChange"),children:(0,n.jsxs)(Fs,{children:[(0,n.jsx)("div",{className:"fixed inset-0 z-50 bg-background"}),(0,n.jsx)("div",{"data-testid":"onboarding-wizard",className:"fixed inset-0 z-50 flex",onKeyDown:pi,children:(0,n.jsx)("div",{className:"w-full flex flex-col overflow-y-auto",children:(0,n.jsxs)("div",{className:Xn("mx-auto my-auto shrink-0",jr||l===1?"w-(--sz-560px) max-w-full px-8 py-10 sm:px-10 sm:py-11":"w-full max-w-md px-8 py-12",l===4&&"pb-8 sm:pb-9"),children:[!Ma&&(0,n.jsx)(fo,{step:fl(l),total:Vt.length,labels:pl,canJumpToStep:i(e=>no({targetStep:Vt[e-1],currentStep:l,entryStep:Ke}),"canJumpToStep"),onJumpToStep:i(e=>B(Vt[e-1]),"onJumpToStep")}),Ma&&(0,n.jsx)(fo,{step:po(l),canJumpToStep:i(e=>no({targetStep:Vr[e-1],currentStep:l,entryStep:Ke}),"canJumpToStep"),onJumpToStep:i(e=>B(Vr[e-1]),"onJumpToStep")}),(l===1||l>=3&&l<=5)&&(0,n.jsx)(Ai,{reducedMotion:"user",children:(0,n.jsxs)("div",{className:"mb-9",children:[(0,n.jsx)(me.div,{className:"overflow-hidden",initial:!1,animate:gi,"aria-hidden":l===1||void 0,children:(0,n.jsxs)(me.div,{initial:Kr.initial,animate:yi,transition:Kr.transition,className:"flex flex-col items-center gap-2 pb-6",children:[(0,n.jsx)("div",{className:"relative size-(--sz-160px)",children:(0,n.jsx)(dl,{appearance:Fe,awake:l===5,className:"size-full"})}),(0,n.jsx)(ml,{agentName:U,agentRole:""})]})}),(0,n.jsx)(_i,{center:!0,title:(0,n.jsx)(me.span,{...to,className:"inline-block",children:l===1?"What is the name of your organization?":l===3?"Create your first agent":l===4?"Connect a model":"Let's get started..."},l)}),(0,n.jsx)(me.div,{className:"overflow-hidden text-center",initial:!1,animate:l===1||l===3?za.closed:za.open,"aria-hidden":l===1||l===3||void 0,children:(0,n.jsx)("p",{className:"pt-2 text-base leading-relaxed text-muted-foreground",children:(0,n.jsx)(me.span,{...to,className:"inline-block",children:l===4?"Microvac works with your subscription or API keys.":`${U.trim()||"Your first agent"} is ready to work!`},l)})})]})}),(0,n.jsxs)(Yi,{mode:Jn?"wait":"sync",initial:I,children:[l===1&&(0,n.jsx)(me.div,{...Pn,exit:Jn?Pn.exit:void 0,className:"mx-auto flex w-full flex-col gap-9",children:(0,n.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,n.jsx)(ao,{htmlFor:"onboarding-company-name",children:"Name"}),(0,n.jsx)(zr,{id:"onboarding-company-name","aria-describedby":"onboarding-company-name-hint",className:"h-(--sz-44px) rounded-lg border-transparent bg-muted shadow-none dark:bg-muted",placeholder:"e.g. Acme Co., Marketing department, Bob's team",value:Oe,onChange:i(e=>et(e.target.value),"onChange"),onKeyDown:i(e=>{e.key==="Enter"&&Oe.trim()&&(e.preventDefault(),Lr())},"onKeyDown"),autoFocus:!0}),(0,n.jsx)("p",{id:"onboarding-company-name-hint",className:"text-sm text-muted-foreground",children:"You can always change this later"})]})},"step-1"),l===3&&(0,n.jsx)(me.div,{...Pn,exit:Jn?Pn.exit:void 0,className:"mx-auto flex w-full flex-col gap-9",children:(0,n.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,n.jsx)(ao,{htmlFor:"onboarding-agent-name",children:"Agent name"}),(0,n.jsx)(zr,{id:"onboarding-agent-name",className:"h-(--sz-44px) rounded-lg border-transparent bg-muted shadow-none dark:bg-muted",placeholder:"e.g. Chief of staff",value:U,onChange:i(e=>Fn(e.target.value),"onChange"),onKeyDown:i(e=>{e.key==="Enter"&&!e.nativeEvent.isComposing&&U.trim()&&(e.preventDefault(),B(4))},"onKeyDown"),autoFocus:!0})]})},"step-3"),l===4&&(0,n.jsxs)(me.div,{...Pn,exit:Jn?Pn.exit:void 0,className:"space-y-8",children:[Ho&&h==="idle"&&(0,n.jsx)("div",{className:"rounded-xl border border-border bg-card p-4 shadow-xs space-y-3",children:(0,n.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(Oi,{className:"size-4 text-primary"}),(0,n.jsx)("span",{className:"text-sm font-semibold text-foreground",children:"Start right away"}),(0,n.jsx)(Mi,{variant:"secondary",className:"rounded-full text-xs",children:co(Vn?.defaultModel).split("/").pop()??"Starter"})]}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try Microvac right away without connecting an account. We’ll ask you to connect a model provider when it’s time to continue."})]}),(0,n.jsx)(Ne,{size:"sm",onClick:zo,disabled:pr||M,className:"shrink-0",children:pr?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(Dr,{className:"size-3.5 mr-1.5 animate-spin"}),"Starting…"]}):(0,n.jsxs)(n.Fragment,{children:["Start free",(0,n.jsx)(Di,{className:"size-3.5 ml-1.5"})]})})]})}),pn&&a&&Sr&&(0,n.jsx)(hl,{destination:Sr,onDismiss:i(()=>{Eo(a),Yr.current?.querySelector('[role="radio"]')?.focus()},"onDismiss")},a),(0,n.jsxs)("div",{ref:Yr,children:[(0,n.jsx)(zs,{label:"Model source",sources:We.map(e=>({id:e.type,label:yn[e.type]??e.label,icon:(0,n.jsx)(go,{type:e.type,Fallback:e.icon})})),mode:f,selectedId:bn&&We.some(e=>e.type===r)?r:null,collapsed:ti,settling:h==="unwindRow",onSelect:i(e=>{h!=="idle"&&h!=="unwindRow"||(cn.current=!1,nn(!0),qn(e),e!==r&&tt("auto"),(e!==r||e==="codex_local"&&f==="subscription"&&G.startsWith("claude-"))&&te(e==="opencode_local"?"openai/gpt-5.2-codex":""),W("collapsing"))},"onSelect")}),X&&We.length===0&&(0,n.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Claude and Codex are unavailable on this instance. Ask an administrator to enable one, or exit setup and choose New Agent on the Agents page to use another provider."}),(0,n.jsx)(me.div,{className:"overflow-hidden",inert:!Ra,initial:!1,animate:{opacity:Ra?1:0,height:ri?"auto":0},transition:{opacity:Gs,height:qt},children:(0,n.jsxs)("div",{className:"-ml-3 mt-1",children:[(0,n.jsx)(Ds,{mode:f,onChange:ot}),q.options.length>0&&(0,n.jsxs)("p",{className:"px-3 text-sm text-muted-foreground",children:[q.options.length," saved API ",q.options.length===1?"key available":"keys available","."]}),f==="subscription"&&Nn==="present"&&(0,n.jsx)("p",{className:"px-3 text-sm text-muted-foreground",children:"An existing provider connection is available."})]})})]}),(0,n.jsxs)(me.div,{className:"overflow-hidden",inert:!Je,initial:!1,animate:{height:Nt?"auto":0,marginTop:Nt?20:0,opacity:Je?1:0},transition:{height:qt,marginTop:qt,opacity:Je?{...$s,delay:qt.duration}:vs},children:[(0,n.jsx)(Ps.Provider,{value:Ot?(0,n.jsx)(go,{type:r,Fallback:Dr}):null,children:(0,n.jsx)(Hs.Provider,{value:Ot&&on?Pt:null,children:Ia?Gn?(0,n.jsxs)("p",{role:"status",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(Dr,{className:"size-4 animate-spin"}),Gn]}):f==="api"?(0,n.jsxs)(fs,{revealTogether:Lt,instruction:(0,n.jsxs)("span",{className:"grid gap-1",children:[(0,n.jsx)("span",{children:ke||ae?"Choose a model for your saved connection":q.options.length?"Choose a saved API key or enter a new one":`Provide your ${yn[r]??r} API key to connect.`}),Lt&&(0,n.jsxs)("span",{id:"onboarding-api-account-note",children:["This will be your default ",Oa," account."]})]}),children:[!ke&&(0,n.jsx)(as,{...q,disabled:M||He,value:Y?.id??"",onChange:i(e=>{rt(void 0),ae&&te(""),sr(a?{companyId:a,envKey:fe(r),id:e}:null),ir("")},"onChange")}),!Y&&!ke&&!ae&&(0,n.jsx)(ws,{label:"API key",describedBy:Lt?"onboarding-api-account-note":void 0,description:!Lt&&O?`This will be your default ${yn[r]??O} account.`:void 0,placeholder:"Enter API key here",masked:!0,autoFocus:!0,value:_e,onChange:i(e=>{sr(a?{companyId:a,envKey:fe(r),id:""}:null),ir(e)},"onChange"),onSubmit:i(()=>Pt(),"onSubmit")}),ke&&(To?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"Your saved gateway connection could not be loaded. Retry to choose a model and connect your agent."}),(0,n.jsx)(Ne,{type:"button",variant:"outline",disabled:M||He,onClick:i(()=>{Qe.refresh()},"onClick"),children:"Retry loading connection"})]}):(0,n.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:Qe.refreshing?"Loading your saved gateway connection…":"Gateway connection saved. Choose a model, then Connect to test it and finish setting up your agent."})),ae&&(0,n.jsx)(Ss,{models:ae.models,value:G,onChange:te,open:_o,onOpenChange:Ao,allowDefault:!1,required:!0,groupByProvider:!1,creatable:ae.models.length===0,presentation:"native"}),(ke||ae)&&(0,n.jsx)(Ne,{type:"button",variant:"ghost",disabled:M||He,onClick:i(()=>{rt(void 0),sr({companyId:a,envKey:fe(r),id:""}),te("")},"onClick"),children:"Use a different API key"})]}):pe&&xr?(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:xr}),(0,n.jsx)(Ne,{type:"button",variant:"outline",disabled:va,onClick:i(()=>{Zo()},"onClick"),children:vr?"Retry":"Retry preparation"})]}):pe&&At&&a&&P?(0,n.jsx)(Ks,{companyId:a,adapterType:r,environmentId:P,requiresAgent:In,agentId:ba?Rn??void 0:void 0,chrome:"onboarding",aiConnection:Ca,autoStart:!0,active:Je,onPromptReady:i(e=>{Je&&(xn(e),e&&W(s=>s==="loading"?"ready":s))},"onPromptReady"),onOpenAuthorization:Ta,onRetryReady:i(e=>{Je&&ar(()=>e)},"onRetryReady"),onSubmitReady:i(e=>or(()=>e),"onSubmitReady"),onCodeSubmitted:i(()=>{Na.current=h,we.current=Date.now(),On(!1),W("connecting")},"onCodeSubmitted"),onSubmitFailed:i(()=>{h==="connecting"&&(we.current=null,On(!1),W(Na.current==="ready"?"ready":"waiting"))},"onSubmitFailed"),onLoginFailed:i(()=>{gn({step:"connect_model",reason:"subscription_login_failed",provider:O??r,method:"subscription"})},"onLoginFailed"),onConnected:i(e=>{$e&&(Te.current={companyId:a,binding:{provider:$e,method:"subscription",mode:"responsible_user"},sessionId:e}),xn(null),!(h!=="loading"&&h!=="ready"&&h!=="waiting"&&h!=="connecting")&&(we.current===null&&(we.current=Date.now()),On(!0),W("connecting"))},"onConnected"),onStored:i(()=>{_.invalidateQueries({queryKey:N.agents.authSignal(a,r,P)})},"onStored")},`${r}:${P}:${ba?Rn:""}`):Ln||ue.status==="ready"?null:It?En&&O?(0,n.jsx)(Bs,{adapterType:r,hostedRedirect:Jo,...jt.instructionsProps,authorizationOpened:!!(qe&&qe===ue.sessionId),onOpenAuthorization:r==="claude_local"?e=>{Bn(ue.sessionId??null),window.open(e,"_blank","noopener,noreferrer")}:void 0,login:{...ue,retry:i(()=>{ja(),ue.retry()},"retry")}}):Cr?(0,n.jsx)("p",{role:"status",className:"text-xs text-muted-foreground",children:"This environment does not support browser sign-in. Go back to use an API key or choose another model."}):null:null:null})}),La&&(0,n.jsxs)("details",{className:"mt-2 space-y-3",children:[(0,n.jsx)("summary",{className:"cursor-pointer text-sm text-muted-foreground",children:"Advanced"}),(0,n.jsx)(sl,{companyId:a,agentId:K??void 0,environmentId:P??void 0,adapterType:r,disabled:M||He,className:"-ml-3",onComplete:i(e=>{rt({companyId:a,adapterType:r,binding:e}),ir(""),te(""),L(null)},"onComplete")})]})]}),Aa&&!M&&(vt||re&&re.status!=="pass")&&(0,n.jsxs)("div",{className:"space-y-2 rounded-md border border-border p-3",children:[vt&&(0,n.jsx)("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-2.5 py-2 text-(length:--text-micro) text-destructive",children:vt}),ma&&(0,n.jsx)(Ne,{type:"button",variant:"outline",disabled:Ge.isFetching||la||ca||da,onClick:i(()=>{Go()},"onClick"),children:"Retry setup"}),re&&re.status==="pass"?(0,n.jsxs)("div",{className:"space-y-2 animate-in fade-in slide-in-from-bottom-1 duration-300",children:[(0,n.jsxs)("div",{className:"status-chip flex items-center gap-2 rounded-md border px-2.5 py-2 text-(length:--text-micro)",style:{"--sc":"var(--status-task-done)"},children:[(0,n.jsx)(vo,{className:"size-3.5 shrink-0"}),(0,n.jsx)("span",{className:"font-medium",children:"Passed"})]}),(0,n.jsx)(ho,{result:re,showHints:wn.isSuccess&&!Ce})]}):re?(0,n.jsx)(ho,{result:re,showHints:wn.isSuccess&&!Ce}):null,ii&&(0,n.jsxs)("div",{className:"rounded-md border border-amber-300/60 bg-amber-50/40 px-2.5 py-2 space-y-2",children:[(0,n.jsxs)("p",{className:"text-(length:--text-micro) text-amber-900/90 leading-relaxed",children:["Claude failed while"," ",(0,n.jsx)("span",{className:"font-mono",children:"ANTHROPIC_API_KEY"})," ","is set. You can clear it in this adapter config and retry the probe."]}),(0,n.jsx)(Ne,{size:"sm",variant:"outline",className:"h-7 px-2.5 text-xs",disabled:He||nr,onClick:i(()=>{ui()},"onClick"),children:nr?"Retrying...":"Unset ANTHROPIC_API_KEY"})]}),re&&re.status==="fail"&&wn.isSuccess&&!Ce&&(0,n.jsxs)("div",{className:"rounded-md border border-border/70 bg-muted/20 px-2.5 py-2 text-(length:--text-micro) space-y-1.5",children:[(0,n.jsx)("p",{className:"font-medium",children:"Manual debug"}),(0,n.jsx)("p",{className:"text-muted-foreground font-mono break-all",children:r==="cursor"?`${jn} -p --mode ask --output-format json "Respond with hello."`:r==="codex_local"?`${jn} exec --json -`:r==="gemini_local"?`${jn} --output-format json "Respond with hello."`:r==="kimi_local"?`${jn} -p "Respond with hello." --output-format stream-json`:r==="opencode_local"?`${jn} run --format json "Respond with hello."`:`${jn} --print - --output-format stream-json --verbose`}),(0,n.jsxs)("p",{className:"text-muted-foreground",children:["Prompt:"," ",(0,n.jsx)("span",{className:"font-mono",children:"Respond with hello."})]}),r==="claude_local"||r==="codex_local"?(0,n.jsx)("p",{className:"text-muted-foreground",children:"If authentication fails, connect your subscription in the browser above or use an API key."}):r==="cursor"||r==="gemini_local"||r==="kimi_local"||r==="opencode_local"?(0,n.jsxs)("p",{className:"text-muted-foreground",children:["If auth fails, set"," ",(0,n.jsx)("span",{className:"font-mono",children:r==="cursor"?"CURSOR_API_KEY":r==="gemini_local"?"GEMINI_API_KEY":r==="kimi_local"?"KIMI_MODEL_NAME + KIMI_MODEL_API_KEY":"OPENAI_API_KEY"})," ","in env or run"," ",(0,n.jsx)("span",{className:"font-mono",children:r==="cursor"?"agent login":r==="gemini_local"?"gemini auth":r==="kimi_local"?"kimi login":"opencode auth login"}),"."]}):(0,n.jsx)("p",{className:"text-muted-foreground",children:"If login is required, connect the provider above and retry."})]})]}),(r==="http"||r==="openclaw_gateway")&&(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:r==="openclaw_gateway"?"Gateway URL":"Webhook URL"}),(0,n.jsx)("input",{className:"w-full rounded-md border border-border bg-transparent px-3 py-2 text-sm font-mono outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50",placeholder:r==="openclaw_gateway"?"ws://127.0.0.1:18789":"https://...",value:Ue,onChange:i(e=>at(e.target.value),"onChange")})]})]},"step-4")]}),Fa&&(0,n.jsx)("div",{className:"mt-3",children:(0,n.jsx)("p",{className:"text-xs text-destructive",children:Fa})}),(jr||l===1)&&(0,n.jsx)(ms,{compact:l===4&&!!La&&Nt,onBack:l===4&&h!=="idle"?ai:Ri({currentStep:l,entryStep:Ke})?()=>B(fi(l)):void 0,primaryLabel:l===1?"Continue":l===5?"Get started":l===4?kt.label:"Next",primaryIcon:l===4?kt.icon:void 0,loadingLabel:l===1?"Creating...":l===4?"Connecting":"Launching...",loading:l===3||l===4?!1:M,primaryDisabled:l===1?!Oe.trim()||M:l===3?!U.trim():l===4?kt.disabled||M:M||Ka,onPrimary:i(()=>{l===1?Lr():l===3?B(4):l===4?Pt():Pa()},"onPrimary")})]})})})]})})}i(Nl,"OnboardingWizardInner");function ho({result:t,showHints:d}){const b=t.status==="pass"?"Passed":t.status==="warn"?"Warnings":"Failed",g=t.status==="pass"?"text-green-700 dark:text-green-300 border-green-300 dark:border-green-500/40 bg-green-50 dark:bg-green-500/10":t.status==="warn"?"text-amber-700 dark:text-amber-300 border-amber-300 dark:border-amber-500/40 bg-amber-50 dark:bg-amber-500/10":"text-red-700 dark:text-red-300 border-red-300 dark:border-red-500/40 bg-red-50 dark:bg-red-500/10";return(0,n.jsxs)("div",{className:`rounded-md border px-2.5 py-2 text-(length:--text-micro) ${g}`,children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,n.jsx)("span",{className:"font-medium",children:b}),(0,n.jsx)("span",{className:"opacity-80",children:new Date(t.testedAt).toLocaleTimeString()})]}),(0,n.jsx)("div",{className:"mt-1.5 space-y-1",children:t.checks.map((y,x)=>(0,n.jsxs)("div",{className:"leading-relaxed break-words",children:[(0,n.jsx)("span",{className:"font-medium uppercase tracking-wide opacity-80",children:y.level}),(0,n.jsx)("span",{className:"mx-1 opacity-60",children:"·"}),(0,n.jsx)("span",{children:y.message}),y.detail&&(0,n.jsxs)("span",{className:"block opacity-75 break-all",children:["(",y.detail,")"]}),d&&y.hint&&(0,n.jsxs)("span",{className:"block opacity-90 break-words",children:["Hint: ",y.hint]})]},`${y.code}-${x}`))})]})}i(ho,"AdapterEnvironmentResult");export{Yl as OnboardingWizard};
2
+ var vi=Object.defineProperty;var i=(t,d)=>vi(t,"name",{value:d,configurable:!0});import{a as bo}from"./rolldown-runtime-DhZMWcEn.js";import{en as kr,nn as xi,tn as gn}from"./issue-detail-CZfjXs0M.js";import{S as Ua}from"./collections-B58p51lw.js";import{a as Ci,i as Si,n as _i,o as Ai,r as wi}from"./OnboardingPrimitives-BkgPF4Mu.js";import{$A as Ei,$u as Ha,AA as Ii,Ar as Ri,BA as Xe,Cd as Ni,Cf as Li,Dd as Pn,Df as me,EA as zt,EC as Oi,Ed as za,Ef as ji,Ey as Ti,FA as ki,FD as Pi,GS as N,GT as Di,H_ as Mi,Hl as Va,IA as $t,ID as Ki,Id as Zn,JD as Pr,Jl as Fi,Ju as $a,KS as qi,Kd as Bi,Kv as Kt,LS as Ui,ME as Hi,MT as vo,Md as zi,Mr as Vi,NA as Qa,NE as Ne,Nd as $i,Nr as Qi,OA as Gi,Of as Yi,Pd as Wi,QO as Ji,Qp as Ga,Rf as Zi,Sd as Xi,Sf as es,Sl as ns,Sy as ts,Tc as rs,Td as Ya,Tf as as,US as os,Vb as is,Vl as ss,WD as ls,Xu as Wa,YD as Hr,Yb as cs,Yl as ds,Zp as Ft,_D as Ja,__ as zr,_d as Za,_f as Xa,_w as Dr,_y as us,aE as ps,ad as fs,al as ms,bd as Dn,bl as gs,cT as ys,cf as hs,ck as hn,dO as bs,dd as vs,ed as eo,fd as xs,fy as Cs,gD as Z,gd as Mr,gl as Ss,hE as _s,hd as As,id as ws,if as Es,jb as Is,jd as Rs,jr as no,kA as Ns,kd as to,ld as Ls,ly as Os,md as qt,my as js,nE as Ts,nb as ro,nd as yn,nj as ks,od as Ps,ol as Ds,op as ao,pE as oo,pd as Ms,pl as Ks,py as Fs,qp as qs,rb as z,rd as Bs,rw as Us,sE as io,sd as Hs,sl as zs,sy as xo,td as so,ub as Vs,ud as $s,ul as Bt,uy as Qs,vd as Gs,vf as Ys,wd as Ws,wf as Js,xE as ve,xd as Kr,xf as Zs,xl as Xs,yd as lo,yf as Ut,yl as el,zE as Xn}from"./index-BJtnP7H1.js";import{t as nl}from"./palette-tokens-CL5ZDrEd.js";import{n as Qt,r as tl}from"./onboarding-state-C5_mIw3o.js";var rl=["subscription","api_key"],al="openrouter/openai/gpt-6-luna";function co(t){const d=t?.trim();return d?d.startsWith("openrouter/")?d:`openrouter/${d}`:al}i(co,"resolveCloudTrialModel");var Vl=$t({connectionId:Xe().uuid(),grantId:Xe().uuid(),provider:zt(bs),method:zt(rl),ownership:zt(["personal","shared"]).default("personal"),model:Xe().trim().min(1).max(200).optional(),agentIds:Gi(Xe().uuid()).max(200).optional(),resumeBlockedWork:Ns().default(!0)}).strict(),$l=Ii("event",[$t({event:Qa("onboarding_exposure"),surface:zt(["onboarding_wizard","onboarding_seed"]).default("onboarding_wizard")}).strict(),$t({event:Qa("modal_shown"),trialAgentCount:ki().int().nonnegative().max(1e3)}).strict()]),Ql=$t({adapterType:Xe().trim().min(1).max(100).optional(),runnerProvider:Xe().trim().min(1).max(100).optional(),acpxAgent:Xe().trim().min(1).max(100).optional(),model:Xe().trim().min(1).max(200).optional()}).strict(),ol=12e4;function Fr(t){return t.status==="fail"?!0:t.checks.some(d=>d.code===Ji)}i(Fr,"blocksAgentCreate");async function il(t){const d=new AbortController;let b;const g=new Promise((y,x)=>{b=setTimeout(()=>{const m=new Error("The connection test took too long. Try connecting again.");x(m),d.abort(m)},ol)});try{return await Promise.race([t(d.signal),g])}finally{clearTimeout(b)}}i(il,"runOnboardingConnectionTest");var o=bo(ks(),1),n=bo(Ei(),1);function sl({companyId:t,agentId:d,environmentId:b,adapterType:g,disabled:y,className:x,onComplete:m}){const[k,D]=(0,o.useState)(!1);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(Ne,{type:"button",variant:"ghost",className:x,disabled:y,onClick:i(()=>D(!0),"onClick"),children:"Use a custom gateway"}),(0,n.jsx)(xo,{open:k,onOpenChange:D,children:(0,n.jsxs)(Os,{className:"max-h-(--sz-85vh) overflow-y-auto sm:max-w-2xl",onKeyDown:i(_=>_.stopPropagation(),"onKeyDown"),children:[(0,n.jsxs)(Cs,{children:[(0,n.jsx)(js,{children:"Custom gateway connection"}),(0,n.jsx)(Qs,{children:"Save the connection, then choose a model and test it with your agent."})]}),(0,n.jsx)(rs,{companyId:t,agentId:d,environmentId:b,initialProvider:"gateway",initialProtocol:g==="codex_local"?"responses":"messages",submitLabel:"Save connection",onCancel:i(()=>D(!1),"onCancel"),onComplete:i(_=>{D(!1),m(_)},"onComplete")})]})})]})}i(sl,"OnboardingGatewaySetup");var qr="sleepy",Br="idle";function ll(t){const d=t.animations.map(x=>x.id),b=t.animations.find(x=>!x.loop)?.id,g=d.includes(qr)?qr:void 0,y=d.includes(Br)?Br:void 0;if(!b||!g||!y)throw new Error(`Onboarding character export needs a looping "${qr}", a looping "${Br}" and one non-looping wake animation; found: ${d.join(", ")||"none"}`);return{asleep:g,wake:b,awake:y}}i(ll,"resolveOnboardingSequences");function cl(t,d){const b=t.animations.find(g=>g.id===d);return b?b.steps.reduce((g,y)=>g+(Number.isFinite(y.duration)?Math.max(.2,y.duration):1),0)/(Number.isFinite(t.character.speed)&&t.character.speed>0?t.character.speed:1):0}i(cl,"sequenceDuration");function Ur(t,d){const b=t.animations.find(V=>V.id===d),g=b?.steps[0],y=g&&t.expressions.find(V=>V.id===g.expressionId),x=y?.beats[0];if(!b||!g||!y||!x)return 0;const m=i(V=>Number.isFinite(V)?Math.max(.2,V):1,"safe"),k=y.beats.reduce((V,se)=>V+m(se.duration),0),D=Math.min(.45,m(x.duration)*.4),_=Number.isFinite(t.character.speed)&&t.character.speed>0?t.character.speed:1;return D*m(g.duration)/k/_}i(Ur,"sequenceLeadIn");function uo(t,d,b){const g=b?"muted-dream":d.paletteId,y=nl[g];return{...t,character:{...t.character,color:y.a,color2:y.b}}}i(uo,"colorOnboardingDefinition");function dl({appearance:t,awake:d,className:b}){const g=Hr(t),y=(0,o.useRef)(null),x=(0,o.useRef)(null),m=(0,o.useRef)({base:null,overlay:null}),k=(0,o.useRef)(null),D=(0,o.useRef)(d?"awake":"asleep"),_=(0,o.useRef)(null),V=(0,o.useRef)([]),[se,xe]=(0,o.useState)(!1),[De,Ce]=(0,o.useState)(!1),[Yt,Mn]=(0,o.useState)(d),[C,en]=(0,o.useState)(0),Le=i(()=>{for(const I of V.current)window.clearTimeout(I);V.current=[]},"clearTimers"),X=i(I=>{m.current[I]?.destroy(),m.current[I]=null},"destroy"),Me=i(()=>{Le(),X("overlay"),X("base"),xe(!1),Ce(!0)},"fail"),Kn=i(()=>typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,"reducedMotion"),l={followCursor:!1,followRotation:!0,trackingScope:"page",displaySize:160};function B(I){const F=k.current;if(!F||!y.current||!x.current)return;Le(),X("overlay"),X("base");const Se=I==="asleep"?F.sequences.asleep:F.sequences.awake,le=Ur(F.definition,Se),M=F.create(y.current,uo(F.definition,g,I==="asleep"),{animation:Se,...l,onError:Me});if(m.current.base=M,M.seek(le),m.current.base===M){if(I==="asleep"){const $=F.create(x.current,uo(F.definition,g,!1),{animation:Se,...l,onError:Me});if(m.current.overlay=$,$.seek(le),m.current.overlay!==$)return}D.current=I,_.current=g.paletteId,Mn(I==="awake")}}i(B,"mount");function Ke(){const I=k.current,F=m.current.base,Se=m.current.overlay;if(!I||!F||!Se||Kn()){B("awake");return}Le();const le=Ur(I.definition,I.sequences.wake),M=Math.max(0,cl(I.definition,I.sequences.wake)-le);en(M);for(const $ of[F,Se]){if($.setAnimation(I.sequences.wake),m.current.base!==F||($.seek(le),m.current.base!==F))return;$.play()}D.current="awake",V.current.push(window.setTimeout(()=>Mn(!0),0)),V.current.push(window.setTimeout(()=>{X("base"),m.current.base=m.current.overlay,m.current.overlay=null,m.current.base?.setAnimation(I.sequences.awake),m.current.base?.seek(Ur(I.definition,I.sequences.awake))},Math.ceil(M*1e3)+50))}i(Ke,"wake"),(0,o.useEffect)(()=>{if(typeof IntersectionObserver!="function"||typeof ResizeObserver!="function"||typeof WebGLRenderingContext>"u"){Ce(!0);return}let I=!1;return xe(!1),Promise.all([io(()=>import("./runtime-IAg0vdY9.js"),__vite__mapDeps([0,1])),io(()=>import("./character-CguPM7IG.js"),[])]).then(([F,Se])=>{if(I)return;const le=Se.PAPERCLIP_CHARACTER;k.current={create:F.createCharacter,definition:le,sequences:ll(le)},B(D.current),m.current.base&&xe(!0)}).catch(F=>{I||Me()}),()=>{I=!0,Le(),X("overlay"),X("base"),k.current=null,xe(!1)}},[]),(0,o.useEffect)(()=>{if(!(!se||!k.current||_.current===g.paletteId))try{B(D.current)}catch{Me()}},[g.paletteId,se]),(0,o.useEffect)(()=>{if(!se||!k.current||!m.current.base)return;const I=d?"awake":"asleep";if(I!==D.current)try{I==="awake"?Ke():B("asleep")}catch{Me()}},[d,se]);const Wt=se&&!De;return(0,n.jsxs)("span",{className:Xn("relative inline-block",b),"aria-hidden":"true",children:[(0,n.jsx)(Is,{appearance:g,size:256,pose:d?"rest":"sleepy",muted:!d,className:Xn("size-full",Wt&&"invisible")}),(0,n.jsx)("span",{ref:y,className:"absolute inset-0"}),(0,n.jsx)("span",{ref:x,className:"absolute inset-0 transition-opacity ease-linear motion-reduce:transition-none",style:{opacity:Yt?1:0,transitionDuration:`${Math.max(0,C)}s`}})]})}i(dl,"OnboardingCharacter");var ul=["Create your first agent","Connect a model","Review"],Vr=[3,4,5],Vt=[1,3,4,5],pl=["Name your organization","Create your first agent","Connect a model","Review"];function fl(t){return Vt.filter(d=>d<=t).length}i(fl,"onboardingStepPositionFor");function po(t){const d=Vr.indexOf(t);return d===-1?null:d+1}i(po,"agentArcStepFor");function fo({step:t,total:d=3,labels:b=ul,canJumpToStep:g,onJumpToStep:y}){return(0,n.jsxs)("div",{className:"mb-11 flex items-center justify-center",children:[Array.from({length:d},(x,m)=>m+1).map(x=>{const m=!!(g?.(x)&&y);return(0,n.jsx)("button",{type:"button","aria-label":b[x-1]??`Step ${x}`,"aria-current":x===t?"step":void 0,disabled:!m,onClick:i(()=>m&&y?.(x),"onClick"),className:Xn("grid h-1.5 w-3.5 shrink-0 place-items-center rounded-full",m?"cursor-pointer":"cursor-default"),children:(0,n.jsx)("span",{"aria-hidden":"true",className:Xn("size-1.5 rounded-full transition-colors",x<=t?"bg-foreground":"bg-border")})},x)}),(0,n.jsxs)("span",{className:"sr-only",children:["Step ",t," of ",d]})]})}i(fo,"Stepper");function ml({agentName:t,agentRole:d}){const b=!!(t||d);return(0,n.jsx)(me.div,{className:"overflow-hidden",initial:!1,animate:{height:b?"auto":0},transition:{duration:Mr,ease:lo},children:(0,n.jsxs)(me.div,{className:"mt-1 flex flex-col items-center gap-1",initial:!1,animate:{opacity:b?1:0},transition:{duration:Mr,ease:lo,delay:b?Mr*.25:0},children:[(0,n.jsx)("span",{className:"flex h-6 items-center text-base font-semibold tracking-tight text-foreground",children:t||" "}),(0,n.jsx)("span",{className:"flex h-4 items-center text-xs text-muted-foreground",children:d||" "})]})})}i(ml,"AgentPreview");var Co="(min-width: 40rem)";function gl(t){const d=window.matchMedia?.(Co);return d?.addEventListener("change",t),()=>d?.removeEventListener("change",t)}i(gl,"subscribeToViewport");function yl(){return(0,o.useSyncExternalStore)(gl,()=>window.matchMedia?.(Co).matches===!1,()=>!1)}i(yl,"useMobileOnboardingViewport");function hl({destination:t,onDismiss:d}){const b=(0,o.useId)(),g=(0,o.useId)(),y=(0,o.useId)(),x=(0,o.useRef)(null),m=(0,o.useRef)(null),[k,D]=(0,o.useState)(!1),[_,V]=(0,o.useState)("idle");(0,o.useEffect)(()=>{k&&m.current?.scrollIntoView({block:"nearest"})},[k]);async function se(){try{await qs(t),V("copied")}catch{V("manual"),x.current?.focus(),x.current?.select()}}return i(se,"copyLink"),(0,n.jsxs)("section",{"aria-labelledby":b,className:"flex flex-col gap-3 rounded-lg border bg-muted/40 p-3 text-left sm:hidden",children:[(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)(Us,{className:"size-5 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,n.jsxs)("div",{className:"flex min-w-0 flex-col gap-1",children:[(0,n.jsx)("h2",{id:b,className:"text-sm font-medium text-foreground",children:"Setup is easier on desktop"}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Especially if you need to sign in or paste a key."})]})]}),(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-1",children:[(0,n.jsx)(Ne,{type:"button",variant:"outline",className:"h-(--sz-44px) px-2","aria-controls":g,"aria-expanded":k,onClick:i(()=>D(xe=>!xe),"onClick"),children:"Continue on desktop"}),(0,n.jsx)(Ne,{type:"button",variant:"ghost",className:"h-(--sz-44px) px-2",onClick:d,children:"Keep going here"})]}),(0,n.jsx)("div",{id:g,ref:m,hidden:!k,children:k&&(0,n.jsxs)("div",{className:"flex flex-col gap-2 border-t pt-3",children:[(0,n.jsx)("label",{htmlFor:y,className:"text-sm text-muted-foreground",children:"Open this link on your computer and sign in with the same account. You may need to re-enter setup choices."}),(0,n.jsx)(zr,{id:y,ref:x,readOnly:!0,value:t,"aria-label":"Desktop setup link",className:"text-base",onFocus:i(xe=>xe.currentTarget.select(),"onFocus")}),(0,n.jsxs)(Ne,{type:"button",variant:"outline",className:"h-(--sz-44px) self-start",onClick:i(()=>{se()},"onClick"),children:[_==="copied"?(0,n.jsx)(vo,{"aria-hidden":"true"}):(0,n.jsx)(ys,{"aria-hidden":"true"}),_==="copied"?"Link copied":"Copy setup link"]}),(0,n.jsx)("span",{role:"status",className:"sr-only",children:_==="copied"?"Desktop setup link copied.":""}),_==="manual"&&(0,n.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Automatic copy is unavailable. Copy the selected link manually."})]})})]})}i(hl,"MobileDesktopNudge");function mo(t){if(!t)return null;try{const d=new URL(t);return d.username||d.password||d.pathname!=="/"||d.search||d.hash?null:d}catch{return null}}i(mo,"parseOrigin");function bl(t){const d=t.hostname.replace(/\.$/,"");return d==="localhost"||d.endsWith(".localhost")||/^127\.[\d.]+$/.test(d)||d==="[::1]"}i(bl,"isLoopback");function vl(t,d){const b=us(t.cloudBaseUrl,"/"),g=b?new URL(b).origin:null,y=i(k=>k?.protocol==="https:"&&!bl(k)&&k.origin!==g,"usableTenantOrigin"),x=mo(t.runtimeIdentity?.canonicalOrigin);if(x&&y(x))return new URL("/onboarding",x).href;const m=mo(d);return m&&y(m)?new URL("/onboarding",m).href:null}i(vl,"cloudDesktopOnboardingUrl");var xl="general",Cl="Chief of staff",Gl=new Set([Cl,...Object.values(hn)]);function Sl(t){return t.setupError?{label:"Retry",icon:"arrow",disabled:!1}:t.retryLogin?{label:"Retry sign-in",icon:"arrow",disabled:!1}:t.localLoginAction?.kind==="connecting"||t.connectPhase==="connecting"?{label:"Connecting…",icon:"spinner",disabled:!0}:t.passiveSubscriptionFooter?{label:"Next",icon:"arrow",disabled:!0}:t.connectProgress?{label:t.adapterEnvLoading?"Testing…":t.connectProgress,icon:"spinner",disabled:!0}:(t.connectPhase==="ready"||t.connectPhase==="waiting")&&t.hasSubmitLoginCode?{label:"Submit code",icon:"arrow",disabled:!1}:t.connectPhase==="waiting"?{label:t.adapterType==="codex_local"?"Waiting for auth…":"Waiting for code…",icon:"spinner",disabled:!0}:t.connectPhase!=="ready"?{label:"Next",icon:"arrow",disabled:!0}:t.connectStepNeedsLogin?{label:`Sign in to ${t.connectSourceLabel}`,icon:"none",disabled:!t.connectAuthUrl}:t.localLoginAction?{label:t.localLoginAction.label,icon:t.localLoginAction.icon,disabled:t.localLoginAction.disabled}:{label:"Connect",icon:"arrow",disabled:t.connectDisabled}}i(Sl,"resolveOnboardingConnectCta");var Ht=new Set(["claude_local","codex_local"]);function _l(t,d,b){return t==="paperclip_runner"&&d==="pi"?"pi_local":t==="paperclip_runner"&&d==="opencode"?"opencode_local":t==="paperclip_runner"&&b!==!0&&(d===void 0||d==="codex")?"codex_local":typeof t=="string"&&t!=="paperclip_runner"?t:"claude_local"}i(_l,"restoreOnboardingAdapterType");function Gt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}i(Gt,"isEnvRecord");var So="ANTHROPIC_API_KEY";function Al(t){if(!Gt(t.env))return!1;const d=t.env[So];return typeof d=="string"?d.trim().length>0:Gt(d)?d.type==="plain"?typeof d.value=="string"&&d.value.trim().length>0:d.type==="secret_ref"||d.type==="user_secret_ref":!1}i(Al,"adapterConfigHasAnthropicApiKey");var wl={claude_local:"/brands/claude-color.svg"};function El({className:t}){return(0,n.jsx)("svg",{viewBox:"114 114 488 488",className:t,fill:"none","aria-hidden":!0,children:(0,n.jsx)("path",{fill:"currentColor",d:"M508.749 317.399C516.777 287.314 508.991 253.884 485.389 230.282C461.788 206.681 428.36 198.895 398.273 206.923C376.231 184.928 343.39 174.956 311.148 183.596C278.906 192.234 255.45 217.292 247.36 247.361C217.291 255.451 192.233 278.91 183.595 311.149C174.957 343.391 184.927 376.232 206.924 398.274C198.896 428.359 206.683 461.789 230.284 485.391C253.885 508.992 287.313 516.779 317.401 508.75C339.442 530.745 372.286 540.717 404.525 532.079C436.767 523.441 460.223 498.384 468.313 468.315C498.383 460.224 523.44 436.766 532.078 404.526C540.716 372.285 530.747 339.443 508.749 317.402V317.399ZM470.899 244.776C486.892 260.77 493.488 282.601 490.687 303.412L415.577 260.046C412.411 258.218 408.509 258.218 405.345 260.046L317.401 310.82V277.526C317.401 275.191 318.652 273.005 320.676 271.837L387.644 233.174C414.178 218.353 448.346 222.223 470.901 244.776H470.899ZM357.837 311.144L398.275 334.491V381.185L357.837 404.532L317.398 381.185V334.491L357.837 311.144ZM264.776 269.693C265.207 239.305 285.644 211.649 316.453 203.393C338.3 197.54 360.505 202.744 377.127 215.573L302.014 258.937C298.848 260.764 296.898 264.144 296.898 267.798V369.346L268.065 352.699C266.043 351.531 264.776 349.353 264.776 347.017V269.691V269.693ZM203.391 316.454C209.244 294.608 224.854 277.978 244.276 269.999V356.73C244.276 360.384 246.226 363.763 249.392 365.591L337.337 416.365L308.503 433.013C306.481 434.181 303.961 434.188 301.939 433.02L234.971 394.357C208.868 378.789 195.138 347.261 203.391 316.454ZM244.775 470.9C228.781 454.906 222.186 433.075 224.986 412.264L300.096 455.63C303.263 457.457 307.164 457.457 310.328 455.63L398.273 404.856V438.149C398.273 440.485 397.022 442.671 394.997 443.839L328.029 482.502C301.495 497.322 267.327 493.452 244.772 470.9H244.775ZM450.897 445.982C450.466 476.371 430.029 504.027 399.22 512.283C377.373 518.136 355.168 512.932 338.547 500.102L413.659 456.738C416.826 454.911 418.775 451.532 418.775 447.877V346.329L447.609 362.977C449.631 364.145 450.897 366.323 450.897 368.659V445.985V445.982ZM512.282 399.221C506.429 421.068 490.819 437.697 471.397 445.676V358.946C471.397 355.292 469.448 351.912 466.281 350.085L378.336 299.311L407.17 282.663C409.192 281.495 411.712 281.487 413.734 282.655L480.702 321.318C506.805 336.887 520.536 368.415 512.282 399.221Z"})})}i(El,"OpenAiBlossom");var Il={codex_local:El},Rl={claude_local:So,codex_local:"OPENAI_API_KEY"};function fe(t){return Rl[t]??"API_KEY"}i(fe,"apiKeyEnvKeyFor");function go({type:t,Fallback:d}){const b=Il[t];if(b)return(0,n.jsx)(b,{className:"size-full"});const g=wl[t];return g?(0,n.jsx)("img",{src:g,alt:"",className:"size-full"}):(0,n.jsx)(d,{className:"size-full"})}i(go,"ModelSourceMark");var yo="Onboarding state is incomplete. Please restart onboarding and try again.";function Yl(){const t=(0,o.useMemo)(()=>{const D=Qt.read();if(D)try{return JSON.parse(D)}catch{return null}},[]),[d,b]=(0,o.useState)(t==null),g=os({staleTime:0,enabled:t!=null}),y=g.isSuccess&&g.data!==void 0&&!g.data.unauthorized,{saved:x,staleStateDetected:m}=(0,o.useMemo)(()=>{if(t===void 0)return{saved:null,staleStateDetected:!1};if(t===null)return{saved:null,staleStateDetected:!0};if(!y)return{saved:null,staleStateDetected:!1};const D=tl(t,g.data.companies);return{saved:D,staleStateDetected:D===null}},[t,y,g.data]);(0,o.useEffect)(()=>{m&&Qt.clear()},[m]);const k=!d&&t!==void 0&&g.isFetching;return(0,o.useEffect)(()=>{!d&&y&&!g.isFetching&&b(!0)},[d,y,g.isFetching]),k?null:(0,n.jsx)(Nl,{saved:x})}i(Yl,"OnboardingWizard");function Nl({saved:t}){const{onboardingOpen:d,onboardingOptions:b,closeOnboarding:g,onboardingRouteDismissed:y,setOnboardingRouteDismissed:x}=Ti(),{companies:m,setSelectedCompanyId:k,loading:D}=Ui(),_=Hi(),V=cs(),se=Ts(),{companyPrefix:xe}=ps(),De=xe??Vi(se.pathname),Ce=ts(),Yt=yl();De&&!D&&m.find(e=>e.issuePrefix.toUpperCase()===De.toUpperCase())?.id;const Mn=De&&D?null:Qi({pathname:se.pathname,companyPrefix:De,companies:m,cloudManaged:!!Ce}),C=d||Mn!==null&&!y,en=d?b:Mn??{},Le=Xs({enabled:C}),X=gs({enabled:C}),Me=en.initialStep??1,Kn=en.companyId,[l,B]=(0,o.useState)(t?.step??Me),[Ke,Wt]=(0,o.useState)(t?.step??Me),I=Ke===3&&Dn(1)>0,[F,Se]=(0,o.useState)(!I);(0,o.useEffect)(()=>{if(F)return;const e=requestAnimationFrame(()=>Se(!0));return()=>cancelAnimationFrame(e)},[F]);const le=(0,o.useRef)(l);(0,o.useEffect)(()=>{le.current=l},[l]);const[M,$]=(0,o.useState)(!1),[$r,L]=(0,o.useState)(null),[_o,Ao]=(0,o.useState)(!1),[Qr,Ll]=(0,o.useState)(""),[Oe,et]=(0,o.useState)(t?.companyName??""),[U,Fn]=(0,o.useState)(t?.agentName??""),[Fe,nt]=(0,o.useState)(()=>ls.safeParse(t?.agentAppearance).data??Pr()),[ce,Gr]=(0,o.useState)(t?.agentRole||"general"),Jt=t?.adapterType==="paperclip_runner"&&t?.onboardingCopilot===!0,[r,qn]=(0,o.useState)(()=>_l(t?.adapterType,t?.runnerProvider,t?.onboardingCopilot)),[j,tt]=(0,o.useState)(()=>Jt?"auto":t?.runner==="legacy"||t?.runner==="paperclip"?t.runner:t?.adapterType==="paperclip_runner"&&(t?.runnerProvider===void 0||["codex","claude","acpx","opencode","pi"].includes(String(t?.runnerProvider)))?"paperclip":"auto"),[qe,Bn]=(0,o.useState)(()=>t?.step===4&&t.adapterType==="claude_local"&&t.credentialMode==="subscription"&&typeof t.createdCompanyId=="string"&&(!Kn||Kn===t.createdCompanyId)&&typeof t.openedClaudeSessionId=="string"?t.openedClaudeSessionId:null),[bn,nn]=(0,o.useState)(!!qe),[wo,Eo]=(0,o.useState)(null),Yr=(0,o.useRef)(null),[Wr,Io]=(0,o.useState)(null),[tn,rt]=(0,o.useState)(),Ro=t?.adapterType==="paperclip_runner"&&!Jt,[Jr,Ol]=(0,o.useState)(t?.cwd??""),[G,te]=(0,o.useState)(Jt||Ro&&t?.runnerProvider!==void 0&&!["codex","claude","acpx","opencode","pi"].includes(String(t.runnerProvider))?"":t?.model??""),[Be,Zt]=(0,o.useState)(t?.adapterType==="paperclip_runner"?"":t?.command??""),[rn,Xt]=(0,o.useState)(t?.adapterType==="paperclip_runner"?"":t?.args??""),[Ue,at]=(0,o.useState)(t?.adapterType==="paperclip_runner"?"":t?.url??""),[re,er]=(0,o.useState)(null),[No,an]=(0,o.useState)(null),[He,vn]=(0,o.useState)(!1),[Lo,Zr]=(0,o.useState)(!1),[nr,tr]=(0,o.useState)(!1),[jl,Tl]=(0,o.useState)(!1),[rr,ot]=(0,o.useState)((t?.credentialModeChoice!==void 0?t.credentialModeChoice:t?.credentialMode)??null),[h,W]=(0,o.useState)(qe?"ready":"idle"),[it,xn]=(0,o.useState)(null),[on,ar]=(0,o.useState)(null),[st,or]=(0,o.useState)(null),[_e,ir]=(0,o.useState)(""),[kl,Xr]=(0,o.useState)(null),[a,lt]=(0,o.useState)(Kn??t?.createdCompanyId??null),q=ji(a,fe(r),C&&l===4),ee=q.subscriptions.find(e=>e.aiConnection?.mode==="responsible_user")??(q.subscriptions.length===1?q.subscriptions[0]:void 0),[Ae,sr]=(0,o.useState)(null),Oo=Ae?.companyId===a&&Ae?.envKey===fe(r)?Ae.id:q.options[0]?.id,Y=q.options.find(e=>e.id===Oo),f=rr??(q.subscriptions.length>0||r==="claude_local"&&q.storedLogin.data?"subscription":q.options.length||r==="opencode_local"?"api":"subscription"),lr=xi({open:C,step:l,connectOutcome:f==="api"?"api_key":"subscription"}),[Un,ct]=(0,o.useState)(t?.createdCompanyPrefix??null),[v,sn]=(0,o.useState)(t?.createdAgentId??null),[K,ln]=(0,o.useState)(t?.setupAgentId??null),[ge,Hn]=(0,o.useState)(!1),[ze,dt]=(0,o.useState)(!1),[jo,ut]=(0,o.useState)(0),je=(0,o.useRef)(new Set),ea=(0,o.useRef)(new Set),[T,na]=(0,o.useState)(null),Cn=(0,o.useRef)(Promise.resolve()),[ta,ra]=(0,o.useState)(t?.createdCompanyGoalId??null),cr=(0,o.useRef)(null),Sn=(0,o.useRef)(null),dr=(0,o.useRef)(!1),Ve=(0,o.useRef)(null),zn=(0,o.useRef)(0),cn=(0,o.useRef)(!1),pt=(0,o.useRef)(!1),de=(0,o.useRef)(null),Te=(0,o.useRef)(null),ft=(0,o.useRef)(new Map),O=hs(r),$e=O==="anthropic"||O==="openai"||O==="xai"||O==="google"&&r==="antigravity_runtime"?O:void 0;function Q(){if(f==="api"&&tn?.companyId===a&&tn.adapterType===r)return tn.binding;const e=T?.companyId===a&&Z(T.adapterType,T.adapterConfig)===Z(r,{})?T.runtimeConfig?.aiConnection:void 0;if(!Ae&&!_e.trim()){if(e?.method===(f==="api"?"api_key":"subscription"))return e;if((T?.companyId===a&&Z(T.adapterType,T.adapterConfig)===Z(r,{})?T.adapterConfig.env:void 0)?.[f==="api"?fe(r):"CODEX_HOME"])return}return f==="api"?Y?.aiConnection??(!Y&&de.current?.companyId===a&&de.current.envKey===fe(r)?de.current.aiConnection:void 0):ee?.aiConnection??(Te.current?.companyId===a&&Te.current.binding.provider===O?Te.current.binding:void 0)}i(Q,"managedBindingForStep");const Qe=Zs(C&&l===4&&f==="api"?a:null,Q(),r),ae=Qe.connectionModels,ke=f==="api"&&tn?.companyId===a&&tn.adapterType===r,aa=JSON.stringify([a,r,j,G,Be,rn,Ue,f,_e,Ae,tn]),mt=(0,o.useRef)(null);function ur(e){mt.current={agentId:e,selection:aa,defaultRevision:ft.current.get(JSON.stringify([a,O]))?.revision??0}}i(ur,"rememberConnectedSelection"),v&&mt.current?.agentId!==v&&ur(v);const To=ke&&!Qe.refreshing&&!!(Qe.error||!ae&&!Qe.loading),oa=!ke&&!ae||!!(ae&&(!ke||!Qe.error&&!Qe.refreshing)&&G.trim()&&(ae.models.length===0||ae.models.some(e=>e.id===G.trim())));Sn.current=a;const _n=(0,o.useRef)(void 0);_n.current=en.initialStep;const ia=(0,o.useRef)(null);function sa(){qe&&(Bn(null),nn(!1),W("idle")),na(null),rt(void 0),nt(Pr()),ct(null),et(""),ra(null),sn(null),ln(null),Hn(!1),dt(!1)}i(sa,"clearCompanyScopedState"),(0,o.useEffect)(()=>{const e=en.companyId??null,s=ia.current;if(ia.current={open:C,companyId:e,hasOpened:s?.hasOpened===!0||C},!C||s?.open&&s.companyId===e)return;const c=s?.hasOpened!==!0,p=c&&!d&&t!==null&&typeof t.step=="number"&&t.step>=1&&t.step<=5&&(e?e===t.createdCompanyId:!De);if(_n.current&&!p&&(B(_n.current),Wt(_n.current)),s?.open||lr.opened(_n.current&&!p?_n.current:l,l),e){(e!==Sn.current||c&&typeof t?.createdCompanyId=="string"&&e!==t.createdCompanyId)&&(lt(e),sa()),cr.current=e;return}(cr.current||c&&De&&t?.createdCompanyId)&&(lt(null),cr.current=null,sa())},[C,en.companyId]),(0,o.useEffect)(()=>{if(!C||!a||Un)return;const e=m.find(s=>s.id===a);e&&ct(e.issuePrefix)},[C,a,Un,m]),(0,o.useEffect)(()=>{if(!C||l===1||!a||Oe)return;const e=m.find(s=>s.id===a);e&&et(e.name)},[C,l,a,Oe,m]),(0,o.useEffect)(()=>{if(!C)return;const e={step:l,companyName:Oe,agentName:U,agentAppearance:Fe,agentRole:ce,adapterType:r,runner:j,cwd:Jr,model:G,command:Be,args:rn,url:Ue,credentialMode:f,credentialModeChoice:rr,openedClaudeSessionId:qe,createdCompanyId:a,createdCompanyPrefix:Un,createdAgentId:v,setupAgentId:K,createdCompanyGoalId:ta};Qt.write(JSON.stringify(e))},[C,l,Oe,U,Fe,ce,r,j,Jr,G,Be,rn,Ue,f,rr,qe,a,Un,v,K,ta]);const Pe=el()(r),{data:An=[],isSuccess:ko,isFetching:la,isError:Po,refetch:Do}=ve({queryKey:a?N.environments.list(a):["environments","none"],queryFn:i(()=>Zn.list(a),"queryFn"),enabled:!!a&&C&&l===4}),{data:gt,isSuccess:Mo,isFetching:ca,isError:Ko,refetch:Fo}=ve({queryKey:N.instance.settings,queryFn:i(()=>Kt.get(),"queryFn"),enabled:C&&l===4}),{data:yt,isSuccess:qo,isFetching:da,isError:Bo,refetch:Uo}=ve({queryKey:N.instance.experimentalSettings,queryFn:i(()=>Kt.getExperimental(),"queryFn"),enabled:C&&l>=3&&l<=5}),ua=yt?.enableCloudTrialInference===!0,{data:Vn}=ve({queryKey:N.cloudInference.status(a??"__none__"),queryFn:i(()=>Ga.getStatus(a),"queryFn"),enabled:C&&l===4&&!!a&&ua}),Ho=ua&&!!Vn&&(Vn?.status==="not_issued"||Vn?.status==="active"),[pr,pa]=(0,o.useState)(!1),fa=(0,o.useRef)(new Set);(0,o.useEffect)(()=>{!C||l!==4||!a||fa.current.has(a)||(fa.current.add(a),Ga.trackTelemetry(a,{event:"onboarding_exposure",surface:"onboarding_wizard"}).catch(()=>{}))},[C,l,a]);async function zo(){if(!(!a||pr||M)){pa(!0),L(null);try{const e=U.trim()||hn[ce],s=co(Vn?.defaultModel);await Cn.current.catch(()=>{});const c=await z.hire(a,{...K?{setupAgentId:K}:{},name:e,appearance:Fe,role:ce,...T?.companyId===a?{reportsTo:T.reportsTo}:{},adapterType:"paperclip_runner",adapterConfig:{provider:"opencode",model:s},onboardingFirstAgent:!0,...T?.companyId===a&&T.defaultEnvironmentId?{defaultEnvironmentId:P}:{},runtimeConfig:{...Bt({heartbeatEnabled:!1}),cloudTrialInference:!0}});c.approval&&(await Ua.approve(c.approval.id,"Approved during onboarding starter-credit setup."),_.invalidateQueries({queryKey:N.approvals.list(a)})),_.invalidateQueries({queryKey:N.agents.list(a)}),_.invalidateQueries({queryKey:N.cloudInference.status(a)}),sn(c.agent.id),B(5)}catch(e){L(e instanceof Error?e.message:"Could not start right away")}finally{pa(!1)}}}i(zo,"handleStartWithCloudTrial");const P=(0,o.useMemo)(()=>{try{return{environmentId:Ha({agentDefaultEnvironmentId:T?.companyId===a?T.defaultEnvironmentId:null,instanceDefaultEnvironmentId:gt?.defaultEnvironmentId??null,localDefaultEnvironmentId:eo(An),managedSandboxOnly:yt?.enableManagedSandboxOnly===!0,managedSandboxEnvironmentId:so(An),visibleEnvironmentIds:An.map(e=>e.id)}),error:null}}catch(e){return{environmentId:null,error:e instanceof Error?e.message:"Could not resolve the execution environment."}}},[T,a,gt?.defaultEnvironmentId,An,yt?.enableManagedSandboxOnly]).environmentId,fr=ko&&Mo&&qo&&!la&&!ca&&!da,Ge=ve({queryKey:N.adapters.availability(a,P),queryFn:i(()=>Ut.list({companyId:a,environmentId:P}),"queryFn"),enabled:!!a&&C&&l===4&&fr}),Vo=Vs(Ge),{data:ht,error:mr,isLoading:$o,isFetching:Qo}=ve({queryKey:a?N.agents.adapterModels(a,r,null):["agents","none","adapter-models",r,null],queryFn:i(()=>z.adapterModels(a,r,{environmentId:null}),"queryFn"),enabled:!!a&&C&&l===4&&Ht.has(r)}),bt=["codex_local","claude_local","opencode_local","pi_local"].includes(r)&&j==="auto",$n=j==="auto"?Ge.data?.find(e=>e.type===r)?.defaultRunner:j,dn=!bt||fr&&Ge.isSuccess&&!Ge.isFetching&&$n!==void 0,ma=bt&&(Po||Ko||Bo)?"Could not load execution environment settings. Retry setup.":bt&&Vo.kind==="error"?"Could not load runner availability. Retry setup.":bt&&Ge.isSuccess&&$n===void 0?"Runner availability is missing for this harness. Retry setup.":null;async function Go(){fr?await Ge.refetch():await Promise.all([Do(),Fo(),Uo()])}i(Go,"retryRunnerAvailability");const vt=No??ma,gr=JSON.stringify([a,P,r,j,r==="codex_local"&&j==="auto"?void 0:$n]),ga=(0,o.useRef)(gr);ga.current=gr;const Ye=(0,o.useMemo)(()=>An.find(e=>e.id===P)??null,[An,P]),xt=JSON.stringify([a,r,j,$n,G,Be,rn,Ue,f,_e,Ae,Y?.binding,ee?.binding,P,Ye?.config]),yr=(0,o.useRef)(xt);yr.current=xt;const Qn=(0,o.useRef)(null);(0,o.useEffect)(()=>{const e=Qn.current;!e||e.selection===xt||(Qn.current=null,zn.current++,Ve.current=null,cn.current=!0,$(!1),vn(!1),L("Configuration changed during setup. Connect again to test the current settings."))},[xt]);const Ct=(0,o.useRef)(""),hr=(0,o.useRef)(null);Ct.current=r==="codex_local"&&j==="auto"&&Ye?.driver==="sandbox"?JSON.stringify([a,r,j,G,Be,rn,Ue,f,_e,Ae,Y?.binding,ee?.binding,P,Ye.config]):"";const{data:Yo}=ve({queryKey:a?N.environments.capabilities(a):["environment-capabilities","none"],queryFn:i(()=>Zn.capabilities(a),"queryFn"),enabled:!!a&&Pe.login!=null&&C&&l===4}),Wo=Ki(Ye,Yo,r),wn=ve({queryKey:N.health,queryFn:is.get}),br=!!(wn.data?.localAiLoginSupported??wn.data?.deploymentMode==="local_trusted"),ya=!!wn.data?.hostedGoogleAiLoginSupported,En=!!$e&&($e==="google"&&ya||Ye?.driver==="local"&&br),Jo=$e==="google"&&ya?br?"optional":!0:!1,ue=Zi(a,{provider:$e??"anthropic",method:"subscription",name:`My ${yn[r]??O} subscription`,ownership:"personal",agentIds:[],allAgents:!0},bn&&(ge||!!v)&&C&&l===4&&En&&f!=="api"&&!!O&&!ee&&!q.storedLogin.data&&!Q(),r==="claude_local"?qe:null);(0,o.useEffect)(()=>(cn.current=!1,Ve.current=null,l===4&&($(!1),vn(!1)),()=>{zn.current++}),[C,a,r,f,l]);const un=!!(Pe.login!=null&&P&&a&&Wo),In=un&&Pi(Ye),Rn=v??K,St=ve({queryKey:N.agents.detail(Rn??"none"),queryFn:i(()=>z.get(Rn,a),"queryFn"),enabled:In&&!!Rn&&f!=="api"&&C&&l===4,refetchInterval:i(e=>{const s=e.state.data;if(e.state.status==="error")return!1;const c=gt?.defaultEnvironmentId??null;return s&&(s.lifecycleError||Si(s,P,c)||wi(s,P,c))?!1:1e3},"refetchInterval")}),_t=St.data?.id===Rn?St.data:null,ha=Ci({required:In,agent:_t,environmentId:P,instanceDefaultEnvironmentId:gt?.defaultEnvironmentId??null}),At=ha.ready,ba=In&&ha.ownComputer,vr=In&&!At&&St.isError,xr=!In||At?null:vr?"Could not check your agent's computer.":_t?.lifecycleError??null,[va,xa]=(0,o.useState)(!1);async function Zo(){if(!(!a||va)){xa(!0);try{if(vr||!_t){await St.refetch();return}const e=await z.retryLifecycle(_t.id,a);_.setQueryData(N.agents.detail(e.id),e),L(null)}catch(e){L(e instanceof Error?e.message:"Could not retry preparing your agent's computer.")}finally{xa(!1)}}}i(Zo,"retryLoginComputer");const Nn=ve({queryKey:a?N.agents.authSignal(a,r,P):["agents","none","auth-signal",r,P],queryFn:i(()=>z.getAdapterAuthSignal(a,r,P??void 0),"queryFn"),enabled:!!a&&C&&l===4&&un}).data?.status??null,Xo=un&&(Nn==="absent"||Nn==="unknown"),Ca=$e?{provider:$e,method:"subscription",name:`My ${yn[r]??O} subscription`,ownership:"personal",agentIds:[],allAgents:!0}:void 0,Sa={environmentId:P??"",aiConnection:Ca},wt=(0,o.useRef)(new Set),Et=JSON.stringify([a,r]),_a=ve({queryKey:a?N.agents.activeLoginSession(a,r):["agents","none","active-login-session",r],queryFn:i(async({signal:e})=>{try{const s=Pe.login?.panelMode==="submitted_browser_code"?await z.getActiveClaudeSetupTokenLoginSession(a,{signal:e}):await z.getActiveAdapterAuthLoginSession(a,r,{signal:e});return s&&wt.current.has(Et)?(Js(s,Sa)&&await es(a,r,Pe.login?.panelMode==="submitted_browser_code",s.sessionId),null):s}catch(s){if(s instanceof oo&&s.status===404)return null;throw s}},"queryFn"),enabled:!!a&&C&&l===4&&un&&!wt.current.has(Et)});(0,o.useEffect)(()=>{wt.current.has(Et)||!_a.data||f==="api"||ee||q.storedLogin.data||(nn(!0),W(e=>e==="idle"?"loading":e))},[_a.data,f,ee,q.storedLogin.data]);const ei=un&&Nn===null,Aa=Pe.supportsInstructionsBundle||Pe.supportsSkills||Pe.supportsLocalAgentJwt||r==="claude_local"||r==="codex_local"||r==="gemini_local"||r==="kimi_local"||r==="opencode_local"||r==="pi_local"||r==="cursor",{recommendedAdapters:We,moreAdapters:wa}=(0,o.useMemo)(()=>{const e=ds().filter(s=>Ht.has(s.type)&&!Le.has(s.type)&&ns(s.type)).map(s=>({...Bi(s.type),type:s.type}));return{recommendedAdapters:e.filter(s=>s.recommended),moreAdapters:e.filter(s=>!s.recommended)}},[Le]),oe=bn&&We.some(e=>e.type===r),Ln=!!(ee||q.storedLogin.data||f!=="api"&&Q()),It=f!=="api"&&!un&&!ei,Cr=It&&!Ln&&ue.status!=="ready"&&!(En&&O),ni=T?.companyId===a&&Z(T.adapterType,T.adapterConfig)===Z(r)&&!Ae&&T.adapterConfig.env?.[fe(r)],Rt=!!(ge||v)&&oe&&!He&&!q.loading&&dn&&!Cr&&oa,Sr=Ce&&Yt?vl(Ce,window.location.origin):null,pn=!!(Sr&&a&&!bn&&!K&&!v&&wo!==a),_r=(0,o.useRef)(pn);_r.current=pn,(0,o.useEffect)(()=>{if(l!==3||!a||!K||v||ge||je.current.has(a)||ze)return;const e=a,s=K;je.current.add(e),z.get(s,e).then(c=>{!ye(e)||c.id!==s||c.companyId!==e||c.pauseReason!=="setup"||c.metadata?.setupAdapterPending!==!0||(c.name!==hn[c.role]&&Fn(p=>p.trim()?p:c.name),Hn(!0))}).catch(()=>{}).finally(()=>{je.current.delete(e),ut(c=>c+1)})},[l,a,K,v,ge,ze]),(0,o.useEffect)(()=>{if(l!==3||!a||!X||K||v||ge||je.current.has(a)||ea.current.has(a)||ze||pn)return;const e=a;ea.current.add(e),je.current.add(e);const s=crypto.randomUUID();(async()=>{if((await z.list(e)).some(p=>p.status!=="terminated"))return null;const c=Le.has("process")?We[0]?.type:"process";return!c||!ye(e)||_r.current?null:(ln(s),z.create(e,{setupId:s,name:hn[ce],appearance:Fe,role:ce,adapterType:c,adapterConfig:{},metadata:{setupAdapterPending:!0},onboardingFirstAgent:!0,runtimeConfig:Bt({heartbeatEnabled:!1})}))})().then(c=>{!c||!ye(e)||(ln(c.id),c.pauseReason!=="setup"&&c.status!=="pending_approval"&&sn(c.id),Hn(!0),_.invalidateQueries({queryKey:N.agents.list(e)}))}).catch(()=>{ye(e)&&ln(c=>c===s?null:c)}).finally(()=>{je.current.delete(e),ut(c=>c+1)})},[l,a,X,K,v,ge,ze,pn]),(0,o.useEffect)(()=>{if(l!==4||!a||!U.trim()||!X||pn||v||ge||je.current.has(a)||ze||!oe&&Wr===JSON.stringify([a,U.trim().toLowerCase()]))return;const e=a;je.current.add(e);const s=K??crypto.randomUUID();let c=!!K;(async()=>{if(!K){const A=(await z.list(e)).filter(E=>E.status!=="terminated"&&E.pauseReason!=="setup"&&E.name.trim().toLowerCase()===U.trim().toLowerCase()),w=oe?A.find(E=>Z(E.adapterType,E.adapterConfig)===Z(r)):void 0;if(w)return c=!0,w;if(!oe&&A.length)return Io(JSON.stringify([e,U.trim().toLowerCase()])),null}const p=Le.has("process")?We[0]?.type:"process";if(!oe&&!p)throw new Error("No agent adapters are available on this instance.");const u=oe?r:p;return!ye(e)||_r.current?null:(ln(s),z.create(e,{setupId:s,name:U.trim()||hn[ce],appearance:Fe,role:ce,adapterType:u,...oe?{runner:j}:{},adapterConfig:{},metadata:{setupAdapterPending:!oe},onboardingFirstAgent:!0,runtimeConfig:Bt({heartbeatEnabled:!1})}))})().then(p=>{if(!(!p||!ye(e))){if(p.pauseReason==="setup"||p.status==="pending_approval"){if(ln(p.id),!c&&p.name&&Fn(u=>u.trim()===U.trim()?p.name:u),c&&p.adapterConfig){na(p),p.metadata?.setupAdapterPending===!0&&U.trim()||(Fn(p.name),Gr(p.role),nt(Hr(p.appearance,p.id)));const u=p.adapterConfig;if(p.metadata?.setupAdapterPending===!0)tt("auto"),te(""),Zt(""),Xt(""),at("");else{qn(Z(p.adapterType,u)),te(typeof u.model=="string"?u.model:""),Zt(typeof u.command=="string"?u.command:""),Xt(Array.isArray(u.args)?u.args.join(" "):""),at(typeof u.url=="string"?u.url:""),tt(Ht.has(Z(p.adapterType,u))?p.adapterType==="paperclip_runner"?"paperclip":"legacy":"auto");const A=p.runtimeConfig?.aiConnection;A?ot(A.method==="api_key"?"api":"subscription"):u.env?.[fe(r)]?ot("api"):(u.env?.CLAUDE_CODE_OAUTH_TOKEN||u.env?.CODEX_HOME)&&ot("subscription")}}}else sn(p.id);Hn(!0),_.invalidateQueries({queryKey:N.agents.list(e)})}}).catch(p=>{ye(e)&&(dt(!0),L(p instanceof Error?p.message:"Could not create agent setup."))}).finally(()=>{je.current.delete(e),ut(p=>p+1)})},[l,a,U,X,oe,Wr,dn,v,ge,jo,pn]);const pe=!!(f!=="api"&&(it||Xo&&!ee&&!(r==="claude_local"&&q.storedLogin.data))&&!q.loading&&a&&P);Pe.login?.panelMode;const ti=h!=="idle"&&h!=="unwindRow"&&oe,Gn=oe&&!ge&&!v&&!ze?"Creating your agent…":pe&&!At&&!xr?"Preparing your agent's computer…":He?"Testing connection…":M?"Connecting…":null,Ea=f==="api"||pe||It||!!Gn,Je=Ea&&(h==="loading"||h==="ready"||h==="waiting"||h==="connecting"),Nt=Je||Ea&&h==="unwindCard",Ia=Nt||h==="unwindRoom",ri=h==="idle"||h==="collapsing"||h==="unwindRoom"||h==="unwindRow",Ra=h==="idle"||h==="unwindRow",we=(0,o.useRef)(null),[Yn,On]=(0,o.useState)(!1),Na=(0,o.useRef)("waiting"),Ar=pe&&h!=="idle"&&h!=="connecting"||bn&&En&&f==="subscription"&&!Ln&&!Q()&&ue.status!=="ready";(0,o.useEffect)(()=>{!C||l!==4||h!=="ready"||!Rt||pe||Yn||f!=="subscription"||r!=="claude_local"&&r!=="codex_local"||!Ln&&ue.status!=="ready"&&Nn!=="present"||M||cn.current||(cn.current=!0,Or())},[C,l,h,Rt,pe,Yn,f,r,Ln,ue.status,Nn,M]),(0,o.useEffect)(()=>{if(l===4){if(h==="collapsing"){const e=setTimeout(()=>W(f==="api"||!pe?"ready":"loading"),Dn(Za));return()=>clearTimeout(e)}if(h==="connecting"){if(!Yn||!dn)return;const e=we.current===null?0:Date.now()-we.current,s=setTimeout(()=>{Or()},Math.max(0,Ms-e));return()=>clearTimeout(s)}if(h==="unwindCard"){const e=setTimeout(()=>W("unwindRoom"),Dn(xs));return()=>clearTimeout(e)}if(h==="unwindRoom"){const e=setTimeout(()=>W("unwindRow"),Dn(As));return()=>clearTimeout(e)}if(h==="unwindRow"){nn(!1);const e=setTimeout(()=>W("idle"),Dn(Za));return()=>clearTimeout(e)}}},[l,h,f,pe,Yn,dn]);const Lt=f==="api"&&!Y&&!ke&&!ae&&(r==="claude_local"||r==="codex_local"),La=oe&&Ia&&!Gn&&f==="api"&&a&&(r==="codex_local"||r==="claude_local"),Oa=yn[r]??r,Ot=f==="subscription"&&(r==="claude_local"||r==="codex_local");function ja(){Bn(null),cn.current=!1,L(null)}i(ja,"prepareLocalLoginRetry");const jt=Ls({enabled:bn&&h==="ready"&&En&&!!O&&f==="subscription"&&!Ln&&!Q()&&It&&!pe,adapterType:r,login:ue,onBeforeRetry:ja}),Tt=jt.action,kt=Sl({passiveSubscriptionFooter:Ot&&(!!on||Tt?.kind==="retry"||!$r&&!vt),setupError:ze,retryLogin:!Ot&&!!on,connectProgress:Gn,adapterEnvLoading:He,connectPhase:h,hasSubmitLoginCode:!!st,adapterType:r,connectStepNeedsLogin:pe,connectSourceLabel:Oa,connectAuthUrl:it,localLoginAction:Tt,connectDisabled:!Rt||Ar||f==="api"&&!_e.trim()&&!Y&&!ni&&!Q()});function ai(){Bn(null),ue.cancel(),jt.resetSubmitting(),wt.current.add(Et),a&&(_.cancelQueries({queryKey:N.agents.activeLoginSession(a,r)}),un&&f!=="api"&&Li(a,r,Pe.login?.panelMode==="submitted_browser_code",Sa)),zn.current++,Ve.current=null,$(!1),vn(!1),xn(null),or(null),ar(null),we.current=null,On(!1),W(Je?"unwindCard":"unwindRow")}i(ai,"unwindConnectStep");function Ta(){h!=="ready"&&h!=="waiting"||!it||on||(window.open(it,"_blank","noreferrer,noopener"),W("waiting"))}i(Ta,"openConnectAuthorization");function Pt(){if(ze){dt(!1),ut(e=>e+1),L(null);return}if(!Cr){if(on){xn(null),or(null),ar(null),we.current=null,On(!1),W("loading"),on();return}if((h==="ready"||h==="waiting")&&st){st();return}if(h==="ready"&&pe){Ta();return}jt.runPrimary()||h!=="connecting"&&(Ar||Or())}}i(Pt,"handleConnectStepPrimary"),(0,o.useEffect)(()=>{if(!X)return;const e=[...We,...wa].filter(c=>!c.comingSoon);if(e.length===0){Ht.has(r)||(qn("claude_local"),te(""),nn(!1));return}if(e.some(c=>c.type===r))return;const s=e[0].type;if(qn(s),nn(!1),s==="opencode_local"){te(Rs);return}if(s==="gemini_local"){te($i);return}if(s==="cursor"){te(Wi);return}te("")},[X,We,wa,r]);const jn=Be.trim()||({claude_local:"claude",codex_local:"codex",gemini_local:"gemini",kimi_local:"kimi",pi_local:"pi",cursor:"agent",opencode_local:"opencode"}[r]??r.replace(/_local$/,""));(0,o.useEffect)(()=>{l===4&&(er(null),pt.current=!1,hr.current!==Ct.current&&an(null))},[l,r,j,G,Be,rn,Ue,f,_e,Ae,Y?.id,ee?.id,a,tn,P,j==="auto"?Ge.data?.find(e=>e.type===r)?.defaultRunner:void 0]),(0,o.useEffect)(()=>{l!==4&&(Bn(null),W("idle"),xn(null),nn(!1),we.current=null,On(!1))},[l]),(ht??[]).find(e=>e.id===G);const oi=re?.checks.some(e=>e.code==="claude_anthropic_api_key_overrides_subscription")??!1,ii=r==="claude_local"&&re?.status==="fail"&&oi,wr=(0,o.useMemo)(()=>{const e=Qr.trim().toLowerCase();return(ht??[]).filter(s=>{if(!e)return!0;const c=Wa(s.id,"");return s.id.toLowerCase().includes(e)||s.label.toLowerCase().includes(e)||c.toLowerCase().includes(e)})},[ht,Qr]);(0,o.useMemo)(()=>{if(r!=="opencode_local")return[{provider:"models",entries:[...wr].sort((s,c)=>s.id.localeCompare(c.id))}];const e=new Map;for(const s of wr){const c=Wa(s.id),p=e.get(c)??[];p.push(s),e.set(c,p)}return Array.from(e.entries()).sort(([s],[c])=>s.localeCompare(c)).map(([s,c])=>({provider:s,entries:[...c].sort((p,u)=>p.id.localeCompare(u.id))}))},[wr,r]);function ka(){Qt.clear(),B(1),$(!1),L(null),et(""),Fn(""),nt(Pr()),Gr(xl),qn("claude_local"),tt("auto"),te(""),Zt(""),Xt(""),at(""),er(null),pt.current=!1,an(null),vn(!1),Zr(!1),tr(!1),Xr(null),lt(null),ct(null),sn(null),ln(null),Hn(!1),dt(!1),ra(null)}i(ka,"reset");function si(){lr.dismissed(l),ka(),g(),x(!0)}i(si,"handleClose");function ye(e){return Sn.current===e}i(ye,"stillTheSameCompany");function li(e,s){const c=Sn.current;return c===e||c===s?!0:(L("Organization created, but onboarding switched to another organization."),!1)}i(li,"canCommitCreatedCompany");const Dt=(0,o.useRef)(void 0),Er=(0,o.useCallback)((e,s)=>{const c=`${e}:${s}`,p=Dt.current;if(p?.key===c)return p;const u={key:c,issue:ro.startOnboarding(e,s),warming:!1};return Dt.current=u,u.issue.catch(()=>{Dt.current===u&&(Dt.current=void 0)}),u},[]);(0,o.useEffect)(()=>{if(!C||l!==5||!a||!v)return;const e=Er(a,v);e.warming||(e.warming=!0,e.issue.then(()=>ro.greet(a,v)).catch(()=>{}))},[C,l,a,v,Er]);async function Pa(){if(!a||!v){L(yo);return}$(!0),L(null),kr("review");try{if(await Er(a,v).issue,kr("launch","succeeded"),!ye(a))return;lr.finished();const e=Un,s=v;k(a,{source:"route_sync"}),ka(),g(),V(`${e?`/${e}`:""}/chats/${s}`,{state:{onboardingWelcome:!0}})}catch(e){kr("launch","failed"),gn({step:"launch",reason:"launch_failed"}),L(e instanceof Error?e.message:"Failed to open your chat. Please try again.")}finally{$(!1)}}i(Pa,"handleLaunchToChat");async function ci(e,s=()=>!0){const c=_e.trim(),p=fe(r),u=de.current?.key===c&&de.current.companyId===e&&de.current.envKey===p?de.current:null;if(u?.binding)return!0;try{if(O){const w=u?.grantId??(await Ft.create(e,{provider:O,method:"api_key",name:`My ${yn[r]??O} API`,ownership:"personal",apiKey:c,agentIds:[],allAgents:!0})).grantId;return de.current={key:c,companyId:e,envKey:p,grantId:w},!s()||!await Ir(e,O,w,s)?!1:(de.current={key:c,companyId:e,envKey:p,grantId:w,aiConnection:{provider:O,method:"api_key",mode:"responsible_user"}},!0)}const A=await Es(e,p,c);return de.current={key:c,companyId:e,envKey:p,binding:A.binding},!0}catch(A){return s()&&(gn({step:"connect_model",reason:"api_key_save_failed",provider:O??r,method:"api_key"}),L(A instanceof Error?`Could not store the API key: ${_s(A).body}`:"Could not store the API key.")),!1}}i(ci,"storeApiKeyUserSecret");function Ir(e,s,c,p,u){const A=JSON.stringify([e,s]);let w=ft.current.get(A);w||(w={pending:Promise.resolve(),queued:0,revision:0},ft.current.set(A,w));const E=w;E.revision++,E.queued++;const S=E.pending.then(async()=>{if(!p())return!1;if(u===c&&(E.grantId===void 0||E.grantId===c))return!0;E.grantId=null;try{await Ft.setDefault(e,c),E.grantId=c}finally{_.invalidateQueries({queryKey:["ai-connections",e]})}return p()}).finally(()=>{E.queued--});return E.pending=S.catch(()=>{}),S}i(Ir,"selectManagedDefault");async function di(e,s){const c=Q();if(c?.mode!=="responsible_user")return;const p=Te.current?.companyId===e&&Te.current.binding.provider===c.provider?Te.current:null;let u=p?.grantId;!u&&p?.sessionId&&(u=(await Ft.loginResult(e,p.sessionId)).grantId);const A=ee?.aiConnection?.mode==="responsible_user"&&ee.id.startsWith("ai:")?ee.id.slice(3):void 0;if(u??=A,!u){const w=await Ft.list(e);if(!s())return;const E=w.connections.filter(S=>S.provider===c.provider&&S.method==="subscription"&&S.ownership==="personal"&&S.ownerUserId===w.currentUserId&&S.status==="connected");u=(E.find(S=>S.isDefault)??(E.length===1?E[0]:void 0))?.grantId}if(s()){if(!u)throw new Error("Choose a subscription account in Connections, then retry setup.");Te.current={companyId:e,binding:c,grantId:u},await Ir(e,c.provider,u,s,A)}}i(di,"selectManagedSubscription");function Wn(e=!1,s,c){const p=Fi(r),u=c??T,A=u?.companyId===a&&Z(u.adapterType,u.adapterConfig)===Z(r)?u.adapterConfig:{},w=p.buildAdapterConfig({...$a,adapterType:r,runner:j,...r==="pi_local"?{adapterSchemaValues:A}:{},resolvedRunner:s??$n,model:r==="gemini_local"?G||"auto":r==="kimi_local"?G||"kimi-code/kimi-for-coding":r==="cursor"?G||"auto":r==="opencode_local"?G||"openai/gpt-5.2-codex":G,command:Be,args:rn,url:Ue,dangerouslySkipPermissions:r==="claude_local"||r==="opencode_local",dangerouslyBypassSandbox:r==="codex_local"?j==="legacy"&&!0:$a.dangerouslyBypassSandbox}),E={...A.env??{}};r==="codex_local"&&(c||Q())&&((f==="api"||Q())&&delete E.CODEX_HOME,(f==="subscription"||Q())&&delete E.OPENAI_API_KEY),r==="claude_local"&&((f==="api"||Q())&&delete E[ss],(f==="subscription"||Q())&&(delete E.ANTHROPIC_API_KEY,delete E.ANTHROPIC_AUTH_TOKEN));const S={...A,...w,...A.env||w.env?{env:{...E,...w.env??{}}}:{}};if(r==="claude_local"&&Lo){const H=typeof S.env=="object"&&S.env!==null&&!Array.isArray(S.env)?{...S.env}:{};H.ANTHROPIC_API_KEY={type:"plain",value:""},S.env=H}if(!Q()&&f==="api"&&(e||Y)&&(!A.env?.[fe(r)]||Ae||_e.trim())){const H=typeof S.env=="object"&&S.env!==null&&!Array.isArray(S.env)?{...S.env}:{};H[fe(r)]=Y?.binding??de.current?.binding,S.env=H}return f==="subscription"&&ee?.binding&&!A.env?.CODEX_HOME&&(S.env={...S.env??{},CODEX_HOME:ee.binding}),S}i(Wn,"buildAdapterConfig");function Rr(e,s){const c=s??T,{aiConnection:p,...u}=c?.companyId===a?c.runtimeConfig:{},A=Q();return{...u,...s?{}:Bt({heartbeatEnabled:e}),...A?{aiConnection:A}:{}}}i(Rr,"buildSetupRuntimeConfig");const Nr=(l===3||l===4)&&ge&&K&&!v&&!M?JSON.stringify({name:U.trim()||hn[ce],appearance:Fe,...oe&&dn?{adapterType:r,runner:j,adapterConfig:Wn(!!de.current?.binding),defaultEnvironmentId:P,runtimeConfig:Rr(!1),metadata:{...T?.metadata,setupAdapterPending:!1}}:{}}):null;(0,o.useEffect)(()=>{if(!Nr||!K||!a)return;const e=a,s=K,c=i(()=>{Cn.current=Cn.current.catch(()=>{}).then(async()=>{!ye(e)||Ve.current!==null||await z.update(s,JSON.parse(Nr),e)}),Cn.current.catch(u=>{ye(e)&&L(u instanceof Error?u.message:"Could not save agent setup.")})},"save");if(l!==3){c();return}const p=setTimeout(c,400);return()=>clearTimeout(p)},[Nr,K,a,l]);async function Da(e,s=!1,c=()=>!0,p,u){if(!dn)return null;if(!a)return an("Create or select an organization before testing adapter environment."),null;const A=Ct.current,w=u??T,E=u&&j==="auto"&&Z(u.adapterType,u.adapterConfig)===r?Ja(u.adapterType):j,S=i(()=>c()&&Ct.current===A,"selectionIsCurrent");hr.current=null,vn(!0),an(null);try{return await il(async H=>{const ne=i(()=>S()&&!H.aborted,"testIsCurrent");let he,fn,Ze;try{const[J,kn,Re]=await Promise.all([_.ensureQueryData({queryKey:N.environments.list(a),queryFn:i(()=>Zn.list(a),"queryFn")}),_.ensureQueryData({queryKey:N.instance.settings,queryFn:i(()=>Kt.get(),"queryFn")}),_.ensureQueryData({queryKey:N.instance.experimentalSettings,queryFn:i(()=>Kt.getExperimental(),"queryFn")})]);he=J,fn=kn,Ze=Re?.enableManagedSandboxOnly===!0}catch{return ne()&&(gn({step:"connect_model",reason:"environment_test_failed",provider:O??r,method:f==="api"?"api_key":"subscription"}),an("Could not load environment settings to determine which environment to test in. Retry the test.")),null}const ie=Ha({agentDefaultEnvironmentId:w?.companyId===a?w.defaultEnvironmentId:null,instanceDefaultEnvironmentId:fn?.defaultEnvironmentId??null,localDefaultEnvironmentId:eo(he),managedSandboxOnly:Ze,managedSandboxEnvironmentId:so(he),visibleEnvironmentIds:he.map(J=>J.id)});if(!ne())return null;const Mt=he.find(J=>J.id===ie),Ee=Mt?.config;if(!v&&r==="codex_local"&&j==="auto"&&Mt?.driver==="sandbox"&&typeof Ee?.image=="string"&&/^[^\s@]+@sha256:[a-f0-9]{64}$/.test(Ee.image)&&!Ee.snapshot&&!Ee.template&&!Ee.templateRef){const J=N.adapters.availability(a,ie),kn=await _.fetchQuery({queryKey:J,staleTime:0,queryFn:i(()=>Ut.list({companyId:a,environmentId:ie},{signal:H}),"queryFn")});if(!ne())return null;const Re=kn.find(be=>be.type==="codex_local"),qa=kn.find(be=>be.type==="paperclip_runner");if(!Re||Re.defaultRunner!=="paperclip"&&Re.defaultRunner!=="legacy"||!Re.supportedRunners?.includes(Re.defaultRunner))throw new Error("Could not confirm Codex runner availability for this environment. Retry setup.");if(Re.defaultRunner!=="paperclip"&&!Re?.disabled&&!Re?.overriddenBuiltin&&!qa?.disabled&&!qa?.overriddenBuiltin){const be=await Zn.probe(ie,a,{signal:H});if(!ne())return null;if(be.ok!==!0||be.details?.platformQualificationRecorded!==!0||typeof be.details.leaseId!="string"||!be.details.leaseId)throw new Error(typeof be.details?.platformQualificationDiagnostic=="string"?be.details.platformQualificationDiagnostic:be.summary||"The environment's platform qualification could not be confirmed. Retry the connection probe.");const hi=await _.fetchQuery({queryKey:J,staleTime:0,queryFn:i(()=>Ut.list({companyId:a,environmentId:ie},{signal:H}),"queryFn")});if(!ne())return null;const Ba=hi.find(bi=>bi.type==="codex_local"),Tr=Ba?.defaultRunner;if(Tr!=="paperclip"&&Tr!=="legacy"||!Ba?.supportedRunners?.includes(Tr))throw new Error("Could not confirm the environment's default runner. Retry setup.")}}if(!ne())return null;const Tn={adapterType:r,runner:j,savedAgentId:v,environment:he.find(J=>J.id===ie)},mn=await Ys({...Tn,readAdapters:i(()=>Ut.list({companyId:a,environmentId:ie},{signal:H}),"readAdapters"),probeEnvironment:i(()=>Zn.probe(ie,a,{signal:H}),"probeEnvironment"),isCurrent:ne});if(!ne()||Xa(Tn)&&!mn)return null;let R=e??Wn();mn&&(R=Wn(!0,mn.runner),s&&(R.env={...Gt(R.env)?R.env:{},...Va()}),p?.(R,mn.adapters,ie));const Ie=await z.testEnvironment(a,r,{adapterConfig:R,...w?.companyId===a?{agentId:w.id}:{},...["codex_local","claude_local","opencode_local","pi_local"].includes(r)&&E!=="auto"?{runner:E}:{},...Q()?{aiConnection:Q()}:{},environmentId:ie},{signal:H});return ne()?(Fr(Ie)&&gn({step:"connect_model",reason:"environment_test_failed",provider:O??r,method:f==="api"?"api_key":"subscription"}),er(Ie),pt.current=s,Ie):null})}catch(H){return S()&&(gn({step:"connect_model",reason:"environment_test_failed",provider:O??r,method:f==="api"?"api_key":"subscription"}),hr.current=A||null,an(H instanceof Error?H.message:"Adapter environment test failed")),null}finally{c()&&vn(!1)}}i(Da,"runAdapterEnvironmentTest");async function Lr(){if(a){B(3);return}if(dr.current)return;dr.current=!0,$(!0),L(null);const e=Sn.current;try{const s=await qi.create({name:Oe.trim()});if(_.invalidateQueries({queryKey:N.companies.all}),!li(e,s.id))return;lt(s.id),Sn.current=s.id,ct(s.issuePrefix),k(s.id),B(3)}catch(s){L(s instanceof Error?s.message:"Failed to create organization")}finally{dr.current=!1,$(!1)}}i(Lr,"handleCreateCompany");async function Or(){if(!a||!ge&&!v)return;if(!oa){L("Choose a model for this gateway connection before connecting your agent.");return}const e=ft.current.get(JSON.stringify([a,O]));if(v&&mt.current?.selection===aa&&!e?.queued&&mt.current.defaultRevision===(e?.revision??0)){B(5);return}if(!dn||Ve.current!==null)return;const s=++zn.current,c=r==="claude_local"&&j==="auto",p=yr.current;Qn.current=c?{attempt:s,selection:p}:null;const u=i(()=>zn.current===s&&ye(a)&&ga.current===gr&&(!c||yr.current===p),"isCurrent");Ve.current=s,cn.current=!0,$(!0),L(null);let A;try{if(r==="opencode_local"){const R=G.trim();if(!zi(R)){L("OpenCode requires an explicit model in provider/model format.");return}if(mr){L(mr instanceof Error?mr.message:"Failed to load OpenCode models.");return}if($o||Qo){L("OpenCode models are still loading. Please wait and try again.");return}const Ie=ht??[];if(!Ie.some(J=>J.id===R)){L(Ie.length===0?"No OpenCode models discovered. Run `opencode models` and authenticate providers.":`Configured OpenCode model is unavailable: ${R}`);return}}let w=!1;if(f==="api"&&!Y&&_e.trim()&&(w=await ci(a,u),!w||!u()))return;if(f==="api"&&Y?.aiConnection?.mode==="responsible_user"){const R=Y.id.startsWith("ai:")?Y.id.slice(3):void 0;if(!R)throw new Error("Choose a connected API account before continuing.");if(!await Ir(a,Y.aiConnection.provider,R,u,R))return}if(f!=="api"&&En&&O&&!Q()&&!ee&&!q.storedLogin.data){const R=await ue.connect();if(!u())return;Te.current={companyId:a,binding:{provider:O,method:"subscription",mode:"responsible_user"},grantId:R.grantId}}if(f==="subscription"&&await di(a,u),!u())return;const E=Q(),S=v?await z.get(v,a):void 0;if(!u())return;if(S?.runtimeConfig.aiConnection&&f==="api"&&Y?.binding&&!E)throw new Error("Choose a connected API account or Enter a new API key to replace this agent’s connected account.");const H=S&&j==="auto"&&Z(S.adapterType,S.adapterConfig)===r?Ja(S.adapterType):void 0,ne=Wn(w,H,S);let he=null;if(!E&&r==="claude_local"&&!Al(ne)){try{he=await z.getClaudeOAuthTokenStatus(a)}catch(R){if(!(R instanceof oo)||R.status!==404)throw R;he=null}if(!u())return;Xr(he)}const fn=he!==null;let Ze=fn?{...ne,env:{...Gt(ne.env)?ne.env:{},...Va()}}:ne;if(Aa){const R=(!Xa({adapterType:r,runner:j,savedAgentId:v,environment:Ye})&&re&&pt.current===fn&&!Fr(re)?re:null)??await Da(Ze,fn,u,(Ie,J,kn)=>{Ze=Ie,A={adapters:J,environmentId:kn}},S);if(!R||!u())return;if(Fr(R)){const Ie=r==="codex_local"&&R.adapterType==="paperclip_runner"?R.checks.find(J=>J.level==="error")?.message:void 0;L(Ie||(R.status==="fail"?Ce?"Microvac couldn't finish connecting this agent. Try connecting again.":"The environment test failed. Fix the reported checks before you hire this agent.":"No working authentication was found. Fix the reported checks before you hire this agent."));return}}if(!ce||!u())return;const ie=U.trim()||hn[ce];if(v&&S){if(await Cn.current.catch(()=>{}),!u()||(await z.update(v,{adapterType:r,adapterConfig:Ze,...["codex_local","claude_local","opencode_local","pi_local"].includes(r)&&(j!=="auto"||H)?{runner:H??j}:{},runtimeConfig:Rr(!0,S)},a),!u()))return;ur(v),_.invalidateQueries({queryKey:N.agents.list(a)}),_.invalidateQueries({queryKey:N.agents.detail(v)}),B(5);return}const Mt=K?null:await z.list(a).catch(()=>null);if(!u())return;const Ee=Mt?.find(R=>R.id!==K&&R.name.trim().toLowerCase()===ie.toLowerCase()&&Z(R.adapterType,R.adapterConfig)===Z(r,Ze));if(Ee){if(!u())return;sn(Ee.id),nt(Hr(Ee.appearance,Ee.id)),_.invalidateQueries({queryKey:N.agents.list(a)}),B(5);return}if(await Cn.current.catch(()=>{}),!u())return;const Tn=await z.hire(a,{...K?{setupAgentId:K}:{},name:ie,appearance:Fe,role:ce,...T?.companyId===a?{reportsTo:T.reportsTo}:{},adapterType:r,adapterConfig:Ze,...["codex_local","claude_local","opencode_local","pi_local"].includes(r)&&j!=="auto"?{runner:j}:{},...fn?{applyStoredClaudeLogin:!0}:{},onboardingFirstAgent:!0,...T?.companyId===a&&T.defaultEnvironmentId?{defaultEnvironmentId:P}:{},runtimeConfig:Rr(!0)});if(!u())return;Tn.approval&&(await Ua.approve(Tn.approval.id,"Approved during onboarding first-agent setup."),_.invalidateQueries({queryKey:N.approvals.list(a)}));const mn=Tn.agent;if(_.invalidateQueries({queryKey:N.agents.list(a)}),!u())return;sn(mn.id),ur(mn.id),B(5)}catch(w){if(!u())return;gn({step:"connect_model",reason:"agent_create_failed",provider:O??r,method:f==="api"?"api_key":"subscription"}),L(w instanceof Error?w.message:"Failed to create agent")}finally{Ve.current===s&&(Ve.current=null),Qn.current?.attempt===s&&(Qn.current=null),u()&&(A&&_.setQueryData(N.adapters.availability(a,A.environmentId),A.adapters),$(!1)),Yn&&u()&&(we.current=null,xn(null),W(w=>w==="connecting"?"ready":w))}}i(Or,"handleGiveHeartbeat");async function ui(){if(!a||nr)return;tr(!0),L(null),an(null),Zr(!0);const e=(()=>{const s=Wn(),c=typeof s.env=="object"&&s.env!==null&&!Array.isArray(s.env)?{...s.env}:{};return c.ANTHROPIC_API_KEY={type:"plain",value:""},s.env=c,s})();try{v&&(await z.update(v,{adapterConfig:e},a),_.invalidateQueries({queryKey:N.agents.list(a)})),(await Da(e))?.status==="fail"&&L("Retried with ANTHROPIC_API_KEY unset in adapter config, but the environment test is still failing.")}catch(s){L(s instanceof Error?s.message:"Failed to unset ANTHROPIC_API_KEY and retry.")}finally{tr(!1)}}i(ui,"handleUnsetAnthropicApiKey");function pi(e){if(!e.defaultPrevented&&e.key==="Enter"&&(e.metaKey||e.ctrlKey)){if(e.preventDefault(),M)return;l===1&&Oe.trim()?Lr():l===3&&U.trim()?B(4):l===4&&!kt.disabled&&U.trim()&&Rt&&(on||st||Tt&&!Tt.disabled||!Ar)?Pt():l===5&&Pa()}}if(i(pi,"handleKeyDown"),!C)return null;function fi(e){return e===3?1:e-1}i(fi,"backStepFrom");const jr=po(l)!==null,mi=yt?.enableManagedSandboxOnly===!0,Ma=jr&&Ke>=3&&!mi,Ka=l===5&&(!a||!v),Jn=Dn(1)>0,gi=l===1||!F?Ya.closed:I&&le.current===Ke?Ws:Ya.open,yi=l===1||!F?Ni:l===3&&Jn&&le.current===1?Xi:Kr.animate,Fa=$r??(Ka?yo:null);return(0,n.jsx)(xo,{open:C,onOpenChange:i(e=>{e||si()},"onOpenChange"),children:(0,n.jsxs)(Fs,{children:[(0,n.jsx)("div",{className:"fixed inset-0 z-50 bg-background"}),(0,n.jsx)("div",{"data-testid":"onboarding-wizard",className:"fixed inset-0 z-50 flex",onKeyDown:pi,children:(0,n.jsx)("div",{className:"w-full flex flex-col overflow-y-auto",children:(0,n.jsxs)("div",{className:Xn("mx-auto my-auto shrink-0",jr||l===1?"w-(--sz-560px) max-w-full px-8 py-10 sm:px-10 sm:py-11":"w-full max-w-md px-8 py-12",l===4&&"pb-8 sm:pb-9"),children:[!Ma&&(0,n.jsx)(fo,{step:fl(l),total:Vt.length,labels:pl,canJumpToStep:i(e=>no({targetStep:Vt[e-1],currentStep:l,entryStep:Ke}),"canJumpToStep"),onJumpToStep:i(e=>B(Vt[e-1]),"onJumpToStep")}),Ma&&(0,n.jsx)(fo,{step:po(l),canJumpToStep:i(e=>no({targetStep:Vr[e-1],currentStep:l,entryStep:Ke}),"canJumpToStep"),onJumpToStep:i(e=>B(Vr[e-1]),"onJumpToStep")}),(l===1||l>=3&&l<=5)&&(0,n.jsx)(Ai,{reducedMotion:"user",children:(0,n.jsxs)("div",{className:"mb-9",children:[(0,n.jsx)(me.div,{className:"overflow-hidden",initial:!1,animate:gi,"aria-hidden":l===1||void 0,children:(0,n.jsxs)(me.div,{initial:Kr.initial,animate:yi,transition:Kr.transition,className:"flex flex-col items-center gap-2 pb-6",children:[(0,n.jsx)("div",{className:"relative size-(--sz-160px)",children:(0,n.jsx)(dl,{appearance:Fe,awake:l===5,className:"size-full"})}),(0,n.jsx)(ml,{agentName:U,agentRole:""})]})}),(0,n.jsx)(_i,{center:!0,title:(0,n.jsx)(me.span,{...to,className:"inline-block",children:l===1?"What is the name of your organization?":l===3?"Create your first agent":l===4?"Connect a model":"Let's get started..."},l)}),(0,n.jsx)(me.div,{className:"overflow-hidden text-center",initial:!1,animate:l===1||l===3?za.closed:za.open,"aria-hidden":l===1||l===3||void 0,children:(0,n.jsx)("p",{className:"pt-2 text-base leading-relaxed text-muted-foreground",children:(0,n.jsx)(me.span,{...to,className:"inline-block",children:l===4?"Microvac works with your subscription or API keys.":`${U.trim()||"Your first agent"} is ready to work!`},l)})})]})}),(0,n.jsxs)(Yi,{mode:Jn?"wait":"sync",initial:I,children:[l===1&&(0,n.jsx)(me.div,{...Pn,exit:Jn?Pn.exit:void 0,className:"mx-auto flex w-full flex-col gap-9",children:(0,n.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,n.jsx)(ao,{htmlFor:"onboarding-company-name",children:"Name"}),(0,n.jsx)(zr,{id:"onboarding-company-name","aria-describedby":"onboarding-company-name-hint",className:"h-(--sz-44px) rounded-lg border-transparent bg-muted shadow-none dark:bg-muted",placeholder:"e.g. Acme Co., Marketing department, Bob's team",value:Oe,onChange:i(e=>et(e.target.value),"onChange"),onKeyDown:i(e=>{e.key==="Enter"&&Oe.trim()&&(e.preventDefault(),Lr())},"onKeyDown"),autoFocus:!0}),(0,n.jsx)("p",{id:"onboarding-company-name-hint",className:"text-sm text-muted-foreground",children:"You can always change this later"})]})},"step-1"),l===3&&(0,n.jsx)(me.div,{...Pn,exit:Jn?Pn.exit:void 0,className:"mx-auto flex w-full flex-col gap-9",children:(0,n.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,n.jsx)(ao,{htmlFor:"onboarding-agent-name",children:"Agent name"}),(0,n.jsx)(zr,{id:"onboarding-agent-name",className:"h-(--sz-44px) rounded-lg border-transparent bg-muted shadow-none dark:bg-muted",placeholder:"e.g. Chief of staff",value:U,onChange:i(e=>Fn(e.target.value),"onChange"),onKeyDown:i(e=>{e.key==="Enter"&&!e.nativeEvent.isComposing&&U.trim()&&(e.preventDefault(),B(4))},"onKeyDown"),autoFocus:!0})]})},"step-3"),l===4&&(0,n.jsxs)(me.div,{...Pn,exit:Jn?Pn.exit:void 0,className:"space-y-8",children:[Ho&&h==="idle"&&(0,n.jsx)("div",{className:"rounded-xl border border-border bg-card p-4 shadow-xs space-y-3",children:(0,n.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(Oi,{className:"size-4 text-primary"}),(0,n.jsx)("span",{className:"text-sm font-semibold text-foreground",children:"Start right away"}),(0,n.jsx)(Mi,{variant:"secondary",className:"rounded-full text-xs",children:co(Vn?.defaultModel).split("/").pop()??"Starter"})]}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try Microvac right away without connecting an account. We’ll ask you to connect a model provider when it’s time to continue."})]}),(0,n.jsx)(Ne,{size:"sm",onClick:zo,disabled:pr||M,className:"shrink-0",children:pr?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(Dr,{className:"size-3.5 mr-1.5 animate-spin"}),"Starting…"]}):(0,n.jsxs)(n.Fragment,{children:["Start free",(0,n.jsx)(Di,{className:"size-3.5 ml-1.5"})]})})]})}),pn&&a&&Sr&&(0,n.jsx)(hl,{destination:Sr,onDismiss:i(()=>{Eo(a),Yr.current?.querySelector('[role="radio"]')?.focus()},"onDismiss")},a),(0,n.jsxs)("div",{ref:Yr,children:[(0,n.jsx)(zs,{label:"Model source",sources:We.map(e=>({id:e.type,label:yn[e.type]??e.label,icon:(0,n.jsx)(go,{type:e.type,Fallback:e.icon})})),mode:f,selectedId:bn&&We.some(e=>e.type===r)?r:null,collapsed:ti,settling:h==="unwindRow",onSelect:i(e=>{h!=="idle"&&h!=="unwindRow"||(cn.current=!1,nn(!0),qn(e),e!==r&&tt("auto"),(e!==r||e==="codex_local"&&f==="subscription"&&G.startsWith("claude-"))&&te(e==="opencode_local"?"openai/gpt-5.2-codex":""),W("collapsing"))},"onSelect")}),X&&We.length===0&&(0,n.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Claude and Codex are unavailable on this instance. Ask an administrator to enable one, or exit setup and choose New Agent on the Agents page to use another provider."}),(0,n.jsx)(me.div,{className:"overflow-hidden",inert:!Ra,initial:!1,animate:{opacity:Ra?1:0,height:ri?"auto":0},transition:{opacity:Gs,height:qt},children:(0,n.jsxs)("div",{className:"-ml-3 mt-1",children:[(0,n.jsx)(Ds,{mode:f,onChange:ot}),q.options.length>0&&(0,n.jsxs)("p",{className:"px-3 text-sm text-muted-foreground",children:[q.options.length," saved API ",q.options.length===1?"key available":"keys available","."]}),f==="subscription"&&Nn==="present"&&(0,n.jsx)("p",{className:"px-3 text-sm text-muted-foreground",children:"An existing provider connection is available."})]})})]}),(0,n.jsxs)(me.div,{className:"overflow-hidden",inert:!Je,initial:!1,animate:{height:Nt?"auto":0,marginTop:Nt?20:0,opacity:Je?1:0},transition:{height:qt,marginTop:qt,opacity:Je?{...$s,delay:qt.duration}:vs},children:[(0,n.jsx)(Ps.Provider,{value:Ot?(0,n.jsx)(go,{type:r,Fallback:Dr}):null,children:(0,n.jsx)(Hs.Provider,{value:Ot&&on?Pt:null,children:Ia?Gn?(0,n.jsxs)("p",{role:"status",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,n.jsx)(Dr,{className:"size-4 animate-spin"}),Gn]}):f==="api"?(0,n.jsxs)(fs,{revealTogether:Lt,instruction:(0,n.jsxs)("span",{className:"grid gap-1",children:[(0,n.jsx)("span",{children:ke||ae?"Choose a model for your saved connection":q.options.length?"Choose a saved API key or enter a new one":`Provide your ${yn[r]??r} API key to connect.`}),Lt&&(0,n.jsxs)("span",{id:"onboarding-api-account-note",children:["This will be your default ",Oa," account."]})]}),children:[!ke&&(0,n.jsx)(as,{...q,disabled:M||He,value:Y?.id??"",onChange:i(e=>{rt(void 0),ae&&te(""),sr(a?{companyId:a,envKey:fe(r),id:e}:null),ir("")},"onChange")}),!Y&&!ke&&!ae&&(0,n.jsx)(ws,{label:"API key",describedBy:Lt?"onboarding-api-account-note":void 0,description:!Lt&&O?`This will be your default ${yn[r]??O} account.`:void 0,placeholder:"Enter API key here",masked:!0,autoFocus:!0,value:_e,onChange:i(e=>{sr(a?{companyId:a,envKey:fe(r),id:""}:null),ir(e)},"onChange"),onSubmit:i(()=>Pt(),"onSubmit")}),ke&&(To?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"Your saved gateway connection could not be loaded. Retry to choose a model and connect your agent."}),(0,n.jsx)(Ne,{type:"button",variant:"outline",disabled:M||He,onClick:i(()=>{Qe.refresh()},"onClick"),children:"Retry loading connection"})]}):(0,n.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:Qe.refreshing?"Loading your saved gateway connection…":"Gateway connection saved. Choose a model, then Connect to test it and finish setting up your agent."})),ae&&(0,n.jsx)(Ss,{models:ae.models,value:G,onChange:te,open:_o,onOpenChange:Ao,allowDefault:!1,required:!0,groupByProvider:!1,creatable:ae.models.length===0,presentation:"native"}),(ke||ae)&&(0,n.jsx)(Ne,{type:"button",variant:"ghost",disabled:M||He,onClick:i(()=>{rt(void 0),sr({companyId:a,envKey:fe(r),id:""}),te("")},"onClick"),children:"Use a different API key"})]}):pe&&xr?(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:xr}),(0,n.jsx)(Ne,{type:"button",variant:"outline",disabled:va,onClick:i(()=>{Zo()},"onClick"),children:vr?"Retry":"Retry preparation"})]}):pe&&At&&a&&P?(0,n.jsx)(Ks,{companyId:a,adapterType:r,environmentId:P,requiresAgent:In,agentId:ba?Rn??void 0:void 0,chrome:"onboarding",aiConnection:Ca,autoStart:!0,active:Je,onPromptReady:i(e=>{Je&&(xn(e),e&&W(s=>s==="loading"?"ready":s))},"onPromptReady"),onOpenAuthorization:Ta,onRetryReady:i(e=>{Je&&ar(()=>e)},"onRetryReady"),onSubmitReady:i(e=>or(()=>e),"onSubmitReady"),onCodeSubmitted:i(()=>{Na.current=h,we.current=Date.now(),On(!1),W("connecting")},"onCodeSubmitted"),onSubmitFailed:i(()=>{h==="connecting"&&(we.current=null,On(!1),W(Na.current==="ready"?"ready":"waiting"))},"onSubmitFailed"),onLoginFailed:i(()=>{gn({step:"connect_model",reason:"subscription_login_failed",provider:O??r,method:"subscription"})},"onLoginFailed"),onConnected:i(e=>{$e&&(Te.current={companyId:a,binding:{provider:$e,method:"subscription",mode:"responsible_user"},sessionId:e}),xn(null),!(h!=="loading"&&h!=="ready"&&h!=="waiting"&&h!=="connecting")&&(we.current===null&&(we.current=Date.now()),On(!0),W("connecting"))},"onConnected"),onStored:i(()=>{_.invalidateQueries({queryKey:N.agents.authSignal(a,r,P)})},"onStored")},`${r}:${P}:${ba?Rn:""}`):Ln||ue.status==="ready"?null:It?En&&O?(0,n.jsx)(Bs,{adapterType:r,hostedRedirect:Jo,...jt.instructionsProps,authorizationOpened:!!(qe&&qe===ue.sessionId),onOpenAuthorization:r==="claude_local"?e=>{Bn(ue.sessionId??null),window.open(e,"_blank","noopener,noreferrer")}:void 0,login:{...ue,retry:i(()=>{ja(),ue.retry()},"retry")}}):Cr?(0,n.jsx)("p",{role:"status",className:"text-xs text-muted-foreground",children:"This environment does not support browser sign-in. Go back to use an API key or choose another model."}):null:null:null})}),La&&(0,n.jsxs)("details",{className:"mt-2 space-y-3",children:[(0,n.jsx)("summary",{className:"cursor-pointer text-sm text-muted-foreground",children:"Advanced"}),(0,n.jsx)(sl,{companyId:a,agentId:K??void 0,environmentId:P??void 0,adapterType:r,disabled:M||He,className:"-ml-3",onComplete:i(e=>{rt({companyId:a,adapterType:r,binding:e}),ir(""),te(""),L(null)},"onComplete")})]})]}),Aa&&!M&&(vt||re&&re.status!=="pass")&&(0,n.jsxs)("div",{className:"space-y-2 rounded-md border border-border p-3",children:[vt&&(0,n.jsx)("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-2.5 py-2 text-(length:--text-micro) text-destructive",children:vt}),ma&&(0,n.jsx)(Ne,{type:"button",variant:"outline",disabled:Ge.isFetching||la||ca||da,onClick:i(()=>{Go()},"onClick"),children:"Retry setup"}),re&&re.status==="pass"?(0,n.jsxs)("div",{className:"space-y-2 animate-in fade-in slide-in-from-bottom-1 duration-300",children:[(0,n.jsxs)("div",{className:"status-chip flex items-center gap-2 rounded-md border px-2.5 py-2 text-(length:--text-micro)",style:{"--sc":"var(--status-task-done)"},children:[(0,n.jsx)(vo,{className:"size-3.5 shrink-0"}),(0,n.jsx)("span",{className:"font-medium",children:"Passed"})]}),(0,n.jsx)(ho,{result:re,showHints:wn.isSuccess&&!Ce})]}):re?(0,n.jsx)(ho,{result:re,showHints:wn.isSuccess&&!Ce}):null,ii&&(0,n.jsxs)("div",{className:"rounded-md border border-amber-300/60 bg-amber-50/40 px-2.5 py-2 space-y-2",children:[(0,n.jsxs)("p",{className:"text-(length:--text-micro) text-amber-900/90 leading-relaxed",children:["Claude failed while"," ",(0,n.jsx)("span",{className:"font-mono",children:"ANTHROPIC_API_KEY"})," ","is set. You can clear it in this adapter config and retry the probe."]}),(0,n.jsx)(Ne,{size:"sm",variant:"outline",className:"h-7 px-2.5 text-xs",disabled:He||nr,onClick:i(()=>{ui()},"onClick"),children:nr?"Retrying...":"Unset ANTHROPIC_API_KEY"})]}),re&&re.status==="fail"&&wn.isSuccess&&!Ce&&(0,n.jsxs)("div",{className:"rounded-md border border-border/70 bg-muted/20 px-2.5 py-2 text-(length:--text-micro) space-y-1.5",children:[(0,n.jsx)("p",{className:"font-medium",children:"Manual debug"}),(0,n.jsx)("p",{className:"text-muted-foreground font-mono break-all",children:r==="cursor"?`${jn} -p --mode ask --output-format json "Respond with hello."`:r==="codex_local"?`${jn} exec --json -`:r==="gemini_local"?`${jn} --output-format json "Respond with hello."`:r==="kimi_local"?`${jn} -p "Respond with hello." --output-format stream-json`:r==="opencode_local"?`${jn} run --format json "Respond with hello."`:`${jn} --print - --output-format stream-json --verbose`}),(0,n.jsxs)("p",{className:"text-muted-foreground",children:["Prompt:"," ",(0,n.jsx)("span",{className:"font-mono",children:"Respond with hello."})]}),r==="claude_local"||r==="codex_local"?(0,n.jsx)("p",{className:"text-muted-foreground",children:"If authentication fails, connect your subscription in the browser above or use an API key."}):r==="cursor"||r==="gemini_local"||r==="kimi_local"||r==="opencode_local"?(0,n.jsxs)("p",{className:"text-muted-foreground",children:["If auth fails, set"," ",(0,n.jsx)("span",{className:"font-mono",children:r==="cursor"?"CURSOR_API_KEY":r==="gemini_local"?"GEMINI_API_KEY":r==="kimi_local"?"KIMI_MODEL_NAME + KIMI_MODEL_API_KEY":"OPENAI_API_KEY"})," ","in env or run"," ",(0,n.jsx)("span",{className:"font-mono",children:r==="cursor"?"agent login":r==="gemini_local"?"gemini auth":r==="kimi_local"?"kimi login":"opencode auth login"}),"."]}):(0,n.jsx)("p",{className:"text-muted-foreground",children:"If login is required, connect the provider above and retry."})]})]}),(r==="http"||r==="openclaw_gateway")&&(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:r==="openclaw_gateway"?"Gateway URL":"Webhook URL"}),(0,n.jsx)("input",{className:"w-full rounded-md border border-border bg-transparent px-3 py-2 text-sm font-mono outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50",placeholder:r==="openclaw_gateway"?"ws://127.0.0.1:18789":"https://...",value:Ue,onChange:i(e=>at(e.target.value),"onChange")})]})]},"step-4")]}),Fa&&(0,n.jsx)("div",{className:"mt-3",children:(0,n.jsx)("p",{className:"text-xs text-destructive",children:Fa})}),(jr||l===1)&&(0,n.jsx)(ms,{compact:l===4&&!!La&&Nt,onBack:l===4&&h!=="idle"?ai:Ri({currentStep:l,entryStep:Ke})?()=>B(fi(l)):void 0,primaryLabel:l===1?"Continue":l===5?"Get started":l===4?kt.label:"Next",primaryIcon:l===4?kt.icon:void 0,loadingLabel:l===1?"Creating...":l===4?"Connecting":"Launching...",loading:l===3||l===4?!1:M,primaryDisabled:l===1?!Oe.trim()||M:l===3?!U.trim():l===4?kt.disabled||M:M||Ka,onPrimary:i(()=>{l===1?Lr():l===3?B(4):l===4?Pt():Pa()},"onPrimary")})]})})})]})})}i(Nl,"OnboardingWizardInner");function ho({result:t,showHints:d}){const b=t.status==="pass"?"Passed":t.status==="warn"?"Warnings":"Failed",g=t.status==="pass"?"text-green-700 dark:text-green-300 border-green-300 dark:border-green-500/40 bg-green-50 dark:bg-green-500/10":t.status==="warn"?"text-amber-700 dark:text-amber-300 border-amber-300 dark:border-amber-500/40 bg-amber-50 dark:bg-amber-500/10":"text-red-700 dark:text-red-300 border-red-300 dark:border-red-500/40 bg-red-50 dark:bg-red-500/10";return(0,n.jsxs)("div",{className:`rounded-md border px-2.5 py-2 text-(length:--text-micro) ${g}`,children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,n.jsx)("span",{className:"font-medium",children:b}),(0,n.jsx)("span",{className:"opacity-80",children:new Date(t.testedAt).toLocaleTimeString()})]}),(0,n.jsx)("div",{className:"mt-1.5 space-y-1",children:t.checks.map((y,x)=>(0,n.jsxs)("div",{className:"leading-relaxed break-words",children:[(0,n.jsx)("span",{className:"font-medium uppercase tracking-wide opacity-80",children:y.level}),(0,n.jsx)("span",{className:"mx-1 opacity-60",children:"·"}),(0,n.jsx)("span",{children:y.message}),y.detail&&(0,n.jsxs)("span",{className:"block opacity-75 break-all",children:["(",y.detail,")"]}),d&&y.hint&&(0,n.jsxs)("span",{className:"block opacity-90 break-words",children:["Hint: ",y.hint]})]},`${y.code}-${x}`))})]})}i(ho,"AdapterEnvironmentResult");export{Yl as OnboardingWizard};
@@ -1 +1 @@
1
- var bt=Object.defineProperty;var u=(e,a)=>bt(e,"name",{value:a,configurable:!0});import{a as ct}from"./rolldown-runtime-DhZMWcEn.js";import{$A as vt,E_ as wt,GS as V,Gb as J,IE as Ct,LS as jt,NE as tt,Sy as Mt,Yb as Nt,ab as kt,aw as Pt,ck as Et,fw as Dt,ib as Tt,jb as Yt,nj as Zt,on as et,pC as St,pb as _t,qC as zt,qd as Xt,rT as $t,rb as rt,ry as Wt,tw as nt,ub as Lt,xE as st}from"./index-Bt31d8ga.js";var o=ct(Zt(),1),n=ct(vt(),1),N=200,W=100,z=32,Rt=80,L=60,At=.2,Ht=2,H=6;function E(e){if(e.reports.length===0)return N;const a=e.reports.reduce((i,x)=>i+E(x),0),d=(e.reports.length-1)*z;return Math.max(N,a+d)}u(E,"subtreeWidth");function it(e,a,d){const i=E(e),x=[];if(e.reports.length>0){const j=e.reports.reduce((w,T)=>w+E(T),0),R=(e.reports.length-1)*z;let D=a+(i-j-R)/2;for(const w of e.reports){const T=E(w);x.push(it(w,D,d+W+Rt)),D+=T+z}}return{id:e.id,name:e.name,role:e.role,status:e.status,x:a+(i-N)/2,y:d,children:x}}u(it,"layoutTree");function Ot(e){if(e.length===0)return[];e.reduce((x,j)=>x+E(j),0),(e.length-1)*z;let a=L;const d=L,i=[];for(const x of e){const j=E(x);i.push(it(x,a,d)),a+=j+z}return i}u(Ot,"layoutForest");function qt(e){const a=[];function d(i){a.push(i),i.children.forEach(d)}return u(d,"walk"),e.forEach(d),a}u(qt,"flattenLayout");function Bt(e){const a=[];function d(i){for(const x of i.children)a.push({parent:i,child:x}),d(x)}return u(d,"walk"),e.forEach(d),a}u(Bt,"collectEdges");function O(e){return Math.min(Math.max(e,At),Ht)}u(O,"clampZoom");function It(e){return{x:e.clientX,y:e.clientY}}u(It,"touchPoint");function ot(e,a){const d=e.clientX-a.clientX,i=e.clientY-a.clientY;return Math.hypot(d,i)}u(ot,"touchDistance");function at(e,a,d){const i=d.getBoundingClientRect();return{x:(e.clientX+a.clientX)/2-i.left,y:(e.clientY+a.clientY)/2-i.top}}u(at,"touchCenter");var Gt={running:"var(--hex-22d3ee)",active:"var(--hex-4ade80)",paused:"var(--hex-facc15)",idle:"var(--hex-facc15)",error:"var(--hex-f87171)",terminated:"var(--hex-a3a3a3)"},Ft="var(--hex-a3a3a3)";function te(){const{selectedCompanyId:e}=jt(),{setBreadcrumbs:a}=Tt(),d=Nt(),i=!!Mt(),{hidden:x}=Wt(),j=!i&&!x.has("company.import"),R=!x.has("company.export"),D=st({queryKey:V.org(e),queryFn:u(()=>rt.org(e),"queryFn"),enabled:!!e}),{data:w,isLoading:T}=D,Y=Lt(D),{data:q}=st({queryKey:V.agents.list(e),queryFn:u(()=>rt.list(e),"queryFn"),enabled:!!e}),lt=(0,o.useMemo)(()=>{const t=new Map;for(const r of q??[])t.set(r.id,r);return t},[q]);(0,o.useEffect)(()=>{a([{label:"Org Chart"}])},[a]);const X=(0,o.useMemo)(()=>Ot(w??[]),[w]),k=(0,o.useMemo)(()=>qt(X),[X]),ut=(0,o.useMemo)(()=>Bt(X),[X]),v=(0,o.useMemo)(()=>{if(k.length===0)return{width:800,height:600};let t=0,r=0;for(const s of k)t=Math.max(t,s.x+N),r=Math.max(r,s.y+W);return{width:t+L,height:r+L}},[k]),p=(0,o.useRef)(null),[l,M]=(0,o.useState)({x:0,y:0}),[h,Z]=(0,o.useState)(1),[A,B]=(0,o.useState)(!1),S=(0,o.useRef)({x:0,y:0,panX:0,panY:0}),m=(0,o.useRef)({mode:null,startPoint:{x:0,y:0},startPan:{x:0,y:0},startZoom:1,startDistance:0,startCenter:{x:0,y:0},moved:!1}),$=(0,o.useRef)(!1),P=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{P.current!==null&&window.clearTimeout(P.current)},[]);const I=(0,o.useRef)(!1);(0,o.useEffect)(()=>{if(I.current||k.length===0||!p.current)return;I.current=!0;const t=p.current,r=t.clientWidth,s=t.clientHeight,c=(r-40)/v.width,f=(s-40)/v.height,g=Math.min(c,f,1),y=v.width*g,C=v.height*g;Z(g),M({x:(r-y)/2,y:(s-C)/2})},[k,v]);const dt=(0,o.useCallback)(t=>{t.button===0&&(t.target.closest("[data-org-card]")||(B(!0),S.current={x:t.clientX,y:t.clientY,panX:l.x,panY:l.y}))},[l]),ht=(0,o.useCallback)(t=>{if(!A)return;const r=t.clientX-S.current.x,s=t.clientY-S.current.y;M({x:S.current.panX+r,y:S.current.panY+s})},[A]),G=(0,o.useCallback)(()=>{B(!1)},[]),mt=(0,o.useCallback)(t=>{t.preventDefault();const r=p.current;if(!r)return;const s=r.getBoundingClientRect(),c=t.clientX-s.left,f=t.clientY-s.top,g=t.deltaY<0?1.1:.9,y=O(h*g),C=y/h;M({x:c-C*(c-l.x),y:f-C*(f-l.y)}),Z(y)},[h,l]),F=(0,o.useCallback)((t,r)=>{const s=O(t),c=s/h;M({x:r.x-c*(r.x-l.x),y:r.y-c*(r.y-l.y)}),Z(s)},[h,l]),xt=(0,o.useCallback)(()=>{if(!p.current)return;const t=p.current.clientWidth,r=p.current.clientHeight,s=(t-40)/v.width,c=(r-40)/v.height,f=Math.min(s,c,1),g=v.width*f,y=v.height*f;Z(f),M({x:(t-g)/2,y:(r-y)/2})},[v]),ft=(0,o.useCallback)(t=>{if(t.touches.length>=2&&p.current){const[s,c]=[t.touches[0],t.touches[1]];m.current={mode:"pinch",startPoint:{x:0,y:0},startPan:l,startZoom:h,startDistance:ot(s,c),startCenter:at(s,c,p.current),moved:!1};return}const r=t.touches[0];r&&(m.current={mode:"pan",startPoint:It(r),startPan:l,startZoom:h,startDistance:0,startCenter:{x:0,y:0},moved:!1})},[l,h]),gt=(0,o.useCallback)(t=>{const r=p.current;if(!r||!m.current.mode)return;if(t.touches.length>=2){const[g,y]=[t.touches[0],t.touches[1]],C=ot(g,y),_=at(g,y,r);if(m.current.mode!=="pinch"||m.current.startDistance===0){m.current={mode:"pinch",startPoint:{x:0,y:0},startPan:l,startZoom:h,startDistance:C,startCenter:_,moved:!1};return}const b=m.current,Q=O(b.startZoom*(C/b.startDistance)),K=Q/b.startZoom,pt=_.x-b.startCenter.x,yt=_.y-b.startCenter.y;b.moved=b.moved||Math.abs(C-b.startDistance)>H||Math.hypot(pt,yt)>H,Z(Q),M({x:_.x-K*(b.startCenter.x-b.startPan.x),y:_.y-K*(b.startCenter.y-b.startPan.y)});return}const s=t.touches[0];if(!s||m.current.mode!=="pan")return;const c=s.clientX-m.current.startPoint.x,f=s.clientY-m.current.startPoint.y;m.current.moved=m.current.moved||Math.hypot(c,f)>H,M({x:m.current.startPan.x+c,y:m.current.startPan.y+f})},[l,h]),U=(0,o.useCallback)(()=>{m.current.moved&&($.current=!0,P.current!==null&&window.clearTimeout(P.current),P.current=window.setTimeout(()=>{$.current=!1,P.current=null},400)),m.current={mode:null,startPoint:{x:0,y:0},startPan:l,startZoom:h,startDistance:0,startCenter:{x:0,y:0},moved:!1}},[l,h]);return e?T||Y.kind==="reconnecting"?(0,n.jsx)(_t,{variant:"org-chart"}):Y.kind==="error"?(0,n.jsx)(kt,{size:"page",error:Y.error,action:"load the org chart",onRetry:Y.retry,retrying:Y.isFetching}):w&&w.length===0?(0,n.jsx)(et,{icon:nt,message:"No organizational hierarchy defined."}):(0,n.jsxs)("div",{className:"flex h-(--sz-calc-38) min-h-(--sz-420px) flex-col md:h-full md:min-h-0",children:[(0,n.jsxs)("div",{className:"mb-2 flex shrink-0 flex-wrap items-center justify-start gap-2",children:[j&&(0,n.jsx)(J,{to:"/company/import",children:(0,n.jsxs)(tt,{variant:"outline",size:"sm",children:[(0,n.jsx)(St,{className:"mr-1.5 h-3.5 w-3.5"}),"Import company"]})}),R&&(0,n.jsx)(J,{to:"/company/export",children:(0,n.jsxs)(tt,{variant:"outline",size:"sm",children:[(0,n.jsx)($t,{className:"mr-1.5 h-3.5 w-3.5"}),"Export company"]})})]}),(0,n.jsxs)("div",{ref:p,"data-testid":"org-chart-viewport",className:"w-full flex-1 min-h-0 overflow-hidden relative bg-muted/20 border border-border rounded-lg",style:{cursor:A?"grabbing":"grab",touchAction:"none",overscrollBehavior:"contain"},onMouseDown:dt,onMouseMove:ht,onMouseUp:G,onMouseLeave:G,onWheel:mt,onTouchStart:ft,onTouchMove:gt,onTouchEnd:U,onTouchCancel:U,children:[(0,n.jsxs)("div",{className:"absolute top-3 right-3 z-10 flex flex-col gap-1.5",children:[(0,n.jsx)("button",{className:"flex size-9 items-center justify-center rounded border border-border bg-background text-sm transition-colors hover:bg-accent sm:size-7",onClick:u(()=>{const t=p.current;t&&F(h*1.2,{x:t.clientWidth/2,y:t.clientHeight/2})},"onClick"),title:"Zoom in","aria-label":"Zoom in",children:(0,n.jsx)(zt,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"})}),(0,n.jsx)("button",{className:"flex size-9 items-center justify-center rounded border border-border bg-background text-sm transition-colors hover:bg-accent sm:size-7",onClick:u(()=>{const t=p.current;t&&F(h*.8,{x:t.clientWidth/2,y:t.clientHeight/2})},"onClick"),title:"Zoom out","aria-label":"Zoom out",children:(0,n.jsx)(Pt,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"})}),(0,n.jsx)("button",{className:"flex size-9 items-center justify-center rounded border border-border bg-background text-(length:--text-nano) transition-colors hover:bg-accent sm:size-7",onClick:xt,title:"Fit to screen","aria-label":"Fit chart to screen",children:(0,n.jsx)(Dt,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"})})]}),(0,n.jsx)("svg",{className:"absolute inset-0 pointer-events-none",style:{width:"100%",height:"100%"},children:(0,n.jsx)("g",{transform:`translate(${l.x}, ${l.y}) scale(${h})`,children:ut.map(({parent:t,child:r})=>{const s=t.x+N/2,c=t.y+W,f=r.x+N/2,g=r.y,y=(c+g)/2;return(0,n.jsx)("path",{d:`M ${s} ${c} L ${s} ${y} L ${f} ${y} L ${f} ${g}`,fill:"none",stroke:"var(--border)",strokeWidth:1.5},`${t.id}-${r.id}`)})})}),(0,n.jsx)("div",{"data-testid":"org-chart-card-layer",className:"absolute inset-0",style:{transform:`translate(${l.x}px, ${l.y}px) scale(${h})`,transformOrigin:"0 0"},children:k.map(t=>{const r=lt.get(t.id),s=Gt[t.status]??Ft;return(0,n.jsx)(wt,{"data-org-card":!0,className:"block absolute py-0 hover:shadow-md hover:border-foreground/20 transition-(--tp-box-shadow-border-color) duration-150 cursor-pointer select-none",style:{left:t.x,top:t.y,width:N,minHeight:W},onClick:u(()=>d(r?Ct(r):`/agents/${t.id}`),"onClick"),onClickCapture:u(c=>{$.current&&($.current=!1,c.preventDefault(),c.stopPropagation())},"onClickCapture"),children:(0,n.jsxs)("div",{className:"flex items-center px-4 py-3 gap-3",children:[(0,n.jsxs)("div",{className:"relative shrink-0",children:[(0,n.jsx)("div",{className:"w-9 h-9 rounded-full bg-muted flex items-center justify-center",children:(0,n.jsx)(Yt,{agent:r,size:16,className:"h-4.5 w-4.5 text-foreground/70"})}),(0,n.jsx)("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-card",style:{backgroundColor:s}})]}),(0,n.jsxs)("div",{className:"flex flex-col items-start min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"text-sm font-semibold text-foreground leading-tight",children:t.name}),(0,n.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground leading-tight mt-0.5",children:r?.title??Qt(t.role)}),r&&(0,n.jsx)("span",{className:"text-(length:--text-nano) text-muted-foreground/60 font-mono leading-tight mt-1",children:Xt(r.adapterType)}),r&&r.capabilities&&(0,n.jsx)("span",{className:"text-(length:--text-nano) text-muted-foreground/80 leading-tight mt-1 line-clamp-2",children:r.capabilities})]})]})},t.id)})})]})]}):(0,n.jsx)(et,{icon:nt,message:"Select a company to view the org chart."})}u(te,"OrgChart");var Ut=Et;function Qt(e){return Ut[e]??e}u(Qt,"roleLabel");export{te as OrgChart};
1
+ var bt=Object.defineProperty;var u=(e,a)=>bt(e,"name",{value:a,configurable:!0});import{a as ct}from"./rolldown-runtime-DhZMWcEn.js";import{$A as vt,E_ as wt,GS as V,Gb as J,IE as Ct,LS as jt,NE as tt,Sy as Mt,Yb as Nt,ab as kt,aw as Pt,ck as Et,fw as Dt,ib as Tt,jb as Yt,nj as Zt,on as et,pC as St,pb as _t,qC as zt,qd as Xt,rT as $t,rb as rt,ry as Wt,tw as nt,ub as Lt,xE as st}from"./index-BJtnP7H1.js";var o=ct(Zt(),1),n=ct(vt(),1),N=200,W=100,z=32,Rt=80,L=60,At=.2,Ht=2,H=6;function E(e){if(e.reports.length===0)return N;const a=e.reports.reduce((i,x)=>i+E(x),0),d=(e.reports.length-1)*z;return Math.max(N,a+d)}u(E,"subtreeWidth");function it(e,a,d){const i=E(e),x=[];if(e.reports.length>0){const j=e.reports.reduce((w,T)=>w+E(T),0),R=(e.reports.length-1)*z;let D=a+(i-j-R)/2;for(const w of e.reports){const T=E(w);x.push(it(w,D,d+W+Rt)),D+=T+z}}return{id:e.id,name:e.name,role:e.role,status:e.status,x:a+(i-N)/2,y:d,children:x}}u(it,"layoutTree");function Ot(e){if(e.length===0)return[];e.reduce((x,j)=>x+E(j),0),(e.length-1)*z;let a=L;const d=L,i=[];for(const x of e){const j=E(x);i.push(it(x,a,d)),a+=j+z}return i}u(Ot,"layoutForest");function qt(e){const a=[];function d(i){a.push(i),i.children.forEach(d)}return u(d,"walk"),e.forEach(d),a}u(qt,"flattenLayout");function Bt(e){const a=[];function d(i){for(const x of i.children)a.push({parent:i,child:x}),d(x)}return u(d,"walk"),e.forEach(d),a}u(Bt,"collectEdges");function O(e){return Math.min(Math.max(e,At),Ht)}u(O,"clampZoom");function It(e){return{x:e.clientX,y:e.clientY}}u(It,"touchPoint");function ot(e,a){const d=e.clientX-a.clientX,i=e.clientY-a.clientY;return Math.hypot(d,i)}u(ot,"touchDistance");function at(e,a,d){const i=d.getBoundingClientRect();return{x:(e.clientX+a.clientX)/2-i.left,y:(e.clientY+a.clientY)/2-i.top}}u(at,"touchCenter");var Gt={running:"var(--hex-22d3ee)",active:"var(--hex-4ade80)",paused:"var(--hex-facc15)",idle:"var(--hex-facc15)",error:"var(--hex-f87171)",terminated:"var(--hex-a3a3a3)"},Ft="var(--hex-a3a3a3)";function te(){const{selectedCompanyId:e}=jt(),{setBreadcrumbs:a}=Tt(),d=Nt(),i=!!Mt(),{hidden:x}=Wt(),j=!i&&!x.has("company.import"),R=!x.has("company.export"),D=st({queryKey:V.org(e),queryFn:u(()=>rt.org(e),"queryFn"),enabled:!!e}),{data:w,isLoading:T}=D,Y=Lt(D),{data:q}=st({queryKey:V.agents.list(e),queryFn:u(()=>rt.list(e),"queryFn"),enabled:!!e}),lt=(0,o.useMemo)(()=>{const t=new Map;for(const r of q??[])t.set(r.id,r);return t},[q]);(0,o.useEffect)(()=>{a([{label:"Org Chart"}])},[a]);const X=(0,o.useMemo)(()=>Ot(w??[]),[w]),k=(0,o.useMemo)(()=>qt(X),[X]),ut=(0,o.useMemo)(()=>Bt(X),[X]),v=(0,o.useMemo)(()=>{if(k.length===0)return{width:800,height:600};let t=0,r=0;for(const s of k)t=Math.max(t,s.x+N),r=Math.max(r,s.y+W);return{width:t+L,height:r+L}},[k]),p=(0,o.useRef)(null),[l,M]=(0,o.useState)({x:0,y:0}),[h,Z]=(0,o.useState)(1),[A,B]=(0,o.useState)(!1),S=(0,o.useRef)({x:0,y:0,panX:0,panY:0}),m=(0,o.useRef)({mode:null,startPoint:{x:0,y:0},startPan:{x:0,y:0},startZoom:1,startDistance:0,startCenter:{x:0,y:0},moved:!1}),$=(0,o.useRef)(!1),P=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{P.current!==null&&window.clearTimeout(P.current)},[]);const I=(0,o.useRef)(!1);(0,o.useEffect)(()=>{if(I.current||k.length===0||!p.current)return;I.current=!0;const t=p.current,r=t.clientWidth,s=t.clientHeight,c=(r-40)/v.width,f=(s-40)/v.height,g=Math.min(c,f,1),y=v.width*g,C=v.height*g;Z(g),M({x:(r-y)/2,y:(s-C)/2})},[k,v]);const dt=(0,o.useCallback)(t=>{t.button===0&&(t.target.closest("[data-org-card]")||(B(!0),S.current={x:t.clientX,y:t.clientY,panX:l.x,panY:l.y}))},[l]),ht=(0,o.useCallback)(t=>{if(!A)return;const r=t.clientX-S.current.x,s=t.clientY-S.current.y;M({x:S.current.panX+r,y:S.current.panY+s})},[A]),G=(0,o.useCallback)(()=>{B(!1)},[]),mt=(0,o.useCallback)(t=>{t.preventDefault();const r=p.current;if(!r)return;const s=r.getBoundingClientRect(),c=t.clientX-s.left,f=t.clientY-s.top,g=t.deltaY<0?1.1:.9,y=O(h*g),C=y/h;M({x:c-C*(c-l.x),y:f-C*(f-l.y)}),Z(y)},[h,l]),F=(0,o.useCallback)((t,r)=>{const s=O(t),c=s/h;M({x:r.x-c*(r.x-l.x),y:r.y-c*(r.y-l.y)}),Z(s)},[h,l]),xt=(0,o.useCallback)(()=>{if(!p.current)return;const t=p.current.clientWidth,r=p.current.clientHeight,s=(t-40)/v.width,c=(r-40)/v.height,f=Math.min(s,c,1),g=v.width*f,y=v.height*f;Z(f),M({x:(t-g)/2,y:(r-y)/2})},[v]),ft=(0,o.useCallback)(t=>{if(t.touches.length>=2&&p.current){const[s,c]=[t.touches[0],t.touches[1]];m.current={mode:"pinch",startPoint:{x:0,y:0},startPan:l,startZoom:h,startDistance:ot(s,c),startCenter:at(s,c,p.current),moved:!1};return}const r=t.touches[0];r&&(m.current={mode:"pan",startPoint:It(r),startPan:l,startZoom:h,startDistance:0,startCenter:{x:0,y:0},moved:!1})},[l,h]),gt=(0,o.useCallback)(t=>{const r=p.current;if(!r||!m.current.mode)return;if(t.touches.length>=2){const[g,y]=[t.touches[0],t.touches[1]],C=ot(g,y),_=at(g,y,r);if(m.current.mode!=="pinch"||m.current.startDistance===0){m.current={mode:"pinch",startPoint:{x:0,y:0},startPan:l,startZoom:h,startDistance:C,startCenter:_,moved:!1};return}const b=m.current,Q=O(b.startZoom*(C/b.startDistance)),K=Q/b.startZoom,pt=_.x-b.startCenter.x,yt=_.y-b.startCenter.y;b.moved=b.moved||Math.abs(C-b.startDistance)>H||Math.hypot(pt,yt)>H,Z(Q),M({x:_.x-K*(b.startCenter.x-b.startPan.x),y:_.y-K*(b.startCenter.y-b.startPan.y)});return}const s=t.touches[0];if(!s||m.current.mode!=="pan")return;const c=s.clientX-m.current.startPoint.x,f=s.clientY-m.current.startPoint.y;m.current.moved=m.current.moved||Math.hypot(c,f)>H,M({x:m.current.startPan.x+c,y:m.current.startPan.y+f})},[l,h]),U=(0,o.useCallback)(()=>{m.current.moved&&($.current=!0,P.current!==null&&window.clearTimeout(P.current),P.current=window.setTimeout(()=>{$.current=!1,P.current=null},400)),m.current={mode:null,startPoint:{x:0,y:0},startPan:l,startZoom:h,startDistance:0,startCenter:{x:0,y:0},moved:!1}},[l,h]);return e?T||Y.kind==="reconnecting"?(0,n.jsx)(_t,{variant:"org-chart"}):Y.kind==="error"?(0,n.jsx)(kt,{size:"page",error:Y.error,action:"load the org chart",onRetry:Y.retry,retrying:Y.isFetching}):w&&w.length===0?(0,n.jsx)(et,{icon:nt,message:"No organizational hierarchy defined."}):(0,n.jsxs)("div",{className:"flex h-(--sz-calc-38) min-h-(--sz-420px) flex-col md:h-full md:min-h-0",children:[(0,n.jsxs)("div",{className:"mb-2 flex shrink-0 flex-wrap items-center justify-start gap-2",children:[j&&(0,n.jsx)(J,{to:"/company/import",children:(0,n.jsxs)(tt,{variant:"outline",size:"sm",children:[(0,n.jsx)(St,{className:"mr-1.5 h-3.5 w-3.5"}),"Import company"]})}),R&&(0,n.jsx)(J,{to:"/company/export",children:(0,n.jsxs)(tt,{variant:"outline",size:"sm",children:[(0,n.jsx)($t,{className:"mr-1.5 h-3.5 w-3.5"}),"Export company"]})})]}),(0,n.jsxs)("div",{ref:p,"data-testid":"org-chart-viewport",className:"w-full flex-1 min-h-0 overflow-hidden relative bg-muted/20 border border-border rounded-lg",style:{cursor:A?"grabbing":"grab",touchAction:"none",overscrollBehavior:"contain"},onMouseDown:dt,onMouseMove:ht,onMouseUp:G,onMouseLeave:G,onWheel:mt,onTouchStart:ft,onTouchMove:gt,onTouchEnd:U,onTouchCancel:U,children:[(0,n.jsxs)("div",{className:"absolute top-3 right-3 z-10 flex flex-col gap-1.5",children:[(0,n.jsx)("button",{className:"flex size-9 items-center justify-center rounded border border-border bg-background text-sm transition-colors hover:bg-accent sm:size-7",onClick:u(()=>{const t=p.current;t&&F(h*1.2,{x:t.clientWidth/2,y:t.clientHeight/2})},"onClick"),title:"Zoom in","aria-label":"Zoom in",children:(0,n.jsx)(zt,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"})}),(0,n.jsx)("button",{className:"flex size-9 items-center justify-center rounded border border-border bg-background text-sm transition-colors hover:bg-accent sm:size-7",onClick:u(()=>{const t=p.current;t&&F(h*.8,{x:t.clientWidth/2,y:t.clientHeight/2})},"onClick"),title:"Zoom out","aria-label":"Zoom out",children:(0,n.jsx)(Pt,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"})}),(0,n.jsx)("button",{className:"flex size-9 items-center justify-center rounded border border-border bg-background text-(length:--text-nano) transition-colors hover:bg-accent sm:size-7",onClick:xt,title:"Fit to screen","aria-label":"Fit chart to screen",children:(0,n.jsx)(Dt,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"})})]}),(0,n.jsx)("svg",{className:"absolute inset-0 pointer-events-none",style:{width:"100%",height:"100%"},children:(0,n.jsx)("g",{transform:`translate(${l.x}, ${l.y}) scale(${h})`,children:ut.map(({parent:t,child:r})=>{const s=t.x+N/2,c=t.y+W,f=r.x+N/2,g=r.y,y=(c+g)/2;return(0,n.jsx)("path",{d:`M ${s} ${c} L ${s} ${y} L ${f} ${y} L ${f} ${g}`,fill:"none",stroke:"var(--border)",strokeWidth:1.5},`${t.id}-${r.id}`)})})}),(0,n.jsx)("div",{"data-testid":"org-chart-card-layer",className:"absolute inset-0",style:{transform:`translate(${l.x}px, ${l.y}px) scale(${h})`,transformOrigin:"0 0"},children:k.map(t=>{const r=lt.get(t.id),s=Gt[t.status]??Ft;return(0,n.jsx)(wt,{"data-org-card":!0,className:"block absolute py-0 hover:shadow-md hover:border-foreground/20 transition-(--tp-box-shadow-border-color) duration-150 cursor-pointer select-none",style:{left:t.x,top:t.y,width:N,minHeight:W},onClick:u(()=>d(r?Ct(r):`/agents/${t.id}`),"onClick"),onClickCapture:u(c=>{$.current&&($.current=!1,c.preventDefault(),c.stopPropagation())},"onClickCapture"),children:(0,n.jsxs)("div",{className:"flex items-center px-4 py-3 gap-3",children:[(0,n.jsxs)("div",{className:"relative shrink-0",children:[(0,n.jsx)("div",{className:"w-9 h-9 rounded-full bg-muted flex items-center justify-center",children:(0,n.jsx)(Yt,{agent:r,size:16,className:"h-4.5 w-4.5 text-foreground/70"})}),(0,n.jsx)("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-card",style:{backgroundColor:s}})]}),(0,n.jsxs)("div",{className:"flex flex-col items-start min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"text-sm font-semibold text-foreground leading-tight",children:t.name}),(0,n.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground leading-tight mt-0.5",children:r?.title??Qt(t.role)}),r&&(0,n.jsx)("span",{className:"text-(length:--text-nano) text-muted-foreground/60 font-mono leading-tight mt-1",children:Xt(r.adapterType)}),r&&r.capabilities&&(0,n.jsx)("span",{className:"text-(length:--text-nano) text-muted-foreground/80 leading-tight mt-1 line-clamp-2",children:r.capabilities})]})]})},t.id)})})]})]}):(0,n.jsx)(et,{icon:nt,message:"Select a company to view the org chart."})}u(te,"OrgChart");var Ut=Et;function Qt(e){return Ut[e]??e}u(Qt,"roleLabel");export{te as OrgChart};
@@ -1 +1 @@
1
- var m=Object.defineProperty;var i=(t,r)=>m(t,"name",{value:r,configurable:!0});import{a as h}from"./rolldown-runtime-DhZMWcEn.js";import{$A as f,Gc as x,Kc as p,NE as d,Wc as u,_w as v,hE as j,nj as b,ny as g,xw as y}from"./index-Bt31d8ga.js";var o=h(b(),1),e=h(f(),1);function N({phase:t,error:r,onRetry:c,onCancel:a}){const n=t==="error";return(0,e.jsx)("main",{className:"flex min-h-screen items-center justify-center bg-background p-6",children:(0,e.jsxs)("div",{className:"flex max-w-lg items-start gap-3",children:[(0,e.jsx)("span",{className:"mt-1 inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-lg border border-border bg-background",children:n?(0,e.jsx)(y,{className:"h-5 w-5 text-destructive"}):(0,e.jsx)(v,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("h1",{className:"text-xl font-bold tracking-tight",children:n?"Sign-in couldn’t continue":"Preparing secure sign-in"}),(0,e.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:n?r??"Microvac couldn’t prepare the provider sign-in. Try again.":t==="reauthenticating"?"Your Microvac sign-in is being refreshed.":"Microvac is opening the provider securely."}),n?(0,e.jsxs)("div",{className:"mt-6 flex items-center gap-2",children:[(0,e.jsx)(d,{type:"button",onClick:c,children:"Try again"}),(0,e.jsx)(d,{type:"button",variant:"ghost",onClick:a,children:"Return to Microvac"})]}):null]})]})})}i(N,"ManagedOAuthHandoffState");function C(){const[t,r]=(0,o.useState)("loading"),[c,a]=(0,o.useState)(null),n=(0,o.useCallback)(async()=>{const l=p();if(!l){r("error"),a("This sign-in expired. Return to Microvac and start the connection again.");return}r("loading"),a(null);try{const s=await x({authorizationUrl:"",handoff:l});if(s.kind==="reauthentication"){r("error"),a("Microvac couldn’t refresh this sign-in. Try again to continue.");return}u(),g(s.url)}catch(s){r("error"),a(j(s).body)}},[]);return(0,o.useEffect)(()=>{n()},[n]),(0,e.jsx)(N,{phase:t,error:c,onRetry:i(()=>{n()},"onRetry"),onCancel:i(()=>{u(),g("/")},"onCancel")})}i(C,"PaperclipCloudOAuthHandoffPage");export{C as PaperclipCloudOAuthHandoffPage};
1
+ var m=Object.defineProperty;var i=(t,r)=>m(t,"name",{value:r,configurable:!0});import{a as h}from"./rolldown-runtime-DhZMWcEn.js";import{$A as f,Gc as x,Kc as p,NE as d,Wc as u,_w as v,hE as j,nj as b,ny as g,xw as y}from"./index-BJtnP7H1.js";var o=h(b(),1),e=h(f(),1);function N({phase:t,error:r,onRetry:c,onCancel:a}){const n=t==="error";return(0,e.jsx)("main",{className:"flex min-h-screen items-center justify-center bg-background p-6",children:(0,e.jsxs)("div",{className:"flex max-w-lg items-start gap-3",children:[(0,e.jsx)("span",{className:"mt-1 inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-lg border border-border bg-background",children:n?(0,e.jsx)(y,{className:"h-5 w-5 text-destructive"}):(0,e.jsx)(v,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("h1",{className:"text-xl font-bold tracking-tight",children:n?"Sign-in couldn’t continue":"Preparing secure sign-in"}),(0,e.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:n?r??"Microvac couldn’t prepare the provider sign-in. Try again.":t==="reauthenticating"?"Your Microvac sign-in is being refreshed.":"Microvac is opening the provider securely."}),n?(0,e.jsxs)("div",{className:"mt-6 flex items-center gap-2",children:[(0,e.jsx)(d,{type:"button",onClick:c,children:"Try again"}),(0,e.jsx)(d,{type:"button",variant:"ghost",onClick:a,children:"Return to Microvac"})]}):null]})]})})}i(N,"ManagedOAuthHandoffState");function C(){const[t,r]=(0,o.useState)("loading"),[c,a]=(0,o.useState)(null),n=(0,o.useCallback)(async()=>{const l=p();if(!l){r("error"),a("This sign-in expired. Return to Microvac and start the connection again.");return}r("loading"),a(null);try{const s=await x({authorizationUrl:"",handoff:l});if(s.kind==="reauthentication"){r("error"),a("Microvac couldn’t refresh this sign-in. Try again to continue.");return}u(),g(s.url)}catch(s){r("error"),a(j(s).body)}},[]);return(0,o.useEffect)(()=>{n()},[n]),(0,e.jsx)(N,{phase:t,error:c,onRetry:i(()=>{n()},"onRetry"),onCancel:i(()=>{u(),g("/")},"onCancel")})}i(C,"PaperclipCloudOAuthHandoffPage");export{C as PaperclipCloudOAuthHandoffPage};
@@ -1 +1 @@
1
- var le=Object.defineProperty;var a=(t,d)=>le(t,"name",{value:d,configurable:!0});import{a as X}from"./rolldown-runtime-DhZMWcEn.js";import{t as de}from"./power-0mw59G-l.js";import{$A as ce,$S as oe,E_ as _,GS as g,Gb as D,H_ as o,KC as z,Kw as me,LS as xe,ME as ue,NC as he,NE as n,O_ as ge,__ as pe,ab as V,bE as k,cv as je,dy as M,fy as B,gC as Ne,hC as L,hy as ye,ib as fe,lv as x,ly as q,my as A,nj as be,op as ve,qC as ke,sy as J,ub as R,uy as Q,xE as G,zE as K}from"./index-Bt31d8ga.js";var c=X(be(),1),e=X(ce(),1);function we(t){return t?t.split(/\r?\n/).map(d=>d.trim()).find(Boolean)??null:null}a(we,"firstNonEmptyLine");function H(t){return we(t.lastError)??"Plugin entered an error state without a stored error message."}a(H,"getPluginErrorSummary");function W(t){if(t.bundledExperimental)return!0;const d=t.packageName??"",u=t.packagePath??"";return d.includes("sandbox")||u.includes("sandbox")?!0:t.manifestJson?.environmentDrivers?.some(r=>r.kind==="sandbox_provider")===!0}a(W,"isExperimentalPluginIdentity");function Y(){return(0,e.jsx)(o,{variant:"outline",className:"border-amber-500/30 bg-amber-500/10 text-amber-700 hover:bg-amber-500/10 dark:text-amber-200",children:"Experimental"})}a(Y,"ExperimentalBadge");function Fe(){const{selectedCompany:t}=xe(),{setBreadcrumbs:d}=fe(),u=ue(),{pushToast:r}=je(),[w,T]=(0,c.useState)(""),[Z,P]=(0,c.useState)(!1),[C,p]=(0,c.useState)(null),[ee,se]=(0,c.useState)(""),[m,E]=(0,c.useState)(null);(0,c.useEffect)(()=>{d([{label:t?.name??"Organization",href:"/dashboard"},{label:"Settings",href:"/company/settings"},{label:"System plugins"}])},[t?.name,d]);const O=G({queryKey:g.plugins.all,queryFn:a(()=>x.list(),"queryFn")}),{data:ae,isLoading:te,error:ne}=O,j=R(O),N=G({queryKey:g.plugins.examples,queryFn:a(()=>x.listBundled(),"queryFn")}),y=R(N),f=a(()=>{u.invalidateQueries({queryKey:g.plugins.all}),u.invalidateQueries({queryKey:g.plugins.examples}),u.invalidateQueries({queryKey:g.plugins.uiContributions})},"invalidatePluginQueries"),i=k({mutationFn:a(s=>x.install(s),"mutationFn"),onSuccess:a(()=>{f(),P(!1),T(""),r({title:"Plugin installed successfully",tone:"success"})},"onSuccess"),onError:a(s=>{r({title:"Failed to install plugin",body:s.message,tone:"error"})},"onError")}),b=k({mutationFn:a(s=>x.uninstall(s),"mutationFn"),onSuccess:a(()=>{f(),r({title:"Plugin uninstalled successfully",tone:"success"})},"onSuccess"),onError:a(s=>{r({title:"Failed to uninstall plugin",body:s.message,tone:"error"})},"onError")}),v=k({mutationFn:a(s=>x.enable(s),"mutationFn"),onSuccess:a(()=>{f(),r({title:"Plugin enabled",tone:"success"})},"onSuccess"),onError:a(s=>{r({title:"Failed to enable plugin",body:s.message,tone:"error"})},"onError")}),U=k({mutationFn:a(s=>x.disable(s),"mutationFn"),onSuccess:a(()=>{f(),r({title:"Plugin disabled",tone:"info"})},"onSuccess"),onError:a(s=>{r({title:"Failed to disable plugin",body:s.message,tone:"error"})},"onError")}),h=ae??[],S=N.data??[],re=new Map(h.map(s=>[s.packageName,s])),F=new Map(S.map(s=>[s.packageName,s])),$=i.variables?.isLocalPath?i.error?.message??null:null,ie=(0,c.useMemo)(()=>new Map(h.map(s=>[s.id,H(s)])),[h]);return te||j.kind==="reconnecting"?(0,e.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading plugins..."}):j.kind==="error"?(0,e.jsx)(V,{size:"page",error:ne,action:"load plugins",onRetry:j.retry,retrying:j.isFetching}):(0,e.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(z,{className:"h-6 w-6 text-muted-foreground"}),(0,e.jsx)("h1",{className:"text-xl font-semibold",children:"System plugins"})]}),(0,e.jsxs)(J,{open:Z,onOpenChange:P,children:[(0,e.jsx)(ye,{asChild:!0,children:(0,e.jsxs)(n,{size:"sm",className:"gap-2",children:[(0,e.jsx)(ke,{className:"h-4 w-4"}),"Install system plugin"]})}),(0,e.jsxs)(q,{children:[(0,e.jsxs)(B,{children:[(0,e.jsx)(A,{children:"Install system plugin"}),(0,e.jsx)(Q,{children:"Enter the npm package name of the plugin you wish to install."})]}),(0,e.jsx)("div",{className:"grid gap-4 py-4",children:(0,e.jsxs)("div",{className:"grid gap-2",children:[(0,e.jsx)(ve,{htmlFor:"packageName",children:"npm Package Name"}),(0,e.jsx)(pe,{id:"packageName",placeholder:"@paperclipai/plugin-example",value:w,onChange:a(s=>T(s.target.value),"onChange")})]})}),(0,e.jsxs)(M,{children:[(0,e.jsx)(n,{variant:"outline",onClick:a(()=>P(!1),"onClick"),children:"Cancel"}),(0,e.jsx)(n,{onClick:a(()=>i.mutate({packageName:w}),"onClick"),disabled:!w||i.isPending,children:i.isPending?"Installing...":"Install"})]})]})]})]}),(0,e.jsx)("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 px-4 py-3",children:(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,e.jsx)(L,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-700"}),(0,e.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,e.jsx)("p",{className:"font-medium text-foreground",children:"System plugins are alpha."}),(0,e.jsx)("p",{className:"text-muted-foreground",children:"The plugin runtime and API surface are still changing. Expect breaking changes while this feature settles."})]})]})}),(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(me,{className:"h-5 w-5 text-muted-foreground"}),(0,e.jsx)("h2",{className:"text-base font-semibold",children:"Available system plugins"}),(0,e.jsx)(o,{variant:"outline",children:"Bundled"})]}),$&&(0,e.jsx)("div",{className:"rounded-md border border-destructive/25 bg-destructive/[0.06] px-4 py-3 text-sm text-destructive whitespace-pre-wrap break-words",children:$}),N.isLoading||y.kind==="reconnecting"?(0,e.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading bundled plugins..."}):y.kind==="error"?(0,e.jsx)(V,{error:N.error,action:"load bundled plugins",onRetry:y.retry,retrying:y.isFetching}):S.length===0?(0,e.jsx)("div",{className:"rounded-md border border-dashed px-4 py-3 text-sm text-muted-foreground",children:"No bundled plugins were found in this checkout."}):(0,e.jsx)(_,{className:"block py-0",children:(0,e.jsx)("ul",{className:"divide-y",children:S.map(s=>{const l=re.get(s.packageName),I=i.isPending&&i.variables?.isLocalPath&&i.variables.packageName===s.localPath;return(0,e.jsx)("li",{children:(0,e.jsxs)("div",{className:"flex items-center gap-4 px-4 py-3",children:[(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("span",{className:"font-medium",children:s.displayName}),(0,e.jsx)(o,{variant:"outline",children:s.tag==="first-party"?"First-party":"Example"}),W({packageName:s.packageName,packagePath:s.localPath,bundledExperimental:s.experimental})&&(0,e.jsx)(Y,{}),l?(0,e.jsx)(o,{variant:l.status==="ready"?"default":"secondary",className:l.status==="ready"?"bg-green-600 hover:bg-green-700":"",children:l.status}):(0,e.jsx)(o,{variant:"secondary",children:"Not installed"})]}),(0,e.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:s.description}),(0,e.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:s.packageName}),I&&!s.hasBuiltEntrypoints&&(0,e.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Building plugin..."})]}),(0,e.jsx)("div",{className:"flex items-center gap-2 shrink-0",children:l?(0,e.jsxs)(e.Fragment,{children:[l.status!=="ready"&&(0,e.jsx)(n,{variant:"outline",size:"sm",disabled:v.isPending,onClick:a(()=>v.mutate(l.id),"onClick"),children:"Enable"}),(0,e.jsx)(n,{variant:"outline",size:"sm",asChild:!0,children:(0,e.jsx)(D,{to:`/company/settings/instance/plugins/${l.id}`,children:l.status==="ready"?"Open Settings":"Review"})})]}):(0,e.jsx)(n,{size:"sm",disabled:I||i.isPending,onClick:a(()=>i.mutate({packageName:s.localPath,isLocalPath:!0}),"onClick"),children:I?"Installing...":"Install"})})]})},s.packageName)})})})]}),(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(z,{className:"h-5 w-5 text-muted-foreground"}),(0,e.jsx)("h2",{className:"text-base font-semibold",children:"Installed system plugins"})]}),h.length?(0,e.jsx)(_,{className:"block py-0",children:(0,e.jsx)("ul",{className:"divide-y",children:h.map(s=>(0,e.jsx)("li",{children:(0,e.jsxs)("div",{className:"flex items-start gap-4 px-4 py-3",children:[(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(D,{to:`/company/settings/instance/plugins/${s.id}`,className:"font-medium hover:underline truncate block",title:s.manifestJson.displayName??s.packageName,children:s.manifestJson.displayName??s.packageName}),F.has(s.packageName)&&(0,e.jsx)(o,{variant:"outline",children:F.get(s.packageName)?.tag==="first-party"?"First-party":"Example"}),W({packageName:s.packageName,packagePath:s.packagePath,manifestJson:s.manifestJson,bundledExperimental:F.get(s.packageName)?.experimental})&&(0,e.jsx)(Y,{})]}),(0,e.jsx)("div",{children:(0,e.jsxs)("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",title:s.packageName,children:[s.packageName," · v",s.manifestJson.version??s.version]})}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground truncate mt-0.5",title:s.manifestJson.description,children:s.manifestJson.description||"No description provided."}),s.status==="error"&&(0,e.jsx)("div",{className:"mt-3 rounded-md border border-red-500/25 bg-red-500/[0.06] px-3 py-2",children:(0,e.jsxs)("div",{className:"flex flex-wrap items-start gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-red-700 dark:text-red-300",children:[(0,e.jsx)(L,{className:"h-4 w-4 shrink-0"}),(0,e.jsx)("span",{children:"Plugin error"})]}),(0,e.jsx)("p",{className:"mt-1 text-sm text-red-700/90 dark:text-red-200/90 break-words",title:s.lastError??void 0,children:ie.get(s.id)})]}),(0,e.jsx)(n,{variant:"outline",size:"sm",className:"border-red-500/30 bg-background/60 text-red-700 hover:bg-red-500/10 hover:text-red-800 dark:text-red-200 dark:hover:text-red-100",onClick:a(()=>E(s),"onClick"),children:"View full error"})]})})]}),(0,e.jsx)("div",{className:"flex shrink-0 self-center",children:(0,e.jsxs)("div",{className:"flex flex-col items-end gap-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(o,{variant:s.status==="ready"?"default":s.status==="error"?"destructive":"secondary",className:K("shrink-0",s.status==="ready"?"bg-green-600 hover:bg-green-700":""),children:s.status}),(0,e.jsx)(n,{variant:"outline",size:"icon-sm",className:"h-8 w-8",title:s.status==="ready"?"Disable":"Enable",onClick:a(()=>{s.status==="ready"?U.mutate(s.id):v.mutate(s.id)},"onClick"),disabled:v.isPending||U.isPending,children:(0,e.jsx)(de,{className:K("h-4 w-4",s.status==="ready"?"text-green-600":"")})}),(0,e.jsx)(n,{variant:"outline",size:"icon-sm",className:"h-8 w-8 text-destructive hover:text-destructive",title:"Uninstall",onClick:a(()=>{p(s.id),se(s.manifestJson.displayName??s.packageName)},"onClick"),disabled:b.isPending,children:(0,e.jsx)(Ne,{className:"h-4 w-4"})})]}),(0,e.jsx)(n,{variant:"outline",size:"sm",className:"mt-2 h-8",asChild:!0,children:(0,e.jsxs)(D,{to:`/company/settings/instance/plugins/${s.id}`,children:[(0,e.jsx)(he,{className:"h-4 w-4"}),"Configure"]})})]})})]})},s.id))})}):(0,e.jsx)(_,{className:"bg-muted/30",children:(0,e.jsxs)(ge,{className:"flex flex-col items-center justify-center py-10",children:[(0,e.jsx)(z,{className:"h-10 w-10 text-muted-foreground mb-4"}),(0,e.jsx)("p",{className:"text-sm font-medium",children:"No system plugins installed"}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Install a plugin to extend functionality."})]})})]}),(0,e.jsx)(J,{open:C!==null,onOpenChange:a(s=>{s||p(null)},"onOpenChange"),children:(0,e.jsxs)(q,{children:[(0,e.jsxs)(B,{children:[(0,e.jsx)(A,{children:"Uninstall Plugin"}),(0,e.jsxs)(Q,{children:["Are you sure you want to uninstall ",(0,e.jsx)("strong",{children:ee}),"? This action cannot be undone."]})]}),(0,e.jsxs)(M,{children:[(0,e.jsx)(n,{variant:"outline",onClick:a(()=>p(null),"onClick"),children:"Cancel"}),(0,e.jsx)(n,{variant:"destructive",disabled:b.isPending,onClick:a(()=>{C&&b.mutate(C,{onSettled:a(()=>p(null),"onSettled")})},"onClick"),children:b.isPending?"Uninstalling...":"Uninstall"})]})]})}),(0,e.jsx)(J,{open:m!==null,onOpenChange:a(s=>{s||E(null)},"onOpenChange"),children:(0,e.jsxs)(q,{className:"sm:max-w-2xl",children:[(0,e.jsxs)(B,{children:[(0,e.jsx)(A,{children:"Error Details"}),(0,e.jsxs)(Q,{children:[m?.manifestJson.displayName??m?.packageName??"Plugin"," hit an error state."]})]}),(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"rounded-md border border-red-500/25 bg-red-500/[0.06] px-4 py-3",children:(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,e.jsx)(L,{className:"mt-0.5 h-4 w-4 shrink-0 text-red-700 dark:text-red-300"}),(0,e.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,e.jsx)("p",{className:"font-medium text-red-700 dark:text-red-300",children:"What errored"}),(0,e.jsx)("p",{className:"text-red-700/90 dark:text-red-200/90 break-words",children:m?H(m):"No error summary available."})]})]})}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("p",{className:"text-sm font-medium",children:"Full error output"}),(0,e.jsx)("pre",{className:K("max-h-(--sz-50vh) overflow-auto rounded-md border bg-muted/40 p-3 text-xs leading-5 whitespace-pre-wrap break-words",oe),children:m?.lastError??"No stored error message."})]})]}),(0,e.jsx)(M,{children:(0,e.jsx)(n,{variant:"outline",onClick:a(()=>E(null),"onClick"),children:"Close"})})]})})]})}a(Fe,"PluginManager");export{Fe as PluginManager};
1
+ var le=Object.defineProperty;var a=(t,d)=>le(t,"name",{value:d,configurable:!0});import{a as X}from"./rolldown-runtime-DhZMWcEn.js";import{t as de}from"./power-sYV-WuqQ.js";import{$A as ce,$S as oe,E_ as _,GS as g,Gb as D,H_ as o,KC as z,Kw as me,LS as xe,ME as ue,NC as he,NE as n,O_ as ge,__ as pe,ab as V,bE as k,cv as je,dy as M,fy as B,gC as Ne,hC as L,hy as ye,ib as fe,lv as x,ly as q,my as A,nj as be,op as ve,qC as ke,sy as J,ub as R,uy as Q,xE as G,zE as K}from"./index-BJtnP7H1.js";var c=X(be(),1),e=X(ce(),1);function we(t){return t?t.split(/\r?\n/).map(d=>d.trim()).find(Boolean)??null:null}a(we,"firstNonEmptyLine");function H(t){return we(t.lastError)??"Plugin entered an error state without a stored error message."}a(H,"getPluginErrorSummary");function W(t){if(t.bundledExperimental)return!0;const d=t.packageName??"",u=t.packagePath??"";return d.includes("sandbox")||u.includes("sandbox")?!0:t.manifestJson?.environmentDrivers?.some(r=>r.kind==="sandbox_provider")===!0}a(W,"isExperimentalPluginIdentity");function Y(){return(0,e.jsx)(o,{variant:"outline",className:"border-amber-500/30 bg-amber-500/10 text-amber-700 hover:bg-amber-500/10 dark:text-amber-200",children:"Experimental"})}a(Y,"ExperimentalBadge");function Fe(){const{selectedCompany:t}=xe(),{setBreadcrumbs:d}=fe(),u=ue(),{pushToast:r}=je(),[w,T]=(0,c.useState)(""),[Z,P]=(0,c.useState)(!1),[C,p]=(0,c.useState)(null),[ee,se]=(0,c.useState)(""),[m,E]=(0,c.useState)(null);(0,c.useEffect)(()=>{d([{label:t?.name??"Organization",href:"/dashboard"},{label:"Settings",href:"/company/settings"},{label:"System plugins"}])},[t?.name,d]);const O=G({queryKey:g.plugins.all,queryFn:a(()=>x.list(),"queryFn")}),{data:ae,isLoading:te,error:ne}=O,j=R(O),N=G({queryKey:g.plugins.examples,queryFn:a(()=>x.listBundled(),"queryFn")}),y=R(N),f=a(()=>{u.invalidateQueries({queryKey:g.plugins.all}),u.invalidateQueries({queryKey:g.plugins.examples}),u.invalidateQueries({queryKey:g.plugins.uiContributions})},"invalidatePluginQueries"),i=k({mutationFn:a(s=>x.install(s),"mutationFn"),onSuccess:a(()=>{f(),P(!1),T(""),r({title:"Plugin installed successfully",tone:"success"})},"onSuccess"),onError:a(s=>{r({title:"Failed to install plugin",body:s.message,tone:"error"})},"onError")}),b=k({mutationFn:a(s=>x.uninstall(s),"mutationFn"),onSuccess:a(()=>{f(),r({title:"Plugin uninstalled successfully",tone:"success"})},"onSuccess"),onError:a(s=>{r({title:"Failed to uninstall plugin",body:s.message,tone:"error"})},"onError")}),v=k({mutationFn:a(s=>x.enable(s),"mutationFn"),onSuccess:a(()=>{f(),r({title:"Plugin enabled",tone:"success"})},"onSuccess"),onError:a(s=>{r({title:"Failed to enable plugin",body:s.message,tone:"error"})},"onError")}),U=k({mutationFn:a(s=>x.disable(s),"mutationFn"),onSuccess:a(()=>{f(),r({title:"Plugin disabled",tone:"info"})},"onSuccess"),onError:a(s=>{r({title:"Failed to disable plugin",body:s.message,tone:"error"})},"onError")}),h=ae??[],S=N.data??[],re=new Map(h.map(s=>[s.packageName,s])),F=new Map(S.map(s=>[s.packageName,s])),$=i.variables?.isLocalPath?i.error?.message??null:null,ie=(0,c.useMemo)(()=>new Map(h.map(s=>[s.id,H(s)])),[h]);return te||j.kind==="reconnecting"?(0,e.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading plugins..."}):j.kind==="error"?(0,e.jsx)(V,{size:"page",error:ne,action:"load plugins",onRetry:j.retry,retrying:j.isFetching}):(0,e.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(z,{className:"h-6 w-6 text-muted-foreground"}),(0,e.jsx)("h1",{className:"text-xl font-semibold",children:"System plugins"})]}),(0,e.jsxs)(J,{open:Z,onOpenChange:P,children:[(0,e.jsx)(ye,{asChild:!0,children:(0,e.jsxs)(n,{size:"sm",className:"gap-2",children:[(0,e.jsx)(ke,{className:"h-4 w-4"}),"Install system plugin"]})}),(0,e.jsxs)(q,{children:[(0,e.jsxs)(B,{children:[(0,e.jsx)(A,{children:"Install system plugin"}),(0,e.jsx)(Q,{children:"Enter the npm package name of the plugin you wish to install."})]}),(0,e.jsx)("div",{className:"grid gap-4 py-4",children:(0,e.jsxs)("div",{className:"grid gap-2",children:[(0,e.jsx)(ve,{htmlFor:"packageName",children:"npm Package Name"}),(0,e.jsx)(pe,{id:"packageName",placeholder:"@paperclipai/plugin-example",value:w,onChange:a(s=>T(s.target.value),"onChange")})]})}),(0,e.jsxs)(M,{children:[(0,e.jsx)(n,{variant:"outline",onClick:a(()=>P(!1),"onClick"),children:"Cancel"}),(0,e.jsx)(n,{onClick:a(()=>i.mutate({packageName:w}),"onClick"),disabled:!w||i.isPending,children:i.isPending?"Installing...":"Install"})]})]})]})]}),(0,e.jsx)("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 px-4 py-3",children:(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,e.jsx)(L,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-700"}),(0,e.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,e.jsx)("p",{className:"font-medium text-foreground",children:"System plugins are alpha."}),(0,e.jsx)("p",{className:"text-muted-foreground",children:"The plugin runtime and API surface are still changing. Expect breaking changes while this feature settles."})]})]})}),(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(me,{className:"h-5 w-5 text-muted-foreground"}),(0,e.jsx)("h2",{className:"text-base font-semibold",children:"Available system plugins"}),(0,e.jsx)(o,{variant:"outline",children:"Bundled"})]}),$&&(0,e.jsx)("div",{className:"rounded-md border border-destructive/25 bg-destructive/[0.06] px-4 py-3 text-sm text-destructive whitespace-pre-wrap break-words",children:$}),N.isLoading||y.kind==="reconnecting"?(0,e.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading bundled plugins..."}):y.kind==="error"?(0,e.jsx)(V,{error:N.error,action:"load bundled plugins",onRetry:y.retry,retrying:y.isFetching}):S.length===0?(0,e.jsx)("div",{className:"rounded-md border border-dashed px-4 py-3 text-sm text-muted-foreground",children:"No bundled plugins were found in this checkout."}):(0,e.jsx)(_,{className:"block py-0",children:(0,e.jsx)("ul",{className:"divide-y",children:S.map(s=>{const l=re.get(s.packageName),I=i.isPending&&i.variables?.isLocalPath&&i.variables.packageName===s.localPath;return(0,e.jsx)("li",{children:(0,e.jsxs)("div",{className:"flex items-center gap-4 px-4 py-3",children:[(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("span",{className:"font-medium",children:s.displayName}),(0,e.jsx)(o,{variant:"outline",children:s.tag==="first-party"?"First-party":"Example"}),W({packageName:s.packageName,packagePath:s.localPath,bundledExperimental:s.experimental})&&(0,e.jsx)(Y,{}),l?(0,e.jsx)(o,{variant:l.status==="ready"?"default":"secondary",className:l.status==="ready"?"bg-green-600 hover:bg-green-700":"",children:l.status}):(0,e.jsx)(o,{variant:"secondary",children:"Not installed"})]}),(0,e.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:s.description}),(0,e.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:s.packageName}),I&&!s.hasBuiltEntrypoints&&(0,e.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Building plugin..."})]}),(0,e.jsx)("div",{className:"flex items-center gap-2 shrink-0",children:l?(0,e.jsxs)(e.Fragment,{children:[l.status!=="ready"&&(0,e.jsx)(n,{variant:"outline",size:"sm",disabled:v.isPending,onClick:a(()=>v.mutate(l.id),"onClick"),children:"Enable"}),(0,e.jsx)(n,{variant:"outline",size:"sm",asChild:!0,children:(0,e.jsx)(D,{to:`/company/settings/instance/plugins/${l.id}`,children:l.status==="ready"?"Open Settings":"Review"})})]}):(0,e.jsx)(n,{size:"sm",disabled:I||i.isPending,onClick:a(()=>i.mutate({packageName:s.localPath,isLocalPath:!0}),"onClick"),children:I?"Installing...":"Install"})})]})},s.packageName)})})})]}),(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(z,{className:"h-5 w-5 text-muted-foreground"}),(0,e.jsx)("h2",{className:"text-base font-semibold",children:"Installed system plugins"})]}),h.length?(0,e.jsx)(_,{className:"block py-0",children:(0,e.jsx)("ul",{className:"divide-y",children:h.map(s=>(0,e.jsx)("li",{children:(0,e.jsxs)("div",{className:"flex items-start gap-4 px-4 py-3",children:[(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(D,{to:`/company/settings/instance/plugins/${s.id}`,className:"font-medium hover:underline truncate block",title:s.manifestJson.displayName??s.packageName,children:s.manifestJson.displayName??s.packageName}),F.has(s.packageName)&&(0,e.jsx)(o,{variant:"outline",children:F.get(s.packageName)?.tag==="first-party"?"First-party":"Example"}),W({packageName:s.packageName,packagePath:s.packagePath,manifestJson:s.manifestJson,bundledExperimental:F.get(s.packageName)?.experimental})&&(0,e.jsx)(Y,{})]}),(0,e.jsx)("div",{children:(0,e.jsxs)("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",title:s.packageName,children:[s.packageName," · v",s.manifestJson.version??s.version]})}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground truncate mt-0.5",title:s.manifestJson.description,children:s.manifestJson.description||"No description provided."}),s.status==="error"&&(0,e.jsx)("div",{className:"mt-3 rounded-md border border-red-500/25 bg-red-500/[0.06] px-3 py-2",children:(0,e.jsxs)("div",{className:"flex flex-wrap items-start gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-red-700 dark:text-red-300",children:[(0,e.jsx)(L,{className:"h-4 w-4 shrink-0"}),(0,e.jsx)("span",{children:"Plugin error"})]}),(0,e.jsx)("p",{className:"mt-1 text-sm text-red-700/90 dark:text-red-200/90 break-words",title:s.lastError??void 0,children:ie.get(s.id)})]}),(0,e.jsx)(n,{variant:"outline",size:"sm",className:"border-red-500/30 bg-background/60 text-red-700 hover:bg-red-500/10 hover:text-red-800 dark:text-red-200 dark:hover:text-red-100",onClick:a(()=>E(s),"onClick"),children:"View full error"})]})})]}),(0,e.jsx)("div",{className:"flex shrink-0 self-center",children:(0,e.jsxs)("div",{className:"flex flex-col items-end gap-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(o,{variant:s.status==="ready"?"default":s.status==="error"?"destructive":"secondary",className:K("shrink-0",s.status==="ready"?"bg-green-600 hover:bg-green-700":""),children:s.status}),(0,e.jsx)(n,{variant:"outline",size:"icon-sm",className:"h-8 w-8",title:s.status==="ready"?"Disable":"Enable",onClick:a(()=>{s.status==="ready"?U.mutate(s.id):v.mutate(s.id)},"onClick"),disabled:v.isPending||U.isPending,children:(0,e.jsx)(de,{className:K("h-4 w-4",s.status==="ready"?"text-green-600":"")})}),(0,e.jsx)(n,{variant:"outline",size:"icon-sm",className:"h-8 w-8 text-destructive hover:text-destructive",title:"Uninstall",onClick:a(()=>{p(s.id),se(s.manifestJson.displayName??s.packageName)},"onClick"),disabled:b.isPending,children:(0,e.jsx)(Ne,{className:"h-4 w-4"})})]}),(0,e.jsx)(n,{variant:"outline",size:"sm",className:"mt-2 h-8",asChild:!0,children:(0,e.jsxs)(D,{to:`/company/settings/instance/plugins/${s.id}`,children:[(0,e.jsx)(he,{className:"h-4 w-4"}),"Configure"]})})]})})]})},s.id))})}):(0,e.jsx)(_,{className:"bg-muted/30",children:(0,e.jsxs)(ge,{className:"flex flex-col items-center justify-center py-10",children:[(0,e.jsx)(z,{className:"h-10 w-10 text-muted-foreground mb-4"}),(0,e.jsx)("p",{className:"text-sm font-medium",children:"No system plugins installed"}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Install a plugin to extend functionality."})]})})]}),(0,e.jsx)(J,{open:C!==null,onOpenChange:a(s=>{s||p(null)},"onOpenChange"),children:(0,e.jsxs)(q,{children:[(0,e.jsxs)(B,{children:[(0,e.jsx)(A,{children:"Uninstall Plugin"}),(0,e.jsxs)(Q,{children:["Are you sure you want to uninstall ",(0,e.jsx)("strong",{children:ee}),"? This action cannot be undone."]})]}),(0,e.jsxs)(M,{children:[(0,e.jsx)(n,{variant:"outline",onClick:a(()=>p(null),"onClick"),children:"Cancel"}),(0,e.jsx)(n,{variant:"destructive",disabled:b.isPending,onClick:a(()=>{C&&b.mutate(C,{onSettled:a(()=>p(null),"onSettled")})},"onClick"),children:b.isPending?"Uninstalling...":"Uninstall"})]})]})}),(0,e.jsx)(J,{open:m!==null,onOpenChange:a(s=>{s||E(null)},"onOpenChange"),children:(0,e.jsxs)(q,{className:"sm:max-w-2xl",children:[(0,e.jsxs)(B,{children:[(0,e.jsx)(A,{children:"Error Details"}),(0,e.jsxs)(Q,{children:[m?.manifestJson.displayName??m?.packageName??"Plugin"," hit an error state."]})]}),(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"rounded-md border border-red-500/25 bg-red-500/[0.06] px-4 py-3",children:(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,e.jsx)(L,{className:"mt-0.5 h-4 w-4 shrink-0 text-red-700 dark:text-red-300"}),(0,e.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,e.jsx)("p",{className:"font-medium text-red-700 dark:text-red-300",children:"What errored"}),(0,e.jsx)("p",{className:"text-red-700/90 dark:text-red-200/90 break-words",children:m?H(m):"No error summary available."})]})]})}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("p",{className:"text-sm font-medium",children:"Full error output"}),(0,e.jsx)("pre",{className:K("max-h-(--sz-50vh) overflow-auto rounded-md border bg-muted/40 p-3 text-xs leading-5 whitespace-pre-wrap break-words",oe),children:m?.lastError??"No stored error message."})]})]}),(0,e.jsx)(M,{children:(0,e.jsx)(n,{variant:"outline",onClick:a(()=>E(null),"onClick"),children:"Close"})})]})})]})}a(Fe,"PluginManager");export{Fe as PluginManager};