@hotmeshio/long-tail 0.22.3 → 0.23.0

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 (198) hide show
  1. package/build/api/escalations/accumulate.js +7 -1
  2. package/build/api/escalations/resolve-batch.d.ts +2 -1
  3. package/build/api/escalations/resolve-batch.js +6 -5
  4. package/build/services/escalation/batch.d.ts +4 -4
  5. package/build/services/escalation/batch.js +7 -4
  6. package/build/services/orchestrator/condition.d.ts +4 -1
  7. package/build/services/orchestrator/condition.js +4 -1
  8. package/build/types/escalation.d.ts +9 -0
  9. package/build/types/escalation.js +2 -0
  10. package/build/types/index.d.ts +1 -1
  11. package/dashboard/dist/assets/{AdminDashboard-hI5-kKpL.js → AdminDashboard-DKrqLGjn.js} +2 -2
  12. package/dashboard/dist/assets/{AdminDashboard-hI5-kKpL.js.map → AdminDashboard-DKrqLGjn.js.map} +1 -1
  13. package/dashboard/dist/assets/{AgentConfigPage-DetU4HZe.js → AgentConfigPage-BoQhRW6U.js} +2 -2
  14. package/dashboard/dist/assets/{AgentConfigPage-DetU4HZe.js.map → AgentConfigPage-BoQhRW6U.js.map} +1 -1
  15. package/dashboard/dist/assets/{AgentDetailPage-DrGXo8KQ.js → AgentDetailPage-DZhzuZmO.js} +2 -2
  16. package/dashboard/dist/assets/{AgentDetailPage-DrGXo8KQ.js.map → AgentDetailPage-DZhzuZmO.js.map} +1 -1
  17. package/dashboard/dist/assets/{AgentsPage-D4md5BzM.js → AgentsPage-5MynmbWX.js} +2 -2
  18. package/dashboard/dist/assets/{AgentsPage-D4md5BzM.js.map → AgentsPage-5MynmbWX.js.map} +1 -1
  19. package/dashboard/dist/assets/{AvailableEscalationsPage-B2bS2ZJy.js → AvailableEscalationsPage-CWMyy3IL.js} +2 -2
  20. package/dashboard/dist/assets/{AvailableEscalationsPage-B2bS2ZJy.js.map → AvailableEscalationsPage-CWMyy3IL.js.map} +1 -1
  21. package/dashboard/dist/assets/{BotPicker-BXtey255.js → BotPicker-C3LR6Sqy.js} +2 -2
  22. package/dashboard/dist/assets/{BotPicker-BXtey255.js.map → BotPicker-C3LR6Sqy.js.map} +1 -1
  23. package/dashboard/dist/assets/{BulkAssignModal-CSL_PeZv.js → BulkAssignModal-COjoOIIH.js} +2 -2
  24. package/dashboard/dist/assets/{BulkAssignModal-CSL_PeZv.js.map → BulkAssignModal-COjoOIIH.js.map} +1 -1
  25. package/dashboard/dist/assets/{CapabilitiesPage-5scufTHW.js → CapabilitiesPage-DKxLvOfB.js} +2 -2
  26. package/dashboard/dist/assets/{CapabilitiesPage-5scufTHW.js.map → CapabilitiesPage-DKxLvOfB.js.map} +1 -1
  27. package/dashboard/dist/assets/{CollapsibleSection-DjjDGxP_.js → CollapsibleSection-Cz5sRx-r.js} +2 -2
  28. package/dashboard/dist/assets/{CollapsibleSection-DjjDGxP_.js.map → CollapsibleSection-Cz5sRx-r.js.map} +1 -1
  29. package/dashboard/dist/assets/{ConfirmDeleteModal-DJSmsHQM.js → ConfirmDeleteModal-Beq1vQtY.js} +2 -2
  30. package/dashboard/dist/assets/{ConfirmDeleteModal-DJSmsHQM.js.map → ConfirmDeleteModal-Beq1vQtY.js.map} +1 -1
  31. package/dashboard/dist/assets/{CountdownTimer-C5ZRYPfF.js → CountdownTimer-BUBl_4mP.js} +2 -2
  32. package/dashboard/dist/assets/{CountdownTimer-C5ZRYPfF.js.map → CountdownTimer-BUBl_4mP.js.map} +1 -1
  33. package/dashboard/dist/assets/{CredentialsPage-CV6e60yC.js → CredentialsPage-DhiHiPsG.js} +2 -2
  34. package/dashboard/dist/assets/{CredentialsPage-CV6e60yC.js.map → CredentialsPage-DhiHiPsG.js.map} +1 -1
  35. package/dashboard/dist/assets/{CronLabel-CnqhqW0B.js → CronLabel-C9SkawB-.js} +2 -2
  36. package/dashboard/dist/assets/{CronLabel-CnqhqW0B.js.map → CronLabel-C9SkawB-.js.map} +1 -1
  37. package/dashboard/dist/assets/{ElapsedCell-C1IOn-tj.js → ElapsedCell-BeK1SUDK.js} +2 -2
  38. package/dashboard/dist/assets/{ElapsedCell-C1IOn-tj.js.map → ElapsedCell-BeK1SUDK.js.map} +1 -1
  39. package/dashboard/dist/assets/{EntityTimelinePanel-Dz6Liig4.js → EntityTimelinePanel-BThdefKj.js} +2 -2
  40. package/dashboard/dist/assets/{EntityTimelinePanel-Dz6Liig4.js.map → EntityTimelinePanel-BThdefKj.js.map} +1 -1
  41. package/dashboard/dist/assets/{EscalationListSchemaPage-bgdmLmrh.js → EscalationListSchemaPage-DlDIYb-p.js} +2 -2
  42. package/dashboard/dist/assets/{EscalationListSchemaPage-bgdmLmrh.js.map → EscalationListSchemaPage-DlDIYb-p.js.map} +1 -1
  43. package/dashboard/dist/assets/{EscalationListView-CrlD3ZGt.js → EscalationListView-DTIVuym4.js} +2 -2
  44. package/dashboard/dist/assets/{EscalationListView-CrlD3ZGt.js.map → EscalationListView-DTIVuym4.js.map} +1 -1
  45. package/dashboard/dist/assets/{EscalationSchemaPage-dxXO_T3t.js → EscalationSchemaPage-CQt-Embr.js} +2 -2
  46. package/dashboard/dist/assets/{EscalationSchemaPage-dxXO_T3t.js.map → EscalationSchemaPage-CQt-Embr.js.map} +1 -1
  47. package/dashboard/dist/assets/{EscalationTimeline-C3WQZQuM.js → EscalationTimeline-DNKNp6pL.js} +2 -2
  48. package/dashboard/dist/assets/{EscalationTimeline-C3WQZQuM.js.map → EscalationTimeline-DNKNp6pL.js.map} +1 -1
  49. package/dashboard/dist/assets/{EscalationTitleSelect-CTtcETUO.js → EscalationTitleSelect-Dewrv8wX.js} +2 -2
  50. package/dashboard/dist/assets/{EscalationTitleSelect-CTtcETUO.js.map → EscalationTitleSelect-Dewrv8wX.js.map} +1 -1
  51. package/dashboard/dist/assets/{EscalationsOverview-DAjZ7JY2.js → EscalationsOverview-BzH-Y-5x.js} +2 -2
  52. package/dashboard/dist/assets/{EscalationsOverview-DAjZ7JY2.js.map → EscalationsOverview-BzH-Y-5x.js.map} +1 -1
  53. package/dashboard/dist/assets/{EventTable-B72DQP_v.js → EventTable-C97m6IZv.js} +2 -2
  54. package/dashboard/dist/assets/{EventTable-B72DQP_v.js.map → EventTable-C97m6IZv.js.map} +1 -1
  55. package/dashboard/dist/assets/{FilterBar-CCTaA_LH.js → FilterBar-D-6xVHIw.js} +2 -2
  56. package/dashboard/dist/assets/{FilterBar-CCTaA_LH.js.map → FilterBar-D-6xVHIw.js.map} +1 -1
  57. package/dashboard/dist/assets/{GraphInvokePage-CAsCgFo3.js → GraphInvokePage-Bwi8EF9Y.js} +2 -2
  58. package/dashboard/dist/assets/{GraphInvokePage-CAsCgFo3.js.map → GraphInvokePage-Bwi8EF9Y.js.map} +1 -1
  59. package/dashboard/dist/assets/{HomePage-DseE_iSr.js → HomePage-Z_Q03C0z.js} +2 -2
  60. package/dashboard/dist/assets/{HomePage-DseE_iSr.js.map → HomePage-Z_Q03C0z.js.map} +1 -1
  61. package/dashboard/dist/assets/{ListToolbar-1zdqnjW6.js → ListToolbar-_jWTw5no.js} +2 -2
  62. package/dashboard/dist/assets/{ListToolbar-1zdqnjW6.js.map → ListToolbar-_jWTw5no.js.map} +1 -1
  63. package/dashboard/dist/assets/{McpOverview-DS_JXDW5.js → McpOverview-CjqTuP0N.js} +2 -2
  64. package/dashboard/dist/assets/{McpOverview-DS_JXDW5.js.map → McpOverview-CjqTuP0N.js.map} +1 -1
  65. package/dashboard/dist/assets/{McpQueryDetailPage-BeMUGcv3.js → McpQueryDetailPage-leCsje1U.js} +2 -2
  66. package/dashboard/dist/assets/{McpQueryDetailPage-BeMUGcv3.js.map → McpQueryDetailPage-leCsje1U.js.map} +1 -1
  67. package/dashboard/dist/assets/{McpQueryPage-CeiLO_LR.js → McpQueryPage-C-PyXYX4.js} +2 -2
  68. package/dashboard/dist/assets/{McpQueryPage-CeiLO_LR.js.map → McpQueryPage-C-PyXYX4.js.map} +1 -1
  69. package/dashboard/dist/assets/{McpRunDetailPage-DYp1uZK2.js → McpRunDetailPage-JDrr3uUQ.js} +2 -2
  70. package/dashboard/dist/assets/{McpRunDetailPage-DYp1uZK2.js.map → McpRunDetailPage-JDrr3uUQ.js.map} +1 -1
  71. package/dashboard/dist/assets/{McpRunsPage-VeaDzcL4.js → McpRunsPage-DERXQLgZ.js} +2 -2
  72. package/dashboard/dist/assets/{McpRunsPage-VeaDzcL4.js.map → McpRunsPage-DERXQLgZ.js.map} +1 -1
  73. package/dashboard/dist/assets/{OperationsPage-DK2mgaXf.js → OperationsPage-B2DA7n9m.js} +2 -2
  74. package/dashboard/dist/assets/{OperationsPage-DK2mgaXf.js.map → OperationsPage-B2DA7n9m.js.map} +1 -1
  75. package/dashboard/dist/assets/{OperatorDashboard-BNjLF0f7.js → OperatorDashboard-C8RtPv8P.js} +2 -2
  76. package/dashboard/dist/assets/{OperatorDashboard-BNjLF0f7.js.map → OperatorDashboard-C8RtPv8P.js.map} +1 -1
  77. package/dashboard/dist/assets/{PersonaDetailPage-IQ2fZLa6.js → PersonaDetailPage-ChXwJ6u5.js} +2 -2
  78. package/dashboard/dist/assets/{PersonaDetailPage-IQ2fZLa6.js.map → PersonaDetailPage-ChXwJ6u5.js.map} +1 -1
  79. package/dashboard/dist/assets/{PersonasPage-DpGFEcU-.js → PersonasPage-BFFxncSE.js} +2 -2
  80. package/dashboard/dist/assets/{PersonasPage-DpGFEcU-.js.map → PersonasPage-BFFxncSE.js.map} +1 -1
  81. package/dashboard/dist/assets/{PortalPage-D07xyvG_.js → PortalPage-Xk1zVneM.js} +2 -2
  82. package/dashboard/dist/assets/{PortalPage-D07xyvG_.js.map → PortalPage-Xk1zVneM.js.map} +1 -1
  83. package/dashboard/dist/assets/{ProcessDetailPage-t8EEYSMk.js → ProcessDetailPage-D7EYwW-j.js} +2 -2
  84. package/dashboard/dist/assets/{ProcessDetailPage-t8EEYSMk.js.map → ProcessDetailPage-D7EYwW-j.js.map} +1 -1
  85. package/dashboard/dist/assets/{ProcessesListPage-BDUXLFdb.js → ProcessesListPage-CakYRtnE.js} +2 -2
  86. package/dashboard/dist/assets/{ProcessesListPage-BDUXLFdb.js.map → ProcessesListPage-CakYRtnE.js.map} +1 -1
  87. package/dashboard/dist/assets/{ResolverForm-BwWOYv_Z.js → ResolverForm-BwVOJUpJ.js} +2 -2
  88. package/dashboard/dist/assets/{ResolverForm-BwWOYv_Z.js.map → ResolverForm-BwVOJUpJ.js.map} +1 -1
  89. package/dashboard/dist/assets/{RoleDetailPage-zMF3x2xi.js → RoleDetailPage-CKbGwezP.js} +2 -2
  90. package/dashboard/dist/assets/{RoleDetailPage-zMF3x2xi.js.map → RoleDetailPage-CKbGwezP.js.map} +1 -1
  91. package/dashboard/dist/assets/{RolesPage-CEBp_PpL.js → RolesPage-Czu7Zku4.js} +2 -2
  92. package/dashboard/dist/assets/{RolesPage-CEBp_PpL.js.map → RolesPage-Czu7Zku4.js.map} +1 -1
  93. package/dashboard/dist/assets/{RunAsSelector-CC_EHN3z.js → RunAsSelector-6BLScYTX.js} +2 -2
  94. package/dashboard/dist/assets/{RunAsSelector-CC_EHN3z.js.map → RunAsSelector-6BLScYTX.js.map} +1 -1
  95. package/dashboard/dist/assets/{ScanCodesPage-DD4uU-jY.js → ScanCodesPage-Cv9q8Bvt.js} +2 -2
  96. package/dashboard/dist/assets/{ScanCodesPage-DD4uU-jY.js.map → ScanCodesPage-Cv9q8Bvt.js.map} +1 -1
  97. package/dashboard/dist/assets/{ScanSchemeDetailPage-CUW8gYFh.js → ScanSchemeDetailPage-BxazXYIc.js} +2 -2
  98. package/dashboard/dist/assets/{ScanSchemeDetailPage-CUW8gYFh.js.map → ScanSchemeDetailPage-BxazXYIc.js.map} +1 -1
  99. package/dashboard/dist/assets/{ScanStationPage-DpO_ESuf.js → ScanStationPage-Cg8LCFR7.js} +2 -2
  100. package/dashboard/dist/assets/{ScanStationPage-DpO_ESuf.js.map → ScanStationPage-Cg8LCFR7.js.map} +1 -1
  101. package/dashboard/dist/assets/{StickyPagination-cNqSDm5f.js → StickyPagination-DsdtYoXR.js} +2 -2
  102. package/dashboard/dist/assets/{StickyPagination-cNqSDm5f.js.map → StickyPagination-DsdtYoXR.js.map} +1 -1
  103. package/dashboard/dist/assets/{StreamMessageDetail-C4oZqQdB.js → StreamMessageDetail-CT3FQoT3.js} +2 -2
  104. package/dashboard/dist/assets/{StreamMessageDetail-C4oZqQdB.js.map → StreamMessageDetail-CT3FQoT3.js.map} +1 -1
  105. package/dashboard/dist/assets/{SwimlaneTimeline-BjBiV7GT.js → SwimlaneTimeline-C8TjkJ10.js} +2 -2
  106. package/dashboard/dist/assets/{SwimlaneTimeline-BjBiV7GT.js.map → SwimlaneTimeline-C8TjkJ10.js.map} +1 -1
  107. package/dashboard/dist/assets/{TaskDetailPage-pO_AnVS1.js → TaskDetailPage-DGUzdBFN.js} +2 -2
  108. package/dashboard/dist/assets/{TaskDetailPage-pO_AnVS1.js.map → TaskDetailPage-DGUzdBFN.js.map} +1 -1
  109. package/dashboard/dist/assets/{TasksListPage-DKDHlWP7.js → TasksListPage-BVIP6-EZ.js} +2 -2
  110. package/dashboard/dist/assets/{TasksListPage-DKDHlWP7.js.map → TasksListPage-BVIP6-EZ.js.map} +1 -1
  111. package/dashboard/dist/assets/{TimeAgo-D2qchUuJ.js → TimeAgo-C-rd9F9g.js} +2 -2
  112. package/dashboard/dist/assets/{TimeAgo-D2qchUuJ.js.map → TimeAgo-C-rd9F9g.js.map} +1 -1
  113. package/dashboard/dist/assets/{TimestampCell-DeswZGGo.js → TimestampCell-DPbchDOI.js} +2 -2
  114. package/dashboard/dist/assets/{TimestampCell-DeswZGGo.js.map → TimestampCell-DPbchDOI.js.map} +1 -1
  115. package/dashboard/dist/assets/{ToolTestPanel-DJh7PIUa.js → ToolTestPanel-DAUC8DHK.js} +2 -2
  116. package/dashboard/dist/assets/{ToolTestPanel-DJh7PIUa.js.map → ToolTestPanel-DAUC8DHK.js.map} +1 -1
  117. package/dashboard/dist/assets/{TopicDetailPage-CsgDJ4Z4.js → TopicDetailPage-70mMKBzG.js} +2 -2
  118. package/dashboard/dist/assets/{TopicDetailPage-CsgDJ4Z4.js.map → TopicDetailPage-70mMKBzG.js.map} +1 -1
  119. package/dashboard/dist/assets/{TopicsPage-tBRZDVDN.js → TopicsPage-CE3hBthn.js} +2 -2
  120. package/dashboard/dist/assets/{TopicsPage-tBRZDVDN.js.map → TopicsPage-CE3hBthn.js.map} +1 -1
  121. package/dashboard/dist/assets/{UserName-B-5JcDck.js → UserName-BDBDA-LR.js} +2 -2
  122. package/dashboard/dist/assets/{UserName-B-5JcDck.js.map → UserName-BDBDA-LR.js.map} +1 -1
  123. package/dashboard/dist/assets/{WorkflowExecutionPage-BPHVnhp6.js → WorkflowExecutionPage-BbkLZ1co.js} +2 -2
  124. package/dashboard/dist/assets/{WorkflowExecutionPage-BPHVnhp6.js.map → WorkflowExecutionPage-BbkLZ1co.js.map} +1 -1
  125. package/dashboard/dist/assets/{WorkflowsDashboard-CxLlfZmY.js → WorkflowsDashboard-Bp1L7Ggz.js} +2 -2
  126. package/dashboard/dist/assets/{WorkflowsDashboard-CxLlfZmY.js.map → WorkflowsDashboard-Bp1L7Ggz.js.map} +1 -1
  127. package/dashboard/dist/assets/{WorkflowsOverview-C4az5rwp.js → WorkflowsOverview-IeTKHAi4.js} +2 -2
  128. package/dashboard/dist/assets/{WorkflowsOverview-C4az5rwp.js.map → WorkflowsOverview-IeTKHAi4.js.map} +1 -1
  129. package/dashboard/dist/assets/{YamlWorkflowDetailPage-BmhlAUFQ.js → YamlWorkflowDetailPage-DtKCXnKt.js} +2 -2
  130. package/dashboard/dist/assets/{YamlWorkflowDetailPage-BmhlAUFQ.js.map → YamlWorkflowDetailPage-DtKCXnKt.js.map} +1 -1
  131. package/dashboard/dist/assets/{YamlWorkflowsPage-CSbG5o2V.js → YamlWorkflowsPage-CEcZBV_3.js} +2 -2
  132. package/dashboard/dist/assets/{YamlWorkflowsPage-CSbG5o2V.js.map → YamlWorkflowsPage-CEcZBV_3.js.map} +1 -1
  133. package/dashboard/dist/assets/{agents-BohEn7vw.js → agents-BT-sEk81.js} +2 -2
  134. package/dashboard/dist/assets/{agents-BohEn7vw.js.map → agents-BT-sEk81.js.map} +1 -1
  135. package/dashboard/dist/assets/{bots-BG2EO-Wi.js → bots-DRoAdLek.js} +2 -2
  136. package/dashboard/dist/assets/{bots-BG2EO-Wi.js.map → bots-DRoAdLek.js.map} +1 -1
  137. package/dashboard/dist/assets/{capabilities-CeFrBmYX.js → capabilities-Bc-nJk6y.js} +2 -2
  138. package/dashboard/dist/assets/{capabilities-CeFrBmYX.js.map → capabilities-Bc-nJk6y.js.map} +1 -1
  139. package/dashboard/dist/assets/{controlplane-Dhvt8l8F.js → controlplane-aXceSIRf.js} +2 -2
  140. package/dashboard/dist/assets/{controlplane-Dhvt8l8F.js.map → controlplane-aXceSIRf.js.map} +1 -1
  141. package/dashboard/dist/assets/{escalation-columns-BWMNxImp.js → escalation-columns-Bf09Q89t.js} +2 -2
  142. package/dashboard/dist/assets/{escalation-columns-BWMNxImp.js.map → escalation-columns-Bf09Q89t.js.map} +1 -1
  143. package/dashboard/dist/assets/{index-CtZWpy22.js → index-BCFEQEMC.js} +2 -2
  144. package/dashboard/dist/assets/{index-CtZWpy22.js.map → index-BCFEQEMC.js.map} +1 -1
  145. package/dashboard/dist/assets/{index-dYKgd06u.js → index-BEPKAjna.js} +2 -2
  146. package/dashboard/dist/assets/{index-dYKgd06u.js.map → index-BEPKAjna.js.map} +1 -1
  147. package/dashboard/dist/assets/{index-fUsx_gYx.js → index-BUYokcrl.js} +3 -3
  148. package/dashboard/dist/assets/{index-fUsx_gYx.js.map → index-BUYokcrl.js.map} +1 -1
  149. package/dashboard/dist/assets/{index-Y-bdW8vo.js → index-Ba-s5Yb5.js} +2 -2
  150. package/dashboard/dist/assets/{index-Y-bdW8vo.js.map → index-Ba-s5Yb5.js.map} +1 -1
  151. package/dashboard/dist/assets/{index-Dc_zWK23.js → index-C3VTJcrp.js} +2 -2
  152. package/dashboard/dist/assets/{index-Dc_zWK23.js.map → index-C3VTJcrp.js.map} +1 -1
  153. package/dashboard/dist/assets/{index-Dc3Om6G3.js → index-CZyO9hRb.js} +2 -2
  154. package/dashboard/dist/assets/{index-Dc3Om6G3.js.map → index-CZyO9hRb.js.map} +1 -1
  155. package/dashboard/dist/assets/{index-DABkM7s-.js → index-CcgmR-7-.js} +2 -2
  156. package/dashboard/dist/assets/{index-DABkM7s-.js.map → index-CcgmR-7-.js.map} +1 -1
  157. package/dashboard/dist/assets/{index-Cl_YXEdp.js → index-CuBGGwXf.js} +2 -2
  158. package/dashboard/dist/assets/{index-Cl_YXEdp.js.map → index-CuBGGwXf.js.map} +1 -1
  159. package/dashboard/dist/assets/index-D1mKf_qz.js +3 -0
  160. package/dashboard/dist/assets/index-D1mKf_qz.js.map +1 -0
  161. package/dashboard/dist/assets/{index-D90D9y0J.js → index-DBxpyIw5.js} +2 -2
  162. package/dashboard/dist/assets/{index-D90D9y0J.js.map → index-DBxpyIw5.js.map} +1 -1
  163. package/dashboard/dist/assets/{index-C8VlM2Oe.js → index-DH03y-UT.js} +2 -2
  164. package/dashboard/dist/assets/{index-C8VlM2Oe.js.map → index-DH03y-UT.js.map} +1 -1
  165. package/dashboard/dist/assets/{index-CiqSVDga.js → index-Djsoi8DI.js} +2 -2
  166. package/dashboard/dist/assets/{index-CiqSVDga.js.map → index-Djsoi8DI.js.map} +1 -1
  167. package/dashboard/dist/assets/{index-Bd_dgyfJ.js → index-h2gX31B2.js} +2 -2
  168. package/dashboard/dist/assets/{index-Bd_dgyfJ.js.map → index-h2gX31B2.js.map} +1 -1
  169. package/dashboard/dist/assets/{knowledge-CCcTidNV.js → knowledge-BhW8V-Hq.js} +2 -2
  170. package/dashboard/dist/assets/{knowledge-CCcTidNV.js.map → knowledge-BhW8V-Hq.js.map} +1 -1
  171. package/dashboard/dist/assets/{mcp-CLA1z7Pg.js → mcp-BYfSMQzh.js} +2 -2
  172. package/dashboard/dist/assets/{mcp-CLA1z7Pg.js.map → mcp-BYfSMQzh.js.map} +1 -1
  173. package/dashboard/dist/assets/{mcp-query-CWG0WMAs.js → mcp-query-DUJoOk_q.js} +2 -2
  174. package/dashboard/dist/assets/{mcp-query-CWG0WMAs.js.map → mcp-query-DUJoOk_q.js.map} +1 -1
  175. package/dashboard/dist/assets/{personas-8jURIzx6.js → personas-jT1O_SB4.js} +2 -2
  176. package/dashboard/dist/assets/{personas-8jURIzx6.js.map → personas-jT1O_SB4.js.map} +1 -1
  177. package/dashboard/dist/assets/{pipelines-hVVRAXqG.js → pipelines-Bp-wIaz2.js} +2 -2
  178. package/dashboard/dist/assets/{pipelines-hVVRAXqG.js.map → pipelines-Bp-wIaz2.js.map} +1 -1
  179. package/dashboard/dist/assets/{tasks-BE1O57Bf.js → tasks-CCrvnXbz.js} +2 -2
  180. package/dashboard/dist/assets/{tasks-BE1O57Bf.js.map → tasks-CCrvnXbz.js.map} +1 -1
  181. package/dashboard/dist/assets/{topics-Bg96Wp1r.js → topics-Blft0I1L.js} +2 -2
  182. package/dashboard/dist/assets/{topics-Bg96Wp1r.js.map → topics-Blft0I1L.js.map} +1 -1
  183. package/dashboard/dist/assets/{useDebouncedValue-DmEveyEy.js → useDebouncedValue-BYqbcism.js} +2 -2
  184. package/dashboard/dist/assets/{useDebouncedValue-DmEveyEy.js.map → useDebouncedValue-BYqbcism.js.map} +1 -1
  185. package/dashboard/dist/assets/{useNamespace-DHgkzIuL.js → useNamespace-BfxJAUgG.js} +2 -2
  186. package/dashboard/dist/assets/{useNamespace-DHgkzIuL.js.map → useNamespace-BfxJAUgG.js.map} +1 -1
  187. package/dashboard/dist/assets/{useYamlActivityEvents-RU0PvU8S.js → useYamlActivityEvents-BukJuWpb.js} +2 -2
  188. package/dashboard/dist/assets/{useYamlActivityEvents-RU0PvU8S.js.map → useYamlActivityEvents-BukJuWpb.js.map} +1 -1
  189. package/dashboard/dist/assets/{yaml-workflows-DQWE9ijc.js → yaml-workflows-DeRWqMGk.js} +2 -2
  190. package/dashboard/dist/assets/{yaml-workflows-DQWE9ijc.js.map → yaml-workflows-DeRWqMGk.js.map} +1 -1
  191. package/dashboard/dist/index.html +1 -1
  192. package/docs/accumulator.md +1 -1
  193. package/docs/api/sdk/escalations.md +1 -1
  194. package/docs/hitl/escalation.md +12 -0
  195. package/docs/hitl/resolution.md +1 -1
  196. package/package.json +2 -2
  197. package/dashboard/dist/assets/index-Dbwu51xm.js +0 -3
  198. package/dashboard/dist/assets/index-Dbwu51xm.js.map +0 -1
