@hotmeshio/long-tail 0.31.1 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (320) hide show
  1. package/build/api/escalations/create.js +17 -6
  2. package/build/api/escalations/files.d.ts +18 -0
  3. package/build/api/escalations/files.js +73 -0
  4. package/build/api/escalations/index.d.ts +1 -0
  5. package/build/api/escalations/index.js +4 -2
  6. package/build/api/escalations/metadata.js +5 -4
  7. package/build/api/escalations/resolve.js +6 -4
  8. package/build/bin/ltc.js +4 -2
  9. package/build/index.d.ts +2 -0
  10. package/build/index.js +13 -2
  11. package/build/lib/cli/commands/escalations.d.ts +2 -0
  12. package/build/lib/cli/commands/escalations.js +12 -4
  13. package/build/lib/storage/s3.js +1 -0
  14. package/build/modules/config.d.ts +9 -0
  15. package/build/modules/config.js +9 -0
  16. package/build/routes/escalations/single.js +11 -0
  17. package/build/sdk/index.d.ts +4 -0
  18. package/build/sdk/index.js +2 -0
  19. package/build/services/escalation/aggregate-resolved-sql.d.ts +19 -0
  20. package/build/services/escalation/aggregate-resolved-sql.js +57 -0
  21. package/build/services/escalation/aggregate-sql.d.ts +6 -1
  22. package/build/services/escalation/aggregate-sql.js +33 -12
  23. package/build/services/escalation/aggregate-validate.d.ts +5 -2
  24. package/build/services/escalation/aggregate-validate.js +7 -4
  25. package/build/services/escalation/aggregates.js +5 -3
  26. package/build/services/escalation/crud.js +3 -0
  27. package/build/services/escalation/file-links.d.ts +39 -0
  28. package/build/services/escalation/file-links.js +118 -0
  29. package/build/services/escalation/resolver-validation.d.ts +33 -0
  30. package/build/services/escalation/resolver-validation.js +22 -6
  31. package/build/services/orchestrator/condition.d.ts +20 -4
  32. package/build/services/orchestrator/condition.js +27 -8
  33. package/build/shared/form-validation/display-only-widgets.d.ts +3 -2
  34. package/build/shared/form-validation/display-only-widgets.js +3 -2
  35. package/build/shared/form-validation/index.d.ts +2 -0
  36. package/build/shared/form-validation/index.js +2 -0
  37. package/build/shared/form-validation/x-lt-confidence-facets.d.ts +27 -0
  38. package/build/shared/form-validation/x-lt-confidence-facets.js +60 -0
  39. package/build/shared/form-validation/x-lt-confidence.d.ts +57 -0
  40. package/build/shared/form-validation/x-lt-confidence.js +177 -0
  41. package/build/shared/form-validation/x-lt-help.d.ts +1 -1
  42. package/build/shared/form-validation/x-lt-help.js +1 -1
  43. package/build/system/mcp-servers/admin/escalations.js +4 -2
  44. package/build/system/mcp-servers/admin/labels-schemas.d.ts +4 -4
  45. package/build/system/mcp-servers/admin/schemas.d.ts +111 -70
  46. package/build/system/mcp-servers/admin/schemas.js +8 -3
  47. package/build/system/mcp-servers/human-queue-files.d.ts +8 -0
  48. package/build/system/mcp-servers/human-queue-files.js +32 -0
  49. package/build/system/mcp-servers/human-queue-schemas.d.ts +7 -0
  50. package/build/system/mcp-servers/human-queue-schemas.js +4 -1
  51. package/build/system/mcp-servers/human-queue.d.ts +1 -0
  52. package/build/system/mcp-servers/human-queue.js +23 -16
  53. package/build/system/seed/tool-manifests-admin.js +1 -1
  54. package/build/system/seed/tool-manifests-escalation.js +13 -0
  55. package/build/tsconfig.tsbuildinfo +1 -1
  56. package/build/types/analytics.d.ts +14 -3
  57. package/build/types/analytics.js +3 -1
  58. package/build/types/escalation.d.ts +34 -0
  59. package/build/types/escalation.js +72 -1
  60. package/build/types/index.d.ts +4 -4
  61. package/build/types/index.js +5 -1
  62. package/dashboard/dist/assets/{AdminDashboard-BafKaq50.js → AdminDashboard-C25co77C.js} +2 -2
  63. package/dashboard/dist/assets/{AdminDashboard-BafKaq50.js.map → AdminDashboard-C25co77C.js.map} +1 -1
  64. package/dashboard/dist/assets/{AgentConfigPage-CFHf31DT.js → AgentConfigPage-CsCpI15j.js} +5 -5
  65. package/dashboard/dist/assets/{AgentConfigPage-CFHf31DT.js.map → AgentConfigPage-CsCpI15j.js.map} +1 -1
  66. package/dashboard/dist/assets/{AgentDetailPage-CEvz5rJr.js → AgentDetailPage-ByaepsB5.js} +3 -3
  67. package/dashboard/dist/assets/{AgentDetailPage-CEvz5rJr.js.map → AgentDetailPage-ByaepsB5.js.map} +1 -1
  68. package/dashboard/dist/assets/{AgentsPage-DjQaio0O.js → AgentsPage-ByHU42SO.js} +2 -2
  69. package/dashboard/dist/assets/{AgentsPage-DjQaio0O.js.map → AgentsPage-ByHU42SO.js.map} +1 -1
  70. package/dashboard/dist/assets/{AvailableEscalationsPage-UB03VTJx.js → AvailableEscalationsPage--o6qcz7-.js} +2 -2
  71. package/dashboard/dist/assets/{AvailableEscalationsPage-UB03VTJx.js.map → AvailableEscalationsPage--o6qcz7-.js.map} +1 -1
  72. package/dashboard/dist/assets/{BotPicker-C7MNWOF7.js → BotPicker-B3y3H3fs.js} +2 -2
  73. package/dashboard/dist/assets/{BotPicker-C7MNWOF7.js.map → BotPicker-B3y3H3fs.js.map} +1 -1
  74. package/dashboard/dist/assets/{BulkAssignModal-h5fX-_cV.js → BulkAssignModal-DMNIkIn6.js} +2 -2
  75. package/dashboard/dist/assets/{BulkAssignModal-h5fX-_cV.js.map → BulkAssignModal-DMNIkIn6.js.map} +1 -1
  76. package/dashboard/dist/assets/{CapabilitiesPage-BIzDl-ZT.js → CapabilitiesPage-BekfKHlk.js} +2 -2
  77. package/dashboard/dist/assets/{CapabilitiesPage-BIzDl-ZT.js.map → CapabilitiesPage-BekfKHlk.js.map} +1 -1
  78. package/dashboard/dist/assets/{CollapsibleSection-B5TivtEg.js → CollapsibleSection-BAteHgBG.js} +2 -2
  79. package/dashboard/dist/assets/{CollapsibleSection-B5TivtEg.js.map → CollapsibleSection-BAteHgBG.js.map} +1 -1
  80. package/dashboard/dist/assets/{ConfirmDeleteModal-CB4nKePb.js → ConfirmDeleteModal-BNY287W9.js} +2 -2
  81. package/dashboard/dist/assets/{ConfirmDeleteModal-CB4nKePb.js.map → ConfirmDeleteModal-BNY287W9.js.map} +1 -1
  82. package/dashboard/dist/assets/{ConnectedAppsPage-B3S5gVWw.js → ConnectedAppsPage-LLiiH3da.js} +2 -2
  83. package/dashboard/dist/assets/{ConnectedAppsPage-B3S5gVWw.js.map → ConnectedAppsPage-LLiiH3da.js.map} +1 -1
  84. package/dashboard/dist/assets/{CountdownTimer-BHVIq3kA.js → CountdownTimer-DBLURjxh.js} +2 -2
  85. package/dashboard/dist/assets/{CountdownTimer-BHVIq3kA.js.map → CountdownTimer-DBLURjxh.js.map} +1 -1
  86. package/dashboard/dist/assets/{CredentialConfirmModal-w0AGmCIe.js → CredentialConfirmModal-BqpY3yen.js} +2 -2
  87. package/dashboard/dist/assets/{CredentialConfirmModal-w0AGmCIe.js.map → CredentialConfirmModal-BqpY3yen.js.map} +1 -1
  88. package/dashboard/dist/assets/{CredentialsPage-BtCGBJrT.js → CredentialsPage-CW3_dbm2.js} +2 -2
  89. package/dashboard/dist/assets/{CredentialsPage-BtCGBJrT.js.map → CredentialsPage-CW3_dbm2.js.map} +1 -1
  90. package/dashboard/dist/assets/{CronLabel-BG1rZK-5.js → CronLabel-CR6DiZZr.js} +2 -2
  91. package/dashboard/dist/assets/{CronLabel-BG1rZK-5.js.map → CronLabel-CR6DiZZr.js.map} +1 -1
  92. package/dashboard/dist/assets/{DataTable-FjFhx0SE.js → DataTable-C-IlbLhY.js} +2 -2
  93. package/dashboard/dist/assets/{DataTable-FjFhx0SE.js.map → DataTable-C-IlbLhY.js.map} +1 -1
  94. package/dashboard/dist/assets/{DropZone-D8ZVdEb5.js → DropZone-CHmz59w4.js} +2 -2
  95. package/dashboard/dist/assets/{DropZone-D8ZVdEb5.js.map → DropZone-CHmz59w4.js.map} +1 -1
  96. package/dashboard/dist/assets/{ElapsedCell-l4m8Yvfv.js → ElapsedCell-CEapQvgU.js} +2 -2
  97. package/dashboard/dist/assets/{ElapsedCell-l4m8Yvfv.js.map → ElapsedCell-CEapQvgU.js.map} +1 -1
  98. package/dashboard/dist/assets/{EntityTimelinePanel-BOHlIaxF.js → EntityTimelinePanel-DqD_BpJM.js} +2 -2
  99. package/dashboard/dist/assets/{EntityTimelinePanel-BOHlIaxF.js.map → EntityTimelinePanel-DqD_BpJM.js.map} +1 -1
  100. package/dashboard/dist/assets/{EscalationListSchemaPage-BotlwlX3.js → EscalationListSchemaPage-DDKcrVbb.js} +3 -3
  101. package/dashboard/dist/assets/{EscalationListSchemaPage-BotlwlX3.js.map → EscalationListSchemaPage-DDKcrVbb.js.map} +1 -1
  102. package/dashboard/dist/assets/{EscalationSchemaPage-CfZSVOSD.js → EscalationSchemaPage-BZHZfJiQ.js} +3 -3
  103. package/dashboard/dist/assets/{EscalationSchemaPage-CfZSVOSD.js.map → EscalationSchemaPage-BZHZfJiQ.js.map} +1 -1
  104. package/dashboard/dist/assets/{EscalationTimeline-CCKpuRBU.js → EscalationTimeline-Dv0XUgQX.js} +2 -2
  105. package/dashboard/dist/assets/{EscalationTimeline-CCKpuRBU.js.map → EscalationTimeline-Dv0XUgQX.js.map} +1 -1
  106. package/dashboard/dist/assets/{EscalationTitleSelect-cpTzPHiW.js → EscalationTitleSelect-BN7D52wT.js} +2 -2
  107. package/dashboard/dist/assets/{EscalationTitleSelect-cpTzPHiW.js.map → EscalationTitleSelect-BN7D52wT.js.map} +1 -1
  108. package/dashboard/dist/assets/{EscalationsOverview-DS-nK0qV.js → EscalationsOverview-DE6EPkhT.js} +2 -2
  109. package/dashboard/dist/assets/{EscalationsOverview-DS-nK0qV.js.map → EscalationsOverview-DE6EPkhT.js.map} +1 -1
  110. package/dashboard/dist/assets/{EventTable-UfebhJf0.js → EventTable-CiV62txY.js} +2 -2
  111. package/dashboard/dist/assets/{EventTable-UfebhJf0.js.map → EventTable-CiV62txY.js.map} +1 -1
  112. package/dashboard/dist/assets/{FilterBar-newA5l-X.js → FilterBar-WyNQPyQ1.js} +2 -2
  113. package/dashboard/dist/assets/{FilterBar-newA5l-X.js.map → FilterBar-WyNQPyQ1.js.map} +1 -1
  114. package/dashboard/dist/assets/{GraphInvokePage-6SCDyQcK.js → GraphInvokePage--gn48yUD.js} +2 -2
  115. package/dashboard/dist/assets/{GraphInvokePage-6SCDyQcK.js.map → GraphInvokePage--gn48yUD.js.map} +1 -1
  116. package/dashboard/dist/assets/{HomePage-BEc-XdKj.js → HomePage-IR_jgBE8.js} +2 -2
  117. package/dashboard/dist/assets/{HomePage-BEc-XdKj.js.map → HomePage-IR_jgBE8.js.map} +1 -1
  118. package/dashboard/dist/assets/{LabelJobsPage-BO50zXT5.js → LabelJobsPage-C8LSts4O.js} +2 -2
  119. package/dashboard/dist/assets/{LabelJobsPage-BO50zXT5.js.map → LabelJobsPage-C8LSts4O.js.map} +1 -1
  120. package/dashboard/dist/assets/{LinePage-NYxJQ-ex.js → LinePage-CS7uUv00.js} +2 -2
  121. package/dashboard/dist/assets/{LinePage-NYxJQ-ex.js.map → LinePage-CS7uUv00.js.map} +1 -1
  122. package/dashboard/dist/assets/{LinesPage-RbWTaQRh.js → LinesPage-CJprjG39.js} +3 -3
  123. package/dashboard/dist/assets/{LinesPage-RbWTaQRh.js.map → LinesPage-CJprjG39.js.map} +1 -1
  124. package/dashboard/dist/assets/{ListToolbar-B-E9-toh.js → ListToolbar-YP3uwvXC.js} +2 -2
  125. package/dashboard/dist/assets/{ListToolbar-B-E9-toh.js.map → ListToolbar-YP3uwvXC.js.map} +1 -1
  126. package/dashboard/dist/assets/{McpOverview-Shcf9QhZ.js → McpOverview-Ce-m2JON.js} +2 -2
  127. package/dashboard/dist/assets/{McpOverview-Shcf9QhZ.js.map → McpOverview-Ce-m2JON.js.map} +1 -1
  128. package/dashboard/dist/assets/{McpQueryDetailPage-D8kmjy2v.js → McpQueryDetailPage-CtnUqO1v.js} +2 -2
  129. package/dashboard/dist/assets/{McpQueryDetailPage-D8kmjy2v.js.map → McpQueryDetailPage-CtnUqO1v.js.map} +1 -1
  130. package/dashboard/dist/assets/{McpQueryPage-ck-o5m8A.js → McpQueryPage-C-lqUPlg.js} +2 -2
  131. package/dashboard/dist/assets/{McpQueryPage-ck-o5m8A.js.map → McpQueryPage-C-lqUPlg.js.map} +1 -1
  132. package/dashboard/dist/assets/{McpRunDetailPage-BJKkM9-3.js → McpRunDetailPage-MnIe0hwz.js} +2 -2
  133. package/dashboard/dist/assets/{McpRunDetailPage-BJKkM9-3.js.map → McpRunDetailPage-MnIe0hwz.js.map} +1 -1
  134. package/dashboard/dist/assets/{McpRunsPage-DqhHfD5G.js → McpRunsPage-CpYLXVPF.js} +2 -2
  135. package/dashboard/dist/assets/{McpRunsPage-DqhHfD5G.js.map → McpRunsPage-CpYLXVPF.js.map} +1 -1
  136. package/dashboard/dist/assets/{NamespacePill--uIaGtrN.js → NamespacePill-DilSgLyE.js} +2 -2
  137. package/dashboard/dist/assets/{NamespacePill--uIaGtrN.js.map → NamespacePill-DilSgLyE.js.map} +1 -1
  138. package/dashboard/dist/assets/{OperationsPage-D6B9Vv__.js → OperationsPage-xe6bAwaq.js} +2 -2
  139. package/dashboard/dist/assets/{OperationsPage-D6B9Vv__.js.map → OperationsPage-xe6bAwaq.js.map} +1 -1
  140. package/dashboard/dist/assets/{OperatorDashboard-CIH1cxjQ.js → OperatorDashboard-Cm9_C0EP.js} +2 -2
  141. package/dashboard/dist/assets/{OperatorDashboard-CIH1cxjQ.js.map → OperatorDashboard-Cm9_C0EP.js.map} +1 -1
  142. package/dashboard/dist/assets/{PageHeader-DClJ33fV.js → PageHeader-B7SOvLT8.js} +2 -2
  143. package/dashboard/dist/assets/{PageHeader-DClJ33fV.js.map → PageHeader-B7SOvLT8.js.map} +1 -1
  144. package/dashboard/dist/assets/{PageHeaderWithStats-C-TrbKQL.js → PageHeaderWithStats-DWKap7gs.js} +2 -2
  145. package/dashboard/dist/assets/{PageHeaderWithStats-C-TrbKQL.js.map → PageHeaderWithStats-DWKap7gs.js.map} +1 -1
  146. package/dashboard/dist/assets/{PersonaDetailPage-DjvfyIph.js → PersonaDetailPage-CvstNkh3.js} +2 -2
  147. package/dashboard/dist/assets/{PersonaDetailPage-DjvfyIph.js.map → PersonaDetailPage-CvstNkh3.js.map} +1 -1
  148. package/dashboard/dist/assets/{PersonasPage-D7ryA8Vc.js → PersonasPage-ba1KeInW.js} +2 -2
  149. package/dashboard/dist/assets/{PersonasPage-D7ryA8Vc.js.map → PersonasPage-ba1KeInW.js.map} +1 -1
  150. package/dashboard/dist/assets/{PortalPage-D3ybr0mo.js → PortalPage-GDgG88TM.js} +2 -2
  151. package/dashboard/dist/assets/{PortalPage-D3ybr0mo.js.map → PortalPage-GDgG88TM.js.map} +1 -1
  152. package/dashboard/dist/assets/{PrintLabelsPanel-D0HF5x8b.js → PrintLabelsPanel-BkUN00Qd.js} +2 -2
  153. package/dashboard/dist/assets/{PrintLabelsPanel-D0HF5x8b.js.map → PrintLabelsPanel-BkUN00Qd.js.map} +1 -1
  154. package/dashboard/dist/assets/{ProcessDetailPage-0xS9EdHe.js → ProcessDetailPage-BKu9_wWv.js} +2 -2
  155. package/dashboard/dist/assets/{ProcessDetailPage-0xS9EdHe.js.map → ProcessDetailPage-BKu9_wWv.js.map} +1 -1
  156. package/dashboard/dist/assets/{ProcessesListPage-93SMj1Fd.js → ProcessesListPage-BfJYTU_v.js} +2 -2
  157. package/dashboard/dist/assets/{ProcessesListPage-93SMj1Fd.js.map → ProcessesListPage-BfJYTU_v.js.map} +1 -1
  158. package/dashboard/dist/assets/ResolverForm-DZmY6wJV.js +8 -0
  159. package/dashboard/dist/assets/ResolverForm-DZmY6wJV.js.map +1 -0
  160. package/dashboard/dist/assets/{RoleDetailPage-DlUOJWSB.js → RoleDetailPage-vGeth3ve.js} +3 -3
  161. package/dashboard/dist/assets/{RoleDetailPage-DlUOJWSB.js.map → RoleDetailPage-vGeth3ve.js.map} +1 -1
  162. package/dashboard/dist/assets/{RolePill-BjD1Qw5y.js → RolePill-KhT-Yehm.js} +2 -2
  163. package/dashboard/dist/assets/{RolePill-BjD1Qw5y.js.map → RolePill-KhT-Yehm.js.map} +1 -1
  164. package/dashboard/dist/assets/{RolesPage-DqhHSvaw.js → RolesPage-CwxHOkqF.js} +2 -2
  165. package/dashboard/dist/assets/{RolesPage-DqhHSvaw.js.map → RolesPage-CwxHOkqF.js.map} +1 -1
  166. package/dashboard/dist/assets/{RosterWidget-BrIq61HR.js → RosterWidget-DRVj9xyk.js} +2 -2
  167. package/dashboard/dist/assets/{RosterWidget-BrIq61HR.js.map → RosterWidget-DRVj9xyk.js.map} +1 -1
  168. package/dashboard/dist/assets/{RunAsSelector-D6zQrCNr.js → RunAsSelector-DvPX3XmA.js} +2 -2
  169. package/dashboard/dist/assets/{RunAsSelector-D6zQrCNr.js.map → RunAsSelector-DvPX3XmA.js.map} +1 -1
  170. package/dashboard/dist/assets/{ScanCodesPage-B2S9DR2f.js → ScanCodesPage-Cptbe7h8.js} +2 -2
  171. package/dashboard/dist/assets/{ScanCodesPage-B2S9DR2f.js.map → ScanCodesPage-Cptbe7h8.js.map} +1 -1
  172. package/dashboard/dist/assets/{ScanSchemeDetailPage-gpxKN-pL.js → ScanSchemeDetailPage-DquNJ7Or.js} +4 -4
  173. package/dashboard/dist/assets/{ScanSchemeDetailPage-gpxKN-pL.js.map → ScanSchemeDetailPage-DquNJ7Or.js.map} +1 -1
  174. package/dashboard/dist/assets/{ScanStationPage-B-UTgXsG.js → ScanStationPage-DaRfGGa8.js} +2 -2
  175. package/dashboard/dist/assets/{ScanStationPage-B-UTgXsG.js.map → ScanStationPage-DaRfGGa8.js.map} +1 -1
  176. package/dashboard/dist/assets/{SchemeMatchFields-BK24aa7K.js → SchemeMatchFields-w-pffi98.js} +2 -2
  177. package/dashboard/dist/assets/{SchemeMatchFields-BK24aa7K.js.map → SchemeMatchFields-w-pffi98.js.map} +1 -1
  178. package/dashboard/dist/assets/{ScopeBadge-ofLQ6HW-.js → ScopeBadge-HeuiMJhW.js} +2 -2
  179. package/dashboard/dist/assets/{ScopeBadge-ofLQ6HW-.js.map → ScopeBadge-HeuiMJhW.js.map} +1 -1
  180. package/dashboard/dist/assets/{StickyPagination-CgVv7vc_.js → StickyPagination-D6fDHCcJ.js} +2 -2
  181. package/dashboard/dist/assets/{StickyPagination-CgVv7vc_.js.map → StickyPagination-D6fDHCcJ.js.map} +1 -1
  182. package/dashboard/dist/assets/{StreamMessageDetail-B9sxDVw4.js → StreamMessageDetail-BmYVQrzl.js} +2 -2
  183. package/dashboard/dist/assets/{StreamMessageDetail-B9sxDVw4.js.map → StreamMessageDetail-BmYVQrzl.js.map} +1 -1
  184. package/dashboard/dist/assets/{SwimlaneTimeline-DQc0CYSL.js → SwimlaneTimeline-KCqA-PeL.js} +2 -2
  185. package/dashboard/dist/assets/{SwimlaneTimeline-DQc0CYSL.js.map → SwimlaneTimeline-KCqA-PeL.js.map} +1 -1
  186. package/dashboard/dist/assets/{TagInput-47qVYzke.js → TagInput-CZBAu1Hy.js} +2 -2
  187. package/dashboard/dist/assets/{TagInput-47qVYzke.js.map → TagInput-CZBAu1Hy.js.map} +1 -1
  188. package/dashboard/dist/assets/{TaskDetailPage-D6VOsA1f.js → TaskDetailPage-WtVv2z7T.js} +2 -2
  189. package/dashboard/dist/assets/{TaskDetailPage-D6VOsA1f.js.map → TaskDetailPage-WtVv2z7T.js.map} +1 -1
  190. package/dashboard/dist/assets/{TaskQueuePill-C5KmdXAl.js → TaskQueuePill-DWGn3CWx.js} +2 -2
  191. package/dashboard/dist/assets/{TaskQueuePill-C5KmdXAl.js.map → TaskQueuePill-DWGn3CWx.js.map} +1 -1
  192. package/dashboard/dist/assets/{TasksListPage-DG8hvO8G.js → TasksListPage-DMYQNDIw.js} +2 -2
  193. package/dashboard/dist/assets/{TasksListPage-DG8hvO8G.js.map → TasksListPage-DMYQNDIw.js.map} +1 -1
  194. package/dashboard/dist/assets/{TimeAgo-CL02EhFi.js → TimeAgo-BkY4lahi.js} +2 -2
  195. package/dashboard/dist/assets/{TimeAgo-CL02EhFi.js.map → TimeAgo-BkY4lahi.js.map} +1 -1
  196. package/dashboard/dist/assets/{TimestampCell-BE7oKVJg.js → TimestampCell-BBPb9TI2.js} +2 -2
  197. package/dashboard/dist/assets/{TimestampCell-BE7oKVJg.js.map → TimestampCell-BBPb9TI2.js.map} +1 -1
  198. package/dashboard/dist/assets/{ToolPill-Cp9Drk1s.js → ToolPill-B2aRk0o1.js} +2 -2
  199. package/dashboard/dist/assets/{ToolPill-Cp9Drk1s.js.map → ToolPill-B2aRk0o1.js.map} +1 -1
  200. package/dashboard/dist/assets/{ToolTestPanel-CRecLh6S.js → ToolTestPanel-CNMbmymK.js} +2 -2
  201. package/dashboard/dist/assets/{ToolTestPanel-CRecLh6S.js.map → ToolTestPanel-CNMbmymK.js.map} +1 -1
  202. package/dashboard/dist/assets/{TopicDetailPage-QzkinTfN.js → TopicDetailPage-CodBRylU.js} +2 -2
  203. package/dashboard/dist/assets/{TopicDetailPage-QzkinTfN.js.map → TopicDetailPage-CodBRylU.js.map} +1 -1
  204. package/dashboard/dist/assets/TopicsPage-BtD8jTU7.js +2 -0
  205. package/dashboard/dist/assets/{TopicsPage-D8dW6J65.js.map → TopicsPage-BtD8jTU7.js.map} +1 -1
  206. package/dashboard/dist/assets/{UserName-Dw3R_zrl.js → UserName-D6y9AnuY.js} +2 -2
  207. package/dashboard/dist/assets/{UserName-Dw3R_zrl.js.map → UserName-D6y9AnuY.js.map} +1 -1
  208. package/dashboard/dist/assets/{WorkflowExecutionPage-BTocv8or.js → WorkflowExecutionPage-BeffqV13.js} +2 -2
  209. package/dashboard/dist/assets/{WorkflowExecutionPage-BTocv8or.js.map → WorkflowExecutionPage-BeffqV13.js.map} +1 -1
  210. package/dashboard/dist/assets/{WorkflowPill-BiLYq__w.js → WorkflowPill-BNm3R4pP.js} +2 -2
  211. package/dashboard/dist/assets/{WorkflowPill-BiLYq__w.js.map → WorkflowPill-BNm3R4pP.js.map} +1 -1
  212. package/dashboard/dist/assets/{WorkflowsDashboard-CIPEt3et.js → WorkflowsDashboard-m4Co5diK.js} +2 -2
  213. package/dashboard/dist/assets/{WorkflowsDashboard-CIPEt3et.js.map → WorkflowsDashboard-m4Co5diK.js.map} +1 -1
  214. package/dashboard/dist/assets/{WorkflowsOverview-Bj4MJIE-.js → WorkflowsOverview-DNoI9qY8.js} +2 -2
  215. package/dashboard/dist/assets/{WorkflowsOverview-Bj4MJIE-.js.map → WorkflowsOverview-DNoI9qY8.js.map} +1 -1
  216. package/dashboard/dist/assets/{YamlWorkflowDetailPage-DMEk5k9-.js → YamlWorkflowDetailPage-8Vpc4Oxy.js} +2 -2
  217. package/dashboard/dist/assets/{YamlWorkflowDetailPage-DMEk5k9-.js.map → YamlWorkflowDetailPage-8Vpc4Oxy.js.map} +1 -1
  218. package/dashboard/dist/assets/{YamlWorkflowsPage-F2yyyoiB.js → YamlWorkflowsPage-D1JNwDSg.js} +2 -2
  219. package/dashboard/dist/assets/{YamlWorkflowsPage-F2yyyoiB.js.map → YamlWorkflowsPage-D1JNwDSg.js.map} +1 -1
  220. package/dashboard/dist/assets/{agents-mSgxEPpI.js → agents-LTHUsfv3.js} +2 -2
  221. package/dashboard/dist/assets/{agents-mSgxEPpI.js.map → agents-LTHUsfv3.js.map} +1 -1
  222. package/dashboard/dist/assets/{bots-p4Hp0CV6.js → bots-CQxehfBo.js} +2 -2
  223. package/dashboard/dist/assets/{bots-p4Hp0CV6.js.map → bots-CQxehfBo.js.map} +1 -1
  224. package/dashboard/dist/assets/{capabilities-D_-I_SXR.js → capabilities-DECTnJrK.js} +2 -2
  225. package/dashboard/dist/assets/{capabilities-D_-I_SXR.js.map → capabilities-DECTnJrK.js.map} +1 -1
  226. package/dashboard/dist/assets/{controlplane-DjdoQnRU.js → controlplane-Dx20db5g.js} +2 -2
  227. package/dashboard/dist/assets/{controlplane-DjdoQnRU.js.map → controlplane-Dx20db5g.js.map} +1 -1
  228. package/dashboard/dist/assets/{escalation-columns-R_IEVQjQ.js → escalation-columns-CVFGUB79.js} +2 -2
  229. package/dashboard/dist/assets/{escalation-columns-R_IEVQjQ.js.map → escalation-columns-CVFGUB79.js.map} +1 -1
  230. package/dashboard/dist/assets/escalation-items-Bj7bkwWy.js +2 -0
  231. package/dashboard/dist/assets/escalation-items-Bj7bkwWy.js.map +1 -0
  232. package/dashboard/dist/assets/index-BD4O-ISx.js +13 -0
  233. package/dashboard/dist/assets/{index-Dk2KKo0z.js.map → index-BD4O-ISx.js.map} +1 -1
  234. package/dashboard/dist/assets/{index-D9RAN9sA.js → index-BL8XOMHT.js} +2 -2
  235. package/dashboard/dist/assets/{index-D9RAN9sA.js.map → index-BL8XOMHT.js.map} +1 -1
  236. package/dashboard/dist/assets/index-C2vRDf96.js +2 -0
  237. package/dashboard/dist/assets/{index-C5osluV3.js.map → index-C2vRDf96.js.map} +1 -1
  238. package/dashboard/dist/assets/{index-DUYAGxwc.js → index-CNgyKRQ8.js} +2 -2
  239. package/dashboard/dist/assets/{index-DUYAGxwc.js.map → index-CNgyKRQ8.js.map} +1 -1
  240. package/dashboard/dist/assets/{index-DlJkZ12b.js → index-CdXPbBgs.js} +2 -2
  241. package/dashboard/dist/assets/{index-DlJkZ12b.js.map → index-CdXPbBgs.js.map} +1 -1
  242. package/dashboard/dist/assets/{index-BuCEhhnl.js → index-CnBUFCV7.js} +2 -2
  243. package/dashboard/dist/assets/{index-BuCEhhnl.js.map → index-CnBUFCV7.js.map} +1 -1
  244. package/dashboard/dist/assets/index-CoLciFzq.css +1 -0
  245. package/dashboard/dist/assets/{index-D-FYj9jT.js → index-D_TSx-k_.js} +2 -2
  246. package/dashboard/dist/assets/{index-D-FYj9jT.js.map → index-D_TSx-k_.js.map} +1 -1
  247. package/dashboard/dist/assets/{index-C_dAJUzh.js → index-Do9Y6Fgt.js} +16 -16
  248. package/dashboard/dist/assets/index-Do9Y6Fgt.js.map +1 -0
  249. package/dashboard/dist/assets/{index-D6K_IgCz.js → index-Dq1zjilj.js} +2 -2
  250. package/dashboard/dist/assets/{index-D6K_IgCz.js.map → index-Dq1zjilj.js.map} +1 -1
  251. package/dashboard/dist/assets/{index-BEMdD58x.js → index-Dz4LSzA2.js} +2 -2
  252. package/dashboard/dist/assets/{index-BEMdD58x.js.map → index-Dz4LSzA2.js.map} +1 -1
  253. package/dashboard/dist/assets/{index-D7L_VoBD.js → index-g1MmARVR.js} +2 -2
  254. package/dashboard/dist/assets/{index-D7L_VoBD.js.map → index-g1MmARVR.js.map} +1 -1
  255. package/dashboard/dist/assets/{index-BxbQmeqh.js → index-qEd4FVmN.js} +2 -2
  256. package/dashboard/dist/assets/{index-BxbQmeqh.js.map → index-qEd4FVmN.js.map} +1 -1
  257. package/dashboard/dist/assets/index-v4rQ8ctJ.js +3 -0
  258. package/dashboard/dist/assets/index-v4rQ8ctJ.js.map +1 -0
  259. package/dashboard/dist/assets/{knowledge-DSsPTqkK.js → knowledge-CT1I1t1S.js} +2 -2
  260. package/dashboard/dist/assets/{knowledge-DSsPTqkK.js.map → knowledge-CT1I1t1S.js.map} +1 -1
  261. package/dashboard/dist/assets/{machines-DSgGtqqr.js → machines-Dsuw-l1y.js} +2 -2
  262. package/dashboard/dist/assets/{machines-DSgGtqqr.js.map → machines-Dsuw-l1y.js.map} +1 -1
  263. package/dashboard/dist/assets/{mcp-Cg-_uLw8.js → mcp-C3o5wzO8.js} +2 -2
  264. package/dashboard/dist/assets/{mcp-Cg-_uLw8.js.map → mcp-C3o5wzO8.js.map} +1 -1
  265. package/dashboard/dist/assets/{mcp-query-DQombEK_.js → mcp-query-IvkIG7gH.js} +2 -2
  266. package/dashboard/dist/assets/{mcp-query-DQombEK_.js.map → mcp-query-IvkIG7gH.js.map} +1 -1
  267. package/dashboard/dist/assets/pdf-CcZYcL52.js +13 -0
  268. package/dashboard/dist/assets/pdf-CcZYcL52.js.map +1 -0
  269. package/dashboard/dist/assets/pdf.worker.min-DgRcL-GR.js +2 -0
  270. package/dashboard/dist/assets/pdf.worker.min-DgRcL-GR.js.map +1 -0
  271. package/dashboard/dist/assets/pdf.worker.min-yatZIOMy.mjs +21 -0
  272. package/dashboard/dist/assets/{personas-DYrcoVBu.js → personas-zWlWjj6j.js} +2 -2
  273. package/dashboard/dist/assets/{personas-DYrcoVBu.js.map → personas-zWlWjj6j.js.map} +1 -1
  274. package/dashboard/dist/assets/{pipelines-wdb4xsey.js → pipelines-BKNvBMdf.js} +2 -2
  275. package/dashboard/dist/assets/{pipelines-wdb4xsey.js.map → pipelines-BKNvBMdf.js.map} +1 -1
  276. package/dashboard/dist/assets/{tasks-Bil7gvm9.js → tasks-BQSO3Sjv.js} +2 -2
  277. package/dashboard/dist/assets/{tasks-Bil7gvm9.js.map → tasks-BQSO3Sjv.js.map} +1 -1
  278. package/dashboard/dist/assets/{topics-wBqaVhRR.js → topics-Dr_1TtUM.js} +2 -2
  279. package/dashboard/dist/assets/{topics-wBqaVhRR.js.map → topics-Dr_1TtUM.js.map} +1 -1
  280. package/dashboard/dist/assets/{useContainerWidth-DSLp1gEm.js → useContainerWidth-D38m8eub.js} +2 -2
  281. package/dashboard/dist/assets/{useContainerWidth-DSLp1gEm.js.map → useContainerWidth-D38m8eub.js.map} +1 -1
  282. package/dashboard/dist/assets/{useDebouncedValue-CwrY8TpV.js → useDebouncedValue-C5ESASfo.js} +2 -2
  283. package/dashboard/dist/assets/{useDebouncedValue-CwrY8TpV.js.map → useDebouncedValue-C5ESASfo.js.map} +1 -1
  284. package/dashboard/dist/assets/{useNamespace-Sod_xApz.js → useNamespace-DLLOJRYY.js} +2 -2
  285. package/dashboard/dist/assets/{useNamespace-Sod_xApz.js.map → useNamespace-DLLOJRYY.js.map} +1 -1
  286. package/dashboard/dist/assets/{useYamlActivityEvents-CKLInV3C.js → useYamlActivityEvents-D0XNXli1.js} +2 -2
  287. package/dashboard/dist/assets/{useYamlActivityEvents-CKLInV3C.js.map → useYamlActivityEvents-D0XNXli1.js.map} +1 -1
  288. package/dashboard/dist/assets/{validate-CYhW1xMJ.js → validate-Be4GWnJ1.js} +2 -2
  289. package/dashboard/dist/assets/{validate-CYhW1xMJ.js.map → validate-Be4GWnJ1.js.map} +1 -1
  290. package/dashboard/dist/assets/{vendor-icons-ed7mYQw4.js → vendor-icons-D48ijXZU.js} +209 -189
  291. package/dashboard/dist/assets/vendor-icons-D48ijXZU.js.map +1 -0
  292. package/dashboard/dist/assets/{yaml-workflows-C20qHo3L.js → yaml-workflows-BQpO-G-I.js} +2 -2
  293. package/dashboard/dist/assets/{yaml-workflows-C20qHo3L.js.map → yaml-workflows-BQpO-G-I.js.map} +1 -1
  294. package/dashboard/dist/index.html +3 -3
  295. package/docs/api/http/escalations.md +54 -7
  296. package/docs/api/mcp/admin.md +7 -5
  297. package/docs/api/mcp/human-queue.md +17 -1
  298. package/docs/api/sdk/escalations.md +30 -4
  299. package/docs/api/sdk/files.md +19 -0
  300. package/docs/cli.md +4 -1
  301. package/docs/escalation-analytics.md +17 -0
  302. package/docs/hitl/files.md +104 -0
  303. package/docs/hitl/x-lt-confidence.md +139 -0
  304. package/docs/hitl/x-lt-layout.md +19 -0
  305. package/docs/hitl/x-lt-widget.md +20 -0
  306. package/docs/hitl-guide.md +6 -0
  307. package/docs/mcp.md +2 -1
  308. package/package.json +1 -1
  309. package/dashboard/dist/assets/ResolverForm-DfogHDzl.js +0 -8
  310. package/dashboard/dist/assets/ResolverForm-DfogHDzl.js.map +0 -1
  311. package/dashboard/dist/assets/TopicsPage-D8dW6J65.js +0 -2
  312. package/dashboard/dist/assets/escalation-items-BGZlJMpk.js +0 -2
  313. package/dashboard/dist/assets/escalation-items-BGZlJMpk.js.map +0 -1
  314. package/dashboard/dist/assets/index-BUmz0NMg.css +0 -1
  315. package/dashboard/dist/assets/index-C5osluV3.js +0 -2
  316. package/dashboard/dist/assets/index-C_dAJUzh.js.map +0 -1
  317. package/dashboard/dist/assets/index-Dk2KKo0z.js +0 -13
  318. package/dashboard/dist/assets/index-FiNThtNU.js +0 -3
  319. package/dashboard/dist/assets/index-FiNThtNU.js.map +0 -1
  320. package/dashboard/dist/assets/vendor-icons-ed7mYQw4.js.map +0 -1
