@open-mercato/cezar 0.9.0-pr614.620 → 0.9.0-pr616.622

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/cezar",
3
- "version": "0.9.0-pr614.620",
3
+ "version": "0.9.0-pr616.622",
4
4
  "description": "Local cockpit for running and tracking AI agent tasks in your repo. Uses your logged-in `claude` CLI and `gh` — zero config, zero database.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1 +1 @@
1
- import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{A as r,Bt as i,a,ct as o,dn as s,i as c,k as l,ln as u,pn as d,t as f,vt as p,z as m}from"./centered-state-NF79blq7.js";import{t as h}from"./utils-B8s5qIcK.js";import{t as g}from"./search-x-BDjaMrzG.js";import{i as _,n as v,r as y,t as b}from"./run-diff-BIaLk9f4.js";import{c as x,t as S}from"./project-router-CBzGUqvS.js";import{Dt as C,Tt as w,X as T,Y as E,Z as D,_ as O,d as k,f as A,ft as j,g as M,h as N,m as P,nn as F,p as I,qt as L,t as R,u as z,x as B}from"./index-NhcB1s5h.js";var V=n(t(),1),H=e();function U(){let{groupId:e}=u(),t=m(e),n=d();if((0,V.useEffect)(()=>{e&&n.invalidateQueries({queryKey:r.groups.detail(e)})},[n,e,(o().data??[]).filter(t=>t.groupId===e).map(e=>`${e.id}:${e.status}:${e.archived}`).sort().join(`,`)]),t.isPending)return(0,H.jsx)(E,{});if(t.isError){let e=t.error instanceof p&&t.error.status===404;return(0,H.jsx)(`div`,{"data-route":`compare`,className:`flex min-h-full flex-col`,children:(0,H.jsx)(f,{icon:e?(0,H.jsx)(g,{}):(0,H.jsx)(L,{}),tone:e?`neutral`:`danger`,title:e?`No such variant group`:`Could not load the variants`,subtitle:e?`No runs share this group id. The group may have been deleted, or a winner was already picked and the others removed.`:t.error.message,actions:(0,H.jsx)(a,{asChild:!0,variant:`outline`,children:(0,H.jsx)(S,{to:`/`,children:`Back to tasks`})})})})}return(0,H.jsx)(W,{groupId:e,variants:t.data.runs})}function W({groupId:e,variants:t}){let n=x(),a=d(),[o,u]=(0,V.useState)(null),f=t.every(e=>T.has(e.status)),p=t[0]?j(t[0]):``,m=s({mutationFn:t=>i(e,t),onSuccess:(t,i)=>{a.invalidateQueries({queryKey:r.runs.all}),a.invalidateQueries({queryKey:r.groups.detail(e)}),n(`/tasks/${t.winner?.id??i}`)},onError:e=>c(e.message,{tone:`danger`})});return(0,H.jsxs)(`div`,{"data-route":`compare`,className:`mx-auto flex w-full max-w-6xl flex-col gap-4 px-4 py-5 md:px-6`,children:[(0,H.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,H.jsxs)(`h1`,{className:`flex items-center gap-2 text-xl font-semibold`,children:[(0,H.jsx)(L,{className:`size-5 shrink-0 text-violet`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`min-w-0 truncate`,title:p,children:p})]}),(0,H.jsxs)(`p`,{className:`text-[13px] text-muted-foreground`,children:[t.length,` variants of the same task, each in its own worktree — pick the diff you want to keep. The others are cancelled and archived, their worktrees and branches removed.`]})]}),(0,H.jsx)(`div`,{"data-slot":`compare-columns`,className:h(`grid grid-cols-1 gap-3`,t.length>=3?`md:grid-cols-3`:`md:grid-cols-2`),children:t.map(e=>(0,H.jsx)(G,{variant:e,allTerminal:f,pickPending:m.isPending,onPick:()=>u(e)},e.id))}),(0,H.jsx)(`section`,{"aria-label":`Full diffs`,className:`flex flex-col gap-2`,children:t.map(e=>(0,H.jsx)(K,{variant:e},e.id))}),(0,H.jsx)(z,{open:o!==null,onOpenChange:e=>!e&&u(null),children:(0,H.jsxs)(I,{children:[(0,H.jsxs)(M,{children:[(0,H.jsxs)(O,{children:[`Pick variant `,o?.variant,`?`]}),(0,H.jsxs)(P,{children:[`Variant `,o?.variant,`'s changes go to the review gate. The other`,` `,t.length-1==1?`variant is`:`${t.length-1} variants are`,` `,`cancelled if still open, archived, and their worktrees and branches removed. There is no undo.`]})]}),(0,H.jsxs)(N,{children:[(0,H.jsx)(A,{children:`Keep comparing`}),(0,H.jsxs)(k,{"data-slot":`confirm-pick`,onClick:()=>{o&&m.mutate(o.id),u(null)},children:[(0,H.jsx)(l,{"aria-hidden":`true`}),`Pick variant `,o?.variant]})]})]})})]})}function G({variant:e,allTerminal:t,pickPending:n,onPick:r}){let i=C(e),o=D(e.costUsd);return(0,H.jsxs)(`article`,{"data-slot":`variant-column`,"data-variant":e.variant,className:`flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-card p-3.5 shadow-xs`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{"data-slot":`variant-letter`,"aria-label":`Variant ${e.variant}`,className:`inline-flex size-6 shrink-0 items-center justify-center rounded-full bg-violet/15 font-mono text-xs font-semibold text-violet`,children:e.variant}),(0,H.jsx)(R,{dot:i.tone,pulse:i.pulse,children:i.label}),(0,H.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[11px] text-soft-foreground tabular-nums`,children:[w(e.tokensUsed),o?` · ${o}`:``]})]}),(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-[10.5px] font-semibold tracking-[0.04em] text-soft-foreground uppercase`,children:`git diff --stat`}),(0,H.jsx)(`pre`,{"data-slot":`variant-diffstat`,className:`max-h-36 overflow-auto rounded-md bg-muted/60 px-2.5 py-2 font-mono text-[11px] leading-[1.6] whitespace-pre text-muted-foreground`,children:e.diffStat.trimEnd()||`(no changes)`})]}),(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-[10.5px] font-semibold tracking-[0.04em] text-soft-foreground uppercase`,children:`Progress`}),e.handoffExcerpt?(0,H.jsx)(`div`,{"data-slot":`variant-progress`,className:`max-h-28 min-w-0 overflow-hidden text-[12.5px] text-muted-foreground [mask-image:linear-gradient(to_bottom,black_75%,transparent)]`,children:(0,H.jsx)(B,{children:e.handoffExcerpt})}):(0,H.jsx)(`p`,{"data-slot":`variant-progress`,className:`text-xs text-soft-foreground`,children:`(no progress notes)`})]}),(0,H.jsxs)(a,{"data-slot":`variant-pick`,title:t?`Keep variant ${e.variant}'s changes and archive the others`:`Every variant must finish before you can pick`,disabled:!t||n,onClick:r,children:[(0,H.jsx)(l,{"aria-hidden":`true`}),`Pick this one`]})]})}function K({variant:e}){let[t,n]=(0,V.useState)(!1);return(0,H.jsxs)(v,{open:t,onOpenChange:n,"data-slot":`variant-diff`,"data-variant":e.variant,className:`min-w-0 overflow-hidden rounded-lg border border-border bg-card`,children:[(0,H.jsxs)(_,{className:`flex w-full items-center gap-2 px-3.5 py-2.5 text-left text-[13px] font-medium hover:bg-muted/50`,children:[(0,H.jsx)(F,{className:h(`size-3.5 shrink-0 text-soft-foreground transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),`Variant `,e.variant,` — full diff`]}),(0,H.jsx)(y,{children:(0,H.jsx)(`div`,{className:`border-t border-border/50 px-3 py-3`,children:(0,H.jsx)(b,{runId:e.id})})})]})}export{U as CompareVariantsRoute};
1
+ import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{A as r,Bt as i,a,ct as o,dn as s,i as c,k as l,ln as u,pn as d,t as f,vt as p,z as m}from"./centered-state-NF79blq7.js";import{t as h}from"./utils-B8s5qIcK.js";import{t as g}from"./search-x-BDjaMrzG.js";import{i as _,n as v,r as y,t as b}from"./run-diff-CJBVcV-y.js";import{c as x,t as S}from"./project-router-CBzGUqvS.js";import{Dt as C,Tt as w,X as T,Y as E,Z as D,_ as O,d as k,f as A,ft as j,g as M,h as N,m as P,nn as F,p as I,qt as L,t as R,u as z,x as B}from"./index-DBwAr6Uj.js";var V=n(t(),1),H=e();function U(){let{groupId:e}=u(),t=m(e),n=d();if((0,V.useEffect)(()=>{e&&n.invalidateQueries({queryKey:r.groups.detail(e)})},[n,e,(o().data??[]).filter(t=>t.groupId===e).map(e=>`${e.id}:${e.status}:${e.archived}`).sort().join(`,`)]),t.isPending)return(0,H.jsx)(E,{});if(t.isError){let e=t.error instanceof p&&t.error.status===404;return(0,H.jsx)(`div`,{"data-route":`compare`,className:`flex min-h-full flex-col`,children:(0,H.jsx)(f,{icon:e?(0,H.jsx)(g,{}):(0,H.jsx)(L,{}),tone:e?`neutral`:`danger`,title:e?`No such variant group`:`Could not load the variants`,subtitle:e?`No runs share this group id. The group may have been deleted, or a winner was already picked and the others removed.`:t.error.message,actions:(0,H.jsx)(a,{asChild:!0,variant:`outline`,children:(0,H.jsx)(S,{to:`/`,children:`Back to tasks`})})})})}return(0,H.jsx)(W,{groupId:e,variants:t.data.runs})}function W({groupId:e,variants:t}){let n=x(),a=d(),[o,u]=(0,V.useState)(null),f=t.every(e=>T.has(e.status)),p=t[0]?j(t[0]):``,m=s({mutationFn:t=>i(e,t),onSuccess:(t,i)=>{a.invalidateQueries({queryKey:r.runs.all}),a.invalidateQueries({queryKey:r.groups.detail(e)}),n(`/tasks/${t.winner?.id??i}`)},onError:e=>c(e.message,{tone:`danger`})});return(0,H.jsxs)(`div`,{"data-route":`compare`,className:`mx-auto flex w-full max-w-6xl flex-col gap-4 px-4 py-5 md:px-6`,children:[(0,H.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,H.jsxs)(`h1`,{className:`flex items-center gap-2 text-xl font-semibold`,children:[(0,H.jsx)(L,{className:`size-5 shrink-0 text-violet`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`min-w-0 truncate`,title:p,children:p})]}),(0,H.jsxs)(`p`,{className:`text-[13px] text-muted-foreground`,children:[t.length,` variants of the same task, each in its own worktree — pick the diff you want to keep. The others are cancelled and archived, their worktrees and branches removed.`]})]}),(0,H.jsx)(`div`,{"data-slot":`compare-columns`,className:h(`grid grid-cols-1 gap-3`,t.length>=3?`md:grid-cols-3`:`md:grid-cols-2`),children:t.map(e=>(0,H.jsx)(G,{variant:e,allTerminal:f,pickPending:m.isPending,onPick:()=>u(e)},e.id))}),(0,H.jsx)(`section`,{"aria-label":`Full diffs`,className:`flex flex-col gap-2`,children:t.map(e=>(0,H.jsx)(K,{variant:e},e.id))}),(0,H.jsx)(z,{open:o!==null,onOpenChange:e=>!e&&u(null),children:(0,H.jsxs)(I,{children:[(0,H.jsxs)(M,{children:[(0,H.jsxs)(O,{children:[`Pick variant `,o?.variant,`?`]}),(0,H.jsxs)(P,{children:[`Variant `,o?.variant,`'s changes go to the review gate. The other`,` `,t.length-1==1?`variant is`:`${t.length-1} variants are`,` `,`cancelled if still open, archived, and their worktrees and branches removed. There is no undo.`]})]}),(0,H.jsxs)(N,{children:[(0,H.jsx)(A,{children:`Keep comparing`}),(0,H.jsxs)(k,{"data-slot":`confirm-pick`,onClick:()=>{o&&m.mutate(o.id),u(null)},children:[(0,H.jsx)(l,{"aria-hidden":`true`}),`Pick variant `,o?.variant]})]})]})})]})}function G({variant:e,allTerminal:t,pickPending:n,onPick:r}){let i=C(e),o=D(e.costUsd);return(0,H.jsxs)(`article`,{"data-slot":`variant-column`,"data-variant":e.variant,className:`flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-card p-3.5 shadow-xs`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{"data-slot":`variant-letter`,"aria-label":`Variant ${e.variant}`,className:`inline-flex size-6 shrink-0 items-center justify-center rounded-full bg-violet/15 font-mono text-xs font-semibold text-violet`,children:e.variant}),(0,H.jsx)(R,{dot:i.tone,pulse:i.pulse,children:i.label}),(0,H.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[11px] text-soft-foreground tabular-nums`,children:[w(e.tokensUsed),o?` · ${o}`:``]})]}),(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-[10.5px] font-semibold tracking-[0.04em] text-soft-foreground uppercase`,children:`git diff --stat`}),(0,H.jsx)(`pre`,{"data-slot":`variant-diffstat`,className:`max-h-36 overflow-auto rounded-md bg-muted/60 px-2.5 py-2 font-mono text-[11px] leading-[1.6] whitespace-pre text-muted-foreground`,children:e.diffStat.trimEnd()||`(no changes)`})]}),(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-[10.5px] font-semibold tracking-[0.04em] text-soft-foreground uppercase`,children:`Progress`}),e.handoffExcerpt?(0,H.jsx)(`div`,{"data-slot":`variant-progress`,className:`max-h-28 min-w-0 overflow-hidden text-[12.5px] text-muted-foreground [mask-image:linear-gradient(to_bottom,black_75%,transparent)]`,children:(0,H.jsx)(B,{children:e.handoffExcerpt})}):(0,H.jsx)(`p`,{"data-slot":`variant-progress`,className:`text-xs text-soft-foreground`,children:`(no progress notes)`})]}),(0,H.jsxs)(a,{"data-slot":`variant-pick`,title:t?`Keep variant ${e.variant}'s changes and archive the others`:`Every variant must finish before you can pick`,disabled:!t||n,onClick:r,children:[(0,H.jsx)(l,{"aria-hidden":`true`}),`Pick this one`]})]})}function K({variant:e}){let[t,n]=(0,V.useState)(!1);return(0,H.jsxs)(v,{open:t,onOpenChange:n,"data-slot":`variant-diff`,"data-variant":e.variant,className:`min-w-0 overflow-hidden rounded-lg border border-border bg-card`,children:[(0,H.jsxs)(_,{className:`flex w-full items-center gap-2 px-3.5 py-2.5 text-left text-[13px] font-medium hover:bg-muted/50`,children:[(0,H.jsx)(F,{className:h(`size-3.5 shrink-0 text-soft-foreground transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),`Variant `,e.variant,` — full diff`]}),(0,H.jsx)(y,{children:(0,H.jsx)(`div`,{className:`border-t border-border/50 px-3 py-3`,children:(0,H.jsx)(b,{runId:e.id})})})]})}export{U as CompareVariantsRoute};
@@ -1,4 +1,4 @@
1
- import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{t as r}from"./utils-B8s5qIcK.js";import{C as i,S as a,et as o,nn as s,w as c}from"./index-NhcB1s5h.js";import{t as l}from"./lib-DPEZDBUN.js";import{n as u,t as d}from"./image-preview-DEhW0TFz.js";var f=n(t(),1),p=44;function m(e){if(e.binary===!0||e.patch===``)return 1;let t=e.patch.split(`
1
+ import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{t as r}from"./utils-B8s5qIcK.js";import{C as i,S as a,et as o,nn as s,w as c}from"./index-DBwAr6Uj.js";import{t as l}from"./lib-DPEZDBUN.js";import{n as u,t as d}from"./image-preview-DEhW0TFz.js";var f=n(t(),1),p=44;function m(e){if(e.binary===!0||e.patch===``)return 1;let t=e.patch.split(`
2
2
  `),n=t.findIndex(e=>e.startsWith(`@@`));return n===-1?t.length:t.length-n}function h(e){return m(e)*20+p}function g(e){return e.reduce((e,t)=>e+m(t),0)}function _(e,t){let n=new URLSearchParams(e).get(`diff`);return n===`flat`||n===`virtual`?n:t>1500?`virtual`:`flat`}function v(e){return`${e.oldPath??``}→${e.path}`}function y(e){let t=0;for(let n of e.split(`
3
3
  `))n.length>t&&(t=n.length);return t}var b=/[A-Za-z0-9_]+|\s+|[^\sA-Za-z0-9_]+/g,x=300,S=.3;function C(e,t){if(e===t)return null;let n=e.match(b)??[],r=t.match(b)??[];if(n.length===0||r.length===0||n.length>x||r.length>x)return null;let i=r.length+1,a=new Uint16Array((n.length+1)*i);for(let e=1;e<=n.length;e++)for(let t=1;t<=r.length;t++)a[e*i+t]=n[e-1]===r[t-1]?(a[(e-1)*i+(t-1)]??0)+1:Math.max(a[(e-1)*i+t]??0,a[e*i+(t-1)]??0);if((a[n.length*i+r.length]??0)/Math.max(n.length,r.length)<S)return null;let o=Array(n.length).fill(!1),s=Array(r.length).fill(!1),c=n.length,l=r.length;for(;c>0&&l>0;)n[c-1]===r[l-1]?(o[c-1]=!0,s[l-1]=!0,c--,l--):(a[(c-1)*i+l]??0)>=(a[c*i+(l-1)]??0)?c--:l--;return{del:w(n,o),add:w(r,s)}}function w(e,t){let n=[];return e.forEach((e,r)=>{let i=!(t[r]??!1),a=n[n.length-1];a&&a.changed===i?a.text+=e:n.push({text:e,changed:i})}),n}function T(e,t,n){if(!t||t.length===0)return e?e.map(e=>({text:e.content,color:e.color,changed:!1})):n===``?[]:[{text:n,changed:!1}];if(!e||e.length===0)return t.map(e=>({text:e.text,changed:e.changed}));let r=[],i=0,a=0,o=0,s=0;for(;i<e.length&&o<t.length;){let n=e[i],c=t[o],l=n.content.length-a,u=c.text.length-s,d=Math.min(l,u);d>0&&(r.push({text:n.content.slice(a,a+d),color:n.color,changed:c.changed}),a+=d,s+=d),n.content.length-a<=0&&(i++,a=0),c.text.length-s<=0&&(o++,s=0)}for(;i<e.length;){let t=e[i],n=t.content.slice(a);n!==``&&r.push({text:n,color:t.color,changed:!1}),i++,a=0}return r}var E=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/,D=`… (patch truncated)`;function O(e){let t=[],n=!1,r=null,i=0,a=0,o=e.split(`
4
4
  `);o.at(-1)===``&&o.pop();for(let e of o){let o=E.exec(e);if(o){r={header:e,oldStart:Number(o[1]),oldCount:o[2]===void 0?1:Number(o[2]),newStart:Number(o[3]),newCount:o[4]===void 0?1:Number(o[4]),lines:[]},i=r.oldStart,a=r.newStart,t.push(r);continue}if(e.includes(D)){n=!0,r=null;continue}r&&(e.startsWith(`+`)?r.lines.push({kind:`add`,text:e.slice(1),newLine:a++}):e.startsWith(`-`)?r.lines.push({kind:`del`,text:e.slice(1),oldLine:i++}):e.startsWith(`\\`)||r.lines.push({kind:`context`,text:e.slice(1),oldLine:i++,newLine:a++}))}return{hunks:t,truncated:n}}function k(e,t=!1){let n=[],r=e[0];if(!r)return n;r.newStart>1&&n.push({beforeHunk:0,count:r.newStart-1,oldStart:1,newStart:1});for(let t=1;t<e.length;t++){let r=e[t-1],i=e[t],a=r.oldStart+r.oldCount,o=r.newStart+r.newCount,s=i.newStart-o;s>0&&n.push({beforeHunk:t,count:s,oldStart:a,newStart:o})}if(t){let t=e[e.length-1];n.push({beforeHunk:e.length,oldStart:t.oldStart+t.oldCount,newStart:t.newStart+t.newCount})}return n}function A(e,t){let n=e.count===void 0?t.length:e.newStart+e.count-1,r=e.oldStart-e.newStart,i=[];for(let a=e.newStart;a<=Math.min(n,t.length);a++)i.push({kind:`context`,text:t[a-1]??``,oldLine:a+r,newLine:a});return i}function j(e,t){let n=Array(e.length),r=Array(t.length),i=Math.min(e.length,t.length);for(let a=0;a<i;a++){let i=C(e[a].text,t[a].text);i&&(n[a]=i.del,r[a]=i.add)}return{dels:e,adds:t,delSpans:n,addSpans:r}}function M(e,t,n){let r=0;for(;r<e.lines.length;){let i=e.lines[r];if(i.kind===`del`||i.kind===`add`){let t=[],i=[];for(;r<e.lines.length&&e.lines[r].kind===`del`;)t.push(e.lines[r++]);for(;r<e.lines.length&&e.lines[r].kind===`add`;)i.push(e.lines[r++]);n(j(t,i))}else t(i),r++}}function N(e,t=[],n){let r=new Map(t.map(e=>[e.beforeHunk,e])),i=[],a=e=>{let t=r.get(e);if(!t)return;let a=n?.get(e);if(a)for(let e of a)i.push({type:`line`,cell:{line:e}});else i.push({type:`gap`,gap:t})};return e.forEach((e,t)=>{a(t),i.push({type:`hunk`,hunk:e}),M(e,e=>i.push({type:`line`,cell:{line:e}}),e=>{e.dels.forEach((t,n)=>i.push({type:`line`,cell:{line:t,spans:e.delSpans[n]}})),e.adds.forEach((t,n)=>i.push({type:`line`,cell:{line:t,spans:e.addSpans[n]}}))})}),a(e.length),i}function P(e,t=[],n){let r=new Map(t.map(e=>[e.beforeHunk,e])),i=[],a=e=>{let t=r.get(e);if(!t)return;let a=n?.get(e);if(a)for(let e of a)i.push({type:`pair`,left:{line:e},right:{line:e}});else i.push({type:`gap`,gap:t})};return e.forEach((e,t)=>{a(t),i.push({type:`hunk`,hunk:e}),M(e,e=>i.push({type:`pair`,left:{line:e},right:{line:e}}),e=>{let t=Math.max(e.dels.length,e.adds.length);for(let n=0;n<t;n++){let t=e.dels[n],r=e.adds[n];i.push({type:`pair`,...t?{left:{line:t,spans:e.delSpans[n]}}:{},...r?{right:{line:r,spans:e.addSpans[n]}}:{}})}})}),a(e.length),i}var F=e(),I=1500,L=new Map;function R(e,t){if(e){for(let n of e.querySelectorAll(`[data-slot="diff-file"]`))if(n.dataset.path===t)return n}}function z({files:e,mode:t=`unified`,wrap:n=!1,loadFileText:i,imageSrc:a,onOpenInApp:s,viewRef:c,className:l}){let u=(0,f.useMemo)(()=>({adds:e.reduce((e,t)=>e+t.adds,0),dels:e.reduce((e,t)=>e+t.dels,0),files:e.length}),[e]),[d,p]=(0,f.useState)(()=>new Set),[m,y]=(0,f.useState)(()=>new Map),b=(0,f.useCallback)(e=>{p(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},[]),x=(0,f.useCallback)(async(e,t)=>{if(!i)return;let n=await i(e.path);if(n===null)return;let r=A(t,n.split(`
@@ -1 +1 @@
1
- import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{a as r}from"./centered-state-NF79blq7.js";import{n as i,r as a,t as o}from"./utils-B8s5qIcK.js";import{t as s}from"./ellipsis-vertical-CNnSLn5a.js";import{n as c}from"./tab-link-DTQ9FBZY.js";import{t as l}from"./file-D4GBh1ao.js";import{a as u,i as d,r as f}from"./use-desktop-CwDD6Gxr.js";import{t as p}from"./git-pull-request-DnR8Xh4_.js";import{t as m}from"./square-terminal-Ckjjn0vb.js";import{t as h}from"./upload-CDdyPPo_.js";import{$t as g,ct as _,dt as v,et as y,nn as b,ot as x,st as S}from"./index-NhcB1s5h.js";var C=a(`file-diff`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]),w=n(t(),1),T=e();function E({root:e,selected:t,onSelect:n}){return(0,T.jsx)(`nav`,{"data-slot":`changes-tree`,"aria-label":`Changed files`,className:`min-w-0 text-[13px]`,children:(0,T.jsxs)(`ul`,{className:`flex flex-col gap-px`,children:[e.dirs.map(e=>(0,T.jsx)(O,{dir:e,depth:0,selected:t,onSelect:n},e.path)),e.files.map(e=>(0,T.jsx)(A,{file:e,depth:0,selected:t,onSelect:n},e.path))]})})}function D({adds:e,dels:t}){return(0,T.jsxs)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[11px] font-medium tabular-nums`,children:[e>0?(0,T.jsxs)(`span`,{className:`text-success`,children:[`+`,e]}):null,e>0&&t>0?` `:null,t>0?(0,T.jsxs)(`span`,{className:`text-danger`,children:[`−`,t]}):null]})}function O({dir:e,depth:t,selected:n,onSelect:r}){let[i,a]=(0,w.useState)(!0);return(0,T.jsxs)(`li`,{children:[(0,T.jsxs)(`button`,{type:`button`,"data-slot":`tree-dir`,"data-path":e.path,"data-state":i?`open`:`closed`,"aria-expanded":i,onClick:()=>a(e=>!e),className:`flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:`${6+t*14}px`},children:[(0,T.jsx)(b,{"aria-hidden":`true`,className:o(`size-3.5 shrink-0 transition-transform`,i&&`rotate-90`)}),(0,T.jsx)(g,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,T.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.name}),(0,T.jsx)(D,{adds:e.adds,dels:e.dels})]}),i?(0,T.jsxs)(`ul`,{className:`flex flex-col gap-px`,children:[e.dirs.map(e=>(0,T.jsx)(O,{dir:e,depth:t+1,selected:n,onSelect:r},e.path)),e.files.map(e=>(0,T.jsx)(A,{file:e,depth:t+1,selected:n,onSelect:r},e.path))]}):null]})}var k={added:`text-success`,deleted:`text-danger`};function A({file:e,depth:t,selected:n,onSelect:r}){let i=n===e.path;return(0,T.jsx)(`li`,{children:(0,T.jsxs)(`button`,{type:`button`,"data-slot":`tree-file`,"data-path":e.path,"aria-current":i?`true`:void 0,onClick:()=>r(e.path),className:o(`flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left hover:bg-muted`,i?`bg-muted font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${24+t*14}px`},children:[(0,T.jsx)(l,{"aria-hidden":`true`,className:o(`size-3.5 shrink-0`,k[e.status])}),(0,T.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,T.jsx)(D,{adds:e.adds,dels:e.dels})]})})}function j(e,t){return{kind:`dir`,name:e,path:t,dirs:[],files:[],adds:0,dels:0,fileCount:0}}function M(e){let t=e;for(;t.files.length===0&&t.dirs.length===1;){let e=t.dirs[0];t={...e,name:`${t.name}/${e.name}`}}return{...t,dirs:t.dirs.map(M)}}var N=(e,t)=>e.name.localeCompare(t.name);function P(e){let t=j(``,``),n=new Map([[``,t]]),r=e=>{let t=n.get(e);if(t)return t;let i=e.lastIndexOf(`/`),a=r(i===-1?``:e.slice(0,i)),o=j(i===-1?e:e.slice(i+1),e);return a.dirs.push(o),n.set(e,o),o};for(let t of e){let e=t.path.lastIndexOf(`/`);r(e===-1?``:t.path.slice(0,e)).files.push({kind:`file`,name:e===-1?t.path:t.path.slice(e+1),path:t.path,status:t.status,adds:t.adds,dels:t.dels,binary:t.binary})}let i=e=>{e.dirs.forEach(i),e.adds=e.files.reduce((e,t)=>e+t.adds,0)+e.dirs.reduce((e,t)=>e+t.adds,0),e.dels=e.files.reduce((e,t)=>e+t.dels,0)+e.dirs.reduce((e,t)=>e+t.dels,0),e.fileCount=e.files.length+e.dirs.reduce((e,t)=>e+t.fileCount,0),e.dirs.sort(N),e.files.sort(N)};return i(t),{...t,dirs:t.dirs.map(M)}}function F({bar:e,branch:t,stat:n,mode:i,wrap:a,onModeChange:o,onWrapChange:c,onAction:l}){return(0,T.jsxs)(`div`,{"data-slot":`git-toolbar`,className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-b border-border px-4 py-2 md:px-6`,children:[t?(0,T.jsx)(f,{branch:t}):null,n?(0,T.jsx)(R,{stat:n}):null,(0,T.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,T.jsx)(`span`,{className:`hidden items-center gap-1 md:flex`,children:(0,T.jsx)(d,{mode:i,wrap:a,onModeChange:o,onWrapChange:c})}),e.secondary.map(e=>(0,T.jsx)(L,{action:e,variant:`outline`,onAction:l},e.id)),(0,T.jsx)(L,{action:e.primary,variant:`primary`,onAction:l}),e.menu.length>0?(0,T.jsxs)(x,{children:[(0,T.jsx)(v,{asChild:!0,children:(0,T.jsx)(r,{variant:`ghost`,size:`icon-sm`,"aria-label":`More git actions`,children:(0,T.jsx)(s,{"aria-hidden":`true`})})}),(0,T.jsx)(S,{align:`end`,"data-slot":`git-toolbar-menu`,children:e.menu.map(e=>(0,T.jsxs)(_,{disabled:!e.enabled,title:e.reason,onSelect:()=>l(e.id),children:[I[e.id],e.label]},e.id))})]}):null]})]})}var I={commit:(0,T.jsx)(u,{"aria-hidden":`true`}),push:(0,T.jsx)(h,{"aria-hidden":`true`}),"create-pr":(0,T.jsx)(p,{"aria-hidden":`true`}),"view-pr":(0,T.jsx)(c,{"aria-hidden":`true`}),"open-terminal":(0,T.jsx)(m,{"aria-hidden":`true`})};function L({action:e,variant:t,onAction:n}){return e.id===`view-pr`?i(e.href)?(0,T.jsx)(r,{asChild:!0,variant:t,size:`sm`,"data-action":e.id,children:(0,T.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,children:[I[e.id],e.label]})}):(0,T.jsxs)(r,{variant:t,size:`sm`,"data-action":e.id,disabled:!0,title:`View PR unavailable — the recorded PR link is not an http(s) URL`,children:[I[e.id],e.label]}):(0,T.jsxs)(r,{variant:t,size:`sm`,"data-action":e.id,disabled:!e.enabled,title:e.enabled?void 0:e.reason,onClick:()=>n(e.id),children:[I[e.id],e.label]})}function R({stat:e}){return(0,T.jsx)(`span`,{"data-slot":`changes-stat`,children:(0,T.jsx)(y,{stat:{adds:z(e.adds),dels:z(e.dels),files:e.files}})})}function z(e){let[t,n]=(0,w.useState)(e),r=(0,w.useRef)(e);return(0,w.useEffect)(()=>{let t=r.current;if(t===e)return;if(typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||typeof requestAnimationFrame!=`function`){r.current=e,n(e);return}let i=performance.now(),a=0,o=s=>{let c=Math.min(1,(s-i)/350),l=1-(1-c)**3;n(Math.round(t+(e-t)*l)),c<1?a=requestAnimationFrame(o):r.current=e};return a=requestAnimationFrame(o),()=>{cancelAnimationFrame(a),r.current=e,n(e)}},[e]),t}export{C as a,E as i,F as n,P as r,R as t};
1
+ import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{a as r}from"./centered-state-NF79blq7.js";import{n as i,r as a,t as o}from"./utils-B8s5qIcK.js";import{t as s}from"./ellipsis-vertical-CNnSLn5a.js";import{n as c}from"./tab-link-DTQ9FBZY.js";import{t as l}from"./file-D4GBh1ao.js";import{a as u,i as d,r as f}from"./use-desktop-BZnLQ0p_.js";import{t as p}from"./git-pull-request-DnR8Xh4_.js";import{t as m}from"./square-terminal-Ckjjn0vb.js";import{t as h}from"./upload-CDdyPPo_.js";import{$t as g,ct as _,dt as v,et as y,nn as b,ot as x,st as S}from"./index-DBwAr6Uj.js";var C=a(`file-diff`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]),w=n(t(),1),T=e();function E({root:e,selected:t,onSelect:n}){return(0,T.jsx)(`nav`,{"data-slot":`changes-tree`,"aria-label":`Changed files`,className:`min-w-0 text-[13px]`,children:(0,T.jsxs)(`ul`,{className:`flex flex-col gap-px`,children:[e.dirs.map(e=>(0,T.jsx)(O,{dir:e,depth:0,selected:t,onSelect:n},e.path)),e.files.map(e=>(0,T.jsx)(A,{file:e,depth:0,selected:t,onSelect:n},e.path))]})})}function D({adds:e,dels:t}){return(0,T.jsxs)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[11px] font-medium tabular-nums`,children:[e>0?(0,T.jsxs)(`span`,{className:`text-success`,children:[`+`,e]}):null,e>0&&t>0?` `:null,t>0?(0,T.jsxs)(`span`,{className:`text-danger`,children:[`−`,t]}):null]})}function O({dir:e,depth:t,selected:n,onSelect:r}){let[i,a]=(0,w.useState)(!0);return(0,T.jsxs)(`li`,{children:[(0,T.jsxs)(`button`,{type:`button`,"data-slot":`tree-dir`,"data-path":e.path,"data-state":i?`open`:`closed`,"aria-expanded":i,onClick:()=>a(e=>!e),className:`flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:`${6+t*14}px`},children:[(0,T.jsx)(b,{"aria-hidden":`true`,className:o(`size-3.5 shrink-0 transition-transform`,i&&`rotate-90`)}),(0,T.jsx)(g,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,T.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.name}),(0,T.jsx)(D,{adds:e.adds,dels:e.dels})]}),i?(0,T.jsxs)(`ul`,{className:`flex flex-col gap-px`,children:[e.dirs.map(e=>(0,T.jsx)(O,{dir:e,depth:t+1,selected:n,onSelect:r},e.path)),e.files.map(e=>(0,T.jsx)(A,{file:e,depth:t+1,selected:n,onSelect:r},e.path))]}):null]})}var k={added:`text-success`,deleted:`text-danger`};function A({file:e,depth:t,selected:n,onSelect:r}){let i=n===e.path;return(0,T.jsx)(`li`,{children:(0,T.jsxs)(`button`,{type:`button`,"data-slot":`tree-file`,"data-path":e.path,"aria-current":i?`true`:void 0,onClick:()=>r(e.path),className:o(`flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left hover:bg-muted`,i?`bg-muted font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${24+t*14}px`},children:[(0,T.jsx)(l,{"aria-hidden":`true`,className:o(`size-3.5 shrink-0`,k[e.status])}),(0,T.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,T.jsx)(D,{adds:e.adds,dels:e.dels})]})})}function j(e,t){return{kind:`dir`,name:e,path:t,dirs:[],files:[],adds:0,dels:0,fileCount:0}}function M(e){let t=e;for(;t.files.length===0&&t.dirs.length===1;){let e=t.dirs[0];t={...e,name:`${t.name}/${e.name}`}}return{...t,dirs:t.dirs.map(M)}}var N=(e,t)=>e.name.localeCompare(t.name);function P(e){let t=j(``,``),n=new Map([[``,t]]),r=e=>{let t=n.get(e);if(t)return t;let i=e.lastIndexOf(`/`),a=r(i===-1?``:e.slice(0,i)),o=j(i===-1?e:e.slice(i+1),e);return a.dirs.push(o),n.set(e,o),o};for(let t of e){let e=t.path.lastIndexOf(`/`);r(e===-1?``:t.path.slice(0,e)).files.push({kind:`file`,name:e===-1?t.path:t.path.slice(e+1),path:t.path,status:t.status,adds:t.adds,dels:t.dels,binary:t.binary})}let i=e=>{e.dirs.forEach(i),e.adds=e.files.reduce((e,t)=>e+t.adds,0)+e.dirs.reduce((e,t)=>e+t.adds,0),e.dels=e.files.reduce((e,t)=>e+t.dels,0)+e.dirs.reduce((e,t)=>e+t.dels,0),e.fileCount=e.files.length+e.dirs.reduce((e,t)=>e+t.fileCount,0),e.dirs.sort(N),e.files.sort(N)};return i(t),{...t,dirs:t.dirs.map(M)}}function F({bar:e,branch:t,stat:n,mode:i,wrap:a,onModeChange:o,onWrapChange:c,onAction:l}){return(0,T.jsxs)(`div`,{"data-slot":`git-toolbar`,className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-b border-border px-4 py-2 md:px-6`,children:[t?(0,T.jsx)(f,{branch:t}):null,n?(0,T.jsx)(R,{stat:n}):null,(0,T.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,T.jsx)(`span`,{className:`hidden items-center gap-1 md:flex`,children:(0,T.jsx)(d,{mode:i,wrap:a,onModeChange:o,onWrapChange:c})}),e.secondary.map(e=>(0,T.jsx)(L,{action:e,variant:`outline`,onAction:l},e.id)),(0,T.jsx)(L,{action:e.primary,variant:`primary`,onAction:l}),e.menu.length>0?(0,T.jsxs)(x,{children:[(0,T.jsx)(v,{asChild:!0,children:(0,T.jsx)(r,{variant:`ghost`,size:`icon-sm`,"aria-label":`More git actions`,children:(0,T.jsx)(s,{"aria-hidden":`true`})})}),(0,T.jsx)(S,{align:`end`,"data-slot":`git-toolbar-menu`,children:e.menu.map(e=>(0,T.jsxs)(_,{disabled:!e.enabled,title:e.reason,onSelect:()=>l(e.id),children:[I[e.id],e.label]},e.id))})]}):null]})]})}var I={commit:(0,T.jsx)(u,{"aria-hidden":`true`}),push:(0,T.jsx)(h,{"aria-hidden":`true`}),"create-pr":(0,T.jsx)(p,{"aria-hidden":`true`}),"view-pr":(0,T.jsx)(c,{"aria-hidden":`true`}),"open-terminal":(0,T.jsx)(m,{"aria-hidden":`true`})};function L({action:e,variant:t,onAction:n}){return e.id===`view-pr`?i(e.href)?(0,T.jsx)(r,{asChild:!0,variant:t,size:`sm`,"data-action":e.id,children:(0,T.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,children:[I[e.id],e.label]})}):(0,T.jsxs)(r,{variant:t,size:`sm`,"data-action":e.id,disabled:!0,title:`View PR unavailable — the recorded PR link is not an http(s) URL`,children:[I[e.id],e.label]}):(0,T.jsxs)(r,{variant:t,size:`sm`,"data-action":e.id,disabled:!e.enabled,title:e.enabled?void 0:e.reason,onClick:()=>n(e.id),children:[I[e.id],e.label]})}function R({stat:e}){return(0,T.jsx)(`span`,{"data-slot":`changes-stat`,children:(0,T.jsx)(y,{stat:{adds:z(e.adds),dels:z(e.dels),files:e.files}})})}function z(e){let[t,n]=(0,w.useState)(e),r=(0,w.useRef)(e);return(0,w.useEffect)(()=>{let t=r.current;if(t===e)return;if(typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||typeof requestAnimationFrame!=`function`){r.current=e,n(e);return}let i=performance.now(),a=0,o=s=>{let c=Math.min(1,(s-i)/350),l=1-(1-c)**3;n(Math.round(t+(e-t)*l)),c<1?a=requestAnimationFrame(o):r.current=e};return a=requestAnimationFrame(o),()=>{cancelAnimationFrame(a),r.current=e,n(e)}},[e]),t}export{C as a,E as i,F as n,P as r,R as t};
@@ -1 +1 @@
1
- import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{A as r,L as i,Mt as a,R as o,Tt as s,Wt as c,a as l,dn as u,ft as d,i as f,jt as p,k as m,ln as h,pn as ee,pt as te,t as g,ut as ne,yn as _}from"./centered-state-NF79blq7.js";import{n as v,r as y,t as b}from"./utils-B8s5qIcK.js";import{t as x}from"./arrow-left-CnSdp92h.js";import{n as S,t as C}from"./tab-link-DTQ9FBZY.js";import{t as w}from"./git-pull-request-DnR8Xh4_.js";import{t as T}from"./refresh-cw-BT8E96Tm.js";import{t as re}from"./triangle-alert-Uy8rokUh.js";import{n as E,t as ie}from"./textarea-Bj_LCreg.js";import{r as D,t as O}from"./project-router-CBzGUqvS.js";import{A as k,At as A,Ct as j,D as ae,E as oe,Et as M,F as N,Ft as P,Gt as F,H as I,J as se,Kt as ce,L as le,M as L,Mt as R,N as z,Nt as B,O as V,Ot as H,P as U,R as W,St as ue,Ut as G,Wt as de,Yt as K,_t as q,bt as fe,en as pe,ht as me,j as he,jt as J,k as ge,kt as Y,rn as _e,x as ve,xt as ye,y as be,yt as xe,z as Se}from"./index-NhcB1s5h.js";var Ce=y(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),we=y(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),Te=y(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),X=n(t(),1),Z=e();function Q({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`skeleton`,className:b(`animate-pulse rounded-md bg-accent`,e),...t})}function $(e){return`${e.kind===`pr`?`Address GitHub pull request`:`Fix GitHub issue`} #${e.number}: ${e.title}\n\n${e.url}`}function Ee(e,t=[]){let n=$(e);return e.body?.trim()&&(n+=`\n\n---\n\n${e.body.trim()}`),t.length&&(n+=De(t)),n}function De(e){return`\n\nUse these skills where relevant: ${e.join(`, `)}.`}function Oe(e,t){return e.replace(/\{\{\s*number\s*\}\}/gi,()=>`#${t.number}`).replace(/\{\{\s*title\s*\}\}/gi,()=>t.title).replace(/\{\{\s*url\s*\}\}/gi,()=>t.url)}function ke(e,t){if(e.includes(t.url))return!0;let n=t.kind===`pr`?String.raw`(?:pull\s+request|pr)`:String.raw`issue`;return new RegExp(String.raw`\b${n}\s*#?\s*${t.number}\b`,`i`).test(e)}function Ae(e,t,n){let r=(n??``).trim();if(!r)return Ee(e,t);let i=$(e),a=r.startsWith(i)?i+Oe(r.slice(i.length),e):Oe(r,e),o=ke(a,e)?a:`${i}\n\n${a}`;return t.length?o+De(t):o}function je(e){let t=[];for(let n of e.slice(0,8)){let e=new Set(t.map(e=>e.id)),r=n;for(let t=2;e.has(r);t++)r=`${n}-${t}`;t.push({id:r,name:n,skill:n,prompt:`{{task}}`})}return t}function Me(e,t,n,r,i={}){return t?{...i,workflow:t,task:Ae(e,n,r)}:n.length?{...i,steps:je(n),task:Ae(e,[],r)}:{...i,workflow:`quick-task`,task:Ae(e,[],r)}}function Ne(e){let t=new Set;for(let n of e)for(let e of n.labels)t.add(e);return[...t].sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()))}function Pe(e,t={}){let n=(t.query??``).trim().toLowerCase(),r=t.labels??[],i=n.replace(/^#/,``),a=i!==``&&/^\d+$/.test(i);return e.filter(e=>r.length>0&&!r.every(t=>e.labels.includes(t))?!1:n===``?!0:a?String(e.number).includes(i):`#${e.number} ${e.title} ${e.author} ${e.body}`.toLowerCase().includes(n))}function Fe(e){if(!e||!/^[0-9a-fA-F]{6}$/.test(e))return{borderColor:`var(--border)`,color:`var(--muted-foreground)`};let t=`#${e}`;return{backgroundColor:`${t}22`,borderColor:`${t}66`,color:`color-mix(in srgb, ${t} 50%, var(--foreground))`}}var Ie={workflow:null,skills:[]},Le=`cez-followup-selection`;function Re(e){let t=e&&typeof e==`object`?e:{};return{workflow:typeof t.workflow==`string`?t.workflow:null,skills:Array.isArray(t.skills)?t.skills.filter(e=>typeof e==`string`):[]}}function ze(){try{let e=localStorage.getItem(Le);return e?Re(JSON.parse(e)):{...Ie}}catch{return{...Ie}}}function Be(e){try{localStorage.setItem(Le,JSON.stringify(e))}catch{}}var Ve=`cez-followup-prompt:`;function He(e){try{return localStorage.getItem(Ve+e)??``}catch{return``}}function Ue(e,t){try{t===``?localStorage.removeItem(Ve+e):localStorage.setItem(Ve+e,t)}catch{}}function We({item:e,workflows:t,skills:n,workflow:i,onWorkflowChange:a,selectedSkills:o,onSkillsChange:p,engine:h,onEngineChange:te,queuedRunId:g,onQueued:ne}){let _=ee(),v=d(),y=o.filter(e=>n.some(t=>t.name===e)),[b]=(0,X.useState)(()=>$(e)),[x,S]=(0,X.useState)(()=>He(e.url)||b),C=Se(h),w=(0,X.useRef)(null);(0,X.useEffect)(()=>{Ue(e.url,x===b?``:x)},[e.url,x,b]);let T=(0,X.useMemo)(()=>k(v.data?.promptTemplates),[v.data?.promptTemplates]),re=e=>{let t=w.current,n=x===b?x.length:t?.selectionStart??x.length,r=ge(x,n,e);S(r.text),requestAnimationFrame(()=>{w.current?.focus(),w.current?.setSelectionRange(r.caret,r.caret)})},D=V(T,y),A=(0,X.useRef)(x);A.current=x;let j=(0,X.useRef)(``);(0,X.useEffect)(()=>{let e=he(A.current,j.current,D,b);j.current=e.applied,e.text!==A.current&&S(e.text)},[D,b]);let M=u({mutationFn:()=>s(Me(e,i,y,x,W(C))),onSuccess:t=>{let n=`runs`in t?t.runs[0]:t;n&&ne(e.url,n.id),y.length>0&&v.data!==void 0&&c({skillUsage:y.reduce((e,t)=>me(e,t),v.data.skillUsage)}).then(()=>_.invalidateQueries({queryKey:r.uiState})).catch(()=>{}),Ue(e.url,``),S(b),j.current=``,_.invalidateQueries({queryKey:r.runs.all})},onError:e=>f(e.message,{tone:`danger`})}),N=e=>{oe({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),M.isPending||M.mutate())},P=e=>p(o.includes(e)?o.filter(t=>t!==e):[...o,e]);return(0,Z.jsxs)(`section`,{"data-slot":`gh-hand`,className:`mt-7 rounded-lg border border-border bg-card p-4`,children:[(0,Z.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-[11px] font-semibold tracking-[.04em] text-soft-foreground uppercase`,children:[(0,Z.jsx)(G,{"aria-hidden":`true`,className:`size-3.5 text-violet`}),`Hand this to the agent`]}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(Ge,{workflows:t,value:i,onChange:a}),(0,Z.jsx)(Ke,{skills:n,skillUsage:v.data?.skillUsage,selected:y,onToggle:P}),(0,Z.jsx)(le,{pick:h,onChange:te,disabled:M.isPending}),(0,Z.jsx)(L,{templates:T,onInsert:re})]}),y.length>0?(0,Z.jsx)(`div`,{"data-slot":`gh-skill-chips`,className:`mt-2.5 flex flex-wrap gap-1.5`,children:y.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-skill-chip`,"data-skill":e,onClick:()=>P(e),title:`Remove this skill`,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:[e,(0,Z.jsx)(E,{"aria-hidden":`true`,className:`size-3`})]},e))}):null,(0,Z.jsx)(ie,{ref:w,"data-slot":`gh-custom-prompt`,"aria-label":`Custom prompt`,"aria-keyshortcuts":`Control+Enter Meta+Enter`,value:x,onChange:e=>S(e.target.value),onKeyDown:N,placeholder:`Instructions for the agent… (#${e.number} and its link are always sent)`,className:`mt-3 min-h-20 text-[13px]`}),(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2.5`,children:[(0,Z.jsxs)(l,{variant:`contrast`,"data-action":`gh-run`,disabled:M.isPending,onClick:()=>M.mutate(),children:[(0,Z.jsx)(K,{"aria-hidden":`true`,className:`size-3.5`}),`Run agent on this `,e.kind===`pr`?`PR`:`issue`]}),(0,Z.jsx)(`kbd`,{"aria-hidden":`true`,className:`rounded-[5px] border border-b-2 border-border bg-card px-[5px] py-px font-mono text-[10.5px] font-medium text-muted-foreground`,children:ae()}),g?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{"data-slot":`gh-queued`,className:`flex items-center gap-1 text-xs font-medium text-success`,children:[(0,Z.jsx)(m,{"aria-hidden":`true`,className:`size-3.5`}),`queued`]}),(0,Z.jsx)(O,{to:`/tasks/${g}`,"data-slot":`gh-view-run`,className:`text-xs font-semibold text-violet hover:underline`,children:`View task →`})]}):null]})]})}function Ge({workflows:e,value:t,onChange:n}){let[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(``),s=(0,X.useRef)(null),c=ue(e,a);return(0,Z.jsxs)(z,{open:r,onOpenChange:e=>{i(e),e||o(``)},children:[(0,Z.jsx)(N,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-workflow-trigger`,"aria-label":`Choose a workflow`,className:b(I,t&&`border-foreground/60 font-mono text-[11.5px] font-semibold text-foreground`),children:[(0,Z.jsx)(de,{"aria-hidden":`true`,className:`size-3 shrink-0 text-violet`}),(0,Z.jsx)(`span`,{className:`max-w-44 truncate`,children:t??`workflow`}),(0,Z.jsx)(_e,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Z.jsx)(U,{align:`start`,sideOffset:8,className:`w-[320px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Z.jsxs)(H,{shouldFilter:!1,children:[(0,Z.jsx)(J,{placeholder:`search workflows…`,value:a,onValueChange:o,onInput:()=>s.current?.scrollTo(0,0)}),(0,Z.jsxs)(B,{ref:s,"data-slot":`gh-workflow-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[c.length===0?(0,Z.jsx)(Y,{children:`Nothing matches.`}):null,(0,Z.jsx)(A,{children:c.map(e=>{let r=t===e.name;return(0,Z.jsxs)(R,{value:`workflow ${e.name}`,keywords:j(e.name,e.description),"data-slot":`gh-workflow-option`,"data-workflow":e.name,onSelect:()=>{n(r?null:e.name),i(!1)},children:[(0,Z.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),e.description?(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,r?(0,Z.jsx)(m,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-primary`}):null]},e.name)})})]})]})})]})}function Ke({skills:e,skillUsage:t,selected:n,onToggle:r}){let[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(null),u=(0,X.useRef)(null),{mostUsed:d,project:f,global:p}=fe(ye(e,o,t),t),h=(e,t)=>{let i=n.includes(e.name);return(0,Z.jsxs)(R,{value:`skill ${e.name} ${e.path}`,keywords:j(e.name,e.description),"data-slot":`gh-skill-option`,"data-skill":e.name,"data-selected":i?`true`:void 0,onSelect:()=>r(e.name),children:[(0,Z.jsx)(`span`,{className:b(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.description?(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,(0,Z.jsx)(`button`,{type:`button`,"data-slot":`gh-skill-view`,"aria-label":`View skill ${e.name}`,title:`View skill`,onClick:t=>{t.preventDefault(),t.stopPropagation(),l(e)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,Z.jsx)(pe,{"aria-hidden":`true`,className:`size-3.5`})}),i?(0,Z.jsx)(m,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},e.path)};return e.length===0?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(be,{skill:c,onClose:()=>l(null)}),(0,Z.jsxs)(z,{open:i,onOpenChange:e=>{a(e),e||s(``)},children:[(0,Z.jsx)(N,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-skills-trigger`,"aria-label":`Choose skills`,className:b(I,n.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,Z.jsx)(F,{"aria-hidden":`true`,className:`size-3 shrink-0 text-violet`}),`skills`,n.length>0?` · ${n.length}`:``,(0,Z.jsx)(_e,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Z.jsx)(U,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Z.jsxs)(H,{shouldFilter:!1,children:[(0,Z.jsx)(J,{placeholder:`search skills…`,value:o,onValueChange:s,onInput:()=>u.current?.scrollTo(0,0)}),(0,Z.jsxs)(B,{ref:u,"data-slot":`gh-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[d.length===0&&f.length===0&&p.length===0?(0,Z.jsx)(Y,{children:`Nothing matches.`}):null,d.length>0?(0,Z.jsx)(A,{heading:`Most used`,children:d.map(e=>h(e,q(e)))}):null,f.length>0?(0,Z.jsx)(A,{heading:`Project skills`,children:f.map(e=>h(e,!0))}):null,p.length>0?(0,Z.jsx)(A,{heading:`Global`,children:p.map(e=>h(e,!1))}):null]})]})})]})]})}var qe=30,Je=1e3;function Ye(){return d().data?.githubView===`prs`?(0,Z.jsx)(D,{to:`/github/prs`,replace:!0}):(0,Z.jsx)(Xe,{view:`issues`})}function Xe({view:e}){let{n:t}=h(),n=i(),o=i({limit:Je},n.data?.available===!0),s=o.data?.available?o.data:n.data,m=o.data?.available===!0,v=ee(),y=e=>{v.setQueryData(r.uiState,t=>({...t,githubView:e})),c({githubView:e}).then(e=>v.setQueryData(r.uiState,e)).catch(e=>{f(e instanceof Error?e.message:String(e),{tone:`danger`}),v.invalidateQueries({queryKey:r.uiState})})},x=(0,X.useRef)(null),S=u({mutationFn:()=>p({refresh:!0}),onSuccess:e=>{v.setQueryData(r.github({}),e),v.invalidateQueries({queryKey:r.github({limit:Je})});let t=x.current;if(!t){v.removeQueries({queryKey:[`github`,`comments`]});return}let n=r.githubComments(t.kind,t.number);a(t.kind,t.number,{refresh:!0}).then(e=>v.setQueryData(n,e)).catch(()=>{}),v.removeQueries({queryKey:[`github`,`comments`],predicate:e=>e.queryHash!==_(n)})},onError:e=>f(e.message,{tone:`danger`})}),E=te(),ie=ne(),D=d(),[O,k]=(0,X.useState)(()=>ze().workflow),[A,j]=(0,X.useState)(()=>ze().skills),[ae,oe]=(0,X.useState)({runner:null,model:null});(0,X.useEffect)(()=>{Be({workflow:O,skills:[...A]})},[O,A]);let N=E.data?.workflows;(0,X.useEffect)(()=>{N&&O!==null&&!N.some(e=>e.name===O)&&k(null)},[N,O]);let F=ie.data,I=D.data?.skillUsage,le=(0,X.useMemo)(()=>xe(F??[],I),[F,I]),[L,R]=(0,X.useState)(new Map),[z,B]=(0,X.useState)(``),[V,H]=(0,X.useState)([]);if(!s)return n.isError?(0,Z.jsx)(`div`,{"data-route":`github`,className:`flex min-h-full flex-col`,children:(0,Z.jsx)(g,{icon:(0,Z.jsx)(re,{}),tone:`danger`,title:`Could not load GitHub`,subtitle:n.error.message})}):(0,Z.jsx)(se,{});if(x.current=null,!s.available)return(0,Z.jsx)(`div`,{"data-route":`github`,className:`flex min-h-full flex-col`,children:(0,Z.jsx)(g,{icon:(0,Z.jsx)(P,{}),tone:`neutral`,title:`GitHub is unavailable here`,subtitle:s.reason??`unknown reason`,actions:(0,Z.jsx)(l,{variant:`outline`,"data-action":`gh-retry`,disabled:S.isPending,onClick:()=>S.mutate(),children:`Try again`}),children:(0,Z.jsxs)(`p`,{className:`text-xs leading-relaxed text-soft-foreground`,children:[`The tab needs the `,(0,Z.jsx)(`span`,{className:`font-mono`,children:`gh`}),` CLI, logged in (`,(0,Z.jsx)(`span`,{className:`font-mono`,children:`gh auth login`}),`), and a repo with a GitHub remote. Everything else in cezar works without it.`]})})});let U=e===`issues`?s.issues:s.prs,W=s.labelColors??{},ue=Ne(U),G=Pe(U,{query:z,labels:V}),de=z.trim()!==``||V.length>0,K=t===void 0?null:Number.parseInt(t,10),q=K===null?G[0]??null:U.find(e=>e.number===K)??null;x.current=q?{kind:q.kind,number:q.number}:null;let fe=e===`issues`?`/github`:`/github/prs`;return(0,Z.jsxs)(`div`,{"data-route":`github`,className:`flex h-full min-h-0 items-stretch`,children:[(0,Z.jsxs)(`section`,{"data-slot":`gh-list`,className:b(`w-full min-h-0 flex-col overflow-y-auto overscroll-contain border-border md:flex md:w-[360px] md:shrink-0 md:border-r`,t===void 0?`flex`:`hidden`),children:[(0,Z.jsxs)(`header`,{"data-slot":`gh-header`,className:`sticky top-0 z-10 border-b border-border bg-background/95 px-4 pt-3 backdrop-blur`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,Z.jsx)(`h1`,{className:`text-lg font-semibold`,children:`GitHub`}),s.repo?(0,Z.jsx)(`span`,{"data-slot":`gh-repo`,className:`min-w-0 truncate font-mono text-[11px] text-soft-foreground`,children:s.repo}):null,(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-refresh`,title:`Refresh from GitHub`,disabled:S.isPending,onClick:()=>S.mutate(),className:`ml-auto flex shrink-0 items-center gap-1 rounded-full border border-border px-1.5 py-px text-[10px] font-medium text-soft-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-55`,children:[(0,Z.jsx)(T,{"aria-hidden":`true`,className:b(`size-[9px]`,S.isPending&&`motion-safe:animate-spin`)}),s.syncedAt?`synced ${M(s.syncedAt)} ago`:`refresh`]})]}),(0,Z.jsxs)(`div`,{"data-slot":`gh-tabs`,className:`mt-2.5 flex items-end gap-1`,children:[(0,Z.jsxs)(C,{to:`/github`,active:e===`issues`,onClick:()=>y(`issues`),children:[`Issues · `,Ze(s.issues.length,m)]}),(0,Z.jsxs)(C,{to:`/github/prs`,active:e===`prs`,onClick:()=>y(`prs`),children:[`Pull requests · `,Ze(s.prs.length,m)]})]}),(0,Z.jsxs)(`div`,{className:`mt-2.5 flex items-center gap-2 pb-3`,children:[(0,Z.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,Z.jsx)(ce,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-soft-foreground`}),(0,Z.jsx)(`input`,{type:`search`,"data-slot":`gh-search`,"aria-label":`Search ${e}`,placeholder:`Search #id, title, author…`,value:z,onChange:e=>B(e.target.value),className:`w-full rounded-md border border-input bg-card py-1 pr-2 pl-7 text-[13px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`})]}),(0,Z.jsx)($e,{options:ue,colors:W,selected:V,onChange:H})]})]}),G.length===0?(0,Z.jsx)(`p`,{className:`px-4 py-4 text-sm text-soft-foreground`,children:de?`No ${e===`issues`?`issues`:`pull requests`} match your filter.`:`No open ${e===`issues`?`issues`:`pull requests`}.`}):(0,Z.jsx)(`ul`,{"data-slot":`gh-rows`,className:`flex flex-col gap-0.5 px-2 py-2`,children:G.map(t=>(0,Z.jsx)(Qe,{item:t,view:e,colors:W,active:q?.url===t.url,queued:L.has(t.url)},t.url))})]}),(0,Z.jsx)(`section`,{"data-slot":`gh-detail`,className:b(`min-w-0 min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain`,t===void 0?`hidden md:flex`:`flex`),children:q?(0,Z.jsx)(tt,{item:q,listPath:fe,colors:W,children:(0,Z.jsx)(We,{item:q,workflows:E.data?.workflows??[],skills:le,workflow:O,onWorkflowChange:k,selectedSkills:A,onSkillsChange:j,engine:ae,onEngineChange:oe,queuedRunId:L.get(q.url)??null,onQueued:(e,t)=>R(n=>new Map(n).set(e,t))},q.url)}):(0,Z.jsx)(g,{icon:e===`issues`?(0,Z.jsx)(Ce,{}):(0,Z.jsx)(w,{}),tone:`neutral`,heading:`h2`,title:K===null?`Nothing selected`:`Not in the open list`,subtitle:K===null?`No open ${e===`issues`?`issues`:`pull requests`} to show.`:`#${K} is not among the open ${e===`issues`?`issues`:`pull requests`} — it may be closed, or still outside the fetched batch.`})})]})}function Ze(e,t){return`${e}${!t&&e>=qe?`+`:``}`}function Qe({item:e,view:t,colors:n,active:r,queued:i}){let a=e.kind===`issue`?Ce:w;return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(O,{to:`${t===`issues`?`/github/issues`:`/github/prs`}/${e.number}`,draggable:!0,onDragStart:t=>{try{t.dataTransfer.setData(`text/plain`,Ee(e)),t.dataTransfer.effectAllowed=`copy`}catch{}},"data-slot":`gh-row`,"data-number":e.number,"aria-current":r?`page`:void 0,title:`Drag into the composer to prefill a task`,className:b(`flex flex-col gap-1 rounded-md px-2.5 py-2 transition-colors hover:bg-muted`,r&&`bg-muted`),children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(a,{"aria-hidden":`true`,className:b(`size-3.5 shrink-0`,e.kind===`issue`?`text-success`:`text-violet`)}),(0,Z.jsx)(`span`,{className:b(`min-w-0 truncate text-[13px] font-medium`,r&&`font-semibold`),children:e.title})]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-2 pl-[22px] font-mono text-[10.5px] text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{children:[`#`,e.number]}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.author}),(0,Z.jsx)(`span`,{children:M(e.createdAt)}),(0,Z.jsx)(ht,{count:e.comments}),e.checks?(0,Z.jsx)(_t,{checks:e.checks}):null,i?(0,Z.jsx)(`span`,{"data-slot":`gh-queued-flag`,className:`font-sans font-medium text-violet`,children:`↗ run queued`}):null]}),e.labels.length>0?(0,Z.jsx)(`span`,{className:`flex flex-wrap gap-1 pl-[22px]`,children:e.labels.map(e=>(0,Z.jsx)(et,{label:e,color:n[e]},e))}):null]})})}function $e({options:e,colors:t,selected:n,onChange:r}){let[i,a]=(0,X.useState)(!1),o=e=>r(n.includes(e)?n.filter(t=>t!==e):[...n,e]);return(0,Z.jsxs)(z,{open:i,onOpenChange:a,children:[(0,Z.jsx)(N,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-label-filter`,disabled:e.length===0,className:b(`flex shrink-0 items-center gap-1 rounded-md border border-input bg-card px-2 py-1 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50`,n.length>0&&`border-primary/60 text-foreground`),children:[(0,Z.jsx)(Te,{"aria-hidden":`true`,className:`size-3.5`}),n.length>0?`Labels · ${n.length}`:`Labels`]})}),(0,Z.jsx)(U,{align:`end`,sideOffset:6,className:`w-60 p-0`,children:(0,Z.jsxs)(H,{children:[(0,Z.jsx)(J,{placeholder:`Filter labels…`}),(0,Z.jsxs)(B,{className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[(0,Z.jsx)(Y,{children:`No labels.`}),n.length>0?(0,Z.jsxs)(R,{value:`__clear__`,onSelect:()=>r([]),className:`text-soft-foreground`,children:[`Clear `,n.length,` filter`,n.length>1?`s`:``]}):null,e.map(e=>{let r=n.includes(e);return(0,Z.jsxs)(R,{value:e,onSelect:()=>o(e),children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`size-2.5 shrink-0 rounded-full border`,style:Fe(t[e])}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e}),r?(0,Z.jsx)(m,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},e)})]})]})})]})}function et({label:e,color:t}){return(0,Z.jsx)(`span`,{"data-slot":`gh-label`,"data-label":e,style:Fe(t),className:`rounded-full border px-1.5 py-px text-[10px] font-medium`,children:e})}function tt({item:e,listPath:t,colors:n,children:r}){let i=e.kind===`pr`?`pull request`:`issue`,a=e.kind===`pr`&&!!(e.additions||e.deletions);return(0,Z.jsxs)(`article`,{"data-slot":`gh-detail-inner`,className:`min-w-0 px-4 py-4 md:px-7 md:py-5`,children:[(0,Z.jsxs)(O,{to:t,"data-slot":`gh-back`,className:`mb-3 inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground md:hidden`,children:[(0,Z.jsx)(x,{"aria-hidden":`true`,className:`size-3.5`}),`Back to the list`]}),(0,Z.jsxs)(`p`,{"data-slot":`gh-meta`,className:`flex flex-wrap items-center gap-x-1.5 font-mono text-[10.5px] text-soft-foreground`,children:[(0,Z.jsxs)(`span`,{children:[`#`,e.number]}),`·`,(0,Z.jsx)(`span`,{children:i}),`·`,(0,Z.jsxs)(`span`,{children:[`opened by `,e.author]}),`·`,(0,Z.jsxs)(`span`,{children:[M(e.createdAt),` ago`]}),e.comments?(0,Z.jsxs)(Z.Fragment,{children:[`·`,(0,Z.jsx)(ht,{count:e.comments})]}):null,a?(0,Z.jsxs)(Z.Fragment,{children:[`·`,(0,Z.jsxs)(`span`,{"data-slot":`gh-diffstat`,children:[(0,Z.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions??0]}),` `,(0,Z.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions??0]})]})]}):null,`·`,v(e.url)?(0,Z.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-open-link`,className:`inline-flex items-center gap-0.5 text-muted-foreground hover:text-foreground hover:underline`,children:[`open on GitHub`,(0,Z.jsx)(S,{"aria-hidden":`true`,className:`size-2.5`})]}):(0,Z.jsx)(`span`,{"data-slot":`gh-open-link`,className:`text-muted-foreground`,children:`open on GitHub`})]}),(0,Z.jsx)(`h2`,{className:`mt-2 text-xl leading-snug font-semibold`,children:e.title}),e.labels.length>0||e.checks?(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[e.labels.map(e=>(0,Z.jsx)(et,{label:e,color:n[e]},e)),e.checks?(0,Z.jsx)(gt,{checks:e.checks,url:e.url}):null]}):null,(0,Z.jsx)(`div`,{"data-slot":`gh-body`,className:`mt-5 text-sm`,children:e.body?(0,Z.jsx)(ve,{children:e.body}):(0,Z.jsx)(`p`,{className:`text-soft-foreground`,children:`(no description)`})}),(0,Z.jsx)(nt,{item:e,colors:n}),r]})}function nt({item:e,colors:t}){let n=o(e.kind,e.number),r=n.data,i=(0,X.useMemo)(()=>{let e=[...(r?.comments??[]).map(e=>({row:`comment`,comment:e})),...(r?.events??[]).map(e=>({row:`event`,event:e}))],t=e=>{let t=Date.parse(rt(e));return Number.isNaN(t)?-1/0:t};return e.sort((e,n)=>t(e)-t(n))},[r?.comments,r?.events]);return n.isPending?(0,Z.jsxs)(`section`,{"data-slot":`gh-thread-loading`,className:`mt-6 border-t border-border pt-5`,children:[(0,Z.jsx)(Q,{className:`mb-3 h-3 w-24`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(Q,{className:`h-14 w-full`}),(0,Z.jsx)(Q,{className:`h-14 w-full`})]})]}):!r||!r.available?(0,Z.jsxs)(`section`,{"data-slot":`gh-thread-error`,className:`mt-6 border-t border-border pt-5 text-xs text-soft-foreground`,children:[(0,Z.jsxs)(`span`,{children:[`Couldn’t load comments — `,r?.reason??(n.error instanceof Error?n.error.message:`could not load comments`),`. `]}),(0,Z.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-0.5 text-muted-foreground hover:text-foreground hover:underline`,children:[`open on GitHub`,(0,Z.jsx)(S,{"aria-hidden":`true`,className:`size-2.5`})]})]}):i.length===0?null:(0,Z.jsxs)(`section`,{"data-slot":`gh-thread`,className:`mt-6 border-t border-border pt-5`,children:[(0,Z.jsxs)(`h3`,{"data-slot":`gh-thread-header`,className:`mb-4 text-[11px] font-semibold tracking-wide text-soft-foreground uppercase`,children:[`Activity · `,r.comments.length,` comment`,r.comments.length===1?``:`s`]}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-5`,children:it(i).map(e=>e.group===`commits`?(0,Z.jsx)(at,{commits:e.commits,colors:t},e.commits[0].id):e.entry.row===`comment`?(0,Z.jsx)(dt,{comment:e.entry.comment},`${e.entry.comment.kind}-${e.entry.comment.id}`):(0,Z.jsx)(st,{event:e.entry.event,colors:t},e.entry.event.id))}),r.truncated?(0,Z.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-thread-truncated`,className:`mt-4 inline-flex items-center gap-0.5 text-xs text-soft-foreground hover:text-foreground hover:underline`,children:[`thread truncated — open on GitHub`,(0,Z.jsx)(S,{"aria-hidden":`true`,className:`size-2.5`})]}):null]})}var rt=e=>e.row===`comment`?e.comment.createdAt:e.event.createdAt;function it(e){let t=[],n=[],r=()=>{n.length!==0&&(n.length===1?t.push({group:`single`,entry:{row:`event`,event:n[0]}}):t.push({group:`commits`,commits:n}),n=[])};for(let i of e){if(i.row===`event`&&i.event.kind===`committed`&&i.row===`event`){let e=n[n.length-1];e&&e.actor!==i.event.actor&&r(),n.push(i.event);continue}r(),t.push({group:`single`,entry:i})}return r(),t}function at({commits:e,colors:t}){let[n,r]=(0,X.useState)(!1),i=e[0]?.actor??`?`;return n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`true`,className:`min-w-0`,children:(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":!0,onClick:()=>r(!1),className:`flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground hover:text-foreground`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:ot.committed}),(0,Z.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,Z.jsxs)(`span`,{children:[`added `,e.length,` commits`]})]})}),e.map(e=>(0,Z.jsx)(st,{event:e,colors:t},e.id))]}):(0,Z.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`false`,className:`min-w-0`,children:(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":!1,onClick:()=>r(!0),className:`flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground hover:text-foreground`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:ot.committed}),(0,Z.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,Z.jsxs)(`span`,{children:[`added `,e.length,` commits`]}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:M(e[e.length-1].createdAt)})]})})}var ot={committed:`⚙`,labeled:`◆`,unlabeled:`◇`,assigned:`◍`,unassigned:`◌`,merged:`⑃`,closed:`⊘`,reopened:`⊙`,head_ref_force_pushed:`↻`,"cross-referenced":`↗`,renamed:`✎`};function st({event:e,colors:t}){return(0,Z.jsxs)(`li`,{"data-slot":`gh-event-row`,"data-kind":e.kind,className:b(`flex min-w-0 items-center gap-1.5 font-mono text-[11px] text-soft-foreground`,e.kind===`merged`&&`text-accent-foreground`),children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:ot[e.kind]}),(0,Z.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.actor}),(0,Z.jsx)(ct,{event:e,colors:t}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:M(e.createdAt)}),e.url?(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`open ${e.kind} on GitHub`,className:`ml-auto shrink-0 text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(S,{"aria-hidden":`true`,className:`size-2.5`})}):null]})}function ct({event:e,colors:t}){switch(e.kind){case`committed`:return(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0`,children:`committed`}),e.sha?(0,Z.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.sha.slice(0,7)}):null,e.message?(0,Z.jsx)(`span`,{className:`truncate font-sans text-foreground`,children:e.message}):null,(0,Z.jsx)(lt,{checks:e.checks})]});case`labeled`:case`unlabeled`:return(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0`,children:e.kind===`labeled`?`added the`:`removed the`}),e.label?(0,Z.jsx)(`span`,{"data-slot":`gh-event-label`,style:Fe(e.label.color??t[e.label.name]),className:`max-w-[12rem] truncate rounded-full border px-1.5 py-px font-sans text-[10px]`,children:e.label.name}):null,(0,Z.jsx)(`span`,{className:`shrink-0`,children:`label`})]});case`assigned`:case`unassigned`:return(0,Z.jsxs)(`span`,{className:`truncate`,children:[e.kind===`assigned`?`assigned`:`unassigned`,` `,e.subject??`someone`]});case`merged`:return(0,Z.jsx)(`span`,{children:`merged this`});case`closed`:return(0,Z.jsx)(`span`,{children:`closed this`});case`reopened`:return(0,Z.jsx)(`span`,{children:`reopened this`});case`head_ref_force_pushed`:return(0,Z.jsx)(`span`,{children:`force-pushed`});case`renamed`:return(0,Z.jsxs)(`span`,{className:`truncate`,children:[`renamed this to `,e.subject??`—`]});case`cross-referenced`:return(0,Z.jsxs)(`span`,{className:`truncate`,children:[`referenced this in `,e.refNumber?`#${e.refNumber}`:`another thread`,e.refTitle?` ${e.refTitle}`:``]})}}function lt({checks:e}){return e?(0,Z.jsx)(`span`,{"data-slot":`gh-commit-checks`,"data-checks":e,"aria-label":`checks ${e}`,className:b(`shrink-0`,mt[e]),children:pt[e]}):null}var ut={approved:{label:`approved`,tone:`border-success/40 text-success`},changes_requested:{label:`changes requested`,tone:`border-danger/40 text-danger`},commented:{label:`commented`,tone:`border-border text-muted-foreground`},dismissed:{label:`dismissed`,tone:`border-border text-muted-foreground`}};function dt({comment:e}){let t=e.reviewState?ut[e.reviewState]:null;return(0,Z.jsxs)(`li`,{"data-slot":`gh-thread-entry`,"data-kind":e.kind,className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground`,children:[(0,Z.jsx)(ft,{url:e.avatarUrl,login:e.author}),(0,Z.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.author}),(0,Z.jsx)(`span`,{children:M(e.createdAt)}),t?(0,Z.jsx)(`span`,{"data-slot":`gh-review-chip`,"data-review-state":e.reviewState,className:b(`rounded-full border px-1.5 py-px font-sans text-[10px] font-medium`,t.tone),children:t.label}):null,(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`open comment on GitHub`,className:`ml-auto shrink-0 text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(S,{"aria-hidden":`true`,className:`size-2.5`})})]}),(0,Z.jsx)(`div`,{"data-slot":`gh-thread-body`,className:`text-sm`,children:e.body?(0,Z.jsx)(ve,{children:e.body}):(0,Z.jsx)(`p`,{className:`text-soft-foreground`,children:`(no body)`})})]})}function ft({url:e,login:t}){let[n,r]=(0,X.useState)(!1);return e&&!n?(0,Z.jsx)(`img`,{src:e,alt:``,width:16,height:16,loading:`lazy`,onError:()=>r(!0),"data-slot":`gh-avatar`,className:`size-4 shrink-0 rounded-full`}):(0,Z.jsx)(`span`,{"data-slot":`gh-avatar-fallback`,"aria-hidden":`true`,className:`flex size-4 shrink-0 items-center justify-center rounded-full bg-muted text-[8px] font-semibold text-muted-foreground uppercase`,children:t.slice(0,1)||`?`})}var pt={passing:`✓`,failing:`✗`,pending:`○`},mt={passing:`text-success`,failing:`text-danger`,pending:`text-muted-foreground`};function ht({count:e}){return e?(0,Z.jsxs)(`span`,{"data-slot":`gh-comment-count`,"data-count":e,"aria-label":`${e} comment${e===1?``:`s`}`,className:`inline-flex shrink-0 items-center gap-0.5`,children:[(0,Z.jsx)(we,{"aria-hidden":`true`,className:`size-3`}),e]}):null}function gt({checks:e,url:t}){let n=b(`text-[11px] font-medium`,mt[e],t&&`hover:underline`),r=`${pt[e]} checks ${e}`;return t?(0,Z.jsx)(`a`,{href:`${t}/checks`,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-checks`,"data-checks":e,className:n,children:r}):(0,Z.jsx)(`span`,{"data-slot":`gh-checks`,"data-checks":e,className:n,children:r})}function _t({checks:e}){return(0,Z.jsx)(`span`,{"data-slot":`gh-row-checks`,"data-checks":e,title:`checks ${e}`,"aria-label":`checks ${e}`,className:b(`shrink-0 font-sans text-[11px] font-semibold`,mt[e]),children:pt[e]})}export{Ye as GithubIndexRoute,Xe as GithubRoute};
1
+ import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{A as r,L as i,Mt as a,R as o,Tt as s,Wt as c,a as l,dn as u,ft as d,i as f,jt as p,k as m,ln as h,pn as ee,pt as te,t as g,ut as ne,yn as _}from"./centered-state-NF79blq7.js";import{n as v,r as y,t as b}from"./utils-B8s5qIcK.js";import{t as x}from"./arrow-left-CnSdp92h.js";import{n as S,t as C}from"./tab-link-DTQ9FBZY.js";import{t as w}from"./git-pull-request-DnR8Xh4_.js";import{t as T}from"./refresh-cw-BT8E96Tm.js";import{t as re}from"./triangle-alert-Uy8rokUh.js";import{n as E,t as ie}from"./textarea-Bj_LCreg.js";import{r as D,t as O}from"./project-router-CBzGUqvS.js";import{A as k,At as A,Ct as j,D as ae,E as oe,Et as M,F as N,Ft as P,Gt as F,H as I,J as se,Kt as ce,L as le,M as L,Mt as R,N as z,Nt as B,O as V,Ot as H,P as U,R as W,St as ue,Ut as G,Wt as de,Yt as K,_t as q,bt as fe,en as pe,ht as me,j as he,jt as J,k as ge,kt as Y,rn as _e,x as ve,xt as ye,y as be,yt as xe,z as Se}from"./index-DBwAr6Uj.js";var Ce=y(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),we=y(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),Te=y(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),X=n(t(),1),Z=e();function Q({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`skeleton`,className:b(`animate-pulse rounded-md bg-accent`,e),...t})}function $(e){return`${e.kind===`pr`?`Address GitHub pull request`:`Fix GitHub issue`} #${e.number}: ${e.title}\n\n${e.url}`}function Ee(e,t=[]){let n=$(e);return e.body?.trim()&&(n+=`\n\n---\n\n${e.body.trim()}`),t.length&&(n+=De(t)),n}function De(e){return`\n\nUse these skills where relevant: ${e.join(`, `)}.`}function Oe(e,t){return e.replace(/\{\{\s*number\s*\}\}/gi,()=>`#${t.number}`).replace(/\{\{\s*title\s*\}\}/gi,()=>t.title).replace(/\{\{\s*url\s*\}\}/gi,()=>t.url)}function ke(e,t){if(e.includes(t.url))return!0;let n=t.kind===`pr`?String.raw`(?:pull\s+request|pr)`:String.raw`issue`;return new RegExp(String.raw`\b${n}\s*#?\s*${t.number}\b`,`i`).test(e)}function Ae(e,t,n){let r=(n??``).trim();if(!r)return Ee(e,t);let i=$(e),a=r.startsWith(i)?i+Oe(r.slice(i.length),e):Oe(r,e),o=ke(a,e)?a:`${i}\n\n${a}`;return t.length?o+De(t):o}function je(e){let t=[];for(let n of e.slice(0,8)){let e=new Set(t.map(e=>e.id)),r=n;for(let t=2;e.has(r);t++)r=`${n}-${t}`;t.push({id:r,name:n,skill:n,prompt:`{{task}}`})}return t}function Me(e,t,n,r,i={}){return t?{...i,workflow:t,task:Ae(e,n,r)}:n.length?{...i,steps:je(n),task:Ae(e,[],r)}:{...i,workflow:`quick-task`,task:Ae(e,[],r)}}function Ne(e){let t=new Set;for(let n of e)for(let e of n.labels)t.add(e);return[...t].sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()))}function Pe(e,t={}){let n=(t.query??``).trim().toLowerCase(),r=t.labels??[],i=n.replace(/^#/,``),a=i!==``&&/^\d+$/.test(i);return e.filter(e=>r.length>0&&!r.every(t=>e.labels.includes(t))?!1:n===``?!0:a?String(e.number).includes(i):`#${e.number} ${e.title} ${e.author} ${e.body}`.toLowerCase().includes(n))}function Fe(e){if(!e||!/^[0-9a-fA-F]{6}$/.test(e))return{borderColor:`var(--border)`,color:`var(--muted-foreground)`};let t=`#${e}`;return{backgroundColor:`${t}22`,borderColor:`${t}66`,color:`color-mix(in srgb, ${t} 50%, var(--foreground))`}}var Ie={workflow:null,skills:[]},Le=`cez-followup-selection`;function Re(e){let t=e&&typeof e==`object`?e:{};return{workflow:typeof t.workflow==`string`?t.workflow:null,skills:Array.isArray(t.skills)?t.skills.filter(e=>typeof e==`string`):[]}}function ze(){try{let e=localStorage.getItem(Le);return e?Re(JSON.parse(e)):{...Ie}}catch{return{...Ie}}}function Be(e){try{localStorage.setItem(Le,JSON.stringify(e))}catch{}}var Ve=`cez-followup-prompt:`;function He(e){try{return localStorage.getItem(Ve+e)??``}catch{return``}}function Ue(e,t){try{t===``?localStorage.removeItem(Ve+e):localStorage.setItem(Ve+e,t)}catch{}}function We({item:e,workflows:t,skills:n,workflow:i,onWorkflowChange:a,selectedSkills:o,onSkillsChange:p,engine:h,onEngineChange:te,queuedRunId:g,onQueued:ne}){let _=ee(),v=d(),y=o.filter(e=>n.some(t=>t.name===e)),[b]=(0,X.useState)(()=>$(e)),[x,S]=(0,X.useState)(()=>He(e.url)||b),C=Se(h),w=(0,X.useRef)(null);(0,X.useEffect)(()=>{Ue(e.url,x===b?``:x)},[e.url,x,b]);let T=(0,X.useMemo)(()=>k(v.data?.promptTemplates),[v.data?.promptTemplates]),re=e=>{let t=w.current,n=x===b?x.length:t?.selectionStart??x.length,r=ge(x,n,e);S(r.text),requestAnimationFrame(()=>{w.current?.focus(),w.current?.setSelectionRange(r.caret,r.caret)})},D=V(T,y),A=(0,X.useRef)(x);A.current=x;let j=(0,X.useRef)(``);(0,X.useEffect)(()=>{let e=he(A.current,j.current,D,b);j.current=e.applied,e.text!==A.current&&S(e.text)},[D,b]);let M=u({mutationFn:()=>s(Me(e,i,y,x,W(C))),onSuccess:t=>{let n=`runs`in t?t.runs[0]:t;n&&ne(e.url,n.id),y.length>0&&v.data!==void 0&&c({skillUsage:y.reduce((e,t)=>me(e,t),v.data.skillUsage)}).then(()=>_.invalidateQueries({queryKey:r.uiState})).catch(()=>{}),Ue(e.url,``),S(b),j.current=``,_.invalidateQueries({queryKey:r.runs.all})},onError:e=>f(e.message,{tone:`danger`})}),N=e=>{oe({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),M.isPending||M.mutate())},P=e=>p(o.includes(e)?o.filter(t=>t!==e):[...o,e]);return(0,Z.jsxs)(`section`,{"data-slot":`gh-hand`,className:`mt-7 rounded-lg border border-border bg-card p-4`,children:[(0,Z.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-[11px] font-semibold tracking-[.04em] text-soft-foreground uppercase`,children:[(0,Z.jsx)(G,{"aria-hidden":`true`,className:`size-3.5 text-violet`}),`Hand this to the agent`]}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(Ge,{workflows:t,value:i,onChange:a}),(0,Z.jsx)(Ke,{skills:n,skillUsage:v.data?.skillUsage,selected:y,onToggle:P}),(0,Z.jsx)(le,{pick:h,onChange:te,disabled:M.isPending}),(0,Z.jsx)(L,{templates:T,onInsert:re})]}),y.length>0?(0,Z.jsx)(`div`,{"data-slot":`gh-skill-chips`,className:`mt-2.5 flex flex-wrap gap-1.5`,children:y.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-skill-chip`,"data-skill":e,onClick:()=>P(e),title:`Remove this skill`,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:[e,(0,Z.jsx)(E,{"aria-hidden":`true`,className:`size-3`})]},e))}):null,(0,Z.jsx)(ie,{ref:w,"data-slot":`gh-custom-prompt`,"aria-label":`Custom prompt`,"aria-keyshortcuts":`Control+Enter Meta+Enter`,value:x,onChange:e=>S(e.target.value),onKeyDown:N,placeholder:`Instructions for the agent… (#${e.number} and its link are always sent)`,className:`mt-3 min-h-20 text-[13px]`}),(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2.5`,children:[(0,Z.jsxs)(l,{variant:`contrast`,"data-action":`gh-run`,disabled:M.isPending,onClick:()=>M.mutate(),children:[(0,Z.jsx)(K,{"aria-hidden":`true`,className:`size-3.5`}),`Run agent on this `,e.kind===`pr`?`PR`:`issue`]}),(0,Z.jsx)(`kbd`,{"aria-hidden":`true`,className:`rounded-[5px] border border-b-2 border-border bg-card px-[5px] py-px font-mono text-[10.5px] font-medium text-muted-foreground`,children:ae()}),g?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{"data-slot":`gh-queued`,className:`flex items-center gap-1 text-xs font-medium text-success`,children:[(0,Z.jsx)(m,{"aria-hidden":`true`,className:`size-3.5`}),`queued`]}),(0,Z.jsx)(O,{to:`/tasks/${g}`,"data-slot":`gh-view-run`,className:`text-xs font-semibold text-violet hover:underline`,children:`View task →`})]}):null]})]})}function Ge({workflows:e,value:t,onChange:n}){let[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(``),s=(0,X.useRef)(null),c=ue(e,a);return(0,Z.jsxs)(z,{open:r,onOpenChange:e=>{i(e),e||o(``)},children:[(0,Z.jsx)(N,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-workflow-trigger`,"aria-label":`Choose a workflow`,className:b(I,t&&`border-foreground/60 font-mono text-[11.5px] font-semibold text-foreground`),children:[(0,Z.jsx)(de,{"aria-hidden":`true`,className:`size-3 shrink-0 text-violet`}),(0,Z.jsx)(`span`,{className:`max-w-44 truncate`,children:t??`workflow`}),(0,Z.jsx)(_e,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Z.jsx)(U,{align:`start`,sideOffset:8,className:`w-[320px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Z.jsxs)(H,{shouldFilter:!1,children:[(0,Z.jsx)(J,{placeholder:`search workflows…`,value:a,onValueChange:o,onInput:()=>s.current?.scrollTo(0,0)}),(0,Z.jsxs)(B,{ref:s,"data-slot":`gh-workflow-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[c.length===0?(0,Z.jsx)(Y,{children:`Nothing matches.`}):null,(0,Z.jsx)(A,{children:c.map(e=>{let r=t===e.name;return(0,Z.jsxs)(R,{value:`workflow ${e.name}`,keywords:j(e.name,e.description),"data-slot":`gh-workflow-option`,"data-workflow":e.name,onSelect:()=>{n(r?null:e.name),i(!1)},children:[(0,Z.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),e.description?(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,r?(0,Z.jsx)(m,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-primary`}):null]},e.name)})})]})]})})]})}function Ke({skills:e,skillUsage:t,selected:n,onToggle:r}){let[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(null),u=(0,X.useRef)(null),{mostUsed:d,project:f,global:p}=fe(ye(e,o,t),t),h=(e,t)=>{let i=n.includes(e.name);return(0,Z.jsxs)(R,{value:`skill ${e.name} ${e.path}`,keywords:j(e.name,e.description),"data-slot":`gh-skill-option`,"data-skill":e.name,"data-selected":i?`true`:void 0,onSelect:()=>r(e.name),children:[(0,Z.jsx)(`span`,{className:b(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.description?(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,(0,Z.jsx)(`button`,{type:`button`,"data-slot":`gh-skill-view`,"aria-label":`View skill ${e.name}`,title:`View skill`,onClick:t=>{t.preventDefault(),t.stopPropagation(),l(e)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,Z.jsx)(pe,{"aria-hidden":`true`,className:`size-3.5`})}),i?(0,Z.jsx)(m,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},e.path)};return e.length===0?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(be,{skill:c,onClose:()=>l(null)}),(0,Z.jsxs)(z,{open:i,onOpenChange:e=>{a(e),e||s(``)},children:[(0,Z.jsx)(N,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-skills-trigger`,"aria-label":`Choose skills`,className:b(I,n.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,Z.jsx)(F,{"aria-hidden":`true`,className:`size-3 shrink-0 text-violet`}),`skills`,n.length>0?` · ${n.length}`:``,(0,Z.jsx)(_e,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Z.jsx)(U,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Z.jsxs)(H,{shouldFilter:!1,children:[(0,Z.jsx)(J,{placeholder:`search skills…`,value:o,onValueChange:s,onInput:()=>u.current?.scrollTo(0,0)}),(0,Z.jsxs)(B,{ref:u,"data-slot":`gh-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[d.length===0&&f.length===0&&p.length===0?(0,Z.jsx)(Y,{children:`Nothing matches.`}):null,d.length>0?(0,Z.jsx)(A,{heading:`Most used`,children:d.map(e=>h(e,q(e)))}):null,f.length>0?(0,Z.jsx)(A,{heading:`Project skills`,children:f.map(e=>h(e,!0))}):null,p.length>0?(0,Z.jsx)(A,{heading:`Global`,children:p.map(e=>h(e,!1))}):null]})]})})]})]})}var qe=30,Je=1e3;function Ye(){return d().data?.githubView===`prs`?(0,Z.jsx)(D,{to:`/github/prs`,replace:!0}):(0,Z.jsx)(Xe,{view:`issues`})}function Xe({view:e}){let{n:t}=h(),n=i(),o=i({limit:Je},n.data?.available===!0),s=o.data?.available?o.data:n.data,m=o.data?.available===!0,v=ee(),y=e=>{v.setQueryData(r.uiState,t=>({...t,githubView:e})),c({githubView:e}).then(e=>v.setQueryData(r.uiState,e)).catch(e=>{f(e instanceof Error?e.message:String(e),{tone:`danger`}),v.invalidateQueries({queryKey:r.uiState})})},x=(0,X.useRef)(null),S=u({mutationFn:()=>p({refresh:!0}),onSuccess:e=>{v.setQueryData(r.github({}),e),v.invalidateQueries({queryKey:r.github({limit:Je})});let t=x.current;if(!t){v.removeQueries({queryKey:[`github`,`comments`]});return}let n=r.githubComments(t.kind,t.number);a(t.kind,t.number,{refresh:!0}).then(e=>v.setQueryData(n,e)).catch(()=>{}),v.removeQueries({queryKey:[`github`,`comments`],predicate:e=>e.queryHash!==_(n)})},onError:e=>f(e.message,{tone:`danger`})}),E=te(),ie=ne(),D=d(),[O,k]=(0,X.useState)(()=>ze().workflow),[A,j]=(0,X.useState)(()=>ze().skills),[ae,oe]=(0,X.useState)({runner:null,model:null});(0,X.useEffect)(()=>{Be({workflow:O,skills:[...A]})},[O,A]);let N=E.data?.workflows;(0,X.useEffect)(()=>{N&&O!==null&&!N.some(e=>e.name===O)&&k(null)},[N,O]);let F=ie.data,I=D.data?.skillUsage,le=(0,X.useMemo)(()=>xe(F??[],I),[F,I]),[L,R]=(0,X.useState)(new Map),[z,B]=(0,X.useState)(``),[V,H]=(0,X.useState)([]);if(!s)return n.isError?(0,Z.jsx)(`div`,{"data-route":`github`,className:`flex min-h-full flex-col`,children:(0,Z.jsx)(g,{icon:(0,Z.jsx)(re,{}),tone:`danger`,title:`Could not load GitHub`,subtitle:n.error.message})}):(0,Z.jsx)(se,{});if(x.current=null,!s.available)return(0,Z.jsx)(`div`,{"data-route":`github`,className:`flex min-h-full flex-col`,children:(0,Z.jsx)(g,{icon:(0,Z.jsx)(P,{}),tone:`neutral`,title:`GitHub is unavailable here`,subtitle:s.reason??`unknown reason`,actions:(0,Z.jsx)(l,{variant:`outline`,"data-action":`gh-retry`,disabled:S.isPending,onClick:()=>S.mutate(),children:`Try again`}),children:(0,Z.jsxs)(`p`,{className:`text-xs leading-relaxed text-soft-foreground`,children:[`The tab needs the `,(0,Z.jsx)(`span`,{className:`font-mono`,children:`gh`}),` CLI, logged in (`,(0,Z.jsx)(`span`,{className:`font-mono`,children:`gh auth login`}),`), and a repo with a GitHub remote. Everything else in cezar works without it.`]})})});let U=e===`issues`?s.issues:s.prs,W=s.labelColors??{},ue=Ne(U),G=Pe(U,{query:z,labels:V}),de=z.trim()!==``||V.length>0,K=t===void 0?null:Number.parseInt(t,10),q=K===null?G[0]??null:U.find(e=>e.number===K)??null;x.current=q?{kind:q.kind,number:q.number}:null;let fe=e===`issues`?`/github`:`/github/prs`;return(0,Z.jsxs)(`div`,{"data-route":`github`,className:`flex h-full min-h-0 items-stretch`,children:[(0,Z.jsxs)(`section`,{"data-slot":`gh-list`,className:b(`w-full min-h-0 flex-col overflow-y-auto overscroll-contain border-border md:flex md:w-[360px] md:shrink-0 md:border-r`,t===void 0?`flex`:`hidden`),children:[(0,Z.jsxs)(`header`,{"data-slot":`gh-header`,className:`sticky top-0 z-10 border-b border-border bg-background/95 px-4 pt-3 backdrop-blur`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,Z.jsx)(`h1`,{className:`text-lg font-semibold`,children:`GitHub`}),s.repo?(0,Z.jsx)(`span`,{"data-slot":`gh-repo`,className:`min-w-0 truncate font-mono text-[11px] text-soft-foreground`,children:s.repo}):null,(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-refresh`,title:`Refresh from GitHub`,disabled:S.isPending,onClick:()=>S.mutate(),className:`ml-auto flex shrink-0 items-center gap-1 rounded-full border border-border px-1.5 py-px text-[10px] font-medium text-soft-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-55`,children:[(0,Z.jsx)(T,{"aria-hidden":`true`,className:b(`size-[9px]`,S.isPending&&`motion-safe:animate-spin`)}),s.syncedAt?`synced ${M(s.syncedAt)} ago`:`refresh`]})]}),(0,Z.jsxs)(`div`,{"data-slot":`gh-tabs`,className:`mt-2.5 flex items-end gap-1`,children:[(0,Z.jsxs)(C,{to:`/github`,active:e===`issues`,onClick:()=>y(`issues`),children:[`Issues · `,Ze(s.issues.length,m)]}),(0,Z.jsxs)(C,{to:`/github/prs`,active:e===`prs`,onClick:()=>y(`prs`),children:[`Pull requests · `,Ze(s.prs.length,m)]})]}),(0,Z.jsxs)(`div`,{className:`mt-2.5 flex items-center gap-2 pb-3`,children:[(0,Z.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,Z.jsx)(ce,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-soft-foreground`}),(0,Z.jsx)(`input`,{type:`search`,"data-slot":`gh-search`,"aria-label":`Search ${e}`,placeholder:`Search #id, title, author…`,value:z,onChange:e=>B(e.target.value),className:`w-full rounded-md border border-input bg-card py-1 pr-2 pl-7 text-[13px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`})]}),(0,Z.jsx)($e,{options:ue,colors:W,selected:V,onChange:H})]})]}),G.length===0?(0,Z.jsx)(`p`,{className:`px-4 py-4 text-sm text-soft-foreground`,children:de?`No ${e===`issues`?`issues`:`pull requests`} match your filter.`:`No open ${e===`issues`?`issues`:`pull requests`}.`}):(0,Z.jsx)(`ul`,{"data-slot":`gh-rows`,className:`flex flex-col gap-0.5 px-2 py-2`,children:G.map(t=>(0,Z.jsx)(Qe,{item:t,view:e,colors:W,active:q?.url===t.url,queued:L.has(t.url)},t.url))})]}),(0,Z.jsx)(`section`,{"data-slot":`gh-detail`,className:b(`min-w-0 min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain`,t===void 0?`hidden md:flex`:`flex`),children:q?(0,Z.jsx)(tt,{item:q,listPath:fe,colors:W,children:(0,Z.jsx)(We,{item:q,workflows:E.data?.workflows??[],skills:le,workflow:O,onWorkflowChange:k,selectedSkills:A,onSkillsChange:j,engine:ae,onEngineChange:oe,queuedRunId:L.get(q.url)??null,onQueued:(e,t)=>R(n=>new Map(n).set(e,t))},q.url)}):(0,Z.jsx)(g,{icon:e===`issues`?(0,Z.jsx)(Ce,{}):(0,Z.jsx)(w,{}),tone:`neutral`,heading:`h2`,title:K===null?`Nothing selected`:`Not in the open list`,subtitle:K===null?`No open ${e===`issues`?`issues`:`pull requests`} to show.`:`#${K} is not among the open ${e===`issues`?`issues`:`pull requests`} — it may be closed, or still outside the fetched batch.`})})]})}function Ze(e,t){return`${e}${!t&&e>=qe?`+`:``}`}function Qe({item:e,view:t,colors:n,active:r,queued:i}){let a=e.kind===`issue`?Ce:w;return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(O,{to:`${t===`issues`?`/github/issues`:`/github/prs`}/${e.number}`,draggable:!0,onDragStart:t=>{try{t.dataTransfer.setData(`text/plain`,Ee(e)),t.dataTransfer.effectAllowed=`copy`}catch{}},"data-slot":`gh-row`,"data-number":e.number,"aria-current":r?`page`:void 0,title:`Drag into the composer to prefill a task`,className:b(`flex flex-col gap-1 rounded-md px-2.5 py-2 transition-colors hover:bg-muted`,r&&`bg-muted`),children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(a,{"aria-hidden":`true`,className:b(`size-3.5 shrink-0`,e.kind===`issue`?`text-success`:`text-violet`)}),(0,Z.jsx)(`span`,{className:b(`min-w-0 truncate text-[13px] font-medium`,r&&`font-semibold`),children:e.title})]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-2 pl-[22px] font-mono text-[10.5px] text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{children:[`#`,e.number]}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.author}),(0,Z.jsx)(`span`,{children:M(e.createdAt)}),(0,Z.jsx)(ht,{count:e.comments}),e.checks?(0,Z.jsx)(_t,{checks:e.checks}):null,i?(0,Z.jsx)(`span`,{"data-slot":`gh-queued-flag`,className:`font-sans font-medium text-violet`,children:`↗ run queued`}):null]}),e.labels.length>0?(0,Z.jsx)(`span`,{className:`flex flex-wrap gap-1 pl-[22px]`,children:e.labels.map(e=>(0,Z.jsx)(et,{label:e,color:n[e]},e))}):null]})})}function $e({options:e,colors:t,selected:n,onChange:r}){let[i,a]=(0,X.useState)(!1),o=e=>r(n.includes(e)?n.filter(t=>t!==e):[...n,e]);return(0,Z.jsxs)(z,{open:i,onOpenChange:a,children:[(0,Z.jsx)(N,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-label-filter`,disabled:e.length===0,className:b(`flex shrink-0 items-center gap-1 rounded-md border border-input bg-card px-2 py-1 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50`,n.length>0&&`border-primary/60 text-foreground`),children:[(0,Z.jsx)(Te,{"aria-hidden":`true`,className:`size-3.5`}),n.length>0?`Labels · ${n.length}`:`Labels`]})}),(0,Z.jsx)(U,{align:`end`,sideOffset:6,className:`w-60 p-0`,children:(0,Z.jsxs)(H,{children:[(0,Z.jsx)(J,{placeholder:`Filter labels…`}),(0,Z.jsxs)(B,{className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[(0,Z.jsx)(Y,{children:`No labels.`}),n.length>0?(0,Z.jsxs)(R,{value:`__clear__`,onSelect:()=>r([]),className:`text-soft-foreground`,children:[`Clear `,n.length,` filter`,n.length>1?`s`:``]}):null,e.map(e=>{let r=n.includes(e);return(0,Z.jsxs)(R,{value:e,onSelect:()=>o(e),children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`size-2.5 shrink-0 rounded-full border`,style:Fe(t[e])}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e}),r?(0,Z.jsx)(m,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},e)})]})]})})]})}function et({label:e,color:t}){return(0,Z.jsx)(`span`,{"data-slot":`gh-label`,"data-label":e,style:Fe(t),className:`rounded-full border px-1.5 py-px text-[10px] font-medium`,children:e})}function tt({item:e,listPath:t,colors:n,children:r}){let i=e.kind===`pr`?`pull request`:`issue`,a=e.kind===`pr`&&!!(e.additions||e.deletions);return(0,Z.jsxs)(`article`,{"data-slot":`gh-detail-inner`,className:`min-w-0 px-4 py-4 md:px-7 md:py-5`,children:[(0,Z.jsxs)(O,{to:t,"data-slot":`gh-back`,className:`mb-3 inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground md:hidden`,children:[(0,Z.jsx)(x,{"aria-hidden":`true`,className:`size-3.5`}),`Back to the list`]}),(0,Z.jsxs)(`p`,{"data-slot":`gh-meta`,className:`flex flex-wrap items-center gap-x-1.5 font-mono text-[10.5px] text-soft-foreground`,children:[(0,Z.jsxs)(`span`,{children:[`#`,e.number]}),`·`,(0,Z.jsx)(`span`,{children:i}),`·`,(0,Z.jsxs)(`span`,{children:[`opened by `,e.author]}),`·`,(0,Z.jsxs)(`span`,{children:[M(e.createdAt),` ago`]}),e.comments?(0,Z.jsxs)(Z.Fragment,{children:[`·`,(0,Z.jsx)(ht,{count:e.comments})]}):null,a?(0,Z.jsxs)(Z.Fragment,{children:[`·`,(0,Z.jsxs)(`span`,{"data-slot":`gh-diffstat`,children:[(0,Z.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions??0]}),` `,(0,Z.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions??0]})]})]}):null,`·`,v(e.url)?(0,Z.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-open-link`,className:`inline-flex items-center gap-0.5 text-muted-foreground hover:text-foreground hover:underline`,children:[`open on GitHub`,(0,Z.jsx)(S,{"aria-hidden":`true`,className:`size-2.5`})]}):(0,Z.jsx)(`span`,{"data-slot":`gh-open-link`,className:`text-muted-foreground`,children:`open on GitHub`})]}),(0,Z.jsx)(`h2`,{className:`mt-2 text-xl leading-snug font-semibold`,children:e.title}),e.labels.length>0||e.checks?(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[e.labels.map(e=>(0,Z.jsx)(et,{label:e,color:n[e]},e)),e.checks?(0,Z.jsx)(gt,{checks:e.checks,url:e.url}):null]}):null,(0,Z.jsx)(`div`,{"data-slot":`gh-body`,className:`mt-5 text-sm`,children:e.body?(0,Z.jsx)(ve,{children:e.body}):(0,Z.jsx)(`p`,{className:`text-soft-foreground`,children:`(no description)`})}),(0,Z.jsx)(nt,{item:e,colors:n}),r]})}function nt({item:e,colors:t}){let n=o(e.kind,e.number),r=n.data,i=(0,X.useMemo)(()=>{let e=[...(r?.comments??[]).map(e=>({row:`comment`,comment:e})),...(r?.events??[]).map(e=>({row:`event`,event:e}))],t=e=>{let t=Date.parse(rt(e));return Number.isNaN(t)?-1/0:t};return e.sort((e,n)=>t(e)-t(n))},[r?.comments,r?.events]);return n.isPending?(0,Z.jsxs)(`section`,{"data-slot":`gh-thread-loading`,className:`mt-6 border-t border-border pt-5`,children:[(0,Z.jsx)(Q,{className:`mb-3 h-3 w-24`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(Q,{className:`h-14 w-full`}),(0,Z.jsx)(Q,{className:`h-14 w-full`})]})]}):!r||!r.available?(0,Z.jsxs)(`section`,{"data-slot":`gh-thread-error`,className:`mt-6 border-t border-border pt-5 text-xs text-soft-foreground`,children:[(0,Z.jsxs)(`span`,{children:[`Couldn’t load comments — `,r?.reason??(n.error instanceof Error?n.error.message:`could not load comments`),`. `]}),(0,Z.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-0.5 text-muted-foreground hover:text-foreground hover:underline`,children:[`open on GitHub`,(0,Z.jsx)(S,{"aria-hidden":`true`,className:`size-2.5`})]})]}):i.length===0?null:(0,Z.jsxs)(`section`,{"data-slot":`gh-thread`,className:`mt-6 border-t border-border pt-5`,children:[(0,Z.jsxs)(`h3`,{"data-slot":`gh-thread-header`,className:`mb-4 text-[11px] font-semibold tracking-wide text-soft-foreground uppercase`,children:[`Activity · `,r.comments.length,` comment`,r.comments.length===1?``:`s`]}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-5`,children:it(i).map(e=>e.group===`commits`?(0,Z.jsx)(at,{commits:e.commits,colors:t},e.commits[0].id):e.entry.row===`comment`?(0,Z.jsx)(dt,{comment:e.entry.comment},`${e.entry.comment.kind}-${e.entry.comment.id}`):(0,Z.jsx)(st,{event:e.entry.event,colors:t},e.entry.event.id))}),r.truncated?(0,Z.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-thread-truncated`,className:`mt-4 inline-flex items-center gap-0.5 text-xs text-soft-foreground hover:text-foreground hover:underline`,children:[`thread truncated — open on GitHub`,(0,Z.jsx)(S,{"aria-hidden":`true`,className:`size-2.5`})]}):null]})}var rt=e=>e.row===`comment`?e.comment.createdAt:e.event.createdAt;function it(e){let t=[],n=[],r=()=>{n.length!==0&&(n.length===1?t.push({group:`single`,entry:{row:`event`,event:n[0]}}):t.push({group:`commits`,commits:n}),n=[])};for(let i of e){if(i.row===`event`&&i.event.kind===`committed`&&i.row===`event`){let e=n[n.length-1];e&&e.actor!==i.event.actor&&r(),n.push(i.event);continue}r(),t.push({group:`single`,entry:i})}return r(),t}function at({commits:e,colors:t}){let[n,r]=(0,X.useState)(!1),i=e[0]?.actor??`?`;return n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`true`,className:`min-w-0`,children:(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":!0,onClick:()=>r(!1),className:`flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground hover:text-foreground`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:ot.committed}),(0,Z.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,Z.jsxs)(`span`,{children:[`added `,e.length,` commits`]})]})}),e.map(e=>(0,Z.jsx)(st,{event:e,colors:t},e.id))]}):(0,Z.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`false`,className:`min-w-0`,children:(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":!1,onClick:()=>r(!0),className:`flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground hover:text-foreground`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:ot.committed}),(0,Z.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,Z.jsxs)(`span`,{children:[`added `,e.length,` commits`]}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:M(e[e.length-1].createdAt)})]})})}var ot={committed:`⚙`,labeled:`◆`,unlabeled:`◇`,assigned:`◍`,unassigned:`◌`,merged:`⑃`,closed:`⊘`,reopened:`⊙`,head_ref_force_pushed:`↻`,"cross-referenced":`↗`,renamed:`✎`};function st({event:e,colors:t}){return(0,Z.jsxs)(`li`,{"data-slot":`gh-event-row`,"data-kind":e.kind,className:b(`flex min-w-0 items-center gap-1.5 font-mono text-[11px] text-soft-foreground`,e.kind===`merged`&&`text-accent-foreground`),children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:ot[e.kind]}),(0,Z.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.actor}),(0,Z.jsx)(ct,{event:e,colors:t}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:M(e.createdAt)}),e.url?(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`open ${e.kind} on GitHub`,className:`ml-auto shrink-0 text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(S,{"aria-hidden":`true`,className:`size-2.5`})}):null]})}function ct({event:e,colors:t}){switch(e.kind){case`committed`:return(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0`,children:`committed`}),e.sha?(0,Z.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.sha.slice(0,7)}):null,e.message?(0,Z.jsx)(`span`,{className:`truncate font-sans text-foreground`,children:e.message}):null,(0,Z.jsx)(lt,{checks:e.checks})]});case`labeled`:case`unlabeled`:return(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0`,children:e.kind===`labeled`?`added the`:`removed the`}),e.label?(0,Z.jsx)(`span`,{"data-slot":`gh-event-label`,style:Fe(e.label.color??t[e.label.name]),className:`max-w-[12rem] truncate rounded-full border px-1.5 py-px font-sans text-[10px]`,children:e.label.name}):null,(0,Z.jsx)(`span`,{className:`shrink-0`,children:`label`})]});case`assigned`:case`unassigned`:return(0,Z.jsxs)(`span`,{className:`truncate`,children:[e.kind===`assigned`?`assigned`:`unassigned`,` `,e.subject??`someone`]});case`merged`:return(0,Z.jsx)(`span`,{children:`merged this`});case`closed`:return(0,Z.jsx)(`span`,{children:`closed this`});case`reopened`:return(0,Z.jsx)(`span`,{children:`reopened this`});case`head_ref_force_pushed`:return(0,Z.jsx)(`span`,{children:`force-pushed`});case`renamed`:return(0,Z.jsxs)(`span`,{className:`truncate`,children:[`renamed this to `,e.subject??`—`]});case`cross-referenced`:return(0,Z.jsxs)(`span`,{className:`truncate`,children:[`referenced this in `,e.refNumber?`#${e.refNumber}`:`another thread`,e.refTitle?` ${e.refTitle}`:``]})}}function lt({checks:e}){return e?(0,Z.jsx)(`span`,{"data-slot":`gh-commit-checks`,"data-checks":e,"aria-label":`checks ${e}`,className:b(`shrink-0`,mt[e]),children:pt[e]}):null}var ut={approved:{label:`approved`,tone:`border-success/40 text-success`},changes_requested:{label:`changes requested`,tone:`border-danger/40 text-danger`},commented:{label:`commented`,tone:`border-border text-muted-foreground`},dismissed:{label:`dismissed`,tone:`border-border text-muted-foreground`}};function dt({comment:e}){let t=e.reviewState?ut[e.reviewState]:null;return(0,Z.jsxs)(`li`,{"data-slot":`gh-thread-entry`,"data-kind":e.kind,className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground`,children:[(0,Z.jsx)(ft,{url:e.avatarUrl,login:e.author}),(0,Z.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.author}),(0,Z.jsx)(`span`,{children:M(e.createdAt)}),t?(0,Z.jsx)(`span`,{"data-slot":`gh-review-chip`,"data-review-state":e.reviewState,className:b(`rounded-full border px-1.5 py-px font-sans text-[10px] font-medium`,t.tone),children:t.label}):null,(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`open comment on GitHub`,className:`ml-auto shrink-0 text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(S,{"aria-hidden":`true`,className:`size-2.5`})})]}),(0,Z.jsx)(`div`,{"data-slot":`gh-thread-body`,className:`text-sm`,children:e.body?(0,Z.jsx)(ve,{children:e.body}):(0,Z.jsx)(`p`,{className:`text-soft-foreground`,children:`(no body)`})})]})}function ft({url:e,login:t}){let[n,r]=(0,X.useState)(!1);return e&&!n?(0,Z.jsx)(`img`,{src:e,alt:``,width:16,height:16,loading:`lazy`,onError:()=>r(!0),"data-slot":`gh-avatar`,className:`size-4 shrink-0 rounded-full`}):(0,Z.jsx)(`span`,{"data-slot":`gh-avatar-fallback`,"aria-hidden":`true`,className:`flex size-4 shrink-0 items-center justify-center rounded-full bg-muted text-[8px] font-semibold text-muted-foreground uppercase`,children:t.slice(0,1)||`?`})}var pt={passing:`✓`,failing:`✗`,pending:`○`},mt={passing:`text-success`,failing:`text-danger`,pending:`text-muted-foreground`};function ht({count:e}){return e?(0,Z.jsxs)(`span`,{"data-slot":`gh-comment-count`,"data-count":e,"aria-label":`${e} comment${e===1?``:`s`}`,className:`inline-flex shrink-0 items-center gap-0.5`,children:[(0,Z.jsx)(we,{"aria-hidden":`true`,className:`size-3`}),e]}):null}function gt({checks:e,url:t}){let n=b(`text-[11px] font-medium`,mt[e],t&&`hover:underline`),r=`${pt[e]} checks ${e}`;return t?(0,Z.jsx)(`a`,{href:`${t}/checks`,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-checks`,"data-checks":e,className:n,children:r}):(0,Z.jsx)(`span`,{"data-slot":`gh-checks`,"data-checks":e,className:n,children:r})}function _t({checks:e}){return(0,Z.jsx)(`span`,{"data-slot":`gh-row-checks`,"data-checks":e,title:`checks ${e}`,"aria-label":`checks ${e}`,className:b(`shrink-0 font-sans text-[11px] font-semibold`,mt[e]),children:pt[e]})}export{Ye as GithubIndexRoute,Xe as GithubRoute};