@@ -100,11 +100,23 @@ The declaration folds into the row at creation, inside the same Leg1 commit:
100
100
  - `metadata.batch_keys` — the immutable declared list (progress = `batch_keys` minus `batch_pending`)
101
101
  - `envelope.batch_items` — the accumulated `Record<itemKey, payload>` map (payloads are plumbing, so they live on the unindexed envelope; payload keys are caller-owned)
102
102
  - `envelope.batch_filled_at` — `Record<itemKey, iso8601>`, stamped by the database clock inside each fill statement — the collection timeline as row truth
103
+ - `envelope.batch_filled_by` — `Record<itemKey, userId>`, the actor of each fill, written in the same statement (every API fill records its caller)
103
104
 
104
105
  Items are submitted via `POST /api/escalations/:id/resolve-batch-item`, `POST /api/escalations/resolve-batch-item-by-signal-key` (the deterministic home signal id — no UUID lookup, no facet duplication), or `POST /api/escalations/resolve-batch-item-by-metadata` (see [Resolution — Batch items](resolution.md)). Each item validates against the same versioned role form a single-item resolver gets, `schemaVersion` pins included. Each fill is one guarded statement: the payload lands only while its key is still pending (duplicates return `duplicate-item` untouched), and the LAST fill resolves the row, stores the assembled collection as `resolver_payload`, and wakes this wait — atomically. The completing submission's `$resolution` rides the delivered collection.
