bunqueue-dashboard 0.0.34 → 0.0.36

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 (174) hide show
  1. package/README.md +20 -13
  2. package/agent/backup/processExecutor.ts +90 -0
  3. package/agent/backup/resultValidation.ts +85 -0
  4. package/agent/backup/routes.ts +160 -0
  5. package/agent/backup/runner.ts +91 -0
  6. package/agent/backup/standaloneWorker.ts +23 -0
  7. package/agent/backup/workerExecutor.ts +40 -0
  8. package/agent/backup/workerFactory.ts +21 -0
  9. package/agent/backup/workerProtocol.ts +10 -0
  10. package/agent/db/core.ts +141 -0
  11. package/agent/db/csvExport.ts +172 -0
  12. package/agent/db/exportTimeout.ts +190 -0
  13. package/agent/db/query.ts +82 -0
  14. package/agent/db/queryTimeout.ts +76 -0
  15. package/agent/db/schema.ts +79 -0
  16. package/agent/db/tables.ts +157 -0
  17. package/agent/db/types.ts +118 -0
  18. package/agent/db/workerFactory.ts +25 -0
  19. package/agent/db.ts +43 -1099
  20. package/agent/errorMessage.ts +9 -0
  21. package/agent/flow/routes.ts +250 -0
  22. package/agent/flow/service.ts +266 -0
  23. package/agent/flow/types.ts +34 -0
  24. package/agent/flow/validation.ts +230 -0
  25. package/agent/index.ts +5 -17
  26. package/agent/logger.ts +121 -17
  27. package/agent/managedTarget.ts +43 -0
  28. package/agent/manager/config.ts +84 -0
  29. package/agent/manager/logs.ts +83 -0
  30. package/agent/manager/process.ts +233 -0
  31. package/agent/manager/storage.ts +28 -0
  32. package/agent/manager/types.ts +38 -0
  33. package/agent/manager.ts +10 -490
  34. package/agent/queue/routes.ts +128 -0
  35. package/agent/queue/runtime.ts +119 -0
  36. package/agent/queue/types.ts +34 -0
  37. package/agent/queue/validation.ts +100 -0
  38. package/agent/server/controlRoutes.ts +153 -0
  39. package/agent/server/databaseRoutes.ts +165 -0
  40. package/agent/server/errors.ts +48 -0
  41. package/agent/server/handler.ts +146 -0
  42. package/agent/server/jsonBody.ts +109 -0
  43. package/agent/server/lifecycle.ts +72 -0
  44. package/agent/server/managedRuntime.ts +41 -0
  45. package/agent/server/policy.ts +60 -0
  46. package/agent/server/router.ts +150 -0
  47. package/agent/server/types.ts +39 -0
  48. package/agent/server/workflowReadRoutes.ts +80 -0
  49. package/agent/server.ts +16 -369
  50. package/agent/shutdown.ts +156 -0
  51. package/agent/workflow/codec.ts +78 -0
  52. package/agent/workflow/detail.ts +63 -0
  53. package/agent/workflow/list.ts +87 -0
  54. package/agent/workflow/runtime.ts +274 -0
  55. package/agent/workflow/runtimeConfig.ts +103 -0
  56. package/agent/workflow/runtimeRoutes.ts +162 -0
  57. package/agent/workflow/sqlite.ts +52 -0
  58. package/agent/workflow/stats.ts +79 -0
  59. package/agent/workflow/types.ts +81 -0
  60. package/agent/workflow/validation.ts +114 -0
  61. package/agent/workflows.ts +16 -0
  62. package/dist/.vite/manifest.json +619 -246
  63. package/dist/assets/AddJob-UUa2fSXE.js +3 -0
  64. package/dist/assets/Alerts-7oGYfQMb.js +1 -0
  65. package/dist/assets/{AreaChart-REK4ZsTC.js → AreaChart-w0ruozXH.js} +1 -1
  66. package/dist/assets/Benchmark-C2NFp_kj.js +1 -0
  67. package/dist/assets/BulkAddJobs-CL4yBae-.js +5 -0
  68. package/dist/assets/Button-BPqpRZJD.js +1 -0
  69. package/dist/assets/Card-C7NMhqUt.js +1 -0
  70. package/dist/assets/{CopilotPanel-CIXpcwkH.js → CopilotPanel-BQ2Cgo9p.js} +3 -3
  71. package/dist/assets/Cron-DfWBhoBf.js +1 -0
  72. package/dist/assets/CronManager-DAK7RSOX.js +1 -0
  73. package/dist/assets/Database-DqL7giEj.js +3 -0
  74. package/dist/assets/Diagnostics-D98YwN-6.js +1 -0
  75. package/dist/assets/Dlq-BHmA5PTI.js +1 -0
  76. package/dist/assets/DlqControl-DihxvP-i.js +1 -0
  77. package/dist/assets/DlqPro-ncgnDtpE.js +1 -0
  78. package/dist/assets/Flows-B5N5Cil0.js +2 -0
  79. package/dist/assets/JobInspector-B40nFiGh.js +2 -0
  80. package/dist/assets/Jobs-Bla3IEef.js +1 -0
  81. package/dist/assets/JobsPro-CnczVx7x.js +1 -0
  82. package/dist/assets/Logs-T91Q3cH0.js +1 -0
  83. package/dist/assets/LogsPro-CMn6-Wwv.js +1 -0
  84. package/dist/assets/{McpServer-D5rwBg74.js → McpServer-BQBabwW-.js} +2 -2
  85. package/dist/assets/Metrics-DxT_RI2B.js +1 -0
  86. package/dist/assets/MetricsPro-Cjen-nAP.js +1 -0
  87. package/dist/assets/Overview-XN2ej8ph.js +1 -0
  88. package/dist/assets/PageHeader-BXlZSBcc.js +1 -0
  89. package/dist/assets/Pagination-Q-vf4hsX.js +1 -0
  90. package/dist/assets/QueueActions-C-Aferd6.js +1 -0
  91. package/dist/assets/QueueControl-B8Q9NX6t.js +1 -0
  92. package/dist/assets/QueueDetail-BMhG0jUB.js +1 -0
  93. package/dist/assets/QueueDetailPro-BKTTyLR4.js +1 -0
  94. package/dist/assets/Queues-COqPMoY9.js +1 -0
  95. package/dist/assets/QueuesOverview-pWdrPy8Z.js +1 -0
  96. package/dist/assets/S3Backup-BmsZ8xtq.js +1 -0
  97. package/dist/assets/S3BackupPro-AtlsPUJL.js +3 -0
  98. package/dist/assets/ServerControl-D3XwHr72.js +3 -0
  99. package/dist/assets/Settings-BofKZoHn.js +1 -0
  100. package/dist/assets/StatusBadge-B0I7hNBX.js +1 -0
  101. package/dist/assets/Usage-DAR9E22v.js +1 -0
  102. package/dist/assets/UsagePro-Bc30N2Lo.js +1 -0
  103. package/dist/assets/Webhooks-Bg2k1PU4.js +1 -0
  104. package/dist/assets/Workers-BqUZMJVQ.js +1 -0
  105. package/dist/assets/WorkersPro-C9aSadUh.js +1 -0
  106. package/dist/assets/Workflows-BEFMfHmo.js +1 -0
  107. package/dist/assets/api-CQ5Z7xR7.js +1 -0
  108. package/dist/assets/bq-BeBxa743.js +1 -0
  109. package/dist/assets/cn-zFEt5SO8.js +1 -0
  110. package/dist/assets/connectionStore-DbBYqHEY.js +1 -0
  111. package/dist/assets/controlConnectionEpoch-CFSO6237.js +1 -0
  112. package/dist/assets/feedback-BnGE2oW2.js +1 -0
  113. package/dist/assets/{flowMutationSafety-DVD1IMr-.js → flowMutationSafety-CoOp94wS.js} +1 -1
  114. package/dist/assets/{form-DsUq0w8s.js → form-tC20r4Ma.js} +1 -1
  115. package/dist/assets/format-Cg7VCIZW.js +1 -0
  116. package/dist/assets/icons-CIvFfU2b.js +1 -0
  117. package/dist/assets/index-Cui9IwWy.js +8 -0
  118. package/dist/assets/index-DOze4TKg.css +1 -0
  119. package/dist/assets/install-Cd9Is10G.js +3 -0
  120. package/dist/assets/{react-vendor-Bjui4wS4.js → react-vendor-CyjgmGTq.js} +3 -3
  121. package/dist/assets/responses-kPO4rSu5.js +1 -0
  122. package/dist/assets/toastStore-CS_9Xndn.js +1 -0
  123. package/dist/assets/{upstreamPaths-nG8N1XAz.js → upstreamPaths-D_LPsv7b.js} +1 -1
  124. package/dist/assets/usePolledData-DzlUpBOO.js +1 -0
  125. package/dist/assets/{useServerActionGuard-CItj3hvh.js → useServerActionGuard-BlH-Kso1.js} +1 -1
  126. package/dist/assets/useThroughputSeries-C2pa1Wd_.js +1 -0
  127. package/dist/index.html +17 -6
  128. package/package.json +15 -3
  129. package/scripts/embedded.gen.ts +152 -124
  130. package/scripts/serve.ts +96 -484
  131. package/scripts/serveHandler.ts +217 -0
  132. package/scripts/servePolicy.ts +133 -0
  133. package/dist/assets/AddJob-Cih9F84t.js +0 -3
  134. package/dist/assets/Alerts-Dp4Vclez.js +0 -1
  135. package/dist/assets/Benchmark-X_gdZun5.js +0 -1
  136. package/dist/assets/BulkAddJobs-CXTpYMZf.js +0 -5
  137. package/dist/assets/Cron-DUHkse77.js +0 -1
  138. package/dist/assets/CronManager-BeYrLK2E.js +0 -1
  139. package/dist/assets/Database-CXPb3XGr.js +0 -3
  140. package/dist/assets/Diagnostics-DDtoiDYT.js +0 -1
  141. package/dist/assets/Dlq-CX_uRblW.js +0 -1
  142. package/dist/assets/DlqControl-CazFmSEd.js +0 -1
  143. package/dist/assets/DlqPro-HSffdtLJ.js +0 -1
  144. package/dist/assets/Flows-CGmyghKF.js +0 -1
  145. package/dist/assets/JobInspector-B9i1HnG5.js +0 -2
  146. package/dist/assets/Jobs-BZGtMnJI.js +0 -1
  147. package/dist/assets/JobsPro-tmEN8f-P.js +0 -1
  148. package/dist/assets/Logs-DxUD9V2A.js +0 -1
  149. package/dist/assets/LogsPro-BTQhvPKj.js +0 -1
  150. package/dist/assets/Metrics-CSPpBf1m.js +0 -1
  151. package/dist/assets/MetricsPro-DSn-3qNT.js +0 -1
  152. package/dist/assets/Overview-StvHYRZ5.js +0 -1
  153. package/dist/assets/Pagination-eotgGQf9.js +0 -1
  154. package/dist/assets/QueueActions-CibRLzrz.js +0 -1
  155. package/dist/assets/QueueControl-DwYNcMfI.js +0 -1
  156. package/dist/assets/QueueDetail-NMfKwj6E.js +0 -1
  157. package/dist/assets/QueueDetailPro-C8SBjX09.js +0 -1
  158. package/dist/assets/Queues-BeTAi8V8.js +0 -1
  159. package/dist/assets/QueuesOverview-BfQO8NS4.js +0 -1
  160. package/dist/assets/S3Backup-BYkAtONl.js +0 -1
  161. package/dist/assets/S3BackupPro-BP1Ch54R.js +0 -2
  162. package/dist/assets/ServerControl-C85jYgyN.js +0 -3
  163. package/dist/assets/Settings-DjP28c_5.js +0 -1
  164. package/dist/assets/Usage-DECeEsO2.js +0 -1
  165. package/dist/assets/UsagePro-CD7dgt3d.js +0 -1
  166. package/dist/assets/Webhooks-Ct-x8DD1.js +0 -1
  167. package/dist/assets/Workers-lP1BXHFq.js +0 -1
  168. package/dist/assets/WorkersPro-CAUqy3Cp.js +0 -1
  169. package/dist/assets/cn-CMFYpumL.js +0 -1
  170. package/dist/assets/connectionStore-Cd9-3Fw0.js +0 -1
  171. package/dist/assets/index-BWoUj86M.css +0 -1
  172. package/dist/assets/index-Dr__4DsT.js +0 -8
  173. package/dist/assets/install-DPCcfOYo.js +0 -3
  174. package/dist/assets/useThroughputSeries-Bpyg6Jaq.js +0 -1
