tide-commander 1.221.1 → 1.223.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/assets/{AudioPlayer-Cc50_s3Z.js → AudioPlayer-CjX0NnDG.js} +1 -1
  3. package/dist/assets/{BossLogsModal-BAlQSLGb.js → BossLogsModal-neHd1jxq.js} +1 -1
  4. package/dist/assets/BossSpawnModal-Bb5bU6M8.js +1 -0
  5. package/dist/assets/ControlsModal-BEKZK4fK.js +1 -0
  6. package/dist/assets/{DockerLogsModal-D1QipVM0.js → DockerLogsModal-C1ZIanzC.js} +1 -1
  7. package/dist/assets/{EmbeddedEditor-C-FvwuCG.js → EmbeddedEditor-DWgHQwj1.js} +1 -1
  8. package/dist/assets/{FcStdViewer-D8K3aNzl.js → FcStdViewer-CvFBDWIv.js} +1 -1
  9. package/dist/assets/{GcodeViewer-DdzJ5Rqq.js → GcodeViewer-CcVaZxR7.js} +1 -1
  10. package/dist/assets/{GlbViewer-D86f4Iew.js → GlbViewer-kF1-oHLk.js} +1 -1
  11. package/dist/assets/{GmailOAuthSetup-DoJi1LPq.js → GmailOAuthSetup-CeMu3b9k.js} +1 -1
  12. package/dist/assets/{GoogleOAuthSetup-CC5uNtC7.js → GoogleOAuthSetup-CW7ov3JO.js} +1 -1
  13. package/dist/assets/{IframeModal-R4YiTy1_.js → IframeModal-DhbsVRJn.js} +1 -1
  14. package/dist/assets/IntegrationsPanel-DKMStfuq.js +2 -0
  15. package/dist/assets/{LogViewerModal-Bqt6oPYD.js → LogViewerModal-Dk3KmPRY.js} +1 -1
  16. package/dist/assets/{MonitoringModal-wBaQR_DC.js → MonitoringModal-BSYKhukp.js} +1 -1
  17. package/dist/assets/{PM2LogsModal-LNSVzbVV.js → PM2LogsModal-CJ8Cn9t8.js} +1 -1
  18. package/dist/assets/{PluginsPanel-n6nHqBK-.js → PluginsPanel-DQv9Xrsn.js} +2 -2
  19. package/dist/assets/{RestoreArchivedAreaModal-BwEGlO0J.js → RestoreArchivedAreaModal-wn8YPSY7.js} +1 -1
  20. package/dist/assets/{Scene2DCanvas-BFTduSMz.js → Scene2DCanvas-DBs2O0PC.js} +1 -1
  21. package/dist/assets/{SceneManager-XxUuHuOt.js → SceneManager-WRjeyaRk.js} +3 -3
  22. package/dist/assets/{SkillsPanel-BRa0HmAr.js → SkillsPanel-DimvGKrN.js} +3 -3
  23. package/dist/assets/{SlackMultiInstanceSetup-KI4VupBv.js → SlackMultiInstanceSetup-cTN3v2At.js} +1 -1
  24. package/dist/assets/SpawnModal-BgdP5LBE.js +1 -0
  25. package/dist/assets/StatisticsModal-jyA2UpM-.js +1 -0
  26. package/dist/assets/{StlViewer-BNiWyISu.js → StlViewer-BTQCSdFg.js} +1 -1
  27. package/dist/assets/{SubordinateAssignmentModal-mS_D4H16.js → SubordinateAssignmentModal-BJCTarDM.js} +1 -1
  28. package/dist/assets/{ThreeAreaSelector-D_jwaxAL.js → ThreeAreaSelector-Bz_OPTco.js} +2 -2
  29. package/dist/assets/{ThreeViewShortcuts-Eyq1Jssn.js → ThreeViewShortcuts-aC84L8xB.js} +1 -1
  30. package/dist/assets/{TriggerManagerPanel-Dz0UL5c9.js → TriggerManagerPanel-CRy8hS_2.js} +3 -3
  31. package/dist/assets/{VideoPlayer-B32ZgRAZ.js → VideoPlayer-BB4cSwPZ.js} +1 -1
  32. package/dist/assets/{WorkflowEditorPanel-Dj9vHmdy.js → WorkflowEditorPanel-JG3EfQ-c.js} +1 -1
  33. package/dist/assets/{abnfDiagram-VRR7QNED-Bu6j_O25.js → abnfDiagram-VRR7QNED-BIymdJ82.js} +1 -1
  34. package/dist/assets/{arc-C5pMU9s8.js → arc--DARpxJq.js} +1 -1
  35. package/dist/assets/{architectureDiagram-ZJ3FMSHR-C0ehHh1u.js → architectureDiagram-ZJ3FMSHR-Ur0IHTuT.js} +1 -1
  36. package/dist/assets/{area-logos-CRaVVMix.js → area-logos-CVOcCaKt.js} +1 -1
  37. package/dist/assets/{blockDiagram-677ZJIJ3-jQiLISyL.js → blockDiagram-677ZJIJ3-CmNjZc5F.js} +1 -1
  38. package/dist/assets/{c4Diagram-LMCZKHZV-mHZQHWi7.js → c4Diagram-LMCZKHZV-B4GHw6__.js} +1 -1
  39. package/dist/assets/channel-DE7sZiOX.js +1 -0
  40. package/dist/assets/{chunk-2Q5K7J3B-lzD5mHaH.js → chunk-2Q5K7J3B-BBErXFBl.js} +1 -1
  41. package/dist/assets/{chunk-32BRIVSS-sk4sagPb.js → chunk-32BRIVSS-C2qUOlfT.js} +1 -1
  42. package/dist/assets/{chunk-5VM5RSS4-CIasWD2C.js → chunk-5VM5RSS4-r9xckJVE.js} +1 -1
  43. package/dist/assets/{chunk-EX3LRPZG-fVqLqaGT.js → chunk-EX3LRPZG-DYUFM6Kx.js} +1 -1
  44. package/dist/assets/{chunk-JWPE2WC7-JIovo3A4.js → chunk-JWPE2WC7-BUC08AKL.js} +1 -1
  45. package/dist/assets/{chunk-MOJQB5TN-b5hDTgD4.js → chunk-MOJQB5TN-C0yNMKSS.js} +1 -1
  46. package/dist/assets/{chunk-RYQCIY6F-DZL8xjmi.js → chunk-RYQCIY6F-DF0DipHM.js} +1 -1
  47. package/dist/assets/{chunk-V7JOEXUC-NvryLBUi.js → chunk-V7JOEXUC-B48QcHmS.js} +1 -1
  48. package/dist/assets/{chunk-VR4S4FIN-BDbvlWFq.js → chunk-VR4S4FIN-Cah567yW.js} +1 -1
  49. package/dist/assets/{chunk-XXDRQBXY-BREQf02A.js → chunk-XXDRQBXY-Cyo-LR80.js} +1 -1
  50. package/dist/assets/classDiagram-OUVF2IWQ-DEZtwip7.js +1 -0
  51. package/dist/assets/classDiagram-v2-EOCWNBFH-DEZtwip7.js +1 -0
  52. package/dist/assets/{cose-bilkent-JH36ORCC-C4lKftDx.js → cose-bilkent-JH36ORCC-BoyB947B.js} +1 -1
  53. package/dist/assets/{cynefin-VYW2F7L2-CqzOybAi.js → cynefin-VYW2F7L2-DFPaQ9Zf.js} +1 -1
  54. package/dist/assets/{cynefinDiagram-TSTJHNR4-DLg9QfOi.js → cynefinDiagram-TSTJHNR4-B2MZ8ySp.js} +1 -1
  55. package/dist/assets/{dagre-VKFMJZFB-CZMVrcMF.js → dagre-VKFMJZFB-NwVkWGfv.js} +1 -1
  56. package/dist/assets/default-agent-skills-B6BhakPb.js +1 -0
  57. package/dist/assets/{diagram-FQU43EPY-HVYIh8IQ.js → diagram-FQU43EPY-5f6e6NP-.js} +1 -1
  58. package/dist/assets/{diagram-G47NLZAW-CsGAvn5D.js → diagram-G47NLZAW-C-OBe1ja.js} +1 -1
  59. package/dist/assets/{diagram-NH7WQ7WH-B1w5Vu5U.js → diagram-NH7WQ7WH-GLMOuSN-.js} +1 -1
  60. package/dist/assets/{diagram-OA4YK3LP-Dgl9Rwgl.js → diagram-OA4YK3LP-BwhAYhbr.js} +1 -1
  61. package/dist/assets/{diagram-WEI45ONY-fX24DRA6.js → diagram-WEI45ONY-n4IRaNvB.js} +1 -1
  62. package/dist/assets/{ebnfDiagram-CCIWWBDH-Cjy6VYdS.js → ebnfDiagram-CCIWWBDH-BRSu16Iy.js} +1 -1
  63. package/dist/assets/{erDiagram-Q63AITRT-DLFD-j1G.js → erDiagram-Q63AITRT-qsCMupOZ.js} +1 -1
  64. package/dist/assets/{flowDiagram-23GEKE2U-Imi-j_ed.js → flowDiagram-23GEKE2U-C8Jfgc5Q.js} +1 -1
  65. package/dist/assets/{ganttDiagram-NO4QXBWP-Bfsn10aA.js → ganttDiagram-NO4QXBWP-CT9Xx98f.js} +1 -1
  66. package/dist/assets/{gitGraphDiagram-IHSO6WYX-C9UYlZqJ.js → gitGraphDiagram-IHSO6WYX-Coi5KukC.js} +1 -1
  67. package/dist/assets/index-BP5FFBEx.js +6 -0
  68. package/dist/assets/index-CIu--mJr.js +3 -0
  69. package/dist/assets/{index-nmpg7sj5.js → index-CZItdiJG.js} +1 -1
  70. package/dist/assets/index-DUDeXZ0I.js +2 -0
  71. package/dist/assets/{index-z8HyhH0i.js → index-GbqO5CFI.js} +5 -5
  72. package/dist/assets/{index-CDfCya1E.js → index-XRPTKib1.js} +1 -1
  73. package/dist/assets/index-Xt8XgRzK.js +1 -0
  74. package/dist/assets/index-dwe7nfIh.js +1 -0
  75. package/dist/assets/index-jOQrglq7.css +1 -0
  76. package/dist/assets/index-vi6NXwpa.js +1 -0
  77. package/dist/assets/{infoDiagram-FWYZ7A6U-BCTCLsfi.js → infoDiagram-FWYZ7A6U-DwRsLIbg.js} +1 -1
  78. package/dist/assets/{ishikawaDiagram-FXEZZL3T-DZnrKjx6.js → ishikawaDiagram-FXEZZL3T-BJHzTkEA.js} +1 -1
  79. package/dist/assets/{journeyDiagram-5HDEW3XC-Dt9KnzLG.js → journeyDiagram-5HDEW3XC-DSbYpqKW.js} +1 -1
  80. package/dist/assets/{kanban-definition-HUTT4EX6-CeXnShuW.js → kanban-definition-HUTT4EX6-095PTicj.js} +1 -1
  81. package/dist/assets/{linear-BjrvVpwg.js → linear-CfqVr0Ja.js} +1 -1
  82. package/dist/assets/main-C661hDwF.js +372 -0
  83. package/dist/assets/main-DoVWAcYA.css +1 -0
  84. package/dist/assets/{mermaid.core-w_DULRGq.js → mermaid.core-Cd-X-VQG.js} +4 -4
  85. package/dist/assets/{mindmap-definition-LN4V7U3C-Df2GRjeg.js → mindmap-definition-LN4V7U3C-BKaq73lx.js} +1 -1
  86. package/dist/assets/{pegDiagram-2B236MQR-BAf8KKDW.js → pegDiagram-2B236MQR-D8G4w9gD.js} +1 -1
  87. package/dist/assets/{pieDiagram-ENE6RG2P-7pQWvWhy.js → pieDiagram-ENE6RG2P-COmE0H9d.js} +1 -1
  88. package/dist/assets/{quadrantDiagram-ABIIQ3AL-GKQpjQPh.js → quadrantDiagram-ABIIQ3AL-ZN6VYk1I.js} +1 -1
  89. package/dist/assets/{railroadDiagram-RFXS5EU6-9uBbPin2.js → railroadDiagram-RFXS5EU6-BE9p17T6.js} +1 -1
  90. package/dist/assets/{requirementDiagram-TGXJPOKE-MGhTcR0s.js → requirementDiagram-TGXJPOKE-YeG4gM4-.js} +1 -1
  91. package/dist/assets/{sankeyDiagram-HTMAVEWB-CjORRtJb.js → sankeyDiagram-HTMAVEWB-x0VZ9b3K.js} +1 -1
  92. package/dist/assets/{sequenceDiagram-DBY2YBRQ-t558Arrr.js → sequenceDiagram-DBY2YBRQ-D1kkFLHj.js} +1 -1
  93. package/dist/assets/settingsSearch-Cv7ya9n1.js +1 -0
  94. package/dist/assets/{sizeCapture-X5ZJPWSS-UNBl42Wq.js → sizeCapture-X5ZJPWSS-CCOED7Lw.js} +1 -1
  95. package/dist/assets/{stateDiagram-2N3HPSRC-BC44-DpX.js → stateDiagram-2N3HPSRC-BVqCnbwf.js} +1 -1
  96. package/dist/assets/stateDiagram-v2-6OUMAXLB-DKzYyGyb.js +1 -0
  97. package/dist/assets/{swimlanes-5IMT3BWC-BushBJfW.js → swimlanes-5IMT3BWC-BASSCXvz.js} +2 -2
  98. package/dist/assets/swimlanesDiagram-G3AALYLV-1ocner1k.js +8 -0
  99. package/dist/assets/{timeline-definition-FHXFAJF6-Z99EoC0m.js → timeline-definition-FHXFAJF6-uL1WYIPG.js} +1 -1
  100. package/dist/assets/{vennDiagram-L72KCM5P-Dr9HMYI-.js → vennDiagram-L72KCM5P-DtbBUscM.js} +1 -1
  101. package/dist/assets/{wardleyDiagram-EHGQE667-BNOxo0ZW.js → wardleyDiagram-EHGQE667-TvRREmtU.js} +1 -1
  102. package/dist/assets/{web-uWV2wvG_.js → web-D7rM8t54.js} +1 -1
  103. package/dist/assets/{web-B9exJUzF.js → web-DEnNRcGv.js} +1 -1
  104. package/dist/assets/{web-C4lzsjab.js → web-DbGcg2p6.js} +1 -1
  105. package/dist/assets/{xychartDiagram-FW5EYKEG-Cgs6w84g.js → xychartDiagram-FW5EYKEG-CdXxeP-q.js} +1 -1
  106. package/dist/build-info.json +1 -1
  107. package/dist/index.html +2 -2
  108. package/dist/src/packages/server/data/builtin-skills/boss-instructions.js +1 -1
  109. package/dist/src/packages/server/integrations/jira/jira-client.js +17 -0
  110. package/dist/src/packages/server/integrations/jira/jira-routes.js +35 -0
  111. package/dist/src/packages/server/pi/backend.js +1 -0
  112. package/dist/src/packages/server/routes/agents.js +59 -12
  113. package/dist/src/packages/server/routes/config.js +1 -1
  114. package/dist/src/packages/server/routes/files.js +195 -14
  115. package/dist/src/packages/server/services/agent-lifecycle-service.js +3 -5
  116. package/dist/src/packages/server/services/agent-service.js +3 -3
  117. package/dist/src/packages/server/services/default-agent-skills-service.js +121 -0
  118. package/dist/src/packages/server/services/file-recovery.js +381 -0
  119. package/dist/src/packages/server/services/llm-matcher-service.js +4 -1
  120. package/dist/src/packages/server/services/skill-service.js +76 -20
  121. package/dist/src/packages/shared/agent-types.js +40 -13
  122. package/dist/src/packages/shared/common-types.js +15 -5
  123. package/dist/src/packages/shared/model-freshness.js +71 -0
  124. package/dist/src/packages/shared/shell-file-writes.js +20 -1
  125. package/dist/src/packages/shared/skill-assignment.js +27 -0
  126. package/package.json +1 -1
  127. package/dist/assets/BossSpawnModal-B79NhJbY.js +0 -1
  128. package/dist/assets/ControlsModal-Cr7GFt6U.js +0 -1
  129. package/dist/assets/IntegrationsPanel-BpUJLvew.js +0 -2
  130. package/dist/assets/SpawnModal-B3EOCMzI.js +0 -1
  131. package/dist/assets/StatisticsModal-DKj8mS7q.js +0 -1
  132. package/dist/assets/channel-DNe3UVEK.js +0 -1
  133. package/dist/assets/classDiagram-OUVF2IWQ-C-rWSUSa.js +0 -1
  134. package/dist/assets/classDiagram-v2-EOCWNBFH-C-rWSUSa.js +0 -1
  135. package/dist/assets/common-types-CXYNLIh4.js +0 -1
  136. package/dist/assets/index-BhXpqWcm.js +0 -2
  137. package/dist/assets/index-Bn49iMaZ.js +0 -1
  138. package/dist/assets/index-BxklT4-t.js +0 -1
  139. package/dist/assets/index-C3P4W37v.js +0 -6
  140. package/dist/assets/index-C9z7YlcT.js +0 -2
  141. package/dist/assets/index-Cekb_QrZ.css +0 -1
  142. package/dist/assets/index-D_KEXsQF.js +0 -1
  143. package/dist/assets/main-B55_oSEq.css +0 -1
  144. package/dist/assets/main-D0DfmHvm.js +0 -357
  145. package/dist/assets/settingsSearch-DYr4vFyy.js +0 -1
  146. package/dist/assets/stateDiagram-v2-6OUMAXLB-aeL0H9w3.js +0 -1
  147. package/dist/assets/swimlanesDiagram-G3AALYLV-Bse-OPnn.js +0 -8