105
106
 
106
107
  `timeout` and cancellation keep their standard semantics (`false` / `null`); a plain resolve on a batch row remains an admin override that resolves the whole row with the payload given. Add `partialOnTimeout: true` (hotmesh 0.29.0+) and the timer instead resumes the wait with the items filled so far plus `$trigger: 'timeout'`, the same value the expired row stores as `resolver_payload`.
107
108
 
109
+ Entries already satisfied before the wait begins go in `filled` (hotmesh 0.31.0+), keyed by item key with their `payload`, the `at` they were satisfied (from the source of record, never a clock read in the workflow), and an optional `actor`. The row starts with that progress: those keys are left out of `batch_pending`, their payloads, times, and actors are written beside the rest, and the completing wake delivers them with the collection. Every key in `filled` must be declared in `batch`, and at least one must stay open; a `filled` that covers every key throws, so skip the wait instead.
110
+
111
+ ```typescript
112
+ const parts = await conditional<Record<'cut' | 'weld' | 'paint', StationResultV1>>(signalId, {
113
+ role: 'assembly',
114
+ metadata: { orderId },
115
+ batch: ['cut', 'weld', 'paint'],
116
+ filled: { cut: { payload: { station: 'cut-1', ok: true }, at: cutRecord.completedAt, actor: cutRecord.userId } },
117
+ });
118
+ ```
119
+
108
120
  ### Open accumulation — items arrive over time
109
121
 
110
122
  Declare `accumulate` and the escalation becomes an open container: items join it one at a time through `accumulateItem` while the row stays pending, and the wait resumes with the ordered collection when the container is full, when its window closes, or when someone resolves it by hand. A timeout is a delivery, never a failure, so the wait has no `false` branch; `conditionalAccumulator` types that contract.
