@hotmeshio/long-tail 0.14.3 → 0.14.4

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 (189) hide show
  1. package/build/shared/form-validation/field-validator.js +6 -4
  2. package/build/shared/form-validation/index.d.ts +2 -0
  3. package/build/shared/form-validation/index.js +2 -0
  4. package/build/shared/form-validation/validate-resolver-payload.d.ts +2 -0
  5. package/build/shared/form-validation/validate-resolver-payload.js +19 -0
  6. package/build/shared/form-validation/x-lt-options.d.ts +22 -0
  7. package/build/shared/form-validation/x-lt-options.js +51 -0
  8. package/build/shared/form-validation/x-lt-require-sum.d.ts +30 -0
  9. package/build/shared/form-validation/x-lt-require-sum.js +59 -0
  10. package/build/tsconfig.tsbuildinfo +1 -1
  11. package/dashboard/dist/assets/{AdminDashboard-BS3wd7Zg.js → AdminDashboard-CUqnrc7h.js} +2 -2
  12. package/dashboard/dist/assets/{AdminDashboard-BS3wd7Zg.js.map → AdminDashboard-CUqnrc7h.js.map} +1 -1
  13. package/dashboard/dist/assets/{AgentConfigPage-4C9aU0dj.js → AgentConfigPage-lmUOwyHO.js} +2 -2
  14. package/dashboard/dist/assets/{AgentConfigPage-4C9aU0dj.js.map → AgentConfigPage-lmUOwyHO.js.map} +1 -1
  15. package/dashboard/dist/assets/{AgentDetailPage-B6uvDnMF.js → AgentDetailPage-C_xAw6aF.js} +2 -2
  16. package/dashboard/dist/assets/{AgentDetailPage-B6uvDnMF.js.map → AgentDetailPage-C_xAw6aF.js.map} +1 -1
  17. package/dashboard/dist/assets/{AgentsPage-vtxdvdrQ.js → AgentsPage-CHCGAkpN.js} +2 -2
  18. package/dashboard/dist/assets/{AgentsPage-vtxdvdrQ.js.map → AgentsPage-CHCGAkpN.js.map} +1 -1
  19. package/dashboard/dist/assets/{AvailableEscalationsPage-C9VKPhD6.js → AvailableEscalationsPage-BvQdHMl2.js} +2 -2
  20. package/dashboard/dist/assets/{AvailableEscalationsPage-C9VKPhD6.js.map → AvailableEscalationsPage-BvQdHMl2.js.map} +1 -1
  21. package/dashboard/dist/assets/{BotPicker-CkY9u7nD.js → BotPicker-Dsr8Yyj_.js} +2 -2
  22. package/dashboard/dist/assets/{BotPicker-CkY9u7nD.js.map → BotPicker-Dsr8Yyj_.js.map} +1 -1
  23. package/dashboard/dist/assets/{BulkAssignModal-OIbUDYlC.js → BulkAssignModal-CbUftMR2.js} +2 -2
  24. package/dashboard/dist/assets/{BulkAssignModal-OIbUDYlC.js.map → BulkAssignModal-CbUftMR2.js.map} +1 -1
  25. package/dashboard/dist/assets/{CapabilitiesPage-Bkbq_GO6.js → CapabilitiesPage-CPNUJPHs.js} +2 -2
  26. package/dashboard/dist/assets/{CapabilitiesPage-Bkbq_GO6.js.map → CapabilitiesPage-CPNUJPHs.js.map} +1 -1
  27. package/dashboard/dist/assets/{CollapsibleSection-Zuz9HkFL.js → CollapsibleSection-DffGX2tR.js} +2 -2
  28. package/dashboard/dist/assets/{CollapsibleSection-Zuz9HkFL.js.map → CollapsibleSection-DffGX2tR.js.map} +1 -1
  29. package/dashboard/dist/assets/{CountdownTimer-CGnk4Bw_.js → CountdownTimer-Bb_VuJc8.js} +2 -2
  30. package/dashboard/dist/assets/{CountdownTimer-CGnk4Bw_.js.map → CountdownTimer-Bb_VuJc8.js.map} +1 -1
  31. package/dashboard/dist/assets/{CredentialsPage-CAmDMnzV.js → CredentialsPage-UXnD_Rau.js} +2 -2
  32. package/dashboard/dist/assets/{CredentialsPage-CAmDMnzV.js.map → CredentialsPage-UXnD_Rau.js.map} +1 -1
  33. package/dashboard/dist/assets/{CronLabel-DX2woCPZ.js → CronLabel-CctUYUlI.js} +2 -2
  34. package/dashboard/dist/assets/{CronLabel-DX2woCPZ.js.map → CronLabel-CctUYUlI.js.map} +1 -1
  35. package/dashboard/dist/assets/{ElapsedCell-D2old1NF.js → ElapsedCell-C7_Y8xXn.js} +2 -2
  36. package/dashboard/dist/assets/{ElapsedCell-D2old1NF.js.map → ElapsedCell-C7_Y8xXn.js.map} +1 -1
  37. package/dashboard/dist/assets/{EntityTimelinePanel-m9baDiW0.js → EntityTimelinePanel-pRu91gZK.js} +2 -2
  38. package/dashboard/dist/assets/{EntityTimelinePanel-m9baDiW0.js.map → EntityTimelinePanel-pRu91gZK.js.map} +1 -1
  39. package/dashboard/dist/assets/{EscalationListSchemaPage-BPr7Ou8c.js → EscalationListSchemaPage-B3f2mjqg.js} +2 -2
  40. package/dashboard/dist/assets/{EscalationListSchemaPage-BPr7Ou8c.js.map → EscalationListSchemaPage-B3f2mjqg.js.map} +1 -1
  41. package/dashboard/dist/assets/{EscalationSchemaPage-83n5JyAh.js → EscalationSchemaPage-AJ85FRZy.js} +2 -2
  42. package/dashboard/dist/assets/{EscalationSchemaPage-83n5JyAh.js.map → EscalationSchemaPage-AJ85FRZy.js.map} +1 -1
  43. package/dashboard/dist/assets/{EscalationsOverview-CDJ5wRlq.js → EscalationsOverview-DMLLWzjS.js} +2 -2
  44. package/dashboard/dist/assets/{EscalationsOverview-CDJ5wRlq.js.map → EscalationsOverview-DMLLWzjS.js.map} +1 -1
  45. package/dashboard/dist/assets/{EventTable-DRUHkKtv.js → EventTable-BlNuCTN6.js} +2 -2
  46. package/dashboard/dist/assets/{EventTable-DRUHkKtv.js.map → EventTable-BlNuCTN6.js.map} +1 -1
  47. package/dashboard/dist/assets/{FilterBar-C06DK5Oa.js → FilterBar-B-rkcWkV.js} +2 -2
  48. package/dashboard/dist/assets/{FilterBar-C06DK5Oa.js.map → FilterBar-B-rkcWkV.js.map} +1 -1
  49. package/dashboard/dist/assets/{GraphInvokePage-DSlyTmyq.js → GraphInvokePage-Bkt5tAFo.js} +2 -2
  50. package/dashboard/dist/assets/{GraphInvokePage-DSlyTmyq.js.map → GraphInvokePage-Bkt5tAFo.js.map} +1 -1
  51. package/dashboard/dist/assets/{HomePage-DXzDBkQV.js → HomePage-CIE9bCFQ.js} +2 -2
  52. package/dashboard/dist/assets/{HomePage-DXzDBkQV.js.map → HomePage-CIE9bCFQ.js.map} +1 -1
  53. package/dashboard/dist/assets/{ListToolbar-BvpGFFYp.js → ListToolbar-C_-Utxqm.js} +2 -2
  54. package/dashboard/dist/assets/{ListToolbar-BvpGFFYp.js.map → ListToolbar-C_-Utxqm.js.map} +1 -1
  55. package/dashboard/dist/assets/{McpOverview-C2atR_B6.js → McpOverview-c0p171OK.js} +2 -2
  56. package/dashboard/dist/assets/{McpOverview-C2atR_B6.js.map → McpOverview-c0p171OK.js.map} +1 -1
  57. package/dashboard/dist/assets/{McpQueryDetailPage-BUxPspjB.js → McpQueryDetailPage-B61I9-dM.js} +2 -2
  58. package/dashboard/dist/assets/{McpQueryDetailPage-BUxPspjB.js.map → McpQueryDetailPage-B61I9-dM.js.map} +1 -1
  59. package/dashboard/dist/assets/{McpQueryPage-CM_Fgl9G.js → McpQueryPage-Viqi13Fa.js} +2 -2
  60. package/dashboard/dist/assets/{McpQueryPage-CM_Fgl9G.js.map → McpQueryPage-Viqi13Fa.js.map} +1 -1
  61. package/dashboard/dist/assets/{McpRunDetailPage-Bo9vXQBA.js → McpRunDetailPage-CiAx_xyV.js} +2 -2
  62. package/dashboard/dist/assets/{McpRunDetailPage-Bo9vXQBA.js.map → McpRunDetailPage-CiAx_xyV.js.map} +1 -1
  63. package/dashboard/dist/assets/{McpRunsPage-BwsgvGtg.js → McpRunsPage-BpfvNRbE.js} +2 -2
  64. package/dashboard/dist/assets/{McpRunsPage-BwsgvGtg.js.map → McpRunsPage-BpfvNRbE.js.map} +1 -1
  65. package/dashboard/dist/assets/{OperationsPage-BftWAJ9m.js → OperationsPage-DGKwUE6h.js} +2 -2
  66. package/dashboard/dist/assets/{OperationsPage-BftWAJ9m.js.map → OperationsPage-DGKwUE6h.js.map} +1 -1
  67. package/dashboard/dist/assets/{OperatorDashboard-CKjrYYFi.js → OperatorDashboard-ha-05tgB.js} +2 -2
  68. package/dashboard/dist/assets/{OperatorDashboard-CKjrYYFi.js.map → OperatorDashboard-ha-05tgB.js.map} +1 -1
  69. package/dashboard/dist/assets/{PersonaDetailPage-BsIPtBxZ.js → PersonaDetailPage-DMH-D1ns.js} +2 -2
  70. package/dashboard/dist/assets/{PersonaDetailPage-BsIPtBxZ.js.map → PersonaDetailPage-DMH-D1ns.js.map} +1 -1
  71. package/dashboard/dist/assets/{PersonasPage-62hANmNf.js → PersonasPage-YLjCcQcU.js} +2 -2
  72. package/dashboard/dist/assets/{PersonasPage-62hANmNf.js.map → PersonasPage-YLjCcQcU.js.map} +1 -1
  73. package/dashboard/dist/assets/{ProcessDetailPage-DS_t9DcR.js → ProcessDetailPage-W5_2FJHn.js} +2 -2
  74. package/dashboard/dist/assets/{ProcessDetailPage-DS_t9DcR.js.map → ProcessDetailPage-W5_2FJHn.js.map} +1 -1
  75. package/dashboard/dist/assets/{ProcessesListPage-Ch2tSICc.js → ProcessesListPage-5f_2S9ER.js} +2 -2
  76. package/dashboard/dist/assets/{ProcessesListPage-Ch2tSICc.js.map → ProcessesListPage-5f_2S9ER.js.map} +1 -1
  77. package/dashboard/dist/assets/{RoleDetailPage-DVbtnTvn.js → RoleDetailPage-CuDTO13n.js} +2 -2
  78. package/dashboard/dist/assets/{RoleDetailPage-DVbtnTvn.js.map → RoleDetailPage-CuDTO13n.js.map} +1 -1
  79. package/dashboard/dist/assets/{RolesPage-CK6FjD5P.js → RolesPage-McMYumsZ.js} +2 -2
  80. package/dashboard/dist/assets/{RolesPage-CK6FjD5P.js.map → RolesPage-McMYumsZ.js.map} +1 -1
  81. package/dashboard/dist/assets/{RunAsSelector-ImueSaJ4.js → RunAsSelector-CC87e67k.js} +2 -2
  82. package/dashboard/dist/assets/{RunAsSelector-ImueSaJ4.js.map → RunAsSelector-CC87e67k.js.map} +1 -1
  83. package/dashboard/dist/assets/{ScanCodesPage-CDqLJuCq.js → ScanCodesPage-Zk6Jorv_.js} +2 -2
  84. package/dashboard/dist/assets/{ScanCodesPage-CDqLJuCq.js.map → ScanCodesPage-Zk6Jorv_.js.map} +1 -1
  85. package/dashboard/dist/assets/{ScanSchemeDetailPage-DO6qtJdM.js → ScanSchemeDetailPage-B79pya8o.js} +2 -2
  86. package/dashboard/dist/assets/{ScanSchemeDetailPage-DO6qtJdM.js.map → ScanSchemeDetailPage-B79pya8o.js.map} +1 -1
  87. package/dashboard/dist/assets/{ScanStationPage-ID3xMhds.js → ScanStationPage-BLlHMmd_.js} +2 -2
  88. package/dashboard/dist/assets/{ScanStationPage-ID3xMhds.js.map → ScanStationPage-BLlHMmd_.js.map} +1 -1
  89. package/dashboard/dist/assets/{StickyPagination-XA1krmz5.js → StickyPagination-CnJgQPU1.js} +2 -2
  90. package/dashboard/dist/assets/{StickyPagination-XA1krmz5.js.map → StickyPagination-CnJgQPU1.js.map} +1 -1
  91. package/dashboard/dist/assets/{StreamMessageDetail-DziA1g1e.js → StreamMessageDetail-CU5wrqO_.js} +2 -2
  92. package/dashboard/dist/assets/{StreamMessageDetail-DziA1g1e.js.map → StreamMessageDetail-CU5wrqO_.js.map} +1 -1
  93. package/dashboard/dist/assets/{SwimlaneTimeline-DTNEnHiF.js → SwimlaneTimeline-D5m-_zgy.js} +2 -2
  94. package/dashboard/dist/assets/{SwimlaneTimeline-DTNEnHiF.js.map → SwimlaneTimeline-D5m-_zgy.js.map} +1 -1
  95. package/dashboard/dist/assets/{TaskDetailPage-U19sJHAI.js → TaskDetailPage-SvVSH39Q.js} +2 -2
  96. package/dashboard/dist/assets/{TaskDetailPage-U19sJHAI.js.map → TaskDetailPage-SvVSH39Q.js.map} +1 -1
  97. package/dashboard/dist/assets/{TasksListPage-jc4Xk7kI.js → TasksListPage-BtpwvxkS.js} +2 -2
  98. package/dashboard/dist/assets/{TasksListPage-jc4Xk7kI.js.map → TasksListPage-BtpwvxkS.js.map} +1 -1
  99. package/dashboard/dist/assets/{TimeAgo-GWgJ0LVq.js → TimeAgo-BPODA7Dm.js} +2 -2
  100. package/dashboard/dist/assets/{TimeAgo-GWgJ0LVq.js.map → TimeAgo-BPODA7Dm.js.map} +1 -1
  101. package/dashboard/dist/assets/{TimestampCell-Dk1TVsFV.js → TimestampCell-DEQXlxbH.js} +2 -2
  102. package/dashboard/dist/assets/{TimestampCell-Dk1TVsFV.js.map → TimestampCell-DEQXlxbH.js.map} +1 -1
  103. package/dashboard/dist/assets/{ToolTestPanel-BKcqnR68.js → ToolTestPanel-Ztc0pRSh.js} +2 -2
  104. package/dashboard/dist/assets/{ToolTestPanel-BKcqnR68.js.map → ToolTestPanel-Ztc0pRSh.js.map} +1 -1
  105. package/dashboard/dist/assets/{TopicDetailPage-D8GcDu_0.js → TopicDetailPage-BmpEqg-Q.js} +2 -2
  106. package/dashboard/dist/assets/{TopicDetailPage-D8GcDu_0.js.map → TopicDetailPage-BmpEqg-Q.js.map} +1 -1
  107. package/dashboard/dist/assets/{TopicsPage-BT9LV3yH.js → TopicsPage-BVW5y6vE.js} +2 -2
  108. package/dashboard/dist/assets/{TopicsPage-BT9LV3yH.js.map → TopicsPage-BVW5y6vE.js.map} +1 -1
  109. package/dashboard/dist/assets/{UserName-BrwZnLjU.js → UserName-D915g7ba.js} +2 -2
  110. package/dashboard/dist/assets/{UserName-BrwZnLjU.js.map → UserName-D915g7ba.js.map} +1 -1
  111. package/dashboard/dist/assets/{WorkflowExecutionPage-CldfHwky.js → WorkflowExecutionPage-CIl9ESgk.js} +2 -2
  112. package/dashboard/dist/assets/{WorkflowExecutionPage-CldfHwky.js.map → WorkflowExecutionPage-CIl9ESgk.js.map} +1 -1
  113. package/dashboard/dist/assets/{WorkflowsDashboard-DkyGkxW1.js → WorkflowsDashboard-DtkaGgdZ.js} +2 -2
  114. package/dashboard/dist/assets/{WorkflowsDashboard-DkyGkxW1.js.map → WorkflowsDashboard-DtkaGgdZ.js.map} +1 -1
  115. package/dashboard/dist/assets/{WorkflowsOverview-DACADuUE.js → WorkflowsOverview-DANXhmXb.js} +2 -2
  116. package/dashboard/dist/assets/{WorkflowsOverview-DACADuUE.js.map → WorkflowsOverview-DANXhmXb.js.map} +1 -1
  117. package/dashboard/dist/assets/{YamlWorkflowDetailPage-DSAjzido.js → YamlWorkflowDetailPage-m6Ub7qtE.js} +2 -2
  118. package/dashboard/dist/assets/{YamlWorkflowDetailPage-DSAjzido.js.map → YamlWorkflowDetailPage-m6Ub7qtE.js.map} +1 -1
  119. package/dashboard/dist/assets/{YamlWorkflowsPage-CqoSFz5B.js → YamlWorkflowsPage-5MOsxbLW.js} +2 -2
  120. package/dashboard/dist/assets/{YamlWorkflowsPage-CqoSFz5B.js.map → YamlWorkflowsPage-5MOsxbLW.js.map} +1 -1
  121. package/dashboard/dist/assets/{agents-Cg_e-aaf.js → agents-DacpnIqz.js} +2 -2
  122. package/dashboard/dist/assets/{agents-Cg_e-aaf.js.map → agents-DacpnIqz.js.map} +1 -1
  123. package/dashboard/dist/assets/{bots-B047yNJ0.js → bots-El47Xy5a.js} +2 -2
  124. package/dashboard/dist/assets/{bots-B047yNJ0.js.map → bots-El47Xy5a.js.map} +1 -1
  125. package/dashboard/dist/assets/{capabilities-CI1dbCDk.js → capabilities-DGC__Aob.js} +2 -2
  126. package/dashboard/dist/assets/{capabilities-CI1dbCDk.js.map → capabilities-DGC__Aob.js.map} +1 -1
  127. package/dashboard/dist/assets/{controlplane-Cy7snw7f.js → controlplane-Bzx-qd8m.js} +2 -2
  128. package/dashboard/dist/assets/{controlplane-Cy7snw7f.js.map → controlplane-Bzx-qd8m.js.map} +1 -1
  129. package/dashboard/dist/assets/{escalation-columns-BNrONMYj.js → escalation-columns-BmY7BriY.js} +2 -2
  130. package/dashboard/dist/assets/{escalation-columns-BNrONMYj.js.map → escalation-columns-BmY7BriY.js.map} +1 -1
  131. package/dashboard/dist/assets/{index-nUmEwQrg.js → index-B4ZNPgcz.js} +2 -2
  132. package/dashboard/dist/assets/{index-nUmEwQrg.js.map → index-B4ZNPgcz.js.map} +1 -1
  133. package/dashboard/dist/assets/{index-B6Grf1WQ.js → index-BPK2cB4Q.js} +2 -2
  134. package/dashboard/dist/assets/{index-B6Grf1WQ.js.map → index-BPK2cB4Q.js.map} +1 -1
  135. package/dashboard/dist/assets/{index-Uk6N1qiH.js → index-Bwlnpbpd.js} +2 -2
  136. package/dashboard/dist/assets/{index-Uk6N1qiH.js.map → index-Bwlnpbpd.js.map} +1 -1
  137. package/dashboard/dist/assets/{index-Bf3hVGXZ.js → index-CHwg51qz.js} +2 -2
  138. package/dashboard/dist/assets/{index-Bf3hVGXZ.js.map → index-CHwg51qz.js.map} +1 -1
  139. package/dashboard/dist/assets/{index-DAUV3eJ-.js → index-Ce6ghhpn.js} +2 -2
  140. package/dashboard/dist/assets/{index-DAUV3eJ-.js.map → index-Ce6ghhpn.js.map} +1 -1
  141. package/dashboard/dist/assets/{index-COKZW8Xx.js → index-Cfw6FARc.js} +2 -2
  142. package/dashboard/dist/assets/{index-COKZW8Xx.js.map → index-Cfw6FARc.js.map} +1 -1
  143. package/dashboard/dist/assets/{index-DVtIMrTb.js → index-CoIh4ipz.js} +2 -2
  144. package/dashboard/dist/assets/{index-DVtIMrTb.js.map → index-CoIh4ipz.js.map} +1 -1
  145. package/dashboard/dist/assets/index-Cqc7Wu5Y.js +3 -0
  146. package/dashboard/dist/assets/index-Cqc7Wu5Y.js.map +1 -0
  147. package/dashboard/dist/assets/{index-X3_AxcUk.js → index-DH_xm9UQ.js} +2 -2
  148. package/dashboard/dist/assets/{index-X3_AxcUk.js.map → index-DH_xm9UQ.js.map} +1 -1
  149. package/dashboard/dist/assets/{index-DyTb77Jb.js → index-DYz57kr_.js} +2 -2
  150. package/dashboard/dist/assets/{index-DyTb77Jb.js.map → index-DYz57kr_.js.map} +1 -1
  151. package/dashboard/dist/assets/{index-Bxd2sXqz.js → index-DpsVlk5z.js} +2 -2
  152. package/dashboard/dist/assets/{index-Bxd2sXqz.js.map → index-DpsVlk5z.js.map} +1 -1
  153. package/dashboard/dist/assets/{index-lGfBW1PB.js → index-SU2xrnBD.js} +3 -3
  154. package/dashboard/dist/assets/{index-lGfBW1PB.js.map → index-SU2xrnBD.js.map} +1 -1
  155. package/dashboard/dist/assets/{index-C_y0lQ_o.js → index-ZtpEajtq.js} +2 -2
  156. package/dashboard/dist/assets/{index-C_y0lQ_o.js.map → index-ZtpEajtq.js.map} +1 -1
  157. package/dashboard/dist/assets/{knowledge-DsIUzscY.js → knowledge-k-5jr2BN.js} +2 -2
  158. package/dashboard/dist/assets/{knowledge-DsIUzscY.js.map → knowledge-k-5jr2BN.js.map} +1 -1
  159. package/dashboard/dist/assets/{mcp-D889kZ-c.js → mcp-BEqxxlW9.js} +2 -2
  160. package/dashboard/dist/assets/{mcp-D889kZ-c.js.map → mcp-BEqxxlW9.js.map} +1 -1
  161. package/dashboard/dist/assets/{mcp-query-Cs9J2pVT.js → mcp-query-qXTlQfc_.js} +2 -2
  162. package/dashboard/dist/assets/{mcp-query-Cs9J2pVT.js.map → mcp-query-qXTlQfc_.js.map} +1 -1
  163. package/dashboard/dist/assets/{personas-xHB16O-Q.js → personas-jJEDmBtg.js} +2 -2
  164. package/dashboard/dist/assets/{personas-xHB16O-Q.js.map → personas-jJEDmBtg.js.map} +1 -1
  165. package/dashboard/dist/assets/{pipelines-DnTPjw1v.js → pipelines-BNPJh69x.js} +2 -2
  166. package/dashboard/dist/assets/{pipelines-DnTPjw1v.js.map → pipelines-BNPJh69x.js.map} +1 -1
  167. package/dashboard/dist/assets/{tasks-BcDvp6dL.js → tasks-DhD71qXJ.js} +2 -2
  168. package/dashboard/dist/assets/{tasks-BcDvp6dL.js.map → tasks-DhD71qXJ.js.map} +1 -1
  169. package/dashboard/dist/assets/{topics-DXw6BNy5.js → topics-CrXwwuW-.js} +2 -2
  170. package/dashboard/dist/assets/{topics-DXw6BNy5.js.map → topics-CrXwwuW-.js.map} +1 -1
  171. package/dashboard/dist/assets/{useEventHooks-C-bsD8zP.js → useEventHooks-DL7R0ASv.js} +2 -2
  172. package/dashboard/dist/assets/{useEventHooks-C-bsD8zP.js.map → useEventHooks-DL7R0ASv.js.map} +1 -1
  173. package/dashboard/dist/assets/{useNamespace-wZCsEF6O.js → useNamespace-ETqzJakA.js} +2 -2
  174. package/dashboard/dist/assets/{useNamespace-wZCsEF6O.js.map → useNamespace-ETqzJakA.js.map} +1 -1
  175. package/dashboard/dist/assets/{useYamlActivityEvents-Cu_o4-ow.js → useYamlActivityEvents-SqY67S-F.js} +2 -2
  176. package/dashboard/dist/assets/{useYamlActivityEvents-Cu_o4-ow.js.map → useYamlActivityEvents-SqY67S-F.js.map} +1 -1
  177. package/dashboard/dist/assets/{users-XpCq_umD.js → users-DF8dTbOo.js} +2 -2
  178. package/dashboard/dist/assets/{users-XpCq_umD.js.map → users-DF8dTbOo.js.map} +1 -1
  179. package/dashboard/dist/assets/{workflows-CMxHVqQ8.js → workflows-Bdke7fzx.js} +2 -2
  180. package/dashboard/dist/assets/{workflows-CMxHVqQ8.js.map → workflows-Bdke7fzx.js.map} +1 -1
  181. package/dashboard/dist/assets/{yaml-workflows-kxOF5yEC.js → yaml-workflows-UMxHYunb.js} +2 -2
  182. package/dashboard/dist/assets/{yaml-workflows-kxOF5yEC.js.map → yaml-workflows-UMxHYunb.js.map} +1 -1
  183. package/dashboard/dist/index.html +1 -1
  184. package/docs/hitl/form.md +1 -0
  185. package/docs/hitl/x-lt-validation.md +62 -1
  186. package/docs/hitl-guide.md +3 -0
  187. package/package.json +1 -1
  188. package/dashboard/dist/assets/index-Ds5rGe-i.js +0 -3
  189. package/dashboard/dist/assets/index-Ds5rGe-i.js.map +0 -1