@@ -1,9 +1,9 @@
1
- import{L as Me,r as o,c as v,d as b,j as e}from"./main-D0DfmHvm.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-GtkNAxzd.js";const Ie=[{value:"webhook",label:"Webhook"},{value:"bitbucket",label:"Bitbucket"},{value:"cron",label:"Cron"},{value:"slack",label:"Slack"},{value:"email",label:"Email"},{value:"jira",label:"Jira"},{value:"whatsapp",label:"WhatsApp"}],Ae=[{value:"all",label:"All",icon:"◎"},{value:"webhook",label:"Webhook",icon:"🪝"},{value:"bitbucket",label:"Bitbucket",icon:"🪣"},{value:"cron",label:"Cron",icon:"⏰"},{value:"slack",label:"Slack",icon:"💬"},{value:"email",label:"Email",icon:"✉️"},{value:"jira",label:"Jira",icon:"🎫"},{value:"whatsapp",label:"WhatsApp",icon:"📱"}],Be=[{value:"pullrequest:created",label:"PR created"},{value:"pullrequest:updated",label:"PR updated"},{value:"pullrequest:approved",label:"PR approved"},{value:"pullrequest:unapproved",label:"PR unapproved"},{value:"pullrequest:fulfilled",label:"PR merged"},{value:"pullrequest:rejected",label:"PR declined"},{value:"pullrequest:comment_created",label:"PR comment created"}],Re=[{value:"structural",label:"Structural",desc:"Field-based matching (fast, free)"},{value:"llm",label:"LLM",desc:"Semantic matching via LLM (flexible, costs tokens)"},{value:"hybrid",label:"Hybrid",desc:"Structural pre-filter + LLM (recommended)"}],Fe=[{value:"structural",label:"Structural"},{value:"llm",label:"LLM"}];function Ee(w){if(!w)return"";const g=new Date(w);if(Number.isNaN(g.getTime()))return"";const m=j=>String(j).padStart(2,"0");return`${g.getFullYear()}-${m(g.getMonth()+1)}-${m(g.getDate())}T${m(g.getHours())}:${m(g.getMinutes())}`}const O=()=>({name:"",description:"",type:"webhook",agentId:"",promptTemplate:"",enabled:!0,matchMode:"structural",extractionMode:"structural",config:{method:"POST"}});function Pe({isOpen:w,onClose:g}){var Q,X,Z,ee,le,te,se,ae,ne,ie,re,oe,ce,de,pe,ue;const m=Me(),[j,xe]=o.useState([]),[S,A]=o.useState("list"),[n,k]=o.useState(O()),[h,R]=o.useState(!1),[L,D]=o.useState(!1),[P,y]=o.useState(null),[z,he]=o.useState([]),[T,ye]=o.useState(null),[F,be]=o.useState(`{
1
+ import{T as Me,r as o,c as v,d as b,j as e}from"./main-C661hDwF.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-GtkNAxzd.js";const Ie=[{value:"webhook",label:"Webhook"},{value:"bitbucket",label:"Bitbucket"},{value:"cron",label:"Cron"},{value:"slack",label:"Slack"},{value:"email",label:"Email"},{value:"jira",label:"Jira"},{value:"whatsapp",label:"WhatsApp"}],Ae=[{value:"all",label:"All",icon:"◎"},{value:"webhook",label:"Webhook",icon:"🪝"},{value:"bitbucket",label:"Bitbucket",icon:"🪣"},{value:"cron",label:"Cron",icon:"⏰"},{value:"slack",label:"Slack",icon:"💬"},{value:"email",label:"Email",icon:"✉️"},{value:"jira",label:"Jira",icon:"🎫"},{value:"whatsapp",label:"WhatsApp",icon:"📱"}],Be=[{value:"pullrequest:created",label:"PR created"},{value:"pullrequest:updated",label:"PR updated"},{value:"pullrequest:approved",label:"PR approved"},{value:"pullrequest:unapproved",label:"PR unapproved"},{value:"pullrequest:fulfilled",label:"PR merged"},{value:"pullrequest:rejected",label:"PR declined"},{value:"pullrequest:comment_created",label:"PR comment created"}],Re=[{value:"structural",label:"Structural",desc:"Field-based matching (fast, free)"},{value:"llm",label:"LLM",desc:"Semantic matching via LLM (flexible, costs tokens)"},{value:"hybrid",label:"Hybrid",desc:"Structural pre-filter + LLM (recommended)"}],Fe=[{value:"structural",label:"Structural"},{value:"llm",label:"LLM"}];function Ee(w){if(!w)return"";const g=new Date(w);if(Number.isNaN(g.getTime()))return"";const m=j=>String(j).padStart(2,"0");return`${g.getFullYear()}-${m(g.getMonth()+1)}-${m(g.getDate())}T${m(g.getHours())}:${m(g.getMinutes())}`}const O=()=>({name:"",description:"",type:"webhook",agentId:"",promptTemplate:"",enabled:!0,matchMode:"structural",extractionMode:"structural",config:{method:"POST"}});function Pe({isOpen:w,onClose:g}){var Q,X,Z,ee,le,te,se,ae,ne,ie,re,oe,ce,de,pe,ue;const m=Me(),[j,xe]=o.useState([]),[T,A]=o.useState("list"),[n,k]=o.useState(O()),[h,R]=o.useState(!1),[L,D]=o.useState(!1),[P,y]=o.useState(null),[z,he]=o.useState([]),[S,ye]=o.useState(null),[F,be]=o.useState(`{
2
2
 
3
- }`),[u,M]=o.useState(null),[N,U]=o.useState(!1),[H,W]=o.useState([]),[I,ge]=o.useState("all"),[_,je]=o.useState([]),f=o.useCallback(async()=>{try{const t=await v(b("/api/triggers"));if(t.ok){const s=await t.json();xe(s)}}catch(t){console.error("Failed to load triggers:",t)}},[]),B=o.useCallback(async t=>{try{const s=await v(b(`/api/triggers/${t}/events?limit=20`));if(s.ok){const a=await s.json();he(a)}}catch(s){console.error("Failed to load trigger history:",s)}},[]),q=o.useCallback(async()=>{try{const t=await v(b("/api/slack/instances"));if(t.ok){const s=await t.json(),a=Array.isArray(s==null?void 0:s.instances)?s.instances:[];je(a.map(p=>({id:p.id,label:p.label||p.id})))}}catch(t){console.error("Failed to load Slack instances:",t)}},[]);o.useEffect(()=>{w&&(f(),q())},[w,f,q]),o.useEffect(()=>{T&&B(T)},[T,B]);const ve=o.useCallback(async()=>{D(!0),y(null);try{const t=h?b(`/api/triggers/${n.id}`):b("/api/triggers"),p=await v(t,{method:h?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!p.ok){const d=await p.json();throw new Error(d.error||"Failed to save trigger")}await f(),A("list"),k(O()),R(!1)}catch(t){y(t instanceof Error?t.message:"Save failed")}finally{D(!1)}},[n,h,f]),me=o.useCallback(async t=>{try{await v(b(`/api/triggers/${t}`),{method:"DELETE"}),await f()}catch(s){console.error("Failed to delete trigger:",s)}},[f]),fe=o.useCallback(async t=>{try{await v(b(`/api/triggers/${t.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!t.enabled})}),await f()}catch(s){console.error("Failed to toggle trigger:",s)}},[f]),ke=o.useCallback(async t=>{try{await v(b(`/api/triggers/${t}/fire`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({variables:{}})}),T===t&&await B(t)}catch(s){console.error("Failed to test fire trigger:",s)}},[T,B]),Ce=o.useCallback(async()=>{if(n.id){U(!0),M(null);try{let t;try{t=JSON.parse(F)}catch{M({structuralMatch:void 0,extractedVariables:{},wouldFire:!1}),y("Invalid JSON payload");return}const s=await v(b(`/api/triggers/${n.id}/test-match`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payload:t})});if(s.ok){const a=await s.json();M(a),y(null)}else{const a=await s.json();y(a.error||"Test match failed")}}catch(t){y(t instanceof Error?t.message:"Test match failed")}finally{U(!1)}}},[n.id,F]),we=o.useCallback(async t=>{var s;try{const a=await v(b("/api/triggers/validate-cron"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expression:t,timezone:((s=n.config)==null?void 0:s.timezone)||"UTC"})});if(a.ok){const p=await a.json();W(p.valid?p.nextFires:[])}}catch{W([])}},[n]),$=o.useCallback(t=>{t?(k({...t}),R(!0)):(k(O()),R(!1)),M(null),y(null),A("edit")},[]),x=o.useCallback((t,s)=>{k(a=>({...a,[t]:s}))},[]),r=o.useCallback((t,s)=>{k(a=>({...a,config:{...a.config,[t]:s}}))},[]),E=o.useCallback((t,s)=>{k(a=>({...a,llmMatch:{...a.llmMatch||{prompt:""},[t]:s}}))},[]),J=o.useCallback((t,s)=>{k(a=>({...a,llmExtract:{...a.llmExtract||{prompt:"",variables:[]},[t]:s}}))},[]),Se=o.useMemo(()=>Array.from(m.values()).map(t=>({id:t.id,name:t.name,class:t.class})),[m]),Te=o.useMemo(()=>{const t={all:j.length,webhook:0,bitbucket:0,cron:0,slack:0,email:0,jira:0,whatsapp:0};for(const s of j)s.type in t&&(t[s.type]+=1);return t},[j]),G=o.useMemo(()=>I==="all"?j:j.filter(t=>t.type===I),[j,I]),[K,V]=o.useState(null),Y=o.useCallback((t,s)=>{t&&navigator.clipboard.writeText(t).then(()=>{V(s),setTimeout(()=>V(a=>a===s?null:a),1500)},()=>y("Failed to copy to clipboard"))},[]);return w?e.jsx("div",{style:l.overlay,onClick:g,children:e.jsxs("div",{style:l.panel,onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{style:l.header,children:[e.jsx("h2",{style:l.title,children:S==="list"?"Triggers":h?"Edit Trigger":"New Trigger"}),e.jsxs("div",{style:l.headerActions,children:[S==="list"&&e.jsx("button",{style:l.addBtn,onClick:()=>$(),children:"+ New Trigger"}),S==="edit"&&e.jsx("button",{style:l.backBtn,onClick:()=>{A("list"),M(null),y(null)},children:"Back"}),e.jsx("button",{style:l.closeBtn,onClick:g,children:"X"})]})]}),P&&e.jsx("div",{style:l.error,children:P}),S==="list"&&e.jsxs("div",{style:l.content,children:[e.jsx("div",{style:l.tabBar,role:"tablist","aria-label":"Filter triggers by type",children:Ae.map(t=>{const s=Te[t.value],a=I===t.value;return e.jsxs("button",{role:"tab","aria-selected":a,onClick:()=>ge(t.value),style:{...l.tab,...a?l.tabActive:{}},title:`${t.label} (${s})`,children:[e.jsx("span",{style:l.tabIcon,children:t.icon}),e.jsx("span",{style:l.tabLabel,children:t.label}),e.jsx("span",{style:{...l.tabBadge,...a?l.tabBadgeActive:{}},children:s})]},t.value)})}),j.length===0?e.jsx("div",{style:l.empty,children:"No triggers configured. Create one to get started."}):G.length===0?e.jsxs("div",{style:l.empty,children:["No ",I," triggers configured yet."]}):G.map(t=>{var s;return e.jsxs("div",{style:{...l.triggerCard,borderLeftColor:t.status==="error"?"#e74c3c":t.enabled?"#2ecc71":"#95a5a6"},onClick:()=>{ye(t.id),$(t)},children:[e.jsxs("div",{style:l.cardHeader,children:[e.jsxs("div",{style:l.cardTitle,children:[e.jsx("span",{style:l.typeTag,children:t.type}),e.jsx("span",{children:t.name}),t.type==="cron"&&(()=>{const a=t.config||{};return a.runOnce?a.completedAt?e.jsx("span",{style:{...l.matchTag,color:"#a6e3a1"},children:"Once · completed"}):a.missedAt?e.jsx("span",{style:{...l.matchTag,color:"#f38ba8"},children:"Once · missed"}):e.jsx("span",{style:{...l.matchTag,color:"#f9e2af"},children:"Once · pending"}):e.jsx("span",{style:l.matchTag,children:"Recurring"})})(),t.matchMode!=="structural"&&e.jsx("span",{style:l.matchTag,children:t.matchMode})]}),e.jsxs("div",{style:l.cardActions,children:[e.jsx("button",{style:l.smallBtn,onClick:a=>{a.stopPropagation(),fe(t)},children:t.enabled?"Disable":"Enable"}),e.jsx("button",{style:l.smallBtn,onClick:a=>{a.stopPropagation(),ke(t.id)},children:"Test Fire"}),e.jsx("button",{style:{...l.smallBtn,color:"#e74c3c"},onClick:a=>{a.stopPropagation(),me(t.id)},children:"Delete"})]})]}),e.jsxs("div",{style:l.cardMeta,children:[e.jsxs("span",{children:["Agent: ",((s=m.get(t.agentId))==null?void 0:s.name)||t.agentId]}),e.jsxs("span",{children:["Fires: ",t.fireCount]}),t.lastFiredAt&&e.jsxs("span",{children:["Last: ",new Date(t.lastFiredAt).toLocaleString()]}),t.status==="error"&&t.lastError&&e.jsxs("span",{style:{color:"#e74c3c"},children:["Error: ",t.lastError]})]})]},t.id)})]}),S==="edit"&&e.jsx("div",{style:l.content,children:e.jsxs("div",{style:l.form,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Name"}),e.jsx("input",{style:l.input,value:n.name||"",onChange:t=>x("name",t.target.value),placeholder:"My Trigger"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Description"}),e.jsx("input",{style:l.input,value:n.description||"",onChange:t=>x("description",t.target.value),placeholder:"Optional description"})]}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Type"}),e.jsx("select",{style:l.select,value:n.type||"webhook",onChange:t=>{const s=t.target.value;x("type",s),s==="webhook"?x("config",{method:"POST"}):s==="cron"?x("config",{expression:"0 9 * * MON-FRI",timezone:"UTC"}):s==="bitbucket"?x("config",{workspace:"",repoSlug:"",events:["pullrequest:created","pullrequest:updated"]}):x("config",{}),(n.promptTemplate??"").trim()||(s==="slack"?x("promptTemplate",`Slack message from {{slack.user}} in {{slack.channelName}}:
3
+ }`),[u,M]=o.useState(null),[N,U]=o.useState(!1),[H,W]=o.useState([]),[I,ge]=o.useState("all"),[_,je]=o.useState([]),f=o.useCallback(async()=>{try{const t=await v(b("/api/triggers"));if(t.ok){const s=await t.json();xe(s)}}catch(t){console.error("Failed to load triggers:",t)}},[]),B=o.useCallback(async t=>{try{const s=await v(b(`/api/triggers/${t}/events?limit=20`));if(s.ok){const a=await s.json();he(a)}}catch(s){console.error("Failed to load trigger history:",s)}},[]),q=o.useCallback(async()=>{try{const t=await v(b("/api/slack/instances"));if(t.ok){const s=await t.json(),a=Array.isArray(s==null?void 0:s.instances)?s.instances:[];je(a.map(p=>({id:p.id,label:p.label||p.id})))}}catch(t){console.error("Failed to load Slack instances:",t)}},[]);o.useEffect(()=>{w&&(f(),q())},[w,f,q]),o.useEffect(()=>{S&&B(S)},[S,B]);const ve=o.useCallback(async()=>{D(!0),y(null);try{const t=h?b(`/api/triggers/${n.id}`):b("/api/triggers"),p=await v(t,{method:h?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!p.ok){const d=await p.json();throw new Error(d.error||"Failed to save trigger")}await f(),A("list"),k(O()),R(!1)}catch(t){y(t instanceof Error?t.message:"Save failed")}finally{D(!1)}},[n,h,f]),me=o.useCallback(async t=>{try{await v(b(`/api/triggers/${t}`),{method:"DELETE"}),await f()}catch(s){console.error("Failed to delete trigger:",s)}},[f]),fe=o.useCallback(async t=>{try{await v(b(`/api/triggers/${t.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!t.enabled})}),await f()}catch(s){console.error("Failed to toggle trigger:",s)}},[f]),ke=o.useCallback(async t=>{try{await v(b(`/api/triggers/${t}/fire`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({variables:{}})}),S===t&&await B(t)}catch(s){console.error("Failed to test fire trigger:",s)}},[S,B]),Ce=o.useCallback(async()=>{if(n.id){U(!0),M(null);try{let t;try{t=JSON.parse(F)}catch{M({structuralMatch:void 0,extractedVariables:{},wouldFire:!1}),y("Invalid JSON payload");return}const s=await v(b(`/api/triggers/${n.id}/test-match`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payload:t})});if(s.ok){const a=await s.json();M(a),y(null)}else{const a=await s.json();y(a.error||"Test match failed")}}catch(t){y(t instanceof Error?t.message:"Test match failed")}finally{U(!1)}}},[n.id,F]),we=o.useCallback(async t=>{var s;try{const a=await v(b("/api/triggers/validate-cron"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expression:t,timezone:((s=n.config)==null?void 0:s.timezone)||"UTC"})});if(a.ok){const p=await a.json();W(p.valid?p.nextFires:[])}}catch{W([])}},[n]),$=o.useCallback(t=>{t?(k({...t}),R(!0)):(k(O()),R(!1)),M(null),y(null),A("edit")},[]),x=o.useCallback((t,s)=>{k(a=>({...a,[t]:s}))},[]),r=o.useCallback((t,s)=>{k(a=>({...a,config:{...a.config,[t]:s}}))},[]),E=o.useCallback((t,s)=>{k(a=>({...a,llmMatch:{...a.llmMatch||{prompt:""},[t]:s}}))},[]),J=o.useCallback((t,s)=>{k(a=>({...a,llmExtract:{...a.llmExtract||{prompt:"",variables:[]},[t]:s}}))},[]),Te=o.useMemo(()=>Array.from(m.values()).map(t=>({id:t.id,name:t.name,class:t.class})),[m]),Se=o.useMemo(()=>{const t={all:j.length,webhook:0,bitbucket:0,cron:0,slack:0,email:0,jira:0,whatsapp:0};for(const s of j)s.type in t&&(t[s.type]+=1);return t},[j]),G=o.useMemo(()=>I==="all"?j:j.filter(t=>t.type===I),[j,I]),[K,V]=o.useState(null),Y=o.useCallback((t,s)=>{t&&navigator.clipboard.writeText(t).then(()=>{V(s),setTimeout(()=>V(a=>a===s?null:a),1500)},()=>y("Failed to copy to clipboard"))},[]);return w?e.jsx("div",{style:l.overlay,onClick:g,children:e.jsxs("div",{style:l.panel,onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{style:l.header,children:[e.jsx("h2",{style:l.title,children:T==="list"?"Triggers":h?"Edit Trigger":"New Trigger"}),e.jsxs("div",{style:l.headerActions,children:[T==="list"&&e.jsx("button",{style:l.addBtn,onClick:()=>$(),children:"+ New Trigger"}),T==="edit"&&e.jsx("button",{style:l.backBtn,onClick:()=>{A("list"),M(null),y(null)},children:"Back"}),e.jsx("button",{style:l.closeBtn,onClick:g,children:"X"})]})]}),P&&e.jsx("div",{style:l.error,children:P}),T==="list"&&e.jsxs("div",{style:l.content,children:[e.jsx("div",{style:l.tabBar,role:"tablist","aria-label":"Filter triggers by type",children:Ae.map(t=>{const s=Se[t.value],a=I===t.value;return e.jsxs("button",{role:"tab","aria-selected":a,onClick:()=>ge(t.value),style:{...l.tab,...a?l.tabActive:{}},title:`${t.label} (${s})`,children:[e.jsx("span",{style:l.tabIcon,children:t.icon}),e.jsx("span",{style:l.tabLabel,children:t.label}),e.jsx("span",{style:{...l.tabBadge,...a?l.tabBadgeActive:{}},children:s})]},t.value)})}),j.length===0?e.jsx("div",{style:l.empty,children:"No triggers configured. Create one to get started."}):G.length===0?e.jsxs("div",{style:l.empty,children:["No ",I," triggers configured yet."]}):G.map(t=>{var s;return e.jsxs("div",{style:{...l.triggerCard,borderLeftColor:t.status==="error"?"#e74c3c":t.enabled?"#2ecc71":"#95a5a6"},onClick:()=>{ye(t.id),$(t)},children:[e.jsxs("div",{style:l.cardHeader,children:[e.jsxs("div",{style:l.cardTitle,children:[e.jsx("span",{style:l.typeTag,children:t.type}),e.jsx("span",{children:t.name}),t.type==="cron"&&(()=>{const a=t.config||{};return a.runOnce?a.completedAt?e.jsx("span",{style:{...l.matchTag,color:"#a6e3a1"},children:"Once · completed"}):a.missedAt?e.jsx("span",{style:{...l.matchTag,color:"#f38ba8"},children:"Once · missed"}):e.jsx("span",{style:{...l.matchTag,color:"#f9e2af"},children:"Once · pending"}):e.jsx("span",{style:l.matchTag,children:"Recurring"})})(),t.matchMode!=="structural"&&e.jsx("span",{style:l.matchTag,children:t.matchMode})]}),e.jsxs("div",{style:l.cardActions,children:[e.jsx("button",{style:l.smallBtn,onClick:a=>{a.stopPropagation(),fe(t)},children:t.enabled?"Disable":"Enable"}),e.jsx("button",{style:l.smallBtn,onClick:a=>{a.stopPropagation(),ke(t.id)},children:"Test Fire"}),e.jsx("button",{style:{...l.smallBtn,color:"#e74c3c"},onClick:a=>{a.stopPropagation(),me(t.id)},children:"Delete"})]})]}),e.jsxs("div",{style:l.cardMeta,children:[e.jsxs("span",{children:["Agent: ",((s=m.get(t.agentId))==null?void 0:s.name)||t.agentId]}),e.jsxs("span",{children:["Fires: ",t.fireCount]}),t.lastFiredAt&&e.jsxs("span",{children:["Last: ",new Date(t.lastFiredAt).toLocaleString()]}),t.status==="error"&&t.lastError&&e.jsxs("span",{style:{color:"#e74c3c"},children:["Error: ",t.lastError]})]})]},t.id)})]}),T==="edit"&&e.jsx("div",{style:l.content,children:e.jsxs("div",{style:l.form,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Name"}),e.jsx("input",{style:l.input,value:n.name||"",onChange:t=>x("name",t.target.value),placeholder:"My Trigger"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Description"}),e.jsx("input",{style:l.input,value:n.description||"",onChange:t=>x("description",t.target.value),placeholder:"Optional description"})]}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Type"}),e.jsx("select",{style:l.select,value:n.type||"webhook",onChange:t=>{const s=t.target.value;x("type",s),s==="webhook"?x("config",{method:"POST"}):s==="cron"?x("config",{expression:"0 9 * * MON-FRI",timezone:"UTC"}):s==="bitbucket"?x("config",{workspace:"",repoSlug:"",events:["pullrequest:created","pullrequest:updated"]}):x("config",{}),(n.promptTemplate??"").trim()||(s==="slack"?x("promptTemplate",`Slack message from {{slack.user}} in {{slack.channelName}}:
4
4
  {{slack.message}}
5
5
 
6
6
  {{slack.attachmentsBlock}}`):s==="whatsapp"&&x("promptTemplate",`WhatsApp message from {{whatsapp.fromName}} ({{whatsapp.from}}):
7
7
  {{whatsapp.body}}
8
8
 
9
- {{whatsapp.attachmentsBlock}}`))},children:Ie.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Agent"}),e.jsxs("select",{style:l.select,value:n.agentId||"",onChange:t=>x("agentId",t.target.value),children:[e.jsx("option",{value:"",children:"Select agent..."}),Se.map(t=>e.jsxs("option",{value:t.id,children:[t.name," (",t.class,")"]},t.id))]})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Prompt Template"}),e.jsx("textarea",{style:l.textarea,value:n.promptTemplate||"",onChange:t=>x("promptTemplate",t.target.value),placeholder:"Message sent to agent. Use {{variable}} for interpolation.",rows:4})]}),n.type==="webhook"&&e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Webhook Config"}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Method"}),e.jsxs("select",{style:l.select,value:((Q=n.config)==null?void 0:Q.method)||"POST",onChange:t=>r("method",t.target.value),children:[e.jsx("option",{value:"POST",children:"POST"}),e.jsx("option",{value:"PUT",children:"PUT"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Secret (HMAC)"}),e.jsx("input",{style:l.input,type:"password",value:((X=n.config)==null?void 0:X.secret)||"",onChange:t=>r("secret",t.target.value||void 0),placeholder:"Optional HMAC secret"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Extract Fields (comma-separated JSON paths)"}),e.jsx("input",{style:l.input,value:((ee=(Z=n.config)==null?void 0:Z.extractFields)==null?void 0:ee.join(", "))||"",onChange:t=>r("extractFields",t.target.value.split(",").map(s=>s.trim()).filter(Boolean)),placeholder:"body.release_name, body.version"})]}),h&&n.id&&e.jsxs("div",{style:l.webhookUrl,children:[e.jsx("label",{style:l.label,children:"Webhook URL"}),e.jsx("code",{style:l.code,children:`${window.location.origin}/api/triggers/webhook/${n.id}`})]})]}),n.type==="bitbucket"&&(()=>{const t=n.config||{},s=Array.isArray(t.events)?t.events:[],a=h&&n.id?`${window.location.origin}/api/triggers/webhook/${n.id}`:"",p=d=>{const i=s.includes(d)?s.filter(c=>c!==d):[...s,d];r("events",i)};return e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Bitbucket Config"}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Workspace"}),e.jsx("input",{style:l.input,value:t.workspace||"",onChange:d=>r("workspace",d.target.value),placeholder:"tide"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Repository slug"}),e.jsx("input",{style:l.input,value:t.repoSlug||"",onChange:d=>r("repoSlug",d.target.value),placeholder:"wind"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Events"}),e.jsx("div",{style:l.checkboxGrid,children:Be.map(d=>{const i=s.includes(d.value);return e.jsxs("label",{style:l.checkboxLabel,children:[e.jsx("input",{type:"checkbox",checked:i,onChange:()=>p(d.value)}),e.jsx("span",{children:d.label}),e.jsx("code",{style:l.checkboxCode,children:d.value})]},d.value)})})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"HMAC secret"}),e.jsxs("div",{style:l.inlineRow,children:[e.jsx("input",{style:{...l.input,flex:1},type:"password",value:t.secret||"",onChange:d=>r("secret",d.target.value||void 0),placeholder:"Shared secret used to validate Bitbucket signature"}),e.jsx("button",{type:"button",style:l.smallBtn,onClick:()=>Y(t.secret||"","bitbucket-secret"),disabled:!t.secret,children:K==="bitbucket-secret"?"Copied!":"Copy"})]}),e.jsx("span",{style:l.llmMeta,children:"Paste the same secret into Bitbucket's webhook configuration."})]}),a&&e.jsxs("div",{style:l.webhookUrl,children:[e.jsx("label",{style:l.label,children:"Webhook URL"}),e.jsxs("div",{style:l.inlineRow,children:[e.jsx("code",{style:{...l.code,flex:1},children:a}),e.jsx("button",{type:"button",style:l.smallBtn,onClick:()=>Y(a,"bitbucket-url"),children:K==="bitbucket-url"?"Copied!":"Copy"})]}),e.jsx("span",{style:l.llmMeta,children:"In Bitbucket: Repository settings → Webhooks → Add webhook, then paste this URL and the secret above."})]}),!a&&e.jsx("span",{style:l.llmMeta,children:"Save the trigger to reveal its webhook URL."})]})})(),n.type==="cron"&&(()=>{const t=n.config||{},s=!!t.runOnce,a=t.completedAt,p=t.missedAt,d=!!a;return e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Cron Config"}),e.jsxs("div",{style:l.modeSelector,children:[e.jsxs("button",{type:"button",style:{...l.modeBtn,...s?{}:l.modeBtnActive},onClick:()=>r("runOnce",!1),disabled:d,children:[e.jsx("strong",{children:"Repeats"}),e.jsx("span",{style:l.modeDesc,children:"Fires on a cron schedule"})]}),e.jsxs("button",{type:"button",style:{...l.modeBtn,...s?l.modeBtnActive:{}},onClick:()=>r("runOnce",!0),disabled:d,children:[e.jsx("strong",{children:"Run once"}),e.jsx("span",{style:l.modeDesc,children:"Fires exactly once at a specific time"})]})]}),d&&e.jsxs("div",{style:{...l.testResult,borderLeft:"3px solid #a6e3a1"},children:[e.jsx("strong",{style:{color:"#a6e3a1"},children:"Completed"}),e.jsxs("span",{style:l.llmMeta,children:["Fired at ",new Date(a).toLocaleString()]})]}),!d&&p&&e.jsxs("div",{style:{...l.testResult,borderLeft:"3px solid #f38ba8"},children:[e.jsx("strong",{style:{color:"#f38ba8"},children:"Missed"}),e.jsxs("span",{style:l.llmMeta,children:["Marked missed at ",new Date(p).toLocaleString()," (server was down at runAt)"]})]}),s?e.jsx("div",{style:l.row,children:e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Run at"}),e.jsx("input",{style:l.input,type:"datetime-local",value:Ee(t.runAt),onChange:i=>{const c=i.target.value;if(!c){r("runAt",void 0);return}const C=new Date(c).toISOString();r("runAt",C)},disabled:d}),e.jsx("span",{style:l.llmMeta,children:"Interpreted in your browser's local timezone"})]})}):e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Expression"}),e.jsx("input",{style:l.input,value:t.expression||"",onChange:i=>{r("expression",i.target.value),i.target.value&&we(i.target.value)},placeholder:"0 9 * * MON-FRI"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Timezone"}),e.jsx("input",{style:l.input,value:t.timezone||"UTC",onChange:i=>r("timezone",i.target.value),placeholder:"America/Mexico_City"})]})]}),!s&&H.length>0&&e.jsxs("div",{style:l.nextFires,children:[e.jsx("label",{style:l.label,children:"Next fires:"}),H.map((i,c)=>e.jsx("div",{style:l.nextFireItem,children:new Date(i).toLocaleString()},c))]})]})})(),n.type==="slack"&&(()=>{var s,a,p,d;const t=n.config||{};return e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Slack Config"}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Instance"}),e.jsxs("select",{style:l.select,value:t.instanceId||"",onChange:i=>r("instanceId",i.target.value||void 0),children:[e.jsx("option",{value:"",children:"Any instance"}),_.map(i=>e.jsxs("option",{value:i.id,children:[i.label," (",i.id,")"]},i.id)),t.instanceId&&!_.some(i=>i.id===t.instanceId)&&e.jsxs("option",{value:t.instanceId,children:[t.instanceId," (not found)"]})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Thread timestamp"}),e.jsx("input",{style:l.input,value:t.threadTs||"",onChange:i=>r("threadTs",i.target.value||void 0),placeholder:"Only replies in this thread"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Channel ID (legacy single channel)"}),e.jsx("input",{style:l.input,value:t.channelId||"",onChange:i=>r("channelId",i.target.value||void 0),placeholder:"C0123ABCD (blank = any)"})]}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Channel allowlist (comma-separated IDs)"}),e.jsx("input",{style:l.input,value:((s=t.channelIdAllowlist)==null?void 0:s.join(", "))||"",onChange:i=>r("channelIdAllowlist",i.target.value.split(",").map(c=>c.trim()).filter(Boolean)),placeholder:"C06UCC5FFST, C0789..."})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Exclude channel IDs (comma-separated)"}),e.jsx("input",{style:l.input,value:((a=t.excludeChannelIds)==null?void 0:a.join(", "))||"",onChange:i=>r("excludeChannelIds",i.target.value.split(",").map(c=>c.trim()).filter(Boolean)),placeholder:"D0AMP833LDQ"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Message pattern (regex)"}),e.jsx("input",{style:l.input,value:t.messagePattern||"",onChange:i=>r("messagePattern",i.target.value||void 0),placeholder:"deploy|release"})]}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"User filter (comma-separated IDs)"}),e.jsx("input",{style:l.input,value:((p=t.userFilter)==null?void 0:p.join(", "))||"",onChange:i=>r("userFilter",i.target.value.split(",").map(c=>c.trim()).filter(Boolean)),placeholder:"U0123ABCD, U0456EFGH"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Exclude user IDs (comma-separated)"}),e.jsx("input",{style:l.input,value:((d=t.excludeUserIds)==null?void 0:d.join(", "))||"",onChange:i=>r("excludeUserIds",i.target.value.split(",").map(c=>c.trim()).filter(Boolean)),placeholder:"U0789IJKL"})]})]}),e.jsxs("div",{style:l.checkboxGrid,children:[e.jsxs("label",{style:l.checkboxLabel,children:[e.jsx("input",{type:"checkbox",checked:!!t.dmOnly,onChange:i=>r("dmOnly",i.target.checked||void 0)}),e.jsx("span",{children:"DMs only"})]}),e.jsxs("label",{style:l.checkboxLabel,children:[e.jsx("input",{type:"checkbox",checked:!!t.excludeDms,onChange:i=>r("excludeDms",i.target.checked||void 0)}),e.jsx("span",{children:"Exclude DMs"})]}),e.jsxs("label",{style:l.checkboxLabel,children:[e.jsx("input",{type:"checkbox",checked:!!t.includeOwnMessages,onChange:i=>r("includeOwnMessages",i.target.checked||void 0)}),e.jsx("span",{children:"Include own messages"})]})]})]})})(),n.type==="email"&&(()=>{var p,d,i;const t=n.config||{},s=t.requiredApprovals,a=c=>r("requiredApprovals",{count:1,approvers:[],approvalKeywords:[],...s,...c});return e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Email Config"}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"From filter (comma-separated addresses)"}),e.jsx("input",{style:l.input,value:((p=t.fromFilter)==null?void 0:p.join(", "))||"",onChange:c=>r("fromFilter",c.target.value.split(",").map(C=>C.trim()).filter(Boolean)),placeholder:"alerts@example.com, ops@example.com"})]}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Subject pattern (regex)"}),e.jsx("input",{style:l.input,value:t.subjectPattern||"",onChange:c=>r("subjectPattern",c.target.value||void 0),placeholder:"^\\\\[Deploy\\\\]"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Thread ID"}),e.jsx("input",{style:l.input,value:t.threadId||"",onChange:c=>r("threadId",c.target.value||void 0),placeholder:"Only watch a specific thread"})]})]}),e.jsx("div",{style:l.field,children:e.jsxs("label",{style:l.checkboxLabel,children:[e.jsx("input",{type:"checkbox",checked:!!s,onChange:c=>r("requiredApprovals",c.target.checked?{count:1,approvers:[],approvalKeywords:[]}:void 0)}),e.jsx("span",{children:"Require approvals before firing"})]})}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Approvals needed"}),e.jsx("input",{style:l.input,type:"number",min:"1",value:s.count??1,onChange:c=>a({count:parseInt(c.target.value,10)||1})})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Approvers (comma-separated)"}),e.jsx("input",{style:l.input,value:((d=s.approvers)==null?void 0:d.join(", "))||"",onChange:c=>a({approvers:c.target.value.split(",").map(C=>C.trim()).filter(Boolean)}),placeholder:"lead@example.com"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Approval keywords (comma-separated)"}),e.jsx("input",{style:l.input,value:((i=s.approvalKeywords)==null?void 0:i.join(", "))||"",onChange:c=>a({approvalKeywords:c.target.value.split(",").map(C=>C.trim()).filter(Boolean)}),placeholder:"approved, lgtm, ship it"})]})]})]})})(),n.type==="jira"&&(()=>{var s;const t=n.config||{};return e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Jira Config"}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Project key"}),e.jsx("input",{style:l.input,value:t.projectKey||"",onChange:a=>r("projectKey",a.target.value||void 0),placeholder:"OPS"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Issue type"}),e.jsx("input",{style:l.input,value:t.issueType||"",onChange:a=>r("issueType",a.target.value||void 0),placeholder:"Service Request"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Events (comma-separated)"}),e.jsx("input",{style:l.input,value:((s=t.events)==null?void 0:s.join(", "))||"",onChange:a=>r("events",a.target.value.split(",").map(p=>p.trim()).filter(Boolean)),placeholder:"jira:issue_created, jira:issue_updated"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"JQL filter"}),e.jsx("textarea",{style:l.textarea,value:t.jqlFilter||"",onChange:a=>r("jqlFilter",a.target.value||void 0),placeholder:"priority = High AND status = Open",rows:2})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"HMAC / shared secret"}),e.jsx("input",{style:l.input,type:"password",value:t.secret||"",onChange:a=>r("secret",a.target.value||void 0),placeholder:"Required — unsigned deliveries are rejected"})]})]})})(),n.type==="whatsapp"&&(()=>{var s;const t=n.config||{};return e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"WhatsApp Config"}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"From filter (comma-separated JID substrings)"}),e.jsx("input",{style:l.input,value:((s=t.fromFilter)==null?void 0:s.join(", "))||"",onChange:a=>r("fromFilter",a.target.value.split(",").map(p=>p.trim()).filter(Boolean)),placeholder:"5215512345678, @g.us"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Direction"}),e.jsxs("select",{style:l.select,value:t.direction||"any",onChange:a=>r("direction",a.target.value==="any"?void 0:a.target.value),children:[e.jsx("option",{value:"any",children:"Any"}),e.jsx("option",{value:"inbound",children:"Inbound"}),e.jsx("option",{value:"outbound",children:"Outbound"})]})]})]}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Body pattern (regex)"}),e.jsx("input",{style:l.input,value:t.bodyPattern||"",onChange:a=>r("bodyPattern",a.target.value||void 0),placeholder:"urgente|deploy"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Session ID"}),e.jsx("input",{style:l.input,value:t.sessionId||"",onChange:a=>r("sessionId",a.target.value||void 0),placeholder:"Restrict to a Baileys session"})]})]}),e.jsxs("div",{style:l.checkboxGrid,children:[e.jsxs("label",{style:l.checkboxLabel,children:[e.jsx("input",{type:"checkbox",checked:!!t.groupOnly,onChange:a=>r("groupOnly",a.target.checked||void 0)}),e.jsx("span",{children:"Groups only"})]}),e.jsxs("label",{style:l.checkboxLabel,children:[e.jsx("input",{type:"checkbox",checked:!!t.dmOnly,onChange:a=>r("dmOnly",a.target.checked||void 0)}),e.jsx("span",{children:"DMs only"})]}),e.jsxs("label",{style:l.checkboxLabel,children:[e.jsx("input",{type:"checkbox",checked:!!t.includeStatuses,onChange:a=>r("includeStatuses",a.target.checked||void 0)}),e.jsx("span",{children:"Include statuses"})]})]})]})})(),e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Match Mode"}),e.jsx("div",{style:l.modeSelector,children:Re.map(t=>e.jsxs("button",{style:{...l.modeBtn,...n.matchMode===t.value?l.modeBtnActive:{}},onClick:()=>x("matchMode",t.value),children:[e.jsx("strong",{children:t.label}),e.jsx("span",{style:l.modeDesc,children:t.desc})]},t.value))}),(n.matchMode==="llm"||n.matchMode==="hybrid")&&e.jsxs("div",{style:l.llmConfig,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"LLM Match Prompt"}),e.jsx("textarea",{style:l.textarea,value:((le=n.llmMatch)==null?void 0:le.prompt)||"",onChange:t=>E("prompt",t.target.value),placeholder:"Does this message request a release deployment?",rows:3})]}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Model"}),e.jsxs("select",{style:l.select,value:((te=n.llmMatch)==null?void 0:te.model)||"haiku",onChange:t=>E("model",t.target.value),children:[e.jsx("option",{value:"haiku",children:"Haiku (fast, cheap)"}),e.jsx("option",{value:"sonnet",children:"Sonnet (balanced)"}),e.jsx("option",{value:"opus",children:"Opus (powerful)"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Min Confidence"}),e.jsx("input",{style:l.input,type:"number",min:"0",max:"1",step:"0.1",value:((se=n.llmMatch)==null?void 0:se.minConfidence)??0,onChange:t=>E("minConfidence",parseFloat(t.target.value))})]})]})]})]}),e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Extraction Mode"}),e.jsx("div",{style:l.row,children:Fe.map(t=>e.jsx("button",{style:{...l.modeBtn,...n.extractionMode===t.value?l.modeBtnActive:{}},onClick:()=>x("extractionMode",t.value),children:t.label},t.value))}),n.extractionMode==="llm"&&e.jsxs("div",{style:l.llmConfig,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Extraction Instructions"}),e.jsx("textarea",{style:l.textarea,value:((ae=n.llmExtract)==null?void 0:ae.prompt)||"",onChange:t=>J("prompt",t.target.value),placeholder:"Extract: release version, affected systems, urgency",rows:3})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Variable Names (comma-separated)"}),e.jsx("input",{style:l.input,value:((ie=(ne=n.llmExtract)==null?void 0:ne.variables)==null?void 0:ie.join(", "))||"",onChange:t=>J("variables",t.target.value.split(",").map(s=>s.trim()).filter(Boolean)),placeholder:"release_name, affected_systems, urgency"})]})]})]}),h&&e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Test Match"}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Sample Event Payload (JSON)"}),e.jsx("textarea",{style:l.textarea,value:F,onChange:t=>be(t.target.value),rows:4})]}),e.jsx("button",{style:l.testBtn,onClick:Ce,disabled:N,children:N?"Testing...":"Test Match"}),u&&e.jsxs("div",{style:l.testResult,children:[e.jsx("div",{style:{...l.testResultHeader,color:u.wouldFire?"#2ecc71":"#e74c3c"},children:u.wouldFire?"WOULD FIRE":"WOULD NOT FIRE"}),u.structuralMatch!==void 0&&e.jsxs("div",{children:["Structural: ",u.structuralMatch?"Match":"No match"]}),u.llmMatch&&e.jsxs("div",{style:l.llmResult,children:[e.jsxs("div",{children:["LLM: ",u.llmMatch.match?"Match":"No match"]}),e.jsxs("div",{children:["Confidence: ",(u.llmMatch.confidence*100).toFixed(0),"%"]}),e.jsxs("div",{children:["Reason: ",u.llmMatch.reason]}),e.jsxs("div",{style:l.llmMeta,children:["Model: ",u.llmMatch.model," | Tokens: ",u.llmMatch.tokensUsed," | Latency: ",u.llmMatch.durationMs,"ms"]})]}),Object.keys(u.extractedVariables).length>0&&e.jsxs("div",{children:[e.jsx("div",{style:l.label,children:"Extracted Variables:"}),Object.entries(u.extractedVariables).map(([t,s])=>e.jsxs("div",{style:l.varRow,children:[e.jsx("code",{children:t}),": ",s]},t))]})]})]}),h&&z.length>0&&e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Recent Fires"}),e.jsx("div",{style:l.historyList,children:z.map((t,s)=>{const a=t.llm_match_result?JSON.parse(t.llm_match_result):null;return e.jsxs("div",{style:l.historyItem,children:[e.jsxs("div",{style:l.historyHeader,children:[e.jsx("span",{style:{color:t.status==="delivered"?"#2ecc71":t.status==="failed"?"#e74c3c":"#f39c12"},children:t.status}),e.jsx("span",{children:new Date(t.fired_at).toLocaleString()}),t.duration_ms&&e.jsxs("span",{children:[t.duration_ms,"ms"]})]}),t.error&&e.jsx("div",{style:{color:"#e74c3c",fontSize:"12px"},children:t.error}),a&&e.jsxs("div",{style:l.llmMeta,children:["LLM: ",a.match?"match":"no match"," (",(a.confidence*100).toFixed(0),"%) - ",a.reason]})]},t.id||s)})})]}),e.jsxs("div",{style:l.actions,children:[e.jsx("button",{style:l.cancelBtn,onClick:()=>{A("list"),y(null)},children:"Cancel"}),e.jsx("button",{style:l.saveBtn,onClick:ve,disabled:L||!n.name||!n.agentId||n.type==="cron"&&!!((re=n.config)!=null&&re.runOnce)&&!((oe=n.config)!=null&&oe.runAt)||n.type==="bitbucket"&&(!((ce=n.config)!=null&&ce.workspace)||!((de=n.config)!=null&&de.repoSlug)||!((ue=(pe=n.config)==null?void 0:pe.events)!=null&&ue.length)),children:L?"Saving...":h?"Update":"Create"})]})]})})]})}):null}const l={overlay:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},panel:{background:"#1e1e2e",borderRadius:"12px",width:"680px",maxHeight:"85vh",display:"flex",flexDirection:"column",color:"#cdd6f4",boxShadow:"0 8px 32px rgba(0,0,0,0.4)"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:"1px solid #313244"},title:{margin:0,fontSize:"18px",fontWeight:600},headerActions:{display:"flex",gap:"8px"},content:{overflow:"auto",padding:"16px 20px",flex:1},empty:{textAlign:"center",padding:"40px",color:"#6c7086"},error:{background:"#45252a",color:"#f38ba8",padding:"8px 20px",fontSize:"13px"},tabBar:{display:"flex",gap:"4px",marginBottom:"12px",paddingBottom:"8px",borderBottom:"1px solid #313244",flexWrap:"wrap"},tab:{background:"transparent",border:"1px solid transparent",borderRadius:"6px",padding:"6px 10px",color:"#a6adc8",cursor:"pointer",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px",transition:"background 0.12s, color 0.12s, border-color 0.12s"},tabActive:{background:"#1e3a5f",borderColor:"#89b4fa",color:"#cdd6f4"},tabIcon:{fontSize:"13px",lineHeight:1},tabLabel:{fontWeight:500},tabBadge:{background:"#313244",color:"#a6adc8",borderRadius:"10px",padding:"1px 7px",fontSize:"10px",fontWeight:600,minWidth:"16px",textAlign:"center",lineHeight:"14px"},tabBadgeActive:{background:"#89b4fa",color:"#1e1e2e"},triggerCard:{background:"#181825",borderRadius:"8px",padding:"12px 16px",marginBottom:"8px",borderLeft:"3px solid",cursor:"pointer",transition:"background 0.15s"},cardHeader:{display:"flex",justifyContent:"space-between",alignItems:"center"},cardTitle:{display:"flex",alignItems:"center",gap:"8px",fontWeight:500},typeTag:{background:"#313244",padding:"2px 6px",borderRadius:"4px",fontSize:"11px",textTransform:"uppercase"},matchTag:{background:"#45475a",padding:"2px 6px",borderRadius:"4px",fontSize:"10px",color:"#a6e3a1"},cardActions:{display:"flex",gap:"6px"},cardMeta:{display:"flex",gap:"16px",marginTop:"8px",fontSize:"12px",color:"#6c7086"},form:{display:"flex",flexDirection:"column",gap:"12px"},field:{display:"flex",flexDirection:"column",gap:"4px",flex:1},row:{display:"flex",gap:"12px"},label:{fontSize:"12px",color:"#a6adc8",fontWeight:500},input:{background:"#313244",border:"1px solid #45475a",borderRadius:"6px",padding:"8px 10px",color:"#cdd6f4",fontSize:"13px",outline:"none"},select:{background:"#313244",border:"1px solid #45475a",borderRadius:"6px",padding:"8px 10px",color:"#cdd6f4",fontSize:"13px",outline:"none"},textarea:{background:"#313244",border:"1px solid #45475a",borderRadius:"6px",padding:"8px 10px",color:"#cdd6f4",fontSize:"13px",outline:"none",fontFamily:"monospace",resize:"vertical"},section:{borderTop:"1px solid #313244",paddingTop:"12px"},sectionTitle:{margin:"0 0 8px",fontSize:"14px",fontWeight:600,color:"#a6adc8"},modeSelector:{display:"flex",gap:"8px",marginBottom:"8px"},modeBtn:{flex:1,background:"#313244",border:"1px solid #45475a",borderRadius:"6px",padding:"8px",color:"#cdd6f4",cursor:"pointer",textAlign:"left",display:"flex",flexDirection:"column",gap:"2px",fontSize:"12px"},modeBtnActive:{borderColor:"#89b4fa",background:"#1e3a5f"},modeDesc:{fontSize:"10px",color:"#6c7086"},llmConfig:{background:"#181825",borderRadius:"6px",padding:"12px",display:"flex",flexDirection:"column",gap:"8px"},webhookUrl:{marginTop:"8px"},inlineRow:{display:"flex",gap:"6px",alignItems:"center"},checkboxGrid:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"6px 12px"},checkboxLabel:{display:"flex",alignItems:"center",gap:"6px",fontSize:"12px",color:"#cdd6f4",cursor:"pointer"},checkboxCode:{fontSize:"10px",color:"#6c7086",background:"transparent",padding:0},code:{background:"#313244",padding:"6px 10px",borderRadius:"4px",fontSize:"12px",display:"block",wordBreak:"break-all",color:"#89b4fa"},nextFires:{marginTop:"8px"},nextFireItem:{fontSize:"12px",color:"#a6e3a1",padding:"2px 0"},testBtn:{background:"#89b4fa",border:"none",borderRadius:"6px",padding:"8px 16px",color:"#1e1e2e",fontWeight:600,cursor:"pointer",fontSize:"13px"},testResult:{background:"#181825",borderRadius:"6px",padding:"12px",marginTop:"8px",fontSize:"13px",display:"flex",flexDirection:"column",gap:"6px"},testResultHeader:{fontWeight:700,fontSize:"14px"},llmResult:{display:"flex",flexDirection:"column",gap:"2px"},llmMeta:{fontSize:"11px",color:"#6c7086",marginTop:"2px"},varRow:{fontSize:"12px",padding:"2px 0"},historyList:{display:"flex",flexDirection:"column",gap:"6px",maxHeight:"200px",overflow:"auto"},historyItem:{background:"#181825",borderRadius:"4px",padding:"8px 10px",fontSize:"12px"},historyHeader:{display:"flex",justifyContent:"space-between",alignItems:"center"},actions:{display:"flex",justifyContent:"flex-end",gap:"8px",marginTop:"16px",paddingTop:"12px",borderTop:"1px solid #313244"},addBtn:{background:"#89b4fa",border:"none",borderRadius:"6px",padding:"6px 14px",color:"#1e1e2e",fontWeight:600,cursor:"pointer",fontSize:"13px"},backBtn:{background:"transparent",border:"1px solid #45475a",borderRadius:"6px",padding:"6px 14px",color:"#cdd6f4",cursor:"pointer",fontSize:"13px"},closeBtn:{background:"transparent",border:"none",color:"#6c7086",cursor:"pointer",fontSize:"16px",padding:"4px 8px"},smallBtn:{background:"transparent",border:"1px solid #45475a",borderRadius:"4px",padding:"3px 8px",color:"#cdd6f4",cursor:"pointer",fontSize:"11px"},saveBtn:{background:"#a6e3a1",border:"none",borderRadius:"6px",padding:"8px 20px",color:"#1e1e2e",fontWeight:600,cursor:"pointer",fontSize:"13px"},cancelBtn:{background:"transparent",border:"1px solid #45475a",borderRadius:"6px",padding:"8px 20px",color:"#cdd6f4",cursor:"pointer",fontSize:"13px"}};export{Pe as TriggerManagerPanel,Pe as default};
9
+ {{whatsapp.attachmentsBlock}}`))},children:Ie.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Agent"}),e.jsxs("select",{style:l.select,value:n.agentId||"",onChange:t=>x("agentId",t.target.value),children:[e.jsx("option",{value:"",children:"Select agent..."}),Te.map(t=>e.jsxs("option",{value:t.id,children:[t.name," (",t.class,")"]},t.id))]})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Prompt Template"}),e.jsx("textarea",{style:l.textarea,value:n.promptTemplate||"",onChange:t=>x("promptTemplate",t.target.value),placeholder:"Message sent to agent. Use {{variable}} for interpolation.",rows:4})]}),n.type==="webhook"&&e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Webhook Config"}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Method"}),e.jsxs("select",{style:l.select,value:((Q=n.config)==null?void 0:Q.method)||"POST",onChange:t=>r("method",t.target.value),children:[e.jsx("option",{value:"POST",children:"POST"}),e.jsx("option",{value:"PUT",children:"PUT"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Secret (HMAC)"}),e.jsx("input",{style:l.input,type:"password",value:((X=n.config)==null?void 0:X.secret)||"",onChange:t=>r("secret",t.target.value||void 0),placeholder:"Optional HMAC secret"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Extract Fields (comma-separated JSON paths)"}),e.jsx("input",{style:l.input,value:((ee=(Z=n.config)==null?void 0:Z.extractFields)==null?void 0:ee.join(", "))||"",onChange:t=>r("extractFields",t.target.value.split(",").map(s=>s.trim()).filter(Boolean)),placeholder:"body.release_name, body.version"})]}),h&&n.id&&e.jsxs("div",{style:l.webhookUrl,children:[e.jsx("label",{style:l.label,children:"Webhook URL"}),e.jsx("code",{style:l.code,children:`${window.location.origin}/api/triggers/webhook/${n.id}`})]})]}),n.type==="bitbucket"&&(()=>{const t=n.config||{},s=Array.isArray(t.events)?t.events:[],a=h&&n.id?`${window.location.origin}/api/triggers/webhook/${n.id}`:"",p=d=>{const i=s.includes(d)?s.filter(c=>c!==d):[...s,d];r("events",i)};return e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Bitbucket Config"}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Workspace"}),e.jsx("input",{style:l.input,value:t.workspace||"",onChange:d=>r("workspace",d.target.value),placeholder:"tide"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Repository slug"}),e.jsx("input",{style:l.input,value:t.repoSlug||"",onChange:d=>r("repoSlug",d.target.value),placeholder:"wind"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Events"}),e.jsx("div",{style:l.checkboxGrid,children:Be.map(d=>{const i=s.includes(d.value);return e.jsxs("label",{style:l.checkboxLabel,children:[e.jsx("input",{type:"checkbox",checked:i,onChange:()=>p(d.value)}),e.jsx("span",{children:d.label}),e.jsx("code",{style:l.checkboxCode,children:d.value})]},d.value)})})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"HMAC secret"}),e.jsxs("div",{style:l.inlineRow,children:[e.jsx("input",{style:{...l.input,flex:1},type:"password",value:t.secret||"",onChange:d=>r("secret",d.target.value||void 0),placeholder:"Shared secret used to validate Bitbucket signature"}),e.jsx("button",{type:"button",style:l.smallBtn,onClick:()=>Y(t.secret||"","bitbucket-secret"),disabled:!t.secret,children:K==="bitbucket-secret"?"Copied!":"Copy"})]}),e.jsx("span",{style:l.llmMeta,children:"Paste the same secret into Bitbucket's webhook configuration."})]}),a&&e.jsxs("div",{style:l.webhookUrl,children:[e.jsx("label",{style:l.label,children:"Webhook URL"}),e.jsxs("div",{style:l.inlineRow,children:[e.jsx("code",{style:{...l.code,flex:1},children:a}),e.jsx("button",{type:"button",style:l.smallBtn,onClick:()=>Y(a,"bitbucket-url"),children:K==="bitbucket-url"?"Copied!":"Copy"})]}),e.jsx("span",{style:l.llmMeta,children:"In Bitbucket: Repository settings → Webhooks → Add webhook, then paste this URL and the secret above."})]}),!a&&e.jsx("span",{style:l.llmMeta,children:"Save the trigger to reveal its webhook URL."})]})})(),n.type==="cron"&&(()=>{const t=n.config||{},s=!!t.runOnce,a=t.completedAt,p=t.missedAt,d=!!a;return e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Cron Config"}),e.jsxs("div",{style:l.modeSelector,children:[e.jsxs("button",{type:"button",style:{...l.modeBtn,...s?{}:l.modeBtnActive},onClick:()=>r("runOnce",!1),disabled:d,children:[e.jsx("strong",{children:"Repeats"}),e.jsx("span",{style:l.modeDesc,children:"Fires on a cron schedule"})]}),e.jsxs("button",{type:"button",style:{...l.modeBtn,...s?l.modeBtnActive:{}},onClick:()=>r("runOnce",!0),disabled:d,children:[e.jsx("strong",{children:"Run once"}),e.jsx("span",{style:l.modeDesc,children:"Fires exactly once at a specific time"})]})]}),d&&e.jsxs("div",{style:{...l.testResult,borderLeft:"3px solid #a6e3a1"},children:[e.jsx("strong",{style:{color:"#a6e3a1"},children:"Completed"}),e.jsxs("span",{style:l.llmMeta,children:["Fired at ",new Date(a).toLocaleString()]})]}),!d&&p&&e.jsxs("div",{style:{...l.testResult,borderLeft:"3px solid #f38ba8"},children:[e.jsx("strong",{style:{color:"#f38ba8"},children:"Missed"}),e.jsxs("span",{style:l.llmMeta,children:["Marked missed at ",new Date(p).toLocaleString()," (server was down at runAt)"]})]}),s?e.jsx("div",{style:l.row,children:e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Run at"}),e.jsx("input",{style:l.input,type:"datetime-local",value:Ee(t.runAt),onChange:i=>{const c=i.target.value;if(!c){r("runAt",void 0);return}const C=new Date(c).toISOString();r("runAt",C)},disabled:d}),e.jsx("span",{style:l.llmMeta,children:"Interpreted in your browser's local timezone"})]})}):e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Expression"}),e.jsx("input",{style:l.input,value:t.expression||"",onChange:i=>{r("expression",i.target.value),i.target.value&&we(i.target.value)},placeholder:"0 9 * * MON-FRI"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Timezone"}),e.jsx("input",{style:l.input,value:t.timezone||"UTC",onChange:i=>r("timezone",i.target.value),placeholder:"America/Mexico_City"})]})]}),!s&&H.length>0&&e.jsxs("div",{style:l.nextFires,children:[e.jsx("label",{style:l.label,children:"Next fires:"}),H.map((i,c)=>e.jsx("div",{style:l.nextFireItem,children:new Date(i).toLocaleString()},c))]})]})})(),n.type==="slack"&&(()=>{var s,a,p,d;const t=n.config||{};return e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Slack Config"}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Instance"}),e.jsxs("select",{style:l.select,value:t.instanceId||"",onChange:i=>r("instanceId",i.target.value||void 0),children:[e.jsx("option",{value:"",children:"Any instance"}),_.map(i=>e.jsxs("option",{value:i.id,children:[i.label," (",i.id,")"]},i.id)),t.instanceId&&!_.some(i=>i.id===t.instanceId)&&e.jsxs("option",{value:t.instanceId,children:[t.instanceId," (not found)"]})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Thread timestamp"}),e.jsx("input",{style:l.input,value:t.threadTs||"",onChange:i=>r("threadTs",i.target.value||void 0),placeholder:"Only replies in this thread"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Channel ID (legacy single channel)"}),e.jsx("input",{style:l.input,value:t.channelId||"",onChange:i=>r("channelId",i.target.value||void 0),placeholder:"C0123ABCD (blank = any)"})]}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Channel allowlist (comma-separated IDs)"}),e.jsx("input",{style:l.input,value:((s=t.channelIdAllowlist)==null?void 0:s.join(", "))||"",onChange:i=>r("channelIdAllowlist",i.target.value.split(",").map(c=>c.trim()).filter(Boolean)),placeholder:"C06UCC5FFST, C0789..."})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Exclude channel IDs (comma-separated)"}),e.jsx("input",{style:l.input,value:((a=t.excludeChannelIds)==null?void 0:a.join(", "))||"",onChange:i=>r("excludeChannelIds",i.target.value.split(",").map(c=>c.trim()).filter(Boolean)),placeholder:"D0AMP833LDQ"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Message pattern (regex)"}),e.jsx("input",{style:l.input,value:t.messagePattern||"",onChange:i=>r("messagePattern",i.target.value||void 0),placeholder:"deploy|release"})]}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"User filter (comma-separated IDs)"}),e.jsx("input",{style:l.input,value:((p=t.userFilter)==null?void 0:p.join(", "))||"",onChange:i=>r("userFilter",i.target.value.split(",").map(c=>c.trim()).filter(Boolean)),placeholder:"U0123ABCD, U0456EFGH"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Exclude user IDs (comma-separated)"}),e.jsx("input",{style:l.input,value:((d=t.excludeUserIds)==null?void 0:d.join(", "))||"",onChange:i=>r("excludeUserIds",i.target.value.split(",").map(c=>c.trim()).filter(Boolean)),placeholder:"U0789IJKL"})]})]}),e.jsxs("div",{style:l.checkboxGrid,children:[e.jsxs("label",{style:l.checkboxLabel,children:[e.jsx("input",{type:"checkbox",checked:!!t.dmOnly,onChange:i=>r("dmOnly",i.target.checked||void 0)}),e.jsx("span",{children:"DMs only"})]}),e.jsxs("label",{style:l.checkboxLabel,children:[e.jsx("input",{type:"checkbox",checked:!!t.excludeDms,onChange:i=>r("excludeDms",i.target.checked||void 0)}),e.jsx("span",{children:"Exclude DMs"})]}),e.jsxs("label",{style:l.checkboxLabel,children:[e.jsx("input",{type:"checkbox",checked:!!t.includeOwnMessages,onChange:i=>r("includeOwnMessages",i.target.checked||void 0)}),e.jsx("span",{children:"Include own messages"})]})]})]})})(),n.type==="email"&&(()=>{var p,d,i;const t=n.config||{},s=t.requiredApprovals,a=c=>r("requiredApprovals",{count:1,approvers:[],approvalKeywords:[],...s,...c});return e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Email Config"}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"From filter (comma-separated addresses)"}),e.jsx("input",{style:l.input,value:((p=t.fromFilter)==null?void 0:p.join(", "))||"",onChange:c=>r("fromFilter",c.target.value.split(",").map(C=>C.trim()).filter(Boolean)),placeholder:"alerts@example.com, ops@example.com"})]}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Subject pattern (regex)"}),e.jsx("input",{style:l.input,value:t.subjectPattern||"",onChange:c=>r("subjectPattern",c.target.value||void 0),placeholder:"^\\\\[Deploy\\\\]"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Thread ID"}),e.jsx("input",{style:l.input,value:t.threadId||"",onChange:c=>r("threadId",c.target.value||void 0),placeholder:"Only watch a specific thread"})]})]}),e.jsx("div",{style:l.field,children:e.jsxs("label",{style:l.checkboxLabel,children:[e.jsx("input",{type:"checkbox",checked:!!s,onChange:c=>r("requiredApprovals",c.target.checked?{count:1,approvers:[],approvalKeywords:[]}:void 0)}),e.jsx("span",{children:"Require approvals before firing"})]})}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Approvals needed"}),e.jsx("input",{style:l.input,type:"number",min:"1",value:s.count??1,onChange:c=>a({count:parseInt(c.target.value,10)||1})})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Approvers (comma-separated)"}),e.jsx("input",{style:l.input,value:((d=s.approvers)==null?void 0:d.join(", "))||"",onChange:c=>a({approvers:c.target.value.split(",").map(C=>C.trim()).filter(Boolean)}),placeholder:"lead@example.com"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Approval keywords (comma-separated)"}),e.jsx("input",{style:l.input,value:((i=s.approvalKeywords)==null?void 0:i.join(", "))||"",onChange:c=>a({approvalKeywords:c.target.value.split(",").map(C=>C.trim()).filter(Boolean)}),placeholder:"approved, lgtm, ship it"})]})]})]})})(),n.type==="jira"&&(()=>{var s;const t=n.config||{};return e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Jira Config"}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Project key"}),e.jsx("input",{style:l.input,value:t.projectKey||"",onChange:a=>r("projectKey",a.target.value||void 0),placeholder:"OPS"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Issue type"}),e.jsx("input",{style:l.input,value:t.issueType||"",onChange:a=>r("issueType",a.target.value||void 0),placeholder:"Service Request"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Events (comma-separated)"}),e.jsx("input",{style:l.input,value:((s=t.events)==null?void 0:s.join(", "))||"",onChange:a=>r("events",a.target.value.split(",").map(p=>p.trim()).filter(Boolean)),placeholder:"jira:issue_created, jira:issue_updated"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"JQL filter"}),e.jsx("textarea",{style:l.textarea,value:t.jqlFilter||"",onChange:a=>r("jqlFilter",a.target.value||void 0),placeholder:"priority = High AND status = Open",rows:2})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"HMAC / shared secret"}),e.jsx("input",{style:l.input,type:"password",value:t.secret||"",onChange:a=>r("secret",a.target.value||void 0),placeholder:"Required — unsigned deliveries are rejected"})]})]})})(),n.type==="whatsapp"&&(()=>{var s;const t=n.config||{};return e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"WhatsApp Config"}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"From filter (comma-separated JID substrings)"}),e.jsx("input",{style:l.input,value:((s=t.fromFilter)==null?void 0:s.join(", "))||"",onChange:a=>r("fromFilter",a.target.value.split(",").map(p=>p.trim()).filter(Boolean)),placeholder:"5215512345678, @g.us"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Direction"}),e.jsxs("select",{style:l.select,value:t.direction||"any",onChange:a=>r("direction",a.target.value==="any"?void 0:a.target.value),children:[e.jsx("option",{value:"any",children:"Any"}),e.jsx("option",{value:"inbound",children:"Inbound"}),e.jsx("option",{value:"outbound",children:"Outbound"})]})]})]}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Body pattern (regex)"}),e.jsx("input",{style:l.input,value:t.bodyPattern||"",onChange:a=>r("bodyPattern",a.target.value||void 0),placeholder:"urgente|deploy"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Session ID"}),e.jsx("input",{style:l.input,value:t.sessionId||"",onChange:a=>r("sessionId",a.target.value||void 0),placeholder:"Restrict to a Baileys session"})]})]}),e.jsxs("div",{style:l.checkboxGrid,children:[e.jsxs("label",{style:l.checkboxLabel,children:[e.jsx("input",{type:"checkbox",checked:!!t.groupOnly,onChange:a=>r("groupOnly",a.target.checked||void 0)}),e.jsx("span",{children:"Groups only"})]}),e.jsxs("label",{style:l.checkboxLabel,children:[e.jsx("input",{type:"checkbox",checked:!!t.dmOnly,onChange:a=>r("dmOnly",a.target.checked||void 0)}),e.jsx("span",{children:"DMs only"})]}),e.jsxs("label",{style:l.checkboxLabel,children:[e.jsx("input",{type:"checkbox",checked:!!t.includeStatuses,onChange:a=>r("includeStatuses",a.target.checked||void 0)}),e.jsx("span",{children:"Include statuses"})]})]})]})})(),e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Match Mode"}),e.jsx("div",{style:l.modeSelector,children:Re.map(t=>e.jsxs("button",{style:{...l.modeBtn,...n.matchMode===t.value?l.modeBtnActive:{}},onClick:()=>x("matchMode",t.value),children:[e.jsx("strong",{children:t.label}),e.jsx("span",{style:l.modeDesc,children:t.desc})]},t.value))}),(n.matchMode==="llm"||n.matchMode==="hybrid")&&e.jsxs("div",{style:l.llmConfig,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"LLM Match Prompt"}),e.jsx("textarea",{style:l.textarea,value:((le=n.llmMatch)==null?void 0:le.prompt)||"",onChange:t=>E("prompt",t.target.value),placeholder:"Does this message request a release deployment?",rows:3})]}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Model"}),e.jsxs("select",{style:l.select,value:((te=n.llmMatch)==null?void 0:te.model)||"haiku",onChange:t=>E("model",t.target.value),children:[e.jsx("option",{value:"haiku",children:"Haiku (fast, cheap)"}),e.jsx("option",{value:"sonnet",children:"Sonnet (balanced)"}),e.jsx("option",{value:"opus",children:"Opus (powerful)"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Min Confidence"}),e.jsx("input",{style:l.input,type:"number",min:"0",max:"1",step:"0.1",value:((se=n.llmMatch)==null?void 0:se.minConfidence)??0,onChange:t=>E("minConfidence",parseFloat(t.target.value))})]})]})]})]}),e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Extraction Mode"}),e.jsx("div",{style:l.row,children:Fe.map(t=>e.jsx("button",{style:{...l.modeBtn,...n.extractionMode===t.value?l.modeBtnActive:{}},onClick:()=>x("extractionMode",t.value),children:t.label},t.value))}),n.extractionMode==="llm"&&e.jsxs("div",{style:l.llmConfig,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Extraction Instructions"}),e.jsx("textarea",{style:l.textarea,value:((ae=n.llmExtract)==null?void 0:ae.prompt)||"",onChange:t=>J("prompt",t.target.value),placeholder:"Extract: release version, affected systems, urgency",rows:3})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Variable Names (comma-separated)"}),e.jsx("input",{style:l.input,value:((ie=(ne=n.llmExtract)==null?void 0:ne.variables)==null?void 0:ie.join(", "))||"",onChange:t=>J("variables",t.target.value.split(",").map(s=>s.trim()).filter(Boolean)),placeholder:"release_name, affected_systems, urgency"})]})]})]}),h&&e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Test Match"}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Sample Event Payload (JSON)"}),e.jsx("textarea",{style:l.textarea,value:F,onChange:t=>be(t.target.value),rows:4})]}),e.jsx("button",{style:l.testBtn,onClick:Ce,disabled:N,children:N?"Testing...":"Test Match"}),u&&e.jsxs("div",{style:l.testResult,children:[e.jsx("div",{style:{...l.testResultHeader,color:u.wouldFire?"#2ecc71":"#e74c3c"},children:u.wouldFire?"WOULD FIRE":"WOULD NOT FIRE"}),u.structuralMatch!==void 0&&e.jsxs("div",{children:["Structural: ",u.structuralMatch?"Match":"No match"]}),u.llmMatch&&e.jsxs("div",{style:l.llmResult,children:[e.jsxs("div",{children:["LLM: ",u.llmMatch.match?"Match":"No match"]}),e.jsxs("div",{children:["Confidence: ",(u.llmMatch.confidence*100).toFixed(0),"%"]}),e.jsxs("div",{children:["Reason: ",u.llmMatch.reason]}),e.jsxs("div",{style:l.llmMeta,children:["Model: ",u.llmMatch.model," | Tokens: ",u.llmMatch.tokensUsed," | Latency: ",u.llmMatch.durationMs,"ms"]})]}),Object.keys(u.extractedVariables).length>0&&e.jsxs("div",{children:[e.jsx("div",{style:l.label,children:"Extracted Variables:"}),Object.entries(u.extractedVariables).map(([t,s])=>e.jsxs("div",{style:l.varRow,children:[e.jsx("code",{children:t}),": ",s]},t))]})]})]}),h&&z.length>0&&e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Recent Fires"}),e.jsx("div",{style:l.historyList,children:z.map((t,s)=>{const a=t.llm_match_result?JSON.parse(t.llm_match_result):null;return e.jsxs("div",{style:l.historyItem,children:[e.jsxs("div",{style:l.historyHeader,children:[e.jsx("span",{style:{color:t.status==="delivered"?"#2ecc71":t.status==="failed"?"#e74c3c":"#f39c12"},children:t.status}),e.jsx("span",{children:new Date(t.fired_at).toLocaleString()}),t.duration_ms&&e.jsxs("span",{children:[t.duration_ms,"ms"]})]}),t.error&&e.jsx("div",{style:{color:"#e74c3c",fontSize:"12px"},children:t.error}),a&&e.jsxs("div",{style:l.llmMeta,children:["LLM: ",a.match?"match":"no match"," (",(a.confidence*100).toFixed(0),"%) - ",a.reason]})]},t.id||s)})})]}),e.jsxs("div",{style:l.actions,children:[e.jsx("button",{style:l.cancelBtn,onClick:()=>{A("list"),y(null)},children:"Cancel"}),e.jsx("button",{style:l.saveBtn,onClick:ve,disabled:L||!n.name||!n.agentId||n.type==="cron"&&!!((re=n.config)!=null&&re.runOnce)&&!((oe=n.config)!=null&&oe.runAt)||n.type==="bitbucket"&&(!((ce=n.config)!=null&&ce.workspace)||!((de=n.config)!=null&&de.repoSlug)||!((ue=(pe=n.config)==null?void 0:pe.events)!=null&&ue.length)),children:L?"Saving...":h?"Update":"Create"})]})]})})]})}):null}const l={overlay:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},panel:{background:"#1e1e2e",borderRadius:"12px",width:"680px",maxHeight:"85vh",display:"flex",flexDirection:"column",color:"#cdd6f4",boxShadow:"0 8px 32px rgba(0,0,0,0.4)"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:"1px solid #313244"},title:{margin:0,fontSize:"18px",fontWeight:600},headerActions:{display:"flex",gap:"8px"},content:{overflow:"auto",padding:"16px 20px",flex:1},empty:{textAlign:"center",padding:"40px",color:"#6c7086"},error:{background:"#45252a",color:"#f38ba8",padding:"8px 20px",fontSize:"13px"},tabBar:{display:"flex",gap:"4px",marginBottom:"12px",paddingBottom:"8px",borderBottom:"1px solid #313244",flexWrap:"wrap"},tab:{background:"transparent",border:"1px solid transparent",borderRadius:"6px",padding:"6px 10px",color:"#a6adc8",cursor:"pointer",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px",transition:"background 0.12s, color 0.12s, border-color 0.12s"},tabActive:{background:"#1e3a5f",borderColor:"#89b4fa",color:"#cdd6f4"},tabIcon:{fontSize:"13px",lineHeight:1},tabLabel:{fontWeight:500},tabBadge:{background:"#313244",color:"#a6adc8",borderRadius:"10px",padding:"1px 7px",fontSize:"10px",fontWeight:600,minWidth:"16px",textAlign:"center",lineHeight:"14px"},tabBadgeActive:{background:"#89b4fa",color:"#1e1e2e"},triggerCard:{background:"#181825",borderRadius:"8px",padding:"12px 16px",marginBottom:"8px",borderLeft:"3px solid",cursor:"pointer",transition:"background 0.15s"},cardHeader:{display:"flex",justifyContent:"space-between",alignItems:"center"},cardTitle:{display:"flex",alignItems:"center",gap:"8px",fontWeight:500},typeTag:{background:"#313244",padding:"2px 6px",borderRadius:"4px",fontSize:"11px",textTransform:"uppercase"},matchTag:{background:"#45475a",padding:"2px 6px",borderRadius:"4px",fontSize:"10px",color:"#a6e3a1"},cardActions:{display:"flex",gap:"6px"},cardMeta:{display:"flex",gap:"16px",marginTop:"8px",fontSize:"12px",color:"#6c7086"},form:{display:"flex",flexDirection:"column",gap:"12px"},field:{display:"flex",flexDirection:"column",gap:"4px",flex:1},row:{display:"flex",gap:"12px"},label:{fontSize:"12px",color:"#a6adc8",fontWeight:500},input:{background:"#313244",border:"1px solid #45475a",borderRadius:"6px",padding:"8px 10px",color:"#cdd6f4",fontSize:"13px",outline:"none"},select:{background:"#313244",border:"1px solid #45475a",borderRadius:"6px",padding:"8px 10px",color:"#cdd6f4",fontSize:"13px",outline:"none"},textarea:{background:"#313244",border:"1px solid #45475a",borderRadius:"6px",padding:"8px 10px",color:"#cdd6f4",fontSize:"13px",outline:"none",fontFamily:"monospace",resize:"vertical"},section:{borderTop:"1px solid #313244",paddingTop:"12px"},sectionTitle:{margin:"0 0 8px",fontSize:"14px",fontWeight:600,color:"#a6adc8"},modeSelector:{display:"flex",gap:"8px",marginBottom:"8px"},modeBtn:{flex:1,background:"#313244",border:"1px solid #45475a",borderRadius:"6px",padding:"8px",color:"#cdd6f4",cursor:"pointer",textAlign:"left",display:"flex",flexDirection:"column",gap:"2px",fontSize:"12px"},modeBtnActive:{borderColor:"#89b4fa",background:"#1e3a5f"},modeDesc:{fontSize:"10px",color:"#6c7086"},llmConfig:{background:"#181825",borderRadius:"6px",padding:"12px",display:"flex",flexDirection:"column",gap:"8px"},webhookUrl:{marginTop:"8px"},inlineRow:{display:"flex",gap:"6px",alignItems:"center"},checkboxGrid:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"6px 12px"},checkboxLabel:{display:"flex",alignItems:"center",gap:"6px",fontSize:"12px",color:"#cdd6f4",cursor:"pointer"},checkboxCode:{fontSize:"10px",color:"#6c7086",background:"transparent",padding:0},code:{background:"#313244",padding:"6px 10px",borderRadius:"4px",fontSize:"12px",display:"block",wordBreak:"break-all",color:"#89b4fa"},nextFires:{marginTop:"8px"},nextFireItem:{fontSize:"12px",color:"#a6e3a1",padding:"2px 0"},testBtn:{background:"#89b4fa",border:"none",borderRadius:"6px",padding:"8px 16px",color:"#1e1e2e",fontWeight:600,cursor:"pointer",fontSize:"13px"},testResult:{background:"#181825",borderRadius:"6px",padding:"12px",marginTop:"8px",fontSize:"13px",display:"flex",flexDirection:"column",gap:"6px"},testResultHeader:{fontWeight:700,fontSize:"14px"},llmResult:{display:"flex",flexDirection:"column",gap:"2px"},llmMeta:{fontSize:"11px",color:"#6c7086",marginTop:"2px"},varRow:{fontSize:"12px",padding:"2px 0"},historyList:{display:"flex",flexDirection:"column",gap:"6px",maxHeight:"200px",overflow:"auto"},historyItem:{background:"#181825",borderRadius:"4px",padding:"8px 10px",fontSize:"12px"},historyHeader:{display:"flex",justifyContent:"space-between",alignItems:"center"},actions:{display:"flex",justifyContent:"flex-end",gap:"8px",marginTop:"16px",paddingTop:"12px",borderTop:"1px solid #313244"},addBtn:{background:"#89b4fa",border:"none",borderRadius:"6px",padding:"6px 14px",color:"#1e1e2e",fontWeight:600,cursor:"pointer",fontSize:"13px"},backBtn:{background:"transparent",border:"1px solid #45475a",borderRadius:"6px",padding:"6px 14px",color:"#cdd6f4",cursor:"pointer",fontSize:"13px"},closeBtn:{background:"transparent",border:"none",color:"#6c7086",cursor:"pointer",fontSize:"16px",padding:"4px 8px"},smallBtn:{background:"transparent",border:"1px solid #45475a",borderRadius:"4px",padding:"3px 8px",color:"#cdd6f4",cursor:"pointer",fontSize:"11px"},saveBtn:{background:"#a6e3a1",border:"none",borderRadius:"6px",padding:"8px 20px",color:"#1e1e2e",fontWeight:600,cursor:"pointer",fontSize:"13px"},cancelBtn:{background:"transparent",border:"1px solid #45475a",borderRadius:"6px",padding:"8px 20px",color:"#cdd6f4",cursor:"pointer",fontSize:"13px"}};export{Pe as TriggerManagerPanel,Pe as default};
@@ -1 +1 @@
1
- import{u,r as a,ac as h,j as e}from"./main-D0DfmHvm.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-GtkNAxzd.js";function y({url:r,downloadUrl:o,filename:s}){const{t:i}=u(["terminal","common"]),[t,l]=a.useState(null),[d,c]=a.useState(!1),m=a.useCallback(()=>{h(o,s)},[o,s]);return d?e.jsxs("div",{className:"video-player-error",children:[e.jsx("div",{children:i("terminal:videoPlayer.unsupported",{defaultValue:"This browser cannot play this video format."})}),e.jsx("button",{type:"button",className:"file-viewer-copy-html-btn",onClick:m,children:i("common:buttons.download")})]}):e.jsxs("div",{className:"video-player",children:[e.jsx("video",{className:"video-player-element",src:r,controls:!0,preload:"metadata",playsInline:!0,onError:()=>c(!0),onLoadedMetadata:n=>l({width:n.currentTarget.videoWidth,height:n.currentTarget.videoHeight})},r),t&&t.width>0&&e.jsxs("div",{className:"video-player-meta",children:[t.width,"×",t.height]})]})}export{y as VideoPlayer};
1
+ import{u,r as a,ag as h,j as e}from"./main-C661hDwF.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-GtkNAxzd.js";function y({url:r,downloadUrl:o,filename:s}){const{t:i}=u(["terminal","common"]),[t,l]=a.useState(null),[d,c]=a.useState(!1),m=a.useCallback(()=>{h(o,s)},[o,s]);return d?e.jsxs("div",{className:"video-player-error",children:[e.jsx("div",{children:i("terminal:videoPlayer.unsupported",{defaultValue:"This browser cannot play this video format."})}),e.jsx("button",{type:"button",className:"file-viewer-copy-html-btn",onClick:m,children:i("common:buttons.download")})]}):e.jsxs("div",{className:"video-player",children:[e.jsx("video",{className:"video-player-element",src:r,controls:!0,preload:"metadata",playsInline:!0,onError:()=>c(!0),onLoadedMetadata:n=>l({width:n.currentTarget.videoWidth,height:n.currentTarget.videoHeight})},r),t&&t.width>0&&e.jsxs("div",{className:"video-player-meta",children:[t.width,"×",t.height]})]})}export{y as VideoPlayer};
@@ -1,4 +1,4 @@
1
- import{r as x,c as M,d as P,j as e,L as J}from"./main-D0DfmHvm.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-GtkNAxzd.js";const H=[{id:"intake",name:"Intake",type:"action",description:"Gather CC details from the developer via Slack",action:{type:"agent_task",agentId:"",promptTemplate:`A developer has requested a new CC (Control de Cambios). Here is their message:
1
+ import{r as x,c as M,d as P,j as e,T as J}from"./main-C661hDwF.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-GtkNAxzd.js";const H=[{id:"intake",name:"Intake",type:"action",description:"Gather CC details from the developer via Slack",action:{type:"agent_task",agentId:"",promptTemplate:`A developer has requested a new CC (Control de Cambios). Here is their message:
2
2
  {{trigger.slack.message}}
3
3
  From: {{trigger.slack.user}} (Slack ID: {{trigger.slack.userId}})
4
4
 
@@ -1 +1 @@
1
- import{g as p,r as u,d as a}from"./chunk-MOJQB5TN-b5hDTgD4.js";import{p as f}from"./chunk-JWPE2WC7-JIovo3A4.js";import{_ as n,l as o}from"./mermaid.core-w_DULRGq.js";import{M as c,b as d}from"./cynefin-VYW2F7L2-CqzOybAi.js";import"./main-D0DfmHvm.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-GtkNAxzd.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},I={parser:R,db:a,renderer:u,styles:p};export{I as diagram};
1
+ import{g as p,r as u,d as a}from"./chunk-MOJQB5TN-C0yNMKSS.js";import{p as f}from"./chunk-JWPE2WC7-BUC08AKL.js";import{_ as n,l as o}from"./mermaid.core-Cd-X-VQG.js";import{M as c,b as d}from"./cynefin-VYW2F7L2-DFPaQ9Zf.js";import"./main-C661hDwF.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-GtkNAxzd.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},I={parser:R,db:a,renderer:u,styles:p};export{I as diagram};
@@ -1 +1 @@
1
- import{G as ln,H as un,I as N,J as I,K as J,L as an,M as y,N as tn,O as j,P as _,Q as rn,R as o,S as on,T as sn,V as fn}from"./mermaid.core-w_DULRGq.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,q,O,v,R,K,u){var D=q-l,i=O-h,n=K-v,d=u-R,a=d*D-n*i;if(!(a*a<y))return a=(n*(h-R)-d*(l-v))/a,[l+a*D,h+a*i]}function W(l,h,q,O,v,R,K){var u=l-q,D=h-O,i=(K?R:-R)/j(u*u+D*D),n=i*D,d=-i*u,a=l+n,s=h+d,f=q+n,c=O+d,L=(a+f)/2,t=(s+c)/2,m=f-a,g=c-s,A=m*m+g*g,T=v-R,P=a*c-f*s,E=(g<0?-1:1)*j(on(0,T*T*A-P*P)),G=(P*g-m*E)/A,H=(-P*m-g*E)/A,w=(P*g+m*E)/A,p=(-P*m+g*E)/A,x=G-L,e=H-t,r=w-L,M=p-t;return x*x+e*e>r*r+M*M&&(G=w,H=p),{cx:G,cy:H,x01:-n,y01:-d,x11:G*(v/T-1),y11:H*(v/T-1)}}function hn(){var l=cn,h=yn,q=J(0),O=null,v=gn,R=dn,K=mn,u=null,D=ln(i);function i(){var n,d,a=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=R.apply(this,arguments)-an,L=rn(c-f),t=c>f;if(u||(u=n=D()),s<a&&(d=s,s=a,a=d),!(s>y))u.moveTo(0,0);else if(L>tn-y)u.moveTo(s*N(f),s*I(f)),u.arc(0,0,s,f,c,!t),a>y&&(u.moveTo(a*N(c),a*I(c)),u.arc(0,0,a,c,f,t));else{var m=f,g=c,A=f,T=c,P=L,E=L,G=K.apply(this,arguments)/2,H=G>y&&(O?+O.apply(this,arguments):j(a*a+s*s)),w=_(rn(s-a)/2,+q.apply(this,arguments)),p=w,x=w,e,r;if(H>y){var M=sn(H/a*I(G)),z=sn(H/s*I(G));(P-=M*2)>y?(M*=t?1:-1,A+=M,T-=M):(P=0,A=T=(f+c)/2),(E-=z*2)>y?(z*=t?1:-1,m+=z,g-=z):(E=0,m=g=(f+c)/2)}var Q=s*N(m),V=s*I(m),B=a*N(T),C=a*I(T);if(w>y){var F=s*N(g),U=s*I(g),X=a*N(A),Y=a*I(A),S;if(L<un)if(S=pn(Q,V,X,Y,F,U,B,C)){var Z=Q-S[0],$=V-S[1],k=F-S[0],b=U-S[1],nn=1/I(fn((Z*k+$*b)/(j(Z*Z+$*$)*j(k*k+b*b)))/2),en=j(S[0]*S[0]+S[1]*S[1]);p=_(w,(a-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}E>y?x>y?(e=W(X,Y,Q,V,s,x,t),r=W(F,U,B,C,s,x,t),u.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),u.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(u.moveTo(Q,V),u.arc(0,0,s,m,g,!t)):u.moveTo(Q,V),!(a>y)||!(P>y)?u.lineTo(B,C):p>y?(e=W(B,C,F,U,a,-p,t),r=W(Q,V,X,Y,a,-p,t),u.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,a,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),u.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):u.arc(0,0,a,T,A,t)}if(u.closePath(),n)return u=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +R.apply(this,arguments))/2-un/2;return[N(d)*n,I(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:J(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:J(+n),i):h},i.cornerRadius=function(n){return arguments.length?(q=typeof n=="function"?n:J(+n),i):q},i.padRadius=function(n){return arguments.length?(O=n==null?null:typeof n=="function"?n:J(+n),i):O},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:J(+n),i):v},i.endAngle=function(n){return arguments.length?(R=typeof n=="function"?n:J(+n),i):R},i.padAngle=function(n){return arguments.length?(K=typeof n=="function"?n:J(+n),i):K},i.context=function(n){return arguments.length?(u=n??null,i):u},i}export{hn as d};
1
+ import{G as ln,H as un,I as N,J as I,K as J,L as an,M as y,N as tn,O as j,P as _,Q as rn,R as o,S as on,T as sn,V as fn}from"./mermaid.core-Cd-X-VQG.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,q,O,v,R,K,u){var D=q-l,i=O-h,n=K-v,d=u-R,a=d*D-n*i;if(!(a*a<y))return a=(n*(h-R)-d*(l-v))/a,[l+a*D,h+a*i]}function W(l,h,q,O,v,R,K){var u=l-q,D=h-O,i=(K?R:-R)/j(u*u+D*D),n=i*D,d=-i*u,a=l+n,s=h+d,f=q+n,c=O+d,L=(a+f)/2,t=(s+c)/2,m=f-a,g=c-s,A=m*m+g*g,T=v-R,P=a*c-f*s,E=(g<0?-1:1)*j(on(0,T*T*A-P*P)),G=(P*g-m*E)/A,H=(-P*m-g*E)/A,w=(P*g+m*E)/A,p=(-P*m+g*E)/A,x=G-L,e=H-t,r=w-L,M=p-t;return x*x+e*e>r*r+M*M&&(G=w,H=p),{cx:G,cy:H,x01:-n,y01:-d,x11:G*(v/T-1),y11:H*(v/T-1)}}function hn(){var l=cn,h=yn,q=J(0),O=null,v=gn,R=dn,K=mn,u=null,D=ln(i);function i(){var n,d,a=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=R.apply(this,arguments)-an,L=rn(c-f),t=c>f;if(u||(u=n=D()),s<a&&(d=s,s=a,a=d),!(s>y))u.moveTo(0,0);else if(L>tn-y)u.moveTo(s*N(f),s*I(f)),u.arc(0,0,s,f,c,!t),a>y&&(u.moveTo(a*N(c),a*I(c)),u.arc(0,0,a,c,f,t));else{var m=f,g=c,A=f,T=c,P=L,E=L,G=K.apply(this,arguments)/2,H=G>y&&(O?+O.apply(this,arguments):j(a*a+s*s)),w=_(rn(s-a)/2,+q.apply(this,arguments)),p=w,x=w,e,r;if(H>y){var M=sn(H/a*I(G)),z=sn(H/s*I(G));(P-=M*2)>y?(M*=t?1:-1,A+=M,T-=M):(P=0,A=T=(f+c)/2),(E-=z*2)>y?(z*=t?1:-1,m+=z,g-=z):(E=0,m=g=(f+c)/2)}var Q=s*N(m),V=s*I(m),B=a*N(T),C=a*I(T);if(w>y){var F=s*N(g),U=s*I(g),X=a*N(A),Y=a*I(A),S;if(L<un)if(S=pn(Q,V,X,Y,F,U,B,C)){var Z=Q-S[0],$=V-S[1],k=F-S[0],b=U-S[1],nn=1/I(fn((Z*k+$*b)/(j(Z*Z+$*$)*j(k*k+b*b)))/2),en=j(S[0]*S[0]+S[1]*S[1]);p=_(w,(a-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}E>y?x>y?(e=W(X,Y,Q,V,s,x,t),r=W(F,U,B,C,s,x,t),u.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),u.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(u.moveTo(Q,V),u.arc(0,0,s,m,g,!t)):u.moveTo(Q,V),!(a>y)||!(P>y)?u.lineTo(B,C):p>y?(e=W(B,C,F,U,a,-p,t),r=W(Q,V,X,Y,a,-p,t),u.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,a,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),u.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):u.arc(0,0,a,T,A,t)}if(u.closePath(),n)return u=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +R.apply(this,arguments))/2-un/2;return[N(d)*n,I(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:J(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:J(+n),i):h},i.cornerRadius=function(n){return arguments.length?(q=typeof n=="function"?n:J(+n),i):q},i.padRadius=function(n){return arguments.length?(O=n==null?null:typeof n=="function"?n:J(+n),i):O},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:J(+n),i):v},i.endAngle=function(n){return arguments.length?(R=typeof n=="function"?n:J(+n),i):R},i.padAngle=function(n){return arguments.length?(K=typeof n=="function"?n:J(+n),i):K},i.context=function(n){return arguments.length?(u=n??null,i):u},i}export{hn as d};