bunqueue-dashboard 0.0.39 → 0.0.40

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 (69) hide show
  1. package/README.md +5 -5
  2. package/agent/backup/resultValidation.ts +1 -1
  3. package/agent/index.ts +3 -0
  4. package/agent/manager/config.ts +1 -1
  5. package/agent/manager/process.ts +2 -2
  6. package/agent/manager/storageMode.ts +20 -0
  7. package/agent/manager.ts +1 -1
  8. package/agent/queue/routes.ts +57 -2
  9. package/agent/queue/runtime.ts +62 -1
  10. package/agent/queue/types.ts +31 -0
  11. package/agent/queue/validation.ts +16 -0
  12. package/agent/server/controlRoutes.ts +2 -93
  13. package/agent/server/controlStatus.ts +115 -0
  14. package/agent/workflows.ts +1 -1
  15. package/dist/.vite/manifest.json +120 -120
  16. package/dist/assets/{AddJob-d5KBvmN8.js → AddJob-DkbI_J5p.js} +1 -1
  17. package/dist/assets/{Alerts-5I44QTnQ.js → Alerts-CFj-u0iV.js} +1 -1
  18. package/dist/assets/{Benchmark-S1afsQRd.js → Benchmark-Ey2sq57q.js} +1 -1
  19. package/dist/assets/{BulkAddJobs-BO8LWUHE.js → BulkAddJobs-BwPoeSB6.js} +1 -1
  20. package/dist/assets/{CopilotPanel-DDkRd35p.js → CopilotPanel-CniuIIPn.js} +1 -1
  21. package/dist/assets/{Cron-X3Y5uISO.js → Cron-B5XFBvU-.js} +1 -1
  22. package/dist/assets/{CronManager-ugmYEAwY.js → CronManager-Bdg2BECM.js} +1 -1
  23. package/dist/assets/{Database-koy8haPX.js → Database-CB0oOEFB.js} +1 -1
  24. package/dist/assets/{Diagnostics-D6oqvkOs.js → Diagnostics-BDRftXQy.js} +1 -1
  25. package/dist/assets/{Dlq-D70Lzmsa.js → Dlq-CJO9itzJ.js} +1 -1
  26. package/dist/assets/{DlqControl-nUT5Zzkl.js → DlqControl-DZL2lHOU.js} +1 -1
  27. package/dist/assets/{DlqPro-VMuBKgP-.js → DlqPro-OqBlzCnN.js} +1 -1
  28. package/dist/assets/{Flows-CAG0nDnt.js → Flows-BItJzbVQ.js} +2 -2
  29. package/dist/assets/{JobInspector-CiS5HOSQ.js → JobInspector-CJHX63p_.js} +2 -2
  30. package/dist/assets/{Jobs-CkyRvzOT.js → Jobs-BwmTsjJx.js} +1 -1
  31. package/dist/assets/{JobsPro-B4-CSoq3.js → JobsPro-eFVAZJ10.js} +1 -1
  32. package/dist/assets/{Logs-DBTz2PTz.js → Logs-CXIf58M4.js} +1 -1
  33. package/dist/assets/{LogsPro-BCFeegvr.js → LogsPro-Xm6rylAd.js} +1 -1
  34. package/dist/assets/{McpServer-BKlTR1qr.js → McpServer-Rf3i6lRn.js} +2 -2
  35. package/dist/assets/{Metrics-Du__9Lbn.js → Metrics-Cj3VYxzL.js} +1 -1
  36. package/dist/assets/{MetricsPro-CqnaO6YX.js → MetricsPro-C63eY00A.js} +1 -1
  37. package/dist/assets/{Overview-udSSt7ZB.js → Overview-CUM3XG7A.js} +1 -1
  38. package/dist/assets/{QueueActions-D7cQrGvJ.js → QueueActions-b19K0vCT.js} +1 -1
  39. package/dist/assets/QueueControl-DusMoa05.js +1 -0
  40. package/dist/assets/{QueueDetail-C-ms6bMe.js → QueueDetail-CpFIG1PU.js} +1 -1
  41. package/dist/assets/{QueueDetailPro-DXEdsZx_.js → QueueDetailPro-BNlBOj5s.js} +1 -1
  42. package/dist/assets/{Queues-BUMwTVAf.js → Queues-CZ2qc7FY.js} +1 -1
  43. package/dist/assets/{QueuesOverview-Du8XLgN0.js → QueuesOverview-CBFqQ3N_.js} +1 -1
  44. package/dist/assets/{S3Backup-CDICSzxM.js → S3Backup-x4mOV-AO.js} +1 -1
  45. package/dist/assets/{S3BackupPro-CBidbI-s.js → S3BackupPro-BtvbPVg-.js} +3 -3
  46. package/dist/assets/{ServerControl-CPT0LpsC.js → ServerControl-C5nQ7CCp.js} +2 -2
  47. package/dist/assets/{Settings-CmxfSX_8.js → Settings-B5kCRSBH.js} +1 -1
  48. package/dist/assets/{Usage-B895tSxi.js → Usage-UYovs3D-.js} +1 -1
  49. package/dist/assets/{UsagePro-CASN77iV.js → UsagePro-bT82DS-d.js} +1 -1
  50. package/dist/assets/{Webhooks-CXbZOFFw.js → Webhooks-BjsUMJAn.js} +1 -1
  51. package/dist/assets/{Workers-BceQlUhX.js → Workers-CD4YZpca.js} +1 -1
  52. package/dist/assets/{WorkersPro-Dtml89jB.js → WorkersPro-hCPhfb1Z.js} +1 -1
  53. package/dist/assets/{Workflows-B8wmQN2X.js → Workflows-DOpeo-TP.js} +1 -1
  54. package/dist/assets/{api-81m1TwB7.js → api-BxYPEynh.js} +1 -1
  55. package/dist/assets/bq-C7wdABtE.js +1 -0
  56. package/dist/assets/{flowMutationSafety-6cP-l4Pa.js → flowMutationSafety-DSd3JLAV.js} +1 -1
  57. package/dist/assets/{index-TploGF7u.js → index-AUHH2nTG.js} +3 -3
  58. package/dist/assets/{index-B-QjN7pA.css → index-BK7fjWKK.css} +1 -1
  59. package/dist/assets/{install-BPp8nydm.js → install-C5y2ohOo.js} +2 -2
  60. package/dist/assets/{responses-C9lP49qu.js → responses-DiIfPXXq.js} +1 -1
  61. package/dist/assets/{upstreamPaths-ZeijhPPb.js → upstreamPaths-B_cyinGI.js} +1 -1
  62. package/dist/assets/{useThroughputSeries-_J7gWbcI.js → useThroughputSeries-y7Yyi7Zh.js} +1 -1
  63. package/dist/index.html +5 -5
  64. package/package.json +10 -7
  65. package/scripts/bunVersion.ts +10 -0
  66. package/scripts/embedded.gen.ts +148 -148
  67. package/scripts/serve.ts +3 -0
  68. package/dist/assets/QueueControl-BF638r_0.js +0 -1
  69. package/dist/assets/bq-BOfwNIlJ.js +0 -1