@@ -0,0 +1 @@
1
+ import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,r,t as i}from"./react-vendor-CyjgmGTq.js";import{t as a}from"./bq-BeBxa743.js";import{t as o}from"./toastStore-CS_9Xndn.js";import{C as s,T as c,a as l,d as u,f as d,u as f}from"./icons-CIvFfU2b.js";import{n as p}from"./usePolledData-DzlUpBOO.js";import{n as m,t as h}from"./Button-BPqpRZJD.js";import{i as g,n as _,r as v,t as y}from"./feedback-BnGE2oW2.js";import{t as b}from"./PageHeader-BXlZSBcc.js";import{a as x,i as S,l as C,s as w}from"./format-Cg7VCIZW.js";import{a as T,n as E}from"./index-Cui9IwWy.js";import{a as D}from"./form-tC20r4Ma.js";import{t as O}from"./Pagination-Q-vf4hsX.js";import{r as k,t as A}from"./flowMutationSafety-CoOp94wS.js";import{t as j}from"./exportFile-C7xhE8Yh.js";import{t as M}from"./QueueControl-B8Q9NX6t.js";var N=e(n(),1),P=i();function F({queue:e,data:t,reasons:n,topReason:r}){return(0,P.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,P.jsx)(E,{label:`Entries`,value:e&&t?w(t.total):`—`,tone:!e||!t?`default`:t.total?`red`:`green`,hint:!e||!t?`waiting for queue data`:t.total?r?`top: ${r}`:void 0:`queue is clean`,compact:!0}),(0,P.jsx)(E,{label:`Failure types`,value:t?.stats?w(n.length):`—`,hint:`distinct reasons`,compact:!0}),(0,P.jsx)(E,{label:`Pending retry`,value:t?.stats?w(t.stats.pendingRetry??0):`—`,tone:t?.stats?.pendingRetry?`amber`:`default`,hint:`auto-retry queued`,compact:!0}),(0,P.jsx)(E,{label:`Oldest entry`,value:t?.stats?.oldestEntry?C(t.stats.oldestEntry):`—`,hint:`time in DLQ`,compact:!0})]})}function I({queue:e,queues:t,reason:n,reasons:r,byReason:i,search:a,pageScoped:o,onQueue:s,onReason:l,onSearch:u}){return(0,P.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,P.jsx)(`div`,{className:`w-56`,children:(0,P.jsx)(D,{value:e,"aria-label":`Queue`,name:`dlq-control-queue`,autoComplete:`off`,onChange:e=>s(e.target.value),children:t.map(e=>(0,P.jsxs)(`option`,{value:e.name,children:[e.name,` `,e.dlq?`(${e.dlq})`:``]},e.name))})}),(0,P.jsx)(`div`,{className:`w-44`,children:(0,P.jsxs)(D,{value:n,"aria-label":`Filter by reason`,name:`dlq-control-reason`,autoComplete:`off`,onChange:e=>l(e.target.value),children:[(0,P.jsx)(`option`,{value:`all`,children:`All reasons`}),r.map(e=>(0,P.jsxs)(`option`,{value:e,children:[e,` (`,i[e],`)`]},e))]})}),(0,P.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,P.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,P.jsx)(`input`,{value:a,onChange:e=>u(e.target.value),placeholder:o?`Filter this page by job ID…`:`Filter by job ID…`,"aria-label":`Filter by job ID`,name:`dlq-control-job-filter`,autoComplete:`off`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]})}function L({entry:e,isOpen:n,onToggle:i,attempts:a}){return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`tr`,{className:`border-b border-line align-top last:border-0 hover:bg-surface-2/40`,children:[(0,P.jsx)(`td`,{className:`py-3 pl-4`,children:(0,P.jsx)(m,{"aria-label":n?`Collapse details`:`Expand details`,"aria-expanded":n,onClick:i,children:(0,P.jsx)(l,{className:t(`size-3.5 transition-transform`,n&&`rotate-90`)})})}),(0,P.jsx)(`td`,{className:`px-3 py-3 font-mono text-xs text-muted`,children:e.job.name??`default`}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(r,{to:`/job?id=${encodeURIComponent(e.job.id)}`,className:`max-w-[14rem] truncate font-mono text-xs text-accent hover:underline`,title:e.job.id,children:e.job.id}),(0,P.jsx)(T,{value:e.job.id})]})}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsx)(`span`,{className:`inline-block rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:e.reason})}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsx)(`span`,{className:`block max-w-md truncate text-xs text-danger/80`,title:e.error??``,children:e.error||`—`})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right tnum text-muted`,children:e.job.attempts??a.length}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right text-faint`,title:S(e.enteredAt),children:C(e.enteredAt)}),(0,P.jsx)(`td`,{className:`px-4 py-3`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,P.jsx)(r,{to:`/job?id=${encodeURIComponent(e.job.id)}`,"aria-label":`Inspect job ${e.job.id}`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,P.jsx)(d,{className:`size-3.5`})}),(0,P.jsx)(m,{"aria-label":`Retry job unavailable`,disabled:!0,title:A,children:(0,P.jsx)(s,{className:`size-3.5`})})]})})]}),n&&(0,P.jsxs)(`tr`,{className:`border-b border-line bg-surface-2/30 last:border-0`,children:[(0,P.jsx)(`td`,{}),(0,P.jsxs)(`td`,{colSpan:7,className:`px-3 pb-4 pt-1`,children:[e.error&&(0,P.jsxs)(`div`,{className:`mb-3`,children:[(0,P.jsx)(`div`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Error`}),(0,P.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap rounded-lg bg-surface p-3 font-mono text-xs text-danger/90`,children:e.error})]}),(0,P.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:[`Failure history`,typeof e.retryCount==`number`&&e.retryCount>0&&(0,P.jsxs)(`span`,{className:`rounded-full bg-surface px-2 py-0.5 text-[10px] normal-case text-muted`,children:[`retried `,e.retryCount,`×`]})]}),a.length===0?(0,P.jsx)(`p`,{className:`text-xs text-faint`,children:`No per-attempt history recorded.`}):(0,P.jsx)(`ol`,{className:`space-y-1.5`,children:a.map(e=>(0,P.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-0.5 rounded-lg border border-line bg-surface px-3 py-2 text-xs`,children:[(0,P.jsxs)(`span`,{className:`font-medium text-fg`,children:[`Attempt `,e.attempt]}),(0,P.jsx)(`span`,{className:`text-faint`,title:S(e.failedAt),children:C(e.failedAt)}),e.duration!=null&&(0,P.jsx)(`span`,{className:`tnum text-muted`,children:x(e.duration)}),e.reason&&(0,P.jsx)(`span`,{className:`rounded bg-red-500/10 px-1.5 text-danger`,children:e.reason}),e.error&&(0,P.jsx)(`span`,{className:`w-full truncate text-danger/70`,children:e.error})]},`${e.attempt}-${e.failedAt}`))})]})]})]})}var R=25,z=e=>`${e.job.id}-${e.enteredAt}`;function B(){let[e,t]=(0,N.useState)(``),[n,r]=(0,N.useState)(0),[i,c]=(0,N.useState)(`all`),[l,d]=(0,N.useState)(``),[m,x]=(0,N.useState)(new Set),{data:S,error:C,loading:w,refetch:T}=p(M,[],{intervalMs:3e4});(0,N.useEffect)(()=>{e||!S?.queues?.length||t((S.queues.find(e=>e.dlq>0)??S.queues[0]).name)},[S,e]);let{data:E,error:D,loading:B,refetch:V}=p((0,N.useCallback)(async()=>{if(!e)return{queue:e,page:n,entries:[],total:0,stats:null,statsError:null};let[t,r]=await Promise.all([a.dlq(e,R,n*R),a.dlqStats(e).then(e=>({stats:e.stats,error:null})).catch(e=>({stats:null,error:e.message||`Unknown error`}))]);return{queue:e,page:n,entries:t.entries??[],total:t.total??0,stats:r.stats,statsError:r.error}},[e,n]),[e,n]),H=E&&E.queue===e&&E.page===n?E:null;(0,N.useEffect)(()=>{if(!H)return;let e=Math.max(0,Math.ceil((H.total??0)/R)-1);n>e&&r(e)},[H,n]),(0,N.useEffect)(()=>{x(new Set)},[e,n]);let U=H?.stats?.byReason??{},W=(0,N.useMemo)(()=>Object.keys(U).filter(e=>U[e]>0),[U]),G=(0,N.useMemo)(()=>[...W].sort((e,t)=>(U[t]??0)-(U[e]??0))[0],[W,U]),K=H?.entries??[],q=(0,N.useMemo)(()=>{let e=K;i!==`all`&&(e=e.filter(e=>e.reason===i));let t=l.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>t.enteredAt-e.enteredAt)},[K,i,l]),J=i!==`all`||l.trim()!==``,Y=(H?.total??0)>R,X=e=>x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,P.jsxs)(`div`,{children:[(0,P.jsx)(b,{title:`DLQ Control`,description:`Inspect and triage one queue's dead-lettered jobs.`,live:!!e&&!!H&&!H.statsError&&!D&&!C,actions:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(h,{size:`sm`,disabled:!e||!q.length,onClick:()=>{if(q.length===0){o.info(`Nothing to export`);return}j(`dlq-${e}`,q.map(e=>({jobId:e.job.id,reason:e.reason,error:e.error??``,attempts:e.job.attempts??e.attempts?.length??``,enteredAt:new Date(e.enteredAt).toISOString()})),[`jobId`,`reason`,`error`,`attempts`,`enteredAt`])},children:[(0,P.jsx)(u,{className:`size-3.5`}),` Export`]}),(0,P.jsxs)(h,{size:`sm`,disabled:!0,title:A,children:[(0,P.jsx)(s,{className:`size-3.5`}),` Retry all`]}),(0,P.jsx)(h,{variant:`danger`,size:`sm`,disabled:!0,title:k,children:`Purge`})]})}),D&&H&&(0,P.jsx)(g,{message:`DLQ refresh failed — showing the last successful page.`,onRetry:V}),C&&(0,P.jsx)(g,{onRetry:T,message:`Could not discover queues — ${C.message}. Retry before selecting a queue.`}),H?.statsError&&(0,P.jsx)(g,{message:`DLQ statistics are unavailable — ${H.statsError}. The entry list may still be current.`,onRetry:V}),(0,P.jsx)(F,{queue:e,data:H,reasons:W,topReason:G}),(0,P.jsx)(I,{queue:e,queues:S?.queues??[],reason:i,reasons:W,byReason:U,search:l,pageScoped:Y,onQueue:e=>{t(e),r(0),c(`all`),d(``)},onReason:c,onSearch:d}),(0,P.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:A}),D&&!H?(0,P.jsx)(_,{error:D,onRetry:V}):w&&!S&&!e&&!C?(0,P.jsx)(v,{label:`Discovering queues…`}):B&&!H&&!D?(0,P.jsx)(v,{label:`Loading DLQ…`}):C&&!e?(0,P.jsx)(y,{icon:(0,P.jsx)(f,{}),title:`Could not discover queues`,hint:`${C.message}. Retry the queue discovery request above.`}):e?q.length===0?(0,P.jsx)(y,{icon:(0,P.jsx)(f,{}),title:J?`No matches`:`Dead letter queue is empty`,hint:J?Y?`No entries on this page match your filter — filters are page-scoped. Try another page or clear them.`:`No entries match your filter. Clear it to see all entries.`:`Failed jobs that exhaust their retries land here.`}):(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,P.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,P.jsx)(`th`,{className:`w-8 py-3 pl-4`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Name`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Job ID`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Reason`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Error`}),(0,P.jsx)(`th`,{className:`px-3 py-3 text-right font-medium`,children:`Attempts`}),(0,P.jsx)(`th`,{className:`px-3 py-3 text-right font-medium`,children:`Entered`}),(0,P.jsx)(`th`,{className:`w-20 px-4 py-3`})]})}),(0,P.jsx)(`tbody`,{children:q.map(e=>{let t=z(e);return(0,P.jsx)(L,{entry:e,isOpen:m.has(t),onToggle:()=>X(t),attempts:e.attempts??[]},t)})})]})}):(0,P.jsx)(y,{icon:(0,P.jsx)(f,{}),title:S?.queues.length===0?`No queues available`:`Select a queue`,hint:`A queue must be selected before its dead letter entries can be inspected.`}),H&&(0,P.jsx)(O,{page:n,pageSize:R,total:H.total,onPageChange:r,label:`entries`})]})}export{B as DlqControl};
@@ -0,0 +1 @@
1
+ import{i as e,t}from"./cn-zFEt5SO8.js";import{f as n,g as r,r as i,t as a}from"./react-vendor-CyjgmGTq.js";import{t as o}from"./bq-BeBxa743.js";import{t as s}from"./toastStore-CS_9Xndn.js";import{C as c,d as l,u}from"./icons-CIvFfU2b.js";import{n as d}from"./usePolledData-DzlUpBOO.js";import{n as f,t as p}from"./Button-BPqpRZJD.js";import{t as m}from"./Card-C7NMhqUt.js";import{i as h,n as g,r as _,t as v}from"./feedback-BnGE2oW2.js";import{t as y}from"./PageHeader-BXlZSBcc.js";import{l as b,s as x}from"./format-Cg7VCIZW.js";import{a as S}from"./form-tC20r4Ma.js";import{t as C}from"./Pagination-Q-vf4hsX.js";import{r as w,t as T}from"./flowMutationSafety-CoOp94wS.js";import{t as E}from"./exportFile-C7xhE8Yh.js";import{t as D}from"./QueueControl-B8Q9NX6t.js";var O=e(r(),1),k=a();function ee({total:e,discoveryError:n,healthy:r,statsError:i,queue:a,topReason:o,pendingRetry:s,reasonCount:c}){return(0,k.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,k.jsxs)(m,{children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,k.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Total in DLQ`}),(0,k.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,n?`bg-amber-500/10 text-warning`:e==null?`bg-surface-2 text-muted`:r?`bg-emerald-500/10 text-success`:`bg-red-500/10 text-danger`),children:n?`Unavailable`:e==null?`Loading`:r?`Healthy`:`Attention`})]}),(0,k.jsx)(`div`,{className:t(`mt-2 text-3xl font-bold tnum`,e==null||n?`text-muted`:r?`text-success`:`text-danger`),children:e==null?`—`:x(e)})]}),(0,k.jsxs)(m,{children:[(0,k.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Top Reason`}),(0,k.jsx)(`div`,{className:`mt-2 text-lg font-semibold text-fg`,children:n||i?`Unavailable`:a?o??`No failures`:`Select a queue`})]}),(0,k.jsxs)(m,{children:[(0,k.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Pending Retry`}),(0,k.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:s==null?`—`:x(s)}),(0,k.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:a?`in this queue`:`awaiting retry`})]}),(0,k.jsxs)(m,{children:[(0,k.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Failure Types`}),(0,k.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:c==null?`—`:x(c)}),(0,k.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:`distinct reasons`})]})]})}function te({queues:e,queue:n,onSelect:r}){return e.length===0?null:(0,k.jsxs)(m,{className:`mb-6`,children:[(0,k.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,k.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`DLQ by queue`}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(p,{size:`sm`,disabled:!0,title:T,children:[(0,k.jsx)(c,{className:`size-3.5`}),` Retry all (`,e.length,` queues)`]}),(0,k.jsxs)(p,{variant:`danger`,size:`sm`,disabled:!0,title:w,children:[`Purge all (`,e.length,` queues)`]})]})]}),(0,k.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-5`,children:e.map(e=>(0,k.jsxs)(`button`,{type:`button`,onClick:()=>r(e.name),className:t(`rounded-lg border p-3 text-left transition-colors`,n===e.name?`border-accent/50 bg-surface-2`:`border-line hover:border-line-strong`),children:[(0,k.jsx)(`div`,{className:`truncate font-mono text-xs text-muted`,children:e.name}),(0,k.jsx)(`div`,{className:`mt-1 text-xl font-bold tnum text-danger`,children:e.dlq})]},e.name))})]})}function A({queue:e,queues:t,reason:n,reasons:r,sort:i,search:a,pageScoped:o,onQueue:s,onReason:u,onSort:d,onSearch:m,onExport:h}){return(0,k.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,k.jsx)(`div`,{className:`w-48`,children:(0,k.jsxs)(S,{value:e,"aria-label":`Queue`,name:`dlq-queue`,autoComplete:`off`,onChange:e=>s(e.target.value),children:[(0,k.jsx)(`option`,{value:``,children:`Select a queue…`}),t.map(e=>(0,k.jsxs)(`option`,{value:e.name,children:[e.name,e.dlq?` (${e.dlq})`:``]},e.name))]})}),(0,k.jsx)(`div`,{className:`w-40`,children:(0,k.jsxs)(S,{value:n,onChange:e=>u(e.target.value),"aria-label":`Filter by reason`,name:`dlq-reason-filter`,autoComplete:`off`,children:[(0,k.jsx)(`option`,{value:`all`,children:`All Reasons`}),r.map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))]})}),(0,k.jsx)(`div`,{className:`w-36`,children:(0,k.jsxs)(S,{value:i,onChange:e=>d(e.target.value),"aria-label":o?`Sort this page`:`Sort`,name:`dlq-sort`,autoComplete:`off`,children:[(0,k.jsxs)(`option`,{value:`newest`,children:[`Newest First`,o?` (this page)`:``]}),(0,k.jsxs)(`option`,{value:`oldest`,children:[`Oldest First`,o?` (this page)`:``]})]})}),(0,k.jsx)(`input`,{value:a,onChange:e=>m(e.target.value),placeholder:`Filter this page by job ID…`,"aria-label":`Filter this page by job ID`,name:`dlq-job-filter`,autoComplete:`off`,className:`h-9 min-w-40 flex-1 rounded-lg border border-line bg-surface px-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),(0,k.jsxs)(p,{size:`sm`,disabled:!0,title:T,children:[(0,k.jsx)(c,{className:`size-3.5`}),` Retry All`]}),(0,k.jsx)(p,{variant:`danger`,size:`sm`,disabled:!0,title:w,children:`Purge All`}),(0,k.jsx)(f,{"aria-label":`Export this page to CSV`,title:`Export this page to CSV`,disabled:!e,onClick:h,children:(0,k.jsx)(l,{className:`size-3.5`})})]})}function j({entries:e,expanded:n,onToggle:r}){return(0,k.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,k.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Reason`}),(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Error`}),(0,k.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Entered`}),(0,k.jsx)(`th`,{className:`w-16 px-5 py-3`})]})}),(0,k.jsx)(`tbody`,{children:e.map(e=>{let a=`${e.job.id}-${e.enteredAt}`;return(0,k.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,k.jsx)(`td`,{className:`px-5 py-3`,children:(0,k.jsx)(i,{to:`/job?id=${encodeURIComponent(e.job.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.job.id})}),(0,k.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.job.name??`default`}),(0,k.jsx)(`td`,{className:`px-5 py-3`,children:(0,k.jsx)(`span`,{className:`rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:e.reason})}),(0,k.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-danger/80`,children:e.error?(0,k.jsx)(`button`,{type:`button`,title:e.error,"aria-expanded":n.has(a),onClick:()=>r(a),className:t(`block w-full break-words text-left`,!n.has(a)&&`line-clamp-2`),children:e.error}):`—`}),(0,k.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:b(e.enteredAt)}),(0,k.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,k.jsx)(f,{"aria-label":`Retry unavailable`,disabled:!0,title:T,children:(0,k.jsx)(c,{className:`size-3.5`})})})]},a)})})]})})}var M=25;function N(){let[e,t]=n(),[r,i]=(0,O.useState)(``),[a,c]=(0,O.useState)(`all`),[l,f]=(0,O.useState)(`newest`),[p,m]=(0,O.useState)(``),[b,x]=(0,O.useState)(0),[S,w]=(0,O.useState)(new Set),{data:N,error:P,loading:F,refetch:I}=d(D,[],{intervalMs:1e4}),L=N?.queues??[],R=N?L.reduce((e,t)=>e+t.dlq,0):null,{data:z,error:B,loading:V,refetch:H}=d((0,O.useCallback)(async()=>{if(!r)return{queue:r,page:b,entries:[],entriesTotal:0,stats:null,statsError:null};let[e,t]=await Promise.all([o.dlq(r,M,b*M),o.dlqStats(r).then(e=>({stats:e.stats,error:null})).catch(e=>({stats:null,error:e.message||`Unknown error`}))]);return{queue:r,page:b,entries:e.entries??[],entriesTotal:e.total??0,stats:t.stats,statsError:t.error}},[r,b]),[r,b]),U=z&&z.queue===r&&z.page===b?z:null;(0,O.useEffect)(()=>{if(!U)return;let e=U.entriesTotal??0;b>0&&b*M>=e&&x(Math.max(0,Math.ceil(e/M)-1))},[U,b]);let W=()=>{let e=(U?.entries??[]).map(e=>({jobId:e.job.id,reason:e.reason,error:e.error??``,enteredAt:new Date(e.enteredAt).toISOString(),attempts:e.attempts?.length??0}));if(e.length===0){s.info(`Nothing to export on this page`);return}E(`dlq-${r}`,e,[`jobId`,`reason`,`error`,`enteredAt`,`attempts`])},G=e=>{X.current=!0,i(e),x(0),c(`all`),t(e?{queue:e}:{},{replace:!0})},K=U?.stats?.byReason??{},q=Object.keys(K).filter(e=>K[e]>0),J=[...q].sort((e,t)=>(K[t]??0)-(K[e]??0))[0],Y=(0,O.useMemo)(()=>L.filter(e=>e.dlq>0).sort((e,t)=>t.dlq-e.dlq),[L]),X=(0,O.useRef)(!1),Z=e.get(`queue`);(0,O.useEffect)(()=>{if(!(X.current||r)){if(Z){if(L.some(e=>e.name===Z)){X.current=!0,i(Z),x(0),c(`all`);return}if(L.length===0)return}Y.length!==0&&(X.current=!0,i(Y[0].name),x(0),c(`all`))}},[r,L,Y,Z]);let Q=(0,O.useMemo)(()=>{let e=U?.entries??[];a!==`all`&&(e=e.filter(e=>e.reason===a));let t=p.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>l===`newest`?t.enteredAt-e.enteredAt:e.enteredAt-t.enteredAt)},[U,a,p,l]),ne=R===0&&!P,$=a!==`all`||p.trim()!==``,re=(U?.entriesTotal??0)>M;return(0,k.jsxs)(`div`,{children:[(0,k.jsx)(y,{title:`Dead Letter Queue`,description:`Jobs that failed after exhausting all retries. Inspect and export entries without mutating flow topology.`,live:!!r&&!!U&&!U.statsError&&!B&&!P}),B&&U&&(0,k.jsx)(h,{message:`DLQ refresh failed — showing the last successful page.`,onRetry:H}),P&&(0,k.jsx)(h,{onRetry:I,message:`Could not discover queue DLQ totals — ${P.message}. Health status is unavailable.`}),U?.statsError&&(0,k.jsx)(h,{message:`DLQ statistics are unavailable — ${U.statsError}. The entry list may still be current.`,onRetry:H}),(0,k.jsx)(ee,{total:R,discoveryError:!!P,healthy:ne,statsError:!!U?.statsError,queue:r,topReason:J,pendingRetry:U?.stats?.pendingRetry,reasonCount:U?.stats?q.length:void 0}),(0,k.jsx)(te,{queues:Y,queue:r,onSelect:G}),(0,k.jsx)(A,{queue:r,queues:L,reason:a,reasons:q,sort:l,search:p,pageScoped:re,onQueue:G,onReason:c,onSort:f,onSearch:m,onExport:W}),(0,k.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:T}),B&&!U?(0,k.jsx)(g,{error:B,onRetry:H}):F&&!N&&!r&&!P?(0,k.jsx)(_,{label:`Discovering queues…`}):V&&!U&&!B?(0,k.jsx)(_,{label:`Loading DLQ…`}):P&&!r?(0,k.jsx)(v,{icon:(0,k.jsx)(u,{}),title:`Could not discover queues`,hint:`${P.message}. Retry the queue discovery request above.`}):r?Q.length===0?(0,k.jsx)(v,{icon:(0,k.jsx)(u,{}),title:$?`No matches on this page`:`No dead letter entries`,hint:$?`No entries on this page match your filter — the filter is page-scoped. Use the pager below to check other pages.`:`This queue has no dead letter entries.`}):(0,k.jsx)(j,{entries:Q,expanded:S,onToggle:e=>w(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}):(0,k.jsx)(v,{icon:(0,k.jsx)(u,{}),title:`Select a queue`,hint:`Choose a queue from the dropdown to view its dead letter queue entries.`}),r&&U&&(0,k.jsx)(C,{page:b,pageSize:M,total:U.entriesTotal,onPageChange:x,label:`entries`})]})}export{N as DlqPro};
@@ -0,0 +1,2 @@
1
+ import{i as e,t}from"./cn-zFEt5SO8.js";import{f as n,g as r,r as i,t as a}from"./react-vendor-CyjgmGTq.js";import{i as o,o as s}from"./connectionStore-DbBYqHEY.js";import{i as c}from"./upstreamPaths-D_LPsv7b.js";import{a as l,c as u,l as d,o as f}from"./bq-BeBxa743.js";import{t as p}from"./Card-C7NMhqUt.js";import{i as m,n as h,r as g}from"./feedback-BnGE2oW2.js";import{t as _}from"./PageHeader-BXlZSBcc.js";import{i as v}from"./index-Cui9IwWy.js";import{n as y,t as b}from"./controlConnectionEpoch-CFSO6237.js";var x={nodeWidth:168,nodeHeight:60},S=`flow-order-9a3f`,C={completed:`border-success/50 bg-success/10 text-success`,failed:`border-danger/50 bg-danger/10 text-danger`,active:`border-blue-400/60 bg-blue-400/10 text-blue-400`,delayed:`border-accent/50 bg-accent/10 text-accent`,waiting:`border-warning/50 bg-warning/10 text-warning`,prioritized:`border-warning/50 bg-warning/10 text-warning`,"waiting-children":`border-cyan-400/60 bg-cyan-400/10 text-cyan-400`},w=e=>e&&C[e]||`border-line bg-surface-2 text-muted`,T=e=>e.length>12?`${e.slice(0,6)}…${e.slice(-4)}`:e,E=class extends Error{constructor(e,t){super(e,t),this.name=`FlowSnapshotError`}};function D(e,t,n){if(!Array.isArray(e)||e.some(e=>typeof e!=`string`||c(e)!==null))throw new E(`Job ${n} returned an invalid ${t} list`);return e}function O(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw new E(`GET /jobs/${t} returned an invalid response`);let n=e;if(n.ok!==!0)throw new E(`GET /jobs/${t} returned an invalid success envelope`);let r=n.job;if(typeof r!=`object`||!r||Array.isArray(r))throw new E(`GET /jobs/${t} returned no job snapshot`);let i=r;if(i.id!==t)throw new E(`GET /jobs/${t} returned the wrong job id (${String(i.id)})`);if(typeof i.queue!=`string`||i.queue.length===0)throw new E(`Job ${t} returned an invalid queue`);if(typeof i.state!=`string`||i.state.length===0)throw new E(`Job ${t} returned an invalid state`);if(!Object.hasOwn(i,`parentId`)||i.parentId!==null&&(typeof i.parentId!=`string`||c(i.parentId)!==null))throw new E(`Job ${t} returned an invalid parentId`);return{...r,parentId:i.parentId,childrenIds:D(i.childrenIds,`childrenIds`,t),dependsOn:D(i.dependsOn,`dependsOn`,t)}}async function k(e,t,n){n?.throwIfAborted();let r=await d(e,t,n);return n?.throwIfAborted(),O(r,t)}function A(e){let t=c(e);return t?`Job ID: ${t}`:null}async function ee(e,t={}){let n=A(e);if(n)throw new E(n);let r=t.target??u(),{signal:i}=t,a=e,o=new Set([e]),s=[];for(let e=0;;e++){i?.throwIfAborted();let t;try{t=await k(r,a,i)}catch(t){if(i?.throwIfAborted(),e===0)throw t;if(t instanceof l&&t.status===404){let e=s.at(-1);if(!e)throw t;return{id:e.id,job:e,hops:Math.max(0,s.length-1),path:s,missingParent:a}}throw new E(`Could not resolve the flow root because parent ${a} could not be loaded: ${t instanceof Error?t.message:String(t)}`,{cause:t})}s.push(t);let n=t.parentId;if(!n)return{id:a,job:t,hops:e,path:s};if(o.has(n))throw new E(`Flow parent cycle detected at job ${n}`);if(e>=100)throw new E(`Flow parent chain exceeds the Bunqueue 2.8.57 limit of 100 levels`);o.add(n),a=n}}function j(e,t){let n=new Set(e),r=new Map(e.map(e=>[e,[]]));for(let e of t)n.has(e.from)&&n.has(e.to)&&r.get(e.from)?.push(e.to);let i=new Map,a=[],o=e=>{i.set(e,1),a.push(e);for(let t of r.get(e)??[]){if(i.get(t)===1){let e=a.lastIndexOf(t);return[...a.slice(Math.max(0,e)),t]}if(i.get(t)!==2){let e=o(t);if(e)return e}}return a.pop(),i.set(e,2),null};for(let t of e)if(!i.has(t)){let e=o(t);if(e)return e}return null}var te=[`failParentOnFailure`,`removeDependencyOnFailure`,`continueParentOnFailure`,`ignoreDependencyOnFailure`];function M(e){return te.filter(t=>e[t]===!0)}function N(e,t){if(e?.parentId!==t)return null;let n=M(e);return n.length===1?n[0]===`continueParentOnFailure`?{scope:`parent`,policy:`continueParentOnFailure`}:n[0]===`removeDependencyOnFailure`?{scope:`child`,policy:`removeDependencyOnFailure`}:n[0]===`ignoreDependencyOnFailure`?{scope:`child`,policy:`ignoreDependencyOnFailure`}:null:null}async function ne(e,t,n={}){let r=A(e);if(r)throw new E(r);let i=n.target??u(),{signal:a}=n,o=new Map,s=[],c=[],l=new Set,d=new Set,f=new Map,p=new Set,m=new Set,h=new Set(n.limitations??[]),g=[{id:e,depth:0}],_=new Set([e]),v=new Map;t&&v.set(e,O({ok:!0,job:t},e));let y=[...n.seedPath??[]].reverse(),b=!1;if(y.length>0&&y[0]?.id!==e)throw new E(`Resolved seed path does not start at the requested flow root`);for(let[e,t]of y.entries()){let n=O({ok:!0,job:t},t.id);if(v.set(n.id,n),e!==0){if(e>100||_.size>=500){b=!0;continue}_.has(n.id)||(_.add(n.id),g.push({id:n.id,depth:e}))}}let x=new Set,S=b;for(;g.length;){a?.throwIfAborted();let{id:t,depth:n}=g.shift();if(x.has(t))continue;x.add(t);let r=null;try{r=v.get(t)??await k(i,t,a)}catch(n){if(a?.throwIfAborted(),t===e)throw n;f.set(t,n instanceof Error?n.message:String(n))}if(o.set(t,r??{id:t,state:`unknown`}),!r)continue;if(n>=100){(r.childrenIds?.length??0)+(r.dependsOn?.length??0)>0&&(S=!0);continue}let u=e=>_.has(e)?!0:_.size>=500?(S=!0,!1):(_.add(e),g.push({id:e,depth:n+1}),!0),m=(e,t,n,r)=>{if(!u(r))return;let i=`${e}->${t}:${n}`;l.has(i)||(l.add(i),s.push({from:e,to:t,kind:n}))},h=r.childrenIds??[],y=r.dependsOn??[],b=new Set(h),C=new Set(y);b.size!==h.length&&p.add(`Job ${t} lists a child more than once`),C.size!==y.length&&p.add(`Job ${t} lists a dependency more than once`);for(let e of h)m(t,e,`child`,e);for(let e of y)if(u(e)){let n=`${e}->${t}`;d.has(n)||(d.add(n),c.push({from:e,to:t,kind:`depends`})),b.has(e)||m(e,t,`depends`,e)}}for(let[e,t]of o)!f.has(e)&&M(t).length>1&&p.add(`Job ${e} enables mutually exclusive failure policies`);for(let e of s){if(e.kind!==`child`||f.has(e.to))continue;let t=o.get(e.to);t&&t.parentId!==e.from&&p.add(`Child ${e.to} points to parent ${String(t.parentId??`none`)}, not ${e.from}`)}for(let[e,t]of o){if(f.has(e))continue;let n=t.childrenIds??[];if(n.some(e=>!o.has(e)||f.has(e)))continue;let r=n.map(t=>({childId:t,release:N(o.get(t),e)})).find(({release:e})=>e?.scope===`parent`);for(let i of n){if(t.dependsOn?.includes(i))continue;if(r?.release?.scope===`parent`){m.add(`Parent ${e} is missing dependency ${i}; ${r.release.policy} on child ${r.childId} may have released all parent dependencies, but the HTTP snapshot cannot prove whether the policy fired`);continue}let n=N(o.get(i),e);if(n?.scope===`child`){m.add(`Parent ${e} is missing dependency ${i}; ${n.policy} may have released it, but the HTTP snapshot cannot prove whether the policy fired`);continue}p.add(`Parent ${e} lists child ${i} without the matching dependency`)}}for(let[e,t]of o){if(f.has(e)||!t.parentId)continue;let n=o.get(t.parentId);!n||f.has(t.parentId)||n.childrenIds?.includes(e)||p.add(`Parent ${t.parentId} does not list child ${e}`)}let C=j([...o.keys()],c);return{jobs:o,edges:s,truncated:S,failed:f.size,failures:f,issues:[...p],policyNotes:[...m],cycle:C,limitations:[...h]}}var re=`bq-dash-recent-flows`,P=8;function F(e){return`${re}:${encodeURIComponent(e.trim()||`/api`)}`}function I(e,t){if(!t)return[];try{let t=JSON.parse(localStorage.getItem(F(e))??`[]`);return Array.isArray(t)?t.filter(e=>typeof e?.root==`string`&&e.root.length>0&&e.root.length<=1024&&Number.isSafeInteger(e?.nodes)&&e.nodes>1&&e.nodes<=500&&Number.isFinite(e?.at)&&e.at>=0).slice(0,P):[]}catch{return[]}}function ie(e,t,n,r){let i=[n,...t.filter(e=>e.root!==n.root)].slice(0,P);if(!r)return i;try{localStorage.setItem(F(e),JSON.stringify(i))}catch{}return i}var L=e(r(),1),ae=new Set([`explore`,`create`,`operations`]);function R(e,t=``){let n=e.get(`root`),r=ce(n)?n:t,i=e.get(`mode`),a=ae.has(i)?i:`explore`,o=e.get(`node`);return{root:r,mode:a,node:r&&ce(o)?o:null}}function oe(e){let t=new URLSearchParams;return e.root&&t.set(`root`,e.root),e.mode!==`explore`&&t.set(`mode`,e.mode),e.root&&e.node&&t.set(`node`,e.node),t}function se(e,t,n=``){return oe({...R(e,n),...t})}function ce(e){return!!(e&&A(e)===null)}function le(){let[e,t]=n(),r=v()?S:``,i=e.toString(),a=(0,L.useMemo)(()=>R(new URLSearchParams(i),r),[r,i]),c=a.root,l=s(e=>e.baseUrl),d=s(e=>e.token),f=o(),[p,m]=(0,L.useState)(c),[h,g]=(0,L.useState)(null),[_,y]=(0,L.useState)(!!c),[b,x]=(0,L.useState)(null),[C,w]=(0,L.useState)(()=>I(f,d.length===0)),T=(0,L.useRef)(0),D=(0,L.useRef)(null),O=(0,L.useRef)(!1),k=(0,L.useRef)(z()),j=h?.seed===c?h.graph:null,te=j?a.node&&j.jobs.has(a.node)?a.node:h?.defaultSelected??null:null,M=(0,L.useCallback)((e,n=!1)=>{t(t=>se(t,e,r),{replace:n})},[r,t]),N=(0,L.useCallback)(async e=>{let t=s.getState();if(t.baseUrl!==l||t.token!==d)return;D.current?.abort(),D.current=null;let n=++T.current,r=e.trim();if(g(null),x(null),!r)return y(!1);let i=A(r);if(i)return x(new E(i)),y(!1);let a=u(),o=z(),c=new AbortController;D.current=c;let f=()=>O.current&&n===T.current&&!c.signal.aborted&&o===z();y(!0);try{let e={target:a,signal:c.signal},t=await ee(r,e),n=t.missingParent?[`Ancestor ${t.missingParent} is no longer available. The graph starts at the oldest surviving node.`]:[],i=await ne(t.id,t.job,{...e,seedPath:t.path,limitations:n});if(!f())return;g({seed:r,graph:i,defaultSelected:t.id}),i.jobs.size>1&&w(e=>ie(a.baseUrl,e,{root:t.id,nodes:i.jobs.size,at:Date.now()},s.getState().token.length===0))}catch(e){f()&&x(e instanceof Error?e:Error(`Failed to load flow`))}finally{D.current===c&&(D.current=null),f()&&y(!1)}},[l,d]);return(0,L.useEffect)(()=>{O.current=!0,k.current=z();let e=s.subscribe(()=>{let e=z();e!==k.current&&(k.current=e,T.current+=1,D.current?.abort(),D.current=null,O.current&&(g(null),x(null),y(!1)))});return()=>{O.current=!1,e(),T.current+=1,D.current?.abort()}},[]),(0,L.useEffect)(()=>w(d?[]:I(f,!0)),[f,d]),(0,L.useEffect)(()=>{let e={...a};j&&(!e.node||!j.jobs.has(e.node))&&(e.node=h?.defaultSelected??null);let n=oe(e).toString();n!==i&&t(n,{replace:!0})},[j,i,t,h?.defaultSelected,a]),(0,L.useEffect)(()=>{m(c),N(c)},[c,N]),{input:p,setInput:m,rootParam:c,mode:a.mode,setMode:e=>M({mode:e}),graph:j,selected:te,setSelected:e=>{j?.jobs.has(e)&&M({node:e})},loading:_,error:b,recent:C,load:N,submit:e=>{e.preventDefault();let t=p.trim();if(t){if(A(t))return void N(t);t===c?N(t):M({root:t,mode:`explore`,node:null})}},openRecent:e=>{if(m(e),A(e))return void N(e);let t=e===c;M({root:e,mode:`explore`,node:null}),t&&N(e)}}}function z(){let{token:e}=s.getState();return JSON.stringify([o(),e])}function ue(e){return e instanceof l&&e.status===0||[`TypeError`,`AbortError`,`TimeoutError`].includes(e.name)}var B=e=>({method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),de=new Set([`removeChildDependency`,`removeUnprocessedChildren`,`removeDeduplicationKey`,`retry`,`promote`,`remove`]),fe=e=>e+5e3,V={create:(e,t)=>f(`/flows/create?target=${encodeURIComponent(o())}`,B({operation:e,...t})),getFlow:e=>{let t=new URLSearchParams({id:e.id,queueName:e.queueName,target:o()});return e.depth!==void 0&&t.set(`depth`,String(e.depth)),e.maxChildren!==void 0&&t.set(`maxChildren`,String(e.maxChildren)),f(`/flows/tree?${t}`)},inspect:(e,t)=>f(`/flows/jobs/${encodeURIComponent(e.id)}/${t}?${new URLSearchParams({queueName:e.queueName,target:o()})}`),getParentResult:e=>f(`/flows/results?target=${encodeURIComponent(o())}`,B({operation:`getParentResult`,parentId:e})),getParentResults:e=>f(`/flows/results?target=${encodeURIComponent(o())}`,B({operation:`getParentResults`,parentIds:e})),waitUntilFinished:(e,t)=>f(`/flows/jobs/${encodeURIComponent(e.id)}/waitUntilFinished?${new URLSearchParams({queueName:e.queueName,target:o(),ttl:String(t)})}`,void 0,fe(t)),mutate:(e,t,n)=>f(`/flows/jobs/${encodeURIComponent(e.id)}/${t}?${new URLSearchParams({queueName:e.queueName,target:o()})}`,de.has(t)?{method:`POST`}:B(n??{}))},H=a();function U({value:e}){return(0,H.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-md border border-line bg-bg p-3 font-mono text-xs text-muted`,children:JSON.stringify(e,null,2)})}function W(...e){return JSON.stringify(e)}function G(e){let t=y(),n=(0,L.useMemo)(()=>({key:e,connectionEpoch:t}),[t,e]),r=(0,L.useRef)(n),i=(0,L.useRef)(void 0),a=(0,L.useRef)(void 0),o=(0,L.useRef)(0),s=(0,L.useRef)(!0),[c,l]=(0,L.useState)(),[u,d]=(0,L.useState)(),[f,p]=(0,L.useState)();return(0,L.useLayoutEffect)(()=>{r.current=n,i.current=void 0,a.current=void 0},[n]),(0,L.useEffect)(()=>(s.current=!0,()=>{s.current=!1,i.current=void 0,a.current=void 0}),[]),{busy:c?.identity===n?c.label:``,error:f?.identity===n?f.message:``,result:u?.identity===n?u.value:void 0,reject:e=>{b()===n.connectionEpoch&&(a.current=void 0,i.current=void 0,l(void 0),d(void 0),p({identity:n,message:e}))},run:async(e,t)=>{if(i.current?.identity===n||b()!==n.connectionEpoch)return;let c={id:++o.current,identity:n};i.current=c,a.current=c,l({...c,label:e}),d(void 0),p(void 0);try{let e=await t();s.current&&r.current===n&&b()===n.connectionEpoch&&a.current===c&&d({identity:n,value:e})}catch(e){s.current&&r.current===n&&b()===n.connectionEpoch&&a.current===c&&p({identity:n,message:pe(e)})}finally{i.current===c&&(i.current=void 0),s.current&&l(e=>e?.id===c.id?void 0:e)}}}}function pe(e){return e instanceof Error?e.message:String(e)}var K={add:{flow:{name:`aggregate`,queueName:`reports`,data:{},children:[{name:`fetch`,queueName:`io`,data:{source:`orders`}}]},options:{queuesOptions:{io:{attempts:3,backoff:1e3}}}},addBulk:{flows:[{name:`report-a`,queueName:`reports`,data:{region:`eu`}},{name:`report-b`,queueName:`reports`,data:{region:`us`}}]},addChain:{steps:[{name:`extract`,queueName:`pipeline`,data:{}},{name:`transform`,queueName:`pipeline`,data:{}},{name:`load`,queueName:`pipeline`,data:{}}]},addBulkThen:{parallel:[{name:`part-a`,queueName:`parallel`,data:{}},{name:`part-b`,queueName:`parallel`,data:{}}],final:{name:`merge`,queueName:`final`,data:{}}},addTree:{root:{name:`root`,queueName:`tree`,data:{},children:[{name:`child`,queueName:`tree`,data:{}}]}}};function me({repository:e=V,onOpen:t}){let[n,r]=(0,L.useState)(`add`),[i,a]=(0,L.useState)(()=>JSON.stringify(K.add,null,2)),o=G(W(n,i)),s=!!o.busy,c=e=>{r(e),a(JSON.stringify(K[e],null,2))},l=async t=>{t.preventDefault();let r;try{r=JSON.parse(i)}catch{return o.reject(`The definition must be valid JSON.`)}if(!r||typeof r!=`object`||Array.isArray(r))return o.reject(`The definition must be a JSON object.`);let a=n;await o.run(a,()=>e.create(a,r))},u=he(o.result);return(0,H.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(0,1fr)_minmax(300px,0.7fr)]`,children:[(0,H.jsxs)(`form`,{onSubmit:l,className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`FlowProducer method`,(0,H.jsx)(`select`,{"aria-label":`FlowProducer method`,value:n,onChange:e=>c(e.target.value),className:`mt-1 block h-9 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:Object.keys(K).map(e=>(0,H.jsx)(`option`,{children:e},e))})]}),(0,H.jsx)(`button`,{type:`submit`,disabled:s,className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg disabled:opacity-50`,children:s?`Creating…`:`Run ${n}`})]}),(0,H.jsxs)(`label`,{className:`mt-4 block text-xs text-faint`,children:[`Definition`,(0,H.jsx)(`textarea`,{"aria-label":`Flow definition JSON`,spellCheck:!1,value:i,onChange:e=>a(e.target.value),className:`mt-1 min-h-80 w-full resize-y rounded-lg border border-line bg-bg p-3 font-mono text-xs text-fg outline-none focus:ring-2 focus:ring-accent/50`})]})]}),(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Atomic commit result`}),(0,H.jsx)(`p`,{className:`mt-1 mb-4 text-xs text-faint`,children:`Validation is performed by Bunqueue before the graph is committed.`}),o.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-danger`,children:o.error}),o.result===void 0?(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`No flow created in this session.`}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{value:o.result}),u&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>t(u),className:`mt-3 rounded-lg border border-line px-3 py-2 text-xs text-fg`,children:`Open created flow`})]})]})]})}function he(e){let t=e,n=t?.result?.root?.id??t?.result?.roots?.[0]?.id??t?.result?.finalId??t?.result?.jobIds?.at(-1);return typeof n==`string`?n:null}function ge({recent:e,onOpen:t}){return(0,H.jsx)(p,{children:(0,H.jsxs)(`div`,{className:`py-16 text-center`,children:[(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`No flow loaded.`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Enter a job ID, or choose “View flow” from Job Inspector.`}),e.length>0&&(0,H.jsxs)(`div`,{className:`mt-6`,children:[(0,H.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Recently viewed`}),(0,H.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:e.map(e=>(0,H.jsxs)(`button`,{type:`button`,title:e.root,onClick:()=>t(e.root),className:`min-h-10 rounded-lg border border-line bg-surface-2 px-3 py-1.5 font-mono text-xs text-muted hover:text-fg`,children:[(0,H.jsx)(`span`,{translate:`no`,children:T(e.root)}),(0,H.jsxs)(`span`,{className:`ml-2 text-faint`,children:[e.nodes,` nodes`]})]},e.root))})]})]})})}function q({target:e,onChange:t}){return(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Job ID`,(0,H.jsx)(`input`,{"aria-label":`Flow job ID`,value:e.id,onChange:n=>t({...e,id:n.target.value}),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 font-mono text-sm text-fg`})]}),(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Queue name`,(0,H.jsx)(`input`,{"aria-label":`Flow queue name`,value:e.queueName,onChange:n=>t({...e,queueName:n.target.value}),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`})]})]})}var _e=[`getChildrenValues`,`getDependencies`,`getDependenciesCount`,`getFailedChildrenValues`,`getIgnoredChildrenFailures`],ve=[{id:`removeChildDependency`,label:`Release dependency`,dangerous:!0},{id:`removeUnprocessedChildren`,label:`Remove unprocessed children`,dangerous:!0},{id:`retry`,label:`Retry job`},{id:`promote`,label:`Promote delayed job`},{id:`remove`,label:`Remove job`,dangerous:!0}];function ye({repository:e=V,initialTarget:t={id:``,queueName:``},target:n,onTargetChange:r,showTarget:i=!0}){let[a,o]=(0,L.useState)(t),s=n??a,c=r??o,l=G(W(s.id,s.queueName)),u=l.busy,d=!!(s.id.trim()&&s.queueName.trim()),f=t=>{let n=be(s);l.run(t,()=>e.inspect(n,t))},p=t=>{let n=be(s);window.confirm(`${t} on ${n.id} in ${n.queueName}? This changes durable queue state and has no compare-and-swap precondition.`)&&l.run(t,()=>e.mutate(n,t))};return(0,H.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(360px,0.8fr)_minmax(0,1.2fr)]`,children:[(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Dependency control`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Run the official Flow Job dependency methods against the managed server TCP endpoint.`}),i&&(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(q,{target:s,onChange:c})}),(0,H.jsx)(`h3`,{className:`mt-5 mb-2 text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`Inspect`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:_e.map(e=>(0,H.jsx)(`button`,{type:`button`,disabled:!d||!!u,onClick:()=>f(e),className:`rounded-md border border-line px-2.5 py-1.5 font-mono text-[11px] text-muted disabled:opacity-40`,children:e},e))}),(0,H.jsx)(`h3`,{className:`mt-5 mb-2 text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`Mutate`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ve.map(e=>(0,H.jsx)(`button`,{type:`button`,disabled:!d||!!u,onClick:()=>p(e.id),className:e.dangerous?`rounded-md border border-danger/40 px-2.5 py-1.5 text-xs text-danger disabled:opacity-40`:`rounded-md border border-line px-2.5 py-1.5 text-xs text-muted disabled:opacity-40`,children:e.label},e.id))})]}),(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Operation result`}),(0,H.jsx)(`p`,{className:`mt-1 mb-4 text-xs text-faint`,children:u?`Running ${u}…`:`The last authoritative broker response appears here.`}),l.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-danger`,children:l.error}),l.result===void 0?(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`Choose an inspection or mutation.`}):(0,H.jsx)(U,{value:l.result})]})]})}var be=e=>({id:e.id.trim(),queueName:e.queueName.trim()});function xe({repository:e=V,initialIds:t=``}){let[n,r]=(0,L.useState)(t),i=G(W(n)),a=i.busy,o=Se(n),s=async t=>{if(o.length===0)return;let n=[...o];await i.run(t,async()=>t===`one`?await e.getParentResult(n[0]):await e.getParentResults(n))};return(0,H.jsxs)(`section`,{className:`grid gap-5 rounded-lg border border-line bg-surface p-4 xl:grid-cols-[minmax(320px,0.8fr)_minmax(0,1.2fr)]`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Parent results`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Resolve completed parent values through the official FlowProducer result API.`}),(0,H.jsxs)(`label`,{className:`mt-4 block text-xs text-faint`,children:[`Parent IDs, one per line`,(0,H.jsx)(`textarea`,{"aria-label":`Flow parent IDs`,value:n,onChange:e=>r(e.target.value),placeholder:`parent-job-id
2
+ another-parent-id`,className:`mt-1 min-h-28 w-full resize-y rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs text-fg`})]}),(0,H.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,H.jsx)(`button`,{type:`button`,disabled:o.length===0||!!a,onClick:()=>void s(`one`),className:`rounded-md border border-line px-3 py-1.5 font-mono text-xs text-muted disabled:opacity-40`,children:`getParentResult`}),(0,H.jsxs)(`button`,{type:`button`,disabled:o.length===0||!!a,onClick:()=>void s(`many`),className:`rounded-md border border-line px-3 py-1.5 font-mono text-xs text-muted disabled:opacity-40`,children:[`getParentResults (`,o.length,`)`]})]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:`Resolved values`}),(0,H.jsx)(`p`,{className:`mt-1 mb-4 text-xs text-faint`,children:a?`Reading durable results…`:`Falsy values and input ordering are preserved.`}),i.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-danger`,children:i.error}),i.result===void 0?(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`No parent result requested.`}):(0,H.jsx)(U,{value:i.result})]})]})}function Se(e){return e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean).slice(0,1e3)}function Ce({repository:e=V,target:t,onTargetChange:n}){let[r,i]=(0,L.useState)(`10`),[a,o]=(0,L.useState)(`100`),s=G(W(t.id,t.queueName,r,a)),c=!!s.busy,l=!!(t.id.trim()&&t.queueName.trim())&&Oe(r)&&Oe(a),u=async()=>{if(!l)return;let n={target:{id:t.id.trim(),queueName:t.queueName.trim()},depth:Number(r),maxChildren:Number(a)};await s.run(`getFlow`,async()=>{let t=await e.getFlow({...n.target,depth:n.depth,maxChildren:n.maxChildren});return{...n,value:t}})};return(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`FlowProducer.getFlow`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Read the broker-native tree with explicit traversal limits. Results are bound to the target and limits that produced them.`})]}),(0,H.jsx)(`button`,{type:`button`,disabled:!l||c,onClick:()=>void u(),className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:c?`Loading tree...`:`Load getFlow tree`})]}),(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(q,{target:t,onChange:n})}),(0,H.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,H.jsx)(we,{label:`Depth`,value:r,onChange:i}),(0,H.jsx)(we,{label:`Children per level`,value:a,onChange:o})]}),(0,H.jsx)(`p`,{className:`mt-2 text-[11px] text-faint`,children:`Both limits accept integers from 0 to 500.`}),s.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:s.error}),s.result&&(0,H.jsx)(Te,{loaded:s.result})]})}function we({label:e,value:t,onChange:n}){return(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[e,(0,H.jsx)(`input`,{"aria-label":`getFlow ${e}`,type:`number`,min:`0`,max:`500`,step:`1`,value:t,onChange:e=>n(e.target.value),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`})]})}function Te({loaded:e}){let t=Ee(e.value),n=t?De(t):[];return(0,H.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,"aria-live":`polite`,children:[(0,H.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,H.jsxs)(`span`,{className:`font-mono text-fg`,children:[e.target.queueName,`/`,e.target.id]}),(0,H.jsxs)(`span`,{className:`text-faint`,children:[`depth `,e.depth,`, max children `,e.maxChildren]})]}),t===null?(0,H.jsx)(`p`,{className:`rounded-md border border-line bg-bg p-3 text-sm text-muted`,children:`Bunqueue returned no flow for this target.`}):n.length>0?(0,H.jsx)(`ul`,{"aria-label":`getFlow tree result`,className:`max-h-72 overflow-auto rounded-md border border-line bg-bg`,children:n.map(e=>(0,H.jsxs)(`li`,{className:`flex min-w-max items-center gap-2 border-b border-line/60 px-3 py-2 last:border-b-0`,style:{paddingLeft:`${12+Math.min(e.level,20)*18}px`},children:[(0,H.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] ${w(e.state)}`,children:e.state}),(0,H.jsx)(`span`,{className:`font-mono text-xs text-fg`,children:e.id}),(0,H.jsx)(`span`,{className:`text-xs text-muted`,children:e.name}),(0,H.jsx)(`span`,{className:`text-[11px] text-faint`,children:e.queueName})]},e.id))}):(0,H.jsx)(`p`,{role:`alert`,className:`rounded-md border border-warning/40 p-3 text-sm text-warning`,children:`The agent returned an unrecognized getFlow payload. Inspect the raw JSON below.`}),(0,H.jsxs)(`details`,{className:`mt-3`,open:!0,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-muted`,children:`Raw getFlow JSON`}),(0,H.jsx)(`div`,{className:`mt-2`,children:(0,H.jsx)(U,{value:e.value})})]})]})}function Ee(e){let t=J(e),n=J(t?.result)??t;if(!(!n||!Object.hasOwn(n,`flow`)))return n.flow===null?null:J(n.flow)}function De(e){let t=[],n=[{node:e,level:0}],r=new WeakSet;for(;n.length>0&&t.length<1e3;){let e=n.shift();if(!e||r.has(e.node))continue;r.add(e.node),t.push({id:Y(e.node.id,`(missing id)`),name:Y(e.node.name,`(unnamed)`),queueName:Y(e.node.queueName,`(missing queue)`),state:Y(e.node.state,`unknown`),level:e.level});let i=Array.isArray(e.node.children)?e.node.children:[];n.unshift(...i.map(J).filter(e=>e!==void 0).map(t=>({node:t,level:e.level+1})))}return t}var Oe=e=>/^\d+$/.test(e)&&Number(e)<=500,J=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:void 0,Y=(e,t)=>typeof e==`string`&&e.length>0?e:t,ke=[`getState`,`isWaiting`,`isActive`,`isDelayed`,`isCompleted`,`isFailed`,`isWaitingChildren`,`toJSON`,`asJSON`],X={updateData:{data:{}},updateProgress:{progress:50,message:`Halfway`},log:{message:`Operator note`},changeDelay:{delay:1e3},changePriority:{priority:1,lifo:!1},clearLogs:{keepLogs:0},removeDeduplicationKey:{}},Ae={progress:{stage:`hydrate`,completed:4,total:10}};function je({repository:e=V,initialTarget:t={id:``,queueName:``}}){let[n,r]=(0,L.useState)(t),[i,a]=(0,L.useState)(`updateData`),[o,s]=(0,L.useState)(JSON.stringify(X.updateData,null,2)),[c,l]=(0,L.useState)(`30000`),u=G(W(n.id,n.queueName,i,o,c)),d=u.busy,f=!!(n.id.trim()&&n.queueName.trim()),p=e=>{a(e),s(JSON.stringify(X[e],null,2))};return(0,H.jsxs)(`div`,{className:`space-y-5`,children:[(0,H.jsx)(Ce,{repository:e,target:n,onTargetChange:r}),(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Flow Job methods`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`State predicates, serialization, bounded waiting, and durable mutations from Bunqueue 2.8.57.`})]}),d&&(0,H.jsxs)(`span`,{className:`font-mono text-xs text-accent`,children:[d,`…`]})]}),(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(q,{target:n,onChange:r})}),(0,H.jsx)(`h3`,{className:`mt-5 mb-2 text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`Inspect state and wire JSON`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ke.map(t=>(0,H.jsx)(`button`,{type:`button`,disabled:!f||!!d,onClick:()=>{let r=Z(n);u.run(t,()=>e.inspect(r,t))},className:`rounded-md border border-line px-2.5 py-1.5 font-mono text-[11px] text-muted disabled:opacity-40`,children:t},t))}),(0,H.jsxs)(`div`,{className:`mt-5 grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(300px,0.7fr)]`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Mutation`,(0,H.jsx)(`select`,{"aria-label":`Flow Job mutation`,value:i,onChange:e=>p(e.target.value),className:`mt-1 block h-9 rounded-lg border border-line bg-surface-2 px-3 font-mono text-xs text-fg`,children:Object.keys(X).map(e=>(0,H.jsx)(`option`,{children:e},e))})]}),(0,H.jsx)(`button`,{type:`button`,disabled:!f||!!d,onClick:()=>{let t;try{t=JSON.parse(o)}catch{return u.reject(`Mutation payload must be valid JSON.`)}if(!t||typeof t!=`object`||Array.isArray(t))return u.reject(`Mutation payload must be a JSON object.`);let r=Z(n),a=i;window.confirm(`${a} on ${r.id}? This writes durable job state without a compare-and-swap precondition.`)&&u.run(a,()=>e.mutate(r,a,t))},className:`h-9 rounded-md border border-warning/40 px-3 text-xs text-warning disabled:opacity-40`,children:`Apply mutation`}),i===`updateProgress`&&(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>s(JSON.stringify(X.updateProgress,null,2)),className:`h-9 rounded-md border border-line px-3 text-xs text-muted`,children:`Numeric progress`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>s(JSON.stringify(Ae,null,2)),className:`h-9 rounded-md border border-line px-3 text-xs text-muted`,children:`Object progress`})]})]}),(0,H.jsx)(`textarea`,{"aria-label":`Flow Job mutation JSON`,value:o,onChange:e=>s(e.target.value),className:`mt-3 min-h-32 w-full resize-y rounded-lg border border-line bg-bg p-3 font-mono text-xs text-fg`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`waitUntilFinished TTL (ms)`,(0,H.jsx)(`input`,{"aria-label":`Flow wait TTL`,type:`number`,min:`1`,max:`60000`,value:c,onChange:e=>l(e.target.value),className:`mt-1 block h-9 w-full rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`})]}),(0,H.jsx)(`button`,{type:`button`,disabled:!f||!!d||!Me(c),onClick:()=>{let t=Z(n),r=Number(c);u.run(`waitUntilFinished`,()=>e.waitUntilFinished(t,r))},className:`mt-3 rounded-md border border-line px-3 py-2 font-mono text-xs text-muted disabled:opacity-40`,children:`waitUntilFinished`}),(0,H.jsx)(`p`,{className:`mt-3 text-[11px] leading-5 text-faint`,children:`Lease-only methods are not forged here: extendLock and worker state transitions require the active worker token; discard is process-local and non-awaitable.`})]})]}),u.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:u.error}),u.result!==void 0&&(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(U,{value:u.result})})]}),(0,H.jsx)(ye,{repository:e,target:n,onTargetChange:r,showTarget:!1}),(0,H.jsx)(xe,{repository:e})]})}var Z=e=>({id:e.id.trim(),queueName:e.queueName.trim()}),Me=e=>Number.isSafeInteger(Number(e))&&Number(e)>=1&&Number(e)<=6e4;function Ne({input:e,loading:t,onInput:n,onSubmit:r}){return(0,H.jsxs)(p,{className:`mb-6`,children:[(0,H.jsxs)(`form`,{onSubmit:r,className:`flex flex-wrap items-center gap-3`,children:[(0,H.jsx)(`input`,{name:`flow-job-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,value:e,onChange:e=>n(e.target.value),placeholder:`Flow job ID`,"aria-label":`Root job ID`,"aria-describedby":`flow-input-help`,className:`min-w-0 flex-1 rounded-lg border border-line bg-surface-2 px-3 py-2 font-mono text-sm text-fg outline-none placeholder:text-faint focus-visible:ring-2 focus-visible:ring-accent/50`}),(0,H.jsx)(`button`,{type:`submit`,disabled:t||!e.trim(),className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg disabled:opacity-50`,children:t?`Loading…`:`Load Flow`})]}),(0,H.jsxs)(`p`,{id:`flow-input-help`,className:`mt-2 text-xs text-faint`,children:[`Start from any surviving structural node. Bunqueue 2.8.57 flow topology is resolved from durable parent, children, and dependency contracts. Up to `,500,` nodes are rendered.`]})]})}var Pe={nodeWidth:168,nodeHeight:60,colGap:72,rowGap:20,padding:24};function Fe(e,t){let n=new Map,r=new Map,i=new Map;for(let t of e)n.set(t,0),r.set(t,0),i.set(t,[]);for(let e of t)!n.has(e.from)||!n.has(e.to)||e.from===e.to||(i.get(e.from)?.push(e.to),r.set(e.to,(r.get(e.to)??0)+1));let a=e.filter(e=>(r.get(e)??0)===0),o=new Set;for(;o.size<n.size;){for(;a.length;){let e=a.shift();if(!o.has(e)){o.add(e);for(let t of i.get(e)??[]){if(o.has(t))continue;n.set(t,Math.max(n.get(t)??0,(n.get(e)??0)+1));let i=(r.get(t)??0)-1;r.set(t,i),i===0&&a.push(t)}}}let t=e.find(e=>!o.has(e));if(t===void 0)break;a.push(t)}return n}function Ie(e,t,n={}){let r={...Pe,...n},i=Fe(e,t),a=new Map,o=0;for(let t of e){let e=i.get(t)??0;o=Math.max(o,e);let n=a.get(e);n?n.push(t):a.set(e,[t])}let s=0;for(let e of a.values())s=Math.max(s,e.length);let c=s*r.nodeHeight+Math.max(0,s-1)*r.rowGap,l=[];for(let e=0;e<=o;e++){let t=a.get(e)??[],n=t.length*r.nodeHeight+Math.max(0,t.length-1)*r.rowGap,i=r.padding+(c-n)/2;t.forEach((t,n)=>{l.push({id:t,layer:e,x:r.padding+e*(r.nodeWidth+r.colGap),y:i+n*(r.nodeHeight+r.rowGap)})})}return{nodes:l,width:r.padding*2+(o+1)*r.nodeWidth+o*r.colGap,height:r.padding*2+c}}function Le({graph:e,layout:n,selected:r,onSelect:i}){let a=new Map(n.nodes.map(e=>[e.id,e]));return(0,H.jsxs)(p,{padded:!1,className:`max-h-[70vh] overflow-auto overscroll-contain p-4`,children:[(0,H.jsx)(`h2`,{className:`sr-only`,children:`Flow Graph`}),(0,H.jsx)(`ul`,{className:`sr-only`,"aria-label":`Flow relationships`,children:e.edges.map(e=>(0,H.jsx)(`li`,{children:e.kind===`child`?`${e.from} has child ${e.to}`:`${e.to} depends on ${e.from}`},`accessible-${e.from}-${e.to}-${e.kind}`))}),(0,H.jsxs)(`div`,{className:`relative`,style:{width:n.width,height:n.height},children:[(0,H.jsxs)(`svg`,{"aria-hidden":`true`,className:`absolute inset-0 text-line`,width:n.width,height:n.height,children:[(0,H.jsxs)(`defs`,{children:[(0,H.jsx)(`marker`,{id:`flow-arrow-child`,markerWidth:`6`,markerHeight:`6`,refX:`5`,refY:`3`,orient:`auto`,children:(0,H.jsx)(`path`,{d:`M0,0 L6,3 L0,6 Z`,fill:`currentColor`})}),(0,H.jsx)(`marker`,{id:`flow-arrow-dependency`,markerWidth:`6`,markerHeight:`6`,refX:`5`,refY:`3`,orient:`auto`,children:(0,H.jsx)(`path`,{d:`M0,0 L6,3 L0,6 Z`,fill:`currentColor`})})]}),e.edges.map(e=>{let t=a.get(e.from),n=a.get(e.to);return!t||!n?null:(0,H.jsx)(`path`,{d:ze(t,n),fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeDasharray:e.kind===`depends`?`4 4`:void 0,markerEnd:`url(#flow-arrow-${e.kind===`depends`?`dependency`:`child`})`,opacity:.5},`${e.from}-${e.to}-${e.kind}`)})]}),n.nodes.map(n=>{let a=e.jobs.get(n.id),o=e.failures.has(n.id)?`unavailable`:a?.state??`unknown`;return(0,H.jsxs)(`button`,{type:`button`,"data-flow-node":n.id,onClick:()=>i(n.id),"aria-pressed":r===n.id,"aria-label":`${n.id}, queue ${a?.queue??`unknown`}, state ${o}`,title:n.id,style:{left:n.x,top:n.y,width:168,height:60},className:t(`absolute flex flex-col justify-center gap-0.5 rounded-lg border px-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/70`,w(a?.state),r===n.id&&`ring-2 ring-accent`),children:[(0,H.jsx)(`span`,{translate:`no`,className:`truncate font-mono text-xs text-fg`,children:T(n.id)}),(0,H.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-[11px]`,children:[(0,H.jsx)(`span`,{className:`truncate`,children:a?.queue??`—`}),(0,H.jsx)(`span`,{className:`font-medium`,children:o})]})]},n.id)})]})]})}function Re(e,t,n,r){let i=(e+n)/2;return`M${e},${t} C${i},${t} ${i},${r} ${n},${r}`}function ze(e,t){return e.x<=t.x?Re(e.x+168,e.y+60/2,t.x,t.y+60/2):Re(e.x,e.y+60/2,t.x+168,t.y+60/2)}function Be({graph:e,selected:t}){let n=t?e.jobs.get(t):void 0,r=t?e.failures.get(t):void 0;return(0,H.jsx)(`aside`,{"aria-label":`Selected job details`,"aria-live":`polite`,children:(0,H.jsxs)(p,{children:[n?(0,H.jsx)(Ve,{job:n,failure:r}):(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`Select a node to inspect it.`}),(0,H.jsx)(He,{graph:e})]})})}function Ve({job:e,failure:t}){return(0,H.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-xs text-faint`,children:`Job`}),(0,H.jsx)(`div`,{translate:`no`,className:`break-all font-mono text-xs text-fg`,children:e.id})]}),t&&(0,H.jsxs)(`p`,{role:`alert`,className:`break-words text-xs text-warning`,children:[`Snapshot unavailable: `,t]}),(0,H.jsx)($,{label:`Queue`,value:e.queue??`—`}),(0,H.jsx)($,{label:`State`,value:t?`unavailable`:e.state??`unknown`}),(0,H.jsx)($,{label:`Priority`,value:e.priority===void 0?`—`:String(e.priority)}),(0,H.jsx)($,{label:`Parent`,value:e.parentId??`—`}),(0,H.jsx)($,{label:`Children`,value:t?`—`:String(e.childrenIds?.length??0)}),(0,H.jsx)($,{label:`Depends on`,value:t?`—`:String(e.dependsOn?.length??0)}),(0,H.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`inline-block rounded-lg border border-line px-3 py-1.5 text-xs text-muted hover:bg-surface-2 hover:text-fg`,children:`Open in Job Inspector`})]})}function He({graph:e}){return(0,H.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3 text-xs text-faint`,"aria-live":`polite`,children:[e.truncated&&(0,H.jsxs)(`div`,{className:`mb-1 text-warning`,children:[`Graph truncated at `,500,` nodes / depth `,100,`.`]}),(0,H.jsx)(Q,{label:`known snapshot limitation`,pluralLabel:`known snapshot limitations`,values:e.limitations,tone:`text-warning`}),(0,H.jsx)(Q,{label:`unavailable node`,pluralLabel:`unavailable nodes`,values:[...e.failures].map(([e,t])=>`${e}: ${t}`),tone:`text-warning`}),e.cycle&&(0,H.jsxs)(`div`,{className:`mb-1 break-words text-danger`,children:[`Dependency cycle: `,(0,H.jsx)(`span`,{className:`font-mono`,children:e.cycle.join(` → `)})]}),(0,H.jsx)(Q,{label:`snapshot inconsistency`,pluralLabel:`snapshot inconsistencies`,values:e.issues,tone:`text-warning`}),e.policyNotes.length>0&&(0,H.jsx)(`p`,{className:`mb-1 text-muted`,children:`Failure-policy notes are informational; the HTTP snapshot cannot prove that a policy fired.`}),(0,H.jsx)(Q,{label:`failure-policy ambiguity`,pluralLabel:`failure-policy ambiguities`,values:e.policyNotes,tone:`text-muted`}),(0,H.jsxs)(`div`,{className:`mb-1`,children:[e.jobs.size,` nodes · `,e.edges.length,` edges`]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`inline-block h-px w-4 bg-current`}),` child`]}),(0,H.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`inline-block h-px w-4 border-t border-dashed border-current`}),` depends`]})]})]})}function Q({label:e,pluralLabel:t,values:n,tone:r}){return n.length?(0,H.jsxs)(`details`,{className:`mb-1 ${r}`,children:[(0,H.jsxs)(`summary`,{className:`cursor-pointer`,children:[n.length,` `,n.length===1?e:t]}),(0,H.jsx)(`ul`,{className:`mt-1 space-y-1 pl-3`,children:n.map(e=>(0,H.jsx)(`li`,{className:`break-words`,children:e},e))})]}):null}function $({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,H.jsx)(`span`,{className:`shrink-0 text-xs text-faint`,children:e}),(0,H.jsx)(`span`,{className:`min-w-0 break-all text-right text-fg`,children:t})]})}function Ue({graph:e,selected:t,onSelect:n}){return(0,H.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1fr)_280px]`,children:[(0,H.jsx)(Le,{graph:e,layout:(0,L.useMemo)(()=>Ie([...e.jobs.keys()],e.edges,x),[e]),selected:t,onSelect:n}),(0,H.jsx)(Be,{graph:e,selected:t})]})}function We(){let e=le();return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(_,{title:`Job Flows`,description:`Inspect Bunqueue 2.8.57 parent, child, and dependency topology as an operational DAG.`,actions:e.graph&&(0,H.jsx)(`button`,{type:`button`,disabled:e.loading,onClick:()=>void e.load(e.rootParam),className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg disabled:opacity-50`,children:`Refresh`})}),(0,H.jsx)(`nav`,{"aria-label":`Job Flow tools`,className:`mb-5 flex border-b border-line`,children:[`explore`,`create`,`operations`].map(t=>(0,H.jsx)(`button`,{type:`button`,"aria-pressed":e.mode===t,onClick:()=>e.setMode(t),className:e.mode===t?`border-b-2 border-accent px-4 py-2 text-sm capitalize text-fg`:`border-b-2 border-transparent px-4 py-2 text-sm capitalize text-faint hover:text-fg`,children:t===`operations`?`Job methods`:t},t))}),e.mode===`create`&&(0,H.jsx)(me,{onOpen:e.openRecent}),e.mode===`operations`&&(0,H.jsx)(je,{initialTarget:v()?{id:`flow-order-9a3f`,queueName:`orders`}:void 0}),e.mode===`explore`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Ne,{input:e.input,loading:e.loading,onInput:e.setInput,onSubmit:e.submit}),(0,H.jsxs)(`div`,{"aria-live":`polite`,children:[e.error&&(ue(e.error)?(0,H.jsx)(m,{message:`Could not load the flow — ${e.error.message}`,onRetry:()=>void e.load(e.rootParam)}):(0,H.jsx)(h,{error:e.error,onRetry:()=>void e.load(e.rootParam)})),e.loading&&(0,H.jsx)(g,{label:`Loading flow…`})]}),!e.loading&&!e.graph&&!e.error&&(0,H.jsx)(ge,{recent:e.recent,onOpen:e.openRecent}),e.graph&&(0,H.jsx)(Ue,{graph:e.graph,selected:e.selected,onSelect:e.setSelected})]})]})}export{We as Flows};
@@ -0,0 +1,2 @@
1
+ import{i as e}from"./cn-zFEt5SO8.js";import{f as t,g as n,l as r,r as i,t as a}from"./react-vendor-CyjgmGTq.js";import{i as o,o as s}from"./connectionStore-DbBYqHEY.js";import{a as c,n as l}from"./upstreamPaths-D_LPsv7b.js";import{a as u,t as d}from"./bq-BeBxa743.js";import{T as f,d as p}from"./icons-CIvFfU2b.js";import{n as m,t as h}from"./Button-BPqpRZJD.js";import{n as g,t as _}from"./Card-C7NMhqUt.js";import{r as v,t as y}from"./feedback-BnGE2oW2.js";import{t as b}from"./StatusBadge-B0I7hNBX.js";import{t as x}from"./PageHeader-BXlZSBcc.js";import{a as S,i as C}from"./format-Cg7VCIZW.js";import{a as w}from"./index-Cui9IwWy.js";import{a as T,n as E,o as D}from"./form-tC20r4Ma.js";import{r as O}from"./flowMutationSafety-CoOp94wS.js";import{n as k}from"./exportFile-C7xhE8Yh.js";import{t as A}from"./jobActions-LQD4KfCc.js";var j=1e4,M=100,ee=256*1024;function N(e){throw new u(`Invalid job response: ${e}`,200)}function P(e,t,{nullable:n=!1,nonEmpty:r=!1}={},i=`job`){if(!Object.hasOwn(e,t)||e[t]===void 0)return;let a=e[t];n&&a===null||(typeof a!=`string`||r&&!a.trim())&&N(`${i}.${t} must be ${n?`a string or null`:`a string`}${r?` (non-empty)`:``}`)}function F(e,t,{nullable:n=!1,integer:r=!1,min:i,max:a}={},o=`job`){if(!Object.hasOwn(e,t)||e[t]===void 0)return;let s=e[t];n&&s===null||(typeof s!=`number`||!Number.isFinite(s)||r&&!Number.isSafeInteger(s)||i!==void 0&&s<i||a!==void 0&&s>a)&&N(`${o}.${t} must be a valid${r?` safe integer`:` finite number`}`)}function I(e,t){Object.hasOwn(e,t)&&e[t]!==void 0&&typeof e[t]!=`boolean`&&N(`job.${t} must be a boolean`)}function L(e,t,{nullable:n=!1,nonEmpty:r=!1}={}){if(!Object.hasOwn(e,t)||e[t]===void 0)return;let i=e[t];n&&i===null||(!Array.isArray(i)||i.some(e=>typeof e!=`string`||r&&!e.trim()))&&N(`job.${t} must be ${n?`a string array or null`:`a string array`}`)}function te(e,t){let n=0,r=0;for(;n<e.length&&r<t;){let t=e.codePointAt(n);n+=t!==void 0&&t>65535?2:1,r+=1}return{text:e.slice(0,n),count:r}}function ne(e){let t=[],n=0,r=!1,i=Math.min(e.length,M);for(let a=0;a<i;a++){let i=+(t.length>0),o=ee-n-i;if(o<=0){r=!0;break}let s=e[a]??``,c=te(s,o);if(t.push(c.text),n+=i+c.count,c.text.length!==s.length){r=!0;break}}return t.length<e.length&&(r=!0),{text:t.join(`
2
+ `),displayedLines:t.length,totalLines:e.length,truncated:r}}function re(e,t){if(t&&(typeof e.state!=`string`||!e.state.trim())&&N(`canonical job.state must be a non-empty string`),P(e,`state`,{nonEmpty:!0}),P(e,`name`,{nonEmpty:!0}),P(e,`failedReason`),t&&(typeof e.queue!=`string`||!e.queue.trim())&&N(`canonical job.queue must be a non-empty string`),P(e,`queue`,{nonEmpty:!0}),P(e,`customId`,{nullable:!0}),P(e,`parentId`,{nullable:!0,nonEmpty:!0}),P(e,`groupId`,{nullable:!0}),P(e,`progressMessage`,{nullable:!0}),L(e,`childrenIds`,{nonEmpty:!0}),L(e,`dependsOn`,{nonEmpty:!0}),L(e,`tags`),L(e,`stacktrace`,{nullable:!0}),Array.isArray(e.stacktrace)&&e.stacktrace.length>j&&N(`job.stacktrace exceeds Bunqueue's ${j}-entry limit`),F(e,`priority`,{integer:!0}),F(e,`createdAt`),F(e,`runAt`),F(e,`startedAt`,{nullable:!0}),F(e,`completedAt`,{nullable:!0}),F(e,`attempts`,{integer:!0,min:0}),F(e,`maxAttempts`,{integer:!0,min:0}),F(e,`backoff`,{integer:!0,min:0}),F(e,`timeout`,{nullable:!0,integer:!0,min:0}),F(e,`ttl`,{nullable:!0,integer:!0,min:0}),F(e,`progress`,{min:0,max:100}),F(e,`lastHeartbeat`),F(e,`stallCount`,{integer:!0,min:0}),I(e,`removeOnComplete`),I(e,`removeOnFail`),Object.hasOwn(e,`backoffConfig`)&&e.backoffConfig!==void 0){let t=e.backoffConfig;if(t!==null){(!t||typeof t!=`object`||Array.isArray(t))&&N(`job.backoffConfig must be an object or null`);let e=t;e.type!==`fixed`&&e.type!==`exponential`&&N(`job.backoffConfig.type must be fixed or exponential`),F(e,`delay`,{integer:!0,min:0},`job.backoffConfig`),(!Object.hasOwn(e,`delay`)||e.delay===void 0)&&N(`job.backoffConfig.delay is required`),F(e,`maxDelay`,{integer:!0,min:0},`job.backoffConfig`)}}if(Object.hasOwn(e,`timeline`)&&e.timeline!==void 0){Array.isArray(e.timeline)||N(`job.timeline must be an array`),e.timeline.length>20&&N(`job.timeline exceeds 20 entries`);for(let[t,n]of e.timeline.entries()){(!n||typeof n!=`object`||Array.isArray(n))&&N(`job.timeline[${t}] must be an object`);let e=n;(typeof e.state!=`string`||!e.state.trim())&&N(`job.timeline[${t}].state must be a non-empty string`),(typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp))&&N(`job.timeline[${t}].timestamp must be a finite number`);let r=`job.timeline[${t}]`;P(e,`worker`,{},r),P(e,`error`,{},r),F(e,`attempt`,{integer:!0,min:0},r)}}}function ie(e,{canonical:t,expectedId:n}){if(!e||typeof e!=`object`||Array.isArray(e))return N(`expected an object envelope`);let r=e;if(r.ok!==!0||!Object.hasOwn(r,`job`))return N(`expected { ok: true, job }`);if(r.job===null)return null;if(!r.job||typeof r.job!=`object`||Array.isArray(r.job))return N(`job must be an object or null`);let i=r.job;return typeof i.id!=`string`||!i.id.trim()?N(`job.id must be a non-empty string`):n!==void 0&&i.id!==n?N(`expected job.id ${JSON.stringify(n)}`):(re(i,t),i)}function ae(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw new u(`Invalid job result response: expected an object envelope`,200);let n=e;if(n.ok!==!0||n.id!==t)throw new u(`Invalid job result response: expected { ok: true, id, result? }`,200);return{result:n.result}}var R=3e4;function z(){let{token:e}=s.getState();return{baseUrl:o(),authorization:e?`Bearer ${e}`:void 0}}function B(e,t){return e?.baseUrl===t.baseUrl&&e.authorization===t.authorization}function V(e,t,n){return t.aborted&&!n?.aborted?new u(`Request timed out`,0):e}async function H(e,t,n,r=R){let i=AbortSignal.timeout(r),a=n?AbortSignal.any([n,i]):i,o=new Headers;e.authorization&&o.set(`Authorization`,e.authorization);let s;try{a.throwIfAborted(),s=await fetch(`${e.baseUrl}${t}`,{headers:o,signal:a}),a.throwIfAborted()}catch(e){throw V(e,i,n)}if(s.status===204)return;let c;try{c=await s.text(),a.throwIfAborted()}catch(e){throw V(e,i,n)}let l,d=!1;if(c)try{l=JSON.parse(c)}catch{d=!0}if(!s.ok){let t=!d&&l&&typeof l==`object`?l.error:void 0,n=typeof t==`string`?t:`HTTP ${s.status}`;throw s.status===401&&typeof window<`u`&&window.dispatchEvent(new window.CustomEvent(`auth:required`,{detail:{scope:`server`,auth:e.authorization,target:e.baseUrl}})),new u(n,s.status)}if(c){if(d)throw new u(`Invalid JSON response (HTTP ${s.status})`,s.status);if(l&&typeof l==`object`&&l.ok===!1){let e=l.error;throw new u(typeof e==`string`?e:`Operation failed`,s.status)}return l}}async function oe(e,t,n={}){let r=n.target??z(),i=n.timeoutMs??R,a=ie(await H(r,t===`custom`?`/jobs/custom/${l(e,`Custom job ID`)}`:`/jobs/${c(e)}`,n.signal,i),{canonical:t===`id`,expectedId:t===`id`?e:void 0});if(!a||t===`id`)return a;if(a.customId!==e)throw new u(`Invalid job response: expected job.customId ${JSON.stringify(e)}`,200);return ie(await H(r,`/jobs/${c(a.id)}`,n.signal,i),{canonical:!0,expectedId:a.id})}function se(e,t){return async(n,r=e.lookupBy,i=!1,a=void 0,o=!1)=>{let s=n.trim();if(!s||a===void 0&&e.actionBusy.current&&!o)return;e.internalEmptyUrlPending.current=!1,e.preservedEmptyLocationKey.current=null,a===void 0&&(e.actionGen.current+=1),e.job!==null&&(r===`id`?e.job.id!==s:e.job.customId!==s)&&(e.jobTarget.current=null,e.setJob(null),e.setResult({fetched:!1,value:void 0}),e.setResultError(null)),e.lookupAbort.current?.abort();let l=new AbortController;e.lookupAbort.current=l,e.lookupIdentity.current={key:s,mode:r};let d=++e.lookupGen.current,f=z();e.setLoading(!0),e.setNotFound(!1),i||e.setMsg(null);try{let n=await oe(s,r,{signal:l.signal,target:f});if(!n){if(d!==e.lookupGen.current)return;e.internalEmptyUrlPending.current=!0,e.preservedEmptyLocationKey.current=null,e.setJob(null),e.setResult({fetched:!1,value:void 0}),e.setResultError(null),e.setNotFound(!0),t({},{replace:!0});return}let i=null,a=null;if(d!==e.lookupGen.current||l.signal.aborted||!B(f,z()))return;if(n.state===`completed`)if(Object.hasOwn(n,`returnvalue`))i={result:n.returnvalue};else try{i=ae(await H(f,`/jobs/${c(n.id)}/result`,l.signal),n.id)}catch(e){if(l.signal.aborted)throw e;a=e.message}if(d!==e.lookupGen.current||l.signal.aborted||!B(f,z()))return;e.jobTarget.current=f,e.setJob(n),r===`custom`?(e.setLookupBy(`id`),e.setIdInput(n.id)):e.setIdInput(s),t({id:n.id},{replace:!0}),e.setResult(i?{fetched:!0,value:i.result}:{fetched:!1,value:void 0}),e.setResultError(a)}catch(n){if(d!==e.lookupGen.current||l.signal.aborted)return;n instanceof u&&(n.status===404||/not found/i.test(n.message))?(e.internalEmptyUrlPending.current=!0,e.preservedEmptyLocationKey.current=null,e.setJob(null),e.setResult({fetched:!1,value:void 0}),e.setResultError(null),e.setNotFound(!0),t({},{replace:!0})):i?e.setMsg(e=>e?{ok:e.ok,text:`${e.text} — couldn't reload: ${n.message}`}:{ok:!1,text:n.message}):e.setMsg({ok:!1,text:n.message})}finally{d===e.lookupGen.current&&(e.lookupAbort.current===l&&(e.lookupAbort.current=null,e.lookupIdentity.current=null),e.setLoading(!1))}}}var U=e(n(),1),W=a(),G=365*24*60*60*1e3;function K(e,t){if(!e.trim())return{ok:!1,msg:`A value is required`};let n=Number(e);return Number.isFinite(n)?t===`progress`?n>=0&&n<=100?{ok:!0,value:n}:{ok:!1,msg:`Progress must be between 0 and 100`}:Number.isSafeInteger(n)?t===`priority`?n>=-1e6&&n<=1e6?{ok:!0,value:n}:{ok:!1,msg:`Priority must be between -1000000 and 1000000`}:n>=0&&n<=G?{ok:!0,value:n}:{ok:!1,msg:`Delay must be between 0 and ${G} ms`}:{ok:!1,msg:`Value must be a whole, safe integer`}:{ok:!1,msg:`Value must be a finite number`}}function ce({job:e,busy:t,act:n}){let r=A(e.state),i=r.promote||r.setPriority||r.setDelay||e.state===`active`;return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Actions`}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.promote&&(0,W.jsx)(h,{size:`sm`,disabled:t,onClick:()=>n(`Promote`,()=>d.promoteJob(e.id)),children:`Promote (run now)`}),e.state===`failed`&&(0,W.jsx)(`p`,{role:`note`,className:`rounded-lg border border-warning/30 bg-warning/5 p-2 text-xs text-warning`,children:`DLQ retry is unavailable in Bunqueue v2.8.57: its GET and retry POST have no atomic job-generation, state, or flow-topology precondition.`}),e.state===`completed`&&(0,W.jsx)(`p`,{role:`note`,className:`rounded-lg border border-warning/30 bg-warning/5 p-2 text-xs text-warning`,children:`Completed-job requeue is unavailable in Bunqueue v2.8.57 because retry-completed re-inserts a child without rebuilding its flow dependency registration.`}),e.state===`active`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{role:`note`,className:`rounded-lg border border-warning/30 bg-warning/5 p-2 text-xs text-warning`,children:`Active-job state changes are unavailable: Bunqueue cannot stop the worker that is already processing this job, so retrying, delaying, discarding or failing it here could run side effects twice.`}),(0,W.jsx)(q,{label:`Set progress (0–100)`,cta:`Progress`,kind:`progress`,disabled:t,onSubmit:t=>n(`Progress`,()=>d.setJobProgress(e.id,t))})]}),r.setPriority&&(0,W.jsx)(le,{disabled:t,onSubmit:(t,r)=>n(`Priority`,()=>d.changePriority(e.id,t,r))}),r.setDelay&&(0,W.jsx)(q,{label:`Set delay (ms)`,cta:`Delay`,kind:`delay`,disabled:t,onSubmit:t=>n(`Delay`,()=>d.changeDelay(e.id,t))}),(0,W.jsxs)(`p`,{role:`note`,className:`text-xs text-faint`,children:[`Cancel/delete/discard: `,O]}),!i&&(0,W.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No actions available for a job in state "`,e.state??`unknown`,`".`]})]})]})}function q({label:e,cta:t,kind:n,disabled:r,onSubmit:i}){let[a,o]=(0,U.useState)(``),s=K(a,n);return(0,W.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),!r&&s.ok&&i(s.value)},children:[(0,W.jsx)(E,{type:`number`,min:0,max:n===`progress`?100:G,step:n===`progress`?`any`:1,name:n===`progress`?`job-progress`:`job-delay`,value:a,onChange:e=>o(e.target.value),placeholder:e,"aria-label":e,className:`h-8 text-xs`}),(0,W.jsx)(h,{type:`submit`,size:`sm`,disabled:r||!s.ok,children:t}),!s.ok&&a.trim()&&(0,W.jsx)(`span`,{role:`alert`,className:`self-center text-[11px] text-danger`,children:s.msg})]})}function le({disabled:e,onSubmit:t}){let[n,r]=(0,U.useState)(``),[i,a]=(0,U.useState)(!1),o=K(n,`priority`);return(0,W.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:n=>{n.preventDefault(),!e&&o.ok&&t(o.value,i)},children:[(0,W.jsx)(E,{type:`number`,min:-1e6,max:1e6,step:1,name:`job-priority`,value:n,onChange:e=>r(e.target.value),placeholder:`Set priority`,"aria-label":`Set priority`,className:`h-8 min-w-28 flex-1 text-xs`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(D,{checked:i,onChange:a,label:`Place first among equal priorities`}),(0,W.jsx)(`span`,{className:`text-xs text-muted`,children:`LIFO`})]}),(0,W.jsx)(h,{type:`submit`,size:`sm`,disabled:e||!o.ok,children:`Set`}),!o.ok&&n.trim()&&(0,W.jsx)(`span`,{role:`alert`,className:`w-full text-[11px] text-danger`,children:o.msg})]})}var J=36e5,Y=10,X=e=>Math.max(e,1);function ue(e){return Math.max(0,(e.maxAttempts??0)-X(e.attempts??0))}function de(e){let t=e.maxAttempts??0,n=e.attempts??0,r=e.backoffConfig,i=r?.maxDelay??J,a=r?.delay??e.backoff??1e3,o=[];for(let e=X(n);e<t&&o.length<Y;e++){let t=r?.type===`fixed`?a:a*2**e;o.push({attempt:e+1,delayMs:Math.min(t,i)})}return o}function fe({job:e}){let t=e.maxAttempts??0,n=e.attempts??0;if(t<=1)return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Backoff`}),(0,W.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No retries configured (max attempts = `,t||1,`).`]})]});if(n>=t)return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Backoff schedule`}),(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`Max attempts reached — no further retries will be scheduled.`})]});let r=e.backoffConfig,i=r?r.type:`exponential (default)`,a=ue(e),o=de(e);return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Backoff schedule`,action:(0,W.jsxs)(`span`,{className:`text-xs capitalize text-faint`,children:[i,r?.maxDelay?` · cap ${S(r.maxDelay)}`:``]})}),(0,W.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:o.map(e=>(0,W.jsxs)(`li`,{className:`flex items-center justify-between text-sm`,children:[(0,W.jsxs)(`span`,{className:`text-muted`,children:[`Attempt `,e.attempt,` / `,t]}),(0,W.jsxs)(`span`,{className:`font-mono text-xs text-fg`,children:[`~`,S(e.delayMs)]})]},e.attempt))}),a>Y&&(0,W.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Showing next `,Y,` of `,a,` remaining attempts.`]}),(0,W.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Approximate — the server applies ±`,r?.type===`fixed`?`20`:`50`,`% jitter at retry time, capped at `,S(r?.maxDelay??J),`.`]})]})}function pe({jobId:e}){let[t,n]=(0,U.useState)(!1),[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(void 0),[l,u]=(0,U.useState)(null),f=async()=>{o(!0),u(null);try{let t=await d.jobChildren(e);c(t.data?.values),i(!0)}catch(e){u(e.message)}finally{o(!1)}},p=()=>{let e=!t;n(e),e&&!r&&!a&&f()},m=s&&typeof s==`object`?Array.isArray(s)?s.length:Object.keys(s).length:0;return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Child values`,action:(0,W.jsx)(h,{size:`sm`,variant:`ghost`,onClick:p,children:t?`Hide`:`Show`})}),t?a?(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`Loading child values…`}):l?(0,W.jsx)(`p`,{className:`text-xs text-danger`,children:l}):m===0?(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`No child values available.`}):(0,W.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:JSON.stringify(s,null,2)}):(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`Resolved return values from this flow job's children.`})]})}function me({data:e,busy:t,editable:n,readOnlyReason:r,onSave:i}){let[a,o]=(0,U.useState)(()=>JSON.stringify(e??null,null,2)),[s,c]=(0,U.useState)(null),l=(0,U.useRef)(a);return(0,U.useEffect)(()=>{let t=JSON.stringify(e??null,null,2);t!==l.current&&(l.current=t,o(t),c(null))},[e]),(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Data`,action:n?(0,W.jsx)(h,{size:`sm`,disabled:t,onClick:()=>{let e;try{e=JSON.parse(a)}catch(e){c(`Invalid JSON: ${e.message}`);return}c(null),i(e)},children:`Save data`}):void 0}),(0,W.jsx)(`textarea`,{"aria-label":`Job data JSON`,name:`job-data-json`,value:a,onChange:e=>o(e.target.value),readOnly:!n,spellCheck:!1,rows:8,className:`w-full resize-y rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),!n&&(0,W.jsx)(`p`,{className:`mt-2 text-xs text-faint`,children:r??`Data is read-only after a job starts processing or leaves the runnable queue.`}),s&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:s})]})}function he(e){return e===`waiting`||e===`prioritized`||e===`delayed`}var ge=[`__parentId`,`__parentQueue`,`__childrenIds`,`__flowParentId`,`__flowParentIds`];function _e(e,t){if(!he(e))return`Data is read-only after a job starts processing or leaves the runnable queue.`;let n=t.data,r=typeof n==`object`&&!!n&&!Array.isArray(n)&&ge.some(e=>Object.hasOwn(n,e));return t.parentId||(t.childrenIds?.length??0)>0||r?`Data is read-only for Flow jobs because Bunqueue v2.8.57 replaces the full payload and would remove structural metadata.`:null}function ve(e){let{logs:t,count:n,loading:r,busy:i,error:a,message:o,level:s,draftRevision:c}=e;return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Logs`,action:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:n}),(0,W.jsx)(h,{size:`sm`,variant:`ghost`,disabled:r||i,onClick:e.load,children:`Refresh`}),(0,W.jsx)(h,{size:`sm`,variant:`danger`,disabled:i||t.length===0,onClick:e.clear,children:`Clear logs`})]})}),a&&(0,W.jsx)(`p`,{className:`mb-2 text-xs text-danger`,children:a}),t.length===0?(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`No log lines recorded for this job.`}):(0,W.jsx)(`ol`,{className:`flex max-h-64 flex-col gap-1 overflow-auto rounded-lg bg-surface-2 p-3`,children:t.map((e,t)=>(0,W.jsx)(`li`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-muted`,children:typeof e==`string`?e:JSON.stringify(e)},t))}),(0,W.jsxs)(`form`,{className:`mt-3 flex gap-2`,onSubmit:t=>{t.preventDefault();let n=t.currentTarget.elements.namedItem(`job-log-message`),r=t.currentTarget.elements.namedItem(`job-log-level`);e.add(n?.value??o,r?.value??s)},children:[(0,W.jsx)(E,{"aria-label":`Log message`,name:`job-log-message`,autoComplete:`off`,value:o,onInput:t=>{c.current+=1,e.setMessage(t.currentTarget.value)},placeholder:`Add a log line…`,className:`h-8 flex-1 text-xs`}),(0,W.jsxs)(T,{"aria-label":`Log level`,name:`job-log-level`,value:s,onChange:t=>{c.current+=1,e.setLevel(t.target.value)},className:`h-8 w-24 text-xs`,children:[(0,W.jsx)(`option`,{value:`info`,children:`info`}),(0,W.jsx)(`option`,{value:`warn`,children:`warn`}),(0,W.jsx)(`option`,{value:`error`,children:`error`})]}),(0,W.jsx)(h,{type:`submit`,size:`sm`,disabled:i||o.trim()===``,children:`Add`})]})]})}var ye=3e4;function Z(){let{token:e}=s.getState();return{baseUrl:o(),authorization:e?`Bearer ${e}`:void 0}}function be(e,t){return e.baseUrl===t.baseUrl&&e.authorization===t.authorization}function xe(e,t,n){return t.aborted&&!n.aborted?new u(`Request timed out`,0):e}async function Se(e,t,n,r){let i=AbortSignal.timeout(ye),a=AbortSignal.any([r,i]),o=new Headers(n.headers);e.authorization&&o.set(`Authorization`,e.authorization),n.body!=null&&!o.has(`Content-Type`)&&o.set(`Content-Type`,`application/json`);let s;try{a.throwIfAborted(),s=await fetch(`${e.baseUrl}${t}`,{...n,headers:o,signal:a}),a.throwIfAborted()}catch(e){throw xe(e,i,r)}if(s.status===204)return;let c;try{c=await s.text(),a.throwIfAborted()}catch(e){throw xe(e,i,r)}let l,d=!1;if(c)try{l=JSON.parse(c)}catch{d=!0}if(!s.ok){let t=!d&&l&&typeof l==`object`?l.error:void 0;throw s.status===401&&typeof window<`u`&&window.dispatchEvent(new window.CustomEvent(`auth:required`,{detail:{scope:`server`,auth:e.authorization,target:e.baseUrl}})),new u(typeof t==`string`?t:`HTTP ${s.status}`,s.status)}if(c){if(d)throw new u(`Invalid JSON response (HTTP ${s.status})`,s.status);if(l&&typeof l==`object`&&l.ok===!1){let e=l.error;throw new u(typeof e==`string`?e:`Operation failed`,s.status)}return l}}function Ce(e){if(!e||typeof e!=`object`||Array.isArray(e))throw new u(`Invalid logs response: expected an object envelope`,200);let t=e;if(t.ok!==!0||!t.data||typeof t.data!=`object`)throw new u(`Invalid logs response: expected { ok: true, data }`,200);let n=t.data;if(!Array.isArray(n.logs)||typeof n.count!=`number`||!Number.isSafeInteger(n.count)||n.count<0)throw new u(`Invalid logs response: expected logs[] and a non-negative count`,200);return{logs:n.logs,count:n.count}}function we({jobId:e}){let t=s(e=>e.baseUrl),n=s(e=>e.token),[r,i]=(0,U.useState)([]),[a,l]=(0,U.useState)(0),[d,f]=(0,U.useState)(!1),[p,m]=(0,U.useState)(null),[h,g]=(0,U.useState)(``),[_,v]=(0,U.useState)(`info`),[y,b]=(0,U.useState)(!1),x=(0,U.useRef)(!1),S=(0,U.useRef)(null),C=(0,U.useRef)(0),w=(0,U.useRef)(null),T=(0,U.useRef)(0),E=(0,U.useRef)(null),D=(0,U.useRef)(!1),O=(0,U.useRef)(0);(0,U.useEffect)(()=>{x.current=!0,S.current=e;let t=()=>{C.current+=1,w.current?.abort(),w.current=null,T.current+=1,E.current?.abort(),E.current=null,D.current=!1,O.current+=1,i([]),l(0),f(!1),m(null),g(``),b(!1)},n=s.subscribe((e,n)=>{e.baseUrl===n.baseUrl&&e.token===n.token||t()});return t(),()=>{x.current=!1,S.current=null,n(),C.current+=1,w.current?.abort(),w.current=null,T.current+=1,E.current?.abort(),E.current=null,D.current=!1}},[e]);let k=(0,U.useCallback)(async r=>{w.current?.abort();let a=new AbortController;w.current=a;let u=++C.current,d=s.getState(),p=r?.target??(d.baseUrl===t&&d.token===n?{baseUrl:o(),authorization:n?`Bearer ${n}`:void 0}:Z()),h=()=>x.current&&S.current===e&&u===C.current&&!a.signal.aborted&&be(p,Z());f(!0),m(null);try{let t=Ce(await Se(p,`/jobs/${c(e)}/logs`,{},a.signal));return h()?(i(t.logs),l(t.count),!0):!1}catch(e){if(!h())return!1;let t=e instanceof Error?e.message:String(e);return m(r?.acceptedLabel?`${r.acceptedLabel} succeeded, but couldn't reload logs: ${t}`:t),!1}finally{u===C.current&&(w.current===a&&(w.current=null),x.current&&f(!1))}},[e,t,n]);(0,U.useEffect)(()=>{k()},[k]);let A=async(t,n,r)=>{if(D.current)return;D.current=!0;let i=new AbortController;E.current=i;let a=++T.current,o=Z();C.current+=1,w.current?.abort(),w.current=null,f(!1),b(!0),m(null);let s=()=>x.current&&S.current===e&&a===T.current&&!i.signal.aborted&&be(o,Z());try{let a=await Se(o,`/jobs/${c(e)}/logs`,t,i.signal);if(!a||typeof a!=`object`||Array.isArray(a)||a.ok!==!0)throw new u(`Invalid log mutation response: expected { ok: true }`,200);if(!s())return;r(),await k({acceptedLabel:n,target:o})}catch(e){s()&&m(e instanceof Error?e.message:String(e))}finally{a===T.current&&(D.current=!1,E.current===i&&(E.current=null),x.current&&b(!1))}},j=async(e=h,t=_)=>{if(D.current)return;let n=e.trim();if(!n)return;let r=t===`warn`||t===`error`?t:`info`,i=O.current;g(e),v(r),await A({method:`POST`,body:JSON.stringify({message:n,level:r})},`Log addition`,()=>{O.current===i&&g(``)})},M=async()=>{D.current||window.confirm(`Clear all logs for this job?`)&&await A({method:`DELETE`},`Log clearing`,()=>{i([]),l(0)})};return(0,W.jsx)(ve,{logs:r,count:a,loading:d,busy:y,error:p,message:h,level:_,draftRevision:O,setMessage:g,setLevel:v,load:()=>void k(),clear:()=>void M(),add:(e,t)=>void j(e,t)})}function Te({timeline:e}){let t=e??[];return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Timeline`}),t.length===0?(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`No state transitions recorded yet.`}):(0,W.jsx)(`ol`,{className:`flex flex-col gap-0`,children:t.map((e,t)=>(0,W.jsxs)(`li`,{className:`border-b border-line/60 py-2 last:border-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(b,{status:e.state}),e.attempt!=null&&(0,W.jsxs)(`span`,{className:`font-mono text-[11px] text-faint`,children:[`attempt `,e.attempt]})]}),(0,W.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:C(e.timestamp)})]}),(e.worker||e.error)&&(0,W.jsxs)(`div`,{className:`mt-1 pl-0.5`,children:[e.worker&&(0,W.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.worker}),e.error&&(0,W.jsx)(`div`,{className:`mt-0.5 text-xs text-danger/90`,children:e.error})]})]},t))})]})}function Ee(e){let t=e.timeline??[];for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.state===`failed`&&n.error)return{message:n.error,attempt:n.attempt,timestamp:n.timestamp}}return e.failedReason?{message:e.failedReason}:null}function De({job:e,result:t,resultError:n,loading:r,notFound:i,busy:a,lookup:o,act:s}){if(r&&!e)return(0,W.jsx)(v,{label:`Loading job…`});if(i)return(0,W.jsx)(y,{title:`Job not found`,hint:`Check the ID, or the job may have been removed.`});if(!e)return(0,W.jsx)(y,{title:`No job loaded`,hint:`Enter a job ID above to inspect it.`});let c=e.state,l=Ee(e),u=e.stacktrace?.length?ne(e.stacktrace):null,f=(e.childrenIds?.length??0)>0,p=_e(c,e),m=c===`failed`,h=l||u?(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Error`}),l&&(0,W.jsxs)(`div`,{className:`mb-3`,children:[(0,W.jsx)(`p`,{className:`text-sm text-danger`,children:l.message}),(0,W.jsxs)(`p`,{className:`mt-1 text-[11px] text-faint`,children:[l.attempt==null?``:`Attempt ${l.attempt} · `,C(l.timestamp)]})]}),u&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap rounded-lg bg-surface-2 p-3 font-mono text-xs text-danger/90`,children:u.text}),u.truncated&&(0,W.jsxs)(`p`,{className:`mt-2 text-xs text-faint`,children:[`Stack preview truncated (`,u.displayedLines,` of `,u.totalLines,` `,`lines, 262,144 characters maximum). Download JSON for the complete stored stack.`]})]})]}):null;return(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-6 lg:col-span-2`,children:[(0,W.jsx)(Oe,{job:e}),m&&h,(0,W.jsx)(me,{data:e.data,busy:a,editable:p===null,readOnlyReason:p??void 0,onSave:t=>s(`Data`,()=>d.updateJobData(e.id,t))},`data-${e.id}`),c===`completed`&&(0,W.jsx)(ke,{jobId:e.id,result:t,resultError:n,loading:r,onRetry:()=>o(e.id,`id`)}),!m&&h,(0,W.jsx)(we,{jobId:e.id},`logs-${e.id}`),f&&(0,W.jsx)(pe,{jobId:e.id},`children-${e.id}`),(0,W.jsx)(Te,{timeline:e.timeline}),(0,W.jsx)(fe,{job:e})]}),(0,W.jsx)(`div`,{className:`order-first lg:order-none`,children:(0,W.jsx)(ce,{job:e,busy:a,act:s})})]})}function Oe({job:e}){return(0,W.jsxs)(_,{children:[(0,W.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(`div`,{className:`truncate font-mono text-sm text-fg`,children:e.id}),(0,W.jsx)(w,{value:e.id})]}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-xs text-faint`,children:e.queue})]}),(0,W.jsx)(b,{status:e.state??`unknown`})]}),(0,W.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-2 text-sm sm:grid-cols-3`,children:[(0,W.jsx)(Q,{label:`Priority`,value:String(e.priority??0)}),(0,W.jsx)(Q,{label:`Name`,value:e.name??`default`}),(0,W.jsx)(Q,{label:`Attempts`,value:`${e.attempts??0} / ${e.maxAttempts??`?`}`}),(0,W.jsx)(Q,{label:`Progress`,value:`${e.progress??0}%`}),(0,W.jsx)(Q,{label:`Created`,value:C(e.createdAt)}),(0,W.jsx)(Q,{label:`Started`,value:C(e.startedAt??void 0)}),(0,W.jsx)(Q,{label:`Completed`,value:C(e.completedAt??void 0)}),(0,W.jsx)(Q,{label:`Duration`,value:S(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Custom ID`}),(0,W.jsxs)(`dd`,{className:`flex items-center gap-1 text-fg`,children:[(0,W.jsx)(`span`,{className:`truncate font-mono`,children:e.customId??`—`}),e.customId&&(0,W.jsx)(w,{value:e.customId})]})]})]})]})}function ke({jobId:e,result:t,resultError:n,loading:r,onRetry:i}){let a=t.fetched&&t.value!==void 0&&t.value!==null;return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Result`,action:a?(0,W.jsx)(je,{value:t.value,filename:`job-${e}-result`}):void 0}),a?(0,W.jsx)(Ae,{value:t.value}):n?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,W.jsxs)(`p`,{className:`text-xs text-danger`,children:[`Couldn't load result — `,n]}),(0,W.jsx)(h,{size:`sm`,disabled:r,onClick:i,children:`Retry`})]}):(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`No result stored for this job.`})]})}function Q({label:e,value:t}){return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:e}),(0,W.jsx)(`dd`,{className:`text-fg`,children:t})]})}function Ae({value:e}){return(0,W.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:JSON.stringify(e??null,null,2)})}function je({value:e,filename:t}){return(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(w,{value:JSON.stringify(e??null,null,2)}),(0,W.jsx)(m,{"aria-label":`Download JSON`,title:`Download JSON`,onClick:()=>k(t,e??null),children:(0,W.jsx)(p,{className:`size-3.5`})})]})}function Me(e){let t={};return typeof e.priority==`number`&&(t.priority=e.priority),typeof e.maxAttempts==`number`&&(t.maxAttempts=e.maxAttempts),typeof e.backoff==`number`&&(t.backoff=e.backoff),e.backoffConfig&&typeof e.backoffConfig.delay==`number`&&(t.backoffConfig={type:e.backoffConfig.type,delay:e.backoffConfig.delay},typeof t.backoff!=`number`&&(t.backoff=e.backoffConfig.delay)),typeof e.timeout==`number`&&(t.timeout=e.timeout),typeof e.removeOnComplete==`boolean`&&(t.removeOnComplete=e.removeOnComplete),typeof e.removeOnFail==`boolean`&&(t.removeOnFail=e.removeOnFail),typeof e.ttl==`number`&&(t.ttl=e.ttl),Array.isArray(e.tags)&&e.tags.length&&(t.tags=[...e.tags]),typeof e.groupId==`string`&&e.groupId&&(t.groupId=e.groupId),{clone:{queue:e.queue??``,name:e.name,dataText:JSON.stringify(e.data??{},null,2),options:t}}}function Ne({job:e,result:t,idInput:n,lookupBy:r,loading:a,busy:o,onInputChange:s,onModeChange:c,onSubmit:l}){let u=!!(e&&((e.childrenIds?.length??0)>0||e.parentId));return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(x,{title:`Job Inspector`,description:`Look up any job by ID and drive its full lifecycle.`,actions:e?(0,W.jsxs)(W.Fragment,{children:[u&&(0,W.jsx)(i,{to:`/flows?root=${encodeURIComponent(e.id)}`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`View flow`}),(0,W.jsx)(i,{to:`/add-job`,state:Me(e),title:`Enqueue a new job pre-filled from this one`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Clone`}),(0,W.jsxs)(h,{size:`sm`,onClick:()=>k(`job-${e.id}`,t.fetched?{...e,result:t.value}:e),children:[(0,W.jsx)(p,{className:`size-3.5`}),` Download JSON`]})]}):void 0}),(0,W.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-2`,children:[(0,W.jsxs)(T,{name:`job-lookup-mode`,autoComplete:`off`,value:r,"aria-label":`Lookup mode`,onChange:e=>c(e.target.value),className:`w-40`,children:[(0,W.jsx)(`option`,{value:`id`,children:`By job ID`}),(0,W.jsx)(`option`,{value:`custom`,children:`By custom ID`})]}),(0,W.jsxs)(`div`,{className:`relative min-w-56 flex-1`,children:[(0,W.jsx)(f,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,W.jsx)(`input`,{value:n,"aria-label":r===`custom`?`Custom job ID`:`Job ID`,name:`job-lookup-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,onInput:e=>s(e.currentTarget.value),onKeyDown:e=>e.key===`Enter`&&l(n),placeholder:r===`custom`?`custom / idempotency id — Enter to look up`:`job id (UUID) — Enter to look up`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 font-mono text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,W.jsx)(h,{variant:`accent`,disabled:a||o,onClick:()=>l(n),children:`Look up`})]})]})}function Pe({state:e,lookup:t,setParams:n,locationKey:r,idParam:i,customParam:a,jobBelongsToCurrentTarget:o,connectionBaseUrl:s,connectionToken:c}){(0,U.useEffect)(()=>{if(e.internalEmptyUrlPending.current){!i&&!a&&(e.internalEmptyUrlPending.current=!1,e.preservedEmptyLocationKey.current=r);return}if(!(!i&&!a&&e.preservedEmptyLocationKey.current===r))if(e.preservedEmptyLocationKey.current=null,a)if(e.job?.customId===a&&o)e.setLookupBy(`id`),e.setIdInput(e.job.id),n({id:e.job.id},{replace:!0});else{e.setLookupBy(`custom`),e.setIdInput(a);let n=e.lookupIdentity.current;(n?.mode!==`custom`||n.key!==a)&&t(a,`custom`,!1,void 0,!0)}else if(i&&(i!==e.job?.id||!o)){e.setLookupBy(`id`),e.setIdInput(i);let n=e.lookupIdentity.current;(n?.mode!==`id`||n.key!==i)&&t(i,`id`,!1,void 0,!0)}else!i&&!a&&(e.lookupGen.current+=1,e.lookupAbort.current?.abort(),e.lookupAbort.current=null,e.lookupIdentity.current=null,e.actionGen.current+=1,e.jobTarget.current=null,e.setJob(null),e.setResult({fetched:!1,value:void 0}),e.setResultError(null),e.setNotFound(!1),e.setMsg(null),e.setLoading(!1),e.setLookupBy(`id`),e.setIdInput(``))},[i,a,e.job?.id,e.job?.customId,o,r,s,c])}var $={fetched:!1,value:void 0};function Fe(e,t){let[n,r]=(0,U.useState)(e??t??``),[i,a]=(0,U.useState)(e?`custom`:`id`),[o,c]=(0,U.useState)(null),[l,u]=(0,U.useState)($),[d,f]=(0,U.useState)(null),[p,m]=(0,U.useState)(!1),[h,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(null),[y,b]=(0,U.useState)(!1),x=(0,U.useRef)(0),S=(0,U.useRef)(null),C=(0,U.useRef)(null),w=(0,U.useRef)(null),T=(0,U.useRef)(!1),E=(0,U.useRef)(null),D=(0,U.useRef)(!1),O=(0,U.useRef)(0),k=(0,U.useRef)(!1),A=(0,U.useRef)(null);return(0,U.useEffect)(()=>{D.current=!0;let e=s.subscribe((e,t)=>{e.baseUrl===t.baseUrl&&e.token===t.token||(x.current+=1,S.current?.abort(),S.current=null,C.current=null,O.current+=1,A.current=null,k.current=!1,w.current=null,T.current=!1,E.current=null,c(null),u($),f(null),g(!1),v(null),m(!1),b(!1))});return()=>{D.current=!1,e(),x.current+=1,S.current?.abort(),S.current=null,C.current=null,O.current+=1,A.current=null,k.current=!1}},[]),{idInput:n,setIdInput:r,lookupBy:i,setLookupBy:a,job:o,setJob:c,result:l,setResult:u,resultError:d,setResultError:f,loading:p,setLoading:m,notFound:h,setNotFound:g,msg:_,setMsg:v,busy:y,setBusy:b,lookupGen:x,lookupAbort:S,lookupIdentity:C,jobTarget:w,internalEmptyUrlPending:T,preservedEmptyLocationKey:E,mounted:D,actionGen:O,actionBusy:k,actionLockOwner:A}}function Ie(){let e=r(),[n,i]=t(),a=s(e=>e.baseUrl),c=s(e=>e.token),l=Fe(n.get(`custom`),n.get(`id`)),d=se(l,i),f=n.get(`id`),p=n.get(`custom`),m={baseUrl:o(),authorization:c?`Bearer ${c}`:void 0},h=B(l.jobTarget.current,m);return Pe({state:l,lookup:d,setParams:i,locationKey:e.key,idParam:f,customParam:p,jobBelongsToCurrentTarget:h,connectionBaseUrl:a,connectionToken:c}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Ne,{job:l.job,result:l.result,idInput:l.idInput,lookupBy:l.lookupBy,loading:l.loading,busy:l.busy,onInputChange:l.setIdInput,onModeChange:l.setLookupBy,onSubmit:(e,t=l.lookupBy)=>{let n=e.trim();if(!(!n||l.actionBusy.current)){if(t===`id`?f===n&&p===null:p===n&&f===null){d(n,t);return}i(t===`custom`?{custom:n}:{id:n})}}}),l.msg&&(0,W.jsx)(`div`,{role:`status`,className:l.msg.ok?`mb-4 text-sm text-success`:`mb-4 text-sm text-danger`,children:l.msg.text}),(0,W.jsx)(De,{job:l.job,result:l.result,resultError:l.resultError,loading:l.loading,notFound:l.notFound,busy:l.busy,lookup:d,act:async(e,t,n)=>{if(!l.job||l.actionBusy.current||l.lookupAbort.current)return;let r=z();if(!B(l.jobTarget.current,r)||n&&!window.confirm(n))return;let a=++l.actionGen.current,o=l.job.id;l.actionLockOwner.current=a,l.actionBusy.current=!0,l.setBusy(!0),l.setMsg(null);let s=()=>l.mounted.current&&a===l.actionGen.current&&B(r,z())&&B(l.jobTarget.current,r);try{let n=await t();if(!n||typeof n!=`object`||Array.isArray(n)||n.ok!==!0)throw new u(`Invalid job mutation response: expected { ok: true }`,200);if(!s())return;l.setMsg({ok:!0,text:`${e} ✓`}),e===`Cancel`?(l.internalEmptyUrlPending.current=!0,l.preservedEmptyLocationKey.current=null,l.lookupGen.current+=1,l.jobTarget.current=null,l.setJob(null),l.setResult({fetched:!1,value:void 0}),l.setResultError(null),i({},{replace:!0})):await d(o,`id`,!0,a)}catch(e){s()&&l.setMsg({ok:!1,text:e.message})}finally{l.actionLockOwner.current===a&&(l.actionLockOwner.current=null,l.actionBusy.current=!1,l.mounted.current&&l.setBusy(!1))}}})]})}export{Ie as JobInspector};
@@ -0,0 +1 @@
1
+ import{i as e}from"./cn-zFEt5SO8.js";import{f as t,g as n,r,t as i}from"./react-vendor-CyjgmGTq.js";import{t as a}from"./bq-BeBxa743.js";import{T as o}from"./icons-CIvFfU2b.js";import{t as s}from"./api-CQ5Z7xR7.js";import{n as c}from"./usePolledData-DzlUpBOO.js";import{i as l,r as u}from"./feedback-BnGE2oW2.js";import{t as d}from"./StatusBadge-B0I7hNBX.js";import{t as f}from"./PageHeader-BXlZSBcc.js";import{a as p,c as m,d as h,l as g,s as _,t as v}from"./format-Cg7VCIZW.js";import{n as y}from"./index-Cui9IwWy.js";import{a as b,i as x}from"./form-tC20r4Ma.js";import{r as S}from"./flowMutationSafety-CoOp94wS.js";import{t as C}from"./promisePool-BVfQ9n9Q.js";var w=e(n(),1),T=`__all__`,E=[`all`,`waiting`,`active`,`completed`,`failed`],D=500,O=20,k=D*O;function A(e,t,n){if(typeof e!=`object`||!e||e.ok!==!0||!Array.isArray(e.queues)||!Number.isSafeInteger(e.total)||e.total<0||e.total>k||n!==null&&e.total!==n||e.offset!==t||e.limit!==D||e.queues.length!==Math.min(D,e.total-t)||e.queues.length>D||e.queues.some(e=>typeof e!=`object`||!e||typeof e.name!=`string`||e.name.length===0||e.name.length>256||!/^[a-zA-Z0-9_\-.:]+$/.test(e.name)))throw Error(`Queue discovery returned a malformed or unsafe page`)}async function j(){let e=await s.queues(D,0);A(e,0,null);let t=[...e.queues],n=new Set;for(let e of t){if(n.has(e.name))throw Error(`Queue discovery returned duplicate queue ${e.name}`);n.add(e.name)}let r=e.total,i=1;for(;t.length<r;){if(i>=O||t.length>=k)throw Error(`Queue discovery exceeds the safety limit of ${k}`);let e=t.length,a=await s.queues(D,e);A(a,e,r);for(let e of a.queues){if(n.has(e.name))throw Error(`Queue discovery pages overlap at queue ${e.name}`);n.add(e.name),t.push(e)}i+=1}return{...e,queues:t,total:r,limit:t.length,offset:0}}function M(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e.name;return typeof t==`string`&&t.length>0?t:null}var N=i();function P({rows:e,emptyMessage:t}){return(0,N.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,N.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,N.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Priority`}),(0,N.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,N.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,N.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,N.jsx)(`tbody`,{children:e.length===0?(0,N.jsx)(`tr`,{children:(0,N.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:t})}):e.map(e=>(0,N.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,N.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs`,children:(0,N.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`text-accent/90 hover:text-accent hover:underline`,title:`Inspect job ${e.id}`,children:e.id})}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name??M(e.data)??`default`}),(0,N.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue}),(0,N.jsx)(`td`,{className:`px-5 py-3`,children:(0,N.jsx)(d,{status:String(e.state??e.status??`waiting`)})}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.priority??0}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:g(e.createdAt)}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(h(e.startedAt??void 0,e.completedAt??void 0))}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,N.jsx)(`span`,{className:`text-xs text-faint`,title:S,children:`Delete unavailable`})})]},`${e.queue}:${e.id}`))})]})})}var F=8;function I(){let[e]=t(),[n,r]=(0,w.useState)(e.get(`queue`)??`__all__`),[i,d]=(0,w.useState)(`all`),[p,h]=(0,w.useState)(``),{data:g,error:S,refetch:D}=c(j,[],{intervalMs:3e4}),{data:O,error:k,refetch:A}=c(()=>s.overview(),[]),I=(0,w.useMemo)(()=>(g?.queues??[]).map(e=>e.name),[g]),L=`${n}\u0000${i}\u0000${JSON.stringify(I)}`,{data:R,error:z,loading:B,refetch:V}=c((0,w.useCallback)(async e=>{if(n===`__all__`&&!g)return null;let t=n===`__all__`?I:[n];if(n===`__all__`&&t.length>100)return{scopeKey:L,jobs:[],failures:[],queueCount:t.length,blockedReason:`All-queue job browsing is limited to 100 queues; ${_(t.length)} were discovered. Select one queue to avoid an unsafe request fan-out.`};let r=i===`all`?void 0:[i],o=a.createServerTargetClient(a.captureServerRequestTarget(),e),s=await C(t,F,async t=>(e.throwIfAborted(),(await o.jobsList(t,r,40)).jobs.map(e=>({...e,stacktrace:e.stacktrace??void 0,queue:e.queue??t}))),e);e.throwIfAborted();let c=[],l=[];return s.forEach((e,n)=>{e.status===`fulfilled`?c.push(...e.value):l.push({queue:t[n],message:e.reason instanceof Error?e.reason.message:String(e.reason)})}),{scopeKey:L,jobs:c.sort((e,t)=>(t.createdAt??0)-(e.createdAt??0)),failures:l,queueCount:t.length,blockedReason:null}},[n,i,g,I,L]),[L],{intervalMs:15e3}),H=R?.scopeKey===L?R:null,U=H?.blockedReason?null:H?.jobs??null,{rows:W,matchingCount:G}=(0,w.useMemo)(()=>{let e=U??[],t=p.trim().toLowerCase(),n=t?e.filter(e=>typeof e.id==`string`&&e.id.toLowerCase().includes(t)||(M(e.data)?.toLowerCase().includes(t)??!1)):e;return{rows:n.slice(0,100),matchingCount:n.length}},[U,p]),K=O?.stats,q=K?v(K.totalCompleted,K.totalFailed):null,J=e=>K?_(e):`—`,Y=!!H&&H.queueCount>0&&H.failures.length===H.queueCount,X=n===`__all__`&&!g&&!S||B&&!H&&!z,Z=`No jobs found.`;return H?.blockedReason?Z=H.blockedReason:n===`__all__`&&S&&!g?Z=`Queue discovery unavailable — ${S.message}`:z&&!H?Z=`Could not load jobs — ${z.message}`:Y?Z=`Could not load jobs from any of the ${H.queueCount} queues.`:p.trim()&&H?.failures.length?Z=`No matching jobs in the queue results that could be loaded.`:p.trim()&&(Z=`No jobs match this search.`),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(f,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!!H&&!S&&!k&&!z&&!H.blockedReason&&H.failures.length===0}),S&&(0,N.jsx)(l,{message:`Queue discovery unavailable — ${S.message}`,onRetry:D}),k&&(0,N.jsx)(l,{message:`Job totals unavailable — ${k.message}`,onRetry:A}),z&&(0,N.jsx)(l,{message:`Could not load jobs — ${z.message}`,onRetry:V}),H?.blockedReason&&(0,N.jsx)(l,{message:H.blockedReason}),!!H?.failures.length&&(0,N.jsx)(l,{message:`Could not load jobs from ${H.failures.length} of ${H.queueCount} queues: ${H.failures.slice(0,3).map(e=>`${e.queue} (${e.message})`).join(`, `)}${H.failures.length>3?`, …`:``}`,onRetry:V}),(0,N.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,N.jsx)(y,{label:`Total`,value:K?_(K.totalCompleted+K.totalFailed+K.waiting+K.active):`—`,compact:!0}),(0,N.jsx)(y,{label:`Waiting`,value:J(K?.waiting),tone:`amber`,compact:!0}),(0,N.jsx)(y,{label:`Active`,value:J(K?.active),tone:`blue`,compact:!0}),(0,N.jsx)(y,{label:`Completed`,value:J(K?.totalCompleted),tone:`green`,compact:!0}),(0,N.jsx)(y,{label:`Failed`,value:J(K?.totalFailed),tone:K?.totalFailed?`red`:`default`,compact:!0}),(0,N.jsx)(y,{label:`Error Rate`,value:q==null?`—`:m(q),tone:q==null?`default`:q>.05?`red`:`green`,compact:!0})]}),(0,N.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,N.jsx)(`div`,{className:`w-48`,children:(0,N.jsxs)(b,{value:n,"aria-label":`Queue`,name:`jobs-queue`,autoComplete:`off`,onChange:e=>r(e.target.value),children:[(0,N.jsx)(`option`,{value:T,children:`All Queues`}),(g?.queues??[]).map(e=>(0,N.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,N.jsx)(x,{options:E,value:i,onChange:d}),(0,N.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,N.jsx)(o,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,N.jsx)(`input`,{value:p,onChange:e=>h(e.target.value),"aria-label":`Search jobs`,name:`jobs-search`,autoComplete:`off`,placeholder:`Search by ID or name…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),H&&!H.blockedReason&&(0,N.jsxs)(`p`,{role:`status`,className:`mb-3 text-xs text-faint`,children:[n===`__all__`?`Queried all ${_(H.queueCount)} discovered queues`:`Queried ${n}`,` `,`· up to `,40,` recent jobs per queue`,G>100?` · showing the newest 100 of ${_(G)} matches`:``]}),X?(0,N.jsx)(u,{label:`Loading jobs…`}):(0,N.jsx)(P,{rows:W,emptyMessage:Z})]})}export{I as Jobs,j as t};
@@ -0,0 +1 @@
1
+ import{i as e,t}from"./cn-zFEt5SO8.js";import{f as n,g as r,r as i,t as a}from"./react-vendor-CyjgmGTq.js";import{t as o}from"./bq-BeBxa743.js";import{t as s}from"./toastStore-CS_9Xndn.js";import{T as c,d as l,f as u,x as d}from"./icons-CIvFfU2b.js";import{n as f}from"./usePolledData-DzlUpBOO.js";import{n as p,t as m}from"./Button-BPqpRZJD.js";import{i as h,n as g,r as _}from"./feedback-BnGE2oW2.js";import{t as v}from"./StatusBadge-B0I7hNBX.js";import{t as y}from"./PageHeader-BXlZSBcc.js";import{a as b,c as x,i as S,s as C,t as ee}from"./format-Cg7VCIZW.js";import{n as w}from"./index-Cui9IwWy.js";import{a as T}from"./form-tC20r4Ma.js";import{t as E}from"./Pagination-Q-vf4hsX.js";import{r as D,t as O}from"./useServerActionGuard-BlH-Kso1.js";import{t as te}from"./exportFile-C7xhE8Yh.js";import{t as k}from"./jobActions-LQD4KfCc.js";var A=e(r(),1),j=a();function ne(e){return(0,j.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4 xl:grid-cols-8`,children:[(0,j.jsx)(w,{label:`Total`,value:e.total,hint:`all queues`,compact:!0}),(0,j.jsx)(w,{label:`Waiting`,value:e.waiting,tone:`amber`,hint:`standard priority`,compact:!0}),(0,j.jsx)(w,{label:`Prioritized`,value:e.prioritized,tone:`amber`,compact:!0}),(0,j.jsx)(w,{label:`Active`,value:e.active,tone:`blue`,compact:!0}),(0,j.jsx)(w,{label:`Flow-blocked`,value:e.flowBlocked,tone:`blue`,compact:!0}),(0,j.jsx)(w,{label:`Completed`,value:e.completed,tone:`green`,compact:!0}),(0,j.jsx)(w,{label:`Failed`,value:e.failed,tone:e.failedCount!=null&&e.failedCount>0?`red`:`default`,compact:!0}),(0,j.jsx)(w,{label:`Error Rate`,value:e.errorRate,tone:e.errorRateTone,compact:!0})]})}var M=[`all`,`waiting`,`prioritized`,`active`,`delayed`,`waiting-children`,`paused`,`completed`,`failed`];function N(e,t){return e===t?`${t} selected`:`${e} of ${t} selected match this filter`}function P(e,t){let n=new Set(e);for(let e of t)n.delete(e);return n}function F(e=0){return e>=10?{text:`HIGH`,className:`text-warning`}:e>=1?{text:`MEDIUM`,className:`text-blue-400`}:{text:`LOW`,className:`text-faint`}}function re({queue:e,rows:n,search:r,discoveryError:a,selected:s,allSelected:c,bulkBusy:l,busyIds:f,page:m,hasNext:h,onToggleAll:g,onToggle:_,onRun:y,onPage:x}){return(0,j.jsxs)(j.Fragment,{children:[e&&(0,j.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm`,children:[(0,j.jsx)(`span`,{className:`text-faint`,children:`Jobs in queue`}),(0,j.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-fg`,children:e})]}),(0,j.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,j.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,j.jsx)(`th`,{className:`w-10 px-5 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:c,ref:e=>{e&&(e.indeterminate=s.size>0&&!c)},"aria-checked":s.size>0&&!c?`mixed`:c,onChange:g,"aria-label":`Select all jobs on page`,className:`accent-accent`})}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Priority`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,j.jsx)(`th`,{className:`w-28 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,j.jsx)(`tbody`,{children:n.length===0?(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:r.trim()?`No jobs on this page match your ID or name filter.`:e?`No jobs found.`:a?`Queue discovery failed. Retry above.`:`Select a queue.`})}):n.map(e=>{let n=F(e.priority),r=k(e.state),a=l||f.has(e.id);return(0,j.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:s.has(e.id),onChange:()=>_(e.id),"aria-label":`Select job ${e.id}`,className:`accent-accent`})}),(0,j.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:(0,j.jsx)(`span`,{className:`block max-w-[16rem] truncate`,title:e.id,children:e.id})}),(0,j.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.name??`default`}),(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsx)(v,{status:String(e.state??`waiting`)})}),(0,j.jsx)(`td`,{className:t(`px-5 py-3 text-xs font-semibold`,n.className),children:n.text}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:S(e.createdAt)}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:b(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,j.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,"aria-label":`Inspect job ${e.id}`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,j.jsx)(u,{className:`size-3.5`})}),r.promote&&(0,j.jsx)(p,{"aria-label":`Promote job`,disabled:a,onClick:()=>y(e,`Promote`,()=>o.promoteJob(e.id)),children:(0,j.jsx)(d,{className:`size-3.5`})})]})})]},e.id)})})]})}),(0,j.jsx)(E,{page:m,pageSize:25,hasNext:h,onPageChange:x,label:`jobs`})]})}function I({queue:e,summary:t,status:n,search:r,selectedTotal:i,selectedVisible:a,canPromote:o,bulkBusy:s,onQueue:l,onStatus:u,onSearch:d,onPromote:f}){return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,j.jsx)(`div`,{className:`w-48`,children:(0,j.jsx)(T,{value:e,"aria-label":`Queue`,name:`jobs-queue`,autoComplete:`off`,onChange:e=>l(e.target.value),children:t.map(e=>(0,j.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),(0,j.jsx)(`div`,{className:`w-48`,children:(0,j.jsx)(T,{"aria-label":`Job state`,name:`jobs-state`,value:n,onChange:e=>u(e.target.value),children:M.map(e=>(0,j.jsx)(`option`,{value:e,children:e===`all`?`All states`:e},e))})}),(0,j.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,j.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,j.jsx)(`input`,{value:r,onChange:e=>d(e.target.value),placeholder:`Filter this page by ID or name…`,"aria-label":`Filter by job ID or name`,name:`jobs-id-filter`,autoComplete:`off`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),i>0&&(0,j.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-lg border border-line bg-surface-2 px-4 py-2 text-sm`,children:[(0,j.jsx)(`span`,{className:`mr-1 text-muted`,children:N(a,i)}),o?(0,j.jsx)(m,{size:`sm`,disabled:s,onClick:f,children:`Promote selected`}):(0,j.jsx)(`span`,{className:`text-xs text-faint`,children:a===0?`The selected jobs are hidden by the filter — clear it to act on them.`:`No actions apply to the selected job states.`})]})]})}function ie({queue:e,rows:t,selected:n,setSelected:r,refetch:i}){let[a,o]=(0,A.useState)(new Set),[c,l]=(0,A.useState)(!1),[u,d]=(0,A.useState)(null),f=D(`jobs:${e}`);return(0,A.useEffect)(()=>{o(new Set),l(!1),d(null)},[f.scopeKey]),{actionMsg:u,bulkBusy:c,busyIds:a,runBulk:async(e,a,o,c)=>{let u=t.filter(e=>n.has(e.id)&&o(e));if(u.length===0||c&&!window.confirm(c(u.length)))return;let p=f.begin([`bulk`,...u.map(e=>`job:${e.id}`)]);if(p){l(!0),d(null);try{let t=await Promise.allSettled(u.map(async t=>{O(await a(t),`${e} ${t.id}`)}));if(!p.isCurrent())return;let n=t.filter(e=>e.status===`fulfilled`).length,o=t.length-n,c=`${e}: ${n} succeeded${o?`, ${o} failed`:``}`;d({ok:o===0,text:c}),o===0?s.success(c):s.error(c),r(e=>P(e,u.map(e=>e.id))),i()}finally{p.finish()&&l(!1)}}},runOne:async(e,t,n,r)=>{if(r&&!window.confirm(r))return;let a=f.begin(`job:${e.id}`);if(a){o(t=>new Set(t).add(e.id)),d(null);try{if(O(await n(),t),!a.isCurrent())return;d({ok:!0,text:`${t} ✓`}),s.success(`${t} ✓`,e.id),i()}catch(e){if(!a.isCurrent())return;d({ok:!1,text:`${t} failed: ${e.message}`}),s.error(`${t} failed`,e.message)}finally{a.finish()&&o(t=>{let n=new Set(t);return n.delete(e.id),n})}}}}}function L(){let[e,t]=n(),[r,i]=(0,A.useState)(e.get(`queue`)??``),[a,c]=(0,A.useState)(()=>{let t=e.get(`status`);return t&&M.includes(t)?t:`all`}),[u,d]=(0,A.useState)(``),[p,v]=(0,A.useState)(0),[b,S]=(0,A.useState)(new Set),{data:w,error:T,loading:E,refetch:D}=f(()=>o.queuesSummary(),[],{intervalMs:3e4}),{data:O,error:N,refetch:P}=f(()=>o.stats(),[],{intervalMs:1e4});(0,A.useEffect)(()=>{!r&&w?.length&&i(w[0].name)},[w,r]);let F=`${r}|${a}|${p}`,{data:L,error:R,loading:z,refetch:B}=f((0,A.useCallback)(async()=>{if(!r)return{view:F,jobs:[]};let e=a===`all`?void 0:[a],t=await o.jobsList(r,e,25,p*25);return{view:F,jobs:(t.jobs??[]).map(e=>({...e,queue:e.queue??r}))}},[r,a,p,F]),[r,a,p]),V=L&&L.view===F?L.jobs:null,ae=(V?.length??0)===25,H=(0,A.useMemo)(()=>{let e=u.trim().toLowerCase();return e?(V??[]).filter(t=>t.id.toLowerCase().includes(e)||t.name?.toLowerCase().includes(e)):V??[]},[V,u]),U=O?.stats,W=(0,A.useMemo)(()=>w?.reduce((e,t)=>e+(t.counts?.failed??0),0)??null,[w]),G=U&&W!=null?ee(U.completed,W):null,K=e=>U?C(e):`—`,q=()=>v(0),J=(e,n)=>{let r={};e&&(r.queue=e),n!==`all`&&(r.status=n),t(r,{replace:!0})};(0,A.useEffect)(()=>{S(new Set)},[r,a,p]);let oe=e=>S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),Y=H.length>0&&H.every(e=>b.has(e.id)),se=()=>S(()=>Y?new Set:new Set(H.map(e=>e.id))),{actionMsg:X,bulkBusy:Z,busyIds:ce,runBulk:le,runOne:ue}=ie({queue:r,rows:H,selected:b,setSelected:S,refetch:B}),Q={promote:e=>k(e.state).promote},$=H.filter(e=>b.has(e.id)),de={promote:$.some(Q.promote)};return(0,j.jsxs)(`div`,{children:[(0,j.jsx)(y,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!!r&&V!=null&&!R&&!T&&!N,actions:(0,j.jsxs)(m,{size:`sm`,disabled:!V||H.length===0,onClick:()=>{if(H.length===0){s.info(`No jobs to export on this page`);return}let e=H.map(e=>({id:e.id,name:e.name??`default`,queue:e.queue??r,state:e.state??``,priority:e.priority??0,attempts:e.attempts??0,maxAttempts:e.maxAttempts??``,createdAt:e.createdAt?new Date(e.createdAt).toISOString():``,durationMs:e.startedAt&&e.completedAt?e.completedAt-e.startedAt:``}));te(`jobs-${r}-${a}`,e,[`id`,`name`,`queue`,`state`,`priority`,`attempts`,`maxAttempts`,`createdAt`,`durationMs`])},children:[(0,j.jsx)(l,{className:`size-3.5`}),` Export CSV`]})}),T&&(0,j.jsx)(h,{onRetry:D,message:w?`Queue inventory refresh failed — showing the last successful queue totals. ${T.message}`:`Could not discover queues — ${T.message}. Select an existing queue from the URL or retry.`}),N&&(0,j.jsx)(h,{onRetry:P,message:O?`Server-wide totals refresh failed — showing the last successful totals. ${N.message}`:`Server-wide job totals are unavailable — ${N.message}. The selected queue page may still be current.`}),(0,j.jsx)(ne,{total:U&&W!=null?C(U.completed+W+U.waiting+U.prioritized+U.active+U.delayed+U[`waiting-children`]):`—`,waiting:K(U?.waiting),prioritized:K(U?.prioritized),active:K(U?.active),flowBlocked:K(U?.[`waiting-children`]),completed:K(U?.completed),failed:W==null?`—`:C(W),failedCount:W,errorRate:G==null?`—`:x(G),errorRateTone:G==null?`default`:G>.05?`red`:`green`}),(0,j.jsx)(I,{queue:r,summary:w??[],status:a,search:u,selectedTotal:b.size,selectedVisible:$.length,canPromote:de.promote,bulkBusy:Z,onQueue:e=>{i(e),q(),J(e,a)},onStatus:e=>{c(e),q(),J(r,e)},onSearch:d,onPromote:()=>le(`Promote`,e=>o.promoteJob(e.id),Q.promote)}),X&&(0,j.jsx)(`div`,{role:`status`,className:`mb-3 text-sm ${X.ok?`text-success`:`text-danger`}`,children:X.text}),R&&V&&(0,j.jsx)(h,{message:`Job refresh failed — showing the last successful page.`,onRetry:B}),R&&!V?(0,j.jsx)(g,{error:R,onRetry:B}):E&&!w&&!r&&!T?(0,j.jsx)(_,{label:`Discovering queues…`}):z&&!V?(0,j.jsx)(_,{label:`Loading jobs…`}):(0,j.jsx)(re,{queue:r,rows:H,search:u,discoveryError:!!T,selected:b,allSelected:Y,bulkBusy:Z,busyIds:ce,page:p,hasNext:ae,onToggleAll:se,onToggle:oe,onRun:(e,t,n)=>void ue(e,t,n),onPage:v})]})}export{L as JobsPro};
@@ -0,0 +1 @@
1
+ import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CyjgmGTq.js";import{T as r,h as i}from"./icons-CIvFfU2b.js";import{n as a}from"./usePolledData-DzlUpBOO.js";import{i as o,t as s}from"./feedback-BnGE2oW2.js";import{t as c}from"./StatusBadge-B0I7hNBX.js";import{t as l}from"./PageHeader-BXlZSBcc.js";import{l as u,s as d}from"./format-Cg7VCIZW.js";import{n as f,t as p}from"./index-Cui9IwWy.js";import{a as m,i as h}from"./form-tC20r4Ma.js";import{t as g}from"./Pagination-Q-vf4hsX.js";import{t as _}from"./Jobs-Bla3IEef.js";var v=e(t(),1),y=n(),b=`__all__`,x=[`all`,`waiting`,`active`,`completed`,`failed`],S=10;async function C(){let e=await _();if(!Number.isFinite(e.timestamp)||e.queues.some(e=>!Number.isSafeInteger(e.waiting)||e.waiting<0||!Number.isSafeInteger(e.delayed)||e.delayed<0||!Number.isSafeInteger(e.active)||e.active<0||!Number.isSafeInteger(e.dlq)||e.dlq<0||typeof e.paused!=`boolean`))throw Error(`Queue discovery returned malformed queue summaries`);return e}function w(){let[e,t]=(0,v.useState)(b),[n,_]=(0,v.useState)(`all`),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(0),{data:O,error:k,refetch:A}=a(C,[],{intervalMs:3e4}),{events:j,counters:M,throughput:N,connected:P,error:F}=p(e===b?void 0:e),I=(0,v.useMemo)(()=>{let e=w.trim().toLowerCase();return j.filter(t=>n!==`all`&&t.status!==n?!1:!e||(t.jobId??``).toLowerCase().includes(e)||(t.name??``).toLowerCase().includes(e)||(t.queue??``).toLowerCase().includes(e))},[j,n,w]);(0,v.useEffect)(()=>D(0),[e,n,w]);let L=Math.max(1,Math.ceil(I.length/S)),R=Math.min(E,L-1);return(0,y.jsxs)(`div`,{children:[(0,y.jsx)(l,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:P}),k&&(0,y.jsx)(o,{onRetry:A,message:`Could not discover queues — ${k.message}. The current stream can still be used.`}),F&&(0,y.jsx)(o,{message:`Event stream unavailable — ${F.message}. Retrying…`}),(0,y.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,y.jsx)(f,{label:`Total Events`,value:d(M.total),compact:!0}),(0,y.jsx)(f,{label:`Completed`,value:d(M.completed),tone:`green`,compact:!0}),(0,y.jsx)(f,{label:`Failed`,value:d(M.failed),tone:M.failed?`red`:`default`,compact:!0}),(0,y.jsx)(f,{label:`Waiting`,value:d(M.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(f,{label:`Active`,value:d(M.active),tone:`blue`,compact:!0}),(0,y.jsx)(f,{label:`Throughput`,value:`${N.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,y.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-48`,children:(0,y.jsxs)(m,{value:e,"aria-label":`Filter by queue`,name:`classic-activity-queue-filter`,autoComplete:`off`,onChange:e=>t(e.target.value),children:[(0,y.jsx)(`option`,{value:b,children:`All Queues`}),(O?.queues??[]).map(e=>(0,y.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,y.jsx)(h,{options:x,value:n,onChange:_}),(0,y.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,y.jsx)(r,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,y.jsx)(`input`,{"aria-label":`Search by job name or ID`,name:`classic-activity-search`,autoComplete:`off`,value:w,onChange:e=>T(e.target.value),placeholder:`Search by job name or ID…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),I.length===0?(0,y.jsx)(s,{icon:(0,y.jsx)(i,{}),title:F?`Event stream unavailable`:P?`Waiting for activity…`:`Connecting to the event stream…`,hint:F?`${F.message}. The dashboard is retrying automatically.`:`Job events stream in here live as they happen on the server.`}):(0,y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,y.jsx)(`tbody`,{children:I.slice(R*S,R*S+S).map(e=>(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(c,{status:e.status})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.event||`job event`}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:u(e.timestamp)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId||`—`})]},e.seq))})]})}),(0,y.jsx)(g,{page:R,pageSize:S,total:I.length,onPageChange:D,label:`events`})]})}export{w as Logs};
@@ -0,0 +1 @@
1
+ import{i as e}from"./cn-zFEt5SO8.js";import{g as t,r as n,t as r}from"./react-vendor-CyjgmGTq.js";import{o as i}from"./connectionStore-DbBYqHEY.js";import{T as a}from"./icons-CIvFfU2b.js";import{n as o}from"./usePolledData-DzlUpBOO.js";import{t as s}from"./Button-BPqpRZJD.js";import{i as c}from"./feedback-BnGE2oW2.js";import{t as l}from"./StatusBadge-B0I7hNBX.js";import{t as u}from"./PageHeader-BXlZSBcc.js";import{l as d,s as f}from"./format-Cg7VCIZW.js";import{a as p,n as m,t as h}from"./index-Cui9IwWy.js";import{a as g,i as _}from"./form-tC20r4Ma.js";import{t as v}from"./Pagination-Q-vf4hsX.js";import{t as y}from"./QueueControl-B8Q9NX6t.js";var b=e(t(),1),x=r(),S=`__all__`,C=[`all`,`waiting`,`active`,`completed`,`failed`],w=10,T=250;function E(){let[e,t]=(0,b.useState)(S),[r,E]=(0,b.useState)(`all`),[D,O]=(0,b.useState)(``),[k,A]=(0,b.useState)(0),[j,M]=(0,b.useState)(null),N=j!==null,P=i(t=>JSON.stringify([t.baseUrl,t.token,e])),{data:F,error:I,refetch:L}=o(y,[],{intervalMs:3e4}),{events:R,counters:z,throughput:B,connected:V,error:H}=h(e===S?void 0:e),U=(0,b.useMemo)(()=>{let e=j??R,t=D.trim().toLowerCase();return e.filter(e=>r!==`all`&&e.status!==r?!1:!t||(e.jobId??``).toLowerCase().includes(t)||(e.queue??``).toLowerCase().includes(t))},[R,j,r,D]),W=N?Math.max(0,(R[0]?.seq??0)-(j[0]?.seq??0)):0;(0,b.useEffect)(()=>A(0),[e,r,D]),(0,b.useEffect)(()=>M(null),[P]);let G=k*w,K=U.slice(G,G+w);return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(u,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:V&&!N}),I&&(0,x.jsx)(c,{onRetry:L,message:`Could not discover queues — ${I.message}. The current stream can still be used.`}),H&&(0,x.jsx)(c,{message:`Event stream unavailable — ${H.message}. Retrying…`}),(0,x.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,x.jsx)(m,{label:`Total Events`,value:f(z.total),compact:!0}),(0,x.jsx)(m,{label:`Completed`,value:f(z.completed),tone:`green`,compact:!0}),(0,x.jsx)(m,{label:`Failed`,value:f(z.failed),tone:z.failed?`red`:`default`,compact:!0}),(0,x.jsx)(m,{label:`Waiting`,value:f(z.waiting),tone:`amber`,compact:!0}),(0,x.jsx)(m,{label:`Active`,value:f(z.active),tone:`blue`,compact:!0}),(0,x.jsx)(m,{label:`Throughput`,value:`${B.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,x.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,x.jsx)(`div`,{className:`w-48`,children:(0,x.jsxs)(g,{"aria-label":`Filter by queue`,name:`activity-queue-filter`,autoComplete:`off`,value:e,onChange:e=>t(e.target.value),children:[(0,x.jsx)(`option`,{value:S,children:`All Queues`}),(F?.queues??[]).map(e=>(0,x.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,x.jsx)(_,{options:C,value:r,onChange:E}),(0,x.jsx)(s,{size:`sm`,variant:N?`warning`:`default`,onClick:()=>M(N?null:R),title:N?`Resume applying live events to the list`:`Freeze the visible list while the stream keeps buffering`,children:N?`Resume${W?` — ${f(W)} new`:``}`:`Following · Pause`}),(0,x.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,x.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,x.jsx)(`input`,{"aria-label":`Search by job ID or queue`,name:`activity-search`,autoComplete:`off`,value:D,onChange:e=>O(e.target.value),placeholder:`Search by job ID or queue…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),(0,x.jsxs)(`p`,{className:`-mt-2 mb-4 text-xs text-faint`,children:[`Search and filters cover the last `,T,` streamed events held in this browser.`]}),(0,x.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,x.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,x.jsx)(`tbody`,{children:K.length===0?(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:H?`Event stream unavailable — ${H.message}. Retrying…`:V?R.length>0?`No events match the current filters.`:`Waiting for activity…`:`Connecting to the event stream…`})}):K.map(e=>(0,x.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(l,{status:e.status})}),(0,x.jsxs)(`td`,{className:`px-5 py-3 font-mono text-xs text-fg`,children:[e.event,e.status===`failed`&&e.error&&(0,x.jsx)(`div`,{className:`mt-0.5 max-w-64 truncate text-[11px] text-danger`,title:e.error,children:e.error})]}),(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,title:new Date(e.timestamp).toISOString(),children:d(e.timestamp)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId?(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,x.jsx)(n,{to:`/job?id=${encodeURIComponent(e.jobId)}`,className:`text-accent hover:underline`,children:e.jobId}),(0,x.jsx)(p,{value:e.jobId})]}):`—`})]},e.seq))})]})}),(0,x.jsx)(v,{page:k,pageSize:w,total:U.length,onPageChange:A,label:`events`})]})}export{E as LogsPro};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./react-vendor-Bjui4wS4.js";import{C as t,O as n,S as r,h as i,m as a}from"./index-Dr__4DsT.js";var o=e(),s=`{
1
+ import{t as e}from"./react-vendor-CyjgmGTq.js";import{n as t,t as n}from"./Card-C7NMhqUt.js";import{t as r}from"./PageHeader-BXlZSBcc.js";import{a as i,n as a}from"./index-Cui9IwWy.js";var o=e(),s=`{
2
2
  "mcpServers": {
3
3
  "bunqueue": {
4
4
  "command": "bunx",
@@ -19,4 +19,4 @@ import{t as e}from"./react-vendor-Bjui4wS4.js";import{C as t,O as n,S as r,h as
19
19
  }
20
20
  }
21
21
  }
22
- }`,l=`claude mcp add bunqueue -- bunx --package=bunqueue bunqueue-mcp`,u=[{name:`Jobs`,count:11,examples:[`add_job`,`get_job`,`get_jobs`,`get_job_result`,`wait_for_job`]},{name:`Job management`,count:6,examples:[`cancel_job`,`change_job_priority`,`promote_job`,`update_job_data`]},{name:`Consumption`,count:8,examples:[`pull_job`,`pull_job_batch`,`ack_job`,`fail_job`,`job_heartbeat`]},{name:`Queues`,count:11,examples:[`list_queues`,`pause_queue`,`resume_queue`,`drain_queue`,`obliterate_queue`]},{name:`Dead letter queue`,count:4,examples:[`get_dlq`,`retry_dlq`,`purge_dlq`]},{name:`Cron`,count:4,examples:[`add_cron`,`list_crons`,`get_cron`,`delete_cron`]},{name:`Flows`,count:4,examples:[`add_flow`,`add_flow_chain`,`get_flow`,`get_children_values`]},{name:`Rate limits`,count:4,examples:[`set_rate_limit`,`set_concurrency`,`clear_rate_limit`]},{name:`Webhooks`,count:4,examples:[`add_webhook`,`list_webhooks`,`remove_webhook`,`set_webhook_enabled`]},{name:`Workers`,count:3,examples:[`register_worker`,`list_workers`,`worker_heartbeat`]},{name:`Handlers`,count:3,examples:[`register_handler`,`list_handlers`,`unregister_handler`]},{name:`Monitoring`,count:11,examples:[`get_stats`,`get_queue_stats`,`get_memory_stats`,`get_prometheus_metrics`]}],d=[`bunqueue://queues`,`bunqueue://stats`,`bunqueue://workers`,`bunqueue://crons`,`bunqueue://webhooks`],f=[`bunqueue_debug_queue`,`bunqueue_health_report`,`bunqueue_incident_response`],p=u.reduce((e,t)=>e+t.count,0);function m({code:e}){return(0,o.jsxs)(`div`,{className:`relative min-w-0 max-w-full`,children:[(0,o.jsx)(`div`,{className:`absolute right-2 top-2`,children:(0,o.jsx)(n,{value:e})}),(0,o.jsx)(`pre`,{className:`max-w-full overflow-x-auto overscroll-x-contain rounded-lg border border-line bg-surface-2 p-4 pr-12 font-mono text-xs leading-relaxed text-fg`,children:e})]})}function h({children:e}){return(0,o.jsx)(`span`,{className:`max-w-full break-all rounded-md border border-line bg-surface-2 px-1.5 py-0.5 font-mono text-[11px] text-muted`,children:e})}function g(){return(0,o.jsxs)(`div`,{className:`min-w-0 overflow-x-hidden`,children:[(0,o.jsx)(i,{title:`MCP Server`,description:`Connect bunqueue to AI agents (Claude Desktop, Claude Code) over the Model Context Protocol.`,actions:(0,o.jsx)(`a`,{href:`https://egeominotti.github.io/bunqueue-dashboard/docs/guide/mcp`,target:`_blank`,rel:`noopener noreferrer`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:`Docs`})}),(0,o.jsxs)(r,{className:`mb-6`,children:[(0,o.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted`,children:[`bunqueue ships a Model Context Protocol server,`,` `,(0,o.jsx)(`span`,{className:`font-mono text-fg`,children:`bunqueue-mcp`}),`, that lets an AI agent drive the queue with tools, resources, and prompts. It is a separate`,` `,(0,o.jsx)(`span`,{className:`text-fg`,children:`stdio`}),` process, launched by the MCP client (not by this dashboard, and not part of the HTTP API), so this page is a setup and reference guide rather than a live monitor. It needs the optional peer dependency`,` `,(0,o.jsx)(`span`,{className:`font-mono text-fg`,children:`@modelcontextprotocol/sdk`}),`.`]}),(0,o.jsx)(`p`,{className:`mt-3 text-sm leading-relaxed text-warning`,children:`The upstream MCP includes destructive Cancel, Discard, Drain, Obliterate, DLQ Retry and DLQ Purge tools. They bypass this dashboard's v2.8.55 flow-safety gates and have no atomic reverse-dependency or job-generation precondition. Grant MCP write access only after independently proving the workload is not flow-linked.`})]}),(0,o.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,o.jsx)(a,{label:`Tools`,value:String(p)}),(0,o.jsx)(a,{label:`Categories`,value:String(u.length)}),(0,o.jsx)(a,{label:`Resources`,value:String(d.length)}),(0,o.jsx)(a,{label:`Prompts`,value:String(f.length)})]}),(0,o.jsxs)(`div`,{className:`mb-6 grid gap-4 lg:grid-cols-2`,children:[(0,o.jsxs)(r,{className:`min-w-0`,children:[(0,o.jsx)(t,{title:`Embedded mode (default)`}),(0,o.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Direct SQLite access, no running server. Point `,(0,o.jsx)(h,{children:`DATA_PATH`}),` at the bunqueue database file. Best for a local agent on the same machine.`]}),(0,o.jsx)(m,{code:s})]}),(0,o.jsxs)(r,{className:`min-w-0`,children:[(0,o.jsx)(t,{title:`TCP mode (remote server)`}),(0,o.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Connect to a running bunqueue server over its TCP protocol port (`,(0,o.jsx)(h,{children:`6789`}),`, distinct from the HTTP admin API on 6790). Use a `,(0,o.jsx)(h,{children:`BUNQUEUE_TOKEN`}),` if the server has one.`]}),(0,o.jsx)(m,{code:c})]})]}),(0,o.jsxs)(r,{className:`mb-6`,children:[(0,o.jsx)(t,{title:`Where to put it`}),(0,o.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Add the JSON above to your MCP client config (for Claude Desktop, its`,` `,(0,o.jsx)(`span`,{className:`font-mono text-fg`,children:`claude_desktop_config.json`}),`). For Claude Code, register it from the CLI:`]}),(0,o.jsx)(m,{code:l})]}),(0,o.jsxs)(r,{className:`mb-6`,children:[(0,o.jsx)(t,{title:`Tools`,action:(0,o.jsxs)(`span`,{className:`text-xs text-faint`,children:[p,` total`]})}),(0,o.jsx)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2 lg:grid-cols-3`,children:u.map(e=>(0,o.jsxs)(`div`,{children:[(0,o.jsxs)(`div`,{className:`mb-1.5 flex items-baseline justify-between gap-2`,children:[(0,o.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,o.jsx)(`span`,{className:`text-xs text-faint`,children:e.count})]}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.examples.map(e=>(0,o.jsx)(h,{children:e},e))})]},e.name))}),(0,o.jsxs)(`p`,{className:`mt-4 text-xs text-faint`,children:[`Every tool name is prefixed `,(0,o.jsx)(`span`,{className:`font-mono`,children:`bunqueue_`}),` (examples above drop it). Counts total `,p,`.`]})]}),(0,o.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,o.jsxs)(r,{children:[(0,o.jsx)(t,{title:`Resources`,action:(0,o.jsx)(`span`,{className:`text-xs text-faint`,children:d.length})}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:d.map(e=>(0,o.jsx)(h,{children:e},e))})]}),(0,o.jsxs)(r,{children:[(0,o.jsx)(t,{title:`Prompts`,action:(0,o.jsx)(`span`,{className:`text-xs text-faint`,children:f.length})}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:f.map(e=>(0,o.jsx)(h,{children:e},e))})]})]})]})}export{g as McpServer};
22
+ }`,l=`claude mcp add bunqueue -- bunx --package=bunqueue bunqueue-mcp`,u=[{name:`Jobs`,count:11,examples:[`add_job`,`get_job`,`get_jobs`,`get_job_result`,`wait_for_job`]},{name:`Job management`,count:6,examples:[`cancel_job`,`change_job_priority`,`promote_job`,`update_job_data`]},{name:`Consumption`,count:8,examples:[`pull_job`,`pull_job_batch`,`ack_job`,`fail_job`,`job_heartbeat`]},{name:`Queues`,count:11,examples:[`list_queues`,`pause_queue`,`resume_queue`,`drain_queue`,`obliterate_queue`]},{name:`Dead letter queue`,count:4,examples:[`get_dlq`,`retry_dlq`,`purge_dlq`]},{name:`Cron`,count:4,examples:[`add_cron`,`list_crons`,`get_cron`,`delete_cron`]},{name:`Flows`,count:4,examples:[`add_flow`,`add_flow_chain`,`get_flow`,`get_children_values`]},{name:`Rate limits`,count:4,examples:[`set_rate_limit`,`set_concurrency`,`clear_rate_limit`]},{name:`Webhooks`,count:4,examples:[`add_webhook`,`list_webhooks`,`remove_webhook`,`set_webhook_enabled`]},{name:`Workers`,count:3,examples:[`register_worker`,`list_workers`,`worker_heartbeat`]},{name:`Handlers`,count:3,examples:[`register_handler`,`list_handlers`,`unregister_handler`]},{name:`Monitoring`,count:11,examples:[`get_stats`,`get_queue_stats`,`get_memory_stats`,`get_prometheus_metrics`]}],d=[`bunqueue://queues`,`bunqueue://stats`,`bunqueue://workers`,`bunqueue://crons`,`bunqueue://webhooks`],f=[`bunqueue_debug_queue`,`bunqueue_health_report`,`bunqueue_incident_response`],p=u.reduce((e,t)=>e+t.count,0);function m({code:e}){return(0,o.jsxs)(`div`,{className:`relative min-w-0 max-w-full`,children:[(0,o.jsx)(`div`,{className:`absolute right-2 top-2`,children:(0,o.jsx)(i,{value:e})}),(0,o.jsx)(`pre`,{className:`max-w-full overflow-x-auto overscroll-x-contain rounded-lg border border-line bg-surface-2 p-4 pr-12 font-mono text-xs leading-relaxed text-fg`,children:e})]})}function h({children:e}){return(0,o.jsx)(`span`,{className:`max-w-full break-all rounded-md border border-line bg-surface-2 px-1.5 py-0.5 font-mono text-[11px] text-muted`,children:e})}function g(){return(0,o.jsxs)(`div`,{className:`min-w-0 overflow-x-hidden`,children:[(0,o.jsx)(r,{title:`MCP Server`,description:`Connect bunqueue to AI agents (Claude Desktop, Claude Code) over the Model Context Protocol.`,actions:(0,o.jsx)(`a`,{href:`https://egeominotti.github.io/bunqueue-dashboard/docs/guide/mcp`,target:`_blank`,rel:`noopener noreferrer`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:`Docs`})}),(0,o.jsxs)(n,{className:`mb-6`,children:[(0,o.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted`,children:[`bunqueue ships a Model Context Protocol server,`,` `,(0,o.jsx)(`span`,{className:`font-mono text-fg`,children:`bunqueue-mcp`}),`, that lets an AI agent drive the queue with tools, resources, and prompts. It is a separate`,` `,(0,o.jsx)(`span`,{className:`text-fg`,children:`stdio`}),` process, launched by the MCP client (not by this dashboard, and not part of the HTTP API), so this page is a setup and reference guide rather than a live monitor. It needs the optional peer dependency`,` `,(0,o.jsx)(`span`,{className:`font-mono text-fg`,children:`@modelcontextprotocol/sdk`}),`.`]}),(0,o.jsx)(`p`,{className:`mt-3 text-sm leading-relaxed text-warning`,children:`The upstream MCP includes destructive Cancel, Discard, Drain, Obliterate, DLQ Retry and DLQ Purge tools. They bypass this dashboard's v2.8.57 flow-safety gates and have no atomic reverse-dependency or job-generation precondition. Grant MCP write access only after independently proving the workload is not flow-linked.`})]}),(0,o.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,o.jsx)(a,{label:`Tools`,value:String(p)}),(0,o.jsx)(a,{label:`Categories`,value:String(u.length)}),(0,o.jsx)(a,{label:`Resources`,value:String(d.length)}),(0,o.jsx)(a,{label:`Prompts`,value:String(f.length)})]}),(0,o.jsxs)(`div`,{className:`mb-6 grid gap-4 lg:grid-cols-2`,children:[(0,o.jsxs)(n,{className:`min-w-0`,children:[(0,o.jsx)(t,{title:`Embedded mode (default)`}),(0,o.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Direct SQLite access, no running server. Point `,(0,o.jsx)(h,{children:`DATA_PATH`}),` at the bunqueue database file. Best for a local agent on the same machine.`]}),(0,o.jsx)(m,{code:s})]}),(0,o.jsxs)(n,{className:`min-w-0`,children:[(0,o.jsx)(t,{title:`TCP mode (remote server)`}),(0,o.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Connect to a running bunqueue server over its TCP protocol port (`,(0,o.jsx)(h,{children:`6789`}),`, distinct from the HTTP admin API on 6790). Use a `,(0,o.jsx)(h,{children:`BUNQUEUE_TOKEN`}),` if the server has one.`]}),(0,o.jsx)(m,{code:c})]})]}),(0,o.jsxs)(n,{className:`mb-6`,children:[(0,o.jsx)(t,{title:`Where to put it`}),(0,o.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Add the JSON above to your MCP client config (for Claude Desktop, its`,` `,(0,o.jsx)(`span`,{className:`font-mono text-fg`,children:`claude_desktop_config.json`}),`). For Claude Code, register it from the CLI:`]}),(0,o.jsx)(m,{code:l})]}),(0,o.jsxs)(n,{className:`mb-6`,children:[(0,o.jsx)(t,{title:`Tools`,action:(0,o.jsxs)(`span`,{className:`text-xs text-faint`,children:[p,` total`]})}),(0,o.jsx)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2 lg:grid-cols-3`,children:u.map(e=>(0,o.jsxs)(`div`,{children:[(0,o.jsxs)(`div`,{className:`mb-1.5 flex items-baseline justify-between gap-2`,children:[(0,o.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,o.jsx)(`span`,{className:`text-xs text-faint`,children:e.count})]}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.examples.map(e=>(0,o.jsx)(h,{children:e},e))})]},e.name))}),(0,o.jsxs)(`p`,{className:`mt-4 text-xs text-faint`,children:[`Every tool name is prefixed `,(0,o.jsx)(`span`,{className:`font-mono`,children:`bunqueue_`}),` (examples above drop it). Counts total `,p,`.`]})]}),(0,o.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,o.jsxs)(n,{children:[(0,o.jsx)(t,{title:`Resources`,action:(0,o.jsx)(`span`,{className:`text-xs text-faint`,children:d.length})}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:d.map(e=>(0,o.jsx)(h,{children:e},e))})]}),(0,o.jsxs)(n,{children:[(0,o.jsx)(t,{title:`Prompts`,action:(0,o.jsx)(`span`,{className:`text-xs text-faint`,children:f.length})}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:f.map(e=>(0,o.jsx)(h,{children:e},e))})]})]})]})}export{g as McpServer};
@@ -0,0 +1 @@
1
+ import{t as e}from"./react-vendor-CyjgmGTq.js";import{t}from"./api-CQ5Z7xR7.js";import{n}from"./usePolledData-DzlUpBOO.js";import{n as r,t as i}from"./Card-C7NMhqUt.js";import{i as a,n as o,r as s}from"./feedback-BnGE2oW2.js";import{t as c}from"./PageHeader-BXlZSBcc.js";import{n as l,s as u}from"./format-Cg7VCIZW.js";import{n as d}from"./index-Cui9IwWy.js";var f=e(),p={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function m(){let{data:e,error:m,loading:_,refetch:v}=n(()=>t.overview(),[]);if(_&&!e&&!m)return(0,f.jsx)(s,{label:`Loading metrics…`});if(m&&!e)return(0,f.jsxs)(`div`,{children:[(0,f.jsx)(c,{title:`Metrics`,description:`Throughput, latency, and resource internals.`}),(0,f.jsx)(o,{error:m,onRetry:v})]});let{stats:y,throughput:b,latency:x,memory:S,collections:C}=e??p,w={};for(let[e,t]of Object.entries(x.percentiles??{}))t&&typeof t==`object`&&(w[`${e} p50`]=t.p50,w[`${e} p95`]=t.p95,w[`${e} p99`]=t.p99);return(0,f.jsxs)(`div`,{children:[m&&(0,f.jsx)(a,{message:`Metrics refresh failed — showing the last successful snapshot.`,onRetry:v}),(0,f.jsx)(c,{title:`Metrics`,description:`Throughput, latency, and resource internals.`,live:!!e&&!m}),(0,f.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,f.jsx)(d,{label:`Pushed /s`,value:b.pushPerSec.toFixed(1),compact:!0}),(0,f.jsx)(d,{label:`Pulled /s`,value:b.pullPerSec.toFixed(1),tone:`blue`,compact:!0}),(0,f.jsx)(d,{label:`Completed /s`,value:b.completePerSec.toFixed(1),tone:`green`,compact:!0}),(0,f.jsx)(d,{label:`Failed /s`,value:b.failPerSec.toFixed(1),tone:`red`,compact:!0})]}),(0,f.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Totals`}),(0,f.jsx)(h,{rows:[[`Pushed`,u(y.totalPushed)],[`Pulled`,u(y.totalPulled)],[`Completed`,u(y.totalCompleted)],[`Failed`,u(y.totalFailed)]]})]}),(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Memory`}),(0,f.jsx)(h,{rows:[[`Heap Used`,l(S.heapUsed*1024*1024)],[`Heap Total`,l(S.heapTotal*1024*1024)],[`RSS`,l(S.rss*1024*1024)]]})]}),(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Latency — percentiles (ms)`}),(0,f.jsx)(g,{record:w,suffix:`ms`})]}),(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Latency — averages (ms)`}),(0,f.jsx)(g,{record:x.averages,suffix:`ms`})]})]}),(0,f.jsx)(`div`,{className:`mt-6`,children:(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`In-memory collections`}),(0,f.jsx)(g,{record:C})]})})]})}function h({rows:e}){return(0,f.jsx)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:e.map(([e,t])=>(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,f.jsx)(`div`,{className:`mt-1 text-xl font-semibold tnum text-fg`,children:t})]},e))})}function g({record:e,suffix:t}){let n=Object.entries(e??{});return n.length===0?(0,f.jsx)(`p`,{className:`py-4 text-sm text-faint`,children:`No data.`}):(0,f.jsx)(`dl`,{className:`divide-y divide-line`,children:n.map(([e,n])=>(0,f.jsxs)(`div`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,f.jsx)(`dt`,{className:`font-mono text-xs text-muted`,children:e}),(0,f.jsxs)(`dd`,{className:`tnum font-medium text-fg`,children:[typeof n==`number`?u(Math.round(n*100)/100):String(n),t&&(0,f.jsx)(`span`,{className:`ml-1 text-xs text-faint`,children:t})]})]},e))})}export{m as Metrics};
@@ -0,0 +1 @@
1
+ import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,t as r}from"./react-vendor-CyjgmGTq.js";import{t as i}from"./bq-BeBxa743.js";import{n as a}from"./usePolledData-DzlUpBOO.js";import{n as o,t as s}from"./Card-C7NMhqUt.js";import{i as c,r as l,t as u}from"./feedback-BnGE2oW2.js";import{t as d}from"./PageHeader-BXlZSBcc.js";import{c as f,r as p,s as m,t as h,u as g}from"./format-Cg7VCIZW.js";import{n as _}from"./index-Cui9IwWy.js";import{t as v}from"./Pagination-Q-vf4hsX.js";import{t as y}from"./AreaChart-w0ruozXH.js";import{n as b,t as x}from"./useThroughputSeries-C2pa1Wd_.js";var S=e(n(),1),C=r();function w({rate:e,stats:t}){return(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Error Rate`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Failed as percentage of total processed`}),(0,C.jsxs)(`div`,{className:`flex items-center justify-around`,children:[(0,C.jsx)(T,{value:e==null?`—`:f(e),label:`error rate`,danger:e!=null&&e>.05}),(0,C.jsx)(T,{value:e==null?`—`:f(1-e),label:`success rate`,success:e!=null})]}),e==null?(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-surface-2`}):(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-red-500/40`,children:(0,C.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${(1-e)*100}%`}})})]}),(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Server Overview`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Current server-wide statistics`}),(0,C.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,C.jsx)(E,{color:`bg-blue-400`,label:`Standard waiting`,value:t?m(t.waiting):`—`}),(0,C.jsx)(E,{color:`bg-accent`,label:`Processing`,value:t?m(t.active):`—`}),(0,C.jsx)(E,{color:`bg-amber-400`,label:`Delayed`,value:t?m(t.delayed):`—`}),(0,C.jsx)(E,{color:`bg-red-400`,label:`Dead Letter`,value:t?m(t.dlq):`—`}),(0,C.jsx)(E,{color:`bg-zinc-500`,label:`Pushed (since restart)`,value:t?p(t.totalPushed):`—`}),(0,C.jsx)(E,{color:`bg-zinc-500`,label:`Pulled (since restart)`,value:t?p(t.totalPulled):`—`}),(0,C.jsx)(E,{color:`bg-emerald-400`,label:`Uptime`,value:t?g(t.uptime/1e3):`—`})]})]})]})}function T({value:e,label:n,danger:r,success:i}){return(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,r?`text-danger`:i?`text-success`:`text-fg`),children:e}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:n})]})}function E({color:e,label:n,value:r}){return(0,C.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,C.jsxs)(`dt`,{className:`flex items-center gap-2 text-muted`,children:[(0,C.jsx)(`span`,{className:t(`size-2 rounded-full`,e)}),n]}),(0,C.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:r})]})}var D=[`push`,`pull`,`ack`],O=100;function k({latency:e}){return(0,C.jsxs)(s,{className:`mb-6`,padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Operation Latency`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`TCP round-trip per operation (p50 / p95 / p99, milliseconds)`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Operation`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Avg`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p50`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p95`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p99`})]})}),(0,C.jsx)(`tbody`,{children:D.map(n=>{let r=e?.percentiles?.[n],i=e?.averages?.[`${n}Ms`];return(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-medium capitalize text-fg`,children:n}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(i)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(r?.p50)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(r?.p95)}),(0,C.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,(r?.p99??0)>O?`text-warning`:`text-muted`),children:j(r?.p99)})]},n)})})]})})]})}function A({rows:e,total:n,page:r,pageSize:i,onPage:a,empty:o}){return(0,C.jsxs)(s,{padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Per-Queue Metrics`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Job counts breakdown by queue`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Prioritized`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Completed`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,C.jsx)(`tbody`,{children:e.length===0?(0,C.jsx)(`tr`,{children:(0,C.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:o})}):e.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent`,children:e.name}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:e.paused?`paused`:`active`})}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:m(e.counts.waiting)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-orange-400`,children:m(e.counts.prioritized)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:m(e.counts.active)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:m(e.counts.completed)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-danger`,children:m(e.counts.failed)})]},e.name))})]})}),(0,C.jsx)(`div`,{className:`px-5 pb-4`,children:(0,C.jsx)(v,{page:r,pageSize:i,total:n,onPageChange:a,label:`queues`})})]})}function j(e){return e==null||!Number.isFinite(e)?`—`:`${e<10?e.toFixed(1):Math.round(e)}ms`}var M=[`-60s`,`-45s`,`-30s`,`-15s`,`now`];function N({series:e}){let n=e.latest?.throughput,r=x(e.depth),i=e.depth.length?e.depth[e.depth.length-1]:null,a=t=>e.error?(0,C.jsx)(u,{title:`${t} unavailable`,hint:e.error.message}):(0,C.jsx)(l,{label:`Connecting ${t.toLowerCase()}…`});return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Live Throughput`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Real-time jobs per second (rolling 60s window)`})]}),n&&(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 font-mono text-[11px] text-faint`,children:[(0,C.jsx)(P,{color:`#ec4899`,label:`Pushed`,value:n.pushPerSec}),(0,C.jsx)(P,{color:`#34d399`,label:`Completed`,value:n.completePerSec}),(0,C.jsx)(P,{color:`#f87171`,label:`Failed`,value:n.failPerSec})]})]}),e.latest?(0,C.jsx)(y,{xLabels:M,series:[{label:`Pushed`,color:`#ec4899`,points:e.push,area:!0},{label:`Completed`,color:`#34d399`,points:e.complete},{label:`Failed`,color:`#f87171`,points:e.fail}]}):a(`Live throughput`)]}),(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Queue Depth`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`All non-terminal jobs over time (waiting + prioritized + active + delayed + waiting-children). The trend says whether you're draining or falling behind.`})]}),(0,C.jsxs)(`div`,{className:`text-right`,children:[(0,C.jsx)(`div`,{className:`tnum text-2xl font-bold text-fg`,children:i==null?`—`:m(i)}),(0,C.jsx)(`div`,{className:t(`text-xs font-medium`,r.label===`draining`?`text-success`:r.label===`accumulating`?`text-danger`:`text-faint`),children:i==null?`unavailable`:r.label===`steady`?`steady`:`${r.slope>0?`+`:``}${r.slope.toFixed(1)}/s · ${r.label}`})]})]}),e.latest?(0,C.jsx)(y,{xLabels:M,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:r.draining?`#34d399`:`#f59e0b`,points:e.depth,area:!0}]}):a(`Queue depth`)]})]})}function P({color:e,label:t,value:n}){return(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e}}),t,` `,(0,C.jsxs)(`span`,{className:`text-fg`,children:[n.toFixed(1),`/s`]})]})}var F=15;function I(){let e=b(60),[t,n]=(0,S.useState)(0),{data:r,error:o,loading:s,refetch:l}=a(async()=>({details:await i.queuesSummary()}),[]),u=r?.details??[],f=Math.max(1,Math.ceil(u.length/F)),g=Math.min(t,f-1),v=(0,S.useMemo)(()=>u.slice(g*F,g*F+F),[u,g]),y=(0,S.useMemo)(()=>r?u.reduce((e,t)=>e+(t.counts?.failed??0),0):null,[r,u]),x=e.latest?.stats,T=e.latest?.throughput,E=e.latest?.latency,D=x&&y!=null?h(x.completed,y):null,O=s&&!r&&!o,j=!!e.latest&&!e.error&&!!r&&!o,M=o&&!r?`Queue metrics unavailable — ${o.message}`:O?`Loading queue metrics…`:`No queues yet.`;return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(d,{title:`Metrics`,description:`Real-time performance telemetry for your queues.`,live:j}),o&&(0,C.jsx)(c,{message:`Queue metrics unavailable — ${o.message}`,onRetry:l}),e.error&&(0,C.jsx)(c,{message:`Live telemetry unavailable — ${e.error.message}. Reconnecting automatically.`}),O&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Loading per-queue metrics…`}),!e.latest&&!e.error&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Connecting live telemetry…`}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,C.jsx)(_,{label:`Total Completed`,value:x?p(x.completed):`—`,tone:`green`,hint:`recorded jobs`}),(0,C.jsx)(_,{label:`Total Failed`,value:y==null?`—`:m(y),tone:y?`red`:`default`,hint:`recorded jobs`}),(0,C.jsx)(_,{label:`Push/sec`,value:T?T.pushPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`}),(0,C.jsx)(_,{label:`Pull/sec`,value:T?T.pullPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`})]}),(0,C.jsx)(N,{series:e}),(0,C.jsx)(w,{rate:D,stats:x}),(0,C.jsx)(k,{latency:E}),(0,C.jsx)(A,{rows:v,total:u.length,page:g,pageSize:F,onPage:n,empty:M})]})}export{I as MetricsPro};
@@ -0,0 +1 @@
1
+ import{t as e}from"./react-vendor-CyjgmGTq.js";import{A as t,c as n}from"./icons-CIvFfU2b.js";import{t as r}from"./api-CQ5Z7xR7.js";import{n as i}from"./usePolledData-DzlUpBOO.js";import{n as a,t as o}from"./Card-C7NMhqUt.js";import{i as s,n as c,r as l}from"./feedback-BnGE2oW2.js";import{t as u}from"./PageHeader-BXlZSBcc.js";import{c as d,n as f,s as p,t as m,u as h}from"./format-Cg7VCIZW.js";import{n as g}from"./index-Cui9IwWy.js";var _=e(),v={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function y(){let{data:e,error:y,loading:S,refetch:C}=i(()=>r.overview(),[]);if(S&&!e&&!y)return(0,_.jsx)(l,{label:`Loading overview…`});if(y&&!e)return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(u,{title:`Overview`,description:`Live health and throughput across all queues.`}),(0,_.jsx)(c,{error:y,onRetry:C})]});let{stats:w,throughput:T,memory:E,workers:D,crons:O,storage:k}=e??v,A=m(w.totalCompleted,w.totalFailed)??0,j=typeof k.diskFull==`boolean`;return(0,_.jsxs)(`div`,{children:[y&&(0,_.jsx)(s,{message:`Connection lost — showing the last successful overview snapshot.`,onRetry:C}),(0,_.jsx)(u,{title:`Overview`,description:`Live health and throughput across all queues.`,live:!!e&&!y&&j}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,_.jsx)(g,{label:`Waiting`,value:p(w.waiting),tone:`amber`}),(0,_.jsx)(g,{label:`Active`,value:p(w.active),tone:`blue`}),(0,_.jsx)(g,{label:`Completed`,value:p(w.totalCompleted),tone:`green`}),(0,_.jsx)(g,{label:`Failed`,value:p(w.totalFailed),tone:`red`}),(0,_.jsx)(g,{label:`DLQ`,value:p(w.dlq),tone:w.dlq>0?`red`:`default`}),(0,_.jsx)(g,{label:`Error Rate`,value:d(A),tone:A>.05?`red`:`green`})]}),(0,_.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Throughput`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,_.jsx)(b,{label:`Pushed`,value:T.pushPerSec,tone:`text-fg`}),(0,_.jsx)(b,{label:`Pulled`,value:T.pullPerSec,tone:`text-blue-400`}),(0,_.jsx)(b,{label:`Completed`,value:T.completePerSec,tone:`text-emerald-400`}),(0,_.jsx)(b,{label:`Failed`,value:T.failPerSec,tone:`text-red-400`})]})]}),(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Resources`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,_.jsx)(x,{label:`Uptime`,value:h(w.uptime/1e3)}),(0,_.jsx)(x,{label:`Heap`,value:f(E.heapUsed*1024*1024)}),(0,_.jsx)(x,{label:`RSS`,value:f(E.rss*1024*1024)}),(0,_.jsx)(x,{label:`Storage`,value:j?k.diskFull?`Disk full`:`Healthy`:`Unavailable`,tone:j?k.diskFull?`text-red-400`:`text-emerald-400`:`text-muted`})]})]})]}),(0,_.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Workers`,icon:(0,_.jsx)(t,{className:`size-4 text-faint`}),action:(0,_.jsxs)(`span`,{className:`text-sm text-muted`,children:[(0,_.jsx)(`span`,{className:`font-semibold text-emerald-400`,children:D.active}),` /`,` `,D.total,` active`]})}),D.list.length===0?(0,_.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No workers registered.`}):(0,_.jsx)(`ul`,{className:`divide-y divide-line`,children:D.list.slice(0,6).map(e=>(0,_.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,_.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name||e.id}),(0,_.jsxs)(`span`,{className:`text-xs text-faint`,children:[e.queues.join(`, `)||`—`,` · `,p(e.processedJobs),` done`]})]},e.id))})]}),(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Cron Jobs`,icon:(0,_.jsx)(n,{className:`size-4 text-faint`}),action:(0,_.jsxs)(`span`,{className:`text-sm text-muted`,children:[O.total,` scheduled`]})}),O.list.length===0?(0,_.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No cron jobs.`}):(0,_.jsx)(`ul`,{className:`divide-y divide-line`,children:O.list.slice(0,6).map(e=>(0,_.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,_.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),(0,_.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:e.schedule??(e.repeatEvery?`every ${e.repeatEvery}ms`:`—`)})]},e.name))})]})]})]})}function b({label:e,value:t,tone:n}){return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,_.jsxs)(`div`,{className:`mt-1 text-2xl font-semibold tnum ${n}`,children:[t.toFixed(1),(0,_.jsx)(`span`,{className:`ml-0.5 text-sm font-normal text-faint`,children:`/s`})]})]})}function x({label:e,value:t,tone:n=`text-fg`}){return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,_.jsx)(`div`,{className:`mt-1 text-base font-semibold ${n}`,children:t})]})}export{y as Overview};
@@ -0,0 +1 @@
1
+ import{t as e}from"./react-vendor-CyjgmGTq.js";import{n as t}from"./StatusBadge-B0I7hNBX.js";var n=e();function r({title:e,description:r,live:i,actions:a,back:o}){return(0,n.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,n.jsxs)(`div`,{className:`flex items-start gap-3`,children:[o,(0,n.jsxs)(`div`,{children:[(0,n.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,n.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight text-fg`,children:e}),i&&(0,n.jsx)(t,{label:`Live`,tone:`green`})]}),r&&(0,n.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:r})]})]}),a&&(0,n.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:a})]})}export{r as t};
@@ -0,0 +1 @@
1
+ import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CyjgmGTq.js";import{s as r}from"./format-Cg7VCIZW.js";var i=e(t(),1),a=n();function o({page:e,pageSize:t,total:n,hasNext:o,onPageChange:s,label:c=`items`,className:l}){let u=n!=null,d=u?Math.max(1,Math.ceil(n/t)):void 0;(0,i.useEffect)(()=>{u&&e>d-1&&s(d-1)},[u,e,d,s]);let f=u?Math.min(e,d-1):e,p=f*t,m=f>0,h=u?f<d-1:!!o;if(u&&n<=t&&f===0)return null;let g=u?n===0?`No ${c}`:`${r(p+1)}–${r(Math.min(p+t,n))} of ${r(n)} ${c}`:`Page ${f+1}`;return(0,a.jsxs)(`div`,{className:`mt-4 flex items-center justify-between text-sm text-faint ${l??``}`,children:[(0,a.jsx)(`span`,{children:g}),(0,a.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,a.jsx)(`button`,{type:`button`,disabled:!m,onClick:()=>s(f-1),className:`rounded-md px-3 py-1 text-xs hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-40 disabled:hover:text-faint`,children:`Previous`}),(0,a.jsx)(`span`,{className:`rounded-md bg-accent/15 px-2.5 py-1 text-xs font-medium text-accent tnum`,children:u?`${f+1} / ${d}`:f+1}),(0,a.jsx)(`button`,{type:`button`,disabled:!h,onClick:()=>s(f+1),className:`rounded-md px-3 py-1 text-xs hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-40 disabled:hover:text-faint`,children:`Next`})]})]})}export{o as t};
@@ -0,0 +1 @@
1
+ import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CyjgmGTq.js";import{o as r}from"./connectionStore-DbBYqHEY.js";import{t as i}from"./bq-BeBxa743.js";import{t as a}from"./Button-BPqpRZJD.js";import{n as o,t as s}from"./Card-C7NMhqUt.js";import{a as c,n as l,o as u,t as d}from"./form-tC20r4Ma.js";import{n as f,r as p}from"./useServerActionGuard-BlH-Kso1.js";import{i as m,n as h,r as g}from"./flowMutationSafety-CoOp94wS.js";var _=n();function v(e){if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e;return JSON.stringify(Object.keys(t).sort().map(e=>[e,t[e]]))}return JSON.stringify(e)}function y(e,t){let n=String(e).trim();if(n===``)return null;let r=Number(n);return Number.isSafeInteger(r)&&r>=t?r:null}function b(e){let t=y(e.stallInterval,0),n=y(e.maxStalls,0),r=y(e.gracePeriod,0);return t===null||n===null||r===null?{ok:!1,error:`Stall interval, max stalls, and grace period must be non-negative whole numbers.`}:{ok:!0,value:{enabled:e.enabled,stallInterval:t,maxStalls:n,gracePeriod:r}}}function x(e){let t=y(e.autoRetryInterval,0),n=y(e.maxAutoRetries,0);return t===null||n===null?{ok:!1,error:`Retry interval and max auto-retries must be non-negative whole numbers.`}:{ok:!0,value:{autoRetry:e.autoRetry,autoRetryInterval:t,maxAutoRetries:n}}}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var C=e=>typeof e==`number`&&Number.isFinite(e);function w(e){return S(e)&&typeof e.enabled==`boolean`&&C(e.stallInterval)&&C(e.maxStalls)&&C(e.gracePeriod)}function T(e){return S(e)&&typeof e.autoRetry==`boolean`&&C(e.autoRetryInterval)&&C(e.maxAutoRetries)&&(e.maxAge===null||C(e.maxAge))&&C(e.maxEntries)}function E(e,t){if(!S(e)||e.ok!==!0)throw Error(`Malformed ${t} response: expected { ok: true }.`)}var D=e(t(),1);function O(e){let[t,n]=(0,D.useState)(e),r=(0,D.useRef)(v(e));return(0,D.useEffect)(()=>{let t=v(e);t!==r.current&&(r.current=t,n(e))},[e]),[t,n,()=>{let e=r.current;return t=>{r.current===e&&(r.current=v(t))}}]}function k(e){let{scopeKey:t,begin:n}=p(e),i=(0,D.useRef)(null),a=(0,D.useRef)(null),[o,s]=(0,D.useState)(!1),[c,l]=(0,D.useState)(!1);return(0,D.useEffect)(()=>{i.current=null,s(!1),l(!1),a.current!==null&&(window.clearTimeout(a.current),a.current=null);let e=f(),t=r.subscribe(()=>{let t=f();t!==e&&(e=t,i.current=null,s(!1),l(!1),a.current!==null&&(window.clearTimeout(a.current),a.current=null))});return()=>{i.current=null,a.current!==null&&window.clearTimeout(a.current),t()}},[t]),{scopeKey:t,saving:o,saved:c,start:()=>{let e=n(`save`);return e?(i.current=e,s(!0),l(!1),e):null},finish:e=>{e.finish(),i.current===e&&(i.current=null,s(!1))},showSaved:e=>{i.current!==e||!e.isCurrent()||(l(!0),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{e.isCurrent()&&l(!1),a.current=null},2e3))}}}function A({queue:e,config:t,onSaved:n}){let[r,c,f]=O(t),[p,h]=(0,D.useState)(null),g=k(`dlq-config:${e}`);(0,D.useEffect)(()=>h(null),[g.scopeKey]);let v=x(r),y=v.ok&&v.value.autoRetry;return(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`DLQ policy`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,_.jsx)(u,{checked:r.autoRetry,disabled:!r.autoRetry,onChange:e=>c({...r,autoRetry:e}),label:`auto-retry`}),(0,_.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`auto-retry`})]}),(0,_.jsx)(`p`,{className:`col-span-2 text-xs text-warning`,children:`Auto-retry can only be disabled. Bunqueue v2.8.57 cannot prove that a DLQ entry has no hidden reverse flow dependents before a background retry.`}),(0,_.jsx)(d,{label:`Retry interval (ms)`,children:(0,_.jsx)(l,{name:`dlq-auto-retry-interval-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.autoRetryInterval,onChange:e=>c({...r,autoRetryInterval:e.target.value})})}),(0,_.jsx)(d,{label:`Max auto-retries`,children:(0,_.jsx)(l,{name:`dlq-max-auto-retries`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.maxAutoRetries,onChange:e=>c({...r,maxAutoRetries:e.target.value})})}),(0,_.jsx)(d,{label:`Max age (ms)`,children:(0,_.jsx)(l,{name:`dlq-max-age-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,disabled:!0,title:m,value:r.maxAge??``,readOnly:!0})}),(0,_.jsx)(d,{label:`Max entries`,children:(0,_.jsx)(l,{name:`dlq-max-entries`,autoComplete:`off`,type:`number`,min:1,max:2**53-1,step:1,disabled:!0,title:m,value:r.maxEntries,readOnly:!0})}),(0,_.jsx)(`p`,{className:`col-span-2 text-xs text-warning`,children:m})]}),(0,_.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:g.saving||!v.ok||y,onClick:async()=>{if(!v.ok)return;let t=g.start();if(t)try{h(null);let a=f();if(E(await i.setDlqConfig(e,v.value),`/dlq-config`),!t.isCurrent())return;a({...r,...v.value}),await n(),g.showSaved(t)}catch(e){t.isCurrent()&&h(e.message)}finally{g.finish(t)}},children:`Save`}),g.saved&&(0,_.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved ✓`}),!v.ok&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:v.error}),y&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:`Disable auto-retry before saving this policy.`}),p&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:p})]})]})}function j({queue:e,config:t,onSaved:n}){let[r,c,f]=O(t),[p,m]=(0,D.useState)(null),h=k(`stall-config:${e}`);(0,D.useEffect)(()=>m(null),[h.scopeKey]);let g=b(r);return(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`Stall detection`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,_.jsx)(u,{checked:r.enabled,onChange:e=>c({...r,enabled:e}),label:`enabled`}),(0,_.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`enabled`})]}),(0,_.jsx)(d,{label:`Stall interval (ms)`,children:(0,_.jsx)(l,{name:`stall-interval-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.stallInterval,onChange:e=>c({...r,stallInterval:e.target.value})})}),(0,_.jsx)(d,{label:`Max stalls`,children:(0,_.jsx)(l,{name:`stall-max-count`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.maxStalls,onChange:e=>c({...r,maxStalls:e.target.value})})}),(0,_.jsx)(d,{label:`Grace period (ms)`,children:(0,_.jsx)(l,{name:`stall-grace-period-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.gracePeriod,onChange:e=>c({...r,gracePeriod:e.target.value})})})]}),(0,_.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:h.saving||!g.ok,onClick:async()=>{if(!g.ok)return;let t=h.start();if(t)try{m(null);let r=f();if(E(await i.setStallConfig(e,g.value),`/stall-config`),!t.isCurrent())return;r(g.value),await n(),h.showSaved(t)}catch(e){t.isCurrent()&&m(e.message)}finally{h.finish(t)}},children:`Save`}),h.saved&&(0,_.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved ✓`}),!g.ok&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:g.error}),p&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:p})]})]})}function M({title:e,onRetry:t}){return(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:e}),(0,_.jsx)(`p`,{className:`mb-3 text-sm text-muted`,children:`Couldn't load this queue's config.`}),(0,_.jsx)(a,{size:`sm`,onClick:t,children:`Retry`})]})}function N(e,t){let n=Number(e),r=Number(t);return{grace:n,limit:r,valid:e.trim()!==``&&t.trim()!==``&&Number.isSafeInteger(n)&&Number.isSafeInteger(r)&&n>=0&&r>0}}function P(e){if(!e.trim())return{valid:!0};let t=Number(e);return Number.isSafeInteger(t)&&t>0?{count:t,valid:!0}:{valid:!1}}function F(e,t){return t===void 0?`Promote every delayed job in "${e}" and make it eligible to run now?`:`Promote up to ${t} delayed jobs in "${e}" and make them eligible to run now?`}function I(e,t,n){let r=e=>{if(!e.trim())return;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null},i=r(e),a=r(t),o=r(n);return{limit:typeof i==`number`?i:0,duration:typeof a==`number`?a:0,...typeof o==`number`?{ttl:o}:{},valid:typeof i==`number`&&typeof a==`number`&&o!==null}}function L(e){let t=Number(e);return{value:t,valid:e.trim()!==``&&Number.isSafeInteger(t)&&t>0}}function R({queue:e,paused:t,busy:n,run:r}){let[u,f]=(0,D.useState)(`0`),[p,m]=(0,D.useState)(`1000`),[v,y]=(0,D.useState)(`completed`),[b,x]=(0,D.useState)(``),S=N(u,p),C=P(b);return(0,_.jsxs)(s,{className:`mb-6`,children:[(0,_.jsx)(o,{title:`Lifecycle`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[t?(0,_.jsx)(a,{variant:`success`,size:`sm`,disabled:n,onClick:()=>r(`Resumed`,()=>i.resume(e)),children:`Resume`}):(0,_.jsx)(a,{variant:`warning`,size:`sm`,disabled:n,onClick:()=>r(`Paused`,()=>i.pause(e)),children:`Pause`}),(0,_.jsx)(a,{size:`sm`,disabled:!0,title:h,children:`Requeue completed`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`w-24`,children:(0,_.jsx)(d,{label:`Promote N`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`promote-count`,"aria-invalid":!C.valid,value:b,onChange:e=>x(e.target.value),placeholder:`all`})})}),(0,_.jsx)(a,{size:`sm`,disabled:n||!C.valid,onClick:()=>r(`Promoted`,()=>i.promoteJobs(e,C.count),F(e,C.count)),children:`Promote delayed`}),!C.valid&&(0,_.jsx)(`span`,{role:`alert`,className:`pb-2 text-xs text-danger`,children:`Promote N must be a positive whole number, or blank for all.`})]})]}),(0,_.jsx)(`p`,{className:`mt-3 text-xs text-warning`,children:h}),(0,_.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3`,children:[(0,_.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Destructive — these permanently remove jobs`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,_.jsx)(a,{size:`sm`,disabled:!0,title:g,children:`Drain`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`w-40`,children:(0,_.jsx)(d,{label:`State`,children:(0,_.jsxs)(c,{name:`clean-state`,disabled:!0,value:v,onChange:e=>y(e.target.value),children:[(0,_.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,_.jsx)(`option`,{value:`failed`,children:`Failed / DLQ`}),(0,_.jsx)(`option`,{value:`waiting`,children:`Queued`})]})})}),(0,_.jsx)(`div`,{className:`w-24`,children:(0,_.jsx)(d,{label:`Grace (ms)`,children:(0,_.jsx)(l,{type:`number`,min:0,max:2**53-1,step:1,name:`clean-grace`,disabled:!0,"aria-invalid":!S.valid,value:u,onChange:e=>f(e.target.value)})})}),(0,_.jsx)(`div`,{className:`w-24`,children:(0,_.jsx)(d,{label:`Limit`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`clean-limit`,disabled:!0,"aria-invalid":!S.valid,value:p,onChange:e=>m(e.target.value)})})}),(0,_.jsx)(a,{variant:`danger`,size:`sm`,disabled:!0,title:g,children:`Clean`}),!S.valid&&(0,_.jsx)(`span`,{role:`alert`,className:`pb-2 text-xs text-danger`,children:`Grace and limit must be whole numbers; limit must be positive.`})]})]}),(0,_.jsx)(`p`,{className:`mt-3 text-xs text-warning`,children:g})]})]})}function z({queue:e,busy:t,run:n}){let[r,u]=(0,D.useState)(``),[f,p]=(0,D.useState)(``),[m,h]=(0,D.useState)(`permanent`),[g,v]=(0,D.useState)(``),[y,b]=(0,D.useState)(``),[x,S]=(0,D.useState)(``),[C,w]=(0,D.useState)(``),[T,E]=(0,D.useState)(null),[O,k]=(0,D.useState)(null),A=I(r,f,m===`expires`?g:``),j=L(y);return(0,_.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`Rate-limit policy`}),(0,_.jsx)(`p`,{className:`mb-3 text-xs text-faint`,children:`Live SDK readback is available in Queue Control. Applying a policy replaces the broker value for this queue.`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`min-w-24 flex-1`,children:(0,_.jsx)(d,{label:`Limit`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-limit`,value:r,onChange:e=>u(e.target.value),placeholder:`max per window`})})}),(0,_.jsx)(`div`,{className:`min-w-28 flex-1`,children:(0,_.jsx)(d,{label:`Window (ms)`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-duration`,value:f,onChange:e=>p(e.target.value),placeholder:`60000`})})}),(0,_.jsx)(`div`,{className:`min-w-28 flex-1`,children:(0,_.jsx)(d,{label:`TTL`,children:(0,_.jsxs)(c,{name:`rate-ttl-mode`,value:m,onChange:e=>h(e.target.value),children:[(0,_.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,_.jsx)(`option`,{value:`expires`,children:`Expires after`})]})})}),(0,_.jsx)(`div`,{className:`min-w-24 flex-1`,children:(0,_.jsx)(d,{label:`TTL (ms)`,hint:m===`permanent`?`Not sent`:void 0,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-ttl`,disabled:m===`permanent`,value:g,onChange:e=>v(e.target.value),placeholder:`—`})})}),(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:t||!A.valid,onClick:()=>n(`Rate limit set`,()=>i.setRateLimit(e,A.limit,A.duration,A.ttl),`Replace the current rate-limit policy for "${e}" with limit ${A.limit}, window ${A.duration}ms${A.ttl===void 0?`, permanent`:`, TTL ${A.ttl}ms`}?`,()=>E(`Applied limit ${A.limit} per ${A.duration}ms${A.ttl===void 0?`, permanent`:`, TTL ${A.ttl}ms`} at ${new Date().toISOString()}.`)),children:`Replace policy`}),(0,_.jsx)(`div`,{className:`min-w-40 flex-1`,children:(0,_.jsx)(d,{label:`Type ${e} to clear`,children:(0,_.jsx)(l,{name:`rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:x,onChange:e=>S(e.target.value)})})}),(0,_.jsx)(a,{size:`sm`,disabled:t||x!==e,onClick:()=>n(`No rate limit ensured`,()=>i.clearRateLimit(e),`Remove the current rate-limit policy from queue "${e}"?`,()=>E(`Removed the rate-limit policy at ${new Date().toISOString()}.`)),children:`Ensure no rate limit`}),!A.valid&&(r.trim()||f.trim()||g.trim())&&(0,_.jsx)(`span`,{role:`alert`,className:`w-full text-xs text-danger`,children:`Limit and window are required; all values must be positive whole numbers.`}),T&&(0,_.jsx)(`span`,{role:`status`,className:`w-full text-xs text-success`,children:T})]})]}),(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`Concurrency policy`}),(0,_.jsx)(`p`,{className:`mb-3 text-xs text-faint`,children:`Live SDK readback is available in Queue Control. Applying a value replaces the broker concurrency for this queue.`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,_.jsx)(d,{label:`Concurrency`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`concurrency`,value:y,onChange:e=>b(e.target.value),placeholder:`max in-flight`})})}),(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:t||!j.valid,onClick:()=>n(`Concurrency set`,()=>i.setConcurrency(e,j.value),`Replace the current concurrency policy for "${e}" with ${j.value} maximum in-flight jobs?`,()=>k(`Applied concurrency ${j.value} at ${new Date().toISOString()}.`)),children:`Replace policy`}),(0,_.jsx)(`div`,{className:`min-w-40 flex-1`,children:(0,_.jsx)(d,{label:`Type ${e} to clear`,children:(0,_.jsx)(l,{name:`concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:C,onChange:e=>w(e.target.value)})})}),(0,_.jsx)(a,{size:`sm`,disabled:t||C!==e,onClick:()=>n(`No concurrency limit ensured`,()=>i.clearConcurrency(e),`Remove the current concurrency policy from queue "${e}"?`,()=>k(`Removed the concurrency policy at ${new Date().toISOString()}.`)),children:`Ensure no concurrency limit`}),!j.valid&&y.trim()&&(0,_.jsx)(`span`,{role:`alert`,className:`self-center text-xs text-danger`,children:`Concurrency must be a positive whole number.`}),O&&(0,_.jsx)(`span`,{role:`status`,className:`w-full text-xs text-success`,children:O})]})]})]})}export{A as a,j as i,R as n,T as o,M as r,w as s,z as t};
@@ -0,0 +1 @@
1
+ import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CyjgmGTq.js";import{t as r}from"./bq-BeBxa743.js";import{n as i}from"./usePolledData-DzlUpBOO.js";import{t as a}from"./Button-BPqpRZJD.js";import{n as o,t as s}from"./Card-C7NMhqUt.js";import{i as c,n as l,r as u}from"./feedback-BnGE2oW2.js";import{n as d}from"./StatusBadge-B0I7hNBX.js";import{t as f}from"./PageHeader-BXlZSBcc.js";import{s as p}from"./format-Cg7VCIZW.js";import{n as m}from"./index-Cui9IwWy.js";import{a as h,n as g,t as _}from"./form-tC20r4Ma.js";import{r as v}from"./useServerActionGuard-BlH-Kso1.js";import{a as y,i as b,n as x,o as S,r as C,s as w,t as ee}from"./QueueActions-C-Aferd6.js";var T=e(t(),1),E={limits:async(e,t)=>D(await r.queueOperations.limits(e,t)),deduplicationJobId:async(e,t)=>O(await r.queueOperations.deduplicationJobId(e,t)),removeDeduplicationKey:async(e,t)=>k(await r.queueOperations.removeDeduplicationKey(e,t)),metrics:async(e,t,n,i)=>A(await r.queueOperations.metrics(e,t,n,i)),trimEvents:async(e,t)=>k(await r.queueOperations.trimEvents(e,t))};function D(e){let t=M(j(e,`Queue limits`).limits,`Queue limits`),n=t.rateLimit;if(n!==null&&(!N(n)||!P(n.max)||!P(n.duration))||t.concurrency!==null&&!P(t.concurrency)||!F(t.rateLimitTtl,-2)||typeof t.maxed!=`boolean`)throw I(`Queue limits`);return{rateLimit:n,concurrency:t.concurrency,rateLimitTtl:t.rateLimitTtl,maxed:t.maxed}}function O(e){let t=j(e,`deduplication lookup`).jobId;if(t!==null&&(typeof t!=`string`||!t))throw I(`deduplication lookup`);return t}function k(e){let t=j(e,`Queue mutation`).removed;if(!F(t,0))throw I(`Queue mutation`);return t}function A(e){let t=M(j(e,`Queue metrics`).metrics,`Queue metrics`),n=M(t.meta,`Queue metrics`);if(!F(n.count,0)||!F(n.prevTS,0)||!F(n.prevCount,0)||!F(t.count,0)||!Array.isArray(t.data)||t.data.length>10001||!t.data.every(e=>F(e,0)))throw I(`Queue metrics`);return t}function j(e,t){let n=M(e,t);if(n.ok!==!0)throw I(t);return n}function M(e,t){if(!N(e))throw I(t);return e}function N(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}var P=e=>F(e,1),F=(e,t)=>Number.isSafeInteger(e)&&e>=t,I=e=>Error(`Malformed ${e} response`),L=n();function R({queue:e,repository:t,busy:n,run:r}){let[i,o]=(0,T.useState)(``),[s,c]=(0,T.useState)(),[l,u]=(0,T.useState)(``),d=i.length>0&&i.length<=1024;return(0,L.jsxs)(`section`,{"aria-labelledby":`queue-dedup-title`,className:`border-t border-line pt-4 xl:border-t-0`,children:[(0,L.jsx)(`h3`,{id:`queue-dedup-title`,className:`text-sm font-semibold text-fg`,children:`Deduplication registry`}),(0,L.jsx)(`p`,{className:`mt-1 mb-4 text-xs leading-5 text-faint`,children:`Resolve an official deduplication ID to its current job, or release only the registry key.`}),(0,L.jsx)(_,{label:`Deduplication ID`,children:(0,L.jsx)(g,{name:`queue-sdk-deduplication-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,value:i,onChange:e=>{o(e.target.value),c(void 0),u(``)}})}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,L.jsx)(a,{size:`sm`,disabled:!d||!!n,onClick:()=>r(`Looking up deduplication key`,()=>t.deduplicationJobId(e,i),c),children:`Find owner`}),(0,L.jsx)(a,{variant:`warning`,size:`sm`,disabled:!d||!!n,onClick:()=>{window.confirm(`Remove deduplication key "${i}" from queue "${e}"? The job is not deleted, but a later enqueue may reuse this key.`)&&r(`Removing deduplication key`,()=>t.removeDeduplicationKey(e,i),e=>{u(e?`Deduplication key removed.`:`No matching key was active.`),c(void 0)},!0)},children:`Remove key`})]}),s!==void 0&&(0,L.jsx)(`p`,{role:`status`,className:`mt-3 break-all text-xs text-muted`,children:s===null?`No active owner.`:`Current job: ${s}`}),l&&(0,L.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:l})]})}function te({snapshot:e,loading:t,error:n}){if(t&&!e)return(0,L.jsx)(`p`,{className:`text-sm text-muted`,children:`Reading broker limit state...`});if(n&&!e)return(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:n});if(!e)return null;let r=e.rateLimit;return(0,L.jsxs)(`div`,{children:[n&&(0,L.jsxs)(`p`,{role:`alert`,className:`mb-3 text-xs text-warning`,children:[`Refresh failed. Showing the last successful limit snapshot: `,n]}),(0,L.jsxs)(`dl`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,L.jsx)(z,{label:`Global rate limit`,value:r?`${r.max} / ${r.duration} ms`:`Not configured`}),(0,L.jsx)(z,{label:`Rate-limit TTL`,value:e.rateLimitTtl===-2?`No active limit`:`${e.rateLimitTtl} ms`}),(0,L.jsx)(z,{label:`Global concurrency`,value:e.concurrency===null?`Not configured`:String(e.concurrency)}),(0,L.jsx)(z,{label:`Capacity`,value:e.maxed?`Maxed`:`Available`})]})]})}function z({label:e,value:t}){return(0,L.jsxs)(`div`,{className:`min-w-0 border-l-2 border-line pl-3`,children:[(0,L.jsx)(`dt`,{className:`text-[11px] font-medium text-faint`,children:e}),(0,L.jsx)(`dd`,{className:`mt-1 break-words font-mono text-sm text-fg`,children:t})]})}function B({queue:e,repository:t,busy:n,run:r}){let[i,o]=(0,T.useState)(`completed`),[s,c]=(0,T.useState)(`0`),[l,u]=(0,T.useState)(`29`),[d,f]=(0,T.useState)(`1000`),[p,m]=(0,T.useState)(null),[v,y]=(0,T.useState)(``),b=H(s,l),x=U(d,0,1e6);return(0,L.jsxs)(`section`,{"aria-labelledby":`queue-telemetry-title`,className:`border-t border-line pt-4 xl:border-t-0`,children:[(0,L.jsx)(`h3`,{id:`queue-telemetry-title`,className:`text-sm font-semibold text-fg`,children:`Durable queue telemetry`}),(0,L.jsx)(`p`,{className:`mt-1 mb-4 text-xs leading-5 text-faint`,children:`Read paged one-minute completion or failure buckets, and bound the lifecycle-event journal.`}),(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,L.jsx)(_,{label:`Metric`,children:(0,L.jsxs)(h,{name:`queue-sdk-metric-type`,value:i,onChange:e=>o(e.target.value),children:[(0,L.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,L.jsx)(`option`,{value:`failed`,children:`Failed`})]})}),(0,L.jsx)(_,{label:`Start bucket`,children:(0,L.jsx)(g,{name:`queue-sdk-metric-start`,type:`number`,min:0,max:1e4,value:s,onChange:e=>c(e.target.value)})}),(0,L.jsx)(_,{label:`End bucket`,hint:`Use -1 for all remaining buckets`,children:(0,L.jsx)(g,{name:`queue-sdk-metric-end`,type:`number`,min:-1,max:1e4,value:l,onChange:e=>u(e.target.value)})})]}),(0,L.jsx)(a,{className:`mt-3`,size:`sm`,disabled:!b||!!n,onClick:()=>{b&&r(`Reading ${i} metrics`,()=>t.metrics(e,i,b.start,b.end),m)},children:`Read metrics`}),!b&&(0,L.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:`Use integer buckets from 0 to 10000; end must be -1 or at least start.`}),p&&(0,L.jsx)(V,{metrics:p}),(0,L.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-end gap-3 border-t border-line pt-4`,children:[(0,L.jsx)(`div`,{className:`min-w-48 flex-1`,children:(0,L.jsx)(_,{label:`Retain lifecycle events`,hint:`0 clears the queue journal`,children:(0,L.jsx)(g,{name:`queue-sdk-event-retention`,type:`number`,min:0,max:1e6,value:d,onChange:e=>f(e.target.value)})})}),(0,L.jsx)(a,{variant:`warning`,size:`sm`,disabled:x===null||!!n,onClick:()=>{x!==null&&window.confirm(`Retain at most ${x} lifecycle events for queue "${e}"? Older journal events are permanently removed; metric buckets are unchanged.`)&&r(`Trimming lifecycle journal`,()=>t.trimEvents(e,x),e=>y(`${e} lifecycle events removed.`),!0)},children:`Trim journal`})]}),v&&(0,L.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:v})]})}function V({metrics:e}){let t=e.data.slice(0,120).map((t,n)=>({timestamp:e.meta.prevTS-n*6e4,value:t,offset:n})),n=Math.max(1,...t.map(e=>e.value));return(0,L.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-2 p-3`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-1 font-mono text-xs text-muted`,children:[(0,L.jsxs)(`span`,{children:[`Total terminal: `,e.meta.count]}),(0,L.jsxs)(`span`,{children:[`Available buckets: `,e.count]}),(0,L.jsxs)(`span`,{children:[`Latest bucket: `,e.meta.prevCount]})]}),t.length?(0,L.jsx)(`div`,{className:`mt-3 flex h-16 items-end gap-px overflow-hidden`,role:`img`,"aria-label":`${t.length} one-minute metric buckets, newest first`,children:t.map(e=>(0,L.jsx)(`span`,{title:`Bucket ${e.offset}: ${e.value}`,className:`min-w-px flex-1 bg-accent/70`,style:{height:`${Math.max(2,e.value/n*100)}%`}},e.timestamp))}):(0,L.jsx)(`p`,{className:`mt-3 text-xs text-faint`,children:`No buckets in this range.`}),e.data.length>t.length&&(0,L.jsx)(`p`,{className:`mt-2 text-[11px] text-faint`,children:`Showing the first 120 returned buckets.`})]})}function H(e,t){let n=U(e,0,1e4),r=U(t,-1,1e4);return n===null||r===null||r!==-1&&r<n?null:{start:n,end:r}}function U(e,t,n){let r=Number(e);return Number.isSafeInteger(r)&&r>=t&&r<=n?r:null}function ne({queue:e,refreshKey:t=0,repository:n=E,onApplied:r}){let[i,c]=(0,T.useState)(``),[l,u]=(0,T.useState)(null),[d,f]=(0,T.useState)(``),[p,m]=(0,T.useState)(``),h=(0,T.useRef)(!1),v=(0,T.useRef)(0),y=(0,T.useRef)(!0),b=l?.queue===e?l:{queue:e,snapshot:null,loading:!0,error:``};(0,T.useEffect)(()=>(y.current=!0,()=>{y.current=!1,v.current+=1}),[]);let x=(0,T.useCallback)(async()=>{let t=re(i);if(t===null){u(t=>({queue:e,snapshot:t?.queue===e?t.snapshot:null,loading:!1,error:`maxJobs must be a whole number from 0 to 1000000.`}));return}let r=++v.current;u(t=>({queue:e,snapshot:t?.queue===e?t.snapshot:null,loading:!0,error:``}));try{let i=await n.limits(e,t);y.current&&r===v.current&&u({queue:e,snapshot:i,loading:!1,error:``})}catch(t){y.current&&r===v.current&&u({queue:e,snapshot:null,loading:!1,error:W(t)})}},[i,e,n]);(0,T.useEffect)(()=>void x(),[e,t]);let S=(e,t,n,i=!1)=>{h.current||(h.current=!0,f(e),m(``),t().then(e=>{y.current&&(n(e),i&&(r?.(),r||x()))}).catch(e=>{y.current&&m(W(e))}).finally(()=>{h.current=!1,y.current&&f(``)}))};return(0,L.jsxs)(s,{className:`mb-6`,children:[(0,L.jsx)(o,{title:`Queue SDK operations`,action:d?(0,L.jsxs)(`span`,{className:`font-mono text-xs text-accent`,children:[d,`...`]}):void 0}),(0,L.jsx)(`p`,{className:`mb-5 max-w-3xl text-xs leading-5 text-faint`,children:`Live Bunqueue 2.8.57 limit, deduplication, metric, and event-journal contracts. Requests are pinned to the server managed by this control agent.`}),(0,L.jsxs)(`div`,{className:`mb-5 flex flex-wrap items-end gap-3 border-b border-line pb-5`,children:[(0,L.jsx)(`div`,{className:`w-48`,children:(0,L.jsx)(_,{label:`TTL threshold (maxJobs)`,hint:`Optional token-consumption threshold`,children:(0,L.jsx)(g,{name:`queue-sdk-max-jobs`,type:`number`,min:0,max:1e6,step:1,value:i,onChange:e=>c(e.target.value),placeholder:`Not set`})})}),(0,L.jsx)(a,{size:`sm`,disabled:b.loading||!!d,onClick:x,children:`Refresh limits`})]}),(0,L.jsx)(te,{snapshot:b.snapshot,loading:b.loading,error:b.error}),p&&(0,L.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:p}),(0,L.jsxs)(`div`,{className:`mt-6 grid gap-6 xl:grid-cols-[0.8fr_1.2fr]`,children:[(0,L.jsx)(R,{queue:e,repository:n,busy:d,run:S},`${e}:deduplication`),(0,L.jsx)(B,{queue:e,repository:n,busy:d,run:S},`${e}:telemetry`)]})]})}function re(e){if(!e.trim())return;let t=Number(e);return Number.isSafeInteger(t)&&t>=0&&t<=1e6?t:null}var W=e=>e instanceof Error?e.message:String(e),G=[`waiting`,`prioritized`,`active`,`completed`,`failed`,`delayed`,`waiting-children`,`paused`],K=500,q=200,J=K*q;function Y(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function X(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ie(e){return Y(e)&&G.every(t=>X(e[t]))}function Z(e,t){if(!Y(e)||e.ok!==!0||!Array.isArray(e.queues)||!X(e.total)||!X(e.limit)||e.limit<1||!X(e.offset)||e.offset!==t||typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp)||!e.queues.every(e=>Y(e)&&typeof e.name==`string`&&e.name.length>0&&X(e.waiting)&&X(e.delayed)&&X(e.active)&&X(e.dlq)&&typeof e.paused==`boolean`))throw Error(`Malformed /dashboard/queues response.`)}async function Q(){let e=await r.queues(K,0);Z(e,0);let t=e.total;if(t>J)throw Error(`Queue discovery reported ${t} queues, above the safe dashboard limit of ${J}.`);if(e.queues.length!==Math.min(K,t))throw Error(`Incomplete /dashboard/queues page at offset 0: expected ${Math.min(K,t)} queues, received ${e.queues.length}.`);let n=new Map,i=e=>{for(let t of e.queues){if(n.has(t.name))throw Error(`Overlapping /dashboard/queues pages: queue "${t.name}" appeared more than once.`);n.set(t.name,t)}};i(e);let a=e.queues.length,o=1;for(;a<t;){if(o>=q)throw Error(`Queue discovery exceeded the safe limit of ${q} pages.`);let e=await r.queues(K,a);if(Z(e,a),e.total!==t)throw Error(`Queue discovery changed during pagination: total moved from ${t} to ${e.total}. Retry the snapshot.`);let n=Math.min(K,t-a);if(e.queues.length!==n)throw Error(`Incomplete /dashboard/queues page at offset ${a}: expected ${n} queues, received ${e.queues.length}.`);i(e),a+=e.queues.length,o+=1}if(n.size!==t)throw Error(`Incomplete /dashboard/queues snapshot: expected ${t} unique queues, received ${n.size}.`);return{...e,queues:[...n.values()],total:t,limit:K,offset:0}}function ae(e,t){if(!Y(e)||e.ok!==!0||e.name!==t||typeof e.paused!=`boolean`||!ie(e.counts))throw Error(`Malformed queue detail response for "${t}".`)}function $(e){if(!Y(e)||e.ok!==!0||!w(e.config))throw Error(`Malformed /stall-config response.`);return e.config}function oe(e){if(!Y(e)||e.ok!==!0||!S(e.config))throw Error(`Malformed /dlq-config response.`);return e.config}function se(e){if(!Y(e)||e.ok!==!0)throw Error(`Malformed queue action response: expected { ok: true }.`);if(e.count!==void 0){if(!X(e.count))throw Error(`Malformed queue action response: count must be a non-negative integer.`);return e.count}}function ce(e,t){return t.some(t=>t.name===e)?e:t[0]?.name??``}function le(){let[e,t]=(0,T.useState)(``),[n,a]=(0,T.useState)(!1),[o,s]=(0,T.useState)(0),[g,_]=(0,T.useState)(null),S=v(`queue-control:${e}`);(0,T.useEffect)(()=>{a(!1),_(null)},[S.scopeKey]);let{data:w,error:E,loading:D,refetch:O}=i(Q,[],{intervalMs:3e4});(0,T.useEffect)(()=>{w&&t(e=>ce(e,w.queues))},[w]);let{data:k,error:A,loading:j,refetch:M}=i((0,T.useCallback)(async()=>{if(!e)return null;let[t,n,i]=await Promise.all([r.queueDetail(e,!1),r.getStallConfig(e).then($).catch(()=>null),r.getDlqConfig(e).then(oe).catch(()=>null)]);return ae(t,e),{queue:e,detail:t,stall:n,dlq:i}},[e]),[e]),N=!w||w.queues.some(t=>t.name===e),P=k&&k.queue===e&&N?k:null,F=(t,n,i,o)=>{let c=e;if(!c||i&&!window.confirm(i))return;let l=S.begin(`queue-write`);l&&(a(!0),_(null),(async()=>{try{let e=await r.queuesSummary();if(!l.isCurrent())return;if(!e.some(e=>e.name===c))throw Error(`Queue "${c}" no longer exists`);let i=se(await n());if(!l.isCurrent())return;_({queue:c,ok:!0,text:`${t}${i==null?` ✓`:`: ${i}`}`}),o?.(),s(e=>e+1),await M()}catch(e){l.isCurrent()&&_({queue:c,ok:!1,text:e.message})}finally{l.finish()&&a(!1)}})())};return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(f,{title:`Queue Control`,description:`Full per-queue operations and configuration.`,live:!!e&&!!P?.detail&&!!P.stall&&!!P.dlq&&!A&&!E}),(0,L.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`w-56`,children:(0,L.jsx)(h,{value:e,"aria-label":`Queue`,name:`queue-control-queue`,autoComplete:`off`,onChange:e=>t(e.target.value),children:(w?.queues??[]).map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),P?.detail&&(0,L.jsx)(d,{label:P.detail.paused?`Paused`:`Active`,tone:P.detail.paused?`amber`:`green`}),g?.queue===e&&(0,L.jsx)(`span`,{role:`status`,className:g.ok?`text-xs text-success`:`text-xs text-danger`,children:g.text})]}),E&&(0,L.jsx)(c,{onRetry:O,message:`Could not discover queues — ${E.message}. Retry to choose a queue.`}),A&&P&&(0,L.jsx)(c,{message:`Queue refresh failed — showing the last successful configuration.`,onRetry:M}),A&&!P?(0,L.jsx)(l,{error:A,onRetry:M}):D&&!w&&!e&&!E?(0,L.jsx)(u,{label:`Discovering queues…`}):j&&!P?(0,L.jsx)(u,{}):E&&!e?(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-warning`,children:`Queue discovery failed. Retry the request above before choosing a queue.`}):P?.detail?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-8`,children:G.map(e=>(0,L.jsx)(m,{label:e,value:p(P.detail.counts[e]),compact:!0},e))}),(0,L.jsx)(x,{queue:e,paused:P.detail.paused,busy:n,run:F},`${e}:lifecycle`),(0,L.jsx)(ee,{queue:e,busy:n,run:F},`${e}:limits`),(0,L.jsx)(ne,{queue:e,refreshKey:o,onApplied:()=>s(e=>e+1)},`${e}:sdk-operations`),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[P.stall?(0,L.jsx)(b,{queue:e,config:P.stall,onSaved:async()=>{_({queue:e,ok:!0,text:`Stall config saved ✓`}),await M()}},`${e}:stall`):(0,L.jsx)(C,{title:`Stall detection`,onRetry:M}),P.dlq?(0,L.jsx)(y,{queue:e,config:P.dlq,onSaved:async()=>{_({queue:e,ok:!0,text:`DLQ config saved ✓`}),await M()}},`${e}:dlq`):(0,L.jsx)(C,{title:`DLQ policy`,onRetry:M})]})]}):!A&&(0,L.jsx)(`p`,{className:`text-sm text-faint`,children:w?.queues.length===0?`No queues are available.`:`Select a queue.`})]})}export{le as QueueControl,Q as t};
@@ -0,0 +1 @@
1
+ import{i as e}from"./cn-zFEt5SO8.js";import{d as t,g as n,r,t as i}from"./react-vendor-CyjgmGTq.js";import{t as a}from"./bq-BeBxa743.js";import{A as o,b as s,i as c,m as l,n as u,x as d}from"./icons-CIvFfU2b.js";import{t as f}from"./api-CQ5Z7xR7.js";import{n as p}from"./usePolledData-DzlUpBOO.js";import{t as m}from"./Button-BPqpRZJD.js";import{t as h}from"./Card-C7NMhqUt.js";import{i as g,r as _,t as v}from"./feedback-BnGE2oW2.js";import{n as y,t as b}from"./StatusBadge-B0I7hNBX.js";import{a as x,c as S,d as C,l as w,s as T,t as E}from"./format-Cg7VCIZW.js";import{n as D}from"./index-Cui9IwWy.js";import{a as O,n as k,t as A}from"./form-tC20r4Ma.js";import{r as j,t as M}from"./useServerActionGuard-BlH-Kso1.js";import{r as N}from"./flowMutationSafety-CoOp94wS.js";var P=e(n(),1),F=i();function I({queue:e}){return(0,F.jsxs)(`div`,{className:`mt-8`,children:[(0,F.jsx)(`h2`,{className:`mb-3 text-lg font-semibold text-fg`,children:`Configuration`}),(0,F.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:`Bunqueue v2.8.57 cannot read either current policy. Every command below is an explicit blind desired-state write; a receipt proves only what this dashboard applied at that time.`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,F.jsx)(z,{queue:e}),(0,F.jsx)(B,{queue:e})]})]})}function L(e){if(!e.trim())return null;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null}function R(e,t){let[n,r]=(0,P.useState)(!1),[i,o]=(0,P.useState)(null),[s,c]=(0,P.useState)(null),l=j(`classic-queue-policy:${e}:${t}`);return(0,P.useEffect)(()=>{r(!1),o(null),c(null)},[l.scopeKey]),{busy:n,error:i,receipt:s,run:async(n,i,s)=>{if(!window.confirm(i))return;let u=l.begin(t);if(u){r(!0),o(null),c(null);try{let t=await a.queuesSummary();if(!u.isCurrent())return;if(!t.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);if(M(await s(),n),!u.isCurrent())return;c(`${n} applied at ${new Date().toISOString()}. Current server state cannot be read.`)}catch(e){u.isCurrent()&&o(e.message)}finally{u.finish()&&r(!1)}}}}}function z({queue:e}){let[t,n]=(0,P.useState)(``),[r,i]=(0,P.useState)(``),[o,s]=(0,P.useState)(`permanent`),[c,u]=(0,P.useState)(``),[d,f]=(0,P.useState)(``),{busy:p,error:g,receipt:_,run:v}=R(e,`rate-limit`),y=L(t),b=L(r),x=o===`expires`?L(c):void 0,S=y!==null&&b!==null&&(o===`permanent`||x!=null);return(0,F.jsxs)(h,{children:[(0,F.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Rate-limit desired state`}),(0,F.jsx)(l,{className:`size-4 text-faint`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,F.jsx)(A,{label:`Limit`,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-limit`,value:t,"aria-invalid":t.trim()!==``&&y===null,onChange:e=>n(e.target.value),placeholder:`100`})}),(0,F.jsx)(A,{label:`Window (ms)`,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-duration`,value:r,"aria-invalid":r.trim()!==``&&b===null,onChange:e=>i(e.target.value),placeholder:`60000`})}),(0,F.jsx)(A,{label:`TTL`,children:(0,F.jsxs)(O,{name:`classic-rate-ttl-mode`,value:o,onChange:e=>s(e.target.value),children:[(0,F.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,F.jsx)(`option`,{value:`expires`,children:`Expires after`})]})}),(0,F.jsx)(A,{label:`TTL (ms)`,hint:o===`permanent`?`Not sent`:void 0,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-ttl`,disabled:o===`permanent`,value:c,"aria-invalid":o===`expires`&&c.trim()!==``&&x==null,onChange:e=>u(e.target.value),placeholder:`3600000`})})]}),(0,F.jsx)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:(0,F.jsx)(m,{variant:`accent`,size:`sm`,disabled:p||!S,onClick:()=>{if(y===null||b===null||o===`expires`&&x===null)return;let t=typeof x==`number`?x:void 0,n=o===`permanent`?`permanent`:`TTL ${x}ms`;v(`Rate-limit policy replaced`,`Replace the unknown rate-limit policy for "${e}" with limit ${y}, window ${b}ms, ${n}?`,()=>a.setRateLimit(e,y,b,t))},children:`Replace rate-limit policy`})}),(0,F.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,F.jsx)(A,{label:`Type ${e} to clear`,children:(0,F.jsx)(k,{name:`classic-rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:d,onChange:e=>f(e.target.value)})}),(0,F.jsx)(m,{className:`mt-2`,size:`sm`,disabled:p||d!==e,onClick:()=>void v(`No rate limit ensured`,`Ensure queue "${e}" has no rate-limit policy? The previous value is unavailable.`,()=>a.clearRateLimit(e)),children:`Ensure no rate limit`})]}),_&&(0,F.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:_}),g&&(0,F.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:g})]})}function B({queue:e}){let[t,n]=(0,P.useState)(``),[r,i]=(0,P.useState)(``),{busy:s,error:c,receipt:l,run:u}=R(e,`concurrency`),d=L(t);return(0,F.jsxs)(h,{children:[(0,F.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Concurrency desired state`}),(0,F.jsx)(o,{className:`size-4 text-faint`})]}),(0,F.jsx)(A,{label:`Maximum in-flight jobs`,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-concurrency`,value:t,"aria-invalid":t.trim()!==``&&d===null,onChange:e=>n(e.target.value),placeholder:`5`})}),(0,F.jsx)(`div`,{className:`mt-4 flex items-center gap-2`,children:(0,F.jsx)(m,{variant:`accent`,size:`sm`,disabled:s||d===null,onClick:()=>{d!==null&&u(`Concurrency policy replaced`,`Replace the unknown concurrency policy for "${e}" with ${d} maximum in-flight jobs?`,()=>a.setConcurrency(e,d))},children:`Replace concurrency policy`})}),(0,F.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,F.jsx)(A,{label:`Type ${e} to clear`,children:(0,F.jsx)(k,{name:`classic-concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value)})}),(0,F.jsx)(m,{className:`mt-2`,size:`sm`,disabled:s||r!==e,onClick:()=>void u(`No concurrency limit ensured`,`Ensure queue "${e}" has no concurrency policy? The previous value is unavailable.`,()=>a.clearConcurrency(e)),children:`Ensure no concurrency limit`})]}),l&&(0,F.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:l}),c&&(0,F.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:c})]})}var V=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`,`paused`],H={detail:{ok:!1,name:``,counts:{waiting:0,active:0,completed:0,failed:0,delayed:0,prioritized:0,"waiting-children":0,paused:0},paused:!1,priorityCounts:{},dlqPreview:[],timestamp:0},jobs:[],recentJobsError:null};function U(){let{name:e=``}=t(),[n,i]=(0,P.useState)(null),[o,l]=(0,P.useState)(null),h=j(`classic-queue:${e}`);(0,P.useEffect)(()=>{i(null),l(null)},[h.scopeKey]);let{data:O,error:k,loading:A,refetch:L}=p((0,P.useCallback)(async()=>{if(!(await a.queuesSummary()).some(t=>t.name===e))return{exists:!1,detail:null,jobs:[],recentJobsError:null};let[t,n]=await Promise.all([f.queueDetail(e,!1),f.jobsList(e,{states:V,limit:12}).then(e=>({jobs:e.jobs??[],error:null})).catch(e=>({jobs:[],error:e.message||`Unknown error`}))]);if(t.ok!==!0||t.name!==e)throw Error(`Malformed queue detail response for "${e}"`);return{exists:!0,detail:t,jobs:n.jobs,recentJobsError:n.error}},[e]),[e]),R=async(t,n,r)=>{if(r&&!window.confirm(r))return;let o=h.begin(t);if(o){i(t),l(null);try{let r=await a.queuesSummary();if(!o.isCurrent())return;if(!r.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);if(M(await n(),t),!o.isCurrent())return;await L()}catch(e){o.isCurrent()&&l(e.message)}finally{o.finish()&&i(null)}}};if(A&&!O&&!k)return(0,F.jsx)(_,{label:`Loading ${e}…`});if(k&&!O)return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsx)(g,{onRetry:L})]});if(O?.exists===!1)return(0,F.jsxs)(`div`,{children:[k&&(0,F.jsx)(g,{onRetry:L}),(0,F.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsx)(v,{title:`Queue not found`,hint:`No queue named "${e}" exists on the current Bunqueue server.`,action:(0,F.jsx)(r,{to:`/queues-classic`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Back to classic queues`})})]});let z=O?.exists===!0?O:H,{detail:B}=z,U=B.counts,W=E(U.completed??0,U.failed??0),G=[...z.jobs].sort((e,t)=>(t.createdAt??0)-(e.createdAt??0));return(0,F.jsxs)(`div`,{children:[k&&(0,F.jsx)(g,{onRetry:L}),(0,F.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(r,{to:`/queues-classic`,"aria-label":`Back to classic queues`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,F.jsx)(c,{className:`size-4`})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3`,children:[(0,F.jsx)(y,{label:B.paused?`Paused`:`Active`,tone:B.paused?`amber`:`green`}),(0,F.jsx)(y,{label:k?`Stale`:`Live`,tone:k?`amber`:`green`})]})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[B.paused?(0,F.jsxs)(m,{variant:`success`,size:`sm`,disabled:n!=null,onClick:()=>R(`resume`,()=>f.resume(e)),children:[(0,F.jsx)(d,{className:`size-3.5`}),` Resume`]}):(0,F.jsxs)(m,{variant:`warning`,size:`sm`,disabled:n!=null,onClick:()=>R(`pause`,()=>f.pause(e)),children:[(0,F.jsx)(s,{className:`size-3.5`}),` Pause`]}),(0,F.jsx)(m,{size:`sm`,disabled:!0,title:N,children:`Drain`}),(0,F.jsx)(m,{variant:`danger`,size:`sm`,disabled:!0,title:N,children:`Obliterate`})]})]}),o&&(0,F.jsx)(`div`,{className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-red-400`,children:o}),(0,F.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:N}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,F.jsx)(D,{label:`Waiting`,value:T(U.waiting),tone:`amber`}),(0,F.jsx)(D,{label:`Active`,value:T(U.active),tone:`blue`}),(0,F.jsx)(D,{label:`Completed`,value:T(U.completed),tone:`green`}),(0,F.jsx)(D,{label:`Failed`,value:T(U.failed),tone:U.failed?`red`:`default`}),(0,F.jsx)(D,{label:`Delayed`,value:T(U.delayed),tone:`default`}),(0,F.jsx)(D,{label:`Error Rate`,value:W==null?`—`:S(W),tone:W==null?`default`:W>.05?`red`:`green`})]}),(0,F.jsxs)(`div`,{className:`mt-8`,children:[(0,F.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,F.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:`Recent Jobs`}),(0,F.jsxs)(r,{to:`/jobs-classic?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all jobs `,(0,F.jsx)(u,{className:`size-3.5`})]})]}),(0,F.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,F.jsxs)(`table`,{className:`w-full min-w-[44rem] text-sm`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`ID`}),(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,F.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,F.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`})]})}),(0,F.jsx)(`tbody`,{children:z.recentJobsError?(0,F.jsx)(`tr`,{children:(0,F.jsxs)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-danger`,children:[`Could not load recent jobs — `,z.recentJobsError,`. Retry the page.`]})}):G.length===0?(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:`No recent jobs.`})}):G.map(e=>(0,F.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,F.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs`,children:(0,F.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`rounded text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:e.id})}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.data?.name||`unknown`}),(0,F.jsx)(`td`,{className:`px-5 py-3`,children:(0,F.jsx)(b,{status:String(e.state??e.status??`waiting`)})}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:x(C(e.startedAt,e.completedAt))}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:w(e.createdAt)})]},e.id))})]})})]}),(0,F.jsx)(I,{queue:e})]})}export{U as QueueDetail};