@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,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DesignSandboxTaskThread-CMeCSQid.js","assets/rolldown-runtime-DhZMWcEn.js","assets/index-Bt31d8ga.js","assets/index-z7lcCz2I.css"])))=>i.map(i=>d[i]);
2
- var hP=Object.defineProperty;var a=(e,t)=>hP(e,"name",{value:t,configurable:!0});import{a as $g,n as Pg,t as fP}from"./rolldown-runtime-DhZMWcEn.js";import{C as Dg,S as nj,_ as WC,a as pP,b as gP,c as xP,d as rj,f as aj,g as bP,h as kc,i as KC,l as yP,m as vP,p as ij,s as wP,u as kP,x as jP,y as NP}from"./collections-BxrcELwt.js";import{$A as IP,$E as SP,$S as Et,$b as VC,$f as U0,$g as _P,$h as CP,$l as AP,$r as vb,$t as Ns,$v as RP,$w as Pu,$x as oj,A as HC,AA as Lg,AC as Oo,AD as Tp,AO as TP,AT as Hh,Ab as QC,Af as EP,Ag as lj,Ai as hl,Am as MP,Ao as $P,Ap as Ra,At as PP,Au as GC,Av as DP,B as jc,BA as he,BC as LP,B_ as YC,Bg as OP,Bm as JC,Bo as wb,Bt as XC,Bv as qP,Bw as la,Bx as cj,C as ZC,CC as Ep,CE as tm,CS as BP,CT as FP,Cb as Og,Cg as lo,Cn as zP,Co as Mp,Cu as eA,Cv as mv,Cx as Da,D as UP,DA as WP,DC as Du,DS as tA,Da as KP,Db as sm,Dc as VP,Dg as HP,Dk as W0,Dm as QP,Do as GP,Dp as md,Du as gh,Dv as YP,Dw as uc,Dy as JP,E as XP,EA as fs,EC as sA,EO as qg,ES as Zm,ET as xh,E_ as mc,Eb as nm,Eg as Wo,Em as ZP,Ep as eD,Eu as qm,Ev as Pi,Ew as hv,Ex as La,F as To,FA as In,FE as tD,FT as yd,F_ as sD,Fb as Sl,Fg as dj,Fo as uj,Ft as nD,Fv as rD,Fw as aD,Fx as iD,Fy as oD,G as fv,GC as lD,GS as G,GT as ei,Gb as tt,Gg as cD,Gh as nA,Gm as dD,Gn as pv,Gt as mj,Gw as co,Gx as uD,H as mD,HC as Bg,HO as hD,H_ as $t,Hb as Gl,Hg as hj,Hh as fD,Hm as bh,Hn as rA,Ho as K0,Ht as aA,Hw as gv,Hx as pD,Hy as xv,I as gD,IA as lt,IC as uo,IE as Fg,IS as ba,Ib as xD,Id as bD,Im as yD,Io as fj,It as vD,Iw as Tl,Ix as wD,Iy as Qh,JA as kD,JC as jd,JT as iA,Jb as jD,Jf as ND,Jg as kb,Jh as pj,Jl as ID,Jn as $p,Jt as bv,Jw as yh,Jx as yl,K as rm,KE as jb,KT as SD,Ka as oA,Kh as _D,Kl as CD,Kr as Pp,Kt as lA,Kv as hc,Kx as Bm,L as Nd,LD as AD,LE as xa,LS as zg,LT as vh,L_ as RD,Lm as cA,Lo as TD,Lt as ED,Lv as MD,Lw as $D,Lx as PD,M as DD,MA as LD,ME as ys,MT as Ut,Mb as Nu,Mf as OD,Mg as qD,Mi as Fm,Mt as dA,Mu as BD,Mv as FD,Mx as gj,My as Gh,N as xj,NA as $n,NE as W,NT as zD,Nb as yv,Ng as UD,Nm as WD,Np as sd,Nt as KD,Nu as VD,Nv as HD,O as uA,OA as dn,OC as QD,OT as GD,Oa as YD,Ob as am,Og as JD,Oi as XD,Ok as ZD,Om as e4,Op as nd,Ou as mA,Ov as t4,Ox as hA,P as s4,PE as n4,PT as r4,P_ as a4,Pb as _l,Pg as ic,Pi as i4,Pm as o4,Po as bj,Pp as rd,Pt as l4,Pw as c4,Px as yj,QA as d4,QC as fc,QE as u4,QT as Xt,Q_ as vj,Qg as m4,Qh as h4,Ql as f4,Qr as wj,Qt as kj,Qv as vv,Qw as El,Qx as p4,Qy as g4,R as pa,RA as fA,RC as x4,RD as b4,RT as pc,Rb as Id,Rg as y4,Rm as pA,Ro as v4,Rp as eh,Rt as w4,Ru as k4,Rv as jj,Rw as j4,Rx as N4,S as wv,SA as Nj,SC as Yh,SS as Ij,ST as $d,S_ as I4,Sb as im,Sg as V0,Sn as S4,So as gA,Sp as Cl,Su as _4,Sw as kv,Sy as C4,T as A4,TA as H0,TS as Sj,TT as Cn,T_ as R4,Tb as om,Tc as T4,Tg as E4,Ti as Dp,Tl as M4,To as $4,Tu as P4,Tv as jv,Tw as xA,Tx as Oa,Ty as Sf,UC as th,UE as Nv,UT as ya,U_ as bA,Ub as D4,Ug as L4,Uh as O4,Um as bp,Un as q4,Uo as _j,Up as Ma,Ut as Lp,Ux as B4,V as Al,VA as Iv,VC as vl,VT as Sd,V_ as yA,Vg as vA,Vm as Nb,Vp as ti,Vt as Sv,Vw as F4,Vx as z4,Vy as U4,W as _v,WE as $s,WS as Cj,WT as W4,Wb as Ib,Wg as Aj,Wh as K4,Wm as V4,Wn as wA,Wo as H4,Wp as Q4,Wt as kA,Ww as G4,Wx as Sm,XA as Y4,XC as wh,XE as Ci,XO as J4,XT as X4,Xc as jA,Xf as Z4,Xg as eL,Xl as tL,Xn as sL,Xr as nL,Xt as rL,Xu as Sb,Xv as aL,Xw as NA,Xx as iL,YA as oL,YE as sc,YO as lL,YS as Ug,YT as Lu,Yb as Jh,Yc as cL,Yf as dL,Yh as _m,Yn as uL,Yp as _f,Yr as mL,Yt as IA,Yw as Fn,Yx as hL,ZA as fL,ZC as pL,ZO as SA,ZS as gL,ZT as _b,Z_ as _A,Zg as xL,Zh as CA,Zp as bL,Zr as yL,Zt as vL,Zv as wL,Zx as kL,_ as Op,_E as AA,_S as jL,_T as $a,__ as ia,_g as gi,_m as NL,_n as Ou,_r as IL,_t as SL,_u as Rj,_v as xn,_w as et,_x as _L,aA as sh,aC as qp,aE as CL,aS as Tj,aT as AL,ab as oa,af as RL,ag as TL,an as RA,au as Q0,aw as EL,ax as ML,ay as Eo,bE as ut,bT as $L,b_ as Cv,bb as kh,bg as Gc,bo as TA,bs as PL,bt as DL,bu as EA,bv as yp,bw as Wg,cA as LL,cE as OL,cS as Kg,cT as yr,c_ as MA,cg as Pd,ci as $A,co as Vg,cs as qL,cu as BL,cv as lm,cw as Hg,cy as FL,d as Av,dD as zL,dE as Rv,dS as nh,d_ as PA,db as UL,dg as G0,dm as WL,do as jh,du as Yl,dx as KL,dy as po,eC as Ej,eD as VL,eS as Mj,eT as Nh,e_ as HL,eg as QL,ei as xu,ej as GL,ek as YL,em as JL,en as Cm,eu as XL,ev as DA,ew as Ih,fC as LA,fD as ZL,fS as wl,fT as OA,f_ as qA,fb as BA,fg as $j,fi as eO,fo as FA,fr as Pj,fu as Cb,fw as Xh,fx as Bp,fy as ca,g as Ab,gC as Nc,gS as tO,gT as mo,g_ as Zs,gg as Vl,gk as Rb,gm as zA,gt as sO,gu as nO,gw as rO,gx as aO,hC as ls,hE as Ps,hS as Dj,hT as Tv,hg as iO,hm as oO,hn as lO,ho as cO,hr as dO,ht as uO,hu as Y0,hv as Di,hw as qo,hy as UA,iC as Gs,iD as va,iE as WA,iS as io,ib as mO,ig as hO,it as Lj,iu as fO,iv as Bo,j as KA,jC as Mi,jE as Ev,jT as en,ja as Fp,jb as un,jf as pO,jg as gO,ji as VA,jm as xO,jo as bO,jt as yO,ju as vO,jv as wO,jw as kO,jx as jO,k as NO,kA as kl,kC as IO,kT as Us,ka as SO,kb as cm,kg as _O,ki as HA,kk as Qg,km as CO,kp as ad,ku as eo,kv as AO,kw as Zh,kx as RO,ky as QA,lC as bu,lD as TO,lS as $e,l_ as EO,lb as zp,lg as Mv,lo as GA,lt as MO,lu as $O,ly as Vr,m as PO,mD as YA,mE as Tb,mS as DO,mT as Up,m_ as Eb,mb as As,mg as LO,mm as JA,mn as OO,mo as Gg,mt as XA,mu as J0,my as Hr,nE as qi,nS as qO,nT as Ic,n_ as BO,ng as FO,nj as zO,nk as UO,nl as ZA,nu as X0,nv as e1,oD as WO,oS as KO,o_ as ef,og as VO,oo as HO,op as hd,os as Yg,ou as QO,ov as tf,p as $v,pC as t1,pD as GO,pE as mn,pO as YO,pT as nr,p_ as JO,pf as Z0,pg as ex,pm as Wp,pn as Pv,po as XO,pu as ZO,pv as Li,pw as eq,qC as fi,qT as s1,qg as jl,qh as tq,ql as n1,qn as Oj,qp as xi,qr as r1,qt as sq,qw as dm,r as a1,rC as i1,rE as nq,rS as qn,rT as yi,r_ as rq,rb as $r,rg as aq,rl as qj,ru as o1,rv as _d,rw as iq,rx as qu,sC as id,sD as oq,sE as lq,sS as cq,s_ as l1,sb as dq,sg as Dv,so as Bj,ss as Mb,st as tx,su as ro,sv as uq,sy as Qr,t as Fj,tD as mq,tS as hq,tT as vr,t_ as fq,tg as pq,ti as gq,tk as xq,tl as Sh,tu as bq,ty as fd,uC as yq,uD as vq,uE as We,uO as zj,uS as Uj,u_ as c1,ub as Sn,ug as gc,uk as d1,uo as wq,uu as kq,uy as Na,vC as u1,vS as jq,vT as Bu,vb as wa,vg as Nq,vm as m1,vn as vd,vo as h1,vu as Wj,vv as f1,w as Iq,wE as Sq,wS as sx,wT as sf,wb as um,wg as nx,wo as p1,wu as zm,wv as Lv,wy as _q,x as _t,xE as Te,xS as ra,xT as nf,x_ as Jg,xb as ka,xg as Kj,xk as Cq,xn as Aq,xo as g1,xu as Vj,xv as nc,xw as Rq,yA as Tq,yE as Xg,y_ as Kp,yb as ja,yg as Cf,yk as Eq,yo as Ov,yu as Um,yv as x1,yw as Zg,z as Mq,zC as Oi,zE as E,zT as b1,z_ as y1,zb as Bi,zg as Wm,zm as v1,zo as $q,zt as Pq,zv as Dq,zw as w1,zx as Hj,zy as Qj}from"./index-Bt31d8ga.js";var k1=["daily","weekdays","weekly","monthly"],xc=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];var Lq=["accepted","declined","withdrawn","issue_closed","addressee_deleted","skipped"],Oq=/^([01]\d|2[0-3]):([0-5]\d)$/,e0=lt({frequency:fs(k1),dayOfWeek:fs(xc).optional().nullable(),dayOfMonth:In().int().min(1).max(28).optional().nullable(),time:he().regex(Oq,"time must be 24-hour HH:MM, for example 09:00")}).strict().superRefine((e,t)=>{e.frequency==="weekly"&&!e.dayOfWeek&&t.addIssue({code:"custom",path:["dayOfWeek"],message:"A weekly routine needs dayOfWeek"}),e.frequency==="monthly"&&!e.dayOfMonth&&t.addIssue({code:"custom",path:["dayOfMonth"],message:"A monthly routine needs dayOfMonth (1-28)"})}),Gj=a(e=>!e.includes("{{"),"NO_PLACEHOLDERS$1"),Yj="Write the text out in full; scheduled routines cannot use {{placeholders}}",iue=lt({title:he().trim().min(1).max(200).refine(Gj,Yj),instructions:he().trim().min(1).max(1e4).refine(Gj,Yj),cadence:e0,message:he().trim().min(1).max(500).optional().nullable()}).strict(),oue=lt({timezone:he().trim().min(1).max(100).optional()}).strict(),lue=lt({}).strict(),cue=lt({version:$n(1),title:he(),instructions:he(),message:he().nullable(),cadence:e0,cadenceLabel:he(),cronExpression:he(),assigneeAgentId:he(),projectId:he().nullable()}),due=lt({version:$n(1),outcome:fs(Lq),reason:he().nullable().optional(),routineId:he().nullable().optional(),routineTitle:he().nullable().optional(),cadenceLabel:he().nullable().optional(),timezone:he().nullable().optional(),responsibilityIds:dn(he()).optional()});function j1(e){const[t,n]=e.time.split(":").map(r=>Number(r));return{...e,hour:t,minute:n}}a(j1,"normalizedCadence");function qq(e){const{frequency:t,hour:n,minute:r,dayOfWeek:i,dayOfMonth:o}=j1(e);switch(t){case"daily":return`${r} ${n} * * *`;case"weekdays":return`${r} ${n} * * 1-5`;case"weekly":return`${r} ${n} * * ${xc.indexOf(i)}`;case"monthly":return`${r} ${n} ${o} * *`}}a(qq,"routineSuggestionCronExpression");function Bq(e,t){const n=e<12?"AM":"PM",r=e%12===0?12:e%12;return t===0?`${r} ${n}`:`${r}:${String(t).padStart(2,"0")} ${n}`}a(Bq,"clockLabel");function Fq(e){const t=e%100;if(t>=11&&t<=13)return`${e}th`;switch(e%10){case 1:return`${e}st`;case 2:return`${e}nd`;case 3:return`${e}rd`;default:return`${e}th`}}a(Fq,"ordinal");function zq(e){const{frequency:t,hour:n,minute:r,dayOfWeek:i,dayOfMonth:o}=j1(e),l=`at ${Bq(n,r)}`;switch(t){case"daily":return`Every day ${l}`;case"weekdays":return`Every weekday ${l}`;case"weekly":return`Every ${i.charAt(0).toUpperCase()}${i.slice(1)} ${l}`;case"monthly":return`On the ${Fq(o)} of every month ${l}`}}a(zq,"routineSuggestionCadenceLabel");var uue=["manual","some_automated","mostly_automated","automated"],mue={manual:"Manual",some_automated:"Some automated",mostly_automated:"Mostly automated",automated:"Automated"};function hue(e){return e===null?null:Math.round(e*100)}a(hue,"responsibilityAutomationPercent");var fue={schedule:"On a schedule",webhook:"From a webhook",standing_check:"Standing check"},Uq=["ing","ed","es","s"];function Fu(e){let t=e.toLowerCase();for(const n of Uq)if(t.endsWith(n)&&t.length-n.length>=3){t=t.slice(0,-n.length);break}return t.endsWith("e")&&t.length>3?t.slice(0,-1):t}a(Fu,"normalizeWord");function Wq(e){return e.split(/[^A-Za-z0-9]+/).filter(Boolean).map(t=>({raw:t,stem:Fu(t)}))}a(Wq,"titleTokens");var Kq=["daily","nightly","hourly","weekly","biweekly","fortnightly","monthly","quarterly","yearly","annual","annually","weekday","weekdays",...xc],Vq=["day","morning","evening","night","week","weekday","month","quarter","year","hour",...xc],Hq=["report","review","audit","reconcile","reconciliation","digest","recap","roundup","newsletter","standup"],Qq=["when","new","incoming","inbound","reply","replies","request","ticket","alert","submitted","submission","signup","triage"],Gq=["monitor","ensure","chase","waiting","waited","overdue","stale","followup"],Yq=["update","digest","recap","report","newsletter","summary","roundup"],mm=a(e=>new Set(e.map(Fu)),"stems"),pue=mm(Kq),gue=mm(Vq),xue=mm(Hq),bue=mm(Qq),yue=mm(Gq),vue=mm(Yq),wue=Fu("send"),Jl={frequency:"weekly",dayOfWeek:"monday",dayOfMonth:null,time:"09:00"},Am=Jl.time,Jq=new Map(xc.map(e=>[Fu(e),e]));function Xq(e){const t=Wq(e).map(o=>o.stem),n=a((...o)=>o.some(l=>t.includes(Fu(l))),"has"),r=t.map(o=>Jq.get(o)).find(Boolean);if(r)return{frequency:"weekly",dayOfWeek:r,dayOfMonth:null,time:Am};if(n("weekday"))return{frequency:"weekdays",dayOfWeek:null,dayOfMonth:null,time:Am};const i=t.some((o,l)=>(o==="every"||o==="each")&&["day","morning"].map(Fu).includes(t[l+1]??""));return n("daily","nightly")||i?{frequency:"daily",dayOfWeek:null,dayOfMonth:null,time:Am}:n("weekly","week")?{frequency:"weekly",dayOfWeek:"monday",dayOfMonth:null,time:Am}:n("monthly","month")?{frequency:"monthly",dayOfWeek:null,dayOfMonth:1,time:Am}:null}a(Xq,"suggestCadenceFromTitle");var $b=a(e=>!e.includes("{{"),"NO_PLACEHOLDERS"),Jj="Write the text out in full; automations cannot use {{placeholders}}",kue=lt({title:he().trim().min(1).max(200).refine($b,"Write the title out in full; scheduled routines cannot use {{placeholders}}"),cadence:e0,assigneeAgentId:he().uuid(),timezone:he().trim().min(1).max(100).optional()}).strict(),Zq=Lg("kind",[lt({kind:$n("schedule"),cadence:e0}).strict(),lt({kind:$n("webhook"),caller:he().trim().min(1).max(500)}).strict(),lt({kind:$n("standing_check"),lookFor:he().trim().min(1).max(1e3),whenFound:he().trim().min(1).max(1e3)}).strict()]),jue=lt({title:he().trim().min(1).max(200).refine($b,Jj),instructions:he().trim().min(1).max(1e4).refine($b,Jj),trigger:Zq,message:he().trim().min(1).max(500).optional().nullable()}).strict(),Nue=lt({timezone:he().trim().min(1).max(100).optional()}).strict(),Iue=lt({}).strict(),Sue=lt({agentId:he().uuid().optional(),responsibilityId:he().uuid().optional()}).strict(),eB=["accepted","declined","replaced","issue_closed","withdrawn","addressee_deleted"],tB=lt({frequency:fs(["daily","weekdays","weekly","monthly"]),dayOfWeek:fs(xc).nullable().optional(),dayOfMonth:In().int().nullable().optional(),time:he()}),_ue=lt({version:$n(1),sourceIssueId:he(),sourceIdentifier:he().nullable(),sourceTitle:he(),title:he(),instructions:he(),message:he().nullable(),trigger:Lg("kind",[lt({kind:$n("schedule"),cadence:tB,cadenceLabel:he(),cronExpression:he()}),lt({kind:$n("webhook"),caller:he()}),lt({kind:$n("standing_check"),lookFor:he(),whenFound:he()})]),startLabel:he(),assigneeAgentId:he(),agentName:he(),projectId:he().nullable(),filedUnder:dn(lt({id:he(),title:he()}))}),Cue=lt({version:$n(1),outcome:fs(eB),reason:he().nullable().optional(),replacedByInteractionId:he().nullable().optional(),routineId:he().nullable().optional(),routineTitle:he().nullable().optional(),triggerId:he().nullable().optional(),cadenceLabel:he().nullable().optional(),timezone:he().nullable().optional(),webhookUrl:he().nullable().optional(),signingMode:he().nullable().optional(),responsibilityIds:dn(he()).optional()}),hm=["number","percent","line","bar"],sB={number:"Large number",percent:"Percentage",line:"Line over time",bar:"Bars per week"};function nB(e,t){return e==="percentage"?"percent":e==="yes_no"?"number":t>=2?"line":"number"}a(nB,"defaultPrimaryDisplay");var qv=In().finite().min(-1e15).max(1e15),rB=6e4,aB=lt({value:qv,recordedAt:he().datetime({offset:!0})}).strict();function Xj(e){return e!=null&&(e<0||e>100)}a(Xj,"percentIssue");var N1=lt({title:he().trim().min(1).max(120),description:he().trim().min(1).max(300),display:fs(hm),unit:he().trim().min(1).max(40).optional().nullable(),target:qv.optional().nullable(),direction:fs(Qg).optional().nullable(),readings:dn(aB).max(12).optional(),readingsEvidence:he().trim().min(1).max(500).optional().nullable()}).strict().superRefine((e,t)=>{e.display==="percent"&&(e.unit&&e.unit!=="%"&&t.addIssue({code:"custom",path:["unit"],message:"A percent metric's unit is always %"}),Xj(e.target)&&t.addIssue({code:"custom",path:["target"],message:"A percent target is a share from 0 to 100"}),e.readings?.forEach((r,i)=>{Xj(r.value)&&t.addIssue({code:"custom",path:["readings",i,"value"],message:"A percent reading is a share from 0 to 100"})})),(e.direction??null)!==null&&(e.target??null)===null&&t.addIssue({code:"custom",path:["direction"],message:"A direction needs a target; leave both out when there is none"});const n=Date.now()+rB;e.readings?.forEach((r,i)=>{new Date(r.recordedAt).getTime()>n&&t.addIssue({code:"custom",path:["readings",i,"recordedAt"],message:"A reading cannot be in the future"})})}),iB=lt({title:he(),description:he(),display:fs(hm),unit:he().nullable(),target:In().nullable(),direction:fs(Qg).nullable(),readings:dn(lt({value:In(),recordedAt:he()})),readingsEvidence:he().nullable()}),Aue=lt({primaryDisplay:fs(hm).optional().nullable(),metrics:dn(N1).max(2)}).strict(),Rue=lt({value:Iv([qv,kl()]),recordedAt:he().datetime({offset:!0}).optional(),readingId:he().uuid().optional(),note:he().trim().min(1).max(500).optional().nullable()}).strict();function Pb(e){switch(e){case"percentage":return["percent","line","bar","number"];case"yes_no":return["number"];case"volume":case"range":return["number","line","bar"]}}a(Pb,"primaryDisplaysFor");var I1=["number","percent","yes_no","trend","per_week"],Tue={number:"Number",percent:"Percent",yes_no:"Yes / No",trend:"Trend",per_week:"Per week"};function Db(e){if(e.kind==="yes_no")return"yes_no";switch(e.display){case"number":return"number";case"percent":return"percent";case"line":return"trend";case"bar":return"per_week"}}a(Db,"responsibilityVisualizationOf");function Eue(e){switch(e){case"number":case"yes_no":return"number";case"percent":return"percent";case"trend":return"line";case"per_week":return"bar"}}a(Eue,"responsibilityVisualizationDisplay");function oB(e){let t;e.role==="primary"&&e.kind?t=e.kind==="range"?["number","line"]:Pb(e.kind):t=e.display==="percent"||e.unit?.trim()==="%"?["percent","line","bar","number"]:["number","line","bar"];const n=a(r=>I1.indexOf(Db({display:r,kind:e.role==="primary"?e.kind:null})),"order");return[...t].sort((r,i)=>n(r)-n(i))}a(oB,"responsibilityMetricDisplaysFor");function Mue(e){const t=e.role==="primary"?e.kind??null:null,n=new Set(oB(e).map(r=>Db({display:r,kind:t})));return n.add(Db({display:e.display,kind:t})),I1.filter(r=>n.has(r))}a(Mue,"responsibilityVisualizationsFor");var $ue=lt({display:fs(hm)}).strict(),Bv=["volume","percentage","yes_no","range"],lB=["metricUnit","metricDirection","metricTarget","metricLow","metricHigh"],zu={volume:{kind:"volume",label:"Volume",summary:"A count or amount that should be at least, or at most, a target.",whenItFits:"Something you count or add up: replies owed, deals in the pipeline, days to close, open bugs, revenue. at_least when more is better, at_most when it should stay down.",fields:["metricUnit","metricDirection","metricTarget"],required:["metricTarget"],readingHelp:"the current count or amount, as a number",example:{standard:"No escalated ticket waits a full day for a first reply.",metricName:"Escalated tickets waiting over a day",metricDirection:"at_most",metricTarget:0}},percentage:{kind:"percentage",label:"Percentage",summary:"A share from 0 to 100 that should be at least, or at most, a target.",whenItFits:"A share of a whole: the part of investors contacted this fortnight, invoices paid on time, churned customers. The unit is always %.",fields:["metricDirection","metricTarget"],required:["metricTarget"],readingHelp:"the current share as a number from 0 to 100",example:{standard:"Every prospective LP hears from us at least every two weeks.",metricName:"Prospective LPs contacted in the last 14 days",metricDirection:"at_least",metricTarget:90}},yes_no:{kind:"yes_no",label:"Yes or no",summary:"A state that is either true or not. Yes is on track; no is behind.",whenItFits:"A commitment that is simply kept or not, with nothing to count: the board pack went out a week before the meeting, payroll was approved by the 25th. The metric name is the statement that should be true.",fields:[],required:[],readingHelp:"true when the statement holds today, false when it does not",example:{standard:"Directors get the board pack a full week before every meeting.",metricName:"Board pack sent a week before the next meeting"}},range:{kind:"range",label:"Range",summary:"A value that should stay between a low and a high bound.",whenItFits:"A level that is wrong when too low and wrong when too high: runway in months, inventory on hand, team utilisation, cash in the operating account.",fields:["metricUnit","metricLow","metricHigh"],required:["metricLow","metricHigh"],readingHelp:"the current value, as a number",example:{standard:"We always have between 12 and 24 months of runway.",metricName:"Runway",metricUnit:"months",metricLow:12,metricHigh:24}}};function cB(e){return typeof e=="string"&&Bv.includes(e)}a(cB,"isResponsibilityMetricKind");function Fv(e,t){return cB(e)?e:t?.trim()==="%"?"percentage":"volume"}a(Fv,"resolveResponsibilityMetricKind");function S1(e){return Math.round(e*1e4)/1e4}a(S1,"round4");function dB(e,t,n){if(t===null||n===null||!Number.isFinite(t)||!Number.isFinite(n))return null;let r;return e==="at_most"?r=t>0&&n>0?t/n:n<=t?1:0:r=t>0?Math.max(0,n/t):n>=t?1:0,S1(r)}a(dB,"directionalAttainment");function uB(e,t){if(t===null||!Number.isFinite(t))return null;switch(e.kind){case"volume":case"percentage":return dB(e.direction??"at_least",e.target,t);case"yes_no":return t===1?1:0;case"range":{const{low:n,high:r}=e;if(n===null||r===null||!(r>n))return null;if(t>=n&&t<=r)return 1;const i=t<n?n-t:t-r;return S1(Math.max(0,1-i/(r-n)))}}}a(uB,"responsibilityAttainment");var Zj=new Intl.NumberFormat("en-US",{maximumFractionDigits:2});function mB(e){return!/[A-Za-z]/.test(e)}a(mB,"isSymbolUnit");function eN(e,t,n=!0){const r=Zj.format(e);return t?t==="%"?`${r}%`:mB(t)?e<0?`-${t}${Zj.format(-e)}`:`${t}${r}`:n?`${r} ${t}`:r:r}a(eN,"formatResponsibilityMetricValue");function _1(e){return e.kind==="percentage"?"%":e.kind==="yes_no"?null:e.unit?.trim()||null}a(_1,"displayUnit");function hB(e){const t=_1(e);return t!==null&&!e.name.toLowerCase().includes(t.toLowerCase())}a(hB,"wordUnitOk");var tN=1e-9;function C1(e){const t=_1(e),n=hB(e),r=a(i=>eN(i,t,n),"fmt");switch(e.kind){case"yes_no":return"On track when the answer is yes; behind when it is no";case"range":{const{low:i,high:o}=e;if(i===null||o===null||!(o>i))return null;const l=(o-i)*(1-W0);return`On track between ${eN(i,t,!1)} and ${r(o)}; at risk up to ${r(l)} outside it; behind further out`}case"volume":case"percentage":{const i=e.target;if(i===null)return null;const o=e.kind==="percentage";if(e.direction==="at_most"){if(i<=0)return`On track at ${r(i)} or less; behind above that`;const c=i/W0;return`On track at ${r(i)} or less; at risk up to ${r(o?Math.floor(c+tN):c)}`}if(i<=0)return`On track at ${r(i)} or more; behind below that`;const l=i*W0;return`On track at ${r(i)} or more; at risk from ${r(o?Math.ceil(l-tN):l)}`}}}a(C1,"responsibilityStatusRule");var vp=In().finite().min(-1e15).max(1e15),fB=Iv([vp,kl()]),pB=he().trim().min(1).max(40),gB=he().trim().min(1).max(200),xB={metricUnit:"a unit",metricDirection:"a direction",metricTarget:"a target",metricLow:"a low bound",metricHigh:"a high bound"},bB={volume:"A volume bar has a target and a direction, not a range; use the range template for low and high bounds",percentage:"A percentage bar has a target and a direction, not a range or another unit (its unit is always %)",yes_no:"A yes-or-no bar has no unit, direction, target or range: yes is on track and no is behind",range:"A range bar has a low and a high bound instead of a target and a direction"};function ku(e){return e!=null}a(ku,"present");function yB(e,t){return t==null?null:e==="yes_no"?typeof t=="boolean"||t===0||t===1?null:"A yes-or-no reading is true or false (or 1 or 0)":typeof t=="boolean"?"metricCurrent is true or false only for a yes-or-no bar; send the reading as a number":e==="percentage"&&(t<0||t>100)?"A percentage reading is a share from 0 to 100":null}a(yB,"responsibilityReadingIssue");function vB(e,t){const n=e.metricKind,r=zu[n],i=[];for(const l of lB){const c=e[l];if(!ku(c)){t.complete&&r.required.includes(l)&&i.push({field:l,message:`A ${r.label.toLowerCase()} bar needs ${xB[l]} (${l})`});continue}if(l==="metricUnit"&&n==="percentage"){String(c).trim()!=="%"&&i.push({field:l,message:"A percentage bar's unit is always %"});continue}if(!r.fields.includes(l)){i.push({field:l,message:bB[n]});continue}l==="metricUnit"&&n==="volume"&&String(c).trim()==="%"&&i.push({field:l,message:"A share belongs in the percentage template; a volume's unit cannot be %"})}n==="percentage"&&ku(e.metricTarget)&&(e.metricTarget<0||e.metricTarget>100)&&i.push({field:"metricTarget",message:"A percentage target is a share from 0 to 100"}),n==="range"&&ku(e.metricLow)&&ku(e.metricHigh)&&!(e.metricHigh>e.metricLow)&&i.push({field:"metricHigh",message:"A range's high bound (metricHigh) must be above its low bound (metricLow)"});const o=yB(n,e.metricCurrent);return o&&i.push({field:"metricCurrent",message:o}),i}a(vB,"responsibilityBarIssues");function wB(e){return!!e.metricName?.trim()||[e.metricTarget,e.metricLow,e.metricHigh,e.metricCurrent].some(t=>t!=null)}a(wB,"responsibilityHasMetric");function kB(e,t={}){if(t.barOptional&&!wB(e))return[];const n=[];e.standard?.trim()||n.push("standard"),e.metricName?.trim()||n.push("metricName");const r=Fv(e.metricKind,e.metricUnit);for(const i of zu[r].required){const o=e[i];o==null&&n.push(i)}return n}a(kB,"responsibilityBarMissingForActive");var jB=["accepted","declined","replaced","issue_closed","withdrawn","addressee_deleted"],NB=he().trim().min(1).max(1e3),Pue=lt({standard:NB,metricKind:fs(Bv),metricName:gB,metricUnit:pB.optional().nullable(),metricDirection:fs(Qg).optional().nullable(),metricTarget:vp.optional().nullable(),metricLow:vp.optional().nullable(),metricHigh:vp.optional().nullable(),metricCurrent:fB.optional().nullable(),currentEvidence:he().trim().min(1).max(1e3).optional().nullable(),message:he().trim().min(1).max(500).optional().nullable(),primaryDisplay:fs(hm).optional().nullable(),metrics:dn(N1).max(2).optional()}).strict().superRefine((e,t)=>{for(const r of vB(e,{complete:!0}))t.addIssue({code:"custom",path:[r.field],message:r.message});ku(e.metricCurrent)&&!e.currentEvidence&&t.addIssue({code:"custom",path:["currentEvidence"],message:"Say how you got the reading in currentEvidence, or leave metricCurrent out"}),ku(e.primaryDisplay)&&!Pb(e.metricKind).includes(e.primaryDisplay)&&t.addIssue({code:"custom",path:["primaryDisplay"],message:`A ${zu[e.metricKind].label.toLowerCase()} bar's metric can be drawn as ${Pb(e.metricKind).join(", ")}`});const n=new Set([e.metricName.trim().toLowerCase()]);e.metrics?.forEach((r,i)=>{(r.readings?.length??0)>0&&!r.readingsEvidence&&t.addIssue({code:"custom",path:["metrics",i,"readingsEvidence"],message:"Say how you got the starting readings in readingsEvidence, or leave readings out"});const o=r.title.trim().toLowerCase();n.has(o)&&t.addIssue({code:"custom",path:["metrics",i,"title"],message:"Each metric measures something different: this title repeats the bar's metric or another supporting metric"}),n.add(o)})}),Due=lt({keepMetrics:dn(In().int().min(0).max(1)).max(2).refine(e=>new Set(e).size===e.length,"Each kept metric is listed once").optional()}).strict(),Lue=lt({}).strict(),Oue=lt({agentId:he().uuid().optional()}).strict(),que=lt({version:$n(1),responsibilityId:he(),responsibilityTitle:he(),bar:lt({standard:he(),metricKind:fs(Bv),metricName:he(),metricUnit:he().nullable(),metricDirection:fs(Qg).nullable(),metricTarget:In().nullable(),metricLow:In().nullable(),metricHigh:In().nullable()}),metricCurrent:In().nullable(),currentEvidence:he().nullable(),message:he().nullable(),templateLabel:he(),targetLabel:he(),readingLabel:he().nullable(),statusRule:he(),preview:lt({health:fs(ZD),statusSentence:he()}).nullable(),primaryDisplay:fs(hm).nullable().optional(),metrics:dn(iB).nullable().optional()}),Bue=lt({version:$n(1),outcome:fs(jB),reason:he().nullable().optional(),replacedByInteractionId:he().nullable().optional(),responsibilityId:he().nullable().optional(),droppedMetrics:dn(he()).nullable().optional()});function IB(e){return{kind:e.metricKind,name:e.metricName,unit:e.metricUnit,direction:e.metricDirection,target:e.metricTarget,low:e.metricLow,high:e.metricHigh}}a(IB,"responsibilityBarMetricFromProposal");var A1=["create","edit"];var SB=["add_area","rename_area","remove_area","add_responsibility","reword_responsibility","move_responsibility","remove_responsibility"],R1=he().trim().min(1).max(200),T1=he().trim().min(1).max(200),rf=he().trim().min(1).max(300).optional().nullable(),E1=he().trim().min(1,"Say why in one line (reason)").max(300),zv=he().trim().min(1).max(40),Cd=he().uuid(),_B=lt({op:$n("add_area"),ref:zv,name:R1,reason:rf}).strict(),CB=lt({op:$n("rename_area"),areaId:Cd,name:R1,reason:rf}).strict(),AB=lt({op:$n("remove_area"),areaId:Cd,reason:E1}).strict(),RB=lt({op:$n("add_responsibility"),areaId:Cd.optional(),areaRef:zv.optional(),sentence:T1,reason:rf}).strict(),TB=lt({op:$n("reword_responsibility"),responsibilityId:Cd,sentence:T1,reason:rf}).strict(),EB=lt({op:$n("move_responsibility"),responsibilityId:Cd,areaId:Cd.optional(),areaRef:zv.optional(),reason:rf}).strict(),MB=lt({op:$n("remove_responsibility"),responsibilityId:Cd,reason:E1}).strict(),$B=Lg("op",[_B,CB,AB,RB,TB,EB,MB]);function PB(e){const t=[],n=new Map,r=new Set,i=new Map,o=new Map,l=new Map,c=a((d,m,h)=>{const f=d.get(m)??new Set;return f.add(h),d.set(m,f),f},"note");e.forEach((d,m)=>{if(d.op==="add_area"){n.has(d.ref)&&t.push({index:m,message:`Two new areas use the ref "${d.ref}"; give each its own`}),n.set(d.ref,m);const h=d.name.trim().toLowerCase();r.has(h)&&t.push({index:m,message:`"${d.name}" is added twice`}),r.add(h);return}if(d.op==="add_responsibility"||d.op==="move_responsibility"){const h=d.areaId!==void 0&&d.areaRef!==void 0,f=d.areaId===void 0&&d.areaRef===void 0;(h||f)&&t.push({index:m,message:"Name the area with exactly one of areaId (an existing area) or areaRef (a new one added earlier in this list)"}),d.areaRef!==void 0&&!n.has(d.areaRef)&&t.push({index:m,message:`No add_area earlier in this list has the ref "${d.areaRef}"`}),d.areaId&&c(o,d.areaId,d.op)}if(d.op==="rename_area"||d.op==="remove_area"){const h=l.get(d.areaId)??[];h.includes(d.op)&&t.push({index:m,message:d.op==="rename_area"?"This area is renamed twice":"This area is removed twice"}),h.includes(d.op==="rename_area"?"remove_area":"rename_area")&&t.push({index:m,message:"An area cannot be renamed and removed in the same proposal"}),h.push(d.op),l.set(d.areaId,h),c(o,d.areaId,d.op)}if("responsibilityId"in d){const h=i.get(d.responsibilityId)??new Set;h.has(d.op)&&t.push({index:m,message:"This responsibility already has that change in this proposal"}),(d.op==="remove_responsibility"?h.size>0:h.has("remove_responsibility"))&&t.push({index:m,message:"A responsibility that is removed cannot also be reworded or moved"}),h.add(d.op),i.set(d.responsibilityId,h)}});for(const[d,m]of o)if(m.has("remove_area")&&(m.has("add_responsibility")||m.has("move_responsibility"))){const h=e.findIndex(f=>f.op==="remove_area"&&f.areaId===d);t.push({index:h,message:"An area that is removed cannot also receive a responsibility"})}return t}a(PB,"responsibilityDashboardChangeSetIssues");var Fue=lt({message:he().trim().min(1).max(500).optional().nullable(),changes:dn($B).min(1).max(60)}).strict().superRefine((e,t)=>{for(const n of PB(e.changes))t.addIssue({code:"custom",path:["changes",n.index],message:n.message})}),zue=lt({keep:dn(In().int().min(0).max(59)).min(1,"Keep at least one change, or say the proposal is not right").max(60).refine(e=>new Set(e).size===e.length,"Each kept change is listed once").optional()}).strict(),Uue=lt({}).strict(),Wue=lt({mode:fs(A1),ownerUserId:he().trim().min(1).optional(),agentId:he().uuid().optional()}).strict(),Kue=lt({}).strict(),Vue=lt({ownerUserId:he().trim().min(1).optional()}),DB=["accepted","declined","replaced","issue_closed","withdrawn","addressee_deleted"],LB=lt({index:In().int().min(0),op:fs(SB),reason:he().nullable(),dependsOn:dn(In().int().min(0)),groupAreaId:he().nullable(),groupRef:he().nullable(),groupName:he(),name:he().nullable(),fromName:he().nullable(),responsibilityId:he().nullable(),sentence:he().nullable(),fromSentence:he().nullable(),fromAreaId:he().nullable(),fromAreaName:he().nullable(),lettingGo:dn(lt({id:he(),sentence:he()})),sharedWith:In().int().min(0)}),Hue=lt({version:$n(1),ownerUserId:he(),mode:fs(A1),message:he().nullable(),changes:dn(LB).min(1)}),Que=lt({version:$n(1),outcome:fs(DB),reason:he().nullable().optional(),replacedByInteractionId:he().nullable().optional(),dropped:dn(In().int()).nullable().optional(),versionId:he().nullable().optional(),previousVersionId:he().nullable().optional(),summary:he().nullable().optional()});function OB(e,t){const n=new Set([t]);let r=!0;for(;r;){r=!1;for(const i of e)!n.has(i.index)&&i.dependsOn.some(o=>n.has(o))&&(n.add(i.index),r=!0)}return[...n].sort((i,o)=>i-o)}a(OB,"dashboardChangesDroppedWith");function qB(e,t){const n=new Map(e.map(o=>[o.index,o])),r=new Set,i=a(o=>{if(!r.has(o)){r.add(o);for(const l of n.get(o)?.dependsOn??[])i(l)}},"visit");return i(t),[...r].sort((o,l)=>o-l)}a(qB,"dashboardChangesKeptWith");var Gue=lt({version:$n(1),areas:dn(lt({id:he(),title:he(),status:he(),sortOrder:In(),description:he().nullable().optional()})),responsibilities:dn(lt({id:he(),title:he(),standard:he().nullable(),areaId:he().nullable(),status:he(),sortOrder:In(),links:lt({projectIds:dn(he()),issueIds:dn(he()),routineIds:dn(he()),skillIds:dn(he()).optional()}).optional(),description:he().nullable().optional(),runByAgentId:he().nullable().optional(),evidence:he().nullable().optional(),healthOverride:he().nullable().optional(),healthNote:he().nullable().optional()})),createdAreaIds:dn(he()).default([])});function Vp(e){const t=new Set([e.targetIssueId]);if(e.type==="create_issue"){e.draft.parentId&&t.add(e.draft.parentId);for(const n of e.draft.blockedByIssueIds??[])t.add(n)}if(e.type==="resolve_blocker")for(const n of e.removeBlockedByIssueIds)t.add(n);return[...t]}a(Vp,"decisionEffectTargetIssueIds");var BB=new Set(["terminated","pending_approval","paused"]),FB=new Set(["active","idle","running","error"]);function zB(e){return FB.has(e)&&!BB.has(e)}a(zB,"isAgentStatusInvokable");var UB=128;function WB(e){return new TextEncoder().encode(e).length}a(WB,"utf8ByteLength");var M1=fs(["execution_workspace","project_workspace"]),Uv=fs(["auto","execution","project"]).default("auto"),KB=fs(["all","recent","changed"]).default("all"),VB=fs(["text","image","video","pdf","unsupported"]),HB=fs(["file","directory","remote_resource"]),$1=lt({kind:$n("workspace_file"),issueId:he().guid().optional(),projectId:he().guid().optional(),projectName:he().min(1).optional(),workspaceKind:M1,workspaceId:he().guid(),relativePath:he().min(1),line:In().int().positive().nullable().optional(),column:In().int().positive().nullable().optional(),displayPath:he().min(1)}),QB=lt({projectId:he().guid().optional(),workspaceId:he().guid().optional(),path:he().min(1).refine(e=>!/[\x00-\x1f\x7f]/.test(e),{message:"Workspace file path contains an invalid character",params:{code:"invalid_path"}}),workspace:Uv.optional()}).refine(e=>!!e.projectId==!!e.workspaceId,{message:"Workspace file target requires both projectId and workspaceId",path:["workspaceId"],params:{code:"invalid_target"}}),Yue=lt({queries:dn(QB).max(100)}),Jue=lt({projectId:he().guid().optional(),workspaceId:he().guid().optional(),workspace:Uv.optional(),path:he().min(1).refine(e=>!/[\x00-\x1f\x7f]/.test(e),{message:"Workspace folder path contains an invalid character",params:{code:"invalid_path"}}).optional(),mode:KB.optional(),q:he().refine(e=>!/[\x00-\x1f\x7f]/.test(e),{message:"Workspace file search contains an invalid character",params:{code:"invalid_query"}}).refine(e=>WB(e.trim())<=UB,{message:"Workspace file search is too long",params:{code:"invalid_query"}}).optional(),limit:Nj().int().min(1).max(100).default(25),offset:Nj().int().min(0).max(1e4).default(0)}).refine(e=>!!e.projectId==!!e.workspaceId,{message:"Workspace file target requires both projectId and workspaceId",path:["workspaceId"],params:{code:"invalid_target"}}),P1=lt({source:lt({kind:fs(["live","saved"]),savedAt:he().datetime().nullable(),snapshotId:he().guid().nullable()}).optional(),kind:HB,provider:he().min(1),title:he().min(1),displayPath:he().min(1),workspaceLabel:he().min(1),workspaceKind:M1,workspaceId:he().guid(),projectId:he().guid().nullable().optional(),projectName:he().min(1).nullable().optional(),contentType:he().nullable().optional(),byteSize:In().int().nonnegative().nullable().optional(),previewKind:VB,denialReason:he().nullable().optional(),capabilities:lt({preview:kl(),download:kl(),listChildren:kl()})}),GB=lt({projectId:he().guid().nullable(),workspaceId:he().guid().nullable(),path:he().min(1),workspace:Uv}),YB=lt({query:GB,openable:kl(),unavailableReason:he().min(1).nullable().optional(),resource:P1.nullable()}),Xue=lt({kind:$n("workspace_file_availability"),results:dn(YB).max(100)}),Zue=lt({resource:P1,content:lt({encoding:fs(["utf8","base64"]),data:he()})});function JB(e){return`/api/attachments/${e}/content`}a(JB,"attachmentContentPath");var XB=fs(["preview_url","runtime_service","pull_request","branch","commit","artifact","document"]),ZB=fs(["active","ready_for_review","approved","changes_requested","merged","closed","failed","archived","draft"]),eF=fs(["none","needs_board_review","approved","changes_requested"]),D1=lt({attachmentId:he().guid(),contentType:he().min(1),byteSize:In().int().nonnegative(),contentPath:he().min(1),openPath:he().min(1),downloadPath:he().min(1),originalFilename:he().optional().nullable()}).superRefine((e,t)=>{const n=JB(e.attachmentId);e.contentPath!==n&&t.addIssue({code:H0.custom,path:["contentPath"],message:"contentPath must point to the same-origin attachment content route"}),e.openPath!==n&&t.addIssue({code:H0.custom,path:["openPath"],message:"openPath must point to the same-origin attachment content route"}),e.downloadPath!==`${n}?download=1`&&t.addIssue({code:H0.custom,path:["downloadPath"],message:"downloadPath must point to the same-origin attachment download route"})}),tF=lt({resourceRef:$1.optional().nullable()}).passthrough(),sF=lt({projectId:he().guid().optional().nullable(),executionWorkspaceId:he().guid().optional().nullable(),runtimeServiceId:he().guid().optional().nullable(),type:XB,provider:he().min(1),externalId:he().optional().nullable(),title:he().min(1),url:he().url().optional().nullable(),status:ZB.default("active"),reviewState:eF.optional().default("none"),isPrimary:kl().optional().default(!1),healthStatus:fs(["unknown","healthy","unhealthy"]).optional().default("unknown"),summary:he().optional().nullable(),metadata:tF.optional().nullable(),createdByRunId:he().guid().optional().nullable()}),eme=UO(sF).partial(),nF=["text/markdown","text/x-markdown","application/markdown","application/x-markdown"],rF=new Set(nF),aF=new Set(["text/plain","application/octet-stream","binary/octet-stream","application/x-binary"]),iF=[".md",".markdown"],oF=524288,lF="artifact-review-";function cF(e){return(e??"").toLowerCase().split(";")[0]?.trim()??""}a(cF,"normalizeAttachmentContentType");function Wv(e){const t=cF(e.contentType);if(rF.has(t))return!0;const n=(e.originalFilename??"").toLowerCase();return iF.some(r=>n.endsWith(r))?aF.has(t):!1}a(Wv,"isMarkdownAttachmentContent");function Dd(e){if(e.type!=="artifact"||e.provider!=="paperclip"||!e.metadata)return null;const t=D1.safeParse(e.metadata);return t.success?t.data:null}a(Dd,"getAttachmentArtifactWorkProductMetadata");function sN(e){const t=Dd(e);return t&&Wv(t)?t:null}a(sN,"getMarkdownWorkProductAttachmentMetadata");function nN(e){return`${lF}${e}`}a(nN,"artifactReviewDocumentKey");function Ld(e){return e.startsWith("artifact-review-")&&e.length>16}a(Ld,"isArtifactReviewDocumentKey");function dF(e){return e==="RESPONSIBLE_USER_UNAUTHORIZED"||e==="RESPONSIBLE_USER_UNAVAILABLE"}a(dF,"isResponsibleUserDenialCode");function t0(e){const t=e?.trim();return t&&t.length>0?t:"the responsible user"}a(t0,"responsibleUserLabel");function Lb(e,t={}){const n=t0(t.userName);return e==="RESPONSIBLE_USER_UNAVAILABLE"?{code:e,tone:"unavailable",title:"Responsible user unavailable",description:`This run acts on behalf of ${n}, but that account was removed or deactivated, so its permissions can no longer be evaluated. The agent's own permissions are not enough on their own — every action still requires an active responsible user.`,recommendedAction:"Mark the work blocked and reassign a responsible user (or reactivate the account) before the agent continues."}:{code:e,tone:"unauthorized",title:"Responsible user not authorized",description:`This action was denied because ${n} — the user this run acts on behalf of — does not have permission to perform it. The agent may be allowed, but a run can never exceed the permissions of the user it acts for, so the action is blocked.`,recommendedAction:`Grant ${n} the required permission, or have someone who is authorized take this action instead.`}}a(Lb,"describeResponsibleUserDenial");var tme=["issue_write_not_visible","issue_write_actor_class_excluded","issue_write_responsible_user_ceiling","issue_write_responsible_user_unavailable","issue_write_assignee_run_lock","issue_status_change_live_run","cross_issue_influence_cap_exceeded","cross_issue_influence_run_context_required","issue_write_attribution_spoof_rejected"];function uF(e){const t=e?.trim();return t&&t.length>0?t:"this task"}a(uF,"issueLabel$2");function mF(e){const t=e?.trim();return t&&t.length>0?t:"the current assignee"}a(mF,"assigneeLabel");function hF(e){const t=e?.trim();return t&&t.length>0?t:"this agent"}a(hF,"actorLabel");function fF(e,t={}){const n=uF(t.issueIdentifier),r=hF(t.actorLabel),i=mF(t.assigneeLabel),o=t0(t.responsibleUserName);switch(e){case"issue_write_not_visible":return{code:e,status:403,tone:"boundary",boundary:"Issue visibility",title:"Task is outside this actor's visibility",description:`Issue writes are open by default, but only for tasks the actor can already read. ${n} is not visible to ${r}, so its comment, update, child, and assignment channels are all closed — the wall is visibility, not the write itself.`,whoCanAct:`${i}, and any agent or board member the task is visible to.`,sanctionedPath:`Ask the board to widen visibility for ${r}.`};case"issue_write_actor_class_excluded":return{code:e,status:403,tone:"boundary",boundary:"Actor-class boundary",title:"This actor class cannot write to tasks",description:`Default-open issue writes are a standard-trust privilege. Low-trust, skill-test, and task-bridge scopes keep their existing tight walls, so ${r} cannot write to ${n} no matter who it acts for.`,whoCanAct:"A standard-trust agent in this company, or a board member.",sanctionedPath:"Report the request upward and let a standard-trust agent make the write — actor-class scope cannot be widened per task."};case"issue_write_responsible_user_ceiling":{const l=Lb("RESPONSIBLE_USER_UNAUTHORIZED",{userName:t.responsibleUserName});return{code:e,status:403,tone:"boundary",boundary:"Responsible-user ceiling",title:l.title,description:`${l.description} The write to ${n} was refused for that reason.`,whoCanAct:`${o} once authorized, or anyone already permitted to write to ${n}.`,sanctionedPath:l.recommendedAction}}case"issue_write_responsible_user_unavailable":{const l=Lb("RESPONSIBLE_USER_UNAVAILABLE",{userName:t.responsibleUserName});return{code:e,status:403,tone:"boundary",boundary:"Responsible-user availability",title:l.title,description:`${l.description} The write to ${n} was refused for that reason.`,whoCanAct:`A board member, or ${r} once it has an active responsible user.`,sanctionedPath:l.recommendedAction}}case"issue_write_assignee_run_lock":return{code:e,status:409,tone:"lock",boundary:"Run checkout lock",title:"Another agent's run owns this task",description:`${i} has ${n} checked out and a run is live. Checkout and run ownership stay assignee-scoped even though writes are open, so field edits belong to the run that holds the lock until it finishes.`,whoCanAct:`${i}'s live run, or an agent holding the manage-active-checkouts permission.`,sanctionedPath:`Comment instead of patching — comments stay open and wake ${i} — or wait for the run to release the lock and retry.`};case"issue_status_change_live_run":{const l=t.issueIdentifier?.trim(),c=t.issuePath?.trim(),d=l&&c?`[${l}](${c})`:n;return{code:e,status:409,tone:"boundary",boundary:"Live run execution lock",title:"Another run is executing this task",description:`A run is live on ${n} and holds its execution lock. Changing the status would release that lock without stopping the run, so the run would keep going with no task bound to it. Agents cannot stop or interrupt another agent's run, so this status change is refused.`,whoCanAct:`A board user, or the run of ${i} that holds the lock.`,sanctionedPath:`This refusal is final: do not retry with another status, assignee or route. Reply now and send the person to ${d}. To stop the live run they use its Stop or Interrupt control there; to hold this task and the tasks under it, they open the parent task and choose More task actions, then Pause subtree. To pass a request to the running agent, comment on the task instead.`}}case"cross_issue_influence_cap_exceeded":{const l=t.cap??20,c=t.count??null;return{code:e,status:429,tone:"cap",boundary:`Per-run cross-issue cap of ${l} writes`,title:"This run has spent its cross-issue write budget",description:`A single heartbeat run may make at most ${l} cross-issue comments or task updates combined${c!==null?`; this was attempt ${c}`:""}. The cap bounds runaway comment sprays and loops — it is a rate backstop, not a permission decision, so ${r} is still allowed to write to ${n}.`,whoCanAct:`${r} on its next heartbeat run, or ${i} on ${n} directly.`,sanctionedPath:"Consolidate what is left into one comment on your own task, or end the run and continue on the next heartbeat — the budget resets per run."}}case"cross_issue_influence_run_context_required":return{code:e,status:403,tone:"boundary",boundary:"Heartbeat run context",title:"Cross-issue writes need a run to attribute them to",description:"Every agent comment and task update is attributed to a heartbeat run so the cross-issue cap can be counted and the audit trail can name who acted for whom. This request arrived without a valid run, so it could not be contained.",whoCanAct:`${r}, once the request carries its own run id.`,sanctionedPath:"Send the `X-Paperclip-Run-Id` header with your current run (`$PAPERCLIP_RUN_ID`) and retry."};case"issue_write_attribution_spoof_rejected":return{code:e,status:422,tone:"attribution",boundary:"Server-derived attribution",title:"Responsible user cannot be chosen by the caller",description:"`onBehalfOfUserId` is derived from the authenticated actor, never from the request body — an agent cannot pick the human whose authority it rides. The attempt was recorded in the audit log.",whoCanAct:`${r} itself: the write is allowed, only the chosen attribution is not.`,sanctionedPath:`Remove \`onBehalfOfUserId\` from the request and retry; the server fills in ${o} from your run.`}}}a(fF,"describeIssueWriteDenial");var pF=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,gF=/^[A-Za-z0-9_. -]+$/,Ob=LD(()=>Iv([he(),In(),kl(),WP(),dn(Ob),fA(he(),Ob)])),sme=lt({name:he().regex(pF,"Expected a lowercase URL slug."),description:he().min(1),"allowed-tools":dn(he()).optional(),metadata:fA(he(),Ob).optional()}).passthrough(),xF=["name","description","allowed-tools","metadata"];function s0(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(s0,"isPlainRecord");function bF(e){if(typeof e!="string")return null;const t=e.trim();return t.length>0?t:null}a(bF,"asString$1");function nme(e){if(e===void 0)return[];if(!Array.isArray(e))return null;const t=[];for(const n of e){const r=bF(n);if(!r)return null;t.push(r)}return t}a(nme,"asStringArray$1");function rme(e){if(!e.startsWith(`---
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DesignSandboxTaskThread-CGU--FXR.js","assets/rolldown-runtime-DhZMWcEn.js","assets/index-BJtnP7H1.js","assets/index-z7lcCz2I.css"])))=>i.map(i=>d[i]);
2
+ var hP=Object.defineProperty;var a=(e,t)=>hP(e,"name",{value:t,configurable:!0});import{a as $g,n as Pg,t as fP}from"./rolldown-runtime-DhZMWcEn.js";import{C as Dg,S as nj,_ as WC,a as pP,b as gP,c as xP,d as rj,f as aj,g as bP,h as kc,i as KC,l as yP,m as vP,p as ij,s as wP,u as kP,x as jP,y as NP}from"./collections-B58p51lw.js";import{$A as IP,$E as SP,$S as Et,$b as VC,$f as U0,$g as _P,$h as CP,$l as AP,$r as vb,$t as Ns,$v as RP,$w as Pu,$x as oj,A as HC,AA as Lg,AC as Oo,AD as Tp,AO as TP,AT as Hh,Ab as QC,Af as EP,Ag as lj,Ai as hl,Am as MP,Ao as $P,Ap as Ra,At as PP,Au as GC,Av as DP,B as jc,BA as he,BC as LP,B_ as YC,Bg as OP,Bm as JC,Bo as wb,Bt as XC,Bv as qP,Bw as la,Bx as cj,C as ZC,CC as Ep,CE as tm,CS as BP,CT as FP,Cb as Og,Cg as lo,Cn as zP,Co as Mp,Cu as eA,Cv as mv,Cx as Da,D as UP,DA as WP,DC as Du,DS as tA,Da as KP,Db as sm,Dc as VP,Dg as HP,Dk as W0,Dm as QP,Do as GP,Dp as md,Du as gh,Dv as YP,Dw as uc,Dy as JP,E as XP,EA as fs,EC as sA,EO as qg,ES as Zm,ET as xh,E_ as mc,Eb as nm,Eg as Wo,Em as ZP,Ep as eD,Eu as qm,Ev as Pi,Ew as hv,Ex as La,F as To,FA as In,FE as tD,FT as yd,F_ as sD,Fb as Sl,Fg as dj,Fo as uj,Ft as nD,Fv as rD,Fw as aD,Fx as iD,Fy as oD,G as fv,GC as lD,GS as G,GT as ei,Gb as tt,Gg as cD,Gh as nA,Gm as dD,Gn as pv,Gt as mj,Gw as co,Gx as uD,H as mD,HC as Bg,HO as hD,H_ as $t,Hb as Gl,Hg as hj,Hh as fD,Hm as bh,Hn as rA,Ho as K0,Ht as aA,Hw as gv,Hx as pD,Hy as xv,I as gD,IA as lt,IC as uo,IE as Fg,IS as ba,Ib as xD,Id as bD,Im as yD,Io as fj,It as vD,Iw as Tl,Ix as wD,Iy as Qh,JA as kD,JC as jd,JT as iA,Jb as jD,Jf as ND,Jg as kb,Jh as pj,Jl as ID,Jn as $p,Jt as bv,Jw as yh,Jx as yl,K as rm,KE as jb,KT as SD,Ka as oA,Kh as _D,Kl as CD,Kr as Pp,Kt as lA,Kv as hc,Kx as Bm,L as Nd,LD as AD,LE as xa,LS as zg,LT as vh,L_ as RD,Lm as cA,Lo as TD,Lt as ED,Lv as MD,Lw as $D,Lx as PD,M as DD,MA as LD,ME as ys,MT as Ut,Mb as Nu,Mf as OD,Mg as qD,Mi as Fm,Mt as dA,Mu as BD,Mv as FD,Mx as gj,My as Gh,N as xj,NA as $n,NE as W,NT as zD,Nb as yv,Ng as UD,Nm as WD,Np as sd,Nt as KD,Nu as VD,Nv as HD,O as uA,OA as dn,OC as QD,OT as GD,Oa as YD,Ob as am,Og as JD,Oi as XD,Ok as ZD,Om as e4,Op as nd,Ou as mA,Ov as t4,Ox as hA,P as s4,PE as n4,PT as r4,P_ as a4,Pb as _l,Pg as ic,Pi as i4,Pm as o4,Po as bj,Pp as rd,Pt as l4,Pw as c4,Px as yj,QA as d4,QC as fc,QE as u4,QT as Xt,Q_ as vj,Qg as m4,Qh as h4,Ql as f4,Qr as wj,Qt as kj,Qv as vv,Qw as El,Qx as p4,Qy as g4,R as pa,RA as fA,RC as x4,RD as b4,RT as pc,Rb as Id,Rg as y4,Rm as pA,Ro as v4,Rp as eh,Rt as w4,Ru as k4,Rv as jj,Rw as j4,Rx as N4,S as wv,SA as Nj,SC as Yh,SS as Ij,ST as $d,S_ as I4,Sb as im,Sg as V0,Sn as S4,So as gA,Sp as Cl,Su as _4,Sw as kv,Sy as C4,T as A4,TA as H0,TS as Sj,TT as Cn,T_ as R4,Tb as om,Tc as T4,Tg as E4,Ti as Dp,Tl as M4,To as $4,Tu as P4,Tv as jv,Tw as xA,Tx as Oa,Ty as Sf,UC as th,UE as Nv,UT as ya,U_ as bA,Ub as D4,Ug as L4,Uh as O4,Um as bp,Un as q4,Uo as _j,Up as Ma,Ut as Lp,Ux as B4,V as Al,VA as Iv,VC as vl,VT as Sd,V_ as yA,Vg as vA,Vm as Nb,Vp as ti,Vt as Sv,Vw as F4,Vx as z4,Vy as U4,W as _v,WE as $s,WS as Cj,WT as W4,Wb as Ib,Wg as Aj,Wh as K4,Wm as V4,Wn as wA,Wo as H4,Wp as Q4,Wt as kA,Ww as G4,Wx as Sm,XA as Y4,XC as wh,XE as Ci,XO as J4,XT as X4,Xc as jA,Xf as Z4,Xg as eL,Xl as tL,Xn as sL,Xr as nL,Xt as rL,Xu as Sb,Xv as aL,Xw as NA,Xx as iL,YA as oL,YE as sc,YO as lL,YS as Ug,YT as Lu,Yb as Jh,Yc as cL,Yf as dL,Yh as _m,Yn as uL,Yp as _f,Yr as mL,Yt as IA,Yw as Fn,Yx as hL,ZA as fL,ZC as pL,ZO as SA,ZS as gL,ZT as _b,Z_ as _A,Zg as xL,Zh as CA,Zp as bL,Zr as yL,Zt as vL,Zv as wL,Zx as kL,_ as Op,_E as AA,_S as jL,_T as $a,__ as ia,_g as gi,_m as NL,_n as Ou,_r as IL,_t as SL,_u as Rj,_v as xn,_w as et,_x as _L,aA as sh,aC as qp,aE as CL,aS as Tj,aT as AL,ab as oa,af as RL,ag as TL,an as RA,au as Q0,aw as EL,ax as ML,ay as Eo,bE as ut,bT as $L,b_ as Cv,bb as kh,bg as Gc,bo as TA,bs as PL,bt as DL,bu as EA,bv as yp,bw as Wg,cA as LL,cE as OL,cS as Kg,cT as yr,c_ as MA,cg as Pd,ci as $A,co as Vg,cs as qL,cu as BL,cv as lm,cw as Hg,cy as FL,d as Av,dD as zL,dE as Rv,dS as nh,d_ as PA,db as UL,dg as G0,dm as WL,do as jh,du as Yl,dx as KL,dy as po,eC as Ej,eD as VL,eS as Mj,eT as Nh,e_ as HL,eg as QL,ei as xu,ej as GL,ek as YL,em as JL,en as Cm,eu as XL,ev as DA,ew as Ih,fC as LA,fD as ZL,fS as wl,fT as OA,f_ as qA,fb as BA,fg as $j,fi as eO,fo as FA,fr as Pj,fu as Cb,fw as Xh,fx as Bp,fy as ca,g as Ab,gC as Nc,gS as tO,gT as mo,g_ as Zs,gg as Vl,gk as Rb,gm as zA,gt as sO,gu as nO,gw as rO,gx as aO,hC as ls,hE as Ps,hS as Dj,hT as Tv,hg as iO,hm as oO,hn as lO,ho as cO,hr as dO,ht as uO,hu as Y0,hv as Di,hw as qo,hy as UA,iC as Gs,iD as va,iE as WA,iS as io,ib as mO,ig as hO,it as Lj,iu as fO,iv as Bo,j as KA,jC as Mi,jE as Ev,jT as en,ja as Fp,jb as un,jf as pO,jg as gO,ji as VA,jm as xO,jo as bO,jt as yO,ju as vO,jv as wO,jw as kO,jx as jO,k as NO,kA as kl,kC as IO,kT as Us,ka as SO,kb as cm,kg as _O,ki as HA,kk as Qg,km as CO,kp as ad,ku as eo,kv as AO,kw as Zh,kx as RO,ky as QA,lC as bu,lD as TO,lS as $e,l_ as EO,lb as zp,lg as Mv,lo as GA,lt as MO,lu as $O,ly as Vr,m as PO,mD as YA,mE as Tb,mS as DO,mT as Up,m_ as Eb,mb as As,mg as LO,mm as JA,mn as OO,mo as Gg,mt as XA,mu as J0,my as Hr,nE as qi,nS as qO,nT as Ic,n_ as BO,ng as FO,nj as zO,nk as UO,nl as ZA,nu as X0,nv as e1,oD as WO,oS as KO,o_ as ef,og as VO,oo as HO,op as hd,os as Yg,ou as QO,ov as tf,p as $v,pC as t1,pD as GO,pE as mn,pO as YO,pT as nr,p_ as JO,pf as Z0,pg as ex,pm as Wp,pn as Pv,po as XO,pu as ZO,pv as Li,pw as eq,qC as fi,qT as s1,qg as jl,qh as tq,ql as n1,qn as Oj,qp as xi,qr as r1,qt as sq,qw as dm,r as a1,rC as i1,rE as nq,rS as qn,rT as yi,r_ as rq,rb as $r,rg as aq,rl as qj,ru as o1,rv as _d,rw as iq,rx as qu,sC as id,sD as oq,sE as lq,sS as cq,s_ as l1,sb as dq,sg as Dv,so as Bj,ss as Mb,st as tx,su as ro,sv as uq,sy as Qr,t as Fj,tD as mq,tS as hq,tT as vr,t_ as fq,tg as pq,ti as gq,tk as xq,tl as Sh,tu as bq,ty as fd,uC as yq,uD as vq,uE as We,uO as zj,uS as Uj,u_ as c1,ub as Sn,ug as gc,uk as d1,uo as wq,uu as kq,uy as Na,vC as u1,vS as jq,vT as Bu,vb as wa,vg as Nq,vm as m1,vn as vd,vo as h1,vu as Wj,vv as f1,w as Iq,wE as Sq,wS as sx,wT as sf,wb as um,wg as nx,wo as p1,wu as zm,wv as Lv,wy as _q,x as _t,xE as Te,xS as ra,xT as nf,x_ as Jg,xb as ka,xg as Kj,xk as Cq,xn as Aq,xo as g1,xu as Vj,xv as nc,xw as Rq,yA as Tq,yE as Xg,y_ as Kp,yb as ja,yg as Cf,yk as Eq,yo as Ov,yu as Um,yv as x1,yw as Zg,z as Mq,zC as Oi,zE as E,zT as b1,z_ as y1,zb as Bi,zg as Wm,zm as v1,zo as $q,zt as Pq,zv as Dq,zw as w1,zx as Hj,zy as Qj}from"./index-BJtnP7H1.js";var k1=["daily","weekdays","weekly","monthly"],xc=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];var Lq=["accepted","declined","withdrawn","issue_closed","addressee_deleted","skipped"],Oq=/^([01]\d|2[0-3]):([0-5]\d)$/,e0=lt({frequency:fs(k1),dayOfWeek:fs(xc).optional().nullable(),dayOfMonth:In().int().min(1).max(28).optional().nullable(),time:he().regex(Oq,"time must be 24-hour HH:MM, for example 09:00")}).strict().superRefine((e,t)=>{e.frequency==="weekly"&&!e.dayOfWeek&&t.addIssue({code:"custom",path:["dayOfWeek"],message:"A weekly routine needs dayOfWeek"}),e.frequency==="monthly"&&!e.dayOfMonth&&t.addIssue({code:"custom",path:["dayOfMonth"],message:"A monthly routine needs dayOfMonth (1-28)"})}),Gj=a(e=>!e.includes("{{"),"NO_PLACEHOLDERS$1"),Yj="Write the text out in full; scheduled routines cannot use {{placeholders}}",iue=lt({title:he().trim().min(1).max(200).refine(Gj,Yj),instructions:he().trim().min(1).max(1e4).refine(Gj,Yj),cadence:e0,message:he().trim().min(1).max(500).optional().nullable()}).strict(),oue=lt({timezone:he().trim().min(1).max(100).optional()}).strict(),lue=lt({}).strict(),cue=lt({version:$n(1),title:he(),instructions:he(),message:he().nullable(),cadence:e0,cadenceLabel:he(),cronExpression:he(),assigneeAgentId:he(),projectId:he().nullable()}),due=lt({version:$n(1),outcome:fs(Lq),reason:he().nullable().optional(),routineId:he().nullable().optional(),routineTitle:he().nullable().optional(),cadenceLabel:he().nullable().optional(),timezone:he().nullable().optional(),responsibilityIds:dn(he()).optional()});function j1(e){const[t,n]=e.time.split(":").map(r=>Number(r));return{...e,hour:t,minute:n}}a(j1,"normalizedCadence");function qq(e){const{frequency:t,hour:n,minute:r,dayOfWeek:i,dayOfMonth:o}=j1(e);switch(t){case"daily":return`${r} ${n} * * *`;case"weekdays":return`${r} ${n} * * 1-5`;case"weekly":return`${r} ${n} * * ${xc.indexOf(i)}`;case"monthly":return`${r} ${n} ${o} * *`}}a(qq,"routineSuggestionCronExpression");function Bq(e,t){const n=e<12?"AM":"PM",r=e%12===0?12:e%12;return t===0?`${r} ${n}`:`${r}:${String(t).padStart(2,"0")} ${n}`}a(Bq,"clockLabel");function Fq(e){const t=e%100;if(t>=11&&t<=13)return`${e}th`;switch(e%10){case 1:return`${e}st`;case 2:return`${e}nd`;case 3:return`${e}rd`;default:return`${e}th`}}a(Fq,"ordinal");function zq(e){const{frequency:t,hour:n,minute:r,dayOfWeek:i,dayOfMonth:o}=j1(e),l=`at ${Bq(n,r)}`;switch(t){case"daily":return`Every day ${l}`;case"weekdays":return`Every weekday ${l}`;case"weekly":return`Every ${i.charAt(0).toUpperCase()}${i.slice(1)} ${l}`;case"monthly":return`On the ${Fq(o)} of every month ${l}`}}a(zq,"routineSuggestionCadenceLabel");var uue=["manual","some_automated","mostly_automated","automated"],mue={manual:"Manual",some_automated:"Some automated",mostly_automated:"Mostly automated",automated:"Automated"};function hue(e){return e===null?null:Math.round(e*100)}a(hue,"responsibilityAutomationPercent");var fue={schedule:"On a schedule",webhook:"From a webhook",standing_check:"Standing check"},Uq=["ing","ed","es","s"];function Fu(e){let t=e.toLowerCase();for(const n of Uq)if(t.endsWith(n)&&t.length-n.length>=3){t=t.slice(0,-n.length);break}return t.endsWith("e")&&t.length>3?t.slice(0,-1):t}a(Fu,"normalizeWord");function Wq(e){return e.split(/[^A-Za-z0-9]+/).filter(Boolean).map(t=>({raw:t,stem:Fu(t)}))}a(Wq,"titleTokens");var Kq=["daily","nightly","hourly","weekly","biweekly","fortnightly","monthly","quarterly","yearly","annual","annually","weekday","weekdays",...xc],Vq=["day","morning","evening","night","week","weekday","month","quarter","year","hour",...xc],Hq=["report","review","audit","reconcile","reconciliation","digest","recap","roundup","newsletter","standup"],Qq=["when","new","incoming","inbound","reply","replies","request","ticket","alert","submitted","submission","signup","triage"],Gq=["monitor","ensure","chase","waiting","waited","overdue","stale","followup"],Yq=["update","digest","recap","report","newsletter","summary","roundup"],mm=a(e=>new Set(e.map(Fu)),"stems"),pue=mm(Kq),gue=mm(Vq),xue=mm(Hq),bue=mm(Qq),yue=mm(Gq),vue=mm(Yq),wue=Fu("send"),Jl={frequency:"weekly",dayOfWeek:"monday",dayOfMonth:null,time:"09:00"},Am=Jl.time,Jq=new Map(xc.map(e=>[Fu(e),e]));function Xq(e){const t=Wq(e).map(o=>o.stem),n=a((...o)=>o.some(l=>t.includes(Fu(l))),"has"),r=t.map(o=>Jq.get(o)).find(Boolean);if(r)return{frequency:"weekly",dayOfWeek:r,dayOfMonth:null,time:Am};if(n("weekday"))return{frequency:"weekdays",dayOfWeek:null,dayOfMonth:null,time:Am};const i=t.some((o,l)=>(o==="every"||o==="each")&&["day","morning"].map(Fu).includes(t[l+1]??""));return n("daily","nightly")||i?{frequency:"daily",dayOfWeek:null,dayOfMonth:null,time:Am}:n("weekly","week")?{frequency:"weekly",dayOfWeek:"monday",dayOfMonth:null,time:Am}:n("monthly","month")?{frequency:"monthly",dayOfWeek:null,dayOfMonth:1,time:Am}:null}a(Xq,"suggestCadenceFromTitle");var $b=a(e=>!e.includes("{{"),"NO_PLACEHOLDERS"),Jj="Write the text out in full; automations cannot use {{placeholders}}",kue=lt({title:he().trim().min(1).max(200).refine($b,"Write the title out in full; scheduled routines cannot use {{placeholders}}"),cadence:e0,assigneeAgentId:he().uuid(),timezone:he().trim().min(1).max(100).optional()}).strict(),Zq=Lg("kind",[lt({kind:$n("schedule"),cadence:e0}).strict(),lt({kind:$n("webhook"),caller:he().trim().min(1).max(500)}).strict(),lt({kind:$n("standing_check"),lookFor:he().trim().min(1).max(1e3),whenFound:he().trim().min(1).max(1e3)}).strict()]),jue=lt({title:he().trim().min(1).max(200).refine($b,Jj),instructions:he().trim().min(1).max(1e4).refine($b,Jj),trigger:Zq,message:he().trim().min(1).max(500).optional().nullable()}).strict(),Nue=lt({timezone:he().trim().min(1).max(100).optional()}).strict(),Iue=lt({}).strict(),Sue=lt({agentId:he().uuid().optional(),responsibilityId:he().uuid().optional()}).strict(),eB=["accepted","declined","replaced","issue_closed","withdrawn","addressee_deleted"],tB=lt({frequency:fs(["daily","weekdays","weekly","monthly"]),dayOfWeek:fs(xc).nullable().optional(),dayOfMonth:In().int().nullable().optional(),time:he()}),_ue=lt({version:$n(1),sourceIssueId:he(),sourceIdentifier:he().nullable(),sourceTitle:he(),title:he(),instructions:he(),message:he().nullable(),trigger:Lg("kind",[lt({kind:$n("schedule"),cadence:tB,cadenceLabel:he(),cronExpression:he()}),lt({kind:$n("webhook"),caller:he()}),lt({kind:$n("standing_check"),lookFor:he(),whenFound:he()})]),startLabel:he(),assigneeAgentId:he(),agentName:he(),projectId:he().nullable(),filedUnder:dn(lt({id:he(),title:he()}))}),Cue=lt({version:$n(1),outcome:fs(eB),reason:he().nullable().optional(),replacedByInteractionId:he().nullable().optional(),routineId:he().nullable().optional(),routineTitle:he().nullable().optional(),triggerId:he().nullable().optional(),cadenceLabel:he().nullable().optional(),timezone:he().nullable().optional(),webhookUrl:he().nullable().optional(),signingMode:he().nullable().optional(),responsibilityIds:dn(he()).optional()}),hm=["number","percent","line","bar"],sB={number:"Large number",percent:"Percentage",line:"Line over time",bar:"Bars per week"};function nB(e,t){return e==="percentage"?"percent":e==="yes_no"?"number":t>=2?"line":"number"}a(nB,"defaultPrimaryDisplay");var qv=In().finite().min(-1e15).max(1e15),rB=6e4,aB=lt({value:qv,recordedAt:he().datetime({offset:!0})}).strict();function Xj(e){return e!=null&&(e<0||e>100)}a(Xj,"percentIssue");var N1=lt({title:he().trim().min(1).max(120),description:he().trim().min(1).max(300),display:fs(hm),unit:he().trim().min(1).max(40).optional().nullable(),target:qv.optional().nullable(),direction:fs(Qg).optional().nullable(),readings:dn(aB).max(12).optional(),readingsEvidence:he().trim().min(1).max(500).optional().nullable()}).strict().superRefine((e,t)=>{e.display==="percent"&&(e.unit&&e.unit!=="%"&&t.addIssue({code:"custom",path:["unit"],message:"A percent metric's unit is always %"}),Xj(e.target)&&t.addIssue({code:"custom",path:["target"],message:"A percent target is a share from 0 to 100"}),e.readings?.forEach((r,i)=>{Xj(r.value)&&t.addIssue({code:"custom",path:["readings",i,"value"],message:"A percent reading is a share from 0 to 100"})})),(e.direction??null)!==null&&(e.target??null)===null&&t.addIssue({code:"custom",path:["direction"],message:"A direction needs a target; leave both out when there is none"});const n=Date.now()+rB;e.readings?.forEach((r,i)=>{new Date(r.recordedAt).getTime()>n&&t.addIssue({code:"custom",path:["readings",i,"recordedAt"],message:"A reading cannot be in the future"})})}),iB=lt({title:he(),description:he(),display:fs(hm),unit:he().nullable(),target:In().nullable(),direction:fs(Qg).nullable(),readings:dn(lt({value:In(),recordedAt:he()})),readingsEvidence:he().nullable()}),Aue=lt({primaryDisplay:fs(hm).optional().nullable(),metrics:dn(N1).max(2)}).strict(),Rue=lt({value:Iv([qv,kl()]),recordedAt:he().datetime({offset:!0}).optional(),readingId:he().uuid().optional(),note:he().trim().min(1).max(500).optional().nullable()}).strict();function Pb(e){switch(e){case"percentage":return["percent","line","bar","number"];case"yes_no":return["number"];case"volume":case"range":return["number","line","bar"]}}a(Pb,"primaryDisplaysFor");var I1=["number","percent","yes_no","trend","per_week"],Tue={number:"Number",percent:"Percent",yes_no:"Yes / No",trend:"Trend",per_week:"Per week"};function Db(e){if(e.kind==="yes_no")return"yes_no";switch(e.display){case"number":return"number";case"percent":return"percent";case"line":return"trend";case"bar":return"per_week"}}a(Db,"responsibilityVisualizationOf");function Eue(e){switch(e){case"number":case"yes_no":return"number";case"percent":return"percent";case"trend":return"line";case"per_week":return"bar"}}a(Eue,"responsibilityVisualizationDisplay");function oB(e){let t;e.role==="primary"&&e.kind?t=e.kind==="range"?["number","line"]:Pb(e.kind):t=e.display==="percent"||e.unit?.trim()==="%"?["percent","line","bar","number"]:["number","line","bar"];const n=a(r=>I1.indexOf(Db({display:r,kind:e.role==="primary"?e.kind:null})),"order");return[...t].sort((r,i)=>n(r)-n(i))}a(oB,"responsibilityMetricDisplaysFor");function Mue(e){const t=e.role==="primary"?e.kind??null:null,n=new Set(oB(e).map(r=>Db({display:r,kind:t})));return n.add(Db({display:e.display,kind:t})),I1.filter(r=>n.has(r))}a(Mue,"responsibilityVisualizationsFor");var $ue=lt({display:fs(hm)}).strict(),Bv=["volume","percentage","yes_no","range"],lB=["metricUnit","metricDirection","metricTarget","metricLow","metricHigh"],zu={volume:{kind:"volume",label:"Volume",summary:"A count or amount that should be at least, or at most, a target.",whenItFits:"Something you count or add up: replies owed, deals in the pipeline, days to close, open bugs, revenue. at_least when more is better, at_most when it should stay down.",fields:["metricUnit","metricDirection","metricTarget"],required:["metricTarget"],readingHelp:"the current count or amount, as a number",example:{standard:"No escalated ticket waits a full day for a first reply.",metricName:"Escalated tickets waiting over a day",metricDirection:"at_most",metricTarget:0}},percentage:{kind:"percentage",label:"Percentage",summary:"A share from 0 to 100 that should be at least, or at most, a target.",whenItFits:"A share of a whole: the part of investors contacted this fortnight, invoices paid on time, churned customers. The unit is always %.",fields:["metricDirection","metricTarget"],required:["metricTarget"],readingHelp:"the current share as a number from 0 to 100",example:{standard:"Every prospective LP hears from us at least every two weeks.",metricName:"Prospective LPs contacted in the last 14 days",metricDirection:"at_least",metricTarget:90}},yes_no:{kind:"yes_no",label:"Yes or no",summary:"A state that is either true or not. Yes is on track; no is behind.",whenItFits:"A commitment that is simply kept or not, with nothing to count: the board pack went out a week before the meeting, payroll was approved by the 25th. The metric name is the statement that should be true.",fields:[],required:[],readingHelp:"true when the statement holds today, false when it does not",example:{standard:"Directors get the board pack a full week before every meeting.",metricName:"Board pack sent a week before the next meeting"}},range:{kind:"range",label:"Range",summary:"A value that should stay between a low and a high bound.",whenItFits:"A level that is wrong when too low and wrong when too high: runway in months, inventory on hand, team utilisation, cash in the operating account.",fields:["metricUnit","metricLow","metricHigh"],required:["metricLow","metricHigh"],readingHelp:"the current value, as a number",example:{standard:"We always have between 12 and 24 months of runway.",metricName:"Runway",metricUnit:"months",metricLow:12,metricHigh:24}}};function cB(e){return typeof e=="string"&&Bv.includes(e)}a(cB,"isResponsibilityMetricKind");function Fv(e,t){return cB(e)?e:t?.trim()==="%"?"percentage":"volume"}a(Fv,"resolveResponsibilityMetricKind");function S1(e){return Math.round(e*1e4)/1e4}a(S1,"round4");function dB(e,t,n){if(t===null||n===null||!Number.isFinite(t)||!Number.isFinite(n))return null;let r;return e==="at_most"?r=t>0&&n>0?t/n:n<=t?1:0:r=t>0?Math.max(0,n/t):n>=t?1:0,S1(r)}a(dB,"directionalAttainment");function uB(e,t){if(t===null||!Number.isFinite(t))return null;switch(e.kind){case"volume":case"percentage":return dB(e.direction??"at_least",e.target,t);case"yes_no":return t===1?1:0;case"range":{const{low:n,high:r}=e;if(n===null||r===null||!(r>n))return null;if(t>=n&&t<=r)return 1;const i=t<n?n-t:t-r;return S1(Math.max(0,1-i/(r-n)))}}}a(uB,"responsibilityAttainment");var Zj=new Intl.NumberFormat("en-US",{maximumFractionDigits:2});function mB(e){return!/[A-Za-z]/.test(e)}a(mB,"isSymbolUnit");function eN(e,t,n=!0){const r=Zj.format(e);return t?t==="%"?`${r}%`:mB(t)?e<0?`-${t}${Zj.format(-e)}`:`${t}${r}`:n?`${r} ${t}`:r:r}a(eN,"formatResponsibilityMetricValue");function _1(e){return e.kind==="percentage"?"%":e.kind==="yes_no"?null:e.unit?.trim()||null}a(_1,"displayUnit");function hB(e){const t=_1(e);return t!==null&&!e.name.toLowerCase().includes(t.toLowerCase())}a(hB,"wordUnitOk");var tN=1e-9;function C1(e){const t=_1(e),n=hB(e),r=a(i=>eN(i,t,n),"fmt");switch(e.kind){case"yes_no":return"On track when the answer is yes; behind when it is no";case"range":{const{low:i,high:o}=e;if(i===null||o===null||!(o>i))return null;const l=(o-i)*(1-W0);return`On track between ${eN(i,t,!1)} and ${r(o)}; at risk up to ${r(l)} outside it; behind further out`}case"volume":case"percentage":{const i=e.target;if(i===null)return null;const o=e.kind==="percentage";if(e.direction==="at_most"){if(i<=0)return`On track at ${r(i)} or less; behind above that`;const c=i/W0;return`On track at ${r(i)} or less; at risk up to ${r(o?Math.floor(c+tN):c)}`}if(i<=0)return`On track at ${r(i)} or more; behind below that`;const l=i*W0;return`On track at ${r(i)} or more; at risk from ${r(o?Math.ceil(l-tN):l)}`}}}a(C1,"responsibilityStatusRule");var vp=In().finite().min(-1e15).max(1e15),fB=Iv([vp,kl()]),pB=he().trim().min(1).max(40),gB=he().trim().min(1).max(200),xB={metricUnit:"a unit",metricDirection:"a direction",metricTarget:"a target",metricLow:"a low bound",metricHigh:"a high bound"},bB={volume:"A volume bar has a target and a direction, not a range; use the range template for low and high bounds",percentage:"A percentage bar has a target and a direction, not a range or another unit (its unit is always %)",yes_no:"A yes-or-no bar has no unit, direction, target or range: yes is on track and no is behind",range:"A range bar has a low and a high bound instead of a target and a direction"};function ku(e){return e!=null}a(ku,"present");function yB(e,t){return t==null?null:e==="yes_no"?typeof t=="boolean"||t===0||t===1?null:"A yes-or-no reading is true or false (or 1 or 0)":typeof t=="boolean"?"metricCurrent is true or false only for a yes-or-no bar; send the reading as a number":e==="percentage"&&(t<0||t>100)?"A percentage reading is a share from 0 to 100":null}a(yB,"responsibilityReadingIssue");function vB(e,t){const n=e.metricKind,r=zu[n],i=[];for(const l of lB){const c=e[l];if(!ku(c)){t.complete&&r.required.includes(l)&&i.push({field:l,message:`A ${r.label.toLowerCase()} bar needs ${xB[l]} (${l})`});continue}if(l==="metricUnit"&&n==="percentage"){String(c).trim()!=="%"&&i.push({field:l,message:"A percentage bar's unit is always %"});continue}if(!r.fields.includes(l)){i.push({field:l,message:bB[n]});continue}l==="metricUnit"&&n==="volume"&&String(c).trim()==="%"&&i.push({field:l,message:"A share belongs in the percentage template; a volume's unit cannot be %"})}n==="percentage"&&ku(e.metricTarget)&&(e.metricTarget<0||e.metricTarget>100)&&i.push({field:"metricTarget",message:"A percentage target is a share from 0 to 100"}),n==="range"&&ku(e.metricLow)&&ku(e.metricHigh)&&!(e.metricHigh>e.metricLow)&&i.push({field:"metricHigh",message:"A range's high bound (metricHigh) must be above its low bound (metricLow)"});const o=yB(n,e.metricCurrent);return o&&i.push({field:"metricCurrent",message:o}),i}a(vB,"responsibilityBarIssues");function wB(e){return!!e.metricName?.trim()||[e.metricTarget,e.metricLow,e.metricHigh,e.metricCurrent].some(t=>t!=null)}a(wB,"responsibilityHasMetric");function kB(e,t={}){if(t.barOptional&&!wB(e))return[];const n=[];e.standard?.trim()||n.push("standard"),e.metricName?.trim()||n.push("metricName");const r=Fv(e.metricKind,e.metricUnit);for(const i of zu[r].required){const o=e[i];o==null&&n.push(i)}return n}a(kB,"responsibilityBarMissingForActive");var jB=["accepted","declined","replaced","issue_closed","withdrawn","addressee_deleted"],NB=he().trim().min(1).max(1e3),Pue=lt({standard:NB,metricKind:fs(Bv),metricName:gB,metricUnit:pB.optional().nullable(),metricDirection:fs(Qg).optional().nullable(),metricTarget:vp.optional().nullable(),metricLow:vp.optional().nullable(),metricHigh:vp.optional().nullable(),metricCurrent:fB.optional().nullable(),currentEvidence:he().trim().min(1).max(1e3).optional().nullable(),message:he().trim().min(1).max(500).optional().nullable(),primaryDisplay:fs(hm).optional().nullable(),metrics:dn(N1).max(2).optional()}).strict().superRefine((e,t)=>{for(const r of vB(e,{complete:!0}))t.addIssue({code:"custom",path:[r.field],message:r.message});ku(e.metricCurrent)&&!e.currentEvidence&&t.addIssue({code:"custom",path:["currentEvidence"],message:"Say how you got the reading in currentEvidence, or leave metricCurrent out"}),ku(e.primaryDisplay)&&!Pb(e.metricKind).includes(e.primaryDisplay)&&t.addIssue({code:"custom",path:["primaryDisplay"],message:`A ${zu[e.metricKind].label.toLowerCase()} bar's metric can be drawn as ${Pb(e.metricKind).join(", ")}`});const n=new Set([e.metricName.trim().toLowerCase()]);e.metrics?.forEach((r,i)=>{(r.readings?.length??0)>0&&!r.readingsEvidence&&t.addIssue({code:"custom",path:["metrics",i,"readingsEvidence"],message:"Say how you got the starting readings in readingsEvidence, or leave readings out"});const o=r.title.trim().toLowerCase();n.has(o)&&t.addIssue({code:"custom",path:["metrics",i,"title"],message:"Each metric measures something different: this title repeats the bar's metric or another supporting metric"}),n.add(o)})}),Due=lt({keepMetrics:dn(In().int().min(0).max(1)).max(2).refine(e=>new Set(e).size===e.length,"Each kept metric is listed once").optional()}).strict(),Lue=lt({}).strict(),Oue=lt({agentId:he().uuid().optional()}).strict(),que=lt({version:$n(1),responsibilityId:he(),responsibilityTitle:he(),bar:lt({standard:he(),metricKind:fs(Bv),metricName:he(),metricUnit:he().nullable(),metricDirection:fs(Qg).nullable(),metricTarget:In().nullable(),metricLow:In().nullable(),metricHigh:In().nullable()}),metricCurrent:In().nullable(),currentEvidence:he().nullable(),message:he().nullable(),templateLabel:he(),targetLabel:he(),readingLabel:he().nullable(),statusRule:he(),preview:lt({health:fs(ZD),statusSentence:he()}).nullable(),primaryDisplay:fs(hm).nullable().optional(),metrics:dn(iB).nullable().optional()}),Bue=lt({version:$n(1),outcome:fs(jB),reason:he().nullable().optional(),replacedByInteractionId:he().nullable().optional(),responsibilityId:he().nullable().optional(),droppedMetrics:dn(he()).nullable().optional()});function IB(e){return{kind:e.metricKind,name:e.metricName,unit:e.metricUnit,direction:e.metricDirection,target:e.metricTarget,low:e.metricLow,high:e.metricHigh}}a(IB,"responsibilityBarMetricFromProposal");var A1=["create","edit"];var SB=["add_area","rename_area","remove_area","add_responsibility","reword_responsibility","move_responsibility","remove_responsibility"],R1=he().trim().min(1).max(200),T1=he().trim().min(1).max(200),rf=he().trim().min(1).max(300).optional().nullable(),E1=he().trim().min(1,"Say why in one line (reason)").max(300),zv=he().trim().min(1).max(40),Cd=he().uuid(),_B=lt({op:$n("add_area"),ref:zv,name:R1,reason:rf}).strict(),CB=lt({op:$n("rename_area"),areaId:Cd,name:R1,reason:rf}).strict(),AB=lt({op:$n("remove_area"),areaId:Cd,reason:E1}).strict(),RB=lt({op:$n("add_responsibility"),areaId:Cd.optional(),areaRef:zv.optional(),sentence:T1,reason:rf}).strict(),TB=lt({op:$n("reword_responsibility"),responsibilityId:Cd,sentence:T1,reason:rf}).strict(),EB=lt({op:$n("move_responsibility"),responsibilityId:Cd,areaId:Cd.optional(),areaRef:zv.optional(),reason:rf}).strict(),MB=lt({op:$n("remove_responsibility"),responsibilityId:Cd,reason:E1}).strict(),$B=Lg("op",[_B,CB,AB,RB,TB,EB,MB]);function PB(e){const t=[],n=new Map,r=new Set,i=new Map,o=new Map,l=new Map,c=a((d,m,h)=>{const f=d.get(m)??new Set;return f.add(h),d.set(m,f),f},"note");e.forEach((d,m)=>{if(d.op==="add_area"){n.has(d.ref)&&t.push({index:m,message:`Two new areas use the ref "${d.ref}"; give each its own`}),n.set(d.ref,m);const h=d.name.trim().toLowerCase();r.has(h)&&t.push({index:m,message:`"${d.name}" is added twice`}),r.add(h);return}if(d.op==="add_responsibility"||d.op==="move_responsibility"){const h=d.areaId!==void 0&&d.areaRef!==void 0,f=d.areaId===void 0&&d.areaRef===void 0;(h||f)&&t.push({index:m,message:"Name the area with exactly one of areaId (an existing area) or areaRef (a new one added earlier in this list)"}),d.areaRef!==void 0&&!n.has(d.areaRef)&&t.push({index:m,message:`No add_area earlier in this list has the ref "${d.areaRef}"`}),d.areaId&&c(o,d.areaId,d.op)}if(d.op==="rename_area"||d.op==="remove_area"){const h=l.get(d.areaId)??[];h.includes(d.op)&&t.push({index:m,message:d.op==="rename_area"?"This area is renamed twice":"This area is removed twice"}),h.includes(d.op==="rename_area"?"remove_area":"rename_area")&&t.push({index:m,message:"An area cannot be renamed and removed in the same proposal"}),h.push(d.op),l.set(d.areaId,h),c(o,d.areaId,d.op)}if("responsibilityId"in d){const h=i.get(d.responsibilityId)??new Set;h.has(d.op)&&t.push({index:m,message:"This responsibility already has that change in this proposal"}),(d.op==="remove_responsibility"?h.size>0:h.has("remove_responsibility"))&&t.push({index:m,message:"A responsibility that is removed cannot also be reworded or moved"}),h.add(d.op),i.set(d.responsibilityId,h)}});for(const[d,m]of o)if(m.has("remove_area")&&(m.has("add_responsibility")||m.has("move_responsibility"))){const h=e.findIndex(f=>f.op==="remove_area"&&f.areaId===d);t.push({index:h,message:"An area that is removed cannot also receive a responsibility"})}return t}a(PB,"responsibilityDashboardChangeSetIssues");var Fue=lt({message:he().trim().min(1).max(500).optional().nullable(),changes:dn($B).min(1).max(60)}).strict().superRefine((e,t)=>{for(const n of PB(e.changes))t.addIssue({code:"custom",path:["changes",n.index],message:n.message})}),zue=lt({keep:dn(In().int().min(0).max(59)).min(1,"Keep at least one change, or say the proposal is not right").max(60).refine(e=>new Set(e).size===e.length,"Each kept change is listed once").optional()}).strict(),Uue=lt({}).strict(),Wue=lt({mode:fs(A1),ownerUserId:he().trim().min(1).optional(),agentId:he().uuid().optional()}).strict(),Kue=lt({}).strict(),Vue=lt({ownerUserId:he().trim().min(1).optional()}),DB=["accepted","declined","replaced","issue_closed","withdrawn","addressee_deleted"],LB=lt({index:In().int().min(0),op:fs(SB),reason:he().nullable(),dependsOn:dn(In().int().min(0)),groupAreaId:he().nullable(),groupRef:he().nullable(),groupName:he(),name:he().nullable(),fromName:he().nullable(),responsibilityId:he().nullable(),sentence:he().nullable(),fromSentence:he().nullable(),fromAreaId:he().nullable(),fromAreaName:he().nullable(),lettingGo:dn(lt({id:he(),sentence:he()})),sharedWith:In().int().min(0)}),Hue=lt({version:$n(1),ownerUserId:he(),mode:fs(A1),message:he().nullable(),changes:dn(LB).min(1)}),Que=lt({version:$n(1),outcome:fs(DB),reason:he().nullable().optional(),replacedByInteractionId:he().nullable().optional(),dropped:dn(In().int()).nullable().optional(),versionId:he().nullable().optional(),previousVersionId:he().nullable().optional(),summary:he().nullable().optional()});function OB(e,t){const n=new Set([t]);let r=!0;for(;r;){r=!1;for(const i of e)!n.has(i.index)&&i.dependsOn.some(o=>n.has(o))&&(n.add(i.index),r=!0)}return[...n].sort((i,o)=>i-o)}a(OB,"dashboardChangesDroppedWith");function qB(e,t){const n=new Map(e.map(o=>[o.index,o])),r=new Set,i=a(o=>{if(!r.has(o)){r.add(o);for(const l of n.get(o)?.dependsOn??[])i(l)}},"visit");return i(t),[...r].sort((o,l)=>o-l)}a(qB,"dashboardChangesKeptWith");var Gue=lt({version:$n(1),areas:dn(lt({id:he(),title:he(),status:he(),sortOrder:In(),description:he().nullable().optional()})),responsibilities:dn(lt({id:he(),title:he(),standard:he().nullable(),areaId:he().nullable(),status:he(),sortOrder:In(),links:lt({projectIds:dn(he()),issueIds:dn(he()),routineIds:dn(he()),skillIds:dn(he()).optional()}).optional(),description:he().nullable().optional(),runByAgentId:he().nullable().optional(),evidence:he().nullable().optional(),healthOverride:he().nullable().optional(),healthNote:he().nullable().optional()})),createdAreaIds:dn(he()).default([])});function Vp(e){const t=new Set([e.targetIssueId]);if(e.type==="create_issue"){e.draft.parentId&&t.add(e.draft.parentId);for(const n of e.draft.blockedByIssueIds??[])t.add(n)}if(e.type==="resolve_blocker")for(const n of e.removeBlockedByIssueIds)t.add(n);return[...t]}a(Vp,"decisionEffectTargetIssueIds");var BB=new Set(["terminated","pending_approval","paused"]),FB=new Set(["active","idle","running","error"]);function zB(e){return FB.has(e)&&!BB.has(e)}a(zB,"isAgentStatusInvokable");var UB=128;function WB(e){return new TextEncoder().encode(e).length}a(WB,"utf8ByteLength");var M1=fs(["execution_workspace","project_workspace"]),Uv=fs(["auto","execution","project"]).default("auto"),KB=fs(["all","recent","changed"]).default("all"),VB=fs(["text","image","video","pdf","unsupported"]),HB=fs(["file","directory","remote_resource"]),$1=lt({kind:$n("workspace_file"),issueId:he().guid().optional(),projectId:he().guid().optional(),projectName:he().min(1).optional(),workspaceKind:M1,workspaceId:he().guid(),relativePath:he().min(1),line:In().int().positive().nullable().optional(),column:In().int().positive().nullable().optional(),displayPath:he().min(1)}),QB=lt({projectId:he().guid().optional(),workspaceId:he().guid().optional(),path:he().min(1).refine(e=>!/[\x00-\x1f\x7f]/.test(e),{message:"Workspace file path contains an invalid character",params:{code:"invalid_path"}}),workspace:Uv.optional()}).refine(e=>!!e.projectId==!!e.workspaceId,{message:"Workspace file target requires both projectId and workspaceId",path:["workspaceId"],params:{code:"invalid_target"}}),Yue=lt({queries:dn(QB).max(100)}),Jue=lt({projectId:he().guid().optional(),workspaceId:he().guid().optional(),workspace:Uv.optional(),path:he().min(1).refine(e=>!/[\x00-\x1f\x7f]/.test(e),{message:"Workspace folder path contains an invalid character",params:{code:"invalid_path"}}).optional(),mode:KB.optional(),q:he().refine(e=>!/[\x00-\x1f\x7f]/.test(e),{message:"Workspace file search contains an invalid character",params:{code:"invalid_query"}}).refine(e=>WB(e.trim())<=UB,{message:"Workspace file search is too long",params:{code:"invalid_query"}}).optional(),limit:Nj().int().min(1).max(100).default(25),offset:Nj().int().min(0).max(1e4).default(0)}).refine(e=>!!e.projectId==!!e.workspaceId,{message:"Workspace file target requires both projectId and workspaceId",path:["workspaceId"],params:{code:"invalid_target"}}),P1=lt({source:lt({kind:fs(["live","saved"]),savedAt:he().datetime().nullable(),snapshotId:he().guid().nullable()}).optional(),kind:HB,provider:he().min(1),title:he().min(1),displayPath:he().min(1),workspaceLabel:he().min(1),workspaceKind:M1,workspaceId:he().guid(),projectId:he().guid().nullable().optional(),projectName:he().min(1).nullable().optional(),contentType:he().nullable().optional(),byteSize:In().int().nonnegative().nullable().optional(),previewKind:VB,denialReason:he().nullable().optional(),capabilities:lt({preview:kl(),download:kl(),listChildren:kl()})}),GB=lt({projectId:he().guid().nullable(),workspaceId:he().guid().nullable(),path:he().min(1),workspace:Uv}),YB=lt({query:GB,openable:kl(),unavailableReason:he().min(1).nullable().optional(),resource:P1.nullable()}),Xue=lt({kind:$n("workspace_file_availability"),results:dn(YB).max(100)}),Zue=lt({resource:P1,content:lt({encoding:fs(["utf8","base64"]),data:he()})});function JB(e){return`/api/attachments/${e}/content`}a(JB,"attachmentContentPath");var XB=fs(["preview_url","runtime_service","pull_request","branch","commit","artifact","document"]),ZB=fs(["active","ready_for_review","approved","changes_requested","merged","closed","failed","archived","draft"]),eF=fs(["none","needs_board_review","approved","changes_requested"]),D1=lt({attachmentId:he().guid(),contentType:he().min(1),byteSize:In().int().nonnegative(),contentPath:he().min(1),openPath:he().min(1),downloadPath:he().min(1),originalFilename:he().optional().nullable()}).superRefine((e,t)=>{const n=JB(e.attachmentId);e.contentPath!==n&&t.addIssue({code:H0.custom,path:["contentPath"],message:"contentPath must point to the same-origin attachment content route"}),e.openPath!==n&&t.addIssue({code:H0.custom,path:["openPath"],message:"openPath must point to the same-origin attachment content route"}),e.downloadPath!==`${n}?download=1`&&t.addIssue({code:H0.custom,path:["downloadPath"],message:"downloadPath must point to the same-origin attachment download route"})}),tF=lt({resourceRef:$1.optional().nullable()}).passthrough(),sF=lt({projectId:he().guid().optional().nullable(),executionWorkspaceId:he().guid().optional().nullable(),runtimeServiceId:he().guid().optional().nullable(),type:XB,provider:he().min(1),externalId:he().optional().nullable(),title:he().min(1),url:he().url().optional().nullable(),status:ZB.default("active"),reviewState:eF.optional().default("none"),isPrimary:kl().optional().default(!1),healthStatus:fs(["unknown","healthy","unhealthy"]).optional().default("unknown"),summary:he().optional().nullable(),metadata:tF.optional().nullable(),createdByRunId:he().guid().optional().nullable()}),eme=UO(sF).partial(),nF=["text/markdown","text/x-markdown","application/markdown","application/x-markdown"],rF=new Set(nF),aF=new Set(["text/plain","application/octet-stream","binary/octet-stream","application/x-binary"]),iF=[".md",".markdown"],oF=524288,lF="artifact-review-";function cF(e){return(e??"").toLowerCase().split(";")[0]?.trim()??""}a(cF,"normalizeAttachmentContentType");function Wv(e){const t=cF(e.contentType);if(rF.has(t))return!0;const n=(e.originalFilename??"").toLowerCase();return iF.some(r=>n.endsWith(r))?aF.has(t):!1}a(Wv,"isMarkdownAttachmentContent");function Dd(e){if(e.type!=="artifact"||e.provider!=="paperclip"||!e.metadata)return null;const t=D1.safeParse(e.metadata);return t.success?t.data:null}a(Dd,"getAttachmentArtifactWorkProductMetadata");function sN(e){const t=Dd(e);return t&&Wv(t)?t:null}a(sN,"getMarkdownWorkProductAttachmentMetadata");function nN(e){return`${lF}${e}`}a(nN,"artifactReviewDocumentKey");function Ld(e){return e.startsWith("artifact-review-")&&e.length>16}a(Ld,"isArtifactReviewDocumentKey");function dF(e){return e==="RESPONSIBLE_USER_UNAUTHORIZED"||e==="RESPONSIBLE_USER_UNAVAILABLE"}a(dF,"isResponsibleUserDenialCode");function t0(e){const t=e?.trim();return t&&t.length>0?t:"the responsible user"}a(t0,"responsibleUserLabel");function Lb(e,t={}){const n=t0(t.userName);return e==="RESPONSIBLE_USER_UNAVAILABLE"?{code:e,tone:"unavailable",title:"Responsible user unavailable",description:`This run acts on behalf of ${n}, but that account was removed or deactivated, so its permissions can no longer be evaluated. The agent's own permissions are not enough on their own — every action still requires an active responsible user.`,recommendedAction:"Mark the work blocked and reassign a responsible user (or reactivate the account) before the agent continues."}:{code:e,tone:"unauthorized",title:"Responsible user not authorized",description:`This action was denied because ${n} — the user this run acts on behalf of — does not have permission to perform it. The agent may be allowed, but a run can never exceed the permissions of the user it acts for, so the action is blocked.`,recommendedAction:`Grant ${n} the required permission, or have someone who is authorized take this action instead.`}}a(Lb,"describeResponsibleUserDenial");var tme=["issue_write_not_visible","issue_write_actor_class_excluded","issue_write_responsible_user_ceiling","issue_write_responsible_user_unavailable","issue_write_assignee_run_lock","issue_status_change_live_run","cross_issue_influence_cap_exceeded","cross_issue_influence_run_context_required","issue_write_attribution_spoof_rejected"];function uF(e){const t=e?.trim();return t&&t.length>0?t:"this task"}a(uF,"issueLabel$2");function mF(e){const t=e?.trim();return t&&t.length>0?t:"the current assignee"}a(mF,"assigneeLabel");function hF(e){const t=e?.trim();return t&&t.length>0?t:"this agent"}a(hF,"actorLabel");function fF(e,t={}){const n=uF(t.issueIdentifier),r=hF(t.actorLabel),i=mF(t.assigneeLabel),o=t0(t.responsibleUserName);switch(e){case"issue_write_not_visible":return{code:e,status:403,tone:"boundary",boundary:"Issue visibility",title:"Task is outside this actor's visibility",description:`Issue writes are open by default, but only for tasks the actor can already read. ${n} is not visible to ${r}, so its comment, update, child, and assignment channels are all closed — the wall is visibility, not the write itself.`,whoCanAct:`${i}, and any agent or board member the task is visible to.`,sanctionedPath:`Ask the board to widen visibility for ${r}.`};case"issue_write_actor_class_excluded":return{code:e,status:403,tone:"boundary",boundary:"Actor-class boundary",title:"This actor class cannot write to tasks",description:`Default-open issue writes are a standard-trust privilege. Low-trust, skill-test, and task-bridge scopes keep their existing tight walls, so ${r} cannot write to ${n} no matter who it acts for.`,whoCanAct:"A standard-trust agent in this company, or a board member.",sanctionedPath:"Report the request upward and let a standard-trust agent make the write — actor-class scope cannot be widened per task."};case"issue_write_responsible_user_ceiling":{const l=Lb("RESPONSIBLE_USER_UNAUTHORIZED",{userName:t.responsibleUserName});return{code:e,status:403,tone:"boundary",boundary:"Responsible-user ceiling",title:l.title,description:`${l.description} The write to ${n} was refused for that reason.`,whoCanAct:`${o} once authorized, or anyone already permitted to write to ${n}.`,sanctionedPath:l.recommendedAction}}case"issue_write_responsible_user_unavailable":{const l=Lb("RESPONSIBLE_USER_UNAVAILABLE",{userName:t.responsibleUserName});return{code:e,status:403,tone:"boundary",boundary:"Responsible-user availability",title:l.title,description:`${l.description} The write to ${n} was refused for that reason.`,whoCanAct:`A board member, or ${r} once it has an active responsible user.`,sanctionedPath:l.recommendedAction}}case"issue_write_assignee_run_lock":return{code:e,status:409,tone:"lock",boundary:"Run checkout lock",title:"Another agent's run owns this task",description:`${i} has ${n} checked out and a run is live. Checkout and run ownership stay assignee-scoped even though writes are open, so field edits belong to the run that holds the lock until it finishes.`,whoCanAct:`${i}'s live run, or an agent holding the manage-active-checkouts permission.`,sanctionedPath:`Comment instead of patching — comments stay open and wake ${i} — or wait for the run to release the lock and retry.`};case"issue_status_change_live_run":{const l=t.issueIdentifier?.trim(),c=t.issuePath?.trim(),d=l&&c?`[${l}](${c})`:n;return{code:e,status:409,tone:"boundary",boundary:"Live run execution lock",title:"Another run is executing this task",description:`A run is live on ${n} and holds its execution lock. Changing the status would release that lock without stopping the run, so the run would keep going with no task bound to it. Agents cannot stop or interrupt another agent's run, so this status change is refused.`,whoCanAct:`A board user, or the run of ${i} that holds the lock.`,sanctionedPath:`This refusal is final: do not retry with another status, assignee or route. Reply now and send the person to ${d}. To stop the live run they use its Stop or Interrupt control there; to hold this task and the tasks under it, they open the parent task and choose More task actions, then Pause subtree. To pass a request to the running agent, comment on the task instead.`}}case"cross_issue_influence_cap_exceeded":{const l=t.cap??20,c=t.count??null;return{code:e,status:429,tone:"cap",boundary:`Per-run cross-issue cap of ${l} writes`,title:"This run has spent its cross-issue write budget",description:`A single heartbeat run may make at most ${l} cross-issue comments or task updates combined${c!==null?`; this was attempt ${c}`:""}. The cap bounds runaway comment sprays and loops — it is a rate backstop, not a permission decision, so ${r} is still allowed to write to ${n}.`,whoCanAct:`${r} on its next heartbeat run, or ${i} on ${n} directly.`,sanctionedPath:"Consolidate what is left into one comment on your own task, or end the run and continue on the next heartbeat — the budget resets per run."}}case"cross_issue_influence_run_context_required":return{code:e,status:403,tone:"boundary",boundary:"Heartbeat run context",title:"Cross-issue writes need a run to attribute them to",description:"Every agent comment and task update is attributed to a heartbeat run so the cross-issue cap can be counted and the audit trail can name who acted for whom. This request arrived without a valid run, so it could not be contained.",whoCanAct:`${r}, once the request carries its own run id.`,sanctionedPath:"Send the `X-Paperclip-Run-Id` header with your current run (`$PAPERCLIP_RUN_ID`) and retry."};case"issue_write_attribution_spoof_rejected":return{code:e,status:422,tone:"attribution",boundary:"Server-derived attribution",title:"Responsible user cannot be chosen by the caller",description:"`onBehalfOfUserId` is derived from the authenticated actor, never from the request body — an agent cannot pick the human whose authority it rides. The attempt was recorded in the audit log.",whoCanAct:`${r} itself: the write is allowed, only the chosen attribution is not.`,sanctionedPath:`Remove \`onBehalfOfUserId\` from the request and retry; the server fills in ${o} from your run.`}}}a(fF,"describeIssueWriteDenial");var pF=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,gF=/^[A-Za-z0-9_. -]+$/,Ob=LD(()=>Iv([he(),In(),kl(),WP(),dn(Ob),fA(he(),Ob)])),sme=lt({name:he().regex(pF,"Expected a lowercase URL slug."),description:he().min(1),"allowed-tools":dn(he()).optional(),metadata:fA(he(),Ob).optional()}).passthrough(),xF=["name","description","allowed-tools","metadata"];function s0(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(s0,"isPlainRecord");function bF(e){if(typeof e!="string")return null;const t=e.trim();return t.length>0?t:null}a(bF,"asString$1");function nme(e){if(e===void 0)return[];if(!Array.isArray(e))return null;const t=[];for(const n of e){const r=bF(n);if(!r)return null;t.push(r)}return t}a(nme,"asStringArray$1");function rme(e){if(!e.startsWith(`---
3
3
  `))return{frontmatterText:"",body:e,hasFrontmatter:!1};const t=e.indexOf(`
4
4
  ---
5
5
  `,3);return t<0?{frontmatterText:"",body:e,hasFrontmatter:!1}:{frontmatterText:e.slice(4,t),body:e.slice(t+5),hasFrontmatter:!0}}a(rme,"splitFrontmatterBlock");function yF(e){return Kv(L1(e),0).join(`
@@ -113,7 +113,7 @@ ${xt}`:xt)}return xe(xt=>xt.map(bt=>bt.id===Ge?{...bt,status:"attached",attachme
113
113
  `).split(`
114
114
  `);return t.length>0&&t[t.length-1]===""&&t.pop(),t.length>0?t:[""]}a(Mle,"splitContentIntoLines");function xC(e){const t=e.lastIndexOf("/");return t<0?e:e.slice(t+1)}a(xC,"basename");function $le(e,t=80){if(e.length<=t)return e;const n=e.slice(0,Math.floor(t/2)-1);return`${n}…${e.slice(e.length-(t-n.length-1))}`}a($le,"middleTruncatePath");function Ple(e){if((e.contentType?.toLowerCase()??"").includes("markdown"))return!0;const t=(e.displayPath||e.title).toLowerCase();return/\.(md|markdown|mdown|mkdn|mkd)$/.test(t)}a(Ple,"isMarkdownResource");function mb(e,t){const n=e.toLowerCase();return n.includes("policy")||n.includes("denied")||n.includes("sensitive")?{icon:(0,s.jsx)(qo,{"aria-hidden":"true",className:"h-6 w-6 text-amber-500"}),title:"Viewer blocked for this file",body:"This file is not available through the viewer because it may contain sensitive data."}:n.includes("outside")||n.includes("traversal")?{icon:(0,s.jsx)(Sd,{"aria-hidden":"true",className:"h-6 w-6 text-red-500"}),title:"Path is outside the workspace",body:"The viewer can only open files that live under the issue's workspace."}:n.includes("archive")||n.includes("cleaned")?{icon:(0,s.jsx)(co,{"aria-hidden":"true",className:"h-6 w-6 text-muted-foreground"}),title:"Workspace is no longer available",body:"The isolated worktree for this issue has been cleaned up, so files cannot be previewed."}:n.includes("remote")?{icon:(0,s.jsx)(ls,{"aria-hidden":"true",className:"h-6 w-6 text-amber-500"}),title:"Remote workspace preview not supported",body:"This workspace is hosted remotely and is not available for inline preview yet."}:n.includes("too_large")||n.includes("size")?{icon:(0,s.jsx)(ls,{"aria-hidden":"true",className:"h-6 w-6 text-amber-500"}),title:"File is too large to preview",body:"This file exceeds the supported preview size."}:n.includes("binary")||n.includes("unsupported")?{icon:(0,s.jsx)(ls,{"aria-hidden":"true",className:"h-6 w-6 text-amber-500"}),title:"Preview not supported for this file type",body:"This file does not have a text, image, or video preview available."}:{icon:(0,s.jsx)(Sd,{"aria-hidden":"true",className:"h-6 w-6 text-red-500"}),title:"Can't preview this file",body:t||"The viewer was unable to load this file."}}a(mb,"describeDenial");function ml({icon:e,title:t,body:n,secondary:r,actions:i}){return(0,s.jsxs)("div",{className:"flex flex-col items-start gap-3 p-6 text-sm",children:[(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[e,(0,s.jsxs)("div",{className:"flex-1 space-y-1",children:[(0,s.jsx)("p",{className:"font-medium text-foreground",children:t}),n?(0,s.jsx)("p",{className:"text-muted-foreground",children:n}):null,r]})]}),i?(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:i}):null]})}a(ml,"FileViewerStateView");function N$({resolvedResource:e,state:t}){return(0,s.jsx)("div",{className:"flex min-h-(--sz-18px) flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground",children:e?(0,s.jsxs)(s.Fragment,{children:[e.previewKind?(0,s.jsx)("span",{className:"capitalize",children:e.previewKind}):null,gC(e.byteSize)?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"opacity-50",children:"·"}),(0,s.jsx)("span",{children:gC(e.byteSize)})]}):null,t?.line?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"opacity-50",children:"·"}),(0,s.jsxs)("span",{children:["Line ",t.line,t.column?`, Col ${t.column}`:""]})]}):null]}):t?(0,s.jsx)("span",{className:"h-3 w-28 rounded bg-muted animate-pulse","aria-label":"Loading file details"}):null})}a(N$,"FileViewerMetadataRow");function Dle({content:e,highlightedLine:t,onLoaded:n,previewMode:r,htmlMode:i="rendered"}){const{resource:o}=e,l=o.previewKind==="text"&&e.content.encoding==="utf8"&&Ple(o),c=o.previewKind==="text"&&e.content.encoding==="utf8"&&Bk(o.displayPath||o.title,o.contentType??""),[d,m]=(0,u.useState)("rendered"),h=l||c?r??d:"raw",f=o.previewKind==="text"&&e.content.encoding==="utf8"&&lf(o.contentType,o.displayPath||o.title),p=c?"CSV":"Markdown",g=(0,u.useMemo)(()=>o.previewKind==="text"?Mle(e.content.data):null,[e.content.data,o.previewKind]),b=(0,u.useMemo)(()=>{if(!g||!rm(o.displayPath||o.title,o.contentType))return null;const w=fv();return g.map(j=>w(j.replace(/\r$/,"")).kind)},[g,o.displayPath,o.title,o.contentType]),y=(0,u.useRef)(null),x=(0,u.useRef)(null);if((0,u.useEffect)(()=>{m(l||c?"rendered":"raw")},[l,c,o.displayPath,o.title,o.contentType]),(0,u.useEffect)(()=>{g&&n?.(`File loaded, ${g.length} ${g.length===1?"line":"lines"}.`)},[g,n]),(0,u.useEffect)(()=>{h==="raw"&&(!t||!x.current||x.current.scrollIntoView({block:"center",behavior:"auto"}))},[t,h,i,r]),o.previewKind==="image"){const w=e.content.encoding==="base64"?`data:${o.contentType??"application/octet-stream"};base64,${e.content.data}`:null;return w?(0,s.jsx)("div",{className:"flex items-center justify-center overflow-auto bg-muted/40 p-4",children:(0,s.jsx)("img",{src:w,alt:o.title,className:"max-h-full max-w-full rounded border border-border object-contain"})}):(0,s.jsx)(ml,{icon:(0,s.jsx)(ls,{"aria-hidden":"true",className:"h-6 w-6 text-amber-500"}),title:"Image preview unavailable"})}if(o.previewKind==="video"){const w=e.content.encoding==="base64"?`data:${o.contentType??"application/octet-stream"};base64,${e.content.data}`:null;return w?(0,s.jsx)("div",{className:"flex flex-1 items-center justify-center overflow-auto bg-black p-4",children:(0,s.jsx)("video",{src:w,controls:!0,preload:"metadata",playsInline:!0,"aria-label":`Video preview: ${o.title}`,className:"max-h-full max-w-full rounded border border-white/10 bg-black"})}):(0,s.jsx)(ml,{icon:(0,s.jsx)(ls,{"aria-hidden":"true",className:"h-6 w-6 text-amber-500"}),title:"Video preview unavailable"})}if(o.previewKind==="unsupported"||!g)return(0,s.jsx)(ml,{icon:(0,s.jsx)(ls,{"aria-hidden":"true",className:"h-6 w-6 text-amber-500"}),title:"Preview not supported for this file type",body:o.contentType?`Content type: ${o.contentType}`:void 0});const v=`calc(${Math.max(4,String(g.length).length)}ch + 2rem)`,k=(0,s.jsx)("div",{ref:y,role:"region","aria-label":`${o.title} source`,tabIndex:0,className:E("paperclip-file-viewer-code min-w-0 flex-1 overflow-auto bg-(--code-bg-resolved) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",Et),children:(0,s.jsx)("pre",{className:E("m-0 font-mono text-xs leading-5",Et),children:g.map((w,j)=>{const _=j+1,I=_===t;return(0,s.jsxs)("div",{ref:I?x:void 0,"data-line-number":_,"data-patch-line":b?.[j],"data-line-selected":I||void 0,className:E("grid grid-cols-(--gtc-5)",b&&"paperclip-patch-line",I&&"bg-(--code-highlight-bg-resolved)"),children:[(0,s.jsx)("span",{"aria-hidden":"true",className:E("sticky left-0 z-10 shrink-0 select-none pl-3 pr-4 text-right text-(--code-gutter-fg-resolved) opacity-70","bg-(--code-bg-resolved)",b&&"text-(--patch-meta-fg) opacity-100",I&&"opacity-100 bg-(--code-highlight-bg-resolved) border-l-2 border-(--code-highlight-border-resolved)"),style:{width:v,minWidth:v},children:_}),(0,s.jsx)("code",{className:E("min-w-0 whitespace-pre-wrap break-words pr-4",b&&"wrap-anywhere"),children:w.length===0?"​":w})]},_)})})});return f?(r??i)==="raw"?k:(0,s.jsx)(g$,{html:e.content.data,title:o.title}):!l&&!c?k:(0,s.jsxs)("div",{className:E("relative flex min-h-0 flex-1 flex-col",Et),children:[r===void 0&&(0,s.jsx)("div",{className:"absolute right-3 top-3 z-20",children:(0,s.jsxs)("div",{role:"group","aria-label":`${p} preview mode`,className:"inline-flex rounded-md border border-border bg-background/95 p-0.5 shadow-sm backdrop-blur",children:[(0,s.jsx)(W,{type:"button",variant:h==="rendered"?"secondary":"ghost",size:"icon-sm","aria-label":`Show rendered ${p}`,title:`Rendered ${p}`,"aria-pressed":h==="rendered",onClick:a(()=>m("rendered"),"onClick"),className:E("h-7 w-7 rounded-sm",h!=="rendered"&&"text-muted-foreground hover:text-foreground"),children:(0,s.jsx)(Pu,{"aria-hidden":"true",className:"h-3.5 w-3.5"})}),(0,s.jsx)(W,{type:"button",variant:h==="raw"?"secondary":"ghost",size:"icon-sm","aria-label":`Show raw ${p}`,title:`Raw ${p}`,"aria-pressed":h==="raw",onClick:a(()=>m("raw"),"onClick"),className:E("h-7 w-7 rounded-sm",h!=="raw"&&"text-muted-foreground hover:text-foreground"),children:(0,s.jsx)(El,{"aria-hidden":"true",className:"h-3.5 w-3.5"})})]})}),h==="raw"?k:c?(0,s.jsx)(p$,{text:e.content.data,title:o.title}):(0,s.jsx)("div",{role:"region","aria-label":`${o.title} rendered Markdown`,tabIndex:0,className:"flex-1 overflow-auto bg-background p-5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",children:(0,s.jsx)(JM,{softBreaks:!1,children:e.content.data})})]})}a(Dle,"FileContentViewer");function bC({elapsedMs:e}){return e<100?(0,s.jsx)("div",{className:"flex-1","aria-hidden":"true"}):e<400?(0,s.jsxs)("div",{className:"flex-1 space-y-2 p-6","aria-busy":"true","aria-live":"polite",children:[(0,s.jsx)("span",{className:"sr-only",children:"Loading file preview"}),Array.from({length:10}).map((t,n)=>(0,s.jsx)("div",{className:"h-3 rounded bg-muted animate-pulse",style:{width:`${90-n*6}%`}},n))]}):(0,s.jsx)("div",{className:"flex flex-1 flex-col items-start justify-start gap-3 p-6 text-sm",role:"status","aria-live":"polite",children:(0,s.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,s.jsx)(et,{"aria-hidden":"true",className:"h-4 w-4 animate-spin"}),"Loading file preview..."]})})}a(bC,"LoadingView");function Lle({issueId:e,companyId:t,state:n,showPromptWhenEmpty:r=!1,open:i,onOpenChange:o}){const l=KA(),c=typeof n<"u"?n:l.state,d=c===null&&(r||l.browse),m=c!==null&&l.browse,h=typeof i=="boolean"?i:c!==null||r||l.browse,[f,p]=(0,u.useState)(0),[g,b]=(0,u.useState)("rendered");(0,u.useEffect)(()=>b("rendered"),[c?.path,c?.workspace,c?.workspaceId,c?.projectId]);const[y,x]=(0,u.useState)(null),[v,k]=(0,u.useState)(null),[w,j]=(0,u.useState)(""),[_,I]=(0,u.useState)(""),[T,F]=(0,u.useState)(288),O=(0,u.useRef)(null),z=(0,u.useRef)(null),q=Te({queryKey:c?G.issues.fileResource(e,c):["issues","file-resources",e,"resolve","__closed__"],queryFn:a(()=>To.resolve(e,c),"queryFn"),enabled:!!c&&h,staleTime:3e4}),A=q.data,H=A?.capabilities.preview??!1,B=c&&A?.capabilities.download?To.downloadUrl(e,c):null,C=Te({queryKey:c?G.issues.fileResourceContent(e,c):["issues","file-resources",e,"content","__closed__"],queryFn:a(()=>To.content(e,c),"queryFn"),enabled:!!c&&h&&H,staleTime:3e4}),S=q.isFetching&&!q.data||H&&C.isFetching&&!C.data;(0,u.useEffect)(()=>{if(!c){p(0);return}if(!S)return;const ee=Date.now();p(0);const ce=window.setInterval(()=>{p(Date.now()-ee)},75);return()=>window.clearInterval(ce)},[c?.path,c?.workspace,c?.projectId,c?.workspaceId,S]),(0,u.useEffect)(()=>{if(q.isError){const ee=Eg(q.error);I(ee.message||"Unable to load file.")}},[q.isError,q.error]),(0,u.useEffect)(()=>{if(C.isError){const ee=Eg(C.error);I(ee.message||"Unable to load file content.")}},[C.isError,C.error]),(0,u.useEffect)(()=>()=>{O.current&&window.clearTimeout(O.current),z.current?.()},[]);const L=(0,u.useCallback)(ee=>{if(o){o(ee);return}ee||l.close()},[o,l]),M=(0,u.useCallback)(ee=>{l.open({path:ee.path,line:ee.line??null,column:ee.column??null,workspace:ee.workspace,projectId:ee.projectId??null,workspaceId:ee.workspaceId??null},{fromBrowse:!0,browseState:{folderPath:ee.browseFolderPath??null,q:ee.browseQuery??null}})},[l]),R=(0,u.useCallback)(ee=>{l.updateBrowseState(ee)},[l]),V=(0,u.useCallback)((ee,ce)=>{x(ee),j(ce),I(ce),O.current&&window.clearTimeout(O.current),O.current=window.setTimeout(()=>{x(ie=>ie===ee?null:ie),j(""),O.current=null},1800)},[]),J=(0,u.useCallback)(async(ee,ce,ie)=>{try{k(ce),await xi(ee),V(ce,ie)}catch{V(null,"Copy failed")}finally{k(ke=>ke===ce?null:ke)}},[V]),Q=(0,u.useCallback)(()=>{c&&(async()=>{let ee=C.data;if(!ee&&H&&(ee=(await C.refetch()).data),!ee){V(null,"File contents unavailable");return}const ce=ee.content.encoding==="base64"?"Copied file data":"Copied contents";await J(ee.content.data,"content",ce)})()},[H,C,J,V,c]),Z=(0,u.useCallback)(()=>{typeof window>"u"||J(window.location.href,"link","Copied link")},[J]),P=(0,u.useCallback)(()=>{q.refetch(),H&&C.refetch()},[H,C,q]),te=(0,u.useCallback)(ee=>{ee.preventDefault(),z.current?.();const ce=ee.clientX,ie=T,ke=a(je=>{const ae=Math.min(ub,Math.max(db,ie+je.clientX-ce));F(ae)},"handlePointerMove"),_e=a(()=>{document.removeEventListener("pointermove",ke),document.removeEventListener("pointerup",_e),z.current=null},"cleanup");z.current=_e,document.addEventListener("pointermove",ke),document.addEventListener("pointerup",_e,{once:!0})},[T]),ne=(0,u.useCallback)(ee=>{ee.key!=="ArrowLeft"&&ee.key!=="ArrowRight"||(ee.preventDefault(),F(ce=>{const ie=ee.key==="ArrowLeft"?-24:24;return Math.min(ub,Math.max(db,ce+ie))}))},[]),ge=c?xC(c.path):"Browse workspace",K=c?$le(c.path):"Search and preview files from this issue's workspace.";return(0,s.jsx)(Qr,{open:h,onOpenChange:L,children:(0,s.jsxs)(Vr,{className:"flex h-(--sz-calc-3) w-(--sz-calc-4) max-w-(--sz-calc-5) flex-col gap-0 overflow-hidden p-0 sm:w-(--sz-94vw) sm:max-w-(--sz-1280px)","aria-labelledby":fC,"aria-describedby":pC,showCloseButton:!1,onEscapeKeyDown:a(ee=>{m&&(ee.preventDefault(),l.backToFiles())},"onEscapeKeyDown"),children:[(0,s.jsxs)(ca,{className:"border-b border-border gap-1 p-3",children:[(0,s.jsxs)("div",{className:"grid min-w-0 grid-cols-(--gtc-6) items-start gap-2",children:[d?(0,s.jsx)(gR,{"aria-hidden":"true",className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}):(0,s.jsx)(El,{"aria-hidden":"true",className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)(Hr,{id:fC,className:"truncate text-sm leading-5",children:ge}),(0,s.jsx)(Na,{id:pC,className:E("truncate font-mono text-xs",!(!c||K!==ge)&&"sr-only"),title:c?.path,children:K})]}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-1 self-start",children:[(0,s.jsx)("span",{className:"hidden min-w-28 text-right text-xs text-muted-foreground sm:inline",role:"status","aria-live":"polite",children:w}),m?(0,s.jsxs)(W,{type:"button",variant:"ghost",size:"sm",onClick:a(()=>l.backToFiles(),"onClick"),className:"h-7 gap-1 px-2 text-xs","aria-label":"Back to files",children:[(0,s.jsx)(s1,{className:"h-3.5 w-3.5"}),"Back to files"]}):null,C.data?.resource.previewKind==="text"&&C.data.content.encoding==="utf8"&&lf(C.data.resource.contentType,C.data.resource.displayPath||C.data.resource.title)?(0,s.jsx)(Fk,{mode:g,onChange:b,label:"HTML view"}):null,c&&B?(0,s.jsx)(W,{asChild:!0,variant:"ghost",size:"icon-sm",className:"h-7 w-7",children:(0,s.jsx)("a",{href:B,download:A?.title??xC(c.path),"aria-label":"Download file",title:"Download file",children:(0,s.jsx)(yi,{className:"h-4 w-4"})})}):null,c?(0,s.jsx)(W,{type:"button",variant:"ghost",size:"icon-sm",onClick:Q,"aria-label":y==="content"?"Copied file contents":"Copy file contents",title:y==="content"?"Copied contents":"Copy file contents",className:"h-7 w-7",children:v==="content"?(0,s.jsx)(et,{className:"h-4 w-4 animate-spin"}):y==="content"?(0,s.jsx)(Ut,{className:"h-4 w-4 text-green-500"}):(0,s.jsx)(yr,{className:"h-4 w-4"})}):null,c?(0,s.jsx)(W,{type:"button",variant:"ghost",size:"icon-sm",onClick:Z,"aria-label":y==="link"?"Copied file view link":"Copy link to this file view",title:y==="link"?"Copied link":"Copy link",className:"h-7 w-7",children:v==="link"?(0,s.jsx)(et,{className:"h-4 w-4 animate-spin"}):y==="link"?(0,s.jsx)(Ut,{className:"h-4 w-4 text-green-500"}):(0,s.jsx)(Rq,{className:"h-4 w-4"})}):null,(0,s.jsx)(W,{type:"button",variant:"ghost",size:"icon-sm",onClick:a(()=>L(!1),"onClick"),className:"h-7 w-7","aria-label":"Close file viewer",title:"Close",children:(0,s.jsx)(Gs,{className:"h-4 w-4"})})]})]}),(0,s.jsx)(N$,{resolvedResource:A,state:c})]}),(0,s.jsxs)("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[(0,s.jsx)("div",{"aria-live":"polite",className:"sr-only",children:_}),c?(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 gap-3 bg-muted/30 p-3",children:[(0,s.jsx)("aside",{className:"hidden min-h-0 shrink-0 overflow-hidden sm:flex",style:{width:T},children:(0,s.jsx)(nv,{issueId:e,companyId:t,onOpen:M,onBrowseStateChange:m?R:void 0,initialQuery:m?l.query:null,initialFolderPath:m?l.folderPath:void 0,initialProjectId:c.projectId??(m?l.browseProjectId:null),initialWorkspaceId:c.workspaceId??(m?l.browseWorkspaceId:null),autoFocusSearch:!1,compact:!0,selectedPath:c.path,selectedProjectId:c.projectId,selectedWorkspaceId:c.workspaceId,active:h,className:"min-h-0 flex-1 p-2"},`${c.projectId??""}:${c.workspaceId??""}`)}),(0,s.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize file tree","aria-valuemin":db,"aria-valuemax":ub,"aria-valuenow":T,tabIndex:0,onPointerDown:te,onKeyDown:ne,className:"hidden w-1 shrink-0 cursor-col-resize rounded-full bg-border transition-colors hover:bg-muted-foreground/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:block"}),(0,s.jsx)("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:(0,s.jsx)(I$,{resolveQuery:q,contentQuery:C,elapsedMs:f,canPreview:H,highlightedLine:c.line??null,htmlMode:g,onRetry:P,onSetAnnouncement:I,onFallbackToProject:c.workspace!=="project"&&!c.projectId&&!c.workspaceId?()=>l.open({path:c.path,line:c.line,column:c.column,workspace:"project",projectId:null,workspaceId:null}):null})})]}):d?(0,s.jsx)(nv,{issueId:e,companyId:t,onOpen:M,onBrowseStateChange:R,initialQuery:l.query,initialFolderPath:l.folderPath,initialProjectId:l.browseProjectId,initialWorkspaceId:l.browseWorkspaceId,active:h,className:"min-h-0 flex-1 p-4"}):null]})]})})}a(Lle,"FileViewerSheet");function I$({resolveQuery:e,contentQuery:t,elapsedMs:n,canPreview:r,highlightedLine:i,onRetry:o,onSetAnnouncement:l,onFallbackToProject:c,previewMode:d,htmlMode:m}){const h=zp(e);if(!e.data&&(e.isFetching||h==="reconnecting"))return(0,s.jsx)(bC,{elapsedMs:n});if(h==="error"){const g=Eg(e.error);if(g.status===404)return(0,s.jsx)(ml,{icon:(0,s.jsx)(cR,{"aria-hidden":"true",className:"h-6 w-6 text-muted-foreground"}),title:"File not found",body:"That file was not found in the active workspace.",actions:(0,s.jsxs)(s.Fragment,{children:[c?(0,s.jsx)(W,{type:"button",variant:"secondary",size:"sm",onClick:c,children:"Try project workspace"}):null,(0,s.jsxs)(W,{type:"button",variant:"ghost",size:"sm",onClick:o,children:[(0,s.jsx)(th,{"aria-hidden":"true",className:"mr-1 h-3 w-3"})," Retry"]})]})});if(g.status===422)return(0,s.jsx)(ml,{icon:(0,s.jsx)(co,{"aria-hidden":"true",className:"h-6 w-6 text-muted-foreground"}),title:"No workspace available",body:"This issue does not have a workspace that supports preview yet."});const b=mb(g.code,g.message);return(0,s.jsx)(ml,{icon:b.icon,title:b.title,body:b.body,actions:(0,s.jsxs)(W,{type:"button",variant:"ghost",size:"sm",onClick:o,children:[(0,s.jsx)(th,{"aria-hidden":"true",className:"mr-1 h-3 w-3"})," Retry"]})})}const f=e.data;if(!f)return null;if(f.kind==="remote_resource")return(0,s.jsx)(ml,{icon:(0,s.jsx)(OA,{"aria-hidden":"true",className:"h-6 w-6 text-muted-foreground"}),title:"Remote workspace preview coming soon",body:"This workspace is hosted remotely; inline previews are not supported yet."});if(!r){const g=mb(f.denialReason??"","");return(0,s.jsx)(ml,{icon:g.icon,title:g.title,body:g.body})}const p=zp(t);if(!t.data&&(t.isFetching||p==="reconnecting"))return(0,s.jsx)(bC,{elapsedMs:n});if(p==="error"){const g=Eg(t.error),b=mb(g.code,g.message);return(0,s.jsx)(ml,{icon:b.icon,title:b.title,body:b.body,actions:(0,s.jsxs)(W,{type:"button",variant:"ghost",size:"sm",onClick:o,children:[(0,s.jsx)(th,{"aria-hidden":"true",className:"mr-1 h-3 w-3"})," Retry"]})})}return t.data?(0,s.jsx)(Dle,{content:t.data,highlightedLine:i,previewMode:d,onLoaded:l,htmlMode:m}):null}a(I$,"FileViewerBody");function Ole({issueId:e,payload:t,onFallbackToProject:n}){const[r,i]=(0,u.useState)("rendered");(0,u.useEffect)(()=>i("rendered"),[t.path,t.workspace,t.workspaceId,t.projectId]);const[o,l]=(0,u.useState)(!1),[c,d]=(0,u.useState)(""),m={path:t.path,workspace:t.workspace,projectId:t.projectId,workspaceId:t.workspaceId,line:t.line,column:t.column},h=Te({queryKey:G.issues.fileResource(e,m),queryFn:a(()=>To.resolve(e,m),"queryFn")}),f=h.data,p=Te({queryKey:G.issues.fileResourceContent(e,m),queryFn:a(()=>To.content(e,m),"queryFn"),enabled:f?.capabilities.preview===!0}),g=f?.capabilities.download?To.downloadUrl(e,m):null,b=f&&(lf(f.contentType,f.displayPath||f.title)||Bk(f.displayPath||f.title,f.contentType??"")||/\.(md|markdown|mdown|mkdn|mkd)$/i.test(f.displayPath||f.title)||f.contentType?.includes("markdown"));return(0,s.jsxs)("div",{className:"flex h-full min-h-0 flex-col bg-muted/20",children:[(0,s.jsxs)("header",{className:"flex min-w-0 items-start gap-2 border-b border-border bg-card px-3 py-2",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("h2",{className:"truncate text-sm font-medium",title:t.path,children:f?.title??t.path}),(0,s.jsx)("p",{className:"truncate font-mono text-xs text-muted-foreground",title:t.path,children:t.path}),(0,s.jsx)(N$,{resolvedResource:f,state:m})]}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[p.data?(0,s.jsx)(W,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Copy file contents",title:o?"Copied":"Copy file contents",onClick:a(()=>{xi(p.data.content.data).then(()=>{l(!0),window.setTimeout(()=>l(!1),1800)})},"onClick"),children:o?(0,s.jsx)(Ut,{"aria-hidden":!0}):(0,s.jsx)(yr,{"aria-hidden":!0})}):null,b&&p.data?(0,s.jsx)(Fk,{mode:r,onChange:i,label:"File preview mode"}):null,g?(0,s.jsx)(W,{asChild:!0,variant:"ghost",size:"icon-sm",children:(0,s.jsx)("a",{href:g,download:f?.title,"aria-label":"Download file",title:"Download file",children:(0,s.jsx)(yi,{"aria-hidden":!0})})}):null]})]}),(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[(0,s.jsx)("div",{className:"sr-only","aria-live":"polite",children:c}),(0,s.jsx)(I$,{previewMode:r,resolveQuery:h,contentQuery:p,elapsedMs:0,canPreview:f?.capabilities.preview??!1,highlightedLine:t.line,onRetry:a(()=>{h.refetch(),f?.capabilities.preview&&p.refetch()},"onRetry"),onSetAnnouncement:d,onFallbackToProject:n??null})]})]})}a(Ole,"TaskWorkspaceFilePanel");function qle({companyId:e,skillId:t}){const n=Jh(),r=Te({queryKey:G.companySkills.detail(e,t),queryFn:a(()=>V4.detail(e,t),"queryFn"),refetchOnWindowFocus:!0,refetchOnMount:"always"}),i=Sn(r);if(r.isLoading||i.kind==="reconnecting")return(0,s.jsxs)("div",{className:"flex items-center gap-2 py-8 text-sm text-muted-foreground",role:"status",children:[(0,s.jsx)(et,{className:"size-4 animate-spin","aria-hidden":!0}),"Loading skill…"]});if(i.kind==="error")return i.errorKind==="not_found"?(0,s.jsx)("div",{className:"py-8 text-sm text-muted-foreground",role:"status",children:"Skill no longer available."}):i.errorKind==="forbidden"?(0,s.jsx)("div",{className:"py-8 text-sm text-muted-foreground",role:"alert",children:"You do not have access to this skill."}):(0,s.jsx)("div",{className:"py-6",children:(0,s.jsx)(oa,{error:r.error,action:"load the skill",onRetry:i.retry,retrying:i.isFetching})});if(!r.data)return(0,s.jsx)("div",{className:"py-8 text-sm text-muted-foreground",role:"status",children:"Skill no longer available."});const o=r.data,l=wF(o.markdown).body;return(0,s.jsxs)("article",{className:"space-y-4",children:[(0,s.jsxs)("header",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(qp,{className:"size-4 text-muted-foreground","aria-hidden":!0}),(0,s.jsx)("h2",{className:"text-lg font-semibold",children:o.name})]}),(0,s.jsxs)(W,{variant:"outline",size:"sm",onClick:a(()=>n(`/skills/studio/${encodeURIComponent(o.id)}`),"onClick"),children:[(0,s.jsx)(vr,{className:"mr-1.5 size-3.5","aria-hidden":!0}),"Open in Skill Studio"]})]}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:[o.slug," · ",o.currentVersion?`Revision ${o.currentVersion.revisionNumber}`:"Current version"]})]}),o.description?(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:o.description}):null,(0,s.jsxs)("section",{className:"space-y-2",children:[(0,s.jsxs)("h3",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[(0,s.jsx)(Fn,{className:"size-3.5","aria-hidden":!0}),"Skill instructions"]}),(0,s.jsx)(_t,{children:l||"Skill instructions are empty."})]})]})}a(qle,"TaskSkillPanel");var Ble=[],Fle=[];function zle(e){switch(e.payload.kind){case"browser":return(0,s.jsx)(Tl,{});case"plugin-panel":return(0,s.jsx)(G1,{});case"properties":return(0,s.jsx)(Du,{});case"subtasks":return(0,s.jsx)(Zg,{});case"artifacts":return(0,s.jsx)(vh,{});case"agent-tasks":return(0,s.jsx)(Wg,{});case"attachment":return(0,s.jsx)(Fn,{});case"files-browser":return(0,s.jsx)(co,{});case"workspace-file":return(0,s.jsx)(El,{});case"issue-document":return e.payload.documentKey==="plan"?(0,s.jsx)(kv,{}):(0,s.jsx)(Fn,{})}}a(zle,"tabIcon");function hb(e){if(e.some(r=>r.id==="subtasks"))return e;const t=e.findIndex(r=>r.id==="properties"),n=[...e];return n.splice(t<0?0:t+1,0,Cle()),n}a(hb,"insertSubtasksAfterProperties");function Ule(e){return e==="execution_workspace"?"execution":"project"}a(Ule,"selectorForWorkspaceKind");function Wle(){const e=qi(),t=Jh(),n=(0,u.useMemo)(()=>uA(e.search),[e.search]),r=(0,u.useMemo)(()=>UP(e.search),[e.search]),i=(0,u.useCallback)((m,h=!1)=>{NO(m,e.search)&&t({pathname:e.pathname,hash:e.hash,search:m},{...Iq,replace:h,state:e.state})},[e.hash,e.pathname,e.search,e.state,t]),o=(0,u.useCallback)((m,h)=>{let f=xj(e.search,m);if(h?.fromBrowse){const p=new URLSearchParams(f),g=new URLSearchParams(e.search);p.set("browse","1");const b=Object.prototype.hasOwnProperty.call(h.browseState??{},"q")?h.browseState?.q:g.get("q"),y=Object.prototype.hasOwnProperty.call(h.browseState??{},"folderPath")?h.browseState?.folderPath:g.get("folder");b?p.set("q",b):p.delete("q"),y?p.set("folder",y):p.delete("folder"),f=p.toString()?`?${p.toString()}`:""}i(f)},[e.search,i]),l=(0,u.useCallback)(m=>{const h=new URLSearchParams(e.search);h.delete("file"),h.delete("line"),h.delete("column"),h.delete("folder"),h.set("browse","1"),m?.q?h.set("q",m.q):h.delete("q"),i(h.toString()?`?${h.toString()}`:"")},[e.search,i]),c=(0,u.useCallback)(m=>{i(DD(e.search,m),!0)},[e.search,i]),d=(0,u.useCallback)(()=>{const m=XP(e.search),h=new URLSearchParams(xj(m,null).replace(/^\?/,""));h.delete("browse"),h.delete("q"),h.delete("folder"),i(h.toString()?`?${h.toString()}`:"")},[e.search,i]);return{state:n,browse:r!==null,query:r?.q??null,folderPath:r?.folderPath??null,browseProjectId:r?.projectId??null,browseWorkspaceId:r?.workspaceId??null,open:o,openBrowse:l,updateBrowseState:c,close:d}}a(Wle,"useTaskSidePanelFileRouting");function yC(e){return(0,s.jsx)(Kle,{...e},JSON.stringify([e.accountScope,e.issue.companyId,e.issue.id]))}a(yC,"TaskSidePanel");function Kle({pluginPanels:e=Fle,pluginPanelsLoading:t=!1,openedPluginPanelKeys:n,dismissedPluginPanelKeys:r,openBrowserId:i,onBrowserOpened:o,issue:l,documentEditor:c,accountScope:d,childIssues:m=[],issueLinkState:h,onAddSubIssue:f,onUpdate:p,inline:g=!1,mobile:b=!1,hasActiveRun:y=!1,externalObjects:x,externalObjectsLoading:v,externalObjectsError:k,onRetryExternalObjects:w,onCheckMonitorNow:j,checkingMonitorNow:_=!1,fileTabsEnabled:I,documentDeepLink:T,showDocumentSourceTask:F=!1,onArtifactVisibilityChange:O,artifactsOpenRequestId:z,onArtifactsOpened:q,onRequestClose:A,streamlinedTabs:H=!1,showSubtasksTab:B=!1,tasksTab:C,openAttachment:S,onAttachmentOpened:L,openSkillId:M,openSkillName:R,onSkillOpened:V}){const J=qi(),Q=RD(),{enabled:Z}=oD(),{enabled:P}=Bi(),te=Z?l.conversationAgentId??null:null,ne=B&&!te,ge=Wle(),K=vle(l),{data:ee}=Ok(l.id),ce=ee??Ble,{data:ie}=pf(l.id),ke=(0,u.useRef)(lC(d,l.companyId,l.id,I)),_e=C?.count??m.length,je=C?"Tasks":"Subtasks",ae=(0,u.useRef)(ne&&(_e>0||C?.hasError===!0)),de=(0,u.useRef)(ke.current?.userInteracted===!0&&ke.current.state.tabs.length===0),[Se,De]=(0,u.useState)(ke.current?.launcherOpen??!1),[nt,Re]=(0,u.useState)(null),ye=(0,u.useRef)(null),Ne=(0,u.useRef)(new Map),xe=(0,u.useRef)(ke.current?.userInteracted??!1),Pe=(0,u.useRef)(ke.current?.autoPlanHandled??!1),Ee=(0,u.useRef)(void 0),jt=(0,u.useRef)(void 0),oe=(0,u.useMemo)(()=>{const Ae=ke.current?.state;let Qe=P?ke.current?.userInteracted?Ae?.tabs??[]:[]:Ae?.tabs??(te?[lb()]:l.conversationAgentId?[mp()]:[cC()]);if(!te){const fe=Qe.filter(Be=>Be.payload.kind!=="agent-tasks");!P&&fe.length===0&&Qe.length>0&&l.conversationAgentId?Qe=[mp()]:Qe=fe}!P&&te&&!ke.current?.userInteracted&&Qe.length===1&&Qe[0].id==="artifacts"&&(Qe=[lb()]),ae.current?!P&&!de.current&&(Qe=hb(Qe)):Qe=Qe.filter(fe=>fe.payload.kind!=="subtasks");const ot=Ae?.activeTabId??"properties";return{tabs:Qe,activeTabId:Qe.some(fe=>fe.id===ot)?ot:Qe[0]?.id??null}},[]),re=(0,u.useCallback)(Ae=>{_le(d,l.companyId,l.id,{state:Ae,launcherOpen:Se,userInteracted:xe.current,autoPlanHandled:Pe.current,updatedAt:Date.now()})},[d,l.companyId,l.id,Se]),le=mL({initialState:oe,onStateChange:re}),mt=(0,u.useRef)(new Set),Pt=n??mt.current,Nt=(0,u.useRef)(new Set),Dt=r??Nt.current,Wt=(0,u.useCallback)(Ae=>FE(Ae,d,l),[d,l.companyId,l.id]);(0,u.useEffect)(()=>{const Ae=new Set(e.map(ll));for(const Qe of le.tabs)!t&&Qe.payload.kind==="plugin-panel"&&!Ae.has(Qe.id)&&le.closeTab(Qe.id);for(const Qe of e){if(!Qe.autoOpen||!Qe.runId)continue;const ot=Wt(Qe);if(Dt.has(ot))continue;const fe=!Pt.has(ot);Pt.add(ot),!(!fe&&le.tabs.some(Be=>Be.id===ll(Qe)))&&(fe&&De(!1),le.openTab(hC(Qe),fe))}},[Dt,Pt,Wt,e,t,le.tabs,le.closeTab,le.openTab]);const Zt=zE(l.id,l.companyId),es=Zt.data?.findLast(Ae=>Ae.status==="running"||Ae.status==="idle");(0,u.useEffect)(()=>{i&&(P&&(xe.current=!0),De(!1),le.openTab(cb(i)))},[i,le.openTab]),(0,u.useEffect)(()=>{i&&le.activeTabId===`browser:${i}`&&lC(d,l.companyId,l.id,I)?.state.activeTabId===le.activeTabId&&o?.()},[i,le.activeTabId,o,d,l.companyId,l.id,I]);const Ke=le.tabs.find(Ae=>Ae.id===le.activeTabId)??null,ps=Ke?.payload.kind,an=ps==="artifacts"||ps==="issue-document"||ps==="attachment"||ps==="workspace-file"||ps==="skill";(0,u.useLayoutEffect)(()=>{if(!(!O||!an))return O(!0),()=>O(!1)},[O,an]);const vs=!te&&!l.id.startsWith("chat:")&&le.tabs.some(Ae=>Ae.payload.kind==="artifacts"),ms=vs&&Ke?.payload.kind==="artifacts",Rs=ne&&(_e>0||C?.hasError===!0),ts=le.tabs.some(Ae=>Ae.id==="subtasks");(0,u.useEffect)(()=>{M&&(P&&(xe.current=!0),De(!1),le.openTab(Ale(M,R??"Skill")),V?.(M))},[le.openTab,V,M,R]),(0,u.useEffect)(()=>{if(!Rs){de.current=!1,ts&&le.closeTab("subtasks");return}!P&&!ts&&!de.current&&le.resetTabs({tabs:hb(le.tabs),activeTabId:le.activeTabId})},[le.activeTabId,le.closeTab,le.resetTabs,le.tabs,ts,Rs,P]),(0,u.useEffect)(()=>{if(g){Re(null);return}Re(document.getElementById(r1))},[g]),(0,u.useEffect)(()=>{ie!==null||!le.tabs.some(Ae=>Ae.id==="document:plan")||(Pe.current=!1,le.closeTab("document:plan"))},[le.closeTab,le.tabs,ie]),(0,u.useEffect)(()=>{P||!ie||Pe.current||xe.current||(Pe.current=!0,le.openTab(hp("plan",no(ie))))},[le.openTab,ie,P]),(0,u.useEffect)(()=>{if(!T){jt.current=void 0;return}if(jt.current===T.requestId)return;const Ae=Al(J.hash),Qe=Ae?.documentKey===T.documentKey?Ae:null,ot=Qe?.documentIssueId&&Qe.documentIssueId!==l.id?Qe.documentIssueId:void 0;if(T.documentKey==="plan"&&ie===null&&!Qe?.revisionId&&!ot)return;const fe=ot?void 0:ce.find(X=>X.key===T.documentKey),Be=fe?no(fe):T.documentKey==="plan"?"Plan":T.documentKey;jt.current=T.requestId,P&&(xe.current=!0);const rt=hp(T.documentKey,Be,Qe?.revisionId,ot);T.focusActivePlan&&T.documentKey==="plan"&&rt.id===le.activeTabId&&zoe(ye.current),le.openTab(rt)},[le.activeTabId,le.openTab,T,ce,ie,J.hash,l.id]),(0,u.useEffect)(()=>{I&&(ge.state?(P&&(xe.current=!0),le.openTab(uC(ge.state))):ge.browse&&(P&&(xe.current=!0),le.openTab(dC()),le.updateTab("files",{payload:{kind:"files-browser",query:ge.query,folderPath:ge.folderPath,projectId:ge.browseProjectId,workspaceId:ge.browseWorkspaceId}})))},[le.openTab,le.updateTab,I,ge.browse,ge.browseProjectId,ge.browseWorkspaceId,ge.folderPath,ge.query,ge.state]),(0,u.useEffect)(()=>{z===void 0||Ee.current===z||(Ee.current=z,P||le.openTab(mp(),!1),q?.(z))},[z,le.openTab,q,P]),(0,u.useEffect)(()=>{S&&(xe.current=!0,De(!1),le.openTab(mC(S.id,S.title)),(ge.state||ge.browse)&&ge.close(),L?.())},[le.openTab,S,L]);const Ds=Te({queryKey:G.issues.fileResources(l.id,{workspace:"auto",mode:"recent",limit:5,offset:0}),queryFn:a(()=>To.list(l.id,{workspace:"auto",mode:"recent",limit:5,offset:0}),"queryFn"),enabled:I&&(Se||!Ke),staleTime:15e3}),fn=Sn(Ds);function ht(){xe.current=!0}a(ht,"markInteracted");function Ls(){le.activeTabId&&ye.current&&Ne.current.set(le.activeTabId,ye.current.scrollTop)}a(Ls,"captureScroll");function An(Ae){Ls(),ht(),le.selectTab(Ae);const Qe=le.tabs.find(ot=>ot.id===Ae);Qe&&(Qe.payload.kind==="workspace-file"?ge.open(Qe.payload):Qe.payload.kind==="files-browser"?ge.openBrowse({q:Qe.payload.query??void 0}):(ge.state||ge.browse)&&ge.close())}a(An,"selectTab"),(0,u.useLayoutEffect)(()=>{const Ae=Ne.current.get(le.activeTabId??"")??0;return Uoe(ye.current,Ae)},[le.activeTabId]),(0,u.useEffect)(()=>{Ke||window.requestAnimationFrame(()=>{ye.current?.querySelector('input[aria-label="Search tabs and resources…"]')?.focus()})},[Ke]);function ws(Ae){ht(),Ae==="subtasks"&&(de.current=!0);const Qe=le.tabs.find(ot=>ot.id===Ae);if(Qe?.payload.kind==="plugin-panel"){const ot=e.find(fe=>ll(fe)===Ae);ot&&Dt.add(Wt(ot))}le.closeTab(Ae),Ae===le.activeTabId&&(Qe?.payload.kind==="workspace-file"||Qe?.payload.kind==="files-browser")&&ge.close()}a(ws,"closeTab");function Kt(Ae){ht(),le.openTab(hp(Ae.key,no(Ae)))}a(Kt,"openDocument");function zn(Ae){ht();const Qe=uC(Ae);le.openTab(Qe),ge?.open({...Ae,projectId:Ae.projectId??null,workspaceId:Ae.workspaceId??null,line:Ae.line??null,column:Ae.column??null},{fromBrowse:!0})}a(zn,"openWorkspaceFile");const Un=(0,u.useMemo)(()=>new Map(ce.map(Ae=>[Ae.key,Ae])),[ce]),Yn=(0,u.useMemo)(()=>le.tabs.map(Ae=>{const Qe=Ae.payload.kind==="issue-document"&&(!Ae.payload.documentIssueId||Ae.payload.documentIssueId===l.id)?Un.get(Ae.payload.documentKey):null,ot=Zt.data?.findIndex(Be=>Ae.payload.kind==="browser"&&(Be.id===Ae.payload.browserId||Be.sessionId===Ae.payload.browserId))??-1,fe=ot>=0&&(Zt.data?.length??0)>1?`Browser ${ot+1}`:null;return{id:Ae.id,type:Ae.type,label:fe??(Ae.payload.kind==="subtasks"&&C?"Tasks":Qe?no(Qe):Ae.label),ariaLabel:Ae.payload.kind==="subtasks"?je:Ae.ariaLabel,closable:!0,contentMode:Ae.contentMode,icon:zle(Ae)}}),[le.tabs,Un,_e,je,C,Zt.data,l.id]),bn=(0,u.useMemo)(()=>{const Ae=te?[{id:"agent-tasks",label:"Tasks",description:"Tasks this agent worked on",icon:(0,s.jsx)(Wg,{}),alreadyOpen:le.tabs.some(fe=>fe.id==="agent-tasks")},{id:"artifacts",label:"Artifacts",description:"Files this agent produced",icon:(0,s.jsx)(vh,{}),alreadyOpen:le.tabs.some(fe=>fe.id==="artifacts")},{id:"properties",label:"Properties",icon:(0,s.jsx)(Du,{}),alreadyOpen:le.tabs.some(fe=>fe.id==="properties")}]:[{id:"properties",label:"Properties",icon:(0,s.jsx)(Du,{}),alreadyOpen:le.tabs.some(fe=>fe.id==="properties")},...Rs?[{id:"subtasks",label:je,description:C?.hasError?"Could not load all tasks":`${_e} total`,icon:(0,s.jsx)(Zg,{}),alreadyOpen:le.tabs.some(fe=>fe.id==="subtasks")}]:[],{id:"artifacts",label:"Artifacts",icon:(0,s.jsx)(vh,{}),alreadyOpen:le.tabs.some(fe=>fe.id==="artifacts")}];for(const[fe,Be]of(Zt.data??[]).entries())Ae.push({id:`browser:${Be.id}`,label:(Zt.data?.length??0)>1?`Browser ${fe+1}`:"Browser",description:Be.status,icon:(0,s.jsx)(Tl,{}),alreadyOpen:le.tabs.some(rt=>rt.id===`browser:${Be.id}`)});for(const fe of e)Ae.push({id:ll(fe),label:fe.slot.displayName,icon:(0,s.jsx)(G1,{}),alreadyOpen:le.tabs.some(Be=>Be.id===ll(fe))});I&&Ae.push({id:"files",label:"Files",icon:(0,s.jsx)(co,{}),shortcut:"G F",alreadyOpen:le.tabs.some(fe=>fe.id==="files")});const Qe=[...ie?[{id:"document:plan",label:no(ie),description:`Revision ${ie.latestRevisionNumber??1}`,icon:(0,s.jsx)(kv,{}),alreadyOpen:le.tabs.some(fe=>fe.id==="document:plan")}]:[],...ce.filter(fe=>fe.key!=="plan"&&!Ld(fe.key)).sort((fe,Be)=>new Date(Be.updatedAt).getTime()-new Date(fe.updatedAt).getTime()).map(fe=>({id:`document:${fe.key}`,label:no(fe),description:`Revision ${fe.latestRevisionNumber??1}`,icon:(0,s.jsx)(Fn,{}),alreadyOpen:le.tabs.some(Be=>Be.id===`document:${fe.key}`)}))],ot=[{id:"open",label:"Open",items:Ae}];if(Qe.length>0&&ot.push({id:"documents",label:"Task documents",items:Qe}),I){const fe=Ds.data?.state==="available"?Ds.data.items.filter(Be=>Be.kind==="file").slice(0,5).map(Be=>({id:`recent-file:${Be.workspaceId}:${Be.relativePath}`,label:Be.title,description:Be.displayPath,searchText:Be.relativePath,icon:(0,s.jsx)(El,{})})):[];ot.push({id:"recent-files",label:"Recent workspace files",items:fe,loading:Ds.isLoading,error:fn.kind==="error"?"Recent files are temporarily unavailable.":null})}return ot},[e,Zt.data,te,_e,je,C?.hasError,le.tabs,ce,I,ie,Ds.data,fn.kind,Ds.isLoading,Rs]);function gs(Ae){if(ht(),Ae.id.startsWith("browser:"))le.openTab(cb(Ae.id.slice(8)));else if(Ae.id.startsWith("plugin:")){const Qe=e.find(ot=>ll(ot)===Ae.id);Qe&&(Dt.delete(Wt(Qe)),le.openTab(hC(Qe)))}else if(Ae.id==="properties")le.openTab(cC());else if(Ae.id==="subtasks")de.current=!1,le.resetTabs({tabs:hb(le.tabs),activeTabId:"subtasks"});else if(Ae.id==="artifacts")le.openTab(mp());else if(Ae.id==="agent-tasks")le.openTab(lb());else if(Ae.id==="files")le.openTab(dC()),ge.openBrowse();else if(Ae.id.startsWith("document:")){const Qe=Ae.id.slice(9);le.openTab(hp(Qe,Ae.label))}else if(Ae.id.startsWith("recent-file:")&&Ds.data?.state==="available"){const Qe=Ds.data.items.find(ot=>Ae.id===`recent-file:${ot.workspaceId}:${ot.relativePath}`);Qe?.kind==="file"&&zn({path:Qe.relativePath,workspace:Ule(Qe.workspaceKind),projectId:Qe.projectId??null,workspaceId:Qe.workspaceId})}}a(gs,"selectLauncherItem");const pn=(0,s.jsx)(wj,{sections:bn,onSelect:gs,presentation:"popover",open:Se,onOpenChange:De,trigger:(0,s.jsx)(W,{type:"button",variant:"ghost",size:"icon-sm",className:E("shrink-0 text-muted-foreground hover:text-foreground focus-visible:text-foreground",b?"size-(--sz-44px) rounded-md":H?"h-(--side-panel-tab-height) w-(--side-panel-tab-height) rounded-md":"h-(--side-panel-tab-height) w-(--side-panel-tab-height) rounded-(--side-panel-control-radius)"),"aria-label":"Open a new tab",children:(0,s.jsx)(fi,{"aria-hidden":!0})})}),rs=b?(0,s.jsx)(nL,{tabs:Yn,activeTabId:le.activeTabId,onActiveTabChange:An,onCloseTab:ws,addControl:pn}):(0,s.jsx)(yL,{tabs:Yn,activeTabId:le.activeTabId,onActiveTabChange:An,onCloseTab:ws,onReorderTabs:a(Ae=>{ht(),le.reorderTabs(Ae)},"onReorderTabs"),addControl:pn,appearance:H?"streamlined-task":"default"});let Jt;if(!Ke)Jt=(0,s.jsx)(wj,{sections:bn,onSelect:gs});else if(Ke.payload.kind==="browser")Jt=null;else if(Ke.payload.kind==="plugin-panel"){const Ae=e.find(Qe=>ll(Qe)===Ke.id);Jt=Ae?(0,s.jsx)(_A,{slot:Ae.slot,context:{companyId:l.companyId,projectId:l.projectId,entityId:Ae.entityId,entityType:"agent"}},ll(Ae)):null}else if(Ke.payload.kind==="properties")Jt=(0,s.jsx)(ev,{issue:l,childIssues:m,issueLinkState:h,onAddSubIssue:f,onUpdate:p,inline:g,hasActiveRun:y,externalObjects:x,externalObjectsLoading:v,externalObjectsError:k,onRetryExternalObjects:w,onCheckMonitorNow:j,checkingMonitorNow:_,sidePanelContentOnly:!0});else if(Ke.payload.kind==="subtasks")Jt=C?.content??(0,s.jsx)(Vw,{items:m,onAddSubtask:f,issueLinkState:h});else if(Ke.payload.kind==="agent-tasks")Jt=te?P?(0,s.jsx)(Ooe,{conversationIssueId:l.id}):(0,s.jsx)(hle,{companyId:l.companyId,agentId:te,excludeIssueId:l.id}):null;else if(Ke.payload.kind==="artifacts"&&te)Jt=(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("section",{"aria-label":"Conversation documents",children:(0,s.jsx)(n$,{issue:l,documentEditor:c??{}})}),(0,s.jsx)(xle,{companyId:l.companyId,agentId:te})]});else if(Ke.payload.kind==="artifacts")Jt=(0,s.jsx)(Ko.Provider,{value:a((Ae,Qe)=>{ht(),le.openTab(mC(Ae,Qe)),(ge.state||ge.browse)&&ge.close()},"value"),children:(0,s.jsx)(a$,{issue:l,documentEditor:c??{},onOpenDocument:Kt,uploadState:K})});else if(Ke.payload.kind==="issue-document"){const{documentKey:Ae,revisionId:Qe,documentIssueId:ot}=Ke.payload,fe=ot??l.identifier??l.id,Be=Ae==="plan"&&!Qe&&!ot?(0,s.jsx)(e$,{issue:l,inline:g}):(0,s.jsx)(Ele,{companyId:l.companyId,issueId:ot??l.id,documentKey:Ae,revisionId:Qe,documentIssueId:ot,currentIssueId:l.id,initialDocument:!ot||ot===l.id?Un.get(Ae):void 0});Jt=F?(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(Tle,{taskRef:fe}),Be]}):Be}else if(Ke.payload.kind==="attachment")Jt=(0,s.jsx)(Foe,{issueId:l.id,attachmentId:Ke.payload.attachmentId},Ke.payload.attachmentId);else if(Ke.payload.kind==="skill")Jt=(0,s.jsx)(qle,{companyId:l.companyId,skillId:Ke.payload.skillId});else if(Ke.payload.kind==="files-browser")Jt=(0,s.jsx)(nv,{issueId:l.id,companyId:l.companyId,onOpen:zn,onBrowseStateChange:a(Ae=>{le.updateTab(Ke.id,{payload:{kind:"files-browser",query:Ae.q,folderPath:Ae.folderPath,projectId:Ae.projectId,workspaceId:Ae.workspaceId}}),ge.updateBrowseState(Ae)},"onBrowseStateChange"),initialQuery:Ke.payload.query,initialFolderPath:Ke.payload.folderPath,initialProjectId:Ke.payload.projectId,initialWorkspaceId:Ke.payload.workspaceId,active:!0,className:"h-full min-h-0 p-3"});else{const Ae=Ke.payload;Jt=(0,s.jsx)(Ole,{issueId:l.id,payload:Ae,onFallbackToProject:Ae.workspace!=="project"&&!Ae.projectId&&!Ae.workspaceId?()=>zn({...Ae,workspace:"project"}):void 0})}const yn=Ke?.contentMode??"full-bleed",ss=(0,s.jsxs)(s.Fragment,{children:[rs,vs?(0,s.jsx)("div",{"data-artifact-upload-slot":!0,className:E("shrink-0",!ms&&"invisible"),"aria-hidden":!ms,inert:!ms,children:(0,s.jsx)(Zie,{onUpload:K.upload})}):null]});return(0,s.jsx)(ble,{enabled:ms,target:nt?.closest("[data-presentation]"),onUpload:K.upload,children:(0,s.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,s.jsx)("span",{className:"sr-only",role:"status","aria-live":"polite",children:K.announcement}),nt?(0,Mu.createPortal)(ss,nt):(0,s.jsxs)("div",{className:"flex h-(--side-panel-header-height) shrink-0 items-center gap-1 px-2",children:[ss,A?b?(0,s.jsx)(W,{variant:"ghost",size:"icon",className:"size-(--sz-44px) shrink-0","aria-label":"Close side panel",onClick:A,children:(0,s.jsx)(Gs,{"aria-hidden":!0})}):(0,s.jsx)(vb,{open:!0,onToggle:A}):null]}),(0,s.jsxs)("div",{ref:ye,"data-side-panel-content-viewport":"true",onScroll:Q,role:Ke?"tabpanel":void 0,id:Ke?`side-panel-content-${Ke.id}`:void 0,"aria-labelledby":Ke?`side-panel-tab-${Ke.id}`:void 0,className:E("min-h-0 flex-1",yn==="full-bleed"?"overflow-hidden":"overflow-auto",yn!=="full-bleed"&&"scrollbar-while-scrolling",yn==="padded"&&"p-4"),children:[le.tabs.map(Ae=>Ae.payload.kind==="browser"?(0,s.jsx)("div",{hidden:Ae.id!==le.activeTabId,className:E("h-full min-h-0",Ae.id!==le.activeTabId&&"hidden"),children:(0,s.jsx)(Joe,{active:Ae.id===le.activeTabId,issueId:l.id,browser:Zt.data?.find(Qe=>Ae.payload.kind==="browser"&&(Qe.id===Ae.payload.browserId||Qe.sessionId===Ae.payload.browserId)),accessError:Zt.isError,onOpenActiveBrowser:es?()=>le.openTab(cb(es.id)):void 0})},Ae.id):null),yn==="prose"?(0,s.jsx)("div",{"data-side-panel-prose-content":"true",className:"mx-auto w-full max-w-4xl px-6 py-4",children:Jt}):Jt]})]})})}a(Kle,"TaskSidePanelForScope");function Vle({scope:e,canPause:t,canResume:n,canCancel:r,canRestore:i,pending:o,onPause:l,onResume:c,onCancel:d,onRestore:m}){const h="flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 disabled:opacity-50 disabled:pointer-events-none";return(0,s.jsxs)(s.Fragment,{children:[t?(0,s.jsxs)("button",{disabled:o,className:h,onClick:l,children:[(0,s.jsx)(nf,{className:"h-3 w-3"}),e==="leaf"?"Pause work":"Pause subtree"]}):null,n?(0,s.jsxs)("button",{disabled:o,className:h,onClick:c,children:[(0,s.jsx)($L,{className:"h-3 w-3"}),e==="leaf"?"Resume work":"Resume subtree"]}):null,r?(0,s.jsxs)("button",{disabled:o,className:`${h} text-destructive`,onClick:d,children:[(0,s.jsx)($a,{className:"h-3 w-3"}),"Cancel subtree..."]}):null,i?(0,s.jsxs)("button",{disabled:o,className:h,onClick:m,children:[(0,s.jsx)(vl,{className:"h-3 w-3"}),"Restore subtree..."]}):null]})}a(Vle,"TaskTreeControlMenuItems");function Hle({open:e,onOpenChange:t,mode:n,scope:r,affectedCount:i,affectedAgentCount:o,warnings:l=[],loading:c,error:d,pending:m,valid:h,wakeAgents:f,onWakeAgentsChange:p,onRetry:g,onApply:b}){const y=n==="cancel",x=`${i} task${i===1?"":"s"}`,v=y?"Cancel subtree?":n==="restore"?"Restore subtree":r==="leaf"?"Resume work":"Resume subtree";return(0,s.jsx)(Qr,{open:e,onOpenChange:a(k=>{m||t(k)},"onOpenChange"),children:(0,s.jsxs)(Vr,{showCloseButton:!m,className:"max-h-(--sz-calc-18) overflow-y-auto sm:max-w-sm",children:[(0,s.jsxs)(ca,{children:[(0,s.jsx)(Hr,{children:v}),(0,s.jsx)(Na,{children:c?"Loading…":y?`${x} will be cancelled.`:n==="restore"?`${x} will be restored.`:`The pause will be removed from ${x}.`})]}),d?(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:d}),(0,s.jsx)(W,{size:"sm",variant:"outline",disabled:m,onClick:g,children:"Retry preview"})]}):null,y?null:(0,s.jsxs)("label",{className:"flex items-center gap-2 text-sm",children:[(0,s.jsx)("input",{type:"checkbox",checked:f&&o>0,disabled:m||c||o===0,onChange:a(k=>p(k.target.checked),"onChange")}),"Wake affected agents (",o,")"]}),c?null:l.map(k=>(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:k},k)),(0,s.jsxs)(po,{children:[(0,s.jsx)(W,{variant:"outline",disabled:m,onClick:a(()=>t(!1),"onClick"),children:y?"Keep tasks":"Close"}),(0,s.jsx)(W,{variant:y?"destructive":"default",disabled:m||c||!!d||!h,onClick:b,children:m?"Applying…":y?`Cancel ${x}`:n==="restore"?`Restore ${x}`:v})]})]})})}a(Hle,"TaskTreeControlDialog");function Qle({issueId:e,attachments:t,workProducts:n,documents:r,onArrival:i}){const o=(0,u.useRef)({issueId:void 0,ids:new Set});(0,u.useEffect)(()=>{if(o.current.issueId!==e&&(o.current={issueId:e,ids:new Set}),!e)return;const l={attachments:t?.filter(VT).map(m=>`attachment:${m.id}`),workProducts:n?.map(m=>{const h=Dd(m);return h?`attachment:${h.attachmentId}`:`work-product:${m.id}`}),documents:r?.filter(m=>m.key!=="plan"&&!Ld(m.key)).map(m=>`document:${m.id}`)},c=o.current;let d=!1;for(const m of Object.values(l))if(m)for(const h of m)c.ids.has(h)||(d=!0),c.ids.add(h);d&&i()},[e,t,n,r,i])}a(Qle,"useTaskArtifactArrival");function zk(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}a(zk,"asRecord$3");function Ti(e){return typeof e=="string"?e:null}a(Ti,"asString");function rv(e){return typeof e=="number"&&Number.isFinite(e)?e:null}a(rv,"asFiniteNumber");function Gle(e){return e===!0}a(Gle,"asBoolean");function Yle(e){const t=zk(e);return t?{attempted:Gle(t.attempted),outcome:Ti(t.outcome)??"no_process_metadata",adapterType:Ti(t.adapterType),pid:rv(t.pid),processGroupId:rv(t.processGroupId),error:Ti(t.error)}:{attempted:!1,outcome:"no_process_metadata",adapterType:null,pid:null,processGroupId:null,error:null}}a(Yle,"parseCleanup");function Jle(e){const t=zk(e);if(!t)return null;const n=Ti(t.sourceIssueId),r=Ti(t.sourceIssueStatus);if(!n||!r)return null;const i=Ti(t.sameRunEvidenceKind),o=Ti(t.sameRunEvidenceId),l=Ti(t.sameRunEvidenceAt);return!i||!o||!l?null:{sourceIssueId:n,sourceIssueIdentifier:Ti(t.sourceIssueIdentifier),sourceIssueStatus:r,sameRunEvidenceKind:i,sameRunEvidenceId:o,sameRunEvidenceAt:l,silenceStartedAt:Ti(t.silenceStartedAt),silenceAgeMs:rv(t.silenceAgeMs),evaluationIssueId:Ti(t.evaluationIssueId),evaluationIssueIdentifier:Ti(t.evaluationIssueIdentifier),cleanup:Yle(t.cleanup)}}a(Jle,"parseSourceResolvedWatchdogFold");function Xle(e){const t=zk(e);return t?Jle(t.sourceResolvedWatchdogFold):null}a(Xle,"readSourceResolvedWatchdogFold");var Zle={terminated:"terminated",termination_sent_still_running:"termination sent (still running)",failed:"failed",not_running:"not running",no_process_metadata:"no process metadata",skipped_non_local_adapter:"skipped (non-local adapter)"};function Khe(e){return Zle[e]??e.replace(/_/g," ")}a(Khe,"formatCleanupOutcome");function Vhe(e){if(!e||e<=0)return null;const t=Math.floor(e/6e4);if(t<1)return"under 1 minute";if(t<60)return`${t} minute${t===1?"":"s"}`;const n=Math.floor(t/60),r=t%60;return r===0?`${n} hour${n===1?"":"s"}`:`${n}h ${r}m`}a(Vhe,"formatSilenceAgeMs");function Hhe(e){return e.length<=12?e:e.slice(0,8)}a(Hhe,"shortenEvidenceId");function ece({className:e,title:t="System folded this run as a source-resolved false positive.",showIcon:n=!0}){return(0,s.jsxs)("span",{className:E("inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-(length:--text-micro) font-medium","border-emerald-300/60 bg-emerald-50/80 text-emerald-900","dark:border-emerald-500/30 dark:bg-emerald-500/10 dark:text-emerald-200",e),title:t,"aria-label":"Source-resolved watchdog fold",children:[n?(0,s.jsx)(sA,{className:"h-3 w-3 text-emerald-700 dark:text-emerald-300","aria-hidden":!0}):null,"Source-resolved"]})}a(ece,"SourceResolvedFoldBadge");function tce({code:e,userName:t,className:n}){const r=Lb(e,{userName:t}),i=r.tone==="unavailable",o=i?j6:bc,l=i?"border-amber-300/70 bg-amber-50/90 text-amber-950 dark:border-amber-500/40 dark:bg-amber-500/10 dark:text-amber-100":"border-red-300/70 bg-red-50/90 text-red-950 dark:border-red-500/40 dark:bg-red-500/10 dark:text-red-100",c=i?"text-amber-600 dark:text-amber-300":"text-red-600 dark:text-red-300",d=i?"text-amber-800 dark:text-amber-200":"text-red-800 dark:text-red-200";return(0,s.jsx)("div",{role:"status","data-testid":"responsible-user-denial-notice","data-denial-code":e,"data-denial-tone":r.tone,className:E("rounded-md border px-3 py-2.5 text-sm shadow-sm",l,n),children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)(o,{className:E("mt-0.5 h-4 w-4 shrink-0",c),"aria-hidden":"true"}),(0,s.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,s.jsx)("p",{className:"font-medium leading-5",children:r.title}),(0,s.jsx)("p",{className:"leading-5",children:r.description}),(0,s.jsx)("p",{className:E("text-xs leading-5",d),children:r.recommendedAction})]})]})})}a(tce,"ResponsibleUserDenialNotice");var Xa=a((e,t,n)=>({disposition:"inline",surface:e,story:t,rationale:n}),"inline"),Kr=a((e,t)=>({disposition:"folded",surface:e,story:null,rationale:t}),"folded"),fb=a((e,t)=>({disposition:"debug-only",surface:e,story:null,rationale:t}),"debugOnly"),sce=["plan.updated","plan.proposed","tool.execution.started","tool.execution.progressed","tool.execution.completed","research.started","research.progressed","research.completed","delegation.started","delegation.updated","delegation.completed","model.route.changed","model.verification.updated","context.compacted","artifact.viewed","artifact.generated","review.mode.changed","hook.started","hook.completed","memory.citation.referenced","safety.review.started","safety.review.completed","terminal.input.sent","wait.started","wait.completed","provider.notice.recorded"],nce=["runner.connected","runner.reconnected","runner.reconciled","runner.disconnected","runner.draining","runner.backpressure","runner.suspending","runner.suspended","runner.stopped","runtime.phase.changed","workspace.ready","harness.starting","harness.ready","harness.exited","session.starting","session.started","session.resuming","session.resumed","session.reconciled","session.updated","session.closed","turn.submitted","turn.accepted","turn.started","turn.completed","run.attached","run.detached"],rce=["runner.diagnostic","harness.diagnostic","session.failed","turn.failed","turn.interrupted","turn.cancelled","item.failed"],ace=["item.started","item.delta","item.completed","usage.reported"],ice=["mcp_app.discovered","mcp_app.resource.resolved","mcp_app.initializing","mcp_app.ready","mcp_app.host_context.changed","mcp_app.failed","mcp_app.teardown"],oce=["interaction.request.proposed","interaction.request.materialized","interaction.request.rejected","interaction.response.progressed","interaction.response.resolved","interaction.response.delivered"],lce=["attention.request.proposed","attention.request.routed","attention.request.resolved","attention.request.expired","attention.request.superseded","work.assessment.recorded","issue.status.decision.recorded","issue.status.decision.applied","issue.status.decision.rejected","issue.status.decision.superseded"],cce=Object.freeze({...Object.fromEntries(sce.map(e=>[e,Xa("provider_activity","Task Page/Runner Protocol/Provider semantics","Provider-neutral semantic activity is readable in the task turn.")])),"workspace.change.updated":Xa("workspace_change","Task Page/Runner Protocol/Workspace changes","In-progress workspace changes update one diff card."),"workspace.diff.recorded":Xa("workspace_change","Task Page/Runner Protocol/Workspace changes","The runner-verified final diff replaces the in-progress revision."),"workspace.file.referenced":Xa("workspace_file","Task Page/Runner Protocol/File references","Verified references open a bounded preview and the production file viewer."),"semantic_tool.input":Kr("tool","Semantic operations reuse the production tool row."),"semantic_tool.result":Kr("tool","Semantic operation outcomes update the matching tool row."),"semantic_tool.reconciled":Kr("tool","Recovered semantic operation outcomes update the matching tool row without duplicating it."),"mcp_app.tool_input":Kr("tool","MCP inputs reuse the production tool row."),"mcp_app.tool_result":Kr("tool","MCP outcomes update the matching tool row."),"mcp_app.action.requested":Kr("interaction","Action requests materialize as authoritative issue-thread interactions."),"mcp_app.action.resolved":Kr("interaction","Action resolution is shown on the authoritative interaction card."),"runtime_request.created":Xa("runtime_request","Task Page/Runner Protocol/Runtime requests","Pending provider runtime requests remain visible and actionable when a resolver is available."),"runtime_request.resolved":Kr("runtime_request","Resolution updates the existing request card."),"runtime_request.expired":Kr("runtime_request","Expiry updates the existing request card."),"runtime_request.cancelled":Kr("runtime_request","Cancellation updates the existing request card."),...Object.fromEntries(oce.map(e=>[e,Kr("interaction","The control-plane interaction record is canonical and owns rendering.")])),"run.result.proposed":Xa("run_result","Task Page/Runner Protocol/Results and terminal states","Structured completion, evidence, verification, blockers, and artifacts remain inspectable."),"run.result.accepted":Kr("run_result","Acceptance updates the existing result without duplicating it."),"run.result.rejected":Kr("run_result","Rejected results remain part of run governance rather than a second completion card."),"run.terminal":Xa("run_terminal","Task Page/Runner Protocol/Results and terminal states","Terminal outcome and stop reason remain visible."),...Object.fromEntries(nce.map(e=>[e,Kr("turn","Routine lifecycle transitions are summarized by the run turn and composer state.")])),...Object.fromEntries(rce.map(e=>[e,Kr("system_notice","Actionable failure text is folded into the run or system notice.")])),...Object.fromEntries(ace.map(e=>[e,Kr("conversation_or_tool","Item payloads normalize into messages, reasoning, tools, diffs, or usage.")])),"runtime.activity.recorded":Kr("task_panel","The activated plugin view appears in the task side panel."),"auth.credentials.updated":fb("run_debug","Credential updates notify the host and remain in run details."),"sandbox.metric":fb("run_debug","Sandbox telemetry is available in run details, not the primary task thread."),...Object.fromEntries(ice.map(e=>[e,fb("run_debug","MCP application transport lifecycle remains in run details unless it produces an actionable failure.")])),...Object.fromEntries(lce.map(e=>[e,Kr("governance","Authoritative task status, attention, and interaction records own this state.")]))}),Qhe=Object.freeze({"runtime.permission":Xa("runtime_request","Task Page/Runner Protocol/Runtime requests","Permission choices render on the runtime request card."),"runtime.input":Xa("runtime_request","Task Page/Runner Protocol/Runtime requests","Structured runtime input renders on the runtime request card."),"issue_thread.request_confirmation":Xa("interaction","Task Page/Runner Protocol/Interactions","Uses the production confirmation card."),"issue_thread.request_checkbox_confirmation":Xa("interaction","Task Page/Runner Protocol/Interactions","Uses the production bounded checkbox card."),"issue_thread.request_item_verdicts":Xa("interaction","Task Page/Runner Protocol/Interactions","Uses the production per-item verdict card."),"issue_thread.ask_user_questions":Xa("interaction","Task Page/Runner Protocol/Interactions","Uses the production typed question controls."),"issue_thread.suggest_tasks":Xa("interaction","Task Page/Runner Protocol/Interactions","Uses the production task suggestion tree.")}),Ghe=Object.freeze({done:"run_result",blocked:"run_result",needs_review:"run_result",yielded:"run_result"}),Yhe=Object.freeze({completed:"run_terminal",failed:"run_terminal",interrupted:"run_terminal",cancelled:"run_terminal"}),Jhe=Object.freeze({succeeded:"run_terminal",failed:"run_terminal",cancelled:"run_terminal"}),dce=[{value:"overview",label:"Overview",icon:xA},{value:"pipeline",label:"Pipeline",icon:ei},{value:"trace",label:"Exact trace",icon:l6}],uce=1e3;function Pa(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}a(Pa,"record");function bs(e){return typeof e=="string"?e:""}a(bs,"text");function vC(e,t){return`${e}:${t}`}a(vC,"revealedFrameKey");function Mg(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}a(Mg,"scalar");function gl(e){return[...new Set(e.filter(Boolean))]}a(gl,"unique");function fp(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KiB`:`${(e/1048576).toFixed(1)} MiB`}a(fp,"formatBytes");function mce(e,t){const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.click(),URL.revokeObjectURL(n)}a(mce,"downloadBlob");function wC(e){const t=atob(e);try{return JSON.parse(t)}catch{return t}}a(wC,"decodeExactFrame");function hce(e){return e==="complete"?"secondary":e==="incomplete"||e==="truncated"?"destructive":"outline"}a(hce,"statusVariant");function kC(e,t){if(e==="capturing")return"Raw trace enabled";if(e==="incomplete")return"Incomplete";if(e==="truncated")return"Truncated";if(e==="deleted")return"Deleted";if(e==="expired")return"Expired";const n=new Date(t).getTime()-Date.now();return!Number.isFinite(n)||n<=0?"Expired":`Expires in ${Math.max(1,Math.ceil(n/36e5))}h`}a(kC,"traceBadgeLabel");function D0(e){return Pa(e.parsed)}a(D0,"frameParsed");function ud(e){const t=D0(e);return bs(t.method)||bs(Pa(t.params).method)}a(ud,"frameMethod");function S$(e){const t=D0(e);return Pa(Pa(t.params).item??t.item)}a(S$,"frameItem");function fce(e){const t=D0(e),n=Pa(t.params);return bs(S$(e).type)||bs(n.itemType)||bs(t.type)}a(fce,"frameItemType");function L0(e){const t=Pa(e.payload),n=Pa(t.prpEvent);return Object.keys(n).length>0?n:t}a(L0,"eventPrp");function jC(e){return bs(L0(e).sourceEventId)}a(jC,"eventSourceId");function pce(e){const t=new Date(e.createdAt).getTime();return Number.isFinite(t)?t:Number.MAX_SAFE_INTEGER}a(pce,"eventTimestamp");function gce(e){const t=Mg(e.timestamp),n=Number(t);if(Number.isFinite(n))return n<1e10?n*1e3:n;const r=Date.parse(t);return Number.isFinite(r)?r:Number.MAX_SAFE_INTEGER}a(gce,"frameTimestamp");function $u(e){const t=cce[e.eventType];return t?{visible:t.disposition!=="debug-only",surface:t.surface,container:t.disposition==="inline"?"primary run turn":"collapsed activity",state:t.disposition,action:t.disposition==="inline"?"render":t.disposition==="folded"?"fold":"operator only",reasonCode:`presentation_${t.disposition}`,reason:t.rationale}:{visible:!1,surface:"run_debug",container:"Runner Inspector",state:"hidden",action:"none",reasonCode:"presentation_surface_unregistered",reason:"No production surface registration exists for this event type."}}a($u,"visibilityDecision");function _$(e){return Array.isArray(e.emittedEventIds)?e.emittedEventIds.map(String):[]}a(_$,"interpretationEventIds");function xce(e,t){const n=D0(e),r=Pa(n.params),i=S$(e),o=t.flatMap(_$).map(c=>`event:${c}`),l=Mg(n.id);if(l){const c=bs(e.direction),d=ud(e)?c==="client_to_provider"?"client":"provider":c==="client_to_provider"?"provider":"client";o.push(`rpc:${d}:${l}`)}for(const c of[i.id,r.itemId,r.callId,n.itemId]){const d=Mg(c);d&&o.push(`item:${d}`)}return gl(o)}a(xce,"frameCorrelationTokens");function bce(e,t,n){const r=[...e].sort((p,g)=>Number(p.frameId)-Number(g.frameId)),i=new Map(r.map(p=>[Number(p.frameId),p])),o=new Map([...i.keys()].map(p=>[p,p])),l=a(p=>{const g=o.get(p)??p;if(g===p)return p;const b=l(g);return o.set(p,b),b},"find"),c=a((p,g)=>{const b=l(p),y=l(g);b!==y&&o.set(y,b)},"union"),d=new Map;for(const p of r){const g=Number(p.frameId),b=t.filter(y=>Number(y.frameId)===g);for(const y of xce(p,b)){const x=d.get(y);x===void 0?d.set(y,g):c(x,g)}}const m=new Map;for(const p of r){const g=l(Number(p.frameId));m.set(g,[...m.get(g)??[],p])}const h=new Set,f=[];for(const p of m.values()){const g=new Set(p.map(T=>Number(T.frameId))),b=t.filter(T=>g.has(Number(T.frameId))),y=new Set(b.flatMap(_$)),x=n.filter(T=>y.has(jC(T)));x.forEach(T=>h.add(T.id));const v=gl(p.map(ud)),k=gl(p.map(fce)),w=k.at(-1)||v.at(-1)||bs(p[0]?.direction)||"Provider frame",j=p[0],_=p.at(-1),I=j===_?`frame ${j?.frameId}`:`frames ${j?.frameId}–${_?.frameId}`;f.push({key:`frames:${j?.frameId}`,frames:p,interpretations:b,events:x,title:w,subtitle:`${I} · ${x.length} PRP event${x.length===1?"":"s"}`,itemType:k.at(-1)??"",nativeMethods:v,directions:gl(p.map(T=>bs(T.direction))),dispositions:gl(b.map(T=>bs(T.disposition))),prpTypes:gl(x.map(T=>T.eventType)),visible:x.some(T=>$u(T).visible),timestamp:Math.min(...p.map(gce))})}for(const p of n){if(h.has(p.id))continue;const g=$u(p);f.push({key:`event:${p.id}`,frames:[],interpretations:[],events:[p],title:p.eventType,subtitle:`PRP ${jC(p)||`event ${p.seq}`} · no raw correlation`,itemType:"",nativeMethods:[],directions:[],dispositions:[],prpTypes:[p.eventType],visible:g.visible,timestamp:pce(p)})}return f.sort((p,g)=>p.timestamp-g.timestamp)}a(bce,"buildOperations");async function yce(e){const t=[];let n=0;for(;;){const r=await qn.events(e,n,1e3);if(t.push(...r),r.length<1e3)return t;const i=r.at(-1)?.seq??n;if(i<=n)return t;n=i}}a(yce,"loadAllRunEvents");function av(e,t){if(!t)return!0;try{return JSON.stringify(e).toLowerCase().includes(t.toLowerCase())}catch{return String(e).toLowerCase().includes(t.toLowerCase())}}a(av,"jsonMatches");function vce({value:e}){return typeof e=="string"?(0,s.jsxs)("span",{className:"text-primary",children:['"',e,'"']}):typeof e=="number"?(0,s.jsx)("span",{className:"text-muted-foreground",children:e}):typeof e=="boolean"?(0,s.jsx)("span",{className:"text-secondary-foreground",children:String(e)}):e===null?(0,s.jsx)("span",{className:"text-muted-foreground",children:"null"}):(0,s.jsx)("span",{children:String(e)})}a(vce,"JsonPrimitive");function C$({label:e,value:t,path:n,depth:r,query:i}){const o=t!==null&&typeof t=="object",l=Array.isArray(t)?t.map((x,v)=>[String(v),x]):Object.entries(Pa(t)),c=l.length>8,[d,m]=(0,u.useState)(r<1&&!c),h=!!i&&av(t,i),f=o&&(d||h),p=i?l.filter(([x,v])=>x.toLowerCase().includes(i.toLowerCase())||av(v,i)):l,g=Sh(),b=Sh(),y=a(()=>{const x=typeof t=="string"?t:JSON.stringify(t,null,2);b.copy(x??String(t))},"copyValue");return(0,s.jsxs)("div",{className:E(r>0&&"border-l border-border/60 pl-3"),children:[(0,s.jsxs)("div",{className:"group flex min-h-6 items-start gap-1 font-mono text-xs leading-6",children:[o?(0,s.jsx)("button",{type:"button",className:"mt-1 rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",onClick:a(()=>m(!f),"onClick"),"aria-label":f?"Collapse JSON value":"Expand JSON value",children:f?(0,s.jsx)(en,{className:"h-3 w-3"}):(0,s.jsx)(Us,{className:"h-3 w-3"})}):(0,s.jsx)("span",{className:"w-4"}),e!==void 0?(0,s.jsxs)("span",{className:"text-primary",children:[e,":"]}):null,o?(0,s.jsx)("span",{className:"text-muted-foreground",children:Array.isArray(t)?`[${l.length}]`:`{${l.length}}`}):(0,s.jsx)(vce,{value:t}),(0,s.jsxs)("span",{className:"ml-auto hidden items-center gap-0.5 group-hover:flex",children:[(0,s.jsx)("button",{type:"button",title:g.copied?"JSON path copied":g.failed?"Copy failed":"Copy JSON path",className:"rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground",onClick:a(()=>{g.copy(n)},"onClick"),children:g.copied?(0,s.jsx)(Ut,{className:"h-3 w-3"}):(0,s.jsx)(a6,{className:"h-3 w-3"})}),(0,s.jsx)("button",{type:"button",title:b.copied?"Value copied":b.failed?"Copy failed":"Copy value",className:"rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground",onClick:y,children:b.copied?(0,s.jsx)(Ut,{className:"h-3 w-3"}):(0,s.jsx)(yr,{className:"h-3 w-3"})})]})]}),f?(0,s.jsxs)("div",{children:[p.map(([x,v])=>(0,s.jsx)(C$,{label:x,value:v,path:Array.isArray(t)?`${n}[${x}]`:`${n}.${x}`,depth:r+1,query:i},`${n}.${x}`)),i&&p.length===0?(0,s.jsx)("p",{className:"pl-5 text-xs text-muted-foreground",children:"No fields match."}):null]}):null]})}a(C$,"JsonNode");function td({value:e,label:t="Search this JSON"}){const[n,r]=(0,u.useState)("");return(0,s.jsxs)("div",{className:E("overflow-hidden rounded-md border border-border bg-muted/20",Et),children:[(0,s.jsxs)("div",{className:"relative border-b border-border bg-background/60",children:[(0,s.jsx)(uo,{className:"absolute left-2.5 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),(0,s.jsx)(ia,{value:n,onChange:a(i=>r(i.target.value),"onChange"),placeholder:t,className:"h-8 border-0 bg-transparent pl-8 text-xs shadow-none focus-visible:ring-0"})]}),(0,s.jsx)("div",{className:"max-h-80 overflow-auto p-3",children:(0,s.jsx)(C$,{value:e,path:"$",depth:0,query:n.trim()})})]})}a(td,"JsonExplorer");function wce(e){const t=Array.isArray(e.fieldMappings)?e.fieldMappings.map(Pa).filter(i=>bs(i.action)).map(i=>({inputPath:bs(i.inputPath)||void 0,outputPath:bs(i.outputPath)||void 0,action:bs(i.action),reason:bs(i.reason)||void 0})):[],n=new Set(t.filter(i=>i.action==="dropped").map(i=>i.inputPath)),r=Array.isArray(e.droppedFields)?e.droppedFields.map(String).filter(i=>!n.has(i)).map(i=>({inputPath:i,action:"dropped",reason:bs(e.reason)||"Field was not carried into the next stage"})):[];return[...t,...r]}a(wce,"fieldMappings");function kce(e){return e==="dropped"||e==="redacted"?"border-destructive/30 bg-destructive/10 text-destructive":e==="derived"?"border-secondary bg-secondary text-secondary-foreground":"border-primary/30 bg-primary/10 text-primary"}a(kce,"mappingTone");function jce({entry:e,last:t}){const n=wce(e);return(0,s.jsxs)("div",{className:"relative grid grid-cols-(--gtc-runner-inspector-stage) gap-3",children:[(0,s.jsxs)("div",{className:"relative flex justify-center",children:[t?null:(0,s.jsx)("span",{className:"absolute bottom-(--sz-neg-1_25rem) top-4 w-px bg-border"}),(0,s.jsx)("span",{className:E("relative mt-1 h-3 w-3 rounded-full border-2 bg-background",e.disposition==="rejected"?"border-destructive":e.disposition==="ignored"?"border-muted-foreground":"border-primary")})]}),(0,s.jsxs)("div",{className:"mb-4 overflow-hidden rounded-lg border border-border bg-card",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b border-border/70 px-3 py-2",children:[(0,s.jsx)("code",{className:"text-xs font-semibold",children:bs(e.stage)}),(0,s.jsx)($t,{variant:"outline",className:"capitalize",children:bs(e.disposition)}),(0,s.jsx)("code",{className:"ml-auto text-(length:--text-nano) text-muted-foreground",children:bs(e.ruleId)})]}),(0,s.jsx)("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:bs(e.reason)}),n.length>0?(0,s.jsx)("div",{className:"overflow-x-auto border-t border-border/70",children:(0,s.jsxs)("table",{className:"w-full min-w-(--sz-36rem) text-left text-xs",children:[(0,s.jsx)("thead",{className:"bg-muted/30 text-muted-foreground",children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{className:"px-3 py-1.5 font-medium",children:"Action"}),(0,s.jsx)("th",{className:"px-3 py-1.5 font-medium",children:"Provider path"}),(0,s.jsx)("th",{className:"px-3 py-1.5 font-medium",children:"Output path"}),(0,s.jsx)("th",{className:"px-3 py-1.5 font-medium",children:"Reason"})]})}),(0,s.jsx)("tbody",{children:n.map((r,i)=>(0,s.jsxs)("tr",{className:"border-t border-border/50 align-top",children:[(0,s.jsx)("td",{className:"px-3 py-2",children:(0,s.jsx)("span",{className:E("rounded border px-1.5 py-0.5 text-(length:--text-nano)",kce(r.action)),children:r.action})}),(0,s.jsx)("td",{className:"px-3 py-2 font-mono",children:r.inputPath??"—"}),(0,s.jsx)("td",{className:"px-3 py-2 font-mono",children:r.outputPath??"—"}),(0,s.jsx)("td",{className:"max-w-xs px-3 py-2 text-muted-foreground",children:r.reason??"—"})]},`${r.inputPath}:${r.outputPath}:${i}`))})]})}):(0,s.jsx)("p",{className:"border-t border-border/70 px-3 py-2 text-(length:--text-nano) text-muted-foreground",children:"No field-level mapping was recorded at this stage."})]})]})}a(jce,"InterpretationStage");function Nce(e){const t=L0(e),n=Pa(t.payload),r=Pa(n.item);return[["Event type",e.eventType],["Source event",bs(t.sourceEventId)],["Sequence",Mg(t.sourceSequence)||String(e.seq)],["Item type",bs(r.type)||bs(n.kind)],["Status",bs(n.status)||bs(r.status)],["Query",bs(n.query)||bs(r.query)]].filter(([,i])=>!!i)}a(Nce,"typedPrpFields");function Ice({event:e,runId:t}){const n=L0(e),r=new Date(e.createdAt).toISOString(),i=f4(JSON.stringify({type:"paperclip.prp.event",event:n}),r),o=Um(i,{runId:t,agentName:"Runner",running:!1}).find(d=>d.kind==="protocol");if(o)return(0,s.jsx)(mf,{item:o});const l=$u(e),c=l.visible?Pu:Nh;return(0,s.jsx)("div",{className:"rounded-md border border-border bg-card/60 px-3 py-2.5",children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)(c,{className:"mt-0.5 h-4 w-4 text-muted-foreground"}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:e.eventType}),(0,s.jsxs)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["Production surface: ",l.surface," · ",l.action," in ",l.container]})]})]})})}a(Ice,"ProductionSurfacePreview");function gu({label:e,value:t,detail:n}){return(0,s.jsxs)("div",{className:"rounded-lg border border-border bg-card px-4 py-3",children:[(0,s.jsx)("p",{className:"text-(length:--text-nano) font-medium uppercase tracking-wide text-muted-foreground",children:e}),(0,s.jsx)("p",{className:"mt-1 text-2xl font-semibold tracking-tight",children:t}),n?(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:n}):null]})}a(gu,"StatCard");function Sce({runId:e,run:t,open:n,onOpenChange:r,onRerunWithTrace:i}){const[o,l]=(0,u.useState)(null),[c,d]=(0,u.useState)([]),[m,h]=(0,u.useState)(null),[f,p]=(0,u.useState)("pipeline"),[g,b]=(0,u.useState)(null),[y,x]=(0,u.useState)(null),[v,k]=(0,u.useState)(""),[w,j]=(0,u.useState)("all"),[_,I]=(0,u.useState)("all"),[T,F]=(0,u.useState)("all"),[O,z]=(0,u.useState)("all"),[q,A]=(0,u.useState)("all"),[H,B]=(0,u.useState)({}),[C,S]=(0,u.useState)(null),L=(0,u.useRef)(null),M=(0,u.useRef)(0),R=n&&C?.runId===e?C.allowed:null;(0,u.useLayoutEffect)(()=>{M.current+=1,L.current=null,S(null),l(null),d([]),h(null),b(null),x(null),B({})},[n,e]);const V=(0,u.useCallback)(()=>{const oe=L.current;if(oe?.runId===e&&oe.phase==="denied")return;M.current+=1;const re={runId:e,allowed:!1,epoch:M.current,phase:"denied"};L.current=re,S(re),l({trace:null,entries:[]}),h(null),b(null),x(null),B({})},[e]);(0,u.useEffect)(()=>{if(!n)return;const oe=new URLSearchParams(window.location.search),re=oe.get("traceView");(re==="overview"||re==="pipeline"||re==="trace")&&p(re);const le=oe.get("traceOperation");le&&b(le)},[n]);const J=x$({key:["runner-inspection",e,n],enabled:n,fetcher:a(async()=>{const oe=M.current,[re,le]=await Promise.all([Eo.getCurrentBoardAccess(),yce(e)]);if(M.current!==oe||L.current?.phase==="deleting")return null;const mt=re.source==="local_implicit"||re.isInstanceAdmin;return{loadEpoch:oe,canRaw:mt,trace:mt?await qn.providerTrace(e):{trace:null,entries:[]},events:le}},"fetcher"),onSuccess:a(oe=>{if(!oe||M.current!==oe.loadEpoch||L.current?.phase==="deleting")return;const re={runId:e,allowed:oe.canRaw,epoch:oe.loadEpoch,phase:oe.canRaw?"granted":"denied"};L.current=re,S(re),oe.canRaw||B({}),l(oe.trace),d(oe.events)},"onSuccess")}),Q=C?.runId!==e&&(J.view.kind==="loading"||J.view.kind==="reconnecting"),Z=J.view.kind==="error"?J.view.error:null;(0,u.useEffect)(()=>{if(!n)return;let oe=!0;const re=a(async()=>{try{const Nt=await Eo.getCurrentBoardAccess();if(!oe)return;Nt.source==="local_implicit"||Nt.isInstanceAdmin||V()}catch{oe&&V()}},"revalidate"),le=a(()=>{re()},"onFocus"),mt=a(()=>{document.visibilityState==="visible"&&re()},"onVisibilityChange"),Pt=window.setInterval(()=>{re()},uce);return window.addEventListener("focus",le),document.addEventListener("visibilitychange",mt),()=>{oe=!1,window.clearInterval(Pt),window.removeEventListener("focus",le),document.removeEventListener("visibilitychange",mt)}},[V,n]);const P=o?.entries??[],te=(0,u.useMemo)(()=>P.filter(oe=>oe.kind==="frame"),[P]),ne=(0,u.useMemo)(()=>P.filter(oe=>oe.kind==="interpretation"),[P]),ge=gl(te.map(oe=>bs(oe.provider))),K=(0,u.useMemo)(()=>bce(te,ne,c),[c,te,ne]),ee=(0,u.useMemo)(()=>K.filter(oe=>!(v.trim()&&!av(oe,v.trim())||w!=="all"&&!oe.directions.includes(w)||_!=="all"&&!oe.nativeMethods.includes(_)||T!=="all"&&!oe.dispositions.includes(T)||O!=="all"&&!oe.prpTypes.includes(O)||q==="visible"&&!oe.visible||q==="hidden"&&oe.visible)),[w,T,_,K,O,v,q]);(0,u.useEffect)(()=>{if(ee.length&&(!g||!ee.some(oe=>oe.key===g))){const oe=ee.find(re=>re.itemType&&re.events.length>0)??ee.find(re=>re.frames.length>0&&re.events.length>0)??ee[0];b(oe.key)}},[ee,g]);const ce=ee.find(oe=>oe.key===g)??ee[0]??null;(0,u.useEffect)(()=>{if(ce&&!ce.frames.some(oe=>Number(oe.frameId)===y)){const oe=[...ce.frames].reverse().find(re=>ud(re).includes("completed"))??ce.frames.at(-1);x(oe?Number(oe.frameId):null)}},[y,ce]),(0,u.useEffect)(()=>{if(!n||!ce)return;const oe=new URLSearchParams(window.location.search);oe.set("inspectRun",e),oe.set("traceView",f),oe.set("traceOperation",ce.key);const re=`${window.location.pathname}?${oe.toString()}${window.location.hash}`;window.history.replaceState(window.history.state,"",re)},[n,e,ce,f]);const ie=ce?.frames.find(oe=>Number(oe.frameId)===y)??ce?.frames.at(-1)??null,ke=R===!0&&ie?H[vC(e,Number(ie.frameId))]??null:null,_e=ie?ce?.interpretations.filter(oe=>Number(oe.frameId)===Number(ie.frameId))??[]:ce?.interpretations??[],je=ce?.events??[],ae=Pa(t?.resultJson),de=Pa(ae.presentationDecision),Se=Array.isArray(ae.verificationCaveats)?ae.verificationCaveats:[],De=Array.isArray(ae.ignoredAttentionRequests)?ae.ignoredAttentionRequests:[],nt=c.filter(oe=>$u(oe).visible).length,Re=ne.filter(oe=>oe.disposition==="ignored").length,ye=ne.reduce((oe,re)=>{const le=bs(re.disposition)||"unknown";return oe[le]=(oe[le]??0)+1,oe},{}),Ne=a(oe=>{b(oe.key),p("pipeline")},"selectOperation"),xe=a(async oe=>{if(R!==!0)return;const re=L.current;if(re?.runId!==e||re.allowed!==!0||!window.confirm("This exact provider frame may contain prompts, tool arguments, secrets, or reasoning. Reveal it now?"))return;const le=e,mt=await qn.revealProviderTraceFrame(le,oe),Pt=L.current;Pt?.runId!==le||Pt.allowed!==!0||Pt.epoch!==re.epoch||B(Nt=>({...Nt,[vC(le,oe)]:mt}))},"reveal"),Pe=a(async()=>{if(R!==!0)return;const oe=L.current;if(oe?.runId!==e||oe.allowed!==!0||!window.confirm("Download the exact raw trace? It may contain sensitive prompts, tool arguments, and provider-only fields."))return;const re=await qn.downloadProviderTrace(e),le=L.current;le?.runId!==e||le.allowed!==!0||le.epoch!==oe.epoch||mce(re,`provider-trace-${e}.ndjson`)},"downloadTrace"),Ee=a(async()=>{if(R!==!0)return;const oe=L.current;if(oe?.runId!==e||oe.allowed!==!0||!window.confirm("Delete this raw trace immediately? This cannot be undone."))return;M.current+=1;const re={...oe,allowed:!1,epoch:M.current,phase:"deleting"};L.current=re,S(re),B({});try{await qn.deleteProviderTrace(e)}catch(Pt){L.current?.epoch===re.epoch&&h(Pt);return}if(L.current?.epoch!==re.epoch)return;let le;try{le=await Eo.getCurrentBoardAccess()}catch{L.current?.epoch===re.epoch&&V();return}if(L.current?.epoch!==re.epoch)return;if(!(le.source==="local_implicit"||le.isInstanceAdmin)){V();return}M.current+=1;const mt={runId:e,allowed:!0,epoch:M.current,phase:"granted"};L.current=mt,S(mt),l({trace:null,entries:[]}),b(null),x(null)},"deleteTrace"),jt=a(oe=>{if(!oe){M.current+=1,L.current=null,S(null),l(null),d([]),b(null),x(null),B({});const re=new URLSearchParams(window.location.search);re.delete("inspectRun"),re.delete("traceView"),re.delete("traceOperation");const le=re.toString();window.history.replaceState(window.history.state,"",`${window.location.pathname}${le?`?${le}`:""}${window.location.hash}`)}r(oe)},"handleOpenChange");return(0,s.jsx)(Av,{open:n,onOpenChange:jt,children:(0,s.jsxs)($v,{className:"w-(--sz-calc-43) max-w-none gap-0 p-0 sm:max-w-none","aria-describedby":"runner-inspector-description",children:[(0,s.jsxs)(Ab,{className:"border-b border-border pr-12",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(Op,{children:"Runner Inspector"}),o?.trace?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)($t,{variant:hce(o.trace.status),children:kC(o.trace.status,o.trace.expiresAt)}),(0,s.jsx)($t,{variant:"outline",className:"font-mono",children:ge.join(", ")||o.trace.provider})]}):null]}),(0,s.jsx)(PO,{id:"runner-inspector-description",children:"Correlate exact provider traffic with every interpretation stage, canonical PRP event, and production surface."}),(0,s.jsx)("div",{className:"flex gap-1 pt-1",role:"tablist","aria-label":"Runner inspector views",children:dce.map(oe=>{const re=oe.icon;return(0,s.jsxs)("button",{type:"button",role:"tab","aria-selected":f===oe.value,onClick:a(()=>p(oe.value),"onClick"),className:E("inline-flex items-center gap-1.5 border-b-2 px-3 py-2 text-sm font-medium transition-colors",f===oe.value?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:[(0,s.jsx)(re,{className:"h-4 w-4"})," ",oe.label]},oe.value)})})]}),(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[Z?(0,s.jsx)(oa,{className:"m-4",error:Z,action:"load the runner inspection",onRetry:J.view.retry,retrying:J.view.isFetching}):null,m!=null?(0,s.jsx)(oa,{className:"m-4",error:m,action:"delete the raw trace"}):null,!Q&&!Z&&R===!1?(0,s.jsxs)("div",{className:"m-4 rounded-md border border-border bg-muted/20 p-4",children:[(0,s.jsx)("p",{className:"font-medium",children:"Raw provider traces require an instance administrator."}),(0,s.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Canonical PRP events and presentation decisions remain inspectable below."})]}):null,!Q&&!Z&&R===!0&&!o?.trace?(0,s.jsxs)("div",{className:"m-4 flex items-start justify-between gap-4 rounded-md border border-border bg-muted/20 p-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium",children:"Raw provider capture was off for this run."}),(0,s.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Canonical PRP events and persisted presentation decisions remain available below."})]}),i&&R===!0?(0,s.jsxs)(W,{size:"sm",onClick:i,children:[(0,s.jsx)(Bg,{className:"mr-1.5 h-4 w-4"}),"Re-run with provider trace"]}):null]}):null,f==="overview"?(0,s.jsx)(xu,{className:"min-h-0 flex-1",children:(0,s.jsxs)("div",{className:"space-y-6 p-5",children:[Q?(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading run pipeline…"}):null,(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6",children:[(0,s.jsx)(gu,{label:"Provider",value:ge.join(", ")||o?.trace?.provider||"PRP only",detail:o?.trace?`captured through ${o.trace.provider}`:"capture was off"}),(0,s.jsx)(gu,{label:"Raw frames",value:te.length,detail:o?.trace?fp(o.trace.byteCount):"no exact bytes"}),(0,s.jsx)(gu,{label:"Operations",value:K.length,detail:"correlated groups"}),(0,s.jsx)(gu,{label:"PRP events",value:c.length,detail:`${nt} visible`}),(0,s.jsx)(gu,{label:"Mappings",value:ne.length,detail:`${Re} ignored`}),(0,s.jsx)(gu,{label:"Run status",value:t?.status??"unknown",detail:o?.trace?kC(o.trace.status,o.trace.expiresAt):"Raw capture off"})]}),(0,s.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,s.jsxs)("section",{className:"rounded-lg border border-border bg-card p-4",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:"Interpretation outcomes"}),(0,s.jsx)("div",{className:"mt-3 space-y-2",children:Object.entries(ye).length?Object.entries(ye).map(([oe,re])=>(0,s.jsxs)("div",{className:"flex items-center gap-3 text-sm",children:[(0,s.jsx)($t,{variant:"outline",className:"w-24 justify-center capitalize",children:oe}),(0,s.jsx)("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:(0,s.jsx)("div",{className:"h-full rounded-full bg-primary",style:{width:`${Math.max(4,re/Math.max(1,ne.length)*100)}%`}})}),(0,s.jsx)("span",{className:"w-8 text-right font-mono text-xs",children:re})]},oe)):(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"No interpretation records were persisted."})})]}),(0,s.jsxs)("section",{className:"rounded-lg border border-border bg-card p-4",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:"Recent correlated operations"}),(0,s.jsx)("div",{className:"mt-2 divide-y divide-border/70",children:K.slice(-6).reverse().map(oe=>(0,s.jsxs)("button",{type:"button",onClick:a(()=>Ne(oe),"onClick"),className:"flex w-full items-center gap-3 py-2 text-left hover:text-primary",children:[(0,s.jsx)("span",{className:E("h-2 w-2 rounded-full",oe.events.length?"bg-primary":"bg-muted-foreground")}),(0,s.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,s.jsx)("span",{className:"block truncate text-sm font-medium",children:oe.title}),(0,s.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:oe.subtitle})]}),(0,s.jsx)(ei,{className:"h-4 w-4 text-muted-foreground"})]},oe.key))})]})]}),(0,s.jsx)("section",{className:"rounded-lg border border-border bg-accent/30 p-4",children:(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsx)(Mi,{className:"mt-0.5 h-5 w-5 shrink-0 text-accent-foreground"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:"Sensitive debug data"}),(0,s.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Parsed frames are redacted on the server. Exact reveals and downloads are administrator-only, warned, audited, and automatically expire."})]})]})})]})}):null,f==="pipeline"?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"grid gap-2 border-b border-border p-3 sm:grid-cols-2 xl:grid-cols-(--gtc-runner-inspector-filters)",children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)(uo,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),(0,s.jsx)(ia,{className:"pl-8",value:v,onChange:a(oe=>k(oe.target.value),"onChange"),placeholder:"Search operations, fields, and events"})]}),(0,s.jsxs)(nd,{value:w,onValueChange:j,children:[(0,s.jsx)(sd,{children:(0,s.jsx)(rd,{placeholder:"Direction"})}),(0,s.jsxs)(ad,{children:[(0,s.jsx)(Ra,{value:"all",children:"All directions"}),(0,s.jsx)(Ra,{value:"client_to_provider",children:"Client → provider"}),(0,s.jsx)(Ra,{value:"provider_to_client",children:"Provider → client"}),(0,s.jsx)(Ra,{value:"provider_stderr",children:"Provider stderr"})]})]}),(0,s.jsxs)(nd,{value:_,onValueChange:I,children:[(0,s.jsx)(sd,{children:(0,s.jsx)(rd,{placeholder:"Native method"})}),(0,s.jsxs)(ad,{children:[(0,s.jsx)(Ra,{value:"all",children:"All native methods"}),gl(te.map(ud)).sort().map(oe=>(0,s.jsx)(Ra,{value:oe,children:oe},oe))]})]}),(0,s.jsxs)(nd,{value:T,onValueChange:F,children:[(0,s.jsx)(sd,{children:(0,s.jsx)(rd,{placeholder:"Mapping"})}),(0,s.jsxs)(ad,{children:[(0,s.jsx)(Ra,{value:"all",children:"All mappings"}),["mapped","generic","ignored","rejected","operator_only"].map(oe=>(0,s.jsx)(Ra,{value:oe,children:oe},oe))]})]}),(0,s.jsxs)(nd,{value:O,onValueChange:z,children:[(0,s.jsx)(sd,{children:(0,s.jsx)(rd,{placeholder:"PRP type"})}),(0,s.jsxs)(ad,{children:[(0,s.jsx)(Ra,{value:"all",children:"All PRP types"}),gl(c.map(oe=>oe.eventType)).sort().map(oe=>(0,s.jsx)(Ra,{value:oe,children:oe},oe))]})]}),(0,s.jsxs)(nd,{value:q,onValueChange:A,children:[(0,s.jsx)(sd,{children:(0,s.jsx)(rd,{placeholder:"Visibility"})}),(0,s.jsxs)(ad,{children:[(0,s.jsx)(Ra,{value:"all",children:"Visible + hidden"}),(0,s.jsx)(Ra,{value:"visible",children:"Visible"}),(0,s.jsx)(Ra,{value:"hidden",children:"Hidden"})]})]})]}),(0,s.jsxs)("div",{className:"grid min-h-0 flex-1 lg:grid-cols-(--gtc-runner-inspector-pipeline)",children:[(0,s.jsx)(xu,{className:"border-r border-border",children:(0,s.jsxs)("div",{className:"p-2",children:[Q?(0,s.jsx)("p",{className:"p-3 text-sm text-muted-foreground",children:"Loading run pipeline…"}):null,!Q&&ee.length===0?(0,s.jsx)("p",{className:"p-3 text-sm text-muted-foreground",children:"No operations match these filters."}):null,ee.map(oe=>(0,s.jsxs)("button",{type:"button",onClick:a(()=>b(oe.key),"onClick"),className:"mb-1 w-full rounded-lg border border-transparent px-3 py-2.5 text-left hover:bg-muted/50 data-[selected=true]:border-border data-[selected=true]:bg-muted","data-selected":ce?.key===oe.key,children:[(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:E("h-2 w-2 shrink-0 rounded-full",oe.events.length?oe.visible?"bg-primary":"bg-secondary-foreground":"bg-muted-foreground"),role:"img","aria-label":oe.events.length?oe.visible?"Visible production event":"Hidden production event":"No production event"}),(0,s.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:oe.title}),oe.frames.length>1?(0,s.jsxs)($t,{variant:"outline",className:"px-1.5 text-(length:--text-nano)",children:[oe.frames.length," frames"]}):null]}),(0,s.jsx)("span",{className:"mt-1 block truncate pl-4 text-(length:--text-nano) text-muted-foreground",children:oe.subtitle}),(0,s.jsx)("span",{className:"mt-1.5 flex flex-wrap gap-1 pl-4",children:oe.prpTypes.slice(0,3).map(re=>(0,s.jsx)("span",{className:"rounded bg-background px-1.5 py-0.5 font-mono text-(length:--text-nano) text-muted-foreground",children:re},re))})]},oe.key))]})}),(0,s.jsx)(xu,{children:ce?(0,s.jsxs)("div",{className:"space-y-6 p-5",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 rounded-lg border border-border bg-muted/20 px-4 py-3",children:[(0,s.jsx)("strong",{className:"text-sm",children:ce.title}),(0,s.jsx)(ei,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:[ce.frames.length," raw frame",ce.frames.length===1?"":"s"]}),(0,s.jsx)(ei,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:[ce.interpretations.length," mapping stage",ce.interpretations.length===1?"":"s"]}),(0,s.jsx)(ei,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:[je.length," PRP event",je.length===1?"":"s"]})]}),(0,s.jsxs)("section",{children:[(0,s.jsxs)("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-accent text-xs font-semibold text-accent-foreground",children:"1"}),(0,s.jsx)("h3",{className:"text-sm font-semibold",children:"Provider frames"}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:"server-redacted by default"})]}),ce.frames.length>1?(0,s.jsx)("div",{className:"mb-2 flex flex-wrap gap-1",children:ce.frames.map(oe=>(0,s.jsxs)("button",{type:"button",onClick:a(()=>x(Number(oe.frameId)),"onClick"),className:E("rounded-md border px-2 py-1 font-mono text-xs",Number(oe.frameId)===Number(ie?.frameId)?"border-primary/50 bg-primary/10 text-foreground":"border-border text-muted-foreground hover:bg-muted"),children:["#",String(oe.frameId)," ",ud(oe)||bs(oe.direction)]},Number(oe.frameId)))}):null,ie?(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[(0,s.jsxs)($t,{variant:"outline",children:["frame ",String(ie.frameId)]}),(0,s.jsx)("span",{children:bs(ie.direction).replaceAll("_"," ")}),(0,s.jsx)("span",{children:fp(Number(ie.byteLength)||0)}),(0,s.jsx)("code",{className:"truncate",children:bs(ie.digest)})]}),(0,s.jsx)(td,{value:ie.parsed}),Array.isArray(ie.withheldPaths)&&ie.withheldPaths.length>0?(0,s.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-border bg-accent/30 px-3 py-2 text-xs text-muted-foreground",children:[(0,s.jsx)(Mi,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-foreground"}),(0,s.jsxs)("span",{children:["Withheld paths: ",ie.withheldPaths.join(", ")]})]}):null,R===!0?(0,s.jsxs)(W,{size:"sm",variant:"outline",onClick:a(()=>{xe(Number(ie.frameId))},"onClick"),children:[(0,s.jsx)(Pu,{className:"mr-1.5 h-4 w-4"}),"Reveal exact frame"]}):null,ke?(0,s.jsxs)("div",{className:E("rounded-md border border-destructive/30 p-2",Ej),children:[(0,s.jsxs)("p",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-destructive",children:[(0,s.jsx)(Mi,{className:"h-3.5 w-3.5"}),"Exact unredacted frame"]}),(0,s.jsx)(td,{value:wC(ke.rawBase64),label:"Search exact frame"})]}):null]}):(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"This PRP event has no recoverable raw frame."})]}),(0,s.jsxs)("section",{children:[(0,s.jsxs)("div",{className:"mb-3 flex items-center gap-2",children:[(0,s.jsx)("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-primary/10 text-xs font-semibold text-primary",children:"2"}),(0,s.jsx)("h3",{className:"text-sm font-semibold",children:"Interpretation stages"})]}),_e.length?_e.map((oe,re)=>(0,s.jsx)(jce,{entry:oe,last:re===_e.length-1},`${oe.debugChannel}:${oe.debugSequence}:${re}`)):(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"No interpretation stage was recorded for this frame."})]}),(0,s.jsxs)("section",{children:[(0,s.jsxs)("div",{className:"mb-3 flex items-center gap-2",children:[(0,s.jsx)("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-secondary text-xs font-semibold text-secondary-foreground",children:"3"}),(0,s.jsx)("h3",{className:"text-sm font-semibold",children:"Canonical PRP events"})]}),je.length?je.map(oe=>(0,s.jsxs)("div",{className:"mb-3 overflow-hidden rounded-lg border border-border bg-card",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b border-border/70 px-3 py-2",children:[(0,s.jsx)("code",{className:"text-xs font-semibold",children:oe.eventType}),(0,s.jsxs)($t,{variant:"outline",children:["seq ",oe.seq]}),(0,s.jsx)("button",{type:"button",className:"ml-auto text-xs text-primary underline-offset-4 hover:underline",onClick:a(()=>{A($u(oe).visible?"visible":"hidden"),b(ce.key)},"onClick"),children:"Why isn’t this visible?"})]}),(0,s.jsx)("dl",{className:"grid gap-x-4 gap-y-1 px-3 py-2 text-xs sm:grid-cols-(--gtc-runner-inspector-fields)",children:Nce(oe).map(([re,le])=>(0,s.jsxs)("div",{className:"contents",children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:re}),(0,s.jsx)("dd",{className:"min-w-0 break-words font-mono",children:le})]},re))}),(0,s.jsxs)("details",{className:"border-t border-border/70",children:[(0,s.jsxs)("summary",{className:"flex cursor-pointer list-none items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground",children:[(0,s.jsx)(en,{className:"h-3.5 w-3.5"}),"Canonical event JSON"]}),(0,s.jsx)("div",{className:"p-3 pt-0",children:(0,s.jsx)(td,{value:L0(oe)})})]})]},oe.id)):(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"This provider operation emitted no canonical PRP events."})]}),(0,s.jsxs)("section",{children:[(0,s.jsxs)("div",{className:"mb-3 flex items-center gap-2",children:[(0,s.jsx)("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-muted text-xs font-semibold text-foreground",children:"4"}),(0,s.jsx)("h3",{className:"text-sm font-semibold",children:"Production presentation"})]}),je.length?je.map(oe=>{const re=$u(oe);return(0,s.jsxs)("div",{className:"mb-4 grid gap-3 xl:grid-cols-(--gtc-runner-inspector-presentation)",children:[(0,s.jsxs)("dl",{className:"grid grid-cols-(--gtc-runner-inspector-fields) gap-x-3 gap-y-1 rounded-lg border border-border p-3 text-sm",children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Visible"}),(0,s.jsxs)("dd",{className:"flex items-center gap-1.5",children:[re.visible?(0,s.jsx)(Ut,{className:"h-3.5 w-3.5 text-primary"}):(0,s.jsx)(Z1,{className:"h-3.5 w-3.5 text-muted-foreground"}),re.visible?"yes":"no"]}),(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Surface"}),(0,s.jsx)("dd",{children:re.surface}),(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Container"}),(0,s.jsx)("dd",{children:re.container}),(0,s.jsx)("dt",{className:"text-muted-foreground",children:"State"}),(0,s.jsx)("dd",{children:re.state}),(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Action"}),(0,s.jsx)("dd",{children:re.action}),(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Reason"}),(0,s.jsx)("dd",{children:re.reason}),(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Reason code"}),(0,s.jsx)("dd",{children:(0,s.jsx)("code",{className:"text-xs",children:re.reasonCode})})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-(length:--text-nano) font-medium uppercase tracking-wide text-muted-foreground",children:"Production surface preview"}),(0,s.jsx)(Ice,{event:oe,runId:e})]})]},oe.id)}):(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"No presentation surface was emitted for this operation."}),Object.keys(de).length>0?(0,s.jsxs)("details",{className:"rounded-lg border border-border",children:[(0,s.jsx)("summary",{className:"cursor-pointer px-3 py-2 text-xs font-medium text-muted-foreground",children:"Resolved final response decision"}),(0,s.jsx)("div",{className:"p-3 pt-0",children:(0,s.jsx)(td,{value:de})})]}):null,Se.length>0||De.length>0?(0,s.jsxs)("div",{className:"mt-3 rounded-lg border border-border bg-accent/30 p-3",children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-accent-foreground",children:"Semantic finalization lineage"}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Provider-native transport and model-authored tool arguments are separate layers. PRP normalized the model payload, then server policy chose the issue disposition."}),De.some(oe=>Pa(oe).sourceKind==="environment_constraint")?(0,s.jsxs)("p",{className:"mt-2 text-xs",children:[(0,s.jsx)("code",{children:"environment_constraint"})," was model-authored tool payload data, not a Codex app-server event. It was normalized into a non-blocking verification caveat."]}):null,(0,s.jsxs)("dl",{className:"mt-2 grid grid-cols-(--gtc-runner-inspector-fields) gap-x-3 gap-y-1 text-xs",children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Policy"}),(0,s.jsx)("dd",{children:(0,s.jsx)("code",{children:bs(ae.finalizationPolicyVersion)||"unknown"})}),(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Decision reason"}),(0,s.jsx)("dd",{children:(0,s.jsx)("code",{children:bs(ae.finalizationReasonCode)||"unknown"})})]}),(0,s.jsxs)("details",{className:"mt-2",children:[(0,s.jsx)("summary",{className:"cursor-pointer text-xs font-medium text-muted-foreground",children:"Normalized caveats and ignored requests"}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(td,{value:{verificationCaveats:Se,ignoredAttentionRequests:De}})})]})]}):null]})]}):(0,s.jsx)("div",{className:"p-5 text-sm text-muted-foreground",children:"Select a correlated operation to inspect its pipeline."})})]})]}):null,f==="trace"?(0,s.jsxs)("div",{className:"grid min-h-0 flex-1 md:grid-cols-(--gtc-runner-inspector-trace)",children:[(0,s.jsx)(xu,{className:"border-r border-border",children:(0,s.jsx)("div",{className:"p-2",children:te.length?[...te].sort((oe,re)=>Number(oe.frameId)-Number(re.frameId)).map(oe=>(0,s.jsxs)("button",{type:"button",onClick:a(()=>{const re=K.find(le=>le.frames.some(mt=>Number(mt.frameId)===Number(oe.frameId)));re&&b(re.key),x(Number(oe.frameId))},"onClick"),className:E("mb-1 w-full rounded-md border px-3 py-2 text-left",Number(oe.frameId)===Number(ie?.frameId)?"border-primary/40 bg-primary/10":"border-transparent hover:bg-muted/50"),children:[(0,s.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,s.jsxs)("span",{className:"font-mono text-xs text-muted-foreground",children:["#",String(oe.frameId)]}),(0,s.jsx)("span",{className:"truncate",children:ud(oe)||bs(oe.direction)})]}),(0,s.jsxs)("span",{className:"mt-1 block text-(length:--text-nano) text-muted-foreground",children:[bs(oe.direction).replaceAll("_"," ")," · ",fp(Number(oe.byteLength)||0)]})]},Number(oe.frameId))):(0,s.jsx)("p",{className:"p-3 text-sm text-muted-foreground",children:"No raw frames were captured for this run."})})}),(0,s.jsx)(xu,{children:(0,s.jsx)("div",{className:"space-y-3 p-5",children:ie?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsxs)("h3",{className:"text-sm font-semibold",children:["Exact trace frame #",String(ie.frameId)]}),(0,s.jsx)($t,{variant:"outline",children:ud(ie)||bs(ie.direction)})]}),(0,s.jsx)(td,{value:ie.parsed}),R===!0?(0,s.jsxs)(W,{size:"sm",variant:"outline",onClick:a(()=>{xe(Number(ie.frameId))},"onClick"),children:[(0,s.jsx)(Pu,{className:"mr-1.5 h-4 w-4"}),"Reveal exact frame"]}):null,ke?(0,s.jsx)("div",{className:Ej,children:(0,s.jsx)(td,{value:wC(ke.rawBase64),label:"Search exact frame"})}):null]}):(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a frame from the chronological trace."})})})]}):null,R===!0&&o?.trace?.runId===e?(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-t border-border p-3",children:[(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:[o.trace.frameCount," frames · ",fp(o.trace.byteCount)," · expires ",new Date(o.trace.expiresAt).toLocaleString()]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)(W,{size:"sm",variant:"outline",onClick:a(()=>{Pe()},"onClick"),children:[(0,s.jsx)(yi,{className:"mr-1.5 h-4 w-4"}),"Download exact trace"]}),(0,s.jsxs)(W,{size:"sm",variant:"destructive",onClick:a(()=>{Ee()},"onClick"),children:[(0,s.jsx)(Nc,{className:"mr-1.5 h-4 w-4"}),"Delete trace"]})]})]}):null]})]})})}a(Sce,"RunnerInspector");function _ce(e){if(!e)return!1;const t=e.debug;return typeof t=="object"&&t!==null&&!Array.isArray(t)&&t.providerTrace==="raw"}a(_ce,"runRequestedProviderTrace");function Cce({trace:e,requested:t=!1,showOff:n=!1,className:r}){const i=e?.status,o=e?new Date(e.expiresAt).getTime()<=Date.now():!1,l=o?"Trace expired":i==="capturing"?"Raw tracing enabled":i==="complete"?"Trace captured":i==="incomplete"?"Trace incomplete":i==="truncated"?"Trace truncated":i==="expired"?"Trace expired":i==="deleted"?"Trace deleted":t?"Trace requested":n?"Trace off":null;if(!l)return null;const c=i==="incomplete"||i==="truncated"||i==="expired"||i==="deleted"||o,d=l==="Trace off"?Z1:r4;return(0,s.jsxs)("span",{className:E("inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-(length:--text-micro) font-medium",l==="Trace off"||l==="Trace deleted"||l==="Trace expired"?"border-border bg-background text-muted-foreground":c?"border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300":"border-amber-500/30 bg-amber-500/10 text-amber-800 dark:text-amber-200",r),title:e?`${e.frameCount} frames · ${e.byteCount} bytes · expires ${new Date(e.expiresAt).toLocaleString()}`:t?"This run requested sensitive provider-frame capture.":"Raw provider-frame capture was disabled for this run.",children:[(0,s.jsx)(d,{className:"h-3 w-3"}),l]})}a(Cce,"ProviderTraceStatusBadge");var Ace={completed:{label:"Completed",tone:"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300",description:"Task reached a terminal state."},advanced:{label:"Advanced",tone:"border-cyan-500/30 bg-cyan-500/10 text-cyan-700 dark:text-cyan-300",description:"Run produced concrete evidence of progress."},plan_only:{label:"Plan only",tone:"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300",description:"Run described future work without concrete action evidence."},empty_response:{label:"Empty response",tone:"border-orange-500/30 bg-orange-500/10 text-orange-700 dark:text-orange-300",description:"Run finished without useful output."},blocked:{label:"Blocked",tone:"border-yellow-500/30 bg-yellow-500/10 text-yellow-700 dark:text-yellow-300",description:"Run or task declared a blocker."},failed:{label:"Failed",tone:"border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300",description:"Run ended unsuccessfully."},needs_followup:{label:"Needs follow-up",tone:"border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",description:"Run produced useful output but did not prove concrete progress."}},Rce={label:"Checks after finish",tone:"border-border bg-background text-muted-foreground",description:"Liveness is evaluated after the run finishes."},Tce={label:"Retry pending",tone:"border-blue-500/30 bg-blue-500/10 text-blue-700 dark:text-blue-300",description:"Microvac queued an automatic retry that has not started yet."},Ece={label:"No liveness data",tone:"border-border bg-background text-muted-foreground",description:"This run has no persisted liveness classification."},Mce=new Set(["done","cancelled"]),$ce=new Set(["queued","running"]),pb={suspicious:{label:"Output silence",tone:"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300"},critical:{label:"Critical silence",tone:"border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300"},snoozed:{label:"Silence snoozed",tone:"border-cyan-500/30 bg-cyan-500/10 text-cyan-700 dark:text-cyan-300"}};function A$(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}a(A$,"asRecord$2");function R$(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}a(R$,"readString");function Pce(e){return typeof e=="number"&&Number.isFinite(e)?e:null}a(Pce,"readNumber$1");function Dce(e,t){if(!e)return null;const n=new Date(e).getTime(),r=t?new Date(t).getTime():Date.now();if(!Number.isFinite(n)||!Number.isFinite(r))return null;const i=Math.max(0,Math.round((r-n)/1e3));if(i<60)return`${i}s`;const o=Math.floor(i/60),l=i%60;if(o<60)return l>0?`${o}m ${l}s`:`${o}m`;const c=Math.floor(o/60),d=o%60;return d>0?`${c}h ${d}m`:`${c}h`}a(Dce,"formatDuration");function gb(e){return e?e instanceof Date?e.toISOString():e:null}a(gb,"toIsoString");function NC(e){return{runId:e.id,status:e.status,agentId:e.agentId,agentName:e.agentName,adapterType:e.adapterType,startedAt:gb(e.startedAt),finishedAt:gb(e.finishedAt),createdAt:gb(e.createdAt)??new Date().toISOString(),invocationSource:e.invocationSource,usageJson:null,resultJson:null,isLive:e.status==="queued"||e.status==="running",outputSilence:e.outputSilence}}a(NC,"liveRunToLedgerRun");function Lce(e,t,n){const r=new Map;for(const i of e)r.set(i.runId,i);for(const i of t??[]){const o=r.get(i.id);r.set(i.id,o?{...o,isLive:!0,agentName:i.agentName,outputSilence:i.outputSilence}:NC(i))}if(n){const i=r.get(n.id);i?r.set(n.id,{...i,isLive:Vh(i)||Vh(n),agentName:n.agentName,outputSilence:n.outputSilence}):r.set(n.id,NC(n))}return[...r.values()].sort((i,o)=>{const l=new Date(i.startedAt??i.createdAt).getTime(),c=new Date(o.startedAt??o.createdAt).getTime();return l!==c?c-l:o.runId.localeCompare(i.runId)})}a(Lce,"mergeRuns");function iv(e){return e.replace(/_/g," ")}a(iv,"statusLabel");function Vh(e){return e.isLive||$ce.has(e.status)}a(Vh,"isActiveRun");function Oce(e,t){const n=T$(e,t);return e.status==="running"?`Running now by ${n}`:e.status==="queued"?`Queued for ${n}`:e.status==="scheduled_retry"?`Automatic retry scheduled for ${n}`:`${iv(e.status)} by ${n}`}a(Oce,"runSummary");function qce(e){return e.status==="scheduled_retry"?Tce:e.livenessState?Ace[e.livenessState]:Vh(e)?Rce:Ece}a(qce,"livenessCopyForRun");function Bce(e){const t=A$(e.resultJson),n=R$(t?.stopReason),r=t?.timeoutFired===!0,i=Pce(t?.effectiveTimeoutSec),o=i&&i>0?`${i}s timeout`:null;if(r||n==="timeout")return o?`timeout (${o})`:"timeout";if(n==="max_turns_exhausted"||n==="turn_limit_exhausted")return"max turns exhausted";if(n==="budget_paused")return"budget paused";if(n==="cancelled")return"cancelled";if(n==="paused")return"paused by board";if(n==="process_lost")return"process lost";if(n==="unmanaged_background_task_stopped")return"unmanaged background task stopped";if(n==="adapter_failed"){const l=t6(e.failureCause);return l?`adapter failed (${l})`:"adapter failed"}return n==="completed"?o?`completed (${o})`:"completed":o}a(Bce,"stopReasonLabel");function Fce(e,t){return t||(e.status==="scheduled_retry"?"Retry pending":e.status==="queued"?"Waiting to start":e.status==="running"?"Still running":e.livenessState?"No stop reason":"Unavailable")}a(Fce,"stopStatusLabel");function zce(e){return e.status==="scheduled_retry"?"Waiting for next attempt":e.lastUsefulActionAt?va(e.lastUsefulActionAt):Vh(e)?"No action recorded yet":e.livenessState==="plan_only"||e.livenessState==="needs_followup"?"No concrete action":e.livenessState==="empty_response"?"No useful output":e.livenessState?"None recorded":"Unavailable"}a(zce,"lastUsefulActionLabel");function Uce(e){return!e.continuationAttempt||e.continuationAttempt<=0?null:`Continuation attempt ${e.continuationAttempt}`}a(Uce,"continuationLabel");function Wce(e){return/continuation attempts exhausted/i.test(e.livenessReason??"")}a(Wce,"hasExhaustedContinuation");function Kce(e){return{active:e.filter(t=>!Mce.has(t.status)),done:e.filter(t=>t.status==="done").length,cancelled:e.filter(t=>t.status==="cancelled").length,total:e.length}}a(Kce,"childIssueSummary");function T$(e,t){return e.agentName??t.get(e.agentId)?.name??e.agentId.slice(0,8)}a(T$,"compactAgentName");function Vce(e){if(!e||e<=0)return null;const t=Math.floor(e/6e4);if(t<1)return"under 1 minute";if(t<60)return`${t} minute${t===1?"":"s"}`;const n=Math.floor(t/60),r=t%60;return r===0?`${n} hour${n===1?"":"s"}`:`${n}h ${r}m`}a(Vce,"formatSilenceAge");function Hce(e,t){if(!t)return!1;if(t.source==="local_implicit"||t.isInstanceAdmin)return!0;const n=t.memberships?.find(r=>r.companyId===e&&r.status==="active");return n?n.membershipRole!=="viewer"&&n.membershipRole!==null:t.companyIds.includes(e)&&!t.memberships}a(Hce,"canBoardRecordWatchdogDecision");function Qce(e){return e instanceof mn&&e.status===403?"Only the board or the assigned recovery owner can record watchdog decisions":e instanceof Error&&e.message.trim().length>0?e.message:"Microvac could not record the watchdog decision."}a(Qce,"watchdogDecisionErrorMessage");function Gce({issueId:e,companyId:t,issueStatus:n,childIssues:r,agentMap:i,hasLiveRuns:o,activityEvents:l,renderActivityEvent:c,resolveUserLabel:d}){const m=ys(),{pushToast:h}=lm(),[f,p]=(0,u.useState)(null),{data:g}=Te({queryKey:G.access.currentBoardAccess,queryFn:a(()=>Eo.getCurrentBoardAccess(),"queryFn")}),{data:b}=Te({queryKey:G.issues.runs(e),queryFn:a(()=>io.runsForIssue(e),"queryFn"),refetchInterval:o||n==="in_progress"?5e3:!1,placeholderData:Mr(e)}),{data:y}=Te({queryKey:G.issues.liveRuns(e),queryFn:a(()=>yl(m,G.issues.liveRuns(e),e,T=>T.liveRuns,()=>qn.liveRunsForIssue(e)),"queryFn"),enabled:o,refetchInterval:3e3,placeholderData:Mr(e)}),{data:x=null}=Te({queryKey:G.issues.activeRun(e),queryFn:a(()=>qn.activeRunForIssue(e),"queryFn"),enabled:o||n==="in_progress",refetchInterval:o?!1:3e3,placeholderData:Mr(e)}),v=(0,u.useMemo)(()=>(b??[]).slice(0,100).map(T=>T.runId),[b]),k=g?.source==="local_implicit"||g?.isInstanceAdmin===!0,{data:w}=Te({queryKey:G.providerTraceMetadata(t,v),queryFn:a(()=>qn.providerTraceMetadata(t,v),"queryFn"),enabled:k&&v.length>0}),j=(0,u.useMemo)(()=>new Map((w??[]).map(T=>[T.runId,T])),[w]),_=ut({mutationFn:a(T=>qn.recordWatchdogDecision(T),"mutationFn"),onMutate:a(()=>{p(null)},"onMutate"),onSuccess:a(()=>{p(null),m.invalidateQueries({queryKey:G.issues.activeRun(e)}),m.invalidateQueries({queryKey:G.issues.liveRuns(e)})},"onSuccess"),onError:a(T=>{const F=Qce(T),O=T instanceof mn?String(T.status):"error";p(F),h({title:"Watchdog decision not recorded",body:F,tone:"error",dedupeKey:`watchdog-decision:${e}:${O}`})},"onError")}),I=ut({mutationFn:a(async T=>{const F=A$(T.contextSnapshot),O={};for(const q of["issueId","taskId","taskKey"]){const A=R$(F?.[q]);A&&(O[q]=A)}const z=await $r.wakeup(T.agentId,{source:"on_demand",triggerDetail:"manual",reason:"rerun_with_provider_trace",payload:O,debug:{providerTrace:"raw"}},t);if(!("id"in z))throw new Error(z.message??"Trace re-run was skipped.");return z},"mutationFn"),onSuccess:a(()=>{m.invalidateQueries({queryKey:G.issues.runs(e)}),m.invalidateQueries({queryKey:G.issues.liveRuns(e)})},"onSuccess"),onError:a(T=>h({title:"Trace re-run not started",body:T instanceof Error?T.message:"Microvac could not start the trace re-run.",tone:"error",dedupeKey:`provider-trace-rerun:${e}`}),"onError")});return(0,s.jsx)(Yce,{runs:b??[],liveRuns:y,activeRun:x,issueStatus:n,childIssues:r,agentMap:i,activityEvents:l,renderActivityEvent:c,resolveUserLabel:d,pendingWatchdogDecision:_.variables?.decision??null,canRecordWatchdogDecisions:Hce(t,g),watchdogDecisionError:f,onWatchdogDecision:a(T=>_.mutate(T),"onWatchdogDecision"),onRerunWithTrace:k?T=>I.mutate(T):void 0,providerTraceMetadata:j})}a(Gce,"IssueRunLedger");function Yce({runs:e,liveRuns:t,activeRun:n,issueStatus:r,childIssues:i,agentMap:o,activityEvents:l,renderActivityEvent:c,resolveUserLabel:d,pendingWatchdogDecision:m,canRecordWatchdogDecisions:h=!0,watchdogDecisionError:f,onWatchdogDecision:p,onRerunWithTrace:g,providerTraceMetadata:b=new Map}){const[y,x]=(0,u.useState)(null),v=(0,u.useMemo)(()=>Lce(e,t,n),[n,t,e]);(0,u.useEffect)(()=>{if(y||typeof window>"u")return;const T=new URLSearchParams(window.location.search).get("inspectRun");if(!T)return;const F=v.find(O=>O.runId===T);F&&x(F)},[y,v]);const k=v[0]??null,w=(0,u.useMemo)(()=>v.find(T=>Vh(T)&&(T.outputSilence?.level==="critical"||T.outputSilence?.level==="suspicious"))??null,[v]),j=Kce(i),_=!!c,I=(0,u.useMemo)(()=>{const T=[];for(const F of v)T.push({kind:"run",id:F.runId,timestamp:F.startedAt??F.createdAt,run:F});if(_)for(const F of l??[])T.push({kind:"activity",id:F.id,timestamp:F.createdAt instanceof Date?F.createdAt.toISOString():String(F.createdAt),event:F});return T.sort((F,O)=>{const z=new Date(F.timestamp).getTime(),q=new Date(O.timestamp).getTime();return z!==q?q-z:F.kind!==O.kind?F.kind==="run"?-1:1:O.id.localeCompare(F.id)})},[l,_,v]);return(0,s.jsxs)("section",{className:"space-y-3","aria-label":"Task run ledger",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Run ledger"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:k?Oce(k,o):r==="in_progress"?"Waiting for the first run record.":"No runs linked yet."})]}),k?(0,s.jsx)(tt,{to:`/agents/${k.agentId}/runs/${k.runId}`,className:"shrink-0 rounded-md border border-border px-2 py-1 text-xs text-muted-foreground hover:text-foreground",children:"Latest run"}):null]}),j.total>0?(0,s.jsxs)("div",{className:"rounded-md border border-border/70 px-3 py-2",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(0,s.jsx)("span",{className:"font-medium text-foreground",children:"Child work"}),(0,s.jsx)("span",{className:"text-muted-foreground",children:j.active.length>0?`${j.active.length} active, ${j.done} done, ${j.cancelled} cancelled`:`all ${j.total} terminal (${j.done} done, ${j.cancelled} cancelled)`})]}),j.active.length>0?(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[j.active.slice(0,4).map(T=>(0,s.jsxs)(tt,{to:`/issues/${T.identifier??T.id}`,className:"inline-flex min-w-0 max-w-full items-center gap-1 rounded-md border border-border bg-background px-2 py-1 text-(length:--text-micro) hover:bg-accent/40",children:[(0,s.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:T.identifier??T.id.slice(0,8)}),(0,s.jsx)("span",{className:"truncate",children:T.title}),(0,s.jsx)("span",{className:"shrink-0 text-muted-foreground",children:iv(T.status)})]},T.id)),j.active.length>4?(0,s.jsxs)("span",{className:"rounded-md border border-border px-2 py-1 text-(length:--text-micro) text-muted-foreground",children:["+",j.active.length-4," more"]}):null]}):null]}):null,w?.outputSilence?(0,s.jsxs)("div",{className:E("rounded-md border px-3 py-2 text-xs",w.outputSilence.level==="critical"?"border-red-500/30 bg-red-500/10 text-red-900 dark:text-red-200":"border-amber-500/30 bg-amber-500/10 text-amber-900 dark:text-amber-200"),children:[(0,s.jsx)("p",{className:"font-medium",children:w.outputSilence.level==="critical"?"Critical output silence":"Output silence watchdog warning"}),(0,s.jsxs)("p",{className:"mt-1",children:["Latest active run has been silent for"," ",Vce(w.outputSilence.silenceAgeMs)??"an extended period",".",w.outputSilence.evaluationIssueIdentifier?(0,s.jsxs)(s.Fragment,{children:[" ","Review"," ",(0,s.jsx)(tt,{to:`/issues/${w.outputSilence.evaluationIssueIdentifier}`,className:"font-medium underline underline-offset-2",children:w.outputSilence.evaluationIssueIdentifier})," ","for recovery context."]}):null]}),(0,s.jsx)("p",{className:"mt-1",children:w.outputSilence.evaluationIssueIdentifier?"This signal is informational. Microvac did not create new delegated recovery work.":"This signal is informational. Microvac did not create or assign a recovery task."}),p&&h?(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[(0,s.jsx)("button",{type:"button",className:"rounded-md border border-border bg-background/80 px-2 py-1 text-(length:--text-micro) text-foreground hover:bg-background",onClick:a(()=>p({runId:w.runId,decision:"continue",evaluationIssueId:w.outputSilence?.evaluationIssueId??null}),"onClick"),disabled:m!=null,children:"Continue monitoring"}),(0,s.jsx)("button",{type:"button",className:"rounded-md border border-border bg-background/80 px-2 py-1 text-(length:--text-micro) text-foreground hover:bg-background",onClick:a(()=>p({runId:w.runId,decision:"snooze",evaluationIssueId:w.outputSilence?.evaluationIssueId??null,snoozedUntil:new Date(Date.now()+36e5).toISOString(),reason:"Snoozed from issue run ledger"}),"onClick"),disabled:m!=null,children:"Snooze 1h"}),(0,s.jsx)("button",{type:"button",className:"rounded-md border border-border bg-background/80 px-2 py-1 text-(length:--text-micro) text-foreground hover:bg-background",onClick:a(()=>p({runId:w.runId,decision:"dismissed_false_positive",evaluationIssueId:w.outputSilence?.evaluationIssueId??null,reason:"Dismissed from issue run ledger"}),"onClick"),disabled:m!=null,children:"Mark false positive"})]}):null,f?(0,s.jsx)("p",{className:"mt-2 rounded-md border border-red-500/30 bg-red-500/10 px-2 py-1 text-(length:--text-micro) text-red-900 dark:text-red-200",children:f}):null]}):null,I.length===0?(0,s.jsx)("div",{className:"rounded-md border border-dashed border-border px-3 py-3 text-sm text-muted-foreground",children:c?"Runs and activity will appear here once this task has history.":"Historical runs without liveness metadata will appear here once linked to this task."}):(0,s.jsxs)("div",{className:"space-y-1.5",children:[I.slice(0,20).map(T=>{if(T.kind==="activity")return(0,s.jsx)("div",{children:c?.(T.event)},`activity:${T.id}`);const F=T.run,O=F.execution?F.execution.nextAction:F.nextAction,z=Mb(F)?Yg(F.execution):null,q=qce(F),A=Bce(F),H=Dce(F.startedAt,F.finishedAt),B=Wce(F),C=Uce(F),S=nse(F),L=T$(F,o),M=F.responsibleUserId?t0(d?.(F.responsibleUserId)):null,R=dF(F.errorCode)?F.errorCode:null,V=Xle(F.resultJson);return(0,s.jsxs)("article",{className:"space-y-1.5 rounded-lg border border-border/60 px-3 py-2 text-xs text-muted-foreground",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,s.jsx)("span",{className:"font-medium text-foreground",children:"Run"}),(0,s.jsx)(tt,{to:`/agents/${F.agentId}/runs/${F.runId}`,className:"min-w-0 max-w-full truncate font-mono text-foreground hover:underline",children:F.runId.slice(0,8)}),(0,s.jsxs)("span",{children:["by ",L]}),M?(0,s.jsxs)("span",{"data-testid":"run-on-behalf-of",className:"min-w-0 max-w-full truncate text-muted-foreground",title:`Acting on behalf of ${M}`,children:["on behalf of"," ",(0,s.jsx)("span",{className:"text-foreground",children:M})]}):null,(0,s.jsx)("span",{className:"rounded-md border border-border px-1.5 py-0.5 text-(length:--text-micro) capitalize text-muted-foreground",children:iv(F.status)}),F.isLive&&!Mb(F)?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md border border-blue-500/30 bg-blue-500/10 px-1.5 py-0.5 text-(length:--text-micro) text-blue-700 dark:text-blue-300",children:[(0,s.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-blue-500"}),"live"]}):null,(0,s.jsx)(Cce,{trace:b.get(F.runId),requested:_ce(F.contextSnapshot),showOff:!0}),(0,s.jsx)("span",{className:E("rounded-md border px-1.5 py-0.5 text-(length:--text-micro) font-medium",q.tone),title:q.description,children:q.label}),B?(0,s.jsx)("span",{className:"rounded-md border border-red-500/30 bg-red-500/10 px-1.5 py-0.5 text-(length:--text-micro) font-medium text-red-700 dark:text-red-300",children:"Exhausted"}):null,C?(0,s.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground",children:C}):null,S?(0,s.jsx)("span",{className:E("rounded-md border px-1.5 py-0.5 text-(length:--text-micro) font-medium",S.tone),children:S.badgeLabel}):null,F.outputSilence&&pb[F.outputSilence.level]?(0,s.jsx)("span",{className:E("rounded-md border px-1.5 py-0.5 text-(length:--text-micro) font-medium",pb[F.outputSilence.level]?.tone),children:pb[F.outputSilence.level]?.label}):null,V?(0,s.jsx)(ece,{}):null,(0,s.jsx)("span",{className:"ml-auto shrink-0",children:va(T.timestamp)}),(0,s.jsx)("button",{type:"button",className:"rounded-md border border-border px-1.5 py-0.5 text-(length:--text-micro) text-foreground hover:bg-accent/40",onClick:a(()=>x(F),"onClick"),children:"Inspect run"})]}),(0,s.jsxs)("div",{className:"grid gap-2 text-xs text-muted-foreground sm:grid-cols-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("span",{className:"text-foreground",children:"Elapsed"})," ",H??"unknown"]}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("span",{className:"text-foreground",children:"Last useful action"})," ",zce(F)]}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("span",{className:"text-foreground",children:"Stop"})," ",Fce(F,A)]})]}),S?(0,s.jsxs)("div",{className:E("rounded-md border border-border/70 bg-accent/20 px-2 py-2 text-xs leading-5 text-muted-foreground",Et),children:[S.detail?(0,s.jsx)("p",{children:S.detail}):null,S.secondary?(0,s.jsx)("p",{children:S.secondary}):null,S.retryOfRunId?(0,s.jsxs)("p",{children:["Retry of"," ",(0,s.jsx)(tt,{to:`/agents/${F.agentId}/runs/${S.retryOfRunId}`,className:"font-mono text-foreground hover:underline",children:S.retryOfRunId.slice(0,8)})]}):null]}):null,F.livenessReason?(0,s.jsx)("p",{className:"min-w-0 break-words text-xs leading-5 text-muted-foreground",children:F.livenessReason}):null,R?(0,s.jsx)(tce,{code:R,userName:F.responsibleUserId?d?.(F.responsibleUserId):null}):null,z?(0,s.jsx)(Pv,{queue:z,className:"text-xs"}):O?(0,s.jsxs)("div",{className:"min-w-0 rounded-md bg-accent/40 px-2 py-1.5 text-xs leading-5",children:[(0,s.jsxs)("span",{className:"font-medium text-foreground",children:["Next action:"," "]}),(0,s.jsx)("span",{className:"break-words text-muted-foreground",children:(0,s.jsx)(zw,{children:O})})]}):null]},`run:${F.runId}`)}),I.length>20?(0,s.jsxs)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:[I.length-20," older items not shown"]}):null]}),y?(0,s.jsx)(Sce,{runId:y.runId,run:y,open:!0,onOpenChange:a(T=>{T||x(null)},"onOpenChange"),onRerunWithTrace:!["queued","running"].includes(y.status)&&g?()=>g(y):void 0}):null]})}a(Yce,"IssueRunLedgerContent");var Jce="h-8 px-2 py-1.5 text-xs font-normal";function Xce({value:e,workspaces:t,onValueChange:n,placeholder:r="Choose an existing workspace",loading:i=!1,error:o=!1,disabled:l=!1,className:c,triggerClassName:d,disablePortal:m}){const h=(0,u.useMemo)(()=>JA(t),[t]);return(0,s.jsx)(m1,{value:e,groups:h,onValueChange:n,placeholder:r,searchPlaceholder:"Search workspaces...",emptyMessage:o?"Workspaces failed to load.":"No matching workspaces.",loadingMessage:"Loading workspaces...",loading:i,disabled:l,className:c,triggerClassName:E(Jce,d),filterOption:zA,scoreOption:NL,disablePortal:m,renderOption:a((f,{selected:p})=>(0,s.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,s.jsx)("span",{className:E("truncate",p&&"font-medium"),children:f.label}),(0,s.jsxs)("span",{className:"truncate text-(length:--text-micro) text-muted-foreground",children:[f.workspace.status?`${f.workspace.status} - `:"",f.description]})]}),"renderOption")})}a(Xce,"ReusableExecutionWorkspaceSelect");var Zce=[{value:"shared_workspace",label:"Project default"},{value:"isolated_workspace",label:"New isolated workspace"},{value:"reuse_existing",label:"Reuse existing workspace"}];function Xm({text:e}){const t=[],n=e.split(/(?<=[\/-])/);for(let r=0;r<n.length;r++)r>0&&t.push((0,s.jsx)("wbr",{},r)),t.push(n[r]);return(0,s.jsx)(s.Fragment,{children:t})}a(Xm,"BreakablePath");function xb({value:e,label:t,mono:n}){const[r,i]=(0,u.useState)(!1),o=(0,u.useRef)(void 0);(0,u.useEffect)(()=>()=>clearTimeout(o.current),[]);const l=(0,u.useCallback)(async()=>{try{await xi(e),i(!0),clearTimeout(o.current),o.current=setTimeout(()=>i(!1),1500)}catch{}},[e]);return(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 group/copy",children:[t&&(0,s.jsx)("span",{className:"text-muted-foreground",children:t}),(0,s.jsx)("span",{className:E("min-w-0",n&&"font-mono"),style:{overflowWrap:"anywhere"},children:(0,s.jsx)(Xm,{text:e})}),(0,s.jsx)("button",{type:"button",className:"shrink-0 p-0.5 rounded hover:bg-accent/50 transition-colors text-muted-foreground hover:text-foreground opacity-0 group-hover/copy:opacity-100 focus:opacity-100",onClick:l,title:r?"Copied!":"Copy","aria-label":r?"Copied to clipboard":`Copy ${t??"value"}`,children:r?(0,s.jsx)(Ut,{className:"h-3 w-3 text-green-500"}):(0,s.jsx)(yr,{className:"h-3 w-3"})})]})}a(xb,"CopyableInline");function ede(e){switch(e){case"isolated_workspace":return"Isolated workspace";case"operator_branch":return"Operator branch";case"cloud_sandbox":return"Cloud environment";case"adapter_managed":return"Adapter managed";default:return"Workspace"}}a(ede,"workspaceModeLabel");function tde(e,t){switch(e){case"isolated_workspace":return"New isolated workspace";case"reuse_existing":return t?.mode==="isolated_workspace"?"Existing isolated workspace":"Reuse existing workspace";default:return"Project default"}}a(tde,"configuredWorkspaceLabel");function sde(e){return!e.projectId||!e.projectWorkspaceId?null:mq({id:e.projectId,urlKey:e.projectId},e.projectWorkspaceId)}a(sde,"projectWorkspaceDetailLink");function IC(e){const t=e.workspace?.projectWorkspaceId??e.issueProjectWorkspaceId??null;return e.workspace?.mode==="shared_workspace"?sde({projectId:e.projectId,projectWorkspaceId:t}):e.workspace?`/execution-workspaces/${e.workspace.id}`:null}a(IC,"workspaceDetailLink");function SC(e){const t={active:"bg-green-500/15 text-green-700 dark:text-green-400",idle:"bg-muted text-muted-foreground",in_review:"bg-blue-500/15 text-blue-700 dark:text-blue-400",archived:"bg-muted text-muted-foreground"};return(0,s.jsx)($t,{variant:"ghost",className:E("text-(length:--text-nano) px-1.5",t[e]??t.idle),children:e.replace(/_/g," ")})}a(SC,"statusBadge");function nde({issue:e,project:t,onUpdate:n,initialEditing:r=!1,livePreview:i=!1,onDraftChange:o,onBrowseFiles:l,onOpenFileByPath:c}){const{visible:d}=Cv(),{selectedCompanyId:m}=zg(),h=e.companyId??m,[f,p]=(0,u.useState)(r),{data:g}=Te({queryKey:G.instance.experimentalSettings,queryFn:a(()=>hc.getExperimental(),"queryFn")}),b=g?.enableEnvironments===!0,y=g===void 0||g.enableManagedSandboxOnly===!0,x=g?.enableIsolatedWorkspaces===!0&&!!t?.executionWorkspacePolicy?.enabled,v=e.currentExecutionWorkspace,{data:k}=Te({queryKey:G.environments.list(h),queryFn:a(()=>bD.list(h),"queryFn"),enabled:!!h&&b}),{data:w,isLoading:j,isError:_}=Te({queryKey:G.executionWorkspaces.list(h,{projectId:e.projectId??void 0,projectWorkspaceId:e.projectWorkspaceId??void 0,reuseEligible:!0}),queryFn:a(()=>Kp.list(h,{projectId:e.projectId??void 0,projectWorkspaceId:e.projectWorkspaceId??void 0,reuseEligible:!0}),"queryFn"),enabled:!!h&&!!e.projectId&&f&&d}),I=w??[],T=I.find(ne=>ne.id===e.executionWorkspaceId)??v??null,F=h$(e,t)??MA(t),[O,z]=(0,u.useState)(F),[q,A]=(0,u.useState)(e.executionWorkspaceId??""),H=T?.config?.environmentId??null,B=b?(F==="reuse_existing"&&H)??v?.config?.environmentId:null,C=k?.find(ne=>ne.id===B)??null;(0,u.useEffect)(()=>{f||(z(F),A(e.executionWorkspaceId??""))},[F,f,e.executionWorkspaceId]);const S=!!(v&&v.mode!=="shared_workspace"),L=I.find(ne=>ne.id===q)??(q===e.executionWorkspaceId?T:null),M=IC({projectId:t?.id,issueProjectWorkspaceId:e.projectWorkspaceId,workspace:T}),R=IC({projectId:t?.id,issueProjectWorkspaceId:e.projectWorkspaceId,workspace:v}),V=O!=="reuse_existing"||q.length>0,J=O==="reuse_existing"&&L?.mode!=="shared_workspace"?L?.branchName??null:null,Q=(0,u.useCallback)(()=>f$(O,q||null,L?.mode),[L?.mode,q,O]);(0,u.useEffect)(()=>{!o||!d||o(Q(),{canSave:V,workspaceBranchName:J})},[Q,V,J,o,d]);const Z=(0,u.useCallback)(()=>{if(!V||!d)return;const ne=Q();ne&&(n(ne),p(!1))},[Q,V,d,n]),P=(0,u.useCallback)(()=>{z(F),A(e.executionWorkspaceId??""),p(!1)},[F,e.executionWorkspaceId]);if(!x||!t)return null;const te=d&&(i||f);return(0,s.jsxs)("div",{className:"rounded-lg border border-border p-3 space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,s.jsx)(la,{className:"h-3.5 w-3.5 text-muted-foreground"}),S&&v?ede(v.mode):tde(F,T),SC(v?v.status:"idle")]}),d&&(0,s.jsx)("div",{className:"flex items-center gap-1",children:te?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(W,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-muted-foreground",onClick:P,children:[(0,s.jsx)(Gs,{className:"h-3 w-3 mr-1"}),"Cancel"]}),(0,s.jsx)(W,{size:"sm",className:"h-6 px-2 text-xs",onClick:Z,disabled:!V,children:"Save"})]}):(0,s.jsxs)(W,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-muted-foreground",onClick:a(()=>p(!0),"onClick"),children:[(0,s.jsx)(wh,{className:"h-3 w-3 mr-1"}),"Edit"]})})]}),!te&&(0,s.jsxs)("div",{className:"space-y-1.5 text-xs",children:[v?.branchName&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)(la,{className:"h-3 w-3 text-muted-foreground shrink-0"}),(0,s.jsx)(xb,{value:v.branchName,mono:!0})]}),v?.cwd&&!y&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)(co,{className:"h-3 w-3 text-muted-foreground shrink-0"}),(0,s.jsx)(xb,{value:v.cwd,mono:!0})]}),v?.repoUrl&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,s.jsx)("span",{className:"text-(length:--text-micro)",children:"Repo:"}),(0,s.jsx)(xb,{value:v.repoUrl,mono:!0})]}),b&&B&&(0,s.jsxs)("div",{className:"text-muted-foreground",style:{overflowWrap:"anywhere"},children:["Environment: ",(0,s.jsx)("span",{className:"text-foreground",children:C?.name??B}),F==="reuse_existing"&&H===B?" · reused workspace":null]}),!v&&(0,s.jsx)("div",{className:"text-muted-foreground",children:F==="isolated_workspace"?"A fresh isolated workspace will be created when this task runs.":F==="reuse_existing"?"This task will reuse an existing workspace when it runs.":"This task will use the project default workspace configuration when it runs."}),F==="reuse_existing"&&T&&(0,s.jsxs)("div",{className:"text-muted-foreground",style:{overflowWrap:"anywhere"},children:["Reusing:"," ",M?(0,s.jsx)(tt,{to:M,className:"hover:text-foreground hover:underline",children:(0,s.jsx)(Xm,{text:T.name})}):(0,s.jsx)(Xm,{text:T.name})]}),v&&R&&(0,s.jsx)("div",{className:"pt-0.5",children:(0,s.jsx)(tt,{to:R,className:"text-(length:--text-micro) text-muted-foreground hover:text-foreground hover:underline",children:"View workspace details →"})})]}),f&&d&&(0,s.jsxs)("div",{className:"space-y-2 pt-1",children:[(0,s.jsx)("select",{className:"w-full rounded border border-border bg-transparent px-2 py-1.5 text-xs outline-none",value:O,onChange:a(ne=>{const ge=ne.target.value;z(ge),ge!=="reuse_existing"?A(""):!q&&e.executionWorkspaceId&&A(e.executionWorkspaceId)},"onChange"),children:Zce.map(ne=>(0,s.jsx)("option",{value:ne.value,children:ne.value==="reuse_existing"&&L?.mode==="isolated_workspace"?"Existing isolated workspace":ne.label},ne.value))}),O==="reuse_existing"&&(0,s.jsx)(Xce,{value:q,workspaces:I,onValueChange:a(ne=>A(ne),"onValueChange"),loading:j,error:_}),v&&(0,s.jsx)("div",{className:"text-(length:--text-micro) text-muted-foreground space-y-0.5 pt-1 border-t border-border/50",children:(0,s.jsxs)("div",{style:{overflowWrap:"anywhere"},children:["Current:"," ",R?(0,s.jsx)(tt,{to:R,className:"hover:text-foreground hover:underline",children:(0,s.jsx)(Xm,{text:v.name})}):(0,s.jsx)(Xm,{text:v.name})," · ",v.status]})})]}),!te&&l&&(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-border/50 pt-2 text-xs",children:[(0,s.jsxs)("button",{type:"button",onClick:l,className:"inline-flex items-center gap-1.5 text-muted-foreground transition-colors hover:text-foreground",children:[(0,s.jsx)(gR,{className:"h-3.5 w-3.5 shrink-0"}),"Browse files…"]}),(0,s.jsxs)("button",{type:"button",onClick:c??l,className:"inline-flex items-center gap-1.5 text-muted-foreground transition-colors hover:text-foreground",children:[(0,s.jsx)(cR,{className:"h-3.5 w-3.5 shrink-0"}),"Open file by path…"]})]})]})}a(nde,"IssueWorkspaceCard");function rde(e){if(!e.projectName)return e.displayPath;const t=`${e.projectName} / `;return e.displayPath.startsWith(t)?e.displayPath:`${t}${e.displayPath}`}a(rde,"artifactFileDisplay");function ade({workspaceFileRef:e,label:t,className:n,onOpen:r,showIcon:i=!0,title:o}){const l=HC(),c=typeof t<"u"?t:rde(e),d=!!(r||l),m=e.line?` line ${e.line}${e.column?` column ${e.column}`:""}`:"",h=d?`Open ${e.displayPath}${m} in the file viewer`:`Workspace file ${e.displayPath}${m}`,f=o??(d?`Open ${e.displayPath}${m} in the file viewer`:`Workspace file ${e.displayPath}${m}`),p=E("paperclip-artifact-file-chip inline-flex items-center gap-1 rounded-sm border border-border bg-muted/60 px-1.5 py-0.5 font-mono text-xs leading-tight text-foreground/90 align-middle no-underline hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",d?"cursor-pointer":null,n),g=(0,s.jsxs)(s.Fragment,{children:[i?(0,s.jsx)(El,{"aria-hidden":"true",className:"h-3 w-3 shrink-0 opacity-70"}):null,(0,s.jsx)("span",{className:"max-w-full whitespace-normal break-all text-left",children:c})]}),b=a(y=>{if(!(y.metaKey||y.ctrlKey||y.shiftKey||y.altKey)&&y.button===0)if(r)r(e);else{const x=e.workspaceKind==="execution_workspace"?"execution":"project";l?.open({path:e.relativePath,line:e.line??null,column:e.column??null,workspace:x,projectId:e.projectId??null,workspaceId:e.projectId?e.workspaceId:null})}},"handleClick");return d?(0,s.jsx)("button",{type:"button","data-artifact-file-chip":"true","data-workspace-file-path":e.relativePath,"aria-label":h,title:f,className:p,onClick:b,children:g}):(0,s.jsx)("span",{"data-artifact-file-chip":"true","data-workspace-file-path":e.relativePath,"aria-label":h,title:f,className:p,children:g})}a(ade,"ArtifactFileChip");function _C(){const e=document.getElementById("main-content");if(e instanceof HTMLElement){const t=window.getComputedStyle(e).overflowY;if((t==="auto"||t==="scroll"||t==="overlay")&&e.scrollHeight>e.clientHeight+1)return{type:"element",element:e}}return{type:"window"}}a(_C,"resolveScrollTarget");function ide(e){return e.type==="element"?e.element.scrollHeight-e.element.scrollTop-e.element.clientHeight:(document.scrollingElement??document.documentElement).scrollHeight-window.scrollY-window.innerHeight}a(ide,"distanceFromBottom");function ode(){const[e,t]=(0,u.useState)(!1),{panelVisible:n,panelContent:r}=$A(),{isMobile:i}=Qh(),[o,l]=(0,u.useState)(null);(0,u.useEffect)(()=>{if(!i){l(null);return}const m=document.getElementById("main-content");if(!m)return;const h=a(()=>l(m.querySelector('[data-testid="task-chat-composer-dock"]')),"findDock");h();const f=new MutationObserver(h);return f.observe(m,{childList:!0,subtree:!0}),()=>f.disconnect()},[i]),(0,u.useEffect)(()=>{const m=a(()=>{t(ide(_C())>300)},"check"),h=document.getElementById("main-content");return m(),h?.addEventListener("scroll",m,{passive:!0}),window.addEventListener("scroll",m,{passive:!0}),window.addEventListener("resize",m),()=>{h?.removeEventListener("scroll",m),window.removeEventListener("scroll",m),window.removeEventListener("resize",m)}},[]);const c=(0,u.useCallback)(()=>{const m=_C();if(m.type==="element"){m.element.scrollTo({top:m.element.scrollHeight,behavior:"smooth"});return}const h=document.scrollingElement??document.documentElement;window.scrollTo({top:h.scrollHeight,behavior:"smooth"})},[]);if(!e)return null;const d=(0,s.jsx)("button",{"data-slot":"icon-button",onClick:c,className:E("z-40 flex h-9 w-9 items-center justify-center rounded-full border border-border bg-background shadow-md hover:bg-accent transition-(--tp-background-color-right) duration-200",i&&o?"absolute bottom-full left-1/2 -translate-x-1/2 mb-3":"fixed bottom-(--sz-calc-21) right-6 md:bottom-6",!i&&n&&r&&"md:right-(--sz-calc-22)"),"aria-label":"Scroll to bottom",children:(0,s.jsx)(iA,{className:"h-4 w-4"})});return i&&o?(0,Mu.createPortal)(d,o):d}a(ode,"ScrollToBottom");var lde=5e3;function cde(e=lde){const t=ys(),[n,r]=(0,u.useState)(!1);return(0,u.useEffect)(()=>{if(n)return;const i=a(()=>r(!0),"done"),o=_q(t,i),l=window.setTimeout(i,e);return()=>{o(),window.clearTimeout(l)}},[t,n,e]),n}a(cde,"usePageSettled");var dde={"case.created":"created","case.updated":"updated","case.fields_changed":"updated details on","case.status_changed":"changed status on","case.issue_linked":"linked a task to","case.issue_unlinked":"unlinked a task from","case.child_linked":"linked a child to","case.attachment_added":"attached a file to","case.label_added":"added a label to","case.label_removed":"removed a label from","case.document_revised":"updated a document on","case.handoff_requested":"requested a handoff for","case.handoff_applied":"handed off","case.handoff_delivered":"delivered a handoff for","case.handoff_retry_requested":"retried a handoff for","case.handoff_cancelled":"cancelled a handoff for","case.handoff_completed":"completed","issue.created":"created","issue.updated":"updated","issue.read_marked":"read","issue.read_unmarked":"marked unread","issue.checked_out":"checked out","issue.released":"released","issue.comment_added":"commented on","issue.comment_cancelled":"cancelled a queued comment on","issue.queued_comment_edited":"edited a queued comment on","issue.queued_comments_reordered":"reordered queued comments on","issue.queued_comment_discarded":"discarded a queued comment on","issue.comment_deleted":"deleted a comment on","issue.attachment_added":"attached file to","issue.attachment_removed":"removed attachment from","issue.document_created":"created document for","issue.document_updated":"updated document on","issue.document_locked":"locked document on","issue.document_unlocked":"unlocked document on","issue.document_deleted":"deleted document from","issue.monitor_scheduled":"scheduled monitor on","issue.monitor_triggered":"triggered monitor for","issue.monitor_cleared":"cleared monitor on","issue.monitor_skipped":"skipped monitor for","issue.monitor_exhausted":"exhausted monitor on","issue.monitor_recovery_wake_queued":"queued monitor recovery for","issue.monitor_recovery_issue_created":"created monitor recovery for","issue.monitor_escalated_to_board":"escalated monitor for","issue.commented":"commented on","issue.deleted":"deleted","issue.successful_run_handoff_required":"flagged missing next step on","issue.successful_run_handoff_resolved":"recorded next step chosen on","issue.successful_run_handoff_escalated":"escalated missing next step on","issue.accepted_plan_decomposition_updated":"updated accepted-plan decomposition on","issue.recovery_action_opened":"opened a recovery action on","issue.workspace_recovered":"recovered saved work for","issue.retry_continued_from_saved_work":"continued from saved work on","issue.workspace_recovery_requested":"requested workspace recovery for","issue.previous_run_files_waiting":"is still working to save the previous run's files on","issue.previous_run_files_lost":"continued from the last save on","issue.recovery_action_resolved":"resolved the recovery action on","issue.recovery_action_escalated":"escalated the recovery action on","agent.created":"created","agent.updated":"updated","agent.paused":"paused","agent.resumed":"resumed","agent.error_cleared":"cleared error on","agent.terminated":"terminated","agent.key_created":"created API key for","agent.budget_updated":"updated budget for","agent.runtime_session_reset":"reset session for","heartbeat.invoked":"invoked heartbeat for","heartbeat.cancelled":"cancelled heartbeat for","heartbeat.output_stale_source_resolved":"system-folded stale run on","heartbeat.output_stale_recovery_recursion_refused":"refused recovery-on-recovery for","approval.created":"requested approval","approval.approved":"approved","approval.rejected":"rejected","issue.thread_interaction_created":"asked for a decision on","issue.thread_interaction_accepted":"accepted the request on","issue.thread_interaction_rejected":"rejected the request on","issue.thread_interaction_answered":"answered the request on","issue.thread_interaction_withdrawn":"withdrew the request on","issue.thread_interaction_cancelled":"cancelled the request on","issue.thread_interaction_skipped":"skipped the request on","issue.thread_interaction_dismissed":"deferred the request on","issue.thread_interaction_expired":"expired the request on","issue.thread_interaction_item_verdicts_submitted":"submitted verdicts on","issue.stalled_review_decided":"recorded a review verdict on","project.created":"created","project.updated":"updated","project.deleted":"deleted","goal.created":"created","goal.updated":"updated","goal.deleted":"deleted","cost.reported":"reported cost for","cost.recorded":"recorded cost for","company.created":"created organization","company.updated":"updated organization","company.archived":"archived","company.reactivated":"reactivated","company.budget_updated":"updated budget for","audit.exported":"exported the agent audit log for","tool_app.connected":"connected","tool_app.oauth_connected":"connected credentials for","tool_app.oauth_failed":"failed to connect credentials for","tool_app.oauth_access_finalized":"finished credential access for","tool_app.finished":"finished setup for","tool_app.reconnected":"reconnected","tool_application.archived":"removed","tool_connection.created":"created","tool_connection.updated":"updated","tool_connection.archived":"removed","tool_connection.sign_in_cancelled":"cancelled sign-in for","tool_connection.catalog_refresh":"refreshed actions for","tool_connection.installs_synced":"changed agent installs for","tool_connection.install_access_extended":"extended agent access for","tool_connection.grant_audience_replaced":"changed human access for","tool_connection.grant_added":"added credentials to","tool_connection.grant_revoked":"revoked credentials from","tool_connection.google_access_ended":"confirmed Google access ended for","tool_connection.google_access_not_ended":"stopped trying to end Google access for","tool_connection.grant_delegated":"delegated credentials for","tool_connection.grant_delegation_revoked":"revoked credential delegation for","tool_connection.content_deletion_requested":"asked to delete stored content from","tool_connection.content_deletion_started":"started deleting stored content from","tool_connection.content_deleted":"deleted stored content from","issue.connection_content_deleted":"deleted connected app content from","issue.connection_content_deletion_incomplete":"partly deleted connected app content from"},bb={"issue.created":"created the issue","issue.updated":"updated the issue","issue.checked_out":"checked out the issue","issue.released":"released the issue","issue.comment_added":"added a comment","issue.comment_cancelled":"cancelled a queued comment","issue.queued_comment_edited":"edited a queued comment","issue.queued_comments_reordered":"reordered queued comments","issue.queued_comment_discarded":"discarded a queued comment","issue.comment_deleted":"deleted a comment","issue.feedback_vote_saved":"saved feedback on an AI output","issue.attachment_added":"added an attachment","issue.attachment_removed":"removed an attachment","issue.document_created":"created a document","issue.document_updated":"updated a document","issue.document_locked":"locked a document","issue.document_unlocked":"unlocked a document","issue.document_deleted":"deleted a document","issue.monitor_scheduled":"scheduled a monitor","issue.monitor_triggered":"triggered a monitor","issue.monitor_cleared":"cleared a monitor","issue.monitor_skipped":"skipped a monitor","issue.monitor_exhausted":"exhausted a monitor","issue.monitor_recovery_wake_queued":"queued a monitor recovery wake","issue.monitor_recovery_issue_created":"created a monitor recovery issue","issue.monitor_escalated_to_board":"escalated a monitor to the board","issue.deleted":"deleted the issue","issue.successful_run_handoff_required":"Run finished without a clear next step","issue.successful_run_handoff_resolved":"Next step chosen","issue.successful_run_handoff_escalated":"Run finished without a next step - recovery escalated","issue.cross_issue_influence_cap_rejected":"hit the per-run cross-task write cap","issue.cross_issue_influence_observed":"made a cross-task write","issue.attribution_spoof_rejected":"tried to choose its own responsible user","issue.recovery_action_opened":"Opened a source-scoped recovery action","issue.workspace_recovered":"Saved work recovered.","issue.retry_continued_from_saved_work":"Retry continued from saved work.","issue.workspace_recovery_requested":"Requested workspace recovery","issue.previous_run_files_waiting":"Still working to save the previous run's unsaved files. New runs start once they are saved. Microvac keeps trying on its own.","issue.previous_run_files_lost":"Could not save the previous run's unsaved files because they were already gone. This task continues from its last save.","issue.recovery_action_resolved":"Resolved the recovery action","issue.recovery_action_escalated":"Escalated the recovery action","issue.accepted_plan_decomposition_updated":"updated the accepted-plan decomposition","agent.created":"created an agent","agent.updated":"updated the agent","agent.paused":"paused the agent","agent.resumed":"resumed the agent","agent.error_cleared":"cleared the agent error","agent.terminated":"terminated the agent","heartbeat.invoked":"invoked a heartbeat","heartbeat.cancelled":"cancelled a heartbeat","heartbeat.output_stale_source_resolved":"System folded a stale run","heartbeat.output_stale_recovery_recursion_refused":"Refused recovery-on-recovery escalation","approval.created":"requested approval","approval.approved":"approved","approval.rejected":"rejected","issue.thread_interaction_created":"asked for a decision","issue.thread_interaction_accepted":"accepted the request","issue.thread_interaction_rejected":"rejected the request","issue.thread_interaction_answered":"answered the request","issue.thread_interaction_withdrawn":"withdrew the request","issue.thread_interaction_cancelled":"cancelled the request","issue.thread_interaction_skipped":"skipped the request","issue.thread_interaction_dismissed":"deferred the request","issue.thread_interaction_expired":"expired the request","issue.thread_interaction_item_verdicts_submitted":"submitted verdicts on the request","issue.stalled_review_decided":"recorded a review verdict","issue.connection_content_deleted":"deleted connected app content","issue.connection_content_deletion_incomplete":"partly deleted connected app content; some is still in use"},ude={company:"the organization",agent:"an agent",goal:"a goal",project:"a project",routine:"a routine",heartbeat_run:"a run",approval:"an approval",tool_connection:"the connection",tool_application:"the app"};function ph(e){return typeof e=="string"&&e.trim()?e.trim():null}a(ph,"readText");function mde(e){const t=bf(e?.providerAccess);return t?.provider==="google"?ph(t.result):null}a(mde,"googleProviderAccessResult");function hde(e){const t=ph(e?.upstreamToolName)??ph(e?.tool)?.replace(/^(?:mcp|app)\.[^:]*:|^(?:mcp|app)\.[a-z0-9-]*-[0-9a-f]{8}\./,"").replace(/-[0-9a-f]{16}$/,""),n=ph(e?.toolTitle);return t?TP(t,n)??t.replace(/[._-]+/g," "):n??"an app action"}a(hde,"formatToolLabel");function Xhe(e,t){const n=ph(t?.name);return e==="tool_application"&&n?n:e==="tool_connection"&&mde(t)?"the Google Workspace connection":ude[e]??e.replace(/[._]+/g," ")}a(Xhe,"formatActivityEntityLabel");function Zhe(e,t){return e==="tool_application.archived"&&t?.reason==="last_connection_removed"?"Its last connection was removed.":null}a(Zhe,"formatActivityOutcome");var E$={approve:"approved the review",request_changes:"requested changes on the review",send_back:"sent the review back to work"},fde={request_confirmation:"approved the request",request_checkbox_confirmation:"approved the request",suggest_tasks:"accepted the task suggestions",ask_user_questions:"accepted the answers"},pde={request_confirmation:"rejected the request",request_checkbox_confirmation:"rejected the request",suggest_tasks:"declined the task suggestions",ask_user_questions:"declined the questions"};function M$(e,t){const n=e==="issue.thread_interaction_accepted"?fde:e==="issue.thread_interaction_rejected"?pde:null;if(!n)return null;const r=typeof t?.interactionKind=="string"?t.interactionKind:null;return r?n[r]??null:null}a(M$,"formatInteractionOutcomeLabel");function bf(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}a(bf,"asRecord$1");function Ao(e){return typeof e!="string"?String(e??"none"):e.replace(/_/g," ")}a(Ao,"humanizeValue");function gde(e){const t=bf(e);return t?t.type==="agent"||t.type==="user":!1}a(gde,"isActivityParticipant");function xde(e){return bf(e)!==null}a(xde,"isActivityIssueReference");function CC(e,t){const n=e?.[t];return Array.isArray(n)?n.filter(gde):[]}a(CC,"readParticipants");function AC(e,t){const n=e?.[t];return Array.isArray(n)?n.filter(xde):[]}a(AC,"readIssueReferences");function $$(e,t={}){if(!e||e==="local-board")return"Board";if(t.currentUserId&&e===t.currentUserId)return"You";const n=t.userProfileMap?.get(e);return n?n.label:`user ${e.slice(0,5)}`}a($$,"formatUserLabel");function RC(e,t){if(e.type==="agent"){const n=e.agentId??"";return t.agentMap?.get(n)?.name??"agent"}return $$(e.userId,t)}a(RC,"formatParticipantLabel");function TC(e){return e.identifier?e.identifier:e.title?e.title:e.id?e.id.slice(0,8):"task"}a(TC,"formatIssueReferenceLabel");function pp(e,t,n){return n.length<=0?t:n.length===1?`${e} ${n[0]}`:`${n.length} ${t}`}a(pp,"formatChangedEntityLabel");function bde(e){return typeof e=="number"&&Number.isFinite(e)?e:null}a(bde,"readNumber");function EC(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0).length:0}a(EC,"readStringArrayLength");function yde(e){if(!e)return null;const t=typeof e.status=="string"?e.status:null,n=bde(e.requestedChildCount),r=EC(e.childIssueIds),i=EC(e.newlyCreatedChildIssueIds),o=Math.max(0,r-i),l=[];i>0&&l.push(`created ${i} new`),o>0&&l.push(`reused ${o} existing`),l.length===0&&n!==null&&l.push(`${n} requested`);const c=l.length>0?l.join(", "):null;return t==="completed"&&c?`decomposition completed (${c})`:t==="completed"?"decomposition completed":t==="in_flight"&&c?`decomposition in flight (${c})`:c}a(yde,"formatAcceptedPlanDecompositionDetail");function vde(e){if(!e)return null;const t=bf(e._previous)??{};if(e.status!==void 0){const n=t.status,r=Ao(e.status==="in_review"&&e.externalConversationState==="waiting"?"idle":e.status);return n?`changed status from ${Ao(n)} to ${r} on`:`changed status to ${r} on`}if(e.priority!==void 0){const n=t.priority;return n?`changed priority from ${Ao(n)} to ${Ao(e.priority)} on`:`changed priority to ${Ao(e.priority)} on`}return null}a(vde,"formatIssueUpdatedVerb");function wde(e,t){if(!e)return null;const n=e.assigneeAgentId,r=e.assigneeUserId;return typeof n=="string"&&n?t.agentMap?.get(n)?.name??"agent":typeof r=="string"&&r?$$(r,t):null}a(wde,"formatAssigneeName");function kde(e,t={}){if(!e)return null;const n=bf(e._previous)??{},r=[];if(e.status!==void 0){const i=n.status,o=Ao(e.status==="in_review"&&e.externalConversationState==="waiting"?"idle":e.status);r.push(i?`changed the status from ${Ao(i)} to ${o}`:`changed the status to ${o}`)}if(e.priority!==void 0){const i=n.priority;r.push(i?`changed the priority from ${Ao(i)} to ${Ao(e.priority)}`:`changed the priority to ${Ao(e.priority)}`)}if(e.assigneeAgentId!==void 0||e.assigneeUserId!==void 0){const i=wde(e,t);r.push(i?`made ${i} responsible for the task`:"cleared the responsible")}return e.reviewPolicy!==void 0&&r.push(`changed who can approve to ${FT(e.reviewPolicy)}`),e.title!==void 0&&r.push("updated the title"),e.description!==void 0&&r.push("updated the description"),r.length>0?r.join(", "):null}a(kde,"formatIssueUpdatedAction");function P$(e){const t=e.details;if(!t)return null;if(e.action==="issue.blockers_updated"){const n=AC(t,"addedBlockedByIssues").map(TC),r=AC(t,"removedBlockedByIssues").map(TC);if(n.length>0&&r.length===0){const i=pp("blocker","blockers",n);return e.forIssueDetail?`added ${i}`:`added ${i} to`}if(r.length>0&&n.length===0){const i=pp("blocker","blockers",r);return e.forIssueDetail?`removed ${i}`:`removed ${i} from`}return e.forIssueDetail?"updated blockers":"updated blockers on"}if(e.action==="issue.reviewers_updated"||e.action==="issue.approvers_updated"){const n=CC(t,"addedParticipants").map(l=>RC(l,e.options)),r=CC(t,"removedParticipants").map(l=>RC(l,e.options)),i=e.action==="issue.reviewers_updated"?"reviewer":"approver",o=e.action==="issue.reviewers_updated"?"reviewers":"approvers";if(n.length>0&&r.length===0){const l=pp(i,o,n);return e.forIssueDetail?`added ${l}`:`added ${l} to`}if(r.length>0&&n.length===0){const l=pp(i,o,r);return e.forIssueDetail?`removed ${l}`:`removed ${l} from`}return e.forIssueDetail?`updated ${o}`:`updated ${o} on`}return null}a(P$,"formatStructuredIssueChange");function efe(e,t,n={}){if(e.startsWith("tool_gateway.")){const o=hde(t),l=t?.source==="test";if(e==="tool_gateway.call_completed")return`${l?"tested":"used"} ${o} on`;if(e==="tool_gateway.call_allowed")return`${l?"started a test of":"was allowed to use"} ${o} on`;if(e==="tool_gateway.call_denied")return`was blocked from using ${o} on`;if(e==="tool_gateway.approval_requested")return`asked to use ${o} on`;if(e==="tool_gateway.call_failed")return`could not ${l?"test":"use"} ${o} on`;if(e==="tool_gateway.call_deferred")return`could not finish ${l?"testing":"using"} ${o} on`;if(e==="tool_gateway.session_created")return"opened an app session for";if(e==="tool_gateway.session_rejected")return"was blocked from opening an app session for";if(e==="tool_gateway.discovery")return"discovered app actions for"}if(e==="issue.updated"){const o=vde(t);if(o)return o}if(e==="issue.stalled_review_decided"){const o=typeof t?.action=="string"?t.action:null,l=o?E$[o]:null;if(l)return`${l} on`}const r=M$(e,t);if(r)return`${r} on`;const i=P$({action:e,details:t,options:n,forIssueDetail:!1});return i||(dde[e]??e.replace(/[._]/g," "))}a(efe,"formatActivityVerb");function jde(e,t,n={}){if(e==="issue.updated"){const o=kde(t,n);if(o)return o}const r=P$({action:e,details:t,options:n,forIssueDetail:!0});if(r)return r;if(e==="issue.accepted_plan_decomposition_updated"){const o=yde(t);if(o)return o}if(e==="issue.stalled_review_decided"){const o=typeof t?.action=="string"?t.action:null,l=o?E$[o]:null;if(l)return l}const i=M$(e,t);if(i)return i;if(e.startsWith("issue.monitor_")&&t){const o=typeof t.serviceName=="string"&&t.serviceName.trim()?t.serviceName.trim():null,l=bb[e]??e.replace(/[._]/g," ");return o?`${l} for ${o}`:l}if((e==="issue.document_created"||e==="issue.document_updated"||e==="issue.document_locked"||e==="issue.document_unlocked"||e==="issue.document_deleted")&&t){const o=typeof t.key=="string"?t.key:"document",l=typeof t.title=="string"&&t.title?` (${t.title})`:"";return`${bb[e]??e} ${o}${l}`}return bb[e]??e.replace(/[._]/g," ")}a(jde,"formatIssueActivityAction");function Nde(e,t){return e?JSON.stringify({id:e.id,status:e.status,displayStatus:e.displayStatus,priority:e.priority,assigneeAgentId:e.assigneeAgentId,assigneeUserId:e.assigneeUserId,projectId:e.projectId,projectWorkspaceId:e.projectWorkspaceId,parentId:e.parentId,createdByUserId:e.createdByUserId,hiddenAt:e.hiddenAt,labelIds:e.labelIds??[],executionWorkspaceId:e.executionWorkspaceId,executionWorkspacePreference:e.executionWorkspacePreference,executionWorkspaceSettings:e.executionWorkspaceSettings??null,currentExecutionWorkspace:e.currentExecutionWorkspace?{id:e.currentExecutionWorkspace.id,mode:e.currentExecutionWorkspace.mode,status:e.currentExecutionWorkspace.status,projectWorkspaceId:e.currentExecutionWorkspace.projectWorkspaceId,branchName:e.currentExecutionWorkspace.branchName,cwd:e.currentExecutionWorkspace.cwd,runtimeServices:(e.currentExecutionWorkspace.runtimeServices??[]).map(n=>({id:n.id,status:n.status,url:n.url}))}:null,executionPolicy:e.executionPolicy??null,executionState:e.executionState?{status:e.executionState.status,currentStageType:e.executionState.currentStageType,currentParticipant:e.executionState.currentParticipant,returnAssignee:e.executionState.returnAssignee}:null,blocks:(e.blocks??[]).map(n=>({id:n.id,identifier:n.identifier??null,title:n.title,status:n.status,displayStatus:n.displayStatus})),blockedBy:(e.blockedBy??[]).map(n=>({id:n.id,identifier:n.identifier??null,title:n.title,status:n.status,displayStatus:n.displayStatus})),watchdog:e.watchdog?{id:e.watchdog.id,watchdogAgentId:e.watchdog.watchdogAgentId,instructions:e.watchdog.instructions??null,status:e.watchdog.status,watchdogIssueId:e.watchdog.watchdogIssueId??null}:null,parentSummary:e.ancestors?.[0]?{id:e.ancestors[0].id,identifier:e.ancestors[0].identifier??null,title:e.ancestors[0].title}:null,childIssues:t.map(n=>({id:n.id,updatedAt:String(n.updatedAt),identifier:n.identifier??null,title:n.title}))}):""}a(Nde,"buildIssuePropertiesPanelKey");var ov=/^(?:\/([^/]+))?\/issues\/([^/]+)\/?$/;function lv(e){const t=Al(e);if(!t)return null;if(t.documentKey==="continuation-summary"&&!t.documentIssueId)return{kind:"continuation-summary"};const n=t.viewer==="full";return t.documentKey==="plan"&&!t.revisionId&&!t.documentIssueId?{kind:"properties-pane",tab:"plans",documentKey:"plan",maximize:n}:{kind:"properties-pane",tab:"document",documentKey:t.documentKey,maximize:n}}a(lv,"resolveIssueDocumentDeepLink");function Ide(e,t,n){let r;try{r=new URL(e,t)}catch{return null}if(r.origin!==t.origin||r.search!==t.search||!lv(r.hash))return null;if(r.pathname===t.pathname)return r.hash;const i=t.pathname.match(ov),o=r.pathname.match(ov);if(!i||!o||o[1]&&o[1]!==i[1])return null;try{const l=decodeURIComponent(o[2]).toLowerCase();return n.some(c=>c.toLowerCase()===l)?r.hash:null}catch{return null}}a(Ide,"sameIssueDocumentHash");function Sde(e,t,n){let r;try{r=new URL(e,t)}catch{return null}if(r.origin!==t.origin||r.search&&r.search!==t.search)return null;const i=Al(r.hash);if(!i)return null;if(r.pathname===t.pathname)return r.hash;const o=r.pathname.match(ov),l=t.pathname.match(/^\/([^/]+)\/chats\//)?.[1];if(!o||o[1]&&o[1].toLowerCase()!==l?.toLowerCase())return null;let c;try{c=i.documentIssueId??decodeURIComponent(o[2])}catch{return null}if(!/^[\w-]+$/.test(c))return null;const d=n.some(m=>m.toLowerCase()===c.toLowerCase());return jc({...i,documentIssueId:d?void 0:c})}a(Sde,"chatSidebarDocumentHash");function MC(e){return e?(0,s.jsx)("span",{className:"flex min-w-0 items-center gap-2",children:e.identity}):null}a(MC,"renderAccessIdentity");var _de={owner:{label:"task owner",icon:qo,className:"border-border bg-muted text-muted-foreground"},explicit:{label:"shared directly",icon:LA,className:"border-primary/30 bg-primary/10 text-primary"},assignment:{label:"via assignment",icon:Ut,className:"border-border bg-secondary text-secondary-foreground"},project:{label:"via project",icon:G4,className:"border-border bg-accent text-accent-foreground"}};function Cde({source:e}){const t=_de[e],n=t.icon;return(0,s.jsxs)("span",{"data-testid":`grant-source-badge-${e}`,"data-source":e,className:E("inline-flex shrink-0 items-center gap-1 rounded-md border px-1.5 py-0.5 text-(length:--text-nano) font-medium leading-tight",t.className),children:[(0,s.jsx)(n,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),t.label]})}a(Cde,"SourceBadge");function $C({displayName:e,avatarUrl:t,initials:n}){return(0,s.jsxs)(_l,{size:"sm",className:"mt-0.5","aria-hidden":"true",children:[t?(0,s.jsx)(Id,{src:t,alt:""}):null,(0,s.jsx)(Sl,{children:n??e.slice(0,2).toUpperCase()})]})}a($C,"PrincipalAvatar");function PC({avatar:e,title:t,subtitle:n,badge:r,action:i}){return(0,s.jsxs)("div",{className:"flex items-start gap-2.5 py-2",children:[e,(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,s.jsx)("span",{className:"truncate text-sm font-medium",children:t}),r]}),n?(0,s.jsx)("div",{className:"truncate text-xs text-muted-foreground",children:n}):null]}),i?(0,s.jsx)("div",{className:"shrink-0 self-center",children:i}):null]})}a(PC,"RowShell");function Ade({issueId:e,companyId:t,canManage:n,open:r,onOpenChange:i,aclDescription:o="Sharing grants access to this task and its descendants, including comments, documents, and run history. Parents and siblings need separate access.",implicitPrincipals:l=[],initialView:c="list",initialAddSelection:d=""}){const m=ys(),{pushToast:h}=lm(),[f,p]=(0,u.useState)(c),[g,b]=(0,u.useState)(d),[y,x]=(0,u.useState)(null),v=Te({queryKey:G.issues.accessGrants(e),queryFn:a(()=>$e.listAccessGrants(e),"queryFn"),enabled:r}),k=Te({queryKey:G.access.companyUserDirectory(t),queryFn:a(()=>Eo.listUserDirectory(t),"queryFn"),enabled:r&&f==="add"&&n}),w=Te({queryKey:G.agents.list(t),queryFn:a(()=>$r.list(t),"queryFn"),enabled:r&&f==="add"&&n}),j=(0,u.useMemo)(()=>(v.data??[]).filter(S=>S.revokedAt===null),[v.data]),_=(0,u.useMemo)(()=>new Set(j.filter(S=>!S.inherited&&S.source!=="project").map(S=>`${S.subjectType}:${S.subjectId}`)),[j]),I=ut({mutationFn:a(S=>$e.createAccessGrant(e,S),"mutationFn"),onSuccess:a(()=>{m.invalidateQueries({queryKey:["issues"]}),b(""),p("list"),h({title:"Access granted",tone:"success"})},"onSuccess"),onError:a(S=>{h({title:"Couldn't add access",body:S.message,tone:"error"})},"onError")}),T=ut({mutationFn:a(S=>$e.revokeAccessGrant(e,S.id),"mutationFn"),onSuccess:a(()=>{m.invalidateQueries({queryKey:["issues"]}),x(null),h({title:"Access revoked",tone:"success"})},"onSuccess"),onError:a(S=>{h({title:"Couldn't revoke access",body:S.message,tone:"error"})},"onError")}),F=(0,u.useMemo)(()=>{const S=(k.data?.users??[]).filter(R=>R.user&&!_.has(`user:${R.user.id}`)).map(R=>({key:`user:${R.user.id}`,value:`user:${R.user.id}`,label:R.user.name??R.user.email??"Unknown user",searchText:[R.user.name,R.user.email].filter(Boolean).join(" "),identity:(0,s.jsx)(Nu,{name:R.user.name??R.user.email??"Unknown user",avatarUrl:R.user.image,size:"sm"})})),L=(w.data??[]).filter(R=>!_.has(`agent:${R.id}`)).map(R=>({key:`agent:${R.id}`,value:`agent:${R.id}`,label:R.name,searchText:R.name,identity:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(un,{agent:R,size:24}),(0,s.jsx)("span",{className:"truncate",children:R.name})]})})),M=[];return S.length>0&&M.push({id:"people",label:"People",options:S}),L.length>0&&M.push({id:"agents",label:"Agents",options:L}),M},[k.data,w.data,_]),O=(0,u.useMemo)(()=>{if(!g.startsWith("agent:"))return null;const S=g.slice(6),L=(w.data??[]).find(M=>M.id===S);return L&&gQ(pQ(L.permissions))?L.name:null},[g,w.data]);function z(S){S||(p("list"),b(""),x(null)),i(S)}a(z,"resetAndClose");function q(){if(!g)return;const[S,L]=g.split(/:(.+)/);L&&I.mutate({subjectType:S,subjectId:L})}a(q,"submitAdd");const A=Sn(v),H=v.isLoading||A.kind==="reconnecting",B=A.kind==="error",C=!H&&!B&&j.length===0&&l.length===0;return(0,s.jsxs)(Qr,{open:r,onOpenChange:z,children:[(0,s.jsxs)(Vr,{className:"sm:max-w-md",children:[(0,s.jsxs)(ca,{children:[(0,s.jsxs)(Hr,{className:"flex items-center gap-2",children:[(0,s.jsx)(qo,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),"Who can access this task"]}),(0,s.jsx)(Na,{children:o})]}),f==="list"?(0,s.jsxs)("div",{className:"space-y-1",children:[H?(0,s.jsx)("div",{className:"space-y-2 py-1","data-testid":"share-sheet-loading",children:[0,1,2].map(S=>(0,s.jsxs)("div",{className:"flex items-center gap-2.5 py-1",children:[(0,s.jsx)(As,{className:"h-6 w-6 rounded-full"}),(0,s.jsxs)("div",{className:"flex-1 space-y-1.5",children:[(0,s.jsx)(As,{className:"h-3 w-32"}),(0,s.jsx)(As,{className:"h-2.5 w-20"})]})]},S))}):B?(0,s.jsx)("div",{"data-testid":"share-sheet-error",children:(0,s.jsx)(oa,{error:v.error,action:"load access",onRetry:A.retry,retrying:A.isFetching})}):C?(0,s.jsx)("p",{className:"py-3 text-sm text-muted-foreground","data-testid":"share-sheet-empty",children:"Only you can see this task."}):(0,s.jsxs)("div",{className:"divide-y divide-border/60",children:[l.filter(S=>!j.some(L=>L.subjectId===S.id||`${L.subjectType}:${L.subjectId}`===S.id)).map(S=>(0,s.jsx)(PC,{avatar:(0,s.jsx)($C,{displayName:S.displayName,avatarUrl:S.avatarUrl,initials:S.initials}),title:S.displayName,subtitle:S.subtitle??void 0,badge:(0,s.jsx)("span",{className:"inline-flex shrink-0 items-center rounded-md border border-border bg-muted/50 px-1.5 py-0.5 text-(length:--text-nano) font-medium text-muted-foreground",children:S.roleLabel})},`implicit:${S.id}`)),j.map(S=>{const L=S.subjectDisplayName??"Unknown",M=l.find(J=>J.id===`${S.subjectType}:${S.subjectId}`),R=n&&!S.inherited&&xQ(S.source),V=S.source==="explicit"?"Shared":"Granted";return(0,s.jsx)(PC,{avatar:(0,s.jsx)($C,{displayName:L,avatarUrl:S.subjectAvatarUrl,initials:S.subjectInitials}),title:L,subtitle:M?`${M.roleLabel} — access remains while this role applies`:S.inherited?"Inherited access — managed at its source":`${V} ${ba(S.createdAt)}`,badge:(0,s.jsx)(Cde,{source:S.source}),action:R?(0,s.jsx)(W,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-destructive",onClick:a(()=>x(S),"onClick"),children:M?"Remove saved grant":"Revoke"}):S.source==="project"?(0,s.jsx)("span",{className:"text-(length:--text-nano) text-muted-foreground",children:"project-managed"}):null},S.id)})]}),n?(0,s.jsx)("div",{className:"pt-2",children:(0,s.jsxs)(W,{variant:"outline",size:"sm",className:"w-full",onClick:a(()=>p("add"),"onClick"),disabled:H,children:[(0,s.jsx)(LA,{className:"h-3.5 w-3.5","aria-hidden":"true"})," Add someone"]})}):null]}):(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(m1,{value:g,groups:F,renderValue:a(S=>S?MC(S):"Choose a person or agent…","renderValue"),renderOption:MC,onValueChange:a(S=>b(S),"onValueChange"),placeholder:"Choose a person or agent…",searchPlaceholder:"Search people and agents…",loading:k.isLoading||w.isLoading,loadingMessage:"Loading directory…",emptyMessage:"No one left to add.",triggerClassName:"w-full"}),O?(0,s.jsxs)("div",{role:"note","aria-label":"Shared agent caution","data-testid":"shared-agent-caution",className:"flex items-start gap-2 rounded-md border border-border bg-muted px-3 py-2 text-xs leading-relaxed text-foreground",children:[(0,s.jsx)(ls,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"font-semibold",children:"Shared agent."})," ",O,"'s memory & workspace may carry residual private context from this task into its later runs for other people. Grant only if that's acceptable."]})]}):null,(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 pt-1",children:[(0,s.jsx)(W,{variant:"ghost",size:"sm",onClick:a(()=>{p("list"),b("")},"onClick"),children:"Back"}),(0,s.jsx)(W,{size:"sm",onClick:q,disabled:!g||I.isPending,children:I.isPending?"Adding…":"Add"})]})]})]}),(0,s.jsx)(im,{open:y!==null,onOpenChange:a(S=>{S||x(null)},"onOpenChange"),children:(0,s.jsxs)(om,{children:[(0,s.jsxs)(am,{children:[(0,s.jsxs)(cm,{children:["Remove ",y?.subjectDisplayName??"this subject","'s saved grant?"]}),(0,s.jsxs)(nm,{children:["This removes this grant and the access it supplies to this task's descendants. Ownership, current assignment, project membership, inherited access, or another grant can still provide access. Revoking access does ",(0,s.jsx)("span",{className:"font-semibold",children:"not"})," erase content already seen or retained in an agent's memory."]})]}),(0,s.jsxs)(sm,{children:[(0,s.jsx)(um,{children:"Cancel"}),(0,s.jsx)(Og,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:a(S=>{S.preventDefault(),y&&T.mutate(y)},"onClick"),disabled:T.isPending,children:T.isPending?"Removing…":"Remove grant"})]})]})})]})}a(Ade,"IssueShareSheet");var gp="flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent",Rde="Only the task owner or an admin can change who can see this task.";function Tde({issue:e,companyId:t,canManage:n,closeMenu:r,implicitPrincipals:i=[],children:o}){const l=ys(),{pushToast:c}=lm(),[d,m]=(0,u.useState)(!1),[h,f]=(0,u.useState)(!1),p=e.visibility==="private",g=Te({queryKey:[...G.issues.privacyConstraints(e.id),e.privacyParentIssueId??null,e.projectId??null],queryFn:a(()=>$e.privacyConstraints(e.id),"queryFn"),enabled:n&&p}),b=Sn(g),y=b.kind==="error"?"Couldn't check task privacy. Retry before making this task public.":b.kind==="loading"||b.kind==="reconnecting"||b.isFetching?"Checking task privacy…":b.data?.publicBlockedBy==="parent"?"Move this task out of its private parent before making it public.":b.data?.publicBlockedBy==="project"?"Move this task out of its private project before making it public.":null,x=ut({mutationFn:a(k=>$e.setVisibility(e.id,k),"mutationFn"),onSuccess:a((k,w)=>{l.invalidateQueries({queryKey:["issues"]}),l.invalidateQueries({queryKey:G.projects.all(t)}),e.identifier&&l.invalidateQueries({queryKey:G.issues.detail(e.identifier)}),l.invalidateQueries({queryKey:G.issues.accessGrants(e.id)}),f(!1),c({title:w==="private"?"Task is now private":"Task is now public",tone:"success"})},"onSuccess"),onError:a(k=>{c({title:"Couldn't change visibility",body:Ps(k).body,tone:"error"})},"onError")});function v(k,w){return n&&!w?k:(0,s.jsxs)(wa,{children:[(0,s.jsx)(ka,{asChild:!0,children:(0,s.jsx)("span",{className:"block w-full",tabIndex:0,children:k})}),(0,s.jsx)(ja,{className:"max-w-xs text-xs",children:n?w:Rde})]})}return a(v,"withTooltip"),(0,s.jsxs)(kh,{children:[o(p?(0,s.jsxs)(s.Fragment,{children:[v((0,s.jsxs)("button",{type:"button",className:gp,disabled:!n,onClick:a(()=>{r(),m(!0)},"onClick"),children:[(0,s.jsx)(id,{className:"h-4 w-4","aria-hidden":"true"})," Share…"]})),v((0,s.jsxs)("button",{type:"button",className:E(gp,"text-destructive"),disabled:!n||!!y,onClick:a(()=>{r(),f(!0)},"onClick"),children:[(0,s.jsx)(Tl,{className:"h-4 w-4","aria-hidden":"true"})," Make public"]}),y),n&&b.kind==="error"?(0,s.jsx)("button",{type:"button",className:gp,onClick:a(()=>{b.retry()},"onClick"),children:"Retry access check"}):null]}):v((0,s.jsxs)("button",{type:"button",className:gp,disabled:!n||x.isPending,onClick:a(()=>{r(),x.mutate("private")},"onClick"),children:[(0,s.jsx)(qo,{className:"h-4 w-4","aria-hidden":"true"})," Make private"]}))),(0,s.jsx)(Ade,{issueId:e.id,companyId:t,canManage:n,open:d,onOpenChange:m,implicitPrincipals:i}),(0,s.jsx)(im,{open:h,onOpenChange:f,children:(0,s.jsxs)(om,{children:[(0,s.jsxs)(am,{children:[(0,s.jsx)(cm,{children:"Make this task public?"}),(0,s.jsxs)(nm,{children:["Everyone in the company will be able to read this task, its comments, documents, and run history. Existing private subtasks keep their privacy."," ",g.data?.leavesPersonalProject?"This task will also leave its personal project. ":null,(0,s.jsx)("span",{className:"font-semibold text-foreground",children:"Content already seen by others cannot be taken back."})]})]}),(0,s.jsxs)(sm,{children:[(0,s.jsx)(um,{children:"Keep private"}),(0,s.jsx)(Og,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:a(k=>{k.preventDefault(),x.mutate("open")},"onClick"),disabled:x.isPending||!!y,children:x.isPending?"Making public…":"Make public"})]})]})})]})}a(Tde,"IssuePrivacyActions");var tfe=Pg({IssueDetail:a(()=>Qde,"IssueDetail"),IssueDetailLoadingState:a(()=>uv,"IssueDetailLoadingState"),TaskDetailSurface:a(()=>q$,"TaskDetailSurface"),canBoardManageRuntime:a(()=>Ww,"canBoardManageRuntime"),canBoardResolveRecoveryAction:a(()=>Kw,"canBoardResolveRecoveryAction"),readRecoveryReconcileWorkspaceId:a(()=>KE,"readRecoveryReconcileWorkspaceId"),shouldScrollIssueDetailToTopOnNavigation:a(()=>D$,"shouldScrollIssueDetailToTopOnNavigation")}),Om=[],Ede=[];function DC(e){const t=e instanceof Error?`Run was stopped, but updating the task failed: ${Ps(e).body}`:"Run was stopped, but updating the task failed. Retry the task status update.",n=new Error(t);return n.runCancelledBeforeStatusUpdateFailed=!0,n}a(DC,"createRunCancelledStatusUpdateError");function Mde(e){return e instanceof Error&&e.runCancelledBeforeStatusUpdateFailed===!0}a(Mde,"didRunCancelBeforeStatusUpdateFail");function LC(e){return e.kind==="request_confirmation"&&e.payload.target?.type==="issue_document"&&e.payload.target.key==="plan"}a(LC,"isPlanConfirmationInteraction");function $de(e){if(e.status==="accepted")return"Approved plan";const t=e.result?.reason?.trim();return t?`Requested changes
115
115
 
116
- ${t}`:"Requested changes"}a($de,"buildPlanDecisionResponseText");var OC="https://paperclip.ing/tos",Pde=150,Dde=10;function Lde(e){if(e instanceof mn){if(e.status===403)return"Only board users can preview subtree controls.";if(e.status===409)return"Preview is stale because subtree hold state changed. Retry to refresh.";if(e.status===422)return"This subtree action is currently invalid for the selected tasks."}return e instanceof Error?e.message:"Unable to load preview."}a(Lde,"treeControlPreviewErrorCopy");function D$(e){return e.navigationType==="POP"?!1:e.previousIssueId!==e.nextIssueId}a(D$,"shouldScrollIssueDetailToTopOnNavigation");var cv={count:0,waitingOnly:!1,agentQueue:null};function qC(e){return e.length?{count:e.length,waitingOnly:e.every(t=>Mb(t)),agentQueue:e.map(t=>Yg(t.execution)).find(Boolean)??null}:cv}a(qC,"summarizeLiveRuns");function L$(e,t){return(t??[]).find(n=>n.status==="running")??(t??[]).find(n=>n.status==="queued")??null??(e?.status==="running"||e?.status==="queued"?e:null)}a(L$,"resolveInterruptibleIssueRun");function BC(e,t,n){const r=e.getQueryData(G.issues.liveRuns(t)),i=e.getQueryData(G.issues.activeRun(t)),o=!!(i&&r?.some(d=>d.id===i.id)),l=!!(i&&n?.executionRunId&&i.id===n.executionRunId),c=o||l?i:null;return{liveRuns:r,activeRun:c,interruptibleIssueRun:L$(c,r)}}a(BC,"readIssueRunStateFromCache");function dv(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}a(dv,"asRecord");function Ode(e){const t=dv(e.metadata);if(!t)return null;const n=$1.safeParse(t.resourceRef);return n.success?n.data:null}a(Ode,"extractWorkspaceFileRefFromWorkProduct");function yb(e,...t){if(!e)return 0;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return 0}a(yb,"usageNumber");function FC(e){const t=e.name.toLowerCase();return t.endsWith(".md")||t.endsWith(".markdown")||e.type==="text/markdown"}a(FC,"isMarkdownFile");function qde(e){return e.replace(/\.[^.]+$/,"")}a(qde,"fileBaseName");function Bde(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"document"}a(Bde,"slugifyDocumentKey");function Fde(e){return e.split(/[-_ ]+/g).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}a(Fde,"titleizeFilename");function zde(e,t,n){const r=new Date,i=e??[],o=i.findIndex(l=>l.targetType===t.targetType&&l.targetId===t.targetId&&(!n||l.authorUserId===n));if(o>=0){const l=i[o],c={...l,vote:t.vote,reason:t.reason!==void 0?t.reason.trim()||null:l.reason,updatedAt:r},d=[...i];return d[o]=c,d}return[...i,{id:`optimistic:${t.targetType}:${t.targetId}`,companyId:"",issueId:t.issueId,targetType:t.targetType,targetId:t.targetId,authorUserId:n??"current-user",vote:t.vote,reason:t.reason?.trim()||null,sharedWithLabs:!1,sharedAt:null,consentVersion:null,redactionSummary:null,createdAt:r,updatedAt:r}]}a(zde,"mergeOptimisticFeedbackVote");function Ude({evt:e,agentMap:t,userProfileMap:n}){const r=e.actorId;if(e.actorType==="agent"){const i=t.get(r);return(0,s.jsx)(Pp,{agent:i??{id:r,name:r.slice(0,8)},size:"sm"})}if(e.actorType==="system")return(0,s.jsx)(Nu,{name:"System",size:"sm"});if(e.actorType==="user"){const i=n?.get(r);return(0,s.jsx)(Nu,{name:i?.label??"Board",avatarUrl:i?.image,size:"sm"})}return(0,s.jsx)(Nu,{name:r||"Unknown",size:"sm"})}a(Ude,"ActorIdentity");function zC(e){const t=e.trim().split(/\s+/);return t.length>=2?(t[0][0]+t[t.length-1][0]).toUpperCase():e.slice(0,2).toUpperCase()}a(zC,"attributionInitials");function UC({label:e,actor:t,via:n}){const r=n?`${e}: ${t.name} · via ${n}`:`${e}: ${t.name}`,i=e.toLowerCase();return(0,s.jsxs)(wa,{children:[(0,s.jsx)(ka,{asChild:!0,children:(0,s.jsx)("span",{"aria-label":r,"data-testid":`issue-${i}-avatar`,children:t.kind==="agent"?(0,s.jsx)(un,{agent:t,size:20}):(0,s.jsxs)(_l,{size:"xs",className:"ring-2 ring-background",children:[t.avatarUrl?(0,s.jsx)(Id,{src:t.avatarUrl,alt:""}):null,(0,s.jsx)(Sl,{children:zC(t.name)})]})})}),(0,s.jsx)(ja,{side:"top",sideOffset:6,className:"px-2 py-1.5",children:(0,s.jsxs)("div",{className:"flex items-center gap-2","data-testid":`issue-${i}-tooltip`,children:[t.kind==="agent"?(0,s.jsx)(un,{agent:t,size:32}):(0,s.jsxs)(_l,{size:"sm",className:"ring-1 ring-background/30",children:[t.avatarUrl?(0,s.jsx)(Id,{src:t.avatarUrl,alt:""}):null,(0,s.jsx)(Sl,{children:zC(t.name)})]}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("div",{className:"text-(length:--text-nano) font-medium uppercase leading-none text-background/70",children:e}),(0,s.jsx)("div",{className:"max-w-48 truncate text-xs font-medium leading-4 text-background",children:t.name}),n?(0,s.jsxs)("div",{className:"max-w-48 truncate text-(length:--text-nano) leading-3 text-background/60",children:["via ",n]}):null]})]})})]})}a(UC,"AttributionAvatar");function Wde({issue:e,agentMap:t,userProfileMap:n,userLabelMap:r}){const i=e.assigneeAgentId?{kind:"agent",id:e.assigneeAgentId,appearance:t.get(e.assigneeAgentId)?.appearance,name:t.get(e.assigneeAgentId)?.name??e.assigneeAgentId.slice(0,8)}:e.assigneeUserId?{kind:"user",id:e.assigneeUserId,name:kb(e.assigneeUserId,r)??n.get(e.assigneeUserId)?.label??"User",avatarUrl:n.get(e.assigneeUserId)?.image??null}:null,o=SA(e),l=o?o.kind==="agent"?{kind:"agent",id:o.id,appearance:t.get(o.id)?.appearance,name:t.get(o.id)?.name??o.id.slice(0,8)}:{kind:"user",id:o.id,name:kb(o.id,r)??n.get(o.id)?.label??"User",avatarUrl:n.get(o.id)?.image??null}:null,c=o?.kind==="user"&&o.viaAgentId?t.get(o.viaAgentId)?.name??o.viaAgentId.slice(0,8):null;return!i&&!l?null:(0,s.jsx)(kh,{children:(0,s.jsxs)(xD,{className:"-space-x-1.5","aria-label":"Task people","data-testid":"issue-attribution-avatar-stack",children:[i?(0,s.jsx)(UC,{label:"Assignee",actor:i}):null,l?(0,s.jsx)(UC,{label:"Originating",actor:l,via:c}):null]})})}a(Wde,"IssueAttributionByline");function Uk({titleWidth:e="w-28",rows:t=3}){return(0,s.jsxs)("div",{className:"space-y-3 rounded-lg border border-border p-3",children:[(0,s.jsx)(As,{className:E("h-4",e)}),(0,s.jsx)("div",{className:"space-y-2",children:Array.from({length:t}).map((n,r)=>(0,s.jsx)(As,{className:"h-12 w-full rounded-md"},r))})]})}a(Uk,"IssueSectionSkeleton");function xp({side:e,className:t}){const n=e==="human";return(0,s.jsxs)("div",{className:E("flex w-full flex-col gap-1",n?"items-end":"items-start"),children:[n?null:(0,s.jsxs)("span",{className:"flex items-center gap-2 px-1",children:[(0,s.jsx)(As,{className:"h-6 w-6 rounded-full"}),(0,s.jsx)(As,{className:"h-3 w-24"})]}),(0,s.jsx)(As,{className:E("max-w-(--pct-85)",n?"rounded-2xl rounded-br-sm":"rounded-2xl rounded-bl-sm",t)})]})}a(xp,"ChatBubbleSkeleton");function O$(){return(0,s.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"issue-chat-skeleton",children:[(0,s.jsx)(xp,{side:"agent",className:"h-16 w-3/4"}),(0,s.jsx)(xp,{side:"human",className:"h-9 w-1/2"}),(0,s.jsx)(xp,{side:"agent",className:"h-24 w-4/5"}),(0,s.jsx)(xp,{side:"human",className:"h-8 w-2/5"})]})}a(O$,"IssueChatSkeleton");function Wk(e=!1){const{enabled:t,loaded:n}=gq(),{enabled:r,loaded:i}=ef(),{enabled:o,loaded:l}=Bi(),c=r||o,d=t&&!e&&!o,m=!d;return{coordinatorWorkspaceEnabled:o,classicTaskInterfaceEnabled:d,taskChatShellEnabled:m,streamlinedTaskDetailEnabled:c&&m,streamlinedUiEnabled:c,loaded:n&&i&&l}}a(Wk,"useTaskDetailInterfaceMode");function uv({headerSeed:e,titleEditor:t}){const n=e?.identifier??e?.id.slice(0,8)??null,{taskChatShellEnabled:r,streamlinedUiEnabled:i,coordinatorWorkspaceEnabled:o,loaded:l}=Wk(),{isMobile:c}=Qh();return t?(0,s.jsxs)("div",{className:"max-w-3xl space-y-6",children:[(0,s.jsx)("div",{"data-testid":"issue-detail-header",children:t}),(0,s.jsx)("div",{role:"status","aria-label":"Loading conversation",className:"flex items-center justify-center",children:(0,s.jsx)(As,{"aria-hidden":"true",className:"h-4 w-24"})})]}):l?r?(0,s.jsx)("div",{"data-task-chat-shell":"",className:"flex h-full min-h-0 w-full flex-1 flex-col",children:(0,s.jsx)(qE,{mobile:c,streamlined:i,coordinator:o})}):(0,s.jsxs)("div",{className:"max-w-3xl space-y-6",children:[(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(As,{className:"h-3 w-40"}),(0,s.jsx)("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ti,{...Ma(e)}),!1,n?(0,s.jsx)("span",{className:"text-sm font-mono text-muted-foreground shrink-0",children:n}):null,e.originKind==="routine_execution"&&e.originId?(0,s.jsxs)($t,{variant:"outline",className:"border-violet-500/30 bg-violet-500/10 text-(length:--text-nano) text-violet-600 dark:text-violet-400",title:`Routine execution from routine ${e.originId}`,children:[(0,s.jsx)(vl,{className:"h-3 w-3"}),"Routine"]}):null,e.projectId?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground rounded px-1 -mx-1 py-0.5 min-w-0",children:[(0,s.jsx)(qu,{size:"xs"}),(0,s.jsx)("span",{className:"truncate",children:e.projectName??e.projectId.slice(0,8)})]}):(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground opacity-50 px-1 -mx-1 py-0.5",children:[(0,s.jsx)(qu,{size:"xs"}),"No project"]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(As,{className:"h-6 w-6"}),(0,s.jsx)(As,{className:"h-6 w-6"}),(0,s.jsx)(As,{className:"h-4 w-20"}),(0,s.jsx)(As,{className:"h-4 w-28"})]})}),e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("h2",{className:"text-xl font-bold",children:e.title}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(As,{className:"h-4 w-full max-w-xl"}),(0,s.jsx)(As,{className:"h-4 w-(--pct-72)"})]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(As,{className:"h-8 w-(--sz-calc-37)"}),(0,s.jsx)(As,{className:"h-16 w-full"})]})]}),(0,s.jsx)(As,{className:"h-28 w-full rounded-lg border border-border"}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(As,{className:"h-8 w-20"}),(0,s.jsx)(As,{className:"h-8 w-20"})]}),(0,s.jsx)(O$,{})]}),(0,s.jsx)(Uk,{titleWidth:"w-24",rows:3})]}):(0,s.jsx)("div",{"data-testid":"task-detail-presentation-loading",role:"status","aria-label":"Loading conversation",className:"flex h-full min-h-0 w-full flex-1 items-center justify-center",children:(0,s.jsx)(As,{"aria-hidden":"true",className:"h-4 w-24"})})}a(uv,"IssueDetailLoadingState");function Kde({backHref:e,preferHistoryBack:t,issueId:n,issueHidden:r,onArchive:i,archivePending:o,onCopy:l,onProperties:c,onHide:d}){const m=Jh(),[h,f]=(0,u.useState)(!1);return(0,s.jsxs)("div",{className:"flex items-center w-full",children:[(0,s.jsx)(W,{variant:"ghost",size:"icon-sm",onClick:a(()=>{t&&window.history.length>1?m(-1):m(e)},"onClick"),"aria-label":"Back to inbox",children:(0,s.jsx)(s1,{className:"h-5 w-5"})}),(0,s.jsxs)("div",{className:"ml-auto flex items-center gap-0.5",children:[n&&!r&&(0,s.jsx)(W,{variant:"ghost",size:"icon-sm",onClick:i,disabled:o,"aria-label":"Archive from inbox",children:(0,s.jsx)(Lu,{className:"h-5 w-5"})}),(0,s.jsxs)(Da,{open:h,onOpenChange:f,children:[(0,s.jsx)(La,{asChild:!0,children:(0,s.jsx)(W,{variant:"ghost",size:"icon-sm","aria-label":"More actions",children:(0,s.jsx)(o6,{className:"h-5 w-5"})})}),(0,s.jsxs)(Oa,{className:"w-44 p-1",align:"end",children:[(0,s.jsxs)("button",{className:"flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",onClick:a(()=>{l(),f(!1)},"onClick"),children:[(0,s.jsx)(yr,{className:"h-3 w-3"}),"Copy as markdown"]}),(0,s.jsxs)("button",{className:"flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",onClick:a(()=>{c(),f(!1)},"onClick"),children:[(0,s.jsx)(Du,{className:"h-3 w-3"}),"Properties"]}),n&&(0,s.jsxs)("button",{className:"flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 text-destructive",onClick:a(()=>{d(),f(!1)},"onClick"),children:[(0,s.jsx)(Nh,{className:"h-3 w-3"}),"Hide this task"]})]})]})]})]})}a(Kde,"InboxMobileToolbar");(0,u.lazy)(()=>lq(()=>import("./DesignSandboxTaskThread-CMeCSQid.js"),__vite__mapDeps([0,1,2,3])));var Vde=(0,u.memo)(a(function({executionBlocked:t,interruption:n,retryPreparing:r,queryIssueId:i,hasLiveConnection:o,browsers:l,onOpenBrowser:c,onOpenSkill:d,issueId:m,companyId:h,projectId:f,issueWorkMode:p,issueStatus:g,issueAssigneeAgentId:b,executionRunId:y,blockedBy:x,liveIssueIds:v,blockerAttention:k,stalledDependencies:w,successfulRunHandoff:j,scheduledRetry:_,recoveryAction:I,onResolveRecoveryAction:T,onReissueIsolatedRecoveryAction:F,reissueIsolatedRecoveryActionPending:O,onReconcileForwardRecoveryAction:z,onBreakGlassOverrideRecoveryAction:q,onQuarantineRestoreRecoveryAction:A,quarantineRestoreRecoveryActionPending:H,canBreakGlassRecoveryAction:B,reconcileRecoveryActionPending:C,canFalsePositiveRecoveryAction:S,legacyRecoverySourceIssue:L,comments:M,commentsInitialLoading:R=!1,historyExpanded:V=!0,onExpandHistory:J,hasEarlierMessages:Q=!1,initialHistoryPending:Z=!1,initialMetadataPending:P=!1,initialHistoryError:te=!1,onRetryInitialHistory:ne,locallyQueuedCommentRunIds:ge,interactions:K,documents:ee,createdTasks:ce,workProducts:ie,attachments:ke,hasOlderComments:_e,commentsLoadingOlder:je,commentsOlderError:ae=!1,onLoadOlderComments:de,onRefreshLatestComments:Se,onWorkModeChange:De,composerRef:nt,composerAccessory:Re,threadHeader:ye,issueBrief:Ne,footer:xe,feedbackVotes:Pe,feedbackDataSharingPreference:Ee,feedbackTermsUrl:jt,agentMap:oe,currentUserId:re,userLabelMap:le,userProfileMap:mt,draftKey:Pt,reassignOptions:Nt,currentAssigneeValue:Dt,assigneeAdapterOverrides:Wt,suggestedAssigneeValue:Zt,mentions:es,conversationMode:Ke,composerPause:ps,composerDisabledReason:an,composerHint:vs,queuedCommentReason:ms,onVote:Rs,onAdd:ts,onImageUpload:Ds,onAttachImage:fn,onInterruptQueued:ht,onRemoveCommentFromCache:Ls,onDeleteComment:An,onPauseWorkRun:ws,onStopResponse:Kt,stopResponsePending:zn,pauseWorkPending:Un,pauseWorkScope:Yn,runFinalizationActions:bn,onCancelQueued:gs,interruptingQueuedRunId:pn,pausingWorkRunId:rs,onImageClick:Jt,onAcceptInteraction:yn,onRejectInteraction:ss,onSubmitInteractionAnswers:Ae,onCancelInteraction:Qe,onSkipInteraction:ot,onDismissInteraction:fe,onSubmitInteractionVerdicts:Be,assigneeUserId:rt,onResumeFromBacklog:X,resumeFromBacklogPending:pe,onResumeAssignee:ze,resumeAssigneePending:yt,onTryAgainNoLiveExecutionPath:ct,tryAgainNoLiveExecutionPathPending:Ts,externalReferences:Wn,linkCaseReferences:Es}){const ns=(0,u.useContext)(qD),Ws=ns?K.find(ic):void 0,Is=ns?M.find(Ie=>Ie.authorType==="user"&&!Ie.deletedAt&&!Ie.createdByRunId):void 0,me=!!(ns?.animate&&!Is),st=me&&!Ws&&!ns?.runId,Ge=ns&&M.find(Ie=>!Ie.deletedAt&&(Ws?.sourceCommentId===Ie.id||Ie.authorType==="system"&&Ie.metadata?.onboardingWelcomeAgentId||Ie.authorType==="agent"&&(st||ns.runId!=null&&Ie.createdByRunId===ns.runId))),at=Ge?Ge.createdByRunId??ns?.runId:ns?.runId,$=me&&Ge&&ns?{phase:"welcome",commentId:Ge.id,onComplete:ns.completeAnimation}:ns?.revealingChoices&&!Is?{phase:"choices",onComplete:ns.completeChoices}:void 0,xt=(0,u.useMemo)(()=>K.filter(Ie=>!ic(Ie)||Ie.status!=="pending"||!me&&!Is),[K,me,Is]),{classicTaskInterfaceEnabled:bt,streamlinedTaskDetailEnabled:tn}=Wk(!!Ke),wr=bt?Ene:sae;QA();const Ze=ys(),ft=i??m,wt=qi(),qt=WA(),{pushToast:it}=lm(),{data:ks,isPending:Ye,isError:Fa,refetch:ai}=Te({queryKey:V?G.issues.activity(ft):hq(ft),queryFn:a(()=>V?io.forIssue(ft):kL(Ze,ft),"queryFn"),enabled:!!m,placeholderData:V?Ze.getQueryData([...G.issues.activity(ft),"recent"]):void 0}),kr=Mj(M),mr=Tj(oj(ft),kr,Ie=>yl(Ze,[...oj(ft),"batch",Ie],ft,Rt=>hL(Mj(Rt.recentComments.comments),Ie)?Rt.commentInputFacts:void 0,()=>io.inputFactsForIssue(ft,Ie)),!!m&&!V),{data:Kn,isFetched:Jn,isError:hr,refetch:fr}=Te({queryKey:G.issues.liveRuns(ft),queryFn:a(()=>yl(Ze,G.issues.liveRuns(ft),ft,Ie=>Ie.liveRuns,()=>qn.liveRunsForIssue(ft)),"queryFn"),enabled:!!m,refetchInterval:a(Ie=>$p(o,Ie.state,1e3),"refetchInterval"),placeholderData:Mr(ft)}),Os=Kn??[],vn=Os.length,pr=!!y||g==="in_progress",{data:Gr=null,isFetched:jr,isError:da,refetch:Fi}=Te({queryKey:G.issues.activeRun(ft),queryFn:a(()=>yl(Ze,G.issues.activeRun(ft),ft,Ie=>Ie.activeRun,()=>qn.activeRunForIssue(ft)),"queryFn"),enabled:pr,refetchInterval:a(Ie=>vn>0?!1:$p(o,Ie.state,1e3),"refetchInterval"),placeholderData:Mr(ft)}),qs=(0,u.useMemo)(()=>sG({status:g,executionRunId:y},Gr,Kn),[Gr,y,g,Kn]),Dr=!!(b&&oe.get(b)?.adapterType==="paperclip_runner"),Ia=qs??Os.find(Ie=>Ie.status==="running"||Ie.status==="queued")??null,rr=Jn&&(!pr||jr),Yr=!bt&&rr&&!!(Ia||b),{data:on}=Te({queryKey:G.issues.queuedComments(m),queryFn:a(async()=>WI(await $e.getQueuedComments(m),m),"queryFn"),enabled:Yr,refetchInterval:a(Ie=>Yr&&(Ia||Ie.state.data?.entries.length)?1e3:!1,"refetchInterval")}),[Vn,zs]=(0,u.useState)(()=>new Set),[Je,hs]=(0,u.useState)(()=>new Set),[Sa,Hn]=(0,u.useState)(()=>new Map),[Pn,za]=(0,u.useState)(()=>new Map),[Nr,Jr]=(0,u.useState)(null);(0,u.useEffect)(()=>{zs(new Set),hs(new Set)},[m]),(0,u.useEffect)(()=>{Hn(new Map),za(new Map),Jr(null)},[m]);const _a=vn>0||!!qs,ua=V?G.issues.runs(ft):qO(ft),{data:Xn,isPending:ln,isError:Qn,refetch:He}=Te({queryKey:ua,queryFn:a(()=>V?io.runsForIssue(ft):p4(Ze,ft,{conversationMode:Ke}),"queryFn"),enabled:!!m,refetchInterval:_a||g==="in_progress"?1e3:!1,placeholderData:V?Ze.getQueryData([...G.issues.runs(ft),"recent-window"])?.runs:void 0}),At=(0,u.useMemo)(()=>[...new Set([...M.flatMap(Ie=>[Ie.createdByRunId,Ie.derivedCreatedByRunId]),...(mr.data??[]).flatMap(Ie=>[Ie.runId,Ie.details?.targetRunId])].filter(Ie=>typeof Ie=="string"&&qg(Ie)))].sort(),[M,mr.data]),Mt=Tj([...G.issues.runs(ft),"comment-window"],At,Ie=>io.runsByIdsForIssue(ft,Ie),!!m&&!!Ke&&!V),Ss=(0,u.useMemo)(()=>[...new Map([...Array.isArray(Xn)?Xn:Xn?.runs??[],...Ke&&!V?Mt.data??[]:[]].map(Ie=>[Ie.runId,Ie])).values()],[Xn,Ke,V,Mt.data]),Gt=Array.isArray(Xn)?void 0:Xn?.earlierRun,Rn=!Array.isArray(Xn)&&Xn?.hasEarlierRuns===!0&&!(Gt?.status==="succeeded"&&p3(M,Gt.runId,Gt.resultJson)),sn=(0,u.useMemo)(()=>[...new Map([...ks??[],...mr.data??[]].map(Ie=>[Ie.id,Ie])).values()],[ks,mr.data]),Ks=Ss??[];(0,u.useEffect)(()=>{Xw({activity:!Ye,"linked-runs":!ln,runtime:rr})},[m,ft,Ye,ln,rr]);const Bs=ut({mutationFn:a(async Ie=>{const Rt=Ks.find(Ft=>Ft.runId===Ie);if(!Rt)throw new Error("Failed run is no longer available.");return $r.retryFailedRun(Rt.agentId,Rt.runId,h)},"mutationFn"),onSuccess:a(Ie=>{Ie.runId||it({title:"Retry queued",body:"The exact request will retry when this task is ready.",tone:"success"})},"onSuccess"),onSettled:a(()=>{Ze.invalidateQueries({queryKey:G.issues.runs(ft)}),Ze.invalidateQueries({queryKey:G.issues.liveRuns(ft)}),Ze.invalidateQueries({queryKey:G.issues.activeRun(ft)})},"onSettled"),onError:a((Ie,Rt)=>{const Ft=Ks.find(as=>as.runId===Rt);it(lG(Ie,Ft?oe.get(Ft.agentId):void 0)??{title:"Run retry failed",body:Ie instanceof Error?Ie.message:"Unable to retry run",tone:"error"})},"onError")}),gn=(0,u.useMemo)(()=>L$(qs,Os),[qs,Os]),Ca=gn?oe.get(gn.agentId):null,Dn=Ca?.adapterType==="paperclip_runner"&&Ca.adapterConfig.provider==="grok_bot",Ir=ut({mutationFn:a(Ie=>k4.stop(h,Ie.agentId,Ie.id),"mutationFn"),onSettled:a((Ie,Rt,Ft)=>Promise.all([Ze.invalidateQueries({queryKey:G.issues.detail(m)}),Ze.invalidateQueries({queryKey:G.issues.runs(m)}),Ze.invalidateQueries({queryKey:["grok-binding",h,Ft.agentId]})]),"onSettled")}),vt=(0,u.useMemo)(()=>{const Ie=new Set;for(const Rt of Os)Ie.add(Rt.id);return qs&&Ie.add(qs.id),Ie},[qs,Os]),ii=(0,u.useMemo)(()=>(vt.size===0?Ks:Ks.filter(Ie=>!vt.has(Ie.runId))).map(Ie=>({...Ie,adapterType:Ie.adapterType,hasStoredOutput:(Ie.logBytes??0)>0})),[vt,Ks]),Zn=(0,u.useMemo)(()=>{const Ie=gn?.startedAt??gn?.createdAt??null,Rt=new Map,Ft=new Set,as=new Map,Ct=new Map;for(const Le of Ks){if(as.set(Le.runId,Le.agentId),Le.status==="queued"||!Le.startedAt)continue;const pt=Array.isArray(Le.wakeCommentIds)?Le.wakeCommentIds.filter(lr=>typeof lr=="string"&&lr.length>0):[],is=typeof Le.wakeCommentId=="string"&&Le.wakeCommentId.length>0?Le.wakeCommentId:typeof Le.contextCommentId=="string"&&Le.contextCommentId.length>0?Le.contextCommentId:null,_s=Array.isArray(Le.firstTurnCommentIds)?Le.firstTurnCommentIds.filter(lr=>typeof lr=="string"&&lr.length>0):[],ds=[...new Set([...pt.length>0?pt:is?[is]:[],..._s])],Gn=Le.startedAt??Le.createdAt,Fs=new Date(Gn).getTime();ds.forEach((lr,Sr)=>{const Ot=Ct.get(lr),Hs=Ot?.queueIds??new Set;if(Le.wakeupRequestId&&Hs.add(Le.wakeupRequestId),Array.isArray(Le.queuedCommentSourceWakeIds))for(const Lr of Le.queuedCommentSourceWakeIds)Hs.add(Lr);Ot&&Ot.anchorMs<=Fs||Ct.set(lr,{runId:Le.runId,anchorAt:Gn,sequence:Sr,anchorMs:Fs,kind:"run_start",queueIds:Hs})})}for(const Le of[qs,...Os]){if(!Le||Le.status!=="running"||!Le.startedAt)continue;const pt=new Date(Le.startedAt).toISOString();for(const is of[Le.contextCommentId,Le.contextWakeCommentId]){if(!is)continue;const _s=Ct.get(is),ds=_s?.queueIds??new Set;if(Le.wakeupRequestId&&ds.add(Le.wakeupRequestId),Array.isArray(Le.queuedCommentSourceWakeIds))for(const Gn of Le.queuedCommentSourceWakeIds)ds.add(Gn);_s||Ct.set(is,{runId:Le.id,anchorAt:pt,sequence:0,anchorMs:new Date(pt).getTime(),kind:"run_start",queueIds:ds})}}const It=sn.filter(Le=>Le.action==="issue.queued_comment_steered").sort((Le,pt)=>new Date(Le.createdAt).getTime()-new Date(pt.createdAt).getTime()),cs=new Map;for(const Le of It){const pt=Le.details??{};if(pt.duplicate===!0)continue;const is=typeof pt.commentId=="string"?pt.commentId:null,_s=typeof pt.targetRunId=="string"?pt.targetRunId:null;if(!is||!_s)continue;const ds=Le.createdAt instanceof Date?Le.createdAt.toISOString():Le.createdAt,Gn=new Date(ds).getTime();if(!Number.isFinite(Gn))continue;const Fs=cs.get(_s)??0;cs.set(_s,Fs+1),Ct.set(is,{runId:_s,anchorAt:ds,sequence:Fs,anchorMs:Gn,kind:"steer",queueIds:Ct.get(is)?.queueIds??new Set})}const js=on?.targetRunId??null;if(js){const Le=new Map(M.map(pt=>[pt.id,pt.createdAt]));on?.firstTurnCommentIds?.forEach((pt,is)=>{const _s=Le.get(pt);if(Ct.has(pt)||!_s)return;const ds=new Date(_s).toISOString();Ct.set(pt,{runId:js,anchorAt:ds,sequence:is,anchorMs:new Date(ds).getTime(),kind:"run_start",queueIds:new Set(on.queueId?[on.queueId]:[])})})}for(const[Le,pt]of Sa)Ct.has(Le)||Ct.set(Le,{runId:pt.targetRunId,anchorAt:pt.anchorAt,sequence:pt.sequence,anchorMs:new Date(pt.anchorAt).getTime(),kind:"steer",queueIds:new Set});for(const Le of sn){if(Le.action!=="issue.comment_added"||!Le.runId)continue;const pt=Le.details??{},is=typeof pt.commentId=="string"?pt.commentId:null;if(!is||Rt.has(is))continue;const _s=typeof pt.interruptedRunId=="string"?pt.interruptedRunId:null;Rt.set(is,{runId:Le.runId,runAgentId:Le.agentId??as.get(Le.runId)??null,interruptedRunId:_s})}for(const Le of sn){if(Le.action!=="issue.comment_added")continue;const pt=Le.details??{},is=typeof pt.commentId=="string"?pt.commentId:null;is&&(pt.followUpRequested===!0||pt.resumeIntent===!0)&&Ft.add(is)}const ir=[...M],or=new Set(M.map(Le=>Le.id));for(const Le of[...Sa.values(),...Pn.values()])Le.comment&&!or.has(Le.comment.id)&&(ir.push(Le.comment),or.add(Le.comment.id));const oi=ir.map(Le=>{if(Le.authorType==="system"&&Ke&&Le.metadata?.onboardingWelcomeAgentId)return{...Le,authorType:"agent",authorAgentId:Le.metadata.onboardingWelcomeAgentId,runId:null};if(Le.metadata?.chatMessage)return{...Le,runId:null};const pt=Rt.get(Le.id),is=Le.authorType==="agent"&&Le.authorAgentId?Le.createdByRunId:null,_s=is?{runId:is,runAgentId:Le.authorAgentId,interruptedRunId:pt?.runId===is?pt.interruptedRunId:null}:pt,ds=Le.id===Ws?.sourceCommentId?void 0:Ct.get(Le.id),Gn=new Date(Le.createdAt).getTime(),Fs=ds?.kind==="run_start"?Ks.find(Zr=>Zr.runId===ds.runId):void 0,lr=Fs?new Date(Fs.startedAt??Fs.createdAt).getTime():NaN,Sr=!!(Fs?.contextIssueId===m&&Number.isFinite(lr)&&Number.isFinite(Gn)&&Ks.some(Zr=>{if(Zr.runId===Fs.runId||Zr.agentId!==Fs.agentId||Zr.contextIssueId!==m||!Zr.finishedAt)return!1;const Ui=new Date(Zr.startedAt??Zr.createdAt).getTime(),Tn=new Date(Zr.finishedAt).getTime();return Number.isFinite(Ui)&&Number.isFinite(Tn)&&Ui<=Gn&&Gn<=Tn&&Tn<=lr})),Ot={...Le,..._s??{},...ds?{consumedByRunId:ds.runId,consumedQueueIds:[...ds.queueIds],...ds.kind==="steer"?{steeredIntoRunId:ds.runId}:{},conversationAnchorAt:ds.anchorAt,conversationAnchorSequence:ds.sequence}:{}};(Ft.has(Le.id)||Sr)&&(Ot.followUpRequested=!0);const Hs=ge.get(Le.id)??Ot.queueTargetRunId??null;if(ds)return{...Ot,clientStatus:void 0,queueState:void 0,queueTargetRunId:null,queueReason:void 0};const Lr=jO(Ot,{queuedTargetRunId:Hs,targetRunIsLive:Hs?vt.has(Hs):!1,runningRunId:gn?.id??null});return Lr!==Ot?Lr:Hs?Ot:PD({comment:Ot,activeRunStartedAt:Ie,activeRunAgentId:gn?.agentId??null,activeRunCommentId:gn?.contextCommentId??null,activeRunWakeCommentId:gn?.contextWakeCommentId??null,runId:_s?.runId??Ot.runId??null,interruptedRunId:_s?.interruptedRunId??Ot.interruptedRunId??null})?{...Ot,queueState:"queued",queueTargetRunId:gn?.id??null,queueReason:ms}:Ot}),zi=new Map;for(const Le of sn){if(Le.action!=="issue.question_response_delivered")continue;const pt=Le.details??{},is=typeof pt.interactionId=="string"?pt.interactionId:null,_s=typeof pt.targetRunId=="string"?pt.targetRunId:null;!is||!_s||zi.has(is)||zi.set(is,{targetRunId:_s,deliveryMode:typeof pt.deliveryMode=="string"?pt.deliveryMode:null})}const vi=bt?[]:K.flatMap(Le=>{const pt=Le.kind==="ask_user_questions"&&Le.status==="answered",is=LC(Le)&&(Le.status==="accepted"||Le.status==="rejected");if(!pt&&!is||!Le.resolvedAt)return[];const _s=Le.resolvedAt instanceof Date?Le.resolvedAt:new Date(Le.resolvedAt);if(Number.isNaN(_s.getTime()))return[];const ds=pt?zi.get(Le.id)??null:null,Gn=Le.sourceRunId&&gn?.id===Le.sourceRunId&&gn.adapterType!=="paperclip_runner"?Le.sourceRunId:null,Fs=Le.kind==="ask_user_questions"?T6(Le):LC(Le)?$de(Le):"";return[{id:`interaction-response:${Le.id}`,companyId:Le.companyId,issueId:Le.issueId,authorType:Le.resolvedByAgentId?"agent":"user",authorAgentId:Le.resolvedByAgentId??null,authorUserId:Le.resolvedByUserId??null,createdByRunId:Le.resolvedByRunId??null,body:Fs,presentation:null,metadata:null,createdAt:_s,updatedAt:_s,consumedByRunId:ds?.targetRunId??null,...ds?.deliveryMode==="steered"?{steeredIntoRunId:ds.targetRunId}:{},conversationAnchorAt:_s,conversationAnchorSequence:0,...Gn?{queueState:"queued",queueTargetRunId:Gn,queueReason:ms}:{}}]});return[...oi,...vi]},[Ke,Ws?.sourceCommentId,on,M,bt,K,vt,Sa,Pn,ge,ms,sn,Ks,qs,Os,gn]),ar=(0,u.useMemo)(()=>XQ(on,Ks),[on,Ks]),xs=(0,u.useMemo)(()=>{if(!Yr)return null;const Ie=new Map,Rt=new Map;for(const It of Zn)It.consumedByRunId&&(Ie.set(It.id,It.consumedByRunId),Rt.set(It.id,It.consumedQueueIds??[]));const Ft=on?{...on,entries:on.entries.filter(It=>!Vn.has(It.comment.id)&&!Je.has(It.comment.id)&&!Rt.get(It.comment.id)?.includes(on.queueId??"")&&Ie.get(It.comment.id)!==on.targetRunId)}:null,as=Zn.flatMap(It=>{if(Vn.has(It.id)||Ie.has(It.id)||Je.has(It.id)||It.steeredIntoRunId)return[];const cs=ge.get(It.id)??("clientStatus"in It&&It.clientStatus==="queued"||It.queueState==="queued"?It.queueTargetRunId??null:null);return cs&&!vt.has(cs)&&!It.id.startsWith("optimistic-")?[]:cs?[{comment:It,targetRunId:cs}]:[]}),Ct=Ia?.adapterType==="paperclip_runner"||!Ia&&Dr?"paperclip_runner_v1":"legacy";return tG({issueId:m,authoritativeQueue:Ft,pendingComments:as,fallbackProtocol:Ct})},[on,Zn,Vn,Je,m,vt,Ia,Dr,ge,Yr]),wn=(0,u.useMemo)(()=>{if(!xs)return null;const Ie=xs.entries.filter(Rt=>!ar.has(Rt.comment.id)).map((Rt,Ft)=>({...Rt,position:Ft}));return Ie.length?{...xs,entries:Ie}:null},[xs,ar]),Ua=(0,u.useMemo)(()=>[...Zn,...(on?.entries??[]).filter(Ie=>ar.has(Ie.comment.id)&&!Zn.some(Rt=>Rt.id===Ie.comment.id)).map(Ie=>Ie.comment)].flatMap(Ie=>Je.has(Ie.id)?[]:!Vn.has(Ie.id)&&!ar.has(Ie.id)?[Ie]:[{...Ie,...!Ie.consumedByRunId&&Pn.has(Ie.id)?{conversationAnchorAt:Pn.get(Ie.id).anchorAt,conversationAnchorSequence:Pn.get(Ie.id).sequence}:{},clientStatus:void 0,queueState:void 0,queueTargetRunId:null,queueReason:void 0}]),[Zn,Vn,Je,Pn,on,ar]),nn=(0,u.useCallback)(Ie=>{const Rt=WI(Ie,m);return Ze.setQueryData(G.issues.queuedComments(m),Rt),Rt},[m,Ze]),Vs=(0,u.useCallback)(async Ie=>{throw Ie instanceof mn&&Ie.status===409&&await Ze.invalidateQueries({queryKey:G.issues.queuedComments(m)}),Ie},[m,Ze]),kn=(0,u.useCallback)(async(Ie,Rt,Ft)=>{const as=xs?.queueId;if(!as)throw new Error("The queued message is awaiting server acknowledgement.");try{nn(await $e.editQueuedComment(m,Ie,{body:Rt,queueId:as,revision:Ft})),await Ze.invalidateQueries({queryKey:G.issues.comments(m)})}catch(Ct){await Vs(Ct)}},[xs?.queueId,m,Ze,Vs,nn]),rn=(0,u.useCallback)(async(Ie,Rt)=>{const Ft=xs?.queueId;if(!Ft)throw new Error("The queued messages are awaiting server acknowledgement.");try{const as=new Set(on?.firstTurnCommentIds??[]),Ct=a(ir=>ar.has(ir)||as.has(ir),"hidden"),It=on?.queueId===Ft?on.entries:xs.entries;let cs=0;const js=It.map(ir=>Ct(ir.comment.id)?ir.comment.id:Ie[cs++]);nn(await $e.reorderQueuedComments(m,{orderedCommentIds:js,queueId:Ft,revision:Rt}))}catch(as){await Vs(as)}},[on,xs,ar,m,Vs,nn]),er=(0,u.useCallback)(async(Ie,Rt)=>{const Ft=xs?.queueId,as=xs?.targetRunId;if(!Ft||!as)throw new Error("The queued message no longer has an active run target.");const Ct=new Date().toISOString();Hn(It=>{const cs=new Map(It),js=[...It.values()].filter(ir=>ir.targetRunId===as).length;return cs.set(Ie,{targetRunId:as,anchorAt:Ct,sequence:js,comment:xs?.entries.find(ir=>ir.comment.id===Ie)?.comment}),cs}),zs(It=>new Set(It).add(Ie));try{const It=await $e.steerQueuedComment(m,Ie,{queueId:Ft,targetRunId:as,revision:Rt});nn(It),Promise.all([Ze.invalidateQueries({queryKey:G.issues.comments(m)}),Ze.invalidateQueries({queryKey:G.issues.activity(ft)})])}catch(It){zs(cs=>{const js=new Set(cs);return js.delete(Ie),js}),Hn(cs=>{const js=new Map(cs);return js.delete(Ie),js}),await Vs(It)}},[xs,m,ft,Ze,Vs,nn]),Bt=(0,u.useCallback)(async Ie=>{const Rt=xs?.targetRunId===Ie?xs.entries.map(Ct=>Ct.comment):Zn.filter(Ct=>Ct.queueState==="queued"&&Ct.queueTargetRunId===Ie),Ft=Rt.map(Ct=>Ct.id),as=new Date().toISOString();Jr(null),zs(Ct=>new Set([...Ct,...Ft])),za(Ct=>{const It=new Map(Ct);return Rt.forEach((cs,js)=>{It.set(cs.id,{anchorAt:as,sequence:js,comment:cs})}),It});try{const Ct=await ht(Ie);if(Ct?.state==="deferred"&&!Qw(Ct)){const It=new Set(Ct.entries.map(cs=>cs.comment.id));zs(cs=>new Set([...cs].filter(js=>!It.has(js)))),za(cs=>new Map([...cs].filter(([js])=>!It.has(js)))),nn(Ct),bt&&Jr(Ct.executionWait?.message??"Messages are still queued.")}return Ct}catch(Ct){if(zs(It=>{const cs=new Set(It);for(const js of Ft)cs.delete(js);return cs}),za(It=>{const cs=new Map(It);for(const js of Ft)cs.delete(js);return cs}),bt){Jr("Couldn’t interrupt. Message is still queued.");return}throw await Vs(Ct),Ct}},[xs,Zn,ht,nn,Vs,bt]),Ml=(0,u.useCallback)(async(Ie,Rt)=>{const Ft=xs?.queueId;try{Ft?nn(await $e.discardQueuedComment(m,Ie,{queueId:Ft,revision:Rt})):await $e.cancelComment(m,Ie),hs(as=>new Set(as).add(Ie)),Ft||Ze.invalidateQueries({queryKey:G.issues.queuedComments(m)}),await Ls(Ie),await Ze.invalidateQueries({queryKey:G.issues.comments(m)})}catch(as){const Ct=as instanceof mn&&typeof as.body=="object"&&as.body!==null?as.body:null,It=Ct&&typeof Ct.details=="object"&&Ct.details!==null?Ct.details:null;(typeof It?.code=="string"?It.code:typeof Ct?.code=="string"?Ct.code:null)==="queued_comment_already_dispatching"&&it({title:"Message is already being sent",body:"The continuation started before the discard was confirmed, so Microvac could not unsend it.",tone:"error",ttlMs:15e3,dedupeKey:`queued-comment-already-dispatching:${m}:${Ie}`}),await Vs(as)}},[xs?.queueId,m,Ls,it,Ze,Vs,nn]),Xr=(0,u.useMemo)(()=>JQ(sn),[sn]),ma=(0,u.useMemo)(()=>YQ(sn),[sn]),Aa=Ke?{hasMore:!!_e,loading:je,error:ae,load:de}:void 0,ha=!Ke&&_e?(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(W,{type:"button",variant:"outline",size:"sm",disabled:je,onClick:de,children:je?"Loading earlier comments...":"Load earlier comments"})}):null;return(0,s.jsxs)("div",{className:bt?"space-y-3":"flex min-h-0 flex-1 flex-col",children:[bt?ha:null,bt&&R&&Zn.length===0&&K.length===0?(0,s.jsx)(O$,{}):(0,s.jsx)(lE.Provider,{value:{...dE(wt),restore:qt==="POP"},children:(0,s.jsx)(XK,{companyId:h,issueId:m,children:(0,s.jsx)(z2.Provider,{value:Ke?null:oe,children:(0,u.createElement)(wr,{...bt?{}:{compactHistory:!V,onExpandHistory:Ke?void 0:J,scrollingHistory:Aa,historyControl:Ke?null:!V&&(Q||Rn)?(0,s.jsx)(W,{type:"button",variant:"ghost",size:"sm",onClick:J,children:"More messages"}):null},executionBlocked:t,interruption:n,retryPreparing:r,key:Ke?Pt:m,...bt?{}:{creationActivity:sn,createdTasks:ce},onOpenSkill:d,browsers:l,onOpenBrowser:c,hasOlderComments:_e,initialHistoryPending:!!m&&(Z||R||P||Ye||ln||Ke&&At.length>0&&Mt.isPending||mr.isLoading||!rr),initialHistoryError:te||Fa||!V&&mr.isError||Qn||Ke&&Mt.isError||hr||pr&&da,onRetryInitialHistory:a(()=>{ne?.(),ai(),!V&&kr.length&&mr.refetch(),He(),Ke&&At.length&&Mt.refetch(),fr(),pr&&Fi()},"onRetryInitialHistory"),composerRef:nt,composerAccessory:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(hQ,{}),Re]}),threadHeader:!bt&&(ye||ha)?(0,s.jsxs)(s.Fragment,{children:[ye,ha]}):null,issueBrief:Ne,comments:Ua,interactions:xt,...$?{onboardingWelcomeAnimation:$}:{},documents:ee,workProducts:ie,attachments:ke,feedbackVotes:Pe,feedbackDataSharingPreference:Ee,feedbackTermsUrl:jt,linkedRuns:at?ii.filter(Ie=>Ie.runId!==at):ii,onRetryFailedRun:a(Ie=>Bs.mutateAsync(Ie).then(()=>{}),"onRetryFailedRun"),retryFailedRunId:Bs.isPending?Bs.variables:null,timelineEvents:Xr,workModeChanges:ma,liveRuns:at?Os.filter(Ie=>Ie.id!==at):Os,activeRun:at&&qs?.id===at?null:qs,issueId:m,blockedBy:x??[],liveIssueIds:v,blockerAttention:k,stalledDependencies:w,successfulRunHandoff:j,scheduledRetry:_,recoveryAction:QE(I?.cause)?null:I??null,onResolveRecoveryAction:T,onReissueIsolatedRecoveryAction:F,reissueIsolatedRecoveryActionPending:O,onReconcileForwardRecoveryAction:z,onBreakGlassOverrideRecoveryAction:q,onQuarantineRestoreRecoveryAction:A,quarantineRestoreRecoveryActionPending:H,canBreakGlassRecoveryAction:B,reconcileRecoveryActionPending:C,canFalsePositiveRecoveryAction:S,legacyRecoverySourceIssue:L??null,companyId:h,projectId:f,issueStatus:g,issueAssigneeAgentId:b,agentMap:oe,currentUserId:re,userLabelMap:le,userProfileMap:mt,draftKey:Pt,conversationMode:Ke,enableReassign:!Ke,reassignOptions:Nt,currentAssigneeValue:Dt,assigneeAdapterOverrides:Wt,suggestedAssigneeValue:Zt,mentions:es,composerPause:ps,composerDisabledReason:an,composerHint:vs,onVote:Rs,onAdd:ts,imageUploadHandler:Ds,onAttachImage:fn,onInterruptQueued:Bt,queuedCommentQueue:wn,onEditQueuedComment:kn,onReorderQueuedComments:rn,onSteerQueuedComment:er,onDiscardQueuedComment:Ml,onDeleteComment:An,onCancelQueued:gs,interruptingQueuedRunId:pn,stoppingRunId:Ir.isPending?Ir.variables.id:Un?rs??gn?.id??null:rs,onStopRun:Dn||ws?async Ie=>{const Rt=Os.find(as=>as.id===Ie)??(qs?.id===Ie?qs:null),Ft=Rt?oe.get(Rt.agentId):null;Rt&&Ft?.adapterType==="paperclip_runner"&&Ft.adapterConfig.provider==="grok_bot"?await Ir.mutateAsync(Rt).catch(()=>{}):ws&&await ws(Ie).catch(()=>{})}:void 0,stopRunLabel:Dn?"Stop Microvac work":"Pause work",stoppingRunLabel:Dn?"Stopping Microvac work…":"Pausing...",stopRunVariant:Dn?"stop":"pause",runFinalizationActions:bn,onAcceptInteraction:yn,onRejectInteraction:ss,onSubmitInteractionAnswers:a((Ie,Rt)=>Ae(Ie,Rt),"onSubmitInteractionAnswers"),onCancelInteraction:Qe,onSkipInteraction:ot,onDismissInteraction:fe,onSubmitInteractionVerdicts:Be,issueWorkMode:p,onWorkModeChange:De,stopPending:Dn?Ir.isPending:zn,onCancelRun:Dn&&gn?()=>Ir.mutateAsync(gn).then(()=>{}):gn&&Kt?()=>Kt(gn.id):void 0,onImageClick:Jt,onRefreshLatestComments:Se,assigneeUserId:rt,onResumeFromBacklog:X,resumeFromBacklogPending:pe,onResumeAssignee:ze,resumeAssigneePending:yt,onTryAgainNoLiveExecutionPath:ct,tryAgainNoLiveExecutionPathPending:Ts,footer:Dn||Ir.error||Nr?(0,s.jsxs)(s.Fragment,{children:[Dn&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Runs in Grok Bot · Usage not reported. Stop Microvac work revokes this session’s authority; remote execution may continue. Open the Grok Bot desktop app to inspect it."}),Ir.error&&(0,s.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:Ps(Ir.error).body}),Nr&&(0,s.jsx)("p",{role:"status",className:"text-sm text-destructive",children:Nr}),xe]}):xe,externalReferences:Wn,linkCaseReferences:Es})})})})]})},"IssueDetailChatTab"));function Hde({issue:e,issueId:t,companyId:n,issueStatus:r,childIssues:i,agentMap:o,hasLiveRuns:l,currentUserId:c,userProfileMap:d,pendingApprovalAction:m,onApprovalAction:h,handoffFocusSignal:f=0,externalReferences:p}){const{data:g,isLoading:b}=Te({queryKey:G.issues.activity(t),queryFn:a(()=>io.forIssue(t),"queryFn"),placeholderData:Mr(t)}),{data:y,isLoading:x}=Te({queryKey:G.issues.runs(t),queryFn:a(()=>io.runsForIssue(t),"queryFn"),placeholderData:Mr(t)}),{data:v}=Te({queryKey:G.issues.approvals(t),queryFn:a(()=>$e.listApprovals(t),"queryFn"),placeholderData:Mr(t)}),{data:k}=Te({queryKey:G.issues.document(t,Rb),queryFn:a(async()=>{try{return await $e.getDocument(t,Rb)}catch(O){if(O instanceof mn&&O.status===404)return null;throw O}},"queryFn"),placeholderData:Mr(t)}),{data:w}=Te({queryKey:G.issues.costSummary(t),queryFn:a(()=>$e.getCostSummary(t),"queryFn"),placeholderData:Mr(t)}),j=b&&g===void 0||x&&y===void 0,_=(0,u.useMemo)(()=>{let O=0,z=0,q=0,A=0,H=0,B=0,C=0,S=!1,L=!1;const M=Date.now();for(const R of y??[]){const V=dv(R.usageJson),J=dv(R.resultJson),Q=yb(V,"inputTokens","input_tokens"),Z=yb(V,"outputTokens","output_tokens"),P=yb(V,"cachedInputTokens","cached_input_tokens","cache_read_input_tokens"),te=WO(V,J);if(te>0&&(S=!0),Q+Z+P>0&&(L=!0),O+=Q,z+=Z,q+=P,A+=oq(V),H+=te,R.startedAt){const ne=new Date(R.startedAt).getTime(),ge=R.finishedAt?new Date(R.finishedAt).getTime():M;Number.isFinite(ne)&&Number.isFinite(ge)&&ge>=ne&&(B+=ge-ne,C+=1)}}return{input:O,output:z,cached:q,cost:H,totalTokens:A,hasCost:S,hasTokens:L,runtimeMs:B,runCount:C,hasRuntime:B>0}},[y]),I=(w?.inputTokens??0)+(w?.cachedInputTokens??0)+(w?.outputTokens??0),T=!!w&&(w.costCents>0||I>0||w.cachedInputTokens>0||w.runtimeMs>0||w.issueCount>1),F=y&&y.length>0||T;return j?(0,s.jsx)(Uk,{titleWidth:"w-20",rows:4}):(0,s.jsxs)(s.Fragment,{children:[F&&(0,s.jsxs)("div",{className:"mb-3 px-3 py-2 rounded-lg border border-border",children:[(0,s.jsx)("div",{className:"text-sm font-medium text-muted-foreground mb-1",children:"Cost Summary"}),!_.hasCost&&!_.hasTokens&&!T?(0,s.jsx)("div",{className:"text-xs text-muted-foreground",children:"No cost data yet."}):(0,s.jsxs)("div",{className:"space-y-1 text-xs text-muted-foreground tabular-nums",children:[(0,s.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,s.jsx)("span",{className:"font-medium text-foreground",children:"This task"}),_.hasCost?(0,s.jsxs)("span",{className:"font-medium text-foreground",children:["$",_.cost.toFixed(4)]}):null,_.hasTokens?(0,s.jsxs)("span",{children:["Tokens ",Ci(_.totalTokens),_.cached>0?` (in ${Ci(_.input)}, out ${Ci(_.output)}, cached ${Ci(_.cached)})`:` (in ${Ci(_.input)}, out ${Ci(_.output)})`]}):null,_.hasRuntime?(0,s.jsxs)("span",{children:["Runtime ",jb(_.runtimeMs),` (${_.runCount} run${_.runCount===1?"":"s"})`]}):null,!_.hasCost&&!_.hasTokens&&!_.hasRuntime?(0,s.jsx)("span",{children:"No direct cost data."}):null]}),T&&w?(0,s.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,s.jsxs)("span",{className:"font-medium text-foreground",children:["Including sub-tasks"," ",(w.costCents/100).toLocaleString(void 0,{style:"currency",currency:"USD",minimumFractionDigits:4,maximumFractionDigits:4})]}),(0,s.jsxs)("span",{children:["Tokens ",Ci(I),w.cachedInputTokens>0?` (in ${Ci(w.inputTokens)}, out ${Ci(w.outputTokens)}, cached ${Ci(w.cachedInputTokens)})`:` (in ${Ci(w.inputTokens)}, out ${Ci(w.outputTokens)})`]}),w.runCount>0?(0,s.jsxs)("span",{children:["Runtime ",jb(w.runtimeMs),` (${w.runCount} run${w.runCount===1?"":"s"})`]}):null,(0,s.jsxs)("span",{children:[w.issueCount," task",w.issueCount===1?"":"s"]})]}):null]})]}),(0,s.jsx)("div",{className:"mb-3",children:(0,s.jsx)(Gce,{issueId:t,companyId:n,issueStatus:r,childIssues:i,agentMap:o,hasLiveRuns:l,activityEvents:g??[],resolveUserLabel:a(O=>d.get(O)?.label??null,"resolveUserLabel"),renderActivityEvent:a(O=>{const z=SL(O.action),q=O.action==="issue.successful_run_handoff_required"||O.action==="issue.successful_run_handoff_escalated";return(0,s.jsxs)("div",{className:E("space-y-1.5 rounded-lg border px-3 py-2 text-xs",z.className),children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[q?(0,s.jsx)(ls,{className:E("h-3.5 w-3.5 shrink-0",z.iconClassName)}):null,(0,s.jsx)(Ude,{evt:O,agentMap:o,userProfileMap:d}),(0,s.jsx)("span",{children:jde(O.action,O.details,{agentMap:o,userProfileMap:d,currentUserId:c})}),(0,s.jsx)("span",{className:"ml-auto shrink-0",children:va(O.createdAt)})]}),(0,s.jsx)(lie,{event:O}),(0,s.jsx)(gie,{event:O,resolveAgentLabel:a(A=>o.get(A)?.name??null,"resolveAgentLabel"),resolveUserLabel:a(A=>d.get(A)?.label??null,"resolveUserLabel")}),(()=>{const A=kie(O.action,O.details,{actorLabel:O.agentId?o.get(O.agentId)?.name??null:null,responsibleUserName:O.responsibleUserId?d.get(O.responsibleUserId)?.label??null:null});return A?(0,s.jsx)(vie,{code:A.code,context:A.context}):null})()]})},"renderActivityEvent")})}),(0,s.jsx)(nae,{document:k,focusSignal:f,externalReferences:p}),v&&v.length>0&&(0,s.jsx)("div",{className:"mb-3 space-y-3",children:v.map(O=>(0,s.jsx)(dG,{approval:O,requesterAgent:O.requestedByAgentId?o.get(O.requestedByAgentId)??null:null,onApprove:a(()=>h(O.id,"approve"),"onApprove"),onReject:a(()=>h(O.id,"reject"),"onReject"),detailLink:`/approvals/${O.id}`,isPending:m?.approvalId===O.id,pendingAction:m?.approvalId===O.id?m.action:null},O.id))}),(0,s.jsx)(ose,{issueId:e.id,scheduledRetry:e.scheduledRetry??null})]})}a(Hde,"IssueDetailActivityTab");function Qde({tasksTab:e}){return(0,s.jsx)(q$,{tasksTab:e})}a(Qde,"IssueDetail");function q$({conversation:e,tasksTab:t}){const{issueId:n,companyPrefix:r}=CL(),i=e?e.issue?.id:n,o=!!e,l=!!e?.issue,[c,d]=(0,u.useState)(null);(0,u.useEffect)(()=>d(null),[i,r]);const[m,h]=(0,u.useState)("standard"),f=(0,u.useMemo)(()=>e?MQ(e.agent,m):void 0,[e?.agent,m]),p=(0,u.useRef)(null),{companies:g,selectedCompanyId:b}=zg(),{classicTaskInterfaceEnabled:y,taskChatShellEnabled:x,streamlinedTaskDetailEnabled:v,streamlinedUiEnabled:k,loaded:w,coordinatorWorkspaceEnabled:j}=Wk(o),_=(QA()||j)&&v,I=x?"mx-auto w-full max-w-(--tc-shell-max-w)":void 0,{openNewIssue:T}=JP(),{openPanel:F,closePanel:O,panelVisible:z,setPanelVisible:q,setPanelShowsArtifact:A,requestPanelMaximize:H,clearPanelMaximizeRequest:B}=$A(),{setBreadcrumbs:C,setBreadcrumbToolbar:S,setBreadcrumbPanelControl:L,setMobileToolbar:M}=mO(),R=ys(),V=Jh(),J=WA(),Q=qi(),{pushToast:Z}=lm(),{isMobile:P}=Qh(),[te,ne]=(0,u.useState)(!1),[ge,K]=(0,u.useState)(!1),[ee,ce]=(0,u.useState)(!1),[ie,ke]=(0,u.useState)(null),[_e,je]=(0,u.useState)(null),[ae,de]=(0,u.useState)(null),Se=(0,u.useCallback)(N=>{de(Y=>Y?.id===N?null:Y)},[]),[De,nt]=(0,u.useState)(null),[Re,ye]=(0,u.useState)(!1),[Ne,xe]=(0,u.useState)("chat"),Pe=x?"chat":Ne,[Ee,jt]=(0,u.useState)(0),[oe,re]=(0,u.useState)(null),[le,mt]=(0,u.useState)(null),[Pt,Nt]=(0,u.useState)(!1),[Dt,Wt]=(0,u.useState)(!1),[Zt,es]=(0,u.useState)(0),[Ke,ps]=(0,u.useState)(!1),[an,vs]=(0,u.useState)(null),[ms,Rs]=(0,u.useState)("resume"),[ts,Ds]=(0,u.useState)(!1),[fn,ht]=(0,u.useState)([]),[Ls,An]=(0,u.useState)(()=>new Map),[ws,Kt]=(0,u.useState)(0),zn=(0,u.useRef)(null),Un=(0,u.useRef)(null),Yn=(0,u.useRef)(new Map),[bn,gs]=(0,u.useState)(0),pn=(0,u.useRef)(void 0),rs=(0,u.useRef)(null),Jt=(0,u.useRef)(new Set),yn=(0,u.useRef)(new Map),ss=(0,u.useMemo)(()=>Sj(i,Q.state,Q.search),[i,Q.state,Q.search]),Ae=(0,u.useMemo)(()=>{const N=ss??Q.state;return!v||typeof N!="object"||N===null?N:{...N,issueDetailInboxQuickArchiveArmed:!1}},[Q.state,ss,v]),Qe=(0,u.useMemo)(()=>Sj(null,Q.state)?.issueDetailSource==="inbox",[Q.state]),ot=(0,u.useMemo)(()=>sx(Q.state)??sx(ss),[Q.state,ss]),fe=g.find(N=>N.issuePrefix===r?.toUpperCase())?.id??b,Be=i?[...G.issues.detail(i),"core"]:null;if(i&&Be&&!e&&(R.getQueryData(Be)===void 0||KO(R,Be))){const N=R.getQueryData(Be);iL(R,fe,i,[N?.id,N?.identifier])}const rt=Te({...hA(R,i),enabled:!!i}),{historyExpanded:X,expandHistory:pe,recent:ze,retainComment:yt,acknowledgedComments:ct}=mQ(i,!!(!e&&!rt.data?.conversationAgentId&&w&&y),rt.data,!!(e||rt.data?.conversationAgentId)),Ts=!!(e||rt.data?.conversationAgentId),Wn=Te({...RO(R,i,{placeholderIssue:ot?{id:ot.id,identifier:ot.identifier}:null}),enabled:!!i&&(rt.isFetched||!!R.getQueryData(G.issues.detail(i)))}),{data:Es,isLoading:ns,isPlaceholderData:Ws,error:Is,refetch:me}=Wn,st=Sn(Ws?{...Wn,data:void 0}:Wn),Ge=Sn(rt);(0,u.useEffect)(()=>{i&&X&&nG(R,i)},[i,X,R]);const at=[Is,rt.error].find(N=>N instanceof mn&&[401,403,404].includes(N.status)),$=at?void 0:Es??rt.data??e?.issue??f,xt=$?.id,bt=(0,u.useCallback)(N=>{xt&&d(Y=>N?xt:Y===xt?null:Y)},[xt]),tn=a1($??void 0),wr=a(async()=>{if(!e)return i;const N=await e.ensureIssue(),Y=p.current;return Y!==null&&Y!==N.workMode&&await $e.update(N.id,{workMode:Y}),p.current=null,N.id},"resolveWritableIssueId"),Ze=!Ws&&!(Is&&!Es&&!rt.data)&&$&&i&&($.id.toLowerCase()===i.toLowerCase()||$.identifier?.toLowerCase()===i.toLowerCase())?$:null,ft=Ze?Ze.id:null;(0,u.useEffect)(()=>{ft&&cq(R,{id:ft})},[R,ft]);const wt=Ze?g.find(N=>N.id===Ze.companyId):void 0,qt=!!(e||Ze&&i===(Ze.identifier??Ze.id)&&(!wt||r===wt.issuePrefix)&&!Ij(Q.search)),it=$?.companyId??b,ks=wA({companyId:it,issueId:$?.id??i,issueQueryRef:i??"pending",assigneeAgentId:$?.assigneeAgentId}),Ye=GP(e&&!e.issue?null:$?.id??null),Fa=(0,u.useMemo)(()=>!!($?.currentExecutionWorkspace&&YF($.currentExecutionWorkspace)),[$?.currentExecutionWorkspace]),{data:ai,isLoading:kr,isError:mr,isFetchingNextPage:Kn,hasNextPage:Jn,fetchNextPage:hr,refetch:fr}=Dg({queryKey:G.issues.comments(i),queryFn:a(({pageParam:N})=>$e.listComments(i,{order:"desc",limit:50,...N?{after:N}:{}}),"queryFn"),enabled:!!i&&X,initialPageParam:null,getNextPageParam:a(N=>wD(N,50),"getNextPageParam"),placeholderData:Mr(i??"pending")}),Os=uQ(i,Ts,ze.data?.oldestCommentId,ze.data?.comments??[]),vn=Q.hash.startsWith("#comment-")?Q.hash.slice(9):null,pr=vn&&qg(vn)?vn.trim():null,Gr=(0,u.useMemo)(()=>Bm(ze.data?.comments??[],Ts?Os.data?.pages.flatMap(N=>N.comments)??[]:iD(ai?.pages),ct),[Ts,Os.data?.pages,ai?.pages,ze.data?.comments,ct]),jr=Te({queryKey:[...G.issues.comments(i),"linked",pr],queryFn:a(({signal:N})=>$e.getComment($.id,pr,{signal:N}),"queryFn"),enabled:!!$&&!!pr&&!X&&!Gr.some(N=>N.id===pr)});(0,u.useEffect)(()=>{const N=jr.data;!N||!ze.data||R.setQueryData([...G.issues.comments(i),"recent"],Y=>!Y||Y.comments.some(se=>se.id===N.id)?Y:{...Y,comments:Bm([N],Y.comments)})},[i,jr.data,ze.data,R]);const da=(0,u.useMemo)(()=>Bm(jr.data?[jr.data]:[],Gr),[jr.data,Gr]),Fi=(0,u.useRef)(1/0);(0,u.useLayoutEffect)(()=>{Fi.current=performance.now(),oG()},[i]);const qs=aG();a4(qs!==null,qs,{enabled:!!i}),(0,u.useEffect)(()=>{qs!==null&&qs>=Fi.current&&e?.onReady?.()},[qs,e?.onReady]),(0,u.useEffect)(()=>{},[i]),(0,u.useEffect)(()=>{!$||!w||!qt||wy(ZE,e5)},[$?.id,w,qt]),(0,u.useEffect)(()=>{!y||!$||kr||wy(Gw,Yw)},[y,kr,$?.id]);const Dr=!!(pr&&!da.some(N=>N.id===pr)&&!(X?mr:jr.isError)&&(X?kr||Jn:jr.isPending)),Ia=(0,u.useMemo)(()=>X&&pD({activeDetailTab:Ne,hasOlderComments:Jn??!1,loadedCommentCount:da.length,initialPageLoading:kr,olderPageLoading:Kn,autoLoadLimit:Pde}),[da.length,kr,Kn,X,Ne,Jn]),{data:rr=[],isLoading:Yr,isError:on,refetch:Vn}=Te({queryKey:G.issues.interactions(i),queryFn:a(()=>yl(R,G.issues.interactions(i),i,N=>N.interactions,()=>$e.listInteractions(i)),"queryFn"),enabled:!!i,refetchInterval:a(N=>HR(N.state.data,2e4),"refetchInterval"),placeholderData:Mr(i??"pending")}),{data:zs,isLoading:Je,isError:hs,refetch:Sa}=Te({queryKey:G.issues.attachments(i),queryFn:a(()=>yl(R,G.issues.attachments(i),i,N=>N.attachments,()=>$e.listAttachments(i)),"queryFn"),enabled:!!i,placeholderData:Mr(i??"pending")}),{data:Hn,isLoading:Pn,isError:za,refetch:Nr}=Hw(i);(0,u.useEffect)(()=>{Xw({issue:!!Ze,comments:!kr,interactions:!Yr,attachments:!Je,"work-products":!Pn})},[i,Ze,kr,Yr,Je,Pn]);const{data:Jr=cv}=Te({queryKey:G.issues.liveRuns(i),queryFn:a(()=>yl(R,G.issues.liveRuns(i),i,N=>N.liveRuns,()=>qn.liveRunsForIssue(i)),"queryFn"),enabled:!!i,refetchInterval:a(N=>$p(ks,N.state,3e3),"refetchInterval"),select:qC,placeholderData:Mr(i??"pending")}),_a=Jr.count,{data:ua=cv}=Te({queryKey:G.issues.activeRun(i),queryFn:a(()=>qn.activeRunForIssue(i),"queryFn"),enabled:!!i&&(!!$?.executionRunId||$?.status==="in_progress"),refetchInterval:a(N=>_a>0?!1:$p(ks,N.state,3e3),"refetchInterval"),select:a(N=>qC(N?[N]:[]),"select"),placeholderData:Mr(i??"pending")}),Xn=ua.count>0,ln=$?XE($)&&Xn:Xn,Qn=_a>0||ln,He=Qn&&(_a===0||Jr.waitingOnly)&&(!ln||ua.waitingOnly),At=Jr.agentQueue??(ln?ua.agentQueue:null);(0,u.useEffect)(()=>{!Qn&&Ls.size>0&&An(new Map)},[Qn,Ls.size]);const Mt=(0,u.useMemo)(()=>BP(i,Q.state,Q.search)??{label:"Tasks",href:"/issues"},[i,Q.state,Q.search]),{data:Ss,isLoading:Gt,isError:Rn,refetch:sn}=Te({queryKey:$?.id&&it?G.issues.listByDescendantRoot(it,$.id):["issues","parent","pending"],queryFn:a(()=>$e.listAll(it,{descendantOf:$.id,includeBlockedBy:!0}),"queryFn"),enabled:!!it&&!!$?.id&&!$.id.startsWith("chat:"),placeholderData:Mr($?.id??"pending")}),Ks=Ss??Om,Bs=Te({queryKey:G.issues.listCreatedFromIssue(it??"pending",$?.id??"pending"),queryFn:a(()=>$e.listAll(it,{createdFromIssueId:$.id,includeRoutineExecutions:!0}),"queryFn"),enabled:!!it&&!!$?.id&&!$.id.startsWith("chat:")&&(x&&!e||v&&!t)}),{data:gn,isLoading:Ca,isError:Dn}=Te({queryKey:$?.parentId&&it?G.issues.listByParent(it,$.parentId):["issues","siblings","pending"],queryFn:a(()=>$e.list(it,{parentId:$.parentId,includeBlockedBy:!0}),"queryFn"),enabled:!!it&&!!$?.parentId}),Ir=gn??Om,vt=it?G.liveRuns(it):["live-runs","pending"],ii=bO({companyId:it,resourceKey:"live-runs",queryKey:vt,enabled:!!it,refetchInterval:!1,leaderOnly:!0}),{data:Zn,dataUpdatedAt:ar}=Te({queryKey:vt,queryFn:a(()=>qn.liveRunsForCompany(it),"queryFn"),enabled:ii.enabled,refetchInterval:ii.refetchInterval,placeholderData:Mr(it??"pending")});$P(ii,Zn,ar);const{data:xs}=Te({queryKey:G.agents.list(b),queryFn:a(()=>$r.list(b),"queryFn"),enabled:!!b}),{data:wn}=Te({queryKey:G.access.companyUserDirectory(b),queryFn:a(()=>Eo.listUserDirectory(b),"queryFn"),enabled:!!b}),Ua=cde(),{data:nn=Om}=Te({queryKey:it?G.issues.mentionPool(it):["issues","mention-pool","pending"],queryFn:a(()=>$e.list(it,{limit:100,sortField:"updated",sortDir:"desc"}),"queryFn"),enabled:!!it&&Ua,staleTime:6e4,placeholderData:Mr(it??"pending")}),{data:Vs,isFetched:kn,dataUpdatedAt:rn}=Te({queryKey:G.auth.session,queryFn:a(()=>Ug.getSession(),"queryFn")}),{data:er=Ede}=Te({...Jg(b),enabled:!!b}),Bt=Vs?.user?.id??Vs?.session?.userId??null,Ml=(0,u.useRef)(null);(0,u.useEffect)(()=>{if(!(k||j)||!Ze||!kn||e||Ze.conversationAgentId||Ze.hiddenAt)return;const N=`${Ze.companyId}:${Bt}:${Ze.id}`;Sf(Ze,Bt,Ml.current===N?void 0:Date.now()),Ml.current=N},[Ze,Bt,kn,k,j,e]);const{data:Xr}=Te({queryKey:G.access.currentBoardAccess,queryFn:a(()=>Eo.getCurrentBoardAccess(),"queryFn"),enabled:!!Vs?.user?.id}),ma=!!(b&&Xr?.companyIds?.includes(b)),Aa=Kw(b,Xr),ha=UE(b,Xr),[Ie,Rt]=(0,u.useState)(!0),Ft=Ww(b,Xr),{data:as}=Te({queryKey:G.issues.feedbackVotes(i),queryFn:a(()=>$e.listFeedbackVotes(i),"queryFn"),enabled:!!i&&!!Bt}),{data:Ct}=Te({queryKey:G.instance.generalSettings,queryFn:a(()=>hc.getGeneral(),"queryFn"),enabled:!!i}),{data:It}=Te({queryKey:G.instance.experimentalSettings,queryFn:a(()=>hc.getExperimental(),"queryFn"),enabled:!!i}),cs=It?.enableCases===!0,js=Ct?.feedbackDataSharingPreference??"prompt",ir=It?.enableIssuePlanDecompositions===!0,or=It?.enableExperimentalFileViewer===!0,{orderedProjects:oi}=l1({projects:er,companyId:b,userId:Bt}),{slots:zi}=DA({slotTypes:["detailTab"],entityType:"issue",companyId:it,enabled:!!it}),vi=(0,u.useMemo)(()=>zi.map(N=>({value:`plugin:${N.pluginKey}:${N.id}`,label:N.displayName,slot:N})),[zi]),Le=vi.find(N=>N.value===Ne)??null,{data:pt,isFetching:is,error:_s,refetch:ds}=Te({queryKey:["issues","tree-control-preview",i??"pending",ms],queryFn:a(()=>$e.previewTreeControl(i,{mode:ms,releasePolicy:{strategy:"manual"}}),"queryFn"),enabled:Ke&&!!i&&ma,staleTime:0}),{data:Gn,error:Fs}=Te({queryKey:["issues","tree-control-state",i??"pending"],queryFn:a(()=>$e.getTreeControlState(i),"queryFn"),enabled:!!i}),{data:lr=[]}=Te({queryKey:["issues","tree-holds",i??"pending","active-pause-with-members"],queryFn:a(()=>$e.listTreeHolds(i,{status:"active",mode:"pause",includeMembers:!0}),"queryFn"),enabled:!!i&&Gn?.activePauseHold?.isRoot===!0}),{data:Sr=[]}=Te({queryKey:["issues","tree-holds",i??"pending","active-cancel"],queryFn:a(()=>$e.listTreeHolds(i,{status:"active",mode:"cancel"}),"queryFn"),enabled:!!i&&ma}),Ot=(0,u.useMemo)(()=>{const N=new Map;for(const Y of xs??[])N.set(Y.id,Y);return N},[xs]),Hs=(0,u.useMemo)(()=>qA(wn?.users),[wn?.users]),Lr=(0,u.useMemo)(()=>PA(wn?.users),[wn?.users]),Zr=BE($,Bt,Xr),Ui=(0,u.useMemo)(()=>{if(!$)return[];const N=[],Y=new Set,se=a((Fe,Xe)=>{if(!Fe||Y.has(`user:${Fe}`))return;Y.add(`user:${Fe}`);const St=Hs.get(Fe);N.push({id:`user:${Fe}`,displayName:St?.label??Fe.slice(0,5),roleLabel:Xe,avatarUrl:St?.image??null})},"pushUser"),ve=a((Fe,Xe)=>{if(!Fe||Y.has(`agent:${Fe}`))return;Y.add(`agent:${Fe}`);const St=Ot.get(Fe);N.push({id:`agent:${Fe}`,displayName:St?.name??Fe.slice(0,8),roleLabel:Xe})},"pushAgent");return se($.responsibleUserId,"Owner"),ve($.assigneeAgentId,"Assignee"),se($.assigneeUserId,"Assignee"),N},[$,Hs,Ot]),Tn=(0,u.useMemo)(()=>JO({agents:xs,projects:oi,members:wn?.users,issues:nn}),[xs,wn?.users,oi,nn]),jn=(0,u.useMemo)(()=>$?.projectId?oi.find(N=>N.id===$.projectId)??$.project??null:null,[$?.project,$?.projectId,oi]),Ht=(0,u.useMemo)(()=>[...$?.id?MO($.id,Ks):Ks].sort((N,Y)=>new Date(N.createdAt).getTime()-new Date(Y.createdAt).getTime()),[$?.id,Ks]),Vo=(0,u.useMemo)(()=>[...Ht.filter(N=>N.parentId===$?.id),...Bs.data??Om],[Ht,Bs.data,$?.id]),Wi=(0,u.useMemo)(()=>{if(t)return t;if(!v)return;const N=Bs.data??Om,Y=Bs.isError||Rn;return{count:new Set([...$?.createdFrom?[$.createdFrom.issue]:[],...$?.ancestors??[],...Ht,...N].map(se=>se.id)).size,hasError:Y,content:(0,s.jsx)(WQ,{ancestors:$?.ancestors,createdFrom:$?.createdFrom,issueLinkState:ss??Q.state,subtasks:Ht,createdTasks:N,projects:er,isLoading:Bs.isLoading||Gt,hasError:Y,onRetry:a(()=>{Bs.refetch(),sn()},"onRetry")})}},[t,$?.ancestors,$?.createdFrom,ss,Q.state,v,Ht,Gt,Rn,sn,er,Bs.data,Bs.isError,Bs.isLoading,Bs.refetch]),Wa=(0,u.useMemo)(()=>lO(Zn,$?[$,...Ht]:Ht),[Ht,Zn,$]),$l=(0,u.useMemo)(()=>Nde($??null,Ht),[Ht,$]),ea=(0,u.useMemo)(()=>$??null,[$?.id,$l]),Ki=(0,u.useMemo)(()=>Ht,[$l]),Ka=x&&$?.originKind==="onboarding_first_task",Ho=x&&(Ka||$?.workMode==="planning"),Qo=rr.some(N=>N.status==="pending"&&N.kind==="request_confirmation"&&N.payload.target?.type==="issue_document"&&N.payload.target.key==="plan"),{data:Yt}=pf(Ho||Qo?$?.id:null),Pl=rr.some(N=>N.status==="pending"&&!_6(N)&&!j3(N,Yt)),[xo,Lc]=(0,u.useState)(null),jm=xo!==null&&xo===$?.id,Ln=Ho&&kle({deferredPlanAvailable:!!Yt,panelBeforePlanOverride:jm}),Or=(0,u.useCallback)(()=>{Ln&&$?.id&&Lc($.id),q(!0)},[$?.id,q,Ln]),Dl=(0,u.useCallback)(()=>je(null),[]),Vi=(0,u.useCallback)((N,Y)=>{$?.id&&(je({issueId:$.id,id:N,title:Y,requestId:Date.now()}),Or(),P&&ce(!0))},[$?.id,Or,P]),Oc=(0,u.useRef)(null);(0,u.useEffect)(()=>{if(!j||!$?.id)return;const N=new URLSearchParams(Q.hash.split("&").slice(1).join("&")).get("attachment")??new URLSearchParams(Q.search).get("attachmentId");if(!N){Oc.current=null;return}const Y=`${$.id}:${Q.key}:${N}`;if(Oc.current===Y)return;const se=zs?.find(ve=>ve.id===N);se&&(Oc.current=Y,Vi(se.id,se.originalFilename??"Attachment"))},[j,$?.id,Q.hash,Q.search,Q.key,zs,Vi]),(0,u.useEffect)(()=>{if(!$?.id)return;const N=Vu(Q.hash);if(!N||!N.startsWith("interaction-")&&!N.startsWith("decision-")||!j&&!N.startsWith("decision-"))return;const Y=a(()=>{const Fe=document.getElementById(N);return Fe?(Fe.tabIndex=-1,Fe.scrollIntoView({block:"center",behavior:"instant"}),Fe.focus({preventScroll:!0}),!0):!1},"focusDecision");if(Y())return;const se=new MutationObserver(()=>{Y()&&se.disconnect()});se.observe(document.getElementById("main-content")??document.body,{subtree:!0,childList:!0});const ve=window.setTimeout(()=>se.disconnect(),1e4);return()=>{se.disconnect(),window.clearTimeout(ve)}},[j,$?.id,Q.hash,Q.key]);const cr=j?`coordinator:${Bt??"anonymous"}`:Bt??"anonymous",{panels:Va,isLoading:qc}=yQ($,x),Kd=(0,u.useRef)(new Set),Ll=(0,u.useRef)(new Set),wi=(0,u.useRef)(new Set);(0,u.useEffect)(()=>{for(const N of Va){if(!N.autoOpen||!N.runId)continue;const Y=FE(N,cr,$);Kd.current.has(Y)||(Kd.current.add(Y),!wi.current.has(Y)&&(Or(),P&&ce(!0)))}},[Va,cr,$?.companyId,$?.id,Or,P]);const Ol=zE($?.id,$?.companyId),{openBrowserId:Go,openBrowser:Vd,acknowledgeBrowserOpened:Yo}=wQ(Bt??"anonymous",$?.id,Ol.data);(0,u.useEffect)(()=>{Go&&(Or(),P&&ce(!0))},[Go,Or,P]);const Bc=(0,u.useCallback)((N,Y)=>{const se=jle({panelBeforePlanOverrideIssueId:xo},{id:N,name:Y},$?.id??null,Ln);de(se.skill),Lc(se.panelBeforePlanOverrideIssueId),q(!0),P&&ce(!0)},[P,$?.id,xo,q,Ln]),Hd=(0,u.useCallback)(()=>{$?.id&&ke(N=>({issueId:$.id,requestId:(N?.requestId??0)+1}))},[$?.id]),li=(0,u.useCallback)(N=>{ke(Y=>Y?.requestId===N?{...Y,handled:!0}:Y)},[]);Qle({issueId:x?$?.id:void 0,attachments:zs,workProducts:Hn,documents:$?.documentSummaries,onArrival:Hd});const tr=(0,u.useCallback)(()=>{if(P){ce(N=>!N);return}if(!z||Ln){Or();return}q(!1)},[P,Or,z,q,Ln]),fa=S4(Gt,Ht.length),Jo=(0,u.useMemo)(()=>$&&!Gt&&!Ca&&!Dn?Aq($,Ir,Ht):null,[Ht,Gt,$,Ir,Dn,Ca]),ki=(0,u.useCallback)(()=>{$&&T(tx($,Bt))},[Bt,$,T]),Fc=(0,u.useMemo)(()=>{const N=[];N.push(...c1(wn?.users,{excludeUserIds:[Bt]}));const Y=[...xs??[]].filter(Eb).sort((se,ve)=>se.name.localeCompare(ve.name));for(const se of Y)N.push({id:`agent:${se.id}`,label:se.name});return Bt&&N.push({id:`user:${Bt}`,label:"Me"}),N},[xs,wn?.users,Bt]),bo=(0,u.useMemo)(()=>cD($??{}),[$]),{data:ql}=Te({queryKey:G.issues.activity(i),queryFn:a(()=>io.forIssue(i),"queryFn"),enabled:!!(i&&Bt&&$?.assigneeUserId===Bt)}),Bl=(0,u.useMemo)(()=>eL($??{},cj(da??[],fn),Bt,void 0,ql),[$,da,fn,Bt,ql]),zc=(0,u.useMemo)(()=>cj(da??[],fn).filter(N=>!(N.authorType==="system"&&N.metadata?.recoveryResponsibility==="system")).map(N=>{"clientId"in N&&N.clientId&&yn.current.set(N.id,N.clientId);const Y=yn.current.get(N.id);return Y?{...N,clientId:Y}:N}),[da,fn]),Fl=$?.title??ot?.title??"",Ha=$?.identifier??ot?.identifier??(i&&/^[a-z0-9]+-\d+$/i.test(i)?i:$?.id.slice(0,8)),yo=$?.status??ot?.status,qr=$?.blockerAttention,Uc=yo?`${yo}|${$?.displayStatus??ot?.displayStatus??""}|${$?.externalConversationState??""}|${JSON.stringify(qr??null)}`:"loading-task-status",Ms=(0,u.useMemo)(()=>yo?(0,s.jsx)(ti,{status:yo,displayStatus:$?.displayStatus??ot?.displayStatus,externalConversationState:$?.externalConversationState,className:"size-3",blockerAttention:qr}):(0,s.jsx)("span",{"aria-hidden":"true",className:"size-3 shrink-0"}),[Uc]),Cs=(0,u.useMemo)(()=>{const N=new Set;return i&&N.add(i),$?.id&&N.add($.id),$?.identifier&&N.add($.identifier),[...N]},[$?.id,$?.identifier,i]),Vt=(0,u.useCallback)(()=>{for(const N of Cs)R.invalidateQueries({queryKey:G.issues.detail(N)}),R.invalidateQueries({queryKey:G.issues.activity(N)}),R.invalidateQueries({queryKey:G.issues.interactions(N)})},[Cs,R]),ci=(0,u.useCallback)(()=>{for(const N of Cs)R.invalidateQueries({queryKey:G.issues.detail(N),refetchType:"inactive"}),R.invalidateQueries({queryKey:G.issues.activity(N),refetchType:"inactive"}),R.invalidateQueries({queryKey:G.issues.interactions(N),refetchType:"inactive"})},[Cs,R]),Br=(0,u.useCallback)(()=>{for(const N of Cs)R.invalidateQueries({queryKey:G.issues.runs(N)}),R.invalidateQueries({queryKey:G.issues.liveRuns(N)}),R.invalidateQueries({queryKey:G.issues.activeRun(N)})},[Cs,R]),Xo=(0,u.useCallback)(()=>{R.invalidateQueries({queryKey:["issues","document-annotations",i]}),R.invalidateQueries({queryKey:G.issues.documents(i)})},[i,R]),Zo=(0,u.useCallback)(async N=>{await Promise.all(Cs.map(Y=>R.cancelQueries({queryKey:G.issues.comments(Y)})));for(const Y of Cs)R.setQueryData([...G.issues.comments(Y),"linked",N],se=>se&&null),R.setQueryData(G.issues.comments(Y),se=>se&&{...se,pages:z4(se.pages,N)}),R.setQueryData(G.issues.acknowledgedComments(Y),se=>se?.filter(ve=>ve.id!==N)),R.setQueryData(G.issues.earlierComments(Y),se=>se&&{...se,pages:se.pages.map(ve=>({...ve,comments:ve.comments.filter(Fe=>Fe.id!==N)}))}),R.setQueryData([...G.issues.comments(Y),"recent"],se=>{if(!se)return se;const ve=Bm(se.comments.filter(Fe=>Fe.id!==N));return{...se,comments:ve,latestCommentId:se.latestCommentId===N?ve.at(-1)?.id??null:se.latestCommentId}})},[Cs,R]),zl=(0,u.useCallback)(N=>{typeof window>"u"||window.location.hash===`#comment-${N}`&&window.history.replaceState(null,"",`${Q.pathname}${Q.search}`)},[Q.pathname,Q.search]),el=(0,u.useCallback)(async N=>{await Promise.all(Cs.map(Y=>R.cancelQueries({queryKey:G.issues.comments(Y)})));for(const Y of Cs)R.setQueryData([...G.issues.comments(Y),"linked",N.id],se=>se&&N),R.setQueryData(G.issues.comments(Y),se=>se&&{...se,pages:Sm(se.pages,N)}),R.setQueryData(G.issues.acknowledgedComments(Y),se=>se?.map(ve=>ve.id===N.id?N:ve)),R.setQueryData(G.issues.earlierComments(Y),se=>se&&{...se,pages:se.pages.map(ve=>({...ve,comments:ve.comments.map(Fe=>Fe.id===N.id?N:Fe)}))}),R.setQueryData([...G.issues.comments(Y),"recent"],se=>se&&{...se,comments:se.comments.map(ve=>ve.id===N.id?N:ve)})},[Cs,R]),Hi=(0,u.useCallback)(N=>{rs.current?.restoreDraft(N)},[]),Qs=(0,u.useCallback)(()=>{b&&(R.invalidateQueries({queryKey:G.issues.list(b)}),R.invalidateQueries({queryKey:G.issues.listMineByMe(b)}),R.invalidateQueries({queryKey:G.issues.listTouchedByMe(b)}),R.invalidateQueries({queryKey:G.issues.listUnreadTouchedByMe(b)}),R.invalidateQueries({queryKey:G.sidebarBadges(b)}))},[R,b]),Wc=(0,u.useCallback)(async(N,Y,se)=>{Y&&(await fj(R,Y),TD(Y,N),_j(R,se,N));try{await $e.unarchiveFromInbox(N),Z({title:"Task restored to inbox",tone:"success"})}catch(ve){Y&&(bj(Y,N),K0(R,Y,N),uj(Y,N)),Z({title:"Undo failed",body:ve instanceof Error?ve.message:"Unable to restore this task to the inbox",tone:"error"})}finally{Y&&await wb(R,Y)}},[Z,R]),Qi=(0,u.useCallback)(N=>{oA(R,N.companyId,N),R.setQueryData(G.issues.interactions(i),Y=>{const se=(Y??[]).filter(ve=>ve.id!==N.id);return se.push(N),se.sort((ve,Fe)=>{const Xe=new Date(ve.createdAt).getTime()-new Date(Fe.createdAt).getTime();return Xe===0?ve.id.localeCompare(Fe.id):Xe}),se})},[i,R]),vo=(0,u.useCallback)((N,Y)=>{R.setQueriesData({queryKey:["issues","detail"]},se=>se&&Hj(se,N)?{...se,...Y}:se),b&&R.setQueryData(G.issues.list(b),se=>se?.map(ve=>Hj(ve,N)?{...ve,...Y}:ve))},[R,b]),Kc=Gl({mutationFn:a(N=>(N.attemptedSessionAt=R.getQueryState(G.auth.session)?.dataUpdatedAt??0,$e.markRead(N.issueId)),"mutationFn"),onSuccess:a((N,Y)=>{Y.confirmed=!0,R.invalidateQueries({queryKey:G.issues.summaries(Y.companyId)}),b&&(R.invalidateQueries({queryKey:G.issues.listMineByMe(b)}),R.invalidateQueries({queryKey:G.issues.listTouchedByMe(b)}),R.invalidateQueries({queryKey:G.issues.listUnreadTouchedByMe(b)}),R.invalidateQueries({queryKey:G.sidebarBadges(b)}))},"onSuccess"),onFinished:a(N=>{Yn.current.delete(N.issueId),Un.current===N&&gs(Y=>Y+1)},"onFinished")}),tl=rj({companyId:b,onSuccess:a(({comment:N,changes:Y,blockedByIssueIds:se,...ve},{data:Fe})=>{Object.prototype.hasOwnProperty.call(Fe,"projectId")&&m4(ve.projectId??"",ve.companyId);const Xe=new Set([i,ve.id]);ve.identifier&&Xe.add(ve.identifier),vo(Xe,ve),k&&kn&&Sf(ve,Bt,Date.now()),R.invalidateQueries({queryKey:G.issues.activity(i)}),Qs()},"onSuccess")}),U=(0,u.useMemo)(()=>({mutate:a((N,Y)=>tl.mutate({id:i,data:N},Y),"mutate"),mutateAsync:a(N=>tl.mutateAsync({id:i,data:N}),"mutateAsync"),isPending:tl.isPending,variables:tl.variables?.data}),[i,tl]),ue=ut({mutationFn:a(N=>$e.resolveRecoveryAction(i,N),"mutationFn"),onSuccess:a(({issue:N})=>{const Y=new Set([i,N.id]);N.identifier&&Y.add(N.identifier),vo(Y,N),R.invalidateQueries({queryKey:G.issues.activity(i)}),Qs()},"onSuccess"),onError:a(N=>{Z({title:"Recovery resolution failed",body:N instanceof Error?N.message:"Unable to resolve recovery action",tone:"error"})},"onError"),onSettled:a(()=>{R.invalidateQueries({queryKey:G.issues.detail(i)}),b&&R.invalidateQueries({queryKey:G.issues.list(b)})},"onSettled")}),qe=ut({mutationFn:a(async N=>{const Y=await $e.resolveRecoveryAction(i,{actionId:N,outcome:"restored",sourceIssueStatus:"todo"});if(Y.issue.status!=="todo"||Y.issue.assigneeAgentId!==Y.recoveryAction.returnOwnerAgentId)throw new Error("The task’s state has changed. Refresh to see its current state.");return Y},"mutationFn"),onSuccess:a(({issue:N})=>{const Y=new Set([i,N.id]);N.identifier&&Y.add(N.identifier),vo(Y,N),Qs()},"onSuccess"),onSettled:a(()=>{for(const N of[G.issues.detail(i),G.issues.activity(i),G.issues.runs(i),G.issues.liveRuns(i)])R.invalidateQueries({queryKey:N})},"onSettled")}),be=ut({onMutate:a(()=>vs(null),"onMutate"),mutationFn:a(async({mode:N,scope:Y,runId:se,wakeAgents:ve=!1})=>{if(N==="resume"){const Xe=Gn?.activePauseHold?.holdId;if(!Xe)throw new Error("No active subtree pause hold is available to resume.");return{kind:"release",hold:await $e.releaseTreeHold(i,Xe,{reason:null,metadata:{wakeAgents:ve}})}}const Fe=await $e.createTreeHold(i,{mode:N,reason:null,releasePolicy:{strategy:"manual",...N==="pause"?{note:Y==="leaf"?"leaf_pause":"full_pause"}:{}},...se?{metadata:{source:"issue_active_run_control",runId:se}}:{},...N==="restore"?{metadata:{wakeAgents:ve}}:{}});return N==="pause"&&(R.invalidateQueries({queryKey:["issues","tree-control-state",i??"pending"]}),await lj(Fe.preview.activeRuns.map(Xe=>Xe.id))),{kind:"create",hold:Fe.hold,preview:Fe.preview}},"mutationFn"),onSuccess:a(N=>{N.kind==="release"&&N.hold.wakeFailures?.length&&vs(`Pause released, but ${N.hold.wakeFailures.length} ${N.hold.wakeFailures.length===1?"task":"tasks"} could not start. ${N.hold.wakeFailures[0].message} Check the affected agents and try starting them again.`),ps(!1),Ds(!1)},"onSuccess"),onSettled:a(async()=>{await Promise.all([R.invalidateQueries({queryKey:G.issues.detail(i)}),R.invalidateQueries({queryKey:G.issues.activity(i)}),R.invalidateQueries({queryKey:G.issues.liveRuns(i)}),R.invalidateQueries({queryKey:G.issues.activeRun(i)}),R.invalidateQueries({queryKey:G.issues.runs(i)}),R.invalidateQueries({queryKey:["issues","tree-control-state",i??"pending"]}),R.invalidateQueries({queryKey:["issues","tree-holds",i??"pending"]}),R.invalidateQueries({queryKey:["issues","tree-control-preview",i??"pending"]})]),b&&await Promise.all([R.invalidateQueries({queryKey:G.issues.list(b)}),...$?.id?[R.invalidateQueries({queryKey:G.issues.listByParent(b,$.id)}),R.invalidateQueries({queryKey:G.issues.listByDescendantRoot(b,$.id)})]:[]])},"onSettled")}),Me=ut({mutationFn:a(async N=>{const Y=await qn.cancel(N);await lj([N],{initialRuns:[Y]})},"mutationFn"),onSettled:a(()=>Promise.all([R.invalidateQueries({queryKey:G.issues.detail(i)}),R.invalidateQueries({queryKey:G.issues.runs(i)})]),"onSettled")}),kt=vP(),zt=ut({mutationFn:a(async({runId:N,status:Y})=>{if(Y==="cancelled"){let se=!1;try{return await kt(i,{status:Y},async()=>{await qn.cancel(N),se=!0})}catch(ve){throw ve instanceof ij||ve instanceof aj?ve:se?DC(ve):ve}}await qn.cancel(N);try{return await $e.update(i,{status:Y})}catch(se){throw DC(se)}},"mutationFn"),onSuccess:a(({comment:N,...Y},{status:se})=>{const ve=new Set([i,Y.id]);Y.identifier&&ve.add(Y.identifier),vo(ve,Y),R.invalidateQueries({queryKey:G.issues.activity(i)}),Br(),Qs(),Z({title:se==="done"?"Run stopped and task done":"Run stopped and task cancelled",tone:"success"})},"onSuccess"),onError:a((N,{status:Y})=>{if(N instanceof ij)return;if(N instanceof aj){Br(),Z({title:"Some subtasks could not be canceled",body:N.message,tone:"error"});return}const se=Mde(N);Z({title:se?"Run stopped; task update failed":Y==="done"?"Stop and done failed":"Stop and cancel failed",body:N instanceof Error?N.message:"Unable to stop the run and update the task",tone:"error"})},"onError"),onSettled:a((N,Y)=>{R.invalidateQueries({queryKey:G.issues.detail(i)}),Y&&Br(),b&&R.invalidateQueries({queryKey:G.issues.list(b)})},"onSettled")}),Ys=(0,u.useCallback)(N=>{U.mutate(N)},[U.mutate]),_r=rj({companyId:it,onSuccess:a(()=>{it&&(R.invalidateQueries({queryKey:["issues",it]}),R.invalidateQueries({queryKey:G.sidebarBadges(it)}))},"onSuccess")}),ta=(0,u.useCallback)((N,Y)=>{_r.mutate({id:N,data:Y})},[_r.mutate]),sl=(0,u.useMemo)(()=>x&&!v&&$&&fa?(0,s.jsx)(Lj,{issues:Ht,isLoading:Gt,agents:xs,projects:er,liveIssueIds:Wa,projectId:$.projectId??void 0,viewStateKey:`paperclip:issue-detail:${$.id}:subissues-view`,issueLinkState:ss??Q.state,searchFilters:{descendantOf:$.id,includeBlockedBy:!0},searchWithinLoadedIssues:!0,baseCreateIssueDefaults:tx($,Bt),createIssueLabel:"Sub-task",showChecklist:!0,showProgressSummary:!0,parentIssueIdForCostSummary:$.id,onUpdateIssue:ta}):null,[x,v,$,fa,Ht,Gt,xs,er,Wa,ss,Q.state,Bt,ta]),Ce=ut({mutationKey:["cancel-issue-monitor",i],mutationFn:a(async()=>{const N=await $e.get(i),{monitor:Y,...se}=N.executionPolicy??{mode:"normal",commentRequired:!0,stages:[]};return $e.update(N.id,{expectedExecutionPolicy:N.executionPolicy??null,executionPolicy:{...se,mode:se.mode??"normal",commentRequired:se.commentRequired??!0,stages:se.stages??[]}})},"mutationFn"),onSuccess:a(()=>{Vt(),Br(),Qs()},"onSuccess")}),Lt=ut({mutationKey:["check-issue-monitor-now",i],mutationFn:a(()=>$e.checkMonitorNow(i),"mutationFn"),onSuccess:a(()=>{Vt(),Br(),Qs(),Z({title:"Monitor check queued",tone:"success"})},"onSuccess"),onError:a(N=>{Z({title:"Monitor check failed",body:N instanceof Error?N.message:"Unable to trigger the monitor right now",tone:"error"})},"onError")}),Ue=ut({mutationFn:a(async({approvalId:N,action:Y})=>Y==="approve"?nj.approve(N):nj.reject(N),"mutationFn"),onMutate:a(({approvalId:N,action:Y})=>{re({approvalId:N,action:Y})},"onMutate"),onSuccess:a((N,Y)=>{Vt(),R.invalidateQueries({queryKey:G.issues.approvals(i)}),Qs(),R.invalidateQueries({queryKey:G.approvals.detail(Y.approvalId)}),it&&R.invalidateQueries({queryKey:G.approvals.list(it)}),Z({title:Y.action==="approve"?"Approval approved":"Approval rejected",tone:"success"})},"onSuccess"),onError:a((N,Y)=>{Z({title:Y.action==="approve"?"Approval failed":"Rejection failed",body:N instanceof Error?N.message:"Unable to update approval",tone:"error"})},"onError"),onSettled:a(()=>{re(null)},"onSettled")}),Cr=Gl({mutationFn:a(async({body:N,reopen:Y,interrupt:se,attachmentIds:ve,clientRequestId:Fe,runSettings:Xe,nativeCommand:St},{assertCurrentAccount:cn})=>{$?.conversationAgentId&&EQ(`${$.companyId}:${Bt}:${$.conversationAgentId}`);const Wr=await wr();if(cn(),Xe&&$?.conversationAgentId){const Im=await $e.getCore(Wr,{cache:"no-store",fresh:!0});cn();const mP=await $e.update(Wr,{assigneeAdapterOverrides:Qj(Im.assigneeAdapterOverrides,(e?.agent??Ot.get($.conversationAgentId))?.adapterType,Xe)});cn(),R.setQueryData(G.issues.detail(Wr),mP)}return $e.addComment(Wr,N,Y,se,ve,Fe??Kg(),St)},"mutationFn"),onMutate:a(async({body:N,reopen:Y,interrupt:se})=>{const ve=R.cancelQueries({queryKey:G.issues.comments(i)}),Fe=R.cancelQueries({queryKey:G.issues.detail(i)}),Xe=R.getQueryData(G.issues.detail(i)),St=se?null:BC(R,i,$).interruptibleIssueRun,cn=$?yj({companyId:$.companyId,issueId:$.id,body:N,authorUserId:Bt,clientStatus:St?"queued":"pending",queueTargetRunId:St?.id??null}):null;return cn&&ht(Wr=>[...Wr,cn]),Xe&&R.setQueryData(G.issues.detail(i),gj(Xe,{reopen:Y})),await Promise.all([ve,Fe]),{optimisticCommentId:cn?.clientId??null,queuedCommentTargetRunId:St?.id??null,previousIssue:Xe}},"onMutate"),onSuccess:a(async(N,Y,se)=>{if(se?.optimisticCommentId&&Jt.current.has(se.optimisticCommentId)){Jt.current.delete(se.optimisticCommentId),ht(ve=>ve.filter(Fe=>Fe.clientId!==se.optimisticCommentId));try{await $e.cancelComment(N.issueId,N.id),await Zo(N.id),Vt(),ci(),Qs();return}catch(ve){Z({title:"Cancel failed",body:ve instanceof Error?ve.message:"Unable to cancel the queued comment",tone:"error"})}}se?.queuedCommentTargetRunId&&(An(ve=>{const Fe=new Map(ve);return Fe.set(N.id,se.queuedCommentTargetRunId),Fe}),R.invalidateQueries({queryKey:G.issues.queuedComments(i??N.issueId)})),$?.conversationAgentId&&g8($.originKind==="onboarding_chat"?"onboarding_chat":"agent_chat"),se?.optimisticCommentId&&yn.current.set(N.id,se.optimisticCommentId),Ts&&yt(N),R.setQueryData(G.issues.comments(i??N.issueId),ve=>ve?{...ve,pages:Sm(ve.pages,N)}:{pageParams:[null],pages:Sm(void 0,N)}),X||await R.invalidateQueries({queryKey:G.issues.comments(i??N.issueId),exact:!0,refetchType:"none"}),se?.optimisticCommentId&&ht(ve=>ve.filter(Fe=>Fe.clientId!==se.optimisticCommentId)),k&&$&&kn&&Sf($,Bt,new Date(N.createdAt).getTime())},"onSuccess"),onError:a((N,Y,se)=>{if(se?.optimisticCommentId&&ht(Xe=>Xe.filter(St=>St.clientId!==se.optimisticCommentId)),se?.previousIssue&&R.setQueryData(G.issues.detail(i),se.previousIssue),wl(N)==="pending")return;const{title:ve,body:Fe}=Ps(N,{action:"post the comment"});Z({title:ve,body:Fe,tone:"error"})},"onError"),onFinished:a((N,Y)=>{Y?.optimisticCommentId&&ht(se=>se.filter(ve=>ve.clientId!==Y.optimisticCommentId))},"onFinished"),onSettled:a((N,Y,se)=>{if(N&&!i&&R.invalidateQueries({queryKey:G.issues.comments(N.issueId)}),Y&&R.invalidateQueries({queryKey:["issues","tree-control-state"]}),ci(),se.attachmentIds?.length)for(const ve of Cs)R.invalidateQueries({queryKey:G.issues.attachments(ve)});se.interrupt&&Br(),se.reopen&&Qs()},"onSettled")}),Fr=Gl({meta:{replay:"idempotent"},mutationFn:a(({interaction:N,selectedClientKeys:Y,selectedOptionIds:se,rememberAction:ve})=>$e.acceptInteraction(i,N.id,{selectedClientKeys:Y,selectedOptionIds:se,rememberAction:ve}),"mutationFn"),onSuccess:a(N=>{Qi(N),N.kind==="suggest_tasks"&&it&&$?.id&&R.invalidateQueries({queryKey:G.issues.listByParent(it,$.id)}),Vt(),Qs();const Y=N.kind==="suggest_tasks"?N.result?.createdTasks?.length??0:0,se=N.kind==="suggest_tasks"?N.result?.skippedClientKeys?.length??0:0;Z({title:N.kind==="request_confirmation"?"Request confirmed":N.kind==="request_checkbox_confirmation"?"Selection confirmed":se>0?`Accepted ${Y} draft${Y===1?"":"s"} and skipped ${se}`:"Suggested tasks accepted",tone:"success"})},"onSuccess"),onError:a(N=>{Uj(N).kind==="settled"&&Vt(),Z({title:"Accept failed",body:nh(N),tone:"error"})},"onError")}),Gi=Gl({meta:{replay:"idempotent"},mutationFn:a(({interaction:N,reason:Y})=>$e.rejectInteraction(i,N.id,Y),"mutationFn"),onSuccess:a(N=>{Qi(N),Vt(),Qs(),Z({title:N.kind==="request_confirmation"?a0(N):"Suggestion rejected",tone:"success"})},"onSuccess"),onError:a(N=>{Uj(N).kind==="settled"&&Vt(),Z({title:"Reject failed",body:nh(N),tone:"error"})},"onError")}),Js=Gl({meta:{replay:"idempotent"},mutationFn:a(({interaction:N,answers:Y})=>$e.respondToInteraction(i,N.id,{answers:Y}),"mutationFn"),onSuccess:a(N=>{Qi(N),Vt(),Qs(),Z({title:"Answers submitted",tone:"success"})},"onSuccess"),onError:a(N=>{Z({title:"Submit failed",body:nh(N),tone:"error"})},"onError")}),Ar=ut({mutationFn:a(({interaction:N,verdicts:Y})=>$e.submitInteractionVerdicts(i,N.id,Y),"mutationFn"),onSuccess:a((N,Y)=>{Qi(N),Vt(),Qs();const se=Y.verdicts.length,ve=N.kind==="request_item_verdicts"?N.result?.complete??!1:!1;Z({title:ve?"All verdicts applied":`Applied ${se} decision${se===1?"":"s"}`,tone:"success"})},"onSuccess"),onError:a(N=>{Z({title:"Apply failed",body:N instanceof Error?N.message:"Unable to apply the verdicts",tone:"error"})},"onError")}),Yi=ut({mutationFn:a(({interaction:N})=>$e.cancelInteraction(i,N.id),"mutationFn"),onSuccess:a(N=>{Qi(N),Vt(),Qs(),Z({title:"Question cancelled",tone:"success"})},"onSuccess"),onError:a(N=>{Z({title:"Cancel failed",body:N instanceof Error?N.message:"Unable to cancel the question",tone:"error"})},"onError")}),ji=ut({mutationFn:a(N=>$e.dismissInteraction(i,N.id),"mutationFn"),onSuccess:a(N=>{Qi(N),Vt(),Qs()},"onSuccess")}),Qa=ut({mutationFn:a(({interaction:N})=>$e.skipInteraction(i,N.id),"mutationFn"),onSuccess:a(N=>{Qi(N),Vt(),Qs()},"onSuccess"),onError:a(N=>{Z({title:"Skip failed",body:N instanceof Error?N.message:"Unable to skip this request",tone:"error"})},"onError")}),En=Gl({mutationFn:a(async({body:N,reopen:Y,interrupt:se,reassignment:ve,attachmentIds:Fe,clientRequestId:Xe,runSettings:St},{assertCurrentAccount:cn})=>{const Wr=St&&!ve?await $e.getCore(i,{cache:"no-store",fresh:!0}):$;return cn(),$e.update(i,{comment:N,commentClientRequestId:Xe,...Fe?.length?{attachmentIds:Fe}:{},...ve?{assigneeAgentId:ve.assigneeAgentId,assigneeUserId:ve.assigneeUserId}:{},...St||ve?{assigneeAdapterOverrides:St?Qj(Wr?.assigneeAdapterOverrides,Ot.get(ve?.assigneeAgentId??Wr?.assigneeAgentId??"")?.adapterType,St,!!ve):null}:{},...Y?{status:"todo"}:{},...se?{interrupt:se}:{}})},"mutationFn"),onMutate:a(async({body:N,reopen:Y,reassignment:se,interrupt:ve})=>{const Fe=R.cancelQueries({queryKey:G.issues.comments(i)}),Xe=R.cancelQueries({queryKey:G.issues.detail(i)}),St=R.getQueryData(G.issues.detail(i)),cn=ve?null:BC(R,i,$).interruptibleIssueRun,Wr=$?yj({companyId:$.companyId,issueId:$.id,body:N,authorUserId:Bt,clientStatus:cn?"queued":"pending",queueTargetRunId:cn?.id??null}):null;return Wr&&ht(Im=>[...Im,Wr]),St&&R.setQueryData(G.issues.detail(i),gj(St,{reopen:Y,reassignment:se})),await Promise.all([Fe,Xe]),{optimisticCommentId:Wr?.clientId??null,queuedCommentTargetRunId:cn?.id??null,previousIssue:St}},"onMutate"),onSuccess:a(async(N,Y,se)=>{const{comment:ve,...Fe}=N;if(R.setQueryData(G.issues.detail(i),Fe),ve&&se?.optimisticCommentId&&Jt.current.has(se.optimisticCommentId)){Jt.current.delete(se.optimisticCommentId),ht(Xe=>Xe.filter(St=>St.clientId!==se.optimisticCommentId));try{await $e.cancelComment(i,ve.id),await Zo(ve.id),Vt(),ci(),Qs();return}catch(Xe){Z({title:"Cancel failed",body:Xe instanceof Error?Xe.message:"Unable to cancel the queued comment",tone:"error"})}}ve&&se?.queuedCommentTargetRunId&&(An(Xe=>{const St=new Map(Xe);return St.set(ve.id,se.queuedCommentTargetRunId),St}),R.invalidateQueries({queryKey:G.issues.queuedComments(i)})),ve&&(Ts&&yt(ve),se?.optimisticCommentId&&yn.current.set(ve.id,se.optimisticCommentId),R.setQueryData(G.issues.comments(i),Xe=>Xe?{...Xe,pages:Sm(Xe.pages,ve)}:{pageParams:[null],pages:Sm(void 0,ve)}),X||await R.invalidateQueries({queryKey:G.issues.comments(i),exact:!0,refetchType:"none"}),k&&kn&&Sf(Fe,Bt,new Date(ve.createdAt).getTime())),se?.optimisticCommentId&&ht(Xe=>Xe.filter(St=>St.clientId!==se.optimisticCommentId))},"onSuccess"),onError:a((N,Y,se)=>{if(se?.optimisticCommentId&&ht(Xe=>Xe.filter(St=>St.clientId!==se.optimisticCommentId)),se?.previousIssue&&R.setQueryData(G.issues.detail(i),se.previousIssue),wl(N)==="pending")return;const{title:ve,body:Fe}=Ps(N,{action:"post the comment"});Z({title:ve,body:Fe,tone:"error"})},"onError"),onSettled:a((N,Y,se)=>{if(Y&&R.invalidateQueries({queryKey:["issues","tree-control-state"]}),ci(),se.attachmentIds?.length)for(const ve of Cs)R.invalidateQueries({queryKey:G.issues.attachments(ve)});se.interrupt&&Br(),Qs()},"onSettled")}),zr=ut({mutationFn:a(N=>$e.interruptLatestQueuedComments(i,N),"mutationFn"),onSuccess:a(()=>{Vt(),Br()},"onSuccess"),onError:a(()=>{Vt(),Br()},"onError")}),wo=ut({mutationFn:a(async({commentId:N})=>$e.cancelComment(i,N),"mutationFn"),onSuccess:a(async N=>{An(Y=>{if(!Y.has(N.id))return Y;const se=new Map(Y);return se.delete(N.id),se}),await Zo(N.id),Hi(N.body),Vt(),ci(),Qs(),Z({title:"Queued comment canceled",body:"The queued message was restored to the composer.",tone:"success"})},"onSuccess"),onError:a(N=>{Z({title:"Cancel failed",body:N instanceof Error?N.message:"Unable to cancel the queued comment",tone:"error"})},"onError")}),Nm=ut({mutationFn:a(async({commentId:N})=>$e.deleteComment(i,N),"mutationFn"),onSuccess:a(async N=>{await el(N),zl(N.id),Vt(),ci(),Qs(),Xo(),Z({title:"Comment deleted",body:"The thread now shows a deleted-comment marker.",tone:"success"})},"onSuccess"),onError:a(N=>{Z({title:"Delete failed",body:N instanceof Error?N.message:"Unable to delete the comment",tone:"error"})},"onError")}),Ul=(0,u.useCallback)(N=>{if(N.startsWith("optimistic-")){Jt.current.add(N);let Y=null;ht(se=>{const ve=B4(se,N);return Y=ve.comment?.body??null,ve.comments}),Y&&(Hi(Y),Z({title:"Queued comment canceled",body:"The queued message was restored to the composer.",tone:"success"}));return}wo.mutateAsync({commentId:N})},[wo,Hi,Z]),Ga=ut({mutationFn:a(N=>$e.upsertFeedbackVote(i,{targetType:N.targetType,targetId:N.targetId,vote:N.vote,...N.reason?{reason:N.reason}:{},...N.allowSharing?{allowSharing:!0}:{}}),"mutationFn"),onMutate:a(async N=>{await R.cancelQueries({queryKey:G.issues.feedbackVotes(i)});const Y=R.getQueryData(G.issues.feedbackVotes(i));return R.setQueryData(G.issues.feedbackVotes(i),zde(Y,{issueId:i,targetType:N.targetType,targetId:N.targetId,vote:N.vote,reason:N.reason},Bt)),{previousVotes:Y}},"onMutate"),onSuccess:a((N,Y)=>{R.invalidateQueries({queryKey:G.issues.feedbackVotes(i)}),R.invalidateQueries({queryKey:G.companies.all}),R.invalidateQueries({queryKey:G.instance.generalSettings}),Z({title:Y.sharingPreferenceAtSubmit==="prompt"?Y.allowSharing?"Feedback saved. Future votes will share":"Feedback saved. Future votes will stay local":Y.allowSharing?"Feedback saved and sharing enabled":"Feedback saved",tone:"success"})},"onSuccess"),onError:a((N,Y,se)=>{se?.previousVotes&&R.setQueryData(G.issues.feedbackVotes(i),se.previousVotes),Z({title:"Failed to save feedback",body:N instanceof Error?N.message:"Unknown error",tone:"error"})},"onError")}),Rr=ut({mutationFn:a(async N=>{if(e)return $e.uploadAttachment(e.agent.companyId,await wr(),N);if(!Ze)throw new Error("Task details are still loading. Please try again.");return $e.uploadAttachment(Ze.companyId,Ze.id,N)},"mutationFn"),onSuccess:a(N=>{mt(null),R.invalidateQueries({queryKey:G.issues.attachments(i??N.issueId)}),Vt(),i||R.invalidateQueries({queryKey:G.issues.detail(N.issueId)})},"onSuccess"),onError:a(N=>{mt(N instanceof Error?N.message:"Upload failed")},"onError")}),di=ut({mutationFn:a(async N=>{const Y=qde(N.name),se=Bde(Y),ve=($?.documentSummaries??[]).find(cn=>cn.key===se)??null,Fe=await N.text(),Xe=Fde(Y),St=ve?.title??Xe??null;return $e.upsertDocument(await wr(),se,{title:se==="plan"?null:St,format:"markdown",body:Fe,baseRevisionId:ve?.latestRevisionId??null})},"mutationFn"),onSuccess:a(N=>{mt(null),Vt(),i||R.invalidateQueries({queryKey:G.issues.detail(N.issueId)}),R.invalidateQueries({queryKey:G.issues.documents(i??N.issueId)})},"onSuccess"),onError:a(N=>{mt(N instanceof Error?N.message:"Document import failed")},"onError")}),Vc=ut({mutationFn:a(N=>$e.deleteAttachment(N),"mutationFn"),onSuccess:a(()=>{mt(null),R.invalidateQueries({queryKey:G.issues.attachments(i)}),Vt()},"onSuccess"),onError:a(N=>{mt(N instanceof Error?N.message:"Delete failed")},"onError")}),sa=Gl({mutationFn:a(N=>$e.archiveFromInbox(N),"mutationFn"),onMutate:a(async N=>{if(!b)return{previousData:[]};const Y=Ib(R),se=bj(b,N);try{await fj(R,b)}catch(Fe){throw se(),Fe}if(!Y.isCurrentScope())return se(),{companyId:b,previousData:[],account:Y,release:se};const ve=H4(R,b);return K0(R,b,N),{companyId:b,previousData:ve,account:Y,release:se}},"onMutate"),onSuccess:a((N,Y,se)=>{b&&K0(R,b,Y),Qs(),V(Mt.href.startsWith("/inbox")?Mt.href:"/inbox",{replace:!0}),Z({title:"Task archived from inbox",tone:"success",action:{label:"Undo",onClick:a(()=>{Wc(Y,se?.companyId,se?.previousData??[])},"onClick")}})},"onSuccess"),onError:a((N,Y,se)=>{se?.release?.(),se?.previousData&&_j(R,se.previousData,Y),Z({title:"Archive failed",body:N instanceof Error?N.message:"Unable to archive this task from the inbox",tone:"error"})},"onError"),onFinished:a((N,Y)=>{Y?.account&&!Y.account.isCurrentScope()&&Y.release()},"onFinished"),onSettled:a(async(N,Y,se,ve)=>{if(ve?.companyId){Y||uj(ve.companyId,se);try{await wb(R,ve.companyId),!Y&&ve.account?.isCurrentScope()&&$q(R,ve.companyId,se)!=="unknown"&&v4(ve.companyId,se)}finally{ve.account&&!ve.account.isCurrentScope()&&ve.release()}}},"onSettled")}),Ji=e?.agent??xs?.find(N=>N.id===$?.conversationAgentId),Tr=$?.ancestors?.[0],nl=Tr&&!pa(Tr)?Tr.identifier??Tr.id:null,Qd=(0,u.useCallback)(()=>{nl&&Zm(nl,ss??Q.state,Q.search)},[nl,ss,Q.state,Q.search]);(0,u.useEffect)(()=>{if(o){C([{label:"Chat"}]);return}C([Mt,...Tr?[{label:pa(Tr)?"Private task":Tr.title,href:pa(Tr)?void 0:ra(Tr.identifier??Tr.id),onClick:pa(Tr)?void 0:Qd,control:pa(Tr)?(0,s.jsx)(Nd,{identifier:null}):void 0,controlKey:pa(Tr)?"private-parent":void 0}]:[],{label:Fl,identifier:Ha,leading:Ms,leadingKey:Uc}])},[o,j,Fl,Ha,Tr,Qd,Qn,C,Mt.href,Mt.label,Ms,Uc]),(0,u.useEffect)(()=>{if(!v&&!o||!x||!$?.id){L(null);return}return L({open:P?ee:z&&!Ln,onToggle:tr}),()=>L(null)},[o,P,$?.id,ee,z,L,v,Ln,x,tr]),(0,u.useEffect)(()=>{const N=x&&!v&&!P&&!!$?.id&&(!z||Ln);return S(N?(0,s.jsx)(kh,{children:(0,s.jsx)(vb,{open:!1,onToggle:Or,shortcut:"]",className:"shrink-0"})}):null),()=>S(null)},[P,$?.id,Or,z,S,v,Ln,x]);const Ni=ss?.issueDetailSource==="inbox";(0,u.useEffect)(()=>{const N=pn.current;if(pn.current=i,!D$({previousIssueId:N,nextIssueId:i,navigationType:J}))return;window.scrollTo({top:0,left:0,behavior:"auto"});const Y=document.getElementById("main-content");Y&&(Y.scrollTop=0)},[i,J]),(0,u.useEffect)(()=>{if(e||!Ze)return;const N=ss??Q.state,Y=wt,se=Ze.identifier??Ze.id,ve=Y&&r!==Y.issuePrefix,Fe=Ij(Q.search);if(i!==se||ve||Fe){Zm(se,N,Q.search);const Xe=ra(se);V({pathname:Y?`/${Y.issuePrefix}${Xe}`:Xe,search:Fe?"":Q.search,hash:Q.hash},{replace:!0,state:N})}},[e,Ze,wt,r,i,V,Q.state,Q.search,Q.hash,ss]),(0,u.useEffect)(()=>{if(!i||!$?.id||$.conversationAgentId)return;const N=Un.current?.issueId===$.id?Un.current:Un.current=Yn.current.get($.id)??{issueId:$.id,companyId:$.companyId,account:Ib(R),confirmed:!1};N.confirmed||Yn.current.has($.id)||!N.account.isCurrentScope()||N.attemptedSessionAt!==rn&&(N.attemptedSessionAt=rn,Yn.current.set($.id,N),Kc.mutate(N))},[i,$?.id,$?.conversationAgentId,rn,bn]);const Ii=(0,u.useMemo)(()=>{const N=[],Y=new Set,se=a((Fe,Xe)=>{Fe&&Y.add(`attachment:${Fe}`),Y.add(`content:${Xe}`)},"mark"),ve=a((Fe,Xe)=>!!(Fe&&Y.has(`attachment:${Fe}`))||Y.has(`content:${Xe}`),"hasSeen");for(const Fe of zs??[])!JT(Fe)&&!XT(Fe)||(N.push(Fe),se(Fe.id,Fe.contentPath));for(const Fe of uw(Hn).items){const Xe=Fe.metadata;Xe&&(!(Od(Xe.contentType,Xe.originalFilename??Fe.title)||si(Xe.contentType,Xe.originalFilename))||ve(Xe.attachmentId,Xe.contentPath)||(N.push({id:`work-product-${Fe.id}`,contentPath:Xe.contentPath,openPath:Xe.openPath,downloadPath:Xe.downloadPath,contentType:Xe.contentType,originalFilename:Xe.originalFilename??Fe.title}),se(Xe.attachmentId,Xe.contentPath)))}return N},[zs,Hn]),ko=(0,u.useCallback)(N=>{const Y=a(Fe=>{try{return new URL(Fe,window.location.origin).href}catch{return Fe}},"absoluteUrl"),se=Y(N);let ve=Ii.findIndex(Fe=>Y(Fe.contentPath)===se||Fe.openPath&&Y(Fe.openPath)===se);if(ve<0){const Fe=N.match(/\/api\/assets\/([^/]+)\/content/);Fe&&(ve=Ii.findIndex(Xe=>"assetId"in Xe&&Xe.assetId===Fe[1]))}return ve>=0?(es(ve),Wt(!0),!0):!1},[Ii]),Gd=(0,u.useCallback)(N=>{ko(N)||e1(N)},[ko]),jo=(0,u.useMemo)(()=>({feedbackVotes:as,feedbackDataSharingPreference:js,feedbackTermsUrl:OC,mentions:Tn,externalReferences:Ye.isEnabled?Ye.markdownReferences:void 0,imageUploadHandler:a(async N=>(await Rr.mutateAsync(N)).contentPath,"imageUploadHandler"),onVote:a(async(N,Y,se)=>{await Ga.mutateAsync({targetType:"issue_document_revision",targetId:N,vote:Y,reason:se?.reason,allowSharing:se?.allowSharing,sharingPreferenceAtSubmit:js})},"onVote"),agentMap:Ot,userProfileMap:Hs}),[as,js,Tn,Ye.isEnabled,Ye.markdownReferences,Rr.mutateAsync,Ga.mutateAsync,Ot,Hs]);(0,u.useLayoutEffect)(()=>{if(!w||!ea||Ln||e&&!e.issue||x&&P){O();return}const N={issue:ea,childIssues:Ki,issueLinkState:v?Ae:void 0,onAddSubIssue:ki,onUpdate:Ys,hasActiveRun:ln,externalObjects:Ye.isEnabled?Ye.groups:void 0,externalObjectsLoading:Ye.isEnabled?Ye.isLoading:void 0,externalObjectsError:Ye.isEnabled?Ye.isError:void 0,onRetryExternalObjects:Ye.isEnabled?Ye.refetch:void 0,onCheckMonitorNow:a(()=>Lt.mutate(),"onCheckMonitorNow"),checkingMonitorNow:Lt.isPending,documentDeepLink:De?.issueId===ea.id?De:null,onAttachmentOpened:Dl,openAttachment:!P&&_e?.issueId===ea.id?_e:null,openSkillId:ae?.id??null,openSkillName:ae?.name??null,onSkillOpened:Se};return x?F((0,s.jsx)(Po.Provider,{value:ko,children:(0,s.jsx)(yC,{documentEditor:jo,pluginPanels:Va,pluginPanelsLoading:qc,openedPluginPanelKeys:Ll.current,dismissedPluginPanelKeys:wi.current,openBrowserId:Go,onBrowserOpened:Yo,...N,showDocumentSourceTask:l,onArtifactVisibilityChange:l?A:void 0,accountScope:cr,fileTabsEnabled:or,streamlinedTabs:v,showSubtasksTab:v,tasksTab:Wi,artifactsOpenRequestId:!P&&!ie?.handled&&ie?.issueId===ea.id?ie.requestId:void 0,onArtifactsOpened:li},ea.id)}),{contentMode:"full-bleed"}):F((0,s.jsx)(Po.Provider,{value:ko,children:(0,s.jsx)(ev,{...N})})),()=>O()},[Va,qc,cr,Go,Yo,O,ko,Ys,$l,ki,F,_e,Dl,ae,Se,Ki,ea,l,A,Ln,Ae,v,ln,Lt.isPending,Lt.mutate,Ye.isEnabled,Ye.groups,Ye.isLoading,Ye.isError,Ye.refetch,De,w,x,jo,Bt,j,or,Wi,ie,li,P]);const rl=(0,u.useRef)(!1),na=(0,u.useRef)(null),Hc=!$?.hiddenAt;(0,u.useEffect)(()=>{if(!$?.id||!Hc)return;const N=a(Y=>{dO({armed:Hc,defaultPrevented:Y.defaultPrevented,key:Y.key,metaKey:Y.metaKey,ctrlKey:Y.ctrlKey,altKey:Y.altKey,target:Y.target,hasOpenDialog:Pj(document)})==="archive"&&(Y.preventDefault(),sa.isPending||sa.mutate($.id))},"handleKeyDown");return document.addEventListener("keydown",N,!0),()=>{document.removeEventListener("keydown",N,!0)}},[sa,Hc,$?.id]),(0,u.useEffect)(()=>{const N=a(()=>{na.current!==null&&(window.clearTimeout(na.current),na.current=null)},"clearArmTimeout"),Y=a(()=>{rl.current=!1,N()},"disarm"),se=a(()=>{rl.current=!0,N(),na.current=window.setTimeout(()=>{rl.current=!1,na.current=null},1200)},"arm"),ve=a(()=>{Y()},"handlePointerDown"),Fe=a(St=>{St.target instanceof HTMLElement&&St.target!==document.body&&Y()},"handleFocusIn"),Xe=a(St=>{const cn=IL({armed:rl.current,defaultPrevented:St.defaultPrevented,key:St.key,metaKey:St.metaKey,ctrlKey:St.ctrlKey,altKey:St.altKey,target:St.target,hasOpenDialog:Pj(document)});if(cn!=="ignore"){if(cn==="arm"){se();return}if(Y(),cn==="navigate_inbox"){St.preventDefault(),St.stopPropagation(),V(Mt.href.startsWith("/inbox")?Mt.href:"/inbox");return}if(cn==="focus_comment"&&(St.preventDefault(),St.stopPropagation(),xe("chat"),Kt(Wr=>Wr+1)),cn==="open_file_viewer"){if(!or)return;St.preventDefault(),St.stopPropagation(),ye(!0)}}},"handleKeyDown");return document.addEventListener("pointerdown",ve,!0),document.addEventListener("focusin",Fe,!0),document.addEventListener("keydown",Xe,!0),()=>{Y(),document.removeEventListener("pointerdown",ve,!0),document.removeEventListener("focusin",Fe,!0),document.removeEventListener("keydown",Xe,!0)}},[or,V,Mt.href]);const Qc=(0,u.useRef)(null),al=(0,u.useRef)(null),Xi=(0,u.useCallback)((N,Y=!1)=>{const se=lv(N),ve=se?.kind==="continuation-summary"&&x?{kind:"properties-pane",tab:"document",documentKey:"continuation-summary",maximize:!1}:se;if(!ve)return!1;if(ve.kind==="continuation-summary")return nt(null),xe("activity"),jt(Xe=>Xe+1),!0;if(!w||!x)return!1;if(P)ce(!0);else if(Ln&&$?.id&&Lc($.id),q(!0),ve.maximize){const Xe=`${i??""}::${N}`;Qc.current!==Xe&&(Qc.current=Xe,H())}const Fe=$?.id??i??"";return nt(Xe=>({issueId:Fe,tab:ve.tab,documentKey:ve.documentKey,focusActivePlan:Y,requestId:Xe?.issueId===Fe?Xe.requestId+1:1})),!0},[w,P,$?.id,i,q,H,Ln,x]);(0,u.useEffect)(()=>{const N=al.current;al.current=null,Xi(Q.hash,N?.pathname===Q.pathname&&N.hash===Q.hash)||(nt(null),Qc.current=null,B())},[i,Q.hash,Q.pathname,Xi,B]),(0,u.useEffect)(()=>()=>{B()},[B]),(0,u.useEffect)(()=>{const N=a(Y=>{if(Y.defaultPrevented||Y.button!==0||Y.metaKey||Y.ctrlKey||Y.shiftKey||Y.altKey)return;const se=Y.target;if(!(se instanceof Element))return;const ve=se.closest("a[href]");if(!ve||ve.hasAttribute("download")||ve.target&&ve.target!=="_self")return;const Fe=ve.getAttribute("href");if(!Fe)return;const Xe=new URL(`${Q.pathname}${Q.search}${Q.hash}`,window.location.origin),St=[$?.id,$?.identifier,i].filter(Im=>!!Im),cn=l&&ve.hasAttribute("data-sidebar-document-link")?Sde(Fe,Xe,St):Ide(Fe,Xe,St);if(!cn||lv(cn)?.kind==="properties-pane"&&(!w||!x))return;Y.preventDefault();const Wr=ve.hasAttribute("data-plan-expand")&&!P&&z&&!Ln;cn===Q.hash?Xi(cn,Wr):(al.current=Wr?{pathname:Q.pathname,hash:cn}:null,V(`${Q.pathname}${Q.search}${cn}`,{preventScrollReset:!0,state:{...Q.state&&typeof Q.state=="object"?Q.state:{},taskDocumentScrollEntry:dE(Q)}}))},"handleDocumentClick");return document.addEventListener("click",N,!0),()=>document.removeEventListener("click",N,!0)},[$?.id,$?.identifier,i,l,P,z,Ln,V,Q.hash,Q.key,Q.pathname,Q.search,Q.state,x,w,Xi]),(0,u.useEffect)(()=>{const N=Q.hash.match(/^#(work-product|attachment)-(.+)$/);if(!N)return;const Y=`${N[1]}-${decodeURIComponent(N[2])}`;let se=!1,ve=0,Fe;const Xe=a(()=>{if(se)return;const St=document.getElementById(Y);if(!St){ve<30&&(ve+=1,Fe=setTimeout(Xe,100));return}St.scrollIntoView({behavior:"smooth",block:"center"}),St.classList.add("ring-2","ring-primary/50","transition-shadow"),Fe=setTimeout(()=>St.classList.remove("ring-2","ring-primary/50","transition-shadow"),3e3)},"tryScroll");return Xe(),()=>{se=!0,Fe&&clearTimeout(Fe)}},[Q.hash,Hn,zs]),(0,u.useEffect)(()=>{ws!==0&&Ne==="chat"&&rs.current?.focus()},[Ne,ws]),(0,u.useEffect)(()=>{if(!or)return;const N=a(()=>{ye(!0)},"handleOpenFileViewer");return window.addEventListener("paperclip:open-file-viewer",N),()=>{window.removeEventListener("paperclip:open-file-viewer",N)}},[or]);const Wl=(0,u.useMemo)(()=>V8(Hn),[Hn]),Yd=(0,u.useMemo)(()=>(zs??[]).filter(N=>!Wl.has(N.id)),[zs,Wl]),Ve=a(async()=>{if(!$)return;const N=a(Fe=>{const Xe=document.createElement("textarea");return Xe.innerHTML=Fe,Xe.value},"decodeEntities"),Y=N($.title),se=N($.description??""),ve=`# ${$.identifier}: ${Y}
116
+ ${t}`:"Requested changes"}a($de,"buildPlanDecisionResponseText");var OC="https://paperclip.ing/tos",Pde=150,Dde=10;function Lde(e){if(e instanceof mn){if(e.status===403)return"Only board users can preview subtree controls.";if(e.status===409)return"Preview is stale because subtree hold state changed. Retry to refresh.";if(e.status===422)return"This subtree action is currently invalid for the selected tasks."}return e instanceof Error?e.message:"Unable to load preview."}a(Lde,"treeControlPreviewErrorCopy");function D$(e){return e.navigationType==="POP"?!1:e.previousIssueId!==e.nextIssueId}a(D$,"shouldScrollIssueDetailToTopOnNavigation");var cv={count:0,waitingOnly:!1,agentQueue:null};function qC(e){return e.length?{count:e.length,waitingOnly:e.every(t=>Mb(t)),agentQueue:e.map(t=>Yg(t.execution)).find(Boolean)??null}:cv}a(qC,"summarizeLiveRuns");function L$(e,t){return(t??[]).find(n=>n.status==="running")??(t??[]).find(n=>n.status==="queued")??null??(e?.status==="running"||e?.status==="queued"?e:null)}a(L$,"resolveInterruptibleIssueRun");function BC(e,t,n){const r=e.getQueryData(G.issues.liveRuns(t)),i=e.getQueryData(G.issues.activeRun(t)),o=!!(i&&r?.some(d=>d.id===i.id)),l=!!(i&&n?.executionRunId&&i.id===n.executionRunId),c=o||l?i:null;return{liveRuns:r,activeRun:c,interruptibleIssueRun:L$(c,r)}}a(BC,"readIssueRunStateFromCache");function dv(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}a(dv,"asRecord");function Ode(e){const t=dv(e.metadata);if(!t)return null;const n=$1.safeParse(t.resourceRef);return n.success?n.data:null}a(Ode,"extractWorkspaceFileRefFromWorkProduct");function yb(e,...t){if(!e)return 0;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return 0}a(yb,"usageNumber");function FC(e){const t=e.name.toLowerCase();return t.endsWith(".md")||t.endsWith(".markdown")||e.type==="text/markdown"}a(FC,"isMarkdownFile");function qde(e){return e.replace(/\.[^.]+$/,"")}a(qde,"fileBaseName");function Bde(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"document"}a(Bde,"slugifyDocumentKey");function Fde(e){return e.split(/[-_ ]+/g).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}a(Fde,"titleizeFilename");function zde(e,t,n){const r=new Date,i=e??[],o=i.findIndex(l=>l.targetType===t.targetType&&l.targetId===t.targetId&&(!n||l.authorUserId===n));if(o>=0){const l=i[o],c={...l,vote:t.vote,reason:t.reason!==void 0?t.reason.trim()||null:l.reason,updatedAt:r},d=[...i];return d[o]=c,d}return[...i,{id:`optimistic:${t.targetType}:${t.targetId}`,companyId:"",issueId:t.issueId,targetType:t.targetType,targetId:t.targetId,authorUserId:n??"current-user",vote:t.vote,reason:t.reason?.trim()||null,sharedWithLabs:!1,sharedAt:null,consentVersion:null,redactionSummary:null,createdAt:r,updatedAt:r}]}a(zde,"mergeOptimisticFeedbackVote");function Ude({evt:e,agentMap:t,userProfileMap:n}){const r=e.actorId;if(e.actorType==="agent"){const i=t.get(r);return(0,s.jsx)(Pp,{agent:i??{id:r,name:r.slice(0,8)},size:"sm"})}if(e.actorType==="system")return(0,s.jsx)(Nu,{name:"System",size:"sm"});if(e.actorType==="user"){const i=n?.get(r);return(0,s.jsx)(Nu,{name:i?.label??"Board",avatarUrl:i?.image,size:"sm"})}return(0,s.jsx)(Nu,{name:r||"Unknown",size:"sm"})}a(Ude,"ActorIdentity");function zC(e){const t=e.trim().split(/\s+/);return t.length>=2?(t[0][0]+t[t.length-1][0]).toUpperCase():e.slice(0,2).toUpperCase()}a(zC,"attributionInitials");function UC({label:e,actor:t,via:n}){const r=n?`${e}: ${t.name} · via ${n}`:`${e}: ${t.name}`,i=e.toLowerCase();return(0,s.jsxs)(wa,{children:[(0,s.jsx)(ka,{asChild:!0,children:(0,s.jsx)("span",{"aria-label":r,"data-testid":`issue-${i}-avatar`,children:t.kind==="agent"?(0,s.jsx)(un,{agent:t,size:20}):(0,s.jsxs)(_l,{size:"xs",className:"ring-2 ring-background",children:[t.avatarUrl?(0,s.jsx)(Id,{src:t.avatarUrl,alt:""}):null,(0,s.jsx)(Sl,{children:zC(t.name)})]})})}),(0,s.jsx)(ja,{side:"top",sideOffset:6,className:"px-2 py-1.5",children:(0,s.jsxs)("div",{className:"flex items-center gap-2","data-testid":`issue-${i}-tooltip`,children:[t.kind==="agent"?(0,s.jsx)(un,{agent:t,size:32}):(0,s.jsxs)(_l,{size:"sm",className:"ring-1 ring-background/30",children:[t.avatarUrl?(0,s.jsx)(Id,{src:t.avatarUrl,alt:""}):null,(0,s.jsx)(Sl,{children:zC(t.name)})]}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("div",{className:"text-(length:--text-nano) font-medium uppercase leading-none text-background/70",children:e}),(0,s.jsx)("div",{className:"max-w-48 truncate text-xs font-medium leading-4 text-background",children:t.name}),n?(0,s.jsxs)("div",{className:"max-w-48 truncate text-(length:--text-nano) leading-3 text-background/60",children:["via ",n]}):null]})]})})]})}a(UC,"AttributionAvatar");function Wde({issue:e,agentMap:t,userProfileMap:n,userLabelMap:r}){const i=e.assigneeAgentId?{kind:"agent",id:e.assigneeAgentId,appearance:t.get(e.assigneeAgentId)?.appearance,name:t.get(e.assigneeAgentId)?.name??e.assigneeAgentId.slice(0,8)}:e.assigneeUserId?{kind:"user",id:e.assigneeUserId,name:kb(e.assigneeUserId,r)??n.get(e.assigneeUserId)?.label??"User",avatarUrl:n.get(e.assigneeUserId)?.image??null}:null,o=SA(e),l=o?o.kind==="agent"?{kind:"agent",id:o.id,appearance:t.get(o.id)?.appearance,name:t.get(o.id)?.name??o.id.slice(0,8)}:{kind:"user",id:o.id,name:kb(o.id,r)??n.get(o.id)?.label??"User",avatarUrl:n.get(o.id)?.image??null}:null,c=o?.kind==="user"&&o.viaAgentId?t.get(o.viaAgentId)?.name??o.viaAgentId.slice(0,8):null;return!i&&!l?null:(0,s.jsx)(kh,{children:(0,s.jsxs)(xD,{className:"-space-x-1.5","aria-label":"Task people","data-testid":"issue-attribution-avatar-stack",children:[i?(0,s.jsx)(UC,{label:"Assignee",actor:i}):null,l?(0,s.jsx)(UC,{label:"Originating",actor:l,via:c}):null]})})}a(Wde,"IssueAttributionByline");function Uk({titleWidth:e="w-28",rows:t=3}){return(0,s.jsxs)("div",{className:"space-y-3 rounded-lg border border-border p-3",children:[(0,s.jsx)(As,{className:E("h-4",e)}),(0,s.jsx)("div",{className:"space-y-2",children:Array.from({length:t}).map((n,r)=>(0,s.jsx)(As,{className:"h-12 w-full rounded-md"},r))})]})}a(Uk,"IssueSectionSkeleton");function xp({side:e,className:t}){const n=e==="human";return(0,s.jsxs)("div",{className:E("flex w-full flex-col gap-1",n?"items-end":"items-start"),children:[n?null:(0,s.jsxs)("span",{className:"flex items-center gap-2 px-1",children:[(0,s.jsx)(As,{className:"h-6 w-6 rounded-full"}),(0,s.jsx)(As,{className:"h-3 w-24"})]}),(0,s.jsx)(As,{className:E("max-w-(--pct-85)",n?"rounded-2xl rounded-br-sm":"rounded-2xl rounded-bl-sm",t)})]})}a(xp,"ChatBubbleSkeleton");function O$(){return(0,s.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"issue-chat-skeleton",children:[(0,s.jsx)(xp,{side:"agent",className:"h-16 w-3/4"}),(0,s.jsx)(xp,{side:"human",className:"h-9 w-1/2"}),(0,s.jsx)(xp,{side:"agent",className:"h-24 w-4/5"}),(0,s.jsx)(xp,{side:"human",className:"h-8 w-2/5"})]})}a(O$,"IssueChatSkeleton");function Wk(e=!1){const{enabled:t,loaded:n}=gq(),{enabled:r,loaded:i}=ef(),{enabled:o,loaded:l}=Bi(),c=r||o,d=t&&!e&&!o,m=!d;return{coordinatorWorkspaceEnabled:o,classicTaskInterfaceEnabled:d,taskChatShellEnabled:m,streamlinedTaskDetailEnabled:c&&m,streamlinedUiEnabled:c,loaded:n&&i&&l}}a(Wk,"useTaskDetailInterfaceMode");function uv({headerSeed:e,titleEditor:t}){const n=e?.identifier??e?.id.slice(0,8)??null,{taskChatShellEnabled:r,streamlinedUiEnabled:i,coordinatorWorkspaceEnabled:o,loaded:l}=Wk(),{isMobile:c}=Qh();return t?(0,s.jsxs)("div",{className:"max-w-3xl space-y-6",children:[(0,s.jsx)("div",{"data-testid":"issue-detail-header",children:t}),(0,s.jsx)("div",{role:"status","aria-label":"Loading conversation",className:"flex items-center justify-center",children:(0,s.jsx)(As,{"aria-hidden":"true",className:"h-4 w-24"})})]}):l?r?(0,s.jsx)("div",{"data-task-chat-shell":"",className:"flex h-full min-h-0 w-full flex-1 flex-col",children:(0,s.jsx)(qE,{mobile:c,streamlined:i,coordinator:o})}):(0,s.jsxs)("div",{className:"max-w-3xl space-y-6",children:[(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(As,{className:"h-3 w-40"}),(0,s.jsx)("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ti,{...Ma(e)}),!1,n?(0,s.jsx)("span",{className:"text-sm font-mono text-muted-foreground shrink-0",children:n}):null,e.originKind==="routine_execution"&&e.originId?(0,s.jsxs)($t,{variant:"outline",className:"border-violet-500/30 bg-violet-500/10 text-(length:--text-nano) text-violet-600 dark:text-violet-400",title:`Routine execution from routine ${e.originId}`,children:[(0,s.jsx)(vl,{className:"h-3 w-3"}),"Routine"]}):null,e.projectId?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground rounded px-1 -mx-1 py-0.5 min-w-0",children:[(0,s.jsx)(qu,{size:"xs"}),(0,s.jsx)("span",{className:"truncate",children:e.projectName??e.projectId.slice(0,8)})]}):(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground opacity-50 px-1 -mx-1 py-0.5",children:[(0,s.jsx)(qu,{size:"xs"}),"No project"]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(As,{className:"h-6 w-6"}),(0,s.jsx)(As,{className:"h-6 w-6"}),(0,s.jsx)(As,{className:"h-4 w-20"}),(0,s.jsx)(As,{className:"h-4 w-28"})]})}),e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("h2",{className:"text-xl font-bold",children:e.title}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(As,{className:"h-4 w-full max-w-xl"}),(0,s.jsx)(As,{className:"h-4 w-(--pct-72)"})]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(As,{className:"h-8 w-(--sz-calc-37)"}),(0,s.jsx)(As,{className:"h-16 w-full"})]})]}),(0,s.jsx)(As,{className:"h-28 w-full rounded-lg border border-border"}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(As,{className:"h-8 w-20"}),(0,s.jsx)(As,{className:"h-8 w-20"})]}),(0,s.jsx)(O$,{})]}),(0,s.jsx)(Uk,{titleWidth:"w-24",rows:3})]}):(0,s.jsx)("div",{"data-testid":"task-detail-presentation-loading",role:"status","aria-label":"Loading conversation",className:"flex h-full min-h-0 w-full flex-1 items-center justify-center",children:(0,s.jsx)(As,{"aria-hidden":"true",className:"h-4 w-24"})})}a(uv,"IssueDetailLoadingState");function Kde({backHref:e,preferHistoryBack:t,issueId:n,issueHidden:r,onArchive:i,archivePending:o,onCopy:l,onProperties:c,onHide:d}){const m=Jh(),[h,f]=(0,u.useState)(!1);return(0,s.jsxs)("div",{className:"flex items-center w-full",children:[(0,s.jsx)(W,{variant:"ghost",size:"icon-sm",onClick:a(()=>{t&&window.history.length>1?m(-1):m(e)},"onClick"),"aria-label":"Back to inbox",children:(0,s.jsx)(s1,{className:"h-5 w-5"})}),(0,s.jsxs)("div",{className:"ml-auto flex items-center gap-0.5",children:[n&&!r&&(0,s.jsx)(W,{variant:"ghost",size:"icon-sm",onClick:i,disabled:o,"aria-label":"Archive from inbox",children:(0,s.jsx)(Lu,{className:"h-5 w-5"})}),(0,s.jsxs)(Da,{open:h,onOpenChange:f,children:[(0,s.jsx)(La,{asChild:!0,children:(0,s.jsx)(W,{variant:"ghost",size:"icon-sm","aria-label":"More actions",children:(0,s.jsx)(o6,{className:"h-5 w-5"})})}),(0,s.jsxs)(Oa,{className:"w-44 p-1",align:"end",children:[(0,s.jsxs)("button",{className:"flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",onClick:a(()=>{l(),f(!1)},"onClick"),children:[(0,s.jsx)(yr,{className:"h-3 w-3"}),"Copy as markdown"]}),(0,s.jsxs)("button",{className:"flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",onClick:a(()=>{c(),f(!1)},"onClick"),children:[(0,s.jsx)(Du,{className:"h-3 w-3"}),"Properties"]}),n&&(0,s.jsxs)("button",{className:"flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 text-destructive",onClick:a(()=>{d(),f(!1)},"onClick"),children:[(0,s.jsx)(Nh,{className:"h-3 w-3"}),"Hide this task"]})]})]})]})]})}a(Kde,"InboxMobileToolbar");(0,u.lazy)(()=>lq(()=>import("./DesignSandboxTaskThread-CGU--FXR.js"),__vite__mapDeps([0,1,2,3])));var Vde=(0,u.memo)(a(function({executionBlocked:t,interruption:n,retryPreparing:r,queryIssueId:i,hasLiveConnection:o,browsers:l,onOpenBrowser:c,onOpenSkill:d,issueId:m,companyId:h,projectId:f,issueWorkMode:p,issueStatus:g,issueAssigneeAgentId:b,executionRunId:y,blockedBy:x,liveIssueIds:v,blockerAttention:k,stalledDependencies:w,successfulRunHandoff:j,scheduledRetry:_,recoveryAction:I,onResolveRecoveryAction:T,onReissueIsolatedRecoveryAction:F,reissueIsolatedRecoveryActionPending:O,onReconcileForwardRecoveryAction:z,onBreakGlassOverrideRecoveryAction:q,onQuarantineRestoreRecoveryAction:A,quarantineRestoreRecoveryActionPending:H,canBreakGlassRecoveryAction:B,reconcileRecoveryActionPending:C,canFalsePositiveRecoveryAction:S,legacyRecoverySourceIssue:L,comments:M,commentsInitialLoading:R=!1,historyExpanded:V=!0,onExpandHistory:J,hasEarlierMessages:Q=!1,initialHistoryPending:Z=!1,initialMetadataPending:P=!1,initialHistoryError:te=!1,onRetryInitialHistory:ne,locallyQueuedCommentRunIds:ge,interactions:K,documents:ee,createdTasks:ce,workProducts:ie,attachments:ke,hasOlderComments:_e,commentsLoadingOlder:je,commentsOlderError:ae=!1,onLoadOlderComments:de,onRefreshLatestComments:Se,onWorkModeChange:De,composerRef:nt,composerAccessory:Re,threadHeader:ye,issueBrief:Ne,footer:xe,feedbackVotes:Pe,feedbackDataSharingPreference:Ee,feedbackTermsUrl:jt,agentMap:oe,currentUserId:re,userLabelMap:le,userProfileMap:mt,draftKey:Pt,reassignOptions:Nt,currentAssigneeValue:Dt,assigneeAdapterOverrides:Wt,suggestedAssigneeValue:Zt,mentions:es,conversationMode:Ke,composerPause:ps,composerDisabledReason:an,composerHint:vs,queuedCommentReason:ms,onVote:Rs,onAdd:ts,onImageUpload:Ds,onAttachImage:fn,onInterruptQueued:ht,onRemoveCommentFromCache:Ls,onDeleteComment:An,onPauseWorkRun:ws,onStopResponse:Kt,stopResponsePending:zn,pauseWorkPending:Un,pauseWorkScope:Yn,runFinalizationActions:bn,onCancelQueued:gs,interruptingQueuedRunId:pn,pausingWorkRunId:rs,onImageClick:Jt,onAcceptInteraction:yn,onRejectInteraction:ss,onSubmitInteractionAnswers:Ae,onCancelInteraction:Qe,onSkipInteraction:ot,onDismissInteraction:fe,onSubmitInteractionVerdicts:Be,assigneeUserId:rt,onResumeFromBacklog:X,resumeFromBacklogPending:pe,onResumeAssignee:ze,resumeAssigneePending:yt,onTryAgainNoLiveExecutionPath:ct,tryAgainNoLiveExecutionPathPending:Ts,externalReferences:Wn,linkCaseReferences:Es}){const ns=(0,u.useContext)(qD),Ws=ns?K.find(ic):void 0,Is=ns?M.find(Ie=>Ie.authorType==="user"&&!Ie.deletedAt&&!Ie.createdByRunId):void 0,me=!!(ns?.animate&&!Is),st=me&&!Ws&&!ns?.runId,Ge=ns&&M.find(Ie=>!Ie.deletedAt&&(Ws?.sourceCommentId===Ie.id||Ie.authorType==="system"&&Ie.metadata?.onboardingWelcomeAgentId||Ie.authorType==="agent"&&(st||ns.runId!=null&&Ie.createdByRunId===ns.runId))),at=Ge?Ge.createdByRunId??ns?.runId:ns?.runId,$=me&&Ge&&ns?{phase:"welcome",commentId:Ge.id,onComplete:ns.completeAnimation}:ns?.revealingChoices&&!Is?{phase:"choices",onComplete:ns.completeChoices}:void 0,xt=(0,u.useMemo)(()=>K.filter(Ie=>!ic(Ie)||Ie.status!=="pending"||!me&&!Is),[K,me,Is]),{classicTaskInterfaceEnabled:bt,streamlinedTaskDetailEnabled:tn}=Wk(!!Ke),wr=bt?Ene:sae;QA();const Ze=ys(),ft=i??m,wt=qi(),qt=WA(),{pushToast:it}=lm(),{data:ks,isPending:Ye,isError:Fa,refetch:ai}=Te({queryKey:V?G.issues.activity(ft):hq(ft),queryFn:a(()=>V?io.forIssue(ft):kL(Ze,ft),"queryFn"),enabled:!!m,placeholderData:V?Ze.getQueryData([...G.issues.activity(ft),"recent"]):void 0}),kr=Mj(M),mr=Tj(oj(ft),kr,Ie=>yl(Ze,[...oj(ft),"batch",Ie],ft,Rt=>hL(Mj(Rt.recentComments.comments),Ie)?Rt.commentInputFacts:void 0,()=>io.inputFactsForIssue(ft,Ie)),!!m&&!V),{data:Kn,isFetched:Jn,isError:hr,refetch:fr}=Te({queryKey:G.issues.liveRuns(ft),queryFn:a(()=>yl(Ze,G.issues.liveRuns(ft),ft,Ie=>Ie.liveRuns,()=>qn.liveRunsForIssue(ft)),"queryFn"),enabled:!!m,refetchInterval:a(Ie=>$p(o,Ie.state,1e3),"refetchInterval"),placeholderData:Mr(ft)}),Os=Kn??[],vn=Os.length,pr=!!y||g==="in_progress",{data:Gr=null,isFetched:jr,isError:da,refetch:Fi}=Te({queryKey:G.issues.activeRun(ft),queryFn:a(()=>yl(Ze,G.issues.activeRun(ft),ft,Ie=>Ie.activeRun,()=>qn.activeRunForIssue(ft)),"queryFn"),enabled:pr,refetchInterval:a(Ie=>vn>0?!1:$p(o,Ie.state,1e3),"refetchInterval"),placeholderData:Mr(ft)}),qs=(0,u.useMemo)(()=>sG({status:g,executionRunId:y},Gr,Kn),[Gr,y,g,Kn]),Dr=!!(b&&oe.get(b)?.adapterType==="paperclip_runner"),Ia=qs??Os.find(Ie=>Ie.status==="running"||Ie.status==="queued")??null,rr=Jn&&(!pr||jr),Yr=!bt&&rr&&!!(Ia||b),{data:on}=Te({queryKey:G.issues.queuedComments(m),queryFn:a(async()=>WI(await $e.getQueuedComments(m),m),"queryFn"),enabled:Yr,refetchInterval:a(Ie=>Yr&&(Ia||Ie.state.data?.entries.length)?1e3:!1,"refetchInterval")}),[Vn,zs]=(0,u.useState)(()=>new Set),[Je,hs]=(0,u.useState)(()=>new Set),[Sa,Hn]=(0,u.useState)(()=>new Map),[Pn,za]=(0,u.useState)(()=>new Map),[Nr,Jr]=(0,u.useState)(null);(0,u.useEffect)(()=>{zs(new Set),hs(new Set)},[m]),(0,u.useEffect)(()=>{Hn(new Map),za(new Map),Jr(null)},[m]);const _a=vn>0||!!qs,ua=V?G.issues.runs(ft):qO(ft),{data:Xn,isPending:ln,isError:Qn,refetch:He}=Te({queryKey:ua,queryFn:a(()=>V?io.runsForIssue(ft):p4(Ze,ft,{conversationMode:Ke}),"queryFn"),enabled:!!m,refetchInterval:_a||g==="in_progress"?1e3:!1,placeholderData:V?Ze.getQueryData([...G.issues.runs(ft),"recent-window"])?.runs:void 0}),At=(0,u.useMemo)(()=>[...new Set([...M.flatMap(Ie=>[Ie.createdByRunId,Ie.derivedCreatedByRunId]),...(mr.data??[]).flatMap(Ie=>[Ie.runId,Ie.details?.targetRunId])].filter(Ie=>typeof Ie=="string"&&qg(Ie)))].sort(),[M,mr.data]),Mt=Tj([...G.issues.runs(ft),"comment-window"],At,Ie=>io.runsByIdsForIssue(ft,Ie),!!m&&!!Ke&&!V),Ss=(0,u.useMemo)(()=>[...new Map([...Array.isArray(Xn)?Xn:Xn?.runs??[],...Ke&&!V?Mt.data??[]:[]].map(Ie=>[Ie.runId,Ie])).values()],[Xn,Ke,V,Mt.data]),Gt=Array.isArray(Xn)?void 0:Xn?.earlierRun,Rn=!Array.isArray(Xn)&&Xn?.hasEarlierRuns===!0&&!(Gt?.status==="succeeded"&&p3(M,Gt.runId,Gt.resultJson)),sn=(0,u.useMemo)(()=>[...new Map([...ks??[],...mr.data??[]].map(Ie=>[Ie.id,Ie])).values()],[ks,mr.data]),Ks=Ss??[];(0,u.useEffect)(()=>{Xw({activity:!Ye,"linked-runs":!ln,runtime:rr})},[m,ft,Ye,ln,rr]);const Bs=ut({mutationFn:a(async Ie=>{const Rt=Ks.find(Ft=>Ft.runId===Ie);if(!Rt)throw new Error("Failed run is no longer available.");return $r.retryFailedRun(Rt.agentId,Rt.runId,h)},"mutationFn"),onSuccess:a(Ie=>{Ie.runId||it({title:"Retry queued",body:"The exact request will retry when this task is ready.",tone:"success"})},"onSuccess"),onSettled:a(()=>{Ze.invalidateQueries({queryKey:G.issues.runs(ft)}),Ze.invalidateQueries({queryKey:G.issues.liveRuns(ft)}),Ze.invalidateQueries({queryKey:G.issues.activeRun(ft)})},"onSettled"),onError:a((Ie,Rt)=>{const Ft=Ks.find(as=>as.runId===Rt);it(lG(Ie,Ft?oe.get(Ft.agentId):void 0)??{title:"Run retry failed",body:Ie instanceof Error?Ie.message:"Unable to retry run",tone:"error"})},"onError")}),gn=(0,u.useMemo)(()=>L$(qs,Os),[qs,Os]),Ca=gn?oe.get(gn.agentId):null,Dn=Ca?.adapterType==="paperclip_runner"&&Ca.adapterConfig.provider==="grok_bot",Ir=ut({mutationFn:a(Ie=>k4.stop(h,Ie.agentId,Ie.id),"mutationFn"),onSettled:a((Ie,Rt,Ft)=>Promise.all([Ze.invalidateQueries({queryKey:G.issues.detail(m)}),Ze.invalidateQueries({queryKey:G.issues.runs(m)}),Ze.invalidateQueries({queryKey:["grok-binding",h,Ft.agentId]})]),"onSettled")}),vt=(0,u.useMemo)(()=>{const Ie=new Set;for(const Rt of Os)Ie.add(Rt.id);return qs&&Ie.add(qs.id),Ie},[qs,Os]),ii=(0,u.useMemo)(()=>(vt.size===0?Ks:Ks.filter(Ie=>!vt.has(Ie.runId))).map(Ie=>({...Ie,adapterType:Ie.adapterType,hasStoredOutput:(Ie.logBytes??0)>0})),[vt,Ks]),Zn=(0,u.useMemo)(()=>{const Ie=gn?.startedAt??gn?.createdAt??null,Rt=new Map,Ft=new Set,as=new Map,Ct=new Map;for(const Le of Ks){if(as.set(Le.runId,Le.agentId),Le.status==="queued"||!Le.startedAt)continue;const pt=Array.isArray(Le.wakeCommentIds)?Le.wakeCommentIds.filter(lr=>typeof lr=="string"&&lr.length>0):[],is=typeof Le.wakeCommentId=="string"&&Le.wakeCommentId.length>0?Le.wakeCommentId:typeof Le.contextCommentId=="string"&&Le.contextCommentId.length>0?Le.contextCommentId:null,_s=Array.isArray(Le.firstTurnCommentIds)?Le.firstTurnCommentIds.filter(lr=>typeof lr=="string"&&lr.length>0):[],ds=[...new Set([...pt.length>0?pt:is?[is]:[],..._s])],Gn=Le.startedAt??Le.createdAt,Fs=new Date(Gn).getTime();ds.forEach((lr,Sr)=>{const Ot=Ct.get(lr),Hs=Ot?.queueIds??new Set;if(Le.wakeupRequestId&&Hs.add(Le.wakeupRequestId),Array.isArray(Le.queuedCommentSourceWakeIds))for(const Lr of Le.queuedCommentSourceWakeIds)Hs.add(Lr);Ot&&Ot.anchorMs<=Fs||Ct.set(lr,{runId:Le.runId,anchorAt:Gn,sequence:Sr,anchorMs:Fs,kind:"run_start",queueIds:Hs})})}for(const Le of[qs,...Os]){if(!Le||Le.status!=="running"||!Le.startedAt)continue;const pt=new Date(Le.startedAt).toISOString();for(const is of[Le.contextCommentId,Le.contextWakeCommentId]){if(!is)continue;const _s=Ct.get(is),ds=_s?.queueIds??new Set;if(Le.wakeupRequestId&&ds.add(Le.wakeupRequestId),Array.isArray(Le.queuedCommentSourceWakeIds))for(const Gn of Le.queuedCommentSourceWakeIds)ds.add(Gn);_s||Ct.set(is,{runId:Le.id,anchorAt:pt,sequence:0,anchorMs:new Date(pt).getTime(),kind:"run_start",queueIds:ds})}}const It=sn.filter(Le=>Le.action==="issue.queued_comment_steered").sort((Le,pt)=>new Date(Le.createdAt).getTime()-new Date(pt.createdAt).getTime()),cs=new Map;for(const Le of It){const pt=Le.details??{};if(pt.duplicate===!0)continue;const is=typeof pt.commentId=="string"?pt.commentId:null,_s=typeof pt.targetRunId=="string"?pt.targetRunId:null;if(!is||!_s)continue;const ds=Le.createdAt instanceof Date?Le.createdAt.toISOString():Le.createdAt,Gn=new Date(ds).getTime();if(!Number.isFinite(Gn))continue;const Fs=cs.get(_s)??0;cs.set(_s,Fs+1),Ct.set(is,{runId:_s,anchorAt:ds,sequence:Fs,anchorMs:Gn,kind:"steer",queueIds:Ct.get(is)?.queueIds??new Set})}const js=on?.targetRunId??null;if(js){const Le=new Map(M.map(pt=>[pt.id,pt.createdAt]));on?.firstTurnCommentIds?.forEach((pt,is)=>{const _s=Le.get(pt);if(Ct.has(pt)||!_s)return;const ds=new Date(_s).toISOString();Ct.set(pt,{runId:js,anchorAt:ds,sequence:is,anchorMs:new Date(ds).getTime(),kind:"run_start",queueIds:new Set(on.queueId?[on.queueId]:[])})})}for(const[Le,pt]of Sa)Ct.has(Le)||Ct.set(Le,{runId:pt.targetRunId,anchorAt:pt.anchorAt,sequence:pt.sequence,anchorMs:new Date(pt.anchorAt).getTime(),kind:"steer",queueIds:new Set});for(const Le of sn){if(Le.action!=="issue.comment_added"||!Le.runId)continue;const pt=Le.details??{},is=typeof pt.commentId=="string"?pt.commentId:null;if(!is||Rt.has(is))continue;const _s=typeof pt.interruptedRunId=="string"?pt.interruptedRunId:null;Rt.set(is,{runId:Le.runId,runAgentId:Le.agentId??as.get(Le.runId)??null,interruptedRunId:_s})}for(const Le of sn){if(Le.action!=="issue.comment_added")continue;const pt=Le.details??{},is=typeof pt.commentId=="string"?pt.commentId:null;is&&(pt.followUpRequested===!0||pt.resumeIntent===!0)&&Ft.add(is)}const ir=[...M],or=new Set(M.map(Le=>Le.id));for(const Le of[...Sa.values(),...Pn.values()])Le.comment&&!or.has(Le.comment.id)&&(ir.push(Le.comment),or.add(Le.comment.id));const oi=ir.map(Le=>{if(Le.authorType==="system"&&Ke&&Le.metadata?.onboardingWelcomeAgentId)return{...Le,authorType:"agent",authorAgentId:Le.metadata.onboardingWelcomeAgentId,runId:null};if(Le.metadata?.chatMessage)return{...Le,runId:null};const pt=Rt.get(Le.id),is=Le.authorType==="agent"&&Le.authorAgentId?Le.createdByRunId:null,_s=is?{runId:is,runAgentId:Le.authorAgentId,interruptedRunId:pt?.runId===is?pt.interruptedRunId:null}:pt,ds=Le.id===Ws?.sourceCommentId?void 0:Ct.get(Le.id),Gn=new Date(Le.createdAt).getTime(),Fs=ds?.kind==="run_start"?Ks.find(Zr=>Zr.runId===ds.runId):void 0,lr=Fs?new Date(Fs.startedAt??Fs.createdAt).getTime():NaN,Sr=!!(Fs?.contextIssueId===m&&Number.isFinite(lr)&&Number.isFinite(Gn)&&Ks.some(Zr=>{if(Zr.runId===Fs.runId||Zr.agentId!==Fs.agentId||Zr.contextIssueId!==m||!Zr.finishedAt)return!1;const Ui=new Date(Zr.startedAt??Zr.createdAt).getTime(),Tn=new Date(Zr.finishedAt).getTime();return Number.isFinite(Ui)&&Number.isFinite(Tn)&&Ui<=Gn&&Gn<=Tn&&Tn<=lr})),Ot={...Le,..._s??{},...ds?{consumedByRunId:ds.runId,consumedQueueIds:[...ds.queueIds],...ds.kind==="steer"?{steeredIntoRunId:ds.runId}:{},conversationAnchorAt:ds.anchorAt,conversationAnchorSequence:ds.sequence}:{}};(Ft.has(Le.id)||Sr)&&(Ot.followUpRequested=!0);const Hs=ge.get(Le.id)??Ot.queueTargetRunId??null;if(ds)return{...Ot,clientStatus:void 0,queueState:void 0,queueTargetRunId:null,queueReason:void 0};const Lr=jO(Ot,{queuedTargetRunId:Hs,targetRunIsLive:Hs?vt.has(Hs):!1,runningRunId:gn?.id??null});return Lr!==Ot?Lr:Hs?Ot:PD({comment:Ot,activeRunStartedAt:Ie,activeRunAgentId:gn?.agentId??null,activeRunCommentId:gn?.contextCommentId??null,activeRunWakeCommentId:gn?.contextWakeCommentId??null,runId:_s?.runId??Ot.runId??null,interruptedRunId:_s?.interruptedRunId??Ot.interruptedRunId??null})?{...Ot,queueState:"queued",queueTargetRunId:gn?.id??null,queueReason:ms}:Ot}),zi=new Map;for(const Le of sn){if(Le.action!=="issue.question_response_delivered")continue;const pt=Le.details??{},is=typeof pt.interactionId=="string"?pt.interactionId:null,_s=typeof pt.targetRunId=="string"?pt.targetRunId:null;!is||!_s||zi.has(is)||zi.set(is,{targetRunId:_s,deliveryMode:typeof pt.deliveryMode=="string"?pt.deliveryMode:null})}const vi=bt?[]:K.flatMap(Le=>{const pt=Le.kind==="ask_user_questions"&&Le.status==="answered",is=LC(Le)&&(Le.status==="accepted"||Le.status==="rejected");if(!pt&&!is||!Le.resolvedAt)return[];const _s=Le.resolvedAt instanceof Date?Le.resolvedAt:new Date(Le.resolvedAt);if(Number.isNaN(_s.getTime()))return[];const ds=pt?zi.get(Le.id)??null:null,Gn=Le.sourceRunId&&gn?.id===Le.sourceRunId&&gn.adapterType!=="paperclip_runner"?Le.sourceRunId:null,Fs=Le.kind==="ask_user_questions"?T6(Le):LC(Le)?$de(Le):"";return[{id:`interaction-response:${Le.id}`,companyId:Le.companyId,issueId:Le.issueId,authorType:Le.resolvedByAgentId?"agent":"user",authorAgentId:Le.resolvedByAgentId??null,authorUserId:Le.resolvedByUserId??null,createdByRunId:Le.resolvedByRunId??null,body:Fs,presentation:null,metadata:null,createdAt:_s,updatedAt:_s,consumedByRunId:ds?.targetRunId??null,...ds?.deliveryMode==="steered"?{steeredIntoRunId:ds.targetRunId}:{},conversationAnchorAt:_s,conversationAnchorSequence:0,...Gn?{queueState:"queued",queueTargetRunId:Gn,queueReason:ms}:{}}]});return[...oi,...vi]},[Ke,Ws?.sourceCommentId,on,M,bt,K,vt,Sa,Pn,ge,ms,sn,Ks,qs,Os,gn]),ar=(0,u.useMemo)(()=>XQ(on,Ks),[on,Ks]),xs=(0,u.useMemo)(()=>{if(!Yr)return null;const Ie=new Map,Rt=new Map;for(const It of Zn)It.consumedByRunId&&(Ie.set(It.id,It.consumedByRunId),Rt.set(It.id,It.consumedQueueIds??[]));const Ft=on?{...on,entries:on.entries.filter(It=>!Vn.has(It.comment.id)&&!Je.has(It.comment.id)&&!Rt.get(It.comment.id)?.includes(on.queueId??"")&&Ie.get(It.comment.id)!==on.targetRunId)}:null,as=Zn.flatMap(It=>{if(Vn.has(It.id)||Ie.has(It.id)||Je.has(It.id)||It.steeredIntoRunId)return[];const cs=ge.get(It.id)??("clientStatus"in It&&It.clientStatus==="queued"||It.queueState==="queued"?It.queueTargetRunId??null:null);return cs&&!vt.has(cs)&&!It.id.startsWith("optimistic-")?[]:cs?[{comment:It,targetRunId:cs}]:[]}),Ct=Ia?.adapterType==="paperclip_runner"||!Ia&&Dr?"paperclip_runner_v1":"legacy";return tG({issueId:m,authoritativeQueue:Ft,pendingComments:as,fallbackProtocol:Ct})},[on,Zn,Vn,Je,m,vt,Ia,Dr,ge,Yr]),wn=(0,u.useMemo)(()=>{if(!xs)return null;const Ie=xs.entries.filter(Rt=>!ar.has(Rt.comment.id)).map((Rt,Ft)=>({...Rt,position:Ft}));return Ie.length?{...xs,entries:Ie}:null},[xs,ar]),Ua=(0,u.useMemo)(()=>[...Zn,...(on?.entries??[]).filter(Ie=>ar.has(Ie.comment.id)&&!Zn.some(Rt=>Rt.id===Ie.comment.id)).map(Ie=>Ie.comment)].flatMap(Ie=>Je.has(Ie.id)?[]:!Vn.has(Ie.id)&&!ar.has(Ie.id)?[Ie]:[{...Ie,...!Ie.consumedByRunId&&Pn.has(Ie.id)?{conversationAnchorAt:Pn.get(Ie.id).anchorAt,conversationAnchorSequence:Pn.get(Ie.id).sequence}:{},clientStatus:void 0,queueState:void 0,queueTargetRunId:null,queueReason:void 0}]),[Zn,Vn,Je,Pn,on,ar]),nn=(0,u.useCallback)(Ie=>{const Rt=WI(Ie,m);return Ze.setQueryData(G.issues.queuedComments(m),Rt),Rt},[m,Ze]),Vs=(0,u.useCallback)(async Ie=>{throw Ie instanceof mn&&Ie.status===409&&await Ze.invalidateQueries({queryKey:G.issues.queuedComments(m)}),Ie},[m,Ze]),kn=(0,u.useCallback)(async(Ie,Rt,Ft)=>{const as=xs?.queueId;if(!as)throw new Error("The queued message is awaiting server acknowledgement.");try{nn(await $e.editQueuedComment(m,Ie,{body:Rt,queueId:as,revision:Ft})),await Ze.invalidateQueries({queryKey:G.issues.comments(m)})}catch(Ct){await Vs(Ct)}},[xs?.queueId,m,Ze,Vs,nn]),rn=(0,u.useCallback)(async(Ie,Rt)=>{const Ft=xs?.queueId;if(!Ft)throw new Error("The queued messages are awaiting server acknowledgement.");try{const as=new Set(on?.firstTurnCommentIds??[]),Ct=a(ir=>ar.has(ir)||as.has(ir),"hidden"),It=on?.queueId===Ft?on.entries:xs.entries;let cs=0;const js=It.map(ir=>Ct(ir.comment.id)?ir.comment.id:Ie[cs++]);nn(await $e.reorderQueuedComments(m,{orderedCommentIds:js,queueId:Ft,revision:Rt}))}catch(as){await Vs(as)}},[on,xs,ar,m,Vs,nn]),er=(0,u.useCallback)(async(Ie,Rt)=>{const Ft=xs?.queueId,as=xs?.targetRunId;if(!Ft||!as)throw new Error("The queued message no longer has an active run target.");const Ct=new Date().toISOString();Hn(It=>{const cs=new Map(It),js=[...It.values()].filter(ir=>ir.targetRunId===as).length;return cs.set(Ie,{targetRunId:as,anchorAt:Ct,sequence:js,comment:xs?.entries.find(ir=>ir.comment.id===Ie)?.comment}),cs}),zs(It=>new Set(It).add(Ie));try{const It=await $e.steerQueuedComment(m,Ie,{queueId:Ft,targetRunId:as,revision:Rt});nn(It),Promise.all([Ze.invalidateQueries({queryKey:G.issues.comments(m)}),Ze.invalidateQueries({queryKey:G.issues.activity(ft)})])}catch(It){zs(cs=>{const js=new Set(cs);return js.delete(Ie),js}),Hn(cs=>{const js=new Map(cs);return js.delete(Ie),js}),await Vs(It)}},[xs,m,ft,Ze,Vs,nn]),Bt=(0,u.useCallback)(async Ie=>{const Rt=xs?.targetRunId===Ie?xs.entries.map(Ct=>Ct.comment):Zn.filter(Ct=>Ct.queueState==="queued"&&Ct.queueTargetRunId===Ie),Ft=Rt.map(Ct=>Ct.id),as=new Date().toISOString();Jr(null),zs(Ct=>new Set([...Ct,...Ft])),za(Ct=>{const It=new Map(Ct);return Rt.forEach((cs,js)=>{It.set(cs.id,{anchorAt:as,sequence:js,comment:cs})}),It});try{const Ct=await ht(Ie);if(Ct?.state==="deferred"&&!Qw(Ct)){const It=new Set(Ct.entries.map(cs=>cs.comment.id));zs(cs=>new Set([...cs].filter(js=>!It.has(js)))),za(cs=>new Map([...cs].filter(([js])=>!It.has(js)))),nn(Ct),bt&&Jr(Ct.executionWait?.message??"Messages are still queued.")}return Ct}catch(Ct){if(zs(It=>{const cs=new Set(It);for(const js of Ft)cs.delete(js);return cs}),za(It=>{const cs=new Map(It);for(const js of Ft)cs.delete(js);return cs}),bt){Jr("Couldn’t interrupt. Message is still queued.");return}throw await Vs(Ct),Ct}},[xs,Zn,ht,nn,Vs,bt]),Ml=(0,u.useCallback)(async(Ie,Rt)=>{const Ft=xs?.queueId;try{Ft?nn(await $e.discardQueuedComment(m,Ie,{queueId:Ft,revision:Rt})):await $e.cancelComment(m,Ie),hs(as=>new Set(as).add(Ie)),Ft||Ze.invalidateQueries({queryKey:G.issues.queuedComments(m)}),await Ls(Ie),await Ze.invalidateQueries({queryKey:G.issues.comments(m)})}catch(as){const Ct=as instanceof mn&&typeof as.body=="object"&&as.body!==null?as.body:null,It=Ct&&typeof Ct.details=="object"&&Ct.details!==null?Ct.details:null;(typeof It?.code=="string"?It.code:typeof Ct?.code=="string"?Ct.code:null)==="queued_comment_already_dispatching"&&it({title:"Message is already being sent",body:"The continuation started before the discard was confirmed, so Microvac could not unsend it.",tone:"error",ttlMs:15e3,dedupeKey:`queued-comment-already-dispatching:${m}:${Ie}`}),await Vs(as)}},[xs?.queueId,m,Ls,it,Ze,Vs,nn]),Xr=(0,u.useMemo)(()=>JQ(sn),[sn]),ma=(0,u.useMemo)(()=>YQ(sn),[sn]),Aa=Ke?{hasMore:!!_e,loading:je,error:ae,load:de}:void 0,ha=!Ke&&_e?(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(W,{type:"button",variant:"outline",size:"sm",disabled:je,onClick:de,children:je?"Loading earlier comments...":"Load earlier comments"})}):null;return(0,s.jsxs)("div",{className:bt?"space-y-3":"flex min-h-0 flex-1 flex-col",children:[bt?ha:null,bt&&R&&Zn.length===0&&K.length===0?(0,s.jsx)(O$,{}):(0,s.jsx)(lE.Provider,{value:{...dE(wt),restore:qt==="POP"},children:(0,s.jsx)(XK,{companyId:h,issueId:m,children:(0,s.jsx)(z2.Provider,{value:Ke?null:oe,children:(0,u.createElement)(wr,{...bt?{}:{compactHistory:!V,onExpandHistory:Ke?void 0:J,scrollingHistory:Aa,historyControl:Ke?null:!V&&(Q||Rn)?(0,s.jsx)(W,{type:"button",variant:"ghost",size:"sm",onClick:J,children:"More messages"}):null},executionBlocked:t,interruption:n,retryPreparing:r,key:Ke?Pt:m,...bt?{}:{creationActivity:sn,createdTasks:ce},onOpenSkill:d,browsers:l,onOpenBrowser:c,hasOlderComments:_e,initialHistoryPending:!!m&&(Z||R||P||Ye||ln||Ke&&At.length>0&&Mt.isPending||mr.isLoading||!rr),initialHistoryError:te||Fa||!V&&mr.isError||Qn||Ke&&Mt.isError||hr||pr&&da,onRetryInitialHistory:a(()=>{ne?.(),ai(),!V&&kr.length&&mr.refetch(),He(),Ke&&At.length&&Mt.refetch(),fr(),pr&&Fi()},"onRetryInitialHistory"),composerRef:nt,composerAccessory:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(hQ,{}),Re]}),threadHeader:!bt&&(ye||ha)?(0,s.jsxs)(s.Fragment,{children:[ye,ha]}):null,issueBrief:Ne,comments:Ua,interactions:xt,...$?{onboardingWelcomeAnimation:$}:{},documents:ee,workProducts:ie,attachments:ke,feedbackVotes:Pe,feedbackDataSharingPreference:Ee,feedbackTermsUrl:jt,linkedRuns:at?ii.filter(Ie=>Ie.runId!==at):ii,onRetryFailedRun:a(Ie=>Bs.mutateAsync(Ie).then(()=>{}),"onRetryFailedRun"),retryFailedRunId:Bs.isPending?Bs.variables:null,timelineEvents:Xr,workModeChanges:ma,liveRuns:at?Os.filter(Ie=>Ie.id!==at):Os,activeRun:at&&qs?.id===at?null:qs,issueId:m,blockedBy:x??[],liveIssueIds:v,blockerAttention:k,stalledDependencies:w,successfulRunHandoff:j,scheduledRetry:_,recoveryAction:QE(I?.cause)?null:I??null,onResolveRecoveryAction:T,onReissueIsolatedRecoveryAction:F,reissueIsolatedRecoveryActionPending:O,onReconcileForwardRecoveryAction:z,onBreakGlassOverrideRecoveryAction:q,onQuarantineRestoreRecoveryAction:A,quarantineRestoreRecoveryActionPending:H,canBreakGlassRecoveryAction:B,reconcileRecoveryActionPending:C,canFalsePositiveRecoveryAction:S,legacyRecoverySourceIssue:L??null,companyId:h,projectId:f,issueStatus:g,issueAssigneeAgentId:b,agentMap:oe,currentUserId:re,userLabelMap:le,userProfileMap:mt,draftKey:Pt,conversationMode:Ke,enableReassign:!Ke,reassignOptions:Nt,currentAssigneeValue:Dt,assigneeAdapterOverrides:Wt,suggestedAssigneeValue:Zt,mentions:es,composerPause:ps,composerDisabledReason:an,composerHint:vs,onVote:Rs,onAdd:ts,imageUploadHandler:Ds,onAttachImage:fn,onInterruptQueued:Bt,queuedCommentQueue:wn,onEditQueuedComment:kn,onReorderQueuedComments:rn,onSteerQueuedComment:er,onDiscardQueuedComment:Ml,onDeleteComment:An,onCancelQueued:gs,interruptingQueuedRunId:pn,stoppingRunId:Ir.isPending?Ir.variables.id:Un?rs??gn?.id??null:rs,onStopRun:Dn||ws?async Ie=>{const Rt=Os.find(as=>as.id===Ie)??(qs?.id===Ie?qs:null),Ft=Rt?oe.get(Rt.agentId):null;Rt&&Ft?.adapterType==="paperclip_runner"&&Ft.adapterConfig.provider==="grok_bot"?await Ir.mutateAsync(Rt).catch(()=>{}):ws&&await ws(Ie).catch(()=>{})}:void 0,stopRunLabel:Dn?"Stop Microvac work":"Pause work",stoppingRunLabel:Dn?"Stopping Microvac work…":"Pausing...",stopRunVariant:Dn?"stop":"pause",runFinalizationActions:bn,onAcceptInteraction:yn,onRejectInteraction:ss,onSubmitInteractionAnswers:a((Ie,Rt)=>Ae(Ie,Rt),"onSubmitInteractionAnswers"),onCancelInteraction:Qe,onSkipInteraction:ot,onDismissInteraction:fe,onSubmitInteractionVerdicts:Be,issueWorkMode:p,onWorkModeChange:De,stopPending:Dn?Ir.isPending:zn,onCancelRun:Dn&&gn?()=>Ir.mutateAsync(gn).then(()=>{}):gn&&Kt?()=>Kt(gn.id):void 0,onImageClick:Jt,onRefreshLatestComments:Se,assigneeUserId:rt,onResumeFromBacklog:X,resumeFromBacklogPending:pe,onResumeAssignee:ze,resumeAssigneePending:yt,onTryAgainNoLiveExecutionPath:ct,tryAgainNoLiveExecutionPathPending:Ts,footer:Dn||Ir.error||Nr?(0,s.jsxs)(s.Fragment,{children:[Dn&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Runs in Grok Bot · Usage not reported. Stop Microvac work revokes this session’s authority; remote execution may continue. Open the Grok Bot desktop app to inspect it."}),Ir.error&&(0,s.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:Ps(Ir.error).body}),Nr&&(0,s.jsx)("p",{role:"status",className:"text-sm text-destructive",children:Nr}),xe]}):xe,externalReferences:Wn,linkCaseReferences:Es})})})})]})},"IssueDetailChatTab"));function Hde({issue:e,issueId:t,companyId:n,issueStatus:r,childIssues:i,agentMap:o,hasLiveRuns:l,currentUserId:c,userProfileMap:d,pendingApprovalAction:m,onApprovalAction:h,handoffFocusSignal:f=0,externalReferences:p}){const{data:g,isLoading:b}=Te({queryKey:G.issues.activity(t),queryFn:a(()=>io.forIssue(t),"queryFn"),placeholderData:Mr(t)}),{data:y,isLoading:x}=Te({queryKey:G.issues.runs(t),queryFn:a(()=>io.runsForIssue(t),"queryFn"),placeholderData:Mr(t)}),{data:v}=Te({queryKey:G.issues.approvals(t),queryFn:a(()=>$e.listApprovals(t),"queryFn"),placeholderData:Mr(t)}),{data:k}=Te({queryKey:G.issues.document(t,Rb),queryFn:a(async()=>{try{return await $e.getDocument(t,Rb)}catch(O){if(O instanceof mn&&O.status===404)return null;throw O}},"queryFn"),placeholderData:Mr(t)}),{data:w}=Te({queryKey:G.issues.costSummary(t),queryFn:a(()=>$e.getCostSummary(t),"queryFn"),placeholderData:Mr(t)}),j=b&&g===void 0||x&&y===void 0,_=(0,u.useMemo)(()=>{let O=0,z=0,q=0,A=0,H=0,B=0,C=0,S=!1,L=!1;const M=Date.now();for(const R of y??[]){const V=dv(R.usageJson),J=dv(R.resultJson),Q=yb(V,"inputTokens","input_tokens"),Z=yb(V,"outputTokens","output_tokens"),P=yb(V,"cachedInputTokens","cached_input_tokens","cache_read_input_tokens"),te=WO(V,J);if(te>0&&(S=!0),Q+Z+P>0&&(L=!0),O+=Q,z+=Z,q+=P,A+=oq(V),H+=te,R.startedAt){const ne=new Date(R.startedAt).getTime(),ge=R.finishedAt?new Date(R.finishedAt).getTime():M;Number.isFinite(ne)&&Number.isFinite(ge)&&ge>=ne&&(B+=ge-ne,C+=1)}}return{input:O,output:z,cached:q,cost:H,totalTokens:A,hasCost:S,hasTokens:L,runtimeMs:B,runCount:C,hasRuntime:B>0}},[y]),I=(w?.inputTokens??0)+(w?.cachedInputTokens??0)+(w?.outputTokens??0),T=!!w&&(w.costCents>0||I>0||w.cachedInputTokens>0||w.runtimeMs>0||w.issueCount>1),F=y&&y.length>0||T;return j?(0,s.jsx)(Uk,{titleWidth:"w-20",rows:4}):(0,s.jsxs)(s.Fragment,{children:[F&&(0,s.jsxs)("div",{className:"mb-3 px-3 py-2 rounded-lg border border-border",children:[(0,s.jsx)("div",{className:"text-sm font-medium text-muted-foreground mb-1",children:"Cost Summary"}),!_.hasCost&&!_.hasTokens&&!T?(0,s.jsx)("div",{className:"text-xs text-muted-foreground",children:"No cost data yet."}):(0,s.jsxs)("div",{className:"space-y-1 text-xs text-muted-foreground tabular-nums",children:[(0,s.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,s.jsx)("span",{className:"font-medium text-foreground",children:"This task"}),_.hasCost?(0,s.jsxs)("span",{className:"font-medium text-foreground",children:["$",_.cost.toFixed(4)]}):null,_.hasTokens?(0,s.jsxs)("span",{children:["Tokens ",Ci(_.totalTokens),_.cached>0?` (in ${Ci(_.input)}, out ${Ci(_.output)}, cached ${Ci(_.cached)})`:` (in ${Ci(_.input)}, out ${Ci(_.output)})`]}):null,_.hasRuntime?(0,s.jsxs)("span",{children:["Runtime ",jb(_.runtimeMs),` (${_.runCount} run${_.runCount===1?"":"s"})`]}):null,!_.hasCost&&!_.hasTokens&&!_.hasRuntime?(0,s.jsx)("span",{children:"No direct cost data."}):null]}),T&&w?(0,s.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,s.jsxs)("span",{className:"font-medium text-foreground",children:["Including sub-tasks"," ",(w.costCents/100).toLocaleString(void 0,{style:"currency",currency:"USD",minimumFractionDigits:4,maximumFractionDigits:4})]}),(0,s.jsxs)("span",{children:["Tokens ",Ci(I),w.cachedInputTokens>0?` (in ${Ci(w.inputTokens)}, out ${Ci(w.outputTokens)}, cached ${Ci(w.cachedInputTokens)})`:` (in ${Ci(w.inputTokens)}, out ${Ci(w.outputTokens)})`]}),w.runCount>0?(0,s.jsxs)("span",{children:["Runtime ",jb(w.runtimeMs),` (${w.runCount} run${w.runCount===1?"":"s"})`]}):null,(0,s.jsxs)("span",{children:[w.issueCount," task",w.issueCount===1?"":"s"]})]}):null]})]}),(0,s.jsx)("div",{className:"mb-3",children:(0,s.jsx)(Gce,{issueId:t,companyId:n,issueStatus:r,childIssues:i,agentMap:o,hasLiveRuns:l,activityEvents:g??[],resolveUserLabel:a(O=>d.get(O)?.label??null,"resolveUserLabel"),renderActivityEvent:a(O=>{const z=SL(O.action),q=O.action==="issue.successful_run_handoff_required"||O.action==="issue.successful_run_handoff_escalated";return(0,s.jsxs)("div",{className:E("space-y-1.5 rounded-lg border px-3 py-2 text-xs",z.className),children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[q?(0,s.jsx)(ls,{className:E("h-3.5 w-3.5 shrink-0",z.iconClassName)}):null,(0,s.jsx)(Ude,{evt:O,agentMap:o,userProfileMap:d}),(0,s.jsx)("span",{children:jde(O.action,O.details,{agentMap:o,userProfileMap:d,currentUserId:c})}),(0,s.jsx)("span",{className:"ml-auto shrink-0",children:va(O.createdAt)})]}),(0,s.jsx)(lie,{event:O}),(0,s.jsx)(gie,{event:O,resolveAgentLabel:a(A=>o.get(A)?.name??null,"resolveAgentLabel"),resolveUserLabel:a(A=>d.get(A)?.label??null,"resolveUserLabel")}),(()=>{const A=kie(O.action,O.details,{actorLabel:O.agentId?o.get(O.agentId)?.name??null:null,responsibleUserName:O.responsibleUserId?d.get(O.responsibleUserId)?.label??null:null});return A?(0,s.jsx)(vie,{code:A.code,context:A.context}):null})()]})},"renderActivityEvent")})}),(0,s.jsx)(nae,{document:k,focusSignal:f,externalReferences:p}),v&&v.length>0&&(0,s.jsx)("div",{className:"mb-3 space-y-3",children:v.map(O=>(0,s.jsx)(dG,{approval:O,requesterAgent:O.requestedByAgentId?o.get(O.requestedByAgentId)??null:null,onApprove:a(()=>h(O.id,"approve"),"onApprove"),onReject:a(()=>h(O.id,"reject"),"onReject"),detailLink:`/approvals/${O.id}`,isPending:m?.approvalId===O.id,pendingAction:m?.approvalId===O.id?m.action:null},O.id))}),(0,s.jsx)(ose,{issueId:e.id,scheduledRetry:e.scheduledRetry??null})]})}a(Hde,"IssueDetailActivityTab");function Qde({tasksTab:e}){return(0,s.jsx)(q$,{tasksTab:e})}a(Qde,"IssueDetail");function q$({conversation:e,tasksTab:t}){const{issueId:n,companyPrefix:r}=CL(),i=e?e.issue?.id:n,o=!!e,l=!!e?.issue,[c,d]=(0,u.useState)(null);(0,u.useEffect)(()=>d(null),[i,r]);const[m,h]=(0,u.useState)("standard"),f=(0,u.useMemo)(()=>e?MQ(e.agent,m):void 0,[e?.agent,m]),p=(0,u.useRef)(null),{companies:g,selectedCompanyId:b}=zg(),{classicTaskInterfaceEnabled:y,taskChatShellEnabled:x,streamlinedTaskDetailEnabled:v,streamlinedUiEnabled:k,loaded:w,coordinatorWorkspaceEnabled:j}=Wk(o),_=(QA()||j)&&v,I=x?"mx-auto w-full max-w-(--tc-shell-max-w)":void 0,{openNewIssue:T}=JP(),{openPanel:F,closePanel:O,panelVisible:z,setPanelVisible:q,setPanelShowsArtifact:A,requestPanelMaximize:H,clearPanelMaximizeRequest:B}=$A(),{setBreadcrumbs:C,setBreadcrumbToolbar:S,setBreadcrumbPanelControl:L,setMobileToolbar:M}=mO(),R=ys(),V=Jh(),J=WA(),Q=qi(),{pushToast:Z}=lm(),{isMobile:P}=Qh(),[te,ne]=(0,u.useState)(!1),[ge,K]=(0,u.useState)(!1),[ee,ce]=(0,u.useState)(!1),[ie,ke]=(0,u.useState)(null),[_e,je]=(0,u.useState)(null),[ae,de]=(0,u.useState)(null),Se=(0,u.useCallback)(N=>{de(Y=>Y?.id===N?null:Y)},[]),[De,nt]=(0,u.useState)(null),[Re,ye]=(0,u.useState)(!1),[Ne,xe]=(0,u.useState)("chat"),Pe=x?"chat":Ne,[Ee,jt]=(0,u.useState)(0),[oe,re]=(0,u.useState)(null),[le,mt]=(0,u.useState)(null),[Pt,Nt]=(0,u.useState)(!1),[Dt,Wt]=(0,u.useState)(!1),[Zt,es]=(0,u.useState)(0),[Ke,ps]=(0,u.useState)(!1),[an,vs]=(0,u.useState)(null),[ms,Rs]=(0,u.useState)("resume"),[ts,Ds]=(0,u.useState)(!1),[fn,ht]=(0,u.useState)([]),[Ls,An]=(0,u.useState)(()=>new Map),[ws,Kt]=(0,u.useState)(0),zn=(0,u.useRef)(null),Un=(0,u.useRef)(null),Yn=(0,u.useRef)(new Map),[bn,gs]=(0,u.useState)(0),pn=(0,u.useRef)(void 0),rs=(0,u.useRef)(null),Jt=(0,u.useRef)(new Set),yn=(0,u.useRef)(new Map),ss=(0,u.useMemo)(()=>Sj(i,Q.state,Q.search),[i,Q.state,Q.search]),Ae=(0,u.useMemo)(()=>{const N=ss??Q.state;return!v||typeof N!="object"||N===null?N:{...N,issueDetailInboxQuickArchiveArmed:!1}},[Q.state,ss,v]),Qe=(0,u.useMemo)(()=>Sj(null,Q.state)?.issueDetailSource==="inbox",[Q.state]),ot=(0,u.useMemo)(()=>sx(Q.state)??sx(ss),[Q.state,ss]),fe=g.find(N=>N.issuePrefix===r?.toUpperCase())?.id??b,Be=i?[...G.issues.detail(i),"core"]:null;if(i&&Be&&!e&&(R.getQueryData(Be)===void 0||KO(R,Be))){const N=R.getQueryData(Be);iL(R,fe,i,[N?.id,N?.identifier])}const rt=Te({...hA(R,i),enabled:!!i}),{historyExpanded:X,expandHistory:pe,recent:ze,retainComment:yt,acknowledgedComments:ct}=mQ(i,!!(!e&&!rt.data?.conversationAgentId&&w&&y),rt.data,!!(e||rt.data?.conversationAgentId)),Ts=!!(e||rt.data?.conversationAgentId),Wn=Te({...RO(R,i,{placeholderIssue:ot?{id:ot.id,identifier:ot.identifier}:null}),enabled:!!i&&(rt.isFetched||!!R.getQueryData(G.issues.detail(i)))}),{data:Es,isLoading:ns,isPlaceholderData:Ws,error:Is,refetch:me}=Wn,st=Sn(Ws?{...Wn,data:void 0}:Wn),Ge=Sn(rt);(0,u.useEffect)(()=>{i&&X&&nG(R,i)},[i,X,R]);const at=[Is,rt.error].find(N=>N instanceof mn&&[401,403,404].includes(N.status)),$=at?void 0:Es??rt.data??e?.issue??f,xt=$?.id,bt=(0,u.useCallback)(N=>{xt&&d(Y=>N?xt:Y===xt?null:Y)},[xt]),tn=a1($??void 0),wr=a(async()=>{if(!e)return i;const N=await e.ensureIssue(),Y=p.current;return Y!==null&&Y!==N.workMode&&await $e.update(N.id,{workMode:Y}),p.current=null,N.id},"resolveWritableIssueId"),Ze=!Ws&&!(Is&&!Es&&!rt.data)&&$&&i&&($.id.toLowerCase()===i.toLowerCase()||$.identifier?.toLowerCase()===i.toLowerCase())?$:null,ft=Ze?Ze.id:null;(0,u.useEffect)(()=>{ft&&cq(R,{id:ft})},[R,ft]);const wt=Ze?g.find(N=>N.id===Ze.companyId):void 0,qt=!!(e||Ze&&i===(Ze.identifier??Ze.id)&&(!wt||r===wt.issuePrefix)&&!Ij(Q.search)),it=$?.companyId??b,ks=wA({companyId:it,issueId:$?.id??i,issueQueryRef:i??"pending",assigneeAgentId:$?.assigneeAgentId}),Ye=GP(e&&!e.issue?null:$?.id??null),Fa=(0,u.useMemo)(()=>!!($?.currentExecutionWorkspace&&YF($.currentExecutionWorkspace)),[$?.currentExecutionWorkspace]),{data:ai,isLoading:kr,isError:mr,isFetchingNextPage:Kn,hasNextPage:Jn,fetchNextPage:hr,refetch:fr}=Dg({queryKey:G.issues.comments(i),queryFn:a(({pageParam:N})=>$e.listComments(i,{order:"desc",limit:50,...N?{after:N}:{}}),"queryFn"),enabled:!!i&&X,initialPageParam:null,getNextPageParam:a(N=>wD(N,50),"getNextPageParam"),placeholderData:Mr(i??"pending")}),Os=uQ(i,Ts,ze.data?.oldestCommentId,ze.data?.comments??[]),vn=Q.hash.startsWith("#comment-")?Q.hash.slice(9):null,pr=vn&&qg(vn)?vn.trim():null,Gr=(0,u.useMemo)(()=>Bm(ze.data?.comments??[],Ts?Os.data?.pages.flatMap(N=>N.comments)??[]:iD(ai?.pages),ct),[Ts,Os.data?.pages,ai?.pages,ze.data?.comments,ct]),jr=Te({queryKey:[...G.issues.comments(i),"linked",pr],queryFn:a(({signal:N})=>$e.getComment($.id,pr,{signal:N}),"queryFn"),enabled:!!$&&!!pr&&!X&&!Gr.some(N=>N.id===pr)});(0,u.useEffect)(()=>{const N=jr.data;!N||!ze.data||R.setQueryData([...G.issues.comments(i),"recent"],Y=>!Y||Y.comments.some(se=>se.id===N.id)?Y:{...Y,comments:Bm([N],Y.comments)})},[i,jr.data,ze.data,R]);const da=(0,u.useMemo)(()=>Bm(jr.data?[jr.data]:[],Gr),[jr.data,Gr]),Fi=(0,u.useRef)(1/0);(0,u.useLayoutEffect)(()=>{Fi.current=performance.now(),oG()},[i]);const qs=aG();a4(qs!==null,qs,{enabled:!!i}),(0,u.useEffect)(()=>{qs!==null&&qs>=Fi.current&&e?.onReady?.()},[qs,e?.onReady]),(0,u.useEffect)(()=>{},[i]),(0,u.useEffect)(()=>{!$||!w||!qt||wy(ZE,e5)},[$?.id,w,qt]),(0,u.useEffect)(()=>{!y||!$||kr||wy(Gw,Yw)},[y,kr,$?.id]);const Dr=!!(pr&&!da.some(N=>N.id===pr)&&!(X?mr:jr.isError)&&(X?kr||Jn:jr.isPending)),Ia=(0,u.useMemo)(()=>X&&pD({activeDetailTab:Ne,hasOlderComments:Jn??!1,loadedCommentCount:da.length,initialPageLoading:kr,olderPageLoading:Kn,autoLoadLimit:Pde}),[da.length,kr,Kn,X,Ne,Jn]),{data:rr=[],isLoading:Yr,isError:on,refetch:Vn}=Te({queryKey:G.issues.interactions(i),queryFn:a(()=>yl(R,G.issues.interactions(i),i,N=>N.interactions,()=>$e.listInteractions(i)),"queryFn"),enabled:!!i,refetchInterval:a(N=>HR(N.state.data,2e4),"refetchInterval"),placeholderData:Mr(i??"pending")}),{data:zs,isLoading:Je,isError:hs,refetch:Sa}=Te({queryKey:G.issues.attachments(i),queryFn:a(()=>yl(R,G.issues.attachments(i),i,N=>N.attachments,()=>$e.listAttachments(i)),"queryFn"),enabled:!!i,placeholderData:Mr(i??"pending")}),{data:Hn,isLoading:Pn,isError:za,refetch:Nr}=Hw(i);(0,u.useEffect)(()=>{Xw({issue:!!Ze,comments:!kr,interactions:!Yr,attachments:!Je,"work-products":!Pn})},[i,Ze,kr,Yr,Je,Pn]);const{data:Jr=cv}=Te({queryKey:G.issues.liveRuns(i),queryFn:a(()=>yl(R,G.issues.liveRuns(i),i,N=>N.liveRuns,()=>qn.liveRunsForIssue(i)),"queryFn"),enabled:!!i,refetchInterval:a(N=>$p(ks,N.state,3e3),"refetchInterval"),select:qC,placeholderData:Mr(i??"pending")}),_a=Jr.count,{data:ua=cv}=Te({queryKey:G.issues.activeRun(i),queryFn:a(()=>qn.activeRunForIssue(i),"queryFn"),enabled:!!i&&(!!$?.executionRunId||$?.status==="in_progress"),refetchInterval:a(N=>_a>0?!1:$p(ks,N.state,3e3),"refetchInterval"),select:a(N=>qC(N?[N]:[]),"select"),placeholderData:Mr(i??"pending")}),Xn=ua.count>0,ln=$?XE($)&&Xn:Xn,Qn=_a>0||ln,He=Qn&&(_a===0||Jr.waitingOnly)&&(!ln||ua.waitingOnly),At=Jr.agentQueue??(ln?ua.agentQueue:null);(0,u.useEffect)(()=>{!Qn&&Ls.size>0&&An(new Map)},[Qn,Ls.size]);const Mt=(0,u.useMemo)(()=>BP(i,Q.state,Q.search)??{label:"Tasks",href:"/issues"},[i,Q.state,Q.search]),{data:Ss,isLoading:Gt,isError:Rn,refetch:sn}=Te({queryKey:$?.id&&it?G.issues.listByDescendantRoot(it,$.id):["issues","parent","pending"],queryFn:a(()=>$e.listAll(it,{descendantOf:$.id,includeBlockedBy:!0}),"queryFn"),enabled:!!it&&!!$?.id&&!$.id.startsWith("chat:"),placeholderData:Mr($?.id??"pending")}),Ks=Ss??Om,Bs=Te({queryKey:G.issues.listCreatedFromIssue(it??"pending",$?.id??"pending"),queryFn:a(()=>$e.listAll(it,{createdFromIssueId:$.id,includeRoutineExecutions:!0}),"queryFn"),enabled:!!it&&!!$?.id&&!$.id.startsWith("chat:")&&(x&&!e||v&&!t)}),{data:gn,isLoading:Ca,isError:Dn}=Te({queryKey:$?.parentId&&it?G.issues.listByParent(it,$.parentId):["issues","siblings","pending"],queryFn:a(()=>$e.list(it,{parentId:$.parentId,includeBlockedBy:!0}),"queryFn"),enabled:!!it&&!!$?.parentId}),Ir=gn??Om,vt=it?G.liveRuns(it):["live-runs","pending"],ii=bO({companyId:it,resourceKey:"live-runs",queryKey:vt,enabled:!!it,refetchInterval:!1,leaderOnly:!0}),{data:Zn,dataUpdatedAt:ar}=Te({queryKey:vt,queryFn:a(()=>qn.liveRunsForCompany(it),"queryFn"),enabled:ii.enabled,refetchInterval:ii.refetchInterval,placeholderData:Mr(it??"pending")});$P(ii,Zn,ar);const{data:xs}=Te({queryKey:G.agents.list(b),queryFn:a(()=>$r.list(b),"queryFn"),enabled:!!b}),{data:wn}=Te({queryKey:G.access.companyUserDirectory(b),queryFn:a(()=>Eo.listUserDirectory(b),"queryFn"),enabled:!!b}),Ua=cde(),{data:nn=Om}=Te({queryKey:it?G.issues.mentionPool(it):["issues","mention-pool","pending"],queryFn:a(()=>$e.list(it,{limit:100,sortField:"updated",sortDir:"desc"}),"queryFn"),enabled:!!it&&Ua,staleTime:6e4,placeholderData:Mr(it??"pending")}),{data:Vs,isFetched:kn,dataUpdatedAt:rn}=Te({queryKey:G.auth.session,queryFn:a(()=>Ug.getSession(),"queryFn")}),{data:er=Ede}=Te({...Jg(b),enabled:!!b}),Bt=Vs?.user?.id??Vs?.session?.userId??null,Ml=(0,u.useRef)(null);(0,u.useEffect)(()=>{if(!(k||j)||!Ze||!kn||e||Ze.conversationAgentId||Ze.hiddenAt)return;const N=`${Ze.companyId}:${Bt}:${Ze.id}`;Sf(Ze,Bt,Ml.current===N?void 0:Date.now()),Ml.current=N},[Ze,Bt,kn,k,j,e]);const{data:Xr}=Te({queryKey:G.access.currentBoardAccess,queryFn:a(()=>Eo.getCurrentBoardAccess(),"queryFn"),enabled:!!Vs?.user?.id}),ma=!!(b&&Xr?.companyIds?.includes(b)),Aa=Kw(b,Xr),ha=UE(b,Xr),[Ie,Rt]=(0,u.useState)(!0),Ft=Ww(b,Xr),{data:as}=Te({queryKey:G.issues.feedbackVotes(i),queryFn:a(()=>$e.listFeedbackVotes(i),"queryFn"),enabled:!!i&&!!Bt}),{data:Ct}=Te({queryKey:G.instance.generalSettings,queryFn:a(()=>hc.getGeneral(),"queryFn"),enabled:!!i}),{data:It}=Te({queryKey:G.instance.experimentalSettings,queryFn:a(()=>hc.getExperimental(),"queryFn"),enabled:!!i}),cs=It?.enableCases===!0,js=Ct?.feedbackDataSharingPreference??"prompt",ir=It?.enableIssuePlanDecompositions===!0,or=It?.enableExperimentalFileViewer===!0,{orderedProjects:oi}=l1({projects:er,companyId:b,userId:Bt}),{slots:zi}=DA({slotTypes:["detailTab"],entityType:"issue",companyId:it,enabled:!!it}),vi=(0,u.useMemo)(()=>zi.map(N=>({value:`plugin:${N.pluginKey}:${N.id}`,label:N.displayName,slot:N})),[zi]),Le=vi.find(N=>N.value===Ne)??null,{data:pt,isFetching:is,error:_s,refetch:ds}=Te({queryKey:["issues","tree-control-preview",i??"pending",ms],queryFn:a(()=>$e.previewTreeControl(i,{mode:ms,releasePolicy:{strategy:"manual"}}),"queryFn"),enabled:Ke&&!!i&&ma,staleTime:0}),{data:Gn,error:Fs}=Te({queryKey:["issues","tree-control-state",i??"pending"],queryFn:a(()=>$e.getTreeControlState(i),"queryFn"),enabled:!!i}),{data:lr=[]}=Te({queryKey:["issues","tree-holds",i??"pending","active-pause-with-members"],queryFn:a(()=>$e.listTreeHolds(i,{status:"active",mode:"pause",includeMembers:!0}),"queryFn"),enabled:!!i&&Gn?.activePauseHold?.isRoot===!0}),{data:Sr=[]}=Te({queryKey:["issues","tree-holds",i??"pending","active-cancel"],queryFn:a(()=>$e.listTreeHolds(i,{status:"active",mode:"cancel"}),"queryFn"),enabled:!!i&&ma}),Ot=(0,u.useMemo)(()=>{const N=new Map;for(const Y of xs??[])N.set(Y.id,Y);return N},[xs]),Hs=(0,u.useMemo)(()=>qA(wn?.users),[wn?.users]),Lr=(0,u.useMemo)(()=>PA(wn?.users),[wn?.users]),Zr=BE($,Bt,Xr),Ui=(0,u.useMemo)(()=>{if(!$)return[];const N=[],Y=new Set,se=a((Fe,Xe)=>{if(!Fe||Y.has(`user:${Fe}`))return;Y.add(`user:${Fe}`);const St=Hs.get(Fe);N.push({id:`user:${Fe}`,displayName:St?.label??Fe.slice(0,5),roleLabel:Xe,avatarUrl:St?.image??null})},"pushUser"),ve=a((Fe,Xe)=>{if(!Fe||Y.has(`agent:${Fe}`))return;Y.add(`agent:${Fe}`);const St=Ot.get(Fe);N.push({id:`agent:${Fe}`,displayName:St?.name??Fe.slice(0,8),roleLabel:Xe})},"pushAgent");return se($.responsibleUserId,"Owner"),ve($.assigneeAgentId,"Assignee"),se($.assigneeUserId,"Assignee"),N},[$,Hs,Ot]),Tn=(0,u.useMemo)(()=>JO({agents:xs,projects:oi,members:wn?.users,issues:nn}),[xs,wn?.users,oi,nn]),jn=(0,u.useMemo)(()=>$?.projectId?oi.find(N=>N.id===$.projectId)??$.project??null:null,[$?.project,$?.projectId,oi]),Ht=(0,u.useMemo)(()=>[...$?.id?MO($.id,Ks):Ks].sort((N,Y)=>new Date(N.createdAt).getTime()-new Date(Y.createdAt).getTime()),[$?.id,Ks]),Vo=(0,u.useMemo)(()=>[...Ht.filter(N=>N.parentId===$?.id),...Bs.data??Om],[Ht,Bs.data,$?.id]),Wi=(0,u.useMemo)(()=>{if(t)return t;if(!v)return;const N=Bs.data??Om,Y=Bs.isError||Rn;return{count:new Set([...$?.createdFrom?[$.createdFrom.issue]:[],...$?.ancestors??[],...Ht,...N].map(se=>se.id)).size,hasError:Y,content:(0,s.jsx)(WQ,{ancestors:$?.ancestors,createdFrom:$?.createdFrom,issueLinkState:ss??Q.state,subtasks:Ht,createdTasks:N,projects:er,isLoading:Bs.isLoading||Gt,hasError:Y,onRetry:a(()=>{Bs.refetch(),sn()},"onRetry")})}},[t,$?.ancestors,$?.createdFrom,ss,Q.state,v,Ht,Gt,Rn,sn,er,Bs.data,Bs.isError,Bs.isLoading,Bs.refetch]),Wa=(0,u.useMemo)(()=>lO(Zn,$?[$,...Ht]:Ht),[Ht,Zn,$]),$l=(0,u.useMemo)(()=>Nde($??null,Ht),[Ht,$]),ea=(0,u.useMemo)(()=>$??null,[$?.id,$l]),Ki=(0,u.useMemo)(()=>Ht,[$l]),Ka=x&&$?.originKind==="onboarding_first_task",Ho=x&&(Ka||$?.workMode==="planning"),Qo=rr.some(N=>N.status==="pending"&&N.kind==="request_confirmation"&&N.payload.target?.type==="issue_document"&&N.payload.target.key==="plan"),{data:Yt}=pf(Ho||Qo?$?.id:null),Pl=rr.some(N=>N.status==="pending"&&!_6(N)&&!j3(N,Yt)),[xo,Lc]=(0,u.useState)(null),jm=xo!==null&&xo===$?.id,Ln=Ho&&kle({deferredPlanAvailable:!!Yt,panelBeforePlanOverride:jm}),Or=(0,u.useCallback)(()=>{Ln&&$?.id&&Lc($.id),q(!0)},[$?.id,q,Ln]),Dl=(0,u.useCallback)(()=>je(null),[]),Vi=(0,u.useCallback)((N,Y)=>{$?.id&&(je({issueId:$.id,id:N,title:Y,requestId:Date.now()}),Or(),P&&ce(!0))},[$?.id,Or,P]),Oc=(0,u.useRef)(null);(0,u.useEffect)(()=>{if(!j||!$?.id)return;const N=new URLSearchParams(Q.hash.split("&").slice(1).join("&")).get("attachment")??new URLSearchParams(Q.search).get("attachmentId");if(!N){Oc.current=null;return}const Y=`${$.id}:${Q.key}:${N}`;if(Oc.current===Y)return;const se=zs?.find(ve=>ve.id===N);se&&(Oc.current=Y,Vi(se.id,se.originalFilename??"Attachment"))},[j,$?.id,Q.hash,Q.search,Q.key,zs,Vi]),(0,u.useEffect)(()=>{if(!$?.id)return;const N=Vu(Q.hash);if(!N||!N.startsWith("interaction-")&&!N.startsWith("decision-")||!j&&!N.startsWith("decision-"))return;const Y=a(()=>{const Fe=document.getElementById(N);return Fe?(Fe.tabIndex=-1,Fe.scrollIntoView({block:"center",behavior:"instant"}),Fe.focus({preventScroll:!0}),!0):!1},"focusDecision");if(Y())return;const se=new MutationObserver(()=>{Y()&&se.disconnect()});se.observe(document.getElementById("main-content")??document.body,{subtree:!0,childList:!0});const ve=window.setTimeout(()=>se.disconnect(),1e4);return()=>{se.disconnect(),window.clearTimeout(ve)}},[j,$?.id,Q.hash,Q.key]);const cr=j?`coordinator:${Bt??"anonymous"}`:Bt??"anonymous",{panels:Va,isLoading:qc}=yQ($,x),Kd=(0,u.useRef)(new Set),Ll=(0,u.useRef)(new Set),wi=(0,u.useRef)(new Set);(0,u.useEffect)(()=>{for(const N of Va){if(!N.autoOpen||!N.runId)continue;const Y=FE(N,cr,$);Kd.current.has(Y)||(Kd.current.add(Y),!wi.current.has(Y)&&(Or(),P&&ce(!0)))}},[Va,cr,$?.companyId,$?.id,Or,P]);const Ol=zE($?.id,$?.companyId),{openBrowserId:Go,openBrowser:Vd,acknowledgeBrowserOpened:Yo}=wQ(Bt??"anonymous",$?.id,Ol.data);(0,u.useEffect)(()=>{Go&&(Or(),P&&ce(!0))},[Go,Or,P]);const Bc=(0,u.useCallback)((N,Y)=>{const se=jle({panelBeforePlanOverrideIssueId:xo},{id:N,name:Y},$?.id??null,Ln);de(se.skill),Lc(se.panelBeforePlanOverrideIssueId),q(!0),P&&ce(!0)},[P,$?.id,xo,q,Ln]),Hd=(0,u.useCallback)(()=>{$?.id&&ke(N=>({issueId:$.id,requestId:(N?.requestId??0)+1}))},[$?.id]),li=(0,u.useCallback)(N=>{ke(Y=>Y?.requestId===N?{...Y,handled:!0}:Y)},[]);Qle({issueId:x?$?.id:void 0,attachments:zs,workProducts:Hn,documents:$?.documentSummaries,onArrival:Hd});const tr=(0,u.useCallback)(()=>{if(P){ce(N=>!N);return}if(!z||Ln){Or();return}q(!1)},[P,Or,z,q,Ln]),fa=S4(Gt,Ht.length),Jo=(0,u.useMemo)(()=>$&&!Gt&&!Ca&&!Dn?Aq($,Ir,Ht):null,[Ht,Gt,$,Ir,Dn,Ca]),ki=(0,u.useCallback)(()=>{$&&T(tx($,Bt))},[Bt,$,T]),Fc=(0,u.useMemo)(()=>{const N=[];N.push(...c1(wn?.users,{excludeUserIds:[Bt]}));const Y=[...xs??[]].filter(Eb).sort((se,ve)=>se.name.localeCompare(ve.name));for(const se of Y)N.push({id:`agent:${se.id}`,label:se.name});return Bt&&N.push({id:`user:${Bt}`,label:"Me"}),N},[xs,wn?.users,Bt]),bo=(0,u.useMemo)(()=>cD($??{}),[$]),{data:ql}=Te({queryKey:G.issues.activity(i),queryFn:a(()=>io.forIssue(i),"queryFn"),enabled:!!(i&&Bt&&$?.assigneeUserId===Bt)}),Bl=(0,u.useMemo)(()=>eL($??{},cj(da??[],fn),Bt,void 0,ql),[$,da,fn,Bt,ql]),zc=(0,u.useMemo)(()=>cj(da??[],fn).filter(N=>!(N.authorType==="system"&&N.metadata?.recoveryResponsibility==="system")).map(N=>{"clientId"in N&&N.clientId&&yn.current.set(N.id,N.clientId);const Y=yn.current.get(N.id);return Y?{...N,clientId:Y}:N}),[da,fn]),Fl=$?.title??ot?.title??"",Ha=$?.identifier??ot?.identifier??(i&&/^[a-z0-9]+-\d+$/i.test(i)?i:$?.id.slice(0,8)),yo=$?.status??ot?.status,qr=$?.blockerAttention,Uc=yo?`${yo}|${$?.displayStatus??ot?.displayStatus??""}|${$?.externalConversationState??""}|${JSON.stringify(qr??null)}`:"loading-task-status",Ms=(0,u.useMemo)(()=>yo?(0,s.jsx)(ti,{status:yo,displayStatus:$?.displayStatus??ot?.displayStatus,externalConversationState:$?.externalConversationState,className:"size-3",blockerAttention:qr}):(0,s.jsx)("span",{"aria-hidden":"true",className:"size-3 shrink-0"}),[Uc]),Cs=(0,u.useMemo)(()=>{const N=new Set;return i&&N.add(i),$?.id&&N.add($.id),$?.identifier&&N.add($.identifier),[...N]},[$?.id,$?.identifier,i]),Vt=(0,u.useCallback)(()=>{for(const N of Cs)R.invalidateQueries({queryKey:G.issues.detail(N)}),R.invalidateQueries({queryKey:G.issues.activity(N)}),R.invalidateQueries({queryKey:G.issues.interactions(N)})},[Cs,R]),ci=(0,u.useCallback)(()=>{for(const N of Cs)R.invalidateQueries({queryKey:G.issues.detail(N),refetchType:"inactive"}),R.invalidateQueries({queryKey:G.issues.activity(N),refetchType:"inactive"}),R.invalidateQueries({queryKey:G.issues.interactions(N),refetchType:"inactive"})},[Cs,R]),Br=(0,u.useCallback)(()=>{for(const N of Cs)R.invalidateQueries({queryKey:G.issues.runs(N)}),R.invalidateQueries({queryKey:G.issues.liveRuns(N)}),R.invalidateQueries({queryKey:G.issues.activeRun(N)})},[Cs,R]),Xo=(0,u.useCallback)(()=>{R.invalidateQueries({queryKey:["issues","document-annotations",i]}),R.invalidateQueries({queryKey:G.issues.documents(i)})},[i,R]),Zo=(0,u.useCallback)(async N=>{await Promise.all(Cs.map(Y=>R.cancelQueries({queryKey:G.issues.comments(Y)})));for(const Y of Cs)R.setQueryData([...G.issues.comments(Y),"linked",N],se=>se&&null),R.setQueryData(G.issues.comments(Y),se=>se&&{...se,pages:z4(se.pages,N)}),R.setQueryData(G.issues.acknowledgedComments(Y),se=>se?.filter(ve=>ve.id!==N)),R.setQueryData(G.issues.earlierComments(Y),se=>se&&{...se,pages:se.pages.map(ve=>({...ve,comments:ve.comments.filter(Fe=>Fe.id!==N)}))}),R.setQueryData([...G.issues.comments(Y),"recent"],se=>{if(!se)return se;const ve=Bm(se.comments.filter(Fe=>Fe.id!==N));return{...se,comments:ve,latestCommentId:se.latestCommentId===N?ve.at(-1)?.id??null:se.latestCommentId}})},[Cs,R]),zl=(0,u.useCallback)(N=>{typeof window>"u"||window.location.hash===`#comment-${N}`&&window.history.replaceState(null,"",`${Q.pathname}${Q.search}`)},[Q.pathname,Q.search]),el=(0,u.useCallback)(async N=>{await Promise.all(Cs.map(Y=>R.cancelQueries({queryKey:G.issues.comments(Y)})));for(const Y of Cs)R.setQueryData([...G.issues.comments(Y),"linked",N.id],se=>se&&N),R.setQueryData(G.issues.comments(Y),se=>se&&{...se,pages:Sm(se.pages,N)}),R.setQueryData(G.issues.acknowledgedComments(Y),se=>se?.map(ve=>ve.id===N.id?N:ve)),R.setQueryData(G.issues.earlierComments(Y),se=>se&&{...se,pages:se.pages.map(ve=>({...ve,comments:ve.comments.map(Fe=>Fe.id===N.id?N:Fe)}))}),R.setQueryData([...G.issues.comments(Y),"recent"],se=>se&&{...se,comments:se.comments.map(ve=>ve.id===N.id?N:ve)})},[Cs,R]),Hi=(0,u.useCallback)(N=>{rs.current?.restoreDraft(N)},[]),Qs=(0,u.useCallback)(()=>{b&&(R.invalidateQueries({queryKey:G.issues.list(b)}),R.invalidateQueries({queryKey:G.issues.listMineByMe(b)}),R.invalidateQueries({queryKey:G.issues.listTouchedByMe(b)}),R.invalidateQueries({queryKey:G.issues.listUnreadTouchedByMe(b)}),R.invalidateQueries({queryKey:G.sidebarBadges(b)}))},[R,b]),Wc=(0,u.useCallback)(async(N,Y,se)=>{Y&&(await fj(R,Y),TD(Y,N),_j(R,se,N));try{await $e.unarchiveFromInbox(N),Z({title:"Task restored to inbox",tone:"success"})}catch(ve){Y&&(bj(Y,N),K0(R,Y,N),uj(Y,N)),Z({title:"Undo failed",body:ve instanceof Error?ve.message:"Unable to restore this task to the inbox",tone:"error"})}finally{Y&&await wb(R,Y)}},[Z,R]),Qi=(0,u.useCallback)(N=>{oA(R,N.companyId,N),R.setQueryData(G.issues.interactions(i),Y=>{const se=(Y??[]).filter(ve=>ve.id!==N.id);return se.push(N),se.sort((ve,Fe)=>{const Xe=new Date(ve.createdAt).getTime()-new Date(Fe.createdAt).getTime();return Xe===0?ve.id.localeCompare(Fe.id):Xe}),se})},[i,R]),vo=(0,u.useCallback)((N,Y)=>{R.setQueriesData({queryKey:["issues","detail"]},se=>se&&Hj(se,N)?{...se,...Y}:se),b&&R.setQueryData(G.issues.list(b),se=>se?.map(ve=>Hj(ve,N)?{...ve,...Y}:ve))},[R,b]),Kc=Gl({mutationFn:a(N=>(N.attemptedSessionAt=R.getQueryState(G.auth.session)?.dataUpdatedAt??0,$e.markRead(N.issueId)),"mutationFn"),onSuccess:a((N,Y)=>{Y.confirmed=!0,R.invalidateQueries({queryKey:G.issues.summaries(Y.companyId)}),b&&(R.invalidateQueries({queryKey:G.issues.listMineByMe(b)}),R.invalidateQueries({queryKey:G.issues.listTouchedByMe(b)}),R.invalidateQueries({queryKey:G.issues.listUnreadTouchedByMe(b)}),R.invalidateQueries({queryKey:G.sidebarBadges(b)}))},"onSuccess"),onFinished:a(N=>{Yn.current.delete(N.issueId),Un.current===N&&gs(Y=>Y+1)},"onFinished")}),tl=rj({companyId:b,onSuccess:a(({comment:N,changes:Y,blockedByIssueIds:se,...ve},{data:Fe})=>{Object.prototype.hasOwnProperty.call(Fe,"projectId")&&m4(ve.projectId??"",ve.companyId);const Xe=new Set([i,ve.id]);ve.identifier&&Xe.add(ve.identifier),vo(Xe,ve),k&&kn&&Sf(ve,Bt,Date.now()),R.invalidateQueries({queryKey:G.issues.activity(i)}),Qs()},"onSuccess")}),U=(0,u.useMemo)(()=>({mutate:a((N,Y)=>tl.mutate({id:i,data:N},Y),"mutate"),mutateAsync:a(N=>tl.mutateAsync({id:i,data:N}),"mutateAsync"),isPending:tl.isPending,variables:tl.variables?.data}),[i,tl]),ue=ut({mutationFn:a(N=>$e.resolveRecoveryAction(i,N),"mutationFn"),onSuccess:a(({issue:N})=>{const Y=new Set([i,N.id]);N.identifier&&Y.add(N.identifier),vo(Y,N),R.invalidateQueries({queryKey:G.issues.activity(i)}),Qs()},"onSuccess"),onError:a(N=>{Z({title:"Recovery resolution failed",body:N instanceof Error?N.message:"Unable to resolve recovery action",tone:"error"})},"onError"),onSettled:a(()=>{R.invalidateQueries({queryKey:G.issues.detail(i)}),b&&R.invalidateQueries({queryKey:G.issues.list(b)})},"onSettled")}),qe=ut({mutationFn:a(async N=>{const Y=await $e.resolveRecoveryAction(i,{actionId:N,outcome:"restored",sourceIssueStatus:"todo"});if(Y.issue.status!=="todo"||Y.issue.assigneeAgentId!==Y.recoveryAction.returnOwnerAgentId)throw new Error("The task’s state has changed. Refresh to see its current state.");return Y},"mutationFn"),onSuccess:a(({issue:N})=>{const Y=new Set([i,N.id]);N.identifier&&Y.add(N.identifier),vo(Y,N),Qs()},"onSuccess"),onSettled:a(()=>{for(const N of[G.issues.detail(i),G.issues.activity(i),G.issues.runs(i),G.issues.liveRuns(i)])R.invalidateQueries({queryKey:N})},"onSettled")}),be=ut({onMutate:a(()=>vs(null),"onMutate"),mutationFn:a(async({mode:N,scope:Y,runId:se,wakeAgents:ve=!1})=>{if(N==="resume"){const Xe=Gn?.activePauseHold?.holdId;if(!Xe)throw new Error("No active subtree pause hold is available to resume.");return{kind:"release",hold:await $e.releaseTreeHold(i,Xe,{reason:null,metadata:{wakeAgents:ve}})}}const Fe=await $e.createTreeHold(i,{mode:N,reason:null,releasePolicy:{strategy:"manual",...N==="pause"?{note:Y==="leaf"?"leaf_pause":"full_pause"}:{}},...se?{metadata:{source:"issue_active_run_control",runId:se}}:{},...N==="restore"?{metadata:{wakeAgents:ve}}:{}});return N==="pause"&&(R.invalidateQueries({queryKey:["issues","tree-control-state",i??"pending"]}),await lj(Fe.preview.activeRuns.map(Xe=>Xe.id))),{kind:"create",hold:Fe.hold,preview:Fe.preview}},"mutationFn"),onSuccess:a(N=>{N.kind==="release"&&N.hold.wakeFailures?.length&&vs(`Pause released, but ${N.hold.wakeFailures.length} ${N.hold.wakeFailures.length===1?"task":"tasks"} could not start. ${N.hold.wakeFailures[0].message} Check the affected agents and try starting them again.`),ps(!1),Ds(!1)},"onSuccess"),onSettled:a(async()=>{await Promise.all([R.invalidateQueries({queryKey:G.issues.detail(i)}),R.invalidateQueries({queryKey:G.issues.activity(i)}),R.invalidateQueries({queryKey:G.issues.liveRuns(i)}),R.invalidateQueries({queryKey:G.issues.activeRun(i)}),R.invalidateQueries({queryKey:G.issues.runs(i)}),R.invalidateQueries({queryKey:["issues","tree-control-state",i??"pending"]}),R.invalidateQueries({queryKey:["issues","tree-holds",i??"pending"]}),R.invalidateQueries({queryKey:["issues","tree-control-preview",i??"pending"]})]),b&&await Promise.all([R.invalidateQueries({queryKey:G.issues.list(b)}),...$?.id?[R.invalidateQueries({queryKey:G.issues.listByParent(b,$.id)}),R.invalidateQueries({queryKey:G.issues.listByDescendantRoot(b,$.id)})]:[]])},"onSettled")}),Me=ut({mutationFn:a(async N=>{const Y=await qn.cancel(N);await lj([N],{initialRuns:[Y]})},"mutationFn"),onSettled:a(()=>Promise.all([R.invalidateQueries({queryKey:G.issues.detail(i)}),R.invalidateQueries({queryKey:G.issues.runs(i)})]),"onSettled")}),kt=vP(),zt=ut({mutationFn:a(async({runId:N,status:Y})=>{if(Y==="cancelled"){let se=!1;try{return await kt(i,{status:Y},async()=>{await qn.cancel(N),se=!0})}catch(ve){throw ve instanceof ij||ve instanceof aj?ve:se?DC(ve):ve}}await qn.cancel(N);try{return await $e.update(i,{status:Y})}catch(se){throw DC(se)}},"mutationFn"),onSuccess:a(({comment:N,...Y},{status:se})=>{const ve=new Set([i,Y.id]);Y.identifier&&ve.add(Y.identifier),vo(ve,Y),R.invalidateQueries({queryKey:G.issues.activity(i)}),Br(),Qs(),Z({title:se==="done"?"Run stopped and task done":"Run stopped and task cancelled",tone:"success"})},"onSuccess"),onError:a((N,{status:Y})=>{if(N instanceof ij)return;if(N instanceof aj){Br(),Z({title:"Some subtasks could not be canceled",body:N.message,tone:"error"});return}const se=Mde(N);Z({title:se?"Run stopped; task update failed":Y==="done"?"Stop and done failed":"Stop and cancel failed",body:N instanceof Error?N.message:"Unable to stop the run and update the task",tone:"error"})},"onError"),onSettled:a((N,Y)=>{R.invalidateQueries({queryKey:G.issues.detail(i)}),Y&&Br(),b&&R.invalidateQueries({queryKey:G.issues.list(b)})},"onSettled")}),Ys=(0,u.useCallback)(N=>{U.mutate(N)},[U.mutate]),_r=rj({companyId:it,onSuccess:a(()=>{it&&(R.invalidateQueries({queryKey:["issues",it]}),R.invalidateQueries({queryKey:G.sidebarBadges(it)}))},"onSuccess")}),ta=(0,u.useCallback)((N,Y)=>{_r.mutate({id:N,data:Y})},[_r.mutate]),sl=(0,u.useMemo)(()=>x&&!v&&$&&fa?(0,s.jsx)(Lj,{issues:Ht,isLoading:Gt,agents:xs,projects:er,liveIssueIds:Wa,projectId:$.projectId??void 0,viewStateKey:`paperclip:issue-detail:${$.id}:subissues-view`,issueLinkState:ss??Q.state,searchFilters:{descendantOf:$.id,includeBlockedBy:!0},searchWithinLoadedIssues:!0,baseCreateIssueDefaults:tx($,Bt),createIssueLabel:"Sub-task",showChecklist:!0,showProgressSummary:!0,parentIssueIdForCostSummary:$.id,onUpdateIssue:ta}):null,[x,v,$,fa,Ht,Gt,xs,er,Wa,ss,Q.state,Bt,ta]),Ce=ut({mutationKey:["cancel-issue-monitor",i],mutationFn:a(async()=>{const N=await $e.get(i),{monitor:Y,...se}=N.executionPolicy??{mode:"normal",commentRequired:!0,stages:[]};return $e.update(N.id,{expectedExecutionPolicy:N.executionPolicy??null,executionPolicy:{...se,mode:se.mode??"normal",commentRequired:se.commentRequired??!0,stages:se.stages??[]}})},"mutationFn"),onSuccess:a(()=>{Vt(),Br(),Qs()},"onSuccess")}),Lt=ut({mutationKey:["check-issue-monitor-now",i],mutationFn:a(()=>$e.checkMonitorNow(i),"mutationFn"),onSuccess:a(()=>{Vt(),Br(),Qs(),Z({title:"Monitor check queued",tone:"success"})},"onSuccess"),onError:a(N=>{Z({title:"Monitor check failed",body:N instanceof Error?N.message:"Unable to trigger the monitor right now",tone:"error"})},"onError")}),Ue=ut({mutationFn:a(async({approvalId:N,action:Y})=>Y==="approve"?nj.approve(N):nj.reject(N),"mutationFn"),onMutate:a(({approvalId:N,action:Y})=>{re({approvalId:N,action:Y})},"onMutate"),onSuccess:a((N,Y)=>{Vt(),R.invalidateQueries({queryKey:G.issues.approvals(i)}),Qs(),R.invalidateQueries({queryKey:G.approvals.detail(Y.approvalId)}),it&&R.invalidateQueries({queryKey:G.approvals.list(it)}),Z({title:Y.action==="approve"?"Approval approved":"Approval rejected",tone:"success"})},"onSuccess"),onError:a((N,Y)=>{Z({title:Y.action==="approve"?"Approval failed":"Rejection failed",body:N instanceof Error?N.message:"Unable to update approval",tone:"error"})},"onError"),onSettled:a(()=>{re(null)},"onSettled")}),Cr=Gl({mutationFn:a(async({body:N,reopen:Y,interrupt:se,attachmentIds:ve,clientRequestId:Fe,runSettings:Xe,nativeCommand:St},{assertCurrentAccount:cn})=>{$?.conversationAgentId&&EQ(`${$.companyId}:${Bt}:${$.conversationAgentId}`);const Wr=await wr();if(cn(),Xe&&$?.conversationAgentId){const Im=await $e.getCore(Wr,{cache:"no-store",fresh:!0});cn();const mP=await $e.update(Wr,{assigneeAdapterOverrides:Qj(Im.assigneeAdapterOverrides,(e?.agent??Ot.get($.conversationAgentId))?.adapterType,Xe)});cn(),R.setQueryData(G.issues.detail(Wr),mP)}return $e.addComment(Wr,N,Y,se,ve,Fe??Kg(),St)},"mutationFn"),onMutate:a(async({body:N,reopen:Y,interrupt:se})=>{const ve=R.cancelQueries({queryKey:G.issues.comments(i)}),Fe=R.cancelQueries({queryKey:G.issues.detail(i)}),Xe=R.getQueryData(G.issues.detail(i)),St=se?null:BC(R,i,$).interruptibleIssueRun,cn=$?yj({companyId:$.companyId,issueId:$.id,body:N,authorUserId:Bt,clientStatus:St?"queued":"pending",queueTargetRunId:St?.id??null}):null;return cn&&ht(Wr=>[...Wr,cn]),Xe&&R.setQueryData(G.issues.detail(i),gj(Xe,{reopen:Y})),await Promise.all([ve,Fe]),{optimisticCommentId:cn?.clientId??null,queuedCommentTargetRunId:St?.id??null,previousIssue:Xe}},"onMutate"),onSuccess:a(async(N,Y,se)=>{if(se?.optimisticCommentId&&Jt.current.has(se.optimisticCommentId)){Jt.current.delete(se.optimisticCommentId),ht(ve=>ve.filter(Fe=>Fe.clientId!==se.optimisticCommentId));try{await $e.cancelComment(N.issueId,N.id),await Zo(N.id),Vt(),ci(),Qs();return}catch(ve){Z({title:"Cancel failed",body:ve instanceof Error?ve.message:"Unable to cancel the queued comment",tone:"error"})}}se?.queuedCommentTargetRunId&&(An(ve=>{const Fe=new Map(ve);return Fe.set(N.id,se.queuedCommentTargetRunId),Fe}),R.invalidateQueries({queryKey:G.issues.queuedComments(i??N.issueId)})),$?.conversationAgentId&&g8($.originKind==="onboarding_chat"?"onboarding_chat":"agent_chat"),se?.optimisticCommentId&&yn.current.set(N.id,se.optimisticCommentId),Ts&&yt(N),R.setQueryData(G.issues.comments(i??N.issueId),ve=>ve?{...ve,pages:Sm(ve.pages,N)}:{pageParams:[null],pages:Sm(void 0,N)}),X||await R.invalidateQueries({queryKey:G.issues.comments(i??N.issueId),exact:!0,refetchType:"none"}),se?.optimisticCommentId&&ht(ve=>ve.filter(Fe=>Fe.clientId!==se.optimisticCommentId)),k&&$&&kn&&Sf($,Bt,new Date(N.createdAt).getTime())},"onSuccess"),onError:a((N,Y,se)=>{if(se?.optimisticCommentId&&ht(Xe=>Xe.filter(St=>St.clientId!==se.optimisticCommentId)),se?.previousIssue&&R.setQueryData(G.issues.detail(i),se.previousIssue),wl(N)==="pending")return;const{title:ve,body:Fe}=Ps(N,{action:"post the comment"});Z({title:ve,body:Fe,tone:"error"})},"onError"),onFinished:a((N,Y)=>{Y?.optimisticCommentId&&ht(se=>se.filter(ve=>ve.clientId!==Y.optimisticCommentId))},"onFinished"),onSettled:a((N,Y,se)=>{if(N&&!i&&R.invalidateQueries({queryKey:G.issues.comments(N.issueId)}),Y&&R.invalidateQueries({queryKey:["issues","tree-control-state"]}),ci(),se.attachmentIds?.length)for(const ve of Cs)R.invalidateQueries({queryKey:G.issues.attachments(ve)});se.interrupt&&Br(),se.reopen&&Qs()},"onSettled")}),Fr=Gl({meta:{replay:"idempotent"},mutationFn:a(({interaction:N,selectedClientKeys:Y,selectedOptionIds:se,rememberAction:ve})=>$e.acceptInteraction(i,N.id,{selectedClientKeys:Y,selectedOptionIds:se,rememberAction:ve}),"mutationFn"),onSuccess:a(N=>{Qi(N),N.kind==="suggest_tasks"&&it&&$?.id&&R.invalidateQueries({queryKey:G.issues.listByParent(it,$.id)}),Vt(),Qs();const Y=N.kind==="suggest_tasks"?N.result?.createdTasks?.length??0:0,se=N.kind==="suggest_tasks"?N.result?.skippedClientKeys?.length??0:0;Z({title:N.kind==="request_confirmation"?"Request confirmed":N.kind==="request_checkbox_confirmation"?"Selection confirmed":se>0?`Accepted ${Y} draft${Y===1?"":"s"} and skipped ${se}`:"Suggested tasks accepted",tone:"success"})},"onSuccess"),onError:a(N=>{Uj(N).kind==="settled"&&Vt(),Z({title:"Accept failed",body:nh(N),tone:"error"})},"onError")}),Gi=Gl({meta:{replay:"idempotent"},mutationFn:a(({interaction:N,reason:Y})=>$e.rejectInteraction(i,N.id,Y),"mutationFn"),onSuccess:a(N=>{Qi(N),Vt(),Qs(),Z({title:N.kind==="request_confirmation"?a0(N):"Suggestion rejected",tone:"success"})},"onSuccess"),onError:a(N=>{Uj(N).kind==="settled"&&Vt(),Z({title:"Reject failed",body:nh(N),tone:"error"})},"onError")}),Js=Gl({meta:{replay:"idempotent"},mutationFn:a(({interaction:N,answers:Y})=>$e.respondToInteraction(i,N.id,{answers:Y}),"mutationFn"),onSuccess:a(N=>{Qi(N),Vt(),Qs(),Z({title:"Answers submitted",tone:"success"})},"onSuccess"),onError:a(N=>{Z({title:"Submit failed",body:nh(N),tone:"error"})},"onError")}),Ar=ut({mutationFn:a(({interaction:N,verdicts:Y})=>$e.submitInteractionVerdicts(i,N.id,Y),"mutationFn"),onSuccess:a((N,Y)=>{Qi(N),Vt(),Qs();const se=Y.verdicts.length,ve=N.kind==="request_item_verdicts"?N.result?.complete??!1:!1;Z({title:ve?"All verdicts applied":`Applied ${se} decision${se===1?"":"s"}`,tone:"success"})},"onSuccess"),onError:a(N=>{Z({title:"Apply failed",body:N instanceof Error?N.message:"Unable to apply the verdicts",tone:"error"})},"onError")}),Yi=ut({mutationFn:a(({interaction:N})=>$e.cancelInteraction(i,N.id),"mutationFn"),onSuccess:a(N=>{Qi(N),Vt(),Qs(),Z({title:"Question cancelled",tone:"success"})},"onSuccess"),onError:a(N=>{Z({title:"Cancel failed",body:N instanceof Error?N.message:"Unable to cancel the question",tone:"error"})},"onError")}),ji=ut({mutationFn:a(N=>$e.dismissInteraction(i,N.id),"mutationFn"),onSuccess:a(N=>{Qi(N),Vt(),Qs()},"onSuccess")}),Qa=ut({mutationFn:a(({interaction:N})=>$e.skipInteraction(i,N.id),"mutationFn"),onSuccess:a(N=>{Qi(N),Vt(),Qs()},"onSuccess"),onError:a(N=>{Z({title:"Skip failed",body:N instanceof Error?N.message:"Unable to skip this request",tone:"error"})},"onError")}),En=Gl({mutationFn:a(async({body:N,reopen:Y,interrupt:se,reassignment:ve,attachmentIds:Fe,clientRequestId:Xe,runSettings:St},{assertCurrentAccount:cn})=>{const Wr=St&&!ve?await $e.getCore(i,{cache:"no-store",fresh:!0}):$;return cn(),$e.update(i,{comment:N,commentClientRequestId:Xe,...Fe?.length?{attachmentIds:Fe}:{},...ve?{assigneeAgentId:ve.assigneeAgentId,assigneeUserId:ve.assigneeUserId}:{},...St||ve?{assigneeAdapterOverrides:St?Qj(Wr?.assigneeAdapterOverrides,Ot.get(ve?.assigneeAgentId??Wr?.assigneeAgentId??"")?.adapterType,St,!!ve):null}:{},...Y?{status:"todo"}:{},...se?{interrupt:se}:{}})},"mutationFn"),onMutate:a(async({body:N,reopen:Y,reassignment:se,interrupt:ve})=>{const Fe=R.cancelQueries({queryKey:G.issues.comments(i)}),Xe=R.cancelQueries({queryKey:G.issues.detail(i)}),St=R.getQueryData(G.issues.detail(i)),cn=ve?null:BC(R,i,$).interruptibleIssueRun,Wr=$?yj({companyId:$.companyId,issueId:$.id,body:N,authorUserId:Bt,clientStatus:cn?"queued":"pending",queueTargetRunId:cn?.id??null}):null;return Wr&&ht(Im=>[...Im,Wr]),St&&R.setQueryData(G.issues.detail(i),gj(St,{reopen:Y,reassignment:se})),await Promise.all([Fe,Xe]),{optimisticCommentId:Wr?.clientId??null,queuedCommentTargetRunId:cn?.id??null,previousIssue:St}},"onMutate"),onSuccess:a(async(N,Y,se)=>{const{comment:ve,...Fe}=N;if(R.setQueryData(G.issues.detail(i),Fe),ve&&se?.optimisticCommentId&&Jt.current.has(se.optimisticCommentId)){Jt.current.delete(se.optimisticCommentId),ht(Xe=>Xe.filter(St=>St.clientId!==se.optimisticCommentId));try{await $e.cancelComment(i,ve.id),await Zo(ve.id),Vt(),ci(),Qs();return}catch(Xe){Z({title:"Cancel failed",body:Xe instanceof Error?Xe.message:"Unable to cancel the queued comment",tone:"error"})}}ve&&se?.queuedCommentTargetRunId&&(An(Xe=>{const St=new Map(Xe);return St.set(ve.id,se.queuedCommentTargetRunId),St}),R.invalidateQueries({queryKey:G.issues.queuedComments(i)})),ve&&(Ts&&yt(ve),se?.optimisticCommentId&&yn.current.set(ve.id,se.optimisticCommentId),R.setQueryData(G.issues.comments(i),Xe=>Xe?{...Xe,pages:Sm(Xe.pages,ve)}:{pageParams:[null],pages:Sm(void 0,ve)}),X||await R.invalidateQueries({queryKey:G.issues.comments(i),exact:!0,refetchType:"none"}),k&&kn&&Sf(Fe,Bt,new Date(ve.createdAt).getTime())),se?.optimisticCommentId&&ht(Xe=>Xe.filter(St=>St.clientId!==se.optimisticCommentId))},"onSuccess"),onError:a((N,Y,se)=>{if(se?.optimisticCommentId&&ht(Xe=>Xe.filter(St=>St.clientId!==se.optimisticCommentId)),se?.previousIssue&&R.setQueryData(G.issues.detail(i),se.previousIssue),wl(N)==="pending")return;const{title:ve,body:Fe}=Ps(N,{action:"post the comment"});Z({title:ve,body:Fe,tone:"error"})},"onError"),onSettled:a((N,Y,se)=>{if(Y&&R.invalidateQueries({queryKey:["issues","tree-control-state"]}),ci(),se.attachmentIds?.length)for(const ve of Cs)R.invalidateQueries({queryKey:G.issues.attachments(ve)});se.interrupt&&Br(),Qs()},"onSettled")}),zr=ut({mutationFn:a(N=>$e.interruptLatestQueuedComments(i,N),"mutationFn"),onSuccess:a(()=>{Vt(),Br()},"onSuccess"),onError:a(()=>{Vt(),Br()},"onError")}),wo=ut({mutationFn:a(async({commentId:N})=>$e.cancelComment(i,N),"mutationFn"),onSuccess:a(async N=>{An(Y=>{if(!Y.has(N.id))return Y;const se=new Map(Y);return se.delete(N.id),se}),await Zo(N.id),Hi(N.body),Vt(),ci(),Qs(),Z({title:"Queued comment canceled",body:"The queued message was restored to the composer.",tone:"success"})},"onSuccess"),onError:a(N=>{Z({title:"Cancel failed",body:N instanceof Error?N.message:"Unable to cancel the queued comment",tone:"error"})},"onError")}),Nm=ut({mutationFn:a(async({commentId:N})=>$e.deleteComment(i,N),"mutationFn"),onSuccess:a(async N=>{await el(N),zl(N.id),Vt(),ci(),Qs(),Xo(),Z({title:"Comment deleted",body:"The thread now shows a deleted-comment marker.",tone:"success"})},"onSuccess"),onError:a(N=>{Z({title:"Delete failed",body:N instanceof Error?N.message:"Unable to delete the comment",tone:"error"})},"onError")}),Ul=(0,u.useCallback)(N=>{if(N.startsWith("optimistic-")){Jt.current.add(N);let Y=null;ht(se=>{const ve=B4(se,N);return Y=ve.comment?.body??null,ve.comments}),Y&&(Hi(Y),Z({title:"Queued comment canceled",body:"The queued message was restored to the composer.",tone:"success"}));return}wo.mutateAsync({commentId:N})},[wo,Hi,Z]),Ga=ut({mutationFn:a(N=>$e.upsertFeedbackVote(i,{targetType:N.targetType,targetId:N.targetId,vote:N.vote,...N.reason?{reason:N.reason}:{},...N.allowSharing?{allowSharing:!0}:{}}),"mutationFn"),onMutate:a(async N=>{await R.cancelQueries({queryKey:G.issues.feedbackVotes(i)});const Y=R.getQueryData(G.issues.feedbackVotes(i));return R.setQueryData(G.issues.feedbackVotes(i),zde(Y,{issueId:i,targetType:N.targetType,targetId:N.targetId,vote:N.vote,reason:N.reason},Bt)),{previousVotes:Y}},"onMutate"),onSuccess:a((N,Y)=>{R.invalidateQueries({queryKey:G.issues.feedbackVotes(i)}),R.invalidateQueries({queryKey:G.companies.all}),R.invalidateQueries({queryKey:G.instance.generalSettings}),Z({title:Y.sharingPreferenceAtSubmit==="prompt"?Y.allowSharing?"Feedback saved. Future votes will share":"Feedback saved. Future votes will stay local":Y.allowSharing?"Feedback saved and sharing enabled":"Feedback saved",tone:"success"})},"onSuccess"),onError:a((N,Y,se)=>{se?.previousVotes&&R.setQueryData(G.issues.feedbackVotes(i),se.previousVotes),Z({title:"Failed to save feedback",body:N instanceof Error?N.message:"Unknown error",tone:"error"})},"onError")}),Rr=ut({mutationFn:a(async N=>{if(e)return $e.uploadAttachment(e.agent.companyId,await wr(),N);if(!Ze)throw new Error("Task details are still loading. Please try again.");return $e.uploadAttachment(Ze.companyId,Ze.id,N)},"mutationFn"),onSuccess:a(N=>{mt(null),R.invalidateQueries({queryKey:G.issues.attachments(i??N.issueId)}),Vt(),i||R.invalidateQueries({queryKey:G.issues.detail(N.issueId)})},"onSuccess"),onError:a(N=>{mt(N instanceof Error?N.message:"Upload failed")},"onError")}),di=ut({mutationFn:a(async N=>{const Y=qde(N.name),se=Bde(Y),ve=($?.documentSummaries??[]).find(cn=>cn.key===se)??null,Fe=await N.text(),Xe=Fde(Y),St=ve?.title??Xe??null;return $e.upsertDocument(await wr(),se,{title:se==="plan"?null:St,format:"markdown",body:Fe,baseRevisionId:ve?.latestRevisionId??null})},"mutationFn"),onSuccess:a(N=>{mt(null),Vt(),i||R.invalidateQueries({queryKey:G.issues.detail(N.issueId)}),R.invalidateQueries({queryKey:G.issues.documents(i??N.issueId)})},"onSuccess"),onError:a(N=>{mt(N instanceof Error?N.message:"Document import failed")},"onError")}),Vc=ut({mutationFn:a(N=>$e.deleteAttachment(N),"mutationFn"),onSuccess:a(()=>{mt(null),R.invalidateQueries({queryKey:G.issues.attachments(i)}),Vt()},"onSuccess"),onError:a(N=>{mt(N instanceof Error?N.message:"Delete failed")},"onError")}),sa=Gl({mutationFn:a(N=>$e.archiveFromInbox(N),"mutationFn"),onMutate:a(async N=>{if(!b)return{previousData:[]};const Y=Ib(R),se=bj(b,N);try{await fj(R,b)}catch(Fe){throw se(),Fe}if(!Y.isCurrentScope())return se(),{companyId:b,previousData:[],account:Y,release:se};const ve=H4(R,b);return K0(R,b,N),{companyId:b,previousData:ve,account:Y,release:se}},"onMutate"),onSuccess:a((N,Y,se)=>{b&&K0(R,b,Y),Qs(),V(Mt.href.startsWith("/inbox")?Mt.href:"/inbox",{replace:!0}),Z({title:"Task archived from inbox",tone:"success",action:{label:"Undo",onClick:a(()=>{Wc(Y,se?.companyId,se?.previousData??[])},"onClick")}})},"onSuccess"),onError:a((N,Y,se)=>{se?.release?.(),se?.previousData&&_j(R,se.previousData,Y),Z({title:"Archive failed",body:N instanceof Error?N.message:"Unable to archive this task from the inbox",tone:"error"})},"onError"),onFinished:a((N,Y)=>{Y?.account&&!Y.account.isCurrentScope()&&Y.release()},"onFinished"),onSettled:a(async(N,Y,se,ve)=>{if(ve?.companyId){Y||uj(ve.companyId,se);try{await wb(R,ve.companyId),!Y&&ve.account?.isCurrentScope()&&$q(R,ve.companyId,se)!=="unknown"&&v4(ve.companyId,se)}finally{ve.account&&!ve.account.isCurrentScope()&&ve.release()}}},"onSettled")}),Ji=e?.agent??xs?.find(N=>N.id===$?.conversationAgentId),Tr=$?.ancestors?.[0],nl=Tr&&!pa(Tr)?Tr.identifier??Tr.id:null,Qd=(0,u.useCallback)(()=>{nl&&Zm(nl,ss??Q.state,Q.search)},[nl,ss,Q.state,Q.search]);(0,u.useEffect)(()=>{if(o){C([{label:"Chat"}]);return}C([Mt,...Tr?[{label:pa(Tr)?"Private task":Tr.title,href:pa(Tr)?void 0:ra(Tr.identifier??Tr.id),onClick:pa(Tr)?void 0:Qd,control:pa(Tr)?(0,s.jsx)(Nd,{identifier:null}):void 0,controlKey:pa(Tr)?"private-parent":void 0}]:[],{label:Fl,identifier:Ha,leading:Ms,leadingKey:Uc}])},[o,j,Fl,Ha,Tr,Qd,Qn,C,Mt.href,Mt.label,Ms,Uc]),(0,u.useEffect)(()=>{if(!v&&!o||!x||!$?.id){L(null);return}return L({open:P?ee:z&&!Ln,onToggle:tr}),()=>L(null)},[o,P,$?.id,ee,z,L,v,Ln,x,tr]),(0,u.useEffect)(()=>{const N=x&&!v&&!P&&!!$?.id&&(!z||Ln);return S(N?(0,s.jsx)(kh,{children:(0,s.jsx)(vb,{open:!1,onToggle:Or,shortcut:"]",className:"shrink-0"})}):null),()=>S(null)},[P,$?.id,Or,z,S,v,Ln,x]);const Ni=ss?.issueDetailSource==="inbox";(0,u.useEffect)(()=>{const N=pn.current;if(pn.current=i,!D$({previousIssueId:N,nextIssueId:i,navigationType:J}))return;window.scrollTo({top:0,left:0,behavior:"auto"});const Y=document.getElementById("main-content");Y&&(Y.scrollTop=0)},[i,J]),(0,u.useEffect)(()=>{if(e||!Ze)return;const N=ss??Q.state,Y=wt,se=Ze.identifier??Ze.id,ve=Y&&r!==Y.issuePrefix,Fe=Ij(Q.search);if(i!==se||ve||Fe){Zm(se,N,Q.search);const Xe=ra(se);V({pathname:Y?`/${Y.issuePrefix}${Xe}`:Xe,search:Fe?"":Q.search,hash:Q.hash},{replace:!0,state:N})}},[e,Ze,wt,r,i,V,Q.state,Q.search,Q.hash,ss]),(0,u.useEffect)(()=>{if(!i||!$?.id||$.conversationAgentId)return;const N=Un.current?.issueId===$.id?Un.current:Un.current=Yn.current.get($.id)??{issueId:$.id,companyId:$.companyId,account:Ib(R),confirmed:!1};N.confirmed||Yn.current.has($.id)||!N.account.isCurrentScope()||N.attemptedSessionAt!==rn&&(N.attemptedSessionAt=rn,Yn.current.set($.id,N),Kc.mutate(N))},[i,$?.id,$?.conversationAgentId,rn,bn]);const Ii=(0,u.useMemo)(()=>{const N=[],Y=new Set,se=a((Fe,Xe)=>{Fe&&Y.add(`attachment:${Fe}`),Y.add(`content:${Xe}`)},"mark"),ve=a((Fe,Xe)=>!!(Fe&&Y.has(`attachment:${Fe}`))||Y.has(`content:${Xe}`),"hasSeen");for(const Fe of zs??[])!JT(Fe)&&!XT(Fe)||(N.push(Fe),se(Fe.id,Fe.contentPath));for(const Fe of uw(Hn).items){const Xe=Fe.metadata;Xe&&(!(Od(Xe.contentType,Xe.originalFilename??Fe.title)||si(Xe.contentType,Xe.originalFilename))||ve(Xe.attachmentId,Xe.contentPath)||(N.push({id:`work-product-${Fe.id}`,contentPath:Xe.contentPath,openPath:Xe.openPath,downloadPath:Xe.downloadPath,contentType:Xe.contentType,originalFilename:Xe.originalFilename??Fe.title}),se(Xe.attachmentId,Xe.contentPath)))}return N},[zs,Hn]),ko=(0,u.useCallback)(N=>{const Y=a(Fe=>{try{return new URL(Fe,window.location.origin).href}catch{return Fe}},"absoluteUrl"),se=Y(N);let ve=Ii.findIndex(Fe=>Y(Fe.contentPath)===se||Fe.openPath&&Y(Fe.openPath)===se);if(ve<0){const Fe=N.match(/\/api\/assets\/([^/]+)\/content/);Fe&&(ve=Ii.findIndex(Xe=>"assetId"in Xe&&Xe.assetId===Fe[1]))}return ve>=0?(es(ve),Wt(!0),!0):!1},[Ii]),Gd=(0,u.useCallback)(N=>{ko(N)||e1(N)},[ko]),jo=(0,u.useMemo)(()=>({feedbackVotes:as,feedbackDataSharingPreference:js,feedbackTermsUrl:OC,mentions:Tn,externalReferences:Ye.isEnabled?Ye.markdownReferences:void 0,imageUploadHandler:a(async N=>(await Rr.mutateAsync(N)).contentPath,"imageUploadHandler"),onVote:a(async(N,Y,se)=>{await Ga.mutateAsync({targetType:"issue_document_revision",targetId:N,vote:Y,reason:se?.reason,allowSharing:se?.allowSharing,sharingPreferenceAtSubmit:js})},"onVote"),agentMap:Ot,userProfileMap:Hs}),[as,js,Tn,Ye.isEnabled,Ye.markdownReferences,Rr.mutateAsync,Ga.mutateAsync,Ot,Hs]);(0,u.useLayoutEffect)(()=>{if(!w||!ea||Ln||e&&!e.issue||x&&P){O();return}const N={issue:ea,childIssues:Ki,issueLinkState:v?Ae:void 0,onAddSubIssue:ki,onUpdate:Ys,hasActiveRun:ln,externalObjects:Ye.isEnabled?Ye.groups:void 0,externalObjectsLoading:Ye.isEnabled?Ye.isLoading:void 0,externalObjectsError:Ye.isEnabled?Ye.isError:void 0,onRetryExternalObjects:Ye.isEnabled?Ye.refetch:void 0,onCheckMonitorNow:a(()=>Lt.mutate(),"onCheckMonitorNow"),checkingMonitorNow:Lt.isPending,documentDeepLink:De?.issueId===ea.id?De:null,onAttachmentOpened:Dl,openAttachment:!P&&_e?.issueId===ea.id?_e:null,openSkillId:ae?.id??null,openSkillName:ae?.name??null,onSkillOpened:Se};return x?F((0,s.jsx)(Po.Provider,{value:ko,children:(0,s.jsx)(yC,{documentEditor:jo,pluginPanels:Va,pluginPanelsLoading:qc,openedPluginPanelKeys:Ll.current,dismissedPluginPanelKeys:wi.current,openBrowserId:Go,onBrowserOpened:Yo,...N,showDocumentSourceTask:l,onArtifactVisibilityChange:l?A:void 0,accountScope:cr,fileTabsEnabled:or,streamlinedTabs:v,showSubtasksTab:v,tasksTab:Wi,artifactsOpenRequestId:!P&&!ie?.handled&&ie?.issueId===ea.id?ie.requestId:void 0,onArtifactsOpened:li},ea.id)}),{contentMode:"full-bleed"}):F((0,s.jsx)(Po.Provider,{value:ko,children:(0,s.jsx)(ev,{...N})})),()=>O()},[Va,qc,cr,Go,Yo,O,ko,Ys,$l,ki,F,_e,Dl,ae,Se,Ki,ea,l,A,Ln,Ae,v,ln,Lt.isPending,Lt.mutate,Ye.isEnabled,Ye.groups,Ye.isLoading,Ye.isError,Ye.refetch,De,w,x,jo,Bt,j,or,Wi,ie,li,P]);const rl=(0,u.useRef)(!1),na=(0,u.useRef)(null),Hc=!$?.hiddenAt;(0,u.useEffect)(()=>{if(!$?.id||!Hc)return;const N=a(Y=>{dO({armed:Hc,defaultPrevented:Y.defaultPrevented,key:Y.key,metaKey:Y.metaKey,ctrlKey:Y.ctrlKey,altKey:Y.altKey,target:Y.target,hasOpenDialog:Pj(document)})==="archive"&&(Y.preventDefault(),sa.isPending||sa.mutate($.id))},"handleKeyDown");return document.addEventListener("keydown",N,!0),()=>{document.removeEventListener("keydown",N,!0)}},[sa,Hc,$?.id]),(0,u.useEffect)(()=>{const N=a(()=>{na.current!==null&&(window.clearTimeout(na.current),na.current=null)},"clearArmTimeout"),Y=a(()=>{rl.current=!1,N()},"disarm"),se=a(()=>{rl.current=!0,N(),na.current=window.setTimeout(()=>{rl.current=!1,na.current=null},1200)},"arm"),ve=a(()=>{Y()},"handlePointerDown"),Fe=a(St=>{St.target instanceof HTMLElement&&St.target!==document.body&&Y()},"handleFocusIn"),Xe=a(St=>{const cn=IL({armed:rl.current,defaultPrevented:St.defaultPrevented,key:St.key,metaKey:St.metaKey,ctrlKey:St.ctrlKey,altKey:St.altKey,target:St.target,hasOpenDialog:Pj(document)});if(cn!=="ignore"){if(cn==="arm"){se();return}if(Y(),cn==="navigate_inbox"){St.preventDefault(),St.stopPropagation(),V(Mt.href.startsWith("/inbox")?Mt.href:"/inbox");return}if(cn==="focus_comment"&&(St.preventDefault(),St.stopPropagation(),xe("chat"),Kt(Wr=>Wr+1)),cn==="open_file_viewer"){if(!or)return;St.preventDefault(),St.stopPropagation(),ye(!0)}}},"handleKeyDown");return document.addEventListener("pointerdown",ve,!0),document.addEventListener("focusin",Fe,!0),document.addEventListener("keydown",Xe,!0),()=>{Y(),document.removeEventListener("pointerdown",ve,!0),document.removeEventListener("focusin",Fe,!0),document.removeEventListener("keydown",Xe,!0)}},[or,V,Mt.href]);const Qc=(0,u.useRef)(null),al=(0,u.useRef)(null),Xi=(0,u.useCallback)((N,Y=!1)=>{const se=lv(N),ve=se?.kind==="continuation-summary"&&x?{kind:"properties-pane",tab:"document",documentKey:"continuation-summary",maximize:!1}:se;if(!ve)return!1;if(ve.kind==="continuation-summary")return nt(null),xe("activity"),jt(Xe=>Xe+1),!0;if(!w||!x)return!1;if(P)ce(!0);else if(Ln&&$?.id&&Lc($.id),q(!0),ve.maximize){const Xe=`${i??""}::${N}`;Qc.current!==Xe&&(Qc.current=Xe,H())}const Fe=$?.id??i??"";return nt(Xe=>({issueId:Fe,tab:ve.tab,documentKey:ve.documentKey,focusActivePlan:Y,requestId:Xe?.issueId===Fe?Xe.requestId+1:1})),!0},[w,P,$?.id,i,q,H,Ln,x]);(0,u.useEffect)(()=>{const N=al.current;al.current=null,Xi(Q.hash,N?.pathname===Q.pathname&&N.hash===Q.hash)||(nt(null),Qc.current=null,B())},[i,Q.hash,Q.pathname,Xi,B]),(0,u.useEffect)(()=>()=>{B()},[B]),(0,u.useEffect)(()=>{const N=a(Y=>{if(Y.defaultPrevented||Y.button!==0||Y.metaKey||Y.ctrlKey||Y.shiftKey||Y.altKey)return;const se=Y.target;if(!(se instanceof Element))return;const ve=se.closest("a[href]");if(!ve||ve.hasAttribute("download")||ve.target&&ve.target!=="_self")return;const Fe=ve.getAttribute("href");if(!Fe)return;const Xe=new URL(`${Q.pathname}${Q.search}${Q.hash}`,window.location.origin),St=[$?.id,$?.identifier,i].filter(Im=>!!Im),cn=l&&ve.hasAttribute("data-sidebar-document-link")?Sde(Fe,Xe,St):Ide(Fe,Xe,St);if(!cn||lv(cn)?.kind==="properties-pane"&&(!w||!x))return;Y.preventDefault();const Wr=ve.hasAttribute("data-plan-expand")&&!P&&z&&!Ln;cn===Q.hash?Xi(cn,Wr):(al.current=Wr?{pathname:Q.pathname,hash:cn}:null,V(`${Q.pathname}${Q.search}${cn}`,{preventScrollReset:!0,state:{...Q.state&&typeof Q.state=="object"?Q.state:{},taskDocumentScrollEntry:dE(Q)}}))},"handleDocumentClick");return document.addEventListener("click",N,!0),()=>document.removeEventListener("click",N,!0)},[$?.id,$?.identifier,i,l,P,z,Ln,V,Q.hash,Q.key,Q.pathname,Q.search,Q.state,x,w,Xi]),(0,u.useEffect)(()=>{const N=Q.hash.match(/^#(work-product|attachment)-(.+)$/);if(!N)return;const Y=`${N[1]}-${decodeURIComponent(N[2])}`;let se=!1,ve=0,Fe;const Xe=a(()=>{if(se)return;const St=document.getElementById(Y);if(!St){ve<30&&(ve+=1,Fe=setTimeout(Xe,100));return}St.scrollIntoView({behavior:"smooth",block:"center"}),St.classList.add("ring-2","ring-primary/50","transition-shadow"),Fe=setTimeout(()=>St.classList.remove("ring-2","ring-primary/50","transition-shadow"),3e3)},"tryScroll");return Xe(),()=>{se=!0,Fe&&clearTimeout(Fe)}},[Q.hash,Hn,zs]),(0,u.useEffect)(()=>{ws!==0&&Ne==="chat"&&rs.current?.focus()},[Ne,ws]),(0,u.useEffect)(()=>{if(!or)return;const N=a(()=>{ye(!0)},"handleOpenFileViewer");return window.addEventListener("paperclip:open-file-viewer",N),()=>{window.removeEventListener("paperclip:open-file-viewer",N)}},[or]);const Wl=(0,u.useMemo)(()=>V8(Hn),[Hn]),Yd=(0,u.useMemo)(()=>(zs??[]).filter(N=>!Wl.has(N.id)),[zs,Wl]),Ve=a(async()=>{if(!$)return;const N=a(Fe=>{const Xe=document.createElement("textarea");return Xe.innerHTML=Fe,Xe.value},"decodeEntities"),Y=N($.title),se=N($.description??""),ve=`# ${$.identifier}: ${Y}
117
117
 
118
118
  ${se}`.trimEnd();try{await xi(ve),K(!0),Z({title:"Copied to clipboard",tone:"success"}),setTimeout(()=>K(!1),2e3)}catch(Fe){Z({title:"Copy failed",body:Fe instanceof Error?Fe.message:"Unable to copy task markdown",tone:"error"})}},"copyIssueToClipboard"),Xs=(0,u.useRef)({onArchive:a(()=>{!sa.isPending&&$?.id&&sa.mutate($.id)},"onArchive"),onCopy:a(()=>Ve(),"onCopy"),onProperties:a(()=>ce(!0),"onProperties"),onHide:a(()=>{U.mutate({hiddenAt:new Date().toISOString()},{onSuccess:a(()=>V("/issues/all"),"onSuccess")})},"onHide")});Xs.current={onArchive:a(()=>{!sa.isPending&&$?.id&&sa.mutate($.id)},"onArchive"),onCopy:a(()=>Ve(),"onCopy"),onProperties:a(()=>ce(!0),"onProperties"),onHide:a(()=>{U.mutate({hiddenAt:new Date().toISOString()},{onSuccess:a(()=>V("/issues/all"),"onSuccess")})},"onHide")};const os=Mt.href??"/inbox",dr=P&&Ni,On=sa.isPending,gr=!!$?.hiddenAt,Ya=Ni&&!!$?.id&&!gr;(0,u.useEffect)(()=>{if(!dr){M(null);return}return M((0,s.jsx)(Kde,{backHref:os,preferHistoryBack:k?Qe:!0,issueId:$?.id,issueHidden:gr,archivePending:On,onArchive:a(()=>Xs.current.onArchive(),"onArchive"),onCopy:a(()=>Xs.current.onCopy(),"onCopy"),onProperties:a(()=>Xs.current.onProperties(),"onProperties"),onHide:a(()=>Xs.current.onHide(),"onHide")})),()=>M(null)},[dr,os,Qe,k,$?.id,gr,On,M]);const Si=Je&&zs===void 0,ui=(0,u.useCallback)(()=>Ts?Os.load():hr(),[Ts,Os.load,hr]),_i=(0,u.useCallback)(async()=>{if(me(),Ts){await ze.refetch();return}const N=await fr(),Y=await N4({pages:N.data?.pages,pageParams:N.data?.pageParams,pageSize:50,maxPages:Dde,fetchPage:a(se=>$e.listComments(i,{order:"desc",limit:50,after:se}),"fetchPage")});R.setQueryData(G.issues.comments(i),Y),await new Promise(se=>{if(typeof window>"u"){se();return}window.requestAnimationFrame(()=>se())})},[i,R,me,fr,Ts,ze.refetch]);(0,u.useEffect)(()=>{!Ia&&!(X&&Dr&&Jn&&!Kn)||hr()},[hr,Ia,X,Dr,Jn,Kn]);const Jd=(0,u.useCallback)(async(N,Y,se)=>{await Ga.mutateAsync({targetType:"issue_comment",targetId:N,vote:Y,reason:se?.reason,allowSharing:se?.allowSharing,sharingPreferenceAtSubmit:js})},[js,Ga]),yf=(0,u.useCallback)(async(N,Y,se,ve,Fe,Xe,St)=>{if(St){await Cr.mutateAsync({body:N,reopen:Y,attachmentIds:ve,clientRequestId:Fe,nativeCommand:St});return}if(!$?.conversationAgentId&&(se||Xe)){await En.mutateAsync({body:N,reopen:Y,reassignment:se,attachmentIds:ve,clientRequestId:Fe,runSettings:Xe});return}await Cr.mutateAsync({body:N,reopen:Y,attachmentIds:ve,clientRequestId:Fe,runSettings:Xe})},[Cr,En,$?.conversationAgentId]),vf=(0,u.useCallback)(async N=>(await Rr.mutateAsync(N)).contentPath,[Rr]),D=(0,u.useCallback)(async N=>Rr.mutateAsync(N),[Rr]),we=(0,u.useCallback)(async N=>zr.mutateAsync(N),[zr]),dt=(0,u.useMemo)(()=>[{id:"cancel",label:"Stop and cancel",pendingLabel:"Stopping and cancelling...",isPending:zt.isPending&&zt.variables?.status==="cancelled",disabled:zt.isPending,onSelect:a(N=>zt.mutateAsync({runId:N,status:"cancelled"}).then(()=>{},()=>{}),"onSelect")},{id:"done",label:"Stop and done",pendingLabel:"Stopping and marking done...",isPending:zt.isPending&&zt.variables?.status==="done",disabled:zt.isPending,onSelect:a(N=>zt.mutateAsync({runId:N,status:"done"}).then(()=>{},()=>{}),"onSelect")}],[zt.isPending,zt.mutateAsync,zt.variables?.status]),Tt=(0,u.useCallback)(async(N,Y,se,ve)=>{await Fr.mutateAsync({interaction:N,selectedClientKeys:Y,selectedOptionIds:se,rememberAction:ve})},[Fr]),mi=(0,u.useCallback)(async(N,Y)=>{await Gi.mutateAsync({interaction:N,reason:Y})},[Gi]),Ur=(0,u.useCallback)(async(N,Y)=>{await Js.mutateAsync({interaction:N,answers:Y})},[Js]),wf=(0,u.useCallback)(async N=>{await Yi.mutateAsync({interaction:N})},[Yi]),B$=(0,u.useCallback)(async N=>{await Qa.mutateAsync({interaction:N})},[Qa]),F$=(0,u.useCallback)(async(N,Y)=>{await Ar.mutateAsync({interaction:N,verdicts:Y})},[Ar]),z$=$?.status==="backlog"&&!!($.assigneeAgentId||$.assigneeUserId),U$=(0,u.useCallback)(async()=>{await U.mutateAsync({status:"todo"})},[U.mutateAsync]),O0=$?.assigneeAgentId??null,kf=$?.companyId??null,Kk=$?.status??null,Vk=$?.id??null,q0=ut({mutationFn:a(async()=>{if(!O0)throw new Error("No assignee agent");if(await $r.resume(O0,kf??void 0),Vk&&(Kk==="todo"||Kk==="in_progress"))try{await $r.wakeup(O0,{source:"assignment",reason:"Assignee resumed from the task page",payload:{issueId:Vk,mutation:"assignee_resumed"}},kf??void 0)}catch{}},"mutationFn"),onSuccess:a(async()=>{kf&&await R.invalidateQueries({queryKey:G.agents.list(kf)})},"onSuccess")}),W$=(0,u.useCallback)(async()=>{await q0.mutateAsync()},[q0.mutateAsync]),Hk=$?.activeRecoveryAction?.id,B0=(0,u.useCallback)(N=>{const Y=Hk;if(Y)switch(N){case"todo":ue.mutateAsync({actionId:Y,outcome:"restored",sourceIssueStatus:"todo"});return;case"done":ue.mutateAsync({actionId:Y,outcome:"restored",sourceIssueStatus:"done"});return;case"in_review":ue.mutateAsync({actionId:Y,outcome:"restored",sourceIssueStatus:"in_review"});return;case"false_positive_done":ue.mutateAsync({actionId:Y,outcome:"false_positive",sourceIssueStatus:"done"});return;case"false_positive_in_review":ue.mutateAsync({actionId:Y,outcome:"false_positive",sourceIssueStatus:"in_review"});return}},[Hk,ue.mutateAsync]),K$=(0,u.useCallback)(()=>{B0("todo")},[B0]),F0=ut({mutationFn:a(async N=>{if(!$)throw new Error("Task is not loaded yet.");const Y=$.identifier??"the stalled task",se=[`Re-issued from ${Y} on an isolated git worktree after a workspace branch divergence.`,"",`- Base ref (live branch): \`${N.baseRef}\``,...N.expectedBranch?[`- Recorded branch: \`${N.expectedBranch}\``]:[],"","---","",$.description??""];return $e.create($.companyId,{title:`Re-issue (isolated): ${$.title??Y}`,description:se.join(`
119
119
  `),priority:$.priority,projectId:$.projectId??null,parentId:$.parentId??null,assigneeAgentId:$.activeRecoveryAction?.returnOwnerAgentId??$.activeRecoveryAction?.previousOwnerAgentId??$.assigneeAgentId??null,executionWorkspacePreference:"isolated_workspace",executionWorkspaceSettings:{mode:"isolated_workspace",workspaceStrategy:{type:"git_worktree",baseRef:N.baseRef}}})},"mutationFn"),onSuccess:a(N=>{Qs(),Z({title:"Isolated re-issue created",body:N.identifier?`${N.identifier} will run on a fresh isolated workspace.`:"A fresh isolated re-issue was created.",tone:"success"}),N.identifier&&V(ra(N.identifier))},"onSuccess"),onError:a(N=>{Z({title:"Re-issue failed",body:N instanceof Error?N.message:"Unable to create an isolated re-issue.",tone:"error"})},"onError")}),V$=(0,u.useCallback)(N=>{F0.mutateAsync(N)},[F0.mutateAsync]),Kl=ut({mutationFn:a(async N=>{const{workspaceId:Y,...se}=N;return Kp.reconcile(Y,se)},"mutationFn"),onSuccess:a((N,Y)=>{Vt(),Qs(),Z(Y.mode==="quarantine_restore"?{title:"Workspace repaired",body:"Dirty changes were quarantined onto a rescue branch and the recorded branch restored; the task will resume.",tone:"success"}:{title:"Workspace branch reconciled",body:"The recorded branch now matches the live branch; the task will resume.",tone:"success"})},"onSuccess"),onError:a(N=>{Z({title:"Reconcile failed",body:N instanceof Error?N.message:"Unable to reconcile the workspace branch.",tone:"error"})},"onError")}),il=KE($?.activeRecoveryAction)??$?.executionWorkspaceId??null,H$=(0,u.useCallback)(()=>{if(!il){Z({title:"Reconcile failed",body:"This task has no execution workspace to reconcile.",tone:"error"});return}Kl.mutateAsync({workspaceId:il,mode:"forward"})},[il,Kl.mutateAsync,Z]),Q$=(0,u.useCallback)(N=>{if(!il){Z({title:"Reconcile failed",body:"This task has no execution workspace to reconcile.",tone:"error"});return}Kl.mutateAsync({workspaceId:il,mode:"override",reason:N})},[il,Kl.mutateAsync,Z]),G$=(0,u.useCallback)(()=>{if(!il){Z({title:"Repair failed",body:"This task has no execution workspace to repair.",tone:"error"});return}Kl.mutateAsync({workspaceId:il,mode:"quarantine_restore"})},[il,Kl.mutateAsync,Z]),Y$=(0,u.useMemo)(()=>(pt?.issues??[]).filter(N=>!N.skipped),[pt]),Er=Gn?.activePauseHold??null,Qk=(0,u.useMemo)(()=>Er?.isRoot===!0?lr:[],[Er?.isRoot,lr]),jf=(0,u.useMemo)(()=>{const N=new Set;for(const Y of Qk)for(const se of Y.members??[])se.skipped||N.add(se.issueId);return N},[Qk]),J$=(0,u.useMemo)(()=>{const N=new Set;for(const Y of Ht)jf.has(Y.id)&&N.add(Y.id);return N},[Ht,jf]),X$=(0,u.useMemo)(()=>{const N=new Map;for(const Y of Ht)jf.has(Y.id)&&N.set(Y.id,"Paused");return N},[Ht,jf]),Z$=(0,u.useMemo)(()=>Er?Er.rootIssueId===$?.id?$??null:$?.ancestors?.find(N=>N.id===Er.rootIssueId)??null:null,[Er,$]);if(!$&&!at&&(ns||rt.isPending||Ge.kind==="reconnecting")||st.kind==="reconnecting"&&(!$||Ws&&!rt.data))return(0,s.jsx)(uv,{headerSeed:ot});if(!$||st.kind==="error"&&Ws&&!rt.data){const N=at??Is??rt.error;if(N)return(0,s.jsx)(oa,{size:"page",error:N,action:"load this task",onRetry:rt.error?Ge.retry:st.retry,retrying:st.isFetching||Ge.isFetching})}if(!$)return null;if(!qt||!w||c===$.id)return(0,s.jsx)(uv,{titleEditor:qt&&Bt&&!$.conversationAgentId?(0,s.jsx)(Ym,{value:$.title,onSave:a(N=>U.mutateAsync({title:N}),"onSave"),onEditingChange:bt,draftKey:`issue:${$.id}:title`,readCurrentValue:a(async()=>(await $e.getCore($.id,{cache:"no-store",fresh:!0})).title,"readCurrentValue"),as:"h2",className:"text-xl font-semibold leading-normal"},$.id):void 0,headerSeed:Ze?sx(tA(null,Ze)):ot});const Nf=$.ancestors??[],eP=(()=>{if($.originKind!=="stranded_issue_recovery"&&$.originKind!=="stale_active_run_evaluation")return null;const N=Nf.length>0?Nf[0]:null;if(!N||pa(N))return null;const Y=N.identifier??N.id;return{identifier:N.identifier??null,title:N.title??null,href:ra(Y)}})(),tP=a(async N=>{const Y=N.target.files;if(!(!Y||Y.length===0)){for(const se of Array.from(Y))FC(se)?await di.mutateAsync(se):await Rr.mutateAsync(se);zn.current&&(zn.current.value="")}},"handleFilePicked"),sP=a(async N=>{N.preventDefault(),Nt(!1);const Y=N.dataTransfer.files;if(!(!Y||Y.length===0))for(const se of Array.from(Y))FC(se)?await di.mutateAsync(se):await Rr.mutateAsync(se)},"handleAttachmentDrop"),Gk=Yd.length>0,Xd=ma&&Ht.length>0,nP=Xd&&Er?.isRoot===!0,rP=Xd&&Sr.length>0,z0=$.status==="done"||$.status==="cancelled",Yk=!!$.assigneeAgentId&&!z0,aP=ma&&Ht.length===0&&!Er&&!z0,iP=ma&&Ht.length===0&&Er?.isRoot===!0,Zd=Ht.length===0?"leaf":"subtree",oP=Y$.length,Jk=pt?.totals.affectedAgents??0,lP=Er?null:Fa?"This issue's isolated workspace was archived. Your next comment or resume reopens it and rebuilds the worktree.":null,cP=Er?"hold":"active_run",dP=!!pt&&!is&&!_s,Xk=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("input",{ref:zn,type:"file",className:"hidden",onChange:tP,multiple:!0}),(0,s.jsxs)(W,{variant:"outline",size:"sm",onClick:a(()=>zn.current?.click(),"onClick"),disabled:Rr.isPending||di.isPending,className:E("shadow-none",Pt&&"border-primary bg-primary/5"),children:[(0,s.jsx)(fc,{className:"h-3.5 w-3.5 mr-1.5"}),Rr.isPending||di.isPending?"Uploading...":(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"hidden sm:inline",children:"Upload attachment"}),(0,s.jsx)("span",{className:"sm:hidden",children:"Upload"})]})]})]}),Zk=!v&&Nf.length>0?(0,s.jsxs)("nav",{className:E("flex items-center gap-1 text-xs text-muted-foreground flex-wrap",I),children:[[...Nf].reverse().map((N,Y)=>(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[Y>0&&(0,s.jsx)(Us,{className:"h-3 w-3 shrink-0"}),pa(N)?(0,s.jsx)(Nd,{identifier:N.identifier}):(0,s.jsx)(tt,{to:ra(N.identifier??N.id),state:ss??Q.state,onClickCapture:a(()=>Zm(N.identifier??N.id,ss??Q.state,Q.search),"onClickCapture"),className:"hover:text-foreground transition-colors truncate max-w-(--sz-200px)",title:N.title,children:N.title})]},N.id)),(0,s.jsx)(Us,{className:"h-3 w-3 shrink-0"}),(0,s.jsx)("span",{className:"text-foreground/60 truncate max-w-(--sz-200px)",children:$.title})]}):null,ej=!v&&$.createdFrom?(0,s.jsx)(YE,{createdFrom:$.createdFrom,issueLinkState:ss??Q.state,className:I}):null,If=(0,s.jsx)(ti,{...Ma($),size:_?"md":"lg",blockerAttention:$.blockerAttention,onChange:a(N=>U.mutate({status:N}),"onChange")}),tj=$.conversationAgentId?null:(0,s.jsxs)("div",{"data-testid":"issue-detail-header",className:E(v?"relative space-y-2":"space-y-3",I),children:[v?(0,s.jsxs)("div",{className:E("flex min-w-0 items-start gap-2 md:items-center md:pr-8",P&&Ni?"pr-8":"pr-16"),children:[_?null:(0,s.jsx)("div",{className:"hidden md:block",children:If}),(0,s.jsxs)("div",{"data-slot":"task-detail-title",className:"flex min-w-0 flex-1 items-baseline gap-2",children:[(0,s.jsx)(Ym,{value:$.title,onSave:a(N=>U.mutateAsync({title:N}),"onSave"),draftKey:`issue:${$.id}:title`,readCurrentValue:a(async()=>(await $e.getCore($.id,{cache:"no-store",fresh:!0})).title,"readCurrentValue"),as:"h2",className:E("min-w-0 text-balance",_?"text-2xl font-normal text-foreground":"text-xl font-semibold","leading-normal")}),_?null:(0,s.jsx)("span",{"data-slot":"task-title-identifier",className:"hidden shrink-0 font-mono text-sm text-muted-foreground md:inline",children:$.identifier??$.id.slice(0,8)})]})]}):null,(0,s.jsxs)("div",{className:E("flex min-w-0 flex-wrap items-center gap-2",v&&(_?"gap-x-6 gap-y-2":"gap-x-3 gap-y-2 md:gap-x-6 md:pl-7")),children:[_?(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[If,(0,s.jsx)("span",{"data-slot":"task-title-identifier",className:"font-mono text-sm text-muted-foreground",children:$.identifier??$.id.slice(0,8)})]}):null,v&&!_?(0,s.jsx)("div",{className:"md:hidden",children:If}):null,v&&!_?(0,s.jsx)("span",{className:"shrink-0 font-mono text-sm text-muted-foreground md:hidden",children:$.identifier??$.id.slice(0,8)}):null,v?null:If,!1,v?null:(0,s.jsx)("span",{className:"shrink-0 font-mono text-sm text-muted-foreground",children:$.identifier??$.id.slice(0,8)}),He?(0,s.jsx)("span",{className:"shrink-0","data-testid":"issue-header-waiting",children:(0,s.jsx)(OO,{queue:At})}):Qn&&(0,s.jsxs)($t,{variant:"outline",className:E("gap-1.5 text-(length:--text-nano)","bg-blue-500/10 border-blue-500/30 text-blue-600 dark:text-blue-400"),children:[(0,s.jsxs)("span",{className:"relative flex h-1.5 w-1.5",children:[(0,s.jsx)("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"}),(0,s.jsx)("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-blue-500"})]}),"Live"]}),$.originKind==="routine_execution"&&$.originId&&(0,s.jsxs)(tt,{to:`/routines/${$.originId}`,className:"inline-flex items-center gap-1 rounded-full bg-violet-500/10 border border-violet-500/30 px-2 py-0.5 text-(length:--text-nano) font-medium text-violet-600 dark:text-violet-400 shrink-0 hover:bg-violet-500/20 transition-colors",title:`Routine execution from routine ${$.originId}`,children:[(0,s.jsx)(vl,{className:"h-3 w-3"}),"Routine"]}),$.originKind==="task_watchdog"?(0,s.jsxs)($t,{variant:"outline",className:"border-sky-500/40 bg-sky-500/10 text-(length:--text-nano) text-sky-700 dark:text-sky-300",title:"This task is a generated watchdog task. It verifies whether stopped work in the watched task tree is legitimate.",children:[(0,s.jsx)(b6,{className:"h-3 w-3"}),"Watchdog"]}):null,!x&&($.workMode==="ask"||$.workMode==="planning")?(()=>{const N=vA($.workMode),Y=N.icon;return(0,s.jsxs)($t,{variant:"outline",className:E("text-(length:--text-nano)",N.classes.badge),title:`This task is in ${N.label.toLowerCase()}.`,children:[(0,s.jsx)(Y,{className:"h-3 w-3","aria-hidden":!0}),N.label]})})():null,PP($.blockedBy)?(0,s.jsxs)($t,{variant:"outline","data-testid":"issue-detail-parked-blocker",className:"border-amber-500/60 bg-amber-500/15 text-(length:--text-nano) text-amber-700 dark:text-amber-300",title:"Blocked by parked work — at least one assigned blocker is in backlog and will not wake its assignee.",children:[(0,s.jsx)(dm,{className:"h-3 w-3"}),"Blocked by parked work"]}):null,$.projectId?(0,s.jsxs)(tt,{to:`/projects/${$.projectId}`,className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors rounded px-1 -mx-1 py-0.5 min-w-0",children:[(0,s.jsx)(qu,{size:"xs",icon:jn?.icon??$.project?.icon}),(0,s.jsx)("span",{className:"truncate",children:jn?.name??$.project?.name??$.projectId.slice(0,8)})]}):(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground opacity-50 px-1 -mx-1 py-0.5",children:[(0,s.jsx)(qu,{size:"xs"}),"No project"]}),(0,s.jsx)(Wde,{issue:$,agentMap:Ot,userProfileMap:Hs,userLabelMap:Lr}),!v&&($.labels??[]).length>0&&(0,s.jsxs)("div",{className:"hidden sm:flex items-center gap-1",children:[($.labels??[]).slice(0,4).map(N=>(0,s.jsx)($t,{variant:"outline",className:"text-(length:--text-nano)",style:{borderColor:N.color,color:dD(N.color,.12),backgroundColor:`${N.color}1f`},children:N.name},N.id)),($.labels??[]).length>4&&(0,s.jsxs)("span",{className:"text-(length:--text-nano) text-muted-foreground",children:["+",($.labels??[]).length-4]})]}),!v&&!(P&&Ni)&&(0,s.jsxs)("div",{className:"ml-auto flex items-center gap-0.5 md:hidden shrink-0",children:[(0,s.jsx)(W,{variant:"ghost",size:"icon-xs",onClick:Ve,title:"Copy task as markdown",children:ge?(0,s.jsx)(Ut,{className:"h-4 w-4 text-green-500"}):(0,s.jsx)(yr,{className:"h-4 w-4"})}),(0,s.jsx)(W,{variant:"ghost",size:"icon-xs",onClick:a(()=>ce(!0),"onClick"),title:"Properties",children:(0,s.jsx)(Du,{className:"h-4 w-4"})})]}),(0,s.jsxs)("div",{className:"hidden md:flex items-center md:ml-auto shrink-0",children:[!v&&Ya&&(0,s.jsx)(W,{variant:"ghost",size:"icon-xs",onClick:a(()=>{!On&&$?.id&&sa.mutate($.id)},"onClick"),disabled:On,title:"Archive from inbox","aria-label":"Archive from inbox",children:(0,s.jsx)(Lu,{className:"h-4 w-4"})}),or?(0,s.jsx)(W,{variant:"ghost",size:"icon-xs",onClick:a(()=>ye(!0),"onClick"),title:"Open file... (g f)","aria-label":"Open file in this issue",children:(0,s.jsx)(El,{className:"h-4 w-4"})}):null,v?null:(0,s.jsx)(W,{variant:"ghost",size:"icon-xs",onClick:Ve,title:"Copy task as markdown",children:ge?(0,s.jsx)(Ut,{className:"h-4 w-4 text-green-500"}):(0,s.jsx)(yr,{className:"h-4 w-4"})}),!v&&!x&&(!z||Ln)?(0,s.jsx)(kh,{children:(0,s.jsx)(vb,{open:!1,onToggle:Or,shortcut:"]",className:"shrink-0"})}):null]}),(0,s.jsxs)("div",{"data-slot":"task-title-actions",className:E("flex shrink-0 items-center gap-0.5",v?"absolute right-0 top-0 h-7":P&&Ni?"ml-auto md:ml-0":void 0),children:[v&&!(P&&Ni)?(0,s.jsx)(W,{variant:"ghost",size:"icon-xs",className:"md:hidden shrink-0",onClick:a(()=>ce(!0),"onClick"),"aria-label":"Properties",title:"Properties",children:(0,s.jsx)(Du,{className:"h-4 w-4"})}):null,(0,s.jsx)(Tde,{issue:$,companyId:$.companyId,canManage:Zr,closeMenu:a(()=>ne(!1),"closeMenu"),implicitPrincipals:Ui,children:a(N=>(0,s.jsxs)(Da,{open:te,onOpenChange:ne,children:[(0,s.jsx)(La,{asChild:!0,children:(0,s.jsx)(W,{variant:"ghost",size:"icon-xs",className:"shrink-0","aria-label":"More task actions",title:"More task actions",onKeyDown:a(Y=>{(Y.key==="Enter"||Y.key===" ")&&(Y.preventDefault(),ne(!0))},"onKeyDown"),children:(0,s.jsx)(Ic,{className:_?"h-3 w-3":"h-4 w-4"})})}),(0,s.jsxs)(Oa,{className:"w-52 p-1",align:"end",children:[x&&!X?(0,s.jsxs)("button",{className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs hover:bg-accent/50",onClick:a(()=>{pe(),ne(!1)},"onClick"),children:[(0,s.jsx)(_b,{className:"h-3 w-3"}),"Show task activity"]}):null,v?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("button",{className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs hover:bg-accent/50",onClick:a(()=>{ki(),ne(!1)},"onClick"),children:[(0,s.jsx)(fi,{className:"h-3 w-3"}),"Add subtask"]}),(0,s.jsxs)("button",{className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs hover:bg-accent/50",onClick:a(()=>{Ve(),ne(!1)},"onClick"),children:[ge?(0,s.jsx)(Ut,{className:"h-3 w-3"}):(0,s.jsx)(yr,{className:"h-3 w-3"}),"Copy as markdown"]}),Ya?(0,s.jsxs)("button",{className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs hover:bg-accent/50 disabled:opacity-50",disabled:On,onClick:a(()=>{!On&&$?.id&&sa.mutate($.id),ne(!1)},"onClick"),children:[(0,s.jsx)(Lu,{className:"h-3 w-3"}),"Archive from inbox"]}):null]}):null,N,(0,s.jsx)(Vle,{scope:Zd,canPause:aP||Xd&&!Er&&!z0,canResume:iP||nP,canCancel:Xd,canRestore:rP,pending:be.isPending,onPause:a(()=>{be.mutate({mode:"pause",scope:Zd}),ne(!1)},"onPause"),onResume:a(()=>{be.reset(),Rs("resume"),Ds(Yk||Xd),ps(!0),ne(!1)},"onResume"),onCancel:a(()=>{be.reset(),Rs("cancel"),ps(!0),ne(!1)},"onCancel"),onRestore:a(()=>{be.reset(),Rs("restore"),Ds(!1),ps(!0),ne(!1)},"onRestore")}),(0,s.jsxs)("button",{className:"flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 text-destructive",onClick:a(()=>{U.mutate({hiddenAt:new Date().toISOString()},{onSuccess:a(()=>V("/issues/all"),"onSuccess")}),ne(!1)},"onClick"),children:[(0,s.jsx)(Nh,{className:"h-3 w-3"}),"Hide this task"]})]})]}),"children")})]})]}),v?null:(0,s.jsx)(Ym,{value:$.title,onSave:a(N=>U.mutateAsync({title:N}),"onSave"),draftKey:`issue:${$.id}:title`,readCurrentValue:a(async()=>(await $e.getCore($.id,{cache:"no-store",fresh:!0})).title,"readCurrentValue"),as:"h2",className:x?"text-base font-semibold":"text-xl font-bold"}),x&&!v?sl:null,(0,s.jsx)(Lie,{hasActiveRun:Qn,onCancelMonitor:a(()=>Ce.mutateAsync(),"onCancelMonitor"),issue:$,workProducts:Hn,checkError:Lt.error?Ps(Lt.error,{action:"check the monitor"}).body:null,onCheckNow:a(()=>Lt.mutate(),"onCheckNow"),checkingNow:Lt.isPending},$.id),x?null:(0,s.jsx)(Ym,{value:$.description??"",onSave:a(N=>U.mutateAsync({description:N}),"onSave"),draftKey:`issue:${$.id}:description`,readCurrentValue:a(async()=>(await $e.getCore($.id,{cache:"no-store",fresh:!0})).description??"","readCurrentValue"),as:"p",className:"text-sm leading-7 text-foreground",placeholder:"Add a description...",multiline:!0,foldable:!0,mentions:Tn,externalReferences:Ye.isEnabled?Ye.markdownReferences:void 0,imageUploadHandler:a(async N=>(await Rr.mutateAsync(N)).contentPath,"imageUploadHandler"),onDropFile:a(async N=>{await Rr.mutateAsync(N)},"onDropFile")})]}),sj=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(vj,{slotTypes:["toolbarButton","contextMenuItem"],entityType:"issue",context:{companyId:$.companyId,projectId:$.projectId??null,entityId:$.id,entityType:"issue"},className:E("flex flex-wrap gap-2",I),itemClassName:"inline-flex",missingBehavior:"placeholder"}),(0,s.jsx)(i4,{placementZones:["toolbarButton"],entityType:"issue",context:{companyId:$.companyId,projectId:$.projectId??null,entityId:$.id,entityType:"issue"},className:E("flex flex-wrap gap-2",I),itemClassName:"inline-flex"}),(0,s.jsx)(vj,{slotTypes:["taskDetailView"],entityType:"issue",context:{companyId:$.companyId,projectId:$.projectId??null,entityId:$.id,entityType:"issue"},className:E("space-y-3",I),itemClassName:"rounded-lg border border-border p-3",missingBehavior:"placeholder"})]}),uP=x?(0,s.jsxs)(s.Fragment,{children:[Zk,ej,tj,(0,s.jsx)(DI,{companyId:$.companyId,issueId:$.id,viewerId:Bt,agentMap:Ot}),sj]}):void 0;return(0,s.jsx)(A4,{issueId:e&&!e.issue?"":$.id,enabled:or,children:(0,s.jsx)(tK,{issueId:$.conversationAgentId&&$.conversationUserId===(Bt??"local-board")&&(!e||e.issue)?$.id:void 0,companyId:$.companyId,userId:Bt,children:(0,s.jsx)(Ko.Provider,{value:x?Vi:null,children:(0,s.jsx)(Po.Provider,{value:ko,children:(0,s.jsxs)("div",{"data-task-chat-shell":x?"":void 0,"data-classic-task-shell":!P&&!x&&Pe==="chat"?"":void 0,className:x?"flex h-full min-h-0 w-full flex-col gap-3":"max-w-3xl space-y-6",children:[Is&&rt.data&&!AA(Is)?(0,s.jsxs)("div",{role:"status",className:"flex items-center gap-2 text-sm text-muted-foreground",children:["Some task details could not be loaded.",(0,s.jsx)(W,{type:"button",variant:"ghost",size:"sm",onClick:a(()=>{me()},"onClick"),children:"Retry"})]}):null,x?null:Zk,x?null:ej,(0,s.jsx)(Kie,{className:E(I,"mt-3"),assigneeAgentId:$.assigneeAgentId,attachments:zs??[],companyId:$.companyId,issueId:$.id,issueCacheRefs:Cs},$.id),Pe==="chat"&&(0,s.jsx)(IQ,{className:I,issueId:$.id,companyId:$.companyId,showStatus:!$.interruption&&!$.executionBlocker?.workspaceRecovery,onRecoveryControlChange:Rt,action:$.activeRecoveryAction??null},`workspace-export:${$.activeRecoveryAction?.id??$.id}`),Pe==="chat"&&(0,s.jsx)(FQ,{className:I,presentation:$.interruption,blockers:$.blockedBy,hideQuestionReminder:$.originKind==="onboarding_chat"&&(Yr||rr.some(N=>N.status==="pending"&&ic(N))),issueId:$.id,companyId:$.companyId,agentName:Ot.get($.assigneeAgentId??"")?.name,projectName:$.project?.name,canRetry:Aa&&!($.executionBlocker?.workspaceRepairRequired&&WE($.executionBlocker.cause)&&Ie),onRetry:tn.retry,optimistic:tn.optimistic,takingLonger:tn.takingLonger,error:tn.error}),$.status==="in_review"&&$.externalConversationState==="waiting"&&(0,s.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Reply sent. Send a message to continue."}),$.hiddenAt&&(0,s.jsxs)("div",{className:E("flex items-center gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",I,x&&(P?"mt-4":"mt-3")),children:[(0,s.jsx)(Nh,{className:"h-4 w-4 shrink-0"}),"This task is hidden"]}),an?(0,s.jsx)("p",{role:"alert",className:E("text-sm text-muted-foreground",I),children:an}):null,be.error&&!Ke&&be.variables?.feedback!=="composer"&&(0,s.jsx)("p",{role:"alert",className:E("text-sm text-destructive",I),children:Ps(be.error).body}),x?null:tj,x?null:(0,s.jsx)(DI,{companyId:$.companyId,issueId:$.id,viewerId:Bt,agentMap:Ot}),x?null:sj,x?null:fa?(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("div",{className:"flex items-center justify-between gap-2",children:(0,s.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Sub-tasks"})}),(0,s.jsx)(Lj,{issues:Ht,isLoading:Gt,agents:xs,projects:er,liveIssueIds:Wa,mutedIssueIds:J$,issueBadgeById:X$,projectId:$.projectId??void 0,viewStateKey:`paperclip:issue-detail:${$.id}:subissues-view`,issueLinkState:ss??Q.state,searchFilters:{descendantOf:$.id,includeBlockedBy:!0},searchWithinLoadedIssues:!0,baseCreateIssueDefaults:tx($,Bt),createIssueLabel:"Sub-task",showChecklist:!0,showProgressSummary:!0,parentIssueIdForCostSummary:$.id,onUpdateIssue:ta})]}):(0,s.jsx)("div",{className:"flex flex-wrap items-center justify-end gap-2 min-w-0",children:(0,s.jsxs)(W,{variant:"outline",size:"sm",onClick:ki,className:"shrink-0 shadow-none",children:[(0,s.jsx)(fi,{className:"mr-1.5 h-3.5 w-3.5"}),"New Sub-task"]})}),!x&&ir?(0,s.jsx)(W3,{issueId:$.id,issueIdentifier:$.identifier,agentMap:Ot}):null,x?null:(0,s.jsx)(U3,{...jo,issue:$,canDeleteDocuments:!!Vs?.user?.id,canManageDocumentLocks:!!Vs?.user?.id,extraActions:Gk?null:Xk}),x?null:(0,s.jsx)(iie,{workProducts:Hn,onMediaClick:a(N=>{const Y=N.metadata;if(!Y)return;const se=Ii.findIndex(ve=>ve.contentPath===Y.contentPath||ve.id===`work-product-${N.id}`||ve.id===Y.attachmentId);es(se>=0?se:0),Wt(!0)},"onMediaClick")}),x?null:Si?(0,s.jsx)(Uk,{titleWidth:"w-24",rows:2}):Gk?(0,s.jsx)(cae,{attachments:Yd,uploadButton:Xk,error:le,dragActive:Pt,deletePending:Vc.isPending,onDelete:a(N=>Vc.mutate(N),"onDelete"),onImageClick:a(N=>{const Y=Ii.findIndex(se=>se.id===N.id);es(Y>=0?Y:0),Wt(!0)},"onImageClick"),onDragEnter:a(N=>{N.preventDefault(),Nt(!0)},"onDragEnter"),onDragOver:a(N=>{N.preventDefault(),Nt(!0)},"onDragOver"),onDragLeave:a(N=>{N.currentTarget.contains(N.relatedTarget)||Nt(!1)},"onDragLeave"),onDrop:a(N=>{sP(N)},"onDrop")}):null,(0,s.jsx)(Ac,{items:Ii,initialIndex:Zt,open:Dt,onOpenChange:Wt}),x?null:(0,s.jsx)(nde,{issue:$,project:jn,onUpdate:a(N=>U.mutate(N),"onUpdate"),onBrowseFiles:or?()=>ye(!0):void 0,onOpenFileByPath:or?()=>ye(!0):void 0}),!x&&or&&$.workProducts&&$.workProducts.length>0&&(()=>{const N=$.workProducts.map(Y=>({product:Y,fileRef:Ode(Y)})).filter(({fileRef:Y})=>Y!==null);return N.length===0?null:(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("div",{className:"flex items-center justify-between gap-2",children:(0,s.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Artifacts"})}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:N.map(({product:Y,fileRef:se})=>(0,s.jsx)(ade,{workspaceFileRef:se,title:Y.title},Y.id))})]})})(),x?null:(0,s.jsx)(KC,{className:I}),(0,s.jsxs)(HA,{value:Pe,onValueChange:xe,className:x?"min-h-0 flex-1":"space-y-3",children:[x?null:(0,s.jsxs)(VA,{variant:"line",className:E("w-full justify-start gap-1",I),children:[(0,s.jsxs)(Fm,{value:"chat",className:"gap-1.5",children:[(0,s.jsx)(Hg,{className:"h-3.5 w-3.5"}),"Chat"]}),(0,s.jsxs)(Fm,{value:"activity",className:"gap-1.5",children:[(0,s.jsx)(_b,{className:"h-3.5 w-3.5"}),"Activity"]}),(0,s.jsxs)(Fm,{value:"related-work",className:"gap-1.5",children:[(0,s.jsx)(Zg,{className:"h-3.5 w-3.5"}),"Related work"]}),vi.map(N=>(0,s.jsx)(Fm,{value:N.value,children:N.label},N.value))]}),(0,s.jsx)(hl,{"data-testid":"issue-detail-content",value:"chat",className:x?P?v?"flex min-h-0 flex-1 flex-col":"-mx-4 flex min-h-0 flex-1 flex-col":v?"flex min-h-0 flex-col":"-mx-4 -mt-4 md:-mx-6 md:-mt-6 flex min-h-0 flex-col":void 0,children:Pe==="chat"?(0,s.jsx)(t7,{issue:$,agentMap:Ot,onRepaired:a(()=>{Vt(),Qs()},"onRepaired"),baseRefUnavailableReason:Ft?null:"You don’t have permission to repair this task’s workspace.",unavailableReason:Aa?Fs?"Couldn’t check whether this task is paused. Refresh to try again.":Er?"Resume the task before retrying.":$.project?.pausedAt?"Resume the project before retrying.":Pl?"Respond to the pending question or confirmation before retrying.":null:"You don’t have permission to retry this task.",children:(0,s.jsxs)(r7,{value:{issue:$,agentMap:Ot,hasPendingInteraction:Pl,unavailableReason:Xr&&!Aa?"You don’t have permission to retry this recovery action.":Fs?"Couldn’t check whether this task is paused. Refresh to try again.":Er?"The task is paused. Resume it before retrying.":$.project?.pausedAt?"The project is paused. Resume it before retrying.":null,onRetry:a(N=>qe.mutateAsync(N).then(()=>{}),"onRetry")},children:[(0,s.jsx)(dQ,{issue:$,canManage:ha,onRecorded:a(()=>{Qs(),R.invalidateQueries({queryKey:G.issues.detail(i)}),R.invalidateQueries({queryKey:G.issues.runs(i)})},"onRecorded")},`${$.activeRecoveryAction?.id}:${JSON.stringify($.activeRecoveryAction?.evidence?.controllerAuthority)}`),(0,s.jsx)(Vde,{executionBlocked:!!$.executionBlocker,interruption:$.interruption,retryPreparing:tn.optimistic,queryIssueId:i??$.id,hasLiveConnection:ks,onOpenSkill:Bc,browsers:Ol.data,onOpenBrowser:a(N=>{Vd(N),P?ce(!0):Or()},"onOpenBrowser"),threadHeader:(0,s.jsxs)(s.Fragment,{children:[uP,(0,s.jsx)(KQ,{companyId:$.companyId,issueId:$.id},$.id),(Rn||Bs.isError)&&(0,s.jsxs)("div",{role:"alert",className:"flex items-center gap-2 px-4 text-sm text-destructive",children:[(0,s.jsx)("span",{children:"Could not load created tasks."}),(0,s.jsx)(W,{variant:"ghost",size:"sm",onClick:a(()=>{sn(),Bs.refetch()},"onClick"),children:"Retry"})]})]}),issueBrief:x&&!$.conversationAgentId&&$.originKind!=="onboarding_first_task"?{description:$.description??"",author:$.createdByAgentId?"agent":"human",authorName:$.createdByAgentId?Ot.get($.createdByAgentId)?.name??"Agent":void 0,agent:$.createdByAgentId?Ot.get($.createdByAgentId)??{id:$.createdByAgentId}:void 0,agentIcon:$.createdByAgentId?Ot.get($.createdByAgentId)?.icon:void 0,createdAt:$.createdAt,onSave:a(N=>U.mutateAsync({description:N}),"onSave"),mentions:Tn,externalReferences:Ye.isEnabled?Ye.markdownReferences:void 0,imageUploadHandler:a(async N=>(await Rr.mutateAsync(N)).contentPath,"imageUploadHandler"),onDropFile:a(async N=>{await Rr.mutateAsync(N)},"onDropFile")}:void 0,issueId:e&&!e.issue?"":$.id,companyId:$.companyId,projectId:$.projectId??null,issueStatus:$.status,issueAssigneeAgentId:$.assigneeAgentId,assigneeAdapterOverrides:$.assigneeAdapterOverrides,issueWorkMode:$.workMode??"standard",executionRunId:$.executionRunId??null,blockedBy:$.blockedBy??[],liveIssueIds:Wa,blockerAttention:$.blockerAttention??null,stalledDependencies:$.stalledDependencies,successfulRunHandoff:$.successfulRunHandoff??null,scheduledRetry:$.scheduledRetry??null,recoveryAction:$.interruption?.responsibility==="system"||QE($.activeRecoveryAction?.cause)?null:$.activeRecoveryAction??null,onResolveRecoveryAction:B0,onReissueIsolatedRecoveryAction:V$,reissueIsolatedRecoveryActionPending:F0.isPending,onReconcileForwardRecoveryAction:H$,onBreakGlassOverrideRecoveryAction:Q$,onQuarantineRestoreRecoveryAction:G$,quarantineRestoreRecoveryActionPending:Kl.isPending,canBreakGlassRecoveryAction:Ft,reconcileRecoveryActionPending:Kl.isPending,canFalsePositiveRecoveryAction:Aa,legacyRecoverySourceIssue:eP,comments:zc,commentsInitialLoading:X?kr:ze.isLoading,historyExpanded:X,onExpandHistory:pe,hasEarlierMessages:ze.data?.hasMore??!1,initialHistoryPending:Dr,initialMetadataPending:Yr||Je||Pn,initialHistoryError:(X?mr:ze.isError||jr.isError)||on||hs||za,onRetryInitialHistory:a(()=>{X?fr():ze.refetch(),pr&&!X&&jr.refetch(),Vn(),Sa(),Nr()},"onRetryInitialHistory"),locallyQueuedCommentRunIds:Ls,interactions:rr,documents:$.documentSummaries??[],createdTasks:Vo,workProducts:Hn??$.workProducts??[],attachments:zs??[],hasOlderComments:Ts&&!X?(Os.data?Os.hasNextPage:ze.data?.hasMore)??!1:Jn,commentsOlderError:Ts&&Os.isError,commentsLoadingOlder:Ts?Os.isFetching:Kn,onLoadOlderComments:ui,onRefreshLatestComments:_i,composerRef:rs,composerAccessory:Mie($)?(0,s.jsx)(Oie,{issue:$,hasActiveRun:Qn,workProducts:Hn,checkError:Lt.error?Ps(Lt.error,{action:"check the monitor"}).body:null,onCheckNow:a(()=>Lt.mutate(),"onCheckNow"),checkingNow:Lt.isPending}):null,footer:!x&&Jo?(0,s.jsx)(oie,{navigation:Jo,linkState:ss??Q.state}):null,feedbackVotes:as,feedbackDataSharingPreference:js,feedbackTermsUrl:OC,agentMap:Ot,currentUserId:Bt,userLabelMap:Lr,userProfileMap:Hs,draftKey:Ji?`paperclip:agent-chat-draft:${$.companyId}:${Bt}:${Ji.id}`:`paperclip:issue-comment-draft:${$.id}`,reassignOptions:Fc,currentAssigneeValue:bo,suggestedAssigneeValue:Bl,mentions:Tn,conversationMode:!!$.conversationAgentId,composerPause:Er?{scope:Er.isRoot&&Ht.length===0?"leaf":"subtree",pending:be.isPending&&be.variables?.mode==="resume",onResume:Er.isRoot&&ma?()=>{be.reset(),Rs("resume"),Ds(Yk||Xd),ps(!0)}:void 0,resumeHref:Er.isRoot?void 0:ra(Z$?.identifier??Er.rootIssueId)}:null,composerDisabledReason:$.conversationAgentId&&!It?.enableAgentChat?"Agent Chat is disabled in Experimental settings.":Fs?"Couldn’t check whether this task is paused. Refresh to try again.":null,composerHint:lP,queuedCommentReason:cP,onVote:Jd,onAdd:yf,onImageUpload:vf,onAttachImage:D,onInterruptQueued:we,onRemoveCommentFromCache:Zo,onDeleteComment:a(N=>Nm.mutateAsync({commentId:N}).then(()=>{}),"onDeleteComment"),onStopResponse:ma?N=>Me.mutateAsync(N):void 0,stopResponsePending:Me.isPending,pauseWorkPending:be.isPending&&be.variables?.mode==="pause",pauseWorkScope:Zd,onPauseWorkRun:ma?(N,Y)=>be.mutateAsync({mode:"pause",feedback:Y,runId:N,scope:Zd}).then(()=>{}):void 0,runFinalizationActions:dt,onWorkModeChange:a(N=>{if(($.workMode??"standard")!==N){if(e&&(!e.issue||p.current!==null)){p.current=N,h(N);return}return U.mutateAsync({workMode:N}).then(()=>{})}},"onWorkModeChange"),onCancelQueued:Ul,interruptingQueuedRunId:zr.isPending?zr.variables??null:null,pausingWorkRunId:be.isPending&&be.variables?.mode==="pause"?be.variables?.runId??null:null,onImageClick:Gd,onAcceptInteraction:Tt,onRejectInteraction:mi,onSubmitInteractionAnswers:Ur,onCancelInteraction:wf,onSkipInteraction:B$,onDismissInteraction:a(async N=>{await ji.mutateAsync(N)},"onDismissInteraction"),onSubmitInteractionVerdicts:F$,assigneeUserId:$.assigneeUserId??null,onResumeFromBacklog:z$?U$:void 0,resumeFromBacklogPending:U.isPending&&U.variables?.status==="todo",onResumeAssignee:$.assigneeAgentId?W$:void 0,resumeAssigneePending:q0.isPending,onTryAgainNoLiveExecutionPath:$.status==="blocked"&&!$.interruption&&$.activeRecoveryAction?K$:void 0,tryAgainNoLiveExecutionPathPending:ue.isPending&&ue.variables?.sourceIssueStatus==="todo",externalReferences:Ye.isEnabled?Ye.markdownReferences:void 0,linkCaseReferences:cs})]})}):null}),(0,s.jsx)(hl,{value:"activity",className:I,children:Ne==="activity"?(0,s.jsx)(Hde,{issue:$,issueId:$.id,companyId:$.companyId,issueStatus:$.status,childIssues:Ht,agentMap:Ot,hasLiveRuns:Qn,currentUserId:Bt,userProfileMap:Hs,pendingApprovalAction:oe,handoffFocusSignal:Ee,onApprovalAction:a((N,Y)=>{Ue.mutate({approvalId:N,action:Y})},"onApprovalAction"),externalReferences:Ye.isEnabled?Ye.markdownReferences:void 0}):null}),(0,s.jsx)(hl,{value:"related-work",className:I,children:(0,s.jsx)(Rie,{relatedWork:$.relatedWork,externalObjectsEnabled:Ye.isEnabled,externalObjects:Ye.isEnabled?Ye.groups:void 0,externalObjectsLoading:Ye.isEnabled?Ye.isLoading:void 0,externalObjectsError:Ye.isEnabled?Ye.isError:void 0,onRetryExternalObjects:Ye.isEnabled?Ye.refetch:void 0})}),Le&&(0,s.jsx)(hl,{value:Le.value,className:I,children:(0,s.jsx)(_A,{slot:Le.slot,context:{companyId:$.companyId,projectId:$.projectId??null,entityId:$.id,entityType:"issue"},missingBehavior:"placeholder"})})]}),(0,s.jsx)(Hle,{open:Ke,onOpenChange:a(N=>{ps(N),N||be.reset()},"onOpenChange"),mode:ms,scope:Zd,affectedCount:oP,affectedAgentCount:Jk,warnings:pt?.warnings.map(N=>N.message),loading:is,error:_s?Lde(_s):be.error?Ps(be.error).body:void 0,pending:be.isPending,valid:dP,wakeAgents:ts,onWakeAgentsChange:a(N=>{be.reset(),Ds(N)},"onWakeAgentsChange"),onRetry:a(()=>{be.reset(),ds()},"onRetry"),onApply:a(()=>be.mutate({mode:ms,scope:Zd,wakeAgents:ts&&Jk>0}),"onApply")}),(0,s.jsx)(Av,{open:ee,onOpenChange:ce,children:(0,s.jsx)($v,{side:x?"bottom":De?.documentKey==="plan"?"right":"bottom",showCloseButton:!x,className:E(x?"mobile-task-side-panel inset-0 h-dvh max-h-dvh w-full max-w-none gap-0 border-0 p-0 pt-(--sz-safe-top) pb-(--sz-safe-bottom)":De?.documentKey==="plan"?"inset-0 h-dvh w-screen max-w-none gap-0 border-0 p-0 sm:max-w-none":"max-h-(--sz-85dvh) pb-(--sz-safe-bottom)"),"data-testid":x?"mobile-task-side-panel":De?.documentKey==="plan"?"mobile-plan-panel":void 0,children:x?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Ab,{className:"sr-only",children:(0,s.jsx)(Op,{children:"Task side panel"})}),(0,s.jsx)(yC,{documentEditor:jo,pluginPanels:Va,pluginPanelsLoading:qc,openedPluginPanelKeys:Ll.current,dismissedPluginPanelKeys:wi.current,openBrowserId:Go,onBrowserOpened:Yo,issue:$,showDocumentSourceTask:l,accountScope:cr,childIssues:Ht,issueLinkState:v?Ae:void 0,onAddSubIssue:ki,onUpdate:a(N=>U.mutate(N),"onUpdate"),inline:!0,mobile:!0,hasActiveRun:ln,externalObjects:Ye.isEnabled?Ye.groups:void 0,externalObjectsLoading:Ye.isEnabled?Ye.isLoading:void 0,externalObjectsError:Ye.isEnabled?Ye.isError:void 0,onRetryExternalObjects:Ye.isEnabled?Ye.refetch:void 0,onCheckMonitorNow:a(()=>Lt.mutate(),"onCheckMonitorNow"),checkingMonitorNow:Lt.isPending,fileTabsEnabled:or,streamlinedTabs:v,showSubtasksTab:v,tasksTab:Wi,artifactsOpenRequestId:P&&!ie?.handled&&ie?.issueId===$.id?ie.requestId:void 0,onArtifactsOpened:li,onAttachmentOpened:Dl,openAttachment:_e?.issueId===$.id?_e:null,openSkillId:ae?.id??null,openSkillName:ae?.name??null,onSkillOpened:Se,documentDeepLink:De?.issueId===$.id?De:null,onRequestClose:a(()=>ce(!1),"onRequestClose")},`${$.id}:mobile`)]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Ab,{children:(0,s.jsx)(Op,{className:"text-sm",children:De?.documentKey==="plan"?"Plan":"Properties"})}),(0,s.jsx)(xu,{className:"flex-1 overflow-y-auto",children:(0,s.jsx)("div",{className:"px-4 pb-4",children:(0,s.jsx)(ev,{issue:$,childIssues:Ht,issueLinkState:v?Ae:void 0,onAddSubIssue:ki,onUpdate:a(N=>U.mutate(N),"onUpdate"),inline:!0,hasActiveRun:ln,externalObjects:Ye.isEnabled?Ye.groups:void 0,externalObjectsLoading:Ye.isEnabled?Ye.isLoading:void 0,externalObjectsError:Ye.isEnabled?Ye.isError:void 0,onRetryExternalObjects:Ye.isEnabled?Ye.refetch:void 0,onCheckMonitorNow:a(()=>Lt.mutate(),"onCheckMonitorNow"),checkingMonitorNow:Lt.isPending,documentDeepLink:De?.issueId===$.id?De:null})})})]})})}),or?(0,s.jsx)(Gde,{issueId:$.id,companyId:$.companyId,promptOpen:Re,onPromptOpenChange:ye,useSidePanel:x}):null,(0,s.jsx)(ode,{})]})})})})})}a(q$,"TaskDetailSurface");function Gde({issueId:e,companyId:t,promptOpen:n,onPromptOpenChange:r,useSidePanel:i=!1}){const o=KA();(0,u.useEffect)(()=>{!i||!n||(o.openBrowse(),r(!1))},[r,n,i,o]);const l=o.state!==null||o.browse||n,c=(n||o.browse)&&o.state===null;return(0,u.useEffect)(()=>{i||n&&(o.state===null&&!o.browse||r(!1))},[r,n,i,o.browse,o.state]),i?null:(0,s.jsx)(Lle,{issueId:e,companyId:t,open:l,showPromptWhenEmpty:c,onOpenChange:a(d=>{d||(r(!1),o.close())},"onOpenChange")})}a(Gde,"IssueFileViewer");export{QM as $,the as $n,Nl as $r,ny as $t,qhe as A,rme as Ai,xN as An,Lme as Ar,w2 as At,pi as B,Db as Bi,vz as Bn,pd as Br,whe as Bt,Boe as C,W1 as Ci,wN as Cn,Hme as Cr,U2 as Ct,Whe as D,s0 as Di,lhe as Dn,hN as Dr,Ahe as Dt,Moe as E,ame as Ei,Oz as En,Pme as Er,Rhe as Et,lie as F,zB as Fi,ohe as Fn,lz as Fr,jhe as Ft,wse as G,hue as Gi,Eme as Gn,jme as Gr,LW as Gt,qne as H,fue as Hi,Xv as Hn,_me as Hr,khe as Ht,ec as I,wB as Ii,_z as In,dx as Ir,Ihe as It,YM as J,X6 as Jn,vme as Jr,af as Jt,hh as K,zme as Kn,wme as Kr,t2 as Kt,iie as L,Tue as Li,ihe as Ln,Wb as Lr,NK as Lt,noe as M,tme as Mi,kT as Mn,Mme as Mr,f0 as Mt,vie as N,dF as Ni,Mz as Nn,nhe as Nr,Ac as Nt,Fhe as O,ime as Oi,Pz as On,lT as Or,Che as Ot,gie as P,t0 as Pi,wT as Pn,Rme as Pr,Nhe as Pt,GM as Q,qme as Qn,Ch as Qr,si as Qt,Wae as R,nB as Ri,vT as Rn,V6 as Rr,JN as Rt,x$ as S,pme as Si,hhe as Sn,cz as Sr,p0 as St,Uhe as T,nme as Ti,jT as Tn,rhe as Tr,Iw as Tt,ep as U,uue as Ui,yz as Un,Ime as Ur,c2 as Ut,cae as V,Mue as Vi,fT as Vn,cx as Vr,FW as Vt,Ene as W,mue as Wi,Xme as Wn,yme as Wr,OW as Wt,Ete as X,ez as Xn,HR as Xr,V8 as Xt,Mte as Y,J6 as Yn,Nme as Yr,uw as Yt,By as Z,Ame as Zn,xme as Zr,sg as Zt,Hhe as _,i6 as _i,IT as _n,$me as _r,CH as _t,Zhe as a,Km as ai,BT as an,Zme as ar,Ww as at,ile as b,G1 as bi,dhe as bn,Gme as br,dV as bt,nde as c,x6 as ci,OT as cn,Fme as cr,pQ as ct,Sce as d,_R as di,fhe as dn,she as dr,qE as dt,Uu as ei,p8 as en,Bme as er,Ym as et,tce as f,f6 as fi,Jb as fn,rz as fr,cQ as ft,Xle as g,o6 as gi,aw as gn,Ome as gr,AH as gt,Vhe as h,c6 as hi,AT as hn,bl as hr,DE as ht,Xhe as i,I6 as ii,xhe as in,Kme as ir,IQ as it,Bhe as j,yF as ji,Zv as jn,ahe as jr,She as jt,ioe as k,ome as ki,yN as kn,Kb as kr,_he as kt,Cce as l,Fb as li,phe as ln,Wme as lr,The as lt,Khe as m,gR as mi,Xb as mn,rT as mr,LE as mt,q$ as n,bme as ni,yhe as nn,Ume as nr,WQ as nt,efe as o,j6 as oi,ghe as on,aT as or,KE as ot,ece as p,u6 as pi,Iu as pn,iT as pr,zw as pt,nse as q,Jme as qn,kme as qr,vhe as qt,MC as r,Nn as ri,m8 as rn,Vme as rr,LQ as rt,ode as s,k6 as si,Np as sn,ehe as sr,_u as st,tfe as t,gme as ti,bhe as tn,Dme as tr,dG as tt,_ce as u,_h as ui,Th as un,Jv as ur,gQ as ut,Hle as v,tR as vi,tw as vn,Qme as vr,PV as vt,zhe as w,lme as wi,che as wn,Yme as wr,P2 as wt,Goe as x,H1 as xi,mhe as xn,Tme as xr,mf as xt,Vle as y,a6 as yi,uhe as yn,oT as yr,$V as yt,gf as z,Eue as zi,pT as zn,Cme as zr,yw as zt};