@@ -0,0 +1,139 @@
1
+ # Reviewing Proposed Values (`x-lt-confidence`)
2
+
3
+ When a model fills a form (a document read, a record matched, a reading interpreted), the person who verifies it needs three things at a glance: which values the model was unsure of, what it proposed, and what they changed. `x-lt-confidence` gives a form all three, while it is worked and after it is resolved.
4
+
5
+ ---
6
+
7
+ ## The Inputs
8
+
9
+ The workflow proposes values in `envelope.formDefaults`, which prefill the form as usual, and scores them in `envelope.confidence`, the same shape with numbers in `[0, 1]`:
10
+
11
+ ```typescript
12
+ await conditional<IntakeReviewV1>(signalId, {
13
+ role: 'intake-verifier',
14
+ envelope: {
15
+ formDefaults: { applicant: { first_name: 'Jon', date_of_birth: '1987-03-04' }, account_type: 'individual' },
16
+ confidence: { applicant: { first_name: 0.52, date_of_birth: 0.58 }, account_type: 0.66 },
17
+ },
18
+ schemaVersion: 1,
19
+ });
20
+ ```
21
+
22
+ Both are read in payload shape and mapped through `x-lt-bind`, so a form field bound to `applicant.first_name` reads its proposal and its score from that path.
23
+
24
+ ## The Token
25
+
26
+ Declare the tranches at the schema root:
27
+
28
+ ```json
29
+ {
30
+ "x-lt-confidence": {
31
+ "tranches": [
32
+ { "below": 0.6, "label": "Low", "tone": "error" },
33
+ { "below": 0.85, "label": "Check", "tone": "warning" }
34
+ ]
35
+ },
36
+ "properties": { "...": {} }
37
+ }
38
+ ```
39
+
40
+ | Field | Meaning |
41
+ |-------|---------|
42
+ | `tranches` | Any number of `{ below, label, tone }`. A score falls into the first tranche whose `below` it is under; a score at or above every threshold is confident and carries no mark |
43
+ | `tranches[].below` | A threshold in `(0, 1]` |
44
+ | `tranches[].label` | The tranche's name, shown beside each field and in the review key |
45
+ | `tranches[].tone` | `error`, `warning` or `info`; defaults to `warning` |
46
+ | `scores` | The context path to the scores. Defaults to `envelope.confidence` |
47
+ | `proposed` | The context path to the proposals. Defaults to `envelope.formDefaults` |
48
+ | `facets` | `true` stamps a review summary onto the row's metadata when it resolves; see [Review Facets](#review-facets) |
49
+
50
+ `"x-lt-confidence": true` uses the default tranches: Low under 0.6, Check under 0.85. A field opts out with `"x-lt-confidence": false`; display-only widgets never take part.
51
+
52
+ ## What the Form Shows
53
+
54
+ - **The tranche, on the field.** The control's rule carries the tranche tone, and a line under it names the tranche and the score: `● Low · 52%`. Focus still takes the accent, and a validation error keeps its own rule.
55
+ - **The review key, above the fields.** One entry per tranche with its count, and **Edited** with the count of changed answers out of the proposed ones. Each entry walks its fields: press **Low** and the next low-confidence field scrolls into view and takes focus.
56
+ - **What it was, while editing.** Once an answer differs from its proposal, the field shows **Edited**. Press it to see the proposed value and **Restore** it.
57
+ - **What it became, after submit.** A locked or resolved form shows each changed field as `Was ~~Jon~~ → John`, beside its tranche.
58
+
59
+ The proposal comes from the envelope, which the resolve leaves untouched, and the answer from the stored resolver payload, so a resolved row shows the same review indefinitely without storing anything extra. Answers compare as values: an empty string and a missing answer are equal, `"42"` equals `42`, text compares by its words (surrounding and repeated whitespace is not a change), and object key order is ignored. The answer is stored exactly as submitted.
60
+
61
+ ## Review Facets
62
+
63
+ With `"facets": true`, the server summarizes each review when the row resolves and merges the summary into its metadata, inside the same guarded update that resolves it:
64
+
65
+ | Key | Value |
66
+ |-----|-------|
67
+ | `review_outcome` | `corrected` when any shown answer differs from its proposal, else `accepted` |
68
+ | `review_changed` | How many shown answers differ, as a string (`"3"`) |
69
+ | `review_worst` | The lowest tranche any shown field fell into (`"Low"`); absent when every score cleared |
70
+
71
+ The counts cover the fields the form shows for the submitted answer, the same set the review key counts, and use the comparison above. They are computed by the server from the role's schema, so an answer submitted through the form, the API or an MCP tool reports the same way, and they win over a caller's metadata of the same name. Values are strings, so `metadata @>` filters and analytics groupings match them exactly.
72
+
73
+ The facets need the role to enforce its schema (`enforce_schema: true`): that is when the server holds the form the answer is checked against. Every single-row resolve path stamps them. A bulk resolve applies one payload to many rows and stamps none, so those rows report no `review_outcome`, which keeps answers approved in bulk apart from reviewed ones. Rows resolved before a form opts in carry no facets, and the tranche named in `review_worst` is the one the row's pinned schema version declared.
74
+
75
+ Record what produced the proposals in the row's metadata too (`extractor: 'intake-extractor-v1'`), so reports compare one version with the next.
76
+
77
+ ## Reporting
78
+
79
+ Every resolved row keeps what was proposed (`envelope.formDefaults`), how sure the model was (`envelope.confidence`), what the reviewer submitted (`resolver_payload`), who resolved it (`metadata.resolved_by`), the work time (`resolved_at - claimed_at`) and the schema version that set the tranches (`metadata.schema_version`).
80
+
81
+ **Trends** come from the review facets and the [resolved measure](../escalation-analytics.md): rows resolved in a window, per day, week or month, grouped by any facets. It is available over HTTP, the SDK, the CLI and the `aggregate_by_facets` MCP tool, so an agent can answer "compare the extractor versions' correction rates by week since October" in one call:
82
+
83
+ ```typescript
84
+ await lt.escalations.aggregateByFacets({
85
+ query: { role: 'intake-verifier' },
86
+ groupBy: { facets: ['extractor', 'review_outcome'] },
87
+ measure: { kind: 'resolved', window: { from: '2026-10-01T00:00:00Z', to: '2026-11-01T00:00:00Z' }, bucket: 'week' },
88
+ });
89
+ ```
90
+
91
+ Group by `review_worst` to see how often each tranche led to a correction, or by `review_changed` for a histogram of edits per review. `search_by_facets` with `{ "review_outcome": "corrected" }` lists the rows behind a count.
92
+
93
+ **Per-field detail** (which fields are corrected most, and how often each score band was right) reads the row columns directly. Run it on a read replica or warehouse copy: it compares every scored field of every row in the window. This query walks the scores, so a field with a proposal and no score is left out, and it compares stored JSON strictly (`"42"` differs from `42`, and whitespace counts):
94
+
95
+ ```sql
96
+ WITH RECURSIVE scored AS (
97
+ SELECT e.id, ARRAY[k] AS path, v
98
+ FROM lt_escalations e, jsonb_each(e.envelope->'confidence') AS t(k, v)
99
+ WHERE e.role = 'intake-verifier' AND e.status = 'resolved'
100
+ AND e.resolved_at >= '2026-10-01' AND e.resolved_at < '2026-11-01'
101
+ UNION ALL
102
+ SELECT s.id, s.path || t.k, t.v
103
+ FROM scored s, jsonb_each(s.v) AS t(k, v)
104
+ WHERE jsonb_typeof(s.v) = 'object'
105
+ )
106
+ SELECT array_to_string(s.path, '.') AS field,
107
+ width_bucket((s.v)::numeric, 0, 1, 10) AS score_band,
108
+ count(*) AS reviewed,
109
+ count(*) FILTER (
110
+ WHERE (e.envelope->'formDefaults' #> s.path) IS DISTINCT FROM (e.resolver_payload #> s.path)
111
+ ) AS corrected
112
+ FROM scored s JOIN lt_escalations e ON e.id = s.id
113
+ WHERE jsonb_typeof(s.v) = 'number'
114
+ GROUP BY 1, 2
115
+ ORDER BY 1, 2;
116
+ ```
117
+
118
+ The role and `resolved_at` range use the resolved-rows index; the comparison runs once per scored field.
119
+
120
+ ## In the Workflow
121
+
122
+ The same rules are exported for workflow and agent code, so a workflow can record what a person corrected, the feedback a model's next round learns from:
123
+
124
+ ```typescript
125
+ import { differsFromProposal } from '@hotmeshio/long-tail';
126
+
127
+ const corrections = Object.entries(flat(proposed))
128
+ .filter(([path, value]) => differsFromProposal(value, get(review, path)));
129
+ ```
130
+
131
+ `readConfidenceSpec`, `buildFormReview`, `summarizeReview` and `buildReviewFacets` are exported beside it.
132
+
133
+ ## With Documents
134
+
135
+ A review usually sits beside the document it checks. Name the files on the escalation and show them in a split form; see [files.md](files.md).
136
+
137
+ ## Reference Example
138
+
139
+ `examples/workflows/document-intake/` is the canonical reference: a split form with the application and ID card in the pane, nine scored proposals in two tranches, review facets and the extractor version on the row, and an activity that records each correction. Invoke `documentIntake` with `{ "data": { "applicationId": "APP-1043" } }`.
@@ -19,6 +19,25 @@ Set `"x-lt-layout": "two-column"` at the schema root to arrange fields in a 2-co
19
19
 