@@ -8,7 +8,7 @@
8
8
  <link rel="preconnect" href="https://fonts.googleapis.com" />
9
9
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
10
10
  <link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet" />
11
- <script type="module" crossorigin src="./assets/index-lGfBW1PB.js"></script>
11
+ <script type="module" crossorigin src="./assets/index-SU2xrnBD.js"></script>
12
12
  <link rel="modulepreload" crossorigin href="./assets/vendor-query-RUZdMvN6.js">
13
13
  <link rel="modulepreload" crossorigin href="./assets/vendor-react-CdqEC2zv.js">
14
14
  <link rel="modulepreload" crossorigin href="./assets/vendor-icons-BgsXTN4h.js">
package/docs/hitl/form.md CHANGED
@@ -32,6 +32,7 @@ Declare `title` on every field whose key isn't already a readable label — it i
32
32
  | `number` | Number input |
33
33
  | `string` | Text input (default) |
34
34
  | `string` + `enum` | Dropdown select |
35
+ | `string`/`number` + `x-lt-options` | Dropdown select — options resolved from the escalation context (see [x-lt-validation.md](x-lt-validation.md#dynamic-select-options-x-lt-options)) |
35
36
  | `null` | Read-only "null" display |
36
37
  | `array` | Tag display (read-only) |
37
38
  | `object` | Nested section with recursive fields, or a widget (see [x-lt-widget.md](x-lt-widget.md)) |
@@ -93,6 +93,36 @@ When `envelope.min_score` is `60`, submitting a score of `45` blocks with "Minim
93
93
 
94
94
  ---
95
95
 
96
+ ## Dynamic Select Options (`x-lt-options`)
97
+
98
+ A select's option list can ride the escalation instead of the schema. The field-level token names a `"domain.path"`; the array of strings or numbers at that path becomes the field's options — one static role form, per-row legal values:
99
+
100
+ ```json
101
+ {
102
+ "properties": {
103
+ "left_quantity": {
104
+ "type": "number",
105
+ "default": 0,
106
+ "x-lt-options": "envelope.left_quantity_options"
107
+ },
108
+ "designation": {
109
+ "type": "string",
110
+ "x-lt-options": "envelope.return_stations"
111
+ }
112
+ }
113
+ }
114
+ ```
115
+
116
+ When the envelope carries `left_quantity_options: [0, 1, 2, 3]`, the field renders as a dropdown offering exactly those values — an out-of-range answer is structurally impossible. The workflow mints only the small per-row array; the form itself stays on the role.
117
+
118
+ - A static `enum` takes precedence when both are present — the same static-over-dynamic rule as the bounds tokens.
119
+ - The declared `type` governs the value: a number-typed field emits the picked option as a number, a string-typed field as a string.
120
+ - While the current value is outside the option list (an empty init, options that shrank per-row), the select opens on an explicit disabled **Choose…** placeholder — never an implicit first option.
121
+ - A path that resolves to nothing (missing, empty array, no scalar entries) yields no options: the field renders as the plain input for its type and membership is not enforced for that submission.
122
+ - Membership is enforced on both sides of the wire: the dashboard constrains the choices, and an enforced role's server gate rejects a payload whose value is outside the row's resolved list with the canonical 422 (`Must be one of: 0, 1, 2, 3`).
123
+
124
+ ---
125
+
96
126
  ## Checklist Completion (`x-lt-require-all`)
97
127
 
98
128
  A checklist-widget field can require every item to be checked before submission:
@@ -143,6 +173,29 @@ The token is an array of groups; each group is an array of property names and en
143
173
 
144
174
  ---
145
175
 
176
+ ## Require a Combined Quantity (`x-lt-require-sum`)
177
+
178
+ For a group of **quantity** fields, `x-lt-require-any` is the wrong guard: `0` is an answer there, so counts defaulting to `0` vacuously satisfy the group. `x-lt-require-sum` reads the members as numbers and demands their sum reach a minimum — a Left quantity and a Right quantity can both default to `0`, and an all-zero submission still blocks:
179
+
180
+ ```json
181
+ {
182
+ "x-lt-require-sum": [{ "fields": ["left_quantity", "right_quantity"] }],
183
+ "properties": {
184
+ "left_quantity": { "type": "number", "title": "Left Quantity", "default": 0 },
185
+ "right_quantity": { "type": "number", "title": "Right Quantity", "default": 0 }
186
+ }
187
+ }
188
+ ```
189
+
190
+ The token is an array of groups; each group is `{ "fields": [...], "minimum": N }` and enforces independently. `minimum` defaults to `1` — the plain "at least one side must be positive" reading. Numbers contribute their value, numeric strings coerce, and everything else (empty, missing, non-numeric) contributes `0`.
191
+
192
+ - Visibility composes the same way as `x-lt-require-any`: a member hidden by `x-lt-showIf` (or naming no schema property) contributes nothing and is not demanded, and a group whose members are all hidden is waived.
193
+ - An unsatisfied group yields one violation on the group's first visible field: `Combined value of Left Quantity, Right Quantity must be at least 1` (member titles, falling back to keys).
194
+ - Composes with `required` and `x-lt-require-any` — each guard reports independently.
195
+ - The same pass runs on both sides of the wire — the dashboard panel blocks the submit, and an enforced role's server gate rejects a violating payload with the canonical 422.
196
+
197
+ ---
198
+
146
199
  ## Pattern Guard
147
200
 
148
201
  Apply a regular expression guard with `pattern`. If the input does not match, the field blocks submission. Provide `x-lt-pattern-error` for a human-readable error message; otherwise the generic "Invalid format" is shown.
@@ -163,7 +216,7 @@ Apply a regular expression guard with `pattern`. If the input does not match, th
163
216
 
164
217
  ## Dynamic Bounds — `"domain.path"` Resolution
165
218
 
166
- `x-lt-minimum`, `x-lt-maximum`, `x-lt-min-length`, and `x-lt-max-length` all accept a `"domain.path"` string. The value is resolved from the escalation context at the moment of submission — the same domain/path convention as `x-lt-showIf` and `x-lt-help` tokens.
219
+ `x-lt-minimum`, `x-lt-maximum`, `x-lt-min-length`, `x-lt-max-length`, and `x-lt-options` all accept a `"domain.path"` string. The value is resolved from the escalation context at the moment of submission — the same domain/path convention as `x-lt-showIf` and `x-lt-help` tokens.
167
220
 
168
221
  | Domain | Resolves against |
169
222
  |--------|-----------------|
@@ -216,3 +269,11 @@ The error panel updates in real-time as fields are corrected — fixing a field
216
269
  - `checks` — checklist widget with `x-lt-source: 'envelope.checklist_items'`
217
270
 
218
271
  The `quality-reviewer` role is seeded with two test escalations that carry different `min_score` and `max_notes_length` values so every dynamic bound is exercisable without code changes.
272
+
273
+ `examples/workflows/parameterized-form/` is the reference for per-row form parameterization:
274
+
275
+ - `left_quantity` / `right_quantity` — number selects with `x-lt-options` from `envelope.left_quantity_options` / `envelope.right_quantity_options`, both defaulting to `0`
276
+ - `designation` — string select with `x-lt-options` from `envelope.return_stations`
277
+ - `x-lt-require-sum` — the quantity pair must total at least 1
278
+
279
+ The `verdict-reviewer` role is seeded with two test escalations whose envelopes carry different quantity ranges and station lists, so the same role form offers different legal values per row.
@@ -103,6 +103,8 @@ Ordered as a learning path — each file adds one capability to the same form:
103
103
  | `x-lt-widget` | field | Rich control: `file-upload`, `code-editor`, `signature`, `rich-text`, `markdown`, `checklist`, `attachment` (alias `image`) |
104
104
  | `x-lt-source` | field | Data path for context-driven widgets: `"domain.path"` |
105
105
  | `x-lt-require-all` | field | Checklist completion guard — every item must be checked, except items declared `required: false` |
106
+ | `x-lt-require-any` | schema | At-least-one guard — each `string[]` group needs a value in one visible member; `0`/`false` count as answers |
107
+ | `x-lt-require-sum` | schema | Quantity-group guard — the numeric values of `{ fields, minimum? }` must total at least `minimum` (default 1) |
106
108
  | `x-lt-language` | field | Syntax hint for the `code-editor` widget |
107
109
  | `accept` | field | File-type filter for `file-upload` (e.g. `".pdf,.png"`) |
108
110
  | `x-lt-bind` | field | Path in the resolver payload (e.g. `"customer.email"`) |
@@ -110,6 +112,7 @@ Ordered as a learning path — each file adds one capability to the same form:
110
112
  | `x-lt-showIf` | field | Show field when a value is truthy at `domain.path`; prefix `!` to invert; `=VALUE` / `!=VALUE` compare the string form |
111
113
  | `x-lt-hide-if-empty` | field | `true` — suppress the field when its value is null, `""`, `false`, or `0` |
112
114
  | `x-lt-section` | field | Section group label |
115
+ | `x-lt-options` | field | Dynamic select options — resolves a `"domain.path"` to the field's option list; static `enum` wins |
113
116
  | `x-lt-minimum` | field | Dynamic lower bound — resolves a `"domain.path"` from the escalation context |
114
117
  | `x-lt-maximum` | field | Dynamic upper bound — resolves a `"domain.path"` from the escalation context |
115
118
  | `x-lt-min-length` | field | Dynamic minimum string length — resolves a `"domain.path"` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/long-tail",
3
- "version": "0.14.3",
3
+ "version": "0.14.4",
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",
@@ -1,3 +0,0 @@
1
- import{b as He,a as m,j as t}from"./vendor-query-RUZdMvN6.js";import{Z as Ms,_ as gt,g as jt,U as Xt,$ as qt,J as Rt,c as Os,d as Is,P as it,b as Gt,m as Me,a0 as Qt,a1 as Be,X as ie,L as oe,T as ze,j as Xe,a2 as Ss,a3 as Ds,i as $s,a4 as Ls,a5 as Ps,A as Ws,B as Fs,u as qs,v as Us,l as Vs,a6 as Js}from"./index-lGfBW1PB.js";import{u as Ge,C as Qe,r as Hs,B as Bs,a as zs}from"./BulkAssignModal-OIbUDYlC.js";import{M as Ye}from"./Modal-BU7No9NH.js";import{a as Ze,u as le,L as yt,b as Xs,e as Gs}from"./vendor-react-CdqEC2zv.js";import{P as Qs}from"./PageHeader-CDDpHpdv.js";import{L as Ys}from"./ListToolbar-BvpGFFYp.js";import{i as Ft,b as Zs,d as Ks,C as Ut,H as tn,g as ce,m as en,c as ot,r as de,s as sn,e as Ke}from"./CountdownTimer-CGnk4Bw_.js";import{u as nn}from"./workflows-CMxHVqQ8.js";import{g as rn}from"./useEventHooks-C-bsD8zP.js";import{S as ts}from"./StatusBadge-BDeUwPtb.js";import{R as an}from"./RolePill-C0hExOmI.js";import{C as dt}from"./CopyableId-4Lqlc5cU.js";import{U as ue}from"./UserName-BrwZnLjU.js";import{d as on}from"./metadata-display-DHjqWkLG.js";import{a3 as es,K as ln,S as cn,au as dn,$ as un,p as xn,ag as ss,U as pn,aj as mn,ak as fn,al as hn,a9 as gn,av as bn,aw as jn,ax as se,ay as yn,az as Oe,aA as Nn,O as Ie,Q as Se,aB as vn,X as wn}from"./vendor-icons-BgsXTN4h.js";import"./users-XpCq_umD.js";import"./constants-BHkpVaqx.js";import"./useDebouncedValue-C4P2jQuh.js";import"./DataTable-DFPMeqyQ.js";import"./EmptyState-lpUFYfun.js";import"./StickyPagination-XA1krmz5.js";const kn={SCHEMA_VALIDATION:"schema_validation"};function _n(e){return typeof e=="object"&&e!==null&&e.code===kn.SCHEMA_VALIDATION&&Array.isArray(e.violations)}function Cn({escalationId:e}){var g;const s=Ze(),r=le(),n=He(),a=(g=s.state)==null?void 0:g[Ms],[i,d]=m.useState(!1),[c,u]=m.useState(null),[p,l]=m.useState(!1);if(!a||a.escalationId!==e||p)return null;const o=()=>{l(!0),r(s.pathname,{replace:!0,state:null})},x=async()=>{var N,f,h;d(!0),u(null);try{switch(a.verb){case gt.CANCEL:await jt(`/escalations/${e}/cancel`,{method:"POST"});break;case gt.CLAIM:case gt.CLAIM_SHOW_DETAIL:await jt(`/escalations/${e}/claim`,{method:"POST",body:JSON.stringify({durationMinutes:((N=a.params)==null?void 0:N.durationMinutes)??30})});break;case gt.RELEASE:await jt(`/escalations/${e}/release`,{method:"POST"});break;case gt.RESOLVE:await jt(`/escalations/${e}/resolve`,{method:"POST",body:JSON.stringify({resolverPayload:((f=a.params)==null?void 0:f.resolverPayload)??{}})});break;case gt.ESCALATE:await jt(`/escalations/${e}/escalate`,{method:"PATCH",body:JSON.stringify({targetRole:(h=a.params)==null?void 0:h.targetRole})});break;default:throw new Error(`Unsupported confirm verb "${a.verb}"`)}n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]}),o()}catch(y){u(y.message)}finally{d(!1)}};return t.jsx(Ye,{open:!0,onClose:o,title:"Confirm scan action",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx("p",{className:"text-sm text-text-secondary",children:a.prompt}),c&&t.jsx("p",{className:"text-xs text-status-error",children:c}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{onClick:o,disabled:i,className:"btn-secondary text-xs",children:"No, go back"}),t.jsx("button",{onClick:x,disabled:i,className:"btn-primary text-xs",children:i?"Working…":"Yes, continue"})]})]})})}const Wt={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))"},Yt=4;function De({pct:e,place:s,label:r,title:n,emphasis:a}){const i=t.jsx("span",{className:"w-px h-1 bg-text-quaternary/70","aria-hidden":!0}),d=t.jsx("span",{className:`whitespace-nowrap leading-none tabular-nums text-[10px] ${a?"text-text-tertiary":"text-text-quaternary"}`,children:r});return t.jsx("div",{title:n,className:`absolute ${s==="above"?"bottom-0":"top-0"} flex flex-col items-center gap-0 -translate-x-1/2 cursor-help`,style:{left:`${e}%`},children:s==="above"?t.jsxs(t.Fragment,{children:[d,i]}):t.jsxs(t.Fragment,{children:[i,d]})})}function En({esc:e,className:s=""}){const r=new Date(e.created_at).getTime(),n=e.claimed_at?new Date(e.claimed_at).getTime():null,a=e.status==="resolved",i=e.status==="cancelled"||e.status==="expired",d=a||i,c=Ft(e),u=!!n&&(c||d),p=a&&e.resolved_at?new Date(e.resolved_at).getTime():i?new Date(e.updated_at).getTime():Date.now(),l=Math.max(p-r,1),o=u&&n?Math.max(n-r,0):l,x=u&&n?Math.max(p-n,0):0,g=Math.min(100,Math.max(0,o/l*100)),N=u?Math.max(0,100-g):0,f=a?Wt.resolved:i?Wt.cancelled:Wt.claimed,h=a?"Resolved after":i?"Cancelled after":"In progress",y=Xt(o),k=Xt(l),j=a?`Resolved in ${k} total`:i?`Cancelled after ${k}`:`Open ${k} so far`,E=`Lifecycle bar: blue = time waiting to be claimed, ${a?"green":i?"red":"orange"} = ${h.toLowerCase()} the claim.`;return t.jsxs("div",{className:s,title:E,children:[t.jsx("div",{className:"relative h-2.5 font-mono",children:u&&t.jsx(De,{pct:g,place:"above",label:y,title:`Time to claim: ${y}`})}),t.jsxs("div",{className:"flex w-full rounded-full overflow-hidden",style:{height:Yt,backgroundColor:"rgb(var(--lt-surface-sunken))"},title:E,children:[t.jsx("div",{style:{width:`${g}%`,minWidth:Yt,backgroundColor:Wt.pending,opacity:.75},title:`Waiting ${y} — created → claimed`}),u&&N>0&&t.jsx("div",{style:{width:`${N}%`,minWidth:Yt,backgroundColor:f,opacity:.75},title:`${h} ${Xt(x)}`})]}),t.jsx("div",{className:"relative h-2.5 font-mono",children:t.jsx(De,{pct:100,place:"below",emphasis:!0,label:k,title:j})})]})}function An({triage:e,payload:s}){const r=e.confidence??0,n=r>=.8?"text-status-success":r>=.5?"text-status-pending":"text-status-error",a=Tn(e.originalData,s);return t.jsxs("div",{className:"space-y-5",children:[e.diagnosis&&t.jsx("p",{className:"text-sm text-text-primary leading-relaxed",children:e.diagnosis}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-text-tertiary",children:[e.tool_calls_made!=null&&t.jsxs("span",{children:[e.tool_calls_made," tool call",e.tool_calls_made!==1?"s":""]}),e.tool_calls_made!=null&&t.jsx("span",{className:"text-text-quaternary",children:"·"}),t.jsxs("span",{className:`font-medium ${n}`,children:[Math.round(r*100),"% confidence"]})]}),e.actions_taken&&e.actions_taken.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.actions_taken.map((i,d)=>t.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 text-2xs
2
- text-text-secondary`,children:[t.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:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),i]},d))}),e.recommendation&&t.jsx("p",{className:"text-2xs text-text-tertiary italic",children:e.recommendation}),a.length>0&&t.jsx("div",{className:"space-y-4 pt-2",children:a.map(i=>t.jsx(Rn,{diff:i},i.key))})]})}function Tn(e,s){if(!e)return[];const r=[];for(const n of Object.keys(e)){if(n.startsWith("_"))continue;const a=e[n],i=s[n];i!==void 0&&JSON.stringify(a)!==JSON.stringify(i)&&r.push({key:n,label:n.replace(/[_-]/g," "),original:a,corrected:i})}return r}function Rn({diff:e}){const s=$e(e.original),r=$e(e.corrected);return s!==null&&r!==null?t.jsx("div",{className:"@container",children:t.jsxs("div",{className:"grid grid-cols-1 @form-cols:grid-cols-2 gap-x-8 gap-y-3",children:[t.jsxs("div",{children:[t.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[e.label," ",t.jsx("span",{className:"normal-case font-normal",children:"(original)"})]}),t.jsx("p",{className:"text-sm text-text-tertiary leading-relaxed line-through decoration-text-tertiary/30",children:s})]}),t.jsxs("div",{children:[t.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[e.label," ",t.jsx("span",{className:"normal-case font-normal text-status-success",children:"(corrected)"})]}),t.jsx("p",{className:"text-sm text-text-primary leading-relaxed",children:r})]})]})}):t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[e.label," ",t.jsx("span",{className:"normal-case font-normal",children:"(original)"})]}),t.jsx("pre",{className:"text-xs text-text-tertiary font-mono whitespace-pre-wrap leading-relaxed",children:typeof e.original=="object"?JSON.stringify(e.original,null,2):String(e.original)})]}),t.jsxs("div",{children:[t.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[e.label," ",t.jsx("span",{className:"normal-case font-normal text-status-success",children:"(corrected)"})]}),t.jsx("pre",{className:"text-xs text-text-primary font-mono whitespace-pre-wrap leading-relaxed",children:typeof e.corrected=="object"?JSON.stringify(e.corrected,null,2):String(e.corrected)})]})]})}function $e(e){return e==null?"null":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):null}function K(e,s){const r=s==null?void 0:s.title;if(typeof r=="string"&&r.trim().length>0)return r.trim();const n=e.split(/[_-]+/).filter(Boolean);return n.length<=1?e:n.map(a=>Mn(a)?a:a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function Mn(e){return e.length>1&&e===e.toUpperCase()&&/[A-Z]/.test(e)}const G={HELP:"help",DETAILS:"details",TRIAGE:"triage",METADATA:"metadata",CONTEXT:"context",RECORD:"record",ERRORS:"errors"},ns="lt:escalation:panel:view";function On(e){try{const s=localStorage.getItem(ns);if(s&&e.includes(s))return s}catch{}return G.HELP}function In({metadata:e,role:s}){const r=on(e);return r.length===0?t.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No metadata on this escalation."}):t.jsx("dl",{className:"space-y-3.5",children:r.map(([n,a])=>{const i=typeof a=="object"&&a!==null?JSON.stringify(a):String(a),d=Me(n,a,s),c=Me(n,a);return t.jsxs("div",{className:"group relative",children:[t.jsx("dt",{className:"text-2xs font-medium text-text-secondary uppercase tracking-wide",children:K(n)}),t.jsxs("dd",{className:"mt-0.5 flex items-center gap-1",children:[t.jsx("span",{className:"text-xs text-text-primary font-mono break-all flex-1",children:i}),t.jsx(yt,{to:d,title:`Filter this queue: ${n} = ${i}`,className:"opacity-50 group-hover:opacity-100 transition-opacity shrink-0 p-0.5 text-text-quaternary hover:text-accent",children:t.jsx(mn,{className:"w-3 h-3"})}),t.jsx(yt,{to:c,title:`Search all queues: ${n} = ${i}`,className:"opacity-50 group-hover:opacity-100 transition-opacity shrink-0 p-0.5 text-text-quaternary hover:text-accent",children:t.jsx(fn,{className:"w-3 h-3"})})]})]},n)})})}function Sn({esc:e,claimed:s,isTerminal:r,isBuilder:n,traceUrl:a}){return t.jsxs("div",{className:"space-y-5",children:[t.jsxs("dl",{className:"space-y-3.5",children:[t.jsx(it,{label:"Status",children:t.jsx(ts,{status:e.status})}),t.jsx(it,{label:"Assigned to Role",children:t.jsx(an,{role:e.role,size:"md"})}),t.jsxs(it,{label:"Priority",children:["P",e.priority]}),(s||r)&&e.assigned_to&&t.jsx(it,{label:"Claimed By",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5 font-medium text-text-primary",children:[t.jsx(pn,{className:"w-3 h-3 shrink-0 text-accent/75"}),t.jsx(ue,{userId:e.assigned_to})]})}),t.jsx(it,{label:"Created",children:t.jsx(Gt,{date:e.created_at})}),(s||r)&&e.claimed_at&&t.jsx(it,{label:"Claimed",children:t.jsx(Gt,{date:e.claimed_at})}),s&&!r&&e.assigned_until&&t.jsx(it,{label:"Time Remaining",children:t.jsx(Ut,{until:e.assigned_until})}),e.resolved_at&&t.jsx(it,{label:"Completed",children:t.jsx("span",{className:"text-status-success",children:t.jsx(Gt,{date:e.resolved_at})})})]}),n&&t.jsxs(t.Fragment,{children:[t.jsx("hr",{className:"border-surface-border/60"}),t.jsxs("div",{className:"space-y-3.5",children:[t.jsx(dt,{label:"Escalation ID",value:e.id}),e.task_id&&t.jsx(dt,{label:"Task ID",value:e.task_id,href:`/workflows/tasks/detail/${e.task_id}`}),e.workflow_type&&t.jsx(dt,{label:"Workflow Name",value:e.workflow_type,href:`/workflows/executions?entity=${encodeURIComponent(e.workflow_type)}`}),e.workflow_id&&t.jsx(dt,{label:"Workflow ID",value:e.workflow_id,href:`/workflows/executions/${e.workflow_id}`}),e.task_queue&&t.jsx(dt,{label:"Task Queue",value:e.task_queue,href:`/admin/controlplane?queue=${encodeURIComponent(e.task_queue)}`}),e.origin_id&&e.origin_id!==e.workflow_id&&t.jsx(dt,{label:"Origin",value:e.origin_id,href:`/processes/detail/${e.origin_id}`}),e.trace_id&&t.jsx(dt,{label:"Trace",value:e.trace_id,href:a?a.replace("{traceId}",e.trace_id):void 0,external:!0})]})]})]})}function Dn({errors:e,schema:s}){const r=n=>{const a=document.querySelector(`[data-field-key="${n}"]`);a&&(a.scrollIntoView({behavior:"smooth",block:"center"}),a.focus({preventScroll:!0}))};return e.length===0?t.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No errors to display."}):t.jsxs("div",{className:"space-y-1",role:"alert","aria-live":"polite",children:[t.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-wider text-status-error mb-4",children:[e.length," ",e.length===1?"issue":"issues"," to resolve"]}),t.jsx("div",{className:"space-y-1.5",children:e.map(({field:n,message:a})=>{var i;return t.jsxs("button",{onClick:()=>r(n),className:"w-full text-left flex items-start gap-3 px-3 py-2.5 rounded hover:bg-status-error/5 transition-colors group",children:[t.jsx(ss,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-status-error/60 group-hover:text-status-error transition-colors"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-2xs font-semibold text-text-primary leading-snug",children:K(n,(i=s==null?void 0:s.properties)==null?void 0:i[n])}),t.jsx("p",{className:"text-2xs text-text-tertiary group-hover:text-text-secondary transition-colors leading-snug mt-0.5",children:a})]})]},n)})}),t.jsx("p",{className:"text-2xs text-text-quaternary mt-4 px-3",children:"Click an issue to scroll to and focus the field."})]})}function $n({esc:e,schema:s,envelope:r,payload:n,resolver:a,triage:i,hasAI:d,claimed:c,claimedByMe:u,isTerminal:p,isBuilder:l,traceUrl:o,open:x,noGutter:g,formErrors:N,activePanel:f,onPanelChange:h}){const y=le(),k=Object.values(G),[j,E]=m.useState(()=>On(k)),O=f??j,T=m.useCallback(A=>{try{localStorage.setItem(ns,A)}catch{}E(A),h==null||h(A)},[h]);m.useEffect(()=>{f&&f!==j&&E(f)},[f]);const q=m.useMemo(()=>Zs(s,{escalation:e,metadata:e.metadata??null,envelope:r,payload:n,resolver:a})??Ks({isTerminal:p,status:e.status,claimed:c,claimedByMe:u}),[s,e,r,n,a,p,c,u]),_=m.useCallback(A=>{const I=A.target.closest("a"),S=I==null?void 0:I.getAttribute("href");S!=null&&S.startsWith("/")&&(A.preventDefault(),y(S))},[y]),M=[{id:G.HELP,icon:es,label:"Instructions",content:t.jsx(qt,{content:q,onClick:_})},{id:G.DETAILS,icon:ln,label:"Details",content:t.jsx(Sn,{esc:e,claimed:c,isTerminal:p,isBuilder:l,traceUrl:o})},...d&&i?[{id:G.TRIAGE,icon:cn,label:"AI Analysis",content:t.jsx(An,{triage:i,payload:n??{}})}]:[],{id:G.METADATA,icon:dn,label:"Metadata",content:t.jsx(In,{metadata:e.metadata,role:e.role})},{id:G.CONTEXT,icon:un,label:"Context",content:t.jsxs("div",{className:"space-y-5",children:[r!=null&&t.jsx(Rt,{data:r,label:"Input Envelope"}),n!=null&&t.jsx(Rt,{data:n,label:"Escalation Context"}),a!=null&&t.jsx(Rt,{data:a,label:"Resolver Payload"}),r==null&&n==null&&a==null&&t.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No context on this escalation."})]})},...l?[{id:G.RECORD,icon:xn,label:"Record",content:t.jsx(Rt,{data:e,label:"Escalation Record"})}]:[],...N&&N.length>0?[{id:G.ERRORS,icon:(({className:A})=>t.jsx(ss,{className:`${A??""} text-status-error`})),label:"Errors",content:t.jsx(Dn,{errors:N,schema:s})}]:[]];return t.jsx(Os,{open:x,width:384,className:"h-full",children:t.jsx("div",{className:`h-full${g?"":" pl-6"}`,children:t.jsxs("div",{className:"h-full flex flex-col bg-surface-hover",children:[t.jsx("div",{className:"shrink-0 pt-2 pb-0 flex justify-center",children:t.jsx(En,{esc:e,className:"w-[80%]"})}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(Is,{views:M,activeId:O,onViewChange:T,stickyClassName:"h-full min-h-0"})})]})})})}function Ln(e,s){if(typeof e!="string"||!s)return[];const r=e.indexOf(".");if(r===-1)return[];const n=s[e.slice(0,r)];if(!n||typeof n!="object")return[];let a=n;for(const i of e.slice(r+1).split("."))if(a=a[i],a===void 0)return[];return Array.isArray(a)?a:[]}function Pn(e,s,r){if((s==null?void 0:s["x-lt-widget"])!=="checklist"||s["x-lt-require-all"]!==!0)return;const a=Ln(s["x-lt-source"],r).filter(c=>c.required!==!1);if(a.length===0)return;const i=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{},d=a.filter(c=>!i[c.id]).length;if(d!==0)return`${d} of ${a.length} checks incomplete`}function Wn(e,s){const r=s==null?void 0:s.type;if(typeof r=="string"&&!(e==null||e===""))switch(r){case"string":return typeof e=="string"?void 0:"Expected text";case"number":return typeof e=="number"&&Number.isFinite(e)?void 0:"Expected a number";case"integer":return typeof e=="number"&&Number.isInteger(e)?void 0:"Expected a whole number";case"boolean":return typeof e=="boolean"?void 0:"Expected true or false";case"array":return Array.isArray(e)?void 0:"Expected a list";case"object":return typeof e=="object"&&!Array.isArray(e)?void 0:"Expected an object";default:return}}function Fn(e,s,r){if(!s)return;const n=s.enum;if(Array.isArray(n)&&n.length>0&&e!==void 0&&e!==null&&e!==""&&!n.includes(e))return`Must be one of: ${n.map(a=>String(a)).join(", ")}`;if(typeof e=="string"){const a=e.trim();if(a==="")return;const i=bt(s.minLength,s["x-lt-min-length"],r);if(i!==void 0&&a.length<i)return`Minimum ${i} character${i===1?"":"s"}`;const d=bt(s.maxLength,s["x-lt-max-length"],r);if(d!==void 0&&a.length>d)return`Maximum ${d} characters (${a.length} entered)`;const c=s.pattern;if(c)try{if(!new RegExp(c).test(a))return s["x-lt-pattern-error"]??"Invalid format"}catch{}const u=s.format;if(u==="email"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a))return"Enter a valid email address";if(u==="uri"&&!/^https?:\/\/.+/.test(a))return"Enter a valid URL"}if(typeof e=="number"){const a=bt(s.minimum,s["x-lt-minimum"],r),i=bt(s.exclusiveMinimum,void 0,r),d=bt(s.maximum,s["x-lt-maximum"],r),c=bt(s.exclusiveMaximum,void 0,r);if(a!==void 0&&e<a)return`Minimum value is ${a}`;if(i!==void 0&&e<=i)return`Must be greater than ${i}`;if(d!==void 0&&e>d)return`Maximum value is ${d}`;if(c!==void 0&&e>=c)return`Must be less than ${c}`}}function bt(e,s,r){if(typeof e=="number")return e;if(typeof s=="string"&&r){const n=s.indexOf(".");if(n!==-1){const a=s.slice(0,n),i=s.slice(n+1),d=r[a];if(d&&typeof d=="object"){const c=i.split(".");let u=d;for(const p of c)if(u=u[p],u===void 0)break;if(typeof u=="number")return u;if(typeof u=="string"){const p=Number(u);if(!Number.isNaN(p))return p}}}}}function rs(e,s,r,n,a){if(!n)return;if(r){if(e==null||typeof e=="boolean"&&!e||typeof e=="string"&&e.trim()==="")return"Required";if(typeof e=="object"&&!Array.isArray(e)&&e!==null){const c=Object.values(e);if(c.length===0||c.every(u=>!u))return"Required"}}const i=Wn(e,s);if(i)return i;const d=Pn(e,s,a);return d||Fn(e,s,a)}function Le(e){return e!=null&&e!==""&&e!==!1&&e!==0}function qn(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function Pe(e,s){const r=e.indexOf("."),n=r===-1?e:e.slice(0,r);if(!tn.includes(n))return{known:!1,value:void 0};const a=s[n];if(r===-1)return{known:!0,value:a};try{return{known:!0,value:ce(a,e.slice(r+1))}}catch{return{known:!0,value:void 0}}}function ne(e,s){if(typeof e!="string"||e.length===0||!s)return!0;const r=e.startsWith("!"),n=r?e.slice(1):e,a=n.indexOf("!="),i=n.indexOf("=");if(a!==-1||i!==-1&&i!==a+1){const u=a!==-1&&(i===-1||a<i),p=u?a:i,l=n.slice(0,p).trim(),o=n.slice(p+(u?2:1)).trim(),{known:x,value:g}=Pe(l,s);if(!x)return!0;const N=qn(g)===o,f=u?!N:N;return r?!f:f}const{known:d,value:c}=Pe(n,s);return d?r?!Le(c):Le(c):!0}const Un="x-lt-require-any";function Vn(e){const s=e==null?void 0:e[Un];return Array.isArray(s)?s.filter(r=>Array.isArray(r)).map(r=>r.filter(n=>typeof n=="string"&&n.length>0)).filter(r=>r.length>0):[]}function Jn(e){return e==null?!1:typeof e=="string"?e.trim().length>0:!0}function as(e,s,r){if(!e)return[];const n=e.properties??{},a=new Set(e.required??[]),i={...r??{},resolver:s},d=[];for(const[c,u]of Object.entries(n)){if(!ne(u["x-lt-showIf"],i))continue;const p=rs(s[c],u,a.has(c),!0,i);p&&d.push({field:c,message:p})}for(const c of Vn(e)){const u=c.filter(l=>n[l]&&ne(n[l]["x-lt-showIf"],i));if(u.length===0||u.some(l=>Jn(s[l])))continue;const p=u.map(l=>n[l].title??l);d.push({field:u[0],message:`Enter a value for at least one of: ${p.join(", ")}`})}return d}function re(e,s){let r;try{r=JSON.parse(e)}catch{return{payload:null,errors:[],parseError:"Invalid JSON"}}const n=r._form_schema;if(n){const d=as(n,r,s);if(d.length>0)return{payload:null,errors:d,parseError:null}}const{_form_schema:a,...i}=r;return{payload:en(i,n),errors:[],parseError:null}}function Hn(e){const{mode:s,activeView:r,onActiveViewChange:n,onClaim:a,claimPending:i,claimNudge:d,workflowType:c,json:u,onResolve:p,resolvePending:l,resolveError:o,requestTriage:x,triageNotes:g,onRelease:N,releasePending:f,onCancel:h,assignedTo:y,assignedUntil:k,onSubmitAttempt:j,onValidationErrors:E,escalationContext:O,labels:T={},submitBlocked:q,submitBlockedMessage:_,actingName:M,badgePrompt:A,canManage:I,onReassign:S,onUnassign:P,unassignPending:W}=e,V=Ge(),[$,J]=m.useState("30"),[B,z]=m.useState(0),[w,C]=m.useState(""),v=$==="custom",F=m.useCallback(D=>z(D),[]),U=!!q&&!x;if(s==="terminal")return null;const tt=()=>{const D=v?B:parseInt($);!D||D<=0||a(D)},Nt=()=>{if(C(""),x){const pt={_lt:{needsTriage:!0}};g.trim()&&(pt.notes=g.trim()),p(pt);return}const D=re(u,O);if(D.parseError){C(D.parseError);return}if(D.errors.length>0){j==null||j(),E==null||E(D.errors);return}p(D.payload)},Q=D=>`text-xs transition-colors ${D?"text-accent font-medium":"text-text-tertiary hover:text-accent"}`;return t.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"&&t.jsxs("div",{"data-testid":"claim-bar",children:[t.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[V.map(D=>t.jsx("button",{onClick:()=>{J(D.value),z(0)},className:Q(!v&&$===D.value),children:D.label},D.value)),t.jsx("button",{onClick:()=>J("custom"),className:Q(v),children:"Other"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[T.cancel!==!1&&t.jsx("button",{onClick:h,className:"text-xs text-text-tertiary hover:text-status-error transition-colors",children:T.cancel??"Cancel escalation"}),t.jsx("div",{className:"flex-1"}),v&&t.jsx(Qe,{onChange:F,compact:!0,autoFocus:!0}),t.jsx("button",{onClick:tt,disabled:i||v&&B<=0,className:`btn-primary text-xs ${d?"animate-[field-shake_0.4s_ease-in-out]":""}`,"data-testid":"claim-button",children:i?"Claiming...":T.claim??"Claim"},d)]})]}),s==="claimed_by_other"&&t.jsxs("div",{className:"flex items-center gap-4","data-testid":"claimed-other-bar",children:[t.jsxs("p",{className:"text-sm text-text-secondary",children:["Claimed by ",t.jsx("span",{className:"font-medium text-text-primary",children:y?t.jsx(ue,{userId:y}):"unknown"})]}),k&&t.jsx(Ut,{until:k}),o&&t.jsx("span",{className:"text-xs text-status-error",children:o.message}),A&&t.jsx("p",{className:"text-xs text-text-tertiary","data-testid":"badge-prompt",children:"If this is your claim, scan your badge."}),I&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex-1"}),t.jsx("button",{onClick:S,className:"text-xs text-text-tertiary hover:text-accent transition-colors","data-testid":"admin-reassign",children:"Reassign…"}),t.jsx("button",{onClick:P,disabled:W,className:"text-xs text-text-tertiary hover:text-status-error transition-colors disabled:opacity-50","data-testid":"admin-unassign",children:W?"Returning…":"Return to queue"})]})]}),s==="claimed_by_me"&&t.jsxs("div",{"data-testid":"action-bar",children:[t.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[t.jsx("button",{onClick:()=>n("resolve"),className:Q(r==="resolve"),children:c?"Resolve":"Acknowledge"}),t.jsx("button",{onClick:()=>n("release"),className:`text-xs transition-colors ${r==="release"?"text-status-error font-medium":"text-text-tertiary hover:text-status-error"}`,children:T.release??"Release"}),T.cancel!==!1&&t.jsx("button",{onClick:h,className:"text-xs transition-colors text-text-tertiary hover:text-status-error",children:T.cancel??"Cancel"})]}),r==="resolve"&&t.jsxs("div",{className:"flex items-center gap-4",children:[M&&t.jsxs("p",{className:"text-sm text-text-secondary","data-testid":"acting-claim-note",children:["Claimed by you ",t.jsxs("span",{className:"font-medium text-text-primary",children:["(",M,")"]})]}),M&&k&&t.jsx(Ut,{until:k}),t.jsx("div",{className:"flex-1"}),w&&t.jsx("span",{className:"text-xs text-status-error",children:w}),o&&t.jsx("span",{className:"text-xs text-status-error",children:o.message}),U&&_&&t.jsx("span",{className:"text-xs text-status-pending","data-testid":"submit-guard-message",children:_}),t.jsx("button",{onClick:Nt,disabled:l||U,className:"btn-primary text-xs",children:l?c?"Submitting...":"Acknowledging...":x?"Send to Triage":T.submit??(c?"Submit":"Acknowledge")})]}),r==="release"&&t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"text-xs text-text-secondary",children:"Release back to pool?"}),t.jsx("div",{className:"flex-1"}),t.jsx("button",{onClick:()=>n("resolve"),className:"btn-secondary text-xs",children:"Back"}),t.jsx("button",{onClick:N,disabled:f,className:"btn-primary text-xs bg-status-error hover:bg-status-error/80",children:f?"Releasing...":"Yes, Release"})]})]})]})}function Zt({children:e}){return t.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1.5",children:e})}function Bn({payload:e,isTerminal:s,resolverPayload:r,onRetryTriage:n,isRetrying:a}){const i=e.title,d=e.summary,c=e.diagnosis,u=e.tool_calls_made,p=e.result,l=r==null?void 0:r._lt,o=(l==null?void 0:l.triaged)===!0,x=l==null?void 0:l.triageWorkflowId,g=s&&o,[N,f]=m.useState(!1);return g?t.jsxs("div",{className:"rounded-md border border-status-success/30 bg-surface-raised",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("svg",{className:"w-4 h-4 text-status-success shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:t.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"})}),t.jsx("span",{className:"text-xs font-medium text-status-success",children:"Resolved by AI Triage"})]}),typeof u=="number"&&t.jsxs("span",{className:"text-2xs font-mono px-2 py-0.5 rounded-full bg-status-success/10 text-status-success",children:[u," tool calls used"]})]}),t.jsxs("div",{className:"px-4 py-4 space-y-4",children:[i&&t.jsx("p",{className:"text-sm font-medium text-text-primary",children:i}),c&&t.jsxs("div",{children:[t.jsx(Zt,{children:"Triage diagnosis"}),t.jsx("div",{className:"text-xs text-text-primary leading-relaxed",children:t.jsx(Qt,{content:c})})]}),t.jsx("div",{className:"flex items-center gap-3",children:x&&t.jsx(yt,{to:`/workflows/executions/${x}`,className:"text-2xs text-accent hover:underline",children:"View triage execution"})})]})]}):t.jsxs("div",{className:"rounded-md border border-status-warning/30 bg-surface-raised",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("svg",{className:"w-4 h-4 text-status-warning shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:t.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"})}),t.jsx("span",{className:"text-xs font-medium text-status-warning",children:"Tool Rounds Exhausted"})]}),typeof u=="number"&&t.jsxs("span",{className:"text-2xs font-mono px-2 py-0.5 rounded-full bg-status-warning/10 text-status-warning",children:[u," tool calls used"]})]}),t.jsxs("div",{className:"px-4 py-4 space-y-4",children:[i&&t.jsx("p",{className:"text-sm font-medium text-text-primary",children:i}),d&&t.jsxs("div",{children:[t.jsx(Zt,{children:"What happened"}),t.jsx("div",{className:"text-xs text-text-secondary leading-relaxed",children:t.jsx(Qt,{content:d})})]}),c&&t.jsxs("div",{children:[t.jsx(Zt,{children:"What went wrong"}),t.jsx("div",{className:"text-xs text-text-primary leading-relaxed",children:t.jsx(Qt,{content:c})})]}),p!=null&&t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>f(!N),className:"flex items-center gap-1 text-2xs font-semibold uppercase tracking-widest text-text-tertiary hover:text-text-secondary transition-colors",children:[t.jsx("svg",{className:`w-3 h-3 transition-transform ${N?"rotate-90":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:t.jsx("path",{d:"M4.5 2l4 4-4 4"})}),"Partial results"]}),N&&t.jsx("div",{className:"mt-2",children:t.jsx(Rt,{data:p,defaultMode:"tree"})})]}),n&&!s&&t.jsx("div",{className:"pt-2",children:t.jsxs("button",{onClick:n,disabled:a,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:[t.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 14 14",fill:"currentColor",children:t.jsx("path",{d:"M7 1a6 6 0 100 12A6 6 0 007 1zm2.5 6.5l-3.5 2V5.5l3.5 2z"})}),a?"Sending to triage...":"Retry with AI Triage"]})})]})]})}function We(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function is({src:e,escalation:s,schema:r,onResolve:n,onEscalate:a,submitAttempted:i,fill:d}){const c=m.useRef(null),u=m.useRef("");m.useEffect(()=>{try{const l=new URL(e);u.current=l.origin}catch{u.current=""}},[e]);const p=m.useCallback(()=>{const l=c.current;if(!(l!=null&&l.contentWindow)||!u.current)return;const x={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:We(s.envelope),metadata:s.metadata??null,escalation_payload:We(s.escalation_payload)},schema:r};l.contentWindow.postMessage(x,u.current)},[s,r]);return m.useEffect(()=>{const l=o=>{if(o.origin!==u.current)return;const x=o.data;if(!(!x||typeof x!="object"||typeof x.type!="string"))switch(x.type){case"lt:ready":p();break;case"lt:submit":x.payload&&typeof x.payload=="object"&&n(x.payload);break;case"lt:escalate":typeof x.target=="string"&&x.target&&a(x.target);break;case"lt:resize":{const g=c.current;g&&typeof x.height=="number"&&x.height>0&&(g.style.height=`${Math.min(x.height,2e3)}px`);break}}};return window.addEventListener("message",l),()=>window.removeEventListener("message",l)},[p,n,a]),m.useEffect(()=>{if(!i)return;const l=c.current;l!=null&&l.contentWindow&&u.current&&l.contentWindow.postMessage({type:"lt:validate"},u.current)},[i]),d?t.jsx("div",{className:"absolute inset-0 overflow-hidden",children:t.jsx("iframe",{ref:c,src:e,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:p})}):t.jsx("div",{className:"rounded-md border border-surface-border overflow-hidden bg-white",children:t.jsx("iframe",{ref:c,src:e,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:p})})}const zn=2600;function Xn({hint:e,onLockedClick:s,children:r}){const[n,a]=m.useState(null);m.useEffect(()=>{if(!n)return;const d=setTimeout(()=>a(null),zn);return()=>clearTimeout(d)},[n]);const i=d=>{if(s==null||s(),e){const c=Math.min(Math.max(d.clientX,96),window.innerWidth-96);a(u=>({x:c,y:d.clientY,n:((u==null?void 0:u.n)??0)+1}))}};return t.jsxs("div",{className:"pb-8 max-w-form",onClick:i,"data-testid":"locked-form-frame",children:[r,e&&n&&t.jsxs("div",{role:"status",className:"fixed z-[60] pointer-events-none flex items-center gap-2 px-3 py-1.5 rounded-md bg-surface-raised border border-surface-border shadow-lg text-xs font-medium text-text-primary whitespace-nowrap animate-[click-hint_2.6s_ease-in-out_both]",style:{left:n.x,top:n.y-12},onAnimationEnd:()=>a(null),"data-testid":"locked-form-hint",children:[t.jsx(hn,{className:"w-3.5 h-3.5 text-accent shrink-0",strokeWidth:1.5}),e]},n.n)]})}function L({children:e,isRequired:s,htmlFor:r}){return t.jsxs("label",{htmlFor:r,className:"block text-2xs font-semibold uppercase tracking-wider text-text-secondary",children:[e,s&&t.jsx("span",{className:"text-status-error ml-0.5",children:"*"})]})}function Y({id:e,children:s}){return t.jsx("p",{id:e,className:"text-2xs text-text-tertiary mt-0.5 leading-snug",children:s})}function ut({error:e,id:s}){return e?t.jsx("p",{id:s,role:"alert",className:"text-2xs text-status-error mt-1 animate-[field-error-in_0.3s_ease-out]",children:e}):null}function Et(e){return e?"input text-sm w-full mt-1 border-status-error/50 focus:border-status-error animate-[field-shake_0.4s_ease-in-out]":"input text-sm w-full mt-1"}function Gn(e){return e?"select text-sm mt-1 min-w-[min(16rem,100%)] max-w-full border-status-error/50 focus:border-status-error animate-[field-shake_0.4s_ease-in-out]":"select text-sm mt-1 min-w-[min(16rem,100%)] max-w-full"}function Qn({fieldKey:e,value:s,onChange:r,schema:n,isRequired:a}){const i=m.useRef(null),d=(n==null?void 0:n.accept)??void 0,c=K(e,n),u=n==null?void 0:n.description,p=m.useCallback(o=>{var N;const x=(N=o.target.files)==null?void 0:N[0];if(!x)return;const g=new FileReader;g.onload=()=>{typeof g.result=="string"&&r(g.result)},g.readAsDataURL(x)},[r]),l=s.startsWith("data:");return t.jsxs("div",{children:[t.jsx(L,{isRequired:a,children:c}),u&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:u}),t.jsxs("div",{className:"mt-1",children:[t.jsx("input",{ref:i,type:"file",accept:d,onChange:p,className:"hidden"}),t.jsx("button",{type:"button",onClick:()=>{var o;return(o=i.current)==null?void 0:o.click()},className:"btn-secondary text-xs px-3 py-1.5",children:l?"Replace file":"Choose file"}),l&&t.jsx("span",{className:"ml-2 text-xs text-status-success",children:"File attached"})]})]})}function Yn({fieldKey:e,value:s,onChange:r,schema:n,isRequired:a}){const i=K(e,n),d=n==null?void 0:n.description,c=(n==null?void 0:n["x-lt-language"])??"",u=m.useCallback(p=>{if(p.key==="Tab"){p.preventDefault();const l=p.currentTarget,o=l.selectionStart,x=l.selectionEnd,g=s.substring(0,o)+" "+s.substring(x);r(g),requestAnimationFrame(()=>{l.selectionStart=l.selectionEnd=o+2})}},[s,r]);return t.jsxs("div",{children:[t.jsxs(L,{isRequired:a,children:[i,c&&t.jsx("span",{className:"ml-2 text-text-tertiary/60 normal-case font-normal",children:c})]}),d&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:d}),t.jsx("textarea",{value:s,onChange:p=>r(p.target.value),onKeyDown:u,className:"input w-full mt-1 font-mono text-xs leading-relaxed",rows:10,spellCheck:!1})]})}function Zn({fieldKey:e,value:s,onChange:r,schema:n,isRequired:a}){const i=m.useRef(null),[d,c]=m.useState(!1),u=K(e,n),p=n==null?void 0:n.description;m.useEffect(()=>{const f=i.current;if(!f)return;const h=f.getContext("2d");if(h&&(h.lineWidth=2,h.lineCap="round",h.strokeStyle="#1E1535",s&&s.startsWith("data:"))){const y=new Image;y.onload=()=>h.drawImage(y,0,0),y.src=s}},[]);const l=m.useCallback(f=>{const h=i.current,y=h.getBoundingClientRect(),k=y.width>0?h.width/y.width:1,j=y.height>0?h.height/y.height:1;return"touches"in f?{x:(f.touches[0].clientX-y.left)*k,y:(f.touches[0].clientY-y.top)*j}:{x:(f.clientX-y.left)*k,y:(f.clientY-y.top)*j}},[]),o=m.useCallback(f=>{var k;c(!0);const h=(k=i.current)==null?void 0:k.getContext("2d");if(!h)return;const y=l(f);h.beginPath(),h.moveTo(y.x,y.y)},[l]),x=m.useCallback(f=>{var k;if(!d)return;const h=(k=i.current)==null?void 0:k.getContext("2d");if(!h)return;const y=l(f);h.lineTo(y.x,y.y),h.stroke()},[d,l]),g=m.useCallback(()=>{c(!1);const f=i.current;f&&r(f.toDataURL("image/png"))},[r]),N=m.useCallback(()=>{const f=i.current;if(!f)return;const h=f.getContext("2d");h&&(h.clearRect(0,0,f.width,f.height),r(""))},[r]);return t.jsxs("div",{children:[t.jsx(L,{isRequired:a,children:u}),p&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:p}),t.jsx("div",{className:"mt-1 max-w-[25rem] border border-surface-border rounded-md overflow-hidden bg-white",children:t.jsx("canvas",{ref:i,width:400,height:150,className:"w-full cursor-crosshair touch-none",onMouseDown:o,onMouseMove:x,onMouseUp:g,onMouseLeave:g,onTouchStart:o,onTouchMove:x,onTouchEnd:g})}),t.jsx("button",{type:"button",onClick:N,className:"mt-1 text-2xs text-text-tertiary hover:text-accent transition-colors",children:"Clear"})]})}function Kn({fieldKey:e,value:s,onChange:r,schema:n,isRequired:a}){const i=K(e,n),d=n==null?void 0:n.description;return t.jsxs("div",{children:[t.jsx(L,{isRequired:a,children:i}),d&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:d}),t.jsx("textarea",{value:s,onChange:c=>r(c.target.value),className:"input w-full mt-1 text-sm leading-relaxed",rows:8,placeholder:"Supports plain text. Markdown formatting is preserved."})]})}function tr({fieldKey:e,value:s,onChange:r,schema:n,isRequired:a}){const[i,d]=m.useState("write"),c=K(e,n),u=n==null?void 0:n.description;return(n==null?void 0:n.readOnly)===!0?t.jsx(qt,{content:s,className:"my-1"}):t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(L,{isRequired:a,children:c}),t.jsx("div",{className:"flex items-center gap-0.5",children:["write","preview"].map(l=>t.jsx("button",{type:"button",onClick:()=>d(l),className:`px-2 py-0.5 text-2xs rounded transition-colors ${i===l?"bg-accent/10 text-accent font-semibold":"text-text-quaternary hover:text-text-secondary"}`,children:l==="write"?"Write":"Preview"},l))})]}),u&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:u}),i==="write"?t.jsx("textarea",{value:s,onChange:l=>r(l.target.value),className:"input w-full mt-1 text-sm font-mono leading-relaxed",rows:10,placeholder:"Write markdown — headings, lists, tables, code blocks, and links all render."}):t.jsx("div",{className:"mt-1 px-3 py-2 border border-surface-border rounded min-h-[120px]",children:s.trim()?t.jsx(qt,{content:s}):t.jsx("p",{className:"text-xs text-text-quaternary italic",children:"Nothing to preview."})})]})}const er=28;function sr({fieldKey:e,value:s,onChange:r,schema:n,escalationContext:a,isRequired:i,submitAttempted:d,error:c}){const u=n==null?void 0:n["x-lt-source"],p=(n==null?void 0:n["x-lt-require-all"])===!0,l=[];if(u&&a){const j=u.indexOf(".");if(j!==-1){const E=u.slice(0,j),O=u.slice(j+1);try{const T=ce(a[E],O);Array.isArray(T)&&l.push(...T)}catch{}}}let o={};try{s&&(o=JSON.parse(s))}catch{}const x=j=>r(JSON.stringify({...o,[j]:!o[j]})),g=K(e,n),N=n==null?void 0:n.description;if(l.length===0)return t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-xs text-text-tertiary italic mt-1",children:"No checklist items. Provide checklist_items in the escalation envelope or metadata."}),c&&t.jsx("p",{className:"text-2xs text-status-error mt-1 animate-[field-error-in_0.3s_ease-out]",children:c})]});const f=n==null?void 0:n["x-lt-variant"],h=f==="chips"||f==="rows"?f:p||l.some(j=>j.label.length>er)?"rows":"chips",y=l.filter(j=>o[j.id]).length,k=(l.find(j=>!o[j.id]&&j.required!==!1)??l[0]).id;return t.jsxs("div",{role:"group","aria-label":g,"aria-required":i||void 0,"aria-invalid":c?!0:void 0,children:[t.jsx(L,{isRequired:i,children:g}),N&&t.jsx(Y,{children:N}),h==="chips"?t.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:l.map(j=>{const E=o[j.id]??!1,O=!E&&!!d&&y===0&&(j.required||i);return t.jsxs("label",{className:`inline-flex items-center gap-1.5 cursor-pointer select-none px-3.5 py-2 text-sm border transition-colors rounded-[var(--lt-radius-field)] ${E?"bg-accent border-accent text-text-inverse":O?"bg-surface-field border-status-error/60 text-status-error":"bg-surface-field border-surface-field-border text-text-secondary hover:border-accent hover:text-text-primary"}`,children:[t.jsx("input",{type:"checkbox",checked:E,onChange:()=>x(j.id),className:"sr-only","data-testid":`checklist-item-${j.id}`,...j.id===k?{"data-field-key":e}:{}}),E&&t.jsx(gn,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:2.5}),j.label]},j.id)})}):t.jsx("div",{className:"space-y-2.5 mt-2",children:l.map(j=>{const E=o[j.id]??!1,O=!E&&!!d&&(p?j.required!==!1:y===0&&(j.required||i));return t.jsxs("label",{className:`flex items-start gap-3 cursor-pointer group select-none rounded px-2 py-1 -mx-2 transition-colors ${O?"bg-status-error/5":"hover:bg-surface-hover"}`,children:[t.jsx("input",{type:"checkbox",checked:E,onChange:()=>x(j.id),className:`mt-0.5 w-3.5 h-3.5 shrink-0 rounded ${O?"accent-status-error":"accent-accent"}`,"data-testid":`checklist-item-${j.id}`,...j.id===k?{"data-field-key":e}:{}}),t.jsxs("span",{className:`text-sm leading-snug transition-colors ${O?"text-status-error":"text-text-secondary group-hover:text-text-primary"}`,children:[j.label,j.required&&t.jsx("span",{className:`ml-0.5 text-2xs ${O?"text-status-error":"text-text-quaternary"}`,children:"*"})]})]},j.id)})}),t.jsx("p",{className:"text-2xs text-text-quaternary mt-3 tabular-nums",children:h==="chips"?t.jsxs(t.Fragment,{children:[y," selected",i&&y===0&&!!d&&t.jsx("span",{className:"ml-1 text-text-quaternary/60",children:"(check at least one)"})]}):t.jsxs(t.Fragment,{children:[y," / ",l.length," confirmed",p?t.jsxs("span",{className:"ml-1 text-text-quaternary/60",children:["(all required",l.some(j=>j.required===!1)?" except optional":"",")"]}):i&&y===0&&!!d&&t.jsx("span",{className:"ml-1 text-text-quaternary/60",children:"(at least one required)"})]})}),c&&t.jsx("p",{role:"alert",className:"text-2xs text-status-error mt-1 animate-[field-error-in_0.3s_ease-out]",children:c})]})}const nr=/\.(png|jpe?g|gif|webp|avif|bmp|svg)(\?.*)?$/i;function rr(e){var n,a,i,d;const s=e.trim();if(!s)return{kind:"none"};const r=(a=(n=/^data:([^;,]+)[;,]/.exec(s))==null?void 0:n[1])==null?void 0:a.toLowerCase();if(r)return r.startsWith("image/")?{kind:"image",src:s}:{kind:"file",href:s,label:r==="application/pdf"?"PDF":r,isData:!0};if(/^https?:\/\//i.test(s)){if(nr.test(s))return{kind:"image",src:s};const c=(d=(i=/\.([a-z0-9]{2,5})(\?.*)?$/i.exec(s))==null?void 0:i[1])==null?void 0:d.toUpperCase();return{kind:"file",href:s,label:c??"attachment",isData:!1}}return{kind:"none"}}function Fe({fieldKey:e,value:s,schema:r}){const[n,a]=m.useState(!1),i=rr(s??""),d=e.replace(/[_-]/g," "),c=r==null?void 0:r.description,u=t.jsxs(t.Fragment,{children:[t.jsx("label",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary",children:d}),c&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:c})]});return i.kind==="none"?t.jsxs("div",{children:[u,t.jsx("p",{className:"text-xs text-text-quaternary italic mt-1",children:"No attachment"})]}):i.kind==="image"?t.jsxs("div",{children:[u,t.jsxs("div",{className:"mt-1",children:[t.jsx("button",{type:"button",onClick:()=>a(!0),className:"block rounded-[0.125em] border border-surface-border overflow-hidden hover:border-accent transition-colors",title:"View full size",children:t.jsx("img",{src:i.src,alt:e.replace(/[_-]/g," "),className:"max-h-48 max-w-full object-contain","data-testid":`attachment-image-${e}`})}),n&&t.jsx("div",{className:"fixed inset-0 z-[100] bg-text-primary/60 backdrop-blur-sm flex items-center justify-center p-8 cursor-zoom-out",onClick:()=>a(!1),role:"dialog","aria-modal":"true","aria-label":`${d} — full size`,children:t.jsx("img",{src:i.src,alt:d,className:"max-h-[90vh] max-w-[90vw] object-contain"})})]})]}):t.jsxs("div",{children:[u,t.jsx("div",{className:"mt-1",children:t.jsxs("a",{href:i.href,...i.isData?{download:`${e}.${i.label==="PDF"?"pdf":"bin"}`}:{target:"_blank",rel:"noopener noreferrer"},className:"inline-flex items-center gap-1.5 text-xs text-accent hover:text-accent-hover transition-colors","data-testid":`attachment-link-${e}`,children:[t.jsx(bn,{className:"w-3.5 h-3.5",strokeWidth:1.5}),i.isData?`Download ${i.label}`:`Open ${i.label}`,i.isData?t.jsx(jn,{className:"w-3 h-3",strokeWidth:1.5}):t.jsx(se,{className:"w-3 h-3",strokeWidth:1.5})]})})]})}function ar({fieldKey:e,schema:s,escalationContext:r}){const n=(s==null?void 0:s["x-lt-href"])??"",a=n&&r?ot(n,r):n,i=(s==null?void 0:s.title)??(s==null?void 0:s.description)??"Open",d=s==null?void 0:s.description,c=a.startsWith("/"),u=!a.trim();return t.jsxs("div",{"data-field-key":e,children:[t.jsx(L,{children:i}),d&&t.jsx(Y,{children:d}),t.jsx("div",{className:"mt-1",children:u?t.jsx("span",{className:"text-xs text-text-quaternary italic",children:"No link configured"}):c?t.jsxs(yt,{to:a,className:"inline-flex items-center gap-1 text-xs text-accent hover:text-accent-hover transition-colors","data-testid":`link-widget-${e}`,children:[i,t.jsx(se,{className:"w-3 h-3 shrink-0",strokeWidth:1.5})]}):t.jsxs("a",{href:a,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-accent hover:text-accent-hover transition-colors","data-testid":`link-widget-${e}`,children:[i,t.jsx(se,{className:"w-3 h-3 shrink-0",strokeWidth:1.5})]})})]})}function os({to:e,className:s=""}){return t.jsxs(yt,{to:e,title:"View details",tabIndex:-1,className:`inline-flex items-center justify-center w-6 h-6 shrink-0 rounded border border-surface-border text-accent/70 hover:text-accent hover:border-accent/60 hover:bg-accent/5 transition-colors ${s}`,children:[t.jsx(yn,{className:"w-3.5 h-3.5",strokeWidth:2}),t.jsx("span",{className:"sr-only",children:"View details"})]})}const qe="—";function ir(e,s){if(!e||!s)return"";const r=e.indexOf(".");if(r===-1)return"";const n=e.slice(0,r),a=e.slice(r+1);try{const i=ce(s[n],a);return typeof i=="string"?i:""}catch{return""}}function or(e,s){if(!e||e===qe)return qe;if(s==="age"){const r=new Date(e);return Number.isNaN(r.getTime())?e:ie(e)}return e}function lr({fieldKey:e,schema:s,escalationContext:r}){const n=s==null?void 0:s["x-lt-source"],a=(s==null?void 0:s["x-lt-fields"])??[],i=(s==null?void 0:s.title)??"Linked escalation",d=s==null?void 0:s.description,c=ir(n,r),{data:u,isLoading:p,isError:l}=Be(c);return t.jsxs("div",{"data-field-key":e,children:[t.jsx(L,{children:i}),d&&t.jsx(Y,{children:d}),t.jsx("div",{className:"mt-1",children:!c||l?t.jsx("p",{className:"text-xs text-text-quaternary italic","data-testid":`escalation-widget-empty-${e}`,children:"No linked record"}):p?t.jsx(dr,{}):u?t.jsx(cr,{esc:u,fields:a,fieldKey:e}):t.jsx("p",{className:"text-xs text-text-quaternary italic",children:"No linked record"})})]})}function cr({esc:e,fields:s,fieldKey:r}){if(!e)return null;const n=de(e);return t.jsxs("div",{className:"border-l-2 border-accent-faint pl-3 py-2 space-y-2","data-testid":`escalation-widget-card-${r}`,children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("span",{className:"text-2xs font-semibold uppercase tracking-wider text-text-secondary",children:[e.type,e.subtype&&e.subtype!==e.type?` · ${e.subtype}`:""]}),t.jsx(ts,{status:e.status})]}),e.description&&t.jsx("p",{className:"text-xs text-text-primary leading-snug",children:e.description}),s.length>0&&t.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-0.5",children:s.map(a=>{const i=ot(a.value,n),d=or(i,a.format);return t.jsxs("div",{className:"contents",children:[t.jsx("dt",{className:"text-2xs text-text-tertiary whitespace-nowrap",children:a.label}),t.jsx("dd",{className:"text-2xs text-text-primary",children:d})]},a.label)})}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("span",{className:"text-2xs text-text-quaternary",children:[e.role," · ",ie(e.created_at)]}),t.jsx(os,{to:`/escalations/detail/${e.id}`})]})]})}function dr(){return t.jsxs("div",{className:"border-l-2 border-accent-faint pl-3 py-2 space-y-2 animate-pulse",children:[t.jsx("div",{className:"h-3 w-32 bg-surface-sunken rounded"}),t.jsx("div",{className:"h-3 w-48 bg-surface-sunken rounded"}),t.jsx("div",{className:"h-3 w-24 bg-surface-sunken rounded"})]})}function ur(e,s){if(!e)return{};const r={};for(const[n,a]of Object.entries(e))r[n]=typeof a=="string"?ot(a,s):a;return r}function ls(e,s,r){const n=ur(e.facets,s),a={role:e.role,status:e.status??"pending",facets:n,limit:e.limit,enabled:!!(e.role||Object.keys(n).length)};return e.assigned==="me"?{...a,assigned_to:r,available:!1,enabled:a.enabled&&!!r}:e.assigned==="any"?a:{...a,available:e.available??!0}}const xr=[{label:"Description",value:"{{escalation.description}}"},{label:"Role",value:"{{escalation.role}}"},{label:"Age",value:"{{escalation.created_at}}",format:"age"}],Ue="—";function pr(e,s){if(!e||e===Ue)return Ue;if(s==="age"){const r=new Date(e);return Number.isNaN(r.getTime())?e:ie(e)}return e}function ae(e,s){return typeof e=="string"?ot(e,s):Array.isArray(e)?e.map(r=>ae(r,s)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([r,n])=>[r,ae(n,s)])):e}function mr({fieldKey:e,schema:s,escalationContext:r}){const n=(s==null?void 0:s["x-lt-query"])??{},a=(s==null?void 0:s["x-lt-columns"])??xr,i=(s==null?void 0:s["x-lt-actions"])??[],d=(s==null?void 0:s.title)??"Related items",c=s==null?void 0:s.description,u=r??{},{user:p}=oe(),l=ls(n,u,p==null?void 0:p.userId),{data:o,isLoading:x}=ze({role:l.role,status:l.status,facets:l.facets,assigned_to:l.assigned_to,available:l.available,limit:l.limit??5,enabled:l.enabled,include:sn({columns:a,actions:i})?"envelope":void 0}),g=(o==null?void 0:o.escalations)??[],N=Xe(),[f,h]=m.useState({}),[y,k]=m.useState(null),j=async(E,O)=>{const T=de(E);if(!(O.confirm&&!window.confirm(ot(O.confirm,T)))){k(E.id),h(q=>({...q,[E.id]:""}));try{await N.mutateAsync({id:E.id,resolverPayload:ae(O.resolverPayload,T)})}catch(q){h(_=>({..._,[E.id]:q.message}))}finally{k(null)}}};return t.jsxs("div",{"data-field-key":e,children:[t.jsx(L,{children:d}),c&&t.jsx(Y,{children:c}),t.jsx("div",{className:"mt-1","data-testid":`escalation-list-widget-${e}`,children:x?t.jsx(hr,{columns:a.length}):t.jsx(fr,{escalations:g,columns:a,fieldKey:e,actions:i,onAction:j,pendingRow:y,rowErrors:f})})]})}function fr({escalations:e,columns:s,fieldKey:r,actions:n,onAction:a,pendingRow:i,rowErrors:d}){return e.length===0?t.jsx("p",{className:"text-xs text-text-quaternary italic py-1","data-testid":`escalation-list-empty-${r}`,children:"No items found"}):t.jsxs("table",{className:"w-full text-xs border-collapse","data-testid":`escalation-list-table-${r}`,children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-surface-border",children:[s.map(c=>t.jsx("th",{className:"text-left text-2xs font-semibold uppercase tracking-wider text-text-tertiary pb-1 pr-3 last:pr-0",children:c.label},c.label)),n.length>0&&t.jsx("th",{className:"w-px"}),t.jsx("th",{className:"w-8"})]})}),t.jsx("tbody",{children:e.map(c=>{const u=de(c),p=d[c.id];return t.jsxs("tr",{className:"border-b border-surface-border/50 last:border-0 hover:bg-surface-sunken/50 transition-colors",children:[s.map(l=>{const o=ot(l.value,u),x=pr(o,l.format);return t.jsx("td",{className:"py-1 pr-3 last:pr-0 text-text-primary align-top",children:x},l.label)}),n.length>0&&t.jsxs("td",{className:"py-1 pr-2 align-top whitespace-nowrap",children:[n.map(l=>t.jsx("button",{type:"button",onClick:()=>a(c,l),disabled:i===c.id,className:"px-2 py-0.5 text-2xs font-medium text-accent border border-accent/40 rounded hover:bg-accent/10 disabled:opacity-40 disabled:cursor-default transition-colors ml-1 first:ml-0","data-testid":`escalation-list-action-${c.id}`,children:l.label},l.label)),p&&t.jsx("p",{className:"text-2xs text-status-error mt-0.5 whitespace-normal max-w-[16rem]","data-testid":`escalation-list-action-error-${c.id}`,children:p})]}),t.jsx("td",{className:"py-1 pl-2 align-top",children:t.jsx(os,{to:`/escalations/detail/${c.id}`})})]},c.id)})})]})}function hr({columns:e}){return t.jsx("div",{className:"space-y-1.5 animate-pulse",children:[0,1,2].map(s=>t.jsx("div",{className:"flex gap-4",children:Array.from({length:e},(r,n)=>t.jsx("div",{className:"h-3 bg-surface-sunken rounded flex-1"},n))},s))})}const Kt={"file-upload":Qn,"code-editor":Yn,signature:Zn,"rich-text":Kn,markdown:tr,checklist:sr,attachment:Fe,image:Fe,link:ar,escalation:lr,"escalation-list":mr};function cs({fieldKey:e,value:s,onChange:r,onBlur:n,schema:a,isRequired:i,isReadOnly:d,error:c,escalationContext:u,submitAttempted:p}){var q;const l=(q=a==null?void 0:a.properties)==null?void 0:q[e],o=K(e,l),x=l==null?void 0:l["x-lt-widget"],g=`lt-field-${e}`,N=`${g}-error`,f=`${g}-help`,h=typeof(l==null?void 0:l.description)=="string"&&l.description.length>0?l.description:void 0,j={id:g,"aria-required":i||void 0,"aria-invalid":c?!0:void 0,"aria-describedby":c?N:h!==void 0?f:void 0},E=x==="markdown"&&typeof s=="string",O=(x==="attachment"||x==="image")&&typeof s=="string",T=!!(x&&x in Kt);if(d&&!E&&!O&&!T){const _=s===null?"null":typeof s=="object"?JSON.stringify(s,null,2):String(s);return t.jsxs("div",{children:[t.jsx(L,{isRequired:i,children:o}),t.jsx("p",{className:"text-sm text-text-secondary mt-0.5 whitespace-pre-wrap",children:_})]})}if(x&&x in Kt){const _=Kt[x],M=i||(l==null?void 0:l["x-lt-require-all"])===!0,A={fieldKey:e,schema:l,escalationContext:u,isRequired:M,submitAttempted:p,error:c};if((l==null?void 0:l.type)==="object"){const I=typeof s=="string"?s:typeof s=="object"&&s!==null&&!Array.isArray(s)?JSON.stringify(s):"";return t.jsx(_,{...A,value:I,onChange:S=>{try{r(JSON.parse(S))}catch{r(S)}}})}if(typeof s=="string")return t.jsx(_,{...A,value:s,onChange:I=>r(I)});if(typeof s=="object"&&s!==null&&!Array.isArray(s))return t.jsx(_,{...A,value:JSON.stringify(s),onChange:I=>{try{r(JSON.parse(I))}catch{r(I)}}})}if(typeof s=="boolean")return t.jsxs("div",{children:[t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:s,onChange:_=>{r(_.target.checked),n==null||n()},className:"w-3.5 h-3.5 rounded accent-accent","data-field-key":e,...j}),t.jsxs("span",{className:"text-2xs font-semibold uppercase tracking-wider text-text-secondary",children:[o,i&&t.jsx("span",{className:"text-status-error ml-0.5",children:"*"})]})]}),h&&t.jsx(Y,{id:f,children:h}),t.jsx(ut,{error:c,id:N})]});if(typeof s=="number")return t.jsxs("div",{children:[t.jsx(L,{isRequired:i,htmlFor:g,children:o}),h&&t.jsx(Y,{id:f,children:h}),t.jsx("input",{type:"number",value:s,onChange:_=>r(parseFloat(_.target.value)||0),onBlur:n,step:"any","data-field-key":e,className:`${Et(!!c)} max-w-48`,...j}),t.jsx(ut,{error:c,id:N})]});if(typeof s=="string"){const _=(l==null?void 0:l.format)==="password",M=l==null?void 0:l.enum;if(M!=null&&M.length){const P=s===""&&!M.includes("");return t.jsxs("div",{children:[t.jsx(L,{isRequired:i,htmlFor:g,children:o}),h&&t.jsx(Y,{id:f,children:h}),t.jsxs("select",{value:s,onChange:W=>r(W.target.value),onBlur:n,"data-field-key":e,className:Gn(!!c),...j,children:[P&&t.jsx("option",{value:"",disabled:!0,children:"Choose…"}),M.map(W=>t.jsx("option",{value:W,children:W},W))]}),t.jsx(ut,{error:c,id:N})]})}if(_)return t.jsxs("div",{children:[t.jsx(L,{isRequired:i,htmlFor:g,children:o}),h&&t.jsx(Y,{id:f,children:h}),t.jsx("input",{type:"password",value:s,onChange:P=>r(P.target.value),onBlur:n,"data-field-key":e,className:Et(!!c),autoComplete:"off",...j}),t.jsx(ut,{error:c,id:N})]});const A=l==null?void 0:l.format,I={date:"date","date-time":"datetime-local",email:"email",uri:"url"},S={date:"max-w-48","date-time":"max-w-64"};if(A&&A in I)return t.jsxs("div",{children:[t.jsx(L,{isRequired:i,htmlFor:g,children:o}),h&&t.jsx(Y,{id:f,children:h}),t.jsx("input",{type:I[A],value:s,onChange:P=>r(P.target.value),onBlur:n,"data-field-key":e,className:`${Et(!!c)} ${S[A]??""}`,...j}),t.jsx(ut,{error:c,id:N})]});if(A==="textarea"||s.length>80){const P=l==null?void 0:l.maxLength,W=l==null?void 0:l["x-lt-max-length"];let V=P;if(V===void 0&&W&&u){const J=W.indexOf(".");if(J!==-1){const B=W.slice(0,J),z=W.slice(J+1),w=u[B];if(w&&typeof w=="object"){let C=w;for(const v of z.split("."))if(C=C[v],C===void 0)break;if(typeof C=="number")V=C;else if(typeof C=="string"){const v=Number(C);Number.isNaN(v)||(V=v)}}}}const $=V!==void 0&&s.length>V;return t.jsxs("div",{children:[t.jsx(L,{isRequired:i,htmlFor:g,children:o}),h&&t.jsx(Y,{id:f,children:h}),t.jsx("textarea",{value:s,onChange:J=>{r(J.target.value),n==null||n()},onBlur:n,"data-field-key":e,className:`${Et(!!c)} leading-relaxed`,rows:Math.min(6,Math.max(3,Math.ceil(s.length/60))),...j}),V!==void 0&&t.jsxs("p",{className:`text-2xs mt-0.5 text-right tabular-nums ${$?"text-status-error font-medium":"text-text-quaternary"}`,children:[s.length," / ",V]}),t.jsx(ut,{error:c,id:N})]})}return t.jsxs("div",{children:[t.jsx(L,{isRequired:i,htmlFor:g,children:o}),h&&t.jsx(Y,{id:f,children:h}),t.jsx("input",{type:"text",value:s,onChange:P=>r(P.target.value),onBlur:n,"data-field-key":e,className:Et(!!c),...j}),t.jsx(ut,{error:c,id:N})]})}if(s===null)return t.jsxs("div",{children:[t.jsx(L,{isRequired:i,children:o}),t.jsx("p",{className:"text-xs text-text-tertiary italic mt-1",children:"null"})]});if(Array.isArray(s))return t.jsxs("div",{children:[t.jsx(L,{isRequired:i,children:o}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:s.map((_,M)=>t.jsx("span",{className:"px-2 py-0.5 text-2xs font-mono bg-surface-sunken rounded text-text-secondary",children:String(_)},M))})]});if(typeof s=="object"){const _=Object.entries(s);return t.jsxs("div",{children:[t.jsx(L,{isRequired:i,children:o}),t.jsx("div",{className:"ml-4 mt-2 pl-4 border-l border-accent-faint space-y-3",children:_.map(([M,A])=>t.jsx(cs,{fieldKey:M,value:A,onChange:I=>r({...s,[M]:I})},M))})]})}return null}function gr({items:e,columns:s=1}){if(e.length===0)return null;const r=s>=2&&e.length>1?"grid-cols-1 @dict-inline:grid-cols-[max-content_1fr] @dict-pairs:grid-cols-[max-content_1fr_max-content_1fr]":"grid-cols-1 @dict-inline:grid-cols-[max-content_1fr]";return t.jsx("div",{className:"@container",children:t.jsx("dl",{className:`grid ${r} items-baseline gap-x-6 @dict-pairs:gap-x-8 gap-y-1.5`,children:e.map(({key:n,label:a,value:i})=>t.jsxs(m.Fragment,{children:[t.jsx("dt",{className:"text-2xs font-semibold uppercase tracking-wide text-text-secondary mt-2 first:mt-0 @dict-inline:mt-0",children:a}),t.jsx("dd",{className:"text-sm text-text-primary break-words min-w-0","data-field-key":n,children:br(i)})]},n))})})}function br(e){return e==null||e===""?"—":typeof e=="boolean"?e?"Yes":"No":typeof e=="object"?JSON.stringify(e):String(e)}const te="dictionary",jr=new Set(["markdown","attachment","image"]);function ds(e,s){if(!s)return;const r=e==null?void 0:e["x-lt-section-options"],n=r==null?void 0:r[s];return n&&typeof n=="object"?n:void 0}function yr(e,s,r){var c,u;const n=(c=e==null?void 0:e.properties)==null?void 0:c[r];if((n==null?void 0:n.readOnly)!==!0)return!1;const a=n==null?void 0:n["x-lt-widget"];if(typeof a=="string"&&jr.has(a))return!1;const i=n==null?void 0:n["x-lt-display"];if(typeof i=="string")return i===te;const d=(u=ds(e,s))==null?void 0:u.display;return typeof d=="string"?d===te:(e==null?void 0:e["x-lt-display"])===te}function Nr(e,s,r,n){var i;const a=[];for(const d of e){const[c]=d,u=a[a.length-1];if(yr(s,r,c)){(u==null?void 0:u.kind)==="dictionary"?u.entries.push(d):a.push({kind:"dictionary",entries:[d]});continue}const p=(i=s==null?void 0:s.properties)==null?void 0:i[c],l=p==null?void 0:p["x-lt-column-group"];if(n==="two-column"&&typeof l=="string"&&l.trim()){(u==null?void 0:u.kind)==="column-group"&&u.name===l?u.entries.push(d):a.push({kind:"column-group",name:l,entries:[d]});continue}a.push({kind:"field",entry:d})}return a}function vr({name:e,entries:s,formSchema:r,layout:n,renderField:a}){const i=Nr(s,r,e,n),d=ds(r,e),c=(d==null?void 0:d.columns)??(n==="two-column"?2:1),u=l=>l.map(([o,x])=>{var g;return{key:o,label:K(o,(g=r==null?void 0:r.properties)==null?void 0:g[o]),value:x}}),p=()=>i.map((l,o)=>l.kind==="dictionary"?t.jsx("div",{className:n==="two-column"?"col-span-full":"",children:t.jsx(gr,{items:u(l.entries),columns:c})},`dict-${o}`):l.kind==="column-group"?t.jsx("div",{className:"@container",children:t.jsx("div",{className:"grid grid-cols-1 @grp-cols:grid-cols-2 gap-x-4 gap-y-5",children:l.entries.map(x=>a(x))})},`group-${l.name}-${o}`):a(l.entry));return t.jsxs("div",{className:e?"border border-surface-border bg-surface-sunken rounded-[var(--lt-radius-section)] p-4 animate-[section-enter_0.25s_ease-out]":"",children:[e&&t.jsx("p",{className:"mb-4 text-[1.40625rem] font-semibold tracking-wider text-heading [font-variant-caps:small-caps]",children:e}),n==="two-column"?t.jsx("div",{className:"@container",children:t.jsx("div",{className:"grid grid-cols-1 @form-cols:grid-cols-2 gap-x-col-gap gap-y-5",children:p()})}):t.jsx("div",{className:"space-y-5",children:p()})]})}function us({value:e,onChange:s,disabled:r,submitAttempted:n,escalationContext:a,onOpenHelp:i,onDisabledClick:d,disabledHint:c}){var B,z;const[u,p]=m.useState({}),[l,o]=m.useState({}),[x,g]=m.useState(null),[N,f]=m.useState(!1),[h,y]=m.useState(new Set);m.useEffect(()=>{try{const w=JSON.parse(e);if(typeof w=="object"&&w!==null&&!Array.isArray(w)){const C={},v={};for(const[F,U]of Object.entries(w))F.startsWith("_")?v[F]=U:C[F]=U;p(C),o(v),g(v._form_schema&&typeof v._form_schema=="object"?v._form_schema:null),f(!1)}}catch{f(!0)}},[e]);const k=m.useCallback(w=>{p(w),s(JSON.stringify({...w,...l},null,2))},[l,s]),j=m.useCallback((w,C)=>{k({...u,[w]:C})},[u,k]),E=m.useCallback(w=>{y(C=>{if(C.has(w))return C;const v=new Set(C);return v.add(w),v})},[]);if(N)return t.jsx("p",{className:"text-xs text-status-error",children:"Unable to parse resolver data as form. Use the JSON editor below."});const O=Object.entries(u);if(O.length===0)return t.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No resolver fields defined."});const T=x==null?void 0:x["x-lt-order"],q=T?[...O].sort((w,C)=>{const v=T.indexOf(w[0]),F=T.indexOf(C[0]);return(v===-1?1/0:v)-(F===-1?1/0:F)}):O,_={...a??{},resolver:u},M=q.filter(([w,C])=>{var F;const v=(F=x==null?void 0:x.properties)==null?void 0:F[w];return!(!ne(v==null?void 0:v["x-lt-showIf"],_)||(v==null?void 0:v["x-lt-hide-if-empty"])===!0&&(C==null||C===""||C===!1||C===0))}),A=new Set((x==null?void 0:x.required)??[]),I=x==null?void 0:x["x-lt-layout"],S=x==null?void 0:x.title,P=x==null?void 0:x.description,W=typeof(x==null?void 0:x["x-lt-help"])=="string"||typeof(x==null?void 0:x["x-lt-context"])=="string",V=[];for(const w of M){const[C]=w,v=(B=x==null?void 0:x.properties)==null?void 0:B[C],F=((z=v==null?void 0:v["x-lt-section"])==null?void 0:z.trim())||null,U=V[V.length-1];!U||U.name!==F?V.push({name:F,entries:[w]}):U.entries.push(w)}const $=([w,C])=>{var D;const v=(D=x==null?void 0:x.properties)==null?void 0:D[w],F=(v==null?void 0:v.readOnly)===!0,U=(v==null?void 0:v["x-lt-span"])??1,tt=A.has(w),Nt=h.has(w)||!!n,Q=rs(C,v,tt,Nt,_);return t.jsx("div",{className:`animate-[field-enter_0.2s_ease-out] ${I==="two-column"&&U>=2?"col-span-full":""}`,children:t.jsx(cs,{fieldKey:w,value:C,onChange:pt=>j(w,pt),onBlur:()=>E(w),schema:x,isRequired:tt,isReadOnly:F,error:Q,escalationContext:_,submitAttempted:!!n})},w)},J=t.jsxs("div",{className:r?"pointer-events-none":void 0,inert:r||void 0,"aria-disabled":r||void 0,children:[S&&t.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[t.jsx("h3",{className:"heading-3",children:S}),W&&i&&t.jsx("button",{type:"button",onClick:i,title:"Open instructions","aria-label":"Open instructions",className:"p-1 rounded-md text-text-tertiary hover:text-accent hover:bg-surface-hover transition-colors",children:t.jsx(es,{className:"w-4 h-4",strokeWidth:1.5})})]}),P&&t.jsx("p",{className:"text-sm text-text-secondary leading-relaxed mb-6",children:P}),t.jsx("div",{className:"space-y-8",children:V.map((w,C)=>t.jsx(vr,{name:w.name,entries:w.entries,formSchema:x,layout:I,renderField:$},w.name??`__s${C}`))})]});return r?t.jsx(Xn,{hint:c,onLockedClick:d,children:J}):t.jsx("div",{className:"pb-8 max-w-form",children:J})}function wr({json:e,onJsonChange:s,requestTriage:r,onRequestTriageChange:n,triageNotes:a,onTriageNotesChange:i,disabled:d=!1,submitAttempted:c=!1,showTriage:u=!1,escalationContext:p,onOpenHelp:l,onDisabledClick:o,disabledHint:x}){return t.jsxs(t.Fragment,{children:[u&&t.jsx("div",{className:"flex items-center justify-between mb-3",children:r?t.jsxs("button",{onClick:()=>n(!1),className:"group flex items-center gap-2 text-left","data-testid":"triage-cancel",children:[t.jsx("span",{className:"flex items-center justify-center w-5 h-5 rounded-full bg-accent/10 text-accent shrink-0",children:t.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),t.jsxs("span",{className:"text-xs text-text-secondary group-hover:text-text-primary transition-colors",children:["AI Triage active."," ",t.jsx("span",{className:"text-accent group-hover:underline",children:"Cancel"})]})]}):t.jsxs("button",{onClick:()=>n(!0),className:"group flex items-center gap-2.5 text-left my-4","data-testid":"triage-callout",children:[t.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:t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.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"})})}),t.jsxs("span",{className:"text-sm text-text-secondary group-hover:text-text-primary transition-colors",children:["This form doesn't capture the issue?"," ",t.jsx("span",{className:"text-accent group-hover:underline",children:"Request AI Triage"})]})]})}),t.jsxs("div",{className:"relative min-h-[200px]",children:[t.jsx("div",{className:r?"pointer-events-none select-none":"",children:t.jsx(us,{value:e,onChange:s,disabled:d,submitAttempted:c,escalationContext:p,onOpenHelp:l,onDisabledClick:o,disabledHint:x})}),r&&t.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:[t.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."}),t.jsx("textarea",{value:a,onChange:g=>i(g.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 xs(e,s){if(!e.includes("{"))return e;try{const r=a=>{if(!a)return{};try{return JSON.parse(a)}catch{return{}}},n={...s.metadata??{},...r(s.envelope),...r(s.escalation_payload)};return e.replace(/\{([^}]+)\}/g,(a,i)=>Object.prototype.hasOwnProperty.call(n,i)?String(n[i]):`{${i}}`)}catch{return e}}function Ve(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function xt(e){return{escalation:e,metadata:e.metadata??null,envelope:Ve(e.envelope),payload:Ve(e.escalation_payload),resolver:null}}function kr({isRoundsExhausted:e,payloadObj:s,isTerminal:r,resolverPayload:n,onRetryTriage:a,isRetrying:i}){return t.jsxs(t.Fragment,{children:[e&&s&&t.jsx("div",{className:"mt-8",children:t.jsx(Bn,{payload:s,isTerminal:r,resolverPayload:n,onRetryTriage:a,isRetrying:i})}),(s==null?void 0:s.category)==="missing_credential"&&t.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:[t.jsx(Oe,{size:20,className:"text-status-warning mt-0.5 shrink-0"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-text-primary mb-1",children:"Missing Credential"}),t.jsxs("p",{className:"text-xs text-text-secondary mb-3",children:["This workflow requires a ",t.jsx("span",{className:"font-medium capitalize",children:String(s.provider)})," credential to continue. Register one and then resolve this escalation to retry."]}),t.jsxs(yt,{to:"/credentials",className:"btn-primary text-xs inline-flex items-center gap-1.5",children:[t.jsx(Oe,{size:12}),"Go to Credentials"]})]})]})]})}function _r({esc:e,resolverPayload:s,isTerminal:r,claimedByMe:n,activeView:a,metadataFormSchema:i,effectiveSchema:d,json:c,onJsonChange:u,requestTriage:p,onRequestTriageChange:l,triageNotes:o,onTriageNotesChange:x,onResolve:g,onEscalate:N,onClaim:f,submitAttempted:h,isCertified:y,hasAI:k,onOpenHelp:j,onDisabledClick:E,disabledHint:O}){const T=d,q=xt(e);if(r){if(s==null)return null;const I=typeof s=="object"&&s!==null?s:{},S=d??i,P=S!=null&&S.properties?{...Ke(I,S),_form_schema:S}:I;return t.jsx("div",{className:"mt-3",children:t.jsx(us,{value:JSON.stringify(P,null,2),onChange:()=>{},disabled:!0,escalationContext:q,disabledHint:O})})}if(a!=="resolve"||!(e.workflow_type||d))return null;const _=T==null?void 0:T["x-lt-viewport"],M=(_==null?void 0:_.type)==="iframe"&&!!_.src&&g&&N;if(M&&!n)return t.jsxs("button",{onClick:()=>f==null?void 0:f(),disabled:!f,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:[t.jsx(Nn,{className:"w-10 h-10 text-text-tertiary group-hover:text-accent transition-colors",strokeWidth:1}),t.jsx("p",{className:"text-base font-medium text-text-primary group-hover:text-accent transition-colors",children:"Claim to launch the editor"})]});const A=M?xs(_.src,e):"";return t.jsx("div",{className:"mt-3",children:M?t.jsx(is,{src:A,escalation:e,schema:T,onResolve:g,onEscalate:N,submitAttempted:h}):t.jsx(wr,{json:c,onJsonChange:u,requestTriage:p,onRequestTriageChange:l,triageNotes:o,onTriageNotesChange:x,disabled:!n,submitAttempted:h,showTriage:!!y&&!!k,escalationContext:q,onOpenHelp:j,onDisabledClick:E,disabledHint:O})})}function Cr({open:e,assignedUntil:s,onClose:r,onExtend:n,isPending:a}){const i=Ge(),[d,c]=m.useState("30"),[u,p]=m.useState(0),l=d==="custom",o=l?u:parseInt(d),x=m.useCallback(g=>p(g),[]);return t.jsx(Ye,{open:e,onClose:r,title:"Claim Expiring",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("p",{className:"text-sm text-text-secondary",children:["Your claim on this escalation expires in"," ",t.jsx(Ut,{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."]}),t.jsxs("select",{value:d,onChange:g=>{c(g.target.value),p(0)},className:"select w-full text-sm","aria-label":"Extension duration",children:[i.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value)),t.jsx("option",{value:"custom",children:"Other..."})]}),l&&t.jsx(Qe,{onChange:x,autoFocus:!0}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{onClick:r,className:"btn-secondary text-xs",children:"Dismiss"}),t.jsx("button",{onClick:()=>n(o),className:"btn-primary text-xs",disabled:a||!o||o<=0,children:a?"Extending...":"Extend Claim"})]})]})})}const Er=9e4;function Ar(e,s=Er){const[,r]=m.useState(0);if(m.useEffect(()=>{if(!e)return;const a=new Date(e).getTime()-Date.now();if(a<=0)return;const i=()=>r(u=>u+1),d=[],c=a-s;return c>0&&d.push(window.setTimeout(i,c)),d.push(window.setTimeout(i,a)),()=>d.forEach(u=>window.clearTimeout(u))},[e,s]),!e)return{expired:!1,expiringSoon:!1,msRemaining:0};const n=Math.max(0,new Date(e).getTime()-Date.now());return{expired:n<=0,expiringSoon:n>0&&n<=s,msRemaining:n}}const Tr="lt:escalation:draft:";function xe(e){return`${Tr}${e}`}function Rr(e){try{return localStorage.getItem(xe(e))}catch{return null}}function Mr(e,s){try{localStorage.setItem(xe(e),s)}catch{}}function ee(e){try{localStorage.removeItem(xe(e))}catch{}}const Or="x-lt-transition",Ir="x-lt-transition-message",Sr="x-lt-transition-max-wait-seconds",Dr="x-lt-transition-done",$r="Submitted. Preparing your next step…",Lr=30,Pr=5,Wr=300;function Fr(e){const s=typeof e=="number"?e:Number(e);return!Number.isFinite(s)||s<=0?Lr:Math.min(Wr,Math.max(Pr,Math.round(s)))}function Je(e){if(!e||!e[Or])return null;const s=e[Ir];return{message:typeof s=="string"&&s.trim().length>0?s:$r,maxWaitSeconds:Fr(e[Sr])}}function qr(e){const s=e==null?void 0:e[Dr];return typeof s=="string"&&s.trim().length>0?s:null}const Ur="x-lt-submit-on-claim";function Vr(e){return!!(e!=null&&e[Ur])}const Jr="x-lt-submit-guard",Hr="{{count}} related items are still pending";function Br(e){const s=e==null?void 0:e[Jr];if(!s||typeof s!="object"||Array.isArray(s))return;const r=s;if(!(!r.query||typeof r.query!="object"))return r}function zr(e,s){const{user:r}=oe(),n=ls((e==null?void 0:e.query)??{},s??{},r==null?void 0:r.userId),{data:a,isSuccess:i}=ze({role:n.role,status:n.status,facets:n.facets,assigned_to:n.assigned_to,available:n.available,limit:1,enabled:!!e&&n.enabled}),d=!!e&&e.mustBeEmpty!==!1&&n.enabled,c=(a==null?void 0:a.total)??0,u=d&&i&&c===0,p=d&&!u;let l="";if(p)if(c>0){const o=(e==null?void 0:e.message)??Hr;l=ot(o.replace(/\{\{count\}\}/g,String(c)),s??{})}else l="Checking related items…";return{blocked:p,count:c,message:l,confirmedEmpty:u}}function Xr({open:e,message:s}){return e?Xs.createPortal(t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center px-4",children:[t.jsx("div",{className:"absolute inset-0 bg-text-primary/40 backdrop-blur-sm"}),t.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:[t.jsx("div",{className:"flex justify-center mb-4","aria-hidden":"true",children:t.jsx("span",{className:"inline-block w-7 h-7 rounded-full border-2 border-surface-border border-t-accent animate-spin"})}),t.jsx("div",{className:"text-sm text-text-secondary [&_p]:m-0 [&_p+p]:mt-2",children:t.jsx(qt,{content:s})})]})]}),document.body):null}const ps="lt:escalation:panel:open";function Gr(){try{const e=localStorage.getItem(ps);return e===null?!0:e==="true"}catch{return!0}}function At(e){try{localStorage.setItem(ps,String(e))}catch{}}function Tt(e){if(!e)return null;try{return JSON.parse(e)}catch{return e}}function ya(){const{id:e}=Gs();return t.jsx(Qr,{id:e},e)}function Qr({id:e}){var we,ke,_e,Ce,Ee;const{user:s,isSuperAdmin:r,hasRoleType:n}=oe(),a=r||n("admin"),{identity:i}=Ss(),d=Ds(),c=(i==null?void 0:i.actorId)??(s==null?void 0:s.userId),u=le(),p=Ze(),l=He(),{data:o,isLoading:x,refetch:g,isFetching:N}=Be(e);rn(e);const f=$s(),h=Xe(),y=Ls(),k=Ps(),j=Ws(),E=Fs(),[O,T]=m.useState(!1),[q,_]=m.useState(!1),{data:M}=nn(),{data:A}=qs(),{isBuilder:I}=Us(),S=M==null?void 0:M.find(b=>b.workflow_type===(o==null?void 0:o.workflow_type)),P=((we=A==null?void 0:A.telemetry)==null?void 0:we.traceUrl)??null,[W,V]=m.useState("resolve"),[$,J]=m.useState("{}"),[B,z]=m.useState(Gr),[w,C]=m.useState(!1),[v,F]=m.useState(""),[U,tt]=m.useState(!1),[Nt,Q]=m.useState([]),[D,pt]=m.useState(0),[ms,vt]=m.useState(void 0),[et,Vt]=m.useState(null),[fs,pe]=m.useState(!1),me=m.useRef(!1),Mt=m.useRef(null),fe=m.useRef(!1),Ot=m.useRef(null),hs=Ar(o==null?void 0:o.assigned_until),[gs,bs]=m.useState(null);m.useEffect(()=>{if(!(!U||!o))try{const b=JSON.parse($),R=b._form_schema;if(!R){Q([]);return}Q(as(R,b,xt(o)))}catch{}},[$,U,o]);const It=((ke=o==null?void 0:o.metadata)==null?void 0:ke.form_schema)??null,mt=(o==null?void 0:o.form_schema)??(S==null?void 0:S.resolver_schema)??null,H=It??mt,he=Vr(H),st=Hs(H),wt=Br(H),kt=zr(wt,o?xt(o):void 0),St=m.useRef(!1),Dt=m.useRef(null);m.useEffect(()=>{if(St.current)return;const b=It??(mt!=null&&mt.properties?mt:null);if(b!=null&&b.properties){St.current=!0;const R=Tt(o==null?void 0:o.envelope),X=R==null?void 0:R.formDefaults,Z={...(o==null?void 0:o.metadata)??{},...typeof X=="object"&&X!==null?X:{}},ct=Ke(Z,b),at={_form_schema:b};for(const[Te,Ts]of Object.entries(b.properties)){const Re=Ts,Rs=Re.type==="object"?{}:"";at[Te]=ct[Te]??Re.default??Rs}Dt.current=JSON.stringify(at,null,2);const Ae=!((o==null?void 0:o.status)==="resolved"||(o==null?void 0:o.status)==="cancelled")&&(o!=null&&o.id)?Rr(o.id):null,Pt=Ae?Tt(Ae):null;Pt&&typeof Pt=="object"&&!Array.isArray(Pt)?J(JSON.stringify({...Pt,_form_schema:b},null,2)):J(Dt.current)}else H&&(St.current=!0,J(JSON.stringify(H,null,2)))},[H,It,mt,o==null?void 0:o.envelope,o==null?void 0:o.metadata,o==null?void 0:o.id,o==null?void 0:o.status]),m.useEffect(()=>{if(!St.current||Dt.current===null||!(o!=null&&o.id)||o.status!=="pending")return;const b=o.id,R=window.setTimeout(()=>{$===Dt.current?ee(b):Mr(b,$)},400);return()=>window.clearTimeout(R)},[$,o==null?void 0:o.id,o==null?void 0:o.status]),m.useEffect(()=>{if(!et)return;const b=window.setTimeout(async()=>{var X;try{const Z=new URLSearchParams({parent_id:e,assigned_to:c??"",status:"pending",limit:"1"}),ct=await jt(`/escalations?${Z}`),at=(X=ct==null?void 0:ct.escalations)==null?void 0:X[0];if(at!=null&&at.id&&at.parent_id===e){Vt(null),u(`/escalations/detail/${at.id}`);return}}catch{}Vt(null),l.resetQueries({queryKey:["escalations"]}),l.resetQueries({queryKey:["escalationStats"]});const R=et.doneDest;R?R.startsWith("/")?u(R):window.location.assign(R):u(-1)},et.maxWaitSeconds*1e3);return()=>window.clearTimeout(b)},[et,e,c,u,l]),m.useEffect(()=>{var b,R;me.current||(b=p.state)!=null&&b.autoStart&&(!o||o.status!=="pending"||Ft(o)||$!=="{}"&&(me.current=!0,(R=Mt.current)==null||R.call(Mt)))},[o,$,p.state]),m.useEffect(()=>{var b;fe.current||!(wt!=null&&wt.autoResolveWhenEmpty)||!kt.confirmedEmpty||!o||o.status!=="pending"||!Ft(o)||o.assigned_to===c&&$!=="{}"&&(fe.current=!0,(b=Ot.current)==null||b.call(Ot))},[kt.confirmedEmpty,wt,o,$,c]);const js=(o==null?void 0:o.subtype)==="rounds_exhausted";if(x)return t.jsxs("div",{className:"animate-pulse space-y-8",children:[t.jsx("div",{className:"h-8 bg-surface-sunken rounded w-64"}),t.jsx("div",{className:"h-32 bg-surface-sunken rounded w-full"})]});if(!o)return t.jsx("p",{className:"text-sm text-text-secondary",children:"Escalation not found."});const Jt=Ft(o),nt=Jt&&o.assigned_to===c,ge=Jt&&!nt,ft=o.status==="resolved"||o.status==="cancelled",lt=H==null?void 0:H["x-lt-viewport"],Ht=(lt==null?void 0:lt.type)==="iframe"&&!!(lt!=null&&lt.src)&&nt&&!ft,$t=Tt(o.escalation_payload),ht=Tt(o.resolver_payload),Lt=Tt(o.envelope),ys=!!((_e=Lt==null?void 0:Lt.metadata)!=null&&_e.certified),be=Vs(),je=be!==null?be:!!((Ce=A==null?void 0:A.ai)!=null&&Ce.enabled),rt=typeof $t=="object"&&$t!==null&&!Array.isArray($t)?$t:null,Ns=rt==null?void 0:rt._triage,vs=typeof ht=="object"&&ht!==null&&!Array.isArray(ht)?ht:null,Bt=ft?"terminal":nt?"claimed_by_me":ge?"claimed_by_other":"available",ws=Bt==="available"?`${typeof st.claim=="string"?st.claim:"Claim"} this escalation to edit the form`:Bt==="claimed_by_other"?t.jsxs(t.Fragment,{children:["Claimed by ",o.assigned_to?t.jsx(ue,{userId:o.assigned_to}):"another user"]}):o.status==="cancelled"?"This escalation is cancelled":o.status==="resolved"?"This escalation is resolved — the submitted values are shown":null,zt=b=>{f.mutate({id:e,durationMinutes:b})},_t=()=>{l.resetQueries({queryKey:["escalations"]}),l.resetQueries({queryKey:["escalationStats"]}),u(-1)},ks=()=>{const b=qr(H);return b&&ot(b,xt(o))||null},_s=b=>{l.resetQueries({queryKey:["escalations"]}),l.resetQueries({queryKey:["escalationStats"]}),b.startsWith("/")?u(b):window.location.assign(b)},Ct=async b=>{try{await h.mutateAsync({id:e,resolverPayload:b})}catch(Z){if(Z instanceof Js&&_n(Z.body)){tt(!0),Q(Z.body.violations),vt(G.ERRORS);return}throw Z}ee(e);const R=Je(H),X=ks();if(R){Vt({...R,doneDest:X});return}if(X){_s(X);return}_t()},ye=async b=>{try{await f.mutateAsync({id:e,durationMinutes:b})}catch{return}if(kt.blocked)return;const R=re($,xt(o));if(!R.parseError){if(R.errors.length>0){tt(!0),Q(R.errors),z(!0),At(!0),vt(G.ERRORS);return}await Ct(R.payload)}};Mt.current=async()=>{var R;const b=(R=p.state)==null?void 0:R.durationMinutes;pe(!0),await ye(typeof b=="number"&&b>0?b:30),pe(!1)},Ot.current=()=>{const b=re($,xt(o));b.parseError||b.errors.length>0||Ct(b.payload)};const Ne=async b=>{b&&(await y.mutateAsync({id:e,targetRole:b}),_t())},Cs=async()=>{nt||await f.mutateAsync({id:e,durationMinutes:30});const b=(rt==null?void 0:rt.diagnosis)||o.description||"";await h.mutateAsync({id:e,resolverPayload:{_lt:{needsTriage:!0},notes:b}}),_t()},ve=async()=>{await f.mutateAsync({id:e,durationMinutes:0}),_t()},Es=async()=>{await k.mutateAsync(e),ee(e),T(!1),_t()},As=t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ys,{onRefresh:()=>g(),isFetching:N,apiPath:`/escalations/${o.id}`,standalone:!0}),t.jsx("button",{onClick:()=>z(b=>(At(!b),!b)),className:"ml-2 text-accent/60 hover:text-accent transition-colors",title:B?"Hide side panel":"Show side panel",children:B?t.jsx(Ie,{className:"w-5 h-5",strokeWidth:1.5}):t.jsx(Se,{className:"w-5 h-5",strokeWidth:1.5})})]});return t.jsxs("div",{className:"flex-1 min-h-0 min-w-0 flex items-stretch -mt-8 -mr-page-x -mb-16",children:[t.jsxs("div",{className:"flex-1 min-w-0 flex flex-col min-h-0",children:[Ht?t.jsxs("div",{className:"relative flex-1 min-h-0 -ml-page-x",children:[t.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:ve,disabled:f.isPending,label:st.release??"Release",hoverClass:"hover:text-accent",icon:t.jsx(vn,{className:"w-4 h-4",strokeWidth:1.5})},...st.cancel===!1?[]:[{onClick:()=>T(!0),disabled:!1,label:st.cancel??"Cancel",hoverClass:"hover:text-status-error",icon:t.jsx(wn,{className:"w-4 h-4",strokeWidth:1.5})}],{onClick:()=>z(b=>(At(!b),!b)),disabled:!1,label:B?"Hide panel":"Show panel",hoverClass:"hover:text-accent",icon:B?t.jsx(Ie,{className:"w-4 h-4",strokeWidth:1.5}):t.jsx(Se,{className:"w-4 h-4",strokeWidth:1.5})}].map(({onClick:b,disabled:R,label:X,hoverClass:Z,icon:ct})=>t.jsxs("div",{className:"relative group/tip",children:[t.jsx("button",{onClick:b,disabled:R,className:`text-text-tertiary ${Z} transition-colors disabled:opacity-40 disabled:cursor-default p-1.5 rounded-md`,children:ct}),t.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:X})]},X))}),t.jsx(is,{src:xs(lt.src,o),escalation:o,schema:H,onResolve:Ct,onEscalate:Ne,submitAttempted:U,fill:!0})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"shrink-0 pt-8 pr-page-x",children:t.jsx(Qs,{title:o.description||"Escalation",actions:As})}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto pr-page-x",children:[t.jsx(kr,{isRoundsExhausted:js,payloadObj:rt,isTerminal:ft,resolverPayload:ht,onRetryTriage:Cs,isRetrying:f.isPending||h.isPending}),t.jsx(_r,{esc:o,resolverPayload:ht,isTerminal:ft,claimedByMe:nt,activeView:W,metadataFormSchema:It,effectiveSchema:H,json:$,onJsonChange:J,requestTriage:w,onRequestTriageChange:C,triageNotes:v,onTriageNotesChange:F,onResolve:Ct,onEscalate:Ne,onClaim:()=>zt(30),submitAttempted:U,isCertified:ys,hasAI:je,onOpenHelp:()=>{z(!0),At(!0),vt(G.HELP)},onDisabledClick:()=>pt(b=>b+1),disabledHint:ws}),t.jsx("div",{className:"h-10"})]})]}),!Ht&&t.jsx(Hn,{escalationContext:xt(o),mode:Bt,activeView:W,onActiveViewChange:V,onClaim:he?ye:zt,claimPending:f.isPending||he&&h.isPending,claimNudge:D,workflowType:o.workflow_type,json:$,onResolve:Ct,resolvePending:h.isPending||h.isSuccess,resolveError:h.error,requestTriage:w,triageNotes:v,onRelease:ve,releasePending:f.isPending,onCancel:()=>T(!0),assignedTo:o.assigned_to,assignedUntil:o.assigned_until,actingName:i&&nt?i.displayName:null,badgePrompt:d&&!i&&ge,onSubmitAttempt:()=>tt(!0),onValidationErrors:b=>{Q(b),z(!0),At(!0),vt(G.ERRORS)},labels:st,submitBlocked:kt.blocked,submitBlockedMessage:kt.message,canManage:a,onReassign:()=>_(!0),onUnassign:()=>E.mutate({ids:[e]}),unassignPending:E.isPending})]}),t.jsx($n,{esc:o,schema:H,envelope:Lt,payload:rt,resolver:vs,triage:Ns??null,hasAI:je,claimed:Jt,claimedByMe:nt,isTerminal:ft,isBuilder:I,traceUrl:P,open:B,noGutter:Ht,formErrors:Nt,activePanel:ms,onPanelChange:vt}),t.jsx(Bs,{open:q,onClose:()=>_(!1),selectedCount:1,selectedRoles:o?[o.role]:[],onSubmit:(b,R)=>j.mutate({ids:[e],targetUserId:b,durationMinutes:R,reassign:!0},{onSuccess:()=>_(!1)}),isPending:j.isPending}),t.jsx(zs,{open:O,onClose:()=>T(!1),onConfirm:Es,isPending:k.isPending,error:k.error,actionLabel:typeof st.cancel=="string"?st.cancel:void 0}),t.jsx(Cn,{escalationId:e}),t.jsx(Xr,{open:!!et||fs,message:(et==null?void 0:et.message)??((Ee=Je(H))==null?void 0:Ee.message)??"Starting…"}),nt&&!ft&&o.assigned_until&&t.jsx(Cr,{open:hs.expiringSoon&&o.assigned_until!==gs,assignedUntil:o.assigned_until,onClose:()=>bs(o.assigned_until??null),onExtend:zt,isPending:f.isPending})]})}export{ya as EscalationDetailPage};
3
- //# sourceMappingURL=index-Ds5rGe-i.js.map