@wjarka/cezarion 0.18.0-dev.8032 → 0.18.0-dev.8037

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 (62) hide show
  1. package/package.json +2 -2
  2. package/web/dist/assets/{accounts-section-Lxa13E8O.js → accounts-section-B-zlsH7k.js} +1 -1
  3. package/web/dist/assets/activity-motion-psm6jyeg.js +2 -0
  4. package/web/dist/assets/{activity-route-Bo-Cyzsz.js → activity-route-DeK0riM9.js} +1 -1
  5. package/web/dist/assets/{agent-config-section-BE239EYo.js → agent-config-section-BvmWn_h-.js} +1 -1
  6. package/web/dist/assets/{agent-defaults-section-Bj5dO6F3.js → agent-defaults-section-DsuYOQpY.js} +1 -1
  7. package/web/dist/assets/{appearance-C2v7z5MF.js → appearance-DNMXL1v0.js} +1 -1
  8. package/web/dist/assets/{archive-on-merge-field-Ta3WlY1p.js → archive-on-merge-field-BovFB0t7.js} +1 -1
  9. package/web/dist/assets/attention-DaLkUl4h.js +1 -0
  10. package/web/dist/assets/{automations-route-DPpaFR0Q.js → automations-route-DyiKOd25.js} +1 -1
  11. package/web/dist/assets/{commit-diff-panel-CzY8bO3p.js → commit-diff-panel-DawdFJ6E.js} +1 -1
  12. package/web/dist/assets/{diff-3jSM3IH7.js → diff-CfoXwmnl.js} +2 -2
  13. package/web/dist/assets/{diff-view-C3cwyYRv.js → diff-view-5xkdG47g.js} +1 -1
  14. package/web/dist/assets/{file-preview-B71T62DU.js → file-preview-DIVTxup4.js} +1 -1
  15. package/web/dist/assets/{folder-browser-BTYMFLBY.js → folder-browser-BzVWaANT.js} +1 -1
  16. package/web/dist/assets/{git-toolbar-Dng31AhK.js → git-toolbar-BUViNmxj.js} +1 -1
  17. package/web/dist/assets/{github-Cft2RNHM.js → github-COe1nsmn.js} +1 -1
  18. package/web/dist/assets/{global-activity-route-CngRjBlD.js → global-activity-route-B-cJo1pg.js} +1 -1
  19. package/web/dist/assets/{index-MG3T7zFQ.js → index-BZiixXpY.js} +5 -5
  20. package/web/dist/assets/{label-C9IGG0mW.js → label-DVUPtyTI.js} +1 -1
  21. package/web/dist/assets/{markdown-BDWm6oGX.js → markdown-bvY77s5D.js} +1 -1
  22. package/web/dist/assets/{notifications-section-BxIKJ1NF.js → notifications-section-Cet1mmEc.js} +1 -1
  23. package/web/dist/assets/{open-in-menu-LbTu2sP4.js → open-in-menu-BpSp2CJF.js} +1 -1
  24. package/web/dist/assets/{preview-pane-connected-CGQngtTw.js → preview-pane-connected-BCrpsIIn.js} +1 -1
  25. package/web/dist/assets/{project-location-B-18C392.js → project-location-ClZPnbBZ.js} +1 -1
  26. package/web/dist/assets/{project-router-DImKA81z.js → project-router-BYrAO9Ws.js} +1 -1
  27. package/web/dist/assets/{project-scope-context-D3_4Nfjk.js → project-scope-context-BDU1qGx3.js} +2 -2
  28. package/web/dist/assets/{projects-section-DQ1LxJ3A.js → projects-section-CdUdrEPd.js} +1 -1
  29. package/web/dist/assets/{prompt-templates-section-C5AYB6Ig.js → prompt-templates-section-D3ojaPZw.js} +1 -1
  30. package/web/dist/assets/{queries-BaHOUYn4.js → queries--x5yVcip.js} +1 -1
  31. package/web/dist/assets/{reference-chip-CdOqXRll.js → reference-chip-013dL8dQ.js} +1 -1
  32. package/web/dist/assets/{remote-settings-notice-BTdflMqO.js → remote-settings-notice-BbBWWAm8.js} +1 -1
  33. package/web/dist/assets/{repo-git-DChiMWrS.js → repo-git-1hSBzyJQ.js} +1 -1
  34. package/web/dist/assets/{report-reader-nV2G6iRk.js → report-reader-BNtgxtSI.js} +1 -1
  35. package/web/dist/assets/{reports-CoQqVEy4.js → reports-C64cW2KP.js} +1 -1
  36. package/web/dist/assets/{resources-section-CVaIlicS.js → resources-section-xAUouGNM.js} +1 -1
  37. package/web/dist/assets/{run-header-xPtXOBkm.js → run-header-75eMWFhM.js} +1 -1
  38. package/web/dist/assets/{runners-DccsyraI.js → runners-C4-xD5Cz.js} +1 -1
  39. package/web/dist/assets/{settings-agent-picker-ixlEQ-MP.js → settings-agent-picker-4P5j_ZP8.js} +1 -1
  40. package/web/dist/assets/{settings-shell-BwknM_fs.js → settings-shell-CME_R4D1.js} +1 -1
  41. package/web/dist/assets/{sidebar-section-BNy-fRPU.js → sidebar-section-BQSB_KxK.js} +1 -1
  42. package/web/dist/assets/{skills-CKceHo5J.js → skills-RUJCWIve.js} +1 -1
  43. package/web/dist/assets/{tab-link-VCVNqxFc.js → tab-link-DnbdjF4r.js} +1 -1
  44. package/web/dist/assets/{task-changes-D4H5YbMo.js → task-changes-Boec_UFj.js} +1 -1
  45. package/web/dist/assets/{task-commits-BNu0VTTf.js → task-commits-B6k-DdnE.js} +1 -1
  46. package/web/dist/assets/{task-files-C8q8GHYK.js → task-files-T731cz4q.js} +1 -1
  47. package/web/dist/assets/{task-github-item-D5kHfnwY.js → task-github-item-iQd_C1Y4.js} +1 -1
  48. package/web/dist/assets/{task-groups-C7yO8nMy.js → task-groups-BTMFLRHJ.js} +1 -1
  49. package/web/dist/assets/{task-thread-Dhts8Nbu.js → task-thread-BaPz3rdA.js} +3 -3
  50. package/web/dist/assets/{tasks-table-I_z4e7uI.js → tasks-table-BCuA9Kx7.js} +1 -1
  51. package/web/dist/assets/{thread-state-DV19z3BD.js → thread-state-B3Ichxx9.js} +1 -1
  52. package/web/dist/assets/{use-hand-to-agent-state-C6e6Mgi1.js → use-hand-to-agent-state-DIIBuX3r.js} +1 -1
  53. package/web/dist/assets/{useInfiniteQuery-DR5UfhCS.js → useInfiniteQuery-BxpPo6z-.js} +1 -1
  54. package/web/dist/assets/useQuery-DcVi2Spi.js +1 -0
  55. package/web/dist/assets/{workflows-BNHmFZRc.js → workflows-8HhOvPhw.js} +1 -1
  56. package/web/dist/assets/{workspace-tools-UHJAnHEN.js → workspace-tools-D6C2Yjat.js} +1 -1
  57. package/web/dist/assets/{worktrees-section-B4XPx6R5.js → worktrees-section-Cm4JH128.js} +1 -1
  58. package/web/dist/assets/{ws-CH3zNFKR.js → ws-Iixb-QFR.js} +1 -1
  59. package/web/dist/index.html +15 -15
  60. package/web/dist/assets/activity-motion-D-8GF_WP.js +0 -2
  61. package/web/dist/assets/attention-B1Ei1IW6.js +0 -1
  62. package/web/dist/assets/useQuery-BMyCehPp.js +0 -1
