@useorgx/openclaw-plugin 0.7.23 → 0.7.24

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 (123) hide show
  1. package/dashboard/dist/assets/{m2smti3F.js → B6VftyY6.js} +1 -1
  2. package/dashboard/dist/assets/B6VftyY6.js.br +0 -0
  3. package/dashboard/dist/assets/B6VftyY6.js.gz +0 -0
  4. package/dashboard/dist/assets/{D-FuHfT8.js → BANQdlC4.js} +1 -1
  5. package/dashboard/dist/assets/BANQdlC4.js.br +0 -0
  6. package/dashboard/dist/assets/BANQdlC4.js.gz +0 -0
  7. package/dashboard/dist/assets/{DDCPrZRt.js → BPL4CL3c.js} +1 -1
  8. package/dashboard/dist/assets/BPL4CL3c.js.br +0 -0
  9. package/dashboard/dist/assets/BPL4CL3c.js.gz +0 -0
  10. package/dashboard/dist/assets/{D0PN5_vY.js → BZCkOZ20.js} +1 -1
  11. package/dashboard/dist/assets/BZCkOZ20.js.br +0 -0
  12. package/dashboard/dist/assets/BZCkOZ20.js.gz +0 -0
  13. package/dashboard/dist/assets/{DNQ-iFO2.js → B_LdOJUa.js} +1 -1
  14. package/dashboard/dist/assets/B_LdOJUa.js.br +0 -0
  15. package/dashboard/dist/assets/B_LdOJUa.js.gz +0 -0
  16. package/dashboard/dist/assets/Bfp-wdwb.css +1 -0
  17. package/dashboard/dist/assets/Bfp-wdwb.css.br +0 -0
  18. package/dashboard/dist/assets/{C1u2SGin.css.gz → Bfp-wdwb.css.gz} +0 -0
  19. package/dashboard/dist/assets/{CZXS5i_5.js → BvFcH_Iy.js} +1 -1
  20. package/dashboard/dist/assets/BvFcH_Iy.js.br +0 -0
  21. package/dashboard/dist/assets/BvFcH_Iy.js.gz +0 -0
  22. package/dashboard/dist/assets/C0i7ABUU.js +212 -0
  23. package/dashboard/dist/assets/C0i7ABUU.js.br +0 -0
  24. package/dashboard/dist/assets/C0i7ABUU.js.gz +0 -0
  25. package/dashboard/dist/assets/CFB0MM7j.js +1 -0
  26. package/dashboard/dist/assets/CFB0MM7j.js.br +0 -0
  27. package/dashboard/dist/assets/CFB0MM7j.js.gz +0 -0
  28. package/dashboard/dist/assets/{OlLPtzdz.js → CQSRb1yu.js} +1 -1
  29. package/dashboard/dist/assets/CQSRb1yu.js.br +0 -0
  30. package/dashboard/dist/assets/CQSRb1yu.js.gz +0 -0
  31. package/dashboard/dist/assets/{CbVWL74-.js → CUoQoSm-.js} +1 -1
  32. package/dashboard/dist/assets/CUoQoSm-.js.br +0 -0
  33. package/dashboard/dist/assets/CUoQoSm-.js.gz +0 -0
  34. package/dashboard/dist/assets/Ckd1R1iE.js +1 -0
  35. package/dashboard/dist/assets/Ckd1R1iE.js.br +0 -0
  36. package/dashboard/dist/assets/Ckd1R1iE.js.gz +0 -0
  37. package/dashboard/dist/assets/{DhPuHPK7.js → CqRNb2EL.js} +1 -1
  38. package/dashboard/dist/assets/CqRNb2EL.js.br +0 -0
  39. package/dashboard/dist/assets/CqRNb2EL.js.gz +0 -0
  40. package/dashboard/dist/assets/{CGJiHCIx.js → DClUc9rw.js} +1 -1
  41. package/dashboard/dist/assets/DClUc9rw.js.br +0 -0
  42. package/dashboard/dist/assets/DClUc9rw.js.gz +0 -0
  43. package/dashboard/dist/assets/DF2PMTwT.js +1 -0
  44. package/dashboard/dist/assets/DF2PMTwT.js.br +0 -0
  45. package/dashboard/dist/assets/DF2PMTwT.js.gz +0 -0
  46. package/dashboard/dist/assets/{RN4M9u9W.js → DJYl7gyA.js} +1 -1
  47. package/dashboard/dist/assets/DJYl7gyA.js.br +0 -0
  48. package/dashboard/dist/assets/DJYl7gyA.js.gz +0 -0
  49. package/dashboard/dist/assets/{BrMXbzQ-.js → DZtNMX0t.js} +1 -1
  50. package/dashboard/dist/assets/DZtNMX0t.js.br +0 -0
  51. package/dashboard/dist/assets/DZtNMX0t.js.gz +0 -0
  52. package/dashboard/dist/assets/{LOFrVoPD.js → DlEa8PI0.js} +1 -1
  53. package/dashboard/dist/assets/DlEa8PI0.js.br +0 -0
  54. package/dashboard/dist/assets/DlEa8PI0.js.gz +0 -0
  55. package/dashboard/dist/assets/M4QxcXjh.js +1 -0
  56. package/dashboard/dist/assets/M4QxcXjh.js.br +0 -0
  57. package/dashboard/dist/assets/M4QxcXjh.js.gz +0 -0
  58. package/dashboard/dist/assets/{nra1yvJX.js → MrW1ixGx.js} +1 -1
  59. package/dashboard/dist/assets/MrW1ixGx.js.br +0 -0
  60. package/dashboard/dist/assets/MrW1ixGx.js.gz +0 -0
  61. package/dashboard/dist/index.html +2 -2
  62. package/dashboard/dist/index.html.br +0 -0
  63. package/dashboard/dist/index.html.gz +0 -0
  64. package/dist/activity-store.js +68 -8
  65. package/dist/contracts/shared-types.d.ts +28 -0
  66. package/dist/http/helpers/auto-continue-engine.js +235 -32
  67. package/dist/http/helpers/triage-mapper.js +285 -6
  68. package/dist/http/helpers/value-utils.d.ts +1 -0
  69. package/dist/http/helpers/value-utils.js +17 -0
  70. package/dist/http/index.js +89 -3
  71. package/dist/http/routes/live-triage.js +6 -1
  72. package/dist/http/routes/mission-control-actions.d.ts +9 -0
  73. package/dist/http/routes/mission-control-actions.js +157 -7
  74. package/dist/http/routes/mission-control-read.d.ts +9 -0
  75. package/dist/http/routes/mission-control-read.js +33 -0
  76. package/dist/stores/sqlite-state.d.ts +1 -1
  77. package/dist/stores/sqlite-state.js +153 -2
  78. package/package.json +1 -1
  79. package/dashboard/dist/assets/9gFmK3Kr.js +0 -1
  80. package/dashboard/dist/assets/9gFmK3Kr.js.br +0 -0
  81. package/dashboard/dist/assets/9gFmK3Kr.js.gz +0 -0
  82. package/dashboard/dist/assets/BrMXbzQ-.js.br +0 -0
  83. package/dashboard/dist/assets/BrMXbzQ-.js.gz +0 -0
  84. package/dashboard/dist/assets/C1u2SGin.css +0 -1
  85. package/dashboard/dist/assets/C1u2SGin.css.br +0 -0
  86. package/dashboard/dist/assets/CGJiHCIx.js.br +0 -0
  87. package/dashboard/dist/assets/CGJiHCIx.js.gz +0 -0
  88. package/dashboard/dist/assets/CSd4rSuU.js +0 -212
  89. package/dashboard/dist/assets/CSd4rSuU.js.br +0 -0
  90. package/dashboard/dist/assets/CSd4rSuU.js.gz +0 -0
  91. package/dashboard/dist/assets/CZXS5i_5.js.br +0 -0
  92. package/dashboard/dist/assets/CZXS5i_5.js.gz +0 -0
  93. package/dashboard/dist/assets/CbVWL74-.js.br +0 -0
  94. package/dashboard/dist/assets/CbVWL74-.js.gz +0 -0
  95. package/dashboard/dist/assets/D-FuHfT8.js.br +0 -0
  96. package/dashboard/dist/assets/D-FuHfT8.js.gz +0 -0
  97. package/dashboard/dist/assets/D0PN5_vY.js.br +0 -0
  98. package/dashboard/dist/assets/D0PN5_vY.js.gz +0 -0
  99. package/dashboard/dist/assets/DDCPrZRt.js.br +0 -0
  100. package/dashboard/dist/assets/DDCPrZRt.js.gz +0 -0
  101. package/dashboard/dist/assets/DNQ-iFO2.js.br +0 -0
  102. package/dashboard/dist/assets/DNQ-iFO2.js.gz +0 -0
  103. package/dashboard/dist/assets/DhPuHPK7.js.br +0 -0
  104. package/dashboard/dist/assets/DhPuHPK7.js.gz +0 -0
  105. package/dashboard/dist/assets/Dhz7qPtn.js +0 -1
  106. package/dashboard/dist/assets/Dhz7qPtn.js.br +0 -0
  107. package/dashboard/dist/assets/Dhz7qPtn.js.gz +0 -0
  108. package/dashboard/dist/assets/LOFrVoPD.js.br +0 -0
  109. package/dashboard/dist/assets/LOFrVoPD.js.gz +0 -0
  110. package/dashboard/dist/assets/OlLPtzdz.js.br +0 -0
  111. package/dashboard/dist/assets/OlLPtzdz.js.gz +0 -0
  112. package/dashboard/dist/assets/RN4M9u9W.js.br +0 -0
  113. package/dashboard/dist/assets/RN4M9u9W.js.gz +0 -0
  114. package/dashboard/dist/assets/VCHu272d.js +0 -1
  115. package/dashboard/dist/assets/VCHu272d.js.br +0 -0
  116. package/dashboard/dist/assets/VCHu272d.js.gz +0 -0
  117. package/dashboard/dist/assets/m2smti3F.js.br +0 -0
  118. package/dashboard/dist/assets/m2smti3F.js.gz +0 -0
  119. package/dashboard/dist/assets/nra1yvJX.js.br +0 -0
  120. package/dashboard/dist/assets/nra1yvJX.js.gz +0 -0
  121. package/dashboard/dist/assets/qLX6NZ-J.js +0 -1
  122. package/dashboard/dist/assets/qLX6NZ-J.js.br +0 -0
  123. package/dashboard/dist/assets/qLX6NZ-J.js.gz +0 -0