20
20
  ---
21
21
 
22
+ ## Split Layout
23
+
24
+ Set `"x-lt-layout": "split"` to put the form's `document` fields in a pane beside the rest. The pane stays in view while the fields scroll, a lone document fills it, and two or more scroll within it. The form takes two measures of width; below the split width the pane stacks above the fields. Without a document field the form lays out as a single column.
25
+
26
+ ```json
27
+ {
28
+ "x-lt-layout": "split",
29
+ "properties": {
30
+ "application": { "type": "string", "x-lt-widget": "document", "x-lt-source": "file.application" },
31
+ "first_name": { "type": "string" },
32
+ "last_name": { "type": "string" }
33
+ }
34
+ }
35
+ ```
36
+
37
+ See [files.md](files.md).
38
+
39
+ ---
40
+
22
41
  ## Field Ordering (`x-lt-order`)
23
42
 
24
43
  By default, fields render in JSON key order. `x-lt-order` sets an explicit sequence. Fields not listed in `x-lt-order` render after the listed ones in their original key order.
@@ -128,6 +128,26 @@ The value is a data URL or a fetchable URL. Rendering dispatches on content type
128
128
 
129
129
  ---
130
130
 
131
+ ## Document
132
+
133
+ A stored file shown in place: PDFs as continuous pages with paging, zoom and rotation; images with zoom and rotation; anything else as an open link. `x-lt-source` names the file, usually a signed ref from the escalation's `file.*` domain:
134
+
135
+ ```json
136
+ {
137
+ "application": {
138
+ "type": "string",
139
+ "title": "Application",
140
+ "description": "The signed application as received.",
141
+ "x-lt-widget": "document",
142
+ "x-lt-source": "file.application"
143
+ }
144
+ }
145
+ ```
146
+
147
+ Display-only: the field carries no answer and never reaches the payload. It stays readable and pageable on a locked or resolved form. In a split form (`x-lt-layout: "split"`) documents sit in a pane beside the fields. See [files.md](files.md).
148
+
149
+ ---
150
+
131
151
  ## Markdown
132
152
 
133
153
  Without `readOnly`, the field is a markdown editor — the resolver writes source in a Write/Preview toggle and the submitted value is the markdown text.
@@ -17,6 +17,8 @@ This works because the form is data: a JSON Schema stored on the role, versioned
17
17
  | Typed fields, formats, required | Plain JSON Schema | [form.md](hitl/form.md) |
18
18
  | Input guards (bounds, patterns, dynamic limits) | Validation keywords | [x-lt-validation.md](hitl/x-lt-validation.md) |
19
19
  | Option lists shared by thousands of rows, cascading selects | Versioned lookups | [lookups.md](hitl/lookups.md) |
20
+ | Documents the reviewer reads in place: PDFs and images, signed per reader | Stored files + `document` widget | [files.md](hitl/files.md) |
21
+ | Values a model proposed, marked by confidence, with what each was and became | `x-lt-confidence` | [x-lt-confidence.md](hitl/x-lt-confidence.md) |
20
22
  | Fields that appear based on another answer | `x-lt-showIf` | [x-lt-show-if.md](hitl/x-lt-show-if.md) |
21
23
  | Sections, columns, ordering, side-panel help | Layout keywords | [x-lt-layout.md](hitl/x-lt-layout.md) |
22
24
  | Runtime-driven items, files, signatures, SOP blocks | Widgets | [x-lt-widget.md](hitl/x-lt-widget.md) |
@@ -72,6 +74,8 @@ When you author a HITL-backed workflow, the platform handles:
72
74
  - **Credential security** — password fields use ephemeral tokens, never stored in plain text
73
75
  - **Schema enforcement** — roles with `enforce_schema` validate every resolver payload server-side (dashboard, API, MCP, CLI alike) with the same pass the form runs, rejecting violations as a structured 422 (see [schema-enforcement.md](schema-enforcement.md))
74
76
  - **Versioned lookups** — escalations reference knowledge entries for their option lists, following the newest edition or pinned to one; the refs grant readers exactly those entries, and cascading selects resolve locally from one batch fetch (see [lookups.md](hitl/lookups.md))
77
+ - **Stored files** — escalations name files in storage; readers receive time-limited signed links, stretched to cover their claim, and the `document` widget shows PDFs and images in place (see [files.md](hitl/files.md))
78
+ - **Confidence review** — proposed values carry their score's tranche on the field, and every edited value shows what it was, before and after submit (see [x-lt-confidence.md](hitl/x-lt-confidence.md))
75
79
  - **Telemetry** — trace IDs link escalations to OpenTelemetry traces
76
80
  - **Bulk operations** — bulk claim, assign, triage, and cancel for queue management
77
81
  - **Cancellation** — cancel pending escalations from the API or dashboard
@@ -88,6 +92,8 @@ Ordered as a learning path — each file adds one capability to the same form:
88
92
  |-------|------|
89
93
  | Creating escalations with `conditional`, schema versioning | [escalation.md](hitl/escalation.md) |
90
94
  | Versioned knowledge lookups, the `lookup.*` domain, cascading selects | [lookups.md](hitl/lookups.md) |
95
+ | Stored files, the `file.*` domain, signed links | [files.md](hitl/files.md) |
96
+ | Reviewing proposed values by confidence (`x-lt-confidence`) | [x-lt-confidence.md](hitl/x-lt-confidence.md) |
91
97
  | Field types, formats, required, read-only | [form.md](hitl/form.md) |
92
98
  | Pre-submission validation guards (min, max, pattern, dynamic bounds) | [x-lt-validation.md](hitl/x-lt-validation.md) |
93
99
  | Conditional visibility (`x-lt-showIf`, `x-lt-hide-if-empty`, `x-lt-hidden`) | [x-lt-show-if.md](hitl/x-lt-show-if.md) |
package/docs/mcp.md CHANGED
@@ -371,7 +371,7 @@ The Human Queue is a built-in MCP server that exposes Long Tail's escalation API
371
371
 
372
372
  These tools act with full authority, so at `/mcp` they are listed for superadmin accounts. Workflows and agents inside Long Tail call them directly. An external agent with any other role works the queue through the role-checked escalation tools: `find_escalations`, `claim_escalation`, `admin_resolve_escalation`.
373
373
 
