bunqueue-dashboard 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/README.md +8 -7
  2. package/agent/manager/config.ts +2 -1
  3. package/agent/server/handler.ts +2 -1
  4. package/agent/server/router.ts +1 -0
  5. package/agent/server/types.ts +1 -1
  6. package/agent/workflow/runtime.ts +25 -7
  7. package/agent/workflow/runtimeRoutes.ts +4 -1
  8. package/dist/.vite/manifest.json +341 -603
  9. package/dist/assets/AddJob-Dgjlhzn2.js +3 -0
  10. package/dist/assets/Alerts-Lyzbq0qw.js +1 -0
  11. package/dist/assets/{AreaChart-Db2UVnaK.js → AreaChart-CSP0-00u.js} +1 -1
  12. package/dist/assets/Benchmark-B4NfYkAi.js +1 -0
  13. package/dist/assets/{BulkAddJobs-GRMVnf0j.js → BulkAddJobs-BAN5wT8A.js} +3 -3
  14. package/dist/assets/Cron-Bz46oVXB.js +1 -0
  15. package/dist/assets/CronManager-Cl5RW2cB.js +1 -0
  16. package/dist/assets/Database-CeUKS6Nf.js +3 -0
  17. package/dist/assets/Diagnostics-DuzTPfyb.js +1 -0
  18. package/dist/assets/Dlq-D8s-NhV2.js +1 -0
  19. package/dist/assets/DlqControl-DDxRMM8i.js +1 -0
  20. package/dist/assets/DlqPro-xj-MM6u8.js +1 -0
  21. package/dist/assets/Fleet-BAziMWfo.js +1 -0
  22. package/dist/assets/Flows-BFUMTSWv.js +2 -0
  23. package/dist/assets/JobInspector-BXuXxDwR.js +2 -0
  24. package/dist/assets/Jobs-pQBmffni.js +1 -0
  25. package/dist/assets/JobsPro-k20Pas24.js +1 -0
  26. package/dist/assets/Logs-DA4JFvpM.js +1 -0
  27. package/dist/assets/LogsPro-hna5L6sP.js +1 -0
  28. package/dist/assets/McpServer-Cqem-L3z.js +22 -0
  29. package/dist/assets/Metrics-CJ9dW0me.js +1 -0
  30. package/dist/assets/MetricsPro-BslYrx1A.js +1 -0
  31. package/dist/assets/Overview-Cmg_2NAt.js +1 -0
  32. package/dist/assets/Pagination-WVfHLHDS.js +1 -0
  33. package/dist/assets/{QueueActions-BBxRt-t0.js → QueueActions-BQf1-g5m.js} +1 -1
  34. package/dist/assets/QueueControl-BiMM0jLp.js +1 -0
  35. package/dist/assets/QueueDetail-DfRY4jS4.js +1 -0
  36. package/dist/assets/QueueDetailPro-CpSMSo8A.js +1 -0
  37. package/dist/assets/Queues-C5lElTjp.js +1 -0
  38. package/dist/assets/QueuesOverview-DRohFtuC.js +1 -0
  39. package/dist/assets/S3Backup-DUHmp2Xw.js +1 -0
  40. package/dist/assets/S3BackupPro-Cr2ZJZkw.js +3 -0
  41. package/dist/assets/ServerControl-m58ooJT2.js +3 -0
  42. package/dist/assets/Settings-DXsjoOqD.js +1 -0
  43. package/dist/assets/{StatusBadge-DereLzOj.js → StatusBadge-D-mexaga.js} +1 -1
  44. package/dist/assets/Usage-CY2uEJEu.js +1 -0
  45. package/dist/assets/UsagePro-DtlB1dJc.js +1 -0
  46. package/dist/assets/Webhooks-B_GwTCBW.js +1 -0
  47. package/dist/assets/Workers-Bu8aJlZf.js +1 -0
  48. package/dist/assets/WorkersPro-C6gNYGfo.js +1 -0
  49. package/dist/assets/Workflows-ClF4YzhW.js +1 -0
  50. package/dist/assets/{api-D9aT0ND7.js → api-CCgfskjt.js} +1 -1
  51. package/dist/assets/{classicJobsData-Csj4iihY.js → classicJobsData-wdIr-E4y.js} +1 -1
  52. package/dist/assets/connectionStore-B946Fhuv.js +1 -0
  53. package/dist/assets/controlConnectionEpoch-x9VjrWgN.js +1 -0
  54. package/dist/assets/{form-DG3X6cLL.js → form-DBkslwzu.js} +1 -1
  55. package/dist/assets/{icons-DH9SS1DA.js → icons-BIT5aq1c.js} +1 -1
  56. package/dist/assets/index-DR8flo6r.css +1 -0
  57. package/dist/assets/index-X_fHGbXZ.js +8 -0
  58. package/dist/assets/install-hFu5e6YM.js +3 -0
  59. package/dist/assets/package-Bb3FkjoS.js +1 -0
  60. package/dist/assets/react-vendor-08inPAVO.js +11 -0
  61. package/dist/assets/responses-YgpvqWEr.js +1 -0
  62. package/dist/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  63. package/dist/assets/{useControlActionGuard-1i7aFA7E.js → useControlActionGuard-Bx5MkufG.js} +1 -1
  64. package/dist/assets/{useServerActionGuard-CUx8TOAC.js → useServerActionGuard-uiZWD3dS.js} +1 -1
  65. package/dist/assets/useThroughputSeries-BN5QmKPt.js +1 -0
  66. package/dist/index.html +8 -16
  67. package/package.json +46 -56
  68. package/scripts/embedded.gen.ts +140 -154
  69. package/dist/assets/AddJob-CiwWycYG.js +0 -3
  70. package/dist/assets/Alerts-DCKl_C8D.js +0 -1
  71. package/dist/assets/Benchmark-DyHvEM8x.js +0 -1
  72. package/dist/assets/Button-_aSJvRoW.js +0 -1
  73. package/dist/assets/Card-egIDLwVk.js +0 -1
  74. package/dist/assets/Cron-XL0PdUEc.js +0 -1
  75. package/dist/assets/CronManager-Cqtg9Zr8.js +0 -1
  76. package/dist/assets/Database-BBzyi7f0.js +0 -3
  77. package/dist/assets/Diagnostics-E_icHggb.js +0 -1
  78. package/dist/assets/Dlq-DNs32CzV.js +0 -1
  79. package/dist/assets/DlqControl-DawwIsTI.js +0 -1
  80. package/dist/assets/DlqPro-BEdxFiNN.js +0 -1
  81. package/dist/assets/Fleet-Bkbq0dFB.js +0 -1
  82. package/dist/assets/Flows-DKZxI7ta.js +0 -2
  83. package/dist/assets/JobInspector-BARE52q3.js +0 -2
  84. package/dist/assets/Jobs-CKzKpQ7i.js +0 -1
  85. package/dist/assets/JobsPro-DxDw-akG.js +0 -1
  86. package/dist/assets/Logs-Bj60G_FP.js +0 -1
  87. package/dist/assets/LogsPro-Hv8xwXDK.js +0 -1
  88. package/dist/assets/McpServer-zxSMjG8K.js +0 -24
  89. package/dist/assets/Metrics-BBLdWOw1.js +0 -1
  90. package/dist/assets/MetricsPro-D470b1aP.js +0 -1
  91. package/dist/assets/Overview-B_AOa5kW.js +0 -1
  92. package/dist/assets/PageHeader-CQzNsw8r.js +0 -1
  93. package/dist/assets/Pagination-CSkzhNW6.js +0 -1
  94. package/dist/assets/QueueControl-DaZjeZnw.js +0 -1
  95. package/dist/assets/QueueDetail-Dgo9Ukmp.js +0 -1
  96. package/dist/assets/QueueDetailPro-D7U8ahp2.js +0 -1
  97. package/dist/assets/Queues-CS8LeZtJ.js +0 -1
  98. package/dist/assets/QueuesOverview-BySSnCm0.js +0 -1
  99. package/dist/assets/S3Backup-Ci4dJPP_.js +0 -1
  100. package/dist/assets/S3BackupPro-UwWu0yxr.js +0 -3
  101. package/dist/assets/ServerControl-Ch1wZcKB.js +0 -3
  102. package/dist/assets/Settings-FOzwrB25.js +0 -1
  103. package/dist/assets/Usage-DR90dCt0.js +0 -1
  104. package/dist/assets/UsagePro-DAlE3oCE.js +0 -1
  105. package/dist/assets/Webhooks-BonYUgMo.js +0 -1
  106. package/dist/assets/Workers-D1Ead02h.js +0 -1
  107. package/dist/assets/WorkersPro-XuLxtU4A.js +0 -1
  108. package/dist/assets/Workflows-CqZZ96EK.js +0 -1
  109. package/dist/assets/bq-DR2BTISO.js +0 -1
  110. package/dist/assets/connectionStore-CVjQyIZv.js +0 -1
  111. package/dist/assets/controlConnectionEpoch-ChAeMMLk.js +0 -1
  112. package/dist/assets/feedback-CtGN_kqB.js +0 -1
  113. package/dist/assets/format-Cg7VCIZW.js +0 -1
  114. package/dist/assets/index-DZFZr0Mi.js +0 -8
  115. package/dist/assets/index-DaEyLvTR.css +0 -1
  116. package/dist/assets/install-oydLpc1T.js +0 -3
  117. package/dist/assets/react-vendor-CFL9l8LK.js +0 -11
  118. package/dist/assets/responses-BkR2JTH9.js +0 -1
  119. package/dist/assets/rolldown-runtime-QTnfLwEv.js +0 -1
  120. package/dist/assets/toastStore-XmMX7A5W.js +0 -1
  121. package/dist/assets/usePolledData-CEyyLRYa.js +0 -1
  122. package/dist/assets/useThroughputSeries-CeFx-Mwq.js +0 -1
  123. package/patches/ai@7.0.14.patch +0 -25
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{d as t,h as n,r,t as i}from"./react-vendor-08inPAVO.js";import{i as a,n as o}from"./icons-BIT5aq1c.js";import{n as s,r as c}from"./StatusBadge-D-mexaga.js";import{C as l,F as u,I as d,O as f,S as p,_ as m,b as h,g,h as _,l as v,r as y,s as b,u as x,v as S,x as C,y as w}from"./index-X_fHGbXZ.js";import{r as T,t as E}from"./useServerActionGuard-uiZWD3dS.js";import{r as D}from"./flowMutationSafety-YKTHxqKv.js";import{n as O}from"./controlConnectionEpoch-x9VjrWgN.js";import{t as k}from"./AreaChart-CSP0-00u.js";import{a as A,i as j,n as M,r as N,t as P}from"./QueueActions-BQf1-g5m.js";import{t as F}from"./useThroughputSeries-BN5QmKPt.js";var I=e(n(),1),L=[`waiting`,`prioritized`,`active`,`waiting-children`,`delayed`,`completed`,`failed`,`paused`],R=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`],z=2e3,B=i();function V({name:e,jobs:t,error:n}){return(0,B.jsxs)(C,{padded:!1,className:`mb-6`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3`,children:[(0,B.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Recent jobs`}),(0,B.jsxs)(r,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all `,(0,B.jsx)(o,{className:`size-3.5`})]})]}),(0,B.jsx)(`div`,{className:`overflow-x-auto border-t border-line`,children:(0,B.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,B.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`ID`}),(0,B.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,B.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`State`}),(0,B.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,B.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`})]})}),(0,B.jsx)(`tbody`,{children:n?(0,B.jsx)(`tr`,{children:(0,B.jsxs)(`td`,{colSpan:5,className:`px-5 py-10 text-center text-sm text-danger`,children:[`Could not load recent jobs — `,n,`. Retry the page.`]})}):t.length===0?(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:5,className:`px-5 py-10 text-center text-sm text-faint`,children:`No recent jobs.`})}):t.map(e=>(0,B.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,B.jsx)(`td`,{className:`px-5 py-3`,children:(0,B.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.id})}),(0,B.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.name??`default`}),(0,B.jsx)(`td`,{className:`px-5 py-3 text-muted`,children:e.state??`—`}),(0,B.jsxs)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:[e.attempts??0,` / `,e.maxAttempts??`?`]}),(0,B.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:b(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)})]},e.id))})]})})]})}function H({counts:e}){let t=Object.entries(e??{}).map(([e,t])=>[Number(e),t]).filter(([,e])=>e>0).sort((e,t)=>t[0]-e[0]);if(t.length===0)return null;let n=Math.max(...t.map(([,e])=>e));return(0,B.jsxs)(C,{className:`mb-6`,children:[(0,B.jsx)(p,{title:`Jobs by priority`}),(0,B.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.map(([e,t])=>(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsxs)(`span`,{className:`w-16 shrink-0 text-right font-mono text-xs text-muted`,children:[`p`,e]}),(0,B.jsx)(`div`,{className:`h-4 flex-1 overflow-hidden rounded bg-surface-2`,children:(0,B.jsx)(`div`,{className:`h-full rounded bg-accent`,style:{width:`${Math.max(2,t/n*100)}%`}})}),(0,B.jsx)(`span`,{className:`w-14 shrink-0 tnum text-xs text-fg`,children:v(t)})]},e))}),(0,B.jsx)(`p`,{className:`mt-2 text-xs text-faint`,children:`Higher p = higher priority. Waiting jobs only.`})]})}function U({name:e,depth:t,trend:n,rate:r}){return(0,B.jsxs)(C,{className:`mb-6`,children:[(0,B.jsx)(p,{title:`Backlog depth`,action:(0,B.jsx)(`span`,{className:c(`rounded-full px-2 py-0.5 text-[11px] font-medium`,n.draining?`bg-emerald-500/10 text-success`:n.label===`accumulating`?`bg-red-500/10 text-danger`:`bg-surface-2 text-muted`),children:n.label})}),t.length<2?(0,B.jsx)(`p`,{className:`py-6 text-center text-xs text-faint`,children:`Sampling… the backlog trend appears after a few polls.`}):(0,B.jsx)(k,{height:140,ariaLabel:`${e} backlog depth`,series:[{label:`depth`,color:`var(--accent)`,points:t,area:!0}]}),(0,B.jsxs)(`div`,{className:`mt-1 flex items-center justify-between text-xs text-faint`,children:[(0,B.jsx)(`span`,{children:`waiting + prioritized + active + delayed + waiting-children`}),(0,B.jsxs)(`span`,{className:`tnum`,children:[`Error rate `,r==null?`—`:x(r)]})]})]})}function W(e,t){let n=`${O()}\u0000${e}`,[r,i]=(0,I.useState)(()=>({scope:n,values:[]})),a=(0,I.useRef)(null);(0,I.useEffect)(()=>{a.current=null,i({scope:n,values:[]});let e=setInterval(()=>{let e=a.current;e!=null&&i(t=>({scope:n,values:[...t.scope===n?t.values:[],e].slice(-40)}))},z);return()=>clearInterval(e)},[n]),(0,I.useEffect)(()=>{t&&(a.current=(t.waiting??0)+(t.prioritized??0)+(t.active??0)+(t.delayed??0)+(t[`waiting-children`]??0))},[t,n]);let o=r.scope===n?r.values:[];return{depth:o,trend:F(o,z)}}function G(){let{name:e=``}=t(),[n,i]=(0,I.useState)(!1),[c,p]=(0,I.useState)(null),b=T(`queue:${e}`);(0,I.useEffect)(()=>{i(!1),p(null)},[b.scopeKey]);let x=(0,I.useCallback)(async()=>{if(!e)return null;if(!(await d.queuesSummary()).some(t=>t.name===e))return{queue:e,exists:!1,detail:null,stall:null,dlq:null,jobs:[],recentJobsError:null};let[t,n,r,i]=await Promise.all([d.queueDetail(e,!1),d.getStallConfig(e).catch(()=>null),d.getDlqConfig(e).catch(()=>null),d.jobsList(e,R,12).then(e=>({jobs:e.jobs??[],error:null})).catch(e=>({jobs:[],error:e.message||`Unknown error`}))]);return{queue:e,exists:!0,detail:t,stall:n?.config??null,dlq:r?.config??null,jobs:i.jobs,recentJobsError:i.error}},[e]),{data:C,error:O,loading:k,refetch:F}=f(x,[e]),z=C?.queue===e?C:null,{depth:G,trend:K}=W(e,z?.detail?.counts),q=async(t,n,r,a)=>{if(r&&!window.confirm(r))return;let o=b.begin();if(o){i(!0),p(null);try{let r=await d.queuesSummary();if(!o.isCurrent())return;if(!r.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);let i=await n();if(E(i,t),!o.isCurrent())return;let s=i.count;if(s!==void 0&&(!Number.isSafeInteger(s)||s<0))throw Error(`${t} returned an invalid count`);let c=`${t}${s==null?` ✓`:`: ${s}`}`;p({ok:!0,text:c}),u.success(c,e),a?.(),F()}catch(e){if(!o.isCurrent())return;let n=e.message;p({ok:!1,text:n}),u.error(`${t} failed`,n)}finally{o.finish()&&i(!1)}}},J=z?.detail,Y=J?.counts,X=Y?y(Y.completed??0,Y.failed??0):null;return(0,B.jsxs)(`div`,{children:[(0,B.jsx)(g,{title:(0,B.jsx)(`span`,{className:`font-mono`,children:e}),description:`Full per-queue operations and complete live non-terminal depth.`,live:z?.exists===!0&&!!z.detail&&!!z.stall&&!!z.dlq&&!z.recentJobsError&&!O,back:(0,B.jsx)(r,{to:`/queues`,"aria-label":`Back to 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,B.jsx)(a,{className:`size-4`})}),actions:z?.exists===!0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(r,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:[`Jobs `,(0,B.jsx)(o,{className:`size-3.5`})]}),(0,B.jsxs)(r,{to:`/dlq?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:[`DLQ `,(0,B.jsx)(o,{className:`size-3.5`})]}),(0,B.jsx)(l,{variant:`danger`,size:`sm`,disabled:!0,title:D,children:`Obliterate`})]}):void 0}),O&&z&&(0,B.jsx)(h,{message:`Queue refresh failed — showing the last successful snapshot.`,onRetry:F}),O&&!z?(0,B.jsx)(S,{error:O,onRetry:F}):k&&!z?(0,B.jsx)(w,{label:`Loading ${e}…`}):z?.exists===!1||!J||!Y?!O&&(0,B.jsx)(m,{title:`Queue not found`,hint:`No queue named "${e}" exists — it may have been obliterated, or the link is stale.`,action:(0,B.jsx)(r,{to:`/queues`,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 queues`})}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,B.jsx)(s,{label:J.paused?`Paused`:`Active`,tone:J.paused?`amber`:`green`}),c&&(0,B.jsx)(`span`,{role:`status`,className:c.ok?`text-xs text-success`:`text-xs text-danger`,children:c.text}),(0,B.jsx)(`span`,{className:`text-xs text-warning`,children:D})]}),(0,B.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-8`,children:L.map(e=>(0,B.jsx)(_,{label:e,value:v(Y[e]),tone:e===`failed`&&Y.failed?`red`:`default`,compact:!0},e))}),(0,B.jsx)(V,{name:e,jobs:z.jobs,error:z.recentJobsError}),(0,B.jsx)(H,{counts:J.priorityCounts}),(0,B.jsx)(U,{name:e,depth:G,trend:K,rate:X}),(0,B.jsx)(M,{queue:e,paused:J.paused,busy:n,run:q}),(0,B.jsx)(P,{queue:e,busy:n,run:q},`${e}:limits`),(0,B.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[z.stall?(0,B.jsx)(j,{queue:e,config:z.stall,onSaved:()=>{p({ok:!0,text:`Stall config saved ✓`}),u.success(`Stall config saved`,e)}},`${e}:stall`):(0,B.jsx)(N,{title:`Stall detection`,onRetry:F}),z.dlq?(0,B.jsx)(A,{queue:e,config:z.dlq,onSaved:()=>{p({ok:!0,text:`DLQ config saved ✓`}),u.success(`DLQ config saved`,e)}},`${e}:dlq`):(0,B.jsx)(N,{title:`DLQ policy`,onRetry:F})]})]})]})}export{G as QueueDetailPro};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{h as t,r as n,t as r}from"./react-vendor-08inPAVO.js";import{S as i,T as a,n as o}from"./icons-BIT5aq1c.js";import{r as s}from"./StatusBadge-D-mexaga.js";import{t as c}from"./api-CCgfskjt.js";import{O as l,b as u,g as d,h as f,l as p,y as m}from"./index-X_fHGbXZ.js";import{t as h}from"./Pagination-WVfHLHDS.js";var g=e(t(),1),_=r(),v=20,y={ok:!1,queues:[],total:0,limit:v,offset:0,timestamp:0};function b(){let[e,t]=(0,g.useState)(``),[r,b]=(0,g.useState)(0),{data:x,error:S,loading:C,refetch:w}=l(()=>c.queues(v,r*v),[r]),{data:T}=l(()=>c.overview(),[]),E=x??y,D=(0,g.useMemo)(()=>{let t=E.queues,n=e.trim().toLowerCase();return n?t.filter(e=>e.name.toLowerCase().includes(n)):t},[E,e]);if(C&&!x&&!S)return(0,_.jsx)(m,{label:`Loading queues…`});let O=T?.stats;return(0,_.jsxs)(`div`,{children:[S&&(0,_.jsx)(u,{onRetry:w}),(0,_.jsx)(d,{title:`Queues`,description:x?`${E.total} queues`:`Queue inventory unavailable`,live:!!x&&!S}),(0,_.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,_.jsx)(f,{label:`Waiting`,value:O?p(O.waiting):`—`,tone:`amber`,compact:!0}),(0,_.jsx)(f,{label:`Active`,value:O?p(O.active):`—`,tone:`blue`,compact:!0}),(0,_.jsx)(f,{label:`Delayed`,value:O?p(O.delayed):`—`,tone:`default`,compact:!0}),(0,_.jsx)(f,{label:`DLQ`,value:O?p(O.dlq):`—`,tone:O?.dlq?`red`:`default`,compact:!0})]}),(0,_.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,_.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,_.jsx)(`input`,{"aria-label":`Filter queues`,name:`classic-queue-filter`,autoComplete:`off`,value:e,onChange:e=>t(e.target.value),placeholder:`Search queues…`,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,_.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,_.jsxs)(`table`,{className:`w-full min-w-[52rem] text-sm`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Delayed`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`DLQ`}),(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,_.jsx)(`th`,{className:`w-10 px-5 py-3`})]})}),(0,_.jsx)(`tbody`,{children:!x&&S?(0,_.jsx)(`tr`,{children:(0,_.jsxs)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-warning`,children:[`Could not load queues — `,S.message,`. Retry above.`]})}):D.length===0?(0,_.jsx)(`tr`,{children:(0,_.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:e?`No queues match on this page.`:`No queues yet.`})}):D.map(e=>(0,_.jsxs)(`tr`,{className:`group border-b border-line last:border-0 transition-colors hover:bg-surface-2/50`,children:[(0,_.jsx)(`td`,{className:`px-5 py-3`,children:(0,_.jsxs)(n,{to:`/queues-classic/${encodeURIComponent(e.name)}`,className:`flex items-center gap-2 rounded font-medium text-fg hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[(0,_.jsx)(i,{className:`size-4 text-faint`}),e.name]})}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(e.waiting)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:p(e.active)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(e.delayed)}),(0,_.jsx)(`td`,{className:s(`px-5 py-3 text-right tnum`,e.dlq?`text-red-400`:`text-muted`),children:p(e.dlq)}),(0,_.jsx)(`td`,{className:`px-5 py-3`,children:(0,_.jsxs)(`span`,{className:s(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-emerald-400`),children:[(0,_.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e.paused?`Paused`:`Active`]})}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-faint`,children:(0,_.jsx)(o,{className:`size-4 opacity-0 transition-opacity group-hover:opacity-100`})})]},e.name))})]})}),x&&(0,_.jsx)(h,{page:r,pageSize:v,total:E.total,onPageChange:b,label:`queues`})]})}export{b as Queues};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{h as t,r as n,t as r}from"./react-vendor-08inPAVO.js";import{S as i,T as a,b as o,n as s,x as c}from"./icons-BIT5aq1c.js";import{r as l}from"./StatusBadge-D-mexaga.js";import{C as u,F as d,I as f,O as p,b as m,g as h,h as g,l as _,v,w as y,y as b}from"./index-X_fHGbXZ.js";import{t as x}from"./Pagination-WVfHLHDS.js";import{r as S,t as C}from"./useServerActionGuard-uiZWD3dS.js";import{t as w}from"./promisePool-BVfQ9n9Q.js";var T=e(t(),1),E=r(),D=[[`waiting`,`Waiting`],[`prioritized`,`Prioritized`],[`active`,`Active`],[`completed`,`Completed`],[`failed`,`Failed`],[`delayed`,`Delayed`]];function O({rows:e,hasData:t,error:r,search:a,sortCol:u,sortDir:d,bulkBusy:f,busy:p,onSort:m,onToggle:h}){return(0,E.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,E.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,E.jsx)(`thead`,{children:(0,E.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,E.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),D.map(([e,t])=>(0,E.jsx)(`th`,{"aria-sort":u===e?d===`desc`?`descending`:`ascending`:void 0,className:`px-5 py-3 text-right font-medium`,children:(0,E.jsxs)(`button`,{type:`button`,onClick:()=>m(e),className:`inline-flex items-center gap-1 rounded uppercase tracking-wider hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[t,u===e&&(0,E.jsx)(`span`,{"aria-hidden":`true`,children:d===`desc`?`↓`:`↑`})]})},e)),(0,E.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,E.jsx)(`th`,{className:`w-24 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,E.jsx)(`tbody`,{children:!t&&r?(0,E.jsx)(`tr`,{children:(0,E.jsxs)(`td`,{colSpan:9,className:`px-5 py-12 text-center text-sm text-warning`,children:[`Could not load queues — `,r.message,`. Retry above.`]})}):e.length===0?(0,E.jsx)(`tr`,{children:(0,E.jsx)(`td`,{colSpan:9,className:`px-5 py-12 text-center text-sm text-faint`,children:a?`No queues match your search.`:`No queues yet.`})}):e.map(e=>{let t=f||p.has(e.name);return(0,E.jsxs)(`tr`,{className:`group border-b border-line last:border-0 transition-colors hover:bg-surface-2/50`,children:[(0,E.jsx)(`td`,{className:`px-5 py-3`,children:(0,E.jsxs)(n,{to:`/queues/${encodeURIComponent(e.name)}`,className:`flex items-center gap-2 rounded font-medium text-fg hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[(0,E.jsx)(i,{className:`size-4 text-faint`}),e.name]})}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:_(e.counts.waiting)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-orange-400`,children:_(e.counts.prioritized)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:_(e.counts.active)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:_(e.counts.completed)}),(0,E.jsx)(`td`,{className:l(`px-5 py-3 text-right tnum`,e.counts.failed?`text-danger`:`text-muted`),children:_(e.counts.failed)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:_(e.counts.delayed)}),(0,E.jsx)(`td`,{className:`px-5 py-3`,children:(0,E.jsxs)(`span`,{className:l(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:[(0,E.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e.paused?`Paused`:`Active`]})}),(0,E.jsx)(`td`,{className:`px-5 py-3`,children:(0,E.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,E.jsx)(y,{"aria-label":e.paused?`Resume queue`:`Pause queue`,disabled:t,onClick:t=>{t.stopPropagation(),h(e)},children:e.paused?(0,E.jsx)(c,{className:`size-3.5 text-success`}):(0,E.jsx)(o,{className:`size-3.5 text-warning`})}),(0,E.jsx)(s,{className:`size-4 text-faint opacity-0 transition-opacity group-hover:opacity-100`})]})})]},e.name)})})]})})}var k=6,A=15,j=[];function M(){let[e,t]=(0,T.useState)(``),[n,r]=(0,T.useState)(0),[i,s]=(0,T.useState)(new Set),[y,D]=(0,T.useState)(!1),[M,N]=(0,T.useState)(null),[P,F]=(0,T.useState)(null),[I,L]=(0,T.useState)(`desc`),R=S(`queues-overview`);(0,T.useEffect)(()=>{s(new Set),D(!1),N(null)},[R.scopeKey]);let{data:z,error:B,loading:V,refetch:H}=p(()=>f.queuesSummary(),[]),U=z??j,W=e=>{P===e?I===`desc`?L(`asc`):F(null):(F(e),L(`desc`)),r(0)},G=(0,T.useMemo)(()=>{let t=e.trim().toLowerCase(),n=[...t?U.filter(e=>e.name.toLowerCase().includes(t)):U].sort((e,t)=>e.name.localeCompare(t.name));if(P){let e=I===`desc`?-1:1;n.sort((t,n)=>e*(t.counts[P]-n.counts[P]))}return n},[U,e,P,I]),K=(0,T.useMemo)(()=>U.reduce((e,t)=>(e.waiting+=t.counts.waiting,e.prioritized+=t.counts.prioritized,e.active+=t.counts.active,e.failed+=t.counts.failed,e.paused+=+!!t.paused,e),{waiting:0,prioritized:0,active:0,failed:0,paused:0}),[U]),q=Math.max(1,Math.ceil(G.length/A)),J=Math.min(n,q-1),Y=G.slice(J*A,J*A+A),X=async e=>{let t=R.begin(`queue:${e.name}`);if(t){s(t=>new Set(t).add(e.name)),N(null);try{let n=await(e.paused?f.resume(e.name):f.pause(e.name));if(C(n,e.paused?`Resume queue`:`Pause queue`),!t.isCurrent())return;N({ok:!0,text:`${e.name} ${e.paused?`resumed`:`paused`} ✓`}),H()}catch(n){if(!t.isCurrent())return;N({ok:!1,text:n.message}),d.error(`Failed to ${e.paused?`resume`:`pause`} ${e.name}`,n.message)}finally{t.finish()&&s(t=>{let n=new Set(t);return n.delete(e.name),n})}}},Z=async e=>{let t=U.filter(t=>e===`pause`?!t.paused:t.paused);if(t.length===0){d.info(`No queues to ${e}`);return}if(!window.confirm(`${e===`pause`?`Pause`:`Resume`} ${t.length} queue(s)?`))return;let n=R.begin([`bulk`,...U.map(e=>`queue:${e.name}`)]);if(n){D(!0),N(null);try{let r=await w(t,k,async t=>{if(!n.isCurrent())throw Error(`Queue action target changed`);let r=e===`pause`?await f.pause(t.name):await f.resume(t.name);C(r,`${e===`pause`?`Pause`:`Resume`} ${t.name}`)});if(!n.isCurrent())return;let i=r.filter(e=>e.status===`rejected`).length,a=`${e===`pause`?`Paused`:`Resumed`} ${t.length-i}/${t.length} queues${i?`, ${i} failed`:``}`;N({ok:i===0,text:a}),i===0?d.success(a):d.error(a),H()}finally{n.finish()&&D(!1)}}};return V&&!z&&!B?(0,E.jsx)(b,{label:`Loading queues…`}):B&&!z?(0,E.jsxs)(`div`,{children:[(0,E.jsx)(h,{title:`Queues`,description:`Queue inventory unavailable`}),(0,E.jsx)(v,{error:B,onRetry:H})]}):(0,E.jsxs)(`div`,{children:[(0,E.jsx)(h,{title:`Queues`,description:z?`${U.length} queues`:`Queue inventory unavailable`,live:!!z&&!B,actions:U.length>0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(u,{variant:`warning`,size:`sm`,disabled:y||i.size>0||K.paused>=U.length,onClick:()=>Z(`pause`),children:[(0,E.jsx)(o,{className:`size-3.5`}),` Pause all`]}),(0,E.jsxs)(u,{variant:`success`,size:`sm`,disabled:y||i.size>0||K.paused===0,onClick:()=>Z(`resume`),children:[(0,E.jsx)(c,{className:`size-3.5`}),` Resume all`]})]}):void 0}),B&&(0,E.jsx)(m,{message:`Queue refresh failed — showing the last successful inventory.`,onRetry:H}),(0,E.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-5`,children:[(0,E.jsx)(g,{label:`Waiting`,value:_(K.waiting),tone:`amber`,compact:!0}),(0,E.jsx)(g,{label:`Prioritized`,value:_(K.prioritized),tone:`amber`,compact:!0}),(0,E.jsx)(g,{label:`Active`,value:_(K.active),tone:`blue`,compact:!0}),(0,E.jsx)(g,{label:`Failed`,value:_(K.failed),tone:K.failed?`red`:`default`,compact:!0}),(0,E.jsx)(g,{label:`Paused`,value:_(K.paused),tone:K.paused?`amber`:`default`,compact:!0})]}),(0,E.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,E.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,E.jsx)(`input`,{value:e,onChange:e=>{t(e.target.value),r(0)},placeholder:`Search queues…`,"aria-label":`Filter queues`,name:`queue-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`})]}),M&&(0,E.jsx)(`div`,{role:`status`,className:l(`mb-3 text-sm`,M.ok?`text-success`:`text-danger`),children:M.text}),(0,E.jsx)(O,{rows:Y,hasData:!!z,error:B,search:e,sortCol:P,sortDir:I,bulkBusy:y,busy:i,onSort:W,onToggle:e=>void X(e)}),(0,E.jsx)(x,{page:J,pageSize:A,total:G.length,onPageChange:r,label:`queues`})]})}export{M as QueuesOverview};
@@ -0,0 +1 @@
1
+ import{t as e}from"./react-vendor-08inPAVO.js";import{t}from"./api-CCgfskjt.js";import{O as n,S as r,b as i,g as a,v as o,x as s,y as c}from"./index-X_fHGbXZ.js";var l=e(),u=[[`S3_BACKUP_ENABLED`,`Set to 1 to enable periodic backups`],[`S3_BUCKET`,`Target bucket name`],[`S3_REGION`,`Bucket region (default us-east-1)`],[`S3_ENDPOINT`,`Custom endpoint (for S3-compatible stores)`],[`S3_ACCESS_KEY_ID`,`Access key`],[`S3_SECRET_ACCESS_KEY`,`Secret key`],[`S3_BACKUP_INTERVAL`,`Interval in ms (default 21600000 = 6h)`],[`S3_BACKUP_RETENTION`,`Backups to keep (default 7)`]];function d(){let{data:e,error:d,loading:f,refetch:p}=n(async()=>{let e=await t.storage();if(!e?.data||typeof e.data.diskFull!=`boolean`)throw Error(`Storage status response is missing disk health data`);return e},[]);return(0,l.jsxs)(`div`,{children:[d&&e&&(0,l.jsx)(i,{message:`Storage refresh failed — showing the last successful status.`,onRetry:p}),(0,l.jsx)(a,{title:`S3 Backup`,description:`SQLite snapshot backups to object storage.`,live:!!e?.data&&!d}),(0,l.jsx)(`div`,{className:`mb-6 rounded-lg border border-line bg-surface/60 px-4 py-3 text-sm text-muted`,children:`S3 backup runs on the server and is configured via environment variables — it cannot be toggled from the dashboard. The status below reflects the connected server's storage.`}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,l.jsxs)(s,{children:[(0,l.jsx)(r,{title:`Storage status`}),d&&!e?(0,l.jsx)(o,{error:d,onRetry:p}):f&&!e?(0,l.jsx)(c,{}):(0,l.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,l.jsx)(`dt`,{className:`text-muted`,children:`Disk`}),(0,l.jsx)(`dd`,{className:e?.data?e.data.diskFull?`font-medium text-red-400`:`font-medium text-emerald-400`:`font-medium text-muted`,children:e?.data?e.data.diskFull?`Full`:`Healthy`:`Unavailable`})]}),(0,l.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,l.jsx)(`dt`,{className:`text-muted`,children:`Error`}),(0,l.jsx)(`dd`,{className:`font-mono text-xs text-fg`,children:e?.data?.error?String(e.data.error):`—`})]})]})]}),(0,l.jsxs)(s,{children:[(0,l.jsx)(r,{title:`Configuration (server env)`}),(0,l.jsx)(`dl`,{className:`divide-y divide-line text-sm`,children:u.map(([e,t])=>(0,l.jsxs)(`div`,{className:`flex items-center justify-between gap-4 py-2.5`,children:[(0,l.jsx)(`dt`,{className:`font-mono text-xs text-accent/90`,children:e}),(0,l.jsx)(`dd`,{className:`text-right text-xs text-faint`,children:t})]},e))})]})]})]})}export{d as S3Backup};
@@ -0,0 +1,3 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{h as t,t as n}from"./react-vendor-08inPAVO.js";import{a as r,f as i,m as a,o,p as s}from"./connectionStore-B946Fhuv.js";import{w as c}from"./icons-BIT5aq1c.js";import{C as l,E as u,H as d,I as f,O as p,U as m,V as h,W as g,g as _,x as v}from"./index-X_fHGbXZ.js";import{a as y,n as b,r as x,t as S}from"./form-DBkslwzu.js";var C=e(t(),1),ee=`bq-dash-s3`,w=2,T=[`disabled`,`6h`,`12h`,`24h`],E={endpoint:``,region:`us-east-1`,bucket:``,schedule:`disabled`,pathPrefix:``,virtualHostedStyle:`auto`,retention:7};function D(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function O(e,t,n){return typeof e==`string`&&e.length<=n?e:t}function k(e){return T.includes(e)?e:`disabled`}function A(e){return e===`virtual-hosted`||e===`path-style`?e:`auto`}function j(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=1&&e<=1e6}function te(e){return j(e)?e:E.retention}function M(e){let t=D(e)?e:{};return{endpoint:O(t.endpoint,E.endpoint,2048),region:O(t.region,E.region,128),bucket:O(t.bucket,E.bucket,255),schedule:k(t.schedule),pathPrefix:O(t.pathPrefix,E.pathPrefix,1024),virtualHostedStyle:A(t.virtualHostedStyle),retention:te(t.retention)}}function ne(e){return M(e)}function N(){try{return globalThis.localStorage??null}catch{return null}}function P(e){try{let t=JSON.parse(e),n=D(t)?t:{},r=M(`state`in n?n.state:n),i=typeof n.version==`number`?n.version:void 0;return{hydration:JSON.stringify({state:r,...i===void 0?{}:{version:i}}),canonical:JSON.stringify({state:r,version:w})}}catch{return null}}var F={getItem(e){let t=N();if(!t)return null;let n;try{n=t.getItem(e)}catch{return null}if(n===null||e!==`bq-dash-s3`)return n;let r=P(n);if(!r){try{t.removeItem(e)}catch{}return null}if(n!==r.canonical)try{t.setItem(e,r.canonical)}catch{try{t.removeItem(e)}catch{}}return r.hydration},setItem(e,t){try{N()?.setItem(e,t)}catch{}},removeItem(e){try{N()?.removeItem(e)}catch{}}},I=a()(s(e=>({...E,accessKeyId:``,secretAccessKey:``,sessionToken:``,set:t=>e(e=>{let n={...e,...t};return{...M(n),accessKeyId:O(n.accessKeyId,``,512),secretAccessKey:O(n.secretAccessKey,``,2048),sessionToken:O(n.sessionToken,``,4096)}})}),{name:ee,version:w,storage:i(()=>F),partialize:ne,migrate:M,merge:(e,t)=>({...t,...M(e),accessKeyId:``,secretAccessKey:``,sessionToken:``})}));function L(){let e=Promise.resolve();return{async run(t,n){let r=e,i;e=new Promise(e=>{i=e}),await r;try{return n?.throwIfAborted(),await t()}finally{i()}}}}var R=new Set([`enabled`,`bucket`,`endpoint`,`interval`,`retention`]),re=new Set([`key`,`size`,`date`]);function ie(e){let t=z(e,R,`Backup status`);return typeof t.enabled!=`boolean`&&H(`Backup status`),{enabled:t.enabled,bucket:B(t.bucket,`Backup status bucket`,1024),endpoint:B(t.endpoint,`Backup status endpoint`,4096),interval:B(t.interval,`Backup status interval`,128),retention:B(t.retention,`Backup status retention`,128)}}function ae(e){(!Array.isArray(e)||e.length>2e4)&&H(`Backup list`);let t=new Set,n=0;return e.map((e,r)=>{let i=z(e,re,`Backup list item ${r}`),a=B(i.key,`Backup list item ${r} key`,2048),o=B(i.size,`Backup list item ${r} size`,128),s=B(i.date,`Backup list item ${r} date`,128);return n+=a.length+o.length+s.length,(n>2097152||t.has(a)||!V(s))&&H(`Backup list item ${r}`),t.add(a),{key:a,size:o,date:s}})}function z(e,t,n){(!e||typeof e!=`object`||Array.isArray(e))&&H(n);let r=e;return Object.keys(r).some(e=>!t.has(e))&&H(n),r}function B(e,t,n){return(typeof e!=`string`||e.length<1||e.length>n)&&H(t),e}function V(e){let t=Date.parse(e);return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(e)&&Number.isFinite(t)&&new Date(t).toISOString()===e}function H(e){throw Error(`${e} returned an invalid Bunqueue 2.9.3 contract`)}function U(e){return e.capture?.()??e}async function W(e,t,n){let r=await t.run(async()=>{let t=G(()=>e.restoreContext()),n=await G(()=>e.status().then(e=>ie(e.data)));return{context:t,list:await G(()=>e.list().then(e=>ae(e.data))),status:n}},n),{list:i,status:a}=r,o=await r.context,s=Array.from(new Set([a,i,o].filter(e=>e.status===`rejected`).map(e=>e.reason instanceof Error?e.reason.message:String(e.reason))));return{status:a.status===`fulfilled`?a.value:void 0,backups:i.status===`fulfilled`?i.value:[],context:o.status===`fulfilled`?o.value:void 0,errors:s}}async function G(e){try{return{status:`fulfilled`,value:await e()}}catch(e){return{status:`rejected`,reason:e}}}function K(e){let t={};for(let n of e.split(`
2
+ `)){let e=n.indexOf(`=`);if(e<1)throw Error(`Generated backup environment is malformed`);let r=n.slice(0,e),i=n.slice(e+1);if(!/^S3_[A-Z0-9_]+$/.test(r))throw Error(`Unexpected backup key: ${r}`);let a;try{a=JSON.parse(i)}catch{if(i===`true`||i===`false`||/^\d+$/.test(i))a=i;else throw Error(`Generated backup value for ${r} is malformed`)}t[r]=String(a)}return t}var q=e=>({method:`POST`,headers:e===void 0?void 0:{"Content-Type":`application/json`},body:e===void 0?void 0:JSON.stringify(e)});function J(e,t){let n=async(n,r)=>(await t(`${n}?target=${encodeURIComponent(e())}`,r)).result;return{status:()=>n(`/backup/status`),list:()=>n(`/backup/list`),backupNow:()=>n(`/backup/now`,q()),restore:(e,t)=>n(`/backup/restore`,q({key:e,database:t})),configure:e=>n(`/backup/configure`,q({environment:e})),restoreContext:async()=>{let e=await t(`/control/status`);return{serverStatus:e.status,database:e.db??null}}}}function oe(){let e=r(),t=g(),n={...h(t)};return J(()=>e,(e,r)=>m(t.baseUrl,e,n,r,!0,`agent`))}var se={...J(r,d),capture:oe},Y=n();function ce({environmentText:e,pollIntervalMs:t=15e3,repository:n=se}){let r=o(e=>JSON.stringify([e.activeProfileId,e.baseUrl,e.agentBaseUrl,e.token,e.agentToken])),i=(0,C.useRef)(!0),a=(0,C.useRef)(null);a.current&&a.current.connectionIdentity===r&&a.current.repository===n||(a.current={connectionIdentity:r,repository:n});let[s]=(0,C.useState)(L),c=p(e=>W(U(n),s,e),[n,s],{intervalMs:t}),[l,u]=(0,C.useState)(``),[d,f]=(0,C.useState)(``),[m,h]=(0,C.useState)(``),g=(0,C.useRef)(!1);(0,C.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]),(0,C.useEffect)(()=>{g.current=!1,u(``),f(``),h(``)},[r,n]);let _=async(e,t)=>{if(g.current)return;let r=a.current;g.current=!0,u(e),f(``),h(``);try{let o=U(n),l=await s.run(async()=>{if(!X(r,a,i))throw Error(`Backup operation scope changed before admission.`);return t(o)});if(!X(r,a,i))return;let u=l?.message;h(u??`${e} completed.`),await c.refetch()}catch(e){X(r,a,i)&&f(e instanceof Error?e.message:String(e))}finally{X(r,a,i)&&(g.current=!1,u(``))}},v=()=>{e&&window.confirm(`Apply this S3 configuration to the managed server? A restart is required.`)&&_(`Configuration`,t=>t.configure(K(e)))},y=()=>{window.confirm(`Create a transactionally consistent S3 backup now?`)&&_(`Backup`,e=>e.backupNow())},b=e=>{let t=c.data?.context?.database;t&&c.data?.context?.serverStatus===`stopped`&&window.prompt(`Type RESTORE to replace ${t.path} with ${e}`)===`RESTORE`&&_(`Restore`,n=>n.restore(e,t))},x=c.data;return(0,Y.jsxs)(`section`,{className:`mt-6 overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,Y.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Live backup operations`}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Official Bunqueue 2.9.3 backup CLI, executed by the local control agent.`})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,disabled:!e||!!l,onClick:v,className:`rounded-md border border-line px-3 py-2 text-xs text-muted disabled:opacity-40`,children:`Apply configuration`}),(0,Y.jsx)(`button`,{type:`button`,disabled:!!l,onClick:y,className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:l===`Backup`?`Backing up…`:`Backup now`}),(0,Y.jsx)(`button`,{type:`button`,disabled:!!l||c.loading,onClick:()=>void c.refetch(),className:`rounded-md border border-line px-3 py-2 text-xs text-muted disabled:opacity-40`,children:`Refresh`})]})]}),x?.status&&(0,Y.jsx)(le,{status:x.status,context:x.context}),d||x?.errors.length?(0,Y.jsx)(`div`,{role:`alert`,className:`border-b border-line px-4 py-3 text-xs text-danger`,children:d||x?.errors.join(` · `)}):null,m&&(0,Y.jsx)(`div`,{role:`status`,className:`border-b border-line px-4 py-3 text-xs text-success`,children:m}),(0,Y.jsx)(ue,{rows:x?.backups??[],canRestore:x?.context?.serverStatus===`stopped`&&!!x.context.database,busy:!!l,onRestore:b})]})}function le({status:e,context:t}){let n=[[`Scheduler`,e.enabled?`Enabled after restart`:`Disabled`],[`Bucket`,e.bucket||`—`],[`Endpoint`,e.endpoint],[`Retention`,e.retention],[`Server`,t?.serverStatus??`Unknown`]];return(0,Y.jsx)(`dl`,{className:`grid border-b border-line sm:grid-cols-2 xl:grid-cols-5`,children:n.map(([e,t])=>(0,Y.jsxs)(`div`,{className:`border-b border-line px-4 py-3 last:border-b-0 xl:border-r xl:border-b-0`,children:[(0,Y.jsx)(`dt`,{className:`text-[10px] uppercase tracking-wider text-faint`,children:e}),(0,Y.jsx)(`dd`,{className:`mt-1 truncate text-xs text-fg`,title:t,children:t})]},e))})}function ue({rows:e,canRestore:t,busy:n,onRestore:r}){return e.length?(0,Y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Y.jsxs)(`table`,{className:`w-full min-w-[680px] text-left text-xs`,children:[(0,Y.jsx)(`thead`,{className:`border-b border-line text-[10px] uppercase tracking-wider text-faint`,children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Object key`}),(0,Y.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Size`}),(0,Y.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Created`}),(0,Y.jsx)(`th`,{className:`px-4 py-2 text-right font-medium`,children:`Restore`})]})}),(0,Y.jsx)(`tbody`,{className:`divide-y divide-line`,children:e.map(e=>(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`max-w-md truncate px-4 py-3 font-mono text-fg`,title:e.key,children:e.key}),(0,Y.jsx)(`td`,{className:`px-4 py-3 text-muted`,children:e.size}),(0,Y.jsx)(`td`,{className:`px-4 py-3 text-muted`,children:e.date}),(0,Y.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,Y.jsx)(`button`,{type:`button`,disabled:!t||n,title:t?`Restore this backup`:`Stop the managed server before restore`,onClick:()=>r(e.key),className:`rounded-md border border-danger/40 px-2.5 py-1.5 text-danger disabled:opacity-35`,children:`Restore`})})]},e.key))})]})}):(0,Y.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-muted`,children:`No backup objects returned.`})}function X(e,t,n){return n.current&&e!==null&&t.current===e}function de(e){if(typeof e!=`object`||!e||Array.isArray(e)||typeof e.ok!=`boolean`)throw Error(`Malformed storage status response.`);let t=e.data;if(typeof t!=`object`||!t||Array.isArray(t)||typeof t.diskFull!=`boolean`)throw Error(`Storage status response is missing disk health data.`);return{diskFull:t.diskFull}}var Z=e=>JSON.stringify([e.activeProfileId,e.baseUrl,e.agentBaseUrl,e.token,e.agentToken]),fe={"6h":216e5,"12h":432e5,"24h":864e5};function Q(e,t){return`${e}=${typeof t==`string`?JSON.stringify(t):String(t)}`}function pe(e){let t=[],n=e.endpoint.trim(),r=e.region.trim(),i=e.bucket.trim(),a=e.accessKeyId.trim(),o=e.secretAccessKey.trim(),s=e.sessionToken.trim(),c=e.pathPrefix.trim();if(e.schedule===`disabled`)return{ok:!0,value:Q(`S3_BACKUP_ENABLED`,!1)};if((!r||r.length>128)&&t.push(`Region is required (maximum 128 characters).`),(!i||i.length>255)&&t.push(`Bucket is required (maximum 255 characters).`),(!a||a.length>512)&&t.push(`Access key ID is required (maximum 512 characters).`),(!o||o.length>2048)&&t.push(`Secret access key is required (maximum 2048 characters).`),s.length>4096&&t.push(`Session token is too long.`),(!Number.isSafeInteger(e.retention)||e.retention<1||e.retention>1e6)&&t.push(`Retention must be a whole number from 1 to 1000000.`),c.length>1024&&t.push(`Path prefix is too long.`),n)try{let e=new URL(n);(e.protocol!==`http:`&&e.protocol!==`https:`||e.username||e.password||n.length>2048)&&t.push(`Endpoint must be an http(s) URL without embedded credentials.`)}catch{t.push(`Endpoint must be a valid http(s) URL.`)}if(t.length)return{ok:!1,errors:t};let l=[Q(`S3_BACKUP_ENABLED`,!0),Q(`S3_ACCESS_KEY_ID`,a),Q(`S3_SECRET_ACCESS_KEY`,o),Q(`S3_BUCKET`,i),Q(`S3_REGION`,r),Q(`S3_BACKUP_RETENTION`,e.retention)];return s&&l.push(Q(`S3_SESSION_TOKEN`,s)),e.virtualHostedStyle!==`auto`&&l.push(Q(`S3_VIRTUAL_HOSTED_STYLE`,e.virtualHostedStyle===`virtual-hosted`)),n&&l.push(Q(`S3_ENDPOINT`,n)),c&&l.push(Q(`S3_BACKUP_PREFIX`,c)),l.push(Q(`S3_BACKUP_INTERVAL`,fe[e.schedule])),{ok:!0,value:l.join(`
3
+ `)}}function $(e){let t=e.trim();return t?Number(t):NaN}function me(e,t){let[n,r]=(0,C.useState)(()=>({text:String(e),base:e})),i=n.base===e?n.text:String(e);return{text:i,value:$(i),change(n){let i=$(n),a=j(i);a&&t(i),r({text:n,base:a?i:e})}}}function he({environment:e}){return(0,Y.jsxs)(v,{children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Server environment`}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Credentials stay in memory and are copied or applied only when you request it.`})]}),e.ok&&(0,Y.jsx)(u,{value:e.value})]}),e.ok?(0,Y.jsx)(`pre`,{className:`overflow-x-auto whitespace-pre-wrap break-all rounded-lg bg-surface-2 p-4 font-mono text-xs text-muted`,children:e.value.replace(/^S3_ACCESS_KEY_ID=.*$/m,`S3_ACCESS_KEY_ID="••••••••"`).replace(/^S3_SECRET_ACCESS_KEY=.*$/m,`S3_SECRET_ACCESS_KEY="••••••••"`).replace(/^S3_SESSION_TOKEN=.*$/m,`S3_SESSION_TOKEN="••••••••"`)}):(0,Y.jsx)(`ul`,{className:`space-y-1 text-sm text-danger`,"aria-label":`Configuration errors`,children:e.errors.map(e=>(0,Y.jsxs)(`li`,{children:[`• `,e]},e))})]})}function ge(){let e=I(),t=me(e.retention,t=>e.set({retention:t})),n=o(Z),[r,i]=(0,C.useState)(null),[a,s]=(0,C.useState)(null),u=(0,C.useRef)(0),d=pe({...e,retention:t.value}),p=r?.target===n?r:null,m=a===n;return(0,C.useEffect)(()=>(u.current++,i(null),s(null),()=>{u.current++}),[n]),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(_,{title:`S3 Backup Setup`,description:`Configure and operate Bunqueue 2.9.3 S3 backups.`}),(0,Y.jsxs)(`div`,{className:`mb-6 flex items-center justify-between rounded-xl border border-line bg-surface px-5 py-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg bg-surface-2 text-faint`,children:(0,Y.jsx)(c,{className:`size-5`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`font-semibold text-fg`,children:d.ok?`Configuration draft complete`:`Configuration draft incomplete`}),(0,Y.jsx)(`div`,{className:`text-xs text-faint`,children:d.ok?e.schedule===`disabled`?`Safe disable settings ready to apply`:`Target: ${e.bucket.trim()} · ready to apply`:`Complete the required fields to generate server settings`})]})]}),(0,Y.jsx)(`span`,{className:d.ok?`rounded-full bg-emerald-500/10 px-3 py-1 text-xs font-medium text-success`:`rounded-full bg-amber-500/10 px-3 py-1 text-xs font-medium text-warning`,children:d.ok?`Ready`:`Configure`})]}),(0,Y.jsx)(`div`,{className:`mb-6 rounded-lg border border-line bg-surface/60 px-4 py-2.5 text-xs text-faint`,children:`Apply the generated settings through the local control agent below, then restart Bunqueue. Status, object listing, manual backups, and guarded restores use the official Bunqueue CLI. Non-secret draft fields are stored locally; credentials remain in memory.`}),(0,Y.jsxs)(v,{className:`mb-6`,children:[(0,Y.jsx)(`h2`,{className:`mb-1 text-base font-semibold text-fg`,children:`Connection Settings`}),(0,Y.jsx)(`p`,{className:`mb-4 text-xs text-faint`,children:`Works with AWS S3, Cloudflare R2, MinIO, DigitalOcean Spaces, and any S3-compatible provider.`}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,Y.jsx)(S,{label:`Endpoint`,children:(0,Y.jsx)(b,{name:`s3-endpoint`,value:e.endpoint,onChange:t=>e.set({endpoint:t.target.value}),placeholder:`https://s3.amazonaws.com`,maxLength:2048,autoComplete:`off`,inputMode:`url`})}),(0,Y.jsx)(S,{label:`Region`,children:(0,Y.jsx)(b,{name:`s3-region`,value:e.region,onChange:t=>e.set({region:t.target.value}),placeholder:`us-east-1`,maxLength:128,autoComplete:`off`,spellCheck:!1})}),(0,Y.jsx)(`div`,{className:`md:col-span-2`,children:(0,Y.jsx)(S,{label:`Bucket name`,children:(0,Y.jsx)(b,{name:`s3-bucket`,value:e.bucket,onChange:t=>e.set({bucket:t.target.value}),placeholder:`my-bunqueue-backups`,maxLength:255,autoComplete:`off`,spellCheck:!1})})}),(0,Y.jsx)(S,{label:`Access key ID`,children:(0,Y.jsx)(b,{name:`s3-access-key-id`,value:e.accessKeyId,onChange:t=>e.set({accessKeyId:t.target.value}),placeholder:`AKIA…`,maxLength:512,autoComplete:`off`,spellCheck:!1})}),(0,Y.jsx)(S,{label:`Secret access key`,children:(0,Y.jsx)(b,{name:`s3-secret-access-key`,type:`password`,value:e.secretAccessKey,onChange:t=>e.set({secretAccessKey:t.target.value}),placeholder:`••••••••••••••••`,maxLength:2048,autoComplete:`off`,spellCheck:!1})}),(0,Y.jsx)(`div`,{className:`md:col-span-2`,children:(0,Y.jsx)(S,{label:`Session token (optional, for temporary STS credentials)`,children:(0,Y.jsx)(b,{name:`s3-session-token`,type:`password`,value:e.sessionToken,onChange:t=>e.set({sessionToken:t.target.value}),placeholder:`Temporary AWS session token`,maxLength:4096,autoComplete:`off`,spellCheck:!1})})}),(0,Y.jsx)(`p`,{className:`-mt-2 text-xs text-faint md:col-span-2`,children:`Keys are kept in memory only and cleared on reload.`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(x,{htmlFor:`s3-backup-schedule`,children:`Backup interval`}),(0,Y.jsxs)(y,{id:`s3-backup-schedule`,name:`s3-backup-schedule`,value:e.schedule,onChange:t=>e.set({schedule:t.target.value}),className:`mt-1.5`,title:`Written to S3_BACKUP_ENABLED and S3_BACKUP_INTERVAL in the generated config`,autoComplete:`off`,children:[(0,Y.jsx)(`option`,{value:`disabled`,children:`Disabled`}),(0,Y.jsx)(`option`,{value:`6h`,children:`Every 6 hours`}),(0,Y.jsx)(`option`,{value:`12h`,children:`Every 12 hours`}),(0,Y.jsx)(`option`,{value:`24h`,children:`Every 24 hours`})]})]}),(0,Y.jsx)(S,{label:`Path prefix (optional)`,children:(0,Y.jsx)(b,{name:`s3-path-prefix`,value:e.pathPrefix,onChange:t=>e.set({pathPrefix:t.target.value}),placeholder:`backups/production/`,maxLength:1024,autoComplete:`off`,spellCheck:!1})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(x,{htmlFor:`s3-addressing-style`,children:`Addressing style`}),(0,Y.jsxs)(y,{id:`s3-addressing-style`,name:`s3-addressing-style`,value:e.virtualHostedStyle,onChange:t=>e.set({virtualHostedStyle:t.target.value}),className:`mt-1.5`,children:[(0,Y.jsx)(`option`,{value:`auto`,children:`Provider default`}),(0,Y.jsx)(`option`,{value:`virtual-hosted`,children:`Virtual-hosted style`}),(0,Y.jsx)(`option`,{value:`path-style`,children:`Path style`})]})]}),(0,Y.jsx)(S,{label:`Backups to retain`,children:(0,Y.jsx)(b,{name:`s3-retention`,type:`number`,min:1,max:1e6,step:1,value:t.text,onChange:e=>t.change(e.target.value),inputMode:`numeric`})})]}),(0,Y.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(l,{onClick:async()=>{let e=n,t=++u.current;i(null),s(e);try{let n=await f.storage();if(t!==u.current||Z(o.getState())!==e)return;let r=de(n);i({target:e,ok:!r.diskFull,msg:r.diskFull?`Server disk is full`:`Server disk healthy — this does not validate the S3 credentials`})}catch(n){if(t!==u.current||Z(o.getState())!==e)return;i({target:e,ok:!1,msg:n.message})}finally{t===u.current&&s(null)}},children:m?`Checking server storage…`:`Check server storage`}),(0,Y.jsx)(`span`,{className:`text-xs text-faint`,children:`This checks SQLite disk health only, not S3 connectivity.`}),p&&(0,Y.jsx)(`span`,{role:`status`,className:p.ok?`text-xs text-success`:`text-xs text-danger`,children:p.msg})]})]}),(0,Y.jsx)(he,{environment:d}),(0,Y.jsx)(ce,{environmentText:d.ok?d.value:void 0})]})}export{ge as S3BackupPro};
@@ -0,0 +1,3 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{h as t,t as n}from"./react-vendor-08inPAVO.js";import{C as r,T as i,b as a,x as o}from"./icons-BIT5aq1c.js";import{r as s}from"./StatusBadge-D-mexaga.js";import{C as c,E as l,I as u,O as d,S as f,b as p,d as m,f as h,g,i as _,m as v,o as y,v as b,x,y as S}from"./index-X_fHGbXZ.js";import{i as C,n as w,t as T}from"./form-DBkslwzu.js";import{t as E}from"./package-Bb3FkjoS.js";import{t as D}from"./useControlActionGuard-Bx5MkufG.js";var O=e(t(),1),k=n();function A({children:e}){return(0,k.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs text-fg`,children:e})}function j({agentBase:e}){return(0,k.jsx)(x,{children:(0,k.jsxs)(`details`,{className:`group`,children:[(0,k.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2`,children:[(0,k.jsx)(`span`,{className:`text-base font-semibold text-fg`,children:`How server control works`}),(0,k.jsx)(`span`,{className:`text-xs text-muted transition-transform group-open:rotate-90`,children:`▶`})]}),(0,k.jsxs)(`div`,{className:`mt-4 space-y-4 text-sm leading-relaxed text-muted`,children:[(0,k.jsxs)(`p`,{children:[`A browser can't start or stop an OS process, so the dashboard talks to a small local`,` `,(0,k.jsx)(`span`,{className:`font-medium text-fg`,children:`control agent`}),` (`,(0,k.jsx)(A,{children:e}),`) that supervises the bunqueue server process — start, stop and restart — and streams its logs back here.`]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Launch & environment`}),(0,k.jsxs)(`p`,{children:[`The agent runs your `,(0,k.jsx)(`span`,{className:`text-fg`,children:`Command`}),` and injects`,` `,(0,k.jsx)(A,{children:`HTTP_PORT`}),` and `,(0,k.jsx)(A,{children:`TCP_PORT`}),`, plus `,(0,k.jsx)(A,{children:`BUNQUEUE_DATA_PATH`}),` `,`only for SQLite. Memory and PostgreSQL modes remove every SQLite path alias before launch. Any `,(0,k.jsx)(`span`,{className:`text-fg`,children:`Environment variables`}),` you add are included too. The default`,` `,(0,k.jsx)(A,{children:`bunx bunqueue@${E.dependencies.bunqueue} start`}),` resolves the verified release; pointing the command at a local entry (e.g.`,` `,(0,k.jsx)(A,{children:`bun run /path/to/bunqueue/src/main.ts`}),`) works without one.`]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`When changes apply`}),(0,k.jsxs)(`p`,{children:[`Config is editable any time, but `,(0,k.jsx)(`span`,{className:`text-fg`,children:`Command`}),`, ports and data path only take effect on the `,(0,k.jsx)(`span`,{className:`text-fg`,children:`next start/restart`}),` `,`— the running process keeps the config it launched with until then.`]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Data path`}),(0,k.jsxs)(`p`,{children:[`Relative paths resolve against the `,(0,k.jsx)(`span`,{className:`text-fg`,children:`agent's`}),` working directory. SQLite creates the database `,(0,k.jsx)(`span`,{className:`text-fg`,children:`file`}),` but not its parent `,(0,k.jsx)(`span`,{className:`text-fg`,children:`folder`}),` — if start fails with`,` `,(0,k.jsx)(A,{children:`SQLITE_CANTOPEN`}),`, create the directory first or use a path whose folder already exists.`]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Security`}),(0,k.jsxs)(`p`,{children:[`The direct agent listener binds `,(0,k.jsx)(A,{children:`127.0.0.1`}),`, locks CORS to an allowlist (never `,(0,k.jsx)(A,{children:`*`}),`), and rejects a disallowed `,(0,k.jsx)(A,{children:`Origin`}),` or`,` `,(0,k.jsx)(A,{children:`Host`}),` with `,(0,k.jsx)(A,{children:`403`}),`. The all-in-one server's `,(0,k.jsx)(A,{children:`/agent`}),` `,`bridge treats LAN and reverse-proxy access as remote: `,(0,k.jsx)(A,{children:`AGENT_TOKEN`}),` is then mandatory for status, logs, database reads and changes alike. Without it, the bridge stays disabled.`]}),(0,k.jsxs)(`p`,{children:[`If you started the agent with `,(0,k.jsx)(A,{children:`AGENT_TOKEN`}),`, enter that token under`,` `,(0,k.jsx)(`span`,{className:`text-fg`,children:`Settings → Agent token`}),` (or when the lock screen prompts). It stays in memory for this browser session; never bake it into a public`,` `,(0,k.jsx)(A,{children:`VITE_*`}),` value.`]})]})]})]})})}function M(e,t,n,r){return{baseline:z(e),id:r,revision:t,scope:n,value:z(e)}}function N(e,t,n,r,i){return{accepted:z(e),acceptedRevision:t,before:n?z(n):null,beforeRevision:r,ignoreThroughRequestId:i}}function P(e,t,n,r){return R(t,e.accepted)?!1:r!==void 0&&e.ignoreThroughRequestId!==void 0?r<=e.ignoreThroughRequestId:n===void 0?e.before!==null&&R(t,e.before):n===e.beforeRevision||n===e.acceptedRevision}function ee(e){if(!V(e))return H();let{command:t,httpPort:n,tcpPort:r,dataPath:i,extraEnv:a}=e;if(typeof t!=`string`||t.trim()===``||!B(n)||!B(r)||n===r||typeof i!=`string`||!V(a)||Object.values(a).some(e=>typeof e!=`string`))return H();let o=F(e.configRevision);return e.configRevision!==void 0&&o===void 0?H():{config:{command:t,httpPort:n,tcpPort:r,dataPath:i,extraEnv:Object.fromEntries(Object.entries(a))},revision:o}}function F(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0?e:void 0}function I(e){return B(e.httpPort)?B(e.tcpPort)?e.httpPort===e.tcpPort?`HTTP and TCP ports must differ`:null:`TCP port must be an integer between 1 and 65535`:`HTTP port must be an integer between 1 and 65535`}function L(e,t){if(!e)return[];let n=[];return e.command!==t.command&&n.push(`command`),e.httpPort!==t.httpPort&&n.push(`HTTP port`),e.tcpPort!==t.tcpPort&&n.push(`TCP port`),e.dataPath!==t.dataPath&&n.push(`data path`),U(e.extraEnv)!==U(t.extraEnv)&&n.push(`environment variables`),n}function R(e,t){return JSON.stringify(W(e))===JSON.stringify(W(t))}function z(e){return{...e,extraEnv:{...e.extraEnv}}}function B(e){return typeof e==`number`&&Number.isInteger(e)&&e>=1&&e<=65535}function V(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function H(){throw Error(`Configuration save returned a malformed response`)}function U(e){return JSON.stringify(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)))}function W(e){return{...e,extraEnv:Object.fromEntries(Object.entries(e.extraEnv).sort(([e],[t])=>e.localeCompare(t)))}}var G=0,K=e=>Object.entries(e).map(([e,t])=>({id:G++,key:e,value:t})),q=e=>{let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return t};function J(e){let t=e.map(e=>e.trim());return[...new Set(t.filter((e,t,n)=>e&&n.indexOf(e)!==t))]}var te=[`AUTH_TOKENS`,`LOG_LEVEL`,`BUNQUEUE_STORAGE_DRIVER`,`BUNQUEUE_POSTGRES_URL`,`BUNQUEUE_POSTGRES_NAMESPACE`,`BUNQUEUE_POSTGRES_POOL_SIZE`,`BUNQUEUE_MAX_COMPLETED_JOBS`,`BUNQUEUE_COMPLETED_RETENTION_MS`,`S3_BACKUP_ENABLED`,`S3_BUCKET`,`METRICS_ENABLED`];function ne({value:e,onChange:t,disabled:n}){let[r,i]=(0,O.useState)(()=>K(e)),a=e=>{i(e),t(q(e))},o=(e,t)=>a(r.map(n=>n.id===e?{...n,...t}:n)),s=(e=``)=>a([...r,{id:G++,key:e,value:``}]),l=e=>a(r.filter(t=>t.id!==e)),u=new Set(r.map(e=>e.key.trim()).filter(Boolean)),d=J(r.map(e=>e.key)),f=[...new Set(r.map(e=>e.key.trim()).filter(e=>e&&(/[\s=]/.test(e)||/[a-z]/.test(e))))];return(0,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.length===0&&(0,k.jsxs)(`p`,{className:`text-xs leading-relaxed text-faint`,children:[`No custom variables. The agent already injects`,` `,(0,k.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`HTTP_PORT`}),`,`,` `,(0,k.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`TCP_PORT`}),`, plus the SQLite data path unless PostgreSQL mode is selected.`]}),r.map(e=>(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`div`,{className:`w-2/5 shrink-0`,children:(0,k.jsx)(w,{id:`env-key-${e.id}`,name:`env-key-${e.id}`,"aria-label":`Variable name${e.key?` ${e.key}`:``}`,className:`font-mono`,placeholder:`KEY`,value:e.key,disabled:n,autoComplete:`off`,spellCheck:!1,onChange:t=>o(e.id,{key:t.target.value})})}),(0,k.jsx)(`span`,{className:`text-faint`,children:`=`}),(0,k.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,k.jsx)(w,{id:`env-value-${e.id}`,name:`env-value-${e.id}`,"aria-label":`Value for ${e.key||`variable`}`,className:`font-mono`,placeholder:`value`,value:e.value,disabled:n,autoComplete:`off`,spellCheck:!1,onChange:t=>o(e.id,{value:t.target.value})})}),(0,k.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.key||`variable`}`,disabled:n,onClick:()=>l(e.id),className:`shrink-0 rounded-md px-2 py-1 text-xs text-faint transition-colors hover:text-danger disabled:opacity-40`,children:`✕`})]},e.id)),d.length>0&&(0,k.jsxs)(`p`,{className:`text-xs text-warning`,children:[`Duplicate key`,d.length>1?`s`:``,` — the last value wins: `,d.join(`, `)]}),f.length>0&&(0,k.jsxs)(`p`,{className:`text-xs text-faint`,children:[`Unusual key`,f.length>1?`s`:``,` — env names are usually UPPER_SNAKE_CASE with no spaces or "=": `,f.join(`, `),`. Saved as-is.`]}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[(0,k.jsx)(c,{size:`sm`,variant:`ghost`,disabled:n,onClick:()=>s(),children:`+ Add variable`}),te.filter(e=>!u.has(e)).map(e=>(0,k.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>s(e),className:`rounded-md border border-line bg-surface-2 px-2 py-1 font-mono text-[11px] text-muted transition-colors hover:border-line-strong hover:text-fg disabled:opacity-40`,children:[`+ `,e]},e))]})]})}function re({status:e,onSaved:t,running:n,statusRequestId:i,getStatusRequestSequence:a,transitioning:o}){let s=D(`server-config`),l=(0,O.useRef)(0),d=(0,O.useRef)(null),p=(0,O.useRef)(null),[m,h]=(0,O.useState)(null),[g,_]=(0,O.useState)(!1),[v,y]=(0,O.useState)(!1),[b,S]=(0,O.useState)(null),[C,A]=(0,O.useState)(!1),[j,z]=(0,O.useState)(null);(0,O.useEffect)(()=>{d.current&&clearTimeout(d.current),d.current=null,p.current=null,h(null),_(!1),y(!1),S(null),A(!1),z(null)},[s.scopeKey]),(0,O.useEffect)(()=>{if(!e?.config||g)return;let t=p.current;t&&P(t,e.config,F(e.configRevision),i)||(p.current=null,h(M(e.config,F(e.configRevision),s.scopeKey,++l.current)),A(!1))},[s.scopeKey,g,e?.config,e?.configRevision,i]),(0,O.useEffect)(()=>()=>{d.current&&clearTimeout(d.current)},[]);let B=m?.scope===s.scopeKey?m:null,V=B?.value??e?.config??null;if(!V)return(0,k.jsx)(x,{children:`Loading…`});let H=t=>{let n=B??M(V,F(e?.configRevision),s.scopeKey,++l.current);h({...n,value:{...n.value,...t}}),_(!0),y(!1),A(!1)},U=L(e?.runningConfig??null,V),W=n&&U.length>0,G=o||b!==null,K=()=>{d.current&&clearTimeout(d.current),y(!0),d.current=setTimeout(()=>{d.current=null,y(!1)},2e3)},q=async n=>{let r=s.begin([`config`,`lifecycle`]);if(!r)return;let i=I(V);if(i)return r.finish(),z(i);let o=B?.baseline??e?.config,c=B?.revision??F(e?.configRevision);if(c===void 0&&o&&e?.config&&!R(o,e.config))return r.finish(),A(!0),z(`Configuration changed elsewhere; reload the latest values before saving.`);z(null),A(!1),S(n?`restart`:`save`);try{let i=await u.control.setConfig(V,c);if(!r.isCurrent())return;let{config:o,revision:d}=ee(i);if(p.current=N(o,d,e?.config??null,F(e?.configRevision),a?.()),h(M(o,d,s.scopeKey,++l.current)),_(!1),n&&await u.control.restart(),!r.isCurrent())return;K(),await t()}catch(e){if(!r.isCurrent())return;let t=e.message;t.startsWith(`Configuration changed since revision`)&&A(!0),z(t)}finally{r.finish()&&S(null)}},J=()=>q(!1);return(0,k.jsxs)(x,{children:[(0,k.jsx)(f,{title:`Configuration`}),(0,k.jsx)(`p`,{className:`mb-3 text-xs text-muted`,children:n?`Ports and data path apply on the next restart — edit freely, then restart.`:`Edit and save; the config is used the next time the server starts.`}),(0,k.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),J()},children:[(0,k.jsx)(T,{label:`Command`,hint:`The exact command the agent runs to launch bunqueue. It receives HTTP_PORT and TCP_PORT; BUNQUEUE_DATA_PATH is injected only for SQLite and removed in non-SQLite modes. The default resolves Bunqueue ${E.dependencies.bunqueue} with bunx; offline installs can point at a local entry.`,children:(0,k.jsx)(w,{name:`server-command`,autoComplete:`off`,spellCheck:!1,value:V.command,disabled:G,onChange:e=>H({command:e.target.value}),placeholder:`bunx bunqueue@${E.dependencies.bunqueue} start`})}),(0,k.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,k.jsx)(T,{label:`HTTP port`,hint:`Dashboard API + SSE.`,children:(0,k.jsx)(w,{name:`server-http-port`,autoComplete:`off`,type:`number`,min:1,max:65535,value:V.httpPort,disabled:G,onChange:e=>H({httpPort:Number(e.target.value)})})}),(0,k.jsx)(T,{label:`TCP port`,hint:`Binary protocol. Must differ from HTTP.`,children:(0,k.jsx)(w,{name:`server-tcp-port`,autoComplete:`off`,type:`number`,min:1,max:65535,value:V.tcpPort,disabled:G,onChange:e=>H({tcpPort:Number(e.target.value)})})})]}),(0,k.jsx)(T,{label:`Data path`,hint:`Durable SQLite path for the managed broker and Workflow Engine, relative to the agent's working directory. In PostgreSQL mode the agent keeps it for Workflow state but does not pass it to the broker.`,children:(0,k.jsx)(w,{name:`server-data-path`,autoComplete:`off`,spellCheck:!1,value:V.dataPath,disabled:G,onChange:e=>H({dataPath:e.target.value})})}),(0,k.jsx)(T,{label:`Environment variables`,hint:`Injected on start. Includes Bunqueue 2.9.3 completed-history controls: BUNQUEUE_MAX_COMPLETED_JOBS bounds hot memory, while BUNQUEUE_COMPLETED_RETENTION_MS opts into durable age-based expiry. Memory and PostgreSQL modes remove inherited SQLite path aliases. Applies on the next restart.`,children:(0,k.jsx)(ne,{value:V.extraEnv??{},onChange:e=>H({extraEnv:e}),disabled:G},B?.id??`initial`)}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,k.jsx)(c,{type:`submit`,variant:`accent`,size:`sm`,disabled:G,children:`Save config`}),n&&(0,k.jsxs)(c,{variant:`warning`,size:`sm`,disabled:G,onClick:()=>{let e=U.length>0?` Changed: ${U.join(`, `)}.`:``;if(window.confirm(`Save configuration and restart the server to apply it?${e}`))return q(!0)},children:[(0,k.jsx)(r,{className:`size-3.5`}),` Save & restart`]}),W&&!v&&(0,k.jsx)(`span`,{className:`text-xs text-warning`,children:`Restart to apply changes`}),v&&(0,k.jsx)(`span`,{className:`text-xs text-success`,children:`Saved`}),C&&(0,k.jsx)(c,{type:`button`,variant:`ghost`,size:`sm`,disabled:G,onClick:()=>{e?.config&&(p.current=null,h(M(e.config,F(e.configRevision),s.scopeKey,++l.current)),_(!1),A(!1),z(null))},children:`Reload latest`}),j&&(0,k.jsx)(`span`,{className:`text-xs text-danger`,children:j})]})]})]})}var ie=[`all`,`stdout`,`stderr`,`sys`],Y=e=>`${new Date(e).toLocaleTimeString([],{hour12:!1})}.${String(e%1e3).padStart(3,`0`)}`,ae=e=>e===`stderr`?`text-danger/90`:e===`sys`?`text-accent/80`:`text-muted`;function oe(e,t=Date.now()){let n=new Blob([e],{type:`text/plain`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`bunqueue-logs-${t}.log`;try{document.body.appendChild(i),i.click()}finally{i.remove(),setTimeout(()=>URL.revokeObjectURL(r),0)}}function se(){let{data:e,error:t,loading:n,refetch:r}=ce(),a=(0,O.useMemo)(()=>e?.lines??[],[e]),[o,c]=(0,O.useState)(`all`),[u,d]=(0,O.useState)(``),[f,m]=(0,O.useState)(!0),[h,g]=(0,O.useState)(!1),_=(0,O.useRef)(null),y=(0,O.useMemo)(()=>{let e=u.trim().toLowerCase();return a.map(e=>e.line.includes(`\x1B`)?{...e,line:v(e.line)}:e).filter(t=>(o===`all`||t.stream===o)&&(!e||t.line.toLowerCase().includes(e)))},[a,o,u]);(0,O.useEffect)(()=>{if(!f)return;let e=_.current;e&&(e.scrollTop=e.scrollHeight)},[y.length,f]);let w=(0,O.useMemo)(()=>y.map(e=>h?`${Y(e.ts)} [${e.stream}] ${e.line}`:e.line).join(`
2
+ `),[y,h]);return(0,k.jsxs)(x,{padded:!1,className:`overflow-hidden`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-line px-4 py-3`,children:[(0,k.jsx)(`h3`,{className:`mr-1 text-base font-semibold text-fg`,children:`Process logs`}),(0,k.jsx)(C,{options:ie,value:o,onChange:c}),(0,k.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,k.jsx)(i,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),(0,k.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),"aria-label":`Filter log lines`,name:`process-log-filter`,autoComplete:`off`,placeholder:`Filter…`,className:`h-8 w-full rounded-lg border border-line bg-surface-2 pl-8 pr-2 text-xs text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,k.jsx)(X,{on:f,onClick:()=>m(e=>!e),label:`Follow`}),(0,k.jsx)(X,{on:h,onClick:()=>g(e=>!e),label:`Times`}),(0,k.jsx)(l,{value:w}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>{oe(w)},disabled:y.length===0,className:`rounded-md border border-line bg-surface-2 px-2 py-1 text-xs text-muted transition-colors hover:text-fg disabled:opacity-40`,children:`Download`})]}),t&&e&&(0,k.jsx)(`div`,{className:`border-b border-line px-4 pt-3 font-sans`,children:(0,k.jsx)(p,{message:`Process-log refresh failed — showing the last received lines. ${t.message}`,onRetry:r})}),(0,k.jsx)(`div`,{ref:_,className:`max-h-80 min-h-40 overflow-y-auto p-4 font-mono text-xs leading-relaxed`,children:n&&!e&&!t?(0,k.jsx)(`div`,{className:`font-sans`,children:(0,k.jsx)(S,{label:`Loading process logs…`})}):t&&!e?(0,k.jsx)(`div`,{className:`font-sans`,children:(0,k.jsx)(b,{error:t,onRetry:r})}):y.length===0?(0,k.jsx)(`p`,{className:`text-faint`,children:a.length===0?`No output yet.`:`No lines match the current filter.`}):y.map(e=>(0,k.jsxs)(`div`,{className:s(`whitespace-pre-wrap`,ae(e.stream)),children:[h&&(0,k.jsx)(`span`,{className:`mr-2 text-faint`,children:Y(e.ts)}),e.line]},e.seq))}),(0,k.jsxs)(`div`,{className:`flex items-center justify-between border-t border-line px-4 py-2 text-[11px] text-faint`,children:[(0,k.jsx)(`span`,{children:t&&!e?`logs unavailable`:y.length===a.length?`${a.length} lines`:`${y.length} of ${a.length} lines`}),(0,k.jsx)(`span`,{children:t?`refresh failed`:f?`following tail`:`paused`})]})]})}function X({on:e,onClick:t,label:n}){return(0,k.jsx)(`button`,{type:`button`,onClick:t,"aria-pressed":e,className:s(`rounded-md border px-2 py-1 text-xs transition-colors`,e?`border-accent/40 bg-accent/10 text-accent`:`border-line bg-surface-2 text-muted hover:text-fg`),children:n})}function ce(){return d(()=>u.control.logs(),[])}var Z={running:{label:`Running`,tone:`text-success`,dot:`bg-emerald-400`},starting:{label:`Starting`,tone:`text-warning`,dot:`bg-amber-400`},stopping:{label:`Stopping`,tone:`text-warning`,dot:`bg-amber-400`},stopped:{label:`Stopped`,tone:`text-danger`,dot:`bg-red-400`}};function le({startedAt:e}){let[,t]=(0,O.useState)(0);return(0,O.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,k.jsx)(k.Fragment,{children:h((Date.now()-e)/1e3)})}function Q({label:e,children:t,title:n}){return(0,k.jsxs)(`div`,{className:`min-w-0`,title:n,children:[(0,k.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-faint`,children:e}),(0,k.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,children:t})]})}function ue({status:e,agentBase:t,transitioning:n,stale:i=!1,vitals:u=null,busy:d,onStart:f,onStop:p,onRestart:m}){let h=e?.status??`stopped`,g=e?.managementMode===`external`,_=g?e?.reachable===!0:h===`running`,v=g?e?.healthy?{label:`External`,tone:`text-success`,dot:`bg-emerald-400`}:e?.reachable?{label:`External`,tone:`text-warning`,dot:`bg-amber-400`}:{label:`External`,tone:`text-danger`,dot:`bg-red-400`}:Z[h]??Z.stopped,b=!!e?.healthy&&!i,x=!g&&!_&&e?.exitCode!=null&&e.exitCode!==0,S=e?.runningConfig??e?.config??null,C=S?.httpPort??6790,w=g?e?.externalUrl??`—`:`http://localhost:${C}`,T=w===`—`?`—`:`${w}/health`;return(0,k.jsxs)(`section`,{className:`mb-6 overflow-hidden rounded-xl border border-line bg-surface`,children:[(0,k.jsx)(`div`,{className:s(`h-0.5 bg-gradient-to-r to-transparent`,_&&b?`from-emerald-400/80 via-emerald-400/25`:_||n?`from-amber-400/80 via-amber-400/25`:`from-red-400/70 via-red-400/20`)}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-5 p-5 lg:flex-row lg:items-center lg:justify-between`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,k.jsxs)(`span`,{className:`relative flex size-3.5 shrink-0`,children:[_&&b&&(0,k.jsx)(`span`,{className:`absolute inline-flex size-full rounded-full bg-emerald-400 opacity-50 motion-safe:animate-ping`}),(0,k.jsx)(`span`,{className:s(`relative inline-flex size-3.5 rounded-full`,v.dot)})]}),(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,k.jsx)(`span`,{className:s(`text-2xl font-bold tracking-tight`,v.tone),children:n&&d?`${d}…`:v.label}),e?.version&&(0,k.jsxs)(`span`,{className:`font-mono text-xs text-muted`,children:[`bunqueue v`,e.version]}),x&&(0,k.jsxs)(`span`,{className:`rounded-full bg-red-500/15 px-2 py-0.5 font-mono text-[11px] font-medium text-danger`,children:[`crashed · exit `,e?.exitCode]})]}),(0,k.jsx)(`div`,{className:`mt-1 font-mono text-xs text-muted`,children:i?(0,k.jsxs)(`span`,{className:`text-warning`,children:[`last known: pid `,e?.pid??`—`,` — agent unreachable, state may have changed`]}):g?(0,k.jsx)(`span`,{title:e?.healthError,children:e?.reachable?b?`healthy via ${T}`:`reachable but unhealthy via ${T}`:`unreachable via ${T}`}):_?(0,k.jsxs)(k.Fragment,{children:[b?`healthy`:`waiting for health…`,` · pid `,e?.pid??`—`,` · up`,` `,e?.startedAt?(0,k.jsx)(le,{startedAt:e.startedAt}):`—`]}):`process not running — start it below or point the dashboard at an external server`})]})]}),!g&&(0,k.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,k.jsxs)(c,{variant:`success`,disabled:_||n||i,onClick:f,children:[(0,k.jsx)(o,{className:`size-4`}),` Start`]}),(0,k.jsxs)(c,{variant:`warning`,disabled:!_||n||i,onClick:p,children:[(0,k.jsx)(a,{className:`size-4`}),` Stop`]}),(0,k.jsxs)(c,{disabled:n||i,onClick:m,children:[(0,k.jsx)(r,{className:`size-4`}),` Restart`]})]})]}),(0,k.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 border-t border-line bg-surface-2/30 px-5 py-4 md:grid-cols-3 xl:grid-cols-7`,children:[(0,k.jsx)(Q,{label:`Memory`,children:u?.memory?.rss==null?(0,k.jsx)(`span`,{className:`text-faint`,children:`—`}):(0,k.jsxs)(`span`,{title:`heap ${u.memory.heapUsed??`?`} / ${u.memory.heapTotal??`?`} MB`,children:[u.memory.rss,` MB rss`]})}),(0,k.jsx)(Q,{label:`Connections`,children:u?.connections?`${u.connections.tcp??0} tcp · ${u.connections.ws??0} ws · ${u.connections.sse??0} sse`:(0,k.jsx)(`span`,{className:`text-faint`,children:`—`})}),(0,k.jsx)(Q,{label:g?`Health target`:`API endpoint`,title:T,children:w===`—`?(0,k.jsx)(`span`,{className:`text-faint`,children:w}):(0,k.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,k.jsx)(`a`,{href:T,target:`_blank`,rel:`noreferrer`,className:`truncate text-accent hover:underline`,children:w}),(0,k.jsx)(l,{value:w})]})}),(0,k.jsx)(Q,{label:g?`Lifecycle`:`Ports`,children:g?`external`:S?`${S.httpPort} http · ${S.tcpPort} tcp`:`—`}),(0,k.jsx)(Q,{label:g?`Health HTTP`:`Started`,children:g?e?.healthStatus??`—`:_&&e?.startedAt?y(e.startedAt):`—`}),(0,k.jsx)(Q,{label:`Control agent`,title:t,children:t.replace(/^https?:\/\//,``)}),(0,k.jsx)(Q,{label:g?`Supervisor`:`Storage`,title:e?.storageMode===`postgres`?`PostgreSQL ${e.postgresTarget??`configured`} · namespace ${e.postgresNamespace??`default`}`:e?.storageMode,children:g?`managed elsewhere`:e?.storageMode===`postgres`?`postgres · ${e.postgresNamespace??`default`}`:e?.storageMode??`—`})]})]})}var $=[{key:`size`,label:`Database`,color:`bg-accent`},{key:`walSize`,label:`WAL`,color:`bg-amber-400`},{key:`shmSize`,label:`SHM`,color:`bg-zinc-500`}];function de({db:e}){let t=e.totalSize||0;return(0,k.jsxs)(x,{children:[(0,k.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2`,children:[(0,k.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Storage`}),(0,k.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:e.exists?`${_(t)} on disk`:`not created yet`})]}),(0,k.jsxs)(`p`,{className:`mb-4 flex items-center gap-1.5 truncate font-mono text-xs text-faint`,title:e.path,children:[(0,k.jsx)(`span`,{className:`truncate`,children:e.path}),(0,k.jsx)(l,{value:e.path})]}),e.exists&&t>0?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`flex h-2.5 overflow-hidden rounded-full bg-surface-2`,children:$.map(n=>{let r=e[n.key];return r?(0,k.jsx)(`div`,{className:s(`h-full`,n.color),style:{width:`${r/t*100}%`},title:`${n.label}: ${_(r)}`},n.key):null})}),(0,k.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 font-mono text-[11px] text-faint`,children:[$.map(t=>(0,k.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,k.jsx)(`span`,{className:s(`size-2 rounded-full`,t.color)}),t.label,` `,(0,k.jsx)(`span`,{className:`text-fg`,children:_(e[t.key])})]},t.key)),e.mtimeMs?(0,k.jsxs)(`span`,{className:`ml-auto`,children:[`written `,m(e.mtimeMs)]}):null]})]}):(0,k.jsx)(`p`,{className:`rounded-lg border border-dashed border-line px-4 py-6 text-center text-sm text-faint`,children:`The database appears here after the first start — SQLite creates the file at the configured data path.`})]})}function fe(){let e=(0,O.useRef)(0),t=(0,O.useRef)(new WeakMap),{data:n,error:r,refetch:i}=d(async()=>{let n=++e.current,r=await u.control.status();return t.current.set(r,n),r},[]),a=D(`server-lifecycle`),[o,s]=(0,O.useState)(null),[c,l]=(0,O.useState)(null);(0,O.useEffect)(()=>{s(null),l(null)},[a.scopeKey]);let m=n?.managementMode===`external`,h=m?n?.reachable===!0:n?.status===`running`,{data:_}=d(()=>h?u.health():Promise.resolve(null),[h]),v=h?_??null:null,y=v?.connections?` This drops ${v.connections.tcp??0} TCP / ${v.connections.ws??0} WS connections; in-flight jobs are interrupted.`:` In-flight jobs are interrupted.`,b=async(e,t,n)=>{let r=a.begin(`lifecycle`);if(r){if(n&&!window.confirm(n))r.finish();else if(!r.isCurrent())r.finish();else{s(e),l(null);try{if(await t(),!r.isCurrent())return;await i()}catch(e){if(!r.isCurrent())return;l(e.message)}finally{r.finish()&&s(null)}}}};if(r&&!n)return(0,k.jsxs)(`div`,{children:[(0,k.jsx)(g,{title:`Server`,description:`Start, stop and restart the bunqueue server.`}),(0,k.jsx)(p,{message:`Control agent unreachable — server lifecycle controls are unavailable.`,onRetry:i}),(0,k.jsxs)(x,{children:[(0,k.jsx)(f,{title:`Control agent not running`}),(0,k.jsxs)(`p`,{className:`text-sm text-muted`,children:[`The local control agent is unreachable at`,` `,(0,k.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs`,children:u.agentBase}),`. It manages the bunqueue server process (start / stop / restart). Start it with:`]}),(0,k.jsxs)(`pre`,{className:`mt-3 overflow-x-auto rounded-lg border border-line bg-surface-2 px-3 py-2 text-xs`,children:[`bun start`,` `,`# agent + dashboard together (recommended)`,`
3
+ `,`bun run agent`,` `,`# agent only, if the dashboard is already running`]}),(0,k.jsx)(`p`,{className:`mt-3 text-xs text-faint`,children:`This page reconnects automatically once the agent is up — no reload needed.`})]})]});let S=n?.status??`stopped`,C=S===`running`,w=S===`starting`||S===`stopping`||o!=null,T=r!=null&&n!=null;return(0,k.jsxs)(`div`,{children:[(0,k.jsx)(g,{title:`Server`,description:m?`Observe the Bunqueue server managed by an external supervisor.`:`Supervise the bunqueue server process — lifecycle, configuration, storage and logs.`}),c&&(0,k.jsx)(`div`,{role:`status`,className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-danger`,children:c}),T&&(0,k.jsx)(`div`,{className:`mb-4 rounded-lg border border-amber-500/20 bg-amber-500/5 px-4 py-2 text-sm text-warning`,children:`Control agent unreachable — showing last known state. Lifecycle actions are disabled until it responds again.`}),(0,k.jsx)(ue,{status:n,agentBase:u.agentBase,stale:T,vitals:v,transitioning:w,busy:o,onStart:()=>b(`starting`,()=>u.control.start()),onStop:()=>b(`stopping`,()=>u.control.stop(),`Stop the bunqueue server?${y}`),onRestart:()=>b(`restarting`,()=>u.control.restart(),`Restart the bunqueue server?${y}`)}),m?(0,k.jsxs)(x,{children:[(0,k.jsx)(f,{title:`Managed externally`}),(0,k.jsxs)(`p`,{className:`text-sm text-muted`,children:[`This dashboard is attached to`,` `,(0,k.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs`,children:n?.externalUrl??`BUNQUEUE_URL`}),`. Start, stop, restart and launch configuration are intentionally unavailable while`,` `,(0,k.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs`,children:`BUNQUEUE_MANAGED=0`}),`. Use systemd, Docker, Kubernetes or the broker's external supervisor instead.`]})]}):(0,k.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,k.jsx)(re,{status:n,onSaved:i,running:C,statusRequestId:n?t.current.get(n):void 0,getStatusRequestSequence:()=>e.current,transitioning:w}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[n?.db&&(0,k.jsx)(de,{db:n.db}),(0,k.jsx)(se,{})]})]}),(0,k.jsx)(`div`,{className:`mt-6`,children:(0,k.jsx)(j,{agentBase:u.agentBase})})]})}export{fe as ServerControl};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{h as t,t as n}from"./react-vendor-08inPAVO.js";import{c as r,o as i,s as a}from"./connectionStore-B946Fhuv.js";import{f as o}from"./icons-BIT5aq1c.js";import{C as s,S as c,g as l,k as u,w as d,x as f}from"./index-X_fHGbXZ.js";import{a as p,n as m,t as h}from"./form-DBkslwzu.js";var g=n(),_=[[`1000`,`1 second`],[`2000`,`2 seconds`],[`3000`,`3 seconds`],[`5000`,`5 seconds`],[`10000`,`10 seconds`]];function v(){let{refreshMs:e,setRefreshMs:t}=i(),{theme:n,setTheme:r}=u();return(0,g.jsxs)(f,{children:[(0,g.jsx)(c,{title:`Appearance & refresh`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,g.jsx)(h,{label:`Theme`,children:(0,g.jsxs)(p,{name:`theme`,autoComplete:`off`,value:n,onChange:e=>r(e.target.value),children:[(0,g.jsx)(`option`,{value:`dark`,children:`Dark`}),(0,g.jsx)(`option`,{value:`light`,children:`Light`})]})}),(0,g.jsx)(h,{label:`Refresh interval`,children:(0,g.jsx)(p,{name:`refresh-interval`,autoComplete:`off`,value:String(e),onChange:e=>t(Number(e.target.value)),children:_.map(([e,t])=>(0,g.jsx)(`option`,{value:e,children:t},e))})})]})]})}var y=e(t(),1),b=1e4,x=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u;async function S(e,t={},n=b){let r=new AbortController,i=t.signal,a=i?AbortSignal.any([i,r.signal]):r.signal,o=Error(`Connection test timed out after ${Math.ceil(n/1e3)} seconds.`),s,c,l=new Promise((e,t)=>{s=setTimeout(()=>{r.abort(o),t(o)},n)}),u=i?new Promise((e,t)=>{let n=()=>{t(i.reason??new DOMException(`Connection test aborted`,`AbortError`))};i.aborted?n():(i.addEventListener(`abort`,n,{once:!0}),c=()=>i.removeEventListener(`abort`,n))}):null;try{let n=(async()=>{let n=await fetch(e,{...t,signal:a});return{response:n,value:await n.json()}})();return await Promise.race(u?[n,l,u]:[n,l])}catch(e){throw r.signal.aborted&&r.signal.reason===o?o:e}finally{s!==void 0&&clearTimeout(s),c?.()}}async function C(e,t={},n=b){let{response:r,value:i}=await S(e,t,n);if(!r.ok&&r.status!==503)throw Error(`HTTP ${r.status}`);if(typeof i!=`object`||!i||Array.isArray(i))throw Error(`Malformed health response`);let a=i;if(typeof a.ok!=`boolean`||a.status!==`healthy`&&a.status!==`degraded`||!Number.isSafeInteger(a.uptime)||a.uptime<0||typeof a.version!=`string`||!x.test(a.version)||a.ok!==(a.status===`healthy`))throw Error(`Malformed health response`);return{response:r,health:a}}function w(){let e=i(),[t,n]=(0,y.useState)(``),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(``),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(null),[x,w]=(0,y.useState)(null),[T,E]=(0,y.useState)(null),D=(0,y.useRef)(!0),O=(0,y.useRef)(0),k=(0,y.useRef)(null),A=(0,y.useRef)(null),j=(0,y.useCallback)(()=>{A.current!==null&&clearTimeout(A.current),A.current=null,D.current&&E(null)},[]),M=(0,y.useCallback)(()=>{O.current+=1,k.current?.abort(new DOMException(`Connection test superseded`,`AbortError`)),k.current=null,D.current&&(h(null),_(null))},[]),N=(0,y.useCallback)(()=>{M(),j()},[j,M]);(0,y.useEffect)(()=>(D.current=!0,()=>{D.current=!1,O.current+=1,k.current?.abort(new DOMException(`Settings unmounted`,`AbortError`)),A.current!==null&&clearTimeout(A.current)}),[]),(0,y.useEffect)(()=>{let t=e.profiles.find(t=>t.id===e.activeProfileId);n(t?.name??`Bunqueue`),s(e.baseUrl),l(e.agentBaseUrl),d(e.token),p(e.agentToken),b(null),w(null),M()},[e.activeProfileId,e.agentBaseUrl,e.baseUrl,e.profiles,e.token,e.agentToken,M]);let P=()=>{let e=i.getState();return JSON.stringify([e.activeProfileId,e.baseUrl,e.agentBaseUrl,e.token,e.agentToken])},F=async e=>{M();let t=r(e===`server`?o:c);if(!t){e===`server`?b(a):w(a),_({ok:!1,msg:a});return}e===`server`?b(null):w(null);let n=O.current,i=new AbortController,s=P(),l=()=>D.current&&n===O.current&&!i.signal.aborted&&P()===s;k.current=i,h(e),_(null);let d=performance.now();try{if(e===`server`){let{response:e,health:n}=await C(`${t}/health`,{headers:u.trim()?{Authorization:`Bearer ${u.trim()}`}:void 0,signal:i.signal});if(!l())return;let r=e.status===503||n.status===`degraded`;_({ok:!r,msg:`${r?`Server reachable`:`Connected`} in ${Math.round(performance.now()-d)}ms · bunqueue v${n.version}${r?` · degraded`:``}`})}else{let{response:e,value:n}=await S(`${t}/control/status`,{headers:f.trim()?{Authorization:`Bearer ${f.trim()}`}:void 0,signal:i.signal});if(!e.ok)throw Error(`HTTP ${e.status}`);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Malformed control agent response`);let r=n;if(![`running`,`stopped`,`starting`,`stopping`].includes(String(r.status)))throw Error(`Malformed control agent response`);if(!l())return;_({ok:!0,msg:`Agent connected in ${Math.round(performance.now()-d)}ms · server ${r.status}${r.storageMode?` · ${r.storageMode}`:``}`})}}catch(e){l()&&_({ok:!1,msg:e.message})}finally{D.current&&n===O.current&&(k.current=null,h(null))}},I=()=>{M();let n=r(o),i=r(c);if(b(n?null:a),w(i?null:a),!n||!i)return;let s=e.saveConnection({name:t,baseUrl:n,agentBaseUrl:i,token:u,agentToken:f});j(),E({ok:s.persisted,msg:s.persisted?`Saved ✓`:`Saved for this session only — browser storage unavailable${s.error?`: ${s.error}`:`.`}`}),A.current=setTimeout(()=>D.current&&E(null),4e3)},L=()=>{N(),e.addProfile({name:`Bunqueue ${e.profiles.length+1}`,baseUrl:`http://localhost:6790`,agentBaseUrl:`http://localhost:6800`,token:``,agentToken:``})},R=()=>{let t=e.profiles.find(t=>t.id===e.activeProfileId);t&&window.confirm(`Remove connection profile "${t.name}"?`)&&e.removeProfile(t.id)};return{...e,name:t,setName:n,url:o,setUrl:s,agentUrl:c,setAgentUrl:l,tok:u,setTok:d,agentTok:f,setAgentTok:p,testing:m,result:g,urlError:v,agentUrlError:x,saveNotice:T,edit:N,save:I,add:L,remove:R,testServer:()=>F(`server`),testAgent:()=>F(`agent`)}}function T({id:e,label:t,hint:n,value:r,placeholder:i,onChange:a}){let[s,c]=(0,y.useState)(!1);return(0,g.jsx)(h,{label:t,hint:n,htmlFor:e,children:(0,g.jsxs)(`div`,{className:`relative`,children:[(0,g.jsx)(m,{id:e,name:e,type:s?`text`:`password`,value:r,onChange:e=>a(e.target.value),placeholder:i,className:`pr-10`,autoComplete:`off`,spellCheck:!1}),(0,g.jsx)(d,{"aria-label":s?`Hide ${t.toLowerCase()}`:`Show ${t.toLowerCase()}`,className:`absolute right-0.5 top-1/2 -translate-y-1/2`,onClick:()=>c(e=>!e),children:(0,g.jsx)(o,{className:`size-4`})})]})})}function E(){let e=w(),t=t=>n=>{e.edit(),t(n)};return(0,g.jsxs)(f,{children:[(0,g.jsx)(c,{title:`Bunqueue fleet connections`}),(0,g.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,g.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[1fr_auto_auto]`,children:[(0,g.jsx)(h,{label:`Active node`,children:(0,g.jsx)(p,{"aria-label":`Active Bunqueue node`,value:e.activeProfileId,onChange:t=>e.activateProfile(t.target.value),children:e.profiles.map(e=>(0,g.jsx)(`option`,{value:e.id,children:e.name},e.id))})}),(0,g.jsx)(s,{className:`self-end`,onClick:e.add,children:`Add node`}),(0,g.jsx)(s,{className:`self-end`,variant:`danger`,disabled:e.profiles.length===1,onClick:e.remove,children:`Remove`})]}),(0,g.jsx)(h,{label:`Node name`,children:(0,g.jsx)(m,{name:`profile-name`,value:e.name,onChange:n=>t(e.setName)(n.target.value),maxLength:64,autoComplete:`off`,placeholder:`broker-eu-1`})}),(0,g.jsx)(h,{label:`Server URL`,children:(0,g.jsx)(m,{name:`server-url`,value:e.url,onChange:n=>{t(e.setUrl)(n.target.value)},placeholder:`/api or https://queue.example.com`,autoComplete:`off`,inputMode:`url`,"aria-invalid":e.urlError?!0:void 0,"aria-describedby":e.urlError?`server-url-error`:`server-url-help`})}),e.urlError?(0,g.jsx)(`p`,{id:`server-url-error`,className:`-mt-2 text-xs text-danger`,children:e.urlError}):(0,g.jsx)(`p`,{id:`server-url-help`,className:`-mt-2 text-xs text-faint`,children:`Bunqueue HTTP API for this broker. All queue pages use the selected node.`}),(0,g.jsx)(h,{label:`Control agent URL`,children:(0,g.jsx)(m,{name:`agent-url`,value:e.agentUrl,onChange:n=>t(e.setAgentUrl)(n.target.value),placeholder:`/agent or https://broker.example.com/agent`,autoComplete:`off`,inputMode:`url`,"aria-invalid":e.agentUrlError?!0:void 0,"aria-describedby":e.agentUrlError?`agent-url-error`:`agent-url-help`})}),e.agentUrlError?(0,g.jsx)(`p`,{id:`agent-url-error`,className:`-mt-2 text-xs text-danger`,children:e.agentUrlError}):(0,g.jsx)(`p`,{id:`agent-url-help`,className:`-mt-2 text-xs text-faint`,children:`One paired agent per broker enables lifecycle, configuration, Flow, Workflow and advanced queue controls.`}),(0,g.jsx)(T,{id:`bearer-token`,label:`Bearer token (optional)`,hint:`Server credential, kept in memory only and isolated to this node.`,value:e.tok,onChange:t(e.setTok),placeholder:`only if AUTH_TOKENS is set`}),(0,g.jsx)(T,{id:`agent-token`,label:`Agent token (optional)`,hint:`AGENT_TOKEN for this node, kept in memory only.`,value:e.agentTok,onChange:t(e.setAgentTok),placeholder:`only if AGENT_TOKEN is set`}),(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,g.jsx)(s,{variant:`accent`,onClick:e.save,children:`Save`}),(0,g.jsx)(s,{onClick:e.testServer,children:e.testing===`server`?`Restart test`:`Test connection`}),(0,g.jsx)(s,{onClick:e.testAgent,children:e.testing===`agent`?`Restart agent test`:`Test agent`}),e.saveNotice&&(0,g.jsx)(`span`,{role:`status`,className:e.saveNotice.ok?`text-sm text-success`:`text-sm text-warning`,children:e.saveNotice.msg}),e.result&&(0,g.jsx)(`span`,{role:`status`,className:e.result.ok?`text-sm text-success`:`text-sm text-danger`,children:e.result.msg})]}),(0,g.jsx)(`p`,{className:`-mt-1 text-xs text-faint`,children:`Switching the active node retargets every Dashboard feature atomically. Profile metadata persists; both credentials are erased on reload.`})]})]})}function D(){return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(l,{title:`Settings`,description:`Bunqueue fleet connections, credentials and appearance.`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,g.jsx)(E,{}),(0,g.jsx)(v,{})]})]})}export{D as Settings};
@@ -1 +1 @@
1
- import{t as e}from"./react-vendor-CFL9l8LK.js";function t(...e){return e.filter(Boolean).join(` `)}var n=e(),r={completed:`text-success bg-emerald-500/10`,active:`text-blue-400 light:text-blue-700 bg-blue-500/10`,failed:`text-danger bg-red-500/10`,waiting:`text-zinc-400 light:text-zinc-600 bg-zinc-500/10`,prioritized:`text-violet-400 light:text-violet-700 bg-violet-500/10`,delayed:`text-warning bg-amber-500/10`,paused:`text-orange-400 light:text-orange-700 bg-orange-500/10`,"waiting-children":`text-cyan-400 light:text-cyan-700 bg-cyan-500/10`,stalled:`text-orange-400 light:text-orange-700 bg-orange-500/10`,running:`text-blue-400 light:text-blue-700 bg-blue-500/10`,compensating:`text-violet-400 light:text-violet-700 bg-violet-500/10`,"compensation-stuck":`text-danger bg-red-500/10`,compensated:`text-success bg-emerald-500/10`,"compensation-failed":`text-danger bg-red-500/10`,"compensation-skipped":`text-warning bg-amber-500/10`,enqueued:`text-zinc-400 light:text-zinc-600 bg-zinc-500/10`,started:`text-blue-400 light:text-blue-700 bg-blue-500/10`,finished:`text-success bg-emerald-500/10`,retry:`text-warning bg-amber-500/10`,cancelled:`text-zinc-400 light:text-zinc-600 bg-zinc-500/10`,default:`text-zinc-400 light:text-zinc-600 bg-zinc-500/10`};function i({status:e}){let i=(e||``).toLowerCase();return(0,n.jsxs)(`span`,{className:t(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium capitalize`,r[i]??r.default),children:[(0,n.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e||`unknown`]})}function a({label:e,tone:r=`green`}){return(0,n.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium text-muted`,children:[(0,n.jsx)(`span`,{className:t(`size-1.5 rounded-full`,r===`green`?`bg-emerald-400`:r===`amber`?`bg-amber-400`:r===`red`?`bg-red-400`:`bg-zinc-400`)}),e]})}export{a as n,t as r,i as t};
1
+ import{t as e}from"./react-vendor-08inPAVO.js";function t(...e){return e.filter(Boolean).join(` `)}var n=e(),r={completed:`text-success bg-emerald-500/10`,active:`text-blue-400 light:text-blue-700 bg-blue-500/10`,failed:`text-danger bg-red-500/10`,waiting:`text-zinc-400 light:text-zinc-600 bg-zinc-500/10`,prioritized:`text-violet-400 light:text-violet-700 bg-violet-500/10`,delayed:`text-warning bg-amber-500/10`,paused:`text-orange-400 light:text-orange-700 bg-orange-500/10`,"waiting-children":`text-cyan-400 light:text-cyan-700 bg-cyan-500/10`,stalled:`text-orange-400 light:text-orange-700 bg-orange-500/10`,running:`text-blue-400 light:text-blue-700 bg-blue-500/10`,compensating:`text-violet-400 light:text-violet-700 bg-violet-500/10`,"compensation-stuck":`text-danger bg-red-500/10`,compensated:`text-success bg-emerald-500/10`,"compensation-failed":`text-danger bg-red-500/10`,"compensation-skipped":`text-warning bg-amber-500/10`,enqueued:`text-zinc-400 light:text-zinc-600 bg-zinc-500/10`,started:`text-blue-400 light:text-blue-700 bg-blue-500/10`,finished:`text-success bg-emerald-500/10`,retry:`text-warning bg-amber-500/10`,cancelled:`text-zinc-400 light:text-zinc-600 bg-zinc-500/10`,default:`text-zinc-400 light:text-zinc-600 bg-zinc-500/10`};function i({status:e}){let i=r[(e||``).toLowerCase()]??r.default;return(0,n.jsxs)(`span`,{className:t(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium capitalize`,i),children:[(0,n.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e||`unknown`]})}function a({label:e,tone:r=`green`}){return(0,n.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium text-muted`,children:[(0,n.jsx)(`span`,{className:t(`size-1.5 rounded-full`,r===`green`?`bg-emerald-400`:r===`amber`?`bg-amber-400`:r===`red`?`bg-red-400`:`bg-zinc-400`)}),e]})}export{a as n,t as r,i as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./react-vendor-08inPAVO.js";import{t}from"./api-CCgfskjt.js";import{O as n,S as r,b as i,d as a,f as o,g as s,h as c,i as l,l as u,v as d,x as f,y as p}from"./index-X_fHGbXZ.js";var m=e(),h={stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},memory:{heapUsed:0,heapTotal:0,rss:0},workers:{total:0,active:0},crons:{total:0},storage:{}};function g(){let{data:e,error:g,loading:v,refetch:y}=n(()=>t.overview(),[]);if(v&&!e&&!g)return(0,m.jsx)(p,{label:`Loading usage…`});if(g&&!e)return(0,m.jsxs)(`div`,{children:[(0,m.jsx)(s,{title:`Usage`,description:`Cumulative resource usage is unavailable.`}),(0,m.jsx)(d,{error:g,onRetry:y})]});let{stats:b,memory:x,workers:S,crons:C,storage:w}=e??h,T=typeof w.diskFull==`boolean`;return(0,m.jsxs)(`div`,{children:[(0,m.jsx)(s,{title:`Usage`,description:`Cumulative resource usage on the connected server.`,live:!!e&&!g&&T}),g&&(0,m.jsx)(i,{message:`Usage refresh failed — showing the last successful snapshot.`,onRetry:y}),(0,m.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,m.jsx)(c,{label:`Jobs Pushed`,value:u(b.totalPushed)}),(0,m.jsx)(c,{label:`Jobs Completed`,value:u(b.totalCompleted),tone:`green`}),(0,m.jsx)(c,{label:`Jobs Failed`,value:u(b.totalFailed),tone:b.totalFailed?`red`:`default`}),(0,m.jsx)(c,{label:`Jobs Pulled`,value:u(b.totalPulled),tone:`blue`})]}),(0,m.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,m.jsxs)(f,{children:[(0,m.jsx)(r,{title:`Runtime`}),(0,m.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,m.jsx)(_,{label:`Uptime`,value:o(b.uptime/1e3)}),(0,m.jsx)(_,{label:`Heap used`,value:l(x.heapUsed*1024*1024)}),(0,m.jsx)(_,{label:`RSS`,value:l(x.rss*1024*1024)}),(0,m.jsx)(_,{label:`Workers`,value:`${S.active} active / ${S.total}`}),(0,m.jsx)(_,{label:`Cron jobs`,value:String(C.total)})]})]}),(0,m.jsxs)(f,{children:[(0,m.jsx)(r,{title:`Storage`}),(0,m.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,m.jsx)(_,{label:`Status`,value:T?w.diskFull?`Disk full`:`Healthy`:`Unavailable`}),(0,m.jsx)(_,{label:`Disk full since`,value:w.diskFull?a(w.since):`—`}),w.error?(0,m.jsx)(_,{label:`Error`,value:String(w.error)}):null]})]})]})]})}function _({label:e,value:t,mono:n}){return(0,m.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,m.jsx)(`dt`,{className:`text-muted`,children:e}),(0,m.jsx)(`dd`,{className:n?`font-mono text-xs text-fg`:`font-medium text-fg`,children:t})]})}export{g as Usage};
@@ -0,0 +1 @@
1
+ import{t as e}from"./react-vendor-08inPAVO.js";import{I as t,O as n,S as r,b as i,d as a,f as o,g as s,h as c,i as l,l as u,n as d,r as f,u as p,v as m,x as h,y as g}from"./index-X_fHGbXZ.js";var _=e(),v={overview:{stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},memory:{heapUsed:0,heapTotal:0,rss:0},crons:{total:0}},storage:{},failedTotal:0};function y(){let{data:e,error:y,loading:x,refetch:S}=n(async()=>{let[e,n,r]=await Promise.all([t.overview(),t.storage(),t.queuesSummary()]);if(!n?.data||typeof n.data.diskFull!=`boolean`)throw Error(`Storage status response is missing disk health data`);if(d(e),!Number.isFinite(e.memory.heapUsed))throw Error(`Malformed /dashboard response: memory.heapUsed is missing or non-numeric.`);let i=r.reduce((e,t)=>e+(t.counts?.failed??0),0);return{overview:e,storage:n.data,failedTotal:i}},[]);if(x&&!e&&!y)return(0,_.jsx)(g,{label:`Loading usage…`});if(y&&!e)return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(s,{title:`Usage`,description:`Cumulative resource usage is unavailable.`}),(0,_.jsx)(m,{error:y,onRetry:S})]});let C=e??v,{stats:w,memory:T,crons:E}=C.overview,{storage:D,failedTotal:O}=C,k=f(w.completed,O),A=w.uptime?o(w.uptime/1e3):`—`;return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(s,{title:`Usage`,description:`Cumulative resource usage on the connected server.`,live:!!e&&!y}),y&&(0,_.jsx)(i,{message:`Usage refresh failed — showing the last successful snapshot.`,onRetry:S}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,_.jsx)(c,{label:`Completed`,value:u(w.completed),tone:`green`}),(0,_.jsx)(c,{label:`Failed`,value:u(O),tone:O?`red`:`default`}),(0,_.jsx)(c,{label:`Waiting`,value:u(w.waiting),tone:`amber`}),(0,_.jsx)(c,{label:`Active`,value:u(w.active),tone:`blue`}),(0,_.jsx)(c,{label:`Error Rate`,value:k==null?`—`:p(k),tone:k==null?`default`:k>.05?`red`:`green`}),(0,_.jsx)(c,{label:`Uptime`,value:A})]}),(0,_.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(h,{children:[(0,_.jsx)(r,{title:`Runtime`}),(0,_.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,_.jsx)(b,{label:`Jobs pushed (since restart)`,value:u(w.totalPushed)}),(0,_.jsx)(b,{label:`Jobs pulled (since restart)`,value:u(w.totalPulled)}),(0,_.jsx)(b,{label:`Heap used`,value:l(T.heapUsed*1024*1024)}),(0,_.jsx)(b,{label:`RSS`,value:l(T.rss*1024*1024)}),(0,_.jsx)(b,{label:`Cron jobs`,value:String(E.total)})]})]}),(0,_.jsxs)(h,{children:[(0,_.jsx)(r,{title:`Storage`}),D.diskFull?(0,_.jsxs)(`div`,{className:`rounded-lg border border-red-500/25 bg-red-500/[0.06] px-4 py-3`,children:[(0,_.jsx)(`div`,{className:`font-semibold text-danger`,children:`Disk full — writes suspended`}),D.error&&(0,_.jsx)(`div`,{className:`mt-1 text-xs text-muted`,children:D.error}),D.since!=null&&(0,_.jsxs)(`div`,{className:`mt-1 text-xs text-faint`,children:[`since `,a(D.since)]})]}):(0,_.jsxs)(`div`,{className:`rounded-lg border border-emerald-500/25 bg-emerald-500/[0.06] px-4 py-3`,children:[(0,_.jsx)(`div`,{className:`font-semibold text-success`,children:`Healthy`}),(0,_.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:`Disk writes are being accepted.`})]})]})]})]})}function b({label:e,value:t}){return(0,_.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,_.jsx)(`dt`,{className:`text-muted`,children:e}),(0,_.jsx)(`dd`,{className:`font-medium text-fg`,children:t})]})}export{y as UsagePro};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{h as t,t as n}from"./react-vendor-08inPAVO.js";import{O as r,m as i}from"./icons-BIT5aq1c.js";import{C as a,F as o,I as s,O as c,S as l,_ as u,b as d,d as f,g as p,l as m,v as h,w as g,x as _,y as v}from"./index-X_fHGbXZ.js";import{n as y,o as b,t as x}from"./form-DBkslwzu.js";import{t as S}from"./Pagination-WVfHLHDS.js";import{r as C,t as w}from"./useServerActionGuard-uiZWD3dS.js";var T=[`job.pushed`,`job.started`,`job.completed`,`job.failed`,`job.progress`],E=e(t(),1);function D(e){try{let t=new URL(e);return e.length<=2048&&/^https?:$/.test(t.protocol)&&t.username===``&&t.password===``}catch{return!1}}function O(e){try{let t=new URL(e);return!t.username&&!t.password?e:(t.username=`redacted`,t.password=`redacted`,t.toString())}catch{return e}}function k(e,t,n,r){let i=e.trim();if(!i||t.length===0)return{ok:!1,msg:`URL and at least one event are required`};if(!D(i))return{ok:!1,msg:`URL must be a valid http:// or https:// address without embedded credentials`};let a=n.trim();return a&&(a.length>256||!/^[a-zA-Z0-9_\-.:]+$/.test(a))?{ok:!1,msg:`Queue must be at most 256 characters using letters, numbers, _, -, . or :`}:{ok:!0,body:{url:i,events:t,queue:a||void 0,secret:r.trim()||void 0}}}var A=n();function j({onAdd:e,onAccepted:t,beginAdd:n,scopeKey:r}){let[i,o]=(0,E.useState)(``),[s,c]=(0,E.useState)(``),[l,u]=(0,E.useState)(``),[d,f]=(0,E.useState)([`job.completed`,`job.failed`]),[p,m]=(0,E.useState)(null),[h,g]=(0,E.useState)(!1);(0,E.useEffect)(()=>{g(!1),m(null)},[r]);let _=e=>f(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),v=async()=>{if(h)return;m(null);let r=k(i,d,s,l);if(!r.ok)return m(r.msg);let a=n();if(a){g(!0);try{let n=await e(r.body);if(w(n,`Add webhook`),!a.isCurrent())return;o(``),u(``),t()}catch(e){a.isCurrent()&&m(e.message)}finally{a.finish()&&g(!1)}}};return(0,A.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),v()},children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-3`,children:[(0,A.jsx)(`div`,{className:`md:col-span-1`,children:(0,A.jsx)(x,{label:`URL`,children:(0,A.jsx)(y,{value:i,onInput:e=>o(e.currentTarget.value),name:`webhook-url`,type:`url`,maxLength:2048,autoComplete:`url`,placeholder:`https://example.com/hook`})})}),(0,A.jsx)(x,{label:`Queue (optional)`,children:(0,A.jsx)(y,{value:s,onChange:e=>c(e.target.value),name:`webhook-queue`,maxLength:256,autoComplete:`off`,placeholder:`all queues`})}),(0,A.jsx)(x,{label:`Secret (optional)`,children:(0,A.jsx)(y,{type:`password`,autoComplete:`new-password`,name:`webhook-secret`,maxLength:65536,value:l,onChange:e=>u(e.target.value),placeholder:`HMAC signing secret`})})]}),(0,A.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:T.map(e=>(0,A.jsx)(`button`,{type:`button`,"aria-pressed":d.includes(e),onClick:()=>_(e),className:d.includes(e)?`rounded-full bg-accent/15 px-3 py-1 text-xs font-medium text-accent`:`rounded-full border border-line px-3 py-1 text-xs font-medium text-muted hover:text-fg`,children:e},e))}),(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(a,{type:`submit`,variant:`accent`,size:`sm`,disabled:h,children:h?`Adding…`:`Add webhook`}),p&&(0,A.jsx)(`span`,{className:`text-xs text-danger`,children:p})]})]})}function M(e){let[t,n]=(0,E.useState)(0);return(0,E.useEffect)(()=>{t>e-1&&n(e-1)},[t,e]),[Math.min(t,e-1),n]}function N(){let{data:e,error:t,loading:n,refetch:a}=c(()=>s.webhooks(),[]),y=e?.data?.webhooks??[],[x,T]=M(Math.max(1,Math.ceil(y.length/15))),[D,k]=(0,E.useState)(null),[N,P]=(0,E.useState)(new Set),F=C(`webhooks`),[I,L]=(0,E.useState)({}),R=(0,E.useRef)(new Map);(0,E.useEffect)(()=>{k(null),P(new Set),L({}),R.current.clear()},[F.scopeKey]);let z=async e=>{let t=F.begin([`registry-write`,`webhook:${e}`]);if(t){k(null),P(t=>new Set(t).add(e));try{let n=await s.removeWebhook(e);if(w(n,`Remove webhook`),!t.isCurrent())return;a()}catch(e){if(!t.isCurrent())return;k(e.message)}finally{t.finish()&&P(t=>{let n=new Set(t);return n.delete(e),n})}}},B=(e,t)=>{let n=Symbol(`webhook-toggle`),r=R.current.get(e);if(r){r.desired=t,r.intent=n,L(r=>({...r,[e]:{value:t,intent:n}}));return}let i=F.begin(`webhook:${e}`);if(!i)return;let c={desired:t,intent:n,lease:i};R.current.set(e,c),L(r=>({...r,[e]:{value:t,intent:n}})),(async()=>{try{for(;i.isCurrent()&&R.current.get(e)===c;){let t=c.desired,n=null;try{let n=await s.setWebhookEnabled(e,t);w(n,`Toggle webhook`)}catch(e){n=e instanceof Error?e:Error(String(e))}if(!i.isCurrent()||R.current.get(e)!==c)return;if(c.desired!==t)continue;if(await a(),!i.isCurrent()||R.current.get(e)!==c)return;if(c.desired!==t)continue;R.current.delete(e);let r=c.intent;L(t=>{if(t[e]?.intent!==r)return t;let{[e]:n,...i}=t;return i}),n&&o.error(`Webhook toggle failed`,n.message);return}}finally{i.finish()}})()};return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(p,{title:`Webhooks`,description:`HTTP callbacks fired on job events.`,live:!!e&&!t}),t&&e&&(0,A.jsx)(d,{message:`Webhook refresh failed — showing the last successful registry.`,onRetry:a}),D&&(0,A.jsx)(`div`,{role:`status`,className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-danger`,children:D}),(0,A.jsxs)(_,{className:`mb-6`,children:[(0,A.jsx)(l,{title:`Add webhook`}),(0,A.jsx)(j,{onAdd:e=>s.addWebhook(e),onAccepted:()=>void a(),beginAdd:()=>F.begin([`registry-write`,`add`]),scopeKey:F.scopeKey})]}),t&&!e?(0,A.jsx)(h,{error:t,onRetry:a}):n&&!e?(0,A.jsx)(v,{label:`Loading webhooks…`}):y.length===0?(0,A.jsx)(u,{icon:(0,A.jsx)(i,{}),title:`No webhooks`,hint:`Add one above to receive job-event callbacks.`}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,A.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,A.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`URL`}),(0,A.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Events`}),(0,A.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,A.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Success / Fail`}),(0,A.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Last`}),(0,A.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Enabled`}),(0,A.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,A.jsx)(`tbody`,{children:y.slice(x*15,x*15+15).map(e=>(0,A.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,A.jsx)(`td`,{className:`max-w-xs truncate px-5 py-3 font-mono text-xs text-fg`,children:O(e.url)}),(0,A.jsx)(`td`,{className:`px-5 py-3 text-xs text-muted`,children:e.events.join(`, `)}),(0,A.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue??`all`}),(0,A.jsxs)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:[(0,A.jsx)(`span`,{className:`text-success`,children:m(e.successCount)}),` / `,(0,A.jsx)(`span`,{className:e.failureCount?`text-danger`:``,children:m(e.failureCount)})]}),(0,A.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:f(e.lastTriggered)}),(0,A.jsx)(`td`,{className:`px-5 py-3`,children:(0,A.jsx)(b,{checked:I[e.id]?.value??e.enabled,label:`${I[e.id]?.value??e.enabled?`Disable`:`Enable`} webhook`,onChange:t=>B(e.id,t)})}),(0,A.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,A.jsx)(g,{"aria-label":`Remove webhook`,disabled:N.has(e.id),onClick:()=>window.confirm(`Remove webhook for ${O(e.url)}?`)&&z(e.id),children:(0,A.jsx)(r,{className:`size-3.5`})})})]},e.id))})]})}),(0,A.jsx)(S,{page:x,pageSize:15,total:y.length,onPageChange:T,label:`webhooks`})]})]})}export{N as Webhooks};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{h as t,t as n}from"./react-vendor-08inPAVO.js";import{A as r}from"./icons-BIT5aq1c.js";import{t as i}from"./api-CCgfskjt.js";import{O as a,_ as o,b as s,d as c,g as l,h as u,l as d,v as f,y as p}from"./index-X_fHGbXZ.js";import{t as m}from"./Pagination-WVfHLHDS.js";var h=e(t(),1),g=n(),_=20,v={workers:{total:0,active:0,list:[],truncated:!1}};function y(){let{data:e,error:t,loading:n,refetch:y}=a(()=>i.overview(),[]),[b,x]=(0,h.useState)(0);if(n&&!e&&!t)return(0,g.jsx)(p,{label:`Loading workers…`});if(t&&!e)return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(l,{title:`Workers`,description:`Worker inventory is unavailable.`}),(0,g.jsx)(f,{error:t,onRetry:y})]});let{workers:S}=e??v,C=Math.max(1,Math.ceil(S.list.length/_)),w=Math.min(b,C-1),T=S.list.slice(w*_,w*_+_);return(0,g.jsxs)(`div`,{children:[t&&(0,g.jsx)(s,{message:`Worker refresh failed — showing the last successful inventory.`,onRetry:y}),(0,g.jsx)(l,{title:`Workers`,description:`Registered workers and their throughput.`,live:!!e&&!t}),(0,g.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,g.jsx)(u,{label:`Total`,value:d(S.total),compact:!0}),(0,g.jsx)(u,{label:`Active`,value:d(S.active),tone:`green`,compact:!0})]}),S.list.length===0?(0,g.jsx)(o,{icon:(0,g.jsx)(r,{}),title:`No workers registered`,hint:`Workers appear here once they connect and register with the server.`}):(0,g.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,g.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,g.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Worker`}),(0,g.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queues`}),(0,g.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,g.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Processed`}),(0,g.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`}),(0,g.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Last Seen`})]})}),(0,g.jsx)(`tbody`,{children:T.map(e=>(0,g.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,g.jsxs)(`td`,{className:`px-5 py-3`,children:[(0,g.jsx)(`div`,{className:`font-medium text-fg`,children:e.name||`worker`}),(0,g.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.id})]}),(0,g.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queues.join(`, `)||`—`}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:d(e.activeJobs)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:d(e.processedJobs)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:d(e.failedJobs)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:c(e.lastSeen)})]},e.id))})]})}),S.truncated&&(0,g.jsxs)(`p`,{className:`mt-3 text-xs text-amber-400`,children:[`Showing first `,d(S.list.length),` of `,d(S.total),` `,`workers.`]}),(0,g.jsx)(m,{page:w,pageSize:_,total:S.list.length,onPageChange:x,label:`workers`})]})}export{y as Workers};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{h as t,t as n}from"./react-vendor-08inPAVO.js";import{A as r,O as i}from"./icons-BIT5aq1c.js";import{r as a}from"./StatusBadge-D-mexaga.js";import{I as o,O as s,_ as c,b as l,d as u,g as d,h as f,l as p,v as m,w as h,y as g}from"./index-X_fHGbXZ.js";import{t as _}from"./Pagination-WVfHLHDS.js";import{r as v,t as y}from"./useServerActionGuard-uiZWD3dS.js";var b=e(t(),1),x=n(),S=`No heartbeat recently — derived from lastSeen`;function C({rows:e,sort:t,busyIds:n,onSort:r,onRemove:o}){return(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:`Worker`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queues`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Processed`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:(0,x.jsx)(w,{label:`Failed`,active:t?.key===`failed`?t.dir:null,onClick:()=>r(`failed`)})}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:(0,x.jsx)(w,{label:`Last Seen`,active:t?.key===`lastSeen`?t.dir:null,onClick:()=>r(`lastSeen`)})}),(0,x.jsx)(`th`,{className:`w-16 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,x.jsx)(`tbody`,{children:e.map(e=>(0,x.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,x.jsxs)(`td`,{className:`px-5 py-3`,children:[(0,x.jsx)(`div`,{className:`font-medium text-fg`,children:e.name||`worker`}),(0,x.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.id})]}),(0,x.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queues.join(`, `)||`—`}),(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(`span`,{title:e.status===`active`?void 0:S,className:a(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.status===`active`?`bg-emerald-500/10 text-success`:`bg-amber-500/10 text-warning`),children:e.status})}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:p(e.activeJobs)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(e.processedJobs)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(e.failedJobs)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:u(e.lastSeen)}),(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(`div`,{className:`flex justify-end`,children:e.status===`stale`&&e.activeJobs===0?(0,x.jsx)(h,{"aria-label":`Remove stale registry record for worker ${e.id}`,title:`Registry cleanup only — does not stop the worker process`,disabled:n.has(e.id),onClick:()=>o(e.id),children:(0,x.jsx)(i,{className:`size-3.5`})}):(0,x.jsx)(`span`,{className:`text-xs text-faint`,title:e.status===`stale`?`Registry cleanup is blocked while active jobs are reported`:`Only stale, idle registry records can be removed`,children:`—`})})})]},e.id))})]})})}function w({label:e,active:t,onClick:n}){return(0,x.jsxs)(`button`,{type:`button`,onClick:n,title:`Sort by ${e}`,className:a(`inline-flex items-center gap-1 uppercase tracking-wider transition-colors hover:text-fg`,t?`text-fg`:`text-faint`),children:[e,(0,x.jsx)(`span`,{"aria-hidden":`true`,children:t===`desc`?`↓`:t===`asc`?`↑`:``})]})}var T=100;function E(){let{data:e,error:t,loading:n,refetch:i}=s(async()=>(await o.workers()).data,[]),[u,h]=(0,b.useState)(new Set),[w,E]=(0,b.useState)(null),[D,O]=(0,b.useState)(null),[k,A]=(0,b.useState)(``),[j,M]=(0,b.useState)(0),N=v(`workers-pro`);if((0,b.useEffect)(()=>{h(new Set),E(null),M(0),A(``)},[N.scopeKey]),n&&!e&&!t)return(0,x.jsx)(g,{label:`Loading workers…`});if(t&&!e)return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(d,{title:`Workers`,description:`Worker inventory is unavailable.`}),(0,x.jsx)(m,{error:t,onRetry:i})]});let P=e?.workers??[],F=e?.quarantinedWorkers??[],I=D?[...P].sort((e,t)=>{let n=D.key===`failed`?e.failedJobs??0:e.lastSeen??0,r=D.key===`failed`?t.failedJobs??0:t.lastSeen??0;return D.dir===`asc`?n-r:r-n}):P,L=k.trim().toLowerCase(),R=L?I.filter(e=>[e.name,e.id,e.hostname,e.status,...e.queues].some(e=>e.toLowerCase().includes(L))):I,z=Math.min(j,Math.max(0,Math.ceil(R.length/T)-1)),B=R.slice(z*T,(z+1)*T),V=e=>{M(0),O(t=>t?.key===e?{key:e,dir:t.dir===`desc`?`asc`:`desc`}:{key:e,dir:`desc`})},H=P.filter(e=>e.status===`active`).length,U=P.length-H,W=P.reduce((e,t)=>e+(t.activeJobs??0),0),G=async e=>{if(!window.confirm(`Remove the stale registry record for worker "${e}"? This does not stop the worker process. Continue only after confirming that process is stopped; Bunqueue v2.9.3 workers do not automatically re-register after their heartbeat record is removed.`))return;let t=N.begin(`worker:${e}`);if(t){h(t=>new Set(t).add(e)),E(null);try{let n=await o.unregisterWorker(e);if(y(n,`Remove stale worker registry record`),!t.isCurrent())return;E({ok:!0,text:`Removed stale registry record for ${e} ✓`}),i()}catch(e){if(!t.isCurrent())return;E({ok:!1,text:`Removal failed: ${e.message}`})}finally{t.finish()&&h(t=>{let n=new Set(t);return n.delete(e),n})}}};return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(d,{title:`Workers`,description:`Registered workers and their throughput.`,live:!!e&&!t}),t&&(0,x.jsx)(l,{message:`Worker refresh failed — showing the last successful inventory.`,onRetry:i}),(0,x.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-5`,children:[(0,x.jsx)(f,{label:`Total`,value:p(P.length+F.length),compact:!0}),(0,x.jsx)(f,{label:`Active`,value:p(H),tone:`green`,compact:!0}),(0,x.jsx)(`div`,{title:S,children:(0,x.jsx)(f,{label:`Stale`,value:p(U),tone:U?`amber`:`default`,compact:!0})}),(0,x.jsx)(f,{label:`Active Jobs`,value:p(W),tone:`blue`,compact:!0}),(0,x.jsx)(f,{label:`Quarantined`,value:p(F.length),tone:F.length?`red`:`default`,compact:!0})]}),F.length>0&&(0,x.jsxs)(`div`,{role:`alert`,className:`mb-4 rounded-lg border border-danger/30 bg-danger/5 p-4`,children:[(0,x.jsxs)(`p`,{className:`text-sm font-medium text-danger`,children:[F.length,` worker registration(s) contain values accepted by Bunqueue 2.9.3 but unsafe to render. Healthy workers remain available below.`]}),(0,x.jsx)(`p`,{className:`mt-1 text-xs text-muted`,children:`Their status and active-job count are unknown, so this dashboard will not offer the registry-only removal action for them.`}),(0,x.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs text-muted`,children:F.slice(0,20).map(e=>(0,x.jsxs)(`li`,{className:`truncate font-mono`,children:[`#`,e.index+1,` `,e.id??`(unaddressable id)`,` — `,e.reason]},`${e.index}:${e.id??`unknown`}`))})]}),w&&(0,x.jsx)(`div`,{className:a(`mb-3 text-sm`,w.ok?`text-success`:`text-danger`),children:w.text}),P.length>0&&(0,x.jsx)(`div`,{className:`mb-4`,children:(0,x.jsx)(`input`,{"aria-label":`Search workers`,name:`workers-search`,value:k,onInput:e=>{A(e.currentTarget.value),M(0)},placeholder:`Search workers, queues or hosts…`,className:`h-9 w-full max-w-sm 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`})}),P.length===0?(0,x.jsx)(c,{icon:(0,x.jsx)(r,{}),title:F.length?`No renderable workers`:`No workers registered`,hint:F.length?`Malformed registrations are isolated above instead of taking down the inventory.`:`Workers appear here once they connect and register with the server.`}):R.length===0?(0,x.jsx)(c,{icon:(0,x.jsx)(r,{}),title:`No workers match your search`,hint:`Try a different name, ID, queue, host, or status.`}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(C,{rows:B,sort:D,busyIds:u,onSort:V,onRemove:e=>void G(e)}),(0,x.jsx)(_,{page:j,pageSize:T,total:R.length,onPageChange:M,label:`workers`})]})]})}export{E as WorkersPro};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{f as t,h as n,l as r,t as i}from"./react-vendor-08inPAVO.js";import{a}from"./connectionStore-B946Fhuv.js";import{t as o}from"./upstreamPaths-DQeKSxGc.js";import{r as s,t as c}from"./StatusBadge-D-mexaga.js";import{F as l,H as u,I as d,O as f,_ as p,b as m,d as h,g,o as _,s as v,v as y,x as b,y as x}from"./index-X_fHGbXZ.js";import{n as S,t as C}from"./controlConnectionEpoch-x9VjrWgN.js";import{t as w}from"./useControlActionGuard-Bx5MkufG.js";var T={"/workflows":{id:`overview`,label:`Overview`,description:`The complete durable command center for Bunqueue Workflow Engine.`,kind:`active`,state:``},"/workflows/executions":{id:`executions`,label:`Executions`,description:`Inspect every active execution, step record, decision, and nested run.`,kind:`active`,state:``},"/workflows/waiting":{id:`waiting`,label:`Waiting & Signals`,description:`Focus on parked executions and their durable signal payloads.`,kind:`active`,state:`waiting`,lockKind:!0,lockState:!0},"/workflows/compensation":{id:`compensation`,label:`Compensation`,description:`See running, completed, skipped, failed, and parked saga compensation outcomes.`,kind:`active`,state:`compensation`,lockKind:!0,lockState:!0},"/workflows/archive":{id:`archive`,label:`Archive`,description:`Audit terminal executions retained by Workflow Engine archival.`,kind:`archive`,state:``,lockKind:!0}};function ee(e){return T[e]??T[`/workflows`]}function te(e,t){return e?.source===`link`||e&&t.some(t=>t.id===e.id)?e:t[0]?{id:t[0].id,source:`page`}:null}var E=e(n(),1),ne=[`waiting`,`failed`,`compensation-stuck`];async function re(e,t){let[n,r]=await Promise.all([e.stats(),e.list(t)]);return{stats:n,page:r}}async function ie(e,t){let[n,...r]=await Promise.all([e.stats(),...ne.map(n=>e.list({kind:`active`,state:n,limit:t,offset:0}))]),i=r.flatMap(e=>e.executions).sort(ae).slice(0,t);return{stats:n,page:{ok:r.every(e=>e.ok),available:r.every(e=>e.available),executions:i,total:r.reduce((e,t)=>e+t.total,0),limit:t,offset:0}}}function ae(e,t){return t.createdAt-e.createdAt||t.id.localeCompare(e.id)}var D=new Set([`summary`,`history`,`payloads`]),oe=new Set([`running`,`waiting`,`completed`,`failed`,`compensating`,`compensation-stuck`,`compensation`]);function O(e,t){let n=e.get(`kind`),r=t.id===`executions`&&(n===`active`||n===`archive`)?n:t.kind,i=t.id===`overview`?``:ce(e.get(`workflow`)),a=ue(e.get(`state`),t),s=t.id===`overview`?0:le(e.get(`offset`)),c=e.get(`execution`),l=c&&o(c,`Workflow execution id`)===null?c:null,u=e.get(`tab`),d=t.id===`overview`||t.id===`executions`;return{kind:r,workflowName:i,state:a,offset:s,executionId:l,tab:l&&d&&D.has(u)?u:`summary`}}function k(e,t){let n=new URLSearchParams;return e.id===`executions`&&t.kind===`archive`&&n.set(`kind`,`archive`),e.id!==`overview`&&t.workflowName&&n.set(`workflow`,t.workflowName),j(e)&&t.state&&n.set(`state`,t.state),e.id!==`overview`&&t.offset>0&&n.set(`offset`,String(t.offset)),t.executionId&&n.set(`execution`,t.executionId),t.executionId&&t.tab!==`summary`&&(e.id===`overview`||e.id===`executions`)&&n.set(`tab`,t.tab),n}function A(e,t,n){return k(t,{...O(e,t),...n})}function se(e){return D.has(e)}function ce(e){return e&&e.length<=256?e:``}function le(e){if(!e||!/^(0|[1-9]\d*)$/.test(e))return 0;let t=Number(e);return Number.isSafeInteger(t)&&t<=1e6?Math.floor(t/25)*25:0}function ue(e,t){return j(t)?e?t.id===`archive`?e===`completed`||e===`failed`?e:``:oe.has(e)?e:``:``:t.state}function j(e){return e.id===`executions`||e.id===`archive`}var de=e=>`${e}?target=${encodeURIComponent(a())}`,M=e=>({method:`POST`,headers:e===void 0?void 0:{"Content-Type":`application/json`},body:e===void 0?void 0:JSON.stringify(e)});async function N(e,t){return(await u(de(e),t)).result}var P={status:()=>N(`/workflows/runtime`),initialize:()=>N(`/workflows/runtime/initialize`,M()),reload:()=>N(`/workflows/runtime/reload`,M()),start:async(e,t)=>(await N(`/workflows/start`,M({workflowName:e,input:t}))).run,signal:async(e,t,n)=>{await N(`/workflows/${encodeURIComponent(e)}/signal`,M({event:t,payload:n}))},recover:async()=>(await N(`/workflows/recover`,M())).recovered,resumeCompensation:async e=>{await N(`/workflows/${encodeURIComponent(e)}/resume-compensation`,M())},abandonCompensation:async e=>{await N(`/workflows/${encodeURIComponent(e)}/abandon-compensation`,M())},archive:async(e,t)=>(await N(`/workflows/archive`,M({maxAgeMs:e,states:t}))).affected,cleanup:async(e,t)=>(await N(`/workflows/cleanup`,M({maxAgeMs:e,states:t}))).affected},fe={stats:()=>d.workflows.stats(),list:e=>d.workflows.list(e),get:(e,t)=>d.workflows.get(e,t)};function pe(e){let[n,r]=t(),i=n.toString(),a=(0,E.useMemo)(()=>O(new URLSearchParams(i),e),[i,e]),o=(0,E.useMemo)(()=>k(e,a).toString(),[e,a]),s=(0,E.useRef)(null);(0,E.useEffect)(()=>{o!==i&&r(o,{replace:!0})},[o,i,r]);let c=(0,E.useCallback)((t,n=!1)=>{r(n=>A(n,e,t),{replace:n})},[e,r]),l=(0,E.useCallback)((e,t=!1)=>{s.current=e,c({executionId:e?.id??null,tab:`summary`},t)},[c]),u=a.executionId?{id:a.executionId,source:s.current?.id===a.executionId?s.current.source:`link`}:null;return{...a,selected:u,update:c,select:l}}function F(e){let t=S(),n=`workflow-command:${e.operationGroup}`,r=w(n),i=(0,E.useMemo)(()=>({local:e.scopeKey,connectionEpoch:t}),[t,e.scopeKey]),a=(0,E.useRef)(e);a.current=e;let o=(0,E.useRef)(null),s=(0,E.useRef)(!0),c=(0,E.useRef)(i),l=(0,E.useRef)(0);if(!Object.is(c.current,i)){let e=c.current.connectionEpoch!==t;c.current=i,l.current+=1,e&&(o.current=null)}let[u,d]=(0,E.useState)(()=>I(i,t));(0,E.useEffect)(()=>(s.current=!0,()=>{s.current=!1,l.current+=1,o.current=null}),[]);let f=(e,t)=>s.current&&e===l.current&&t===C(),p=async(e,c)=>{if(o.current||t!==C())return;let u=r.begin(n);if(!u)return;let p=Symbol(`workflow-command`);o.current=p;let m=l.current,h=t,{onApplied:g,onSucceeded:_}=a.current;try{d({connectionEpoch:t,scope:i,busy:e,error:``,receipt:null});let n=await c();if(!f(m,h))return;d({connectionEpoch:t,scope:i,busy:e,error:``,receipt:{label:e,value:n}});try{_?.(e,n)}catch{}try{await g?.()}catch(e){f(m,h)&&d(t=>({...t,error:`Command succeeded; refresh failed: ${L(e)}`}))}}catch(n){f(m,h)&&d({connectionEpoch:t,scope:i,busy:e,error:L(n),receipt:null})}finally{u.finish(),o.current===p&&(o.current=null,s.current&&h===C()&&d(e=>({...e,busy:``})))}},m=Object.is(u.scope,i)?u:I(i,t);return{busy:u.connectionEpoch===t?u.busy:``,error:m.error,result:m.receipt?.value,succeeded:m.receipt?.label??``,run:p,clearResult:()=>d(e=>({...e,receipt:null}))}}function I(e,t){return{connectionEpoch:t,scope:e,busy:``,error:``,receipt:null}}function L(e){return e instanceof Error?e.message:String(e)}var R=i(),z=e=>JSON.stringify(e,null,2)??`null`;function B({value:e,empty:t=`None`}){return e==null||typeof e==`object`&&Object.keys(e).length===0?(0,R.jsx)(`p`,{className:`text-xs text-faint`,children:t}):(0,R.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs leading-5 text-muted`,children:z(e)})}function V({label:e,value:t}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`text-faint`,children:e}),(0,R.jsx)(`dd`,{className:`mt-0.5 break-words text-muted`,children:t})]})}var me=36e5;function he({repository:e=P,onApplied:t}){let[n,r]=(0,E.useState)(`720`),[i,a]=(0,E.useState)(!0),[o,s]=(0,E.useState)(!0),c=F({operationGroup:`maintenance`,scopeKey:(0,E.useMemo)(()=>Symbol(`workflow-maintenance:${n.length}:${i}:${o}`),[i,o,n]),onApplied:t}),l=[...i?[`completed`]:[],...o?[`failed`]:[]],u=n.trim()===``?NaN:Number(n),d=Number.isFinite(u)&&u>=0&&l.length>0,f=t=>{if(!d)return;let n=t===`archive`?`Archive ${l.join(` and `)} workflows at least ${u} hours old?`:`Permanently delete ${l.join(` and `)} workflows at least ${u} hours old from the active execution store? Archive records are not deleted.`;if(!window.confirm(n))return;let r=Math.round(u*me);c.run(t,async()=>({operation:t,affected:t===`archive`?await e.archive(r,l):await e.cleanup(r,l)}))};return(0,R.jsxs)(`section`,{className:`mb-5 rounded-lg border border-line bg-surface p-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Retention operations`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Archive moves terminal runs into retention. Cleanup permanently deletes eligible terminal runs from the active store only; archive records remain intact.`})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Minimum age (hours)`,(0,R.jsx)(`input`,{"aria-label":`Workflow retention age hours`,type:`number`,min:`0`,step:`1`,value:n,onChange:e=>r(e.target.value),className:`mt-1 block h-9 w-32 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`})]}),(0,R.jsxs)(`label`,{className:`flex h-9 items-center gap-2 text-xs text-muted`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked)}),`Completed`]}),(0,R.jsxs)(`label`,{className:`flex h-9 items-center gap-2 text-xs text-muted`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Failed`]})]})]}),(0,R.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:!d||!!c.busy,onClick:()=>f(`archive`),className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:`Archive eligible`}),(0,R.jsx)(`button`,{type:`button`,disabled:!d||!!c.busy,onClick:()=>f(`cleanup`),className:`rounded-md border border-danger/40 px-3 py-2 text-xs text-danger disabled:opacity-40`,children:`Delete eligible`})]}),c.error&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:c.error}),c.result!==void 0&&(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(B,{value:c.result})})]})}var ge=[[`Active`,`activeTotal`,`text-fg`],[`Running`,`running`,`text-blue-400`],[`Waiting`,`waiting`,`text-warning`],[`Completed`,`completed`,`text-success`],[`Failed`,`failed`,`text-danger`],[`Compensating`,`compensating`,`text-violet-400`],[`Stuck`,`compensation-stuck`,`text-danger`]];function _e({stats:e}){return(0,R.jsx)(`dl`,{className:`mb-4 grid grid-cols-2 divide-x divide-y divide-line overflow-hidden rounded-lg border border-line bg-surface sm:grid-cols-4 xl:grid-cols-7 xl:divide-y-0`,children:ge.map(([t,n,r])=>(0,R.jsxs)(`div`,{className:`px-3 py-2.5 first:border-0`,children:[(0,R.jsx)(`dt`,{className:`text-[10px] font-medium uppercase tracking-wider text-faint`,children:t}),(0,R.jsx)(`dd`,{className:s(`mt-1 tnum font-mono text-lg font-semibold`,r),children:n===`activeTotal`?e.activeTotal:e.states[n]})]},n))})}function ve(e,t){let n=S(),r=(0,E.useRef)(null),i=F({operationGroup:`runtime-initialization`,scopeKey:e,onApplied:t.refetch});return(0,E.useEffect)(()=>{if(t.data?.ready&&(r.current=null),!t.data?.needsInitialization||t.error||i.busy)return;let a=JSON.stringify([n,t.data.moduleName]);(r.current?.repository!==e||r.current.key!==a)&&(r.current={repository:e,key:a},i.run(`initialize`,()=>e.initialize()))},[i,n,e,t.data,t.error]),i}function ye({repository:e=P,onApplied:t}){let[n,r]=(0,E.useState)(``),[i,a]=(0,E.useState)(`{}`),o=(0,E.useMemo)(()=>Symbol(`workflow-runtime:${n.length}:${i.length}`),[i,n]),s=f(()=>e.status(),[e],{intervalMs:5e3}),c=F({operationGroup:`runtime`,scopeKey:o,onApplied:async()=>{await s.refetch(),await t?.()}}),l=ve(e,s),u=s.data?.ready===!0;return(0,R.jsxs)(`section`,{className:`mb-5 overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Workflow runtime`}),(0,R.jsx)(`p`,{className:`mt-0.5 text-xs text-faint`,children:`Registered application handlers stay in the agent-side runtime; commands never edit SQLite directly.`})]}),(0,R.jsx)(be,{ready:u,configured:s.data?.configured===!0,unavailable:!(!s.error||s.data)})]}),s.data?.configured&&(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-line px-4 py-2 text-[11px] text-faint`,children:[(0,R.jsxs)(`span`,{children:[`Module`,` `,(0,R.jsx)(`strong`,{className:`font-mono font-medium text-muted`,children:s.data.moduleName??`—`})]}),(0,R.jsxs)(`span`,{children:[`Queue`,` `,(0,R.jsx)(`strong`,{className:`font-mono font-medium text-muted`,children:s.data.queueName??`—`})]}),(0,R.jsxs)(`span`,{children:[`Concurrency`,` `,(0,R.jsx)(`strong`,{className:`font-mono font-medium text-muted`,children:s.data.concurrency??`—`})]})]}),s.error&&s.data&&(0,R.jsx)(m,{message:`Runtime status refresh failed; showing the last snapshot.`,onRetry:s.refetch}),s.error&&!s.data&&(0,R.jsx)(`div`,{className:`p-4`,children:(0,R.jsx)(y,{error:s.error,onRetry:s.refetch})}),(0,R.jsxs)(`div`,{className:`grid gap-5 p-4 lg:grid-cols-[minmax(0,1fr)_auto]`,children:[(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Registered workflow`,(0,R.jsx)(`input`,{"aria-label":`Registered workflow`,list:`workflow-runtime-names`,value:n,onChange:e=>r(e.target.value),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`}),(0,R.jsx)(`datalist`,{id:`workflow-runtime-names`,children:s.data?.workflowNames.map(e=>(0,R.jsx)(`option`,{value:e},e))})]}),(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Input JSON`,(0,R.jsx)(`textarea`,{"aria-label":`Workflow input JSON`,value:i,onChange:e=>a(e.target.value),className:`mt-1 min-h-20 w-full resize-y rounded-lg border border-line bg-surface-2 p-2 font-mono text-xs text-fg`})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap content-start gap-2 lg:w-48 lg:flex-col`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:!u||!n.trim()||!!c.busy,onClick:()=>{let t;try{t=JSON.parse(i)}catch{c.run(`start`,async()=>{throw Error(`Workflow input must be valid JSON.`)});return}c.run(`start`,()=>e.start(n.trim(),t))},className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:c.busy===`start`?`Starting…`:`Start execution`}),(0,R.jsx)(`button`,{type:`button`,disabled:!u||!!c.busy,onClick:()=>{window.confirm(`Recover every orphaned workflow using the registered idempotent handlers?`)&&c.run(`recover`,()=>e.recover())},className:`rounded-md border border-line px-3 py-2 text-xs text-muted disabled:opacity-40`,children:`Recover orphaned`}),(0,R.jsx)(`button`,{type:`button`,disabled:!s.data?.configured||!!c.busy||!!l.busy,onClick:()=>void c.run(`reload`,()=>e.reload()),className:`rounded-md border border-line px-3 py-2 text-xs text-muted disabled:opacity-40`,children:`Reload definitions`})]})]}),!s.loading&&!s.error&&!s.data?.configured&&(0,R.jsxs)(`p`,{className:`border-t border-line px-4 py-3 text-xs text-warning`,children:[`Set `,(0,R.jsx)(`code`,{children:`BUNQUEUE_WORKFLOW_MODULE`}),` to an absolute module path in Server → Extra environment, then start the managed server.`]}),s.data?.error&&(0,R.jsx)(`p`,{role:`alert`,className:`border-t border-line px-4 py-3 text-xs text-danger`,children:s.data.error}),l.error&&!u&&(0,R.jsx)(`p`,{role:`alert`,className:`border-t border-line px-4 py-3 text-xs text-danger`,children:l.error}),c.error&&(0,R.jsx)(`p`,{role:`alert`,className:`border-t border-line px-4 py-3 text-xs text-danger`,children:c.error}),c.result!==void 0&&(0,R.jsx)(`div`,{className:`border-t border-line p-4`,children:(0,R.jsx)(B,{value:c.result})})]})}function be({ready:e,configured:t,unavailable:n}){return(0,R.jsx)(`span`,{className:e?`rounded-full bg-success/10 px-2 py-1 text-[11px] text-success`:`rounded-full bg-warning/10 px-2 py-1 text-[11px] text-warning`,children:e?`Handlers loaded`:n?`Status unavailable`:t?`Unavailable`:`Not configured`})}var xe=[``,`running`,`waiting`,`completed`,`failed`,`compensating`,`compensation-stuck`,`compensation`];function Se({section:e,kind:t,workflowName:n,state:r,stats:i,total:a,onKind:o,onWorkflowName:s,onState:c}){return(0,R.jsx)(b,{className:`mb-5`,children:(0,R.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[e.lockKind?(0,R.jsx)(H,{label:`Store`,value:`${e.kind}${e.kind===`archive`&&i?` · ${i.archiveTotal}`:``}`,capitalize:!0}):(0,R.jsx)(Ce,{kind:t,archiveTotal:i?.archiveTotal,onChange:o}),(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Workflow`,(0,R.jsxs)(`select`,{value:n,onChange:e=>s(e.target.value),className:`mt-1 block h-9 min-w-48 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:[(0,R.jsx)(`option`,{value:``,children:`All workflows`}),i?.workflowNames.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})]}),e.lockState?(0,R.jsx)(H,{label:`State scope`,value:e.state===`compensation`?`Compensating + stuck`:e.state}):(0,R.jsx)(we,{state:r,onChange:c}),a!==void 0&&(0,R.jsxs)(`span`,{className:`ml-auto text-xs text-faint`,children:[a,` execution`,a===1?``:`s`]})]})})}function Ce({kind:e,archiveTotal:t,onChange:n}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`mb-1 block text-xs text-faint`,children:`Store`}),(0,R.jsx)(`div`,{className:`flex rounded-lg border border-line p-0.5`,children:[`active`,`archive`].map(r=>(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":e===r,onClick:()=>n(r),className:s(`rounded-md px-3 py-1.5 text-xs capitalize`,e===r?`bg-surface-2 text-fg`:`text-muted hover:text-fg`),children:[r,r===`archive`&&t!==void 0?` (${t})`:``]},r))})]})}function we({state:e,onChange:t}){return(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`State`,(0,R.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),className:`mt-1 block h-9 min-w-44 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:xe.map(e=>(0,R.jsx)(`option`,{value:e,children:e===`compensation`?`All compensation`:e||`All states`},e||`all`))})]})}function H({label:e,value:t,capitalize:n=!1}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`mb-1 block text-xs text-faint`,children:e}),(0,R.jsx)(`span`,{className:s(`inline-flex h-9 items-center rounded-lg border border-line bg-surface-2 px-3 text-xs text-fg`,n&&`capitalize`),children:t})]})}function Te({label:e=`Workflow`,value:t,stats:n,onChange:r}){return(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[e,(0,R.jsxs)(`select`,{value:t,onChange:e=>r(e.target.value),className:`mt-1 block h-9 min-w-52 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:[(0,R.jsx)(`option`,{value:``,children:`All workflows`}),n?.workflowNames.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})]})}function Ee(e){return e.section.id===`overview`?null:e.section.id===`executions`?(0,R.jsx)(Se,{...e}):(0,R.jsxs)(`div`,{className:`mb-5 flex items-end gap-4 rounded-lg border border-line bg-surface px-4 py-3`,children:[(0,R.jsx)(Te,{value:e.workflowName,stats:e.stats,onChange:e.onWorkflowName}),e.section.id===`archive`&&(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Outcome`,(0,R.jsxs)(`select`,{value:e.state,onChange:t=>e.onState(t.target.value),className:`mt-1 block h-9 min-w-36 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:[(0,R.jsx)(`option`,{value:``,children:`All outcomes`}),(0,R.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,R.jsx)(`option`,{value:`failed`,children:`Failed`})]})]}),(0,R.jsxs)(`span`,{className:`ml-auto pb-2 text-xs text-faint`,children:[e.total??0,` `,e.section.id===`archive`?`records`:`executions`]})]})}function De(e){let t=[{id:`execution-started`,at:e.createdAt,title:`Execution started`,detail:e.workflowName,status:`running`,category:`execution`}];for(let[n,r]of Object.entries(e.steps))t.push(...Oe(n,r));for(let n of Object.keys(e.signals))t.push({id:`signal:${n}`,title:`Signal persisted: ${n}`,detail:`The store does not expose an exact signal timestamp.`,category:`signal`});return e.state!==`running`&&e.state!==`waiting`&&t.push({id:`execution-settled`,at:e.updatedAt,title:`Execution ${e.state}`,detail:e.failureReason,status:e.state,category:`execution`}),t.sort(ke)}function Oe(e,t){let n=[];return t.startedAt!==void 0&&n.push({id:`step:${e}:started`,at:t.startedAt,title:`Step started: ${e}`,detail:t.attempts?`Attempt ${t.attempts}`:void 0,status:`running`,category:`step`}),(t.completedAt!==void 0||t.status===`failed`)&&n.push({id:`step:${e}:settled`,at:t.completedAt,title:`Step ${t.status}: ${e}`,detail:t.error,status:t.status,category:`step`}),t.compensation&&n.push({id:`step:${e}:compensation`,at:t.compensation.at,title:`Compensation ${t.compensation.status}: ${e}`,detail:t.compensation.error,status:t.compensation.status,category:`compensation`}),n}function ke(e,t){return e.at===void 0&&t.at===void 0?e.id.localeCompare(t.id):e.at===void 0?1:t.at===void 0?-1:e.at-t.at||e.id.localeCompare(t.id)}function U({execution:e}){let t=De(e);return(0,R.jsx)(`ol`,{className:`divide-y divide-line/70 border-y border-line/70`,children:t.map((e,n)=>(0,R.jsxs)(`li`,{className:`grid grid-cols-[28px_minmax(0,1fr)] gap-3 py-3`,children:[(0,R.jsxs)(`div`,{className:`relative flex justify-center`,"aria-hidden":`true`,children:[(0,R.jsx)(`span`,{className:`mt-1.5 size-2 rounded-full border-2 border-surface bg-accent ring-1 ring-line`}),n<t.length-1&&(0,R.jsx)(`span`,{className:`absolute top-5 bottom-[-13px] w-px bg-line`})]}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`break-words text-sm font-medium text-fg`,children:e.title}),e.status&&(0,R.jsx)(c,{status:e.status})]}),(0,R.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-x-3 text-xs text-faint`,children:[(0,R.jsx)(`span`,{className:`capitalize`,children:e.category}),(0,R.jsx)(`span`,{children:e.at===void 0?`Timestamp unavailable`:_(e.at)})]}),e.detail&&(0,R.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs text-muted`,children:e.detail})]})]},e.id))})}var W={now:Date.now,subscribe:e=>{let t=window.setInterval(e,1e3);return()=>window.clearInterval(t)}};function Ae({since:e,clock:t=W}){let n=G(t);return(0,R.jsx)(R.Fragment,{children:v(Math.max(0,n-e))})}function G(e=W,t=!0){let[n,r]=(0,E.useState)(()=>e.now());return(0,E.useEffect)(()=>{if(r(e.now()),t)return e.subscribe(()=>r(e.now()))},[e,t]),n}function K({error:e,onRetry:t}){return e?(0,R.jsx)(m,{message:`Execution refresh failed; showing the last persisted snapshot.`,onRetry:t}):null}async function q(e,t){await Promise.all([e(),t?.()])}function je({repository:e,id:t,pollIntervalMs:n=1e4}){let{data:r,error:i,loading:a,refetch:o}=f(()=>e.get(t,`archive`),[e,t],{intervalMs:n});if(a&&!r)return(0,R.jsx)(x,{label:`Loading audit record…`});if(i&&!r)return(0,R.jsx)(y,{error:i,onRetry:o});let s=r?.execution;return s?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(K,{error:i,onRetry:o}),(0,R.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`flex items-start justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Immutable audit record`}),(0,R.jsx)(`h2`,{className:`mt-1 break-all font-mono text-sm font-semibold text-fg`,children:s.id})]}),(0,R.jsx)(c,{status:s.state})]}),(0,R.jsxs)(`dl`,{className:`grid grid-cols-2 gap-3 border-b border-line p-4 text-xs sm:grid-cols-3`,children:[(0,R.jsx)(V,{label:`Workflow`,value:s.workflowName}),(0,R.jsx)(V,{label:`Runtime`,value:v(s.updatedAt-s.createdAt)}),(0,R.jsx)(V,{label:`Archived`,value:s.archivedAt?_(s.archivedAt):`Unavailable`}),(0,R.jsx)(V,{label:`Definition hash`,value:s.definitionHash??`Unavailable`}),(0,R.jsx)(V,{label:`Final node`,value:String(s.currentNodeIndex)}),(0,R.jsx)(V,{label:`Final transition`,value:_(s.updatedAt)})]}),(0,R.jsx)(`div`,{className:`p-4`,children:(0,R.jsx)(U,{execution:s})})]})]}):null}function Me({repository:e,executionId:t,stuck:n,onApplied:r}){let i=F({operationGroup:`compensation`,scopeKey:`${t}:${n}`,onApplied:r,onSucceeded:e=>l.success(e===`resume`?`Compensation resumed`:`Compensation abandoned`,t)});return n?(0,R.jsxs)(`div`,{className:`border-t border-line p-4`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-faint`,children:`Operator decision`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-muted`,children:`Retry after fixing the reversal, or explicitly abandon the remaining compensation steps.`}),(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:!!i.busy,onClick:()=>{window.confirm(`Retry the stuck compensation for ${t}? Handlers must be idempotent.`)&&i.run(`resume`,()=>e.resumeCompensation(t))},className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:`Resume compensation`}),(0,R.jsx)(`button`,{type:`button`,disabled:!!i.busy,onClick:()=>{window.confirm(`Abandon remaining compensation for ${t}? This is irreversible.`)&&i.run(`abandon`,()=>e.abandonCompensation(t))},className:`rounded-md border border-danger/40 px-3 py-2 text-xs text-danger disabled:opacity-40`,children:`Abandon remainder`})]}),i.error&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:i.error}),i.succeeded&&(0,R.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:i.succeeded===`resume`?`Resume command accepted; recovery state refreshed.`:`Abandon command accepted; recovery state refreshed.`}),i.result!==void 0&&(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(B,{value:i.result})})]}):null}function Ne({repository:e,controlRepository:t,id:n,onApplied:r,pollIntervalMs:i=5e3}){let{data:a,error:o,loading:s,refetch:l}=f(()=>e.get(n,`active`),[e,n],{intervalMs:i});if(s&&!a)return(0,R.jsx)(x,{label:`Loading recovery plan…`});if(o&&!a)return(0,R.jsx)(y,{error:o,onRetry:l});let u=a?.execution;if(!u)return null;let d=Object.entries(u.steps).filter(([,e])=>e.compensatable||e.compensation);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(K,{error:o,onRetry:l}),(0,R.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`flex items-start justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-violet-400`,children:`Recovery plan`}),(0,R.jsx)(`h2`,{className:`mt-1 break-all font-mono text-sm font-semibold text-fg`,children:u.id})]}),(0,R.jsx)(c,{status:u.state})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 border-b border-line p-4 text-xs`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-faint`,children:`Compensation pivot`}),(0,R.jsx)(`div`,{className:`mt-1 text-fg`,children:u.committedAt===void 0?`Not committed`:`Node ${u.committedAt}`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-faint`,children:`Rollback state`}),(0,R.jsx)(`div`,{className:`mt-1 text-fg`,children:u.rollbackStatus??u.state})]})]}),u.failureReason&&(0,R.jsx)(`div`,{role:`alert`,className:`border-b border-danger/30 bg-danger/[0.06] px-4 py-3 text-xs text-danger`,children:u.failureReason}),(0,R.jsxs)(`div`,{className:`p-4`,children:[(0,R.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-faint`,children:`Compensation ledger`}),d.length?(0,R.jsx)(`ol`,{className:`space-y-2`,children:d.reverse().map(([e,t])=>(0,R.jsxs)(`li`,{className:`grid gap-2 rounded-md border border-line px-3 py-2 text-xs sm:grid-cols-[1fr_auto]`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`font-mono text-fg`,children:e}),(0,R.jsx)(`div`,{className:`mt-1 text-faint`,children:t.compensation?.error??`Compensation handler registered`})]}),(0,R.jsxs)(`div`,{className:`text-right text-muted`,children:[t.compensation?t.compensation.status:`pending`,t.compensation?.at?(0,R.jsx)(`div`,{className:`mt-1 text-[10px] text-faint`,children:_(t.compensation.at)}):null]})]},e))}):(0,R.jsx)(`p`,{className:`text-sm text-muted`,children:`No compensatable step was persisted.`})]}),(0,R.jsx)(Me,{repository:t,executionId:n,stuck:u.state===`compensation-stuck`,onApplied:()=>q(l,r)},n)]})]})}function Pe({execution:e}){return(0,R.jsxs)(`div`,{className:`space-y-5`,children:[(0,R.jsx)(J,{title:`Input`,value:e.input}),(0,R.jsx)(J,{title:`Signals`,value:e.signals}),(0,R.jsx)(J,{title:`Resolved steps`,value:e.resolvedSteps}),(0,R.jsx)(J,{title:`Decisions`,value:e.decisions})]})}function J({title:e,value:t}){return(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-faint`,children:e}),(0,R.jsx)(B,{value:t})]})}function Fe({steps:e,onSelect:t}){let n=Object.entries(e);return n.length===0?(0,R.jsx)(`p`,{className:`text-xs text-faint`,children:`No persisted step records.`}):(0,R.jsx)(`ol`,{className:`space-y-3`,children:n.map(([e,r],i)=>(0,R.jsx)(Ie,{name:e,step:r,last:i===n.length-1,onSelect:t},e))})}function Ie({name:e,step:t,last:n,onSelect:r}){let i=t.startedAt!==void 0&&t.completedAt!==void 0?t.completedAt-t.startedAt:void 0;return(0,R.jsxs)(`li`,{className:`relative grid grid-cols-[18px_1fr] gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col items-center`,"aria-hidden":`true`,children:[(0,R.jsx)(`span`,{className:`mt-1 size-2.5 rounded-full bg-current text-accent`}),!n&&(0,R.jsx)(`span`,{className:`mt-1 w-px flex-1 bg-line`})]}),(0,R.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-line bg-surface-2 p-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{translate:`no`,className:`break-all font-mono text-sm font-medium text-fg`,children:e}),(0,R.jsx)(c,{status:t.status})]}),(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-faint`,children:[t.attempts!==void 0&&(0,R.jsxs)(`span`,{children:[t.attempts,` attempt`,t.attempts===1?``:`s`]}),i!==void 0&&(0,R.jsx)(`span`,{children:v(i)}),t.occurrence!==void 0&&(0,R.jsxs)(`span`,{children:[`Occurrence `,t.occurrence]}),t.loopIndex!==void 0&&(0,R.jsxs)(`span`,{children:[`Loop index `,t.loopIndex]}),t.compensatable&&(0,R.jsx)(`span`,{children:`Compensatable`})]}),t.idempotencyKey&&(0,R.jsxs)(`div`,{className:`mt-2 break-all font-mono text-[11px] text-faint`,children:[`Idempotency: `,t.idempotencyKey]}),t.childExecutionId&&(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r(t.childExecutionId),className:`mt-2 break-all font-mono text-xs text-accent hover:underline`,children:[`Child execution: `,t.childExecutionId]}),t.error&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-2 whitespace-pre-wrap text-xs text-danger`,children:t.error}),t.compensation&&(0,R.jsxs)(`div`,{className:`mt-3 rounded-md border border-line px-3 py-2 text-xs`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-faint`,children:`Compensation`}),(0,R.jsx)(c,{status:t.compensation.status}),(0,R.jsx)(`span`,{className:`text-faint`,children:_(t.compensation.at)})]}),t.compensation.error&&(0,R.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-danger`,children:t.compensation.error})]}),(0,R.jsx)(Le,{step:t})]})]})}function Le({step:e}){return(0,R.jsxs)(R.Fragment,{children:[Object.hasOwn(e,`result`)&&(0,R.jsx)(Y,{label:`Result`,value:e.result}),Object.hasOwn(e,`loopItem`)&&(0,R.jsx)(Y,{label:`Loop item`,value:e.loopItem})]})}function Y({label:e,value:t}){return(0,R.jsxs)(`details`,{className:`mt-3`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted`,children:e}),(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(B,{value:t})})]})}function Re({execution:e,onSelect:t}){let n=Object.values(e.steps),r=n.filter(e=>e.status===`completed`).length;return(0,R.jsxs)(`div`,{className:`space-y-5`,children:[(0,R.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-3 border-b border-line pb-5 text-xs sm:grid-cols-3`,children:[(0,R.jsx)(V,{label:`Current node`,value:String(e.currentNodeIndex)}),(0,R.jsx)(V,{label:`Step progress`,value:`${r}/${n.length} completed`}),(0,R.jsx)(V,{label:`Duration`,value:v(e.updatedAt-e.createdAt)}),(0,R.jsx)(V,{label:`Started`,value:_(e.createdAt)}),(0,R.jsx)(V,{label:`Last transition`,value:_(e.updatedAt)}),(0,R.jsx)(V,{label:`Rollback`,value:e.rollbackStatus??`Not started`})]}),e.failureReason&&(0,R.jsxs)(`div`,{role:`alert`,className:`border-l-2 border-danger bg-danger/[0.06] px-3 py-2 text-xs text-danger`,children:[(0,R.jsx)(`div`,{className:`mb-1 font-medium`,children:`Failure`}),(0,R.jsx)(`p`,{className:`whitespace-pre-wrap`,children:e.failureReason})]}),(0,R.jsx)(ze,{execution:e,onSelect:t}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-faint`,children:`Step state`}),(0,R.jsx)(Fe,{steps:e.steps,onSelect:t})]})]})}function ze({execution:e,onSelect:t}){return!e.parentExecutionId&&!e.definitionHash&&e.committedAt===void 0?null:(0,R.jsxs)(`div`,{className:`grid gap-3 border-b border-line pb-5 text-xs sm:grid-cols-2`,children:[e.parentExecutionId&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-faint`,children:`Parent execution`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>t(e.parentExecutionId),className:`mt-1 break-all font-mono text-accent hover:underline`,children:e.parentExecutionId})]}),e.definitionHash&&(0,R.jsx)(V,{label:`Definition hash`,value:e.definitionHash}),e.committedAt!==void 0&&(0,R.jsx)(V,{label:`Compensation pivot`,value:`Node ${e.committedAt}`}),(0,R.jsx)(`div`,{className:`flex items-end`,children:(0,R.jsx)(c,{status:e.state})})]})}var Be=[{id:`summary`,label:`Summary`},{id:`history`,label:`History`},{id:`payloads`,label:`Payloads`}];function X({repository:e,id:t,kind:n,onSelect:r}){return(0,R.jsx)(Ve,{repository:e,id:t,kind:n,onSelect:r},`${n}:${t}`)}function Ve({repository:e,id:n,kind:r,onSelect:i}){let[a,o]=t(),l=a.get(`tab`),u=se(l)?l:`summary`,{data:d,error:p,loading:h,refetch:g}=f(()=>e.get(n,r),[e,n,r],{intervalMs:5e3});if(h&&!d)return(0,R.jsx)(Z,{children:(0,R.jsx)(x,{label:`Loading execution…`})});if(p&&!d)return(0,R.jsx)(Z,{children:(0,R.jsx)(y,{error:p,onRetry:g})});let _=d?.execution;return _?(0,R.jsxs)(Z,{children:[p&&(0,R.jsx)(m,{message:`Execution refresh failed. Showing the last snapshot.`,onRetry:g}),(0,R.jsx)(`header`,{className:`border-b border-line px-4 py-3`,children:(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Execution`}),(0,R.jsx)(`h2`,{translate:`no`,className:`mt-1 break-all font-mono text-sm font-semibold text-fg`,children:_.id}),(0,R.jsx)(`div`,{className:`mt-1 text-xs text-muted`,children:_.workflowName})]}),(0,R.jsx)(c,{status:_.state})]})}),(0,R.jsx)(`nav`,{"aria-label":`Execution detail`,className:`flex border-b border-line px-2`,children:Be.map(e=>(0,R.jsx)(`button`,{type:`button`,"aria-pressed":u===e.id,onClick:()=>{o(t=>{let n=new URLSearchParams(t);return e.id===`summary`?n.delete(`tab`):n.set(`tab`,e.id),n})},className:s(`border-b-2 px-3 py-2 text-xs font-medium`,u===e.id?`border-accent text-fg`:`border-transparent text-faint hover:text-muted`),children:e.label},e.id))}),(0,R.jsxs)(`div`,{className:`p-4`,"aria-live":`polite`,children:[u===`summary`&&(0,R.jsx)(Re,{execution:_,onSelect:i}),u===`history`&&(0,R.jsx)(U,{execution:_}),u===`payloads`&&(0,R.jsx)(Pe,{execution:_})]})]}):null}function Z({children:e}){return(0,R.jsx)(`section`,{className:`min-w-0 overflow-hidden rounded-lg border border-line bg-surface`,children:e})}function Q({total:e,offset:t,pageSize:n,count:r,onPage:i}){let a=r===0?0:t+1,o=Math.min(t+r,e);return(0,R.jsxs)(`nav`,{"aria-label":`Workflow execution pages`,className:`mt-3 flex items-center justify-between`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:t===0,onClick:()=>i(Math.max(0,t-n)),className:`rounded-lg border border-line px-3 py-1.5 text-xs text-muted disabled:opacity-40`,children:`Previous`}),(0,R.jsxs)(`span`,{className:`text-xs text-faint`,children:[a,`–`,o,` of `,e]}),(0,R.jsx)(`button`,{type:`button`,disabled:t+n>=e,onClick:()=>i(t+n),className:`rounded-lg border border-line px-3 py-1.5 text-xs text-muted disabled:opacity-40`,children:`Next`})]})}var He=e=>e.length>22?`${e.slice(0,12)}…${e.slice(-7)}`:e;function Ue({executions:e,total:t,offset:n,pageSize:r,selected:i,onSelect:a,onPage:o}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-line bg-surface`,children:(0,R.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,R.jsx)(`thead`,{className:`bg-surface-2/80`,children:(0,R.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Workflow / execution`}),(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Status`}),(0,R.jsx)(`th`,{className:`hidden px-3 py-2 font-medium md:table-cell`,children:`Node`}),(0,R.jsx)(`th`,{className:`hidden px-3 py-2 font-medium lg:table-cell`,children:`Elapsed`}),(0,R.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:`Updated`})]})}),(0,R.jsx)(`tbody`,{children:e.map(e=>(0,R.jsx)(We,{execution:e,selected:i?.id===e.id,onSelect:a},e.id))})]})}),(0,R.jsx)(Q,{total:t,offset:n,pageSize:r,count:e.length,onPage:o})]})}function We({execution:e,selected:t,onSelect:n}){return(0,R.jsxs)(`tr`,{className:s(`border-b border-line/70 last:border-0`,t&&`bg-surface-2`),children:[(0,R.jsx)(`td`,{className:`p-0`,children:(0,R.jsxs)(`button`,{type:`button`,onClick:()=>n({id:e.id,source:`page`}),className:`block w-full px-3 py-2.5 text-left focus-visible:outline-2 focus-visible:outline-inset focus-visible:outline-accent`,children:[(0,R.jsx)(`span`,{className:`block truncate font-medium text-fg`,children:e.workflowName}),(0,R.jsx)(`span`,{translate:`no`,title:e.id,className:`mt-0.5 block font-mono text-[11px] text-faint`,children:He(e.id)})]})}),(0,R.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,R.jsx)(c,{status:e.state})}),(0,R.jsx)(`td`,{className:`hidden px-3 py-2.5 font-mono text-xs text-muted md:table-cell`,children:e.currentNodeIndex}),(0,R.jsx)(`td`,{className:`hidden whitespace-nowrap px-3 py-2.5 font-mono text-xs text-muted lg:table-cell`,children:v(e.updatedAt-e.createdAt)}),(0,R.jsx)(`td`,{title:_(e.updatedAt),className:`whitespace-nowrap px-3 py-2.5 text-right text-xs text-muted`,children:h(e.updatedAt)})]})}function Ge({mode:e,rows:t,selected:n,onSelect:r,total:i,offset:a,pageSize:o,onPage:c,clock:l=W}){let u=G(l,e===`waiting`);return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`section`,{className:`overflow-x-auto rounded-lg border border-line bg-surface`,children:(0,R.jsxs)(`table`,{className:`w-full min-w-[560px] text-sm`,children:[(0,R.jsx)(`thead`,{className:`border-b border-line bg-surface-2/80 text-left text-[10px] uppercase tracking-wider text-faint`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e===`archive`?`Execution record`:`Execution`}),(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Workflow`}),(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:Ke(e)}),(0,R.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:qe(e)})]})}),(0,R.jsx)(`tbody`,{children:t.map(t=>(0,R.jsxs)(`tr`,{className:s(`border-b border-line last:border-0`,n?.id===t.id&&`bg-surface-2`),children:[(0,R.jsx)(`td`,{className:`p-0`,children:(0,R.jsx)(`button`,{type:`button`,className:`block w-full px-3 py-3 text-left font-mono text-xs text-fg`,onClick:()=>r({id:t.id,source:`page`}),children:t.id})}),(0,R.jsx)(`td`,{className:`px-3 py-3 text-muted`,children:t.workflowName}),(0,R.jsx)(`td`,{className:`px-3 py-3`,children:(0,R.jsx)(Je,{mode:e,row:t})}),(0,R.jsx)(`td`,{className:`whitespace-nowrap px-3 py-3 text-right text-xs text-muted`,children:$(e,t,u)})]},t.id))})]})}),(0,R.jsx)(Q,{total:i,offset:a,pageSize:o,count:t.length,onPage:c})]})}var Ke=e=>e===`waiting`?`Resume node`:e===`compensation`?`Recovery state`:`Outcome`,qe=e=>e===`archive`?`Archived`:e===`waiting`?`Waiting`:`Updated`;function Je({mode:e,row:t}){return e===`waiting`?(0,R.jsxs)(`span`,{className:`font-mono text-xs text-warning`,children:[`Node `,t.currentNodeIndex]}):(0,R.jsx)(c,{status:t.state})}function $(e,t,n){return e===`archive`?t.archivedAt?_(t.archivedAt):`Unavailable`:e===`waiting`?v(Math.max(0,n-t.updatedAt)):h(t.updatedAt)}function Ye({stats:e,page:t,repository:n,kind:r,selected:i,onSelect:a}){let o=t.executions.filter(e=>[`waiting`,`failed`,`compensation-stuck`].includes(e.state));return(0,R.jsxs)(`div`,{className:`space-y-5`,children:[(0,R.jsx)(Xe,{stats:e}),(0,R.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(320px,0.7fr)_minmax(0,1.3fr)]`,children:[(0,R.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`border-b border-line px-4 py-3`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Needs attention`}),(0,R.jsxs)(`p`,{className:`mt-0.5 text-xs text-faint`,children:[`Waiting, failed, and stuck executions · showing `,o.length,` of `,t.total,`.`]})]}),(0,R.jsx)(Ze,{rows:o,selected:i,onSelect:a})]}),i&&(0,R.jsx)(X,{repository:n,id:i.id,kind:r,onSelect:e=>a({id:e,source:`link`})})]})]})}function Xe({stats:e}){let t=[[`Open executions`,e.activeTotal],[`Waiting for signal`,e.states.waiting],[`Recovery required`,e.states[`compensation-stuck`]+e.states.failed],[`Retained in archive`,e.archiveTotal]];return(0,R.jsx)(`dl`,{className:`grid overflow-hidden rounded-lg border border-line bg-surface sm:grid-cols-2 xl:grid-cols-4`,children:t.map(([e,t])=>(0,R.jsxs)(`div`,{className:`border-b border-line px-4 py-3 sm:border-r xl:border-b-0`,children:[(0,R.jsx)(`dt`,{className:`text-[10px] uppercase tracking-wider text-faint`,children:e}),(0,R.jsx)(`dd`,{className:`mt-1 font-mono text-xl font-semibold text-fg`,children:t})]},e))})}function Ze({rows:e,selected:t,onSelect:n}){return e.length?(0,R.jsx)(`ul`,{className:`divide-y divide-line`,children:e.map(e=>(0,R.jsx)(`li`,{className:t?.id===e.id?`bg-surface-2`:void 0,children:(0,R.jsxs)(`button`,{type:`button`,className:`w-full px-4 py-3 text-left`,onClick:()=>n({id:e.id,source:`page`}),children:[(0,R.jsxs)(`span`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.workflowName}),(0,R.jsx)(`span`,{className:`text-xs text-faint`,children:h(e.updatedAt)})]}),(0,R.jsxs)(`span`,{className:`mt-1 flex items-center justify-between gap-3 font-mono text-[11px] text-faint`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e.id}),(0,R.jsx)(`span`,{children:e.state})]})]})},e.id))}):(0,R.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-muted`,children:`No intervention required.`})}function Qe({repository:e,executionId:t,onApplied:n}){let[r,i]=(0,E.useState)(``),[a,o]=(0,E.useState)(`{}`),s=F({operationGroup:`signal`,scopeKey:t,onApplied:n,onSucceeded:()=>l.success(`Workflow signal accepted`,`${r.trim()} · ${t}`)});return(0,R.jsxs)(`div`,{className:`border-t border-line p-4`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-faint`,children:`Send signal`}),(0,R.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Event name`,(0,R.jsx)(`input`,{"aria-label":`Workflow signal event`,value:r,onChange:e=>i(e.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,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Payload JSON`,(0,R.jsx)(`textarea`,{"aria-label":`Workflow signal payload`,value:a,onChange:e=>o(e.target.value),className:`mt-1 min-h-20 w-full resize-y rounded-lg border border-line bg-surface-2 p-2 font-mono text-xs text-fg`})]})]}),(0,R.jsx)(`button`,{type:`button`,disabled:!r.trim()||!!s.busy,onClick:()=>{let n;try{n=JSON.parse(a)}catch{s.run(`signal`,async()=>{throw Error(`Signal payload must be valid JSON.`)});return}window.confirm(`Send durable signal "${r.trim()}" to ${t}?`)&&s.run(`signal`,()=>e.signal(t,r.trim(),n))},className:`mt-3 rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:s.busy?`Sending…`:`Send durable signal`}),s.error&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:s.error}),s.succeeded&&(0,R.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:`Durable signal accepted; execution and list refreshed.`}),s.result!==void 0&&(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(B,{value:s.result})})]})}function $e({repository:e,controlRepository:t,id:n,onApplied:r,clock:i,pollIntervalMs:a=5e3}){let{data:o,error:s,loading:c,refetch:l}=f(()=>e.get(n,`active`),[e,n],{intervalMs:a});if(c&&!o)return(0,R.jsx)(x,{label:`Loading signal inbox…`});if(s&&!o)return(0,R.jsx)(y,{error:s,onRetry:l});let u=o?.execution;if(!u)return null;let d=Object.entries(u.signals);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(K,{error:s,onRetry:l}),(0,R.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`border-b border-line px-4 py-3`,children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-warning`,children:`Signal inbox`}),(0,R.jsx)(`h2`,{className:`mt-1 break-all font-mono text-sm font-semibold text-fg`,children:u.id})]}),(0,R.jsxs)(`dl`,{className:`grid grid-cols-2 gap-3 border-b border-line p-4 text-xs sm:grid-cols-3`,children:[(0,R.jsx)(V,{label:`Waiting at node`,value:String(u.currentNodeIndex)}),(0,R.jsx)(V,{label:`Parked for`,value:(0,R.jsx)(Ae,{since:u.updatedAt,clock:i})}),(0,R.jsx)(V,{label:`Last transition`,value:_(u.updatedAt)})]}),(0,R.jsxs)(`div`,{className:`p-4`,children:[(0,R.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-faint`,children:`Durable signals`}),d.length?d.map(([e,t])=>(0,R.jsxs)(`div`,{className:`mb-3 last:mb-0`,children:[(0,R.jsx)(`div`,{className:`mb-1 font-mono text-xs text-warning`,children:e}),(0,R.jsx)(B,{value:t})]},e)):(0,R.jsx)(`p`,{className:`text-sm text-muted`,children:`No signal has been persisted yet. The execution remains parked.`})]}),(0,R.jsx)(Qe,{repository:t,executionId:n,onApplied:()=>q(l,r)},n)]})]})}function et(e){return e.section.id===`overview`?(0,R.jsx)(Ye,{...e}):e.section.id===`executions`?(0,R.jsx)(tt,{...e}):(0,R.jsx)(nt,{...e})}function tt({repository:e,kind:t,page:n,selected:r,offset:i,pageSize:a,onSelect:o,onPage:s}){return(0,R.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(390px,0.8fr)_minmax(0,1.4fr)]`,children:[(0,R.jsx)(Ue,{executions:n.executions,total:n.total,offset:i,pageSize:a,selected:r,onSelect:o,onPage:s}),r&&(0,R.jsx)(X,{repository:e,id:r.id,kind:t,onSelect:e=>o({id:e,source:`link`})})]})}function nt(e){let t=e.section.id;return(0,R.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(420px,0.95fr)_minmax(0,1.05fr)]`,children:[(0,R.jsx)(Ge,{mode:t,rows:e.page.executions,selected:e.selected,onSelect:e.onSelect,total:e.page.total,offset:e.offset,pageSize:e.pageSize,onPage:e.onPage}),e.selected&&(0,R.jsx)(rt,{...e,id:e.selected.id})]})}function rt({section:e,repository:t,controlRepository:n,onRefresh:r,id:i}){return e.id===`waiting`?(0,R.jsx)($e,{repository:t,controlRepository:n,id:i,onApplied:r}):e.id===`compensation`?(0,R.jsx)(Ne,{repository:t,controlRepository:n,id:i,onApplied:r}):(0,R.jsx)(je,{repository:t,id:i})}function it({repository:e=fe,controlRepository:t=P}){let{pathname:n}=r(),i=ee(n),a=pe(i),{kind:o,workflowName:s,state:c,offset:l,selected:u,update:d,select:p}=a,h={kind:o,workflowName:s||void 0,state:c||void 0,limit:25,offset:l},{data:_,error:v,loading:y,refetch:b}=f(()=>i.id===`overview`?ie(e,25):re(e,h),[e,i.id,o,s,c,l],{intervalMs:5e3});(0,E.useEffect)(()=>{let e=_?.page.total;if(e===void 0||l===0)return;let t=e===0?0:Math.floor((e-1)/25)*25;l>t&&d({offset:t,executionId:null,tab:`summary`},!0)},[_?.page.total,l,d]),(0,E.useEffect)(()=>{let e=_?.page.executions;if(e){let t=i.id===`overview`?e.filter(e=>[`waiting`,`failed`,`compensation-stuck`].includes(e.state)):e,n=te(u,t);n?.id!==u?.id&&p(n,!0)}},[_?.page.executions,i.id,u,p]);let x=_?.stats,S=_?.page;return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(g,{title:(0,R.jsxs)(R.Fragment,{children:[`Workflow `,(0,R.jsxs)(`span`,{className:`text-faint`,children:[`/ `,i.label]})]}),description:i.description,live:!(!_||v),actions:(0,R.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Refresh`})}),i.id===`overview`&&(0,R.jsx)(ye,{repository:t,onApplied:b}),i.id===`archive`&&(0,R.jsx)(he,{repository:t,onApplied:b}),i.id===`executions`&&x&&(0,R.jsx)(_e,{stats:x}),(0,R.jsx)(Ee,{section:i,kind:o,workflowName:s,state:c,stats:x??void 0,total:S?.total,onKind:e=>{a.update({kind:e,offset:0,executionId:null,tab:`summary`},!1)},onWorkflowName:e=>{a.update({workflowName:e,offset:0,executionId:null,tab:`summary`},!1)},onState:e=>{a.update({state:e,offset:0,executionId:null,tab:`summary`},!1)}}),v&&_&&(0,R.jsx)(m,{message:`Workflow refresh failed — showing the last snapshot.`,onRetry:b}),(0,R.jsx)(at,{repository:e,controlRepository:t,section:i,stats:x,kind:o,page:S,error:v,loading:y,dataPresent:!!_,selected:u,offset:l,onRetry:b,onSelect:e=>a.select(e),onPage:e=>{a.update({offset:e,executionId:null,tab:`summary`})}})]})}function at({repository:e,controlRepository:t,section:n,stats:r,kind:i,page:a,error:o,loading:s,dataPresent:c,selected:l,offset:u,onRetry:d,onSelect:f,onPage:m}){return o&&!c?(0,R.jsx)(y,{error:o,onRetry:d}):s&&!c?(0,R.jsx)(x,{label:`Loading workflows…`}):a?.available?a.executions.length===0&&a.total>0&&u>0?(0,R.jsx)(x,{label:`Loading workflow page…`}):a.executions.length===0?(0,R.jsx)(p,{title:`No executions match these filters`,hint:`Change the store, workflow, or state filter.`}):r?(0,R.jsx)(et,{section:n,repository:e,controlRepository:t,kind:i,stats:r,page:a,selected:l,offset:u,pageSize:25,onSelect:f,onPage:m,onRefresh:d}):null:(0,R.jsx)(p,{title:`Workflow store not initialized`,hint:`Start a Bunqueue Workflow Engine with this server dataPath; its official workflow_executions tables will appear here automatically.`})}export{it as Workflows};
@@ -1 +1 @@
1
- import{a as e,i as t}from"./connectionStore-CVjQyIZv.js";import{a as n,n as r,r as i,s as a}from"./upstreamPaths-DQeKSxGc.js";var o=class extends Error{status;constructor(e,t){super(e),this.status=t,this.name=`ApiError`}},s=3e4;async function c(n,r,i=!0,a=[],c=`json`){let l=AbortSignal.timeout(s),u=r?.signal?AbortSignal.any([r.signal,l]):l,d=new Headers(t());r?.headers&&new Headers(r.headers).forEach((e,t)=>{d.set(t,e)}),r?.body!=null&&!d.has(`Content-Type`)&&d.set(`Content-Type`,`application/json`);let f;try{f=await fetch(e()+n,{...r,headers:d,signal:u})}catch(e){throw l.aborted&&!r?.signal?.aborted||e?.name===`TimeoutError`?new o(`Request timed out`,0):e}if(!f.ok&&!a.includes(f.status)){let e=`HTTP ${f.status}`;try{let t=await f.json();t?.error&&(e=t.error)}catch{}throw new o(e,f.status)}if(f.status===204)return;let p;try{p=await f.text()}catch(e){throw l.aborted&&!r?.signal?.aborted?new o(`Request timed out`,0):e}if(!p)return;if(c===`text`)return p;let m;try{m=JSON.parse(p)}catch{throw new o(`Invalid JSON response (HTTP ${f.status})`,f.status)}if(i&&m&&typeof m==`object`&&m.ok===!1){let e=m.error;throw new o(e??`Operation failed`,f.status)}return m}var l=a,u=(e,t)=>c(e,{method:`POST`,body:t?JSON.stringify(t):void 0}),d=(e,t)=>c(e,{method:`PUT`,body:t?JSON.stringify(t):void 0}),f=e=>c(e,{method:`DELETE`}),p={overview:()=>c(`/dashboard`),queues:(e=200,t=0)=>c(`/dashboard/queues?limit=${e}&offset=${t}`),queueDetail:(e,t=!0)=>c(`/dashboard/queues/${l(e)}?includeJobs=${t}`),stats:()=>c(`/stats`),storage:()=>c(`/storage`,void 0,!1),health:()=>c(`/health`,void 0,!1,[503]),healthz:()=>c(`/healthz`,void 0,!0,[],`text`),live:()=>c(`/live`,void 0,!0,[],`text`),ready:()=>c(`/ready`,void 0,!1,[503]),metrics:()=>c(`/metrics`),jobsList:(e,t={})=>{let n=new URLSearchParams;return t.states?.length&&n.set(`states`,t.states.join(`,`)),n.set(`limit`,String(t.limit??50)),n.set(`offset`,String(t.offset??0)),c(`/queues/${l(e)}/jobs/list?${n.toString()}`)},job:e=>c(`/jobs/${n(e)}`),cancelJob:e=>f(`/jobs/${n(e)}`),promoteJob:e=>u(`/jobs/${n(e)}/promote`),retryJob:e=>u(`/jobs/${n(e)}/move-to-wait`),pause:e=>u(`/queues/${l(e)}/pause`),resume:e=>u(`/queues/${l(e)}/resume`),drain:e=>u(`/queues/${l(e)}/drain`),obliterate:e=>u(`/queues/${l(e)}/obliterate`),clean:(e,t=0,n=1e3)=>u(`/queues/${l(e)}/clean`,{grace:t,limit:n}),retryCompleted:e=>{throw TypeError(`Completed-job requeue is unavailable in Bunqueue v2.9.3 because flow dependency registration is not rebuilt.`)},setRateLimit:(e,t)=>d(`/queues/${l(e)}/rate-limit`,{limit:t}),clearRateLimit:e=>f(`/queues/${l(e)}/rate-limit`),setConcurrency:(e,t)=>d(`/queues/${l(e)}/concurrency`,{concurrency:t}),clearConcurrency:e=>f(`/queues/${l(e)}/concurrency`),dlq:(e,t=50,n=0)=>c(`/queues/${l(e)}/dlq?limit=${t}&offset=${n}`),dlqStats:e=>c(`/queues/${l(e)}/dlq/stats`),retryDlq:e=>{throw TypeError(`DLQ retry is unavailable in Bunqueue v2.9.3 because the endpoint has no atomic flow-safety precondition.`)},purgeDlq:e=>u(`/queues/${l(e)}/dlq/purge`),crons:()=>c(`/crons`),deleteCron:e=>f(`/crons/${r(e,`Cron name`,256)}`),workers:()=>c(`/workers`),eventsUrl:t=>e()+(t?`/events/queues/${i(t)}`:`/events`)};export{p as t};
1
+ import{a as e,i as t}from"./connectionStore-B946Fhuv.js";import{a as n,n as r,r as i,s as a}from"./upstreamPaths-DQeKSxGc.js";var o=class extends Error{status;constructor(e,t){super(e),this.status=t,this.name=`ApiError`}},s=3e4;async function c(n,r,i=!0,a=[],c=`json`){let l=AbortSignal.timeout(s),u=r?.signal?AbortSignal.any([r.signal,l]):l,d=new Headers(t());r?.headers&&new Headers(r.headers).forEach((e,t)=>{d.set(t,e)}),r?.body!=null&&!d.has(`Content-Type`)&&d.set(`Content-Type`,`application/json`);let f;try{f=await fetch(e()+n,{...r,headers:d,signal:u})}catch(e){throw l.aborted&&!r?.signal?.aborted||e?.name===`TimeoutError`?new o(`Request timed out`,0):e}if(!f.ok&&!a.includes(f.status)){let e=`HTTP ${f.status}`;try{let t=await f.json();t?.error&&(e=t.error)}catch{}throw new o(e,f.status)}if(f.status===204)return;let p;try{p=await f.text()}catch(e){throw l.aborted&&!r?.signal?.aborted?new o(`Request timed out`,0):e}if(!p)return;if(c===`text`)return p;let m;try{m=JSON.parse(p)}catch{throw new o(`Invalid JSON response (HTTP ${f.status})`,f.status)}if(i&&m&&typeof m==`object`&&m.ok===!1){let e=m.error;throw new o(e??`Operation failed`,f.status)}return m}var l=a,u=(e,t)=>c(e,{method:`POST`,body:t?JSON.stringify(t):void 0}),d=(e,t)=>c(e,{method:`PUT`,body:t?JSON.stringify(t):void 0}),f=e=>c(e,{method:`DELETE`}),p={overview:()=>c(`/dashboard`),queues:(e=200,t=0)=>c(`/dashboard/queues?limit=${e}&offset=${t}`),queueDetail:(e,t=!0)=>c(`/dashboard/queues/${l(e)}?includeJobs=${t}`),stats:()=>c(`/stats`),storage:()=>c(`/storage`,void 0,!1),health:()=>c(`/health`,void 0,!1,[503]),healthz:()=>c(`/healthz`,void 0,!0,[],`text`),live:()=>c(`/live`,void 0,!0,[],`text`),ready:()=>c(`/ready`,void 0,!1,[503]),metrics:()=>c(`/metrics`),jobsList:(e,t={})=>{let n=new URLSearchParams;return t.states?.length&&n.set(`states`,t.states.join(`,`)),n.set(`limit`,String(t.limit??50)),n.set(`offset`,String(t.offset??0)),c(`/queues/${l(e)}/jobs/list?${n.toString()}`)},job:e=>c(`/jobs/${n(e)}`),cancelJob:e=>f(`/jobs/${n(e)}`),promoteJob:e=>u(`/jobs/${n(e)}/promote`),retryJob:e=>u(`/jobs/${n(e)}/move-to-wait`),pause:e=>u(`/queues/${l(e)}/pause`),resume:e=>u(`/queues/${l(e)}/resume`),drain:e=>u(`/queues/${l(e)}/drain`),obliterate:e=>u(`/queues/${l(e)}/obliterate`),clean:(e,t=0,n=1e3)=>u(`/queues/${l(e)}/clean`,{grace:t,limit:n}),retryCompleted:e=>{throw TypeError(`Completed-job requeue is unavailable in Bunqueue v2.9.3 because flow dependency registration is not rebuilt.`)},setRateLimit:(e,t)=>d(`/queues/${l(e)}/rate-limit`,{limit:t}),clearRateLimit:e=>f(`/queues/${l(e)}/rate-limit`),setConcurrency:(e,t)=>d(`/queues/${l(e)}/concurrency`,{concurrency:t}),clearConcurrency:e=>f(`/queues/${l(e)}/concurrency`),dlq:(e,t=50,n=0)=>c(`/queues/${l(e)}/dlq?limit=${t}&offset=${n}`),dlqStats:e=>c(`/queues/${l(e)}/dlq/stats`),retryDlq:e=>{throw TypeError(`DLQ retry is unavailable in Bunqueue v2.9.3 because the endpoint has no atomic flow-safety precondition.`)},purgeDlq:e=>u(`/queues/${l(e)}/dlq/purge`),crons:()=>c(`/crons`),deleteCron:e=>f(`/crons/${r(e,`Cron name`,256)}`),workers:()=>c(`/workers`),eventsUrl:t=>e()+(t?`/events/queues/${i(t)}`:`/events`)};export{p as t};
@@ -1 +1 @@
1
- import{t as e}from"./api-D9aT0ND7.js";var t=`__all__`,n=[`all`,`waiting`,`active`,`completed`,`failed`],r=500,i=20,a=r*i;function o(e,t,n){if(typeof e!=`object`||!e||e.ok!==!0||!Array.isArray(e.queues)||!Number.isSafeInteger(e.total)||e.total<0||e.total>a||n!==null&&e.total!==n||e.offset!==t||e.limit!==r||e.queues.length!==Math.min(r,e.total-t)||e.queues.length>r||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 s(){let t=await e.queues(r,0);o(t,0,null);let n=[...t.queues],s=new Set;for(let e of n){if(s.has(e.name))throw Error(`Queue discovery returned duplicate queue ${e.name}`);s.add(e.name)}let c=t.total,l=1;for(;n.length<c;){if(l>=i||n.length>=a)throw Error(`Queue discovery exceeds the safety limit of ${a}`);let t=n.length,u=await e.queues(r,t);o(u,t,c);for(let e of u.queues){if(s.has(e.name))throw Error(`Queue discovery pages overlap at queue ${e.name}`);s.add(e.name),n.push(e)}l+=1}return{...t,queues:n,total:c,limit:n.length,offset:0}}function c(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e.name;return typeof t==`string`&&t.length>0?t:null}export{c as i,n,s as r,t};
1
+ import{t as e}from"./api-CCgfskjt.js";var t=`__all__`,n=[`all`,`waiting`,`active`,`completed`,`failed`],r=500,i=20,a=r*i;function o(e,t,n){if(typeof e!=`object`||!e||e.ok!==!0||!Array.isArray(e.queues)||!Number.isSafeInteger(e.total)||e.total<0||e.total>a||n!==null&&e.total!==n||e.offset!==t||e.limit!==r||e.queues.length!==Math.min(r,e.total-t)||e.queues.length>r||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 s(){let t=await e.queues(r,0);o(t,0,null);let n=[...t.queues],s=new Set;for(let e of n){if(s.has(e.name))throw Error(`Queue discovery returned duplicate queue ${e.name}`);s.add(e.name)}let c=t.total,l=1;for(;n.length<c;){if(l>=i||n.length>=a)throw Error(`Queue discovery exceeds the safety limit of ${a}`);let t=n.length,u=await e.queues(r,t);o(u,t,c);for(let e of u.queues){if(s.has(e.name))throw Error(`Queue discovery pages overlap at queue ${e.name}`);s.add(e.name),n.push(e)}l+=1}return{...t,queues:n,total:c,limit:n.length,offset:0}}function c(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e.name;return typeof t==`string`&&t.length>0?t:null}export{c as i,n,s as r,t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{h as t}from"./react-vendor-08inPAVO.js";var n=e(t(),1),r=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},i=(e=>e?r(e):r),a=e=>e;function o(e,t=a){let r=n.useSyncExternalStore(e.subscribe,n.useCallback(()=>t(e.getState()),[e,t]),()=>t(e.getInitialState()));return n.useDebugValue(r),r}var s=e=>{let t=i(e),n=e=>o(t,e);return Object.assign(n,t),n},c=(e=>e?s(e):s);function l(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var u=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return u(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return u(t)(e)}}}},d=(e,t)=>(n,r,i)=>{let a={storage:l(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},o=!1,s=0,c=new Set,d=new Set,f=a.storage;if(!f)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...e)},r,i);let p=()=>{let e=a.partialize({...r()});return f.setItem(a.name,{state:e,version:a.version})},m=i.setState;i.setState=(...e)=>(m(...e),p());let h=e((...e)=>(n(...e),p()),r,i);i.getInitialState=()=>h;let g,_=()=>{if(!f)return;let e=++s;o=!1,c.forEach(e=>e(r()??h));let t=a.onRehydrateStorage?.call(a,r()??h)||void 0;return u(f.getItem.bind(f))(a.name).then(e=>{if(e){if(typeof e.version==`number`&&e.version!==a.version){if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state]}return[!1,void 0]}).then(t=>{if(e!==s)return;let[i,o]=t;if(g=a.merge(o,r()??h),n(g,!0),i)return p()}).then(()=>{e===s&&(t?.(r(),void 0),g=r(),o=!0,d.forEach(e=>e(g)))}).catch(n=>{e===s&&t?.(void 0,n)})};return i.persist={setOptions:e=>{a={...a,...e},e.storage&&(f=e.storage)},clearStorage:()=>{++s,f?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>_(),hasHydrated:()=>o,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(d.add(e),()=>{d.delete(e)})},a.skipHydration||_(),g||h},f=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function p(e,t=!1){try{let n=globalThis.localStorage??null;return!n&&t&&e.reportMissingWrites&&e.onError?.(Error(`localStorage is unavailable`)),n}catch(t){return e.onError?.(t),null}}function m(e,t){try{let n=JSON.parse(e),r=f(n)?n:{},i=typeof r.version==`number`?r.version:void 0,a=t.sanitizeState(`state`in r?r.state:r,i);return{hydration:JSON.stringify({state:a,...i===void 0?{}:{version:i}}),canonical:JSON.stringify({state:a,version:t.version})}}catch(e){return t.onError?.(e),null}}function h(e){let t=t=>e.onError?.(t);return{getItem(n){let r=p(e);if(!r)return null;let i;try{i=r.getItem(n)}catch(e){return t(e),null}if(i===null||n!==e.key)return i;let a=m(i,e);if(!a){try{r.removeItem(n)}catch(e){t(e)}return null}if(i!==a.canonical)try{r.setItem(n,a.canonical)}catch(e){t(e);try{r.removeItem(n)}catch(e){t(e)}}return a.hydration},setItem(n,r){let i=p(e,!0);if(i)try{i.setItem(n,r)}catch(e){t(e)}},removeItem(n){let r=p(e);if(r)try{r.removeItem(n)}catch(e){t(e)}}}}var g=/^\/(?:[A-Za-z0-9._~-]+(?:\/[A-Za-z0-9._~-]+)*)?\/?$/;function _(e){try{return globalThis[e]}catch{return}}function v(e){if(typeof e!=`string`)return null;let t=e.trim();return!g.test(t)||t.split(`/`).some(e=>e===`.`||e===`..`)?null:t.replace(/\/+$/,``)||`/`}function y(e,t){return v(e)??v(t)??`/`}var b=`Use an http(s) URL without credentials, query, or fragment, or a non-root path starting with '/'.`,x=`https://bunqueue-dashboard.invalid`,ee=/\s/u;function te(e){return[...e].some(e=>{let t=e.charCodeAt(0);return e===`\\`||ee.test(e)||t<32||t===127})}function S(e){if(typeof e!=`string`)return null;let t=e.trim();if(!t||t.includes(`?`)||t.includes(`#`)||te(t))return null;if(t.startsWith(`/`)){if(t.startsWith(`//`))return null;try{let e=new URL(t,x),n=e.pathname.replace(/\/+$/,``);return e.origin!==x||!n||n===`/`||n.startsWith(`//`)?null:n}catch{return null}}let n=t.match(/^https?:\/\//i)?.[0];if(!n)return null;let r=t.slice(n.length).split(`/`,1)[0];if(!r||r.includes(`@`))return null;try{let e=new URL(t);if(e.protocol!==`http:`&&e.protocol!==`https:`||!e.hostname||e.username||e.password)return null;let n=e.pathname.replace(/\/+$/,``);return n.startsWith(`//`)?null:`${e.origin}${n}`}catch{return null}}function C(e,t){return S(e)??S(t)??`/api`}function w(e,t){return S(e)??S(t)??`http://localhost:6800`}function T(e,t){return S(e)??t}function E(e){return typeof e==`string`?e.trim():``}var ne=`default`,re=64,D=/^[a-zA-Z0-9_-]{1,64}$/u;function O(e){return{id:ne,name:`Local Bunqueue`,baseUrl:e.baseUrl,agentBaseUrl:e.agentBaseUrl}}function k(e,t){if(typeof e!=`string`)return t;let n=[...e].map(e=>{let t=e.codePointAt(0)??0;return t<=31||t===127?` `:e}).join(``).trim();return n?[...n].slice(0,re).join(``):t}function A(e,t){return typeof e==`string`&&D.test(e)?e:t}function j(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return null;let r=e,i=S(r.baseUrl);return i?{id:A(r.id,`profile-${t+1}`),name:k(r.name,`Bunqueue ${t+1}`),baseUrl:i,agentBaseUrl:T(r.agentBaseUrl,n.agentBaseUrl)}:null}function M(e,t){if(!Array.isArray(e))return[O(t)];let n=[],r=new Set;for(let[i,a]of e.slice(0,32).entries()){let e=j(a,i,t);e&&!r.has(e.id)&&(r.add(e.id),n.push(e))}return n.length?n:[O(t)]}function N(e,t,n){let r=e&&typeof e==`object`&&!Array.isArray(e)?e:{},i=M(r.profiles,t),a=typeof r.activeProfileId==`string`?r.activeProfileId:``;return{profiles:i,activeProfileId:i.some(e=>e.id===a)?a:i[0].id,refreshMs:n(r.refreshMs)}}function P(e,t,n){let r=e&&typeof e==`object`&&!Array.isArray(e)?e:{};if(Array.isArray(r.profiles))return N(r,t,n);let i=O({...t,baseUrl:T(r.baseUrl,t.baseUrl)});return{profiles:[i],activeProfileId:i.id,refreshMs:n(r.refreshMs)}}function ie(e){let t=new Set(e.map(e=>e.id)),n=globalThis.crypto?.randomUUID?.().replaceAll(`-`,``).slice(0,16)||`${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`,r=`node-${n}`,i=2;for(;t.has(r);)r=`node-${n}-${i++}`;return r}var F=`bq-dash-connection`,I=3e3,ae=500,oe=6e4,L={baseUrl:C(void 0,_(`__BUNQUEUE_API_URL__`)),agentBaseUrl:w(_(`__BUNQUEUE_AGENT_URL__`),void 0),refreshMs:I},R=O(L);function z(e){return typeof e!=`number`||!Number.isFinite(e)?I:Math.min(oe,Math.max(ae,Math.round(e)))}function B(e){let t=e;return N({profiles:t?.profiles??(t?.baseUrl?[{...R,baseUrl:t.baseUrl}]:void 0),activeProfileId:t?.activeProfileId,refreshMs:t?.refreshMs},L,z)}function V(e,t){if(t!==void 0&&t<4)return H(e,t);let n=e;return Array.isArray(n?.profiles)?N(e,L,z):P(e,L,z)}function H(e,t,n=L.baseUrl){let r={...L,baseUrl:C(void 0,n)},i=e&&typeof e==`object`&&!Array.isArray(e)?e:{},a=t<3&&i.baseUrl===`/api`?{...i,baseUrl:r.baseUrl}:e;return t<4?P(a,r,z):N(e,r,z)}var U=null;function W(e){U=e instanceof Error?e:Error(String(e))}function G(){U=null}function K(){return U?{persisted:!1,error:`${U.name&&U.name!==`Error`?`${U.name}: `:``}${U.message}`}:{persisted:!0}}var se=l(()=>h({key:F,version:4,sanitizeState:V,onError:W,reportMissingWrites:!0})),q=new Map;function J(e){return e.profiles.find(t=>t.id===e.activeProfileId)??e.profiles[0]??R}function Y(e,t){let n=J(e),r={...n,...t,id:n.id};return e.profiles.map(e=>e.id===n.id?r:e)}function X(e,t,n){q.set(e,{token:E(t),agentToken:E(n)})}var Z=c()(d((e,t)=>({profiles:[R],activeProfileId:R.id,baseUrl:R.baseUrl,agentBaseUrl:R.agentBaseUrl,token:``,agentToken:``,refreshMs:L.refreshMs,saveConnection:n=>{G();let r=t(),i=J(r),a={...i,name:k(n.name,i.name),baseUrl:T(n.baseUrl,L.baseUrl),agentBaseUrl:T(n.agentBaseUrl??i.agentBaseUrl,L.agentBaseUrl)};return X(i.id,n.token,n.agentToken),e({profiles:Y(r,a),baseUrl:a.baseUrl,agentBaseUrl:a.agentBaseUrl,token:E(n.token),agentToken:E(n.agentToken)}),K()},addProfile:n=>{let r=t();if(r.profiles.length>=32)return{persisted:!1,error:`At most 32 Bunqueue nodes are supported.`};G();let i=ie(r.profiles),a={id:i,name:k(n.name,`Bunqueue ${r.profiles.length+1}`),baseUrl:T(n.baseUrl,L.baseUrl),agentBaseUrl:T(n.agentBaseUrl,L.agentBaseUrl)};return X(i,n.token,n.agentToken),e({profiles:[...r.profiles,a],activeProfileId:i,baseUrl:a.baseUrl,agentBaseUrl:a.agentBaseUrl,token:E(n.token),agentToken:E(n.agentToken)}),{...K(),id:i}},activateProfile:n=>{let r=t(),i=r.profiles.find(e=>e.id===n);if(!i)return!1;X(r.activeProfileId,r.token,r.agentToken);let a=q.get(n)??{token:``,agentToken:``};return e({activeProfileId:n,baseUrl:i.baseUrl,agentBaseUrl:i.agentBaseUrl,...a}),!0},removeProfile:n=>{let r=t();if(r.profiles.length===1||!r.profiles.some(e=>e.id===n))return!1;q.delete(n);let i=r.profiles.filter(e=>e.id!==n);if(n!==r.activeProfileId)return e({profiles:i}),!0;let a=i[0],o=q.get(a.id)??{token:``,agentToken:``};return e({profiles:i,activeProfileId:a.id,baseUrl:a.baseUrl,agentBaseUrl:a.agentBaseUrl,...o}),!0},setBaseUrl:t=>e(e=>{let n=T(t,L.baseUrl);return{baseUrl:n,profiles:Y(e,{baseUrl:n})}}),setAgentBaseUrl:t=>e(e=>{let n=T(t,L.agentBaseUrl);return{agentBaseUrl:n,profiles:Y(e,{agentBaseUrl:n})}}),setToken:t=>e(e=>{let n=E(t);return X(e.activeProfileId,n,e.agentToken),{token:n}}),setAgentToken:t=>e(e=>{let n=E(t);return X(e.activeProfileId,e.token,n),{agentToken:n}}),setRefreshMs:t=>e({refreshMs:z(t)})}),{name:F,storage:se,version:4,partialize:B,migrate:H,merge:(e,t)=>{q.clear();let n=V(e),r=n.profiles.find(e=>e.id===n.activeProfileId)??n.profiles[0];return{...t,...n,baseUrl:r.baseUrl,agentBaseUrl:r.agentBaseUrl,token:``,agentToken:``}}}));function ce(e){let t=Z.getState(),n=t.profiles.find(t=>t.id===e);if(!n)return null;let r=e===t.activeProfileId?{token:E(t.token),agentToken:E(t.agentToken)}:q.get(e)??{token:``,agentToken:``};return Object.freeze({...n,...r})}var le=()=>T(Z.getState().baseUrl,L.baseUrl),ue=()=>T(Z.getState().agentBaseUrl,L.agentBaseUrl),Q=()=>$(Z.getState().token),de=()=>$(Z.getState().agentToken);function $(e){let t=E(e);return t?{Authorization:`Bearer ${t}`}:{}}export{le as a,S as c,h as d,l as f,Q as i,y as l,c as m,de as n,Z as o,d as p,ue as r,b as s,ce as t,_ as u};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{h as t}from"./react-vendor-08inPAVO.js";import{o as n}from"./connectionStore-B946Fhuv.js";var r=e(t(),1),i=0,a=new Set;n.subscribe((e,t)=>{if(e.baseUrl!==t.baseUrl||e.agentBaseUrl!==t.agentBaseUrl||e.activeProfileId!==t.activeProfileId||e.token!==t.token||e.agentToken!==t.agentToken){i+=1;for(let e of a)e()}});function o(){return i}function s(){return(0,r.useSyncExternalStore)(c,o,o)}function c(e){return a.add(e),()=>a.delete(e)}export{s as n,o as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-CFL9l8LK.js";import{r}from"./StatusBadge-DereLzOj.js";var i=e(t(),1),a=n();function o({children:e,htmlFor:t}){return(0,a.jsx)(`label`,{htmlFor:t,className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e})}function s({label:e,hint:t,htmlFor:n,children:r}){let s=(0,i.useId)(),c=r,d=n;if(!n&&(0,i.isValidElement)(r)){let e=r;(typeof e.type==`string`&&[`input`,`select`,`textarea`].includes(e.type)||e.type===l||e.type===u)&&(d=e.props.id??s,c=e.props.id?e:(0,i.cloneElement)(e,{id:s}))}return(0,a.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,a.jsx)(o,{htmlFor:d,children:e}),c,t&&(0,a.jsx)(`p`,{className:`text-xs leading-relaxed text-faint`,children:t})]})}var c=`h-9 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg placeholder:text-faint transition-colors focus-visible:border-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`;function l({className:e,...t}){return(0,a.jsx)(`input`,{className:r(c,`w-full`,e),...t})}function u({className:e,children:t,...n}){return(0,a.jsx)(`select`,{className:r(c,`w-full cursor-pointer pr-8`,e),...n,children:t})}function d({checked:e,onChange:t,label:n,disabled:i}){return(0,a.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":n,disabled:i,onClick:()=>t(!e),className:r(`relative inline-flex h-6 w-11 items-center rounded-full transition-colors`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,e?`bg-accent`:`bg-surface-2 border border-line`,i&&`opacity-40`),children:(0,a.jsx)(`span`,{className:r(`inline-block size-4 transform rounded-full bg-white shadow transition-transform`,e?`translate-x-6`:`translate-x-1`)})})}function f({options:e,value:t,onChange:n,disabled:i,label:o=`View options`}){return(0,a.jsxs)(`fieldset`,{className:`inline-flex items-center gap-1 rounded-lg border border-line bg-surface p-1`,children:[(0,a.jsx)(`legend`,{className:`sr-only`,children:o}),e.map(e=>(0,a.jsx)(`button`,{type:`button`,"aria-pressed":t===e,disabled:i,onClick:()=>n(e),className:r(`rounded-md px-3 py-1 text-xs font-medium capitalize transition-colors`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,t===e?`bg-surface-2 text-fg`:`text-muted hover:text-fg`,i&&`opacity-40`),children:e},e))]})}export{u as a,f as i,l as n,d as o,o as r,s as t};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{h as t,t as n}from"./react-vendor-08inPAVO.js";import{r}from"./StatusBadge-D-mexaga.js";var i=e(t(),1),a=n();function o({children:e,htmlFor:t}){return(0,a.jsx)(`label`,{htmlFor:t,className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e})}function s({label:e,hint:t,htmlFor:n,children:r}){let s=(0,i.useId)(),c=r,d=n;if(!n&&(0,i.isValidElement)(r)){let e=r;(typeof e.type==`string`&&[`input`,`select`,`textarea`].includes(e.type)||e.type===l||e.type===u)&&(d=e.props.id??s,c=e.props.id?e:(0,i.cloneElement)(e,{id:s}))}return(0,a.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,a.jsx)(o,{htmlFor:d,children:e}),c,t&&(0,a.jsx)(`p`,{className:`text-xs leading-relaxed text-faint`,children:t})]})}var c=`h-9 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg placeholder:text-faint transition-colors focus-visible:border-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`;function l({className:e,...t}){return(0,a.jsx)(`input`,{className:r(c,`w-full`,e),...t})}function u({className:e,children:t,...n}){return(0,a.jsx)(`select`,{className:r(c,`w-full cursor-pointer pr-8`,e),...n,children:t})}function d({checked:e,onChange:t,label:n,disabled:i}){return(0,a.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":n,disabled:i,onClick:()=>t(!e),className:r(`relative inline-flex h-6 w-11 items-center rounded-full transition-colors`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,e?`bg-accent`:`bg-surface-2 border border-line`,i&&`opacity-40`),children:(0,a.jsx)(`span`,{className:r(`inline-block size-4 transform rounded-full bg-white shadow transition-transform`,e?`translate-x-6`:`translate-x-1`)})})}function f({options:e,value:t,onChange:n,disabled:i,label:o=`View options`}){return(0,a.jsxs)(`fieldset`,{className:`inline-flex items-center gap-1 rounded-lg border border-line bg-surface p-1`,children:[(0,a.jsx)(`legend`,{className:`sr-only`,children:o}),e.map(e=>(0,a.jsx)(`button`,{type:`button`,"aria-pressed":t===e,disabled:i,onClick:()=>n(e),className:r(`rounded-md px-3 py-1 text-xs font-medium capitalize transition-colors`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,t===e?`bg-surface-2 text-fg`:`text-muted hover:text-fg`,i&&`opacity-40`),children:e},e))]})}export{u as a,f as i,l as n,d as o,o as r,s as t};
@@ -1 +1 @@
1
- import{t as e}from"./react-vendor-CFL9l8LK.js";var t=e();function n({children:e,...n}){return(0,t.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,...n,children:e})}var r=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`path`,{d:`M3 3v18h18`}),(0,t.jsx)(`rect`,{x:`7`,y:`12`,width:`3`,height:`6`}),(0,t.jsx)(`rect`,{x:`12`,y:`8`,width:`3`,height:`10`}),(0,t.jsx)(`rect`,{x:`17`,y:`5`,width:`3`,height:`13`})]}),i=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`line`,{x1:`8`,y1:`6`,x2:`21`,y2:`6`}),(0,t.jsx)(`line`,{x1:`8`,y1:`12`,x2:`21`,y2:`12`}),(0,t.jsx)(`line`,{x1:`8`,y1:`18`,x2:`21`,y2:`18`}),(0,t.jsx)(`line`,{x1:`3`,y1:`6`,x2:`3.01`,y2:`6`}),(0,t.jsx)(`line`,{x1:`3`,y1:`12`,x2:`3.01`,y2:`12`}),(0,t.jsx)(`line`,{x1:`3`,y1:`18`,x2:`3.01`,y2:`18`})]}),a=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`rect`,{x:`2`,y:`7`,width:`20`,height:`14`,rx:`2`}),(0,t.jsx)(`path`,{d:`M16 7V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2`})]}),o=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0Z`}),(0,t.jsx)(`line`,{x1:`12`,y1:`9`,x2:`12`,y2:`13`}),(0,t.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`})]}),s=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,t.jsx)(`polyline`,{points:`12 7 12 12 15 14`})]}),c=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`path`,{d:`M3 3v18h18`}),(0,t.jsx)(`path`,{d:`m19 9-5 5-4-4-3 3`})]}),l=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`rect`,{x:`4`,y:`4`,width:`16`,height:`8`,rx:`2`}),(0,t.jsx)(`rect`,{x:`4`,y:`14`,width:`16`,height:`6`,rx:`2`}),(0,t.jsx)(`line`,{x1:`8`,y1:`8`,x2:`8.01`,y2:`8`}),(0,t.jsx)(`line`,{x1:`8`,y1:`17`,x2:`8.01`,y2:`17`})]}),u=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`path`,{d:`M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9`}),(0,t.jsx)(`path`,{d:`M13.73 21a2 2 0 0 1-3.46 0`})]}),d=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`line`,{x1:`8`,y1:`6`,x2:`21`,y2:`6`}),(0,t.jsx)(`line`,{x1:`8`,y1:`12`,x2:`21`,y2:`12`}),(0,t.jsx)(`line`,{x1:`8`,y1:`18`,x2:`21`,y2:`18`}),(0,t.jsx)(`path`,{d:`M3 6h.01M3 12h.01M3 18h.01`})]}),f=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`path`,{d:`M12 20V10`}),(0,t.jsx)(`path`,{d:`M18 20V4`}),(0,t.jsx)(`path`,{d:`M6 20v-4`})]}),p=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,t.jsx)(`path`,{d:`M4 5v6c0 1.66 3.58 3 8 3s8-1.34 8-3V5`}),(0,t.jsx)(`path`,{d:`M4 11v6c0 1.66 3.58 3 8 3s8-1.34 8-3v-6`})]}),m=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`16`,rx:`2`}),(0,t.jsx)(`path`,{d:`M3 10h18`}),(0,t.jsx)(`path`,{d:`M9 10v10`})]}),h=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,t.jsx)(`path`,{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1Z`})]}),g=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,t.jsx)(`path`,{d:`M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41`})]}),_=e=>(0,t.jsx)(n,{...e,children:(0,t.jsx)(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79Z`})}),v=e=>(0,t.jsx)(n,{...e,children:(0,t.jsx)(`polyline`,{points:`15 18 9 12 15 6`})}),y=e=>(0,t.jsx)(n,{...e,children:(0,t.jsx)(`polyline`,{points:`9 18 15 12 9 6`})}),b=e=>(0,t.jsx)(n,{...e,children:(0,t.jsx)(`polygon`,{points:`5 3 19 12 5 21 5 3`})}),x=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`rect`,{x:`6`,y:`4`,width:`4`,height:`16`}),(0,t.jsx)(`rect`,{x:`14`,y:`4`,width:`4`,height:`16`})]}),S=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`polyline`,{points:`3 6 5 6 21 6`}),(0,t.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`})]}),C=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`polyline`,{points:`23 4 23 10 17 10`}),(0,t.jsx)(`polyline`,{points:`1 20 1 14 7 14`}),(0,t.jsx)(`path`,{d:`M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15`})]}),w=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,t.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]}),T=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`path`,{d:`M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8Z`}),(0,t.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]}),E=e=>(0,t.jsx)(n,{...e,children:(0,t.jsx)(`polygon`,{points:`13 2 3 14 12 14 11 22 21 10 12 10 13 2`})}),D=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,t.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]}),O=e=>(0,t.jsx)(n,{...e,children:(0,t.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}),k=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,t.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]}),A=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`}),(0,t.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]}),j=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`line`,{x1:`3`,y1:`6`,x2:`21`,y2:`6`}),(0,t.jsx)(`line`,{x1:`3`,y1:`12`,x2:`21`,y2:`12`}),(0,t.jsx)(`line`,{x1:`3`,y1:`18`,x2:`21`,y2:`18`})]}),M=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,t.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,t.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]});export{l as A,C,g as D,h as E,S as O,i as S,w as T,c as _,y as a,x as b,s as c,M as d,T as f,j as g,d as h,v as i,f as k,m as l,E as m,k as n,D as o,a as p,O as r,A as s,u as t,o as u,_ as v,p as w,b as x,r as y};
1
+ import{t as e}from"./react-vendor-08inPAVO.js";var t=e();function n({children:e,...n}){return(0,t.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,...n,children:e})}var r=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`path`,{d:`M3 3v18h18`}),(0,t.jsx)(`rect`,{x:`7`,y:`12`,width:`3`,height:`6`}),(0,t.jsx)(`rect`,{x:`12`,y:`8`,width:`3`,height:`10`}),(0,t.jsx)(`rect`,{x:`17`,y:`5`,width:`3`,height:`13`})]}),i=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`line`,{x1:`8`,y1:`6`,x2:`21`,y2:`6`}),(0,t.jsx)(`line`,{x1:`8`,y1:`12`,x2:`21`,y2:`12`}),(0,t.jsx)(`line`,{x1:`8`,y1:`18`,x2:`21`,y2:`18`}),(0,t.jsx)(`line`,{x1:`3`,y1:`6`,x2:`3.01`,y2:`6`}),(0,t.jsx)(`line`,{x1:`3`,y1:`12`,x2:`3.01`,y2:`12`}),(0,t.jsx)(`line`,{x1:`3`,y1:`18`,x2:`3.01`,y2:`18`})]}),a=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`rect`,{x:`2`,y:`7`,width:`20`,height:`14`,rx:`2`}),(0,t.jsx)(`path`,{d:`M16 7V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2`})]}),o=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0Z`}),(0,t.jsx)(`line`,{x1:`12`,y1:`9`,x2:`12`,y2:`13`}),(0,t.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`})]}),s=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,t.jsx)(`polyline`,{points:`12 7 12 12 15 14`})]}),c=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`path`,{d:`M3 3v18h18`}),(0,t.jsx)(`path`,{d:`m19 9-5 5-4-4-3 3`})]}),l=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`rect`,{x:`4`,y:`4`,width:`16`,height:`8`,rx:`2`}),(0,t.jsx)(`rect`,{x:`4`,y:`14`,width:`16`,height:`6`,rx:`2`}),(0,t.jsx)(`line`,{x1:`8`,y1:`8`,x2:`8.01`,y2:`8`}),(0,t.jsx)(`line`,{x1:`8`,y1:`17`,x2:`8.01`,y2:`17`})]}),u=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`path`,{d:`M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9`}),(0,t.jsx)(`path`,{d:`M13.73 21a2 2 0 0 1-3.46 0`})]}),d=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`line`,{x1:`8`,y1:`6`,x2:`21`,y2:`6`}),(0,t.jsx)(`line`,{x1:`8`,y1:`12`,x2:`21`,y2:`12`}),(0,t.jsx)(`line`,{x1:`8`,y1:`18`,x2:`21`,y2:`18`}),(0,t.jsx)(`path`,{d:`M3 6h.01M3 12h.01M3 18h.01`})]}),f=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`path`,{d:`M12 20V10`}),(0,t.jsx)(`path`,{d:`M18 20V4`}),(0,t.jsx)(`path`,{d:`M6 20v-4`})]}),p=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,t.jsx)(`path`,{d:`M4 5v6c0 1.66 3.58 3 8 3s8-1.34 8-3V5`}),(0,t.jsx)(`path`,{d:`M4 11v6c0 1.66 3.58 3 8 3s8-1.34 8-3v-6`})]}),m=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`16`,rx:`2`}),(0,t.jsx)(`path`,{d:`M3 10h18`}),(0,t.jsx)(`path`,{d:`M9 10v10`})]}),h=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,t.jsx)(`path`,{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1Z`})]}),g=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,t.jsx)(`path`,{d:`M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41`})]}),_=e=>(0,t.jsx)(n,{...e,children:(0,t.jsx)(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79Z`})}),v=e=>(0,t.jsx)(n,{...e,children:(0,t.jsx)(`polyline`,{points:`15 18 9 12 15 6`})}),y=e=>(0,t.jsx)(n,{...e,children:(0,t.jsx)(`polyline`,{points:`9 18 15 12 9 6`})}),b=e=>(0,t.jsx)(n,{...e,children:(0,t.jsx)(`polygon`,{points:`5 3 19 12 5 21 5 3`})}),x=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`rect`,{x:`6`,y:`4`,width:`4`,height:`16`}),(0,t.jsx)(`rect`,{x:`14`,y:`4`,width:`4`,height:`16`})]}),S=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`polyline`,{points:`3 6 5 6 21 6`}),(0,t.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`})]}),C=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`polyline`,{points:`23 4 23 10 17 10`}),(0,t.jsx)(`polyline`,{points:`1 20 1 14 7 14`}),(0,t.jsx)(`path`,{d:`M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15`})]}),w=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,t.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]}),T=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`path`,{d:`M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8Z`}),(0,t.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]}),E=e=>(0,t.jsx)(n,{...e,children:(0,t.jsx)(`polygon`,{points:`13 2 3 14 12 14 11 22 21 10 12 10 13 2`})}),D=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,t.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]}),O=e=>(0,t.jsx)(n,{...e,children:(0,t.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}),k=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,t.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]}),A=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`}),(0,t.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]}),j=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`line`,{x1:`3`,y1:`6`,x2:`21`,y2:`6`}),(0,t.jsx)(`line`,{x1:`3`,y1:`12`,x2:`21`,y2:`12`}),(0,t.jsx)(`line`,{x1:`3`,y1:`18`,x2:`21`,y2:`18`})]}),M=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,t.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,t.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]});export{l as A,C,g as D,h as E,S as O,i as S,w as T,c as _,y as a,x as b,s as c,M as d,T as f,j as g,d as h,v as i,f as k,m as l,E as m,k as n,D as o,a as p,O as r,A as s,u as t,o as u,_ as v,p as w,b as x,r as y};