@@ -1,8 +1,8 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CopilotPanel-DDkRd35p.js","./cn-zFEt5SO8.js","./react-vendor-CvwrP0tU.js","./bq-BOfwNIlJ.js","./connectionStore-CFuNYZ_8.js","./upstreamPaths-ZeijhPPb.js","./dist-DZL8soAh.js","./form-C4oby9pI.js","./AddJob-d5KBvmN8.js","./toastStore-B31o6Z5J.js","./usePolledData-CNtNtd0a.js","./Button-Ch1W94fJ.js","./Card-CWxrC8OY.js","./PageHeader-CvIyaFOO.js","./StatusBadge-BoOVTnKu.js","./useServerActionGuard-Db7PPgaI.js","./responses-C9lP49qu.js","./Benchmark-S1afsQRd.js","./icons-BVzwsfbG.js","./format-Cg7VCIZW.js","./AreaChart-DEAalJ6P.js","./BulkAddJobs-BO8LWUHE.js","./CronManager-ugmYEAwY.js","./feedback-QDN1AsYt.js","./Pagination-x-Cwgrul.js","./Database-koy8haPX.js","./Diagnostics-D6oqvkOs.js","./api-81m1TwB7.js","./useControlActionGuard-DT7uudrj.js","./controlConnectionEpoch-DzbuWOhe.js","./DlqControl-nUT5Zzkl.js","./flowMutationSafety-6cP-l4Pa.js","./exportFile-C7xhE8Yh.js","./QueueControl-BF638r_0.js","./QueueActions-D7cQrGvJ.js","./DlqPro-VMuBKgP-.js","./Flows-CAG0nDnt.js","./JobInspector-CiS5HOSQ.js","./jobActions-LQD4KfCc.js","./JobsPro-B4-CSoq3.js","./LogsPro-BCFeegvr.js","./McpServer-BKlTR1qr.js","./MetricsPro-CqnaO6YX.js","./useThroughputSeries-_J7gWbcI.js","./QueueDetailPro-DXEdsZx_.js","./QueuesOverview-Du8XLgN0.js","./promisePool-BVfQ9n9Q.js","./S3BackupPro-CBidbI-s.js","./ServerControl-CPT0LpsC.js","./UsagePro-CASN77iV.js","./Webhooks-CXbZOFFw.js","./WorkersPro-Dtml89jB.js","./Workflows-B8wmQN2X.js","./Alerts-5I44QTnQ.js","./Cron-X3Y5uISO.js","./Dlq-D70Lzmsa.js","./Jobs-CkyRvzOT.js","./Logs-DBTz2PTz.js","./Metrics-Du__9Lbn.js","./Overview-udSSt7ZB.js","./QueueDetail-C-ms6bMe.js","./Queues-BUMwTVAf.js","./S3Backup-CDICSzxM.js","./Settings-CmxfSX_8.js","./Usage-B895tSxi.js","./Workers-BceQlUhX.js"])))=>i.map(i=>d[i]);
2
- import{i as e,t}from"./cn-zFEt5SO8.js";import{a as n,c as r,g as i,i as a,l as o,m as s,n as c,o as l,p as u,r as d,s as f,t as p,u as m}from"./react-vendor-CvwrP0tU.js";import{a as h,c as g,d as _,f as v,i as y,l as b,n as x,o as S,r as C,s as ee,u as w}from"./connectionStore-CFuNYZ_8.js";import{t as T}from"./bq-BOfwNIlJ.js";import{n as te,t as ne}from"./toastStore-B31o6Z5J.js";import{A as re,D as ie,E as ae,S as oe,T as se,_ as ce,c as le,f as ue,g as de,h as fe,k as pe,l as me,m as he,n as ge,o as _e,p as E,r as ve,s as ye,t as be,u as D,v as xe,w as Se,y as Ce}from"./icons-BVzwsfbG.js";import{t as we}from"./api-81m1TwB7.js";import{n as Te}from"./usePolledData-CNtNtd0a.js";import{t as Ee}from"./Button-Ch1W94fJ.js";import{t as O}from"./Card-CWxrC8OY.js";import{i as De,n as Oe,r as ke}from"./feedback-QDN1AsYt.js";import{t as Ae}from"./PageHeader-CvIyaFOO.js";import{c as je,l as Me,n as Ne,r as Pe,s as k,t as Fe,u as Ie}from"./format-Cg7VCIZW.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var A=e(i(),1),Le=s(),Re=`bq-dash-alerts`,ze=1,Be=[`email`,`webhook`,`slack`],Ve=[`error_rate`,`p99_latency`,`waiting`,`failed`,`dlq`],He=[`>=`,`>`,`<=`,`<`],Ue=128,We=200,Ge=2048,Ke=256,qe=/^[^\s@]+@[^\s@]+\.[^\s@]+$/u,Je=()=>`${Date.now().toString(36)}${Math.floor(Math.random()*1e6).toString(36)}`;function Ye(e){let t=new Set(e.map(e=>e.id)),n=Je();if(!t.has(n))return n;let r=1;for(;t.has(`${n}-${r}`);)r+=1;return`${n}-${r}`}function Xe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ze(e){return Be.includes(e)}function Qe(e){return Ve.includes(e)}function $e(e){return He.includes(e)}function et(e,t){let n=t.trim();if(!n||n.length>Ge)return!1;if(e===`email`)return n.length<=320&&qe.test(n);try{let e=new URL(n);return[`http:`,`https:`].includes(e.protocol)&&!e.username&&!e.password}catch{return!1}}function tt(e){if(!Xe(e)||typeof e.id!=`string`||!Ze(e.type)||typeof e.target!=`string`)return null;let t=e.id.trim(),n=e.target.trim();return!t||t.length>Ue||n.length>Ge||e.type===`email`&&!et(e.type,n)?null:{id:t,type:e.type,target:e.type===`email`?n:``}}function nt(e){if(!Xe(e)||typeof e.id!=`string`||typeof e.name!=`string`||!Qe(e.metric)||!$e(e.operator)||typeof e.threshold!=`number`||!Number.isFinite(e.threshold)||typeof e.queue!=`string`||!Ze(e.channel)||typeof e.enabled!=`boolean`)return null;let t=e.id.trim(),n=e.name.trim(),r=e.queue.trim();return!t||t.length>Ue||!n||n.length>We||r.length>Ke||e.threshold<0||e.metric===`error_rate`&&e.threshold>100?null:{id:t,name:n,metric:e.metric,operator:e.operator,threshold:e.threshold,queue:r,channel:e.channel,enabled:e.enabled}}function j(e){let t=Xe(e)?e:{},n=[],r=new Set;if(Array.isArray(t.channels))for(let e of t.channels){if(n.length>=100)break;let t=tt(e);!t||r.has(t.id)||(r.add(t.id),n.push(t))}let i=[],a=new Set;if(Array.isArray(t.rules))for(let e of t.rules){if(i.length>=500)break;let t=nt(e);!t||a.has(t.id)||(a.add(t.id),i.push(t))}return{channels:n,rules:i}}function rt(e){return j({channels:e.channels,rules:e.rules})}var it=b({key:Re,version:ze,sanitizeState:j}),M=v()(_(e=>({channels:[],rules:[],addChannel:(t,n)=>{let r={ok:!1,error:`Alert destination was rejected.`};return e(e=>{let i=n.trim();return!Ze(t)||!et(t,i)?(r={ok:!1,error:`Alert destination is invalid.`},e):e.channels.length>=100?(r={ok:!1,error:`A maximum of 100 alert destinations can be stored in this browser.`},e):(r={ok:!0},{channels:[...e.channels,{id:Ye(e.channels),type:t,target:i}]})}),r},removeChannel:t=>e(e=>({channels:e.channels.filter(e=>e.id!==t)})),addRule:t=>{let n={ok:!1,error:`Alert rule was rejected.`};return e(e=>{if(e.rules.length>=500)return n={ok:!1,error:`A maximum of 500 alert rules can be stored in this browser.`},e;let r=nt({...t,id:Ye(e.rules)});return r?(n={ok:!0},{rules:[...e.rules,r]}):(n={ok:!1,error:`Alert rule contains invalid fields.`},e)}),n},removeRule:t=>e(e=>({rules:e.rules.filter(e=>e.id!==t)})),toggleRule:t=>e(e=>({rules:e.rules.map(e=>e.id===t?{...e,enabled:!e.enabled}:e)}))}),{name:Re,version:ze,storage:w(()=>it),partialize:rt,migrate:j,merge:(e,t)=>({...t,...j(e)})})),at={error_rate:`error rate`,p99_latency:`p99 latency`,waiting:`waiting jobs`,failed:`failed jobs`,dlq:`DLQ size`},ot=10500,st=500,ct=21,lt=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0;function ut(e,t,n){return t===`>=`?e>=n:t===`>`?e>n:t===`<=`?e<=n:t===`<`&&e<n}function dt(e){if(!Array.isArray(e)||e.length>ot)return null;let t=new Set,n=[];for(let r of e){if(!r||typeof r!=`object`||Array.isArray(r))return null;let e=r,i=e.counts;if(typeof e.name!=`string`||!e.name||e.name.length>256||!/^[a-zA-Z0-9_\-.:]+$/.test(e.name)||t.has(e.name)||typeof e.paused!=`boolean`||!i||typeof i!=`object`||Array.isArray(i))return null;let a=i;if(![`waiting`,`active`,`completed`,`failed`,`delayed`].every(e=>lt(a[e])))return null;t.add(e.name),n.push(r)}return n}function ft(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;if(t.ok!==!0||!t.latency||typeof t.latency!=`object`||Array.isArray(t.latency))return null;let n=t.latency.percentiles;if(!n||typeof n!=`object`||Array.isArray(n))return null;for(let e of Object.values(n)){let t=e?.p99;if(!e||typeof e!=`object`||Array.isArray(e)||typeof t!=`number`||!Number.isFinite(t)||t<0)return null}return e}var pt=(e,t)=>{let n=e+t;return n>0?t/n*100:null};function mt(e,t){let n=e.queue.trim();if(e.metric===`waiting`||e.metric===`failed`){if(!t.summary)return null;let r=e.metric;return n?t.summary.find(e=>e.name===n)?.counts[r]??null:t.summary.reduce((e,t)=>e+t.counts[r],0)}if(e.metric===`dlq`)return t.queues?n?t.queues.find(e=>e.name===n)?.dlq??null:t.queues.reduce((e,t)=>e+(t.dlq??0),0):null;if(e.metric===`error_rate`){if(!t.summary)return null;if(n){let e=t.summary.find(e=>e.name===n);return e?pt(e.counts.completed,e.counts.failed):null}return pt(t.summary.reduce((e,t)=>e+t.counts.completed,0),t.summary.reduce((e,t)=>e+t.counts.failed,0))}let r=t.overview?.latency?.percentiles;if(!r)return null;let i=Object.values(r).map(e=>e.p99).filter(Number.isFinite);return i.length?Math.max(...i):null}function ht(e,t,n){if(typeof e!=`object`||!e||Array.isArray(e))return null;let r=e;if(r.ok!==!0||!Array.isArray(r.queues)||!Number.isSafeInteger(r.total)||r.total<0||r.total>ot||n!==null&&r.total!==n||r.offset!==t||r.limit!==st)return null;let i=r.total;if(r.queues.length!==Math.min(st,i-t))return null;let a=[];for(let e of r.queues){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;if(typeof t.name!=`string`||!t.name||t.name.length>256||!/^[a-zA-Z0-9_\-.:]+$/.test(t.name)||!lt(t.dlq))return null;a.push(e)}return{queues:a,total:i}}async function gt(e=T){try{let t=[],n=new Set,r=null;for(let i=0;i<ct;i++){let i=ht(await e.queues(st,t.length),t.length,r);if(!i)return null;r??=i.total;for(let e of i.queues){if(n.has(e.name))return null;n.add(e.name),t.push(e)}if(t.length===r)return t}return null}catch{return null}}var _t=3,vt=e=>`${e.queue||`All queues`}: ${e.metricLabel} ${e.operator} ${e.threshold} (now ${Math.round(e.value)})`;function yt(e){if(globalThis.Notification?.permission===`granted`)try{new Notification(`bunqueue alert: ${e.ruleName}`,{body:vt(e),tag:e.ruleId})}catch{}}function bt(e){if(e.length<=_t){for(let t of e)ne.error(`Alert: ${t.ruleName}`,vt(t)),yt(t);return}ne.error(`${e.length} alert rules breaching`,e.map(e=>e.ruleName).join(`, `));for(let t of e)yt(t)}var xt=3e4,St=(e,t)=>JSON.stringify([e,t]);function Ct(e){let t=JSON.parse(e);if(!Array.isArray(t)||t.length!==2)throw TypeError(`Invalid alert connection identity.`);let[n,r]=t,i=h(n);if(!i||typeof r!=`string`)throw TypeError(`Invalid alert server target.`);let a=r.trim();return Object.freeze({baseUrl:i,...a?{authorization:`Bearer ${a}`}:{}})}function wt(e,t){let n=new Headers({Accept:`application/json`});e.authorization&&n.set(`Authorization`,e.authorization);let r=async r=>{t.throwIfAborted();let i=AbortSignal.any([t,AbortSignal.timeout(xt)]),a=await fetch(e.baseUrl+r,{headers:n,signal:i});if(t.throwIfAborted(),!a.ok)throw await a.body?.cancel().catch(()=>{}),a.status===401&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(`auth:required`,{detail:{scope:`server`,auth:e.authorization,target:e.baseUrl}})),Error(`Alert metrics request failed: HTTP ${a.status}`);let o=await a.text();if(t.throwIfAborted(),!o)throw Error(`Alert metrics request returned an empty response.`);try{return JSON.parse(o)}catch{throw Error(`Alert metrics request returned invalid JSON (HTTP ${a.status}).`)}};return Object.freeze({queuesSummary:()=>r(`/queues/summary`),queues:(e=500,t=0)=>r(`/dashboard/queues?limit=${e}&offset=${t}`),overview:()=>r(`/dashboard`)})}var Tt=15e3,Et=6e4,N=v(e=>({breaching:[],status:`idle`,error:null,connectionIdentity:null,setBreaching:t=>e({breaching:t})}));async function Dt(){if(typeof Notification>`u`)return`denied`;if(Notification.permission===`granted`)return`granted`;try{return await Notification.requestPermission()}catch{return`denied`}}function Ot(){let e=M(e=>e.rules),t=S(e=>St(e.baseUrl,e.token)),n=(0,A.useRef)(new Map),r=(0,A.useRef)(new Map),i=(0,A.useRef)(new Map),a=(0,A.useRef)(new Map),o=(0,A.useRef)(t),s=(0,A.useRef)(0),c=JSON.stringify(e.filter(e=>e.enabled).map(e=>[e.id,e.metric,e.operator,e.threshold,e.queue]));(0,A.useEffect)(()=>{let e=()=>{n.current.clear(),r.current.clear(),i.current.clear(),a.current.clear()},l=o.current!==t;if(l&&(o.current=t,e()),c===`[]`){e(),N.setState({breaching:[],status:`idle`,error:null,connectionIdentity:t});return}let u=new Set(M.getState().rules.filter(e=>e.enabled).map(e=>e.id)),d=l?[]:N.getState().breaching.filter(e=>u.has(e.ruleId));N.setState({breaching:d,status:`checking`,error:null,connectionIdentity:t});let f;try{f=Ct(t)}catch(e){N.setState({breaching:[],status:`degraded`,error:`Alert evaluation failed: ${e.message}`,connectionIdentity:t});return}let p=new AbortController,m=++s.current,h=!1,g=!1,_=()=>{if(h||s.current!==m)return!1;let e=S.getState();return St(e.baseUrl,e.token)===t},v=e=>{for(let t of[...n.current.keys()])e.has(t)||(n.current.delete(t),r.current.delete(t),i.current.delete(t),a.current.delete(t))},y=async()=>{if(!g){g=!0;try{let e=wt(f,p.signal),[o,s,c]=await Promise.all([e.queuesSummary().then(dt).catch(()=>null),gt(e),e.overview().then(ft).catch(()=>null)]);if(!_())return;let l=M.getState().rules.filter(e=>e.enabled),u=new Set(l.map(e=>e.id));if(v(u),!c){let e=N.getState().breaching.filter(e=>u.has(e.ruleId));if(!_())return;N.setState({breaching:e,status:`degraded`,error:`The bunqueue overview endpoint is unavailable; alert results may be stale.`,connectionIdentity:t});return}let d=Date.now(),m=[],h=[],g=!1;for(let e of l){let t=mt(e,{summary:o,queues:s,overview:c});if(t==null){g=!0;let t=n.current.get(e.id)?a.current.get(e.id):void 0;t&&m.push(t);continue}let l=ut(t,e.operator,e.threshold),u=n.current.get(e.id)??!1;if(l){let n=u?i.current.get(e.id)??d:d;i.current.set(e.id,n);let o={ruleId:e.id,ruleName:e.name,metricLabel:at[e.metric],operator:e.operator,threshold:e.threshold,value:t,queue:e.queue,at:n};m.push(o),a.current.set(e.id,o);let s=r.current.get(e.id)??0;d-s>Et&&s<n&&(h.push(o),r.current.set(e.id,d))}else i.current.delete(e.id),a.current.delete(e.id);n.current.set(e.id,l)}if(!_())return;bt(h);let y=!o||!s||g;N.setState({breaching:m,status:y?`degraded`:`live`,error:y?`Some alert rules could not be evaluated; affected results remain unknown.`:null,connectionIdentity:t})}catch(e){if(!_())return;N.setState({status:`degraded`,error:`Alert evaluation failed: ${e.message}`,connectionIdentity:t})}finally{g=!1}}};y();let b=setInterval(y,Tt);return()=>{h=!0,s.current===m&&(s.current+=1),p.abort(),clearInterval(b)}},[c,t])}function kt(){return Ot(),null}var At={authentication:100,"command-palette":80,copilot:60,"database-row":40,"mobile-navigation":20},P=v((e,t)=>({active:null,request(n){let r=t().active;return r===n?!0:r&&At[r]>At[n]?!1:(e({active:n}),!0)},release(n){t().active===n&&e({active:null})},reset(){e({active:null})}}));function F(e){let t=P.getState().active;return t===null||t===e}var I=p();function jt(e){return{scope:e,auth:e===`agent`?x().Authorization:C().Authorization,target:e===`agent`?T.agentBase:y()}}function L(e,t){return e?.scope===t.scope&&e.auth===t.auth&&e.target===t.target}function Mt(){let[e,t]=(0,A.useState)(!1),[n,r]=(0,A.useState)(`server`),[i,a]=(0,A.useState)(``),o=S(e=>e.baseUrl),s=S(e=>e.setToken),c=S(e=>e.setAgentToken),l=(0,A.useRef)(null),u=(0,A.useRef)(null),f=(0,A.useRef)(null),p=(0,A.useRef)(null),m=P(e=>e.active),h=e&&m===`authentication`;(0,A.useEffect)(()=>{let e=e=>{let n=e.detail;if(n?.scope!==`server`&&n?.scope!==`agent`)return;let i=jt(n.scope);n.auth!==i.auth||n.target!==i.target||(L(f.current,i)||(p.current=null,a(``)),f.current=i,P.getState().request(`authentication`),r(i.scope),t(!0),window.dispatchEvent(new window.Event(`auth:gate-opened`)))};return window.addEventListener(`auth:required`,e),()=>window.removeEventListener(`auth:required`,e)},[]),(0,A.useEffect)(()=>()=>{P.getState().release(`authentication`)},[]),(0,A.useEffect)(()=>{if(!h)return;let e=document.activeElement,t=document.getElementById(`app-shell`)?[]:[`app-nav`,`app-content`].map(e=>document.getElementById(e)).filter(e=>e!==null),n=t.map(e=>({element:e,inert:e.inert,ariaHidden:e.getAttribute(`aria-hidden`)}));for(let e of t)e.inert=!0,e.setAttribute(`aria-hidden`,`true`);let r=window.requestAnimationFrame(()=>l.current?.focus()),i=()=>u.current?Array.from(u.current.querySelectorAll(`a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])`)):[],a=e=>{if(e.key!==`Tab`)return;let t=i();if(!t.length){e.preventDefault();return}let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())};return window.addEventListener(`keydown`,a),()=>{window.cancelAnimationFrame(r),window.removeEventListener(`keydown`,a);for(let e of n)e.element.inert=e.inert,e.ariaHidden===null?e.element.removeAttribute(`aria-hidden`):e.element.setAttribute(`aria-hidden`,e.ariaHidden);F(`authentication`)&&e?.isConnected&&e.focus()}},[h]);let g=()=>{f.current=null,p.current=null,a(``),t(!1),P.getState().release(`authentication`)};return h?(0,I.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/60 p-4`,children:(0,I.jsxs)(`form`,{ref:u,onSubmit:e=>{e.preventDefault();let t=f.current,n=p.current;if(!t||!n||!L(n.identity,t)||!L(t,jt(t.scope))){g();return}let r=n.value.trim();r&&(t.scope===`agent`?c(r):s(r),g())},role:`dialog`,"aria-modal":`true`,"aria-label":`Authentication required`,className:`w-full max-w-sm rounded-xl border border-line-strong bg-surface p-6 shadow-2xl`,children:[(0,I.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:`Authentication required`}),n===`agent`?(0,I.jsxs)(`p`,{className:`mt-1 text-sm text-muted`,children:[`The control agent at `,(0,I.jsx)(`span`,{className:`break-all font-mono text-fg`,children:T.agentBase}),` `,`rejected the request (401). Enter its`,` `,(0,I.jsx)(`span`,{className:`font-mono text-fg`,children:`AGENT_TOKEN`}),` to continue.`]}):(0,I.jsxs)(`p`,{className:`mt-1 text-sm text-muted`,children:[`The server at `,(0,I.jsx)(`span`,{className:`break-all font-mono text-fg`,children:o}),` rejected the request (401). Enter its bearer token to continue.`]}),(0,I.jsx)(`input`,{ref:l,type:`password`,value:i,onInput:e=>{let t=e.currentTarget.value;a(t);let n=f.current;p.current=n?{identity:n,value:t}:null},placeholder:n===`agent`?`AGENT_TOKEN`:`Bearer token`,"aria-label":n===`agent`?`Agent token`:`Bearer token`,name:n===`agent`?`agent-token`:`server-token`,autoComplete:`current-password`,className:`mt-4 w-full rounded-lg border border-line bg-surface-2 px-3 py-2 text-sm text-fg outline-none placeholder:text-faint focus-visible:ring-2 focus-visible:ring-accent/50`}),(0,I.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-3`,children:[(0,I.jsx)(d,{to:`/settings`,onClick:g,className:`text-xs text-muted underline-offset-2 hover:text-fg hover:underline`,children:`Open Settings instead`}),(0,I.jsx)(`button`,{type:`submit`,disabled:!i.trim(),className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-50`,children:`Unlock`})]})]})}):null}var Nt=`bq-dash-theme`,Pt=1;function R(e){return e===`light`?`light`:`dark`}function z(){try{return globalThis.localStorage??null}catch{return null}}var Ft={getItem(e){let t=z();if(!t)return null;try{let n=t.getItem(e);if(n===null||e!==Nt)return n;let r=JSON.parse(n),i=r&&typeof r==`object`&&!Array.isArray(r)?r:{},a=i.state&&typeof i.state==`object`&&!Array.isArray(i.state)?i.state:{},o=JSON.stringify({state:{theme:R(a.theme)},version:Pt});if(n!==o)try{t.setItem(e,o)}catch{}return o}catch{try{t.removeItem(e)}catch{}return null}},setItem(e,t){try{z()?.setItem(e,t)}catch{}},removeItem(e){try{z()?.removeItem(e)}catch{}}};function B(e){typeof document<`u`&&(document.documentElement.dataset.theme=e,document.documentElement.style.colorScheme=e)}var V=v()(_((e,t)=>({theme:`dark`,toggle:()=>{let n=t().theme===`dark`?`light`:`dark`;B(n),e({theme:n})},setTheme:t=>{let n=R(t);B(n),e({theme:n})}}),{name:Nt,version:Pt,storage:w(()=>Ft),partialize:e=>({theme:R(e.theme)}),merge:(e,t)=>{let n=e&&typeof e==`object`&&!Array.isArray(e)?e:{};return{...t,theme:R(n.theme)}},onRehydrateStorage:()=>e=>{e&&B(R(e.theme))}}));function It(){B(R(V.getState().theme))}var Lt={connecting:{dot:`bg-zinc-500`,label:`connecting`},connected:{dot:`bg-emerald-400`,label:`connected`},degraded:{dot:`bg-amber-400`,label:`reachable, degraded`},offline:{dot:`bg-red-400`,label:`offline`}};function Rt(){let e=S(e=>e.baseUrl),{data:n,error:r,loading:i}=Te(async()=>{let e=await we.health();if(typeof e.ok!=`boolean`)throw Error(`Malformed health response`);return{healthy:e.ok}},[],{intervalMs:15e3}),a=Lt[i?`connecting`:r||!n?`offline`:n.healthy?`connected`:`degraded`],o=e.replace(/^https?:\/\//,``)||`local`;return(0,I.jsxs)(`div`,{className:`mx-3 mb-4 flex items-center gap-2 rounded-lg border border-line bg-surface px-3 py-1.5`,children:[(0,I.jsx)(`span`,{className:t(`size-1.5 rounded-full`,a.dot),title:a.label}),(0,I.jsx)(`span`,{className:`truncate font-mono text-[11px] text-muted`,title:e,children:o}),(0,I.jsx)(`span`,{className:`sr-only`,children:a.label})]})}function zt(e){let t=null;try{return t=document.createElement(`textarea`),t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`)}catch{return!1}finally{t?.remove()}}function Bt({value:e,className:n}){let[r,i]=(0,A.useState)(`idle`),a=(0,A.useRef)(null);(0,A.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]);let o=async()=>{let t=!1;if(navigator.clipboard)try{await navigator.clipboard.writeText(e),t=!0}catch{}t||=zt(e),i(t?`copied`:`failed`),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(`idle`),1500)},s=r===`copied`?`Copied to clipboard`:r===`failed`?`Copy failed`:`Copy to clipboard`;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,onClick:o,"aria-label":s,title:s,className:t(`inline-flex size-6 shrink-0 items-center justify-center rounded-md text-faint transition-colors hover:bg-surface-2 hover:text-fg`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,n),children:r===`copied`?(0,I.jsx)(ve,{className:`size-3.5 text-success`}):r===`failed`?(0,I.jsx)(_e,{className:`size-3.5 text-danger`}):(0,I.jsx)(ye,{className:`size-3.5`})}),(0,I.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:r===`idle`?``:s})]})}var Vt;function H(){return Vt===void 0&&(Vt=Ht()),Vt}function Ht(){if(typeof window>`u`)return!1;let{search:e,hash:t}=window.location;return new URLSearchParams(e).has(`demo`)||t.replace(/^#/,``)===`demo`}var Ut=`https://github.com/egeominotti/bunqueue-dashboard`,Wt=`https://egeominotti.github.io/bunqueue-dashboard/docs/`,Gt=`bunx bunqueue-dashboard`;function Kt(){return(0,I.jsxs)(`div`,{className:`mx-3 mb-2 rounded-lg border border-accent/30 bg-accent/5 p-3`,children:[(0,I.jsx)(`p`,{className:`mb-2 text-[11px] font-medium leading-snug text-fg`,children:`Like it? Run it on your own bunqueue server.`}),(0,I.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 rounded-md border border-line bg-surface-2 px-2 py-1`,children:[(0,I.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-fg`,children:Gt}),(0,I.jsx)(Bt,{value:Gt})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(`a`,{href:Ut,target:`_blank`,rel:`noreferrer`,className:`flex flex-1 items-center justify-center gap-1 rounded-md bg-accent px-2 py-1.5 text-[11px] font-semibold text-accent-fg transition-opacity hover:opacity-90`,children:[(0,I.jsx)(`span`,{"aria-hidden":!0,children:`★`}),` Star`]}),(0,I.jsx)(`a`,{href:Wt,target:`_blank`,rel:`noreferrer`,className:`flex flex-1 items-center justify-center rounded-md border border-line px-2 py-1.5 text-[11px] font-medium text-muted transition-colors hover:bg-surface-2 hover:text-fg`,children:`Docs`})]})]})}function qt(){let e=S(e=>e.baseUrl),t=e===`/api`?`localhost:6790`:e.replace(/^https?:\/\//,``);return(0,I.jsxs)(I.Fragment,{children:[H()&&(0,I.jsx)(Kt,{}),(0,I.jsxs)(`div`,{className:`mx-3 mb-3 flex items-center gap-2.5 rounded-lg border border-line bg-surface px-3 py-2`,children:[(0,I.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-full bg-gradient-to-br from-accent to-fuchsia-600 text-[11px] font-bold text-white`,children:`bq`}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`div`,{className:`truncate text-xs font-medium text-fg`,children:`bunqueue`}),(0,I.jsx)(`div`,{className:`truncate font-mono text-[10px] text-faint`,title:e,children:t})]}),(0,I.jsx)(d,{to:`/settings`,"aria-label":`Settings`,className:`text-faint transition-colors hover:text-fg`,children:(0,I.jsx)(ae,{className:`size-4`})})]})]})}var Jt=[{section:null,items:[{to:`/`,label:`Overview`,icon:Ce,end:!0}]},{section:`Queues`,items:[{to:`/queues`,label:`Queues`,icon:oe,end:!0},{to:`/jobs`,label:`Jobs`,icon:E,end:!0},{to:`/dlq`,label:`Dead Letter Queue`,icon:D},{to:`/cron`,label:`Cron Jobs`,icon:le}]},{section:`Workflow`,items:[{to:`/workflows`,label:`Overview`,icon:Ce,end:!0},{to:`/flows`,label:`Job Flows`,icon:ge,end:!0},{to:`/workflows/executions`,label:`Executions`,icon:E,end:!0},{to:`/workflows/waiting`,label:`Waiting & Signals`,icon:le,end:!0},{to:`/workflows/compensation`,label:`Compensation`,icon:D,end:!0},{to:`/workflows/archive`,label:`Archive`,icon:me,end:!0}]},{section:`Monitoring`,items:[{to:`/metrics`,label:`Metrics`,icon:ce},{to:`/workers`,label:`Workers`,icon:re},{to:`/logs`,label:`Logs`,icon:fe},{to:`/alerts`,label:`Alerts`,icon:be}]},{section:`Control`,items:[{to:`/server`,label:`Server`,icon:re},{to:`/add-job`,label:`Add Job`,icon:E},{to:`/jobs/bulk-add`,label:`Bulk Add`,icon:E},{to:`/job`,label:`Job Inspector`,icon:ue},{to:`/queue-control`,label:`Queue Control`,icon:oe},{to:`/dlq-control`,label:`DLQ Control`,icon:D},{to:`/webhooks`,label:`Webhooks`,icon:he},{to:`/diagnostics`,label:`Diagnostics`,icon:ce},{to:`/benchmark`,label:`Benchmark`,icon:he}]},{section:`Management`,items:[{to:`/database`,label:`Database`,icon:me},{to:`/mcp`,label:`MCP`,icon:he},{to:`/usage`,label:`Usage`,icon:pe},{to:`/s3`,label:`S3 Backup`,icon:Se},{to:`/settings`,label:`Settings`,icon:ae}]}];function Yt(){let e=V(e=>e.theme),t=V(e=>e.toggle),n=e===`dark`;return(0,I.jsxs)(`button`,{type:`button`,onClick:t,className:`mx-3 mb-3 flex items-center gap-3 rounded-lg px-3 py-2 text-sm 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:[n?(0,I.jsx)(ie,{className:`size-4`}):(0,I.jsx)(xe,{className:`size-4`}),n?`Light Mode`:`Dark Mode`]})}function Xt({open:e=!1,blocked:n=!1,onClose:r}){return(0,I.jsxs)(I.Fragment,{children:[e&&(0,I.jsx)(`button`,{type:`button`,"aria-label":`Close navigation`,tabIndex:-1,onClick:r,className:`fixed inset-0 z-40 bg-black/50 lg:hidden`}),(0,I.jsxs)(`div`,{id:`app-nav`,role:e?`dialog`:`complementary`,"aria-modal":e||void 0,"aria-label":e?`Navigation menu`:void 0,inert:n?!0:void 0,"aria-hidden":n||void 0,className:t(`flex w-60 shrink-0 flex-col border-r border-line bg-sidebar`,`fixed inset-y-0 left-0 z-50 transition-[transform,visibility] lg:static lg:z-auto lg:translate-x-0`,e?`translate-x-0`:`-translate-x-full lg:translate-x-0 invisible lg:visible`),children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-5`,children:[(0,I.jsx)(`span`,{className:`text-lg font-bold tracking-tight text-fg`,children:`bunqueue`}),(0,I.jsx)(`span`,{className:`rounded-md bg-accent/15 px-1.5 py-0.5 text-[10px] font-bold uppercase tracking-wider text-accent`,children:`dash`}),(0,I.jsx)(`span`,{title:`Beta — under active development`,className:`rounded-md bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-bold uppercase tracking-wider text-warning`,children:`beta`})]}),(0,I.jsx)(`nav`,{className:`flex-1 overscroll-contain overflow-y-auto px-3 pb-4`,children:Jt.map(e=>(0,I.jsxs)(`div`,{className:`mb-4`,children:[e.section&&(0,I.jsx)(`div`,{className:`px-2 pb-2 pt-1 text-[10px] font-semibold uppercase tracking-wider text-faint`,children:e.section}),(0,I.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.items.map(({to:e,label:n,icon:r,end:i})=>(0,I.jsx)(a,{to:e,end:i,className:({isActive:e})=>t(`group relative flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,e?`bg-surface-2 text-fg`:`text-muted hover:bg-surface-2/60 hover:text-fg`),children:({isActive:e})=>(0,I.jsxs)(I.Fragment,{children:[e&&(0,I.jsx)(`span`,{className:`absolute inset-y-1.5 left-0 w-0.5 rounded-full bg-accent`}),(0,I.jsx)(r,{className:`size-[18px] shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:n})]})},e))})]},e.section??`root`))}),(0,I.jsx)(Rt,{}),(0,I.jsx)(Yt,{}),(0,I.jsx)(qt,{})]})]})}var Zt=`https://egeominotti.github.io/bunqueue-dashboard/docs/`,Qt=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function $t(e){let t=e.parentElement;if(!t)return()=>{};let n=Array.from(t.children).filter(t=>t!==e),r=n.map(e=>({node:e,inert:e.inert,ariaHidden:e.getAttribute(`aria-hidden`)}));for(let e of n)e.inert=!0,e.setAttribute(`aria-hidden`,`true`);return()=>{for(let{node:e,inert:t,ariaHidden:n}of r)e.inert=t,n==null?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,n)}}function en(){let[e,t]=(0,A.useState)(``),[n,r]=(0,A.useState)(0),i=P(e=>e.active===`command-palette`),a=P(e=>e.release),o=m(),s=V(e=>e.toggle),c=(0,A.useRef)(null),l=(0,A.useRef)(null),u=(0,A.useRef)(null),d=(0,A.useRef)(null),f=(0,A.useCallback)(()=>a(`command-palette`),[a]),p=(0,A.useMemo)(()=>{let e=Jt.flatMap(e=>e.items.map(t=>({id:`nav:${t.to}`,label:t.label,hint:e.section??`Home`,run:()=>o(t.to)}))),t=[{id:`act:theme`,label:`Toggle theme (dark / light)`,hint:`Action`,run:s},{id:`act:docs`,label:`Open documentation`,hint:`Action`,run:()=>window.open(Zt,`_blank`,`noopener`)}];return[...e,...t]},[o,s]),h=(0,A.useMemo)(()=>{let t=e.trim().toLowerCase();return t?p.filter(e=>`${e.label} ${e.hint}`.toLowerCase().includes(t)):p},[p,e]);(0,A.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`){e.preventDefault();let t=P.getState();t.active===`command-palette`?t.release(`command-palette`):t.request(`command-palette`)}},t=()=>P.getState().request(`command-palette`);return window.addEventListener(`keydown`,e),window.addEventListener(`command-palette:open`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`command-palette:open`,t)}},[]),(0,A.useEffect)(()=>{if(!i)return;let e=document.activeElement;t(``),r(0);let n=u.current&&!document.getElementById(`app-shell`)?$t(u.current):()=>{},a=requestAnimationFrame(()=>c.current?.focus()),o=e=>{if(e.key===`Escape`){e.preventDefault(),f();return}if(e.key!==`Tab`)return;let t=d.current;if(!t)return;let n=Array.from(t.querySelectorAll(Qt));if(n.length===0){e.preventDefault(),t.focus();return}let r=n[0],i=n[n.length-1],a=document.activeElement;e.shiftKey&&(a===r||!t.contains(a))?(e.preventDefault(),i.focus()):!e.shiftKey&&(a===i||!t.contains(a))&&(e.preventDefault(),r.focus())};return document.addEventListener(`keydown`,o),()=>{cancelAnimationFrame(a),document.removeEventListener(`keydown`,o),n(),F(`command-palette`)&&e?.isConnected&&e.focus()}},[i,f]),(0,A.useEffect)(()=>{l.current?.querySelector(`[data-idx="${n}"]`)?.scrollIntoView({block:`nearest`})},[n]);let g=(0,A.useCallback)(e=>{e&&(e.run(),f())},[f]);return i?(0,I.jsxs)(`div`,{ref:u,className:`fixed inset-0 z-50 flex items-start justify-center p-4 pt-[12vh]`,children:[(0,I.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":`Close command palette`,onClick:f,className:`fixed inset-0 bg-black/50`}),(0,I.jsxs)(`div`,{ref:d,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,className:`relative z-10 w-full max-w-lg overflow-hidden rounded-xl border border-line-strong bg-surface shadow-2xl`,children:[(0,I.jsx)(`input`,{ref:c,role:`combobox`,value:e,onChange:e=>{t(e.target.value),r(0)},onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),f()):e.key===`ArrowDown`?(e.preventDefault(),r(e=>Math.min(e+1,Math.max(0,h.length-1)))):e.key===`ArrowUp`?(e.preventDefault(),r(e=>Math.max(e-1,0))):e.key===`Enter`&&(e.preventDefault(),g(h[n]))},placeholder:`Search pages and actions…`,"aria-label":`Search pages and actions`,"aria-autocomplete":`list`,"aria-expanded":`true`,"aria-controls":`command-palette-results`,"aria-activedescendant":h[n]?`command-palette-option-${n}`:void 0,autoComplete:`off`,name:`command-palette-search`,className:`w-full border-b border-line bg-transparent px-4 py-3 text-sm text-fg outline-none placeholder:text-faint focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent/50`}),(0,I.jsxs)(`div`,{ref:l,id:`command-palette-results`,role:`listbox`,className:`max-h-80 overflow-y-auto overscroll-contain py-2`,"aria-label":`Results`,children:[h.length===0&&(0,I.jsx)(`div`,{role:`presentation`,className:`px-4 py-6 text-center text-sm text-faint`,children:`No matches`}),h.map((e,t)=>(0,I.jsx)(`div`,{role:`presentation`,children:(0,I.jsxs)(`button`,{type:`button`,id:`command-palette-option-${t}`,role:`option`,"aria-selected":t===n,tabIndex:-1,"data-idx":t,onMouseEnter:()=>r(t),onClick:()=>g(e),className:`flex w-full items-center justify-between gap-3 px-4 py-2 text-left text-sm transition-colors ${t===n?`bg-accent/15 text-fg`:`text-muted`}`,children:[(0,I.jsx)(`span`,{className:`truncate`,children:e.label}),(0,I.jsx)(`span`,{className:`shrink-0 text-xs text-faint`,children:e.hint})]})},e.id))]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between border-t border-line px-4 py-2 text-xs text-faint`,children:[(0,I.jsx)(`span`,{children:`↑↓ navigate · ↵ open · esc close`}),(0,I.jsx)(`span`,{className:`font-mono`,children:`⌘K`})]})]})]}):null}var tn=`bq-dash-copilot`,nn=1,rn=new Set([`anthropic`,`openai`,`google`,`zai`,`openrouter`,`custom`]),U={provider:`anthropic`,baseURL:``,model:`claude-opus-4-8`,apiKey:``};function an(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function on(e,t){return typeof e==`string`?e:t}function sn(e){return typeof e==`string`&&rn.has(e)?e:U.provider}function cn(e,t=``){let n=an(e)?e:{},r=sn(n.provider);return{provider:r,baseURL:r===`custom`?on(n.baseURL,U.baseURL):U.baseURL,model:on(n.model,U.model),apiKey:t}}function W(e){let t=cn((an(e)?e:{}).config);return{config:{provider:t.provider,baseURL:t.baseURL,model:t.model}}}var ln=0,un=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${(ln++).toString(36)}-${Math.random().toString(36).slice(2,8)}`,G=new Map,K=(e,t,n)=>e.map(e=>e.id===t?n(e):e);function dn(e){return W(e)}var fn=b({key:tn,version:nn,sanitizeState:W}),pn=v()(_(e=>({open:!1,config:{...U},messages:[],pending:[],busy:!1,setOpen:t=>e({open:t}),toggle:()=>e(e=>({open:!e.open})),setConfig:t=>e(e=>{let n={...e.config,...t};return{config:cn(n,on(n.apiKey,``))}}),clear:()=>{for(let e of G.values())e(!1);G.clear(),e({messages:[],pending:[]})},cancelPending:()=>{for(let e of G.values())e(!1);G.clear(),e({pending:[]})},setBusy:t=>e({busy:t}),addUser:t=>e(e=>({messages:[...e.messages,{id:un(),role:`user`,content:t}]})),startAssistant:()=>{let t=un();return e(e=>({messages:[...e.messages,{id:t,role:`assistant`,content:``,tools:[]}]})),t},appendAssistant:(t,n)=>e(e=>({messages:K(e.messages,t,e=>({...e,content:e.content+n}))})),finishAssistant:(t,n)=>e(e=>({messages:K(e.messages,t,e=>({...e,done:!0,error:!!n?.error,content:n?.error?e.content?`${e.content}\n\n${n.error}`:n.error:e.content}))})),addTool:(t,n)=>e(e=>({messages:K(e.messages,t,e=>({...e,tools:[...e.tools??[],n]}))})),updateTool:(t,n,r)=>e(e=>({messages:K(e.messages,t,e=>({...e,tools:(e.tools??[]).map(e=>e.id===n?{...e,...r}:e)}))})),requestConfirm:t=>new Promise(n=>{let r=un();G.set(r,n),e(e=>({pending:[...e.pending,{...t,id:r}]}))}),resolveConfirm:(t,n)=>{let r=G.get(t);r&&(G.delete(t),r(n)),e(e=>({pending:e.pending.filter(e=>e.id!==t)}))}}),{name:tn,version:nn,storage:w(()=>fn),partialize:e=>dn(e),migrate:W,merge:(e,t)=>{let n=W(e);return{...t,config:{...n.config,apiKey:``}}}})),mn=(0,A.lazy)(()=>u(()=>import(`./CopilotPanel-DDkRd35p.js`).then(e=>({default:e.CopilotPanel})),__vite__mapDeps([0,1,2,3,4,5,6,7]),import.meta.url)),hn=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function gn(e){let t=[],n=e;for(;n?.parentElement&&n.parentElement!==document.documentElement;){let e=n.parentElement;for(let r of Array.from(e.children))r===n||!(r instanceof window.HTMLElement)||(t.push({node:r,inert:r.inert,ariaHidden:r.getAttribute(`aria-hidden`)}),r.inert=!0,r.setAttribute(`aria-hidden`,`true`));n=e}return()=>{for(let{node:e,inert:n,ariaHidden:r}of t)e.inert=n,r==null?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,r)}}function _n({className:e}){return(0,I.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:[(0,I.jsx)(`path`,{d:`M12 3l1.9 4.6L18.5 9.5 13.9 11.4 12 16l-1.9-4.6L5.5 9.5l4.6-1.9L12 3z`,fill:`currentColor`}),(0,I.jsx)(`path`,{d:`M19 14l.8 2 2 .8-2 .8-.8 2-.8-2-2-.8 2-.8.8-2z`,fill:`currentColor`,opacity:`0.7`})]})}var vn=class extends A.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,I.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Copilot failed to load`,tabIndex:-1,className:`fixed inset-y-0 right-0 z-[60] flex w-full max-w-md flex-col items-center justify-center gap-3 border-l border-line bg-surface px-6 text-center`,children:[(0,I.jsx)(`p`,{className:`text-sm text-fg`,children:`Copilot failed to load.`}),(0,I.jsx)(`p`,{className:`text-xs text-muted`,children:`The panel is loaded on demand; the request failed. If the dashboard was just redeployed, reload the page. The rest of the dashboard is unaffected.`}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>{this.setState({failed:!1}),this.props.onClose()},className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Close`})]}):this.props.children}};function yn(){let e=pn(e=>e.open),t=pn(e=>e.setOpen),n=P(e=>e.active),r=e&&n===`copilot`,i=(0,A.useRef)(null),a=(0,A.useRef)(null),o=(0,A.useRef)(null);return(0,A.useEffect)(()=>{let r=P.getState();if(e){if(n===`copilot`)return;r.request(`copilot`)||t(!1);return}r.release(`copilot`)},[e,n,t]),(0,A.useEffect)(()=>()=>{P.getState().release(`copilot`)},[]),(0,A.useEffect)(()=>{if(!r||!i.current)return;let e=i.current,n=document.getElementById(`app-shell`)?()=>{}:gn(e),s=requestAnimationFrame(()=>{let t=e.querySelector(hn),n=e.querySelector(`[role="dialog"]`);(t??n??e).focus()}),c=n=>{if(n.key===`Escape`){n.preventDefault(),t(!1);return}if(n.key!==`Tab`)return;let r=Array.from(e.querySelectorAll(hn));if(r.length===0){n.preventDefault(),(e.querySelector(`[role="dialog"]`)??e).focus();return}let i=r[0],a=r[r.length-1],o=document.activeElement;n.shiftKey&&(o===i||!e.contains(o))?(n.preventDefault(),a.focus()):!n.shiftKey&&(o===a||!e.contains(o))&&(n.preventDefault(),i.focus())};return document.addEventListener(`keydown`,c),()=>{cancelAnimationFrame(s),document.removeEventListener(`keydown`,c),n();let e=a.current;requestAnimationFrame(()=>{F(`copilot`)&&(e?.isConnected?e.focus():o.current?.focus())})}},[r,t]),(0,I.jsxs)(I.Fragment,{children:[!r&&(0,I.jsxs)(`button`,{ref:o,type:`button`,onClick:e=>{a.current=e.currentTarget,P.getState().request(`copilot`)&&t(!0)},className:`fixed bottom-5 right-5 z-40 flex items-center gap-2 rounded-full border border-line bg-surface px-4 py-2.5 text-sm font-medium text-fg shadow-lg transition-colors hover:border-accent/50 hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,"aria-label":`Open Copilot`,children:[(0,I.jsx)(_n,{className:`size-4 text-accent`}),`Copilot`,(0,I.jsx)(`span`,{className:`rounded bg-accent/15 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-accent`,children:`beta`})]}),r&&(0,I.jsx)(`div`,{ref:i,tabIndex:-1,className:`contents`,children:(0,I.jsx)(vn,{onClose:()=>t(!1),children:(0,I.jsx)(A.Suspense,{fallback:(0,I.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Loading Copilot`,tabIndex:-1,className:`fixed inset-y-0 right-0 z-[60] flex w-full max-w-md items-center justify-center border-l border-line bg-surface text-sm text-muted`,children:`Loading Copilot…`}),children:(0,I.jsx)(mn,{})})})})]})}var bn=class extends A.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`ErrorBoundary caught an error`,e,t.componentStack)}componentDidUpdate(e){this.state.error&&e.resetKey!==this.props.resetKey&&this.setState({error:null})}render(){let{error:e}=this.state;return e?(0,I.jsx)(`div`,{className:`flex min-h-screen items-center justify-center p-6`,children:(0,I.jsxs)(O,{className:`w-full max-w-lg`,children:[(0,I.jsx)(Oe,{error:e}),(0,I.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,I.jsx)(Ee,{onClick:()=>window.location.reload(),children:`Reload`})})]})}):this.props.children}},xn={success:{bar:`bg-emerald-500`,title:`text-success`},error:{bar:`bg-red-500`,title:`text-danger`},info:{bar:`bg-accent`,title:`text-accent`}};function Sn({toast:e,dismiss:n}){(0,A.useEffect)(()=>{let t=window.setTimeout(()=>n(e.id),e.ttlMs);return()=>window.clearTimeout(t)},[e.id,e.ttlMs,n]);let r=xn[e.level];return(0,I.jsxs)(`div`,{className:`pointer-events-auto flex w-80 max-w-[calc(100vw-2rem)] overflow-hidden rounded-lg border border-line bg-surface shadow-lg`,children:[(0,I.jsx)(`span`,{className:t(`w-1 shrink-0`,r.bar),"aria-hidden":`true`}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3 px-3 py-2.5`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`div`,{className:t(`text-sm font-medium`,r.title),children:e.title}),e.detail&&(0,I.jsx)(`div`,{className:`mt-0.5 break-words text-xs text-muted`,children:e.detail})]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>n(e.id),"aria-label":`Dismiss notification`,className:`-mr-1 shrink-0 rounded p-0.5 text-faint hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,I.jsx)(_e,{className:`size-4`})})]})]})}function Cn(){let e=te(e=>e.toasts),t=te(e=>e.dismiss);return e.length===0?null:(0,I.jsx)(`section`,{className:`pointer-events-none fixed bottom-4 right-4 z-[60] flex flex-col gap-2`,"aria-label":`Notifications`,"aria-live":`polite`,children:e.map(e=>(0,I.jsx)(Sn,{toast:e,dismiss:t},e.id))})}function wn(e,t){(0,A.useLayoutEffect)(()=>{let t=e.current;t&&(t.scrollTop=0,t.scrollLeft=0)},[t,e])}var Tn={"/":`Overview`,"/queues":`Queues`,"/jobs":`Jobs`,"/dlq":`Dead Letter Queue`,"/cron":`Cron Jobs`,"/flows":`Flows`,"/workflows":`Workflow · Overview`,"/workflows/executions":`Workflow · Executions`,"/workflows/waiting":`Workflow · Waiting & Signals`,"/workflows/compensation":`Workflow · Compensation`,"/workflows/archive":`Workflow · Archive`,"/metrics":`Metrics`,"/workers":`Workers`,"/logs":`Logs`,"/server":`Server`,"/add-job":`Add Job`,"/jobs/bulk-add":`Bulk Add Jobs`,"/job":`Job Inspector`,"/queue-control":`Queue Control`,"/dlq-control":`DLQ Control`,"/webhooks":`Webhooks`,"/diagnostics":`Diagnostics`,"/alerts":`Alerts`,"/benchmark":`Benchmark`,"/database":`Database`,"/mcp":`MCP`,"/usage":`Usage`,"/s3":`S3 Backup`,"/settings":`Settings`,"/overview-classic":`Overview (classic)`,"/queues-classic":`Queues (classic)`,"/jobs-classic":`Jobs (classic)`,"/dlq-classic":`DLQ (classic)`,"/cron-classic":`Cron Jobs (classic)`,"/metrics-classic":`Metrics (classic)`,"/workers-classic":`Workers (classic)`,"/logs-classic":`Logs (classic)`,"/usage-classic":`Usage (classic)`,"/s3-classic":`S3 Backup (classic)`};function En(e){let t=e.length>1?e.replace(/\/+$/,``):e;if(Tn[t])return Tn[t];let n=t.startsWith(`/queues-classic/`);if(n||t.startsWith(`/queues/`)){let e=t.slice(n?16:8);try{e=decodeURIComponent(e)}catch{}return`${e} · Queue${n?` (classic)`:``}`}return`Page not found`}function Dn(e){(0,A.useEffect)(()=>{document.title=`${e} · bunqueue`},[e])}var On=H();function kn({onMenu:e,navOpen:t=!1}){let{pathname:n}=o(),r=En(n);return Dn(r),(0,I.jsxs)(`header`,{className:`sticky top-0 z-10 flex h-14 items-center justify-between gap-3 border-b border-line bg-bg/80 px-4 backdrop-blur sm:px-6 lg:px-8`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`button`,{type:`button`,"aria-label":`Open navigation`,"aria-expanded":t,"aria-controls":`app-nav`,onClick:t=>e?.(t.currentTarget),className:`-ml-1 flex size-9 shrink-0 items-center justify-center rounded-lg text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 lg:hidden`,children:(0,I.jsx)(de,{className:`size-5`})}),(0,I.jsxs)(`div`,{className:`truncate text-sm text-muted`,children:[(0,I.jsx)(`span`,{className:`text-faint`,children:r}),(0,I.jsx)(`span`,{className:`mx-2 hidden text-faint sm:inline`,children:`·`}),(0,I.jsx)(`span`,{className:`hidden text-faint sm:inline`,children:`bunqueue`})]})]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[On&&(0,I.jsxs)(`span`,{title:`Showing canned sample data. No real bunqueue server is connected.`,className:`hidden items-center gap-1.5 rounded-full border border-accent/40 bg-accent/10 px-2.5 py-1 text-xs font-medium text-accent sm:inline-flex`,children:[(0,I.jsx)(`span`,{className:`size-1.5 rounded-full bg-accent`}),`Live demo`]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>window.dispatchEvent(new Event(`command-palette:open`)),title:`Command palette`,"aria-label":`Open command palette`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 sm:hidden`,children:(0,I.jsx)(se,{className:`size-5`})}),(0,I.jsxs)(`button`,{type:`button`,onClick:()=>window.dispatchEvent(new Event(`command-palette:open`)),title:`Command palette (⌘K)`,"aria-label":`Open command palette`,className:`hidden items-center gap-2 rounded-lg border border-line px-2.5 py-1.5 text-xs text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 sm:flex`,children:[(0,I.jsx)(`span`,{children:`Search`}),(0,I.jsx)(`kbd`,{className:`rounded border border-line bg-surface-2 px-1 font-mono text-[10px]`,children:`⌘K`})]}),(0,I.jsx)(d,{to:`/settings`,title:`Settings`,"aria-label":`Open settings`,className:`flex size-8 shrink-0 items-center justify-center rounded-full bg-gradient-to-br from-accent to-fuchsia-600 text-xs font-bold text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:`bq`})]})]})}function An(){let[e,n]=(0,A.useState)(!1),{pathname:r,key:i}=o(),a=(0,A.useRef)(null),s=(0,A.useRef)(null),c=P(e=>e.active),u=P(e=>e.request),d=P(e=>e.release),f=e&&c===`mobile-navigation`,p=(0,A.useCallback)(()=>{n(!1),d(`mobile-navigation`)},[d]);return wn(a,i),(0,A.useEffect)(()=>p(),[r,p]),(0,A.useEffect)(()=>{let e=window.matchMedia(`(min-width: 1024px)`),t=()=>e.matches&&p();return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[p]),(0,A.useEffect)(()=>{if(!f)return;let e=e=>{e.key===`Escape`&&p()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[f,p]),(0,A.useEffect)(()=>{if(!f)return;let e=document.getElementById(`app-nav`),t=()=>e?Array.from(e.querySelectorAll(`a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])`)):[],n=()=>t()[0]?.focus(),r=setTimeout(n,0),i=setTimeout(()=>{e?.contains(document.activeElement)||n()},200),a=n=>{if(n.key!==`Tab`)return;let r=t();if(!r.length)return;let i=r[0],a=r[r.length-1];e?.contains(document.activeElement)?n.shiftKey&&document.activeElement===i?(n.preventDefault(),a.focus()):!n.shiftKey&&document.activeElement===a&&(n.preventDefault(),i.focus()):(n.preventDefault(),(n.shiftKey?a:i).focus())};return window.addEventListener(`keydown`,a),()=>{clearTimeout(r),clearTimeout(i),window.removeEventListener(`keydown`,a);let e=s.current;F(`mobile-navigation`)&&e?.isConnected&&e.focus()}},[f]),(0,A.useEffect)(()=>{e&&c!==`mobile-navigation`&&n(!1)},[e,c]),(0,A.useEffect)(()=>{let e=()=>p();return window.addEventListener(`auth:gate-opened`,e),window.addEventListener(`command-palette:open`,e),()=>{window.removeEventListener(`auth:gate-opened`,e),window.removeEventListener(`command-palette:open`,e)}},[p]),(0,A.useEffect)(()=>()=>{P.getState().release(`mobile-navigation`)},[]),(0,I.jsx)(bn,{children:(0,I.jsxs)(`div`,{id:`app-shell`,className:`flex h-screen overflow-hidden bg-bg text-fg`,children:[(0,I.jsx)(`a`,{href:`#main`,inert:c!==null||void 0,tabIndex:c===null?void 0:-1,className:`sr-only rounded-md bg-accent px-3 py-2 text-sm font-medium text-accent-fg shadow-lg focus:not-sr-only focus:absolute focus:left-4 focus:top-3 focus:z-50`,children:`Skip to content`}),(0,I.jsx)(Xt,{open:f,blocked:c!==null&&c!==`mobile-navigation`,onClose:p}),(0,I.jsxs)(`div`,{id:`app-content`,className:`flex min-w-0 flex-1 flex-col`,inert:c!==null||void 0,"aria-hidden":c!==null||void 0,children:[(0,I.jsx)(kn,{navOpen:f,onMenu:e=>{u(`mobile-navigation`)&&(s.current=e,n(!0))}}),(0,I.jsx)(`main`,{ref:a,id:`main`,tabIndex:-1,className:t(`flex-1 px-4 pt-5 pb-24 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-accent sm:px-6 lg:px-8 lg:pt-6`,f?`overflow-hidden`:`overflow-y-auto`),children:(0,I.jsx)(A.Suspense,{fallback:(0,I.jsx)(`div`,{className:`p-2 text-sm text-muted`,children:`Loading…`}),children:(0,I.jsx)(bn,{resetKey:i,children:(0,I.jsx)(l,{})})})})]}),(0,I.jsx)(en,{}),(0,I.jsx)(Mt,{}),(0,I.jsx)(`div`,{id:`copilot-layer`,inert:c!==null&&c!==`copilot`||void 0,"aria-hidden":c!==null&&c!==`copilot`||void 0,children:(0,I.jsx)(yn,{})}),(0,I.jsx)(Cn,{}),(0,I.jsx)(kt,{})]})})}var jn={default:`text-fg`,green:`text-success`,red:`text-danger`,blue:`text-blue-400 light:text-blue-700`,amber:`text-warning`,accent:`text-accent`};function q({label:e,value:n,tone:r=`default`,hint:i,compact:a}){return(0,I.jsxs)(`div`,{className:t(`rounded-xl border border-line bg-surface`,a?`px-4 py-3`:`px-5 py-4`),children:[(0,I.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,I.jsx)(`div`,{className:t(`mt-2 font-semibold tnum`,a?`text-xl`:`text-3xl`,jn[r]),children:n}),i!=null&&(0,I.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:i})]})}var Mn={overview:{stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},memory:{heapUsed:0,heapTotal:0,rss:0},crons:{total:0}},queuesTotal:0,details:[],failedTotal:0,readyTotal:0};function Nn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function J(e,t){return Nn(e)&&t.every(t=>typeof e[t]==`number`&&Number.isFinite(e[t]))}function Pn(e){if(!Nn(e)||!J(e.stats,[`waiting`,`active`,`completed`,`dlq`,`totalPushed`,`totalPulled`,`uptime`])||!J(e.throughput,[`pushPerSec`,`pullPerSec`])||!J(e.memory,[`rss`])||!J(e.crons,[`total`]))throw Error(`Malformed /dashboard response: required overview metrics are missing or non-numeric.`)}var Fn=class extends Error{status;lastEventIdSent;constructor(e,t,n=!1){super(e),this.status=t,this.lastEventIdSent=n,this.name=`SseConnectError`}},In=new Set([400,409,413,431]);function Ln(e){return e instanceof Fn&&e.lastEventIdSent&&In.has(e.status)}function Rn(e){return!e.includes(`\0`)&&e.length<=4096}function zn(e){return!0}function Bn(e){let t=`message`,n,r=[];for(let i of e.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CopilotPanel-CniuIIPn.js","./cn-zFEt5SO8.js","./react-vendor-CvwrP0tU.js","./bq-C7wdABtE.js","./connectionStore-CFuNYZ_8.js","./upstreamPaths-B_cyinGI.js","./dist-DZL8soAh.js","./form-C4oby9pI.js","./AddJob-DkbI_J5p.js","./toastStore-B31o6Z5J.js","./usePolledData-CNtNtd0a.js","./Button-Ch1W94fJ.js","./Card-CWxrC8OY.js","./PageHeader-CvIyaFOO.js","./StatusBadge-BoOVTnKu.js","./useServerActionGuard-Db7PPgaI.js","./responses-DiIfPXXq.js","./Benchmark-Ey2sq57q.js","./icons-BVzwsfbG.js","./format-Cg7VCIZW.js","./AreaChart-DEAalJ6P.js","./BulkAddJobs-BwPoeSB6.js","./CronManager-Bdg2BECM.js","./feedback-QDN1AsYt.js","./Pagination-x-Cwgrul.js","./Database-CB0oOEFB.js","./Diagnostics-BDRftXQy.js","./api-BxYPEynh.js","./useControlActionGuard-DT7uudrj.js","./controlConnectionEpoch-DzbuWOhe.js","./DlqControl-DZL2lHOU.js","./flowMutationSafety-DSd3JLAV.js","./exportFile-C7xhE8Yh.js","./QueueControl-DusMoa05.js","./QueueActions-b19K0vCT.js","./DlqPro-OqBlzCnN.js","./Flows-BItJzbVQ.js","./JobInspector-CJHX63p_.js","./jobActions-LQD4KfCc.js","./JobsPro-eFVAZJ10.js","./LogsPro-Xm6rylAd.js","./McpServer-Rf3i6lRn.js","./MetricsPro-C63eY00A.js","./useThroughputSeries-y7Yyi7Zh.js","./QueueDetailPro-BNlBOj5s.js","./QueuesOverview-CBFqQ3N_.js","./promisePool-BVfQ9n9Q.js","./S3BackupPro-BtvbPVg-.js","./ServerControl-C5nQ7CCp.js","./UsagePro-bT82DS-d.js","./Webhooks-BjsUMJAn.js","./WorkersPro-hCPhfb1Z.js","./Workflows-DOpeo-TP.js","./Alerts-CFj-u0iV.js","./Cron-B5XFBvU-.js","./Dlq-CJO9itzJ.js","./Jobs-BwmTsjJx.js","./Logs-CXIf58M4.js","./Metrics-Cj3VYxzL.js","./Overview-CUM3XG7A.js","./QueueDetail-CpFIG1PU.js","./Queues-CZ2qc7FY.js","./S3Backup-x4mOV-AO.js","./Settings-B5kCRSBH.js","./Usage-UYovs3D-.js","./Workers-CD4YZpca.js"])))=>i.map(i=>d[i]);
2
+ import{i as e,t}from"./cn-zFEt5SO8.js";import{a as n,c as r,g as i,i as a,l as o,m as s,n as c,o as l,p as u,r as d,s as f,t as p,u as m}from"./react-vendor-CvwrP0tU.js";import{a as h,c as g,d as _,f as v,i as y,l as b,n as x,o as S,r as C,s as ee,u as w}from"./connectionStore-CFuNYZ_8.js";import{t as T}from"./bq-C7wdABtE.js";import{n as te,t as ne}from"./toastStore-B31o6Z5J.js";import{A as re,D as ie,E as ae,S as oe,T as se,_ as ce,c as le,f as ue,g as de,h as fe,k as pe,l as me,m as he,n as ge,o as _e,p as E,r as ve,s as ye,t as be,u as D,v as xe,w as Se,y as Ce}from"./icons-BVzwsfbG.js";import{t as we}from"./api-BxYPEynh.js";import{n as Te}from"./usePolledData-CNtNtd0a.js";import{t as Ee}from"./Button-Ch1W94fJ.js";import{t as O}from"./Card-CWxrC8OY.js";import{i as De,n as Oe,r as ke}from"./feedback-QDN1AsYt.js";import{t as Ae}from"./PageHeader-CvIyaFOO.js";import{c as je,l as Me,n as Ne,r as Pe,s as k,t as Fe,u as Ie}from"./format-Cg7VCIZW.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var A=e(i(),1),Le=s(),Re=`bq-dash-alerts`,ze=1,Be=[`email`,`webhook`,`slack`],Ve=[`error_rate`,`p99_latency`,`waiting`,`failed`,`dlq`],He=[`>=`,`>`,`<=`,`<`],Ue=128,We=200,Ge=2048,Ke=256,qe=/^[^\s@]+@[^\s@]+\.[^\s@]+$/u,Je=()=>`${Date.now().toString(36)}${Math.floor(Math.random()*1e6).toString(36)}`;function Ye(e){let t=new Set(e.map(e=>e.id)),n=Je();if(!t.has(n))return n;let r=1;for(;t.has(`${n}-${r}`);)r+=1;return`${n}-${r}`}function Xe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ze(e){return Be.includes(e)}function Qe(e){return Ve.includes(e)}function $e(e){return He.includes(e)}function et(e,t){let n=t.trim();if(!n||n.length>Ge)return!1;if(e===`email`)return n.length<=320&&qe.test(n);try{let e=new URL(n);return[`http:`,`https:`].includes(e.protocol)&&!e.username&&!e.password}catch{return!1}}function tt(e){if(!Xe(e)||typeof e.id!=`string`||!Ze(e.type)||typeof e.target!=`string`)return null;let t=e.id.trim(),n=e.target.trim();return!t||t.length>Ue||n.length>Ge||e.type===`email`&&!et(e.type,n)?null:{id:t,type:e.type,target:e.type===`email`?n:``}}function nt(e){if(!Xe(e)||typeof e.id!=`string`||typeof e.name!=`string`||!Qe(e.metric)||!$e(e.operator)||typeof e.threshold!=`number`||!Number.isFinite(e.threshold)||typeof e.queue!=`string`||!Ze(e.channel)||typeof e.enabled!=`boolean`)return null;let t=e.id.trim(),n=e.name.trim(),r=e.queue.trim();return!t||t.length>Ue||!n||n.length>We||r.length>Ke||e.threshold<0||e.metric===`error_rate`&&e.threshold>100?null:{id:t,name:n,metric:e.metric,operator:e.operator,threshold:e.threshold,queue:r,channel:e.channel,enabled:e.enabled}}function j(e){let t=Xe(e)?e:{},n=[],r=new Set;if(Array.isArray(t.channels))for(let e of t.channels){if(n.length>=100)break;let t=tt(e);!t||r.has(t.id)||(r.add(t.id),n.push(t))}let i=[],a=new Set;if(Array.isArray(t.rules))for(let e of t.rules){if(i.length>=500)break;let t=nt(e);!t||a.has(t.id)||(a.add(t.id),i.push(t))}return{channels:n,rules:i}}function rt(e){return j({channels:e.channels,rules:e.rules})}var it=b({key:Re,version:ze,sanitizeState:j}),M=v()(_(e=>({channels:[],rules:[],addChannel:(t,n)=>{let r={ok:!1,error:`Alert destination was rejected.`};return e(e=>{let i=n.trim();return!Ze(t)||!et(t,i)?(r={ok:!1,error:`Alert destination is invalid.`},e):e.channels.length>=100?(r={ok:!1,error:`A maximum of 100 alert destinations can be stored in this browser.`},e):(r={ok:!0},{channels:[...e.channels,{id:Ye(e.channels),type:t,target:i}]})}),r},removeChannel:t=>e(e=>({channels:e.channels.filter(e=>e.id!==t)})),addRule:t=>{let n={ok:!1,error:`Alert rule was rejected.`};return e(e=>{if(e.rules.length>=500)return n={ok:!1,error:`A maximum of 500 alert rules can be stored in this browser.`},e;let r=nt({...t,id:Ye(e.rules)});return r?(n={ok:!0},{rules:[...e.rules,r]}):(n={ok:!1,error:`Alert rule contains invalid fields.`},e)}),n},removeRule:t=>e(e=>({rules:e.rules.filter(e=>e.id!==t)})),toggleRule:t=>e(e=>({rules:e.rules.map(e=>e.id===t?{...e,enabled:!e.enabled}:e)}))}),{name:Re,version:ze,storage:w(()=>it),partialize:rt,migrate:j,merge:(e,t)=>({...t,...j(e)})})),at={error_rate:`error rate`,p99_latency:`p99 latency`,waiting:`waiting jobs`,failed:`failed jobs`,dlq:`DLQ size`},ot=10500,st=500,ct=21,lt=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0;function ut(e,t,n){return t===`>=`?e>=n:t===`>`?e>n:t===`<=`?e<=n:t===`<`&&e<n}function dt(e){if(!Array.isArray(e)||e.length>ot)return null;let t=new Set,n=[];for(let r of e){if(!r||typeof r!=`object`||Array.isArray(r))return null;let e=r,i=e.counts;if(typeof e.name!=`string`||!e.name||e.name.length>256||!/^[a-zA-Z0-9_\-.:]+$/.test(e.name)||t.has(e.name)||typeof e.paused!=`boolean`||!i||typeof i!=`object`||Array.isArray(i))return null;let a=i;if(![`waiting`,`active`,`completed`,`failed`,`delayed`].every(e=>lt(a[e])))return null;t.add(e.name),n.push(r)}return n}function ft(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;if(t.ok!==!0||!t.latency||typeof t.latency!=`object`||Array.isArray(t.latency))return null;let n=t.latency.percentiles;if(!n||typeof n!=`object`||Array.isArray(n))return null;for(let e of Object.values(n)){let t=e?.p99;if(!e||typeof e!=`object`||Array.isArray(e)||typeof t!=`number`||!Number.isFinite(t)||t<0)return null}return e}var pt=(e,t)=>{let n=e+t;return n>0?t/n*100:null};function mt(e,t){let n=e.queue.trim();if(e.metric===`waiting`||e.metric===`failed`){if(!t.summary)return null;let r=e.metric;return n?t.summary.find(e=>e.name===n)?.counts[r]??null:t.summary.reduce((e,t)=>e+t.counts[r],0)}if(e.metric===`dlq`)return t.queues?n?t.queues.find(e=>e.name===n)?.dlq??null:t.queues.reduce((e,t)=>e+(t.dlq??0),0):null;if(e.metric===`error_rate`){if(!t.summary)return null;if(n){let e=t.summary.find(e=>e.name===n);return e?pt(e.counts.completed,e.counts.failed):null}return pt(t.summary.reduce((e,t)=>e+t.counts.completed,0),t.summary.reduce((e,t)=>e+t.counts.failed,0))}let r=t.overview?.latency?.percentiles;if(!r)return null;let i=Object.values(r).map(e=>e.p99).filter(Number.isFinite);return i.length?Math.max(...i):null}function ht(e,t,n){if(typeof e!=`object`||!e||Array.isArray(e))return null;let r=e;if(r.ok!==!0||!Array.isArray(r.queues)||!Number.isSafeInteger(r.total)||r.total<0||r.total>ot||n!==null&&r.total!==n||r.offset!==t||r.limit!==st)return null;let i=r.total;if(r.queues.length!==Math.min(st,i-t))return null;let a=[];for(let e of r.queues){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;if(typeof t.name!=`string`||!t.name||t.name.length>256||!/^[a-zA-Z0-9_\-.:]+$/.test(t.name)||!lt(t.dlq))return null;a.push(e)}return{queues:a,total:i}}async function gt(e=T){try{let t=[],n=new Set,r=null;for(let i=0;i<ct;i++){let i=ht(await e.queues(st,t.length),t.length,r);if(!i)return null;r??=i.total;for(let e of i.queues){if(n.has(e.name))return null;n.add(e.name),t.push(e)}if(t.length===r)return t}return null}catch{return null}}var _t=3,vt=e=>`${e.queue||`All queues`}: ${e.metricLabel} ${e.operator} ${e.threshold} (now ${Math.round(e.value)})`;function yt(e){if(globalThis.Notification?.permission===`granted`)try{new Notification(`bunqueue alert: ${e.ruleName}`,{body:vt(e),tag:e.ruleId})}catch{}}function bt(e){if(e.length<=_t){for(let t of e)ne.error(`Alert: ${t.ruleName}`,vt(t)),yt(t);return}ne.error(`${e.length} alert rules breaching`,e.map(e=>e.ruleName).join(`, `));for(let t of e)yt(t)}var xt=3e4,St=(e,t)=>JSON.stringify([e,t]);function Ct(e){let t=JSON.parse(e);if(!Array.isArray(t)||t.length!==2)throw TypeError(`Invalid alert connection identity.`);let[n,r]=t,i=h(n);if(!i||typeof r!=`string`)throw TypeError(`Invalid alert server target.`);let a=r.trim();return Object.freeze({baseUrl:i,...a?{authorization:`Bearer ${a}`}:{}})}function wt(e,t){let n=new Headers({Accept:`application/json`});e.authorization&&n.set(`Authorization`,e.authorization);let r=async r=>{t.throwIfAborted();let i=AbortSignal.any([t,AbortSignal.timeout(xt)]),a=await fetch(e.baseUrl+r,{headers:n,signal:i});if(t.throwIfAborted(),!a.ok)throw await a.body?.cancel().catch(()=>{}),a.status===401&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(`auth:required`,{detail:{scope:`server`,auth:e.authorization,target:e.baseUrl}})),Error(`Alert metrics request failed: HTTP ${a.status}`);let o=await a.text();if(t.throwIfAborted(),!o)throw Error(`Alert metrics request returned an empty response.`);try{return JSON.parse(o)}catch{throw Error(`Alert metrics request returned invalid JSON (HTTP ${a.status}).`)}};return Object.freeze({queuesSummary:()=>r(`/queues/summary`),queues:(e=500,t=0)=>r(`/dashboard/queues?limit=${e}&offset=${t}`),overview:()=>r(`/dashboard`)})}var Tt=15e3,Et=6e4,N=v(e=>({breaching:[],status:`idle`,error:null,connectionIdentity:null,setBreaching:t=>e({breaching:t})}));async function Dt(){if(typeof Notification>`u`)return`denied`;if(Notification.permission===`granted`)return`granted`;try{return await Notification.requestPermission()}catch{return`denied`}}function Ot(){let e=M(e=>e.rules),t=S(e=>St(e.baseUrl,e.token)),n=(0,A.useRef)(new Map),r=(0,A.useRef)(new Map),i=(0,A.useRef)(new Map),a=(0,A.useRef)(new Map),o=(0,A.useRef)(t),s=(0,A.useRef)(0),c=JSON.stringify(e.filter(e=>e.enabled).map(e=>[e.id,e.metric,e.operator,e.threshold,e.queue]));(0,A.useEffect)(()=>{let e=()=>{n.current.clear(),r.current.clear(),i.current.clear(),a.current.clear()},l=o.current!==t;if(l&&(o.current=t,e()),c===`[]`){e(),N.setState({breaching:[],status:`idle`,error:null,connectionIdentity:t});return}let u=new Set(M.getState().rules.filter(e=>e.enabled).map(e=>e.id)),d=l?[]:N.getState().breaching.filter(e=>u.has(e.ruleId));N.setState({breaching:d,status:`checking`,error:null,connectionIdentity:t});let f;try{f=Ct(t)}catch(e){N.setState({breaching:[],status:`degraded`,error:`Alert evaluation failed: ${e.message}`,connectionIdentity:t});return}let p=new AbortController,m=++s.current,h=!1,g=!1,_=()=>{if(h||s.current!==m)return!1;let e=S.getState();return St(e.baseUrl,e.token)===t},v=e=>{for(let t of[...n.current.keys()])e.has(t)||(n.current.delete(t),r.current.delete(t),i.current.delete(t),a.current.delete(t))},y=async()=>{if(!g){g=!0;try{let e=wt(f,p.signal),[o,s,c]=await Promise.all([e.queuesSummary().then(dt).catch(()=>null),gt(e),e.overview().then(ft).catch(()=>null)]);if(!_())return;let l=M.getState().rules.filter(e=>e.enabled),u=new Set(l.map(e=>e.id));if(v(u),!c){let e=N.getState().breaching.filter(e=>u.has(e.ruleId));if(!_())return;N.setState({breaching:e,status:`degraded`,error:`The bunqueue overview endpoint is unavailable; alert results may be stale.`,connectionIdentity:t});return}let d=Date.now(),m=[],h=[],g=!1;for(let e of l){let t=mt(e,{summary:o,queues:s,overview:c});if(t==null){g=!0;let t=n.current.get(e.id)?a.current.get(e.id):void 0;t&&m.push(t);continue}let l=ut(t,e.operator,e.threshold),u=n.current.get(e.id)??!1;if(l){let n=u?i.current.get(e.id)??d:d;i.current.set(e.id,n);let o={ruleId:e.id,ruleName:e.name,metricLabel:at[e.metric],operator:e.operator,threshold:e.threshold,value:t,queue:e.queue,at:n};m.push(o),a.current.set(e.id,o);let s=r.current.get(e.id)??0;d-s>Et&&s<n&&(h.push(o),r.current.set(e.id,d))}else i.current.delete(e.id),a.current.delete(e.id);n.current.set(e.id,l)}if(!_())return;bt(h);let y=!o||!s||g;N.setState({breaching:m,status:y?`degraded`:`live`,error:y?`Some alert rules could not be evaluated; affected results remain unknown.`:null,connectionIdentity:t})}catch(e){if(!_())return;N.setState({status:`degraded`,error:`Alert evaluation failed: ${e.message}`,connectionIdentity:t})}finally{g=!1}}};y();let b=setInterval(y,Tt);return()=>{h=!0,s.current===m&&(s.current+=1),p.abort(),clearInterval(b)}},[c,t])}function kt(){return Ot(),null}var At={authentication:100,"command-palette":80,copilot:60,"database-row":40,"mobile-navigation":20},P=v((e,t)=>({active:null,request(n){let r=t().active;return r===n?!0:r&&At[r]>At[n]?!1:(e({active:n}),!0)},release(n){t().active===n&&e({active:null})},reset(){e({active:null})}}));function F(e){let t=P.getState().active;return t===null||t===e}var I=p();function jt(e){return{scope:e,auth:e===`agent`?x().Authorization:C().Authorization,target:e===`agent`?T.agentBase:y()}}function L(e,t){return e?.scope===t.scope&&e.auth===t.auth&&e.target===t.target}function Mt(){let[e,t]=(0,A.useState)(!1),[n,r]=(0,A.useState)(`server`),[i,a]=(0,A.useState)(``),o=S(e=>e.baseUrl),s=S(e=>e.setToken),c=S(e=>e.setAgentToken),l=(0,A.useRef)(null),u=(0,A.useRef)(null),f=(0,A.useRef)(null),p=(0,A.useRef)(null),m=P(e=>e.active),h=e&&m===`authentication`;(0,A.useEffect)(()=>{let e=e=>{let n=e.detail;if(n?.scope!==`server`&&n?.scope!==`agent`)return;let i=jt(n.scope);n.auth!==i.auth||n.target!==i.target||(L(f.current,i)||(p.current=null,a(``)),f.current=i,P.getState().request(`authentication`),r(i.scope),t(!0),window.dispatchEvent(new window.Event(`auth:gate-opened`)))};return window.addEventListener(`auth:required`,e),()=>window.removeEventListener(`auth:required`,e)},[]),(0,A.useEffect)(()=>()=>{P.getState().release(`authentication`)},[]),(0,A.useEffect)(()=>{if(!h)return;let e=document.activeElement,t=document.getElementById(`app-shell`)?[]:[`app-nav`,`app-content`].map(e=>document.getElementById(e)).filter(e=>e!==null),n=t.map(e=>({element:e,inert:e.inert,ariaHidden:e.getAttribute(`aria-hidden`)}));for(let e of t)e.inert=!0,e.setAttribute(`aria-hidden`,`true`);let r=window.requestAnimationFrame(()=>l.current?.focus()),i=()=>u.current?Array.from(u.current.querySelectorAll(`a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])`)):[],a=e=>{if(e.key!==`Tab`)return;let t=i();if(!t.length){e.preventDefault();return}let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())};return window.addEventListener(`keydown`,a),()=>{window.cancelAnimationFrame(r),window.removeEventListener(`keydown`,a);for(let e of n)e.element.inert=e.inert,e.ariaHidden===null?e.element.removeAttribute(`aria-hidden`):e.element.setAttribute(`aria-hidden`,e.ariaHidden);F(`authentication`)&&e?.isConnected&&e.focus()}},[h]);let g=()=>{f.current=null,p.current=null,a(``),t(!1),P.getState().release(`authentication`)};return h?(0,I.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/60 p-4`,children:(0,I.jsxs)(`form`,{ref:u,onSubmit:e=>{e.preventDefault();let t=f.current,n=p.current;if(!t||!n||!L(n.identity,t)||!L(t,jt(t.scope))){g();return}let r=n.value.trim();r&&(t.scope===`agent`?c(r):s(r),g())},role:`dialog`,"aria-modal":`true`,"aria-label":`Authentication required`,className:`w-full max-w-sm rounded-xl border border-line-strong bg-surface p-6 shadow-2xl`,children:[(0,I.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:`Authentication required`}),n===`agent`?(0,I.jsxs)(`p`,{className:`mt-1 text-sm text-muted`,children:[`The control agent at `,(0,I.jsx)(`span`,{className:`break-all font-mono text-fg`,children:T.agentBase}),` `,`rejected the request (401). Enter its`,` `,(0,I.jsx)(`span`,{className:`font-mono text-fg`,children:`AGENT_TOKEN`}),` to continue.`]}):(0,I.jsxs)(`p`,{className:`mt-1 text-sm text-muted`,children:[`The server at `,(0,I.jsx)(`span`,{className:`break-all font-mono text-fg`,children:o}),` rejected the request (401). Enter its bearer token to continue.`]}),(0,I.jsx)(`input`,{ref:l,type:`password`,value:i,onInput:e=>{let t=e.currentTarget.value;a(t);let n=f.current;p.current=n?{identity:n,value:t}:null},placeholder:n===`agent`?`AGENT_TOKEN`:`Bearer token`,"aria-label":n===`agent`?`Agent token`:`Bearer token`,name:n===`agent`?`agent-token`:`server-token`,autoComplete:`current-password`,className:`mt-4 w-full rounded-lg border border-line bg-surface-2 px-3 py-2 text-sm text-fg outline-none placeholder:text-faint focus-visible:ring-2 focus-visible:ring-accent/50`}),(0,I.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-3`,children:[(0,I.jsx)(d,{to:`/settings`,onClick:g,className:`text-xs text-muted underline-offset-2 hover:text-fg hover:underline`,children:`Open Settings instead`}),(0,I.jsx)(`button`,{type:`submit`,disabled:!i.trim(),className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-50`,children:`Unlock`})]})]})}):null}var Nt=`bq-dash-theme`,Pt=1;function R(e){return e===`light`?`light`:`dark`}function z(){try{return globalThis.localStorage??null}catch{return null}}var Ft={getItem(e){let t=z();if(!t)return null;try{let n=t.getItem(e);if(n===null||e!==Nt)return n;let r=JSON.parse(n),i=r&&typeof r==`object`&&!Array.isArray(r)?r:{},a=i.state&&typeof i.state==`object`&&!Array.isArray(i.state)?i.state:{},o=JSON.stringify({state:{theme:R(a.theme)},version:Pt});if(n!==o)try{t.setItem(e,o)}catch{}return o}catch{try{t.removeItem(e)}catch{}return null}},setItem(e,t){try{z()?.setItem(e,t)}catch{}},removeItem(e){try{z()?.removeItem(e)}catch{}}};function B(e){typeof document<`u`&&(document.documentElement.dataset.theme=e,document.documentElement.style.colorScheme=e)}var V=v()(_((e,t)=>({theme:`dark`,toggle:()=>{let n=t().theme===`dark`?`light`:`dark`;B(n),e({theme:n})},setTheme:t=>{let n=R(t);B(n),e({theme:n})}}),{name:Nt,version:Pt,storage:w(()=>Ft),partialize:e=>({theme:R(e.theme)}),merge:(e,t)=>{let n=e&&typeof e==`object`&&!Array.isArray(e)?e:{};return{...t,theme:R(n.theme)}},onRehydrateStorage:()=>e=>{e&&B(R(e.theme))}}));function It(){B(R(V.getState().theme))}var Lt={connecting:{dot:`bg-zinc-500`,label:`connecting`},connected:{dot:`bg-emerald-400`,label:`connected`},degraded:{dot:`bg-amber-400`,label:`reachable, degraded`},offline:{dot:`bg-red-400`,label:`offline`}};function Rt(){let e=S(e=>e.baseUrl),{data:n,error:r,loading:i}=Te(async()=>{let e=await we.health();if(typeof e.ok!=`boolean`)throw Error(`Malformed health response`);return{healthy:e.ok}},[],{intervalMs:15e3}),a=Lt[i?`connecting`:r||!n?`offline`:n.healthy?`connected`:`degraded`],o=e.replace(/^https?:\/\//,``)||`local`;return(0,I.jsxs)(`div`,{className:`mx-3 mb-4 flex items-center gap-2 rounded-lg border border-line bg-surface px-3 py-1.5`,children:[(0,I.jsx)(`span`,{className:t(`size-1.5 rounded-full`,a.dot),title:a.label}),(0,I.jsx)(`span`,{className:`truncate font-mono text-[11px] text-muted`,title:e,children:o}),(0,I.jsx)(`span`,{className:`sr-only`,children:a.label})]})}function zt(e){let t=null;try{return t=document.createElement(`textarea`),t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`)}catch{return!1}finally{t?.remove()}}function Bt({value:e,className:n}){let[r,i]=(0,A.useState)(`idle`),a=(0,A.useRef)(null);(0,A.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]);let o=async()=>{let t=!1;if(navigator.clipboard)try{await navigator.clipboard.writeText(e),t=!0}catch{}t||=zt(e),i(t?`copied`:`failed`),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(`idle`),1500)},s=r===`copied`?`Copied to clipboard`:r===`failed`?`Copy failed`:`Copy to clipboard`;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,onClick:o,"aria-label":s,title:s,className:t(`inline-flex size-6 shrink-0 items-center justify-center rounded-md text-faint transition-colors hover:bg-surface-2 hover:text-fg`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,n),children:r===`copied`?(0,I.jsx)(ve,{className:`size-3.5 text-success`}):r===`failed`?(0,I.jsx)(_e,{className:`size-3.5 text-danger`}):(0,I.jsx)(ye,{className:`size-3.5`})}),(0,I.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:r===`idle`?``:s})]})}var Vt;function H(){return Vt===void 0&&(Vt=Ht()),Vt}function Ht(){if(typeof window>`u`)return!1;let{search:e,hash:t}=window.location;return new URLSearchParams(e).has(`demo`)||t.replace(/^#/,``)===`demo`}var Ut=`https://github.com/egeominotti/bunqueue-dashboard`,Wt=`https://egeominotti.github.io/bunqueue-dashboard/docs/`,Gt=`bunx bunqueue-dashboard`;function Kt(){return(0,I.jsxs)(`div`,{className:`mx-3 mb-2 rounded-lg border border-accent/30 bg-accent/5 p-3`,children:[(0,I.jsx)(`p`,{className:`mb-2 text-[11px] font-medium leading-snug text-fg`,children:`Like it? Run it on your own bunqueue server.`}),(0,I.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 rounded-md border border-line bg-surface-2 px-2 py-1`,children:[(0,I.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-fg`,children:Gt}),(0,I.jsx)(Bt,{value:Gt})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(`a`,{href:Ut,target:`_blank`,rel:`noreferrer`,className:`flex flex-1 items-center justify-center gap-1 rounded-md bg-accent px-2 py-1.5 text-[11px] font-semibold text-accent-fg transition-opacity hover:opacity-90`,children:[(0,I.jsx)(`span`,{"aria-hidden":!0,children:`★`}),` Star`]}),(0,I.jsx)(`a`,{href:Wt,target:`_blank`,rel:`noreferrer`,className:`flex flex-1 items-center justify-center rounded-md border border-line px-2 py-1.5 text-[11px] font-medium text-muted transition-colors hover:bg-surface-2 hover:text-fg`,children:`Docs`})]})]})}function qt(){let e=S(e=>e.baseUrl),t=e===`/api`?`localhost:6790`:e.replace(/^https?:\/\//,``);return(0,I.jsxs)(I.Fragment,{children:[H()&&(0,I.jsx)(Kt,{}),(0,I.jsxs)(`div`,{className:`mx-3 mb-3 flex items-center gap-2.5 rounded-lg border border-line bg-surface px-3 py-2`,children:[(0,I.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-full bg-gradient-to-br from-accent to-fuchsia-600 text-[11px] font-bold text-white`,children:`bq`}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`div`,{className:`truncate text-xs font-medium text-fg`,children:`bunqueue`}),(0,I.jsx)(`div`,{className:`truncate font-mono text-[10px] text-faint`,title:e,children:t})]}),(0,I.jsx)(d,{to:`/settings`,"aria-label":`Settings`,className:`text-faint transition-colors hover:text-fg`,children:(0,I.jsx)(ae,{className:`size-4`})})]})]})}var Jt=[{section:null,items:[{to:`/`,label:`Overview`,icon:Ce,end:!0}]},{section:`Queues`,items:[{to:`/queues`,label:`Queues`,icon:oe,end:!0},{to:`/jobs`,label:`Jobs`,icon:E,end:!0},{to:`/dlq`,label:`Dead Letter Queue`,icon:D},{to:`/cron`,label:`Cron Jobs`,icon:le}]},{section:`Workflow`,items:[{to:`/workflows`,label:`Overview`,icon:Ce,end:!0},{to:`/flows`,label:`Job Flows`,icon:ge,end:!0},{to:`/workflows/executions`,label:`Executions`,icon:E,end:!0},{to:`/workflows/waiting`,label:`Waiting & Signals`,icon:le,end:!0},{to:`/workflows/compensation`,label:`Compensation`,icon:D,end:!0},{to:`/workflows/archive`,label:`Archive`,icon:me,end:!0}]},{section:`Monitoring`,items:[{to:`/metrics`,label:`Metrics`,icon:ce},{to:`/workers`,label:`Workers`,icon:re},{to:`/logs`,label:`Logs`,icon:fe},{to:`/alerts`,label:`Alerts`,icon:be}]},{section:`Control`,items:[{to:`/server`,label:`Server`,icon:re},{to:`/add-job`,label:`Add Job`,icon:E},{to:`/jobs/bulk-add`,label:`Bulk Add`,icon:E},{to:`/job`,label:`Job Inspector`,icon:ue},{to:`/queue-control`,label:`Queue Control`,icon:oe},{to:`/dlq-control`,label:`DLQ Control`,icon:D},{to:`/webhooks`,label:`Webhooks`,icon:he},{to:`/diagnostics`,label:`Diagnostics`,icon:ce},{to:`/benchmark`,label:`Benchmark`,icon:he}]},{section:`Management`,items:[{to:`/database`,label:`Database`,icon:me},{to:`/mcp`,label:`MCP`,icon:he},{to:`/usage`,label:`Usage`,icon:pe},{to:`/s3`,label:`S3 Backup`,icon:Se},{to:`/settings`,label:`Settings`,icon:ae}]}];function Yt(){let e=V(e=>e.theme),t=V(e=>e.toggle),n=e===`dark`;return(0,I.jsxs)(`button`,{type:`button`,onClick:t,className:`mx-3 mb-3 flex items-center gap-3 rounded-lg px-3 py-2 text-sm 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:[n?(0,I.jsx)(ie,{className:`size-4`}):(0,I.jsx)(xe,{className:`size-4`}),n?`Light Mode`:`Dark Mode`]})}function Xt({open:e=!1,blocked:n=!1,onClose:r}){return(0,I.jsxs)(I.Fragment,{children:[e&&(0,I.jsx)(`button`,{type:`button`,"aria-label":`Close navigation`,tabIndex:-1,onClick:r,className:`fixed inset-0 z-40 bg-black/50 lg:hidden`}),(0,I.jsxs)(`div`,{id:`app-nav`,role:e?`dialog`:`complementary`,"aria-modal":e||void 0,"aria-label":e?`Navigation menu`:void 0,inert:n?!0:void 0,"aria-hidden":n||void 0,className:t(`flex w-60 shrink-0 flex-col border-r border-line bg-sidebar`,`fixed inset-y-0 left-0 z-50 transition-[transform,visibility] lg:static lg:z-auto lg:translate-x-0`,e?`translate-x-0`:`-translate-x-full lg:translate-x-0 invisible lg:visible`),children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-5`,children:[(0,I.jsx)(`span`,{className:`text-lg font-bold tracking-tight text-fg`,children:`bunqueue`}),(0,I.jsx)(`span`,{className:`rounded-md bg-accent/15 px-1.5 py-0.5 text-[10px] font-bold uppercase tracking-wider text-accent`,children:`dash`}),(0,I.jsx)(`span`,{title:`Beta — under active development`,className:`rounded-md bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-bold uppercase tracking-wider text-warning`,children:`beta`})]}),(0,I.jsx)(`nav`,{className:`flex-1 overscroll-contain overflow-y-auto px-3 pb-4`,children:Jt.map(e=>(0,I.jsxs)(`div`,{className:`mb-4`,children:[e.section&&(0,I.jsx)(`div`,{className:`px-2 pb-2 pt-1 text-[10px] font-semibold uppercase tracking-wider text-faint`,children:e.section}),(0,I.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.items.map(({to:e,label:n,icon:r,end:i})=>(0,I.jsx)(a,{to:e,end:i,className:({isActive:e})=>t(`group relative flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,e?`bg-surface-2 text-fg`:`text-muted hover:bg-surface-2/60 hover:text-fg`),children:({isActive:e})=>(0,I.jsxs)(I.Fragment,{children:[e&&(0,I.jsx)(`span`,{className:`absolute inset-y-1.5 left-0 w-0.5 rounded-full bg-accent`}),(0,I.jsx)(r,{className:`size-[18px] shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:n})]})},e))})]},e.section??`root`))}),(0,I.jsx)(Rt,{}),(0,I.jsx)(Yt,{}),(0,I.jsx)(qt,{})]})]})}var Zt=`https://egeominotti.github.io/bunqueue-dashboard/docs/`,Qt=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function $t(e){let t=e.parentElement;if(!t)return()=>{};let n=Array.from(t.children).filter(t=>t!==e),r=n.map(e=>({node:e,inert:e.inert,ariaHidden:e.getAttribute(`aria-hidden`)}));for(let e of n)e.inert=!0,e.setAttribute(`aria-hidden`,`true`);return()=>{for(let{node:e,inert:t,ariaHidden:n}of r)e.inert=t,n==null?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,n)}}function en(){let[e,t]=(0,A.useState)(``),[n,r]=(0,A.useState)(0),i=P(e=>e.active===`command-palette`),a=P(e=>e.release),o=m(),s=V(e=>e.toggle),c=(0,A.useRef)(null),l=(0,A.useRef)(null),u=(0,A.useRef)(null),d=(0,A.useRef)(null),f=(0,A.useCallback)(()=>a(`command-palette`),[a]),p=(0,A.useMemo)(()=>{let e=Jt.flatMap(e=>e.items.map(t=>({id:`nav:${t.to}`,label:t.label,hint:e.section??`Home`,run:()=>o(t.to)}))),t=[{id:`act:theme`,label:`Toggle theme (dark / light)`,hint:`Action`,run:s},{id:`act:docs`,label:`Open documentation`,hint:`Action`,run:()=>window.open(Zt,`_blank`,`noopener`)}];return[...e,...t]},[o,s]),h=(0,A.useMemo)(()=>{let t=e.trim().toLowerCase();return t?p.filter(e=>`${e.label} ${e.hint}`.toLowerCase().includes(t)):p},[p,e]);(0,A.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`){e.preventDefault();let t=P.getState();t.active===`command-palette`?t.release(`command-palette`):t.request(`command-palette`)}},t=()=>P.getState().request(`command-palette`);return window.addEventListener(`keydown`,e),window.addEventListener(`command-palette:open`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`command-palette:open`,t)}},[]),(0,A.useEffect)(()=>{if(!i)return;let e=document.activeElement;t(``),r(0);let n=u.current&&!document.getElementById(`app-shell`)?$t(u.current):()=>{},a=requestAnimationFrame(()=>c.current?.focus()),o=e=>{if(e.key===`Escape`){e.preventDefault(),f();return}if(e.key!==`Tab`)return;let t=d.current;if(!t)return;let n=Array.from(t.querySelectorAll(Qt));if(n.length===0){e.preventDefault(),t.focus();return}let r=n[0],i=n[n.length-1],a=document.activeElement;e.shiftKey&&(a===r||!t.contains(a))?(e.preventDefault(),i.focus()):!e.shiftKey&&(a===i||!t.contains(a))&&(e.preventDefault(),r.focus())};return document.addEventListener(`keydown`,o),()=>{cancelAnimationFrame(a),document.removeEventListener(`keydown`,o),n(),F(`command-palette`)&&e?.isConnected&&e.focus()}},[i,f]),(0,A.useEffect)(()=>{l.current?.querySelector(`[data-idx="${n}"]`)?.scrollIntoView({block:`nearest`})},[n]);let g=(0,A.useCallback)(e=>{e&&(e.run(),f())},[f]);return i?(0,I.jsxs)(`div`,{ref:u,className:`fixed inset-0 z-50 flex items-start justify-center p-4 pt-[12vh]`,children:[(0,I.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":`Close command palette`,onClick:f,className:`fixed inset-0 bg-black/50`}),(0,I.jsxs)(`div`,{ref:d,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,className:`relative z-10 w-full max-w-lg overflow-hidden rounded-xl border border-line-strong bg-surface shadow-2xl`,children:[(0,I.jsx)(`input`,{ref:c,role:`combobox`,value:e,onChange:e=>{t(e.target.value),r(0)},onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),f()):e.key===`ArrowDown`?(e.preventDefault(),r(e=>Math.min(e+1,Math.max(0,h.length-1)))):e.key===`ArrowUp`?(e.preventDefault(),r(e=>Math.max(e-1,0))):e.key===`Enter`&&(e.preventDefault(),g(h[n]))},placeholder:`Search pages and actions…`,"aria-label":`Search pages and actions`,"aria-autocomplete":`list`,"aria-expanded":`true`,"aria-controls":`command-palette-results`,"aria-activedescendant":h[n]?`command-palette-option-${n}`:void 0,autoComplete:`off`,name:`command-palette-search`,className:`w-full border-b border-line bg-transparent px-4 py-3 text-sm text-fg outline-none placeholder:text-faint focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent/50`}),(0,I.jsxs)(`div`,{ref:l,id:`command-palette-results`,role:`listbox`,className:`max-h-80 overflow-y-auto overscroll-contain py-2`,"aria-label":`Results`,children:[h.length===0&&(0,I.jsx)(`div`,{role:`presentation`,className:`px-4 py-6 text-center text-sm text-faint`,children:`No matches`}),h.map((e,t)=>(0,I.jsx)(`div`,{role:`presentation`,children:(0,I.jsxs)(`button`,{type:`button`,id:`command-palette-option-${t}`,role:`option`,"aria-selected":t===n,tabIndex:-1,"data-idx":t,onMouseEnter:()=>r(t),onClick:()=>g(e),className:`flex w-full items-center justify-between gap-3 px-4 py-2 text-left text-sm transition-colors ${t===n?`bg-accent/15 text-fg`:`text-muted`}`,children:[(0,I.jsx)(`span`,{className:`truncate`,children:e.label}),(0,I.jsx)(`span`,{className:`shrink-0 text-xs text-faint`,children:e.hint})]})},e.id))]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between border-t border-line px-4 py-2 text-xs text-faint`,children:[(0,I.jsx)(`span`,{children:`↑↓ navigate · ↵ open · esc close`}),(0,I.jsx)(`span`,{className:`font-mono`,children:`⌘K`})]})]})]}):null}var tn=`bq-dash-copilot`,nn=1,rn=new Set([`anthropic`,`openai`,`google`,`zai`,`openrouter`,`custom`]),U={provider:`anthropic`,baseURL:``,model:`claude-opus-4-8`,apiKey:``};function an(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function on(e,t){return typeof e==`string`?e:t}function sn(e){return typeof e==`string`&&rn.has(e)?e:U.provider}function cn(e,t=``){let n=an(e)?e:{},r=sn(n.provider);return{provider:r,baseURL:r===`custom`?on(n.baseURL,U.baseURL):U.baseURL,model:on(n.model,U.model),apiKey:t}}function W(e){let t=cn((an(e)?e:{}).config);return{config:{provider:t.provider,baseURL:t.baseURL,model:t.model}}}var ln=0,un=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${(ln++).toString(36)}-${Math.random().toString(36).slice(2,8)}`,G=new Map,K=(e,t,n)=>e.map(e=>e.id===t?n(e):e);function dn(e){return W(e)}var fn=b({key:tn,version:nn,sanitizeState:W}),pn=v()(_(e=>({open:!1,config:{...U},messages:[],pending:[],busy:!1,setOpen:t=>e({open:t}),toggle:()=>e(e=>({open:!e.open})),setConfig:t=>e(e=>{let n={...e.config,...t};return{config:cn(n,on(n.apiKey,``))}}),clear:()=>{for(let e of G.values())e(!1);G.clear(),e({messages:[],pending:[]})},cancelPending:()=>{for(let e of G.values())e(!1);G.clear(),e({pending:[]})},setBusy:t=>e({busy:t}),addUser:t=>e(e=>({messages:[...e.messages,{id:un(),role:`user`,content:t}]})),startAssistant:()=>{let t=un();return e(e=>({messages:[...e.messages,{id:t,role:`assistant`,content:``,tools:[]}]})),t},appendAssistant:(t,n)=>e(e=>({messages:K(e.messages,t,e=>({...e,content:e.content+n}))})),finishAssistant:(t,n)=>e(e=>({messages:K(e.messages,t,e=>({...e,done:!0,error:!!n?.error,content:n?.error?e.content?`${e.content}\n\n${n.error}`:n.error:e.content}))})),addTool:(t,n)=>e(e=>({messages:K(e.messages,t,e=>({...e,tools:[...e.tools??[],n]}))})),updateTool:(t,n,r)=>e(e=>({messages:K(e.messages,t,e=>({...e,tools:(e.tools??[]).map(e=>e.id===n?{...e,...r}:e)}))})),requestConfirm:t=>new Promise(n=>{let r=un();G.set(r,n),e(e=>({pending:[...e.pending,{...t,id:r}]}))}),resolveConfirm:(t,n)=>{let r=G.get(t);r&&(G.delete(t),r(n)),e(e=>({pending:e.pending.filter(e=>e.id!==t)}))}}),{name:tn,version:nn,storage:w(()=>fn),partialize:e=>dn(e),migrate:W,merge:(e,t)=>{let n=W(e);return{...t,config:{...n.config,apiKey:``}}}})),mn=(0,A.lazy)(()=>u(()=>import(`./CopilotPanel-CniuIIPn.js`).then(e=>({default:e.CopilotPanel})),__vite__mapDeps([0,1,2,3,4,5,6,7]),import.meta.url)),hn=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function gn(e){let t=[],n=e;for(;n?.parentElement&&n.parentElement!==document.documentElement;){let e=n.parentElement;for(let r of Array.from(e.children))r===n||!(r instanceof window.HTMLElement)||(t.push({node:r,inert:r.inert,ariaHidden:r.getAttribute(`aria-hidden`)}),r.inert=!0,r.setAttribute(`aria-hidden`,`true`));n=e}return()=>{for(let{node:e,inert:n,ariaHidden:r}of t)e.inert=n,r==null?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,r)}}function _n({className:e}){return(0,I.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:[(0,I.jsx)(`path`,{d:`M12 3l1.9 4.6L18.5 9.5 13.9 11.4 12 16l-1.9-4.6L5.5 9.5l4.6-1.9L12 3z`,fill:`currentColor`}),(0,I.jsx)(`path`,{d:`M19 14l.8 2 2 .8-2 .8-.8 2-.8-2-2-.8 2-.8.8-2z`,fill:`currentColor`,opacity:`0.7`})]})}var vn=class extends A.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,I.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Copilot failed to load`,tabIndex:-1,className:`fixed inset-y-0 right-0 z-[60] flex w-full max-w-md flex-col items-center justify-center gap-3 border-l border-line bg-surface px-6 text-center`,children:[(0,I.jsx)(`p`,{className:`text-sm text-fg`,children:`Copilot failed to load.`}),(0,I.jsx)(`p`,{className:`text-xs text-muted`,children:`The panel is loaded on demand; the request failed. If the dashboard was just redeployed, reload the page. The rest of the dashboard is unaffected.`}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>{this.setState({failed:!1}),this.props.onClose()},className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Close`})]}):this.props.children}};function yn(){let e=pn(e=>e.open),t=pn(e=>e.setOpen),n=P(e=>e.active),r=e&&n===`copilot`,i=(0,A.useRef)(null),a=(0,A.useRef)(null),o=(0,A.useRef)(null);return(0,A.useEffect)(()=>{let r=P.getState();if(e){if(n===`copilot`)return;r.request(`copilot`)||t(!1);return}r.release(`copilot`)},[e,n,t]),(0,A.useEffect)(()=>()=>{P.getState().release(`copilot`)},[]),(0,A.useEffect)(()=>{if(!r||!i.current)return;let e=i.current,n=document.getElementById(`app-shell`)?()=>{}:gn(e),s=requestAnimationFrame(()=>{let t=e.querySelector(hn),n=e.querySelector(`[role="dialog"]`);(t??n??e).focus()}),c=n=>{if(n.key===`Escape`){n.preventDefault(),t(!1);return}if(n.key!==`Tab`)return;let r=Array.from(e.querySelectorAll(hn));if(r.length===0){n.preventDefault(),(e.querySelector(`[role="dialog"]`)??e).focus();return}let i=r[0],a=r[r.length-1],o=document.activeElement;n.shiftKey&&(o===i||!e.contains(o))?(n.preventDefault(),a.focus()):!n.shiftKey&&(o===a||!e.contains(o))&&(n.preventDefault(),i.focus())};return document.addEventListener(`keydown`,c),()=>{cancelAnimationFrame(s),document.removeEventListener(`keydown`,c),n();let e=a.current;requestAnimationFrame(()=>{F(`copilot`)&&(e?.isConnected?e.focus():o.current?.focus())})}},[r,t]),(0,I.jsxs)(I.Fragment,{children:[!r&&(0,I.jsxs)(`button`,{ref:o,type:`button`,onClick:e=>{a.current=e.currentTarget,P.getState().request(`copilot`)&&t(!0)},className:`fixed bottom-5 right-5 z-40 flex items-center gap-2 rounded-full border border-line bg-surface px-4 py-2.5 text-sm font-medium text-fg shadow-lg transition-colors hover:border-accent/50 hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,"aria-label":`Open Copilot`,children:[(0,I.jsx)(_n,{className:`size-4 text-accent`}),`Copilot`,(0,I.jsx)(`span`,{className:`rounded bg-accent/15 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-accent`,children:`beta`})]}),r&&(0,I.jsx)(`div`,{ref:i,tabIndex:-1,className:`contents`,children:(0,I.jsx)(vn,{onClose:()=>t(!1),children:(0,I.jsx)(A.Suspense,{fallback:(0,I.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Loading Copilot`,tabIndex:-1,className:`fixed inset-y-0 right-0 z-[60] flex w-full max-w-md items-center justify-center border-l border-line bg-surface text-sm text-muted`,children:`Loading Copilot…`}),children:(0,I.jsx)(mn,{})})})})]})}var bn=class extends A.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`ErrorBoundary caught an error`,e,t.componentStack)}componentDidUpdate(e){this.state.error&&e.resetKey!==this.props.resetKey&&this.setState({error:null})}render(){let{error:e}=this.state;return e?(0,I.jsx)(`div`,{className:`flex min-h-screen items-center justify-center p-6`,children:(0,I.jsxs)(O,{className:`w-full max-w-lg`,children:[(0,I.jsx)(Oe,{error:e}),(0,I.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,I.jsx)(Ee,{onClick:()=>window.location.reload(),children:`Reload`})})]})}):this.props.children}},xn={success:{bar:`bg-emerald-500`,title:`text-success`},error:{bar:`bg-red-500`,title:`text-danger`},info:{bar:`bg-accent`,title:`text-accent`}};function Sn({toast:e,dismiss:n}){(0,A.useEffect)(()=>{let t=window.setTimeout(()=>n(e.id),e.ttlMs);return()=>window.clearTimeout(t)},[e.id,e.ttlMs,n]);let r=xn[e.level];return(0,I.jsxs)(`div`,{className:`pointer-events-auto flex w-80 max-w-[calc(100vw-2rem)] overflow-hidden rounded-lg border border-line bg-surface shadow-lg`,children:[(0,I.jsx)(`span`,{className:t(`w-1 shrink-0`,r.bar),"aria-hidden":`true`}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3 px-3 py-2.5`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`div`,{className:t(`text-sm font-medium`,r.title),children:e.title}),e.detail&&(0,I.jsx)(`div`,{className:`mt-0.5 break-words text-xs text-muted`,children:e.detail})]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>n(e.id),"aria-label":`Dismiss notification`,className:`-mr-1 shrink-0 rounded p-0.5 text-faint hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,I.jsx)(_e,{className:`size-4`})})]})]})}function Cn(){let e=te(e=>e.toasts),t=te(e=>e.dismiss);return e.length===0?null:(0,I.jsx)(`section`,{className:`pointer-events-none fixed bottom-4 right-4 z-[60] flex flex-col gap-2`,"aria-label":`Notifications`,"aria-live":`polite`,children:e.map(e=>(0,I.jsx)(Sn,{toast:e,dismiss:t},e.id))})}function wn(e,t){(0,A.useLayoutEffect)(()=>{let t=e.current;t&&(t.scrollTop=0,t.scrollLeft=0)},[t,e])}var Tn={"/":`Overview`,"/queues":`Queues`,"/jobs":`Jobs`,"/dlq":`Dead Letter Queue`,"/cron":`Cron Jobs`,"/flows":`Flows`,"/workflows":`Workflow · Overview`,"/workflows/executions":`Workflow · Executions`,"/workflows/waiting":`Workflow · Waiting & Signals`,"/workflows/compensation":`Workflow · Compensation`,"/workflows/archive":`Workflow · Archive`,"/metrics":`Metrics`,"/workers":`Workers`,"/logs":`Logs`,"/server":`Server`,"/add-job":`Add Job`,"/jobs/bulk-add":`Bulk Add Jobs`,"/job":`Job Inspector`,"/queue-control":`Queue Control`,"/dlq-control":`DLQ Control`,"/webhooks":`Webhooks`,"/diagnostics":`Diagnostics`,"/alerts":`Alerts`,"/benchmark":`Benchmark`,"/database":`Database`,"/mcp":`MCP`,"/usage":`Usage`,"/s3":`S3 Backup`,"/settings":`Settings`,"/overview-classic":`Overview (classic)`,"/queues-classic":`Queues (classic)`,"/jobs-classic":`Jobs (classic)`,"/dlq-classic":`DLQ (classic)`,"/cron-classic":`Cron Jobs (classic)`,"/metrics-classic":`Metrics (classic)`,"/workers-classic":`Workers (classic)`,"/logs-classic":`Logs (classic)`,"/usage-classic":`Usage (classic)`,"/s3-classic":`S3 Backup (classic)`};function En(e){let t=e.length>1?e.replace(/\/+$/,``):e;if(Tn[t])return Tn[t];let n=t.startsWith(`/queues-classic/`);if(n||t.startsWith(`/queues/`)){let e=t.slice(n?16:8);try{e=decodeURIComponent(e)}catch{}return`${e} · Queue${n?` (classic)`:``}`}return`Page not found`}function Dn(e){(0,A.useEffect)(()=>{document.title=`${e} · bunqueue`},[e])}var On=H();function kn({onMenu:e,navOpen:t=!1}){let{pathname:n}=o(),r=En(n);return Dn(r),(0,I.jsxs)(`header`,{className:`sticky top-0 z-10 flex h-14 items-center justify-between gap-3 border-b border-line bg-bg/80 px-4 backdrop-blur sm:px-6 lg:px-8`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`button`,{type:`button`,"aria-label":`Open navigation`,"aria-expanded":t,"aria-controls":`app-nav`,onClick:t=>e?.(t.currentTarget),className:`-ml-1 flex size-9 shrink-0 items-center justify-center rounded-lg text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 lg:hidden`,children:(0,I.jsx)(de,{className:`size-5`})}),(0,I.jsxs)(`div`,{className:`truncate text-sm text-muted`,children:[(0,I.jsx)(`span`,{className:`text-faint`,children:r}),(0,I.jsx)(`span`,{className:`mx-2 hidden text-faint sm:inline`,children:`·`}),(0,I.jsx)(`span`,{className:`hidden text-faint sm:inline`,children:`bunqueue`})]})]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[On&&(0,I.jsxs)(`span`,{title:`Showing canned sample data. No real bunqueue server is connected.`,className:`hidden items-center gap-1.5 rounded-full border border-accent/40 bg-accent/10 px-2.5 py-1 text-xs font-medium text-accent sm:inline-flex`,children:[(0,I.jsx)(`span`,{className:`size-1.5 rounded-full bg-accent`}),`Live demo`]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>window.dispatchEvent(new Event(`command-palette:open`)),title:`Command palette`,"aria-label":`Open command palette`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 sm:hidden`,children:(0,I.jsx)(se,{className:`size-5`})}),(0,I.jsxs)(`button`,{type:`button`,onClick:()=>window.dispatchEvent(new Event(`command-palette:open`)),title:`Command palette (⌘K)`,"aria-label":`Open command palette`,className:`hidden items-center gap-2 rounded-lg border border-line px-2.5 py-1.5 text-xs text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 sm:flex`,children:[(0,I.jsx)(`span`,{children:`Search`}),(0,I.jsx)(`kbd`,{className:`rounded border border-line bg-surface-2 px-1 font-mono text-[10px]`,children:`⌘K`})]}),(0,I.jsx)(d,{to:`/settings`,title:`Settings`,"aria-label":`Open settings`,className:`flex size-8 shrink-0 items-center justify-center rounded-full bg-gradient-to-br from-accent to-fuchsia-600 text-xs font-bold text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:`bq`})]})]})}function An(){let[e,n]=(0,A.useState)(!1),{pathname:r,key:i}=o(),a=(0,A.useRef)(null),s=(0,A.useRef)(null),c=P(e=>e.active),u=P(e=>e.request),d=P(e=>e.release),f=e&&c===`mobile-navigation`,p=(0,A.useCallback)(()=>{n(!1),d(`mobile-navigation`)},[d]);return wn(a,i),(0,A.useEffect)(()=>p(),[r,p]),(0,A.useEffect)(()=>{let e=window.matchMedia(`(min-width: 1024px)`),t=()=>e.matches&&p();return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[p]),(0,A.useEffect)(()=>{if(!f)return;let e=e=>{e.key===`Escape`&&p()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[f,p]),(0,A.useEffect)(()=>{if(!f)return;let e=document.getElementById(`app-nav`),t=()=>e?Array.from(e.querySelectorAll(`a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])`)):[],n=()=>t()[0]?.focus(),r=setTimeout(n,0),i=setTimeout(()=>{e?.contains(document.activeElement)||n()},200),a=n=>{if(n.key!==`Tab`)return;let r=t();if(!r.length)return;let i=r[0],a=r[r.length-1];e?.contains(document.activeElement)?n.shiftKey&&document.activeElement===i?(n.preventDefault(),a.focus()):!n.shiftKey&&document.activeElement===a&&(n.preventDefault(),i.focus()):(n.preventDefault(),(n.shiftKey?a:i).focus())};return window.addEventListener(`keydown`,a),()=>{clearTimeout(r),clearTimeout(i),window.removeEventListener(`keydown`,a);let e=s.current;F(`mobile-navigation`)&&e?.isConnected&&e.focus()}},[f]),(0,A.useEffect)(()=>{e&&c!==`mobile-navigation`&&n(!1)},[e,c]),(0,A.useEffect)(()=>{let e=()=>p();return window.addEventListener(`auth:gate-opened`,e),window.addEventListener(`command-palette:open`,e),()=>{window.removeEventListener(`auth:gate-opened`,e),window.removeEventListener(`command-palette:open`,e)}},[p]),(0,A.useEffect)(()=>()=>{P.getState().release(`mobile-navigation`)},[]),(0,I.jsx)(bn,{children:(0,I.jsxs)(`div`,{id:`app-shell`,className:`flex h-screen overflow-hidden bg-bg text-fg`,children:[(0,I.jsx)(`a`,{href:`#main`,inert:c!==null||void 0,tabIndex:c===null?void 0:-1,className:`sr-only rounded-md bg-accent px-3 py-2 text-sm font-medium text-accent-fg shadow-lg focus:not-sr-only focus:absolute focus:left-4 focus:top-3 focus:z-50`,children:`Skip to content`}),(0,I.jsx)(Xt,{open:f,blocked:c!==null&&c!==`mobile-navigation`,onClose:p}),(0,I.jsxs)(`div`,{id:`app-content`,className:`flex min-w-0 flex-1 flex-col`,inert:c!==null||void 0,"aria-hidden":c!==null||void 0,children:[(0,I.jsx)(kn,{navOpen:f,onMenu:e=>{u(`mobile-navigation`)&&(s.current=e,n(!0))}}),(0,I.jsx)(`main`,{ref:a,id:`main`,tabIndex:-1,className:t(`flex-1 px-4 pt-5 pb-24 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-accent sm:px-6 lg:px-8 lg:pt-6`,f?`overflow-hidden`:`overflow-y-auto`),children:(0,I.jsx)(A.Suspense,{fallback:(0,I.jsx)(`div`,{className:`p-2 text-sm text-muted`,children:`Loading…`}),children:(0,I.jsx)(bn,{resetKey:i,children:(0,I.jsx)(l,{})})})})]}),(0,I.jsx)(en,{}),(0,I.jsx)(Mt,{}),(0,I.jsx)(`div`,{id:`copilot-layer`,inert:c!==null&&c!==`copilot`||void 0,"aria-hidden":c!==null&&c!==`copilot`||void 0,children:(0,I.jsx)(yn,{})}),(0,I.jsx)(Cn,{}),(0,I.jsx)(kt,{})]})})}var jn={default:`text-fg`,green:`text-success`,red:`text-danger`,blue:`text-blue-400 light:text-blue-700`,amber:`text-warning`,accent:`text-accent`};function q({label:e,value:n,tone:r=`default`,hint:i,compact:a}){return(0,I.jsxs)(`div`,{className:t(`rounded-xl border border-line bg-surface`,a?`px-4 py-3`:`px-5 py-4`),children:[(0,I.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,I.jsx)(`div`,{className:t(`mt-2 font-semibold tnum`,a?`text-xl`:`text-3xl`,jn[r]),children:n}),i!=null&&(0,I.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:i})]})}var Mn={overview:{stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},memory:{heapUsed:0,heapTotal:0,rss:0},crons:{total:0}},queuesTotal:0,details:[],failedTotal:0,readyTotal:0};function Nn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function J(e,t){return Nn(e)&&t.every(t=>typeof e[t]==`number`&&Number.isFinite(e[t]))}function Pn(e){if(!Nn(e)||!J(e.stats,[`waiting`,`active`,`completed`,`dlq`,`totalPushed`,`totalPulled`,`uptime`])||!J(e.throughput,[`pushPerSec`,`pullPerSec`])||!J(e.memory,[`rss`])||!J(e.crons,[`total`]))throw Error(`Malformed /dashboard response: required overview metrics are missing or non-numeric.`)}var Fn=class extends Error{status;lastEventIdSent;constructor(e,t,n=!1){super(e),this.status=t,this.lastEventIdSent=n,this.name=`SseConnectError`}},In=new Set([400,409,413,431]);function Ln(e){return e instanceof Fn&&e.lastEventIdSent&&In.has(e.status)}function Rn(e){return!e.includes(`\0`)&&e.length<=4096}function zn(e){return!0}function Bn(e){let t=`message`,n,r=[];for(let i of e.split(`
3
3
  `)){if(!i||i.startsWith(`:`))continue;let e=i.indexOf(`:`),a=e===-1?i:i.slice(0,e),o=e===-1?``:i.slice(e+1).replace(/^ /,``);a===`event`?t=o:a===`data`?r.push(o):a===`id`&&Rn(o)&&(n=o)}if(r.length===0)return null;let i=r.join(`
4
4
  `),a=i;try{a=JSON.parse(i)}catch{}return{id:n,event:t,data:a}}var Vn=45e3,Hn=256*1024;async function Un(e,t,n,r=Vn,i){let a=new AbortController,o=()=>a.abort(n.reason);n.aborted?a.abort(n.reason):n.addEventListener(`abort`,o,{once:!0});let s,c=()=>{clearTimeout(s),s=setTimeout(()=>a.abort(Error(`SSE idle timeout`)),r)};try{c();let n=new Headers({Accept:`text/event-stream`,...C()}),r=!1;if(i&&Rn(i))try{n.set(`Last-Event-ID`,i),r=!0}catch{n.delete(`Last-Event-ID`)}let o=await fetch(e,{headers:n,signal:a.signal});if(!o.ok||!o.body)throw await o.body?.cancel().catch(()=>{}),new Fn(o.ok?`SSE connect failed: empty response body`:`SSE connect failed: HTTP ${o.status}`,o.status,r);let s=o.headers.get(`content-type`)?.split(`;`,1)[0]?.trim().toLowerCase();if(s!==`text/event-stream`)throw await o.body.cancel().catch(()=>{}),new Fn(`SSE connect failed: expected text/event-stream, received ${s||`no Content-Type`}`,o.status,r);let l=o.body.getReader(),u=new TextDecoder,d=``;try{for(;;){let{done:e,value:n}=await l.read();if(e)break;for(c(),d+=u.decode(n,{stream:!0});;){let e=d.indexOf(`
5
5
 
6
6
  `),n=d.indexOf(`\r
7
7
  \r
8
- `),r,i;if(e!==-1&&(n===-1||e<=n))r=e,i=2;else if(n!==-1)r=n,i=4;else{if(d.length>262144)throw Error(`SSE frame exceeds the ${Hn}-character limit`);break}if(r>262144)throw Error(`SSE frame exceeds the ${Hn}-character limit`);let a=d.slice(0,r);d=d.slice(r+i);let o=Bn(a.replace(/\r/g,``));o&&t(o)}}}finally{l.releaseLock()}}finally{clearTimeout(s),n.removeEventListener(`abort`,o),a.abort()}}var Y={total:0,completed:0,failed:0,waiting:0,active:0},Wn=250,Gn=()=>typeof performance<`u`?performance.now():Date.now();function Kn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function X(e,t){return typeof e==`string`&&e.length<=t?e:void 0}function qn(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function Jn(e,t){let n=qn(e);return n!==void 0&&Math.abs(n)<=864e13?n:Number.isFinite(t)&&Math.abs(t)<=864e13?t:0}function Yn(e){let t=Kn(e)?e:{},n=Date.now();return{queue:X(t.queue,256),jobId:X(t.jobId,1024),name:X(t.name,512),timestamp:Jn(t.timestamp,n),error:X(t.error,4096),progress:qn(t.progress)}}function Xn(e){let t=e.includes(`:`)?e.split(`:`)[1]:e;switch(t){case`pushed`:case`added`:return`waiting`;case`pulled`:return`active`;case`progress`:return`active`;default:return t}}function Zn(e){let t=S(e=>e.baseUrl),n=S(e=>e.token),[r,i]=(0,A.useState)([]),[a,o]=(0,A.useState)(Y),[s,c]=(0,A.useState)(0),[l,u]=(0,A.useState)(!1),[d,f]=(0,A.useState)(null),p=(0,A.useRef)([]),m=(0,A.useRef)(0),h=JSON.stringify([t,n,e??null]),g=(0,A.useRef)(h),_=g.current===h,v=_?r:[],y=_?a:Y,b=_?s:0,x=_?l:!1,C=_?d:null;return(0,A.useEffect)(()=>{let t=new AbortController,n=++m.current,r=0,a=!1,s=[],l={...Y},d,_=()=>!a&&m.current===n;g.current=h,i([]),o(Y),c(0),u(!1),f(null),p.current=[];let v=e=>new Promise(n=>{let r=()=>{clearTimeout(i),n()},i=setTimeout(()=>{t.signal.removeEventListener(`abort`,r),n()},e);t.signal.addEventListener(`abort`,r,{once:!0})}),y=e=>{if(!_()||(e.id!==void 0&&(d=e.id||void 0),zn(e)&&(u(e=>_()?!0:e),f(e=>_()?null:e)),!e.event.startsWith(`job:`)))return;let t=Yn(e.data),n=Xn(e.event),i={seq:++r,event:e.event,queue:t.queue,jobId:t.jobId,name:t.name,status:n,timestamp:t.timestamp,error:t.error,progress:t.progress};s.push(i);let a=l;a.total+=1,n===`completed`?a.completed+=1:n===`failed`?a.failed+=1:n===`waiting`?a.waiting+=1:n===`active`&&(a.active+=1),p.current.push(Gn())};(async()=>{let n=0;for(;!a;){let r=null,i=d,a=!1;try{await Un(we.eventsUrl(e),e=>{a=!0,y(e)},t.signal,void 0,i)}catch(e){r=e instanceof Error?e:Error(String(e))}if(i&&!a&&d===i&&Ln(r)&&(d=void 0),!_())break;u(e=>!_()&&e),f(e=>_()?r:e),n=r?Math.min(n+1,8):0,await v(2e3*Math.max(1,n))}})();let b=setInterval(()=>{if(!_())return;if(s.length){let e=s;s=[],e.reverse(),i(t=>_()?[...e,...t].slice(0,Wn):t)}let e=l;e.total&&(l={...Y},o(t=>_()?{total:t.total+e.total,completed:t.completed+e.completed,failed:t.failed+e.failed,waiting:t.waiting+e.waiting,active:t.active+e.active}:t))},150);return()=>{a=!0,m.current===n&&(m.current+=1),t.abort(),clearInterval(b)}},[e,t,n,h]),(0,A.useEffect)(()=>{let e=setInterval(()=>{let e=Gn();p.current=p.current.filter(t=>t<=e&&e-t<5e3),c(p.current.length/5)},1e3);return()=>clearInterval(e)},[]),{events:v,counters:y,throughput:b,connected:x,error:C}}function Qn(){let{events:e,connected:n,error:r}=Zn();return(0,I.jsxs)(`div`,{className:`mt-8`,children:[(0,I.jsx)($n,{title:`Recent Activity`,to:`/logs`}),(0,I.jsxs)(O,{padded:!1,children:[r&&e.length>0&&(0,I.jsxs)(`p`,{className:`border-b border-line px-5 py-2 text-xs text-warning`,children:[`Event stream unavailable — `,r.message,`. Reconnecting…`]}),e.length===0?(0,I.jsx)(`p`,{role:r?`alert`:void 0,className:t(`py-8 text-center text-sm`,r?`text-warning`:`text-faint`),children:r?`Event stream unavailable — ${r.message}. Reconnecting…`:n?`Waiting for live activity…`:`Connecting to the event stream…`}):(0,I.jsx)(`ul`,{className:`divide-y divide-line`,children:e.slice(0,8).map(e=>(0,I.jsxs)(`li`,{className:`flex items-center justify-between px-5 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(`span`,{className:t(`size-2 rounded-full`,er(e.status))}),(0,I.jsxs)(`div`,{className:`text-sm`,children:[(0,I.jsx)(`span`,{className:`font-mono font-medium text-fg`,children:e.queue||`—`}),(0,I.jsx)(`span`,{className:`text-faint`,children:` · `}),(0,I.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:e.jobId?e.jobId.slice(0,8):`—`}),(0,I.jsx)(`span`,{className:`text-faint`,children:` · `}),(0,I.jsx)(`span`,{className:`capitalize text-muted`,children:e.status})]})]}),(0,I.jsx)(`span`,{className:`text-xs text-faint`,children:Me(e.timestamp)})]},e.seq))})]})]})}function $n({title:e,to:t}){return(0,I.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,I.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:e}),(0,I.jsxs)(d,{to:t,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View All `,(0,I.jsx)(ge,{className:`size-3.5`})]})]})}function Z({label:e,value:n,tone:r}){return(0,I.jsxs)(`span`,{children:[e,` `,(0,I.jsx)(`span`,{className:t(`tnum font-semibold`,r),children:n==null?`—`:k(n)})]})}function er(e){return e===`completed`?`bg-emerald-400`:e===`failed`?`bg-red-400`:e===`active`?`bg-blue-400`:e===`waiting`?`bg-amber-400`:`bg-accent`}function tr(){let e=S(e=>e.baseUrl),n=(0,A.useRef)(null),{data:r,error:i,loading:a,refetch:o}=Te(async()=>{let[e,t]=await Promise.all([T.overview(),T.queuesSummary()]);Pn(e);let r=[...t].sort((e,t)=>(t.counts?.failed??0)-(e.counts?.failed??0)||(t.counts?.waiting??0)+(t.counts?.prioritized??0)-((e.counts?.waiting??0)+(e.counts?.prioritized??0))).slice(0,6).map(e=>({name:e.name,paused:e.paused,counts:e.counts})),i=t.reduce((e,t)=>e+(t.counts?.failed??0),0),a=t.reduce((e,t)=>e+t.counts.waiting+t.counts.prioritized,0);return n.current=Date.now(),{overview:e,queuesTotal:t.length,details:r,failedTotal:i,readyTotal:a}},[]);if(a&&!r&&!i)return(0,I.jsx)(ke,{label:`Loading overview…`});if(i&&!r)return(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Ae,{title:`Overview`,description:`Real-time system health is unavailable.`}),(0,I.jsx)(Oe,{error:i,onRetry:o})]});let{overview:s,queuesTotal:c,details:l,failedTotal:u,readyTotal:f}=r??Mn,{stats:p,throughput:m,memory:h,crons:g}=s,_=Fe(p.completed,u),v=e===`/api`?`localhost:6790`:e.replace(/^https?:\/\//,``),y=p.uptime?Ie(p.uptime/1e3):`—`,b=Ne(h.rss*1024*1024),x=!!i;return(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Ae,{title:`Overview`,description:`Real-time system health at a glance.`,live:!!r&&!i}),i&&(0,I.jsx)(De,{message:`Connection lost — showing the last successful overview snapshot.`,onRetry:o}),(0,I.jsxs)(`div`,{className:t(`mb-6 flex flex-wrap items-center justify-between gap-y-2 rounded-xl border px-5 py-4`,x?`border-amber-500/25 bg-amber-500/[0.06]`:`border-emerald-500/25 bg-emerald-500/[0.06]`),children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,I.jsxs)(`span`,{className:`relative flex size-2.5`,children:[!x&&(0,I.jsx)(`span`,{className:`absolute inline-flex size-full animate-ping rounded-full bg-emerald-400 opacity-60`}),(0,I.jsx)(`span`,{className:t(`relative inline-flex size-2.5 rounded-full`,x?`bg-amber-400`:`bg-emerald-400`)})]}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:t(`font-semibold`,x?`text-warning`:`text-success`),children:x?`Connection lost — showing last known data`:`bunqueue server connected`}),(0,I.jsxs)(`div`,{className:`truncate font-mono text-xs text-muted`,children:[v,` · uptime `,y,` · `,b,` RAM`,x&&(0,I.jsxs)(I.Fragment,{children:[` `,`· last updated `,n.current?Me(n.current):`never`]})]})]})]}),(0,I.jsx)(`span`,{className:t(`rounded-full px-3 py-1 text-xs font-medium`,x?`bg-amber-500/15 text-warning`:`bg-emerald-500/15 text-success`),children:x?`Stale`:`Online`})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-3`,children:[(0,I.jsx)(q,{label:`Error Rate`,value:_==null?`—`:je(_),tone:_==null?`default`:_>.05?`red`:`green`,hint:`failed / processed`}),(0,I.jsx)(q,{label:`Failed`,value:k(u),tone:u?`red`:`default`,hint:`recorded across queues`}),(0,I.jsx)(q,{label:`DLQ`,value:k(p.dlq),tone:p.dlq?`red`:`default`,hint:`dead-lettered jobs`})]}),(0,I.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,I.jsx)(q,{label:`Completed`,value:k(p.completed),tone:`green`,compact:!0}),(0,I.jsx)(q,{label:`Active`,value:k(p.active),tone:`blue`,compact:!0}),(0,I.jsx)(q,{label:`Ready backlog`,value:k(f),tone:f>100?`amber`:`default`,hint:`waiting + prioritized`,compact:!0}),(0,I.jsx)(q,{label:`Push/sec`,value:m.pushPerSec.toFixed(1),tone:`accent`,hint:`${Pe(p.totalPushed)} since restart`,compact:!0}),(0,I.jsx)(q,{label:`Pull/sec`,value:m.pullPerSec.toFixed(1),tone:`accent`,hint:`${Pe(p.totalPulled)} since restart`,compact:!0}),(0,I.jsx)(q,{label:`Queues`,value:k(c),hint:`${g.total} cron active`,compact:!0})]}),(0,I.jsxs)(`div`,{className:`mt-8`,children:[(0,I.jsx)($n,{title:`Queue Health — most loaded`,to:`/queues`}),l.length===0?(0,I.jsx)(O,{children:(0,I.jsx)(`p`,{className:`py-4 text-center text-sm text-faint`,children:`No queues yet.`})}):(0,I.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3`,children:l.map(e=>(0,I.jsxs)(d,{to:`/queues/${encodeURIComponent(e.name)}`,className:`rounded-xl border border-line bg-surface p-4 transition-colors hover:border-line-strong`,children:[(0,I.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,I.jsx)(`span`,{className:`truncate font-mono text-sm font-medium text-accent`,children:e.name}),(0,I.jsx)(`span`,{className:t(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:e.paused?`paused`:`active`})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 font-mono text-xs text-faint`,children:[(0,I.jsx)(Z,{label:`W`,value:e.counts?.waiting,tone:`text-warning`}),(0,I.jsx)(Z,{label:`P`,value:e.counts?.prioritized,tone:`text-orange-400`}),(0,I.jsx)(Z,{label:`A`,value:e.counts?.active,tone:`text-blue-400`}),(0,I.jsx)(Z,{label:`C`,value:e.counts?.completed,tone:`text-success`}),(0,I.jsx)(Z,{label:`F`,value:e.counts?.failed,tone:`text-danger`})]})]},e.name))})]}),(0,I.jsx)(Qn,{})]})}function nr(){return(0,I.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-24 text-center`,children:[(0,I.jsx)(`h1`,{className:`text-5xl font-bold text-faint`,children:`404`}),(0,I.jsx)(`p`,{className:`text-sm text-muted`,children:`This page does not exist.`}),(0,I.jsx)(d,{to:`/`,className:`rounded-lg border border-line bg-surface-2 px-4 py-2 text-sm font-medium text-fg hover:border-line-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:`Back to Overview`})]})}var rr=(0,A.lazy)(()=>u(()=>import(`./AddJob-d5KBvmN8.js`).then(e=>e.t).then(e=>({default:e.AddJob})),__vite__mapDeps([8,1,2,5,3,4,9,10,11,12,13,14,7,15,16]),import.meta.url)),ir=(0,A.lazy)(()=>u(()=>import(`./Benchmark-S1afsQRd.js`).then(e=>({default:e.Benchmark})),__vite__mapDeps([17,1,2,4,3,5,18,10,11,12,13,14,19,7,20]),import.meta.url)),ar=(0,A.lazy)(()=>u(()=>import(`./BulkAddJobs-BO8LWUHE.js`).then(e=>({default:e.BulkAddJobs})),__vite__mapDeps([21,1,2,5,3,4,9,10,11,12,13,14,7,15,16]),import.meta.url)),or=(0,A.lazy)(()=>u(()=>import(`./CronManager-ugmYEAwY.js`).then(e=>({default:e.CronManager})),__vite__mapDeps([22,1,2,5,3,4,9,18,10,11,12,23,13,14,19,7,24,15,16,8]),import.meta.url)),sr=(0,A.lazy)(()=>u(()=>import(`./Database-koy8haPX.js`).then(e=>({default:e.Database})),__vite__mapDeps([25,1,2,4,3,5,9,18,10,11,12,23,13,14,19,7,24]),import.meta.url)),cr=(0,A.lazy)(()=>u(()=>import(`./Diagnostics-D6oqvkOs.js`).then(e=>({default:e.Diagnostics})),__vite__mapDeps([26,1,2,3,4,5,9,27,10,11,12,23,14,13,19,28,29]),import.meta.url)),lr=(0,A.lazy)(()=>u(()=>import(`./DlqControl-nUT5Zzkl.js`).then(e=>({default:e.DlqControl})),__vite__mapDeps([30,1,2,3,4,5,9,18,10,11,23,13,14,19,7,24,31,32,33,12,15,34]),import.meta.url)),ur=(0,A.lazy)(()=>u(()=>import(`./DlqPro-VMuBKgP-.js`).then(e=>({default:e.DlqPro})),__vite__mapDeps([35,1,2,3,4,5,9,18,10,11,12,23,13,14,19,7,24,31,32,33,15,34]),import.meta.url)),dr=(0,A.lazy)(()=>u(()=>import(`./Flows-CAG0nDnt.js`).then(e=>({default:e.Flows})),__vite__mapDeps([36,1,2,4,5,3,12,23,13,14,29,28]),import.meta.url)),fr=(0,A.lazy)(()=>u(()=>import(`./JobInspector-CiS5HOSQ.js`).then(e=>({default:e.JobInspector})),__vite__mapDeps([37,1,2,4,5,3,18,11,12,23,14,13,19,7,31,32,38]),import.meta.url)),pr=(0,A.lazy)(()=>u(()=>import(`./JobsPro-B4-CSoq3.js`).then(e=>({default:e.JobsPro})),__vite__mapDeps([39,1,2,3,4,5,9,18,10,11,23,14,13,19,7,24,15,32,38]),import.meta.url)),mr=(0,A.lazy)(()=>u(()=>import(`./LogsPro-BCFeegvr.js`).then(e=>({default:e.LogsPro})),__vite__mapDeps([40,1,2,4,18,10,11,23,14,13,19,7,24,33,3,5,12,15,34,31]),import.meta.url)),hr=(0,A.lazy)(()=>u(()=>import(`./McpServer-BKlTR1qr.js`).then(e=>({default:e.McpServer})),__vite__mapDeps([41,2,1,12,13,14]),import.meta.url)),gr=(0,A.lazy)(()=>u(()=>import(`./MetricsPro-CqnaO6YX.js`).then(e=>({default:e.MetricsPro})),__vite__mapDeps([42,1,2,3,4,5,10,12,23,13,14,19,24,20,43]),import.meta.url)),_r=(0,A.lazy)(()=>u(()=>import(`./QueueControl-BF638r_0.js`).then(e=>({default:e.QueueControl})),__vite__mapDeps([33,1,2,3,4,5,10,11,12,23,14,13,19,7,15,34,31]),import.meta.url)),vr=(0,A.lazy)(()=>u(()=>import(`./QueueDetailPro-DXEdsZx_.js`).then(e=>({default:e.QueueDetailPro})),__vite__mapDeps([44,1,2,3,4,5,9,18,10,11,12,23,14,13,19,15,31,20,29,34,7,43]),import.meta.url)),yr=(0,A.lazy)(()=>u(()=>import(`./QueuesOverview-Du8XLgN0.js`).then(e=>({default:e.QueuesOverview})),__vite__mapDeps([45,1,2,3,4,5,9,18,10,11,23,13,14,19,24,15,46]),import.meta.url)),br=(0,A.lazy)(()=>u(()=>import(`./S3BackupPro-CBidbI-s.js`).then(e=>({default:e.S3BackupPro})),__vite__mapDeps([47,1,2,4,3,5,18,10,11,12,13,14,7]),import.meta.url)),xr=(0,A.lazy)(()=>u(()=>import(`./ServerControl-CPT0LpsC.js`).then(e=>({default:e.ServerControl})),__vite__mapDeps([48,1,2,3,4,5,18,10,11,12,23,13,14,19,7,28,29]),import.meta.url)),Sr=(0,A.lazy)(()=>u(()=>import(`./UsagePro-CASN77iV.js`).then(e=>({default:e.UsagePro})),__vite__mapDeps([49,2,1,3,4,5,10,12,23,13,14,19]),import.meta.url)),Cr=(0,A.lazy)(()=>u(()=>import(`./Webhooks-CXbZOFFw.js`).then(e=>({default:e.Webhooks})),__vite__mapDeps([50,1,2,3,4,5,9,18,10,11,12,23,13,14,19,7,24,15]),import.meta.url)),wr=(0,A.lazy)(()=>u(()=>import(`./WorkersPro-Dtml89jB.js`).then(e=>({default:e.WorkersPro})),__vite__mapDeps([51,1,2,3,4,5,18,10,11,23,13,14,19,15]),import.meta.url)),Q=(0,A.lazy)(()=>u(()=>import(`./Workflows-B8wmQN2X.js`).then(e=>({default:e.Workflows})),__vite__mapDeps([52,1,2,4,5,3,9,10,12,23,14,13,19,29,28]),import.meta.url)),Tr=(0,A.lazy)(()=>u(()=>import(`./Alerts-5I44QTnQ.js`).then(e=>({default:e.Alerts})),__vite__mapDeps([53,1,2,4,18,11,12,23,13,14,19,7]),import.meta.url)),Er=(0,A.lazy)(()=>u(()=>import(`./Cron-X3Y5uISO.js`).then(e=>({default:e.Cron})),__vite__mapDeps([54,1,2,18,27,4,5,10,11,23,13,14,19,24,15]),import.meta.url)),Dr=(0,A.lazy)(()=>u(()=>import(`./Dlq-D70Lzmsa.js`).then(e=>({default:e.Dlq})),__vite__mapDeps([55,1,2,18,27,4,5,10,11,23,13,14,19,7,24,31,56,3,46]),import.meta.url)),Or=(0,A.lazy)(()=>u(()=>import(`./Jobs-CkyRvzOT.js`).then(e=>({default:e.Jobs})),__vite__mapDeps([56,1,2,3,4,5,18,27,10,23,14,13,19,7,31,46]),import.meta.url)),kr=(0,A.lazy)(()=>u(()=>import(`./Logs-DBTz2PTz.js`).then(e=>({default:e.Logs})),__vite__mapDeps([57,1,2,18,10,4,23,14,13,19,7,24,56,3,5,27,31,46]),import.meta.url)),Ar=(0,A.lazy)(()=>u(()=>import(`./Metrics-Du__9Lbn.js`).then(e=>({default:e.Metrics})),__vite__mapDeps([58,2,1,27,4,5,10,12,23,13,14,19]),import.meta.url)),jr=(0,A.lazy)(()=>u(()=>import(`./Overview-udSSt7ZB.js`).then(e=>({default:e.Overview})),__vite__mapDeps([59,2,1,18,27,4,5,10,12,23,13,14,19]),import.meta.url)),Mr=(0,A.lazy)(()=>u(()=>import(`./QueueDetail-C-ms6bMe.js`).then(e=>({default:e.QueueDetail})),__vite__mapDeps([60,1,2,3,4,5,18,27,10,11,12,23,14,19,7,15,31]),import.meta.url)),Nr=(0,A.lazy)(()=>u(()=>import(`./Queues-BUMwTVAf.js`).then(e=>({default:e.Queues})),__vite__mapDeps([61,1,2,18,27,4,5,10,23,13,14,19,24]),import.meta.url)),Pr=(0,A.lazy)(()=>u(()=>import(`./S3Backup-CDICSzxM.js`).then(e=>({default:e.S3Backup})),__vite__mapDeps([62,2,1,27,4,5,10,12,23,13,14]),import.meta.url)),Fr=(0,A.lazy)(()=>u(()=>import(`./Settings-CmxfSX_8.js`).then(e=>({default:e.Settings})),__vite__mapDeps([63,1,2,4,18,11,12,13,14,7]),import.meta.url)),Ir=(0,A.lazy)(()=>u(()=>import(`./Usage-B895tSxi.js`).then(e=>({default:e.Usage})),__vite__mapDeps([64,2,1,27,4,5,10,12,23,13,14,19]),import.meta.url)),Lr=(0,A.lazy)(()=>u(()=>import(`./Workers-BceQlUhX.js`).then(e=>({default:e.Workers})),__vite__mapDeps([65,1,2,18,27,4,5,10,23,13,14,19,24]),import.meta.url));function Rr(){return(0,I.jsx)(r,{children:(0,I.jsxs)(f,{element:(0,I.jsx)(An,{}),children:[(0,I.jsx)(f,{path:`/`,element:(0,I.jsx)(tr,{})}),(0,I.jsx)(f,{path:`/overview-classic`,element:(0,I.jsx)(jr,{})}),(0,I.jsx)(f,{path:`/queues`,element:(0,I.jsx)(yr,{})}),(0,I.jsx)(f,{path:`/queues-classic`,element:(0,I.jsx)(Nr,{})}),(0,I.jsx)(f,{path:`/queues/:name`,element:(0,I.jsx)(vr,{})}),(0,I.jsx)(f,{path:`/queues-classic/:name`,element:(0,I.jsx)(Mr,{})}),(0,I.jsx)(f,{path:`/jobs`,element:(0,I.jsx)(pr,{})}),(0,I.jsx)(f,{path:`/jobs-classic`,element:(0,I.jsx)(Or,{})}),(0,I.jsx)(f,{path:`/dlq`,element:(0,I.jsx)(ur,{})}),(0,I.jsx)(f,{path:`/dlq-classic`,element:(0,I.jsx)(Dr,{})}),(0,I.jsx)(f,{path:`/cron`,element:(0,I.jsx)(or,{})}),(0,I.jsx)(f,{path:`/cron-classic`,element:(0,I.jsx)(Er,{})}),(0,I.jsx)(f,{path:`/flows`,element:(0,I.jsx)(dr,{})}),(0,I.jsx)(f,{path:`/workflows`,element:(0,I.jsx)(Q,{})}),(0,I.jsx)(f,{path:`/workflows/executions`,element:(0,I.jsx)(Q,{})}),(0,I.jsx)(f,{path:`/workflows/waiting`,element:(0,I.jsx)(Q,{})}),(0,I.jsx)(f,{path:`/workflows/compensation`,element:(0,I.jsx)(Q,{})}),(0,I.jsx)(f,{path:`/workflows/archive`,element:(0,I.jsx)(Q,{})}),(0,I.jsx)(f,{path:`/metrics`,element:(0,I.jsx)(gr,{})}),(0,I.jsx)(f,{path:`/metrics-classic`,element:(0,I.jsx)(Ar,{})}),(0,I.jsx)(f,{path:`/workers`,element:(0,I.jsx)(wr,{})}),(0,I.jsx)(f,{path:`/workers-classic`,element:(0,I.jsx)(Lr,{})}),(0,I.jsx)(f,{path:`/logs`,element:(0,I.jsx)(mr,{})}),(0,I.jsx)(f,{path:`/logs-classic`,element:(0,I.jsx)(kr,{})}),(0,I.jsx)(f,{path:`/server`,element:(0,I.jsx)(xr,{})}),(0,I.jsx)(f,{path:`/add-job`,element:(0,I.jsx)(rr,{})}),(0,I.jsx)(f,{path:`/jobs/bulk-add`,element:(0,I.jsx)(ar,{})}),(0,I.jsx)(f,{path:`/job`,element:(0,I.jsx)(fr,{})}),(0,I.jsx)(f,{path:`/queue-control`,element:(0,I.jsx)(_r,{})}),(0,I.jsx)(f,{path:`/cron-manager`,element:(0,I.jsx)(n,{to:`/cron`,replace:!0})}),(0,I.jsx)(f,{path:`/dlq-control`,element:(0,I.jsx)(lr,{})}),(0,I.jsx)(f,{path:`/webhooks`,element:(0,I.jsx)(Cr,{})}),(0,I.jsx)(f,{path:`/diagnostics`,element:(0,I.jsx)(cr,{})}),(0,I.jsx)(f,{path:`/alerts`,element:(0,I.jsx)(Tr,{})}),(0,I.jsx)(f,{path:`/benchmark`,element:(0,I.jsx)(ir,{})}),(0,I.jsx)(f,{path:`/database`,element:(0,I.jsx)(sr,{})}),(0,I.jsx)(f,{path:`/mcp`,element:(0,I.jsx)(hr,{})}),(0,I.jsx)(f,{path:`/usage`,element:(0,I.jsx)(Sr,{})}),(0,I.jsx)(f,{path:`/usage-classic`,element:(0,I.jsx)(Ir,{})}),(0,I.jsx)(f,{path:`/s3`,element:(0,I.jsx)(br,{})}),(0,I.jsx)(f,{path:`/s3-classic`,element:(0,I.jsx)(Pr,{})}),(0,I.jsx)(f,{path:`/settings`,element:(0,I.jsx)(Fr,{})}),(0,I.jsx)(f,{path:`*`,element:(0,I.jsx)(nr,{})})]})})}var $=new WeakMap;function zr(e,t){let n=document.createElement(`div`);n.setAttribute(`role`,`alert`),n.style.cssText=`padding:2rem;font:14px/1.6 system-ui,sans-serif;max-width:44rem;margin:auto`;let r=document.createElement(`h1`);r.style.cssText=`font-size:1.1rem;font-weight:600;margin-bottom:.5rem`,r.textContent=`Demo data failed to load`;let i=document.createElement(`p`);i.textContent=`This build serves canned data from a bundled chunk that could not be fetched, so there is no backend to talk to. Reload the page (a hard refresh clears a stale cached index.html).`;let a=document.createElement(`p`);a.style.cssText=`margin-top:.75rem;opacity:.7;font-family:ui-monospace,monospace`,a.textContent=t instanceof Error?t.message:String(t),n.append(r,i,a),e.replaceChildren(n)}function Br({root:e,demo:t,loadDemo:n,render:r,reportError:i=e=>console.error(`[demo] failed to load the demo backend`,e)}){let a=$.get(e);if(a)return a===!0?void 0:a;if(!t){$.set(e,!0);try{r()}catch(t){throw $.delete(e),t}return}let o=Promise.resolve().then(async()=>{let t;try{t=await n(),t.installDemo()}catch(t){try{i(t)}catch{}zr(e,t);return}r()});return $.set(e,o),o}It();var Vr=document.getElementById(`root`);if(!Vr)throw Error(`Root element #root not found`);function Hr(){(0,Le.createRoot)(Vr).render((0,I.jsx)(A.StrictMode,{children:(0,I.jsx)(c,{basename:ee(g(`__BUNQUEUE_BASE_PATH__`),`./`),children:(0,I.jsx)(Rr,{})})}))}Br({root:Vr,demo:H(),loadDemo:()=>u(()=>import(`./install-BPp8nydm.js`),[],import.meta.url),render:Hr});export{Bt as a,P as c,St as d,at as f,H as i,Dt as l,q as n,V as o,M as p,pn as r,F as s,Zn as t,N as u};
8
+ `),r,i;if(e!==-1&&(n===-1||e<=n))r=e,i=2;else if(n!==-1)r=n,i=4;else{if(d.length>262144)throw Error(`SSE frame exceeds the ${Hn}-character limit`);break}if(r>262144)throw Error(`SSE frame exceeds the ${Hn}-character limit`);let a=d.slice(0,r);d=d.slice(r+i);let o=Bn(a.replace(/\r/g,``));o&&t(o)}}}finally{l.releaseLock()}}finally{clearTimeout(s),n.removeEventListener(`abort`,o),a.abort()}}var Y={total:0,completed:0,failed:0,waiting:0,active:0},Wn=250,Gn=()=>typeof performance<`u`?performance.now():Date.now();function Kn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function X(e,t){return typeof e==`string`&&e.length<=t?e:void 0}function qn(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function Jn(e,t){let n=qn(e);return n!==void 0&&Math.abs(n)<=864e13?n:Number.isFinite(t)&&Math.abs(t)<=864e13?t:0}function Yn(e){let t=Kn(e)?e:{},n=Date.now();return{queue:X(t.queue,256),jobId:X(t.jobId,1024),name:X(t.name,512),timestamp:Jn(t.timestamp,n),error:X(t.error,4096),progress:qn(t.progress)}}function Xn(e){let t=e.includes(`:`)?e.split(`:`)[1]:e;switch(t){case`pushed`:case`added`:return`waiting`;case`pulled`:return`active`;case`progress`:return`active`;default:return t}}function Zn(e){let t=S(e=>e.baseUrl),n=S(e=>e.token),[r,i]=(0,A.useState)([]),[a,o]=(0,A.useState)(Y),[s,c]=(0,A.useState)(0),[l,u]=(0,A.useState)(!1),[d,f]=(0,A.useState)(null),p=(0,A.useRef)([]),m=(0,A.useRef)(0),h=JSON.stringify([t,n,e??null]),g=(0,A.useRef)(h),_=g.current===h,v=_?r:[],y=_?a:Y,b=_?s:0,x=_?l:!1,C=_?d:null;return(0,A.useEffect)(()=>{let t=new AbortController,n=++m.current,r=0,a=!1,s=[],l={...Y},d,_=()=>!a&&m.current===n;g.current=h,i([]),o(Y),c(0),u(!1),f(null),p.current=[];let v=e=>new Promise(n=>{let r=()=>{clearTimeout(i),n()},i=setTimeout(()=>{t.signal.removeEventListener(`abort`,r),n()},e);t.signal.addEventListener(`abort`,r,{once:!0})}),y=e=>{if(!_()||(e.id!==void 0&&(d=e.id||void 0),zn(e)&&(u(e=>_()?!0:e),f(e=>_()?null:e)),!e.event.startsWith(`job:`)))return;let t=Yn(e.data),n=Xn(e.event),i={seq:++r,event:e.event,queue:t.queue,jobId:t.jobId,name:t.name,status:n,timestamp:t.timestamp,error:t.error,progress:t.progress};s.push(i);let a=l;a.total+=1,n===`completed`?a.completed+=1:n===`failed`?a.failed+=1:n===`waiting`?a.waiting+=1:n===`active`&&(a.active+=1),p.current.push(Gn())};(async()=>{let n=0;for(;!a;){let r=null,i=d,a=!1;try{await Un(we.eventsUrl(e),e=>{a=!0,y(e)},t.signal,void 0,i)}catch(e){r=e instanceof Error?e:Error(String(e))}if(i&&!a&&d===i&&Ln(r)&&(d=void 0),!_())break;u(e=>!_()&&e),f(e=>_()?r:e),n=r?Math.min(n+1,8):0,await v(2e3*Math.max(1,n))}})();let b=setInterval(()=>{if(!_())return;if(s.length){let e=s;s=[],e.reverse(),i(t=>_()?[...e,...t].slice(0,Wn):t)}let e=l;e.total&&(l={...Y},o(t=>_()?{total:t.total+e.total,completed:t.completed+e.completed,failed:t.failed+e.failed,waiting:t.waiting+e.waiting,active:t.active+e.active}:t))},150);return()=>{a=!0,m.current===n&&(m.current+=1),t.abort(),clearInterval(b)}},[e,t,n,h]),(0,A.useEffect)(()=>{let e=setInterval(()=>{let e=Gn();p.current=p.current.filter(t=>t<=e&&e-t<5e3),c(p.current.length/5)},1e3);return()=>clearInterval(e)},[]),{events:v,counters:y,throughput:b,connected:x,error:C}}function Qn(){let{events:e,connected:n,error:r}=Zn();return(0,I.jsxs)(`div`,{className:`mt-8`,children:[(0,I.jsx)($n,{title:`Recent Activity`,to:`/logs`}),(0,I.jsxs)(O,{padded:!1,children:[r&&e.length>0&&(0,I.jsxs)(`p`,{className:`border-b border-line px-5 py-2 text-xs text-warning`,children:[`Event stream unavailable — `,r.message,`. Reconnecting…`]}),e.length===0?(0,I.jsx)(`p`,{role:r?`alert`:void 0,className:t(`py-8 text-center text-sm`,r?`text-warning`:`text-faint`),children:r?`Event stream unavailable — ${r.message}. Reconnecting…`:n?`Waiting for live activity…`:`Connecting to the event stream…`}):(0,I.jsx)(`ul`,{className:`divide-y divide-line`,children:e.slice(0,8).map(e=>(0,I.jsxs)(`li`,{className:`flex items-center justify-between px-5 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(`span`,{className:t(`size-2 rounded-full`,er(e.status))}),(0,I.jsxs)(`div`,{className:`text-sm`,children:[(0,I.jsx)(`span`,{className:`font-mono font-medium text-fg`,children:e.queue||`—`}),(0,I.jsx)(`span`,{className:`text-faint`,children:` · `}),(0,I.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:e.jobId?e.jobId.slice(0,8):`—`}),(0,I.jsx)(`span`,{className:`text-faint`,children:` · `}),(0,I.jsx)(`span`,{className:`capitalize text-muted`,children:e.status})]})]}),(0,I.jsx)(`span`,{className:`text-xs text-faint`,children:Me(e.timestamp)})]},e.seq))})]})]})}function $n({title:e,to:t}){return(0,I.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,I.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:e}),(0,I.jsxs)(d,{to:t,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View All `,(0,I.jsx)(ge,{className:`size-3.5`})]})]})}function Z({label:e,value:n,tone:r}){return(0,I.jsxs)(`span`,{children:[e,` `,(0,I.jsx)(`span`,{className:t(`tnum font-semibold`,r),children:n==null?`—`:k(n)})]})}function er(e){return e===`completed`?`bg-emerald-400`:e===`failed`?`bg-red-400`:e===`active`?`bg-blue-400`:e===`waiting`?`bg-amber-400`:`bg-accent`}function tr(){let e=S(e=>e.baseUrl),n=(0,A.useRef)(null),{data:r,error:i,loading:a,refetch:o}=Te(async()=>{let[e,t]=await Promise.all([T.overview(),T.queuesSummary()]);Pn(e);let r=[...t].sort((e,t)=>(t.counts?.failed??0)-(e.counts?.failed??0)||(t.counts?.waiting??0)+(t.counts?.prioritized??0)-((e.counts?.waiting??0)+(e.counts?.prioritized??0))).slice(0,6).map(e=>({name:e.name,paused:e.paused,counts:e.counts})),i=t.reduce((e,t)=>e+(t.counts?.failed??0),0),a=t.reduce((e,t)=>e+t.counts.waiting+t.counts.prioritized,0);return n.current=Date.now(),{overview:e,queuesTotal:t.length,details:r,failedTotal:i,readyTotal:a}},[]);if(a&&!r&&!i)return(0,I.jsx)(ke,{label:`Loading overview…`});if(i&&!r)return(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Ae,{title:`Overview`,description:`Real-time system health is unavailable.`}),(0,I.jsx)(Oe,{error:i,onRetry:o})]});let{overview:s,queuesTotal:c,details:l,failedTotal:u,readyTotal:f}=r??Mn,{stats:p,throughput:m,memory:h,crons:g}=s,_=Fe(p.completed,u),v=e===`/api`?`localhost:6790`:e.replace(/^https?:\/\//,``),y=p.uptime?Ie(p.uptime/1e3):`—`,b=Ne(h.rss*1024*1024),x=!!i;return(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Ae,{title:`Overview`,description:`Real-time system health at a glance.`,live:!!r&&!i}),i&&(0,I.jsx)(De,{message:`Connection lost — showing the last successful overview snapshot.`,onRetry:o}),(0,I.jsxs)(`div`,{className:t(`mb-6 flex flex-wrap items-center justify-between gap-y-2 rounded-xl border px-5 py-4`,x?`border-amber-500/25 bg-amber-500/[0.06]`:`border-emerald-500/25 bg-emerald-500/[0.06]`),children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,I.jsxs)(`span`,{className:`relative flex size-2.5`,children:[!x&&(0,I.jsx)(`span`,{className:`absolute inline-flex size-full animate-ping rounded-full bg-emerald-400 opacity-60`}),(0,I.jsx)(`span`,{className:t(`relative inline-flex size-2.5 rounded-full`,x?`bg-amber-400`:`bg-emerald-400`)})]}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:t(`font-semibold`,x?`text-warning`:`text-success`),children:x?`Connection lost — showing last known data`:`bunqueue server connected`}),(0,I.jsxs)(`div`,{className:`truncate font-mono text-xs text-muted`,children:[v,` · uptime `,y,` · `,b,` RAM`,x&&(0,I.jsxs)(I.Fragment,{children:[` `,`· last updated `,n.current?Me(n.current):`never`]})]})]})]}),(0,I.jsx)(`span`,{className:t(`rounded-full px-3 py-1 text-xs font-medium`,x?`bg-amber-500/15 text-warning`:`bg-emerald-500/15 text-success`),children:x?`Stale`:`Online`})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-3`,children:[(0,I.jsx)(q,{label:`Error Rate`,value:_==null?`—`:je(_),tone:_==null?`default`:_>.05?`red`:`green`,hint:`failed / processed`}),(0,I.jsx)(q,{label:`Failed`,value:k(u),tone:u?`red`:`default`,hint:`recorded across queues`}),(0,I.jsx)(q,{label:`DLQ`,value:k(p.dlq),tone:p.dlq?`red`:`default`,hint:`dead-lettered jobs`})]}),(0,I.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,I.jsx)(q,{label:`Completed`,value:k(p.completed),tone:`green`,compact:!0}),(0,I.jsx)(q,{label:`Active`,value:k(p.active),tone:`blue`,compact:!0}),(0,I.jsx)(q,{label:`Ready backlog`,value:k(f),tone:f>100?`amber`:`default`,hint:`waiting + prioritized`,compact:!0}),(0,I.jsx)(q,{label:`Push/sec`,value:m.pushPerSec.toFixed(1),tone:`accent`,hint:`${Pe(p.totalPushed)} since restart`,compact:!0}),(0,I.jsx)(q,{label:`Pull/sec`,value:m.pullPerSec.toFixed(1),tone:`accent`,hint:`${Pe(p.totalPulled)} since restart`,compact:!0}),(0,I.jsx)(q,{label:`Queues`,value:k(c),hint:`${g.total} cron active`,compact:!0})]}),(0,I.jsxs)(`div`,{className:`mt-8`,children:[(0,I.jsx)($n,{title:`Queue Health — most loaded`,to:`/queues`}),l.length===0?(0,I.jsx)(O,{children:(0,I.jsx)(`p`,{className:`py-4 text-center text-sm text-faint`,children:`No queues yet.`})}):(0,I.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3`,children:l.map(e=>(0,I.jsxs)(d,{to:`/queues/${encodeURIComponent(e.name)}`,className:`rounded-xl border border-line bg-surface p-4 transition-colors hover:border-line-strong`,children:[(0,I.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,I.jsx)(`span`,{className:`truncate font-mono text-sm font-medium text-accent`,children:e.name}),(0,I.jsx)(`span`,{className:t(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:e.paused?`paused`:`active`})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 font-mono text-xs text-faint`,children:[(0,I.jsx)(Z,{label:`W`,value:e.counts?.waiting,tone:`text-warning`}),(0,I.jsx)(Z,{label:`P`,value:e.counts?.prioritized,tone:`text-orange-400`}),(0,I.jsx)(Z,{label:`A`,value:e.counts?.active,tone:`text-blue-400`}),(0,I.jsx)(Z,{label:`C`,value:e.counts?.completed,tone:`text-success`}),(0,I.jsx)(Z,{label:`F`,value:e.counts?.failed,tone:`text-danger`})]})]},e.name))})]}),(0,I.jsx)(Qn,{})]})}function nr(){return(0,I.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-24 text-center`,children:[(0,I.jsx)(`h1`,{className:`text-5xl font-bold text-faint`,children:`404`}),(0,I.jsx)(`p`,{className:`text-sm text-muted`,children:`This page does not exist.`}),(0,I.jsx)(d,{to:`/`,className:`rounded-lg border border-line bg-surface-2 px-4 py-2 text-sm font-medium text-fg hover:border-line-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:`Back to Overview`})]})}var rr=(0,A.lazy)(()=>u(()=>import(`./AddJob-DkbI_J5p.js`).then(e=>e.t).then(e=>({default:e.AddJob})),__vite__mapDeps([8,1,2,5,3,4,9,10,11,12,13,14,7,15,16]),import.meta.url)),ir=(0,A.lazy)(()=>u(()=>import(`./Benchmark-Ey2sq57q.js`).then(e=>({default:e.Benchmark})),__vite__mapDeps([17,1,2,4,3,5,18,10,11,12,13,14,19,7,20]),import.meta.url)),ar=(0,A.lazy)(()=>u(()=>import(`./BulkAddJobs-BwPoeSB6.js`).then(e=>({default:e.BulkAddJobs})),__vite__mapDeps([21,1,2,5,3,4,9,10,11,12,13,14,7,15,16]),import.meta.url)),or=(0,A.lazy)(()=>u(()=>import(`./CronManager-Bdg2BECM.js`).then(e=>({default:e.CronManager})),__vite__mapDeps([22,1,2,5,3,4,9,18,10,11,12,23,13,14,19,7,24,15,16,8]),import.meta.url)),sr=(0,A.lazy)(()=>u(()=>import(`./Database-CB0oOEFB.js`).then(e=>({default:e.Database})),__vite__mapDeps([25,1,2,4,3,5,9,18,10,11,12,23,13,14,19,7,24]),import.meta.url)),cr=(0,A.lazy)(()=>u(()=>import(`./Diagnostics-BDRftXQy.js`).then(e=>({default:e.Diagnostics})),__vite__mapDeps([26,1,2,3,4,5,9,27,10,11,12,23,14,13,19,28,29]),import.meta.url)),lr=(0,A.lazy)(()=>u(()=>import(`./DlqControl-DZL2lHOU.js`).then(e=>({default:e.DlqControl})),__vite__mapDeps([30,1,2,3,4,5,9,18,10,11,23,13,14,19,7,24,31,32,33,12,15,34]),import.meta.url)),ur=(0,A.lazy)(()=>u(()=>import(`./DlqPro-OqBlzCnN.js`).then(e=>({default:e.DlqPro})),__vite__mapDeps([35,1,2,3,4,5,9,18,10,11,12,23,13,14,19,7,24,31,32,33,15,34]),import.meta.url)),dr=(0,A.lazy)(()=>u(()=>import(`./Flows-BItJzbVQ.js`).then(e=>({default:e.Flows})),__vite__mapDeps([36,1,2,4,5,3,12,23,13,14,29,28]),import.meta.url)),fr=(0,A.lazy)(()=>u(()=>import(`./JobInspector-CJHX63p_.js`).then(e=>({default:e.JobInspector})),__vite__mapDeps([37,1,2,4,5,3,18,11,12,23,14,13,19,7,31,32,38]),import.meta.url)),pr=(0,A.lazy)(()=>u(()=>import(`./JobsPro-eFVAZJ10.js`).then(e=>({default:e.JobsPro})),__vite__mapDeps([39,1,2,3,4,5,9,18,10,11,23,14,13,19,7,24,15,32,38]),import.meta.url)),mr=(0,A.lazy)(()=>u(()=>import(`./LogsPro-Xm6rylAd.js`).then(e=>({default:e.LogsPro})),__vite__mapDeps([40,1,2,4,18,10,11,23,14,13,19,7,24,33,3,5,12,15,34,31]),import.meta.url)),hr=(0,A.lazy)(()=>u(()=>import(`./McpServer-Rf3i6lRn.js`).then(e=>({default:e.McpServer})),__vite__mapDeps([41,2,1,12,13,14]),import.meta.url)),gr=(0,A.lazy)(()=>u(()=>import(`./MetricsPro-C63eY00A.js`).then(e=>({default:e.MetricsPro})),__vite__mapDeps([42,1,2,3,4,5,10,12,23,13,14,19,24,20,43]),import.meta.url)),_r=(0,A.lazy)(()=>u(()=>import(`./QueueControl-DusMoa05.js`).then(e=>({default:e.QueueControl})),__vite__mapDeps([33,1,2,3,4,5,10,11,12,23,14,13,19,7,15,34,31]),import.meta.url)),vr=(0,A.lazy)(()=>u(()=>import(`./QueueDetailPro-BNlBOj5s.js`).then(e=>({default:e.QueueDetailPro})),__vite__mapDeps([44,1,2,3,4,5,9,18,10,11,12,23,14,13,19,15,31,20,29,34,7,43]),import.meta.url)),yr=(0,A.lazy)(()=>u(()=>import(`./QueuesOverview-CBFqQ3N_.js`).then(e=>({default:e.QueuesOverview})),__vite__mapDeps([45,1,2,3,4,5,9,18,10,11,23,13,14,19,24,15,46]),import.meta.url)),br=(0,A.lazy)(()=>u(()=>import(`./S3BackupPro-BtvbPVg-.js`).then(e=>({default:e.S3BackupPro})),__vite__mapDeps([47,1,2,4,3,5,18,10,11,12,13,14,7]),import.meta.url)),xr=(0,A.lazy)(()=>u(()=>import(`./ServerControl-C5nQ7CCp.js`).then(e=>({default:e.ServerControl})),__vite__mapDeps([48,1,2,3,4,5,18,10,11,12,23,13,14,19,7,28,29]),import.meta.url)),Sr=(0,A.lazy)(()=>u(()=>import(`./UsagePro-bT82DS-d.js`).then(e=>({default:e.UsagePro})),__vite__mapDeps([49,2,1,3,4,5,10,12,23,13,14,19]),import.meta.url)),Cr=(0,A.lazy)(()=>u(()=>import(`./Webhooks-BjsUMJAn.js`).then(e=>({default:e.Webhooks})),__vite__mapDeps([50,1,2,3,4,5,9,18,10,11,12,23,13,14,19,7,24,15]),import.meta.url)),wr=(0,A.lazy)(()=>u(()=>import(`./WorkersPro-hCPhfb1Z.js`).then(e=>({default:e.WorkersPro})),__vite__mapDeps([51,1,2,3,4,5,18,10,11,23,13,14,19,15]),import.meta.url)),Q=(0,A.lazy)(()=>u(()=>import(`./Workflows-DOpeo-TP.js`).then(e=>({default:e.Workflows})),__vite__mapDeps([52,1,2,4,5,3,9,10,12,23,14,13,19,29,28]),import.meta.url)),Tr=(0,A.lazy)(()=>u(()=>import(`./Alerts-CFj-u0iV.js`).then(e=>({default:e.Alerts})),__vite__mapDeps([53,1,2,4,18,11,12,23,13,14,19,7]),import.meta.url)),Er=(0,A.lazy)(()=>u(()=>import(`./Cron-B5XFBvU-.js`).then(e=>({default:e.Cron})),__vite__mapDeps([54,1,2,18,27,4,5,10,11,23,13,14,19,24,15]),import.meta.url)),Dr=(0,A.lazy)(()=>u(()=>import(`./Dlq-CJO9itzJ.js`).then(e=>({default:e.Dlq})),__vite__mapDeps([55,1,2,18,27,4,5,10,11,23,13,14,19,7,24,31,56,3,46]),import.meta.url)),Or=(0,A.lazy)(()=>u(()=>import(`./Jobs-BwmTsjJx.js`).then(e=>({default:e.Jobs})),__vite__mapDeps([56,1,2,3,4,5,18,27,10,23,14,13,19,7,31,46]),import.meta.url)),kr=(0,A.lazy)(()=>u(()=>import(`./Logs-CXIf58M4.js`).then(e=>({default:e.Logs})),__vite__mapDeps([57,1,2,18,10,4,23,14,13,19,7,24,56,3,5,27,31,46]),import.meta.url)),Ar=(0,A.lazy)(()=>u(()=>import(`./Metrics-Cj3VYxzL.js`).then(e=>({default:e.Metrics})),__vite__mapDeps([58,2,1,27,4,5,10,12,23,13,14,19]),import.meta.url)),jr=(0,A.lazy)(()=>u(()=>import(`./Overview-CUM3XG7A.js`).then(e=>({default:e.Overview})),__vite__mapDeps([59,2,1,18,27,4,5,10,12,23,13,14,19]),import.meta.url)),Mr=(0,A.lazy)(()=>u(()=>import(`./QueueDetail-CpFIG1PU.js`).then(e=>({default:e.QueueDetail})),__vite__mapDeps([60,1,2,3,4,5,18,27,10,11,12,23,14,19,7,15,31]),import.meta.url)),Nr=(0,A.lazy)(()=>u(()=>import(`./Queues-CZ2qc7FY.js`).then(e=>({default:e.Queues})),__vite__mapDeps([61,1,2,18,27,4,5,10,23,13,14,19,24]),import.meta.url)),Pr=(0,A.lazy)(()=>u(()=>import(`./S3Backup-x4mOV-AO.js`).then(e=>({default:e.S3Backup})),__vite__mapDeps([62,2,1,27,4,5,10,12,23,13,14]),import.meta.url)),Fr=(0,A.lazy)(()=>u(()=>import(`./Settings-B5kCRSBH.js`).then(e=>({default:e.Settings})),__vite__mapDeps([63,1,2,4,18,11,12,13,14,7]),import.meta.url)),Ir=(0,A.lazy)(()=>u(()=>import(`./Usage-UYovs3D-.js`).then(e=>({default:e.Usage})),__vite__mapDeps([64,2,1,27,4,5,10,12,23,13,14,19]),import.meta.url)),Lr=(0,A.lazy)(()=>u(()=>import(`./Workers-CD4YZpca.js`).then(e=>({default:e.Workers})),__vite__mapDeps([65,1,2,18,27,4,5,10,23,13,14,19,24]),import.meta.url));function Rr(){return(0,I.jsx)(r,{children:(0,I.jsxs)(f,{element:(0,I.jsx)(An,{}),children:[(0,I.jsx)(f,{path:`/`,element:(0,I.jsx)(tr,{})}),(0,I.jsx)(f,{path:`/overview-classic`,element:(0,I.jsx)(jr,{})}),(0,I.jsx)(f,{path:`/queues`,element:(0,I.jsx)(yr,{})}),(0,I.jsx)(f,{path:`/queues-classic`,element:(0,I.jsx)(Nr,{})}),(0,I.jsx)(f,{path:`/queues/:name`,element:(0,I.jsx)(vr,{})}),(0,I.jsx)(f,{path:`/queues-classic/:name`,element:(0,I.jsx)(Mr,{})}),(0,I.jsx)(f,{path:`/jobs`,element:(0,I.jsx)(pr,{})}),(0,I.jsx)(f,{path:`/jobs-classic`,element:(0,I.jsx)(Or,{})}),(0,I.jsx)(f,{path:`/dlq`,element:(0,I.jsx)(ur,{})}),(0,I.jsx)(f,{path:`/dlq-classic`,element:(0,I.jsx)(Dr,{})}),(0,I.jsx)(f,{path:`/cron`,element:(0,I.jsx)(or,{})}),(0,I.jsx)(f,{path:`/cron-classic`,element:(0,I.jsx)(Er,{})}),(0,I.jsx)(f,{path:`/flows`,element:(0,I.jsx)(dr,{})}),(0,I.jsx)(f,{path:`/workflows`,element:(0,I.jsx)(Q,{})}),(0,I.jsx)(f,{path:`/workflows/executions`,element:(0,I.jsx)(Q,{})}),(0,I.jsx)(f,{path:`/workflows/waiting`,element:(0,I.jsx)(Q,{})}),(0,I.jsx)(f,{path:`/workflows/compensation`,element:(0,I.jsx)(Q,{})}),(0,I.jsx)(f,{path:`/workflows/archive`,element:(0,I.jsx)(Q,{})}),(0,I.jsx)(f,{path:`/metrics`,element:(0,I.jsx)(gr,{})}),(0,I.jsx)(f,{path:`/metrics-classic`,element:(0,I.jsx)(Ar,{})}),(0,I.jsx)(f,{path:`/workers`,element:(0,I.jsx)(wr,{})}),(0,I.jsx)(f,{path:`/workers-classic`,element:(0,I.jsx)(Lr,{})}),(0,I.jsx)(f,{path:`/logs`,element:(0,I.jsx)(mr,{})}),(0,I.jsx)(f,{path:`/logs-classic`,element:(0,I.jsx)(kr,{})}),(0,I.jsx)(f,{path:`/server`,element:(0,I.jsx)(xr,{})}),(0,I.jsx)(f,{path:`/add-job`,element:(0,I.jsx)(rr,{})}),(0,I.jsx)(f,{path:`/jobs/bulk-add`,element:(0,I.jsx)(ar,{})}),(0,I.jsx)(f,{path:`/job`,element:(0,I.jsx)(fr,{})}),(0,I.jsx)(f,{path:`/queue-control`,element:(0,I.jsx)(_r,{})}),(0,I.jsx)(f,{path:`/cron-manager`,element:(0,I.jsx)(n,{to:`/cron`,replace:!0})}),(0,I.jsx)(f,{path:`/dlq-control`,element:(0,I.jsx)(lr,{})}),(0,I.jsx)(f,{path:`/webhooks`,element:(0,I.jsx)(Cr,{})}),(0,I.jsx)(f,{path:`/diagnostics`,element:(0,I.jsx)(cr,{})}),(0,I.jsx)(f,{path:`/alerts`,element:(0,I.jsx)(Tr,{})}),(0,I.jsx)(f,{path:`/benchmark`,element:(0,I.jsx)(ir,{})}),(0,I.jsx)(f,{path:`/database`,element:(0,I.jsx)(sr,{})}),(0,I.jsx)(f,{path:`/mcp`,element:(0,I.jsx)(hr,{})}),(0,I.jsx)(f,{path:`/usage`,element:(0,I.jsx)(Sr,{})}),(0,I.jsx)(f,{path:`/usage-classic`,element:(0,I.jsx)(Ir,{})}),(0,I.jsx)(f,{path:`/s3`,element:(0,I.jsx)(br,{})}),(0,I.jsx)(f,{path:`/s3-classic`,element:(0,I.jsx)(Pr,{})}),(0,I.jsx)(f,{path:`/settings`,element:(0,I.jsx)(Fr,{})}),(0,I.jsx)(f,{path:`*`,element:(0,I.jsx)(nr,{})})]})})}var $=new WeakMap;function zr(e,t){let n=document.createElement(`div`);n.setAttribute(`role`,`alert`),n.style.cssText=`padding:2rem;font:14px/1.6 system-ui,sans-serif;max-width:44rem;margin:auto`;let r=document.createElement(`h1`);r.style.cssText=`font-size:1.1rem;font-weight:600;margin-bottom:.5rem`,r.textContent=`Demo data failed to load`;let i=document.createElement(`p`);i.textContent=`This build serves canned data from a bundled chunk that could not be fetched, so there is no backend to talk to. Reload the page (a hard refresh clears a stale cached index.html).`;let a=document.createElement(`p`);a.style.cssText=`margin-top:.75rem;opacity:.7;font-family:ui-monospace,monospace`,a.textContent=t instanceof Error?t.message:String(t),n.append(r,i,a),e.replaceChildren(n)}function Br({root:e,demo:t,loadDemo:n,render:r,reportError:i=e=>console.error(`[demo] failed to load the demo backend`,e)}){let a=$.get(e);if(a)return a===!0?void 0:a;if(!t){$.set(e,!0);try{r()}catch(t){throw $.delete(e),t}return}let o=Promise.resolve().then(async()=>{let t;try{t=await n(),t.installDemo()}catch(t){try{i(t)}catch{}zr(e,t);return}r()});return $.set(e,o),o}It();var Vr=document.getElementById(`root`);if(!Vr)throw Error(`Root element #root not found`);function Hr(){(0,Le.createRoot)(Vr).render((0,I.jsx)(A.StrictMode,{children:(0,I.jsx)(c,{basename:ee(g(`__BUNQUEUE_BASE_PATH__`),`./`),children:(0,I.jsx)(Rr,{})})}))}Br({root:Vr,demo:H(),loadDemo:()=>u(()=>import(`./install-C5y2ohOo.js`),[],import.meta.url),render:Hr});export{Bt as a,P as c,St as d,at as f,H as i,Dt as l,q as n,V as o,M as p,pn as r,F as s,Zn as t,N as u};