374
- `get_escalation_lookups` is listed for every account and runs as the caller: anyone who may read the escalation reads the knowledge editions it names, the same grant `GET /api/escalations/:id/lookups` serves.
374
+ `get_escalation_lookups` and `get_escalation_files` are listed for every account and run as the caller: anyone who may read the escalation reads the knowledge editions it names and receives signed links to the files it names, the same grants `GET /api/escalations/:id/lookups` and `GET /api/escalations/:id/files` serve.
375
375
 
376
376
  ### Tools
377
377
 
@@ -380,6 +380,7 @@ These tools act with full authority, so at `/mcp` they are listed for superadmin
380
380
  | `escalate_to_human` | Create an escalation for human review |
381
381
  | `check_resolution` | Check whether an escalation is resolved and read its payload |
382
382
  | `get_escalation_lookups` | Read the knowledge lookups pinned on an escalation |
383
+ | `get_escalation_files` | Sign the stored files an escalation names |
383
384
  | `get_available_work` | List pending, unclaimed escalations for a role |
384
385
  | `claim_and_resolve` | Claim and resolve an escalation in one atomic call |
385
386
  | `resolve_escalation` | Resolve an escalation that is already claimed |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/long-tail",
3
- "version": "0.31.1",
3
+ "version": "0.32.0",
4
4
  "description": "Long Tail Workflows — Durable AI workflows with human-in-the-loop escalation. Powered by PostgreSQL.",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -1,8 +0,0 @@