@@ -107,7 +107,7 @@ Interim items return `accepted` with the remaining count and publish `escalation
107
107
 
108
108
  Each item validates against the same versioned role form a single-item resolve uses, canonical 422 included. Batch fills are claim-agnostic — a batch collects contributions from multiple principals, the same rationale as the signal-key path — while `assertClaim: true` (by-id form) opts into the caller's own live-claim assertion inside the guarded statement.
109
109
 
110
- Item keys are non-empty strings up to 128 characters; prefer URL-friendly names (`u1-L`). Payload keys inside each item are caller-owned — the platform reserves no names inside `batch_items` values. Every fill stamps `envelope.batch_filled_at[itemKey]` with the database clock in the same statement, so the row carries the collection timeline as row truth. After an SLA expiry (`conditional` returns `false`) the terminal row retains the partial `batch_items` and their timestamps — read them back with `GET /api/escalations/:id` or `getEscalationBySignalKey` from an activity.
110
+ Item keys are non-empty strings up to 128 characters; prefer URL-friendly names (`u1-L`). Payload keys inside each item are caller-owned — the platform reserves no names inside `batch_items` values. Every fill stamps `envelope.batch_filled_at[itemKey]` with the database clock and `envelope.batch_filled_by[itemKey]` with the caller in the same statement, so the row carries the collection timeline and who filled each item as row truth. After an SLA expiry (`conditional` returns `false`) the terminal row retains the partial `batch_items` and their timestamps — read them back with `GET /api/escalations/:id` or `getEscalationBySignalKey` from an activity.
111
111
 
112
112
  ### Accumulator items
113
113
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/long-tail",
3
- "version": "0.22.3",
3
+ "version": "0.23.0",
4
4
  "description": "Long Tail Workflows — Durable AI workflows with human-in-the-loop escalation. Powered by PostgreSQL.",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -75,7 +75,7 @@
75
75
  "@anthropic-ai/sdk": "^0.92.0",
76
76
  "@aws-sdk/client-s3": "^3.1017.0",
77
77
  "@aws-sdk/s3-request-presigner": "^3.1045.0",
78
- "@hotmeshio/hotmesh": "^0.30.0",
78
+ "@hotmeshio/hotmesh": "^0.31.0",
79
79
  "@modelcontextprotocol/sdk": "^1.27.1",
80
80
  "@opentelemetry/exporter-trace-otlp-proto": "^0.215.0",
81
81
  "@opentelemetry/resources": "^2.5.1",
@@ -1,3 +0,0 @@
1
- import{b as qt,a as d,j as e}from"./vendor-query-DvWWuNIB.js";import{ab as Ss,ac as Cs,ad as _s,M as ot,ae as fe,m as ge,a4 as at,af as Es,ag as As,g as Ue,ah as Jt,J as Se,h as Ts,i as Is,P as Q,ai as Et,aj as nt,$ as Ut,a9 as Rs,ak as Ms,al as Os,am as Ps,an as Ds,ao as $s,ap as Ls,aq as Ws,ar as Fs,r as Vs,s as Bs,as as qs,at as Js,U as Us,V as Ks,a as Gs,c as Hs,O as zs,au as At,y as Xs,av as Tt}from"./index-fUsx_gYx.js";import{u as Kt,C as Gt,r as Qs,B as Ys,a as Zs}from"./BulkAssignModal-CSL_PeZv.js";import{E as ea,d as ta,b as Ke,R as Ht,r as sa,p as aa,a as na,w as ra,s as ia,v as la,c as oa,i as ca}from"./ResolverForm-BwWOYv_Z.js";import{a as zt,u as ct,L as _e,b as da,e as ua}from"./vendor-react-_9U4mKFr.js";import{P as ma}from"./PageHeader-CMd3f4bz.js";import{L as xa}from"./ListToolbar-1zdqnjW6.js";import{i as Ce,g as fa,a as dt,b as pa,d as ha,m as ga}from"./EscalationListView-CrlD3ZGt.js";import{S as ya}from"./StatusBadge-DHVwxre2.js";import{R as ba}from"./RolePill-Di2CAHuD.js";import{C as ze}from"./CountdownTimer-C5ZRYPfF.js";import{C as ae}from"./CopyableId-Bn02zYxt.js";import{U as ye}from"./UserName-B-5JcDck.js";import{d as ja}from"./metadata-display-B7X5hGxG.js";import{U as Xt,X as Qt,g as Na,a5 as va,Q as wa,S as ka,ap as Sa,aq as Ca,a1 as _a,o as Ea,ai as Aa,ar as Ta,b as Ia,as as Yt,at as It,au as Ra,a as Ma,V as Rt,Y as Mt,av as Oa}from"./vendor-icons-CeVtUKyP.js";import"./constants-CeBBTzf5.js";import"./useDebouncedValue-DmEveyEy.js";import"./WorkflowPill-Dg7BDTyM.js";import"./DataTable-spX1dFyb.js";import"./EmptyState-DgC_6njU.js";import"./useContainerWidth-DSLp1gEm.js";import"./StickyPagination-cNqSDm5f.js";const Pa="0";function Da(t,s){const n=t.trim();if(!n)return{ok:!1,failure:{reason:"empty",detail:"empty scan code"}};if(/^[0-9]+$/.test(n)){const c=s.find(m=>m.encoding==="fixed"&&m.version===Number(n.slice(0,2)));if(!((c==null?void 0:c.enabled)&&$a(n,c))){const m=La(n,s);if(m)return m}}const r=n.slice(0,2),i=Number(r);if(!/^[0-9]{2}$/.test(r)||i<10||i>99)return{ok:!1,failure:{reason:"unknown_version",detail:`code must start with a two-digit scheme 10-99, got "${r}"`}};const l=s.find(c=>c.version===i);return l?l.enabled?l.encoding==="gtin"?ne(l,"reads manufacturer barcodes, which carry no scheme prefix"):l.encoding==="delimited"?Wa(n,i,l):Fa(n,i,l):{ok:!1,failure:{reason:"scheme_disabled",detail:`scan scheme ${i} ("${l.name}") is disabled`}}:{ok:!1,failure:{reason:"unknown_version",detail:`no scan scheme configured for version ${i}`}}}function $a(t,s){const n=3+(s.target_length??0);return t.length===n||t.length===n+1}function La(t,s){if(!Ss(t))return null;const n=s.find(r=>r.encoding==="gtin"&&r.enabled)??s.find(r=>r.encoding==="gtin");return n?n.enabled?{ok:!0,parsed:{version:n.version,category:Pa,target:Cs(t),raw:t},scheme:n}:{ok:!1,failure:{reason:"scheme_disabled",detail:`scan scheme ${n.version} ("${n.name}") is disabled`}}:null}function Wa(t,s,n){const r=n.delimiter;if(t[2]!==r)return ne(n,`expected "${r}" after the two-digit scheme`);const i=t.slice(3,4);if(!/^[0-9]$/.test(i))return ne(n,"category must be a single digit");if(t[4]!==r)return ne(n,`expected "${r}" after the category`);const l=t.slice(5);return l?{ok:!0,parsed:{version:s,category:i,target:l},scheme:n}:ne(n,"target is empty")}function Fa(t,s,n){const r=n.target_length??0,i=3+r;if(!/^[0-9]+$/.test(t))return ne(n,"fixed encoding accepts digits only");if(t.length!==i&&t.length!==i+1)return ne(n,`expected ${i} digits (or ${i+1} with check digit), got ${t.length}`);const l=t.slice(2,3),c=t.slice(3,3+r);return{ok:!0,parsed:{version:s,category:l,target:c},scheme:n}}function ne(t,s){return{ok:!1,failure:{reason:"malformed",detail:`scheme ${t.version} ("${t.name}"): ${s}`}}}function Va({escalationId:t}){var a;const s=zt(),n=ct(),r=qt(),i=(a=s.state)==null?void 0:a[_s],[l,c]=d.useState(!1),[x,m]=d.useState(null),[u,f]=d.useState(!1);if(!i||i.escalationId!==t||u)return null;const b=()=>{f(!0),n(s.pathname,{replace:!0,state:null})},h=async()=>{var g,j,N;c(!0),m(null);try{switch(i.verb){case fe.CANCEL:await ge(`/escalations/${t}/cancel`,{method:"POST"});break;case fe.CLAIM:case fe.CLAIM_SHOW_DETAIL:await ge(`/escalations/${t}/claim`,{method:"POST",body:JSON.stringify({durationMinutes:((g=i.params)==null?void 0:g.durationMinutes)??30})});break;case fe.RELEASE:await ge(`/escalations/${t}/release`,{method:"POST"});break;case fe.RESOLVE:await ge(`/escalations/${t}/resolve`,{method:"POST",body:JSON.stringify({resolverPayload:((j=i.params)==null?void 0:j.resolverPayload)??{}})});break;case fe.ESCALATE:await ge(`/escalations/${t}/escalate`,{method:"PATCH",body:JSON.stringify({targetRole:(N=i.params)==null?void 0:N.targetRole})});break;default:throw new Error(`Unsupported confirm verb "${i.verb}"`)}r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]}),b()}catch(w){m(w.message)}finally{c(!1)}};return e.jsx(ot,{open:!0,onClose:b,title:"Confirm scan action",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-text-secondary",children:i.prompt}),x&&e.jsx("p",{className:"text-xs text-status-error",children:x}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx("button",{onClick:b,disabled:l,className:"btn-secondary text-xs",children:"No, go back"}),e.jsx("button",{onClick:h,disabled:l,className:"btn-primary text-xs",children:l?"Working…":"Yes, continue"})]})]})})}const Je={pending:"rgb(var(--lt-status-queued-graphic))",claimed:"rgb(var(--lt-status-claimed-graphic))",resolved:"rgb(var(--lt-status-success-graphic))",cancelled:"rgb(var(--lt-status-error))"},rt=4;function Ot({pct:t,place:s,label:n,title:r,emphasis:i}){const l=e.jsx("span",{className:"w-px h-1 bg-text-quaternary/70","aria-hidden":!0}),c=e.jsx("span",{className:`whitespace-nowrap leading-none tabular-nums text-[10px] ${i?"text-text-tertiary":"text-text-quaternary"}`,children:n});return e.jsx("div",{title:r,className:`absolute ${s==="above"?"bottom-0":"top-0"} flex flex-col items-center gap-0 -translate-x-1/2 cursor-help`,style:{left:`${t}%`},children:s==="above"?e.jsxs(e.Fragment,{children:[c,l]}):e.jsxs(e.Fragment,{children:[l,c]})})}function Ba({esc:t,className:s=""}){const n=new Date(t.created_at).getTime(),r=t.claimed_at?new Date(t.claimed_at).getTime():null,i=t.status==="resolved",l=t.status==="cancelled"||t.status==="expired",c=i||l,x=Ce(t),m=!!r&&(x||c),u=i&&t.resolved_at?new Date(t.resolved_at).getTime():l?new Date(t.updated_at).getTime():Date.now(),f=Math.max(u-n,1),b=m&&r?Math.max(r-n,0):f,h=m&&r?Math.max(u-r,0):0,a=Math.min(100,Math.max(0,b/f*100)),g=m?Math.max(0,100-a):0,j=i?Je.resolved:l?Je.cancelled:Je.claimed,N=i?"Resolved after":l?"Cancelled after":"In progress",w=at(b),k=at(f),S=i?`Resolved in ${k} total`:l?`Cancelled after ${k}`:`Open ${k} so far`,v=`Lifecycle bar: blue = time waiting to be claimed, ${i?"green":l?"red":"orange"} = ${N.toLowerCase()} the claim.`;return e.jsxs("div",{className:s,title:v,children:[e.jsx("div",{className:"relative h-2.5 font-mono",children:m&&e.jsx(Ot,{pct:a,place:"above",label:w,title:`Time to claim: ${w}`})}),e.jsxs("div",{className:"flex w-full rounded-full overflow-hidden",style:{height:rt,backgroundColor:"rgb(var(--lt-surface-sunken))"},title:v,children:[e.jsx("div",{style:{width:`${a}%`,minWidth:rt,backgroundColor:Je.pending,opacity:.75},title:`Waiting ${w} — created → claimed`}),m&&g>0&&e.jsx("div",{style:{width:`${g}%`,minWidth:rt,backgroundColor:j,opacity:.75},title:`${N} ${at(h)}`})]}),e.jsx("div",{className:"relative h-2.5 font-mono",children:e.jsx(Ot,{pct:100,place:"below",emphasis:!0,label:k,title:S})})]})}function qa({triage:t,payload:s}){const n=t.confidence??0,r=n>=.8?"text-status-success":n>=.5?"text-status-pending":"text-status-error",i=Ja(t.originalData,s);return e.jsxs("div",{className:"space-y-5",children:[t.diagnosis&&e.jsx("p",{className:"text-sm text-text-primary leading-relaxed",children:t.diagnosis}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-text-tertiary",children:[t.tool_calls_made!=null&&e.jsxs("span",{children:[t.tool_calls_made," tool call",t.tool_calls_made!==1?"s":""]}),t.tool_calls_made!=null&&e.jsx("span",{className:"text-text-quaternary",children:"·"}),e.jsxs("span",{className:`font-medium ${r}`,children:[Math.round(n*100),"% confidence"]})]}),t.actions_taken&&t.actions_taken.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.actions_taken.map((l,c)=>e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 text-2xs
2
- text-text-secondary`,children:[e.jsx("svg",{className:"w-3 h-3 text-status-success shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),l]},c))}),t.recommendation&&e.jsx("p",{className:"text-2xs text-text-tertiary italic",children:t.recommendation}),i.length>0&&e.jsx("div",{className:"space-y-4 pt-2",children:i.map(l=>e.jsx(Ua,{diff:l},l.key))})]})}function Ja(t,s){if(!t)return[];const n=[];for(const r of Object.keys(t)){if(r.startsWith("_"))continue;const i=t[r],l=s[r];l!==void 0&&JSON.stringify(i)!==JSON.stringify(l)&&n.push({key:r,label:r.replace(/[_-]/g," "),original:i,corrected:l})}return n}function Ua({diff:t}){const s=Pt(t.original),n=Pt(t.corrected);return s!==null&&n!==null?e.jsx("div",{className:"@container",children:e.jsxs("div",{className:"grid grid-cols-1 @form-cols:grid-cols-2 gap-x-8 gap-y-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[t.label," ",e.jsx("span",{className:"normal-case font-normal",children:"(original)"})]}),e.jsx("p",{className:"text-sm text-text-tertiary leading-relaxed line-through decoration-text-tertiary/30",children:s})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[t.label," ",e.jsx("span",{className:"normal-case font-normal text-status-success",children:"(corrected)"})]}),e.jsx("p",{className:"text-sm text-text-primary leading-relaxed",children:n})]})]})}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[t.label," ",e.jsx("span",{className:"normal-case font-normal",children:"(original)"})]}),e.jsx("pre",{className:"text-xs text-text-tertiary font-mono whitespace-pre-wrap leading-relaxed",children:typeof t.original=="object"?JSON.stringify(t.original,null,2):String(t.original)})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[t.label," ",e.jsx("span",{className:"normal-case font-normal text-status-success",children:"(corrected)"})]}),e.jsx("pre",{className:"text-xs text-text-primary font-mono whitespace-pre-wrap leading-relaxed",children:typeof t.corrected=="object"?JSON.stringify(t.corrected,null,2):String(t.corrected)})]})]})}function Pt(t){return t==null?"null":typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"?String(t):null}const Ka="accumulate_items",Ga="accumulate_max",Dt="batch_items",$t="batch_filled_at",Ha="batch_keys",za="batch_pending";function pe(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Lt(t,s){return t.at.localeCompare(s.at)||t.itemKey.localeCompare(s.itemKey)}function Xa(t,s){const n=t.metadata??{},r=s==null?void 0:s[Ka];if(pe(r)){const l=Object.entries(r).map(([x,m])=>{const u=pe(m)?m:{};return{itemKey:x,at:typeof u.at=="string"?u.at:"",...pe(u.payload)?{payload:u.payload}:{},...typeof u.actor=="string"?{actor:u.actor}:{},...typeof u.reciprocalId=="string"?{reciprocalId:u.reciprocalId}:{}}}).sort(Lt),c=n[Ga];return{kind:"accumulate",count:l.length,max:typeof c=="number"?c:null,items:l,pending:[]}}const i=n[za];if(Array.isArray(i)){const l=pe(s==null?void 0:s[Dt])?s[Dt]:{},c=pe(s==null?void 0:s[$t])?s[$t]:{},x=Object.entries(l).map(([u,f])=>({itemKey:u,at:typeof c[u]=="string"?c[u]:"",...pe(f)?{payload:f}:{}})).sort(Lt),m=n[Ha];return{kind:"batch",count:x.length,max:Array.isArray(m)?m.length:null,items:x,pending:i.filter(u=>typeof u=="string")}}return null}function Qa(t){if(!t)return"";const s=Object.entries(t).slice(0,3).map(([r,i])=>{const l=typeof i=="object"&&i!==null?JSON.stringify(i):String(i);return`${r}: ${l.length>24?`${l.slice(0,23)}…`:l}`}),n=Object.keys(t).length-s.length;return n>0?`${s.join(" · ")} · +${n}`:s.join(" · ")}const Ya="x-lt-item-label",Za=/\{\{\s*([^{}]+?)\s*\}\}/g,en="item",Zt="—";function tn(t){if(t==null||t==="")return null;if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return null}}function sn(t,s,n){const r=t.indexOf(".");if((r===-1?t:t.slice(0,r))===en)try{return tn(r===-1?s:fa(s,t.slice(r+1)))}catch{return null}const l=dt(`{{${t}}}`,n);return l===Zt?null:l}function an(t,s,n={}){if(typeof t!="string"||!t.trim())return null;let r=0,i=0;const l=t.replace(Za,(c,x)=>{i+=1;const m=sn(x,s,n);return m===null?Zt:(r+=1,m)}).trim();return i>0&&r===0?null:l||null}function nn({escalationId:t,items:s,canWrite:n,labelTemplate:r,labelContext:i,guardWrite:l}){var v,C;const c=Es(),x=As(),[m,u]=d.useState(""),[f,b]=d.useState(""),[h,a]=d.useState(null),g=n&&s.kind==="accumulate",j=(y,_)=>l?l(y,_):_(),N=s.max!==null&&s.count>=s.max,w=()=>{const y=m.trim();if(!y){a("An item key is required.");return}let _;if(f.trim())try{const E=JSON.parse(f);if(!E||typeof E!="object"||Array.isArray(E))throw new Error("object");_=E}catch{a("Payload must be a JSON object.");return}a(null),j("add an item",()=>c.mutate({id:t,itemKey:y,payload:_},{onSuccess:()=>{u(""),b("")}}))},k=s.kind==="batch"?"filled":"held",S=s.max===null?`${s.count} ${k}`:`${s.count} of ${s.max} ${k}`;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium text-text-primary","data-testid":"items-headline",children:S}),e.jsx("span",{className:"text-2xs uppercase tracking-wide text-text-tertiary",children:s.kind==="batch"?"Batch":s.max===null?"Open":"Accumulator"})]}),s.items.length===0?e.jsx("p",{className:"text-xs text-text-tertiary italic",children:"Nothing held yet."}):e.jsx("ol",{className:"divide-y divide-surface-border/60","data-testid":"items-list",children:s.items.map((y,_)=>{const E=an(r,y,i);return e.jsxs("li",{className:"py-2 flex items-start gap-2 group",children:[e.jsx("span",{className:"text-2xs text-text-quaternary font-mono w-5 shrink-0 text-right pt-0.5",children:_+1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:`text-xs text-text-primary truncate ${E?"":"font-mono"}`,title:y.itemKey,"data-testid":"item-label",children:E??y.itemKey}),y.reciprocalId&&e.jsx(_e,{to:`/escalations/detail/${y.reciprocalId}`,className:"icon-link text-2xs shrink-0",title:"Open the reciprocal escalation",children:"linked"})]}),y.payload&&e.jsx("div",{className:"text-2xs text-text-secondary truncate",title:JSON.stringify(y.payload),children:Qa(y.payload)}),e.jsxs("div",{className:"flex items-center gap-2 text-2xs text-text-tertiary",children:[y.at&&e.jsx(Ue,{date:y.at}),y.actor&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Xt,{className:"w-2.5 h-2.5"}),e.jsx(ye,{userId:y.actor})]})]})]}),g&&e.jsx("button",{type:"button",onClick:()=>j("remove an item",()=>x.mutate({id:t,itemKey:y.itemKey})),disabled:x.isPending,className:"icon-link opacity-50 group-hover:opacity-100 shrink-0 p-0.5",title:`Remove ${E??y.itemKey}`,"aria-label":`Remove ${E??y.itemKey}`,children:e.jsx(Qt,{className:"w-3 h-3"})})]},y.itemKey)})}),s.kind==="batch"&&s.pending.length>0&&e.jsxs("p",{className:"text-2xs text-text-tertiary",children:["Awaiting: ",e.jsx("span",{className:"font-mono",children:s.pending.join(", ")})]}),g&&e.jsxs("form",{className:"space-y-2 pt-2 border-t border-surface-border/60",onSubmit:y=>{y.preventDefault(),w()},"data-testid":"add-item-form",children:[e.jsx("label",{className:"block text-2xs uppercase tracking-wide text-text-secondary",children:"Add item"}),e.jsx("input",{value:m,onChange:y=>u(y.target.value),placeholder:"Item key","aria-label":"Item key",disabled:N||c.isPending,className:"w-full text-xs font-mono px-2 py-1.5 rounded-md bg-surface-base border border-surface-border text-text-primary placeholder:text-text-quaternary focus:outline-none focus:border-accent disabled:opacity-50"}),e.jsx("textarea",{value:f,onChange:y=>b(y.target.value),placeholder:'Payload JSON (optional), e.g. {"weight": 2}',"aria-label":"Item payload",rows:2,disabled:N||c.isPending,className:"w-full text-xs font-mono px-2 py-1.5 rounded-md bg-surface-base border border-surface-border text-text-primary placeholder:text-text-quaternary focus:outline-none focus:border-accent disabled:opacity-50"}),e.jsxs("div",{className:"flex items-center justify-end gap-3",children:[N&&e.jsx("span",{className:"text-2xs text-text-tertiary",children:"Every slot is held."}),e.jsxs("button",{type:"submit",disabled:N||c.isPending,className:"btn-secondary text-xs inline-flex items-center gap-1",children:[e.jsx(Na,{className:"w-3 h-3"}),c.isPending?"Adding…":"Add"]})]}),(h||c.error||x.error)&&e.jsx("p",{className:"text-2xs text-status-error",role:"alert",children:h??((v=c.error)==null?void 0:v.message)??((C=x.error)==null?void 0:C.message)})]})]})}const P={HELP:"help",DETAILS:"details",TRIAGE:"triage",METADATA:"metadata",ITEMS:"items",CONTEXT:"context",RECORD:"record",ERRORS:"errors"},es="lt:escalation:panel:view";function rn(t){try{const s=localStorage.getItem(es);if(s&&t.includes(s))return s}catch{}return P.HELP}function ln({metadata:t,role:s}){const n=ja(t);return n.length===0?e.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No metadata on this escalation."}):e.jsx("dl",{className:"space-y-3.5",children:n.map(([r,i])=>{const l=typeof i=="object"&&i!==null?JSON.stringify(i):String(i),c=Et(r,i,s),x=Et(r,i);return e.jsxs("div",{className:"group relative",children:[e.jsx("dt",{className:"text-2xs font-medium text-text-secondary uppercase tracking-wide",children:ta(r)}),e.jsxs("dd",{className:"mt-0.5 flex items-center gap-1",children:[e.jsx("span",{className:"text-xs text-text-primary font-mono break-all flex-1",children:l}),e.jsx(_e,{to:c,title:`Filter this queue: ${r} = ${l}`,className:"opacity-50 group-hover:opacity-100 transition-opacity shrink-0 p-0.5 text-text-quaternary hover:text-accent",children:e.jsx(Ta,{className:"w-3 h-3"})}),e.jsx(_e,{to:x,title:`Search all queues: ${r} = ${l}`,className:"opacity-50 group-hover:opacity-100 transition-opacity shrink-0 p-0.5 text-text-quaternary hover:text-accent",children:e.jsx(Ia,{className:"w-3 h-3"})})]})]},r)})})}function on({esc:t,claimed:s,isTerminal:n,isBuilder:r,traceUrl:i}){return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("dl",{className:"space-y-3.5",children:[e.jsx(Q,{label:"Status",children:e.jsx(ya,{status:t.status})}),e.jsx(Q,{label:"Assigned to Role",children:e.jsx(ba,{role:t.role,size:"md"})}),e.jsxs(Q,{label:"Priority",children:["P",t.priority]}),(s||n)&&t.assigned_to&&e.jsx(Q,{label:"Claimed By",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-medium text-text-primary",children:[e.jsx(Xt,{className:"w-3 h-3 shrink-0 text-accent/75"}),e.jsx(ye,{userId:t.assigned_to})]})}),e.jsx(Q,{label:"Created",children:e.jsx(Ue,{date:t.created_at})}),(s||n)&&t.claimed_at&&e.jsx(Q,{label:"Claimed",children:e.jsx(Ue,{date:t.claimed_at})}),s&&!n&&t.assigned_until&&e.jsx(Q,{label:"Time Remaining",children:e.jsx(ze,{until:t.assigned_until})}),t.resolved_at&&e.jsx(Q,{label:"Completed",children:e.jsx("span",{className:"text-status-success",children:e.jsx(Ue,{date:t.resolved_at})})})]}),r&&e.jsxs(e.Fragment,{children:[e.jsx("hr",{className:"border-surface-border/60"}),e.jsxs("div",{className:"space-y-3.5",children:[e.jsx(ae,{label:"Escalation ID",value:t.id}),t.task_id&&e.jsx(ae,{label:"Task ID",value:t.task_id,href:`/workflows/tasks/detail/${t.task_id}`}),t.workflow_type&&e.jsx(ae,{label:"Workflow Name",value:t.workflow_type,href:`/workflows/executions?entity=${encodeURIComponent(t.workflow_type)}`}),t.workflow_id&&e.jsx(ae,{label:"Workflow ID",value:t.workflow_id,href:`/workflows/executions/${t.workflow_id}`}),t.task_queue&&e.jsx(ae,{label:"Task Queue",value:t.task_queue,href:`/admin/controlplane?queue=${encodeURIComponent(t.task_queue)}`}),t.origin_id&&t.origin_id!==t.workflow_id&&e.jsx(ae,{label:"Origin",value:t.origin_id,href:`/processes/detail/${t.origin_id}`}),t.trace_id&&e.jsx(ae,{label:"Trace",value:t.trace_id,href:i?i.replace("{traceId}",t.trace_id):void 0,external:!0})]})]})]})}function cn({esc:t,schema:s,envelope:n,payload:r,resolver:i,triage:l,hasAI:c,claimed:x,claimedByMe:m,isTerminal:u,isBuilder:f,traceUrl:b,open:h,noGutter:a,formErrors:g,activePanel:j,onPanelChange:N,canWriteItems:w,guardItemWrite:k}){const S=ct(),v=Object.values(P),[C,y]=d.useState(()=>rn(v)),_=j??C,E=d.useCallback(T=>{try{localStorage.setItem(es,T)}catch{}y(T),N==null||N(T)},[N]);d.useEffect(()=>{j&&j!==C&&y(j)},[j]);const D=d.useMemo(()=>pa(s,{escalation:t,metadata:t.metadata??null,envelope:n,payload:r,resolver:i})??ha({isTerminal:u,status:t.status,claimed:x,claimedByMe:m}),[s,t,n,r,i,u,x,m]),V=d.useCallback(T=>{const R=T.target.closest("a"),O=R==null?void 0:R.getAttribute("href");O!=null&&O.startsWith("/")&&(T.preventDefault(),S(O))},[S]),L=d.useMemo(()=>Xa(t,n),[t,n]),W=[{id:P.HELP,icon:va,label:"Instructions",content:e.jsx(Jt,{content:D,onClick:V})},{id:P.DETAILS,icon:wa,label:"Details",content:e.jsx(on,{esc:t,claimed:x,isTerminal:u,isBuilder:f,traceUrl:b})},...c&&l?[{id:P.TRIAGE,icon:ka,label:"AI Analysis",content:e.jsx(qa,{triage:l,payload:r??{}})}]:[],{id:P.METADATA,icon:Sa,label:"Metadata",content:e.jsx(ln,{metadata:t.metadata,role:t.role})},...L?[{id:P.ITEMS,icon:Ca,label:"Items",content:e.jsx(nn,{escalationId:t.id,items:L,canWrite:!!w&&t.status==="pending",guardWrite:k,labelTemplate:s==null?void 0:s[Ya],labelContext:{escalation:t,metadata:t.metadata??null,envelope:n,payload:r}})}]:[],{id:P.CONTEXT,icon:_a,label:"Context",content:e.jsxs("div",{className:"space-y-5",children:[n!=null&&e.jsx(Se,{data:n,label:"Input Envelope"}),r!=null&&e.jsx(Se,{data:r,label:"Escalation Context"}),i!=null&&e.jsx(Se,{data:i,label:"Resolver Payload"}),n==null&&r==null&&i==null&&e.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No context on this escalation."})]})},...f?[{id:P.RECORD,icon:Ea,label:"Record",content:e.jsx(Se,{data:t,label:"Escalation Record"})}]:[],...g&&g.length>0?[{id:P.ERRORS,icon:(({className:T})=>e.jsx(Aa,{className:`${T??""} text-status-error`})),label:"Errors",content:e.jsx(ea,{errors:g,schema:s})}]:[]];return e.jsx(Ts,{open:h,width:384,className:"h-full",children:e.jsx("div",{className:`h-full${a?"":" pl-6"}`,children:e.jsxs("div",{className:"h-full flex flex-col bg-surface-hover",children:[e.jsx("div",{className:"shrink-0 pt-2 pb-0 flex justify-center",children:e.jsx(Ba,{esc:t,className:"w-[80%]"})}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Is,{views:W,activeId:_,onViewChange:E,stickyClassName:"h-full min-h-0"})})]})})})}function dn(t){const{mode:s,activeView:n,onActiveViewChange:r,onClaim:i,claimPending:l,claimNudge:c,workflowType:x,json:m,onResolve:u,resolvePending:f,resolveError:b,requestTriage:h,triageNotes:a,onRelease:g,releasePending:j,onCancel:N,assignedTo:w,assignedUntil:k,onSubmitAttempt:S,onValidationErrors:v,escalationContext:C,labels:y={},submitBlocked:_,submitBlockedMessage:E,actingName:D,submitNeedsBadge:V,canManage:L,onReassign:W,onUnassign:T,unassignPending:R}=t,O=Kt(),[U,re]=d.useState("30"),[Ee,be]=d.useState(0),[Ae,I]=d.useState(""),F=U==="custom",Z=d.useCallback(A=>be(A),[]),q=!!_&&!h;if(s==="terminal")return null;const Te=()=>{const A=F?Ee:parseInt(U);!A||A<=0||i(A)},Xe=()=>{if(I(""),h){const ee={_lt:{needsTriage:!0}};a.trim()&&(ee.notes=a.trim()),u(ee);return}const A=Ke(m,C);if(A.parseError){I(A.parseError);return}if(A.errors.length>0){S==null||S(),v==null||v(A.errors);return}u(A.payload)},ie=A=>`text-xs transition-colors ${A?"text-accent font-medium":"text-text-tertiary hover:text-accent"}`;return e.jsxs("div",{className:"shrink-0 h-[80px] bg-surface/95 backdrop-blur-sm border-t border-surface-border -ml-10 pl-10 pr-10 pt-3 pb-5","data-testid":"escalation-action-bar",children:[s==="available"&&e.jsxs("div",{"data-testid":"claim-bar",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[O.map(A=>e.jsx("button",{onClick:()=>{re(A.value),be(0)},className:ie(!F&&U===A.value),children:A.label},A.value)),e.jsx("button",{onClick:()=>re("custom"),className:ie(F),children:"Other"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[y.cancel!==!1&&e.jsx("button",{onClick:N,className:"text-xs text-text-tertiary hover:text-status-error transition-colors",children:y.cancel??"Cancel escalation"}),e.jsx("div",{className:"flex-1"}),F&&e.jsx(Gt,{onChange:Z,compact:!0,autoFocus:!0}),e.jsx("button",{onClick:Te,disabled:l||F&&Ee<=0,className:`btn-primary text-xs ${c?"animate-[field-shake_0.4s_ease-in-out]":""}`,"data-testid":"claim-button",children:l?"Claiming...":y.claim??"Claim"},c)]})]}),s==="claimed_by_other"&&e.jsxs("div",{className:"flex items-center gap-4","data-testid":"claimed-other-bar",children:[e.jsxs("p",{className:"text-sm text-text-secondary",children:["Claimed by ",e.jsx("span",{className:"font-medium text-text-primary",children:w?e.jsx(ye,{userId:w}):"unknown"})]}),k&&e.jsx(ze,{until:k}),b&&e.jsx("span",{className:"text-xs text-status-error",children:b.message}),L&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:W,className:"text-xs text-text-tertiary hover:text-accent transition-colors","data-testid":"admin-reassign",children:"Reassign…"}),e.jsx("button",{onClick:T,disabled:R,className:"text-xs text-text-tertiary hover:text-status-error transition-colors disabled:opacity-50","data-testid":"admin-unassign",children:R?"Returning…":"Return to queue"})]})]}),s==="claimed_by_me"&&e.jsxs("div",{"data-testid":"action-bar",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[e.jsx("button",{onClick:()=>r("resolve"),className:ie(n==="resolve"),children:x?"Resolve":"Acknowledge"}),e.jsx("button",{onClick:()=>r("release"),className:`text-xs transition-colors ${n==="release"?"text-status-error font-medium":"text-text-tertiary hover:text-status-error"}`,children:y.release??"Release"}),y.cancel!==!1&&e.jsx("button",{onClick:N,className:"text-xs transition-colors text-text-tertiary hover:text-status-error",children:y.cancel??"Cancel"})]}),n==="resolve"&&e.jsxs("div",{className:"flex items-center gap-4",children:[V?e.jsxs("p",{className:"flex items-center gap-1.5 text-sm text-text-secondary","data-testid":"submit-badge-warning",children:[e.jsx(Yt,{className:"w-4 h-4 text-accent-muted shrink-0",strokeWidth:1.5}),"When you submit, you'll scan your badge to confirm you're"," ",e.jsx("span",{className:"font-medium text-text-primary",children:w?e.jsx(ye,{userId:w}):"the claimant"}),"."]}):D&&e.jsxs("p",{className:"text-sm text-text-secondary","data-testid":"acting-claim-note",children:["Claimed by you ",e.jsxs("span",{className:"font-medium text-text-primary",children:["(",D,")"]})]}),!V&&D&&k&&e.jsx(ze,{until:k}),e.jsx("div",{className:"flex-1"}),Ae&&e.jsx("span",{className:"text-xs text-status-error",children:Ae}),b&&e.jsx("span",{className:"text-xs text-status-error",children:b.message}),q&&E&&e.jsx("span",{className:"text-xs text-status-pending","data-testid":"submit-guard-message",children:E}),e.jsx("button",{onClick:Xe,disabled:f||q,className:"btn-primary text-xs",children:f?x?"Submitting...":"Acknowledging...":h?"Send to Triage":y.submit??(x?"Submit":"Acknowledge")})]}),n==="release"&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-text-secondary",children:"Release back to pool?"}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:()=>r("resolve"),className:"btn-secondary text-xs",children:"Back"}),e.jsx("button",{onClick:g,disabled:j,className:"btn-primary text-xs bg-status-error hover:bg-status-error/80",children:j?"Releasing...":"Yes, Release"})]})]})]})}function it({children:t}){return e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1.5",children:t})}function un({payload:t,isTerminal:s,resolverPayload:n,onRetryTriage:r,isRetrying:i}){const l=t.title,c=t.summary,x=t.diagnosis,m=t.tool_calls_made,u=t.result,f=n==null?void 0:n._lt,b=(f==null?void 0:f.triaged)===!0,h=f==null?void 0:f.triageWorkflowId,a=s&&b,[g,j]=d.useState(!1);return a?e.jsxs("div",{className:"rounded-md border border-status-success/30 bg-surface-raised",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4 text-status-success shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 1a7 7 0 110 14A7 7 0 018 1zm3.36 4.65a.5.5 0 00-.72 0L7 9.29 5.36 7.65a.5.5 0 10-.72.7l2 2a.5.5 0 00.72 0l4-4a.5.5 0 000-.7z"})}),e.jsx("span",{className:"text-xs font-medium text-status-success",children:"Resolved by AI Triage"})]}),typeof m=="number"&&e.jsxs("span",{className:"text-2xs font-mono px-2 py-0.5 rounded-full bg-status-success/10 text-status-success",children:[m," tool calls used"]})]}),e.jsxs("div",{className:"px-4 py-4 space-y-4",children:[l&&e.jsx("p",{className:"text-sm font-medium text-text-primary",children:l}),x&&e.jsxs("div",{children:[e.jsx(it,{children:"Triage diagnosis"}),e.jsx("div",{className:"text-xs text-text-primary leading-relaxed",children:e.jsx(nt,{content:x})})]}),e.jsx("div",{className:"flex items-center gap-3",children:h&&e.jsx(_e,{to:`/workflows/executions/${h}`,className:"text-2xs text-accent hover:underline",children:"View triage execution"})})]})]}):e.jsxs("div",{className:"rounded-md border border-status-warning/30 bg-surface-raised",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4 text-status-warning shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 1a7 7 0 110 14A7 7 0 018 1zm0 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 4zm0 7a.75.75 0 100-1.5.75.75 0 000 1.5z"})}),e.jsx("span",{className:"text-xs font-medium text-status-warning",children:"Tool Rounds Exhausted"})]}),typeof m=="number"&&e.jsxs("span",{className:"text-2xs font-mono px-2 py-0.5 rounded-full bg-status-warning/10 text-status-warning",children:[m," tool calls used"]})]}),e.jsxs("div",{className:"px-4 py-4 space-y-4",children:[l&&e.jsx("p",{className:"text-sm font-medium text-text-primary",children:l}),c&&e.jsxs("div",{children:[e.jsx(it,{children:"What happened"}),e.jsx("div",{className:"text-xs text-text-secondary leading-relaxed",children:e.jsx(nt,{content:c})})]}),x&&e.jsxs("div",{children:[e.jsx(it,{children:"What went wrong"}),e.jsx("div",{className:"text-xs text-text-primary leading-relaxed",children:e.jsx(nt,{content:x})})]}),u!=null&&e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>j(!g),className:"flex items-center gap-1 text-2xs font-semibold uppercase tracking-widest text-text-tertiary hover:text-text-secondary transition-colors",children:[e.jsx("svg",{className:`w-3 h-3 transition-transform ${g?"rotate-90":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:e.jsx("path",{d:"M4.5 2l4 4-4 4"})}),"Partial results"]}),g&&e.jsx("div",{className:"mt-2",children:e.jsx(Se,{data:u,defaultMode:"tree"})})]}),r&&!s&&e.jsx("div",{className:"pt-2",children:e.jsxs("button",{onClick:r,disabled:i,className:"inline-flex items-center gap-2 px-4 py-2 text-xs font-medium bg-accent text-text-inverse rounded-md hover:bg-accent/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 14 14",fill:"currentColor",children:e.jsx("path",{d:"M7 1a6 6 0 100 12A6 6 0 007 1zm2.5 6.5l-3.5 2V5.5l3.5 2z"})}),i?"Sending to triage...":"Retry with AI Triage"]})})]})]})}const Y={PENDING:"pending",CLAIMED:"claimed",RESOLVED:"resolved"};function ts(t){const s=t==null?void 0:t["x-lt-viewport"];return(s==null?void 0:s.type)!=="iframe"||typeof s.src!="string"||!s.src?null:s}function Wt(t,s){return s===Y.CLAIMED?t.src:s===Y.PENDING?t.onPending??null:t.onResolved??null}function Ge(t,s){if(!t.includes("{"))return t;try{const n=i=>{if(!i)return{};try{return JSON.parse(i)}catch{return{}}},r={...s.metadata??{},...n(s.envelope),...n(s.escalation_payload),...n(s.resolver_payload)};return t.replace(/\{([^}]+)\}/g,(i,l)=>Object.prototype.hasOwnProperty.call(r,l)?String(r[l]):`{${l}}`)}catch{return t}}function Ft(t){if(!t)return null;try{return JSON.parse(t)}catch{return null}}function He({src:t,escalation:s,schema:n,stage:r=Y.CLAIMED,onResolve:i,onEscalate:l,readOnly:c=!1,submitAttempted:x,fill:m}){const u=d.useRef(null),f=d.useRef("");d.useEffect(()=>{try{const h=new URL(t);f.current=h.origin}catch{f.current=""}},[t]);const b=d.useCallback(()=>{const h=u.current;if(!(h!=null&&h.contentWindow)||!f.current)return;const g={type:"lt:init",escalation:{id:s.id,type:s.type,subtype:s.subtype,description:s.description,status:s.status,priority:s.priority,role:s.role,workflow_type:s.workflow_type,envelope:Ft(s.envelope),metadata:s.metadata??null,escalation_payload:Ft(s.escalation_payload)},schema:n,stage:r};h.contentWindow.postMessage(g,f.current)},[s,n,r]);return d.useEffect(()=>{const h=a=>{if(a.origin!==f.current)return;const g=a.data;if(!(!g||typeof g!="object"||typeof g.type!="string"))switch(g.type){case"lt:ready":b();break;case"lt:submit":!c&&g.payload&&typeof g.payload=="object"&&(i==null||i(g.payload));break;case"lt:escalate":!c&&typeof g.target=="string"&&g.target&&(l==null||l(g.target));break;case"lt:resize":{const j=u.current;j&&typeof g.height=="number"&&g.height>0&&(j.style.height=`${Math.min(g.height,2e3)}px`);break}}};return window.addEventListener("message",h),()=>window.removeEventListener("message",h)},[b,i,l,c]),d.useEffect(()=>{if(!x||c)return;const h=u.current;h!=null&&h.contentWindow&&f.current&&h.contentWindow.postMessage({type:"lt:validate"},f.current)},[x,c]),m?e.jsx("div",{className:"absolute inset-0 overflow-hidden",children:e.jsx("iframe",{ref:u,src:t,sandbox:"allow-scripts allow-same-origin allow-forms allow-pointer-lock allow-downloads",className:"w-full h-full border-0 block",title:"HITL Viewport",onLoad:b})}):e.jsx("div",{className:"rounded-md border border-surface-border overflow-hidden bg-white",children:e.jsx("iframe",{ref:u,src:t,sandbox:"allow-scripts allow-same-origin allow-forms allow-pointer-lock allow-downloads",className:"w-full border-0",style:{minHeight:"600px"},title:"HITL Viewport",onLoad:b})})}function mn({json:t,onJsonChange:s,requestTriage:n,onRequestTriageChange:r,triageNotes:i,onTriageNotesChange:l,disabled:c=!1,submitAttempted:x=!1,showTriage:m=!1,escalationContext:u,onOpenHelp:f,onDisabledClick:b,disabledHint:h}){return e.jsxs(e.Fragment,{children:[m&&e.jsx("div",{className:"flex items-center justify-between mb-3",children:n?e.jsxs("button",{onClick:()=>r(!1),className:"group flex items-center gap-2 text-left","data-testid":"triage-cancel",children:[e.jsx("span",{className:"flex items-center justify-center w-5 h-5 rounded-full bg-accent/10 text-accent shrink-0",children:e.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),e.jsxs("span",{className:"text-xs text-text-secondary group-hover:text-text-primary transition-colors",children:["AI Triage active."," ",e.jsx("span",{className:"text-accent group-hover:underline",children:"Cancel"})]})]}):e.jsxs("button",{onClick:()=>r(!0),className:"group flex items-center gap-2.5 text-left my-4","data-testid":"triage-callout",children:[e.jsx("span",{className:"flex items-center justify-center w-6 h-6 rounded-full bg-accent/10 text-accent shrink-0 animate-[triage-glow_6s_ease-in-out_infinite]",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.663 17h4.674M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}),e.jsxs("span",{className:"text-sm text-text-secondary group-hover:text-text-primary transition-colors",children:["This form doesn't capture the issue?"," ",e.jsx("span",{className:"text-accent group-hover:underline",children:"Request AI Triage"})]})]})}),e.jsxs("div",{className:"relative min-h-[200px]",children:[e.jsx("div",{className:n?"pointer-events-none select-none":"",children:e.jsx(Ht,{value:t,onChange:s,disabled:c,submitAttempted:x,escalationContext:u,onOpenHelp:f,onDisabledClick:b,disabledHint:h})}),n&&e.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col bg-surface/90 backdrop-blur-[2px] rounded-md border border-accent/20 p-5","data-testid":"triage-overlay",children:[e.jsx("p",{className:"text-xs text-text-secondary mb-3 leading-relaxed",children:"The resolution form will not be submitted. Describe the issue so AI triage can diagnose and fix it using available tools. The corrected result will come back as a new escalation for your review."}),e.jsx("textarea",{value:i,onChange:a=>l(a.target.value),placeholder:"e.g. Content is in Spanish — needs translation to English before review...",className:"input text-xs w-full flex-1 min-h-[80px] resize-none",autoFocus:!0,"data-testid":"triage-notes"})]})]})]})}function Vt(t){if(!t)return null;try{return JSON.parse(t)}catch{return null}}function J(t,s){return{escalation:t,metadata:t.metadata??null,envelope:Vt(t.envelope),payload:Vt(t.escalation_payload),resolver:null,...s?{lookup:s}:{}}}function xn({isRoundsExhausted:t,payloadObj:s,isTerminal:n,resolverPayload:r,onRetryTriage:i,isRetrying:l}){return e.jsxs(e.Fragment,{children:[t&&s&&e.jsx("div",{className:"mt-8",children:e.jsx(un,{payload:s,isTerminal:n,resolverPayload:r,onRetryTriage:i,isRetrying:l})}),(s==null?void 0:s.category)==="missing_credential"&&e.jsxs("div",{className:"mt-8 bg-status-warning/10 border border-status-warning/30 rounded-md px-5 py-4 flex items-start gap-3",children:[e.jsx(It,{size:20,className:"text-status-warning mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-text-primary mb-1",children:"Missing Credential"}),e.jsxs("p",{className:"text-xs text-text-secondary mb-3",children:["This workflow requires a ",e.jsx("span",{className:"font-medium capitalize",children:String(s.provider)})," credential to continue. Register one and then resolve this escalation to retry."]}),e.jsxs(_e,{to:"/credentials",className:"btn-primary text-xs inline-flex items-center gap-1.5",children:[e.jsx(It,{size:12}),"Go to Credentials"]})]})]})]})}function fn({esc:t,resolverPayload:s,isTerminal:n,editable:r,activeView:i,metadataFormSchema:l,effectiveSchema:c,lookup:x,json:m,onJsonChange:u,requestTriage:f,onRequestTriageChange:b,triageNotes:h,onTriageNotesChange:a,onResolve:g,onEscalate:j,onClaim:N,submitAttempted:w,isCertified:k,hasAI:S,onOpenHelp:v,onDisabledClick:C,disabledHint:y}){const _=c,E=J(t,x),D=ts(_);if(n){const W=D&&t.status==="resolved"?Wt(D,Y.RESOLVED):null;if(W)return e.jsx("div",{className:"mt-3",children:e.jsx(He,{src:Ge(W,t),escalation:t,schema:_,stage:Y.RESOLVED,readOnly:!0})});if(s==null)return null;const T=typeof s=="object"&&s!==null?s:{};if(!Object.keys(T).some(U=>!U.startsWith("$")&&!U.startsWith("_")))return null;const R=c??l,O=R!=null&&R.properties?{...ga(T,R),_form_schema:R}:T;return e.jsx("div",{className:"mt-3",children:e.jsx(Ht,{value:JSON.stringify(O,null,2),onChange:()=>{},disabled:!0,escalationContext:E,disabledHint:y})})}if(i!=="resolve"||!(t.workflow_type||c))return null;const V=!!D&&!!g&&!!j;if(V&&!r){const W=Wt(D,Y.PENDING);return W?e.jsx("div",{className:"mt-3",children:e.jsx(He,{src:Ge(W,t),escalation:t,schema:_,stage:Y.PENDING,readOnly:!0})}):e.jsxs("button",{onClick:()=>N==null?void 0:N(),disabled:!N,className:"flex flex-col items-center justify-center min-h-[55vh] w-full gap-3 text-center group disabled:opacity-50 disabled:cursor-default",children:[e.jsx(Ra,{className:"w-10 h-10 text-text-tertiary group-hover:text-accent transition-colors",strokeWidth:1}),e.jsx("p",{className:"text-base font-medium text-text-primary group-hover:text-accent transition-colors",children:"Claim to launch the editor"})]})}const L=V?Ge(D.src,t):"";return e.jsx("div",{className:"mt-3",children:V?e.jsx(He,{src:L,escalation:t,schema:_,onResolve:g,onEscalate:j,submitAttempted:w}):e.jsx(mn,{json:m,onJsonChange:u,requestTriage:f,onRequestTriageChange:b,triageNotes:h,onTriageNotesChange:a,disabled:!r,submitAttempted:w,showTriage:!!k&&!!S,escalationContext:E,onOpenHelp:v,onDisabledClick:C,disabledHint:y})})}function pn({open:t,assignedUntil:s,onClose:n,onExtend:r,isPending:i}){const l=Kt(),[c,x]=d.useState("30"),[m,u]=d.useState(0),f=c==="custom",b=f?m:parseInt(c),h=d.useCallback(a=>u(a),[]);return e.jsx(ot,{open:t,onClose:n,title:"Claim Expiring",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-text-secondary",children:["Your claim on this escalation expires in"," ",e.jsx(ze,{until:s}),". When it lapses, the form locks and the item returns to the queue — your edits are kept as a draft. Extend to keep working."]}),e.jsxs("select",{value:c,onChange:a=>{x(a.target.value),u(0)},className:"select w-full text-sm","aria-label":"Extension duration",children:[l.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value)),e.jsx("option",{value:"custom",children:"Other..."})]}),f&&e.jsx(Gt,{onChange:h,autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx("button",{onClick:n,className:"btn-secondary text-xs",children:"Dismiss"}),e.jsx("button",{onClick:()=>r(b),className:"btn-primary text-xs",disabled:i||!b||b<=0,children:i?"Extending...":"Extend Claim"})]})]})})}const hn=9e4;function gn(t,s=hn){const[,n]=d.useState(0);if(d.useEffect(()=>{if(!t)return;const i=new Date(t).getTime()-Date.now();if(i<=0)return;const l=()=>n(m=>m+1),c=[],x=i-s;return x>0&&c.push(window.setTimeout(l,x)),c.push(window.setTimeout(l,i)),()=>c.forEach(m=>window.clearTimeout(m))},[t,s]),!t)return{expired:!1,expiringSoon:!1,msRemaining:0};const r=Math.max(0,new Date(t).getTime()-Date.now());return{expired:r<=0,expiringSoon:r>0&&r<=s,msRemaining:r}}const yn="lt:escalation:draft:";function ut(t){return`${yn}${t}`}function bn(t){try{return localStorage.getItem(ut(t))}catch{return null}}function jn(t,s){try{localStorage.setItem(ut(t),s)}catch{}}function lt(t){try{localStorage.removeItem(ut(t))}catch{}}const Nn="x-lt-transition",vn="x-lt-transition-message",wn="x-lt-transition-max-wait-seconds",kn="x-lt-transition-done",Sn="Submitted. Preparing your next step…",Cn=30,_n=5,En=300;function An(t){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0?Cn:Math.min(En,Math.max(_n,Math.round(s)))}function Bt(t){if(!t||!t[Nn])return null;const s=t[vn];return{message:typeof s=="string"&&s.trim().length>0?s:Sn,maxWaitSeconds:An(t[wn])}}function Tn(t){const s=t==null?void 0:t[kn];return typeof s=="string"&&s.trim().length>0?s:null}const In="x-lt-submit-on-claim";function Rn(t){return!!(t!=null&&t[In])}const Mn="x-lt-submit-guard",On="{{count}} related items are still pending";function Pn(t){const s=t==null?void 0:t[Mn];if(!s||typeof s!="object"||Array.isArray(s))return;const n=s;if(!(!n.query||typeof n.query!="object"))return n}function Dn(t,s){const{user:n}=Ut(),r=sa((t==null?void 0:t.query)??{},s??{},n==null?void 0:n.userId),{data:i,isSuccess:l}=Rs({role:r.role,status:r.status,facets:r.facets,assigned_to:r.assigned_to,available:r.available,limit:1,enabled:!!t&&r.enabled}),c=!!t&&t.mustBeEmpty!==!1&&r.enabled,x=(i==null?void 0:i.total)??0,m=c&&l&&x===0,u=c&&!m;let f="";if(u)if(x>0){const b=(t==null?void 0:t.message)??On;f=dt(b.replace(/\{\{count\}\}/g,String(x)),s??{})}else f="Checking related items…";return{blocked:u,count:x,message:f,confirmedEmpty:m}}function $n({open:t,message:s}){return t?da.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center px-4",children:[e.jsx("div",{className:"absolute inset-0 bg-text-primary/40 backdrop-blur-sm"}),e.jsxs("div",{role:"status","aria-live":"polite",className:"relative w-full max-w-sm bg-surface-raised border border-surface-border rounded-lg shadow-xl px-6 py-7 text-center",children:[e.jsx("div",{className:"flex justify-center mb-4","aria-hidden":"true",children:e.jsx("span",{className:"inline-block w-7 h-7 rounded-full border-2 border-surface-border border-t-accent animate-spin"})}),e.jsx("div",{className:"text-sm text-text-secondary [&_p]:m-0 [&_p+p]:mt-2",children:e.jsx(Jt,{content:s})})]})]}),document.body):null}function Ln({open:t,verb:s="submit",claimantId:n,wrongBadgeName:r,onCancel:i}){return t?e.jsx(ot,{open:!0,onClose:i,title:`Scan your badge to ${s}`,children:e.jsxs("div",{className:"flex flex-col items-center text-center py-6","data-testid":"station-write-challenge",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx(Ma,{className:"w-7 h-7 text-text-quaternary",strokeWidth:1}),e.jsx(Yt,{className:"w-9 h-9 text-accent-muted",strokeWidth:1})]}),e.jsxs("p",{className:"text-lg text-text-secondary",children:["Scan your badge to ",s," as"," ",e.jsx("span",{className:"font-medium text-text-primary",children:n?e.jsx(ye,{userId:n}):"the claimant"}),"."]}),r&&e.jsxs("p",{className:"text-sm text-status-error mt-3","data-testid":"wrong-badge",children:["That badge is ",r,"'s — scan the claimant's badge to ",s,"."]}),e.jsx("div",{className:"w-16 border-t border-surface-border my-6"}),e.jsx("button",{type:"button",onClick:i,className:"text-sm text-text-tertiary hover:text-text-secondary hover:underline",children:"Cancel"})]})}):null}function Wn(){var s;const t=typeof document<"u"?document.activeElement:null;return t instanceof HTMLElement?((s=t.closest("[data-field-key]"))==null?void 0:s.getAttribute("data-field-key"))??null:null}function Fn({enabled:t,json:s,onJsonChange:n,context:r,onScanSubmit:i}){var f;const l=(f=Ms())==null?void 0:f.pushCodeInterceptor,{data:c}=Os({enabled:t,staleTime:6e4}),[x,m]=d.useState(null),u=d.useRef({json:s,onJsonChange:n,context:r,onScanSubmit:i,schemes:(c==null?void 0:c.schemes)??[]});return u.current={json:s,onJsonChange:n,context:r,onScanSubmit:i,schemes:(c==null?void 0:c.schemes)??[]},d.useEffect(()=>{if(!(!t||!l))return l(b=>{const{json:h,schemes:a}=u.current,g=Da(b,a);if(!g.ok||g.scheme.kind!=="action")return!1;let j;try{j=JSON.parse(h)}catch{return!1}const N=j._form_schema,w=aa(N,j,g.parsed.version,Wn());if(!N||!w)return!1;const k=N.properties[w],S={version:g.parsed.version,target:g.parsed.target,code:g.parsed.raw??b.trim()},v=na(j[w],S,k,u.current.context);if(!v.ok)return m({field:w,error:v.error,at:Date.now()}),!0;const C={...j,[w]:v.value},y=JSON.stringify(C,null,2);return u.current.onJsonChange(y),m({field:w,error:null,at:Date.now()}),ra(N)&&ia(N,C)&&u.current.onScanSubmit(y),!0})},[t,l]),x}const ss="lt:escalation:panel:open";function Vn(){try{const t=localStorage.getItem(ss);return t===null?!0:t==="true"}catch{return!0}}function he(t){try{localStorage.setItem(ss,String(t))}catch{}}function ke(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function mr(){const{id:t}=ua();return e.jsx(Bn,{id:t},t)}function Bn({id:t}){var wt,kt,St,Ct,_t;const{user:s,isSuperAdmin:n,hasRoleType:r}=Ut(),i=n||r("admin"),{identity:l,clear:c}=Ps(),x=Ds(),{data:m}=$s((s==null?void 0:s.userId)??null),u=(l==null?void 0:l.actorId)??(s==null?void 0:s.userId),f=ct(),b=zt(),h=qt(),{data:a,isLoading:g,refetch:j,isFetching:N}=Ls(t);Ws(t);const w=d.useMemo(()=>{if(!(a!=null&&a.envelope))return!1;try{const o=JSON.parse(a.envelope);return Array.isArray(o==null?void 0:o.lookups)&&o.lookups.length>0}catch{return!1}},[a==null?void 0:a.envelope]),{data:k}=Fs(t,w),S=d.useMemo(()=>{var o;return(o=k==null?void 0:k.lookups)!=null&&o.length?Object.fromEntries(k.lookups.filter(p=>!p.missing).map(p=>[p.as??p.key,p.data])):null},[k]),v=Vs(),C=Bs(),y=qs(),_=Js(),E=Us(),D=Ks(),[V,L]=d.useState(!1),[W,T]=d.useState(!1),{data:R}=Gs(),{data:O}=Hs(),{isBuilder:U}=zs(),re=R==null?void 0:R.find(o=>o.workflow_type===(a==null?void 0:a.workflow_type)),Ee=((wt=O==null?void 0:O.telemetry)==null?void 0:wt.traceUrl)??null,[be,Ae]=d.useState("resolve"),[I,F]=d.useState("{}"),[Z,q]=d.useState(Vn),[Te,Xe]=d.useState(!1),[ie,A]=d.useState(""),[ee,Ie]=d.useState(!1),[as,le]=d.useState([]),[ns,rs]=d.useState(0),[is,oe]=d.useState(void 0),[K,Qe]=d.useState(null),[ls,mt]=d.useState(!1),xt=d.useRef(!1),Re=d.useRef(null),ft=d.useRef(!1),Me=d.useRef(null),pt=d.useRef(()=>{}),[te,Oe]=d.useState(null),os=gn(a==null?void 0:a.assigned_until),[cs,ds]=d.useState(null);d.useEffect(()=>{if(!(!ee||!a))try{const o=JSON.parse(I),p=o._form_schema;if(!p){le([]);return}le(la(p,o,J(a,S)))}catch{}},[I,ee,a]);const Pe=((kt=a==null?void 0:a.metadata)==null?void 0:kt.form_schema)??null,ce=(a==null?void 0:a.form_schema)??(re==null?void 0:re.resolver_schema)??null,$=Pe??ce,ht=Rn($),G=Qs($),je=Pn($),de=Dn(je,a?J(a,S):void 0),De=d.useRef(!1),$e=d.useRef(null);d.useEffect(()=>{if(De.current)return;const o=Pe??(ce!=null&&ce.properties?ce:null);if(o!=null&&o.properties){De.current=!0;const p=ke(a==null?void 0:a.envelope),M=p==null?void 0:p.formDefaults,B={...(a==null?void 0:a.metadata)??{},...typeof M=="object"&&M!==null?M:{}};$e.current=oa(o,B);const X=!((a==null?void 0:a.status)==="resolved"||(a==null?void 0:a.status)==="cancelled")&&(a!=null&&a.id)?bn(a.id):null,qe=X?ke(X):null;qe&&typeof qe=="object"&&!Array.isArray(qe)?F(JSON.stringify({...qe,_form_schema:o},null,2)):F($e.current)}else $&&(De.current=!0,F(JSON.stringify($,null,2)))},[$,Pe,ce,a==null?void 0:a.envelope,a==null?void 0:a.metadata,a==null?void 0:a.id,a==null?void 0:a.status]),d.useEffect(()=>{if(!De.current||$e.current===null||!(a!=null&&a.id)||a.status!=="pending")return;const o=a.id,p=window.setTimeout(()=>{I===$e.current?lt(o):jn(o,I)},400);return()=>window.clearTimeout(p)},[I,a==null?void 0:a.id,a==null?void 0:a.status]),d.useEffect(()=>{if(!K)return;const o=window.setTimeout(async()=>{var M;try{const B=new URLSearchParams({parent_id:t,assigned_to:u??"",status:"pending",limit:"1"}),xe=await ge(`/escalations?${B}`),X=(M=xe==null?void 0:xe.escalations)==null?void 0:M[0];if(X!=null&&X.id&&X.parent_id===t){Qe(null),f(`/escalations/detail/${X.id}`);return}}catch{}Qe(null),h.resetQueries({queryKey:["escalations"]}),h.resetQueries({queryKey:["escalationStats"]});const p=K.doneDest;p?p.startsWith("/")?f(p):window.location.assign(p):f(-1)},K.maxWaitSeconds*1e3);return()=>window.clearTimeout(o)},[K,t,u,f,h]),d.useEffect(()=>{var o,p;xt.current||(o=b.state)!=null&&o.autoStart&&(!a||a.status!=="pending"||Ce(a)||I!=="{}"&&(xt.current=!0,(p=Re.current)==null||p.call(Re)))},[a,I,b.state]),d.useEffect(()=>{var o;ft.current||!(je!=null&&je.autoResolveWhenEmpty)||!de.confirmedEmpty||!a||a.status!=="pending"||!Ce(a)||a.assigned_to===u&&I!=="{}"&&(ft.current=!0,(o=Me.current)==null||o.call(Me))},[de.confirmedEmpty,je,a,I,u]),d.useEffect(()=>{if(!(!te||!a)&&l&&l.actorId===a.assigned_to){const{run:o}=te;Oe(null),Promise.resolve().then(o).finally(()=>c())}},[l,te,a==null?void 0:a.assigned_to,c]);const us=(a==null?void 0:a.subtype)==="rounds_exhausted",ms=!!a&&Ce(a),xs=(a==null?void 0:a.status)==="resolved"||(a==null?void 0:a.status)==="cancelled",Ne=Fn({enabled:x&&!!a&&ms&&!xs&&(a.assigned_to===u||At(m)),json:I,onJsonChange:F,context:a?J(a,S):void 0,onScanSubmit:o=>pt.current(o)});if(g)return e.jsxs("div",{className:"animate-pulse space-y-8",children:[e.jsx("div",{className:"h-8 bg-surface-sunken rounded w-64"}),e.jsx("div",{className:"h-32 bg-surface-sunken rounded w-full"})]});if(!a)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Escalation not found."});const Le=Ce(a),H=Le&&a.assigned_to===u,fs=Le&&!H,se=a.status==="resolved"||a.status==="cancelled",We=x&&At(m)&&Le&&!se,Ye=H||We,Ze=We&&a.assigned_to!==(s==null?void 0:s.userId),gt=ts($),et=!!gt&&Ye&&!se,Fe=ke(a.escalation_payload),ue=ke(a.resolver_payload),Ve=ke(a.envelope),ps=!!((St=Ve==null?void 0:Ve.metadata)!=null&&St.certified),yt=Xs(),bt=yt!==null?yt:!!((Ct=O==null?void 0:O.ai)!=null&&Ct.enabled),z=typeof Fe=="object"&&Fe!==null&&!Array.isArray(Fe)?Fe:null,hs=z==null?void 0:z._triage,gs=typeof ue=="object"&&ue!==null&&!Array.isArray(ue)?ue:null,Be=se?"terminal":H||We?"claimed_by_me":fs?"claimed_by_other":"available",ys=Be==="available"?`${typeof G.claim=="string"?G.claim:"Claim"} this escalation to edit the form`:Be==="claimed_by_other"?e.jsxs(e.Fragment,{children:["Claimed by ",a.assigned_to?e.jsx(ye,{userId:a.assigned_to}):"another user"]}):a.status==="cancelled"?"This escalation is cancelled":a.status==="resolved"?"This escalation is resolved — the submitted values are shown":null,tt=o=>{v.mutate({id:t,durationMinutes:o})},ve=()=>{h.resetQueries({queryKey:["escalations"]}),h.resetQueries({queryKey:["escalationStats"]}),f(-1)},bs=()=>{const o=Tn($);return o&&dt(o,J(a,S))||null},js=o=>{h.resetQueries({queryKey:["escalations"]}),h.resetQueries({queryKey:["escalationStats"]}),o.startsWith("/")?f(o):window.location.assign(o)},Ns=async o=>{try{await C.mutateAsync({id:t,resolverPayload:o})}catch(B){if(B instanceof Tt&&ca(B.body)){Ie(!0),le(B.body.violations),oe(P.ERRORS);return}throw B}lt(t);const p=Bt($),M=bs();if(p){Qe({...p,doneDest:M});return}if(M){js(M);return}ve()},st=!!l&&l.actorId===a.assigned_to&&!l.subjectScoped,we=(o,p)=>{if(Ze&&!(st&&o==="submit")){c(),Oe({verb:o,run:p});return}if(!Ze){p();return}Promise.resolve().then(p).catch(M=>{M instanceof Tt&&M.status===401&&Oe({verb:o,run:p})})},me=async o=>{we("submit",()=>Ns(o))},jt=async o=>{try{await v.mutateAsync({id:t,durationMinutes:o})}catch{return}if(de.blocked)return;const p=Ke(I,J(a,S));if(!p.parseError){if(p.errors.length>0){Ie(!0),le(p.errors),q(!0),he(!0),oe(P.ERRORS);return}await me(p.payload)}};Re.current=async()=>{var p;const o=(p=b.state)==null?void 0:p.durationMinutes;mt(!0),await jt(typeof o=="number"&&o>0?o:30),mt(!1)},Me.current=()=>{const o=Ke(I,J(a,S));o.parseError||o.errors.length>0||me(o.payload)},pt.current=o=>{if(de.blocked)return;const p=Ke(o,J(a,S));if(!p.parseError){if(p.errors.length>0){Ie(!0),le(p.errors),q(!0),he(!0),oe(P.ERRORS);return}me(p.payload)}};const Nt=o=>{o&&we("escalate",async()=>{await y.mutateAsync({id:t,targetRole:o}),ve()})},vs=async()=>{H||await v.mutateAsync({id:t,durationMinutes:30});const o=(z==null?void 0:z.diagnosis)||a.description||"";await C.mutateAsync({id:t,resolverPayload:{_lt:{needsTriage:!0},notes:o}}),ve()},vt=()=>{we("release",async()=>{await v.mutateAsync({id:t,durationMinutes:0}),ve()})},ws=()=>{L(!1),we("cancel",async()=>{await _.mutateAsync(t),lt(t),ve()})},ks=e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xa,{onRefresh:()=>j(),isFetching:N,apiPath:`/escalations/${a.id}`,standalone:!0}),e.jsx("button",{onClick:()=>q(o=>(he(!o),!o)),className:"ml-2 text-accent/60 hover:text-accent transition-colors",title:Z?"Hide side panel":"Show side panel",children:Z?e.jsx(Rt,{className:"w-5 h-5",strokeWidth:1.5}):e.jsx(Mt,{className:"w-5 h-5",strokeWidth:1.5})})]});return e.jsxs("div",{className:"flex-1 min-h-0 min-w-0 flex items-stretch -mt-8 -mr-page-x -mb-16",children:[e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col min-h-0",children:[et?e.jsxs("div",{className:"relative flex-1 min-h-0 -ml-page-x",children:[e.jsx("div",{className:"absolute top-3 right-3 z-50 flex items-center gap-0.5 bg-surface/90 backdrop-blur-sm rounded-lg px-1.5 py-1 shadow-sm border border-surface-border/40",children:[{onClick:vt,disabled:v.isPending,label:G.release??"Release",hoverClass:"hover:text-accent",icon:e.jsx(Oa,{className:"w-4 h-4",strokeWidth:1.5})},...G.cancel===!1?[]:[{onClick:()=>L(!0),disabled:!1,label:G.cancel??"Cancel",hoverClass:"hover:text-status-error",icon:e.jsx(Qt,{className:"w-4 h-4",strokeWidth:1.5})}],{onClick:()=>q(o=>(he(!o),!o)),disabled:!1,label:Z?"Hide panel":"Show panel",hoverClass:"hover:text-accent",icon:Z?e.jsx(Rt,{className:"w-4 h-4",strokeWidth:1.5}):e.jsx(Mt,{className:"w-4 h-4",strokeWidth:1.5})}].map(({onClick:o,disabled:p,label:M,hoverClass:B,icon:xe})=>e.jsxs("div",{className:"relative group/tip",children:[e.jsx("button",{onClick:o,disabled:p,className:`text-text-tertiary ${B} transition-colors disabled:opacity-40 disabled:cursor-default p-1.5 rounded-md`,children:xe}),e.jsx("span",{className:"pointer-events-none absolute top-full left-1/2 -translate-x-1/2 mt-1.5 px-2 py-0.5 rounded text-2xs bg-surface-sunken text-text-primary whitespace-nowrap opacity-0 group-hover/tip:opacity-100 transition-opacity",children:M})]},M))}),e.jsx(He,{src:Ge(gt.src,a),escalation:a,schema:$,stage:Y.CLAIMED,onResolve:me,onEscalate:Nt,submitAttempted:ee,fill:!0})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"shrink-0 pt-8 pr-page-x",children:e.jsx(ma,{title:a.description||"Escalation",actions:ks})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto pr-page-x",children:[e.jsx(xn,{isRoundsExhausted:us,payloadObj:z,isTerminal:se,resolverPayload:ue,onRetryTriage:vs,isRetrying:v.isPending||C.isPending}),Ne&&Ye&&e.jsx("p",{role:"status",className:`text-sm mb-3 ${Ne.error?"text-status-error":"text-status-success"}`,children:Ne.error??`Scanned into ${qn($,Ne.field)}`},Ne.at),e.jsx(fn,{esc:a,resolverPayload:ue,isTerminal:se,editable:Ye,activeView:be,lookup:S,metadataFormSchema:Pe,effectiveSchema:$,json:I,onJsonChange:F,requestTriage:Te,onRequestTriageChange:Xe,triageNotes:ie,onTriageNotesChange:A,onResolve:me,onEscalate:Nt,onClaim:()=>tt(30),submitAttempted:ee,isCertified:ps,hasAI:bt,onOpenHelp:()=>{q(!0),he(!0),oe(P.HELP)},onDisabledClick:()=>rs(o=>o+1),disabledHint:ys}),e.jsx("div",{className:"h-10"})]})]}),!et&&e.jsx(dn,{escalationContext:J(a,S),mode:Be,activeView:be,onActiveViewChange:Ae,onClaim:ht?jt:tt,claimPending:v.isPending||ht&&C.isPending,claimNudge:ns,workflowType:a.workflow_type,json:I,onResolve:me,resolvePending:C.isPending||C.isSuccess,resolveError:C.error,requestTriage:Te,triageNotes:ie,onRelease:vt,releasePending:v.isPending,onCancel:()=>L(!0),assignedTo:a.assigned_to,assignedUntil:a.assigned_until,actingName:l&&(H||st)?l.displayName:null,submitNeedsBadge:Ze&&!st,onSubmitAttempt:()=>Ie(!0),onValidationErrors:o=>{le(o),q(!0),he(!0),oe(P.ERRORS)},labels:G,submitBlocked:de.blocked,submitBlockedMessage:de.message,canManage:i,onReassign:()=>T(!0),onUnassign:()=>D.mutate({ids:[t]}),unassignPending:D.isPending})]}),e.jsx(cn,{esc:a,schema:$,envelope:Ve,payload:z,resolver:gs,triage:hs??null,hasAI:bt,claimed:Le,claimedByMe:H,isTerminal:se,isBuilder:U,traceUrl:Ee,open:Z,noGutter:et,formErrors:as,activePanel:is,onPanelChange:oe,canWriteItems:Be==="available"||H||i||We,guardItemWrite:we}),e.jsx(Ys,{open:W,onClose:()=>T(!1),selectedCount:1,selectedRoles:a?[a.role]:[],onSubmit:(o,p)=>E.mutate({ids:[t],targetUserId:o,durationMinutes:p,reassign:!0},{onSuccess:()=>T(!1)}),isPending:E.isPending}),e.jsx(Zs,{open:V,onClose:()=>L(!1),onConfirm:ws,isPending:_.isPending,error:_.error,actionLabel:typeof G.cancel=="string"?G.cancel:void 0}),e.jsx(Va,{escalationId:t}),e.jsx(Ln,{open:!!te,verb:(te==null?void 0:te.verb)??"submit",claimantId:a.assigned_to,wrongBadgeName:l&&l.actorId!==a.assigned_to?l.displayName:null,onCancel:()=>Oe(null)}),e.jsx($n,{open:!!K||ls,message:(K==null?void 0:K.message)??((_t=Bt($))==null?void 0:_t.message)??"Starting…"}),H&&!se&&a.assigned_until&&e.jsx(pn,{open:os.expiringSoon&&a.assigned_until!==cs,assignedUntil:a.assigned_until,onClose:()=>ds(a.assigned_until??null),onExtend:tt,isPending:v.isPending})]})}function qn(t,s){var i;const n=t==null?void 0:t.properties,r=(i=n==null?void 0:n[s])==null?void 0:i.title;return typeof r=="string"&&r?r:s}export{mr as EscalationDetailPage};
3
- //# sourceMappingURL=index-Dbwu51xm.js.map