pierre-review 0.1.62 → 0.1.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api/routes/repos.js
CHANGED
|
@@ -129,11 +129,15 @@ export async function repoRoutes(app) {
|
|
|
129
129
|
}
|
|
130
130
|
const watched = await getWatchedRepoNodeIds(accountId);
|
|
131
131
|
const me = resp.viewer.login.toLowerCase();
|
|
132
|
-
const orgLogins = new Set(resp.viewer.organizations.nodes
|
|
132
|
+
const orgLogins = new Set(resp.viewer.organizations.nodes
|
|
133
|
+
.filter((o) => o != null)
|
|
134
|
+
.map((o) => o.login.toLowerCase()));
|
|
133
135
|
const results = resp.search.nodes
|
|
134
|
-
//
|
|
135
|
-
//
|
|
136
|
-
|
|
136
|
+
// GitHub returns a NULL node for any hit the token can't fully resolve (a scoped
|
|
137
|
+
// GitHub-App token in cloud hits this; the local `gh` PAT sees them all), and {} for
|
|
138
|
+
// a (theoretical) non-repo node. Drop both null-safely BEFORE reading `id`/`owner`,
|
|
139
|
+
// then drop already-watched. (This null node is the cloud-only crash source.)
|
|
140
|
+
.filter((n) => n != null && typeof n.id === 'string')
|
|
137
141
|
.filter((n) => !watched.has(n.id))
|
|
138
142
|
.map((n) => {
|
|
139
143
|
const ownerLogin = n.owner.login;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pierre-review",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.63",
|
|
4
4
|
"description": "Dashboard for tracking your team's GitHub PR activity across repos — local (SQLite + gh) or self-hosted multi-tenant cloud (Postgres + GitHub App).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Alex Wakeman",
|
|
@@ -1387,4 +1387,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1387
1387
|
`).at(-1)??null:null}function FCe({ev:e,pr:t,usersById:n,onOpen:r}){const s=t.authorId!=null?n.get(t.authorId):void 0,a=e.actorId!=null&&t.authorId!=null&&e.actorId!==t.authorId;return f.jsxs("div",{className:"flex items-baseline gap-1 text-[11px] text-gray-500",children:[f.jsx("span",{children:"on"}),a&&f.jsxs("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:[jr(s,t.authorId),"’s"]}),f.jsxs("button",{type:"button",onClick:r,className:"font-medium text-blue-500 hover:underline",children:["#",t.number]}),f.jsx("span",{className:"truncate text-gray-400",title:t.title,children:t.title})]})}function WO({ev:e,usersById:t,prsById:n,onNavigate:r}){var W;const s=Me(M=>M.selectThread),a=Me(M=>M.selectPr),o=Me(M=>M.showActivityEntry),l=Me(M=>M.showPrComment),u=U6(e),d=e.actorId!=null?t.get(e.actorId):void 0,p=jr(d,e.actorId),m=e.type==="review_comment"&&e.threadId!=null,{data:g}=Fk(m?e.threadId:null),y=Date.parse(e.occurredAt),_=(g==null?void 0:g.comments.find(M=>Date.parse(M.createdAt)===y&&M.authorId===e.actorId))??(g==null?void 0:g.comments[0]),S=g?LCe((_==null?void 0:_.diffHunk)??((W=g.comments[0])==null?void 0:W.diffHunk)??null):null,E=e.type==="commit_pushed",N=e.type==="pr_comment",C=e.type==="review_submitted",{data:O}=jy((E||N)&&e.prId!=null?e.prId:null),I=E&&O?O.commits.find(M=>M.id===e.refId):void 0,F=N&&O?O.comments.find(M=>M.id===e.refId):void 0,P=e.prId!=null?n.get(e.prId):void 0,H=()=>{e.threadId!=null?s(e.prId,e.threadId):N&&e.prId!=null&&e.refId!=null?l(e.prId,e.refId):C&&e.prId!=null&&e.refId!=null?o(e.prId,{type:e.type,refId:e.refId}):e.prId!=null&&a(e.prId),r()},B=()=>{e.prId!=null&&(o(e.prId,{type:e.type,refId:e.refId}),r())};return f.jsxs("div",{className:"space-y-1.5",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[f.jsx("span",{className:"inline-block h-3 w-3",dangerouslySetInnerHTML:{__html:u.svg}}),f.jsx("span",{className:"font-semibold",children:p}),f.jsxs("span",{className:"text-gray-500",children:["· ",u.label]}),f.jsx("span",{className:"ml-auto text-gray-400",children:Yr(e.occurredAt)})]}),P&&f.jsx(FCe,{ev:e,pr:P,usersById:t,onOpen:H}),E&&f.jsx("div",{className:"text-[11px]",children:I?f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("code",{className:"rounded bg-gray-100 px-1 font-mono text-gray-600 dark:bg-gray-800 dark:text-gray-300",children:I.sha.slice(0,7)}),I.message&&f.jsx("span",{className:"truncate text-gray-600 dark:text-gray-300",children:I.message.split(`
|
|
1388
1388
|
`)[0]})]}):f.jsx("span",{className:"text-gray-400",children:"loading commit…"})}),g&&f.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[f.jsxs("code",{className:"truncate font-mono text-gray-600 dark:text-gray-300",children:[g.path,g.line!=null?`:${g.line}`:""]}),f.jsx("span",{className:"ml-auto shrink-0",children:f.jsx(SL,{state:g.derivedState})})]}),S&&f.jsx("pre",{className:"overflow-x-auto rounded border border-gray-200 bg-gray-50 px-2 py-1 font-mono text-[11px] leading-snug text-gray-600 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-300",children:S}),_&&f.jsxs("div",{className:"text-xs",children:[f.jsx(ss,{children:_.body}),g&&g.comments.length>1&&f.jsxs("div",{className:"mt-1 text-[11px] text-gray-400",children:["+",g.comments.length-1," more in thread"]})]}),N&&f.jsx("div",{className:"text-xs",children:F?f.jsx(ss,{children:F.body}):f.jsx("span",{className:"text-gray-400",children:"loading comment…"})}),f.jsxs("div",{className:"flex items-center gap-3 pt-0.5 text-[11px]",children:[!E&&f.jsx("button",{type:"button",onClick:H,className:"text-blue-500 hover:underline",children:"Open in detail pane"}),E&&e.prId!=null&&f.jsx("button",{type:"button",onClick:B,className:"text-blue-500 hover:underline",title:"Show this commit in the PR's Activity tab",children:"View in Activity"}),E&&I&&O&&f.jsx("a",{href:`${O.githubUrl}/commits/${I.sha}`,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"Open commit on GitHub ↗"}),N&&F&&O&&f.jsx("a",{href:F.url??O.githubUrl,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"Open on GitHub ↗"})]})]})}function jCe({state:e,eventsById:t,usersById:n,prsById:r,focusPrId:s,onContextFocus:a,onDismiss:o,onNavigate:l}){var M;const[u,d]=z6("pierre:popoverSize",null),{refs:p,floatingStyles:m,context:g,isPositioned:y}=$6({open:!0,onOpenChange:z=>{z||o()},strategy:"fixed",placement:"right-start",middleware:[R6(24),D6({fallbackPlacements:["left-start","bottom"]}),O6({padding:8})],whileElementsMounted:(z,K,V)=>I6(z,K,V,{animationFrame:!0})}),_=j6(g,{outsidePress:!1}),{getFloatingProps:S}=B6([_]),E=e.eventIds[0]??null,N=D.useRef(null);D.useEffect(()=>{N.current=null},[E]),D.useEffect(()=>{const z=()=>({x:e.x,y:e.y,top:e.y,left:e.x,right:e.x,bottom:e.y,width:0,height:0});p.setReference({getBoundingClientRect:()=>{if(E!=null){const K=document.querySelector(`.ev-key-${E}`),V=(K==null?void 0:K.querySelector(".ev-marker-inner, .ev-cluster-inner"))??K;if(V){const G=V.getBoundingClientRect();return N.current=G,G}}return N.current??z()}})},[p,E,e.x,e.y]);const C=e.eventIds.map(z=>t.get(z)).filter(z=>z!=null).filter(z=>s==null||z.prId===s),O=((M=C[0])==null?void 0:M.prId)??null;D.useEffect(()=>{a({groupIds:null,prId:O,eventId:null})},[O,a]);const I=z=>{const K=z.currentTarget;d({width:K.offsetWidth,height:K.offsetHeight})},[F,P]=D.useState({x:0,y:0}),H=D.useRef(null);D.useEffect(()=>{const z=V=>{const G=H.current;G&&P({x:G.ox+(V.clientX-G.sx),y:G.oy+(V.clientY-G.sy)})},K=()=>{H.current=null};return window.addEventListener("pointermove",z),window.addEventListener("pointerup",K),()=>{window.removeEventListener("pointermove",z),window.removeEventListener("pointerup",K)}},[]);const B=z=>{z.button===0&&(z.preventDefault(),H.current={sx:z.clientX,sy:z.clientY,ox:F.x,oy:F.y})},W=`${m.transform??""} translate(${F.x}px, ${F.y}px)`.trim();return f.jsx(F6,{children:f.jsxs("div",{ref:p.setFloating,style:{...m,transform:W,visibility:y?"visible":"hidden",width:(u==null?void 0:u.width)??420,height:(u==null?void 0:u.height)??340,minWidth:240,minHeight:120,maxWidth:"92vw",maxHeight:"80vh",resize:"both",overflow:"hidden"},...S(),onPointerUp:I,"data-testid":"marker-popover",className:"z-50 flex flex-col rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-900",children:[f.jsxs("div",{className:"tl-modal-header",onPointerDown:B,children:[f.jsx("svg",{className:"tl-grip",width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:f.jsxs("g",{fill:"currentColor",children:[f.jsx("circle",{cx:"2",cy:"2",r:"1"}),f.jsx("circle",{cx:"8",cy:"2",r:"1"}),f.jsx("circle",{cx:"2",cy:"5",r:"1"}),f.jsx("circle",{cx:"8",cy:"5",r:"1"}),f.jsx("circle",{cx:"2",cy:"8",r:"1"}),f.jsx("circle",{cx:"8",cy:"8",r:"1"})]})}),f.jsx("span",{className:"tl-modal-title",children:C.length>1?`${C.length} events`:"Activity"}),f.jsx("button",{type:"button",className:"tl-modal-close",onPointerDown:z=>z.stopPropagation(),onClick:o,"aria-label":"Close",title:"Close",children:"✕"})]}),f.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-2",children:C.length===1?f.jsx(WO,{ev:C[0],usersById:n,prsById:r,onNavigate:l}):f.jsx("div",{className:"divide-y divide-gray-200 dark:divide-gray-800",children:C.map(z=>f.jsx("div",{className:"py-2 first:pt-0 last:pb-0",children:f.jsx(WO,{ev:z,usersById:n,prsById:r,onNavigate:l})},z.id))})})]})})}const $Ce=1e3*60*60,BCe={stack:!1,stackSubgroups:!0,groupHeightMode:"fixed",orientation:{axis:"top",item:"top"},zoomMin:$Ce,zoomMax:1e3*60*60*24*365*2,margin:{item:4,axis:8},tooltip:{followMouse:!0,overflowMethod:"flip",delay:150},verticalScroll:!0,horizontalScroll:!0,selectable:!0,multiselect:!1,maxHeight:"100%",xss:{disabled:!0}},UCe=12,HCe=2;function GO(e){return[...new Set(e)]}function VO(e,t){var s,a;if(!e)return 0;const n=e.body,r=t==null?void 0:t.querySelector(".vis-panel.vis-center");return((a=(s=n==null?void 0:n.domProps)==null?void 0:s.center)==null?void 0:a.width)||(r==null?void 0:r.clientWidth)||(t==null?void 0:t.clientWidth)||0}function Op(e){return Date.parse(String(e.start))}function zCe(e){return e.end!=null?Date.parse(String(e.end)):Op(e)}function YCe(e,t){if(t<=0)return;const n=UCe*t,r=new Map;for(const s of e){const a=`${String(s.group)}|${String(s.subgroup??"")}`,o=r.get(a);o?o.push(s):r.set(a,[s])}for(const s of r.values())if(s.length!==0){s.sort((a,o)=>Op(a)-Op(o));for(let a=0;a<s.length;a++){const o=s[a],l=Op(o),u=zCe(o),d=a+1<s.length?Op(s[a+1]):Number.POSITIVE_INFINITY,p=Math.min(Math.max(u,l+n),d);p!==u&&(o.end=new Date(p).toISOString())}}}function qO(e,t){const n=t.getTime()-e.getTime(),r=Math.max(n*.06,14400*1e3),s=Math.max(n*.03,7200*1e3);return{start:new Date(e.getTime()-s),end:new Date(t.getTime()+r)}}function WCe(e){const t=document.createElement("div");return t.innerHTML=e,t.firstElementChild??t}function GCe(){const e=typeof navigator<"u"?navigator.platform||navigator.userAgent:"";return/Mac|iP(hone|ad|od)/.test(e)?"metaKey":"ctrlKey"}function VCe(e){return e.actorId!=null?`repo:${e.repoId}:user:${e.actorId}`:`repo:${e.repoId}`}const qCe=/^repo:\d+:user:\d+$/;function Jd(e){return`tlg-${e.replace(/:/g,"-")}`}function KCe(e){return new Date(e.mergedAt??e.closedAt??new Date().toISOString()).getTime()}function KO({mode:e}={}){const t=(e==null?void 0:e.kind)==="isolate"?e.prId:null,n=D.useRef(null),r=D.useRef(null),s=D.useRef(new Eu),a=D.useRef(new Eu),o=D.useRef(new Map),l=D.useRef(new Map),u=D.useRef(new Map),d=D.useRef([]),p=D.useRef(null),m=D.useRef(new Map),g=D.useRef(new Map),y=D.useRef(new Map),_=D.useRef({active:!1,states:[]}),S=D.useRef(null),E=D.useRef(null),N=D.useRef(new Set),C=D.useRef(new Set),O=D.useRef(!1);if(!O.current){O.current=!0;try{const q=localStorage.getItem("pierre:collapsedRows");if(q){const ce=JSON.parse(q);Array.isArray(ce)&&(C.current=new Set(ce.map(String)))}}catch{}}const I=D.useRef(new Map),F=D.useRef(null),P=D.useRef(null),H=D.useRef(null),B=D.useRef(null),W=D.useRef(null),M=D.useRef(null),z=D.useRef(null),K=D.useRef(null),V=D.useRef(null),G=D.useRef(0),X=D.useRef(!1),pe=D.useRef(null),ye=D.useRef(null),Z=D.useRef(null),ee=D.useRef(null),j=D.useRef(null),J=D.useRef(null),he=D.useRef(null),[Y,Pe]=D.useState(null),se=D.useRef(null);se.current=Y;const[Re,ot]=D.useState(null),ft=D.useRef(new Map),[Ne,Se]=D.useState(!1),{data:_e,isLoading:tt,error:be}=eP(t!=null?{prIds:[t]}:void 0),{data:Ge}=tP(),{data:St}=ok(),{data:et}=lk(),{data:rn}=pl(),{data:cn}=Za(),{data:Zn}=ak(),Et=nn(),dn=Me(q=>q.derivedStates),Ni=Me(q=>q.userIds),aa=Me(q=>q.selectPr),kr=Me(q=>q.selectedPrId),Ci=D.useRef(kr),[Ee,Ve]=D.useState(0),[Nt,Ft]=D.useState(0),xt=Me(q=>q.preset),pr=Me(q=>q.customFrom),Ii=Me(q=>q.customTo),Rr=Me(q=>q.rangeResetSignal),Tr=D.useMemo(()=>{const q=new Map;for(const ce of rn??[])q.set(ce.id,ce);return q},[rn]),yi=D.useRef(Tr);yi.current=Tr;const jn=D.useMemo(()=>{const q=new Map;for(const ce of Zn??[])q.set(ce.repoId,new Set(ce.userIds));return q},[Zn]),Jn=D.useMemo(()=>ia(cn),[cn]);m.current=Jn;const xr=D.useRef(!1);D.useEffect(()=>{if(!_e)return;let q=!1;for(const ce of _e.events)if(ce.actorId!=null&&!Jn.has(ce.actorId)){q=!0;break}if(!q){for(const ce of _e.prs)if(ce.authorId!=null&&!Jn.has(ce.authorId)){q=!0;break}}if(!q){xr.current=!1;return}xr.current||(xr.current=!0,Et.invalidateQueries({queryKey:["users"]}))},[_e,Jn,Et]);const ds=D.useMemo(()=>{const q=new Map;for(const ce of(_e==null?void 0:_e.prs)??[])q.set(ce.id,ce);return q},[_e]);g.current=ds;const Fs=D.useCallback(q=>{const ce=s.current,me=S.current;if(me!=null&&me!==q){const Ie=ce.get(`pr:${me}`);Ie&&typeof Ie.className=="string"&&ce.update({id:`pr:${me}`,className:Ie.className.replace(/\s*pr-cross-linked/g,"")})}if(q!=null){const Ie=ce.get(`pr:${q}`);Ie&&typeof Ie.className=="string"&&!Ie.className.includes("pr-cross-linked")&&ce.update({id:`pr:${q}`,className:`${Ie.className} pr-cross-linked`})}S.current=q},[]),sr=D.useCallback(q=>{const ce=s.current,me=P.current;if(me!=null){const De=ce.get(me);De&&typeof De.className=="string"&&De.className.includes("ev-cross-linked")&&ce.update({id:me,className:De.className.replace(/\s*ev-cross-linked/g,"")}),P.current=null}if(F.current=q,q==null)return;const Ie=ce.get(`ev:${q}`)?`ev:${q}`:u.current.get(q)??null;if(Ie==null)return;const Oe=ce.get(Ie);Oe&&typeof Oe.className=="string"&&!Oe.className.includes("ev-cross-linked")&&(ce.update({id:Ie,className:`${Oe.className} ev-cross-linked`}),P.current=Ie)},[]),_r=D.useCallback(q=>{const ce=s.current;for(const Oe of ce.getIds()){const De=ce.get(Oe);De&&typeof De.className=="string"&&De.className.includes("ev-exit-glow")&&ce.update({id:Oe,className:De.className.replace(/\s*ev-exit-glow/g,"")})}if(B.current=null,H.current=q,q==null)return;const me=ce.get(`ev:${q}`)?`ev:${q}`:u.current.get(q)??null;if(me==null)return;const Ie=ce.get(me);Ie&&typeof Ie.className=="string"&&!Ie.className.includes("ev-exit-glow")&&(ce.update({id:me,className:`${Ie.className} ev-exit-glow`}),B.current=me)},[]),ii=D.useCallback(q=>{const ce=s.current;for(const Oe of ce.getIds()){const De=ce.get(Oe);De&&typeof De.className=="string"&&De.className.includes("ev-selected")&&ce.update({id:Oe,className:De.className.replace(/\s*ev-selected/g,"")})}if(he.current=null,J.current=q,q==null)return;const me=ce.get(`ev:${q}`)?`ev:${q}`:u.current.get(q)??null;if(me==null)return;const Ie=ce.get(me);Ie&&typeof Ie.className=="string"&&!Ie.className.includes("ev-selected")&&(ce.update({id:me,className:`${Ie.className} ev-selected`}),he.current=me)},[]),ae=D.useCallback(()=>{const q=s.current,ce=N.current,me=[],Ie=[],Oe=E.current!=null;for(const De of d.current){const st=String(De.id),ze=ce.has(String(De.group))||!Oe&&C.current.has(String(De.group)),Be=q.get(st)!=null;ze&&Be?me.push(st):!ze&&!Be&&Ie.push(De)}me.length&&q.remove(me),Ie.length&&q.add(Ie)},[]),fe=D.useCallback(()=>{try{localStorage.setItem("pierre:collapsedRows",JSON.stringify([...C.current]))}catch{}},[]),Xe=D.useCallback((q,ce)=>{var Be,_t;const me=a.current;if(!me.get(q))return;const Ie=s.current.get(),Oe=new Set;for(const Je of Ie)Je.group===q&&typeof Je.subgroup=="string"&&Oe.add(Je.subgroup);const De={};for(const Je of Oe)De[Je]=!ce;const st=me.get(q);st&&(me.remove(q),me.add({...st,subgroupVisibility:De,heightMode:ce?"auto":"fixed"})),ce?C.current.add(q):C.current.delete(q),fe(),ae();const ze=r.current;(_t=(Be=ze==null?void 0:ze.itemSet)==null?void 0:Be.markDirty)==null||_t.call(Be,{restackGroups:!0}),ze==null||ze.redraw()},[fe,ae]),Rt=D.useCallback(q=>{const ce=a.current.getIds().map(String).filter(Oe=>qCe.test(Oe)),me=q&&q.length?new Set(q):null,Ie=[];for(const Oe of ce){const De=me!=null&&!me.has(Oe);De?N.current.add(Oe):N.current.delete(Oe),Ie.push({id:Oe,visible:!De})}Ie.length&&a.current.update(Ie),E.current=me?q:null,ae()},[ae]),Ht=D.useCallback(()=>{const q=r.current,ce=n.current,me=p.current;if(!q||!ce||!me)return;const Ie=q.getWindow(),Oe=Ie.end.valueOf()-Ie.start.valueOf();K.current=Oe;const De=ce.clientWidth||1e3,st=Oe/De;let ze;if(X.current&&pe.current!=null)ze=me.events.filter(Ct=>Ct.prId===pe.current);else if(ze=me.events,_.current.active){const{states:Ct}=_.current;ze=ze.filter(pt=>pt.type==="review_comment"&&pt.prId!=null&&pt.derivedState!=null&&Ct.includes(pt.derivedState))}const{items:Be,clusterMembers:_t}=DCe(ze,VCe,m.current,g.current,y.current,st,8,{start:Ie.start.valueOf(),end:Ie.end.valueOf()});l.current=_t;const Je=new Map;for(const[Ct,pt]of _t)for(const zt of pt)Je.set(zt,Ct);u.current=Je;const vt=s.current.getIds().filter(Ct=>{const pt=String(Ct);return pt.startsWith("ev:")||pt.startsWith("cl:")||pt.startsWith("xsep:")});if(s.current.remove(vt),s.current.add(Be),d.current=Be.filter(Ct=>String(Ct.id).startsWith("xsep:")),ae(),F.current!=null){const Ct=F.current;P.current=null,F.current=null,sr(Ct)}if(H.current!=null){const Ct=H.current;B.current=null,H.current=null,_r(Ct)}if(J.current!=null){const Ct=J.current;he.current=null,J.current=null,ii(Ct)}},[sr,_r,ii,ae]),Zt=D.useCallback(()=>{const q=ye.current;if(!q)return;const ce=()=>{q.childElementCount&&q.replaceChildren(),q.style.display="none"},me=n.current,Ie=pe.current;if(!X.current||Ie==null||!me){ce();return}const Oe=me.querySelector(".vis-panel.vis-center"),De=g.current.get(Ie);if(!Oe||!De){ce();return}const st=Jd(fc(De)),ze=me.querySelector(`.vis-foreground .vis-group.${st} .vis-item.pr-bar.vis-selected`)??me.querySelector(`.vis-foreground .vis-group.${st} .vis-item.pr-bar:not(.pr-focus-hidden)`);if(!ze||ze.offsetHeight===0){ce();return}const _t=(q.parentElement??me).getBoundingClientRect(),Je=Oe.getBoundingClientRect();q.style.display="block",q.style.left=`${Je.left-_t.left}px`,q.style.top=`${Je.top-_t.top}px`,q.style.width=`${Je.width}px`,q.style.height=`${Je.height}px`;const vt=ze.getBoundingClientRect(),Ct=vt.top-Je.top,pt=vt.bottom-Je.top,zt=vt.left-Je.left,xn=vt.right-Je.left,fn="http://www.w3.org/2000/svg",ar=document.createDocumentFragment(),sn=me.querySelectorAll(".vis-foreground .vis-item.ev-cross");for(const On of sn){if(On.offsetHeight===0)continue;const yt=(On.querySelector(".ev-marker-inner, .ev-cluster-inner")??On).getBoundingClientRect(),Ri=yt.left+yt.width/2-Je.left,Yn=yt.top-Je.top,hn=yt.bottom-Je.top,ms=Math.max(zt,Math.min(Ri,xn));let si,Oi;if(Yn>=pt)si=Yn,Oi=pt;else if(hn<=Ct)si=hn,Oi=Ct;else continue;const Br=document.createElementNS(fn,"path");Br.setAttribute("d",`M ${Ri.toFixed(1)} ${si.toFixed(1)} L ${ms.toFixed(1)} ${Oi.toFixed(1)}`),ar.appendChild(Br)}q.replaceChildren(ar)},[]),Le=D.useCallback(()=>{var me;const q=X.current&&pe.current!=null,ce=(((me=ye.current)==null?void 0:me.childElementCount)??0)>0;!q&&!ce||Z.current==null&&(Z.current=requestAnimationFrame(()=>{Z.current=null,Zt()}))},[Zt]),nt=D.useCallback((q,ce)=>{const me=a.current;for(const[Be,_t]of I.current){if(!me.get(Be))continue;const Je={};for(const vt of _t)Je[vt]=!0;me.update({id:Be,subgroupVisibility:Je})}if(I.current.clear(),!q||q.length===0||ce==null)return;const Ie=y.current.get(ce),Oe=g.current.get(ce),De=s.current.get(`pr:${ce}`),st=Oe?fc(Oe):De&&typeof De.group=="string"?De.group:null,ze=s.current.get();for(const Be of q){const _t=new Set(["cross"]);Be===st&&Ie!=null&&(_t.add(`bar:${Ie}`),_t.add(`ev:${Ie}`));const Je=new Set;for(const pt of ze)pt.group===Be&&typeof pt.subgroup=="string"&&Je.add(pt.subgroup);const vt=[...Je].filter(pt=>!_t.has(pt)),Ct={};for(const pt of vt)Ct[pt]=!1;for(const pt of Je)_t.has(pt)&&(Ct[pt]=!0);Object.keys(Ct).length!==0&&(me.update({id:Be,subgroupVisibility:Ct}),vt.length&&I.current.set(Be,vt))}},[]),Ze=D.useCallback(q=>{const ce=s.current,me=[];for(const Ie of ce.getIds()){const Oe=String(Ie);if(!Oe.startsWith("pr:"))continue;const De=ce.get(Ie);if(!De||typeof De.className!="string")continue;const st=Number.parseInt(Oe.slice(3),10),ze=De.className.includes("pr-focus-hidden"),Be=q!=null&&st!==q;Be&&!ze?me.push({id:Ie,className:`${De.className} pr-focus-hidden`}):!Be&&ze&&me.push({id:Ie,className:De.className.replace(/\s*pr-focus-hidden/g,"")})}me.length&&ce.update(me)},[]),pn=D.useCallback(q=>{_r(null);const ce=X.current;nt((q==null?void 0:q.groupIds)??null,(q==null?void 0:q.prId)??null),Rt((q==null?void 0:q.groupIds)??null),Fs((q==null?void 0:q.prId)??null),sr((q==null?void 0:q.eventId)??null);const me=!!(q!=null&&q.groupIds&&q.groupIds.length>0);if(Se(me),me||(X.current=!1,pe.current=null),me&&(q==null?void 0:q.prId)!=null){const Ie=Me.getState();Ie.selectedPrId!==q.prId&&Ie.selectPr(q.prId)}if(!me&&ce&&(Ze(null),Ht()),!me&&C.current.size>0)for(const Ie of C.current)Xe(Ie,!0)},[nt,Rt,Fs,sr,_r,Ze,Ht,Xe]),Rn=D.useCallback(q=>{X.current||pn(q)},[pn]),$n=D.useCallback(()=>{const q=n.current;return q?q.querySelector(".vis-panel.vis-left.vis-vertical-scroll")??q.querySelector(".vis-panel.vis-right.vis-vertical-scroll"):null},[]),Bn=D.useCallback(()=>{const q=ee.current,ce=n.current;if(!q||!ce)return;const me=()=>{q.style.display!=="none"&&(q.style.display="none")},Ie=$n();if(!Ie){me();return}const De=(q.parentElement??ce).getBoundingClientRect(),st=Ie.getBoundingClientRect(),ze=st.top,Be=1;let _t=null;for(const zt of ce.querySelectorAll(".vis-labelset .vis-label.tl-repo-header")){const xn=zt.getBoundingClientRect();xn.height<1||xn.top<=ze+Be&&(_t=zt)}if(!_t){me();return}if(_t.getBoundingClientRect().top>=ze-Be){me();return}const Ct=((_t.querySelector(".vis-inner")??_t).textContent??"").trim();if(!Ct){me();return}const pt=[..._t.classList].find(zt=>zt.startsWith("tl-repo-tint-"))??"";q.dataset.repo!==Ct&&(q.textContent=Ct,q.dataset.repo=Ct),q.dataset.tint!==pt&&(q.className=`tl-repo-sticky${pt?` ${pt}`:""}`,q.dataset.tint=pt),q.style.left=`${st.left-De.left}px`,q.style.top=`${st.top-De.top}px`,q.style.width=`${st.width}px`,q.style.display!=="block"&&(q.style.display="block")},[$n]),cr=D.useCallback(()=>{j.current==null&&(j.current=requestAnimationFrame(()=>{j.current=null,Bn()}))},[Bn]),Gr=D.useCallback(()=>{const q=$n(),ce=n.current;if(!q||!ce)return null;const me=q.getBoundingClientRect().top;let Ie=null,Oe=0,De=1/0;for(const st of ce.querySelectorAll(".vis-labelset .vis-label")){const ze=st.getBoundingClientRect();if(ze.height<4||ze.bottom<=me+1)continue;const Be=[...st.classList].find(Je=>Je.startsWith("tlg-"));if(!Be)continue;const _t=Math.abs(ze.top-me);_t<De&&(De=_t,Ie=Be,Oe=ze.top-me)}return{token:Ie,offset:Oe,scrollTop:q.scrollTop}},[$n]),Un=D.useCallback((q,ce)=>{const me=r.current,Ie=p.current;if(!me||!Ie)return;const Oe=(ce==null?void 0:ce.pr)??g.current.get(q);if(!Oe)return;Pe(null);const De=Oe.repoId,st=new Set;Oe.authorId!=null&&st.add(Oe.authorId);let ze=1/0,Be=-1/0;const _t=vt=>{vt<ze&&(ze=vt),vt>Be&&(Be=vt)};_t(new Date(Oe.openedAt).getTime()),_t(KCe(Oe));for(const vt of Ie.events)vt.prId===q&&(vt.actorId!=null&&st.add(vt.actorId),_t(new Date(vt.occurredAt).getTime()));const Je=[...st].map(vt=>`repo:${De}:user:${vt}`);if((ce==null?void 0:ce.fitWindow)!==!1&&Number.isFinite(ze)&&Number.isFinite(Be)){const vt=Math.max((Be-ze)*.08,432e5);me.setWindow(ze-vt,Be+vt,{animation:!0})}X.current=!0,pe.current=q,pn({groupIds:Je.length?Je:null,prId:q,eventId:(ce==null?void 0:ce.anchorEventId)??null}),Ht(),Ze(q),me.setSelection([`pr:${q}`]),(ce==null?void 0:ce.anchorEventId)!=null&&sr(ce.anchorEventId)},[pn,Ht,Ze,sr]),Sr=D.useCallback(q=>{const ce=$n();if(!ce||r.current==null||!ce.isConnected)return;const me=Math.max(0,ce.scrollHeight-ce.clientHeight);ce.scrollTop=Math.max(0,Math.min(me,q)),ce.dispatchEvent(new Event("scroll"))},[$n]),Hn=D.useRef(!1),bi=D.useRef(0),fs=D.useCallback((q,ce,me=".ev-cross-linked",Ie=".pr-cross-linked")=>{const Oe=n.current,De=$n(),st=Oe==null?void 0:Oe.querySelector(".vis-panel.vis-center");if(!Oe||!De||!st)return;const ze=`.vis-labelset .vis-label.${q}`;let Be;const _t=fn=>{const ar=st.getBoundingClientRect(),sn=fn.getBoundingClientRect();return sn.top+sn.height/2-ar.top-ar.height/2},Je=()=>{const fn=On=>[...Oe.querySelectorAll(On)].filter(Ot=>Ot.offsetHeight>0).sort((Ot,yt)=>yt.offsetHeight-Ot.offsetHeight)[0];if(ce){const On=fn(me);if(On)return{delta:_t(On),settleable:!0};const Ot=Oe.querySelector(`.vis-foreground .vis-group.${q}`);if(Ot){const yt=st.getBoundingClientRect();return{delta:Ot.getBoundingClientRect().bottom-12-(yt.top+yt.height/2),settleable:!1}}return null}if(Be&&Be.isConnected&&Be.offsetHeight>0)return{delta:_t(Be),settleable:!0};const ar=fn(Ie);if(ar)return Be=ar,{delta:_t(ar),settleable:!0};const sn=Oe.querySelector(ze);return sn?{delta:_t(sn),settleable:!0}:null},vt=Oe.querySelector(ze);vt&&Sr(vt.offsetTop-8);let Ct=0,pt=0;const zt=++bi.current;Hn.current=!0,window.setTimeout(()=>{bi.current===zt&&(Hn.current=!1)},2500);const xn=()=>{if(bi.current!==zt)return;const fn=Je();fn!=null&&(Math.abs(fn.delta)>6?(Sr(De.scrollTop+fn.delta),pt=0):fn.settleable?pt+=1:pt=0),pt<6&&Ct++<90?requestAnimationFrame(xn):Hn.current=!1};requestAnimationFrame(()=>requestAnimationFrame(xn))},[$n,Sr]),hs=D.useCallback(q=>{const ce=n.current,me=()=>{var ze;const st=$n();if(!st||!ce)return!0;if(q.token){const Be=ce.querySelector(`.vis-labelset .vis-label.${q.token}`);if(Be&&Be.offsetHeight>0){const Je=Be.getBoundingClientRect().top-st.getBoundingClientRect().top-q.offset;return Math.abs(Je)>1?(Sr(st.scrollTop+Je),!1):!0}}return Sr(q.scrollTop),Math.abs((((ze=$n())==null?void 0:ze.scrollTop)??q.scrollTop)-q.scrollTop)<=2};me();let Ie=0,Oe=0;const De=()=>{me()?Oe+=1:Oe=0,Oe<3&&Ie++<30&&requestAnimationFrame(De)};requestAnimationFrame(De)},[$n,Sr]),Ai=D.useCallback((q,ce,me)=>{me.length!==0&&(E.current||pn(null),ot(null),Pe({x:q,y:ce,eventIds:me}))},[pn]),js=D.useCallback(()=>{Pe(null),E.current||pn(null)},[pn]),Aa=D.useCallback(()=>{se.current?js():E.current||(Ci.current!=null?Me.getState().clearSelection():H.current!=null&&_r(null))},[js,_r]),$r=D.useCallback(()=>{Pe(null)},[]);D.useEffect(()=>{ii(Y&&!Ne?Y.eventIds[0]??null:null)},[Y,Ne,ii]);const ps=(Y==null?void 0:Y.eventIds[0])??null;D.useEffect(()=>{if(ps==null)return;const q=o.current.get(ps);(q==null?void 0:q.prId)!=null&&Me.getState().selectPr(q.prId)},[ps]);const Ra=D.useCallback(q=>{const ce=yi.current.get(q.repoId),me=q.authorId!=null?m.current.get(q.authorId):void 0;return{id:q.id,number:q.number,title:q.title,repoFullName:(ce==null?void 0:ce.fullName)??`repo ${q.repoId}`,authorLogin:(me==null?void 0:me.githubLogin)??null,authorDisplayName:(me==null?void 0:me.displayName)??null,authorAvatarUrl:(me==null?void 0:me.avatarUrl)??null}},[]);D.useEffect(()=>{if(!n.current)return;const{from:q,to:ce}=mv(Me.getState()),{start:me,end:Ie}=qO(q,ce),Oe=new cSe(n.current,s.current,a.current,{...BCe,start:me,end:Ie,zoomKey:GCe()});Oe.on("click",Be=>{var xn,fn,ar;const _t=Be.item,Je=((xn=Be.event)==null?void 0:xn.srcEvent)??Be.event,vt=(Je==null?void 0:Je.clientX)??Be.pageX??0,Ct=(Je==null?void 0:Je.clientY)??Be.pageY??0,pt=(Je==null?void 0:Je.target)??null;if((fn=pt==null?void 0:pt.closest)!=null&&fn.call(pt,"[data-collapse-gid]")||(ar=pt==null?void 0:pt.closest)!=null&&ar.call(pt,"[data-stats-gid]"))return;if(_t==null){if(((Je==null?void 0:Je.detail)??0)>=2)return;Aa();return}const zt=String(_t);if(zt.startsWith("pr:"))se.current&&!X.current&&!E.current&&js(),aa(Number.parseInt(zt.slice(3),10));else if(zt.startsWith("ev:")){const sn=Number.parseInt(zt.slice(3),10);if(X.current){sr(sn),Ai(vt,Ct,[sn]);return}Ai(vt,Ct,[sn])}else if(zt.startsWith("cl:")){const sn=l.current.get(zt)??[];if(sn.length===0)return;const On=sn[0];if(X.current){sr(On),Ai(vt,Ct,sn);return}Ai(vt,Ct,sn)}}),Oe.on("doubleClick",Be=>{const _t=Be.item;if(_t==null||X.current)return;const Je=String(_t);if(Je.startsWith("pr:")){const vt=Number.parseInt(Je.slice(3),10),Ct=g.current.get(vt);Ct&&Wt.getState().openPrFocusTab(Ra(Ct));return}if(Je.startsWith("ev:")||Je.startsWith("cl:")){const Ct=(Je.startsWith("ev:")?[Number.parseInt(Je.slice(3),10)]:l.current.get(Je)??[])[0]??null;if(Ct==null)return;const pt=o.current.get(Ct);if((pt==null?void 0:pt.prId)==null)return;const zt=g.current.get(pt.prId);zt&&Wt.getState().openPrFocusTab(Ra(zt))}});let De=null,st=null;Oe.on("rangechanged",()=>{const Be=Oe.getWindow(),_t=Be.end.valueOf()-Be.start.valueOf(),Je=K.current;if(Je==null||Math.abs(_t-Je)/Je>.02){De&&clearTimeout(De);const xn=()=>{if(Hn.current){De=setTimeout(xn,120);return}De=null;const fn=Gr();Ht(),Oe.redraw(),fn&&hs(fn)};De=setTimeout(xn,120)}const Ct=z.current;if(Ct==null||X.current||E.current)return;const pt=Oe.getWindow(),zt=pt.end.valueOf()-pt.start.valueOf();Math.abs(zt-Ct)/Ct<=.02||(st&&clearTimeout(st),st=setTimeout(()=>Ft(xn=>xn+1),160))}),Oe.on("changed",Le);const ze=$n();return ze==null||ze.addEventListener("scroll",Le,{passive:!0}),Oe.on("changed",cr),ze==null||ze.addEventListener("scroll",cr,{passive:!0}),window.addEventListener("resize",cr,{passive:!0}),cr(),r.current=Oe,()=>{bi.current+=1,Hn.current=!1,De&&clearTimeout(De),st&&clearTimeout(st),ze==null||ze.removeEventListener("scroll",Le),ze==null||ze.removeEventListener("scroll",cr),window.removeEventListener("resize",cr),Z.current!=null&&(cancelAnimationFrame(Z.current),Z.current=null),j.current!=null&&(cancelAnimationFrame(j.current),j.current=null),Oe.destroy(),r.current=null}},[aa,Ht,Ai,Aa,js,sr,Ra,Gr,hs,Le,cr,$n]),D.useEffect(()=>{const q=n.current;if(!q)return;const ce=me=>{var Be;const Ie=me.target,Oe=(Be=Ie==null?void 0:Ie.closest)==null?void 0:Be.call(Ie,"[data-collapse-gid]");if(!Oe)return;const De=Oe.getAttribute("data-collapse-gid");if(!De||(me.stopPropagation(),me.preventDefault(),X.current||E.current))return;const st=!C.current.has(De);Xe(De,st),Oe.textContent=st?"▸":"▾";const ze=st?"Expand row":"Collapse row";Oe.setAttribute("title",ze),Oe.setAttribute("aria-label",ze)};return q.addEventListener("click",ce,!0),()=>q.removeEventListener("click",ce,!0)},[Xe]),D.useEffect(()=>{const q=n.current;if(!q)return;const ce=me=>{var ze;const Ie=me.target,Oe=(ze=Ie==null?void 0:Ie.closest)==null?void 0:ze.call(Ie,"[data-stats-gid]");if(!Oe)return;const De=Oe.getAttribute("data-stats-gid");if(!De)return;me.stopPropagation(),me.preventDefault();const st=Number(De.split(":user:")[1]);Number.isFinite(st)&&(Pe(null),ot(Be=>Be&&Be.gid===De?null:{gid:De,uid:st,x:me.clientX,y:me.clientY}))};return q.addEventListener("click",ce,!0),()=>q.removeEventListener("click",ce,!0)},[]),D.useEffect(()=>{const q=n.current;if(!q)return;const ce=me=>{const Ie=me.target;!Ie||!Ie.isConnected||Ie.closest(".vis-timeline")||Aa()};return q.addEventListener("click",ce),()=>q.removeEventListener("click",ce)},[Aa]);const zn=D.useCallback((q,ce)=>{V.current!=null&&(cancelAnimationFrame(V.current),V.current=null);const me=Be=>{const _t=r.current;if(!_t||Be<=0)return;const Je=_t.getWindow();YCe(q,(Je.end.valueOf()-Je.start.valueOf())/Be),s.current.update(q),G.current=Be,ce==null||ce()},Ie=VO(r.current,n.current);if(Ie>0&&Math.abs(Ie-G.current)<1){me(Ie);return}let Oe=-1,De=0,st=0;const ze=()=>{const Be=VO(r.current,n.current);if(Be>0&&Be===Oe?De+=1:(De=0,Oe=Be),Be>0&&De>=2||st++>40){V.current=null,me(Be);return}V.current=requestAnimationFrame(ze)};V.current=requestAnimationFrame(ze)},[]);D.useEffect(()=>()=>{V.current!=null&&cancelAnimationFrame(V.current)},[]),D.useEffect(()=>{let q=null;const ce=()=>{q&&clearTimeout(q),q=setTimeout(()=>Ft(me=>me+1),200)};return window.addEventListener("resize",ce),()=>{window.removeEventListener("resize",ce),q&&clearTimeout(q)}},[]);const no=D.useRef(!1);D.useEffect(()=>{const q=()=>{!document.hidden&&no.current&&(no.current=!1,Ft(ce=>ce+1))};return document.addEventListener("visibilitychange",q),()=>document.removeEventListener("visibilitychange",q)},[]),D.useEffect(()=>{var lt;if(!_e)return;if(p.current=_e,document.hidden){no.current=!0;return}no.current=!1;const q=W.current,ce=q&&!_e.prs.some(Ae=>Ae.id===q.id)?[..._e.prs,q]:_e.prs,me=Ni&&Ni.length>0?new Set(Ni):null,Ie=Ae=>!me||Ae.authorId!=null&&me.has(Ae.authorId),Oe=dn.length>0,De=new Set;if(Oe){const Ae=new Set(dn);for(const kt of _e.events)kt.type==="review_comment"&&kt.prId!=null&&kt.derivedState!=null&&Ae.has(kt.derivedState)&&De.add(kt.prId)}const st=Ae=>!Oe||De.has(Ae.id),ze=ce.filter(Ae=>Ae.id===t||Ae.id===Ci.current||Ae.id===(q==null?void 0:q.id)||Ie(Ae)&&st(Ae));_.current={active:Oe,states:dn};const Be=new Map;for(const Ae of _e.events)Be.set(Ae.id,Ae);o.current=Be;const _t=new Set;for(const Ae of _e.events)Ae.prId!=null&&(Ae.type==="review_comment"||Ae.type==="pr_comment")&&_t.add(Ae.prId);const Je=(lt=r.current)==null?void 0:lt.getWindow();z.current=Je?Je.end.valueOf()-Je.start.valueOf():null;const vt=MCe(ce);y.current=vt;const Ct=RSe(_e.events,ce);ft.current=Ct;let pt=_e.events;if(t==null&&!X.current&&Oe){const Ae=new Set(dn);pt=_e.events.filter(kt=>kt.type==="review_comment"&&kt.prId!=null&&kt.derivedState!=null&&Ae.has(kt.derivedState))}const zt=GO([...ze.map(Ae=>Ae.repoId),...pt.map(Ae=>Ae.repoId)]).sort((Ae,kt)=>{const _n=Tr.get(Ae),Cn=Tr.get(kt);return!_n||!Cn?(_n?0:1)-(Cn?0:1)||Ae-kt:_n.owner.localeCompare(Cn.owner)||_n.name.localeCompare(Cn.name)||Ae-kt}),xn=[],fn=0,ar=1e6;zt.forEach((Ae,kt)=>{const _n=GO([...pt.filter(mr=>mr.repoId===Ae&&mr.actorId!=null).map(mr=>mr.actorId),...ze.filter(mr=>mr.repoId===Ae&&mr.authorId!=null).map(mr=>mr.authorId)]),Cn=jn.get(Ae),oa=_n.map(mr=>`repo:${Ae}:user:${mr}`),la=`tl-repo-tint-${kt%HCe}`,gs=Tr.get(Ae),id=(gs==null?void 0:gs.fullName)??`repo ${Ae}`,sd=gs!=null&&gs.inboxWatch?`${Zr(id)}${E8()}`:Zr(id);xn.push({id:`repo:${Ae}`,content:sd,nestedGroups:oa.length?oa:void 0,treeLevel:1,order:kt,subgroupOrder:"sortKey",className:`tl-repo-header ${la}`}),_n.forEach((mr,ad)=>{const Bo=`repo:${Ae}:user:${mr}`,io=(Cn==null?void 0:Cn.has(mr))??!1;xn.push({id:Bo,content:WCe(PSe(Jn.get(mr),mr,Ct.get(mr),io,Bo,C.current.has(Bo))),treeLevel:2,order:(io?fn:ar)+ad,subgroupOrder:"sortKey",heightMode:C.current.has(Bo)?"auto":"fixed",className:`tl-user-row ${Jd(Bo)} ${la}`})})});const sn=X.current?pe.current:null,On=ze.map(Ae=>{const kt=Ae.authorId!=null?Jn.get(Ae.authorId):void 0,_n=fc(Ae),Cn=vt.get(Ae.id)??0,oa={author:{label:jr(kt,Ae.authorId),avatarUrl:(kt==null?void 0:kt.avatarUrl)??null},hasComments:_t.has(Ae.id)};return{id:`pr:${Ae.id}`,group:_n,subgroup:`bar:${Cn}`,sortKey:Cn*2,type:"range",start:Ae.openedAt,end:Ae.mergedAt??Ae.closedAt??new Date().toISOString(),content:NSe(Ae,oa),className:(()=>{const la=ISe(Ae,oa.hasComments);return sn!=null&&Ae.id!==sn?`${la} pr-focus-hidden`:la})(),title:CSe(Ae,oa)}}),Ot=r.current,yt=Ot==null?void 0:Ot.getWindow(),Ri=q?null:Gr(),Yn=Hn.current,hn=new Set(xn.map(Ae=>String(Ae.id)));a.current.update(xn);const ms=a.current.getIds().map(String).filter(Ae=>!hn.has(Ae));ms.length&&a.current.remove(ms);const si=new Set(On.map(Ae=>String(Ae.id))),Oi=s.current.getIds().map(String).filter(Ae=>Ae.startsWith("pr:")&&!si.has(Ae));if(s.current.update(On),Oi.length&&s.current.remove(Oi),zn(On,()=>{Ri&&!Hn.current&&!Yn&&hs(Ri)}),Ht(),Ot&&yt){const Ae=Ot.getWindow();(Ae.start.valueOf()!==yt.start.valueOf()||Ae.end.valueOf()!==yt.end.valueOf())&&Ot.setWindow(yt.start,yt.end,{animation:!1})}const Br=Ci.current;if(Br!=null&&Ot&&s.current.get(`pr:${Br}`)&&!Ot.getSelection().map(String).includes(`pr:${Br}`)&&Ot.setSelection([`pr:${Br}`]),S.current!=null){const Ae=S.current;S.current=null,Fs(Ae)}if(E.current&&Rt(E.current),X.current&&pe.current!=null&&Ze(pe.current),!E.current&&!X.current&&C.current.size>0)for(const Ae of C.current)Xe(Ae,!0);const Ke=W.current;(!Ke||_e.prs.some(Ae=>Ae.id===Ke.id)||Ci.current!==Ke.id&&pe.current!==Ke.id)&&(W.current=null),Ri&&!Hn.current&&hs(Ri)},[_e,dn,Ge,Ni,Tr,Jn,jn,Ee,Nt,Ht,Fs,Rt,Ze,Xe,Gr,hs,zn]),D.useEffect(()=>{Ci.current=kr;const q=r.current;if(!q)return;if(kr!=null&&!s.current.get(`pr:${kr}`)){Ve(Oe=>Oe+1);return}const ce=kr!=null?[`pr:${kr}`]:[],me=q.getSelection().map(String);me.length===ce.length&&ce.every(Oe=>me.includes(Oe))||q.setSelection(ce)},[kr]);const ro=D.useRef(!1);D.useEffect(()=>{if(t==null||ro.current||!r.current||!p.current)return;Me.getState().selectedPrId!==t&&Me.getState().selectPr(t);const ce=g.current.get(t)??(_e==null?void 0:_e.prs.find(st=>st.id===t))??(Ge==null?void 0:Ge.prs.find(st=>st.id===t))??(et==null?void 0:et.prs.find(st=>st.id===t));if(!ce)return;ro.current=!0,Un(t,{fitWindow:!0,pr:ce});const me=Jd(fc(ce)),Ie=Me.getState(),De=Ie.timelineFocusPr===t&&Ie.timelineFocusEvent!=null?null:window.setTimeout(()=>fs(me,!1),320);return()=>{De!=null&&window.clearTimeout(De)}},[t,_e,Ge,et,Un,fs]),D.useEffect(()=>{const q=r.current;if(!q||t!=null)return;const{from:ce,to:me}=mv(Me.getState()),{start:Ie,end:Oe}=qO(ce,me);q.setWindow(Ie,Oe,{animation:!1})},[xt,pr,Ii,Rr,t]);const bn=Me(q=>q.timelineCenterAt);D.useEffect(()=>{if(bn==null)return;const q=r.current;if(!q)return;const ce=q.getWindow(),me=ce.end.valueOf()-ce.start.valueOf();q.setWindow(bn-me/2,bn+me/2,{animation:!0}),Me.getState().consumeTimelineCenter()},[bn]);const Or=Me(q=>q.timelineFocusPr),Ue=Me(q=>q.timelineFocusAt);return D.useEffect(()=>{if(Or==null)return;const q=r.current;if(!q)return;const ce=_e==null?void 0:_e.prs.find(De=>De.id===Or);if(ce){const De=Me.getState().timelineFocusEvent;if(De&&_e){const Je=_e.events.filter(zt=>zt.prId===Or&&zt.type===De.type&&(De.refId==null||zt.refId===De.refId)),vt=Ue!=null&&Je.find(zt=>zt.occurredAt===Ue)||Je[0],Ct=(vt==null?void 0:vt.actorId)??ce.authorId,pt=vt!=null&&(s.current.get(`ev:${vt.id}`)!=null||u.current.get(vt.id)!=null);if(Ue){const zt=Date.parse(Ue),xn=q.getWindow(),fn=xn.end.valueOf()-xn.start.valueOf();q.setWindow(zt-fn/2,zt+fn/2,{animation:!0})}if(q.setSelection([`pr:${Or}`]),vt!=null&&sr(vt.id),Ct!=null){const zt=Jd(`repo:${ce.repoId}:user:${Ct}`);window.setTimeout(()=>fs(zt,pt),120)}Me.getState().consumeTimelineFocus();return}const st=q.getWindow(),ze=st.end.valueOf()-st.start.valueOf();let Be;if(Ue)Be=Date.parse(Ue);else{const Je=new Date(ce.openedAt).getTime(),vt=new Date(ce.mergedAt??ce.closedAt??new Date().toISOString()).getTime();Be=(Je+vt)/2}q.setWindow(Be-ze/2,Be+ze/2,{animation:!0}),q.setSelection([`pr:${Or}`]);const _t=Jd(fc(ce));window.setTimeout(()=>{fs(_t,!1,".ev-cross-linked",".pr-bar.vis-selected")},120),Me.getState().consumeTimelineFocus();return}const me=De=>{W.current=De,Ve(ze=>ze+1);const st=Jd(fc(De));M.current!=null&&window.clearTimeout(M.current),M.current=window.setTimeout(()=>{M.current=null,q.setSelection([`pr:${De.id}`]),fs(st,!1,".ev-cross-linked",".pr-bar.vis-selected")},360),Me.getState().consumeTimelineFocus()},Ie=_e&&!_e.prs.some(De=>De.id===Or)?St==null?void 0:St.prs.find(De=>De.id===Or):void 0;if(Ie){me(Ie);return}const Oe=(Ge==null?void 0:Ge.prs.find(De=>De.id===Or))??(et==null?void 0:et.prs.find(De=>De.id===Or));if(Oe){const{from:De}=mv(Me.getState()),st=new Date(Oe.openedAt).getTime();if(st<De.getTime()){const ze=new Date(st-864e5).toISOString().slice(0,10),Be=new Date().toISOString().slice(0,10);Me.getState().setCustomRange(ze,Be);return}if(_e&&!_e.prs.some(ze=>ze.id===Oe.id)){me(Oe);return}}Me.getState().consumeTimelineFocus()},[Or,Ue,_e,Ge,St,et,fs,sr]),f.jsxs("div",{className:`relative h-full w-full${Ne?" tl-focus-active":""}`,children:[tt&&!_e&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-gray-500",children:"Loading timeline…"}),be&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-red-500",children:String(be)}),_e&&_e.prs.length===0&&_e.events.length===0&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-gray-500",children:"No activity in this window. Add a repo or widen the date range."}),f.jsx("div",{ref:n,className:"h-full w-full"}),f.jsx("svg",{ref:ye,className:"tl-cross-connectors","aria-hidden":"true",style:{display:"none"}}),f.jsx("div",{ref:ee,className:"tl-repo-sticky","aria-hidden":"true",style:{display:"none"}}),Y&&f.jsx(jCe,{state:Y,eventsById:o.current,usersById:Jn,prsById:ds,focusPrId:Ne?pe.current:null,onContextFocus:Rn,onDismiss:js,onNavigate:$r}),Re&&f.jsx(pCe,{gid:Re.gid,uid:Re.uid,user:Jn.get(Re.uid),stats:ft.current.get(Re.uid)??{comments:0,reviews:0,prsOpen:0,prsMerged:0,prsClosed:0},x:Re.x,y:Re.y,onDismiss:()=>ot(null)})]})}const Iv=rk;function QCe(e){return Iv.reduce((t,n)=>t+e[n],0)}function JT({counts:e,compact:t=!1,activeState:n=null,onSegmentClick:r,className:s=""}){const a=QCe(e);return t?f.jsx("span",{className:`inline-flex h-1.5 w-16 overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700 ${s}`,"aria-hidden":"true",children:a>0&&Iv.map(o=>e[o]>0?f.jsx("span",{style:{width:`${e[o]/a*100}%`,background:ei[o].color}},o):null)}):f.jsxs("div",{className:s,children:[f.jsx("div",{className:"flex h-2.5 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",children:a===0?null:Iv.map(o=>{if(e[o]===0)return null;const l=ei[o],u=f.jsx("span",{title:`${l.label}: ${e[o]}`,style:{width:`${e[o]/a*100}%`,background:l.color,opacity:n==null||n===o?1:.35},className:"block h-full"},o);return r?f.jsx("button",{type:"button",onClick:()=>r(o),title:`${l.label}: ${e[o]} — click to filter`,style:{width:`${e[o]/a*100}%`,background:l.color,opacity:n==null||n===o?1:.35},className:"block h-full transition-opacity hover:opacity-100","aria-pressed":n===o},o):u})}),f.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-0.5",children:[Iv.map(o=>{const l=ei[o],u=n===o,d=n!=null&&!u,p=f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{background:l.color}}),f.jsx("span",{className:"tabular-nums",children:e[o]}),f.jsx("span",{children:l.label.toLowerCase()})]}),m=`flex items-center gap-1 text-[10px] ${d?"text-gray-400 opacity-60":"text-gray-600 dark:text-gray-300"}`;return r?f.jsx("button",{type:"button",onClick:()=>r(o),className:`${m} hover:underline`,"aria-pressed":u,title:l.description,children:p},o):f.jsx("span",{className:m,title:l.description,children:p},o)}),f.jsx("span",{className:"ml-auto text-[10px] tabular-nums text-gray-400",children:a})]})]})}function eS(e){return gn({queryKey:["ai-usage"],queryFn:()=>it.aiUsage(),enabled:e,staleTime:3e4})}function XCe(e){return e&&e.length>0?`repoIds=${e.join(",")}`:""}function ZCe(e,t){const n=XCe(e);return gn({queryKey:["repo-digests",n],queryFn:()=>it.repoDigests(n),enabled:t,staleTime:1/0})}function JCe(e,t){return gn({queryKey:["repo-digest",e],queryFn:()=>it.repoDigest(e),enabled:t&&e!=null,staleTime:1/0})}function eIe(e,t){e.setQueriesData({queryKey:["repo-digests"]},n=>{if(!n)return n;const r=n.digests.findIndex(a=>a.repoId===t.repoId);if(r===-1)return n;const s=n.digests.slice();return s[r]=t,{...n,digests:s}})}const tIe=5e3;function Y6(e){return!e||e.total<=0?{value:null}:{value:e.completed/e.total*100,sub:`${e.completed}/${e.total}`}}function W6(){const e=nn(),[t,n]=D.useState(!1),[r,s]=D.useState(()=>new Set),[a,o]=D.useState(null),[l,u]=D.useState(null),d=D.useRef(null);return D.useEffect(()=>()=>{var m;return(m=d.current)==null?void 0:m.abort()},[]),D.useEffect(()=>{if(l==null)return;const m=window.setTimeout(()=>u(null),tIe);return()=>window.clearTimeout(m)},[l]),{mutate:D.useCallback(m=>{var F;(F=d.current)==null||F.abort();const g=new AbortController;d.current=g,n(!0),u(null),s(new Set),o(null);const y=P=>s(H=>{if(!H.has(P))return H;const B=new Set(H);return B.delete(P),B}),_=m==null?void 0:Array.isArray(m)?m.length>0?`repoIds=${m.join(",")}`:void 0:`repoIds=${m}`,S=`/api/pro/activity/digests/refresh/stream${_?`?${_}`:""}`;let E=!1,N=!1,C=[],O=0,I=0;$y(S,{method:"POST",signal:g.signal,onEvent:P=>{switch(P.type){case"start":P.throttled&&(E=!0),P.creditsExhausted&&(N=!0);break;case"plan":C=P.toRegenerate,O=C.length,s(new Set(C)),o({completed:0,total:O});break;case"repo":I+=1,o({completed:I,total:O}),e.setQueryData(["repo-digest",P.digest.repoId],P.digest),eIe(e,P.digest),y(P.digest.repoId);break;case"error":I+=1,o({completed:I,total:O}),y(P.repoId);break}}}).catch(()=>{}).finally(()=>{if(d.current===g){d.current=null,n(!1),s(new Set),o(null),u(N?"Out of AI credits this month — summaries resume on the 1st.":E?"Refreshed moments ago — showing the latest. Try again shortly.":O===0?"Already up to date — no new activity since the last digest.":null),e.invalidateQueries({queryKey:["ai-usage"]});for(const P of C)e.invalidateQueries({queryKey:["repo-digest",P]});C.length>0&&e.invalidateQueries({queryKey:["repo-digests"]})}})},[e]),isPending:t,refreshingRepoIds:r,progress:a,notice:l}}function nIe(e){return{id:e.prId,number:e.prNumber,title:e.title??`#${e.prNumber}`,repoFullName:e.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null}}function G6(){const e=Wt(t=>t.openPrDetailTab);return t=>{t.prId!=null&&e(nIe(t),{fromActivity:!0})}}const V6="pierre:collapsedDigests";function rIe(){try{const e=localStorage.getItem(V6),t=e?JSON.parse(e):[];return new Set(Array.isArray(t)?t.filter(n=>typeof n=="number"):[])}catch{return new Set}}function iIe(e){try{localStorage.setItem(V6,JSON.stringify([...e]))}catch{}}const QO=Sm((e,t)=>({collapsed:rIe(),toggle:n=>{const r=new Set(t().collapsed);r.has(n)?r.delete(n):r.add(n),iIe(r),e({collapsed:r})}})),q6="pierre:insightsDigestsExpanded";function sIe(){try{const e=localStorage.getItem(q6),t=e?JSON.parse(e):[];return new Set(Array.isArray(t)?t.filter(n=>typeof n=="number"):[])}catch{return new Set}}const XO=Sm((e,t)=>({expanded:sIe(),toggle:n=>{const r=new Set(t().expanded);r.has(n)?r.delete(n):r.add(n);try{localStorage.setItem(q6,JSON.stringify([...r]))}catch{}e({expanded:r})}})),K6="pierre:sprintReportUi";function aIe(){const e={collapsed:!1,reposOpen:!1};try{const t=localStorage.getItem(K6);if(!t)return e;const n=JSON.parse(t);if(n==null||typeof n!="object")return e;const r=n;return{collapsed:typeof r.collapsed=="boolean"?r.collapsed:!1,reposOpen:typeof r.reposOpen=="boolean"?r.reposOpen:!1}}catch{return e}}const uv=Sm((e,t)=>{const n=()=>{try{const{collapsed:r,reposOpen:s}=t();localStorage.setItem(K6,JSON.stringify({collapsed:r,reposOpen:s}))}catch{}};return{...aIe(),setCollapsed:r=>{e({collapsed:r}),n()},setReposOpen:r=>{e({reposOpen:r}),n()}}});function oIe(e){const t=new Map,n=new Map;for(const r of e)r.prId!=null&&(t.set(`${r.repoFullName}#${r.prNumber}`,r),n.has(r.prNumber)||n.set(r.prNumber,r));return{byKey:t,byNumber:n}}const tS=/([A-Za-z0-9][\w.-]*\/[A-Za-z0-9][\w.-]*)#(\d+)|#(\d+)/.source;function Q6(e,t){const n=e[1]!=null,r=Number(n?e[2]:e[3]);return n?t.byKey.get(`${e[1]}#${r}`)??t.byNumber.get(r):t.byNumber.get(r)}function ZO(e,t,n,r=""){const s=[];let a=0,o=0;const l=new RegExp(tS,"g");let u;for(;(u=l.exec(e))!=null;){u.index>a&&s.push(e.slice(a,u.index));const d=u[1]!=null,p=Number(d?u[2]:u[3]),m=d?t.byKey.get(`${u[1]}#${p}`)??t.byNumber.get(p):t.byNumber.get(p);if(m!=null){const g=`${m.repoFullName}#${m.prNumber}`;s.push(f.jsx("button",{type:"button",onClick:()=>n(m),className:"font-semibold text-sky-600 hover:underline dark:text-sky-400",title:m.title??g,children:g},`${r}r${o++}`))}else s.push(u[0]);a=u.index+u[0].length}return a<e.length&&s.push(e.slice(a)),s}function Dp(e,t,n){return e.split(/(\*\*[^*]+\*\*)/g).flatMap((s,a)=>{const o=/^\*\*([^*]+)\*\*$/.exec(s);return o!=null?[f.jsx("strong",{children:ZO(o[1]??"",t,n,`b${a}-`)},`b${a}`)]:ZO(s,t,n,`t${a}-`)})}const JO=e=>{const t=e.additions+e.deletions,n=e.openedAt?Math.max(0,(Date.now()-Date.parse(e.openedAt))/36e5):0;return t*n},eD=(e,t)=>JO(t)-JO(e);function lIe(e,t){const n=[],r=new Set,s=new RegExp(tS,"g");let a;for(;(a=s.exec(e))!=null;){const o=Q6(a,t);if((o==null?void 0:o.prId)!=null){const l=`${o.repoFullName}#${o.prNumber}`;r.has(l)||(r.add(l),n.push(o))}}return n}function uIe(e,t){const n=e.replace(new RegExp(tS,"g"),(r,...s)=>{const a=s.slice(0,3),o=Q6([r,...a],t);return(o==null?void 0:o.prId)!=null?"":r}).replace(/\s{2,}/g," ").replace(/^[\s:,.\-–—·•]+/,"").trim();return/^[a-z]/.test(n)?n[0].toUpperCase()+n.slice(1):n}function cIe(e,t){const n=e.split(`
|
|
1389
1389
|
`).map(l=>l.replace(/`/g,"").trim()).filter(l=>l!==""&&!/^[-–—*_]{3,}$/.test(l)),r=[];let s=[],a=!1;const o=()=>{s.length!==0&&(s.sort((l,u)=>eD(l.prs[0],u.prs[0])),r.push({kind:"prtable",groups:s}),s=[])};for(const l of n){const u=/^#{1,6}\s+(.*)$/.exec(l),d=l.replace(/^[-*]\s+/,"");if(!a){a=!0,r.push({kind:"headline",text:u?u[1]??"":d});continue}const p=lIe(l,t);if(p.length>0){p.sort(eD),s.push({prs:p,summary:uIe(d,t)});continue}const m=/^\*\*(.+)\*\*$/.exec(d);o(),u?r.push({kind:"header",text:u[1]}):m?r.push({kind:"subhead",text:m[1]}):r.push({kind:"prose",text:d})}return o(),r}function dIe({groups:e,onOpenPr:t,usersById:n,index:r}){return f.jsx("div",{className:"overflow-x-auto",children:f.jsxs("table",{className:"w-full min-w-[820px] table-fixed border-collapse text-[12px]",children:[f.jsxs("colgroup",{children:[f.jsx("col",{style:{width:"320px"}}),f.jsx("col",{style:{width:"24px"}}),f.jsx("col",{style:{width:"84px"}}),f.jsx("col",{style:{width:"110px"}}),f.jsx("col",{style:{width:"72px"}}),f.jsx("col",{})]}),f.jsx("thead",{children:f.jsxs("tr",{className:"text-left text-[9px] font-semibold uppercase tracking-wide text-gray-400",children:[f.jsx("th",{className:"pb-1 pr-2 font-semibold",children:"Pull request"}),f.jsx("th",{className:"pb-1 pr-2 font-semibold",children:"CI"}),f.jsx("th",{className:"pb-1 pr-2 font-semibold",children:"Age"}),f.jsx("th",{className:"pb-1 pr-2 font-semibold",children:"Author"}),f.jsx("th",{className:"pb-1 pr-2 font-semibold",children:"Diff"}),f.jsx("th",{className:"pb-1 font-semibold",children:"Summary"})]})}),f.jsx("tbody",{children:e.map((s,a)=>s.prs.map((o,l)=>{const u=o.ciStatus?ml[o.ciStatus]:null,d=o.authorId!=null?n.get(o.authorId):void 0;return f.jsxs("tr",{className:"border-t border-gray-100 align-top dark:border-gray-800/60",children:[f.jsx("td",{className:"py-1 pr-2",children:f.jsxs("button",{type:"button",onClick:()=>t(o),className:"block text-left leading-snug hover:underline",title:`${o.repoFullName}#${o.prNumber}${o.title?` — ${o.title}`:""}`,children:[f.jsxs("span",{className:"font-semibold text-sky-600 dark:text-sky-400",children:["#",o.prNumber]})," ",f.jsx("span",{className:"text-gray-700 dark:text-gray-200",children:o.title??""})]})}),f.jsx("td",{className:"py-1 pr-2",children:f.jsx("span",{className:"inline-flex items-center gap-1 text-[11px] text-gray-500 dark:text-gray-400",title:(u==null?void 0:u.label)??"no checks",children:f.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:u?{background:u.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"},"aria-hidden":!0})})}),f.jsx("td",{className:"whitespace-nowrap py-1 pr-2 text-[11px] text-gray-500 dark:text-gray-400",children:o.openedAt?Yr(o.openedAt):"—"}),f.jsx("td",{className:"overflow-hidden py-1 pr-2",children:f.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-[11px] text-gray-600 dark:text-gray-300",children:[f.jsx("span",{className:"shrink-0",children:f.jsx(mi,{user:d,size:13})}),f.jsx("span",{className:"min-w-0 truncate",children:d?f.jsx(wa,{user:d,fallbackId:o.authorId??0}):o.authorLogin??"—"})]})}),f.jsxs("td",{className:"whitespace-nowrap py-1 pr-2 text-[11px]",children:[f.jsxs("span",{className:"font-mono text-green-600 dark:text-green-400",children:["+",o.additions]})," ",f.jsxs("span",{className:"font-mono text-red-500 dark:text-red-400",children:["−",o.deletions]})]}),l===0&&f.jsx("td",{rowSpan:s.prs.length,className:"py-1 align-top text-[12px] leading-relaxed text-gray-700 dark:text-gray-200",children:s.summary?Dp(s.summary,r,t):null})]},`${a}-${o.prId}`)}))})]})})}function X6({markdown:e,prRefs:t,onOpenPr:n}){const{data:r}=Za(),s=D.useMemo(()=>ia(r),[r]),a=D.useMemo(()=>oIe(t),[t]),o=D.useMemo(()=>cIe(e,a),[e,a]),l=u=>u;return f.jsx("div",{className:"space-y-1.5",children:o.map((u,d)=>u.kind==="prtable"?f.jsx(dIe,{groups:u.groups,onOpenPr:n,usersById:s,index:a},d):u.kind==="headline"?f.jsx("div",{className:"border-l-2 border-violet-400 pl-2 text-[13px] font-semibold leading-relaxed text-gray-800 dark:border-violet-500 dark:text-gray-100",children:l(Dp(u.text??"",a,n))},d):u.kind==="header"?f.jsx("div",{className:"pt-1 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:l(Dp(u.text??"",a,n))},d):u.kind==="subhead"?f.jsx("div",{className:"pt-1.5 text-[12px] font-semibold text-gray-700 dark:text-gray-200",children:l(Dp(u.text??"",a,n))},d):f.jsxs("div",{className:"flex gap-1.5 text-[13px] leading-relaxed text-gray-700 dark:text-gray-200",children:[f.jsx("span",{"aria-hidden":"true",className:"select-none text-gray-400",children:"•"}),f.jsx("span",{className:"min-w-0",children:l(Dp(u.text??"",a,n))})]},d))})}function fIe({markdown:e,prRefs:t,onOpenPr:n}){return f.jsx(X6,{markdown:e,prRefs:t,onOpenPr:n})}function hIe(e){if(!e)return"Haiku";const t=e.toLowerCase();return t.includes("haiku")?"Haiku":t.includes("sonnet")?"Sonnet":t.includes("opus")?"Opus":e}function Z6({digest:e,isLoading:t,title:n,collapsed:r,onToggle:s,onRegenerate:a,regenerating:o=!1,onOpenPr:l,showProBadge:u=!0,outOfCredits:d=!1}){return f.jsxs("div",{className:"rounded-md border border-violet-200 bg-violet-50/60 px-3 py-2 dark:border-violet-900/50 dark:bg-violet-950/20",children:[f.jsxs("div",{onClick:s,className:"-mx-1 flex cursor-pointer select-none items-center gap-2 rounded px-1 hover:bg-violet-500/5",children:[f.jsxs("button",{type:"button",onClick:p=>{p.stopPropagation(),s()},"aria-expanded":!r,className:"flex min-w-0 items-center gap-1 text-[11px] font-semibold uppercase tracking-wide text-violet-600 hover:text-violet-700 dark:text-violet-300 dark:hover:text-violet-200",title:r?"Expand digest":"Collapse digest",children:[f.jsx("span",{"aria-hidden":"true",className:"text-[9px]",children:r?"▸":"▾"}),f.jsx("span",{"aria-hidden":"true",children:"✨"}),f.jsx("span",{className:"truncate normal-case",children:n})]}),u&&f.jsx("span",{className:"shrink-0 rounded bg-violet-500/15 px-1 text-[10px] font-semibold text-violet-600 dark:text-violet-300",children:"Pro"}),f.jsxs("span",{className:"ml-auto flex items-center gap-2 text-[10px] text-gray-400",children:[e!=null&&f.jsxs("span",{title:e.model,children:[hIe(e.model)," · ",Yr(e.generatedAt),e.stale?" · stale":""]}),a!=null&&f.jsxs("button",{type:"button",onClick:p=>{p.stopPropagation(),a==null||a()},disabled:o||d,className:"flex items-center gap-0.5 rounded border border-violet-300 px-1.5 py-0.5 font-medium text-violet-600 hover:border-violet-400 disabled:opacity-50 dark:border-violet-800 dark:text-violet-300 dark:hover:border-violet-600",title:d?"Out of AI credits — resets next month":e==null?"Generate this repo's digest (runs the cheap-tier model)":"Regenerate this repo's digest (runs the cheap-tier model)",children:[f.jsx("span",{"aria-hidden":"true",children:"↻"}),d?"Out of credits":o?e==null?"Generating…":"Regenerating…":e==null?"Generate":"Regenerate"]})]})]}),!r&&f.jsx("div",{className:"mt-1",children:o?f.jsx(pIe,{}):t?f.jsx("div",{className:"h-3 w-2/3 animate-pulse rounded bg-violet-200/60 dark:bg-violet-900/40"}):e!=null&&e.summary.trim()!==""?f.jsx("div",{className:"digest-fade-in",children:f.jsx(fIe,{markdown:e.summary,prRefs:e.prRefs,onOpenPr:l})},e.generatedAt):f.jsx("p",{className:"text-xs text-gray-400",children:"No digest yet — click Generate to summarise this repo's recent activity."})})]})}function pIe(){return f.jsx("div",{className:"space-y-1.5 py-0.5","aria-hidden":"true",children:["92%","80%","66%","74%"].map((e,t)=>f.jsx("div",{className:"digest-skeleton-line h-3",style:{width:e}},t))})}function mIe({repoId:e}){var m,g;const{activityDigest:t}=zi(),{data:n,isLoading:r}=JCe(e,t),s=W6(),a=G6(),o=eS(t),l=((m=o.data)==null?void 0:m.allowanceCredits)!=null&&(o.data.remainingCredits??0)<=0,u=QO(y=>y.collapsed.has(e)),d=QO(y=>y.toggle),p=s.refreshingRepoIds.has(e);return t?f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(Z6,{digest:n,isLoading:r,title:"Digest",collapsed:u,onToggle:()=>d(e),onRegenerate:n==null||n.stale?()=>s.mutate(e):void 0,regenerating:p,onOpenPr:a,outOfCredits:l}),f.jsx(Fm,{active:s.isPending&&(((g=s.progress)==null?void 0:g.total)??0)>0,label:"Regenerating digest",...Y6(s.progress)}),s.notice!=null&&f.jsx("p",{className:"px-0.5 text-[11px] text-gray-400","aria-live":"polite",children:s.notice})]}):null}function gIe({stats:e}){return f.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-gray-500 dark:text-gray-400",children:[f.jsxs("span",{children:[f.jsx("span",{className:"font-semibold text-gray-700 dark:text-gray-200 tabular-nums",children:e.openPrs})," ","open"]}),f.jsxs("span",{children:[f.jsx("span",{className:"tabular-nums",children:e.draftPrs})," draft"]}),e.stalledPrs>0&&f.jsxs("span",{className:"text-amber-500",children:[f.jsx("span",{className:"tabular-nums",children:e.stalledPrs})," stalled ⏱"]}),e.medianHoursToFirstReview!=null&&f.jsxs("span",{title:"Median hours to first review",children:["TTFR"," ",f.jsx("span",{className:"tabular-nums",children:e.medianHoursToFirstReview<1?`${Math.round(e.medianHoursToFirstReview*60)}m`:`${Math.round(e.medianHoursToFirstReview)}h`})]}),e.oldestUnreviewed!=null&&f.jsxs("a",{href:e.oldestUnreviewed.githubUrl,target:"_blank",rel:"noreferrer noopener",className:"hover:underline",title:e.oldestUnreviewed.title,children:["oldest unreviewed #",e.oldestUnreviewed.number," ·"," ",Yr(e.oldestUnreviewed.openedAt)]})]})}function vIe({repo:e}){const t=e.maintainerIds.length;return f.jsxs("div",{className:"space-y-2 rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"min-w-0 truncate text-base font-semibold text-gray-800 dark:text-gray-100",children:e.repoFullName}),t>0&&f.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 text-[11px] text-gray-400",title:`${t} maintainer${t===1?"":"s"} (have merged here)`,children:[f.jsx(Lk,{}),t]}),e.attentionCount>0&&f.jsxs("span",{className:"shrink-0 rounded bg-amber-500/15 px-1 text-[10px] font-semibold text-amber-600 dark:text-amber-400",title:"PRs needing attention (your turn · stalled · untouched threads)",children:["⚠ ",e.attentionCount]}),f.jsx("span",{className:"ml-auto shrink-0 text-[11px] tabular-nums text-gray-400",children:e.stats.openPrs>0?`[${e.stats.openPrs}]`:"[—]"})]}),f.jsx(gIe,{stats:e.stats}),f.jsx(JT,{counts:e.threadTotals}),f.jsx(mIe,{repoId:e.repoId})]})}function dg(){const e=D.useRef(null),[t,n]=D.useState(0);return D.useEffect(()=>{const r=e.current;if(!r)return;const s=new ResizeObserver(a=>{var l;const o=(l=a[0])==null?void 0:l.contentRect.width;o!=null&&n(o)});return s.observe(r),n(r.clientWidth),()=>s.disconnect()},[]),[e,t]}const on={blue:"#3b82f6",green:"#22c55e",gray:"#9ca3af",orange:"#f97316",amber:"#f59e0b",purple:"#8957e5",red:"#ef4444",teal:"#14b8a6",pink:"#ec4899",slate:"#64748b"},tD=[on.blue,on.green,on.amber,on.purple,on.teal,on.pink,on.slate];function _a(e){if(e<=0)return"0h";if(e<1)return`${Math.round(e*60)}m`;if(e<48)return`${e%1===0?e:e.toFixed(1)}h`;const t=e/24;return`${t<10?t.toFixed(1):Math.round(t)}d`}function Dc(e){return new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function Wc(e){return Math.abs(e)>=1e3?`${(e/1e3).toFixed(e%1e3===0?0:1)}k`:`${Math.round(e)}`}function nS(e){if(e<=0)return 1;const t=Math.floor(Math.log10(e)),n=Math.pow(10,t),r=e/n;return(r<=1?1:r<=2?2:r<=5?5:10)*n}function xb({series:e}){return f.jsx("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-0.5",children:e.map(t=>f.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-500 dark:text-gray-400",children:[f.jsx("span",{className:"inline-block h-2 w-2 rounded-[2px]",style:{background:t.color}}),t.label]},t.label))})}function fg({x:e,y:t,width:n,children:r}){const s=Math.max(58,Math.min(e,Math.max(58,n-58)));return f.jsx("div",{className:"pointer-events-none absolute z-20 -translate-x-1/2 -translate-y-full whitespace-nowrap rounded-md border border-gray-200 bg-white/95 px-2 py-1 text-[10px] leading-tight text-gray-700 shadow-md dark:border-gray-700 dark:bg-gray-900/95 dark:text-gray-200",style:{left:s,top:Math.max(t-6,0)},children:r})}function Ti({title:e,note:t,children:n}){return f.jsxs("div",{className:"rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[f.jsxs("div",{className:"mb-1 flex items-baseline justify-between gap-2",children:[f.jsx("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-200",children:e}),t&&f.jsx("span",{className:"text-[10px] text-gray-400",children:t})]}),n]})}function fi({label:e="No data in this window"}){return f.jsx("div",{className:"flex h-[120px] items-center justify-center rounded-md border border-dashed border-gray-200 text-[10px] text-gray-400 dark:border-gray-800",children:e})}function xf({labels:e,series:t,area:n=!1,curved:r=!1,formatY:s=Wc,height:a=132}){const[o,l]=dg(),[u,d]=D.useState(null),p=30,m=8,g=8,y=16,_=e.length,S=Math.max(l-p-m,1),E=a-g-y,N=nS(Math.max(1,...t.flatMap(V=>V.values.map(G=>G??0)))),C=V=>p+(_<=1?S/2:V/(_-1)*S),O=V=>g+E*(1-V/N),I=g+E,F=V=>V.values.map((G,X)=>G==null?null:`${C(X)},${O(G)}`).reduce((G,X)=>X==null?{d:G.d,pen:!1}:{d:`${G.d}${G.pen?" L":" M"} ${X}`,pen:!0},{d:"",pen:!1}).d,P=V=>{const G=V.values.map((X,pe)=>X==null?null:[C(pe),O(X)]).filter(X=>X!=null);return G.length<2?"":`M ${G[0][0]} ${I} `+G.map(([X,pe])=>`L ${X} ${pe}`).join(" ")+` L ${G[G.length-1][0]} ${I} Z`},H=V=>{let G="";for(let X=0;X<V.length-1;X++){const pe=V[X-1]??V[X],ye=V[X],Z=V[X+1],ee=V[X+2]??Z,j=ye[0]+(Z[0]-pe[0])/6,J=ye[1]+(Z[1]-pe[1])/6,he=Z[0]-(ee[0]-ye[0])/6,Y=Z[1]-(ee[1]-ye[1])/6;G+=` C ${j} ${J} ${he} ${Y} ${Z[0]} ${Z[1]}`}return G},B=V=>{const G=[];let X=[];return V.values.forEach((pe,ye)=>{pe==null?(X.length&&G.push(X),X=[]):X.push([C(ye),O(pe)])}),X.length&&G.push(X),G.map(pe=>{const ye=`M ${pe[0][0]} ${pe[0][1]}`;return pe.length<2?ye:ye+H(pe)}).join(" ")},W=V=>{const G=V.values.map((ye,Z)=>ye==null?null:[C(Z),O(ye)]).filter(ye=>ye!=null);if(G.length<2)return"";const X=G[0],pe=G[G.length-1];return`M ${X[0]} ${I} L ${X[0]} ${X[1]}`+H(G)+` L ${pe[0]} ${I} Z`},M=r?B:F,z=r?W:P,K=V=>{const G=V.nativeEvent.offsetX,X=_<=1?0:Math.round((G-p)/S*(_-1));d(Math.max(0,Math.min(_-1,X)))};return f.jsxs("div",{children:[f.jsxs("div",{ref:o,className:"relative",style:{height:a},children:[l>0&&f.jsxs("svg",{width:l,height:a,className:"block",children:[[0,N].map(V=>f.jsxs("g",{children:[f.jsx("line",{x1:p,y1:O(V),x2:l-m,y2:O(V),className:"text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),f.jsx("text",{x:p-4,y:O(V)+3,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:s(V)})]},V)),n&&t[0]&&z(t[0])&&f.jsx("path",{d:z(t[0]),fill:t[0].color,opacity:.12}),u!=null&&f.jsx("line",{x1:C(u),y1:g,x2:C(u),y2:I,className:"text-gray-300 dark:text-gray-600",stroke:"currentColor",strokeWidth:1}),t.map(V=>f.jsx("path",{d:M(V),fill:"none",stroke:V.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"},V.key)),t.map(V=>V.values.map((G,X)=>G==null?null:f.jsx("circle",{cx:C(X),cy:O(G),r:u===X?3:1.8,fill:V.color},`${V.key}-${X}`))),f.jsx("text",{x:p,y:a-4,className:"fill-gray-400 text-[8px]",children:e[0]?Dc(e[0]):""}),f.jsx("text",{x:l-m,y:a-4,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:e[_-1]?Dc(e[_-1]):""}),f.jsx("rect",{x:0,y:0,width:l,height:a,fill:"transparent",onMouseMove:K,onMouseLeave:()=>d(null)})]}),u!=null&&l>0&&f.jsxs(fg,{x:C(u),y:g,width:l,children:[f.jsx("div",{className:"font-medium",children:e[u]?Dc(e[u]):""}),t.map(V=>f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-[1px]",style:{background:V.color}}),V.label,": ",V.values[u]==null?"—":s(V.values[u])]},V.key))]})]}),t.length>1&&f.jsx(xb,{series:t})]})}function yIe({repoId:e,onOpenCharts:t}){const{data:n,isLoading:r}=rP(e),s=(n==null?void 0:n.weekBuckets)??[],a=[{key:"opened",label:"Opened",color:on.blue,values:(n==null?void 0:n.throughput.opened)??[]},{key:"merged",label:"Merged",color:on.green,values:(n==null?void 0:n.throughput.merged)??[]}],o=a.some(l=>l.values.some(u=>u>0));return f.jsxs("div",{className:"rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[f.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[f.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:["PR merge rate",n?` · ${n.windowDays/7}-wk`:""]}),f.jsx("button",{type:"button",onClick:t,className:"shrink-0 rounded border border-gray-300 px-2 py-0.5 text-[11px] font-medium text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",title:"Open the full analytics charts for this repo",children:"📊 Charts"})]}),r&&n==null?f.jsx("div",{className:"h-[132px] animate-pulse rounded bg-gray-50 dark:bg-gray-900/40"}):o?f.jsx(xf,{labels:s,series:a,area:!0,curved:!0}):f.jsx(fi,{})]})}function bIe({prs:e,repoFullName:t}){const{data:n}=Za(),r=Wt(l=>l.openPrDetailTab),s=D.useMemo(()=>ia(n),[n]);if(e.length===0)return null;const a=e.reduce((l,u)=>l+(u.isDraft?1:0),0),o=e.length-a;return f.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800",children:[f.jsxs("div",{className:"border-b border-gray-200 px-3 py-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:border-gray-800 dark:text-gray-400",children:["Open PRs · ",o,a>0&&f.jsxs("span",{className:"font-normal normal-case text-gray-400",children:[" ","· ",a," draft",a===1?"":"s"]})]}),f.jsx("ul",{className:"divide-y divide-gray-100 dark:divide-gray-800/70",children:e.map(l=>{const u=ml[l.ciStatus],d=l.authorId!=null?s.get(l.authorId):void 0,p=aP[l.reasonTag],m=Ty(l.mergeable,l.mergeStateStatus),g=l.isApproved?{label:"approved",color:"#22c55e"}:l.isChangesRequested?{label:"changes",color:"#ef4444"}:null;return f.jsx("li",{children:f.jsxs("button",{type:"button",onClick:()=>r({id:l.id,number:l.number,title:l.title,repoFullName:t,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null},{fromActivity:!0}),className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs hover:bg-gray-50 dark:hover:bg-gray-800/40",children:[f.jsx("span",{"aria-hidden":"true",title:(u==null?void 0:u.label)??"no checks",className:"inline-block h-2 w-2 shrink-0 rounded-full",style:u!=null?{background:u.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"}}),_8(l)&&f.jsx("span",{"aria-hidden":"true",title:"Needs attention (your turn · stalled · untouched threads · CI / conflicts)",className:"shrink-0 text-xs leading-none text-amber-500 dark:text-amber-400",children:"⚠"}),f.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[f.jsxs("span",{className:"text-gray-400",children:["#",l.number]})," ",f.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:l.title})]}),f.jsx(mi,{user:d,size:16}),f.jsx("span",{className:"max-w-[7rem] shrink-0 truncate text-gray-500 dark:text-gray-400",title:jr(d,l.authorId),children:jr(d,l.authorId)}),l.isDraft&&f.jsx("span",{className:"shrink-0 rounded bg-gray-500/15 px-1 text-[10px] font-medium text-gray-500 dark:text-gray-400",children:"draft"}),g!=null&&f.jsx("span",{className:"shrink-0 rounded px-1 text-[10px] font-semibold",style:{color:g.color,background:g.color+"1a"},children:g.label}),m!=null&&f.jsx("span",{className:"shrink-0 rounded bg-orange-500/15 px-1 text-[10px] font-medium text-orange-600 dark:text-orange-400",children:m}),f.jsx(JT,{counts:l.threadCounts,compact:!0}),p.myTurn?f.jsx("span",{className:"hidden shrink-0 rounded px-1 text-[10px] font-medium sm:inline",style:{color:p.color,background:p.color+"1a"},title:jr(d,l.authorId),children:p.label}):f.jsx("span",{className:"hidden shrink-0 text-[10px] text-gray-400 sm:inline",children:Yr(l.updatedAt)})]})},l.id)})})]})}function xIe(){const e=nn();return kn({mutationFn:()=>it.markFeedSeen(),onSuccess:()=>void e.invalidateQueries({queryKey:["me"]})})}const _Ie=50;function J6(e,t,n,r){const s=new URLSearchParams;return e&&e.length>0&&s.set("repoIds",e.join(",")),t&&t.length>0&&s.set("userIds",t.join(",")),n&&(s.set("excludeBots","true"),r.length>0&&s.set("allowBotIds",r.join(","))),s.toString()}function wIe(e){var a,o,l,u,d;const t=J6(e.repoIds,e.userIds,e.excludeBots??!1,e.allowedBotIds??[]),n=H$({queryKey:["consolidated-feed",t],initialPageParam:0,queryFn:({pageParam:p})=>{const m=new URLSearchParams(t);return m.set("limit",String(_Ie)),m.set("offset",String(p)),it.consolidatedFeed(m.toString())},getNextPageParam:(p,m)=>{var _;const g=m.reduce((S,E)=>S+E.items.length,0),y=((_=m[0])==null?void 0:_.total)??0;return g<y?g:void 0},enabled:e.enabled??!0,staleTime:1/0,refetchOnMount:!1,placeholderData:p=>p}),{items:r,users:s}=D.useMemo(()=>{var y;const p=((y=n.data)==null?void 0:y.pages)??[],m=p.flatMap(_=>_.items),g=new Map;for(const _ of p)for(const S of _.users)g.set(S.id,S);return{items:m,users:[...g.values()]}},[n.data]);return{items:r,users:s,total:((o=(a=n.data)==null?void 0:a.pages[0])==null?void 0:o.total)??0,generatedAt:((u=(l=n.data)==null?void 0:l.pages[0])==null?void 0:u.generatedAt)??null,latestId:((d=r[0])==null?void 0:d.id)??null,hasMore:n.hasNextPage,loadMore:n.fetchNextPage,isFetchingMore:n.isFetchingNextPage,isLoading:n.isLoading,isFetching:n.isFetching}}function EIe(e){var l,u,d;const t=nn(),n=J6(e.repoIds,e.userIds,e.excludeBots??!1,e.allowedBotIds??[]),r=gn({queryKey:["feed-head",n],queryFn:()=>{const p=new URLSearchParams(n);return p.set("limit","1"),p.set("offset","0"),it.consolidatedFeed(p.toString())},enabled:e.enabled??!0,refetchInterval:6e4,refetchIntervalInBackground:!1,staleTime:3e4}),s=((u=(l=r.data)==null?void 0:l.items[0])==null?void 0:u.id)??null,a=((d=r.data)==null?void 0:d.total)??0;return{hasNew:e.feedSettled&&s!=null&&(e.loadedLatestId==null||s!==e.loadedLatestId||a>e.loadedTotal),refresh:()=>{t.invalidateQueries({queryKey:["consolidated-feed"]}),t.invalidateQueries({queryKey:["feed-head"]})}}}function kIe(e){if(e.kind==="claude_review")return{color:"#8957e5",label:"Claude Review"};if(e.kind==="review_submitted"&&e.reviewState!=null)return{color:TIe[e.reviewState].color,label:`Review: ${SIe[e.reviewState]}`};const t=sP[e.kind];return{color:(t==null?void 0:t.color)??"#6b7280",label:(t==null?void 0:t.label)??e.kind}}const TIe={approved:{label:"approved",color:"#22c55e"},changes_requested:{label:"requested changes",color:"#ef4444"},commented:{label:"commented",color:"#9ca3af"},dismissed:{label:"dismissed",color:"#9ca3af"},pending:{label:"pending",color:"#eab308"}},SIe={approved:"Approved",changes_requested:"Request Changes",commented:"Comment",dismissed:"Dismissed",pending:"Pending"},NIe={APPROVE:{label:"approve",color:"#22c55e"},REQUEST_CHANGES:{label:"request changes",color:"#ef4444"},COMMENT:{label:"comment",color:"#9ca3af"}};function nD(e){for(let t=(e==null?void 0:e.parentElement)??null;t;t=t.parentElement){const n=getComputedStyle(t).overflowY;if((n==="auto"||n==="scroll"||n==="overlay")&&t.scrollHeight>t.clientHeight)return t}return null}function nw({repoId:e}){const t=Me(be=>be.userIds),n=Me(be=>be.excludeBots),r=Me(be=>be.allowedBotIds),s=Me(be=>be.feedMyTurnOnly),a=Me(be=>be.toggleFeedMyTurnOnly),o=Me(be=>be.feedClaudeOnly),l=Me(be=>be.toggleFeedClaudeOnly),u=Me(be=>be.showThreadInChanges),d=Me(be=>be.selectPr),p=Me(be=>be.showPrComment),m=Me(be=>be.openClaudeReview),g=Me(be=>be.focusEventInTab),y=Wt(be=>be.openPrDetailTab),_=Wt(be=>be.openPrFocusTab),{claudeReview:S,feedMyTurn:E}=zi(),N=Wt(be=>be.activityFlashItemId),C=Wt(be=>be.clearActivityFlashItem),O=e!=null?[e]:null,I=xIe(),F=D.useRef(!1);D.useEffect(()=>{e==null&&!F.current&&(F.current=!0,I.mutate())},[e,I]);const{items:P,users:H,total:B,latestId:W,isLoading:M,hasMore:z,loadMore:K,isFetchingMore:V}=wIe({repoIds:O,userIds:t,excludeBots:n,allowedBotIds:r}),G=D.useRef(null),{hasNew:X,refresh:pe}=EIe({repoIds:O,userIds:t,excludeBots:n,allowedBotIds:r,loadedLatestId:W,loadedTotal:B,feedSettled:!M}),ye=()=>{var be;pe(),(be=nD(G.current))==null||be.scrollTo({top:0,behavior:"smooth"})},Z=D.useMemo(()=>ia(H),[H]),ee=P.filter(be=>be.isMyTurn).length,j=P.filter(be=>be.kind==="claude_review").length,J=E&&s?P.filter(be=>be.isMyTurn):o?P.filter(be=>be.kind==="claude_review"):P,he=D.useRef(new Map),[Y,Pe]=D.useState(null);D.useEffect(()=>{if(N==null)return;const be=N,Ge=requestAnimationFrame(()=>{const St=he.current.get(be);St&&(St.scrollIntoView({block:"center",behavior:"smooth"}),Pe(be),window.setTimeout(()=>Pe(et=>et===be?null:et),1800)),C()});return()=>cancelAnimationFrame(Ge)},[N,C]);const se=D.useRef(null),Re=D.useRef(!1),ot=D.useRef(()=>{});ot.current=()=>{z&&!V&&P.length>0&&K()};const ft=z&&P.length>0;D.useEffect(()=>{const be=se.current;if(!be)return;const Ge=new IntersectionObserver(St=>{var et;Re.current=((et=St[0])==null?void 0:et.isIntersecting)??!1,Re.current&&ot.current()},{root:nD(be),rootMargin:"0px 0px 600px 0px"});return Ge.observe(be),()=>Ge.disconnect()},[ft]),D.useEffect(()=>{!V&&Re.current&&ot.current()},[V,P.length,z]);const Ne=(be,Ge)=>({id:Ge,number:be.prNumber??0,title:be.prTitle??`#${be.prNumber??""}`,repoFullName:be.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null});function Se(be){const Ge=be.prId;if(Ge==null)return;const St=Ne(be,Ge),et={fromActivity:!0,returnItemId:be.id};if(be.kind==="claude_review"){m(St,et);return}y(St,et),be.threadId!=null?u(Ge,be.threadId):be.commentId!=null?p(Ge,be.commentId):d(Ge)}function _e(be,Ge){const St=be.prId;St!=null&&(y(Ne(be,St),{fromActivity:!0,returnItemId:be.id}),u(St,Ge))}function tt(be){const Ge=be.prId;if(Ge!=null&&(_(Ne(be,Ge),{fromActivity:!0,returnItemId:be.id}),be.kind!=="claude_review")){const St=be.threadId??be.commentId??null,et=be.kind==="review_comment"?be.threadId:null;g(Ge,be.occurredAt,{type:be.kind,refId:St},et)}}return f.jsxs("div",{className:"space-y-3","data-testid":"feed-view",ref:G,children:[X&&f.jsx("div",{className:"sticky top-0 z-10",children:f.jsxs("button",{type:"button",onClick:ye,"data-testid":"feed-new-activity",className:"flex w-full items-center justify-center gap-2 rounded-full border border-sky-400 bg-sky-50 px-3 py-1.5 text-xs font-semibold text-sky-700 shadow-sm transition-colors hover:bg-sky-100 dark:border-sky-500/60 dark:bg-sky-950/50 dark:text-sky-300 dark:hover:bg-sky-900/60",children:[f.jsx("span",{"aria-hidden":"true",children:"↑"})," New activity — Refresh"]})}),f.jsxs("div",{className:"flex items-center gap-2 px-0.5",children:[E&&f.jsxs("button",{type:"button",onClick:a,"aria-pressed":s,className:`flex items-center gap-1 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${s?"border-yellow-400 bg-yellow-50 text-yellow-700 dark:border-yellow-500/60 dark:bg-yellow-950/30 dark:text-yellow-300":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,title:"Show only items that concern you (FYI)",children:[f.jsx("span",{"aria-hidden":"true",children:"★"})," FYI",ee>0&&f.jsx("span",{className:"tabular-nums opacity-70",children:ee})]}),S&&f.jsxs("button",{type:"button",onClick:l,"aria-pressed":o,className:`flex items-center gap-1 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${o?"border-violet-400 bg-violet-50 text-violet-700 dark:border-violet-500/60 dark:bg-violet-950/30 dark:text-violet-300":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,title:"Show only Claude Reviews",children:[f.jsx("span",{"aria-hidden":"true",children:"✨"})," Claude Reviews",j>0&&f.jsx("span",{className:"tabular-nums opacity-70",children:j})]}),P.length>0&&f.jsxs("span",{className:"text-[11px] text-gray-400",children:[J.length," of ",P.length]})]}),P.length===0?f.jsx("div",{className:"flex h-32 items-center justify-center text-sm text-gray-400",children:"Nothing to show yet — activity across your repos will appear here."}):J.length===0?f.jsx("div",{className:"flex h-32 items-center justify-center text-sm text-gray-400",children:o?"No Claude Reviews in this window.":"Nothing needs your attention right now."}):f.jsx("ul",{className:"space-y-2",children:J.map(be=>{const Ge=be.actorId!=null?Z.get(be.actorId):void 0,St=be.mergedById!=null?Z.get(be.mergedById):void 0,et=St!=null||be.mergedById!=null?jr(St,be.mergedById):null,rn=(be.reviewers??[]).map(cn=>jr(Z.get(cn.userId),cn.userId));return f.jsx(DIe,{item:be,actorUser:Ge,mergedByLabel:et,reviewerLabels:rn,usersById:Z,flash:Y===be.id,innerRef:cn=>{cn?he.current.set(be.id,cn):he.current.delete(be.id)},onOpen:()=>Se(be),onOpenThread:cn=>_e(be,cn),onFocus:()=>tt(be)},be.id)})}),ft&&f.jsx("div",{ref:se,className:"flex justify-center pt-1",children:V?f.jsxs("span",{className:"flex items-center gap-2 py-1.5 text-xs text-gray-400",children:[f.jsx("span",{className:"h-3 w-3 animate-spin rounded-full border-2 border-gray-300 border-t-transparent dark:border-gray-600 dark:border-t-transparent"}),"Loading more…"]}):f.jsx("button",{type:"button",onClick:()=>void K(),className:"rounded-full border border-gray-300 px-4 py-1.5 text-xs font-medium text-gray-600 hover:border-gray-400 hover:bg-gray-50 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500 dark:hover:bg-gray-800/50",children:"Load more"})})]})}function CIe({item:e}){const{data:t,isLoading:n}=Fk(e.threadId),{data:r}=Za(),s=D.useMemo(()=>ia(r),[r]),a=D.useMemo(()=>{if(!t||e.actorId==null)return null;const l=new Date(e.occurredAt).getTime();let u=null;for(const d of t.comments){if(d.authorId!==e.actorId)continue;const p=Math.abs(new Date(d.createdAt).getTime()-l);(u==null||p<u.dist)&&(u={id:d.id,dist:p})}return(u==null?void 0:u.id)??null},[t,e.actorId,e.occurredAt]),o=e.prNumber!=null?`https://github.com/${e.repoFullName}/pull/${e.prNumber}`:"";return n?f.jsx("div",{className:"px-1 py-2 text-xs text-gray-400",children:"Loading conversation…"}):t?f.jsx(Lm,{thread:t,usersById:s,prUrl:o,repoId:e.repoId,highlightCommentId:a}):f.jsx("div",{className:"px-1 py-2 text-xs text-gray-400",children:"Couldn’t load this conversation."})}function IIe({prId:e}){var s;const{data:t,isLoading:n}=jy(e);if(n)return f.jsx("div",{className:"mt-1 px-1 text-xs text-gray-400",children:"Loading summary…"});const r=(s=t==null?void 0:t.body)==null?void 0:s.trim();return r?f.jsx("div",{className:"mt-1 max-h-72 overflow-auto rounded bg-gray-50 px-2 py-1.5 text-sm dark:bg-gray-900/50",children:f.jsx(ss,{children:r})}):f.jsx("div",{className:"mt-1 px-1 text-xs text-gray-400",children:"No description."})}function AIe({item:e}){const[t,n]=D.useState(!1),r=e.ciStatus!=null&&e.ciStatus!=="unknown"?ml[e.ciStatus]:null,s=e.changedFilesCount,a=e.prId;return f.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[(r!=null||s!=null)&&f.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-gray-500 dark:text-gray-400",children:[r!=null&&f.jsxs("span",{className:"inline-flex items-center gap-1 font-medium",style:{color:r.color},children:[f.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-2 rounded-full",style:{background:r.color}}),r.label]}),s!=null&&f.jsxs("span",{children:[s," ",s===1?"file":"files"," changed"]})]}),a!=null&&f.jsxs("div",{onClick:o=>o.stopPropagation(),children:[f.jsx("button",{type:"button",onClick:()=>n(o=>!o),className:"text-[11px] font-medium text-sky-600 hover:underline dark:text-sky-400",children:t?"Hide summary":"Show summary"}),t&&f.jsx(IIe,{prId:a})]})]})}function RIe({thread:e,author:t,onOpen:n}){const r=ei[e.derivedState],s=e.path.split("/").pop()??e.path;return f.jsx("li",{children:f.jsxs("button",{type:"button",onClick:n,className:"group/th block w-full rounded border border-gray-200 bg-white/60 px-2 py-1 text-left hover:border-sky-300 dark:border-gray-800 dark:bg-gray-900/40 dark:hover:border-sky-700",children:[f.jsxs("span",{className:"flex items-center gap-1.5 text-[11px]",children:[f.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-2 shrink-0 rounded-full",style:{background:r.color}}),f.jsxs("code",{className:"truncate font-mono text-gray-600 group-hover/th:text-sky-600 dark:text-gray-300",children:[s,e.line!=null?`:${e.line}`:""]}),f.jsx("span",{className:"shrink-0 text-gray-400",children:r.label.toLowerCase()})]}),e.excerpt.trim()!==""&&f.jsxs("span",{className:"mt-0.5 block truncate text-xs italic text-gray-500 dark:text-gray-400",children:[t!=null?`${jr(t,e.authorId)}: `:"","“",e.excerpt,"”"]})]})})}const OIe=160;function DIe({item:e,actorUser:t,mergedByLabel:n,reviewerLabels:r,usersById:s,flash:a,innerRef:o,onOpen:l,onOpenThread:u,onFocus:d}){const p=kIe(e),g=zi().feedMyTurn&&e.isMyTurn,y=e.kind==="claude_review",_=e.kind==="pr_merged",S=y?"Claude":e.actorId==null&&e.kind==="commit_pushed"?"A contributor":jr(t,e.actorId),E=e.prNumber!=null?`#${e.prNumber}${e.prTitle!=null?` ${e.prTitle}`:""}`:"",N=e.claudeVerdict!=null?NIe[e.claudeVerdict]:null,C=e.affectedThreads??[],O=e.myTurnReasons[0],I=e.kind==="review_comment"&&e.threadId!=null,F=e.kind==="pr_comment"&&e.prId!=null,P=e.kind==="pr_opened",[H,B]=D.useState(!1),W=_&&n!=null&&e.mergedById!==e.actorId,M=_&&r.length>0,z=D.useRef(null),K=D.useRef(null),[V,G]=D.useState(!1),[X,pe]=D.useState(!1),ye=e.content!=null&&e.content.trim()!=="";D.useEffect(()=>{const ee=z.current,j=K.current;if(!ee||!j)return;const J=()=>{V||pe(ee.scrollHeight>ee.clientHeight+4)};J();const he=new ResizeObserver(J);return he.observe(j),()=>he.disconnect()},[e.content,V]);const Z=ee=>{ee.target.closest("a,button")||l()};return f.jsx("li",{ref:o,children:f.jsxs("article",{onClick:Z,className:`cursor-pointer rounded-md border p-2.5 text-sm transition-colors ${a?"border-sky-400 ring-2 ring-sky-400/60 dark:border-sky-500":g?"border-yellow-400 bg-yellow-50/40 dark:border-yellow-500/50 dark:bg-yellow-950/15":y?"border-violet-300 bg-violet-50/30 dark:border-violet-500/40 dark:bg-violet-950/10":"border-gray-200 hover:border-sky-300 dark:border-gray-800 dark:hover:border-sky-700"}`,children:[f.jsxs("div",{className:"flex items-center gap-2",children:[e.prId!=null&&f.jsx("button",{type:"button",onClick:ee=>{ee.stopPropagation(),d()},className:"shrink-0 rounded p-0.5 text-blue-500 hover:text-blue-600",title:"Focus — open this PR in its own isolated timeline tab","aria-label":"Focus this PR in its own timeline tab",children:f.jsx(Ly,{size:13})}),f.jsx("span",{className:"shrink-0 text-[11px] text-gray-400",title:Pf(e.occurredAt),children:Yr(e.occurredAt)}),f.jsx(mi,{user:t,size:20}),f.jsx("span",{className:"truncate font-medium text-gray-800 dark:text-gray-100",children:S}),f.jsx("span",{className:"inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-[11px] font-medium",style:{color:p.color,background:p.color+"1a"},children:p.label}),N!=null&&f.jsx("span",{className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",style:{color:N.color,background:N.color+"1a"},children:N.label}),g&&f.jsx("span",{className:"shrink-0 rounded bg-yellow-400/20 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-yellow-700 dark:text-yellow-300",children:"FYI"}),g&&O!=null&&f.jsx("span",{className:"shrink-0 rounded border border-yellow-300 px-1.5 py-0.5 text-[10px] font-medium text-yellow-700 dark:border-yellow-600/50 dark:text-yellow-300",title:e.myTurnReasons.map(ee=>JN[ee].title).join(" · "),children:JN[O].label})]}),f.jsxs("div",{className:"mt-1 flex items-baseline gap-1.5 text-xs",children:[f.jsx("span",{className:"shrink-0 text-gray-400",children:e.repoFullName}),E!==""&&f.jsx("button",{type:"button",onClick:l,className:"min-w-0 truncate font-medium text-gray-700 hover:text-sky-600 hover:underline dark:text-gray-200",children:E}),e.path!=null&&f.jsxs("span",{className:"shrink-0 text-gray-400",children:["· ",e.path.split("/").pop()]})]}),P&&f.jsx(AIe,{item:e}),ye&&!I&&f.jsxs("div",{className:"mt-1.5 rounded bg-gray-50 px-2 py-1.5 text-sm dark:bg-gray-900/50",children:[f.jsx("div",{ref:z,className:V?"":"overflow-hidden",style:V?void 0:{maxHeight:OIe},children:f.jsx("div",{ref:K,children:f.jsx(ss,{children:e.content})})}),(X||V)&&f.jsx("button",{type:"button",onClick:()=>G(ee=>!ee),className:"mt-1 text-[11px] font-medium text-sky-600 hover:underline dark:text-sky-400",children:V?"Show less":"Show more"})]}),e.mergedComments.length>0&&f.jsx("div",{className:"mt-1.5 space-y-1.5",children:e.mergedComments.map(ee=>f.jsxs("div",{className:"rounded bg-gray-50 px-2 py-1.5 text-sm dark:bg-gray-900/50",children:[f.jsx("div",{className:"mb-0.5 text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:"Also commented"}),f.jsx("div",{className:"max-h-72 overflow-auto",children:f.jsx(ss,{children:ee.content})})]},ee.commentId))}),C.length>0&&f.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[e.changeSummary!=null&&f.jsx("div",{className:"text-[11px] font-medium text-gray-500 dark:text-gray-400",children:e.changeSummary}),f.jsx("ul",{className:"space-y-1.5",children:C.map(ee=>f.jsx(RIe,{thread:ee,author:ee.authorId!=null?s.get(ee.authorId):void 0,onOpen:()=>u(ee.threadId)},ee.threadId))})]}),(W||M)&&f.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-gray-500 dark:text-gray-400",children:[W&&f.jsxs("span",{children:["Merged by ",f.jsx("span",{className:"font-medium",children:n})]}),M&&f.jsxs("span",{children:["Reviewed by ",f.jsx("span",{className:"font-medium",children:r.join(", ")})]})]}),I&&f.jsx("div",{className:"mt-1.5",onClick:ee=>ee.stopPropagation(),children:f.jsx(CIe,{item:e})}),F&&e.prId!=null&&f.jsx("div",{className:"mt-1.5",children:H?f.jsx("div",{onClick:ee=>ee.stopPropagation(),children:f.jsx(Bk,{prId:e.prId,initialBody:oP(e.content,(t==null?void 0:t.githubLogin)??null),autoFocus:!0,onCancel:()=>B(!1),onDone:()=>B(!1)})}):f.jsx("button",{type:"button",onClick:ee=>{ee.stopPropagation(),B(!0)},className:"text-[11px] font-medium text-sky-600 hover:underline dark:text-sky-400",children:"Reply"})})]})})}function PIe(e){return gn({queryKey:["team-insights"],queryFn:()=>it.teamInsights(),enabled:e,refetchInterval:5*6e4,refetchIntervalInBackground:!1,staleTime:6e4})}function MIe(e){return gn({queryKey:["sprint-report"],queryFn:it.sprintReport,enabled:e,staleTime:6e4})}const LIe=5e3;function FIe(){const e=nn(),[t,n]=D.useState(null);D.useEffect(()=>{if(t==null)return;const s=window.setTimeout(()=>n(null),LIe);return()=>window.clearTimeout(s)},[t]);const r=kn({mutationFn:it.refreshSprintReport,onSuccess:s=>{var a;e.setQueryData(["sprint-report"],s),e.invalidateQueries({queryKey:["ai-usage"]}),n(s.creditsExhausted?"Out of AI credits this month — summaries resume on the 1st.":s.throttled&&((a=s.report)!=null&&a.stale)?"Refreshed moments ago — showing the latest. Try again shortly.":null)}});return Object.assign(r,{notice:t})}function jIe({digests:e,isLoading:t,anyWatched:n,refreshingRepoIds:r,onRegenerateRepo:s,outOfCredits:a=!1,embedded:o=!1}){const{activityDigest:l}=zi(),{data:u}=pl(),d=XO(_=>_.expanded),p=XO(_=>_.toggle),m=G6(),g=D.useMemo(()=>(u??[]).filter(_=>_.inboxWatch),[u]),y=D.useMemo(()=>new Map(e.map(_=>[_.repoId,_])),[e]);return l?f.jsxs("div",{className:"space-y-2",children:[!o&&f.jsx("div",{className:"flex items-center gap-2 px-0.5",children:f.jsxs("span",{className:"flex items-center gap-1 text-[11px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:[f.jsx("span",{"aria-hidden":"true",children:"✨"})," Repo summaries · watched repos"]})}),!n||g.length===0?f.jsx("p",{className:"px-0.5 text-xs text-gray-400",children:"No watched repos in view — Watch a repo (the eye toggle) to get a summary here."}):t&&e.length===0?f.jsx("div",{className:"h-12 animate-pulse rounded-md border border-violet-200 bg-violet-50/40 dark:border-violet-900/40 dark:bg-violet-950/10"}):f.jsx("div",{className:"space-y-2",children:g.map(_=>{const S=y.get(_.id);return f.jsx(Z6,{digest:S,isLoading:!1,title:_.fullName,collapsed:!d.has(_.id),onToggle:()=>p(_.id),onRegenerate:(S==null||S.stale)&&s?()=>s(_.id):void 0,regenerating:r.has(_.id),onOpenPr:m,showProBadge:!1,outOfCredits:a},_.id)})})]}):null}function $Ie(e){return{id:e.prId,number:e.prNumber,title:e.title??`#${e.prNumber}`,repoFullName:e.repoFullName,authorLogin:e.authorLogin,authorDisplayName:null,authorAvatarUrl:null}}function BIe({digests:e,digestsLoading:t=!1,anyWatched:n=!1,refreshingRepoIds:r,onRegenerateRepo:s,onRegenerateAllDigests:a,cascadeBusy:o=!1}){var H,B;const{activityDigest:l}=zi(),u=Wt(W=>W.openPrDetailTab),{data:d,isLoading:p}=MIe(l),m=FIe(),g=eS(l),y=((H=g.data)==null?void 0:H.allowanceCredits)!=null&&(g.data.remainingCredits??0)<=0,_=uv(W=>W.collapsed),S=uv(W=>W.setCollapsed),E=uv(W=>W.reposOpen),N=uv(W=>W.setReposOpen),C=e!==void 0&&n,O=(e==null?void 0:e.length)??0;if(!l)return null;const I=(d==null?void 0:d.report)??null,F=m.isPending||o,P=()=>{m.mutate(),a==null||a()};return f.jsxs("div",{className:"rounded-lg border border-violet-200 bg-violet-50/40 p-3 dark:border-violet-900/60 dark:bg-violet-950/20","data-testid":"sprint-report",children:[f.jsxs("div",{onClick:()=>S(!_),className:"-mx-1 flex cursor-pointer select-none items-center gap-2 rounded px-1 hover:bg-violet-500/5",children:[f.jsxs("button",{type:"button",onClick:W=>{W.stopPropagation(),S(!_)},"aria-expanded":!_,className:"flex items-center gap-1.5 text-sm font-semibold text-gray-700 hover:text-gray-900 dark:text-gray-200 dark:hover:text-white",children:[f.jsx("span",{className:"w-3 select-none text-gray-400",children:_?"▸":"▾"}),f.jsx("span",{"aria-hidden":"true",children:"✨"})," Sprint report"]}),f.jsx("span",{className:"shrink-0 rounded bg-violet-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:"Pro"}),f.jsxs("span",{className:"ml-auto flex items-center gap-2 text-[10px] text-gray-400",children:[I!=null&&f.jsxs("span",{title:I.model,children:["Haiku "," · ",Yr(I.generatedAt),I.stale?" · stale":""]}),I==null?f.jsx("button",{type:"button",onClick:W=>{W.stopPropagation(),P()},disabled:F||y,className:"flex items-center gap-0.5 rounded border border-violet-300 px-1.5 py-0.5 font-medium text-violet-600 hover:border-violet-400 disabled:opacity-50 dark:border-violet-800 dark:text-violet-300 dark:hover:border-violet-600",title:y?"Out of AI credits — resets next month":"Generate the first sprint report from the current Insights, and every watched repo’s summary (runs the Haiku model)",children:y?"Out of credits":F?"Generating…":"Generate"}):I.stale&&f.jsxs("button",{type:"button",onClick:W=>{W.stopPropagation(),P()},disabled:F||y,className:"flex items-center gap-0.5 rounded border border-violet-300 px-1.5 py-0.5 font-medium text-violet-600 hover:border-violet-400 disabled:opacity-50 dark:border-violet-800 dark:text-violet-300 dark:hover:border-violet-600",title:y?"Out of AI credits — resets next month":"Regenerate the sprint report and every changed repo summary — the Insights changed since it was written (runs the Haiku model)",children:[f.jsx("span",{"aria-hidden":"true",children:"↻"}),y?"Out of credits":F?"Regenerating…":"Regenerate"]})]})]}),m.isError&&f.jsx("div",{className:"mt-2 text-[11px] text-red-500",children:((B=m.error)==null?void 0:B.message)??"Couldn’t generate the report."}),!m.isError&&m.notice&&f.jsx("div",{className:"mt-2 text-[11px] text-gray-400",children:m.notice}),y&&f.jsx("div",{className:"mt-2 text-[11px] text-amber-600 dark:text-amber-400",children:"Out of AI credits this month — summaries resume on the 1st. Existing reports still show."}),!_&&f.jsx("div",{className:"mt-2",children:F?f.jsx(UIe,{}):p?f.jsx("div",{className:"h-16 animate-pulse rounded bg-violet-500/5"}):I?f.jsxs("div",{className:"digest-fade-in",children:[f.jsx(X6,{markdown:I.summary,prRefs:I.prRefs,onOpenPr:W=>u($Ie(W),{fromActivity:!0})}),f.jsxs("div",{className:"mt-1.5 text-[10px] text-gray-400",children:["Generated ",new Date(I.generatedAt).toLocaleString()]})]},I.generatedAt):f.jsxs("div",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:["A prioritised, PR-linked summary of what needs attention this sprint — generated from the Insights below. Click"," ",f.jsx("span",{className:"font-medium",children:"Generate"})," above."]})}),!_&&C&&f.jsxs("div",{className:"mt-3 border-t border-violet-200/60 pt-2 dark:border-violet-900/40",children:[f.jsxs("button",{type:"button",onClick:()=>N(!E),className:"flex w-full items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:[f.jsx("span",{className:"w-3 select-none text-gray-400",children:E?"▾":"▸"}),f.jsx("span",{"aria-hidden":"true",children:"✨"})," Repo summaries",f.jsxs("span",{className:"font-normal text-gray-400",children:["· ",O]})]}),E&&f.jsx("div",{className:"mt-2",children:f.jsx(jIe,{embedded:!0,digests:e??[],isLoading:t,anyWatched:n,refreshingRepoIds:r??new Set,onRegenerateRepo:s,outOfCredits:y})})]})]})}function UIe(){return f.jsxs("div",{className:"space-y-1.5 py-0.5","aria-hidden":"true",children:[f.jsx("div",{className:"digest-skeleton-line h-3.5",style:{width:"58%"}}),["94%","88%","72%","80%","64%"].map((e,t)=>f.jsx("div",{className:"digest-skeleton-line h-3",style:{width:e}},t))]})}function nu({labels:e,series:t,mode:n="grouped",formatY:r=Wc,formatValue:s=r,height:a=132,rotateLabels:o=!1}){const[l,u]=dg(),[d,p]=D.useState(null),m=30,g=8,y=8,_=o?40:16,S=e.length,E=Math.max(u-m-g,1),N=a-y-_,C=/^\d{4}-\d{2}-\d{2}T/.test(e[0]??""),O=V=>t.reduce((G,X)=>G+(X.values[V]??0),0),I=nS(n==="stacked"?Math.max(1,...e.map((V,G)=>O(G))):Math.max(1,...t.flatMap(V=>V.values.map(G=>G??0)))),F=E/Math.max(S,1),P=V=>m+V*F+F*.15,H=F*.7,B=V=>y+N*(1-V/I),W=y+N,M=V=>{const G=Math.floor((V.nativeEvent.offsetX-m)/F);p(Math.max(0,Math.min(S-1,G)))},z=V=>{const G=e[V]??"";return C?Dc(G):G},K=!C||S<=8;return f.jsxs("div",{children:[f.jsxs("div",{ref:l,className:"relative",style:{height:a},children:[u>0&&f.jsxs("svg",{width:u,height:a,className:"block",children:[[0,I].map(V=>f.jsxs("g",{children:[f.jsx("line",{x1:m,y1:B(V),x2:u-g,y2:B(V),className:"text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),f.jsx("text",{x:m-4,y:B(V)+3,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:r(V)})]},V)),d!=null&&f.jsx("rect",{x:m+d*F,y,width:F,height:N,className:"text-gray-400/10 dark:text-gray-300/10",fill:"currentColor"}),e.map((V,G)=>{if(n==="stacked"){let pe=0;return t.map(ye=>{const Z=ye.values[G]??0;if(Z<=0)return null;const ee=B(pe+Z),j=B(pe)-ee;return pe+=Z,f.jsx("rect",{x:P(G),y:ee,width:H,height:Math.max(j,0),fill:ye.color},`${G}-${ye.key}`)})}const X=H/Math.max(t.length,1);return t.map((pe,ye)=>{const Z=pe.values[G]??0;return Z<=0?null:f.jsx("rect",{x:P(G)+ye*X,y:B(Z),width:Math.max(X-.5,.5),height:W-B(Z),fill:pe.color},`${G}-${pe.key}`)})}),e.map((V,G)=>{if(!(K||G===0||G===S-1))return null;const X=m+G*F+F/2;if(o){const pe=W+9;return f.jsx("text",{x:X,y:pe,textAnchor:"end",transform:`rotate(-35 ${X} ${pe})`,className:"fill-gray-400 text-[8px]",children:z(G)},`lbl-${G}`)}return f.jsx("text",{x:X,y:a-4,textAnchor:"middle",className:"fill-gray-400 text-[8px]",children:z(G)},`lbl-${G}`)}),f.jsx("rect",{x:0,y:0,width:u,height:a,fill:"transparent",onMouseMove:M,onMouseLeave:()=>p(null)})]}),d!=null&&u>0&&f.jsxs(fg,{x:m+d*F+F/2,y,width:u,children:[f.jsx("div",{className:"font-medium",children:z(d)}),t.map(V=>f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-[1px]",style:{background:V.color}}),V.label,": ",s(V.values[d]??0)]},V.key)),n==="stacked"&&t.length>1&&f.jsxs("div",{className:"mt-0.5 border-t border-gray-200 pt-0.5 dark:border-gray-700",children:["total: ",s(O(d))]})]})]}),t.length>1&&f.jsx(xb,{series:t})]})}const rD=e=>`${Math.round(e)}%`,HIe=e=>String(Math.round(e));function Tp({label:e,stat:t,format:n,betterWhen:r,sub:s,onActivate:a}){const{value:o,previous:l,lowConfidence:u}=t,d=o!=null&&l!=null?o-l:null,p=d!=null&&d!==0&&d>0==(r==="up"),m=d!=null&&d!==0&&!u;return f.jsxs(VE,{onActivate:a,children:[f.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wide text-gray-400",children:e}),f.jsx("div",{className:"text-lg font-semibold text-gray-800 dark:text-gray-100",children:o==null?"—":n(o)}),m?f.jsxs("div",{className:`text-[11px] ${p?"text-green-600 dark:text-green-400":"text-red-500 dark:text-red-400"}`,children:[d>0?"▲":"▼"," ",n(Math.abs(d))," ",f.jsx("span",{className:"text-gray-400",children:"vs last"})]}):u?f.jsx("div",{className:"text-[11px] text-gray-400",title:"Too few data points to read a trend yet (small sample)",children:l==null?"building baseline":`was ${n(l)}`}):f.jsx("div",{className:"text-[11px] text-gray-400",children:l==null?s:"no change"}),f.jsx("div",{className:"mt-0.5 text-[10px] text-gray-400",children:s})]})}function VE({onActivate:e,children:t}){const n="block w-full rounded-lg border border-gray-200 bg-white p-2 text-left dark:border-gray-800 dark:bg-gray-900/40";return e?f.jsx("button",{type:"button",onClick:e,title:"Inspect the PRs behind this metric",className:`${n} cursor-pointer transition hover:border-gray-300 hover:bg-gray-50/70 focus:outline-none focus-visible:ring-2 focus-visible:ring-sky-400 dark:hover:border-gray-600 dark:hover:bg-gray-900/60`,children:t}):f.jsx("div",{className:n,children:t})}function zIe({metrics:e,onOpenMetric:t}){const[n,r]=D.useState(!1),s=e.weekBuckets,a=e.comparisonMode??"rolling_14",o=Math.max(1,Math.min(e.sprintDays,Math.ceil(e.elapsedDays??e.sprintDays))),l=a==="sprint"?`day ${o} of ${e.sprintDays} · vs same point last sprint`:`rolling ${e.sprintDays} days · vs prior ${e.sprintDays} days`,u=E=>E.reduce((N,C)=>N+C,0),d=E=>t?()=>t(E):void 0,p=[{key:"opened",label:"Opened",color:on.blue,values:e.throughput.opened},{key:"merged",label:"Merged",color:on.green,values:e.throughput.merged}],m=[{key:"lead",label:"Lead time",color:on.purple,values:e.leadTimeTrend}],g=[{key:"ci",label:"Merge CI success",color:on.green,values:e.ciSuccessTrend}],y=[{key:"recovery",label:"CI recovery",color:on.orange,values:e.ciRecoveryTrend}],_=[{key:"failures",label:"Failures",color:on.red,values:e.ciFailureReasons.map(E=>E.count)}],S=e.ciFailureReasons.map(E=>E.stage);return f.jsxs("div",{className:"space-y-3 rounded-lg border border-gray-200 bg-gray-50/50 p-3 dark:border-gray-800 dark:bg-gray-900/20","data-testid":"flow-metrics",children:[f.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[f.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-300",children:"Flow metrics"}),f.jsxs("span",{className:"text-[11px] text-gray-400",children:["DORA-ish · ",l,t?" · tap a tile to drill in":""]})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-7",children:[f.jsxs(VE,{onActivate:d("open_prs"),children:[f.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wide text-gray-400",children:"Open PRs"}),f.jsx("div",{className:"text-lg font-semibold text-gray-800 dark:text-gray-100",children:e.openPrs}),f.jsx("div",{className:"text-[11px] text-gray-400",children:"across all repos"}),f.jsx("div",{className:"mt-0.5 text-[10px] text-gray-400",children:"currently open"})]}),f.jsx(Tp,{label:"Merges",stat:e.merges,format:HIe,betterWhen:"up",sub:"deploy frequency",onActivate:d("merges")}),f.jsx(Tp,{label:"Lead time",stat:e.leadTimeHours,format:_a,betterWhen:"down",sub:"open → merge",onActivate:d("lead_time")}),f.jsx(Tp,{label:"Review latency",stat:e.timeToFirstReviewHours,format:_a,betterWhen:"down",sub:"to first review",onActivate:d("review_latency")}),f.jsx(Tp,{label:"Merge CI",stat:e.mergeCiSuccessPct,format:rD,betterWhen:"up",sub:"green at merge",onActivate:d("merge_ci")}),f.jsx(Tp,{label:"CI recovery",stat:e.ciRecoveryHours,format:_a,betterWhen:"down",sub:"red → green",onActivate:d("ci_recovery")}),f.jsxs(VE,{onActivate:d("ci_red"),children:[f.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wide text-gray-400",children:"CI red now"}),f.jsx("div",{className:`text-lg font-semibold ${e.ciFailingNow>0?"text-red-500 dark:text-red-400":"text-gray-800 dark:text-gray-100"}`,children:e.ciFailingNow}),f.jsx("div",{className:"text-[11px] text-gray-400",children:e.ciFailingNow>0&&e.ciFailingMedianAgeHours!=null?`~${_a(e.ciFailingMedianAgeHours)} unresolved`:"all green"}),f.jsx("div",{className:"mt-0.5 text-[10px] text-gray-400",children:"recovery pressure"})]})]}),f.jsx("h4",{className:"pt-1 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"12-week trend"}),f.jsxs("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-3",children:[f.jsx(Ti,{title:"Throughput",note:"opened vs merged · weekly",children:u(e.throughput.opened)+u(e.throughput.merged)===0?f.jsx(fi,{}):f.jsx(nu,{labels:s,series:p,mode:"grouped"})}),f.jsx(Ti,{title:"CI recovery time",note:"median red→green · weekly",children:e.ciRecoveryTrend.every(E=>E==null)?f.jsx(fi,{label:"No CI recoveries yet — accrues from sync"}):f.jsx(xf,{labels:s,series:y,area:!0,curved:!0,formatY:_a})}),f.jsx(Ti,{title:"CI failures by stage",note:"which checks fail · window",children:S.length===0?f.jsx(fi,{label:"No CI failures recorded yet"}):f.jsx(nu,{labels:S,series:_,rotateLabels:!0})})]}),f.jsxs("div",{children:[f.jsxs("button",{type:"button",onClick:()=>r(E=>!E),className:"text-[11px] font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:[n?"▾":"▸"," More charts — lead time · merge CI success"]}),n&&f.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-3 lg:grid-cols-2",children:[f.jsx(Ti,{title:"Lead time for changes",note:"median open→merge · weekly",children:e.leadTimeTrend.every(E=>E==null)?f.jsx(fi,{}):f.jsx(xf,{labels:s,series:m,area:!0,curved:!0,formatY:_a})}),f.jsx(Ti,{title:"Merge CI success",note:"% green at merge · weekly",children:e.ciSuccessTrend.every(E=>E==null)?f.jsx(fi,{}):f.jsx(xf,{labels:s,series:g,curved:!0,formatY:rD})})]})]})]})}function iD(e){const t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+1,1)).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function sD({label:e,credits:t,hint:n}){return f.jsxs("div",{className:"flex items-baseline justify-between gap-3 py-1",children:[f.jsxs("div",{children:[f.jsx("div",{className:"text-[12px] font-medium text-gray-700 dark:text-gray-200",children:e}),f.jsx("div",{className:"text-[10px] text-gray-400",children:n})]}),f.jsxs("div",{className:"whitespace-nowrap text-sm font-semibold tabular-nums text-gray-800 dark:text-gray-100",children:[t.toLocaleString()," ",f.jsx("span",{className:"text-[10px] font-normal text-gray-400",children:"cr"})]})]})}function YIe(){const{data:e,isLoading:t,isError:n}=eS(!0),r=e?new Date(e.monthStart).toLocaleDateString(void 0,{month:"long"}):"";return f.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white p-3 dark:border-gray-800 dark:bg-gray-900/40",children:[f.jsxs("div",{className:"mb-1 flex items-baseline gap-2",children:[f.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-300",children:"AI usage"}),f.jsx("span",{className:"text-[11px] text-gray-400",children:r?`${r} to date · credits`:"month to date · credits"})]}),t?f.jsx("div",{className:"h-16 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"}):n||!e?f.jsx("div",{className:"text-[11px] text-gray-400",children:"Usage isn’t available."}):(()=>{const s=e.allowanceCredits,a=s!=null,o=e.remainingCredits??0,l=a&&o<=0,u=a&&s>0?Math.min(100,Math.round(e.totalCredits/s*100)):0;return f.jsxs(f.Fragment,{children:[a&&f.jsxs("div",{className:"mb-2",children:[f.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[f.jsxs("div",{className:"text-[13px] font-semibold tabular-nums text-gray-800 dark:text-gray-100",children:[e.totalCredits.toLocaleString(),f.jsxs("span",{className:"text-gray-400",children:[" / ",s.toLocaleString()]})," ",f.jsx("span",{className:"text-[10px] font-normal text-gray-400",children:"cr"})]}),f.jsx("div",{className:`text-[11px] tabular-nums ${l?"font-medium text-amber-600 dark:text-amber-400":"text-gray-500 dark:text-gray-400"}`,children:l?"out of credits":`${o.toLocaleString()} left`})]}),f.jsx("div",{className:"mt-1 h-1.5 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",children:f.jsx("div",{className:`h-full rounded-full ${l?"bg-amber-500":"bg-violet-500"}`,style:{width:`${u}%`}})}),f.jsx("div",{className:"mt-1 text-[10px] text-gray-400",children:l?`Out of AI credits — resets ${iD(e.monthStart)}.`:`digest ≈ 9 cr · sprint ≈ 10 cr · resets ${iD(e.monthStart)}`})]}),f.jsxs("div",{className:"divide-y divide-gray-100 dark:divide-gray-800/60",children:[f.jsx(sD,{label:"Summaries",credits:e.summaryCredits,hint:"digests · sprint report · analyses"}),f.jsx(sD,{label:"Agentic tools",credits:e.agentCredits,hint:"Claude Review · AI Fix"})]}),!a&&f.jsxs("div",{className:"mt-1 flex items-baseline justify-between gap-3 border-t border-gray-200 pt-1.5 dark:border-gray-700",children:[f.jsx("div",{className:"text-[12px] font-semibold text-gray-700 dark:text-gray-200",children:"Total this month"}),f.jsxs("div",{className:"whitespace-nowrap text-base font-semibold tabular-nums text-violet-600 dark:text-violet-300",children:[e.totalCredits.toLocaleString()," ",f.jsx("span",{className:"text-[10px] font-normal text-gray-400",children:"cr"})]})]}),f.jsx("div",{className:"mt-1.5 text-[10px] text-gray-400",children:"An approximate measure of model usage across everything Pierre runs for you."})]})})()]})}const WIe={high:{border:"border-l-red-400 dark:border-l-red-500",dot:"bg-red-500"},warn:{border:"border-l-amber-400 dark:border-l-amber-500",dot:"bg-amber-500"},info:{border:"border-l-sky-400 dark:border-l-sky-500",dot:"bg-sky-500"}},GIe={stalled_review:"Stalled review",untouched_thread:"Untouched thread",reviewer_load:"Review load",reviewer_routing:"Needs a reviewer"};function aD(e){return e<48?`${e}h`:`${Math.round(e/24)}d`}function ef(e,t){const n=e.authorId!=null?t.get(e.authorId):void 0;return{id:e.prId,number:e.prNumber,title:e.prTitle,repoFullName:e.repoFullName,authorLogin:(n==null?void 0:n.githubLogin)??null,authorDisplayName:(n==null?void 0:n.displayName)??null,authorAvatarUrl:(n==null?void 0:n.avatarUrl)??null}}function Av({id:e,usersById:t}){const n=t.get(e);return f.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-gray-500/10 px-1.5 py-0.5 text-[11px]",children:[f.jsx(mi,{user:n,size:13}),f.jsx(wa,{user:n,fallbackId:e})]})}function rw({pr:e}){const t=e.ciStatus?ml[e.ciStatus]:null;return f.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-gray-500 dark:text-gray-400",children:[f.jsxs("span",{className:"inline-flex items-center gap-1",title:(t==null?void 0:t.label)??"no checks",children:[f.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:t?{background:t.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"},"aria-hidden":!0}),(t==null?void 0:t.label)??"no checks"]}),f.jsxs("span",{children:[e.changedFiles," file",e.changedFiles===1?"":"s"]}),f.jsxs("span",{className:"font-mono",children:[f.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.additions]})," ",f.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",e.deletions]})]})]})}function iw({prId:e}){const[t,n]=D.useState(!1);return f.jsxs("div",{className:"mt-2",children:[f.jsxs("button",{type:"button",onClick:()=>n(r=>!r),className:"text-[11px] font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:[t?"▾":"▸"," PR summary"]}),t&&f.jsx(VIe,{prId:e})]})}function VIe({prId:e}){const{data:t,isLoading:n}=jy(e);if(n)return f.jsx("div",{className:"mt-1 text-[11px] text-gray-400",children:"Loading…"});if(!t)return f.jsx("div",{className:"mt-1 text-[11px] text-gray-400",children:"Couldn’t load this PR."});const r=t.body!=null&&t.body.trim()!=="";return f.jsxs("div",{className:"mt-1 space-y-2 rounded border border-gray-200 bg-gray-50 p-2 dark:border-gray-800 dark:bg-gray-900/40",children:[r?f.jsx("div",{className:"max-h-64 overflow-auto text-sm",children:f.jsx(ss,{children:t.body})}):f.jsx("div",{className:"text-[11px] italic text-gray-400",children:"No PR description."}),f.jsx(jk,{pr:t})]})}function qIe({card:e}){const{data:t,isLoading:n}=Fk(e.threadId),{data:r}=Za(),s=D.useMemo(()=>ia(r),[r]),a=`https://github.com/${e.repoFullName}/pull/${e.prNumber}`;return n?f.jsx("div",{className:"px-1 py-2 text-xs text-gray-400",children:"Loading conversation…"}):t?f.jsx(Lm,{thread:t,usersById:s,prUrl:a,repoId:e.repoId}):f.jsx("div",{className:"px-1 py-2 text-xs text-gray-400",children:"Couldn’t load this conversation."})}function KIe({card:e,usersById:t}){var a;const n=WK(e.prId),r=e.suggestedReviewers.map(o=>o.userId),s=n.isSuccess;return f.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[f.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-gray-500",children:[f.jsx("span",{className:"font-medium",children:"Suggested reviewers"}),f.jsx("button",{type:"button",onClick:()=>n.mutate(r),disabled:n.isPending||s||r.length===0,className:"rounded border border-violet-300 px-1.5 py-0.5 font-medium text-violet-700 hover:bg-violet-50 disabled:opacity-50 dark:border-violet-700 dark:text-violet-300 dark:hover:bg-violet-900/20",title:"Request these reviewers on GitHub",children:s?"✓ Requested":n.isPending?"Assigning…":`Assign${r.length>1?" all":""}`})]}),f.jsx("ul",{className:"space-y-1",children:e.suggestedReviewers.map(o=>f.jsxs("li",{className:"flex flex-wrap items-center gap-1.5 text-[11px] text-gray-500",children:[f.jsx(Av,{id:o.userId,usersById:t}),f.jsx("span",{className:"text-gray-400",children:o.reason})]},o.userId))}),n.isError&&f.jsx("div",{className:"text-[11px] text-red-500",children:((a=n.error)==null?void 0:a.message)??"Couldn’t request reviewers."})]})}function cv({card:e,right:t,onActivate:n,children:r,innerRef:s,flash:a=!1}){const o=WIe[e.severity],l=n?u=>{u.target.closest("a,button,textarea,input,[data-noactivate]")||n()}:void 0;return f.jsxs("li",{ref:s,onClick:l,className:`rounded-lg border border-l-4 border-gray-200 bg-white p-3 dark:border-gray-800 dark:bg-gray-900/40 ${o.border}${a?" ring-2 ring-sky-400/70":""}${n?" cursor-pointer hover:bg-gray-50/70 dark:hover:bg-gray-900/60":""}`,children:[f.jsxs("div",{className:"mb-1.5 flex items-center gap-2 text-[11px]",children:[f.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${o.dot}`,"aria-hidden":!0}),f.jsx("span",{className:"font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:GIe[e.kind]}),f.jsx("span",{className:"ml-auto text-gray-400",children:t})]}),r]})}function sw({card:e,onOpen:t}){return f.jsxs("div",{className:"flex min-w-0 items-baseline gap-1.5 text-sm",children:[f.jsxs("button",{type:"button",onClick:t,className:"min-w-0 truncate text-left font-medium text-gray-800 hover:underline dark:text-gray-100",title:"Open this PR on its Overview tab",children:[f.jsxs("span",{className:"text-gray-400",children:[e.repoFullName," #",e.prNumber]})," ",e.prTitle]}),f.jsx("a",{href:e.githubUrl,target:"_blank",rel:"noreferrer noopener",onClick:n=>n.stopPropagation(),className:"shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",title:"Open on GitHub",children:"↗"})]})}function QIe(){var H,B,W;const e=Wt(M=>M.openPrDetailTab),t=Me(M=>M.showThreadInChanges),n=Me(M=>M.openMetricsDetail),{data:r,isLoading:s,isError:a}=PIe(!0),o=D.useMemo(()=>ia(r==null?void 0:r.users),[r==null?void 0:r.users]),l=Wt(M=>M.activityFlashItemId),u=Wt(M=>M.clearActivityFlashItem),d=D.useRef(new Map),[p,m]=D.useState(null);D.useEffect(()=>{if(l==null)return;const M=l,z=requestAnimationFrame(()=>{const K=d.current.get(M);K&&(K.scrollIntoView({block:"center",behavior:"smooth"}),m(M),window.setTimeout(()=>m(V=>V===M?null:V),1800)),u()});return()=>cancelAnimationFrame(z)},[l,u]);const g=(M,z)=>{z?d.current.set(M,z):d.current.delete(M)},{activityDigest:y}=zi(),{data:_}=pl(),S=D.useMemo(()=>(_??[]).filter(M=>M.inboxWatch).map(M=>M.id),[_]),E=ZCe(S,y&&S.length>0),N=W6(),[C,O]=D.useState(!1),I=(M,z)=>e(M,{fromActivity:!0,returnItemId:z}),F=M=>{e(ef(M,o),{fromActivity:!0,returnItemId:M.id}),t(M.prId,M.threadId)},P=(r==null?void 0:r.cards)??[];return f.jsxs("div",{className:"space-y-3","data-testid":"insights-view",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h2",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:"Insights"}),f.jsx("span",{className:"rounded bg-violet-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:"Pro"}),(r==null?void 0:r.sprint)&&f.jsxs("span",{className:"text-[11px] text-gray-400",children:["sprint: last ",((H=r.metrics)==null?void 0:H.sprintDays)??14,"d · ",P.length," item",P.length===1?"":"s"]}),f.jsx("div",{className:"ml-auto flex items-center gap-1.5",children:f.jsxs("button",{type:"button",onClick:()=>O(M=>!M),className:`rounded border px-1.5 py-0.5 text-[11px] font-medium ${C?"border-violet-300 bg-violet-50 text-violet-700 dark:border-violet-700 dark:bg-violet-950/30 dark:text-violet-300":"border-gray-300 hover:border-gray-400 dark:border-gray-700 dark:hover:border-gray-500"}`,title:"Show your month-to-date AI usage (in credits)",children:[C?"▾":"▸"," Track usage"]})})]}),C&&f.jsx(YIe,{}),(r==null?void 0:r.metrics)&&f.jsx(zIe,{metrics:r.metrics,onOpenMetric:n}),f.jsx(BIe,{digests:((B=E.data)==null?void 0:B.digests)??[],digestsLoading:E.isLoading,anyWatched:S.length>0,refreshingRepoIds:N.refreshingRepoIds,onRegenerateRepo:M=>N.mutate(M),onRegenerateAllDigests:S.length>0?()=>N.mutate(S):void 0,cascadeBusy:N.isPending}),f.jsx(Fm,{active:N.isPending&&(((W=N.progress)==null?void 0:W.total)??0)>0,label:"Regenerating summaries",...Y6(N.progress)}),s?f.jsx("div",{className:"space-y-3",children:[0,1,2].map(M=>f.jsx("div",{className:"h-20 animate-pulse rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900/40"},M))}):a?f.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load insights."}):P.length===0?f.jsxs("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:["Nothing needs attention across your watched repos right now. 🎉",f.jsx("div",{className:"mt-1 text-[11px]",children:"Stalled reviews, untouched threads, reviewer load and un-assigned PRs will surface here."})]}):f.jsx("ul",{className:"space-y-2",children:P.map(M=>{switch(M.kind){case"stalled_review":return f.jsxs(cv,{card:M,innerRef:z=>g(M.id,z),flash:p===M.id,right:`waiting ${aD(M.ageHours)}`,onActivate:()=>I(ef(M,o),M.id),children:[f.jsx(sw,{card:M,onOpen:()=>I(ef(M,o),M.id)}),f.jsx(rw,{pr:M}),f.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5 text-[11px] text-gray-500",children:[f.jsx("span",{children:"waiting on"}),M.requestedReviewerIds.length>0?M.requestedReviewerIds.map(z=>f.jsx(Av,{id:z,usersById:o},z)):f.jsx("span",{className:"italic",children:"no reviewer requested"})]}),f.jsx(iw,{prId:M.prId})]},M.id);case"untouched_thread":return f.jsxs(cv,{card:M,innerRef:z=>g(M.id,z),flash:p===M.id,right:`${aD(M.ageHours)} old`,children:[f.jsxs("div",{className:"-m-1 cursor-pointer rounded p-1 hover:bg-gray-50/70 dark:hover:bg-gray-900/60",onClick:z=>{z.target.closest("a,button")||F(M)},children:[f.jsx(sw,{card:M,onOpen:()=>I(ef(M,o),M.id)}),f.jsx(rw,{pr:M}),f.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5 text-[11px] text-gray-500",children:[f.jsx("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5 font-mono",children:M.path}),f.jsx("span",{children:"· no reply since"}),M.originalCommenterId!=null&&f.jsx(Av,{id:M.originalCommenterId,usersById:o})]})]}),f.jsx("div",{className:"mt-2",children:f.jsx(qIe,{card:M})}),f.jsx(iw,{prId:M.prId})]},M.id);case"reviewer_routing":return f.jsxs(cv,{card:M,innerRef:z=>g(M.id,z),flash:p===M.id,right:"unassigned",onActivate:()=>I(ef(M,o),M.id),children:[f.jsx(sw,{card:M,onOpen:()=>I(ef(M,o),M.id)}),f.jsx(rw,{pr:M}),M.topPaths.length>0&&f.jsxs("div",{className:"mt-1 truncate text-[11px] text-gray-400",children:["touches"," ",f.jsx("span",{className:"font-mono",children:M.topPaths.slice(0,3).join(", ")})]}),f.jsx(KIe,{card:M,usersById:o}),f.jsx(iw,{prId:M.prId})]},M.id);case"reviewer_load":return f.jsxs(cv,{card:M,innerRef:z=>g(M.id,z),flash:p===M.id,right:`${M.reviewsThisSprint} review${M.reviewsThisSprint===1?"":"s"} this sprint`,children:[f.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[f.jsx(Av,{id:M.reviewerId,usersById:o}),f.jsxs("span",{className:"font-semibold text-gray-800 dark:text-gray-100",children:[M.pendingCount," pending review",M.pendingCount===1?"":"s"]})]}),M.pendingPrs.length>0&&f.jsx("ul",{className:"mt-1.5 space-y-0.5",children:M.pendingPrs.map(z=>f.jsx("li",{className:"truncate text-[11px]",children:f.jsxs("button",{type:"button",onClick:()=>I({id:z.prId,number:z.prNumber,title:z.prTitle,repoFullName:z.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null},M.id),className:"text-left text-gray-500 hover:underline dark:text-gray-400",children:[f.jsxs("span",{className:"text-gray-400",children:[z.repoFullName," #",z.prNumber]})," ",z.prTitle]})},z.prId))})]},M.id);default:return null}})})]})}function oD({labels:e,series:t,formatValue:n=Wc,height:r=132}){const[s,a]=dg(),[o,l]=D.useState(null),u=30,d=8,p=8,m=16,g=e.length,y=Math.max(a-u-d,1),_=r-p-m,S=(B,W)=>B.values[W]??0,E=B=>t.reduce((W,M)=>W+S(M,B),0),N=nS(Math.max(1,...e.map((B,W)=>E(W)))),C=B=>u+(g<=1?y/2:B/(g-1)*y),O=B=>p+_*(1-B/N),I=p+_,F=[];{const B=e.map(()=>0);for(const W of t)F.push([...B]),e.forEach((M,z)=>B[z]=(B[z]??0)+S(W,z))}const P=(B,W)=>{const M=F[W],z=e.map((V,G)=>[C(G),O(M[G]+S(B,G))]),K=e.map((V,G)=>[C(G),O(M[G])]).reverse();return`M ${z.map(([V,G])=>`${V},${G}`).join(" L ")} L ${K.map(([V,G])=>`${V},${G}`).join(" L ")} Z`},H=B=>{const W=g<=1?0:Math.round((B.nativeEvent.offsetX-u)/y*(g-1));l(Math.max(0,Math.min(g-1,W)))};return f.jsxs("div",{children:[f.jsxs("div",{ref:s,className:"relative",style:{height:r},children:[a>0&&f.jsxs("svg",{width:a,height:r,className:"block",children:[[0,N].map(B=>f.jsxs("g",{children:[f.jsx("line",{x1:u,y1:O(B),x2:a-d,y2:O(B),className:"text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),f.jsx("text",{x:u-4,y:O(B)+3,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:Wc(B)})]},B)),t.map((B,W)=>f.jsx("path",{d:P(B,W),fill:B.color,opacity:.85},B.key)),o!=null&&f.jsx("line",{x1:C(o),y1:p,x2:C(o),y2:I,className:"text-gray-400 dark:text-gray-300",stroke:"currentColor",strokeWidth:1}),f.jsx("text",{x:u,y:r-4,className:"fill-gray-400 text-[8px]",children:e[0]?Dc(e[0]):""}),f.jsx("text",{x:a-d,y:r-4,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:e[g-1]?Dc(e[g-1]):""}),f.jsx("rect",{x:0,y:0,width:a,height:r,fill:"transparent",onMouseMove:H,onMouseLeave:()=>l(null)})]}),o!=null&&a>0&&f.jsxs(fg,{x:C(o),y:p,width:a,children:[f.jsx("div",{className:"font-medium",children:e[o]?Dc(e[o]):""}),t.map(B=>f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-[1px]",style:{background:B.color}}),B.label,": ",n(S(B,o))]},B.key)),f.jsxs("div",{className:"mt-0.5 border-t border-gray-200 pt-0.5 dark:border-gray-700",children:["total: ",n(E(o))]})]})]}),t.length>1&&f.jsx(xb,{series:t})]})}function XIe({points:e,xLabel:t,yLabel:n,formatX:r=Wc,formatY:s=Wc,fit:a=!1,height:o=150}){const[l,u]=dg(),[d,p]=D.useState(null),m=32,g=8,y=8,_=18,S=Math.max(u-m-g,1),E=o-y-_,N=M=>Math.log10(1+Math.max(0,M)),C=N(Math.max(1,...e.map(M=>M.x))),O=N(Math.max(1,...e.map(M=>M.y))),I=M=>m+N(M)/(C||1)*S,F=M=>y+E*(1-N(M)/(O||1)),P=M=>[0,1,10,100,1e3,1e4].filter(z=>N(z)<=M+.01),H=(()=>{if(!a)return null;const M=e.filter(Pe=>Pe.x>0&&Pe.y>0);if(M.length<4)return null;const z=M.map(Pe=>Math.log10(Pe.x)),K=M.map(Pe=>Math.log10(Pe.y)),V=M.length,G=z.reduce((Pe,se)=>Pe+se,0)/V,X=K.reduce((Pe,se)=>Pe+se,0)/V;let pe=0,ye=0;for(let Pe=0;Pe<V;Pe++)pe+=(z[Pe]-G)**2,ye+=(z[Pe]-G)*(K[Pe]-X);if(pe===0)return null;const Z=ye/pe,ee=X-Z*G,j=Math.min(...z),J=Math.max(...z);if(J<=j)return null;const he=24;let Y="";for(let Pe=0;Pe<=he;Pe++){const se=j+Pe/he*(J-j),Re=10**se,ot=10**(ee+Z*se);Y+=`${Pe===0?"M":" L"} ${I(Re).toFixed(1)} ${F(ot).toFixed(1)}`}return{d:Y,slope:Z}})(),B=M=>{const z=M.nativeEvent.offsetX,K=M.nativeEvent.offsetY;let V=-1,G=196;e.forEach((X,pe)=>{const ye=I(X.x)-z,Z=F(X.y)-K,ee=ye*ye+Z*Z;ee<G&&(G=ee,V=pe)}),p(V>=0?V:null)},W=d!=null?e[d]:null;return f.jsxs("div",{children:[f.jsxs("div",{ref:l,className:"relative",style:{height:o},children:[u>0&&f.jsxs("svg",{width:u,height:o,className:"block",children:[P(O).map(M=>f.jsxs("g",{children:[f.jsx("line",{x1:m,y1:F(M),x2:u-g,y2:F(M),className:"text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),f.jsx("text",{x:m-4,y:F(M)+3,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:s(M)})]},`y${M}`)),P(C).map(M=>f.jsx("text",{x:I(M),y:o-8,textAnchor:"middle",className:"fill-gray-400 text-[8px]",children:r(M)},`x${M}`)),e.map((M,z)=>f.jsx("circle",{cx:I(M.x),cy:F(M.y),r:d===z?4:2.2,fill:M.merged?on.green:on.gray,opacity:d==null||d===z?.75:.3},z)),H&&f.jsx("path",{d:H.d,fill:"none",stroke:on.amber,strokeWidth:1.5,strokeDasharray:"4 3",opacity:.95}),H&&f.jsxs("text",{x:m+5,y:y+9,fill:on.amber,className:"text-[8px] font-semibold",children:["≈ ",n," ∝ ",t,"^",H.slope.toFixed(1)]}),f.jsxs("text",{x:m,y:o-1,className:"fill-gray-400 text-[8px]",children:[t," →"]}),f.jsx("rect",{x:0,y:0,width:u,height:o,fill:"transparent",onMouseMove:B,onMouseLeave:()=>p(null)})]}),W&&u>0&&f.jsxs(fg,{x:I(W.x),y:F(W.y),width:u,children:[f.jsx("div",{className:"font-medium",children:W.label}),f.jsxs("div",{children:[t,": ",r(W.x)]}),f.jsxs("div",{children:[n,": ",s(W.y)]})]})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("span",{className:"text-[9px] text-gray-400",children:[n," (log) ↑"]}),f.jsx(xb,{series:[{label:"merged",color:on.green},{label:"closed",color:on.gray}]})]})]})}const aw=[1,2,3,4,5,6,0],ZIe=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],JIe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function e2e({cells:e,height:t}){const[n,r]=dg(),[s,a]=D.useState(null),o=26,l=2,u=14,p=Math.max(r-o-2,1)/24,m=t??l+7*u+14,g=Math.max(1,...e),y=S=>{const E=Math.floor((S.nativeEvent.offsetX-o)/p),N=Math.floor((S.nativeEvent.offsetY-l)/u);if(E<0||E>23||N<0||N>6){a(null);return}a({row:N,col:E})},_=(S,E)=>e[aw[S]*24+E]??0;return f.jsx("div",{children:f.jsxs("div",{ref:n,className:"relative",style:{height:m},children:[r>0&&f.jsxs("svg",{width:r,height:m,className:"block",children:[ZIe.map((S,E)=>f.jsx("text",{x:o-4,y:l+E*u+u-4,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:S},S)),aw.map((S,E)=>Array.from({length:24},(N,C)=>{const O=_(E,C),I=(s==null?void 0:s.row)===E&&(s==null?void 0:s.col)===C;return f.jsx("rect",{x:o+C*p,y:l+E*u,width:Math.max(p-1,1),height:u-1,rx:1.5,fill:O>0?on.blue:"currentColor",className:O>0?"":"text-gray-100 dark:text-gray-800",fillOpacity:O>0?.15+.85*(O/g):1,stroke:I?on.blue:"none",strokeWidth:I?1.5:0},`${E}-${C}`)})),[0,6,12,18].map(S=>f.jsxs("text",{x:o+S*p,y:m-3,className:"fill-gray-400 text-[8px]",children:[S,":00"]},S)),f.jsx("rect",{x:0,y:0,width:r,height:m,fill:"transparent",onMouseMove:y,onMouseLeave:()=>a(null)})]}),s&&r>0&&f.jsxs(fg,{x:o+s.col*p+p/2,y:l+s.row*u,width:r,children:[JIe[aw[s.row]]," ",String(s.col).padStart(2,"0"),":00 ·"," ",_(s.row,s.col)," events"]})]})})}const Kl=e=>e.reduce((t,n)=>t+n,0);function Sp({title:e,children:t}){return f.jsxs("div",{children:[f.jsx("h3",{className:"mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:e}),f.jsx("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:t})]})}function t2e({data:e}){const{data:t}=Za(),n=ia(t),r=e.weekBuckets,s=`${e.windowDays/7}-wk · weekly`,a=[{key:"opened",label:"Opened",color:on.blue,values:e.throughput.opened},{key:"merged",label:"Merged",color:on.green,values:e.throughput.merged},{key:"closed",label:"Closed",color:on.gray,values:e.throughput.closed}],o=[{key:"open",label:"Open",color:on.blue,values:e.backlog.open},{key:"stalled",label:"Stalled",color:on.orange,values:e.backlog.stalled}],l=[{key:"median",label:"Median to 1st review",color:on.blue,values:e.reviewLatencyTrend.medianHours}],u=[{key:"ttfr",label:"Open → 1st review",color:on.amber,values:e.cycleBreakdown.toFirstReview},{key:"rtm",label:"1st review → close",color:on.blue,values:e.cycleBreakdown.reviewToMerge}],d=[{key:"count",label:"PRs",color:on.blue,values:e.reviewLatencyDist.map(O=>O.count)}],p=e.reviewLatencyDist.map(O=>O.label),m=[{key:"untouched",label:ei.untouched.label,color:ei.untouched.color,values:e.threadMix.untouched},{key:"replied",label:ei.replied_unresolved.label,color:ei.replied_unresolved.color,values:e.threadMix.replied_unresolved},{key:"likely",label:ei.likely_addressed.label,color:ei.likely_addressed.color,values:e.threadMix.likely_addressed},{key:"resolved",label:ei.resolved.label,color:ei.resolved.color,values:e.threadMix.resolved}],g=[{key:"approved",label:"Approved",color:on.green,values:e.reviewVerdicts.approved},{key:"changes",label:"Changes requested",color:on.orange,values:e.reviewVerdicts.changes_requested},{key:"commented",label:"Commented",color:on.gray,values:e.reviewVerdicts.commented},{key:"dismissed",label:"Dismissed",color:on.slate,values:e.reviewVerdicts.dismissed}],y=e.reviewerLoad.map((O,I)=>({key:String(O.userId),label:O.userId===-1?"Others":jr(n.get(O.userId),O.userId),color:tD[I%tD.length],values:O.weekly})),_=[{key:"count",label:"PRs",color:on.purple,values:e.sizeDist.map(O=>O.count)}],S=e.sizeDist.map(O=>O.label),E=e.sizeVsCycle.map(O=>({x:O.loc,y:O.hoursOpen,label:`#${O.prNumber}`,merged:O.merged})),N=e.sizeCycleByBucket.map(O=>O.label),C=[{key:"median",label:"Median time open",color:on.teal,values:e.sizeCycleByBucket.map(O=>O.medianHours??0)}];return f.jsxs("div",{className:"space-y-4",children:[f.jsxs(Sp,{title:"Flow & throughput",children:[f.jsx(Ti,{title:"PR throughput",note:s,children:Kl(a.flatMap(O=>O.values))===0?f.jsx(fi,{}):f.jsx(nu,{labels:r,series:a,mode:"grouped"})}),f.jsx(Ti,{title:"Open backlog & stalled",note:"weekly snapshot",children:Math.max(0,...e.backlog.open)===0?f.jsx(fi,{}):f.jsx(xf,{labels:r,series:o,curved:!0})})]}),f.jsxs(Sp,{title:"Speed & latency",children:[f.jsx(Ti,{title:"Time to first review",note:"weekly median",children:e.reviewLatencyTrend.medianHours.every(O=>O==null)?f.jsx(fi,{}):f.jsx(xf,{labels:r,series:l,area:!0,formatY:_a,curved:!0})}),f.jsx(Ti,{title:"Cycle-time breakdown",note:"by close week",children:Kl(e.cycleBreakdown.count)===0?f.jsx(fi,{}):f.jsx(nu,{labels:r,series:u,mode:"stacked",formatY:_a})}),f.jsx(Ti,{title:"Review-latency distribution",note:"open → 1st review",children:Kl(d[0].values)===0?f.jsx(fi,{}):f.jsx(nu,{labels:p,series:d})})]}),f.jsxs(Sp,{title:"Review health",children:[f.jsx(Ti,{title:"Thread-resolution mix",note:"by thread created week",children:Kl(m.flatMap(O=>O.values))===0?f.jsx(fi,{}):f.jsx(oD,{labels:r,series:m})}),f.jsx(Ti,{title:"Review verdicts",note:s,children:Kl(g.flatMap(O=>O.values))===0?f.jsx(fi,{}):f.jsx(nu,{labels:r,series:g,mode:"stacked"})}),f.jsx(Ti,{title:"Reviews by reviewer",note:s,children:y.length===0?f.jsx(fi,{}):f.jsx(oD,{labels:r,series:y})})]}),f.jsxs(Sp,{title:"Size & risk",children:[f.jsx(Ti,{title:"PR size distribution",note:"opened, by LOC",children:Kl(_[0].values)===0?f.jsx(fi,{}):f.jsx(nu,{labels:S,series:_})}),f.jsx(Ti,{title:"Median time open by size",note:"PRs closed in window",children:Kl(e.sizeCycleByBucket.map(O=>O.count))===0?f.jsx(fi,{}):f.jsx(nu,{labels:N,series:C,formatY:_a,formatValue:_a})}),f.jsx(Ti,{title:"Size vs. time open",note:"log–log · power-law fit",children:E.length===0?f.jsx(fi,{}):f.jsx(XIe,{points:E,xLabel:"LOC",yLabel:"time open",formatX:Wc,formatY:_a,fit:!0})})]}),f.jsx(Sp,{title:"Cadence",children:f.jsx(Ti,{title:"Activity heatmap",note:"by weekday × hour (UTC)",children:Kl(e.activityHeatmap)===0?f.jsx(fi,{}):f.jsx(e2e,{cells:e.activityHeatmap})})})]})}function n2e({repoId:e,repoName:t,onClose:n}){const{data:r,isLoading:s,error:a}=rP(e);return D.useEffect(()=>{if(e==null)return;const o=l=>{l.key==="Escape"&&(l.stopImmediatePropagation(),n())};return window.addEventListener("keydown",o,!0),()=>window.removeEventListener("keydown",o,!0)},[e,n]),e==null?null:f.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4",onClick:n,role:"presentation",children:f.jsxs("div",{className:"flex max-h-[88vh] w-[60rem] max-w-[96vw] flex-col rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-900",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Repo analytics",children:[f.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("h2",{className:"truncate text-sm font-semibold",children:t??"Analytics"}),f.jsxs("p",{className:"text-[11px] text-gray-400",children:["Charts over the last ",r?r.windowDays/7:12," weeks"]})]}),f.jsx("button",{type:"button",onClick:n,className:"shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200","aria-label":"Close (Esc)",title:"Close (Esc)",children:"✕"})]}),f.jsxs("div",{className:"min-h-0 flex-1 overflow-auto px-4 py-3",children:[s&&!r&&f.jsx("div",{className:"py-12 text-center text-sm text-gray-500",children:"Loading analytics…"}),a&&f.jsx("div",{className:"py-12 text-center text-sm text-red-500",children:"Failed to load analytics."}),r&&f.jsx(t2e,{data:r})]})]})})}let lD=!1;function r2e(e){return[...e].sort((t,n)=>n.attentionCount!==t.attentionCount?n.attentionCount-t.attentionCount:t.hasUnread!==n.hasUnread?t.hasUnread?-1:1:t.repoFullName.localeCompare(n.repoFullName))}function i2e(){const[,e]=D.useState(0);D.useEffect(()=>{const t=window.setInterval(()=>e(n=>n+1),3e4);return()=>window.clearInterval(t)},[])}function s2e({fullName:e,maintainerCount:t,hasUnread:n,attentionCount:r,openPrs:s,threadTotals:a,selected:o,onSelect:l}){const u=a!=null||n||r>0||s!=null;return f.jsxs("button",{type:"button",onClick:l,"aria-pressed":o,className:`flex w-56 shrink-0 flex-col gap-0.5 rounded border-l-2 px-2 py-1.5 text-left text-xs md:w-full ${o?"border-sky-500 bg-sky-50 dark:bg-sky-950/30":"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800/50"}`,children:[f.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[f.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-gray-700 dark:text-gray-200",children:e}),t>0&&f.jsx(Lk,{})]}),u&&f.jsxs("span",{className:"flex items-center gap-1.5 pl-0.5",children:[n&&f.jsx("span",{"aria-hidden":"true",title:"New activity",className:"inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-sky-500"}),a!=null&&f.jsx(JT,{counts:a,compact:!0}),r>0&&f.jsxs("span",{className:"shrink-0 rounded bg-amber-500/15 px-1 text-[10px] font-semibold text-amber-600 dark:text-amber-400",title:"PRs needing attention",children:["⚠",r]}),f.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-gray-400",children:s==null?"":s>0?`[${s}]`:"[—]"})]})]})}function a2e(){i2e();const e=Me(C=>C.userIds),t=Me(C=>C.activityRepoId),n=Me(C=>C.setActivityRepo),{teamInsights:r}=zi(),{data:s,isFetching:a,isLoading:o}=c8(null,e),{data:l}=pl(),[u,d]=D.useState(null),p=D.useMemo(()=>r2e((s==null?void 0:s.repos)??[]),[s==null?void 0:s.repos]),m=typeof t=="number"?p.find(C=>C.repoId===t)??null:null,g=t==="feed"||t==null,y=t==="insights";D.useEffect(()=>{!lD&&r&&(lD=!0,Me.getState().activityRepoId==="feed"&&n("insights"))},[r,n]);const _=(s==null?void 0:s.generatedAt)??null,S=s!=null?p.map(C=>({repoId:C.repoId,fullName:C.repoFullName,maintainerCount:C.maintainerIds.length,hasUnread:C.hasUnread,attentionCount:C.attentionCount,openPrs:C.stats.openPrs,threadTotals:C.threadTotals})):(l??[]).map(C=>({repoId:C.id,fullName:C.fullName,maintainerCount:0,hasUnread:!1,attentionCount:0,openPrs:null,threadTotals:null})),E=s!=null&&p.length===0,N=(l??[]).length>0;return f.jsxs("div",{className:"flex h-full min-h-0 flex-col md:flex-row",children:[f.jsxs("div",{className:"flex flex-col border-b border-gray-200 md:w-72 md:shrink-0 md:border-b-0 md:border-r dark:border-gray-800",children:[f.jsx("div",{className:"flex items-center gap-2 border-b border-gray-200 px-3 py-2 dark:border-gray-800",children:f.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"State of play"})}),_!=null&&f.jsx("div",{className:"px-3 py-1 text-[10px] text-gray-400",title:new Date(_).toLocaleString(),children:Yr(_)}),a&&s!=null&&f.jsx("div",{className:"h-0.5 w-full overflow-hidden bg-sky-100 dark:bg-sky-950",children:f.jsx("div",{className:"h-full w-1/3 animate-pulse bg-sky-500"})}),f.jsxs("div",{className:`flex gap-1 overflow-x-auto p-2 md:min-h-0 md:flex-1 md:flex-col md:overflow-x-visible md:overflow-y-auto ${a&&s!=null?"opacity-60 transition-opacity":""}`,children:[r&&f.jsxs("button",{type:"button",onClick:()=>n("insights"),"aria-pressed":y,className:`flex w-56 shrink-0 items-center gap-1.5 rounded border-l-2 px-2 py-1.5 text-left text-xs md:w-full ${y?"border-sky-500 bg-sky-50 dark:bg-sky-950/30":"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800/50"}`,title:"Team review-intelligence across your watched repos (Pro)",children:[f.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-violet-500",children:"◈"}),f.jsx("span",{className:"min-w-0 flex-1 truncate font-semibold text-gray-700 dark:text-gray-200",children:"Insights"}),f.jsx("span",{className:"shrink-0 rounded bg-violet-500/10 px-1 text-[9px] font-semibold uppercase text-violet-600 dark:text-violet-300",children:"Pro"})]}),f.jsxs("button",{type:"button",onClick:()=>n("feed"),"aria-pressed":g,className:`flex w-56 shrink-0 items-center gap-1.5 rounded border-l-2 px-2 py-1.5 text-left text-xs md:w-full ${g?"border-sky-500 bg-sky-50 dark:bg-sky-950/30":"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800/50"}`,title:"A relevance-ranked stream across all your repos",children:[f.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-sky-500",children:"✦"}),f.jsx("span",{className:"min-w-0 flex-1 truncate font-semibold text-gray-700 dark:text-gray-200",children:"Feed"})]}),S.map(C=>f.jsx(s2e,{fullName:C.fullName,maintainerCount:C.maintainerCount,hasUnread:C.hasUnread,attentionCount:C.attentionCount,openPrs:C.openPrs,threadTotals:C.threadTotals,selected:t===C.repoId,onSelect:()=>n(C.repoId)},C.repoId)),f.jsx("div",{className:"mt-auto hidden flex-wrap gap-x-3 gap-y-0.5 px-1 pt-3 md:flex",children:["untouched","replied_unresolved","likely_addressed","resolved"].map(C=>f.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-400",title:ei[C].description,children:[f.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{background:ei[C].color}}),ei[C].label.toLowerCase()]},C))})]})]}),f.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-3",children:y?f.jsx(QIe,{}):E?f.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-sm text-gray-400",children:N?"No watched repos yet. Open the repos dropdown in the filter bar and toggle Watch on a repo to populate the Activity console.":"No repos yet. Add a repo from the filter bar to populate the Activity console."}):g?f.jsx(nw,{}):o&&s==null?f.jsx("div",{className:"space-y-3",children:[0,1,2].map(C=>f.jsx("div",{className:"h-24 animate-pulse rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900/40"},C))}):m!=null?f.jsxs("div",{className:"space-y-3","data-testid":"repo-console",children:[f.jsx(vIe,{repo:m}),f.jsx(yIe,{repoId:m.repoId,onOpenCharts:()=>d({repoId:m.repoId,name:m.repoFullName})}),f.jsx(bIe,{prs:m.prs,repoFullName:m.repoFullName}),f.jsx(nw,{repoId:m.repoId})]}):f.jsx(nw,{})}),f.jsx(n2e,{repoId:(u==null?void 0:u.repoId)??null,repoName:(u==null?void 0:u.name)??null,onClose:()=>d(null)})]})}function o2e(e){return gn({queryKey:["team-metrics-detail"],queryFn:()=>it.teamMetricsDetail(),enabled:e,refetchInterval:5*6e4,refetchIntervalInBackground:!1,staleTime:6e4})}function l2e({repos:e,selected:t,onChange:n}){const[r,s]=D.useState(!1),a=D.useRef(null);Do(a,()=>s(!1),r),D.useEffect(()=>{if(!r)return;const g=y=>{y.key==="Escape"&&(y.stopPropagation(),s(!1))};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[r]);const o=e.map(g=>g.id),l=o.length,u=t==null,d=g=>u||t.includes(g),p=g=>{const y=u?o:t,_=y.includes(g)?y.filter(S=>S!==g):[...y,g];n(_.length===l?null:_)},m=u?l:t.length;return f.jsxs("div",{ref:a,className:"relative",children:[f.jsxs("span",{className:"inline-flex items-center whitespace-nowrap rounded-full border border-gray-300 text-xs text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:[f.jsxs("button",{type:"button",onClick:()=>s(g=>!g),"aria-haspopup":"true","aria-expanded":r,className:`inline-flex items-center gap-1 py-0.5 pl-2.5 ${u?"pr-2.5":"pr-1"}`,children:[u?"All team repos":`Repos (${m}/${l})`,f.jsx("span",{"aria-hidden":!0,className:"text-[9px]",children:"▾"})]}),!u&&f.jsx("button",{type:"button",onClick:()=>n(null),title:"Show all team repos","aria-label":"Show all team repos",className:"py-0.5 pl-0.5 pr-2 opacity-60 hover:opacity-100",children:"✕"})]}),r&&f.jsxs("div",{role:"dialog","aria-label":"Filter by repo",className:"absolute right-0 top-full z-[60] mt-1 w-64 rounded-lg border border-gray-200 bg-white p-2 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[f.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs font-medium hover:bg-gray-100 dark:hover:bg-gray-800",children:[f.jsx("input",{type:"checkbox",checked:u,onChange:()=>n(null)}),f.jsx("span",{className:"text-gray-800 dark:text-gray-100",children:"All team repos"})]}),f.jsx("div",{className:"my-1 border-t border-gray-200 dark:border-gray-700"}),f.jsx("div",{className:"max-h-72 overflow-y-auto",children:l===0?f.jsx("div",{className:"px-1 py-2 text-xs text-gray-500",children:"No repos with data."}):e.map(g=>{const y=t!=null&&t.length===1&&t[0]===g.id;return f.jsxs("div",{className:"group flex items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[f.jsxs("label",{className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2",children:[f.jsx("input",{type:"checkbox",checked:d(g.id),onChange:()=>p(g.id)}),f.jsx("span",{className:"min-w-0 truncate text-gray-800 dark:text-gray-100",title:g.fullName,children:g.fullName})]}),l>1&&!y&&f.jsx("button",{type:"button",onClick:()=>n([g.id]),title:`Show only ${g.fullName}`,"aria-label":`Show only ${g.fullName}`,className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-gray-400 opacity-0 hover:bg-gray-200 hover:text-gray-700 focus:opacity-100 group-hover:opacity-100 dark:hover:bg-gray-700 dark:hover:text-gray-200",children:"only"})]},g.id)})})]})]})}const uD={open_prs:{label:"Open PRs",blurb:"All currently-open PRs · longest-open first"},merges:{label:"Merges",blurb:"Merged this sprint · newest first"},lead_time:{label:"Lead time",blurb:"Open → merge (merged + open) · longest first"},review_latency:{label:"Review latency",blurb:"Open → first review · longest first"},merge_ci:{label:"Merge CI",blurb:"Merged PRs · CI-failed-at-merge first"},ci_recovery:{label:"CI recovery",blurb:"Red → green · slowest first"},ci_red:{label:"CI red now",blurb:"Currently-failing branches · longest red first"}};function ow(e,t){if(!e)return[];switch(t){case"open_prs":return e.openPrs;case"merges":return e.merges;case"lead_time":return e.leadTime;case"review_latency":return e.reviewLatency;case"merge_ci":return e.mergeCi;case"ci_recovery":return e.ciRecovery;case"ci_red":return e.ciRed}}function u2e({ci:e}){const t=e?ml[e]:null;return f.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-gray-500 dark:text-gray-400",children:[f.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:t?{background:t.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"},"aria-hidden":!0}),(t==null?void 0:t.label)??"no checks"]})}function c2e({pr:e}){return f.jsxs("span",{className:"whitespace-nowrap text-[11px]",children:[f.jsxs("span",{className:"text-gray-400",children:[e.changedFiles,"f"]})," ",f.jsxs("span",{className:"font-mono text-green-600 dark:text-green-400",children:["+",e.additions]})," ",f.jsxs("span",{className:"font-mono text-red-500 dark:text-red-400",children:["−",e.deletions]})]})}function cD({id:e,usersById:t}){const n=e!=null?t.get(e):void 0;return f.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-gray-600 dark:text-gray-300",children:[f.jsx(mi,{user:n,size:14}),f.jsx(wa,{user:n,fallbackId:e??0})]})}function d2e({ids:e,usersById:t}){return e.length===0?f.jsx("span",{className:"text-[11px] italic text-gray-400",children:"none"}):f.jsx("span",{className:"flex flex-wrap gap-1",children:e.map(n=>{const r=t.get(n);return f.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-gray-500/10 px-1 py-0.5 text-[10px]",children:[f.jsx(mi,{user:r,size:11}),f.jsx(wa,{user:r,fallbackId:n})]},n)})})}function f2e(e){switch(e){case"open_prs":return"Open for";case"merges":case"lead_time":return"Lead time";case"review_latency":return"Latency";case"merge_ci":return"CI @ merge";case"ci_recovery":return"Recovery";case"ci_red":return"Red for"}}function h2e({m:e,pr:t}){const n=r=>r==null?"—":_a(r);switch(e){case"open_prs":case"merges":case"lead_time":return f.jsx("span",{className:"font-medium",children:n(t.leadTimeHours)});case"review_latency":return f.jsx("span",{className:"font-medium",children:n(t.reviewLatencyHours)});case"ci_recovery":return f.jsx("span",{className:"font-medium text-orange-600 dark:text-orange-400",children:n(t.recoveryHours)});case"ci_red":return f.jsx("span",{className:"font-medium text-red-500 dark:text-red-400",children:n(t.redAgeHours)});case"merge_ci":{const r=t.ciStatus==="failure"||t.ciStatus==="error";return f.jsx("span",{className:`font-medium ${r?"text-red-500 dark:text-red-400":"text-gray-500"}`,children:t.ciStatus??"—"})}}}function p2e({m:e,pr:t,usersById:n,onOpen:r}){const s=e==="review_latency",a=e==="merges"||e==="merge_ci";return f.jsxs("tr",{className:"border-t border-gray-100 align-top hover:bg-gray-50/70 dark:border-gray-800/60 dark:hover:bg-gray-900/40",children:[f.jsx("td",{className:"py-1.5 pr-3",children:f.jsxs("button",{type:"button",onClick:()=>r(t),className:"block max-w-md text-left hover:underline",title:`${t.repoFullName} #${t.prNumber} — ${t.prTitle}`,children:[f.jsxs("span",{className:"block truncate font-mono text-[11px] text-gray-400",children:[t.repoFullName," #",t.prNumber]}),f.jsx("span",{className:"block truncate text-sm font-medium text-gray-800 dark:text-gray-100",children:t.prTitle})]})}),f.jsx("td",{className:"py-1.5 pr-3",children:f.jsx(h2e,{m:e,pr:t})}),f.jsx("td",{className:"py-1.5 pr-3",children:f.jsx(u2e,{ci:t.ciStatus})}),f.jsx("td",{className:"py-1.5 pr-3",children:f.jsx(c2e,{pr:t})}),f.jsx("td",{className:"py-1.5 pr-3",children:f.jsx(cD,{id:t.authorId,usersById:n})}),f.jsx("td",{className:"py-1.5 pr-3 text-[11px] text-gray-500 dark:text-gray-400",children:s?f.jsx(d2e,{ids:t.reviewerIds,usersById:n}):a?f.jsx(cD,{id:t.mergedById,usersById:n}):Yr(t.openedAt)})]})}function m2e({m:e,rows:t,usersById:n,onOpen:r}){const s=e==="review_latency"?"Reviewers":e==="merges"||e==="merge_ci"?"Merged by":"Opened";return f.jsx("div",{className:"overflow-x-auto",children:f.jsxs("table",{className:"w-full min-w-[720px] border-collapse text-sm",children:[f.jsx("thead",{children:f.jsxs("tr",{className:"text-left text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:[f.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Pull request"}),f.jsx("th",{className:"pb-1 pr-3 font-semibold",children:f2e(e)}),f.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"CI"}),f.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Diff"}),f.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Author"}),f.jsx("th",{className:"pb-1 pr-3 font-semibold",children:s})]})}),f.jsx("tbody",{children:t.map(a=>f.jsx(p2e,{m:e,pr:a,usersById:n,onOpen:r},a.prId))})]})})}function g2e(){const e=Me(F=>F.metricsFocus),t=Me(F=>F.consumeMetricsFocus),n=Wt(F=>F.openPrDetailTab),{data:r,isLoading:s,isError:a,refetch:o,isFetching:l}=o2e(!0),{data:u}=Za(),d=D.useMemo(()=>ia(u),[u]),[p,m]=D.useState(e??"merges");D.useEffect(()=>{e&&(m(e),t())},[e,t]);const g=(r==null?void 0:r.detail)??null,[y,_]=D.useState({}),S=y[p]??null,E=F=>_(P=>({...P,[p]:F})),N=D.useMemo(()=>{const F=new Map;if(g)for(const P of zN)for(const H of ow(g,P))F.set(H.repoId,H.repoFullName);return[...F.entries()].map(([P,H])=>({id:P,fullName:H})).sort((P,H)=>P.fullName.localeCompare(H.fullName))},[g]),C=ow(g,p),O=S==null?C:C.filter(F=>S.includes(F.repoId)),I=F=>{const P=F.authorId!=null?d.get(F.authorId):void 0,H={id:F.prId,number:F.prNumber,title:F.prTitle,repoFullName:F.repoFullName,authorLogin:(P==null?void 0:P.githubLogin)??null,authorDisplayName:(P==null?void 0:P.displayName)??null,authorAvatarUrl:(P==null?void 0:P.avatarUrl)??null};n(H)};return f.jsxs("div",{className:"mx-auto max-w-6xl space-y-4 p-4",children:[f.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[f.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:"Flow metrics"}),f.jsx("span",{className:"rounded bg-violet-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:"Pro"}),g&&f.jsx("span",{className:"text-[11px] text-gray-400",children:"sprint: last 2 weeks · where issues cluster"}),f.jsxs("button",{type:"button",onClick:()=>void o(),disabled:l,className:"ml-auto rounded border border-gray-300 px-1.5 py-0.5 text-[11px] font-medium hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:[f.jsx("span",{"aria-hidden":!0,className:l?"animate-spin":"",children:"↻"})," ","Refresh"]})]}),f.jsx("div",{role:"tablist",className:"flex flex-wrap gap-1 border-b border-gray-200 dark:border-gray-800",children:zN.map(F=>{const P=F===p,H=ow(g,F).length;return f.jsxs("button",{type:"button",role:"tab","aria-selected":P,onClick:()=>m(F),className:`-mb-px rounded-t-md border border-b-0 px-3 py-1.5 text-xs font-medium ${P?"border-gray-300 bg-white text-violet-600 dark:border-gray-700 dark:bg-gray-950 dark:text-violet-300":"border-transparent text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-900/60"}`,children:[uD[F].label,g?f.jsx("span",{className:"ml-1 text-gray-400",children:H}):null]},F)})}),f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsx("div",{className:"text-[11px] text-gray-400",children:uD[p].blurb}),O.length!==C.length&&f.jsxs("span",{className:"text-[11px] text-gray-400",children:["· ",O.length," of ",C.length]}),f.jsx("div",{className:"ml-auto",children:f.jsx(l2e,{repos:N,selected:S,onChange:E})})]}),s?f.jsx("div",{className:"space-y-2",children:[0,1,2,3].map(F=>f.jsx("div",{className:"h-8 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"},F))}):a?f.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load the metric detail."}):O.length===0?f.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:C.length===0?"Nothing to show for this metric in the current sprint. 🎉":"No PRs for the selected repos — adjust the repo filter."}):f.jsx(m2e,{m:p,rows:O,usersById:d,onOpen:I})]})}function v2e(){const e=Me(d=>d.selectedPrId),t=Me(d=>d.selectedThreadId),n=Me(d=>d.clearSelection),r=D.useDeferredValue(e),s=e??r,a=Wt(d=>d.activeTab),o=ik(a),l=(o==null?void 0:o.kind)==="pr-detail"?o.prId:null,u=s!=null&&s!==l;return f.jsxs("div",{className:"relative h-full","data-testid":"detail-pane",children:[e!=null&&f.jsx("div",{className:"absolute right-2 top-1.5 z-10 flex items-center gap-2",children:f.jsx("button",{type:"button","data-testid":"detail-clear",onClick:n,className:"rounded px-2 py-0.5 text-xs text-gray-400 hover:text-gray-600",title:"Clear selection (Esc)",children:"✕"})}),u?f.jsx(ML,{prId:s,selectedThreadId:t},s):f.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-sm text-gray-400",children:"Select a PR on the timeline to see its details — your relevance-ranked state of play lives in the Activity."})]})}const ej="pierre:notifications",lw="pierre:notif-pref";function dD(){try{return localStorage.getItem(ej)==="1"}catch{return!1}}function tj(){const[e,t]=D.useState(dD);D.useEffect(()=>{const r=()=>t(dD());return window.addEventListener(lw,r),window.addEventListener("storage",r),()=>{window.removeEventListener(lw,r),window.removeEventListener("storage",r)}},[]);const n=D.useCallback(r=>{try{localStorage.setItem(ej,r?"1":"0")}catch{}t(r),window.dispatchEvent(new Event(lw))},[]);return[e,n]}function y2e(e){if(e.length===0||typeof Notification>"u"||Notification.permission!=="granted")return;const t=e.length===1?"Claude review ready":`${e.length} Claude reviews ready`,n=e.length===1?`${e[0].repoFullName} #${e[0].prNumber}`:e.slice(0,3).map(r=>`${r.repoFullName} #${r.prNumber}`).join(" · ");try{const r=new Notification(t,{body:n,tag:"pierre-claude-review"});r.onclick=()=>{window.focus(),r.close()}}catch{}}const b2e={cloning:"Cloning",fetching_diff:"Fetching diff",deciding:"Deciding scope",reviewing:"Reviewing",persisting:"Saving findings"};function x2e(){const e=zi().claudeReview,t=Me(I=>I.claudeReviewKickoff),n=Me(I=>I.openClaudeReview),[r]=tj(),s=D.useRef(r);s.current=r;const[a,o]=D.useState(!1);D.useEffect(()=>{t>0&&o(!0)},[t]);const{data:l,dataUpdatedAt:u}=rX(e&&a);D.useEffect(()=>{a&&((l==null?void 0:l.reviews.length)??0)===0&&o(!1)},[u]);const[d,p]=D.useState({}),[m,g]=D.useState({}),y=D.useRef(null),_=((l==null?void 0:l.reviews)??[]).map(I=>`${I.reviewId}:${I.phase??""}`).join(",");D.useEffect(()=>{const I=(l==null?void 0:l.reviews)??[],F=new Set(I.map(H=>H.reviewId)),P=y.current;if(P!=null){const H=[];for(const[B,W]of P)F.has(B)||H.push(W);H.length>0&&(VQ(),s.current&&y2e(H))}y.current=new Map(I.map(H=>[H.reviewId,{repoFullName:H.repoFullName,prNumber:H.prNumber,prTitle:H.prTitle}])),p(H=>{const B={...H};for(const W of I)B[W.reviewId]={reviewId:W.reviewId,prId:W.prId,repoFullName:W.repoFullName,prNumber:W.prNumber,prTitle:W.prTitle,phase:W.phase,done:!1};for(const W of Object.values(B))!F.has(W.reviewId)&&!W.done&&(B[W.reviewId]={...W,done:!0});return B})},[_]);const S=Object.values(d).filter(I=>!m[I.reviewId]);if(!e||S.length===0)return null;const E=S.filter(I=>!I.done),N=E.length===0,C=()=>{g(I=>{const F={...I};for(const P of S)F[P.reviewId]=!0;return F})},O=I=>g(F=>({...F,[I]:!0}));return f.jsx("div",{className:"pointer-events-none fixed bottom-4 right-4 z-50 flex w-80 max-w-[calc(100vw-2rem)] flex-col gap-2",children:f.jsxs("div",{className:"pointer-events-auto rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[f.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 px-3 py-1.5 dark:border-gray-800",children:[f.jsxs("span",{className:"text-xs font-semibold",children:["Claude reviews",E.length>0&&f.jsxs("span",{className:"ml-1 font-normal text-gray-400",children:["· ",E.length," running"]})]}),N&&f.jsx("button",{type:"button",onClick:C,className:"text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:"Dismiss all"})]}),f.jsx("ul",{className:"max-h-64 divide-y divide-gray-100 overflow-auto dark:divide-gray-800",children:S.map(I=>f.jsxs("li",{className:"px-3 py-2 text-xs",children:[f.jsxs("button",{type:"button",onClick:()=>n({id:I.prId,number:I.prNumber,title:I.prTitle,repoFullName:I.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null}),className:"block w-full text-left",title:"Open this review",children:[f.jsxs("div",{className:"flex items-center gap-1.5",children:[I.done?f.jsx("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full bg-green-500"}):f.jsx("span",{className:"inline-block h-2.5 w-2.5 shrink-0 animate-spin rounded-full border-2 border-gray-300 border-t-blue-500"}),f.jsxs("span",{className:"truncate font-medium text-blue-600 hover:underline dark:text-blue-400",children:[I.repoFullName," #",I.prNumber]})]}),f.jsx("div",{className:"mt-0.5 truncate text-gray-500",children:I.prTitle}),f.jsx("div",{className:"mt-0.5 text-gray-400",children:I.done?"Ready — click to view":`${I.phase!=null?b2e[I.phase]??I.phase:"Starting"}…`})]}),I.done&&f.jsx("div",{className:"mt-1 text-right",children:f.jsx("button",{type:"button",onClick:()=>O(I.reviewId),className:"text-[11px] text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:"dismiss"})})]},I.reviewId))})]})})}function _2e({repos:e,statuses:t,cancelling:n,onCancel:r}){const s=u=>t==null?void 0:t.find(d=>d.repoId===u),a=u=>{if(t===void 0)return!0;const d=s(u);return d===void 0||d.status==="running"},o=e.filter(u=>!a(u.id)).length,l=e.length>0&&o===e.length;return f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",role:"presentation",children:f.jsxs("div",{className:"w-[28rem] max-w-[90vw] rounded-lg border border-gray-200 bg-white p-4 shadow-xl dark:border-gray-700 dark:bg-gray-900",role:"dialog","aria-modal":"true","aria-label":"Sync progress",children:[f.jsx("div",{className:"mb-3 flex items-center justify-between",children:f.jsx("h2",{className:"text-sm font-semibold",children:n?"Cancelling…":e.length===0?"Starting sync…":l?"Sync complete":`Syncing ${e.length} repo${e.length===1?"":"s"}`})}),f.jsx("ul",{className:"space-y-3",children:e.map(u=>{var _,S;const d=s(u.id),p=a(u.id),m=(d==null?void 0:d.status)==="error",g=((_=d==null?void 0:d.progress)==null?void 0:_.prsProcessed)??0,y=p?Math.round((((S=d==null?void 0:d.progress)==null?void 0:S.percent)??0)*100):100;return f.jsxs("li",{children:[f.jsxs("div",{className:"mb-1 flex items-baseline justify-between gap-2 text-xs",children:[f.jsx("span",{className:"truncate font-medium",title:u.fullName,children:u.fullName}),f.jsx("span",{className:"shrink-0 text-gray-500",children:m?f.jsx("span",{className:"text-red-500",children:"error"}):p?`${y}%${g>0?` · ${g} PRs`:""}`:f.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["✓ done",g>0?` · ${g} PRs`:""]})})]}),f.jsx("div",{className:"h-2 w-full overflow-hidden rounded bg-gray-200 dark:bg-gray-800",children:f.jsx("div",{className:`h-2 rounded transition-all duration-500 ${m?"bg-red-500":p?"bg-blue-500":"bg-green-500"}`,style:{width:`${m?100:y}%`}})})]},u.id)})}),f.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 text-xs text-gray-500",children:[f.jsxs("span",{children:[o," of ",e.length," repo",e.length===1?"":"s"," complete"]}),f.jsx("button",{type:"button",onClick:r,disabled:n,title:"Stop the sync and remove any repos still loading for the first time",className:"rounded border border-red-300 px-3 py-1 text-red-600 hover:border-red-400 hover:bg-red-50 disabled:opacity-50 dark:border-red-900 dark:text-red-400 dark:hover:bg-red-950",children:n?"Cancelling…":"Cancel"})]})]})})}function w2e(e){let t=null;for(const n of e){const r=n.lastIncrementalSyncAt??n.lastFullSyncAt;r&&(!t||r>t)&&(t=r)}return t}const fD=5,hD=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});function E2e(e){const t=new Date,n=new Date(t);return n.setSeconds(0,0),n.setMinutes(Math.floor(t.getMinutes()/e)*e+e),n}function k2e(e){const t=E2e(fD),n=Math.max(1,Math.round((t.getTime()-Date.now())/6e4)),r=e?[`Last synced ${hD(new Date(e))}`]:[];return r.push(`Syncs automatically every ${fD} minutes`),r.push(`Next sync ~${hD(t)} (in ${n} min)`),r.join(`
|
|
1390
|
-
`)}function T2e(){const e=nn(),[t,n]=D.useState(!1),[r,s]=D.useState(!1),[a,o]=D.useState(!1),[l,u]=D.useState(!1),[d,p]=D.useState([]),{data:m}=gn({queryKey:["repos"],queryFn:it.listRepos,refetchInterval:t?3e3:3e4}),g=(m??[]).map(ee=>ee.id).join(","),{data:y}=gn({queryKey:["sync-status",g],enabled:t&&!!m&&m.length>0,queryFn:()=>Promise.all((m??[]).map(ee=>it.syncStatus(ee.id))),refetchInterval:1500}),_=new Set(d),S=_.size===0?m??[]:(m??[]).filter(ee=>_.has(ee.id)),E=new Set(S.map(ee=>ee.id)),N=y==null?void 0:y.filter(ee=>E.has(ee.repoId)),C=(N??[]).filter(ee=>ee.status==="running"),O=C.length,I=O>0&&C.every(ee=>{var j;return((j=ee.progress)==null?void 0:j.foregroundComplete)===!0}),F=w2e(m??[]),P=D.useRef(F),H=D.useRef(!1),B=D.useRef(null),W=()=>{B.current!=null&&(clearTimeout(B.current),B.current=null)},M=()=>{o(!1),H.current=!1,W()};D.useEffect(()=>W,[]);const z=()=>{e.invalidateQueries({queryKey:["timeline"]}),e.invalidateQueries({queryKey:["open-prs"]}),e.invalidateQueries({queryKey:["users"]}),e.invalidateQueries({queryKey:["mergers"]}),e.invalidateQueries({queryKey:["my-turn"]}),e.invalidateQueries({queryKey:["me"]});for(const ee of ck)e.invalidateQueries({queryKey:[ee]})};D.useEffect(()=>{P.current!==F&&(P.current=F,z())},[F]),D.useEffect(()=>{!t||!I||H.current||(H.current=!0,s(!1),z())},[t,I]),D.useEffect(()=>{O>0&&o(!0)},[O]),D.useEffect(()=>{t&&a&&y&&O===0&&(n(!1),o(!1),z(),W(),B.current=setTimeout(()=>{s(!1),B.current=null},1e3))},[t,a,y,O]);const K=Me(ee=>ee.syncModalSignal),V=Me(ee=>ee.syncModalRepoId),G=D.useRef(K);if(D.useEffect(()=>{K!==G.current&&(G.current=K,V!=null&&(r?p(ee=>ee.includes(V)?ee:[...ee,V]):(p([V]),s(!0),n(!0),M()),e.invalidateQueries({queryKey:["repos"]}),e.invalidateQueries({queryKey:["sync-status"]})))},[K,e]),!m||m.length===0)return null;const X=m.find(ee=>ee.lastSyncStatus==="error"),pe=async(ee=!1)=>{n(!0),s(!0),p([]),M(),await Promise.allSettled(m.map(j=>it.syncRepo(j.id,ee))),e.invalidateQueries({queryKey:["repos"]}),e.invalidateQueries({queryKey:["sync-status"]})},ye=async()=>{u(!0),W();const ee=(N??[]).filter(J=>J.status==="running").map(J=>J.repoId),j=ee.length?ee:S.map(J=>J.id);await Promise.allSettled(j.map(J=>it.cancelSync(J))),n(!1),o(!1),u(!1),s(!1),e.invalidateQueries({queryKey:["repos"]}),z()},Z=I?"loading older history…":O>0?`syncing ${O} repo${O===1?"":"s"}…`:"syncing…";return f.jsxs(f.Fragment,{children:[r&&f.jsx(_2e,{repos:S,statuses:N,cancelling:l,onCancel:()=>void ye()}),f.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[X?f.jsxs("span",{className:"text-red-500",title:X.lastSyncError??"",children:["sync error: ",X.fullName]}):f.jsx("span",{className:"cursor-help",title:k2e(F),children:t?Z:F?`synced ${Yr(F)}`:"not synced yet"}),f.jsx("button",{type:"button",onClick:()=>void pe(!1),disabled:t,className:"rounded border border-gray-300 px-2 py-0.5 hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:"Sync now"}),f.jsx("button",{type:"button",onClick:()=>{window.confirm("Deep re-sync re-fetches the full backfill window for every repo. Slower, but catches CI/thread changes the incremental sync can lag. Continue?")&&pe(!0)},disabled:t,className:"rounded px-1.5 py-0.5 text-gray-400 hover:text-gray-600 disabled:opacity-50",title:"Force a full backfill for all repos",children:"deep"})]})]})}function S2e(){const e=Me(I=>I.searchQuery),t=Me(I=>I.setSearchQuery),n=Wt(I=>I.openPrFocusTab),{data:r}=ok(),{data:s}=lk(),{data:a}=pl(),{data:o}=Za(),[l,u]=D.useState(!1),[d,p]=D.useState(-1),m=D.useRef(null),g=D.useMemo(()=>{const I=new Map;for(const F of a??[])I.set(F.id,F.fullName);return I},[a]),y=D.useMemo(()=>ia(o),[o]),_=D.useMemo(()=>{const I=new Map;for(const F of(r==null?void 0:r.prs)??[])I.set(F.id,F);for(const F of(s==null?void 0:s.prs)??[])I.has(F.id)||I.set(F.id,F);return[...I.values()]},[r,s]),S=D.useMemo(()=>{const I=e.trim().toLowerCase();if(!I)return[];const F=I.replace(/^#/,""),P=F.length>0&&/^\d+$/.test(F),H=_.filter(B=>B.title.toLowerCase().includes(I)||P&&String(B.number).includes(F));if(P){const B=W=>{const M=String(W.number);return M===F?0:M.startsWith(F)?1:M.includes(F)?2:3};H.sort((W,M)=>B(W)-B(M))}return H.slice(0,30)},[_,e]),E=l&&e.trim().length>0,N=d>=0&&d<S.length?S[d].id:null;Do(m,()=>u(!1),E),D.useEffect(()=>{var I,F;N!=null&&((F=(I=m.current)==null?void 0:I.querySelector(`#pr-result-${N}`))==null||F.scrollIntoView({block:"nearest"}))},[N]);const C=I=>{if(!I)return;const F=I.authorId!=null?y.get(I.authorId):void 0;n({id:I.id,number:I.number,title:I.title,repoFullName:g.get(I.repoId)??`repo ${I.repoId}`,authorLogin:(F==null?void 0:F.githubLogin)??null,authorDisplayName:(F==null?void 0:F.displayName)??null,authorAvatarUrl:(F==null?void 0:F.avatarUrl)??null}),u(!1)},O=I=>{if(I.key==="Escape"){u(!1),I.target.blur();return}!E||S.length===0||(I.key==="ArrowDown"?(I.preventDefault(),p(F=>(F+1)%S.length)):I.key==="ArrowUp"?(I.preventDefault(),p(F=>F<=0?S.length-1:F-1)):I.key==="Enter"&&(I.preventDefault(),C(S[d>=0?d:0])))};return f.jsxs("div",{ref:m,className:"relative",children:[f.jsx("input",{type:"search",value:e,placeholder:"Search PRs (title or number)…",onChange:I=>{t(I.target.value),p(-1),u(!0)},onFocus:()=>u(!0),onKeyDown:O,role:"combobox","aria-expanded":E,"aria-controls":"pr-search-results","aria-autocomplete":"list","aria-activedescendant":N!=null?`pr-result-${N}`:void 0,"aria-label":"Search PRs by title or number",className:"w-56 rounded border border-gray-300 bg-transparent px-2 py-0.5 text-xs focus:border-blue-500 focus:outline-none dark:border-gray-700"}),E&&f.jsx("div",{id:"pr-search-results",role:"listbox","aria-label":"PR search results",className:"absolute right-0 top-full z-[60] mt-1 max-h-80 w-80 overflow-y-auto rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-900",children:S.length===0?f.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:"No matching PRs."}):S.map((I,F)=>{const P=I.authorId!=null?y.get(I.authorId):void 0;return f.jsxs("button",{id:`pr-result-${I.id}`,type:"button",role:"option","aria-selected":F===d,onMouseEnter:()=>p(F),onClick:()=>C(I),className:`flex w-full flex-col gap-0.5 px-3 py-1.5 text-left ${F===d?"bg-gray-100 dark:bg-gray-800":""} hover:bg-gray-100 dark:hover:bg-gray-800`,children:[f.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-400",children:[f.jsx(mi,{user:P,size:12}),f.jsx("span",{className:"truncate",title:jr(P,I.authorId),children:jr(P,I.authorId)}),f.jsx("span",{"aria-hidden":!0,children:"·"}),f.jsxs("span",{className:"shrink-0",children:[g.get(I.repoId)??`repo ${I.repoId}`," · #",I.number]})]}),f.jsx("span",{className:"truncate text-xs",title:I.title,children:I.title})]},I.id)})})]})}function N2e(){const{data:e}=uk(),t=zi().feedMyTurn,n=Wt(m=>m.activeTab),r=Wt(m=>m.showActivity),s=Me(m=>m.setActivityRepo),a=Me(m=>m.setFeedMyTurnOnly),[o,l]=D.useState(!1);if(!t||o||!(e!=null&&e.user)||n==="activity")return null;const u=e.newFeedItems??0;if(u<=0)return null;const d=e.feedLastSeenAt,p=()=>{s("feed"),a(!0),r(),l(!0)};return f.jsxs("div",{className:"flex items-center gap-2 border-b border-amber-200 bg-amber-50 px-4 py-1.5 text-xs text-amber-800 dark:border-amber-900/50 dark:bg-amber-900/20 dark:text-amber-200",children:[f.jsxs("button",{type:"button",onClick:p,title:"Show your feed",className:"flex min-w-0 flex-1 items-center gap-2 text-left hover:underline",children:[f.jsx("span",{className:"font-medium",children:"Welcome back"}),f.jsxs("span",{className:"min-w-0 truncate text-amber-700/80 dark:text-amber-300/80",children:["· ",u," new item",u===1?"":"s"," in your feed",d?` since you were last here ${Yr(d)}`:""]})]}),f.jsx("button",{type:"button",onClick:p,className:"shrink-0 rounded border border-amber-400 px-2 py-0.5 font-medium hover:bg-amber-100 dark:border-amber-700 dark:hover:bg-amber-900/40",children:"Show feed"}),f.jsx("button",{type:"button",onClick:()=>l(!0),"aria-label":"Dismiss",title:"Dismiss",className:"shrink-0 rounded px-1 text-amber-500 hover:text-amber-700 dark:hover:text-amber-300",children:"✕"})]})}function C2e({onClose:e}){return D.useEffect(()=>{const t=n=>{n.key==="Escape"&&(n.stopImmediatePropagation(),e())};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[e]),f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:e,role:"presentation",children:f.jsxs("div",{className:"flex max-h-[80vh] w-[34rem] max-w-[92vw] flex-col rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-900",onClick:t=>t.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Pierre help",children:[f.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[f.jsx("h2",{className:"brand-title",children:"Pierre"}),f.jsx("button",{type:"button",onClick:e,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-200","aria-label":"Close (Esc)",title:"Close (Esc)",children:"✕"})]}),f.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto px-4 py-3 text-sm leading-relaxed text-gray-600 dark:text-gray-300",children:[f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"A local dashboard for your team’s GitHub pull-request activity across repos, drawn as an interactive timeline. Everything runs on your machine."}),f.jsxs(Ql,{title:"Track repositories",children:["Add repos in the filter bar’s ",f.jsx("em",{children:"add repo"})," box as ",f.jsx(I2e,{children:"owner/name"}),". Pierre syncs their PR activity every few minutes into a local file — nothing leaves your machine."]}),f.jsxs(Ql,{title:"Read the timeline",children:["Rows are grouped ",f.jsx("strong",{children:"repo → contributor"}),". Each PR is a bar; the markers beneath it are events — commits, comments, reviews. Scroll to pan, hold the zoom key while scrolling to zoom. Click a marker for its details, or a PR bar to select it."]}),f.jsxs(Ql,{title:"Focus mode",children:["To isolate one PR and just its contributors: double-click its bar, click"," ",f.jsx("strong",{children:"Focus"})," in the detail pane, or click a cross-person marker. Leave focus with the ",f.jsx("strong",{children:"✕"})," on the header"," ",f.jsx("strong",{children:"Focus mode"})," badge, ",f.jsx(tf,{children:"Esc"}),", or the browser"," ",f.jsx("strong",{children:"Back"})," button."]}),f.jsxs(Ql,{title:"Detail pane",children:["Selecting a PR opens the bottom pane with ",f.jsx("strong",{children:"Overview"})," (checks, summary, comments), ",f.jsx("strong",{children:"Threads"}),", and ",f.jsx("strong",{children:"Activity"}),". The ",f.jsx("em",{children:"Show"})," links jump back to that moment on the timeline; drag the divider to resize the pane."]}),f.jsxs(Ql,{title:"Filter",children:["Narrow by date range, members (auto-scoped to who’s active in view), event categories, and thread states. ",f.jsx("em",{children:"Exclude bots"})," hides renovate / dependabot / CI noise."]}),f.jsxs(Ql,{title:"Open-PRs strip",children:["The collapsible strip up top lists currently-open PRs — toggle between"," ",f.jsx("strong",{children:"all"}),", ",f.jsx("strong",{children:"my turn"}),", and"," ",f.jsx("strong",{children:"needs attention"}),"."]}),f.jsxs(Ql,{title:"Activity & Insights",children:["Clicking an item in the ",f.jsx("strong",{children:"Activity Feed"})," opens that PR's detail tab, where ",f.jsx("strong",{children:"Show"})," / ",f.jsx("strong",{children:"Focus"})," drive the timeline; the feed's ",f.jsx("strong",{children:"My Turn only"})," toggle narrows it to what needs you."," ",f.jsx("strong",{children:"Insights"})," opens a per-repo snapshot (open / merged / stalled, time-to-first-review, review load). Save filter combinations as named ",f.jsx("strong",{children:"Views"}),", and use the bell to get notified when something new lands in your queue."]}),f.jsxs(Ql,{title:"Keyboard",children:[f.jsx(tf,{children:"/"})," focus the filter · ",f.jsx(tf,{children:"j"}),"/",f.jsx(tf,{children:"k"})," cycle PRs ·"," ",f.jsx(tf,{children:"i"})," Insights · ",f.jsx(tf,{children:"Esc"})," exit focus, else clear the selection."]})]})]})})}function Ql({title:e,children:t}){return f.jsxs("section",{children:[f.jsx("h3",{className:"mb-1 font-semibold text-gray-800 dark:text-gray-100",children:e}),f.jsx("p",{children:t})]})}function I2e({children:e}){return f.jsx("code",{className:"rounded bg-gray-100 px-1 font-mono text-[12px] text-gray-700 dark:bg-gray-800 dark:text-gray-300",children:e})}function tf({children:e}){return f.jsx("kbd",{className:"rounded border border-gray-300 bg-gray-100 px-1 text-[11px] font-medium text-gray-600 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",children:e})}function A2e(){const e=zi();return e.teamInsights||e.activityDigest||e.slackDigest||e.issueLinks}function R2e(e){return gn({queryKey:["pro-settings"],queryFn:it.proSettings,enabled:e,staleTime:6e4})}function O2e(){const e=nn();return kn({mutationFn:t=>it.updateProSettings(t),onSuccess:(t,n)=>{e.setQueryData(["pro-settings"],t),n.issue&&(e.invalidateQueries({queryKey:["pr"]}),e.invalidateQueries({queryKey:["thread"]})),n.sprint&&(e.invalidateQueries({queryKey:["team-insights"]}),e.invalidateQueries({queryKey:["team-metrics-detail"]}),e.invalidateQueries({queryKey:["sprint-report"]}))}})}function _b({title:e,desc:t,children:n}){return f.jsxs("section",{className:"border-b border-gray-100 pb-4 last:border-b-0 dark:border-gray-800",children:[f.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:e}),t!=null&&f.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:t}),f.jsx("div",{className:"mt-2.5 space-y-2.5",children:n})]})}function ka({label:e,htmlFor:t,hint:n,children:r}){return f.jsxs("label",{htmlFor:t,className:"flex flex-col gap-1 text-xs",children:[f.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:e}),r,n!=null&&f.jsx("span",{className:"text-[11px] text-gray-400",children:n})]})}const Ta="w-full rounded border border-gray-300 bg-white px-2 py-1 text-xs text-gray-800 outline-none focus:border-sky-400 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100";function wb({dirty:e,saving:t,onClick:n}){return f.jsx("button",{type:"button",onClick:n,disabled:!e||t,className:"self-start rounded bg-sky-600 px-3 py-1 text-xs font-medium text-white hover:bg-sky-700 disabled:cursor-not-allowed disabled:opacity-40",children:t?"Saving…":"Save"})}const D2e=[7,14,21,28],pD=[{value:"rolling_14",label:"Rolling 14 days (default)",hint:"Trailing 14 days vs the prior 14 — always a full window, no sprint needed. Best if you don’t run fixed sprints."},{value:"rolling_7",label:"Rolling 7 days",hint:"Trailing 7 days vs the prior 7 — a tighter, more responsive momentum read."},{value:"sprint",label:"Sprint position (like-for-like)",hint:"This sprint SO FAR vs the SAME point in the previous sprint (e.g. day 3 vs day 3). Needs a start date + cadence below."}];function P2e({settings:e,save:t,saving:n}){var I,F;const r=e.sprint.comparisonMode,s=e.sprint.cadenceDays??14,a=((I=e.sprint.startDate)==null?void 0:I.slice(0,10))??"",[o,l]=D.useState(r),[u,d]=D.useState(s),[p,m]=D.useState(!D2e.includes(s)),[g,y]=D.useState(a),_=o==="sprint",S=o!==r||_&&(u!==s||g!==a),E=a!==""||e.sprint.cadenceDays!=null,N=(F=pD.find(P=>P.value===o))==null?void 0:F.hint,C=()=>t({sprint:_?{comparisonMode:o,cadenceDays:u,startDate:g===""?null:g}:{comparisonMode:o}}),O=()=>{const P=o==="sprint"?"rolling_14":o;l(P),y(""),m(!1),d(14),t({sprint:{comparisonMode:P,cadenceDays:null,startDate:null}})};return f.jsxs(_b,{title:"Sprint",desc:"How the Insights flow-metrics compare over time. Open PRs always count, regardless of the window.",children:[f.jsx(ka,{label:"Comparison window",hint:N,children:f.jsx("select",{className:Ta,value:o,onChange:P=>l(P.target.value),children:pD.map(P=>f.jsx("option",{value:P.value,children:P.label},P.value))})}),_&&f.jsxs(f.Fragment,{children:[f.jsx(ka,{label:"Cadence",children:f.jsxs("select",{className:Ta,value:p?"custom":String(u),onChange:P=>{P.target.value==="custom"?m(!0):(m(!1),d(Number(P.target.value)))},children:[f.jsx("option",{value:"7",children:"1 week"}),f.jsx("option",{value:"14",children:"2 weeks"}),f.jsx("option",{value:"21",children:"3 weeks"}),f.jsx("option",{value:"28",children:"4 weeks"}),f.jsx("option",{value:"custom",children:"Custom…"})]})}),p&&f.jsx(ka,{label:"Sprint length (days)",children:f.jsx("input",{type:"number",min:1,max:90,className:Ta,value:u,onChange:P=>d(Math.max(1,Math.min(90,Number(P.target.value)||1)))})}),f.jsx(ka,{label:"Start date",hint:"The day your first/any sprint began — cadence rolls forward from here.",children:f.jsx("input",{type:"date",className:Ta,value:g,onChange:P=>y(P.target.value)})}),g===""&&f.jsx("p",{className:"text-[11px] text-amber-600 dark:text-amber-400",children:"Set a start date to use sprint-position comparison — until then the Insights fall back to a rolling 14-day window."})]}),f.jsx(wb,{dirty:S,saving:n,onClick:C}),E&&f.jsx("div",{className:"mt-3 border-t border-gray-100 pt-3 dark:border-gray-800",children:f.jsx("button",{type:"button",onClick:O,disabled:n,className:"text-[11px] text-gray-400 underline hover:text-red-500 disabled:opacity-50",title:"Remove the sprint start date + cadence and use a rolling 14-day tracker",children:"Clear sprint dates (disable sprints)"})})]})}const mD=Array.from({length:24},(e,t)=>t),gD=e=>{const t=e<12;return`${e%12===0?12:e%12}:00 ${t?"AM":"PM"}`};function M2e({settings:e,save:t,saving:n}){const r=e.slack,[s,a]=D.useState(""),[o,l]=D.useState(r.cadence),[u,d]=D.useState(r.hour1),[p,m]=D.useState(r.hour2),[g,y]=D.useState({busy:!1,msg:null,ok:!1}),_=async()=>{y({busy:!0,msg:null,ok:!1});try{const E=await it.testSlackDigest();y({busy:!1,ok:E.sent,msg:E.sent?"Sent — check Slack.":E.message??"Not sent."})}catch(E){y({busy:!1,ok:!1,msg:E.message})}},S=s.trim()!==""||o!==r.cadence||u!==r.hour1||p!==r.hour2;return f.jsxs(_b,{title:"Slack digest",desc:"Deliver the sprint + repo digest to a Slack channel on a schedule. Report is generated fresh at send time.",children:[f.jsx(ka,{label:"Incoming webhook URL",hint:r.configured?f.jsx("span",{className:"text-emerald-500",children:"A webhook is configured. Enter a new URL to replace it, or clear it to disable."}):"Create one at api.slack.com/apps → Incoming Webhooks.",children:f.jsx("input",{type:"url",className:Ta,placeholder:r.configured?"•••••••• (unchanged)":"https://hooks.slack.com/services/…",value:s,onChange:E=>a(E.target.value)})}),f.jsx(ka,{label:"Cadence",children:f.jsxs("select",{className:Ta,value:o,onChange:E=>l(E.target.value),children:[f.jsx("option",{value:"off",children:"Off"}),f.jsx("option",{value:"daily",children:"Daily"}),f.jsx("option",{value:"twice_daily",children:"Twice daily"})]})}),o!=="off"&&f.jsxs("div",{className:"flex gap-2",children:[f.jsx(ka,{label:"Send at",hint:e.slack.timezone??"server time",children:f.jsx("select",{className:Ta,value:u,onChange:E=>d(Number(E.target.value)),children:mD.map(E=>f.jsx("option",{value:E,children:gD(E)},E))})}),o==="twice_daily"&&f.jsx(ka,{label:"And at",children:f.jsx("select",{className:Ta,value:p,onChange:E=>m(Number(E.target.value)),children:mD.map(E=>f.jsx("option",{value:E,children:gD(E)},E))})})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(wb,{dirty:S,saving:n,onClick:()=>{const E={cadence:o,hour1:u,hour2:p};s.trim()!==""&&(E.webhookUrl=s.trim()),t({slack:E}),a("")}}),r.configured&&f.jsx("button",{type:"button",onClick:_,disabled:g.busy,className:"rounded border border-gray-300 px-3 py-1 text-xs font-medium text-gray-600 hover:bg-gray-100 disabled:opacity-40 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:g.busy?"Sending…":"Send test"}),r.configured&&f.jsx("button",{type:"button",onClick:()=>{a(""),t({slack:{webhookUrl:""}})},disabled:n,className:"rounded px-2 py-1 text-xs font-medium text-red-500 hover:bg-red-50 disabled:opacity-40 dark:hover:bg-red-950",children:"Remove webhook"}),g.msg!=null&&f.jsx("span",{className:`text-[11px] ${g.ok?"text-emerald-500":"text-red-500"}`,children:g.msg})]})]})}const dv=5,L2e=[{value:"manual",label:"Manual",desc:"Only regenerate when you click Refresh."},{value:"interval",label:"Every N minutes",desc:"Regenerate on a timer (unchanged repos cost nothing)."},{value:"on_change",label:"When a change is detected",desc:"Regenerate after a sync that changed a watched repo."}];function F2e({settings:e,save:t,saving:n}){const r=e.aiUpdate,[s,a]=D.useState(r.mode),[o,l]=D.useState(r.intervalMinutes),u=s!==r.mode||s==="interval"&&o!==r.intervalMinutes;return f.jsxs(_b,{title:"AI summary updates",desc:"Controls when the Pro Haiku digests / sprint report regenerate.",children:[f.jsx("div",{className:"space-y-1.5",children:L2e.map(d=>f.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[f.jsx("input",{type:"radio",name:"ai-update-mode",className:"mt-0.5",checked:s===d.value,onChange:()=>a(d.value)}),f.jsxs("span",{children:[f.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:d.label}),f.jsx("span",{className:"block text-[11px] text-gray-400",children:d.desc})]})]},d.value))}),s==="interval"&&f.jsx(ka,{label:"Interval (minutes)",hint:`Minimum ${dv}.`,children:f.jsx("input",{type:"number",min:dv,className:Ta,value:o,onChange:d=>l(Math.max(dv,Number(d.target.value)||dv))})}),f.jsx(wb,{dirty:u,saving:n,onClick:()=>t({aiUpdate:{mode:s,intervalMinutes:o}})})]})}const j2e={jira:"https://your-org.atlassian.net",linear:"https://linear.app/your-workspace"};function $2e({settings:e,save:t,saving:n}){const r=e.issue,[s,a]=D.useState(r.provider??""),[o,l]=D.useState(r.baseUrl??""),u=r.projectKeys.join(", "),[d,p]=D.useState(u),m=d.split(/[\s,]+/).map(y=>y.trim().toUpperCase()).filter(y=>y!==""),g=(s||null)!==r.provider||o.trim()!==(r.baseUrl??"")||m.join(",")!==r.projectKeys.join(",");return f.jsxs(_b,{title:"Issue tracker",desc:"Link Jira/Linear tickets detected in a PR's title or branch into the PR details.",children:[f.jsx(ka,{label:"Provider",children:f.jsxs("select",{className:Ta,value:s,onChange:y=>a(y.target.value),children:[f.jsx("option",{value:"",children:"None"}),f.jsx("option",{value:"jira",children:"Jira"}),f.jsx("option",{value:"linear",children:"Linear"})]})}),s!==""&&f.jsxs(f.Fragment,{children:[f.jsx(ka,{label:"Base URL",hint:s==="jira"?"Tickets link to {base}/browse/KEY-123.":"Tickets link to {base}/issue/KEY-123.",children:f.jsx("input",{type:"url",className:Ta,placeholder:j2e[s],value:o,onChange:y=>l(y.target.value)})}),f.jsx(ka,{label:"Project keys",hint:"Optional, comma-separated (e.g. ENG, PROJ). When set, ONLY these prefixes are detected (in the title AND branch) — the most reliable way to avoid false matches like GPT-4 or node-18. Leave blank to detect uppercase keys in the PR title only.",children:f.jsx("input",{type:"text",className:Ta,placeholder:"ENG, PROJ",value:d,onChange:y=>p(y.target.value)})})]}),f.jsx(wb,{dirty:g,saving:n,onClick:()=>t({issue:{provider:s===""?null:s,baseUrl:o.trim()===""?null:o.trim(),projectKeys:m}})})]})}function B2e({onClose:e}){const t=zi(),n=R2e(!0),r=O2e(),s=o=>{r.mutate(o)};D.useEffect(()=>{const o=l=>{l.key==="Escape"&&(l.stopImmediatePropagation(),e())};return window.addEventListener("keydown",o,!0),()=>window.removeEventListener("keydown",o,!0)},[e]);const a=n.data;return f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:e,role:"presentation",children:f.jsxs("div",{className:"flex max-h-[85vh] w-[30rem] max-w-[92vw] flex-col rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-900",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Settings",children:[f.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[f.jsx("h2",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:"Settings"}),f.jsx("button",{type:"button",onClick:e,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-200","aria-label":"Close (Esc)",title:"Close (Esc)",children:"✕"})]}),f.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto px-4 py-3",children:[r.isError&&f.jsx("p",{className:"rounded bg-red-50 px-2 py-1 text-xs text-red-600 dark:bg-red-950 dark:text-red-300",children:r.error.message}),n.isLoading||a==null?f.jsx("p",{className:"py-6 text-center text-xs text-gray-400",children:n.isError?"Settings unavailable.":"Loading…"}):f.jsxs(f.Fragment,{children:[t.teamInsights&&f.jsx(P2e,{settings:a,save:s,saving:r.isPending}),t.slackDigest&&f.jsx(M2e,{settings:a,save:s,saving:r.isPending}),t.activityDigest&&f.jsx(F2e,{settings:a,save:s,saving:r.isPending}),t.issueLinks&&f.jsx($2e,{settings:a,save:s,saving:r.isPending})]})]})]})})}const U2e={expired:"Your sign-in link expired. Please sign in again.",failed:"We couldn’t complete sign-in with GitHub. Please try again.",error:"Something went wrong reaching GitHub. Please try again in a moment."};function H2e(){const[e]=D.useState(()=>{const t=new URLSearchParams(window.location.search).get("auth");return t?U2e[t]??"We couldn’t complete sign-in. Please try again.":null});return D.useEffect(()=>{if(!e)return;const t=new URL(window.location.href);t.searchParams.delete("auth"),window.history.replaceState({},"",t.pathname+t.search+t.hash)},[e]),f.jsx("div",{className:"flex h-full min-h-screen w-full items-center justify-center bg-gray-950 px-4 text-gray-100",children:f.jsxs("div",{className:"flex w-full max-w-sm flex-col items-center rounded-2xl border border-gray-800 bg-gray-900/40 px-8 py-10 text-center shadow-xl",children:[f.jsx("span",{className:"brand-title text-4xl",title:"Pierre — a play on “PR”",children:"Pierre"}),f.jsx("p",{className:"mt-4 text-sm text-gray-400",children:"Sign in to view your team’s GitHub activity — pull requests, reviews, and what needs your attention."}),e&&f.jsx("div",{role:"alert",className:"mt-6 w-full rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs text-amber-200",children:e}),f.jsxs("a",{href:"/api/auth/login",className:"mt-7 inline-flex w-full items-center justify-center gap-2 rounded-lg bg-blue-600 px-4 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-sky-400 focus:ring-offset-2 focus:ring-offset-gray-950",children:[f.jsx("svg",{viewBox:"0 0 16 16",width:"18",height:"18",fill:"currentColor","aria-hidden":"true",children:f.jsx("path",{fillRule:"evenodd",d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8Z"})}),"Sign in with GitHub"]}),f.jsx("p",{className:"mt-5 text-xs leading-relaxed text-gray-500",children:"Read-only access. Add any public repo instantly; private repos only when you install Pierre on them. Revoke anytime from GitHub settings."})]})})}function z2e({user:e,canSignOut:t,onSignOut:n,onOpenSettings:r}){const[s,a]=D.useState(!1),o=D.useRef(null),l=e.displayName??e.login;Do(o,()=>a(!1),s),D.useEffect(()=>{if(!s)return;const d=p=>{p.key==="Escape"&&(p.stopPropagation(),a(!1))};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[s]);const u=e.avatarUrl!=null?f.jsx("img",{src:e.avatarUrl,alt:l,width:20,height:20,className:"shrink-0 rounded-full",style:{width:20,height:20}}):f.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-full bg-gray-300 text-[9px] font-semibold text-gray-700 dark:bg-gray-700 dark:text-gray-200",style:{width:20,height:20},children:l.slice(0,2).toUpperCase()});return f.jsxs("div",{ref:o,className:"relative",children:[f.jsxs("button",{type:"button",onClick:()=>a(d=>!d),"aria-haspopup":"menu","aria-expanded":s,className:`flex items-center gap-1.5 rounded px-1.5 py-0.5 text-xs font-medium text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800 ${s?"bg-gray-100 dark:bg-gray-800":""}`,title:e.displayName!=null?`Signed in as ${e.displayName} (@${e.login})`:`Signed in as ${e.login}`,children:[u,f.jsx("span",{className:"max-w-[10rem] truncate",children:l}),f.jsx("span",{"aria-hidden":"true",className:"text-[9px] text-gray-400",children:"▾"})]}),s&&f.jsxs("div",{role:"menu","aria-label":"Account menu",className:"absolute right-0 top-full z-[60] mt-1 w-52 rounded-lg border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[r!=null&&f.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{a(!1),r()},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-800",children:[f.jsxs("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[f.jsx("circle",{cx:"12",cy:"12",r:"3"}),f.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),"Settings"]}),f.jsxs("a",{role:"menuitem",href:dk(e.login),target:"_blank",rel:"noreferrer noopener",onClick:()=>a(!1),className:"flex items-center gap-2 px-3 py-1.5 text-xs text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-800",children:[f.jsx(kL,{size:13}),"Open Profile on GitHub"]}),t&&f.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{a(!1),n()},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-800",children:[f.jsxs("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[f.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),f.jsx("polyline",{points:"16 17 21 12 16 7"}),f.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]}),"Sign Out"]})]})]})}const Y2e=["7d","14d","30d","90d","custom"];function uw(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(r=>n.has(r))}function cw(e){if(!e)return null;const t=e.split(",").map(n=>Number.parseInt(n,10)).filter(Number.isFinite);return t.length?t:null}function W2e(){const e=new URLSearchParams(window.location.search),t={},n=e.get("preset");n&&Y2e.includes(n)&&(t.preset=n),t.repoIds=cw(e.get("repos")),t.userIds=cw(e.get("users")),e.get("bots")!==null&&(t.excludeBots=e.get("bots")==="1");const r=cw(e.get("allowBots"));r&&(t.allowedBotIds=r);const s=e.get("stale");s==="0"?t.excludeStale=!1:s==="1"&&(t.excludeStale=!0),t.customFrom=e.get("from"),t.customTo=e.get("to");const a=e.get("cats");if(a){const y=new Set(em);t.categories=a.split(",").filter(_=>y.has(_))}const o=e.get("status");if(o!==null){const y=new Set(tm);t.prStatuses=o.split(",").filter(_=>y.has(_))}const l=e.get("reviews");if(l!==null){const y=new Set(nm);t.reviewStates=l.split(",").filter(_=>y.has(_))}const u=e.get("states");if(u){const y=new Set(rk);t.derivedStates=u.split(",").filter(_=>y.has(_))}const d=e.get("pr");d&&(t.selectedPrId=Number.parseInt(d,10));const p=e.get("thread");p&&(t.selectedThreadId=Number.parseInt(p,10));const m=e.get("strip");(m==="my_turn"||m==="needs_attention"||m==="all")&&(t.stripFilter=m);const g=e.get("activityRepo");if(g){const y=Number.parseInt(g,10);Number.isFinite(y)&&(t.activityRepoId=y)}return e.get("open")==="1"&&(t.stripCollapsed=!1),t}function vD(e){var s,a;const t=new URLSearchParams;e.preset!=="14d"&&t.set("preset",e.preset),(s=e.repoIds)!=null&&s.length&&t.set("repos",e.repoIds.join(",")),(a=e.userIds)!=null&&a.length&&t.set("users",e.userIds.join(",")),e.excludeBots&&t.set("bots","1"),e.excludeBots&&e.allowedBotIds.length&&t.set("allowBots",e.allowedBotIds.join(",")),e.excludeStale||t.set("stale","0"),e.preset==="custom"&&e.customFrom&&t.set("from",e.customFrom),e.preset==="custom"&&e.customTo&&t.set("to",e.customTo),uw(e.categories,Dv)||t.set("cats",e.categories.join(",")),uw(e.prStatuses,Mv)||t.set("status",e.prStatuses.join(",")),uw(e.reviewStates,Pv)||t.set("reviews",e.reviewStates.join(",")),e.derivedStates.length&&t.set("states",e.derivedStates.join(",")),e.selectedPrId&&t.set("pr",String(e.selectedPrId)),e.selectedThreadId&&t.set("thread",String(e.selectedThreadId)),e.stripFilter!=="all"&&t.set("strip",e.stripFilter),e.stripCollapsed||t.set("open","1"),Wt.getState().activeTab==="activity"&&(t.set("view","activity"),typeof e.activityRepoId=="number"&&t.set("activityRepo",String(e.activityRepoId)));const n=t.toString(),r=`${window.location.pathname}${n?`?${n}`:""}`;r!==window.location.pathname+window.location.search&&window.history.replaceState(null,"",r)}const nj="pierre:filterBarState";function G2e(){try{const e=localStorage.getItem(nj);if(!e)return null;const t=JSON.parse(e);return t&&typeof t=="object"?ky(t):null}catch{return null}}function V2e(e){try{localStorage.setItem(nj,JSON.stringify(Iw(e)))}catch{}}function q2e(){const e=D.useRef(!1);D.useEffect(()=>{if(!e.current){if(window.location.search.length>1)Me.getState().hydrate(W2e()),new URLSearchParams(window.location.search).get("view")==="activity"&&Wt.getState().setActiveTab("activity");else{const s=T8(),a=s?ky(s.state):G2e();a&&Me.getState().hydrate(a),Wt.getState().setActiveTab("activity")}e.current=!0}const t=Me.subscribe(r=>{vD(r),V2e(r)}),n=Wt.subscribe(()=>{vD(Me.getState())});return()=>{t(),n()}},[])}function yD(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable}function K2e(){const{data:e}=eP();D.useEffect(()=>{const t=n=>{var u;const{selectedPrId:r,selectPr:s,clearSelection:a}=Me.getState(),o=Wt.getState(),l=o.activeTab==="timeline";if(n.key==="Escape"){yD(n.target)?n.target.blur():l?a():o.showTimeline();return}if(!yD(n.target)){if(n.key==="/"){n.preventDefault(),(u=document.getElementById("add-repo-input"))==null||u.focus();return}if(n.key==="i"){o.showActivity();return}if(l&&(n.key==="j"||n.key==="k")){const d=[...(e==null?void 0:e.prs)??[]].sort((y,_)=>_.openedAt.localeCompare(y.openedAt));if(d.length===0)return;const p=d.findIndex(y=>y.id===r);let m;p===-1?m=0:m=n.key==="j"?p+1:p-1,m=Math.max(0,Math.min(d.length-1,m));const g=d[m];g&&s(g.id)}}};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e])}function Q2e(){const e=nn();D.useEffect(()=>{let t=null;const n=()=>{const a=new Map,o=(l,u)=>{const d=a.get(l);(!d||u>d)&&a.set(l,u)};for(const[,l]of e.getQueriesData({queryKey:["timeline"]}))for(const u of(l==null?void 0:l.prs)??[])o(u.id,u.updatedAt);for(const[,l]of e.getQueriesData({queryKey:["open-prs"]}))for(const u of(l==null?void 0:l.prs)??[])o(u.id,u.updatedAt);for(const[l,u]of a){const d=e.getQueryData(["pr",l]);if(!d||d.updatedAt>=u)continue;const p=e.getQueryState(["pr",l]);if(!(p&&p.fetchStatus!=="idle")){e.invalidateQueries({queryKey:["pr",l]});for(const m of d.threads??[])e.invalidateQueries({queryKey:["thread",m.id]})}}},r=()=>{t||(t=setTimeout(()=>{t=null,n()},300))};r();const s=e.getQueryCache().subscribe(a=>{const o=a.query.queryKey[0];(o==="timeline"||o==="open-prs")&&r()});return()=>{t&&clearTimeout(t),s()}},[e])}function X2e(e){const{data:t}=nP(),n=D.useRef(null);D.useEffect(()=>{if(!t)return;const r=new Set;for(const g of t.awaitingReview)r.add(`r:${g.prId}`);for(const g of t.yourPrs)r.add(`p:${g.prId}`);for(const g of t.approvedPrs??[])r.add(`a:${g.prId}`);for(const g of t.threadsAwaiting)r.add(`t:${g.threadId}`);for(const g of t.watchedRepoPrs)r.add(`w:${g.prId}`);const s=n.current;if(n.current=r,s==null||!e||typeof Notification>"u"||Notification.permission!=="granted")return;const a=[...r].filter(g=>!s.has(g));if(a.length===0)return;const o=a.filter(g=>g.startsWith("r:")).length,l=a.filter(g=>g.startsWith("t:")).length,u=a.filter(g=>g.startsWith("p:")).length,d=a.filter(g=>g.startsWith("a:")).length,p=a.filter(g=>g.startsWith("w:")).length,m=[];o&&m.push(`${o} review${o===1?"":"s"} requested`),l&&m.push(`${l} thread${l===1?"":"s"} awaiting you`),u&&m.push(`${u} of your PRs active`),d&&m.push(`${d} of your PRs approved`),p&&m.push(`${p} new in watched repos`);try{const g=new Notification(`Pierre — ${a.length} new in My Turn`,{body:m.join(" · "),tag:"pierre-my-turn"});g.onclick=()=>{window.focus(),g.close()}}catch{}},[t,e])}const dw="";function Z2e(e){return/^G-[A-Z0-9]{6,}$/i.test(e)&&e!=="G-XXXXXXXXXX"}let qE=!1;function J2e(){if(qE||typeof window>"u"||!Z2e(dw))return;qE=!0;const e=document.createElement("script");e.async=!0,e.src=`https://www.googletagmanager.com/gtag/js?id=${dw}`,document.head.appendChild(e),window.dataLayer=window.dataLayer||[],window.gtag=function(...n){window.dataLayer.push(n)},window.gtag("js",new Date),window.gtag("config",dw,{send_page_view:!1})}function eAe(e=window.location.pathname){!qE||!window.gtag||window.gtag("event","page_view",{page_path:e,page_location:`${window.location.origin}${e}`,page_title:document.title})}function tAe(){const[e,t]=D.useState(()=>(localStorage.getItem("theme")??"dark")!=="light");return D.useEffect(()=>{document.documentElement.classList.toggle("dark",e),localStorage.setItem("theme",e?"dark":"light")},[e]),[e,()=>t(n=>!n)]}function nAe(){var Z,ee;const e=uk();q2e(),K2e(),Q2e();const[t,n]=tAe(),[r,s]=D.useState(!1),[a,o]=D.useState(!1),l=A2e(),[u,d]=tj(),p=typeof window<"u"&&"Notification"in window;X2e(u&&p);const m=()=>{if(p){if(u){d(!1);return}Notification.permission==="granted"?d(!0):Notification.permission!=="denied"&&Notification.requestPermission().then(j=>d(j==="granted"))}},g=((Z=e.data)==null?void 0:Z.deploymentMode)==="cloud",y=((ee=e.data)==null?void 0:ee.user)??null,_=()=>{Wt.getState().clear(),it.logout().finally(()=>window.location.assign("/"))},S=Me(j=>j.selectedPrId),E=Me(j=>j.selectedThreadId),N=Wt(j=>j.activeTab),C=Wt(j=>j.tabs),O=N!=="timeline"&&N!=="activity"?C.find(j=>j.key===N)??null:null,I=N==="activity",F=(O==null?void 0:O.kind)==="pr-detail"?O.prId:null,P=(O==null?void 0:O.kind)==="metrics-detail",H=(O==null?void 0:O.kind)==="pr-focus"?{kind:"isolate",prId:O.prId}:null,B=F!=null||I||P,W=S!=null&&!B,[M,z]=z6("pierre:detailPaneHeight",384),K=D.useRef(null),V=D.useRef(null),G=D.useRef(null);D.useEffect(()=>{for(const j of[V.current,K.current])j&&(B?j.setAttribute("inert",""):j.removeAttribute("inert"))},[B]),D.useEffect(()=>{const j=()=>Wt.getState().navigateBack();return window.addEventListener("popstate",j),()=>window.removeEventListener("popstate",j)},[]),D.useEffect(()=>{window.dispatchEvent(new Event("resize"))},[W]);const X=j=>{var J;G.current={startY:j.clientY,startH:((J=K.current)==null?void 0:J.offsetHeight)??M},j.currentTarget.setPointerCapture(j.pointerId)},pe=j=>{const J=G.current;if(!J||!K.current)return;const he=window.innerHeight*.7,Y=Math.min(Math.max(J.startH+(J.startY-j.clientY),160),he);K.current.style.height=`${Y}px`,window.dispatchEvent(new Event("resize"))},ye=j=>{!G.current||!K.current||(G.current=null,j.currentTarget.releasePointerCapture(j.pointerId),z(K.current.offsetHeight))};return D.useEffect(()=>{if(!g)return;const j=()=>{it.me().catch(()=>{})},J=window.setInterval(j,180*1e3);return()=>window.clearInterval(J)},[g]),D.useEffect(()=>{g&&(J2e(),eAe())},[g]),e.error instanceof Hi&&e.error.status===401?f.jsx(H2e,{}):e.isLoading&&!e.data?f.jsx("div",{className:"flex h-full min-h-screen items-center justify-center bg-gray-950",children:f.jsx("span",{className:"brand-title text-4xl text-gray-100",children:"Pierre"})}):f.jsxs("div",{className:"flex h-full flex-col",children:[f.jsxs("header",{className:"flex items-center gap-3 border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[f.jsx("h1",{className:"brand-title",title:"Pierre — a play on “PR”",children:"Pierre"}),f.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[f.jsx(S2e,{}),f.jsx(T2e,{}),p&&f.jsx("button",{type:"button",onClick:m,"aria-pressed":u,className:`rounded border px-2 py-0.5 text-xs hover:border-gray-400 dark:hover:border-gray-500 ${u?"border-blue-400 text-blue-600 dark:border-blue-600 dark:text-blue-400":"border-gray-300 dark:border-gray-700"}`,title:u?"Notifications on — alerts when a new item enters your My Turn. Click to turn off.":"Turn on browser notifications for new My Turn items","aria-label":"Toggle My Turn notifications",children:f.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:u?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[f.jsx("path",{d:"M18 8a6 6 0 0 0-12 0c0 7-3 9-3 9h18s-3-2-3-9"}),f.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}),f.jsx("button",{type:"button",onClick:()=>s(!0),className:"rounded border border-gray-300 px-2 py-0.5 text-xs font-semibold hover:border-gray-400 dark:border-gray-700 dark:hover:border-gray-500",title:"Help — what is Pierre and how to use it","aria-label":"Help",children:"?"}),f.jsx("button",{type:"button",onClick:n,className:"rounded border border-gray-300 px-2 py-0.5 text-xs hover:border-gray-400 dark:border-gray-700 dark:hover:border-gray-500",title:"Toggle dark mode",children:t?"☀":"☾"}),y!=null&&f.jsx(z2e,{user:y,canSignOut:g,onSignOut:_,onOpenSettings:l?()=>o(!0):null})]})]}),r&&f.jsx(C2e,{onClose:()=>s(!1)}),a&&f.jsx(B2e,{onClose:()=>o(!1)}),f.jsx(N2e,{}),f.jsx(mK,{}),f.jsx(xK,{}),f.jsx(NK,{}),f.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[f.jsx("section",{ref:V,className:"min-h-0 flex-1 overflow-hidden",children:H==null?f.jsx(KO,{},"board"):f.jsx(KO,{mode:H},`focus:${H.prId}`)}),W&&f.jsxs(f.Fragment,{children:[f.jsx("div",{role:"separator","aria-orientation":"horizontal","aria-label":"Resize detail pane",onPointerDown:X,onPointerMove:pe,onPointerUp:ye,title:"Drag to resize",className:"h-1 shrink-0 cursor-row-resize bg-gray-200 transition-colors hover:bg-blue-400 dark:bg-gray-800 dark:hover:bg-blue-500"}),f.jsx("section",{ref:K,style:{height:M},className:"shrink-0 overflow-auto",children:f.jsx(v2e,{})})]}),F!=null&&f.jsx("div",{"data-testid":"pinned-pr-overlay",className:"absolute inset-0 z-20 bg-white dark:bg-gray-950",children:f.jsx(ML,{prId:F,selectedThreadId:S===F?E:null},F)}),I&&f.jsx("div",{"data-testid":"activity-overlay",className:"absolute inset-0 z-20 overflow-hidden bg-white dark:bg-gray-950",children:f.jsx(a2e,{})}),P&&f.jsx("div",{"data-testid":"metrics-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:f.jsx(g2e,{})})]}),f.jsx(x2e,{})]})}function KE(){}function rAe(e,{interval:t=1e3,onError:n=KE}={}){if(typeof e!="function")throw new Error("argument is not function.");let r=0,s=null,a=!1,o=!1;return async(...l)=>{if(s=l,!o){for(o=!0;a;)await new Promise(u=>nl.setTimeout(u,t));for(;Date.now()<r;)await new Promise(u=>nl.setTimeout(u,r-Date.now()));o=!1,a=!0;try{await e(...s)}catch(u){try{n(u)}catch{}}r=Date.now()+t,a=!1}}}var iAe=({storage:e,key:t="REACT_QUERY_OFFLINE_CACHE",throttleTime:n=1e3,serialize:r=JSON.stringify,deserialize:s=JSON.parse,retry:a})=>{if(e){const o=async l=>{try{const u=await r(l);await e.setItem(t,u);return}catch(u){return u}};return{persistClient:rAe(async l=>{let u=l,d=await o(u),p=0;for(;d&&u;)p++,u=await(a==null?void 0:a({persistedClient:u,error:d,errorCount:p})),u&&(d=await o(u))},{interval:n}),restoreClient:async()=>{const l=await e.getItem(t);if(l)return await s(l)},removeClient:()=>e.removeItem(t)}}return{persistClient:KE,restoreClient:()=>Promise.resolve(void 0),removeClient:KE}};function Eb(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function sAe(e,t){let n;const r=()=>{if(n)return n;const s=indexedDB.open(e);return s.onupgradeneeded=()=>s.result.createObjectStore(t),n=Eb(s),n.then(a=>{a.onclose=()=>n=void 0},()=>{}),n};return(s,a)=>r().then(o=>a(o.transaction(t,s).objectStore(t)))}let fw;function rS(){return fw||(fw=sAe("keyval-store","keyval")),fw}function aAe(e,t=rS()){return t("readonly",n=>Eb(n.get(e)))}function oAe(e,t,n=rS()){return n("readwrite",r=>(r.put(t,e),Eb(r.transaction)))}function lAe(e,t=rS()){return t("readwrite",n=>(n.delete(e),Eb(n.transaction)))}const uAe=iAe({storage:{getItem:e=>aAe(e).then(t=>t??null),setItem:(e,t)=>oAe(e,t),removeItem:e=>lAe(e)},key:"pierre-query-cache",throttleTime:1e3}),cAe=new I$({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1,retry:1}}});var fv,AD;(AD=(fv=navigator.storage)==null?void 0:fv.persist)==null||AD.call(fv);new URLSearchParams(window.location.search).has("perf")&&Bj(()=>import("./perfProbe-Da13EhTE.js"),[]).then(e=>e.startPerfProbe());const rj=document.getElementById("root");if(!rj)throw new Error("#root not found");const dAe=1e3*60*60*24*7;qj.createRoot(rj).render(f.jsx(D.StrictMode,{children:f.jsx(G$,{client:cAe,persistOptions:{persister:uAe,maxAge:dAe,buster:"pierre-detail-v2",dehydrateOptions:{shouldDehydrateQuery:e=>{const t=e.queryKey[0];return(t==="pr"||t==="thread"||t==="pr-files")&&e.state.status==="success"}}},children:f.jsx(nAe,{})})}));
|
|
1390
|
+
`)}function T2e(){const e=nn(),[t,n]=D.useState(!1),[r,s]=D.useState(!1),[a,o]=D.useState(!1),[l,u]=D.useState(!1),[d,p]=D.useState([]),{data:m}=gn({queryKey:["repos"],queryFn:it.listRepos,refetchInterval:t?3e3:3e4}),g=(m??[]).map(ee=>ee.id).join(","),{data:y}=gn({queryKey:["sync-status",g],enabled:t&&!!m&&m.length>0,queryFn:()=>Promise.all((m??[]).map(ee=>it.syncStatus(ee.id))),refetchInterval:1500}),_=new Set(d),S=_.size===0?m??[]:(m??[]).filter(ee=>_.has(ee.id)),E=new Set(S.map(ee=>ee.id)),N=y==null?void 0:y.filter(ee=>E.has(ee.repoId)),C=(N??[]).filter(ee=>ee.status==="running"),O=C.length,I=O>0&&C.every(ee=>{var j;return((j=ee.progress)==null?void 0:j.foregroundComplete)===!0}),F=w2e(m??[]),P=D.useRef(F),H=D.useRef(!1),B=D.useRef(null),W=()=>{B.current!=null&&(clearTimeout(B.current),B.current=null)},M=()=>{o(!1),H.current=!1,W()};D.useEffect(()=>W,[]);const z=()=>{e.invalidateQueries({queryKey:["timeline"]}),e.invalidateQueries({queryKey:["open-prs"]}),e.invalidateQueries({queryKey:["users"]}),e.invalidateQueries({queryKey:["mergers"]}),e.invalidateQueries({queryKey:["my-turn"]}),e.invalidateQueries({queryKey:["me"]});for(const ee of ck)e.invalidateQueries({queryKey:[ee]})};D.useEffect(()=>{P.current!==F&&(P.current=F,z())},[F]),D.useEffect(()=>{!t||!I||H.current||(H.current=!0,s(!1),z())},[t,I]),D.useEffect(()=>{O>0&&o(!0)},[O]),D.useEffect(()=>{t&&a&&y&&O===0&&(n(!1),o(!1),z(),W(),B.current=setTimeout(()=>{s(!1),B.current=null},1e3))},[t,a,y,O]);const K=Me(ee=>ee.syncModalSignal),V=Me(ee=>ee.syncModalRepoId),G=D.useRef(K);if(D.useEffect(()=>{K!==G.current&&(G.current=K,V!=null&&(r?p(ee=>ee.includes(V)?ee:[...ee,V]):(p([V]),s(!0),n(!0),M()),e.invalidateQueries({queryKey:["repos"]}),e.invalidateQueries({queryKey:["sync-status"]})))},[K,e]),!m||m.length===0)return null;const X=m.find(ee=>ee.lastSyncStatus==="error"),pe=async(ee=!1)=>{n(!0),s(!0),p([]),M(),await Promise.allSettled(m.map(j=>it.syncRepo(j.id,ee))),e.invalidateQueries({queryKey:["repos"]}),e.invalidateQueries({queryKey:["sync-status"]})},ye=async()=>{u(!0),W();const ee=(N??[]).filter(J=>J.status==="running").map(J=>J.repoId),j=ee.length?ee:S.map(J=>J.id);await Promise.allSettled(j.map(J=>it.cancelSync(J))),n(!1),o(!1),u(!1),s(!1),e.invalidateQueries({queryKey:["repos"]}),z()},Z=I?"loading older history…":O>0?`syncing ${O} repo${O===1?"":"s"}…`:"syncing…";return f.jsxs(f.Fragment,{children:[r&&f.jsx(_2e,{repos:S,statuses:N,cancelling:l,onCancel:()=>void ye()}),f.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[X?f.jsxs("span",{className:"text-red-500",title:X.lastSyncError??"",children:["sync error: ",X.fullName]}):f.jsx("span",{className:"cursor-help",title:k2e(F),children:t?Z:F?`synced ${Yr(F)}`:"not synced yet"}),f.jsx("button",{type:"button",onClick:()=>void pe(!1),disabled:t,className:"rounded border border-gray-300 px-2 py-0.5 hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:"Sync now"}),f.jsx("button",{type:"button",onClick:()=>{window.confirm("Deep re-sync re-fetches the full backfill window for every repo. Slower, but catches CI/thread changes the incremental sync can lag. Continue?")&&pe(!0)},disabled:t,className:"rounded px-1.5 py-0.5 text-gray-400 hover:text-gray-600 disabled:opacity-50",title:"Force a full backfill for all repos",children:"deep"})]})]})}function S2e(){const e=Me(I=>I.searchQuery),t=Me(I=>I.setSearchQuery),n=Wt(I=>I.openPrFocusTab),{data:r}=ok(),{data:s}=lk(),{data:a}=pl(),{data:o}=Za(),[l,u]=D.useState(!1),[d,p]=D.useState(-1),m=D.useRef(null),g=D.useMemo(()=>{const I=new Map;for(const F of a??[])I.set(F.id,F.fullName);return I},[a]),y=D.useMemo(()=>ia(o),[o]),_=D.useMemo(()=>{const I=new Map;for(const F of(r==null?void 0:r.prs)??[])I.set(F.id,F);for(const F of(s==null?void 0:s.prs)??[])I.has(F.id)||I.set(F.id,F);return[...I.values()]},[r,s]),S=D.useMemo(()=>{const I=e.trim().toLowerCase();if(!I)return[];const F=I.replace(/^#/,""),P=F.length>0&&/^\d+$/.test(F),H=_.filter(B=>B.title.toLowerCase().includes(I)||P&&String(B.number).includes(F));if(P){const B=W=>{const M=String(W.number);return M===F?0:M.startsWith(F)?1:M.includes(F)?2:3};H.sort((W,M)=>B(W)-B(M))}return H.slice(0,30)},[_,e]),E=l&&e.trim().length>0,N=d>=0&&d<S.length?S[d].id:null;Do(m,()=>u(!1),E),D.useEffect(()=>{var I,F;N!=null&&((F=(I=m.current)==null?void 0:I.querySelector(`#pr-result-${N}`))==null||F.scrollIntoView({block:"nearest"}))},[N]);const C=I=>{if(!I)return;const F=I.authorId!=null?y.get(I.authorId):void 0;n({id:I.id,number:I.number,title:I.title,repoFullName:g.get(I.repoId)??`repo ${I.repoId}`,authorLogin:(F==null?void 0:F.githubLogin)??null,authorDisplayName:(F==null?void 0:F.displayName)??null,authorAvatarUrl:(F==null?void 0:F.avatarUrl)??null}),u(!1)},O=I=>{if(I.key==="Escape"){u(!1),I.target.blur();return}!E||S.length===0||(I.key==="ArrowDown"?(I.preventDefault(),p(F=>(F+1)%S.length)):I.key==="ArrowUp"?(I.preventDefault(),p(F=>F<=0?S.length-1:F-1)):I.key==="Enter"&&(I.preventDefault(),C(S[d>=0?d:0])))};return f.jsxs("div",{ref:m,className:"relative",children:[f.jsx("input",{type:"search",value:e,placeholder:"Search PRs (title or number)…",onChange:I=>{t(I.target.value),p(-1),u(!0)},onFocus:()=>u(!0),onKeyDown:O,role:"combobox","aria-expanded":E,"aria-controls":"pr-search-results","aria-autocomplete":"list","aria-activedescendant":N!=null?`pr-result-${N}`:void 0,"aria-label":"Search PRs by title or number",className:"w-56 rounded border border-gray-300 bg-transparent px-2 py-0.5 text-xs focus:border-blue-500 focus:outline-none dark:border-gray-700"}),E&&f.jsx("div",{id:"pr-search-results",role:"listbox","aria-label":"PR search results",className:"absolute right-0 top-full z-[60] mt-1 max-h-80 w-80 overflow-y-auto rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-900",children:S.length===0?f.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:"No matching PRs."}):S.map((I,F)=>{const P=I.authorId!=null?y.get(I.authorId):void 0;return f.jsxs("button",{id:`pr-result-${I.id}`,type:"button",role:"option","aria-selected":F===d,onMouseEnter:()=>p(F),onClick:()=>C(I),className:`flex w-full flex-col gap-0.5 px-3 py-1.5 text-left ${F===d?"bg-gray-100 dark:bg-gray-800":""} hover:bg-gray-100 dark:hover:bg-gray-800`,children:[f.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-400",children:[f.jsx(mi,{user:P,size:12}),f.jsx("span",{className:"truncate",title:jr(P,I.authorId),children:jr(P,I.authorId)}),f.jsx("span",{"aria-hidden":!0,children:"·"}),f.jsxs("span",{className:"shrink-0",children:[g.get(I.repoId)??`repo ${I.repoId}`," · #",I.number]})]}),f.jsx("span",{className:"truncate text-xs",title:I.title,children:I.title})]},I.id)})})]})}function N2e(){const{data:e}=uk(),t=zi().feedMyTurn,n=Wt(m=>m.activeTab),r=Wt(m=>m.showActivity),s=Me(m=>m.setActivityRepo),a=Me(m=>m.setFeedMyTurnOnly),[o,l]=D.useState(!1);if(!t||o||!(e!=null&&e.user)||n==="activity")return null;const u=e.newFeedItems??0;if(u<=0)return null;const d=e.feedLastSeenAt,p=()=>{s("feed"),a(!0),r(),l(!0)};return f.jsxs("div",{className:"flex items-center gap-2 border-b border-amber-200 bg-amber-50 px-4 py-1.5 text-xs text-amber-800 dark:border-amber-900/50 dark:bg-amber-900/20 dark:text-amber-200",children:[f.jsxs("button",{type:"button",onClick:p,title:"Show your feed",className:"flex min-w-0 flex-1 items-center gap-2 text-left hover:underline",children:[f.jsx("span",{className:"font-medium",children:"Welcome back"}),f.jsxs("span",{className:"min-w-0 truncate text-amber-700/80 dark:text-amber-300/80",children:["· ",u," new item",u===1?"":"s"," in your feed",d?` since you were last here ${Yr(d)}`:""]})]}),f.jsx("button",{type:"button",onClick:p,className:"shrink-0 rounded border border-amber-400 px-2 py-0.5 font-medium hover:bg-amber-100 dark:border-amber-700 dark:hover:bg-amber-900/40",children:"Show feed"}),f.jsx("button",{type:"button",onClick:()=>l(!0),"aria-label":"Dismiss",title:"Dismiss",className:"shrink-0 rounded px-1 text-amber-500 hover:text-amber-700 dark:hover:text-amber-300",children:"✕"})]})}function C2e({onClose:e}){return D.useEffect(()=>{const t=n=>{n.key==="Escape"&&(n.stopImmediatePropagation(),e())};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[e]),f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:e,role:"presentation",children:f.jsxs("div",{className:"flex max-h-[80vh] w-[34rem] max-w-[92vw] flex-col rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-900",onClick:t=>t.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Pierre help",children:[f.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[f.jsx("h2",{className:"brand-title",children:"Pierre"}),f.jsx("button",{type:"button",onClick:e,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-200","aria-label":"Close (Esc)",title:"Close (Esc)",children:"✕"})]}),f.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto px-4 py-3 text-sm leading-relaxed text-gray-600 dark:text-gray-300",children:[f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"A local dashboard for your team’s GitHub pull-request activity across repos, drawn as an interactive timeline. Everything runs on your machine."}),f.jsxs(Ql,{title:"Track repositories",children:["Add repos in the filter bar’s ",f.jsx("em",{children:"add repo"})," box as ",f.jsx(I2e,{children:"owner/name"}),". Pierre syncs their PR activity every few minutes into a local file — nothing leaves your machine."]}),f.jsxs(Ql,{title:"Read the timeline",children:["Rows are grouped ",f.jsx("strong",{children:"repo → contributor"}),". Each PR is a bar; the markers beneath it are events — commits, comments, reviews. Scroll to pan, hold the zoom key while scrolling to zoom. Click a marker for its details, or a PR bar to select it."]}),f.jsxs(Ql,{title:"Focus mode",children:["To isolate one PR and just its contributors: double-click its bar, click"," ",f.jsx("strong",{children:"Focus"})," in the detail pane, or click a cross-person marker. Leave focus with the ",f.jsx("strong",{children:"✕"})," on the header"," ",f.jsx("strong",{children:"Focus mode"})," badge, ",f.jsx(tf,{children:"Esc"}),", or the browser"," ",f.jsx("strong",{children:"Back"})," button."]}),f.jsxs(Ql,{title:"Detail pane",children:["Selecting a PR opens the bottom pane with ",f.jsx("strong",{children:"Overview"})," (checks, summary, comments), ",f.jsx("strong",{children:"Threads"}),", and ",f.jsx("strong",{children:"Activity"}),". The ",f.jsx("em",{children:"Show"})," links jump back to that moment on the timeline; drag the divider to resize the pane."]}),f.jsxs(Ql,{title:"Filter",children:["Narrow by date range, members (auto-scoped to who’s active in view), event categories, and thread states. ",f.jsx("em",{children:"Exclude bots"})," hides renovate / dependabot / CI noise."]}),f.jsxs(Ql,{title:"Open-PRs strip",children:["The collapsible strip up top lists currently-open PRs — toggle between"," ",f.jsx("strong",{children:"all"}),", ",f.jsx("strong",{children:"my turn"}),", and"," ",f.jsx("strong",{children:"needs attention"}),"."]}),f.jsxs(Ql,{title:"Activity & Insights",children:["Clicking an item in the ",f.jsx("strong",{children:"Activity Feed"})," opens that PR's detail tab, where ",f.jsx("strong",{children:"Show"})," / ",f.jsx("strong",{children:"Focus"})," drive the timeline; the feed's ",f.jsx("strong",{children:"My Turn only"})," toggle narrows it to what needs you."," ",f.jsx("strong",{children:"Insights"})," opens a per-repo snapshot (open / merged / stalled, time-to-first-review, review load). Save filter combinations as named ",f.jsx("strong",{children:"Views"}),", and use the bell to get notified when something new lands in your queue."]}),f.jsxs(Ql,{title:"Keyboard",children:[f.jsx(tf,{children:"/"})," focus the filter · ",f.jsx(tf,{children:"j"}),"/",f.jsx(tf,{children:"k"})," cycle PRs ·"," ",f.jsx(tf,{children:"i"})," Insights · ",f.jsx(tf,{children:"Esc"})," exit focus, else clear the selection."]})]})]})})}function Ql({title:e,children:t}){return f.jsxs("section",{children:[f.jsx("h3",{className:"mb-1 font-semibold text-gray-800 dark:text-gray-100",children:e}),f.jsx("p",{children:t})]})}function I2e({children:e}){return f.jsx("code",{className:"rounded bg-gray-100 px-1 font-mono text-[12px] text-gray-700 dark:bg-gray-800 dark:text-gray-300",children:e})}function tf({children:e}){return f.jsx("kbd",{className:"rounded border border-gray-300 bg-gray-100 px-1 text-[11px] font-medium text-gray-600 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",children:e})}function A2e(){const e=zi();return e.teamInsights||e.activityDigest||e.slackDigest||e.issueLinks}function R2e(e){return gn({queryKey:["pro-settings"],queryFn:it.proSettings,enabled:e,staleTime:6e4})}function O2e(){const e=nn();return kn({mutationFn:t=>it.updateProSettings(t),onSuccess:(t,n)=>{e.setQueryData(["pro-settings"],t),n.issue&&(e.invalidateQueries({queryKey:["pr"]}),e.invalidateQueries({queryKey:["thread"]})),n.sprint&&(e.invalidateQueries({queryKey:["team-insights"]}),e.invalidateQueries({queryKey:["team-metrics-detail"]}),e.invalidateQueries({queryKey:["sprint-report"]}))}})}function _b({title:e,desc:t,children:n}){return f.jsxs("section",{className:"border-b border-gray-100 pb-4 last:border-b-0 dark:border-gray-800",children:[f.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:e}),t!=null&&f.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:t}),f.jsx("div",{className:"mt-2.5 space-y-2.5",children:n})]})}function ka({label:e,htmlFor:t,hint:n,children:r}){return f.jsxs("label",{htmlFor:t,className:"flex flex-col gap-1 text-xs",children:[f.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:e}),r,n!=null&&f.jsx("span",{className:"text-[11px] text-gray-400",children:n})]})}const Ta="w-full rounded border border-gray-300 bg-white px-2 py-1 text-xs text-gray-800 outline-none focus:border-sky-400 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100";function wb({dirty:e,saving:t,onClick:n}){return f.jsx("button",{type:"button",onClick:n,disabled:!e||t,className:"self-start rounded bg-sky-600 px-3 py-1 text-xs font-medium text-white hover:bg-sky-700 disabled:cursor-not-allowed disabled:opacity-40",children:t?"Saving…":"Save"})}const D2e=[7,14,21,28],pD=[{value:"rolling_14",label:"Rolling 14 days (default)",hint:"Trailing 14 days vs the prior 14 — always a full window, no sprint needed. Best if you don’t run fixed sprints."},{value:"rolling_7",label:"Rolling 7 days",hint:"Trailing 7 days vs the prior 7 — a tighter, more responsive momentum read."},{value:"sprint",label:"Sprint position (like-for-like)",hint:"This sprint SO FAR vs the SAME point in the previous sprint (e.g. day 3 vs day 3). Needs a start date + cadence below."}];function P2e({settings:e,save:t,saving:n}){var I,F;const r=e.sprint.comparisonMode,s=e.sprint.cadenceDays??14,a=((I=e.sprint.startDate)==null?void 0:I.slice(0,10))??"",[o,l]=D.useState(r),[u,d]=D.useState(s),[p,m]=D.useState(!D2e.includes(s)),[g,y]=D.useState(a),_=o==="sprint",S=o!==r||_&&(u!==s||g!==a),E=a!==""||e.sprint.cadenceDays!=null,N=(F=pD.find(P=>P.value===o))==null?void 0:F.hint,C=()=>t({sprint:_?{comparisonMode:o,cadenceDays:u,startDate:g===""?null:g}:{comparisonMode:o}}),O=()=>{const P=o==="sprint"?"rolling_14":o;l(P),y(""),m(!1),d(14),t({sprint:{comparisonMode:P,cadenceDays:null,startDate:null}})};return f.jsxs(_b,{title:"Sprint",desc:"How the Insights flow-metrics compare over time. Open PRs always count, regardless of the window.",children:[f.jsx(ka,{label:"Comparison window",hint:N,children:f.jsx("select",{className:Ta,value:o,onChange:P=>l(P.target.value),children:pD.map(P=>f.jsx("option",{value:P.value,children:P.label},P.value))})}),_&&f.jsxs(f.Fragment,{children:[f.jsx(ka,{label:"Cadence",children:f.jsxs("select",{className:Ta,value:p?"custom":String(u),onChange:P=>{P.target.value==="custom"?m(!0):(m(!1),d(Number(P.target.value)))},children:[f.jsx("option",{value:"7",children:"1 week"}),f.jsx("option",{value:"14",children:"2 weeks"}),f.jsx("option",{value:"21",children:"3 weeks"}),f.jsx("option",{value:"28",children:"4 weeks"}),f.jsx("option",{value:"custom",children:"Custom…"})]})}),p&&f.jsx(ka,{label:"Sprint length (days)",children:f.jsx("input",{type:"number",min:1,max:90,className:Ta,value:u,onChange:P=>d(Math.max(1,Math.min(90,Number(P.target.value)||1)))})}),f.jsx(ka,{label:"Start date",hint:"The day your first/any sprint began — cadence rolls forward from here.",children:f.jsx("input",{type:"date",className:Ta,value:g,onChange:P=>y(P.target.value)})}),g===""&&f.jsx("p",{className:"text-[11px] text-amber-600 dark:text-amber-400",children:"Set a start date to use sprint-position comparison — until then the Insights fall back to a rolling 14-day window."})]}),f.jsx(wb,{dirty:S,saving:n,onClick:C}),E&&f.jsx("div",{className:"mt-3 border-t border-gray-100 pt-3 dark:border-gray-800",children:f.jsx("button",{type:"button",onClick:O,disabled:n,className:"text-[11px] text-gray-400 underline hover:text-red-500 disabled:opacity-50",title:"Remove the sprint start date + cadence and use a rolling 14-day tracker",children:"Clear sprint dates (disable sprints)"})})]})}const mD=Array.from({length:24},(e,t)=>t),gD=e=>{const t=e<12;return`${e%12===0?12:e%12}:00 ${t?"AM":"PM"}`};function M2e({settings:e,save:t,saving:n}){const r=e.slack,[s,a]=D.useState(""),[o,l]=D.useState(r.cadence),[u,d]=D.useState(r.hour1),[p,m]=D.useState(r.hour2),[g,y]=D.useState({busy:!1,msg:null,ok:!1}),_=async()=>{y({busy:!0,msg:null,ok:!1});try{const E=await it.testSlackDigest();y({busy:!1,ok:E.sent,msg:E.sent?"Sent — check Slack.":E.message??"Not sent."})}catch(E){y({busy:!1,ok:!1,msg:E.message})}},S=s.trim()!==""||o!==r.cadence||u!==r.hour1||p!==r.hour2;return f.jsxs(_b,{title:"Slack digest",desc:"Deliver the sprint + repo digest to a Slack channel on a schedule. Report is generated fresh at send time.",children:[f.jsx(ka,{label:"Incoming webhook URL",hint:r.configured?f.jsx("span",{className:"text-emerald-500",children:"A webhook is configured. Enter a new URL to replace it, or clear it to disable."}):"Create one at api.slack.com/apps → Incoming Webhooks.",children:f.jsx("input",{type:"url",className:Ta,placeholder:r.configured?"•••••••• (unchanged)":"https://hooks.slack.com/services/…",value:s,onChange:E=>a(E.target.value)})}),f.jsx(ka,{label:"Cadence",children:f.jsxs("select",{className:Ta,value:o,onChange:E=>l(E.target.value),children:[f.jsx("option",{value:"off",children:"Off"}),f.jsx("option",{value:"daily",children:"Daily"}),f.jsx("option",{value:"twice_daily",children:"Twice daily"})]})}),o!=="off"&&f.jsxs("div",{className:"flex gap-2",children:[f.jsx(ka,{label:"Send at",hint:e.slack.timezone??"server time",children:f.jsx("select",{className:Ta,value:u,onChange:E=>d(Number(E.target.value)),children:mD.map(E=>f.jsx("option",{value:E,children:gD(E)},E))})}),o==="twice_daily"&&f.jsx(ka,{label:"And at",children:f.jsx("select",{className:Ta,value:p,onChange:E=>m(Number(E.target.value)),children:mD.map(E=>f.jsx("option",{value:E,children:gD(E)},E))})})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(wb,{dirty:S,saving:n,onClick:()=>{const E={cadence:o,hour1:u,hour2:p};s.trim()!==""&&(E.webhookUrl=s.trim()),t({slack:E}),a("")}}),r.configured&&f.jsx("button",{type:"button",onClick:_,disabled:g.busy,className:"rounded border border-gray-300 px-3 py-1 text-xs font-medium text-gray-600 hover:bg-gray-100 disabled:opacity-40 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:g.busy?"Sending…":"Send test"}),r.configured&&f.jsx("button",{type:"button",onClick:()=>{a(""),t({slack:{webhookUrl:""}})},disabled:n,className:"rounded px-2 py-1 text-xs font-medium text-red-500 hover:bg-red-50 disabled:opacity-40 dark:hover:bg-red-950",children:"Remove webhook"}),g.msg!=null&&f.jsx("span",{className:`text-[11px] ${g.ok?"text-emerald-500":"text-red-500"}`,children:g.msg})]})]})}const dv=5,L2e=[{value:"manual",label:"Manual",desc:"Only regenerate when you click Refresh."},{value:"interval",label:"Every N minutes",desc:"Regenerate on a timer (unchanged repos cost nothing)."},{value:"on_change",label:"When a change is detected",desc:"Regenerate after a sync that changed a watched repo."}];function F2e({settings:e,save:t,saving:n}){const r=e.aiUpdate,[s,a]=D.useState(r.mode),[o,l]=D.useState(r.intervalMinutes),u=s!==r.mode||s==="interval"&&o!==r.intervalMinutes;return f.jsxs(_b,{title:"AI summary updates",desc:"Controls when the Pro Haiku digests / sprint report regenerate.",children:[f.jsx("div",{className:"space-y-1.5",children:L2e.map(d=>f.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[f.jsx("input",{type:"radio",name:"ai-update-mode",className:"mt-0.5",checked:s===d.value,onChange:()=>a(d.value)}),f.jsxs("span",{children:[f.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:d.label}),f.jsx("span",{className:"block text-[11px] text-gray-400",children:d.desc})]})]},d.value))}),s==="interval"&&f.jsx(ka,{label:"Interval (minutes)",hint:`Minimum ${dv}.`,children:f.jsx("input",{type:"number",min:dv,className:Ta,value:o,onChange:d=>l(Math.max(dv,Number(d.target.value)||dv))})}),f.jsx(wb,{dirty:u,saving:n,onClick:()=>t({aiUpdate:{mode:s,intervalMinutes:o}})})]})}const j2e={jira:"https://your-org.atlassian.net",linear:"https://linear.app/your-workspace"};function $2e({settings:e,save:t,saving:n}){const r=e.issue,[s,a]=D.useState(r.provider??""),[o,l]=D.useState(r.baseUrl??""),u=r.projectKeys.join(", "),[d,p]=D.useState(u),m=d.split(/[\s,]+/).map(y=>y.trim().toUpperCase()).filter(y=>y!==""),g=(s||null)!==r.provider||o.trim()!==(r.baseUrl??"")||m.join(",")!==r.projectKeys.join(",");return f.jsxs(_b,{title:"Issue tracker",desc:"Link Jira/Linear tickets detected in a PR's title or branch into the PR details.",children:[f.jsx(ka,{label:"Provider",children:f.jsxs("select",{className:Ta,value:s,onChange:y=>a(y.target.value),children:[f.jsx("option",{value:"",children:"None"}),f.jsx("option",{value:"jira",children:"Jira"}),f.jsx("option",{value:"linear",children:"Linear"})]})}),s!==""&&f.jsxs(f.Fragment,{children:[f.jsx(ka,{label:"Base URL",hint:s==="jira"?"Tickets link to {base}/browse/KEY-123.":"Tickets link to {base}/issue/KEY-123.",children:f.jsx("input",{type:"url",className:Ta,placeholder:j2e[s],value:o,onChange:y=>l(y.target.value)})}),f.jsx(ka,{label:"Project keys",hint:"Optional, comma-separated (e.g. ENG, PROJ). When set, ONLY these prefixes are detected (in the title AND branch) — the most reliable way to avoid false matches like GPT-4 or node-18. Leave blank to detect uppercase keys in the PR title only.",children:f.jsx("input",{type:"text",className:Ta,placeholder:"ENG, PROJ",value:d,onChange:y=>p(y.target.value)})})]}),f.jsx(wb,{dirty:g,saving:n,onClick:()=>t({issue:{provider:s===""?null:s,baseUrl:o.trim()===""?null:o.trim(),projectKeys:m}})})]})}function B2e({onClose:e}){const t=zi(),n=R2e(!0),r=O2e(),s=o=>{r.mutate(o)};D.useEffect(()=>{const o=l=>{l.key==="Escape"&&(l.stopImmediatePropagation(),e())};return window.addEventListener("keydown",o,!0),()=>window.removeEventListener("keydown",o,!0)},[e]);const a=n.data;return f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:e,role:"presentation",children:f.jsxs("div",{className:"flex max-h-[85vh] w-[30rem] max-w-[92vw] flex-col rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-900",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Settings",children:[f.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[f.jsx("h2",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:"Settings"}),f.jsx("button",{type:"button",onClick:e,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-200","aria-label":"Close (Esc)",title:"Close (Esc)",children:"✕"})]}),f.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto px-4 py-3",children:[r.isError&&f.jsx("p",{className:"rounded bg-red-50 px-2 py-1 text-xs text-red-600 dark:bg-red-950 dark:text-red-300",children:r.error.message}),n.isLoading||a==null?f.jsx("p",{className:"py-6 text-center text-xs text-gray-400",children:n.isError?"Settings unavailable.":"Loading…"}):f.jsxs(f.Fragment,{children:[t.teamInsights&&f.jsx(P2e,{settings:a,save:s,saving:r.isPending}),t.slackDigest&&f.jsx(M2e,{settings:a,save:s,saving:r.isPending}),t.activityDigest&&f.jsx(F2e,{settings:a,save:s,saving:r.isPending}),t.issueLinks&&f.jsx($2e,{settings:a,save:s,saving:r.isPending})]})]})]})})}const U2e={expired:"Your sign-in link expired. Please sign in again.",failed:"We couldn’t complete sign-in with GitHub. Please try again.",error:"Something went wrong reaching GitHub. Please try again in a moment."};function H2e(){const[e]=D.useState(()=>{const t=new URLSearchParams(window.location.search).get("auth");return t?U2e[t]??"We couldn’t complete sign-in. Please try again.":null});return D.useEffect(()=>{if(!e)return;const t=new URL(window.location.href);t.searchParams.delete("auth"),window.history.replaceState({},"",t.pathname+t.search+t.hash)},[e]),f.jsx("div",{className:"flex h-full min-h-screen w-full items-center justify-center bg-gray-950 px-4 text-gray-100",children:f.jsxs("div",{className:"flex w-full max-w-sm flex-col items-center rounded-2xl border border-gray-800 bg-gray-900/40 px-8 py-10 text-center shadow-xl",children:[f.jsx("span",{className:"brand-title text-4xl",title:"Pierre — a play on “PR”",children:"Pierre"}),f.jsx("p",{className:"mt-4 text-sm text-gray-400",children:"Sign in to view your team’s GitHub activity — pull requests, reviews, and what needs your attention."}),e&&f.jsx("div",{role:"alert",className:"mt-6 w-full rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs text-amber-200",children:e}),f.jsxs("a",{href:"/api/auth/login",className:"mt-7 inline-flex w-full items-center justify-center gap-2 rounded-lg bg-blue-600 px-4 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-sky-400 focus:ring-offset-2 focus:ring-offset-gray-950",children:[f.jsx("svg",{viewBox:"0 0 16 16",width:"18",height:"18",fill:"currentColor","aria-hidden":"true",children:f.jsx("path",{fillRule:"evenodd",d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8Z"})}),"Sign in with GitHub"]}),f.jsx("p",{className:"mt-5 text-xs leading-relaxed text-gray-500",children:"Read-only access. Add any public repo instantly; private repos only when you install Pierre on them. Revoke anytime from GitHub settings."})]})})}function z2e({user:e,canSignOut:t,onSignOut:n,onOpenSettings:r}){const[s,a]=D.useState(!1),o=D.useRef(null),l=e.displayName??e.login;Do(o,()=>a(!1),s),D.useEffect(()=>{if(!s)return;const d=p=>{p.key==="Escape"&&(p.stopPropagation(),a(!1))};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[s]);const u=e.avatarUrl!=null?f.jsx("img",{src:e.avatarUrl,alt:l,width:20,height:20,className:"shrink-0 rounded-full",style:{width:20,height:20}}):f.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-full bg-gray-300 text-[9px] font-semibold text-gray-700 dark:bg-gray-700 dark:text-gray-200",style:{width:20,height:20},children:l.slice(0,2).toUpperCase()});return f.jsxs("div",{ref:o,className:"relative",children:[f.jsxs("button",{type:"button",onClick:()=>a(d=>!d),"aria-haspopup":"menu","aria-expanded":s,className:`flex items-center gap-1.5 rounded px-1.5 py-0.5 text-xs font-medium text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800 ${s?"bg-gray-100 dark:bg-gray-800":""}`,title:e.displayName!=null?`Signed in as ${e.displayName} (@${e.login})`:`Signed in as ${e.login}`,children:[u,f.jsx("span",{className:"max-w-[10rem] truncate",children:l}),f.jsx("span",{"aria-hidden":"true",className:"text-[9px] text-gray-400",children:"▾"})]}),s&&f.jsxs("div",{role:"menu","aria-label":"Account menu",className:"absolute right-0 top-full z-[60] mt-1 w-52 rounded-lg border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[r!=null&&f.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{a(!1),r()},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-800",children:[f.jsxs("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[f.jsx("circle",{cx:"12",cy:"12",r:"3"}),f.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),"Settings"]}),f.jsxs("a",{role:"menuitem",href:dk(e.login),target:"_blank",rel:"noreferrer noopener",onClick:()=>a(!1),className:"flex items-center gap-2 px-3 py-1.5 text-xs text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-800",children:[f.jsx(kL,{size:13}),"Open Profile on GitHub"]}),t&&f.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{a(!1),n()},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-800",children:[f.jsxs("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[f.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),f.jsx("polyline",{points:"16 17 21 12 16 7"}),f.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]}),"Sign Out"]})]})]})}const Y2e=["7d","14d","30d","90d","custom"];function uw(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(r=>n.has(r))}function cw(e){if(!e)return null;const t=e.split(",").map(n=>Number.parseInt(n,10)).filter(Number.isFinite);return t.length?t:null}function W2e(){const e=new URLSearchParams(window.location.search),t={},n=e.get("preset");n&&Y2e.includes(n)&&(t.preset=n),t.repoIds=cw(e.get("repos")),t.userIds=cw(e.get("users")),e.get("bots")!==null&&(t.excludeBots=e.get("bots")==="1");const r=cw(e.get("allowBots"));r&&(t.allowedBotIds=r);const s=e.get("stale");s==="0"?t.excludeStale=!1:s==="1"&&(t.excludeStale=!0),t.customFrom=e.get("from"),t.customTo=e.get("to");const a=e.get("cats");if(a){const y=new Set(em);t.categories=a.split(",").filter(_=>y.has(_))}const o=e.get("status");if(o!==null){const y=new Set(tm);t.prStatuses=o.split(",").filter(_=>y.has(_))}const l=e.get("reviews");if(l!==null){const y=new Set(nm);t.reviewStates=l.split(",").filter(_=>y.has(_))}const u=e.get("states");if(u){const y=new Set(rk);t.derivedStates=u.split(",").filter(_=>y.has(_))}const d=e.get("pr");d&&(t.selectedPrId=Number.parseInt(d,10));const p=e.get("thread");p&&(t.selectedThreadId=Number.parseInt(p,10));const m=e.get("strip");(m==="my_turn"||m==="needs_attention"||m==="all")&&(t.stripFilter=m);const g=e.get("activityRepo");if(g){const y=Number.parseInt(g,10);Number.isFinite(y)&&(t.activityRepoId=y)}return e.get("open")==="1"&&(t.stripCollapsed=!1),t}function vD(e){var s,a;const t=new URLSearchParams;e.preset!=="14d"&&t.set("preset",e.preset),(s=e.repoIds)!=null&&s.length&&t.set("repos",e.repoIds.join(",")),(a=e.userIds)!=null&&a.length&&t.set("users",e.userIds.join(",")),e.excludeBots&&t.set("bots","1"),e.excludeBots&&e.allowedBotIds.length&&t.set("allowBots",e.allowedBotIds.join(",")),e.excludeStale||t.set("stale","0"),e.preset==="custom"&&e.customFrom&&t.set("from",e.customFrom),e.preset==="custom"&&e.customTo&&t.set("to",e.customTo),uw(e.categories,Dv)||t.set("cats",e.categories.join(",")),uw(e.prStatuses,Mv)||t.set("status",e.prStatuses.join(",")),uw(e.reviewStates,Pv)||t.set("reviews",e.reviewStates.join(",")),e.derivedStates.length&&t.set("states",e.derivedStates.join(",")),e.selectedPrId&&t.set("pr",String(e.selectedPrId)),e.selectedThreadId&&t.set("thread",String(e.selectedThreadId)),e.stripFilter!=="all"&&t.set("strip",e.stripFilter),e.stripCollapsed||t.set("open","1"),Wt.getState().activeTab==="activity"&&(t.set("view","activity"),typeof e.activityRepoId=="number"&&t.set("activityRepo",String(e.activityRepoId)));const n=t.toString(),r=`${window.location.pathname}${n?`?${n}`:""}`;r!==window.location.pathname+window.location.search&&window.history.replaceState(null,"",r)}const nj="pierre:filterBarState";function G2e(){try{const e=localStorage.getItem(nj);if(!e)return null;const t=JSON.parse(e);return t&&typeof t=="object"?ky(t):null}catch{return null}}function V2e(e){try{localStorage.setItem(nj,JSON.stringify(Iw(e)))}catch{}}function q2e(){const e=D.useRef(!1);D.useEffect(()=>{if(!e.current){if(window.location.search.length>1)Me.getState().hydrate(W2e()),new URLSearchParams(window.location.search).get("view")==="activity"&&Wt.getState().setActiveTab("activity");else{const s=T8(),a=s?ky(s.state):G2e();a&&Me.getState().hydrate(a),Wt.getState().setActiveTab("activity")}e.current=!0}const t=Me.subscribe(r=>{vD(r),V2e(r)}),n=Wt.subscribe(()=>{vD(Me.getState())});return()=>{t(),n()}},[])}function yD(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable}function K2e(){const{data:e}=eP();D.useEffect(()=>{const t=n=>{var u;const{selectedPrId:r,selectPr:s,clearSelection:a}=Me.getState(),o=Wt.getState(),l=o.activeTab==="timeline";if(n.key==="Escape"){yD(n.target)?n.target.blur():l?a():o.showTimeline();return}if(!yD(n.target)){if(n.key==="/"){n.preventDefault(),(u=document.getElementById("add-repo-input"))==null||u.focus();return}if(n.key==="i"){o.showActivity();return}if(l&&(n.key==="j"||n.key==="k")){const d=[...(e==null?void 0:e.prs)??[]].sort((y,_)=>_.openedAt.localeCompare(y.openedAt));if(d.length===0)return;const p=d.findIndex(y=>y.id===r);let m;p===-1?m=0:m=n.key==="j"?p+1:p-1,m=Math.max(0,Math.min(d.length-1,m));const g=d[m];g&&s(g.id)}}};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e])}function Q2e(){const e=nn();D.useEffect(()=>{let t=null;const n=()=>{const a=new Map,o=(l,u)=>{const d=a.get(l);(!d||u>d)&&a.set(l,u)};for(const[,l]of e.getQueriesData({queryKey:["timeline"]}))for(const u of(l==null?void 0:l.prs)??[])o(u.id,u.updatedAt);for(const[,l]of e.getQueriesData({queryKey:["open-prs"]}))for(const u of(l==null?void 0:l.prs)??[])o(u.id,u.updatedAt);for(const[l,u]of a){const d=e.getQueryData(["pr",l]);if(!d||d.updatedAt>=u)continue;const p=e.getQueryState(["pr",l]);if(!(p&&p.fetchStatus!=="idle")){e.invalidateQueries({queryKey:["pr",l]});for(const m of d.threads??[])e.invalidateQueries({queryKey:["thread",m.id]})}}},r=()=>{t||(t=setTimeout(()=>{t=null,n()},300))};r();const s=e.getQueryCache().subscribe(a=>{const o=a.query.queryKey[0];(o==="timeline"||o==="open-prs")&&r()});return()=>{t&&clearTimeout(t),s()}},[e])}function X2e(e){const{data:t}=nP(),n=D.useRef(null);D.useEffect(()=>{if(!t)return;const r=new Set;for(const g of t.awaitingReview)r.add(`r:${g.prId}`);for(const g of t.yourPrs)r.add(`p:${g.prId}`);for(const g of t.approvedPrs??[])r.add(`a:${g.prId}`);for(const g of t.threadsAwaiting)r.add(`t:${g.threadId}`);for(const g of t.watchedRepoPrs)r.add(`w:${g.prId}`);const s=n.current;if(n.current=r,s==null||!e||typeof Notification>"u"||Notification.permission!=="granted")return;const a=[...r].filter(g=>!s.has(g));if(a.length===0)return;const o=a.filter(g=>g.startsWith("r:")).length,l=a.filter(g=>g.startsWith("t:")).length,u=a.filter(g=>g.startsWith("p:")).length,d=a.filter(g=>g.startsWith("a:")).length,p=a.filter(g=>g.startsWith("w:")).length,m=[];o&&m.push(`${o} review${o===1?"":"s"} requested`),l&&m.push(`${l} thread${l===1?"":"s"} awaiting you`),u&&m.push(`${u} of your PRs active`),d&&m.push(`${d} of your PRs approved`),p&&m.push(`${p} new in watched repos`);try{const g=new Notification(`Pierre — ${a.length} new in My Turn`,{body:m.join(" · "),tag:"pierre-my-turn"});g.onclick=()=>{window.focus(),g.close()}}catch{}},[t,e])}const dw="";function Z2e(e){return/^G-[A-Z0-9]{6,}$/i.test(e)&&e!=="G-XXXXXXXXXX"}let qE=!1;function J2e(){if(qE||typeof window>"u"||!Z2e(dw))return;qE=!0;const e=document.createElement("script");e.async=!0,e.src=`https://www.googletagmanager.com/gtag/js?id=${dw}`,document.head.appendChild(e),window.dataLayer=window.dataLayer||[],window.gtag=function(){window.dataLayer.push(arguments)},window.gtag("js",new Date),window.gtag("config",dw,{send_page_view:!1})}function eAe(e=window.location.pathname){!qE||!window.gtag||window.gtag("event","page_view",{page_path:e,page_location:`${window.location.origin}${e}`,page_title:document.title})}function tAe(){const[e,t]=D.useState(()=>(localStorage.getItem("theme")??"dark")!=="light");return D.useEffect(()=>{document.documentElement.classList.toggle("dark",e),localStorage.setItem("theme",e?"dark":"light")},[e]),[e,()=>t(n=>!n)]}function nAe(){var Z,ee;const e=uk();q2e(),K2e(),Q2e();const[t,n]=tAe(),[r,s]=D.useState(!1),[a,o]=D.useState(!1),l=A2e(),[u,d]=tj(),p=typeof window<"u"&&"Notification"in window;X2e(u&&p);const m=()=>{if(p){if(u){d(!1);return}Notification.permission==="granted"?d(!0):Notification.permission!=="denied"&&Notification.requestPermission().then(j=>d(j==="granted"))}},g=((Z=e.data)==null?void 0:Z.deploymentMode)==="cloud",y=((ee=e.data)==null?void 0:ee.user)??null,_=()=>{Wt.getState().clear(),it.logout().finally(()=>window.location.assign("/"))},S=Me(j=>j.selectedPrId),E=Me(j=>j.selectedThreadId),N=Wt(j=>j.activeTab),C=Wt(j=>j.tabs),O=N!=="timeline"&&N!=="activity"?C.find(j=>j.key===N)??null:null,I=N==="activity",F=(O==null?void 0:O.kind)==="pr-detail"?O.prId:null,P=(O==null?void 0:O.kind)==="metrics-detail",H=(O==null?void 0:O.kind)==="pr-focus"?{kind:"isolate",prId:O.prId}:null,B=F!=null||I||P,W=S!=null&&!B,[M,z]=z6("pierre:detailPaneHeight",384),K=D.useRef(null),V=D.useRef(null),G=D.useRef(null);D.useEffect(()=>{for(const j of[V.current,K.current])j&&(B?j.setAttribute("inert",""):j.removeAttribute("inert"))},[B]),D.useEffect(()=>{const j=()=>Wt.getState().navigateBack();return window.addEventListener("popstate",j),()=>window.removeEventListener("popstate",j)},[]),D.useEffect(()=>{window.dispatchEvent(new Event("resize"))},[W]);const X=j=>{var J;G.current={startY:j.clientY,startH:((J=K.current)==null?void 0:J.offsetHeight)??M},j.currentTarget.setPointerCapture(j.pointerId)},pe=j=>{const J=G.current;if(!J||!K.current)return;const he=window.innerHeight*.7,Y=Math.min(Math.max(J.startH+(J.startY-j.clientY),160),he);K.current.style.height=`${Y}px`,window.dispatchEvent(new Event("resize"))},ye=j=>{!G.current||!K.current||(G.current=null,j.currentTarget.releasePointerCapture(j.pointerId),z(K.current.offsetHeight))};return D.useEffect(()=>{if(!g)return;const j=()=>{it.me().catch(()=>{})},J=window.setInterval(j,180*1e3);return()=>window.clearInterval(J)},[g]),D.useEffect(()=>{g&&(J2e(),eAe())},[g]),e.error instanceof Hi&&e.error.status===401?f.jsx(H2e,{}):e.isLoading&&!e.data?f.jsx("div",{className:"flex h-full min-h-screen items-center justify-center bg-gray-950",children:f.jsx("span",{className:"brand-title text-4xl text-gray-100",children:"Pierre"})}):f.jsxs("div",{className:"flex h-full flex-col",children:[f.jsxs("header",{className:"flex items-center gap-3 border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[f.jsx("h1",{className:"brand-title",title:"Pierre — a play on “PR”",children:"Pierre"}),f.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[f.jsx(S2e,{}),f.jsx(T2e,{}),p&&f.jsx("button",{type:"button",onClick:m,"aria-pressed":u,className:`rounded border px-2 py-0.5 text-xs hover:border-gray-400 dark:hover:border-gray-500 ${u?"border-blue-400 text-blue-600 dark:border-blue-600 dark:text-blue-400":"border-gray-300 dark:border-gray-700"}`,title:u?"Notifications on — alerts when a new item enters your My Turn. Click to turn off.":"Turn on browser notifications for new My Turn items","aria-label":"Toggle My Turn notifications",children:f.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:u?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[f.jsx("path",{d:"M18 8a6 6 0 0 0-12 0c0 7-3 9-3 9h18s-3-2-3-9"}),f.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}),f.jsx("button",{type:"button",onClick:()=>s(!0),className:"rounded border border-gray-300 px-2 py-0.5 text-xs font-semibold hover:border-gray-400 dark:border-gray-700 dark:hover:border-gray-500",title:"Help — what is Pierre and how to use it","aria-label":"Help",children:"?"}),f.jsx("button",{type:"button",onClick:n,className:"rounded border border-gray-300 px-2 py-0.5 text-xs hover:border-gray-400 dark:border-gray-700 dark:hover:border-gray-500",title:"Toggle dark mode",children:t?"☀":"☾"}),y!=null&&f.jsx(z2e,{user:y,canSignOut:g,onSignOut:_,onOpenSettings:l?()=>o(!0):null})]})]}),r&&f.jsx(C2e,{onClose:()=>s(!1)}),a&&f.jsx(B2e,{onClose:()=>o(!1)}),f.jsx(N2e,{}),f.jsx(mK,{}),f.jsx(xK,{}),f.jsx(NK,{}),f.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[f.jsx("section",{ref:V,className:"min-h-0 flex-1 overflow-hidden",children:H==null?f.jsx(KO,{},"board"):f.jsx(KO,{mode:H},`focus:${H.prId}`)}),W&&f.jsxs(f.Fragment,{children:[f.jsx("div",{role:"separator","aria-orientation":"horizontal","aria-label":"Resize detail pane",onPointerDown:X,onPointerMove:pe,onPointerUp:ye,title:"Drag to resize",className:"h-1 shrink-0 cursor-row-resize bg-gray-200 transition-colors hover:bg-blue-400 dark:bg-gray-800 dark:hover:bg-blue-500"}),f.jsx("section",{ref:K,style:{height:M},className:"shrink-0 overflow-auto",children:f.jsx(v2e,{})})]}),F!=null&&f.jsx("div",{"data-testid":"pinned-pr-overlay",className:"absolute inset-0 z-20 bg-white dark:bg-gray-950",children:f.jsx(ML,{prId:F,selectedThreadId:S===F?E:null},F)}),I&&f.jsx("div",{"data-testid":"activity-overlay",className:"absolute inset-0 z-20 overflow-hidden bg-white dark:bg-gray-950",children:f.jsx(a2e,{})}),P&&f.jsx("div",{"data-testid":"metrics-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:f.jsx(g2e,{})})]}),f.jsx(x2e,{})]})}function KE(){}function rAe(e,{interval:t=1e3,onError:n=KE}={}){if(typeof e!="function")throw new Error("argument is not function.");let r=0,s=null,a=!1,o=!1;return async(...l)=>{if(s=l,!o){for(o=!0;a;)await new Promise(u=>nl.setTimeout(u,t));for(;Date.now()<r;)await new Promise(u=>nl.setTimeout(u,r-Date.now()));o=!1,a=!0;try{await e(...s)}catch(u){try{n(u)}catch{}}r=Date.now()+t,a=!1}}}var iAe=({storage:e,key:t="REACT_QUERY_OFFLINE_CACHE",throttleTime:n=1e3,serialize:r=JSON.stringify,deserialize:s=JSON.parse,retry:a})=>{if(e){const o=async l=>{try{const u=await r(l);await e.setItem(t,u);return}catch(u){return u}};return{persistClient:rAe(async l=>{let u=l,d=await o(u),p=0;for(;d&&u;)p++,u=await(a==null?void 0:a({persistedClient:u,error:d,errorCount:p})),u&&(d=await o(u))},{interval:n}),restoreClient:async()=>{const l=await e.getItem(t);if(l)return await s(l)},removeClient:()=>e.removeItem(t)}}return{persistClient:KE,restoreClient:()=>Promise.resolve(void 0),removeClient:KE}};function Eb(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function sAe(e,t){let n;const r=()=>{if(n)return n;const s=indexedDB.open(e);return s.onupgradeneeded=()=>s.result.createObjectStore(t),n=Eb(s),n.then(a=>{a.onclose=()=>n=void 0},()=>{}),n};return(s,a)=>r().then(o=>a(o.transaction(t,s).objectStore(t)))}let fw;function rS(){return fw||(fw=sAe("keyval-store","keyval")),fw}function aAe(e,t=rS()){return t("readonly",n=>Eb(n.get(e)))}function oAe(e,t,n=rS()){return n("readwrite",r=>(r.put(t,e),Eb(r.transaction)))}function lAe(e,t=rS()){return t("readwrite",n=>(n.delete(e),Eb(n.transaction)))}const uAe=iAe({storage:{getItem:e=>aAe(e).then(t=>t??null),setItem:(e,t)=>oAe(e,t),removeItem:e=>lAe(e)},key:"pierre-query-cache",throttleTime:1e3}),cAe=new I$({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1,retry:1}}});var fv,AD;(AD=(fv=navigator.storage)==null?void 0:fv.persist)==null||AD.call(fv);new URLSearchParams(window.location.search).has("perf")&&Bj(()=>import("./perfProbe-Da13EhTE.js"),[]).then(e=>e.startPerfProbe());const rj=document.getElementById("root");if(!rj)throw new Error("#root not found");const dAe=1e3*60*60*24*7;qj.createRoot(rj).render(f.jsx(D.StrictMode,{children:f.jsx(G$,{client:cAe,persistOptions:{persister:uAe,maxAge:dAe,buster:"pierre-detail-v2",dehydrateOptions:{shouldDehydrateQuery:e=>{const t=e.queryKey[0];return(t==="pr"||t==="thread"||t==="pr-files")&&e.state.status==="success"}}},children:f.jsx(nAe,{})})}));
|
package/public/index.html
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
href="https://fonts.googleapis.com/css2?family=Great+Vibes&display=swap"
|
|
21
21
|
rel="stylesheet"
|
|
22
22
|
/>
|
|
23
|
-
<script type="module" crossorigin src="/app/assets/index-
|
|
23
|
+
<script type="module" crossorigin src="/app/assets/index-B1Q1rRQ7.js"></script>
|
|
24
24
|
<link rel="stylesheet" crossorigin href="/app/assets/index-WLWeK-9-.css">
|
|
25
25
|
</head>
|
|
26
26
|
<body>
|