@wjarka/cezarion 0.18.0-dev.7516 → 0.18.0-dev.7527

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 (46) hide show
  1. package/package.json +2 -2
  2. package/web/dist/assets/{activity-motion-DQwtapOI.js → activity-motion-C3PyGX1i.js} +1 -1
  3. package/web/dist/assets/{activity-route-BwZiMGfK.js → activity-route-CBE9suPx.js} +1 -1
  4. package/web/dist/assets/{commit-diff-panel-BVWKMptW.js → commit-diff-panel-BHLfoc5K.js} +1 -1
  5. package/web/dist/assets/diff-CPP5-PAO.js +3 -0
  6. package/web/dist/assets/{diff-view-y7x-a5xQ.js → diff-view-pVNE2LKd.js} +4 -4
  7. package/web/dist/assets/{file-preview-CEaNT3ht.js → file-preview-Dnl25_Yq.js} +2 -2
  8. package/web/dist/assets/{git-toolbar-BvvAgmDO.js → git-toolbar-B8j0rXz_.js} +1 -1
  9. package/web/dist/assets/{github-B3WekFy2.js → github-Bk_W_P7M.js} +1 -1
  10. package/web/dist/assets/{global-activity-route-D3lMjvxF.js → global-activity-route-B3Bg4j74.js} +1 -1
  11. package/web/dist/assets/index-BUcVG7uX.js +14 -0
  12. package/web/dist/assets/{markdown-BojHOSHX.js → markdown-DZFo50wI.js} +3 -3
  13. package/web/dist/assets/picker-pill-Bhsrt_K5.js +15 -0
  14. package/web/dist/assets/preview-pane-connected-B887FUPw.js +3 -0
  15. package/web/dist/assets/prompt-template-menu-Cl8ES_lT.js +1 -0
  16. package/web/dist/assets/{queries-BpsLvjtu.js → queries-D5f-3moU.js} +1 -1
  17. package/web/dist/assets/{reference-chip-HnvJLwQV.js → reference-chip-BPdU-pFz.js} +1 -1
  18. package/web/dist/assets/repo-git-DkdZ-lHF.js +1 -0
  19. package/web/dist/assets/{report-reader-B9tuKd1M.js → report-reader-ClrhPnHJ.js} +1 -1
  20. package/web/dist/assets/{reports-DX1Hw80D.js → reports-CNDxM3-h.js} +1 -1
  21. package/web/dist/assets/run-header-CGu_4msV.js +2 -0
  22. package/web/dist/assets/runners-Dc2_oqXR.js +1 -0
  23. package/web/dist/assets/skills-rESbVzy9.js +1 -0
  24. package/web/dist/assets/task-changes-BqMvI8iD.js +1 -0
  25. package/web/dist/assets/{task-commits-BtU9bGk7.js → task-commits-B0vE6rWz.js} +1 -1
  26. package/web/dist/assets/{task-files-B0n2qyBi.js → task-files-5YPOAXtn.js} +1 -1
  27. package/web/dist/assets/{task-github-item-Xr08h42p.js → task-github-item-D6VreAoa.js} +1 -1
  28. package/web/dist/assets/task-thread-DO2BE7tp.js +9 -0
  29. package/web/dist/assets/{thread-state-DoSqzctg.js → thread-state-Cn5cetra.js} +1 -1
  30. package/web/dist/assets/{use-desktop-Coqw26IL.js → use-desktop-R2WTomyJ.js} +1 -1
  31. package/web/dist/assets/use-hand-to-agent-state-B277xMq3.js +1 -0
  32. package/web/dist/assets/{workflows-BEniI_am.js → workflows-fZms9I7r.js} +3 -3
  33. package/web/dist/index.html +7 -8
  34. package/web/dist/assets/agent-accounts-C_UK6pPU.js +0 -1
  35. package/web/dist/assets/diff-CXCoZr3w.js +0 -3
  36. package/web/dist/assets/index-BvMEJ3Ux.js +0 -14
  37. package/web/dist/assets/picker-pill-ToL4uifX.js +0 -15
  38. package/web/dist/assets/preview-pane-connected-BmBOIaSo.js +0 -3
  39. package/web/dist/assets/prompt-template-menu-D8RsDr0w.js +0 -1
  40. package/web/dist/assets/repo-git-jRvRtMVC.js +0 -1
  41. package/web/dist/assets/run-header-ClrfkoK4.js +0 -2
  42. package/web/dist/assets/runners-CIHj9D-C.js +0 -1
  43. package/web/dist/assets/skills-Y60pkNkG.js +0 -1
  44. package/web/dist/assets/task-changes-D-No9noD.js +0 -1
  45. package/web/dist/assets/task-thread-B7lUY_dn.js +0 -9
  46. package/web/dist/assets/use-hand-to-agent-state-PL74uvoL.js +0 -1
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{C as r,S as i,l as a,w as o}from"./button-RJMdCnZw.js";import{i as s}from"./bundle-mjs-BT31bpU6.js";import{H as c,K as l,U as u,W as d,ct as ee,dt as f,ft as p,lt as m,mt as h,pt as te,st as ne,ut as re}from"./index-BvMEJ3Ux.js";import{i as ie,n as g}from"./chunk-BO2N2NFS-CM5F_Wdn.js";var _=e(t(),1),v=n();function y({isOpen:e,onClose:t,onConfirm:n,url:r}){return(0,v.jsx)(ne,{open:e,onOpenChange:e=>{e||t()},children:(0,v.jsxs)(re,{"data-slot":`link-safety-dialog`,children:[(0,v.jsxs)(te,{children:[(0,v.jsx)(h,{children:`Open this link?`}),(0,v.jsxs)(f,{children:[`It leaves Squawk in a new tab. The words of a link in a transcript are the agent's — the address below is where it actually goes.`,(0,v.jsx)(`span`,{"data-slot":`link-safety-url`,className:`mt-3 block wrap-anywhere rounded-md border border-border bg-muted px-3 py-2 font-mono text-xs text-foreground`,children:r})]})]}),(0,v.jsxs)(p,{children:[(0,v.jsx)(m,{children:`Cancel`}),(0,v.jsx)(ee,{onClick:n,children:`Open link`})]})]})})}var b=String.raw`https?:\/\/(?:cdn\.jsdelivr\.net\/npm|unpkg\.com)\/`,x=[{id:`tailwind-v3`,script:/^https?:\/\/cdn\.tailwindcss\.com(?:\/[\d.]+)?\/?(?:[?#]|$)/i},{id:`tailwind`,script:new RegExp(String.raw`^${b}@tailwindcss\/browser@4(?:\.[.\d]*)?(?:\/dist\/index\.global(?:\.min)?\.js)?\/?(?:[?#]|$)`,`i`)},{id:`mermaid`,script:new RegExp(String.raw`^${b}mermaid@11(?:\.[.\d]*)?\/dist\/mermaid(?:\.esm)?(?:\.min)?\.m?js(?:[?#]|$)`,`i`)}],S=new RegExp(String.raw`(['"])(${b}mermaid@11(?:\.[.\d]*)?(?:\/dist\/mermaid(?:\.esm)?(?:\.min)?\.mjs|\/\+esm)?)\1`,`gi`);function C(e){let t=e.trim();return x.find(e=>e.script.test(t))?.id??null}function w(e){let t=new DOMParser().parseFromString(e,`text/html`),n=new Set;for(let e of t.querySelectorAll(`script`)){let t=e.getAttribute(`src`),r=t===null?null:C(t);r&&n.add(r===`tailwind-v3`?`tailwind`:r).add(r),t===null&&e.getAttribute(`type`)===`module`&&(e.textContent??``).search(S)>=0&&n.add(`mermaid`),S.lastIndex=0}return[...n].sort()}var T={tailwind:async()=>(await s(()=>import(`./index.global-D3Ga_D3Y.js`),[])).default,"tailwind-v3":()=>Promise.resolve(se),mermaid:async()=>(await s(()=>import(`./mermaid.min-3O9YjB2l.js`),[])).default};async function E(e){let t=await Promise.all(e.map(e=>T[e]().then(t=>[e,t],()=>null)));return Object.fromEntries(t.filter(e=>e!==null))}function ae(){let e={colors:`color`,fontFamily:`font`,fontSize:`text`,fontWeight:`font-weight`,spacing:`spacing`,borderRadius:`radius`,boxShadow:`shadow`,dropShadow:`drop-shadow`,blur:`blur`,screens:`breakpoint`,letterSpacing:`tracking`,lineHeight:`leading`,maxWidth:`container`,animation:`animate`,aspectRatio:`aspect`},t=e=>typeof e==`object`&&!!e&&!Array.isArray(e),n=t=>Object.hasOwn(e,t)?e[t]:void 0,r=(e,n,i,a)=>{if(t(a)){for(let[t,o]of Object.entries(a))r(e,n,t===`DEFAULT`?i:i?`${i}-${t}`:t,o);return}let o=i?`--${n}-${i}`:`--${n}`;if(n===`text`&&Array.isArray(a)){e.push(`${o}: ${String(a[0])};`);let n=t(a[1])?a[1].lineHeight:a[1];typeof n==`string`&&e.push(`${o}--line-height: ${n};`);return}typeof a==`string`||typeof a==`number`?e.push(`${o}: ${a};`):Array.isArray(a)&&e.push(`${o}: ${a.join(`, `)};`)},i=e=>{let[t,n]=Array.isArray(e)?e:[e];if(t!==`class`&&t!==`selector`)return``;let r=typeof n==`string`?n:`.dark`;return`@custom-variant dark (&:where(${r}, ${r} *));\n`},a=e=>{let a=t(e)?e:{},o=t(a.theme)?a.theme:{},s=[];for(let[e,t]of Object.entries(o)){let i=n(e);i&&(s.push(`--${i}-*: initial;`),r(s,i,``,t))}for(let[e,i]of Object.entries(t(o.extend)?o.extend:{})){let t=n(e);t&&r(s,t,``,i)}return`${i(a.darkMode)}@theme {\n${s.join(`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{C as r,S as i,l as a,w as o}from"./button-RJMdCnZw.js";import{i as s}from"./bundle-mjs-BT31bpU6.js";import{G as c,J as l,K as u,W as d,dt as f,ft as ee,gt as p,ht as m,lt as h,mt as g,pt as te,ut as ne}from"./index-BUcVG7uX.js";import{i as re,n as _}from"./chunk-BO2N2NFS-CM5F_Wdn.js";var v=e(t(),1),y=n();function b({isOpen:e,onClose:t,onConfirm:n,url:r}){return(0,y.jsx)(h,{open:e,onOpenChange:e=>{e||t()},children:(0,y.jsxs)(ee,{"data-slot":`link-safety-dialog`,children:[(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:`Open this link?`}),(0,y.jsxs)(te,{children:[`It leaves Squawk in a new tab. The words of a link in a transcript are the agent's — the address below is where it actually goes.`,(0,y.jsx)(`span`,{"data-slot":`link-safety-url`,className:`mt-3 block wrap-anywhere rounded-md border border-border bg-muted px-3 py-2 font-mono text-xs text-foreground`,children:r})]})]}),(0,y.jsxs)(g,{children:[(0,y.jsx)(f,{children:`Cancel`}),(0,y.jsx)(ne,{onClick:n,children:`Open link`})]})]})})}var x=String.raw`https?:\/\/(?:cdn\.jsdelivr\.net\/npm|unpkg\.com)\/`,ie=[{id:`tailwind-v3`,script:/^https?:\/\/cdn\.tailwindcss\.com(?:\/[\d.]+)?\/?(?:[?#]|$)/i},{id:`tailwind`,script:new RegExp(String.raw`^${x}@tailwindcss\/browser@4(?:\.[.\d]*)?(?:\/dist\/index\.global(?:\.min)?\.js)?\/?(?:[?#]|$)`,`i`)},{id:`mermaid`,script:new RegExp(String.raw`^${x}mermaid@11(?:\.[.\d]*)?\/dist\/mermaid(?:\.esm)?(?:\.min)?\.m?js(?:[?#]|$)`,`i`)}],S=new RegExp(String.raw`(['"])(${x}mermaid@11(?:\.[.\d]*)?(?:\/dist\/mermaid(?:\.esm)?(?:\.min)?\.mjs|\/\+esm)?)\1`,`gi`);function C(e){let t=e.trim();return ie.find(e=>e.script.test(t))?.id??null}function w(e){let t=new DOMParser().parseFromString(e,`text/html`),n=new Set;for(let e of t.querySelectorAll(`script`)){let t=e.getAttribute(`src`),r=t===null?null:C(t);r&&n.add(r===`tailwind-v3`?`tailwind`:r).add(r),t===null&&e.getAttribute(`type`)===`module`&&(e.textContent??``).search(S)>=0&&n.add(`mermaid`),S.lastIndex=0}return[...n].sort()}var T={tailwind:async()=>(await s(()=>import(`./index.global-D3Ga_D3Y.js`),[])).default,"tailwind-v3":()=>Promise.resolve(se),mermaid:async()=>(await s(()=>import(`./mermaid.min-3O9YjB2l.js`),[])).default};async function E(e){let t=await Promise.all(e.map(e=>T[e]().then(t=>[e,t],()=>null)));return Object.fromEntries(t.filter(e=>e!==null))}function ae(){let e={colors:`color`,fontFamily:`font`,fontSize:`text`,fontWeight:`font-weight`,spacing:`spacing`,borderRadius:`radius`,boxShadow:`shadow`,dropShadow:`drop-shadow`,blur:`blur`,screens:`breakpoint`,letterSpacing:`tracking`,lineHeight:`leading`,maxWidth:`container`,animation:`animate`,aspectRatio:`aspect`},t=e=>typeof e==`object`&&!!e&&!Array.isArray(e),n=t=>Object.hasOwn(e,t)?e[t]:void 0,r=(e,n,i,a)=>{if(t(a)){for(let[t,o]of Object.entries(a))r(e,n,t===`DEFAULT`?i:i?`${i}-${t}`:t,o);return}let o=i?`--${n}-${i}`:`--${n}`;if(n===`text`&&Array.isArray(a)){e.push(`${o}: ${String(a[0])};`);let n=t(a[1])?a[1].lineHeight:a[1];typeof n==`string`&&e.push(`${o}--line-height: ${n};`);return}typeof a==`string`||typeof a==`number`?e.push(`${o}: ${a};`):Array.isArray(a)&&e.push(`${o}: ${a.join(`, `)};`)},i=e=>{let[t,n]=Array.isArray(e)?e:[e];if(t!==`class`&&t!==`selector`)return``;let r=typeof n==`string`?n:`.dark`;return`@custom-variant dark (&:where(${r}, ${r} *));\n`},a=e=>{let a=t(e)?e:{},o=t(a.theme)?a.theme:{},s=[];for(let[e,t]of Object.entries(o)){let i=n(e);i&&(s.push(`--${i}-*: initial;`),r(s,i,``,t))}for(let[e,i]of Object.entries(t(o.extend)?o.extend:{})){let t=n(e);t&&r(s,t,``,i)}return`${i(a.darkMode)}@theme {\n${s.join(`
2
2
  `)}\n}`},o=document.createElement(`style`);o.setAttribute(`type`,`text/tailwindcss`),document.currentScript?.before(o);let s={};Object.defineProperty(globalThis,"tailwind",{configurable:!0,value:{get config(){return s},set config(e){s=e,o.textContent=a(e)}}})}var oe=`(${ae.toString()})()`,se=[`@import "tailwindcss/theme.css";@import "tailwindcss/preflight.css";@import "tailwindcss/utilities.css";`,`@theme{`,`--color-slate-50:#f8fafc;--color-slate-100:#f1f5f9;--color-slate-200:#e2e8f0;--color-slate-300:#cbd5e1;--color-slate-400:#94a3b8;--color-slate-500:#64748b;--color-slate-600:#475569;--color-slate-700:#334155;--color-slate-800:#1e293b;--color-slate-900:#0f172a;--color-slate-950:#020617;`,`--color-gray-50:#f9fafb;--color-gray-100:#f3f4f6;--color-gray-200:#e5e7eb;--color-gray-300:#d1d5db;--color-gray-400:#9ca3af;--color-gray-500:#6b7280;--color-gray-600:#4b5563;--color-gray-700:#374151;--color-gray-800:#1f2937;--color-gray-900:#111827;--color-gray-950:#030712;`,`--color-zinc-50:#fafafa;--color-zinc-100:#f4f4f5;--color-zinc-200:#e4e4e7;--color-zinc-300:#d4d4d8;--color-zinc-400:#a1a1aa;--color-zinc-500:#71717a;--color-zinc-600:#52525b;--color-zinc-700:#3f3f46;--color-zinc-800:#27272a;--color-zinc-900:#18181b;--color-zinc-950:#09090b;`,`--color-neutral-50:#fafafa;--color-neutral-100:#f5f5f5;--color-neutral-200:#e5e5e5;--color-neutral-300:#d4d4d4;--color-neutral-400:#a3a3a3;--color-neutral-500:#737373;--color-neutral-600:#525252;--color-neutral-700:#404040;--color-neutral-800:#262626;--color-neutral-900:#171717;--color-neutral-950:#0a0a0a;`,`--color-stone-50:#fafaf9;--color-stone-100:#f5f5f4;--color-stone-200:#e7e5e4;--color-stone-300:#d6d3d1;--color-stone-400:#a8a29e;--color-stone-500:#78716c;--color-stone-600:#57534e;--color-stone-700:#44403c;--color-stone-800:#292524;--color-stone-900:#1c1917;--color-stone-950:#0c0a09;`,`--color-red-50:#fef2f2;--color-red-100:#fee2e2;--color-red-200:#fecaca;--color-red-300:#fca5a5;--color-red-400:#f87171;--color-red-500:#ef4444;--color-red-600:#dc2626;--color-red-700:#b91c1c;--color-red-800:#991b1b;--color-red-900:#7f1d1d;--color-red-950:#450a0a;`,`--color-orange-50:#fff7ed;--color-orange-100:#ffedd5;--color-orange-200:#fed7aa;--color-orange-300:#fdba74;--color-orange-400:#fb923c;--color-orange-500:#f97316;--color-orange-600:#ea580c;--color-orange-700:#c2410c;--color-orange-800:#9a3412;--color-orange-900:#7c2d12;--color-orange-950:#431407;`,`--color-amber-50:#fffbeb;--color-amber-100:#fef3c7;--color-amber-200:#fde68a;--color-amber-300:#fcd34d;--color-amber-400:#fbbf24;--color-amber-500:#f59e0b;--color-amber-600:#d97706;--color-amber-700:#b45309;--color-amber-800:#92400e;--color-amber-900:#78350f;--color-amber-950:#451a03;`,`--color-yellow-50:#fefce8;--color-yellow-100:#fef9c3;--color-yellow-200:#fef08a;--color-yellow-300:#fde047;--color-yellow-400:#facc15;--color-yellow-500:#eab308;--color-yellow-600:#ca8a04;--color-yellow-700:#a16207;--color-yellow-800:#854d0e;--color-yellow-900:#713f12;--color-yellow-950:#422006;`,`--color-lime-50:#f7fee7;--color-lime-100:#ecfccb;--color-lime-200:#d9f99d;--color-lime-300:#bef264;--color-lime-400:#a3e635;--color-lime-500:#84cc16;--color-lime-600:#65a30d;--color-lime-700:#4d7c0f;--color-lime-800:#3f6212;--color-lime-900:#365314;--color-lime-950:#1a2e05;`,`--color-green-50:#f0fdf4;--color-green-100:#dcfce7;--color-green-200:#bbf7d0;--color-green-300:#86efac;--color-green-400:#4ade80;--color-green-500:#22c55e;--color-green-600:#16a34a;--color-green-700:#15803d;--color-green-800:#166534;--color-green-900:#14532d;--color-green-950:#052e16;`,`--color-emerald-50:#ecfdf5;--color-emerald-100:#d1fae5;--color-emerald-200:#a7f3d0;--color-emerald-300:#6ee7b7;--color-emerald-400:#34d399;--color-emerald-500:#10b981;--color-emerald-600:#059669;--color-emerald-700:#047857;--color-emerald-800:#065f46;--color-emerald-900:#064e3b;--color-emerald-950:#022c22;`,`--color-teal-50:#f0fdfa;--color-teal-100:#ccfbf1;--color-teal-200:#99f6e4;--color-teal-300:#5eead4;--color-teal-400:#2dd4bf;--color-teal-500:#14b8a6;--color-teal-600:#0d9488;--color-teal-700:#0f766e;--color-teal-800:#115e59;--color-teal-900:#134e4a;--color-teal-950:#042f2e;`,`--color-cyan-50:#ecfeff;--color-cyan-100:#cffafe;--color-cyan-200:#a5f3fc;--color-cyan-300:#67e8f9;--color-cyan-400:#22d3ee;--color-cyan-500:#06b6d4;--color-cyan-600:#0891b2;--color-cyan-700:#0e7490;--color-cyan-800:#155e75;--color-cyan-900:#164e63;--color-cyan-950:#083344;`,`--color-sky-50:#f0f9ff;--color-sky-100:#e0f2fe;--color-sky-200:#bae6fd;--color-sky-300:#7dd3fc;--color-sky-400:#38bdf8;--color-sky-500:#0ea5e9;--color-sky-600:#0284c7;--color-sky-700:#0369a1;--color-sky-800:#075985;--color-sky-900:#0c4a6e;--color-sky-950:#082f49;`,`--color-blue-50:#eff6ff;--color-blue-100:#dbeafe;--color-blue-200:#bfdbfe;--color-blue-300:#93c5fd;--color-blue-400:#60a5fa;--color-blue-500:#3b82f6;--color-blue-600:#2563eb;--color-blue-700:#1d4ed8;--color-blue-800:#1e40af;--color-blue-900:#1e3a8a;--color-blue-950:#172554;`,`--color-indigo-50:#eef2ff;--color-indigo-100:#e0e7ff;--color-indigo-200:#c7d2fe;--color-indigo-300:#a5b4fc;--color-indigo-400:#818cf8;--color-indigo-500:#6366f1;--color-indigo-600:#4f46e5;--color-indigo-700:#4338ca;--color-indigo-800:#3730a3;--color-indigo-900:#312e81;--color-indigo-950:#1e1b4b;`,`--color-violet-50:#f5f3ff;--color-violet-100:#ede9fe;--color-violet-200:#ddd6fe;--color-violet-300:#c4b5fd;--color-violet-400:#a78bfa;--color-violet-500:#8b5cf6;--color-violet-600:#7c3aed;--color-violet-700:#6d28d9;--color-violet-800:#5b21b6;--color-violet-900:#4c1d95;--color-violet-950:#2e1065;`,`--color-purple-50:#faf5ff;--color-purple-100:#f3e8ff;--color-purple-200:#e9d5ff;--color-purple-300:#d8b4fe;--color-purple-400:#c084fc;--color-purple-500:#a855f7;--color-purple-600:#9333ea;--color-purple-700:#7e22ce;--color-purple-800:#6b21a8;--color-purple-900:#581c87;--color-purple-950:#3b0764;`,`--color-fuchsia-50:#fdf4ff;--color-fuchsia-100:#fae8ff;--color-fuchsia-200:#f5d0fe;--color-fuchsia-300:#f0abfc;--color-fuchsia-400:#e879f9;--color-fuchsia-500:#d946ef;--color-fuchsia-600:#c026d3;--color-fuchsia-700:#a21caf;--color-fuchsia-800:#86198f;--color-fuchsia-900:#701a75;--color-fuchsia-950:#4a044e;`,`--color-pink-50:#fdf2f8;--color-pink-100:#fce7f3;--color-pink-200:#fbcfe8;--color-pink-300:#f9a8d4;--color-pink-400:#f472b6;--color-pink-500:#ec4899;--color-pink-600:#db2777;--color-pink-700:#be185d;--color-pink-800:#9d174d;--color-pink-900:#831843;--color-pink-950:#500724;`,`--color-rose-50:#fff1f2;--color-rose-100:#ffe4e6;--color-rose-200:#fecdd3;--color-rose-300:#fda4af;--color-rose-400:#fb7185;--color-rose-500:#f43f5e;--color-rose-600:#e11d48;--color-rose-700:#be123c;--color-rose-800:#9f1239;--color-rose-900:#881337;--color-rose-950:#4c0519;`,`--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";`,`--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;`,`--text-xs--line-height:1rem;--text-sm--line-height:1.25rem;--text-base--line-height:1.5rem;--text-lg--line-height:1.75rem;`,`--text-xl--line-height:1.75rem;--text-2xl--line-height:2rem;--text-3xl--line-height:2.25rem;--text-4xl--line-height:2.5rem;`,`--shadow-sm:0 1px 2px 0 rgb(0 0 0 / 0.05);--radius-sm:0.125rem;--blur-sm:4px;`,`}`,`body{line-height:inherit}`,`*,::after,::before,::backdrop,::file-selector-button{border-color:var(--color-gray-200,currentColor)}`,`input::placeholder,textarea::placeholder{color:var(--color-gray-400)}`,`button:not(:disabled),[role="button"]:not(:disabled){cursor:pointer}`].join(`
3
- `),D=`default-src 'none'; script-src 'unsafe-inline' data:; img-src data:; media-src data:; font-src data:; style-src 'unsafe-inline' data:; form-action 'none'; base-uri 'none'`,ce=`${D}; frame-src 'none'`,O=`allow-scripts allow-popups allow-popups-to-escape-sandbox`,k=`clipboard-write`,A=`data:text/javascript,export%20default%20globalThis.mermaid`;function j(e){return/\.html?$/i.test(e)}var M=/^(?:https?:|mailto:)/i,N=/^data:/i,P=`http://www.w3.org/1999/xlink`,F=/^(?:[a-z][a-z\d+.-]*:|\/\/)/i,I=/url\(\s*(['"]?)([^'")]*)\1\s*\)|@import\s+(['"])([^'"]+)\3/gi,L=[`src`,`href`,`xlink:href`,`poster`,`background`],R=/(?:^|,)\s*(data:\S+|[^,\s]+)/gi,z=/\b(?:preconnect|dns-prefetch|prefetch|preload|modulepreload|prerender)\b/i;function B(e,t){let n=e.trim();!n||n.startsWith(`#`)||N.test(n)||(F.test(n)?t.remote++:t.relative++)}function V(e,t){for(let n of e.matchAll(I))B(n[2]??n[4]??``,t)}function H(e,t){let n=e.createElement(`script`);return n.textContent=t.replace(/<\/script/gi,`<\\/script`),n}function U(e,t){let n=e.createElement(`style`);return n.setAttribute(`type`,`text/tailwindcss`),n.textContent=t,n}var W=`http://www.w3.org/2000/svg`;function G(e){return e.namespaceURI===W?e.getAttribute(`href`)??e.getAttributeNS(P,`href`):e.getAttribute(`src`)}function K(e,t,n,r){let i=r===void 0?[]:[U(e,r),H(e,oe)],a=H(e,n),o=t.hasAttribute(`defer`)||t.hasAttribute(`async`)||t.getAttribute(`type`)===`module`;o&&e.body.append(a),t.replaceWith(...i,...o?[]:[a])}function le(e,t,n){let r=new Set,i=new Set;for(let a of[...e.querySelectorAll(`script`)]){let o=G(a);if(o!==null&&N.test(o.trim()))continue;if(o===null){if(a.getAttribute(`type`)===`module`)for(let e of(a.textContent??``).matchAll(S))i.add(e[2]);continue}let s=C(o),c=s===`tailwind-v3`?`tailwind`:s,l=c?n[c]:void 0;if(!c||l===void 0||s===`tailwind-v3`&&n[`tailwind-v3`]===void 0){t.scripts++,a.remove();continue}if(r.has(c)){a.remove();continue}r.add(c),K(e,a,l,s===`tailwind-v3`?n[`tailwind-v3`]:void 0)}if(!i.size)return;if(n.mermaid===void 0){t.scripts+=i.size;return}let a=e.createElement(`script`);a.setAttribute(`type`,`importmap`),a.textContent=JSON.stringify({imports:Object.fromEntries([...i].map(e=>[e,A]))}),e.head.prepend(a,...r.has(`mermaid`)?[]:[H(e,n.mermaid)])}function ue(e,t,n){let r=t=>{let n=[...e.querySelectorAll(t)];return n.forEach(e=>e.remove()),n.length};le(e,t,n),t.embeds=r(`iframe, frame, frameset, object, embed, portal`),r(`base, meta[http-equiv]`);for(let t of e.querySelectorAll(`link`))z.test(t.getAttribute(`rel`)??``)&&t.remove();for(let t of e.querySelectorAll(`[ping]`))t.removeAttribute(`ping`);for(let n of e.querySelectorAll(`form`))t.forms++,n.removeAttribute(`action`);for(let t of e.querySelectorAll(`[formaction]`))t.removeAttribute(`formaction`)}function de(e,t){for(let n of e.querySelectorAll(`a, area`)){let e=n.getAttribute(`href`)??n.getAttributeNS(P,`href`);if(e===null)continue;let r=e.trim();if(r.startsWith(`#`)){n.setAttribute(`href`,`about:srcdoc${r}`),n.removeAttributeNS(P,`href`),n.removeAttribute(`target`);continue}if(M.test(r)){n.setAttribute(`target`,`_blank`),n.setAttribute(`rel`,`noopener noreferrer`);continue}F.test(r)||t.relative++,n.removeAttribute(`href`),n.removeAttributeNS(P,`href`),n.removeAttribute(`target`)}}function fe(e,t){for(let n of e.querySelectorAll(`[style]`))V(n.getAttribute(`style`),t);for(let n of e.querySelectorAll(`style`))/^(?:text\/css)?$/i.test(n.getAttribute(`type`)?.trim()??``)&&V(n.textContent??``,t);for(let n of e.querySelectorAll(`link[href]`))B(n.getAttribute(`href`),t);for(let n of e.querySelectorAll(`img, source, video, audio, track, input, image, use, body, table, td`)){for(let e of L){let r=n.getAttribute(e);r!==null&&B(r,t)}for(let e of(n.getAttribute(`srcset`)??``).matchAll(R))B(e[1],t)}}function pe(e,t={}){let n=new DOMParser().parseFromString(e,`text/html`),r={scripts:0,remote:0,relative:0,forms:0,embeds:0};ue(n,r,t),de(n,r),fe(n,r);let i=n.createElement(`meta`);i.setAttribute(`http-equiv`,`Content-Security-Policy`),i.setAttribute(`content`,D);let a=n.createElement(`meta`);return a.setAttribute(`name`,`referrer`),a.setAttribute(`content`,`no-referrer`),n.head.prepend(i,a),{srcdoc:`<!DOCTYPE html>${n.documentElement.outerHTML}`,blocked:r}}var q=e=>e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`);function me(e,t){return`<!DOCTYPE html><html><head><meta http-equiv="Content-Security-Policy" content="${ce}"><meta name="referrer" content="no-referrer"><style>html,body{margin:0;height:100%;overflow:hidden}iframe{display:block;border:0;width:100%;height:100%}</style></head><body><iframe title="${q(t)}" sandbox="${O}" allow="${k}" referrerpolicy="no-referrer" srcdoc="${q(e)}"></iframe></body></html>`}var J=(0,_.createContext)(null),he=/^[0-9a-f-]{36}$/i,ge=/^(\/p\/[^/?#]+\/tasks\/[^/?#]+)\/files\?(artifact=[^&#]*)$/;function Y(e){let t=new URLSearchParams(e);return[...t.keys()].length===1&&he.test(t.get(`artifact`)??``)}function _e(e,t,n){if(e.startsWith(`${t}?artifact=`))return Y(e.slice(t.length+1))?n+e.slice(t.length):null;let r=ge.exec(e);return r&&Y(r[2])?`${r[1]}/report?${r[2]}`:void 0}var ve=/^\/(?:api|p|tasks|new|settings|skills|workflows|git|github|inbox|automations)(?:\/|[?#]|$)/;function ye(e,t){let n=/^[a-z]:[\\/]/i.test(e),r=/^file:/i.test(e);if(!n&&/^[a-z][a-z\d+.-]*:/i.test(e)&&!r)return null;let i=r?e:decodeURIComponent(e);if(/[\u0000-\u001f]/.test(i))return null;if(!t||i.startsWith(`/`)||n||r)return i;let a=t.replaceAll(`\\`,`/`);return a.slice(0,a.lastIndexOf(`/`)+1)+i}function X(e,t){if(!e||/[\u0000-\u001f]/.test(e)||e.startsWith(`#`)||e.startsWith(`//`))return null;let n=e.indexOf(`#`),r=n<0?e:e.slice(0,n),i=n<0?``:e.slice(n),a=t.projectId?`/p/${encodeURIComponent(t.projectId)}`:``,o=`/tasks/${encodeURIComponent(t.runId)}/files`,s=`/tasks/${encodeURIComponent(t.runId)}/report`,c=_e(r,o,a+s);if(c!==void 0)return c===null?null:c+i;if(ve.test(r))return null;let l=ye(r,t.basePath);return l===null?null:`${a}${j(l)?s:o}?path=${encodeURIComponent(l)}${i}`}var Z=`text-accent-text underline underline-offset-2`;function be({href:e,children:t,internal:n,...r}){let[a,o]=(0,_.useState)(!1),s=i();return e?n?s?(0,v.jsx)(xe,{...r,href:e,children:t}):(0,v.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:Z,children:t}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:`cursor-pointer ${Z}`,onClick:e=>{e.preventDefault(),o(!0)},children:t}),(0,v.jsx)(y,{isOpen:a,url:e,onClose:()=>o(!1),onConfirm:()=>{window.open(e,`_blank`,`noreferrer`),o(!1)}})]}):(0,v.jsx)(`span`,{children:t})}function xe({href:e,children:t,...n}){let i=o(),a=r();return(0,v.jsx)(`a`,{...n,href:e,"data-streamdown":`link`,className:Z,onClick:t=>Q(t,i,e,a),children:t})}function Q(e,t,n,r){e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t(n,{state:{readerFrom:r.pathname+r.search,filesRestoreKey:r.key}}))}var Se={name:`shiki`,type:`code-highlighter`,getThemes:()=>[c,c],getSupportedLanguages:()=>l(),supportsLanguage:e=>l().includes(String(e).toLowerCase()),highlight:({code:e,language:t},n)=>d(e,String(t))||(u(e,String(t)).then(e=>n?.(e)),null)};function Ce(){let e=t=>{if(!t.children)return;let n=[];for(let r of t.children)if(r.type===`text`&&r.value?.includes(`
4
- `)){let e=r.value.split(/\r?\n/);e.forEach((t,r)=>{r>0&&!(t===``&&r===e.length-1)&&n.push({type:`break`}),t&&n.push({type:`text`,value:t})})}else e(r),n.push(r);t.children=n};return e}var $=[...Object.values(g),Ce],we=[`p`,`strong`,`em`,`del`,`code`,`a`],Te={p:`span`,a:`span`},Ee={enabled:!0,renderModal:e=>(0,v.jsx)(y,{...e})},De=`https://refused.invalid/`,Oe=0,ke=(0,_.memo)(function({children:e,breaks:t=!1,inline:n=!1,document:r=!1,imageSrc:i}){let o=(0,_.useContext)(J),s=(0,_.useMemo)(()=>{let e={instance:++Oe},n=new Set;function a(){let e=t=>{if((t.type===`link`||t.type===`definition`)&&t.url&&o){let e=X(t.url,o);e&&(t.url=e,n.add(e))}t.children?.forEach(e)};return e}let s=new Set;function c(){let e=t=>{if(t.type===`image`&&t.url&&i){let e=i(t.url);t.url=e?new URL(e,window.location.href).href:De,e&&s.add(t.url)}t.children?.forEach(e)};return e}let l=o?[[a,e]]:[],u=r&&i?[[c,e]]:[];return{remark:[...t?$:Object.values(g),...l,...u],components:{...o||r?{a:({href:e,children:t})=>r&&!o&&!/^(?:https?:|mailto:|#)/i.test(e??``)?(0,v.jsx)(`span`,{children:t}):(0,v.jsx)(be,{href:e,internal:n.has(e??``),children:t})}:{},...r?{img:({src:e,alt:t})=>typeof e==`string`&&s.has(e)?(0,v.jsx)(`img`,{src:e,alt:t??``,loading:`lazy`}):(0,v.jsxs)(`span`,{className:`text-muted-foreground`,children:[`[Image: `,t||`embedded image`,`]`]})}:{}}}},[o,t,r,i]);return(0,v.jsx)(ie,{className:n?`thread-markdown thread-markdown-inline`:`thread-markdown`,plugins:{code:Se},shikiTheme:[c,c],...a({remarkPlugins:o||r&&i?s.remark:t?$:void 0,allowedElements:n?we:void 0,unwrapDisallowed:n||void 0,components:n?Te:o||r?s.components:void 0}),linkSafety:Ee,controls:{code:{copy:!0,download:!1},table:!1,mermaid:!1},lineNumbers:!1,children:e})});export{k as a,pe as c,E as d,X as i,me as l,Q as n,O as o,J as r,j as s,ke as t,w as u};
3
+ `),D=`default-src 'none'; script-src 'unsafe-inline' data:; img-src data:; media-src data:; font-src data:; style-src 'unsafe-inline' data:; form-action 'none'; base-uri 'none'`,ce=`${D}; frame-src 'none'`,O=`allow-scripts allow-popups allow-popups-to-escape-sandbox`,k=`clipboard-write`,A=`data:text/javascript,export%20default%20globalThis.mermaid`;function j(e){return/\.html?$/i.test(e)}var M=/^(?:https?:|mailto:)/i,N=/^data:/i,P=`http://www.w3.org/1999/xlink`,F=/^(?:[a-z][a-z\d+.-]*:|\/\/)/i,I=/url\(\s*(['"]?)([^'")]*)\1\s*\)|@import\s+(['"])([^'"]+)\3/gi,L=[`src`,`href`,`xlink:href`,`poster`,`background`],R=/(?:^|,)\s*(data:\S+|[^,\s]+)/gi,z=/\b(?:preconnect|dns-prefetch|prefetch|preload|modulepreload|prerender)\b/i;function B(e,t){let n=e.trim();!n||n.startsWith(`#`)||N.test(n)||(F.test(n)?t.remote++:t.relative++)}function V(e,t){for(let n of e.matchAll(I))B(n[2]??n[4]??``,t)}function H(e,t){let n=e.createElement(`script`);return n.textContent=t.replace(/<\/script/gi,`<\\/script`),n}function U(e,t){let n=e.createElement(`style`);return n.setAttribute(`type`,`text/tailwindcss`),n.textContent=t,n}var W=`http://www.w3.org/2000/svg`;function G(e){return e.namespaceURI===W?e.getAttribute(`href`)??e.getAttributeNS(P,`href`):e.getAttribute(`src`)}function le(e,t,n,r){let i=r===void 0?[]:[U(e,r),H(e,oe)],a=H(e,n),o=t.hasAttribute(`defer`)||t.hasAttribute(`async`)||t.getAttribute(`type`)===`module`;o&&e.body.append(a),t.replaceWith(...i,...o?[]:[a])}function K(e,t,n){let r=new Set,i=new Set;for(let a of[...e.querySelectorAll(`script`)]){let o=G(a);if(o!==null&&N.test(o.trim()))continue;if(o===null){if(a.getAttribute(`type`)===`module`)for(let e of(a.textContent??``).matchAll(S))i.add(e[2]);continue}let s=C(o),c=s===`tailwind-v3`?`tailwind`:s,l=c?n[c]:void 0;if(!c||l===void 0||s===`tailwind-v3`&&n[`tailwind-v3`]===void 0){t.scripts++,a.remove();continue}if(r.has(c)){a.remove();continue}r.add(c),le(e,a,l,s===`tailwind-v3`?n[`tailwind-v3`]:void 0)}if(!i.size)return;if(n.mermaid===void 0){t.scripts+=i.size;return}let a=e.createElement(`script`);a.setAttribute(`type`,`importmap`),a.textContent=JSON.stringify({imports:Object.fromEntries([...i].map(e=>[e,A]))}),e.head.prepend(a,...r.has(`mermaid`)?[]:[H(e,n.mermaid)])}function ue(e,t,n){let r=t=>{let n=[...e.querySelectorAll(t)];return n.forEach(e=>e.remove()),n.length};K(e,t,n),t.embeds=r(`iframe, frame, frameset, object, embed, portal`),r(`base, meta[http-equiv]`);for(let t of e.querySelectorAll(`link`))z.test(t.getAttribute(`rel`)??``)&&t.remove();for(let t of e.querySelectorAll(`[ping]`))t.removeAttribute(`ping`);for(let n of e.querySelectorAll(`form`))t.forms++,n.removeAttribute(`action`);for(let t of e.querySelectorAll(`[formaction]`))t.removeAttribute(`formaction`)}function de(e,t){for(let n of e.querySelectorAll(`a, area`)){let e=n.getAttribute(`href`)??n.getAttributeNS(P,`href`);if(e===null)continue;let r=e.trim();if(r.startsWith(`#`)){n.setAttribute(`href`,`about:srcdoc${r}`),n.removeAttributeNS(P,`href`),n.removeAttribute(`target`);continue}if(M.test(r)){n.setAttribute(`target`,`_blank`),n.setAttribute(`rel`,`noopener noreferrer`);continue}F.test(r)||t.relative++,n.removeAttribute(`href`),n.removeAttributeNS(P,`href`),n.removeAttribute(`target`)}}function fe(e,t){for(let n of e.querySelectorAll(`[style]`))V(n.getAttribute(`style`),t);for(let n of e.querySelectorAll(`style`))/^(?:text\/css)?$/i.test(n.getAttribute(`type`)?.trim()??``)&&V(n.textContent??``,t);for(let n of e.querySelectorAll(`link[href]`))B(n.getAttribute(`href`),t);for(let n of e.querySelectorAll(`img, source, video, audio, track, input, image, use, body, table, td`)){for(let e of L){let r=n.getAttribute(e);r!==null&&B(r,t)}for(let e of(n.getAttribute(`srcset`)??``).matchAll(R))B(e[1],t)}}function pe(e,t={}){let n=new DOMParser().parseFromString(e,`text/html`),r={scripts:0,remote:0,relative:0,forms:0,embeds:0};ue(n,r,t),de(n,r),fe(n,r);let i=n.createElement(`meta`);i.setAttribute(`http-equiv`,`Content-Security-Policy`),i.setAttribute(`content`,D);let a=n.createElement(`meta`);return a.setAttribute(`name`,`referrer`),a.setAttribute(`content`,`no-referrer`),n.head.prepend(i,a),{srcdoc:`<!DOCTYPE html>${n.documentElement.outerHTML}`,blocked:r}}var q=e=>e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`);function me(e,t){return`<!DOCTYPE html><html><head><meta http-equiv="Content-Security-Policy" content="${ce}"><meta name="referrer" content="no-referrer"><style>html,body{margin:0;height:100%;overflow:hidden}iframe{display:block;border:0;width:100%;height:100%}</style></head><body><iframe title="${q(t)}" sandbox="${O}" allow="${k}" referrerpolicy="no-referrer" srcdoc="${q(e)}"></iframe></body></html>`}var J=(0,v.createContext)(null),he=/^[0-9a-f-]{36}$/i,ge=/^(\/p\/[^/?#]+\/tasks\/[^/?#]+)\/files\?(artifact=[^&#]*)$/;function Y(e){let t=new URLSearchParams(e);return[...t.keys()].length===1&&he.test(t.get(`artifact`)??``)}function _e(e,t,n){if(e.startsWith(`${t}?artifact=`))return Y(e.slice(t.length+1))?n+e.slice(t.length):null;let r=ge.exec(e);return r&&Y(r[2])?`${r[1]}/report?${r[2]}`:void 0}var ve=/^\/(?:api|p|tasks|new|settings|skills|workflows|git|github|inbox|automations)(?:\/|[?#]|$)/;function ye(e,t){let n=/^[a-z]:[\\/]/i.test(e),r=/^file:/i.test(e);if(!n&&/^[a-z][a-z\d+.-]*:/i.test(e)&&!r)return null;let i=r?e:decodeURIComponent(e);if(/[\u0000-\u001f]/.test(i))return null;if(!t||i.startsWith(`/`)||n||r)return i;let a=t.replaceAll(`\\`,`/`);return a.slice(0,a.lastIndexOf(`/`)+1)+i}function X(e,t){if(!e||/[\u0000-\u001f]/.test(e)||e.startsWith(`#`)||e.startsWith(`//`))return null;let n=e.indexOf(`#`),r=n<0?e:e.slice(0,n),i=n<0?``:e.slice(n),a=t.projectId?`/p/${encodeURIComponent(t.projectId)}`:``,o=`/tasks/${encodeURIComponent(t.runId)}/files`,s=`/tasks/${encodeURIComponent(t.runId)}/report`,c=_e(r,o,a+s);if(c!==void 0)return c===null?null:c+i;if(ve.test(r))return null;let l=ye(r,t.basePath);return l===null?null:`${a}${j(l)?s:o}?path=${encodeURIComponent(l)}${i}`}var Z=`text-accent-text underline underline-offset-2`;function be({href:e,children:t,internal:n,...r}){let[a,o]=(0,v.useState)(!1),s=i();return e?n?s?(0,y.jsx)(xe,{...r,href:e,children:t}):(0,y.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:Z,children:t}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:`cursor-pointer ${Z}`,onClick:e=>{e.preventDefault(),o(!0)},children:t}),(0,y.jsx)(b,{isOpen:a,url:e,onClose:()=>o(!1),onConfirm:()=>{window.open(e,`_blank`,`noreferrer`),o(!1)}})]}):(0,y.jsx)(`span`,{children:t})}function xe({href:e,children:t,...n}){let i=o(),a=r();return(0,y.jsx)(`a`,{...n,href:e,"data-streamdown":`link`,className:Z,onClick:t=>Q(t,i,e,a),children:t})}function Q(e,t,n,r){e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t(n,{state:{readerFrom:r.pathname+r.search,filesRestoreKey:r.key}}))}var Se={name:`shiki`,type:`code-highlighter`,getThemes:()=>[d,d],getSupportedLanguages:()=>l(),supportsLanguage:e=>l().includes(String(e).toLowerCase()),highlight:({code:e,language:t},n)=>u(e,String(t))||(c(e,String(t)).then(e=>n?.(e)),null)};function Ce(){let e=t=>{if(!t.children)return;let n=[];for(let r of t.children)if(r.type===`text`&&r.value?.includes(`
4
+ `)){let e=r.value.split(/\r?\n/);e.forEach((t,r)=>{r>0&&!(t===``&&r===e.length-1)&&n.push({type:`break`}),t&&n.push({type:`text`,value:t})})}else e(r),n.push(r);t.children=n};return e}var $=[...Object.values(_),Ce],we=[`p`,`strong`,`em`,`del`,`code`,`a`],Te={p:`span`,a:`span`},Ee={enabled:!0,renderModal:e=>(0,y.jsx)(b,{...e})},De=`https://refused.invalid/`,Oe=0,ke=(0,v.memo)(function({children:e,breaks:t=!1,inline:n=!1,document:r=!1,imageSrc:i}){let o=(0,v.useContext)(J),s=(0,v.useMemo)(()=>{let e={instance:++Oe},n=new Set;function a(){let e=t=>{if((t.type===`link`||t.type===`definition`)&&t.url&&o){let e=X(t.url,o);e&&(t.url=e,n.add(e))}t.children?.forEach(e)};return e}let s=new Set;function c(){let e=t=>{if(t.type===`image`&&t.url&&i){let e=i(t.url);t.url=e?new URL(e,window.location.href).href:De,e&&s.add(t.url)}t.children?.forEach(e)};return e}let l=o?[[a,e]]:[],u=r&&i?[[c,e]]:[];return{remark:[...t?$:Object.values(_),...l,...u],components:{...o||r?{a:({href:e,children:t})=>r&&!o&&!/^(?:https?:|mailto:|#)/i.test(e??``)?(0,y.jsx)(`span`,{children:t}):(0,y.jsx)(be,{href:e,internal:n.has(e??``),children:t})}:{},...r?{img:({src:e,alt:t})=>typeof e==`string`&&s.has(e)?(0,y.jsx)(`img`,{src:e,alt:t??``,loading:`lazy`}):(0,y.jsxs)(`span`,{className:`text-muted-foreground`,children:[`[Image: `,t||`embedded image`,`]`]})}:{}}}},[o,t,r,i]);return(0,y.jsx)(re,{className:n?`thread-markdown thread-markdown-inline`:`thread-markdown`,plugins:{code:Se},shikiTheme:[d,d],...a({remarkPlugins:o||r&&i?s.remark:t?$:void 0,allowedElements:n?we:void 0,unwrapDisallowed:n||void 0,components:n?Te:o||r?s.components:void 0}),linkSafety:Ee,controls:{code:{copy:!0,download:!1},table:!1,mermaid:!1},lineNumbers:!1,children:e})});export{k as a,pe as c,E as d,X as i,me as l,Q as n,O as o,J as r,j as s,ke as t,w as u};
@@ -0,0 +1,15 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{l as r,o as i,u as a}from"./button-RJMdCnZw.js";import{_r as o,br as s,vr as c}from"./project-scope-context-Xjbxntpg.js";import{A as l,L as u,N as d,V as f,j as p,z as m}from"./live-protocol-CjfZMf1X.js";import{a as h,i as g,n as _,r as v,s as y}from"./runners-Dc2_oqXR.js";import{X as b,l as x}from"./design-icons-B6-0w7Aw.js";import{h as S,l as C}from"./es2015-VrVcR1vD.js";import{c as w,i as T,p as E,r as ee,s as D,t as O}from"./dropdown-menu-Cr9RsmWG.js";import{a as k,o as A,r as j,t as M}from"./dist-FHKv_Ysh.js";import{i as N,o as P,r as F,s as I,t as L}from"./dialog-7Mg2IZCP.js";var R=e(t(),1),z=1,te=.9,ne=.8,re=.17,B=.1,V=.999,ie=.9999,ae=.99,oe=/[\\\/_+.#"@\[\(\{&]/,se=/[\\\/_+.#"@\[\(\{&]/g,ce=/[\s-]/,le=/[\s-]/g;function H(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?z:ae;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=H(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=z:oe.test(e.charAt(l-1))?(d*=ne,p=e.slice(i,l-1).match(se),p&&i>0&&(d*=V**+p.length)):ce.test(e.charAt(l-1))?(d*=te,m=e.slice(i,l-1).match(le),m&&i>0&&(d*=V**+m.length)):(d*=re,i>0&&(d*=V**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=ie)),(d<B&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=H(e,t,n,r,l+1,a+2,o),f*B>d&&(d=f*B)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function ue(e){return e.toLowerCase().replace(le,` `)}function de(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,H(e,t,ue(e),ue(t),0,0,{})}var U=`[cmdk-group=""]`,fe=`[cmdk-group-items=""]`,pe=`[cmdk-group-heading=""]`,me=`[cmdk-item=""]`,he=`${me}:not([aria-disabled="true"])`,ge=`cmdk-item-select`,W=`data-value`,_e=(e,t,n)=>de(e,t,n),ve=R.createContext(void 0),G=()=>R.useContext(ve),ye=R.createContext(void 0),be=()=>R.useContext(ye),xe=R.createContext(void 0),Se=R.forwardRef((e,t)=>{let n=J(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=J(()=>new Set),i=J(()=>new Map),a=J(()=>new Map),o=J(()=>new Set),s=Ne(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=C(),y=C(),b=C(),x=R.useRef(null),w=Fe();q(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,T.emit()}},[u]),q(()=>{w(6,A)},[]);let T=R.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)k(),D(),w(1,O);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(w(7,()=>{n.current.selectedItemId=j()?.id,T.emit()}),r||w(5,A),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}T.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),E=R.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,ee(t,r)),w(2,()=>{D(),T.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),w(3,()=>{k(),D(),n.current.value||O(),T.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=j();w(4,()=>{k(),t?.getAttribute(`id`)===e&&O(),T.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function ee(e,t){let r=s.current?.filter??_e;return e?r(e,n.current.search,t):0}function D(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;M().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(fe);t?t.appendChild(e.parentElement===t?e:e.closest(`${fe} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${fe} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${U}[${W}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function O(){let e=M().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(W);T.setState(`value`,e||void 0)}function k(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=ee(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function A(){var e;let t=j();t&&(t.parentElement?.firstChild===t&&((e=t.closest(U)?.querySelector(pe))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function j(){return x.current?.querySelector(`${me}[aria-selected="true"]`)}function M(){return Array.from(x.current?.querySelectorAll(he)||[])}function N(e){let t=M()[e];t&&T.setState(`value`,t.getAttribute(W))}function P(e){var t;let n=j(),r=M(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&T.setState(`value`,a.getAttribute(W))}function F(e){let t=j()?.closest(U),n;for(;t&&!n;)t=e>0?je(t,U):Me(t,U),n=t?.querySelector(he);n?T.setState(`value`,n.getAttribute(W)):P(e)}let I=()=>N(M().length-1),L=e=>{e.preventDefault(),e.metaKey?I():e.altKey?F(1):P(1)},z=e=>{e.preventDefault(),e.metaKey?N(0):e.altKey?F(-1):P(-1)};return R.createElement(S.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&L(e);break;case`ArrowDown`:L(e);break;case`p`:case`k`:g&&e.ctrlKey&&z(e);break;case`ArrowUp`:z(e);break;case`Home`:e.preventDefault(),N(0);break;case`End`:e.preventDefault(),I();break;case`Enter`:{e.preventDefault();let t=j();if(t){let e=new Event(ge);t.dispatchEvent(e)}}}}},R.createElement(`label`,{"cmdk-label":``,htmlFor:E.inputId,id:E.labelId,style:Le},c),X(e,e=>R.createElement(ye.Provider,{value:T},R.createElement(ve.Provider,{value:E},e))))}),Ce=R.forwardRef((e,t)=>{let n=C(),r=R.useRef(null),a=R.useContext(xe),o=G(),s=Ne(e),c=s.current?.forceMount??a?.forceMount;q(()=>{if(!c)return o.item(n,a?.id)},[c]);let l=Pe(n,r,[e.value,e.children,r],e.keywords),u=be(),d=Y(e=>e.value&&e.value===l.current),f=Y(e=>c||o.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);R.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(ge,p),()=>t.removeEventListener(ge,p)},[f,e.onSelect,e.disabled]);function p(){var e,t;m(),(t=(e=s.current).onSelect)==null||t.call(e,l.current)}function m(){u.setState(`value`,l.current,!0)}if(!f)return null;let{disabled:h,value:g,onSelect:_,forceMount:v,keywords:y,...b}=e;return R.createElement(S.div,{ref:i(r,t),...b,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!h,"aria-selected":!!d,"data-disabled":!!h,"data-selected":!!d,onPointerMove:h||o.getDisablePointerSelection()?void 0:m,onClick:h?void 0:p},e.children)}),we=R.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:a,...o}=e,s=C(),c=R.useRef(null),l=R.useRef(null),u=C(),d=G(),f=Y(e=>a||d.filter()===!1?!0:!e.search||e.filtered.groups.has(s));q(()=>d.group(s),[]),Pe(s,c,[e.value,e.heading,l]);let p=R.useMemo(()=>({id:s,forceMount:a}),[a]);return R.createElement(S.div,{ref:i(c,t),...o,"cmdk-group":``,role:`presentation`,hidden:!f||void 0},n&&R.createElement(`div`,{ref:l,"cmdk-group-heading":``,"aria-hidden":!0,id:u},n),X(e,e=>R.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?u:void 0},R.createElement(xe.Provider,{value:p},e))))}),Te=R.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,a=R.useRef(null),o=Y(e=>!e.search);return!n&&!o?null:R.createElement(S.div,{ref:i(a,t),...r,"cmdk-separator":``,role:`separator`})}),Ee=R.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=be(),o=Y(e=>e.search),s=Y(e=>e.selectedItemId),c=G();return R.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),R.createElement(S.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),De=R.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...a}=e,o=R.useRef(null),s=R.useRef(null),c=Y(e=>e.selectedItemId),l=G();return R.useEffect(()=>{if(s.current&&o.current){let e=s.current,t=o.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),R.createElement(S.div,{ref:i(o,t),...a,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":c,"aria-label":r,id:l.listId},X(e,e=>R.createElement(`div`,{ref:i(s,l.listInnerRef),"cmdk-list-sizer":``},e)))}),Oe=R.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return R.createElement(M,{open:n,onOpenChange:r},R.createElement(A,{container:o},R.createElement(k,{"cmdk-overlay":``,className:i}),R.createElement(j,{"aria-label":e.label,"cmdk-dialog":``,className:a},R.createElement(Se,{ref:t,...s}))))}),ke=R.forwardRef((e,t)=>Y(e=>e.filtered.count===0)?R.createElement(S.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Ae=R.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return R.createElement(S.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},X(e,e=>R.createElement(`div`,{"aria-hidden":!0},e)))}),K=Object.assign(Se,{List:De,Item:Ce,Input:Ee,Group:we,Separator:Te,Dialog:Oe,Empty:ke,Loading:Ae});function je(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Me(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Ne(e){let t=R.useRef(e);return q(()=>{t.current=e}),t}var q=typeof window>`u`?R.useEffect:R.useLayoutEffect;function J(e){let t=R.useRef();return t.current===void 0&&(t.current=e()),t}function Y(e){let t=be(),n=()=>e(t.snapshot());return R.useSyncExternalStore(t.subscribe,n,n)}function Pe(e,t,n,r=[]){let i=R.useRef(),a=G();return q(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(W,s),i.current=s}),i}var Fe=()=>{let[e,t]=R.useState(),n=J(()=>new Map);return q(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function Ie(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function X({asChild:e,children:t},n){return e&&R.isValidElement(t)?R.cloneElement(Ie(t),{ref:t.ref},n(t.props.children)):n(t)}var Le={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},Z=n();function Re({className:e,...t}){return(0,Z.jsx)(K,{"data-slot":`command`,className:a(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,e),...t})}function ze({title:e=`Command Palette`,description:t=`Search for a command to run...`,children:n,className:i,showCloseButton:o=!0,filter:s,...c}){return(0,Z.jsxs)(L,{...c,children:[(0,Z.jsxs)(P,{className:`sr-only`,children:[(0,Z.jsx)(I,{children:e}),(0,Z.jsx)(N,{children:t})]}),(0,Z.jsx)(F,{className:a(`overflow-hidden p-0`,i),showCloseButton:o,children:(0,Z.jsx)(Re,{...r({filter:s}),className:`**:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5`,children:n})})]})}function Be({className:e,...t}){return(0,Z.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex min-h-11 shrink-0 items-center gap-2 rounded-ss-[inherit] rounded-se-[inherit] border-b px-3`,children:[(0,Z.jsx)(b,{className:`size-4 shrink-0 opacity-50`}),(0,Z.jsx)(K.Input,{"data-slot":`command-input`,className:a(`flex h-11 min-w-0 flex-1 rounded-md bg-transparent py-3 text-base md:text-sm placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...t})]})}function Ve({className:e,onPointerMoveCapture:t,...n}){return(0,Z.jsx)(K.List,{"data-slot":`command-list`,onPointerMoveCapture:e=>{t?.(e),e.pointerType===`touch`&&e.stopPropagation()},className:a(`max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto`,e),...n})}function He({...e}){return(0,Z.jsx)(K.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e})}function Ue({className:e,...t}){return(0,Z.jsx)(K.Group,{"data-slot":`command-group`,className:a(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function We({className:e,...t}){return(0,Z.jsx)(K.Separator,{"data-slot":`command-separator`,className:a(`-mx-1 h-px bg-border`,e),...t})}function Ge({className:e,...t}){return(0,Z.jsx)(K.Item,{"data-slot":`command-item`,className:a(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...t})}function Ke({className:e,...t}){return(0,Z.jsx)(`span`,{"data-slot":`command-shortcut`,className:a(`ml-auto text-xs tracking-widest text-muted-foreground`,e),...t})}var qe=`default`,Je=u({id:f(),provider:o,label:f(),configDir:f(),path:f(),exists:p(),looksValid:p(),isDefault:p(),status:c.optional()});function Ye(e){return e.isDefault?`default:${e.provider}`:e.id}var Xe=s();u({editable:p(),profiles:l(Je),profileCapableProviders:l(o),selections:m(f(),Xe)}),u({projectId:f().min(1).max(64),provider:o,profileId:f().max(64).nullable()}),u({selections:m(f(),Xe)}),u({status:c}),u({provider:o,label:f().trim().max(200).optional(),configDir:f().trim().min(1).max(4096)}),u({profile:Je}),u({label:f().trim().max(200).optional(),configDir:f().trim().min(1).max(4096).optional()}),u({removed:d(!0),id:f()});var Ze=`quick-task`;function Qe(e,t,n=24){return[t,...(e??[]).filter(e=>!(e.source===t.source&&e.ref===t.ref))].slice(0,n)}function $e(e,t){return v(e,t)?.models.suggested}var et=[{value:``,label:`auto`,desc:`Harness default`},{value:`low`,label:`low`,desc:`Less reasoning, faster replies`},{value:`medium`,label:`medium`,desc:`Balanced reasoning`},{value:`high`,label:`high`,desc:`More reasoning for hard tasks`},{value:`xhigh`,label:`xhigh`,desc:`Extra-high reasoning`},{value:`max`,label:`max`,desc:`Maximum reasoning`}];function tt(e,t){let n=et,r=t?.models.find(t=>t.id===e)?.effortLevels;if(!r?.length)return n;let i=[et[0]],a=new Set;for(let e of r){if(a.has(e))continue;let t=et.find(t=>t.value===e);t&&(a.add(e),i.push(t))}return i.length>1?i:n}function nt(e,t){let n=e??``;return t.some(e=>e.value===n)?n:``}function rt(e,t,n){if(!e||$e(n,t)?.some(t=>t.id===e))return!1;let r=(n?.runners??[]).filter(e=>e.id!==t);return r.some(t=>t.models.retired.includes(e))?!0:r.some(t=>t.modelIdScope!==`provider-spanning`&&t.models.suggested.some(t=>t.id!==``&&t.id===e))}function it(e,t,n,r=[]){let i=n?.runner===e?n.models:[],a=$e(t,e)??$e(t,`claude`)??[],o=[...i.length?a.slice(0,1):a],s=new Set(o.map(e=>e.id));for(let e of i)!e.id||s.has(e.id)||(s.add(e.id),o.push({id:e.id,label:e.label||e.id,desc:e.description}));for(let n of r)!n||s.has(n)||rt(n,e,t)||(s.add(n),o.push({id:n,label:n,desc:`Custom or legacy model`}));return o}function at(e,t,n,r=!1,i=!1){let a=h(t,e);if(a!==void 0){if(n?.stale)return`Using cached ${a} model list`;if(r||n?.source===`unavailable`)return`Latest ${a} models unavailable`;if(i&&!n)return`Loading ${a} models…`}}function ot(e,t,n){return at(e,t,n?.data,n?.isError,n?.isFetching)}function st(e,t){let n=g(t).filter(t=>e.some(e=>e.name===t&&e.available));return n.length>0?n:[`claude`]}function ct(e,t,n){return e!==null&&t.includes(e)?e:t.includes(n)?n:t[0]??`claude`}function lt(e,t,n=!1){return!n&&e===t?void 0:e}function ut(e,t,n,r,i){let a=it(t,n,i,[e,r?.[t]]);if(e!==null&&a.some(t=>t.id===e))return e;let o=r?.[t];return o!==void 0&&a.some(e=>e.id===o)?o:``}function dt(e,t,n){return e.source===`skill`?t.some(t=>t.id===e.ref&&(e.path===void 0||t.path===e.path)):n.some(t=>t.name===e.ref)}function ft(e,t,n,r=!1){return e?.source===`skill`&&(r||e.typed)||e&&dt(e,t,n)?e:null}function pt(e){let{task:t,source:n,model:r,modelsLocked:i,effort:a,runner:o,runnerExplicit:s,defaultRunner:c,agentProfile:l,images:u,worktree:d,autonomous:f,archiveWhenDone:p,autoMergePr:m,allowWorkers:h,allowMessaging:g}=e;return{task:t,...n?.source===`skill`?{steps:[{id:`task`,name:n.ref,skill:n.ref,...n.path===void 0?{}:{skillPath:n.path},prompt:`{{task}}`}]}:{workflow:n?.ref??`quick-task`},model:i?void 0:r||void 0,effort:i?void 0:a||void 0,runner:lt(o,c,s),agentProfile:l||void 0,images:u.length>0?[...u]:void 0,worktree:d!==!1&&void 0,autonomous:f===!0||void 0,...mt({archiveWhenDone:p,autoMergePr:m,allowWorkers:h,allowMessaging:g})}}function mt(e){return{...e.archiveWhenDone?{archiveWhenDone:!0}:{},...e.autoMergePr?{autoMergePr:!0}:{},...e.allowWorkers===!1?{allowWorkers:!1}:{},...e.allowMessaging===!1?{allowMessaging:!1}:{}}}function ht(e,t){return t?{...e,notify:!0}:e}function gt(e){return`/tasks/${e.id}`}var _t=80,vt=2e3,yt=50,bt=200,xt=50,St=[{id:`add-tests`,label:`Add tests`,text:`Also add or update tests covering this change.`},{id:`explain-change`,label:`Explain the change`,text:`Explain what changed and why before finishing.`},{id:`keep-minimal`,label:`Keep it minimal`,text:`Keep the change as small and targeted as possible — no unrelated refactors.`},{id:`update-docs`,label:`Update docs`,text:`Also update any relevant documentation or comments.`},{id:`check-edge-cases`,label:`Double-check edge cases`,text:`Double-check edge cases and error handling before finishing.`}];function Ct(e){return!!e&&typeof e==`object`}function wt(e){if(e===void 0||!Array.isArray(e))return St.map(e=>({...e}));let t=new Set,n=[];for(let r of e){if(!Ct(r))continue;let e=typeof r.id==`string`?r.id.trim():``;if(e===`create-automation`)continue;let i=typeof r.label==`string`?r.label.trim():``,a=typeof r.text==`string`?r.text.trim():``;if(!e||!i||!a||t.has(e))continue;t.add(e);let o=Tt(r.skills);if(n.push({id:e,label:i.slice(0,_t),text:a.slice(0,vt),...o.length>0?{skills:o}:{}}),n.length>=yt)break}return n}function Tt(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){if(typeof n!=`string`)continue;let e=n.trim();if(!(!e||t.has(e))&&(t.add(e.slice(0,bt)),t.size>=xt))break}return[...t]}function Et(e,t){if(t.length===0)return[];let n=new Set(t);return e.filter(e=>e.skills?.some(e=>n.has(e)))}function Dt(e,t){return Et(e,t).map(e=>e.text).join(`
2
+
3
+ `)}function Ot(e,t,n,r=``){if(e===``||e===r||e===t){let e=r&&n?`${r}\n\n${n}`:r||n;return{text:e,applied:n?e:``}}return{text:e,applied:t}}function kt(){return`tpl-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function At(e,t,n){let r=Math.max(0,Math.min(t,e.length)),i=e.slice(0,r),a=e.slice(r),o=``;i.length>0&&(o=i.endsWith(`
4
+
5
+ `)?``:i.endsWith(`
6
+ `)?`
7
+ `:`
8
+
9
+ `);let s=a.replace(/^[ \t]+/,``),c=``;return s.length>0&&(c=s.startsWith(`
10
+
11
+ `)?``:s.startsWith(`
12
+ `)?`
13
+ `:`
14
+
15
+ `),{text:i+o+n+c+s,caret:i.length+o.length+n.length}}function jt({prompt:e,base:t,selectionStart:n,focused:r,remembered:i}){return e===t?e.length:r&&n!=null||n!=null&&n>0?n:i??e.length}var Mt=`inline-flex h-[26px] min-w-0 max-w-full items-center gap-1.5 rounded-full border border-control-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:border-dashed disabled:bg-muted`,Nt=(0,Z.jsx)(x,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-supporting-foreground`}),Pt=(0,R.createContext)(null),Q=e=>Number.parseFloat(e)||0;function Ft({pill:e,box:t,full:n}){let r=getComputedStyle(e),i=[...e.children].filter(e=>{if(e===t)return!1;let n=getComputedStyle(e);return n.display!==`none`&&n.position!==`absolute`});return i.reduce((e,t)=>e+t.getBoundingClientRect().width,0)+Q(r.columnGap)*i.length+n.getBoundingClientRect().width+Q(r.paddingLeft)+Q(r.paddingRight)+Q(r.borderLeftWidth)+Q(r.borderRightWidth)}function It(e){for(let t=e.parentElement;t;t=t.parentElement){if(t.dataset.slot===`picker-pill-disabled-wrapper`)continue;let e=getComputedStyle(t).display;if(e===`grid`||e===`flex`)return t}return e.parentElement}function Lt(e){let t=new Map;for(let n of e){let e=It(n.pill),r=t.get(e)??new Map,i=Math.round(n.pill.getBoundingClientRect().top);r.set(i,[...r.get(i)??[],n]),t.set(e,r)}for(let[e,n]of t){let t=getComputedStyle(e),r=e.clientWidth-Q(t.paddingLeft)-Q(t.paddingRight);for(let e of n.values())if(e.reduce((e,t)=>e+Ft(t),0)+Q(t.columnGap)*(e.length-1)>r+.5)return!1}return!0}function Rt({children:e}){let t=(0,R.useRef)(new Map),n=(0,R.useRef)(null),[r,i]=(0,R.useState)(!0),a=(0,R.useCallback)(()=>i(Lt([...t.current.values()])),[]),o=(0,R.useCallback)((e,r)=>{if(t.current.set(e,r),typeof ResizeObserver<`u`){n.current??=new ResizeObserver(a);for(let e of[r.box,r.full,It(r.pill)])n.current.observe(e)}return a(),()=>{if(t.current.delete(e),typeof ResizeObserver<`u`)for(let e of[r.box,r.full])n.current?.unobserve(e);a()}},[a]);(0,R.useLayoutEffect)(()=>()=>n.current?.disconnect(),[]);let s=(0,R.useMemo)(()=>({register:o,showPrefixes:r}),[o,r]);return(0,Z.jsx)(Pt.Provider,{value:s,children:e})}function zt({field:e,children:t}){let n=(0,R.useRef)(null),r=(0,R.useRef)(null),i=(0,R.useContext)(Pt),o=i?.register,s=(0,R.useId)(),[c,l]=(0,R.useState)(!0);(0,R.useLayoutEffect)(()=>{let e=n.current,t=r.current;if(o){let n=e.closest(`[data-slot$="pill"]`);return n?o(s,{pill:n,box:e,full:t}):void 0}let i=()=>l(t.getBoundingClientRect().width<=e.getBoundingClientRect().width+.5);if(i(),typeof ResizeObserver>`u`)return;let a=new ResizeObserver(i);return a.observe(e),a.observe(t),()=>a.disconnect()},[e,t,s,o]);let u=i!==null,d=u?i.showPrefixes:c,f=u&&!d;return(0,Z.jsxs)(`span`,{ref:n,className:`relative min-w-0 overflow-hidden`,"aria-hidden":`true`,children:[(0,Z.jsxs)(`span`,{ref:r,className:a(`invisible w-max whitespace-nowrap`,f?`absolute left-0 top-0`:`block`),children:[e,` · `,t]}),(0,Z.jsxs)(`span`,{"data-slot":`picker-label`,className:a(`block truncate`,f?`relative`:`absolute inset-0`),children:[d?(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[e,` · `]}):null,t]})]})}function Bt({fieldLabel:e,ariaLabel:t,label:n,options:r,value:i}){return e?`${t} · ${typeof n==`string`?n:r.find(e=>e.value===i)?.label??i}`:t}function Vt({readOnly:e,disabled:t,hint:n,disabledHint:r}){return e?r??n:t?r:n}function Ht({fieldLabel:e,fullLabel:t,explanation:n}){return e?[t,n].filter(Boolean).join(` — `):n}function Ut({icon:e,fieldLabel:t,ariaLabel:n,label:r}){return(0,Z.jsxs)(Z.Fragment,{children:[e,t?(0,Z.jsx)(zt,{field:n,children:r}):(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,title:typeof r==`string`?r:void 0,children:r})]})}function Wt({slot:e,ariaLabel:t,label:n,value:r,options:i,onPick:o,disabled:s=!1,readOnly:c=!1,hint:l,disabledHint:u,status:d,searchPlaceholder:f,icon:p,fieldLabel:m=!1}){let[h,g]=(0,R.useState)(!1),[_,v]=(0,R.useState)(``),y=(0,R.useRef)(null),S=(0,R.useRef)(null),C=f?i.filter(e=>e.label.toLowerCase().includes(_.trim().toLowerCase())):i;(0,R.useEffect)(()=>{if(!h||!f)return;let e=window.setTimeout(()=>y.current?.focus());return()=>window.clearTimeout(e)},[h,f]);let k=e=>{y.current&&document.activeElement===y.current&&e.preventDefault()},A=p?` h-11 gap-2 rounded-lg border-border px-3 text-foreground`:``,j=Bt({fieldLabel:m,ariaLabel:t,label:n,options:i,value:r}),M=Ht({fieldLabel:m,fullLabel:j,explanation:Vt({readOnly:c,disabled:s,hint:l,disabledHint:u})}),N=Ut({icon:p,fieldLabel:m,ariaLabel:t,label:n});if(c)return(0,Z.jsxs)(`span`,{"data-slot":e,"aria-label":j,title:M,className:a(Mt,A,`cursor-default hover:bg-card hover:text-muted-foreground`),children:[N,m?(0,Z.jsx)(`span`,{className:`sr-only`,children:j}):null]});let P=(0,Z.jsxs)(`button`,{type:`button`,"data-slot":e,"aria-label":j,disabled:s,title:M,className:a(Mt,A),children:[N,p?(0,Z.jsx)(x,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-muted-foreground`}):Nt]});return s?(0,Z.jsx)(`span`,{"data-slot":`picker-pill-disabled-wrapper`,title:M,className:`inline-flex min-w-0 max-w-full`,children:P}):(0,Z.jsxs)(O,{open:h,onOpenChange:e=>{g(e),e||v(``)},children:[(0,Z.jsx)(E,{asChild:!0,children:P}),(0,Z.jsxs)(ee,{ref:S,align:`start`,"data-testid":`${e}-menu`,children:[f?(0,Z.jsxs)(`div`,{"data-slot":`picker-search`,className:`mbe-1 flex min-h-11 min-w-56 items-center gap-2 border-b border-border px-2`,children:[(0,Z.jsx)(b,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Z.jsx)(`input`,{ref:y,type:`search`,"aria-label":f,placeholder:f,value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),e.stopPropagation();let t=S.current?.querySelectorAll(`[role="menuitemradio"]:not([data-disabled])`);(e.key===`ArrowDown`?t?.[0]:t?.[t.length-1])?.focus()}else e.key!==`Escape`&&e.stopPropagation()},className:`h-11 w-0 min-w-0 flex-1 bg-transparent text-sm placeholder:text-muted-foreground`})]}):null,(0,Z.jsx)(D,{value:r,onValueChange:o,children:C.map(e=>(0,Z.jsx)(w,{value:e.value,className:a(`gap-2.5`,f&&`min-h-11`),onPointerMove:k,onPointerLeave:k,onKeyDown:t=>{y.current&&(t.key===`ArrowUp`&&e===C[0]||t.key===`Tab`&&t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),y.current.focus())},children:(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsx)(`span`,{className:`text-[13px] font-medium`,children:e.label}),e.desc?(0,Z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.desc}):null]})},e.value))}),f&&C.length===0?(0,Z.jsx)(`p`,{role:`status`,className:`px-2 py-5 text-center text-xs text-muted-foreground`,children:`No matches found.`}):null,d?(0,Z.jsx)(T,{disabled:!0,onPointerMove:k,onPointerLeave:k,className:`border-t border-border text-[11px] text-muted-foreground`,children:d}):null]})]})}var $=(e,t)=>t===null?e:`${e}:${t}`;function Gt({runners:e,value:t,onPick:n,disabled:r=!1,accounts:i=[],account:a=null,repoAccount:o,icon:s,fieldLabel:c}){let l=y().data,u=_(l).filter(t=>e.includes(t.id)).flatMap(e=>{let t=i.filter(t=>t.provider===e.id);return t.length<2?[{value:$(e.id,null),label:e.id,desc:e.pickerDescription}]:t.map(t=>({value:$(e.id,t.id),label:`${e.id} · ${t.label}`,desc:t.configDir}))}),d=a??o?.[t]??`default`,f=u.some(e=>e.value===$(t,d))?$(t,d):$(t,null);return(0,Z.jsx)(Wt,{icon:s,fieldLabel:c,slot:`runner-pill`,ariaLabel:`Runner`,label:u.find(e=>e.value===f)?.label??t,value:f,disabled:r,onPick:e=>{let[t,r]=e.split(`:`);n(t,r??null)},options:u})}export{Ye as A,ft as C,mt as D,gt as E,Be as F,Ge as I,Ve as L,ze as M,He as N,ht as O,Ue as P,We as R,ct as S,dt as T,tt as _,Mt as a,nt as b,At as c,Ot as d,jt as f,ot as g,pt as h,Nt as i,Re as j,qe as k,kt as l,st as m,Rt as n,St as o,Ze as p,Gt as r,Dt as s,Wt as t,wt as u,it as v,lt as w,ut as x,Qe as y,Ke as z};
@@ -0,0 +1,3 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r,u as i}from"./button-RJMdCnZw.js";import{Lr as a,Rr as o,lr as s,zr as c}from"./project-scope-context-Xjbxntpg.js";import{n as l}from"./toaster-BWMQArHJ.js";import{t as u}from"./createLucideIcon-BHp8sXmF.js";import{t as d}from"./arrow-right-Dh_Lx3um.js";import{n as f,r as p,t as m}from"./hourglass-B0lPAJvT.js";import{t as h}from"./info-DA1x_4bz.js";import{a as g}from"./format-BNCkW110.js";import{t as _}from"./play-CmVAj_fu.js";import{d as v,l as y,n as b,u as x}from"./thread-state-Cn5cetra.js";import{a as S,c as C,i as w,l as T,p as E,r as D,s as ee,t as O}from"./dropdown-menu-Cr9RsmWG.js";import{s as te}from"./project-router-lPPUPPDI.js";import{Bt as ne,Ht as k,Vt as A,Zt as j,_n as re,b as ie,cn as ae,d as oe,f as se,g as ce,gn as le,h as M,in as ue,ln as de,m as fe,mn as N,nn as pe,p as me,pn as he,rn as ge,sn as _e,un as P,vn as F,x as ve,y as ye,zt as I}from"./index-BUcVG7uX.js";var be=u(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),xe=u(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),L=u(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),R=u(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),z=u(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),B=u(`folder-x`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),V=u(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),Se=u(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),Ce=u(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),H=u(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),U=u(`monitor-smartphone`,[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]),W=u(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),G=u(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),K=u(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),q=u(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),we=u(`tablet`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]),Te=u(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Ee=u(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),De=u(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),J=e(t(),1),Oe=1e3,ke=[500,1e3,2e3,4e3,8e3],Ae=1;function je(e,t){let n=`/api/v1/p/${encodeURIComponent(e.projectId)}/runs/${encodeURIComponent(e.runId)}/preview/ws`,r=()=>`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${n}`,i=null,c,l=!1,u=!1,d=0,f=0,p=()=>typeof document>`u`||a(),m=()=>{if(l||!p())return;let e=globalThis.WebSocket;if(typeof e!=`function`)return;let n=new e(r());n.binaryType=`blob`,i=n,n.addEventListener(`open`,()=>{n===i&&(u=!0,t.onTransport(`open`))}),n.addEventListener(`message`,e=>{if(n!==i)return;let r=e.data;if(typeof r==`string`){let e;try{e=JSON.parse(r)}catch{return}let n=s.safeParse(e);n.success&&t.onMessage(n.data);return}r instanceof Blob&&(f=0,t.onFrame(r))}),n.addEventListener(`error`,()=>void 0),n.addEventListener(`close`,()=>{if(n!==i||l)return;if(i=null,!u){if(d+=1,d>=2){l=!0,t.onTransport(`blocked`);return}t.onTransport(`reconnecting`,d),c=setTimeout(m,Oe);return}if(f>=5){l=!0,t.onTransport(`closed`);return}let e=ke[Math.min(f,ke.length-1)];f+=1,t.onTransport(`reconnecting`,f),c=setTimeout(m,e)})},h=o(e=>{if(!l)if(e)i||m();else{clearTimeout(c),c=void 0;let e=i;i=null,e?.close()}});return t.onTransport(`connecting`),m(),{send(e){i?.readyState===Ae&&i.send(JSON.stringify(e))},close(){l=!0,h(),clearTimeout(c),c=void 0;let e=i;i=null,e?.close()}}}var Y=n();function Me({iconOnly:e=!1,responsive:t=!1,className:n}){return t?(0,Y.jsx)(A,{children:(0,Y.jsxs)(I,{children:[(0,Y.jsx)(k,{asChild:!0,children:(0,Y.jsxs)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:i(`inline-flex h-7 min-w-7 shrink-0 items-center justify-center gap-0 rounded-full bg-muted px-0 text-xs font-semibold text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none @min-[640px]:gap-1.5 @min-[640px]:px-2.5`,n),children:[(0,Y.jsx)(z,{className:`size-3.5`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[640px]:inline`,children:`Experimental`})]})}),(0,Y.jsx)(ne,{children:`Experimental`})]})}):e?(0,Y.jsx)(A,{children:(0,Y.jsxs)(I,{children:[(0,Y.jsx)(k,{asChild:!0,children:(0,Y.jsx)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:i(`inline-flex size-7 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,n),children:(0,Y.jsx)(z,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Y.jsx)(ne,{children:`Experimental`})]})}):(0,Y.jsxs)(`span`,{"data-slot":`preview-experimental`,className:i(`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full bg-muted px-2.5 text-xs font-semibold text-muted-foreground`,n),children:[(0,Y.jsx)(z,{className:`size-3.5`,"aria-hidden":`true`}),`Experimental`]})}function Ne({text:e,source:t,onCopy:n,className:r}){let a=e.replace(/\s+$/,``).split(`
2
+ `);return(0,Y.jsxs)(`div`,{"data-slot":`preview-log-tail`,className:i(`min-w-0 rounded-lg bg-muted px-3.5 py-3 font-mono text-xs`,r),children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 font-sans text-xs text-soft-foreground`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,Y.jsx)(`span`,{className:`font-semibold tracking-wide uppercase`,children:`Log tail`}),` last ${a.length} ${a.length===1?`line`:`lines`} · ${t}`]}),(0,Y.jsxs)(`button`,{type:`button`,className:`-m-2 inline-flex min-h-11 items-center gap-1.5 rounded-sm p-2 text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:min-h-0 md:p-0`,onClick:()=>n(e),children:[(0,Y.jsx)(N,{className:`size-3.5`,"aria-hidden":`true`}),`Copy`]})]}),(0,Y.jsx)(`pre`,{className:`max-h-48 overflow-auto break-words whitespace-pre-wrap text-foreground`,children:e.replace(/\s+$/,``)})]})}var Pe=/^([a-z][a-z0-9+.-]*):/i;function Fe(e,t){let n=e.trim();if(n===``)return{kind:`error`,message:`Type a URL or a port.`};if(/^\d{1,5}$/.test(n)){let e=Number(n);return e<1||e>65535?{kind:`error`,message:`A port is a number from 1 to 65535.`}:t.some(t=>t.port===e)?{kind:`server`,port:e}:{kind:`url`,url:`http://localhost:${e}`}}let r=Pe.exec(n)?.[1]?.toLowerCase();return r&&!/^[a-z0-9.-]+:\d/i.test(n)?r!==`http`&&r!==`https`?{kind:`error`,message:`Only http and https addresses open here.`}:Ie(n):Ie(`http://${n}`)}function Ie(e){let t={kind:`error`,message:`That is not a valid address.`};if(/\s/.test(e))return t;try{new URL(e)}catch{return t}return{kind:`url`,url:e}}function Le(e){return e.replace(/^https?:\/\//i,``)}var Re=`https://github.com/hearsay-tools/squawk#environment-variables`;function ze({state:e,actions:t,url:n,worktree:r}){switch(e.stage){case`chromium-missing`:return(0,Y.jsx)(Ue,{state:e,actions:t});case`downloading`:return(0,Y.jsx)(Ge,{state:e,actions:t});case`download-failed`:return(0,Y.jsx)(Ke,{state:e,actions:t});case`sandbox-failed`:return(0,Y.jsx)(qe,{state:e,actions:t});case`browser-exited`:return(0,Y.jsx)(Je,{state:e,actions:t});case`needs-approval`:return(0,Y.jsx)(Ze,{state:e,actions:t});case`port-held`:return(0,Y.jsx)(Qe,{state:e,actions:t});case`server-starting`:return(0,Y.jsx)($e,{state:e,actions:t});case`server-stalled`:return(0,Y.jsx)(et,{state:e,actions:t});case`server-exited`:return(0,Y.jsx)(tt,{state:e,actions:t});case`server-stopped`:return(0,Y.jsx)(nt,{state:e,actions:t});case`loading`:return(0,Y.jsx)(it,{step:e.step,url:n});case`worktree-removed`:return(0,Y.jsx)(at,{state:e,actions:t,worktree:r});case`proxy-blocked`:return(0,Y.jsx)(ot,{actions:t});case`taken-over`:return(0,Y.jsx)(ct,{state:e,actions:t})}}function X({icon:e,title:t,children:n,state:r}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":r,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:e}),(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:t}),n]})}var Z=({children:e})=>(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e}),Q=({children:e})=>(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e});function Be({server:e}){return(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(ge,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`Runs ${M(e.command)} in this task's worktree, on the host.`})]})}function Ve({copy:e,command:t,label:n}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-install-command`,className:`min-w-0 rounded-lg bg-muted px-3.5 py-3`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-3 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:[(0,Y.jsx)(`span`,{children:n}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Copy command`,className:`-m-2 inline-flex size-11 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:size-6`,onClick:()=>e(t),children:(0,Y.jsx)(N,{className:`size-4`,"aria-hidden":`true`})})]}),(0,Y.jsx)(`code`,{className:`block font-mono text-sm break-words whitespace-pre-wrap text-foreground`,children:t})]})}function He({server:e,status:t}){return(0,Y.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,Y.jsx)(j,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:t})]}),(0,Y.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,Y.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:e.command}),e.cwd?(0,Y.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,Y.jsx)(`span`,{children:`cwd`}),(0,Y.jsx)(`span`,{className:`break-all`,children:e.cwd})]}):null]}),(0,Y.jsx)(`div`,{className:`mt-2.5`,children:(0,Y.jsx)(Be,{server:e})})]})}function Ue({state:e,actions:t}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(R,{}),title:`This host has no browser yet`,children:[(0,Y.jsx)(Z,{children:e.canDownload?`Preview runs Chromium on the machine Squawk runs on. Squawk can download it into ~/.cache/cez/ (about 150 MB). Nothing else on the host changes.`:`Preview runs Chromium on the machine Squawk runs on. Squawk has no download for this platform, so install it with the system package manager.`}),e.canDownload?(0,Y.jsx)(Q,{children:(0,Y.jsxs)(r,{variant:`contrast`,onClick:t.download,children:[(0,Y.jsx)(R,{"aria-hidden":`true`}),`Download Chromium`]})}):null,(0,Y.jsx)(Ve,{command:e.installCommand,copy:t.copy,label:e.canDownload?`Or install it yourself`:`Install it yourself`})]})}function We(e){return Math.round(e/1e6)}function Ge({state:e,actions:t}){let n=(0,J.useRef)(null);n.current??={at:Date.now(),received:e.received};let i=e.total>0?Math.min(100,Math.floor(e.received/e.total*100)):0,a=(Date.now()-n.current.at)/1e3,o=a>=1?(e.received-n.current.received)/a:0,s=o>0?Math.ceil((e.total-e.received)/o):void 0;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(R,{}),title:`Downloading Chromium`,children:[(0,Y.jsx)(Z,{children:`Into ~/.cache/cez/, no root needed. Nothing else on the host changes.`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":`Chromium download`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":i,className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:`h-full rounded-full bg-success`,style:{width:`${i}%`}})}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:`${We(e.received)} of ${We(e.total)} MB · ${i}%`}),s===void 0?null:(0,Y.jsx)(`span`,{children:`about ${s} s left`})]})]}),(0,Y.jsx)(Q,{children:(0,Y.jsx)(r,{variant:`outline`,onClick:t.cancelDownload,children:`Cancel`})})]})}function Ke({state:e,actions:t}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(Te,{className:`text-danger`}),title:`Couldn't download Chromium`,children:[(0,Y.jsx)(Z,{children:`${e.error.replace(/\.$/,``)}. Install Chromium with the system package manager, then retry.`}),(0,Y.jsx)(Ve,{command:e.installCommand,copy:t.copy,label:`Install it yourself`}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(r,{variant:`contrast`,onClick:t.download,children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Retry download`]}),(0,Y.jsxs)(r,{variant:`outline`,onClick:()=>t.copy(`Chromium download failed\n${e.error}\nInstall: ${e.installCommand}`),children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}function qe({state:e,actions:t}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(q,{className:`text-danger`}),title:`Chromium couldn't start its sandbox`,children:[(0,Y.jsx)(Z,{children:`The host blocks the sandbox Chromium needs. This usually means Squawk runs as root, or inside a container without user namespaces.`}),(0,Y.jsx)(Ne,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(r,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(r,{variant:`outline`,onClick:()=>t.copy(`Chromium failed to start its sandbox\n${e.stderrTail}`),children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),`Copy diagnostics`]})]}),(0,Y.jsx)(`a`,{className:`text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:Re,target:`_blank`,rel:`noopener noreferrer`,children:`Docs: running without the sandbox (CEZ_PREVIEW_NO_SANDBOX=1)`})]})}function Je({state:e,actions:t}){let n=e.reason===`timeout`,i=e.signal?` (${e.signal})`:e.exitCode===void 0?``:` (code ${e.exitCode})`,a=e.serverUp?`The dev server is still up; only the browser needs a restart.`:`The browser needs a restart.`,o=n?`Chromium did not start in time`:`Chromium exited${i}`;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(f,{className:`text-danger`}),title:n?`The browser did not start`:`The browser stopped`,children:[(0,Y.jsx)(Z,{children:n?`Chromium did not open its DevTools port in time. ${a}`:`Chromium exited unexpectedly${i}. ${a}`}),(0,Y.jsx)(Ne,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(r,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(r,{variant:`outline`,onClick:()=>t.copy(`${o}\n${e.stderrTail}`),children:[(0,Y.jsx)(N,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}var Ye=2;function Xe(e){let[t,n]=(0,J.useState)(()=>Date.now());return(0,J.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function Ze({state:e,actions:t}){let{server:n,wasRunning:i}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:i?(0,Y.jsx)(Ee,{className:`text-pending-strong`}):(0,Y.jsx)(_,{}),title:i?`Nothing answers on :${n.port} anymore`:`${n.label} isn't running yet`,children:[(0,Y.jsx)(Z,{children:i?`${n.label} was running when the agent registered it, likely inside the agent's own session, which has ended. Squawk can start it with the registered command.`:`The agent registered this server. Nothing runs until you approve it here.`}),(0,Y.jsx)(He,{server:n,status:i?`was running when registered · silent now`:`registered · not started`}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(r,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(_,{"aria-hidden":`true`}),`Run and open`]})})]})}function Qe({state:e,actions:t}){let{server:n,ownerTitle:i}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(Te,{className:`text-pending-strong`}),title:`${n.label} :${n.port} is in use by another task`,children:[(0,Y.jsx)(Z,{children:`Task "${i}" is running its own server on :${n.port}. Register a different port for this task, or stop that task's server.`}),(0,Y.jsx)(Q,{children:(0,Y.jsx)(r,{variant:`contrast`,onClick:t.close,children:`Close preview`})})]})}function $e({state:e,actions:t}){let{server:n}=e,i=Xe(1e3),a=Math.max(0,Math.floor((i-Date.parse(e.startedAt))/1e3)),[o,s]=(0,J.useState)(()=>Date.now());(0,J.useEffect)(()=>s(Date.now()),[e.attempt]);let c=Math.max(0,Math.ceil(Ye-(i-o)/1e3));return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(_,{}),title:`Starting ${n.label}`,children:[(0,Y.jsx)(Z,{children:`Squawk ran ${M(n.command)} in the worktree. The page opens as soon as :${n.port} answers.`}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border px-3.5 py-3 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-2.5 font-semibold text-foreground`,children:[(0,Y.jsx)(g,{className:`size-4 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}),c>0?`Attempt ${e.attempt} · next try in ${c} s`:`Attempt ${e.attempt}`]}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`started ${a} s ago`})]}),e.logTail.length>0?(0,Y.jsx)(Ne,{text:e.logTail.join(`
3
+ `),source:M(n.command),onCopy:t.copy}):null,(0,Y.jsx)(Q,{children:(0,Y.jsx)(r,{variant:`outline`,onClick:()=>t.stop(n.port),children:`Stop server`})})]})}function et({state:e,actions:t}){let{server:n}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(m,{className:`text-pending-strong`}),title:`${n.label} is running, but :${n.port} is silent`,children:[(0,Y.jsx)(Z,{children:`The process has run for 2 min without opening the port. It may be waiting on another service, or listening somewhere else.`}),(0,Y.jsx)(Ne,{text:e.logTail,source:M(n.command),onCopy:t.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsx)(r,{variant:`contrast`,onClick:()=>t.keepWaiting(n.port),children:`Keep waiting`}),(0,Y.jsx)(r,{variant:`outline`,onClick:()=>t.stop(n.port),children:`Stop server`})]})]})}function tt({state:e,actions:t}){let{server:n}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(f,{className:`text-danger`}),title:e.exitCode===null?`${n.label} was stopped by a signal`:`${n.label} exited with code ${e.exitCode}`,children:[(0,Y.jsx)(Z,{children:`${M(n.command)} stopped.`}),(0,Y.jsx)(Ne,{text:e.logTail,source:M(n.command),onCopy:t.copy}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(r,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(Be,{server:n})]})}function nt({state:e,actions:t}){let{server:n}=e,i=e.reason===`idle`;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(_e,{}),title:i?`Stopped after 15 min idle`:`${n.label} stopped`,children:[(0,Y.jsx)(Z,{children:i?`Nobody had this pane open for 15 min, so Squawk stopped ${n.label} :${n.port} and the browser to free memory. Start again reopens ${Le(e.lastUrl)}.`:`You stopped ${n.label} :${n.port}. Start again reopens ${Le(e.lastUrl)}.`}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(r,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(Be,{server:n})]})}var rt=[`browser`,`page`,`frame`];function it({step:e,url:t}){let n=rt.indexOf(e),r=t?Le(t):`the page`;return(0,Y.jsx)(`div`,{"data-slot":`preview-state`,"data-state":`loading`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center px-6 py-8`,children:(0,Y.jsx)(`ol`,{"aria-label":`Opening the page`,className:`mx-auto flex flex-col gap-4 text-sm`,children:[{done:`Browser started`,active:`Starting the browser`},{done:`Opened ${r}`,active:`Opening ${r}`},{done:`First frame`,active:`First frame`}].map((e,t)=>{let r=t<n,a=t===n;return(0,Y.jsxs)(`li`,{"aria-current":a?`step`:void 0,className:i(`flex items-center gap-3`,a?`font-semibold text-foreground`:r?`text-foreground`:`text-soft-foreground`),children:[r?(0,Y.jsx)(p,{className:`size-5 text-success`,"aria-hidden":`true`}):a?(0,Y.jsx)(g,{className:`size-5 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}):(0,Y.jsx)(L,{className:`size-5 text-border`,"aria-hidden":`true`}),r?e.done:a?e.active:e.done]},t)})})})}function at({state:e,actions:t,worktree:n}){let i=n?/\.ai\/(?:cezar|squawk)\/worktrees\/[^/]+/.exec(n)?.[0]:void 0,a=e.server?.label;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(B,{}),title:`This task's worktree is gone`,children:[(0,Y.jsx)(Z,{children:`${a??`The server`} ran in ${i??`this task's worktree`}, which has been removed. There is nothing left to start.`}),e.server?(0,Y.jsx)(y,{entry:{kind:`preview-server`,id:`preview-server:${e.server.port}`,server:e.server,state:`unavailable`},inPreview:!1}):null,(0,Y.jsx)(Q,{children:(0,Y.jsx)(r,{variant:`outline`,onClick:t.close,children:`Close preview`})})]})}function ot({actions:e}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":`proxy-blocked`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`div`,{children:(0,Y.jsx)(Me,{})}),(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:(0,Y.jsx)(W,{})}),(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Preview doesn't work behind this proxy yet`}),(0,Y.jsx)(Z,{children:`The proxy in front of Squawk didn't let the preview's WebSocket through. This is a known gap behind Basic Auth. Everything else in Squawk keeps working.`}),(0,Y.jsxs)(Q,{children:[(0,Y.jsx)(r,{variant:`outline`,onClick:e.close,children:`Close preview`}),(0,Y.jsx)(`a`,{className:`inline-flex min-h-11 items-center text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:Re,target:`_blank`,rel:`noopener noreferrer`,children:`Which setups work`})]})]})}function st(e){let t=/iPhone/.test(e)?`iPhone`:/iPad/.test(e)?`iPad`:/Android/.test(e)?`Android`:/Windows/.test(e)?`Windows`:/Mac OS X|Macintosh/.test(e)?`Mac`:/Linux|X11/.test(e)?`Linux`:``,n=/Edg\//.test(e)?`Edge`:/Firefox\/|FxiOS/.test(e)?`Firefox`:/Chrome\/|CriOS/.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:``;return n&&t?`${n} on ${t}`:n||t}function ct({state:e,actions:t}){let n=st(e.by);return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(U,{}),title:`Preview is open somewhere else`,children:[(0,Y.jsx)(Z,{children:`Another tab took this browser${n?` (${n})`:``}. Only one tab can view and drive it at a time.`}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(r,{variant:`contrast`,onClick:t.useHere,children:[(0,Y.jsx)(R,{"aria-hidden":`true`}),`Use it here`]}),(0,Y.jsx)(r,{variant:`outline`,onClick:t.close,children:`Close preview`})]})]})}function lt({attempt:e,exhausted:t,onReconnect:n}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-connection-banner`,role:`status`,className:`absolute inset-x-3 top-3 z-10 flex flex-wrap items-center justify-between gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-3.5 py-2.5 text-sm shadow-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,Y.jsx)(De,{className:`size-4 shrink-0 text-danger`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{className:`font-semibold text-foreground`,children:`Lost the connection to the host`}),t?null:(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` · reconnecting (attempt ${e} of 5)`})]})]}),(0,Y.jsx)(r,{variant:`outline`,onClick:n,children:t?`Reconnect`:`Reconnect now`})]})}function ut({servers:e,states:t,onOpen:n,agentLive:i=!1,agentIdle:a=!1,onOpenAgent:o}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":a?`agent-idle`:`empty`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Open a page in this task's browser`}),(0,Y.jsx)(Z,{children:`The browser runs on the host, next to the worktree. Type a URL, a bare port such as 3000, or open a server the agent registered.`}),a?(0,Y.jsxs)(`p`,{role:`status`,className:`flex items-start gap-2 text-sm text-foreground`,children:[(0,Y.jsx)(Ee,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`The agent is not driving the browser now.`})]}):null,i&&o!==void 0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-agent`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.jsx)(`h3`,{id:`preview-agent`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Driven by the agent`}),(0,Y.jsxs)(`div`,{"data-slot":`preview-agent-entry`,className:`flex items-center justify-between gap-3 px-3.5 py-2 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,Y.jsx)(j,{tone:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`The agent drives this page through agent-browser.`})]}),(0,Y.jsx)(r,{variant:`outline`,size:`sm`,className:`max-md:h-11`,"aria-label":`Open the agent's page`,onClick:o,children:`Open`})]})]}):null,e.length>0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-registered`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.jsx)(`h3`,{id:`preview-registered`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Registered in this task`}),(0,Y.jsx)(`ul`,{children:e.map(e=>{let i=me(e,t),a=ce(i);return(0,Y.jsxs)(`li`,{className:`flex items-center justify-between gap-3 border-b border-border px-3.5 py-2 text-sm last:border-b-0`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,Y.jsx)(j,{tone:a.tone,shape:a.ring?`ring`:`filled`,pulse:a.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:a.text})]}),(0,Y.jsx)(r,{variant:`outline`,size:`sm`,className:`max-md:h-11`,onClick:()=>n(e.port),children:fe(i)?`Open`:`Review`})]},e.port)})})]}):null,(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(h,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`Review opens a server's approval in this pane: its command, cwd and Run and open. Nothing runs from this list. Paste works; copying text out, file pickers and downloads don't yet.`})]})]})}function dt({dialog:e,onResult:t}){let[n,i]=(0,J.useState)(e.defaultPrompt??``),a=e.type===`beforeunload`,o=(0,J.useRef)(null),s=(0,J.useRef)(null);(0,J.useEffect)(()=>{(e.type===`prompt`?s.current:o.current)?.focus()},[e.type]);let c=(0,J.useRef)(t);c.current=t,(0,J.useEffect)(()=>{let e=e=>{if(e.key!==`Escape`||e.defaultPrevented)return;let t=e.target instanceof Element?e.target:null;t&&t!==document.body&&!t.closest(`[data-slot="preview-pane-body"], [data-slot="preview-page-dialog"]`)||(e.stopPropagation(),c.current({accept:!1}))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let l=()=>t(e.type===`prompt`?{accept:!0,text:n}:{accept:!0});return(0,Y.jsx)(`div`,{"data-slot":`preview-page-dialog`,className:`absolute inset-0 z-20 flex items-center justify-center bg-foreground/30 p-4`,children:(0,Y.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":`${e.origin} says`,className:`w-full max-w-[380px] rounded-xl border border-border bg-card p-4 shadow-lg`,children:[(0,Y.jsx)(`p`,{className:`mb-3 truncate font-mono text-xs text-muted-foreground`,children:`${e.origin} says`}),(0,Y.jsx)(`p`,{className:`mb-4 text-sm break-words whitespace-pre-wrap text-foreground`,children:e.message||(a?`Changes you made may not be saved.`:``)}),e.type===`prompt`?(0,Y.jsx)(`input`,{ref:s,value:n,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&l()},className:`mb-4 h-11 w-full rounded-md border border-border bg-background px-3 text-sm outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}):null,(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[e.type===`alert`?null:(0,Y.jsx)(r,{variant:`outline`,onClick:()=>t({accept:!1}),children:a?`Stay`:`Cancel`}),(0,Y.jsx)(r,{ref:o,variant:`contrast`,onClick:l,children:a?`Leave`:`OK`})]})]})})}var ft=10,pt=500,mt=500,ht=4,gt=16,_t=e=>!!e.altKey|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0);function vt(e,t,n,r){return{x:Math.round((e-n.left)/r),y:Math.round((t-n.top)/r)}}function yt(e,t){return{rect:e,scale:t,touches:new Map,multiTouch:!1,click:{at:-1/0,x:0,y:0,button:-1,count:1}}}var bt=[`left`,`middle`,`right`];function $(e,t,n,r){let i=vt(n.clientX,n.clientY,t.rect,t.scale);return{t:`mouse`,type:e,x:i.x,y:i.y,button:bt[n.button]??`none`,buttons:n.buttons,clickCount:1,modifiers:_t(n),...r}}var xt=e=>e===0?0:-e;function St(e,t,n,r,i){let a=vt(t,n,e.rect,e.scale);return{t:`mouse`,type:`mouseWheel`,x:a.x,y:a.y,button:`none`,buttons:0,deltaX:xt(r/e.scale),deltaY:xt(i/e.scale),modifiers:0}}function Ct(e,t){let{touches:n}=t,r=n.get(e.pointerId),i=()=>{n.delete(e.pointerId),n.size===0&&(t.multiTouch=!1)};switch(e.type){case`pointerdown`:return n.set(e.pointerId,{startX:e.clientX,startY:e.clientY,startAt:e.timeStamp,lastX:e.clientX,lastY:e.clientY,scrolling:!1}),n.size>1&&(t.multiTouch=!0),[];case`pointermove`:{if(!r)return[];if(t.multiTouch)return r.lastX=e.clientX,r.lastY=e.clientY,[];if(!r.scrolling){if(Math.hypot(e.clientX-r.startX,e.clientY-r.startY)<=ft)return[];r.scrolling=!0}let n=e.clientX-r.lastX,i=e.clientY-r.lastY;return r.lastX=e.clientX,r.lastY=e.clientY,n===0&&i===0?[]:[St(t,e.clientX,e.clientY,n,i)]}case`pointerup`:{let n=r!==void 0&&!t.multiTouch&&!r.scrolling&&e.timeStamp-r.startAt<=pt;if(i(),!n||!r)return[];let a={...e,clientX:r.startX,clientY:r.startY};return[$(`mouseMoved`,t,a,{button:`none`,buttons:0}),$(`mousePressed`,t,a,{button:`left`,buttons:1}),$(`mouseReleased`,t,a,{button:`left`,buttons:0})]}case`pointercancel`:return i(),[]}}function wt(e,t){if(e.pointerType===`touch`)return Ct(e,t);switch(e.type){case`pointerdown`:{let n=t.click,r=n.button===e.button&&e.timeStamp-n.at<=mt&&Math.hypot(e.clientX-n.x,e.clientY-n.y)<=ht;return t.click={at:e.timeStamp,x:e.clientX,y:e.clientY,button:e.button,count:r?n.count+1:1},[$(`mousePressed`,t,e,{clickCount:t.click.count})]}case`pointermove`:return[$(`mouseMoved`,t,e,{button:e.buttons&1?`left`:`none`})];case`pointerup`:return[$(`mouseReleased`,t,e,{clickCount:t.click.count})];case`pointercancel`:return[]}}function Tt(e,t,n){let r=vt(e.clientX,e.clientY,t,n),i=e.deltaMode===1?gt:1;return{t:`mouse`,type:`mouseWheel`,x:r.x,y:r.y,button:`none`,buttons:e.buttons??0,deltaX:e.deltaX*i/n,deltaY:e.deltaY*i/n,modifiers:_t(e)}}var Et={a:`selectAll`,c:`copy`,x:`cut`,z:`undo`,y:`redo`};function Dt(e){let t=e.key.toLowerCase(),n=(e.ctrlKey||e.metaKey)&&!e.getModifierState?.(`AltGraph`);if(n&&(t===`v`||t===`k`))return;let r={t:`key`,key:e.key,code:e.code,modifiers:_t(e),vk:e.keyCode};if(e.type===`keyup`)return{...r,type:`keyUp`};let i=n?``:e.key.length===1?e.key:e.key===`Enter`?`\r`:e.key===`Tab`?` `:``,a=n?t===`z`&&e.shiftKey?`redo`:Et[t]:void 0,o={t:`key`,type:i?`keyDown`:`rawKeyDown`,key:e.key,code:e.code,text:i,modifiers:_t(e),vk:e.keyCode};return a?{...o,commands:[a]}:o}function Ot(e){return e?{t:`insertText`,text:e}:void 0}var kt=e=>e,At=e=>e.key===`Escape`&&e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey;function jt({scale:e,send:t,onLeave:n}){let r=(0,J.useRef)(null),i=(0,J.useRef)(yt({left:0,top:0},e)),a=(0,J.useRef)(e);a.current=e;let o=(0,J.useRef)(t);o.current=t;let s=(0,J.useRef)(void 0),c=()=>{let e=r.current;e&&(i.current.rect=e.getBoundingClientRect()),i.current.scale=a.current},l=e=>{c();for(let t of wt(kt(e),i.current))o.current(t)},u=()=>{let e=s.current;e&&(s.current=void 0,cancelAnimationFrame(e.frame),l(e.event))};(0,J.useEffect)(()=>()=>{s.current&&cancelAnimationFrame(s.current.frame)},[]),(0,J.useEffect)(()=>{document.activeElement===document.body&&r.current?.focus({preventScroll:!0})},[]),(0,J.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{e.preventDefault(),c(),o.current(Tt(e,i.current.rect,i.current.scale))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,J.useEffect)(()=>{let e=e=>{if(document.activeElement!==r.current)return;let t=Ot(e.clipboardData?.getData(`text`)??``);t&&(e.preventDefault(),o.current(t))};return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)},[]);let d=e=>{u(),r.current?.focus({preventScroll:!0});try{r.current?.setPointerCapture(e.pointerId)}catch{}l(e.nativeEvent)},f=e=>{let t=e.nativeEvent;if(t.pointerType===`touch`)return l(t);let n=s.current;if(n){n.event=t;return}s.current={event:t,frame:requestAnimationFrame(()=>{let e=s.current;s.current=void 0,e&&l(e.event)})}},p=e=>{u(),l(e.nativeEvent)},m=e=>{if(At(e)){e.preventDefault(),e.stopPropagation(),e.type===`keydown`&&(n?n():r.current?.blur());return}let i=Dt(e.nativeEvent);i&&(e.preventDefault(),e.stopPropagation(),t(i))};return(0,Y.jsx)(`div`,{ref:r,"data-slot":`preview-input`,role:`application`,"aria-label":`Page preview, interactive`,"aria-description":`Keys go to the page, Tab included. Press Shift+Escape to return to the cockpit.`,tabIndex:0,onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onContextMenu:e=>e.preventDefault(),onKeyDown:m,onKeyUp:m,className:`absolute inset-0 touch-none select-none outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-inset`})}async function Mt(e){if(typeof createImageBitmap==`function`){let t=await createImageBitmap(e);return{source:t,width:t.width,height:t.height,release:()=>t.close()}}let t=URL.createObjectURL(e),n=new Image;return n.src=t,await n.decode(),{source:n,width:n.naturalWidth,height:n.naturalHeight,release:()=>URL.revokeObjectURL(t)}}function Nt({ref:e,viewport:t,dimmed:n=!1,cursor:r,onSize:o,renderInput:s,children:c}){let l=(0,J.useRef)(0),u=(0,J.useRef)(null),d=(0,J.useRef)(null),[f,p]=(0,J.useState)(null),m=(0,J.useRef)(o);m.current=o,(0,J.useImperativeHandle)(e,()=>({async draw(e){let t=++l.current,n=d.current,r=n?.getContext(`2d`);if(!(!n||!r||!a()))try{let i=await Mt(e);try{if(t!==l.current||!a()||d.current!==n)return;n.width!==i.width&&(n.width=i.width),n.height!==i.height&&(n.height=i.height),r.drawImage(i.source,0,0)}finally{i.release()}}catch{}}}),[]),(0,J.useEffect)(()=>{let e=u.current;if(!e)return;let t=()=>{let t=Math.round(e.clientWidth),n=Math.round(e.clientHeight);t===0||n===0||(p(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n}),m.current?.({w:t,h:n}))};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let h=t===`fit`?f:t,g=t===`fit`||!f?1:Math.min(1,(f.w-24)/t.w,(f.h-24)/t.h),_=h?{width:Math.floor(h.w*g),height:Math.floor(h.h*g)}:void 0;return(0,Y.jsxs)(`div`,{ref:u,"data-slot":`preview-stage`,"data-viewport":t===`fit`?`fit`:`${t.w}x${t.h}`,className:i(`relative min-h-0 flex-1 overflow-hidden bg-muted`,t!==`fit`&&`flex items-start justify-center overflow-auto p-3`),children:[h?(0,Y.jsxs)(`div`,{"data-slot":`preview-surface`,"data-scale":g,style:{..._,cursor:r},className:i(`relative shrink-0 bg-card`,t!==`fit`&&`shadow-md`,n&&`opacity-60 saturate-50`),children:[(0,Y.jsx)(`canvas`,{ref:d,"aria-label":`Page preview`,role:`img`,style:_,className:`block touch-none select-none`}),s?.({canvas:d.current,scale:g,viewport:h})]}):null,c]})}var Pt=`cez-preview-quality`,Ft=[{value:`normal`,label:`Normal`,detail:`The default. Lighter on CPU and network.`},{value:`high`,label:`High`,detail:`Sharper text and fine detail. Uses more CPU and network.`},{value:`ultra`,label:`Ultra`,detail:`High at your screen's pixel density, up to 2×. Uses the most CPU and network.`}];function It(e){return Ft.find(t=>t.value===e)?.value??`normal`}var Lt=e=>Ft.find(t=>t.value===e)?.label??`Normal`;function Rt(){try{return It(localStorage.getItem(Pt))}catch{return`normal`}}function zt(e){try{localStorage.setItem(Pt,e)}catch{}}var Bt=[{w:390,h:844,icon:ue},{w:820,h:1180,icon:we},{w:1440,h:900,icon:ae}],Vt=`size-8 shrink-0 max-md:size-11`,Ht=e=>e===`fit`?`Fit`:`${e.w} × ${e.h}`;function Ut(e){let[t,n]=(0,J.useState)(()=>Date.now());return(0,J.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var Wt=e=>`${e.fps} fps · ${e.kbps} KB/s${e.rttMs===void 0?``:` · ${e.rttMs} ms`}`;function Gt({stats:e,shrunk:t}){let n=Ut(250),r=e.lastFrameAt===void 0||n-e.lastFrameAt>=1e3;return t?(0,Y.jsx)(j,{"data-slot":`preview-stats`,tone:r?`neutral`:`success`,"aria-label":`Preview is live`,role:`img`}):(0,Y.jsxs)(`span`,{"data-slot":`preview-stats`,role:`img`,"aria-label":r?`idle`:Wt(e),className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(j,{tone:r?`neutral`:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[640px]:inline-block w-[28ch] overflow-hidden text-ellipsis`,children:r?`idle`:Wt(e)})]})}function Kt({current:e,agentShown:t,...n}){let i=e?e.label:t?`Agent's page`:`Server`;return(0,Y.jsxs)(r,{variant:`outline`,size:`sm`,className:`max-w-[11rem] min-w-0 gap-1.5 max-md:h-11`,"aria-label":e?`Server: ${e.label} :${e.port}`:t?`Server: ${i}`:`Server`,...n,children:[e||t?(0,Y.jsx)(j,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}):(0,Y.jsx)(x,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:i}),e?(0,Y.jsxs)(`span`,{className:`font-mono font-normal text-muted-foreground`,children:[`:`,e.port]}):null,(0,Y.jsx)(le,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}function qt({shown:e,live:t,onSelect:n}){return(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":e||void 0,onSelect:n,children:[(0,Y.jsx)(j,{tone:t?`success`:`neutral`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`agent-browser`}),e?(0,Y.jsx)(F,{className:`size-4`,"aria-hidden":`true`}):null]})}function Jt(e,t){return e?`${e.label} :${e.port}`:t?`Agent's page`:`Preview`}function Yt(e){let t=e.onPickAgent!==void 0,n=e.agentLive===!0&&t,r=e.agentShown===!0;return{agentLive:n,agentShown:r,agentListed:n||r&&t}}function Xt(e){let{compact:t=!1,navEnabled:n,loading:i=!1}=e,a=(0,J.useRef)(null),o=e.urlInputRef??a,s=(0,J.useRef)(!1),[c,l]=(0,J.useState)(null),[u,f]=(0,J.useState)(!1),p=(0,Y.jsx)(r,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Back`,disabled:!n,onClick:e.onBack,children:(0,Y.jsx)(be,{"aria-hidden":`true`})}),m=(0,Y.jsx)(r,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Forward`,disabled:!n,onClick:e.onForward,children:(0,Y.jsx)(d,{"aria-hidden":`true`})}),h=(0,Y.jsx)(r,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Reload`,"aria-busy":i||void 0,disabled:!n||i,onClick:()=>e.onReload(!1),children:(0,Y.jsx)(K,{"aria-hidden":`true`})}),g=e.onSession?(0,Y.jsxs)(r,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1 max-md:h-11`,onClick:e.onSession,children:[(0,Y.jsx)(re,{"aria-hidden":`true`}),`Session`]}):null,_=i?(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":`Loading the page`,className:`absolute inset-x-0 bottom-0 h-0.5 overflow-hidden bg-transparent`,children:(0,Y.jsx)(`div`,{className:`preview-progress h-full w-2/5 bg-success`})}):null,v=(0,Y.jsx)(Qt,{props:e,input:o,draft:c,setDraft:l,focused:u,setFocused:f}),{agentListed:y}=Yt(e),b=e.servers.length+ +!!y>=2,x=b||e.adopted,S={back:p,forward:m,reload:h,address:v,more:(0,Y.jsx)(rn,{props:e,compact:t,crowded:x}),session:g,progress:_};return t?(0,Y.jsx)(an,{props:e,elements:S}):(0,Y.jsx)(on,{props:e,elements:S,switcher:b,crowded:x,input:o,focusUrlAfterMenu:s})}function Zt({props:e,input:t,focusUrlAfterMenu:n}){let{servers:r,current:i}=e,{agentLive:a,agentShown:o,agentListed:s}=Yt(e);return(0,Y.jsxs)(O,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsx)(Kt,{current:i,agentShown:o})}),(0,Y.jsxs)(D,{align:`start`,className:`min-w-64`,onCloseAutoFocus:e=>{n.current&&(n.current=!1,e.preventDefault(),t.current?.focus())},children:[s?(0,Y.jsx)(qt,{shown:o,live:a,onSelect:()=>e.onPickAgent?.()}):null,r.map(t=>{let n=ce(me(t,e.serverStates));return(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":i?.port===t.port||void 0,onSelect:()=>e.onPickServer(t.port),children:[(0,Y.jsx)(j,{tone:n.tone,shape:n.ring?`ring`:`filled`,pulse:n.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:t.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,t.port]}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:n.text}),i?.port===t.port?(0,Y.jsx)(F,{className:`size-4`,"aria-hidden":`true`}):null]},t.port)}),(0,Y.jsx)(T,{}),(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>{n.current=!0},children:[(0,Y.jsx)(P,{"aria-hidden":`true`}),`Type a URL instead`]})]})]})}function Qt({props:e,input:t,draft:n,setDraft:r,focused:a,setFocused:o}){let{url:s,adopted:c}=e;return(0,Y.jsxs)(`div`,{className:`relative flex min-w-[9rem] flex-1 items-center`,children:[(0,Y.jsx)(P,{className:`pointer-events-none absolute left-2.5 size-4 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`input`,{ref:t,type:`text`,"aria-label":`Page address`,placeholder:`Type a URL or a port`,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,value:n??(a?s:Le(s)),title:s||void 0,className:i(`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-muted pl-8 font-mono text-[13px] text-foreground outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:bg-background focus-visible:ring-[3px] focus-visible:ring-ring/30 max-md:h-11`,c?`pr-40`:`pr-2.5`),onFocus:e=>{let t=e.currentTarget;o(!0),requestAnimationFrame(()=>{document.activeElement===t&&t.select()})},onBlur:()=>{o(!1),r(null)},onChange:e=>r(e.target.value),onKeyDown:t=>{t.key===`Enter`?(e.onNavigate(n??s),t.currentTarget.blur()):t.key===`Escape`&&t.currentTarget.blur()}}),c&&!a?(0,Y.jsxs)(`span`,{className:`pointer-events-none absolute right-2 inline-flex h-6 items-center gap-1 rounded-full border border-border bg-card px-2 text-xs font-semibold text-muted-foreground`,children:[(0,Y.jsx)(Se,{className:`size-3`,"aria-hidden":`true`}),`Not started by Squawk`]}):null]})}function $t({props:e}){let{viewport:t}=e;return(0,Y.jsxs)(O,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsxs)(r,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Viewport size: ${Ht(t)}`,children:[t===`fit`?(0,Y.jsx)(H,{"aria-hidden":`true`}):(0,Y.jsx)(ae,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:i(`hidden @min-[500px]:inline`,t!==`fit`&&`font-mono font-normal`),children:Ht(t)}),(0,Y.jsx)(le,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(D,{align:`start`,className:`min-w-56`,children:[(0,Y.jsxs)(w,{className:`gap-2.5`,"aria-current":t===`fit`||void 0,onSelect:()=>e.onViewport(`fit`),children:[(0,Y.jsx)(H,{"aria-hidden":`true`}),`Fit`,(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`pane size`}),t===`fit`?(0,Y.jsx)(F,{className:`size-4`,"aria-hidden":`true`}):null]}),Bt.map(({w:n,h:r,icon:i})=>(0,Y.jsxs)(w,{className:`gap-2.5 font-mono`,"aria-current":t!==`fit`&&t.w===n&&t.h===r||void 0,onSelect:()=>e.onViewport({w:n,h:r}),children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),n,` × `,r,t!==`fit`&&t.w===n&&t.h===r?(0,Y.jsx)(F,{className:`ml-auto size-4`,"aria-hidden":`true`}):null]},`${n}x${r}`))]})]})}function en({quality:e,onQuality:t,compact:n}){return(0,Y.jsx)(ee,{value:e,onValueChange:e=>t(It(e)),children:Ft.map(e=>(0,Y.jsx)(C,{value:e.value,"data-quality":e.value,className:i(`items-start`,n&&`min-h-11`),children:(0,Y.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{children:e.label}),(0,Y.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:e.detail})]})},e.value))})}function tn({props:e}){let{quality:t}=e;return(0,Y.jsxs)(O,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsxs)(r,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Stream quality: ${Lt(t)}`,children:[(0,Y.jsx)(V,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[560px]:inline`,children:Lt(t)}),(0,Y.jsx)(le,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(D,{align:`start`,className:`w-64`,children:[(0,Y.jsx)(S,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(en,{quality:t,onQuality:e.onQuality,compact:!1})]})]})}function nn({stats:e,status:t,crowded:n}){return e?(0,Y.jsx)(Gt,{stats:e,shrunk:n}):t?(0,Y.jsxs)(`span`,{"data-slot":`preview-status`,className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(j,{tone:t.tone,"aria-hidden":`true`}),t.label]}):null}function rn({props:e,compact:t,crowded:n}){let{stats:i,navEnabled:a,url:o,current:s,adopted:c}=e;return(0,Y.jsxs)(O,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsx)(r,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`More`,children:(0,Y.jsx)(he,{"aria-hidden":`true`})})}),(0,Y.jsxs)(D,{align:`end`,className:`min-w-64`,children:[n&&i&&!t?(0,Y.jsx)(S,{className:`font-mono text-xs font-normal text-muted-foreground`,children:Wt(i)}):null,(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:!a,onSelect:()=>e.onReload(!0),children:[(0,Y.jsx)(G,{"aria-hidden":`true`}),`Reload without cache`]}),(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:o===``,onSelect:e.onCopyUrl,children:[(0,Y.jsx)(de,{"aria-hidden":`true`}),`Copy page URL`]}),s?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(T,{}),c?(0,Y.jsxs)(w,{disabled:!0,className:`items-start gap-2.5 opacity-100 data-[disabled]:opacity-100`,children:[(0,Y.jsx)(Ce,{className:`mt-0.5 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`Stop server · ${s.label} :${s.port}`}),(0,Y.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:`Squawk didn't start this server, so it won't stop it. Stop it where it was started.`})]})]}):(0,Y.jsxs)(w,{variant:`destructive`,className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>e.onStop(s.port),children:[(0,Y.jsx)(xe,{"aria-hidden":`true`}),`Stop server · ${s.label} :${s.port}`]})]}):null,t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(T,{}),(0,Y.jsx)(S,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(en,{quality:e.quality,onQuality:e.onQuality,compact:!0}),(0,Y.jsx)(T,{}),(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5`,onSelect:e.onClose,children:[(0,Y.jsx)(pe,{"aria-hidden":`true`}),`Close preview`]})]}):null]})]})}function an({props:e,elements:t}){let{stats:n,current:r,badge:i=!0}=e,{agentShown:a}=Yt(e),{back:o,forward:s,reload:c,address:l,more:u,session:d,progress:f}=t;return(0,Y.jsxs)(`div`,{"data-slot":`preview-toolbar`,"data-compact":``,className:`relative flex shrink-0 flex-col border-b border-border bg-background`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-2 pt-[max(0.25rem,env(safe-area-inset-top))]`,children:[d,(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col items-center leading-tight`,children:[(0,Y.jsxs)(`span`,{className:`flex max-w-full items-center gap-1.5 text-sm font-semibold text-foreground`,children:[n?(0,Y.jsx)(j,{tone:`success`,"aria-hidden":`true`}):null,(0,Y.jsx)(`span`,{className:`truncate`,children:Jt(r,a)})]}),i?(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Experimental`}):null]}),u]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1`,children:[o,s,c,l]}),f]})}function on({props:e,elements:t,switcher:n,crowded:i,input:a,focusUrlAfterMenu:o}){let{badge:s=!0,stats:c,status:l}=e,{back:u,forward:d,reload:f,address:p,more:m,session:h,progress:g}=t;return(0,Y.jsxs)(`div`,{"data-slot":`preview-toolbar`,className:`@container relative flex shrink-0 items-center gap-1.5 border-b border-border bg-background px-2.5 py-2`,children:[h,u,d,f,n?(0,Y.jsx)(Zt,{props:e,input:a,focusUrlAfterMenu:o}):null,p,(0,Y.jsx)($t,{props:e}),(0,Y.jsx)(tn,{props:e}),(0,Y.jsx)(nn,{stats:c,status:l,crowded:i}),s?(0,Y.jsx)(Me,{iconOnly:i,responsive:!i}):null,(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-5 w-px shrink-0 bg-border`}),m,(0,Y.jsx)(r,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Close preview`,onClick:e.onClose,children:(0,Y.jsx)(pe,{"aria-hidden":`true`})}),g]})}function sn({transport:e,takenOver:t,empty:n,stage:r,hasFrame:i,lost:a,url:o,worktree:s}){let c=a||e!==`blocked`&&t!==void 0;return e===`blocked`?{content:{kind:`state`,state:{stage:`proxy-blocked`}},dim:c}:t===void 0?n||r?.stage===`agent-idle`?{content:{kind:`empty`,agentIdle:!n&&r?.stage===`agent-idle`},dim:c}:r?.stage===`streaming`||r?.stage===`loading`&&i?{content:{kind:`none`},dim:c}:r?{content:{kind:`state`,state:r,url:o,worktree:s},dim:c}:a?{content:{kind:`none`},dim:c}:{content:{kind:`state`,state:{t:`state`,stage:`loading`,step:`browser`},url:o},dim:c}:{content:{kind:`state`,state:{stage:`taken-over`,by:t}},dim:c}}function cn(e,{servers:t,serverStates:n,agentLive:r,openServer:i,openAgent:a,actions:o}){switch(e.kind){case`none`:return null;case`state`:{let{kind:t,...n}=e;return(0,Y.jsx)(ze,{...n,actions:o})}case`empty`:return(0,Y.jsx)(ut,{servers:t,states:n,onOpen:e=>i(e),agentLive:r===!0,agentIdle:e.agentIdle,onOpenAgent:a})}}function ln(){let e=typeof window>`u`?void 0:window.devicePixelRatio;return typeof e==`number`&&e>0?e:1}function un(){let[e,t]=(0,J.useState)(ln);return(0,J.useEffect)(()=>{let n=window.matchMedia?.(`(resolution: ${e}dppx)`);if(!n)return;let r=()=>t(ln());return n.addEventListener(`change`,r),()=>n.removeEventListener(`change`,r)},[e]),e}var dn=2e3,fn=500,pn=1e3;function mn(e,t){switch(e.stage){case`needs-approval`:case`port-held`:case`server-starting`:case`server-stalled`:case`server-exited`:case`server-stopped`:return e.server.port===t;case`loading`:case`streaming`:return!0;default:return!1}}function hn(e){navigator.clipboard?.writeText(e).then(()=>l(`Copied`),()=>l(`Couldn't copy to the clipboard`,{tone:`danger`}))}var gn=e=>`http://localhost:${e.port}${e.path&&e.path!==`/`?e.path:``}`;function _n(e,t){return e?.port===void 0?e?.agent===!0||e?.url!==void 0:e.restored!==!0||t.some(t=>t.port===e.port)}function vn(e){return`port`in e?{port:e.port}:`agent`in e?{agent:!0}:{url:e.url}}function yn({run:e,servers:t,request:n,onTarget:r,onLive:i,onClose:o}){let s=un(),l=(0,J.useRef)(s);l.current=s;let u=c(),d=(0,J.useRef)(crypto.randomUUID()),f=(0,J.useRef)(!1),p=te(),m=ie(ye,!1),[h,g]=(0,J.useState)(0),[_,v]=(0,J.useState)({state:`connecting`,attempt:0}),[y,b]=(0,J.useState)(!1),[x,S]=(0,J.useState)(void 0),[C,w]=(0,J.useState)(void 0),[T,E]=(0,J.useState)(``),[D,ee]=(0,J.useState)(void 0),[O,ne]=(0,J.useState)(!1),[k,A]=(0,J.useState)(void 0),[j,re]=(0,J.useState)(!1),[ae,oe]=(0,J.useState)(!1),[se,ce]=(0,J.useState)(void 0),[le,M]=(0,J.useState)(void 0),[ue,de]=(0,J.useState)(void 0),[fe,N]=(0,J.useState)(`fit`),[pe,me]=(0,J.useState)(Rt),[he,ge]=(0,J.useState)(null),[_e,P]=(0,J.useState)(void 0),[F,ve]=(0,J.useState)(0),I=(0,J.useRef)(void 0),be=(0,J.useRef)(null),xe=(0,J.useRef)(null),L=(0,J.useRef)(void 0),R=(0,J.useRef)(void 0),z=(0,J.useRef)(pe);z.current=pe;let B=(0,J.useRef)({port:D,stage:C,agent:O});B.current={port:D,stage:C,agent:O};let V=(0,J.useRef)([]),Se=(0,J.useRef)(void 0),Ce=(0,J.useRef)(!1),H=(0,J.useRef)(!1),U=(0,J.useCallback)(e=>{H.current&&I.current?.send(e)},[]);(0,J.useEffect)(()=>{let t;return t=je({projectId:p??`default`,runId:e.id},{onFrame(e){if(!a())return;let n=Date.now();V.current.push({at:n,bytes:e.size}),Ce.current||(Ce.current=!0,oe(!0)),(be.current?.draw(e)??Promise.resolve()).finally(()=>t?.send({t:`ack`}))},onMessage(e){switch(e.t){case`state`:if(w(e),(e.stage===`streaming`||e.stage===`loading`)&&ve(e=>e+1),R.current!==void 0&&mn(e,R.current)){let n=R.current;R.current=void 0,(e.stage===`needs-approval`||e.stage===`server-exited`||e.stage===`server-stopped`)&&t?.send({t:`run`,port:n})}return;case`url`:return E(e.url);case`cursor`:return ce(e.cursor);case`dialog`:return M(e);case`pong`:Se.current=Math.max(0,Date.now()-e.ts);return;case`downloadProgress`:w(t=>t?.stage===`downloading`?{...t,received:e.received,total:e.total}:t);return;case`replaced`:S(e.by),H.current=!1,t?.close();return}},onTransport(e,n){H.current=e===`open`,v({state:e,attempt:n??0}),e===`open`&&(b(!0),L.current&&(t?.send({t:`open`,target:L.current,viewerId:d.current,resume:f.current,quality:z.current,dpr:l.current}),f.current=!0))}}),I.current=t,()=>{H.current=!1,t?.close(),I.current===t&&(I.current=void 0)}},[p,e.id,h]);let W=u&&_.state===`open`&&x===void 0,G=m||fe===`fit`?he:fe;(0,J.useEffect)(()=>{G&&W&&(C?.stage===`streaming`||C?.stage===`loading`)&&U({t:`resize`,w:G.w,h:G.h,...s===1?{}:{dpr:s}})},[G?.w,G?.h,s,W,C?.stage,F,U]),(0,J.useEffect)(()=>{if(!W)return;let e=setInterval(()=>U({t:`ping`,ts:Date.now()}),dn);return()=>clearInterval(e)},[W,U]);let K=W&&C?.stage===`streaming`;(0,J.useEffect)(()=>{if(!K){de(void 0);return}let e=setInterval(()=>{let e=Date.now();V.current=V.current.filter(t=>e-t.at<=pn);let t={fps:V.current.length,kbps:Math.round(V.current.reduce((e,t)=>e+t.bytes,0)/1024),...Se.current===void 0?{}:{rttMs:Se.current},...V.current.length>0?{lastFrameAt:V.current.at(-1).at}:{}};de(e=>{let n=t.lastFrameAt??e?.lastFrameAt,r={...t,...n===void 0?{}:{lastFrameAt:n}};return e&&e.fps===r.fps&&e.kbps===r.kbps&&e.rttMs===r.rttMs&&e.lastFrameAt===r.lastFrameAt?e:r})},fn);return()=>clearInterval(e)},[K]),(0,J.useEffect)(()=>(i?.(K),()=>i?.(!1)),[K,i]),(0,J.useEffect)(()=>{k&&r?.(k)},[k,r]);let q=(0,J.useCallback)((e,t,n=!1)=>{L.current=e,R.current=n&&`port`in e?e.port:void 0,re(!0),w(void 0),S(void 0),P(void 0),E(t),ee(`port`in e?e.port:void 0),ne(`agent`in e),A(vn(e)),U({t:`open`,target:e,viewerId:d.current,quality:z.current,dpr:l.current}),f.current=H.current},[U]),we=(0,J.useCallback)((e,n=!1)=>{let r=t.find(t=>t.port===e);q({port:e},r?gn(r):`http://localhost:${e}`,n)},[t,q]),Te=(0,J.useCallback)(()=>q({agent:!0},``),[q]);(0,J.useEffect)(()=>{if(n?.agent){if(B.current.agent&&B.current.stage?.stage===`streaming`)return;Te();return}if(n?.url!==void 0){let e=Fe(n.url,t);e.kind===`server`?we(e.port):e.kind===`url`&&q({url:e.url},e.url);return}n?.port!==void 0&&(n.restored&&!t.some(e=>e.port===n.port)||B.current.port===n.port&&B.current.stage?.stage===`streaming`&&n.run!==!0||we(n.port,n.run===!0))},[n]);let Ee=!j&&!x&&_.state!==`blocked`,De=_n(n,t);(0,J.useEffect)(()=>{Ee&&!De&&xe.current?.focus()},[Ee,De]);let Oe=e=>{let n=Fe(e,t);if(n.kind===`error`)return P(n.message);if(n.kind===`server`)return we(n.port);if(B.current.stage?.stage===`streaming`&&!B.current.agent)return L.current={url:n.url},R.current=void 0,ee(void 0),A({url:n.url}),P(void 0),E(n.url),U({t:`nav`,url:n.url});q({url:n.url},n.url)},ke=(0,J.useCallback)(e=>{z.current=e,me(e),zt(e),U({t:`quality`,quality:e})},[U]),Ae=()=>{f.current=!1,S(void 0),v({state:`connecting`,attempt:0}),Ce.current=!1,g(e=>e+1)};return{compact:m,transport:_,everOpened:y,takenOver:x,stage:C,url:T,port:D,agent:O,hasFrame:ae,cursor:se,dialog:le,setDialog:M,stats:ue,viewport:fe,setViewport:N,quality:pe,chooseQuality:ke,setStageSize:ge,addressError:_e,stageHandle:be,urlInput:xe,send:U,connected:W,streaming:K,openServer:we,openAgent:Te,empty:Ee,navigate:Oe,reconnect:Ae,actions:(0,J.useMemo)(()=>({download:()=>U({t:`download`}),cancelDownload:()=>U({t:`cancelDownload`}),retryBrowser:()=>U({t:`retryBrowser`}),run:e=>U({t:`run`,port:e}),stop:e=>U({t:`stop`,port:e}),keepWaiting:e=>U({t:`keepWaiting`,port:e}),close:o,useHere:Ae,copy:hn}),[U,o])}}function bn(e){return(0,Y.jsx)(ve,{onClose:e.onClose,children:(0,Y.jsx)(Cn,{...e})})}function xn(e,t,n,r){return e.state===`blocked`?{tone:`neutral`,label:`not supported`}:n?{tone:`neutral`,label:`paused`}:t&&(e.state===`reconnecting`||e.state===`closed`)?{tone:`danger`,label:`offline`}:e.state===`open`?r?Sn(r):void 0:{tone:`neutral`,label:`connecting…`}}function Sn(e){switch(e.stage){case`downloading`:return{tone:`pending`,label:`downloading`};case`download-failed`:return{tone:`danger`,label:`download failed`};case`sandbox-failed`:return{tone:`danger`,label:`browser failed`};case`browser-exited`:return{tone:`danger`,label:e.reason===`timeout`?`browser timed out`:`browser exited`};case`needs-approval`:return{tone:`neutral`,label:`not started`};case`port-held`:return{tone:`danger`,label:`port in use`};case`server-starting`:return{tone:`pending`,label:`waiting for :${e.server.port}`};case`server-stalled`:return{tone:`pending`,label:`waiting · 2 min`};case`server-exited`:return{tone:`danger`,label:`server exited`};case`server-stopped`:return{tone:`neutral`,label:`stopped`};case`agent-idle`:return{tone:`neutral`,label:`agent idle`};case`loading`:return{tone:`neutral`,label:`connecting…`};default:return}}function Cn(e){let{run:t,servers:n,serverStates:r,agentLive:i,onSession:a,onClose:o}=e,s=yn(e),{compact:c,transport:l,everOpened:u,takenOver:d,stage:f,url:p,port:m,agent:h,hasFrame:g,stats:_,viewport:v,setViewport:y,quality:b,chooseQuality:x,addressError:S,urlInput:C,send:w,streaming:T,openServer:E,openAgent:D,empty:ee,navigate:O,actions:te}=s,ne=n.find(e=>e.port===m),k=f?.stage===`streaming`&&f.adopted,A=u&&(l.state===`reconnecting`||l.state===`closed`),{content:j,dim:re}=sn({transport:l.state,takenOver:d,empty:ee,stage:f,hasFrame:g,lost:A,url:p,worktree:t.worktreePath}),ie=cn(j,{servers:n,serverStates:r,agentLive:i,openServer:E,openAgent:D,actions:te});return(0,Y.jsxs)(`section`,{"data-slot":`preview-pane-body`,"aria-label":`Live preview`,className:`flex h-full min-h-0 flex-col bg-background text-foreground`,children:[(0,Y.jsx)(Xt,{url:p,servers:n,serverStates:r,badge:l.state!==`blocked`,current:ne,agentLive:i===!0,agentShown:h,adopted:k,viewport:c?`fit`:v,quality:b,compact:c,navEnabled:T,loading:f?.stage===`loading`,stats:T?_??{fps:0,kbps:0}:void 0,status:T?void 0:xn(l,u,d!==void 0,f),urlInputRef:C,onSession:a,onNavigate:O,onBack:()=>w({t:`back`}),onForward:()=>w({t:`forward`}),onReload:e=>w({t:`reload`,...e?{ignoreCache:!0}:{}}),onPickServer:e=>E(e),onPickAgent:D,onViewport:y,onQuality:x,onCopyUrl:()=>hn(p),onStop:e=>w({t:`stop`,port:e}),onClose:o}),S?(0,Y.jsx)(`p`,{role:`alert`,className:`border-b border-border bg-card px-3 py-1.5 text-xs text-danger`,children:S}):null,(0,Y.jsx)(wn,{transportState:s,overlay:ie,dim:re,lost:A})]})}function wn({transportState:e,overlay:t,dim:n,lost:r}){let{connected:i,dialog:a,hasFrame:o,stage:s,stageHandle:c,compact:l,viewport:u,cursor:d,setStageSize:f,send:p,urlInput:m,transport:h,reconnect:g,setDialog:_}=e,v=s?.stage,y=i&&t===null&&!a;return(0,Y.jsxs)(Nt,{ref:c,viewport:l?`fit`:u,dimmed:n&&o&&(v===`streaming`||v===`loading`||n),cursor:d,onSize:f,renderInput:e=>y?(0,Y.jsx)(jt,{scale:e.scale,send:p,onLeave:()=>m.current?.focus()}):null,children:[r?(0,Y.jsx)(lt,{attempt:h.attempt,exhausted:h.state===`closed`,onReconnect:g}):null,t?(0,Y.jsx)(`div`,{"data-slot":`preview-overlay`,className:n&&o?`absolute inset-0 overflow-auto bg-background/85`:`absolute inset-0 overflow-auto bg-background`,children:t}):null,a?(0,Y.jsx)(dt,{dialog:a,onResult:e=>{_(void 0),p({t:`dialogResult`,...e})}}):null]})}function Tn(e){let{visibleEvents:t}=se(e);return(0,J.useMemo)(()=>{let e=new Map;for(let n of b(t,{activeTurn:!1}).turns)for(let t of n.items)t.kind===`preview-server`&&e.set(t.server.port,t);return e},[t])}function En(e){let t=Tn(e.run.id),n=oe(e.run.id);return(0,Y.jsx)(bn,{...e,serverStates:t,agentLive:n})}export{En as ConnectedPreviewPane};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{u as r}from"./button-RJMdCnZw.js";import{zt as i}from"./queries-D5f-3moU.js";import{N as a,S as o,a as s,o as c,r as l}from"./use-desktop-R2WTomyJ.js";import{W as u,l as d,tt as f}from"./design-icons-B6-0w7Aw.js";import{c as p}from"./project-router-lPPUPPDI.js";import{F as m,I as h,L as g,N as _,P as v,R as y,j as b}from"./picker-pill-Bhsrt_K5.js";import{a as x}from"./skills-pM_PouEs.js";var S=n();function C({className:e,...t}){return(0,S.jsx)(`div`,{"data-slot":`skeleton`,className:r(`animate-pulse rounded-md bg-accent`,e),...t})}var w=[`assigned`,`no-task`,`has-task`,`all`],T=[`review`,`mine`,`failing`,`all`],E=50,D=`is:open review-requested:@me`,O=`is:open status:failure`;function k(e,t){return e===`prs`&&(t===`review`||t===`failing`)}function A(e){return e===`review`?D:e===`failing`?O:null}function j(e,t){return t===null?null:(e===`issues`?w:T).includes(t)?t:`all`}function M(e,t,n,r=``){let i=`${n===void 0?e===`issues`?`/github`:`/github/prs`:`${e===`issues`?`/github/issues`:`/github/prs`}/${n}`}${r}`;return t===null?i:`${i}?filter=${encodeURIComponent(t)}`}function N(e,t){let n=t??`all`;return n===`all`?e===`issues`?`all`:`all-prs`:n}function P(e){return e===`all`?{view:`issues`,filter:`all`}:e===`all-prs`?{view:`prs`,filter:`all`}:{view:e===`review`||e===`mine`||e===`failing`?`prs`:`issues`,filter:e}}var F=[{id:`assigned`,label:`Assigned to me`},{id:`no-task`,label:`No task yet`},{id:`has-task`,label:`Has a task`},{id:`all`,label:`All open`}],I=[{id:`review`,label:`Review requested`},{id:`mine`,label:`Mine`},{id:`failing`,label:`Checks failing`},{id:`all-prs`,label:`All open`}],L=Object.fromEntries([...F,...I].map(e=>[e.id,e.label]));function R(e){return e===null?``:`${e.value}${e.bound===`atLeast`?`+`:``}`}function z(e,t){if(t?.bound===`atLeast`)return e===`review`||e===`failing`?`At least ${t.value}: GitHub search returns at most ${E} results.`:`At least ${t.value}: only the loaded pages are counted. Scroll to load more.`}var B=(e,t)=>e!==void 0&&t!==void 0&&e.toLowerCase()===t.toLowerCase();function V(e){try{let t=new URL(e).pathname.split(`/`).filter(Boolean);return t.length>=2?`${t[0]}/${t[1]}`.toLowerCase():null}catch{return null}}function H(e,t,n){return new Set(e.filter(e=>!e.archived).flatMap(e=>U(e,t,n)))}function U(e,t,n){let r=t?.toLowerCase();return o(e,void 0,n).filter(e=>e.kind===`Issue`&&(!e.url||r!==void 0&&V(e.url)===r)).map(e=>e.number)}function W(e,t,n,r){let i=new Map;for(let o of e)!a(o)&&U(o,n,r).includes(t)&&i.set(o.id,o);return[...i.values()].sort((e,t)=>Date.parse(t.createdAt)-Date.parse(e.createdAt)||e.id.localeCompare(t.id))}function G(e,t){let n=new Map(t.map(e=>[e.number,e]));return e.map(e=>n.get(e.number)??e)}function K(e){return e?.available?{value:e.items.length,bound:e.truncated?`atLeast`:`exact`}:null}function q({gh:e,tasks:t,review:n,failing:r}){let a={assigned:null,"no-task":null,"has-task":null,all:null,review:K(n),mine:null,failing:K(r),"all-prs":null};if(!e?.available)return a;let o=!i(e,`issues`),s=!i(e,`prs`),c=(e,t)=>({value:e,bound:t?`atLeast`:`exact`}),l=t?e.issues.filter(e=>t.has(e.number)).length:null;return{...a,all:c(e.issuesTotal??e.issues.length,!1),"all-prs":c(e.prsTotal??e.prs.length,!1),assigned:e.viewerLogin?c(e.issues.filter(t=>t.assignees?.some(t=>B(t,e.viewerLogin))).length,o):null,mine:e.viewerLogin?c(e.prs.filter(t=>B(t.author,e.viewerLogin)).length,s):null,"has-task":l===null?null:c(l,o),"no-task":l===null?null:c(e.issues.length-l,o)}}var J=e(t(),1);function Y({templates:e,onInsert:t,triggerClassName:n,disabled:i,iconOnly:a=!1,label:o=`Template`}){let[C,w]=(0,J.useState)(!1),T=(0,J.useRef)(null),E=p();return e.length===0?null:(0,S.jsxs)(l,{open:C,onOpenChange:w,children:[(0,S.jsx)(c,{asChild:!0,children:(0,S.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-trigger`,"aria-label":`Insert a prompt template`,title:`Insert a prompt template`,disabled:i,className:r(`inline-flex h-[26px] items-center gap-1.5 rounded-full border border-border bg-card text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,a?`w-[26px] justify-center px-0`:`h-11 gap-2 rounded-lg px-3 text-foreground`,n),children:[(0,S.jsx)(u,{"aria-hidden":`true`,className:a?`size-3 shrink-0 text-accent-icon`:`size-[18px] shrink-0 text-muted-foreground`}),a?null:(0,S.jsxs)(S.Fragment,{children:[o,(0,S.jsx)(d,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`})]})]})}),(0,S.jsx)(s,{align:`start`,sideOffset:8,"data-slot":`prompt-template-menu`,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,onCloseAutoFocus:e=>e.preventDefault(),children:(0,S.jsxs)(b,{filter:x,children:[(0,S.jsx)(m,{placeholder:`search templates…`,onInput:()=>T.current?.scrollTo(0,0)}),(0,S.jsxs)(g,{ref:T,"data-slot":`prompt-template-list-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[(0,S.jsx)(_,{children:`Nothing matches.`}),(0,S.jsx)(v,{heading:`Insert a template`,children:e.map(e=>(0,S.jsxs)(h,{value:`template ${e.label} ${e.id}`,keywords:[e.text,...e.skills??[]],"data-slot":`prompt-template-option`,"data-template":e.id,title:e.text,className:`flex-col items-start gap-0.5`,onSelect:()=>{t(e.text),w(!1)},children:[(0,S.jsxs)(`span`,{className:`flex w-full items-center gap-1.5`,children:[(0,S.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-medium text-foreground`,children:e.label}),e.skills&&e.skills.length>0?(0,S.jsxs)(`span`,{"data-slot":`prompt-template-assigned`,title:`Applied automatically with: ${e.skills.join(`, `)}`,className:`inline-flex shrink-0 items-center gap-0.5 text-[12px] font-medium text-accent-text`,children:[(0,S.jsx)(f,{"aria-hidden":`true`,className:`size-2.5`}),e.skills.length]}):null]}),(0,S.jsx)(`span`,{className:`line-clamp-1 text-[11px] text-soft-foreground`,children:e.text})]},e.id))}),(0,S.jsx)(y,{}),(0,S.jsx)(v,{children:(0,S.jsx)(h,{value:`edit prompt templates settings`,"data-slot":`prompt-template-settings`,className:`text-[12px] text-muted-foreground`,onSelect:()=>{w(!1),E(`/settings/prompt-templates`)},children:`Edit templates…`})})]})]})})]})}export{G as _,I as a,q as c,M as d,k as f,N as g,j as h,F as i,P as l,W as m,L as n,D as o,H as p,O as r,z as s,Y as t,R as u,A as v,C as y};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{A as n,M as r}from"./button-RJMdCnZw.js";import{n as i,t as a}from"./live-refetch-CZb2VOyu.js";import{$ as o,$r as s,$t as c,At as l,B as u,Ci as d,Cr as f,Ct as p,Dt as m,Et as h,F as g,Ft as _,Ht as v,I as y,J as b,Jr as ee,K as te,Kr as ne,Kt as re,L as ie,Or as ae,Ot as oe,P as se,Pr as ce,Q as le,Qr as ue,R as de,St as fe,Tt as pe,V as me,Vt as he,W as ge,X as _e,Xr as ve,Y as ye,Yr as be,Z as xe,Zr as Se,_ as Ce,_i as x,_t as we,an as Te,at as Ee,b as De,bi as Oe,bn as ke,c as Ae,cn as je,ct as Me,dn as Ne,dt as Pe,en as Fe,et as Ie,f as Le,fi as Re,ft as ze,g as Be,gn as Ve,gr as He,gt as Ue,hi as We,hn as Ge,ht as Ke,i as qe,it as Je,j as Ye,jt as Xe,kr as Ze,kt as Qe,ln as $e,lt as et,m as tt,mn as nt,mt as rt,ni as it,nn as at,nt as ot,oi as st,ot as ct,pt as lt,q as ut,qr as dt,r as ft,rn as pt,rt as mt,si as ht,st as gt,ti as S,tn as _t,ui as vt,un as yt,ut as bt,v as xt,vn as St,vt as Ct,wt,x as Tt,xn as Et,yi as Dt,yt as Ot,z as kt}from"./project-scope-context-Xjbxntpg.js";import{q as C}from"./live-protocol-CjfZMf1X.js";import{t as w}from"./useInfiniteQuery-C05yR_S9.js";import{t as T}from"./useQuery-7jNqNIJb.js";import{n as At,r as E,t as jt}from"./ws-wEXmfalm.js";import{n as Mt}from"./toaster-BWMQArHJ.js";var Nt=class extends st{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Pt(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=ht({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),C.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Pt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Ft=class extends d{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),Dt(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&vt(t.mutationKey)!==vt(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Pt();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){C.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function It(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Lt(e,t,n){let r=e.slice(0);return r[t]=n,r}var Rt=class extends d{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,C.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!Dt(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(It(e,n).forEach(e=>{e.destroy()}),It(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=x(this.#a,t(e))),this.#a}return e}#f(){return this.#r?.combine!==void 0&&this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new it(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Lt(this.#t,n,t),this.#h())}#h(){if(this.hasListeners()){let e=this.#u(this.#t,this.#l),t=this.#f(),n=this.#a,r=t?n:this.#d(e,this.#r?.combine);(t||n!==r)&&C.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},D=e(t(),1);function O({queries:e,...t},n){let r=S(n),i=s(),a=ue(),o=D.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{ne(e);let t=r.getQueryCache().get(e.queryHash);be(e,a,t)}),Se(a);let[c]=D.useState(()=>new Rt(r,o,t)),[l,u,d]=c.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;D.useSyncExternalStore(D.useCallback(e=>f?c.subscribe(C.batchCalls(e)):We,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),D.useEffect(()=>{c.setQueries(o,t)},[o,t,c]);let p=l.some((e,t)=>ee(o[t],e))?l.flatMap((e,t)=>{let n=o[t];return n&&ee(n,e)?dt(n,new it(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=l.find((e,t)=>{let n=o[t];return n&&ve({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return u(d())}function k(e,t){let n=S(t),[r]=D.useState(()=>new Ft(n,e));D.useEffect(()=>{r.setOptions(e)},[r,e]);let i=D.useSyncExternalStore(D.useCallback(e=>r.subscribe(C.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=D.useCallback((e,t)=>{r.mutate(e,t).catch(We)},[r]);if(i.error&&Oe(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function A(e={}){let t=e.projectId??r();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function j(e,t={}){return{...A(t),runId:e}}var M=[`workspace`,`runs-index`],N=e=>[e.cacheScope,`runs`,`list`],P=e=>[e.cacheScope,`runs`,`detail`,e.runId],F=e=>typeof e==`function`?e():e;function zt(e){let{seenAt:t,...n}=e;return n}function Bt(e,t){let n=zt(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function I(e,t,n){return t?{...e,seenAt:n}:zt(e)}function Vt(e){let t=()=>{e.invalidateQueries({queryKey:M})};function n(n,i){if(n===`index`)return t();let a=typeof i==`function`?i():i;if(n===`indexed`){t(),e.invalidateQueries({queryKey:[r(),`runs`]}),e.invalidateQueries({queryKey:[a.projectId,`runs`,`list`]});return}if(n===`runs`)return e.invalidateQueries({queryKey:[a.cacheScope,`runs`]});let o=Ze(),s=[a.projectId,a.cacheScope],c=o!==void 0&&s.some(e=>e===o||e==="default")?[o,`default`]:[],l=new Set([...s,...c,r()]);return Promise.all([...l].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}async function i(n,r){await e.cancelQueries({queryKey:N(F(n))}),await e.cancelQueries({queryKey:P(F(n))});let i=e.getQueryData(N(F(n))),a=e.getQueryData(P(F(n))),o=F(n).runId,s=new Date().toISOString();return e.setQueryData(N(F(n)),e=>e?.map(e=>e.id===o?I(e,r,s):e)),e.setQueryData(P(F(n)),e=>e&&I(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(N(F(n)),i),a&&e.setQueryData(P(F(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(N(F(n)),e=>e?.map(e=>e.id===o?Bt(e,t):e)),a&&e.setQueryData(P(F(n)),e=>e&&Bt(e,a))},settle(i){let a=e=>e.id===(r?o:i.id)?I(e,r,i.seenAt):e;e.setQueryData(N(F(n)),e=>e?.map(a));let s={...F(n),runId:r?o:i.id};e.setQueryData(P(s),e=>e?a(e):i),t()}}}async function a(t,r){await e.cancelQueries({queryKey:M});let i=e.getQueryData(M),a=r();return e.setQueryData(M,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.projectId===t.projectId&&e.id===t.runId?a(e):e)}),{previous:i,rollback(){i&&e.setQueryData(M,i)},settle(){n(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:n}}function L(){let e=S();return(0,D.useMemo)(()=>Vt(e),[e])}function Ht(e){return e.type===`run`?e.run.id:e.id}function R(e,t){return{...e,runs:t}}function Ut(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}function Wt(e,t){let n=e.findIndex(e=>(e.createdAt??``).localeCompare(t.createdAt)<0),r=[...e];return r.splice(n<0?e.length:n,0,t),r}function Gt(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function Kt(e,t,n){let{project:r}=t,i=Ht(t),a=e.runs.findIndex(e=>e.projectId===r&&e.id===i),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(r);if(t.type===`deleted`)return o?{index:R(e,e.runs.filter((e,t)=>t!==a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:R(e,e.runs.filter((e,t)=>t!==a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!Gt(e,r,n))return{index:e,reconcile:!0};let l=x(o,{projectId:r,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=[...e.runs];t[a]=l;let n=o.archived!==l.archived&&(s||Ut(t,r)>e.perProjectLimit);return{index:R(e,t),reconcile:n}}if(s)return Jt(e,l);let u=Wt(e.runs,l);return{index:R(e,u),reconcile:l.archived&&Ut(u,r)>e.perProjectLimit}}function qt(e,t){let n;for(let r of e)r.projectId===t&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function Jt(e,t){let n=qt(e.runs,t.projectId),r=n!==void 0&&t.createdAt>n;return t.archived&&!r?{index:e,reconcile:!1}:{index:R(e,Wt(e.runs,t)),reconcile:t.archived||n===void 0||t.createdAt<n}}function Yt(e,t,n){let r=!1,i=e.runs.map(e=>{if(e.projectId!==t)return e;let i=n[e.id];if(i){let t=x(e.usage,i);return t===e.usage?e:(r=!0,{...e,usage:t})}if(e.usage===void 0)return e;r=!0;let{usage:a,...o}=e;return o});return r?R(e,i):e}function Xt(e,t){let n=e.runs.filter(e=>e.projectId!==t),r=e.truncated.filter(e=>e!==t),i=Object.prototype.hasOwnProperty.call(e.referenceStatuses,t);if(n.length===e.runs.length&&r.length===e.truncated.length&&!i)return e;let a={...e.referenceStatuses};return delete a[t],{...e,runs:n,truncated:r,referenceStatuses:a}}function Zt(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function Qt(e,t,n){if(e.lastStream===t)e.floor=Math.max(e.floor??n,n);else{for(let[n,r]of e.changes)r.generation!==t&&e.changes.delete(n);e.floor=n}e.stream=t,e.lastStream=t,e.mismatch=void 0}function $t(e){e.stream=void 0}function en(e,t,n=!1){let r=e.stream;if(r===void 0)return!1;(e.floor===void 0||n)&&(e.floor=t.seq-1);let i=JSON.stringify([r,t.project,Ht(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function tn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function nn(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function rn(e,t,n){if(!nn(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t;if(e.stream!==void 0&&e.stream!==r){let n=e.mismatch!==r;return e.mismatch=r,{index:t,reconcile:n}}let a=e.lastStream===r&&e.floor!==void 0,o=a&&i<e.floor,s=t,c=o,l=[...e.changes.entries()].filter(([,e])=>e.generation===r),u=l.map(([,e])=>e).filter(e=>e.seq>i).sort((e,t)=>e.seq-t.seq);for(let e of u){let t=Kt(s,e,n);s=t.index,c||=t.reconcile}for(let[t,n]of l)n.seq<=i&&e.changes.delete(t);return a&&!o&&(e.floor=i),{index:s,reconcile:c}}var z=[`workspace`,`runs-index`],an=[`workspace`,`projects`],on=6e4,sn=100,cn=new WeakMap;function B(e){let t=cn.get(e);return t||(t=pn(e),cn.set(e,t)),t}function ln(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:B(t).merge(e)}function un(e){let t=e.getQueryData(an)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function dn(e,t,n){if(!(!e||typeof e.eventSeq!=`number`||typeof t.eventSeq!=`number`))return e.generation===t.generation?t.eventSeq<e.eventSeq?e:void 0:n!==void 0&&e.generation===n&&t.generation!==n?e:void 0}function fn(e,t){return t.type===`run-summary`?{type:`run`,project:e,seq:t.seq,run:t.summary}:{type:`deleted`,project:e,seq:t.seq,id:t.id}}function pn(e){let t=Zt(),n=[],r,i,a,o,s=!1,c=-1/0,l=new Set,u=!1,d,f=!1,p=()=>{if(!u){if(u=!0,d?.()){f=!0;return}_({hold:!0})}},m=t=>{c=Date.now(),e.setQueryData(z,t)},h=()=>e.getQueryData(z),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:z,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:z,exact:!0}).then(()=>e.invalidateQueries({queryKey:z})):e.invalidateQueries({queryKey:z})).catch(()=>void 0).finally(()=>{o===n&&(o=void 0,s&&(s=!1,g()))});return o=n,n},_=(e={})=>o?(s=!0,o):e.hold?(a??=setTimeout(()=>{g()},400),Promise.resolve()):g(),v=()=>{r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0;let t=n;n=[];let a=h();if(!a||t.length===0)return;let o=un(e),s=a,c=!1;for(let e of t){if(e.generation!==a.generation)continue;if(e.type===`usage`){l.has(e.project)||(s=Yt(s,e.project,e.usage));continue}if(l.has(e.change.project)||e.change.seq<=a.eventSeq)continue;let t=Kt(s,e.change,o);s=t.index,c||=t.reconcile}s!==a&&m(s),c&&_({hold:!0})},y=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,sn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){Qt(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){$t(t)},run(e,r,i=!1){if(l.has(e))return;let a=fn(e,r);if(!en(t,a,i)){p();return}n.push({type:`change`,change:a,generation:t.stream}),y()},usage(e,r){if(!l.has(e)){if(t.stream===void 0){p();return}n.push({type:`usage`,project:e,usage:r,generation:t.stream}),y()}},dropProject(e){l.add(e),tn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=Xt(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=rn(t,n,un(e));for(let e of l)i.index=Xt(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),dn(r,n,t.stream)??i.index},reconcile:_,flush:v,stop(){r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0,clearTimeout(a),a=void 0,n=[],s=!1}}}var mn={draft:{label:`Draft`,hint:`the author has not marked it ready for review`,tone:`neutral`},"review-required":{label:`Waiting for review`,hint:`checks are fine, no one has reviewed it yet`,tone:`info`},"changes-requested":{label:`Changes requested`,hint:`a reviewer asked for edits before this can merge`,tone:`danger`},"checks-pending":{label:`Checks running`,hint:`CI has not finished on the latest commit`,tone:`pending`},"checks-failing":{label:`Checks failing`,hint:`CI is red on the latest commit`,tone:`danger`},ready:{label:`Ready to merge`,hint:`open, checks pass, nothing is waiting on a reviewer`,tone:`success`},merged:{label:`Merged`,hint:`this landed on its base branch`,tone:`merged`},closed:{label:`Closed`,hint:`closed without merging — the work did not land`,tone:`danger`},open:{label:`Open`,hint:`still open on the tracker`,tone:`success`},completed:{label:`Closed as completed`,hint:`the issue was resolved`,tone:`accent`},"not-planned":{label:`Closed as not planned`,hint:`the issue was declined — nothing shipped for it`,tone:`neutral`}},hn={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function gn(e){return typeof e==`string`&&Object.hasOwn(mn,e)}function _n(e){return e!==void 0&&gn(e)?mn[e]:void 0}var vn=`cez.reference-statuses.v1`,yn=`cez.reference-conflicts.v1`,V=new Map(Sn()),bn=1e3;function H(e,t){if(V.get(e)!==t){for(V.delete(e),V.set(e,t);V.size>bn;){let e=V.keys().next().value;if(e===void 0)break;V.delete(e)}wn()}}var U=new Set(Cn());function xn(e,t){if(U.has(e)!==t){if(t)for(U.add(e);U.size>bn;){let e=U.values().next().value;if(e===void 0)break;U.delete(e)}else U.delete(e);wn()}}function Sn(){try{let e=globalThis.sessionStorage?.getItem(vn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`&&gn(e[1])):[]}catch{return[]}}function Cn(){try{let e=globalThis.sessionStorage?.getItem(yn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var W;function wn(){W===void 0&&(W=setTimeout(()=>{W=void 0;try{globalThis.sessionStorage?.setItem(vn,JSON.stringify([...V])),globalThis.sessionStorage?.setItem(yn,JSON.stringify([...U]))}catch{}},250))}var G=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function K(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function Tn(e){return[...e.prs.map(t=>({projectId:e.projectId,kind:`PR`,number:t})),...e.issues.map(t=>({projectId:e.projectId,kind:`Issue`,number:t}))]}function En(e,t,n,r,i,a){let o=r.prs[n.number]??r.issues[n.number];if(!o){e.set(t,{state:`unknown`,...i?{status:i}:{}});return}let s=r.conflicts?r.conflicts.includes(n.number):void 0;H(t,o),s!==void 0&&xn(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function Dn(e,t,n){let r=G(t),i=V.get(r),a=U.has(r)?!0:void 0,o=n.data;if(o?.available){En(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...K(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...K(i,a)});return}e.set(r,{state:`loading`,...K(i,a)})}function On(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of Tn(i))Dn(n,e,t)}),n}async function kn(e,t=!1){return Ve(await Le.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:r(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),je(e,`/worker-destroy`))}function An(e){if(!e)return;let t=e.trim().replace(/\/+$/,``),n=/^(?:https?|ssh|git|git\+ssh):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+)$/.exec(t),r=n?null:/^(?:[^@/:]+@)?([^:/]+):(.+)$/.exec(t),i=n??r;if(!i)return;let[,a,o]=i;if(!o||a?.toLowerCase()!==`github.com`)return;let s=o.replace(/\.git$/i,``).split(`/`).filter(Boolean),c=s[s.length-2],l=s[s.length-1];return c&&l?`https://github.com/${c}/${l}`:void 0}function jn(e){let t=new Map;for(let n of e)for(let e of n.tags??[]){let n=e.toLowerCase();t.has(n)||t.set(n,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function Mn(e,t,n,r=8){let i=n.trim().toLowerCase(),a=new Set(t.map(e=>e.toLowerCase())),o=e.filter(e=>{let t=e.toLowerCase();return a.has(t)?!1:i===``||t.includes(i)&&t!==i});return i===``?o.slice(0,r):o.sort((e,t)=>Number(t.toLowerCase().startsWith(i))-Number(e.toLowerCase().startsWith(i))||e.localeCompare(t,void 0,{sensitivity:`base`})).slice(0,r)}function Nn(e){let t=new Map;for(let n of e){let e=n.trim();if(!e)continue;let r=e.toLowerCase();t.has(r)||t.set(r,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function Pn(e){if(!e.available)return;let t=e.issuesNextCursor,n=e.prsNextCursor;if(!(t===void 0&&n===void 0)&&!(!t&&!n))return{...t?{issuesCursor:t}:{issuesDone:!0},...n?{prsCursor:n}:{prsDone:!0}}}function Fn(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function In(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function Ln(e){let t=e[0];if(!t)return;let n=e[e.length-1],r=[],i=[],a=new Set,o=new Set,s={};for(let t of e){In(t.issues,a,r),In(t.prs,o,i);for(let[e,n]of Object.entries(t.labelColors??{}))s[e]??=n}let c=e.find(e=>e.projects)?.projects,l=e.map(e=>e.projectsState),u=e.find(e=>e.projectsState===`unavailable`),d=l.includes(`refreshing`)?`refreshing`:u?`unavailable`:l.some(e=>e===`ready`)?`ready`:void 0,{projectsGeneration:f,projectsReason:p,...m}=t;return{...m,issues:r,prs:i,...Object.keys(s).length>0?{labelColors:s}:{},...c?{projects:c}:{},...d?{projectsState:d}:{},...d===`unavailable`&&u?.projectsReason?{projectsReason:u.projectsReason}:{},...`issuesNextCursor`in n?{issuesNextCursor:n.issuesNextCursor}:{},...`prsNextCursor`in n?{prsNextCursor:n.prsNextCursor}:{}}}var q=e=>e.map(e=>e.number).join(`,`);function Rn(e,t){let n=e[0];if(e.length>1&&n&&(q(n.issues)!==q(t.issues)||q(n.prs)!==q(t.prs)||n.issuesTotal!==t.issuesTotal||n.prsTotal!==t.prsTotal))return`refetch`;let r=t;if(n&&t.available&&t.projectsState===`refreshing`&&n.repo===t.repo){let e=new Map(n.issues.map(e=>[e.number,e.projectIds]));r={...t,issues:t.issues.map(t=>{let n=e.get(t.number);return t.projectIds===void 0&&n!==void 0?{...t,projectIds:n}:t})}}return[r,...e.slice(1)]}function zn(e,t,n=!0){let i=Hr(),a=$(),o=e??i.data?.defaultRunner??`claude`,s=a.data?.capabilities?.localHandoff===!1?null:t,c=r(),l=T({queryKey:J.runnerSkills(o,s),queryFn:({signal:e})=>wt(o,s,{signal:e,projectId:c}),enabled:n&&(e!==void 0||!i.isPending)&&(!t||!a.isPending),retry:!1});return{...l,runner:o,account:s,data:l.data?.skills,list:l.data,unchecked:l.isError||!l.data||l.data.source===`unavailable`}}var J={get health(){return[r(),`health`]},runs:{get all(){return[r(),`runs`]},relationships:e=>[r(),`runs`,`relationships`,e],list:(e=r())=>[e,`runs`,`list`],archived:e=>[r(),`runs`,`archived`,e],detail:(e,t=r())=>[t,`runs`,`detail`,e],diff:e=>[r(),`runs`,`diff`,e],changes:e=>[r(),`runs`,`changes`,e],file:(e,t)=>[r(),`runs`,`files`,e,t],handoff:e=>[r(),`runs`,`handoff`,e],commits:e=>[r(),`runs`,`commits`,e],commit:(e,t)=>[r(),`runs`,`commit`,e,t]},get workflows(){return[r(),`workflows`]},runnerSkills:(e,t)=>[r(),`runner-skills`,e,t??null],get repo(){return[r(),`repo`]},get repoChanges(){return[r(),`repo`,`changes`]},repoCommit:e=>[r(),`repo`,`commit`,e],get repoBranches(){return[r(),`repo`,`branches`]},get uiState(){return[r(),`ui-state`]},get config(){return[r(),`config`]},get agentConfig(){return[r(),`agent-config`]},agentConfigFile:e=>[r(),`agent-config`,`file`,e],get worktrees(){return[r(),`worktrees`]},github:(e={})=>[r(),`github`,e.limit??null],githubPages:e=>[r(),`github`,`pages`,e],githubPagesHead:e=>[r(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[r(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],githubChecks:e=>[r(),`github`,`checks`,[...e].sort((e,t)=>e-t).join(`,`)],githubSearch:(e,t)=>[r(),`github`,`search`,e,t],githubRefStatus:(e,t,n)=>[e,`github`,`ref-status`,[...t].sort((e,t)=>e-t).join(`,`),[...n].sort((e,t)=>e-t).join(`,`)],githubComments:(e,t)=>[r(),`github`,`comments`,e,t],githubItem:(e,t)=>[r(),`github`,`item`,e,t],githubRefStatusOf:e=>[e,`github`,`ref-status`],githubPrChanges:e=>[r(),`github`,`pr-changes`,e],githubMergeState:e=>[r(),`github`,`merge-state`,e],get openTargets(){return[r(),`open-targets`]}},Y={models:e=>[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:z,runsSearch:e=>[`workspace`,`runs-search`,e],uiState:[`workspace`,`ui-state`],config:[`workspace`,`config`],agentProfiles:[`workspace`,`agent-profiles`],agentAccountStatus:e=>[`workspace`,`agent-profiles`,`status`,e],fsBrowseRoot:[`workspace`,`fs-browse`],fsBrowse:(e,t=!1)=>[...Y.fsBrowseRoot,e,t]};function X(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:Y.models(t),refetchType:n})}function Z(e,t=!0){return T({queryKey:Y.models(e),queryFn:({signal:t})=>p(e,{signal:t}),staleTime:300*1e3,enabled:t})}function Bn(e=!0){return{claude:Z(`claude`,e),codex:Z(`codex`,e),opencode:Z(`opencode`,e),pi:Z(`pi`,e),omp:Z(`omp`,e)}}function Vn(){let e=S();return T({queryKey:Y.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(Y.providerStatus),r=await Me(!1,{signal:t});return f(n,e.getQueryData(Y.providerStatus),r)},staleTime:5*6e4,refetchInterval:a(!1),refetchOnWindowFocus:!0})}function Hn(){let e=S();return k({mutationFn:()=>Me(!0),onMutate:()=>e.getQueryData(Y.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Y.providerStatus,e=>f(r,e,t)),X(e)}})}function Un(){let e=S();return k({mutationFn:({provider:e,authFailureId:t})=>Te(e,t),onMutate:()=>e.getQueryData(Y.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Y.providerStatus,e=>f(r,e,t,n.authFailureId)),X(e,n.provider)}})}function Wn(e={}){return T({queryKey:Y.projects,queryFn:({signal:e})=>gt({signal:e}),...e})}function Gn(e,t=!1){return T({queryKey:Y.fsBrowse(e,t),queryFn:({signal:n})=>Ae(e??void 0,{signal:n,showHidden:t}),retry:!1})}function Kn(){let e=S();return k({mutationFn:e=>c(e),onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function qn(){let e=S();return k({mutationFn:e=>_t(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:Y.projects})}})}function Jn(){let e=S();return k({mutationFn:e=>{let{id:t,...n}=e;return ke(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:Y.projects});let r=e.getQueryData(Y.projects);return e.setQueryData(Y.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Yn(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(Y.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(Y.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:Y.projects})})}function Yn(e,t){let{maxParallel:n,tags:r,...i}=e,a={...i},o=`maxParallel`in t?t.maxParallel:e.maxParallel;o!=null&&(a.maxParallel=o);let s=`tags`in t&&t.tags!==void 0?t.tags:e.tags,c=s==null?[]:Nn(s);if(c.length>0&&(a.tags=c),`webhook`in t&&t.webhook!==void 0)if(t.webhook===null)delete a.webhook;else{let n=t.webhook.token===void 0?e.webhook?.tokenSet??!1:t.webhook.token!==``;a.webhook={url:t.webhook.url,tokenSet:n}}return a}function Xn(e){let t=S();return k({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(Y.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:Y.projects})})}function Zn(){return Xn(e=>{let{projectId:t,...n}=e;return Tt(t,n)})}function Qn(){return Xn(e=>{let{projectId:t,webhookId:n,...r}=e;return Et(t,n,r)})}function $n(){return Xn(({projectId:e,webhookId:t})=>at(e,t))}function er(){return k({mutationFn:({projectId:e,webhookId:t})=>Ge(e,t),retry:!1})}function tr(e){let t=S();return k({mutationFn:t=>_(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function Q(e){let t=S();return k({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:Y.agentProfiles}),t.invalidateQueries({queryKey:Y.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`})])}})}function nr(){return Q(e=>xt(e))}function rr(){return Q(e=>{let{id:t,...n}=e;return St(t,n)})}function ir(){return Q(e=>Fe(e))}function ar(){return Q(e=>yt(e))}function or(e,t){return T({queryKey:Y.agentAccountStatus(e),queryFn:({signal:t})=>se(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function sr(){let e=S();return k({mutationFn:({provider:e,profileId:t})=>Be(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:Y.agentProfiles}),e.invalidateQueries({queryKey:Y.providerStatus}),X(e,n,`none`)])}})}function cr(){let e=S();return k({mutationFn:e=>se(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(Y.agentAccountStatus(n),t),e.invalidateQueries({queryKey:Y.agentProfiles}),X(e,t.status.provider)}})}function lr(){let e=S();return k({mutationFn:e=>tt(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function ur(){let e=S();return k({mutationFn:e=>De(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function dr({enabled:e}){return T({queryKey:Y.githubOwners,queryFn:({signal:e})=>o({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function fr(){let e=S();(0,D.useEffect)(()=>{let t,r=()=>{let r=e.getQueryData(J.health),i=r?.capabilities?.localHandoff===!0;r&&ae({local:i,bootProject:r.bootProject??`default`,apiBase:n()}),i&&t===void 0?t=jt(`health`,t=>{e.setQueryData(J.health,t)}):!i&&t!==void 0&&(t(),t=void 0)};r();let i=e.getQueryCache().subscribe(r);return()=>{i(),t?.(),ce()}},[e])}function $(){return T({queryKey:J.health,queryFn:({signal:e})=>Ee({signal:e})})}function pr(e,t){let n=$().data,r=Wn(t).data?.projects,i=ft(),a=e??i.projectId,o=a??n?.bootProject,s=o===void 0?void 0:r?.find(e=>e.id===o);return s?.repoUrl?s.repoUrl:a===null||a===n?.bootProject?An(n?.repo?.remote):void 0}function mr(){return T({queryKey:J.openTargets,queryFn:({signal:e})=>ct({signal:e}),staleTime:5*6e4})}function hr(){return T({queryKey:J.runs.list(),queryFn:({signal:e})=>pe(A(),{signal:e})})}function gr(e,t){return w({queryKey:J.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>de({before:t,limit:200,q:e},{signal:n}),getNextPageParam:e=>e.nextCursor??void 0,placeholderData:(e,t)=>t?.queryKey[0]===r()?e:void 0})}function _r(e){let t=e.trim();return T({queryKey:Y.runsSearch(t),queryFn:({signal:e})=>$e(t,{signal:e}),enabled:t.length>=2,placeholderData:Re,staleTime:1e4})}function vr(e=!0,t=on){let n=B(S());return E(`/api/v1/workspace/runs-index`,Y.runsIndex,a(e?t:!1),ln),T({queryKey:Y.runsIndex,queryFn:({signal:e})=>h({signal:e}).then(n.merge),enabled:e,staleTime:3e4,refetchInterval:!1})}function yr(e,t=!0,n=!1){return T({queryKey:[A({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>pe(A({projectId:e,boot:n}),{signal:t}),enabled:t,placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function br(e){let t=S();return k({mutationFn:({workerId:e,discardWork:t=!1})=>kn(e,t),onSettled:()=>t.invalidateQueries({queryKey:J.runs.relationships(e)})})}function xr(e,t={}){return T({queryKey:J.runs.relationships(e),queryFn:({signal:t})=>fe(e,{signal:t}),enabled:t.enabled??!0})}function Sr(e){return T({queryKey:J.runs.detail(e??``),queryFn:({signal:t})=>lt(j(e),{signal:t}),enabled:!!e})}function Cr(e,t,n=!0){return T({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>lt(j(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t})}function wr(e){return T({queryKey:J.runs.diff(e??``),queryFn:({signal:t})=>we(e,{signal:t}),enabled:!!e})}function Tr(e,t=!1){return E(e?`/api/v1/p/${r()}/runs/${encodeURIComponent(e)}/changes`:void 0,J.runs.changes(e??``),a(t?4e3:!1)),T({queryKey:J.runs.changes(e??``),queryFn:({signal:t})=>rt(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function Er(e,t){return T({queryKey:J.runs.file(e??``,t??``),queryFn:({signal:n})=>Ct(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function Dr(e,t){return T({queryKey:[r(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>ut(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Or(e,t){return T({queryKey:[r(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>kt(e,t,{signal:n}),enabled:t!==null,retry:!1})}function kr(e,t){return T({queryKey:[r(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>u(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Ar(e){return T({queryKey:[r(),`runs`,`artifacts`,e],queryFn:({signal:t})=>me(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function jr(e,t=!1){return E(e?`/api/v1/p/${r()}/runs/${encodeURIComponent(e)}/commits`:void 0,J.runs.commits(e??``),a(t?5e3:!1)),T({queryKey:J.runs.commits(e??``),queryFn:({signal:t})=>Ue(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function Mr(e,t){return T({queryKey:J.runs.commit(e??``,t??``),queryFn:({signal:n})=>Ke(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function Nr(e,t=!0){return T({queryKey:J.runs.handoff(e??``),queryFn:({signal:t})=>Ot(j(e),{signal:t}),enabled:!!e&&t})}function Pr(e,t,n){return T({queryKey:e===void 0?J.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>Ot(j(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function Fr(e,t){let n=[...new Set(e)],i=O({queries:n.map(e=>({queryKey:[e??r(),`automations`,`names`],queryFn:({signal:t})=>ge({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,D.useMemo)(()=>{let e=new Map;return a.forEach((t,r)=>{if(t?.available)for(let i of t.automations)e.set(JSON.stringify([n[r]??null,i.id]),i.name)}),(t,n)=>e.get(JSON.stringify([t??null,n]))},[JSON.stringify([n,i.map(e=>e.dataUpdatedAt)])])}function Ir(){return T({queryKey:J.workflows,queryFn:({signal:e})=>oe({signal:e})})}function Lr(){return T({queryKey:J.repo,queryFn:({signal:e})=>et({signal:e})})}function Rr(e){return T({queryKey:[e,`repo`],queryFn:({signal:t})=>et({signal:t},e)})}function zr(){return T({queryKey:J.repoBranches,queryFn:({signal:e})=>bt({signal:e})})}function Br(){return T({queryKey:J.repoChanges,queryFn:({signal:e})=>Pe({signal:e}),retry:!1})}function Vr(e){return T({queryKey:J.repoCommit(e??``),queryFn:({signal:t})=>ze(e,{signal:t}),enabled:!!e,retry:!1})}function Hr(){return T({queryKey:J.config,queryFn:({signal:e})=>te({signal:e})})}function Ur(){return T({queryKey:J.worktrees,queryFn:({signal:e})=>Xe({signal:e})})}function Wr(e){return T({queryKey:[e,`worktrees`],queryFn:({signal:t})=>Xe({signal:t},e),staleTime:0})}function Gr(e,t=!0,n=!1){return T({queryKey:[A({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>m({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:He(e.sidebarLimits)},enabled:t})}function Kr(){return Gr(r())}function qr(){return T({queryKey:J.agentConfig,queryFn:({signal:e})=>g({signal:e})})}function Jr(e){return T({queryKey:J.agentConfigFile(e??``),queryFn:({signal:t})=>y(e,{signal:t}),enabled:e!==null})}function Yr(e){let t=S(),n=J.agentConfig,r=J.agentConfigFile(e);return k({mutationFn:t=>re(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}function Xr(){return T({queryKey:Y.uiState,queryFn:({signal:e})=>l({signal:e})})}function Zr(){return T({queryKey:Y.config,queryFn:({signal:e})=>Qe({signal:e})})}function Qr(){return T({queryKey:Y.agentProfiles,queryFn:({signal:e})=>ie({signal:e})})}function $r(e){let t=S();return k({mutationFn:t=>he(e,t),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function ei(e){let t=L(),n=e?.projectId,r=e?.cacheScope,i=k({mutationFn:e=>nt(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,D.useCallback)(e=>({...j(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,D.useCallback)(e=>({onSuccess:(t,n,r,i)=>e?.onSuccess?.(t,n.id,r,i),onError:(t,n,r,i)=>e?.onError?.(t,n.id,r,i),onSettled:(t,n,r,i,a)=>e?.onSettled?.(t,n,r.id,i,a)}),[]),{mutate:s,mutateAsync:c}=i,l=(0,D.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,D.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function ti(){let e=L();return k({mutationFn:e=>nt(j(e),!1),onMutate:t=>e.patchRead(()=>j(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function ni(e){let t=L();return k({mutationFn:({id:t,pinned:n})=>v(j(t,e),n),onError:e=>Mt(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??A(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function ri(e,t){let n=L();return k({mutationFn:n=>Ne(j(e,{projectId:t}),n),onMutate:()=>A({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof qe&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function ii(e,t){let n=L();return k({mutationFn:(n={})=>Ce(j(e,{projectId:t}),n),onMutate:()=>A({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function ai(e){let t=S();return k({mutationFn:({msgId:t,message:n})=>Ye(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function oi(e){let t=S();return k({mutationFn:t=>pt(e,t),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function si(e={},t=!0){let n=S(),i=J.github(e);E(`/api/v1/p/${r()}/github${e.limit===void 0?``:`?limit=${e.limit}`}`,i,a(t?6e4:!1));let o=T({queryKey:J.github(e),queryFn:({signal:t})=>b({limit:e.limit},{signal:t}),enabled:t,staleTime:6e4,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),s=o.data?.projectsGeneration,c=T({queryKey:[...i,`projects`,s],queryFn:({signal:e})=>ot(s,{signal:e}),enabled:t&&o.data?.projectsState===`refreshing`&&!!s,staleTime:1/0,retry:!1});return(0,D.useEffect)(()=>{!s||!c.data&&!c.error||n.setQueryData(i,e=>{if(!e||e.projectsGeneration!==s||e.projectsState!==`refreshing`)return e;let t=c.data;return t?.generation&&t.generation!==s?e:t?.state===`ready`?{...e,projectsState:`ready`,projects:t.projects,issues:e.issues.map(e=>({...e,projectIds:t.membership?.[e.number]??[]}))}:{...e,projectsState:`unavailable`,projectsReason:t?.reason??`Project boards unavailable. Refresh to try again.`}})},[n,s,c.data,c.error,i]),o}var ci=class extends Error{};function li(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await b({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new ci(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>Pn(e),retry:(e,t)=>!(t instanceof ci)&&!(t instanceof qe&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function ui(e=50,t=!0){let n=S(),i=J.githubPages(e),o=J.githubPagesHead(e);E(`/api/v1/p/${r()}/github?limit=${e}`,o,a(t?6e4:!1));let s=w({...li(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),c=T({queryKey:o,queryFn:({signal:t})=>b({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:l}=s;(0,D.useEffect)(()=>{if(!c.data)return;let e=n.getQueryData(i);if(!e||e.pages.length===0)return;let t=Rn(e.pages,c.data);t===`refetch`?l():n.setQueryData(i,{...e,pages:t})},[n,c.dataUpdatedAt,l]);let u=(s.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),d=O({queries:u.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>ot(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,D.useEffect)(()=>{d.forEach((e,t)=>{let r=u[t];!r||!e.data&&!e.error||n.setQueryData(i,t=>{if(!t)return t;let n=!1,i=t.pages.map(t=>{if(t.projectsGeneration!==r||t.projectsState!==`refreshing`)return t;let i=e.data;return i?.generation&&i.generation!==r?t:(n=!0,i?.state===`ready`?{...t,projectsState:`ready`,projects:i.projects,issues:t.issues.map(e=>({...e,projectIds:i.membership?.[e.number]??[]}))}:{...t,projectsState:`unavailable`,projectsReason:i?.reason??`Project boards unavailable. Refresh to try again.`})});return n?{...t,pages:i}:t})})},[n,d.map((e,t)=>e.data||e.error?u[t]:``).join(`,`)]),{pages:s,data:(0,D.useMemo)(()=>Ln(s.data?.pages??[]),[s.data])}}function di(e,t=50,n=!0){let r=w({...li([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,D.useMemo)(()=>Ln(r.data?.pages??[]),[r.data])}}function fi(e,t,n=!0){let r=O({queries:t.filter(e=>e.length>0).map(t=>({queryKey:J.githubCommentCounts(e,t),queryFn:({signal:n})=>_e(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,D.useMemo)(()=>{let e={};for(let t of r)t.data?.available&&Object.assign(e,t.data.counts);return e},[r.map(e=>e.dataUpdatedAt).join(`,`)])}function pi(e,t,n,r=!0){return T({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>Je(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function mi(e,t=!0){return T({queryKey:J.githubChecks(e),queryFn:({signal:t})=>ye(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function hi(e,t,n=!0){return T({queryKey:J.githubSearch(e,t),queryFn:({signal:n})=>Je(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var gi=100;function _i(e){return[...e].sort((e,t)=>t-e).slice(0,gi).sort((e,t)=>e-t)}function vi(){let e=ft(),t=$();return e.projectId??t.data?.bootProject}function yi(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))H(G({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))H(G({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var bi=5*6e4;function xi(e){return e?e.recheckAfterMs:bi}function Si(e,t=!0){let n=(0,D.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.projectId)??{prs:new Set,issues:new Set};e[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(n.projectId,e)}return[...t.entries()].map(([e,t])=>({projectId:e,prs:_i(t.prs),issues:_i(t.issues)}))},[e.map(G).sort().join(`|`)]),r=O({queries:n.map(e=>({queryKey:J.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>mt(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>xi(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),a=S(),o=JSON.stringify(n.map((e,t)=>({...e,interval:xi(r[t]?.data)??!1})));(0,D.useEffect)(()=>{if(!t||i())return;let e=!0,n=JSON.parse(o).filter(e=>e.interval!==!1).map(t=>{let n=new URLSearchParams;t.prs.length&&n.set(`prs`,t.prs.join(`,`)),t.issues.length&&n.set(`issues`,t.issues.join(`,`));let r=J.githubRefStatus(t.projectId,t.prs,t.issues);return At({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||a.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&a.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,o,a]);let s=(0,D.useMemo)(()=>On(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,D.useCallback)(e=>{let t=G(e),n=s.get(t);if(n)return n;let r=V.get(t);return{state:`idle`,...r?{status:r}:{},...U.has(t)?{conflicting:!0}:{}}},[s])}function Ci(e,t,n=!0){return T({queryKey:J.githubComments(e,t),queryFn:({signal:n})=>xe(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function wi(e,t,n=!0){return T({queryKey:J.githubItem(e,t),queryFn:({signal:n})=>le(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Ti(e){return T({queryKey:J.githubPrChanges(e??0),queryFn:({signal:t})=>Ie(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{vi as $,ui as A,rr as At,ni as B,jn as Bt,Gn as C,vr as Ct,Ci as D,Pr as Dt,fi as E,ri as Et,ei as F,Xr as Ft,Cr as G,B as Gt,pi as H,An as Ht,ti as I,Ur as It,Wr as J,j as Jt,yr as K,L as Kt,tr as L,Y as Lt,hi as M,Qn as Mt,$ as N,Ir as Nt,wi as O,er as Ot,fr as P,Zr as Pt,cr as Q,mr as R,zn as Rt,Dr as S,hr as St,mi as T,ar as Tt,Rr as U,hn as Ut,di as V,Mn as Vt,pr as W,_n as Wt,Vn as X,Nt as Xt,Wn as Y,k as Yt,Yr as Z,nr as _,Er as _t,qr as a,$n as at,br as b,Bn as bt,gr as c,zr as ct,Ar as d,Un as dt,Si as et,Fr as f,Sr as ft,ii as g,wr as gt,sr as h,jr as ht,or as i,qn as it,Ti as j,Jn as jt,dr as k,Kr as kt,Or as l,Br as lt,Hr as m,Mr as mt,J as n,Kn as nt,Jr as o,oi as ot,lr as p,Tr as pt,Gr as q,A as qt,yi as r,ir as rt,Qr as s,Lr as st,X as t,Hn as tt,kr as u,Vr as ut,ur as v,Nr as vt,si as w,_r as wt,ai as x,Z as xt,Zn as y,xr as yt,$r as z,Fn as zt};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{A as n,M as r}from"./button-RJMdCnZw.js";import{n as i,t as a}from"./live-refetch-CZb2VOyu.js";import{$ as o,$r as s,$t as c,At as l,B as u,Ci as d,Cr as f,Ct as p,Dt as m,Et as h,F as g,Ft as _,Ht as v,I as y,J as b,Jr as ee,K as te,Kr as ne,Kt as re,L as ie,Or as ae,Ot as oe,P as se,Pr as ce,Q as le,Qr as ue,R as de,St as fe,Tt as pe,V as me,Vt as he,W as ge,X as _e,Xr as ve,Y as ye,Yr as be,Z as xe,Zr as Se,_ as Ce,_i as x,_t as we,an as Te,at as Ee,b as De,bi as Oe,bn as ke,c as Ae,cn as je,ct as Me,dn as Ne,dt as Pe,en as Fe,et as Ie,f as Le,fi as Re,ft as ze,g as Be,gn as Ve,gr as He,gt as Ue,hi as We,hn as Ge,ht as Ke,i as qe,it as Je,j as Ye,jt as Xe,kr as Ze,kt as Qe,ln as $e,lt as et,m as tt,mn as nt,mt as rt,ni as it,nn as at,nt as ot,oi as st,ot as ct,pt as lt,q as ut,qr as dt,r as ft,rn as pt,rt as mt,si as ht,st as gt,ti as S,tn as _t,ui as vt,un as yt,ut as bt,v as xt,vn as St,vt as Ct,wt,x as Tt,xn as Et,yi as Dt,yt as Ot,z as kt}from"./project-scope-context-Xjbxntpg.js";import{q as C}from"./live-protocol-CjfZMf1X.js";import{t as w}from"./useInfiniteQuery-C05yR_S9.js";import{t as T}from"./useQuery-7jNqNIJb.js";import{n as At,r as E,t as jt}from"./ws-wEXmfalm.js";import{n as Mt}from"./toaster-BWMQArHJ.js";var Nt=class extends st{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Pt(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=ht({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),C.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Pt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Ft=class extends d{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),Dt(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&vt(t.mutationKey)!==vt(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Pt();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){C.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function It(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Lt(e,t,n){let r=e.slice(0);return r[t]=n,r}var Rt=class extends d{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,C.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!Dt(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(It(e,n).forEach(e=>{e.destroy()}),It(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=x(this.#a,t(e))),this.#a}return e}#f(){return this.#r?.combine!==void 0&&this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new it(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Lt(this.#t,n,t),this.#h())}#h(){if(this.hasListeners()){let e=this.#u(this.#t,this.#l),t=this.#f(),n=this.#a,r=t?n:this.#d(e,this.#r?.combine);(t||n!==r)&&C.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},D=e(t(),1);function O({queries:e,...t},n){let r=S(n),i=s(),a=ue(),o=D.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{ne(e);let t=r.getQueryCache().get(e.queryHash);be(e,a,t)}),Se(a);let[c]=D.useState(()=>new Rt(r,o,t)),[l,u,d]=c.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;D.useSyncExternalStore(D.useCallback(e=>f?c.subscribe(C.batchCalls(e)):We,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),D.useEffect(()=>{c.setQueries(o,t)},[o,t,c]);let p=l.some((e,t)=>ee(o[t],e))?l.flatMap((e,t)=>{let n=o[t];return n&&ee(n,e)?dt(n,new it(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=l.find((e,t)=>{let n=o[t];return n&&ve({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return u(d())}function k(e,t){let n=S(t),[r]=D.useState(()=>new Ft(n,e));D.useEffect(()=>{r.setOptions(e)},[r,e]);let i=D.useSyncExternalStore(D.useCallback(e=>r.subscribe(C.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=D.useCallback((e,t)=>{r.mutate(e,t).catch(We)},[r]);if(i.error&&Oe(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function A(e={}){let t=e.projectId??r();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function j(e,t={}){return{...A(t),runId:e}}var M=[`workspace`,`runs-index`],N=e=>[e.cacheScope,`runs`,`list`],P=e=>[e.cacheScope,`runs`,`detail`,e.runId],F=e=>typeof e==`function`?e():e;function zt(e){let{seenAt:t,...n}=e;return n}function Bt(e,t){let n=zt(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function I(e,t,n){return t?{...e,seenAt:n}:zt(e)}function Vt(e){let t=()=>{e.invalidateQueries({queryKey:M})};function n(n,i){if(n===`index`)return t();let a=typeof i==`function`?i():i;if(n===`indexed`){t(),e.invalidateQueries({queryKey:[r(),`runs`]}),e.invalidateQueries({queryKey:[a.projectId,`runs`,`list`]});return}if(n===`runs`)return e.invalidateQueries({queryKey:[a.cacheScope,`runs`]});let o=Ze(),s=[a.projectId,a.cacheScope],c=o!==void 0&&s.some(e=>e===o||e==="default")?[o,`default`]:[],l=new Set([...s,...c,r()]);return Promise.all([...l].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}async function i(n,r){await e.cancelQueries({queryKey:N(F(n))}),await e.cancelQueries({queryKey:P(F(n))});let i=e.getQueryData(N(F(n))),a=e.getQueryData(P(F(n))),o=F(n).runId,s=new Date().toISOString();return e.setQueryData(N(F(n)),e=>e?.map(e=>e.id===o?I(e,r,s):e)),e.setQueryData(P(F(n)),e=>e&&I(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(N(F(n)),i),a&&e.setQueryData(P(F(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(N(F(n)),e=>e?.map(e=>e.id===o?Bt(e,t):e)),a&&e.setQueryData(P(F(n)),e=>e&&Bt(e,a))},settle(i){let a=e=>e.id===(r?o:i.id)?I(e,r,i.seenAt):e;e.setQueryData(N(F(n)),e=>e?.map(a));let s={...F(n),runId:r?o:i.id};e.setQueryData(P(s),e=>e?a(e):i),t()}}}async function a(t,r){await e.cancelQueries({queryKey:M});let i=e.getQueryData(M),a=r();return e.setQueryData(M,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.projectId===t.projectId&&e.id===t.runId?a(e):e)}),{previous:i,rollback(){i&&e.setQueryData(M,i)},settle(){n(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:n}}function L(){let e=S();return(0,D.useMemo)(()=>Vt(e),[e])}function Ht(e){return e.type===`run`?e.run.id:e.id}function R(e,t){return{...e,runs:t}}function Ut(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}function Wt(e,t){let n=e.findIndex(e=>(e.createdAt??``).localeCompare(t.createdAt)<0),r=[...e];return r.splice(n<0?e.length:n,0,t),r}function Gt(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function Kt(e,t,n){let{project:r}=t,i=Ht(t),a=e.runs.findIndex(e=>e.projectId===r&&e.id===i),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(r);if(t.type===`deleted`)return o?{index:R(e,e.runs.filter((e,t)=>t!==a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:R(e,e.runs.filter((e,t)=>t!==a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!Gt(e,r,n))return{index:e,reconcile:!0};let l=x(o,{projectId:r,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=[...e.runs];t[a]=l;let n=o.archived!==l.archived&&(s||Ut(t,r)>e.perProjectLimit);return{index:R(e,t),reconcile:n}}if(s)return Jt(e,l);let u=Wt(e.runs,l);return{index:R(e,u),reconcile:l.archived&&Ut(u,r)>e.perProjectLimit}}function qt(e,t){let n;for(let r of e)r.projectId===t&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function Jt(e,t){let n=qt(e.runs,t.projectId),r=n!==void 0&&t.createdAt>n;return t.archived&&!r?{index:e,reconcile:!1}:{index:R(e,Wt(e.runs,t)),reconcile:t.archived||n===void 0||t.createdAt<n}}function Yt(e,t,n){let r=!1,i=e.runs.map(e=>{if(e.projectId!==t)return e;let i=n[e.id];if(i){let t=x(e.usage,i);return t===e.usage?e:(r=!0,{...e,usage:t})}if(e.usage===void 0)return e;r=!0;let{usage:a,...o}=e;return o});return r?R(e,i):e}function Xt(e,t){let n=e.runs.filter(e=>e.projectId!==t),r=e.truncated.filter(e=>e!==t),i=Object.prototype.hasOwnProperty.call(e.referenceStatuses,t);if(n.length===e.runs.length&&r.length===e.truncated.length&&!i)return e;let a={...e.referenceStatuses};return delete a[t],{...e,runs:n,truncated:r,referenceStatuses:a}}function Zt(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function Qt(e,t,n){if(e.lastStream===t)e.floor=Math.max(e.floor??n,n);else{for(let[n,r]of e.changes)r.generation!==t&&e.changes.delete(n);e.floor=n}e.stream=t,e.lastStream=t,e.mismatch=void 0}function $t(e){e.stream=void 0}function en(e,t,n=!1){let r=e.stream;if(r===void 0)return!1;(e.floor===void 0||n)&&(e.floor=t.seq-1);let i=JSON.stringify([r,t.project,Ht(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function tn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function nn(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function rn(e,t,n){if(!nn(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t;if(e.stream!==void 0&&e.stream!==r){let n=e.mismatch!==r;return e.mismatch=r,{index:t,reconcile:n}}let a=e.lastStream===r&&e.floor!==void 0,o=a&&i<e.floor,s=t,c=o,l=[...e.changes.entries()].filter(([,e])=>e.generation===r),u=l.map(([,e])=>e).filter(e=>e.seq>i).sort((e,t)=>e.seq-t.seq);for(let e of u){let t=Kt(s,e,n);s=t.index,c||=t.reconcile}for(let[t,n]of l)n.seq<=i&&e.changes.delete(t);return a&&!o&&(e.floor=i),{index:s,reconcile:c}}var z=[`workspace`,`runs-index`],an=[`workspace`,`projects`],on=6e4,sn=100,cn=new WeakMap;function B(e){let t=cn.get(e);return t||(t=pn(e),cn.set(e,t)),t}function ln(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:B(t).merge(e)}function un(e){let t=e.getQueryData(an)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function dn(e,t,n){if(!(!e||typeof e.eventSeq!=`number`||typeof t.eventSeq!=`number`))return e.generation===t.generation?t.eventSeq<e.eventSeq?e:void 0:n!==void 0&&e.generation===n&&t.generation!==n?e:void 0}function fn(e,t){return t.type===`run-summary`?{type:`run`,project:e,seq:t.seq,run:t.summary}:{type:`deleted`,project:e,seq:t.seq,id:t.id}}function pn(e){let t=Zt(),n=[],r,i,a,o,s=!1,c=-1/0,l=new Set,u=!1,d,f=!1,p=()=>{if(!u){if(u=!0,d?.()){f=!0;return}_({hold:!0})}},m=t=>{c=Date.now(),e.setQueryData(z,t)},h=()=>e.getQueryData(z),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:z,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:z,exact:!0}).then(()=>e.invalidateQueries({queryKey:z})):e.invalidateQueries({queryKey:z})).catch(()=>void 0).finally(()=>{o===n&&(o=void 0,s&&(s=!1,g()))});return o=n,n},_=(e={})=>o?(s=!0,o):e.hold?(a??=setTimeout(()=>{g()},400),Promise.resolve()):g(),v=()=>{r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0;let t=n;n=[];let a=h();if(!a||t.length===0)return;let o=un(e),s=a,c=!1;for(let e of t){if(e.generation!==a.generation)continue;if(e.type===`usage`){l.has(e.project)||(s=Yt(s,e.project,e.usage));continue}if(l.has(e.change.project)||e.change.seq<=a.eventSeq)continue;let t=Kt(s,e.change,o);s=t.index,c||=t.reconcile}s!==a&&m(s),c&&_({hold:!0})},y=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,sn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){Qt(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){$t(t)},run(e,r,i=!1){if(l.has(e))return;let a=fn(e,r);if(!en(t,a,i)){p();return}n.push({type:`change`,change:a,generation:t.stream}),y()},usage(e,r){if(!l.has(e)){if(t.stream===void 0){p();return}n.push({type:`usage`,project:e,usage:r,generation:t.stream}),y()}},dropProject(e){l.add(e),tn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=Xt(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=rn(t,n,un(e));for(let e of l)i.index=Xt(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),dn(r,n,t.stream)??i.index},reconcile:_,flush:v,stop(){r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0,clearTimeout(a),a=void 0,n=[],s=!1}}}var mn={draft:{label:`Draft`,hint:`the author has not marked it ready for review`,tone:`neutral`},"review-required":{label:`Waiting for review`,hint:`checks are fine, no one has reviewed it yet`,tone:`info`},"changes-requested":{label:`Changes requested`,hint:`a reviewer asked for edits before this can merge`,tone:`danger`},"checks-pending":{label:`Checks running`,hint:`CI has not finished on the latest commit`,tone:`pending`},"checks-failing":{label:`Checks failing`,hint:`CI is red on the latest commit`,tone:`danger`},ready:{label:`Ready to merge`,hint:`open, checks pass, nothing is waiting on a reviewer`,tone:`success`},merged:{label:`Merged`,hint:`this landed on its base branch`,tone:`merged`},closed:{label:`Closed`,hint:`closed without merging — the work did not land`,tone:`danger`},open:{label:`Open`,hint:`still open on the tracker`,tone:`success`},completed:{label:`Closed as completed`,hint:`the issue was resolved`,tone:`accent`},"not-planned":{label:`Closed as not planned`,hint:`the issue was declined — nothing shipped for it`,tone:`neutral`}},hn={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function gn(e){return typeof e==`string`&&Object.hasOwn(mn,e)}function _n(e){return e!==void 0&&gn(e)?mn[e]:void 0}var vn=`cez.reference-statuses.v1`,yn=`cez.reference-conflicts.v1`,V=new Map(Sn()),bn=1e3;function H(e,t){if(V.get(e)!==t){for(V.delete(e),V.set(e,t);V.size>bn;){let e=V.keys().next().value;if(e===void 0)break;V.delete(e)}wn()}}var U=new Set(Cn());function xn(e,t){if(U.has(e)!==t){if(t)for(U.add(e);U.size>bn;){let e=U.values().next().value;if(e===void 0)break;U.delete(e)}else U.delete(e);wn()}}function Sn(){try{let e=globalThis.sessionStorage?.getItem(vn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`&&gn(e[1])):[]}catch{return[]}}function Cn(){try{let e=globalThis.sessionStorage?.getItem(yn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var W;function wn(){W===void 0&&(W=setTimeout(()=>{W=void 0;try{globalThis.sessionStorage?.setItem(vn,JSON.stringify([...V])),globalThis.sessionStorage?.setItem(yn,JSON.stringify([...U]))}catch{}},250))}var G=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function K(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function Tn(e){return[...e.prs.map(t=>({projectId:e.projectId,kind:`PR`,number:t})),...e.issues.map(t=>({projectId:e.projectId,kind:`Issue`,number:t}))]}function En(e,t,n,r,i,a){let o=r.prs[n.number]??r.issues[n.number];if(!o){e.set(t,{state:`unknown`,...i?{status:i}:{}});return}let s=r.conflicts?r.conflicts.includes(n.number):void 0;H(t,o),s!==void 0&&xn(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function Dn(e,t,n){let r=G(t),i=V.get(r),a=U.has(r)?!0:void 0,o=n.data;if(o?.available){En(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...K(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...K(i,a)});return}e.set(r,{state:`loading`,...K(i,a)})}function On(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of Tn(i))Dn(n,e,t)}),n}async function kn(e,t=!1){return Ve(await Le.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:r(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),je(e,`/worker-destroy`))}function An(e){if(!e)return;let t=e.trim().replace(/\/+$/,``),n=/^(?:https?|ssh|git|git\+ssh):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+)$/.exec(t),r=n?null:/^(?:[^@/:]+@)?([^:/]+):(.+)$/.exec(t),i=n??r;if(!i)return;let[,a,o]=i;if(!o||a?.toLowerCase()!==`github.com`)return;let s=o.replace(/\.git$/i,``).split(`/`).filter(Boolean),c=s[s.length-2],l=s[s.length-1];return c&&l?`https://github.com/${c}/${l}`:void 0}function jn(e){let t=new Map;for(let n of e)for(let e of n.tags??[]){let n=e.toLowerCase();t.has(n)||t.set(n,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function Mn(e,t,n,r=8){let i=n.trim().toLowerCase(),a=new Set(t.map(e=>e.toLowerCase())),o=e.filter(e=>{let t=e.toLowerCase();return a.has(t)?!1:i===``||t.includes(i)&&t!==i});return i===``?o.slice(0,r):o.sort((e,t)=>Number(t.toLowerCase().startsWith(i))-Number(e.toLowerCase().startsWith(i))||e.localeCompare(t,void 0,{sensitivity:`base`})).slice(0,r)}function Nn(e){let t=new Map;for(let n of e){let e=n.trim();if(!e)continue;let r=e.toLowerCase();t.has(r)||t.set(r,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function Pn(e){if(!e.available)return;let t=e.issuesNextCursor,n=e.prsNextCursor;if(!(t===void 0&&n===void 0)&&!(!t&&!n))return{...t?{issuesCursor:t}:{issuesDone:!0},...n?{prsCursor:n}:{prsDone:!0}}}function Fn(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function In(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function Ln(e){let t=e[0];if(!t)return;let n=e[e.length-1],r=[],i=[],a=new Set,o=new Set,s={};for(let t of e){In(t.issues,a,r),In(t.prs,o,i);for(let[e,n]of Object.entries(t.labelColors??{}))s[e]??=n}let c=e.find(e=>e.projects)?.projects,l=e.map(e=>e.projectsState),u=e.find(e=>e.projectsState===`unavailable`),d=l.includes(`refreshing`)?`refreshing`:u?`unavailable`:l.some(e=>e===`ready`)?`ready`:void 0,{projectsGeneration:f,projectsReason:p,...m}=t;return{...m,issues:r,prs:i,...Object.keys(s).length>0?{labelColors:s}:{},...c?{projects:c}:{},...d?{projectsState:d}:{},...d===`unavailable`&&u?.projectsReason?{projectsReason:u.projectsReason}:{},...`issuesNextCursor`in n?{issuesNextCursor:n.issuesNextCursor}:{},...`prsNextCursor`in n?{prsNextCursor:n.prsNextCursor}:{}}}var q=e=>e.map(e=>e.number).join(`,`);function Rn(e,t){let n=e[0];if(e.length>1&&n&&(q(n.issues)!==q(t.issues)||q(n.prs)!==q(t.prs)||n.issuesTotal!==t.issuesTotal||n.prsTotal!==t.prsTotal))return`refetch`;let r=t;if(n&&t.available&&t.projectsState===`refreshing`&&n.repo===t.repo){let e=new Map(n.issues.map(e=>[e.number,e.projectIds]));r={...t,issues:t.issues.map(t=>{let n=e.get(t.number);return t.projectIds===void 0&&n!==void 0?{...t,projectIds:n}:t})}}return[r,...e.slice(1)]}function zn(e,t,n=!0){let i=Ur(),a=$(),o=e??i.data?.defaultRunner??`claude`,s=a.data?.capabilities?.localHandoff===!1?null:t,c=r(),l=T({queryKey:J.runnerSkills(o,s),queryFn:({signal:e})=>wt(o,s,{signal:e,projectId:c}),enabled:n&&(e!==void 0||!i.isPending)&&(!t||!a.isPending),retry:!1});return{...l,runner:o,account:s,data:l.data?.skills,list:l.data,unchecked:l.isError||!l.data||l.data.source===`unavailable`}}var J={get health(){return[r(),`health`]},runs:{get all(){return[r(),`runs`]},relationships:e=>[r(),`runs`,`relationships`,e],list:(e=r())=>[e,`runs`,`list`],archived:e=>[r(),`runs`,`archived`,e],detail:(e,t=r())=>[t,`runs`,`detail`,e],diff:e=>[r(),`runs`,`diff`,e],changes:e=>[r(),`runs`,`changes`,e],file:(e,t)=>[r(),`runs`,`files`,e,t],handoff:e=>[r(),`runs`,`handoff`,e],commits:e=>[r(),`runs`,`commits`,e],commit:(e,t)=>[r(),`runs`,`commit`,e,t]},get workflows(){return[r(),`workflows`]},runnerSkills:(e,t)=>[r(),`runner-skills`,e,t??null],get repo(){return[r(),`repo`]},get repoChanges(){return[r(),`repo`,`changes`]},repoCommit:e=>[r(),`repo`,`commit`,e],get repoBranches(){return[r(),`repo`,`branches`]},get uiState(){return[r(),`ui-state`]},get config(){return[r(),`config`]},get agentConfig(){return[r(),`agent-config`]},agentConfigFile:e=>[r(),`agent-config`,`file`,e],get worktrees(){return[r(),`worktrees`]},github:(e={})=>[r(),`github`,e.limit??null],githubPages:e=>[r(),`github`,`pages`,e],githubPagesHead:e=>[r(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[r(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],githubChecks:e=>[r(),`github`,`checks`,[...e].sort((e,t)=>e-t).join(`,`)],githubSearch:(e,t)=>[r(),`github`,`search`,e,t],githubRefStatus:(e,t,n)=>[e,`github`,`ref-status`,[...t].sort((e,t)=>e-t).join(`,`),[...n].sort((e,t)=>e-t).join(`,`)],githubComments:(e,t)=>[r(),`github`,`comments`,e,t],githubItem:(e,t)=>[r(),`github`,`item`,e,t],githubRefStatusOf:e=>[e,`github`,`ref-status`],githubPrChanges:e=>[r(),`github`,`pr-changes`,e],githubMergeState:e=>[r(),`github`,`merge-state`,e],get openTargets(){return[r(),`open-targets`]}},Y={models:e=>[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:z,runsSearch:e=>[`workspace`,`runs-search`,e],uiState:[`workspace`,`ui-state`],config:[`workspace`,`config`],agentProfiles:[`workspace`,`agent-profiles`],agentAccountStatus:e=>[`workspace`,`agent-profiles`,`status`,e],fsBrowseRoot:[`workspace`,`fs-browse`],fsBrowse:(e,t=!1)=>[...Y.fsBrowseRoot,e,t]};function X(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:Y.models(t),refetchType:n})}function Bn(e,t=!0){return T({...Vn(e),enabled:t})}var Vn=e=>({queryKey:Y.models(e),queryFn:({signal:t})=>p(e,{signal:t}),staleTime:300*1e3});function Hn(e,t=!0){let n=O({queries:e.map(e=>({...Vn(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}function Un(){let e=S();return T({queryKey:Y.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(Y.providerStatus),r=await Me(!1,{signal:t});return f(n,e.getQueryData(Y.providerStatus),r)},staleTime:5*6e4,refetchInterval:a(!1),refetchOnWindowFocus:!0})}function Wn(){let e=S();return k({mutationFn:()=>Me(!0),onMutate:()=>e.getQueryData(Y.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Y.providerStatus,e=>f(r,e,t)),X(e)}})}function Gn(){let e=S();return k({mutationFn:({provider:e,authFailureId:t})=>Te(e,t),onMutate:()=>e.getQueryData(Y.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Y.providerStatus,e=>f(r,e,t,n.authFailureId)),X(e,n.provider)}})}function Kn(e={}){return T({queryKey:Y.projects,queryFn:({signal:e})=>gt({signal:e}),...e})}function qn(e,t=!1){return T({queryKey:Y.fsBrowse(e,t),queryFn:({signal:n})=>Ae(e??void 0,{signal:n,showHidden:t}),retry:!1})}function Jn(){let e=S();return k({mutationFn:e=>c(e),onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function Yn(){let e=S();return k({mutationFn:e=>_t(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:Y.projects})}})}function Xn(){let e=S();return k({mutationFn:e=>{let{id:t,...n}=e;return ke(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:Y.projects});let r=e.getQueryData(Y.projects);return e.setQueryData(Y.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Zn(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(Y.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(Y.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:Y.projects})})}function Zn(e,t){let{maxParallel:n,tags:r,...i}=e,a={...i},o=`maxParallel`in t?t.maxParallel:e.maxParallel;o!=null&&(a.maxParallel=o);let s=`tags`in t&&t.tags!==void 0?t.tags:e.tags,c=s==null?[]:Nn(s);if(c.length>0&&(a.tags=c),`webhook`in t&&t.webhook!==void 0)if(t.webhook===null)delete a.webhook;else{let n=t.webhook.token===void 0?e.webhook?.tokenSet??!1:t.webhook.token!==``;a.webhook={url:t.webhook.url,tokenSet:n}}return a}function Z(e){let t=S();return k({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(Y.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:Y.projects})})}function Qn(){return Z(e=>{let{projectId:t,...n}=e;return Tt(t,n)})}function $n(){return Z(e=>{let{projectId:t,webhookId:n,...r}=e;return Et(t,n,r)})}function er(){return Z(({projectId:e,webhookId:t})=>at(e,t))}function tr(){return k({mutationFn:({projectId:e,webhookId:t})=>Ge(e,t),retry:!1})}function nr(e){let t=S();return k({mutationFn:t=>_(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function Q(e){let t=S();return k({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:Y.agentProfiles}),t.invalidateQueries({queryKey:Y.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`})])}})}function rr(){return Q(e=>xt(e))}function ir(){return Q(e=>{let{id:t,...n}=e;return St(t,n)})}function ar(){return Q(e=>Fe(e))}function or(){return Q(e=>yt(e))}function sr(e,t){return T({queryKey:Y.agentAccountStatus(e),queryFn:({signal:t})=>se(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function cr(){let e=S();return k({mutationFn:({provider:e,profileId:t})=>Be(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:Y.agentProfiles}),e.invalidateQueries({queryKey:Y.providerStatus}),X(e,n,`none`)])}})}function lr(){let e=S();return k({mutationFn:e=>se(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(Y.agentAccountStatus(n),t),e.invalidateQueries({queryKey:Y.agentProfiles}),X(e,t.status.provider)}})}function ur(){let e=S();return k({mutationFn:e=>tt(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function dr(){let e=S();return k({mutationFn:e=>De(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function fr({enabled:e}){return T({queryKey:Y.githubOwners,queryFn:({signal:e})=>o({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function pr(){let e=S();(0,D.useEffect)(()=>{let t,r=()=>{let r=e.getQueryData(J.health),i=r?.capabilities?.localHandoff===!0;r&&ae({local:i,bootProject:r.bootProject??`default`,apiBase:n()}),i&&t===void 0?t=jt(`health`,t=>{e.setQueryData(J.health,t)}):!i&&t!==void 0&&(t(),t=void 0)};r();let i=e.getQueryCache().subscribe(r);return()=>{i(),t?.(),ce()}},[e])}function $(){return T({queryKey:J.health,queryFn:({signal:e})=>Ee({signal:e})})}function mr(e,t){let n=$().data,r=Kn(t).data?.projects,i=ft(),a=e??i.projectId,o=a??n?.bootProject,s=o===void 0?void 0:r?.find(e=>e.id===o);return s?.repoUrl?s.repoUrl:a===null||a===n?.bootProject?An(n?.repo?.remote):void 0}function hr(){return T({queryKey:J.openTargets,queryFn:({signal:e})=>ct({signal:e}),staleTime:5*6e4})}function gr(){return T({queryKey:J.runs.list(),queryFn:({signal:e})=>pe(A(),{signal:e})})}function _r(e,t){return w({queryKey:J.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>de({before:t,limit:200,q:e},{signal:n}),getNextPageParam:e=>e.nextCursor??void 0,placeholderData:(e,t)=>t?.queryKey[0]===r()?e:void 0})}function vr(e){let t=e.trim();return T({queryKey:Y.runsSearch(t),queryFn:({signal:e})=>$e(t,{signal:e}),enabled:t.length>=2,placeholderData:Re,staleTime:1e4})}function yr(e=!0,t=on){let n=B(S());return E(`/api/v1/workspace/runs-index`,Y.runsIndex,a(e?t:!1),ln),T({queryKey:Y.runsIndex,queryFn:({signal:e})=>h({signal:e}).then(n.merge),enabled:e,staleTime:3e4,refetchInterval:!1})}function br(e,t=!0,n=!1){return T({queryKey:[A({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>pe(A({projectId:e,boot:n}),{signal:t}),enabled:t,placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function xr(e){let t=S();return k({mutationFn:({workerId:e,discardWork:t=!1})=>kn(e,t),onSettled:()=>t.invalidateQueries({queryKey:J.runs.relationships(e)})})}function Sr(e,t={}){return T({queryKey:J.runs.relationships(e),queryFn:({signal:t})=>fe(e,{signal:t}),enabled:t.enabled??!0})}function Cr(e){return T({queryKey:J.runs.detail(e??``),queryFn:({signal:t})=>lt(j(e),{signal:t}),enabled:!!e})}function wr(e,t,n=!0){return T({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>lt(j(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t})}function Tr(e){return T({queryKey:J.runs.diff(e??``),queryFn:({signal:t})=>we(e,{signal:t}),enabled:!!e})}function Er(e,t=!1){return E(e?`/api/v1/p/${r()}/runs/${encodeURIComponent(e)}/changes`:void 0,J.runs.changes(e??``),a(t?4e3:!1)),T({queryKey:J.runs.changes(e??``),queryFn:({signal:t})=>rt(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function Dr(e,t){return T({queryKey:J.runs.file(e??``,t??``),queryFn:({signal:n})=>Ct(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function Or(e,t){return T({queryKey:[r(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>ut(e,t,{signal:n}),enabled:t!==null,retry:!1})}function kr(e,t){return T({queryKey:[r(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>kt(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Ar(e,t){return T({queryKey:[r(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>u(e,t,{signal:n}),enabled:t!==null,retry:!1})}function jr(e){return T({queryKey:[r(),`runs`,`artifacts`,e],queryFn:({signal:t})=>me(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function Mr(e,t=!1){return E(e?`/api/v1/p/${r()}/runs/${encodeURIComponent(e)}/commits`:void 0,J.runs.commits(e??``),a(t?5e3:!1)),T({queryKey:J.runs.commits(e??``),queryFn:({signal:t})=>Ue(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function Nr(e,t){return T({queryKey:J.runs.commit(e??``,t??``),queryFn:({signal:n})=>Ke(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function Pr(e,t=!0){return T({queryKey:J.runs.handoff(e??``),queryFn:({signal:t})=>Ot(j(e),{signal:t}),enabled:!!e&&t})}function Fr(e,t,n){return T({queryKey:e===void 0?J.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>Ot(j(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function Ir(e,t){let n=[...new Set(e)],i=O({queries:n.map(e=>({queryKey:[e??r(),`automations`,`names`],queryFn:({signal:t})=>ge({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,D.useMemo)(()=>{let e=new Map;return a.forEach((t,r)=>{if(t?.available)for(let i of t.automations)e.set(JSON.stringify([n[r]??null,i.id]),i.name)}),(t,n)=>e.get(JSON.stringify([t??null,n]))},[JSON.stringify([n,i.map(e=>e.dataUpdatedAt)])])}function Lr(){return T({queryKey:J.workflows,queryFn:({signal:e})=>oe({signal:e})})}function Rr(){return T({queryKey:J.repo,queryFn:({signal:e})=>et({signal:e})})}function zr(e){return T({queryKey:[e,`repo`],queryFn:({signal:t})=>et({signal:t},e)})}function Br(){return T({queryKey:J.repoBranches,queryFn:({signal:e})=>bt({signal:e})})}function Vr(){return T({queryKey:J.repoChanges,queryFn:({signal:e})=>Pe({signal:e}),retry:!1})}function Hr(e){return T({queryKey:J.repoCommit(e??``),queryFn:({signal:t})=>ze(e,{signal:t}),enabled:!!e,retry:!1})}function Ur(){return T({queryKey:J.config,queryFn:({signal:e})=>te({signal:e})})}function Wr(){return T({queryKey:J.worktrees,queryFn:({signal:e})=>Xe({signal:e})})}function Gr(e){return T({queryKey:[e,`worktrees`],queryFn:({signal:t})=>Xe({signal:t},e),staleTime:0})}function Kr(e,t=!0,n=!1){return T({queryKey:[A({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>m({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:He(e.sidebarLimits)},enabled:t})}function qr(){return Kr(r())}function Jr(){return T({queryKey:J.agentConfig,queryFn:({signal:e})=>g({signal:e})})}function Yr(e){return T({queryKey:J.agentConfigFile(e??``),queryFn:({signal:t})=>y(e,{signal:t}),enabled:e!==null})}function Xr(e){let t=S(),n=J.agentConfig,r=J.agentConfigFile(e);return k({mutationFn:t=>re(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}function Zr(){return T({queryKey:Y.uiState,queryFn:({signal:e})=>l({signal:e})})}function Qr(){return T({queryKey:Y.config,queryFn:({signal:e})=>Qe({signal:e})})}function $r(){return T({queryKey:Y.agentProfiles,queryFn:({signal:e})=>ie({signal:e})})}function ei(e){let t=S();return k({mutationFn:t=>he(e,t),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function ti(e){let t=L(),n=e?.projectId,r=e?.cacheScope,i=k({mutationFn:e=>nt(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,D.useCallback)(e=>({...j(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,D.useCallback)(e=>({onSuccess:(t,n,r,i)=>e?.onSuccess?.(t,n.id,r,i),onError:(t,n,r,i)=>e?.onError?.(t,n.id,r,i),onSettled:(t,n,r,i,a)=>e?.onSettled?.(t,n,r.id,i,a)}),[]),{mutate:s,mutateAsync:c}=i,l=(0,D.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,D.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function ni(){let e=L();return k({mutationFn:e=>nt(j(e),!1),onMutate:t=>e.patchRead(()=>j(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function ri(e){let t=L();return k({mutationFn:({id:t,pinned:n})=>v(j(t,e),n),onError:e=>Mt(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??A(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function ii(e,t){let n=L();return k({mutationFn:n=>Ne(j(e,{projectId:t}),n),onMutate:()=>A({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof qe&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function ai(e,t){let n=L();return k({mutationFn:(n={})=>Ce(j(e,{projectId:t}),n),onMutate:()=>A({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function oi(e){let t=S();return k({mutationFn:({msgId:t,message:n})=>Ye(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function si(e){let t=S();return k({mutationFn:t=>pt(e,t),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function ci(e={},t=!0){let n=S(),i=J.github(e);E(`/api/v1/p/${r()}/github${e.limit===void 0?``:`?limit=${e.limit}`}`,i,a(t?6e4:!1));let o=T({queryKey:J.github(e),queryFn:({signal:t})=>b({limit:e.limit},{signal:t}),enabled:t,staleTime:6e4,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),s=o.data?.projectsGeneration,c=T({queryKey:[...i,`projects`,s],queryFn:({signal:e})=>ot(s,{signal:e}),enabled:t&&o.data?.projectsState===`refreshing`&&!!s,staleTime:1/0,retry:!1});return(0,D.useEffect)(()=>{!s||!c.data&&!c.error||n.setQueryData(i,e=>{if(!e||e.projectsGeneration!==s||e.projectsState!==`refreshing`)return e;let t=c.data;return t?.generation&&t.generation!==s?e:t?.state===`ready`?{...e,projectsState:`ready`,projects:t.projects,issues:e.issues.map(e=>({...e,projectIds:t.membership?.[e.number]??[]}))}:{...e,projectsState:`unavailable`,projectsReason:t?.reason??`Project boards unavailable. Refresh to try again.`}})},[n,s,c.data,c.error,i]),o}var li=class extends Error{};function ui(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await b({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new li(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>Pn(e),retry:(e,t)=>!(t instanceof li)&&!(t instanceof qe&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function di(e=50,t=!0){let n=S(),i=J.githubPages(e),o=J.githubPagesHead(e);E(`/api/v1/p/${r()}/github?limit=${e}`,o,a(t?6e4:!1));let s=w({...ui(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),c=T({queryKey:o,queryFn:({signal:t})=>b({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:l}=s;(0,D.useEffect)(()=>{if(!c.data)return;let e=n.getQueryData(i);if(!e||e.pages.length===0)return;let t=Rn(e.pages,c.data);t===`refetch`?l():n.setQueryData(i,{...e,pages:t})},[n,c.dataUpdatedAt,l]);let u=(s.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),d=O({queries:u.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>ot(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,D.useEffect)(()=>{d.forEach((e,t)=>{let r=u[t];!r||!e.data&&!e.error||n.setQueryData(i,t=>{if(!t)return t;let n=!1,i=t.pages.map(t=>{if(t.projectsGeneration!==r||t.projectsState!==`refreshing`)return t;let i=e.data;return i?.generation&&i.generation!==r?t:(n=!0,i?.state===`ready`?{...t,projectsState:`ready`,projects:i.projects,issues:t.issues.map(e=>({...e,projectIds:i.membership?.[e.number]??[]}))}:{...t,projectsState:`unavailable`,projectsReason:i?.reason??`Project boards unavailable. Refresh to try again.`})});return n?{...t,pages:i}:t})})},[n,d.map((e,t)=>e.data||e.error?u[t]:``).join(`,`)]),{pages:s,data:(0,D.useMemo)(()=>Ln(s.data?.pages??[]),[s.data])}}function fi(e,t=50,n=!0){let r=w({...ui([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,D.useMemo)(()=>Ln(r.data?.pages??[]),[r.data])}}function pi(e,t,n=!0){let r=O({queries:t.filter(e=>e.length>0).map(t=>({queryKey:J.githubCommentCounts(e,t),queryFn:({signal:n})=>_e(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,D.useMemo)(()=>{let e={};for(let t of r)t.data?.available&&Object.assign(e,t.data.counts);return e},[r.map(e=>e.dataUpdatedAt).join(`,`)])}function mi(e,t,n,r=!0){return T({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>Je(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function hi(e,t=!0){return T({queryKey:J.githubChecks(e),queryFn:({signal:t})=>ye(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function gi(e,t,n=!0){return T({queryKey:J.githubSearch(e,t),queryFn:({signal:n})=>Je(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var _i=100;function vi(e){return[...e].sort((e,t)=>t-e).slice(0,_i).sort((e,t)=>e-t)}function yi(){let e=ft(),t=$();return e.projectId??t.data?.bootProject}function bi(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))H(G({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))H(G({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var xi=5*6e4;function Si(e){return e?e.recheckAfterMs:xi}function Ci(e,t=!0){let n=(0,D.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.projectId)??{prs:new Set,issues:new Set};e[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(n.projectId,e)}return[...t.entries()].map(([e,t])=>({projectId:e,prs:vi(t.prs),issues:vi(t.issues)}))},[e.map(G).sort().join(`|`)]),r=O({queries:n.map(e=>({queryKey:J.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>mt(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>Si(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),a=S(),o=JSON.stringify(n.map((e,t)=>({...e,interval:Si(r[t]?.data)??!1})));(0,D.useEffect)(()=>{if(!t||i())return;let e=!0,n=JSON.parse(o).filter(e=>e.interval!==!1).map(t=>{let n=new URLSearchParams;t.prs.length&&n.set(`prs`,t.prs.join(`,`)),t.issues.length&&n.set(`issues`,t.issues.join(`,`));let r=J.githubRefStatus(t.projectId,t.prs,t.issues);return At({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||a.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&a.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,o,a]);let s=(0,D.useMemo)(()=>On(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,D.useCallback)(e=>{let t=G(e),n=s.get(t);if(n)return n;let r=V.get(t);return{state:`idle`,...r?{status:r}:{},...U.has(t)?{conflicting:!0}:{}}},[s])}function wi(e,t,n=!0){return T({queryKey:J.githubComments(e,t),queryFn:({signal:n})=>xe(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Ti(e,t,n=!0){return T({queryKey:J.githubItem(e,t),queryFn:({signal:n})=>le(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Ei(e){return T({queryKey:J.githubPrChanges(e??0),queryFn:({signal:t})=>Ie(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{yi as $,di as A,ir as At,ri as B,jn as Bt,qn as C,yr as Ct,wi as D,Fr as Dt,pi as E,ii as Et,ti as F,Zr as Ft,wr as G,B as Gt,mi as H,An as Ht,ni as I,Wr as It,Gr as J,j as Jt,br as K,L as Kt,nr as L,Y as Lt,gi as M,$n as Mt,$ as N,Lr as Nt,Ti as O,tr as Ot,pr as P,Qr as Pt,lr as Q,hr as R,zn as Rt,Or as S,gr as St,hi as T,or as Tt,zr as U,hn as Ut,fi as V,Mn as Vt,mr as W,_n as Wt,Un as X,Nt as Xt,Kn as Y,k as Yt,Xr as Z,rr as _,Dr as _t,Jr as a,er as at,xr as b,Hn as bt,_r as c,Br as ct,jr as d,Gn as dt,Ci as et,Ir as f,Cr as ft,ai as g,Tr as gt,cr as h,Mr as ht,sr as i,Yn as it,Ei as j,Xn as jt,fr as k,qr as kt,kr as l,Vr as lt,Ur as m,Nr as mt,J as n,Jn as nt,Yr as o,si as ot,ur as p,Er as pt,Kr as q,A as qt,bi as r,ar as rt,$r as s,Rr as st,X as t,Wn as tt,Ar as u,Hr as ut,dr as v,Pr as vt,ci as w,vr as wt,oi as x,Bn as xt,Qn as y,Sr as yt,ei as z,Fn as zt};