@open-mercato/cezar 0.9.1-pr705.843 → 0.9.1-pr706.849

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/server/server.d.ts +36 -36
  2. package/package.json +2 -2
  3. package/web/dist/assets/alert-dialog-CqA7-o5o.js +1 -0
  4. package/web/dist/assets/compare-variants-Ck0n8H5c.js +1 -0
  5. package/web/dist/assets/diff-DZ2caWZz.js +3 -0
  6. package/web/dist/assets/{diff-view-CPL3GUgh.js → diff-view-CzPFDiNY.js} +4 -4
  7. package/web/dist/assets/git-toolbar-MA30tIn1.js +1 -0
  8. package/web/dist/assets/github-_GvVduGu.js +1 -0
  9. package/web/dist/assets/index-DKow-qJG.js +22 -0
  10. package/web/dist/assets/repo-git-r9n4yWI8.js +1 -0
  11. package/web/dist/assets/{run-diff-DLo_-8Et.js → run-diff-LMnDbd7_.js} +3 -3
  12. package/web/dist/assets/run-header-b4v8eawS.js +1 -0
  13. package/web/dist/assets/skills-CTfAFZMK.js +1 -0
  14. package/web/dist/assets/{task-changes-noIrnu9G.js → task-changes-D06zJxms.js} +1 -1
  15. package/web/dist/assets/task-commits-C8OrmCXt.js +1 -0
  16. package/web/dist/assets/task-files-C3nSZoM-.js +2 -0
  17. package/web/dist/assets/task-thread-9qjkVV_X.js +9 -0
  18. package/web/dist/assets/{use-desktop-DpM2CSDg.js → use-desktop-D3aCAKQb.js} +1 -1
  19. package/web/dist/assets/workflows-Zd83Rlef.js +11 -0
  20. package/web/dist/index.html +2 -2
  21. package/web/dist/assets/compare-variants--IUax1iv.js +0 -1
  22. package/web/dist/assets/diff-CNt01FyY.js +0 -3
  23. package/web/dist/assets/dist-BDertzy3.js +0 -1
  24. package/web/dist/assets/git-toolbar-PuZTnn2Z.js +0 -1
  25. package/web/dist/assets/github-DHTw87wy.js +0 -1
  26. package/web/dist/assets/index-DiyQLNs2.js +0 -22
  27. package/web/dist/assets/repo-git-D4oyqtPR.js +0 -1
  28. package/web/dist/assets/run-header-CiBeaAnP.js +0 -1
  29. package/web/dist/assets/skills-Bed45O3c.js +0 -1
  30. package/web/dist/assets/task-commits-bDEF2Jfz.js +0 -1
  31. package/web/dist/assets/task-files-BOOblfZc.js +0 -2
  32. package/web/dist/assets/task-thread-BbyYsjLW.js +0 -9
  33. package/web/dist/assets/workflows-DMH4Gabv.js +0 -11
