@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 +1 @@
1
- var S=Object.defineProperty;var p=(t,n)=>S(t,"name",{value:n,configurable:!0});import{a as b}from"./rolldown-runtime-DhZMWcEn.js";import{$A as _,$_ as M,GS as q,Gb as B,LS as K,NE as R,Z_ as U,aE as D,ib as E,lv as $,nj as w,nr as j,qT as z,qb as A,xE as F}from"./index-Bt31d8ga.js";var c=b(w(),1),r=b(_(),1);function Z(){const t=D(),{companyPrefix:n,pluginId:l,pluginRoutePath:s}=t,d=t["*"],{companies:m,selectedCompanyId:N}=K(),{setBreadcrumbs:h}=E(),y=(0,c.useMemo)(()=>{if(!n)return null;const i=n.toUpperCase();return m.find(e=>e.issuePrefix.toUpperCase()===i)??null},[m,n]),C=!!n&&!y,u=(0,c.useMemo)(()=>y?y.id:n?null:N??null,[y,n,N]),x=(0,c.useMemo)(()=>u?m.find(i=>i.id===u)?.issuePrefix??null:null,[m,u]),{data:a}=F({queryKey:q.plugins.uiContributions,queryFn:p(()=>$.listUiContributions(),"queryFn"),enabled:!!u&&(!!l||!!s)}),g=(0,c.useMemo)(()=>{if(!a)return null;if(l){const e=a.find(f=>f.pluginId===l);if(!e)return null;const o=e.slots.find(f=>f.type==="page");return o?{...o,pluginId:e.pluginId,pluginKey:e.pluginKey,pluginDisplayName:e.displayName,pluginVersion:e.version}:null}if(!s)return null;const i=a.flatMap(e=>{const o=e.slots.find(f=>f.type==="page"&&f.routePath===s);return o?[{...o,pluginId:e.pluginId,pluginKey:e.pluginKey,pluginDisplayName:e.displayName,pluginVersion:e.version}]:[]});return i.length!==1?null:i[0]??null},[l,s,a]),I=(0,c.useMemo)(()=>({companyId:u??null,companyPrefix:x}),[u,x]),v=(0,c.useMemo)(()=>{if(!s||!a)return!1;const i=a.flatMap(e=>e.slots.map(o=>({...o,pluginId:e.pluginId,pluginKey:e.pluginKey,pluginDisplayName:e.displayName,pluginVersion:e.version})));return M(i,s)!==null},[a,s]);if((0,c.useEffect)(()=>{if(g){if(v){h([{label:L(g,d)}]);return}h([{label:"System plugins",href:"/company/settings/instance/plugins"},{label:g.pluginDisplayName}])}},[g,d,h,v]),!u)return C?(0,r.jsx)(j,{scope:"invalid_company_prefix",requestedPrefix:n}):(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select an organization to view this page."})});if(!a)return(0,r.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading…"});if(!l&&s&&a.filter(i=>i.slots.some(e=>e.type==="page"&&e.routePath===s)).length>1)return(0,r.jsxs)("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:["Multiple plugins declare the route ",(0,r.jsx)("code",{children:s}),". Use the plugin-id route until the conflict is resolved."]});if(!g){if(s)return(0,r.jsx)(j,{scope:"board"});const i=l?`/company/settings/instance/plugins/${l}`:"/company/settings/instance/plugins";return(0,r.jsx)(A,{to:i,replace:!0})}return(0,r.jsxs)("div",{className:"space-y-4",children:[!v&&(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsx)(R,{variant:"ghost",size:"sm",asChild:!0,children:(0,r.jsxs)(B,{to:x?`/${x}/dashboard`:"/dashboard",children:[(0,r.jsx)(z,{className:"h-4 w-4 mr-1"}),"Back"]})})}),(0,r.jsx)(U,{slot:g,context:I,className:"min-h-(--sz-200px)",missingBehavior:"placeholder"})]})}p(Z,"PluginPage");function L(t,n){return V(n)??t.displayName??t.pluginDisplayName}p(L,"resolveRouteSidebarPageTitle");function V(t){const n=(t??"").split("/").filter(Boolean).map(k);return n.length===0?null:n[0]==="page"&&n.length>1?P(n.slice(1).join("/"),{preserveCase:!0}):P(n[0]??null)}p(V,"titleFromRouteSplat");function P(t,n={}){const l=t?.trim();if(!l)return null;const s=l.split("/").filter(Boolean).at(-1)??l,d=(s.split("::").at(-1)??s).replace(/\.[^.]+$/,"").replace(/[-_]+/g," ").trim();return d?n.preserveCase?d:d.replace(/\b\w/g,m=>m.toUpperCase()):null}p(P,"titleFromPath");function k(t){try{return decodeURIComponent(t)}catch{return t}}p(k,"decodeRouteSegment");export{Z as PluginPage};
1
+ var S=Object.defineProperty;var p=(t,n)=>S(t,"name",{value:n,configurable:!0});import{a as b}from"./rolldown-runtime-DhZMWcEn.js";import{$A as _,$_ as M,GS as q,Gb as B,LS as K,NE as R,Z_ as U,aE as D,ib as E,lv as $,nj as w,nr as j,qT as z,qb as A,xE as F}from"./index-BJtnP7H1.js";var c=b(w(),1),r=b(_(),1);function Z(){const t=D(),{companyPrefix:n,pluginId:l,pluginRoutePath:s}=t,d=t["*"],{companies:m,selectedCompanyId:N}=K(),{setBreadcrumbs:h}=E(),y=(0,c.useMemo)(()=>{if(!n)return null;const i=n.toUpperCase();return m.find(e=>e.issuePrefix.toUpperCase()===i)??null},[m,n]),C=!!n&&!y,u=(0,c.useMemo)(()=>y?y.id:n?null:N??null,[y,n,N]),x=(0,c.useMemo)(()=>u?m.find(i=>i.id===u)?.issuePrefix??null:null,[m,u]),{data:a}=F({queryKey:q.plugins.uiContributions,queryFn:p(()=>$.listUiContributions(),"queryFn"),enabled:!!u&&(!!l||!!s)}),g=(0,c.useMemo)(()=>{if(!a)return null;if(l){const e=a.find(f=>f.pluginId===l);if(!e)return null;const o=e.slots.find(f=>f.type==="page");return o?{...o,pluginId:e.pluginId,pluginKey:e.pluginKey,pluginDisplayName:e.displayName,pluginVersion:e.version}:null}if(!s)return null;const i=a.flatMap(e=>{const o=e.slots.find(f=>f.type==="page"&&f.routePath===s);return o?[{...o,pluginId:e.pluginId,pluginKey:e.pluginKey,pluginDisplayName:e.displayName,pluginVersion:e.version}]:[]});return i.length!==1?null:i[0]??null},[l,s,a]),I=(0,c.useMemo)(()=>({companyId:u??null,companyPrefix:x}),[u,x]),v=(0,c.useMemo)(()=>{if(!s||!a)return!1;const i=a.flatMap(e=>e.slots.map(o=>({...o,pluginId:e.pluginId,pluginKey:e.pluginKey,pluginDisplayName:e.displayName,pluginVersion:e.version})));return M(i,s)!==null},[a,s]);if((0,c.useEffect)(()=>{if(g){if(v){h([{label:L(g,d)}]);return}h([{label:"System plugins",href:"/company/settings/instance/plugins"},{label:g.pluginDisplayName}])}},[g,d,h,v]),!u)return C?(0,r.jsx)(j,{scope:"invalid_company_prefix",requestedPrefix:n}):(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select an organization to view this page."})});if(!a)return(0,r.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading…"});if(!l&&s&&a.filter(i=>i.slots.some(e=>e.type==="page"&&e.routePath===s)).length>1)return(0,r.jsxs)("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:["Multiple plugins declare the route ",(0,r.jsx)("code",{children:s}),". Use the plugin-id route until the conflict is resolved."]});if(!g){if(s)return(0,r.jsx)(j,{scope:"board"});const i=l?`/company/settings/instance/plugins/${l}`:"/company/settings/instance/plugins";return(0,r.jsx)(A,{to:i,replace:!0})}return(0,r.jsxs)("div",{className:"space-y-4",children:[!v&&(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsx)(R,{variant:"ghost",size:"sm",asChild:!0,children:(0,r.jsxs)(B,{to:x?`/${x}/dashboard`:"/dashboard",children:[(0,r.jsx)(z,{className:"h-4 w-4 mr-1"}),"Back"]})})}),(0,r.jsx)(U,{slot:g,context:I,className:"min-h-(--sz-200px)",missingBehavior:"placeholder"})]})}p(Z,"PluginPage");function L(t,n){return V(n)??t.displayName??t.pluginDisplayName}p(L,"resolveRouteSidebarPageTitle");function V(t){const n=(t??"").split("/").filter(Boolean).map(k);return n.length===0?null:n[0]==="page"&&n.length>1?P(n.slice(1).join("/"),{preserveCase:!0}):P(n[0]??null)}p(V,"titleFromRouteSplat");function P(t,n={}){const l=t?.trim();if(!l)return null;const s=l.split("/").filter(Boolean).at(-1)??l,d=(s.split("::").at(-1)??s).replace(/\.[^.]+$/,"").replace(/[-_]+/g," ").trim();return d?n.preserveCase?d:d.replace(/\b\w/g,m=>m.toUpperCase()):null}p(P,"titleFromPath");function k(t){try{return decodeURIComponent(t)}catch{return t}}p(k,"decodeRouteSegment");export{Z as PluginPage};
@@ -1 +1 @@
1
- var fe=Object.defineProperty;var o=(s,a)=>fe(s,"name",{value:a,configurable:!0});import{a as ie}from"./rolldown-runtime-DhZMWcEn.js";import{M as pe,ai as je}from"./issue-detail-4PCbYpdv.js";import{i as Q}from"./collections-BxrcELwt.js";import{$A as be,Ai as Z,Di as Ne,E_ as P,GS as N,Gb as X,Gw as ve,H_ as f,KC as ye,LC as we,LS as ke,ME as le,M_ as _,NE as E,NT as Ce,O_ as M,QT as oe,Z_ as Se,_T as qe,_w as z,aE as Le,ab as ce,bE as B,ev as De,hC as Fe,hE as H,ib as Pe,ip as I,jC as _e,j_ as $,k_ as ee,ki as Me,lv as v,nj as $e,np as Ee,ob as de,pT as Ke,qT as Te,qb as Re,qu as ze,rp as R,sT as se,ub as xe,xE as D}from"./index-Bt31d8ga.js";var ue={name:"circle-check-big",size:24,node:[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],aliases:["check-circle"]};ue.node;var Ae=oe(ue),me={name:"square-activity",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M17 12h-2l-2 5-2-10-2 5H7",key:"15hlnc"}]],aliases:["activity-square"]};me.node;var te=oe(me),h=ie($e(),1),e=ie(be(),1);function ts(){const{selectedCompany:s,selectedCompanyId:a}=ke(),{setBreadcrumbs:r}=Pe(),{companyPrefix:i,pluginId:l}=Le(),{hideHostPaths:g}=pe(),[u,y]=(0,h.useState)("configuration"),j=D({queryKey:N.plugins.detail(l),queryFn:o(()=>v.get(l),"queryFn"),enabled:!!l}),n=j.data,p=xe(j),{data:m,isLoading:F}=D({queryKey:N.plugins.health(l),queryFn:o(()=>v.health(l),"queryFn"),enabled:!!l&&n?.status==="ready",refetchInterval:3e4}),{data:c}=D({queryKey:N.plugins.dashboard(l),queryFn:o(()=>v.dashboard(l),"queryFn"),enabled:!!l,refetchInterval:3e4}),{data:b}=D({queryKey:N.plugins.logs(l),queryFn:o(()=>v.logs(l,{limit:50}),"queryFn"),enabled:!!l&&n?.status==="ready",refetchInterval:3e4}),d=n?.manifestJson?.instanceConfigSchema,w=d&&d.properties&&Object.keys(d.properties).length>0,C=l&&a?N.plugins.config(l,a):["plugins",l??"__missing_plugin__","companies","__missing_company__","config"],{data:K,isLoading:S,isSuccess:L}=D({queryKey:C,queryFn:o(()=>v.getConfig(l,a),"queryFn"),enabled:!!l&&!!w&&!!a}),{slots:A}=De({slotTypes:["settingsPage"],companyId:a,enabled:!!a}),T=A.filter(t=>t.pluginId===l||t.pluginKey===l),J=T.length>0;if((0,h.useEffect)(()=>{r([{label:s?.name??"Organization",href:"/dashboard"},{label:"Settings",href:"/company/settings"},{label:"System plugins",href:"/company/settings/instance/plugins"},{label:n?.manifestJson?.displayName??n?.packageName??"Plugin Details"}])},[s?.name,r,i,n]),(0,h.useEffect)(()=>{y("configuration")},[l]),p.kind==="loading"||p.kind==="reconnecting")return(0,e.jsx)(de,{size:"page",label:"Loading plugin details",className:"p-4"});if(p.kind==="error")return(0,e.jsx)(ce,{size:"page",className:"p-4",error:j.error,action:"load this plugin",onRetry:p.retry,retrying:p.isFetching});if(!n)return(0,e.jsx)(Re,{to:"/company/settings/instance/plugins",replace:!0});const x=n.status,k=n.status==="ready"?"default":n.status==="error"?"destructive":"secondary",q=n.manifestJson.description||"No description provided.",V=n.manifestJson.capabilities??[],G=n.manifestJson.environmentDrivers??[],Y=n.manifestJson.localFolders??[],U=Y.length>0&&!g,he=G.map(t=>t.displayName?.trim()||t.driverKey).filter((t,O,ge)=>ge.indexOf(t)===O).join(", ");return(0,e.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,e.jsx)(X,{to:"/company/settings/instance/plugins",children:(0,e.jsx)(E,{variant:"outline",size:"icon",className:"h-8 w-8",children:(0,e.jsx)(Te,{className:"h-4 w-4"})})}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(ye,{className:"h-6 w-6 text-muted-foreground"}),(0,e.jsx)("h1",{className:"text-xl font-semibold",children:n.manifestJson.displayName??n.packageName}),(0,e.jsx)(f,{variant:k,className:"ml-2",children:x}),(0,e.jsxs)(f,{variant:"outline",className:"ml-1",children:["v",n.manifestJson.version??n.version]})]})]}),(0,e.jsxs)(Me,{value:u,onValueChange:o(t=>y(t),"onValueChange"),className:"space-y-6",children:[(0,e.jsx)(Ne,{align:"start",items:[{value:"configuration",label:"Configuration"},{value:"status",label:"Status"}],value:u,onValueChange:o(t=>y(t),"onValueChange")}),(0,e.jsx)(Z,{value:"configuration",className:"space-y-6",children:(0,e.jsxs)("div",{className:"space-y-8",children:[(0,e.jsxs)("section",{className:"space-y-5",children:[(0,e.jsx)("h2",{className:"text-base font-semibold",children:"About"}),(0,e.jsxs)("div",{className:"grid gap-8 lg:grid-cols-(--gtc-52)",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Description"}),(0,e.jsx)("p",{className:"text-sm leading-6 text-foreground/90",children:q})]}),(0,e.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("h3",{className:"font-medium text-muted-foreground",children:"Author"}),(0,e.jsx)("p",{className:"text-foreground",children:n.manifestJson.author})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"font-medium text-muted-foreground",children:"Categories"}),(0,e.jsx)("div",{className:"flex flex-wrap gap-2",children:n.categories.length>0?n.categories.map(t=>(0,e.jsx)(f,{variant:"outline",className:"capitalize",children:t},t)):(0,e.jsx)("span",{className:"text-foreground",children:"None"})})]})]})]})]}),(0,e.jsx)(Q,{}),(0,e.jsxs)("section",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"space-y-1",children:(0,e.jsx)("h2",{className:"text-base font-semibold",children:"Settings"})}),U?(0,e.jsx)(Je,{pluginId:l,companyId:a,declarations:Y}):null,J?(0,e.jsx)("div",{className:"space-y-3",children:T.map(t=>(0,e.jsx)(Se,{slot:t,context:{companyId:a,companyPrefix:i??null},missingBehavior:"placeholder"},`${t.pluginKey}:${t.id}`))}):w?(0,e.jsx)(He,{pluginId:l,companyId:a,schema:d,initialValues:K?.configJson,needsInitialSave:L&&K===null,isLoading:S,pluginStatus:n.status,supportsConfigTest:n.supportsConfigTest===!0}):G.length>0?(0,e.jsxs)("div",{className:"rounded-md border border-border/60 bg-muted/20 px-4 py-3 text-sm",children:[(0,e.jsx)("p",{className:"font-medium text-foreground",children:"Configure this plugin from Settings → Environments."}),(0,e.jsxs)("p",{className:"mt-1 text-muted-foreground",children:[he||"This plugin"," registers environment runtime settings there so the execution target stays instance-scoped while secret bindings still resolve through the selected organization context."]}),(0,e.jsx)("div",{className:"mt-3",children:(0,e.jsx)(X,{to:"/company/settings/instance/environments",children:(0,e.jsx)(E,{variant:"outline",size:"sm",children:"Open Environments"})})})]}):U?null:(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"This plugin does not require any settings."})]})]})}),(0,e.jsx)(Z,{value:"status",className:"space-y-6",children:(0,e.jsxs)("div",{className:"grid gap-6 xl:grid-cols-(--gtc-39)",children:[(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)(P,{children:[(0,e.jsxs)($,{children:[(0,e.jsxs)(_,{className:"text-base flex items-center gap-1.5",children:[(0,e.jsx)(se,{className:"h-4 w-4"}),"Runtime Dashboard"]}),(0,e.jsx)(ee,{children:"Worker process, scheduled jobs, and webhook deliveries"})]}),(0,e.jsx)(M,{className:"space-y-6",children:c?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[(0,e.jsx)(se,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Worker Process"]}),c.worker?(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[(0,e.jsxs)("div",{className:"flex justify-between",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Status"}),(0,e.jsx)(f,{variant:c.worker.status==="running"?"default":"secondary",children:c.worker.status})]}),(0,e.jsxs)("div",{className:"flex justify-between",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"PID"}),(0,e.jsx)("span",{className:"font-mono text-xs",children:c.worker.pid??"—"})]}),(0,e.jsxs)("div",{className:"flex justify-between",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Uptime"}),(0,e.jsx)("span",{className:"text-xs",children:Ve(c.worker.uptime)})]}),(0,e.jsxs)("div",{className:"flex justify-between",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Pending RPCs"}),(0,e.jsx)("span",{className:"text-xs",children:c.worker.pendingRequests})]}),c.worker.totalCrashes>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"flex justify-between col-span-2",children:[(0,e.jsxs)("span",{className:"text-muted-foreground flex items-center gap-1",children:[(0,e.jsx)(Fe,{className:"h-3 w-3 text-amber-500"}),"Crashes"]}),(0,e.jsxs)("span",{className:"text-xs",children:[c.worker.consecutiveCrashes," consecutive / ",c.worker.totalCrashes," total"]})]}),c.worker.lastCrashAt&&(0,e.jsxs)("div",{className:"flex justify-between col-span-2",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Last Crash"}),(0,e.jsx)("span",{className:"text-xs",children:Ge(c.worker.lastCrashAt)})]})]})]}):(0,e.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No worker process registered."})]}),(0,e.jsx)(Q,{}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[(0,e.jsx)(Ce,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Recent Job Runs"]}),c.recentJobRuns.length>0?(0,e.jsx)("div",{className:"space-y-2",children:c.recentJobRuns.map(t=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-md bg-muted/50 px-2 py-1.5 text-sm",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,e.jsx)(Ye,{status:t.status}),(0,e.jsx)("span",{className:"truncate font-mono text-xs",title:t.jobKey??t.jobId,children:t.jobKey??t.jobId.slice(0,8)}),(0,e.jsx)(f,{variant:"outline",className:"px-1 py-0 text-(length:--text-nano)",children:t.trigger})]}),(0,e.jsxs)("div",{className:"flex shrink-0 items-center gap-2 text-xs text-muted-foreground",children:[t.durationMs!=null?(0,e.jsx)("span",{children:ae(t.durationMs)}):null,(0,e.jsx)("span",{title:t.createdAt,children:ne(t.createdAt)})]})]},t.id))}):(0,e.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No job runs recorded yet."})]}),(0,e.jsx)(Q,{}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[(0,e.jsx)(je,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Recent Webhook Deliveries"]}),c.recentWebhookDeliveries.length>0?(0,e.jsx)("div",{className:"space-y-2",children:c.recentWebhookDeliveries.map(t=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-md bg-muted/50 px-2 py-1.5 text-sm",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,e.jsx)(Ue,{status:t.status}),(0,e.jsx)("span",{className:"truncate font-mono text-xs",title:t.webhookKey,children:t.webhookKey})]}),(0,e.jsxs)("div",{className:"flex shrink-0 items-center gap-2 text-xs text-muted-foreground",children:[t.durationMs!=null?(0,e.jsx)("span",{children:ae(t.durationMs)}):null,(0,e.jsx)("span",{title:t.createdAt,children:ne(t.createdAt)})]})]},t.id))}):(0,e.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No webhook deliveries recorded yet."})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1.5 border-t border-border/50 pt-2 text-xs text-muted-foreground",children:[(0,e.jsx)(Ke,{className:"h-3 w-3"}),"Last checked: ",new Date(c.checkedAt).toLocaleTimeString()]})]}):(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Runtime diagnostics are unavailable right now."})})]}),b&&b.length>0?(0,e.jsxs)(P,{children:[(0,e.jsxs)($,{children:[(0,e.jsxs)(_,{className:"text-base flex items-center gap-1.5",children:[(0,e.jsx)(te,{className:"h-4 w-4"}),"Recent Logs"]}),(0,e.jsxs)(ee,{children:["Last ",b.length," log entries"]})]}),(0,e.jsx)(M,{children:(0,e.jsx)("div",{className:"max-h-64 space-y-1 overflow-y-auto font-mono text-xs",children:b.map(t=>(0,e.jsxs)("div",{className:`flex gap-2 py-0.5 ${t.level==="error"?"text-destructive":t.level==="warn"?"text-yellow-600 dark:text-yellow-400":t.level==="debug"?"text-muted-foreground/60":"text-muted-foreground"}`,children:[(0,e.jsx)("span",{className:"shrink-0 text-muted-foreground/50",children:new Date(t.createdAt).toLocaleTimeString()}),(0,e.jsx)(f,{variant:"outline",className:"h-4 shrink-0 px-1 text-(length:--text-nano)",children:t.level}),(0,e.jsx)("span",{className:"truncate",title:t.message,children:t.message})]},t.id))})})]}):null]}),(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)(P,{children:[(0,e.jsx)($,{children:(0,e.jsxs)(_,{className:"text-base flex items-center gap-1.5",children:[(0,e.jsx)(te,{className:"h-4 w-4"}),"Health Status"]})}),(0,e.jsx)(M,{children:F?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Checking health..."}):m?(0,e.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Overall"}),(0,e.jsx)(f,{variant:m.healthy?"default":"destructive",children:m.status})]}),m.checks.length>0?(0,e.jsx)("div",{className:"space-y-2 border-t border-border/50 pt-2",children:m.checks.map((t,O)=>(0,e.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,e.jsx)("span",{className:"truncate text-muted-foreground",title:t.name,children:t.name}),t.passed?(0,e.jsx)(Ae,{className:"h-4 w-4 shrink-0 text-green-500"}):(0,e.jsx)(qe,{className:"h-4 w-4 shrink-0 text-destructive"})]},O))}):null,m.lastError?(0,e.jsx)("div",{className:"break-words rounded border border-destructive/20 bg-destructive/10 p-2 text-xs text-destructive",children:m.lastError}):null]}):(0,e.jsxs)("div",{className:"space-y-3 text-sm text-muted-foreground",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)("span",{children:"Lifecycle"}),(0,e.jsx)(f,{variant:k,children:x})]}),(0,e.jsx)("p",{children:"Health checks run once the plugin is ready."}),n.lastError?(0,e.jsx)("div",{className:"break-words rounded border border-destructive/20 bg-destructive/10 p-2 text-xs text-destructive",children:n.lastError}):null]})})]}),(0,e.jsxs)(P,{children:[(0,e.jsx)($,{children:(0,e.jsx)(_,{className:"text-base",children:"Details"})}),(0,e.jsxs)(M,{className:"space-y-3 text-sm text-muted-foreground",children:[(0,e.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,e.jsx)("span",{children:"Plugin ID"}),(0,e.jsx)("span",{className:"font-mono text-xs text-right",children:n.id})]}),(0,e.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,e.jsx)("span",{children:"Plugin Key"}),(0,e.jsx)("span",{className:"font-mono text-xs text-right",children:n.pluginKey})]}),(0,e.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,e.jsx)("span",{children:"NPM Package"}),(0,e.jsx)("span",{className:"max-w-(--sz-170px) truncate text-right text-xs",title:n.packageName,children:n.packageName})]}),(0,e.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,e.jsx)("span",{children:"Version"}),(0,e.jsxs)("span",{className:"text-right text-foreground",children:["v",n.manifestJson.version??n.version]})]})]})]}),(0,e.jsxs)(P,{children:[(0,e.jsx)($,{children:(0,e.jsxs)(_,{className:"text-base flex items-center gap-1.5",children:[(0,e.jsx)(_e,{className:"h-4 w-4"}),"Permissions"]})}),(0,e.jsx)(M,{children:V.length>0?(0,e.jsx)("ul",{className:"space-y-2 text-sm text-muted-foreground",children:V.map(t=>(0,e.jsx)("li",{className:"rounded-md bg-muted/40 px-2.5 py-2 font-mono text-xs text-foreground/85",children:t},t))}):(0,e.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No special permissions requested."})})]})]})]})})]})]})}o(ts,"PluginSettings");function Je({pluginId:s,companyId:a,declarations:r}){const i=D({queryKey:a?N.plugins.localFolders(s,a):["plugins",s,"companies","none","local-folders"],queryFn:o(()=>v.listLocalFolders(s,a),"queryFn"),enabled:!!a}),l=xe(i),g=new Map((i.data?.folders??[]).map(u=>[u.folderKey,u]));return a?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(ve,{className:"h-4 w-4 text-muted-foreground"}),(0,e.jsx)("h3",{className:"text-sm font-medium",children:"Local folders"})]}),l.kind==="error"?(0,e.jsx)(ce,{size:"panel",error:i.error,action:"load local folder settings",onRetry:l.retry,retrying:l.isFetching}):null,l.kind==="loading"||l.kind==="reconnecting"?(0,e.jsx)(de,{size:"panel",label:"Loading local folders",className:"py-3"}):(0,e.jsx)("div",{className:"space-y-3",children:r.map(u=>(0,e.jsx)(Oe,{pluginId:s,companyId:a,declaration:u,status:g.get(u.folderKey)},u.folderKey))})]}):(0,e.jsx)("div",{className:"rounded-md border border-border/60 bg-muted/20 px-4 py-3 text-sm text-muted-foreground",children:"Select an organization to configure this plugin's local folders."})}o(Je,"PluginLocalFoldersSettings");function Oe({pluginId:s,companyId:a,declaration:r,status:i}){const l=le(),g=i?.path??"",[u,y]=(0,h.useState)(g),[j,n]=(0,h.useState)(null);(0,h.useEffect)(()=>{y(g),n(null)},[g,r.folderKey]);const p=B({mutationFn:o(d=>v.configureLocalFolder(s,a,r.folderKey,{path:d,access:r.access,requiredDirectories:r.requiredDirectories,requiredFiles:r.requiredFiles}),"mutationFn"),onSuccess:o(d=>{n({type:d.healthy?"success":"error",text:d.healthy?"Local folder saved.":"Local folder saved, but validation still needs attention."}),l.invalidateQueries({queryKey:N.plugins.localFolders(s,a)})},"onSuccess"),onError:o(d=>{n({type:"error",text:H(d).body})},"onError")}),m=u.trim(),F=m!==g,c=i?.access??r.access??"readWrite",b=(0,h.useCallback)(()=>{if(!m){n({type:"error",text:"Local folder path is required."});return}if(!Be(m)){n({type:"error",text:"Local folder must be a full absolute path."});return}n(null),p.mutate(m)},[p,m]);return(0,e.jsxs)("div",{className:"space-y-4 rounded-md border border-border/70 bg-background px-4 py-4",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("h4",{className:"text-sm font-medium",children:r.displayName}),(0,e.jsx)(f,{variant:"outline",className:"font-mono text-(length:--text-nano)",children:r.folderKey}),(0,e.jsx)(f,{variant:i?.healthy?"default":"secondary",children:i?.healthy?"Healthy":"Needs attention"})]}),r.description?(0,e.jsx)("p",{className:"max-w-3xl text-sm leading-5 text-muted-foreground",children:r.description}):null]}),(0,e.jsx)(f,{variant:c==="readWrite"?"default":"outline",children:c==="readWrite"?"Read/write":"Read only"})]}),(0,e.jsxs)("div",{className:"grid gap-3 text-sm sm:grid-cols-3",children:[(0,e.jsx)(W,{label:"Configured",value:i?.configured?"Yes":"No",ok:!!i?.configured}),(0,e.jsx)(W,{label:"Readable",value:i?.readable?"Yes":"No",ok:!!i?.readable}),(0,e.jsx)(W,{label:"Writable",value:c==="read"?"Not requested":i?.writable?"Yes":"No",ok:c==="read"||!!i?.writable})]}),i?.path?(0,e.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,e.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Configured path"}),(0,e.jsx)("div",{className:"break-all rounded-md bg-muted/60 px-2 py-1.5 font-mono text-xs text-foreground",children:i.path})]}):null,(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("label",{className:"text-xs font-medium text-muted-foreground",htmlFor:`local-folder-${r.folderKey}`,children:"Local folder path"}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("input",{id:`local-folder-${r.folderKey}`,className:"min-w-0 flex-1 rounded-md border border-border bg-background px-2.5 py-1.5 font-mono text-sm outline-none focus:border-foreground/40 focus:ring-2 focus:ring-ring/20",value:u,onChange:o(d=>{y(d.target.value),n(null)},"onChange"),placeholder:"/absolute/path/to/folder"}),(0,e.jsx)(ze,{className:"h-8"}),(0,e.jsxs)(E,{size:"sm",onClick:b,disabled:p.isPending||!F||!a,children:[p.isPending?(0,e.jsx)(z,{className:"h-3.5 w-3.5 animate-spin"}):(0,e.jsx)(we,{className:"h-3.5 w-3.5"}),"Save"]})]})]}),(0,e.jsx)(Qe,{status:i,declaration:r}),i?.problems?.length?(0,e.jsxs)("div",{className:"space-y-2 rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[(0,e.jsx)("div",{className:"font-medium",children:"Validation problems"}),(0,e.jsx)("ul",{className:"space-y-1",children:i.problems.map((d,w)=>(0,e.jsxs)("li",{children:[d.message,d.path?(0,e.jsxs)("span",{className:"font-mono",children:[" ",d.path]}):null]},`${d.code}:${d.path??""}:${w}`))})]}):null,j?(0,e.jsx)("div",{className:`rounded-md border px-3 py-2 text-sm ${j.type==="success"?"border-green-200 bg-green-50 text-green-700 dark:border-green-900 dark:bg-green-950/30 dark:text-green-400":"border-destructive/20 bg-destructive/10 text-destructive"}`,children:j.text}):null]})}o(Oe,"PluginLocalFolderRow");function W({label:s,value:a,ok:r}){return(0,e.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border/60 px-2.5 py-2",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:s}),(0,e.jsx)(f,{variant:r?"default":"secondary",children:a})]})}o(W,"FolderStatusMetric");function Qe({status:s,declaration:a}){const r=s?.requiredDirectories??a.requiredDirectories??[],i=s?.requiredFiles??a.requiredFiles??[],l=s?.missingDirectories??r,g=s?.missingFiles??i,u=We(s);return r.length===0&&i.length===0?null:(0,e.jsxs)("div",{className:"grid gap-3 text-sm md:grid-cols-2",children:[(0,e.jsx)(re,{title:"Required directories",items:r,missingItems:l,missingLabel:"Missing directories",inspectionUnavailable:u}),(0,e.jsx)(re,{title:"Required files",items:i,missingItems:g,missingLabel:"Missing files",inspectionUnavailable:u})]})}o(Qe,"FolderRequirements");function We(s){return!s?.configured||s.readable?!1:s.problems.some(a=>a.code==="missing"||a.code==="not_readable"||a.code==="not_directory")}o(We,"isRootNotInspected");function re({title:s,items:a,missingItems:r,missingLabel:i,inspectionUnavailable:l}){return(0,e.jsxs)("div",{className:"space-y-2 rounded-md border border-border/60 px-3 py-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:s}),l?(0,e.jsx)(f,{variant:"secondary",className:"text-(length:--text-nano)",children:"Not inspected"}):r.length>0?(0,e.jsxs)(f,{variant:"destructive",className:"text-(length:--text-nano)",children:[r.length," missing"]}):(0,e.jsx)(f,{variant:"outline",className:"text-(length:--text-nano)",children:"Present"})]}),a.length>0?(0,e.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.map(g=>{const u=r.includes(g);return(0,e.jsx)("span",{className:`rounded border px-1.5 py-0.5 font-mono text-(length:--text-micro) ${l?"border-amber-300/60 bg-amber-50 text-amber-700 dark:border-amber-800/70 dark:bg-amber-950/30 dark:text-amber-300":u?"border-destructive/30 bg-destructive/10 text-destructive":"border-border bg-muted/50 text-foreground/80"}`,children:g},g)})}):(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"None declared."}),l?(0,e.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:"Configured root was not inspected."}):r.length>0?(0,e.jsxs)("p",{className:"text-xs text-destructive",children:[i,": ",r.join(", ")]}):null]})}o(re,"RequirementList");function Be(s){return s.startsWith("/")||/^[A-Za-z]:[\\/]/.test(s)||s.startsWith("\\\\")}o(Be,"isLikelyAbsolutePath");function He({pluginId:s,companyId:a,schema:r,initialValues:i,needsInitialSave:l,isLoading:g,pluginStatus:u,supportsConfigTest:y}){const j=le(),[n,p]=(0,h.useState)(()=>({...R(r),...i??{}})),m=(0,h.useRef)(!1);(0,h.useEffect)(()=>{m.current=!1,p(R(r))},[a,s,r]),(0,h.useEffect)(()=>{i&&!m.current&&(m.current=!0,p({...R(r),...i}))},[i,r]);const[F,c]=(0,h.useState)({}),[b,d]=(0,h.useState)(null),[w,C]=(0,h.useState)(null),K=JSON.stringify(n)!==JSON.stringify({...R(r),...i??{}}),S=B({mutationFn:o(({pluginId:x,companyId:k,configJson:q})=>{if(!k)throw new Error("Select an organization before saving plugin configuration.");return v.saveConfig(x,k,q)},"mutationFn"),onSuccess:o((x,{pluginId:k,companyId:q})=>{d({type:"success",text:"Configuration saved."}),C(null),q&&(j.setQueryData(N.plugins.config(k,q),x),j.invalidateQueries({queryKey:N.plugins.config(k,q)})),setTimeout(()=>d(null),3e3)},"onSuccess"),onError:o(x=>{d({type:"error",text:H(x).body})},"onError")}),L=B({mutationFn:o(x=>{if(!a)throw new Error("Select an organization before testing plugin configuration.");return v.testConfig(s,a,x)},"mutationFn"),onSuccess:o(x=>{x.valid?C({type:"success",text:"Configuration test passed."}):C({type:"error",text:x.message||"Configuration test failed."})},"onSuccess"),onError:o(x=>{C({type:"error",text:H(x).body})},"onError")}),A=(0,h.useCallback)(x=>{p(x),c({}),d(null)},[]),T=(0,h.useCallback)(()=>{const x=I(r,n);if(Object.keys(x).length>0){c(x);return}c({}),S.mutate({pluginId:s,companyId:a,configJson:n})},[r,n,S,s,a]),J=(0,h.useCallback)(()=>{const x=I(r,n);if(Object.keys(x).length>0){c(x);return}c({}),C(null),L.mutate(n)},[r,n,L]);return g?(0,e.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-4",children:[(0,e.jsx)(z,{className:"h-4 w-4 animate-spin"}),"Loading configuration..."]}):(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)(Ee,{schema:r,values:n,onChange:A,errors:F,disabled:S.isPending}),b&&(0,e.jsx)("div",{className:`text-sm p-2 rounded border ${b.type==="success"?"text-green-700 bg-green-50 border-green-200 dark:text-green-400 dark:bg-green-950/30 dark:border-green-900":"text-destructive bg-destructive/10 border-destructive/20"}`,children:b.text}),w&&(0,e.jsx)("div",{className:`text-sm p-2 rounded border ${w.type==="success"?"text-green-700 bg-green-50 border-green-200 dark:text-green-400 dark:bg-green-950/30 dark:border-green-900":"text-destructive bg-destructive/10 border-destructive/20"}`,children:w.text}),(0,e.jsxs)("div",{className:"flex items-center gap-2 pt-2",children:[(0,e.jsx)(E,{onClick:T,disabled:S.isPending||!K&&!l,size:"sm",children:S.isPending?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(z,{className:"h-3.5 w-3.5 animate-spin"}),"Saving..."]}):"Save Configuration"}),u==="ready"&&y&&(0,e.jsx)(E,{variant:"outline",onClick:J,disabled:L.isPending||!a,size:"sm",children:L.isPending?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(z,{className:"h-3.5 w-3.5 animate-spin"}),"Testing..."]}):"Test Configuration"})]})]})}o(He,"PluginConfigForm");function Ve(s){if(s==null)return"—";const a=Math.floor(s/1e3);if(a<60)return`${a}s`;const r=Math.floor(a/60);if(r<60)return`${r}m ${a%60}s`;const i=Math.floor(r/60);return i<24?`${i}h ${r%60}m`:`${Math.floor(i/24)}d ${i%24}h`}o(Ve,"formatUptime");function ae(s){return s<1e3?`${s}ms`:s<6e4?`${(s/1e3).toFixed(1)}s`:`${(s/6e4).toFixed(1)}m`}o(ae,"formatDuration");function ne(s){const a=Date.now()-new Date(s).getTime();if(a<0)return"just now";const r=Math.floor(a/1e3);if(r<60)return`${r}s ago`;const i=Math.floor(r/60);if(i<60)return`${i}m ago`;const l=Math.floor(i/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}o(ne,"formatRelativeTime");function Ge(s){return new Date(s).toLocaleString()}o(Ge,"formatTimestamp");function Ye({status:s}){return(0,e.jsx)("span",{className:`inline-block h-2 w-2 rounded-full shrink-0 ${s==="success"||s==="succeeded"?"bg-green-500":s==="failed"?"bg-red-500":s==="running"?"bg-blue-500 animate-pulse":s==="cancelled"?"bg-gray-400":"bg-amber-500"}`,title:s})}o(Ye,"JobStatusDot");function Ue({status:s}){return(0,e.jsx)("span",{className:`inline-block h-2 w-2 rounded-full shrink-0 ${s==="processed"||s==="success"?"bg-green-500":s==="failed"?"bg-red-500":s==="received"?"bg-blue-500":"bg-amber-500"}`,title:s})}o(Ue,"DeliveryStatusDot");export{ts as PluginSettings};
1
+ var fe=Object.defineProperty;var o=(s,a)=>fe(s,"name",{value:a,configurable:!0});import{a as ie}from"./rolldown-runtime-DhZMWcEn.js";import{M as pe,ai as je}from"./issue-detail-CZfjXs0M.js";import{i as Q}from"./collections-B58p51lw.js";import{$A as be,Ai as Z,Di as Ne,E_ as P,GS as N,Gb as X,Gw as ve,H_ as f,KC as ye,LC as we,LS as ke,ME as le,M_ as _,NE as E,NT as Ce,O_ as M,QT as oe,Z_ as Se,_T as qe,_w as z,aE as Le,ab as ce,bE as B,ev as De,hC as Fe,hE as H,ib as Pe,ip as I,jC as _e,j_ as $,k_ as ee,ki as Me,lv as v,nj as $e,np as Ee,ob as de,pT as Ke,qT as Te,qb as Re,qu as ze,rp as R,sT as se,ub as xe,xE as D}from"./index-BJtnP7H1.js";var ue={name:"circle-check-big",size:24,node:[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],aliases:["check-circle"]};ue.node;var Ae=oe(ue),me={name:"square-activity",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M17 12h-2l-2 5-2-10-2 5H7",key:"15hlnc"}]],aliases:["activity-square"]};me.node;var te=oe(me),h=ie($e(),1),e=ie(be(),1);function ts(){const{selectedCompany:s,selectedCompanyId:a}=ke(),{setBreadcrumbs:r}=Pe(),{companyPrefix:i,pluginId:l}=Le(),{hideHostPaths:g}=pe(),[u,y]=(0,h.useState)("configuration"),j=D({queryKey:N.plugins.detail(l),queryFn:o(()=>v.get(l),"queryFn"),enabled:!!l}),n=j.data,p=xe(j),{data:m,isLoading:F}=D({queryKey:N.plugins.health(l),queryFn:o(()=>v.health(l),"queryFn"),enabled:!!l&&n?.status==="ready",refetchInterval:3e4}),{data:c}=D({queryKey:N.plugins.dashboard(l),queryFn:o(()=>v.dashboard(l),"queryFn"),enabled:!!l,refetchInterval:3e4}),{data:b}=D({queryKey:N.plugins.logs(l),queryFn:o(()=>v.logs(l,{limit:50}),"queryFn"),enabled:!!l&&n?.status==="ready",refetchInterval:3e4}),d=n?.manifestJson?.instanceConfigSchema,w=d&&d.properties&&Object.keys(d.properties).length>0,C=l&&a?N.plugins.config(l,a):["plugins",l??"__missing_plugin__","companies","__missing_company__","config"],{data:K,isLoading:S,isSuccess:L}=D({queryKey:C,queryFn:o(()=>v.getConfig(l,a),"queryFn"),enabled:!!l&&!!w&&!!a}),{slots:A}=De({slotTypes:["settingsPage"],companyId:a,enabled:!!a}),T=A.filter(t=>t.pluginId===l||t.pluginKey===l),J=T.length>0;if((0,h.useEffect)(()=>{r([{label:s?.name??"Organization",href:"/dashboard"},{label:"Settings",href:"/company/settings"},{label:"System plugins",href:"/company/settings/instance/plugins"},{label:n?.manifestJson?.displayName??n?.packageName??"Plugin Details"}])},[s?.name,r,i,n]),(0,h.useEffect)(()=>{y("configuration")},[l]),p.kind==="loading"||p.kind==="reconnecting")return(0,e.jsx)(de,{size:"page",label:"Loading plugin details",className:"p-4"});if(p.kind==="error")return(0,e.jsx)(ce,{size:"page",className:"p-4",error:j.error,action:"load this plugin",onRetry:p.retry,retrying:p.isFetching});if(!n)return(0,e.jsx)(Re,{to:"/company/settings/instance/plugins",replace:!0});const x=n.status,k=n.status==="ready"?"default":n.status==="error"?"destructive":"secondary",q=n.manifestJson.description||"No description provided.",V=n.manifestJson.capabilities??[],G=n.manifestJson.environmentDrivers??[],Y=n.manifestJson.localFolders??[],U=Y.length>0&&!g,he=G.map(t=>t.displayName?.trim()||t.driverKey).filter((t,O,ge)=>ge.indexOf(t)===O).join(", ");return(0,e.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,e.jsx)(X,{to:"/company/settings/instance/plugins",children:(0,e.jsx)(E,{variant:"outline",size:"icon",className:"h-8 w-8",children:(0,e.jsx)(Te,{className:"h-4 w-4"})})}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(ye,{className:"h-6 w-6 text-muted-foreground"}),(0,e.jsx)("h1",{className:"text-xl font-semibold",children:n.manifestJson.displayName??n.packageName}),(0,e.jsx)(f,{variant:k,className:"ml-2",children:x}),(0,e.jsxs)(f,{variant:"outline",className:"ml-1",children:["v",n.manifestJson.version??n.version]})]})]}),(0,e.jsxs)(Me,{value:u,onValueChange:o(t=>y(t),"onValueChange"),className:"space-y-6",children:[(0,e.jsx)(Ne,{align:"start",items:[{value:"configuration",label:"Configuration"},{value:"status",label:"Status"}],value:u,onValueChange:o(t=>y(t),"onValueChange")}),(0,e.jsx)(Z,{value:"configuration",className:"space-y-6",children:(0,e.jsxs)("div",{className:"space-y-8",children:[(0,e.jsxs)("section",{className:"space-y-5",children:[(0,e.jsx)("h2",{className:"text-base font-semibold",children:"About"}),(0,e.jsxs)("div",{className:"grid gap-8 lg:grid-cols-(--gtc-52)",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Description"}),(0,e.jsx)("p",{className:"text-sm leading-6 text-foreground/90",children:q})]}),(0,e.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("h3",{className:"font-medium text-muted-foreground",children:"Author"}),(0,e.jsx)("p",{className:"text-foreground",children:n.manifestJson.author})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"font-medium text-muted-foreground",children:"Categories"}),(0,e.jsx)("div",{className:"flex flex-wrap gap-2",children:n.categories.length>0?n.categories.map(t=>(0,e.jsx)(f,{variant:"outline",className:"capitalize",children:t},t)):(0,e.jsx)("span",{className:"text-foreground",children:"None"})})]})]})]})]}),(0,e.jsx)(Q,{}),(0,e.jsxs)("section",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"space-y-1",children:(0,e.jsx)("h2",{className:"text-base font-semibold",children:"Settings"})}),U?(0,e.jsx)(Je,{pluginId:l,companyId:a,declarations:Y}):null,J?(0,e.jsx)("div",{className:"space-y-3",children:T.map(t=>(0,e.jsx)(Se,{slot:t,context:{companyId:a,companyPrefix:i??null},missingBehavior:"placeholder"},`${t.pluginKey}:${t.id}`))}):w?(0,e.jsx)(He,{pluginId:l,companyId:a,schema:d,initialValues:K?.configJson,needsInitialSave:L&&K===null,isLoading:S,pluginStatus:n.status,supportsConfigTest:n.supportsConfigTest===!0}):G.length>0?(0,e.jsxs)("div",{className:"rounded-md border border-border/60 bg-muted/20 px-4 py-3 text-sm",children:[(0,e.jsx)("p",{className:"font-medium text-foreground",children:"Configure this plugin from Settings → Environments."}),(0,e.jsxs)("p",{className:"mt-1 text-muted-foreground",children:[he||"This plugin"," registers environment runtime settings there so the execution target stays instance-scoped while secret bindings still resolve through the selected organization context."]}),(0,e.jsx)("div",{className:"mt-3",children:(0,e.jsx)(X,{to:"/company/settings/instance/environments",children:(0,e.jsx)(E,{variant:"outline",size:"sm",children:"Open Environments"})})})]}):U?null:(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"This plugin does not require any settings."})]})]})}),(0,e.jsx)(Z,{value:"status",className:"space-y-6",children:(0,e.jsxs)("div",{className:"grid gap-6 xl:grid-cols-(--gtc-39)",children:[(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)(P,{children:[(0,e.jsxs)($,{children:[(0,e.jsxs)(_,{className:"text-base flex items-center gap-1.5",children:[(0,e.jsx)(se,{className:"h-4 w-4"}),"Runtime Dashboard"]}),(0,e.jsx)(ee,{children:"Worker process, scheduled jobs, and webhook deliveries"})]}),(0,e.jsx)(M,{className:"space-y-6",children:c?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[(0,e.jsx)(se,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Worker Process"]}),c.worker?(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[(0,e.jsxs)("div",{className:"flex justify-between",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Status"}),(0,e.jsx)(f,{variant:c.worker.status==="running"?"default":"secondary",children:c.worker.status})]}),(0,e.jsxs)("div",{className:"flex justify-between",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"PID"}),(0,e.jsx)("span",{className:"font-mono text-xs",children:c.worker.pid??"—"})]}),(0,e.jsxs)("div",{className:"flex justify-between",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Uptime"}),(0,e.jsx)("span",{className:"text-xs",children:Ve(c.worker.uptime)})]}),(0,e.jsxs)("div",{className:"flex justify-between",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Pending RPCs"}),(0,e.jsx)("span",{className:"text-xs",children:c.worker.pendingRequests})]}),c.worker.totalCrashes>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"flex justify-between col-span-2",children:[(0,e.jsxs)("span",{className:"text-muted-foreground flex items-center gap-1",children:[(0,e.jsx)(Fe,{className:"h-3 w-3 text-amber-500"}),"Crashes"]}),(0,e.jsxs)("span",{className:"text-xs",children:[c.worker.consecutiveCrashes," consecutive / ",c.worker.totalCrashes," total"]})]}),c.worker.lastCrashAt&&(0,e.jsxs)("div",{className:"flex justify-between col-span-2",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Last Crash"}),(0,e.jsx)("span",{className:"text-xs",children:Ge(c.worker.lastCrashAt)})]})]})]}):(0,e.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No worker process registered."})]}),(0,e.jsx)(Q,{}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[(0,e.jsx)(Ce,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Recent Job Runs"]}),c.recentJobRuns.length>0?(0,e.jsx)("div",{className:"space-y-2",children:c.recentJobRuns.map(t=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-md bg-muted/50 px-2 py-1.5 text-sm",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,e.jsx)(Ye,{status:t.status}),(0,e.jsx)("span",{className:"truncate font-mono text-xs",title:t.jobKey??t.jobId,children:t.jobKey??t.jobId.slice(0,8)}),(0,e.jsx)(f,{variant:"outline",className:"px-1 py-0 text-(length:--text-nano)",children:t.trigger})]}),(0,e.jsxs)("div",{className:"flex shrink-0 items-center gap-2 text-xs text-muted-foreground",children:[t.durationMs!=null?(0,e.jsx)("span",{children:ae(t.durationMs)}):null,(0,e.jsx)("span",{title:t.createdAt,children:ne(t.createdAt)})]})]},t.id))}):(0,e.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No job runs recorded yet."})]}),(0,e.jsx)(Q,{}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[(0,e.jsx)(je,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Recent Webhook Deliveries"]}),c.recentWebhookDeliveries.length>0?(0,e.jsx)("div",{className:"space-y-2",children:c.recentWebhookDeliveries.map(t=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-md bg-muted/50 px-2 py-1.5 text-sm",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,e.jsx)(Ue,{status:t.status}),(0,e.jsx)("span",{className:"truncate font-mono text-xs",title:t.webhookKey,children:t.webhookKey})]}),(0,e.jsxs)("div",{className:"flex shrink-0 items-center gap-2 text-xs text-muted-foreground",children:[t.durationMs!=null?(0,e.jsx)("span",{children:ae(t.durationMs)}):null,(0,e.jsx)("span",{title:t.createdAt,children:ne(t.createdAt)})]})]},t.id))}):(0,e.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No webhook deliveries recorded yet."})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1.5 border-t border-border/50 pt-2 text-xs text-muted-foreground",children:[(0,e.jsx)(Ke,{className:"h-3 w-3"}),"Last checked: ",new Date(c.checkedAt).toLocaleTimeString()]})]}):(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Runtime diagnostics are unavailable right now."})})]}),b&&b.length>0?(0,e.jsxs)(P,{children:[(0,e.jsxs)($,{children:[(0,e.jsxs)(_,{className:"text-base flex items-center gap-1.5",children:[(0,e.jsx)(te,{className:"h-4 w-4"}),"Recent Logs"]}),(0,e.jsxs)(ee,{children:["Last ",b.length," log entries"]})]}),(0,e.jsx)(M,{children:(0,e.jsx)("div",{className:"max-h-64 space-y-1 overflow-y-auto font-mono text-xs",children:b.map(t=>(0,e.jsxs)("div",{className:`flex gap-2 py-0.5 ${t.level==="error"?"text-destructive":t.level==="warn"?"text-yellow-600 dark:text-yellow-400":t.level==="debug"?"text-muted-foreground/60":"text-muted-foreground"}`,children:[(0,e.jsx)("span",{className:"shrink-0 text-muted-foreground/50",children:new Date(t.createdAt).toLocaleTimeString()}),(0,e.jsx)(f,{variant:"outline",className:"h-4 shrink-0 px-1 text-(length:--text-nano)",children:t.level}),(0,e.jsx)("span",{className:"truncate",title:t.message,children:t.message})]},t.id))})})]}):null]}),(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)(P,{children:[(0,e.jsx)($,{children:(0,e.jsxs)(_,{className:"text-base flex items-center gap-1.5",children:[(0,e.jsx)(te,{className:"h-4 w-4"}),"Health Status"]})}),(0,e.jsx)(M,{children:F?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Checking health..."}):m?(0,e.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Overall"}),(0,e.jsx)(f,{variant:m.healthy?"default":"destructive",children:m.status})]}),m.checks.length>0?(0,e.jsx)("div",{className:"space-y-2 border-t border-border/50 pt-2",children:m.checks.map((t,O)=>(0,e.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,e.jsx)("span",{className:"truncate text-muted-foreground",title:t.name,children:t.name}),t.passed?(0,e.jsx)(Ae,{className:"h-4 w-4 shrink-0 text-green-500"}):(0,e.jsx)(qe,{className:"h-4 w-4 shrink-0 text-destructive"})]},O))}):null,m.lastError?(0,e.jsx)("div",{className:"break-words rounded border border-destructive/20 bg-destructive/10 p-2 text-xs text-destructive",children:m.lastError}):null]}):(0,e.jsxs)("div",{className:"space-y-3 text-sm text-muted-foreground",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)("span",{children:"Lifecycle"}),(0,e.jsx)(f,{variant:k,children:x})]}),(0,e.jsx)("p",{children:"Health checks run once the plugin is ready."}),n.lastError?(0,e.jsx)("div",{className:"break-words rounded border border-destructive/20 bg-destructive/10 p-2 text-xs text-destructive",children:n.lastError}):null]})})]}),(0,e.jsxs)(P,{children:[(0,e.jsx)($,{children:(0,e.jsx)(_,{className:"text-base",children:"Details"})}),(0,e.jsxs)(M,{className:"space-y-3 text-sm text-muted-foreground",children:[(0,e.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,e.jsx)("span",{children:"Plugin ID"}),(0,e.jsx)("span",{className:"font-mono text-xs text-right",children:n.id})]}),(0,e.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,e.jsx)("span",{children:"Plugin Key"}),(0,e.jsx)("span",{className:"font-mono text-xs text-right",children:n.pluginKey})]}),(0,e.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,e.jsx)("span",{children:"NPM Package"}),(0,e.jsx)("span",{className:"max-w-(--sz-170px) truncate text-right text-xs",title:n.packageName,children:n.packageName})]}),(0,e.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,e.jsx)("span",{children:"Version"}),(0,e.jsxs)("span",{className:"text-right text-foreground",children:["v",n.manifestJson.version??n.version]})]})]})]}),(0,e.jsxs)(P,{children:[(0,e.jsx)($,{children:(0,e.jsxs)(_,{className:"text-base flex items-center gap-1.5",children:[(0,e.jsx)(_e,{className:"h-4 w-4"}),"Permissions"]})}),(0,e.jsx)(M,{children:V.length>0?(0,e.jsx)("ul",{className:"space-y-2 text-sm text-muted-foreground",children:V.map(t=>(0,e.jsx)("li",{className:"rounded-md bg-muted/40 px-2.5 py-2 font-mono text-xs text-foreground/85",children:t},t))}):(0,e.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No special permissions requested."})})]})]})]})})]})]})}o(ts,"PluginSettings");function Je({pluginId:s,companyId:a,declarations:r}){const i=D({queryKey:a?N.plugins.localFolders(s,a):["plugins",s,"companies","none","local-folders"],queryFn:o(()=>v.listLocalFolders(s,a),"queryFn"),enabled:!!a}),l=xe(i),g=new Map((i.data?.folders??[]).map(u=>[u.folderKey,u]));return a?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(ve,{className:"h-4 w-4 text-muted-foreground"}),(0,e.jsx)("h3",{className:"text-sm font-medium",children:"Local folders"})]}),l.kind==="error"?(0,e.jsx)(ce,{size:"panel",error:i.error,action:"load local folder settings",onRetry:l.retry,retrying:l.isFetching}):null,l.kind==="loading"||l.kind==="reconnecting"?(0,e.jsx)(de,{size:"panel",label:"Loading local folders",className:"py-3"}):(0,e.jsx)("div",{className:"space-y-3",children:r.map(u=>(0,e.jsx)(Oe,{pluginId:s,companyId:a,declaration:u,status:g.get(u.folderKey)},u.folderKey))})]}):(0,e.jsx)("div",{className:"rounded-md border border-border/60 bg-muted/20 px-4 py-3 text-sm text-muted-foreground",children:"Select an organization to configure this plugin's local folders."})}o(Je,"PluginLocalFoldersSettings");function Oe({pluginId:s,companyId:a,declaration:r,status:i}){const l=le(),g=i?.path??"",[u,y]=(0,h.useState)(g),[j,n]=(0,h.useState)(null);(0,h.useEffect)(()=>{y(g),n(null)},[g,r.folderKey]);const p=B({mutationFn:o(d=>v.configureLocalFolder(s,a,r.folderKey,{path:d,access:r.access,requiredDirectories:r.requiredDirectories,requiredFiles:r.requiredFiles}),"mutationFn"),onSuccess:o(d=>{n({type:d.healthy?"success":"error",text:d.healthy?"Local folder saved.":"Local folder saved, but validation still needs attention."}),l.invalidateQueries({queryKey:N.plugins.localFolders(s,a)})},"onSuccess"),onError:o(d=>{n({type:"error",text:H(d).body})},"onError")}),m=u.trim(),F=m!==g,c=i?.access??r.access??"readWrite",b=(0,h.useCallback)(()=>{if(!m){n({type:"error",text:"Local folder path is required."});return}if(!Be(m)){n({type:"error",text:"Local folder must be a full absolute path."});return}n(null),p.mutate(m)},[p,m]);return(0,e.jsxs)("div",{className:"space-y-4 rounded-md border border-border/70 bg-background px-4 py-4",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("h4",{className:"text-sm font-medium",children:r.displayName}),(0,e.jsx)(f,{variant:"outline",className:"font-mono text-(length:--text-nano)",children:r.folderKey}),(0,e.jsx)(f,{variant:i?.healthy?"default":"secondary",children:i?.healthy?"Healthy":"Needs attention"})]}),r.description?(0,e.jsx)("p",{className:"max-w-3xl text-sm leading-5 text-muted-foreground",children:r.description}):null]}),(0,e.jsx)(f,{variant:c==="readWrite"?"default":"outline",children:c==="readWrite"?"Read/write":"Read only"})]}),(0,e.jsxs)("div",{className:"grid gap-3 text-sm sm:grid-cols-3",children:[(0,e.jsx)(W,{label:"Configured",value:i?.configured?"Yes":"No",ok:!!i?.configured}),(0,e.jsx)(W,{label:"Readable",value:i?.readable?"Yes":"No",ok:!!i?.readable}),(0,e.jsx)(W,{label:"Writable",value:c==="read"?"Not requested":i?.writable?"Yes":"No",ok:c==="read"||!!i?.writable})]}),i?.path?(0,e.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,e.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Configured path"}),(0,e.jsx)("div",{className:"break-all rounded-md bg-muted/60 px-2 py-1.5 font-mono text-xs text-foreground",children:i.path})]}):null,(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("label",{className:"text-xs font-medium text-muted-foreground",htmlFor:`local-folder-${r.folderKey}`,children:"Local folder path"}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("input",{id:`local-folder-${r.folderKey}`,className:"min-w-0 flex-1 rounded-md border border-border bg-background px-2.5 py-1.5 font-mono text-sm outline-none focus:border-foreground/40 focus:ring-2 focus:ring-ring/20",value:u,onChange:o(d=>{y(d.target.value),n(null)},"onChange"),placeholder:"/absolute/path/to/folder"}),(0,e.jsx)(ze,{className:"h-8"}),(0,e.jsxs)(E,{size:"sm",onClick:b,disabled:p.isPending||!F||!a,children:[p.isPending?(0,e.jsx)(z,{className:"h-3.5 w-3.5 animate-spin"}):(0,e.jsx)(we,{className:"h-3.5 w-3.5"}),"Save"]})]})]}),(0,e.jsx)(Qe,{status:i,declaration:r}),i?.problems?.length?(0,e.jsxs)("div",{className:"space-y-2 rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[(0,e.jsx)("div",{className:"font-medium",children:"Validation problems"}),(0,e.jsx)("ul",{className:"space-y-1",children:i.problems.map((d,w)=>(0,e.jsxs)("li",{children:[d.message,d.path?(0,e.jsxs)("span",{className:"font-mono",children:[" ",d.path]}):null]},`${d.code}:${d.path??""}:${w}`))})]}):null,j?(0,e.jsx)("div",{className:`rounded-md border px-3 py-2 text-sm ${j.type==="success"?"border-green-200 bg-green-50 text-green-700 dark:border-green-900 dark:bg-green-950/30 dark:text-green-400":"border-destructive/20 bg-destructive/10 text-destructive"}`,children:j.text}):null]})}o(Oe,"PluginLocalFolderRow");function W({label:s,value:a,ok:r}){return(0,e.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border/60 px-2.5 py-2",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:s}),(0,e.jsx)(f,{variant:r?"default":"secondary",children:a})]})}o(W,"FolderStatusMetric");function Qe({status:s,declaration:a}){const r=s?.requiredDirectories??a.requiredDirectories??[],i=s?.requiredFiles??a.requiredFiles??[],l=s?.missingDirectories??r,g=s?.missingFiles??i,u=We(s);return r.length===0&&i.length===0?null:(0,e.jsxs)("div",{className:"grid gap-3 text-sm md:grid-cols-2",children:[(0,e.jsx)(re,{title:"Required directories",items:r,missingItems:l,missingLabel:"Missing directories",inspectionUnavailable:u}),(0,e.jsx)(re,{title:"Required files",items:i,missingItems:g,missingLabel:"Missing files",inspectionUnavailable:u})]})}o(Qe,"FolderRequirements");function We(s){return!s?.configured||s.readable?!1:s.problems.some(a=>a.code==="missing"||a.code==="not_readable"||a.code==="not_directory")}o(We,"isRootNotInspected");function re({title:s,items:a,missingItems:r,missingLabel:i,inspectionUnavailable:l}){return(0,e.jsxs)("div",{className:"space-y-2 rounded-md border border-border/60 px-3 py-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:s}),l?(0,e.jsx)(f,{variant:"secondary",className:"text-(length:--text-nano)",children:"Not inspected"}):r.length>0?(0,e.jsxs)(f,{variant:"destructive",className:"text-(length:--text-nano)",children:[r.length," missing"]}):(0,e.jsx)(f,{variant:"outline",className:"text-(length:--text-nano)",children:"Present"})]}),a.length>0?(0,e.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.map(g=>{const u=r.includes(g);return(0,e.jsx)("span",{className:`rounded border px-1.5 py-0.5 font-mono text-(length:--text-micro) ${l?"border-amber-300/60 bg-amber-50 text-amber-700 dark:border-amber-800/70 dark:bg-amber-950/30 dark:text-amber-300":u?"border-destructive/30 bg-destructive/10 text-destructive":"border-border bg-muted/50 text-foreground/80"}`,children:g},g)})}):(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"None declared."}),l?(0,e.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:"Configured root was not inspected."}):r.length>0?(0,e.jsxs)("p",{className:"text-xs text-destructive",children:[i,": ",r.join(", ")]}):null]})}o(re,"RequirementList");function Be(s){return s.startsWith("/")||/^[A-Za-z]:[\\/]/.test(s)||s.startsWith("\\\\")}o(Be,"isLikelyAbsolutePath");function He({pluginId:s,companyId:a,schema:r,initialValues:i,needsInitialSave:l,isLoading:g,pluginStatus:u,supportsConfigTest:y}){const j=le(),[n,p]=(0,h.useState)(()=>({...R(r),...i??{}})),m=(0,h.useRef)(!1);(0,h.useEffect)(()=>{m.current=!1,p(R(r))},[a,s,r]),(0,h.useEffect)(()=>{i&&!m.current&&(m.current=!0,p({...R(r),...i}))},[i,r]);const[F,c]=(0,h.useState)({}),[b,d]=(0,h.useState)(null),[w,C]=(0,h.useState)(null),K=JSON.stringify(n)!==JSON.stringify({...R(r),...i??{}}),S=B({mutationFn:o(({pluginId:x,companyId:k,configJson:q})=>{if(!k)throw new Error("Select an organization before saving plugin configuration.");return v.saveConfig(x,k,q)},"mutationFn"),onSuccess:o((x,{pluginId:k,companyId:q})=>{d({type:"success",text:"Configuration saved."}),C(null),q&&(j.setQueryData(N.plugins.config(k,q),x),j.invalidateQueries({queryKey:N.plugins.config(k,q)})),setTimeout(()=>d(null),3e3)},"onSuccess"),onError:o(x=>{d({type:"error",text:H(x).body})},"onError")}),L=B({mutationFn:o(x=>{if(!a)throw new Error("Select an organization before testing plugin configuration.");return v.testConfig(s,a,x)},"mutationFn"),onSuccess:o(x=>{x.valid?C({type:"success",text:"Configuration test passed."}):C({type:"error",text:x.message||"Configuration test failed."})},"onSuccess"),onError:o(x=>{C({type:"error",text:H(x).body})},"onError")}),A=(0,h.useCallback)(x=>{p(x),c({}),d(null)},[]),T=(0,h.useCallback)(()=>{const x=I(r,n);if(Object.keys(x).length>0){c(x);return}c({}),S.mutate({pluginId:s,companyId:a,configJson:n})},[r,n,S,s,a]),J=(0,h.useCallback)(()=>{const x=I(r,n);if(Object.keys(x).length>0){c(x);return}c({}),C(null),L.mutate(n)},[r,n,L]);return g?(0,e.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-4",children:[(0,e.jsx)(z,{className:"h-4 w-4 animate-spin"}),"Loading configuration..."]}):(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)(Ee,{schema:r,values:n,onChange:A,errors:F,disabled:S.isPending}),b&&(0,e.jsx)("div",{className:`text-sm p-2 rounded border ${b.type==="success"?"text-green-700 bg-green-50 border-green-200 dark:text-green-400 dark:bg-green-950/30 dark:border-green-900":"text-destructive bg-destructive/10 border-destructive/20"}`,children:b.text}),w&&(0,e.jsx)("div",{className:`text-sm p-2 rounded border ${w.type==="success"?"text-green-700 bg-green-50 border-green-200 dark:text-green-400 dark:bg-green-950/30 dark:border-green-900":"text-destructive bg-destructive/10 border-destructive/20"}`,children:w.text}),(0,e.jsxs)("div",{className:"flex items-center gap-2 pt-2",children:[(0,e.jsx)(E,{onClick:T,disabled:S.isPending||!K&&!l,size:"sm",children:S.isPending?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(z,{className:"h-3.5 w-3.5 animate-spin"}),"Saving..."]}):"Save Configuration"}),u==="ready"&&y&&(0,e.jsx)(E,{variant:"outline",onClick:J,disabled:L.isPending||!a,size:"sm",children:L.isPending?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(z,{className:"h-3.5 w-3.5 animate-spin"}),"Testing..."]}):"Test Configuration"})]})]})}o(He,"PluginConfigForm");function Ve(s){if(s==null)return"—";const a=Math.floor(s/1e3);if(a<60)return`${a}s`;const r=Math.floor(a/60);if(r<60)return`${r}m ${a%60}s`;const i=Math.floor(r/60);return i<24?`${i}h ${r%60}m`:`${Math.floor(i/24)}d ${i%24}h`}o(Ve,"formatUptime");function ae(s){return s<1e3?`${s}ms`:s<6e4?`${(s/1e3).toFixed(1)}s`:`${(s/6e4).toFixed(1)}m`}o(ae,"formatDuration");function ne(s){const a=Date.now()-new Date(s).getTime();if(a<0)return"just now";const r=Math.floor(a/1e3);if(r<60)return`${r}s ago`;const i=Math.floor(r/60);if(i<60)return`${i}m ago`;const l=Math.floor(i/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}o(ne,"formatRelativeTime");function Ge(s){return new Date(s).toLocaleString()}o(Ge,"formatTimestamp");function Ye({status:s}){return(0,e.jsx)("span",{className:`inline-block h-2 w-2 rounded-full shrink-0 ${s==="success"||s==="succeeded"?"bg-green-500":s==="failed"?"bg-red-500":s==="running"?"bg-blue-500 animate-pulse":s==="cancelled"?"bg-gray-400":"bg-amber-500"}`,title:s})}o(Ye,"JobStatusDot");function Ue({status:s}){return(0,e.jsx)("span",{className:`inline-block h-2 w-2 rounded-full shrink-0 ${s==="processed"||s==="success"?"bg-green-500":s==="failed"?"bg-red-500":s==="received"?"bg-blue-500":"bg-amber-500"}`,title:s})}o(Ue,"DeliveryStatusDot");export{ts as PluginSettings};
@@ -1 +1 @@
1
- var ue=Object.defineProperty;var t=(s,a)=>ue(s,"name",{value:a,configurable:!0});import{a as te}from"./rolldown-runtime-DhZMWcEn.js";import{si as me}from"./issue-detail-4PCbYpdv.js";import{$A as pe,$S as xe,AC as he,GS as R,H_ as ae,Jp as I,LS as fe,ME as ge,NE as p,QT as je,XC as ve,XT as ye,YE as ne,Yb as be,__ as H,aE as Ne,ab as re,bE as _,cT as we,dy as F,fy as K,gC as ke,g_ as Ce,ib as Ae,ly as O,my as M,nj as Te,oE as Se,op as z,sv as Ie,sy as q,ub as ee,uy as U,vi as Ee,xE as Pe,zE as Y}from"./index-Bt31d8ga.js";import{a as Le,i as ie,s as se}from"./shared-CIwISWMj.js";import{a as De,n as Re,t as _e}from"./profile-summary-B5rPf8v-.js";import{n as Be}from"./useProfilesData-0VYQ4lAT.js";import{t as $e}from"./ToolsAdminGate-CEr0zy2T.js";var oe={name:"plug-zap",size:24,node:[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]],aliases:["plug-zap-2"]};oe.node;var ze=je(oe),g=te(Te(),1),e=te(pe(),1);function Fe({companyId:s,profileId:a,initialCreated:n,initialReviewOpen:o}){const u=be(),[x,v]=Se(),j=ge(),{pushToast:i}=Ie(),l=Be(s),f=ee(l.profiles),[d,h]=(0,g.useState)(null),[N,A]=(0,g.useState)(null),[Q,y]=(0,g.useState)(!!o),[B,E]=(0,g.useState)({}),m=(l.profiles.data?.profiles??[]).find(r=>r.id===a)??null,W=n??x.get("created")==="1",w=m?.newToolsPendingCount??0,k=Pe({queryKey:R.tools.profileNewTools(a),queryFn:t(()=>I.getProfileNewTools(a),"queryFn"),enabled:w>0}),C=ee(k),P=k.isLoading||C.kind==="reconnecting",c=t(()=>{j.invalidateQueries({queryKey:R.tools.profiles(s)}),j.invalidateQueries({queryKey:R.tools.testAgentAccesses()})},"invalidate"),L=t(r=>String(r?.message??r),"errorBody"),de=(0,g.useMemo)(()=>m?He(m,l.catalog,l.maps.applicationsById,l.maps.connectionsById,l.connections.data?.connections??[]):[],[m,l.catalog,l.maps.applicationsById,l.maps.connectionsById,l.connections.data?.connections]),T=k.data?.tools??[];(0,g.useEffect)(()=>{x.get("review")==="new-tools"&&w>0&&y(!0)},[w,x]),(0,g.useEffect)(()=>{T.length!==0&&E(r=>{const D={...r};for(const $ of T)D[$.catalogEntryId]||(D[$.catalogEntryId]="keep_blocked");return D})},[T]);const S=_({mutationFn:t(r=>I.updateProfile(a,r),"mutationFn"),onSuccess:t(()=>{c(),i({title:"Profile updated",tone:"success"})},"onSuccess"),onError:t(r=>i({title:"Could not update profile",body:L(r),tone:"error"}),"onError")}),G=_({mutationFn:t(r=>I.duplicateProfile(a,r),"mutationFn"),onSuccess:t(r=>{c(),i({title:"Profile duplicated",body:"The copy is not assigned to anyone yet.",tone:"success"}),u(`/apps/advanced/profiles/${r.id}?created=1`)},"onSuccess"),onError:t(r=>i({title:"Could not duplicate",body:L(r),tone:"error"}),"onError")}),X=_({mutationFn:t(()=>I.deleteProfile(a),"mutationFn"),onSuccess:t(()=>{c(),i({title:"Profile deleted",tone:"success"}),u("/apps/advanced/profiles")},"onSuccess"),onError:t(r=>i({title:"Could not delete",body:L(r),tone:"error"}),"onError")}),Z=_({mutationFn:t(r=>I.unbindProfile(s,a,{targetType:r.targetType,targetId:r.targetId}),"mutationFn"),onSuccess:t(()=>{A(null),c(),i({title:"Assignment removed",tone:"success"})},"onSuccess"),onError:t(r=>i({title:"Could not remove assignment",body:L(r),tone:"error"}),"onError")}),J=_({mutationFn:t(()=>I.reviewProfileNewTools(a,{decisions:T.map(r=>({catalogEntryId:r.catalogEntryId,decision:B[r.catalogEntryId]??"keep_blocked"}))}),"mutationFn"),onSuccess:t(()=>{y(!1),v({}),j.invalidateQueries({queryKey:R.tools.profiles(s)}),j.invalidateQueries({queryKey:R.tools.profileNewTools(a)}),i({title:"New tools reviewed",tone:"success"})},"onSuccess"),onError:t(r=>i({title:"Could not submit review",body:L(r),tone:"error"}),"onError")});if(l.profiles.isLoading||f.kind==="reconnecting")return(0,e.jsx)(ie,{label:"Loading profile..."});if(f.kind==="error")return(0,e.jsx)(re,{size:"page",error:l.profiles.error,action:"load the profile",onRetry:f.retry,retrying:f.isFetching});if(!m)return(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)(se,{title:"Profile not found",description:"This access profile may have been deleted."}),(0,e.jsx)(p,{variant:"outline",onClick:t(()=>u("/apps/advanced/profiles"),"onClick"),children:"Back to profiles"})]});const b=m.status==="archived",ce=m.summary.assignmentCount===0;return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsx)(se,{title:m.name,description:m.description??"No description yet.",actions:(0,e.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,e.jsxs)(p,{variant:"outline",disabled:b,onClick:t(()=>h("edit"),"onClick"),children:[(0,e.jsx)(ve,{className:"mr-1.5 h-4 w-4"}),"Edit"]}),(0,e.jsxs)(p,{variant:"outline",disabled:b,onClick:t(()=>h("duplicate"),"onClick"),children:[(0,e.jsx)(we,{className:"mr-1.5 h-4 w-4"}),"Duplicate"]}),b?(0,e.jsxs)(p,{variant:"outline",onClick:t(()=>h("restore"),"onClick"),children:[(0,e.jsx)(ye,{className:"mr-1.5 h-4 w-4"}),"Restore"]}):(0,e.jsx)(p,{variant:"outline",onClick:t(()=>h("archive"),"onClick"),children:"Archive"}),(0,e.jsxs)(p,{variant:"outline",className:"text-destructive hover:text-destructive",onClick:t(()=>h("delete"),"onClick"),children:[(0,e.jsx)(ke,{className:"mr-1.5 h-4 w-4"}),"Delete"]})]})}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-sm",children:[(0,e.jsx)(ae,{variant:b?"outline":"default",children:_e[m.status]}),(0,e.jsxs)("span",{className:"text-muted-foreground",children:["Updated ",(0,e.jsx)(Le,{value:m.updatedAt})]}),(0,e.jsx)("span",{className:"text-muted-foreground",children:Re(m.summary)})]}),W?(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-primary/30 bg-primary/5 px-4 py-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Profile saved"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:ce?"Assign it to agents before it changes their access.":"Assignments are active now."})]}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)(p,{size:"sm",onClick:t(()=>u(`/apps/advanced/profiles/${m.id}/edit?step=3`),"onClick"),children:"Assign"}),(0,e.jsx)(p,{size:"sm",variant:"ghost",onClick:t(()=>v({}),"onClick"),children:"Dismiss"})]})]}):null,b?(0,e.jsx)("div",{className:"rounded-lg border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-950",children:"This profile is archived. It does not apply to agents until it is restored."}):null,w>0?(0,e.jsx)(Ke,{count:w,tools:T,loading:P,onReview:t(()=>y(!0),"onReview")}):null,(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)("h2",{className:"text-base font-semibold text-foreground",children:"What it allows"}),(0,e.jsx)(p,{variant:"outline",size:"sm",disabled:b,onClick:t(()=>u(`/apps/advanced/profiles/${m.id}/edit?step=2`),"onClick"),children:"Edit tools"})]}),(0,e.jsx)(Me,{rows:de,total:m.summary.totalToolCount})]}),(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)("h2",{className:"text-base font-semibold text-foreground",children:"Who has it"}),(0,e.jsx)(p,{variant:"outline",size:"sm",disabled:b,onClick:t(()=>u(`/apps/advanced/profiles/${m.id}/edit?step=3`),"onClick"),children:"Assign"})]}),(0,e.jsx)(qe,{profile:m,companyId:s,maps:l.maps,archived:b,onRemove:A})]}),(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsx)("h2",{className:"text-base font-semibold text-foreground",children:"New tools that appear later"}),(0,e.jsx)(Ue,{value:m.defaultAction,disabled:b||S.isPending,onChange:t(r=>S.mutate({defaultAction:r}),"onChange")})]}),(0,e.jsxs)(p,{variant:"link",className:"h-auto px-0",onClick:t(()=>u("/apps/advanced/profiles?check=1"),"onClick"),children:[(0,e.jsx)(he,{className:"mr-1.5 h-4 w-4"}),"Check what an agent can actually do"]}),(0,e.jsx)(Qe,{kind:d,profile:m,allProfiles:l.profiles.data?.profiles??[],pending:S.isPending||G.isPending||X.isPending,onClose:t(()=>h(null),"onClose"),onUpdate:t(r=>S.mutate(r,{onSuccess:t(()=>h(null),"onSuccess")}),"onUpdate"),onDuplicate:t(r=>G.mutate(r,{onSuccess:t(()=>h(null),"onSuccess")}),"onDuplicate"),onArchive:t(()=>S.mutate({status:"archived"},{onSuccess:t(()=>h(null),"onSuccess")}),"onArchive"),onRestore:t(()=>S.mutate({status:"active"},{onSuccess:t(()=>h(null),"onSuccess")}),"onRestore"),onDelete:t(()=>X.mutate(void 0,{onSuccess:t(()=>h(null),"onSuccess")}),"onDelete")}),(0,e.jsx)(We,{binding:N,label:N?le(N,s,l.maps):"",pending:Z.isPending,onClose:t(()=>A(null),"onClose"),onConfirm:t(()=>N&&Z.mutate(N),"onConfirm")}),(0,e.jsx)(Oe,{open:Q,tools:T,loading:P,error:C.kind==="error"?k.error:null,decisions:B,pending:J.isPending,onClose:t(()=>y(!1),"onClose"),onRetry:C.retry,retrying:C.isFetching,onDecision:t((r,D)=>E($=>({...$,[r]:D})),"onDecision"),onSubmit:t(()=>J.mutate(),"onSubmit")})]})}t(Fe,"ProfileDetail");function Ke({count:s,tools:a,loading:n,onReview:o}){const u=Xe(a);return(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-lg border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-950",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"font-medium",children:n?"New tools need review":`${u} added ${s} new ${s===1?"tool":"tools"} since your last review`}),(0,e.jsx)("p",{className:"text-amber-900/80",children:"Choose which ones this profile should allow."})]}),(0,e.jsx)(p,{size:"sm",onClick:o,children:"Review"})]})}t(Ke,"NewToolsReviewBanner");function Oe({open:s,tools:a,loading:n,error:o,decisions:u,pending:x,onClose:v,onRetry:j,retrying:i,onDecision:l,onSubmit:f}){return(0,e.jsx)(q,{open:s,onOpenChange:t(d=>!d&&v(),"onOpenChange"),children:(0,e.jsxs)(O,{className:"max-w-2xl",children:[(0,e.jsxs)(K,{children:[(0,e.jsx)(M,{children:"Review new tools"}),(0,e.jsx)(U,{children:"Allow the tools this profile should use. Keep the rest blocked."})]}),n?(0,e.jsx)(ie,{label:"Loading new tools..."}):o?(0,e.jsx)(re,{error:o,action:"load new tools",onRetry:j,retrying:i}):a.length===0?(0,e.jsx)("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-sm text-muted-foreground",children:"There are no new tools waiting for review."}):(0,e.jsx)("div",{className:"max-h-(--sz-52vh) divide-y divide-border overflow-y-auto rounded-lg border border-border",children:a.map(d=>(0,e.jsxs)("div",{className:"grid gap-3 px-3 py-3 sm:grid-cols-[1fr_auto]",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("p",{className:"truncate text-sm font-medium text-foreground",children:d.title||d.toolName}),(0,e.jsx)(ae,{variant:"secondary",children:Ge(d)})]}),d.description?(0,e.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:d.description}):null,(0,e.jsxs)("p",{className:Y("mt-1 text-xs text-muted-foreground",xe),children:[d.applicationName??d.connectionName??"App tool"," · added ",ne(d.addedAt)]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2 sm:justify-end",children:[(0,e.jsxs)("label",{className:"inline-flex items-center gap-1.5 text-sm",children:[(0,e.jsx)("input",{type:"radio",name:`review-${d.catalogEntryId}`,checked:(u[d.catalogEntryId]??"keep_blocked")==="allow",onChange:t(()=>l(d.catalogEntryId,"allow"),"onChange")}),"Allow"]}),(0,e.jsxs)("label",{className:"inline-flex items-center gap-1.5 text-sm",children:[(0,e.jsx)("input",{type:"radio",name:`review-${d.catalogEntryId}`,checked:(u[d.catalogEntryId]??"keep_blocked")==="keep_blocked",onChange:t(()=>l(d.catalogEntryId,"keep_blocked"),"onChange")}),"Keep blocked"]})]})]},d.catalogEntryId))}),(0,e.jsxs)(F,{children:[(0,e.jsx)(p,{variant:"ghost",onClick:v,children:"Cancel"}),(0,e.jsx)(p,{disabled:x||n||a.length===0,onClick:f,children:"Submit review"})]})]})})}t(Oe,"NewToolsReviewDialog");function Me({rows:s,total:a}){return s.length===0?(0,e.jsx)("div",{className:"rounded-lg border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-950",children:"This profile allows 0 tools. Agents with only this profile will not be able to use app tools."}):(0,e.jsxs)("div",{className:"overflow-hidden rounded-lg border border-border",children:[(0,e.jsx)("div",{className:"max-w-full overflow-x-auto",children:(0,e.jsxs)("table",{className:"w-full text-sm",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"border-b border-border bg-muted/40 text-left text-xs font-medium text-muted-foreground",children:[(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Tool"}),(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"App"}),(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Capabilities"}),(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Source"})]})}),(0,e.jsx)("tbody",{children:s.slice(0,80).map(n=>(0,e.jsxs)("tr",{className:Y("border-b border-border last:border-0",n.degraded&&"bg-muted/30 text-muted-foreground"),children:[(0,e.jsx)("td",{className:"px-3 py-2",children:(0,e.jsxs)("div",{className:"flex flex-col",children:[(0,e.jsx)("span",{className:"font-medium text-foreground",children:n.tool}),n.degraded?(0,e.jsxs)("a",{className:"mt-0.5 inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline",href:`/apps/${n.connectionId}`,children:[(0,e.jsx)(ze,{className:"h-3 w-3"}),"Reconnect"]}):null]})}),(0,e.jsxs)("td",{className:"px-3 py-2",children:[(0,e.jsx)("span",{children:n.app}),n.degraded?(0,e.jsxs)("span",{className:"ml-2 text-xs text-muted-foreground",children:[n.app," is disconnected"]}):null]}),(0,e.jsx)("td",{className:"px-3 py-2 text-muted-foreground",children:n.capabilities}),(0,e.jsxs)("td",{className:"px-3 py-2",children:[n.source.startsWith("added by rule")?(0,e.jsx)("span",{className:"rounded bg-amber-100 px-1.5 py-0.5 text-xs text-amber-950",children:n.source}):(0,e.jsx)("span",{className:"text-muted-foreground",children:n.source}),n.autoAddedAt?(0,e.jsxs)("div",{className:"mt-0.5 text-xs text-muted-foreground",children:["added automatically · ",ne(n.autoAddedAt)]}):null]})]},n.id))})]})}),s.length>80?(0,e.jsxs)("p",{className:"border-t border-border px-3 py-2 text-xs text-muted-foreground",children:["Showing 80 of ",s.length," allowed tools."]}):(0,e.jsxs)("p",{className:"border-t border-border px-3 py-2 text-xs text-muted-foreground",children:["Allows ",s.length," of ",a," known tools."]})]})}t(Me,"AllowList");function qe({profile:s,companyId:a,maps:n,archived:o,onRemove:u}){return s.bindings.length===0?(0,e.jsxs)("div",{className:"rounded-lg border border-dashed border-border px-4 py-5",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Not assigned yet"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Assign this profile before it changes access."})]}):(0,e.jsx)("div",{className:"divide-y divide-border overflow-hidden rounded-lg border border-border",children:s.bindings.map(x=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 px-3 py-2.5",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,e.jsx)("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-muted text-xs font-semibold text-muted-foreground",children:x.targetType==="company"?"Or":x.targetType.slice(0,2).toUpperCase()}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("p",{className:"truncate text-sm font-medium text-foreground",children:le(x,a,n)}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:Je(x.targetType)})]})]}),(0,e.jsxs)(p,{variant:"ghost",size:"sm",disabled:o,onClick:t(()=>u(x),"onClick"),children:[(0,e.jsx)(me,{className:"mr-1.5 h-4 w-4"}),"Remove"]})]},x.id))})}t(qe,"Assignments");function Ue({value:s,disabled:a,onChange:n}){return(0,e.jsx)("div",{className:"grid gap-2 sm:grid-cols-2",children:[{value:"deny",title:"Stay blocked until reviewed",body:"New tools do not become available automatically."},{value:"allow",title:"Allowed automatically",body:"New tools from selected apps become available right away."}].map(o=>(0,e.jsxs)("label",{className:Y("flex cursor-pointer items-start gap-3 rounded-lg border px-4 py-3",s===o.value?"border-primary bg-primary/5":"border-border",a&&"cursor-not-allowed opacity-60"),children:[(0,e.jsx)("input",{type:"radio",className:"mt-1",disabled:a,checked:s===o.value,onChange:t(()=>n(o.value),"onChange")}),(0,e.jsxs)("span",{children:[(0,e.jsx)("span",{className:"block text-sm font-medium text-foreground",children:o.title}),(0,e.jsx)("span",{className:"block text-xs text-muted-foreground",children:o.body})]})]},o.value))})}t(Ue,"NewToolsSetting");function Qe({kind:s,profile:a,allProfiles:n,pending:o,onClose:u,onUpdate:x,onDuplicate:v,onArchive:j,onRestore:i,onDelete:l}){const[f,d]=(0,g.useState)(a.name),[h,N]=(0,g.useState)(a.description??""),[A,Q]=(0,g.useState)(a.profileKey),[y,B]=(0,g.useState)(`${a.name} copy`),[E,m]=(0,g.useState)(!1),[W,w]=(0,g.useState)(!1),k=n.some(c=>c.id!==a.id&&c.name.trim().toLowerCase()===f.trim().toLowerCase()),C=n.some(c=>c.name.trim().toLowerCase()===y.trim().toLowerCase());if(!s)return null;const P=!!s;return s==="edit"?(0,e.jsx)(q,{open:P,onOpenChange:t(c=>!c&&u(),"onOpenChange"),children:(0,e.jsxs)(O,{children:[(0,e.jsxs)(K,{children:[(0,e.jsx)(M,{children:"Edit profile"}),(0,e.jsx)(U,{children:"Update the profile name and description."})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(z,{htmlFor:"edit-profile-name",children:"Name"}),(0,e.jsx)(H,{id:"edit-profile-name",value:f,onChange:t(c=>d(c.target.value),"onChange")}),k?(0,e.jsx)("p",{className:"text-xs text-destructive",children:"Another profile already uses this name."}):null]}),(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(z,{htmlFor:"edit-profile-description",children:"Description"}),(0,e.jsx)(Ce,{id:"edit-profile-description",value:h,onChange:t(c=>N(c.target.value),"onChange"),rows:3})]}),(0,e.jsx)("button",{type:"button",className:"text-sm font-medium text-muted-foreground hover:text-foreground",onClick:t(()=>w(c=>!c),"onClick"),children:"Advanced"}),W?(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(z,{htmlFor:"edit-profile-key",children:"Identifier"}),(0,e.jsx)(H,{id:"edit-profile-key",value:A,onChange:t(c=>Q(c.target.value),"onChange"),className:"font-mono text-xs"})]}):null]}),(0,e.jsxs)(F,{children:[(0,e.jsx)(p,{variant:"ghost",onClick:u,children:"Cancel"}),(0,e.jsx)(p,{disabled:!f.trim()||k||o,onClick:t(()=>x({name:f.trim(),description:h.trim()||null,profileKey:A.trim()}),"onClick"),children:"Save"})]})]})}):s==="duplicate"?(0,e.jsx)(q,{open:P,onOpenChange:t(c=>!c&&u(),"onOpenChange"),children:(0,e.jsxs)(O,{children:[(0,e.jsxs)(K,{children:[(0,e.jsx)(M,{children:"Duplicate profile"}),(0,e.jsx)(U,{children:"The copy starts unassigned unless you choose to copy assignments too."})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(z,{htmlFor:"copy-profile-name",children:"Name"}),(0,e.jsx)(H,{id:"copy-profile-name",value:y,onChange:t(c=>B(c.target.value),"onChange")}),C?(0,e.jsx)("p",{className:"text-xs text-destructive",children:"Another profile already uses this name."}):null]}),(0,e.jsxs)("label",{className:"flex items-center gap-2 text-sm",children:[(0,e.jsx)("input",{type:"checkbox",checked:E,onChange:t(c=>m(c.target.checked),"onChange")}),"Also copy assignments?"]})]}),(0,e.jsxs)(F,{children:[(0,e.jsx)(p,{variant:"ghost",onClick:u,children:"Cancel"}),(0,e.jsx)(p,{disabled:!y.trim()||C||o,onClick:t(()=>v({name:y.trim(),includeAssignments:E}),"onClick"),children:"Duplicate"})]})]})}):(0,e.jsx)(De,{kind:s,profile:a,pending:o,onClose:u,onArchive:j,onRestore:i,onDelete:l})}t(Qe,"ProfileDialogs");function We({binding:s,label:a,pending:n,onClose:o,onConfirm:u}){return(0,e.jsx)(q,{open:!!s,onOpenChange:t(x=>!x&&o(),"onOpenChange"),children:(0,e.jsxs)(O,{children:[(0,e.jsxs)(K,{children:[(0,e.jsx)(M,{children:"Remove assignment"}),(0,e.jsx)(U,{children:s?.targetType==="company"?"Removing the organization default changes access for every agent that relies on it.":`Remove this profile from ${a}.`})]}),(0,e.jsxs)(F,{children:[(0,e.jsx)(p,{variant:"ghost",onClick:o,children:"Cancel"}),(0,e.jsx)(p,{disabled:n,onClick:u,children:"Remove"})]})]})})}t(We,"RemoveAssignmentDialog");function He(s,a,n,o,u){const x=s.entries.filter(i=>i.effect==="exclude"),v=s.entries.filter(i=>i.effect==="include"),j=s.summary.accessMode==="all_except";return a.filter(i=>!x.some(l=>V(l,i))).filter(i=>j||v.some(l=>V(l,i))).map(i=>{const l=j?null:v.find(h=>V(h,i))??null,f=n.get(i.applicationId??"")??o.get(i.connectionId)??"Unknown app",d=u.find(h=>h.id===i.connectionId);return{id:i.id,app:f,tool:i.title||i.toolName,capabilities:Ye(i),source:Ve(l,f),autoAddedAt:s.defaultAction==="allow"&&Ze(i)?i.addedAt??i.firstSeenAt:null,degraded:!!(d&&(d.status!=="active"||d.healthStatus==="error")),connectionId:i.connectionId}})}t(He,"buildAllowRows");function V(s,a){switch(s.selectorType){case"application":return!!(s.applicationId&&s.applicationId===a.applicationId);case"connection":return!!(s.connectionId&&s.connectionId===a.connectionId);case"catalog_entry":return!!(s.catalogEntryId&&s.catalogEntryId===a.id);case"tool_name":return!!(s.toolName&&s.toolName===a.toolName);case"risk_level":return!!(s.riskLevel&&s.riskLevel===a.riskLevel);default:return!1}}t(V,"entryMatchesTool");function Ve(s,a){return s?s.selectorType==="application"||s.selectorType==="connection"?`added by rule: all ${a}`:s.selectorType==="risk_level"&&s.riskLevel?`added by rule: ${s.riskLevel} tools`:"added directly":"added directly"}t(Ve,"sourceLabel");function Ye(s){return s.isDestructive?"Destructive":s.isWrite?"Write":"Read"}t(Ye,"capabilityLabel");function Ge(s){return s.riskLevel==="destructive"?"Destructive":s.riskLevel==="write"?"Write":s.riskLevel==="read"?"Read":s.capability}t(Ge,"capabilityText");function Xe(s){const a=[...new Set(s.map(n=>n.applicationName??n.connectionName).filter(Boolean))];return a.length===0?"An app":a.length===1?a[0]??"An app":a.length===2?`${a[0]} and ${a[1]}`:`${a[0]} and ${a.length-1} more apps`}t(Xe,"newToolsAppLabel");function Ze(s){const a=s.addedAt??s.firstSeenAt,n=new Date(a).getTime();return Number.isFinite(n)?Date.now()-n<=2592e6:!1}t(Ze,"isRecentTool");function le(s,a,n){return s.targetType==="company"?"Organization default":s.targetType==="agent"?n.agentsById.get(s.targetId)??"Unknown agent":s.targetType==="project"?n.projectsById.get(s.targetId)??"Unknown project":s.targetType==="routine"?n.routinesById.get(s.targetId)??"Unknown routine":s.targetId===a?"Organization":s.targetId}t(le,"assignmentLabel");function Je(s){return s==="company"?"Organization default":s==="agent"?"Agent":s==="project"?"Project":s==="routine"?"Routine":"Scoped assignment"}t(Je,"assignmentTypeLabel");function ls(){const{selectedCompany:s,selectedCompanyId:a}=fe(),{setBreadcrumbs:n}=Ae(),o=Ne();return(0,g.useEffect)(()=>(n([{label:s?.name??"Company",href:"/dashboard"},{label:"Apps",href:"/apps"},{label:"Access profiles",href:Ee("profiles")},{label:"Profile detail"}]),()=>n([])),[n,s?.name]),!a||!o.profileId?(0,e.jsx)("div",{className:"p-6 text-sm text-muted-foreground",children:"Select an organization and profile."}):(0,e.jsx)($e,{children:(0,e.jsx)("div",{className:"mx-auto flex w-full max-w-6xl flex-col gap-5 p-4 sm:p-6",children:(0,e.jsx)(Fe,{companyId:a,profileId:o.profileId})})})}t(ls,"ProfileDetailRoute");export{ls as ProfileDetailRoute};
1
+ var ue=Object.defineProperty;var t=(s,a)=>ue(s,"name",{value:a,configurable:!0});import{a as te}from"./rolldown-runtime-DhZMWcEn.js";import{si as me}from"./issue-detail-CZfjXs0M.js";import{$A as pe,$S as xe,AC as he,GS as R,H_ as ae,Jp as I,LS as fe,ME as ge,NE as p,QT as je,XC as ve,XT as ye,YE as ne,Yb as be,__ as H,aE as Ne,ab as re,bE as _,cT as we,dy as F,fy as K,gC as ke,g_ as Ce,ib as Ae,ly as O,my as M,nj as Te,oE as Se,op as z,sv as Ie,sy as q,ub as ee,uy as U,vi as Ee,xE as Pe,zE as Y}from"./index-BJtnP7H1.js";import{a as Le,i as ie,s as se}from"./shared-D37zfckm.js";import{a as De,n as Re,t as _e}from"./profile-summary-D4LPX-Dv.js";import{n as Be}from"./useProfilesData-CWHdMSuL.js";import{t as $e}from"./ToolsAdminGate-DpBg30hQ.js";var oe={name:"plug-zap",size:24,node:[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]],aliases:["plug-zap-2"]};oe.node;var ze=je(oe),g=te(Te(),1),e=te(pe(),1);function Fe({companyId:s,profileId:a,initialCreated:n,initialReviewOpen:o}){const u=be(),[x,v]=Se(),j=ge(),{pushToast:i}=Ie(),l=Be(s),f=ee(l.profiles),[d,h]=(0,g.useState)(null),[N,A]=(0,g.useState)(null),[Q,y]=(0,g.useState)(!!o),[B,E]=(0,g.useState)({}),m=(l.profiles.data?.profiles??[]).find(r=>r.id===a)??null,W=n??x.get("created")==="1",w=m?.newToolsPendingCount??0,k=Pe({queryKey:R.tools.profileNewTools(a),queryFn:t(()=>I.getProfileNewTools(a),"queryFn"),enabled:w>0}),C=ee(k),P=k.isLoading||C.kind==="reconnecting",c=t(()=>{j.invalidateQueries({queryKey:R.tools.profiles(s)}),j.invalidateQueries({queryKey:R.tools.testAgentAccesses()})},"invalidate"),L=t(r=>String(r?.message??r),"errorBody"),de=(0,g.useMemo)(()=>m?He(m,l.catalog,l.maps.applicationsById,l.maps.connectionsById,l.connections.data?.connections??[]):[],[m,l.catalog,l.maps.applicationsById,l.maps.connectionsById,l.connections.data?.connections]),T=k.data?.tools??[];(0,g.useEffect)(()=>{x.get("review")==="new-tools"&&w>0&&y(!0)},[w,x]),(0,g.useEffect)(()=>{T.length!==0&&E(r=>{const D={...r};for(const $ of T)D[$.catalogEntryId]||(D[$.catalogEntryId]="keep_blocked");return D})},[T]);const S=_({mutationFn:t(r=>I.updateProfile(a,r),"mutationFn"),onSuccess:t(()=>{c(),i({title:"Profile updated",tone:"success"})},"onSuccess"),onError:t(r=>i({title:"Could not update profile",body:L(r),tone:"error"}),"onError")}),G=_({mutationFn:t(r=>I.duplicateProfile(a,r),"mutationFn"),onSuccess:t(r=>{c(),i({title:"Profile duplicated",body:"The copy is not assigned to anyone yet.",tone:"success"}),u(`/apps/advanced/profiles/${r.id}?created=1`)},"onSuccess"),onError:t(r=>i({title:"Could not duplicate",body:L(r),tone:"error"}),"onError")}),X=_({mutationFn:t(()=>I.deleteProfile(a),"mutationFn"),onSuccess:t(()=>{c(),i({title:"Profile deleted",tone:"success"}),u("/apps/advanced/profiles")},"onSuccess"),onError:t(r=>i({title:"Could not delete",body:L(r),tone:"error"}),"onError")}),Z=_({mutationFn:t(r=>I.unbindProfile(s,a,{targetType:r.targetType,targetId:r.targetId}),"mutationFn"),onSuccess:t(()=>{A(null),c(),i({title:"Assignment removed",tone:"success"})},"onSuccess"),onError:t(r=>i({title:"Could not remove assignment",body:L(r),tone:"error"}),"onError")}),J=_({mutationFn:t(()=>I.reviewProfileNewTools(a,{decisions:T.map(r=>({catalogEntryId:r.catalogEntryId,decision:B[r.catalogEntryId]??"keep_blocked"}))}),"mutationFn"),onSuccess:t(()=>{y(!1),v({}),j.invalidateQueries({queryKey:R.tools.profiles(s)}),j.invalidateQueries({queryKey:R.tools.profileNewTools(a)}),i({title:"New tools reviewed",tone:"success"})},"onSuccess"),onError:t(r=>i({title:"Could not submit review",body:L(r),tone:"error"}),"onError")});if(l.profiles.isLoading||f.kind==="reconnecting")return(0,e.jsx)(ie,{label:"Loading profile..."});if(f.kind==="error")return(0,e.jsx)(re,{size:"page",error:l.profiles.error,action:"load the profile",onRetry:f.retry,retrying:f.isFetching});if(!m)return(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)(se,{title:"Profile not found",description:"This access profile may have been deleted."}),(0,e.jsx)(p,{variant:"outline",onClick:t(()=>u("/apps/advanced/profiles"),"onClick"),children:"Back to profiles"})]});const b=m.status==="archived",ce=m.summary.assignmentCount===0;return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsx)(se,{title:m.name,description:m.description??"No description yet.",actions:(0,e.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,e.jsxs)(p,{variant:"outline",disabled:b,onClick:t(()=>h("edit"),"onClick"),children:[(0,e.jsx)(ve,{className:"mr-1.5 h-4 w-4"}),"Edit"]}),(0,e.jsxs)(p,{variant:"outline",disabled:b,onClick:t(()=>h("duplicate"),"onClick"),children:[(0,e.jsx)(we,{className:"mr-1.5 h-4 w-4"}),"Duplicate"]}),b?(0,e.jsxs)(p,{variant:"outline",onClick:t(()=>h("restore"),"onClick"),children:[(0,e.jsx)(ye,{className:"mr-1.5 h-4 w-4"}),"Restore"]}):(0,e.jsx)(p,{variant:"outline",onClick:t(()=>h("archive"),"onClick"),children:"Archive"}),(0,e.jsxs)(p,{variant:"outline",className:"text-destructive hover:text-destructive",onClick:t(()=>h("delete"),"onClick"),children:[(0,e.jsx)(ke,{className:"mr-1.5 h-4 w-4"}),"Delete"]})]})}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-sm",children:[(0,e.jsx)(ae,{variant:b?"outline":"default",children:_e[m.status]}),(0,e.jsxs)("span",{className:"text-muted-foreground",children:["Updated ",(0,e.jsx)(Le,{value:m.updatedAt})]}),(0,e.jsx)("span",{className:"text-muted-foreground",children:Re(m.summary)})]}),W?(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-primary/30 bg-primary/5 px-4 py-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Profile saved"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:ce?"Assign it to agents before it changes their access.":"Assignments are active now."})]}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)(p,{size:"sm",onClick:t(()=>u(`/apps/advanced/profiles/${m.id}/edit?step=3`),"onClick"),children:"Assign"}),(0,e.jsx)(p,{size:"sm",variant:"ghost",onClick:t(()=>v({}),"onClick"),children:"Dismiss"})]})]}):null,b?(0,e.jsx)("div",{className:"rounded-lg border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-950",children:"This profile is archived. It does not apply to agents until it is restored."}):null,w>0?(0,e.jsx)(Ke,{count:w,tools:T,loading:P,onReview:t(()=>y(!0),"onReview")}):null,(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)("h2",{className:"text-base font-semibold text-foreground",children:"What it allows"}),(0,e.jsx)(p,{variant:"outline",size:"sm",disabled:b,onClick:t(()=>u(`/apps/advanced/profiles/${m.id}/edit?step=2`),"onClick"),children:"Edit tools"})]}),(0,e.jsx)(Me,{rows:de,total:m.summary.totalToolCount})]}),(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)("h2",{className:"text-base font-semibold text-foreground",children:"Who has it"}),(0,e.jsx)(p,{variant:"outline",size:"sm",disabled:b,onClick:t(()=>u(`/apps/advanced/profiles/${m.id}/edit?step=3`),"onClick"),children:"Assign"})]}),(0,e.jsx)(qe,{profile:m,companyId:s,maps:l.maps,archived:b,onRemove:A})]}),(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsx)("h2",{className:"text-base font-semibold text-foreground",children:"New tools that appear later"}),(0,e.jsx)(Ue,{value:m.defaultAction,disabled:b||S.isPending,onChange:t(r=>S.mutate({defaultAction:r}),"onChange")})]}),(0,e.jsxs)(p,{variant:"link",className:"h-auto px-0",onClick:t(()=>u("/apps/advanced/profiles?check=1"),"onClick"),children:[(0,e.jsx)(he,{className:"mr-1.5 h-4 w-4"}),"Check what an agent can actually do"]}),(0,e.jsx)(Qe,{kind:d,profile:m,allProfiles:l.profiles.data?.profiles??[],pending:S.isPending||G.isPending||X.isPending,onClose:t(()=>h(null),"onClose"),onUpdate:t(r=>S.mutate(r,{onSuccess:t(()=>h(null),"onSuccess")}),"onUpdate"),onDuplicate:t(r=>G.mutate(r,{onSuccess:t(()=>h(null),"onSuccess")}),"onDuplicate"),onArchive:t(()=>S.mutate({status:"archived"},{onSuccess:t(()=>h(null),"onSuccess")}),"onArchive"),onRestore:t(()=>S.mutate({status:"active"},{onSuccess:t(()=>h(null),"onSuccess")}),"onRestore"),onDelete:t(()=>X.mutate(void 0,{onSuccess:t(()=>h(null),"onSuccess")}),"onDelete")}),(0,e.jsx)(We,{binding:N,label:N?le(N,s,l.maps):"",pending:Z.isPending,onClose:t(()=>A(null),"onClose"),onConfirm:t(()=>N&&Z.mutate(N),"onConfirm")}),(0,e.jsx)(Oe,{open:Q,tools:T,loading:P,error:C.kind==="error"?k.error:null,decisions:B,pending:J.isPending,onClose:t(()=>y(!1),"onClose"),onRetry:C.retry,retrying:C.isFetching,onDecision:t((r,D)=>E($=>({...$,[r]:D})),"onDecision"),onSubmit:t(()=>J.mutate(),"onSubmit")})]})}t(Fe,"ProfileDetail");function Ke({count:s,tools:a,loading:n,onReview:o}){const u=Xe(a);return(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-lg border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-950",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"font-medium",children:n?"New tools need review":`${u} added ${s} new ${s===1?"tool":"tools"} since your last review`}),(0,e.jsx)("p",{className:"text-amber-900/80",children:"Choose which ones this profile should allow."})]}),(0,e.jsx)(p,{size:"sm",onClick:o,children:"Review"})]})}t(Ke,"NewToolsReviewBanner");function Oe({open:s,tools:a,loading:n,error:o,decisions:u,pending:x,onClose:v,onRetry:j,retrying:i,onDecision:l,onSubmit:f}){return(0,e.jsx)(q,{open:s,onOpenChange:t(d=>!d&&v(),"onOpenChange"),children:(0,e.jsxs)(O,{className:"max-w-2xl",children:[(0,e.jsxs)(K,{children:[(0,e.jsx)(M,{children:"Review new tools"}),(0,e.jsx)(U,{children:"Allow the tools this profile should use. Keep the rest blocked."})]}),n?(0,e.jsx)(ie,{label:"Loading new tools..."}):o?(0,e.jsx)(re,{error:o,action:"load new tools",onRetry:j,retrying:i}):a.length===0?(0,e.jsx)("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-sm text-muted-foreground",children:"There are no new tools waiting for review."}):(0,e.jsx)("div",{className:"max-h-(--sz-52vh) divide-y divide-border overflow-y-auto rounded-lg border border-border",children:a.map(d=>(0,e.jsxs)("div",{className:"grid gap-3 px-3 py-3 sm:grid-cols-[1fr_auto]",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("p",{className:"truncate text-sm font-medium text-foreground",children:d.title||d.toolName}),(0,e.jsx)(ae,{variant:"secondary",children:Ge(d)})]}),d.description?(0,e.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:d.description}):null,(0,e.jsxs)("p",{className:Y("mt-1 text-xs text-muted-foreground",xe),children:[d.applicationName??d.connectionName??"App tool"," · added ",ne(d.addedAt)]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2 sm:justify-end",children:[(0,e.jsxs)("label",{className:"inline-flex items-center gap-1.5 text-sm",children:[(0,e.jsx)("input",{type:"radio",name:`review-${d.catalogEntryId}`,checked:(u[d.catalogEntryId]??"keep_blocked")==="allow",onChange:t(()=>l(d.catalogEntryId,"allow"),"onChange")}),"Allow"]}),(0,e.jsxs)("label",{className:"inline-flex items-center gap-1.5 text-sm",children:[(0,e.jsx)("input",{type:"radio",name:`review-${d.catalogEntryId}`,checked:(u[d.catalogEntryId]??"keep_blocked")==="keep_blocked",onChange:t(()=>l(d.catalogEntryId,"keep_blocked"),"onChange")}),"Keep blocked"]})]})]},d.catalogEntryId))}),(0,e.jsxs)(F,{children:[(0,e.jsx)(p,{variant:"ghost",onClick:v,children:"Cancel"}),(0,e.jsx)(p,{disabled:x||n||a.length===0,onClick:f,children:"Submit review"})]})]})})}t(Oe,"NewToolsReviewDialog");function Me({rows:s,total:a}){return s.length===0?(0,e.jsx)("div",{className:"rounded-lg border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-950",children:"This profile allows 0 tools. Agents with only this profile will not be able to use app tools."}):(0,e.jsxs)("div",{className:"overflow-hidden rounded-lg border border-border",children:[(0,e.jsx)("div",{className:"max-w-full overflow-x-auto",children:(0,e.jsxs)("table",{className:"w-full text-sm",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"border-b border-border bg-muted/40 text-left text-xs font-medium text-muted-foreground",children:[(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Tool"}),(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"App"}),(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Capabilities"}),(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Source"})]})}),(0,e.jsx)("tbody",{children:s.slice(0,80).map(n=>(0,e.jsxs)("tr",{className:Y("border-b border-border last:border-0",n.degraded&&"bg-muted/30 text-muted-foreground"),children:[(0,e.jsx)("td",{className:"px-3 py-2",children:(0,e.jsxs)("div",{className:"flex flex-col",children:[(0,e.jsx)("span",{className:"font-medium text-foreground",children:n.tool}),n.degraded?(0,e.jsxs)("a",{className:"mt-0.5 inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline",href:`/apps/${n.connectionId}`,children:[(0,e.jsx)(ze,{className:"h-3 w-3"}),"Reconnect"]}):null]})}),(0,e.jsxs)("td",{className:"px-3 py-2",children:[(0,e.jsx)("span",{children:n.app}),n.degraded?(0,e.jsxs)("span",{className:"ml-2 text-xs text-muted-foreground",children:[n.app," is disconnected"]}):null]}),(0,e.jsx)("td",{className:"px-3 py-2 text-muted-foreground",children:n.capabilities}),(0,e.jsxs)("td",{className:"px-3 py-2",children:[n.source.startsWith("added by rule")?(0,e.jsx)("span",{className:"rounded bg-amber-100 px-1.5 py-0.5 text-xs text-amber-950",children:n.source}):(0,e.jsx)("span",{className:"text-muted-foreground",children:n.source}),n.autoAddedAt?(0,e.jsxs)("div",{className:"mt-0.5 text-xs text-muted-foreground",children:["added automatically · ",ne(n.autoAddedAt)]}):null]})]},n.id))})]})}),s.length>80?(0,e.jsxs)("p",{className:"border-t border-border px-3 py-2 text-xs text-muted-foreground",children:["Showing 80 of ",s.length," allowed tools."]}):(0,e.jsxs)("p",{className:"border-t border-border px-3 py-2 text-xs text-muted-foreground",children:["Allows ",s.length," of ",a," known tools."]})]})}t(Me,"AllowList");function qe({profile:s,companyId:a,maps:n,archived:o,onRemove:u}){return s.bindings.length===0?(0,e.jsxs)("div",{className:"rounded-lg border border-dashed border-border px-4 py-5",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Not assigned yet"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Assign this profile before it changes access."})]}):(0,e.jsx)("div",{className:"divide-y divide-border overflow-hidden rounded-lg border border-border",children:s.bindings.map(x=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 px-3 py-2.5",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,e.jsx)("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-muted text-xs font-semibold text-muted-foreground",children:x.targetType==="company"?"Or":x.targetType.slice(0,2).toUpperCase()}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("p",{className:"truncate text-sm font-medium text-foreground",children:le(x,a,n)}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:Je(x.targetType)})]})]}),(0,e.jsxs)(p,{variant:"ghost",size:"sm",disabled:o,onClick:t(()=>u(x),"onClick"),children:[(0,e.jsx)(me,{className:"mr-1.5 h-4 w-4"}),"Remove"]})]},x.id))})}t(qe,"Assignments");function Ue({value:s,disabled:a,onChange:n}){return(0,e.jsx)("div",{className:"grid gap-2 sm:grid-cols-2",children:[{value:"deny",title:"Stay blocked until reviewed",body:"New tools do not become available automatically."},{value:"allow",title:"Allowed automatically",body:"New tools from selected apps become available right away."}].map(o=>(0,e.jsxs)("label",{className:Y("flex cursor-pointer items-start gap-3 rounded-lg border px-4 py-3",s===o.value?"border-primary bg-primary/5":"border-border",a&&"cursor-not-allowed opacity-60"),children:[(0,e.jsx)("input",{type:"radio",className:"mt-1",disabled:a,checked:s===o.value,onChange:t(()=>n(o.value),"onChange")}),(0,e.jsxs)("span",{children:[(0,e.jsx)("span",{className:"block text-sm font-medium text-foreground",children:o.title}),(0,e.jsx)("span",{className:"block text-xs text-muted-foreground",children:o.body})]})]},o.value))})}t(Ue,"NewToolsSetting");function Qe({kind:s,profile:a,allProfiles:n,pending:o,onClose:u,onUpdate:x,onDuplicate:v,onArchive:j,onRestore:i,onDelete:l}){const[f,d]=(0,g.useState)(a.name),[h,N]=(0,g.useState)(a.description??""),[A,Q]=(0,g.useState)(a.profileKey),[y,B]=(0,g.useState)(`${a.name} copy`),[E,m]=(0,g.useState)(!1),[W,w]=(0,g.useState)(!1),k=n.some(c=>c.id!==a.id&&c.name.trim().toLowerCase()===f.trim().toLowerCase()),C=n.some(c=>c.name.trim().toLowerCase()===y.trim().toLowerCase());if(!s)return null;const P=!!s;return s==="edit"?(0,e.jsx)(q,{open:P,onOpenChange:t(c=>!c&&u(),"onOpenChange"),children:(0,e.jsxs)(O,{children:[(0,e.jsxs)(K,{children:[(0,e.jsx)(M,{children:"Edit profile"}),(0,e.jsx)(U,{children:"Update the profile name and description."})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(z,{htmlFor:"edit-profile-name",children:"Name"}),(0,e.jsx)(H,{id:"edit-profile-name",value:f,onChange:t(c=>d(c.target.value),"onChange")}),k?(0,e.jsx)("p",{className:"text-xs text-destructive",children:"Another profile already uses this name."}):null]}),(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(z,{htmlFor:"edit-profile-description",children:"Description"}),(0,e.jsx)(Ce,{id:"edit-profile-description",value:h,onChange:t(c=>N(c.target.value),"onChange"),rows:3})]}),(0,e.jsx)("button",{type:"button",className:"text-sm font-medium text-muted-foreground hover:text-foreground",onClick:t(()=>w(c=>!c),"onClick"),children:"Advanced"}),W?(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(z,{htmlFor:"edit-profile-key",children:"Identifier"}),(0,e.jsx)(H,{id:"edit-profile-key",value:A,onChange:t(c=>Q(c.target.value),"onChange"),className:"font-mono text-xs"})]}):null]}),(0,e.jsxs)(F,{children:[(0,e.jsx)(p,{variant:"ghost",onClick:u,children:"Cancel"}),(0,e.jsx)(p,{disabled:!f.trim()||k||o,onClick:t(()=>x({name:f.trim(),description:h.trim()||null,profileKey:A.trim()}),"onClick"),children:"Save"})]})]})}):s==="duplicate"?(0,e.jsx)(q,{open:P,onOpenChange:t(c=>!c&&u(),"onOpenChange"),children:(0,e.jsxs)(O,{children:[(0,e.jsxs)(K,{children:[(0,e.jsx)(M,{children:"Duplicate profile"}),(0,e.jsx)(U,{children:"The copy starts unassigned unless you choose to copy assignments too."})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(z,{htmlFor:"copy-profile-name",children:"Name"}),(0,e.jsx)(H,{id:"copy-profile-name",value:y,onChange:t(c=>B(c.target.value),"onChange")}),C?(0,e.jsx)("p",{className:"text-xs text-destructive",children:"Another profile already uses this name."}):null]}),(0,e.jsxs)("label",{className:"flex items-center gap-2 text-sm",children:[(0,e.jsx)("input",{type:"checkbox",checked:E,onChange:t(c=>m(c.target.checked),"onChange")}),"Also copy assignments?"]})]}),(0,e.jsxs)(F,{children:[(0,e.jsx)(p,{variant:"ghost",onClick:u,children:"Cancel"}),(0,e.jsx)(p,{disabled:!y.trim()||C||o,onClick:t(()=>v({name:y.trim(),includeAssignments:E}),"onClick"),children:"Duplicate"})]})]})}):(0,e.jsx)(De,{kind:s,profile:a,pending:o,onClose:u,onArchive:j,onRestore:i,onDelete:l})}t(Qe,"ProfileDialogs");function We({binding:s,label:a,pending:n,onClose:o,onConfirm:u}){return(0,e.jsx)(q,{open:!!s,onOpenChange:t(x=>!x&&o(),"onOpenChange"),children:(0,e.jsxs)(O,{children:[(0,e.jsxs)(K,{children:[(0,e.jsx)(M,{children:"Remove assignment"}),(0,e.jsx)(U,{children:s?.targetType==="company"?"Removing the organization default changes access for every agent that relies on it.":`Remove this profile from ${a}.`})]}),(0,e.jsxs)(F,{children:[(0,e.jsx)(p,{variant:"ghost",onClick:o,children:"Cancel"}),(0,e.jsx)(p,{disabled:n,onClick:u,children:"Remove"})]})]})})}t(We,"RemoveAssignmentDialog");function He(s,a,n,o,u){const x=s.entries.filter(i=>i.effect==="exclude"),v=s.entries.filter(i=>i.effect==="include"),j=s.summary.accessMode==="all_except";return a.filter(i=>!x.some(l=>V(l,i))).filter(i=>j||v.some(l=>V(l,i))).map(i=>{const l=j?null:v.find(h=>V(h,i))??null,f=n.get(i.applicationId??"")??o.get(i.connectionId)??"Unknown app",d=u.find(h=>h.id===i.connectionId);return{id:i.id,app:f,tool:i.title||i.toolName,capabilities:Ye(i),source:Ve(l,f),autoAddedAt:s.defaultAction==="allow"&&Ze(i)?i.addedAt??i.firstSeenAt:null,degraded:!!(d&&(d.status!=="active"||d.healthStatus==="error")),connectionId:i.connectionId}})}t(He,"buildAllowRows");function V(s,a){switch(s.selectorType){case"application":return!!(s.applicationId&&s.applicationId===a.applicationId);case"connection":return!!(s.connectionId&&s.connectionId===a.connectionId);case"catalog_entry":return!!(s.catalogEntryId&&s.catalogEntryId===a.id);case"tool_name":return!!(s.toolName&&s.toolName===a.toolName);case"risk_level":return!!(s.riskLevel&&s.riskLevel===a.riskLevel);default:return!1}}t(V,"entryMatchesTool");function Ve(s,a){return s?s.selectorType==="application"||s.selectorType==="connection"?`added by rule: all ${a}`:s.selectorType==="risk_level"&&s.riskLevel?`added by rule: ${s.riskLevel} tools`:"added directly":"added directly"}t(Ve,"sourceLabel");function Ye(s){return s.isDestructive?"Destructive":s.isWrite?"Write":"Read"}t(Ye,"capabilityLabel");function Ge(s){return s.riskLevel==="destructive"?"Destructive":s.riskLevel==="write"?"Write":s.riskLevel==="read"?"Read":s.capability}t(Ge,"capabilityText");function Xe(s){const a=[...new Set(s.map(n=>n.applicationName??n.connectionName).filter(Boolean))];return a.length===0?"An app":a.length===1?a[0]??"An app":a.length===2?`${a[0]} and ${a[1]}`:`${a[0]} and ${a.length-1} more apps`}t(Xe,"newToolsAppLabel");function Ze(s){const a=s.addedAt??s.firstSeenAt,n=new Date(a).getTime();return Number.isFinite(n)?Date.now()-n<=2592e6:!1}t(Ze,"isRecentTool");function le(s,a,n){return s.targetType==="company"?"Organization default":s.targetType==="agent"?n.agentsById.get(s.targetId)??"Unknown agent":s.targetType==="project"?n.projectsById.get(s.targetId)??"Unknown project":s.targetType==="routine"?n.routinesById.get(s.targetId)??"Unknown routine":s.targetId===a?"Organization":s.targetId}t(le,"assignmentLabel");function Je(s){return s==="company"?"Organization default":s==="agent"?"Agent":s==="project"?"Project":s==="routine"?"Routine":"Scoped assignment"}t(Je,"assignmentTypeLabel");function ls(){const{selectedCompany:s,selectedCompanyId:a}=fe(),{setBreadcrumbs:n}=Ae(),o=Ne();return(0,g.useEffect)(()=>(n([{label:s?.name??"Company",href:"/dashboard"},{label:"Apps",href:"/apps"},{label:"Access profiles",href:Ee("profiles")},{label:"Profile detail"}]),()=>n([])),[n,s?.name]),!a||!o.profileId?(0,e.jsx)("div",{className:"p-6 text-sm text-muted-foreground",children:"Select an organization and profile."}):(0,e.jsx)($e,{children:(0,e.jsx)("div",{className:"mx-auto flex w-full max-w-6xl flex-col gap-5 p-4 sm:p-6",children:(0,e.jsx)(Fe,{companyId:a,profileId:o.profileId})})})}t(ls,"ProfileDetailRoute");export{ls as ProfileDetailRoute};
@@ -1 +1 @@
1
- var ne=Object.defineProperty;var t=(s,i)=>ne(s,"name",{value:i,configurable:!0});import{a as V}from"./rolldown-runtime-DhZMWcEn.js";import{$A as ie,A_ as re,E_ as W,Fb as oe,Fd as le,GS as k,Hb as T,LC as Y,LS as ce,ME as $,M_ as de,NE as w,O_ as ue,Ow as me,Pb as ge,QT as G,Rb as pe,YS as B,__ as K,_w as N,ab as J,bE as F,bp as he,dC as xe,gC as fe,hE as S,ib as be,j_ as ye,k_ as ve,m_ as we,nj as je,op as D,rb as Ne,uE as j,ub as X,xE as I,yp as ke}from"./index-Bt31d8ga.js";var Z={name:"bell-ring",size:24,node:[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]]};Z.node;var Se=G(Z),ee={name:"camera",size:24,node:[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]};ee.node;var Q=G(ee),p=V(je(),1),U={getMine:t(s=>j.get(`/companies/${s}/users/me/inbox-agent-policy`),"getMine"),updateMine:t((s,i)=>j.put(`/companies/${s}/users/me/inbox-agent-policy`,i),"updateMine")},e=V(ie(),1),Ae=[{value:"open",title:"Any of my agents",description:"Let any agent you manage archive tasks out of your inbox."},{value:"allowlist",title:"Only chosen agents",description:"Restrict inbox tidying to the agents you pick below."},{value:"disabled",title:"Off",description:"Agents can never archive tasks from your inbox."}];function M(s,i){return`${s}:${[...i].sort().join(",")}`}t(M,"policyKey");function Ce({companyId:s}){const i=$(),[a,u]=(0,p.useState)(null),g=(0,p.useRef)(null),x=I({queryKey:s?k.inboxAgentPolicy.mine(s):["inbox-agent-policy","none"],queryFn:t(()=>U.getMine(s),"queryFn"),enabled:!!s}),h=X(x),l=x.data,b=I({queryKey:s?k.agents.list(s):["agents","none"],queryFn:t(()=>Ne.list(s),"queryFn"),enabled:!!s}),f=(0,p.useMemo)(()=>(b.data??[]).filter(we),[b.data]),y=(0,p.useMemo)(()=>f.map(o=>({id:o.id,name:o.name,title:o.title??o.role,icon:o.icon})),[f]),r=(0,p.useMemo)(()=>new Set(a?.allowedAgentIds??[]),[a?.allowedAgentIds]);(0,p.useEffect)(()=>{if(!l)return;const o=M(l.mode,l.allowedAgentIds);u(m=>m===null||M(m.mode,m.allowedAgentIds)===g.current?{mode:l.mode,allowedAgentIds:l.allowedAgentIds}:m),g.current=o},[l]);const c=F({mutationFn:t(o=>U.updateMine(s,{mode:o.mode,allowedAgentIds:o.mode==="allowlist"?o.allowedAgentIds:[]}),"mutationFn"),onSuccess:t(o=>{i.setQueryData(k.inboxAgentPolicy.mine(s),o)},"onSuccess")}),v=!!(a&&l&&M(a.mode,a.allowedAgentIds)!==M(l.mode,l.allowedAgentIds));return h.kind==="error"?(0,e.jsx)(J,{error:h.error,action:"load the inbox agent policy",onRetry:h.retry,retrying:h.isFetching}):x.isLoading||h.kind==="reconnecting"||!a?(0,e.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading inbox agent policy…"}):(0,e.jsxs)("section",{className:"space-y-4","aria-label":"Let agents tidy my inbox",children:[(0,e.jsxs)("div",{className:"space-y-1",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:"Let agents tidy my inbox"})]}),(0,e.jsx)("p",{className:"max-w-2xl text-sm text-muted-foreground",children:"Choose whether the agents you manage may archive tasks out of your inbox on your behalf. You can undo any archive, and every agent archive is attributed in the task's properties."})]}),(0,e.jsx)(ke,{ariaLabel:"Inbox agent archiving policy",value:a.mode,onValueChange:t(o=>u(m=>m&&{...m,mode:o}),"onValueChange"),options:Ae,className:"max-w-2xl"}),a.mode==="allowlist"?(0,e.jsxs)("div",{className:"max-w-2xl space-y-2",children:[(0,e.jsx)("div",{className:"text-sm font-medium",children:"Agents allowed to tidy my inbox"}),(0,e.jsx)(he,{agents:y,selectedAgentIds:r,onChange:t(o=>u(m=>m&&{...m,allowedAgentIds:[...o]}),"onChange"),triggerLabel:r.size===0?"Select agents":`${r.size} ${r.size===1?"agent":"agents"} selected`,triggerFullWidth:!1,showSelectionPreview:!1,emptyMessage:"You don’t manage any agents yet."})]}):null,c.error?(0,e.jsx)("div",{role:"alert",className:"max-w-2xl rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:S(c.error,{action:"save the inbox agent policy"}).body}):null,(0,e.jsxs)("div",{className:"flex max-w-2xl items-center justify-end gap-3",children:[c.isSuccess&&!v?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",role:"status",children:"Saved"}):null,(0,e.jsxs)(w,{type:"button",disabled:!v||c.isPending,onClick:t(()=>a&&c.mutate(a),"onClick"),children:[c.isPending?(0,e.jsx)(N,{className:"size-4 animate-spin"}):(0,e.jsx)(Y,{className:"size-4"}),c.isPending?"Saving…":"Save"]})]})]})}t(Ce,"InboxAgentPolicyControl");var z={status:t(s=>j.get(`/microvac/push${s?`?endpoint=${encodeURIComponent(s)}`:""}`),"status"),subscribe:t(s=>j.post("/microvac/push/subscriptions",s),"subscribe"),unsubscribe:t(s=>j.delete("/microvac/push/subscriptions",{endpoint:s}),"unsubscribe"),test:t(s=>j.post("/microvac/push/test",{endpoint:s}),"test")};function Pe(s){const i=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(s.length/4)*4,"="),a=atob(i),u=new Uint8Array(new ArrayBuffer(a.length));for(let g=0;g<a.length;g+=1)u[g]=a.charCodeAt(g);return u}t(Pe,"keyBytes");async function _e(){if(!await navigator.serviceWorker.getRegistration())throw new Error("The service worker is not installed; reload the page and try again.");return navigator.serviceWorker.ready}t(_e,"registration");var Ee={supported:t(()=>typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window,"supported"),permission:t(()=>Notification.permission,"permission"),async current(){const s=await navigator.serviceWorker.getRegistration();return s?s.pushManager.getSubscription():null},async subscribe(s){if(await Notification.requestPermission()!=="granted")throw new Error("Notifications are blocked for this site in the browser settings.");const i=await _e(),a=(await i.pushManager.getSubscription()??await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Pe(s)})).toJSON();if(!a.endpoint||!a.keys?.p256dh||!a.keys.auth)throw new Error("The browser returned an incomplete subscription.");return{endpoint:a.endpoint,keys:{p256dh:a.keys.p256dh,auth:a.keys.auth}}}},H=["microvac","push"],Me={awaiting_human_answer:"an agent asks you a question",agent_failed:"an agent run fails",blocked_by_child:"a subtask blocks its parent"};function ze(s){const i=s.map(a=>Me[a]??a.replace(/_/g," "));return i.length===0?"No event sends notifications yet; an instance admin chooses them in the Cordis plugin settings.":`This device is notified when ${i.join(", or when ")}.`}t(ze,"describeReasons");function Fe({browser:s=Ee}){const i=$(),a=s.supported(),u=I({queryKey:H,enabled:a,queryFn:t(async()=>{const r=await s.current();return z.status(r?.endpoint??null)},"queryFn")}),g=t(()=>i.invalidateQueries({queryKey:H}),"refresh"),x=F({mutationFn:t(async()=>{const r=u.data?.publicKey;if(!r)throw new Error("Push notifications are off on this instance.");await z.subscribe(await s.subscribe(r))},"mutationFn"),onSettled:g}),h=F({mutationFn:t(async()=>{const r=await s.current();r&&(await z.unsubscribe(r.endpoint),await r.unsubscribe())},"mutationFn"),onSettled:g}),l=F({mutationFn:t(async()=>{const r=await s.current();if(!r)throw new Error("This browser is not subscribed.");return z.test(r.endpoint)},"mutationFn")});if(a&&(u.isLoading||u.data?.enabled===!1))return null;const b=u.error??x.error??h.error??l.error,f=u.data?.subscribed===!0,y=x.isPending||h.isPending;return(0,e.jsxs)(W,{className:"rounded-(--rad-28) border-border/70",children:[(0,e.jsxs)(ye,{children:[(0,e.jsxs)(de,{className:"flex items-center gap-2",children:[(0,e.jsx)(Se,{className:"size-4"}),"Push notifications"]}),(0,e.jsx)(ve,{children:a?ze(u.data?.reasons??[]):"This browser cannot receive push notifications. On iPhone and iPad, add the board to the Home Screen first."})]}),a?(0,e.jsxs)(ue,{className:"space-y-2 text-sm",children:[(0,e.jsx)("p",{children:f?"On for this browser.":"Off for this browser."}),s.permission()==="denied"?(0,e.jsx)("p",{className:"text-muted-foreground",children:"Notifications are blocked for this site in the browser settings."}):null,l.data?(0,e.jsx)("p",{className:"text-muted-foreground",children:l.data.outcome==="delivered"?"Test notification sent.":"The push service refused the test notification."}):null,b?(0,e.jsx)("p",{role:"alert",className:"text-destructive",children:S(b,{action:"change push notifications"}).body}):null]}):null,a?(0,e.jsx)(re,{className:"justify-end gap-2",children:f?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(w,{variant:"outline",disabled:l.isPending,onClick:t(()=>l.mutate(),"onClick"),children:"Send a test"}),(0,e.jsx)(w,{variant:"outline",disabled:y,onClick:t(()=>h.mutate(),"onClick"),children:"Turn off"})]}):(0,e.jsx)(w,{disabled:y||s.permission()==="denied",onClick:t(()=>x.mutate(),"onClick"),children:"Turn on"})}):null]})}t(Fe,"PushNotificationsCard");function Ie(s){const i=s.trim().split(/\s+/).filter(Boolean);return i.length>=2?`${i[0]?.[0]??""}${i[i.length-1]?.[0]??""}`.toUpperCase():s.slice(0,2).toUpperCase()}t(Ie,"deriveInitials");function Oe(){const{setBreadcrumbs:s}=be(),{selectedCompanyId:i,selectedCompany:a}=ce(),u=$(),g=(0,p.useId)(),x=(0,p.useRef)(null),[h,l]=(0,p.useState)(null),[b,f]=(0,p.useState)(null),[y,r]=(0,p.useState)(null),c=I({queryKey:k.auth.session,queryFn:t(()=>B.getSession(),"queryFn")}),v=X(c),o=h??c.data?.user.name??"",m=b??c.data?.user.image??"";(0,p.useEffect)(()=>{s([{label:"Settings",href:"/company/settings"},{label:"Profile"}])},[s]),(0,p.useEffect)(()=>{l(null),f(null)},[c.data]);function se(n){u.setQueryData(k.auth.session,d=>d&&{...d,user:{...d.user,...n}})}t(se,"syncSessionProfile");async function L(n,d){d();const E=await B.updateProfile(n);return d(),se(E),E}t(L,"persistProfile");function R(){return o.trim()||c.data?.user.name||"Board"}t(R,"resolveProfileName");const A=T({mutationFn:t((n,{assertCurrentAccount:d})=>L(n,d),"mutationFn"),onSuccess:t(n=>{r(null),l(n.name??""),f(n.image??"")},"onSuccess"),onError:t(n=>{r(S(n).body)},"onError")}),C=T({mutationFn:t(async(n,{assertCurrentAccount:d})=>{if(!i)throw new Error("Select an organization before uploading a profile avatar.");const E=await le.uploadImage(i,n,`profiles/${c.data?.user.id??"board-user"}`);return L({name:R(),image:E.contentPath},d)},"mutationFn"),onSuccess:t(n=>{r(null),l(n.name??""),f(n.image??"")},"onSuccess"),onError:t(n=>{r(S(n).body)},"onError")}),q=T({mutationFn:t((n,{assertCurrentAccount:d})=>L({name:R(),image:null},d),"mutationFn"),onSuccess:t(n=>{r(null),l(n.name??""),f(n.image??"")},"onSuccess"),onError:t(n=>{r(S(n).body)},"onError")});if(c.isLoading||v.kind==="reconnecting")return(0,e.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading profile..."});if(v.kind==="error")return(0,e.jsx)(J,{size:"page",error:c.error,action:"load your profile",onRetry:v.retry,retrying:v.isFetching});if(!c.data)return(0,e.jsx)("div",{className:"text-sm text-destructive",children:"Failed to load profile."});const O=o.trim()||c.data.user.name||"Board",P=m.trim()||null,te=Ie(O),_=A.isPending||C.isPending||q.isPending,ae=a?`Stored in Microvac file storage for ${a.name}.`:"Select an organization to upload an avatar into Microvac storage.";return(0,e.jsxs)("div",{className:"min-w-0 max-w-6xl space-y-6",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(xe,{className:"h-5 w-5 text-muted-foreground"}),(0,e.jsx)("h1",{className:"text-lg font-semibold",children:"Profile"})]}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Control how your account appears in the sidebar and other board surfaces."})]}),y?(0,e.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:y}):null,(0,e.jsxs)("section",{className:"min-w-0 max-w-full space-y-8",children:[(0,e.jsxs)(W,{className:"block relative min-w-0 max-w-full overflow-hidden rounded-(--rad-28) border-border/70",children:[(0,e.jsx)("div",{className:"absolute inset-x-0 top-0 h-32 bg-(image:--gradient-extract-26)"}),(0,e.jsx)("div",{className:"absolute inset-0 bg-(image:--gradient-extract-7)"}),(0,e.jsx)("div",{className:"relative min-w-0 p-4 pt-8 sm:p-6 sm:pt-10",children:(0,e.jsxs)("div",{className:"flex min-w-0 flex-wrap items-end gap-5 rounded-(--rad-24) border border-border/70 bg-background/92 p-4 shadow-(--shadow-extract-18) backdrop-blur-sm sm:p-5",children:[(0,e.jsxs)("div",{className:"min-w-0 max-w-full space-y-3",children:[(0,e.jsxs)("label",{htmlFor:g,className:"group relative inline-block w-fit cursor-pointer rounded-full focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background",children:[(0,e.jsx)("input",{ref:x,id:g,type:"file",accept:"image/*",className:"sr-only",disabled:!i||_,onChange:t(n=>{const d=n.target.files?.[0];d&&(C.mutate(d),n.target.value="")},"onChange")}),(0,e.jsx)("span",{className:"absolute inset-0 z-10 rounded-full bg-black/0 transition-colors group-hover:bg-black/14 group-focus-within:bg-black/14"}),(0,e.jsx)("span",{className:"absolute bottom-1 right-1 z-20 flex size-9 items-center justify-center rounded-full border border-background bg-primary text-primary-foreground shadow-sm",children:C.isPending?(0,e.jsx)(N,{className:"size-4 animate-spin"}):(0,e.jsx)(Q,{className:"size-4"})}),(0,e.jsxs)(ge,{size:"lg",className:"data-[size=lg]:size-24 ring-4 ring-background shadow-xl",children:[P?(0,e.jsx)(pe,{src:P,alt:O}):null,(0,e.jsx)(oe,{children:te})]})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxs)(w,{type:"button",variant:"secondary",onClick:t(()=>x.current?.click(),"onClick"),disabled:!i||_,children:[C.isPending?(0,e.jsx)(N,{className:"size-4 animate-spin"}):(0,e.jsx)(Q,{className:"size-4"}),P?"Change photo":"Upload photo"]}),P?(0,e.jsxs)(w,{type:"button",variant:"outline",onClick:t(()=>q.mutate(),"onClick"),disabled:_,children:[q.isPending?(0,e.jsx)(N,{className:"size-4 animate-spin"}):(0,e.jsx)(fe,{className:"size-4"}),"Remove"]}):null]})]}),(0,e.jsxs)("div",{className:"min-w-0 flex-1 space-y-2 pb-1",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{className:"truncate text-2xl font-semibold text-foreground",children:O}),(0,e.jsx)("p",{className:"truncate text-sm text-muted-foreground",children:c.data.user.email??"No email"})]}),(0,e.jsxs)("p",{className:"max-w-2xl text-sm leading-6 text-muted-foreground",children:["Click the avatar to upload a new image. ",ae]})]})]})})]}),(0,e.jsxs)("form",{className:"grid min-w-0 gap-6 md:grid-cols-2",onSubmit:t(n=>{n.preventDefault(),A.mutate({name:R(),image:m.trim()||null})},"onSubmit"),children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-2",children:[(0,e.jsx)(D,{htmlFor:"profile-name",children:"Display name"}),(0,e.jsx)(K,{id:"profile-name",value:o,onChange:t(n=>l(n.target.value),"onChange"),maxLength:120,placeholder:"Board"}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Shown in the sidebar account footer and comment author surfaces."})]}),(0,e.jsxs)("div",{className:"min-w-0 space-y-2",children:[(0,e.jsx)(D,{htmlFor:"profile-email",children:"Email"}),(0,e.jsx)(K,{id:"profile-email",value:c.data.user.email??"",readOnly:!0,disabled:!0}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Email is managed by your auth session and is read-only here."})]}),(0,e.jsx)("div",{className:"md:col-span-2 flex justify-end",children:(0,e.jsxs)(w,{type:"submit",disabled:_||!o.trim(),children:[A.isPending?(0,e.jsx)(N,{className:"size-4 animate-spin"}):(0,e.jsx)(Y,{className:"size-4"}),A.isPending?"Saving...":"Save profile"]})})]}),(0,e.jsx)(Ce,{companyId:i}),(0,e.jsx)(Fe,{})]})]})}t(Oe,"ProfileSettings");export{Oe as ProfileSettings};
1
+ var ne=Object.defineProperty;var t=(s,i)=>ne(s,"name",{value:i,configurable:!0});import{a as V}from"./rolldown-runtime-DhZMWcEn.js";import{$A as ie,A_ as re,E_ as W,Fb as oe,Fd as le,GS as k,Hb as T,LC as Y,LS as ce,ME as $,M_ as de,NE as w,O_ as ue,Ow as me,Pb as ge,QT as G,Rb as pe,YS as B,__ as K,_w as N,ab as J,bE as F,bp as he,dC as xe,gC as fe,hE as S,ib as be,j_ as ye,k_ as ve,m_ as we,nj as je,op as D,rb as Ne,uE as j,ub as X,xE as I,yp as ke}from"./index-BJtnP7H1.js";var Z={name:"bell-ring",size:24,node:[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]]};Z.node;var Se=G(Z),ee={name:"camera",size:24,node:[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]};ee.node;var Q=G(ee),p=V(je(),1),U={getMine:t(s=>j.get(`/companies/${s}/users/me/inbox-agent-policy`),"getMine"),updateMine:t((s,i)=>j.put(`/companies/${s}/users/me/inbox-agent-policy`,i),"updateMine")},e=V(ie(),1),Ae=[{value:"open",title:"Any of my agents",description:"Let any agent you manage archive tasks out of your inbox."},{value:"allowlist",title:"Only chosen agents",description:"Restrict inbox tidying to the agents you pick below."},{value:"disabled",title:"Off",description:"Agents can never archive tasks from your inbox."}];function M(s,i){return`${s}:${[...i].sort().join(",")}`}t(M,"policyKey");function Ce({companyId:s}){const i=$(),[a,u]=(0,p.useState)(null),g=(0,p.useRef)(null),x=I({queryKey:s?k.inboxAgentPolicy.mine(s):["inbox-agent-policy","none"],queryFn:t(()=>U.getMine(s),"queryFn"),enabled:!!s}),h=X(x),l=x.data,b=I({queryKey:s?k.agents.list(s):["agents","none"],queryFn:t(()=>Ne.list(s),"queryFn"),enabled:!!s}),f=(0,p.useMemo)(()=>(b.data??[]).filter(we),[b.data]),y=(0,p.useMemo)(()=>f.map(o=>({id:o.id,name:o.name,title:o.title??o.role,icon:o.icon})),[f]),r=(0,p.useMemo)(()=>new Set(a?.allowedAgentIds??[]),[a?.allowedAgentIds]);(0,p.useEffect)(()=>{if(!l)return;const o=M(l.mode,l.allowedAgentIds);u(m=>m===null||M(m.mode,m.allowedAgentIds)===g.current?{mode:l.mode,allowedAgentIds:l.allowedAgentIds}:m),g.current=o},[l]);const c=F({mutationFn:t(o=>U.updateMine(s,{mode:o.mode,allowedAgentIds:o.mode==="allowlist"?o.allowedAgentIds:[]}),"mutationFn"),onSuccess:t(o=>{i.setQueryData(k.inboxAgentPolicy.mine(s),o)},"onSuccess")}),v=!!(a&&l&&M(a.mode,a.allowedAgentIds)!==M(l.mode,l.allowedAgentIds));return h.kind==="error"?(0,e.jsx)(J,{error:h.error,action:"load the inbox agent policy",onRetry:h.retry,retrying:h.isFetching}):x.isLoading||h.kind==="reconnecting"||!a?(0,e.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading inbox agent policy…"}):(0,e.jsxs)("section",{className:"space-y-4","aria-label":"Let agents tidy my inbox",children:[(0,e.jsxs)("div",{className:"space-y-1",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:"Let agents tidy my inbox"})]}),(0,e.jsx)("p",{className:"max-w-2xl text-sm text-muted-foreground",children:"Choose whether the agents you manage may archive tasks out of your inbox on your behalf. You can undo any archive, and every agent archive is attributed in the task's properties."})]}),(0,e.jsx)(ke,{ariaLabel:"Inbox agent archiving policy",value:a.mode,onValueChange:t(o=>u(m=>m&&{...m,mode:o}),"onValueChange"),options:Ae,className:"max-w-2xl"}),a.mode==="allowlist"?(0,e.jsxs)("div",{className:"max-w-2xl space-y-2",children:[(0,e.jsx)("div",{className:"text-sm font-medium",children:"Agents allowed to tidy my inbox"}),(0,e.jsx)(he,{agents:y,selectedAgentIds:r,onChange:t(o=>u(m=>m&&{...m,allowedAgentIds:[...o]}),"onChange"),triggerLabel:r.size===0?"Select agents":`${r.size} ${r.size===1?"agent":"agents"} selected`,triggerFullWidth:!1,showSelectionPreview:!1,emptyMessage:"You don’t manage any agents yet."})]}):null,c.error?(0,e.jsx)("div",{role:"alert",className:"max-w-2xl rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:S(c.error,{action:"save the inbox agent policy"}).body}):null,(0,e.jsxs)("div",{className:"flex max-w-2xl items-center justify-end gap-3",children:[c.isSuccess&&!v?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",role:"status",children:"Saved"}):null,(0,e.jsxs)(w,{type:"button",disabled:!v||c.isPending,onClick:t(()=>a&&c.mutate(a),"onClick"),children:[c.isPending?(0,e.jsx)(N,{className:"size-4 animate-spin"}):(0,e.jsx)(Y,{className:"size-4"}),c.isPending?"Saving…":"Save"]})]})]})}t(Ce,"InboxAgentPolicyControl");var z={status:t(s=>j.get(`/microvac/push${s?`?endpoint=${encodeURIComponent(s)}`:""}`),"status"),subscribe:t(s=>j.post("/microvac/push/subscriptions",s),"subscribe"),unsubscribe:t(s=>j.delete("/microvac/push/subscriptions",{endpoint:s}),"unsubscribe"),test:t(s=>j.post("/microvac/push/test",{endpoint:s}),"test")};function Pe(s){const i=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(s.length/4)*4,"="),a=atob(i),u=new Uint8Array(new ArrayBuffer(a.length));for(let g=0;g<a.length;g+=1)u[g]=a.charCodeAt(g);return u}t(Pe,"keyBytes");async function _e(){if(!await navigator.serviceWorker.getRegistration())throw new Error("The service worker is not installed; reload the page and try again.");return navigator.serviceWorker.ready}t(_e,"registration");var Ee={supported:t(()=>typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window,"supported"),permission:t(()=>Notification.permission,"permission"),async current(){const s=await navigator.serviceWorker.getRegistration();return s?s.pushManager.getSubscription():null},async subscribe(s){if(await Notification.requestPermission()!=="granted")throw new Error("Notifications are blocked for this site in the browser settings.");const i=await _e(),a=(await i.pushManager.getSubscription()??await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Pe(s)})).toJSON();if(!a.endpoint||!a.keys?.p256dh||!a.keys.auth)throw new Error("The browser returned an incomplete subscription.");return{endpoint:a.endpoint,keys:{p256dh:a.keys.p256dh,auth:a.keys.auth}}}},H=["microvac","push"],Me={awaiting_human_answer:"an agent asks you a question",agent_failed:"an agent run fails",blocked_by_child:"a subtask blocks its parent"};function ze(s){const i=s.map(a=>Me[a]??a.replace(/_/g," "));return i.length===0?"No event sends notifications yet; an instance admin chooses them in the Cordis plugin settings.":`This device is notified when ${i.join(", or when ")}.`}t(ze,"describeReasons");function Fe({browser:s=Ee}){const i=$(),a=s.supported(),u=I({queryKey:H,enabled:a,queryFn:t(async()=>{const r=await s.current();return z.status(r?.endpoint??null)},"queryFn")}),g=t(()=>i.invalidateQueries({queryKey:H}),"refresh"),x=F({mutationFn:t(async()=>{const r=u.data?.publicKey;if(!r)throw new Error("Push notifications are off on this instance.");await z.subscribe(await s.subscribe(r))},"mutationFn"),onSettled:g}),h=F({mutationFn:t(async()=>{const r=await s.current();r&&(await z.unsubscribe(r.endpoint),await r.unsubscribe())},"mutationFn"),onSettled:g}),l=F({mutationFn:t(async()=>{const r=await s.current();if(!r)throw new Error("This browser is not subscribed.");return z.test(r.endpoint)},"mutationFn")});if(a&&(u.isLoading||u.data?.enabled===!1))return null;const b=u.error??x.error??h.error??l.error,f=u.data?.subscribed===!0,y=x.isPending||h.isPending;return(0,e.jsxs)(W,{className:"rounded-(--rad-28) border-border/70",children:[(0,e.jsxs)(ye,{children:[(0,e.jsxs)(de,{className:"flex items-center gap-2",children:[(0,e.jsx)(Se,{className:"size-4"}),"Push notifications"]}),(0,e.jsx)(ve,{children:a?ze(u.data?.reasons??[]):"This browser cannot receive push notifications. On iPhone and iPad, add the board to the Home Screen first."})]}),a?(0,e.jsxs)(ue,{className:"space-y-2 text-sm",children:[(0,e.jsx)("p",{children:f?"On for this browser.":"Off for this browser."}),s.permission()==="denied"?(0,e.jsx)("p",{className:"text-muted-foreground",children:"Notifications are blocked for this site in the browser settings."}):null,l.data?(0,e.jsx)("p",{className:"text-muted-foreground",children:l.data.outcome==="delivered"?"Test notification sent.":"The push service refused the test notification."}):null,b?(0,e.jsx)("p",{role:"alert",className:"text-destructive",children:S(b,{action:"change push notifications"}).body}):null]}):null,a?(0,e.jsx)(re,{className:"justify-end gap-2",children:f?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(w,{variant:"outline",disabled:l.isPending,onClick:t(()=>l.mutate(),"onClick"),children:"Send a test"}),(0,e.jsx)(w,{variant:"outline",disabled:y,onClick:t(()=>h.mutate(),"onClick"),children:"Turn off"})]}):(0,e.jsx)(w,{disabled:y||s.permission()==="denied",onClick:t(()=>x.mutate(),"onClick"),children:"Turn on"})}):null]})}t(Fe,"PushNotificationsCard");function Ie(s){const i=s.trim().split(/\s+/).filter(Boolean);return i.length>=2?`${i[0]?.[0]??""}${i[i.length-1]?.[0]??""}`.toUpperCase():s.slice(0,2).toUpperCase()}t(Ie,"deriveInitials");function Oe(){const{setBreadcrumbs:s}=be(),{selectedCompanyId:i,selectedCompany:a}=ce(),u=$(),g=(0,p.useId)(),x=(0,p.useRef)(null),[h,l]=(0,p.useState)(null),[b,f]=(0,p.useState)(null),[y,r]=(0,p.useState)(null),c=I({queryKey:k.auth.session,queryFn:t(()=>B.getSession(),"queryFn")}),v=X(c),o=h??c.data?.user.name??"",m=b??c.data?.user.image??"";(0,p.useEffect)(()=>{s([{label:"Settings",href:"/company/settings"},{label:"Profile"}])},[s]),(0,p.useEffect)(()=>{l(null),f(null)},[c.data]);function se(n){u.setQueryData(k.auth.session,d=>d&&{...d,user:{...d.user,...n}})}t(se,"syncSessionProfile");async function L(n,d){d();const E=await B.updateProfile(n);return d(),se(E),E}t(L,"persistProfile");function R(){return o.trim()||c.data?.user.name||"Board"}t(R,"resolveProfileName");const A=T({mutationFn:t((n,{assertCurrentAccount:d})=>L(n,d),"mutationFn"),onSuccess:t(n=>{r(null),l(n.name??""),f(n.image??"")},"onSuccess"),onError:t(n=>{r(S(n).body)},"onError")}),C=T({mutationFn:t(async(n,{assertCurrentAccount:d})=>{if(!i)throw new Error("Select an organization before uploading a profile avatar.");const E=await le.uploadImage(i,n,`profiles/${c.data?.user.id??"board-user"}`);return L({name:R(),image:E.contentPath},d)},"mutationFn"),onSuccess:t(n=>{r(null),l(n.name??""),f(n.image??"")},"onSuccess"),onError:t(n=>{r(S(n).body)},"onError")}),q=T({mutationFn:t((n,{assertCurrentAccount:d})=>L({name:R(),image:null},d),"mutationFn"),onSuccess:t(n=>{r(null),l(n.name??""),f(n.image??"")},"onSuccess"),onError:t(n=>{r(S(n).body)},"onError")});if(c.isLoading||v.kind==="reconnecting")return(0,e.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading profile..."});if(v.kind==="error")return(0,e.jsx)(J,{size:"page",error:c.error,action:"load your profile",onRetry:v.retry,retrying:v.isFetching});if(!c.data)return(0,e.jsx)("div",{className:"text-sm text-destructive",children:"Failed to load profile."});const O=o.trim()||c.data.user.name||"Board",P=m.trim()||null,te=Ie(O),_=A.isPending||C.isPending||q.isPending,ae=a?`Stored in Microvac file storage for ${a.name}.`:"Select an organization to upload an avatar into Microvac storage.";return(0,e.jsxs)("div",{className:"min-w-0 max-w-6xl space-y-6",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(xe,{className:"h-5 w-5 text-muted-foreground"}),(0,e.jsx)("h1",{className:"text-lg font-semibold",children:"Profile"})]}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Control how your account appears in the sidebar and other board surfaces."})]}),y?(0,e.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:y}):null,(0,e.jsxs)("section",{className:"min-w-0 max-w-full space-y-8",children:[(0,e.jsxs)(W,{className:"block relative min-w-0 max-w-full overflow-hidden rounded-(--rad-28) border-border/70",children:[(0,e.jsx)("div",{className:"absolute inset-x-0 top-0 h-32 bg-(image:--gradient-extract-26)"}),(0,e.jsx)("div",{className:"absolute inset-0 bg-(image:--gradient-extract-7)"}),(0,e.jsx)("div",{className:"relative min-w-0 p-4 pt-8 sm:p-6 sm:pt-10",children:(0,e.jsxs)("div",{className:"flex min-w-0 flex-wrap items-end gap-5 rounded-(--rad-24) border border-border/70 bg-background/92 p-4 shadow-(--shadow-extract-18) backdrop-blur-sm sm:p-5",children:[(0,e.jsxs)("div",{className:"min-w-0 max-w-full space-y-3",children:[(0,e.jsxs)("label",{htmlFor:g,className:"group relative inline-block w-fit cursor-pointer rounded-full focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background",children:[(0,e.jsx)("input",{ref:x,id:g,type:"file",accept:"image/*",className:"sr-only",disabled:!i||_,onChange:t(n=>{const d=n.target.files?.[0];d&&(C.mutate(d),n.target.value="")},"onChange")}),(0,e.jsx)("span",{className:"absolute inset-0 z-10 rounded-full bg-black/0 transition-colors group-hover:bg-black/14 group-focus-within:bg-black/14"}),(0,e.jsx)("span",{className:"absolute bottom-1 right-1 z-20 flex size-9 items-center justify-center rounded-full border border-background bg-primary text-primary-foreground shadow-sm",children:C.isPending?(0,e.jsx)(N,{className:"size-4 animate-spin"}):(0,e.jsx)(Q,{className:"size-4"})}),(0,e.jsxs)(ge,{size:"lg",className:"data-[size=lg]:size-24 ring-4 ring-background shadow-xl",children:[P?(0,e.jsx)(pe,{src:P,alt:O}):null,(0,e.jsx)(oe,{children:te})]})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxs)(w,{type:"button",variant:"secondary",onClick:t(()=>x.current?.click(),"onClick"),disabled:!i||_,children:[C.isPending?(0,e.jsx)(N,{className:"size-4 animate-spin"}):(0,e.jsx)(Q,{className:"size-4"}),P?"Change photo":"Upload photo"]}),P?(0,e.jsxs)(w,{type:"button",variant:"outline",onClick:t(()=>q.mutate(),"onClick"),disabled:_,children:[q.isPending?(0,e.jsx)(N,{className:"size-4 animate-spin"}):(0,e.jsx)(fe,{className:"size-4"}),"Remove"]}):null]})]}),(0,e.jsxs)("div",{className:"min-w-0 flex-1 space-y-2 pb-1",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{className:"truncate text-2xl font-semibold text-foreground",children:O}),(0,e.jsx)("p",{className:"truncate text-sm text-muted-foreground",children:c.data.user.email??"No email"})]}),(0,e.jsxs)("p",{className:"max-w-2xl text-sm leading-6 text-muted-foreground",children:["Click the avatar to upload a new image. ",ae]})]})]})})]}),(0,e.jsxs)("form",{className:"grid min-w-0 gap-6 md:grid-cols-2",onSubmit:t(n=>{n.preventDefault(),A.mutate({name:R(),image:m.trim()||null})},"onSubmit"),children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-2",children:[(0,e.jsx)(D,{htmlFor:"profile-name",children:"Display name"}),(0,e.jsx)(K,{id:"profile-name",value:o,onChange:t(n=>l(n.target.value),"onChange"),maxLength:120,placeholder:"Board"}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Shown in the sidebar account footer and comment author surfaces."})]}),(0,e.jsxs)("div",{className:"min-w-0 space-y-2",children:[(0,e.jsx)(D,{htmlFor:"profile-email",children:"Email"}),(0,e.jsx)(K,{id:"profile-email",value:c.data.user.email??"",readOnly:!0,disabled:!0}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Email is managed by your auth session and is read-only here."})]}),(0,e.jsx)("div",{className:"md:col-span-2 flex justify-end",children:(0,e.jsxs)(w,{type:"submit",disabled:_||!o.trim(),children:[A.isPending?(0,e.jsx)(N,{className:"size-4 animate-spin"}):(0,e.jsx)(Y,{className:"size-4"}),A.isPending?"Saving...":"Save profile"]})})]}),(0,e.jsx)(Ce,{companyId:i}),(0,e.jsx)(Fe,{})]})]})}t(Oe,"ProfileSettings");export{Oe as ProfileSettings};
@@ -1 +1 @@
1
- var Be=Object.defineProperty;var a=(t,n)=>Be(t,"name",{value:n,configurable:!0});import{a as Ae}from"./rolldown-runtime-DhZMWcEn.js";import{li as ze}from"./issue-detail-4PCbYpdv.js";import{$A as Fe,Ap as L,B_ as ee,GS as be,Gb as Oe,H_ as Ie,IC as qe,Jp as T,LS as Ve,ME as Ue,MT as We,NE as P,Np as Y,Op as Q,Pp as H,Sp as ve,V_ as te,Yb as Ge,__ as K,_w as J,aE as Ye,bE as ye,bp as Qe,g_ as He,iC as Je,ib as Xe,jT as M,kT as Ze,kp as X,nj as et,oE as tt,op as Z,qC as st,sv as at,vi as nt,zE as _,z_ as se}from"./index-Bt31d8ga.js";import{i as Pe}from"./shared-CIwISWMj.js";import{a as rt,c as lt,d as ot,f as it,i as _e,l as dt,m as Ee,n as ct,o as mt,p as ut,r as Le,s as Ne,u as we}from"./useProfilesData-0VYQ4lAT.js";import{t as pt}from"./ToolsAdminGate-CEr0zy2T.js";var u=Ae(et(),1),e=Ae(Fe(),1),xt=["read","write","destructive"],ft={read:"outline",write:"secondary",destructive:"destructive"};function ht(t){const{appGroups:n,catalogLoading:l,selections:o,onSelectionsChange:c}=t,[x,g]=(0,u.useState)(""),[p,s]=(0,u.useState)(null),f=(0,u.useMemo)(()=>{const d=x.trim().toLowerCase();return n.map(i=>({group:i,tools:i.tools.filter(h=>p&&Ee(h)!==p?!1:d?h.toolName.toLowerCase().includes(d)||(h.title??"").toLowerCase().includes(d)||i.name.toLowerCase().includes(d):!0)})).filter(i=>i.tools.length>0)},[n,x,p]);return l?(0,e.jsx)(Pe,{label:"Loading tools…"}):n.length===0?(0,e.jsxs)("div",{className:"flex flex-col items-center gap-3 rounded-lg border border-dashed border-border py-12 text-center",children:[(0,e.jsx)(ze,{className:"h-6 w-6 text-muted-foreground"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-medium text-foreground",children:"App connections are coming soon"}),(0,e.jsx)("p",{className:"mx-auto max-w-sm text-sm text-muted-foreground",children:"Profiles will be available once app connections are ready. Browse the planned integrations in the meantime."})]}),(0,e.jsx)(P,{asChild:!0,variant:"outline",children:(0,e.jsx)(Oe,{to:"/apps",children:"Browse app connections"})})]}):(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxs)("div",{className:"relative min-w-(--sz-220px) flex-1",children:[(0,e.jsx)(qe,{className:"pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),(0,e.jsx)(K,{value:x,onChange:a(d=>g(d.target.value),"onChange"),placeholder:"Search tools…",className:"pl-8"})]}),(0,e.jsx)("div",{className:"flex items-center gap-1.5",children:xt.map(d=>(0,e.jsx)("button",{type:"button",onClick:a(()=>s(i=>i===d?null:d),"onClick"),className:_("rounded-full border px-2.5 py-1 text-xs font-medium transition-colors",p===d?"border-primary bg-primary/10 text-primary":"border-border text-muted-foreground hover:bg-accent"),children:Le[d]},d))})]}),f.length===0?(0,e.jsxs)("div",{className:"flex flex-col items-center gap-2 rounded-lg border border-dashed border-border py-10 text-center",children:[(0,e.jsxs)("p",{className:"text-sm font-medium text-foreground",children:["No tools match “",x,"”."]}),(0,e.jsx)("button",{type:"button",onClick:a(()=>{g(""),s(null)},"onClick"),className:"text-sm font-medium text-primary hover:underline",children:"Clear search"})]}):(0,e.jsx)("div",{className:"divide-y divide-border overflow-hidden rounded-lg border border-border",children:f.map(({group:d,tools:i})=>(0,e.jsx)(gt,{group:d,visibleTools:i,selection:o[d.appKey],onToggleApp:a(()=>c({...o,[d.appKey]:it(d,o[d.appKey])}),"onToggleApp"),onToggleTool:a(h=>c({...o,[d.appKey]:ut(d,o[d.appKey],h)}),"onToggleTool")},d.appKey))}),(0,e.jsx)(jt,{value:t.newToolsAction,onChange:t.onNewToolsActionChange}),(0,e.jsx)(Nt,{rules:t.advancedRules,onChange:t.onAdvancedRulesChange})]})}a(ht,"WizardToolsStep");function gt({group:t,visibleTools:n,selection:l,onToggleApp:o,onToggleTool:c}){const[x,g]=(0,u.useState)(!1),p=rt(t,l);return(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[(0,e.jsx)(ve,{checked:p==="checked"?!0:p==="indeterminate"?"indeterminate":!1,onCheckedChange:o,"aria-label":`All ${t.name} tools`}),(0,e.jsxs)("button",{type:"button",onClick:a(()=>g(s=>!s),"onClick"),className:"flex flex-1 items-center gap-1.5 text-left",children:[x?(0,e.jsx)(M,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):(0,e.jsx)(Ze,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,e.jsxs)("span",{className:"flex flex-col",children:[(0,e.jsxs)("span",{className:"text-sm font-medium text-foreground",children:["All ",t.name," tools (",t.tools.length,")"]}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:p==="indeterminate"?mt(t,l):"includes tools "+t.name+" adds later"})]})]})]}),x?(0,e.jsx)("div",{className:"space-y-0.5 border-t border-border bg-muted/20 px-3 py-2 pl-10",children:n.map(s=>{const f=Ee(s);return(0,e.jsxs)("label",{className:"flex cursor-pointer items-start gap-2.5 rounded-md px-1.5 py-1.5 hover:bg-accent/50",children:[(0,e.jsx)(ve,{className:"mt-0.5",checked:dt(t,l,s.id),onCheckedChange:a(()=>c(s.id),"onCheckedChange")}),(0,e.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[(0,e.jsxs)("span",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("code",{className:"font-mono text-xs text-foreground",children:s.toolName}),(0,e.jsx)(Ie,{variant:ft[f],className:"text-(length:--text-nano)",children:Le[f]})]}),s.title||s.description?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:s.title??s.description}):null]})]},s.id)})}):null]})}a(gt,"AppRow");function jt({value:t,onChange:n}){return(0,e.jsxs)("fieldset",{className:"space-y-2 rounded-lg border border-border p-4",children:[(0,e.jsx)("legend",{className:"px-1 text-sm font-medium text-foreground",children:"New tools that appear later"}),(0,e.jsx)("div",{className:"space-y-2",children:[{value:"deny",label:"Stay blocked until someone allows them",hint:"New tools an app adds later won't be usable until you review them.",recommended:!0},{value:"allow",label:"Allowed automatically",hint:"Any tool an app adds later becomes usable right away."}].map(l=>(0,e.jsxs)("label",{className:"flex cursor-pointer items-start gap-2.5",children:[(0,e.jsx)("input",{type:"radio",name:"new-tools-action",className:"mt-0.5",checked:t===l.value,onChange:a(()=>n(l.value),"onChange")}),(0,e.jsxs)("span",{className:"flex flex-col gap-0.5",children:[(0,e.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[l.label,l.recommended?(0,e.jsx)(Ie,{variant:"outline",className:"text-(length:--text-nano)",children:"Recommended"}):(0,e.jsx)("span",{className:"text-xs font-normal text-amber-600",children:"(risky)"})]}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:l.hint})]})]},l.value))})]})}a(jt,"NewToolsRadio");var bt=[{value:"tool_name",label:"Tool name pattern"},{value:"risk_level",label:"Risk level"},{value:"catalog_entry",label:"By tool ID"}];function vt(){const t=globalThis.crypto?.randomUUID?.();return t||`rule-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}a(vt,"createAdvancedRuleId");function yt(t){const n=t.effect==="include"?"Allow":"Block";return t.kind==="tool_name"?`${n} tools matching ${t.value}`:t.kind==="risk_level"?`${n} ${t.riskLevel??t.value} tools`:`${n} tool ${t.value}`}a(yt,"ruleSummary");function Nt({rules:t,onChange:n}){const[l,o]=(0,u.useState)(!1),[c,x]=(0,u.useState)("tool_name"),[g,p]=(0,u.useState)(""),[s,f]=(0,u.useState)("include"),d=a(()=>{const i=g.trim();if(!i&&c!=="risk_level")return;const h={id:vt(),kind:c,value:c==="risk_level"?i||"destructive":i,riskLevel:c==="risk_level"?i||"destructive":void 0,effect:s};n([...t,h]),p("")},"addRule");return(0,e.jsxs)(se,{open:l,onOpenChange:o,className:"rounded-lg border border-border",children:[(0,e.jsxs)(te,{className:"flex w-full items-center justify-between px-4 py-3 text-left",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-foreground",children:"Advanced rules"}),(0,e.jsx)(M,{className:_("h-4 w-4 text-muted-foreground transition-transform",l&&"rotate-180")})]}),(0,e.jsxs)(ee,{className:"space-y-3 border-t border-border px-4 py-3",children:[(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Match tools by a name pattern, a risk level, or a specific tool ID. These run on top of the choices above."}),t.length>0?(0,e.jsx)("ul",{className:"space-y-1.5",children:t.map(i=>(0,e.jsxs)("li",{className:"flex items-center justify-between gap-2 rounded-md border border-border bg-muted/30 px-3 py-1.5 text-sm",children:[(0,e.jsx)("span",{className:"text-foreground",children:yt(i)}),(0,e.jsx)("button",{type:"button","aria-label":"Remove rule",onClick:a(()=>n(t.filter(h=>h.id!==i.id)),"onClick"),className:"text-muted-foreground hover:text-destructive",children:(0,e.jsx)(Je,{className:"h-4 w-4"})})]},i.id))}):null,(0,e.jsxs)("div",{className:"flex flex-wrap items-end gap-2",children:[(0,e.jsxs)(Q,{value:s,onValueChange:a(i=>f(i),"onValueChange"),children:[(0,e.jsx)(Y,{className:"w-28",children:(0,e.jsx)(H,{})}),(0,e.jsxs)(X,{children:[(0,e.jsx)(L,{value:"include",children:"Allow"}),(0,e.jsx)(L,{value:"exclude",children:"Block"})]})]}),(0,e.jsxs)(Q,{value:c,onValueChange:a(i=>x(i),"onValueChange"),children:[(0,e.jsx)(Y,{className:"w-40",children:(0,e.jsx)(H,{})}),(0,e.jsx)(X,{children:bt.map(i=>(0,e.jsx)(L,{value:i.value,children:i.label},i.value))})]}),c==="risk_level"?(0,e.jsxs)(Q,{value:g||"destructive",onValueChange:p,children:[(0,e.jsx)(Y,{className:"w-36",children:(0,e.jsx)(H,{})}),(0,e.jsxs)(X,{children:[(0,e.jsx)(L,{value:"read",children:"Read-only"}),(0,e.jsx)(L,{value:"write",children:"Makes changes"}),(0,e.jsx)(L,{value:"destructive",children:"Destructive"})]})]}):(0,e.jsx)(K,{value:g,onChange:a(i=>p(i.target.value),"onChange"),placeholder:c==="tool_name"?"e.g. gmail.send*":"tool ID",className:"w-44"}),(0,e.jsxs)(P,{type:"button",variant:"outline",size:"sm",onClick:d,children:[(0,e.jsx)(st,{className:"mr-1 h-3.5 w-3.5"}),"Add rule"]})]})]})]})}a(Nt,"AdvancedRules");var $e="wizard";function wt(t){const n=t?.metadata?.[$e];if(!n||typeof n!="object")return null;const l=n,o=l.lastCompletedStep;return o!==1&&o!==2&&o!==3?null:{lastCompletedStep:o,template:typeof l.template=="string"?l.template:null}}a(wt,"readWizardMeta");function Se(t,n){return{...t??{},[$e]:n}}a(Se,"withWizardMeta");function St(t){return t?Math.min(t.lastCompletedStep+1,3):1}a(St,"resumeStep");function Ce(t){return t.trim().toLowerCase().replace(/[^a-z0-9._:-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,160)}a(Ce,"slugifyProfileKey");var ke=[{step:1,label:"Name"},{step:2,label:"Choose tools"},{step:3,label:"Assign"}];function Ct({companyId:t,profileId:n,initialTemplate:l,initialStep:o}){const c=Ge(),x=Ue(),{pushToast:g}=at(),p=ct(t),{appGroups:s,catalog:f,profiles:d,agents:i}=p,h=d.data?.profiles??[],m=n?h.find(r=>r.id===n)??null:null,[b,A]=(0,u.useState)(1),[j,v]=(0,u.useState)(n??null),[y,$]=(0,u.useState)(l??null),[R,Re]=(0,u.useState)(null),[I,ae]=(0,u.useState)(""),[B,ne]=(0,u.useState)(""),[z,F]=(0,u.useState)(""),[re,le]=(0,u.useState)(!1),[E,O]=(0,u.useState)({}),[q,oe]=(0,u.useState)([]),[k,ie]=(0,u.useState)("deny"),[V,de]=(0,u.useState)(new Set),[ce,me]=(0,u.useState)(new Set),[ue,pe]=(0,u.useState)(new Set),[U,xe]=(0,u.useState)(!1),W=a(r=>N=>r(w=>{const S=new Set(w);return S.has(N)?S.delete(N):S.add(N),S}),"toggleIn"),fe=(0,u.useRef)(!1);(0,u.useEffect)(()=>{if(fe.current||!m||s.length===0||m.id!==n)return;fe.current=!0,ae(m.name),ne(m.description??""),F(m.profileKey),le(!0),ie(m.defaultAction);const r=we(s,m.entries);O(r.selections),oe(r.advancedRules);const N=wt(m);$(N?.template??null),A(o??(m.status==="draft"?St(N):1));const w=a(S=>new Set(m.bindings.filter(G=>G.targetType===S).map(G=>G.targetId)),"targetIds");de(w("agent")),me(w("project")),pe(w("routine")),xe(m.bindings.some(S=>S.targetType==="company"))},[m,s,n,o]),(0,u.useEffect)(()=>{re||F(Ce(I))},[I,re]);const he=a(()=>{x.invalidateQueries({queryKey:be.tools.profiles(t)}),x.invalidateQueries({queryKey:be.tools.testAgentAccesses()})},"invalidate"),ge=(0,u.useMemo)(()=>lt(s,E,k,f.length),[s,E,k,f.length]),De=a(()=>{if(y==="copy"&&R){const r=h.find(N=>N.id===R);if(r)return we(s,r.entries).selections}return y&&y!=="copy"?ot(y,s):E},"seedSelections"),D=ye({mutationFn:a(async r=>{const N=r.seed??E,w=Ne(s,N,q,k),S=Se(m?.metadata??null,{lastCompletedStep:r.completedStep,template:y});return j?{created:await T.updateProfile(j,{profileKey:z||void 0,name:I.trim()||"Untitled profile",description:B.trim()||null,defaultAction:k,entries:w,metadata:S}),goToStep:r.goToStep,seed:r.seed}:{created:await T.createProfile(t,{profileKey:z||Ce(I)||"profile",name:I.trim()||"Untitled profile",description:B.trim()||null,status:"draft",defaultAction:k,entries:w,metadata:S}),goToStep:r.goToStep,seed:r.seed}},"mutationFn"),onSuccess:a(({created:r,goToStep:N,seed:w})=>{v(r.id),w&&O(w),A(N),he()},"onSuccess"),onError:a(r=>g({title:"Could not save",body:String(r?.message??r),tone:"error"}),"onError")}),je=ye({mutationFn:a(async()=>{if(!j)throw new Error("No draft to finish");const r=Ne(s,E,q,k);return await kt(t,await T.updateProfile(j,{defaultAction:k,entries:r,metadata:Se(m?.metadata??null,{lastCompletedStep:3,template:y})}),{agentIds:[...V],projectIds:[...ce],routineIds:[...ue],companyDefault:U}),T.updateProfile(j,{status:"active"})},"mutationFn"),onSuccess:a(r=>{g({title:"Profile saved",tone:"success"}),he(),c(`/apps/advanced/profiles/${r.id}${V.size===0&&!U?"?created=1":""}`)},"onSuccess"),onError:a(r=>g({title:"Could not save profile",body:String(r?.message??r),tone:"error"}),"onError")}),Ke=a(()=>{const r=b;D.mutate({goToStep:b,completedStep:r},{onSuccess:a(()=>{g({title:"Draft saved",body:"Pick it back up from the profiles list.",tone:"success"}),c("/apps/advanced/profiles")},"onSuccess")})},"saveAndExit"),C=D.isPending||je.isPending,Me=I.trim().length>0&&(y!=="copy"||!!R);return n&&d.isLoading?(0,e.jsx)(Pe,{label:"Loading draft…"}):(0,e.jsxs)("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-6 pb-36 md:pb-24",children:[(0,e.jsx)(Tt,{current:b}),(0,e.jsxs)("div",{className:"min-h-(--sz-320px)",children:[b===1?(0,e.jsx)(At,{template:y,onTemplate:$,copyFromId:R,onCopyFrom:Re,copyOptions:h.filter(r=>r.status!=="archived"&&r.id!==n),name:I,onName:ae,description:B,onDescription:ne,profileKey:z,onProfileKey:a(r=>{le(!0),F(r)},"onProfileKey")}):null,b===2?(0,e.jsx)(ht,{appGroups:s,catalogLoading:p.catalogLoading,selections:E,onSelectionsChange:O,advancedRules:q,onAdvancedRulesChange:oe,newToolsAction:k,onNewToolsActionChange:ie}):null,b===3?(0,e.jsx)(It,{agents:(i.data??[]).map(r=>({id:r.id,name:r.name,title:r.title,icon:r.icon})),projects:(p.projects.data??[]).map(r=>({id:r.id,name:r.name})),routines:(p.routines.data??[]).map(r=>({id:r.id,name:r.title})),profiles:h,selectedAgentIds:V,onToggleAgent:W(de),selectedProjectIds:ce,onToggleProject:W(me),selectedRoutineIds:ue,onToggleRoutine:W(pe),companyDefault:U,onCompanyDefault:xe}):null]}),(0,e.jsx)("div",{className:"mobile-nav-composer fixed inset-x-0 bottom-(--tc-composer-bottom) z-20 border-t border-border bg-background/95 backdrop-blur md:bottom-0",children:(0,e.jsxs)("div",{className:"mx-auto flex w-full max-w-3xl flex-wrap items-center justify-between gap-3 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[b>=2?(0,e.jsxs)("span",{children:["Allows ",(0,e.jsx)("span",{className:"font-medium text-foreground",children:ge.allowed})," of ",ge.total," ","tools"]}):null,j?(0,e.jsx)("button",{type:"button",onClick:Ke,disabled:C,className:"font-medium text-primary hover:underline disabled:opacity-50",children:"Save & finish later"}):null]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[b>1?(0,e.jsx)(P,{variant:"outline",disabled:C,onClick:a(()=>A(r=>r-1),"onClick"),children:"Back"}):(0,e.jsx)(P,{variant:"ghost",disabled:C,onClick:a(()=>c("/apps/advanced/profiles"),"onClick"),children:"Cancel"}),b===1?(0,e.jsxs)(P,{disabled:!Me||C,onClick:a(()=>D.mutate({goToStep:2,completedStep:1,seed:De()}),"onClick"),children:[C?(0,e.jsx)(J,{className:"mr-1.5 h-4 w-4 animate-spin"}):null,"Continue"]}):null,b===2?(0,e.jsxs)(P,{disabled:C,onClick:a(()=>D.mutate({goToStep:3,completedStep:2}),"onClick"),children:[C?(0,e.jsx)(J,{className:"mr-1.5 h-4 w-4 animate-spin"}):null,"Continue"]}):null,b===3?(0,e.jsxs)(P,{disabled:C,onClick:a(()=>je.mutate(),"onClick"),children:[C?(0,e.jsx)(J,{className:"mr-1.5 h-4 w-4 animate-spin"}):null,"Save profile"]}):null]})]})})]})}a(Ct,"ProfileWizard");async function kt(t,n,l){const o=new Map;l.companyDefault&&o.set(`company:${t}`,{targetType:"company",targetId:t});for(const s of l.agentIds)o.set(`agent:${s}`,{targetType:"agent",targetId:s});for(const s of l.projectIds)o.set(`project:${s}`,{targetType:"project",targetId:s});for(const s of l.routineIds)o.set(`routine:${s}`,{targetType:"routine",targetId:s});const c=new Set(["company","agent","project","routine"]),x=new Set(n.bindings.map(s=>`${s.targetType}:${s.targetId}`)),g=[...[...o.entries()].filter(([s])=>!x.has(s)).map(([s,f])=>({key:s,apply:a(()=>T.bindProfile(t,n.id,f),"apply"),rollback:a(()=>T.unbindProfile(t,n.id,f),"rollback")})),...n.bindings.filter(s=>c.has(s.targetType)&&!o.has(`${s.targetType}:${s.targetId}`)).map(s=>{const f={targetType:s.targetType,targetId:s.targetId};return{key:`${s.targetType}:${s.targetId}`,apply:a(()=>T.unbindProfile(t,n.id,f),"apply"),rollback:a(()=>T.bindProfile(t,n.id,f),"rollback")}})],p=[];for(const s of g)try{await s.apply(),p.push(s)}catch(f){const d=(await Promise.allSettled(p.reverse().map(h=>h.rollback()))).filter(h=>h.status==="rejected").length,i=d>0?`; ${d} rollback operation(s) also failed`:"";throw new Error(`Could not update assignment ${s.key}${i}`,{cause:f})}}a(kt,"reconcileBindings");function Tt({current:t}){return(0,e.jsx)("ol",{className:"flex items-center gap-2 text-sm",children:ke.map(({step:n,label:l},o)=>{const c=t>n,x=t===n;return(0,e.jsxs)("li",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:_("inline-flex h-6 w-6 items-center justify-center rounded-full text-xs font-semibold",x&&"bg-primary text-primary-foreground",c&&"bg-primary/20 text-primary",!x&&!c&&"bg-muted text-muted-foreground"),children:c?(0,e.jsx)(We,{className:"h-3.5 w-3.5"}):n}),(0,e.jsx)("span",{className:_("font-medium",x?"text-foreground":"text-muted-foreground"),children:l}),o<ke.length-1?(0,e.jsx)("span",{className:"mx-1 text-muted-foreground",children:"→"}):null]},n)})})}a(Tt,"Stepper");function At({template:t,onTemplate:n,copyFromId:l,onCopyFrom:o,copyOptions:c,name:x,onName:g,description:p,onDescription:s,profileKey:f,onProfileKey:d}){const[i,h]=(0,u.useState)(!1);return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:"Start from"}),(0,e.jsx)("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:_e.map(m=>(0,e.jsxs)("button",{type:"button",onClick:a(()=>n(m.key),"onClick"),className:_("flex flex-col items-start gap-1 rounded-md border px-4 py-3 text-left transition-colors",t===m.key?"border-primary bg-primary/5 ring-1 ring-primary":"border-border hover:border-primary/40 hover:bg-accent/40"),children:[(0,e.jsx)("span",{className:"text-sm font-medium text-foreground",children:m.title}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:m.description})]},m.key))})]}),t==="copy"?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:"Which profile?"}),c.length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"You don't have another profile to copy yet."}):(0,e.jsx)("div",{className:"space-y-1.5",children:c.map(m=>(0,e.jsxs)("label",{className:"flex cursor-pointer items-center gap-2.5 rounded-md border border-border px-3 py-2",children:[(0,e.jsx)("input",{type:"radio",name:"copy-from",checked:l===m.id,onChange:a(()=>o(m.id),"onChange")}),(0,e.jsx)("span",{className:"text-sm font-medium text-foreground",children:m.name})]},m.id))})]}):null,(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(Z,{htmlFor:"profile-name",children:"Name"}),(0,e.jsx)(K,{id:"profile-name",value:x,onChange:a(m=>g(m.target.value),"onChange"),placeholder:"e.g. Everyday work"})]}),(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(Z,{htmlFor:"profile-description",children:"Description (optional)"}),(0,e.jsx)(He,{id:"profile-description",value:p,onChange:a(m=>s(m.target.value),"onChange"),placeholder:"What is this profile for?",rows:2})]})]}),(0,e.jsxs)(se,{open:i,onOpenChange:h,children:[(0,e.jsxs)(te,{className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[(0,e.jsx)(M,{className:_("h-4 w-4 transition-transform",i&&"rotate-180")}),"Advanced"]}),(0,e.jsx)(ee,{className:"pt-2",children:(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(Z,{htmlFor:"profile-key",children:"Identifier"}),(0,e.jsx)(K,{id:"profile-key",value:f,onChange:a(m=>d(m.target.value),"onChange"),className:"font-mono text-xs"}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Used in exports and the API. Auto-filled from the name."})]})})]})]})}a(At,"StepName");function It({agents:t,projects:n=[],routines:l=[],profiles:o,selectedAgentIds:c,onToggleAgent:x,selectedProjectIds:g,onToggleProject:p,selectedRoutineIds:s,onToggleRoutine:f,companyDefault:d,onCompanyDefault:i}){const[h,m]=(0,u.useState)(!1),b=(0,u.useMemo)(()=>{const j=new Map;for(const v of o)for(const y of v.bindings)if(y.targetType==="agent"){const $=j.get(y.targetId)??[];$.push(v.name),j.set(y.targetId,$)}return j},[o]),A=o.find(j=>j.summary.isCompanyDefault)?.name??null;return(0,e.jsxs)("div",{className:"space-y-5",children:[(0,e.jsxs)("label",{className:"flex items-start gap-3 rounded-lg border border-border p-4",children:[(0,e.jsx)("input",{type:"checkbox",className:"mt-1",checked:d,onChange:a(j=>i(j.target.checked),"onChange")}),(0,e.jsxs)("span",{className:"flex flex-col gap-0.5",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-foreground",children:"Make this the organization default"}),(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Every agent without its own profile uses this one.",A?` Replaces “${A}”.`:""]})]})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:"Assign to agents"}),(0,e.jsx)(Qe,{agents:t,selectedAgentIds:c,onChange:a(j=>{for(const v of t)c.has(v.id)!==j.has(v.id)&&x(v.id)},"onChange"),getDescription:a(j=>{const v=[...b.get(j.id)??[]];return A&&v.push("organization default"),v.length>0?`already has: ${v.join(" · ")}`:"no profiles yet"},"getDescription")}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"If an agent has several profiles, it can use anything any of them allows."})]}),(n.length>0||l.length>0)&&p&&f?(0,e.jsxs)(se,{open:h,onOpenChange:m,className:"rounded-lg border border-border",children:[(0,e.jsxs)(te,{className:"flex w-full items-center justify-between px-4 py-3 text-left",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-foreground",children:"More targets"}),(0,e.jsx)(M,{className:_("h-4 w-4 text-muted-foreground transition-transform",h&&"rotate-180")})]}),(0,e.jsxs)(ee,{className:"space-y-4 border-t border-border px-4 py-3",children:[(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Assign this profile to a whole project or a scheduled routine instead of (or as well as) individual agents."}),(0,e.jsx)(Te,{label:"Projects",options:n,selected:g??new Set,onToggle:p}),(0,e.jsx)(Te,{label:"Routines",options:l,selected:s??new Set,onToggle:f})]})]}):null]})}a(It,"StepAssign");function Te({label:t,options:n,selected:l,onToggle:o}){return n.length===0?null:(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("h4",{className:"text-xs font-medium text-muted-foreground",children:t}),(0,e.jsx)("div",{className:"flex flex-wrap gap-x-4 gap-y-1.5",children:n.map(c=>(0,e.jsxs)("label",{className:"flex cursor-pointer items-center gap-2 text-sm text-foreground",children:[(0,e.jsx)("input",{type:"checkbox",checked:l.has(c.id),onChange:a(()=>o(c.id),"onChange")}),c.name]},c.id))})]})}a(Te,"TargetChecklist");function Kt({mode:t}){const{selectedCompany:n,selectedCompanyId:l}=Ve(),{setBreadcrumbs:o}=Xe(),c=Ye(),[x]=tt(),g=x.get("template"),p=Number(x.get("step")),s=_e.some(d=>d.key===g)?g:void 0,f=p===2||p===3?p:void 0;return(0,u.useEffect)(()=>(o([{label:n?.name??"Organization",href:"/dashboard"},{label:"Apps",href:"/apps"},{label:"Access profiles",href:nt("profiles")},{label:t==="edit"?"Resume draft":"New profile"}]),()=>o([])),[o,n?.name,t]),l?(0,e.jsx)(pt,{children:(0,e.jsxs)("div",{className:"mx-auto flex w-full max-w-4xl flex-col gap-5 p-4 sm:p-6",children:[(0,e.jsxs)("header",{children:[(0,e.jsx)("h1",{className:"text-xl font-bold text-foreground",children:t==="edit"?"Finish your profile":"New access profile"}),(0,e.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Choose which tools this profile allows, then assign it to the agents that need them."})]}),(0,e.jsx)(Ct,{companyId:l,profileId:t==="edit"?c.profileId:void 0,initialTemplate:s,initialStep:f})]})}):(0,e.jsx)("div",{className:"p-6 text-sm text-muted-foreground",children:"Select an organization to create a profile."})}a(Kt,"ProfileWizardRoute");export{Kt as ProfileWizardRoute};
1
+ var Be=Object.defineProperty;var a=(t,n)=>Be(t,"name",{value:n,configurable:!0});import{a as Ae}from"./rolldown-runtime-DhZMWcEn.js";import{li as ze}from"./issue-detail-CZfjXs0M.js";import{$A as Fe,Ap as L,B_ as ee,GS as be,Gb as Oe,H_ as Ie,IC as qe,Jp as T,LS as Ve,ME as Ue,MT as We,NE as P,Np as Y,Op as Q,Pp as H,Sp as ve,V_ as te,Yb as Ge,__ as K,_w as J,aE as Ye,bE as ye,bp as Qe,g_ as He,iC as Je,ib as Xe,jT as M,kT as Ze,kp as X,nj as et,oE as tt,op as Z,qC as st,sv as at,vi as nt,zE as _,z_ as se}from"./index-BJtnP7H1.js";import{i as Pe}from"./shared-D37zfckm.js";import{a as rt,c as lt,d as ot,f as it,i as _e,l as dt,m as Ee,n as ct,o as mt,p as ut,r as Le,s as Ne,u as we}from"./useProfilesData-CWHdMSuL.js";import{t as pt}from"./ToolsAdminGate-DpBg30hQ.js";var u=Ae(et(),1),e=Ae(Fe(),1),xt=["read","write","destructive"],ft={read:"outline",write:"secondary",destructive:"destructive"};function ht(t){const{appGroups:n,catalogLoading:l,selections:o,onSelectionsChange:c}=t,[x,g]=(0,u.useState)(""),[p,s]=(0,u.useState)(null),f=(0,u.useMemo)(()=>{const d=x.trim().toLowerCase();return n.map(i=>({group:i,tools:i.tools.filter(h=>p&&Ee(h)!==p?!1:d?h.toolName.toLowerCase().includes(d)||(h.title??"").toLowerCase().includes(d)||i.name.toLowerCase().includes(d):!0)})).filter(i=>i.tools.length>0)},[n,x,p]);return l?(0,e.jsx)(Pe,{label:"Loading tools…"}):n.length===0?(0,e.jsxs)("div",{className:"flex flex-col items-center gap-3 rounded-lg border border-dashed border-border py-12 text-center",children:[(0,e.jsx)(ze,{className:"h-6 w-6 text-muted-foreground"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-medium text-foreground",children:"App connections are coming soon"}),(0,e.jsx)("p",{className:"mx-auto max-w-sm text-sm text-muted-foreground",children:"Profiles will be available once app connections are ready. Browse the planned integrations in the meantime."})]}),(0,e.jsx)(P,{asChild:!0,variant:"outline",children:(0,e.jsx)(Oe,{to:"/apps",children:"Browse app connections"})})]}):(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxs)("div",{className:"relative min-w-(--sz-220px) flex-1",children:[(0,e.jsx)(qe,{className:"pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),(0,e.jsx)(K,{value:x,onChange:a(d=>g(d.target.value),"onChange"),placeholder:"Search tools…",className:"pl-8"})]}),(0,e.jsx)("div",{className:"flex items-center gap-1.5",children:xt.map(d=>(0,e.jsx)("button",{type:"button",onClick:a(()=>s(i=>i===d?null:d),"onClick"),className:_("rounded-full border px-2.5 py-1 text-xs font-medium transition-colors",p===d?"border-primary bg-primary/10 text-primary":"border-border text-muted-foreground hover:bg-accent"),children:Le[d]},d))})]}),f.length===0?(0,e.jsxs)("div",{className:"flex flex-col items-center gap-2 rounded-lg border border-dashed border-border py-10 text-center",children:[(0,e.jsxs)("p",{className:"text-sm font-medium text-foreground",children:["No tools match “",x,"”."]}),(0,e.jsx)("button",{type:"button",onClick:a(()=>{g(""),s(null)},"onClick"),className:"text-sm font-medium text-primary hover:underline",children:"Clear search"})]}):(0,e.jsx)("div",{className:"divide-y divide-border overflow-hidden rounded-lg border border-border",children:f.map(({group:d,tools:i})=>(0,e.jsx)(gt,{group:d,visibleTools:i,selection:o[d.appKey],onToggleApp:a(()=>c({...o,[d.appKey]:it(d,o[d.appKey])}),"onToggleApp"),onToggleTool:a(h=>c({...o,[d.appKey]:ut(d,o[d.appKey],h)}),"onToggleTool")},d.appKey))}),(0,e.jsx)(jt,{value:t.newToolsAction,onChange:t.onNewToolsActionChange}),(0,e.jsx)(Nt,{rules:t.advancedRules,onChange:t.onAdvancedRulesChange})]})}a(ht,"WizardToolsStep");function gt({group:t,visibleTools:n,selection:l,onToggleApp:o,onToggleTool:c}){const[x,g]=(0,u.useState)(!1),p=rt(t,l);return(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[(0,e.jsx)(ve,{checked:p==="checked"?!0:p==="indeterminate"?"indeterminate":!1,onCheckedChange:o,"aria-label":`All ${t.name} tools`}),(0,e.jsxs)("button",{type:"button",onClick:a(()=>g(s=>!s),"onClick"),className:"flex flex-1 items-center gap-1.5 text-left",children:[x?(0,e.jsx)(M,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):(0,e.jsx)(Ze,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,e.jsxs)("span",{className:"flex flex-col",children:[(0,e.jsxs)("span",{className:"text-sm font-medium text-foreground",children:["All ",t.name," tools (",t.tools.length,")"]}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:p==="indeterminate"?mt(t,l):"includes tools "+t.name+" adds later"})]})]})]}),x?(0,e.jsx)("div",{className:"space-y-0.5 border-t border-border bg-muted/20 px-3 py-2 pl-10",children:n.map(s=>{const f=Ee(s);return(0,e.jsxs)("label",{className:"flex cursor-pointer items-start gap-2.5 rounded-md px-1.5 py-1.5 hover:bg-accent/50",children:[(0,e.jsx)(ve,{className:"mt-0.5",checked:dt(t,l,s.id),onCheckedChange:a(()=>c(s.id),"onCheckedChange")}),(0,e.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[(0,e.jsxs)("span",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("code",{className:"font-mono text-xs text-foreground",children:s.toolName}),(0,e.jsx)(Ie,{variant:ft[f],className:"text-(length:--text-nano)",children:Le[f]})]}),s.title||s.description?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:s.title??s.description}):null]})]},s.id)})}):null]})}a(gt,"AppRow");function jt({value:t,onChange:n}){return(0,e.jsxs)("fieldset",{className:"space-y-2 rounded-lg border border-border p-4",children:[(0,e.jsx)("legend",{className:"px-1 text-sm font-medium text-foreground",children:"New tools that appear later"}),(0,e.jsx)("div",{className:"space-y-2",children:[{value:"deny",label:"Stay blocked until someone allows them",hint:"New tools an app adds later won't be usable until you review them.",recommended:!0},{value:"allow",label:"Allowed automatically",hint:"Any tool an app adds later becomes usable right away."}].map(l=>(0,e.jsxs)("label",{className:"flex cursor-pointer items-start gap-2.5",children:[(0,e.jsx)("input",{type:"radio",name:"new-tools-action",className:"mt-0.5",checked:t===l.value,onChange:a(()=>n(l.value),"onChange")}),(0,e.jsxs)("span",{className:"flex flex-col gap-0.5",children:[(0,e.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[l.label,l.recommended?(0,e.jsx)(Ie,{variant:"outline",className:"text-(length:--text-nano)",children:"Recommended"}):(0,e.jsx)("span",{className:"text-xs font-normal text-amber-600",children:"(risky)"})]}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:l.hint})]})]},l.value))})]})}a(jt,"NewToolsRadio");var bt=[{value:"tool_name",label:"Tool name pattern"},{value:"risk_level",label:"Risk level"},{value:"catalog_entry",label:"By tool ID"}];function vt(){const t=globalThis.crypto?.randomUUID?.();return t||`rule-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}a(vt,"createAdvancedRuleId");function yt(t){const n=t.effect==="include"?"Allow":"Block";return t.kind==="tool_name"?`${n} tools matching ${t.value}`:t.kind==="risk_level"?`${n} ${t.riskLevel??t.value} tools`:`${n} tool ${t.value}`}a(yt,"ruleSummary");function Nt({rules:t,onChange:n}){const[l,o]=(0,u.useState)(!1),[c,x]=(0,u.useState)("tool_name"),[g,p]=(0,u.useState)(""),[s,f]=(0,u.useState)("include"),d=a(()=>{const i=g.trim();if(!i&&c!=="risk_level")return;const h={id:vt(),kind:c,value:c==="risk_level"?i||"destructive":i,riskLevel:c==="risk_level"?i||"destructive":void 0,effect:s};n([...t,h]),p("")},"addRule");return(0,e.jsxs)(se,{open:l,onOpenChange:o,className:"rounded-lg border border-border",children:[(0,e.jsxs)(te,{className:"flex w-full items-center justify-between px-4 py-3 text-left",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-foreground",children:"Advanced rules"}),(0,e.jsx)(M,{className:_("h-4 w-4 text-muted-foreground transition-transform",l&&"rotate-180")})]}),(0,e.jsxs)(ee,{className:"space-y-3 border-t border-border px-4 py-3",children:[(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Match tools by a name pattern, a risk level, or a specific tool ID. These run on top of the choices above."}),t.length>0?(0,e.jsx)("ul",{className:"space-y-1.5",children:t.map(i=>(0,e.jsxs)("li",{className:"flex items-center justify-between gap-2 rounded-md border border-border bg-muted/30 px-3 py-1.5 text-sm",children:[(0,e.jsx)("span",{className:"text-foreground",children:yt(i)}),(0,e.jsx)("button",{type:"button","aria-label":"Remove rule",onClick:a(()=>n(t.filter(h=>h.id!==i.id)),"onClick"),className:"text-muted-foreground hover:text-destructive",children:(0,e.jsx)(Je,{className:"h-4 w-4"})})]},i.id))}):null,(0,e.jsxs)("div",{className:"flex flex-wrap items-end gap-2",children:[(0,e.jsxs)(Q,{value:s,onValueChange:a(i=>f(i),"onValueChange"),children:[(0,e.jsx)(Y,{className:"w-28",children:(0,e.jsx)(H,{})}),(0,e.jsxs)(X,{children:[(0,e.jsx)(L,{value:"include",children:"Allow"}),(0,e.jsx)(L,{value:"exclude",children:"Block"})]})]}),(0,e.jsxs)(Q,{value:c,onValueChange:a(i=>x(i),"onValueChange"),children:[(0,e.jsx)(Y,{className:"w-40",children:(0,e.jsx)(H,{})}),(0,e.jsx)(X,{children:bt.map(i=>(0,e.jsx)(L,{value:i.value,children:i.label},i.value))})]}),c==="risk_level"?(0,e.jsxs)(Q,{value:g||"destructive",onValueChange:p,children:[(0,e.jsx)(Y,{className:"w-36",children:(0,e.jsx)(H,{})}),(0,e.jsxs)(X,{children:[(0,e.jsx)(L,{value:"read",children:"Read-only"}),(0,e.jsx)(L,{value:"write",children:"Makes changes"}),(0,e.jsx)(L,{value:"destructive",children:"Destructive"})]})]}):(0,e.jsx)(K,{value:g,onChange:a(i=>p(i.target.value),"onChange"),placeholder:c==="tool_name"?"e.g. gmail.send*":"tool ID",className:"w-44"}),(0,e.jsxs)(P,{type:"button",variant:"outline",size:"sm",onClick:d,children:[(0,e.jsx)(st,{className:"mr-1 h-3.5 w-3.5"}),"Add rule"]})]})]})]})}a(Nt,"AdvancedRules");var $e="wizard";function wt(t){const n=t?.metadata?.[$e];if(!n||typeof n!="object")return null;const l=n,o=l.lastCompletedStep;return o!==1&&o!==2&&o!==3?null:{lastCompletedStep:o,template:typeof l.template=="string"?l.template:null}}a(wt,"readWizardMeta");function Se(t,n){return{...t??{},[$e]:n}}a(Se,"withWizardMeta");function St(t){return t?Math.min(t.lastCompletedStep+1,3):1}a(St,"resumeStep");function Ce(t){return t.trim().toLowerCase().replace(/[^a-z0-9._:-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,160)}a(Ce,"slugifyProfileKey");var ke=[{step:1,label:"Name"},{step:2,label:"Choose tools"},{step:3,label:"Assign"}];function Ct({companyId:t,profileId:n,initialTemplate:l,initialStep:o}){const c=Ge(),x=Ue(),{pushToast:g}=at(),p=ct(t),{appGroups:s,catalog:f,profiles:d,agents:i}=p,h=d.data?.profiles??[],m=n?h.find(r=>r.id===n)??null:null,[b,A]=(0,u.useState)(1),[j,v]=(0,u.useState)(n??null),[y,$]=(0,u.useState)(l??null),[R,Re]=(0,u.useState)(null),[I,ae]=(0,u.useState)(""),[B,ne]=(0,u.useState)(""),[z,F]=(0,u.useState)(""),[re,le]=(0,u.useState)(!1),[E,O]=(0,u.useState)({}),[q,oe]=(0,u.useState)([]),[k,ie]=(0,u.useState)("deny"),[V,de]=(0,u.useState)(new Set),[ce,me]=(0,u.useState)(new Set),[ue,pe]=(0,u.useState)(new Set),[U,xe]=(0,u.useState)(!1),W=a(r=>N=>r(w=>{const S=new Set(w);return S.has(N)?S.delete(N):S.add(N),S}),"toggleIn"),fe=(0,u.useRef)(!1);(0,u.useEffect)(()=>{if(fe.current||!m||s.length===0||m.id!==n)return;fe.current=!0,ae(m.name),ne(m.description??""),F(m.profileKey),le(!0),ie(m.defaultAction);const r=we(s,m.entries);O(r.selections),oe(r.advancedRules);const N=wt(m);$(N?.template??null),A(o??(m.status==="draft"?St(N):1));const w=a(S=>new Set(m.bindings.filter(G=>G.targetType===S).map(G=>G.targetId)),"targetIds");de(w("agent")),me(w("project")),pe(w("routine")),xe(m.bindings.some(S=>S.targetType==="company"))},[m,s,n,o]),(0,u.useEffect)(()=>{re||F(Ce(I))},[I,re]);const he=a(()=>{x.invalidateQueries({queryKey:be.tools.profiles(t)}),x.invalidateQueries({queryKey:be.tools.testAgentAccesses()})},"invalidate"),ge=(0,u.useMemo)(()=>lt(s,E,k,f.length),[s,E,k,f.length]),De=a(()=>{if(y==="copy"&&R){const r=h.find(N=>N.id===R);if(r)return we(s,r.entries).selections}return y&&y!=="copy"?ot(y,s):E},"seedSelections"),D=ye({mutationFn:a(async r=>{const N=r.seed??E,w=Ne(s,N,q,k),S=Se(m?.metadata??null,{lastCompletedStep:r.completedStep,template:y});return j?{created:await T.updateProfile(j,{profileKey:z||void 0,name:I.trim()||"Untitled profile",description:B.trim()||null,defaultAction:k,entries:w,metadata:S}),goToStep:r.goToStep,seed:r.seed}:{created:await T.createProfile(t,{profileKey:z||Ce(I)||"profile",name:I.trim()||"Untitled profile",description:B.trim()||null,status:"draft",defaultAction:k,entries:w,metadata:S}),goToStep:r.goToStep,seed:r.seed}},"mutationFn"),onSuccess:a(({created:r,goToStep:N,seed:w})=>{v(r.id),w&&O(w),A(N),he()},"onSuccess"),onError:a(r=>g({title:"Could not save",body:String(r?.message??r),tone:"error"}),"onError")}),je=ye({mutationFn:a(async()=>{if(!j)throw new Error("No draft to finish");const r=Ne(s,E,q,k);return await kt(t,await T.updateProfile(j,{defaultAction:k,entries:r,metadata:Se(m?.metadata??null,{lastCompletedStep:3,template:y})}),{agentIds:[...V],projectIds:[...ce],routineIds:[...ue],companyDefault:U}),T.updateProfile(j,{status:"active"})},"mutationFn"),onSuccess:a(r=>{g({title:"Profile saved",tone:"success"}),he(),c(`/apps/advanced/profiles/${r.id}${V.size===0&&!U?"?created=1":""}`)},"onSuccess"),onError:a(r=>g({title:"Could not save profile",body:String(r?.message??r),tone:"error"}),"onError")}),Ke=a(()=>{const r=b;D.mutate({goToStep:b,completedStep:r},{onSuccess:a(()=>{g({title:"Draft saved",body:"Pick it back up from the profiles list.",tone:"success"}),c("/apps/advanced/profiles")},"onSuccess")})},"saveAndExit"),C=D.isPending||je.isPending,Me=I.trim().length>0&&(y!=="copy"||!!R);return n&&d.isLoading?(0,e.jsx)(Pe,{label:"Loading draft…"}):(0,e.jsxs)("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-6 pb-36 md:pb-24",children:[(0,e.jsx)(Tt,{current:b}),(0,e.jsxs)("div",{className:"min-h-(--sz-320px)",children:[b===1?(0,e.jsx)(At,{template:y,onTemplate:$,copyFromId:R,onCopyFrom:Re,copyOptions:h.filter(r=>r.status!=="archived"&&r.id!==n),name:I,onName:ae,description:B,onDescription:ne,profileKey:z,onProfileKey:a(r=>{le(!0),F(r)},"onProfileKey")}):null,b===2?(0,e.jsx)(ht,{appGroups:s,catalogLoading:p.catalogLoading,selections:E,onSelectionsChange:O,advancedRules:q,onAdvancedRulesChange:oe,newToolsAction:k,onNewToolsActionChange:ie}):null,b===3?(0,e.jsx)(It,{agents:(i.data??[]).map(r=>({id:r.id,name:r.name,title:r.title,icon:r.icon})),projects:(p.projects.data??[]).map(r=>({id:r.id,name:r.name})),routines:(p.routines.data??[]).map(r=>({id:r.id,name:r.title})),profiles:h,selectedAgentIds:V,onToggleAgent:W(de),selectedProjectIds:ce,onToggleProject:W(me),selectedRoutineIds:ue,onToggleRoutine:W(pe),companyDefault:U,onCompanyDefault:xe}):null]}),(0,e.jsx)("div",{className:"mobile-nav-composer fixed inset-x-0 bottom-(--tc-composer-bottom) z-20 border-t border-border bg-background/95 backdrop-blur md:bottom-0",children:(0,e.jsxs)("div",{className:"mx-auto flex w-full max-w-3xl flex-wrap items-center justify-between gap-3 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[b>=2?(0,e.jsxs)("span",{children:["Allows ",(0,e.jsx)("span",{className:"font-medium text-foreground",children:ge.allowed})," of ",ge.total," ","tools"]}):null,j?(0,e.jsx)("button",{type:"button",onClick:Ke,disabled:C,className:"font-medium text-primary hover:underline disabled:opacity-50",children:"Save & finish later"}):null]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[b>1?(0,e.jsx)(P,{variant:"outline",disabled:C,onClick:a(()=>A(r=>r-1),"onClick"),children:"Back"}):(0,e.jsx)(P,{variant:"ghost",disabled:C,onClick:a(()=>c("/apps/advanced/profiles"),"onClick"),children:"Cancel"}),b===1?(0,e.jsxs)(P,{disabled:!Me||C,onClick:a(()=>D.mutate({goToStep:2,completedStep:1,seed:De()}),"onClick"),children:[C?(0,e.jsx)(J,{className:"mr-1.5 h-4 w-4 animate-spin"}):null,"Continue"]}):null,b===2?(0,e.jsxs)(P,{disabled:C,onClick:a(()=>D.mutate({goToStep:3,completedStep:2}),"onClick"),children:[C?(0,e.jsx)(J,{className:"mr-1.5 h-4 w-4 animate-spin"}):null,"Continue"]}):null,b===3?(0,e.jsxs)(P,{disabled:C,onClick:a(()=>je.mutate(),"onClick"),children:[C?(0,e.jsx)(J,{className:"mr-1.5 h-4 w-4 animate-spin"}):null,"Save profile"]}):null]})]})})]})}a(Ct,"ProfileWizard");async function kt(t,n,l){const o=new Map;l.companyDefault&&o.set(`company:${t}`,{targetType:"company",targetId:t});for(const s of l.agentIds)o.set(`agent:${s}`,{targetType:"agent",targetId:s});for(const s of l.projectIds)o.set(`project:${s}`,{targetType:"project",targetId:s});for(const s of l.routineIds)o.set(`routine:${s}`,{targetType:"routine",targetId:s});const c=new Set(["company","agent","project","routine"]),x=new Set(n.bindings.map(s=>`${s.targetType}:${s.targetId}`)),g=[...[...o.entries()].filter(([s])=>!x.has(s)).map(([s,f])=>({key:s,apply:a(()=>T.bindProfile(t,n.id,f),"apply"),rollback:a(()=>T.unbindProfile(t,n.id,f),"rollback")})),...n.bindings.filter(s=>c.has(s.targetType)&&!o.has(`${s.targetType}:${s.targetId}`)).map(s=>{const f={targetType:s.targetType,targetId:s.targetId};return{key:`${s.targetType}:${s.targetId}`,apply:a(()=>T.unbindProfile(t,n.id,f),"apply"),rollback:a(()=>T.bindProfile(t,n.id,f),"rollback")}})],p=[];for(const s of g)try{await s.apply(),p.push(s)}catch(f){const d=(await Promise.allSettled(p.reverse().map(h=>h.rollback()))).filter(h=>h.status==="rejected").length,i=d>0?`; ${d} rollback operation(s) also failed`:"";throw new Error(`Could not update assignment ${s.key}${i}`,{cause:f})}}a(kt,"reconcileBindings");function Tt({current:t}){return(0,e.jsx)("ol",{className:"flex items-center gap-2 text-sm",children:ke.map(({step:n,label:l},o)=>{const c=t>n,x=t===n;return(0,e.jsxs)("li",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:_("inline-flex h-6 w-6 items-center justify-center rounded-full text-xs font-semibold",x&&"bg-primary text-primary-foreground",c&&"bg-primary/20 text-primary",!x&&!c&&"bg-muted text-muted-foreground"),children:c?(0,e.jsx)(We,{className:"h-3.5 w-3.5"}):n}),(0,e.jsx)("span",{className:_("font-medium",x?"text-foreground":"text-muted-foreground"),children:l}),o<ke.length-1?(0,e.jsx)("span",{className:"mx-1 text-muted-foreground",children:"→"}):null]},n)})})}a(Tt,"Stepper");function At({template:t,onTemplate:n,copyFromId:l,onCopyFrom:o,copyOptions:c,name:x,onName:g,description:p,onDescription:s,profileKey:f,onProfileKey:d}){const[i,h]=(0,u.useState)(!1);return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:"Start from"}),(0,e.jsx)("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:_e.map(m=>(0,e.jsxs)("button",{type:"button",onClick:a(()=>n(m.key),"onClick"),className:_("flex flex-col items-start gap-1 rounded-md border px-4 py-3 text-left transition-colors",t===m.key?"border-primary bg-primary/5 ring-1 ring-primary":"border-border hover:border-primary/40 hover:bg-accent/40"),children:[(0,e.jsx)("span",{className:"text-sm font-medium text-foreground",children:m.title}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:m.description})]},m.key))})]}),t==="copy"?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:"Which profile?"}),c.length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"You don't have another profile to copy yet."}):(0,e.jsx)("div",{className:"space-y-1.5",children:c.map(m=>(0,e.jsxs)("label",{className:"flex cursor-pointer items-center gap-2.5 rounded-md border border-border px-3 py-2",children:[(0,e.jsx)("input",{type:"radio",name:"copy-from",checked:l===m.id,onChange:a(()=>o(m.id),"onChange")}),(0,e.jsx)("span",{className:"text-sm font-medium text-foreground",children:m.name})]},m.id))})]}):null,(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(Z,{htmlFor:"profile-name",children:"Name"}),(0,e.jsx)(K,{id:"profile-name",value:x,onChange:a(m=>g(m.target.value),"onChange"),placeholder:"e.g. Everyday work"})]}),(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(Z,{htmlFor:"profile-description",children:"Description (optional)"}),(0,e.jsx)(He,{id:"profile-description",value:p,onChange:a(m=>s(m.target.value),"onChange"),placeholder:"What is this profile for?",rows:2})]})]}),(0,e.jsxs)(se,{open:i,onOpenChange:h,children:[(0,e.jsxs)(te,{className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[(0,e.jsx)(M,{className:_("h-4 w-4 transition-transform",i&&"rotate-180")}),"Advanced"]}),(0,e.jsx)(ee,{className:"pt-2",children:(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(Z,{htmlFor:"profile-key",children:"Identifier"}),(0,e.jsx)(K,{id:"profile-key",value:f,onChange:a(m=>d(m.target.value),"onChange"),className:"font-mono text-xs"}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Used in exports and the API. Auto-filled from the name."})]})})]})]})}a(At,"StepName");function It({agents:t,projects:n=[],routines:l=[],profiles:o,selectedAgentIds:c,onToggleAgent:x,selectedProjectIds:g,onToggleProject:p,selectedRoutineIds:s,onToggleRoutine:f,companyDefault:d,onCompanyDefault:i}){const[h,m]=(0,u.useState)(!1),b=(0,u.useMemo)(()=>{const j=new Map;for(const v of o)for(const y of v.bindings)if(y.targetType==="agent"){const $=j.get(y.targetId)??[];$.push(v.name),j.set(y.targetId,$)}return j},[o]),A=o.find(j=>j.summary.isCompanyDefault)?.name??null;return(0,e.jsxs)("div",{className:"space-y-5",children:[(0,e.jsxs)("label",{className:"flex items-start gap-3 rounded-lg border border-border p-4",children:[(0,e.jsx)("input",{type:"checkbox",className:"mt-1",checked:d,onChange:a(j=>i(j.target.checked),"onChange")}),(0,e.jsxs)("span",{className:"flex flex-col gap-0.5",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-foreground",children:"Make this the organization default"}),(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Every agent without its own profile uses this one.",A?` Replaces “${A}”.`:""]})]})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:"Assign to agents"}),(0,e.jsx)(Qe,{agents:t,selectedAgentIds:c,onChange:a(j=>{for(const v of t)c.has(v.id)!==j.has(v.id)&&x(v.id)},"onChange"),getDescription:a(j=>{const v=[...b.get(j.id)??[]];return A&&v.push("organization default"),v.length>0?`already has: ${v.join(" · ")}`:"no profiles yet"},"getDescription")}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"If an agent has several profiles, it can use anything any of them allows."})]}),(n.length>0||l.length>0)&&p&&f?(0,e.jsxs)(se,{open:h,onOpenChange:m,className:"rounded-lg border border-border",children:[(0,e.jsxs)(te,{className:"flex w-full items-center justify-between px-4 py-3 text-left",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-foreground",children:"More targets"}),(0,e.jsx)(M,{className:_("h-4 w-4 text-muted-foreground transition-transform",h&&"rotate-180")})]}),(0,e.jsxs)(ee,{className:"space-y-4 border-t border-border px-4 py-3",children:[(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Assign this profile to a whole project or a scheduled routine instead of (or as well as) individual agents."}),(0,e.jsx)(Te,{label:"Projects",options:n,selected:g??new Set,onToggle:p}),(0,e.jsx)(Te,{label:"Routines",options:l,selected:s??new Set,onToggle:f})]})]}):null]})}a(It,"StepAssign");function Te({label:t,options:n,selected:l,onToggle:o}){return n.length===0?null:(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("h4",{className:"text-xs font-medium text-muted-foreground",children:t}),(0,e.jsx)("div",{className:"flex flex-wrap gap-x-4 gap-y-1.5",children:n.map(c=>(0,e.jsxs)("label",{className:"flex cursor-pointer items-center gap-2 text-sm text-foreground",children:[(0,e.jsx)("input",{type:"checkbox",checked:l.has(c.id),onChange:a(()=>o(c.id),"onChange")}),c.name]},c.id))})]})}a(Te,"TargetChecklist");function Kt({mode:t}){const{selectedCompany:n,selectedCompanyId:l}=Ve(),{setBreadcrumbs:o}=Xe(),c=Ye(),[x]=tt(),g=x.get("template"),p=Number(x.get("step")),s=_e.some(d=>d.key===g)?g:void 0,f=p===2||p===3?p:void 0;return(0,u.useEffect)(()=>(o([{label:n?.name??"Organization",href:"/dashboard"},{label:"Apps",href:"/apps"},{label:"Access profiles",href:nt("profiles")},{label:t==="edit"?"Resume draft":"New profile"}]),()=>o([])),[o,n?.name,t]),l?(0,e.jsx)(pt,{children:(0,e.jsxs)("div",{className:"mx-auto flex w-full max-w-4xl flex-col gap-5 p-4 sm:p-6",children:[(0,e.jsxs)("header",{children:[(0,e.jsx)("h1",{className:"text-xl font-bold text-foreground",children:t==="edit"?"Finish your profile":"New access profile"}),(0,e.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Choose which tools this profile allows, then assign it to the agents that need them."})]}),(0,e.jsx)(Ct,{companyId:l,profileId:t==="edit"?c.profileId:void 0,initialTemplate:s,initialStep:f})]})}):(0,e.jsx)("div",{className:"p-6 text-sm text-muted-foreground",children:"Select an organization to create a profile."})}a(Kt,"ProfileWizardRoute");export{Kt as ProfileWizardRoute};