@@ -1 +1 @@
1
- import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{t as i}from"./utils-DSMR_WLb.js";import{Jt as a,ci as o}from"./project-scope-context-D3_4Nfjk.js";import{At as s,Dt as c,It as l,Lt as u,Nt as d,Yt as f,nt as p,q as m}from"./queries-BaHOUYn4.js";import{n as h}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{n as g}from"./toaster-Bo5vCbz-.js";import{O as _,ft as v}from"./design-icons-CzEoMH9c.js";import{t as y}from"./button-BQ2y4XRB.js";import{n as b,r as x,t as S}from"./popover-BPgUYFyu.js";import{t as C}from"./centered-state-V15AR_qo.js";import{Bt as w,Gt as T,Ht as E,Kt as D,Un as O,Ut as k,Vt as A,Wt as j,qt as M}from"./index-MG3T7zFQ.js";import{t as N}from"./settings-field-Bl6WuvGX.js";var P=t(n(),1),F=r();function I(){let e=p();return{isPending:e.isPending,confirm:(t,n)=>e.mutate(t.id,{onSuccess:()=>{g(`${t.name} removed from the workspace — its files are untouched`),n?.()},onError:e=>g(e.message,{tone:`danger`})})}}function L({project:e,onOpenChange:t,onConfirm:n}){return(0,F.jsx)(w,{open:e!==null,onOpenChange:t,children:(0,F.jsxs)(k,{children:[(0,F.jsxs)(D,{children:[(0,F.jsxs)(M,{children:[`Remove `,e?.name,` from the workspace?`]}),(0,F.jsxs)(j,{children:[`This only unregisters the project — `,(0,F.jsx)(`strong`,{children:`nothing on disk is deleted`}),`. The folder, its git history and its task history all stay exactly where they are, and opening it again re-registers it with everything intact.`,(0,F.jsx)(`span`,{className:`mt-1 block truncate font-mono text-[11px] text-foreground`,title:e?.root,children:e?.root})]})]}),(0,F.jsxs)(T,{children:[(0,F.jsx)(E,{children:`Keep it`}),(0,F.jsx)(A,{"data-action":`projects-confirm-remove`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:n,children:`Remove from list`})]})]})})}var R=e({MaxParallelSelect:()=>J,ProjectTagsEditor:()=>q,ProjectsSection:()=>H,STATUS_LABEL:()=>B}),z=1,B={ok:`ok`,"not-git":`no git repo`,missing:`folder not found`};function V(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function H(){let e=s(),t=m();return e.isPending||t.isPending?(0,F.jsx)(`p`,{"data-slot":`projects-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading projects…`}):e.isError||t.isError?(0,F.jsx)(C,{icon:(0,F.jsx)(_,{}),tone:`danger`,title:`Project settings did not load`,subtitle:(e.error??t.error)?.message,heading:`h2`}):(0,F.jsx)(U,{config:e.data,registry:t.data})}function U({config:e,registry:t}){let[n,r]=(0,P.useState)(!1);return(0,F.jsxs)(`div`,{"data-slot":`projects-section`,className:`mx-auto flex w-full max-w-4xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,F.jsx)(W,{configKey:`browseRoot`,value:e.browseRoot,title:`Default browse folder`,hint:`Where “Open local folder…” starts. The picker cannot navigate above this folder.`,placeholder:`~/`,slot:`browse`,savedLabel:`Browse folder`,footer:`Only affects folder browsing; GitHub checkouts use the separate checkout folder.`}),(0,F.jsx)(W,{configKey:`projectsDir`,value:e.projectsDir,title:`Default checkout folder`,hint:`Where “Clone from GitHub” puts new projects: <folder>/<project name>.`,placeholder:`~/cezar/projects`,slot:`checkout`,savedLabel:`Checkout folder`,footer:`Only affects new checkouts; projects already registered keep their location.`,refreshProjects:!0}),(0,F.jsx)(G,{registry:t,workspaceMax:e.resources.maxParallel}),(0,F.jsx)(y,{className:`self-start`,onClick:()=>r(!0),children:`Add project`}),n?(0,F.jsx)(O,{open:!0,onOpenChange:r}):null]})}function W({configKey:e,value:t,title:n,hint:r,placeholder:i,slot:s,savedLabel:c,footer:l,refreshProjects:u=!1}){let p=o(),m=f({mutationFn:t=>a(e===`browseRoot`?{browseRoot:t}:{projectsDir:t}),onSuccess:t=>{p.setQueryData(d.config,t),e===`browseRoot`?p.invalidateQueries({queryKey:d.fsBrowseRoot}):u&&p.invalidateQueries({queryKey:d.projects})}}),[h,_]=(0,P.useState)(t),v=h.trim(),b=v===t,x=m.isError?m.error.message:null;return(0,F.jsxs)(N,{title:n,hint:`${r} ${e===`browseRoot`?`Choose an existing folder; it is verified writable before saving.`:`The folder is created recursively if needed, then verified writable before saving.`}`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`input`,{type:`text`,spellCheck:!1,"aria-label":n,"aria-invalid":x!==null,"data-slot":`projects-${s}-root`,value:h,disabled:m.isPending,placeholder:i,onChange:e=>{_(e.target.value),m.isError&&m.reset()},className:`block w-full max-w-sm rounded-md border border-input bg-card px-3 py-1.5 font-mono text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-danger disabled:opacity-50`}),(0,F.jsx)(y,{type:`button`,variant:`outline`,size:`sm`,"data-action":`projects-save-${s}-root`,disabled:b||v===``||m.isPending,onClick:()=>m.mutate(v,{onSuccess:()=>g(`${c} set to ${v}`)}),children:`Save`})]}),x===null?(0,F.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:l}):(0,F.jsxs)(`p`,{"data-slot":`projects-${s}-root-error`,role:`alert`,className:`text-[11px] text-danger`,children:[x,` — setting unchanged`]})]})}function G({registry:e,workspaceMax:t}){let[n,r]=(0,P.useState)(null),i=I(),a=(0,P.useMemo)(()=>l(e.projects),[e.projects]);return(0,F.jsxs)(N,{title:`Registered projects`,hint:`Connected repositories. Removing a project only unregisters it — no files on disk are deleted.`,children:[e.projects.length===0?(0,F.jsx)(`p`,{"data-slot":`projects-empty`,className:`text-[13px] text-soft-foreground`,children:`No projects registered yet.`}):(0,F.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border`,children:(0,F.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,F.jsx)(`caption`,{className:`sr-only`,children:`Projects registered in this workspace`}),(0,F.jsxs)(`colgroup`,{children:[(0,F.jsx)(`col`,{}),(0,F.jsx)(`col`,{style:{width:`104px`}}),(0,F.jsx)(`col`,{style:{width:`260px`}}),(0,F.jsx)(`col`,{style:{width:`150px`}}),(0,F.jsx)(`col`,{style:{width:`72px`}}),(0,F.jsx)(`col`,{style:{width:`92px`}})]}),(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`border-b border-border text-left text-[12px] text-soft-foreground`,children:[(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Project`}),(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Status`}),(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Tags`}),(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Max parallel`}),(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Added`}),(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium text-right`,children:`Actions`})]})}),(0,F.jsx)(`tbody`,{children:e.projects.map(n=>(0,F.jsx)(K,{project:n,isBoot:n.id===e.bootProject,workspaceMax:t,vocabulary:a,disabled:i.isPending,onRemove:()=>r(n)},n.id))})]})}),(0,F.jsx)(L,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{if(!n)return;let e=n;r(null),i.confirm(e)}})]})}function K({project:e,isBoot:t,workspaceMax:n,vocabulary:r,disabled:i,onRemove:a}){return(0,F.jsxs)(`tr`,{"data-slot":`project-row`,"data-project":e.id,className:`border-b border-border last:border-0`,children:[(0,F.jsxs)(`th`,{scope:`row`,className:`max-w-0 px-3 py-2 text-left font-normal`,children:[(0,F.jsx)(`span`,{className:`block truncate text-foreground`,children:e.name}),(0,F.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-soft-foreground`,title:e.root,children:e.root})]}),(0,F.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,F.jsx)(`span`,{"data-slot":`project-status`,className:e.status===`missing`?`text-[12px] text-danger`:`text-[12px] text-soft-foreground`,children:B[e.status]}),e.status===`missing`?null:(0,F.jsxs)(`span`,{className:`ml-1 text-[11px] text-soft-foreground`,children:[`· `,e.source]})]}),(0,F.jsx)(`td`,{className:`px-3 py-2`,children:(0,F.jsx)(q,{project:e,vocabulary:r})}),(0,F.jsx)(`td`,{className:`px-3 py-2`,children:(0,F.jsx)(J,{project:e,workspaceMax:n})}),(0,F.jsx)(`td`,{className:`px-3 py-2 tabular-nums text-soft-foreground`,children:V(e.addedAt)}),(0,F.jsxs)(`td`,{className:`px-3 py-2 text-right`,children:[e.status===`missing`?null:(0,F.jsx)(y,{asChild:!0,variant:`outline`,className:`mr-2`,children:(0,F.jsx)(h,{to:`/p/${encodeURIComponent(e.id)}`,children:`Open`})}),(0,F.jsx)(y,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`project-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:t?`Squawk is serving this project — it re-registers itself at every start`:void 0,disabled:i||t,onClick:a,children:`Remove`})]})]})}function q({project:e,vocabulary:t}){let n=c(),[r,a]=(0,P.useState)(``),[o,s]=(0,P.useState)(!1),[l,d]=(0,P.useState)(-1),f=(0,P.useRef)(null),p=e.tags??[],m=u(t,p,r),h=o&&m.length>0,_=(t,r)=>{n.mutate({id:e.id,tags:t},{onSuccess:()=>g(r),onError:e=>g(e.message,{tone:`danger`})})},y=t=>{let n=t.trim().slice(0,32);if(d(-1),n){if(p.some(e=>e.toLowerCase()===n.toLowerCase())){a(``);return}if(p.length>=20){g(`${e.name} already has the maximum of 20 tags`,{tone:`danger`});return}a(``),_([...p,n],`${e.name} tagged \u201c${n}\u201d`)}},C=t=>{_(p.filter(e=>e!==t),`\u201c${t}\u201d removed from ${e.name}`)},w=`project-tag-suggestions-${e.id}`;return(0,F.jsxs)(`div`,{"data-slot":`project-tags`,className:`flex flex-wrap items-center gap-1`,children:[p.map(t=>(0,F.jsxs)(`span`,{"data-slot":`project-tag`,className:`inline-flex max-w-full items-center gap-1 rounded-full bg-accent-strong/15 py-px pr-1 pl-2 text-[11px] font-medium whitespace-nowrap text-accent-text`,children:[t,(0,F.jsx)(`button`,{type:`button`,"data-action":`project-tag-remove`,"aria-label":`Remove tag ${t} from ${e.name}`,disabled:n.isPending,onClick:()=>C(t),className:`rounded-full p-0.5 hover:bg-accent-strong/25 disabled:opacity-50`,children:(0,F.jsx)(v,{className:`size-3`,"aria-hidden":`true`})})]},t)),(0,F.jsxs)(S,{open:h,onOpenChange:s,children:[(0,F.jsx)(b,{asChild:!0,children:(0,F.jsx)(`input`,{ref:f,type:`text`,"data-slot":`project-tag-input`,"aria-label":`Add a tag to ${e.name}`,role:`combobox`,"aria-expanded":h,"aria-controls":h?w:void 0,"aria-autocomplete":`list`,"aria-activedescendant":h&&l>=0?`${w}-${l}`:void 0,placeholder:p.length===0?`Add tag…`:`+`,value:r,maxLength:32,disabled:n.isPending,onFocus:()=>s(!0),onBlur:()=>s(!1),onChange:e=>{if(s(!0),d(-1),e.target.value.includes(`,`)){a(e.target.value.replace(/,/g,``));return}a(e.target.value)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(m.length===0)return;e.preventDefault(),s(!0);let t=e.key===`ArrowDown`?1:-1,n=l+t;d(n>=m.length?-1:n<-1?m.length-1:n);return}if(e.key===`Escape`&&h){e.preventDefault(),s(!1),d(-1);return}if(e.key===`Enter`||e.key===`,`){e.preventDefault(),y(l>=0?m[l]??r:r);return}if(e.key===`Tab`){s(!1);return}if(e.key===`Backspace`&&r===``&&p.length>0){e.preventDefault();let t=p[p.length-1];t!==void 0&&C(t)}},className:`h-6 w-16 min-w-0 flex-1 rounded-md border border-input bg-card px-1.5 text-[12px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`})}),(0,F.jsxs)(x,{align:`start`,sideOffset:4,id:w,role:`listbox`,"data-slot":`project-tag-suggestions`,className:`w-56 p-1`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,F.jsx)(`p`,{className:`px-2 pt-1 pb-1.5 text-[11px] text-soft-foreground`,children:`Tags used in this workspace`}),m.map((e,t)=>(0,F.jsx)(`button`,{type:`button`,id:`${w}-${t}`,role:`option`,"aria-selected":t===l,"data-slot":`project-tag-suggestion`,onMouseDown:e=>e.preventDefault(),onClick:()=>{y(e),f.current?.focus()},onMouseEnter:()=>d(t),className:i(`flex w-full items-center rounded-sm px-2 py-1 text-left text-[12px] font-medium text-accent-text`,t===l&&`bg-muted`),children:e},e))]})]})]})}function J({project:e,workspaceMax:t}){let n=c(),r=e.maxParallel===void 0?``:String(e.maxParallel);return(0,F.jsxs)(`select`,{"aria-label":`Max parallel tasks for ${e.name}`,"data-slot":`project-max-parallel`,value:r,disabled:n.isPending,onChange:r=>{let i=r.target.value,a=i===``?null:Number(i);n.mutate({id:e.id,maxParallel:a},{onSuccess:()=>g(a===null?`${e.name} inherits the workspace limit (${t})`:`${e.name} runs at most ${a} task${a===1?``:`s`} at a time`),onError:e=>g(e.message,{tone:`danger`})})},className:`block w-44 rounded-md border border-input bg-card px-2 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,F.jsxs)(`option`,{value:``,children:[`Inherit workspace (`,t,`)`]}),Array.from({length:16},(e,t)=>t+z).map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))]})}export{I as a,L as i,B as n,R as r,J as t};
1
+ import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{t as i}from"./utils-DSMR_WLb.js";import{Jt as a,ci as o}from"./project-scope-context-BDU1qGx3.js";import{At as s,Dt as c,It as l,Lt as u,Nt as d,Yt as f,nt as p,q as m}from"./queries--x5yVcip.js";import{n as h}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{n as g}from"./toaster-Bo5vCbz-.js";import{O as _,ft as v}from"./design-icons-CzEoMH9c.js";import{t as y}from"./button-BQ2y4XRB.js";import{n as b,r as x,t as S}from"./popover-BPgUYFyu.js";import{t as C}from"./centered-state-V15AR_qo.js";import{Bt as w,Gt as T,Ht as E,Kt as D,Un as O,Ut as k,Vt as A,Wt as j,qt as M}from"./index-BZiixXpY.js";import{t as N}from"./settings-field-Bl6WuvGX.js";var P=t(n(),1),F=r();function I(){let e=p();return{isPending:e.isPending,confirm:(t,n)=>e.mutate(t.id,{onSuccess:()=>{g(`${t.name} removed from the workspace — its files are untouched`),n?.()},onError:e=>g(e.message,{tone:`danger`})})}}function L({project:e,onOpenChange:t,onConfirm:n}){return(0,F.jsx)(w,{open:e!==null,onOpenChange:t,children:(0,F.jsxs)(k,{children:[(0,F.jsxs)(D,{children:[(0,F.jsxs)(M,{children:[`Remove `,e?.name,` from the workspace?`]}),(0,F.jsxs)(j,{children:[`This only unregisters the project — `,(0,F.jsx)(`strong`,{children:`nothing on disk is deleted`}),`. The folder, its git history and its task history all stay exactly where they are, and opening it again re-registers it with everything intact.`,(0,F.jsx)(`span`,{className:`mt-1 block truncate font-mono text-[11px] text-foreground`,title:e?.root,children:e?.root})]})]}),(0,F.jsxs)(T,{children:[(0,F.jsx)(E,{children:`Keep it`}),(0,F.jsx)(A,{"data-action":`projects-confirm-remove`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:n,children:`Remove from list`})]})]})})}var R=e({MaxParallelSelect:()=>J,ProjectTagsEditor:()=>q,ProjectsSection:()=>H,STATUS_LABEL:()=>B}),z=1,B={ok:`ok`,"not-git":`no git repo`,missing:`folder not found`};function V(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function H(){let e=s(),t=m();return e.isPending||t.isPending?(0,F.jsx)(`p`,{"data-slot":`projects-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading projects…`}):e.isError||t.isError?(0,F.jsx)(C,{icon:(0,F.jsx)(_,{}),tone:`danger`,title:`Project settings did not load`,subtitle:(e.error??t.error)?.message,heading:`h2`}):(0,F.jsx)(U,{config:e.data,registry:t.data})}function U({config:e,registry:t}){let[n,r]=(0,P.useState)(!1);return(0,F.jsxs)(`div`,{"data-slot":`projects-section`,className:`mx-auto flex w-full max-w-4xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,F.jsx)(W,{configKey:`browseRoot`,value:e.browseRoot,title:`Default browse folder`,hint:`Where “Open local folder…” starts. The picker cannot navigate above this folder.`,placeholder:`~/`,slot:`browse`,savedLabel:`Browse folder`,footer:`Only affects folder browsing; GitHub checkouts use the separate checkout folder.`}),(0,F.jsx)(W,{configKey:`projectsDir`,value:e.projectsDir,title:`Default checkout folder`,hint:`Where “Clone from GitHub” puts new projects: <folder>/<project name>.`,placeholder:`~/cezar/projects`,slot:`checkout`,savedLabel:`Checkout folder`,footer:`Only affects new checkouts; projects already registered keep their location.`,refreshProjects:!0}),(0,F.jsx)(G,{registry:t,workspaceMax:e.resources.maxParallel}),(0,F.jsx)(y,{className:`self-start`,onClick:()=>r(!0),children:`Add project`}),n?(0,F.jsx)(O,{open:!0,onOpenChange:r}):null]})}function W({configKey:e,value:t,title:n,hint:r,placeholder:i,slot:s,savedLabel:c,footer:l,refreshProjects:u=!1}){let p=o(),m=f({mutationFn:t=>a(e===`browseRoot`?{browseRoot:t}:{projectsDir:t}),onSuccess:t=>{p.setQueryData(d.config,t),e===`browseRoot`?p.invalidateQueries({queryKey:d.fsBrowseRoot}):u&&p.invalidateQueries({queryKey:d.projects})}}),[h,_]=(0,P.useState)(t),v=h.trim(),b=v===t,x=m.isError?m.error.message:null;return(0,F.jsxs)(N,{title:n,hint:`${r} ${e===`browseRoot`?`Choose an existing folder; it is verified writable before saving.`:`The folder is created recursively if needed, then verified writable before saving.`}`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`input`,{type:`text`,spellCheck:!1,"aria-label":n,"aria-invalid":x!==null,"data-slot":`projects-${s}-root`,value:h,disabled:m.isPending,placeholder:i,onChange:e=>{_(e.target.value),m.isError&&m.reset()},className:`block w-full max-w-sm rounded-md border border-input bg-card px-3 py-1.5 font-mono text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-danger disabled:opacity-50`}),(0,F.jsx)(y,{type:`button`,variant:`outline`,size:`sm`,"data-action":`projects-save-${s}-root`,disabled:b||v===``||m.isPending,onClick:()=>m.mutate(v,{onSuccess:()=>g(`${c} set to ${v}`)}),children:`Save`})]}),x===null?(0,F.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:l}):(0,F.jsxs)(`p`,{"data-slot":`projects-${s}-root-error`,role:`alert`,className:`text-[11px] text-danger`,children:[x,` — setting unchanged`]})]})}function G({registry:e,workspaceMax:t}){let[n,r]=(0,P.useState)(null),i=I(),a=(0,P.useMemo)(()=>l(e.projects),[e.projects]);return(0,F.jsxs)(N,{title:`Registered projects`,hint:`Connected repositories. Removing a project only unregisters it — no files on disk are deleted.`,children:[e.projects.length===0?(0,F.jsx)(`p`,{"data-slot":`projects-empty`,className:`text-[13px] text-soft-foreground`,children:`No projects registered yet.`}):(0,F.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border`,children:(0,F.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,F.jsx)(`caption`,{className:`sr-only`,children:`Projects registered in this workspace`}),(0,F.jsxs)(`colgroup`,{children:[(0,F.jsx)(`col`,{}),(0,F.jsx)(`col`,{style:{width:`104px`}}),(0,F.jsx)(`col`,{style:{width:`260px`}}),(0,F.jsx)(`col`,{style:{width:`150px`}}),(0,F.jsx)(`col`,{style:{width:`72px`}}),(0,F.jsx)(`col`,{style:{width:`92px`}})]}),(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`border-b border-border text-left text-[12px] text-soft-foreground`,children:[(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Project`}),(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Status`}),(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Tags`}),(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Max parallel`}),(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Added`}),(0,F.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium text-right`,children:`Actions`})]})}),(0,F.jsx)(`tbody`,{children:e.projects.map(n=>(0,F.jsx)(K,{project:n,isBoot:n.id===e.bootProject,workspaceMax:t,vocabulary:a,disabled:i.isPending,onRemove:()=>r(n)},n.id))})]})}),(0,F.jsx)(L,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{if(!n)return;let e=n;r(null),i.confirm(e)}})]})}function K({project:e,isBoot:t,workspaceMax:n,vocabulary:r,disabled:i,onRemove:a}){return(0,F.jsxs)(`tr`,{"data-slot":`project-row`,"data-project":e.id,className:`border-b border-border last:border-0`,children:[(0,F.jsxs)(`th`,{scope:`row`,className:`max-w-0 px-3 py-2 text-left font-normal`,children:[(0,F.jsx)(`span`,{className:`block truncate text-foreground`,children:e.name}),(0,F.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-soft-foreground`,title:e.root,children:e.root})]}),(0,F.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,F.jsx)(`span`,{"data-slot":`project-status`,className:e.status===`missing`?`text-[12px] text-danger`:`text-[12px] text-soft-foreground`,children:B[e.status]}),e.status===`missing`?null:(0,F.jsxs)(`span`,{className:`ml-1 text-[11px] text-soft-foreground`,children:[`· `,e.source]})]}),(0,F.jsx)(`td`,{className:`px-3 py-2`,children:(0,F.jsx)(q,{project:e,vocabulary:r})}),(0,F.jsx)(`td`,{className:`px-3 py-2`,children:(0,F.jsx)(J,{project:e,workspaceMax:n})}),(0,F.jsx)(`td`,{className:`px-3 py-2 tabular-nums text-soft-foreground`,children:V(e.addedAt)}),(0,F.jsxs)(`td`,{className:`px-3 py-2 text-right`,children:[e.status===`missing`?null:(0,F.jsx)(y,{asChild:!0,variant:`outline`,className:`mr-2`,children:(0,F.jsx)(h,{to:`/p/${encodeURIComponent(e.id)}`,children:`Open`})}),(0,F.jsx)(y,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`project-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:t?`Squawk is serving this project — it re-registers itself at every start`:void 0,disabled:i||t,onClick:a,children:`Remove`})]})]})}function q({project:e,vocabulary:t}){let n=c(),[r,a]=(0,P.useState)(``),[o,s]=(0,P.useState)(!1),[l,d]=(0,P.useState)(-1),f=(0,P.useRef)(null),p=e.tags??[],m=u(t,p,r),h=o&&m.length>0,_=(t,r)=>{n.mutate({id:e.id,tags:t},{onSuccess:()=>g(r),onError:e=>g(e.message,{tone:`danger`})})},y=t=>{let n=t.trim().slice(0,32);if(d(-1),n){if(p.some(e=>e.toLowerCase()===n.toLowerCase())){a(``);return}if(p.length>=20){g(`${e.name} already has the maximum of 20 tags`,{tone:`danger`});return}a(``),_([...p,n],`${e.name} tagged \u201c${n}\u201d`)}},C=t=>{_(p.filter(e=>e!==t),`\u201c${t}\u201d removed from ${e.name}`)},w=`project-tag-suggestions-${e.id}`;return(0,F.jsxs)(`div`,{"data-slot":`project-tags`,className:`flex flex-wrap items-center gap-1`,children:[p.map(t=>(0,F.jsxs)(`span`,{"data-slot":`project-tag`,className:`inline-flex max-w-full items-center gap-1 rounded-full bg-accent-strong/15 py-px pr-1 pl-2 text-[11px] font-medium whitespace-nowrap text-accent-text`,children:[t,(0,F.jsx)(`button`,{type:`button`,"data-action":`project-tag-remove`,"aria-label":`Remove tag ${t} from ${e.name}`,disabled:n.isPending,onClick:()=>C(t),className:`rounded-full p-0.5 hover:bg-accent-strong/25 disabled:opacity-50`,children:(0,F.jsx)(v,{className:`size-3`,"aria-hidden":`true`})})]},t)),(0,F.jsxs)(S,{open:h,onOpenChange:s,children:[(0,F.jsx)(b,{asChild:!0,children:(0,F.jsx)(`input`,{ref:f,type:`text`,"data-slot":`project-tag-input`,"aria-label":`Add a tag to ${e.name}`,role:`combobox`,"aria-expanded":h,"aria-controls":h?w:void 0,"aria-autocomplete":`list`,"aria-activedescendant":h&&l>=0?`${w}-${l}`:void 0,placeholder:p.length===0?`Add tag…`:`+`,value:r,maxLength:32,disabled:n.isPending,onFocus:()=>s(!0),onBlur:()=>s(!1),onChange:e=>{if(s(!0),d(-1),e.target.value.includes(`,`)){a(e.target.value.replace(/,/g,``));return}a(e.target.value)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(m.length===0)return;e.preventDefault(),s(!0);let t=e.key===`ArrowDown`?1:-1,n=l+t;d(n>=m.length?-1:n<-1?m.length-1:n);return}if(e.key===`Escape`&&h){e.preventDefault(),s(!1),d(-1);return}if(e.key===`Enter`||e.key===`,`){e.preventDefault(),y(l>=0?m[l]??r:r);return}if(e.key===`Tab`){s(!1);return}if(e.key===`Backspace`&&r===``&&p.length>0){e.preventDefault();let t=p[p.length-1];t!==void 0&&C(t)}},className:`h-6 w-16 min-w-0 flex-1 rounded-md border border-input bg-card px-1.5 text-[12px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`})}),(0,F.jsxs)(x,{align:`start`,sideOffset:4,id:w,role:`listbox`,"data-slot":`project-tag-suggestions`,className:`w-56 p-1`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,F.jsx)(`p`,{className:`px-2 pt-1 pb-1.5 text-[11px] text-soft-foreground`,children:`Tags used in this workspace`}),m.map((e,t)=>(0,F.jsx)(`button`,{type:`button`,id:`${w}-${t}`,role:`option`,"aria-selected":t===l,"data-slot":`project-tag-suggestion`,onMouseDown:e=>e.preventDefault(),onClick:()=>{y(e),f.current?.focus()},onMouseEnter:()=>d(t),className:i(`flex w-full items-center rounded-sm px-2 py-1 text-left text-[12px] font-medium text-accent-text`,t===l&&`bg-muted`),children:e},e))]})]})]})}function J({project:e,workspaceMax:t}){let n=c(),r=e.maxParallel===void 0?``:String(e.maxParallel);return(0,F.jsxs)(`select`,{"aria-label":`Max parallel tasks for ${e.name}`,"data-slot":`project-max-parallel`,value:r,disabled:n.isPending,onChange:r=>{let i=r.target.value,a=i===``?null:Number(i);n.mutate({id:e.id,maxParallel:a},{onSuccess:()=>g(a===null?`${e.name} inherits the workspace limit (${t})`:`${e.name} runs at most ${a} task${a===1?``:`s`} at a time`),onError:e=>g(e.message,{tone:`danger`})})},className:`block w-44 rounded-md border border-input bg-card px-2 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,F.jsxs)(`option`,{value:``,children:[`Inherit workspace (`,t,`)`]}),Array.from({length:16},(e,t)=>t+z).map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))]})}export{I as a,L as i,B as n,R as r,J as t};
@@ -1 +1 @@
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}from"./utils-DSMR_WLb.js";import{ci as i,qt as a}from"./project-scope-context-D3_4Nfjk.js";import{Pt as o,Tt as s,Yt as c,t as l}from"./queries-BaHOUYn4.js";import{n as u}from"./toaster-Bo5vCbz-.js";import{J as d,W as f,c as p,ft as m,l as h,tt as g}from"./design-icons-CzEoMH9c.js";import{t as _}from"./button-BQ2y4XRB.js";import{i as v,r as y,t as b}from"./popover-BPgUYFyu.js";import{a as x,i as S,o as C,r as w,s as T,t as E}from"./command-CDt1BsZy.js";import{f as D,i as O,p as k,u as A}from"./skills-pM_PouEs.js";import{t as j}from"./centered-state-V15AR_qo.js";import{Hn as M,Q as N,at as P,nt as F,tt as I}from"./index-MG3T7zFQ.js";import{t as L}from"./textarea-vJt9undk.js";var R=e(t(),1),z=n();function B(){let e=s();return e.isPending?(0,z.jsx)(`p`,{"data-slot":`prompt-templates-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading prompt templates…`}):e.isError?(0,z.jsx)(j,{icon:(0,z.jsx)(f,{}),tone:`danger`,title:`Prompt templates did not load`,subtitle:e.error.message,heading:`h2`}):(0,z.jsx)(V,{initial:F(e.data.promptTemplates)})}function V({initial:e}){let t=i(),n=o(),r=s(),[f,p]=(0,R.useState)(e),[h,g]=(0,R.useState)(``),[v,y]=(0,R.useState)(``),b=c({mutationFn:e=>a({promptTemplates:e}),onSuccess:e=>{t.setQueryData(l.uiState,e),u(`Prompt templates saved`)},onError:e=>u(e.message,{tone:`danger`})}),x=JSON.stringify(f)!==JSON.stringify(e),S=f.some(e=>e.label.trim()===``||e.text.trim()===``),C=(e,t)=>p(n=>n.map(n=>n.id===e?{...n,...t}:n)),w=(e,t)=>p(n=>n.map(n=>{if(n.id!==e)return n;let r=n.skills??[],i=r.includes(t)?r.filter(e=>e!==t):[...r,t],{skills:a,...o}=n;return i.length>0?{...o,skills:i}:o})),T=e=>p(t=>t.filter(t=>t.id!==e));return(0,z.jsx)(`div`,{"data-slot":`prompt-templates-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:(0,z.jsxs)(U,{title:`Reusable instructions`,hint:`Insert templates from task composers, or apply them automatically with selected skills when the prompt is empty.`,children:[(0,z.jsx)(`div`,{"data-slot":`prompt-template-list`,className:`flex flex-col gap-3`,children:f.length===0?(0,z.jsx)(`p`,{"data-slot":`prompt-templates-empty`,className:`text-[13px] text-soft-foreground`,children:`No templates. Add one below, or reset to the built-ins.`}):f.map(e=>(0,z.jsxs)(`div`,{"data-slot":`prompt-template-row`,"data-template":e.id,className:`flex flex-col gap-1.5 rounded-md border border-border bg-card p-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(`label`,{htmlFor:`template-label-${e.id}`,className:`text-sm`,children:`Template label`}),(0,z.jsx)(M,{id:`template-label-${e.id}`,"aria-label":`Label for ${e.label||`this template`}`,"data-slot":`prompt-template-label-input`,value:e.label,maxLength:80,onChange:t=>C(e.id,{label:t.target.value}),className:`flex-1`})]}),(0,z.jsx)(`label`,{htmlFor:`template-text-${e.id}`,className:`text-sm`,children:`Instructions`}),(0,z.jsx)(L,{id:`template-text-${e.id}`,"aria-label":`Text for ${e.label||`this template`}`,"data-slot":`prompt-template-text-input`,value:e.text,maxLength:2e3,onChange:t=>C(e.id,{text:t.target.value}),className:`min-h-14 text-[13px]`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm`,children:`Apply automatically with skills`}),(0,z.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5`,children:[(0,z.jsx)(H,{label:e.label,skills:n.data??[],skillUsage:r.data?.skillUsage,selected:e.skills??[],onToggle:t=>w(e.id,t)}),(e.skills??[]).map(t=>(0,z.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skill-chip`,"data-skill":t,title:`Stop applying “${e.label}” automatically with ${t}`,onClick:()=>w(e.id,t),className:`inline-flex items-center gap-1 rounded-full border border-border bg-muted px-2 py-px font-mono text-[11px] font-medium text-foreground transition-colors hover:bg-danger/10 hover:text-danger`,children:[t,(0,z.jsx)(m,{"aria-hidden":`true`,className:`size-3`})]},t))]}),(0,z.jsx)(_,{type:`button`,className:`self-start`,variant:`outline`,size:`sm`,"data-action":`prompt-template-remove`,title:`Remove this template`,onClick:()=>T(e.id),children:`Delete template`})]},e.id))}),(0,z.jsxs)(`div`,{"data-slot":`prompt-template-new`,className:`flex flex-col gap-1.5 rounded-md border border-dashed border-border p-3`,children:[(0,z.jsx)(`h3`,{className:`text-lg`,children:`New template`}),(0,z.jsx)(`label`,{htmlFor:`new-template-label`,className:`text-sm`,children:`Label`}),(0,z.jsx)(M,{id:`new-template-label`,"aria-label":`New template label`,"data-slot":`prompt-template-new-label`,placeholder:`e.g. Review security`,value:h,maxLength:80,onChange:e=>g(e.target.value)}),(0,z.jsx)(`label`,{htmlFor:`new-template-text`,className:`text-sm`,children:`Instructions to insert`}),(0,z.jsx)(L,{id:`new-template-text`,"aria-label":`New template text`,"data-slot":`prompt-template-new-text`,placeholder:`Enter reusable instructions…`,value:v,maxLength:2e3,onChange:e=>y(e.target.value),className:`min-h-14 text-[13px]`}),(0,z.jsxs)(_,{type:`button`,variant:`outline`,size:`sm`,"data-action":`prompt-template-add`,disabled:!h.trim()||!v.trim(),onClick:()=>{let e=h.trim(),t=v.trim();!e||!t||(p(n=>[...n,{id:I(),label:e,text:t}]),g(``),y(``))},className:`self-start`,children:[(0,z.jsx)(d,{"aria-hidden":`true`,className:`size-3.5`}),`Add template`]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(_,{type:`button`,variant:`primary`,size:`sm`,"data-action":`prompt-templates-save`,disabled:!x||S||b.isPending,onClick:()=>b.mutate(f),children:`Save`}),(0,z.jsx)(_,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`prompt-templates-reset`,disabled:b.isPending,onClick:()=>p(N.map(e=>({...e}))),children:`Reset to defaults`}),S?(0,z.jsx)(`p`,{"data-slot":`prompt-templates-invalid`,className:`text-[11px] text-danger`,children:`Every template needs both a label and text.`}):null]})]})})}function H({label:e,skills:t,skillUsage:n,selected:i,onToggle:a}){let[o,s]=(0,R.useState)(!1),[c,l]=(0,R.useState)(``),u=(0,R.useRef)(null),{mostUsed:d,project:f,global:m,ranked:_}=A(t,c,n),j=(e,t)=>{let n=i.includes(e.id);return(0,z.jsxs)(C,{value:D(e),keywords:k(e.name,e.description),"data-slot":`prompt-template-skill-option`,"data-skill":e.id,"data-selected":n?`true`:void 0,onSelect:()=>a(e.id),children:[(0,z.jsx)(P,{skill:e,emphasized:t}),n?(0,z.jsx)(p,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},D(e))};return(0,z.jsxs)(b,{open:o,onOpenChange:e=>{s(e),e||l(``)},children:[(0,z.jsx)(v,{asChild:!0,children:(0,z.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skills-trigger`,"aria-label":`Apply ${e||`this template`} automatically with a skill`,title:`Pick the skills this template applies itself to`,className:r(`inline-flex h-[26px] items-center gap-1.5 rounded-full border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,i.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,z.jsx)(g,{"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),`apply with…`,(0,z.jsx)(h,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,z.jsx)(y,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,z.jsxs)(E,{shouldFilter:!1,children:[(0,z.jsx)(x,{placeholder:`search skills…`,value:c,onValueChange:l,onInput:()=>u.current?.scrollTo(0,0)}),(0,z.jsxs)(T,{ref:u,"data-slot":`prompt-template-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[c.trim()&&!t.some(e=>e.id===c.trim())?(0,z.jsx)(S,{children:(0,z.jsxs)(C,{value:`typed-skill`,onSelect:()=>a(c.trim()),children:[`Use skill id “`,c.trim(),`” (unchecked)`]})}):null,(_?_.length===0:d.length===0&&f.length===0&&m.length===0)?(0,z.jsx)(w,{children:`Nothing matches.`}):null,_?_.length>0?(0,z.jsx)(S,{children:_.map(e=>j(e,O(e)))}):null:(0,z.jsxs)(z.Fragment,{children:[d.length>0?(0,z.jsx)(S,{heading:`Most used`,children:d.map(e=>j(e,O(e)))}):null,f.length>0?(0,z.jsx)(S,{heading:`Project skills`,children:f.map(e=>j(e,!0))}):null,m.length>0?(0,z.jsx)(S,{heading:`Global`,children:m.map(e=>j(e,!1))}):null]})]})]})})]})}function U({title:e,hint:t,children:n}){return(0,z.jsxs)(`section`,{className:`settings-field flex flex-col gap-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,z.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t})]}),n]})}export{B as PromptTemplatesSection};
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}from"./utils-DSMR_WLb.js";import{ci as i,qt as a}from"./project-scope-context-BDU1qGx3.js";import{Pt as o,Tt as s,Yt as c,t as l}from"./queries--x5yVcip.js";import{n as u}from"./toaster-Bo5vCbz-.js";import{J as d,W as f,c as p,ft as m,l as h,tt as g}from"./design-icons-CzEoMH9c.js";import{t as _}from"./button-BQ2y4XRB.js";import{i as v,r as y,t as b}from"./popover-BPgUYFyu.js";import{a as x,i as S,o as C,r as w,s as T,t as E}from"./command-CDt1BsZy.js";import{f as D,i as O,p as k,u as A}from"./skills-pM_PouEs.js";import{t as j}from"./centered-state-V15AR_qo.js";import{Hn as M,Q as N,at as P,nt as F,tt as I}from"./index-BZiixXpY.js";import{t as L}from"./textarea-vJt9undk.js";var R=e(t(),1),z=n();function B(){let e=s();return e.isPending?(0,z.jsx)(`p`,{"data-slot":`prompt-templates-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading prompt templates…`}):e.isError?(0,z.jsx)(j,{icon:(0,z.jsx)(f,{}),tone:`danger`,title:`Prompt templates did not load`,subtitle:e.error.message,heading:`h2`}):(0,z.jsx)(V,{initial:F(e.data.promptTemplates)})}function V({initial:e}){let t=i(),n=o(),r=s(),[f,p]=(0,R.useState)(e),[h,g]=(0,R.useState)(``),[v,y]=(0,R.useState)(``),b=c({mutationFn:e=>a({promptTemplates:e}),onSuccess:e=>{t.setQueryData(l.uiState,e),u(`Prompt templates saved`)},onError:e=>u(e.message,{tone:`danger`})}),x=JSON.stringify(f)!==JSON.stringify(e),S=f.some(e=>e.label.trim()===``||e.text.trim()===``),C=(e,t)=>p(n=>n.map(n=>n.id===e?{...n,...t}:n)),w=(e,t)=>p(n=>n.map(n=>{if(n.id!==e)return n;let r=n.skills??[],i=r.includes(t)?r.filter(e=>e!==t):[...r,t],{skills:a,...o}=n;return i.length>0?{...o,skills:i}:o})),T=e=>p(t=>t.filter(t=>t.id!==e));return(0,z.jsx)(`div`,{"data-slot":`prompt-templates-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:(0,z.jsxs)(U,{title:`Reusable instructions`,hint:`Insert templates from task composers, or apply them automatically with selected skills when the prompt is empty.`,children:[(0,z.jsx)(`div`,{"data-slot":`prompt-template-list`,className:`flex flex-col gap-3`,children:f.length===0?(0,z.jsx)(`p`,{"data-slot":`prompt-templates-empty`,className:`text-[13px] text-soft-foreground`,children:`No templates. Add one below, or reset to the built-ins.`}):f.map(e=>(0,z.jsxs)(`div`,{"data-slot":`prompt-template-row`,"data-template":e.id,className:`flex flex-col gap-1.5 rounded-md border border-border bg-card p-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(`label`,{htmlFor:`template-label-${e.id}`,className:`text-sm`,children:`Template label`}),(0,z.jsx)(M,{id:`template-label-${e.id}`,"aria-label":`Label for ${e.label||`this template`}`,"data-slot":`prompt-template-label-input`,value:e.label,maxLength:80,onChange:t=>C(e.id,{label:t.target.value}),className:`flex-1`})]}),(0,z.jsx)(`label`,{htmlFor:`template-text-${e.id}`,className:`text-sm`,children:`Instructions`}),(0,z.jsx)(L,{id:`template-text-${e.id}`,"aria-label":`Text for ${e.label||`this template`}`,"data-slot":`prompt-template-text-input`,value:e.text,maxLength:2e3,onChange:t=>C(e.id,{text:t.target.value}),className:`min-h-14 text-[13px]`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm`,children:`Apply automatically with skills`}),(0,z.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5`,children:[(0,z.jsx)(H,{label:e.label,skills:n.data??[],skillUsage:r.data?.skillUsage,selected:e.skills??[],onToggle:t=>w(e.id,t)}),(e.skills??[]).map(t=>(0,z.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skill-chip`,"data-skill":t,title:`Stop applying “${e.label}” automatically with ${t}`,onClick:()=>w(e.id,t),className:`inline-flex items-center gap-1 rounded-full border border-border bg-muted px-2 py-px font-mono text-[11px] font-medium text-foreground transition-colors hover:bg-danger/10 hover:text-danger`,children:[t,(0,z.jsx)(m,{"aria-hidden":`true`,className:`size-3`})]},t))]}),(0,z.jsx)(_,{type:`button`,className:`self-start`,variant:`outline`,size:`sm`,"data-action":`prompt-template-remove`,title:`Remove this template`,onClick:()=>T(e.id),children:`Delete template`})]},e.id))}),(0,z.jsxs)(`div`,{"data-slot":`prompt-template-new`,className:`flex flex-col gap-1.5 rounded-md border border-dashed border-border p-3`,children:[(0,z.jsx)(`h3`,{className:`text-lg`,children:`New template`}),(0,z.jsx)(`label`,{htmlFor:`new-template-label`,className:`text-sm`,children:`Label`}),(0,z.jsx)(M,{id:`new-template-label`,"aria-label":`New template label`,"data-slot":`prompt-template-new-label`,placeholder:`e.g. Review security`,value:h,maxLength:80,onChange:e=>g(e.target.value)}),(0,z.jsx)(`label`,{htmlFor:`new-template-text`,className:`text-sm`,children:`Instructions to insert`}),(0,z.jsx)(L,{id:`new-template-text`,"aria-label":`New template text`,"data-slot":`prompt-template-new-text`,placeholder:`Enter reusable instructions…`,value:v,maxLength:2e3,onChange:e=>y(e.target.value),className:`min-h-14 text-[13px]`}),(0,z.jsxs)(_,{type:`button`,variant:`outline`,size:`sm`,"data-action":`prompt-template-add`,disabled:!h.trim()||!v.trim(),onClick:()=>{let e=h.trim(),t=v.trim();!e||!t||(p(n=>[...n,{id:I(),label:e,text:t}]),g(``),y(``))},className:`self-start`,children:[(0,z.jsx)(d,{"aria-hidden":`true`,className:`size-3.5`}),`Add template`]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(_,{type:`button`,variant:`primary`,size:`sm`,"data-action":`prompt-templates-save`,disabled:!x||S||b.isPending,onClick:()=>b.mutate(f),children:`Save`}),(0,z.jsx)(_,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`prompt-templates-reset`,disabled:b.isPending,onClick:()=>p(N.map(e=>({...e}))),children:`Reset to defaults`}),S?(0,z.jsx)(`p`,{"data-slot":`prompt-templates-invalid`,className:`text-[11px] text-danger`,children:`Every template needs both a label and text.`}):null]})]})})}function H({label:e,skills:t,skillUsage:n,selected:i,onToggle:a}){let[o,s]=(0,R.useState)(!1),[c,l]=(0,R.useState)(``),u=(0,R.useRef)(null),{mostUsed:d,project:f,global:m,ranked:_}=A(t,c,n),j=(e,t)=>{let n=i.includes(e.id);return(0,z.jsxs)(C,{value:D(e),keywords:k(e.name,e.description),"data-slot":`prompt-template-skill-option`,"data-skill":e.id,"data-selected":n?`true`:void 0,onSelect:()=>a(e.id),children:[(0,z.jsx)(P,{skill:e,emphasized:t}),n?(0,z.jsx)(p,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},D(e))};return(0,z.jsxs)(b,{open:o,onOpenChange:e=>{s(e),e||l(``)},children:[(0,z.jsx)(v,{asChild:!0,children:(0,z.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skills-trigger`,"aria-label":`Apply ${e||`this template`} automatically with a skill`,title:`Pick the skills this template applies itself to`,className:r(`inline-flex h-[26px] items-center gap-1.5 rounded-full border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,i.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,z.jsx)(g,{"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),`apply with…`,(0,z.jsx)(h,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,z.jsx)(y,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,z.jsxs)(E,{shouldFilter:!1,children:[(0,z.jsx)(x,{placeholder:`search skills…`,value:c,onValueChange:l,onInput:()=>u.current?.scrollTo(0,0)}),(0,z.jsxs)(T,{ref:u,"data-slot":`prompt-template-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[c.trim()&&!t.some(e=>e.id===c.trim())?(0,z.jsx)(S,{children:(0,z.jsxs)(C,{value:`typed-skill`,onSelect:()=>a(c.trim()),children:[`Use skill id “`,c.trim(),`” (unchecked)`]})}):null,(_?_.length===0:d.length===0&&f.length===0&&m.length===0)?(0,z.jsx)(w,{children:`Nothing matches.`}):null,_?_.length>0?(0,z.jsx)(S,{children:_.map(e=>j(e,O(e)))}):null:(0,z.jsxs)(z.Fragment,{children:[d.length>0?(0,z.jsx)(S,{heading:`Most used`,children:d.map(e=>j(e,O(e)))}):null,f.length>0?(0,z.jsx)(S,{heading:`Project skills`,children:f.map(e=>j(e,!0))}):null,m.length>0?(0,z.jsx)(S,{heading:`Global`,children:m.map(e=>j(e,!1))}):null]})]})]})})]})}function U({title:e,hint:t,children:n}){return(0,z.jsxs)(`section`,{className:`settings-field flex flex-col gap-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,z.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t})]}),n]})}export{B as PromptTemplatesSection};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{c as n,o as r}from"./utils-DSMR_WLb.js";import{n as i,t as a}from"./live-refetch-CZb2VOyu.js";import{$ as o,$r as s,$t as c,Ai as l,At as u,B as d,Bt as f,Ct as p,Di as m,Dt as h,Ei as g,Et as _,F as v,Fr as ee,Gt as te,I as ne,In as re,Ir as ie,J as ae,K as oe,L as se,Nr as ce,Ot as le,P as ue,Pt as de,Q as fe,Qt as pe,R as me,Si as he,St as ge,Tt as _e,V as ve,Vr as ye,Vt as be,W as xe,X as Se,Y as Ce,Z as we,_ as Te,_i as Ee,_n as De,_r as Oe,_t as ke,ai as Ae,at as je,b as Me,bn as Ne,c as Pe,ci as y,cn as Fe,ct as Ie,dt as Le,ei as Re,en as ze,et as Be,f as Ve,fr as He,ft as Ue,g as We,gt as Ge,hn as Ke,ht as qe,i as Je,ii as Ye,in as Xe,it as Ze,j as Qe,kt as $e,li as et,ln as tt,lt as nt,m as rt,mi as it,mn as at,mt as ot,ni as st,nn as ct,nt as lt,oi as ut,ot as dt,pi as ft,pn as pt,pt as mt,q as ht,r as gt,ri as _t,rt as vt,sn as yt,st as bt,ti as xt,tn as St,un as Ct,ut as wt,v as Tt,vt as Et,wi as Dt,wt as Ot,x as kt,yi as At,yn as jt,yt as Mt,z as Nt}from"./project-scope-context-D3_4Nfjk.js";import{B as b,H as x,L as S,M as C,N as w,O as Pt,P as T,R as E,Y as D,j as O,k}from"./live-protocol-D9ji1YCl.js";import{t as Ft}from"./useInfiniteQuery-DR5UfhCS.js";import{t as A}from"./useQuery-BMyCehPp.js";import{n as It,r as j,t as Lt}from"./ws-CH3zNFKR.js";import{n as Rt}from"./toaster-Bo5vCbz-.js";var zt=class extends ft{#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||Bt(),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=it({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),D.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Bt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Vt=class extends l{#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),g(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Ee(t.mutationKey)!==Ee(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??Bt();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){D.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 Ht(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Ut(e,t,n){let r=e.slice(0);return r[t]=n,r}var Wt=class extends l{#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,D.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||!g(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Ht(e,n).forEach(e=>{e.destroy()}),Ht(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=Dt(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 et(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Ut(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)&&D.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},M=e(t(),1);function N({queries:e,...t},n){let r=y(n),i=ut(),a=Ae(),o=M.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{s(e);let t=r.getQueryCache().get(e.queryHash);st(e,a,t)}),Ye(a);let[c]=M.useState(()=>new Wt(r,o,t)),[l,u,d]=c.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;M.useSyncExternalStore(M.useCallback(e=>f?c.subscribe(D.batchCalls(e)):he,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),M.useEffect(()=>{c.setQueries(o,t)},[o,t,c]);let p=l.some((e,t)=>xt(o[t],e))?l.flatMap((e,t)=>{let n=o[t];return n&&xt(n,e)?Re(n,new et(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=l.find((e,t)=>{let n=o[t];return n&&_t({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 P(e,t){let n=y(t),[r]=M.useState(()=>new Vt(n,e));M.useEffect(()=>{r.setOptions(e)},[r,e]);let i=M.useSyncExternalStore(M.useCallback(e=>r.subscribe(D.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=M.useCallback((e,t)=>{r.mutate(e,t).catch(he)},[r]);if(i.error&&m(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function F(e={}){let t=e.projectId??n();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function I(e,t={}){return{...F(t),runId:e}}function Gt(e,t=!0,n=!1,r){return A({queryKey:[F({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>Ot(F({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function L(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:Z.models(t),refetchType:n})}function Kt(e,t=!0,n){return A({...qt(e,n),enabled:t})}var qt=(e,t)=>({queryKey:Z.models(e,t),queryFn:({signal:n})=>re(e,{signal:n},t),staleTime:300*1e3});function Jt(e,t=!0){let n=N({queries:e.map(e=>({...qt(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}var R=[`workspace`,`runs-index`],z=e=>[e.cacheScope,`runs`,`list`],B=e=>[e.cacheScope,`runs`,`detail`,e.runId],V=e=>typeof e==`function`?e():e;function Yt(e){let{seenAt:t,...n}=e;return n}function Xt(e,t){let n=Yt(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function Zt(e,t,n){return t?{...e,seenAt:n}:Yt(e)}function Qt(e){let t=()=>{e.invalidateQueries({queryKey:R})};function r(r,i){if(r===`index`)return t();let a=typeof i==`function`?i():i;if(r===`indexed`){t(),e.invalidateQueries({queryKey:[n(),`runs`]}),e.invalidateQueries({queryKey:[a.projectId,`runs`,`list`]});return}if(r===`runs`)return e.invalidateQueries({queryKey:[a.cacheScope,`runs`]});let o=ie(),s=[a.projectId,a.cacheScope],c=o!==void 0&&s.some(e=>e===o||e==="default")?[o,`default`]:[],l=new Set([...s,...c,n()]);return Promise.all([...l].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}async function i(n,r){await e.cancelQueries({queryKey:z(V(n))}),await e.cancelQueries({queryKey:B(V(n))});let i=e.getQueryData(z(V(n))),a=e.getQueryData(B(V(n))),o=V(n).runId,s=new Date().toISOString();return e.setQueryData(z(V(n)),e=>e?.map(e=>e.id===o?Zt(e,r,s):e)),e.setQueryData(B(V(n)),e=>e&&Zt(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(z(V(n)),i),a&&e.setQueryData(B(V(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(z(V(n)),e=>e?.map(e=>e.id===o?Xt(e,t):e)),a&&e.setQueryData(B(V(n)),e=>e&&Xt(e,a))},settle(i){let a=e=>e.id===(r?o:i.id)?Zt(e,r,i.seenAt):e;e.setQueryData(z(V(n)),e=>e?.map(a));let s={...V(n),runId:r?o:i.id};e.setQueryData(B(s),e=>e?a(e):i),t()}}}async function a(t,n){await e.cancelQueries({queryKey:R});let i=e.getQueryData(R),a=n();return e.setQueryData(R,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(R,i)},settle(){r(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:r}}function H(){let e=y();return(0,M.useMemo)(()=>Qt(e),[e])}function $t(e,t){return JSON.stringify([e,t])}function en(e){return e.type===`run`?e.run.id:e.id}function U(e,t){return{...e,runs:t}}function tn(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}var nn=class{runs;copied=!1;positions=new Map;constructor(e){this.runs=e,this.reindex()}reindex(){this.positions.clear(),this.runs.forEach((e,t)=>this.positions.set($t(e.projectId,e.id),t))}at(e,t){return this.positions.get($t(e,t))??-1}mutable(){return this.copied||=(this.runs=[...this.runs],!0),this.runs}replace(e,t){return this.mutable()[e]=t,this.runs}remove(e){return this.mutable().splice(e,1),this.reindex(),this.runs}insert(e){let t=this.runs.findIndex(t=>(t.createdAt??``).localeCompare(e.createdAt)<0);return this.mutable().splice(t<0?this.runs.length:t,0,e),this.reindex(),this.runs}};function rn(e,t,n){let r=new nn(e.runs),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=un(i,e.project,e.usage,r);else{let t=sn(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function an(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function on(e,t,n){return sn(e,t,n,new nn(e.runs))}function sn(e,t,n,r){let{project:i}=t,a=r.at(i,en(t)),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(i);if(t.type===`deleted`)return o?{index:U(e,r.remove(a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:U(e,r.remove(a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!an(e,i,n))return{index:e,reconcile:!0};let l=Dt(o,{projectId:i,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=r.replace(a,l),n=o.archived!==l.archived&&(s||tn(t,i)>e.perProjectLimit);return{index:U(e,t),reconcile:n}}if(s)return ln(e,l,r);let u=r.insert(l);return{index:U(e,u),reconcile:l.archived&&tn(u,i)>e.perProjectLimit}}function cn(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 ln(e,t,n){let r=cn(e.runs,t.projectId),i=r!==void 0&&t.createdAt>r;return t.archived&&!i?{index:e,reconcile:!1}:{index:U(e,n.insert(t)),reconcile:t.archived||r===void 0||t.createdAt<r}}function un(e,t,n,r){let i=!1;return e.runs.forEach((e,a)=>{if(e.projectId!==t)return;let o=n[e.id];if(o){let t=Dt(e.usage,o);if(t===e.usage)return;r.replace(a,{...e,usage:t})}else{if(e.usage===void 0)return;let{usage:t,...n}=e;r.replace(a,n)}i=!0}),i?U(e,r.runs):e}function dn(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 fn(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function pn(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 mn(e){e.stream=void 0}function hn(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,en(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function gn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function _n(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function vn(e,t,n){if(!_n(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=on(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 W=[`workspace`,`runs-index`],yn=[`workspace`,`projects`],bn=6e4,xn=100,Sn=new WeakMap;function Cn(e){let t=Sn.get(e);return t||(t=On(e),Sn.set(e,t)),t}function wn(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:Cn(t).merge(e)}function Tn(e){let t=e.getQueryData(yn)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function En(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 Dn(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 On(e){let t=fn(),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(W,t)},h=()=>e.getQueryData(W),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:W,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:W,exact:!0}).then(()=>e.invalidateQueries({queryKey:W})):e.invalidateQueries({queryKey:W})).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=Tn(e),{index:s,reconcile:c}=rn(a,t.filter(e=>e.generation===a.generation?e.type===`usage`?!l.has(e.project):!l.has(e.change.project)&&e.change.seq>a.eventSeq:!1),o);s!==a&&m(s),c&&_({hold:!0})},ee=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,xn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){pn(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){mn(t)},run(e,r,i=!1){if(l.has(e))return;let a=Dn(e,r);if(!hn(t,a,i)){p();return}n.push({type:`change`,change:a,generation:t.stream}),ee()},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}),ee()}},dropProject(e){l.add(e),gn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=dn(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=vn(t,n,Tn(e));for(let e of l)i.index=dn(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),En(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 kn={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`}},An={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function jn(e){return typeof e==`string`&&Object.hasOwn(kn,e)}function Mn(e){return e!==void 0&&jn(e)?kn[e]:void 0}var Nn=`cez.reference-statuses.v1`,Pn=`cez.reference-conflicts.v1`,G=new Map(Rn()),Fn=1e3;function In(e,t){if(G.get(e)!==t){for(G.delete(e),G.set(e,t);G.size>Fn;){let e=G.keys().next().value;if(e===void 0)break;G.delete(e)}Vn()}}var K=new Set(zn());function Ln(e,t){if(K.has(e)!==t){if(t)for(K.add(e);K.size>Fn;){let e=K.values().next().value;if(e===void 0)break;K.delete(e)}else K.delete(e);Vn()}}function Rn(){try{let e=globalThis.sessionStorage?.getItem(Nn);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`&&jn(e[1])):[]}catch{return[]}}function zn(){try{let e=globalThis.sessionStorage?.getItem(Pn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var Bn;function Vn(){Bn===void 0&&(Bn=setTimeout(()=>{Bn=void 0;try{globalThis.sessionStorage?.setItem(Nn,JSON.stringify([...G])),globalThis.sessionStorage?.setItem(Pn,JSON.stringify([...K]))}catch{}},250))}var q=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function Hn(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function Un(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 Wn(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;In(t,o),s!==void 0&&Ln(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function Gn(e,t,n){let r=q(t),i=G.get(r),a=K.has(r)?!0:void 0,o=n.data;if(o?.available){Wn(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...Hn(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...Hn(i,a)});return}e.set(r,{state:`loading`,...Hn(i,a)})}function Kn(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of Un(i))Gn(n,e,t)}),n}async function qn(e,t=!1){return Ke(await Ve.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:n(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),yt(e,`/worker-destroy`))}var Jn=k([`passing`,`failing`,`pending`]).nullable(),J=E({kind:k([`issue`,`pr`]),number:S(),title:x(),author:x(),createdAt:x(),labels:O(x()),body:x().optional(),url:x(),comments:S(),assignees:O(x()).optional(),projectIds:O(x()).optional(),isDraft:C().optional(),additions:S().optional(),deletions:S().optional(),checks:Jn.optional()});w(`available`,[E({available:T(!0),item:J.nullable(),labelColors:b(x(),x()).optional()}),E({available:T(!1),reason:x()})]),E({kind:k([`issue`,`pr`]),number:Pt().int().positive().safe()});var Yn=E({id:x(),title:x(),url:x()});E({available:C(),reason:x().optional(),repo:x().optional(),syncedAt:x().optional(),issues:O(J),prs:O(J),labelColors:b(x(),x()).optional(),viewerLogin:x().optional(),projects:O(Yn).optional(),projectsReason:x().optional(),projectsState:k([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:x().optional(),issuesTotal:S().int().nonnegative().optional(),prsTotal:S().int().nonnegative().optional(),issuesNextCursor:x().nullable().optional(),prsNextCursor:x().nullable().optional(),commentsDeferred:T(!0).optional()});var Xn=x().min(1).max(2e3).optional();E({limit:x().optional(),refresh:x().optional(),issuesCursor:Xn,prsCursor:Xn,issuesDone:T(`1`).optional(),prsDone:T(`1`).optional()}).superRefine((e,t)=>{e.issuesDone&&e.issuesCursor&&t.addIssue({code:`custom`,message:`issuesDone and issuesCursor are exclusive`}),e.prsDone&&e.prsCursor&&t.addIssue({code:`custom`,message:`prsDone and prsCursor are exclusive`}),e.issuesDone&&e.prsDone&&t.addIssue({code:`custom`,message:`both sides are done; there is no page to ask for`})}),E({kind:k([`issue`,`pr`]),numbers:x().regex(/^[1-9]\d{0,15}(,[1-9]\d{0,15})*$/).refine(e=>{let t=e.split(`,`);return t.length<=100&&t.every(e=>Number.isSafeInteger(Number(e)))},{message:`at most 100 safe positive integers`}),refresh:T(`1`).optional()}),w(`available`,[E({available:T(!0),counts:b(S(),S().int().nonnegative())}),E({available:T(!1),reason:x()})]),w(`available`,[E({available:T(!0),checks:b(S(),Jn)}),E({available:T(!1),reason:x()})]),E({kind:k([`issue`,`pr`]),q:x().trim().min(1).max(256),limit:Pt().int().positive().max(50).optional()}),E({available:C(),projectsReason:x().optional(),reason:x().optional(),items:O(J),truncated:C().optional(),labelColors:b(x(),x()).optional()});var Zn=S().nullable();w(`available`,[E({available:T(!0),prs:b(S(),He),issues:b(S(),He),conflicts:O(S()).optional(),recheckAfterMs:Zn}),E({available:T(!1),reason:x(),recheckAfterMs:Zn})]);var Qn=E({id:S(),author:x(),avatarUrl:x().optional(),createdAt:x(),body:x(),kind:k([`comment`,`review`]),reviewState:k([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:x()}),$n=k([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),er=E({id:x(),kind:$n,actor:x(),avatarUrl:x().optional(),createdAt:x(),url:x().optional(),sha:x().optional(),message:x().optional(),checks:Jn.optional(),label:E({name:x(),color:x().optional()}).optional(),subject:x().optional(),refNumber:S().optional(),refTitle:x().optional(),refIsPr:C().optional()});E({available:C(),reason:x().optional(),comments:O(Qn),truncated:C().optional(),events:O(er).optional(),detail:E({body:x(),additions:S().int().nonnegative().optional(),deletions:S().int().nonnegative().optional()}).optional()});var tr=k([`merge`,`squash`,`rebase`]),nr=E({name:x(),state:k([`passing`,`failing`,`pending`,`unknown`]),required:C().nullable(),url:x().optional()}),rr=E({number:S(),title:x(),url:x(),state:k([`open`,`closed`,`merged`]),isDraft:C(),headRef:x(),baseRef:x(),headSha:x(),mergeable:k([`mergeable`,`conflicting`,`unknown`]),reviewDecision:k([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:O(nr),methods:O(tr),defaultMethod:tr.nullable(),eligibility:k([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:O(E({code:x(),message:x()})),canMerge:C(),canOverride:C()});w(`available`,[E({available:T(!0),mergeState:rr}),E({available:T(!1),reason:x()})]),E({merged:T(!0),number:S(),url:x(),method:tr,mergeCommitSha:x().optional()});var ir=E({path:x(),previousPath:x().optional(),status:k([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:S(),deletions:S(),patch:x().optional(),patchUnavailableReason:k([`binary`,`too-large`,`not-provided`]).optional(),truncated:C().optional()});w(`available`,[E({available:T(!0),number:S(),headSha:x(),files:O(ir),additions:S(),deletions:S(),truncated:C(),reason:x().optional()}),E({available:T(!1),reason:x()})]),E({generation:x().uuid()}),w(`state`,[E({generation:x().uuid(),state:T(`ready`),projects:O(Yn),membership:b(x(),O(x()))}),E({generation:x().uuid(),state:T(`unavailable`),reason:x()})]);function ar(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 or(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 sr(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 cr(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 lr(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 ur(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function dr(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function fr(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){dr(t.issues,a,r),dr(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 Y=e=>e.map(e=>e.number).join(`,`);function pr(e,t){let n=e[0];if(e.length>1&&n&&(Y(n.issues)!==Y(t.issues)||Y(n.prs)!==Y(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 mr(e,t,r=!0){let i=hi(),a=$(),o=e??i.data?.defaultRunner??`claude`,s=a.data?.capabilities?.localHandoff===!1?null:t,c=n(),l=A({queryKey:X.runnerSkills(o,s),queryFn:({signal:e})=>p(o,s,{signal:e,projectId:c}),enabled:r&&(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 X={get health(){return[n(),`health`]},runs:{get all(){return[n(),`runs`]},relationships:e=>[n(),`runs`,`relationships`,e],list:(e=n())=>[e,`runs`,`list`],archived:e=>[n(),`runs`,`archived`,e],detail:(e,t=n())=>[t,`runs`,`detail`,e],diff:e=>[n(),`runs`,`diff`,e],changes:e=>[n(),`runs`,`changes`,e],file:(e,t)=>[n(),`runs`,`files`,e,t],handoff:e=>[n(),`runs`,`handoff`,e],commits:e=>[n(),`runs`,`commits`,e],commit:(e,t)=>[n(),`runs`,`commit`,e,t]},get workflows(){return[n(),`workflows`]},runnerSkills:(e,t)=>[n(),`runner-skills`,e,t??null],get repo(){return[n(),`repo`]},get repoChanges(){return[n(),`repo`,`changes`]},repoCommit:e=>[n(),`repo`,`commit`,e],get repoBranches(){return[n(),`repo`,`branches`]},get uiState(){return[n(),`ui-state`]},get config(){return[n(),`config`]},get agentConfig(){return[n(),`agent-config`]},agentConfigFile:e=>[n(),`agent-config`,`file`,e],get worktrees(){return[n(),`worktrees`]},github:(e={})=>[n(),`github`,e.limit??null],githubPages:e=>[n(),`github`,`pages`,e],githubPagesHead:e=>[n(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[n(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],githubChecks:e=>[n(),`github`,`checks`,[...e].sort((e,t)=>e-t).join(`,`)],githubSearch:(e,t)=>[n(),`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)=>[n(),`github`,`comments`,e,t],githubItem:(e,t)=>[n(),`github`,`item`,e,t],githubRefStatusOf:e=>[e,`github`,`ref-status`],githubPrChanges:e=>[n(),`github`,`pr-changes`,e],githubMergeState:e=>[n(),`github`,`merge-state`,e],get openTargets(){return[n(),`open-targets`]}},Z={models:(e,t)=>t&&t!=="default"?[`workspace`,`models`,e,t]:[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:W,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)=>[...Z.fsBrowseRoot,e,t]};function hr(){let e=y();return A({queryKey:Z.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(Z.providerStatus),r=await Ie(!1,{signal:t});return Oe(n,e.getQueryData(Z.providerStatus),r)},staleTime:5*6e4,refetchInterval:a(!1),refetchOnWindowFocus:!0})}function gr(){let e=y();return P({mutationFn:()=>Ie(!0),onMutate:()=>e.getQueryData(Z.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Z.providerStatus,e=>Oe(r,e,t)),L(e)}})}function _r(){let e=y();return P({mutationFn:({provider:e,authFailureId:t})=>Xe(e,t),onMutate:()=>e.getQueryData(Z.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Z.providerStatus,e=>Oe(r,e,t,n.authFailureId)),L(e,n.provider)}})}function vr(e={}){return A({queryKey:Z.projects,queryFn:({signal:e})=>bt({signal:e}),...e})}function yr(e,t=!1){return A({queryKey:Z.fsBrowse(e,t),queryFn:({signal:n})=>Pe(e??void 0,{signal:n,showHidden:t}),retry:!1})}function br(){let e=y();return P({mutationFn:e=>pe(e),onSuccess:()=>e.invalidateQueries({queryKey:Z.projects})})}function xr(){let e=y();return P({mutationFn:e=>ze(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:Z.projects})}})}function Sr(){let e=y();return P({mutationFn:e=>{let{id:t,...n}=e;return jt(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:Z.projects});let r=e.getQueryData(Z.projects);return e.setQueryData(Z.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Cr(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(Z.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(Z.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:Z.projects})})}function Cr(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?[]:cr(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 wr(e){let t=y();return P({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(Z.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:Z.projects})})}function Tr(){return wr(e=>{let{projectId:t,...n}=e;return kt(t,n)})}function Er(){return wr(e=>{let{projectId:t,webhookId:n,...r}=e;return Ne(t,n,r)})}function Dr(){return wr(({projectId:e,webhookId:t})=>St(e,t))}function Or(){return P({mutationFn:({projectId:e,webhookId:t})=>at(e,t),retry:!1})}function kr(e){let t=y();return P({mutationFn:t=>de(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function Q(e){let t=y();return P({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:Z.agentProfiles}),t.invalidateQueries({queryKey:Z.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),L(t)])}})}function Ar(){return Q(e=>Tt(e))}function jr(){return Q(e=>{let{id:t,...n}=e;return De(t,n)})}function Mr(){return Q(e=>c(e))}function Nr(){return Q(e=>tt(e))}function Pr(e,t){return A({queryKey:Z.agentAccountStatus(e),queryFn:({signal:t})=>ue(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function Fr(){let e=y();return P({mutationFn:({provider:e,profileId:t})=>We(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:Z.agentProfiles}),e.invalidateQueries({queryKey:Z.providerStatus}),L(e,n,`none`)])}})}function Ir(){let e=y();return P({mutationFn:e=>ue(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(Z.agentAccountStatus(n),t),e.invalidateQueries({queryKey:Z.agentProfiles}),L(e,t.status.provider)}})}function Lr(){let e=y();return P({mutationFn:e=>rt(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Z.projects})})}function Rr(){let e=y();return P({mutationFn:e=>Me(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Z.projects})})}function zr({enabled:e}){return A({queryKey:Z.githubOwners,queryFn:({signal:e})=>o({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function Br(){let e=y();(0,M.useEffect)(()=>{let t,n=()=>{let n=e.getQueryData(X.health);n&&(ee({bootProject:n.bootProject??`default`,apiBase:r()}),t??=Lt(`health`,t=>{e.setQueryData(X.health,t)}))};n();let i=e.getQueryCache().subscribe(n);return()=>{i(),t?.(),ye()}},[e])}function $(){return A({queryKey:X.health,queryFn:({signal:e})=>je({signal:e})})}function Vr(e,t){let n=$().data,r=vr(t).data?.projects,i=gt(),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?ar(n?.repo?.remote):void 0}function Hr(){return A({queryKey:X.openTargets,queryFn:({signal:e})=>dt({signal:e}),staleTime:5*6e4})}function Ur(){return A({queryKey:X.runs.list(),queryFn:({signal:e})=>Ot(F(),{signal:e})})}function Wr(e,t){return Ft({queryKey:X.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>me({before:t,limit:200,q:e},{signal:n}),getNextPageParam:e=>e.nextCursor??void 0,placeholderData:(e,t)=>t?.queryKey[0]===n()?e:void 0})}function Gr(e){let t=e.trim();return A({queryKey:Z.runsSearch(t),queryFn:({signal:e})=>Fe(t,{signal:e}),enabled:t.length>=2,placeholderData:At,staleTime:1e4})}function Kr(e=!0,t=bn,n){let r=Cn(y());return j(`/api/v1/workspace/runs-index`,Z.runsIndex,a(e?t:!1),wn),A({queryKey:Z.runsIndex,queryFn:({signal:e})=>_e({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},staleTime:3e4,refetchInterval:!1})}function qr(e){let t=y();return P({mutationFn:({workerId:e,discardWork:t=!1})=>qn(e,t),onSettled:()=>t.invalidateQueries({queryKey:X.runs.relationships(e)})})}function Jr(e,t={}){return A({queryKey:X.runs.relationships(e),queryFn:({signal:t})=>ge(e,{signal:t}),enabled:t.enabled??!0})}function Yr(e){return A({queryKey:X.runs.detail(e??``),queryFn:({signal:t})=>mt(I(e),{signal:t}),enabled:!!e})}function Xr(e,t,n=!0){return A({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>mt(I(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t})}function Zr(e){return A({queryKey:X.runs.diff(e??``),queryFn:({signal:t})=>ke(e,{signal:t}),enabled:!!e})}function Qr(e,t=!1){return j(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,X.runs.changes(e??``),a(t?4e3:!1)),A({queryKey:X.runs.changes(e??``),queryFn:({signal:t})=>ot(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function $r(e,t){return A({queryKey:X.runs.file(e??``,t??``),queryFn:({signal:n})=>Et(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function ei(e,t){return A({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>ht(e,t,{signal:n}),enabled:t!==null,retry:!1})}function ti(e,t){return A({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>Nt(e,t,{signal:n}),enabled:t!==null,retry:!1})}function ni(e,t){return A({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>d(e,t,{signal:n}),enabled:t!==null,retry:!1})}function ri(e){return A({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>ve(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function ii(e,t=!1){return j(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,X.runs.commits(e??``),a(t?5e3:!1)),A({queryKey:X.runs.commits(e??``),queryFn:({signal:t})=>Ge(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function ai(e,t){return A({queryKey:X.runs.commit(e??``,t??``),queryFn:({signal:n})=>qe(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function oi(e,t=!0){return A({queryKey:X.runs.handoff(e??``),queryFn:({signal:t})=>Mt(I(e),{signal:t}),enabled:!!e&&t})}function si(e,t,n){return A({queryKey:e===void 0?X.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>Mt(I(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function ci(e,t){let r=[...new Set(e)],i=N({queries:r.map(e=>({queryKey:[e??n(),`automations`,`names`],queryFn:({signal:t})=>xe({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,M.useMemo)(()=>{let e=new Map;return a.forEach((t,n)=>{if(t?.available)for(let i of t.automations)e.set(JSON.stringify([r[n]??null,i.id]),i.name)}),(t,n)=>e.get(JSON.stringify([t??null,n]))},[JSON.stringify([r,i.map(e=>e.dataUpdatedAt)])])}function li(){return A({queryKey:X.workflows,queryFn:({signal:e})=>h({signal:e})})}function ui(){return A({queryKey:X.repo,queryFn:({signal:e})=>nt({signal:e})})}function di(e){return A({queryKey:[e,`repo`],queryFn:({signal:t})=>nt({signal:t},e)})}function fi(){return A({queryKey:X.repoBranches,queryFn:({signal:e})=>wt({signal:e})})}function pi(){return A({queryKey:X.repoChanges,queryFn:({signal:e})=>Le({signal:e}),retry:!1})}function mi(e){return A({queryKey:X.repoCommit(e??``),queryFn:({signal:t})=>Ue(e,{signal:t}),enabled:!!e,retry:!1})}function hi(){return A({queryKey:X.config,queryFn:({signal:e})=>oe({signal:e})})}function gi(){return A({queryKey:X.worktrees,queryFn:({signal:e})=>u({signal:e})})}function _i(e){return A({queryKey:[e,`worktrees`],queryFn:({signal:t})=>u({signal:t},e),staleTime:0})}function vi(e,t=!0,n=!1){return A({queryKey:[F({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>_({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:ce(e.sidebarLimits)},enabled:t})}function yi(){return vi(n())}function bi(){return A({queryKey:X.agentConfig,queryFn:({signal:e})=>v({signal:e})})}function xi(e){return A({queryKey:X.agentConfigFile(e??``),queryFn:({signal:t})=>ne(e,{signal:t}),enabled:e!==null})}function Si(e){let t=y(),n=X.agentConfig,r=X.agentConfigFile(e);return P({mutationFn:t=>te(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}function Ci(){return A({queryKey:Z.uiState,queryFn:({signal:e})=>$e({signal:e})})}function wi(){return A({queryKey:Z.config,queryFn:({signal:e})=>le({signal:e})})}function Ti(){return A({queryKey:Z.agentProfiles,queryFn:({signal:e})=>se({signal:e})})}function Ei(e){let t=y();return P({mutationFn:t=>f(e,t),onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function Di(e){let t=H(),n=e?.projectId,r=e?.cacheScope,i=P({mutationFn:e=>pt(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,M.useCallback)(e=>({...I(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,M.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,M.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,M.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function Oi(){let e=H();return P({mutationFn:e=>pt(I(e),!1),onMutate:t=>e.patchRead(()=>I(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function ki(e){let t=H();return P({mutationFn:({id:t,pinned:n})=>be(I(t,e),n),onError:e=>Rt(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??F(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Ai(e,t){let n=H();return P({mutationFn:n=>Ct(I(e,{projectId:t}),n),onMutate:()=>F({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof Je&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function ji(e,t){let n=H();return P({mutationFn:(n={})=>Te(I(e,{projectId:t}),n),onMutate:()=>F({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function Mi(e){let t=y();return P({mutationFn:({msgId:t,message:n})=>Qe(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function Ni(e){let t=y();return P({mutationFn:t=>ct(e,t),onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function Pi(e={},t=!0){let r=y(),i=X.github(e);j(`/api/v1/p/${n()}/github${e.limit===void 0?``:`?limit=${e.limit}`}`,i,a(t?6e4:!1));let o=A({queryKey:X.github(e),queryFn:({signal:t})=>ae({limit:e.limit},{signal:t}),enabled:t,staleTime:6e4,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),s=o.data?.projectsGeneration,c=A({queryKey:[...i,`projects`,s],queryFn:({signal:e})=>lt(s,{signal:e}),enabled:t&&o.data?.projectsState===`refreshing`&&!!s,staleTime:1/0,retry:!1});return(0,M.useEffect)(()=>{!s||!c.data&&!c.error||r.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.`}})},[r,s,c.data,c.error,i]),o}var Fi=class extends Error{};function Ii(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await ae({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new Fi(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>lr(e),retry:(e,t)=>!(t instanceof Fi)&&!(t instanceof Je&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function Li(e=50,t=!0){let r=y(),i=X.githubPages(e),o=X.githubPagesHead(e);j(`/api/v1/p/${n()}/github?limit=${e}`,o,a(t?6e4:!1));let s=Ft({...Ii(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),c=A({queryKey:o,queryFn:({signal:t})=>ae({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:l}=s;(0,M.useEffect)(()=>{if(!c.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=pr(e.pages,c.data);t===`refetch`?l():r.setQueryData(i,{...e,pages:t})},[r,c.dataUpdatedAt,l]);let u=(s.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),d=N({queries:u.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>lt(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,M.useEffect)(()=>{d.forEach((e,t)=>{let n=u[t];!n||!e.data&&!e.error||r.setQueryData(i,t=>{if(!t)return t;let r=!1,i=t.pages.map(t=>{if(t.projectsGeneration!==n||t.projectsState!==`refreshing`)return t;let i=e.data;return i?.generation&&i.generation!==n?t:(r=!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 r?{...t,pages:i}:t})})},[r,d.map((e,t)=>e.data||e.error?u[t]:``).join(`,`)]),{pages:s,data:(0,M.useMemo)(()=>fr(s.data?.pages??[]),[s.data])}}function Ri(e,t=50,n=!0){let r=Ft({...Ii([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,M.useMemo)(()=>fr(r.data?.pages??[]),[r.data])}}function zi(e,t,n=!0){let r=N({queries:t.filter(e=>e.length>0).map(t=>({queryKey:X.githubCommentCounts(e,t),queryFn:({signal:n})=>Se(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,M.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 Bi(e,t,n,r=!0){return A({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>Ze(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function Vi(e,t=!0){return A({queryKey:X.githubChecks(e),queryFn:({signal:t})=>Ce(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function Hi(e,t,n=!0){return A({queryKey:X.githubSearch(e,t),queryFn:({signal:n})=>Ze(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var Ui=100;function Wi(e){return[...e].sort((e,t)=>t-e).slice(0,Ui).sort((e,t)=>e-t)}function Gi(){let e=gt(),t=$();return e.projectId??t.data?.bootProject}function Ki(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))In(q({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))In(q({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var qi=5*6e4;function Ji(e){return e?e.recheckAfterMs:qi}function Yi(e,t=!0){let n=(0,M.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:Wi(t.prs),issues:Wi(t.issues)}))},[e.map(q).sort().join(`|`)]),r=N({queries:n.map(e=>({queryKey:X.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>vt(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>Ji(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),a=y(),o=JSON.stringify(n.map((e,t)=>({...e,interval:Ji(r[t]?.data)??!1})));(0,M.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=X.githubRefStatus(t.projectId,t.prs,t.issues);return It({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,M.useMemo)(()=>Kn(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,M.useCallback)(e=>{let t=q(e),n=s.get(t);if(n)return n;let r=G.get(t);return{state:`idle`,...r?{status:r}:{},...K.has(t)?{conflicting:!0}:{}}},[s])}function Xi(e,t,n=!0){return A({queryKey:X.githubComments(e,t),queryFn:({signal:n})=>we(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Zi(e,t,n=!0){return A({queryKey:X.githubItem(e,t),queryFn:({signal:n})=>fe(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Qi(e){return A({queryKey:X.githubPrChanges(e??0),queryFn:({signal:t})=>Be(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{gr as $,Qi as A,wi as At,Ri as B,Mn as Bt,Pi as C,si as Ct,Zi as D,Sr as Dt,Xi as E,jr as Et,Oi as F,ur as Ft,vi as G,Kt as Gt,di as H,H as Ht,kr as I,or as It,hr as J,I as Jt,_i as K,Gt as Kt,Hr as L,sr as Lt,$ as M,gi as Mt,Br as N,Z as Nt,zr as O,Er as Ot,Di as P,mr as Pt,Yi as Q,Ei as R,ar as Rt,yr as S,Ai as St,zi as T,yi as Tt,Vr as U,L as Ut,Bi as V,Cn as Vt,Xr as W,Jt as Wt,Ir as X,N as Xt,Si as Y,P as Yt,Gi as Z,zt as Zt,Rr as _,Jr as _t,xi as a,ui as at,Mi as b,Gr as bt,ti as c,mi as ct,ci as d,Qr as dt,br as et,Lr as f,ai as ft,Ar as g,oi as gt,ji as h,$r as ht,bi as i,Ni as it,Hi as j,Ci as jt,Li as k,li as kt,ni as l,_r as lt,Fr as m,Zr as mt,Ki as n,xr as nt,Ti as o,fi as ot,hi as p,ii as pt,vr as q,F as qt,Pr as r,Dr as rt,Wr as s,pi as st,X as t,Mr as tt,ri as u,Yr as ut,Tr as v,Ur as vt,Vi as w,Or as wt,ei as x,Nr as xt,qr as y,Kr as yt,ki as z,An as zt};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{c as n,o as r}from"./utils-DSMR_WLb.js";import{n as i,t as a}from"./live-refetch-CZb2VOyu.js";import{$ as o,$r as s,$t as c,Ai as l,At as u,B as d,Bt as f,Ct as p,Di as m,Dt as h,Ei as g,Et as _,F as v,Fr as ee,Gt as te,I as ne,In as re,Ir as ie,J as ae,K as oe,L as se,Nr as ce,Ot as le,P as ue,Pt as de,Q as fe,Qt as pe,R as me,Si as he,St as ge,Tt as _e,V as ve,Vr as ye,Vt as be,W as xe,X as Se,Y as Ce,Z as we,_ as Te,_i as Ee,_n as De,_r as Oe,_t as ke,ai as Ae,at as je,b as Me,bn as Ne,c as Pe,ci as y,cn as Fe,ct as Ie,dt as Le,ei as Re,en as ze,et as Be,f as Ve,fr as He,ft as Ue,g as We,gt as Ge,hn as Ke,ht as qe,i as Je,ii as Ye,in as Xe,it as Ze,j as Qe,kt as $e,li as et,ln as tt,lt as nt,m as rt,mi as it,mn as at,mt as ot,ni as st,nn as ct,nt as lt,oi as ut,ot as dt,pi as ft,pn as pt,pt as mt,q as ht,r as gt,ri as _t,rt as vt,sn as yt,st as bt,ti as xt,tn as St,un as Ct,ut as wt,v as Tt,vt as Et,wi as Dt,wt as Ot,x as kt,yi as At,yn as jt,yt as Mt,z as Nt}from"./project-scope-context-BDU1qGx3.js";import{B as b,H as x,L as S,M as C,N as w,O as Pt,P as T,R as E,Y as D,j as O,k}from"./live-protocol-D9ji1YCl.js";import{t as Ft}from"./useInfiniteQuery-BxpPo6z-.js";import{t as A}from"./useQuery-DcVi2Spi.js";import{n as It,r as j,t as Lt}from"./ws-Iixb-QFR.js";import{n as Rt}from"./toaster-Bo5vCbz-.js";var zt=class extends ft{#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||Bt(),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=it({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),D.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Bt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Vt=class extends l{#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),g(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Ee(t.mutationKey)!==Ee(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??Bt();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){D.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 Ht(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Ut(e,t,n){let r=e.slice(0);return r[t]=n,r}var Wt=class extends l{#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,D.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||!g(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Ht(e,n).forEach(e=>{e.destroy()}),Ht(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=Dt(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 et(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Ut(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)&&D.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},M=e(t(),1);function N({queries:e,...t},n){let r=y(n),i=ut(),a=Ae(),o=M.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{s(e);let t=r.getQueryCache().get(e.queryHash);st(e,a,t)}),Ye(a);let[c]=M.useState(()=>new Wt(r,o,t)),[l,u,d]=c.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;M.useSyncExternalStore(M.useCallback(e=>f?c.subscribe(D.batchCalls(e)):he,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),M.useEffect(()=>{c.setQueries(o,t)},[o,t,c]);let p=l.some((e,t)=>xt(o[t],e))?l.flatMap((e,t)=>{let n=o[t];return n&&xt(n,e)?Re(n,new et(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=l.find((e,t)=>{let n=o[t];return n&&_t({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 P(e,t){let n=y(t),[r]=M.useState(()=>new Vt(n,e));M.useEffect(()=>{r.setOptions(e)},[r,e]);let i=M.useSyncExternalStore(M.useCallback(e=>r.subscribe(D.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=M.useCallback((e,t)=>{r.mutate(e,t).catch(he)},[r]);if(i.error&&m(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function F(e={}){let t=e.projectId??n();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function I(e,t={}){return{...F(t),runId:e}}function Gt(e,t=!0,n=!1,r){return A({queryKey:[F({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>Ot(F({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function L(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:Z.models(t),refetchType:n})}function Kt(e,t=!0,n){return A({...qt(e,n),enabled:t})}var qt=(e,t)=>({queryKey:Z.models(e,t),queryFn:({signal:n})=>re(e,{signal:n},t),staleTime:300*1e3});function Jt(e,t=!0){let n=N({queries:e.map(e=>({...qt(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}var R=[`workspace`,`runs-index`],z=e=>[e.cacheScope,`runs`,`list`],B=e=>[e.cacheScope,`runs`,`detail`,e.runId],V=e=>typeof e==`function`?e():e;function Yt(e){let{seenAt:t,...n}=e;return n}function Xt(e,t){let n=Yt(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function Zt(e,t,n){return t?{...e,seenAt:n}:Yt(e)}function Qt(e){let t=()=>{e.invalidateQueries({queryKey:R})};function r(r,i){if(r===`index`)return t();let a=typeof i==`function`?i():i;if(r===`indexed`){t(),e.invalidateQueries({queryKey:[n(),`runs`]}),e.invalidateQueries({queryKey:[a.projectId,`runs`,`list`]});return}if(r===`runs`)return e.invalidateQueries({queryKey:[a.cacheScope,`runs`]});let o=ie(),s=[a.projectId,a.cacheScope],c=o!==void 0&&s.some(e=>e===o||e==="default")?[o,`default`]:[],l=new Set([...s,...c,n()]);return Promise.all([...l].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}async function i(n,r){await e.cancelQueries({queryKey:z(V(n))}),await e.cancelQueries({queryKey:B(V(n))});let i=e.getQueryData(z(V(n))),a=e.getQueryData(B(V(n))),o=V(n).runId,s=new Date().toISOString();return e.setQueryData(z(V(n)),e=>e?.map(e=>e.id===o?Zt(e,r,s):e)),e.setQueryData(B(V(n)),e=>e&&Zt(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(z(V(n)),i),a&&e.setQueryData(B(V(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(z(V(n)),e=>e?.map(e=>e.id===o?Xt(e,t):e)),a&&e.setQueryData(B(V(n)),e=>e&&Xt(e,a))},settle(i){let a=e=>e.id===(r?o:i.id)?Zt(e,r,i.seenAt):e;e.setQueryData(z(V(n)),e=>e?.map(a));let s={...V(n),runId:r?o:i.id};e.setQueryData(B(s),e=>e?a(e):i),t()}}}async function a(t,n){await e.cancelQueries({queryKey:R});let i=e.getQueryData(R),a=n();return e.setQueryData(R,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(R,i)},settle(){r(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:r}}function H(){let e=y();return(0,M.useMemo)(()=>Qt(e),[e])}function $t(e,t){return JSON.stringify([e,t])}function en(e){return e.type===`run`?e.run.id:e.id}function U(e,t){return{...e,runs:t}}function tn(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}var nn=class{runs;copied=!1;positions=new Map;constructor(e){this.runs=e,this.reindex()}reindex(){this.positions.clear(),this.runs.forEach((e,t)=>this.positions.set($t(e.projectId,e.id),t))}at(e,t){return this.positions.get($t(e,t))??-1}mutable(){return this.copied||=(this.runs=[...this.runs],!0),this.runs}replace(e,t){return this.mutable()[e]=t,this.runs}remove(e){return this.mutable().splice(e,1),this.reindex(),this.runs}insert(e){let t=this.runs.findIndex(t=>(t.createdAt??``).localeCompare(e.createdAt)<0);return this.mutable().splice(t<0?this.runs.length:t,0,e),this.reindex(),this.runs}};function rn(e,t,n){let r=new nn(e.runs),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=un(i,e.project,e.usage,r);else{let t=sn(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function an(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function on(e,t,n){return sn(e,t,n,new nn(e.runs))}function sn(e,t,n,r){let{project:i}=t,a=r.at(i,en(t)),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(i);if(t.type===`deleted`)return o?{index:U(e,r.remove(a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:U(e,r.remove(a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!an(e,i,n))return{index:e,reconcile:!0};let l=Dt(o,{projectId:i,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=r.replace(a,l),n=o.archived!==l.archived&&(s||tn(t,i)>e.perProjectLimit);return{index:U(e,t),reconcile:n}}if(s)return ln(e,l,r);let u=r.insert(l);return{index:U(e,u),reconcile:l.archived&&tn(u,i)>e.perProjectLimit}}function cn(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 ln(e,t,n){let r=cn(e.runs,t.projectId),i=r!==void 0&&t.createdAt>r;return t.archived&&!i?{index:e,reconcile:!1}:{index:U(e,n.insert(t)),reconcile:t.archived||r===void 0||t.createdAt<r}}function un(e,t,n,r){let i=!1;return e.runs.forEach((e,a)=>{if(e.projectId!==t)return;let o=n[e.id];if(o){let t=Dt(e.usage,o);if(t===e.usage)return;r.replace(a,{...e,usage:t})}else{if(e.usage===void 0)return;let{usage:t,...n}=e;r.replace(a,n)}i=!0}),i?U(e,r.runs):e}function dn(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 fn(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function pn(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 mn(e){e.stream=void 0}function hn(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,en(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function gn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function _n(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function vn(e,t,n){if(!_n(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=on(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 W=[`workspace`,`runs-index`],yn=[`workspace`,`projects`],bn=6e4,xn=100,Sn=new WeakMap;function Cn(e){let t=Sn.get(e);return t||(t=On(e),Sn.set(e,t)),t}function wn(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:Cn(t).merge(e)}function Tn(e){let t=e.getQueryData(yn)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function En(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 Dn(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 On(e){let t=fn(),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(W,t)},h=()=>e.getQueryData(W),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:W,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:W,exact:!0}).then(()=>e.invalidateQueries({queryKey:W})):e.invalidateQueries({queryKey:W})).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=Tn(e),{index:s,reconcile:c}=rn(a,t.filter(e=>e.generation===a.generation?e.type===`usage`?!l.has(e.project):!l.has(e.change.project)&&e.change.seq>a.eventSeq:!1),o);s!==a&&m(s),c&&_({hold:!0})},ee=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,xn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){pn(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){mn(t)},run(e,r,i=!1){if(l.has(e))return;let a=Dn(e,r);if(!hn(t,a,i)){p();return}n.push({type:`change`,change:a,generation:t.stream}),ee()},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}),ee()}},dropProject(e){l.add(e),gn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=dn(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=vn(t,n,Tn(e));for(let e of l)i.index=dn(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),En(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 kn={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`}},An={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function jn(e){return typeof e==`string`&&Object.hasOwn(kn,e)}function Mn(e){return e!==void 0&&jn(e)?kn[e]:void 0}var Nn=`cez.reference-statuses.v1`,Pn=`cez.reference-conflicts.v1`,G=new Map(Rn()),Fn=1e3;function In(e,t){if(G.get(e)!==t){for(G.delete(e),G.set(e,t);G.size>Fn;){let e=G.keys().next().value;if(e===void 0)break;G.delete(e)}Vn()}}var K=new Set(zn());function Ln(e,t){if(K.has(e)!==t){if(t)for(K.add(e);K.size>Fn;){let e=K.values().next().value;if(e===void 0)break;K.delete(e)}else K.delete(e);Vn()}}function Rn(){try{let e=globalThis.sessionStorage?.getItem(Nn);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`&&jn(e[1])):[]}catch{return[]}}function zn(){try{let e=globalThis.sessionStorage?.getItem(Pn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var Bn;function Vn(){Bn===void 0&&(Bn=setTimeout(()=>{Bn=void 0;try{globalThis.sessionStorage?.setItem(Nn,JSON.stringify([...G])),globalThis.sessionStorage?.setItem(Pn,JSON.stringify([...K]))}catch{}},250))}var q=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function Hn(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function Un(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 Wn(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;In(t,o),s!==void 0&&Ln(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function Gn(e,t,n){let r=q(t),i=G.get(r),a=K.has(r)?!0:void 0,o=n.data;if(o?.available){Wn(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...Hn(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...Hn(i,a)});return}e.set(r,{state:`loading`,...Hn(i,a)})}function Kn(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of Un(i))Gn(n,e,t)}),n}async function qn(e,t=!1){return Ke(await Ve.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:n(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),yt(e,`/worker-destroy`))}var Jn=k([`passing`,`failing`,`pending`]).nullable(),J=E({kind:k([`issue`,`pr`]),number:S(),title:x(),author:x(),createdAt:x(),labels:O(x()),body:x().optional(),url:x(),comments:S(),assignees:O(x()).optional(),projectIds:O(x()).optional(),isDraft:C().optional(),additions:S().optional(),deletions:S().optional(),checks:Jn.optional()});w(`available`,[E({available:T(!0),item:J.nullable(),labelColors:b(x(),x()).optional()}),E({available:T(!1),reason:x()})]),E({kind:k([`issue`,`pr`]),number:Pt().int().positive().safe()});var Yn=E({id:x(),title:x(),url:x()});E({available:C(),reason:x().optional(),repo:x().optional(),syncedAt:x().optional(),issues:O(J),prs:O(J),labelColors:b(x(),x()).optional(),viewerLogin:x().optional(),projects:O(Yn).optional(),projectsReason:x().optional(),projectsState:k([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:x().optional(),issuesTotal:S().int().nonnegative().optional(),prsTotal:S().int().nonnegative().optional(),issuesNextCursor:x().nullable().optional(),prsNextCursor:x().nullable().optional(),commentsDeferred:T(!0).optional()});var Xn=x().min(1).max(2e3).optional();E({limit:x().optional(),refresh:x().optional(),issuesCursor:Xn,prsCursor:Xn,issuesDone:T(`1`).optional(),prsDone:T(`1`).optional()}).superRefine((e,t)=>{e.issuesDone&&e.issuesCursor&&t.addIssue({code:`custom`,message:`issuesDone and issuesCursor are exclusive`}),e.prsDone&&e.prsCursor&&t.addIssue({code:`custom`,message:`prsDone and prsCursor are exclusive`}),e.issuesDone&&e.prsDone&&t.addIssue({code:`custom`,message:`both sides are done; there is no page to ask for`})}),E({kind:k([`issue`,`pr`]),numbers:x().regex(/^[1-9]\d{0,15}(,[1-9]\d{0,15})*$/).refine(e=>{let t=e.split(`,`);return t.length<=100&&t.every(e=>Number.isSafeInteger(Number(e)))},{message:`at most 100 safe positive integers`}),refresh:T(`1`).optional()}),w(`available`,[E({available:T(!0),counts:b(S(),S().int().nonnegative())}),E({available:T(!1),reason:x()})]),w(`available`,[E({available:T(!0),checks:b(S(),Jn)}),E({available:T(!1),reason:x()})]),E({kind:k([`issue`,`pr`]),q:x().trim().min(1).max(256),limit:Pt().int().positive().max(50).optional()}),E({available:C(),projectsReason:x().optional(),reason:x().optional(),items:O(J),truncated:C().optional(),labelColors:b(x(),x()).optional()});var Zn=S().nullable();w(`available`,[E({available:T(!0),prs:b(S(),He),issues:b(S(),He),conflicts:O(S()).optional(),recheckAfterMs:Zn}),E({available:T(!1),reason:x(),recheckAfterMs:Zn})]);var Qn=E({id:S(),author:x(),avatarUrl:x().optional(),createdAt:x(),body:x(),kind:k([`comment`,`review`]),reviewState:k([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:x()}),$n=k([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),er=E({id:x(),kind:$n,actor:x(),avatarUrl:x().optional(),createdAt:x(),url:x().optional(),sha:x().optional(),message:x().optional(),checks:Jn.optional(),label:E({name:x(),color:x().optional()}).optional(),subject:x().optional(),refNumber:S().optional(),refTitle:x().optional(),refIsPr:C().optional()});E({available:C(),reason:x().optional(),comments:O(Qn),truncated:C().optional(),events:O(er).optional(),detail:E({body:x(),additions:S().int().nonnegative().optional(),deletions:S().int().nonnegative().optional()}).optional()});var tr=k([`merge`,`squash`,`rebase`]),nr=E({name:x(),state:k([`passing`,`failing`,`pending`,`unknown`]),required:C().nullable(),url:x().optional()}),rr=E({number:S(),title:x(),url:x(),state:k([`open`,`closed`,`merged`]),isDraft:C(),headRef:x(),baseRef:x(),headSha:x(),mergeable:k([`mergeable`,`conflicting`,`unknown`]),reviewDecision:k([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:O(nr),methods:O(tr),defaultMethod:tr.nullable(),eligibility:k([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:O(E({code:x(),message:x()})),canMerge:C(),canOverride:C()});w(`available`,[E({available:T(!0),mergeState:rr}),E({available:T(!1),reason:x()})]),E({merged:T(!0),number:S(),url:x(),method:tr,mergeCommitSha:x().optional()});var ir=E({path:x(),previousPath:x().optional(),status:k([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:S(),deletions:S(),patch:x().optional(),patchUnavailableReason:k([`binary`,`too-large`,`not-provided`]).optional(),truncated:C().optional()});w(`available`,[E({available:T(!0),number:S(),headSha:x(),files:O(ir),additions:S(),deletions:S(),truncated:C(),reason:x().optional()}),E({available:T(!1),reason:x()})]),E({generation:x().uuid()}),w(`state`,[E({generation:x().uuid(),state:T(`ready`),projects:O(Yn),membership:b(x(),O(x()))}),E({generation:x().uuid(),state:T(`unavailable`),reason:x()})]);function ar(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 or(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 sr(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 cr(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 lr(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 ur(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function dr(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function fr(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){dr(t.issues,a,r),dr(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 Y=e=>e.map(e=>e.number).join(`,`);function pr(e,t){let n=e[0];if(e.length>1&&n&&(Y(n.issues)!==Y(t.issues)||Y(n.prs)!==Y(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 mr(e,t,r=!0){let i=hi(),a=$(),o=e??i.data?.defaultRunner??`claude`,s=a.data?.capabilities?.localHandoff===!1?null:t,c=n(),l=A({queryKey:X.runnerSkills(o,s),queryFn:({signal:e})=>p(o,s,{signal:e,projectId:c}),enabled:r&&(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 X={get health(){return[n(),`health`]},runs:{get all(){return[n(),`runs`]},relationships:e=>[n(),`runs`,`relationships`,e],list:(e=n())=>[e,`runs`,`list`],archived:e=>[n(),`runs`,`archived`,e],detail:(e,t=n())=>[t,`runs`,`detail`,e],diff:e=>[n(),`runs`,`diff`,e],changes:e=>[n(),`runs`,`changes`,e],file:(e,t)=>[n(),`runs`,`files`,e,t],handoff:e=>[n(),`runs`,`handoff`,e],commits:e=>[n(),`runs`,`commits`,e],commit:(e,t)=>[n(),`runs`,`commit`,e,t]},get workflows(){return[n(),`workflows`]},runnerSkills:(e,t)=>[n(),`runner-skills`,e,t??null],get repo(){return[n(),`repo`]},get repoChanges(){return[n(),`repo`,`changes`]},repoCommit:e=>[n(),`repo`,`commit`,e],get repoBranches(){return[n(),`repo`,`branches`]},get uiState(){return[n(),`ui-state`]},get config(){return[n(),`config`]},get agentConfig(){return[n(),`agent-config`]},agentConfigFile:e=>[n(),`agent-config`,`file`,e],get worktrees(){return[n(),`worktrees`]},github:(e={})=>[n(),`github`,e.limit??null],githubPages:e=>[n(),`github`,`pages`,e],githubPagesHead:e=>[n(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[n(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],githubChecks:e=>[n(),`github`,`checks`,[...e].sort((e,t)=>e-t).join(`,`)],githubSearch:(e,t)=>[n(),`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)=>[n(),`github`,`comments`,e,t],githubItem:(e,t)=>[n(),`github`,`item`,e,t],githubRefStatusOf:e=>[e,`github`,`ref-status`],githubPrChanges:e=>[n(),`github`,`pr-changes`,e],githubMergeState:e=>[n(),`github`,`merge-state`,e],get openTargets(){return[n(),`open-targets`]}},Z={models:(e,t)=>t&&t!=="default"?[`workspace`,`models`,e,t]:[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:W,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)=>[...Z.fsBrowseRoot,e,t]};function hr(){let e=y();return A({queryKey:Z.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(Z.providerStatus),r=await Ie(!1,{signal:t});return Oe(n,e.getQueryData(Z.providerStatus),r)},staleTime:5*6e4,refetchInterval:a(!1),refetchOnWindowFocus:!0})}function gr(){let e=y();return P({mutationFn:()=>Ie(!0),onMutate:()=>e.getQueryData(Z.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Z.providerStatus,e=>Oe(r,e,t)),L(e)}})}function _r(){let e=y();return P({mutationFn:({provider:e,authFailureId:t})=>Xe(e,t),onMutate:()=>e.getQueryData(Z.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Z.providerStatus,e=>Oe(r,e,t,n.authFailureId)),L(e,n.provider)}})}function vr(e={}){return A({queryKey:Z.projects,queryFn:({signal:e})=>bt({signal:e}),...e})}function yr(e,t=!1){return A({queryKey:Z.fsBrowse(e,t),queryFn:({signal:n})=>Pe(e??void 0,{signal:n,showHidden:t}),retry:!1})}function br(){let e=y();return P({mutationFn:e=>pe(e),onSuccess:()=>e.invalidateQueries({queryKey:Z.projects})})}function xr(){let e=y();return P({mutationFn:e=>ze(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:Z.projects})}})}function Sr(){let e=y();return P({mutationFn:e=>{let{id:t,...n}=e;return jt(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:Z.projects});let r=e.getQueryData(Z.projects);return e.setQueryData(Z.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Cr(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(Z.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(Z.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:Z.projects})})}function Cr(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?[]:cr(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 wr(e){let t=y();return P({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(Z.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:Z.projects})})}function Tr(){return wr(e=>{let{projectId:t,...n}=e;return kt(t,n)})}function Er(){return wr(e=>{let{projectId:t,webhookId:n,...r}=e;return Ne(t,n,r)})}function Dr(){return wr(({projectId:e,webhookId:t})=>St(e,t))}function Or(){return P({mutationFn:({projectId:e,webhookId:t})=>at(e,t),retry:!1})}function kr(e){let t=y();return P({mutationFn:t=>de(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function Q(e){let t=y();return P({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:Z.agentProfiles}),t.invalidateQueries({queryKey:Z.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),L(t)])}})}function Ar(){return Q(e=>Tt(e))}function jr(){return Q(e=>{let{id:t,...n}=e;return De(t,n)})}function Mr(){return Q(e=>c(e))}function Nr(){return Q(e=>tt(e))}function Pr(e,t){return A({queryKey:Z.agentAccountStatus(e),queryFn:({signal:t})=>ue(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function Fr(){let e=y();return P({mutationFn:({provider:e,profileId:t})=>We(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:Z.agentProfiles}),e.invalidateQueries({queryKey:Z.providerStatus}),L(e,n,`none`)])}})}function Ir(){let e=y();return P({mutationFn:e=>ue(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(Z.agentAccountStatus(n),t),e.invalidateQueries({queryKey:Z.agentProfiles}),L(e,t.status.provider)}})}function Lr(){let e=y();return P({mutationFn:e=>rt(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Z.projects})})}function Rr(){let e=y();return P({mutationFn:e=>Me(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Z.projects})})}function zr({enabled:e}){return A({queryKey:Z.githubOwners,queryFn:({signal:e})=>o({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function Br(){let e=y();(0,M.useEffect)(()=>{let t,n=()=>{let n=e.getQueryData(X.health);n&&(ee({bootProject:n.bootProject??`default`,apiBase:r()}),t??=Lt(`health`,t=>{e.setQueryData(X.health,t)}))};n();let i=e.getQueryCache().subscribe(n);return()=>{i(),t?.(),ye()}},[e])}function $(){return A({queryKey:X.health,queryFn:({signal:e})=>je({signal:e})})}function Vr(e,t){let n=$().data,r=vr(t).data?.projects,i=gt(),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?ar(n?.repo?.remote):void 0}function Hr(){return A({queryKey:X.openTargets,queryFn:({signal:e})=>dt({signal:e}),staleTime:5*6e4})}function Ur(){return A({queryKey:X.runs.list(),queryFn:({signal:e})=>Ot(F(),{signal:e})})}function Wr(e,t){return Ft({queryKey:X.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>me({before:t,limit:200,q:e},{signal:n}),getNextPageParam:e=>e.nextCursor??void 0,placeholderData:(e,t)=>t?.queryKey[0]===n()?e:void 0})}function Gr(e){let t=e.trim();return A({queryKey:Z.runsSearch(t),queryFn:({signal:e})=>Fe(t,{signal:e}),enabled:t.length>=2,placeholderData:At,staleTime:1e4})}function Kr(e=!0,t=bn,n){let r=Cn(y());return j(`/api/v1/workspace/runs-index`,Z.runsIndex,a(e?t:!1),wn),A({queryKey:Z.runsIndex,queryFn:({signal:e})=>_e({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},staleTime:3e4,refetchInterval:!1})}function qr(e){let t=y();return P({mutationFn:({workerId:e,discardWork:t=!1})=>qn(e,t),onSettled:()=>t.invalidateQueries({queryKey:X.runs.relationships(e)})})}function Jr(e,t={}){return A({queryKey:X.runs.relationships(e),queryFn:({signal:t})=>ge(e,{signal:t}),enabled:t.enabled??!0})}function Yr(e){return A({queryKey:X.runs.detail(e??``),queryFn:({signal:t})=>mt(I(e),{signal:t}),enabled:!!e})}function Xr(e,t,n=!0){return A({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>mt(I(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t})}function Zr(e){return A({queryKey:X.runs.diff(e??``),queryFn:({signal:t})=>ke(e,{signal:t}),enabled:!!e})}function Qr(e,t=!1){return j(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,X.runs.changes(e??``),a(t?4e3:!1)),A({queryKey:X.runs.changes(e??``),queryFn:({signal:t})=>ot(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function $r(e,t){return A({queryKey:X.runs.file(e??``,t??``),queryFn:({signal:n})=>Et(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function ei(e,t){return A({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>ht(e,t,{signal:n}),enabled:t!==null,retry:!1})}function ti(e,t){return A({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>Nt(e,t,{signal:n}),enabled:t!==null,retry:!1})}function ni(e,t){return A({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>d(e,t,{signal:n}),enabled:t!==null,retry:!1})}function ri(e){return A({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>ve(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function ii(e,t=!1){return j(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,X.runs.commits(e??``),a(t?5e3:!1)),A({queryKey:X.runs.commits(e??``),queryFn:({signal:t})=>Ge(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function ai(e,t){return A({queryKey:X.runs.commit(e??``,t??``),queryFn:({signal:n})=>qe(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function oi(e,t=!0){return A({queryKey:X.runs.handoff(e??``),queryFn:({signal:t})=>Mt(I(e),{signal:t}),enabled:!!e&&t})}function si(e,t,n){return A({queryKey:e===void 0?X.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>Mt(I(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function ci(e,t){let r=[...new Set(e)],i=N({queries:r.map(e=>({queryKey:[e??n(),`automations`,`names`],queryFn:({signal:t})=>xe({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,M.useMemo)(()=>{let e=new Map;return a.forEach((t,n)=>{if(t?.available)for(let i of t.automations)e.set(JSON.stringify([r[n]??null,i.id]),i.name)}),(t,n)=>e.get(JSON.stringify([t??null,n]))},[JSON.stringify([r,i.map(e=>e.dataUpdatedAt)])])}function li(){return A({queryKey:X.workflows,queryFn:({signal:e})=>h({signal:e})})}function ui(){return A({queryKey:X.repo,queryFn:({signal:e})=>nt({signal:e})})}function di(e){return A({queryKey:[e,`repo`],queryFn:({signal:t})=>nt({signal:t},e)})}function fi(){return A({queryKey:X.repoBranches,queryFn:({signal:e})=>wt({signal:e})})}function pi(){return A({queryKey:X.repoChanges,queryFn:({signal:e})=>Le({signal:e}),retry:!1})}function mi(e){return A({queryKey:X.repoCommit(e??``),queryFn:({signal:t})=>Ue(e,{signal:t}),enabled:!!e,retry:!1})}function hi(){return A({queryKey:X.config,queryFn:({signal:e})=>oe({signal:e})})}function gi(){return A({queryKey:X.worktrees,queryFn:({signal:e})=>u({signal:e})})}function _i(e){return A({queryKey:[e,`worktrees`],queryFn:({signal:t})=>u({signal:t},e),staleTime:0})}function vi(e,t=!0,n=!1){return A({queryKey:[F({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>_({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:ce(e.sidebarLimits)},enabled:t})}function yi(){return vi(n())}function bi(){return A({queryKey:X.agentConfig,queryFn:({signal:e})=>v({signal:e})})}function xi(e){return A({queryKey:X.agentConfigFile(e??``),queryFn:({signal:t})=>ne(e,{signal:t}),enabled:e!==null})}function Si(e){let t=y(),n=X.agentConfig,r=X.agentConfigFile(e);return P({mutationFn:t=>te(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}function Ci(){return A({queryKey:Z.uiState,queryFn:({signal:e})=>$e({signal:e})})}function wi(){return A({queryKey:Z.config,queryFn:({signal:e})=>le({signal:e})})}function Ti(){return A({queryKey:Z.agentProfiles,queryFn:({signal:e})=>se({signal:e})})}function Ei(e){let t=y();return P({mutationFn:t=>f(e,t),onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function Di(e){let t=H(),n=e?.projectId,r=e?.cacheScope,i=P({mutationFn:e=>pt(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,M.useCallback)(e=>({...I(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,M.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,M.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,M.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function Oi(){let e=H();return P({mutationFn:e=>pt(I(e),!1),onMutate:t=>e.patchRead(()=>I(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function ki(e){let t=H();return P({mutationFn:({id:t,pinned:n})=>be(I(t,e),n),onError:e=>Rt(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??F(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Ai(e,t){let n=H();return P({mutationFn:n=>Ct(I(e,{projectId:t}),n),onMutate:()=>F({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof Je&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function ji(e,t){let n=H();return P({mutationFn:(n={})=>Te(I(e,{projectId:t}),n),onMutate:()=>F({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function Mi(e){let t=y();return P({mutationFn:({msgId:t,message:n})=>Qe(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function Ni(e){let t=y();return P({mutationFn:t=>ct(e,t),onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function Pi(e={},t=!0){let r=y(),i=X.github(e);j(`/api/v1/p/${n()}/github${e.limit===void 0?``:`?limit=${e.limit}`}`,i,a(t?6e4:!1));let o=A({queryKey:X.github(e),queryFn:({signal:t})=>ae({limit:e.limit},{signal:t}),enabled:t,staleTime:6e4,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),s=o.data?.projectsGeneration,c=A({queryKey:[...i,`projects`,s],queryFn:({signal:e})=>lt(s,{signal:e}),enabled:t&&o.data?.projectsState===`refreshing`&&!!s,staleTime:1/0,retry:!1});return(0,M.useEffect)(()=>{!s||!c.data&&!c.error||r.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.`}})},[r,s,c.data,c.error,i]),o}var Fi=class extends Error{};function Ii(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await ae({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new Fi(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>lr(e),retry:(e,t)=>!(t instanceof Fi)&&!(t instanceof Je&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function Li(e=50,t=!0){let r=y(),i=X.githubPages(e),o=X.githubPagesHead(e);j(`/api/v1/p/${n()}/github?limit=${e}`,o,a(t?6e4:!1));let s=Ft({...Ii(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),c=A({queryKey:o,queryFn:({signal:t})=>ae({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:l}=s;(0,M.useEffect)(()=>{if(!c.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=pr(e.pages,c.data);t===`refetch`?l():r.setQueryData(i,{...e,pages:t})},[r,c.dataUpdatedAt,l]);let u=(s.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),d=N({queries:u.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>lt(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,M.useEffect)(()=>{d.forEach((e,t)=>{let n=u[t];!n||!e.data&&!e.error||r.setQueryData(i,t=>{if(!t)return t;let r=!1,i=t.pages.map(t=>{if(t.projectsGeneration!==n||t.projectsState!==`refreshing`)return t;let i=e.data;return i?.generation&&i.generation!==n?t:(r=!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 r?{...t,pages:i}:t})})},[r,d.map((e,t)=>e.data||e.error?u[t]:``).join(`,`)]),{pages:s,data:(0,M.useMemo)(()=>fr(s.data?.pages??[]),[s.data])}}function Ri(e,t=50,n=!0){let r=Ft({...Ii([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,M.useMemo)(()=>fr(r.data?.pages??[]),[r.data])}}function zi(e,t,n=!0){let r=N({queries:t.filter(e=>e.length>0).map(t=>({queryKey:X.githubCommentCounts(e,t),queryFn:({signal:n})=>Se(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,M.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 Bi(e,t,n,r=!0){return A({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>Ze(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function Vi(e,t=!0){return A({queryKey:X.githubChecks(e),queryFn:({signal:t})=>Ce(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function Hi(e,t,n=!0){return A({queryKey:X.githubSearch(e,t),queryFn:({signal:n})=>Ze(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var Ui=100;function Wi(e){return[...e].sort((e,t)=>t-e).slice(0,Ui).sort((e,t)=>e-t)}function Gi(){let e=gt(),t=$();return e.projectId??t.data?.bootProject}function Ki(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))In(q({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))In(q({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var qi=5*6e4;function Ji(e){return e?e.recheckAfterMs:qi}function Yi(e,t=!0){let n=(0,M.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:Wi(t.prs),issues:Wi(t.issues)}))},[e.map(q).sort().join(`|`)]),r=N({queries:n.map(e=>({queryKey:X.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>vt(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>Ji(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),a=y(),o=JSON.stringify(n.map((e,t)=>({...e,interval:Ji(r[t]?.data)??!1})));(0,M.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=X.githubRefStatus(t.projectId,t.prs,t.issues);return It({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,M.useMemo)(()=>Kn(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,M.useCallback)(e=>{let t=q(e),n=s.get(t);if(n)return n;let r=G.get(t);return{state:`idle`,...r?{status:r}:{},...K.has(t)?{conflicting:!0}:{}}},[s])}function Xi(e,t,n=!0){return A({queryKey:X.githubComments(e,t),queryFn:({signal:n})=>we(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Zi(e,t,n=!0){return A({queryKey:X.githubItem(e,t),queryFn:({signal:n})=>fe(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Qi(e){return A({queryKey:X.githubPrChanges(e??0),queryFn:({signal:t})=>Be(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{gr as $,Qi as A,wi as At,Ri as B,Mn as Bt,Pi as C,si as Ct,Zi as D,Sr as Dt,Xi as E,jr as Et,Oi as F,ur as Ft,vi as G,Kt as Gt,di as H,H as Ht,kr as I,or as It,hr as J,I as Jt,_i as K,Gt as Kt,Hr as L,sr as Lt,$ as M,gi as Mt,Br as N,Z as Nt,zr as O,Er as Ot,Di as P,mr as Pt,Yi as Q,Ei as R,ar as Rt,yr as S,Ai as St,zi as T,yi as Tt,Vr as U,L as Ut,Bi as V,Cn as Vt,Xr as W,Jt as Wt,Ir as X,N as Xt,Si as Y,P as Yt,Gi as Z,zt as Zt,Rr as _,Jr as _t,xi as a,ui as at,Mi as b,Gr as bt,ti as c,mi as ct,ci as d,Qr as dt,br as et,Lr as f,ai as ft,Ar as g,oi as gt,ji as h,$r as ht,bi as i,Ni as it,Hi as j,Ci as jt,Li as k,li as kt,ni as l,_r as lt,Fr as m,Zr as mt,Ki as n,xr as nt,Ti as o,fi as ot,hi as p,ii as pt,vr as q,F as qt,Pr as r,Dr as rt,Wr as s,pi as st,X as t,Mr as tt,ri as u,Yr as ut,Tr as v,Ur as vt,Vi as w,Or as wt,ei as x,Nr as xt,qr as y,Kr as yt,ki as z,An as zt};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{n as r,t as i}from"./utils-DSMR_WLb.js";import{Bt as a,Q as o,zt as s}from"./queries-BaHOUYn4.js";import{n as c}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{a as l}from"./tasks-table-I_z4e7uI.js";import{F as u,H as d,M as f,N as p,P as m,f as h,g,h as _,m as v,ot as y,p as b}from"./design-icons-CzEoMH9c.js";import{t as x}from"./createLucideIcon-BHp8sXmF.js";import{n as S,r as C,t as w}from"./popover-BPgUYFyu.js";var T=x(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),E={general:[`Settings`,`General`],webhooks:[`Settings`,`General`,`Webhooks`],providers:[`Settings`,`Agent defaults`,`Providers`],projects:[`Settings`,`Projects`],worktrees:[`Settings`,`Worktrees`],sidebar:[`Settings`,`Sidebar`]};function D(e,t=` → `){return E[e].join(t)}var O=e(t(),1),k=n(),A=(0,O.createContext)(null);function j({children:e}){let[t,n]=(0,O.useState)(()=>new Map),r=(0,O.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return r.set(e,t),r})},[]),i=(0,O.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),a=o((0,O.useMemo)(()=>[...t.values()].flat(),[t])),s=(0,O.useMemo)(()=>({publish:r,retract:i,lookup:a}),[r,i,a]);return(0,k.jsx)(A.Provider,{value:s,children:e})}var M=(0,O.createContext)(null);function ee({projectId:e,repoBase:t,requests:n,children:r}){let i=(0,O.useContext)(A),a=(0,O.useContext)(M),s=(0,O.useId)();(0,O.useEffect)(()=>{if(i)return i.publish(s,n),()=>i.retract(s)},[i,s,n.map(e=>`${e.projectId} ${e.kind}#${e.number}`).sort().join(`|`)]);let c=o(i?N:n),l=i?.lookup??c,u=t??(a&&a.projectId===e?a.repoBase:void 0),d=(0,O.useMemo)(()=>({lookup:l,projectId:e,repoBase:u}),[l,e,u]);return(0,k.jsx)(M.Provider,{value:d,children:r})}var N=[];function P(e,t,n){let r=(0,O.useContext)(M),i=n??r?.projectId;return!r||!i||t===void 0?te:r.lookup({projectId:i,kind:e,number:t})}function F(e,t){let n=(0,O.useContext)(M),r=t??n?.projectId;return!n||!r?[]:e.filter(e=>n.lookup({projectId:r,kind:`PR`,number:e}).conflicting===!0)}function I(){let e=(0,O.useContext)(M);return{projectId:e?.projectId,repoBase:e?.repoBase}}var te=Object.freeze({state:`idle`}),ne={success:`border-success/40 text-success`,danger:`border-danger/40 text-danger`,accent:`border-accent-strong/35 text-accent-text`,merged:`border-merged-strong/35 text-merged-text`,info:`border-info/40 text-info`,neutral:`border-border text-muted-foreground`,pending:`border-pending-strong/45 text-pending-strong`,conflict:`border-conflict/45 text-conflict`},L={success:`text-success`,danger:`text-danger`,accent:`text-merged-text`,merged:`text-merged-text`,info:`text-info`,neutral:`text-soft-foreground`,pending:`text-pending-strong`,conflict:`text-conflict`},re={success:`hover:bg-success/10`,danger:`hover:bg-danger/10`,accent:`hover:bg-accent-strong/10`,merged:`hover:bg-merged-strong/10`,info:`hover:bg-info/10`,neutral:`hover:bg-muted`,pending:`hover:bg-pending-strong/10`,conflict:`hover:bg-conflict/10`},R={draft:m,"review-required":u,"changes-requested":d,"checks-pending":null,"checks-failing":g,ready:h,merged:f,closed:p,open:b,completed:h,"not-planned":_};function z(e){return e===`PR`?`pr-chip`:`issue-chip`}function B(e){return e?{"data-conflicting":`true`}:{}}function V(e,t,n,r){return!n||r!==void 0&&l({kind:e,number:t??0,url:n},r)}function H(e,t,n){return e===`PR`&&(t??n)===!0}function U({plain:e,inert:t,conflicting:n,className:r,tone:a}){return e?i(`inline-flex items-center gap-1 rounded-[2px] text-inherit`,n&&`text-conflict font-medium`,!t&&`group/reference focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground`,r):i(`inline-flex h-[22px] items-center gap-1 rounded-md border px-1.5 font-mono text-[12px] font-normal`,ne[a],r)}function W(e,t,n,r){return n&&!r?t?`${e===`PR`?`PR `:``}#${t}`:e:t?`${!r&&e===`Issue`?`Issue `:``}#${t}`:e}function G(e){return e===`PR`?`pull request`:`issue`}function K(e,t,n,r){return`Open the ${e}${t?` #${t}`:``} for ${n}${r?` — ${r.label}`:``}`}function q(e,t){return e&&t?L[t.tone]:void 0}function J(e,t){return!e&&(!t||!r(t))}function Y({conflicting:e,presentation:t,status:n,plain:r,compact:a,inert:o,kind:s,label:c,glyphClass:l}){return(0,k.jsxs)(k.Fragment,{children:[e?(0,k.jsx)(y,{className:i(`size-2.5 shrink-0`,l),"aria-hidden":`true`}):(0,k.jsx)($,{status:t?n:void 0,className:r?i(`size-2.5`,l):void 0}),r&&a?s===`PR`?(0,k.jsx)(u,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):(0,k.jsx)(b,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):null,r?(0,k.jsx)(`span`,{className:o?void 0:`underline-offset-2 group-hover/reference:underline group-focus-visible/reference:underline`,children:c}):c]})}function ie({kind:e,status:t,conflicting:n,chipClass:r,body:i}){return(0,k.jsx)(`span`,{"data-slot":z(e),"data-status":t,"data-inert":`true`,...B(n),className:r,children:i})}function ae({kind:e,number:t,tooltip:n,url:i}){return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`span`,{className:`block font-medium`,children:[e===`PR`?`Pull request`:`Issue`,t?` #${t}`:``,` · `,n.headline]}),(0,k.jsx)(`span`,{className:`block`,children:n.detail}),n.also?(0,k.jsx)(`span`,{className:`block opacity-70`,children:n.also}):null,i&&r(i)?(0,k.jsx)(`span`,{className:`block opacity-70`,children:i.replace(/^https?:\/\//,``)}):null]})}function oe({reference:e,taskTitle:t,status:n,conflicting:r,conflictAction:o,projectId:c,repoBase:l,to:u,className:d,compact:f=!1,plain:p=!1,inert:m=!1}){let{kind:h,number:g,url:_}=e,v=I(),y=P(h,V(h,g,_,l??v.repoBase)?g:void 0,c),b=n??y.status,x=a(b),S=H(h,r,y.conflicting),C=S?s:x,w=C?.tone??`accent`,T=U({plain:p,inert:m,conflicting:S,className:d,tone:w}),E=ue(y,C,S?x:void 0),D=W(h,g,p,f),O=G(h),A=K(O,g,t,C),j=(0,k.jsx)(Y,{conflicting:S,presentation:C,status:b,plain:p,compact:f,inert:m,kind:h,label:D,glyphClass:q(p,C)});if(m)return(0,k.jsx)(ie,{kind:h,status:b,conflicting:S,chipClass:T,body:j});let M=J(u,_)?(0,k.jsx)(`span`,{"data-slot":z(h),"data-status":b,...B(S),"aria-label":C?`${O} ${D} — ${C.label}`:void 0,className:T,children:j}):(0,k.jsx)(se,{to:u,url:_,"data-slot":z(h),"data-status":b,...B(S),title:E?void 0:_,"aria-label":A,className:p?T:i(T,re[w]),children:j});return E?(0,k.jsx)(le,{chip:M,action:S?o:void 0,state:y.state,children:(0,k.jsx)(ae,{kind:h,number:g,tooltip:E,url:_})}):M}function se({to:e,url:t,children:n,...r}){return e?(0,k.jsx)(c,{to:e,...r,children:n}):(0,k.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,...r,children:n})}var X=(0,O.createContext)(()=>{});function ce(){return(0,O.useContext)(X)}var Z=150,Q=120;function le({chip:e,action:t,state:n,children:r}){let[i,a]=(0,O.useState)(!1),o=(0,O.useRef)(null),s=(0,O.useRef)(null),c=(0,O.useRef)(void 0),l=(0,O.useCallback)((e,t)=>{clearTimeout(c.current),c.current=setTimeout(()=>a(e),t)},[]),u=(0,O.useCallback)(()=>{clearTimeout(c.current),a(!1)},[]);(0,O.useEffect)(()=>()=>clearTimeout(c.current),[]);let d=e=>e instanceof Node&&(s.current?.contains(e)||o.current?.contains(e));return(0,k.jsxs)(w,{open:i,onOpenChange:e=>e?a(!0):u(),children:[(0,k.jsx)(S,{asChild:!0,ref:o,onPointerEnter:e=>{e.pointerType!==`touch`&&l(!0,Z)},onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,Q)},onFocus:()=>a(!0),onBlur:e=>{d(e.relatedTarget)||u()},onKeyDown:e=>{if(e.key===`Escape`)return u();if(e.key!==`Tab`||e.shiftKey||!t)return;let n=s.current?.querySelector(`button:not([disabled]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);n&&(e.preventDefault(),n.focus())},...t?{"aria-haspopup":`dialog`,"aria-expanded":i}:{},children:e}),(0,k.jsxs)(C,{ref:s,side:`top`,role:t?`dialog`:`tooltip`,"data-slot":`reference-status-card`,"data-tooltip-state":n,className:`w-64 space-y-2 p-3 text-xs`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),d(document.activeElement)&&o.current?.focus()},onPointerEnter:()=>clearTimeout(c.current),onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,Q)},children:[(0,k.jsx)(`div`,{className:`space-y-0.5`,children:r}),t?(0,k.jsx)(X.Provider,{value:u,children:t}):null]})]})}function ue(e,t,n){if(t){let{label:r,hint:i}=t,a=n?`also ${de(n.label)} — ${n.hint}`:void 0;return e.state===`unavailable`?{headline:r,detail:`last known — GitHub is unreachable${e.reason?` (${e.reason})`:``}`,...a?{also:a}:{}}:{headline:r,detail:i,...a?{also:a}:{}}}switch(e.state){case`loading`:return{headline:`Checking GitHub…`,detail:`the status of this reference is on its way`};case`unavailable`:return{headline:`Status unavailable`,detail:e.reason??`GitHub could not be reached — the chip says nothing rather than guessing`};case`unknown`:return{headline:`Not found on this repository`,detail:`GitHub has no such number here — the reference may point at another repo`};default:return null}}function de(e){return e.charAt(0).toLowerCase()+e.slice(1)}function fe({kind:e,number:t,className:n}){let r=P(e,t),o=a(r.status),c=e===`PR`&&r.conflicting===!0,l=c?s:o;if(!l)return null;let u=i(`size-2.5`,L[l.tone]);return(0,k.jsx)(`span`,{"data-slot":`reference-status-glyph`,"data-status":r.status,...c?{"data-conflicting":`true`}:{},"aria-hidden":`true`,className:i(`inline-flex items-center`,n),children:c?(0,k.jsx)(y,{className:i(`shrink-0`,u),"aria-hidden":`true`}):(0,k.jsx)($,{status:r.status,className:u})})}function $({status:e,className:t}){if(!e)return null;if(e===`checks-pending`)return(0,k.jsx)(v,{"data-slot":`status-dot`,"data-tone":`pending`,className:i(`size-3 animate-pulse motion-reduce:animate-none`,t),"aria-hidden":`true`});let n=R[e];return n?(0,k.jsx)(n,{className:i(`size-2.5 shrink-0`,t),"aria-hidden":`true`}):null}export{j as a,P as c,ee as i,D as l,fe as n,F as o,ce as r,I as s,oe as t,T as u};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{n as r,t as i}from"./utils-DSMR_WLb.js";import{Bt as a,Q as o,zt as s}from"./queries--x5yVcip.js";import{n as c}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{a as l}from"./tasks-table-BCuA9Kx7.js";import{F as u,H as d,M as f,N as p,P as m,f as h,g,h as _,m as v,ot as y,p as b}from"./design-icons-CzEoMH9c.js";import{t as x}from"./createLucideIcon-BHp8sXmF.js";import{n as S,r as C,t as w}from"./popover-BPgUYFyu.js";var T=x(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),E={general:[`Settings`,`General`],webhooks:[`Settings`,`General`,`Webhooks`],providers:[`Settings`,`Agent defaults`,`Providers`],projects:[`Settings`,`Projects`],worktrees:[`Settings`,`Worktrees`],sidebar:[`Settings`,`Sidebar`]};function D(e,t=` → `){return E[e].join(t)}var O=e(t(),1),k=n(),A=(0,O.createContext)(null);function j({children:e}){let[t,n]=(0,O.useState)(()=>new Map),r=(0,O.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return r.set(e,t),r})},[]),i=(0,O.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),a=o((0,O.useMemo)(()=>[...t.values()].flat(),[t])),s=(0,O.useMemo)(()=>({publish:r,retract:i,lookup:a}),[r,i,a]);return(0,k.jsx)(A.Provider,{value:s,children:e})}var M=(0,O.createContext)(null);function ee({projectId:e,repoBase:t,requests:n,children:r}){let i=(0,O.useContext)(A),a=(0,O.useContext)(M),s=(0,O.useId)();(0,O.useEffect)(()=>{if(i)return i.publish(s,n),()=>i.retract(s)},[i,s,n.map(e=>`${e.projectId} ${e.kind}#${e.number}`).sort().join(`|`)]);let c=o(i?N:n),l=i?.lookup??c,u=t??(a&&a.projectId===e?a.repoBase:void 0),d=(0,O.useMemo)(()=>({lookup:l,projectId:e,repoBase:u}),[l,e,u]);return(0,k.jsx)(M.Provider,{value:d,children:r})}var N=[];function P(e,t,n){let r=(0,O.useContext)(M),i=n??r?.projectId;return!r||!i||t===void 0?te:r.lookup({projectId:i,kind:e,number:t})}function F(e,t){let n=(0,O.useContext)(M),r=t??n?.projectId;return!n||!r?[]:e.filter(e=>n.lookup({projectId:r,kind:`PR`,number:e}).conflicting===!0)}function I(){let e=(0,O.useContext)(M);return{projectId:e?.projectId,repoBase:e?.repoBase}}var te=Object.freeze({state:`idle`}),ne={success:`border-success/40 text-success`,danger:`border-danger/40 text-danger`,accent:`border-accent-strong/35 text-accent-text`,merged:`border-merged-strong/35 text-merged-text`,info:`border-info/40 text-info`,neutral:`border-border text-muted-foreground`,pending:`border-pending-strong/45 text-pending-strong`,conflict:`border-conflict/45 text-conflict`},L={success:`text-success`,danger:`text-danger`,accent:`text-merged-text`,merged:`text-merged-text`,info:`text-info`,neutral:`text-soft-foreground`,pending:`text-pending-strong`,conflict:`text-conflict`},re={success:`hover:bg-success/10`,danger:`hover:bg-danger/10`,accent:`hover:bg-accent-strong/10`,merged:`hover:bg-merged-strong/10`,info:`hover:bg-info/10`,neutral:`hover:bg-muted`,pending:`hover:bg-pending-strong/10`,conflict:`hover:bg-conflict/10`},R={draft:m,"review-required":u,"changes-requested":d,"checks-pending":null,"checks-failing":g,ready:h,merged:f,closed:p,open:b,completed:h,"not-planned":_};function z(e){return e===`PR`?`pr-chip`:`issue-chip`}function B(e){return e?{"data-conflicting":`true`}:{}}function V(e,t,n,r){return!n||r!==void 0&&l({kind:e,number:t??0,url:n},r)}function H(e,t,n){return e===`PR`&&(t??n)===!0}function U({plain:e,inert:t,conflicting:n,className:r,tone:a}){return e?i(`inline-flex items-center gap-1 rounded-[2px] text-inherit`,n&&`text-conflict font-medium`,!t&&`group/reference focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground`,r):i(`inline-flex h-[22px] items-center gap-1 rounded-md border px-1.5 font-mono text-[12px] font-normal`,ne[a],r)}function W(e,t,n,r){return n&&!r?t?`${e===`PR`?`PR `:``}#${t}`:e:t?`${!r&&e===`Issue`?`Issue `:``}#${t}`:e}function G(e){return e===`PR`?`pull request`:`issue`}function K(e,t,n,r){return`Open the ${e}${t?` #${t}`:``} for ${n}${r?` — ${r.label}`:``}`}function q(e,t){return e&&t?L[t.tone]:void 0}function J(e,t){return!e&&(!t||!r(t))}function Y({conflicting:e,presentation:t,status:n,plain:r,compact:a,inert:o,kind:s,label:c,glyphClass:l}){return(0,k.jsxs)(k.Fragment,{children:[e?(0,k.jsx)(y,{className:i(`size-2.5 shrink-0`,l),"aria-hidden":`true`}):(0,k.jsx)($,{status:t?n:void 0,className:r?i(`size-2.5`,l):void 0}),r&&a?s===`PR`?(0,k.jsx)(u,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):(0,k.jsx)(b,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):null,r?(0,k.jsx)(`span`,{className:o?void 0:`underline-offset-2 group-hover/reference:underline group-focus-visible/reference:underline`,children:c}):c]})}function ie({kind:e,status:t,conflicting:n,chipClass:r,body:i}){return(0,k.jsx)(`span`,{"data-slot":z(e),"data-status":t,"data-inert":`true`,...B(n),className:r,children:i})}function ae({kind:e,number:t,tooltip:n,url:i}){return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`span`,{className:`block font-medium`,children:[e===`PR`?`Pull request`:`Issue`,t?` #${t}`:``,` · `,n.headline]}),(0,k.jsx)(`span`,{className:`block`,children:n.detail}),n.also?(0,k.jsx)(`span`,{className:`block opacity-70`,children:n.also}):null,i&&r(i)?(0,k.jsx)(`span`,{className:`block opacity-70`,children:i.replace(/^https?:\/\//,``)}):null]})}function oe({reference:e,taskTitle:t,status:n,conflicting:r,conflictAction:o,projectId:c,repoBase:l,to:u,className:d,compact:f=!1,plain:p=!1,inert:m=!1}){let{kind:h,number:g,url:_}=e,v=I(),y=P(h,V(h,g,_,l??v.repoBase)?g:void 0,c),b=n??y.status,x=a(b),S=H(h,r,y.conflicting),C=S?s:x,w=C?.tone??`accent`,T=U({plain:p,inert:m,conflicting:S,className:d,tone:w}),E=ue(y,C,S?x:void 0),D=W(h,g,p,f),O=G(h),A=K(O,g,t,C),j=(0,k.jsx)(Y,{conflicting:S,presentation:C,status:b,plain:p,compact:f,inert:m,kind:h,label:D,glyphClass:q(p,C)});if(m)return(0,k.jsx)(ie,{kind:h,status:b,conflicting:S,chipClass:T,body:j});let M=J(u,_)?(0,k.jsx)(`span`,{"data-slot":z(h),"data-status":b,...B(S),"aria-label":C?`${O} ${D} — ${C.label}`:void 0,className:T,children:j}):(0,k.jsx)(se,{to:u,url:_,"data-slot":z(h),"data-status":b,...B(S),title:E?void 0:_,"aria-label":A,className:p?T:i(T,re[w]),children:j});return E?(0,k.jsx)(le,{chip:M,action:S?o:void 0,state:y.state,children:(0,k.jsx)(ae,{kind:h,number:g,tooltip:E,url:_})}):M}function se({to:e,url:t,children:n,...r}){return e?(0,k.jsx)(c,{to:e,...r,children:n}):(0,k.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,...r,children:n})}var X=(0,O.createContext)(()=>{});function ce(){return(0,O.useContext)(X)}var Z=150,Q=120;function le({chip:e,action:t,state:n,children:r}){let[i,a]=(0,O.useState)(!1),o=(0,O.useRef)(null),s=(0,O.useRef)(null),c=(0,O.useRef)(void 0),l=(0,O.useCallback)((e,t)=>{clearTimeout(c.current),c.current=setTimeout(()=>a(e),t)},[]),u=(0,O.useCallback)(()=>{clearTimeout(c.current),a(!1)},[]);(0,O.useEffect)(()=>()=>clearTimeout(c.current),[]);let d=e=>e instanceof Node&&(s.current?.contains(e)||o.current?.contains(e));return(0,k.jsxs)(w,{open:i,onOpenChange:e=>e?a(!0):u(),children:[(0,k.jsx)(S,{asChild:!0,ref:o,onPointerEnter:e=>{e.pointerType!==`touch`&&l(!0,Z)},onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,Q)},onFocus:()=>a(!0),onBlur:e=>{d(e.relatedTarget)||u()},onKeyDown:e=>{if(e.key===`Escape`)return u();if(e.key!==`Tab`||e.shiftKey||!t)return;let n=s.current?.querySelector(`button:not([disabled]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);n&&(e.preventDefault(),n.focus())},...t?{"aria-haspopup":`dialog`,"aria-expanded":i}:{},children:e}),(0,k.jsxs)(C,{ref:s,side:`top`,role:t?`dialog`:`tooltip`,"data-slot":`reference-status-card`,"data-tooltip-state":n,className:`w-64 space-y-2 p-3 text-xs`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),d(document.activeElement)&&o.current?.focus()},onPointerEnter:()=>clearTimeout(c.current),onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,Q)},children:[(0,k.jsx)(`div`,{className:`space-y-0.5`,children:r}),t?(0,k.jsx)(X.Provider,{value:u,children:t}):null]})]})}function ue(e,t,n){if(t){let{label:r,hint:i}=t,a=n?`also ${de(n.label)} — ${n.hint}`:void 0;return e.state===`unavailable`?{headline:r,detail:`last known — GitHub is unreachable${e.reason?` (${e.reason})`:``}`,...a?{also:a}:{}}:{headline:r,detail:i,...a?{also:a}:{}}}switch(e.state){case`loading`:return{headline:`Checking GitHub…`,detail:`the status of this reference is on its way`};case`unavailable`:return{headline:`Status unavailable`,detail:e.reason??`GitHub could not be reached — the chip says nothing rather than guessing`};case`unknown`:return{headline:`Not found on this repository`,detail:`GitHub has no such number here — the reference may point at another repo`};default:return null}}function de(e){return e.charAt(0).toLowerCase()+e.slice(1)}function fe({kind:e,number:t,className:n}){let r=P(e,t),o=a(r.status),c=e===`PR`&&r.conflicting===!0,l=c?s:o;if(!l)return null;let u=i(`size-2.5`,L[l.tone]);return(0,k.jsx)(`span`,{"data-slot":`reference-status-glyph`,"data-status":r.status,...c?{"data-conflicting":`true`}:{},"aria-hidden":`true`,className:i(`inline-flex items-center`,n),children:c?(0,k.jsx)(y,{className:i(`shrink-0`,u),"aria-hidden":`true`}):(0,k.jsx)($,{status:r.status,className:u})})}function $({status:e,className:t}){if(!e)return null;if(e===`checks-pending`)return(0,k.jsx)(v,{"data-slot":`status-dot`,"data-tone":`pending`,className:i(`size-3 animate-pulse motion-reduce:animate-none`,t),"aria-hidden":`true`});let n=R[e];return n?(0,k.jsx)(n,{className:i(`size-2.5 shrink-0`,t),"aria-hidden":`true`}):null}export{j as a,P as c,ee as i,D as l,fe as n,F as o,ce as r,I as s,oe as t,T as u};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{ci as r}from"./project-scope-context-D3_4Nfjk.js";import{M as i,t as a}from"./queries-BaHOUYn4.js";import{gn as o}from"./index-MG3T7zFQ.js";var s=e(t(),1),c=n();function l(){let e=r(),t=(0,s.useCallback)(async()=>{await Promise.all([e.invalidateQueries({queryKey:a.health}),e.invalidateQueries({queryKey:a.agentConfig,exact:!0})])},[e]);return(0,s.useEffect)(()=>{t()},[t]),t}var u=`${o()} remote-settings enable`;function d({risk:e}){return i().data?.capabilities?.remoteSettingsAdmin===!0?(0,c.jsxs)(`p`,{role:`note`,"data-slot":`remote-settings-notice`,className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-[13px] text-foreground`,children:[`Remote settings administration is on. `,e,`, and anyone who can open this cockpit can change them. The host operator turns this off with`,` `,(0,c.jsxs)(`code`,{children:[o(),` remote-settings disable`]}),`.`]}):null}export{d as n,l as r,u as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{ci as r}from"./project-scope-context-BDU1qGx3.js";import{M as i,t as a}from"./queries--x5yVcip.js";import{gn as o}from"./index-BZiixXpY.js";var s=e(t(),1),c=n();function l(){let e=r(),t=(0,s.useCallback)(async()=>{await Promise.all([e.invalidateQueries({queryKey:a.health}),e.invalidateQueries({queryKey:a.agentConfig,exact:!0})])},[e]);return(0,s.useEffect)(()=>{t()},[t]),t}var u=`${o()} remote-settings enable`;function d({risk:e}){return i().data?.capabilities?.remoteSettingsAdmin===!0?(0,c.jsxs)(`p`,{role:`note`,"data-slot":`remote-settings-notice`,className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-[13px] text-foreground`,children:[`Remote settings administration is on. `,e,`, and anyone who can open this cockpit can change them. The host operator turns this off with`,` `,(0,c.jsxs)(`code`,{children:[o(),` remote-settings disable`]}),`.`]}):null}export{d as n,l as r,u as t};