@hotmeshio/long-tail 0.10.13 → 0.11.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.
- package/README.md +2 -4
- package/build/api/escalations/analytics.d.ts +6 -0
- package/build/api/escalations/analytics.js +123 -0
- package/build/api/escalations/index.d.ts +1 -0
- package/build/api/escalations/index.js +4 -1
- package/build/api/escalations/metadata.js +1 -1
- package/build/api/escalations/resolve.js +4 -4
- package/build/api/roles.d.ts +4 -0
- package/build/api/roles.js +8 -0
- package/build/api/scan-codes/choice.d.ts +11 -0
- package/build/api/scan-codes/choice.js +136 -0
- package/build/api/scan-codes/context.d.ts +24 -0
- package/build/api/scan-codes/context.js +86 -0
- package/build/api/scan-codes/execute.d.ts +1 -0
- package/build/api/scan-codes/execute.js +49 -244
- package/build/api/scan-codes/identity.d.ts +18 -0
- package/build/api/scan-codes/identity.js +116 -0
- package/build/api/scan-codes/index.d.ts +2 -0
- package/build/api/scan-codes/index.js +6 -1
- package/build/api/scan-codes/locate.d.ts +14 -0
- package/build/api/scan-codes/locate.js +127 -0
- package/build/api/scan-codes/present.d.ts +9 -0
- package/build/api/scan-codes/present.js +59 -0
- package/build/api/scan-codes/verbs.d.ts +15 -0
- package/build/api/scan-codes/verbs.js +205 -0
- package/build/bin/ltc.js +33 -0
- package/build/lib/cli/commands/escalations.d.ts +31 -0
- package/build/lib/cli/commands/escalations.js +88 -0
- package/build/lib/db/schemas/028_role_entity_facet.sql +18 -0
- package/build/lib/db/schemas/029_scan_scheme_kind.sql +31 -0
- package/build/modules/config.d.ts +5 -0
- package/build/modules/config.js +12 -0
- package/build/routes/escalations/acting.d.ts +12 -0
- package/build/routes/escalations/acting.js +25 -0
- package/build/routes/escalations/analytics.d.ts +8 -0
- package/build/routes/escalations/analytics.js +63 -0
- package/build/routes/escalations/index.js +3 -0
- package/build/routes/escalations/resolve.js +8 -1
- package/build/routes/escalations/single.js +13 -4
- package/build/routes/roles.js +1 -1
- package/build/routes/scan-codes.js +28 -2
- package/build/scripts/ortho-populate.js +14 -0
- package/build/scripts/printer-cycle.d.ts +25 -0
- package/build/scripts/printer-cycle.js +169 -0
- package/build/scripts/twin-farm.js +19 -5
- package/build/sdk/index.d.ts +2 -0
- package/build/sdk/index.js +3 -0
- package/build/services/escalation/aggregate-sql.d.ts +36 -0
- package/build/services/escalation/aggregate-sql.js +253 -0
- package/build/services/escalation/aggregate-validate.d.ts +57 -0
- package/build/services/escalation/aggregate-validate.js +218 -0
- package/build/services/escalation/aggregates.d.ts +26 -0
- package/build/services/escalation/aggregates.js +204 -0
- package/build/services/escalation/client.js +57 -21
- package/build/services/escalation/facet-sql.js +17 -0
- package/build/services/escalation/index.d.ts +2 -0
- package/build/services/escalation/index.js +8 -1
- package/build/services/escalation/metrics-cache.d.ts +18 -0
- package/build/services/escalation/metrics-cache.js +47 -1
- package/build/services/escalation/queries.js +2 -0
- package/build/services/escalation/resolver-validation.d.ts +1 -1
- package/build/services/escalation/resolver-validation.js +12 -5
- package/build/services/escalation/submit-guard.d.ts +29 -0
- package/build/services/escalation/submit-guard.js +57 -0
- package/build/services/iam/acting-identity.d.ts +16 -0
- package/build/services/iam/acting-identity.js +60 -0
- package/build/services/role/index.js +2 -0
- package/build/services/role/sql.d.ts +10 -2
- package/build/services/role/sql.js +14 -1
- package/build/services/role/types.d.ts +16 -0
- package/build/services/scan-code/read.js +4 -0
- package/build/services/scan-code/sql.d.ts +4 -4
- package/build/services/scan-code/sql.js +14 -8
- package/build/services/scan-code/validate.d.ts +2 -0
- package/build/services/scan-code/validate.js +86 -0
- package/build/services/scan-code/write.d.ts +4 -0
- package/build/services/scan-code/write.js +16 -2
- package/build/services/user/crud.d.ts +6 -0
- package/build/services/user/crud.js +16 -0
- package/build/services/user/index.d.ts +1 -1
- package/build/services/user/index.js +2 -1
- package/build/services/user/sql.d.ts +8 -0
- package/build/services/user/sql.js +9 -1
- package/build/shared/form-validation/index.d.ts +4 -0
- package/build/shared/form-validation/index.js +4 -0
- package/build/shared/form-validation/x-lt-labels.d.ts +28 -0
- package/build/shared/form-validation/x-lt-labels.js +42 -0
- package/build/shared/form-validation/x-lt-query.d.ts +56 -0
- package/build/shared/form-validation/x-lt-query.js +49 -0
- package/build/shared/form-validation/x-lt-submit-guard.d.ts +46 -0
- package/build/shared/form-validation/x-lt-submit-guard.js +25 -0
- package/build/shared/form-validation/x-lt-submit-on-claim.d.ts +22 -0
- package/build/shared/form-validation/x-lt-submit-on-claim.js +28 -0
- package/build/system/mcp-servers/admin/escalations.js +34 -0
- package/build/system/mcp-servers/admin/scan-codes.js +17 -1
- package/build/system/mcp-servers/admin/schemas.d.ts +643 -25
- package/build/system/mcp-servers/admin/schemas.js +127 -19
- package/build/system/mcp-servers/admin/users.js +3 -1
- package/build/system/mcp-servers/human-queue-schemas.d.ts +2 -2
- package/build/system/seed/tool-manifests-admin.d.ts +2283 -0
- package/build/system/seed/tool-manifests-admin.js +8 -5
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types/analytics.d.ts +154 -0
- package/build/types/analytics.js +14 -0
- package/build/types/facets.d.ts +13 -0
- package/build/types/index.d.ts +5 -2
- package/build/types/index.js +5 -1
- package/build/types/scan-choice.d.ts +49 -0
- package/build/types/scan-choice.js +9 -0
- package/build/types/scan-code.d.ts +72 -1
- package/build/types/scan-code.js +30 -1
- package/dashboard/dist/assets/{AdminDashboard-Bv3pHBzn.js → AdminDashboard-DJ3LJQ09.js} +2 -2
- package/dashboard/dist/assets/{AdminDashboard-Bv3pHBzn.js.map → AdminDashboard-DJ3LJQ09.js.map} +1 -1
- package/dashboard/dist/assets/{AgentConfigPage-Dk2zlvDb.js → AgentConfigPage-BMMvaD0z.js} +2 -2
- package/dashboard/dist/assets/{AgentConfigPage-Dk2zlvDb.js.map → AgentConfigPage-BMMvaD0z.js.map} +1 -1
- package/dashboard/dist/assets/{AgentDetailPage-DUno6EGs.js → AgentDetailPage-C6wfsnRe.js} +2 -2
- package/dashboard/dist/assets/{AgentDetailPage-DUno6EGs.js.map → AgentDetailPage-C6wfsnRe.js.map} +1 -1
- package/dashboard/dist/assets/AgentsPage-Cwqka7nE.js +2 -0
- package/dashboard/dist/assets/{AgentsPage-CToVu1qj.js.map → AgentsPage-Cwqka7nE.js.map} +1 -1
- package/dashboard/dist/assets/AvailableEscalationsPage-CVlG_AVC.js +2 -0
- package/dashboard/dist/assets/AvailableEscalationsPage-CVlG_AVC.js.map +1 -0
- package/dashboard/dist/assets/{BotPicker-DQOpVB4M.js → BotPicker-BBkJBXZB.js} +2 -2
- package/dashboard/dist/assets/{BotPicker-DQOpVB4M.js.map → BotPicker-BBkJBXZB.js.map} +1 -1
- package/dashboard/dist/assets/{CapabilitiesPage-Dmf46PUJ.js → CapabilitiesPage-wxmE4917.js} +2 -2
- package/dashboard/dist/assets/{CapabilitiesPage-Dmf46PUJ.js.map → CapabilitiesPage-wxmE4917.js.map} +1 -1
- package/dashboard/dist/assets/{CollapsibleSection-CDADefUY.js → CollapsibleSection-B3FsrHwH.js} +2 -2
- package/dashboard/dist/assets/{CollapsibleSection-CDADefUY.js.map → CollapsibleSection-B3FsrHwH.js.map} +1 -1
- package/dashboard/dist/assets/CountdownTimer-B3nCqJdC.js +2 -0
- package/dashboard/dist/assets/CountdownTimer-B3nCqJdC.js.map +1 -0
- package/dashboard/dist/assets/{CredentialsPage-8LIEvomi.js → CredentialsPage-Bv875IHe.js} +2 -2
- package/dashboard/dist/assets/{CredentialsPage-8LIEvomi.js.map → CredentialsPage-Bv875IHe.js.map} +1 -1
- package/dashboard/dist/assets/{CronLabel-CK3WSsM5.js → CronLabel-CSzjWuwj.js} +2 -2
- package/dashboard/dist/assets/{CronLabel-CK3WSsM5.js.map → CronLabel-CSzjWuwj.js.map} +1 -1
- package/dashboard/dist/assets/{CustomDurationPicker-FPmlA6cE.js → CustomDurationPicker-CCpqf3e4.js} +2 -2
- package/dashboard/dist/assets/{CustomDurationPicker-FPmlA6cE.js.map → CustomDurationPicker-CCpqf3e4.js.map} +1 -1
- package/dashboard/dist/assets/{DropZone-CL9gA7pu.js → DropZone-CJkk-U3o.js} +2 -2
- package/dashboard/dist/assets/{DropZone-CL9gA7pu.js.map → DropZone-CJkk-U3o.js.map} +1 -1
- package/dashboard/dist/assets/{ElapsedCell-BZVkVxE0.js → ElapsedCell-WV6pUaKo.js} +2 -2
- package/dashboard/dist/assets/{ElapsedCell-BZVkVxE0.js.map → ElapsedCell-WV6pUaKo.js.map} +1 -1
- package/dashboard/dist/assets/EntityTimelinePanel-DrL86Yrf.js +2 -0
- package/dashboard/dist/assets/EntityTimelinePanel-DrL86Yrf.js.map +1 -0
- package/dashboard/dist/assets/{EscalationListSchemaPage-kYLdUtZX.js → EscalationListSchemaPage-CTQCALw4.js} +3 -3
- package/dashboard/dist/assets/{EscalationListSchemaPage-kYLdUtZX.js.map → EscalationListSchemaPage-CTQCALw4.js.map} +1 -1
- package/dashboard/dist/assets/{EscalationSchemaPage-kUmCDivo.js → EscalationSchemaPage-D_UgP0pv.js} +3 -3
- package/dashboard/dist/assets/{EscalationSchemaPage-kUmCDivo.js.map → EscalationSchemaPage-D_UgP0pv.js.map} +1 -1
- package/dashboard/dist/assets/{EscalationsOverview-D17auO-m.js → EscalationsOverview-DuIUyxr0.js} +2 -2
- package/dashboard/dist/assets/{EscalationsOverview-D17auO-m.js.map → EscalationsOverview-DuIUyxr0.js.map} +1 -1
- package/dashboard/dist/assets/EventTable-BV6unphX.js +2 -0
- package/dashboard/dist/assets/EventTable-BV6unphX.js.map +1 -0
- package/dashboard/dist/assets/FilterBar-DYFgzXNB.js +2 -0
- package/dashboard/dist/assets/FilterBar-DYFgzXNB.js.map +1 -0
- package/dashboard/dist/assets/{GraphInvokePage-D11uOnZi.js → GraphInvokePage-BGHVUipJ.js} +2 -2
- package/dashboard/dist/assets/{GraphInvokePage-D11uOnZi.js.map → GraphInvokePage-BGHVUipJ.js.map} +1 -1
- package/dashboard/dist/assets/HomePage-B-S2cK3E.js +2 -0
- package/dashboard/dist/assets/{HomePage-Bcq10Bxx.js.map → HomePage-B-S2cK3E.js.map} +1 -1
- package/dashboard/dist/assets/ListToolbar-Bl7F3A28.js +2 -0
- package/dashboard/dist/assets/{ListToolbar-IPXsTb3Q.js.map → ListToolbar-Bl7F3A28.js.map} +1 -1
- package/dashboard/dist/assets/{McpOverview-Dx2j0KkF.js → McpOverview-_T9IsCD_.js} +2 -2
- package/dashboard/dist/assets/{McpOverview-Dx2j0KkF.js.map → McpOverview-_T9IsCD_.js.map} +1 -1
- package/dashboard/dist/assets/{McpQueryDetailPage-CzF_bna8.js → McpQueryDetailPage-DtsVqKPw.js} +2 -2
- package/dashboard/dist/assets/{McpQueryDetailPage-CzF_bna8.js.map → McpQueryDetailPage-DtsVqKPw.js.map} +1 -1
- package/dashboard/dist/assets/McpQueryPage-DX5u-1bx.js +2 -0
- package/dashboard/dist/assets/{McpQueryPage-CNsuiw_q.js.map → McpQueryPage-DX5u-1bx.js.map} +1 -1
- package/dashboard/dist/assets/McpRunDetailPage-BhcqqtYS.js +2 -0
- package/dashboard/dist/assets/McpRunDetailPage-BhcqqtYS.js.map +1 -0
- package/dashboard/dist/assets/{McpRunsPage-CK96s3Nt.js → McpRunsPage-L-1y8wnX.js} +2 -2
- package/dashboard/dist/assets/{McpRunsPage-CK96s3Nt.js.map → McpRunsPage-L-1y8wnX.js.map} +1 -1
- package/dashboard/dist/assets/{NamespacePill-B9Vc_Pz2.js → NamespacePill-in1SLd0W.js} +2 -2
- package/dashboard/dist/assets/{NamespacePill-B9Vc_Pz2.js.map → NamespacePill-in1SLd0W.js.map} +1 -1
- package/dashboard/dist/assets/OperationsPage-i8KcDpKo.js +3 -0
- package/dashboard/dist/assets/OperationsPage-i8KcDpKo.js.map +1 -0
- package/dashboard/dist/assets/OperatorDashboard-CIbDzOlh.js +2 -0
- package/dashboard/dist/assets/{OperatorDashboard-C-jE0IRA.js.map → OperatorDashboard-CIbDzOlh.js.map} +1 -1
- package/dashboard/dist/assets/{PageHeader-Ce4GcIYo.js → PageHeader-BJgWMZtw.js} +2 -2
- package/dashboard/dist/assets/{PageHeader-Ce4GcIYo.js.map → PageHeader-BJgWMZtw.js.map} +1 -1
- package/dashboard/dist/assets/{PageHeaderWithStats-Ck0KZvXD.js → PageHeaderWithStats-Ccio4vyG.js} +2 -2
- package/dashboard/dist/assets/{PageHeaderWithStats-Ck0KZvXD.js.map → PageHeaderWithStats-Ccio4vyG.js.map} +1 -1
- package/dashboard/dist/assets/{PersonaDetailPage-CJ6jqo7h.js → PersonaDetailPage-BOaf0TW1.js} +2 -2
- package/dashboard/dist/assets/{PersonaDetailPage-CJ6jqo7h.js.map → PersonaDetailPage-BOaf0TW1.js.map} +1 -1
- package/dashboard/dist/assets/{PersonasPage-D8hL3kL5.js → PersonasPage-DSdRb90f.js} +2 -2
- package/dashboard/dist/assets/{PersonasPage-D8hL3kL5.js.map → PersonasPage-DSdRb90f.js.map} +1 -1
- package/dashboard/dist/assets/{ProcessDetailPage-Vnx8Z5_y.js → ProcessDetailPage-DN9NqfeP.js} +2 -2
- package/dashboard/dist/assets/{ProcessDetailPage-Vnx8Z5_y.js.map → ProcessDetailPage-DN9NqfeP.js.map} +1 -1
- package/dashboard/dist/assets/{ProcessesListPage-DRYtvS3N.js → ProcessesListPage-CfQEWaD4.js} +2 -2
- package/dashboard/dist/assets/{ProcessesListPage-DRYtvS3N.js.map → ProcessesListPage-CfQEWaD4.js.map} +1 -1
- package/dashboard/dist/assets/RoleDetailPage-BC5HL7ls.js +8 -0
- package/dashboard/dist/assets/RoleDetailPage-BC5HL7ls.js.map +1 -0
- package/dashboard/dist/assets/{RolePill-CnuBPhPw.js → RolePill-BNAP-uK6.js} +2 -2
- package/dashboard/dist/assets/{RolePill-CnuBPhPw.js.map → RolePill-BNAP-uK6.js.map} +1 -1
- package/dashboard/dist/assets/RolesPage-DCnW0VmD.js +2 -0
- package/dashboard/dist/assets/RolesPage-DCnW0VmD.js.map +1 -0
- package/dashboard/dist/assets/RunAsSelector-twbuX7fB.js +2 -0
- package/dashboard/dist/assets/{RunAsSelector-CS3KQ-BF.js.map → RunAsSelector-twbuX7fB.js.map} +1 -1
- package/dashboard/dist/assets/ScanCodesPage-CPNg6K--.js +2 -0
- package/dashboard/dist/assets/ScanCodesPage-CPNg6K--.js.map +1 -0
- package/dashboard/dist/assets/ScanSchemeDetailPage-DyLmCamO.js +2 -0
- package/dashboard/dist/assets/ScanSchemeDetailPage-DyLmCamO.js.map +1 -0
- package/dashboard/dist/assets/ScanStationPage-DoZccU5B.js +2 -0
- package/dashboard/dist/assets/ScanStationPage-DoZccU5B.js.map +1 -0
- package/dashboard/dist/assets/{ScopeBadge-BUpYpS3x.js → ScopeBadge-BG7KkZ8Q.js} +2 -2
- package/dashboard/dist/assets/{ScopeBadge-BUpYpS3x.js.map → ScopeBadge-BG7KkZ8Q.js.map} +1 -1
- package/dashboard/dist/assets/SegmentedTabs-DXNzY05q.js +2 -0
- package/dashboard/dist/assets/SegmentedTabs-DXNzY05q.js.map +1 -0
- package/dashboard/dist/assets/StickyPagination-DIeYMPPd.js +2 -0
- package/dashboard/dist/assets/StickyPagination-DIeYMPPd.js.map +1 -0
- package/dashboard/dist/assets/{StreamMessageDetail-DyJyZwBl.js → StreamMessageDetail-gU4CUeQI.js} +2 -2
- package/dashboard/dist/assets/{StreamMessageDetail-DyJyZwBl.js.map → StreamMessageDetail-gU4CUeQI.js.map} +1 -1
- package/dashboard/dist/assets/{SwimlaneTimeline-BlzV74V5.js → SwimlaneTimeline-Br-nBA4l.js} +2 -2
- package/dashboard/dist/assets/{SwimlaneTimeline-BlzV74V5.js.map → SwimlaneTimeline-Br-nBA4l.js.map} +1 -1
- package/dashboard/dist/assets/{TagInput-BbZ25nNe.js → TagInput-CvM5n6ww.js} +2 -2
- package/dashboard/dist/assets/{TagInput-BbZ25nNe.js.map → TagInput-CvM5n6ww.js.map} +1 -1
- package/dashboard/dist/assets/{TaskDetailPage-B0p_Z4J_.js → TaskDetailPage-_9cr_R0u.js} +2 -2
- package/dashboard/dist/assets/{TaskDetailPage-B0p_Z4J_.js.map → TaskDetailPage-_9cr_R0u.js.map} +1 -1
- package/dashboard/dist/assets/{TaskQueuePill-D0QKBrN3.js → TaskQueuePill-D4JPHXOq.js} +2 -2
- package/dashboard/dist/assets/{TaskQueuePill-D0QKBrN3.js.map → TaskQueuePill-D4JPHXOq.js.map} +1 -1
- package/dashboard/dist/assets/{TasksListPage-CiGR2QiQ.js → TasksListPage-DVENC9Jp.js} +2 -2
- package/dashboard/dist/assets/{TasksListPage-CiGR2QiQ.js.map → TasksListPage-DVENC9Jp.js.map} +1 -1
- package/dashboard/dist/assets/{TimeAgo-D_DA9ucC.js → TimeAgo-C9yYnOui.js} +2 -2
- package/dashboard/dist/assets/{TimeAgo-D_DA9ucC.js.map → TimeAgo-C9yYnOui.js.map} +1 -1
- package/dashboard/dist/assets/{TimestampCell-C7rkC9nh.js → TimestampCell-DoB8cYgw.js} +2 -2
- package/dashboard/dist/assets/{TimestampCell-C7rkC9nh.js.map → TimestampCell-DoB8cYgw.js.map} +1 -1
- package/dashboard/dist/assets/{ToolPill-8xY9rkoc.js → ToolPill-BUjbC-Tj.js} +2 -2
- package/dashboard/dist/assets/{ToolPill-8xY9rkoc.js.map → ToolPill-BUjbC-Tj.js.map} +1 -1
- package/dashboard/dist/assets/{ToolTestPanel-E8efYGYs.js → ToolTestPanel-CBtsIP8K.js} +2 -2
- package/dashboard/dist/assets/{ToolTestPanel-E8efYGYs.js.map → ToolTestPanel-CBtsIP8K.js.map} +1 -1
- package/dashboard/dist/assets/{TopicDetailPage-B455XrRc.js → TopicDetailPage-mR4Jaz83.js} +4 -4
- package/dashboard/dist/assets/{TopicDetailPage-B455XrRc.js.map → TopicDetailPage-mR4Jaz83.js.map} +1 -1
- package/dashboard/dist/assets/TopicsPage-CP7HFxIC.js +2 -0
- package/dashboard/dist/assets/{TopicsPage-1VAc29Qw.js.map → TopicsPage-CP7HFxIC.js.map} +1 -1
- package/dashboard/dist/assets/{UserName-DikzjQHJ.js → UserName-BnLF6yhz.js} +2 -2
- package/dashboard/dist/assets/{UserName-DikzjQHJ.js.map → UserName-BnLF6yhz.js.map} +1 -1
- package/dashboard/dist/assets/WorkflowExecutionPage-xL956RZi.js +2 -0
- package/dashboard/dist/assets/WorkflowExecutionPage-xL956RZi.js.map +1 -0
- package/dashboard/dist/assets/{WorkflowPill-Da406nEj.js → WorkflowPill-tXU0-eXu.js} +2 -2
- package/dashboard/dist/assets/{WorkflowPill-Da406nEj.js.map → WorkflowPill-tXU0-eXu.js.map} +1 -1
- package/dashboard/dist/assets/WorkflowsDashboard-B-u7zFKM.js +2 -0
- package/dashboard/dist/assets/{WorkflowsDashboard-BMQd_0tW.js.map → WorkflowsDashboard-B-u7zFKM.js.map} +1 -1
- package/dashboard/dist/assets/{WorkflowsOverview-CdxjVifp.js → WorkflowsOverview-CqZVarK-.js} +2 -2
- package/dashboard/dist/assets/{WorkflowsOverview-CdxjVifp.js.map → WorkflowsOverview-CqZVarK-.js.map} +1 -1
- package/dashboard/dist/assets/{YamlWorkflowDetailPage-DNVffIXa.js → YamlWorkflowDetailPage-DiFLavW0.js} +10 -10
- package/dashboard/dist/assets/{YamlWorkflowDetailPage-DNVffIXa.js.map → YamlWorkflowDetailPage-DiFLavW0.js.map} +1 -1
- package/dashboard/dist/assets/{YamlWorkflowsPage-BGP8wuos.js → YamlWorkflowsPage-BuQM6uZA.js} +2 -2
- package/dashboard/dist/assets/{YamlWorkflowsPage-BGP8wuos.js.map → YamlWorkflowsPage-BuQM6uZA.js.map} +1 -1
- package/dashboard/dist/assets/{agents-BZJLIJ4h.js → agents-DU9GPovp.js} +2 -2
- package/dashboard/dist/assets/{agents-BZJLIJ4h.js.map → agents-DU9GPovp.js.map} +1 -1
- package/dashboard/dist/assets/{bots-ClLcDGJb.js → bots-Cy-Hmg7w.js} +2 -2
- package/dashboard/dist/assets/{bots-ClLcDGJb.js.map → bots-Cy-Hmg7w.js.map} +1 -1
- package/dashboard/dist/assets/capabilities-sSJJqrp-.js +2 -0
- package/dashboard/dist/assets/{capabilities-IaCcS7ge.js.map → capabilities-sSJJqrp-.js.map} +1 -1
- package/dashboard/dist/assets/{controlplane-Zi4m_MSx.js → controlplane-TVCjDHQ-.js} +2 -2
- package/dashboard/dist/assets/{controlplane-Zi4m_MSx.js.map → controlplane-TVCjDHQ-.js.map} +1 -1
- package/dashboard/dist/assets/escalation-columns-BpkjKYGd.js +2 -0
- package/dashboard/dist/assets/escalation-columns-BpkjKYGd.js.map +1 -0
- package/dashboard/dist/assets/index-5TblaCXQ.css +1 -0
- package/dashboard/dist/assets/index-7BP6FaCZ.js +2 -0
- package/dashboard/dist/assets/{index-Dldi3Q3M.js.map → index-7BP6FaCZ.js.map} +1 -1
- package/dashboard/dist/assets/{index-BzkE48xJ.js → index-B7IaBPBg.js} +4 -4
- package/dashboard/dist/assets/{index-BzkE48xJ.js.map → index-B7IaBPBg.js.map} +1 -1
- package/dashboard/dist/assets/index-BE0phFw0.js +2 -0
- package/dashboard/dist/assets/{index-CLmZaNTK.js.map → index-BE0phFw0.js.map} +1 -1
- package/dashboard/dist/assets/{index-BqGnhkh0.js → index-BYNN9N1T.js} +2 -2
- package/dashboard/dist/assets/{index-BqGnhkh0.js.map → index-BYNN9N1T.js.map} +1 -1
- package/dashboard/dist/assets/{index-kiKZresb.js → index-CLPVqbVY.js} +2 -2
- package/dashboard/dist/assets/{index-kiKZresb.js.map → index-CLPVqbVY.js.map} +1 -1
- package/dashboard/dist/assets/{index-C3o4OisO.js → index-Cfv86_L9.js} +2 -2
- package/dashboard/dist/assets/{index-C3o4OisO.js.map → index-Cfv86_L9.js.map} +1 -1
- package/dashboard/dist/assets/{index-yGNt29V9.js → index-CtwbQ_-m.js} +2 -2
- package/dashboard/dist/assets/{index-yGNt29V9.js.map → index-CtwbQ_-m.js.map} +1 -1
- package/dashboard/dist/assets/index-DOai950R.js +3 -0
- package/dashboard/dist/assets/index-DOai950R.js.map +1 -0
- package/dashboard/dist/assets/index-DTtHNC-D.js +5 -0
- package/dashboard/dist/assets/{index-CvNBdkB1.js.map → index-DTtHNC-D.js.map} +1 -1
- package/dashboard/dist/assets/{index-CJu2PBNx.js → index-DsWnVyVN.js} +2 -2
- package/dashboard/dist/assets/{index-CJu2PBNx.js.map → index-DsWnVyVN.js.map} +1 -1
- package/dashboard/dist/assets/{index-D0zFReGL.js → index-Dy-MMYti.js} +2 -2
- package/dashboard/dist/assets/{index-D0zFReGL.js.map → index-Dy-MMYti.js.map} +1 -1
- package/dashboard/dist/assets/index-errgQT5x.js +65 -0
- package/dashboard/dist/assets/index-errgQT5x.js.map +1 -0
- package/dashboard/dist/assets/{index-CmnNqpWg.js → index-fgBDhnI6.js} +2 -2
- package/dashboard/dist/assets/{index-CmnNqpWg.js.map → index-fgBDhnI6.js.map} +1 -1
- package/dashboard/dist/assets/{knowledge-DWLxGTib.js → knowledge-arh4NfmL.js} +2 -2
- package/dashboard/dist/assets/{knowledge-DWLxGTib.js.map → knowledge-arh4NfmL.js.map} +1 -1
- package/dashboard/dist/assets/{mcp-B6AARZ2I.js → mcp-QGf5jHCo.js} +2 -2
- package/dashboard/dist/assets/{mcp-B6AARZ2I.js.map → mcp-QGf5jHCo.js.map} +1 -1
- package/dashboard/dist/assets/{mcp-query-DrkvBU3a.js → mcp-query-BEJN1nMZ.js} +2 -2
- package/dashboard/dist/assets/{mcp-query-DrkvBU3a.js.map → mcp-query-BEJN1nMZ.js.map} +1 -1
- package/dashboard/dist/assets/{personas-Cmz2SAEU.js → personas-DYtw1COf.js} +2 -2
- package/dashboard/dist/assets/{personas-Cmz2SAEU.js.map → personas-DYtw1COf.js.map} +1 -1
- package/dashboard/dist/assets/{pipelines-CSgfVCMy.js → pipelines-Byi6PnbE.js} +2 -2
- package/dashboard/dist/assets/{pipelines-CSgfVCMy.js.map → pipelines-Byi6PnbE.js.map} +1 -1
- package/dashboard/dist/assets/{tasks-UOtUkDk-.js → tasks-D0SQdENz.js} +2 -2
- package/dashboard/dist/assets/{tasks-UOtUkDk-.js.map → tasks-D0SQdENz.js.map} +1 -1
- package/dashboard/dist/assets/{topics-Df5hGh6o.js → topics-DgDv5ZXP.js} +2 -2
- package/dashboard/dist/assets/{topics-Df5hGh6o.js.map → topics-DgDv5ZXP.js.map} +1 -1
- package/dashboard/dist/assets/useEventHooks-DZaYzE7s.js +2 -0
- package/dashboard/dist/assets/{useEventHooks-PDbuSJ12.js.map → useEventHooks-DZaYzE7s.js.map} +1 -1
- package/dashboard/dist/assets/{useNamespace-tZSOlge3.js → useNamespace-C1OqiNXN.js} +2 -2
- package/dashboard/dist/assets/{useNamespace-tZSOlge3.js.map → useNamespace-C1OqiNXN.js.map} +1 -1
- package/dashboard/dist/assets/{useYamlActivityEvents-CINLzE32.js → useYamlActivityEvents-CkmXDm-Z.js} +2 -2
- package/dashboard/dist/assets/{useYamlActivityEvents-CINLzE32.js.map → useYamlActivityEvents-CkmXDm-Z.js.map} +1 -1
- package/dashboard/dist/assets/{users-G8qwyZKS.js → users-D4DCFPH1.js} +2 -2
- package/dashboard/dist/assets/{users-G8qwyZKS.js.map → users-D4DCFPH1.js.map} +1 -1
- package/dashboard/dist/assets/{vendor-icons-BpZiWH2f.js → vendor-icons-BxuyFxH2.js} +156 -136
- package/dashboard/dist/assets/vendor-icons-BxuyFxH2.js.map +1 -0
- package/dashboard/dist/assets/{workflows-DbPqi1TW.js → workflows-qyc0ku_5.js} +2 -2
- package/dashboard/dist/assets/{workflows-DbPqi1TW.js.map → workflows-qyc0ku_5.js.map} +1 -1
- package/dashboard/dist/assets/{yaml-workflows-DozD8hpR.js → yaml-workflows-DWFww9Xn.js} +2 -2
- package/dashboard/dist/assets/{yaml-workflows-DozD8hpR.js.map → yaml-workflows-DWFww9Xn.js.map} +1 -1
- package/dashboard/dist/index.html +3 -3
- package/docs/api/http/escalations.md +133 -0
- package/docs/api/http/roles.md +6 -0
- package/docs/api/mcp/admin.md +53 -0
- package/docs/api/sdk/escalations.md +58 -0
- package/docs/cli.md +11 -0
- package/docs/dashboard.md +22 -20
- package/docs/data.md +12 -4
- package/docs/design-principles.md +9 -7
- package/docs/escalation-analytics.md +251 -0
- package/docs/hitl/roles.md +1 -1
- package/docs/hitl/x-lt-embed.md +8 -4
- package/docs/hitl/x-lt-footer.md +67 -0
- package/docs/hitl/x-lt-list-schema.md +10 -3
- package/docs/hitl-guide.md +11 -2
- package/docs/iam.md +12 -0
- package/docs/operations.md +17 -0
- package/docs/scan-codes.md +112 -0
- package/docs/sdk.md +1 -1
- package/package.json +2 -1
- package/dashboard/dist/assets/AgentsPage-CToVu1qj.js +0 -2
- package/dashboard/dist/assets/AvailableEscalationsPage-DldboL4W.js +0 -2
- package/dashboard/dist/assets/AvailableEscalationsPage-DldboL4W.js.map +0 -1
- package/dashboard/dist/assets/CountdownTimer-DPjIkerB.js +0 -2
- package/dashboard/dist/assets/CountdownTimer-DPjIkerB.js.map +0 -1
- package/dashboard/dist/assets/EventTable-CwPWl163.js +0 -2
- package/dashboard/dist/assets/EventTable-CwPWl163.js.map +0 -1
- package/dashboard/dist/assets/FilterBar-D7GghUsU.js +0 -2
- package/dashboard/dist/assets/FilterBar-D7GghUsU.js.map +0 -1
- package/dashboard/dist/assets/HomePage-Bcq10Bxx.js +0 -2
- package/dashboard/dist/assets/ListToolbar-IPXsTb3Q.js +0 -2
- package/dashboard/dist/assets/McpQueryPage-CNsuiw_q.js +0 -2
- package/dashboard/dist/assets/McpRunDetailPage-BJguEMS0.js +0 -2
- package/dashboard/dist/assets/McpRunDetailPage-BJguEMS0.js.map +0 -1
- package/dashboard/dist/assets/OperationsPage-DvWrLuH6.js +0 -2
- package/dashboard/dist/assets/OperationsPage-DvWrLuH6.js.map +0 -1
- package/dashboard/dist/assets/OperatorDashboard-C-jE0IRA.js +0 -2
- package/dashboard/dist/assets/RoleDetailPage-BKkUvTO-.js +0 -8
- package/dashboard/dist/assets/RoleDetailPage-BKkUvTO-.js.map +0 -1
- package/dashboard/dist/assets/RolesPage-BHzWK9n6.js +0 -2
- package/dashboard/dist/assets/RolesPage-BHzWK9n6.js.map +0 -1
- package/dashboard/dist/assets/RunAsSelector-CS3KQ-BF.js +0 -2
- package/dashboard/dist/assets/ScanCodesPage-BW4P4zWf.js +0 -2
- package/dashboard/dist/assets/ScanCodesPage-BW4P4zWf.js.map +0 -1
- package/dashboard/dist/assets/ScanSchemeDetailPage-BLykA4j-.js +0 -2
- package/dashboard/dist/assets/ScanSchemeDetailPage-BLykA4j-.js.map +0 -1
- package/dashboard/dist/assets/StickyPagination-hMrnLXde.js +0 -2
- package/dashboard/dist/assets/StickyPagination-hMrnLXde.js.map +0 -1
- package/dashboard/dist/assets/TopicsPage-1VAc29Qw.js +0 -2
- package/dashboard/dist/assets/WorkflowExecutionPage-C15GSAoe.js +0 -2
- package/dashboard/dist/assets/WorkflowExecutionPage-C15GSAoe.js.map +0 -1
- package/dashboard/dist/assets/WorkflowsDashboard-BMQd_0tW.js +0 -2
- package/dashboard/dist/assets/capabilities-IaCcS7ge.js +0 -2
- package/dashboard/dist/assets/escalation-columns-BY2mg9DY.js +0 -2
- package/dashboard/dist/assets/escalation-columns-BY2mg9DY.js.map +0 -1
- package/dashboard/dist/assets/index-CLmZaNTK.js +0 -2
- package/dashboard/dist/assets/index-CfAi1OsI.js +0 -65
- package/dashboard/dist/assets/index-CfAi1OsI.js.map +0 -1
- package/dashboard/dist/assets/index-CvNBdkB1.js +0 -5
- package/dashboard/dist/assets/index-Dldi3Q3M.js +0 -2
- package/dashboard/dist/assets/index-mKcQGi2B.js +0 -3
- package/dashboard/dist/assets/index-mKcQGi2B.js.map +0 -1
- package/dashboard/dist/assets/index-zQiUPfxA.css +0 -1
- package/dashboard/dist/assets/useEventHooks-PDbuSJ12.js +0 -2
- package/dashboard/dist/assets/vendor-icons-BpZiWH2f.js.map +0 -1
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{a as m,j as e}from"./vendor-query-RUZdMvN6.js";import{d as z,h as U,u as H,i as K,b as X}from"./workflows-DbPqi1TW.js";import{F as Y,b as G,a as V}from"./FilterBar-D7GghUsU.js";import{C as O}from"./ConfirmDeleteModal-CQsJUzEa.js";import{R as D}from"./RolePill-CnuBPhPw.js";import{W as Z}from"./WorkflowPill-Da406nEj.js";import{P as ee}from"./PageHeader-Ce4GcIYo.js";import{A as te,ay as I,aA as $,aC as se,h as L,aD as re,aE as W,Q as ne,U as E,X as oe,s as ae,a3 as le,j as ie}from"./vendor-icons-BpZiWH2f.js";import{u as Q,e as ce,f as de}from"./vendor-react-CdqEC2zv.js";import{E as ue}from"./index-CfAi1OsI.js";import{B as me}from"./BotPicker-DQOpVB4M.js";import{N as xe}from"./NamespacePill-B9Vc_Pz2.js";import"./Modal-BU7No9NH.js";import"./bots-ClLcDGJb.js";function he({tier:t}){return t==="certified"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-2xs font-medium text-status-success",children:[e.jsx($,{className:"w-3 h-3"}),"Certified"]}):t==="registered"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-2xs font-medium text-text-secondary",children:[e.jsx(ne,{className:"w-3 h-3"}),"Registered"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-2xs font-medium text-text-quaternary",children:[e.jsx(I,{className:"w-3 h-3"}),"Durable"]})}function Fe(){const t=Q(),{data:o,isLoading:u}=z(),x=U(),[c,g]=m.useState(""),[s,v]=m.useState(null),[j,k]=m.useState(null),i=o??[],f=m.useMemo(()=>[...new Set(i.map(a=>a.task_queue).filter(Boolean))].sort(),[i]),l=m.useMemo(()=>{const a=c.toLowerCase().trim();return(s?[s]:f).map(h=>({queue:h,workflows:i.filter(b=>{var p;return b.task_queue===h&&(!a||b.workflow_type.toLowerCase().includes(a)||((p=b.description)==null?void 0:p.toLowerCase().includes(a)))})})).filter(h=>h.workflows.length>0)},[i,f,c,s]),d=m.useMemo(()=>{const a=c.toLowerCase().trim();return s?[]:i.filter(w=>{var h;return!w.task_queue&&(!a||w.workflow_type.toLowerCase().includes(a)||((h=w.description)==null?void 0:h.toLowerCase().includes(a)))})},[i,c,s]),r=a=>{a.registered?t(`/workflows/registry/${encodeURIComponent(a.workflow_type)}`):t(`/workflows/registry/new?workflow_type=${encodeURIComponent(a.workflow_type)}&task_queue=${encodeURIComponent(a.task_queue??"")}`)},C=()=>{j&&x.mutate(j,{onSuccess:()=>k(null)})};return e.jsxs("div",{children:[e.jsx(ee,{title:"Registered Workflows",docsHash:"#docs:dashboard.md:workflow-registry",actions:e.jsx("button",{onClick:()=>t("/workflows/registry/new"),className:"btn-primary text-xs",children:"Register Workflow"})}),!u&&f.length>0&&e.jsxs(Y,{children:[e.jsx(G,{label:"Queue",value:s??"",onChange:a=>v(a||null),options:f.map(a=>({value:a,label:a}))}),e.jsx(V,{label:"Search",value:c,onChange:g,placeholder:`${i.length} workflows…`})]}),u?e.jsx(pe,{}):l.length===0&&d.length===0?e.jsx("p",{className:"text-sm text-text-tertiary mt-8",children:c||s?"No workflows match your filter.":"No workflows discovered yet."}):e.jsxs("div",{className:"space-y-10",children:[l.map(({queue:a,workflows:w})=>e.jsxs("div",{children:[e.jsxs("div",{className:"sticky top-[60px] z-10 bg-surface flex items-center gap-2 py-2 mb-2 border-b border-surface-border",children:[e.jsx(te,{className:"w-3 h-3 text-accent",strokeWidth:1.5}),e.jsx("h2",{className:"section-h2",children:a}),e.jsx("span",{className:"text-xs text-text-quaternary",children:w.length})]}),e.jsx(T,{}),e.jsx("div",{className:"divide-y divide-surface-border/30",children:w.map(h=>e.jsx(F,{wf:h,onRowClick:r,onDelete:k,onNavigate:t},h.workflow_type))})]},a)),d.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"sticky top-[60px] z-10 bg-surface flex items-center gap-2 py-2 mb-2 border-b border-surface-border",children:[e.jsx(I,{className:"w-3 h-3 text-text-quaternary",strokeWidth:1.5}),e.jsx("h2",{className:"section-h2",children:"No Queue"}),e.jsx("span",{className:"text-xs text-text-quaternary",children:d.length})]}),e.jsx(T,{}),e.jsx("div",{className:"divide-y divide-surface-border/30",children:d.map(a=>e.jsx(F,{wf:a,onRowClick:r,onDelete:k,onNavigate:t},a.workflow_type))})]})]}),e.jsx(O,{open:!!j,onClose:()=>k(null),onConfirm:C,title:"Unregister Workflow",description:e.jsxs(e.Fragment,{children:["Delete the registration for"," ",e.jsx("span",{className:"font-mono font-medium text-text-primary",children:j}),"? This removes its invocation settings, certification, and interceptor treatment; the workflow keeps running as a plain durable workflow. To demote certified → registered instead, open the workflow and uncheck Certify — that keeps every setting."]}),isPending:x.isPending,error:x.error})]})}const J="grid grid-cols-[minmax(0,1fr)_7rem_13rem_4.5rem] gap-x-6";function T(){return e.jsxs("div",{className:`${J} px-3 pb-2 pt-1`,children:[e.jsx("span",{className:"text-2xs font-medium text-text-quaternary",children:"Workflow"}),e.jsx("span",{className:"text-2xs font-medium text-text-quaternary",children:"Tier"}),e.jsx("span",{className:"text-2xs font-medium text-text-quaternary",children:"Access"}),e.jsx("span",{})]})}function F({wf:t,onRowClick:o,onDelete:u,onNavigate:x}){const c=t.roles??[],g=t.invocation_roles??[];return e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>o(t),onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&o(t)},className:`group ${J} py-2 px-3 -mx-3 rounded-md cursor-pointer transition-colors items-center`,children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(Z,{type:t.workflow_type,size:"md",variant:t.tier==="certified"?"certified":t.tier==="registered"?"registered":"durable"}),t.description&&e.jsx("p",{className:"flex-1 min-w-0 truncate text-2xs text-text-tertiary group-hover:text-text-secondary transition-colors",children:t.description})]}),e.jsx("div",{children:e.jsx(he,{tier:t.tier??"durable"})}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 overflow-hidden whitespace-nowrap",children:[c.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{title:"Escalation roles",children:e.jsx($,{className:"w-3 h-3 text-text-quaternary shrink-0"})}),c.map(s=>e.jsx(D,{role:s},`e-${s}`))]}),g.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{title:"Invocation roles",children:e.jsx(se,{className:"w-3 h-3 text-text-quaternary shrink-0"})}),g.map(s=>e.jsx(D,{role:s},`i-${s}`))]}),c.length===0&&g.length===0&&e.jsx("span",{className:"text-xs text-text-quaternary",children:"—"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[t.invocable&&e.jsx("button",{title:"Invoke workflow",onClick:s=>{s.stopPropagation(),x(`/workflows/start?type=${encodeURIComponent(t.workflow_type)}&mode=now`)},className:"text-text-quaternary hover:text-status-success transition-colors",children:e.jsx(L,{className:"w-3.5 h-3.5"})}),t.tier==="durable"&&e.jsx("button",{title:"Configure workflow",onClick:s=>{s.stopPropagation(),x(`/workflows/registry/new?workflow_type=${encodeURIComponent(t.workflow_type)}&task_queue=${encodeURIComponent(t.task_queue??"")}`)},className:"text-text-quaternary hover:text-status-info transition-colors",children:e.jsx(I,{className:"w-3.5 h-3.5"})}),t.tier==="registered"&&e.jsx("button",{title:"Certify workflow",onClick:s=>{s.stopPropagation(),x(`/workflows/registry/${encodeURIComponent(t.workflow_type)}`)},className:"text-text-quaternary hover:text-status-success transition-colors",children:e.jsx(re,{className:"w-3.5 h-3.5"})}),t.registered&&e.jsx("button",{title:"Unregister workflow",onClick:s=>{s.stopPropagation(),u(t.workflow_type)},className:"text-text-quaternary hover:text-status-warning transition-colors",children:e.jsx(W,{className:"w-3.5 h-3.5"})})]})]})}function pe(){return e.jsx("div",{className:"animate-pulse space-y-8 mt-4",children:[1,2].map(t=>e.jsxs("div",{children:[e.jsx("div",{className:"h-4 bg-surface-sunken rounded w-36 mb-4"}),e.jsx("div",{className:"space-y-4",children:[1,2,3].map(o=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"h-3 bg-surface-sunken rounded w-48"}),e.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]},o))})]},t))})}function fe({selected:t,onChange:o,single:u,placeholder:x}){const{data:c}=ue(),g=(c==null?void 0:c.roles)??[],[s,v]=m.useState(!1),j=m.useRef(null);m.useEffect(()=>{const l=d=>{j.current&&!j.current.contains(d.target)&&v(!1)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[]);const k=l=>{u?(o(t.includes(l)?[]:[l]),v(!1)):o(t.includes(l)?t.filter(d=>d!==l):[...t,l])},i=l=>{o(t.filter(d=>d!==l))},f=x??(u?"Select role...":"Add roles...");return e.jsxs("div",{ref:j,className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>v(!s),className:"flex flex-wrap items-center gap-1.5 w-full min-h-[34px] px-2 py-1.5 bg-surface-sunken border border-surface-border rounded-md text-left cursor-pointer hover:border-accent/40 transition-colors focus:ring-1 focus:ring-accent focus:outline-none",children:[t.length===0&&e.jsx("span",{className:"text-xs text-text-tertiary",children:f}),t.map(l=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-lg bg-accent/[0.08] text-text-secondary text-2xs",children:[e.jsx(E,{className:"w-2.5 h-2.5 shrink-0 text-accent/75"}),l,e.jsx("span",{role:"button",onClick:d=>{d.stopPropagation(),i(l)},className:"ml-0.5 hover:text-status-error transition-colors",children:e.jsx(oe,{className:"w-2.5 h-2.5"})})]},l)),e.jsx(ae,{className:`w-3.5 h-3.5 ml-auto shrink-0 text-text-tertiary transition-transform ${s?"rotate-180":""}`})]}),s&&e.jsx("div",{className:"absolute z-[100] mt-1 w-full bg-surface-raised border border-surface-border rounded-md shadow-lg max-h-48 overflow-y-auto",children:g.length===0?e.jsx("p",{className:"px-3 py-2 text-xs text-text-tertiary",children:"No roles defined"}):g.map(l=>{const d=t.includes(l);return e.jsxs("button",{type:"button",onClick:()=>k(l),className:`flex items-center gap-2 w-full px-3 py-1.5 text-left text-xs transition-colors ${d?"bg-accent/[0.06] text-accent":"text-text-primary hover:bg-surface-sunken"}`,children:[e.jsx(E,{className:"w-3 h-3 shrink-0 text-accent/60"}),e.jsx("span",{className:"flex-1",children:l}),d&&e.jsx(le,{className:"w-3 h-3 shrink-0"})]},l)})})]})}function S(t){return t.split(",").map(o=>o.trim()).filter(Boolean)}const R={workflow_type:"",description:"",task_queue:"",default_role:"reviewer",invocable:!1,roles:"",invocation_roles:"",consumes:"",envelope_schema:"",resolver_schema:"",cron_schedule:"",execute_as:"",certified:!1};function we(t){const o=(t.roles??[]).join(", "),u=(t.consumes??[]).join(", ");return{workflow_type:t.workflow_type,description:t.description??"",task_queue:t.task_queue??"",default_role:t.default_role,invocable:t.invocable,roles:o,invocation_roles:(t.invocation_roles??[]).join(", "),consumes:u,envelope_schema:t.envelope_schema?JSON.stringify(t.envelope_schema,null,2):"",resolver_schema:t.resolver_schema?JSON.stringify(t.resolver_schema,null,2):"",cron_schedule:t.cron_schedule??"",execute_as:t.execute_as??"",certified:t.certified}}function q(t){if(!t.trim())return!0;try{return JSON.parse(t),!0}catch{return!1}}function P({icon:t,color:o,children:u}){return e.jsxs("div",{className:"flex items-center gap-2 mb-4 pb-2 border-b border-surface-border",children:[e.jsx(t,{className:`w-4 h-4 ${o}`,strokeWidth:1.5}),e.jsx("h2",{className:"section-h2",children:u})]})}function _({label:t,hint:o,children:u}){return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"label",children:t}),u,o&&e.jsx("p",{className:"hint",children:o})]})}const ge="input-json w-full";function je(t){return S(t)}function ve(t){return t.join(", ")}const ke=new Set(["mcpQuery","mcpDeterministic","mcpQueryRouter","mcpTriage","mcpTriageRouter","mcpTriageDeterministic","insightQuery"]);function Ue(){const{workflowType:t}=ce(),o=!t,u=Q(),[x]=de(),{data:c,isLoading:g}=H(),s=K(),v=U(),[j,k]=m.useState(!1),i=(c==null?void 0:c.find(n=>n.workflow_type===t))??null,{data:f}=X({limit:500}),l=m.useMemo(()=>{const n=new Set((c??[]).map(N=>N.workflow_type));return[...new Set(((f==null?void 0:f.jobs)??[]).map(N=>N.entity))].filter(N=>!n.has(N)&&!ke.has(N)).sort()},[c,f]),d=m.useMemo(()=>{if(!o)return R;const n=x.get("workflow_type")??"",y=x.get("task_queue")??"";return n||y?{...R,workflow_type:n,task_queue:y}:R},[o,x]),[r,C]=m.useState(d),[a,w]=m.useState(""),[h,b]=m.useState(!1),p=m.useCallback((n,y)=>C(N=>({...N,[n]:y})),[]);m.useEffect(()=>{if(!h){if(o){C(d),b(!0);return}i&&(C(we(i)),b(!0))}},[i,o,h,d]);const A=()=>{if(!r.workflow_type.trim())return;w("");let n=null,y=null;try{r.envelope_schema.trim()&&(n=JSON.parse(r.envelope_schema))}catch{w("Invalid JSON in Envelope Schema");return}try{r.resolver_schema.trim()&&(y=JSON.parse(r.resolver_schema))}catch{w("Invalid JSON in Resolver Schema");return}s.mutate({workflow_type:r.workflow_type.trim(),description:r.description.trim()||null,task_queue:r.task_queue.trim()||null,default_role:r.default_role.trim()||"reviewer",invocable:r.invocable,certified:r.certified,roles:S(r.roles),invocation_roles:S(r.invocation_roles),consumes:S(r.consumes),envelope_schema:n,resolver_schema:y,cron_schedule:r.cron_schedule.trim()||null,execute_as:r.execute_as.trim()||null},{onSuccess:()=>u("/workflows/registry")})};if(g)return e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-8 bg-surface-sunken rounded w-64"}),e.jsx("div",{className:"h-40 bg-surface-sunken rounded"})]});if(!o&&!i)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Config not found."});const M=!!r.workflow_type.trim()&&q(r.envelope_schema)&&q(r.resolver_schema),B=o&&!r.workflow_type&&l.length>0;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-start justify-between mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-light font-mono text-text-primary",children:o?"New Workflow":(i==null?void 0:i.workflow_type)??""}),i&&e.jsx("div",{className:"flex items-center gap-2 mt-2",children:e.jsx(xe,{namespace:"durable"})})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[e.jsx("button",{onClick:()=>u("/workflows/registry"),className:"btn-ghost text-xs",children:"Cancel"}),e.jsx("button",{onClick:A,disabled:!M||s.isPending,className:"btn-primary text-xs",children:s.isPending?"Saving…":o?"Register":"Save"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 @wall:grid-cols-3 gap-x-14 gap-y-10",children:[e.jsxs("div",{children:[e.jsx(P,{icon:ie,color:"text-accent",children:"Identity"}),e.jsxs("div",{className:"space-y-5",children:[e.jsx(_,{label:"Workflow Type",hint:"Register a workflow to configure invocation and HITL escalation routing.",children:B?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-text-secondary",children:"Select a durable workflow to register:"}),e.jsx("div",{className:"grid gap-1",children:l.map(n=>e.jsx("button",{onClick:()=>p("workflow_type",n),className:"flex items-center gap-2 px-3 py-2 text-left text-xs font-mono rounded-md border border-surface-border hover:border-accent/50 hover:bg-accent/[0.04] transition-colors",children:n},n))}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("span",{className:"text-2xs text-text-tertiary",children:"or"}),e.jsx("input",{type:"text",onChange:n=>p("workflow_type",n.target.value),placeholder:"Enter type manually",className:"input font-mono flex-1"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:r.workflow_type,onChange:n=>p("workflow_type",n.target.value),disabled:!o,placeholder:"reviewContent",className:"input font-mono w-full"}),o&&r.workflow_type&&l.length>0&&e.jsx("button",{onClick:()=>p("workflow_type",""),className:"text-2xs text-accent hover:underline mt-1",children:"Choose from durable workflows"})]})}),e.jsx(_,{label:"Description",children:e.jsx("input",{type:"text",value:r.description,onChange:n=>p("description",n.target.value),placeholder:"Describe what this workflow does",className:"input text-xs w-full"})}),e.jsx(_,{label:"Task Queue",hint:"Durable task queue this workflow listens on.",children:e.jsx("input",{type:"text",value:r.task_queue,onChange:n=>p("task_queue",n.target.value),placeholder:"lt-review",className:"input font-mono w-full"})})]})]}),e.jsxs("div",{children:[e.jsx(P,{icon:L,color:"text-accent",children:"Invocation"}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:r.invocable,onChange:n=>p("invocable",n.target.checked),className:"w-4 h-4 rounded border-border accent-accent"}),e.jsx("span",{className:"text-xs text-text-primary font-medium",children:"Invocable"})]}),e.jsx("p",{className:"hint",children:"Allow this workflow to be started from the dashboard or API."})]}),r.invocable?e.jsxs(e.Fragment,{children:[e.jsx(_,{label:"Run As",hint:"Bot identity to run under. Default runs as the invoking user.",children:e.jsx(me,{selected:r.execute_as,onChange:n=>p("execute_as",n)})}),e.jsx(_,{label:"Invocation Roles",hint:"Only users with these roles can start this workflow. Empty = all authenticated users.",children:e.jsx(fe,{selected:je(r.invocation_roles),onChange:n=>p("invocation_roles",ve(n)),placeholder:"Select roles…"})}),e.jsxs(_,{label:"Envelope Schema",hint:e.jsxs(e.Fragment,{children:["Pre-fills the JSON editor when invoking. Include ",e.jsx("code",{className:"font-mono",children:"data"})," (input) and optional ",e.jsx("code",{className:"font-mono",children:"metadata"}),"."]}),children:[e.jsx("textarea",{value:r.envelope_schema,onChange:n=>p("envelope_schema",n.target.value),placeholder:`{
|
|
2
|
-
"data": {},
|
|
3
|
-
"metadata": {}
|
|
4
|
-
}`,className:ge,rows:8,spellCheck:!1}),r.envelope_schema.trim()&&!q(r.envelope_schema)&&e.jsx("p",{className:"text-2xs text-status-error mt-1",children:"Invalid JSON"})]})]}):e.jsxs("p",{className:"text-2xs text-text-tertiary py-2",children:["Enable ",e.jsx("span",{className:"font-medium text-text-secondary",children:"Invocable"})," to configure invocation roles and an input template."]})]})]}),i&&e.jsxs("div",{children:[e.jsx(P,{icon:W,color:"text-text-tertiary",children:"Registration"}),e.jsxs("button",{onClick:()=>k(!0),className:"flex items-center gap-1.5 text-2xs text-status-warning hover:underline",title:"Delete this registration — the workflow returns to plain durable",children:[e.jsx(W,{className:"w-3 h-3"})," Unregister workflow"]})]})]}),(a||s.error)&&e.jsx("p",{className:"text-xs text-status-error mt-8",children:a||s.error.message}),e.jsx(O,{open:j,onClose:()=>k(!1),onConfirm:()=>v.mutate(i.workflow_type,{onSuccess:()=>u("/workflows/registry")}),title:"Unregister Workflow",description:e.jsxs(e.Fragment,{children:["Delete the registration for"," ",e.jsx("span",{className:"font-mono font-medium text-text-primary",children:i==null?void 0:i.workflow_type}),"? This removes its invocation settings, certification, and interceptor treatment; the workflow keeps running as a plain durable workflow. Escalation schemas versioned on roles are untouched."]}),isPending:v.isPending,error:v.error})]})}export{Ue as WorkflowConfigDetailPage,Fe as WorkflowConfigsPage};
|
|
5
|
-
//# sourceMappingURL=index-CvNBdkB1.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{c as k,u as R,b as O,j as e,a as d}from"./vendor-query-RUZdMvN6.js";import{P as F}from"./PageHeader-Ce4GcIYo.js";import{d as b}from"./index-CfAi1OsI.js";import{M}from"./Modal-BU7No9NH.js";import{R as g,C}from"./constants-BHkpVaqx.js";import{aP as E,aE as T,aA as W,ao as j,T as I,al as D}from"./vendor-icons-BpZiWH2f.js";import"./vendor-react-CdqEC2zv.js";function $(){return R({queryKey:["maintenance"],queryFn:()=>b("/config/maintenance")})}function _(){const t=O();return k({mutationFn:r=>b("/config/maintenance",{method:"PUT",body:JSON.stringify(r)}),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenance"]})}})}function q(){return k({mutationFn:t=>b("/dba/prune",{method:"POST",body:JSON.stringify(t)})})}function v({checked:t,onToggle:r,label:a,hint:s,safety:i,value:l,onChange:c}){const n=i==="safe"?W:i==="moderate"?E:T,o=i==="safe"?"text-status-success":i==="moderate"?"text-status-warning":"text-status-error",p=i==="safe"?"Safe":i==="moderate"?"Careful":"Permanent";return e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer w-80 shrink-0",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:x=>r(x.target.checked),className:"w-4 h-4 rounded border-border accent-accent shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-text-primary",children:a}),e.jsxs("span",{className:`flex items-center gap-0.5 text-2xs ${o}`,children:[e.jsx(n,{className:"w-3 h-3",strokeWidth:1.5}),p]})]}),e.jsx("p",{className:"text-2xs text-text-tertiary",children:s})]})]}),e.jsx("select",{value:l,onChange:x=>c(x.target.value),disabled:!t,className:`select text-xs w-36 transition-opacity ${t?"":"opacity-40 cursor-not-allowed"}`,children:g.map(x=>e.jsx("option",{value:x.value,children:x.label},x.value))})]})}function L(){return e.jsxs("div",{className:"flex items-start gap-2 mt-2 px-3 py-2 rounded bg-surface-sunken",children:[e.jsx(j,{className:"w-3.5 h-3.5 text-text-tertiary shrink-0 mt-0.5"}),e.jsx("p",{className:"text-2xs text-text-tertiary leading-relaxed",children:"Stripping preserves workflow results and timeline data needed for the execution detail view. Transient jobs are internal bookkeeping that accumulates over time."})]})}const f={pruneJobs:!0,expire:"30 days",engineStreams:!0,engineStreamsExpire:"1 day",workerStreams:!0,workerStreamsExpire:"90 days",stripAttributes:!1,pruneTransient:!1};function N(t){return t.pruneJobs||t.engineStreams||t.workerStreams||t.stripAttributes||t.pruneTransient}function P({fields:t,onChange:r}){const a=(s,i)=>r({...t,[s]:i});return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Stream Messages"}),e.jsx("p",{className:"text-2xs text-text-tertiary mb-4",children:"Processed routing messages. Already consumed — safe to remove after a short retention window."}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(v,{checked:t.engineStreams,onToggle:s=>a("engineStreams",s),label:"Engine messages",hint:"Internal orchestration signals",safety:"safe",value:t.engineStreamsExpire,onChange:s=>a("engineStreamsExpire",s)}),e.jsx(v,{checked:t.workerStreams,onToggle:s=>a("workerStreams",s),label:"Worker messages",hint:"Activity dispatch and response payloads",safety:"safe",value:t.workerStreamsExpire,onChange:s=>a("workerStreamsExpire",s)})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Completed Workflows"}),e.jsx("p",{className:"text-2xs text-text-tertiary mb-4",children:"Choose how to handle completed workflow records. Reducing strips step-level detail but keeps the workflow and its results. Deleting removes the record entirely."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"workflow-cleanup",checked:!t.stripAttributes&&!t.pruneJobs,onChange:()=>r({...t,stripAttributes:!1,pruneJobs:!1}),className:"w-4 h-4 mt-0.5 accent-accent shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-text-primary",children:"Keep as-is"}),e.jsx("p",{className:"text-2xs text-text-tertiary",children:"No changes to completed workflow records."})]})]}),e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer w-80 shrink-0",children:[e.jsx("input",{type:"radio",name:"workflow-cleanup",checked:t.stripAttributes&&!t.pruneJobs,onChange:()=>r({...t,stripAttributes:!0,pruneJobs:!1}),className:"w-4 h-4 mt-0.5 accent-accent shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-text-primary",children:"Reduce completed workflows"}),e.jsxs("span",{className:"flex items-center gap-0.5 text-2xs text-status-warning",children:[e.jsx(E,{className:"w-3 h-3",strokeWidth:1.5}),"Careful"]})]}),e.jsx("p",{className:"text-2xs text-text-tertiary",children:"Strips step-level execution detail (activity inputs/outputs, internal state). Workflow results and timeline are preserved."})]})]}),e.jsx("select",{value:t.expire,onChange:s=>a("expire",s.target.value),disabled:!t.stripAttributes||t.pruneJobs,className:`select text-xs w-36 transition-opacity mt-0.5 ${!t.stripAttributes||t.pruneJobs?"opacity-40 cursor-not-allowed":""}`,children:g.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]}),e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer w-80 shrink-0",children:[e.jsx("input",{type:"radio",name:"workflow-cleanup",checked:t.pruneJobs,onChange:()=>r({...t,pruneJobs:!0,stripAttributes:!1}),className:"w-4 h-4 mt-0.5 accent-accent shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-text-primary",children:"Delete completed workflows"}),e.jsxs("span",{className:"flex items-center gap-0.5 text-2xs text-status-error",children:[e.jsx(T,{className:"w-3 h-3",strokeWidth:1.5}),"Permanent"]})]}),e.jsx("p",{className:"text-2xs text-text-tertiary",children:"Permanently removes workflow records. Results, timeline, and all execution data are deleted and cannot be recovered."})]})]}),e.jsx("select",{value:t.expire,onChange:s=>a("expire",s.target.value),disabled:!t.pruneJobs,className:`select text-xs w-36 transition-opacity mt-0.5 ${t.pruneJobs?"":"opacity-40 cursor-not-allowed"}`,children:g.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]})]}),e.jsx(L,{})]})]})}function m({label:t,value:r}){return e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-light text-text-primary",children:r.toLocaleString()}),e.jsx("p",{className:"text-2xs text-text-tertiary",children:t})]})}function U(){const t=q(),[r,a]=d.useState(f),[s,i]=d.useState(null),[l,c]=d.useState(!1),n=()=>{i(null),t.mutate({expire:r.expire,jobs:r.pruneJobs,engineStreams:r.engineStreams,engineStreamsExpire:r.engineStreamsExpire,workerStreams:r.workerStreams,workerStreamsExpire:r.workerStreamsExpire,attributes:r.stripAttributes,pruneTransient:r.pruneTransient},{onSuccess:o=>{i(o),c(!1)}})};return e.jsxs("div",{className:"space-y-8",children:[e.jsx(P,{fields:r,onChange:a}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-surface-border",children:[e.jsx("p",{className:"text-2xs text-text-tertiary",children:N(r)?"This action permanently deletes data and cannot be undone.":"Select at least one operation to enable pruning."}),e.jsx("button",{onClick:()=>c(!0),disabled:!N(r)||t.isPending,className:"bg-status-error text-text-inverse px-4 py-1.5 rounded-md text-xs hover:opacity-90 transition-opacity disabled:opacity-40 shrink-0",children:t.isPending?"Pruning...":"Prune Now"})]}),s&&e.jsxs("div",{className:"bg-surface-sunken rounded-md px-4 py-3",children:[e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-2",children:"Results"}),e.jsxs("div",{className:"flex flex-wrap gap-6",children:[s.jobs!=null&&s.jobs>0&&e.jsx(m,{label:"Jobs deleted",value:s.jobs}),s.engineStreams!=null&&s.engineStreams>0&&e.jsx(m,{label:"Engine streams",value:s.engineStreams}),s.workerStreams!=null&&s.workerStreams>0&&e.jsx(m,{label:"Worker streams",value:s.workerStreams}),s.streams!=null&&s.engineStreams==null&&s.streams>0&&e.jsx(m,{label:"Streams",value:s.streams}),s.attributes!=null&&s.attributes>0&&e.jsx(m,{label:"Artifacts stripped",value:s.attributes}),s.transient!=null&&s.transient>0&&e.jsx(m,{label:"Transient deleted",value:s.transient}),s.marked!=null&&s.marked>0&&e.jsx(m,{label:"Marked pruned",value:s.marked}),Object.values(s).every(o=>!o||o===0)&&e.jsx("p",{className:"text-xs text-text-tertiary",children:"Nothing to prune within the selected retention windows."})]})]}),t.error&&e.jsx("p",{className:"text-xs text-status-error",children:t.error.message}),e.jsx(M,{open:l,onClose:()=>c(!1),title:"Confirm Prune",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-text-secondary",children:"This will permanently delete data. This action cannot be undone."}),e.jsxs("ul",{className:"text-xs text-text-secondary space-y-1 list-disc list-inside",children:[r.pruneJobs&&e.jsxs("li",{children:["Delete jobs older than ",r.expire]}),r.engineStreams&&e.jsxs("li",{children:["Delete engine streams older than ",r.engineStreamsExpire]}),r.workerStreams&&e.jsxs("li",{children:["Delete worker streams older than ",r.workerStreamsExpire]}),r.stripAttributes&&e.jsx("li",{children:"Strip execution artifacts from completed jobs"}),r.pruneTransient&&e.jsx("li",{children:"Delete transient (entity-less) jobs"})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx("button",{onClick:()=>c(!1),className:"btn-secondary text-xs",children:"Cancel"}),e.jsx("button",{onClick:n,className:"bg-status-error text-text-inverse px-3 py-1.5 rounded-md text-xs hover:opacity-90 transition-opacity",disabled:t.isPending,children:t.isPending?"Pruning...":"Confirm Prune"})]})]})})]})}function w(t){var c;if(!((c=t==null?void 0:t.rules)!=null&&c.length))return f;const r=t.rules,a=r.find(n=>n.target==="streams"&&n.action==="delete"),s=r.find(n=>n.target==="jobs"&&n.action==="delete"&&n.hasEntity===!1),i=r.find(n=>n.target==="jobs"&&n.action==="prune"&&n.hasEntity===!0),l=r.find(n=>n.target==="jobs"&&n.action==="delete"&&n.pruned===!0);return{pruneJobs:!!l,expire:(l==null?void 0:l.olderThan)??"180 days",engineStreams:!!a,engineStreamsExpire:(a==null?void 0:a.olderThan)??"1 day",workerStreams:!!a,workerStreamsExpire:(a==null?void 0:a.olderThan)??"90 days",stripAttributes:!!i,pruneTransient:!!s}}function H(t){const r=[];return t.engineStreams&&r.push({target:"streams",action:"delete",olderThan:t.engineStreamsExpire}),t.workerStreams&&t.workerStreamsExpire!==t.engineStreamsExpire&&r.push({target:"streams",action:"delete",olderThan:t.workerStreamsExpire}),t.pruneTransient&&r.push({target:"jobs",action:"delete",olderThan:t.expire,hasEntity:!1}),t.stripAttributes&&r.push({target:"jobs",action:"prune",olderThan:t.expire,hasEntity:!0}),t.pruneJobs&&r.push({target:"jobs",action:"delete",olderThan:t.expire,pruned:!0}),r}function S(t){var r;return((r=C.find(a=>a.value===t))==null?void 0:r.label)??""}function K(){const{data:t,isLoading:r}=$(),a=_(),[s,i]=d.useState(""),[l,c]=d.useState(f),[n,o]=d.useState(""),p=d.useCallback(()=>{t!=null&&t.config&&(i(t.config.schedule),c(w(t.config)),o(JSON.stringify({schedule:t.config.schedule,fields:w(t.config)})))},[t]);d.useEffect(()=>{p()},[p]);const x=JSON.stringify({schedule:s,fields:l}),y=n!==""&&x!==n,h=(t==null?void 0:t.active)??!1,J=()=>{const u=H(l);a.mutate({schedule:s,rules:u},{onSuccess:()=>{o(JSON.stringify({schedule:s,fields:l}))}})},A=()=>{p()};return r?e.jsx("div",{className:"animate-pulse h-40 bg-surface-sunken rounded"}):e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"grid grid-cols-1 @split:grid-cols-[1fr_auto] gap-10",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-4",children:"Schedule"}),e.jsxs("div",{className:"flex items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-2xs text-text-tertiary mb-1",children:"Cron Expression"}),e.jsx("input",{type:"text",value:s,onChange:u=>i(u.target.value),placeholder:"0 2 * * *",className:"input text-xs font-mono w-48"})]}),e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-1.5 h-8",children:[e.jsx("span",{className:`w-2.5 h-2.5 rounded-full dot-ring ${h?"bg-status-success":"bg-text-tertiary"}`}),e.jsx("span",{className:`text-xs ${h?"text-status-success":"text-text-tertiary"}`,children:h?"Active":"Inactive"})]})}),S(s)&&e.jsx("p",{className:"text-xs text-text-tertiary h-8 flex items-center",children:S(s)})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:C.map(u=>e.jsx("button",{type:"button",onClick:()=>i(u.value),className:`px-2.5 py-1 text-2xs rounded-full transition-colors ${s===u.value?"bg-accent/10 text-accent font-medium":"bg-surface-sunken text-text-tertiary hover:text-text-secondary"}`,children:u.label},u.value))})]}),e.jsxs("div",{className:"lg:w-72",children:[e.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-4",children:"How It Works"}),e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 rounded bg-surface-sunken",children:[e.jsx(j,{className:"w-3.5 h-3.5 text-text-tertiary shrink-0 mt-0.5"}),e.jsx("p",{className:"text-2xs text-text-tertiary leading-relaxed",children:"Rules execute sequentially on each cron cycle. Engine streams can be pruned aggressively since they only contain internal routing data. Worker streams should be retained longer to preserve execution playback and input enrichment."})]})]})]}),e.jsx(P,{fields:l,onChange:c}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-surface-border",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[y&&e.jsx("button",{onClick:A,className:"text-2xs text-text-tertiary hover:text-text-primary transition-colors",children:"Revert changes"}),a.error&&e.jsx("p",{className:"text-xs text-status-error",children:a.error.message})]}),e.jsx("button",{onClick:J,disabled:!y||!s.trim()||a.isPending,className:"btn-primary text-xs disabled:opacity-40 shrink-0",children:a.isPending?"Saving...":"Save Schedule"})]})]})}function Q({mode:t,onChange:r}){const a=(s,i,l)=>e.jsxs("button",{onClick:()=>r(s),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md transition-colors ${t===s?"bg-accent/10 text-accent font-medium":"text-text-tertiary hover:text-text-secondary hover:bg-surface-hover"}`,children:[i,l]});return e.jsxs("div",{className:"flex gap-1 p-0.5 bg-surface-sunken rounded-lg w-fit",children:[a("prune",e.jsx(I,{className:"w-3.5 h-3.5"}),"Prune Now"),a("schedule",e.jsx(D,{className:"w-3.5 h-3.5"}),"Schedule")]})}function ee(){const[t,r]=d.useState("schedule");return e.jsxs("div",{children:[e.jsx(F,{title:"DB Maintenance",docsHash:"#docs:dashboard.md:db-maintenance",actions:e.jsx(Q,{mode:t,onChange:r})}),e.jsxs("div",{className:"flex items-start gap-2 px-4 py-3 mb-8 rounded-md bg-accent/5 border border-accent/10",children:[e.jsx(j,{className:"w-4 h-4 text-accent shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs text-text-secondary leading-relaxed",children:"Workflow data grows as jobs complete. Operations are ordered safest-first: stream messages are always safe to prune, workflow reduction preserves results, and deletion is permanent."})]}),t==="prune"?e.jsx(U,{}):e.jsx(K,{})]})}export{ee as MaintenancePage};
|
|
2
|
-
//# sourceMappingURL=index-Dldi3Q3M.js.map
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{b as ve,a as p,j as t}from"./vendor-query-RUZdMvN6.js";import{T as rs,U as ft,d as gt,O as St,V as Ot,J as wt,W as as,X as is,Y as et,b as Lt,m as ce,k as zt,L as we,Z as Pt,_ as ke,R as Xt,h as Ce,g as os,$ as ls,a0 as cs,a1 as ds,u as xs,t as us,j as ps,a2 as ms}from"./index-CfAi1OsI.js";import{u as _e,C as Ee,a as fs}from"./CustomDurationPicker-FPmlA6cE.js";import{M as Ae}from"./Modal-BU7No9NH.js";import{a as hs,u as Gt,L as ct,b as gs,e as js}from"./vendor-react-CdqEC2zv.js";import{P as bs}from"./PageHeader-Ce4GcIYo.js";import{L as ys}from"./ListToolbar-IPXsTb3Q.js";import{i as Te,b as Ns,d as vs,C as Yt,H as ws,g as Qt,c as st,m as ks,r as Bt,e as Oe}from"./CountdownTimer-DPjIkerB.js";import{u as Cs}from"./workflows-DbPqi1TW.js";import{g as _s}from"./useEventHooks-PDbuSJ12.js";import{S as Re}from"./StatusBadge-DkgllZHv.js";import{R as Es}from"./RolePill-CnuBPhPw.js";import{C as ot}from"./CopyableId-4Lqlc5cU.js";import{U as De}from"./UserName-DikzjQHJ.js";import{Y as Ie,ao as As,S as Ts,ap as Os,K as Rs,o as Ds,aa as Me,U as Is,ad as Ms,ae as $s,a3 as Ss,aq as Ls,ar as Ps,as as Ht,at as de,au as Ws,av as xe,aw as ue,ax as Fs,X as qs}from"./vendor-icons-BpZiWH2f.js";import"./constants-BHkpVaqx.js";import"./DataTable-Bir0Xs1p.js";import"./EmptyState-lpUFYfun.js";import"./StickyPagination-hMrnLXde.js";import"./users-G8qwyZKS.js";const Vs={SCHEMA_VALIDATION:"schema_validation"};function Js(e){return typeof e=="object"&&e!==null&&e.code===Vs.SCHEMA_VALIDATION&&Array.isArray(e.violations)}function Hs({escalationId:e}){var h;const s=hs(),a=Gt(),r=ve(),n=(h=s.state)==null?void 0:h[rs],[i,d]=p.useState(!1),[l,c]=p.useState(null),[u,o]=p.useState(!1);if(!n||n.escalationId!==e||u)return null;const x=()=>{o(!0),a(s.pathname,{replace:!0,state:null})},m=async()=>{var b,g,f;d(!0),c(null);try{switch(n.verb){case ft.CANCEL:await gt(`/escalations/${e}/cancel`,{method:"POST"});break;case ft.CLAIM:case ft.CLAIM_SHOW_DETAIL:await gt(`/escalations/${e}/claim`,{method:"POST",body:JSON.stringify({durationMinutes:((b=n.params)==null?void 0:b.durationMinutes)??30})});break;case ft.RELEASE:await gt(`/escalations/${e}/release`,{method:"POST"});break;case ft.RESOLVE:await gt(`/escalations/${e}/resolve`,{method:"POST",body:JSON.stringify({resolverPayload:((g=n.params)==null?void 0:g.resolverPayload)??{}})});break;case ft.ESCALATE:await gt(`/escalations/${e}/escalate`,{method:"PATCH",body:JSON.stringify({targetRole:(f=n.params)==null?void 0:f.targetRole})});break;default:throw new Error(`Unsupported confirm verb "${n.verb}"`)}r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]}),x()}catch(y){c(y.message)}finally{d(!1)}};return t.jsx(Ae,{open:!0,onClose:x,title:"Confirm scan action",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx("p",{className:"text-sm text-text-secondary",children:n.prompt}),l&&t.jsx("p",{className:"text-xs text-status-error",children:l}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{onClick:x,disabled:i,className:"btn-secondary text-xs",children:"No, go back"}),t.jsx("button",{onClick:m,disabled:i,className:"btn-primary text-xs",children:i?"Working…":"Yes, continue"})]})]})})}const Et={pending:"rgb(var(--lt-status-queued-graphic))",claimed:"rgb(var(--lt-status-claimed-graphic))",resolved:"rgb(var(--lt-status-success-graphic))",cancelled:"rgb(var(--lt-status-error))"},Wt=5;function pe({pct:e,place:s,label:a,title:r,emphasis:n}){const i=t.jsx("span",{className:"w-px h-1.5 bg-text-quaternary","aria-hidden":!0}),d=t.jsx("span",{className:`whitespace-nowrap leading-none tabular-nums ${n?"text-text-secondary":"text-text-tertiary"}`,children:a});return t.jsx("div",{title:r,className:`absolute ${s==="above"?"bottom-0":"top-0"} flex flex-col items-center gap-0 -translate-x-1/2 cursor-help`,style:{left:`${e}%`},children:s==="above"?t.jsxs(t.Fragment,{children:[d,i]}):t.jsxs(t.Fragment,{children:[i,d]})})}function Us({esc:e,className:s=""}){const a=new Date(e.created_at).getTime(),r=e.claimed_at?new Date(e.claimed_at).getTime():null,n=e.status==="resolved",i=e.status==="cancelled"||e.status==="expired",d=n||i,l=Te(e),c=!!r&&(l||d),u=n&&e.resolved_at?new Date(e.resolved_at).getTime():i?new Date(e.updated_at).getTime():Date.now(),o=Math.max(u-a,1),x=c&&r?Math.max(r-a,0):o,m=c&&r?Math.max(u-r,0):0,h=Math.min(100,Math.max(0,x/o*100)),b=c?Math.max(0,100-h):0,g=n?Et.resolved:i?Et.cancelled:Et.claimed,f=n?"Resolved after":i?"Cancelled after":"In progress",y=St(x),_=St(o),j=n?`Resolved in ${_} total`:i?`Cancelled after ${_}`:`Open ${_} so far`,k=`Lifecycle bar: blue = time waiting to be claimed, ${n?"green":i?"red":"orange"} = ${f.toLowerCase()} the claim.`;return t.jsxs("div",{className:s,title:k,children:[t.jsx("div",{className:"relative h-3 text-2xs font-mono",children:c&&t.jsx(pe,{pct:h,place:"above",label:y,title:`Time to claim: ${y}`})}),t.jsxs("div",{className:"flex w-full rounded-full overflow-hidden",style:{height:Wt,backgroundColor:"rgb(var(--lt-surface-sunken))"},title:k,children:[t.jsx("div",{style:{width:`${h}%`,minWidth:Wt,backgroundColor:Et.pending,opacity:.75},title:`Waiting ${y} — created → claimed`}),c&&b>0&&t.jsx("div",{style:{width:`${b}%`,minWidth:Wt,backgroundColor:g,opacity:.75},title:`${f} ${St(m)}`})]}),t.jsx("div",{className:"relative h-3 text-2xs font-mono",children:t.jsx(pe,{pct:100,place:"below",emphasis:!0,label:_,title:j})})]})}function zs({triage:e,payload:s}){const a=e.confidence??0,r=a>=.8?"text-status-success":a>=.5?"text-status-pending":"text-status-error",n=Xs(e.originalData,s);return t.jsxs("div",{className:"space-y-5",children:[e.diagnosis&&t.jsx("p",{className:"text-sm text-text-primary leading-relaxed",children:e.diagnosis}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-text-tertiary",children:[e.tool_calls_made!=null&&t.jsxs("span",{children:[e.tool_calls_made," tool call",e.tool_calls_made!==1?"s":""]}),e.tool_calls_made!=null&&t.jsx("span",{className:"text-text-quaternary",children:"·"}),t.jsxs("span",{className:`font-medium ${r}`,children:[Math.round(a*100),"% confidence"]})]}),e.actions_taken&&e.actions_taken.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.actions_taken.map((i,d)=>t.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 text-2xs
|
|
2
|
-
text-text-secondary`,children:[t.jsx("svg",{className:"w-3 h-3 text-status-success shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),i]},d))}),e.recommendation&&t.jsx("p",{className:"text-2xs text-text-tertiary italic",children:e.recommendation}),n.length>0&&t.jsx("div",{className:"space-y-4 pt-2",children:n.map(i=>t.jsx(Gs,{diff:i},i.key))})]})}function Xs(e,s){if(!e)return[];const a=[];for(const r of Object.keys(e)){if(r.startsWith("_"))continue;const n=e[r],i=s[r];i!==void 0&&JSON.stringify(n)!==JSON.stringify(i)&&a.push({key:r,label:r.replace(/[_-]/g," "),original:n,corrected:i})}return a}function Gs({diff:e}){const s=me(e.original),a=me(e.corrected);return s!==null&&a!==null?t.jsx("div",{className:"@container",children:t.jsxs("div",{className:"grid grid-cols-1 @form-cols:grid-cols-2 gap-x-8 gap-y-3",children:[t.jsxs("div",{children:[t.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[e.label," ",t.jsx("span",{className:"normal-case font-normal",children:"(original)"})]}),t.jsx("p",{className:"text-sm text-text-tertiary leading-relaxed line-through decoration-text-tertiary/30",children:s})]}),t.jsxs("div",{children:[t.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[e.label," ",t.jsx("span",{className:"normal-case font-normal text-status-success",children:"(corrected)"})]}),t.jsx("p",{className:"text-sm text-text-primary leading-relaxed",children:a})]})]})}):t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[e.label," ",t.jsx("span",{className:"normal-case font-normal",children:"(original)"})]}),t.jsx("pre",{className:"text-xs text-text-tertiary font-mono whitespace-pre-wrap leading-relaxed",children:typeof e.original=="object"?JSON.stringify(e.original,null,2):String(e.original)})]}),t.jsxs("div",{children:[t.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[e.label," ",t.jsx("span",{className:"normal-case font-normal text-status-success",children:"(corrected)"})]}),t.jsx("pre",{className:"text-xs text-text-primary font-mono whitespace-pre-wrap leading-relaxed",children:typeof e.corrected=="object"?JSON.stringify(e.corrected,null,2):String(e.corrected)})]})]})}function me(e){return e==null?"null":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):null}function Q(e,s){const a=s==null?void 0:s.title;if(typeof a=="string"&&a.trim().length>0)return a.trim();const r=e.split(/[_-]+/).filter(Boolean);return r.length<=1?e:r.map(n=>Ys(n)?n:n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function Ys(e){return e.length>1&&e===e.toUpperCase()&&/[A-Z]/.test(e)}const z={HELP:"help",DETAILS:"details",TRIAGE:"triage",METADATA:"metadata",CONTEXT:"context",RECORD:"record",ERRORS:"errors"},$e="lt:escalation:panel:view";function Qs(e){try{const s=localStorage.getItem($e);if(s&&e.includes(s))return s}catch{}return z.HELP}const Bs=new Set(["form_schema"]);function Zs({metadata:e,role:s}){const a=Object.entries(e??{}).filter(([r])=>!r.startsWith("_")&&!Bs.has(r));return a.length===0?t.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No metadata on this escalation."}):t.jsx("dl",{className:"space-y-3.5",children:a.map(([r,n])=>{const i=typeof n=="object"&&n!==null?JSON.stringify(n):String(n),d=ce(r,n,s),l=ce(r,n);return t.jsxs("div",{className:"group relative",children:[t.jsx("dt",{className:"text-2xs font-medium text-text-secondary uppercase tracking-wide",children:Q(r)}),t.jsxs("dd",{className:"mt-0.5 flex items-center gap-1",children:[t.jsx("span",{className:"text-xs text-text-primary font-mono break-all flex-1",children:i}),t.jsx(ct,{to:d,title:`Filter this queue: ${r} = ${i}`,className:"opacity-50 group-hover:opacity-100 transition-opacity shrink-0 p-0.5 text-text-quaternary hover:text-accent",children:t.jsx(Ms,{className:"w-3 h-3"})}),t.jsx(ct,{to:l,title:`Search all queues: ${r} = ${i}`,className:"opacity-50 group-hover:opacity-100 transition-opacity shrink-0 p-0.5 text-text-quaternary hover:text-accent",children:t.jsx($s,{className:"w-3 h-3"})})]})]},r)})})}function Ks({esc:e,claimed:s,isTerminal:a,isBuilder:r,traceUrl:n}){return t.jsxs("div",{className:"space-y-5",children:[t.jsxs("dl",{className:"space-y-3.5",children:[t.jsx(et,{label:"Status",children:t.jsx(Re,{status:e.status})}),t.jsx(et,{label:"Assigned to Role",children:t.jsx(Es,{role:e.role,size:"md"})}),t.jsxs(et,{label:"Priority",children:["P",e.priority]}),(s||a)&&e.assigned_to&&t.jsx(et,{label:"Claimed By",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5 font-medium text-text-primary",children:[t.jsx(Is,{className:"w-3 h-3 shrink-0 text-accent/75"}),t.jsx(De,{userId:e.assigned_to})]})}),t.jsx(et,{label:"Created",children:t.jsx(Lt,{date:e.created_at})}),(s||a)&&e.claimed_at&&t.jsx(et,{label:"Claimed",children:t.jsx(Lt,{date:e.claimed_at})}),s&&!a&&e.assigned_until&&t.jsx(et,{label:"Time Remaining",children:t.jsx(Yt,{until:e.assigned_until})}),e.resolved_at&&t.jsx(et,{label:"Completed",children:t.jsx("span",{className:"text-status-success",children:t.jsx(Lt,{date:e.resolved_at})})})]}),r&&t.jsxs(t.Fragment,{children:[t.jsx("hr",{className:"border-surface-border/60"}),t.jsxs("div",{className:"space-y-3.5",children:[t.jsx(ot,{label:"Escalation ID",value:e.id}),e.task_id&&t.jsx(ot,{label:"Task ID",value:e.task_id,href:`/workflows/tasks/detail/${e.task_id}`}),e.workflow_type&&t.jsx(ot,{label:"Workflow Name",value:e.workflow_type,href:`/workflows/executions?entity=${encodeURIComponent(e.workflow_type)}`}),e.workflow_id&&t.jsx(ot,{label:"Workflow ID",value:e.workflow_id,href:`/workflows/executions/${e.workflow_id}`}),e.task_queue&&t.jsx(ot,{label:"Task Queue",value:e.task_queue,href:`/admin/controlplane?queue=${encodeURIComponent(e.task_queue)}`}),e.origin_id&&e.origin_id!==e.workflow_id&&t.jsx(ot,{label:"Origin",value:e.origin_id,href:`/processes/detail/${e.origin_id}`}),e.trace_id&&t.jsx(ot,{label:"Trace",value:e.trace_id,href:n?n.replace("{traceId}",e.trace_id):void 0,external:!0})]})]})]})}function tn({errors:e,schema:s}){const a=r=>{const n=document.querySelector(`[data-field-key="${r}"]`);n&&(n.scrollIntoView({behavior:"smooth",block:"center"}),n.focus({preventScroll:!0}))};return e.length===0?t.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No errors to display."}):t.jsxs("div",{className:"space-y-1",role:"alert","aria-live":"polite",children:[t.jsxs("p",{className:"text-2xs font-semibold uppercase tracking-wider text-status-error mb-4",children:[e.length," ",e.length===1?"issue":"issues"," to resolve"]}),t.jsx("div",{className:"space-y-1.5",children:e.map(({field:r,message:n})=>{var i;return t.jsxs("button",{onClick:()=>a(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:[t.jsx(Me,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-status-error/60 group-hover:text-status-error transition-colors"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-2xs font-semibold text-text-primary leading-snug",children:Q(r,(i=s==null?void 0:s.properties)==null?void 0:i[r])}),t.jsx("p",{className:"text-2xs text-text-tertiary group-hover:text-text-secondary transition-colors leading-snug mt-0.5",children:n})]})]},r)})}),t.jsx("p",{className:"text-2xs text-text-quaternary mt-4 px-3",children:"Click an issue to scroll to and focus the field."})]})}function en({esc:e,schema:s,envelope:a,payload:r,resolver:n,triage:i,hasAI:d,claimed:l,claimedByMe:c,isTerminal:u,isBuilder:o,traceUrl:x,open:m,noGutter:h,formErrors:b,activePanel:g,onPanelChange:f}){const y=Gt(),_=Object.values(z),[j,k]=p.useState(()=>Qs(_)),T=g??j,$=p.useCallback(E=>{try{localStorage.setItem($e,E)}catch{}k(E),f==null||f(E)},[f]);p.useEffect(()=>{g&&g!==j&&k(g)},[g]);const M=p.useMemo(()=>Ns(s,{escalation:e,metadata:e.metadata??null,envelope:a,payload:r,resolver:n})??vs({isTerminal:u,status:e.status,claimed:l,claimedByMe:c}),[s,e,a,r,n,u,l,c]),C=p.useCallback(E=>{const I=E.target.closest("a"),P=I==null?void 0:I.getAttribute("href");P!=null&&P.startsWith("/")&&(E.preventDefault(),y(P))},[y]),D=[{id:z.HELP,icon:Ie,label:"Instructions",content:t.jsx(Ot,{content:M,onClick:C})},{id:z.DETAILS,icon:As,label:"Details",content:t.jsx(Ks,{esc:e,claimed:l,isTerminal:u,isBuilder:o,traceUrl:x})},...d&&i?[{id:z.TRIAGE,icon:Ts,label:"AI Analysis",content:t.jsx(zs,{triage:i,payload:r??{}})}]:[],{id:z.METADATA,icon:Os,label:"Metadata",content:t.jsx(Zs,{metadata:e.metadata,role:e.role})},{id:z.CONTEXT,icon:Rs,label:"Context",content:t.jsxs("div",{className:"space-y-5",children:[a!=null&&t.jsx(wt,{data:a,label:"Input Envelope"}),r!=null&&t.jsx(wt,{data:r,label:"Escalation Context"}),n!=null&&t.jsx(wt,{data:n,label:"Resolver Payload"}),a==null&&r==null&&n==null&&t.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No context on this escalation."})]})},...o?[{id:z.RECORD,icon:Ds,label:"Record",content:t.jsx(wt,{data:e,label:"Escalation Record"})}]:[],...b&&b.length>0?[{id:z.ERRORS,icon:(({className:E})=>t.jsx(Me,{className:`${E??""} text-status-error`})),label:"Errors",content:t.jsx(tn,{errors:b,schema:s})}]:[]];return t.jsx(as,{open:m,width:384,className:"h-full",children:t.jsx("div",{className:`h-full${h?"":" pl-6"}`,children:t.jsxs("div",{className:"h-full flex flex-col bg-surface-hover",children:[t.jsx("div",{className:"shrink-0 pt-1.5 pb-0.5 flex justify-center",children:t.jsx(Us,{esc:e,className:"w-[80%]"})}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(is,{views:D,activeId:T,onViewChange:$,stickyClassName:"h-full min-h-0"})})]})})})}function sn(e,s){if(typeof e!="string"||!s)return[];const a=e.indexOf(".");if(a===-1)return[];const r=s[e.slice(0,a)];if(!r||typeof r!="object")return[];let n=r;for(const i of e.slice(a+1).split("."))if(n=n[i],n===void 0)return[];return Array.isArray(n)?n:[]}function nn(e,s,a){if((s==null?void 0:s["x-lt-widget"])!=="checklist"||s["x-lt-require-all"]!==!0)return;const n=sn(s["x-lt-source"],a).filter(l=>l.required!==!1);if(n.length===0)return;const i=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{},d=n.filter(l=>!i[l.id]).length;if(d!==0)return`${d} of ${n.length} checks incomplete`}function rn(e,s){const a=s==null?void 0:s.type;if(typeof a=="string"&&!(e==null||e===""))switch(a){case"string":return typeof e=="string"?void 0:"Expected text";case"number":return typeof e=="number"&&Number.isFinite(e)?void 0:"Expected a number";case"integer":return typeof e=="number"&&Number.isInteger(e)?void 0:"Expected a whole number";case"boolean":return typeof e=="boolean"?void 0:"Expected true or false";case"array":return Array.isArray(e)?void 0:"Expected a list";case"object":return typeof e=="object"&&!Array.isArray(e)?void 0:"Expected an object";default:return}}function an(e,s,a){if(!s)return;const r=s.enum;if(Array.isArray(r)&&r.length>0&&e!==void 0&&e!==null&&e!==""&&!r.includes(e))return`Must be one of: ${r.map(n=>String(n)).join(", ")}`;if(typeof e=="string"){const n=e.trim();if(n==="")return;const i=ht(s.minLength,s["x-lt-min-length"],a);if(i!==void 0&&n.length<i)return`Minimum ${i} character${i===1?"":"s"}`;const d=ht(s.maxLength,s["x-lt-max-length"],a);if(d!==void 0&&n.length>d)return`Maximum ${d} characters (${n.length} entered)`;const l=s.pattern;if(l)try{if(!new RegExp(l).test(n))return s["x-lt-pattern-error"]??"Invalid format"}catch{}const c=s.format;if(c==="email"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n))return"Enter a valid email address";if(c==="uri"&&!/^https?:\/\/.+/.test(n))return"Enter a valid URL"}if(typeof e=="number"){const n=ht(s.minimum,s["x-lt-minimum"],a),i=ht(s.exclusiveMinimum,void 0,a),d=ht(s.maximum,s["x-lt-maximum"],a),l=ht(s.exclusiveMaximum,void 0,a);if(n!==void 0&&e<n)return`Minimum value is ${n}`;if(i!==void 0&&e<=i)return`Must be greater than ${i}`;if(d!==void 0&&e>d)return`Maximum value is ${d}`;if(l!==void 0&&e>=l)return`Must be less than ${l}`}}function ht(e,s,a){if(typeof e=="number")return e;if(typeof s=="string"&&a){const r=s.indexOf(".");if(r!==-1){const n=s.slice(0,r),i=s.slice(r+1),d=a[n];if(d&&typeof d=="object"){const l=i.split(".");let c=d;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 Se(e,s,a,r,n){if(!r)return;if(a){if(e==null||typeof e=="boolean"&&!e||typeof e=="string"&&e.trim()==="")return"Required";if(typeof e=="object"&&!Array.isArray(e)&&e!==null){const l=Object.values(e);if(l.length===0||l.every(c=>!c))return"Required"}}const i=rn(e,s);if(i)return i;const d=nn(e,s,n);return d||an(e,s,n)}function fe(e){return e!=null&&e!==""&&e!==!1&&e!==0}function on(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function he(e,s){const a=e.indexOf("."),r=a===-1?e:e.slice(0,a);if(!ws.includes(r))return{known:!1,value:void 0};const n=s[r];if(a===-1)return{known:!0,value:n};try{return{known:!0,value:Qt(n,e.slice(a+1))}}catch{return{known:!0,value:void 0}}}function Le(e,s){if(typeof e!="string"||e.length===0||!s)return!0;const a=e.startsWith("!"),r=a?e.slice(1):e,n=r.indexOf("!="),i=r.indexOf("=");if(n!==-1||i!==-1&&i!==n+1){const c=n!==-1&&(i===-1||n<i),u=c?n:i,o=r.slice(0,u).trim(),x=r.slice(u+(c?2:1)).trim(),{known:m,value:h}=he(o,s);if(!m)return!0;const b=on(h)===x,g=c?!b:b;return a?!g:g}const{known:d,value:l}=he(r,s);return d?a?!fe(l):fe(l):!0}function Pe(e,s,a){if(!e)return[];const r=e.properties??{},n=new Set(e.required??[]),i={...a??{},resolver:s},d=[];for(const[l,c]of Object.entries(r)){if(!Le(c["x-lt-showIf"],i))continue;const u=Se(s[l],c,n.has(l),!0,i);u&&d.push({field:l,message:u})}return d}function ln(e,s){if(!e)return{};const a={};for(const[r,n]of Object.entries(e))a[r]=typeof n=="string"?st(n,s):n;return a}function We(e,s,a){const r=ln(e.facets,s),n={role:e.role,status:e.status??"pending",facets:r,limit:e.limit,enabled:!!(e.role||Object.keys(r).length)};return e.assigned==="me"?{...n,assigned_to:a,available:!1,enabled:n.enabled&&!!a}:e.assigned==="any"?n:{...n,available:e.available??!0}}const cn="{{count}} related items are still pending";function dn(e,s){const{user:a}=zt(),r=We((e==null?void 0:e.query)??{},s??{},a==null?void 0:a.userId),{data:n}=we({role:r.role,status:r.status,facets:r.facets,assigned_to:r.assigned_to,available:r.available,limit:1,enabled:!!e&&r.enabled}),i=(n==null?void 0:n.total)??0,d=!!e&&e.mustBeEmpty!==!1&&i>0,l=(e==null?void 0:e.message)??cn,c=d?st(l.replace(/\{\{count\}\}/g,String(i)),s??{}):"";return{blocked:d,count:i,message:c}}function xn(e){const{mode:s,activeView:a,onActiveViewChange:r,onClaim:n,claimPending:i,claimNudge:d,workflowType:l,json:c,onResolve:u,resolvePending:o,resolveError:x,requestTriage:m,triageNotes:h,currentRole:b,escalationTargets:g,onEscalate:f,escalatePending:y,escalateError:_,onRelease:j,releasePending:k,onCancel:T,assignedTo:$,assignedUntil:M,onSubmitAttempt:C,onValidationErrors:D,escalationContext:E}=e,I=_e(),[P,V]=p.useState("30"),[L,H]=p.useState(0),[B,J]=p.useState(""),[w,O]=p.useState(""),v=P==="custom",R=p.useCallback(A=>H(A),[]),S=p.useMemo(()=>{var A;try{const W=(A=JSON.parse(c))==null?void 0:A._form_schema;return W==null?void 0:W["x-lt-submit-guard"]}catch{return}},[c]),Z=dn(S,E),dt=Z.blocked&&!m;if(s==="terminal")return null;const jt=()=>{const A=v?L:parseInt(P);!A||A<=0||n(A)},xt=()=>{if(J(""),m){const nt={_lt:{needsTriage:!0}};h.trim()&&(nt.notes=h.trim()),u(nt);return}let A;try{A=JSON.parse(c)}catch{J("Invalid JSON");return}const W=A._form_schema;if(W){const nt=Pe(W,A,E);if(nt.length>0){C==null||C(),D==null||D(nt);return}}const{_form_schema:bt,...ut}=A;u(ks(ut,W))},X=A=>`text-xs transition-colors ${A?"text-accent font-medium":"text-text-tertiary hover:text-accent"}`;return t.jsxs("div",{className:"shrink-0 h-[80px] bg-surface/95 backdrop-blur-sm border-t border-surface-border -ml-10 pl-10 pr-10 pt-3 pb-5","data-testid":"escalation-action-bar",children:[s==="available"&&t.jsxs("div",{"data-testid":"claim-bar",children:[t.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[I.map(A=>t.jsx("button",{onClick:()=>{V(A.value),H(0)},className:X(!v&&P===A.value),children:A.label},A.value)),t.jsx("button",{onClick:()=>V("custom"),className:X(v),children:"Other"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:T,className:"text-xs text-text-tertiary hover:text-status-error transition-colors",children:"Cancel escalation"}),t.jsx("div",{className:"flex-1"}),v&&t.jsx(Ee,{onChange:R,compact:!0,autoFocus:!0}),t.jsx("button",{onClick:jt,disabled:i||v&&L<=0,className:`btn-primary text-xs ${d?"animate-[field-shake_0.4s_ease-in-out]":""}`,"data-testid":"claim-button",children:i?"Claiming...":"Claim"},d)]})]}),s==="claimed_by_other"&&t.jsxs("div",{className:"flex items-center gap-4","data-testid":"claimed-other-bar",children:[t.jsxs("p",{className:"text-sm text-text-secondary",children:["Claimed by ",t.jsx("span",{className:"font-medium text-text-primary",children:$?t.jsx(De,{userId:$}):"unknown"})]}),M&&t.jsx(Yt,{until:M})]}),s==="claimed_by_me"&&t.jsxs("div",{"data-testid":"action-bar",children:[t.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[t.jsx("button",{onClick:()=>r("resolve"),className:X(a==="resolve"),children:l?"Resolve":"Acknowledge"}),g.length>0&&t.jsx("button",{onClick:()=>r("escalate"),className:X(a==="escalate"),children:"Escalate"}),t.jsx("button",{onClick:()=>r("release"),className:`text-xs transition-colors ${a==="release"?"text-status-error font-medium":"text-text-tertiary hover:text-status-error"}`,children:"Release"}),t.jsx("button",{onClick:T,className:"text-xs transition-colors text-text-tertiary hover:text-status-error",children:"Cancel"})]}),a==="resolve"&&t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("div",{className:"flex-1"}),B&&t.jsx("span",{className:"text-xs text-status-error",children:B}),x&&t.jsx("span",{className:"text-xs text-status-error",children:x.message}),dt&&t.jsx("span",{className:"text-xs text-status-pending","data-testid":"submit-guard-message",children:Z.message}),t.jsx("button",{onClick:xt,disabled:o||dt,className:"btn-primary text-xs",children:o?l?"Submitting...":"Acknowledging...":m?"Send to Triage":l?"Submit":"Acknowledge"})]}),a==="escalate"&&t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("span",{className:"text-xs text-text-secondary",children:["From ",t.jsx("span",{className:"font-medium text-text-primary",children:b})," to"]}),t.jsxs("select",{value:w,onChange:A=>O(A.target.value),className:"select text-xs","data-testid":"escalate-select",children:[t.jsx("option",{value:"",children:"Select role..."}),g.map(A=>t.jsx("option",{value:A,children:A},A))]}),t.jsx("div",{className:"flex-1"}),_&&t.jsx("span",{className:"text-xs text-status-error",children:_.message}),t.jsx("button",{onClick:()=>f(w),disabled:!w||y,className:"btn-primary text-xs",children:y?"Escalating...":"Escalate"})]}),a==="release"&&t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"text-xs text-text-secondary",children:"Release back to pool?"}),t.jsx("div",{className:"flex-1"}),t.jsx("button",{onClick:()=>r("resolve"),className:"btn-secondary text-xs",children:"Back"}),t.jsx("button",{onClick:j,disabled:k,className:"btn-primary text-xs bg-status-error hover:bg-status-error/80",children:k?"Releasing...":"Yes, Release"})]})]})]})}function Ft({children:e}){return t.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-1.5",children:e})}function un({payload:e,isTerminal:s,resolverPayload:a,onRetryTriage:r,isRetrying:n}){const i=e.title,d=e.summary,l=e.diagnosis,c=e.tool_calls_made,u=e.result,o=a==null?void 0:a._lt,x=(o==null?void 0:o.triaged)===!0,m=o==null?void 0:o.triageWorkflowId,h=s&&x,[b,g]=p.useState(!1);return h?t.jsxs("div",{className:"rounded-md border border-status-success/30 bg-surface-raised",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("svg",{className:"w-4 h-4 text-status-success shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M8 1a7 7 0 110 14A7 7 0 018 1zm3.36 4.65a.5.5 0 00-.72 0L7 9.29 5.36 7.65a.5.5 0 10-.72.7l2 2a.5.5 0 00.72 0l4-4a.5.5 0 000-.7z"})}),t.jsx("span",{className:"text-xs font-medium text-status-success",children:"Resolved by AI Triage"})]}),typeof c=="number"&&t.jsxs("span",{className:"text-2xs font-mono px-2 py-0.5 rounded-full bg-status-success/10 text-status-success",children:[c," tool calls used"]})]}),t.jsxs("div",{className:"px-4 py-4 space-y-4",children:[i&&t.jsx("p",{className:"text-sm font-medium text-text-primary",children:i}),l&&t.jsxs("div",{children:[t.jsx(Ft,{children:"Triage diagnosis"}),t.jsx("div",{className:"text-xs text-text-primary leading-relaxed",children:t.jsx(Pt,{content:l})})]}),t.jsx("div",{className:"flex items-center gap-3",children:m&&t.jsx(ct,{to:`/workflows/executions/${m}`,className:"text-2xs text-accent hover:underline",children:"View triage execution"})})]})]}):t.jsxs("div",{className:"rounded-md border border-status-warning/30 bg-surface-raised",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("svg",{className:"w-4 h-4 text-status-warning shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M8 1a7 7 0 110 14A7 7 0 018 1zm0 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 4zm0 7a.75.75 0 100-1.5.75.75 0 000 1.5z"})}),t.jsx("span",{className:"text-xs font-medium text-status-warning",children:"Tool Rounds Exhausted"})]}),typeof c=="number"&&t.jsxs("span",{className:"text-2xs font-mono px-2 py-0.5 rounded-full bg-status-warning/10 text-status-warning",children:[c," tool calls used"]})]}),t.jsxs("div",{className:"px-4 py-4 space-y-4",children:[i&&t.jsx("p",{className:"text-sm font-medium text-text-primary",children:i}),d&&t.jsxs("div",{children:[t.jsx(Ft,{children:"What happened"}),t.jsx("div",{className:"text-xs text-text-secondary leading-relaxed",children:t.jsx(Pt,{content:d})})]}),l&&t.jsxs("div",{children:[t.jsx(Ft,{children:"What went wrong"}),t.jsx("div",{className:"text-xs text-text-primary leading-relaxed",children:t.jsx(Pt,{content:l})})]}),u!=null&&t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>g(!b),className:"flex items-center gap-1 text-2xs font-semibold uppercase tracking-widest text-text-tertiary hover:text-text-secondary transition-colors",children:[t.jsx("svg",{className:`w-3 h-3 transition-transform ${b?"rotate-90":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:t.jsx("path",{d:"M4.5 2l4 4-4 4"})}),"Partial results"]}),b&&t.jsx("div",{className:"mt-2",children:t.jsx(wt,{data:u,defaultMode:"tree"})})]}),r&&!s&&t.jsx("div",{className:"pt-2",children:t.jsxs("button",{onClick:r,disabled:n,className:"inline-flex items-center gap-2 px-4 py-2 text-xs font-medium bg-accent text-text-inverse rounded-md hover:bg-accent/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[t.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 14 14",fill:"currentColor",children:t.jsx("path",{d:"M7 1a6 6 0 100 12A6 6 0 007 1zm2.5 6.5l-3.5 2V5.5l3.5 2z"})}),n?"Sending to triage...":"Retry with AI Triage"]})})]})]})}function ge(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Fe({src:e,escalation:s,schema:a,onResolve:r,onEscalate:n,submitAttempted:i,fill:d}){const l=p.useRef(null),c=p.useRef("");p.useEffect(()=>{try{const o=new URL(e);c.current=o.origin}catch{c.current=""}},[e]);const u=p.useCallback(()=>{const o=l.current;if(!(o!=null&&o.contentWindow)||!c.current)return;const m={type:"lt:init",escalation:{id:s.id,type:s.type,subtype:s.subtype,description:s.description,status:s.status,priority:s.priority,role:s.role,workflow_type:s.workflow_type,envelope:ge(s.envelope),metadata:s.metadata??null,escalation_payload:ge(s.escalation_payload)},schema:a};o.contentWindow.postMessage(m,c.current)},[s,a]);return p.useEffect(()=>{const o=x=>{if(x.origin!==c.current)return;const m=x.data;if(!(!m||typeof m!="object"||typeof m.type!="string"))switch(m.type){case"lt:ready":u();break;case"lt:submit":m.payload&&typeof m.payload=="object"&&r(m.payload);break;case"lt:escalate":typeof m.target=="string"&&m.target&&n(m.target);break;case"lt:resize":{const h=l.current;h&&typeof m.height=="number"&&m.height>0&&(h.style.height=`${Math.min(m.height,2e3)}px`);break}}};return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[u,r,n]),p.useEffect(()=>{if(!i)return;const o=l.current;o!=null&&o.contentWindow&&c.current&&o.contentWindow.postMessage({type:"lt:validate"},c.current)},[i]),d?t.jsx("div",{className:"absolute inset-0 overflow-hidden",children:t.jsx("iframe",{ref:l,src:e,sandbox:"allow-scripts allow-same-origin allow-forms allow-pointer-lock allow-downloads",className:"w-full h-full border-0 block",title:"HITL Viewport",onLoad:u})}):t.jsx("div",{className:"rounded-md border border-surface-border overflow-hidden bg-white",children:t.jsx("iframe",{ref:l,src:e,sandbox:"allow-scripts allow-same-origin allow-forms allow-pointer-lock allow-downloads",className:"w-full border-0",style:{minHeight:"600px"},title:"HITL Viewport",onLoad:u})})}function F({children:e,isRequired:s,htmlFor:a}){return t.jsxs("label",{htmlFor:a,className:"block text-2xs font-semibold uppercase tracking-wider text-text-secondary",children:[e,s&&t.jsx("span",{className:"text-status-error ml-0.5",children:"*"})]})}function G({id:e,children:s}){return t.jsx("p",{id:e,className:"text-2xs text-text-tertiary mt-0.5 leading-snug",children:s})}function lt({error:e,id:s}){return e?t.jsx("p",{id:s,role:"alert",className:"text-2xs text-status-error mt-1 animate-[field-error-in_0.3s_ease-out]",children:e}):null}function Nt(e){return e?"input text-sm w-full mt-1 border-status-error/50 focus:border-status-error animate-[field-shake_0.4s_ease-in-out]":"input text-sm w-full mt-1"}function pn(e){return e?"select text-sm mt-1 min-w-[min(16rem,100%)] max-w-full border-status-error/50 focus:border-status-error animate-[field-shake_0.4s_ease-in-out]":"select text-sm mt-1 min-w-[min(16rem,100%)] max-w-full"}function mn({fieldKey:e,value:s,onChange:a,schema:r,isRequired:n}){const i=p.useRef(null),d=(r==null?void 0:r.accept)??void 0,l=Q(e,r),c=r==null?void 0:r.description,u=p.useCallback(x=>{var b;const m=(b=x.target.files)==null?void 0:b[0];if(!m)return;const h=new FileReader;h.onload=()=>{typeof h.result=="string"&&a(h.result)},h.readAsDataURL(m)},[a]),o=s.startsWith("data:");return t.jsxs("div",{children:[t.jsx(F,{isRequired:n,children:l}),c&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:c}),t.jsxs("div",{className:"mt-1",children:[t.jsx("input",{ref:i,type:"file",accept:d,onChange:u,className:"hidden"}),t.jsx("button",{type:"button",onClick:()=>{var x;return(x=i.current)==null?void 0:x.click()},className:"btn-secondary text-xs px-3 py-1.5",children:o?"Replace file":"Choose file"}),o&&t.jsx("span",{className:"ml-2 text-xs text-status-success",children:"File attached"})]})]})}function fn({fieldKey:e,value:s,onChange:a,schema:r,isRequired:n}){const i=Q(e,r),d=r==null?void 0:r.description,l=(r==null?void 0:r["x-lt-language"])??"",c=p.useCallback(u=>{if(u.key==="Tab"){u.preventDefault();const o=u.currentTarget,x=o.selectionStart,m=o.selectionEnd,h=s.substring(0,x)+" "+s.substring(m);a(h),requestAnimationFrame(()=>{o.selectionStart=o.selectionEnd=x+2})}},[s,a]);return t.jsxs("div",{children:[t.jsxs(F,{isRequired:n,children:[i,l&&t.jsx("span",{className:"ml-2 text-text-tertiary/60 normal-case font-normal",children:l})]}),d&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:d}),t.jsx("textarea",{value:s,onChange:u=>a(u.target.value),onKeyDown:c,className:"input w-full mt-1 font-mono text-xs leading-relaxed",rows:10,spellCheck:!1})]})}function hn({fieldKey:e,value:s,onChange:a,schema:r,isRequired:n}){const i=p.useRef(null),[d,l]=p.useState(!1),c=Q(e,r),u=r==null?void 0:r.description;p.useEffect(()=>{const g=i.current;if(!g)return;const f=g.getContext("2d");if(f&&(f.lineWidth=2,f.lineCap="round",f.strokeStyle="#1E1535",s&&s.startsWith("data:"))){const y=new Image;y.onload=()=>f.drawImage(y,0,0),y.src=s}},[]);const o=p.useCallback(g=>{const f=i.current,y=f.getBoundingClientRect(),_=y.width>0?f.width/y.width:1,j=y.height>0?f.height/y.height:1;return"touches"in g?{x:(g.touches[0].clientX-y.left)*_,y:(g.touches[0].clientY-y.top)*j}:{x:(g.clientX-y.left)*_,y:(g.clientY-y.top)*j}},[]),x=p.useCallback(g=>{var _;l(!0);const f=(_=i.current)==null?void 0:_.getContext("2d");if(!f)return;const y=o(g);f.beginPath(),f.moveTo(y.x,y.y)},[o]),m=p.useCallback(g=>{var _;if(!d)return;const f=(_=i.current)==null?void 0:_.getContext("2d");if(!f)return;const y=o(g);f.lineTo(y.x,y.y),f.stroke()},[d,o]),h=p.useCallback(()=>{l(!1);const g=i.current;g&&a(g.toDataURL("image/png"))},[a]),b=p.useCallback(()=>{const g=i.current;if(!g)return;const f=g.getContext("2d");f&&(f.clearRect(0,0,g.width,g.height),a(""))},[a]);return t.jsxs("div",{children:[t.jsx(F,{isRequired:n,children:c}),u&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:u}),t.jsx("div",{className:"mt-1 max-w-[25rem] border border-surface-border rounded-md overflow-hidden bg-white",children:t.jsx("canvas",{ref:i,width:400,height:150,className:"w-full cursor-crosshair touch-none",onMouseDown:x,onMouseMove:m,onMouseUp:h,onMouseLeave:h,onTouchStart:x,onTouchMove:m,onTouchEnd:h})}),t.jsx("button",{type:"button",onClick:b,className:"mt-1 text-2xs text-text-tertiary hover:text-accent transition-colors",children:"Clear"})]})}function gn({fieldKey:e,value:s,onChange:a,schema:r,isRequired:n}){const i=Q(e,r),d=r==null?void 0:r.description;return t.jsxs("div",{children:[t.jsx(F,{isRequired:n,children:i}),d&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:d}),t.jsx("textarea",{value:s,onChange:l=>a(l.target.value),className:"input w-full mt-1 text-sm leading-relaxed",rows:8,placeholder:"Supports plain text. Markdown formatting is preserved."})]})}function jn({fieldKey:e,value:s,onChange:a,schema:r,isRequired:n}){const[i,d]=p.useState("write"),l=Q(e,r),c=r==null?void 0:r.description;return(r==null?void 0:r.readOnly)===!0?t.jsx(Ot,{content:s,className:"my-1"}):t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(F,{isRequired:n,children:l}),t.jsx("div",{className:"flex items-center gap-0.5",children:["write","preview"].map(o=>t.jsx("button",{type:"button",onClick:()=>d(o),className:`px-2 py-0.5 text-2xs rounded transition-colors ${i===o?"bg-accent/10 text-accent font-semibold":"text-text-quaternary hover:text-text-secondary"}`,children:o==="write"?"Write":"Preview"},o))})]}),c&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:c}),i==="write"?t.jsx("textarea",{value:s,onChange:o=>a(o.target.value),className:"input w-full mt-1 text-sm font-mono leading-relaxed",rows:10,placeholder:"Write markdown — headings, lists, tables, code blocks, and links all render."}):t.jsx("div",{className:"mt-1 px-3 py-2 border border-surface-border rounded min-h-[120px]",children:s.trim()?t.jsx(Ot,{content:s}):t.jsx("p",{className:"text-xs text-text-quaternary italic",children:"Nothing to preview."})})]})}const bn=28;function yn({fieldKey:e,value:s,onChange:a,schema:r,escalationContext:n,isRequired:i,submitAttempted:d,error:l}){const c=r==null?void 0:r["x-lt-source"],u=(r==null?void 0:r["x-lt-require-all"])===!0,o=[];if(c&&n){const j=c.indexOf(".");if(j!==-1){const k=c.slice(0,j),T=c.slice(j+1);try{const $=Qt(n[k],T);Array.isArray($)&&o.push(...$)}catch{}}}let x={};try{s&&(x=JSON.parse(s))}catch{}const m=j=>a(JSON.stringify({...x,[j]:!x[j]})),h=Q(e,r),b=r==null?void 0:r.description;if(o.length===0)return t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-xs text-text-tertiary italic mt-1",children:"No checklist items. Provide checklist_items in the escalation envelope or metadata."}),l&&t.jsx("p",{className:"text-2xs text-status-error mt-1 animate-[field-error-in_0.3s_ease-out]",children:l})]});const g=r==null?void 0:r["x-lt-variant"],f=g==="chips"||g==="rows"?g:u||o.some(j=>j.label.length>bn)?"rows":"chips",y=o.filter(j=>x[j.id]).length,_=(o.find(j=>!x[j.id]&&j.required!==!1)??o[0]).id;return t.jsxs("div",{role:"group","aria-label":h,"aria-required":i||void 0,"aria-invalid":l?!0:void 0,children:[t.jsx(F,{isRequired:i,children:h}),b&&t.jsx(G,{children:b}),f==="chips"?t.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:o.map(j=>{const k=x[j.id]??!1,T=!k&&!!d&&y===0&&(j.required||i);return t.jsxs("label",{className:`inline-flex items-center gap-1.5 cursor-pointer select-none px-3.5 py-2 text-sm border transition-colors rounded-[var(--lt-radius-field)] ${k?"bg-accent border-accent text-text-inverse":T?"bg-surface-field border-status-error/60 text-status-error":"bg-surface-field border-surface-field-border text-text-secondary hover:border-accent hover:text-text-primary"}`,children:[t.jsx("input",{type:"checkbox",checked:k,onChange:()=>m(j.id),className:"sr-only","data-testid":`checklist-item-${j.id}`,...j.id===_?{"data-field-key":e}:{}}),k&&t.jsx(Ss,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:2.5}),j.label]},j.id)})}):t.jsx("div",{className:"space-y-2.5 mt-2",children:o.map(j=>{const k=x[j.id]??!1,T=!k&&!!d&&(u?j.required!==!1:y===0&&(j.required||i));return t.jsxs("label",{className:`flex items-start gap-3 cursor-pointer group select-none rounded px-2 py-1 -mx-2 transition-colors ${T?"bg-status-error/5":"hover:bg-surface-hover"}`,children:[t.jsx("input",{type:"checkbox",checked:k,onChange:()=>m(j.id),className:`mt-0.5 w-3.5 h-3.5 shrink-0 rounded ${T?"accent-status-error":"accent-accent"}`,"data-testid":`checklist-item-${j.id}`,...j.id===_?{"data-field-key":e}:{}}),t.jsxs("span",{className:`text-sm leading-snug transition-colors ${T?"text-status-error":"text-text-secondary group-hover:text-text-primary"}`,children:[j.label,j.required&&t.jsx("span",{className:`ml-0.5 text-2xs ${T?"text-status-error":"text-text-quaternary"}`,children:"*"})]})]},j.id)})}),t.jsx("p",{className:"text-2xs text-text-quaternary mt-3 tabular-nums",children:f==="chips"?t.jsxs(t.Fragment,{children:[y," selected",i&&y===0&&!!d&&t.jsx("span",{className:"ml-1 text-text-quaternary/60",children:"(check at least one)"})]}):t.jsxs(t.Fragment,{children:[y," / ",o.length," confirmed",u?t.jsxs("span",{className:"ml-1 text-text-quaternary/60",children:["(all required",o.some(j=>j.required===!1)?" except optional":"",")"]}):i&&y===0&&!!d&&t.jsx("span",{className:"ml-1 text-text-quaternary/60",children:"(at least one required)"})]})}),l&&t.jsx("p",{role:"alert",className:"text-2xs text-status-error mt-1 animate-[field-error-in_0.3s_ease-out]",children:l})]})}const Nn=/\.(png|jpe?g|gif|webp|avif|bmp|svg)(\?.*)?$/i;function vn(e){var r,n,i,d;const s=e.trim();if(!s)return{kind:"none"};const a=(n=(r=/^data:([^;,]+)[;,]/.exec(s))==null?void 0:r[1])==null?void 0:n.toLowerCase();if(a)return a.startsWith("image/")?{kind:"image",src:s}:{kind:"file",href:s,label:a==="application/pdf"?"PDF":a,isData:!0};if(/^https?:\/\//i.test(s)){if(Nn.test(s))return{kind:"image",src:s};const l=(d=(i=/\.([a-z0-9]{2,5})(\?.*)?$/i.exec(s))==null?void 0:i[1])==null?void 0:d.toUpperCase();return{kind:"file",href:s,label:l??"attachment",isData:!1}}return{kind:"none"}}function je({fieldKey:e,value:s,schema:a}){const[r,n]=p.useState(!1),i=vn(s??""),d=e.replace(/[_-]/g," "),l=a==null?void 0:a.description,c=t.jsxs(t.Fragment,{children:[t.jsx("label",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary",children:d}),l&&t.jsx("p",{className:"text-2xs text-text-tertiary mt-0.5",children:l})]});return i.kind==="none"?t.jsxs("div",{children:[c,t.jsx("p",{className:"text-xs text-text-quaternary italic mt-1",children:"No attachment"})]}):i.kind==="image"?t.jsxs("div",{children:[c,t.jsxs("div",{className:"mt-1",children:[t.jsx("button",{type:"button",onClick:()=>n(!0),className:"block rounded-[0.125em] border border-surface-border overflow-hidden hover:border-accent transition-colors",title:"View full size",children:t.jsx("img",{src:i.src,alt:e.replace(/[_-]/g," "),className:"max-h-48 max-w-full object-contain","data-testid":`attachment-image-${e}`})}),r&&t.jsx("div",{className:"fixed inset-0 z-[100] bg-text-primary/60 backdrop-blur-sm flex items-center justify-center p-8 cursor-zoom-out",onClick:()=>n(!1),role:"dialog","aria-modal":"true","aria-label":`${d} — full size`,children:t.jsx("img",{src:i.src,alt:d,className:"max-h-[90vh] max-w-[90vw] object-contain"})})]})]}):t.jsxs("div",{children:[c,t.jsx("div",{className:"mt-1",children:t.jsxs("a",{href:i.href,...i.isData?{download:`${e}.${i.label==="PDF"?"pdf":"bin"}`}:{target:"_blank",rel:"noopener noreferrer"},className:"inline-flex items-center gap-1.5 text-xs text-accent hover:text-accent-hover transition-colors","data-testid":`attachment-link-${e}`,children:[t.jsx(Ls,{className:"w-3.5 h-3.5",strokeWidth:1.5}),i.isData?`Download ${i.label}`:`Open ${i.label}`,i.isData?t.jsx(Ps,{className:"w-3 h-3",strokeWidth:1.5}):t.jsx(Ht,{className:"w-3 h-3",strokeWidth:1.5})]})})]})}function wn({fieldKey:e,schema:s,escalationContext:a}){const r=(s==null?void 0:s["x-lt-href"])??"",n=r&&a?st(r,a):r,i=(s==null?void 0:s.title)??(s==null?void 0:s.description)??"Open",d=s==null?void 0:s.description,l=n.startsWith("/"),c=!n.trim();return t.jsxs("div",{"data-field-key":e,children:[t.jsx(F,{children:i}),d&&t.jsx(G,{children:d}),t.jsx("div",{className:"mt-1",children:c?t.jsx("span",{className:"text-xs text-text-quaternary italic",children:"No link configured"}):l?t.jsxs(ct,{to:n,className:"inline-flex items-center gap-1 text-xs text-accent hover:text-accent-hover transition-colors","data-testid":`link-widget-${e}`,children:[i,t.jsx(Ht,{className:"w-3 h-3 shrink-0",strokeWidth:1.5})]}):t.jsxs("a",{href:n,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-accent hover:text-accent-hover transition-colors","data-testid":`link-widget-${e}`,children:[i,t.jsx(Ht,{className:"w-3 h-3 shrink-0",strokeWidth:1.5})]})})]})}const be="—";function kn(e,s){if(!e||!s)return"";const a=e.indexOf(".");if(a===-1)return"";const r=e.slice(0,a),n=e.slice(a+1);try{const i=Qt(s[r],n);return typeof i=="string"?i:""}catch{return""}}function Cn(e,s){if(!e||e===be)return be;if(s==="age"){const a=new Date(e);return Number.isNaN(a.getTime())?e:Xt(e)}return e}function _n({fieldKey:e,schema:s,escalationContext:a}){const r=s==null?void 0:s["x-lt-source"],n=(s==null?void 0:s["x-lt-fields"])??[],i=(s==null?void 0:s.title)??"Linked escalation",d=s==null?void 0:s.description,l=kn(r,a),{data:c,isLoading:u,isError:o}=ke(l);return t.jsxs("div",{"data-field-key":e,children:[t.jsx(F,{children:i}),d&&t.jsx(G,{children:d}),t.jsx("div",{className:"mt-1",children:!l||o?t.jsx("p",{className:"text-xs text-text-quaternary italic","data-testid":`escalation-widget-empty-${e}`,children:"No linked record"}):u?t.jsx(An,{}):c?t.jsx(En,{esc:c,fields:n,fieldKey:e}):t.jsx("p",{className:"text-xs text-text-quaternary italic",children:"No linked record"})})]})}function En({esc:e,fields:s,fieldKey:a}){if(!e)return null;const r=Bt(e);return t.jsxs("div",{className:"border-l-2 border-accent-faint pl-3 py-2 space-y-2","data-testid":`escalation-widget-card-${a}`,children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("span",{className:"text-2xs font-semibold uppercase tracking-wider text-text-secondary",children:[e.type,e.subtype&&e.subtype!==e.type?` · ${e.subtype}`:""]}),t.jsx(Re,{status:e.status})]}),e.description&&t.jsx("p",{className:"text-xs text-text-primary leading-snug",children:e.description}),s.length>0&&t.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-0.5",children:s.map(n=>{const i=st(n.value,r),d=Cn(i,n.format);return t.jsxs("div",{className:"contents",children:[t.jsx("dt",{className:"text-2xs text-text-tertiary whitespace-nowrap",children:n.label}),t.jsx("dd",{className:"text-2xs text-text-primary",children:d})]},n.label)})}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("span",{className:"text-2xs text-text-quaternary",children:[e.role," · ",Xt(e.created_at)]}),t.jsx(ct,{to:`/escalations/detail/${e.id}`,className:"text-2xs text-accent hover:text-accent-hover transition-colors",title:"Open escalation detail",children:"Detail"})]})]})}function An(){return t.jsxs("div",{className:"border-l-2 border-accent-faint pl-3 py-2 space-y-2 animate-pulse",children:[t.jsx("div",{className:"h-3 w-32 bg-surface-sunken rounded"}),t.jsx("div",{className:"h-3 w-48 bg-surface-sunken rounded"}),t.jsx("div",{className:"h-3 w-24 bg-surface-sunken rounded"})]})}const Tn=[{label:"Description",value:"{{escalation.description}}"},{label:"Role",value:"{{escalation.role}}"},{label:"Age",value:"{{escalation.created_at}}",format:"age"}],ye="—";function On(e,s){if(!e||e===ye)return ye;if(s==="age"){const a=new Date(e);return Number.isNaN(a.getTime())?e:Xt(e)}return e}function Ut(e,s){return typeof e=="string"?st(e,s):Array.isArray(e)?e.map(a=>Ut(a,s)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([a,r])=>[a,Ut(r,s)])):e}function Rn({fieldKey:e,schema:s,escalationContext:a}){const r=(s==null?void 0:s["x-lt-query"])??{},n=(s==null?void 0:s["x-lt-columns"])??Tn,i=(s==null?void 0:s["x-lt-actions"])??[],d=(s==null?void 0:s.title)??"Related items",l=s==null?void 0:s.description,c=a??{},{user:u}=zt(),o=We(r,c,u==null?void 0:u.userId),{data:x,isLoading:m}=we({role:o.role,status:o.status,facets:o.facets,assigned_to:o.assigned_to,available:o.available,limit:o.limit??5,enabled:o.enabled}),h=(x==null?void 0:x.escalations)??[],b=Ce(),[g,f]=p.useState({}),[y,_]=p.useState(null),j=async(k,T)=>{const $=Bt(k);if(!(T.confirm&&!window.confirm(st(T.confirm,$)))){_(k.id),f(M=>({...M,[k.id]:""}));try{await b.mutateAsync({id:k.id,resolverPayload:Ut(T.resolverPayload,$)})}catch(M){f(C=>({...C,[k.id]:M.message}))}finally{_(null)}}};return t.jsxs("div",{"data-field-key":e,children:[t.jsx(F,{children:d}),l&&t.jsx(G,{children:l}),t.jsx("div",{className:"mt-1","data-testid":`escalation-list-widget-${e}`,children:m?t.jsx(In,{columns:n.length}):t.jsx(Dn,{escalations:h,columns:n,fieldKey:e,actions:i,onAction:j,pendingRow:y,rowErrors:g})})]})}function Dn({escalations:e,columns:s,fieldKey:a,actions:r,onAction:n,pendingRow:i,rowErrors:d}){return e.length===0?t.jsx("p",{className:"text-xs text-text-quaternary italic py-1","data-testid":`escalation-list-empty-${a}`,children:"No items found"}):t.jsxs("table",{className:"w-full text-xs border-collapse","data-testid":`escalation-list-table-${a}`,children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-surface-border",children:[s.map(l=>t.jsx("th",{className:"text-left text-2xs font-semibold uppercase tracking-wider text-text-tertiary pb-1 pr-3 last:pr-0",children:l.label},l.label)),r.length>0&&t.jsx("th",{className:"w-px"}),t.jsx("th",{className:"w-4"})]})}),t.jsx("tbody",{children:e.map(l=>{const c=Bt(l),u=d[l.id];return t.jsxs("tr",{className:"border-b border-surface-border/50 last:border-0 hover:bg-surface-sunken/50 transition-colors",children:[s.map(o=>{const x=st(o.value,c),m=On(x,o.format);return t.jsx("td",{className:"py-1 pr-3 last:pr-0 text-text-primary align-top",children:m},o.label)}),r.length>0&&t.jsxs("td",{className:"py-1 pr-2 align-top whitespace-nowrap",children:[r.map(o=>t.jsx("button",{type:"button",onClick:()=>n(l,o),disabled:i===l.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-${l.id}`,children:o.label},o.label)),u&&t.jsx("p",{className:"text-2xs text-status-error mt-0.5 whitespace-normal max-w-[16rem]","data-testid":`escalation-list-action-error-${l.id}`,children:u})]}),t.jsx("td",{className:"py-1 align-top",children:t.jsx(ct,{to:`/escalations/detail/${l.id}`,className:"text-accent hover:text-accent-hover transition-colors",title:"Open escalation detail",tabIndex:-1,children:"→"})})]},l.id)})})]})}function In({columns:e}){return t.jsx("div",{className:"space-y-1.5 animate-pulse",children:[0,1,2].map(s=>t.jsx("div",{className:"flex gap-4",children:Array.from({length:e},(a,r)=>t.jsx("div",{className:"h-3 bg-surface-sunken rounded flex-1"},r))},s))})}const qt={"file-upload":mn,"code-editor":fn,signature:hn,"rich-text":gn,markdown:jn,checklist:yn,attachment:je,image:je,link:wn,escalation:_n,"escalation-list":Rn};function qe({fieldKey:e,value:s,onChange:a,onBlur:r,schema:n,isRequired:i,isReadOnly:d,error:l,escalationContext:c,submitAttempted:u}){var M;const o=(M=n==null?void 0:n.properties)==null?void 0:M[e],x=Q(e,o),m=o==null?void 0:o["x-lt-widget"],h=`lt-field-${e}`,b=`${h}-error`,g=`${h}-help`,f=typeof(o==null?void 0:o.description)=="string"&&o.description.length>0?o.description:void 0,j={id:h,"aria-required":i||void 0,"aria-invalid":l?!0:void 0,"aria-describedby":l?b:f!==void 0?g:void 0},k=m==="markdown"&&typeof s=="string",T=(m==="attachment"||m==="image")&&typeof s=="string",$=!!(m&&m in qt);if(d&&!k&&!T&&!$){const C=s===null?"null":typeof s=="object"?JSON.stringify(s,null,2):String(s);return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,children:x}),t.jsx("p",{className:"text-sm text-text-secondary mt-0.5 whitespace-pre-wrap",children:C})]})}if(m&&m in qt){const C=qt[m],D=i||(o==null?void 0:o["x-lt-require-all"])===!0,E={fieldKey:e,schema:o,escalationContext:c,isRequired:D,submitAttempted:u,error:l};if((o==null?void 0:o.type)==="object"){const I=typeof s=="string"?s:typeof s=="object"&&s!==null&&!Array.isArray(s)?JSON.stringify(s):"";return t.jsx(C,{...E,value:I,onChange:P=>{try{a(JSON.parse(P))}catch{a(P)}}})}if(typeof s=="string")return t.jsx(C,{...E,value:s,onChange:I=>a(I)});if(typeof s=="object"&&s!==null&&!Array.isArray(s))return t.jsx(C,{...E,value:JSON.stringify(s),onChange:I=>{try{a(JSON.parse(I))}catch{a(I)}}})}if(typeof s=="boolean")return t.jsxs("div",{children:[t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:s,onChange:C=>{a(C.target.checked),r==null||r()},className:"w-3.5 h-3.5 rounded accent-accent","data-field-key":e,...j}),t.jsxs("span",{className:"text-2xs font-semibold uppercase tracking-wider text-text-secondary",children:[x,i&&t.jsx("span",{className:"text-status-error ml-0.5",children:"*"})]})]}),f&&t.jsx(G,{id:g,children:f}),t.jsx(lt,{error:l,id:b})]});if(typeof s=="number")return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,htmlFor:h,children:x}),f&&t.jsx(G,{id:g,children:f}),t.jsx("input",{type:"number",value:s,onChange:C=>a(parseFloat(C.target.value)||0),onBlur:r,step:"any","data-field-key":e,className:`${Nt(!!l)} max-w-48`,...j}),t.jsx(lt,{error:l,id:b})]});if(typeof s=="string"){const C=(o==null?void 0:o.format)==="password",D=o==null?void 0:o.enum;if(D!=null&&D.length){const V=s===""&&!D.includes("");return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,htmlFor:h,children:x}),f&&t.jsx(G,{id:g,children:f}),t.jsxs("select",{value:s,onChange:L=>a(L.target.value),onBlur:r,"data-field-key":e,className:pn(!!l),...j,children:[V&&t.jsx("option",{value:"",disabled:!0,children:"Choose…"}),D.map(L=>t.jsx("option",{value:L,children:L},L))]}),t.jsx(lt,{error:l,id:b})]})}if(C)return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,htmlFor:h,children:x}),f&&t.jsx(G,{id:g,children:f}),t.jsx("input",{type:"password",value:s,onChange:V=>a(V.target.value),onBlur:r,"data-field-key":e,className:Nt(!!l),autoComplete:"off",...j}),t.jsx(lt,{error:l,id:b})]});const E=o==null?void 0:o.format,I={date:"date","date-time":"datetime-local",email:"email",uri:"url"},P={date:"max-w-48","date-time":"max-w-64"};if(E&&E in I)return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,htmlFor:h,children:x}),f&&t.jsx(G,{id:g,children:f}),t.jsx("input",{type:I[E],value:s,onChange:V=>a(V.target.value),onBlur:r,"data-field-key":e,className:`${Nt(!!l)} ${P[E]??""}`,...j}),t.jsx(lt,{error:l,id:b})]});if(E==="textarea"||s.length>80){const V=o==null?void 0:o.maxLength,L=o==null?void 0:o["x-lt-max-length"];let H=V;if(H===void 0&&L&&c){const J=L.indexOf(".");if(J!==-1){const w=L.slice(0,J),O=L.slice(J+1),v=c[w];if(v&&typeof v=="object"){let R=v;for(const S of O.split("."))if(R=R[S],R===void 0)break;if(typeof R=="number")H=R;else if(typeof R=="string"){const S=Number(R);Number.isNaN(S)||(H=S)}}}}const B=H!==void 0&&s.length>H;return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,htmlFor:h,children:x}),f&&t.jsx(G,{id:g,children:f}),t.jsx("textarea",{value:s,onChange:J=>{a(J.target.value),r==null||r()},onBlur:r,"data-field-key":e,className:`${Nt(!!l)} leading-relaxed`,rows:Math.min(6,Math.max(3,Math.ceil(s.length/60))),...j}),H!==void 0&&t.jsxs("p",{className:`text-2xs mt-0.5 text-right tabular-nums ${B?"text-status-error font-medium":"text-text-quaternary"}`,children:[s.length," / ",H]}),t.jsx(lt,{error:l,id:b})]})}return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,htmlFor:h,children:x}),f&&t.jsx(G,{id:g,children:f}),t.jsx("input",{type:"text",value:s,onChange:V=>a(V.target.value),onBlur:r,"data-field-key":e,className:Nt(!!l),...j}),t.jsx(lt,{error:l,id:b})]})}if(s===null)return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,children:x}),t.jsx("p",{className:"text-xs text-text-tertiary italic mt-1",children:"null"})]});if(Array.isArray(s))return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,children:x}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:s.map((C,D)=>t.jsx("span",{className:"px-2 py-0.5 text-2xs font-mono bg-surface-sunken rounded text-text-secondary",children:String(C)},D))})]});if(typeof s=="object"){const C=Object.entries(s);return t.jsxs("div",{children:[t.jsx(F,{isRequired:i,children:x}),t.jsx("div",{className:"ml-4 mt-2 pl-4 border-l border-accent-faint space-y-3",children:C.map(([D,E])=>t.jsx(qe,{fieldKey:D,value:E,onChange:I=>a({...s,[D]:I})},D))})]})}return null}function Mn({items:e,columns:s=1}){if(e.length===0)return null;const a=s>=2&&e.length>1?"grid-cols-1 @dict-inline:grid-cols-[max-content_1fr] @dict-pairs:grid-cols-[max-content_1fr_max-content_1fr]":"grid-cols-1 @dict-inline:grid-cols-[max-content_1fr]";return t.jsx("div",{className:"@container",children:t.jsx("dl",{className:`grid ${a} items-baseline gap-x-6 @dict-pairs:gap-x-8 gap-y-1.5`,children:e.map(({key:r,label:n,value:i})=>t.jsxs(p.Fragment,{children:[t.jsx("dt",{className:"text-2xs font-semibold uppercase tracking-wide text-text-secondary mt-2 first:mt-0 @dict-inline:mt-0",children:n}),t.jsx("dd",{className:"text-sm text-text-primary break-words min-w-0","data-field-key":r,children:$n(i)})]},r))})})}function $n(e){return e==null||e===""?"—":typeof e=="boolean"?e?"Yes":"No":typeof e=="object"?JSON.stringify(e):String(e)}const Vt="dictionary",Sn=new Set(["markdown","attachment","image"]);function Ve(e,s){if(!s)return;const a=e==null?void 0:e["x-lt-section-options"],r=a==null?void 0:a[s];return r&&typeof r=="object"?r:void 0}function Ln(e,s,a){var l,c;const r=(l=e==null?void 0:e.properties)==null?void 0:l[a];if((r==null?void 0:r.readOnly)!==!0)return!1;const n=r==null?void 0:r["x-lt-widget"];if(typeof n=="string"&&Sn.has(n))return!1;const i=r==null?void 0:r["x-lt-display"];if(typeof i=="string")return i===Vt;const d=(c=Ve(e,s))==null?void 0:c.display;return typeof d=="string"?d===Vt:(e==null?void 0:e["x-lt-display"])===Vt}function Pn(e,s,a,r){var i;const n=[];for(const d of e){const[l]=d,c=n[n.length-1];if(Ln(s,a,l)){(c==null?void 0:c.kind)==="dictionary"?c.entries.push(d):n.push({kind:"dictionary",entries:[d]});continue}const u=(i=s==null?void 0:s.properties)==null?void 0:i[l],o=u==null?void 0:u["x-lt-column-group"];if(r==="two-column"&&typeof o=="string"&&o.trim()){(c==null?void 0:c.kind)==="column-group"&&c.name===o?c.entries.push(d):n.push({kind:"column-group",name:o,entries:[d]});continue}n.push({kind:"field",entry:d})}return n}function Wn({name:e,entries:s,formSchema:a,layout:r,renderField:n}){const i=Pn(s,a,e,r),d=Ve(a,e),l=(d==null?void 0:d.columns)??(r==="two-column"?2:1),c=o=>o.map(([x,m])=>{var h;return{key:x,label:Q(x,(h=a==null?void 0:a.properties)==null?void 0:h[x]),value:m}}),u=()=>i.map((o,x)=>o.kind==="dictionary"?t.jsx("div",{className:r==="two-column"?"col-span-full":"",children:t.jsx(Mn,{items:c(o.entries),columns:l})},`dict-${x}`):o.kind==="column-group"?t.jsx("div",{className:"@container",children:t.jsx("div",{className:"grid grid-cols-1 @grp-cols:grid-cols-2 gap-x-4 gap-y-5",children:o.entries.map(m=>n(m))})},`group-${o.name}-${x}`):n(o.entry));return t.jsxs("div",{className:e?"border border-surface-border/60 bg-surface-sunken rounded-[0.25em] p-4 animate-[section-enter_0.25s_ease-out]":"",children:[e&&t.jsx("p",{className:"mb-4 text-[1.40625rem] font-semibold tracking-wider text-heading [font-variant-caps:small-caps]",children:e}),r==="two-column"?t.jsx("div",{className:"@container",children:t.jsx("div",{className:"grid grid-cols-1 @form-cols:grid-cols-2 gap-x-col-gap gap-y-5",children:u()})}):t.jsx("div",{className:"space-y-5",children:u()})]})}function Je({value:e,onChange:s,disabled:a,submitAttempted:r,escalationContext:n,onOpenHelp:i,onDisabledClick:d}){var B,J;const[l,c]=p.useState({}),[u,o]=p.useState({}),[x,m]=p.useState(null),[h,b]=p.useState(!1),[g,f]=p.useState(new Set);p.useEffect(()=>{try{const w=JSON.parse(e);if(typeof w=="object"&&w!==null&&!Array.isArray(w)){const O={},v={};for(const[R,S]of Object.entries(w))R.startsWith("_")?v[R]=S:O[R]=S;c(O),o(v),m(v._form_schema&&typeof v._form_schema=="object"?v._form_schema:null),b(!1)}}catch{b(!0)}},[e]);const y=p.useCallback(w=>{c(w),s(JSON.stringify({...w,...u},null,2))},[u,s]),_=p.useCallback((w,O)=>{y({...l,[w]:O})},[l,y]),j=p.useCallback(w=>{f(O=>{if(O.has(w))return O;const v=new Set(O);return v.add(w),v})},[]);if(h)return t.jsx("p",{className:"text-xs text-status-error",children:"Unable to parse resolver data as form. Use the JSON editor below."});const k=Object.entries(l);if(k.length===0)return t.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No resolver fields defined."});const T=x==null?void 0:x["x-lt-order"],$=T?[...k].sort((w,O)=>{const v=T.indexOf(w[0]),R=T.indexOf(O[0]);return(v===-1?1/0:v)-(R===-1?1/0:R)}):k,M={...n??{},resolver:l},C=$.filter(([w,O])=>{var R;const v=(R=x==null?void 0:x.properties)==null?void 0:R[w];return!(!Le(v==null?void 0:v["x-lt-showIf"],M)||(v==null?void 0:v["x-lt-hide-if-empty"])===!0&&(O==null||O===""||O===!1||O===0))}),D=new Set((x==null?void 0:x.required)??[]),E=x==null?void 0:x["x-lt-layout"],I=x==null?void 0:x.title,P=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",L=[];for(const w of C){const[O]=w,v=(B=x==null?void 0:x.properties)==null?void 0:B[O],R=((J=v==null?void 0:v["x-lt-section"])==null?void 0:J.trim())||null,S=L[L.length-1];!S||S.name!==R?L.push({name:R,entries:[w]}):S.entries.push(w)}const H=([w,O])=>{var xt;const v=(xt=x==null?void 0:x.properties)==null?void 0:xt[w],R=(v==null?void 0:v.readOnly)===!0,S=(v==null?void 0:v["x-lt-span"])??1,Z=D.has(w),dt=g.has(w)||!!r,jt=Se(O,v,Z,dt,M);return t.jsx("div",{className:`animate-[field-enter_0.2s_ease-out] ${E==="two-column"&&S>=2?"col-span-full":""}`,children:t.jsx(qe,{fieldKey:w,value:O,onChange:X=>_(w,X),onBlur:()=>j(w),schema:x,isRequired:Z,isReadOnly:R,error:jt,escalationContext:M,submitAttempted:!!r})},w)};return t.jsx("div",{className:"pb-8 max-w-form",onClick:a?d:void 0,children:t.jsxs("div",{className:a?"pointer-events-none":void 0,inert:a||void 0,"aria-disabled":a||void 0,children:[I&&t.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[t.jsx("h3",{className:"heading-3",children:I}),V&&i&&t.jsx("button",{type:"button",onClick:i,title:"Open instructions","aria-label":"Open instructions",className:"p-1 rounded-md text-text-tertiary hover:text-accent hover:bg-surface-hover transition-colors",children:t.jsx(Ie,{className:"w-4 h-4",strokeWidth:1.5})})]}),P&&t.jsx("p",{className:"text-sm text-text-secondary leading-relaxed mb-6",children:P}),t.jsx("div",{className:"space-y-8",children:L.map((w,O)=>t.jsx(Wn,{name:w.name,entries:w.entries,formSchema:x,layout:E,renderField:H},w.name??`__s${O}`))})]})})}function Fn({json:e,onJsonChange:s,requestTriage:a,onRequestTriageChange:r,triageNotes:n,onTriageNotesChange:i,disabled:d=!1,submitAttempted:l=!1,showTriage:c=!1,escalationContext:u,onOpenHelp:o,onDisabledClick:x}){return t.jsxs(t.Fragment,{children:[c&&t.jsx("div",{className:"flex items-center justify-between mb-3",children:a?t.jsxs("button",{onClick:()=>r(!1),className:"group flex items-center gap-2 text-left","data-testid":"triage-cancel",children:[t.jsx("span",{className:"flex items-center justify-center w-5 h-5 rounded-full bg-accent/10 text-accent shrink-0",children:t.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),t.jsxs("span",{className:"text-xs text-text-secondary group-hover:text-text-primary transition-colors",children:["AI Triage active."," ",t.jsx("span",{className:"text-accent group-hover:underline",children:"Cancel"})]})]}):t.jsxs("button",{onClick:()=>r(!0),className:"group flex items-center gap-2.5 text-left my-4","data-testid":"triage-callout",children:[t.jsx("span",{className:"flex items-center justify-center w-6 h-6 rounded-full bg-accent/10 text-accent shrink-0 animate-[triage-glow_6s_ease-in-out_infinite]",children:t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.663 17h4.674M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}),t.jsxs("span",{className:"text-sm text-text-secondary group-hover:text-text-primary transition-colors",children:["This form doesn't capture the issue?"," ",t.jsx("span",{className:"text-accent group-hover:underline",children:"Request AI Triage"})]})]})}),t.jsxs("div",{className:"relative min-h-[200px]",children:[t.jsx("div",{className:a?"pointer-events-none select-none":"",children:t.jsx(Je,{value:e,onChange:s,disabled:d,submitAttempted:l,escalationContext:u,onOpenHelp:o,onDisabledClick:x})}),a&&t.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col bg-surface/90 backdrop-blur-[2px] rounded-md border border-accent/20 p-5","data-testid":"triage-overlay",children:[t.jsx("p",{className:"text-xs text-text-secondary mb-3 leading-relaxed",children:"The resolution form will not be submitted. Describe the issue so AI triage can diagnose and fix it using available tools. The corrected result will come back as a new escalation for your review."}),t.jsx("textarea",{value:n,onChange:m=>i(m.target.value),placeholder:"e.g. Content is in Spanish — needs translation to English before review...",className:"input text-xs w-full flex-1 min-h-[80px] resize-none",autoFocus:!0,"data-testid":"triage-notes"})]})]})]})}function He(e,s){if(!e.includes("{"))return e;try{const a=n=>{if(!n)return{};try{return JSON.parse(n)}catch{return{}}},r={...s.metadata??{},...a(s.envelope),...a(s.escalation_payload)};return e.replace(/\{([^}]+)\}/g,(n,i)=>Object.prototype.hasOwnProperty.call(r,i)?String(r[i]):`{${i}}`)}catch{return e}}function Ne(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Tt(e){return{escalation:e,metadata:e.metadata??null,envelope:Ne(e.envelope),payload:Ne(e.escalation_payload),resolver:null}}function qn({isRoundsExhausted:e,payloadObj:s,isTerminal:a,resolverPayload:r,onRetryTriage:n,isRetrying:i}){return t.jsxs(t.Fragment,{children:[e&&s&&t.jsx("div",{className:"mt-8",children:t.jsx(un,{payload:s,isTerminal:a,resolverPayload:r,onRetryTriage:n,isRetrying:i})}),(s==null?void 0:s.category)==="missing_credential"&&t.jsxs("div",{className:"mt-8 bg-status-warning/10 border border-status-warning/30 rounded-md px-5 py-4 flex items-start gap-3",children:[t.jsx(de,{size:20,className:"text-status-warning mt-0.5 shrink-0"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-text-primary mb-1",children:"Missing Credential"}),t.jsxs("p",{className:"text-xs text-text-secondary mb-3",children:["This workflow requires a ",t.jsx("span",{className:"font-medium capitalize",children:String(s.provider)})," credential to continue. Register one and then resolve this escalation to retry."]}),t.jsxs(ct,{to:"/credentials",className:"btn-primary text-xs inline-flex items-center gap-1.5",children:[t.jsx(de,{size:12}),"Go to Credentials"]})]})]})]})}function Vn({esc:e,resolverPayload:s,isTerminal:a,claimedByMe:r,activeView:n,metadataFormSchema:i,effectiveSchema:d,json:l,onJsonChange:c,requestTriage:u,onRequestTriageChange:o,triageNotes:x,onTriageNotesChange:m,onResolve:h,onEscalate:b,onClaim:g,submitAttempted:f,isCertified:y,hasAI:_,onOpenHelp:j,onDisabledClick:k}){const T=d,$=Tt(e);if(a){if(s==null)return null;const E=typeof s=="object"&&s!==null?s:{},I=d??i,P=I!=null&&I.properties?{...Oe(E,I),_form_schema:I}:E;return t.jsx("div",{className:"mt-3",children:t.jsx(Je,{value:JSON.stringify(P,null,2),onChange:()=>{},disabled:!0,escalationContext:$})})}if(n!=="resolve"||!(e.workflow_type||d))return null;const M=T==null?void 0:T["x-lt-viewport"],C=(M==null?void 0:M.type)==="iframe"&&!!M.src&&h&&b;if(C&&!r)return t.jsxs("button",{onClick:()=>g==null?void 0:g(),disabled:!g,className:"flex flex-col items-center justify-center min-h-[55vh] w-full gap-3 text-center group disabled:opacity-50 disabled:cursor-default",children:[t.jsx(Ws,{className:"w-10 h-10 text-text-tertiary group-hover:text-accent transition-colors",strokeWidth:1}),t.jsx("p",{className:"text-base font-medium text-text-primary group-hover:text-accent transition-colors",children:"Claim to launch the editor"})]});const D=C?He(M.src,e):"";return t.jsx("div",{className:"mt-3",children:C?t.jsx(Fe,{src:D,escalation:e,schema:T,onResolve:h,onEscalate:b,submitAttempted:f}):t.jsx(Fn,{json:l,onJsonChange:c,requestTriage:u,onRequestTriageChange:o,triageNotes:x,onTriageNotesChange:m,disabled:!r,submitAttempted:f,showTriage:!!y&&!!_,escalationContext:$,onOpenHelp:j,onDisabledClick:k})})}function Jn({open:e,assignedUntil:s,onClose:a,onExtend:r,isPending:n}){const i=_e(),[d,l]=p.useState("30"),[c,u]=p.useState(0),o=d==="custom",x=o?c:parseInt(d),m=p.useCallback(h=>u(h),[]);return t.jsx(Ae,{open:e,onClose:a,title:"Claim Expiring",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("p",{className:"text-sm text-text-secondary",children:["Your claim on this escalation expires in"," ",t.jsx(Yt,{until:s}),". When it lapses, the form locks and the item returns to the queue — your edits are kept as a draft. Extend to keep working."]}),t.jsxs("select",{value:d,onChange:h=>{l(h.target.value),u(0)},className:"select w-full text-sm","aria-label":"Extension duration",children:[i.map(h=>t.jsx("option",{value:h.value,children:h.label},h.value)),t.jsx("option",{value:"custom",children:"Other..."})]}),o&&t.jsx(Ee,{onChange:m,autoFocus:!0}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{onClick:a,className:"btn-secondary text-xs",children:"Dismiss"}),t.jsx("button",{onClick:()=>r(x),className:"btn-primary text-xs",disabled:n||!x||x<=0,children:n?"Extending...":"Extend Claim"})]})]})})}const Hn=9e4;function Un(e,s=Hn){const[,a]=p.useState(0);if(p.useEffect(()=>{if(!e)return;const n=new Date(e).getTime()-Date.now();if(n<=0)return;const i=()=>a(c=>c+1),d=[],l=n-s;return l>0&&d.push(window.setTimeout(i,l)),d.push(window.setTimeout(i,n)),()=>d.forEach(c=>window.clearTimeout(c))},[e,s]),!e)return{expired:!1,expiringSoon:!1,msRemaining:0};const r=Math.max(0,new Date(e).getTime()-Date.now());return{expired:r<=0,expiringSoon:r>0&&r<=s,msRemaining:r}}const zn="lt:escalation:draft:";function Zt(e){return`${zn}${e}`}function Xn(e){try{return localStorage.getItem(Zt(e))}catch{return null}}function Gn(e,s){try{localStorage.setItem(Zt(e),s)}catch{}}function Jt(e){try{localStorage.removeItem(Zt(e))}catch{}}const Yn="x-lt-transition",Qn="x-lt-transition-message",Bn="x-lt-transition-max-wait-seconds",Zn="x-lt-transition-done",Kn="Submitted. Preparing your next step…",tr=30,er=5,sr=300;function nr(e){const s=typeof e=="number"?e:Number(e);return!Number.isFinite(s)||s<=0?tr:Math.min(sr,Math.max(er,Math.round(s)))}function rr(e){if(!e||!e[Yn])return null;const s=e[Qn];return{message:typeof s=="string"&&s.trim().length>0?s:Kn,maxWaitSeconds:nr(e[Bn])}}function ar(e){const s=e==null?void 0:e[Zn];return typeof s=="string"&&s.trim().length>0?s:null}function ir({open:e,message:s}){return e?gs.createPortal(t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center px-4",children:[t.jsx("div",{className:"absolute inset-0 bg-text-primary/40 backdrop-blur-sm"}),t.jsxs("div",{role:"status","aria-live":"polite",className:"relative w-full max-w-sm bg-surface-raised border border-surface-border rounded-lg shadow-xl px-6 py-7 text-center",children:[t.jsx("div",{className:"flex justify-center mb-4","aria-hidden":"true",children:t.jsx("span",{className:"inline-block w-7 h-7 rounded-full border-2 border-surface-border border-t-accent animate-spin"})}),t.jsx("div",{className:"text-sm text-text-secondary [&_p]:m-0 [&_p+p]:mt-2",children:t.jsx(Ot,{content:s})})]})]}),document.body):null}const Ue="lt:escalation:panel:open";function or(){try{const e=localStorage.getItem(Ue);return e===null?!0:e==="true"}catch{return!0}}function At(e){try{localStorage.setItem(Ue,String(e))}catch{}}function vt(e){if(!e)return null;try{return JSON.parse(e)}catch{return e}}function Or(){const{id:e}=js();return t.jsx(lr,{id:e},e)}function lr({id:e}){var se,ne,re,ae;const{user:s}=zt(),a=Gt(),r=ve(),{data:n,isLoading:i,refetch:d,isFetching:l}=ke(e);_s(e);const c=os(),u=Ce(),o=ls(),x=cs(),[m,h]=p.useState(!1),{data:b}=ds((n==null?void 0:n.role)??""),{data:g}=Cs(),{data:f}=xs(),{isBuilder:y}=us(),_=g==null?void 0:g.find(N=>N.workflow_type===(n==null?void 0:n.workflow_type)),j=((se=f==null?void 0:f.telemetry)==null?void 0:se.traceUrl)??null,[k,T]=p.useState("resolve"),[$,M]=p.useState("{}"),[C,D]=p.useState(or),[E,I]=p.useState(!1),[P,V]=p.useState(""),[L,H]=p.useState(!1),[B,J]=p.useState([]),[w,O]=p.useState(0),[v,R]=p.useState(void 0),[S,Z]=p.useState(null),dt=Un(n==null?void 0:n.assigned_until),[jt,xt]=p.useState(null);p.useEffect(()=>{if(!(!L||!n))try{const N=JSON.parse($),q=N._form_schema;if(!q){J([]);return}J(Pe(q,N,Tt(n)))}catch{}},[$,L,n]);const X=((ne=n==null?void 0:n.metadata)==null?void 0:ne.form_schema)??null,A=(n==null?void 0:n.form_schema)??(_==null?void 0:_.resolver_schema)??null,W=X??A,bt=p.useRef(!1),ut=p.useRef(null);p.useEffect(()=>{if(bt.current)return;const N=X??(A!=null&&A.properties?A:null);if(N!=null&&N.properties){bt.current=!0;const q=vt(n==null?void 0:n.envelope),U=q==null?void 0:q.formDefaults,Y={...(n==null?void 0:n.metadata)??{},...typeof U=="object"&&U!==null?U:{}},it=Oe(Y,N),tt={_form_schema:N};for(const[oe,ss]of Object.entries(N.properties)){const le=ss,ns=le.type==="object"?{}:"";tt[oe]=it[oe]??le.default??ns}ut.current=JSON.stringify(tt,null,2);const ie=!((n==null?void 0:n.status)==="resolved"||(n==null?void 0:n.status)==="cancelled")&&(n!=null&&n.id)?Xn(n.id):null,_t=ie?vt(ie):null;_t&&typeof _t=="object"&&!Array.isArray(_t)?M(JSON.stringify({..._t,_form_schema:N},null,2)):M(ut.current)}else W&&(bt.current=!0,M(JSON.stringify(W,null,2)))},[W,X,A,n==null?void 0:n.envelope,n==null?void 0:n.metadata,n==null?void 0:n.id,n==null?void 0:n.status]),p.useEffect(()=>{if(!bt.current||ut.current===null||!(n!=null&&n.id)||n.status!=="pending")return;const N=n.id,q=window.setTimeout(()=>{$===ut.current?Jt(N):Gn(N,$)},400);return()=>window.clearTimeout(q)},[$,n==null?void 0:n.id,n==null?void 0:n.status]),p.useEffect(()=>{if(!S)return;const N=window.setTimeout(async()=>{var U;try{const Y=new URLSearchParams({parent_id:e,assigned_to:(s==null?void 0:s.userId)??"",status:"pending",limit:"1"}),it=await gt(`/escalations?${Y}`),tt=(U=it==null?void 0:it.escalations)==null?void 0:U[0];if(tt!=null&&tt.id&&tt.parent_id===e){Z(null),a(`/escalations/detail/${tt.id}`);return}}catch{}Z(null),r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]});const q=S.doneDest;q?q.startsWith("/")?a(q):window.location.assign(q):a(-1)},S.maxWaitSeconds*1e3);return()=>window.clearTimeout(N)},[S,e,s==null?void 0:s.userId,a,r]);const nt=(n==null?void 0:n.subtype)==="rounds_exhausted";if(i)return t.jsxs("div",{className:"animate-pulse space-y-8",children:[t.jsx("div",{className:"h-8 bg-surface-sunken rounded w-64"}),t.jsx("div",{className:"h-32 bg-surface-sunken rounded w-full"})]});if(!n)return t.jsx("p",{className:"text-sm text-text-secondary",children:"Escalation not found."});const Rt=Te(n),rt=Rt&&n.assigned_to===(s==null?void 0:s.userId),ze=Rt&&!rt,pt=n.status==="resolved"||n.status==="cancelled",at=W==null?void 0:W["x-lt-viewport"],Dt=(at==null?void 0:at.type)==="iframe"&&!!(at!=null&&at.src)&&rt&&!pt,kt=vt(n.escalation_payload),mt=vt(n.resolver_payload),Ct=vt(n.envelope),Xe=!!((re=Ct==null?void 0:Ct.metadata)!=null&&re.certified),Kt=ps(),te=Kt!==null?Kt:!!((ae=f==null?void 0:f.ai)!=null&&ae.enabled),K=typeof kt=="object"&&kt!==null&&!Array.isArray(kt)?kt:null,Ge=K==null?void 0:K._triage,Ye=typeof mt=="object"&&mt!==null&&!Array.isArray(mt)?mt:null,Qe=pt?"terminal":rt?"claimed_by_me":ze?"claimed_by_other":"available",It=N=>{c.mutate({id:e,durationMinutes:N})},yt=()=>{r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]}),a(-1)},Be=()=>{const N=ar(W);return N&&st(N,Tt(n))||null},Ze=N=>{r.resetQueries({queryKey:["escalations"]}),r.resetQueries({queryKey:["escalationStats"]}),N.startsWith("/")?a(N):window.location.assign(N)},Mt=async N=>{try{await u.mutateAsync({id:e,resolverPayload:N})}catch(Y){if(Y instanceof ms&&Js(Y.body)){H(!0),J(Y.body.violations),R(z.ERRORS);return}throw Y}Jt(e);const q=rr(W),U=Be();if(q){Z({...q,doneDest:U});return}if(U){Ze(U);return}yt()},$t=async N=>{N&&(await o.mutateAsync({id:e,targetRole:N}),yt())},Ke=async()=>{rt||await c.mutateAsync({id:e,durationMinutes:30});const N=(K==null?void 0:K.diagnosis)||n.description||"";await u.mutateAsync({id:e,resolverPayload:{_lt:{needsTriage:!0},notes:N}}),yt()},ee=async()=>{await c.mutateAsync({id:e,durationMinutes:0}),yt()},ts=async()=>{await x.mutateAsync(e),Jt(e),h(!1),yt()},es=t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ys,{onRefresh:()=>d(),isFetching:l,apiPath:`/escalations/${n.id}`,standalone:!0}),t.jsx("button",{onClick:()=>D(N=>(At(!N),!N)),className:"ml-2 text-text-tertiary hover:text-accent transition-colors",title:C?"Hide side panel":"Show side panel",children:C?t.jsx(xe,{className:"w-5 h-5",strokeWidth:1.5}):t.jsx(ue,{className:"w-5 h-5",strokeWidth:1.5})})]});return t.jsxs("div",{className:"flex-1 min-h-0 min-w-0 flex items-stretch -mt-8 -mr-page-x -mb-16",children:[t.jsxs("div",{className:"flex-1 min-w-0 flex flex-col min-h-0",children:[Dt?t.jsxs("div",{className:"relative flex-1 min-h-0 -ml-page-x",children:[t.jsx("div",{className:"absolute top-3 right-3 z-50 flex items-center gap-0.5 bg-surface/90 backdrop-blur-sm rounded-lg px-1.5 py-1 shadow-sm border border-surface-border/40",children:[{onClick:ee,disabled:c.isPending,label:"Release",hoverClass:"hover:text-accent",icon:t.jsx(Fs,{className:"w-4 h-4",strokeWidth:1.5})},{onClick:()=>h(!0),disabled:!1,label:"Cancel",hoverClass:"hover:text-status-error",icon:t.jsx(qs,{className:"w-4 h-4",strokeWidth:1.5})},{onClick:()=>D(N=>(At(!N),!N)),disabled:!1,label:C?"Hide panel":"Show panel",hoverClass:"hover:text-accent",icon:C?t.jsx(xe,{className:"w-4 h-4",strokeWidth:1.5}):t.jsx(ue,{className:"w-4 h-4",strokeWidth:1.5})}].map(({onClick:N,disabled:q,label:U,hoverClass:Y,icon:it})=>t.jsxs("div",{className:"relative group/tip",children:[t.jsx("button",{onClick:N,disabled:q,className:`text-text-tertiary ${Y} transition-colors disabled:opacity-40 disabled:cursor-default p-1.5 rounded-md`,children:it}),t.jsx("span",{className:"pointer-events-none absolute top-full left-1/2 -translate-x-1/2 mt-1.5 px-2 py-0.5 rounded text-2xs bg-surface-sunken text-text-primary whitespace-nowrap opacity-0 group-hover/tip:opacity-100 transition-opacity",children:U})]},U))}),t.jsx(Fe,{src:He(at.src,n),escalation:n,schema:W,onResolve:Mt,onEscalate:$t,submitAttempted:L,fill:!0})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"shrink-0 pt-8 pr-page-x",children:t.jsx(bs,{title:n.description||"Escalation",actions:es})}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto pr-page-x",children:[t.jsx(qn,{isRoundsExhausted:nt,payloadObj:K,isTerminal:pt,resolverPayload:mt,onRetryTriage:Ke,isRetrying:c.isPending||u.isPending}),t.jsx(Vn,{esc:n,resolverPayload:mt,isTerminal:pt,claimedByMe:rt,activeView:k,metadataFormSchema:X,effectiveSchema:W,json:$,onJsonChange:M,requestTriage:E,onRequestTriageChange:I,triageNotes:P,onTriageNotesChange:V,onResolve:Mt,onEscalate:$t,onClaim:()=>It(30),submitAttempted:L,isCertified:Xe,hasAI:te,onOpenHelp:()=>{D(!0),At(!0),R(z.HELP)},onDisabledClick:()=>O(N=>N+1)}),t.jsx("div",{className:"h-10"})]})]}),!Dt&&t.jsx(xn,{escalationContext:Tt(n),mode:Qe,activeView:k,onActiveViewChange:T,onClaim:It,claimPending:c.isPending,claimNudge:w,workflowType:n.workflow_type,json:$,onResolve:Mt,resolvePending:u.isPending||u.isSuccess,resolveError:u.error,requestTriage:E,triageNotes:P,currentRole:n.role,escalationTargets:((b==null?void 0:b.targets)??[]).filter(N=>N!==n.role),onEscalate:$t,escalatePending:o.isPending,escalateError:o.error,onRelease:ee,releasePending:c.isPending,onCancel:()=>h(!0),assignedTo:n.assigned_to,assignedUntil:n.assigned_until,onSubmitAttempt:()=>H(!0),onValidationErrors:N=>{J(N),D(!0),At(!0),R(z.ERRORS)}})]}),t.jsx(en,{esc:n,schema:W,envelope:Ct,payload:K,resolver:Ye,triage:Ge??null,hasAI:te,claimed:Rt,claimedByMe:rt,isTerminal:pt,isBuilder:y,traceUrl:j,open:C,noGutter:Dt,formErrors:B,activePanel:v,onPanelChange:R}),t.jsx(fs,{open:m,onClose:()=>h(!1),onConfirm:ts,isPending:x.isPending,error:x.error}),t.jsx(Hs,{escalationId:e}),t.jsx(ir,{open:!!S,message:(S==null?void 0:S.message)??""}),rt&&!pt&&n.assigned_until&&t.jsx(Jn,{open:dt.expiringSoon&&n.assigned_until!==jt,assignedUntil:n.assigned_until,onClose:()=>xt(n.assigned_until??null),onExtend:It,isPending:c.isPending})]})}export{Or as EscalationDetailPage};
|
|
3
|
-
//# sourceMappingURL=index-mKcQGi2B.js.map
|