@@ -306,10 +306,14 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
306
306
  "/agent-config/:id": {
307
307
  $put: {
308
308
  output: {
309
- error: string;
309
+ id: string;
310
+ path: string;
311
+ exists: boolean;
312
+ content: string;
313
+ version: string | null;
310
314
  };
311
315
  outputFormat: "json";
312
- status: 404;
316
+ status: import("hono/utils/http-status").ContentfulStatusCode;
313
317
  input: {
314
318
  param: {
315
319
  id: string;
@@ -317,14 +321,10 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
317
321
  };
318
322
  } | {
319
323
  output: {
320
- id: string;
321
- path: string;
322
- exists: boolean;
323
- content: string;
324
- version: string | null;
324
+ error: string;
325
325
  };
326
326
  outputFormat: "json";
327
- status: import("hono/utils/http-status").ContentfulStatusCode;
327
+ status: 404;
328
328
  input: {
329
329
  param: {
330
330
  id: string;
@@ -381,14 +381,6 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
381
381
  } & {
382
382
  "/workflows": {
383
383
  $post: {
384
- output: {
385
- path: string;
386
- name: string;
387
- };
388
- outputFormat: "json";
389
- status: 201;
390
- input: {};
391
- } | {
392
384
  output: {
393
385
  error: string;
394
386
  };
@@ -410,6 +402,14 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
410
402
  outputFormat: "json";
411
403
  status: 500;
412
404
  input: {};
405
+ } | {
406
+ output: {
407
+ path: string;
408
+ name: string;
409
+ };
410
+ outputFormat: "json";
411
+ status: 201;
412
+ input: {};
413
413
  };
414
414
  };
415
415
  } & {
@@ -419,7 +419,7 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
419
419
  error: string;
420
420
  };
421
421
  outputFormat: "json";
422
- status: 400;
422
+ status: 404;
423
423
  input: {
424
424
  param: {
425
425
  name: string;
@@ -430,7 +430,7 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
430
430
  error: string;
431
431
  };
432
432
  outputFormat: "json";
433
- status: 404;
433
+ status: 400;
434
434
  input: {
435
435
  param: {
436
436
  name: string;
@@ -583,10 +583,14 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
583
583
  "/agent-config/:id": {
584
584
  $put: {
585
585
  output: {
586
- error: string;
586
+ id: string;
587
+ path: string;
588
+ exists: boolean;
589
+ content: string;
590
+ version: string | null;
587
591
  };
588
592
  outputFormat: "json";
589
- status: 404;
593
+ status: import("hono/utils/http-status").ContentfulStatusCode;
590
594
  input: {
591
595
  param: {
592
596
  id: string;
@@ -594,14 +598,10 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
594
598
  };
595
599
  } | {
596
600
  output: {
597
- id: string;
598
- path: string;
599
- exists: boolean;
600
- content: string;
601
- version: string | null;
601
+ error: string;
602
602
  };
603
603
  outputFormat: "json";
604
- status: import("hono/utils/http-status").ContentfulStatusCode;
604
+ status: 404;
605
605
  input: {
606
606
  param: {
607
607
  id: string;
@@ -658,14 +658,6 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
658
658
  } & {
659
659
  "/workflows": {
660
660
  $post: {
661
- output: {
662
- path: string;
663
- name: string;
664
- };
665
- outputFormat: "json";
666
- status: 201;
667
- input: {};
668
- } | {
669
661
  output: {
670
662
  error: string;
671
663
  };
@@ -687,6 +679,14 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
687
679
  outputFormat: "json";
688
680
  status: 500;
689
681
  input: {};
682
+ } | {
683
+ output: {
684
+ path: string;
685
+ name: string;
686
+ };
687
+ outputFormat: "json";
688
+ status: 201;
689
+ input: {};
690
690
  };
691
691
  };
692
692
  } & {
@@ -696,7 +696,7 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
696
696
  error: string;
697
697
  };
698
698
  outputFormat: "json";
699
- status: 400;
699
+ status: 404;
700
700
  input: {
701
701
  param: {
702
702
  name: string;
@@ -707,7 +707,7 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
707
707
  error: string;
708
708
  };
709
709
  outputFormat: "json";
710
- status: 404;
710
+ status: 400;
711
711
  input: {
712
712
  param: {
713
713
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/cezar",
3
- "version": "0.9.1-pr705.843",
3
+ "version": "0.9.1-pr706.849",
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",
@@ -50,7 +50,7 @@
50
50
  "zod": "^3.23.0"
51
51
  },
52
52
  "devDependencies": {
53
- "@open-mercato/cezar-api-client": "0.9.1-pr705.843",
53
+ "@open-mercato/cezar-api-client": "0.9.1-pr706.849",
54
54
  "@types/node": "^20.14.0",
55
55
  "@types/ws": "^8.18.1",
56
56
  "tsx": "^4.19.0",
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{E as r,_ as i,b as a,c as o,d as s,f as c,g as l,h as u,l as d,o as f,p as ee,s as te,u as ne,w as re,x as p,y as m}from"./centered-state-_B4KtyI9.js";import{t as h}from"./utils-D27OaPrA.js";var g=e(t(),1),_=n(),v=`Dialog`,[y,b]=a(v),[ie,x]=y(v),S=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=g.useRef(null),l=g.useRef(null),[d,f]=i({prop:r,defaultProp:a??!1,onChange:o,caller:v});return(0,_.jsx)(ie,{scope:t,triggerRef:c,contentRef:l,contentId:u(),titleId:u(),descriptionId:u(),open:d,onOpenChange:f,onOpenToggle:g.useCallback(()=>f(e=>!e),[f]),modal:s,children:n})};S.displayName=v;var C=`DialogTrigger`,w=g.forwardRef((e,t)=>{let{__scopeDialog:n,...i}=e,a=x(C,n),o=r(t,a.triggerRef);return(0,_.jsx)(p.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":B(a.open),...i,ref:o,onClick:m(e.onClick,a.onOpenToggle)})});w.displayName=C;var T=`DialogPortal`,[E,D]=y(T,{forceMount:void 0}),O=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=x(T,t);return(0,_.jsx)(E,{scope:t,forceMount:n,children:g.Children.map(r,e=>(0,_.jsx)(l,{present:n||a.open,children:(0,_.jsx)(ne,{asChild:!0,container:i,children:e})}))})};O.displayName=T;var k=`DialogOverlay`,A=g.forwardRef((e,t)=>{let n=D(k,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=x(k,e.__scopeDialog);return a.modal?(0,_.jsx)(l,{present:r||a.open,children:(0,_.jsx)(oe,{...i,ref:t})}):null});A.displayName=k;var ae=re(`DialogOverlay.RemoveScroll`),oe=g.forwardRef((e,t)=>{let{__scopeDialog:n,...i}=e,a=x(k,n),s=r(t,ee());return(0,_.jsx)(o,{as:ae,allowPinchZoom:!0,shards:[a.contentRef],children:(0,_.jsx)(p.div,{"data-state":B(a.open),...i,ref:s,style:{pointerEvents:`auto`,...i.style}})})}),j=`DialogContent`,M=g.forwardRef((e,t)=>{let n=D(j,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=x(j,e.__scopeDialog);return(0,_.jsx)(l,{present:r||a.open,children:a.modal?(0,_.jsx)(se,{...i,ref:t}):(0,_.jsx)(ce,{...i,ref:t})})});M.displayName=j;var se=g.forwardRef((e,t)=>{let n=x(j,e.__scopeDialog),i=g.useRef(null),a=r(t,n.contentRef,i);return g.useEffect(()=>{let e=i.current;if(e)return te(e)},[]),(0,_.jsx)(N,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:m(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:m(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:m(e.onFocusOutside,e=>e.preventDefault())})}),ce=g.forwardRef((e,t)=>{let n=x(j,e.__scopeDialog),r=g.useRef(!1),i=g.useRef(!1);return(0,_.jsx)(N,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),N=g.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,l=x(j,n);return d(),(0,_.jsx)(_.Fragment,{children:(0,_.jsx)(s,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,_.jsx)(c,{role:`dialog`,id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":B(l.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})}),P=`DialogTitle`,F=g.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=x(P,n);return(0,_.jsx)(p.h2,{id:i.titleId,...r,ref:t})});F.displayName=P;var I=`DialogDescription`,L=g.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=x(I,n);return(0,_.jsx)(p.p,{id:i.descriptionId,...r,ref:t})});L.displayName=I;var R=`DialogClose`,z=g.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=x(R,n);return(0,_.jsx)(p.button,{type:`button`,...r,ref:t,onClick:m(e.onClick,()=>i.onOpenChange(!1))})});z.displayName=R;function B(e){return e?`open`:`closed`}var V=`AlertDialog`,[le,ue]=a(V,[b]),H=b(),U=e=>{let{__scopeAlertDialog:t,...n}=e,r=H(t);return(0,_.jsx)(S,{...r,...n,modal:!0})};U.displayName=V;var de=`AlertDialogTrigger`,fe=g.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=H(n);return(0,_.jsx)(w,{...i,...r,ref:t})});fe.displayName=de;var pe=`AlertDialogPortal`,W=e=>{let{__scopeAlertDialog:t,...n}=e,r=H(t);return(0,_.jsx)(O,{...r,...n})};W.displayName=pe;var me=`AlertDialogOverlay`,G=g.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=H(n);return(0,_.jsx)(A,{...i,...r,ref:t})});G.displayName=me;var K=`AlertDialogContent`,[he,ge]=le(K),q=g.forwardRef((e,t)=>{let{__scopeAlertDialog:n,children:i,...a}=e,o=H(n),s=r(t,g.useRef(null)),c=g.useRef(null);return(0,_.jsx)(he,{scope:n,cancelRef:c,children:(0,_.jsx)(M,{role:`alertdialog`,...o,...a,ref:s,onOpenAutoFocus:m(a.onOpenAutoFocus,e=>{e.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:i})})});q.displayName=K;var _e=`AlertDialogTitle`,J=g.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=H(n);return(0,_.jsx)(F,{...i,...r,ref:t})});J.displayName=_e;var ve=`AlertDialogDescription`,Y=g.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=H(n);return(0,_.jsx)(L,{...i,...r,ref:t})});Y.displayName=ve;var ye=`AlertDialogAction`,X=g.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=H(n);return(0,_.jsx)(z,{...i,...r,ref:t})});X.displayName=ye;var Z=`AlertDialogCancel`,Q=g.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...i}=e,{cancelRef:a}=ge(Z,n),o=H(n),s=r(t,a);return(0,_.jsx)(z,{...o,...i,ref:s})});Q.displayName=Z;var be=U,xe=W,Se=G,Ce=q,we=X,Te=Q,Ee=J,De=Y;function Oe({...e}){return(0,_.jsx)(be,{"data-slot":`alert-dialog`,...e})}function ke({...e}){return(0,_.jsx)(xe,{"data-slot":`alert-dialog-portal`,...e})}function $({className:e,...t}){return(0,_.jsx)(Se,{"data-slot":`alert-dialog-overlay`,className:h(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function Ae({className:e,...t}){return(0,_.jsxs)(ke,{children:[(0,_.jsx)($,{}),(0,_.jsx)(Ce,{"data-slot":`alert-dialog-content`,className:h(`fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-card p-6 shadow-modal duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-md`,e),...t})]})}function je({className:e,...t}){return(0,_.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:h(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function Me({className:e,...t}){return(0,_.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:h(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t})}function Ne({className:e,...t}){return(0,_.jsx)(Ee,{"data-slot":`alert-dialog-title`,className:h(`text-lg leading-none font-semibold`,e),...t})}function Pe({className:e,...t}){return(0,_.jsx)(De,{"data-slot":`alert-dialog-description`,className:h(`text-sm text-muted-foreground`,e),...t})}function Fe({className:e,...t}){return(0,_.jsx)(we,{"data-slot":`alert-dialog-action`,className:h(f({variant:`contrast`}),e),...t})}function Ie({className:e,...t}){return(0,_.jsx)(Te,{"data-slot":`alert-dialog-cancel`,className:h(f({variant:`outline`}),e),...t})}export{Pe as a,Ne as c,M as d,L as f,w as g,F as h,Ae as i,S as l,O as m,Fe as n,Me as o,A as p,Ie as r,je as s,Oe as t,z as u};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{A as r,Et as i,Pn as a,V as o,a as s,en as c,i as l,jn as u,k as d,kn as f,mt as p,t as m}from"./centered-state-_B4KtyI9.js";import{t as h}from"./utils-D27OaPrA.js";import{t as g}from"./search-x-CaddQd7u.js";import{i as _,n as v,r as y,t as b}from"./run-diff-LMnDbd7_.js";import{a as x,c as S,i as C,n as w,o as T,r as E,s as D,t as O}from"./alert-dialog-CqA7-o5o.js";import{c as k,t as A}from"./project-router-DHNVGMTs.js";import{H as j,Ht as M,St as N,U as P,V as F,Zt as I,bt as L,p as R,st as z,t as B}from"./index-DKow-qJG.js";var V=e(t(),1),H=n();function U(){let{groupId:e}=f(),t=o(e),n=a();if((0,V.useEffect)(()=>{e&&n.invalidateQueries({queryKey:r.groups.detail(e)})},[n,e,(p().data??[]).filter(t=>t.groupId===e).map(e=>`${e.id}:${e.status}:${e.archived}`).sort().join(`,`)]),t.isPending)return(0,H.jsx)(F,{});if(t.isError){let e=t.error instanceof i&&t.error.status===404;return(0,H.jsx)(`div`,{"data-route":`compare`,className:`flex min-h-full flex-col`,children:(0,H.jsx)(m,{icon:e?(0,H.jsx)(g,{}):(0,H.jsx)(M,{}),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)(s,{asChild:!0,variant:`outline`,children:(0,H.jsx)(A,{to:`/`,children:`Back to tasks`})})})})}return(0,H.jsx)(W,{groupId:e,variants:t.data.runs})}function W({groupId:e,variants:t}){let n=k(),i=a(),[o,s]=(0,V.useState)(null),f=t.every(e=>j.has(e.status)),p=t[0]?z(t[0]):``,m=u({mutationFn:t=>c(e,t),onSuccess:(t,a)=>{i.invalidateQueries({queryKey:r.runs.all}),i.invalidateQueries({queryKey:r.groups.detail(e)}),n(`/tasks/${t.winner?.id??a}`)},onError:e=>l(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)(M,{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:()=>s(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)(O,{open:o!==null,onOpenChange:e=>!e&&s(null),children:(0,H.jsxs)(C,{children:[(0,H.jsxs)(D,{children:[(0,H.jsxs)(S,{children:[`Pick variant `,o?.variant,`?`]}),(0,H.jsxs)(x,{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)(T,{children:[(0,H.jsx)(E,{children:`Keep comparing`}),(0,H.jsxs)(w,{"data-slot":`confirm-pick`,onClick:()=>{o&&m.mutate(o.id),s(null)},children:[(0,H.jsx)(d,{"aria-hidden":`true`}),`Pick variant `,o?.variant]})]})]})})]})}function G({variant:e,allTerminal:t,pickPending:n,onPick:r}){let i=N(e),a=P(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)(B,{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:[L(e.tokensUsed),a?` · ${a}`:``]})]}),(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)(R,{children:e.handoffExcerpt})}):(0,H.jsx)(`p`,{"data-slot":`variant-progress`,className:`text-xs text-soft-foreground`,children:`(no progress notes)`})]}),(0,H.jsxs)(s,{"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)(d,{"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)(I,{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};
@@ -0,0 +1,3 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diff-view-CzPFDiNY.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-runtime-CCIEwYL0.js","assets/utils-D27OaPrA.js","assets/bundle-mjs-BT31bpU6.js","assets/index-DKow-qJG.js","assets/centered-state-_B4KtyI9.js","assets/search-x-CaddQd7u.js","assets/triangle-alert-BMsU3ymT.js","assets/textarea-Dd8d_Pwi.js","assets/alert-dialog-CqA7-o5o.js","assets/project-router-DHNVGMTs.js","assets/chunk-BO2N2NFS-DE6qKn3r.js","assets/lib-BxQXEXDF.js","assets/index-CrdG_TLt.css","assets/lib-BQXq3kEf.js","assets/image-preview-B3W7bWIq.js","assets/zoomable-image-BBB-AoPi.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{i as r}from"./bundle-mjs-BT31bpU6.js";import{t as i}from"./utils-D27OaPrA.js";import{Y as a}from"./index-DKow-qJG.js";import{n as o,t as s}from"./image-preview-B3W7bWIq.js";var c=e(t(),1),l=n();function u(e){let[t,n]=(0,c.useState)(null);return(0,c.useEffect)(()=>{let e=!1;return r(()=>import(`./diff-view-CzPFDiNY.js`).then(t=>{e||n({View:t.DiffView})},()=>{e||n(`failed`)}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])),()=>{e=!0}},[]),e.files.length===0?(0,l.jsx)(`p`,{"data-slot":`diff-empty`,className:i(`px-1 text-xs text-soft-foreground`,e.className),children:`No changes.`}):t===`failed`?(0,l.jsx)(d,{...e}):t===null?(0,l.jsx)(`p`,{"data-slot":`diff-loading`,className:i(`px-1 text-xs text-soft-foreground`,e.className),children:`Loading diff…`}):(0,l.jsx)(t.View,{...e})}function d({files:e,wrap:t=!1,imageSrc:n,onOpenInApp:r,viewRef:o,className:s}){let u={adds:e.reduce((e,t)=>e+t.adds,0),dels:e.reduce((e,t)=>e+t.dels,0),files:e.length},d=(0,c.useRef)(null);return(0,c.useImperativeHandle)(o,()=>({scrollToPath:e=>{for(let t of d.current?.querySelectorAll(`[data-slot="diff-file"]`)??[])if(t.dataset.path===e){t.scrollIntoView({block:`start`,behavior:`smooth`});return}}})),(0,l.jsxs)(`div`,{ref:d,"data-slot":`diff`,"data-fallback":`true`,className:i(`flex min-w-0 flex-col gap-3`,s),children:[(0,l.jsxs)(`p`,{"data-slot":`diff-totals`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,l.jsxs)(`span`,{children:[u.files,` `,u.files===1?`file`:`files`,` changed`]}),(0,l.jsx)(a,{stat:u})]}),e.map(e=>(0,l.jsx)(f,{file:e,wrap:t,imageSrc:n,onOpenInApp:r},`${e.oldPath??``}→${e.path}`))]})}function f({file:e,wrap:t,imageSrc:n,onOpenInApp:r}){return(0,l.jsxs)(`section`,{"data-slot":`diff-file`,"data-path":e.path,className:`min-w-0 overflow-clip rounded-md border border-border bg-card`,children:[(0,l.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,l.jsx)(`span`,{"data-slot":`diff-file-path`,className:`min-w-0 truncate font-mono text-xs font-medium`,children:e.oldPath?`${e.oldPath} → ${e.path}`:e.path}),(0,l.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,l.jsx)(a,{stat:{adds:e.adds,dels:e.dels,files:1},className:`text-[11px]`})})]}),o(e)?(0,l.jsx)(s,{file:e,imageSrc:n,onOpenInApp:r}):e.binary?(0,l.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`Binary file — no text diff.`}):e.patch===``?(0,l.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`No content changes (metadata only).`}):(0,l.jsx)(`pre`,{className:i(`py-2 font-mono text-xs leading-[1.7]`,t?`break-words whitespace-pre-wrap`:`overflow-x-auto whitespace-pre`),children:e.patch.split(`
3
+ `).map((e,t)=>(0,l.jsxs)(`span`,{className:i(`block px-4`,e.startsWith(`+`)&&!e.startsWith(`+++`)&&`bg-diff-add`,e.startsWith(`-`)&&!e.startsWith(`---`)&&`bg-diff-del`,e.startsWith(`@@`)&&`text-soft-foreground`),children:[e,e===``?` `:``]},t))})]})}export{u as t};
@@ -1,6 +1,6 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-D27OaPrA.js";import{C as i,S as a,an as o,rt as s,w as c}from"./index-DiyQLNs2.js";import{t as l}from"./lib-BQXq3kEf.js";import{n as u,t as d}from"./image-preview-B3W7bWIq.js";var f=e(t(),1),p=44;function m(e){if(e.binary===!0||e.patch===``)return 1;let t=e.patch.split(`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-D27OaPrA.js";import{Y as i,Zt as a,g as o,h as s,m as c}from"./index-DKow-qJG.js";import{t as l}from"./lib-BQXq3kEf.js";import{n as u,t as d}from"./image-preview-B3W7bWIq.js";var f=e(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
- `);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=n(),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:o,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(`
5
- `));y(n=>{let i=v(e);return new Map(n).set(i,new Map(n.get(i)??L).set(t.beforeHunk,r))})},[i]),S=(0,f.useMemo)(()=>g(e),[e]),[C]=(0,f.useState)(()=>typeof window>`u`?``:window.location.search),w=_(C,S),T=(0,f.useRef)(null),E=(0,f.useRef)(null),D=(0,f.useRef)(null);(0,f.useImperativeHandle)(c,()=>({scrollToPath:t=>{let n=e.findIndex(e=>e.path===t);if(n===-1)return;let r=E.current;r?r.scrollToIndex(n,{align:`start`}):R(D.current,t)?.scrollIntoView({block:`start`,behavior:`smooth`})}}),[e]);let O=e=>{let r=v(e);return(0,F.jsx)(H,{file:e,open:!d.has(r),onToggle:()=>b(r),expanded:m.get(r)??L,onExpand:t=>void x(e,t),mode:t,wrap:n,canExpand:i!==void 0,imageSrc:a,onOpenInApp:o})};return(0,F.jsxs)(`div`,{ref:e=>{D.current=e,e&&(T.current=e.closest(`[data-slot="main"]`))},"data-slot":`diff`,"data-mode":t,className:r(`flex min-w-0 flex-col`,l),children:[(0,F.jsxs)(`p`,{"data-slot":`diff-totals`,className:`flex items-center gap-2 px-1 pb-3 text-xs text-muted-foreground`,children:[(0,F.jsxs)(`span`,{children:[u.files,` `,u.files===1?`file`:`files`,` changed`]}),(0,F.jsx)(s,{stat:u})]}),w===`virtual`?(0,F.jsx)(B,{files:e,handleRef:E,scrollElRef:T,card:O}):(0,F.jsx)(`div`,{"data-slot":`diff-files`,"data-virtualized":`false`,children:e.map(e=>(0,F.jsx)(`div`,{"data-slot":`diff-file-slot`,style:{containIntrinsicBlockSize:`auto ${h(e)}px`},className:`pb-3 [content-visibility:auto]`,children:O(e)},v(e)))})]})}function B({files:e,handleRef:t,scrollElRef:n,card:r}){let i=(0,f.useRef)(null),[a,o]=(0,f.useState)(0);return(0,f.useLayoutEffect)(()=>{let e=()=>{let e=i.current,t=n.current;!e||!t||o(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[n]),(0,F.jsx)(`div`,{ref:e=>{i.current=e,e&&(n.current=e.closest(`[data-slot="main"]`))},"data-slot":`diff-files`,"data-virtualized":`true`,children:(0,F.jsx)(l,{ref:t,scrollRef:n,startMargin:a,children:e.map(e=>(0,F.jsx)(`div`,{"data-slot":`diff-file-slot`,className:`pb-3`,children:r(e)},v(e)))})})}var V={added:`added`,deleted:`deleted`,renamed:`renamed`,copied:`copied`};function H({file:e,open:t,onToggle:n,expanded:i,onExpand:a,mode:c,wrap:l,canExpand:u,imageSrc:d,onOpenInApp:f}){let p=V[e.status];return(0,F.jsxs)(`section`,{"data-slot":`diff-file`,"data-path":e.path,className:`min-w-0 overflow-clip rounded-md border border-border bg-card`,children:[(0,F.jsx)(`header`,{className:`sticky top-[var(--diff-sticky-top,0px)] z-10 rounded-t-md border-b border-border/50 bg-card`,children:(0,F.jsxs)(`button`,{type:`button`,"data-slot":`diff-file-header`,"aria-expanded":t,onClick:n,className:`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-muted/50`,children:[(0,F.jsx)(o,{className:r(`size-3.5 shrink-0 text-soft-foreground transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),(0,F.jsx)(`span`,{"data-slot":`diff-file-path`,className:`min-w-0 truncate font-mono text-xs font-medium`,children:e.oldPath?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`span`,{className:`text-soft-foreground`,children:[e.oldPath,` → `]}),e.path]}):e.path}),p?(0,F.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[10px] font-medium text-muted-foreground`,children:p}):null,e.image?(0,F.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[10px] font-medium text-muted-foreground`,children:`image`}):e.binary?(0,F.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[10px] font-medium text-muted-foreground`,children:`binary`}):null,(0,F.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,F.jsx)(s,{stat:{adds:e.adds,dels:e.dels,files:1},className:`text-[11px]`})})]})}),t?(0,F.jsx)(U,{file:e,expanded:i,onExpand:a,mode:c,wrap:l,canExpand:u,imageSrc:d,onOpenInApp:f}):null]})}function U({file:e,expanded:t,onExpand:n,mode:i,wrap:a,canExpand:o,imageSrc:s,onOpenInApp:c}){let l=(0,f.useMemo)(()=>O(e.patch),[e.patch]),p=o&&e.status!==`added`&&e.status!==`deleted`,m=(0,f.useMemo)(()=>k(l.hunks,p),[l.hunks,p]),h=(0,f.useMemo)(()=>{let e=[];l.hunks.forEach((n,r)=>{let i=t.get(r);i&&e.push(...i),e.push(...n.lines)});let n=t.get(l.hunks.length);return n&&e.push(...n),e},[l.hunks,t]),g=(0,f.useMemo)(()=>new Map(h.map((e,t)=>[e,t])),[h]),_=W(e.path,h),v=(0,f.useMemo)(()=>i===`unified`?N(l.hunks,m,t):null,[i,l.hunks,m,t]),b=(0,f.useMemo)(()=>i===`split`?P(l.hunks,m,t):null,[i,l.hunks,m,t]),x=(0,f.useMemo)(()=>i===`unified`&&!a?{minInlineSize:`calc(${y(e.patch)}ch + 7rem)`}:void 0,[i,a,e.patch]);if(u(e))return(0,F.jsx)(d,{file:e,imageSrc:s,onOpenInApp:c});if(e.binary)return(0,F.jsx)(G,{children:`Binary file — no text diff.`});if(l.hunks.length===0)return(0,F.jsx)(G,{children:l.truncated?`Patch truncated by the server.`:`No content changes (metadata only).`});let S=e=>{if(!_)return null;let t=g.get(e);return t===void 0?null:_[t]??null};return(0,F.jsxs)(`div`,{"data-slot":`diff-file-body`,"data-wrap":a||void 0,className:r(`py-1 font-mono text-xs leading-[1.7]`,!a&&`overflow-x-auto`),children:[(0,F.jsxs)(`div`,{"data-slot":`diff-rows`,style:x,className:`[&>*]:[contain-intrinsic-block-size:auto_20px] [&>*]:[content-visibility:auto]`,children:[v?v.map((e,t)=>(0,F.jsx)(Q,{row:e,wrap:a,tokensFor:S,onExpand:p?n:void 0},t)):null,b?b.map((e,t)=>(0,F.jsx)(ee,{row:e,wrap:a,tokensFor:S,onExpand:p?n:void 0},t)):null]}),l.truncated?(0,F.jsx)(G,{children:`Patch truncated by the server — counts above remain exact.`}):null]})}function W(e,t){let n=(0,f.useMemo)(()=>t.length>I?null:t.map(e=>e.text).join(`
6
- `),[t]),r=(0,f.useMemo)(()=>c(e),[e]),[o,s]=(0,f.useState)(null);return(0,f.useEffect)(()=>{if(n===null||r===null)return;let e=!1;return a(n,r).then(t=>{e||s({text:n,tokens:t.tokens})}),()=>{e=!0}},[n,r]),n===null||r===null?null:o?.text===n?o.tokens:i(n,r)?.tokens??null}function G({children:e}){return(0,F.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:e})}var K={add:`bg-diff-add`,del:`bg-diff-del`,context:void 0},q={add:`+`,del:`−`,context:` `};function J({hunk:e}){return(0,F.jsx)(`div`,{"data-slot":`diff-hunk`,className:`bg-muted/40 px-4 py-0.5 whitespace-pre text-soft-foreground`,children:e.header})}function Y({gap:e,onExpand:t}){let n=e.count===void 0?`⋯ unchanged lines to end of file`:`⋯ ${e.count} unchanged ${e.count===1?`line`:`lines`}`;return t?(0,F.jsxs)(`button`,{type:`button`,"data-slot":`diff-gap`,onClick:()=>t(e),className:`block w-full border-y border-border/40 bg-muted/20 px-4 py-0.5 text-left text-[11px] text-soft-foreground hover:bg-muted/50 hover:text-foreground`,children:[n,` — expand`]}):(0,F.jsx)(`div`,{"data-slot":`diff-gap`,className:`border-y border-border/40 bg-muted/20 px-4 py-0.5 text-[11px] text-soft-foreground`,children:n})}function X({cell:e,tokens:t,wrap:n}){let i=T(t,e.spans,e.line.text),a=e.line.kind===`add`?`bg-diff-add-strong`:`bg-diff-del-strong`;return(0,F.jsxs)(`span`,{className:r(`min-w-0 flex-1 pr-4`,n?`break-words whitespace-pre-wrap`:`whitespace-pre`),children:[i.map((t,n)=>(0,F.jsx)(`span`,{"data-word":t.changed?e.line.kind:void 0,style:t.color===void 0?void 0:{color:t.color},className:t.changed?r(`rounded-[2px]`,a):void 0,children:t.text},n)),e.line.text===``?` `:``]})}function Z({value:e}){return(0,F.jsx)(`span`,{className:`w-10 shrink-0 pr-2 text-right text-soft-foreground/70 tabular-nums select-none`,children:e??``})}function Q({row:e,wrap:t,tokensFor:n,onExpand:i}){if(e.type===`hunk`)return(0,F.jsx)(J,{hunk:e.hunk});if(e.type===`gap`)return(0,F.jsx)(Y,{gap:e.gap,onExpand:i});let{line:a}=e.cell;return(0,F.jsxs)(`div`,{"data-slot":`diff-line`,"data-line":a.kind,className:r(`flex`,K[a.kind]),children:[(0,F.jsx)(Z,{value:a.oldLine}),(0,F.jsx)(Z,{value:a.newLine}),(0,F.jsx)(`span`,{className:`w-4 shrink-0 text-soft-foreground select-none`,children:q[a.kind]}),(0,F.jsx)(X,{cell:e.cell,tokens:n(a),wrap:t})]})}function ee({row:e,wrap:t,tokensFor:n,onExpand:r}){return e.type===`hunk`?(0,F.jsx)(J,{hunk:e.hunk}):e.type===`gap`?(0,F.jsx)(Y,{gap:e.gap,onExpand:r}):(0,F.jsxs)(`div`,{"data-slot":`diff-pair`,className:`grid grid-cols-2`,children:[(0,F.jsx)($,{cell:e.left,side:`old`,tokensFor:n,wrap:t}),(0,F.jsx)($,{cell:e.right,side:`new`,tokensFor:n,wrap:t})]})}function $({cell:e,side:t,tokensFor:n,wrap:i}){if(!e)return(0,F.jsx)(`div`,{"data-slot":`diff-cell-empty`,className:r(`bg-muted/20`,t===`new`&&`border-l border-border/40`)});let{line:a}=e;return(0,F.jsxs)(`div`,{"data-slot":`diff-cell`,"data-line":a.kind,className:r(`flex min-w-0 overflow-x-auto`,K[a.kind],t===`new`&&`border-l border-border/40`),children:[(0,F.jsx)(Z,{value:t===`old`?a.oldLine:a.newLine}),(0,F.jsx)(`span`,{className:`w-4 shrink-0 text-soft-foreground select-none`,children:q[a.kind]}),(0,F.jsx)(X,{cell:e,tokens:n(a),wrap:i})]})}export{z as DiffView};
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=n(),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:a,imageSrc:o,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(!a)return;let n=await a(e.path);if(n===null)return;let r=A(t,n.split(`
5
+ `));y(n=>{let i=v(e);return new Map(n).set(i,new Map(n.get(i)??L).set(t.beforeHunk,r))})},[a]),S=(0,f.useMemo)(()=>g(e),[e]),[C]=(0,f.useState)(()=>typeof window>`u`?``:window.location.search),w=_(C,S),T=(0,f.useRef)(null),E=(0,f.useRef)(null),D=(0,f.useRef)(null);(0,f.useImperativeHandle)(c,()=>({scrollToPath:t=>{let n=e.findIndex(e=>e.path===t);if(n===-1)return;let r=E.current;r?r.scrollToIndex(n,{align:`start`}):R(D.current,t)?.scrollIntoView({block:`start`,behavior:`smooth`})}}),[e]);let O=e=>{let r=v(e);return(0,F.jsx)(H,{file:e,open:!d.has(r),onToggle:()=>b(r),expanded:m.get(r)??L,onExpand:t=>void x(e,t),mode:t,wrap:n,canExpand:a!==void 0,imageSrc:o,onOpenInApp:s})};return(0,F.jsxs)(`div`,{ref:e=>{D.current=e,e&&(T.current=e.closest(`[data-slot="main"]`))},"data-slot":`diff`,"data-mode":t,className:r(`flex min-w-0 flex-col`,l),children:[(0,F.jsxs)(`p`,{"data-slot":`diff-totals`,className:`flex items-center gap-2 px-1 pb-3 text-xs text-muted-foreground`,children:[(0,F.jsxs)(`span`,{children:[u.files,` `,u.files===1?`file`:`files`,` changed`]}),(0,F.jsx)(i,{stat:u})]}),w===`virtual`?(0,F.jsx)(B,{files:e,handleRef:E,scrollElRef:T,card:O}):(0,F.jsx)(`div`,{"data-slot":`diff-files`,"data-virtualized":`false`,children:e.map(e=>(0,F.jsx)(`div`,{"data-slot":`diff-file-slot`,style:{containIntrinsicBlockSize:`auto ${h(e)}px`},className:`pb-3 [content-visibility:auto]`,children:O(e)},v(e)))})]})}function B({files:e,handleRef:t,scrollElRef:n,card:r}){let i=(0,f.useRef)(null),[a,o]=(0,f.useState)(0);return(0,f.useLayoutEffect)(()=>{let e=()=>{let e=i.current,t=n.current;!e||!t||o(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[n]),(0,F.jsx)(`div`,{ref:e=>{i.current=e,e&&(n.current=e.closest(`[data-slot="main"]`))},"data-slot":`diff-files`,"data-virtualized":`true`,children:(0,F.jsx)(l,{ref:t,scrollRef:n,startMargin:a,children:e.map(e=>(0,F.jsx)(`div`,{"data-slot":`diff-file-slot`,className:`pb-3`,children:r(e)},v(e)))})})}var V={added:`added`,deleted:`deleted`,renamed:`renamed`,copied:`copied`};function H({file:e,open:t,onToggle:n,expanded:o,onExpand:s,mode:c,wrap:l,canExpand:u,imageSrc:d,onOpenInApp:f}){let p=V[e.status];return(0,F.jsxs)(`section`,{"data-slot":`diff-file`,"data-path":e.path,className:`min-w-0 overflow-clip rounded-md border border-border bg-card`,children:[(0,F.jsx)(`header`,{className:`sticky top-[var(--diff-sticky-top,0px)] z-10 rounded-t-md border-b border-border/50 bg-card`,children:(0,F.jsxs)(`button`,{type:`button`,"data-slot":`diff-file-header`,"aria-expanded":t,onClick:n,className:`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-muted/50`,children:[(0,F.jsx)(a,{className:r(`size-3.5 shrink-0 text-soft-foreground transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),(0,F.jsx)(`span`,{"data-slot":`diff-file-path`,className:`min-w-0 truncate font-mono text-xs font-medium`,children:e.oldPath?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`span`,{className:`text-soft-foreground`,children:[e.oldPath,` → `]}),e.path]}):e.path}),p?(0,F.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[10px] font-medium text-muted-foreground`,children:p}):null,e.image?(0,F.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[10px] font-medium text-muted-foreground`,children:`image`}):e.binary?(0,F.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[10px] font-medium text-muted-foreground`,children:`binary`}):null,(0,F.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,F.jsx)(i,{stat:{adds:e.adds,dels:e.dels,files:1},className:`text-[11px]`})})]})}),t?(0,F.jsx)(U,{file:e,expanded:o,onExpand:s,mode:c,wrap:l,canExpand:u,imageSrc:d,onOpenInApp:f}):null]})}function U({file:e,expanded:t,onExpand:n,mode:i,wrap:a,canExpand:o,imageSrc:s,onOpenInApp:c}){let l=(0,f.useMemo)(()=>O(e.patch),[e.patch]),p=o&&e.status!==`added`&&e.status!==`deleted`,m=(0,f.useMemo)(()=>k(l.hunks,p),[l.hunks,p]),h=(0,f.useMemo)(()=>{let e=[];l.hunks.forEach((n,r)=>{let i=t.get(r);i&&e.push(...i),e.push(...n.lines)});let n=t.get(l.hunks.length);return n&&e.push(...n),e},[l.hunks,t]),g=(0,f.useMemo)(()=>new Map(h.map((e,t)=>[e,t])),[h]),_=W(e.path,h),v=(0,f.useMemo)(()=>i===`unified`?N(l.hunks,m,t):null,[i,l.hunks,m,t]),b=(0,f.useMemo)(()=>i===`split`?P(l.hunks,m,t):null,[i,l.hunks,m,t]),x=(0,f.useMemo)(()=>i===`unified`&&!a?{minInlineSize:`calc(${y(e.patch)}ch + 7rem)`}:void 0,[i,a,e.patch]);if(u(e))return(0,F.jsx)(d,{file:e,imageSrc:s,onOpenInApp:c});if(e.binary)return(0,F.jsx)(G,{children:`Binary file — no text diff.`});if(l.hunks.length===0)return(0,F.jsx)(G,{children:l.truncated?`Patch truncated by the server.`:`No content changes (metadata only).`});let S=e=>{if(!_)return null;let t=g.get(e);return t===void 0?null:_[t]??null};return(0,F.jsxs)(`div`,{"data-slot":`diff-file-body`,"data-wrap":a||void 0,className:r(`py-1 font-mono text-xs leading-[1.7]`,!a&&`overflow-x-auto`),children:[(0,F.jsxs)(`div`,{"data-slot":`diff-rows`,style:x,className:`[&>*]:[contain-intrinsic-block-size:auto_20px] [&>*]:[content-visibility:auto]`,children:[v?v.map((e,t)=>(0,F.jsx)(Q,{row:e,wrap:a,tokensFor:S,onExpand:p?n:void 0},t)):null,b?b.map((e,t)=>(0,F.jsx)(ee,{row:e,wrap:a,tokensFor:S,onExpand:p?n:void 0},t)):null]}),l.truncated?(0,F.jsx)(G,{children:`Patch truncated by the server — counts above remain exact.`}):null]})}function W(e,t){let n=(0,f.useMemo)(()=>t.length>I?null:t.map(e=>e.text).join(`
6
+ `),[t]),r=(0,f.useMemo)(()=>o(e),[e]),[i,a]=(0,f.useState)(null);return(0,f.useEffect)(()=>{if(n===null||r===null)return;let e=!1;return c(n,r).then(t=>{e||a({text:n,tokens:t.tokens})}),()=>{e=!0}},[n,r]),n===null||r===null?null:i?.text===n?i.tokens:s(n,r)?.tokens??null}function G({children:e}){return(0,F.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:e})}var K={add:`bg-diff-add`,del:`bg-diff-del`,context:void 0},q={add:`+`,del:`−`,context:` `};function J({hunk:e}){return(0,F.jsx)(`div`,{"data-slot":`diff-hunk`,className:`bg-muted/40 px-4 py-0.5 whitespace-pre text-soft-foreground`,children:e.header})}function Y({gap:e,onExpand:t}){let n=e.count===void 0?`⋯ unchanged lines to end of file`:`⋯ ${e.count} unchanged ${e.count===1?`line`:`lines`}`;return t?(0,F.jsxs)(`button`,{type:`button`,"data-slot":`diff-gap`,onClick:()=>t(e),className:`block w-full border-y border-border/40 bg-muted/20 px-4 py-0.5 text-left text-[11px] text-soft-foreground hover:bg-muted/50 hover:text-foreground`,children:[n,` — expand`]}):(0,F.jsx)(`div`,{"data-slot":`diff-gap`,className:`border-y border-border/40 bg-muted/20 px-4 py-0.5 text-[11px] text-soft-foreground`,children:n})}function X({cell:e,tokens:t,wrap:n}){let i=T(t,e.spans,e.line.text),a=e.line.kind===`add`?`bg-diff-add-strong`:`bg-diff-del-strong`;return(0,F.jsxs)(`span`,{className:r(`min-w-0 flex-1 pr-4`,n?`break-words whitespace-pre-wrap`:`whitespace-pre`),children:[i.map((t,n)=>(0,F.jsx)(`span`,{"data-word":t.changed?e.line.kind:void 0,style:t.color===void 0?void 0:{color:t.color},className:t.changed?r(`rounded-[2px]`,a):void 0,children:t.text},n)),e.line.text===``?` `:``]})}function Z({value:e}){return(0,F.jsx)(`span`,{className:`w-10 shrink-0 pr-2 text-right text-soft-foreground/70 tabular-nums select-none`,children:e??``})}function Q({row:e,wrap:t,tokensFor:n,onExpand:i}){if(e.type===`hunk`)return(0,F.jsx)(J,{hunk:e.hunk});if(e.type===`gap`)return(0,F.jsx)(Y,{gap:e.gap,onExpand:i});let{line:a}=e.cell;return(0,F.jsxs)(`div`,{"data-slot":`diff-line`,"data-line":a.kind,className:r(`flex`,K[a.kind]),children:[(0,F.jsx)(Z,{value:a.oldLine}),(0,F.jsx)(Z,{value:a.newLine}),(0,F.jsx)(`span`,{className:`w-4 shrink-0 text-soft-foreground select-none`,children:q[a.kind]}),(0,F.jsx)(X,{cell:e.cell,tokens:n(a),wrap:t})]})}function ee({row:e,wrap:t,tokensFor:n,onExpand:r}){return e.type===`hunk`?(0,F.jsx)(J,{hunk:e.hunk}):e.type===`gap`?(0,F.jsx)(Y,{gap:e.gap,onExpand:r}):(0,F.jsxs)(`div`,{"data-slot":`diff-pair`,className:`grid grid-cols-2`,children:[(0,F.jsx)($,{cell:e.left,side:`old`,tokensFor:n,wrap:t}),(0,F.jsx)($,{cell:e.right,side:`new`,tokensFor:n,wrap:t})]})}function $({cell:e,side:t,tokensFor:n,wrap:i}){if(!e)return(0,F.jsx)(`div`,{"data-slot":`diff-cell-empty`,className:r(`bg-muted/20`,t===`new`&&`border-l border-border/40`)});let{line:a}=e;return(0,F.jsxs)(`div`,{"data-slot":`diff-cell`,"data-line":a.kind,className:r(`flex min-w-0 overflow-x-auto`,K[a.kind],t===`new`&&`border-l border-border/40`),children:[(0,F.jsx)(Z,{value:t===`old`?a.oldLine:a.newLine}),(0,F.jsx)(`span`,{className:`w-4 shrink-0 text-soft-foreground select-none`,children:q[a.kind]}),(0,F.jsx)(X,{cell:e,tokens:n(a),wrap:i})]})}export{z as DiffView};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{a as r}from"./centered-state-_B4KtyI9.js";import{n as i,r as a,t as o}from"./utils-D27OaPrA.js";import{t as s}from"./ellipsis-vertical-WowqAN6-.js";import{n as c}from"./tab-link-D6mbZhQc.js";import{t as l}from"./file-BWgi5VOt.js";import{i as u,n as d,r as f}from"./use-desktop-D3aCAKQb.js";import{t as p}from"./git-pull-request-D8yt-2Tr.js";import{t as m}from"./square-terminal-CoE5Kj-S.js";import{t as h}from"./upload-DH2pWIfO.js";import{Jt as g,Y as _,Zt as v,nt as y,ot as b,rt as x,tt as S}from"./index-DKow-qJG.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=e(t(),1),T=n();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)(v,{"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)(d,{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)(f,{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)(S,{children:[(0,T.jsx)(b,{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)(y,{align:`end`,"data-slot":`git-toolbar-menu`,children:e.menu.map(e=>(0,T.jsxs)(x,{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)(_,{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};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{A as r,B as i,Bn as a,Gt as o,Ht as s,It as c,Jt as l,L as u,Mn as d,O as f,Pn as p,R as m,Ut as h,Wt as g,a as _,gt as v,i as y,in as ee,jn as b,k as x,kn as S,t as C,xt as w,yt as te,z as T}from"./centered-state-_B4KtyI9.js";import{n as E,r as D,t as O}from"./utils-D27OaPrA.js";import{t as k}from"./arrow-left-BWue3Imk.js";import{t as A}from"./circle-check-TKq6_8_Y.js";import{t as j}from"./circle-x-bH39f-Yh.js";import{n as M,t as N}from"./tab-link-D6mbZhQc.js";import{t as ne}from"./git-pull-request-D8yt-2Tr.js";import{t as re}from"./refresh-cw-CFp_jUZr.js";import{t as ie}from"./triangle-alert-BMsU3ymT.js";import{n as P,t as ae}from"./textarea-Dd8d_Pwi.js";import{r as oe,t as F}from"./project-router-DHNVGMTs.js";import{A as I,At as se,B as ce,Bt as le,C as ue,Ct as L,D as R,Dt as z,E as B,Et as V,Ft as H,It as de,Lt as U,Mt as W,Nt as fe,Ot as G,P as pe,Pt as K,Qt as q,Rt as me,S as he,T as ge,Tt as J,Vt as _e,Wt as ve,Xt as ye,Yt as be,Zt as xe,_t as Se,b as Ce,d as we,ft as Te,gt as Ee,ht as De,j as Oe,k as ke,mt as Ae,p as je,ut as Me,v as Ne,vt as Pe,w as Fe,wt as Ie,x as Le,xt as Y,y as Re,zt as ze}from"./index-DKow-qJG.js";import{t as Be}from"./diff-DZ2caWZz.js";var Ve=D(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),He=D(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),Ue=D(`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`}]]),We=D(`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=e(t(),1),Z=n();function Q({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`skeleton`,className:O(`animate-pulse rounded-md bg-accent`,e),...t})}function Ge(e){return`${e.kind===`pr`?`Address GitHub pull request`:`Fix GitHub issue`} #${e.number}: ${e.title}\n\n${e.url}`}function Ke(e,t=[]){let n=Ge(e);return e.body?.trim()&&(n+=`\n\n---\n\n${e.body.trim()}`),t.length&&(n+=qe(t)),n}function qe(e){return`\n\nUse these skills where relevant: ${e.join(`, `)}.`}function Je(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 Ye(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 Xe(e,t,n){let r=(n??``).trim();if(!r)return Ke(e,t);let i=Ge(e),a=r.startsWith(i)?i+Je(r.slice(i.length),e):Je(r,e),o=Ye(a,e)?a:`${i}\n\n${a}`;return t.length?o+qe(t):o}function Ze(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 Qe(e,t,n,r,i={}){return t?{...i,workflow:t,task:Xe(e,n,r)}:n.length?{...i,steps:Ze(n),task:Xe(e,[],r)}:{...i,workflow:`quick-task`,task:Xe(e,[],r)}}function $e(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 et(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 tt(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 nt={workflow:null,skills:[]},rt=`cez-followup-selection`;function it(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 at(){try{let e=localStorage.getItem(rt);return e?it(JSON.parse(e)):{...nt}}catch{return{...nt}}}function ot(e){try{localStorage.setItem(rt,JSON.stringify(e))}catch{}}var st=`cez-followup-prompt:`;function ct(e){try{return localStorage.getItem(st+e)??``}catch{return``}}function lt(e,t){try{t===``?localStorage.removeItem(st+e):localStorage.setItem(st+e,t)}catch{}}function ut({item:e,workflows:t,skills:n,workflow:i,onWorkflowChange:a,selectedSkills:o,onSkillsChange:s,engine:l,onEngineChange:u,queuedRunId:d,onQueued:f}){let m=p(),h=te(),g=e.kind===`pr`?`PR`:`issue`,v=o.filter(e=>n.some(t=>t.name===e)),[S]=(0,X.useState)(()=>Ge(e)),[C,w]=(0,X.useState)(()=>ct(e.url)||S),T=Oe(l),E=(0,X.useRef)(null);(0,X.useEffect)(()=>{lt(e.url,C===S?``:C)},[e.url,C,S]);let D=(0,X.useMemo)(()=>he(h.data?.promptTemplates),[h.data?.promptTemplates]),O=e=>{let t=E.current,n=C===S?C.length:t?.selectionStart??C.length,r=Le(C,n,e);w(r.text),requestAnimationFrame(()=>{E.current?.focus(),E.current?.setSelectionRange(r.caret,r.caret)})},k=Ce(D,v),A=(0,X.useRef)(C);A.current=C;let j=(0,X.useRef)(``);(0,X.useEffect)(()=>{let e=ue(A.current,j.current,k,S);j.current=e.applied,e.text!==A.current&&w(e.text)},[k,S]);let M=b({mutationFn:async()=>T.canRun?c(Qe(e,i,v,C,I(T))):null,onSuccess:t=>{if(t===null)return;let n=`runs`in t?t.runs[0]:t;n&&f(e.url,n.id),y(`Added to the queue — ${g} #${e.number}`),v.length>0&&h.data!==void 0&&ee({skillUsage:v.reduce((e,t)=>Me(e,t),h.data.skillUsage)}).then(()=>m.invalidateQueries({queryKey:r.uiState})).catch(()=>{}),lt(e.url,``),w(S),j.current=``,m.invalidateQueries({queryKey:r.runs.all})},onError:e=>y(e.message,{tone:`danger`})}),N=e=>{Ne({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&&T.canRun&&M.mutate())},ne=e=>s(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)(me,{"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)(dt,{workflows:t,value:i,onChange:a}),(0,Z.jsx)(ft,{skills:n,skillUsage:h.data?.skillUsage,selected:v,onToggle:ne}),(0,Z.jsx)(ke,{pick:l,onChange:u,disabled:M.isPending||!T.canRun}),!T.providerPending&&!T.canRun?(0,Z.jsxs)(`span`,{"data-slot":`gh-provider-gate`,className:`inline-flex flex-wrap items-center gap-1 text-xs text-muted-foreground`,children:[T.providerError?`Provider authentication could not be verified.`:`Connect an agent provider to run this item.`,(0,Z.jsx)(F,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null,(0,Z.jsx)(Fe,{templates:D,onInsert:O})]}),v.length>0?(0,Z.jsx)(`div`,{"data-slot":`gh-skill-chips`,className:`mt-2.5 flex flex-wrap gap-1.5`,children:v.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-skill-chip`,"data-skill":e,onClick:()=>ne(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)(P,{"aria-hidden":`true`,className:`size-3`})]},e))}):null,(0,Z.jsx)(ae,{ref:E,"data-slot":`gh-custom-prompt`,"aria-label":`Custom prompt`,"aria-keyshortcuts":`Control+Enter Meta+Enter`,value:C,onChange:e=>w(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)(_,{variant:`contrast`,"data-action":`gh-run`,disabled:M.isPending||!T.canRun,onClick:()=>M.mutate(),children:[(0,Z.jsx)(ve,{"aria-hidden":`true`,className:`size-3.5`}),`Run agent on this `,g]}),(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:Re()}),d?(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)(x,{"aria-hidden":`true`,className:`size-3.5`}),`queued`]}),(0,Z.jsx)(F,{to:`/tasks/${d}`,"data-slot":`gh-view-run`,className:`text-xs font-semibold text-violet hover:underline`,children:`View task →`})]}):null]})]})}function dt({workflows:e,value:t,onChange:n}){let[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(``),s=(0,X.useRef)(null),c=Se(e,a);return(0,Z.jsxs)(ge,{open:r,onOpenChange:e=>{i(e),e||o(``)},children:[(0,Z.jsx)(R,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-workflow-trigger`,"aria-label":`Choose a workflow`,className:O(pe,t&&`border-foreground/60 font-mono text-[11.5px] font-semibold text-foreground`),children:[(0,Z.jsx)(ze,{"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)(q,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Z.jsx)(B,{align:`start`,sideOffset:8,className:`w-[320px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Z.jsxs)(L,{shouldFilter:!1,children:[(0,Z.jsx)(V,{placeholder:`search workflows…`,value:a,onValueChange:o,onInput:()=>s.current?.scrollTo(0,0)}),(0,Z.jsxs)(G,{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)(Ie,{children:`Nothing matches.`}):null,(0,Z.jsx)(J,{children:c.map(e=>{let r=t===e.name;return(0,Z.jsxs)(z,{value:`workflow ${e.name}`,keywords:Pe(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)(x,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-primary`}):null]},e.name)})})]})]})})]})}function ft({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}=De(Ee(e,o,t),t),m=(e,t)=>{let i=n.includes(e.name);return(0,Z.jsxs)(z,{value:`skill ${e.name} ${e.path}`,keywords:Pe(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:O(`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)(be,{"aria-hidden":`true`,className:`size-3.5`})}),i?(0,Z.jsx)(x,{"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)(we,{skill:c,onClose:()=>l(null)}),(0,Z.jsxs)(ge,{open:i,onOpenChange:e=>{a(e),e||s(``)},children:[(0,Z.jsx)(R,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-skills-trigger`,"aria-label":`Choose skills`,className:O(pe,n.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,Z.jsx)(le,{"aria-hidden":`true`,className:`size-3 shrink-0 text-violet`}),`skills`,n.length>0?` · ${n.length}`:``,(0,Z.jsx)(q,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Z.jsx)(B,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Z.jsxs)(L,{shouldFilter:!1,children:[(0,Z.jsx)(V,{placeholder:`search skills…`,value:o,onValueChange:s,onInput:()=>u.current?.scrollTo(0,0)}),(0,Z.jsxs)(G,{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)(Ie,{children:`Nothing matches.`}):null,d.length>0?(0,Z.jsx)(J,{heading:`Most used`,children:d.map(e=>m(e,Te(e)))}):null,f.length>0?(0,Z.jsx)(J,{heading:`Project skills`,children:f.map(e=>m(e,!0))}):null,p.length>0?(0,Z.jsx)(J,{heading:`Global`,children:p.map(e=>m(e,!1))}):null]})]})})]})]})}var $=1e3,pt=100;function mt(){return te().data?.githubView===`prs`?(0,Z.jsx)(oe,{to:`/github/prs`,replace:!0}):(0,Z.jsx)(ht,{view:`issues`})}function ht({view:e,changes:t=!1}){let{n}=S(),i=u({limit:$}),o=i.data,c=n===void 0?null:Number.parseInt(n,10),l=(0,X.useMemo)(()=>{if(!o?.available)return[];let t=new Set;e===`prs`&&c!==null&&Number.isInteger(c)&&t.add(c);for(let e of o.prs){if(t.size>=pt)break;t.add(e.number)}return[...t]},[o,e,c]),d=m(l,e===`prs`),f=d.data?.available?d.data.checks:void 0,g=p(),x=e=>{g.setQueryData(r.uiState,t=>({...t,githubView:e})),ee({githubView:e}).then(e=>g.setQueryData(r.uiState,e)).catch(e=>{y(e instanceof Error?e.message:String(e),{tone:`danger`}),g.invalidateQueries({queryKey:r.uiState})})},T=(0,X.useRef)(null),E=b({mutationFn:()=>s({refresh:!0,limit:$}),onSuccess:e=>{g.setQueryData(r.github({limit:$}),e),g.invalidateQueries({queryKey:r.githubChecks(l)});let t=T.current;if(!t){g.removeQueries({queryKey:[`github`,`comments`]});return}let n=r.githubComments(t.kind,t.number);h(t.kind,t.number,{refresh:!0}).then(e=>g.setQueryData(n,e)).catch(()=>{}),g.removeQueries({queryKey:[`github`,`comments`],predicate:e=>e.queryHash!==a(n)})},onError:e=>y(e.message,{tone:`danger`})}),D=w(),k=v(),A=te(),[j,M]=(0,X.useState)(()=>at().workflow),[P,ae]=(0,X.useState)(()=>at().skills),[oe,F]=(0,X.useState)({runner:null,model:null});(0,X.useEffect)(()=>{ot({workflow:j,skills:[...P]})},[j,P]);let I=D.data?.workflows;(0,X.useEffect)(()=>{I&&j!==null&&!I.some(e=>e.name===j)&&M(null)},[I,j]);let le=k.data,ue=A.data?.skillUsage,L=(0,X.useMemo)(()=>Ae(le??[],ue),[le,ue]),[R,z]=(0,X.useState)(new Map),[B,V]=(0,X.useState)(``),[H,de]=(0,X.useState)([]);if(!o)return i.isError?(0,Z.jsx)(`div`,{"data-route":`github`,className:`flex min-h-full flex-col`,children:(0,Z.jsx)(C,{icon:(0,Z.jsx)(ie,{}),tone:`danger`,title:`Could not load GitHub`,subtitle:i.error.message})}):(0,Z.jsx)(ce,{});if(T.current=null,!o.available)return(0,Z.jsx)(`div`,{"data-route":`github`,className:`flex min-h-full flex-col`,children:(0,Z.jsx)(C,{icon:(0,Z.jsx)(se,{}),tone:`neutral`,title:`GitHub is unavailable here`,subtitle:o.reason??`unknown reason`,actions:(0,Z.jsx)(_,{variant:`outline`,"data-action":`gh-retry`,disabled:E.isPending,onClick:()=>E.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`?o.issues:o.prs,W=o.labelColors??{},fe=$e(U),G=et(U,{query:B,labels:H}),pe=B.trim()!==``||H.length>0,K=n===void 0?null:Number.parseInt(n,10),q=K===null?G[0]??null:U.find(e=>e.number===K)??null;T.current=q?{kind:q.kind,number:q.number}:null;let me=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:O(`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`,n===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`}),o.repo?(0,Z.jsx)(`span`,{"data-slot":`gh-repo`,className:`min-w-0 truncate font-mono text-[11px] text-soft-foreground`,children:o.repo}):null,(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-refresh`,title:`Refresh from GitHub`,disabled:E.isPending,onClick:()=>E.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)(re,{"aria-hidden":`true`,className:O(`size-[9px]`,E.isPending&&`motion-safe:animate-spin`)}),o.syncedAt?`synced ${Y(o.syncedAt)} ago`:`refresh`]})]}),(0,Z.jsxs)(`div`,{"data-slot":`gh-tabs`,className:`mt-2.5 flex items-end gap-1`,children:[(0,Z.jsxs)(N,{to:`/github`,active:e===`issues`,onClick:()=>x(`issues`),children:[`Issues · `,gt(o.issues.length)]}),(0,Z.jsxs)(N,{to:`/github/prs`,active:e===`prs`,onClick:()=>x(`prs`),children:[`Pull requests · `,gt(o.prs.length)]})]}),(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)(_e,{"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:B,onChange:e=>V(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)(vt,{options:fe,colors:W,selected:H,onChange:de})]})]}),G.length===0?(0,Z.jsx)(`p`,{className:`px-4 py-4 text-sm text-soft-foreground`,children:pe?`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)(_t,{item:t,view:e,colors:W,active:q?.url===t.url,queued:R.has(t.url),checks:t.kind===`pr`?f?.[t.number]??t.checks:t.checks},t.url))})]}),(0,Z.jsx)(`section`,{"data-slot":`gh-detail`,className:O(`min-w-0 min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain`,n===void 0?`hidden md:flex`:`flex`),children:q?(0,Z.jsx)(bt,{item:q,listPath:me,colors:W,changes:t,checks:q.kind===`pr`?f?.[q.number]??q.checks:q.checks,children:(0,Z.jsx)(ut,{item:q,workflows:D.data?.workflows??[],skills:L,workflow:j,onWorkflowChange:M,selectedSkills:P,onSkillsChange:ae,engine:oe,onEngineChange:F,queuedRunId:R.get(q.url)??null,onQueued:(e,t)=>z(n=>new Map(n).set(e,t))},q.url)}):(0,Z.jsx)(C,{icon:e===`issues`?(0,Z.jsx)(He,{}):(0,Z.jsx)(ne,{}),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 gt(e){return`${e}${e>=$?`+`:``}`}function _t({item:e,view:t,colors:n,active:i,queued:a,checks:o}){let s=e.kind===`issue`?He:ne,c=p(),l=()=>{c.prefetchQuery({queryKey:r.githubComments(e.kind,e.number),queryFn:({signal:t})=>h(e.kind,e.number,{},{signal:t}),staleTime:6e4})};return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(F,{to:`${t===`issues`?`/github/issues`:`/github/prs`}/${e.number}`,draggable:!0,onDragStart:t=>{try{t.dataTransfer.setData(`text/plain`,Ke(e)),t.dataTransfer.effectAllowed=`copy`}catch{}},onMouseEnter:l,onFocus:l,"data-slot":`gh-row`,"data-number":e.number,"aria-current":i?`page`:void 0,title:`Drag into the composer to prefill a task`,className:O(`flex flex-col gap-1 rounded-md px-2.5 py-2 transition-colors hover:bg-muted`,i&&`bg-muted`),children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(s,{"aria-hidden":`true`,className:O(`size-3.5 shrink-0`,e.kind===`issue`?`text-success`:`text-violet`)}),(0,Z.jsx)(`span`,{className:O(`min-w-0 truncate text-[13px] font-medium`,i&&`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:Y(e.createdAt)}),(0,Z.jsx)(Rt,{count:e.comments}),o?(0,Z.jsx)(Bt,{checks:o}):null,a?(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)(yt,{label:e,color:n[e]},e))}):null]})})}function vt({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)(ge,{open:i,onOpenChange:a,children:[(0,Z.jsx)(R,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`gh-label-filter`,disabled:e.length===0,className:O(`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)(We,{"aria-hidden":`true`,className:`size-3.5`}),n.length>0?`Labels · ${n.length}`:`Labels`]})}),(0,Z.jsx)(B,{align:`end`,sideOffset:6,className:`w-60 p-0`,children:(0,Z.jsxs)(L,{children:[(0,Z.jsx)(V,{placeholder:`Filter labels…`}),(0,Z.jsxs)(G,{className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[(0,Z.jsx)(Ie,{children:`No labels.`}),n.length>0?(0,Z.jsxs)(z,{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)(z,{value:e,onSelect:()=>o(e),children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`size-2.5 shrink-0 rounded-full border`,style:tt(t[e])}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e}),r?(0,Z.jsx)(x,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},e)})]})]})})]})}function yt({label:e,color:t}){return(0,Z.jsx)(`span`,{"data-slot":`gh-label`,"data-label":e,style:tt(t),className:`rounded-full border px-1.5 py-px text-[10px] font-medium`,children:e})}function bt({item:e,listPath:t,colors:n,children:r,changes:i,checks:a}){let o=e.kind===`pr`?`pull request`:`issue`,s=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)(F,{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)(k,{"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:o}),`·`,(0,Z.jsxs)(`span`,{children:[`opened by `,e.author]}),`·`,(0,Z.jsxs)(`span`,{children:[Y(e.createdAt),` ago`]}),e.comments?(0,Z.jsxs)(Z.Fragment,{children:[`·`,(0,Z.jsx)(Rt,{count:e.comments})]}):null,s?(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,`·`,E(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)(M,{"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.kind===`pr`?(0,Z.jsxs)(`nav`,{"aria-label":`Pull request detail`,className:`mt-4 flex border-b border-border`,children:[(0,Z.jsx)(N,{to:`/github/prs/${e.number}`,active:!i,children:`Conversation`}),(0,Z.jsx)(N,{to:`/github/prs/${e.number}/changes`,active:i,children:`Changes`})]}):null,e.labels.length>0||a?(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[e.labels.map(e=>(0,Z.jsx)(yt,{label:e,color:n[e]},e)),a?(0,Z.jsx)(zt,{checks:a,url:e.url}):null]}):null,i&&e.kind===`pr`?(0,Z.jsx)(wt,{item:e}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{"data-slot":`gh-body`,className:`mt-5 text-sm`,children:e.body?(0,Z.jsx)(je,{children:e.body}):(0,Z.jsx)(`p`,{className:`text-soft-foreground`,children:`(no description)`})}),(0,Z.jsx)(Tt,{item:e,colors:n}),e.kind===`pr`?(0,Z.jsx)(Ct,{number:e.number}):null,r]})]})}var xt={squash:`Squash and merge`,merge:`Create a merge commit`,rebase:`Rebase and merge`};function St({state:e}){let t=`size-4 shrink-0`;return e===`passing`?(0,Z.jsx)(A,{"aria-hidden":`true`,"data-slot":`gh-merge-status-passing`,className:O(t,`text-success`)}):e===`failing`?(0,Z.jsx)(j,{"aria-hidden":`true`,"data-slot":`gh-merge-status-failing`,className:O(t,`text-danger`)}):e===`pending`?(0,Z.jsx)(f,{"aria-hidden":`true`,"data-slot":`gh-merge-status-pending`,className:O(t,`animate-spin text-warning`)}):(0,Z.jsx)(ye,{"aria-hidden":`true`,"data-slot":`gh-merge-status-unknown`,className:O(t,`text-soft-foreground`)})}function Ct({number:e}){let t=p(),n=d({queryKey:r.githubMergeState(e),queryFn:({signal:t})=>o(e,{},{signal:t}),retry:!1}),i=n.data?.available?n.data.mergeState:null,[a,s]=(0,X.useState)(null),[c,u]=(0,X.useState)(!1),[f,m]=(0,X.useState)(!1),h=b({mutationFn:()=>o(e,{refresh:!0}),onSuccess:n=>t.setQueryData(r.githubMergeState(e),n),onError:e=>y(e instanceof Error?e.message:String(e),{tone:`danger`})}),g=a&&i?.methods.includes(a)?a:i?.defaultMethod??i?.methods[0]??null,v=b({mutationFn:()=>{if(!i||!g)throw Error(`No merge method is available.`);return l(e,{method:g,expectedHeadSha:i.headSha,...f&&i.canOverride?{overrideRules:!0}:{}})},onSuccess:()=>{u(!1),y(`Pull request #${e} merged`),t.invalidateQueries({queryKey:r.githubMergeState(e)}),t.invalidateQueries({queryKey:r.github({limit:$})}),t.invalidateQueries({queryKey:r.githubComments(`pr`,e)})},onError:n=>{y(n instanceof Error?n.message:String(n),{tone:`danger`}),t.invalidateQueries({queryKey:r.githubMergeState(e)})}});if(n.isPending)return(0,Z.jsx)(Q,{"data-slot":`gh-merge-loading`,className:`mt-6 h-32 w-full`});if(!i)return(0,Z.jsxs)(`section`,{"data-slot":`gh-merge-unavailable`,className:`mt-6 rounded-lg border border-border bg-card p-4 text-sm`,children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:`Merge status unavailable`}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-soft-foreground`,children:n.data?.available===!1?n.data.reason:`GitHub could not load merge requirements.`})]});let ee=i.state===`merged`?`Merged`:i.state===`closed`?`Closed`:i.isDraft?`Draft`:i.mergeable===`conflicting`?`Conflicts must be resolved`:i.canMerge?`Ready to merge`:`Merge blocked`,S=i.reviewDecision===`approved`?`passing`:i.reviewDecision===`unknown`?`unknown`:`failing`,C=i.mergeable===`mergeable`?`passing`:i.mergeable===`conflicting`?`failing`:`unknown`,w=!!(g&&(i.canMerge||i.canOverride&&f));return(0,Z.jsxs)(`section`,{"data-slot":`gh-merge-box`,"aria-live":`polite`,className:`mt-6 rounded-lg border border-border bg-card p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[i.canMerge?(0,Z.jsx)(x,{"aria-hidden":`true`,className:`mt-0.5 size-5 shrink-0 text-success`}):(0,Z.jsx)(ie,{"aria-hidden":`true`,className:`mt-0.5 size-5 shrink-0 text-warning`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`h3`,{className:`font-semibold`,children:ee}),(0,Z.jsxs)(_,{type:`button`,variant:`ghost`,size:`sm`,disabled:h.isPending,onClick:()=>h.mutate(),children:[(0,Z.jsx)(re,{"aria-hidden":`true`,className:O(`size-3.5`,h.isPending&&`animate-spin`)}),`Refresh`]})]}),(0,Z.jsxs)(`p`,{className:`mt-1 font-mono text-[11px] text-soft-foreground`,children:[i.headRef,` (`,i.headSha.slice(0,7),`) → `,i.baseRef]}),(0,Z.jsxs)(`ul`,{className:`mt-3 space-y-2 text-xs`,children:[(0,Z.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(St,{state:S}),(0,Z.jsxs)(`span`,{children:[`Reviews: `,i.reviewDecision.replaceAll(`-`,` `)]})]}),(0,Z.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(St,{state:C}),(0,Z.jsxs)(`span`,{children:[`Conflicts: `,i.mergeable===`conflicting`?`present`:i.mergeable===`mergeable`?`none`:`unknown`]})]}),i.checks.length===0?(0,Z.jsx)(`li`,{children:`No checks configured`}):i.checks.map(e=>(0,Z.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(St,{state:e.state}),(0,Z.jsxs)(`span`,{children:[e.name,` · `,e.state,e.required===!0?` · required`:e.required===null?` · requiredness unknown`:``]})]}),e.url&&E(e.url)?(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-muted-foreground underline`,children:`details`}):null]},e.name)),i.blockers.map(e=>(0,Z.jsx)(`li`,{className:`text-soft-foreground`,children:e.message},e.code))]}),i.canOverride?(0,Z.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-2 rounded-md border border-warning/40 bg-warning/5 p-3 text-xs`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:f,onChange:e=>m(e.target.checked),className:`mt-0.5 size-4 accent-primary`}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`block font-medium`,children:`Merge without waiting for requirements`}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-soft-foreground`,children:`GitHub will allow this only if your permissions can bypass the repository rules.`})]})]}):null,i.state===`open`&&i.methods.length>0?(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2 sm:flex-row`,children:[(0,Z.jsx)(`select`,{"aria-label":`Merge method`,value:g??``,onChange:e=>s(e.target.value),className:`h-9 min-w-0 flex-1 rounded-md border border-input bg-background px-3 text-sm`,children:i.methods.map(e=>(0,Z.jsx)(`option`,{value:e,children:xt[e]},e))}),(0,Z.jsx)(_,{disabled:!w,onClick:()=>u(!0),children:g?xt[g]:`Merge`})]}):null]})]}),(0,Z.jsx)(W,{open:c,onOpenChange:u,children:(0,Z.jsxs)(fe,{"data-slot":`gh-merge-confirm`,showCloseButton:!1,children:[(0,Z.jsxs)(de,{children:[(0,Z.jsxs)(U,{children:[g?xt[g]:`Merge`,` pull request #`,e,`?`]}),(0,Z.jsxs)(K,{children:[`This will merge “`,i.title,`” into `,i.baseRef,`. GitHub will re-check the exact reviewed head before changing the repository.`,f&&i.canOverride?` You are asking GitHub to bypass unmet repository requirements; GitHub may refuse if your permissions do not allow it.`:``]})]}),v.error?(0,Z.jsx)(`p`,{className:`text-sm text-danger`,children:v.error.message}):null,(0,Z.jsxs)(H,{children:[(0,Z.jsx)(_,{variant:`outline`,disabled:v.isPending,onClick:()=>u(!1),children:`Cancel`}),(0,Z.jsx)(_,{disabled:v.isPending,onClick:()=>v.mutate(),children:v.isPending?`Merging…`:g?xt[g]:`Merge`})]})]})})]})}function wt({item:e}){let t=p(),n=i(e.number),[r,a]=(0,X.useState)(``),[o,s]=(0,X.useState)(null),c=n.data,l=c?.available?c.files.filter(e=>e.path.toLowerCase().includes(r.toLowerCase())):[],u=l.findIndex(e=>e.path===o);(0,X.useEffect)(()=>{l.length>0&&!l.some(e=>e.path===o)&&s(l[0].path)},[c?.available?c.headSha:``,r]);let d=async()=>{let n=c?.available?c.headSha:null,r=await g(e.number,{refresh:!0});t.setQueryData([`github`,`pr-changes`,e.number],r),r.available&&n&&n!==r.headSha&&(s(r.files[0]?.path??null),y(`The reviewed revision changed.`))};if(n.isPending)return(0,Z.jsx)(`p`,{"aria-live":`polite`,className:`mt-6 text-sm text-muted-foreground`,children:`Loading changed files…`});if(n.isError||!c)return(0,Z.jsx)(`p`,{className:`mt-6 text-sm text-danger`,children:`Changed files could not be loaded.`});if(!c.available)return(0,Z.jsx)(`p`,{className:`mt-6 text-sm text-muted-foreground`,children:c.reason});let f=l.map(e=>({path:e.path,...e.previousPath?{oldPath:e.previousPath}:{},status:e.status===`removed`?`deleted`:e.status===`changed`?`modified`:e.status,adds:e.additions,dels:e.deletions,binary:e.patchUnavailableReason===`binary`,patch:e.patch??``})),m=E(e.url)?`${e.url}/files`:null,h=l.find(e=>e.path===o);return(0,Z.jsxs)(`section`,{"data-slot":`gh-pr-changes`,className:`mt-5 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,Z.jsxs)(`strong`,{children:[c.files.length,` changed files`]}),(0,Z.jsxs)(`span`,{className:`text-success`,children:[`+`,c.additions]}),(0,Z.jsxs)(`span`,{className:`text-danger`,children:[`−`,c.deletions]}),(0,Z.jsxs)(`span`,{className:`font-mono text-muted-foreground`,title:c.headSha,children:[`head `,c.headSha.slice(0,8)]}),(0,Z.jsx)(_,{type:`button`,variant:`outline`,size:`sm`,className:`ml-auto min-h-11`,onClick:()=>void d(),children:`Refresh`})]}),c.truncated?(0,Z.jsxs)(`p`,{role:`status`,className:`mt-3 rounded-md border border-warning/40 bg-warning/10 p-3 text-xs`,children:[c.reason??`This response is incomplete.`,` `,m?(0,Z.jsx)(`a`,{href:m,target:`_blank`,rel:`noopener noreferrer`,className:`underline`,children:`Open all files on GitHub`}):null]}):null,(0,Z.jsxs)(`div`,{className:`mt-4 grid min-w-0 gap-4 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`aside`,{className:`min-w-0`,children:[(0,Z.jsx)(`input`,{"aria-label":`Filter changed files`,value:r,onChange:e=>a(e.target.value),placeholder:`Filter files…`,className:`min-h-11 w-full rounded-md border border-input bg-background px-3 text-sm`}),(0,Z.jsx)(`select`,{"aria-label":`Select changed file`,value:o??``,onChange:e=>s(e.target.value),className:`mt-2 min-h-11 w-full rounded-md border border-input bg-background px-2 text-sm lg:hidden`,children:l.map(e=>(0,Z.jsx)(`option`,{children:e.path},e.path))}),(0,Z.jsx)(`ul`,{className:`mt-2 hidden max-h-[60vh] overflow-auto lg:block`,children:l.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>s(e.path),className:O(`min-h-11 w-full truncate rounded px-2 text-left text-xs`,o===e.path&&`bg-muted font-medium`),title:e.path,children:[e.status,` · `,e.path,` `,(0,Z.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions]}),` `,(0,Z.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions]})]})},e.path))})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex justify-end gap-1`,children:[(0,Z.jsx)(_,{"aria-label":`Previous file`,variant:`outline`,size:`icon`,className:`min-h-11 min-w-11`,disabled:u<=0,onClick:()=>s(l[u-1]?.path??null),children:(0,Z.jsx)(Ve,{})}),(0,Z.jsx)(_,{"aria-label":`Next file`,variant:`outline`,size:`icon`,className:`min-h-11 min-w-11`,disabled:u<0||u>=l.length-1,onClick:()=>s(l[u+1]?.path??null),children:(0,Z.jsx)(xe,{})})]}),l.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No changed files match this filter.`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Be,{files:f.filter(e=>e.path===o),wrap:!0,className:`min-w-0`}),h&&!h.patch?(0,Z.jsxs)(`p`,{className:`rounded-b border border-border p-3 text-xs text-muted-foreground`,children:[`Patch unavailable: `,h.patchUnavailableReason??`not-provided`,`.`]}):null]})]})]})]})}function Tt({item:e,colors:t}){let n=T(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(Et(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)(M,{"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:Dt(i).map(e=>e.group===`commits`?(0,Z.jsx)(Ot,{commits:e.commits,colors:t},e.commits[0].id):e.entry.row===`comment`?(0,Z.jsx)(Pt,{comment:e.entry.comment},`${e.entry.comment.kind}-${e.entry.comment.id}`):(0,Z.jsx)(At,{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)(M,{"aria-hidden":`true`,className:`size-2.5`})]}):null]})}var Et=e=>e.row===`comment`?e.comment.createdAt:e.event.createdAt;function Dt(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 Ot({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:kt.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)(At,{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:kt.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:Y(e[e.length-1].createdAt)})]})})}var kt={committed:`⚙`,labeled:`◆`,unlabeled:`◇`,assigned:`◍`,unassigned:`◌`,merged:`⑃`,closed:`⊘`,reopened:`⊙`,head_ref_force_pushed:`↻`,"cross-referenced":`↗`,renamed:`✎`};function At({event:e,colors:t}){return(0,Z.jsxs)(`li`,{"data-slot":`gh-event-row`,"data-kind":e.kind,className:O(`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:kt[e.kind]}),(0,Z.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.actor}),(0,Z.jsx)(jt,{event:e,colors:t}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:Y(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)(M,{"aria-hidden":`true`,className:`size-2.5`})}):null]})}function jt({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)(Mt,{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:tt(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 Mt({checks:e}){return e?(0,Z.jsx)(`span`,{"data-slot":`gh-commit-checks`,"data-checks":e,"aria-label":`checks ${e}`,className:O(`shrink-0`,Lt[e]),children:It[e]}):null}var Nt={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 Pt({comment:e}){let t=e.reviewState?Nt[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:Y(e.createdAt)}),t?(0,Z.jsx)(`span`,{"data-slot":`gh-review-chip`,"data-review-state":e.reviewState,className:O(`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)(M,{"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)(je,{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 It={passing:`✓`,failing:`✗`,pending:`○`},Lt={passing:`text-success`,failing:`text-danger`,pending:`text-muted-foreground`};function Rt({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)(Ue,{"aria-hidden":`true`,className:`size-3`}),e]}):null}function zt({checks:e,url:t}){let n=O(`text-[11px] font-medium`,Lt[e],t&&`hover:underline`),r=`${It[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 Bt({checks:e}){return(0,Z.jsx)(`span`,{"data-slot":`gh-row-checks`,"data-checks":e,title:`checks ${e}`,"aria-label":`checks ${e}`,className:O(`shrink-0 font-sans text-[11px] font-semibold`,Lt[e]),children:It[e]})}export{mt as GithubIndexRoute,ht as GithubRoute};