@@ -1 +0,0 @@
1
- import{r as x,j as e}from"./Dj2k1r16.js";import{A as w,m as v}from"./eeHXe_OQ.js";function k(s){switch(s){case"decision_required":return"Decision required";case"blocked_intervention":return"Blocked — needs intervention";case"review_required":return"Review required";case"failure_diagnostic":return"Failure diagnostic";default:return s}}function g(s){switch(s){case"critical":return"#FF6B6B";case"high":return"#F5B700";case"medium":return"#0AD4C4";default:return"#8B8FA3"}}function b({children:s}){return e.jsx("h4",{className:"text-micro font-semibold uppercase tracking-wider text-muted mb-1.5",children:s})}function C({item:s}){const t=s.proofBundle;return t.artifactRefs.length>0||t.fileChanges.length>0||t.prRefs.length>0||t.logRefs.length>0||t.decisionRefs.length>0?e.jsxs("div",{children:[e.jsx(b,{children:"Proof"}),e.jsxs("div",{className:"space-y-1",children:[t.prRefs.map((r,n)=>e.jsx(p,{icon:"pr",label:r},`pr-${n}`)),t.fileChanges.map((r,n)=>e.jsx(p,{icon:"file",label:r},`file-${n}`)),t.artifactRefs.map((r,n)=>e.jsx(p,{icon:"artifact",label:r},`art-${n}`)),t.logRefs.map((r,n)=>e.jsx(p,{icon:"log",label:r},`log-${n}`)),t.decisionRefs.map((r,n)=>e.jsx(p,{icon:"decision",label:r},`dec-${n}`))]})]}):null}function p({icon:s,label:t}){const o=s==="pr"?"⎇":s==="file"?"◇":s==="log"?"▸":s==="decision"?"◈":"▪";return e.jsxs("div",{className:"flex items-center gap-2 rounded bg-white/[0.03] px-2 py-1 text-caption text-secondary",children:[e.jsx("span",{className:"text-muted flex-shrink-0 w-4 text-center",children:o}),e.jsx("span",{className:"truncate",children:t})]})}function N({item:s}){const{impact:t}=s;return t.initiativeCount===0&&t.workstreamCount===0&&t.downstreamBlockedCount===0?null:e.jsxs("div",{children:[e.jsx(b,{children:"Impact if ignored"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.initiativeCount>0&&e.jsx(j,{label:`${t.initiativeCount} initiative${t.initiativeCount>1?"s":""}`}),t.workstreamCount>0&&e.jsx(j,{label:`${t.workstreamCount} workstream${t.workstreamCount>1?"s":""}`}),t.downstreamBlockedCount>0&&e.jsx(j,{label:`${t.downstreamBlockedCount} blocked downstream`,tone:"red"})]})]})}function A({item:s}){const t=s.intervention;return!t||!(!!t.blockerReason||!!t.waitingOn||!!t.requiredAction||!!t.requiredActor||!!t.errorCode||!!t.errorCategory||typeof t.retryable=="boolean"||Array.isArray(t.suggestedActions)&&t.suggestedActions.length>0||Array.isArray(t.nextActions)&&t.nextActions.length>0||typeof t.taskUpdateCount=="number"||typeof t.milestoneUpdateCount=="number")?null:e.jsxs("div",{children:[e.jsx(b,{children:"Intervention brief"}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-white/[0.08] bg-white/[0.02] px-3 py-2.5",children:[t.blockerReason&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-wider text-muted",children:"Blocker"}),e.jsx("p",{className:"text-caption text-primary",children:t.blockerReason})]}),t.requiredAction&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-wider text-muted",children:"Required action"}),e.jsx("p",{className:"text-caption text-[#7AEDE5]",children:t.requiredAction})]}),t.waitingOn&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-wider text-muted",children:"Waiting on"}),e.jsx("p",{className:"text-caption text-secondary",children:t.waitingOn})]}),(t.errorCode||t.errorCategory||typeof t.retryable=="boolean")&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.errorCode&&e.jsxs("span",{className:"rounded bg-white/[0.06] px-1.5 py-0.5 text-micro text-secondary",children:["Error: ",t.errorCode]}),t.errorCategory&&e.jsxs("span",{className:"rounded bg-white/[0.06] px-1.5 py-0.5 text-micro text-secondary",children:["Category: ",t.errorCategory]}),typeof t.retryable=="boolean"&&e.jsx("span",{className:"rounded bg-white/[0.06] px-1.5 py-0.5 text-micro text-secondary",children:t.retryable?"Retryable":"Non-retryable"})]}),((t.taskUpdateCount??0)>0||(t.milestoneUpdateCount??0)>0)&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[(t.taskUpdateCount??0)>0&&e.jsxs("span",{className:"rounded bg-[#0AD4C4]/12 px-1.5 py-0.5 text-micro text-[#7AEDE5]",children:[t.taskUpdateCount," task update",t.taskUpdateCount===1?"":"s"]}),(t.milestoneUpdateCount??0)>0&&e.jsxs("span",{className:"rounded bg-[#0AD4C4]/12 px-1.5 py-0.5 text-micro text-[#7AEDE5]",children:[t.milestoneUpdateCount," milestone update",t.milestoneUpdateCount===1?"":"s"]})]}),Array.isArray(t.suggestedActions)&&t.suggestedActions.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-wider text-muted",children:"Suggested actions"}),e.jsx("ul",{className:"mt-1 space-y-0.5",children:t.suggestedActions.slice(0,4).map(r=>e.jsxs("li",{className:"text-caption text-secondary",children:["- ",r]},r))})]}),Array.isArray(t.nextActions)&&t.nextActions.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-wider text-muted",children:"Next up"}),e.jsx("ul",{className:"mt-1 space-y-0.5",children:t.nextActions.slice(0,4).map(r=>e.jsxs("li",{className:"text-caption text-secondary",children:["- ",r]},r))})]})]})]})}function j({label:s,tone:t="amber"}){const o=t==="red"?"bg-[#FF6B6B]/14":"bg-[#F5B700]/14",r=t==="red"?"text-[#FFA8A8]":"text-[#FFE7A8]";return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-micro font-medium ${o} ${r}`,children:s})}function B({triageAction:s,onPerform:t,isActing:o}){const[r,n]=x.useState(!1),[d,m]=x.useState(""),f=s.action==="approve"||s.action==="autofix",h=s.action==="dismiss",c=f?"bg-[#0AD4C4]/20 text-[#7AEDE5] hover:bg-[#0AD4C4]/30":h?"bg-[#FF6B6B]/14 text-[#FFA8A8] hover:bg-[#FF6B6B]/20":"bg-white/[0.08] text-secondary hover:bg-white/[0.12]";return s.available?s.requiresNote&&r?e.jsxs("div",{className:"flex flex-col gap-1.5 w-full",children:[e.jsx("textarea",{value:d,onChange:u=>m(u.target.value),placeholder:"Add a note...",className:"w-full rounded-lg border border-subtle bg-white/[0.04] px-2.5 py-1.5 text-caption text-primary placeholder:text-muted resize-none",rows:2}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>t(s.action,d,s.optionId??void 0),disabled:o,className:`rounded-lg px-3 py-1 text-caption font-medium transition-colors disabled:opacity-40 ${c}`,children:"Confirm"}),e.jsx("button",{type:"button",onClick:()=>n(!1),className:"text-caption text-muted hover:text-secondary",children:"Cancel"})]})]}):e.jsxs("button",{type:"button",onClick:()=>{s.requiresNote?n(!0):t(s.action,void 0,s.optionId??void 0)},disabled:o,className:`rounded-lg px-3 py-1.5 text-caption font-medium transition-colors disabled:opacity-40 ${c}`,title:s.consequences,children:[e.jsx("span",{children:s.label}),e.jsxs("span",{className:"ml-1 text-micro opacity-60",children:["— ",s.consequences]})]}):e.jsx("button",{type:"button",disabled:!0,className:"rounded-lg px-3 py-1.5 text-caption font-medium opacity-30 bg-white/[0.06] text-muted cursor-not-allowed",title:"Not available",children:s.label})}function D({item:s}){const[t,o]=x.useState(!1),r=[["ID",s.id],["Kind",s.kind],["Dedupe key",s.dedupeKey],["Source system",s.sourceSystem],["Conflict source",s.conflictSource],["Agent ID",s.agentId],["Source decision",s.sourceDecisionId],["Source activity",s.sourceActivityId],["First seen",s.firstSeenAt],["Last seen",s.lastSeenAt],["Created",s.createdAt]].filter(([,n])=>n!=null);return e.jsxs("div",{className:"border-t border-subtle pt-2",children:[e.jsxs("button",{type:"button",onClick:()=>o(n=>!n),className:"flex w-full items-center justify-between text-micro font-semibold uppercase tracking-wider text-muted hover:text-secondary transition-colors",children:[e.jsx("span",{children:"Technical details"}),e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:`transition-transform ${t?"rotate-180":""}`,children:e.jsx("path",{d:"m6 9 6 6 6-6"})})]}),t&&e.jsx("div",{className:"mt-2 space-y-0.5",children:r.map(([n,d])=>e.jsxs("div",{className:"flex gap-2 text-micro",children:[e.jsx("span",{className:"text-muted w-28 flex-shrink-0",children:n}),e.jsx("span",{className:"text-secondary truncate",children:d})]},n))})]})}function I({item:s,actions:t,onClose:o,onNavigate:r,currentIndex:n,totalCount:d,decisions:m}){const f=x.useRef(null),h=x.useCallback(i=>{if(!s)return;const a=s.actionContract.find(l=>l.action===i&&typeof l.optionId=="string"&&l.optionId.trim().length>0);return typeof(a==null?void 0:a.optionId)=="string"?a.optionId:void 0},[s]);x.useEffect(()=>{if(!s)return;const i=a=>{var y;const l=(y=a.target)==null?void 0:y.tagName;if(!(l==="INPUT"||l==="TEXTAREA"))switch(a.key){case"j":case"ArrowRight":a.preventDefault(),r==null||r(1);break;case"k":case"ArrowLeft":a.preventDefault(),r==null||r(-1);break;case"a":a.preventDefault(),c("approve");break;case"d":a.preventDefault(),c("dismiss");break;case"r":a.preventDefault(),c("retry");break;case"s":a.preventDefault(),c("snooze");break;case"Escape":a.preventDefault(),o();break}};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[s,r,o]);const c=x.useCallback(async(i,a,l)=>{if(s)try{await t.performAction(s.id,i,{note:a,optionId:l??h(i)}),r==null||r(1)}catch{}},[s,t,r,h]);if(!s)return null;const u=s.sourceDecisionId&&Array.isArray(m)?m.find(i=>i.id===s.sourceDecisionId)??null:null;return e.jsx(w,{mode:"wait",children:e.jsxs(v.div,{ref:f,initial:{opacity:0,x:44,scale:.985},animate:{opacity:1,x:0,scale:1},exit:{opacity:0,x:-44,scale:.985},transition:{duration:.28},className:"flex h-full min-h-0 flex-col overflow-y-auto px-5 pb-5 pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>r(-1),className:"rounded p-1 text-muted hover:text-secondary hover:bg-white/[0.06] transition-colors",title:"Previous (k)",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"m15 18-6-6 6-6"})})}),e.jsx("button",{type:"button",onClick:()=>r(1),className:"rounded p-1 text-muted hover:text-secondary hover:bg-white/[0.06] transition-colors",title:"Next (j)",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"m9 18 6-6-6-6"})})})]}),n!=null&&d!=null&&e.jsxs("span",{className:"text-micro text-muted tabular-nums",children:[n+1," of ",d]})]}),e.jsx("button",{type:"button",onClick:o,className:"rounded p-1 text-muted hover:text-secondary hover:bg-white/[0.06] transition-colors",title:"Close (Esc)",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})})]}),(s.initiativeTitle||s.workstreamTitle)&&e.jsx("p",{className:"text-micro text-muted mb-1",children:[s.initiativeTitle,s.workstreamTitle,s.taskTitle].filter(Boolean).join(" › ")}),e.jsxs("div",{className:"mb-4 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("h3",{className:"text-heading font-semibold text-primary",children:s.title}),e.jsx("span",{className:"flex-shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider",style:{backgroundColor:`${g(s.severity)}20`,color:g(s.severity)},children:k(s.kind)})]}),e.jsxs("div",{className:"flex items-center gap-2 text-caption text-secondary",children:[s.agentId&&e.jsx("span",{className:"rounded bg-white/[0.06] px-1.5 py-0.5 text-micro font-medium text-secondary",children:s.agentId}),s.occurrenceCount>1&&e.jsxs("span",{className:"text-micro text-muted",children:["x",s.occurrenceCount," occurrences"]})]}),e.jsx("p",{className:"text-body text-secondary leading-relaxed",children:s.summary}),(u==null?void 0:u.recommendedAction)&&e.jsxs("p",{className:"text-caption text-[#7AEDE5]",children:["Recommended: ",u.recommendedAction]})]}),e.jsx("div",{className:"h-px bg-gradient-to-r from-transparent via-white/[0.06] to-transparent mb-4"}),e.jsxs("div",{className:"space-y-4 mb-4",children:[e.jsx(A,{item:s}),e.jsx(C,{item:s})]}),e.jsx("div",{className:"mb-4",children:e.jsx(N,{item:s})}),e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"space-y-1.5",children:s.actionContract.map(i=>e.jsx(B,{triageAction:i,onPerform:c,isActing:t.isActing},i.action))}),s.recommendedAction&&e.jsxs("p",{className:"mt-2 text-micro text-[#7AEDE5]",children:["Recommended: ",s.recommendedAction]})]}),e.jsx(D,{item:s}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-x-3 gap-y-1 text-micro text-muted opacity-60",children:[e.jsx("span",{children:"j/k nav"}),e.jsx("span",{children:"a approve"}),e.jsx("span",{children:"d dismiss"}),e.jsx("span",{children:"r retry"}),e.jsx("span",{children:"s snooze"}),e.jsx("span",{children:"esc close"})]})]},s.id)})}export{I as TriageDetailModal};
@@ -1 +0,0 @@
1
- import{j as e,r as b}from"./Dj2k1r16.js";import{a7 as fe,f as p,Q as be,a8 as se,a9 as ke,z as ye,aa as ve,A as je,n as we,D as A,ab as Ne,ac as Ie,ad as Te,w as F,E as ne,T as Ce}from"./CSd4rSuU.js";import{E as Se}from"./DhPuHPK7.js";import{m as h,A as Ae}from"./eeHXe_OQ.js";import{M as De}from"./By0MIBj_.js";import{f as Ee,g as ae,w as re}from"./CbVWL74-.js";import"./DMKyYAtD.js";import"./cX2e-TLi.js";import"./BjK42gtU.js";import"./BV0BcV1u.js";function $e(n){if(!n)return{label:"artifact",color:"rgba(255,255,255,0.4)"};const s=n.toLowerCase();return s.includes("code")||s.includes("pr")||s.includes("pull_request")||s.includes("commit")?{label:"code",color:p.lime}:s.includes("doc")||s.includes("spec")||s.includes("document")||s.includes("proposal")?{label:"doc",color:p.teal}:s.includes("design")||s.includes("a11y")||s.includes("accessibility")?{label:"design",color:p.iris}:s.includes("test")||s.includes("experiment")?{label:"test",color:p.cyan}:s.includes("config")||s.includes("decision")||s.includes("routing")||s.includes("runbook")||s.includes("incident")?{label:"config",color:p.amber}:s.includes("marketing")||s.includes("qualification")||s.includes("sales")?{label:s.includes("marketing")?"marketing":"sales",color:p.teal}:{label:n.slice(0,12),color:"rgba(255,255,255,0.5)"}}function Re({artifacts:n,onOpenArtifact:s,className:o}){return n.length===0?null:e.jsxs("div",{className:o,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"section-kicker font-semibold",children:"Artifacts"}),e.jsx("span",{className:"chip text-micro",children:n.length})]}),e.jsx(h.div,{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",initial:"hidden",animate:"visible",variants:{visible:{transition:{staggerChildren:.04}}},children:n.map((m,v)=>{const g=$e(m.type);return e.jsxs(h.button,{type:"button",onClick:()=>s==null?void 0:s(m),className:"subsection-shell rounded-xl px-3.5 py-3 text-left hover-lift",variants:fe,custom:v,children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"rounded-full px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-[0.08em]",style:{color:g.color,backgroundColor:`${g.color}18`,border:`1px solid ${g.color}30`},children:g.label})}),e.jsx("p",{className:"mt-1.5 text-body font-medium text-white truncate",children:m.title})]},m.id??`artifact-${v}`)})})]})}function z(n){return n.toLowerCase().trim().replace(/\.\s*$/,"").replace(/\s+/g," ")}function Fe(n){var w,N,I;const s=new Set,o=((w=n.statusExplainer)==null?void 0:w.trim())||null;o&&s.add(z(o));const m=((N=n.summary)==null?void 0:N.trim())||null,v=m!=null&&!s.has(z(m));m&&s.add(z(m));const g=((I=n.lastEventSummary)==null?void 0:I.trim())||null,D=g!=null&&!s.has(z(g));return{outcome:o,whatHappened:v?m:null,lastActivity:D?g:null}}function _e(n){const s=[];if(n.lifecycleState==="completed"&&n.artifactCount===0)s.push("Completed but produced no artifacts."),s.push("This may indicate the agent finished analysis without outputting structured results."),n.statusExplainer&&s.push(n.statusExplainer);else if(n.lifecycleState==="completed"&&n.artifactCount>0){s.push(`Completed with ${n.artifactCount} artifact${n.artifactCount>1?"s":""}.`);const o=n.artifacts??[];for(const m of o.slice(0,3))s.push(`· ${m.title} (${m.type})`);o.length>3&&s.push(`· and ${o.length-3} more`)}else n.lifecycleState==="failed"?(s.push("Failed during execution."),n.statusExplainer&&s.push(n.statusExplainer)):n.lifecycleState==="awaiting_input"&&(s.push("Waiting for input before continuing."),n.statusExplainer&&s.push(n.statusExplainer));return s.length>0?s.join(" "):null}function _(n){return n===0?p.red:n===1?p.amber:n===2?p.iris:"rgba(255,255,255,0.5)"}function O(n){return n===0?"P0":n===1?"P1":n===2?"P2":n===3?"P3":""}function Be(n){switch(n){case"high":return{filled:5,color:p.lime};case"medium":return{filled:3,color:p.amber};case"low":return{filled:1,color:p.red};default:return{filled:0,color:p.iris}}}async function qe(n){const s={};if(n.runId&&(s.runId=n.runId),n.sliceRunId&&(s.sliceRunId=n.sliceRunId),n.sessionId&&(s.sessionId=n.sessionId),Object.keys(s).length===0)throw new Error("No run identifier available for terminal open.");const o=await fetch("/orgx/api/live/terminal/open",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!o.ok){const m=await o.json().catch(()=>({}));throw new Error(m.error??`Terminal open failed (${o.status})`)}}const Pe={hidden:{opacity:0,y:-4},visible:n=>({opacity:1,y:0,transition:{duration:.28,delay:n*.04,ease:[.16,1,.3,1]}}),exit:{opacity:0,transition:{duration:.18}}},j={hidden:{opacity:0,y:8},visible:n=>({opacity:1,y:0,transition:{duration:.22,delay:n*.04,ease:we.easingStandard}}),exit:{opacity:0,transition:{duration:.18}}};function le(n){var v,g,D,w,N,I,$,E;if(n.source==="queue"){const{item:r,linkedSliceRun:d}=n;return{initiativeId:r.initiativeId,initiativeTitle:A(r.initiativeTitle),initiativeStatus:r.initiativeStatus,workstreamId:r.workstreamId,workstreamTitle:A(r.workstreamTitle),workstreamStatus:r.workstreamStatus,nextTaskTitle:r.nextTaskTitle?A(r.nextTaskTitle):null,nextTaskPriority:r.nextTaskPriority,nextTaskDueAt:r.nextTaskDueAt,agentId:r.runnerAgentId,agentName:r.runnerAgentName,agentSource:r.runnerSource,queueState:r.queueState,blockReason:r.blockReason?A(r.blockReason):null,sliceScope:r.sliceScope??null,sliceTaskCount:typeof r.sliceTaskCount=="number"&&Number.isFinite(r.sliceTaskCount)?Math.max(0,Math.floor(r.sliceTaskCount)):((v=r.sliceTaskIds)==null?void 0:v.length)??null,autoContinue:r.autoContinue,milestoneBreakdown:r.milestoneBreakdown??null,sliceRun:d,sessionId:null,runId:(d==null?void 0:d.runId)??null}}if(n.source==="in_progress"){const{row:r,sliceRun:d}=n;return{initiativeId:r.initiativeId,initiativeTitle:r.initiativeTitle?A(r.initiativeTitle):null,initiativeStatus:null,workstreamId:r.workstreamId,workstreamTitle:r.workstreamTitle?A(r.workstreamTitle):r.title,workstreamStatus:r.status,nextTaskTitle:null,nextTaskPriority:null,nextTaskDueAt:null,agentId:((g=r.session)==null?void 0:g.agentId)??null,agentName:((D=r.session)==null?void 0:D.agentName)??"OrgX",agentSource:null,queueState:r.status==="running"?"running":"queued",blockReason:null,sliceScope:(d==null?void 0:d.scope)??null,sliceTaskCount:typeof((w=d==null?void 0:d.scopeProgress)==null?void 0:w.totalTasks)=="number"?Math.max(0,Math.floor(d.scopeProgress.totalTasks-d.scopeProgress.completedTasks)):((N=d==null?void 0:d.taskIds)==null?void 0:N.length)??null,autoContinue:null,milestoneBreakdown:null,sliceRun:d,sessionId:((I=r.session)==null?void 0:I.id)??null,runId:r.runId}}const{sliceRun:s}=n,o=Array.isArray(s.blockers)&&s.blockers.length>0?s.blockers[0]:null,m=s.sourceClient?s.sourceClient.charAt(0).toUpperCase()+s.sourceClient.slice(1):"OrgX";return{initiativeId:s.initiativeId,initiativeTitle:null,initiativeStatus:null,workstreamId:s.workstreamId,workstreamTitle:s.workstreamTitle?A(s.workstreamTitle):"Work slice",workstreamStatus:s.status,nextTaskTitle:null,nextTaskPriority:null,nextTaskDueAt:null,agentId:null,agentName:m,agentSource:s.sourceClient,queueState:s.status==="needs_review"?"completed":"blocked",blockReason:(o==null?void 0:o.reason)??(s.status==="failed"&&s.statusExplainer||null),sliceScope:s.scope??null,sliceTaskCount:typeof(($=s.scopeProgress)==null?void 0:$.totalTasks)=="number"?Math.max(0,Math.floor(s.scopeProgress.totalTasks-s.scopeProgress.completedTasks)):((E=s.taskIds)==null?void 0:E.length)??null,autoContinue:null,milestoneBreakdown:null,sliceRun:s,sessionId:null,runId:s.runId}}function S(){return e.jsx("div",{className:"h-px bg-gradient-to-r from-transparent via-white/[0.06] to-transparent"})}function Ze({target:n,onClose:s,onPlayWorkstream:o,onStartAutoContinue:m,onMoveWorkstream:v,onRemoveFromQueue:g,onOpenSession:D,onFocusRunId:w,onOpenInitiative:N,onReviewActivity:I,onOpenDecisions:$,onAcceptSlice:E,onRejectSlice:r,initiatives:d=[]}){var ee,te,ie;const B=n!==null,[oe,K]=b.useState(!1),[Me,H]=b.useState(null),[f,R]=b.useState(null),[q,P]=b.useState(""),[M,T]=b.useState(null),G=b.useRef(null),U=b.useCallback(a=>{if(n&&(a.metaKey||a.ctrlKey)&&a.key==="Enter"){a.preventDefault();const l=le(n);l.initiativeId&&l.workstreamId&&(o==null||o(l.initiativeId,l.workstreamId,l.agentId??void 0))}},[n,o]);b.useEffect(()=>{if(B)return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[B,U]),b.useEffect(()=>{B||(H(null),K(!1),R(null),P(""),T(null))},[B]),b.useEffect(()=>{f&&requestAnimationFrame(()=>{var a;(a=G.current)==null||a.focus()})},[f]);const ce=b.useMemo(()=>{const a=new Map;for(const l of d)l.id&&a.set(l.id,l.name??l.id);return a},[d]);if(!n)return null;const i=le(n);!i.initiativeTitle&&i.initiativeId&&(i.initiativeTitle=ce.get(i.initiativeId)??null);const t=i.sliceRun,k=be({sessionStatus:i.queueState,sessionPhase:i.workstreamStatus,sliceStatus:(t==null?void 0:t.status)??i.workstreamStatus,activityStatus:(t==null?void 0:t.runtimeState)??i.workstreamStatus??i.queueState,stopReason:i.queueState==="blocked"?"blocked":null,decisionRequired:((t==null?void 0:t.blockingDecisionCount)??0)>0,blockingDecisionCount:(t==null?void 0:t.blockingDecisionCount)??0,nonBlockingDecisionCount:Math.max(0,((t==null?void 0:t.decisionCount)??0)-((t==null?void 0:t.blockingDecisionCount)??0)),blockerCount:i.blockReason?1:0,blockerReason:i.blockReason}),de=k.status==="completed"?"text-lime border-lime/30 bg-lime/[0.12]":k.status==="failed"?"text-red-200 border-red-400/30 bg-red-500/[0.12]":k.status==="needs_attention"?"text-amber-200 border-amber-400/30 bg-amber-500/[0.12]":k.status==="in_progress"?"text-teal-200 border-teal-400/30 bg-teal-500/[0.12]":"text-secondary border-white/[0.14] bg-white/[0.04]",ue=k.tone==="critical"?"border-red-400/24 bg-red-500/[0.08]":k.tone==="warning"?"border-amber-400/24 bg-amber-500/[0.08]":k.tone==="positive"?"border-lime/24 bg-lime/[0.08]":"border-subtle bg-white/[0.02]",me=[...i.initiativeTitle?[{label:i.initiativeTitle,onClick:i.initiativeId?()=>N==null?void 0:N(i.initiativeId):void 0}]:[],{label:i.workstreamTitle}],Z=k.status==="in_progress",xe=!!(i.initiativeId&&i.workstreamId&&!Z),W=k.nextAction??(n.source==="needs_input"&&t?t.primaryAction==="resolve_decision"?"Resolve decision":t.primaryAction==="open_artifact"?"Open result":"Review activity":null),V=(()=>{const a=(t==null?void 0:t.primaryAction)??null;return!a||a==="none"?null:a==="resolve_decision"?"resolve_decision":a==="open_artifact"||a==="review_output"?"review":a==="retry_slice"?"start":null})(),Y="ring-1 ring-lime/40 shadow-[0_0_8px_rgba(191,255,0,0.15)]",pe=b.useCallback(async a=>{try{H(null),K(!0),await qe(a)}catch(l){H(l instanceof Error?l.message:"Unable to open terminal")}finally{K(!1)}},[]),Q=b.useMemo(()=>i.sessionId?{sessionId:i.sessionId,runId:i.runId,sliceRunId:(t==null?void 0:t.sliceRunId)??null}:t!=null&&t.runId||t!=null&&t.sliceRunId?{runId:t.runId??null,sliceRunId:t.sliceRunId??null}:i.runId?{runId:i.runId,sliceRunId:(t==null?void 0:t.sliceRunId)??null}:null,[i.sessionId,i.runId,t]),he=Q!==null,J=b.useMemo(()=>t!=null&&t.scopeProgress?se({initiativeId:i.initiativeId,initiativeTitle:i.initiativeTitle,workstreamId:i.workstreamId,workstreamTitle:i.workstreamTitle,taskIds:t==null?void 0:t.taskIds,milestoneIds:t==null?void 0:t.milestoneIds,scopeProgress:t.scopeProgress,status:(t==null?void 0:t.status)??i.queueState,agentName:i.agentName,agentId:i.agentId}):i.milestoneBreakdown&&i.milestoneBreakdown.length>0?ke(i.milestoneBreakdown):se({initiativeId:i.initiativeId,initiativeTitle:i.initiativeTitle,workstreamId:i.workstreamId,workstreamTitle:i.workstreamTitle,taskIds:t==null?void 0:t.taskIds,milestoneIds:t==null?void 0:t.milestoneIds,scopeProgress:null,status:(t==null?void 0:t.status)??i.queueState,agentName:i.agentName,agentId:i.agentId}),[i.initiativeId,i.initiativeTitle,i.workstreamId,i.workstreamTitle,t,i.queueState,i.agentName,i.agentId,i.milestoneBreakdown]),L=n.source==="needs_input"&&(t==null?void 0:t.status)==="needs_review",X=b.useCallback(async()=>{if(!t||!f)return;const a=q.trim(),l=t.runId??t.sliceRunId;if(f==="accept")try{T("Accepting…");const u=a?`Accepted: ${a}`:"Accepted from dashboard",x=await fetch(`/orgx/api/runs/${encodeURIComponent(l)}/actions/complete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:u})});if(!x.ok){const C=await x.json().catch(()=>null);T(`Error: ${(C==null?void 0:C.error)??(C==null?void 0:C.message)??x.status}`);return}T("Accepted!");try{E==null||E(t,a||void 0)}catch{}setTimeout(()=>s(),600)}catch(u){T(`Failed: ${u instanceof Error?u.message:"network error"}`)}else if(f==="reject"&&a)try{T("Sending feedback…");const u=await fetch(`/orgx/api/entities/run/${encodeURIComponent(l)}/comments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:a,commentType:"review_feedback",severity:"warn",tags:["changes_requested"]})});if(!u.ok){const x=await u.json().catch(()=>null);T(`Error: ${(x==null?void 0:x.error)??(x==null?void 0:x.message)??u.status}`);return}T("Feedback sent!");try{r==null||r(t,a)}catch{}R(null),P("")}catch(u){T(`Failed: ${u instanceof Error?u.message:"network error"}`)}},[t,f,q,E,r,s]),ge=e.jsxs("div",{className:"space-y-2",children:[M&&e.jsx("div",{className:`flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[11px] font-medium ${M.startsWith("Error")||M.startsWith("Failed")?"bg-[#FF6B88]/10 text-[#FF6B88]":M.includes("…")?"bg-white/[0.04] text-white/60 animate-pulse":"bg-lime/10 text-lime"}`,children:M}),e.jsx(Ae,{children:f&&e.jsx(h.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:e.jsxs("div",{className:"pb-2",children:[e.jsx("textarea",{ref:G,value:q,onChange:a=>P(a.target.value),onKeyDown:a=>{(a.metaKey||a.ctrlKey)&&a.key==="Enter"&&(a.preventDefault(),X()),a.key==="Escape"&&(a.preventDefault(),R(null),P(""))},placeholder:f==="accept"?"Optional note...":"What needs to change?",className:"w-full resize-none rounded-lg border border-white/[0.08] bg-white/[0.03] px-3 py-2 text-[13px] text-white/80 outline-none placeholder:text-white/25 focus:border-white/15 transition-colors",rows:2}),e.jsxs("div",{className:"mt-1.5 flex items-center justify-between",children:[e.jsx("button",{type:"button",onClick:()=>{R(null),P("")},className:"text-[11px] text-white/30 transition-colors hover:text-white/50",children:"Cancel"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-micro text-white/20",children:f==="reject"&&!q.trim()?"Note required":"⌘Enter to confirm"}),e.jsx("button",{type:"button",onClick:X,disabled:f==="reject"&&!q.trim(),className:`inline-flex h-7 items-center gap-1 rounded-md px-3 text-[11px] font-semibold transition-colors disabled:opacity-30 ${f==="accept"?"bg-lime/12 text-lime hover:bg-lime/20":"bg-[#FF6B88]/12 text-[#FF6B88] hover:bg-[#FF6B88]/20"}`,children:f==="accept"?"Confirm accept":"Request changes"})]})]})]})})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[n.source==="queue"&&i.initiativeId&&i.workstreamId&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>{g==null||g(i.initiativeId,i.workstreamId),s()},className:"rounded-md px-2.5 py-1.5 text-[12px] font-medium text-[#FF6B88]/70 transition-colors hover:bg-[#FF6B88]/[0.08] hover:text-[#FF6B88]",children:"Remove"}),e.jsx("button",{type:"button",onClick:()=>v==null?void 0:v(i.initiativeId,i.workstreamId,"top"),className:"rounded-md px-2.5 py-1.5 text-[12px] font-medium text-white/35 transition-colors hover:bg-white/[0.04] hover:text-white/60",children:"Move top"})]}),n.source==="in_progress"&&i.sessionId&&e.jsx("button",{type:"button",onClick:()=>{D==null||D(i.sessionId),s()},className:"rounded-md px-2.5 py-1.5 text-[12px] font-medium text-white/35 transition-colors hover:bg-white/[0.04] hover:text-white/60",children:"Open session"}),n.source==="needs_input"&&t&&t.primaryAction==="resolve_decision"&&e.jsx("button",{type:"button",onClick:()=>{$==null||$(),s()},className:`rounded-md px-2.5 py-1.5 text-[12px] font-medium text-[#0AD4C4]/70 transition-colors hover:bg-[#0AD4C4]/[0.08] hover:text-[#0AD4C4] ${V==="resolve_decision"?Y:""}`,children:"Resolve decision"}),n.source==="needs_input"&&t&&e.jsx("button",{type:"button",onClick:()=>{I==null||I(t),s()},className:`rounded-md px-2.5 py-1.5 text-[12px] font-medium text-white/35 transition-colors hover:bg-white/[0.04] hover:text-white/60 ${V==="review"?Y:""}`,children:"Review"}),i.runId&&e.jsx("button",{type:"button",onClick:()=>{w==null||w(i.runId),s()},className:"rounded-md px-2.5 py-1.5 text-[12px] font-medium text-white/35 transition-colors hover:bg-white/[0.04] hover:text-white/60",children:"Timeline"})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[L&&r&&e.jsx("button",{type:"button",onClick:()=>R(f==="reject"?null:"reject"),className:`rounded-md px-2.5 py-1.5 text-[12px] font-medium transition-colors ${f==="reject"?"bg-[#FF6B88]/12 text-[#FF6B88]":"text-white/35 hover:bg-white/[0.04] hover:text-white/60"}`,children:"Request changes"}),L&&E&&e.jsxs("button",{type:"button",onClick:()=>{f==="accept"?X():R("accept")},className:"inline-flex h-8 items-center gap-1.5 rounded-lg bg-lime/12 px-4 text-[12px] font-semibold text-lime transition-colors hover:bg-lime/20",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Accept"]}),xe&&e.jsxs("button",{type:"button","data-modal-autofocus":"true",onClick:()=>{o==null||o(i.initiativeId,i.workstreamId,i.agentId??void 0),s()},className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-lime/25 bg-lime/10 px-4 text-[12px] font-semibold text-lime transition-colors hover:bg-lime/20 ${V==="start"?"ring-1 ring-lime/50 shadow-[0_0_10px_rgba(191,255,0,0.2)]":""}`,title:"Start (⌘ Enter)",children:[e.jsx("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":!0,className:"h-3.5 w-3.5",children:e.jsx("path",{d:"M7 5.4v9.2c0 .7.75 1.15 1.38.83l7.6-4.6a.95.95 0 0 0 0-1.62l-7.6-4.64A.95.95 0 0 0 7 5.4Z",fill:"currentColor"})}),k.status==="completed"?"Restart":k.status==="needs_attention"?"Retry":"Start"]}),he&&e.jsx("button",{type:"button",onClick:()=>void pe(Q),disabled:oe,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-white/30 transition-colors hover:bg-white/[0.04] hover:text-white/50 disabled:opacity-40",title:"Open in terminal",children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"4 17 10 11 4 5"}),e.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})})]})]})]});let y=0;return e.jsx(ye,{open:B,onClose:s,maxWidth:"max-w-xl",children:e.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[e.jsx("div",{className:"h-[2px] flex-shrink-0 rounded-t-2xl",style:Ee(i.queueState),"aria-hidden":!0}),e.jsx(ve,{breadcrumbs:me,onClose:s,footer:ge,children:e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs(h.div,{variants:Pe,initial:"hidden",animate:"visible",exit:"exit",custom:y++,className:"flex items-start gap-3",children:[e.jsx(je,{name:i.agentName??"OrgX",hint:i.agentSource??i.agentId,size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"text-display font-medium leading-none text-white truncate",children:i.workstreamTitle}),i.initiativeTitle&&e.jsx("p",{className:"mt-1 text-micro uppercase tracking-[0.08em] text-muted",children:i.initiativeTitle}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:[e.jsxs("span",{className:`inline-flex items-center rounded-full border px-2 py-0.5 text-micro font-semibold uppercase tracking-[0.08em] ${de}`,children:[e.jsxs("span",{className:"relative mr-1.5 inline-block h-1.5 w-1.5",children:[e.jsx("span",{className:"absolute inset-0 rounded-full",style:{backgroundColor:ae(i.queueState)}}),Z&&e.jsx(h.span,{className:"absolute inset-0 rounded-full",style:{backgroundColor:ae(i.queueState)},animate:{opacity:[1,.3,1],scale:[1,1.6,1]},transition:{duration:2,repeat:1/0,ease:"easeInOut"}})]}),k.label]}),(t==null?void 0:t.confidence)&&e.jsx("span",{className:`chip text-[9px] font-semibold ${t.confidence==="high"?"border-lime/30 bg-lime/[0.12] text-lime":t.confidence==="medium"?"border-[#F5B700]/30 bg-[#F5B700]/[0.12] text-[#FFE7A8]":"border-white/[0.12] bg-white/[0.05] text-white/60"}`,children:t.confidence})]}),(t==null?void 0:t.statusExplainer)&&n.source!=="needs_input"&&e.jsx("p",{className:"mt-2 text-body text-secondary",children:t.statusExplainer})]})]}),t&&e.jsx(De,{metrics:[...t.startedAt?[{label:"Duration",value:(()=>{const a=t.completedAt??t.failedAt??t.updatedAt??new Date().toISOString(),l=Date.parse(a)-Date.parse(t.startedAt);return l<6e4?`${Math.round(l/1e3)}s`:l<36e5?`${Math.round(l/6e4)}m`:`${(l/36e5).toFixed(1)}h`})()}]:[],...t.artifactCount>0?[{label:"Artifacts",value:t.artifactCount,color:p.teal}]:[],...t.decisionCount>0?[{label:"Decisions",value:t.decisionCount,color:p.amber}]:[]],className:"pb-4 border-b border-white/[0.04]"}),t&&t.artifacts.length>0&&e.jsx(Re,{artifacts:t.artifacts}),e.jsx(S,{}),n.source==="needs_input"&&t?(()=>{const a=Fe({statusExplainer:t.statusExplainer,summary:i.blockReason,lastEventSummary:t.lastEventSummary}),u=_e({lifecycleState:t.status,artifactCount:t.artifactCount,artifacts:t.artifacts.map(c=>({title:c.title,type:c.type??"unknown"})),statusExplainer:t.statusExplainer,confidence:t.confidence})??a.outcome,x=Array.isArray(t.blockers)?t.blockers:[],C=Array.isArray(t.pendingDecisions)?t.pendingDecisions:[];return e.jsxs(e.Fragment,{children:[e.jsxs(h.div,{variants:j,initial:"hidden",animate:"visible",exit:"exit",custom:y++,className:`rounded-xl border px-4 py-3 ${ue}`,children:[e.jsx("p",{className:"section-kicker",children:"What to do now"}),e.jsx("p",{className:"mt-1 text-body text-primary",children:k.sentence}),t.artifactCount>0?e.jsxs("p",{className:"mt-1 text-caption text-secondary",children:[t.artifactCount," artifact",t.artifactCount===1?"":"s"," ready for review."]}):null,t.blockingDecisionCount>0?e.jsxs("p",{className:"mt-1 text-caption text-secondary",children:[t.blockingDecisionCount," blocking decision",t.blockingDecisionCount===1?"":"s"," waiting."]}):null,W?e.jsxs("p",{className:"mt-1 text-caption text-lime/70 flex items-center gap-1",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"flex-shrink-0",children:e.jsx("polyline",{points:"9 18 15 12 9 6"})}),"Recommended action: ",W]}):null]}),(x.length>0||C.length>0)&&e.jsxs(h.div,{variants:j,initial:"hidden",animate:"visible",exit:"exit",custom:y++,className:"space-y-2",children:[e.jsx("p",{className:"section-kicker",children:"Intervention brief"}),x.slice(0,3).map(c=>e.jsxs("div",{className:`rounded-lg border px-3 py-2 ${c.severity==="error"?"border-red-400/24 bg-red-500/[0.08]":c.severity==="warn"?"border-amber-300/20 bg-amber-500/[0.08]":"border-white/[0.10] bg-white/[0.03]"}`,children:[e.jsx("p",{className:"text-caption font-semibold text-primary",children:c.reason}),(c.waitingOn||c.requiredAction)&&e.jsxs("p",{className:"mt-1 text-micro text-secondary",children:[c.waitingOn?`Waiting on: ${c.waitingOn}`:null,c.waitingOn&&c.requiredAction?" · ":null,c.requiredAction?`Required action: ${c.requiredAction}`:null]})]},c.id)),C.slice(0,2).map(c=>e.jsxs("div",{className:"rounded-lg border border-amber-300/16 bg-amber-500/[0.06] px-3 py-2",children:[e.jsx("p",{className:"text-caption font-semibold text-primary",children:c.title}),c.summary&&e.jsx("p",{className:"mt-1 text-micro text-secondary leading-relaxed",children:c.summary}),c.recommendedAction&&e.jsxs("p",{className:"mt-1 text-micro text-amber-100/80",children:["Recommended: ",c.recommendedAction]})]},c.id))]}),u&&e.jsxs(h.div,{variants:j,initial:"hidden",animate:"visible",exit:"exit",custom:y++,children:[e.jsx("p",{className:"section-kicker",children:"Outcome"}),e.jsx("p",{className:"mt-1 text-body text-secondary leading-relaxed",children:A(u)})]}),a.lastActivity&&e.jsxs(h.div,{variants:j,initial:"hidden",animate:"visible",exit:"exit",custom:y++,children:[e.jsx("p",{className:"section-kicker",children:"Last activity"}),e.jsx("p",{className:"mt-1 text-caption text-white/50 leading-relaxed",children:A(a.lastActivity)})]}),e.jsx(S,{})]})})():null,(i.blockReason||i.autoContinue||i.agentSource&&i.agentSource!=="assigned")&&e.jsxs(h.div,{variants:j,initial:"hidden",animate:"visible",exit:"exit",custom:y++,className:"space-y-2",children:[i.blockReason&&e.jsxs("div",{className:"rounded-lg border border-red-400/24 bg-red-500/[0.08] px-2.5 py-1.5 text-caption text-red-100/85",children:[e.jsx("p",{className:"mb-0.5 text-micro font-semibold uppercase tracking-[0.08em] text-red-200/70",children:"Why blocked"}),i.blockReason]}),i.autoContinue&&e.jsxs("div",{className:"flex items-center gap-2 text-caption text-secondary",children:[e.jsx("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":!0,className:"h-3.5 w-3.5 flex-shrink-0 text-[#0AD4C4]",children:e.jsx("path",{d:"M6.1 13.25C4.25 13.25 2.8 11.8 2.8 10s1.45-3.25 3.3-3.25c3.15 0 4.35 6.5 8.05 6.5 1.85 0 3.3-1.45 3.3-3.25s-1.45-3.25-3.3-3.25c-3.7 0-4.9 6.5-8.05 6.5Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsxs("span",{children:["Auto-continue: ",e.jsx("span",{className:"text-primary capitalize",children:i.autoContinue.status}),i.autoContinue.laneState&&e.jsxs("span",{className:"text-muted",children:[" · ",Ne(i.autoContinue.laneState)]})]})]}),((ee=i.autoContinue)==null?void 0:ee.laneBlockedReason)&&e.jsx("p",{className:"text-micro text-red-100/75",children:i.autoContinue.laneBlockedReason}),((te=i.autoContinue)==null?void 0:te.stopReason)&&e.jsx("p",{className:"text-micro text-amber-100/75",children:Ie(i.autoContinue.stopReason)})]}),J.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(S,{}),e.jsxs(h.div,{variants:j,initial:"hidden",animate:"visible",exit:"exit",custom:y++,className:"space-y-2",children:[e.jsx("p",{className:"section-kicker",children:re(i.queueState,L)}),e.jsx(Te,{nodes:J}),e.jsxs("div",{className:"flex items-center gap-2",children:[i.nextTaskPriority!==null&&O(i.nextTaskPriority)&&e.jsx("span",{className:"inline-flex rounded-full border px-2 py-0.5 text-micro font-semibold",style:{color:_(i.nextTaskPriority),borderColor:`${_(i.nextTaskPriority)}33`,backgroundColor:`${_(i.nextTaskPriority)}14`},children:O(i.nextTaskPriority)}),i.nextTaskDueAt&&e.jsxs("span",{className:"text-micro text-secondary",children:["Due ",F(i.nextTaskDueAt)]})]})]})]}),J.length===0&&(i.nextTaskTitle||i.sliceTaskCount!==null||i.sliceScope)&&e.jsxs(e.Fragment,{children:[e.jsx(S,{}),e.jsxs(h.div,{variants:j,initial:"hidden",animate:"visible",exit:"exit",custom:y++,className:"space-y-2",children:[e.jsx("p",{className:"section-kicker",children:re(i.queueState,L)}),i.nextTaskTitle&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ne,{type:"task",size:14,className:"mt-[2px] flex-shrink-0 opacity-80"}),e.jsx("p",{className:"text-body font-semibold leading-snug text-white",children:i.nextTaskTitle})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[i.sliceScope?e.jsxs("span",{className:"inline-flex rounded-full border border-strong bg-white/[0.03] px-2 py-0.5 text-micro uppercase tracking-[0.08em] text-secondary",children:[i.sliceScope," slice"]}):null,typeof i.sliceTaskCount=="number"?e.jsxs("span",{className:"inline-flex rounded-full border border-strong bg-white/[0.03] px-2 py-0.5 text-micro text-secondary",children:[i.sliceTaskCount," ",i.sliceTaskCount===1?"task":"tasks"," in scope"]}):null,i.nextTaskPriority!==null&&O(i.nextTaskPriority)&&e.jsx("span",{className:"inline-flex rounded-full border px-2 py-0.5 text-micro font-semibold",style:{color:_(i.nextTaskPriority),borderColor:`${_(i.nextTaskPriority)}33`,backgroundColor:`${_(i.nextTaskPriority)}14`},children:O(i.nextTaskPriority)}),i.nextTaskDueAt&&e.jsxs("span",{className:"text-micro text-secondary",children:["Due ",F(i.nextTaskDueAt)]})]})]})]}),t&&(t.startedAt||t.updatedAt||t.completedAt||t.failedAt)&&e.jsxs(e.Fragment,{children:[e.jsx(S,{}),e.jsxs(h.div,{variants:j,initial:"hidden",animate:"visible",exit:"exit",custom:y++,className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"section-kicker",children:"Timeline"}),t.scope&&t.scope!=="task"&&e.jsx(Ce,{tone:t.scope==="milestone"?"cyan":"lime",children:t.scope}),t.confidence&&e.jsx("div",{className:"flex items-center gap-1 ml-auto",title:`Confidence: ${t.confidence}`,children:Array.from({length:5},(a,l)=>{const{filled:u,color:x}=Be(t.confidence);return e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full",style:{backgroundColor:l<u?x:"rgba(255,255,255,0.1)"}},l)})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[t.startedAt&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.08em] text-muted",children:"Started"}),e.jsx("p",{className:"mt-0.5 text-caption text-primary",children:F(t.startedAt)})]}),t.completedAt?e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.08em] text-muted",children:"Completed"}),e.jsx("p",{className:"mt-0.5 text-caption text-primary",children:F(t.completedAt)})]}):t.failedAt?e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.08em] text-muted",children:"Failed"}),e.jsx("p",{className:"mt-0.5 text-caption text-red-100",children:F(t.failedAt)})]}):t.updatedAt&&t.updatedAt!==t.startedAt?e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.08em] text-muted",children:"Updated"}),e.jsx("p",{className:"mt-0.5 text-caption text-primary",children:F(t.updatedAt)})]}):null]})]})]}),t&&t.artifactCount>0&&t.artifacts.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(S,{}),e.jsxs(h.div,{variants:j,initial:"hidden",animate:"visible",exit:"exit",custom:y++,className:"space-y-2",children:[e.jsxs("p",{className:"section-kicker",children:["Artifacts ",e.jsx("span",{className:"text-muted tabular-nums",children:t.artifactCount})]}),e.jsx("div",{className:"space-y-1",children:t.artifacts.map((a,l)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-2 py-1.5 transition-colors hover:bg-white/[0.04]",children:[e.jsx(ne,{type:a.type==="pull_request"?"session":"workstream",size:13,className:"flex-shrink-0 opacity-75"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-caption text-primary",children:a.title}),a.url&&e.jsx("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",className:"flex-shrink-0 text-micro text-secondary transition-colors hover:text-white",title:"Open artifact",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})})]},a.id??l))})]})]}),t&&(t.decisionCount>0||(((ie=t.pendingDecisions)==null?void 0:ie.length)??0)>0)&&e.jsxs(e.Fragment,{children:[e.jsx(S,{}),e.jsxs(h.div,{variants:j,initial:"hidden",animate:"visible",exit:"exit",custom:y++,className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{className:"section-kicker",children:["Decisions ",e.jsx("span",{className:"text-muted tabular-nums",children:t.decisionCount})]}),t.blockingDecisionCount>0&&e.jsxs("span",{className:"inline-flex rounded-full border px-1.5 py-[0.5px] text-micro font-semibold tabular-nums",style:{color:p.red,borderColor:`${p.red}33`,backgroundColor:`${p.red}14`},children:[t.blockingDecisionCount," blocking"]})]}),Array.isArray(t.pendingDecisions)&&t.pendingDecisions.length>0&&e.jsx("div",{className:"space-y-2",children:t.pendingDecisions.slice(0,4).map(a=>{var l,u;return e.jsxs("div",{className:"rounded-lg border border-white/[0.08] bg-white/[0.03] px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"text-caption font-semibold text-primary",children:a.title}),e.jsx("span",{className:`inline-flex rounded-full border px-1.5 py-[0.5px] text-micro font-semibold ${a.blocking?"border-red-400/30 bg-red-500/[0.12] text-red-100":"border-amber-300/25 bg-amber-400/[0.10] text-amber-100"}`,children:a.blocking?"Blocking":"Advisory"})]}),a.summary&&e.jsx("p",{className:"mt-1 text-micro leading-relaxed text-secondary",children:a.summary}),(a.recommendedAction||(((l=a.options)==null?void 0:l.length)??0)>0)&&e.jsxs("div",{className:"mt-1.5 space-y-1",children:[a.recommendedAction&&e.jsxs("p",{className:"text-micro text-lime/75",children:["Recommended: ",a.recommendedAction]}),(((u=a.options)==null?void 0:u.length)??0)>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:a.options.slice(0,3).map(x=>e.jsx("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.04] px-2 py-0.5 text-micro text-secondary",children:x.label},`${a.id}:${x.id}`))})]})]},a.id)})}),t.decisionOptions.length>0&&e.jsx("div",{className:"space-y-1.5",children:t.decisionOptions.slice(0,4).map(a=>e.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-white/[0.02] px-3 py-2",children:[e.jsx("p",{className:"text-caption font-semibold text-primary",children:a.label}),a.description&&e.jsx("p",{className:"mt-0.5 text-micro leading-snug text-secondary",children:a.description})]},a.id))})]})]}),t&&(t.sliceRunId||t.runId)&&e.jsxs(e.Fragment,{children:[e.jsx(S,{}),e.jsxs(h.div,{variants:j,initial:"hidden",animate:"visible",exit:"exit",custom:y++,children:[e.jsx("p",{className:"section-kicker mb-2",children:"Notes"}),e.jsx(Se,{entityType:"run",entityId:t.runId??t.sliceRunId,variant:"inline"})]})]}),t&&(t.sourceClient||t.runtimeState||t.correlationId||t.runId)&&e.jsxs(e.Fragment,{children:[e.jsx(S,{}),e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"flex cursor-pointer select-none items-center gap-1.5 py-1 text-micro uppercase tracking-[0.08em] text-muted transition-colors hover:text-secondary",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"transition-transform group-open:rotate-90",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),"Technical details"]}),e.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-x-4 gap-y-2",children:[t.sourceClient&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.08em] text-muted",children:"Source"}),e.jsx("p",{className:"mt-0.5 font-mono text-caption text-primary",children:t.sourceClient})]}),t.runtimeState&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.08em] text-muted",children:"Runtime State"}),e.jsx("p",{className:"mt-0.5 font-mono text-caption text-primary",children:t.runtimeState})]}),t.runId&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.08em] text-muted",children:"Run ID"}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(t.runId)},className:"mt-0.5 font-mono text-caption text-primary transition-colors hover:text-white",title:"Click to copy",children:t.runId})]}),t.correlationId&&t.correlationId!==t.runId&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.08em] text-muted",children:"Correlation ID"}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(t.correlationId)},className:"mt-0.5 font-mono text-caption text-primary transition-colors hover:text-white",title:"Click to copy",children:t.correlationId})]})]})]})]})]})})]})})}export{Ze as SliceDetailModal};
@@ -1 +0,0 @@
1
- import{r as c,j as e}from"./Dj2k1r16.js";import{E as ae,f as P,z as Pe,a4 as ee,w as Re,a5 as Ue,a6 as Oe,M as ze,h as We,P as Ge,C as ue}from"./CSd4rSuU.js";import{E as Ke}from"./DhPuHPK7.js";import{A as De,m as V,u as Xe}from"./eeHXe_OQ.js";import{u as Je}from"./CGJiHCIx.js";import"./DMKyYAtD.js";import"./cX2e-TLi.js";import"./BjK42gtU.js";import"./BV0BcV1u.js";const Ve={pr:"⎋",file:"◇",artifact:"▪",log:"▸",decision:"◈"};function Ze(a){return a>=.8?"#BFFF00":a>=.5?"#F5B700":"#FF6B88"}function Qe(a){const t=a.match(/https?:\/\/\S+/);return t?t[0]:null}function Ye({evidenceType:a,title:t,summary:u,sourceUrl:m,confidence:y,payload:k,icon:j,label:v,onOpenTerminal:C}){const[o,W]=c.useState(!1),B=t??v??null,_=a??(j?j.toUpperCase():null),T=j?Ve[j]:null,S=j==="pr"&&v?Qe(v):null;return e.jsxs("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-start gap-2.5 cursor-pointer",onClick:()=>W(N=>!N),children:[(_||T)&&e.jsxs("span",{className:"mt-0.5 flex-shrink-0 rounded bg-white/[0.06] px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wider text-secondary",children:[T?e.jsx("span",{className:"mr-1",children:T}):null,_]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[B&&e.jsx("p",{className:"text-body font-medium text-primary",children:m?e.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-[#D8FFA1] hover:underline",onClick:N=>N.stopPropagation(),children:B}):S?e.jsx("a",{href:S,target:"_blank",rel:"noopener noreferrer",className:"text-[#D8FFA1] hover:underline",onClick:N=>N.stopPropagation(),children:B}):B}),u&&e.jsx("p",{className:`mt-0.5 text-caption text-secondary ${o?"":"line-clamp-2"}`,children:u})]}),e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:`mt-1 flex-shrink-0 text-muted transition-transform ${o?"rotate-180":""}`,children:e.jsx("path",{d:"m6 9 6 6 6-6"})})]}),y!=null&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("div",{className:"h-1 flex-1 overflow-hidden rounded-full bg-white/[0.06]",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Math.round(y*100)}%`,backgroundColor:Ze(y)}})}),e.jsxs("span",{className:"text-micro text-muted tabular-nums",children:[Math.round(y*100),"%"]})]}),e.jsx(De,{children:o&&e.jsx(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:e.jsxs("div",{className:"mt-2 space-y-2",children:[j==="log"&&C&&e.jsxs("button",{type:"button",onClick:N=>{N.stopPropagation(),C()},className:"inline-flex items-center gap-1.5 rounded-lg border border-white/[0.12] bg-white/[0.04] px-3 py-1.5 text-caption font-semibold text-primary transition-colors hover:bg-white/[0.08]",children:[e.jsx("span",{className:"font-mono text-micro",children:">_"}),"Open in terminal"]}),k&&Object.keys(k).length>0&&e.jsx("pre",{className:"max-h-40 overflow-auto rounded-lg bg-black/40 p-2.5 text-micro text-secondary font-mono",children:JSON.stringify(k,null,2)})]})})})]})}function He({segments:a}){return a.length===0?null:e.jsx("nav",{className:"flex items-center gap-1.5 min-w-0 text-caption text-secondary",children:a.map((t,u)=>e.jsxs("span",{className:"flex items-center gap-1.5 min-w-0",children:[u>0&&e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"flex-shrink-0 text-faint",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),t.icon&&e.jsx(ae,{type:t.icon,size:11,className:"flex-shrink-0 opacity-80"}),t.onClick?e.jsx("button",{type:"button",onClick:t.onClick,className:"truncate transition-colors hover:text-primary",children:t.label}):e.jsx("span",{className:"truncate",children:t.label})]},u))})}const ve={label:"Retry this workstream",description:"Re-run with the same configuration. Recommended if this was a transient issue.",impliedStatus:"approved"},J={label:"Skip and continue",description:"Mark as accepted and move to the next workstream.",impliedStatus:"approved"},et=[{test:/Worker exited without structured output.*?code=(\S+?),\s*signal=(\S+?)\)/i,headline:"Agent work stopped unexpectedly",explain:(a,t)=>{const u=t[1]==="null"?"none":t[1],m=t[2]==="null"?"none":t[2];return`The agent process exited before producing results. Exit code: ${u}. Signal: ${m}. This usually means the worker was terminated externally or ran out of resources.`},severity:"critical",options:[ve,{label:"Retry with more resources",description:"Increase token budget before re-running.",impliedStatus:"approved"},J],extractDetails:(a,t)=>({exitCode:t[1]==="null"?void 0:t[1],signal:t[2]==="null"?void 0:t[2]})},{test:/MCP handshake failed(?:\s+for\s+(\S+))?/i,headline:"Agent couldn't connect to tools",explain:(a,t)=>`The agent failed to connect to its tool server${t[1]?` (${t[1]})`:""}. This typically means the MCP server is unreachable or took too long to respond.`,severity:"critical",options:[ve,{label:"Check MCP server",description:"Investigate the tool server connection before retrying.",impliedStatus:"approved"},J],extractDetails:(a,t)=>({server:t[1]||void 0})},{test:/(?:Slice|Autopilot slice) timed out after (\d+)/i,headline:"Agent ran out of time",explain:(a,t)=>{const u=Math.round(parseInt(t[1],10)/6e4);return`The agent exceeded its ${u>0?`${u}-minute`:`${t[1]}ms`} time limit. Consider breaking the work into smaller steps or increasing the time budget.`},severity:"warning",options:[{label:"Retry with more time",description:"Increase the timeout before re-running.",impliedStatus:"approved"},{label:"Break into smaller tasks",description:"Split the workstream into smaller pieces that fit the time budget.",impliedStatus:"approved"},J],extractDetails:(a,t)=>({elapsedMs:t[1]})},{test:/(?:Slice|Autopilot slice) stalled/i,headline:"Agent stopped making progress",explain:()=>"The agent stopped producing output. It may be stuck in a loop, waiting on an unresponsive resource, or unable to proceed with the current approach.",severity:"warning",options:[ve,{label:"Review logs",description:"Check the session logs to understand why the agent stalled.",impliedStatus:"approved"},J]},{test:/blocked.*?(?:needs|requires?) intervention/i,headline:"Agent needs your help to continue",explain:()=>"The agent reached a point where it cannot proceed without human guidance. This may be a question about requirements, a permission needed, or an ambiguity.",severity:"warning",options:[{label:"Review blocker",description:"Look at what the agent needs and provide guidance.",impliedStatus:"approved"},{label:"Provide guidance",description:"Add a note with instructions for the agent.",impliedStatus:"approved"},J]},{test:/completed.*?(?:without|no) (?:verifiable )?(?:outcomes?|artifacts?)/i,headline:"Agent finished but produced no outputs",explain:()=>"The agent reported completion but produced no artifacts or status updates. The work may have been done informally, or the agent could not find actionable work.",severity:"info",options:[{label:"Accept as-is",description:"The work was done informally or no output was needed.",impliedStatus:"approved"},{label:"Retry with stronger output requirements",description:"Re-run and require the agent to produce structured artifacts.",impliedStatus:"approved"},J]},{test:/Spawn guard denied/i,headline:"Agent dispatch was blocked by safety check",explain:()=>"The system's safety checks prevented this agent from starting. This is typically due to capacity limits or quality gate requirements.",severity:"warning",options:[{label:"Approve exception",description:"Override the safety check and allow dispatch.",impliedStatus:"approved"},{label:"Investigate quality gate",description:"Review what safety check failed before proceeding.",impliedStatus:"approved"},J]},{test:/code=(\d+)/i,headline:"Agent encountered an error",explain:(a,t)=>`The agent process exited with error code ${t[1]}. Reviewing the session logs will show what operation failed.`,severity:"critical",options:[ve,{label:"Review error logs",description:"Check session logs to understand the error before retrying.",impliedStatus:"approved"},J],extractDetails:(a,t)=>({exitCode:t[1]})}];function tt(a){var u;const t=a.context||a.title||"";for(const m of et){const y=t.match(m.test);if(y)return{headline:m.headline,explanation:m.explain(t,y),structuredDetails:((u=m.extractDetails)==null?void 0:u.call(m,t,y))??{},suggestedOptions:m.options,severity:m.severity}}return a.decisionType==="autopilot_failure"?{headline:"Agent work needs attention",explanation:t||"An issue occurred during autopilot execution that requires review.",structuredDetails:{},suggestedOptions:[ve,J],severity:"warning"}:{headline:a.title||"Decision needed",explanation:t||"Review the details and choose an action.",structuredDetails:{},suggestedOptions:[],severity:"info"}}function st(a){return a.map((t,u)=>({id:`suggested-${u}`,label:t.label,description:t.description,impliedStatus:t.impliedStatus,actionType:null,requiresNote:!1}))}function rt(a,t){var v;if(!t||!a.workstreamId||!t.nodes.find(C=>C.id===a.workstreamId&&C.entityType==="workstream"))return null;const m=new Set(t.edges.filter(C=>C.source===a.workstreamId).map(C=>C.target)),y=[];for(const C of m){const o=t.nodes.find(W=>W.id===C);o&&y.push({id:o.id,title:o.title,taskCount:((v=o.children)==null?void 0:v.length)??0,status:o.status})}if(y.length===0)return null;const k=y.reduce((C,o)=>C+o.taskCount,0),j=y.some(C=>t.edges.some(o=>o.source===C.id));return{blockedWorkstreams:y,totalBlockedTasks:k,criticalPath:j}}function nt(a){const t=a.blockedWorkstreams.length,u=a.blockedWorkstreams.map(m=>m.title);return t===1?`Resolving this unblocks 1 downstream workstream: ${u[0]}.`:t<=3?`Resolving this unblocks ${t} downstream workstreams: ${u.join(", ")}.`:`Resolving this unblocks ${t} downstream workstreams including ${u[0]} and ${u[1]}.`}const Fe=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.userAgent);function it(a){try{return JSON.stringify(a,null,2)}catch{return null}}function pe(a){return!a||typeof a!="object"||Array.isArray(a)?null:a}function at(a){if(!a)return[];const t=pe(a.result),u=[a,t].filter(j=>!!j),m=[],y=new Set,k=(j,v)=>{if(Array.isArray(v))for(const C of v){const o=pe(C);if(!o)continue;const W=typeof o.task_id=="string"&&o.task_id.trim()||typeof o.taskId=="string"&&o.taskId.trim()||typeof o.milestone_id=="string"&&o.milestone_id.trim()||typeof o.milestoneId=="string"&&o.milestoneId.trim()||null,B=typeof o.task_title=="string"&&o.task_title.trim()||typeof o.taskTitle=="string"&&o.taskTitle.trim()||typeof o.milestone_title=="string"&&o.milestone_title.trim()||typeof o.milestoneTitle=="string"&&o.milestoneTitle.trim()||typeof o.title=="string"&&o.title.trim()||W||j,_=typeof o.status=="string"&&o.status.trim()||typeof o.state=="string"&&o.state.trim()||null,T=typeof o.reason=="string"&&o.reason.trim()||typeof o.summary=="string"&&o.summary.trim()||typeof o.note=="string"&&o.note.trim()||null,S=`${j}|${B.toLowerCase()}|${(_??"").toLowerCase()}|${(T??"").toLowerCase()}`;y.has(S)||(y.add(S),m.push({scope:j,label:B,status:_,note:T}))}};for(const j of u)k("Task",j.task_updates??j.taskUpdates),k("Milestone",j.milestone_updates??j.milestoneUpdates);return m.slice(0,8)}function Le(a){if(typeof a!="string")return null;const t=a.trim().toLowerCase();return t==="rejected"?"declined":t==="approved"||t==="declined"||t==="cancelled"?t:null}function Ae(a,t){return!a||a.trim().length===0?t:We(a.trim())||t}function lt(a){switch(a){case"spawn_guard_blocked":return"Spawn Guard";case"autopilot_failure":return"Autopilot Failure";case"budget_exceeded":return"Budget Exceeded";case"scope_change":return"Scope Change";case"conflict_resolution":return"Conflict Resolution";case"approval_required":return"Approval Required";case"review_required":return"Review Required";case"permission_request":return"Permission Request";default:return a.replace(/[_-]/g," ").replace(/\b\w/g,t=>t.toUpperCase())}}function ot(a){const t=a.toLowerCase();return t==="critical"||t==="p0"?P.red:t==="high"||t==="p1"?P.amber:t==="medium"||t==="p2"?P.iris:"rgba(255,255,255,0.5)"}function ct({open:a,decision:t,onClose:u,onApprove:m,onReject:y,initiativeTitle:k,workstreamTitle:j,onNavigate:v,currentIndex:C,totalCount:o,onFocusRunId:W,graph:B}){const[_,T]=c.useState("idle"),[S,N]=c.useState(null),[U,O]=c.useState(null),[I,Z]=c.useState(""),[ke,te]=c.useState(!1),[me,Ne]=c.useState(!1),Q=c.useRef(null),le=c.useRef(),xe=c.useRef(u);xe.current=u,c.useEffect(()=>{if(a){T("idle"),N(null);const s=(t==null?void 0:t.selectedOptionId)??(t!=null&&t.options&&t.options.length===1?t.options[0].id:null);O(s),Z(""),te(!1),Ne(!1)}return()=>{le.current&&clearTimeout(le.current)}},[a,t==null?void 0:t.id]);const F=t==null?void 0:t.metadata,G=c.useMemo(()=>{if(!F)return[];const s=F,l=s.decision_options??s.options??s.actions??null;if(!Array.isArray(l))return[];const x=[],z=new Set;for(let R=0;R<l.length;R+=1){const L=l[R];if(typeof L=="string"){const r=L.trim();if(!r)continue;const i=`option-${R+1}`;if(z.has(i))continue;z.add(i),x.push({id:i,label:r,description:null,consequences:null,impliedStatus:null,actionType:null,requiresNote:!1});continue}if(!L||typeof L!="object")continue;const h=L,X=typeof h.id=="string"&&h.id.trim()||typeof h.option_id=="string"&&h.option_id.trim()||typeof h.action_id=="string"&&h.action_id.trim()||`option-${R+1}`;if(z.has(X))continue;const n=typeof h.label=="string"&&h.label.trim()||typeof h.title=="string"&&h.title.trim()||typeof h.name=="string"&&h.name.trim()||typeof h.action=="string"&&h.action.trim()||null;n&&(z.add(X),x.push({id:X,label:n,description:typeof h.description=="string"?h.description:null,consequences:typeof h.consequences=="string"&&h.consequences||typeof h.impact=="string"&&h.impact||null,impliedStatus:Le(h.implied_status)??Le(h.status),actionType:typeof h.action_type=="string"&&h.action_type||typeof h.type=="string"&&h.type||null,requiresNote:h.requires_note===!0||h.requiresNote===!0||h.note_required===!0}))}return x.slice(0,12)},[F]),w=c.useMemo(()=>t?tt(t):null,[t==null?void 0:t.context,t==null?void 0:t.title,t==null?void 0:t.decisionType]),se=c.useMemo(()=>t?rt(t,B??null):null,[t==null?void 0:t.workstreamId,t==null?void 0:t.initiativeId,B]),oe=((t==null?void 0:t.waitingMinutes)??0)>1440,E=c.useMemo(()=>t!=null&&t.options&&t.options.length>0?t.options:G.length>0?G:w&&w.suggestedOptions.length>0?st(w.suggestedOptions):[],[t==null?void 0:t.options,G,w]),g=c.useMemo(()=>E.find(s=>s.id===U)??null,[E,U]),he=(g==null?void 0:g.requiresNote)===!0,b=c.useMemo(()=>{const s=((t==null?void 0:t.context)??"").trim();if(s)return s;if(!F)return"";const l=F,x=(typeof l.summary=="string"?l.summary:null)??(typeof l.description=="string"?l.description:null)??"";return String(x??"").trim()},[t==null?void 0:t.context,F]),A=c.useMemo(()=>{var X,n,r;const s=F&&typeof F=="object"?F:void 0,l=at(s),x=pe(s==null?void 0:s.outcomes),z=typeof(s==null?void 0:s.status_updates_applied)=="number"&&Number.isFinite(s.status_updates_applied)?s.status_updates_applied:typeof((X=pe(s==null?void 0:s.result))==null?void 0:X.status_updates_applied)=="number"&&Number.isFinite((n=pe(s==null?void 0:s.result))==null?void 0:n.status_updates_applied)?(r=pe(s==null?void 0:s.result))==null?void 0:r.status_updates_applied:null,R=Array.isArray(s==null?void 0:s.artifacts)?s.artifacts.length:typeof(x==null?void 0:x.artifacts)=="number"?x.artifacts:null,L=(s==null?void 0:s.status_updates_buffered)??(s==null?void 0:s.statusUpdatesBuffered),h=L===!0||typeof L=="number"&&L>0||typeof L=="string"&&["true","1","yes"].includes(L.trim().toLowerCase());return{rows:l,statusUpdatesApplied:z,artifactCount:typeof R=="number"?R:null,buffered:h,hasPr:typeof(x==null?void 0:x.pr_url)=="string"||typeof(x==null?void 0:x.commit_sha)=="string"}},[F]),q=c.useMemo(()=>{const s=(t==null?void 0:t.waitingMinutes)??0;return s>=15?P.red:s>=5?P.amber:P.teal},[t==null?void 0:t.waitingMinutes]),ce=c.useCallback(async()=>{if(!t)return;const s=it({decision:t,metadata:F});if(s)try{await navigator.clipboard.writeText(s),te(!0),setTimeout(()=>te(!1),2e3)}catch{}},[t,F]),re=c.useCallback(()=>{const s=I.trim(),l=g==null?void 0:g.id;if(!(!s&&!l))return{note:s.length>0?s:void 0,optionId:l??void 0}},[I,g]),de=c.useCallback(async()=>{if(!t||!m)return;if(E.length>0&&!g){N("Select an option before approving this decision.");return}if(g!=null&&g.requiresNote&&I.trim().length===0){N("A note is required for the selected option."),requestAnimationFrame(()=>{var l;return(l=Q.current)==null?void 0:l.focus()});return}let s=!1;if(T(l=>l==="approving"||l==="rejecting"?l:(s=!0,"approving")),!!s){N(null);try{const l=await m(t.id,re());l.failed>0?(T("error"),N(Ae(l.firstError,"Approval failed. Please try again."))):(T("success"),le.current=setTimeout(()=>xe.current(),800))}catch(l){T("error");const x=l instanceof Error?l.message:"";N(Ae(x,"Approval failed."))}}},[re,t,I,m,E.length,g]),Y=c.useCallback(async()=>{if(!t||!y)return;if(E.length>0&&!g){N("Select an option before rejecting this decision.");return}if(g!=null&&g.requiresNote&&I.trim().length===0){N("A note is required for the selected option."),requestAnimationFrame(()=>{var l;return(l=Q.current)==null?void 0:l.focus()});return}let s=!1;if(T(l=>l==="approving"||l==="rejecting"?l:(s=!0,"rejecting")),!!s){N(null);try{const l=await y(t.id,re());l.failed>0?(T("error"),N(Ae(l.firstError,"Rejection failed. Please try again."))):(T("rejected"),le.current=setTimeout(()=>xe.current(),800))}catch(l){T("error");const x=l instanceof Error?l.message:"";N(Ae(x,"Rejection failed."))}}},[re,t,I,y,E.length,g]);if(c.useEffect(()=>{if(!a)return;const s=l=>{var z,R;if((l.metaKey||l.ctrlKey)&&l.key==="Enter"){l.preventDefault(),de();return}const x=(z=l.target)==null?void 0:z.tagName;if(!(x==="INPUT"||x==="TEXTAREA"))switch(l.key){case"j":l.preventDefault(),v==null||v(1);break;case"k":l.preventDefault(),v==null||v(-1);break;case"a":l.preventDefault(),de();break;case"r":l.preventDefault(),Y();break;case"n":l.preventDefault(),(R=Q.current)==null||R.focus();break}};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[a,de,Y,v]),!a||!t)return null;const fe=_==="approving"||_==="rejecting",$e=_==="success"||_==="rejected",ne=(t.status??"pending").toLowerCase(),ge=!ne.includes("approved")&&!ne.includes("resolved")&&!ne.includes("rejected")&&!ne.includes("declined")&&!ne.includes("cancelled"),_e=E.length>0&&!g,be=(g==null?void 0:g.requiresNote)===!0&&I.trim().length===0,M=fe||_e||be,Ce=t.evidenceRefs??[],Te=Ce.length>0,ye=t.recommendedAction??null,Se=t.decisionType??null,we=t.priority??null,D=t.occurrenceCount??null,je=t.sourceRunId??null,ie=[];k&&ie.push({label:k,icon:"initiative"}),j&&ie.push({label:j,icon:"workstream"});const K=[["ID",t.id],["Type",t.decisionType],["Dedupe key",t.dedupeKey],["Source system",t.sourceSystem],["Conflict source",t.conflictSource],["Agent ID",t.agentId],["Source run",t.sourceRunId],["Source session",t.sourceSessionId],["Source stream",t.sourceStreamId]].filter(([,s])=>s!=null);if($e){const s=_==="success",l=s?P.lime:P.red;return e.jsx(Pe,{open:a,onClose:u,maxWidth:"max-w-xl",fitContent:!0,children:e.jsxs("div",{className:"flex flex-col items-center justify-center px-8 py-12",children:[e.jsx("div",{className:"mb-4 flex h-16 w-16 items-center justify-center rounded-full",style:{backgroundColor:`${l}18`,border:`1.5px solid ${l}40`},children:s?e.jsx("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:l,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):e.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:l,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 6L6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})}),e.jsx("p",{className:"text-heading font-semibold text-white",children:s?"Approved":"Rejected"}),e.jsx("p",{className:"mt-1 text-body text-secondary",children:t.title})]})})}return e.jsx(Pe,{open:a,onClose:u,maxWidth:"max-w-xl",children:e.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col",style:oe?{boxShadow:`inset 0 0 0 1px ${P.amber}30`,borderRadius:"inherit"}:void 0,children:[e.jsx("div",{className:"h-[2px] w-full flex-shrink-0",style:{background:`linear-gradient(90deg, ${q}60, ${q}20, transparent)`}}),v&&e.jsxs("div",{className:"flex items-center justify-between px-6 pt-3 pb-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>v(-1),className:"rounded p-1 text-muted hover:text-secondary hover:bg-white/[0.06] transition-colors",title:"Previous (k)",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"m15 18-6-6 6-6"})})}),e.jsx("button",{type:"button",onClick:()=>v(1),className:"rounded p-1 text-muted hover:text-secondary hover:bg-white/[0.06] transition-colors",title:"Next (j)",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"m9 18 6-6-6-6"})})}),C!=null&&o!=null&&e.jsxs("span",{className:"text-micro text-muted tabular-nums",children:[C+1," of ",o,e.jsx("span",{className:"ml-1 hidden sm:inline",children:"· Longest waiting first"})]})]}),e.jsx("button",{type:"button",onClick:u,"aria-label":"Close",className:"rounded p-1 text-muted hover:text-secondary hover:bg-white/[0.06] transition-colors",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})})]}),ie.length>0&&e.jsx("div",{className:"px-6 pt-2",children:e.jsx(He,{segments:ie})}),e.jsxs("div",{className:"flex items-start justify-between gap-3 px-6 pt-4 pb-4",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${q}14`,border:`1px solid ${q}30`},children:e.jsx(ae,{type:"decision",size:14})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-title font-medium leading-tight text-white mb-2",children:t.title||"Decision Required"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-body text-secondary",children:[e.jsx("span",{children:t.agentName||"OrgX Autopilot"}),e.jsx("span",{className:"text-white/[0.15]",children:"|"}),e.jsx("span",{className:oe?"font-semibold text-red-300":"",children:ee(t.waitingMinutes).text}),Se&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-white/[0.15]",children:"|"}),e.jsx("span",{className:"text-primary",children:lt(Se)})]}),we&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-white/[0.15]",children:"|"}),e.jsx("span",{className:"font-medium",style:{color:ot(we)},children:we})]})]}),D!=null&&D>1&&e.jsxs("p",{className:"mt-2 text-caption text-muted",children:["Seen ",D," times",t.firstSeenAt&&e.jsxs(e.Fragment,{children:[" · first ",Re(t.firstSeenAt)]}),t.lastSeenAt&&e.jsxs(e.Fragment,{children:[" · last ",Re(t.lastSeenAt)]})]})]})]})}),!v&&e.jsx("button",{type:"button",onClick:u,"aria-label":"Close",className:"mt-0.5 flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg text-muted transition-colors hover:bg-white/[0.06] hover:text-white",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 6L6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-4",children:[(t.initiativeId||t.workstreamId)&&e.jsx("div",{className:"mb-4",children:e.jsx(Ue,{nodes:Oe({initiativeId:t.initiativeId,initiativeTitle:k,workstreamId:t.workstreamId,workstreamTitle:j,agentName:t.agentName,agentId:t.agentId}),activeId:t.workstreamId,compact:!0})}),ye&&e.jsxs("div",{className:"mb-4 rounded-xl border border-cyan-300/[0.28] bg-cyan-500/[0.12] px-4 py-3",children:[e.jsx("p",{className:"text-micro font-semibold uppercase tracking-wider text-cyan-200 mb-1",children:"Recommended"}),e.jsx("p",{className:"text-body text-cyan-100",children:ye})]}),Te&&e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"mb-2 px-1 text-micro font-semibold uppercase tracking-wider text-muted",children:"Evidence"}),e.jsx("div",{className:"space-y-1.5",children:Ce.map((s,l)=>e.jsx(Ye,{evidenceType:s.evidenceType,title:s.title,summary:s.summary,sourceUrl:s.sourceUrl,confidence:s.confidence,payload:s.payload},l))})]}),oe&&e.jsx("div",{className:"mb-4 rounded-xl border border-amber-400/[0.3] bg-amber-500/[0.08] px-4 py-3",children:e.jsxs("p",{className:"text-body text-amber-200",children:["This decision has been waiting"," ",e.jsx("span",{className:"font-semibold text-amber-100",children:ee(t.waitingMinutes).text}),". Downstream work is paused."]})}),w&&w.headline!==t.title?e.jsxs("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] px-4 py-3",children:[e.jsx("p",{className:"text-micro font-semibold uppercase tracking-wider text-muted mb-2",children:"What happened"}),e.jsx("p",{className:"text-body text-primary leading-relaxed",children:w.explanation}),Object.keys(w.structuredDetails).length>0&&e.jsx("div",{className:"mt-3 flex flex-wrap gap-x-4 gap-y-1 text-caption text-secondary",children:Object.entries(w.structuredDetails).filter(([,s])=>s!=null).map(([s,l])=>e.jsxs("span",{children:[s.replace(/([A-Z])/g," $1").replace(/^./,x=>x.toUpperCase()),": ",l]},s))})]}):b?e.jsx("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] px-4 py-3",children:e.jsx(ze,{text:b,mode:"block"})}):e.jsx("p",{className:"px-1 text-body text-muted italic",children:"No additional context provided."}),(A.rows.length>0||(A.statusUpdatesApplied??0)>0||A.buffered||(A.artifactCount??0)>0||A.hasPr)&&e.jsxs("div",{className:"mt-4 rounded-xl border border-[#14B8A6]/20 bg-[#14B8A6]/[0.06] px-4 py-3",children:[e.jsx("p",{className:"text-micro font-semibold uppercase tracking-wider text-[#7ce0d3] mb-1",children:A.buffered?"Updates being applied":"Expected updates"}),(A.statusUpdatesApplied??0)>0&&e.jsxs("p",{className:"text-caption text-primary",children:[A.statusUpdatesApplied," status update",A.statusUpdatesApplied===1?"":"s",A.buffered?" queued for sync":" planned","."]}),(A.artifactCount??0)>0&&e.jsxs("p",{className:"text-caption text-primary",children:[A.artifactCount," artifact",A.artifactCount===1?"":"s"," expected from this decision path."]}),A.rows.length>0&&e.jsx("ul",{className:"mt-2 space-y-1 pl-4",children:A.rows.map((s,l)=>e.jsxs("li",{className:"text-caption text-secondary",children:[e.jsxs("span",{className:"text-primary",children:[s.scope,": ",s.label]}),s.status?` → ${s.status}`:"",s.note?` · ${s.note}`:""]},`${s.scope}-${s.label}-${l}`))})]}),E.length>0&&e.jsxs("div",{className:"mt-8",children:[e.jsx("p",{className:"mb-3 px-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-muted",children:"Options"}),e.jsx("div",{className:"space-y-1 relative",children:E.map(s=>{const l=U===s.id;return e.jsxs("button",{type:"button",onClick:()=>{O(l?null:s.id),s.requiresNote&&requestAnimationFrame(()=>{var x;return(x=Q.current)==null?void 0:x.focus()})},disabled:fe,className:"group relative flex w-full items-start gap-4 px-4 py-4 text-left focus:outline-none",children:[l&&e.jsx(V.div,{layoutId:"decision-option-bg",className:"absolute inset-0 rounded-xl",style:{backgroundColor:`${P.lime}12`},transition:{type:"spring",stiffness:400,damping:25}}),!l&&e.jsx("div",{className:"absolute inset-0 rounded-xl opacity-0 transition-opacity group-hover:bg-white/[0.03]"}),e.jsx("div",{className:"relative mt-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full border-[1.5px] transition-colors",style:{borderColor:l?P.lime:"rgba(255,255,255,0.2)"},children:e.jsx(De,{children:l&&e.jsx(V.div,{initial:{scale:0},animate:{scale:1},exit:{scale:0},transition:{type:"spring",stiffness:500,damping:30},className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:P.lime}})})}),e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx("span",{className:`block text-[15px] ${l?"font-medium text-white":"text-primary"}`,children:s.label}),s.description&&e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-secondary",children:s.description}),s.consequences&&e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-muted",children:s.consequences}),s.requiresNote&&e.jsx("p",{className:"mt-1.5 text-[11px] font-medium uppercase tracking-wider text-amber-400",children:"Note required"})]})]},s.id)})})]}),ge&&he&&e.jsxs("div",{className:"mt-4",children:[e.jsx("textarea",{ref:Q,value:I,onChange:s=>Z(s.target.value),disabled:fe,placeholder:"Required: add context for this decision...",rows:3,className:"w-full resize-none rounded-xl border border-white/[0.08] bg-white/[0.03] px-4 py-3 text-body text-primary placeholder-white/30 outline-none transition-colors focus:border-white/[0.16] focus:bg-white/[0.04]"}),I.trim().length===0&&e.jsx("p",{className:"mt-2 text-caption text-amber-300",children:"This option requires a note before submission."})]}),se&&e.jsxs("div",{className:"mt-6 rounded-xl border border-white/[0.06] bg-white/[0.02] px-4 py-3",children:[e.jsx("p",{className:"text-micro font-semibold uppercase tracking-wider text-muted mb-2",children:"Impact"}),e.jsx("p",{className:"text-body text-primary leading-relaxed",children:nt(se)}),se.blockedWorkstreams.length>0&&e.jsx("ul",{className:"mt-2 space-y-1 text-caption text-secondary",children:se.blockedWorkstreams.map(s=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block h-1 w-1 rounded-full bg-amber-400 flex-shrink-0"}),s.title,s.status==="blocked"&&e.jsx("span",{className:"text-amber-400 text-micro",children:"(blocked)"})]},s.id))})]}),je&&W&&e.jsx("div",{className:"mt-4",children:e.jsxs("button",{type:"button",onClick:()=>W(je),className:"inline-flex items-center gap-1.5 text-caption text-[#D8FFA1] transition-colors hover:text-white",children:[e.jsx(ae,{type:"session",size:12}),"View source run"]})}),e.jsx("div",{className:"mt-4 border-t border-white/[0.06] pt-4",children:e.jsx(Ke,{entityType:"decision",entityId:t.id})}),K.length>0&&e.jsxs("div",{className:"mt-4 border-t border-white/[0.06] pt-2",children:[e.jsxs("button",{type:"button",onClick:()=>Ne(s=>!s),className:"flex w-full items-center justify-between text-micro font-semibold uppercase tracking-wider text-muted hover:text-secondary transition-colors",children:[e.jsx("span",{children:"Technical details"}),e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:`transition-transform ${me?"rotate-180":""}`,children:e.jsx("path",{d:"m6 9 6 6 6-6"})})]}),me&&e.jsx("div",{className:"mt-2 space-y-0.5",children:K.map(([s,l])=>e.jsxs("div",{className:"flex gap-2 text-micro",children:[e.jsx("span",{className:"text-muted w-28 flex-shrink-0",children:s}),e.jsx("span",{className:"text-secondary truncate",children:l})]},s))})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-x-3 gap-y-1 text-micro text-muted opacity-60",children:[v&&e.jsx("span",{children:"j/k nav"}),e.jsx("span",{children:"a approve"}),e.jsx("span",{children:"r reject"}),e.jsx("span",{children:"n note"}),e.jsxs("span",{children:[Fe?"⌘":"Ctrl","+Enter approve"]}),e.jsx("span",{children:"esc close"})]})]}),S&&e.jsxs("div",{className:"flex items-center gap-2 border-t border-white/[0.06] px-6 py-3",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:P.red,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}),e.jsx("p",{className:"text-caption text-red-300",children:S})]}),ge&&e.jsx("div",{className:"relative mt-auto border-t border-white/[0.04] bg-black/60 px-6 py-5 backdrop-blur-xl",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[y&&e.jsx(V.button,{whileTap:{scale:.97},type:"button",onClick:Y,disabled:M,className:"rounded-lg px-4 py-2 text-[14px] font-medium text-secondary transition-colors hover:text-red-400 disabled:opacity-40 focus:outline-none",children:_==="rejecting"?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block h-3 w-3 animate-spin rounded-full border-[1.5px] border-current border-t-transparent"}),"Rejecting"]}):"Reject"}),e.jsx("button",{type:"button",onClick:ce,className:"rounded-lg px-2 py-2 text-[13px] text-muted transition-colors hover:text-secondary focus:outline-none",title:"Copy decision as JSON",children:ke?"Copied":"Copy JSON"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"hidden text-[13px] text-muted sm:block",children:[Fe?"⌘":"Ctrl","+Enter"]}),e.jsx(V.button,{whileTap:!m||M?void 0:{scale:.97},type:"button",onClick:de,disabled:!m||M,"data-modal-autofocus":"true",className:"rounded-lg px-6 py-2.5 text-[14px] font-semibold transition-all focus:outline-none",style:{backgroundColor:!m||M?"rgba(255,255,255,0.06)":P.lime,color:!m||M?"rgba(255,255,255,0.4)":"#000"},children:_==="approving"?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block h-3 w-3 animate-spin rounded-full border-[1.5px] border-black/40 border-t-black"}),"Approving"]}):"Approve"})]})]})})]})})}const Ie=40;function Me(a,t){return!a||a.trim().length===0?t:We(a.trim())||t}function Ee(a,t,u){const m=a==="approve"?`Approval failed for ${t} decision${t===1?"":"s"}.`:`Rejection failed for ${t} decision${t===1?"":"s"}.`;return Me(u,m)}function qe(a){return a>=1440?"overdue":a>=60?"urgent":"normal"}function dt(a){return a.length>=32?a.slice(0,8):a}function Be({group:a}){const t=qe(a.worstWaitingMinutes),u=a.decisions.length;return e.jsxs(V.div,{initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.22,ease:[.22,1,.36,1]},className:"flex items-center gap-2 px-1 pb-1 pt-2.5 first:pt-0",children:[e.jsx("span",{className:"text-caption font-semibold text-white/70 truncate",children:a.label}),e.jsxs("span",{className:"text-micro text-muted whitespace-nowrap",children:["(",u," decision",u===1?"":"s",")"]}),t==="overdue"&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-red-500/[0.12] px-1.5 py-0.5 text-micro font-medium text-red-400",children:[e.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 rounded-full bg-red-400"}),"overdue"]}),t==="urgent"&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-amber-400/[0.12] px-1.5 py-0.5 text-micro font-medium text-amber-400",children:[e.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 rounded-full bg-amber-400"}),"urgent"]})]})}function ut(a,t){return`${a}_${t}`}const jt=c.memo(function({decisions:t,focusDecisionId:u=null,onFocusDecisionHandled:m,onApproveDecision:y,onRejectDecision:k,onApproveAll:j,onBulkDecisionAction:v,mutationState:C,showHeader:o=!0,panelStyle:W="card",className:B,initiativeNames:_}){var X;const T=Xe(),[S,N]=c.useState(!1),[U,O]=c.useState(new Set),[I,Z]=c.useState(new Set),[ke,te]=c.useState(new Set),{enqueue:me,ToastRenderer:Ne}=Je(),[Q,le]=c.useState("approve_selected"),[xe,F]=c.useState(""),[G,w]=c.useState(null),[se,oe]=c.useState(Ie),[E,g]=c.useState(null),he=c.useRef(null),b=c.useMemo(()=>{const n=new Set;return[...t].filter(r=>n.has(r.id)?!1:(n.add(r.id),!0)).sort((r,i)=>{if(r.waitingMinutes!==i.waitingMinutes)return i.waitingMinutes-r.waitingMinutes;const d=Date.parse(r.requestedAt??r.updatedAt??""),p=Date.parse(i.requestedAt??i.updatedAt??""),f=Number.isFinite(d)?d:0;return(Number.isFinite(p)?p:0)-f})},[t]);c.useEffect(()=>{Z(n=>{const r=new Set(b.map(d=>d.id)),i=new Set;for(const d of n)r.has(d)&&i.add(d);return i})},[b]);const A=I.size,q=c.useMemo(()=>b.filter(n=>!ke.has(n.id)).slice(0,se),[b,se,ke]),ce=c.useMemo(()=>{const n=new Map,r=[];for(const d of q){const p=d.initiativeId??"_unscoped";let f=n.get(p);f||(f=[],n.set(p,f),r.push(p)),f.push(d)}const i=r.map(d=>{const p=n.get(d),f=Math.max(0,...p.map(H=>H.waitingMinutes)),$=d==="_unscoped"?"General":(_==null?void 0:_[d])??dt(d);return{initiativeId:d,label:$,decisions:p,worstWaitingMinutes:f}});return i.sort((d,p)=>p.worstWaitingMinutes-d.worstWaitingMinutes),i},[q,_]),re=c.useMemo(()=>{if(q.length===0)return!1;for(const n of q)if(!I.has(n.id))return!1;return!0},[I,q]),de=c.useMemo(()=>E?b.find(n=>n.id===E)??null:null,[E,b]),Y=c.useMemo(()=>E?b.findIndex(n=>n.id===E):-1,[E,b]),fe=c.useCallback(n=>{const r=Y+n;r>=0&&r<b.length&&g(b[r].id)},[Y,b]),$e=async(n,r)=>{w(null),O(d=>{const p=new Set(d);return p.add(n),p});const i=await y(n,r);return i.failed>0?w(Ee("approve",i.failed,i.firstError)):i.updated>0&&w("Decision approved. Changes synced."),O(d=>{const p=new Set(d);return p.delete(n),p}),i},ne=k?async(n,r)=>{w(null),O(d=>{const p=new Set(d);return p.add(n),p});const i=await k(n,r);return i.failed>0?w(Ee("reject",i.failed,i.firstError)):i.updated>0&&w("Decision rejected. Changes synced."),O(d=>{const p=new Set(d);return p.delete(n),p}),i}:void 0;c.useEffect(()=>{oe(n=>b.length===0?0:Math.min(Math.max(Ie,n),b.length))},[b.length]),c.useEffect(()=>{const n=(u??"").trim();if(!n){he.current=null;return}he.current===n||!b.some(i=>i.id===n)||(he.current=n,g(n),m==null||m(n))},[u,m,b]);const ge=n=>{Z(r=>{const i=new Set(r);return i.has(n)?i.delete(n):i.add(n),i})},_e=()=>{Z(n=>{if(q.length===0)return n;const r=new Set(n),i=re;for(const d of q)i?r.delete(d.id):r.add(d.id);return r})},be=c.useMemo(()=>{const n=b.map(i=>i.id).filter(i=>I.has(i)),r=q.map(i=>i.id);return[{id:"approve_selected",label:`Approve selected (${n.length})`,action:"approve",ids:n},{id:"reject_selected",label:`Reject selected (${n.length})`,action:"reject",ids:n,hidden:!k},{id:"approve_visible",label:`Approve visible (${r.length})`,action:"approve",ids:r},{id:"reject_visible",label:`Reject visible (${r.length})`,action:"reject",ids:r,hidden:!k}].filter(i=>!i.hidden)},[k,I,b,q]),M=c.useMemo(()=>be.find(n=>n.id===Q)??be[0]??null,[Q,be]),Ce=async(n,r,i)=>{if(n.length===0)return{updated:0,failed:0};if(r==="approve"&&n.length===b.length&&!i)return j();let d=0,p=0,f;for(const $ of n)try{const H=r==="approve"?await y($,i?{note:i}:void 0):k?await k($,i?{note:i}:void 0):{updated:0,failed:1};d+=H.updated,p+=H.failed,!f&&H.firstError&&(f=H.firstError)}catch{p+=1}return{updated:d,failed:p,firstError:f}},Te=async()=>{if(!M||S)return;const n=M.ids;if(n.length===0){w("No decisions selected for this action.");return}w(null),N(!0),O(new Set(n));const r=xe.trim();try{const i=v?await v(n,M.action,r.length>0?r:void 0):await Ce(n,M.action,r.length>0?r:void 0),d=M.action==="approve"?"Approved":"Rejected";if(i.failed>0){const p=`${d} ${i.updated}; ${i.failed} failed.`,f=Me(i.firstError,p);w(f===p?p:`${p} ${f}`)}else i.updated>0?w(`${d} ${i.updated} decision${i.updated===1?"":"s"}.`):w("No decisions were updated.");Z(new Set)}catch(i){const d=i instanceof Error?i.message:"";w(Me(d,"Bulk decision action failed."))}finally{N(!1),O(new Set)}},ye=async n=>{if(!(U.has(n)||S)){w(null),O(r=>{const i=new Set(r);return i.add(n),i});try{const r=await y(n);r.failed>0?w(Ee("approve",r.failed,r.firstError)):r.updated>0&&w("Decision approved.")}catch(r){const i=r instanceof Error?r.message:"";w(Me(i,"Decision approval failed."))}finally{O(r=>{const i=new Set(r);return i.delete(n),i}),Z(r=>{if(!r.has(n))return r;const i=new Set(r);return i.delete(n),i})}}},Se=c.useCallback(n=>{U.has(n.id)||S||(te(r=>new Set(r).add(n.id)),me({message:`Approved '${n.title.length>40?n.title.slice(0,40)+"…":n.title}'`,onUndo:()=>{te(r=>{const i=new Set(r);return i.delete(n.id),i})},onCommit:()=>{te(r=>{const i=new Set(r);return i.delete(n.id),i}),y(n.id).catch(()=>{w("Approval failed. Try again from the decision panel.")})}}))},[U,S,me,y]);c.useEffect(()=>{if(!G)return;const n=window.setTimeout(()=>w(null),5200);return()=>window.clearTimeout(n)},[G]);const we=G!==null&&!G.toLowerCase().includes("fail"),D=S||U.size>0,je=Math.max(U.size,S?A:0),ie=D?`Applying ${je} decision action${je===1?"":"s"}…`:G??null,K=D?"processing":G?we?"success":"warning":"idle",s=!T&&q.length<=32,l=M!==null&&M.ids.length>0&&!S,x=b.length;(X=b[0])==null||X.waitingMinutes;const z=M!=null&&M.id.includes("visible")?"visible":"selected",R=(M==null?void 0:M.action)??"approve",L=ie!==null||K!=="idle",h=W==="card"?Ge:"div";return e.jsxs(h,{className:ue("flex h-full min-h-0 flex-col",W==="card"&&"card-enter",B),children:[e.jsx(ct,{open:E!==null,decision:de,onClose:()=>g(null),onApprove:$e,onReject:ne,onNavigate:fe,currentIndex:Y>=0?Y:void 0,totalCount:b.length}),o?e.jsxs("div",{className:"space-y-2.5 border-b border-subtle px-4 py-3.5",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h2",{className:"inline-flex items-center gap-2 text-heading font-semibold text-white",children:[e.jsx(ae,{type:"decision",size:14}),"Decisions"]}),e.jsx("p",{className:"mt-0.5 text-caption text-secondary",children:x>0?`${x} decision${x===1?"":"s"} need${x===1?"s":""} your input`:"All clear — no decisions pending"})]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[b.length>0&&e.jsx("button",{onClick:_e,disabled:D,className:"control-pill h-8 flex-shrink-0 px-3 text-caption font-semibold disabled:opacity-45",children:re?"Clear all":"Select all"}),A>0&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:Te,disabled:!l||D,"data-state":l?"active":"idle",className:"control-pill h-8 flex-shrink-0 px-3 text-caption font-semibold disabled:opacity-45",children:S?"Approving…":`Approve ${A} selected`}),k&&e.jsx("button",{type:"button",onClick:()=>le(ut("reject",z)),disabled:D,"data-state":R==="reject"?"active":"idle",className:ue("control-pill h-8 px-2.5 text-caption font-semibold disabled:opacity-45",R==="reject"&&"border-amber-300/35 bg-amber-400/[0.12] text-amber-100"),children:"Reject"})]})]}),L?e.jsxs(V.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.22,ease:[.22,1,.36,1]},"aria-live":"polite",className:ue("flex min-h-[32px] items-center gap-2 rounded-lg border px-2.5 py-1.5 text-caption transition-colors overflow-hidden",K==="processing"?"border-amber-300/25 bg-amber-400/[0.08] text-amber-100":K==="success"?"border-lime/30 bg-lime/10 text-lime":K==="warning"?"border-red-400/25 bg-red-500/[0.08] text-red-100":"border-strong bg-white/[0.02] text-secondary"),children:[K==="processing"?e.jsx("span",{"aria-hidden":!0,className:"h-3.5 w-3.5 rounded-full border-2 border-amber-200/45 border-t-transparent animate-spin"}):K==="success"?e.jsx(ae,{type:"decision",size:12,className:"opacity-90"}):K==="warning"?e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"opacity-90",children:[e.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"}),e.jsx("line",{x1:"12",x2:"12",y1:"9",y2:"13"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"17",y2:"17"})]}):e.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 rounded-full bg-white/35"}),e.jsx("span",{className:"min-w-0 truncate",children:ie})]}):null]}):null,e.jsxs("div",{className:ue("min-h-0 flex-1 space-y-2 overflow-y-auto",o?"p-3":"p-0"),children:[b.length===0&&e.jsx(V.div,{initial:{opacity:0,scale:.97},animate:{opacity:1,scale:1},transition:{duration:.28,ease:[.22,1,.36,1]},className:"flex flex-col items-center gap-2.5 rounded-xl border border-subtle bg-white/[0.02] p-4 text-center",children:D?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,className:"h-5 w-5 rounded-full border-2 border-amber-200/45 border-t-transparent animate-spin"}),e.jsx("p",{className:"text-body text-secondary",children:"Finalizing decision updates…"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-faint",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),e.jsx("p",{className:"text-body text-secondary",children:"No pending decisions. All clear."})]})}),s?e.jsx(De,{mode:"popLayout",children:ce.map(n=>e.jsxs("div",{children:[ce.length>1&&e.jsx(Be,{group:n}),n.decisions.map((r,i)=>{const d=U.has(r.id),p=I.has(r.id),f=qe(r.waitingMinutes);return e.jsx(V.article,{role:"button",tabIndex:0,onClick:()=>g(r.id),onKeyDown:$=>{($.key==="Enter"||$.key===" ")&&($.preventDefault(),g(r.id))},drag:!D&&!d?"x":!1,dragConstraints:{left:0,right:0},dragElastic:.3,onDragEnd:($,H)=>{H.offset.x>120&&Se(r)},initial:S?{opacity:0,x:300}:{opacity:0,y:8,scale:.98},animate:{opacity:1,y:0,x:0,scale:1},exit:{opacity:0,x:300,scale:.95,boxShadow:"0 0 12px 4px rgba(191, 255, 0, 0.15)"},transition:{duration:.25,ease:[.22,1,.36,1],...S?{delay:i*.04}:{}},layout:!0,className:"mt-1.5 rounded-xl border bg-white/[0.03] px-3 py-2.5 transition-[border-color,box-shadow] cv-auto",style:{borderColor:p?`${P.lime}50`:"rgba(255, 255, 255, 0.1)",boxShadow:p?"0 0 0 1px rgba(191, 255, 0, 0.14)":"none"},children:e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("input",{type:"checkbox",checked:p,onChange:()=>ge(r.id),disabled:d||D,onClick:$=>$.stopPropagation(),className:"mt-0.5 h-4 w-4 rounded border-white/20 bg-black/40 text-lime focus:ring-lime/40"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-1.5",children:[f!=="normal"&&e.jsx("span",{"aria-label":f==="overdue"?"Overdue":"Urgent",className:ue("mt-[5px] h-2 w-2 flex-shrink-0 rounded-full",f==="overdue"?"bg-red-400":"bg-amber-400")}),e.jsxs("p",{className:"flex min-w-0 items-start gap-1.5 text-body font-medium text-white",title:r.title,children:[e.jsx(ae,{type:"decision",size:12,className:"mt-[3px] flex-shrink-0 opacity-90"}),e.jsx("span",{className:"line-clamp-2",children:r.title})]})]}),r.context&&e.jsx("p",{className:"mt-1 line-clamp-2 text-caption text-secondary",title:r.context,children:r.context}),e.jsxs("div",{className:"mt-1.5 flex items-center justify-between gap-2",children:[e.jsxs("p",{className:`min-w-0 truncate text-micro ${(()=>{const $=ee(r.waitingMinutes);return $.tone==="urgent"?"text-red-400":$.tone==="attention"?"text-amber-400":"text-muted"})()}`,title:`${r.agentName??"OrgX Autopilot"} · ${ee(r.waitingMinutes).text}`,children:[r.agentName??"OrgX Autopilot"," · ",ee(r.waitingMinutes).text]}),e.jsx("button",{onClick:$=>{$.stopPropagation(),ye(r.id)},disabled:d||D,className:"flex-shrink-0 rounded-md border border-lime/25 bg-lime/10 px-2.5 py-1 text-micro font-semibold text-lime transition-colors hover:bg-lime/20 disabled:cursor-not-allowed disabled:border-white/10 disabled:bg-white/[0.08] disabled:text-secondary",children:d?"Approving…":"Approve"}),k&&e.jsx("button",{onClick:$=>{$.stopPropagation(),g(r.id)},disabled:d||D,className:"flex-shrink-0 rounded-md border border-white/[0.08] bg-white/[0.03] px-2.5 py-1 text-micro font-semibold text-secondary transition-colors hover:border-red-400/30 hover:bg-red-400/[0.08] hover:text-red-300 disabled:cursor-not-allowed disabled:opacity-40",children:"Reject"})]})]})})]})},r.id)})]},n.initiativeId))}):e.jsx(e.Fragment,{children:ce.map(n=>e.jsxs("div",{children:[ce.length>1&&e.jsx(Be,{group:n}),n.decisions.map(r=>{const i=U.has(r.id),d=I.has(r.id),p=qe(r.waitingMinutes);return e.jsx("article",{role:"button",tabIndex:0,onClick:()=>g(r.id),onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),g(r.id))},className:"mt-1.5 rounded-xl border bg-white/[0.03] px-3 py-2.5 transition-[border-color,box-shadow] cv-auto",style:{borderColor:d?`${P.lime}50`:"rgba(255, 255, 255, 0.1)",boxShadow:d?"0 0 0 1px rgba(191, 255, 0, 0.14)":"none"},children:e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("input",{type:"checkbox",checked:d,onChange:()=>ge(r.id),disabled:i||D,onClick:f=>f.stopPropagation(),className:"mt-0.5 h-4 w-4 rounded border-white/20 bg-black/40 text-lime focus:ring-lime/40"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-1.5",children:[p!=="normal"&&e.jsx("span",{"aria-label":p==="overdue"?"Overdue":"Urgent",className:ue("mt-[5px] h-2 w-2 flex-shrink-0 rounded-full",p==="overdue"?"bg-red-400":"bg-amber-400")}),e.jsxs("p",{className:"flex min-w-0 items-start gap-1.5 text-body font-medium text-white",title:r.title,children:[e.jsx(ae,{type:"decision",size:12,className:"mt-[3px] flex-shrink-0 opacity-90"}),e.jsx("span",{className:"line-clamp-2",children:r.title})]})]}),r.context&&e.jsx("p",{className:"mt-1 line-clamp-2 text-caption text-secondary",title:r.context,children:r.context}),e.jsxs("div",{className:"mt-1.5 flex items-center justify-between gap-2",children:[e.jsxs("p",{className:`min-w-0 truncate text-micro ${(()=>{const f=ee(r.waitingMinutes);return f.tone==="urgent"?"text-red-400":f.tone==="attention"?"text-amber-400":"text-muted"})()}`,title:`${r.agentName??"OrgX Autopilot"} · ${ee(r.waitingMinutes).text}`,children:[r.agentName??"OrgX Autopilot"," · ",ee(r.waitingMinutes).text]}),e.jsx("button",{onClick:f=>{f.stopPropagation(),ye(r.id)},disabled:i||D,className:"flex-shrink-0 rounded-md border border-lime/25 bg-lime/10 px-2.5 py-1 text-micro font-semibold text-lime transition-colors hover:bg-lime/20 disabled:cursor-not-allowed disabled:border-white/10 disabled:bg-white/[0.08] disabled:text-secondary",children:i?"Approving…":"Approve"}),k&&e.jsx("button",{onClick:f=>{f.stopPropagation(),g(r.id)},disabled:i||D,className:"flex-shrink-0 rounded-md border border-white/[0.08] bg-white/[0.03] px-2.5 py-1 text-micro font-semibold text-secondary transition-colors hover:border-red-400/30 hover:bg-red-400/[0.08] hover:text-red-300 disabled:cursor-not-allowed disabled:opacity-40",children:"Reject"})]})]})})]})},r.id)})]},n.initiativeId))}),q.length<b.length&&e.jsxs("button",{onClick:()=>oe(n=>Math.min(b.length,n+Ie)),className:"w-full rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2 text-caption text-secondary transition-colors hover:bg-white/[0.05]",children:["Load more (",b.length-q.length," remaining)"]})]}),e.jsx(Ne,{})]})});export{jt as DecisionQueue};