1
- import{a as g,j as s}from"./vendor-query-DvWWuNIB.js";import{al as at,am as Yt,ae as zt,aU as Ie,aV as Kt,aD as ut,Z as Ce,az as Oe,aW as Te,aX as Re,n as Le,r as _e,U as Se,aY as Fe,aZ as Me,J as $e,a_ as De,a$ as Pe,s as We,b0 as Ue,b1 as Ge,b2 as Je,S as qe,b3 as He,b4 as Ve,aC as Be,V as Xe,K as Ye,b as ze,b5 as Ke,a as Qe,b6 as Ze,b7 as ts,b8 as es,ai as ss,ap as ns,b9 as rs,ba as is,bb as os,bc as as,bd as ls,be as cs,bf as ds,bg as us,a5 as xs,M as ps,bh as fs,bi as ms,l as gs,bj as bs,bk as ys,a4 as hs,aO as js,bl as Ns,bm as vs,bn as ks,G as As,bo as Es,bp as ws,bq as Is,br as Cs,F as Os,bs as Ts,t as Rs,a9 as Ls,bt as _s,aA as Ss,bu as Fs,bv as Ms,bw as $s,bx as Ds,by as Ps,at as Ws,bz as Us,g as Gs,aF as Js,bA as qs,bB as Hs,bC as Vs,aq as Qt,a1 as Bs,W as Xs,bD as Ys,a8 as Zt,X as zs}from"./vendor-icons-ed7mYQw4.js";import{b as Q,h as rt,i as pt,e as et,c as te,F as L,d as D,O as ee,f as Ks,I as Qs,R as Zs,s as tn,g as P,j as Y,k as en}from"./RosterWidget-BrIq61HR.js";import{m as se,c as sn,a as B,g as nn,f as rn,b as on,h as an}from"./escalation-items-BGZlJMpk.js";import{ah as z,aq as ln,b1 as ft,a1 as cn,ab as dn,s as un,b2 as xn,m as pn,J as fn,b3 as mn,R as gn,b4 as bn,ay as yn,b5 as hn,a$ as jn,i as Nn,M as ne,aB as vn,aC as kn,aD as An,b6 as En}from"./index-C_dAJUzh.js";import{L as mt}from"./vendor-react-_9U4mKFr.js";import{r as gt,a as re}from"./validate-CYhW1xMJ.js";import{S as wn}from"./StatusBadge-DHVwxre2.js";import{E as In}from"./constants-CeBBTzf5.js";import{V as Cn}from"./WorkflowPill-BiLYq__w.js";const ie=g.createContext(null),vi=ie.Provider;function On(t){const e=g.useContext(ie);return e&&e.field===t?e:null}function oe({notice:t}){return t?t.error?s.jsx("p",{role:"alert",className:"text-2xs text-status-error mt-1 animate-[field-error-in_0.3s_ease-out]","data-testid":"field-scan-notice",children:t.error},t.at):s.jsx("p",{role:"status",className:"text-2xs text-status-success mt-1","data-testid":"field-scan-notice",children:t.message??"Scanned"},t.at):null}const Tn={SCHEMA_VALIDATION:"schema_validation"};function Rn(t){return typeof t=="object"&&t!==null&&t.code===Tn.SCHEMA_VALIDATION&&Array.isArray(t.violations)}function Ot(t,e={}){const n=se(e,t),r={_form_schema:t};for(const[i,o]of Object.entries(t.properties??{})){const a=o.type==="object"?{}:"";r[i]=n[i]??o.default??a}return JSON.stringify(r,null,2)}function J(t,e){const n=e==null?void 0:e.title;if(typeof n=="string"&&n.trim().length>0)return n.trim();const r=t.split(/[_-]+/).filter(Boolean);return r.length<=1?t:r.map(i=>Ln(i)?i:i.charAt(0).toUpperCase()+i.slice(1)).join(" ")}function Ln(t){return t.length>1&&t===t.toUpperCase()&&/[A-Z]/.test(t)}function ae({errors:t,schema:e}){const n=r=>{const i=document.querySelector(`[data-field-key="${r}"]`);i&&(i.scrollIntoView({behavior:"smooth",block:"center"}),i.focus({preventScroll:!0}))};return t.length===0?s.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No errors to display."}):s.jsxs("div",{className:"space-y-1",role:"alert","aria-live":"polite",children:[s.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-wider text-status-error mb-4",children:[t.length," ",t.length===1?"issue":"issues"," to resolve"]}),s.jsx("div",{className:"space-y-1.5",children:t.map(({field:r,message:i})=>{var o;return s.jsxs("button",{onClick:()=>n(r),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:[s.jsx(at,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-status-error/60 group-hover:text-status-error transition-colors"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xs font-semibold text-text-primary leading-snug",children:J(r,(o=e==null?void 0:e.properties)==null?void 0:o[r])}),s.jsx("p",{className:"text-2xs text-text-tertiary group-hover:text-text-secondary transition-colors leading-snug mt-0.5",children:i})]})]},r)})}),s.jsx("p",{className:"text-2xs text-text-quaternary mt-4 px-3",children:"Click an issue to scroll to and focus the field."})]})}const _n="x-lt-scan",Sn="x-lt-scan-submit",Tt="x-lt-order",Fn="Expected {{expected}}";function X(t){const e=t==null?void 0:t[_n];if(!e||typeof e!="object"||Array.isArray(e))return null;const n=e,r=Array.isArray(n.schemes)?n.schemes.filter(o=>Number.isInteger(o)):[];if(r.length===0)return null;const i=Array.isArray(n.expect)?n.expect.filter(o=>typeof o=="string"):void 0;return{schemes:r,value:n.value==="code"?"code":"target",...i!=null&&i.length?{expect:i}:{},expectError:typeof n["expect-error"]=="string"?n["expect-error"]:Fn,multiplicity:n.multiplicity==="count"?"count":"once",...typeof n.prompt=="string"&&n.prompt.trim()?{prompt:n.prompt}:{}}}function Mn(t,e){if(t===e)return!0;const n=/^[0-9]{8,14}$/;return n.test(t)&&n.test(e)&&t.padStart(14,"0")===e.padStart(14,"0")}function le(t,e){if(!t.expect)return null;const n=[];for(const r of t.expect){const i=Q(r,e),o=Array.isArray(i)?i:[i];for(const a of o)typeof a=="string"&&a?n.push(a):typeof a=="number"&&n.push(String(a))}return n}function $n(t,e){return t.expectError.replace(/\{\{\s*expected\s*\}\}/g,[...new Set(e)].join(", ")||"nothing")}function ce(t,e,n){const r=X(e);if(!r)return;const i=le(r,n);if(i===null)return;const o=Array.isArray(t)?t:t==null||t===""?[]:[t],a=r.multiplicity==="count"?[...i]:[...new Set(i)];for(const l of o){const c=a.findIndex(u=>Mn(String(l),u));if(c===-1)return $n(r,i);a.splice(c,1)}}function Dn(t,e){const n=X(t);if(n){const i=le(n,e);if(i!==null)return n.multiplicity==="count"?i.length:new Set(i).size}const r=t==null?void 0:t.maxItems;return typeof r=="number"?r:null}function ki(t,e,n,r){const i=X(n);if(!i)return{ok:!1,error:"This field takes no scans"};const o=i.value==="code"?e.code:e.target,a=n.type==="array",l=a?[...Array.isArray(t)?t:[],o]:o,c=ce(l,n,r);if(c)return{ok:!1,error:c};const u=n.maxItems;return a&&typeof u=="number"&&l.length>u?{ok:!1,error:`At most ${u}`}:{ok:!0,value:l}}function Pn(t,e){if(e.type==="array"){const n=e.maxItems;return typeof n!="number"||!Array.isArray(t)||t.length<n}return t==null||t===""}function Ai(t,e,n,r){const i=(t==null?void 0:t.properties)??{},o=Array.isArray(t==null?void 0:t[Tt])?t[Tt]:[],l=[...o.filter(c=>c in i),...Object.keys(i).filter(c=>!o.includes(c))].filter(c=>{var u;return(u=X(i[c]))==null?void 0:u.schemes.includes(n)});return l.length===0?null:r&&l.includes(r)?r:l.find(c=>Pn(e[c],i[c]))??l[0]}function Ei(t){return(t==null?void 0:t[Sn])===!0}function wi(t,e){const n=(t==null?void 0:t.properties)??{},r=new Set((t==null?void 0:t.required)??[]),i=Object.keys(n).filter(o=>X(n[o])&&r.has(o));return i.length===0?!1:i.every(o=>{const a=e[o];if(Array.isArray(a)){const l=n[o].minItems;return a.length>=(typeof l=="number"?l:1)}return a!=null&&a!==""})}const de="x-lt-options";function Rt(t){return typeof t=="string"||typeof t=="boolean"||typeof t=="number"&&Number.isFinite(t)}function Wn(t){return Array.isArray(t)&&t.length>0&&!t.some(e=>typeof e=="string")}function Lt(t){if(Rt(t))return{value:t,label:String(t)};if(t&&typeof t=="object"&&!Array.isArray(t)){const e=t,n=e.value!==void 0?e.value:e.id;if(Rt(n)&&typeof e.label=="string"&&e.label.length>0)return{value:n,label:e.label}}return null}function bt(t,e){if(!t)return;const n=t.enum;if(Array.isArray(n)&&n.length>0)return n.map(a=>({value:a,label:String(a)}));const r=t[de];if(Wn(r)){const a=r.map(Lt).filter(l=>l!==null);return a.length>0?a:void 0}const i=(typeof r=="string"?[r]:Array.isArray(r)?r:[]).filter(a=>typeof a=="string"&&a.length>0);if(i.length===0)return;const o=i.some(rt)?[]:void 0;for(const a of i){let l=a;if(rt(a)){const d=pt(a,e);if(d===null)continue;l=d}const c=Q(l,e);if(!Array.isArray(c))continue;const u=c.map(Lt).filter(d=>d!==null);if(u.length>0)return u}return o}function yt(t,e){const n=(typeof t=="string"?[t]:Array.isArray(t)?t:[]).filter(r=>typeof r=="string"&&r.length>0);if(n.length===0||!e)return[];for(const r of n){let i=r;if(rt(r)){const a=pt(r,e);if(a===null)continue;i=a}const o=Q(i,e);if(Array.isArray(o)&&o.length>0)return o}return[]}const Un="x-lt-default-checked";function Gn(t,e,n){if((t==null?void 0:t["x-lt-widget"])!=="checklist"||t[Un]!==!0||e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0)return null;const r=yt(t["x-lt-source"],n);return r.length===0?null:Object.fromEntries(r.map(i=>[i.id,!0]))}function Jn(t,e,n){if((e==null?void 0:e["x-lt-widget"])!=="checklist"||e["x-lt-require-all"]!==!0)return;const i=yt(e["x-lt-source"],n).filter(l=>l.required!==!1);if(i.length===0)return;const o=typeof t=="object"&&t!==null&&!Array.isArray(t)?t:{},a=i.filter(l=>!o[l.id]).length;if(a!==0)return`${a} of ${i.length} checks incomplete`}const _t="Invalid JSON";function it(t){return(t==null?void 0:t["x-lt-widget"])==="json"}function ue(t){return it(t)||(t==null?void 0:t[de])!==void 0}function St(t,e){return`${t} ${e}${t===1?"":"s"}`}function ht(t,e){const n=e==null?void 0:e.type;if(typeof n=="string"&&!(t==null||t===""))switch(n){case"string":return typeof t=="string"?void 0:"Expected text";case"number":return typeof t=="number"&&Number.isFinite(t)?void 0:"Expected a number";case"integer":return typeof t=="number"&&Number.isInteger(t)?void 0:"Expected a whole number";case"boolean":return typeof t=="boolean"?void 0:"Expected true or false";case"array":return Array.isArray(t)?void 0:it(e)&&typeof t=="string"?_t:"Expected a list";case"object":return typeof t=="object"&&!Array.isArray(t)?void 0:it(e)&&typeof t=="string"?_t:"Expected an object";default:return}}function jt(t,e,n){if(!e)return;const r=bt(e,n);if(r!==void 0&&t!==void 0&&t!==null&&t!==""&&!Array.isArray(t)){if(r.length===0)return"No valid options for this selection";if(!r.some(o=>o.value===t))return`Must be one of: ${r.map(o=>String(o.value)).join(", ")}`}const i=ce(t,e,n);if(i)return i;if(Array.isArray(t))return ue(e)?qn(t,e,r,n):void 0;if(t!==null&&typeof t=="object")return Hn(t,e,n);if(typeof t=="string"){const o=t.trim();if(o==="")return;const a=H(e.minLength,e["x-lt-min-length"],n);if(a!==void 0&&o.length<a)return`Minimum ${a} character${a===1?"":"s"}`;const l=H(e.maxLength,e["x-lt-max-length"],n);if(l!==void 0&&o.length>l)return`Maximum ${l} characters (${o.length} entered)`;const c=e.pattern;if(c)try{if(!new RegExp(c).test(o))return e["x-lt-pattern-error"]??"Invalid format"}catch{}const u=e.format;if(u==="email"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o))return"Enter a valid email address";if(u==="uri"&&!/^https?:\/\/.+/.test(o))return"Enter a valid URL"}if(typeof t=="number"){const o=H(e.minimum,e["x-lt-minimum"],n),a=H(e.exclusiveMinimum,void 0,n),l=H(e.maximum,e["x-lt-maximum"],n),c=H(e.exclusiveMaximum,void 0,n);if(o!==void 0&&t<o)return`Minimum value is ${o}`;if(a!==void 0&&t<=a)return`Must be greater than ${a}`;if(l!==void 0&&t>l)return`Maximum value is ${l}`;if(c!==void 0&&t>=c)return`Must be less than ${c}`}}function qn(t,e,n,r){if(t.length===0)return;if(n!==void 0){if(n.length===0)return"No valid options for this selection";if(t.some(l=>!n.some(c=>c.value===l)))return`Must be one of: ${n.map(l=>String(l.value)).join(", ")}`}const i=H(e.minItems,void 0,r);if(i!==void 0&&t.length<i)return`At least ${St(i,"item")}`;const o=H(e.maxItems,void 0,r);if(o!==void 0&&t.length>o)return`At most ${St(o,"item")}`;const a=e.items;if(a&&typeof a=="object"&&!Array.isArray(a)){const l=a;for(let c=0;c<t.length;c++){const u=ht(t[c],l)??jt(t[c],l,r);if(u)return`Item ${c+1}: ${u}`}}}function Hn(t,e,n){const r=Object.entries(t);if(r.length===0)return;const i=e.propertyNames,o=Array.isArray(i==null?void 0:i.enum)?i.enum.map(String):void 0;if(o){const l=r.find(([c])=>!o.includes(c));if(l)return`Unknown key "${l[0]}". Allowed: ${o.join(", ")}`}const a=e.additionalProperties;if(a&&typeof a=="object"&&!Array.isArray(a)){const l=a;for(const[c,u]of r){const d=ht(u,l)??jt(u,l,n);if(d)return`"${c}": ${d}`}}}function H(t,e,n){if(typeof t=="number")return t;if(typeof e=="string"&&n){const r=e.indexOf(".");if(r!==-1){const i=e.slice(0,r),o=e.slice(r+1),a=n[i];if(a&&typeof a=="object"){const l=o.split(".");let c=a;for(const u of l)if(c=c[u],c===void 0)break;if(typeof c=="number")return c;if(typeof c=="string"){const u=Number(c);if(!Number.isNaN(u))return u}}}}}function xe(t,e,n,r,i){if(!r)return;if(n){if(t==null||typeof t=="boolean"&&!t&&bt(e,i)===void 0||typeof t=="string"&&t.trim()===""||Array.isArray(t)&&t.length===0&&ue(e))return"Required";if(typeof t=="object"&&!Array.isArray(t)&&t!==null){const l=Object.values(t);if(l.length===0||!it(e)&&l.every(c=>!c))return"Required"}}const o=ht(t,e);if(o)return o;const a=Jn(t,e,i);return a||jt(t,e,i)}const Vn="x-lt-require-any";function Bn(t){const e=t==null?void 0:t[Vn];return Array.isArray(e)?e.filter(n=>Array.isArray(n)).map(n=>n.filter(r=>typeof r=="string"&&r.length>0)).filter(n=>n.length>0):[]}function Xn(t){return t==null?!1:typeof t=="string"?t.trim().length>0:!0}const Yn="x-lt-require-sum";function zn(t){const e=t==null?void 0:t[Yn];if(!Array.isArray(e))return[];const n=[];for(const r of e){if(!r||typeof r!="object"||Array.isArray(r))continue;const{fields:i,minimum:o}=r;if(!Array.isArray(i))continue;const a=i.filter(l=>typeof l=="string"&&l.length>0);a.length!==0&&(o!==void 0&&typeof o!="number"||n.push({fields:a,minimum:typeof o=="number"?o:1}))}return n}function Kn(t){if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"&&t.trim()!==""){const e=Number(t);if(!Number.isNaN(e))return e}return 0}function pe(t,e,n){if(!t)return[];const r=t.properties??{},i=new Set(t.required??[]),o={...n??{},resolver:e,input:e},a=[];for(const[l,c]of Object.entries(r)){if(!et(c["x-lt-showIf"],o))continue;const u=xe(e[l],c,i.has(l)&&!te(c),!0,o);u&&a.push({field:l,message:u})}for(const l of Bn(t)){const c=l.filter(d=>r[d]&&et(r[d]["x-lt-showIf"],o));if(c.length===0||c.some(d=>Xn(e[d])))continue;const u=c.map(d=>r[d].title??d);a.push({field:c[0],message:`Enter a value for at least one of: ${u.join(", ")}`})}for(const l of zn(t)){const c=l.fields.filter(p=>r[p]&&et(r[p]["x-lt-showIf"],o));if(c.length===0||c.reduce((p,x)=>p+Kn(e[x]),0)>=l.minimum)continue;const d=c.map(p=>r[p].title??p);a.push({field:c[0],message:`Combined value of ${d.join(", ")} must be at least ${l.minimum}`})}return a}function Qn(t,e,n){if(!t)return[];const r=se(e,t);return pe(t,r,n)}function Ft(t,e){let n;try{n=JSON.parse(t)}catch{return{payload:null,errors:[],parseError:"Invalid JSON"}}const r=n._form_schema;if(r){const a=pe(r,n,e);if(a.length>0)return{payload:null,errors:a,parseError:null}}const{_form_schema:i,...o}=n;return{payload:sn(o,r),errors:[],parseError:null}}const Zn=2600;function tr({hint:t,onLockedClick:e,children:n}){const[r,i]=g.useState(null);g.useEffect(()=>{if(!r)return;const a=setTimeout(()=>i(null),Zn);return()=>clearTimeout(a)},[r]);const o=a=>{if(e==null||e(),t){const l=Math.min(Math.max(a.clientX,96),window.innerWidth-96);i(c=>({x:l,y:a.clientY,n:((c==null?void 0:c.n)??0)+1}))}};return s.jsxs("div",{className:"pb-8 max-w-form",onClick:o,"data-testid":"locked-form-frame",children:[n,t&&r&&s.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:r.x,top:r.y-12},onAnimationEnd:()=>i(null),"data-testid":"locked-form-hint",children:[s.jsx(Yt,{className:"w-3.5 h-3.5 text-accent shrink-0",strokeWidth:1.5}),t]},r.n)]})}function er({fieldKey:t,value:e,onChange:n,schema:r,isRequired:i}){const o=g.useRef(null),a=(r==null?void 0:r.accept)??void 0,l=J(t,r),c=r==null?void 0:r.description,u=g.useCallback(p=>{var b;const x=(b=p.target.files)==null?void 0:b[0];if(!x)return;const f=new FileReader;f.onload=()=>{typeof f.result=="string"&&n(f.result)},f.readAsDataURL(x)},[n]),d=e.startsWith("data:");return s.jsxs("div",{children:[s.jsx(L,{isRequired:i,children:l}),c&&s.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:c}),s.jsxs("div",{className:"mt-1",children:[s.jsx("input",{ref:o,type:"file",accept:a,onChange:u,className:"hidden"}),s.jsx("button",{type:"button",onClick:()=>{var p;return(p=o.current)==null?void 0:p.click()},className:"btn-secondary text-xs px-3 py-1.5",children:d?"Replace file":"Choose file"}),d&&s.jsx("span",{className:"ml-2 text-xs text-status-success",children:"File attached"})]})]})}function sr({fieldKey:t,value:e,onChange:n,schema:r,isRequired:i}){const o=J(t,r),a=r==null?void 0:r.description,l=(r==null?void 0:r["x-lt-language"])??"",c=g.useCallback(u=>{if(u.key==="Tab"){u.preventDefault();const d=u.currentTarget,p=d.selectionStart,x=d.selectionEnd,f=e.substring(0,p)+" "+e.substring(x);n(f),requestAnimationFrame(()=>{d.selectionStart=d.selectionEnd=p+2})}},[e,n]);return s.jsxs("div",{children:[s.jsxs(L,{isRequired:i,children:[o,l&&s.jsx("span",{className:"ml-2 text-text-tertiary/60 normal-case font-normal",children:l})]}),a&&s.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:a}),s.jsx("textarea",{value:e,onChange:u=>n(u.target.value),onKeyDown:c,className:"input w-full mt-1 font-mono text-xs leading-relaxed",rows:10,spellCheck:!1})]})}function nr({fieldKey:t,value:e,onChange:n,schema:r,isRequired:i}){const o=g.useRef(null),[a,l]=g.useState(!1),c=J(t,r),u=r==null?void 0:r.description;g.useEffect(()=>{const m=o.current;if(!m)return;const y=m.getContext("2d");if(y&&(y.lineWidth=2,y.lineCap="round",y.strokeStyle="#1E1535",e&&e.startsWith("data:"))){const h=new Image;h.onload=()=>y.drawImage(h,0,0),h.src=e}},[]);const d=g.useCallback(m=>{const y=o.current,h=y.getBoundingClientRect(),A=h.width>0?y.width/h.width:1,j=h.height>0?y.height/h.height:1;return"touches"in m?{x:(m.touches[0].clientX-h.left)*A,y:(m.touches[0].clientY-h.top)*j}:{x:(m.clientX-h.left)*A,y:(m.clientY-h.top)*j}},[]),p=g.useCallback(m=>{var A;l(!0);const y=(A=o.current)==null?void 0:A.getContext("2d");if(!y)return;const h=d(m);y.beginPath(),y.moveTo(h.x,h.y)},[d]),x=g.useCallback(m=>{var A;if(!a)return;const y=(A=o.current)==null?void 0:A.getContext("2d");if(!y)return;const h=d(m);y.lineTo(h.x,h.y),y.stroke()},[a,d]),f=g.useCallback(()=>{l(!1);const m=o.current;m&&n(m.toDataURL("image/png"))},[n]),b=g.useCallback(()=>{const m=o.current;if(!m)return;const y=m.getContext("2d");y&&(y.clearRect(0,0,m.width,m.height),n(""))},[n]);return s.jsxs("div",{children:[s.jsx(L,{isRequired:i,children:c}),u&&s.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:u}),s.jsx("div",{className:"mt-1 max-w-[25rem] border border-surface-border rounded-md overflow-hidden bg-white",children:s.jsx("canvas",{ref:o,width:400,height:150,className:"w-full cursor-crosshair touch-none",onMouseDown:p,onMouseMove:x,onMouseUp:f,onMouseLeave:f,onTouchStart:p,onTouchMove:x,onTouchEnd:f})}),s.jsx("button",{type:"button",onClick:b,className:"mt-1 text-2xs text-text-tertiary hover:text-accent transition-colors",children:"Clear"})]})}function rr({fieldKey:t,value:e,onChange:n,schema:r,isRequired:i}){const o=J(t,r),a=r==null?void 0:r.description;return s.jsxs("div",{children:[s.jsx(L,{isRequired:i,children:o}),a&&s.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:a}),s.jsx("textarea",{value:e,onChange:l=>n(l.target.value),className:"input w-full mt-1 text-sm leading-relaxed",rows:8,placeholder:"Supports plain text. Markdown formatting is preserved."})]})}function ir({fieldKey:t,value:e,onChange:n,schema:r,isRequired:i}){const[o,a]=g.useState("write"),l=J(t,r),c=r==null?void 0:r.description;return(r==null?void 0:r.readOnly)===!0?s.jsx(z,{content:e,className:"my-1"}):s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(L,{isRequired:i,children:l}),s.jsx("div",{className:"flex items-center gap-0.5",children:["write","preview"].map(d=>s.jsx("button",{type:"button",onClick:()=>a(d),className:`px-2 py-0.5 text-2xs rounded transition-colors ${o===d?"bg-accent/10 text-accent font-semibold":"text-text-quaternary hover:text-text-secondary"}`,children:d==="write"?"Write":"Preview"},d))})]}),c&&s.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:c}),o==="write"?s.jsx("textarea",{value:e,onChange:d=>n(d.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."}):s.jsx("div",{className:"mt-1 px-3 py-2 border border-surface-border rounded min-h-[120px]",children:e.trim()?s.jsx(z,{content:e}):s.jsx("p",{className:"text-xs text-text-quaternary italic",children:"Nothing to preview."})})]})}const or=28;function ar({fieldKey:t,value:e,onChange:n,schema:r,escalationContext:i,isRequired:o,submitAttempted:a,error:l}){const c=(r==null?void 0:r["x-lt-require-all"])===!0,u=yt(r==null?void 0:r["x-lt-source"],i);let d={};try{e&&(d=JSON.parse(e))}catch{}const p=(()=>{const j=Gn(r,d,i);return j?JSON.stringify(j):null})();g.useEffect(()=>{p&&n(p)},[p]);const x=j=>n(JSON.stringify({...d,[j]:!d[j]})),f=J(t,r),b=r==null?void 0:r.description;if(u.length===0)return s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-xs text-text-tertiary italic mt-1",children:"No checklist items. None of the field's x-lt-source paths resolved on this escalation."}),l&&s.jsx("p",{className:"text-2xs text-status-error mt-1 animate-[field-error-in_0.3s_ease-out]",children:l})]});const m=r==null?void 0:r["x-lt-variant"],y=m==="chips"||m==="rows"?m:c||u.some(j=>j.label.length>or)?"rows":"chips",h=u.filter(j=>d[j.id]).length,A=(u.find(j=>!d[j.id]&&j.required!==!1)??u[0]).id;return s.jsxs("div",{role:"group","aria-label":f,"aria-required":o||void 0,"aria-invalid":l?!0:void 0,children:[s.jsx(L,{isRequired:o,children:f}),b&&s.jsx(D,{children:b}),y==="chips"?s.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:u.map(j=>{const N=d[j.id]??!1,v=!N&&!!a&&h===0&&(j.required||o);return s.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)] ${N?"bg-accent border-accent text-text-inverse":v?"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:[s.jsx("input",{type:"checkbox",checked:N,onChange:()=>x(j.id),className:"sr-only","data-testid":`checklist-item-${j.id}`,...j.id===A?{"data-field-key":t}:{}}),N&&s.jsx(zt,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:2.5}),j.label]},j.id)})}):s.jsx("div",{className:"space-y-2.5 mt-2",children:u.map(j=>{const N=d[j.id]??!1,v=!N&&!!a&&(c?j.required!==!1:h===0&&(j.required||o));return s.jsxs("label",{className:`flex items-start gap-3 cursor-pointer group select-none rounded px-2 py-1 -mx-2 transition-colors ${v?"bg-status-error/5":"hover:bg-surface-hover"}`,children:[s.jsx("input",{type:"checkbox",checked:N,onChange:()=>x(j.id),className:`mt-0.5 w-3.5 h-3.5 shrink-0 rounded ${v?"accent-status-error":"accent-accent"}`,"data-testid":`checklist-item-${j.id}`,...j.id===A?{"data-field-key":t}:{}}),s.jsxs("span",{className:`text-sm leading-snug transition-colors ${v?"text-status-error":"text-text-secondary group-hover:text-text-primary"}`,children:[j.label,j.required&&s.jsx("span",{className:`ml-0.5 text-2xs ${v?"text-status-error":"text-text-quaternary"}`,children:"*"})]})]},j.id)})}),s.jsx("p",{className:"text-2xs text-text-quaternary mt-3 tabular-nums",children:y==="chips"?s.jsxs(s.Fragment,{children:[h," selected",o&&h===0&&!!a&&s.jsx("span",{className:"ml-1 text-text-quaternary/60",children:"(check at least one)"})]}):s.jsxs(s.Fragment,{children:[h," / ",u.length," confirmed",c?s.jsxs("span",{className:"ml-1 text-text-quaternary/60",children:["(all required",u.some(j=>j.required===!1)?" except optional":"",")"]}):o&&h===0&&!!a&&s.jsx("span",{className:"ml-1 text-text-quaternary/60",children:"(at least one required)"})]})}),l&&s.jsx("p",{role:"alert",className:"text-2xs text-status-error mt-1 animate-[field-error-in_0.3s_ease-out]",children:l})]})}const lr=/\.(png|jpe?g|gif|webp|avif|bmp|svg)(\?.*)?$/i;function cr(t){var r,i,o,a;const e=t.trim();if(!e)return{kind:"none"};const n=(i=(r=/^data:([^;,]+)[;,]/.exec(e))==null?void 0:r[1])==null?void 0:i.toLowerCase();if(n)return n.startsWith("image/")?{kind:"image",src:e}:{kind:"file",href:e,label:n==="application/pdf"?"PDF":n,isData:!0};if(/^https?:\/\//i.test(e)){if(lr.test(e))return{kind:"image",src:e};const l=(a=(o=/\.([a-z0-9]{2,5})(\?.*)?$/i.exec(e))==null?void 0:o[1])==null?void 0:a.toUpperCase();return{kind:"file",href:e,label:l??"attachment",isData:!1}}return{kind:"none"}}function Mt({fieldKey:t,value:e,schema:n}){const[r,i]=g.useState(!1),o=cr(e??""),a=t.replace(/[_-]/g," "),l=n==null?void 0:n.description,c=s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary",children:a}),l&&s.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:l})]});return o.kind==="none"?s.jsxs("div",{children:[c,s.jsx("p",{className:"text-xs text-text-quaternary italic mt-1",children:"No attachment"})]}):o.kind==="image"?s.jsxs("div",{children:[c,s.jsxs("div",{className:"mt-1",children:[s.jsx("button",{type:"button",onClick:()=>i(!0),className:"block rounded-[0.125em] border border-surface-border overflow-hidden hover:border-accent transition-colors",title:"View full size",children:s.jsx("img",{src:o.src,alt:t.replace(/[_-]/g," "),className:"max-h-48 max-w-full object-contain","data-testid":`attachment-image-${t}`})}),r&&s.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:()=>i(!1),role:"dialog","aria-modal":"true","aria-label":`${a} — full size`,children:s.jsx("img",{src:o.src,alt:a,className:"max-h-[90vh] max-w-[90vw] object-contain"})})]})]}):s.jsxs("div",{children:[c,s.jsx("div",{className:"mt-1",children:s.jsxs("a",{href:o.href,...o.isData?{download:`${t}.${o.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-${t}`,children:[s.jsx(Ie,{className:"w-3.5 h-3.5",strokeWidth:1.5}),o.isData?`Download ${o.label}`:`Open ${o.label}`,o.isData?s.jsx(Kt,{className:"w-3 h-3",strokeWidth:1.5}):s.jsx(ut,{className:"w-3 h-3",strokeWidth:1.5})]})})]})}function dr({fieldKey:t,schema:e,escalationContext:n}){const r=(e==null?void 0:e["x-lt-href"])??"",i=r&&n?B(r,n):r,o=(e==null?void 0:e.title)??(e==null?void 0:e.description)??"Open",a=e==null?void 0:e.description,l=i.startsWith("/"),c=!i.trim();return s.jsxs("div",{"data-field-key":t,children:[s.jsx(L,{children:o}),a&&s.jsx(D,{children:a}),s.jsx("div",{className:"mt-1",children:c?s.jsx("span",{className:"text-xs text-text-quaternary italic",children:"No link configured"}):l?s.jsxs(mt,{to:i,className:"inline-flex items-center gap-1 text-xs text-accent hover:text-accent-hover transition-colors","data-testid":`link-widget-${t}`,children:[o,s.jsx(ut,{className:"w-3 h-3 shrink-0",strokeWidth:1.5})]}):s.jsxs("a",{href:i,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-${t}`,children:[o,s.jsx(ut,{className:"w-3 h-3 shrink-0",strokeWidth:1.5})]})})]})}const $t="—";function ur(t,e){if(!t||!e)return"";const n=t.indexOf(".");if(n===-1)return"";const r=t.slice(0,n),i=t.slice(n+1);try{const o=nn(e[r],i);return typeof o=="string"?o:""}catch{return""}}function xr(t,e){if(!t||t===$t)return $t;if(e==="age"){const n=new Date(t);return Number.isNaN(n.getTime())?t:ft(t)}return t}function pr({fieldKey:t,schema:e,escalationContext:n}){const r=e==null?void 0:e["x-lt-source"],i=(e==null?void 0:e["x-lt-fields"])??[],o=(e==null?void 0:e.title)??"Linked escalation",a=e==null?void 0:e.description,l=ur(r,n),{data:c,isLoading:u,isError:d}=ln(l);return s.jsxs("div",{"data-field-key":t,children:[s.jsx(L,{children:o}),a&&s.jsx(D,{children:a}),s.jsx("div",{className:"mt-1",children:!l||d?s.jsx("p",{className:"text-xs text-text-quaternary italic","data-testid":`escalation-widget-empty-${t}`,children:"No linked record"}):u?s.jsx(mr,{}):c?s.jsx(fr,{esc:c,fields:i,fieldKey:t}):s.jsx("p",{className:"text-xs text-text-quaternary italic",children:"No linked record"})})]})}function fr({esc:t,fields:e,fieldKey:n}){if(!t)return null;const r=gt(t);return s.jsxs("div",{className:"border-l-2 border-accent-faint pl-3 py-2 space-y-2","data-testid":`escalation-widget-card-${n}`,children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsxs("span",{className:"text-2xs font-semibold uppercase tracking-wider text-text-secondary",children:[t.type,t.subtype&&t.subtype!==t.type?` · ${t.subtype}`:""]}),s.jsx(wn,{status:t.status})]}),t.description&&s.jsx("p",{className:"text-xs text-text-primary leading-snug",children:t.description}),e.length>0&&s.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-0.5",children:e.map(i=>{const o=B(i.value,r),a=xr(o,i.format);return s.jsxs("div",{className:"contents",children:[s.jsx("dt",{className:"text-2xs text-text-tertiary whitespace-nowrap",children:i.label}),s.jsx("dd",{className:"text-2xs text-text-primary",children:a})]},i.label)})}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"text-2xs text-text-quaternary",children:[t.role," · ",ft(t.created_at)]}),s.jsx(ee,{to:`/escalations/detail/${t.id}`})]})]})}function mr(){return s.jsxs("div",{className:"border-l-2 border-accent-faint pl-3 py-2 space-y-2 animate-pulse",children:[s.jsx("div",{className:"h-3 w-32 bg-surface-sunken rounded"}),s.jsx("div",{className:"h-3 w-48 bg-surface-sunken rounded"}),s.jsx("div",{className:"h-3 w-24 bg-surface-sunken rounded"})]})}function gr(t,e){if(!t)return{};const n={};for(const[r,i]of Object.entries(t))n[r]=typeof i=="string"?B(i,e):i;return n}function br(t,e,n){const r=gr(t.facets,e),i={role:t.role,status:t.status??"pending",facets:r,limit:t.limit,enabled:!!(t.role||Object.keys(r).length)};return t.assigned==="me"?{...i,assigned_to:n,available:!1,enabled:i.enabled&&!!n}:t.assigned==="any"?i:{...i,available:t.available??!0}}const Dt="—";function yr(t,e){if(!t||t===Dt)return Dt;if(e==="age"){const n=new Date(t);return Number.isNaN(n.getTime())?t:ft(t)}return t}function xt(t,e){return typeof t=="string"?B(t,e):Array.isArray(t)?t.map(n=>xt(n,e)):t&&typeof t=="object"?Object.fromEntries(Object.entries(t).map(([n,r])=>[n,xt(r,e)])):t}const hr="continue",jr=[{label:"Description",value:"{{escalation.description}}"},{label:"Role",value:"{{escalation.role}}"},{label:"Age",value:"{{escalation.created_at}}",format:"age"}];function Nr({fieldKey:t,schema:e,escalationContext:n}){const r=(e==null?void 0:e["x-lt-query"])??{},i=(e==null?void 0:e["x-lt-columns"])??jr,o=((e==null?void 0:e["x-lt-actions"])??[]).filter(O=>!(Array.isArray(O.roles)&&O.roles.length>0)),a=(e==null?void 0:e.title)??"Related items",l=e==null?void 0:e.description,c=n??{},{user:u}=cn(),d=br(r,c,u==null?void 0:u.userId),{data:p,isLoading:x}=dn({role:d.role,status:d.status,facets:d.facets,assigned_to:d.assigned_to,available:d.available,limit:d.limit??5,enabled:d.enabled,include:rn({columns:i,actions:o})?"envelope":void 0}),f=(p==null?void 0:p.escalations)??[],b=un(),[m,y]=g.useState({}),[h,A]=g.useState(null),[j,N]=g.useState(null),v=Ks(),I=(O,k)=>{N(null),v(hr,()=>F(O,k))},R=(O,k)=>{k.confirm?N({id:O.id,action:k}):I(O,k)},F=async(O,k)=>{const T=gt(O);A(O.id),y(w=>({...w,[O.id]:""}));try{await b.mutateAsync({id:O.id,resolverPayload:xt(k.resolverPayload,T)})}catch(w){y(M=>({...M,[O.id]:w.message}))}finally{A(null)}};return s.jsxs("div",{"data-field-key":t,children:[s.jsx(L,{children:a}),l&&s.jsx(D,{children:l}),s.jsx("div",{className:"mt-1","data-testid":`escalation-list-widget-${t}`,children:x?s.jsx(kr,{columns:i.length}):s.jsx(vr,{escalations:f,columns:i,fieldKey:t,actions:o,onAction:R,confirming:j,onConfirm:O=>j&&I(O,j.action),onCancel:()=>N(null),pendingRow:h,rowErrors:m})})]})}function vr({escalations:t,columns:e,fieldKey:n,actions:r,onAction:i,confirming:o,onConfirm:a,onCancel:l,pendingRow:c,rowErrors:u}){return t.length===0?s.jsx("p",{className:"text-xs text-text-quaternary italic py-1","data-testid":`escalation-list-empty-${n}`,children:"No items found"}):s.jsxs("table",{className:"w-full text-xs border-collapse","data-testid":`escalation-list-table-${n}`,children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-surface-border",children:[e.map(d=>s.jsx("th",{className:"text-left text-2xs font-semibold uppercase tracking-wider text-text-tertiary pb-1 pr-3 last:pr-0",children:d.label},d.label)),r.length>0&&s.jsx("th",{className:"w-px"}),s.jsx("th",{className:"w-8"})]})}),s.jsx("tbody",{children:t.map(d=>{const p=gt(d),x=u[d.id];return s.jsxs("tr",{className:"border-b border-surface-border/50 last:border-0 hover:bg-surface-sunken/50 transition-colors",children:[e.map(f=>{const b=B(f.value,p),m=yr(b,f.format);return s.jsx("td",{className:"py-1 pr-3 last:pr-0 text-text-primary align-top",children:m},f.label)}),r.length>0&&s.jsxs("td",{className:"py-1 pr-2 align-top whitespace-nowrap",children:[(o==null?void 0:o.id)===d.id?s.jsx(Qs,{message:B(o.action.confirm??"",p),onConfirm:()=>a(d),onCancel:l,testId:`escalation-list-confirm-${d.id}`}):r.map(f=>s.jsx("button",{type:"button",onClick:()=>i(d,f),disabled:c===d.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-${d.id}`,children:f.label},f.label)),x&&s.jsx("p",{className:"text-2xs text-status-error mt-0.5 whitespace-normal max-w-[16rem]","data-testid":`escalation-list-action-error-${d.id}`,children:x})]}),s.jsx("td",{className:"py-1 pl-2 align-top",children:s.jsx(ee,{to:`/escalations/detail/${d.id}`})})]},d.id)})})]})}function kr({columns:t}){return s.jsx("div",{className:"space-y-1.5 animate-pulse",children:[0,1,2].map(e=>s.jsx("div",{className:"flex gap-4",children:Array.from({length:t},(n,r)=>s.jsx("div",{className:"h-3 bg-surface-sunken rounded flex-1"},r))},e))})}function fe(t,e){return{metadata:t??{},...e?{lookup:e}:{}}}const Ar="x-lt-invoke",K={LINK:"link",BUTTON:"button"},Er=/^\{\{\s*([^{}]+?)\s*\}\}$/;function st(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function wr(t){return t===K.LINK||t===K.BUTTON}function Ir(t){const e=t==null?void 0:t[Ar];if(!st(e))return null;const n=e.workflow;if(typeof n!="string"||n.trim().length===0)return null;const r=e.confirm;return{workflow:n.trim(),data:st(e.data)?e.data:{},metadata:st(e.metadata)?e.metadata:{},modal:e.modal===!0,confirm:typeof r=="string"&&r.trim().length>0?r:null,variant:wr(e.variant)?e.variant:K.LINK,icon:e.icon!==!1}}function ot(t,e){if(typeof t=="string"){const n=Er.exec(t);if(n){const r=Q(n[1],e??void 0);return r===null?void 0:r}return rt(t)?pt(t,e??void 0)??void 0:t}if(Array.isArray(t))return t.map(n=>ot(n,e)).filter(n=>n!==void 0);if(st(t)){const n={};for(const[r,i]of Object.entries(t)){const o=ot(i,e);o!==void 0&&(n[r]=o)}return n}return t}function Cr(t,e){return{data:ot(t.data,e),metadata:ot(t.metadata,e)}}const Nt={ACTIVITY:"Activity",ALERT:"AlertTriangle",ARCHIVE:"Archive",AWARD:"Award",BARCODE:"Barcode",BELL:"Bell",BOT:"Bot",BOX:"Box",BOXES:"Boxes",BUILDING:"Building2",CALENDAR:"Calendar",CAMERA:"Camera",CHECKLIST:"ListChecks",CLIPBOARD:"ClipboardList",CLIPBOARD_CHECK:"ClipboardCheck",CLOCK:"Clock",COG:"Cog",CPU:"Cpu",DATABASE:"Database",DOWNLOAD:"Download",DROPLETS:"Droplets",FACTORY:"Factory",FAN:"Fan",FILE:"FileText",FLAG:"Flag",FLAME:"Flame",GAUGE:"Gauge",HAMMER:"Hammer",HEART:"Heart",IMAGE:"Image",KEY:"Key",LAYERS:"Layers",LEAF:"Leaf",LIFEBUOY:"LifeBuoy",LOCK:"Lock",MAIL:"Mail",MAP:"Map",MEGAPHONE:"Megaphone",MESSAGE:"MessageSquare",PACKAGE:"Package",PALETTE:"Palette",PEN:"PenTool",PILL:"Pill",POWER:"Power",PRINTER:"Printer",RECEIPT:"Receipt",RECYCLE:"Recycle",REFRESH:"RefreshCw",ROCKET:"Rocket",ROUTE:"Route",RULER:"Ruler",SCALE:"Scale",SCAN:"ScanBarcode",SCISSORS:"Scissors",SEARCH:"Search",SEND:"Send",SERVER:"Server",SHIELD:"ShieldCheck",SHOPPING_CART:"ShoppingCart",SNOWFLAKE:"Snowflake",SPARKLES:"Sparkles",STAR:"Star",STORE:"Store",SUN:"Sun",TAG:"Tag",TEST_TUBE:"TestTube",THERMOMETER:"Thermometer",TRASH:"Trash2",TRUCK:"Truck",UPLOAD:"Upload",USER:"User",USERS:"Users",WAND:"Wand2",WAREHOUSE:"Warehouse",WIFI:"Wifi",WRENCH:"Wrench",ZAP:"Zap"},Or=new Set(Object.values(Nt));function Tr(t){return typeof t=="string"&&Or.has(t)}const Rr={Activity:Bs,AlertTriangle:Qt,Archive:Vs,Award:Hs,Barcode:qs,Bell:Js,Bot:Gs,Box:Us,Boxes:Ws,Building2:Ps,Calendar:Ds,Camera:$s,ClipboardCheck:Ms,ClipboardList:Fs,Clock:Ss,Cog:_s,Cpu:Ls,Database:Rs,Download:Kt,Droplets:Ts,Factory:Os,Fan:Cs,FileText:Is,Flag:ws,Flame:Es,Gauge:As,Hammer:ks,Heart:vs,Image:Ns,Key:js,Layers:hs,Leaf:ys,LifeBuoy:bs,ListChecks:gs,Lock:Yt,Mail:ms,Map:fs,Megaphone:ps,MessageSquare:xs,Package:us,Palette:ds,PenTool:cs,Pill:ls,Power:as,Printer:os,Receipt:is,Recycle:rs,RefreshCw:ns,Rocket:ss,Route:es,Ruler:ts,Scale:Ze,ScanBarcode:Qe,Scissors:Ke,Search:ze,Send:Ye,Server:Xe,ShieldCheck:Be,ShoppingCart:Ve,Snowflake:He,Sparkles:qe,Star:Je,Store:Ge,Sun:Ue,Tag:We,TestTube:Pe,Thermometer:De,Trash2:$e,Truck:Me,Upload:Fe,User:Se,Users:_e,Wand2:Le,Warehouse:Re,Wifi:Te,Wrench:Oe,Zap:Ce},Pt=Object.values(Nt),Lr=Object.fromEntries(Object.entries(Nt).map(([t,e])=>[e,t]));function _r(t){return Tr(t)?Rr[t]:null}function Ii(t){const e=t.trim().toLowerCase().replace(/[\s_-]+/g,"");return e?Pt.filter(n=>n.toLowerCase().includes(e)||Lr[n].toLowerCase().replace(/_/g,"").includes(e)):[...Pt]}function vt({icon:t,tier:e,className:n,strokeWidth:r=1.5}){const i=_r(t)??Cn[e]??Xs;return s.jsx(i,{className:n,strokeWidth:r,"aria-hidden":!0})}function Sr(t){return`${t.domain}/${t.key} ${t.current||t.version===null?"(current)":`v${t.version}`}`}const S={RUNNING:"running",COMPLETED:"completed",FAILED:"failed"};function Wt(t,e){return`lt.events.system.workflow.${t}.${e}`}function kt(t){const[e,n]=g.useState(S.RUNNING),[r,i]=g.useState(void 0);return g.useEffect(()=>{n(S.RUNNING),i(void 0)},[t]),xn(t?[Wt(t,"completed"),Wt(t,"failed")]:[],o=>{if(o.workflowId!==t)return;const a=o.type.endsWith(".failed");n(a?S.FAILED:S.COMPLETED),i(o.data),o.data===void 0&&pn(`/workflows/${encodeURIComponent(t)}/result`).then(l=>{var c;return i(a?l.error?{error:l.error}:void 0:(c=l.result)==null?void 0:c.data)}).catch(()=>{})}),{outcome:e,payload:r}}const Fr={[S.RUNNING]:"Working…",[S.COMPLETED]:"Completed",[S.FAILED]:"Failed"};function me({outcome:t,className:e=""}){const n=t===S.FAILED?"text-status-error":t===S.COMPLETED?"text-status-success":"text-text-secondary";return s.jsxs("p",{className:`flex items-center gap-1.5 text-xs ${n} ${e}`,role:"status","data-testid":"run-outcome",children:[Fr[t],t===S.RUNNING&&s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent animate-pulse","aria-hidden":!0})]})}function ge({payload:t}){return!t||Object.keys(t).length===0?null:s.jsx("div",{className:"max-h-72 overflow-y-auto px-3 py-2 bg-surface-sunken","data-testid":"run-outline",children:s.jsx(mn,{data:t})})}function Mr({workflowId:t,outcome:e,executionPath:n}){const r=e===S.FAILED?"text-status-error":"text-status-success",i=e===S.RUNNING?"Started":e===S.COMPLETED?"Completed":"Failed";return s.jsxs("p",{className:"flex items-center gap-1.5 text-xs min-w-0",role:"status","data-testid":"started-run",children:[s.jsx("span",{className:r,children:i}),e===S.RUNNING&&s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent animate-pulse","aria-hidden":!0}),s.jsx("span",{className:"text-text-quaternary",children:"·"}),s.jsx("span",{className:"font-mono text-text-secondary truncate",children:t}),n&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-quaternary",children:"·"}),s.jsx(mt,{to:n,className:"text-accent hover:underline shrink-0",children:"View workflow →"})]})]})}function $r({payload:t}){return!t||Object.keys(t).length===0?null:s.jsx("div",{className:"mt-3 h-48 overflow-y-auto rounded-md border border-surface-border bg-surface-raised px-3 py-2","data-testid":"started-run-result",children:s.jsx(fn,{data:t,label:"Result"})})}const Dr="/workflows/executions",W={PAGE:"page",MODAL:"modal"};function be(t,e){const{realIsBuilder:n}=gn(),r=bn(),[i,o]=g.useState(null),[a,l]=g.useState([]),[c,u]=g.useState(null),d=g.useCallback(()=>{o(null),l([]),u(null),r.reset()},[r]);return{submit:g.useCallback(async(x,f)=>{o(null),l([]),u(null);const b={...f};e.certified&&(b.certified=!0);try{const m=await r.mutateAsync({workflowType:t.workflow_type,data:x,metadata:b,...e.overrideBot?{execute_as:e.overrideBot}:{}});u(m.workflowId)}catch(m){m instanceof yn&&Rn(m.body)?(l(m.body.violations),o(m.body.error)):o(m instanceof Error?m.message:"Invocation failed")}},[r,e.certified,e.overrideBot,t.workflow_type]),reset:d,pending:r.isPending,error:i,violations:a,startedId:c,executionPath:c&&n?`${Dr}/${encodeURIComponent(c)}`:null}}function At(){const{connected:t}=hn();return t?null:s.jsxs("p",{className:"flex items-center gap-1.5 text-2xs text-status-warning","data-testid":"events-warning",children:[s.jsx(Ys,{className:"w-3 h-3 shrink-0",strokeWidth:1.5}),"Live events are off, so the result will not appear here.",s.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"text-accent hover:underline",children:"Reconnect events"})]})}const Pr={[W.PAGE]:"sticky bottom-0 z-10 bg-surface border-t border-surface-border/40 pt-3 pb-16 -mb-16",[W.MODAL]:"border-t border-surface-border/40 pt-3"};function ye({onSubmit:t,onSubmitAgain:e,pending:n,error:r,issueCount:i=0,onShowIssues:o,startedId:a,executionPath:l,host:c=W.PAGE}){const u=c===W.PAGE,d=kt(u?a??"":""),p=u&&a!==null;return s.jsxs("div",{className:Pr[c],children:[s.jsxs("div",{className:"flex items-center justify-between gap-6 min-h-9",children:[s.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[s.jsx(At,{}),i>0&&o?s.jsxs("button",{type:"button",onClick:o,className:"flex items-center gap-1.5 text-xs text-status-error hover:underline","data-testid":"invoke-issues",children:[s.jsx(at,{className:"w-3.5 h-3.5",strokeWidth:1.5}),i," ",i===1?"issue":"issues"," to resolve"]}):r?s.jsx("p",{className:"text-xs text-status-error",role:"alert",children:r}):null,p&&s.jsx(Mr,{workflowId:a,outcome:d.outcome,executionPath:l})]}),s.jsx("div",{className:"shrink-0",children:p?s.jsx("button",{type:"button",onClick:e,className:"text-xs text-accent hover:underline","data-testid":"invoke-again",children:"Submit again"}):s.jsx("button",{type:"button",onClick:t,disabled:n,className:"btn-primary px-8 py-2","data-testid":"invoke-start",children:n?"Submitting…":"Submit"})})]}),p&&d.outcome!==S.RUNNING&&s.jsx($r,{payload:d.payload})]})}const tt="invoke-help",Wr=380,G={INSTRUCTIONS:"instructions",ISSUES:"issues"};function Ur({view:t,onViewChange:e,onClose:n,helpMarkdown:r,errors:i,schema:o}){const a=[];r&&a.push({id:G.INSTRUCTIONS,icon:Zt,label:"Instructions",content:s.jsx(z,{content:r})}),a.push({id:G.ISSUES,icon:at,label:"Issues",content:s.jsx(ae,{errors:i,schema:o})});const l=a.some(c=>c.id===t)?t:a[0].id;return s.jsx(Nn,{views:a,activeId:l,onViewChange:c=>e(c),onClose:n,stickyClassName:"h-full min-h-0",labelInline:!0})}function Gr({schema:t,context:e,errors:n,enabled:r=!0}){const i=jn(),o=r?i==null?void 0:i.setPanel:void 0,a=r?i==null?void 0:i.closePanel:void 0,l=(i==null?void 0:i.ownerKey)??null,c=(i==null?void 0:i.open)??!1,[u,d]=g.useState(null),p=g.useMemo(()=>on(t,e),[t,e]),x=g.useCallback(()=>{d(null),a==null||a(tt)},[a]);g.useEffect(()=>{!o||!u||o(s.jsx(Ur,{view:u,onViewChange:d,onClose:x,helpMarkdown:p,errors:n,schema:t}),{key:tt,width:Wr})},[o,u,p,n,t,x]),g.useEffect(()=>{u&&c&&l&&l!==tt&&d(null)},[u,c,l]);const f=g.useRef(a);return f.current=a,g.useEffect(()=>()=>{var b;(b=f.current)==null||b.call(f,tt)},[]),{helpMarkdown:p,hasInstructions:!!p,open:u!==null,showInstructions:()=>d(G.INSTRUCTIONS),showIssues:()=>d(G.ISSUES),close:x}}function Jr({selected:t,schema:e,metadata:n,lookup:r,submission:i,lead:o,prefill:a,host:l=W.PAGE}){const c=l===W.MODAL,[u,d]=g.useState(()=>Ot(e,a)),[p,x]=g.useState(!1),[f,b]=g.useState([]),[m,y]=g.useState(null),[h,A]=g.useState(null);g.useEffect(()=>{d(Ot(e,a)),x(!1),b([]),y(null),A(null),i.reset()},[t.workflow_type]);const j=g.useMemo(()=>({...fe(n,r),resolver:null}),[n,r]),N=g.useMemo(()=>{try{const w=JSON.parse(u);return{...j,resolver:w,input:w}}catch{return j}},[u,j]);g.useEffect(()=>{p&&b(Ft(u,j).errors)},[u,p,j]);const v=f.length>0?f:i.violations,I=Gr({schema:e,context:N,errors:v,enabled:!c}),R=c?()=>A(G.ISSUES):I.showIssues,F=c?()=>A(w=>w===G.INSTRUCTIONS?null:G.INSTRUCTIONS):I.showInstructions;g.useEffect(()=>{i.violations.length>0&&R()},[i.violations]);const O=()=>{x(!0);const w=Ft(u,j);if(w.parseError){y(w.parseError);return}if(y(null),w.errors.length>0){b(w.errors),R();return}b([]),i.submit(w.payload,n)},k=c&&h===G.ISSUES&&v.length>0,T=c&&h===G.INSTRUCTIONS&&I.helpMarkdown;return s.jsxs("div",{"data-testid":"rich-invoke-form",children:[s.jsxs("div",{className:"space-y-6 pb-6",children:[o,T&&s.jsx("div",{className:"px-4 py-3 bg-surface-hover","data-testid":"invoke-inline-help",children:s.jsx(z,{content:I.helpMarkdown})}),s.jsx(ui,{value:u,onChange:d,submitAttempted:p,escalationContext:j,onOpenHelp:I.hasInstructions?F:void 0}),k&&s.jsx("div",{"data-testid":"invoke-inline-issues",children:s.jsx(ae,{errors:v,schema:e})})]}),s.jsx(ye,{onSubmitAgain:i.reset,onSubmit:O,pending:i.pending,error:m??i.error,issueCount:v.length,onShowIssues:R,startedId:i.startedId,executionPath:i.executionPath,host:l})]})}const Ut=`{
2
- "data": {},
3
- "metadata": {}
4
- }`;function qr(t){return typeof t=="boolean"?"boolean":typeof t=="number"?"number":Array.isArray(t)?"array":t!==null&&typeof t=="object"?"object":"string"}function Gt(t){if(!t)return[];const e=t.data;return!e||typeof e!="object"?[]:Object.entries(e).map(([n,r])=>({key:n,type:qr(r),defaultValue:r}))}function ct(t){return{...t}}function Jt(t,e){return JSON.stringify({data:t,metadata:e},null,2)}function Hr({selectedConfig:t,isJsonMode:e,hasFormView:n,jsonInput:r,formFields:i,dataFields:o,onJsonChange:a,onToggleMode:l,onUpdateFormField:c,onSetFormFields:u}){return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-baseline justify-between mb-2",children:[s.jsx("label",{className:"block text-xs text-text-secondary",children:"Envelope"}),s.jsxs("div",{className:"flex items-center gap-3",children:[n&&s.jsx("button",{type:"button",onClick:l,className:"text-2xs text-accent hover:underline",children:e?"Form view":"JSON view"}),t.envelope_schema?s.jsx("span",{className:"text-2xs text-accent",children:"Pre-filled from workflow config"}):s.jsx("span",{className:"text-2xs text-status-warning",children:"No template"})]})]}),!t.envelope_schema&&s.jsx("div",{className:"bg-surface-sunken border border-surface-border rounded px-4 py-3 mb-3",children:s.jsxs("p",{className:"text-xs text-text-secondary leading-relaxed",children:["This workflow has no input template. Edit the JSON directly below, or ",s.jsx(mt,{to:"/workflows/registry/new",className:"text-status-success hover:underline",children:"register it"})," in the Workflow Registry with an envelope schema for pre-filled fields and form-based input."]})}),e||!n?s.jsx("textarea",{value:r,onChange:d=>a(d.target.value),className:"input-json",rows:12,spellCheck:!1}):s.jsx("div",{className:"space-y-3",children:o.map(({key:d,type:p})=>{var m,y;const x=i[d],f=typeof x=="string"?x:JSON.stringify(x??(p==="array"?[]:{}),null,2),b=Math.min(20,Math.max(4,((y=(m=f==null?void 0:f.split)==null?void 0:m.call(f,`
5
- `))==null?void 0:y.length)??4));return s.jsxs("div",{children:[s.jsxs("label",{className:"block text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[d,s.jsx("span",{className:"ml-2 font-normal normal-case",children:p})]}),p==="boolean"?s.jsxs("select",{value:String(x??!1),onChange:h=>c(d,h.target.value,p),className:"select text-xs w-full",children:[s.jsx("option",{value:"true",children:"true"}),s.jsx("option",{value:"false",children:"false"})]}):p==="object"||p==="array"?s.jsx("textarea",{value:f,onChange:h=>{try{c(d,JSON.parse(h.target.value),p)}catch{u({...i,[d]:h.target.value})}},className:"input-json w-full",rows:b,spellCheck:!1}):s.jsx("input",{type:p==="number"?"number":"text",value:String(x??""),onChange:h=>c(d,h.target.value,p),className:"input text-xs w-full"})]},d)})}),s.jsxs("p",{className:"text-2xs text-text-tertiary mt-1.5",children:["The envelope wraps your workflow input. ",s.jsx("code",{className:"text-accent/80",children:"data"})," holds workflow-specific fields; ",s.jsx("code",{className:"text-accent/80",children:"metadata"})," is optional context."]})]})}const qt="lt:invoke:prefill";function Vr({selected:t,metadata:e,submission:n,lead:r,prefill:i,host:o=W.PAGE}){const[a,l]=g.useState(Ut),[c,u]=g.useState(""),[d,p]=g.useState({}),[x,f]=g.useState(!1),b=g.useMemo(()=>{const N=t.envelope_schema??null;if(!i||Object.keys(i).length===0)return N;const v=N==null?void 0:N.data,I={...v&&typeof v=="object"?v:{},...i};return{...N??{},data:I}},[t.envelope_schema,i]),m=g.useMemo(()=>Gt(b),[b]),y=m.length>0;g.useEffect(()=>{u(""),n.reset();const N=o===W.PAGE?sessionStorage.getItem(qt):null;if(N){sessionStorage.removeItem(qt),l(N);try{const I=JSON.parse(N),R=(I==null?void 0:I.data)??I;R&&typeof R=="object"&&p(ct(R))}catch{}f(!0);return}l(b?JSON.stringify(b,null,2):Ut);const v=b==null?void 0:b.data;p(v&&typeof v=="object"?ct(v):{}),f(!Gt(b).length)},[t.workflow_type]);const h=()=>{if(x)try{const N=JSON.parse(a);N.data&&typeof N.data=="object"&&p(ct(N.data))}catch{}else l(Jt(d,e));f(!x)},A=(N,v,I)=>{let R=v;I==="number"?R=v===""?0:Number(v):I==="boolean"&&(R=v==="true"||v===!0);const F={...d,[N]:R};p(F),l(Jt(F,e))},j=()=>{u("");let N;try{N=JSON.parse(a)}catch{u("Invalid JSON");return}const{data:v,metadata:I}=N;if(!v||typeof v!="object"){u('Envelope must include a "data" object');return}n.submit(v,I??{})};return s.jsxs("div",{children:[s.jsxs("div",{className:"space-y-6 pb-6",children:[r,s.jsx(Hr,{selectedConfig:t,isJsonMode:x,hasFormView:y,jsonInput:a,formFields:d,dataFields:m,onJsonChange:N=>{l(N),u("")},onToggleMode:h,onUpdateFormField:A,onSetFormFields:p})]}),s.jsx(ye,{onSubmitAgain:n.reset,onSubmit:j,pending:n.pending,error:c||n.error,startedId:n.startedId,executionPath:n.executionPath,host:o})]})}function Br({workflow:t,workflowId:e,onDone:n,onRetry:r}){var c;const i=kt(e),o=i.outcome===S.FAILED,a=i.outcome===S.RUNNING,l=o&&typeof((c=i.payload)==null?void 0:c.error)=="string"?i.payload.error:null;return s.jsxs("div",{className:"flex flex-col gap-4","data-testid":"run-receipt","data-outcome":i.outcome,children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(vt,{icon:t.icon,tier:t.tier,className:"w-6 h-6 shrink-0 text-accent"}),s.jsx(me,{outcome:i.outcome,className:"text-sm"})]}),a&&s.jsx(At,{}),l&&s.jsx("p",{className:"text-xs text-status-error",role:"alert",children:l}),!a&&s.jsx(ge,{payload:l?void 0:i.payload}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-surface-border/40",children:[o&&s.jsx("button",{type:"button",onClick:r,className:"btn-secondary text-xs","data-testid":"run-retry",children:"Try again"}),s.jsx("button",{type:"button",onClick:n,className:"btn-primary text-xs px-6","data-testid":"run-done",children:a||o?"Close":"Done"})]})]})}function he(t,e){var r;const n=(r=t.envelope_schema)==null?void 0:r.metadata;return{...n&&typeof n=="object"?n:{},...e}}function Xr({workflow:t,prefill:e,onClose:n}){const r=g.useMemo(()=>he(t,e.metadata),[t,e.metadata]),i=Array.isArray(t.input_lookups)&&t.input_lookups.length>0,{data:o}=vn(t.workflow_type,i),a=g.useMemo(()=>o?kn(o.lookups):void 0,[o]),l=(o==null?void 0:o.lookups.filter(p=>p.missing))??[],c=be(t,{certified:t.certified,overrideBot:""}),u=t.description?s.jsx(z,{content:t.description,className:"text-xs text-text-secondary leading-relaxed"}):void 0,d=c.startedId!==null;return s.jsxs("div",{"data-testid":"invoke-modal",children:[d&&s.jsx(Br,{workflow:t,workflowId:c.startedId,onDone:n,onRetry:c.reset}),s.jsxs("div",{hidden:d,children:[l.length>0&&s.jsxs("p",{className:"flex items-center gap-1.5 text-2xs text-status-warning mb-4","data-testid":"lookup-missing",children:[s.jsx(Qt,{className:"w-3 h-3 shrink-0",strokeWidth:1.5}),l.map(Sr).join(", ")," ",l.length===1?"is":"are"," not available; the fields that read ",l.length===1?"it":"them"," fall back to plain inputs."]}),t.input_schema?s.jsx(Jr,{selected:t,schema:t.input_schema,metadata:r,lookup:a,submission:c,lead:u,prefill:e.data,host:W.MODAL}):s.jsx(Vr,{selected:t,metadata:r,submission:c,lead:u,prefill:e.data,host:W.MODAL})]})]})}function Yr({open:t,onClose:e,workflow:n,prefill:r}){const i=s.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(vt,{icon:n.icon,tier:n.tier,className:"w-4 h-4 shrink-0 text-accent"}),s.jsx("span",{className:"truncate",title:n.workflow_type,children:re(n.workflow_type)})]});return s.jsx(ne,{open:t,onClose:e,title:i,maxWidth:"max-w-2xl",closeOnBackdrop:!1,children:s.jsx(Xr,{workflow:n,prefill:r,onClose:e})})}const zr={[K.LINK]:"inline-flex items-center gap-1.5 text-xs text-accent hover:text-accent-hover transition-colors",[K.BUTTON]:"btn-secondary inline-flex items-center gap-1.5 text-xs px-3 py-1.5"};function Kr({fieldKey:t,schema:e,escalationContext:n}){var u;const r=g.useMemo(()=>Ir(e),[e]),{data:i,isPending:o}=An(),a=i==null?void 0:i.find(d=>d.workflow_type===(r==null?void 0:r.workflow)),l=(u=n==null?void 0:n.escalation)==null?void 0:u.status,c=l!==void 0&&l!==In.PENDING;return!r||c?null:o?s.jsx("div",{className:"h-4 w-32 rounded bg-surface-hover animate-pulse","data-testid":`invoke-widget-${t}-loading`}):a?s.jsx(Qr,{fieldKey:t,schema:e,config:r,workflow:a,escalationContext:n}):null}function Qr({fieldKey:t,schema:e,config:n,workflow:r,escalationContext:i}){var k;const o=i,a=g.useMemo(()=>Cr(n,o),[n,o]),l=g.useMemo(()=>he(r,a.metadata),[r,a.metadata]),c=be(r,{certified:r.certified,overrideBot:""}),u=kt(c.startedId??""),[d,p]=g.useState([]),[x,f]=g.useState(!1),[b,m]=g.useState(!1),y=(e==null?void 0:e.title)??re(r.workflow_type),h=e==null?void 0:e.description,A=n.icon?s.jsx(vt,{icon:r.icon,tier:r.tier,className:"w-3.5 h-3.5 shrink-0"}):null,j=()=>{f(!1),c.submit(a.data,l)},N=()=>{if(n.modal){m(!0);return}if(p([]),r.input_schema){const T=Qn(r.input_schema,a.data,fe(l));if(T.length>0){p(T);return}}n.confirm?f(!0):j()},v=()=>{p([]),c.reset(),m(!0)},I=d.length>0?d:c.violations,R=c.startedId!==null,F=R&&u.outcome===S.RUNNING,O=R&&u.outcome===S.FAILED&&typeof((k=u.payload)==null?void 0:k.error)=="string"?u.payload.error:null;return s.jsxs("div",{"data-field-key":t,"data-testid":`invoke-widget-${t}`,children:[s.jsx(L,{children:y}),h&&s.jsx(D,{children:h}),s.jsxs("div",{className:"mt-1 flex flex-col gap-1.5",children:[R&&s.jsxs(s.Fragment,{children:[s.jsx(me,{outcome:u.outcome}),F&&s.jsx(At,{}),O&&s.jsx("p",{className:"text-2xs text-status-error",role:"alert",children:O}),!F&&s.jsx(ge,{payload:O?void 0:u.payload})]}),!F&&s.jsxs("button",{type:"button",onClick:N,disabled:c.pending,className:`self-start ${zr[n.variant]}`,"data-testid":`invoke-control-${t}`,children:[A,c.pending?"Starting…":y]}),I.length>0&&s.jsxs("div",{className:"text-2xs",role:"alert","data-testid":`invoke-issues-${t}`,children:[s.jsx("ul",{className:"space-y-0.5 text-status-error",children:I.map(T=>s.jsxs("li",{className:"flex items-start gap-1.5",children:[s.jsx(at,{className:"w-3 h-3 mt-px shrink-0",strokeWidth:1.5}),s.jsxs("span",{children:[s.jsx("span",{className:"font-semibold",children:T.field})," · ",T.message]})]},T.field))}),s.jsx("button",{type:"button",onClick:v,className:"mt-1 text-accent hover:underline","data-testid":`invoke-open-form-${t}`,children:"Open form"})]}),I.length===0&&c.error&&s.jsx("p",{className:"text-2xs text-status-error",role:"alert",children:c.error})]}),n.confirm&&s.jsxs(ne,{open:x,onClose:()=>f(!1),title:y,children:[s.jsx("p",{className:"text-sm text-text-secondary mb-5",children:B(n.confirm,i??{})}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{type:"button",onClick:()=>f(!1),className:"btn-secondary text-xs",children:"Cancel"}),s.jsx("button",{type:"button",onClick:j,className:"btn-primary text-xs","data-testid":`invoke-confirm-${t}`,children:y})]})]}),s.jsx(Yr,{open:b,onClose:()=>m(!1),workflow:r,prefill:a})]})}const nt={"file-upload":er,"code-editor":sr,signature:nr,"rich-text":rr,markdown:ir,checklist:ar,attachment:Mt,image:Mt,link:dr,escalation:pr,"escalation-list":Nr,invoke:Kr,roster:Zs},je="textarea",Ne="json";function Zr(t){return t in nt||t===je||t===Ne}function Ht(t,e=""){if(!t||typeof t!="object"||Array.isArray(t))return[];const n=t,r=[],i=n["x-lt-widget"];typeof i=="string"&&e&&!Zr(i)&&r.push({path:e,widget:i});const o=n.properties;if(o&&typeof o=="object"&&!Array.isArray(o))for(const[a,l]of Object.entries(o))r.push(...Ht(l,e?`${e}.${a}`:a));return n.items&&r.push(...Ht(n.items,e)),r}const ti=new Set(["string","number","integer","boolean","array","object"]);function ei(t,e){const n=t==null?void 0:t.type;if(typeof n=="string"&&ti.has(n))return n;if(e==null)return"null";if(Array.isArray(e))return"array";const r=typeof e;return r==="number"||r==="boolean"||r==="string"?r:"object"}const dt="dictionary",si=new Set(["markdown","attachment","image"]);function ve(t,e){if(!e)return;const n=t==null?void 0:t["x-lt-section-options"],r=n==null?void 0:n[e];return r&&typeof r=="object"?r:void 0}function ni(t,e,n){var l,c;const r=(l=t==null?void 0:t.properties)==null?void 0:l[n];if((r==null?void 0:r.readOnly)!==!0)return!1;const i=r==null?void 0:r["x-lt-widget"];if(typeof i=="string"&&(si.has(i)||an(i)))return!1;const o=r==null?void 0:r["x-lt-display"];if(typeof o=="string")return o===dt;const a=(c=ve(t,e))==null?void 0:c.display;return typeof a=="string"?a===dt:(t==null?void 0:t["x-lt-display"])===dt}function ri(t,e,n,r){var o;const i=[];for(const a of t){const[l]=a,c=i[i.length-1];if(ni(e,n,l)){(c==null?void 0:c.kind)==="dictionary"?c.entries.push(a):i.push({kind:"dictionary",entries:[a]});continue}const u=(o=e==null?void 0:e.properties)==null?void 0:o[l],d=u==null?void 0:u["x-lt-column-group"];if(r==="two-column"&&typeof d=="string"&&d.trim()){(c==null?void 0:c.kind)==="column-group"&&c.name===d?c.entries.push(a):i.push({kind:"column-group",name:d,entries:[a]});continue}i.push({kind:"field",entry:a})}return i}function ii({value:t,options:e,nullable:n,fieldKey:r,label:i,helperText:o,isRequired:a,error:l,onBlur:c,ids:u,ariaProps:d,onChange:p}){const x=t==null||t===""?"":String(t),f=e.some(b=>String(b.value)===x);return s.jsxs("div",{children:[s.jsx(L,{isRequired:a,htmlFor:u.field,children:i}),o&&s.jsx(D,{id:u.help,children:o}),s.jsxs("select",{value:f?x:"",disabled:e.length===0,onChange:b=>{const m=e.find(y=>String(y.value)===b.target.value);p(m?m.value:null),c==null||c()},onBlur:c,"data-field-key":r,className:tn(!!l),...d,children:[(!f||n)&&s.jsx("option",{value:"",disabled:!n,children:"Choose…"}),e.map(b=>s.jsx("option",{value:String(b.value),children:b.label},String(b.value)))]}),s.jsx(P,{error:l,id:u.error})]})}function oi({value:t,options:e,fieldKey:n,label:r,helperText:i,isRequired:o,error:a,onBlur:l,ids:c,ariaProps:u,onChange:d}){const p=new Set(Array.isArray(t)?t:[]),x=f=>{const b=new Set(p);b.has(f)?b.delete(f):b.add(f),d(e.filter(m=>b.has(m.value)).map(m=>m.value)),l==null||l()};return s.jsxs("div",{role:"group","aria-label":r,"aria-required":o||void 0,"aria-invalid":a?!0:void 0,"aria-describedby":u["aria-describedby"],children:[s.jsx(L,{isRequired:o,children:r}),i&&s.jsx(D,{id:c.help,children:i}),e.length===0?s.jsx("p",{className:"text-xs text-text-tertiary italic mt-1",children:"No options yet"}):s.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map((f,b)=>{const m=p.has(f.value);return s.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)] ${m?"bg-accent border-accent text-text-inverse":a?"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:[s.jsx("input",{type:"checkbox",checked:m,onChange:()=>x(f.value),className:"sr-only","data-testid":`multi-select-${n}-${String(f.value)}`,...b===0?{"data-field-key":n,id:c.field}:{}}),m&&s.jsx(zt,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:2.5}),f.label]},String(f.value))})}),s.jsx(P,{error:a,id:c.error})]})}function Vt(t){return typeof t=="string"?t:t==null?"":JSON.stringify(t,null,2)}function Bt(t){try{return{ok:!0,value:JSON.parse(t)}}catch{return{ok:!1}}}function ai({value:t,fieldKey:e,label:n,helperText:r,isRequired:i,error:o,onBlur:a,ids:l,ariaProps:c,onChange:u}){const[d,p]=g.useState(()=>Vt(t));g.useEffect(()=>{if(typeof t=="string"){t!==d&&p(t);return}const f=Bt(d);!(f.ok&&JSON.stringify(f.value)===JSON.stringify(t??null))&&!(d.trim()===""&&t===null)&&p(Vt(t))},[t]);const x=d.split(`
6
- `).length;return s.jsxs("div",{children:[s.jsx(L,{isRequired:i,htmlFor:l.field,children:n}),r&&s.jsx(D,{id:l.help,children:r}),s.jsx("textarea",{value:d,onChange:f=>{const b=f.target.value;if(p(b),b.trim()===""){u(null);return}const m=Bt(b);u(m.ok?m.value:b)},onBlur:a,spellCheck:!1,"data-field-key":e,rows:Math.min(14,Math.max(4,x)),className:`${Y(!!o)} font-mono text-xs leading-relaxed`,...c}),s.jsx(P,{error:o,id:l.error})]})}function li({fieldKey:t,label:e,values:n,fieldSchema:r,helperText:i,isRequired:o,error:a,ids:l,notice:c,context:u,onChange:d}){const p=X(r),x=p?Dn(r,u):null,f=(p==null?void 0:p.prompt)??i,b=m=>d(n.filter((y,h)=>h!==m));return s.jsxs("div",{"data-field-key":t,tabIndex:p?-1:void 0,className:"outline-none",children:[s.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[s.jsx(L,{isRequired:o,children:e}),x!==null&&s.jsxs("span",{className:"text-2xs tabular-nums text-text-tertiary","data-testid":"list-field-count",children:[n.length," of ",x]})]}),i&&(n.length>0||!p)&&s.jsx(D,{id:l.help,children:i}),n.length===0&&p?s.jsx("p",{id:l.help,className:"text-xs text-text-tertiary mt-1 italic","data-testid":"list-field-empty",children:f??"Scan to add"}):s.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:n.map((m,y)=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-2xs font-mono bg-surface-sunken rounded text-text-secondary",children:[String(m),p&&s.jsx("button",{type:"button",onClick:()=>b(y),className:"-mr-1 p-0.5 rounded text-text-quaternary hover:text-status-error hover:bg-surface-hover","aria-label":`Remove ${String(m)}`,"data-testid":"list-field-remove",children:s.jsx(zs,{className:"w-3 h-3",strokeWidth:2})})]},y))}),s.jsx(P,{error:a,id:l.error}),s.jsx(oe,{notice:c})]})}const Xt={date:"date","date-time":"datetime-local",email:"email",uri:"url"},ci={date:"max-w-48","date-time":"max-w-64"};function ke({fieldKey:t,value:e,onChange:n,onBlur:r,schema:i,isRequired:o,isReadOnly:a,error:l,escalationContext:c,submitAttempted:u}){var O;const d=(O=i==null?void 0:i.properties)==null?void 0:O[t],p=On(t),x=J(t,d),f=d==null?void 0:d["x-lt-widget"],b=ei(d,e),m=`lt-field-${t}`,y={field:m,help:`${m}-help`,error:`${m}-error`},h=typeof(d==null?void 0:d.description)=="string"&&d.description.length>0?d.description:void 0,A={id:m,"aria-required":o||void 0,"aria-invalid":l?!0:void 0,"aria-describedby":l?y.error:h?y.help:void 0},j={fieldKey:t,label:x,helperText:h,isRequired:o,error:l,onBlur:r,ids:y,ariaProps:A,onChange:n},N=f==="markdown"&&typeof e=="string",v=(f==="attachment"||f==="image")&&typeof e=="string",I=!!(f&&f in nt);if(a&&!N&&!v&&!I){const k=e===null?"null":typeof e=="object"?JSON.stringify(e,null,2):String(e);return s.jsxs("div",{children:[s.jsx(L,{isRequired:o,children:x}),s.jsx("p",{className:"text-sm text-text-secondary mt-0.5 whitespace-pre-wrap",children:k})]})}if(f===Ne&&(b==="array"||b==="object"))return s.jsx(ai,{...j,value:e});if(f&&f in nt){const k=nt[f],T=o||(d==null?void 0:d["x-lt-require-all"])===!0,w={fieldKey:t,schema:d,escalationContext:c,isRequired:T,submitAttempted:u,error:l};if((d==null?void 0:d.type)==="object"){const M=typeof e=="string"?e:typeof e=="object"&&e!==null&&!Array.isArray(e)?JSON.stringify(e):"";return s.jsx(k,{...w,value:M,onChange:V=>{try{n(JSON.parse(V))}catch{n(V)}}})}if(typeof e=="string")return s.jsx(k,{...w,value:e,onChange:M=>n(M)});if(typeof e=="object"&&e!==null&&!Array.isArray(e))return s.jsx(k,{...w,value:JSON.stringify(e),onChange:M=>{try{n(JSON.parse(M))}catch{n(M)}}})}const R=bt(d,c);if(b==="array"){if(R!==void 0&&(d==null?void 0:d["x-lt-options"])!==void 0)return s.jsx(oi,{...j,value:e,options:R})}else if(R!==void 0&&b!=="object")return s.jsx(ii,{...j,value:e,options:R,nullable:(d==null?void 0:d["x-lt-nullable"])===!0});switch(b){case"boolean":return s.jsxs("div",{children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:e===!0,onChange:k=>{n(k.target.checked),r==null||r()},className:"w-3.5 h-3.5 rounded accent-accent","data-field-key":t,...A}),s.jsxs("span",{className:"text-2xs font-semibold uppercase tracking-wider text-text-secondary",children:[x,o&&s.jsx("span",{className:"text-status-error ml-0.5",children:"*"})]})]}),h&&s.jsx(D,{id:y.help,children:h}),s.jsx(P,{error:l,id:y.error})]});case"number":case"integer":return s.jsxs("div",{children:[s.jsx(L,{isRequired:o,htmlFor:m,children:x}),h&&s.jsx(D,{id:y.help,children:h}),s.jsx("input",{type:"number",value:typeof e=="number"||typeof e=="string"?e:"",onChange:k=>n(parseFloat(k.target.value)||0),onBlur:r,step:"any","data-field-key":t,className:`${Y(!!l)} max-w-48`,...A}),s.jsx(P,{error:l,id:y.error})]});case"string":return F(typeof e=="string"?e:e==null?"":String(e));case"array":return!Array.isArray(e)&&!(e==null&&X(d))?F(e==null?"":String(e)):s.jsx(li,{fieldKey:t,label:x,values:Array.isArray(e)?e:[],fieldSchema:d,helperText:h,isRequired:o,error:l,ids:y,notice:p,context:c,onChange:n});case"object":{if(typeof e!="object"||e===null||Array.isArray(e))return F(e==null?"":String(e));const k=Object.entries(e);return s.jsxs("div",{children:[s.jsx(L,{isRequired:o,children:x}),s.jsx("div",{className:"ml-4 mt-2 pl-4 border-l border-accent-faint space-y-3",children:k.map(([T,w])=>s.jsx(ke,{fieldKey:T,value:w,onChange:M=>n({...e,[T]:M})},T))})]})}default:return s.jsxs("div",{children:[s.jsx(L,{isRequired:o,children:x}),s.jsx("p",{className:"text-xs text-text-tertiary italic mt-1",children:"null"})]})}function F(k){const T=d==null?void 0:d.format;if(T==="password")return s.jsxs("div",{children:[s.jsx(L,{isRequired:o,htmlFor:m,children:x}),h&&s.jsx(D,{id:y.help,children:h}),s.jsx("input",{type:"password",value:k,onChange:w=>n(w.target.value),onBlur:r,"data-field-key":t,className:Y(!!l),autoComplete:"off",...A}),s.jsx(P,{error:l,id:y.error})]});if(T&&T in Xt)return s.jsxs("div",{children:[s.jsx(L,{isRequired:o,htmlFor:m,children:x}),h&&s.jsx(D,{id:y.help,children:h}),s.jsx("input",{type:Xt[T],value:k,onChange:w=>n(w.target.value),onBlur:r,"data-field-key":t,className:`${Y(!!l)} ${ci[T]??""}`,...A}),s.jsx(P,{error:l,id:y.error})]});if(T==="textarea"||f===je||k.includes(`
7
- `)||k.length>80){const w=d==null?void 0:d.maxLength,M=d==null?void 0:d["x-lt-max-length"],V=M?Number(Q(M,c)):NaN,U=w??(Number.isFinite(V)?V:void 0),lt=U!==void 0&&k.length>U;return s.jsxs("div",{children:[s.jsx(L,{isRequired:o,htmlFor:m,children:x}),h&&s.jsx(D,{id:y.help,children:h}),s.jsx("textarea",{value:k,onChange:Z=>{n(Z.target.value),r==null||r()},onBlur:r,"data-field-key":t,className:`${Y(!!l)} leading-relaxed`,rows:Math.min(6,Math.max(3,Math.ceil(k.length/60))),...A}),U!==void 0&&s.jsxs("p",{className:`text-2xs mt-0.5 text-right tabular-nums ${lt?"text-status-error font-medium":"text-text-quaternary"}`,children:[k.length," / ",U]}),s.jsx(P,{error:l,id:y.error})]})}return s.jsxs("div",{children:[s.jsx(L,{isRequired:o,htmlFor:m,children:x}),h&&s.jsx(D,{id:y.help,children:h}),s.jsx("input",{type:"text",value:k,onChange:w=>n(w.target.value),onBlur:r,"data-field-key":t,className:Y(!!l),...A}),s.jsx(P,{error:l,id:y.error}),s.jsx(oe,{notice:p})]})}}function di({name:t,entries:e,formSchema:n,layout:r,renderField:i}){const o=ri(e,n,t,r),a=ve(n,t),l=(a==null?void 0:a.columns)??(r==="two-column"?2:1),c=d=>d.map(([p,x])=>{var f;return{key:p,label:J(p,(f=n==null?void 0:n.properties)==null?void 0:f[p]),value:x}}),u=()=>o.map((d,p)=>d.kind==="dictionary"?s.jsx("div",{className:r==="two-column"?"col-span-full":"",children:s.jsx(En,{items:c(d.entries),columns:l})},`dict-${p}`):d.kind==="column-group"?s.jsx("div",{className:"@container",children:s.jsx("div",{className:"grid grid-cols-1 @grp-cols:grid-cols-2 gap-x-4 gap-y-5",children:d.entries.map(x=>i(x))})},`group-${d.name}-${p}`):i(d.entry));return s.jsxs("div",{className:t?"border border-surface-border bg-surface-sunken rounded-[var(--lt-radius-section)] p-4 animate-[section-enter_0.25s_ease-out]":"",children:[t&&s.jsx("p",{className:"mb-4 text-[1.40625rem] font-semibold tracking-wider text-heading [font-variant-caps:small-caps]",children:t}),r==="two-column"?s.jsx("div",{className:"@container",children:s.jsx("div",{className:"grid grid-cols-1 @form-cols:grid-cols-2 gap-x-col-gap gap-y-5",children:u()})}):s.jsx("div",{className:"space-y-5",children:u()})]})}function ui({value:t,onChange:e,disabled:n,submitAttempted:r,escalationContext:i,onOpenHelp:o,onDisabledClick:a,disabledHint:l}){var Et,wt;const[c,u]=g.useState({}),[d,p]=g.useState({}),[x,f]=g.useState(null),[b,m]=g.useState(!1),[y,h]=g.useState(new Set);g.useEffect(()=>{try{const E=JSON.parse(t);if(typeof E=="object"&&E!==null&&!Array.isArray(E)){const _={},C={};for(const[$,q]of Object.entries(E))$.startsWith("_")||$.startsWith("$")?C[$]=q:_[$]=q;u(_),p(C),f(C._form_schema&&typeof C._form_schema=="object"?C._form_schema:null),m(!1)}}catch{m(!0)}},[t]);const A=g.useCallback(E=>{u(E),e(JSON.stringify({...E,...d},null,2))},[d,e]),j=g.useCallback((E,_)=>{A({...c,[E]:_})},[c,A]),N=g.useCallback(E=>{h(_=>{if(_.has(E))return _;const C=new Set(_);return C.add(E),C})},[]);if(b)return s.jsx("p",{className:"text-xs text-status-error",children:"Unable to parse resolver data as form. Use the JSON editor below."});const v=Object.entries(c);if(v.length===0)return s.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No resolver fields defined."});const I=x==null?void 0:x["x-lt-order"],R=I?[...v].sort((E,_)=>{const C=I.indexOf(E[0]),$=I.indexOf(_[0]);return(C===-1?1/0:C)-($===-1?1/0:$)}):v,F={...i??{},resolver:c,input:c},O=R.filter(([E,_])=>{var $;const C=($=x==null?void 0:x.properties)==null?void 0:$[E];return te(C)||!et(C==null?void 0:C["x-lt-showIf"],F)?!1:!en(C,_)}),k=new Set((x==null?void 0:x.required)??[]),T=x==null?void 0:x["x-lt-layout"],w=x==null?void 0:x.title,M=x==null?void 0:x.description,V=typeof(x==null?void 0:x["x-lt-help"])=="string"||typeof(x==null?void 0:x["x-lt-context"])=="string",U=[];for(const E of O){const[_]=E,C=(Et=x==null?void 0:x.properties)==null?void 0:Et[_],$=((wt=C==null?void 0:C["x-lt-section"])==null?void 0:wt.trim())||null,q=U[U.length-1];!q||q.name!==$?U.push({name:$,entries:[E]}):q.entries.push(E)}const lt=([E,_])=>{var Ct;const C=(Ct=x==null?void 0:x.properties)==null?void 0:Ct[E],$=(C==null?void 0:C.readOnly)===!0,q=(C==null?void 0:C["x-lt-span"])??1,It=k.has(E),Ae=y.has(E)||!!r,Ee=xe(_,C,It,Ae,F);return s.jsx("div",{className:`animate-[field-enter_0.2s_ease-out] ${T==="two-column"&&q>=2?"col-span-full":""}`,children:s.jsx(ke,{fieldKey:E,value:_,onChange:we=>j(E,we),onBlur:()=>N(E),schema:x,isRequired:It,isReadOnly:$,error:Ee,escalationContext:F,submitAttempted:!!r})},E)},Z=s.jsxs("div",{className:n?"pointer-events-none":void 0,inert:n||void 0,"aria-disabled":n||void 0,children:[w&&s.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[s.jsx("h3",{className:"heading-3",children:w}),V&&o&&s.jsx("button",{type:"button",onClick:o,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:s.jsx(Zt,{className:"w-4 h-4",strokeWidth:1.5})})]}),M&&s.jsx("p",{className:"text-sm text-text-secondary leading-relaxed mb-6",children:M}),s.jsx("div",{className:"space-y-8",children:U.map((E,_)=>s.jsx(di,{name:E.name,entries:E.entries,formSchema:x,layout:T,renderField:lt},E.name??`__s${_}`))})]});return n?s.jsx(tr,{hint:l,onLockedClick:a,children:Z}):s.jsx("div",{className:"pb-8 max-w-form",children:Z})}export{ae as E,vi as F,Vr as L,ui as R,vt as W,ki as a,Ft as b,Ot as c,J as d,Jr as e,fe as f,Ii as g,_r as h,Rn as i,Ht as j,Sr as l,Ai as p,br as r,wi as s,be as u,pe as v,Ei as w};
8
- //# sourceMappingURL=ResolverForm-DfogHDzl.js.map