pierre-review 0.1.42 → 0.1.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pierre-review",
3
- "version": "0.1.42",
3
+ "version": "0.1.43",
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",
@@ -1373,6 +1373,6 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1373
1373
  * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
1374
1374
  */var Zke=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],Ew=Zke.join(","),pF=typeof Element>"u",cm=pF?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,ay=!pF&&Element.prototype.getRootNode?function(e){var t;return e==null||(t=e.getRootNode)===null||t===void 0?void 0:t.call(e)}:function(e){return e==null?void 0:e.ownerDocument},sy=function(t,n){var r;n===void 0&&(n=!0);var a=t==null||(r=t.getAttribute)===null||r===void 0?void 0:r.call(t,"inert"),s=a===""||a==="true",o=s||n&&t&&(typeof t.closest=="function"?t.closest("[inert]"):sy(t.parentNode));return o},Jke=function(t){var n,r=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return r===""||r==="true"},eTe=function(t,n,r){if(sy(t))return[];var a=Array.prototype.slice.apply(t.querySelectorAll(Ew));return n&&cm.call(t,Ew)&&a.unshift(t),a=a.filter(r),a},ww=function(t,n,r){for(var a=[],s=Array.from(t);s.length;){var o=s.shift();if(!sy(o,!1))if(o.tagName==="SLOT"){var l=o.assignedElements(),c=l.length?l:o.children,d=ww(c,!0,r);r.flatten?a.push.apply(a,d):a.push({scopeParent:o,candidates:d})}else{var h=cm.call(o,Ew);h&&r.filter(o)&&(n||!t.includes(o))&&a.push(o);var p=o.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(o),v=!sy(p,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(o));if(p&&v){var y=ww(p===!0?o.children:p.children,!0,r);r.flatten?a.push.apply(a,y):a.push({scopeParent:o,candidates:y})}else s.unshift.apply(s,o.children)}}return a},mF=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},gF=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||Jke(t))&&!mF(t)?0:t.tabIndex},tTe=function(t,n){var r=gF(t);return r<0&&n&&!mF(t)?0:r},nTe=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},vF=function(t){return t.tagName==="INPUT"},rTe=function(t){return vF(t)&&t.type==="hidden"},iTe=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(r){return r.tagName==="SUMMARY"});return n},aTe=function(t,n){for(var r=0;r<t.length;r++)if(t[r].checked&&t[r].form===n)return t[r]},sTe=function(t){if(!t.name)return!0;var n=t.form||ay(t),r=function(l){return n.querySelectorAll('input[type="radio"][name="'+l+'"]')},a;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")a=r(window.CSS.escape(t.name));else try{a=r(t.name)}catch(o){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",o.message),!1}var s=aTe(a,t.form);return!s||s===t},oTe=function(t){return vF(t)&&t.type==="radio"},lTe=function(t){return oTe(t)&&!sTe(t)},uTe=function(t){var n,r=t&&ay(t),a=(n=r)===null||n===void 0?void 0:n.host,s=!1;if(r&&r!==t){var o,l,c;for(s=!!((o=a)!==null&&o!==void 0&&(l=o.ownerDocument)!==null&&l!==void 0&&l.contains(a)||t!=null&&(c=t.ownerDocument)!==null&&c!==void 0&&c.contains(t));!s&&a;){var d,h,p;r=ay(a),a=(d=r)===null||d===void 0?void 0:d.host,s=!!((h=a)!==null&&h!==void 0&&(p=h.ownerDocument)!==null&&p!==void 0&&p.contains(a))}}return s},QR=function(t){var n=t.getBoundingClientRect(),r=n.width,a=n.height;return r===0&&a===0},cTe=function(t,n){var r=n.displayCheck,a=n.getShadowRoot;if(r==="full-native"&&"checkVisibility"in t){var s=t.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!s}if(getComputedStyle(t).visibility==="hidden")return!0;var o=cm.call(t,"details>summary:first-of-type"),l=o?t.parentElement:t;if(cm.call(l,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof a=="function"){for(var c=t;t;){var d=t.parentElement,h=ay(t);if(d&&!d.shadowRoot&&a(d)===!0)return QR(t);t.assignedSlot?t=t.assignedSlot:!d&&h!==t.ownerDocument?t=h.host:t=d}t=c}if(uTe(t))return!t.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return QR(t);return!1},dTe=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var n=t.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var a=n.children.item(r);if(a.tagName==="LEGEND")return cm.call(n,"fieldset[disabled] *")?!0:!a.contains(t)}return!0}n=n.parentElement}return!1},fTe=function(t,n){return!(n.disabled||rTe(n)||cTe(n,t)||iTe(n)||dTe(n))},XR=function(t,n){return!(lTe(n)||gF(n)<0||!fTe(t,n))},hTe=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},yF=function(t){var n=[],r=[];return t.forEach(function(a,s){var o=!!a.scopeParent,l=o?a.scopeParent:a,c=tTe(l,o),d=o?yF(a.candidates):l;c===0?o?n.push.apply(n,d):n.push(l):r.push({documentOrder:s,tabIndex:c,item:a,isScope:o,content:d})}),r.sort(nTe).reduce(function(a,s){return s.isScope?a.push.apply(a,s.content):a.push(s.content),a},[]).concat(n)},bF=function(t,n){n=n||{};var r;return n.getShadowRoot?r=ww([t],n.includeContainer,{filter:XR.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:hTe}):r=eTe(t,n.includeContainer,XR.bind(null,n)),yF(r)};function pTe(){return/apple/i.test(navigator.vendor)}function mTe(e){let t=e.activeElement;for(;((n=t)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;t=t.shadowRoot.activeElement}return t}function kw(e,t){if(!e||!t)return!1;const n=t.getRootNode==null?void 0:t.getRootNode();if(e.contains(t))return!0;if(n&&bw(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function gp(e){return"composedPath"in e?e.composedPath()[0]:e.target}function A1(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function gTe(e){return e.matches("html,body")}function dm(e){return(e==null?void 0:e.ownerDocument)||document}function pv(e,t,n){return n===void 0&&(n=!0),e.filter(a=>{var s;return a.parentId===t&&(!n||((s=a.context)==null?void 0:s.open))}).flatMap(a=>[a,...pv(e,a.id,n)])}function vTe(e){return"nativeEvent"in e}var yTe=typeof document<"u",bTe=function(){},Sc=yTe?L.useLayoutEffect:bTe;const xTe={...jO},_Te=xTe.useInsertionEffect,ETe=_Te||(e=>e());function Zd(e){const t=L.useRef(()=>{});return ETe(()=>{t.current=e}),L.useCallback(function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return t.current==null?void 0:t.current(...r)},[])}const xF=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function _F(e,t){const n=bF(e,xF()),r=n.length;if(r===0)return;const a=mTe(dm(e)),s=n.indexOf(a),o=s===-1?t===1?0:r-1:s+t;return n[o]}function wTe(e){return _F(dm(e).body,1)||e}function kTe(e){return _F(dm(e).body,-1)||e}function R1(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!kw(n,r)}function TTe(e){bF(e,xF()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function ZR(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}var EF=BO();function JR(e,t,n){let{reference:r,floating:a}=e;const s=lu(t),o=hF(t),l=fF(o),c=Fc(t),d=s==="y",h=r.x+r.width/2-a.width/2,p=r.y+r.height/2-a.height/2,v=r[l]/2-a[l]/2;let y;switch(c){case"top":y={x:h,y:r.y-a.height};break;case"bottom":y={x:h,y:r.y+r.height};break;case"right":y={x:r.x+r.width,y:p};break;case"left":y={x:r.x-a.width,y:p};break;default:y={x:r.x,y:r.y}}switch(rb(t)){case"start":y[o]-=v*(n&&d?-1:1);break;case"end":y[o]+=v*(n&&d?-1:1);break}return y}async function STe(e,t){var n;t===void 0&&(t={});const{x:r,y:a,platform:s,rects:o,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:h="viewport",elementContext:p="floating",altBoundary:v=!1,padding:y=0}=nb(t,e),_=Xke(y),w=l[v?p==="floating"?"reference":"floating":p],C=iy(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(w)))==null||n?w:w.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:h,strategy:c})),O=p==="floating"?{x:r,y:a,width:o.floating.width,height:o.floating.height}:o.reference,A=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),R=await(s.isElement==null?void 0:s.isElement(A))?await(s.getScale==null?void 0:s.getScale(A))||{x:1,y:1}:{x:1,y:1},F=iy(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:O,offsetParent:A,strategy:c}):O);return{top:(C.top-F.top+_.top)/R.y,bottom:(F.bottom-C.bottom+_.bottom)/R.y,left:(C.left-F.left+_.left)/R.x,right:(F.right-C.right+_.right)/R.x}}const CTe=50,NTe=async(e,t,n)=>{const{placement:r="bottom",strategy:a="absolute",middleware:s=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:STe},c=await(o.isRTL==null?void 0:o.isRTL(t));let d=await o.getElementRects({reference:e,floating:t,strategy:a}),{x:h,y:p}=JR(d,r,c),v=r,y=0;const _={};for(let S=0;S<s.length;S++){const w=s[S];if(!w)continue;const{name:C,fn:O}=w,{x:A,y:R,data:F,reset:M}=await O({x:h,y:p,initialPlacement:r,placement:v,strategy:a,middlewareData:_,rects:d,platform:l,elements:{reference:e,floating:t}});h=A??h,p=R??p,_[C]={..._[C],...F},M&&y<CTe&&(y++,typeof M=="object"&&(M.placement&&(v=M.placement),M.rects&&(d=M.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:a}):M.rects),{x:h,y:p}=JR(d,v,c)),S=-1)}return{x:h,y:p,placement:v,strategy:a,middlewareData:_}},ITe=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:a,middlewareData:s,rects:o,initialPlacement:l,platform:c,elements:d}=t,{mainAxis:h=!0,crossAxis:p=!0,fallbackPlacements:v,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:_="none",flipAlignment:S=!0,...w}=nb(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const C=Fc(a),O=lu(l),A=Fc(l)===l,R=await(c.isRTL==null?void 0:c.isRTL(d.floating)),F=v||(A||!S?[ry(l)]:Wke(l)),M=_!=="none";!v&&M&&F.push(...Kke(l,S,_,R));const Y=[l,...F],B=await c.detectOverflow(t,w),J=[];let P=((r=s.flip)==null?void 0:r.overflows)||[];if(h&&J.push(B[C]),p){const G=Yke(a,o,R);J.push(B[G[0]],B[G[1]])}if(P=[...P,{placement:a,overflows:J}],!J.every(G=>G<=0)){var q,z;const G=(((q=s.flip)==null?void 0:q.index)||0)+1,X=Y[G];if(X&&(!(p==="alignment"?O!==lu(X):!1)||P.every(H=>lu(H.placement)===O?H.overflows[0]>0:!0)))return{data:{index:G,overflows:P},reset:{placement:X}};let de=(z=P.filter(ue=>ue.overflows[0]<=0).sort((ue,H)=>ue.overflows[1]-H.overflows[1])[0])==null?void 0:z.placement;if(!de)switch(y){case"bestFit":{var W;const ue=(W=P.filter(H=>{if(M){const oe=lu(H.placement);return oe===O||oe==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(oe=>oe>0).reduce((oe,j)=>oe+j,0)]).sort((H,oe)=>H[1]-oe[1])[0])==null?void 0:W[0];ue&&(de=ue);break}case"initialPlacement":de=l;break}if(a!==de)return{reset:{placement:de}}}return{}}}},ATe=new Set(["left","top"]);async function RTe(e,t){const{placement:n,platform:r,elements:a}=e,s=await(r.isRTL==null?void 0:r.isRTL(a.floating)),o=Fc(n),l=rb(n),c=lu(n)==="y",d=ATe.has(o)?-1:1,h=s&&c?-1:1,p=nb(t,e);let{mainAxis:v,crossAxis:y,alignmentAxis:_}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&typeof _=="number"&&(y=l==="end"?_*-1:_),c?{x:y*h,y:v*d}:{x:v*d,y:y*h}}const OTe=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:a,y:s,placement:o,middlewareData:l}=t,c=await RTe(t,e);return o===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:a+c.x,y:s+c.y,data:{...c,placement:o}}}}},DTe=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:a,platform:s}=t,{mainAxis:o=!0,crossAxis:l=!1,limiter:c={fn:C=>{let{x:O,y:A}=C;return{x:O,y:A}}},...d}=nb(e,t),h={x:n,y:r},p=await s.detectOverflow(t,d),v=lu(Fc(a)),y=dF(v);let _=h[y],S=h[v];if(o){const C=y==="y"?"top":"left",O=y==="y"?"bottom":"right",A=_+p[C],R=_-p[O];_=VR(A,_,R)}if(l){const C=v==="y"?"top":"left",O=v==="y"?"bottom":"right",A=S+p[C],R=S-p[O];S=VR(A,S,R)}const w=c.fn({...t,[y]:_,[v]:S});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[y]:o,[v]:l}}}}}};function wF(e){const t=xs(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const a=Oo(e),s=a?e.offsetWidth:n,o=a?e.offsetHeight:r,l=ny(n)!==s||ny(r)!==o;return l&&(n=s,r=o),{width:n,height:r,$:l}}function NT(e){return Dr(e)?e:e.contextElement}function df(e){const t=NT(e);if(!Oo(t))return ko(1);const n=t.getBoundingClientRect(),{width:r,height:a,$:s}=wF(t);let o=(s?ny(n.width):n.width)/r,l=(s?ny(n.height):n.height)/a;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const PTe=ko(0);function kF(e){const t=Ja(e);return!eb()||!t.visualViewport?PTe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function MTe(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ja(e)?!1:t}function $c(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect(),s=NT(e);let o=ko(1);t&&(r?Dr(r)&&(o=df(r)):o=df(e));const l=MTe(s,n,r)?kF(s):ko(0);let c=(a.left+l.x)/o.x,d=(a.top+l.y)/o.y,h=a.width/o.x,p=a.height/o.y;if(s){const v=Ja(s),y=r&&Dr(r)?Ja(r):r;let _=v,S=xw(_);for(;S&&r&&y!==_;){const w=df(S),C=S.getBoundingClientRect(),O=xs(S),A=C.left+(S.clientLeft+parseFloat(O.paddingLeft))*w.x,R=C.top+(S.clientTop+parseFloat(O.paddingTop))*w.y;c*=w.x,d*=w.y,h*=w.x,p*=w.y,c+=A,d+=R,_=Ja(S),S=xw(_)}}return iy({width:h,height:p,x:c,y:d})}function ib(e,t){const n=tb(e).scrollLeft;return t?t.left+n:$c(Ro(e)).left+n}function TF(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ib(e,n),a=n.top+t.scrollTop;return{x:r,y:a}}function LTe(e){let{elements:t,rect:n,offsetParent:r,strategy:a}=e;const s=a==="fixed",o=Ro(r),l=t?Jy(t.floating):!1;if(r===o||l&&s)return n;let c={scrollLeft:0,scrollTop:0},d=ko(1);const h=ko(0),p=Oo(r);if((p||!p&&!s)&&((lh(r)!=="body"||Zm(o))&&(c=tb(r)),p)){const y=$c(r);d=df(r),h.x=y.x+r.clientLeft,h.y=y.y+r.clientTop}const v=o&&!p&&!s?TF(o,c):ko(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+h.x+v.x,y:n.y*d.y-c.scrollTop*d.y+h.y+v.y}}function FTe(e){return Array.from(e.getClientRects())}function $Te(e){const t=Ro(e),n=tb(e),r=e.ownerDocument.body,a=Tc(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Tc(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+ib(e);const l=-n.scrollTop;return xs(r).direction==="rtl"&&(o+=Tc(t.clientWidth,r.clientWidth)-a),{width:a,height:s,x:o,y:l}}const eO=25;function jTe(e,t){const n=Ja(e),r=Ro(e),a=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,l=0,c=0;if(a){s=a.width,o=a.height;const h=eb();(!h||h&&t==="fixed")&&(l=a.offsetLeft,c=a.offsetTop)}const d=ib(r);if(d<=0){const h=r.ownerDocument,p=h.body,v=getComputedStyle(p),y=h.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,_=Math.abs(r.clientWidth-p.clientWidth-y);_<=eO&&(s-=_)}else d<=eO&&(s+=d);return{width:s,height:o,x:l,y:c}}function BTe(e,t){const n=$c(e,!0,t==="fixed"),r=n.top+e.clientTop,a=n.left+e.clientLeft,s=Oo(e)?df(e):ko(1),o=e.clientWidth*s.x,l=e.clientHeight*s.y,c=a*s.x,d=r*s.y;return{width:o,height:l,x:c,y:d}}function tO(e,t,n){let r;if(t==="viewport")r=jTe(e,n);else if(t==="document")r=$Te(Ro(e));else if(Dr(t))r=BTe(t,n);else{const a=kF(e);r={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return iy(r)}function SF(e,t){const n=al(e);return n===t||!Dr(n)||Jo(n)?!1:xs(n).position==="fixed"||SF(n,t)}function UTe(e,t){const n=t.get(e);if(n)return n;let r=hu(e,[],!1).filter(l=>Dr(l)&&lh(l)!=="body"),a=null;const s=xs(e).position==="fixed";let o=s?al(e):e;for(;Dr(o)&&!Jo(o);){const l=xs(o),c=CT(o);!c&&l.position==="fixed"&&(a=null),(s?!c&&!a:!c&&l.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||Zm(o)&&!c&&SF(e,o))?r=r.filter(h=>h!==o):a=l,o=al(o)}return t.set(e,r),r}function HTe(e){let{element:t,boundary:n,rootBoundary:r,strategy:a}=e;const o=[...n==="clippingAncestors"?Jy(t)?[]:UTe(t,this._c):[].concat(n),r],l=tO(t,o[0],a);let c=l.top,d=l.right,h=l.bottom,p=l.left;for(let v=1;v<o.length;v++){const y=tO(t,o[v],a);c=Tc(y.top,c),d=ty(y.right,d),h=ty(y.bottom,h),p=Tc(y.left,p)}return{width:d-p,height:h-c,x:p,y:c}}function zTe(e){const{width:t,height:n}=wF(e);return{width:t,height:n}}function YTe(e,t,n){const r=Oo(t),a=Ro(t),s=n==="fixed",o=$c(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const c=ko(0);function d(){c.x=ib(a)}if(r||!r&&!s)if((lh(t)!=="body"||Zm(a))&&(l=tb(t)),r){const y=$c(t,!0,s,t);c.x=y.x+t.clientLeft,c.y=y.y+t.clientTop}else a&&d();s&&!r&&a&&d();const h=a&&!r&&!s?TF(a,l):ko(0),p=o.left+l.scrollLeft-c.x-h.x,v=o.top+l.scrollTop-c.y-h.y;return{x:p,y:v,width:o.width,height:o.height}}function O1(e){return xs(e).position==="static"}function nO(e,t){if(!Oo(e)||xs(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ro(e)===n&&(n=n.ownerDocument.body),n}function CF(e,t){const n=Ja(e);if(Jy(e))return n;if(!Oo(e)){let a=al(e);for(;a&&!Jo(a);){if(Dr(a)&&!O1(a))return a;a=al(a)}return n}let r=nO(e,t);for(;r&&jke(r)&&O1(r);)r=nO(r,t);return r&&Jo(r)&&O1(r)&&!CT(r)?n:r||Hke(e)||n}const WTe=async function(e){const t=this.getOffsetParent||CF,n=this.getDimensions,r=await n(e.floating);return{reference:YTe(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function GTe(e){return xs(e).direction==="rtl"}const VTe={convertOffsetParentRelativeRectToViewportRelativeRect:LTe,getDocumentElement:Ro,getClippingRect:HTe,getOffsetParent:CF,getElementRects:WTe,getClientRects:FTe,getDimensions:zTe,getScale:df,isElement:Dr,isRTL:GTe};function NF(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function qTe(e,t){let n=null,r;const a=Ro(e);function s(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function o(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),s();const d=e.getBoundingClientRect(),{left:h,top:p,width:v,height:y}=d;if(l||t(),!v||!y)return;const _=X0(p),S=X0(a.clientWidth-(h+v)),w=X0(a.clientHeight-(p+y)),C=X0(h),A={rootMargin:-_+"px "+-S+"px "+-w+"px "+-C+"px",threshold:Tc(0,ty(1,c))||1};let R=!0;function F(M){const Y=M[0].intersectionRatio;if(Y!==c){if(!R)return o();Y?o(!1,Y):r=setTimeout(()=>{o(!1,1e-7)},1e3)}Y===1&&!NF(d,e.getBoundingClientRect())&&o(),R=!1}try{n=new IntersectionObserver(F,{...A,root:a.ownerDocument})}catch{n=new IntersectionObserver(F,A)}n.observe(e)}return o(!0),s}function IF(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:a=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,d=NT(e),h=a||s?[...d?hu(d):[],...t?hu(t):[]]:[];h.forEach(C=>{a&&C.addEventListener("scroll",n,{passive:!0}),s&&C.addEventListener("resize",n)});const p=d&&l?qTe(d,n):null;let v=-1,y=null;o&&(y=new ResizeObserver(C=>{let[O]=C;O&&O.target===d&&y&&t&&(y.unobserve(t),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var A;(A=y)==null||A.observe(t)})),n()}),d&&!c&&y.observe(d),t&&y.observe(t));let _,S=c?$c(e):null;c&&w();function w(){const C=$c(e);S&&!NF(S,C)&&n(),S=C,_=requestAnimationFrame(w)}return n(),()=>{var C;h.forEach(O=>{a&&O.removeEventListener("scroll",n),s&&O.removeEventListener("resize",n)}),p==null||p(),(C=y)==null||C.disconnect(),y=null,c&&cancelAnimationFrame(_)}}const KTe=OTe,QTe=DTe,XTe=ITe,ZTe=(e,t,n)=>{const r=new Map,a={platform:VTe,...n},s={...a.platform,_c:r};return NTe(e,t,{...a,platform:s})};var JTe=typeof document<"u",eSe=function(){},mv=JTe?L.useLayoutEffect:eSe;function oy(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!oy(e[r],t[r]))return!1;return!0}if(a=Object.keys(e),n=a.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,a[r]))return!1;for(r=n;r--!==0;){const s=a[r];if(!(s==="_owner"&&e.$$typeof)&&!oy(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function AF(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function rO(e,t){const n=AF(e);return Math.round(t*n)/n}function D1(e){const t=L.useRef(e);return mv(()=>{t.current=e}),t}function tSe(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:a,elements:{reference:s,floating:o}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[h,p]=L.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[v,y]=L.useState(r);oy(v,r)||y(r);const[_,S]=L.useState(null),[w,C]=L.useState(null),O=L.useCallback(H=>{H!==M.current&&(M.current=H,S(H))},[]),A=L.useCallback(H=>{H!==Y.current&&(Y.current=H,C(H))},[]),R=s||_,F=o||w,M=L.useRef(null),Y=L.useRef(null),B=L.useRef(h),J=c!=null,P=D1(c),q=D1(a),z=D1(d),W=L.useCallback(()=>{if(!M.current||!Y.current)return;const H={placement:t,strategy:n,middleware:v};q.current&&(H.platform=q.current),ZTe(M.current,Y.current,H).then(oe=>{const j={...oe,isPositioned:z.current!==!1};G.current&&!oy(B.current,j)&&(B.current=j,EF.flushSync(()=>{p(j)}))})},[v,t,n,q,z]);mv(()=>{d===!1&&B.current.isPositioned&&(B.current.isPositioned=!1,p(H=>({...H,isPositioned:!1})))},[d]);const G=L.useRef(!1);mv(()=>(G.current=!0,()=>{G.current=!1}),[]),mv(()=>{if(R&&(M.current=R),F&&(Y.current=F),R&&F){if(P.current)return P.current(R,F,W);W()}},[R,F,W,P,J]);const X=L.useMemo(()=>({reference:M,floating:Y,setReference:O,setFloating:A}),[O,A]),de=L.useMemo(()=>({reference:R,floating:F}),[R,F]),ue=L.useMemo(()=>{const H={position:n,left:0,top:0};if(!de.floating)return H;const oe=rO(de.floating,h.x),j=rO(de.floating,h.y);return l?{...H,transform:"translate("+oe+"px, "+j+"px)",...AF(de.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:oe,top:j}},[n,l,de.floating,h.x,h.y]);return L.useMemo(()=>({...h,update:W,refs:X,elements:de,floatingStyles:ue}),[h,W,X,de,ue])}const RF=(e,t)=>{const n=KTe(e);return{name:n.name,fn:n.fn,options:[e,t]}},OF=(e,t)=>{const n=QTe(e);return{name:n.name,fn:n.fn,options:[e,t]}},DF=(e,t)=>{const n=XTe(e);return{name:n.name,fn:n.fn,options:[e,t]}},nSe="data-floating-ui-focusable",iO="active",aO="selected",rSe={...jO};let sO=!1,iSe=0;const oO=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+iSe++;function aSe(){const[e,t]=L.useState(()=>sO?oO():void 0);return Sc(()=>{e==null&&t(oO())},[]),L.useEffect(()=>{sO=!0},[]),e}const sSe=rSe.useId,PF=sSe||aSe;function oSe(){const e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(a=>a(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){var r;(r=e.get(t))==null||r.delete(n)}}}const lSe=L.createContext(null),uSe=L.createContext(null),cSe=()=>{var e;return((e=L.useContext(lSe))==null?void 0:e.id)||null},MF=()=>L.useContext(uSe);function IT(e){return"data-floating-ui-"+e}const dSe={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},lO=L.forwardRef(function(t,n){const[r,a]=L.useState();Sc(()=>{pTe()&&a("button")},[]);const s={ref:n,tabIndex:0,role:r,"aria-hidden":r?void 0:!0,[IT("focus-guard")]:"",style:dSe};return m.jsx("span",{...t,...s})}),fSe={clipPath:"inset(50%)",position:"fixed",top:0,left:0},LF=L.createContext(null),uO=IT("portal");function hSe(e){e===void 0&&(e={});const{id:t,root:n}=e,r=PF(),a=pSe(),[s,o]=L.useState(null),l=L.useRef(null);return Sc(()=>()=>{s==null||s.remove(),queueMicrotask(()=>{l.current=null})},[s]),Sc(()=>{if(!r||l.current)return;const c=t?document.getElementById(t):null;if(!c)return;const d=document.createElement("div");d.id=r,d.setAttribute(uO,""),c.appendChild(d),l.current=d,o(d)},[t,r]),Sc(()=>{if(n===null||!r||l.current)return;let c=n||(a==null?void 0:a.portalNode);c&&!ST(c)&&(c=c.current),c=c||document.body;let d=null;t&&(d=document.createElement("div"),d.id=t,c.appendChild(d));const h=document.createElement("div");h.id=r,h.setAttribute(uO,""),c=d||c,c.appendChild(h),l.current=h,o(h)},[t,n,r,a]),s}function FF(e){const{children:t,id:n,root:r,preserveTabOrder:a=!0}=e,s=hSe({id:n,root:r}),[o,l]=L.useState(null),c=L.useRef(null),d=L.useRef(null),h=L.useRef(null),p=L.useRef(null),v=o==null?void 0:o.modal,y=o==null?void 0:o.open,_=!!o&&!o.modal&&o.open&&a&&!!(r||s);return L.useEffect(()=>{if(!s||!a||v)return;function S(w){s&&R1(w)&&(w.type==="focusin"?ZR:TTe)(s)}return s.addEventListener("focusin",S,!0),s.addEventListener("focusout",S,!0),()=>{s.removeEventListener("focusin",S,!0),s.removeEventListener("focusout",S,!0)}},[s,a,v]),L.useEffect(()=>{s&&(y||ZR(s))},[y,s]),m.jsxs(LF.Provider,{value:L.useMemo(()=>({preserveTabOrder:a,beforeOutsideRef:c,afterOutsideRef:d,beforeInsideRef:h,afterInsideRef:p,portalNode:s,setFocusManagerState:l}),[a,s]),children:[_&&s&&m.jsx(lO,{"data-type":"outside",ref:c,onFocus:S=>{if(R1(S,s)){var w;(w=h.current)==null||w.focus()}else{const C=o?o.domReference:null,O=kTe(C);O==null||O.focus()}}}),_&&s&&m.jsx("span",{"aria-owns":s.id,style:fSe}),s&&EF.createPortal(t,s),_&&s&&m.jsx(lO,{"data-type":"outside",ref:d,onFocus:S=>{if(R1(S,s)){var w;(w=p.current)==null||w.focus()}else{const C=o?o.domReference:null,O=wTe(C);O==null||O.focus(),o!=null&&o.closeOnFocusOut&&(o==null||o.onOpenChange(!1,S.nativeEvent,"focus-out"))}}})]})}const pSe=()=>L.useContext(LF),mSe={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},gSe={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},cO=e=>{var t,n;return{escapeKey:typeof e=="boolean"?e:(t=e==null?void 0:e.escapeKey)!=null?t:!1,outsidePress:typeof e=="boolean"?e:(n=e==null?void 0:e.outsidePress)!=null?n:!0}};function $F(e,t){t===void 0&&(t={});const{open:n,onOpenChange:r,elements:a,dataRef:s}=e,{enabled:o=!0,escapeKey:l=!0,outsidePress:c=!0,outsidePressEvent:d="pointerdown",referencePress:h=!1,referencePressEvent:p="pointerdown",ancestorScroll:v=!1,bubbles:y,capture:_}=t,S=MF(),w=Zd(typeof c=="function"?c:()=>!1),C=typeof c=="function"?w:c,O=L.useRef(!1),{escapeKey:A,outsidePress:R}=cO(y),{escapeKey:F,outsidePress:M}=cO(_),Y=L.useRef(!1),B=Zd(G=>{var X;if(!n||!o||!l||G.key!=="Escape"||Y.current)return;const de=(X=s.current.floatingContext)==null?void 0:X.nodeId,ue=S?pv(S.nodesRef.current,de):[];if(!A&&(G.stopPropagation(),ue.length>0)){let H=!0;if(ue.forEach(oe=>{var j;if((j=oe.context)!=null&&j.open&&!oe.context.dataRef.current.__escapeKeyBubbles){H=!1;return}}),!H)return}r(!1,vTe(G)?G.nativeEvent:G,"escape-key")}),J=Zd(G=>{var X;const de=()=>{var ue;B(G),(ue=gp(G))==null||ue.removeEventListener("keydown",de)};(X=gp(G))==null||X.addEventListener("keydown",de)}),P=Zd(G=>{var X;const de=s.current.insideReactTree;s.current.insideReactTree=!1;const ue=O.current;if(O.current=!1,d==="click"&&ue||de||typeof C=="function"&&!C(G))return;const H=gp(G),oe="["+IT("inert")+"]",j=dm(a.floating).querySelectorAll(oe);let te=Dr(H)?H:null;for(;te&&!Jo(te);){const ae=al(te);if(Jo(ae)||!Dr(ae))break;te=ae}if(j.length&&Dr(H)&&!gTe(H)&&!kw(H,a.floating)&&Array.from(j).every(ae=>!kw(te,ae)))return;if(Oo(H)&&W){const ae=Jo(H),Ie=xs(H),me=/auto|scroll/,Xe=ae||me.test(Ie.overflowX),we=ae||me.test(Ie.overflowY),ke=Xe&&H.clientWidth>0&&H.scrollWidth>H.clientWidth,Pe=we&&H.clientHeight>0&&H.scrollHeight>H.clientHeight,Ae=Ie.direction==="rtl",yt=Pe&&(Ae?G.offsetX<=H.offsetWidth-H.clientWidth:G.offsetX>H.clientWidth),ft=ke&&G.offsetY>H.clientHeight;if(yt||ft)return}const ve=(X=s.current.floatingContext)==null?void 0:X.nodeId,Q=S&&pv(S.nodesRef.current,ve).some(ae=>{var Ie;return A1(G,(Ie=ae.context)==null?void 0:Ie.elements.floating)});if(A1(G,a.floating)||A1(G,a.domReference)||Q)return;const Me=S?pv(S.nodesRef.current,ve):[];if(Me.length>0){let ae=!0;if(Me.forEach(Ie=>{var me;if((me=Ie.context)!=null&&me.open&&!Ie.context.dataRef.current.__outsidePressBubbles){ae=!1;return}}),!ae)return}r(!1,G,"outside-press")}),q=Zd(G=>{var X;const de=()=>{var ue;P(G),(ue=gp(G))==null||ue.removeEventListener(d,de)};(X=gp(G))==null||X.addEventListener(d,de)});L.useEffect(()=>{if(!n||!o)return;s.current.__escapeKeyBubbles=A,s.current.__outsidePressBubbles=R;let G=-1;function X(j){r(!1,j,"ancestor-scroll")}function de(){window.clearTimeout(G),Y.current=!0}function ue(){G=window.setTimeout(()=>{Y.current=!1},eb()?5:0)}const H=dm(a.floating);l&&(H.addEventListener("keydown",F?J:B,F),H.addEventListener("compositionstart",de),H.addEventListener("compositionend",ue)),C&&H.addEventListener(d,M?q:P,M);let oe=[];return v&&(Dr(a.domReference)&&(oe=hu(a.domReference)),Dr(a.floating)&&(oe=oe.concat(hu(a.floating))),!Dr(a.reference)&&a.reference&&a.reference.contextElement&&(oe=oe.concat(hu(a.reference.contextElement)))),oe=oe.filter(j=>{var te;return j!==((te=H.defaultView)==null?void 0:te.visualViewport)}),oe.forEach(j=>{j.addEventListener("scroll",X,{passive:!0})}),()=>{l&&(H.removeEventListener("keydown",F?J:B,F),H.removeEventListener("compositionstart",de),H.removeEventListener("compositionend",ue)),C&&H.removeEventListener(d,M?q:P,M),oe.forEach(j=>{j.removeEventListener("scroll",X)}),window.clearTimeout(G)}},[s,a,l,C,d,n,r,v,o,A,R,B,F,J,P,M,q]),L.useEffect(()=>{s.current.insideReactTree=!1},[s,C,d]);const z=L.useMemo(()=>({onKeyDown:B,...h&&{[mSe[p]]:G=>{r(!1,G.nativeEvent,"reference-press")},...p!=="click"&&{onClick(G){r(!1,G.nativeEvent,"reference-press")}}}}),[B,r,h,p]),W=L.useMemo(()=>{function G(X){X.button===0&&(O.current=!0)}return{onKeyDown:B,onMouseDown:G,onMouseUp:G,[gSe[d]]:()=>{s.current.insideReactTree=!0}}},[B,d,s]);return L.useMemo(()=>o?{reference:z,floating:W}:{},[o,z,W])}function vSe(e){const{open:t=!1,onOpenChange:n,elements:r}=e,a=PF(),s=L.useRef({}),[o]=L.useState(()=>oSe()),l=cSe()!=null,[c,d]=L.useState(r.reference),h=Zd((y,_,S)=>{s.current.openEvent=y?_:void 0,o.emit("openchange",{open:y,event:_,reason:S,nested:l}),n==null||n(y,_,S)}),p=L.useMemo(()=>({setPositionReference:d}),[]),v=L.useMemo(()=>({reference:c||r.reference||null,floating:r.floating||null,domReference:r.reference}),[c,r.reference,r.floating]);return L.useMemo(()=>({dataRef:s,open:t,onOpenChange:h,elements:v,events:o,floatingId:a,refs:p}),[t,h,v,o,a,p])}function jF(e){e===void 0&&(e={});const{nodeId:t}=e,n=vSe({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||n,a=r.elements,[s,o]=L.useState(null),[l,c]=L.useState(null),h=(a==null?void 0:a.domReference)||s,p=L.useRef(null),v=MF();Sc(()=>{h&&(p.current=h)},[h]);const y=tSe({...e,elements:{...a,...l&&{reference:l}}}),_=L.useCallback(A=>{const R=Dr(A)?{getBoundingClientRect:()=>A.getBoundingClientRect(),getClientRects:()=>A.getClientRects(),contextElement:A}:A;c(R),y.refs.setReference(R)},[y.refs]),S=L.useCallback(A=>{(Dr(A)||A===null)&&(p.current=A,o(A)),(Dr(y.refs.reference.current)||y.refs.reference.current===null||A!==null&&!Dr(A))&&y.refs.setReference(A)},[y.refs]),w=L.useMemo(()=>({...y.refs,setReference:S,setPositionReference:_,domReference:p}),[y.refs,S,_]),C=L.useMemo(()=>({...y.elements,domReference:h}),[y.elements,h]),O=L.useMemo(()=>({...y,...r,refs:w,elements:C,nodeId:t}),[y,w,C,t,r]);return Sc(()=>{r.dataRef.current.floatingContext=O;const A=v==null?void 0:v.nodesRef.current.find(R=>R.id===t);A&&(A.context=O)}),L.useMemo(()=>({...y,context:O,refs:w,elements:C}),[y,w,C,O])}function P1(e,t,n){const r=new Map,a=n==="item";let s=e;if(a&&e){const{[iO]:o,[aO]:l,...c}=e;s=c}return{...n==="floating"&&{tabIndex:-1,[nSe]:""},...s,...t.map(o=>{const l=o?o[n]:null;return typeof l=="function"?e?l(e):null:l}).concat(e).reduce((o,l)=>(l&&Object.entries(l).forEach(c=>{let[d,h]=c;if(!(a&&[iO,aO].includes(d)))if(d.indexOf("on")===0){if(r.has(d)||r.set(d,[]),typeof h=="function"){var p;(p=r.get(d))==null||p.push(h),o[d]=function(){for(var v,y=arguments.length,_=new Array(y),S=0;S<y;S++)_[S]=arguments[S];return(v=r.get(d))==null?void 0:v.map(w=>w(..._)).find(w=>w!==void 0)}}}else o[d]=h}),o),{})}}function BF(e){e===void 0&&(e=[]);const t=e.map(l=>l==null?void 0:l.reference),n=e.map(l=>l==null?void 0:l.floating),r=e.map(l=>l==null?void 0:l.item),a=L.useCallback(l=>P1(l,e,"reference"),t),s=L.useCallback(l=>P1(l,e,"floating"),n),o=L.useCallback(l=>P1(l,e,"item"),r);return L.useMemo(()=>({getReferenceProps:a,getFloatingProps:s,getItemProps:o}),[a,s,o])}function ySe({gid:e,uid:t,user:n,stats:r,x:a,y:s,onDismiss:o}){const{refs:l,floatingStyles:c,context:d,isPositioned:h}=jF({open:!0,onOpenChange:C=>{C||o()},strategy:"fixed",placement:"right-start",middleware:[RF(8),DF({fallbackPlacements:["left-start","bottom-start"]}),OF({padding:8})],whileElementsMounted:(C,O,A)=>IF(C,O,A,{animationFrame:!0})}),p=$F(d,{outsidePress:C=>{var O,A;return!((A=(O=C.target)==null?void 0:O.closest)!=null&&A.call(O,"[data-stats-gid]"))}}),{getFloatingProps:v}=BF([p]),y=L.useRef(null);L.useEffect(()=>{y.current=null},[e]),L.useEffect(()=>{const C=()=>({x:a,y:s,top:s,left:a,right:a,bottom:s,width:0,height:0});l.setReference({getBoundingClientRect:()=>{const O=document.querySelector(`[data-stats-gid="${e}"]`);if(O){const A=O.getBoundingClientRect();return y.current=A,A}return y.current??C()}})},[l,e,a,s]);const _=Lr(n,t),S=r.prsOpen+r.prsMerged+r.prsClosed,w=[{label:"Comments",value:r.comments},{label:"Reviews given",value:r.reviews},{label:"PRs open",value:r.prsOpen,dot:"#3b82f6"},{label:"PRs merged",value:r.prsMerged,dot:"#22c55e"},{label:"PRs closed",value:r.prsClosed,dot:"#9ca3af"}];return m.jsx(FF,{children:m.jsxs("div",{ref:l.setFloating,style:{...c,visibility:h?"visible":"hidden"},...v(),"data-testid":"user-stats-popover",className:"z-50 w-56 rounded-lg border border-gray-200 bg-white p-3 shadow-xl dark:border-gray-700 dark:bg-gray-900",children:[m.jsx("div",{className:"mb-1 truncate text-sm font-semibold text-gray-800 dark:text-gray-100",title:_,children:_}),m.jsx("div",{className:"mb-2 text-[10px] uppercase tracking-wide text-gray-400",children:"In this window"}),m.jsx("table",{className:"w-full text-xs",children:m.jsxs("tbody",{children:[w.map(C=>m.jsxs("tr",{className:"border-t border-gray-100 first:border-0 dark:border-gray-800",children:[m.jsx("td",{className:"py-1 pr-2 text-gray-500 dark:text-gray-400",children:m.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[C.dot&&m.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:C.dot}}),C.label]})}),m.jsx("td",{className:"py-1 text-right font-medium tabular-nums text-gray-800 dark:text-gray-100",children:C.value})]},C.label)),m.jsxs("tr",{className:"border-t border-gray-200 dark:border-gray-700",children:[m.jsx("td",{className:"py-1 pr-2 text-gray-500 dark:text-gray-400",children:"PRs authored"}),m.jsx("td",{className:"py-1 text-right font-medium tabular-nums text-gray-800 dark:text-gray-100",children:S})]})]})})]})})}const Qr={reviewComment:"#f59e0b",prComment:"#9ca3af",approved:"#22c55e",changes:"#f97316",commented:"#9ca3af",dismissed:"#9ca3af",commit:"#6b7280",lifecycle:"#3b82f6"};function Zc(e){return`<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true">${e}</svg>`}const dO=e=>Zc(`<circle cx="8" cy="8" r="5" fill="${e}"/>`),bSe=e=>Zc(`<circle cx="8" cy="8" r="4.5" fill="none" stroke="${e}" stroke-width="2"/>`),xSe=e=>Zc(`<circle cx="8" cy="8" r="4.5" fill="none" stroke="${e}" stroke-width="1.6" stroke-dasharray="2.2 2"/>`),_Se=e=>Zc(`<rect x="3.5" y="3.5" width="9" height="9" rx="1.5" fill="${e}"/>`),ESe=e=>Zc(`<circle cx="8" cy="8" r="7" fill="${e}"/><path d="M4.5 8.3 L7 10.8 L11.5 5.5" fill="none" stroke="#fff" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>`),wSe=e=>Zc(`<circle cx="8" cy="8" r="7" fill="${e}"/><path d="M4.5 6.5 L8 10 L11.5 6.5" fill="none" stroke="#fff" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>`),kSe=e=>Zc(`<path d="M2.5 4.5 a1.5 1.5 0 0 1 1.5-1.5 h8 a1.5 1.5 0 0 1 1.5 1.5 v4 a1.5 1.5 0 0 1 -1.5 1.5 h-5 l-2.5 2.2 v-2.2 h-0 a1.5 1.5 0 0 1 -1.5 -1.5 z" fill="none" stroke="${e}" stroke-width="1.5"/>`);function UF(e){switch(e.type){case"review_comment":return{svg:dO(Qr.reviewComment),color:Qr.reviewComment,label:"Review comment",round:!0};case"pr_comment":return{svg:bSe(Qr.prComment),color:Qr.prComment,label:"PR comment",round:!0};case"commit_pushed":return{svg:_Se(Qr.commit),color:Qr.commit,label:"Commit pushed"};case"review_submitted":switch(e.reviewState){case"approved":return{svg:ESe(Qr.approved),color:Qr.approved,label:"Approved"};case"changes_requested":return{svg:wSe(Qr.changes),color:Qr.changes,label:"Changes requested"};case"dismissed":return{svg:xSe(Qr.dismissed),color:Qr.dismissed,label:"Review dismissed",round:!0};default:return{svg:kSe(Qr.commented),color:Qr.commented,label:"Review comment"}}default:return{svg:dO(Qr.lifecycle),color:Qr.lifecycle,label:"Event",round:!0}}}function TSe(e){const t=UF(e);return`<div class="ev-marker-inner${t.round?" ev-round":""}">${t.svg}</div>`}function M1(e){return`<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true">${e}</svg>`}const SSe={commit:{color:Qr.commit,glyph:M1('<rect x="3.5" y="3.5" width="9" height="9" rx="1.5" fill="#fff"/>'),label:"commits"},comment:{color:Qr.reviewComment,glyph:M1('<circle cx="8" cy="8" r="5" fill="#fff"/>'),label:"comments"},review:{color:Qr.approved,glyph:M1('<path d="M4.5 8.3 L7 10.8 L11.5 5.5" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>'),label:"reviews"}};function CSe(e,t){const n=SSe[t];return`<div class="ev-cluster-inner" style="background:${n.color}" title="${e} ${n.label}">${n.glyph}+${e}</div>`}function NSe(e,t){const n=uD[e.type],r=Lr(e.actorId!=null?t.get(e.actorId):void 0,e.actorId);return`${n.label} · ${r} · ${ra(e.occurredAt)}`}const fO=Number.MAX_SAFE_INTEGER,ISe="2000-01-01T00:00:00Z",ASe="2100-01-01T00:00:00Z";function RSe(e){if(!e||e.end<=e.start)return{start:ISe,end:ASe};const t=e.end-e.start;return{start:new Date(e.start-t*3).toISOString(),end:new Date(e.end+t*3).toISOString()}}const OSe=new Set(["review_comment","pr_comment","review_submitted","commit_pushed"]);function DSe(e){return OSe.has(e.type)}function PSe(e){return e.type==="commit_pushed"?"commit":e.type==="review_submitted"?"review":"comment"}const HF=9,MSe=3;function LSe(e){return(23+(1+String(e).length)*6.5)/2}function FSe(e,t,n,r,a,s,o=8,l){const c=Math.max(1,o*s),d=[],h=new Map,p=new Map,v=new Set,y=new Map;for(const S of e){if(!DSe(S))continue;const w=t(S),C=PSe(S),O=S.prId,A=O!=null?r.get(O):void 0,R=S.actorId!=null&&(A==null?void 0:A.authorId)!=null&&S.actorId===A.authorId,F=R?`${w}::${C}::own::${O}`:`${w}::${C}::cross::${O??"none"}`,M=y.get(F);if(M){M.events.push(S);continue}R||v.add(w);const Y=R?a.get(O)??0:0;y.set(F,{group:w,kind:C,ownWork:R,subgroup:R?`ev:${Y}`:"cross",sortKey:R?Y*2+1:fO,events:[S]})}for(const{group:S,kind:w,ownWork:C,subgroup:O,sortKey:A,events:R}of y.values()){const F=P=>`${P} ${C?"ev-own":"ev-cross"}`,M=[...R].sort((P,q)=>Date.parse(P.occurredAt)-Date.parse(q.occurredAt));let Y=[],B=-1/0;const J=()=>{if(Y.length!==0){if(Y.length===1){const P=Y[0],q=`ev:${P.id}`;d.push({id:q,group:S,subgroup:O,sortKey:A,type:"point",start:P.occurredAt,content:TSe(P),className:`${F("ev-marker")} ev-key-${P.id}`,title:NSe(P,n),selectable:!1}),p.set(q,HF)}else{const P=Y.reduce((z,W)=>z+Date.parse(W.occurredAt),0)/Y.length,q=`cl:${S}:${w}:${Y[0].id}`;h.set(q,Y.map(z=>z.id)),d.push({id:q,group:S,subgroup:O,sortKey:A,type:"point",start:new Date(P).toISOString(),content:CSe(Y.length,w),className:`${F("ev-cluster")} ${Y.map(z=>`ev-key-${z.id}`).join(" ")}`,title:`${Y.length} ${w}s`,selectable:!1}),p.set(q,LSe(Y.length))}Y=[]}};for(const P of M){const q=Date.parse(P.occurredAt);Y.length>0&&q-B>c&&J(),Y.push(P),B=q}J()}$Se(d,s,p);const _=RSe(l);for(const S of v)d.push({id:`xsep:${S}`,group:S,subgroup:"cross",sortKey:fO,type:"background",start:_.start,end:_.end,content:"",className:"cross-sep"});return{items:d,clusterMembers:h}}function $Se(e,t,n){if(t<=0)return;const r=new Map;for(const a of e){if(a.type!=="point")continue;const s=`${String(a.group)}\0${String(a.subgroup??"")}`,o=r.get(s);o?o.push(a):r.set(s,[a])}for(const a of r.values()){if(a.length<2)continue;a.sort((l,c)=>L1(l)-L1(c));let s=-1/0,o=0;for(const l of a){const c=n.get(String(l.id))??HF;let d=L1(l);const h=(o+c+MSe)*t;d-s<h&&(d=s+h,l.start=new Date(d).toISOString()),s=d,o=c}}}function L1(e){const t=e.start;return t instanceof Date?t.valueOf():typeof t=="number"?t:Date.parse(String(t))}function sc(e){return e.authorId!=null?`repo:${e.repoId}:user:${e.authorId}`:`repo:${e.repoId}`}function F1(e){return Date.parse(e.openedAt)}function hO(e,t){const n=e.mergedAt??e.closedAt;return n?Date.parse(n):t}function jSe(e,t=()=>0,n=Date.now()){const r=new Map;for(const s of e){const o=sc(s),l=r.get(o);l?l.push(s):r.set(o,[s])}const a=new Map;for(const s of r.values()){const o=[...s].sort((d,h)=>F1(d)-F1(h)),l=[],c=[];for(const d of o){const h=F1(d),p=t(d);let v=l.findIndex((y,_)=>y<=h&&c[_]===p);v===-1?(v=l.length,l.push(hO(d,n)),c.push(p)):l[v]=hO(d,n),a.set(d.id,v)}}return a}function zF(e,t){const[n,r]=L.useState(()=>{try{const a=localStorage.getItem(e);return a!=null?JSON.parse(a):t}catch{return t}});return L.useEffect(()=>{try{localStorage.setItem(e,JSON.stringify(n))}catch{}},[e,n]),[n,r]}function BSe(e){return e?e.replace(/\n$/,"").split(`
1375
1375
  `).at(-1)??null:null}function USe({ev:e,pr:t,usersById:n,onOpen:r}){const a=t.authorId!=null?n.get(t.authorId):void 0,s=e.actorId!=null&&t.authorId!=null&&e.actorId!==t.authorId;return m.jsxs("div",{className:"flex items-baseline gap-1 text-[11px] text-gray-500",children:[m.jsx("span",{children:"on"}),s&&m.jsxs("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:[Lr(a,t.authorId),"’s"]}),m.jsxs("button",{type:"button",onClick:r,className:"font-medium text-blue-500 hover:underline",children:["#",t.number]}),m.jsx("span",{className:"truncate text-gray-400",title:t.title,children:t.title})]})}function pO({ev:e,usersById:t,prsById:n,onNavigate:r}){var J;const a=$e(P=>P.selectThread),s=$e(P=>P.selectPr),o=$e(P=>P.showActivityEntry),l=$e(P=>P.showPrComment),c=UF(e),d=e.actorId!=null?t.get(e.actorId):void 0,h=Lr(d,e.actorId),p=e.type==="review_comment"&&e.threadId!=null,{data:v}=NM(p?e.threadId:null),y=Date.parse(e.occurredAt),_=(v==null?void 0:v.comments.find(P=>Date.parse(P.createdAt)===y&&P.authorId===e.actorId))??(v==null?void 0:v.comments[0]),S=v?BSe((_==null?void 0:_.diffHunk)??((J=v.comments[0])==null?void 0:J.diffHunk)??null):null,w=e.type==="commit_pushed",C=e.type==="pr_comment",O=e.type==="review_submitted",{data:A}=vk((w||C)&&e.prId!=null?e.prId:null),R=w&&A?A.commits.find(P=>P.id===e.refId):void 0,F=C&&A?A.comments.find(P=>P.id===e.refId):void 0,M=e.prId!=null?n.get(e.prId):void 0,Y=()=>{e.threadId!=null?a(e.prId,e.threadId):C&&e.prId!=null&&e.refId!=null?l(e.prId,e.refId):O&&e.prId!=null&&e.refId!=null?o(e.prId,{type:e.type,refId:e.refId}):e.prId!=null&&s(e.prId),r()},B=()=>{e.prId!=null&&(o(e.prId,{type:e.type,refId:e.refId}),r())};return m.jsxs("div",{className:"space-y-1.5",children:[m.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[m.jsx("span",{className:"inline-block h-3 w-3",dangerouslySetInnerHTML:{__html:c.svg}}),m.jsx("span",{className:"font-semibold",children:h}),m.jsxs("span",{className:"text-gray-500",children:["· ",c.label]}),m.jsx("span",{className:"ml-auto text-gray-400",children:ra(e.occurredAt)})]}),M&&m.jsx(USe,{ev:e,pr:M,usersById:t,onOpen:Y}),w&&m.jsx("div",{className:"text-[11px]",children:R?m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx("code",{className:"rounded bg-gray-100 px-1 font-mono text-gray-600 dark:bg-gray-800 dark:text-gray-300",children:R.sha.slice(0,7)}),R.message&&m.jsx("span",{className:"truncate text-gray-600 dark:text-gray-300",children:R.message.split(`
1376
- `)[0]})]}):m.jsx("span",{className:"text-gray-400",children:"loading commit…"})}),v&&m.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[m.jsxs("code",{className:"truncate font-mono text-gray-600 dark:text-gray-300",children:[v.path,v.line!=null?`:${v.line}`:""]}),m.jsx("span",{className:"ml-auto shrink-0",children:m.jsx(AM,{state:v.derivedState})})]}),S&&m.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}),_&&m.jsxs("div",{className:"text-xs",children:[m.jsx(So,{children:_.body}),v&&v.comments.length>1&&m.jsxs("div",{className:"mt-1 text-[11px] text-gray-400",children:["+",v.comments.length-1," more in thread"]})]}),C&&m.jsx("div",{className:"text-xs",children:F?m.jsx(So,{children:F.body}):m.jsx("span",{className:"text-gray-400",children:"loading comment…"})}),m.jsxs("div",{className:"flex items-center gap-3 pt-0.5 text-[11px]",children:[!w&&m.jsx("button",{type:"button",onClick:Y,className:"text-blue-500 hover:underline",children:"Open in detail pane"}),w&&e.prId!=null&&m.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"}),w&&R&&A&&m.jsx("a",{href:`${A.githubUrl}/commits/${R.sha}`,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"Open commit on GitHub ↗"}),C&&F&&A&&m.jsx("a",{href:F.url??A.githubUrl,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"Open on GitHub ↗"})]})]})}function HSe({state:e,eventsById:t,usersById:n,prsById:r,focusPrId:a,onContextFocus:s,onDismiss:o,onNavigate:l}){var P;const[c,d]=zF("pierre:popoverSize",null),{refs:h,floatingStyles:p,context:v,isPositioned:y}=jF({open:!0,onOpenChange:q=>{q||o()},strategy:"fixed",placement:"right-start",middleware:[RF(24),DF({fallbackPlacements:["left-start","bottom"]}),OF({padding:8})],whileElementsMounted:(q,z,W)=>IF(q,z,W,{animationFrame:!0})}),_=$F(v,{outsidePress:!1}),{getFloatingProps:S}=BF([_]),w=e.eventIds[0]??null,C=L.useRef(null);L.useEffect(()=>{C.current=null},[w]),L.useEffect(()=>{const q=()=>({x:e.x,y:e.y,top:e.y,left:e.x,right:e.x,bottom:e.y,width:0,height:0});h.setReference({getBoundingClientRect:()=>{if(w!=null){const z=document.querySelector(`.ev-key-${w}`),W=(z==null?void 0:z.querySelector(".ev-marker-inner, .ev-cluster-inner"))??z;if(W){const G=W.getBoundingClientRect();return C.current=G,G}}return C.current??q()}})},[h,w,e.x,e.y]);const O=e.eventIds.map(q=>t.get(q)).filter(q=>q!=null).filter(q=>a==null||q.prId===a),A=((P=O[0])==null?void 0:P.prId)??null;L.useEffect(()=>{s({groupIds:null,prId:A,eventId:null})},[A,s]);const R=q=>{const z=q.currentTarget;d({width:z.offsetWidth,height:z.offsetHeight})},[F,M]=L.useState({x:0,y:0}),Y=L.useRef(null);L.useEffect(()=>{const q=W=>{const G=Y.current;G&&M({x:G.ox+(W.clientX-G.sx),y:G.oy+(W.clientY-G.sy)})},z=()=>{Y.current=null};return window.addEventListener("pointermove",q),window.addEventListener("pointerup",z),()=>{window.removeEventListener("pointermove",q),window.removeEventListener("pointerup",z)}},[]);const B=q=>{q.button===0&&(q.preventDefault(),Y.current={sx:q.clientX,sy:q.clientY,ox:F.x,oy:F.y})},J=`${p.transform??""} translate(${F.x}px, ${F.y}px)`.trim();return m.jsx(FF,{children:m.jsxs("div",{ref:h.setFloating,style:{...p,transform:J,visibility:y?"visible":"hidden",width:(c==null?void 0:c.width)??420,height:(c==null?void 0:c.height)??340,minWidth:240,minHeight:120,maxWidth:"92vw",maxHeight:"80vh",resize:"both",overflow:"hidden"},...S(),onPointerUp:R,"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:[m.jsxs("div",{className:"tl-modal-header",onPointerDown:B,children:[m.jsx("svg",{className:"tl-grip",width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:m.jsxs("g",{fill:"currentColor",children:[m.jsx("circle",{cx:"2",cy:"2",r:"1"}),m.jsx("circle",{cx:"8",cy:"2",r:"1"}),m.jsx("circle",{cx:"2",cy:"5",r:"1"}),m.jsx("circle",{cx:"8",cy:"5",r:"1"}),m.jsx("circle",{cx:"2",cy:"8",r:"1"}),m.jsx("circle",{cx:"8",cy:"8",r:"1"})]})}),m.jsx("span",{className:"tl-modal-title",children:O.length>1?`${O.length} events`:"Activity"}),m.jsx("button",{type:"button",className:"tl-modal-close",onPointerDown:q=>q.stopPropagation(),onClick:o,"aria-label":"Close",title:"Close",children:"✕"})]}),m.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-2",children:O.length===1?m.jsx(pO,{ev:O[0],usersById:n,prsById:r,onNavigate:l}):m.jsx("div",{className:"divide-y divide-gray-200 dark:divide-gray-800",children:O.map(q=>m.jsx("div",{className:"py-2 first:pt-0 last:pb-0",children:m.jsx(pO,{ev:q,usersById:n,prsById:r,onNavigate:l})},q.id))})})]})})}const zSe=1e3*60*60,YSe={stack:!1,stackSubgroups:!0,groupHeightMode:"fixed",orientation:{axis:"top",item:"top"},zoomMin:zSe,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}},WSe=12,GSe=2;function mO(e){return[...new Set(e)]}function gO(e,t){var a,s;if(!e)return 0;const n=e.body,r=t==null?void 0:t.querySelector(".vis-panel.vis-center");return((s=(a=n==null?void 0:n.domProps)==null?void 0:a.center)==null?void 0:s.width)||(r==null?void 0:r.clientWidth)||(t==null?void 0:t.clientWidth)||0}function kp(e){return Date.parse(String(e.start))}function VSe(e){return e.end!=null?Date.parse(String(e.end)):kp(e)}function qSe(e,t){if(t<=0)return;const n=WSe*t,r=new Map;for(const a of e){const s=`${String(a.group)}|${String(a.subgroup??"")}`,o=r.get(s);o?o.push(a):r.set(s,[a])}for(const a of r.values())if(a.length!==0){a.sort((s,o)=>kp(s)-kp(o));for(let s=0;s<a.length;s++){const o=a[s],l=kp(o),c=VSe(o),d=s+1<a.length?kp(a[s+1]):Number.POSITIVE_INFINITY,h=Math.min(Math.max(c,l+n),d);h!==c&&(o.end=new Date(h).toISOString())}}}function vO(e,t){const n=t.getTime()-e.getTime(),r=Math.max(n*.06,14400*1e3),a=Math.max(n*.03,7200*1e3);return{start:new Date(e.getTime()-a),end:new Date(t.getTime()+r)}}function KSe(e){const t=document.createElement("div");return t.innerHTML=e,t.firstElementChild??t}function QSe(){const e=typeof navigator<"u"?navigator.platform||navigator.userAgent:"";return/Mac|iP(hone|ad|od)/.test(e)?"metaKey":"ctrlKey"}function XSe(e){return e.actorId!=null?`repo:${e.repoId}:user:${e.actorId}`:`repo:${e.repoId}`}const ZSe=/^repo:\d+:user:\d+$/;function Wd(e){return`tlg-${e.replace(/:/g,"-")}`}function JSe(e){return new Date(e.mergedAt??e.closedAt??new Date().toISOString()).getTime()}const eCe=1440*60*1e3;function yO({mode:e}={}){const t=(e==null?void 0:e.kind)==="isolate"?e.prId:null,n=L.useRef(null),r=L.useRef(null),a=L.useRef(new mu),s=L.useRef(new mu),o=L.useRef(new Map),l=L.useRef(new Map),c=L.useRef(new Map),d=L.useRef([]),h=L.useRef(null),p=L.useRef(new Map),v=L.useRef(new Map),y=L.useRef(new Map),_=L.useRef({active:!1,states:[]}),S=L.useRef(null),w=L.useRef(null),C=L.useRef(new Set),O=L.useRef(new Set),A=L.useRef(!1);if(!A.current){A.current=!0;try{const K=localStorage.getItem("pierre:collapsedRows");if(K){const fe=JSON.parse(K);Array.isArray(fe)&&(O.current=new Set(fe.map(String)))}}catch{}}const R=L.useRef(new Map),F=L.useRef(null),M=L.useRef(null),Y=L.useRef(null),B=L.useRef(null),J=L.useRef(null),P=L.useRef(null),q=L.useRef(null),z=L.useRef(null),W=L.useRef(null),G=L.useRef(0),X=L.useRef(!1),de=L.useRef(null),ue=L.useRef(null),H=L.useRef(null),oe=L.useRef(null),j=L.useRef(null),te=L.useRef(null),ve=L.useRef(null),[Q,Me]=L.useState(null),ae=L.useRef(null);ae.current=Q;const[Ie,me]=L.useState(null),Xe=L.useRef(new Map),[we,ke]=L.useState(!1),Pe=L.useMemo(()=>t!=null?Date.now()-Z$*eCe:null,[t]),{data:Ae,isLoading:yt,error:ft}=Bw(t!=null?{dropMembers:!0,fromMs:Pe}:void 0),{data:Ht}=sD(),{data:_t}=Uw(),{data:Vt}=Hw(),{data:jn}=gu(),{data:Kn}=Bc(),{data:Bn}=jw(),Pn=lr(),kt=$e(K=>K.derivedStates),_r=$e(K=>K.userIds),gi=$e(K=>K.selectPr),ii=$e(K=>K.selectedPrId),_e=L.useRef(ii),[Ge,Tt]=L.useState(0),[$t,mt]=L.useState(0),dr=$e(K=>K.preset),Ci=$e(K=>K.customFrom),Nr=$e(K=>K.customTo),vi=$e(K=>K.rangeResetSignal),Ir=L.useMemo(()=>{const K=new Map;for(const fe of jn??[])K.set(fe.id,fe);return K},[jn]),Mn=L.useRef(Ir);Mn.current=Ir;const Fr=L.useMemo(()=>{const K=new Map;for(const fe of Bn??[])K.set(fe.repoId,new Set(fe.userIds));return K},[Bn]),Ln=L.useMemo(()=>vu(Kn),[Kn]);p.current=Ln;const Ui=L.useRef(!1);L.useEffect(()=>{if(!Ae)return;let K=!1;for(const fe of Ae.events)if(fe.actorId!=null&&!Ln.has(fe.actorId)){K=!0;break}if(!K){for(const fe of Ae.prs)if(fe.authorId!=null&&!Ln.has(fe.authorId)){K=!0;break}}if(!K){Ui.current=!1;return}Ui.current||(Ui.current=!0,Pn.invalidateQueries({queryKey:["users"]}))},[Ae,Ln,Pn]);const ws=L.useMemo(()=>{const K=new Map;for(const fe of(Ae==null?void 0:Ae.prs)??[])K.set(fe.id,fe);return K},[Ae]);v.current=ws;const Yr=L.useCallback(K=>{const fe=a.current,xe=S.current;if(xe!=null&&xe!==K){const Ne=fe.get(`pr:${xe}`);Ne&&typeof Ne.className=="string"&&fe.update({id:`pr:${xe}`,className:Ne.className.replace(/\s*pr-cross-linked/g,"")})}if(K!=null){const Ne=fe.get(`pr:${K}`);Ne&&typeof Ne.className=="string"&&!Ne.className.includes("pr-cross-linked")&&fe.update({id:`pr:${K}`,className:`${Ne.className} pr-cross-linked`})}S.current=K},[]),Un=L.useCallback(K=>{const fe=a.current,xe=M.current;if(xe!=null){const Oe=fe.get(xe);Oe&&typeof Oe.className=="string"&&Oe.className.includes("ev-cross-linked")&&fe.update({id:xe,className:Oe.className.replace(/\s*ev-cross-linked/g,"")}),M.current=null}if(F.current=K,K==null)return;const Ne=fe.get(`ev:${K}`)?`ev:${K}`:c.current.get(K)??null;if(Ne==null)return;const Re=fe.get(Ne);Re&&typeof Re.className=="string"&&!Re.className.includes("ev-cross-linked")&&(fe.update({id:Ne,className:`${Re.className} ev-cross-linked`}),M.current=Ne)},[]),$r=L.useCallback(K=>{const fe=a.current;for(const Re of fe.getIds()){const Oe=fe.get(Re);Oe&&typeof Oe.className=="string"&&Oe.className.includes("ev-exit-glow")&&fe.update({id:Re,className:Oe.className.replace(/\s*ev-exit-glow/g,"")})}if(B.current=null,Y.current=K,K==null)return;const xe=fe.get(`ev:${K}`)?`ev:${K}`:c.current.get(K)??null;if(xe==null)return;const Ne=fe.get(xe);Ne&&typeof Ne.className=="string"&&!Ne.className.includes("ev-exit-glow")&&(fe.update({id:xe,className:`${Ne.className} ev-exit-glow`}),B.current=xe)},[]),ie=L.useCallback(K=>{const fe=a.current;for(const Re of fe.getIds()){const Oe=fe.get(Re);Oe&&typeof Oe.className=="string"&&Oe.className.includes("ev-selected")&&fe.update({id:Re,className:Oe.className.replace(/\s*ev-selected/g,"")})}if(ve.current=null,te.current=K,K==null)return;const xe=fe.get(`ev:${K}`)?`ev:${K}`:c.current.get(K)??null;if(xe==null)return;const Ne=fe.get(xe);Ne&&typeof Ne.className=="string"&&!Ne.className.includes("ev-selected")&&(fe.update({id:xe,className:`${Ne.className} ev-selected`}),ve.current=xe)},[]),pe=L.useCallback(()=>{const K=a.current,fe=C.current,xe=[],Ne=[],Re=w.current!=null;for(const Oe of d.current){const tt=String(Oe.id),ze=fe.has(String(Oe.group))||!Re&&O.current.has(String(Oe.group)),Ve=K.get(tt)!=null;ze&&Ve?xe.push(tt):!ze&&!Ve&&Ne.push(Oe)}xe.length&&K.remove(xe),Ne.length&&K.add(Ne)},[]),Je=L.useCallback(()=>{try{localStorage.setItem("pierre:collapsedRows",JSON.stringify([...O.current]))}catch{}},[]),Nt=L.useCallback((K,fe)=>{var Ve,bt;const xe=s.current;if(!xe.get(K))return;const Ne=a.current.get(),Re=new Set;for(const Ze of Ne)Ze.group===K&&typeof Ze.subgroup=="string"&&Re.add(Ze.subgroup);const Oe={};for(const Ze of Re)Oe[Ze]=!fe;const tt=xe.get(K);tt&&(xe.remove(K),xe.add({...tt,subgroupVisibility:Oe,heightMode:fe?"auto":"fixed"})),fe?O.current.add(K):O.current.delete(K),Je(),pe();const ze=r.current;(bt=(Ve=ze==null?void 0:ze.itemSet)==null?void 0:Ve.markDirty)==null||bt.call(Ve,{restackGroups:!0}),ze==null||ze.redraw()},[Je,pe]),Zt=L.useCallback(K=>{const fe=s.current.getIds().map(String).filter(Re=>ZSe.test(Re)),xe=K&&K.length?new Set(K):null,Ne=[];for(const Re of fe){const Oe=xe!=null&&!xe.has(Re);Oe?C.current.add(Re):C.current.delete(Re),Ne.push({id:Re,visible:!Oe})}Ne.length&&s.current.update(Ne),w.current=xe?K:null,pe()},[pe]),zt=L.useCallback(()=>{const K=r.current,fe=n.current,xe=h.current;if(!K||!fe||!xe)return;const Ne=K.getWindow(),Re=Ne.end.valueOf()-Ne.start.valueOf();z.current=Re;const Oe=fe.clientWidth||1e3,tt=Re/Oe;let ze;if(X.current&&de.current!=null)ze=xe.events.filter(St=>St.prId===de.current);else if(ze=xe.events,_.current.active){const{states:St}=_.current;ze=ze.filter(ct=>ct.type==="review_comment"&&ct.prId!=null&&ct.derivedState!=null&&St.includes(ct.derivedState))}const{items:Ve,clusterMembers:bt}=FSe(ze,XSe,p.current,v.current,y.current,tt,8,{start:Ne.start.valueOf(),end:Ne.end.valueOf()});l.current=bt;const Ze=new Map;for(const[St,ct]of bt)for(const jt of ct)Ze.set(jt,St);c.current=Ze;const Et=a.current.getIds().filter(St=>{const ct=String(St);return ct.startsWith("ev:")||ct.startsWith("cl:")||ct.startsWith("xsep:")});if(a.current.remove(Et),a.current.add(Ve),d.current=Ve.filter(St=>String(St.id).startsWith("xsep:")),pe(),F.current!=null){const St=F.current;M.current=null,F.current=null,Un(St)}if(Y.current!=null){const St=Y.current;B.current=null,Y.current=null,$r(St)}if(te.current!=null){const St=te.current;ve.current=null,te.current=null,ie(St)}},[Un,$r,ie,pe]),Le=L.useCallback(()=>{const K=ue.current;if(!K)return;const fe=()=>{K.childElementCount&&K.replaceChildren(),K.style.display="none"},xe=n.current,Ne=de.current;if(!X.current||Ne==null||!xe){fe();return}const Re=xe.querySelector(".vis-panel.vis-center"),Oe=v.current.get(Ne);if(!Re||!Oe){fe();return}const tt=Wd(sc(Oe)),ze=xe.querySelector(`.vis-foreground .vis-group.${tt} .vis-item.pr-bar.vis-selected`)??xe.querySelector(`.vis-foreground .vis-group.${tt} .vis-item.pr-bar:not(.pr-focus-hidden)`);if(!ze||ze.offsetHeight===0){fe();return}const bt=(K.parentElement??xe).getBoundingClientRect(),Ze=Re.getBoundingClientRect();K.style.display="block",K.style.left=`${Ze.left-bt.left}px`,K.style.top=`${Ze.top-bt.top}px`,K.style.width=`${Ze.width}px`,K.style.height=`${Ze.height}px`;const Et=ze.getBoundingClientRect(),St=Et.top-Ze.top,ct=Et.bottom-Ze.top,jt=Et.left-Ze.left,sn=Et.right-Ze.left,pn="http://www.w3.org/2000/svg",bn=document.createDocumentFragment(),cn=xe.querySelectorAll(".vis-foreground .vis-item.ev-cross");for(const Mt of cn){if(Mt.offsetHeight===0)continue;const yr=(Mt.querySelector(".ev-marker-inner, .ev-cluster-inner")??Mt).getBoundingClientRect(),wn=yr.left+yr.width/2-Ze.left,un=yr.top-Ze.top,ua=yr.bottom-Ze.top,bi=Math.max(jt,Math.min(wn,sn));let Yi,Wr;if(un>=ct)Yi=un,Wr=ct;else if(ua<=St)Yi=ua,Wr=St;else continue;const qe=document.createElementNS(pn,"path");qe.setAttribute("d",`M ${wn.toFixed(1)} ${Yi.toFixed(1)} L ${bi.toFixed(1)} ${Wr.toFixed(1)}`),bn.appendChild(qe)}K.replaceChildren(bn)},[]),nt=L.useCallback(()=>{var xe;const K=X.current&&de.current!=null,fe=(((xe=ue.current)==null?void 0:xe.childElementCount)??0)>0;!K&&!fe||H.current==null&&(H.current=requestAnimationFrame(()=>{H.current=null,Le()}))},[Le]),et=L.useCallback((K,fe)=>{const xe=s.current;for(const[Ve,bt]of R.current){if(!xe.get(Ve))continue;const Ze={};for(const Et of bt)Ze[Et]=!0;xe.update({id:Ve,subgroupVisibility:Ze})}if(R.current.clear(),!K||K.length===0||fe==null)return;const Ne=y.current.get(fe),Re=v.current.get(fe),Oe=a.current.get(`pr:${fe}`),tt=Re?sc(Re):Oe&&typeof Oe.group=="string"?Oe.group:null,ze=a.current.get();for(const Ve of K){const bt=new Set(["cross"]);Ve===tt&&Ne!=null&&(bt.add(`bar:${Ne}`),bt.add(`ev:${Ne}`));const Ze=new Set;for(const ct of ze)ct.group===Ve&&typeof ct.subgroup=="string"&&Ze.add(ct.subgroup);const Et=[...Ze].filter(ct=>!bt.has(ct)),St={};for(const ct of Et)St[ct]=!1;for(const ct of Ze)bt.has(ct)&&(St[ct]=!0);Object.keys(St).length!==0&&(xe.update({id:Ve,subgroupVisibility:St}),Et.length&&R.current.set(Ve,Et))}},[]),yn=L.useCallback(K=>{const fe=a.current,xe=[];for(const Ne of fe.getIds()){const Re=String(Ne);if(!Re.startsWith("pr:"))continue;const Oe=fe.get(Ne);if(!Oe||typeof Oe.className!="string")continue;const tt=Number.parseInt(Re.slice(3),10),ze=Oe.className.includes("pr-focus-hidden"),Ve=K!=null&&tt!==K;Ve&&!ze?xe.push({id:Ne,className:`${Oe.className} pr-focus-hidden`}):!Ve&&ze&&xe.push({id:Ne,className:Oe.className.replace(/\s*pr-focus-hidden/g,"")})}xe.length&&fe.update(xe)},[]),an=L.useCallback(K=>{$r(null);const fe=X.current;et((K==null?void 0:K.groupIds)??null,(K==null?void 0:K.prId)??null),Zt((K==null?void 0:K.groupIds)??null),Yr((K==null?void 0:K.prId)??null),Un((K==null?void 0:K.eventId)??null);const xe=!!(K!=null&&K.groupIds&&K.groupIds.length>0);if(ke(xe),xe||(X.current=!1,de.current=null),xe&&(K==null?void 0:K.prId)!=null){const Ne=$e.getState();Ne.selectedPrId!==K.prId&&Ne.selectPr(K.prId)}if(!xe&&fe&&(yn(null),zt()),!xe&&O.current.size>0)for(const Ne of O.current)Nt(Ne,!0)},[et,Zt,Yr,Un,$r,yn,zt,Nt]),yi=L.useCallback(K=>{X.current||an(K)},[an]),tn=L.useCallback(()=>{const K=n.current;return K?K.querySelector(".vis-panel.vis-left.vis-vertical-scroll")??K.querySelector(".vis-panel.vis-right.vis-vertical-scroll"):null},[]),jr=L.useCallback(()=>{const K=oe.current,fe=n.current;if(!K||!fe)return;const xe=()=>{K.style.display!=="none"&&(K.style.display="none")},Ne=tn();if(!Ne){xe();return}const Oe=(K.parentElement??fe).getBoundingClientRect(),tt=Ne.getBoundingClientRect(),ze=tt.top,Ve=1;let bt=null;for(const jt of fe.querySelectorAll(".vis-labelset .vis-label.tl-repo-header")){const sn=jt.getBoundingClientRect();sn.height<1||sn.top<=ze+Ve&&(bt=jt)}if(!bt){xe();return}if(bt.getBoundingClientRect().top>=ze-Ve){xe();return}const St=((bt.querySelector(".vis-inner")??bt).textContent??"").trim();if(!St){xe();return}const ct=[...bt.classList].find(jt=>jt.startsWith("tl-repo-tint-"))??"";K.dataset.repo!==St&&(K.textContent=St,K.dataset.repo=St),K.dataset.tint!==ct&&(K.className=`tl-repo-sticky${ct?` ${ct}`:""}`,K.dataset.tint=ct),K.style.left=`${tt.left-Oe.left}px`,K.style.top=`${tt.top-Oe.top}px`,K.style.width=`${tt.width}px`,K.style.display!=="block"&&(K.style.display="block")},[tn]),Er=L.useCallback(()=>{j.current==null&&(j.current=requestAnimationFrame(()=>{j.current=null,jr()}))},[jr]),Cn=L.useCallback(()=>{const K=tn(),fe=n.current;if(!K||!fe)return null;const xe=K.getBoundingClientRect().top;let Ne=null,Re=0,Oe=1/0;for(const tt of fe.querySelectorAll(".vis-labelset .vis-label")){const ze=tt.getBoundingClientRect();if(ze.height<4||ze.bottom<=xe+1)continue;const Ve=[...tt.classList].find(Ze=>Ze.startsWith("tlg-"));if(!Ve)continue;const bt=Math.abs(ze.top-xe);bt<Oe&&(Oe=bt,Ne=Ve,Re=ze.top-xe)}return{token:Ne,offset:Re,scrollTop:K.scrollTop}},[tn]),ai=L.useCallback((K,fe)=>{const xe=r.current,Ne=h.current;if(!xe||!Ne)return;const Re=(fe==null?void 0:fe.pr)??v.current.get(K);if(!Re)return;Me(null);const Oe=Re.repoId,tt=new Set;Re.authorId!=null&&tt.add(Re.authorId);let ze=1/0,Ve=-1/0;const bt=Et=>{Et<ze&&(ze=Et),Et>Ve&&(Ve=Et)};bt(new Date(Re.openedAt).getTime()),bt(JSe(Re));for(const Et of Ne.events)Et.prId===K&&(Et.actorId!=null&&tt.add(Et.actorId),bt(new Date(Et.occurredAt).getTime()));const Ze=[...tt].map(Et=>`repo:${Oe}:user:${Et}`);if((fe==null?void 0:fe.fitWindow)!==!1&&Number.isFinite(ze)&&Number.isFinite(Ve)){const Et=Math.max((Ve-ze)*.08,432e5);xe.setWindow(ze-Et,Ve+Et,{animation:!0})}X.current=!0,de.current=K,an({groupIds:Ze.length?Ze:null,prId:K,eventId:(fe==null?void 0:fe.anchorEventId)??null}),zt(),yn(K),xe.setSelection([`pr:${K}`]),(fe==null?void 0:fe.anchorEventId)!=null&&Un(fe.anchorEventId)},[an,zt,yn,Un]),tr=L.useCallback(K=>{const fe=tn();if(!fe||r.current==null||!fe.isConnected)return;const xe=Math.max(0,fe.scrollHeight-fe.clientHeight);fe.scrollTop=Math.max(0,Math.min(xe,K)),fe.dispatchEvent(new Event("scroll"))},[tn]),Ar=L.useRef(!1),ns=L.useRef(0),Hi=L.useCallback((K,fe,xe=".ev-cross-linked",Ne=".pr-cross-linked")=>{const Re=n.current,Oe=tn(),tt=Re==null?void 0:Re.querySelector(".vis-panel.vis-center");if(!Re||!Oe||!tt)return;const ze=`.vis-labelset .vis-label.${K}`;let Ve;const bt=pn=>{const bn=tt.getBoundingClientRect(),cn=pn.getBoundingClientRect();return cn.top+cn.height/2-bn.top-bn.height/2},Ze=()=>{const pn=Mt=>[...Re.querySelectorAll(Mt)].filter(ht=>ht.offsetHeight>0).sort((ht,yr)=>yr.offsetHeight-ht.offsetHeight)[0];if(fe){const Mt=pn(xe);if(Mt)return{delta:bt(Mt),settleable:!0};const ht=Re.querySelector(`.vis-foreground .vis-group.${K}`);if(ht){const yr=tt.getBoundingClientRect();return{delta:ht.getBoundingClientRect().bottom-12-(yr.top+yr.height/2),settleable:!1}}return null}if(Ve&&Ve.isConnected&&Ve.offsetHeight>0)return{delta:bt(Ve),settleable:!0};const bn=pn(Ne);if(bn)return Ve=bn,{delta:bt(bn),settleable:!0};const cn=Re.querySelector(ze);return cn?{delta:bt(cn),settleable:!0}:null},Et=Re.querySelector(ze);Et&&tr(Et.offsetTop-8);let St=0,ct=0;const jt=++ns.current;Ar.current=!0,window.setTimeout(()=>{ns.current===jt&&(Ar.current=!1)},2500);const sn=()=>{if(ns.current!==jt)return;const pn=Ze();pn!=null&&(Math.abs(pn.delta)>6?(tr(Oe.scrollTop+pn.delta),ct=0):pn.settleable?ct+=1:ct=0),ct<6&&St++<90?requestAnimationFrame(sn):Ar.current=!1};requestAnimationFrame(()=>requestAnimationFrame(sn))},[tn,tr]),Ni=L.useCallback(K=>{const fe=n.current,xe=()=>{var ze;const tt=tn();if(!tt||!fe)return!0;if(K.token){const Ve=fe.querySelector(`.vis-labelset .vis-label.${K.token}`);if(Ve&&Ve.offsetHeight>0){const Ze=Ve.getBoundingClientRect().top-tt.getBoundingClientRect().top-K.offset;return Math.abs(Ze)>1?(tr(tt.scrollTop+Ze),!1):!0}}return tr(K.scrollTop),Math.abs((((ze=tn())==null?void 0:ze.scrollTop)??K.scrollTop)-K.scrollTop)<=2};xe();let Ne=0,Re=0;const Oe=()=>{xe()?Re+=1:Re=0,Re<3&&Ne++<30&&requestAnimationFrame(Oe)};requestAnimationFrame(Oe)},[tn,tr]),Ra=L.useCallback((K,fe,xe)=>{xe.length!==0&&(w.current||an(null),me(null),Me({x:K,y:fe,eventIds:xe}))},[an]),rs=L.useCallback(()=>{Me(null),w.current||an(null)},[an]),vr=L.useCallback(()=>{ae.current?rs():w.current||(_e.current!=null?$e.getState().clearSelection():Y.current!=null&&$r(null))},[rs,$r]),is=L.useCallback(()=>{Me(null)},[]);L.useEffect(()=>{ie(Q&&!we?Q.eventIds[0]??null:null)},[Q,we,ie]);const ks=(Q==null?void 0:Q.eventIds[0])??null;L.useEffect(()=>{if(ks==null)return;const K=o.current.get(ks);(K==null?void 0:K.prId)!=null&&$e.getState().selectPr(K.prId)},[ks]);const Fn=L.useCallback(K=>{const fe=Mn.current.get(K.repoId),xe=K.authorId!=null?p.current.get(K.authorId):void 0;return{id:K.id,number:K.number,title:K.title,repoFullName:(fe==null?void 0:fe.fullName)??`repo ${K.repoId}`,authorLogin:(xe==null?void 0:xe.githubLogin)??null,authorDisplayName:(xe==null?void 0:xe.displayName)??null,authorAvatarUrl:(xe==null?void 0:xe.avatarUrl)??null}},[]);L.useEffect(()=>{if(!n.current)return;const{from:K,to:fe}=nv($e.getState()),{start:xe,end:Ne}=vO(K,fe),Re=new pke(n.current,a.current,s.current,{...YSe,start:xe,end:Ne,zoomKey:QSe()});Re.on("click",Ve=>{var sn,pn,bn;const bt=Ve.item,Ze=((sn=Ve.event)==null?void 0:sn.srcEvent)??Ve.event,Et=(Ze==null?void 0:Ze.clientX)??Ve.pageX??0,St=(Ze==null?void 0:Ze.clientY)??Ve.pageY??0,ct=(Ze==null?void 0:Ze.target)??null;if((pn=ct==null?void 0:ct.closest)!=null&&pn.call(ct,"[data-collapse-gid]")||(bn=ct==null?void 0:ct.closest)!=null&&bn.call(ct,"[data-stats-gid]"))return;if(bt==null){if(((Ze==null?void 0:Ze.detail)??0)>=2)return;vr();return}const jt=String(bt);if(jt.startsWith("pr:"))ae.current&&!X.current&&!w.current&&rs(),gi(Number.parseInt(jt.slice(3),10));else if(jt.startsWith("ev:")){const cn=Number.parseInt(jt.slice(3),10);if(X.current){Un(cn),Ra(Et,St,[cn]);return}Ra(Et,St,[cn])}else if(jt.startsWith("cl:")){const cn=l.current.get(jt)??[];if(cn.length===0)return;const Mt=cn[0];if(X.current){Un(Mt),Ra(Et,St,cn);return}Ra(Et,St,cn)}}),Re.on("doubleClick",Ve=>{const bt=Ve.item;if(bt==null||X.current)return;const Ze=String(bt);if(Ze.startsWith("pr:")){const Et=Number.parseInt(Ze.slice(3),10),St=v.current.get(Et);St&&ln.getState().openPrFocusTab(Fn(St));return}if(Ze.startsWith("ev:")||Ze.startsWith("cl:")){const St=(Ze.startsWith("ev:")?[Number.parseInt(Ze.slice(3),10)]:l.current.get(Ze)??[])[0]??null;if(St==null)return;const ct=o.current.get(St);if((ct==null?void 0:ct.prId)==null)return;const jt=v.current.get(ct.prId);jt&&ln.getState().openPrFocusTab(Fn(jt))}});let Oe=null,tt=null;Re.on("rangechanged",()=>{const Ve=Re.getWindow(),bt=Ve.end.valueOf()-Ve.start.valueOf(),Ze=z.current;if(Ze==null||Math.abs(bt-Ze)/Ze>.02){Oe&&clearTimeout(Oe);const sn=()=>{if(Ar.current){Oe=setTimeout(sn,120);return}Oe=null;const pn=Cn();zt(),Re.redraw(),pn&&Ni(pn)};Oe=setTimeout(sn,120)}const St=q.current;if(St==null||X.current||w.current)return;const ct=Re.getWindow(),jt=ct.end.valueOf()-ct.start.valueOf();Math.abs(jt-St)/St<=.02||(tt&&clearTimeout(tt),tt=setTimeout(()=>mt(sn=>sn+1),160))}),Re.on("changed",nt);const ze=tn();return ze==null||ze.addEventListener("scroll",nt,{passive:!0}),Re.on("changed",Er),ze==null||ze.addEventListener("scroll",Er,{passive:!0}),window.addEventListener("resize",Er,{passive:!0}),Er(),r.current=Re,()=>{ns.current+=1,Ar.current=!1,Oe&&clearTimeout(Oe),tt&&clearTimeout(tt),ze==null||ze.removeEventListener("scroll",nt),ze==null||ze.removeEventListener("scroll",Er),window.removeEventListener("resize",Er),H.current!=null&&(cancelAnimationFrame(H.current),H.current=null),j.current!=null&&(cancelAnimationFrame(j.current),j.current=null),Re.destroy(),r.current=null}},[gi,zt,Ra,vr,rs,Un,Fn,Cn,Ni,nt,Er,tn]),L.useEffect(()=>{const K=n.current;if(!K)return;const fe=xe=>{var Ve;const Ne=xe.target,Re=(Ve=Ne==null?void 0:Ne.closest)==null?void 0:Ve.call(Ne,"[data-collapse-gid]");if(!Re)return;const Oe=Re.getAttribute("data-collapse-gid");if(!Oe||(xe.stopPropagation(),xe.preventDefault(),X.current||w.current))return;const tt=!O.current.has(Oe);Nt(Oe,tt),Re.textContent=tt?"▸":"▾";const ze=tt?"Expand row":"Collapse row";Re.setAttribute("title",ze),Re.setAttribute("aria-label",ze)};return K.addEventListener("click",fe,!0),()=>K.removeEventListener("click",fe,!0)},[Nt]),L.useEffect(()=>{const K=n.current;if(!K)return;const fe=xe=>{var ze;const Ne=xe.target,Re=(ze=Ne==null?void 0:Ne.closest)==null?void 0:ze.call(Ne,"[data-stats-gid]");if(!Re)return;const Oe=Re.getAttribute("data-stats-gid");if(!Oe)return;xe.stopPropagation(),xe.preventDefault();const tt=Number(Oe.split(":user:")[1]);Number.isFinite(tt)&&(Me(null),me(Ve=>Ve&&Ve.gid===Oe?null:{gid:Oe,uid:tt,x:xe.clientX,y:xe.clientY}))};return K.addEventListener("click",fe,!0),()=>K.removeEventListener("click",fe,!0)},[]),L.useEffect(()=>{const K=n.current;if(!K)return;const fe=xe=>{const Ne=xe.target;!Ne||!Ne.isConnected||Ne.closest(".vis-timeline")||vr()};return K.addEventListener("click",fe),()=>K.removeEventListener("click",fe)},[vr]);const pl=L.useCallback((K,fe)=>{W.current!=null&&(cancelAnimationFrame(W.current),W.current=null);const xe=Ve=>{const bt=r.current;if(!bt||Ve<=0)return;const Ze=bt.getWindow();qSe(K,(Ze.end.valueOf()-Ze.start.valueOf())/Ve),a.current.update(K),G.current=Ve,fe==null||fe()},Ne=gO(r.current,n.current);if(Ne>0&&Math.abs(Ne-G.current)<1){xe(Ne);return}let Re=-1,Oe=0,tt=0;const ze=()=>{const Ve=gO(r.current,n.current);if(Ve>0&&Ve===Re?Oe+=1:(Oe=0,Re=Ve),Ve>0&&Oe>=2||tt++>40){W.current=null,xe(Ve);return}W.current=requestAnimationFrame(ze)};W.current=requestAnimationFrame(ze)},[]);L.useEffect(()=>()=>{W.current!=null&&cancelAnimationFrame(W.current)},[]),L.useEffect(()=>{let K=null;const fe=()=>{K&&clearTimeout(K),K=setTimeout(()=>mt(xe=>xe+1),200)};return window.addEventListener("resize",fe),()=>{window.removeEventListener("resize",fe),K&&clearTimeout(K)}},[]);const as=L.useRef(!1);L.useEffect(()=>{const K=()=>{!document.hidden&&as.current&&(as.current=!1,mt(fe=>fe+1))};return document.addEventListener("visibilitychange",K),()=>document.removeEventListener("visibilitychange",K)},[]),L.useEffect(()=>{var At;if(!Ae)return;if(h.current=Ae,document.hidden){as.current=!0;return}as.current=!1;const K=J.current,fe=K&&!Ae.prs.some(De=>De.id===K.id)?[...Ae.prs,K]:Ae.prs,xe=_r&&_r.length>0?new Set(_r):null,Ne=De=>!xe||De.authorId!=null&&xe.has(De.authorId),Re=kt.length>0,Oe=new Set;if(Re){const De=new Set(kt);for(const Bt of Ae.events)Bt.type==="review_comment"&&Bt.prId!=null&&Bt.derivedState!=null&&De.has(Bt.derivedState)&&Oe.add(Bt.prId)}const tt=De=>!Re||Oe.has(De.id),ze=fe.filter(De=>De.id===_e.current||De.id===(K==null?void 0:K.id)||Ne(De)&&tt(De));_.current={active:Re,states:kt};const Ve=new Map;for(const De of Ae.events)Ve.set(De.id,De);o.current=Ve;const bt=new Set;for(const De of Ae.events)De.prId!=null&&(De.type==="review_comment"||De.type==="pr_comment")&&bt.add(De.prId);const Ze=(At=r.current)==null?void 0:At.getWindow();q.current=Ze?Ze.end.valueOf()-Ze.start.valueOf():null;const Et=jSe(fe);y.current=Et;const St=Mke(Ae.events,fe);Xe.current=St;let ct=Ae.events;if(!X.current&&Re){const De=new Set(kt);ct=Ae.events.filter(Bt=>Bt.type==="review_comment"&&Bt.prId!=null&&Bt.derivedState!=null&&De.has(Bt.derivedState))}const jt=mO([...ze.map(De=>De.repoId),...ct.map(De=>De.repoId)]).sort((De,Bt)=>{const Nn=Ir.get(De),xi=Ir.get(Bt);return!Nn||!xi?(Nn?0:1)-(xi?0:1)||De-Bt:Nn.owner.localeCompare(xi.owner)||Nn.name.localeCompare(xi.name)||De-Bt}),sn=[],pn=0,bn=1e6;jt.forEach((De,Bt)=>{const Nn=mO([...ct.filter(wr=>wr.repoId===De&&wr.actorId!=null).map(wr=>wr.actorId),...ze.filter(wr=>wr.repoId===De&&wr.authorId!=null).map(wr=>wr.authorId)]),xi=Fr.get(De),Oa=Nn.map(wr=>`repo:${De}:user:${wr}`),Da=`tl-repo-tint-${Bt%GSe}`,qs=Ir.get(De),Cu=(qs==null?void 0:qs.fullName)??`repo ${De}`,ml=qs!=null&&qs.inboxWatch?`${Xr(Cu)}${gj()}`:Xr(Cu);sn.push({id:`repo:${De}`,content:ml,nestedGroups:Oa.length?Oa:void 0,treeLevel:1,order:Bt,subgroupOrder:"sortKey",className:`tl-repo-header ${Da}`}),Nn.forEach((wr,uh)=>{const Pa=`repo:${De}:user:${wr}`,Ks=(xi==null?void 0:xi.has(wr))??!1;sn.push({id:Pa,content:KSe($ke(Ln.get(wr),wr,St.get(wr),Ks,Pa,O.current.has(Pa))),treeLevel:2,order:(Ks?pn:bn)+uh,subgroupOrder:"sortKey",heightMode:O.current.has(Pa)?"auto":"fixed",className:`tl-user-row ${Wd(Pa)} ${Da}`})})});const cn=X.current?de.current:null,Mt=ze.map(De=>{const Bt=De.authorId!=null?Ln.get(De.authorId):void 0,Nn=sc(De),xi=Et.get(De.id)??0,Oa={author:{label:Lr(Bt,De.authorId),avatarUrl:(Bt==null?void 0:Bt.avatarUrl)??null},hasComments:bt.has(De.id)};return{id:`pr:${De.id}`,group:Nn,subgroup:`bar:${xi}`,sortKey:xi*2,type:"range",start:De.openedAt,end:De.mergedAt??De.closedAt??new Date().toISOString(),content:Rke(De,Oa),className:(()=>{const Da=Dke(De,Oa.hasComments);return cn!=null&&De.id!==cn?`${Da} pr-focus-hidden`:Da})(),title:Oke(De,Oa)}}),ht=r.current,yr=ht==null?void 0:ht.getWindow(),wn=K?null:Cn(),un=Ar.current,ua=new Set(sn.map(De=>String(De.id)));s.current.update(sn);const bi=s.current.getIds().map(String).filter(De=>!ua.has(De));bi.length&&s.current.remove(bi);const Yi=new Set(Mt.map(De=>String(De.id))),Wr=a.current.getIds().map(String).filter(De=>De.startsWith("pr:")&&!Yi.has(De));if(a.current.update(Mt),Wr.length&&a.current.remove(Wr),pl(Mt,()=>{wn&&!Ar.current&&!un&&Ni(wn)}),zt(),ht&&yr){const De=ht.getWindow();(De.start.valueOf()!==yr.start.valueOf()||De.end.valueOf()!==yr.end.valueOf())&&ht.setWindow(yr.start,yr.end,{animation:!1})}const qe=_e.current;if(qe!=null&&ht&&a.current.get(`pr:${qe}`)&&!ht.getSelection().map(String).includes(`pr:${qe}`)&&ht.setSelection([`pr:${qe}`]),S.current!=null){const De=S.current;S.current=null,Yr(De)}if(w.current&&Zt(w.current),X.current&&de.current!=null&&yn(de.current),!w.current&&!X.current&&O.current.size>0)for(const De of O.current)Nt(De,!0);const it=J.current;(!it||Ae.prs.some(De=>De.id===it.id)||_e.current!==it.id&&de.current!==it.id)&&(J.current=null),wn&&!Ar.current&&Ni(wn)},[Ae,kt,Ht,_r,Ir,Ln,Fr,Ge,$t,zt,Yr,Zt,yn,Nt,Cn,Ni,pl]),L.useEffect(()=>{_e.current=ii;const K=r.current;if(!K)return;if(ii!=null&&!a.current.get(`pr:${ii}`)){Tt(Re=>Re+1);return}const fe=ii!=null?[`pr:${ii}`]:[],xe=K.getSelection().map(String);xe.length===fe.length&&fe.every(Re=>xe.includes(Re))||K.setSelection(fe)},[ii]);const En=L.useRef(!1);L.useEffect(()=>{if(t==null||En.current||!r.current||!h.current)return;$e.getState().selectedPrId!==t&&$e.getState().selectPr(t);const fe=v.current.get(t)??(Ae==null?void 0:Ae.prs.find(tt=>tt.id===t))??(Ht==null?void 0:Ht.prs.find(tt=>tt.id===t))??(Vt==null?void 0:Vt.prs.find(tt=>tt.id===t));if(!fe)return;En.current=!0,ai(t,{fitWindow:!0,pr:fe});const xe=Wd(sc(fe)),Ne=$e.getState(),Oe=Ne.timelineFocusPr===t&&Ne.timelineFocusEvent!=null?null:window.setTimeout(()=>Hi(xe,!1),320);return()=>{Oe!=null&&window.clearTimeout(Oe)}},[t,Ae,Ht,Vt,ai,Hi]),L.useEffect(()=>{const K=r.current;if(!K||t!=null)return;const{from:fe,to:xe}=nv($e.getState()),{start:Ne,end:Re}=vO(fe,xe);K.setWindow(Ne,Re,{animation:!1})},[dr,Ci,Nr,vi,t]);const zi=$e(K=>K.timelineCenterAt);L.useEffect(()=>{if(zi==null)return;const K=r.current;if(!K)return;const fe=K.getWindow(),xe=fe.end.valueOf()-fe.start.valueOf();K.setWindow(zi-xe/2,zi+xe/2,{animation:!0}),$e.getState().consumeTimelineCenter()},[zi]);const je=$e(K=>K.timelineFocusPr),ut=$e(K=>K.timelineFocusAt);return L.useEffect(()=>{if(je==null)return;const K=r.current;if(!K)return;const fe=Ae==null?void 0:Ae.prs.find(Oe=>Oe.id===je);if(fe){const Oe=$e.getState().timelineFocusEvent;if(Oe&&Ae){const Ze=Ae.events.filter(jt=>jt.prId===je&&jt.type===Oe.type&&(Oe.refId==null||jt.refId===Oe.refId)),Et=ut!=null&&Ze.find(jt=>jt.occurredAt===ut)||Ze[0],St=(Et==null?void 0:Et.actorId)??fe.authorId,ct=Et!=null&&(a.current.get(`ev:${Et.id}`)!=null||c.current.get(Et.id)!=null);if(ut){const jt=Date.parse(ut),sn=K.getWindow(),pn=sn.end.valueOf()-sn.start.valueOf();K.setWindow(jt-pn/2,jt+pn/2,{animation:!0})}if(K.setSelection([`pr:${je}`]),Et!=null&&Un(Et.id),St!=null){const jt=Wd(`repo:${fe.repoId}:user:${St}`);window.setTimeout(()=>Hi(jt,ct),120)}$e.getState().consumeTimelineFocus();return}const tt=K.getWindow(),ze=tt.end.valueOf()-tt.start.valueOf();let Ve;if(ut)Ve=Date.parse(ut);else{const Ze=new Date(fe.openedAt).getTime(),Et=new Date(fe.mergedAt??fe.closedAt??new Date().toISOString()).getTime();Ve=(Ze+Et)/2}K.setWindow(Ve-ze/2,Ve+ze/2,{animation:!0}),K.setSelection([`pr:${je}`]);const bt=Wd(sc(fe));window.setTimeout(()=>{Hi(bt,!1,".ev-cross-linked",".pr-bar.vis-selected")},120),$e.getState().consumeTimelineFocus();return}const xe=Oe=>{J.current=Oe,Tt(ze=>ze+1);const tt=Wd(sc(Oe));P.current!=null&&window.clearTimeout(P.current),P.current=window.setTimeout(()=>{P.current=null,K.setSelection([`pr:${Oe.id}`]),Hi(tt,!1,".ev-cross-linked",".pr-bar.vis-selected")},360),$e.getState().consumeTimelineFocus()},Ne=Ae&&!Ae.prs.some(Oe=>Oe.id===je)?_t==null?void 0:_t.prs.find(Oe=>Oe.id===je):void 0;if(Ne){xe(Ne);return}const Re=(Ht==null?void 0:Ht.prs.find(Oe=>Oe.id===je))??(Vt==null?void 0:Vt.prs.find(Oe=>Oe.id===je));if(Re){const{from:Oe}=nv($e.getState()),tt=new Date(Re.openedAt).getTime();if(tt<Oe.getTime()){const ze=new Date(tt-864e5).toISOString().slice(0,10),Ve=new Date().toISOString().slice(0,10);$e.getState().setCustomRange(ze,Ve);return}if(Ae&&!Ae.prs.some(ze=>ze.id===Re.id)){xe(Re);return}}$e.getState().consumeTimelineFocus()},[je,ut,Ae,Ht,_t,Vt,Hi,Un]),m.jsxs("div",{className:`relative h-full w-full${we?" tl-focus-active":""}`,children:[yt&&!Ae&&m.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-gray-500",children:"Loading timeline…"}),ft&&m.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-red-500",children:String(ft)}),Ae&&Ae.prs.length===0&&Ae.events.length===0&&m.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."}),m.jsx("div",{ref:n,className:"h-full w-full"}),m.jsx("svg",{ref:ue,className:"tl-cross-connectors","aria-hidden":"true",style:{display:"none"}}),m.jsx("div",{ref:oe,className:"tl-repo-sticky","aria-hidden":"true",style:{display:"none"}}),Q&&m.jsx(HSe,{state:Q,eventsById:o.current,usersById:Ln,prsById:ws,focusPrId:we?de.current:null,onContextFocus:yi,onDismiss:rs,onNavigate:is}),Ie&&m.jsx(ySe,{gid:Ie.gid,uid:Ie.uid,user:Ln.get(Ie.uid),stats:Xe.current.get(Ie.uid)??{comments:0,reviews:0,prsOpen:0,prsMerged:0,prsClosed:0},x:Ie.x,y:Ie.y,onDismiss:()=>me(null)})]})}function tCe(e,t){const n=new URLSearchParams;return e&&e.length>0&&n.set("repoIds",e.join(",")),t&&t.length>0&&n.set("userIds",t.join(",")),n.toString()}function nCe(e,t){const n=tCe(e,t);return ar({queryKey:["activity",n],queryFn:()=>Lt.inbox(n),staleTime:1/0,refetchOnMount:!1,placeholderData:r=>r})}const gv=Mw;function rCe(e){return gv.reduce((t,n)=>t+e[n],0)}function AT({counts:e,compact:t=!1,activeState:n=null,onSegmentClick:r,className:a=""}){const s=rCe(e);return t?m.jsx("span",{className:`inline-flex h-1.5 w-16 overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700 ${a}`,"aria-hidden":"true",children:s>0&&gv.map(o=>e[o]>0?m.jsx("span",{style:{width:`${e[o]/s*100}%`,background:Jr[o].color}},o):null)}):m.jsxs("div",{className:a,children:[m.jsx("div",{className:"flex h-2.5 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",children:s===0?null:gv.map(o=>{if(e[o]===0)return null;const l=Jr[o],c=m.jsx("span",{title:`${l.label}: ${e[o]}`,style:{width:`${e[o]/s*100}%`,background:l.color,opacity:n==null||n===o?1:.35},className:"block h-full"},o);return r?m.jsx("button",{type:"button",onClick:()=>r(o),title:`${l.label}: ${e[o]} — click to filter`,style:{width:`${e[o]/s*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):c})}),m.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-0.5",children:[gv.map(o=>{const l=Jr[o],c=n===o,d=n!=null&&!c,h=m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{background:l.color}}),m.jsx("span",{className:"tabular-nums",children:e[o]}),m.jsx("span",{children:l.label.toLowerCase()})]}),p=`flex items-center gap-1 text-[10px] ${d?"text-gray-400 opacity-60":"text-gray-600 dark:text-gray-300"}`;return r?m.jsx("button",{type:"button",onClick:()=>r(o),className:`${p} hover:underline`,"aria-pressed":c,title:l.description,children:h},o):m.jsx("span",{className:p,title:l.description,children:h},o)}),m.jsx("span",{className:"ml-auto text-[10px] tabular-nums text-gray-400",children:s})]})]})}function iCe(e){return e&&e.length>0?`repoIds=${e.join(",")}`:""}function aCe(e,t){const n=iCe(e);return ar({queryKey:["repo-digests",n],queryFn:()=>Lt.repoDigests(n),enabled:t,staleTime:1/0})}function sCe(e,t){return ar({queryKey:["repo-digest",e],queryFn:()=>Lt.repoDigest(e),enabled:t&&e!=null,staleTime:1/0})}function YF(){const e=lr();return ti({mutationFn:t=>{const n=t==null?void 0:Array.isArray(t)?t.length>0?`repoIds=${t.join(",")}`:void 0:`repoIds=${t}`;return Lt.refreshRepoDigests(n)},onSuccess:(t,n)=>{typeof n=="number"?e.invalidateQueries({queryKey:["repo-digest",n]}):e.invalidateQueries({queryKey:["repo-digest"]}),e.invalidateQueries({queryKey:["repo-digests"]})}})}function WF(){const e=ln(t=>t.openPrDetailTab);return t=>{t.prId!=null&&e({id:t.prId,number:t.prNumber,title:t.title??`#${t.prNumber}`,repoFullName:t.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null},{fromActivity:!0})}}const GF="pierre:collapsedDigests";function oCe(){try{const e=localStorage.getItem(GF),t=e?JSON.parse(e):[];return new Set(Array.isArray(t)?t.filter(n=>typeof n=="number"):[])}catch{return new Set}}function lCe(e){try{localStorage.setItem(GF,JSON.stringify([...e]))}catch{}}const ly=Lw((e,t)=>({collapsed:oCe(),toggle:n=>{const r=new Set(t().collapsed);r.has(n)?r.delete(n):r.add(n),lCe(r),e({collapsed:r})}}));function uCe(e,t,n){const r=[],a=/#(\d+)/g;let s=0,o=0,l;for(;(l=a.exec(e))!=null;){l.index>s&&r.push(e.slice(s,l.index));const c=Number(l[1]),d=t.get(c);d!=null?r.push(m.jsxs("button",{type:"button",onClick:()=>n(d),className:"font-medium text-sky-600 hover:underline dark:text-sky-400",title:d.title??`Open PR #${c}`,children:["#",c]},`r${o++}`)):r.push(`#${c}`),s=l.index+l[0].length}return s<e.length&&r.push(e.slice(s)),r}function cCe({markdown:e,prRefs:t,onOpenPr:n}){const r=new Map;for(const s of t)s.prId!=null&&r.set(s.prNumber,s);const a=e.split(`
1377
- `).map(s=>s.trim()).filter(s=>s!=="").map(s=>s.replace(/^[-*]\s+/,""));return a.length===0?m.jsx(m.Fragment,{}):m.jsx("ul",{className:"space-y-1",children:a.map((s,o)=>m.jsxs("li",{className:"flex gap-1.5 text-[13px] leading-relaxed text-gray-700 dark:text-gray-200",children:[m.jsx("span",{"aria-hidden":"true",className:"select-none text-gray-400",children:"•"}),m.jsx("span",{className:"min-w-0",children:uCe(s,r,n)})]},o))})}function dCe(e){if(!e)return"Haiku";const t=e.toLowerCase();return t.includes("haiku")?"Haiku":t.includes("sonnet")?"Sonnet":t.includes("opus")?"Opus":e}function VF({digest:e,isLoading:t,title:n,collapsed:r,onToggle:a,onRegenerate:s,regenerating:o=!1,onOpenPr:l}){return m.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:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsxs("button",{type:"button",onClick:a,"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:[m.jsx("span",{"aria-hidden":"true",className:"text-[9px]",children:r?"▸":"▾"}),m.jsx("span",{"aria-hidden":"true",children:"✨"}),m.jsx("span",{className:"truncate normal-case",children:n})]}),m.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"}),m.jsxs("span",{className:"ml-auto flex items-center gap-2 text-[10px] text-gray-400",children:[e!=null&&m.jsxs("span",{title:e.model,children:[dCe(e.model)," · ",ra(e.generatedAt),e.stale?" · stale":""]}),s!=null&&m.jsxs("button",{type:"button",onClick:s,disabled:o,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:"Regenerate this repo's digest (runs the cheap-tier model)",children:[m.jsx("span",{"aria-hidden":"true",children:"↻"}),o?"Regenerating…":"Regenerate"]})]})]}),!r&&m.jsx("div",{className:`mt-1 ${o?"opacity-50 transition-opacity":""}`,children:t?m.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()!==""?m.jsx("div",{className:"digest-fade-in",children:m.jsx(cCe,{markdown:e.summary,prRefs:e.prRefs,onOpenPr:l})},e.generatedAt):m.jsx("p",{className:"text-xs text-gray-400",children:"No digest yet — click Regenerate to summarise this repo's recent activity."})})]})}function fCe({repoId:e}){const{activityDigest:t}=zw(),{data:n,isLoading:r}=sCe(e,t),a=YF(),s=WF(),o=ly(d=>d.collapsed.has(e)),l=ly(d=>d.toggle),c=a.isPending&&a.variables===e;return t?m.jsxs("div",{className:"space-y-1.5",children:[m.jsx(VF,{digest:n,isLoading:r,title:"Digest",collapsed:o,onToggle:()=>l(e),onRegenerate:()=>a.mutate(e),regenerating:c,onOpenPr:s}),m.jsx(bk,{active:c})]}):null}function hCe({stats:e}){return m.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-gray-500 dark:text-gray-400",children:[m.jsxs("span",{children:[m.jsx("span",{className:"font-semibold text-gray-700 dark:text-gray-200 tabular-nums",children:e.openPrs})," ","open"]}),m.jsxs("span",{children:[m.jsx("span",{className:"tabular-nums",children:e.draftPrs})," draft"]}),e.stalledPrs>0&&m.jsxs("span",{className:"text-amber-500",children:[m.jsx("span",{className:"tabular-nums",children:e.stalledPrs})," stalled ⏱"]}),e.medianHoursToFirstReview!=null&&m.jsxs("span",{title:"Median hours to first review",children:["TTFR"," ",m.jsx("span",{className:"tabular-nums",children:e.medianHoursToFirstReview<1?`${Math.round(e.medianHoursToFirstReview*60)}m`:`${Math.round(e.medianHoursToFirstReview)}h`})]}),e.oldestUnreviewed!=null&&m.jsxs("a",{href:e.oldestUnreviewed.githubUrl,target:"_blank",rel:"noreferrer noopener",className:"hover:underline",title:e.oldestUnreviewed.title,children:["oldest unreviewed #",e.oldestUnreviewed.number," ·"," ",ra(e.oldestUnreviewed.openedAt)]})]})}function pCe({repo:e}){const t=e.maintainerIds.length;return m.jsxs("div",{className:"space-y-2 rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:"min-w-0 truncate text-base font-semibold text-gray-800 dark:text-gray-100",children:e.repoFullName}),t>0&&m.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:[m.jsx(gk,{}),t]}),e.attentionCount>0&&m.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]}),m.jsx("span",{className:"ml-auto shrink-0 text-[11px] tabular-nums text-gray-400",children:e.stats.openPrs>0?`[${e.stats.openPrs}]`:"[—]"})]}),m.jsx(hCe,{stats:e.stats}),m.jsx(AT,{counts:e.threadTotals}),m.jsx(fCe,{repoId:e.repoId})]})}function Jm(){const e=L.useRef(null),[t,n]=L.useState(0);return L.useEffect(()=>{const r=e.current;if(!r)return;const a=new ResizeObserver(s=>{var l;const o=(l=s[0])==null?void 0:l.contentRect.width;o!=null&&n(o)});return a.observe(r),n(r.clientWidth),()=>a.disconnect()},[]),[e,t]}const Tn={blue:"#3b82f6",green:"#22c55e",gray:"#9ca3af",orange:"#f97316",amber:"#f59e0b",purple:"#8957e5",teal:"#14b8a6",pink:"#ec4899",slate:"#64748b"},bO=[Tn.blue,Tn.green,Tn.amber,Tn.purple,Tn.teal,Tn.pink,Tn.slate];function vp(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 Cc(e){return new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function jc(e){return Math.abs(e)>=1e3?`${(e/1e3).toFixed(e%1e3===0?0:1)}k`:`${Math.round(e)}`}function RT(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 ab({series:e}){return m.jsx("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-0.5",children:e.map(t=>m.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-500 dark:text-gray-400",children:[m.jsx("span",{className:"inline-block h-2 w-2 rounded-[2px]",style:{background:t.color}}),t.label]},t.label))})}function eg({x:e,y:t,width:n,children:r}){const a=Math.max(58,Math.min(e,Math.max(58,n-58)));return m.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:a,top:Math.max(t-6,0)},children:r})}function fs({title:e,note:t,children:n}){return m.jsxs("div",{className:"rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[m.jsxs("div",{className:"mb-1 flex items-baseline justify-between gap-2",children:[m.jsx("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-200",children:e}),t&&m.jsx("span",{className:"text-[10px] text-gray-400",children:t})]}),n]})}function za({label:e="No data in this window"}){return m.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 Tw({labels:e,series:t,area:n=!1,curved:r=!1,formatY:a=jc,height:s=132}){const[o,l]=Jm(),[c,d]=L.useState(null),h=30,p=8,v=8,y=16,_=e.length,S=Math.max(l-h-p,1),w=s-v-y,C=RT(Math.max(1,...t.flatMap(W=>W.values.map(G=>G??0)))),O=W=>h+(_<=1?S/2:W/(_-1)*S),A=W=>v+w*(1-W/C),R=v+w,F=W=>W.values.map((G,X)=>G==null?null:`${O(X)},${A(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,M=W=>{const G=W.values.map((X,de)=>X==null?null:[O(de),A(X)]).filter(X=>X!=null);return G.length<2?"":`M ${G[0][0]} ${R} `+G.map(([X,de])=>`L ${X} ${de}`).join(" ")+` L ${G[G.length-1][0]} ${R} Z`},Y=W=>{let G="";for(let X=0;X<W.length-1;X++){const de=W[X-1]??W[X],ue=W[X],H=W[X+1],oe=W[X+2]??H,j=ue[0]+(H[0]-de[0])/6,te=ue[1]+(H[1]-de[1])/6,ve=H[0]-(oe[0]-ue[0])/6,Q=H[1]-(oe[1]-ue[1])/6;G+=` C ${j} ${te} ${ve} ${Q} ${H[0]} ${H[1]}`}return G},B=W=>{const G=[];let X=[];return W.values.forEach((de,ue)=>{de==null?(X.length&&G.push(X),X=[]):X.push([O(ue),A(de)])}),X.length&&G.push(X),G.map(de=>{const ue=`M ${de[0][0]} ${de[0][1]}`;return de.length<2?ue:ue+Y(de)}).join(" ")},J=W=>{const G=W.values.map((ue,H)=>ue==null?null:[O(H),A(ue)]).filter(ue=>ue!=null);if(G.length<2)return"";const X=G[0],de=G[G.length-1];return`M ${X[0]} ${R} L ${X[0]} ${X[1]}`+Y(G)+` L ${de[0]} ${R} Z`},P=r?B:F,q=r?J:M,z=W=>{const G=W.nativeEvent.offsetX,X=_<=1?0:Math.round((G-h)/S*(_-1));d(Math.max(0,Math.min(_-1,X)))};return m.jsxs("div",{children:[m.jsxs("div",{ref:o,className:"relative",style:{height:s},children:[l>0&&m.jsxs("svg",{width:l,height:s,className:"block",children:[[0,C].map(W=>m.jsxs("g",{children:[m.jsx("line",{x1:h,y1:A(W),x2:l-p,y2:A(W),className:"text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),m.jsx("text",{x:h-4,y:A(W)+3,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:a(W)})]},W)),n&&t[0]&&q(t[0])&&m.jsx("path",{d:q(t[0]),fill:t[0].color,opacity:.12}),c!=null&&m.jsx("line",{x1:O(c),y1:v,x2:O(c),y2:R,className:"text-gray-300 dark:text-gray-600",stroke:"currentColor",strokeWidth:1}),t.map(W=>m.jsx("path",{d:P(W),fill:"none",stroke:W.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"},W.key)),t.map(W=>W.values.map((G,X)=>G==null?null:m.jsx("circle",{cx:O(X),cy:A(G),r:c===X?3:1.8,fill:W.color},`${W.key}-${X}`))),m.jsx("text",{x:h,y:s-4,className:"fill-gray-400 text-[8px]",children:e[0]?Cc(e[0]):""}),m.jsx("text",{x:l-p,y:s-4,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:e[_-1]?Cc(e[_-1]):""}),m.jsx("rect",{x:0,y:0,width:l,height:s,fill:"transparent",onMouseMove:z,onMouseLeave:()=>d(null)})]}),c!=null&&l>0&&m.jsxs(eg,{x:O(c),y:v,width:l,children:[m.jsx("div",{className:"font-medium",children:e[c]?Cc(e[c]):""}),t.map(W=>m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-[1px]",style:{background:W.color}}),W.label,": ",W.values[c]==null?"—":a(W.values[c])]},W.key))]})]}),t.length>1&&m.jsx(ab,{series:t})]})}function mCe({repoId:e,onOpenCharts:t}){const{data:n,isLoading:r}=lD(e),a=(n==null?void 0:n.weekBuckets)??[],s=[{key:"opened",label:"Opened",color:Tn.blue,values:(n==null?void 0:n.throughput.opened)??[]},{key:"merged",label:"Merged",color:Tn.green,values:(n==null?void 0:n.throughput.merged)??[]}],o=s.some(l=>l.values.some(c=>c>0));return m.jsxs("div",{className:"rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[m.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[m.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:["PR merge rate",n?` · ${n.windowDays/7}-wk`:""]}),m.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?m.jsx("div",{className:"h-[132px] animate-pulse rounded bg-gray-50 dark:bg-gray-900/40"}):o?m.jsx(Tw,{labels:a,series:s,area:!0,curved:!0}):m.jsx(za,{})]})}function gCe({prs:e,repoFullName:t}){const{data:n}=Bc(),r=ln(s=>s.openPrDetailTab),a=L.useMemo(()=>vu(n),[n]);return e.length===0?null:m.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800",children:[m.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 · ",e.length]}),m.jsx("ul",{className:"divide-y divide-gray-100 dark:divide-gray-800/70",children:e.map(s=>{const o=jf[s.ciStatus],l=s.authorId!=null?a.get(s.authorId):void 0,c=cD[s.reasonTag],d=fy(s.mergeable,s.mergeStateStatus),h=s.isApproved?{label:"approved",color:"#22c55e"}:s.isChangesRequested?{label:"changes",color:"#ef4444"}:null;return m.jsx("li",{children:m.jsxs("button",{type:"button",onClick:()=>r({id:s.id,number:s.number,title:s.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:[m.jsx("span",{"aria-hidden":"true",title:(o==null?void 0:o.label)??"no checks",className:"inline-block h-2 w-2 shrink-0 rounded-full",style:o!=null?{background:o.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"}}),pj(s)&&m.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:"⚠"}),m.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[m.jsxs("span",{className:"text-gray-400",children:["#",s.number]})," ",m.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:s.title})]}),m.jsx(ka,{user:l,size:16}),m.jsx("span",{className:"max-w-[7rem] shrink-0 truncate text-gray-500 dark:text-gray-400",title:Lr(l,s.authorId),children:Lr(l,s.authorId)}),s.isDraft&&m.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"}),h!=null&&m.jsx("span",{className:"shrink-0 rounded px-1 text-[10px] font-semibold",style:{color:h.color,background:h.color+"1a"},children:h.label}),d!=null&&m.jsx("span",{className:"shrink-0 rounded bg-orange-500/15 px-1 text-[10px] font-medium text-orange-600 dark:text-orange-400",children:d}),m.jsx(AT,{counts:s.threadCounts,compact:!0}),c.myTurn?m.jsx("span",{className:"hidden shrink-0 rounded px-1 text-[10px] font-medium sm:inline",style:{color:c.color,background:c.color+"1a"},title:Lr(l,s.authorId),children:c.label}):m.jsx("span",{className:"hidden shrink-0 text-[10px] text-gray-400 sm:inline",children:ra(s.updatedAt)})]})},s.id)})})]})}const vCe=50;function yCe(e,t,n,r){const a=new URLSearchParams;return e&&e.length>0&&a.set("repoIds",e.join(",")),t&&t.length>0&&a.set("userIds",t.join(",")),n&&(a.set("excludeBots","true"),r.length>0&&a.set("allowBotIds",r.join(","))),a.toString()}function bCe(e){var s,o,l,c;const t=yCe(e.repoIds,e.userIds,e.excludeBots??!1,e.allowedBotIds??[]),n=F$({queryKey:["consolidated-feed",t],initialPageParam:0,queryFn:({pageParam:d})=>{const h=new URLSearchParams(t);return h.set("limit",String(vCe)),h.set("offset",String(d)),Lt.consolidatedFeed(h.toString())},getNextPageParam:(d,h)=>{var y;const p=h.reduce((_,S)=>_+S.items.length,0),v=((y=h[0])==null?void 0:y.total)??0;return p<v?p:void 0},enabled:e.enabled??!0,staleTime:1/0,refetchOnMount:!1,placeholderData:d=>d}),{items:r,users:a}=L.useMemo(()=>{var v;const d=((v=n.data)==null?void 0:v.pages)??[],h=d.flatMap(y=>y.items),p=new Map;for(const y of d)for(const _ of y.users)p.set(_.id,_);return{items:h,users:[...p.values()]}},[n.data]);return{items:r,users:a,total:((o=(s=n.data)==null?void 0:s.pages[0])==null?void 0:o.total)??0,generatedAt:((c=(l=n.data)==null?void 0:l.pages[0])==null?void 0:c.generatedAt)??null,hasMore:n.hasNextPage,loadMore:n.fetchNextPage,isFetchingMore:n.isFetchingNextPage,isLoading:n.isLoading,isFetching:n.isFetching}}function xCe(){const{activityDigest:e}=zw(),{data:t}=gu(),n=$e(v=>v.repoIds),r=WF(),a=YF(),s=ly(v=>v.collapsed),o=ly(v=>v.toggle),l=L.useMemo(()=>(t??[]).filter(v=>v.inboxWatch&&(n==null||n.includes(v.id))).map(v=>v.id),[t,n]),{data:c,isLoading:d}=aCe(l,e&&l.length>0);if(!e)return null;const h=(c==null?void 0:c.digests)??[],p=l.length>0;return m.jsxs("div",{className:"space-y-2",children:[m.jsxs("div",{className:"flex items-center gap-2 px-0.5",children:[m.jsxs("span",{className:"flex items-center gap-1 text-[11px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:[m.jsx("span",{"aria-hidden":"true",children:"✨"})," Digests · watched repos"]}),m.jsx("span",{className:"rounded bg-violet-500/15 px-1 text-[10px] font-semibold text-violet-600 dark:text-violet-300",children:"Pro"}),m.jsxs("button",{type:"button",onClick:()=>a.mutate(l),disabled:a.isPending||!p,className:"ml-auto flex items-center gap-0.5 rounded border border-violet-300 px-1.5 py-0.5 text-[10px] 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:"Regenerate the digests for all your watched repos (unchanged repos are free)",children:[m.jsx("span",{"aria-hidden":"true",children:"↻"}),a.isPending?"Regenerating…":"Regenerate"]})]}),m.jsx(bk,{active:a.isPending}),p?d?m.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"}):h.length===0?m.jsx("p",{className:"px-0.5 text-xs text-gray-400",children:"No digests yet — click Regenerate to summarise your watched repos."}):m.jsx("div",{className:"space-y-2",children:h.map(v=>m.jsx(VF,{digest:v,isLoading:!1,title:v.repoFullName,collapsed:s.has(v.repoId),onToggle:()=>o(v.repoId),regenerating:a.isPending,onOpenPr:r},v.repoId))}):m.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 digest here."})]})}function _Ce(e){if(e.kind==="claude_review")return{color:"#8957e5",label:"Claude Review"};if(e.kind==="review_submitted"&&e.reviewState!=null)return{color:ECe[e.reviewState].color,label:`Review: ${wCe[e.reviewState]}`};const t=uD[e.kind];return{color:(t==null?void 0:t.color)??"#6b7280",label:(t==null?void 0:t.label)??e.kind}}const ECe={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"}},wCe={approved:"Approved",changes_requested:"Request Changes",commented:"Comment",dismissed:"Dismissed",pending:"Pending"},kCe={APPROVE:{label:"approve",color:"#22c55e"},REQUEST_CHANGES:{label:"request changes",color:"#ef4444"},COMMENT:{label:"comment",color:"#9ca3af"}};function $1({repoId:e}){var ae,Ie;const t=$e(me=>me.repoIds),n=$e(me=>me.userIds),r=$e(me=>me.excludeBots),a=$e(me=>me.allowedBotIds),s=$e(me=>me.feedMyTurnOnly),o=$e(me=>me.toggleFeedMyTurnOnly),l=$e(me=>me.feedClaudeOnly),c=$e(me=>me.toggleFeedClaudeOnly),d=$e(me=>me.selectThread),h=$e(me=>me.selectPr),p=$e(me=>me.showPrComment),v=$e(me=>me.openClaudeReview),y=$e(me=>me.focusEventInTab),_=ln(me=>me.openPrDetailTab),S=ln(me=>me.openPrFocusTab),C=((ae=$f().data)==null?void 0:ae.claudeReviewEnabled)??!1,O=ln(me=>me.activityFlashItemId),A=ln(me=>me.clearActivityFlashItem),R=e!=null?[e]:t,{items:F,users:M,hasMore:Y,loadMore:B,isFetchingMore:J}=bCe({repoIds:R,userIds:n,excludeBots:r,allowedBotIds:a}),P=L.useMemo(()=>vu(M),[M]),q=(Ie=Bw().data)==null?void 0:Ie.prs,z=L.useMemo(()=>new Set((q??[]).map(me=>me.id)),[q]),[W,G]=L.useState(null),X=F.filter(me=>me.isMyTurn).length,de=F.filter(me=>me.kind==="claude_review").length,ue=s?F.filter(me=>me.isMyTurn):l?F.filter(me=>me.kind==="claude_review"):F,H=L.useRef(new Map),[oe,j]=L.useState(null);L.useEffect(()=>{if(O==null)return;const me=O,Xe=requestAnimationFrame(()=>{const we=H.current.get(me);we&&(we.scrollIntoView({block:"center",behavior:"smooth"}),j(me),window.setTimeout(()=>j(ke=>ke===me?null:ke),1800)),A()});return()=>cancelAnimationFrame(Xe)},[O,A]);const te=(me,Xe)=>({id:Xe,number:me.prNumber??0,title:me.prTitle??`#${me.prNumber??""}`,repoFullName:me.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null});function ve(me){const Xe=me.prId;Xe!=null&&(_(te(me,Xe),{fromActivity:!0,returnItemId:me.id}),me.kind==="claude_review"?v(Xe):me.threadId!=null?d(Xe,me.threadId):me.commentId!=null?p(Xe,me.commentId):h(Xe))}function Q(me,Xe){const we=me.prId;we!=null&&(_(te(me,we),{fromActivity:!0,returnItemId:me.id}),d(we,Xe))}function Me(me){const Xe=me.prId;if(Xe!=null){if(q!=null&&!z.has(Xe)){G(me);return}if(S(te(me,Xe),{fromActivity:!0,returnItemId:me.id}),me.kind!=="claude_review"){const we=me.threadId??me.commentId??null,ke=me.kind==="review_comment"?me.threadId:null;y(Xe,me.occurredAt,{type:me.kind,refId:we},ke)}}}return m.jsxs("div",{className:"space-y-3",children:[e==null&&m.jsx(xCe,{}),m.jsxs("div",{className:"flex items-center gap-2 px-0.5",children:[m.jsxs("button",{type:"button",onClick:o,"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:[m.jsx("span",{"aria-hidden":"true",children:"★"})," FYI",X>0&&m.jsx("span",{className:"tabular-nums opacity-70",children:X})]}),C&&m.jsxs("button",{type:"button",onClick:c,"aria-pressed":l,className:`flex items-center gap-1 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${l?"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:[m.jsx("span",{"aria-hidden":"true",children:"✨"})," Claude Reviews",de>0&&m.jsx("span",{className:"tabular-nums opacity-70",children:de})]}),F.length>0&&m.jsxs("span",{className:"text-[11px] text-gray-400",children:[ue.length," of ",F.length]})]}),F.length===0?m.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."}):ue.length===0?m.jsx("div",{className:"flex h-32 items-center justify-center text-sm text-gray-400",children:l?"No Claude Reviews in this window.":"Nothing needs your attention right now."}):m.jsx("ul",{className:"space-y-2",children:ue.map(me=>{const Xe=me.actorId!=null?P.get(me.actorId):void 0,we=me.mergedById!=null?P.get(me.mergedById):void 0,ke=we!=null||me.mergedById!=null?Lr(we,me.mergedById):null,Pe=(me.reviewers??[]).map(Ae=>Lr(P.get(Ae.userId),Ae.userId));return m.jsx(RCe,{item:me,actorUser:Xe,mergedByLabel:ke,reviewerLabels:Pe,usersById:P,flash:oe===me.id,innerRef:Ae=>{Ae?H.current.set(me.id,Ae):H.current.delete(me.id)},onOpen:()=>ve(me),onOpenThread:Ae=>Q(me,Ae),onFocus:()=>Me(me)},me.id)})}),Y&&F.length>0&&m.jsx("div",{className:"flex justify-center pt-1",children:m.jsx("button",{type:"button",onClick:()=>void B(),disabled:J,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 disabled:opacity-50 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500 dark:hover:bg-gray-800/50",children:J?"Loading…":"Load more"})}),W!=null&&m.jsx(TCe,{item:W,onClose:()=>G(null),onOpenDetails:()=>{const me=W;G(null),ve(me)}})]})}function TCe({item:e,onClose:t,onOpenDetails:n}){L.useEffect(()=>{const a=s=>{s.key==="Escape"&&(s.stopImmediatePropagation(),t())};return window.addEventListener("keydown",a,!0),()=>window.removeEventListener("keydown",a,!0)},[t]);const r=e.prNumber!=null?`#${e.prNumber}${e.prTitle!=null?` ${e.prTitle}`:""}`:"This PR";return m.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:t,role:"presentation",children:m.jsxs("div",{className:"flex w-[26rem] max-w-[92vw] flex-col rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-900",onClick:a=>a.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"PR not on the timeline",children:[m.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[m.jsx("h2",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:"Not on the timeline"}),m.jsx("button",{type:"button",onClick:t,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-200","aria-label":"Close (Esc)",title:"Close (Esc)",children:"✕"})]}),m.jsxs("div",{className:"space-y-3 px-4 py-3 text-sm leading-relaxed text-gray-600 dark:text-gray-300",children:[m.jsxs("p",{children:[m.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-100",children:r})," isn’t shown on the timeline with your current filters (date range, repositories, members), so it can’t be focused there."]}),m.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Widen the date range or clear the filters to bring it onto the board — or open its details directly."})]}),m.jsxs("div",{className:"flex justify-end gap-2 border-t border-gray-200 px-4 py-2 dark:border-gray-800",children:[m.jsx("button",{type:"button",onClick:t,className:"rounded border border-gray-300 px-3 py-1 text-sm hover:border-gray-400 dark:border-gray-700 dark:hover:border-gray-500",children:"Close"}),m.jsx("button",{type:"button",onClick:n,className:"rounded border border-blue-400 bg-blue-500/10 px-3 py-1 text-sm font-medium text-blue-600 hover:bg-blue-500/20 dark:border-blue-600 dark:text-blue-400",children:"Open PR details"})]})]})})}function SCe({item:e}){const{data:t,isLoading:n}=NM(e.threadId),{data:r}=Bc(),a=L.useMemo(()=>vu(r),[r]),s=L.useMemo(()=>{if(!t||e.actorId==null)return null;const l=new Date(e.occurredAt).getTime();let c=null;for(const d of t.comments){if(d.authorId!==e.actorId)continue;const h=Math.abs(new Date(d.createdAt).getTime()-l);(c==null||h<c.dist)&&(c={id:d.id,dist:h})}return(c==null?void 0:c.id)??null},[t,e.actorId,e.occurredAt]),o=e.prNumber!=null?`https://github.com/${e.repoFullName}/pull/${e.prNumber}`:"";return n?m.jsx("div",{className:"px-1 py-2 text-xs text-gray-400",children:"Loading conversation…"}):t?m.jsx(DM,{thread:t,usersById:a,prUrl:o,repoId:e.repoId,highlightCommentId:s}):m.jsx("div",{className:"px-1 py-2 text-xs text-gray-400",children:"Couldn’t load this conversation."})}function CCe({prId:e}){var a;const{data:t,isLoading:n}=vk(e);if(n)return m.jsx("div",{className:"mt-1 px-1 text-xs text-gray-400",children:"Loading summary…"});const r=(a=t==null?void 0:t.body)==null?void 0:a.trim();return r?m.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:m.jsx(So,{children:r})}):m.jsx("div",{className:"mt-1 px-1 text-xs text-gray-400",children:"No description."})}function NCe({item:e}){const[t,n]=L.useState(!1),r=e.ciStatus!=null&&e.ciStatus!=="unknown"?jf[e.ciStatus]:null,a=e.changedFilesCount,s=e.prId;return m.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[(r!=null||a!=null)&&m.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&&m.jsxs("span",{className:"inline-flex items-center gap-1 font-medium",style:{color:r.color},children:[m.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-2 rounded-full",style:{background:r.color}}),r.label]}),a!=null&&m.jsxs("span",{children:[a," ",a===1?"file":"files"," changed"]})]}),s!=null&&m.jsxs("div",{onClick:o=>o.stopPropagation(),children:[m.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&&m.jsx(CCe,{prId:s})]})]})}function ICe({thread:e,author:t,onOpen:n}){const r=Jr[e.derivedState],a=e.path.split("/").pop()??e.path;return m.jsx("li",{children:m.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:[m.jsxs("span",{className:"flex items-center gap-1.5 text-[11px]",children:[m.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-2 shrink-0 rounded-full",style:{background:r.color}}),m.jsxs("code",{className:"truncate font-mono text-gray-600 group-hover/th:text-sky-600 dark:text-gray-300",children:[a,e.line!=null?`:${e.line}`:""]}),m.jsx("span",{className:"shrink-0 text-gray-400",children:r.label.toLowerCase()})]}),e.excerpt.trim()!==""&&m.jsxs("span",{className:"mt-0.5 block truncate text-xs italic text-gray-500 dark:text-gray-400",children:[t!=null?`${Lr(t,e.authorId)}: `:"","“",e.excerpt,"”"]})]})})}const ACe=160;function RCe({item:e,actorUser:t,mergedByLabel:n,reviewerLabels:r,usersById:a,flash:s,innerRef:o,onOpen:l,onOpenThread:c,onFocus:d}){const h=_Ce(e),p=e.isMyTurn,v=e.kind==="claude_review",y=e.kind==="pr_merged",_=v?"Claude":e.actorId==null&&e.kind==="commit_pushed"?"A contributor":Lr(t,e.actorId),S=e.prNumber!=null?`#${e.prNumber}${e.prTitle!=null?` ${e.prTitle}`:""}`:"",w=e.claudeVerdict!=null?kCe[e.claudeVerdict]:null,C=e.affectedThreads??[],O=e.myTurnReasons[0],A=e.kind==="review_comment"&&e.threadId!=null,R=e.kind==="pr_comment"&&e.prId!=null,F=e.kind==="pr_opened",[M,Y]=L.useState(!1),B=y&&n!=null&&e.mergedById!==e.actorId,J=y&&r.length>0,P=L.useRef(null),q=L.useRef(null),[z,W]=L.useState(!1),[G,X]=L.useState(!1),de=e.content!=null&&e.content.trim()!=="";L.useEffect(()=>{const H=P.current,oe=q.current;if(!H||!oe)return;const j=()=>{z||X(H.scrollHeight>H.clientHeight+4)};j();const te=new ResizeObserver(j);return te.observe(oe),()=>te.disconnect()},[e.content,z]);const ue=H=>{H.target.closest("a,button")||l()};return m.jsx("li",{ref:o,children:m.jsxs("article",{onClick:ue,className:`cursor-pointer rounded-md border p-2.5 text-sm transition-colors ${s?"border-sky-400 ring-2 ring-sky-400/60 dark:border-sky-500":p?"border-yellow-400 bg-yellow-50/40 dark:border-yellow-500/50 dark:bg-yellow-950/15":v?"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:[m.jsxs("div",{className:"flex items-center gap-2",children:[e.prId!=null&&m.jsx("button",{type:"button",onClick:H=>{H.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:m.jsx(wy,{size:13})}),m.jsx("span",{className:"shrink-0 text-[11px] text-gray-400",title:qp(e.occurredAt),children:ra(e.occurredAt)}),m.jsx(ka,{user:t,size:20}),m.jsx("span",{className:"truncate font-medium text-gray-800 dark:text-gray-100",children:_}),m.jsx("span",{className:"inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-[11px] font-medium",style:{color:h.color,background:h.color+"1a"},children:h.label}),w!=null&&m.jsx("span",{className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",style:{color:w.color,background:w.color+"1a"},children:w.label}),p&&m.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"}),p&&O!=null&&m.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(H=>CC[H].title).join(" · "),children:CC[O].label})]}),m.jsxs("div",{className:"mt-1 flex items-baseline gap-1.5 text-xs",children:[m.jsx("span",{className:"shrink-0 text-gray-400",children:e.repoFullName}),S!==""&&m.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:S}),e.path!=null&&m.jsxs("span",{className:"shrink-0 text-gray-400",children:["· ",e.path.split("/").pop()]})]}),F&&m.jsx(NCe,{item:e}),de&&!A&&m.jsxs("div",{className:"mt-1.5 rounded bg-gray-50 px-2 py-1.5 text-sm dark:bg-gray-900/50",children:[m.jsx("div",{ref:P,className:z?"":"overflow-hidden",style:z?void 0:{maxHeight:ACe},children:m.jsx("div",{ref:q,children:m.jsx(So,{children:e.content})})}),(G||z)&&m.jsx("button",{type:"button",onClick:()=>W(H=>!H),className:"mt-1 text-[11px] font-medium text-sky-600 hover:underline dark:text-sky-400",children:z?"Show less":"Show more"})]}),C.length>0&&m.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[e.changeSummary!=null&&m.jsx("div",{className:"text-[11px] font-medium text-gray-500 dark:text-gray-400",children:e.changeSummary}),m.jsx("ul",{className:"space-y-1.5",children:C.map(H=>m.jsx(ICe,{thread:H,author:H.authorId!=null?a.get(H.authorId):void 0,onOpen:()=>c(H.threadId)},H.threadId))})]}),(B||J)&&m.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:[B&&m.jsxs("span",{children:["Merged by ",m.jsx("span",{className:"font-medium",children:n})]}),J&&m.jsxs("span",{children:["Reviewed by ",m.jsx("span",{className:"font-medium",children:r.join(", ")})]})]}),A&&m.jsx("div",{className:"mt-1.5",onClick:H=>H.stopPropagation(),children:m.jsx(SCe,{item:e})}),R&&e.prId!=null&&m.jsx("div",{className:"mt-1.5",children:M?m.jsx("div",{onClick:H=>H.stopPropagation(),children:m.jsx(yk,{prId:e.prId,initialBody:dD(e.content,(t==null?void 0:t.githubLogin)??null),autoFocus:!0,onCancel:()=>Y(!1),onDone:()=>Y(!1)})}):m.jsx("button",{type:"button",onClick:H=>{H.stopPropagation(),Y(!0)},className:"text-[11px] font-medium text-sky-600 hover:underline dark:text-sky-400",children:"Reply"})})]})})}function Gd({labels:e,series:t,mode:n="grouped",formatY:r=jc,formatValue:a=r,height:s=132}){const[o,l]=Jm(),[c,d]=L.useState(null),h=30,p=8,v=8,y=16,_=e.length,S=Math.max(l-h-p,1),w=s-v-y,C=/^\d{4}-\d{2}-\d{2}T/.test(e[0]??""),O=z=>t.reduce((W,G)=>W+(G.values[z]??0),0),A=RT(n==="stacked"?Math.max(1,...e.map((z,W)=>O(W))):Math.max(1,...t.flatMap(z=>z.values.map(W=>W??0)))),R=S/Math.max(_,1),F=z=>h+z*R+R*.15,M=R*.7,Y=z=>v+w*(1-z/A),B=v+w,J=z=>{const W=Math.floor((z.nativeEvent.offsetX-h)/R);d(Math.max(0,Math.min(_-1,W)))},P=z=>{const W=e[z]??"";return C?Cc(W):W},q=!C||_<=8;return m.jsxs("div",{children:[m.jsxs("div",{ref:o,className:"relative",style:{height:s},children:[l>0&&m.jsxs("svg",{width:l,height:s,className:"block",children:[[0,A].map(z=>m.jsxs("g",{children:[m.jsx("line",{x1:h,y1:Y(z),x2:l-p,y2:Y(z),className:"text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),m.jsx("text",{x:h-4,y:Y(z)+3,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:r(z)})]},z)),c!=null&&m.jsx("rect",{x:h+c*R,y:v,width:R,height:w,className:"text-gray-400/10 dark:text-gray-300/10",fill:"currentColor"}),e.map((z,W)=>{if(n==="stacked"){let X=0;return t.map(de=>{const ue=de.values[W]??0;if(ue<=0)return null;const H=Y(X+ue),oe=Y(X)-H;return X+=ue,m.jsx("rect",{x:F(W),y:H,width:M,height:Math.max(oe,0),fill:de.color},`${W}-${de.key}`)})}const G=M/Math.max(t.length,1);return t.map((X,de)=>{const ue=X.values[W]??0;return ue<=0?null:m.jsx("rect",{x:F(W)+de*G,y:Y(ue),width:Math.max(G-.5,.5),height:B-Y(ue),fill:X.color},`${W}-${X.key}`)})}),e.map((z,W)=>q||W===0||W===_-1?m.jsx("text",{x:h+W*R+R/2,y:s-4,textAnchor:"middle",className:"fill-gray-400 text-[8px]",children:P(W)},`lbl-${W}`):null),m.jsx("rect",{x:0,y:0,width:l,height:s,fill:"transparent",onMouseMove:J,onMouseLeave:()=>d(null)})]}),c!=null&&l>0&&m.jsxs(eg,{x:h+c*R+R/2,y:v,width:l,children:[m.jsx("div",{className:"font-medium",children:P(c)}),t.map(z=>m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-[1px]",style:{background:z.color}}),z.label,": ",a(z.values[c]??0)]},z.key)),n==="stacked"&&t.length>1&&m.jsxs("div",{className:"mt-0.5 border-t border-gray-200 pt-0.5 dark:border-gray-700",children:["total: ",a(O(c))]})]})]}),t.length>1&&m.jsx(ab,{series:t})]})}function xO({labels:e,series:t,formatValue:n=jc,height:r=132}){const[a,s]=Jm(),[o,l]=L.useState(null),c=30,d=8,h=8,p=16,v=e.length,y=Math.max(s-c-d,1),_=r-h-p,S=(B,J)=>B.values[J]??0,w=B=>t.reduce((J,P)=>J+S(P,B),0),C=RT(Math.max(1,...e.map((B,J)=>w(J)))),O=B=>c+(v<=1?y/2:B/(v-1)*y),A=B=>h+_*(1-B/C),R=h+_,F=[];{const B=e.map(()=>0);for(const J of t)F.push([...B]),e.forEach((P,q)=>B[q]=(B[q]??0)+S(J,q))}const M=(B,J)=>{const P=F[J],q=e.map((W,G)=>[O(G),A(P[G]+S(B,G))]),z=e.map((W,G)=>[O(G),A(P[G])]).reverse();return`M ${q.map(([W,G])=>`${W},${G}`).join(" L ")} L ${z.map(([W,G])=>`${W},${G}`).join(" L ")} Z`},Y=B=>{const J=v<=1?0:Math.round((B.nativeEvent.offsetX-c)/y*(v-1));l(Math.max(0,Math.min(v-1,J)))};return m.jsxs("div",{children:[m.jsxs("div",{ref:a,className:"relative",style:{height:r},children:[s>0&&m.jsxs("svg",{width:s,height:r,className:"block",children:[[0,C].map(B=>m.jsxs("g",{children:[m.jsx("line",{x1:c,y1:A(B),x2:s-d,y2:A(B),className:"text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),m.jsx("text",{x:c-4,y:A(B)+3,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:jc(B)})]},B)),t.map((B,J)=>m.jsx("path",{d:M(B,J),fill:B.color,opacity:.85},B.key)),o!=null&&m.jsx("line",{x1:O(o),y1:h,x2:O(o),y2:R,className:"text-gray-400 dark:text-gray-300",stroke:"currentColor",strokeWidth:1}),m.jsx("text",{x:c,y:r-4,className:"fill-gray-400 text-[8px]",children:e[0]?Cc(e[0]):""}),m.jsx("text",{x:s-d,y:r-4,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:e[v-1]?Cc(e[v-1]):""}),m.jsx("rect",{x:0,y:0,width:s,height:r,fill:"transparent",onMouseMove:Y,onMouseLeave:()=>l(null)})]}),o!=null&&s>0&&m.jsxs(eg,{x:O(o),y:h,width:s,children:[m.jsx("div",{className:"font-medium",children:e[o]?Cc(e[o]):""}),t.map(B=>m.jsxs("div",{className:"flex items-center gap-1",children:[m.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)),m.jsxs("div",{className:"mt-0.5 border-t border-gray-200 pt-0.5 dark:border-gray-700",children:["total: ",n(w(o))]})]})]}),t.length>1&&m.jsx(ab,{series:t})]})}function OCe({points:e,xLabel:t,yLabel:n,formatX:r=jc,formatY:a=jc,fit:s=!1,height:o=150}){const[l,c]=Jm(),[d,h]=L.useState(null),p=32,v=8,y=8,_=18,S=Math.max(c-p-v,1),w=o-y-_,C=P=>Math.log10(1+Math.max(0,P)),O=C(Math.max(1,...e.map(P=>P.x))),A=C(Math.max(1,...e.map(P=>P.y))),R=P=>p+C(P)/(O||1)*S,F=P=>y+w*(1-C(P)/(A||1)),M=P=>[0,1,10,100,1e3,1e4].filter(q=>C(q)<=P+.01),Y=(()=>{if(!s)return null;const P=e.filter(Me=>Me.x>0&&Me.y>0);if(P.length<4)return null;const q=P.map(Me=>Math.log10(Me.x)),z=P.map(Me=>Math.log10(Me.y)),W=P.length,G=q.reduce((Me,ae)=>Me+ae,0)/W,X=z.reduce((Me,ae)=>Me+ae,0)/W;let de=0,ue=0;for(let Me=0;Me<W;Me++)de+=(q[Me]-G)**2,ue+=(q[Me]-G)*(z[Me]-X);if(de===0)return null;const H=ue/de,oe=X-H*G,j=Math.min(...q),te=Math.max(...q);if(te<=j)return null;const ve=24;let Q="";for(let Me=0;Me<=ve;Me++){const ae=j+Me/ve*(te-j),Ie=10**ae,me=10**(oe+H*ae);Q+=`${Me===0?"M":" L"} ${R(Ie).toFixed(1)} ${F(me).toFixed(1)}`}return{d:Q,slope:H}})(),B=P=>{const q=P.nativeEvent.offsetX,z=P.nativeEvent.offsetY;let W=-1,G=196;e.forEach((X,de)=>{const ue=R(X.x)-q,H=F(X.y)-z,oe=ue*ue+H*H;oe<G&&(G=oe,W=de)}),h(W>=0?W:null)},J=d!=null?e[d]:null;return m.jsxs("div",{children:[m.jsxs("div",{ref:l,className:"relative",style:{height:o},children:[c>0&&m.jsxs("svg",{width:c,height:o,className:"block",children:[M(A).map(P=>m.jsxs("g",{children:[m.jsx("line",{x1:p,y1:F(P),x2:c-v,y2:F(P),className:"text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),m.jsx("text",{x:p-4,y:F(P)+3,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:a(P)})]},`y${P}`)),M(O).map(P=>m.jsx("text",{x:R(P),y:o-8,textAnchor:"middle",className:"fill-gray-400 text-[8px]",children:r(P)},`x${P}`)),e.map((P,q)=>m.jsx("circle",{cx:R(P.x),cy:F(P.y),r:d===q?4:2.2,fill:P.merged?Tn.green:Tn.gray,opacity:d==null||d===q?.75:.3},q)),Y&&m.jsx("path",{d:Y.d,fill:"none",stroke:Tn.amber,strokeWidth:1.5,strokeDasharray:"4 3",opacity:.95}),Y&&m.jsxs("text",{x:p+5,y:y+9,fill:Tn.amber,className:"text-[8px] font-semibold",children:["≈ ",n," ∝ ",t,"^",Y.slope.toFixed(1)]}),m.jsxs("text",{x:p,y:o-1,className:"fill-gray-400 text-[8px]",children:[t," →"]}),m.jsx("rect",{x:0,y:0,width:c,height:o,fill:"transparent",onMouseMove:B,onMouseLeave:()=>h(null)})]}),J&&c>0&&m.jsxs(eg,{x:R(J.x),y:F(J.y),width:c,children:[m.jsx("div",{className:"font-medium",children:J.label}),m.jsxs("div",{children:[t,": ",r(J.x)]}),m.jsxs("div",{children:[n,": ",a(J.y)]})]})]}),m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsxs("span",{className:"text-[9px] text-gray-400",children:[n," (log) ↑"]}),m.jsx(ab,{series:[{label:"merged",color:Tn.green},{label:"closed",color:Tn.gray}]})]})]})}const j1=[1,2,3,4,5,6,0],DCe=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],PCe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function MCe({cells:e,height:t}){const[n,r]=Jm(),[a,s]=L.useState(null),o=26,l=2,c=14,h=Math.max(r-o-2,1)/24,p=t??l+7*c+14,v=Math.max(1,...e),y=S=>{const w=Math.floor((S.nativeEvent.offsetX-o)/h),C=Math.floor((S.nativeEvent.offsetY-l)/c);if(w<0||w>23||C<0||C>6){s(null);return}s({row:C,col:w})},_=(S,w)=>e[j1[S]*24+w]??0;return m.jsx("div",{children:m.jsxs("div",{ref:n,className:"relative",style:{height:p},children:[r>0&&m.jsxs("svg",{width:r,height:p,className:"block",children:[DCe.map((S,w)=>m.jsx("text",{x:o-4,y:l+w*c+c-4,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:S},S)),j1.map((S,w)=>Array.from({length:24},(C,O)=>{const A=_(w,O),R=(a==null?void 0:a.row)===w&&(a==null?void 0:a.col)===O;return m.jsx("rect",{x:o+O*h,y:l+w*c,width:Math.max(h-1,1),height:c-1,rx:1.5,fill:A>0?Tn.blue:"currentColor",className:A>0?"":"text-gray-100 dark:text-gray-800",fillOpacity:A>0?.15+.85*(A/v):1,stroke:R?Tn.blue:"none",strokeWidth:R?1.5:0},`${w}-${O}`)})),[0,6,12,18].map(S=>m.jsxs("text",{x:o+S*h,y:p-3,className:"fill-gray-400 text-[8px]",children:[S,":00"]},S)),m.jsx("rect",{x:0,y:0,width:r,height:p,fill:"transparent",onMouseMove:y,onMouseLeave:()=>s(null)})]}),a&&r>0&&m.jsxs(eg,{x:o+a.col*h+h/2,y:l+a.row*c,width:r,children:[PCe[j1[a.row]]," ",String(a.col).padStart(2,"0"),":00 ·"," ",_(a.row,a.col)," events"]})]})})}const Hl=e=>e.reduce((t,n)=>t+n,0);function yp({title:e,children:t}){return m.jsxs("div",{children:[m.jsx("h3",{className:"mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:e}),m.jsx("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:t})]})}function LCe({data:e}){const{data:t}=Bc(),n=vu(t),r=e.weekBuckets,a=`${e.windowDays/7}-wk · weekly`,s=[{key:"opened",label:"Opened",color:Tn.blue,values:e.throughput.opened},{key:"merged",label:"Merged",color:Tn.green,values:e.throughput.merged},{key:"closed",label:"Closed",color:Tn.gray,values:e.throughput.closed}],o=[{key:"open",label:"Open",color:Tn.blue,values:e.backlog.open},{key:"stalled",label:"Stalled",color:Tn.orange,values:e.backlog.stalled}],l=[{key:"median",label:"Median to 1st review",color:Tn.blue,values:e.reviewLatencyTrend.medianHours}],c=[{key:"ttfr",label:"Open → 1st review",color:Tn.amber,values:e.cycleBreakdown.toFirstReview},{key:"rtm",label:"1st review → close",color:Tn.blue,values:e.cycleBreakdown.reviewToMerge}],d=[{key:"count",label:"PRs",color:Tn.blue,values:e.reviewLatencyDist.map(A=>A.count)}],h=e.reviewLatencyDist.map(A=>A.label),p=[{key:"untouched",label:Jr.untouched.label,color:Jr.untouched.color,values:e.threadMix.untouched},{key:"replied",label:Jr.replied_unresolved.label,color:Jr.replied_unresolved.color,values:e.threadMix.replied_unresolved},{key:"likely",label:Jr.likely_addressed.label,color:Jr.likely_addressed.color,values:e.threadMix.likely_addressed},{key:"resolved",label:Jr.resolved.label,color:Jr.resolved.color,values:e.threadMix.resolved}],v=[{key:"approved",label:"Approved",color:Tn.green,values:e.reviewVerdicts.approved},{key:"changes",label:"Changes requested",color:Tn.orange,values:e.reviewVerdicts.changes_requested},{key:"commented",label:"Commented",color:Tn.gray,values:e.reviewVerdicts.commented},{key:"dismissed",label:"Dismissed",color:Tn.slate,values:e.reviewVerdicts.dismissed}],y=e.reviewerLoad.map((A,R)=>({key:String(A.userId),label:A.userId===-1?"Others":Lr(n.get(A.userId),A.userId),color:bO[R%bO.length],values:A.weekly})),_=[{key:"count",label:"PRs",color:Tn.purple,values:e.sizeDist.map(A=>A.count)}],S=e.sizeDist.map(A=>A.label),w=e.sizeVsCycle.map(A=>({x:A.loc,y:A.hoursOpen,label:`#${A.prNumber}`,merged:A.merged})),C=e.sizeCycleByBucket.map(A=>A.label),O=[{key:"median",label:"Median time open",color:Tn.teal,values:e.sizeCycleByBucket.map(A=>A.medianHours??0)}];return m.jsxs("div",{className:"space-y-4",children:[m.jsxs(yp,{title:"Flow & throughput",children:[m.jsx(fs,{title:"PR throughput",note:a,children:Hl(s.flatMap(A=>A.values))===0?m.jsx(za,{}):m.jsx(Gd,{labels:r,series:s,mode:"grouped"})}),m.jsx(fs,{title:"Open backlog & stalled",note:"weekly snapshot",children:Math.max(0,...e.backlog.open)===0?m.jsx(za,{}):m.jsx(Tw,{labels:r,series:o,curved:!0})})]}),m.jsxs(yp,{title:"Speed & latency",children:[m.jsx(fs,{title:"Time to first review",note:"weekly median",children:e.reviewLatencyTrend.medianHours.every(A=>A==null)?m.jsx(za,{}):m.jsx(Tw,{labels:r,series:l,area:!0,formatY:vp,curved:!0})}),m.jsx(fs,{title:"Cycle-time breakdown",note:"by close week",children:Hl(e.cycleBreakdown.count)===0?m.jsx(za,{}):m.jsx(Gd,{labels:r,series:c,mode:"stacked",formatY:vp})}),m.jsx(fs,{title:"Review-latency distribution",note:"open → 1st review",children:Hl(d[0].values)===0?m.jsx(za,{}):m.jsx(Gd,{labels:h,series:d})})]}),m.jsxs(yp,{title:"Review health",children:[m.jsx(fs,{title:"Thread-resolution mix",note:"by thread created week",children:Hl(p.flatMap(A=>A.values))===0?m.jsx(za,{}):m.jsx(xO,{labels:r,series:p})}),m.jsx(fs,{title:"Review verdicts",note:a,children:Hl(v.flatMap(A=>A.values))===0?m.jsx(za,{}):m.jsx(Gd,{labels:r,series:v,mode:"stacked"})}),m.jsx(fs,{title:"Reviews by reviewer",note:a,children:y.length===0?m.jsx(za,{}):m.jsx(xO,{labels:r,series:y})})]}),m.jsxs(yp,{title:"Size & risk",children:[m.jsx(fs,{title:"PR size distribution",note:"opened, by LOC",children:Hl(_[0].values)===0?m.jsx(za,{}):m.jsx(Gd,{labels:S,series:_})}),m.jsx(fs,{title:"Median time open by size",note:"PRs closed in window",children:Hl(e.sizeCycleByBucket.map(A=>A.count))===0?m.jsx(za,{}):m.jsx(Gd,{labels:C,series:O,formatY:vp,formatValue:vp})}),m.jsx(fs,{title:"Size vs. time open",note:"log–log · power-law fit",children:w.length===0?m.jsx(za,{}):m.jsx(OCe,{points:w,xLabel:"LOC",yLabel:"time open",formatX:jc,formatY:vp,fit:!0})})]}),m.jsx(yp,{title:"Cadence",children:m.jsx(fs,{title:"Activity heatmap",note:"by weekday × hour (UTC)",children:Hl(e.activityHeatmap)===0?m.jsx(za,{}):m.jsx(MCe,{cells:e.activityHeatmap})})})]})}function FCe({repoId:e,repoName:t,onClose:n}){const{data:r,isLoading:a,error:s}=lD(e);return L.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:m.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4",onClick:n,role:"presentation",children:m.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:[m.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[m.jsxs("div",{className:"min-w-0",children:[m.jsx("h2",{className:"truncate text-sm font-semibold",children:t??"Analytics"}),m.jsxs("p",{className:"text-[11px] text-gray-400",children:["Charts over the last ",r?r.windowDays/7:12," weeks"]})]}),m.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:"✕"})]}),m.jsxs("div",{className:"min-h-0 flex-1 overflow-auto px-4 py-3",children:[a&&!r&&m.jsx("div",{className:"py-12 text-center text-sm text-gray-500",children:"Loading analytics…"}),s&&m.jsx("div",{className:"py-12 text-center text-sm text-red-500",children:"Failed to load analytics."}),r&&m.jsx(LCe,{data:r})]})]})})}function $Ce(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 jCe(){const[,e]=L.useState(0);L.useEffect(()=>{const t=window.setInterval(()=>e(n=>n+1),3e4);return()=>window.clearInterval(t)},[])}function BCe({fullName:e,maintainerCount:t,hasUnread:n,attentionCount:r,openPrs:a,threadTotals:s,selected:o,onSelect:l}){const c=s!=null||n||r>0||a!=null;return m.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:[m.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[m.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-gray-700 dark:text-gray-200",children:e}),t>0&&m.jsx(gk,{})]}),c&&m.jsxs("span",{className:"flex items-center gap-1.5 pl-0.5",children:[n&&m.jsx("span",{"aria-hidden":"true",title:"New activity",className:"inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-sky-500"}),s!=null&&m.jsx(AT,{counts:s,compact:!0}),r>0&&m.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]}),m.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-gray-400",children:a==null?"":a>0?`[${a}]`:"[—]"})]})]})}function UCe(){jCe();const e=$e(A=>A.repoIds),t=$e(A=>A.userIds),n=$e(A=>A.activityRepoId),r=$e(A=>A.setActivityRepo),{data:a,isFetching:s,isLoading:o,refetch:l}=nCe(e,t),{data:c}=gu(),d=lr(),[h,p]=L.useState(null),v=L.useMemo(()=>$Ce((a==null?void 0:a.repos)??[]),[a==null?void 0:a.repos]),y=typeof n=="number"?v.find(A=>A.repoId===n)??null:null,_=n==="feed"||n==null,S=(a==null?void 0:a.generatedAt)??null,w=S!=null&&Date.now()-new Date(S).getTime()>10*6e4,C=a!=null?v.map(A=>({repoId:A.repoId,fullName:A.repoFullName,maintainerCount:A.maintainerIds.length,hasUnread:A.hasUnread,attentionCount:A.attentionCount,openPrs:A.stats.openPrs,threadTotals:A.threadTotals})):(c??[]).map(A=>({repoId:A.id,fullName:A.fullName,maintainerCount:0,hasUnread:!1,attentionCount:0,openPrs:null,threadTotals:null})),O=a!=null&&v.length===0;return m.jsxs("div",{className:"flex h-full min-h-0 flex-col md:flex-row",children:[m.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:[m.jsxs("div",{className:"flex items-center gap-2 border-b border-gray-200 px-3 py-2 dark:border-gray-800",children:[m.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"State of play"}),m.jsxs("button",{type:"button",onClick:()=>{l(),d.invalidateQueries({queryKey:["consolidated-feed"]})},disabled:s,className:"ml-auto flex items-center gap-1 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",title:"Re-query the local database (does not trigger a GitHub sync)",children:[m.jsx("span",{"aria-hidden":"true",className:s?"animate-spin":"",children:"↻"}),"Refresh"]})]}),S!=null&&m.jsxs("div",{className:`px-3 py-1 text-[10px] ${w?"text-amber-500":"text-gray-400"}`,title:new Date(S).toLocaleString(),children:[ra(S),w?" · stale":""]}),s&&a!=null&&m.jsx("div",{className:"h-0.5 w-full overflow-hidden bg-sky-100 dark:bg-sky-950",children:m.jsx("div",{className:"h-full w-1/3 animate-pulse bg-sky-500"})}),m.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 ${s&&a!=null?"opacity-60 transition-opacity":""}`,children:[m.jsxs("button",{type:"button",onClick:()=>r("feed"),"aria-pressed":_,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 ${_?"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:[m.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-sky-500",children:"✦"}),m.jsx("span",{className:"min-w-0 flex-1 truncate font-semibold text-gray-700 dark:text-gray-200",children:"Feed"})]}),C.map(A=>m.jsx(BCe,{fullName:A.fullName,maintainerCount:A.maintainerCount,hasUnread:A.hasUnread,attentionCount:A.attentionCount,openPrs:A.openPrs,threadTotals:A.threadTotals,selected:n===A.repoId,onSelect:()=>r(A.repoId)},A.repoId)),m.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(A=>m.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-400",title:Jr[A].description,children:[m.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{background:Jr[A].color}}),Jr[A].label.toLowerCase()]},A))})]})]}),m.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-3",children:O?m.jsx("div",{className:"flex h-full items-center justify-center text-sm text-gray-400",children:"No watched repos yet. Add a repo from the filter bar to populate the Activity."}):_?m.jsx($1,{}):o&&a==null?m.jsx("div",{className:"space-y-3",children:[0,1,2].map(A=>m.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"},A))}):y!=null?m.jsxs("div",{className:"space-y-3",children:[m.jsx(pCe,{repo:y}),m.jsx(mCe,{repoId:y.repoId,onOpenCharts:()=>p({repoId:y.repoId,name:y.repoFullName})}),m.jsx(gCe,{prs:y.prs,repoFullName:y.repoFullName}),m.jsx($1,{repoId:y.repoId})]}):m.jsx($1,{})}),m.jsx(FCe,{repoId:(h==null?void 0:h.repoId)??null,repoName:(h==null?void 0:h.name)??null,onClose:()=>p(null)})]})}function HCe(){const e=$e(d=>d.selectedPrId),t=$e(d=>d.selectedThreadId),n=$e(d=>d.clearSelection),r=L.useDeferredValue(e),a=e??r,s=ln(d=>d.activeTab),o=Fw(s),l=(o==null?void 0:o.kind)==="pr-detail"?o.prId:null,c=a!=null&&a!==l;return m.jsxs("div",{className:"relative h-full","data-testid":"detail-pane",children:[e!=null&&m.jsx("div",{className:"absolute right-2 top-1.5 z-10 flex items-center gap-2",children:m.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:"✕"})}),c?m.jsx(MM,{prId:a,selectedThreadId:t},a):m.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 qF="pierre:notifications",B1="pierre:notif-pref";function _O(){try{return localStorage.getItem(qF)==="1"}catch{return!1}}function KF(){const[e,t]=L.useState(_O);L.useEffect(()=>{const r=()=>t(_O());return window.addEventListener(B1,r),window.addEventListener("storage",r),()=>{window.removeEventListener(B1,r),window.removeEventListener("storage",r)}},[]);const n=L.useCallback(r=>{try{localStorage.setItem(qF,r?"1":"0")}catch{}t(r),window.dispatchEvent(new Event(B1))},[]);return[e,n]}function zCe(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 YCe={cloning:"Cloning",fetching_diff:"Fetching diff",deciding:"Deciding scope",reviewing:"Reviewing",persisting:"Saving findings"};function WCe(){var R;const e=((R=$f().data)==null?void 0:R.claudeReviewEnabled)??!1,t=$e(F=>F.claudeReviewKickoff),n=$e(F=>F.openClaudeReview),[r]=KF(),a=L.useRef(r);a.current=r;const[s,o]=L.useState(!1);L.useEffect(()=>{t>0&&o(!0)},[t]);const{data:l,dataUpdatedAt:c}=kK(e&&s);L.useEffect(()=>{s&&((l==null?void 0:l.reviews.length)??0)===0&&o(!1)},[c]);const[d,h]=L.useState({}),[p,v]=L.useState({}),y=L.useRef(null),_=((l==null?void 0:l.reviews)??[]).map(F=>`${F.reviewId}:${F.phase??""}`).join(",");L.useEffect(()=>{const F=(l==null?void 0:l.reviews)??[],M=new Set(F.map(B=>B.reviewId)),Y=y.current;if(Y!=null){const B=[];for(const[J,P]of Y)M.has(J)||B.push(P);B.length>0&&(pK(),a.current&&zCe(B))}y.current=new Map(F.map(B=>[B.reviewId,{repoFullName:B.repoFullName,prNumber:B.prNumber,prTitle:B.prTitle}])),h(B=>{const J={...B};for(const P of F)J[P.reviewId]={reviewId:P.reviewId,prId:P.prId,repoFullName:P.repoFullName,prNumber:P.prNumber,prTitle:P.prTitle,phase:P.phase,done:!1};for(const P of Object.values(J))!M.has(P.reviewId)&&!P.done&&(J[P.reviewId]={...P,done:!0});return J})},[_]);const S=Object.values(d).filter(F=>!p[F.reviewId]);if(!e||S.length===0)return null;const w=S.filter(F=>!F.done),C=w.length===0,O=()=>{v(F=>{const M={...F};for(const Y of S)M[Y.reviewId]=!0;return M})},A=F=>v(M=>({...M,[F]:!0}));return m.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:m.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:[m.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 px-3 py-1.5 dark:border-gray-800",children:[m.jsxs("span",{className:"text-xs font-semibold",children:["Claude reviews",w.length>0&&m.jsxs("span",{className:"ml-1 font-normal text-gray-400",children:["· ",w.length," running"]})]}),C&&m.jsx("button",{type:"button",onClick:O,className:"text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:"Dismiss all"})]}),m.jsx("ul",{className:"max-h-64 divide-y divide-gray-100 overflow-auto dark:divide-gray-800",children:S.map(F=>m.jsxs("li",{className:"px-3 py-2 text-xs",children:[m.jsxs("button",{type:"button",onClick:()=>n(F.prId),className:"block w-full text-left",title:"Open this review",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[F.done?m.jsx("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full bg-green-500"}):m.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"}),m.jsxs("span",{className:"truncate font-medium text-blue-600 hover:underline dark:text-blue-400",children:[F.repoFullName," #",F.prNumber]})]}),m.jsx("div",{className:"mt-0.5 truncate text-gray-500",children:F.prTitle}),m.jsx("div",{className:"mt-0.5 text-gray-400",children:F.done?"Ready — click to view":`${F.phase!=null?YCe[F.phase]??F.phase:"Starting"}…`})]}),F.done&&m.jsx("div",{className:"mt-1 text-right",children:m.jsx("button",{type:"button",onClick:()=>A(F.reviewId),className:"text-[11px] text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:"dismiss"})})]},F.reviewId))})]})})}function GCe({repos:e,statuses:t,cancelling:n,onCancel:r}){const a=c=>t==null?void 0:t.find(d=>d.repoId===c),s=c=>{if(t===void 0)return!0;const d=a(c);return d===void 0||d.status==="running"},o=e.filter(c=>!s(c.id)).length,l=e.length>0&&o===e.length;return m.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",role:"presentation",children:m.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:[m.jsx("div",{className:"mb-3 flex items-center justify-between",children:m.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"}`})}),m.jsx("ul",{className:"space-y-3",children:e.map(c=>{var _,S;const d=a(c.id),h=s(c.id),p=(d==null?void 0:d.status)==="error",v=((_=d==null?void 0:d.progress)==null?void 0:_.prsProcessed)??0,y=h?Math.round((((S=d==null?void 0:d.progress)==null?void 0:S.percent)??0)*100):100;return m.jsxs("li",{children:[m.jsxs("div",{className:"mb-1 flex items-baseline justify-between gap-2 text-xs",children:[m.jsx("span",{className:"truncate font-medium",title:c.fullName,children:c.fullName}),m.jsx("span",{className:"shrink-0 text-gray-500",children:p?m.jsx("span",{className:"text-red-500",children:"error"}):h?`${y}%${v>0?` · ${v} PRs`:""}`:m.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["✓ done",v>0?` · ${v} PRs`:""]})})]}),m.jsx("div",{className:"h-2 w-full overflow-hidden rounded bg-gray-200 dark:bg-gray-800",children:m.jsx("div",{className:`h-2 rounded transition-all duration-500 ${p?"bg-red-500":h?"bg-blue-500":"bg-green-500"}`,style:{width:`${p?100:y}%`}})})]},c.id)})}),m.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 text-xs text-gray-500",children:[m.jsxs("span",{children:[o," of ",e.length," repo",e.length===1?"":"s"," complete"]}),m.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 VCe(e){let t=null;for(const n of e){const r=n.lastIncrementalSyncAt??n.lastFullSyncAt;r&&(!t||r>t)&&(t=r)}return t}const EO=5,wO=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});function qCe(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 KCe(e){const t=qCe(EO),n=Math.max(1,Math.round((t.getTime()-Date.now())/6e4)),r=e?[`Last synced ${wO(new Date(e))}`]:[];return r.push(`Syncs automatically every ${EO} minutes`),r.push(`Next sync ~${wO(t)} (in ${n} min)`),r.join(`
1376
+ `)[0]})]}):m.jsx("span",{className:"text-gray-400",children:"loading commit…"})}),v&&m.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[m.jsxs("code",{className:"truncate font-mono text-gray-600 dark:text-gray-300",children:[v.path,v.line!=null?`:${v.line}`:""]}),m.jsx("span",{className:"ml-auto shrink-0",children:m.jsx(AM,{state:v.derivedState})})]}),S&&m.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}),_&&m.jsxs("div",{className:"text-xs",children:[m.jsx(So,{children:_.body}),v&&v.comments.length>1&&m.jsxs("div",{className:"mt-1 text-[11px] text-gray-400",children:["+",v.comments.length-1," more in thread"]})]}),C&&m.jsx("div",{className:"text-xs",children:F?m.jsx(So,{children:F.body}):m.jsx("span",{className:"text-gray-400",children:"loading comment…"})}),m.jsxs("div",{className:"flex items-center gap-3 pt-0.5 text-[11px]",children:[!w&&m.jsx("button",{type:"button",onClick:Y,className:"text-blue-500 hover:underline",children:"Open in detail pane"}),w&&e.prId!=null&&m.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"}),w&&R&&A&&m.jsx("a",{href:`${A.githubUrl}/commits/${R.sha}`,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"Open commit on GitHub ↗"}),C&&F&&A&&m.jsx("a",{href:F.url??A.githubUrl,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"Open on GitHub ↗"})]})]})}function HSe({state:e,eventsById:t,usersById:n,prsById:r,focusPrId:a,onContextFocus:s,onDismiss:o,onNavigate:l}){var P;const[c,d]=zF("pierre:popoverSize",null),{refs:h,floatingStyles:p,context:v,isPositioned:y}=jF({open:!0,onOpenChange:q=>{q||o()},strategy:"fixed",placement:"right-start",middleware:[RF(24),DF({fallbackPlacements:["left-start","bottom"]}),OF({padding:8})],whileElementsMounted:(q,z,W)=>IF(q,z,W,{animationFrame:!0})}),_=$F(v,{outsidePress:!1}),{getFloatingProps:S}=BF([_]),w=e.eventIds[0]??null,C=L.useRef(null);L.useEffect(()=>{C.current=null},[w]),L.useEffect(()=>{const q=()=>({x:e.x,y:e.y,top:e.y,left:e.x,right:e.x,bottom:e.y,width:0,height:0});h.setReference({getBoundingClientRect:()=>{if(w!=null){const z=document.querySelector(`.ev-key-${w}`),W=(z==null?void 0:z.querySelector(".ev-marker-inner, .ev-cluster-inner"))??z;if(W){const G=W.getBoundingClientRect();return C.current=G,G}}return C.current??q()}})},[h,w,e.x,e.y]);const O=e.eventIds.map(q=>t.get(q)).filter(q=>q!=null).filter(q=>a==null||q.prId===a),A=((P=O[0])==null?void 0:P.prId)??null;L.useEffect(()=>{s({groupIds:null,prId:A,eventId:null})},[A,s]);const R=q=>{const z=q.currentTarget;d({width:z.offsetWidth,height:z.offsetHeight})},[F,M]=L.useState({x:0,y:0}),Y=L.useRef(null);L.useEffect(()=>{const q=W=>{const G=Y.current;G&&M({x:G.ox+(W.clientX-G.sx),y:G.oy+(W.clientY-G.sy)})},z=()=>{Y.current=null};return window.addEventListener("pointermove",q),window.addEventListener("pointerup",z),()=>{window.removeEventListener("pointermove",q),window.removeEventListener("pointerup",z)}},[]);const B=q=>{q.button===0&&(q.preventDefault(),Y.current={sx:q.clientX,sy:q.clientY,ox:F.x,oy:F.y})},J=`${p.transform??""} translate(${F.x}px, ${F.y}px)`.trim();return m.jsx(FF,{children:m.jsxs("div",{ref:h.setFloating,style:{...p,transform:J,visibility:y?"visible":"hidden",width:(c==null?void 0:c.width)??420,height:(c==null?void 0:c.height)??340,minWidth:240,minHeight:120,maxWidth:"92vw",maxHeight:"80vh",resize:"both",overflow:"hidden"},...S(),onPointerUp:R,"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:[m.jsxs("div",{className:"tl-modal-header",onPointerDown:B,children:[m.jsx("svg",{className:"tl-grip",width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:m.jsxs("g",{fill:"currentColor",children:[m.jsx("circle",{cx:"2",cy:"2",r:"1"}),m.jsx("circle",{cx:"8",cy:"2",r:"1"}),m.jsx("circle",{cx:"2",cy:"5",r:"1"}),m.jsx("circle",{cx:"8",cy:"5",r:"1"}),m.jsx("circle",{cx:"2",cy:"8",r:"1"}),m.jsx("circle",{cx:"8",cy:"8",r:"1"})]})}),m.jsx("span",{className:"tl-modal-title",children:O.length>1?`${O.length} events`:"Activity"}),m.jsx("button",{type:"button",className:"tl-modal-close",onPointerDown:q=>q.stopPropagation(),onClick:o,"aria-label":"Close",title:"Close",children:"✕"})]}),m.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-2",children:O.length===1?m.jsx(pO,{ev:O[0],usersById:n,prsById:r,onNavigate:l}):m.jsx("div",{className:"divide-y divide-gray-200 dark:divide-gray-800",children:O.map(q=>m.jsx("div",{className:"py-2 first:pt-0 last:pb-0",children:m.jsx(pO,{ev:q,usersById:n,prsById:r,onNavigate:l})},q.id))})})]})})}const zSe=1e3*60*60,YSe={stack:!1,stackSubgroups:!0,groupHeightMode:"fixed",orientation:{axis:"top",item:"top"},zoomMin:zSe,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}},WSe=12,GSe=2;function mO(e){return[...new Set(e)]}function gO(e,t){var a,s;if(!e)return 0;const n=e.body,r=t==null?void 0:t.querySelector(".vis-panel.vis-center");return((s=(a=n==null?void 0:n.domProps)==null?void 0:a.center)==null?void 0:s.width)||(r==null?void 0:r.clientWidth)||(t==null?void 0:t.clientWidth)||0}function kp(e){return Date.parse(String(e.start))}function VSe(e){return e.end!=null?Date.parse(String(e.end)):kp(e)}function qSe(e,t){if(t<=0)return;const n=WSe*t,r=new Map;for(const a of e){const s=`${String(a.group)}|${String(a.subgroup??"")}`,o=r.get(s);o?o.push(a):r.set(s,[a])}for(const a of r.values())if(a.length!==0){a.sort((s,o)=>kp(s)-kp(o));for(let s=0;s<a.length;s++){const o=a[s],l=kp(o),c=VSe(o),d=s+1<a.length?kp(a[s+1]):Number.POSITIVE_INFINITY,h=Math.min(Math.max(c,l+n),d);h!==c&&(o.end=new Date(h).toISOString())}}}function vO(e,t){const n=t.getTime()-e.getTime(),r=Math.max(n*.06,14400*1e3),a=Math.max(n*.03,7200*1e3);return{start:new Date(e.getTime()-a),end:new Date(t.getTime()+r)}}function KSe(e){const t=document.createElement("div");return t.innerHTML=e,t.firstElementChild??t}function QSe(){const e=typeof navigator<"u"?navigator.platform||navigator.userAgent:"";return/Mac|iP(hone|ad|od)/.test(e)?"metaKey":"ctrlKey"}function XSe(e){return e.actorId!=null?`repo:${e.repoId}:user:${e.actorId}`:`repo:${e.repoId}`}const ZSe=/^repo:\d+:user:\d+$/;function Wd(e){return`tlg-${e.replace(/:/g,"-")}`}function JSe(e){return new Date(e.mergedAt??e.closedAt??new Date().toISOString()).getTime()}const eCe=1440*60*1e3;function yO({mode:e}={}){const t=(e==null?void 0:e.kind)==="isolate"?e.prId:null,n=L.useRef(null),r=L.useRef(null),a=L.useRef(new mu),s=L.useRef(new mu),o=L.useRef(new Map),l=L.useRef(new Map),c=L.useRef(new Map),d=L.useRef([]),h=L.useRef(null),p=L.useRef(new Map),v=L.useRef(new Map),y=L.useRef(new Map),_=L.useRef({active:!1,states:[]}),S=L.useRef(null),w=L.useRef(null),C=L.useRef(new Set),O=L.useRef(new Set),A=L.useRef(!1);if(!A.current){A.current=!0;try{const K=localStorage.getItem("pierre:collapsedRows");if(K){const fe=JSON.parse(K);Array.isArray(fe)&&(O.current=new Set(fe.map(String)))}}catch{}}const R=L.useRef(new Map),F=L.useRef(null),M=L.useRef(null),Y=L.useRef(null),B=L.useRef(null),J=L.useRef(null),P=L.useRef(null),q=L.useRef(null),z=L.useRef(null),W=L.useRef(null),G=L.useRef(0),X=L.useRef(!1),de=L.useRef(null),ue=L.useRef(null),H=L.useRef(null),oe=L.useRef(null),j=L.useRef(null),te=L.useRef(null),ve=L.useRef(null),[Q,Me]=L.useState(null),ae=L.useRef(null);ae.current=Q;const[Ie,me]=L.useState(null),Xe=L.useRef(new Map),[we,ke]=L.useState(!1),Pe=L.useMemo(()=>t!=null?Date.now()-Z$*eCe:null,[t]),{data:Ae,isLoading:yt,error:ft}=Bw(t!=null?{dropMembers:!0,fromMs:Pe}:void 0),{data:Ht}=sD(),{data:_t}=Uw(),{data:Vt}=Hw(),{data:jn}=gu(),{data:Kn}=Bc(),{data:Bn}=jw(),Pn=lr(),kt=$e(K=>K.derivedStates),_r=$e(K=>K.userIds),gi=$e(K=>K.selectPr),ii=$e(K=>K.selectedPrId),_e=L.useRef(ii),[Ge,Tt]=L.useState(0),[$t,mt]=L.useState(0),dr=$e(K=>K.preset),Ci=$e(K=>K.customFrom),Nr=$e(K=>K.customTo),vi=$e(K=>K.rangeResetSignal),Ir=L.useMemo(()=>{const K=new Map;for(const fe of jn??[])K.set(fe.id,fe);return K},[jn]),Mn=L.useRef(Ir);Mn.current=Ir;const Fr=L.useMemo(()=>{const K=new Map;for(const fe of Bn??[])K.set(fe.repoId,new Set(fe.userIds));return K},[Bn]),Ln=L.useMemo(()=>vu(Kn),[Kn]);p.current=Ln;const Ui=L.useRef(!1);L.useEffect(()=>{if(!Ae)return;let K=!1;for(const fe of Ae.events)if(fe.actorId!=null&&!Ln.has(fe.actorId)){K=!0;break}if(!K){for(const fe of Ae.prs)if(fe.authorId!=null&&!Ln.has(fe.authorId)){K=!0;break}}if(!K){Ui.current=!1;return}Ui.current||(Ui.current=!0,Pn.invalidateQueries({queryKey:["users"]}))},[Ae,Ln,Pn]);const ws=L.useMemo(()=>{const K=new Map;for(const fe of(Ae==null?void 0:Ae.prs)??[])K.set(fe.id,fe);return K},[Ae]);v.current=ws;const Yr=L.useCallback(K=>{const fe=a.current,xe=S.current;if(xe!=null&&xe!==K){const Ne=fe.get(`pr:${xe}`);Ne&&typeof Ne.className=="string"&&fe.update({id:`pr:${xe}`,className:Ne.className.replace(/\s*pr-cross-linked/g,"")})}if(K!=null){const Ne=fe.get(`pr:${K}`);Ne&&typeof Ne.className=="string"&&!Ne.className.includes("pr-cross-linked")&&fe.update({id:`pr:${K}`,className:`${Ne.className} pr-cross-linked`})}S.current=K},[]),Un=L.useCallback(K=>{const fe=a.current,xe=M.current;if(xe!=null){const Oe=fe.get(xe);Oe&&typeof Oe.className=="string"&&Oe.className.includes("ev-cross-linked")&&fe.update({id:xe,className:Oe.className.replace(/\s*ev-cross-linked/g,"")}),M.current=null}if(F.current=K,K==null)return;const Ne=fe.get(`ev:${K}`)?`ev:${K}`:c.current.get(K)??null;if(Ne==null)return;const Re=fe.get(Ne);Re&&typeof Re.className=="string"&&!Re.className.includes("ev-cross-linked")&&(fe.update({id:Ne,className:`${Re.className} ev-cross-linked`}),M.current=Ne)},[]),$r=L.useCallback(K=>{const fe=a.current;for(const Re of fe.getIds()){const Oe=fe.get(Re);Oe&&typeof Oe.className=="string"&&Oe.className.includes("ev-exit-glow")&&fe.update({id:Re,className:Oe.className.replace(/\s*ev-exit-glow/g,"")})}if(B.current=null,Y.current=K,K==null)return;const xe=fe.get(`ev:${K}`)?`ev:${K}`:c.current.get(K)??null;if(xe==null)return;const Ne=fe.get(xe);Ne&&typeof Ne.className=="string"&&!Ne.className.includes("ev-exit-glow")&&(fe.update({id:xe,className:`${Ne.className} ev-exit-glow`}),B.current=xe)},[]),ie=L.useCallback(K=>{const fe=a.current;for(const Re of fe.getIds()){const Oe=fe.get(Re);Oe&&typeof Oe.className=="string"&&Oe.className.includes("ev-selected")&&fe.update({id:Re,className:Oe.className.replace(/\s*ev-selected/g,"")})}if(ve.current=null,te.current=K,K==null)return;const xe=fe.get(`ev:${K}`)?`ev:${K}`:c.current.get(K)??null;if(xe==null)return;const Ne=fe.get(xe);Ne&&typeof Ne.className=="string"&&!Ne.className.includes("ev-selected")&&(fe.update({id:xe,className:`${Ne.className} ev-selected`}),ve.current=xe)},[]),pe=L.useCallback(()=>{const K=a.current,fe=C.current,xe=[],Ne=[],Re=w.current!=null;for(const Oe of d.current){const tt=String(Oe.id),ze=fe.has(String(Oe.group))||!Re&&O.current.has(String(Oe.group)),Ve=K.get(tt)!=null;ze&&Ve?xe.push(tt):!ze&&!Ve&&Ne.push(Oe)}xe.length&&K.remove(xe),Ne.length&&K.add(Ne)},[]),Je=L.useCallback(()=>{try{localStorage.setItem("pierre:collapsedRows",JSON.stringify([...O.current]))}catch{}},[]),Nt=L.useCallback((K,fe)=>{var Ve,bt;const xe=s.current;if(!xe.get(K))return;const Ne=a.current.get(),Re=new Set;for(const Ze of Ne)Ze.group===K&&typeof Ze.subgroup=="string"&&Re.add(Ze.subgroup);const Oe={};for(const Ze of Re)Oe[Ze]=!fe;const tt=xe.get(K);tt&&(xe.remove(K),xe.add({...tt,subgroupVisibility:Oe,heightMode:fe?"auto":"fixed"})),fe?O.current.add(K):O.current.delete(K),Je(),pe();const ze=r.current;(bt=(Ve=ze==null?void 0:ze.itemSet)==null?void 0:Ve.markDirty)==null||bt.call(Ve,{restackGroups:!0}),ze==null||ze.redraw()},[Je,pe]),Zt=L.useCallback(K=>{const fe=s.current.getIds().map(String).filter(Re=>ZSe.test(Re)),xe=K&&K.length?new Set(K):null,Ne=[];for(const Re of fe){const Oe=xe!=null&&!xe.has(Re);Oe?C.current.add(Re):C.current.delete(Re),Ne.push({id:Re,visible:!Oe})}Ne.length&&s.current.update(Ne),w.current=xe?K:null,pe()},[pe]),zt=L.useCallback(()=>{const K=r.current,fe=n.current,xe=h.current;if(!K||!fe||!xe)return;const Ne=K.getWindow(),Re=Ne.end.valueOf()-Ne.start.valueOf();z.current=Re;const Oe=fe.clientWidth||1e3,tt=Re/Oe;let ze;if(X.current&&de.current!=null)ze=xe.events.filter(St=>St.prId===de.current);else if(ze=xe.events,_.current.active){const{states:St}=_.current;ze=ze.filter(ct=>ct.type==="review_comment"&&ct.prId!=null&&ct.derivedState!=null&&St.includes(ct.derivedState))}const{items:Ve,clusterMembers:bt}=FSe(ze,XSe,p.current,v.current,y.current,tt,8,{start:Ne.start.valueOf(),end:Ne.end.valueOf()});l.current=bt;const Ze=new Map;for(const[St,ct]of bt)for(const jt of ct)Ze.set(jt,St);c.current=Ze;const Et=a.current.getIds().filter(St=>{const ct=String(St);return ct.startsWith("ev:")||ct.startsWith("cl:")||ct.startsWith("xsep:")});if(a.current.remove(Et),a.current.add(Ve),d.current=Ve.filter(St=>String(St.id).startsWith("xsep:")),pe(),F.current!=null){const St=F.current;M.current=null,F.current=null,Un(St)}if(Y.current!=null){const St=Y.current;B.current=null,Y.current=null,$r(St)}if(te.current!=null){const St=te.current;ve.current=null,te.current=null,ie(St)}},[Un,$r,ie,pe]),Le=L.useCallback(()=>{const K=ue.current;if(!K)return;const fe=()=>{K.childElementCount&&K.replaceChildren(),K.style.display="none"},xe=n.current,Ne=de.current;if(!X.current||Ne==null||!xe){fe();return}const Re=xe.querySelector(".vis-panel.vis-center"),Oe=v.current.get(Ne);if(!Re||!Oe){fe();return}const tt=Wd(sc(Oe)),ze=xe.querySelector(`.vis-foreground .vis-group.${tt} .vis-item.pr-bar.vis-selected`)??xe.querySelector(`.vis-foreground .vis-group.${tt} .vis-item.pr-bar:not(.pr-focus-hidden)`);if(!ze||ze.offsetHeight===0){fe();return}const bt=(K.parentElement??xe).getBoundingClientRect(),Ze=Re.getBoundingClientRect();K.style.display="block",K.style.left=`${Ze.left-bt.left}px`,K.style.top=`${Ze.top-bt.top}px`,K.style.width=`${Ze.width}px`,K.style.height=`${Ze.height}px`;const Et=ze.getBoundingClientRect(),St=Et.top-Ze.top,ct=Et.bottom-Ze.top,jt=Et.left-Ze.left,sn=Et.right-Ze.left,pn="http://www.w3.org/2000/svg",bn=document.createDocumentFragment(),cn=xe.querySelectorAll(".vis-foreground .vis-item.ev-cross");for(const Mt of cn){if(Mt.offsetHeight===0)continue;const yr=(Mt.querySelector(".ev-marker-inner, .ev-cluster-inner")??Mt).getBoundingClientRect(),wn=yr.left+yr.width/2-Ze.left,un=yr.top-Ze.top,ua=yr.bottom-Ze.top,bi=Math.max(jt,Math.min(wn,sn));let Yi,Wr;if(un>=ct)Yi=un,Wr=ct;else if(ua<=St)Yi=ua,Wr=St;else continue;const qe=document.createElementNS(pn,"path");qe.setAttribute("d",`M ${wn.toFixed(1)} ${Yi.toFixed(1)} L ${bi.toFixed(1)} ${Wr.toFixed(1)}`),bn.appendChild(qe)}K.replaceChildren(bn)},[]),nt=L.useCallback(()=>{var xe;const K=X.current&&de.current!=null,fe=(((xe=ue.current)==null?void 0:xe.childElementCount)??0)>0;!K&&!fe||H.current==null&&(H.current=requestAnimationFrame(()=>{H.current=null,Le()}))},[Le]),et=L.useCallback((K,fe)=>{const xe=s.current;for(const[Ve,bt]of R.current){if(!xe.get(Ve))continue;const Ze={};for(const Et of bt)Ze[Et]=!0;xe.update({id:Ve,subgroupVisibility:Ze})}if(R.current.clear(),!K||K.length===0||fe==null)return;const Ne=y.current.get(fe),Re=v.current.get(fe),Oe=a.current.get(`pr:${fe}`),tt=Re?sc(Re):Oe&&typeof Oe.group=="string"?Oe.group:null,ze=a.current.get();for(const Ve of K){const bt=new Set(["cross"]);Ve===tt&&Ne!=null&&(bt.add(`bar:${Ne}`),bt.add(`ev:${Ne}`));const Ze=new Set;for(const ct of ze)ct.group===Ve&&typeof ct.subgroup=="string"&&Ze.add(ct.subgroup);const Et=[...Ze].filter(ct=>!bt.has(ct)),St={};for(const ct of Et)St[ct]=!1;for(const ct of Ze)bt.has(ct)&&(St[ct]=!0);Object.keys(St).length!==0&&(xe.update({id:Ve,subgroupVisibility:St}),Et.length&&R.current.set(Ve,Et))}},[]),yn=L.useCallback(K=>{const fe=a.current,xe=[];for(const Ne of fe.getIds()){const Re=String(Ne);if(!Re.startsWith("pr:"))continue;const Oe=fe.get(Ne);if(!Oe||typeof Oe.className!="string")continue;const tt=Number.parseInt(Re.slice(3),10),ze=Oe.className.includes("pr-focus-hidden"),Ve=K!=null&&tt!==K;Ve&&!ze?xe.push({id:Ne,className:`${Oe.className} pr-focus-hidden`}):!Ve&&ze&&xe.push({id:Ne,className:Oe.className.replace(/\s*pr-focus-hidden/g,"")})}xe.length&&fe.update(xe)},[]),an=L.useCallback(K=>{$r(null);const fe=X.current;et((K==null?void 0:K.groupIds)??null,(K==null?void 0:K.prId)??null),Zt((K==null?void 0:K.groupIds)??null),Yr((K==null?void 0:K.prId)??null),Un((K==null?void 0:K.eventId)??null);const xe=!!(K!=null&&K.groupIds&&K.groupIds.length>0);if(ke(xe),xe||(X.current=!1,de.current=null),xe&&(K==null?void 0:K.prId)!=null){const Ne=$e.getState();Ne.selectedPrId!==K.prId&&Ne.selectPr(K.prId)}if(!xe&&fe&&(yn(null),zt()),!xe&&O.current.size>0)for(const Ne of O.current)Nt(Ne,!0)},[et,Zt,Yr,Un,$r,yn,zt,Nt]),yi=L.useCallback(K=>{X.current||an(K)},[an]),tn=L.useCallback(()=>{const K=n.current;return K?K.querySelector(".vis-panel.vis-left.vis-vertical-scroll")??K.querySelector(".vis-panel.vis-right.vis-vertical-scroll"):null},[]),jr=L.useCallback(()=>{const K=oe.current,fe=n.current;if(!K||!fe)return;const xe=()=>{K.style.display!=="none"&&(K.style.display="none")},Ne=tn();if(!Ne){xe();return}const Oe=(K.parentElement??fe).getBoundingClientRect(),tt=Ne.getBoundingClientRect(),ze=tt.top,Ve=1;let bt=null;for(const jt of fe.querySelectorAll(".vis-labelset .vis-label.tl-repo-header")){const sn=jt.getBoundingClientRect();sn.height<1||sn.top<=ze+Ve&&(bt=jt)}if(!bt){xe();return}if(bt.getBoundingClientRect().top>=ze-Ve){xe();return}const St=((bt.querySelector(".vis-inner")??bt).textContent??"").trim();if(!St){xe();return}const ct=[...bt.classList].find(jt=>jt.startsWith("tl-repo-tint-"))??"";K.dataset.repo!==St&&(K.textContent=St,K.dataset.repo=St),K.dataset.tint!==ct&&(K.className=`tl-repo-sticky${ct?` ${ct}`:""}`,K.dataset.tint=ct),K.style.left=`${tt.left-Oe.left}px`,K.style.top=`${tt.top-Oe.top}px`,K.style.width=`${tt.width}px`,K.style.display!=="block"&&(K.style.display="block")},[tn]),Er=L.useCallback(()=>{j.current==null&&(j.current=requestAnimationFrame(()=>{j.current=null,jr()}))},[jr]),Cn=L.useCallback(()=>{const K=tn(),fe=n.current;if(!K||!fe)return null;const xe=K.getBoundingClientRect().top;let Ne=null,Re=0,Oe=1/0;for(const tt of fe.querySelectorAll(".vis-labelset .vis-label")){const ze=tt.getBoundingClientRect();if(ze.height<4||ze.bottom<=xe+1)continue;const Ve=[...tt.classList].find(Ze=>Ze.startsWith("tlg-"));if(!Ve)continue;const bt=Math.abs(ze.top-xe);bt<Oe&&(Oe=bt,Ne=Ve,Re=ze.top-xe)}return{token:Ne,offset:Re,scrollTop:K.scrollTop}},[tn]),ai=L.useCallback((K,fe)=>{const xe=r.current,Ne=h.current;if(!xe||!Ne)return;const Re=(fe==null?void 0:fe.pr)??v.current.get(K);if(!Re)return;Me(null);const Oe=Re.repoId,tt=new Set;Re.authorId!=null&&tt.add(Re.authorId);let ze=1/0,Ve=-1/0;const bt=Et=>{Et<ze&&(ze=Et),Et>Ve&&(Ve=Et)};bt(new Date(Re.openedAt).getTime()),bt(JSe(Re));for(const Et of Ne.events)Et.prId===K&&(Et.actorId!=null&&tt.add(Et.actorId),bt(new Date(Et.occurredAt).getTime()));const Ze=[...tt].map(Et=>`repo:${Oe}:user:${Et}`);if((fe==null?void 0:fe.fitWindow)!==!1&&Number.isFinite(ze)&&Number.isFinite(Ve)){const Et=Math.max((Ve-ze)*.08,432e5);xe.setWindow(ze-Et,Ve+Et,{animation:!0})}X.current=!0,de.current=K,an({groupIds:Ze.length?Ze:null,prId:K,eventId:(fe==null?void 0:fe.anchorEventId)??null}),zt(),yn(K),xe.setSelection([`pr:${K}`]),(fe==null?void 0:fe.anchorEventId)!=null&&Un(fe.anchorEventId)},[an,zt,yn,Un]),tr=L.useCallback(K=>{const fe=tn();if(!fe||r.current==null||!fe.isConnected)return;const xe=Math.max(0,fe.scrollHeight-fe.clientHeight);fe.scrollTop=Math.max(0,Math.min(xe,K)),fe.dispatchEvent(new Event("scroll"))},[tn]),Ar=L.useRef(!1),ns=L.useRef(0),Hi=L.useCallback((K,fe,xe=".ev-cross-linked",Ne=".pr-cross-linked")=>{const Re=n.current,Oe=tn(),tt=Re==null?void 0:Re.querySelector(".vis-panel.vis-center");if(!Re||!Oe||!tt)return;const ze=`.vis-labelset .vis-label.${K}`;let Ve;const bt=pn=>{const bn=tt.getBoundingClientRect(),cn=pn.getBoundingClientRect();return cn.top+cn.height/2-bn.top-bn.height/2},Ze=()=>{const pn=Mt=>[...Re.querySelectorAll(Mt)].filter(ht=>ht.offsetHeight>0).sort((ht,yr)=>yr.offsetHeight-ht.offsetHeight)[0];if(fe){const Mt=pn(xe);if(Mt)return{delta:bt(Mt),settleable:!0};const ht=Re.querySelector(`.vis-foreground .vis-group.${K}`);if(ht){const yr=tt.getBoundingClientRect();return{delta:ht.getBoundingClientRect().bottom-12-(yr.top+yr.height/2),settleable:!1}}return null}if(Ve&&Ve.isConnected&&Ve.offsetHeight>0)return{delta:bt(Ve),settleable:!0};const bn=pn(Ne);if(bn)return Ve=bn,{delta:bt(bn),settleable:!0};const cn=Re.querySelector(ze);return cn?{delta:bt(cn),settleable:!0}:null},Et=Re.querySelector(ze);Et&&tr(Et.offsetTop-8);let St=0,ct=0;const jt=++ns.current;Ar.current=!0,window.setTimeout(()=>{ns.current===jt&&(Ar.current=!1)},2500);const sn=()=>{if(ns.current!==jt)return;const pn=Ze();pn!=null&&(Math.abs(pn.delta)>6?(tr(Oe.scrollTop+pn.delta),ct=0):pn.settleable?ct+=1:ct=0),ct<6&&St++<90?requestAnimationFrame(sn):Ar.current=!1};requestAnimationFrame(()=>requestAnimationFrame(sn))},[tn,tr]),Ni=L.useCallback(K=>{const fe=n.current,xe=()=>{var ze;const tt=tn();if(!tt||!fe)return!0;if(K.token){const Ve=fe.querySelector(`.vis-labelset .vis-label.${K.token}`);if(Ve&&Ve.offsetHeight>0){const Ze=Ve.getBoundingClientRect().top-tt.getBoundingClientRect().top-K.offset;return Math.abs(Ze)>1?(tr(tt.scrollTop+Ze),!1):!0}}return tr(K.scrollTop),Math.abs((((ze=tn())==null?void 0:ze.scrollTop)??K.scrollTop)-K.scrollTop)<=2};xe();let Ne=0,Re=0;const Oe=()=>{xe()?Re+=1:Re=0,Re<3&&Ne++<30&&requestAnimationFrame(Oe)};requestAnimationFrame(Oe)},[tn,tr]),Ra=L.useCallback((K,fe,xe)=>{xe.length!==0&&(w.current||an(null),me(null),Me({x:K,y:fe,eventIds:xe}))},[an]),rs=L.useCallback(()=>{Me(null),w.current||an(null)},[an]),vr=L.useCallback(()=>{ae.current?rs():w.current||(_e.current!=null?$e.getState().clearSelection():Y.current!=null&&$r(null))},[rs,$r]),is=L.useCallback(()=>{Me(null)},[]);L.useEffect(()=>{ie(Q&&!we?Q.eventIds[0]??null:null)},[Q,we,ie]);const ks=(Q==null?void 0:Q.eventIds[0])??null;L.useEffect(()=>{if(ks==null)return;const K=o.current.get(ks);(K==null?void 0:K.prId)!=null&&$e.getState().selectPr(K.prId)},[ks]);const Fn=L.useCallback(K=>{const fe=Mn.current.get(K.repoId),xe=K.authorId!=null?p.current.get(K.authorId):void 0;return{id:K.id,number:K.number,title:K.title,repoFullName:(fe==null?void 0:fe.fullName)??`repo ${K.repoId}`,authorLogin:(xe==null?void 0:xe.githubLogin)??null,authorDisplayName:(xe==null?void 0:xe.displayName)??null,authorAvatarUrl:(xe==null?void 0:xe.avatarUrl)??null}},[]);L.useEffect(()=>{if(!n.current)return;const{from:K,to:fe}=nv($e.getState()),{start:xe,end:Ne}=vO(K,fe),Re=new pke(n.current,a.current,s.current,{...YSe,start:xe,end:Ne,zoomKey:QSe()});Re.on("click",Ve=>{var sn,pn,bn;const bt=Ve.item,Ze=((sn=Ve.event)==null?void 0:sn.srcEvent)??Ve.event,Et=(Ze==null?void 0:Ze.clientX)??Ve.pageX??0,St=(Ze==null?void 0:Ze.clientY)??Ve.pageY??0,ct=(Ze==null?void 0:Ze.target)??null;if((pn=ct==null?void 0:ct.closest)!=null&&pn.call(ct,"[data-collapse-gid]")||(bn=ct==null?void 0:ct.closest)!=null&&bn.call(ct,"[data-stats-gid]"))return;if(bt==null){if(((Ze==null?void 0:Ze.detail)??0)>=2)return;vr();return}const jt=String(bt);if(jt.startsWith("pr:"))ae.current&&!X.current&&!w.current&&rs(),gi(Number.parseInt(jt.slice(3),10));else if(jt.startsWith("ev:")){const cn=Number.parseInt(jt.slice(3),10);if(X.current){Un(cn),Ra(Et,St,[cn]);return}Ra(Et,St,[cn])}else if(jt.startsWith("cl:")){const cn=l.current.get(jt)??[];if(cn.length===0)return;const Mt=cn[0];if(X.current){Un(Mt),Ra(Et,St,cn);return}Ra(Et,St,cn)}}),Re.on("doubleClick",Ve=>{const bt=Ve.item;if(bt==null||X.current)return;const Ze=String(bt);if(Ze.startsWith("pr:")){const Et=Number.parseInt(Ze.slice(3),10),St=v.current.get(Et);St&&ln.getState().openPrFocusTab(Fn(St));return}if(Ze.startsWith("ev:")||Ze.startsWith("cl:")){const St=(Ze.startsWith("ev:")?[Number.parseInt(Ze.slice(3),10)]:l.current.get(Ze)??[])[0]??null;if(St==null)return;const ct=o.current.get(St);if((ct==null?void 0:ct.prId)==null)return;const jt=v.current.get(ct.prId);jt&&ln.getState().openPrFocusTab(Fn(jt))}});let Oe=null,tt=null;Re.on("rangechanged",()=>{const Ve=Re.getWindow(),bt=Ve.end.valueOf()-Ve.start.valueOf(),Ze=z.current;if(Ze==null||Math.abs(bt-Ze)/Ze>.02){Oe&&clearTimeout(Oe);const sn=()=>{if(Ar.current){Oe=setTimeout(sn,120);return}Oe=null;const pn=Cn();zt(),Re.redraw(),pn&&Ni(pn)};Oe=setTimeout(sn,120)}const St=q.current;if(St==null||X.current||w.current)return;const ct=Re.getWindow(),jt=ct.end.valueOf()-ct.start.valueOf();Math.abs(jt-St)/St<=.02||(tt&&clearTimeout(tt),tt=setTimeout(()=>mt(sn=>sn+1),160))}),Re.on("changed",nt);const ze=tn();return ze==null||ze.addEventListener("scroll",nt,{passive:!0}),Re.on("changed",Er),ze==null||ze.addEventListener("scroll",Er,{passive:!0}),window.addEventListener("resize",Er,{passive:!0}),Er(),r.current=Re,()=>{ns.current+=1,Ar.current=!1,Oe&&clearTimeout(Oe),tt&&clearTimeout(tt),ze==null||ze.removeEventListener("scroll",nt),ze==null||ze.removeEventListener("scroll",Er),window.removeEventListener("resize",Er),H.current!=null&&(cancelAnimationFrame(H.current),H.current=null),j.current!=null&&(cancelAnimationFrame(j.current),j.current=null),Re.destroy(),r.current=null}},[gi,zt,Ra,vr,rs,Un,Fn,Cn,Ni,nt,Er,tn]),L.useEffect(()=>{const K=n.current;if(!K)return;const fe=xe=>{var Ve;const Ne=xe.target,Re=(Ve=Ne==null?void 0:Ne.closest)==null?void 0:Ve.call(Ne,"[data-collapse-gid]");if(!Re)return;const Oe=Re.getAttribute("data-collapse-gid");if(!Oe||(xe.stopPropagation(),xe.preventDefault(),X.current||w.current))return;const tt=!O.current.has(Oe);Nt(Oe,tt),Re.textContent=tt?"▸":"▾";const ze=tt?"Expand row":"Collapse row";Re.setAttribute("title",ze),Re.setAttribute("aria-label",ze)};return K.addEventListener("click",fe,!0),()=>K.removeEventListener("click",fe,!0)},[Nt]),L.useEffect(()=>{const K=n.current;if(!K)return;const fe=xe=>{var ze;const Ne=xe.target,Re=(ze=Ne==null?void 0:Ne.closest)==null?void 0:ze.call(Ne,"[data-stats-gid]");if(!Re)return;const Oe=Re.getAttribute("data-stats-gid");if(!Oe)return;xe.stopPropagation(),xe.preventDefault();const tt=Number(Oe.split(":user:")[1]);Number.isFinite(tt)&&(Me(null),me(Ve=>Ve&&Ve.gid===Oe?null:{gid:Oe,uid:tt,x:xe.clientX,y:xe.clientY}))};return K.addEventListener("click",fe,!0),()=>K.removeEventListener("click",fe,!0)},[]),L.useEffect(()=>{const K=n.current;if(!K)return;const fe=xe=>{const Ne=xe.target;!Ne||!Ne.isConnected||Ne.closest(".vis-timeline")||vr()};return K.addEventListener("click",fe),()=>K.removeEventListener("click",fe)},[vr]);const pl=L.useCallback((K,fe)=>{W.current!=null&&(cancelAnimationFrame(W.current),W.current=null);const xe=Ve=>{const bt=r.current;if(!bt||Ve<=0)return;const Ze=bt.getWindow();qSe(K,(Ze.end.valueOf()-Ze.start.valueOf())/Ve),a.current.update(K),G.current=Ve,fe==null||fe()},Ne=gO(r.current,n.current);if(Ne>0&&Math.abs(Ne-G.current)<1){xe(Ne);return}let Re=-1,Oe=0,tt=0;const ze=()=>{const Ve=gO(r.current,n.current);if(Ve>0&&Ve===Re?Oe+=1:(Oe=0,Re=Ve),Ve>0&&Oe>=2||tt++>40){W.current=null,xe(Ve);return}W.current=requestAnimationFrame(ze)};W.current=requestAnimationFrame(ze)},[]);L.useEffect(()=>()=>{W.current!=null&&cancelAnimationFrame(W.current)},[]),L.useEffect(()=>{let K=null;const fe=()=>{K&&clearTimeout(K),K=setTimeout(()=>mt(xe=>xe+1),200)};return window.addEventListener("resize",fe),()=>{window.removeEventListener("resize",fe),K&&clearTimeout(K)}},[]);const as=L.useRef(!1);L.useEffect(()=>{const K=()=>{!document.hidden&&as.current&&(as.current=!1,mt(fe=>fe+1))};return document.addEventListener("visibilitychange",K),()=>document.removeEventListener("visibilitychange",K)},[]),L.useEffect(()=>{var At;if(!Ae)return;if(h.current=Ae,document.hidden){as.current=!0;return}as.current=!1;const K=J.current,fe=K&&!Ae.prs.some(De=>De.id===K.id)?[...Ae.prs,K]:Ae.prs,xe=_r&&_r.length>0?new Set(_r):null,Ne=De=>!xe||De.authorId!=null&&xe.has(De.authorId),Re=kt.length>0,Oe=new Set;if(Re){const De=new Set(kt);for(const Bt of Ae.events)Bt.type==="review_comment"&&Bt.prId!=null&&Bt.derivedState!=null&&De.has(Bt.derivedState)&&Oe.add(Bt.prId)}const tt=De=>!Re||Oe.has(De.id),ze=fe.filter(De=>De.id===_e.current||De.id===(K==null?void 0:K.id)||Ne(De)&&tt(De));_.current={active:Re,states:kt};const Ve=new Map;for(const De of Ae.events)Ve.set(De.id,De);o.current=Ve;const bt=new Set;for(const De of Ae.events)De.prId!=null&&(De.type==="review_comment"||De.type==="pr_comment")&&bt.add(De.prId);const Ze=(At=r.current)==null?void 0:At.getWindow();q.current=Ze?Ze.end.valueOf()-Ze.start.valueOf():null;const Et=jSe(fe);y.current=Et;const St=Mke(Ae.events,fe);Xe.current=St;let ct=Ae.events;if(!X.current&&Re){const De=new Set(kt);ct=Ae.events.filter(Bt=>Bt.type==="review_comment"&&Bt.prId!=null&&Bt.derivedState!=null&&De.has(Bt.derivedState))}const jt=mO([...ze.map(De=>De.repoId),...ct.map(De=>De.repoId)]).sort((De,Bt)=>{const Nn=Ir.get(De),xi=Ir.get(Bt);return!Nn||!xi?(Nn?0:1)-(xi?0:1)||De-Bt:Nn.owner.localeCompare(xi.owner)||Nn.name.localeCompare(xi.name)||De-Bt}),sn=[],pn=0,bn=1e6;jt.forEach((De,Bt)=>{const Nn=mO([...ct.filter(wr=>wr.repoId===De&&wr.actorId!=null).map(wr=>wr.actorId),...ze.filter(wr=>wr.repoId===De&&wr.authorId!=null).map(wr=>wr.authorId)]),xi=Fr.get(De),Oa=Nn.map(wr=>`repo:${De}:user:${wr}`),Da=`tl-repo-tint-${Bt%GSe}`,qs=Ir.get(De),Cu=(qs==null?void 0:qs.fullName)??`repo ${De}`,ml=qs!=null&&qs.inboxWatch?`${Xr(Cu)}${gj()}`:Xr(Cu);sn.push({id:`repo:${De}`,content:ml,nestedGroups:Oa.length?Oa:void 0,treeLevel:1,order:Bt,subgroupOrder:"sortKey",className:`tl-repo-header ${Da}`}),Nn.forEach((wr,uh)=>{const Pa=`repo:${De}:user:${wr}`,Ks=(xi==null?void 0:xi.has(wr))??!1;sn.push({id:Pa,content:KSe($ke(Ln.get(wr),wr,St.get(wr),Ks,Pa,O.current.has(Pa))),treeLevel:2,order:(Ks?pn:bn)+uh,subgroupOrder:"sortKey",heightMode:O.current.has(Pa)?"auto":"fixed",className:`tl-user-row ${Wd(Pa)} ${Da}`})})});const cn=X.current?de.current:null,Mt=ze.map(De=>{const Bt=De.authorId!=null?Ln.get(De.authorId):void 0,Nn=sc(De),xi=Et.get(De.id)??0,Oa={author:{label:Lr(Bt,De.authorId),avatarUrl:(Bt==null?void 0:Bt.avatarUrl)??null},hasComments:bt.has(De.id)};return{id:`pr:${De.id}`,group:Nn,subgroup:`bar:${xi}`,sortKey:xi*2,type:"range",start:De.openedAt,end:De.mergedAt??De.closedAt??new Date().toISOString(),content:Rke(De,Oa),className:(()=>{const Da=Dke(De,Oa.hasComments);return cn!=null&&De.id!==cn?`${Da} pr-focus-hidden`:Da})(),title:Oke(De,Oa)}}),ht=r.current,yr=ht==null?void 0:ht.getWindow(),wn=K?null:Cn(),un=Ar.current,ua=new Set(sn.map(De=>String(De.id)));s.current.update(sn);const bi=s.current.getIds().map(String).filter(De=>!ua.has(De));bi.length&&s.current.remove(bi);const Yi=new Set(Mt.map(De=>String(De.id))),Wr=a.current.getIds().map(String).filter(De=>De.startsWith("pr:")&&!Yi.has(De));if(a.current.update(Mt),Wr.length&&a.current.remove(Wr),pl(Mt,()=>{wn&&!Ar.current&&!un&&Ni(wn)}),zt(),ht&&yr){const De=ht.getWindow();(De.start.valueOf()!==yr.start.valueOf()||De.end.valueOf()!==yr.end.valueOf())&&ht.setWindow(yr.start,yr.end,{animation:!1})}const qe=_e.current;if(qe!=null&&ht&&a.current.get(`pr:${qe}`)&&!ht.getSelection().map(String).includes(`pr:${qe}`)&&ht.setSelection([`pr:${qe}`]),S.current!=null){const De=S.current;S.current=null,Yr(De)}if(w.current&&Zt(w.current),X.current&&de.current!=null&&yn(de.current),!w.current&&!X.current&&O.current.size>0)for(const De of O.current)Nt(De,!0);const it=J.current;(!it||Ae.prs.some(De=>De.id===it.id)||_e.current!==it.id&&de.current!==it.id)&&(J.current=null),wn&&!Ar.current&&Ni(wn)},[Ae,kt,Ht,_r,Ir,Ln,Fr,Ge,$t,zt,Yr,Zt,yn,Nt,Cn,Ni,pl]),L.useEffect(()=>{_e.current=ii;const K=r.current;if(!K)return;if(ii!=null&&!a.current.get(`pr:${ii}`)){Tt(Re=>Re+1);return}const fe=ii!=null?[`pr:${ii}`]:[],xe=K.getSelection().map(String);xe.length===fe.length&&fe.every(Re=>xe.includes(Re))||K.setSelection(fe)},[ii]);const En=L.useRef(!1);L.useEffect(()=>{if(t==null||En.current||!r.current||!h.current)return;$e.getState().selectedPrId!==t&&$e.getState().selectPr(t);const fe=v.current.get(t)??(Ae==null?void 0:Ae.prs.find(tt=>tt.id===t))??(Ht==null?void 0:Ht.prs.find(tt=>tt.id===t))??(Vt==null?void 0:Vt.prs.find(tt=>tt.id===t));if(!fe)return;En.current=!0,ai(t,{fitWindow:!0,pr:fe});const xe=Wd(sc(fe)),Ne=$e.getState(),Oe=Ne.timelineFocusPr===t&&Ne.timelineFocusEvent!=null?null:window.setTimeout(()=>Hi(xe,!1),320);return()=>{Oe!=null&&window.clearTimeout(Oe)}},[t,Ae,Ht,Vt,ai,Hi]),L.useEffect(()=>{const K=r.current;if(!K||t!=null)return;const{from:fe,to:xe}=nv($e.getState()),{start:Ne,end:Re}=vO(fe,xe);K.setWindow(Ne,Re,{animation:!1})},[dr,Ci,Nr,vi,t]);const zi=$e(K=>K.timelineCenterAt);L.useEffect(()=>{if(zi==null)return;const K=r.current;if(!K)return;const fe=K.getWindow(),xe=fe.end.valueOf()-fe.start.valueOf();K.setWindow(zi-xe/2,zi+xe/2,{animation:!0}),$e.getState().consumeTimelineCenter()},[zi]);const je=$e(K=>K.timelineFocusPr),ut=$e(K=>K.timelineFocusAt);return L.useEffect(()=>{if(je==null)return;const K=r.current;if(!K)return;const fe=Ae==null?void 0:Ae.prs.find(Oe=>Oe.id===je);if(fe){const Oe=$e.getState().timelineFocusEvent;if(Oe&&Ae){const Ze=Ae.events.filter(jt=>jt.prId===je&&jt.type===Oe.type&&(Oe.refId==null||jt.refId===Oe.refId)),Et=ut!=null&&Ze.find(jt=>jt.occurredAt===ut)||Ze[0],St=(Et==null?void 0:Et.actorId)??fe.authorId,ct=Et!=null&&(a.current.get(`ev:${Et.id}`)!=null||c.current.get(Et.id)!=null);if(ut){const jt=Date.parse(ut),sn=K.getWindow(),pn=sn.end.valueOf()-sn.start.valueOf();K.setWindow(jt-pn/2,jt+pn/2,{animation:!0})}if(K.setSelection([`pr:${je}`]),Et!=null&&Un(Et.id),St!=null){const jt=Wd(`repo:${fe.repoId}:user:${St}`);window.setTimeout(()=>Hi(jt,ct),120)}$e.getState().consumeTimelineFocus();return}const tt=K.getWindow(),ze=tt.end.valueOf()-tt.start.valueOf();let Ve;if(ut)Ve=Date.parse(ut);else{const Ze=new Date(fe.openedAt).getTime(),Et=new Date(fe.mergedAt??fe.closedAt??new Date().toISOString()).getTime();Ve=(Ze+Et)/2}K.setWindow(Ve-ze/2,Ve+ze/2,{animation:!0}),K.setSelection([`pr:${je}`]);const bt=Wd(sc(fe));window.setTimeout(()=>{Hi(bt,!1,".ev-cross-linked",".pr-bar.vis-selected")},120),$e.getState().consumeTimelineFocus();return}const xe=Oe=>{J.current=Oe,Tt(ze=>ze+1);const tt=Wd(sc(Oe));P.current!=null&&window.clearTimeout(P.current),P.current=window.setTimeout(()=>{P.current=null,K.setSelection([`pr:${Oe.id}`]),Hi(tt,!1,".ev-cross-linked",".pr-bar.vis-selected")},360),$e.getState().consumeTimelineFocus()},Ne=Ae&&!Ae.prs.some(Oe=>Oe.id===je)?_t==null?void 0:_t.prs.find(Oe=>Oe.id===je):void 0;if(Ne){xe(Ne);return}const Re=(Ht==null?void 0:Ht.prs.find(Oe=>Oe.id===je))??(Vt==null?void 0:Vt.prs.find(Oe=>Oe.id===je));if(Re){const{from:Oe}=nv($e.getState()),tt=new Date(Re.openedAt).getTime();if(tt<Oe.getTime()){const ze=new Date(tt-864e5).toISOString().slice(0,10),Ve=new Date().toISOString().slice(0,10);$e.getState().setCustomRange(ze,Ve);return}if(Ae&&!Ae.prs.some(ze=>ze.id===Re.id)){xe(Re);return}}$e.getState().consumeTimelineFocus()},[je,ut,Ae,Ht,_t,Vt,Hi,Un]),m.jsxs("div",{className:`relative h-full w-full${we?" tl-focus-active":""}`,children:[yt&&!Ae&&m.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-gray-500",children:"Loading timeline…"}),ft&&m.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-red-500",children:String(ft)}),Ae&&Ae.prs.length===0&&Ae.events.length===0&&m.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."}),m.jsx("div",{ref:n,className:"h-full w-full"}),m.jsx("svg",{ref:ue,className:"tl-cross-connectors","aria-hidden":"true",style:{display:"none"}}),m.jsx("div",{ref:oe,className:"tl-repo-sticky","aria-hidden":"true",style:{display:"none"}}),Q&&m.jsx(HSe,{state:Q,eventsById:o.current,usersById:Ln,prsById:ws,focusPrId:we?de.current:null,onContextFocus:yi,onDismiss:rs,onNavigate:is}),Ie&&m.jsx(ySe,{gid:Ie.gid,uid:Ie.uid,user:Ln.get(Ie.uid),stats:Xe.current.get(Ie.uid)??{comments:0,reviews:0,prsOpen:0,prsMerged:0,prsClosed:0},x:Ie.x,y:Ie.y,onDismiss:()=>me(null)})]})}function tCe(e,t){const n=new URLSearchParams;return e&&e.length>0&&n.set("repoIds",e.join(",")),t&&t.length>0&&n.set("userIds",t.join(",")),n.toString()}function nCe(e,t){const n=tCe(e,t);return ar({queryKey:["activity",n],queryFn:()=>Lt.inbox(n),staleTime:1/0,refetchOnMount:!1,placeholderData:r=>r})}const gv=Mw;function rCe(e){return gv.reduce((t,n)=>t+e[n],0)}function AT({counts:e,compact:t=!1,activeState:n=null,onSegmentClick:r,className:a=""}){const s=rCe(e);return t?m.jsx("span",{className:`inline-flex h-1.5 w-16 overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700 ${a}`,"aria-hidden":"true",children:s>0&&gv.map(o=>e[o]>0?m.jsx("span",{style:{width:`${e[o]/s*100}%`,background:Jr[o].color}},o):null)}):m.jsxs("div",{className:a,children:[m.jsx("div",{className:"flex h-2.5 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",children:s===0?null:gv.map(o=>{if(e[o]===0)return null;const l=Jr[o],c=m.jsx("span",{title:`${l.label}: ${e[o]}`,style:{width:`${e[o]/s*100}%`,background:l.color,opacity:n==null||n===o?1:.35},className:"block h-full"},o);return r?m.jsx("button",{type:"button",onClick:()=>r(o),title:`${l.label}: ${e[o]} — click to filter`,style:{width:`${e[o]/s*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):c})}),m.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-0.5",children:[gv.map(o=>{const l=Jr[o],c=n===o,d=n!=null&&!c,h=m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{background:l.color}}),m.jsx("span",{className:"tabular-nums",children:e[o]}),m.jsx("span",{children:l.label.toLowerCase()})]}),p=`flex items-center gap-1 text-[10px] ${d?"text-gray-400 opacity-60":"text-gray-600 dark:text-gray-300"}`;return r?m.jsx("button",{type:"button",onClick:()=>r(o),className:`${p} hover:underline`,"aria-pressed":c,title:l.description,children:h},o):m.jsx("span",{className:p,title:l.description,children:h},o)}),m.jsx("span",{className:"ml-auto text-[10px] tabular-nums text-gray-400",children:s})]})]})}function iCe(e){return e&&e.length>0?`repoIds=${e.join(",")}`:""}function aCe(e,t){const n=iCe(e);return ar({queryKey:["repo-digests",n],queryFn:()=>Lt.repoDigests(n),enabled:t,staleTime:1/0})}function sCe(e,t){return ar({queryKey:["repo-digest",e],queryFn:()=>Lt.repoDigest(e),enabled:t&&e!=null,staleTime:1/0})}function YF(){const e=lr();return ti({mutationFn:t=>{const n=t==null?void 0:Array.isArray(t)?t.length>0?`repoIds=${t.join(",")}`:void 0:`repoIds=${t}`;return Lt.refreshRepoDigests(n)},onSuccess:(t,n)=>{typeof n=="number"?e.invalidateQueries({queryKey:["repo-digest",n]}):e.invalidateQueries({queryKey:["repo-digest"]}),e.invalidateQueries({queryKey:["repo-digests"]})}})}function WF(){const e=ln(t=>t.openPrDetailTab);return t=>{t.prId!=null&&e({id:t.prId,number:t.prNumber,title:t.title??`#${t.prNumber}`,repoFullName:t.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null},{fromActivity:!0})}}const GF="pierre:collapsedDigests";function oCe(){try{const e=localStorage.getItem(GF),t=e?JSON.parse(e):[];return new Set(Array.isArray(t)?t.filter(n=>typeof n=="number"):[])}catch{return new Set}}function lCe(e){try{localStorage.setItem(GF,JSON.stringify([...e]))}catch{}}const ly=Lw((e,t)=>({collapsed:oCe(),toggle:n=>{const r=new Set(t().collapsed);r.has(n)?r.delete(n):r.add(n),lCe(r),e({collapsed:r})}}));function uCe(e,t,n){const r=[],a=/#(\d+)/g;let s=0,o=0,l;for(;(l=a.exec(e))!=null;){l.index>s&&r.push(e.slice(s,l.index));const c=Number(l[1]),d=t.get(c);d!=null?(r.push(m.jsxs("button",{type:"button",onClick:()=>n(d),className:"font-medium text-sky-600 hover:underline dark:text-sky-400",title:d.title??`Open PR #${c}`,children:["#",c]},`r${o++}`)),d.title!=null&&d.title.trim()!==""&&r.push(m.jsxs("span",{className:"text-gray-700 dark:text-gray-200",children:[" ",d.title]},`t${o++}`)),d.authorLogin!=null&&d.authorLogin.trim()!==""&&r.push(m.jsxs("span",{className:"text-gray-400",children:[" · by ",d.authorLogin]},`a${o++}`))):r.push(`#${c}`),s=l.index+l[0].length}return s<e.length&&r.push(e.slice(s)),r}function cCe({markdown:e,prRefs:t,onOpenPr:n}){const r=new Map;for(const l of t)l.prId!=null&&r.set(l.prNumber,l);const a=l=>{const c=new Set;for(const d of l.matchAll(/#(\d+)/g)){const h=Number(d[1]);r.has(h)&&c.add(h)}return c.size},s=l=>{const c=a(l);return c===0?0:c>=2?1:2},o=e.split(`
1377
+ `).map(l=>l.trim()).filter(l=>l!=="").map(l=>l.replace(/^[-*]\s+/,"")).map((l,c)=>({line:l,i:c})).sort((l,c)=>s(l.line)-s(c.line)||l.i-c.i).map(l=>l.line);return o.length===0?m.jsx(m.Fragment,{}):m.jsx("ul",{className:"space-y-1",children:o.map((l,c)=>m.jsxs("li",{className:"flex gap-1.5 text-[13px] leading-relaxed text-gray-700 dark:text-gray-200",children:[m.jsx("span",{"aria-hidden":"true",className:"select-none text-gray-400",children:"•"}),m.jsx("span",{className:"min-w-0",children:uCe(l,r,n)})]},c))})}function dCe(e){if(!e)return"Haiku";const t=e.toLowerCase();return t.includes("haiku")?"Haiku":t.includes("sonnet")?"Sonnet":t.includes("opus")?"Opus":e}function VF({digest:e,isLoading:t,title:n,collapsed:r,onToggle:a,onRegenerate:s,regenerating:o=!1,onOpenPr:l}){return m.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:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsxs("button",{type:"button",onClick:a,"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:[m.jsx("span",{"aria-hidden":"true",className:"text-[9px]",children:r?"▸":"▾"}),m.jsx("span",{"aria-hidden":"true",children:"✨"}),m.jsx("span",{className:"truncate normal-case",children:n})]}),m.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"}),m.jsxs("span",{className:"ml-auto flex items-center gap-2 text-[10px] text-gray-400",children:[e!=null&&m.jsxs("span",{title:e.model,children:[dCe(e.model)," · ",ra(e.generatedAt),e.stale?" · stale":""]}),s!=null&&m.jsxs("button",{type:"button",onClick:s,disabled:o,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:"Regenerate this repo's digest (runs the cheap-tier model)",children:[m.jsx("span",{"aria-hidden":"true",children:"↻"}),o?"Regenerating…":"Regenerate"]})]})]}),!r&&m.jsx("div",{className:`mt-1 ${o?"opacity-50 transition-opacity":""}`,children:t?m.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()!==""?m.jsx("div",{className:"digest-fade-in",children:m.jsx(cCe,{markdown:e.summary,prRefs:e.prRefs,onOpenPr:l})},e.generatedAt):m.jsx("p",{className:"text-xs text-gray-400",children:"No digest yet — click Regenerate to summarise this repo's recent activity."})})]})}function fCe({repoId:e}){const{activityDigest:t}=zw(),{data:n,isLoading:r}=sCe(e,t),a=YF(),s=WF(),o=ly(d=>d.collapsed.has(e)),l=ly(d=>d.toggle),c=a.isPending&&a.variables===e;return t?m.jsxs("div",{className:"space-y-1.5",children:[m.jsx(VF,{digest:n,isLoading:r,title:"Digest",collapsed:o,onToggle:()=>l(e),onRegenerate:()=>a.mutate(e),regenerating:c,onOpenPr:s}),m.jsx(bk,{active:c})]}):null}function hCe({stats:e}){return m.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-gray-500 dark:text-gray-400",children:[m.jsxs("span",{children:[m.jsx("span",{className:"font-semibold text-gray-700 dark:text-gray-200 tabular-nums",children:e.openPrs})," ","open"]}),m.jsxs("span",{children:[m.jsx("span",{className:"tabular-nums",children:e.draftPrs})," draft"]}),e.stalledPrs>0&&m.jsxs("span",{className:"text-amber-500",children:[m.jsx("span",{className:"tabular-nums",children:e.stalledPrs})," stalled ⏱"]}),e.medianHoursToFirstReview!=null&&m.jsxs("span",{title:"Median hours to first review",children:["TTFR"," ",m.jsx("span",{className:"tabular-nums",children:e.medianHoursToFirstReview<1?`${Math.round(e.medianHoursToFirstReview*60)}m`:`${Math.round(e.medianHoursToFirstReview)}h`})]}),e.oldestUnreviewed!=null&&m.jsxs("a",{href:e.oldestUnreviewed.githubUrl,target:"_blank",rel:"noreferrer noopener",className:"hover:underline",title:e.oldestUnreviewed.title,children:["oldest unreviewed #",e.oldestUnreviewed.number," ·"," ",ra(e.oldestUnreviewed.openedAt)]})]})}function pCe({repo:e}){const t=e.maintainerIds.length;return m.jsxs("div",{className:"space-y-2 rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:"min-w-0 truncate text-base font-semibold text-gray-800 dark:text-gray-100",children:e.repoFullName}),t>0&&m.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:[m.jsx(gk,{}),t]}),e.attentionCount>0&&m.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]}),m.jsx("span",{className:"ml-auto shrink-0 text-[11px] tabular-nums text-gray-400",children:e.stats.openPrs>0?`[${e.stats.openPrs}]`:"[—]"})]}),m.jsx(hCe,{stats:e.stats}),m.jsx(AT,{counts:e.threadTotals}),m.jsx(fCe,{repoId:e.repoId})]})}function Jm(){const e=L.useRef(null),[t,n]=L.useState(0);return L.useEffect(()=>{const r=e.current;if(!r)return;const a=new ResizeObserver(s=>{var l;const o=(l=s[0])==null?void 0:l.contentRect.width;o!=null&&n(o)});return a.observe(r),n(r.clientWidth),()=>a.disconnect()},[]),[e,t]}const Tn={blue:"#3b82f6",green:"#22c55e",gray:"#9ca3af",orange:"#f97316",amber:"#f59e0b",purple:"#8957e5",teal:"#14b8a6",pink:"#ec4899",slate:"#64748b"},bO=[Tn.blue,Tn.green,Tn.amber,Tn.purple,Tn.teal,Tn.pink,Tn.slate];function vp(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 Cc(e){return new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function jc(e){return Math.abs(e)>=1e3?`${(e/1e3).toFixed(e%1e3===0?0:1)}k`:`${Math.round(e)}`}function RT(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 ab({series:e}){return m.jsx("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-0.5",children:e.map(t=>m.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-500 dark:text-gray-400",children:[m.jsx("span",{className:"inline-block h-2 w-2 rounded-[2px]",style:{background:t.color}}),t.label]},t.label))})}function eg({x:e,y:t,width:n,children:r}){const a=Math.max(58,Math.min(e,Math.max(58,n-58)));return m.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:a,top:Math.max(t-6,0)},children:r})}function fs({title:e,note:t,children:n}){return m.jsxs("div",{className:"rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[m.jsxs("div",{className:"mb-1 flex items-baseline justify-between gap-2",children:[m.jsx("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-200",children:e}),t&&m.jsx("span",{className:"text-[10px] text-gray-400",children:t})]}),n]})}function za({label:e="No data in this window"}){return m.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 Tw({labels:e,series:t,area:n=!1,curved:r=!1,formatY:a=jc,height:s=132}){const[o,l]=Jm(),[c,d]=L.useState(null),h=30,p=8,v=8,y=16,_=e.length,S=Math.max(l-h-p,1),w=s-v-y,C=RT(Math.max(1,...t.flatMap(W=>W.values.map(G=>G??0)))),O=W=>h+(_<=1?S/2:W/(_-1)*S),A=W=>v+w*(1-W/C),R=v+w,F=W=>W.values.map((G,X)=>G==null?null:`${O(X)},${A(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,M=W=>{const G=W.values.map((X,de)=>X==null?null:[O(de),A(X)]).filter(X=>X!=null);return G.length<2?"":`M ${G[0][0]} ${R} `+G.map(([X,de])=>`L ${X} ${de}`).join(" ")+` L ${G[G.length-1][0]} ${R} Z`},Y=W=>{let G="";for(let X=0;X<W.length-1;X++){const de=W[X-1]??W[X],ue=W[X],H=W[X+1],oe=W[X+2]??H,j=ue[0]+(H[0]-de[0])/6,te=ue[1]+(H[1]-de[1])/6,ve=H[0]-(oe[0]-ue[0])/6,Q=H[1]-(oe[1]-ue[1])/6;G+=` C ${j} ${te} ${ve} ${Q} ${H[0]} ${H[1]}`}return G},B=W=>{const G=[];let X=[];return W.values.forEach((de,ue)=>{de==null?(X.length&&G.push(X),X=[]):X.push([O(ue),A(de)])}),X.length&&G.push(X),G.map(de=>{const ue=`M ${de[0][0]} ${de[0][1]}`;return de.length<2?ue:ue+Y(de)}).join(" ")},J=W=>{const G=W.values.map((ue,H)=>ue==null?null:[O(H),A(ue)]).filter(ue=>ue!=null);if(G.length<2)return"";const X=G[0],de=G[G.length-1];return`M ${X[0]} ${R} L ${X[0]} ${X[1]}`+Y(G)+` L ${de[0]} ${R} Z`},P=r?B:F,q=r?J:M,z=W=>{const G=W.nativeEvent.offsetX,X=_<=1?0:Math.round((G-h)/S*(_-1));d(Math.max(0,Math.min(_-1,X)))};return m.jsxs("div",{children:[m.jsxs("div",{ref:o,className:"relative",style:{height:s},children:[l>0&&m.jsxs("svg",{width:l,height:s,className:"block",children:[[0,C].map(W=>m.jsxs("g",{children:[m.jsx("line",{x1:h,y1:A(W),x2:l-p,y2:A(W),className:"text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),m.jsx("text",{x:h-4,y:A(W)+3,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:a(W)})]},W)),n&&t[0]&&q(t[0])&&m.jsx("path",{d:q(t[0]),fill:t[0].color,opacity:.12}),c!=null&&m.jsx("line",{x1:O(c),y1:v,x2:O(c),y2:R,className:"text-gray-300 dark:text-gray-600",stroke:"currentColor",strokeWidth:1}),t.map(W=>m.jsx("path",{d:P(W),fill:"none",stroke:W.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"},W.key)),t.map(W=>W.values.map((G,X)=>G==null?null:m.jsx("circle",{cx:O(X),cy:A(G),r:c===X?3:1.8,fill:W.color},`${W.key}-${X}`))),m.jsx("text",{x:h,y:s-4,className:"fill-gray-400 text-[8px]",children:e[0]?Cc(e[0]):""}),m.jsx("text",{x:l-p,y:s-4,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:e[_-1]?Cc(e[_-1]):""}),m.jsx("rect",{x:0,y:0,width:l,height:s,fill:"transparent",onMouseMove:z,onMouseLeave:()=>d(null)})]}),c!=null&&l>0&&m.jsxs(eg,{x:O(c),y:v,width:l,children:[m.jsx("div",{className:"font-medium",children:e[c]?Cc(e[c]):""}),t.map(W=>m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-[1px]",style:{background:W.color}}),W.label,": ",W.values[c]==null?"—":a(W.values[c])]},W.key))]})]}),t.length>1&&m.jsx(ab,{series:t})]})}function mCe({repoId:e,onOpenCharts:t}){const{data:n,isLoading:r}=lD(e),a=(n==null?void 0:n.weekBuckets)??[],s=[{key:"opened",label:"Opened",color:Tn.blue,values:(n==null?void 0:n.throughput.opened)??[]},{key:"merged",label:"Merged",color:Tn.green,values:(n==null?void 0:n.throughput.merged)??[]}],o=s.some(l=>l.values.some(c=>c>0));return m.jsxs("div",{className:"rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[m.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[m.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:["PR merge rate",n?` · ${n.windowDays/7}-wk`:""]}),m.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?m.jsx("div",{className:"h-[132px] animate-pulse rounded bg-gray-50 dark:bg-gray-900/40"}):o?m.jsx(Tw,{labels:a,series:s,area:!0,curved:!0}):m.jsx(za,{})]})}function gCe({prs:e,repoFullName:t}){const{data:n}=Bc(),r=ln(s=>s.openPrDetailTab),a=L.useMemo(()=>vu(n),[n]);return e.length===0?null:m.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800",children:[m.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 · ",e.length]}),m.jsx("ul",{className:"divide-y divide-gray-100 dark:divide-gray-800/70",children:e.map(s=>{const o=jf[s.ciStatus],l=s.authorId!=null?a.get(s.authorId):void 0,c=cD[s.reasonTag],d=fy(s.mergeable,s.mergeStateStatus),h=s.isApproved?{label:"approved",color:"#22c55e"}:s.isChangesRequested?{label:"changes",color:"#ef4444"}:null;return m.jsx("li",{children:m.jsxs("button",{type:"button",onClick:()=>r({id:s.id,number:s.number,title:s.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:[m.jsx("span",{"aria-hidden":"true",title:(o==null?void 0:o.label)??"no checks",className:"inline-block h-2 w-2 shrink-0 rounded-full",style:o!=null?{background:o.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"}}),pj(s)&&m.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:"⚠"}),m.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[m.jsxs("span",{className:"text-gray-400",children:["#",s.number]})," ",m.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:s.title})]}),m.jsx(ka,{user:l,size:16}),m.jsx("span",{className:"max-w-[7rem] shrink-0 truncate text-gray-500 dark:text-gray-400",title:Lr(l,s.authorId),children:Lr(l,s.authorId)}),s.isDraft&&m.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"}),h!=null&&m.jsx("span",{className:"shrink-0 rounded px-1 text-[10px] font-semibold",style:{color:h.color,background:h.color+"1a"},children:h.label}),d!=null&&m.jsx("span",{className:"shrink-0 rounded bg-orange-500/15 px-1 text-[10px] font-medium text-orange-600 dark:text-orange-400",children:d}),m.jsx(AT,{counts:s.threadCounts,compact:!0}),c.myTurn?m.jsx("span",{className:"hidden shrink-0 rounded px-1 text-[10px] font-medium sm:inline",style:{color:c.color,background:c.color+"1a"},title:Lr(l,s.authorId),children:c.label}):m.jsx("span",{className:"hidden shrink-0 text-[10px] text-gray-400 sm:inline",children:ra(s.updatedAt)})]})},s.id)})})]})}const vCe=50;function yCe(e,t,n,r){const a=new URLSearchParams;return e&&e.length>0&&a.set("repoIds",e.join(",")),t&&t.length>0&&a.set("userIds",t.join(",")),n&&(a.set("excludeBots","true"),r.length>0&&a.set("allowBotIds",r.join(","))),a.toString()}function bCe(e){var s,o,l,c;const t=yCe(e.repoIds,e.userIds,e.excludeBots??!1,e.allowedBotIds??[]),n=F$({queryKey:["consolidated-feed",t],initialPageParam:0,queryFn:({pageParam:d})=>{const h=new URLSearchParams(t);return h.set("limit",String(vCe)),h.set("offset",String(d)),Lt.consolidatedFeed(h.toString())},getNextPageParam:(d,h)=>{var y;const p=h.reduce((_,S)=>_+S.items.length,0),v=((y=h[0])==null?void 0:y.total)??0;return p<v?p:void 0},enabled:e.enabled??!0,staleTime:1/0,refetchOnMount:!1,placeholderData:d=>d}),{items:r,users:a}=L.useMemo(()=>{var v;const d=((v=n.data)==null?void 0:v.pages)??[],h=d.flatMap(y=>y.items),p=new Map;for(const y of d)for(const _ of y.users)p.set(_.id,_);return{items:h,users:[...p.values()]}},[n.data]);return{items:r,users:a,total:((o=(s=n.data)==null?void 0:s.pages[0])==null?void 0:o.total)??0,generatedAt:((c=(l=n.data)==null?void 0:l.pages[0])==null?void 0:c.generatedAt)??null,hasMore:n.hasNextPage,loadMore:n.fetchNextPage,isFetchingMore:n.isFetchingNextPage,isLoading:n.isLoading,isFetching:n.isFetching}}function xCe(){const{activityDigest:e}=zw(),{data:t}=gu(),n=$e(v=>v.repoIds),r=WF(),a=YF(),s=ly(v=>v.collapsed),o=ly(v=>v.toggle),l=L.useMemo(()=>(t??[]).filter(v=>v.inboxWatch&&(n==null||n.includes(v.id))).map(v=>v.id),[t,n]),{data:c,isLoading:d}=aCe(l,e&&l.length>0);if(!e)return null;const h=(c==null?void 0:c.digests)??[],p=l.length>0;return m.jsxs("div",{className:"space-y-2",children:[m.jsxs("div",{className:"flex items-center gap-2 px-0.5",children:[m.jsxs("span",{className:"flex items-center gap-1 text-[11px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:[m.jsx("span",{"aria-hidden":"true",children:"✨"})," Digests · watched repos"]}),m.jsx("span",{className:"rounded bg-violet-500/15 px-1 text-[10px] font-semibold text-violet-600 dark:text-violet-300",children:"Pro"}),m.jsxs("button",{type:"button",onClick:()=>a.mutate(l),disabled:a.isPending||!p,className:"ml-auto flex items-center gap-0.5 rounded border border-violet-300 px-1.5 py-0.5 text-[10px] 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:"Regenerate the digests for all your watched repos (unchanged repos are free)",children:[m.jsx("span",{"aria-hidden":"true",children:"↻"}),a.isPending?"Regenerating…":"Regenerate"]})]}),m.jsx(bk,{active:a.isPending}),p?d?m.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"}):h.length===0?m.jsx("p",{className:"px-0.5 text-xs text-gray-400",children:"No digests yet — click Regenerate to summarise your watched repos."}):m.jsx("div",{className:"space-y-2",children:h.map(v=>m.jsx(VF,{digest:v,isLoading:!1,title:v.repoFullName,collapsed:s.has(v.repoId),onToggle:()=>o(v.repoId),regenerating:a.isPending,onOpenPr:r},v.repoId))}):m.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 digest here."})]})}function _Ce(e){if(e.kind==="claude_review")return{color:"#8957e5",label:"Claude Review"};if(e.kind==="review_submitted"&&e.reviewState!=null)return{color:ECe[e.reviewState].color,label:`Review: ${wCe[e.reviewState]}`};const t=uD[e.kind];return{color:(t==null?void 0:t.color)??"#6b7280",label:(t==null?void 0:t.label)??e.kind}}const ECe={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"}},wCe={approved:"Approved",changes_requested:"Request Changes",commented:"Comment",dismissed:"Dismissed",pending:"Pending"},kCe={APPROVE:{label:"approve",color:"#22c55e"},REQUEST_CHANGES:{label:"request changes",color:"#ef4444"},COMMENT:{label:"comment",color:"#9ca3af"}};function $1({repoId:e}){var ae,Ie;const t=$e(me=>me.repoIds),n=$e(me=>me.userIds),r=$e(me=>me.excludeBots),a=$e(me=>me.allowedBotIds),s=$e(me=>me.feedMyTurnOnly),o=$e(me=>me.toggleFeedMyTurnOnly),l=$e(me=>me.feedClaudeOnly),c=$e(me=>me.toggleFeedClaudeOnly),d=$e(me=>me.selectThread),h=$e(me=>me.selectPr),p=$e(me=>me.showPrComment),v=$e(me=>me.openClaudeReview),y=$e(me=>me.focusEventInTab),_=ln(me=>me.openPrDetailTab),S=ln(me=>me.openPrFocusTab),C=((ae=$f().data)==null?void 0:ae.claudeReviewEnabled)??!1,O=ln(me=>me.activityFlashItemId),A=ln(me=>me.clearActivityFlashItem),R=e!=null?[e]:t,{items:F,users:M,hasMore:Y,loadMore:B,isFetchingMore:J}=bCe({repoIds:R,userIds:n,excludeBots:r,allowedBotIds:a}),P=L.useMemo(()=>vu(M),[M]),q=(Ie=Bw().data)==null?void 0:Ie.prs,z=L.useMemo(()=>new Set((q??[]).map(me=>me.id)),[q]),[W,G]=L.useState(null),X=F.filter(me=>me.isMyTurn).length,de=F.filter(me=>me.kind==="claude_review").length,ue=s?F.filter(me=>me.isMyTurn):l?F.filter(me=>me.kind==="claude_review"):F,H=L.useRef(new Map),[oe,j]=L.useState(null);L.useEffect(()=>{if(O==null)return;const me=O,Xe=requestAnimationFrame(()=>{const we=H.current.get(me);we&&(we.scrollIntoView({block:"center",behavior:"smooth"}),j(me),window.setTimeout(()=>j(ke=>ke===me?null:ke),1800)),A()});return()=>cancelAnimationFrame(Xe)},[O,A]);const te=(me,Xe)=>({id:Xe,number:me.prNumber??0,title:me.prTitle??`#${me.prNumber??""}`,repoFullName:me.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null});function ve(me){const Xe=me.prId;Xe!=null&&(_(te(me,Xe),{fromActivity:!0,returnItemId:me.id}),me.kind==="claude_review"?v(Xe):me.threadId!=null?d(Xe,me.threadId):me.commentId!=null?p(Xe,me.commentId):h(Xe))}function Q(me,Xe){const we=me.prId;we!=null&&(_(te(me,we),{fromActivity:!0,returnItemId:me.id}),d(we,Xe))}function Me(me){const Xe=me.prId;if(Xe!=null){if(q!=null&&!z.has(Xe)){G(me);return}if(S(te(me,Xe),{fromActivity:!0,returnItemId:me.id}),me.kind!=="claude_review"){const we=me.threadId??me.commentId??null,ke=me.kind==="review_comment"?me.threadId:null;y(Xe,me.occurredAt,{type:me.kind,refId:we},ke)}}}return m.jsxs("div",{className:"space-y-3",children:[e==null&&m.jsx(xCe,{}),m.jsxs("div",{className:"flex items-center gap-2 px-0.5",children:[m.jsxs("button",{type:"button",onClick:o,"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:[m.jsx("span",{"aria-hidden":"true",children:"★"})," FYI",X>0&&m.jsx("span",{className:"tabular-nums opacity-70",children:X})]}),C&&m.jsxs("button",{type:"button",onClick:c,"aria-pressed":l,className:`flex items-center gap-1 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${l?"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:[m.jsx("span",{"aria-hidden":"true",children:"✨"})," Claude Reviews",de>0&&m.jsx("span",{className:"tabular-nums opacity-70",children:de})]}),F.length>0&&m.jsxs("span",{className:"text-[11px] text-gray-400",children:[ue.length," of ",F.length]})]}),F.length===0?m.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."}):ue.length===0?m.jsx("div",{className:"flex h-32 items-center justify-center text-sm text-gray-400",children:l?"No Claude Reviews in this window.":"Nothing needs your attention right now."}):m.jsx("ul",{className:"space-y-2",children:ue.map(me=>{const Xe=me.actorId!=null?P.get(me.actorId):void 0,we=me.mergedById!=null?P.get(me.mergedById):void 0,ke=we!=null||me.mergedById!=null?Lr(we,me.mergedById):null,Pe=(me.reviewers??[]).map(Ae=>Lr(P.get(Ae.userId),Ae.userId));return m.jsx(RCe,{item:me,actorUser:Xe,mergedByLabel:ke,reviewerLabels:Pe,usersById:P,flash:oe===me.id,innerRef:Ae=>{Ae?H.current.set(me.id,Ae):H.current.delete(me.id)},onOpen:()=>ve(me),onOpenThread:Ae=>Q(me,Ae),onFocus:()=>Me(me)},me.id)})}),Y&&F.length>0&&m.jsx("div",{className:"flex justify-center pt-1",children:m.jsx("button",{type:"button",onClick:()=>void B(),disabled:J,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 disabled:opacity-50 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500 dark:hover:bg-gray-800/50",children:J?"Loading…":"Load more"})}),W!=null&&m.jsx(TCe,{item:W,onClose:()=>G(null),onOpenDetails:()=>{const me=W;G(null),ve(me)}})]})}function TCe({item:e,onClose:t,onOpenDetails:n}){L.useEffect(()=>{const a=s=>{s.key==="Escape"&&(s.stopImmediatePropagation(),t())};return window.addEventListener("keydown",a,!0),()=>window.removeEventListener("keydown",a,!0)},[t]);const r=e.prNumber!=null?`#${e.prNumber}${e.prTitle!=null?` ${e.prTitle}`:""}`:"This PR";return m.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:t,role:"presentation",children:m.jsxs("div",{className:"flex w-[26rem] max-w-[92vw] flex-col rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-900",onClick:a=>a.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"PR not on the timeline",children:[m.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[m.jsx("h2",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:"Not on the timeline"}),m.jsx("button",{type:"button",onClick:t,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-200","aria-label":"Close (Esc)",title:"Close (Esc)",children:"✕"})]}),m.jsxs("div",{className:"space-y-3 px-4 py-3 text-sm leading-relaxed text-gray-600 dark:text-gray-300",children:[m.jsxs("p",{children:[m.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-100",children:r})," isn’t shown on the timeline with your current filters (date range, repositories, members), so it can’t be focused there."]}),m.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Widen the date range or clear the filters to bring it onto the board — or open its details directly."})]}),m.jsxs("div",{className:"flex justify-end gap-2 border-t border-gray-200 px-4 py-2 dark:border-gray-800",children:[m.jsx("button",{type:"button",onClick:t,className:"rounded border border-gray-300 px-3 py-1 text-sm hover:border-gray-400 dark:border-gray-700 dark:hover:border-gray-500",children:"Close"}),m.jsx("button",{type:"button",onClick:n,className:"rounded border border-blue-400 bg-blue-500/10 px-3 py-1 text-sm font-medium text-blue-600 hover:bg-blue-500/20 dark:border-blue-600 dark:text-blue-400",children:"Open PR details"})]})]})})}function SCe({item:e}){const{data:t,isLoading:n}=NM(e.threadId),{data:r}=Bc(),a=L.useMemo(()=>vu(r),[r]),s=L.useMemo(()=>{if(!t||e.actorId==null)return null;const l=new Date(e.occurredAt).getTime();let c=null;for(const d of t.comments){if(d.authorId!==e.actorId)continue;const h=Math.abs(new Date(d.createdAt).getTime()-l);(c==null||h<c.dist)&&(c={id:d.id,dist:h})}return(c==null?void 0:c.id)??null},[t,e.actorId,e.occurredAt]),o=e.prNumber!=null?`https://github.com/${e.repoFullName}/pull/${e.prNumber}`:"";return n?m.jsx("div",{className:"px-1 py-2 text-xs text-gray-400",children:"Loading conversation…"}):t?m.jsx(DM,{thread:t,usersById:a,prUrl:o,repoId:e.repoId,highlightCommentId:s}):m.jsx("div",{className:"px-1 py-2 text-xs text-gray-400",children:"Couldn’t load this conversation."})}function CCe({prId:e}){var a;const{data:t,isLoading:n}=vk(e);if(n)return m.jsx("div",{className:"mt-1 px-1 text-xs text-gray-400",children:"Loading summary…"});const r=(a=t==null?void 0:t.body)==null?void 0:a.trim();return r?m.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:m.jsx(So,{children:r})}):m.jsx("div",{className:"mt-1 px-1 text-xs text-gray-400",children:"No description."})}function NCe({item:e}){const[t,n]=L.useState(!1),r=e.ciStatus!=null&&e.ciStatus!=="unknown"?jf[e.ciStatus]:null,a=e.changedFilesCount,s=e.prId;return m.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[(r!=null||a!=null)&&m.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&&m.jsxs("span",{className:"inline-flex items-center gap-1 font-medium",style:{color:r.color},children:[m.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-2 rounded-full",style:{background:r.color}}),r.label]}),a!=null&&m.jsxs("span",{children:[a," ",a===1?"file":"files"," changed"]})]}),s!=null&&m.jsxs("div",{onClick:o=>o.stopPropagation(),children:[m.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&&m.jsx(CCe,{prId:s})]})]})}function ICe({thread:e,author:t,onOpen:n}){const r=Jr[e.derivedState],a=e.path.split("/").pop()??e.path;return m.jsx("li",{children:m.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:[m.jsxs("span",{className:"flex items-center gap-1.5 text-[11px]",children:[m.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-2 shrink-0 rounded-full",style:{background:r.color}}),m.jsxs("code",{className:"truncate font-mono text-gray-600 group-hover/th:text-sky-600 dark:text-gray-300",children:[a,e.line!=null?`:${e.line}`:""]}),m.jsx("span",{className:"shrink-0 text-gray-400",children:r.label.toLowerCase()})]}),e.excerpt.trim()!==""&&m.jsxs("span",{className:"mt-0.5 block truncate text-xs italic text-gray-500 dark:text-gray-400",children:[t!=null?`${Lr(t,e.authorId)}: `:"","“",e.excerpt,"”"]})]})})}const ACe=160;function RCe({item:e,actorUser:t,mergedByLabel:n,reviewerLabels:r,usersById:a,flash:s,innerRef:o,onOpen:l,onOpenThread:c,onFocus:d}){const h=_Ce(e),p=e.isMyTurn,v=e.kind==="claude_review",y=e.kind==="pr_merged",_=v?"Claude":e.actorId==null&&e.kind==="commit_pushed"?"A contributor":Lr(t,e.actorId),S=e.prNumber!=null?`#${e.prNumber}${e.prTitle!=null?` ${e.prTitle}`:""}`:"",w=e.claudeVerdict!=null?kCe[e.claudeVerdict]:null,C=e.affectedThreads??[],O=e.myTurnReasons[0],A=e.kind==="review_comment"&&e.threadId!=null,R=e.kind==="pr_comment"&&e.prId!=null,F=e.kind==="pr_opened",[M,Y]=L.useState(!1),B=y&&n!=null&&e.mergedById!==e.actorId,J=y&&r.length>0,P=L.useRef(null),q=L.useRef(null),[z,W]=L.useState(!1),[G,X]=L.useState(!1),de=e.content!=null&&e.content.trim()!=="";L.useEffect(()=>{const H=P.current,oe=q.current;if(!H||!oe)return;const j=()=>{z||X(H.scrollHeight>H.clientHeight+4)};j();const te=new ResizeObserver(j);return te.observe(oe),()=>te.disconnect()},[e.content,z]);const ue=H=>{H.target.closest("a,button")||l()};return m.jsx("li",{ref:o,children:m.jsxs("article",{onClick:ue,className:`cursor-pointer rounded-md border p-2.5 text-sm transition-colors ${s?"border-sky-400 ring-2 ring-sky-400/60 dark:border-sky-500":p?"border-yellow-400 bg-yellow-50/40 dark:border-yellow-500/50 dark:bg-yellow-950/15":v?"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:[m.jsxs("div",{className:"flex items-center gap-2",children:[e.prId!=null&&m.jsx("button",{type:"button",onClick:H=>{H.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:m.jsx(wy,{size:13})}),m.jsx("span",{className:"shrink-0 text-[11px] text-gray-400",title:qp(e.occurredAt),children:ra(e.occurredAt)}),m.jsx(ka,{user:t,size:20}),m.jsx("span",{className:"truncate font-medium text-gray-800 dark:text-gray-100",children:_}),m.jsx("span",{className:"inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-[11px] font-medium",style:{color:h.color,background:h.color+"1a"},children:h.label}),w!=null&&m.jsx("span",{className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",style:{color:w.color,background:w.color+"1a"},children:w.label}),p&&m.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"}),p&&O!=null&&m.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(H=>CC[H].title).join(" · "),children:CC[O].label})]}),m.jsxs("div",{className:"mt-1 flex items-baseline gap-1.5 text-xs",children:[m.jsx("span",{className:"shrink-0 text-gray-400",children:e.repoFullName}),S!==""&&m.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:S}),e.path!=null&&m.jsxs("span",{className:"shrink-0 text-gray-400",children:["· ",e.path.split("/").pop()]})]}),F&&m.jsx(NCe,{item:e}),de&&!A&&m.jsxs("div",{className:"mt-1.5 rounded bg-gray-50 px-2 py-1.5 text-sm dark:bg-gray-900/50",children:[m.jsx("div",{ref:P,className:z?"":"overflow-hidden",style:z?void 0:{maxHeight:ACe},children:m.jsx("div",{ref:q,children:m.jsx(So,{children:e.content})})}),(G||z)&&m.jsx("button",{type:"button",onClick:()=>W(H=>!H),className:"mt-1 text-[11px] font-medium text-sky-600 hover:underline dark:text-sky-400",children:z?"Show less":"Show more"})]}),C.length>0&&m.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[e.changeSummary!=null&&m.jsx("div",{className:"text-[11px] font-medium text-gray-500 dark:text-gray-400",children:e.changeSummary}),m.jsx("ul",{className:"space-y-1.5",children:C.map(H=>m.jsx(ICe,{thread:H,author:H.authorId!=null?a.get(H.authorId):void 0,onOpen:()=>c(H.threadId)},H.threadId))})]}),(B||J)&&m.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:[B&&m.jsxs("span",{children:["Merged by ",m.jsx("span",{className:"font-medium",children:n})]}),J&&m.jsxs("span",{children:["Reviewed by ",m.jsx("span",{className:"font-medium",children:r.join(", ")})]})]}),A&&m.jsx("div",{className:"mt-1.5",onClick:H=>H.stopPropagation(),children:m.jsx(SCe,{item:e})}),R&&e.prId!=null&&m.jsx("div",{className:"mt-1.5",children:M?m.jsx("div",{onClick:H=>H.stopPropagation(),children:m.jsx(yk,{prId:e.prId,initialBody:dD(e.content,(t==null?void 0:t.githubLogin)??null),autoFocus:!0,onCancel:()=>Y(!1),onDone:()=>Y(!1)})}):m.jsx("button",{type:"button",onClick:H=>{H.stopPropagation(),Y(!0)},className:"text-[11px] font-medium text-sky-600 hover:underline dark:text-sky-400",children:"Reply"})})]})})}function Gd({labels:e,series:t,mode:n="grouped",formatY:r=jc,formatValue:a=r,height:s=132}){const[o,l]=Jm(),[c,d]=L.useState(null),h=30,p=8,v=8,y=16,_=e.length,S=Math.max(l-h-p,1),w=s-v-y,C=/^\d{4}-\d{2}-\d{2}T/.test(e[0]??""),O=z=>t.reduce((W,G)=>W+(G.values[z]??0),0),A=RT(n==="stacked"?Math.max(1,...e.map((z,W)=>O(W))):Math.max(1,...t.flatMap(z=>z.values.map(W=>W??0)))),R=S/Math.max(_,1),F=z=>h+z*R+R*.15,M=R*.7,Y=z=>v+w*(1-z/A),B=v+w,J=z=>{const W=Math.floor((z.nativeEvent.offsetX-h)/R);d(Math.max(0,Math.min(_-1,W)))},P=z=>{const W=e[z]??"";return C?Cc(W):W},q=!C||_<=8;return m.jsxs("div",{children:[m.jsxs("div",{ref:o,className:"relative",style:{height:s},children:[l>0&&m.jsxs("svg",{width:l,height:s,className:"block",children:[[0,A].map(z=>m.jsxs("g",{children:[m.jsx("line",{x1:h,y1:Y(z),x2:l-p,y2:Y(z),className:"text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),m.jsx("text",{x:h-4,y:Y(z)+3,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:r(z)})]},z)),c!=null&&m.jsx("rect",{x:h+c*R,y:v,width:R,height:w,className:"text-gray-400/10 dark:text-gray-300/10",fill:"currentColor"}),e.map((z,W)=>{if(n==="stacked"){let X=0;return t.map(de=>{const ue=de.values[W]??0;if(ue<=0)return null;const H=Y(X+ue),oe=Y(X)-H;return X+=ue,m.jsx("rect",{x:F(W),y:H,width:M,height:Math.max(oe,0),fill:de.color},`${W}-${de.key}`)})}const G=M/Math.max(t.length,1);return t.map((X,de)=>{const ue=X.values[W]??0;return ue<=0?null:m.jsx("rect",{x:F(W)+de*G,y:Y(ue),width:Math.max(G-.5,.5),height:B-Y(ue),fill:X.color},`${W}-${X.key}`)})}),e.map((z,W)=>q||W===0||W===_-1?m.jsx("text",{x:h+W*R+R/2,y:s-4,textAnchor:"middle",className:"fill-gray-400 text-[8px]",children:P(W)},`lbl-${W}`):null),m.jsx("rect",{x:0,y:0,width:l,height:s,fill:"transparent",onMouseMove:J,onMouseLeave:()=>d(null)})]}),c!=null&&l>0&&m.jsxs(eg,{x:h+c*R+R/2,y:v,width:l,children:[m.jsx("div",{className:"font-medium",children:P(c)}),t.map(z=>m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-[1px]",style:{background:z.color}}),z.label,": ",a(z.values[c]??0)]},z.key)),n==="stacked"&&t.length>1&&m.jsxs("div",{className:"mt-0.5 border-t border-gray-200 pt-0.5 dark:border-gray-700",children:["total: ",a(O(c))]})]})]}),t.length>1&&m.jsx(ab,{series:t})]})}function xO({labels:e,series:t,formatValue:n=jc,height:r=132}){const[a,s]=Jm(),[o,l]=L.useState(null),c=30,d=8,h=8,p=16,v=e.length,y=Math.max(s-c-d,1),_=r-h-p,S=(B,J)=>B.values[J]??0,w=B=>t.reduce((J,P)=>J+S(P,B),0),C=RT(Math.max(1,...e.map((B,J)=>w(J)))),O=B=>c+(v<=1?y/2:B/(v-1)*y),A=B=>h+_*(1-B/C),R=h+_,F=[];{const B=e.map(()=>0);for(const J of t)F.push([...B]),e.forEach((P,q)=>B[q]=(B[q]??0)+S(J,q))}const M=(B,J)=>{const P=F[J],q=e.map((W,G)=>[O(G),A(P[G]+S(B,G))]),z=e.map((W,G)=>[O(G),A(P[G])]).reverse();return`M ${q.map(([W,G])=>`${W},${G}`).join(" L ")} L ${z.map(([W,G])=>`${W},${G}`).join(" L ")} Z`},Y=B=>{const J=v<=1?0:Math.round((B.nativeEvent.offsetX-c)/y*(v-1));l(Math.max(0,Math.min(v-1,J)))};return m.jsxs("div",{children:[m.jsxs("div",{ref:a,className:"relative",style:{height:r},children:[s>0&&m.jsxs("svg",{width:s,height:r,className:"block",children:[[0,C].map(B=>m.jsxs("g",{children:[m.jsx("line",{x1:c,y1:A(B),x2:s-d,y2:A(B),className:"text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),m.jsx("text",{x:c-4,y:A(B)+3,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:jc(B)})]},B)),t.map((B,J)=>m.jsx("path",{d:M(B,J),fill:B.color,opacity:.85},B.key)),o!=null&&m.jsx("line",{x1:O(o),y1:h,x2:O(o),y2:R,className:"text-gray-400 dark:text-gray-300",stroke:"currentColor",strokeWidth:1}),m.jsx("text",{x:c,y:r-4,className:"fill-gray-400 text-[8px]",children:e[0]?Cc(e[0]):""}),m.jsx("text",{x:s-d,y:r-4,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:e[v-1]?Cc(e[v-1]):""}),m.jsx("rect",{x:0,y:0,width:s,height:r,fill:"transparent",onMouseMove:Y,onMouseLeave:()=>l(null)})]}),o!=null&&s>0&&m.jsxs(eg,{x:O(o),y:h,width:s,children:[m.jsx("div",{className:"font-medium",children:e[o]?Cc(e[o]):""}),t.map(B=>m.jsxs("div",{className:"flex items-center gap-1",children:[m.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)),m.jsxs("div",{className:"mt-0.5 border-t border-gray-200 pt-0.5 dark:border-gray-700",children:["total: ",n(w(o))]})]})]}),t.length>1&&m.jsx(ab,{series:t})]})}function OCe({points:e,xLabel:t,yLabel:n,formatX:r=jc,formatY:a=jc,fit:s=!1,height:o=150}){const[l,c]=Jm(),[d,h]=L.useState(null),p=32,v=8,y=8,_=18,S=Math.max(c-p-v,1),w=o-y-_,C=P=>Math.log10(1+Math.max(0,P)),O=C(Math.max(1,...e.map(P=>P.x))),A=C(Math.max(1,...e.map(P=>P.y))),R=P=>p+C(P)/(O||1)*S,F=P=>y+w*(1-C(P)/(A||1)),M=P=>[0,1,10,100,1e3,1e4].filter(q=>C(q)<=P+.01),Y=(()=>{if(!s)return null;const P=e.filter(Me=>Me.x>0&&Me.y>0);if(P.length<4)return null;const q=P.map(Me=>Math.log10(Me.x)),z=P.map(Me=>Math.log10(Me.y)),W=P.length,G=q.reduce((Me,ae)=>Me+ae,0)/W,X=z.reduce((Me,ae)=>Me+ae,0)/W;let de=0,ue=0;for(let Me=0;Me<W;Me++)de+=(q[Me]-G)**2,ue+=(q[Me]-G)*(z[Me]-X);if(de===0)return null;const H=ue/de,oe=X-H*G,j=Math.min(...q),te=Math.max(...q);if(te<=j)return null;const ve=24;let Q="";for(let Me=0;Me<=ve;Me++){const ae=j+Me/ve*(te-j),Ie=10**ae,me=10**(oe+H*ae);Q+=`${Me===0?"M":" L"} ${R(Ie).toFixed(1)} ${F(me).toFixed(1)}`}return{d:Q,slope:H}})(),B=P=>{const q=P.nativeEvent.offsetX,z=P.nativeEvent.offsetY;let W=-1,G=196;e.forEach((X,de)=>{const ue=R(X.x)-q,H=F(X.y)-z,oe=ue*ue+H*H;oe<G&&(G=oe,W=de)}),h(W>=0?W:null)},J=d!=null?e[d]:null;return m.jsxs("div",{children:[m.jsxs("div",{ref:l,className:"relative",style:{height:o},children:[c>0&&m.jsxs("svg",{width:c,height:o,className:"block",children:[M(A).map(P=>m.jsxs("g",{children:[m.jsx("line",{x1:p,y1:F(P),x2:c-v,y2:F(P),className:"text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),m.jsx("text",{x:p-4,y:F(P)+3,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:a(P)})]},`y${P}`)),M(O).map(P=>m.jsx("text",{x:R(P),y:o-8,textAnchor:"middle",className:"fill-gray-400 text-[8px]",children:r(P)},`x${P}`)),e.map((P,q)=>m.jsx("circle",{cx:R(P.x),cy:F(P.y),r:d===q?4:2.2,fill:P.merged?Tn.green:Tn.gray,opacity:d==null||d===q?.75:.3},q)),Y&&m.jsx("path",{d:Y.d,fill:"none",stroke:Tn.amber,strokeWidth:1.5,strokeDasharray:"4 3",opacity:.95}),Y&&m.jsxs("text",{x:p+5,y:y+9,fill:Tn.amber,className:"text-[8px] font-semibold",children:["≈ ",n," ∝ ",t,"^",Y.slope.toFixed(1)]}),m.jsxs("text",{x:p,y:o-1,className:"fill-gray-400 text-[8px]",children:[t," →"]}),m.jsx("rect",{x:0,y:0,width:c,height:o,fill:"transparent",onMouseMove:B,onMouseLeave:()=>h(null)})]}),J&&c>0&&m.jsxs(eg,{x:R(J.x),y:F(J.y),width:c,children:[m.jsx("div",{className:"font-medium",children:J.label}),m.jsxs("div",{children:[t,": ",r(J.x)]}),m.jsxs("div",{children:[n,": ",a(J.y)]})]})]}),m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsxs("span",{className:"text-[9px] text-gray-400",children:[n," (log) ↑"]}),m.jsx(ab,{series:[{label:"merged",color:Tn.green},{label:"closed",color:Tn.gray}]})]})]})}const j1=[1,2,3,4,5,6,0],DCe=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],PCe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function MCe({cells:e,height:t}){const[n,r]=Jm(),[a,s]=L.useState(null),o=26,l=2,c=14,h=Math.max(r-o-2,1)/24,p=t??l+7*c+14,v=Math.max(1,...e),y=S=>{const w=Math.floor((S.nativeEvent.offsetX-o)/h),C=Math.floor((S.nativeEvent.offsetY-l)/c);if(w<0||w>23||C<0||C>6){s(null);return}s({row:C,col:w})},_=(S,w)=>e[j1[S]*24+w]??0;return m.jsx("div",{children:m.jsxs("div",{ref:n,className:"relative",style:{height:p},children:[r>0&&m.jsxs("svg",{width:r,height:p,className:"block",children:[DCe.map((S,w)=>m.jsx("text",{x:o-4,y:l+w*c+c-4,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:S},S)),j1.map((S,w)=>Array.from({length:24},(C,O)=>{const A=_(w,O),R=(a==null?void 0:a.row)===w&&(a==null?void 0:a.col)===O;return m.jsx("rect",{x:o+O*h,y:l+w*c,width:Math.max(h-1,1),height:c-1,rx:1.5,fill:A>0?Tn.blue:"currentColor",className:A>0?"":"text-gray-100 dark:text-gray-800",fillOpacity:A>0?.15+.85*(A/v):1,stroke:R?Tn.blue:"none",strokeWidth:R?1.5:0},`${w}-${O}`)})),[0,6,12,18].map(S=>m.jsxs("text",{x:o+S*h,y:p-3,className:"fill-gray-400 text-[8px]",children:[S,":00"]},S)),m.jsx("rect",{x:0,y:0,width:r,height:p,fill:"transparent",onMouseMove:y,onMouseLeave:()=>s(null)})]}),a&&r>0&&m.jsxs(eg,{x:o+a.col*h+h/2,y:l+a.row*c,width:r,children:[PCe[j1[a.row]]," ",String(a.col).padStart(2,"0"),":00 ·"," ",_(a.row,a.col)," events"]})]})})}const Hl=e=>e.reduce((t,n)=>t+n,0);function yp({title:e,children:t}){return m.jsxs("div",{children:[m.jsx("h3",{className:"mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:e}),m.jsx("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:t})]})}function LCe({data:e}){const{data:t}=Bc(),n=vu(t),r=e.weekBuckets,a=`${e.windowDays/7}-wk · weekly`,s=[{key:"opened",label:"Opened",color:Tn.blue,values:e.throughput.opened},{key:"merged",label:"Merged",color:Tn.green,values:e.throughput.merged},{key:"closed",label:"Closed",color:Tn.gray,values:e.throughput.closed}],o=[{key:"open",label:"Open",color:Tn.blue,values:e.backlog.open},{key:"stalled",label:"Stalled",color:Tn.orange,values:e.backlog.stalled}],l=[{key:"median",label:"Median to 1st review",color:Tn.blue,values:e.reviewLatencyTrend.medianHours}],c=[{key:"ttfr",label:"Open → 1st review",color:Tn.amber,values:e.cycleBreakdown.toFirstReview},{key:"rtm",label:"1st review → close",color:Tn.blue,values:e.cycleBreakdown.reviewToMerge}],d=[{key:"count",label:"PRs",color:Tn.blue,values:e.reviewLatencyDist.map(A=>A.count)}],h=e.reviewLatencyDist.map(A=>A.label),p=[{key:"untouched",label:Jr.untouched.label,color:Jr.untouched.color,values:e.threadMix.untouched},{key:"replied",label:Jr.replied_unresolved.label,color:Jr.replied_unresolved.color,values:e.threadMix.replied_unresolved},{key:"likely",label:Jr.likely_addressed.label,color:Jr.likely_addressed.color,values:e.threadMix.likely_addressed},{key:"resolved",label:Jr.resolved.label,color:Jr.resolved.color,values:e.threadMix.resolved}],v=[{key:"approved",label:"Approved",color:Tn.green,values:e.reviewVerdicts.approved},{key:"changes",label:"Changes requested",color:Tn.orange,values:e.reviewVerdicts.changes_requested},{key:"commented",label:"Commented",color:Tn.gray,values:e.reviewVerdicts.commented},{key:"dismissed",label:"Dismissed",color:Tn.slate,values:e.reviewVerdicts.dismissed}],y=e.reviewerLoad.map((A,R)=>({key:String(A.userId),label:A.userId===-1?"Others":Lr(n.get(A.userId),A.userId),color:bO[R%bO.length],values:A.weekly})),_=[{key:"count",label:"PRs",color:Tn.purple,values:e.sizeDist.map(A=>A.count)}],S=e.sizeDist.map(A=>A.label),w=e.sizeVsCycle.map(A=>({x:A.loc,y:A.hoursOpen,label:`#${A.prNumber}`,merged:A.merged})),C=e.sizeCycleByBucket.map(A=>A.label),O=[{key:"median",label:"Median time open",color:Tn.teal,values:e.sizeCycleByBucket.map(A=>A.medianHours??0)}];return m.jsxs("div",{className:"space-y-4",children:[m.jsxs(yp,{title:"Flow & throughput",children:[m.jsx(fs,{title:"PR throughput",note:a,children:Hl(s.flatMap(A=>A.values))===0?m.jsx(za,{}):m.jsx(Gd,{labels:r,series:s,mode:"grouped"})}),m.jsx(fs,{title:"Open backlog & stalled",note:"weekly snapshot",children:Math.max(0,...e.backlog.open)===0?m.jsx(za,{}):m.jsx(Tw,{labels:r,series:o,curved:!0})})]}),m.jsxs(yp,{title:"Speed & latency",children:[m.jsx(fs,{title:"Time to first review",note:"weekly median",children:e.reviewLatencyTrend.medianHours.every(A=>A==null)?m.jsx(za,{}):m.jsx(Tw,{labels:r,series:l,area:!0,formatY:vp,curved:!0})}),m.jsx(fs,{title:"Cycle-time breakdown",note:"by close week",children:Hl(e.cycleBreakdown.count)===0?m.jsx(za,{}):m.jsx(Gd,{labels:r,series:c,mode:"stacked",formatY:vp})}),m.jsx(fs,{title:"Review-latency distribution",note:"open → 1st review",children:Hl(d[0].values)===0?m.jsx(za,{}):m.jsx(Gd,{labels:h,series:d})})]}),m.jsxs(yp,{title:"Review health",children:[m.jsx(fs,{title:"Thread-resolution mix",note:"by thread created week",children:Hl(p.flatMap(A=>A.values))===0?m.jsx(za,{}):m.jsx(xO,{labels:r,series:p})}),m.jsx(fs,{title:"Review verdicts",note:a,children:Hl(v.flatMap(A=>A.values))===0?m.jsx(za,{}):m.jsx(Gd,{labels:r,series:v,mode:"stacked"})}),m.jsx(fs,{title:"Reviews by reviewer",note:a,children:y.length===0?m.jsx(za,{}):m.jsx(xO,{labels:r,series:y})})]}),m.jsxs(yp,{title:"Size & risk",children:[m.jsx(fs,{title:"PR size distribution",note:"opened, by LOC",children:Hl(_[0].values)===0?m.jsx(za,{}):m.jsx(Gd,{labels:S,series:_})}),m.jsx(fs,{title:"Median time open by size",note:"PRs closed in window",children:Hl(e.sizeCycleByBucket.map(A=>A.count))===0?m.jsx(za,{}):m.jsx(Gd,{labels:C,series:O,formatY:vp,formatValue:vp})}),m.jsx(fs,{title:"Size vs. time open",note:"log–log · power-law fit",children:w.length===0?m.jsx(za,{}):m.jsx(OCe,{points:w,xLabel:"LOC",yLabel:"time open",formatX:jc,formatY:vp,fit:!0})})]}),m.jsx(yp,{title:"Cadence",children:m.jsx(fs,{title:"Activity heatmap",note:"by weekday × hour (UTC)",children:Hl(e.activityHeatmap)===0?m.jsx(za,{}):m.jsx(MCe,{cells:e.activityHeatmap})})})]})}function FCe({repoId:e,repoName:t,onClose:n}){const{data:r,isLoading:a,error:s}=lD(e);return L.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:m.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4",onClick:n,role:"presentation",children:m.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:[m.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[m.jsxs("div",{className:"min-w-0",children:[m.jsx("h2",{className:"truncate text-sm font-semibold",children:t??"Analytics"}),m.jsxs("p",{className:"text-[11px] text-gray-400",children:["Charts over the last ",r?r.windowDays/7:12," weeks"]})]}),m.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:"✕"})]}),m.jsxs("div",{className:"min-h-0 flex-1 overflow-auto px-4 py-3",children:[a&&!r&&m.jsx("div",{className:"py-12 text-center text-sm text-gray-500",children:"Loading analytics…"}),s&&m.jsx("div",{className:"py-12 text-center text-sm text-red-500",children:"Failed to load analytics."}),r&&m.jsx(LCe,{data:r})]})]})})}function $Ce(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 jCe(){const[,e]=L.useState(0);L.useEffect(()=>{const t=window.setInterval(()=>e(n=>n+1),3e4);return()=>window.clearInterval(t)},[])}function BCe({fullName:e,maintainerCount:t,hasUnread:n,attentionCount:r,openPrs:a,threadTotals:s,selected:o,onSelect:l}){const c=s!=null||n||r>0||a!=null;return m.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:[m.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[m.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-gray-700 dark:text-gray-200",children:e}),t>0&&m.jsx(gk,{})]}),c&&m.jsxs("span",{className:"flex items-center gap-1.5 pl-0.5",children:[n&&m.jsx("span",{"aria-hidden":"true",title:"New activity",className:"inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-sky-500"}),s!=null&&m.jsx(AT,{counts:s,compact:!0}),r>0&&m.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]}),m.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-gray-400",children:a==null?"":a>0?`[${a}]`:"[—]"})]})]})}function UCe(){jCe();const e=$e(A=>A.repoIds),t=$e(A=>A.userIds),n=$e(A=>A.activityRepoId),r=$e(A=>A.setActivityRepo),{data:a,isFetching:s,isLoading:o,refetch:l}=nCe(e,t),{data:c}=gu(),d=lr(),[h,p]=L.useState(null),v=L.useMemo(()=>$Ce((a==null?void 0:a.repos)??[]),[a==null?void 0:a.repos]),y=typeof n=="number"?v.find(A=>A.repoId===n)??null:null,_=n==="feed"||n==null,S=(a==null?void 0:a.generatedAt)??null,w=S!=null&&Date.now()-new Date(S).getTime()>10*6e4,C=a!=null?v.map(A=>({repoId:A.repoId,fullName:A.repoFullName,maintainerCount:A.maintainerIds.length,hasUnread:A.hasUnread,attentionCount:A.attentionCount,openPrs:A.stats.openPrs,threadTotals:A.threadTotals})):(c??[]).map(A=>({repoId:A.id,fullName:A.fullName,maintainerCount:0,hasUnread:!1,attentionCount:0,openPrs:null,threadTotals:null})),O=a!=null&&v.length===0;return m.jsxs("div",{className:"flex h-full min-h-0 flex-col md:flex-row",children:[m.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:[m.jsxs("div",{className:"flex items-center gap-2 border-b border-gray-200 px-3 py-2 dark:border-gray-800",children:[m.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"State of play"}),m.jsxs("button",{type:"button",onClick:()=>{l(),d.invalidateQueries({queryKey:["consolidated-feed"]})},disabled:s,className:"ml-auto flex items-center gap-1 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",title:"Re-query the local database (does not trigger a GitHub sync)",children:[m.jsx("span",{"aria-hidden":"true",className:s?"animate-spin":"",children:"↻"}),"Refresh"]})]}),S!=null&&m.jsxs("div",{className:`px-3 py-1 text-[10px] ${w?"text-amber-500":"text-gray-400"}`,title:new Date(S).toLocaleString(),children:[ra(S),w?" · stale":""]}),s&&a!=null&&m.jsx("div",{className:"h-0.5 w-full overflow-hidden bg-sky-100 dark:bg-sky-950",children:m.jsx("div",{className:"h-full w-1/3 animate-pulse bg-sky-500"})}),m.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 ${s&&a!=null?"opacity-60 transition-opacity":""}`,children:[m.jsxs("button",{type:"button",onClick:()=>r("feed"),"aria-pressed":_,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 ${_?"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:[m.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-sky-500",children:"✦"}),m.jsx("span",{className:"min-w-0 flex-1 truncate font-semibold text-gray-700 dark:text-gray-200",children:"Feed"})]}),C.map(A=>m.jsx(BCe,{fullName:A.fullName,maintainerCount:A.maintainerCount,hasUnread:A.hasUnread,attentionCount:A.attentionCount,openPrs:A.openPrs,threadTotals:A.threadTotals,selected:n===A.repoId,onSelect:()=>r(A.repoId)},A.repoId)),m.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(A=>m.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-400",title:Jr[A].description,children:[m.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{background:Jr[A].color}}),Jr[A].label.toLowerCase()]},A))})]})]}),m.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-3",children:O?m.jsx("div",{className:"flex h-full items-center justify-center text-sm text-gray-400",children:"No watched repos yet. Add a repo from the filter bar to populate the Activity."}):_?m.jsx($1,{}):o&&a==null?m.jsx("div",{className:"space-y-3",children:[0,1,2].map(A=>m.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"},A))}):y!=null?m.jsxs("div",{className:"space-y-3",children:[m.jsx(pCe,{repo:y}),m.jsx(mCe,{repoId:y.repoId,onOpenCharts:()=>p({repoId:y.repoId,name:y.repoFullName})}),m.jsx(gCe,{prs:y.prs,repoFullName:y.repoFullName}),m.jsx($1,{repoId:y.repoId})]}):m.jsx($1,{})}),m.jsx(FCe,{repoId:(h==null?void 0:h.repoId)??null,repoName:(h==null?void 0:h.name)??null,onClose:()=>p(null)})]})}function HCe(){const e=$e(d=>d.selectedPrId),t=$e(d=>d.selectedThreadId),n=$e(d=>d.clearSelection),r=L.useDeferredValue(e),a=e??r,s=ln(d=>d.activeTab),o=Fw(s),l=(o==null?void 0:o.kind)==="pr-detail"?o.prId:null,c=a!=null&&a!==l;return m.jsxs("div",{className:"relative h-full","data-testid":"detail-pane",children:[e!=null&&m.jsx("div",{className:"absolute right-2 top-1.5 z-10 flex items-center gap-2",children:m.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:"✕"})}),c?m.jsx(MM,{prId:a,selectedThreadId:t},a):m.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 qF="pierre:notifications",B1="pierre:notif-pref";function _O(){try{return localStorage.getItem(qF)==="1"}catch{return!1}}function KF(){const[e,t]=L.useState(_O);L.useEffect(()=>{const r=()=>t(_O());return window.addEventListener(B1,r),window.addEventListener("storage",r),()=>{window.removeEventListener(B1,r),window.removeEventListener("storage",r)}},[]);const n=L.useCallback(r=>{try{localStorage.setItem(qF,r?"1":"0")}catch{}t(r),window.dispatchEvent(new Event(B1))},[]);return[e,n]}function zCe(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 YCe={cloning:"Cloning",fetching_diff:"Fetching diff",deciding:"Deciding scope",reviewing:"Reviewing",persisting:"Saving findings"};function WCe(){var R;const e=((R=$f().data)==null?void 0:R.claudeReviewEnabled)??!1,t=$e(F=>F.claudeReviewKickoff),n=$e(F=>F.openClaudeReview),[r]=KF(),a=L.useRef(r);a.current=r;const[s,o]=L.useState(!1);L.useEffect(()=>{t>0&&o(!0)},[t]);const{data:l,dataUpdatedAt:c}=kK(e&&s);L.useEffect(()=>{s&&((l==null?void 0:l.reviews.length)??0)===0&&o(!1)},[c]);const[d,h]=L.useState({}),[p,v]=L.useState({}),y=L.useRef(null),_=((l==null?void 0:l.reviews)??[]).map(F=>`${F.reviewId}:${F.phase??""}`).join(",");L.useEffect(()=>{const F=(l==null?void 0:l.reviews)??[],M=new Set(F.map(B=>B.reviewId)),Y=y.current;if(Y!=null){const B=[];for(const[J,P]of Y)M.has(J)||B.push(P);B.length>0&&(pK(),a.current&&zCe(B))}y.current=new Map(F.map(B=>[B.reviewId,{repoFullName:B.repoFullName,prNumber:B.prNumber,prTitle:B.prTitle}])),h(B=>{const J={...B};for(const P of F)J[P.reviewId]={reviewId:P.reviewId,prId:P.prId,repoFullName:P.repoFullName,prNumber:P.prNumber,prTitle:P.prTitle,phase:P.phase,done:!1};for(const P of Object.values(J))!M.has(P.reviewId)&&!P.done&&(J[P.reviewId]={...P,done:!0});return J})},[_]);const S=Object.values(d).filter(F=>!p[F.reviewId]);if(!e||S.length===0)return null;const w=S.filter(F=>!F.done),C=w.length===0,O=()=>{v(F=>{const M={...F};for(const Y of S)M[Y.reviewId]=!0;return M})},A=F=>v(M=>({...M,[F]:!0}));return m.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:m.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:[m.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 px-3 py-1.5 dark:border-gray-800",children:[m.jsxs("span",{className:"text-xs font-semibold",children:["Claude reviews",w.length>0&&m.jsxs("span",{className:"ml-1 font-normal text-gray-400",children:["· ",w.length," running"]})]}),C&&m.jsx("button",{type:"button",onClick:O,className:"text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:"Dismiss all"})]}),m.jsx("ul",{className:"max-h-64 divide-y divide-gray-100 overflow-auto dark:divide-gray-800",children:S.map(F=>m.jsxs("li",{className:"px-3 py-2 text-xs",children:[m.jsxs("button",{type:"button",onClick:()=>n(F.prId),className:"block w-full text-left",title:"Open this review",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[F.done?m.jsx("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full bg-green-500"}):m.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"}),m.jsxs("span",{className:"truncate font-medium text-blue-600 hover:underline dark:text-blue-400",children:[F.repoFullName," #",F.prNumber]})]}),m.jsx("div",{className:"mt-0.5 truncate text-gray-500",children:F.prTitle}),m.jsx("div",{className:"mt-0.5 text-gray-400",children:F.done?"Ready — click to view":`${F.phase!=null?YCe[F.phase]??F.phase:"Starting"}…`})]}),F.done&&m.jsx("div",{className:"mt-1 text-right",children:m.jsx("button",{type:"button",onClick:()=>A(F.reviewId),className:"text-[11px] text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:"dismiss"})})]},F.reviewId))})]})})}function GCe({repos:e,statuses:t,cancelling:n,onCancel:r}){const a=c=>t==null?void 0:t.find(d=>d.repoId===c),s=c=>{if(t===void 0)return!0;const d=a(c);return d===void 0||d.status==="running"},o=e.filter(c=>!s(c.id)).length,l=e.length>0&&o===e.length;return m.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",role:"presentation",children:m.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:[m.jsx("div",{className:"mb-3 flex items-center justify-between",children:m.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"}`})}),m.jsx("ul",{className:"space-y-3",children:e.map(c=>{var _,S;const d=a(c.id),h=s(c.id),p=(d==null?void 0:d.status)==="error",v=((_=d==null?void 0:d.progress)==null?void 0:_.prsProcessed)??0,y=h?Math.round((((S=d==null?void 0:d.progress)==null?void 0:S.percent)??0)*100):100;return m.jsxs("li",{children:[m.jsxs("div",{className:"mb-1 flex items-baseline justify-between gap-2 text-xs",children:[m.jsx("span",{className:"truncate font-medium",title:c.fullName,children:c.fullName}),m.jsx("span",{className:"shrink-0 text-gray-500",children:p?m.jsx("span",{className:"text-red-500",children:"error"}):h?`${y}%${v>0?` · ${v} PRs`:""}`:m.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["✓ done",v>0?` · ${v} PRs`:""]})})]}),m.jsx("div",{className:"h-2 w-full overflow-hidden rounded bg-gray-200 dark:bg-gray-800",children:m.jsx("div",{className:`h-2 rounded transition-all duration-500 ${p?"bg-red-500":h?"bg-blue-500":"bg-green-500"}`,style:{width:`${p?100:y}%`}})})]},c.id)})}),m.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 text-xs text-gray-500",children:[m.jsxs("span",{children:[o," of ",e.length," repo",e.length===1?"":"s"," complete"]}),m.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 VCe(e){let t=null;for(const n of e){const r=n.lastIncrementalSyncAt??n.lastFullSyncAt;r&&(!t||r>t)&&(t=r)}return t}const EO=5,wO=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});function qCe(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 KCe(e){const t=qCe(EO),n=Math.max(1,Math.round((t.getTime()-Date.now())/6e4)),r=e?[`Last synced ${wO(new Date(e))}`]:[];return r.push(`Syncs automatically every ${EO} minutes`),r.push(`Next sync ~${wO(t)} (in ${n} min)`),r.join(`
1378
1378
  `)}function QCe(){const e=lr(),[t,n]=L.useState(!1),[r,a]=L.useState(!1),[s,o]=L.useState(!1),[l,c]=L.useState(!1),[d,h]=L.useState([]),{data:p}=ar({queryKey:["repos"],queryFn:Lt.listRepos,refetchInterval:t?3e3:3e4}),v=(p??[]).map(oe=>oe.id).join(","),{data:y}=ar({queryKey:["sync-status",v],enabled:t&&!!p&&p.length>0,queryFn:()=>Promise.all((p??[]).map(oe=>Lt.syncStatus(oe.id))),refetchInterval:1500}),_=new Set(d),S=_.size===0?p??[]:(p??[]).filter(oe=>_.has(oe.id)),w=new Set(S.map(oe=>oe.id)),C=y==null?void 0:y.filter(oe=>w.has(oe.repoId)),O=(C??[]).filter(oe=>oe.status==="running"),A=O.length,R=A>0&&O.every(oe=>{var j;return((j=oe.progress)==null?void 0:j.foregroundComplete)===!0}),F=VCe(p??[]),M=L.useRef(F),Y=L.useRef(!1),B=L.useRef(null),J=()=>{B.current!=null&&(clearTimeout(B.current),B.current=null)},P=()=>{o(!1),Y.current=!1,J()};L.useEffect(()=>J,[]);const q=()=>{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"]})};L.useEffect(()=>{M.current!==F&&(M.current=F,q())},[F]),L.useEffect(()=>{!t||!R||Y.current||(Y.current=!0,a(!1),q())},[t,R]),L.useEffect(()=>{A>0&&o(!0)},[A]),L.useEffect(()=>{t&&s&&y&&A===0&&(n(!1),o(!1),q(),J(),B.current=setTimeout(()=>{a(!1),B.current=null},1e3))},[t,s,y,A]);const z=$e(oe=>oe.syncModalSignal),W=$e(oe=>oe.syncModalRepoId),G=L.useRef(z);if(L.useEffect(()=>{z!==G.current&&(G.current=z,W!=null&&(r?h(oe=>oe.includes(W)?oe:[...oe,W]):(h([W]),a(!0),n(!0),P()),e.invalidateQueries({queryKey:["repos"]}),e.invalidateQueries({queryKey:["sync-status"]})))},[z,e]),!p||p.length===0)return null;const X=p.find(oe=>oe.lastSyncStatus==="error"),de=async(oe=!1)=>{n(!0),a(!0),h([]),P(),await Promise.allSettled(p.map(j=>Lt.syncRepo(j.id,oe))),e.invalidateQueries({queryKey:["repos"]}),e.invalidateQueries({queryKey:["sync-status"]})},ue=async()=>{c(!0),J();const oe=(C??[]).filter(te=>te.status==="running").map(te=>te.repoId),j=oe.length?oe:S.map(te=>te.id);await Promise.allSettled(j.map(te=>Lt.cancelSync(te))),n(!1),o(!1),c(!1),a(!1),e.invalidateQueries({queryKey:["repos"]}),q()},H=R?"loading older history…":A>0?`syncing ${A} repo${A===1?"":"s"}…`:"syncing…";return m.jsxs(m.Fragment,{children:[r&&m.jsx(GCe,{repos:S,statuses:C,cancelling:l,onCancel:()=>void ue()}),m.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[X?m.jsxs("span",{className:"text-red-500",title:X.lastSyncError??"",children:["sync error: ",X.fullName]}):m.jsx("span",{className:"cursor-help",title:KCe(F),children:t?H:F?`synced ${ra(F)}`:"not synced yet"}),m.jsx("button",{type:"button",onClick:()=>void de(!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"}),m.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?")&&de(!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 XCe(){const e=$e(R=>R.searchQuery),t=$e(R=>R.setSearchQuery),n=ln(R=>R.openPrFocusTab),{data:r}=Uw(),{data:a}=Hw(),{data:s}=gu(),{data:o}=Bc(),[l,c]=L.useState(!1),[d,h]=L.useState(-1),p=L.useRef(null),v=L.useMemo(()=>{const R=new Map;for(const F of s??[])R.set(F.id,F.fullName);return R},[s]),y=L.useMemo(()=>vu(o),[o]),_=L.useMemo(()=>{const R=new Map;for(const F of(r==null?void 0:r.prs)??[])R.set(F.id,F);for(const F of(a==null?void 0:a.prs)??[])R.has(F.id)||R.set(F.id,F);return[...R.values()]},[r,a]),S=L.useMemo(()=>{const R=e.trim().toLowerCase();if(!R)return[];const F=R.replace(/^#/,""),M=F.length>0&&/^\d+$/.test(F),Y=_.filter(B=>B.title.toLowerCase().includes(R)||M&&String(B.number).includes(F));if(M){const B=J=>{const P=String(J.number);return P===F?0:P.startsWith(F)?1:P.includes(F)?2:3};Y.sort((J,P)=>B(J)-B(P))}return Y.slice(0,30)},[_,e]),w=l&&e.trim().length>0,C=d>=0&&d<S.length?S[d].id:null;sl(p,()=>c(!1),w),L.useEffect(()=>{var R,F;C!=null&&((F=(R=p.current)==null?void 0:R.querySelector(`#pr-result-${C}`))==null||F.scrollIntoView({block:"nearest"}))},[C]);const O=R=>{if(!R)return;const F=R.authorId!=null?y.get(R.authorId):void 0;n({id:R.id,number:R.number,title:R.title,repoFullName:v.get(R.repoId)??`repo ${R.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}),c(!1)},A=R=>{if(R.key==="Escape"){c(!1),R.target.blur();return}!w||S.length===0||(R.key==="ArrowDown"?(R.preventDefault(),h(F=>(F+1)%S.length)):R.key==="ArrowUp"?(R.preventDefault(),h(F=>F<=0?S.length-1:F-1)):R.key==="Enter"&&(R.preventDefault(),O(S[d>=0?d:0])))};return m.jsxs("div",{ref:p,className:"relative",children:[m.jsx("input",{type:"search",value:e,placeholder:"Search PRs (title or number)…",onChange:R=>{t(R.target.value),h(-1),c(!0)},onFocus:()=>c(!0),onKeyDown:A,role:"combobox","aria-expanded":w,"aria-controls":"pr-search-results","aria-autocomplete":"list","aria-activedescendant":C!=null?`pr-result-${C}`: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"}),w&&m.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?m.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:"No matching PRs."}):S.map((R,F)=>{const M=R.authorId!=null?y.get(R.authorId):void 0;return m.jsxs("button",{id:`pr-result-${R.id}`,type:"button",role:"option","aria-selected":F===d,onMouseEnter:()=>h(F),onClick:()=>O(R),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:[m.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-400",children:[m.jsx(ka,{user:M,size:12}),m.jsx("span",{className:"truncate",title:Lr(M,R.authorId),children:Lr(M,R.authorId)}),m.jsx("span",{"aria-hidden":!0,children:"·"}),m.jsxs("span",{className:"shrink-0",children:[v.get(R.repoId)??`repo ${R.repoId}`," · #",R.number]})]}),m.jsx("span",{className:"truncate text-xs",title:R.title,children:R.title})]},R.id)})})]})}const QF="pierre:lastVisitAt",ZCe=3600*1e3,JCe=60*1e3;let Z0;function eNe(){if(Z0===void 0)try{Z0=localStorage.getItem(QF)}catch{Z0=null}return Z0}function kO(){try{localStorage.setItem(QF,new Date().toISOString())}catch{}}function tNe(){const e=eNe(),{data:t}=$f(),n=ln(y=>y.activeTab),r=ln(y=>y.showActivity),a=$e(y=>y.setActivityRepo),s=$e(y=>y.setFeedMyTurnOnly),[o,l]=L.useState(!1);if(L.useEffect(()=>{kO();const y=()=>{document.visibilityState==="visible"&&kO()};window.addEventListener("focus",y),document.addEventListener("visibilitychange",y);const _=window.setInterval(y,JCe);return()=>{window.removeEventListener("focus",y),document.removeEventListener("visibilitychange",y),window.clearInterval(_)}},[]),o||e==null||!(t!=null&&t.user)||n==="activity")return null;const c=Date.now()-Date.parse(e);if(Number.isNaN(c)||c<ZCe)return null;const d=t.counts;if(d.awaitingReview+d.yourPrsActivity+(d.approvedPrs??0)+d.threadsAwaiting+d.watchedRepoPrs+d.claudeReviewsToAction===0)return null;const p=[];d.awaitingReview>0&&p.push(`${d.awaitingReview} awaiting your review`),d.yourPrsActivity>0&&p.push(`${d.yourPrsActivity} of your PRs active`),d.approvedPrs>0&&p.push(`${d.approvedPrs} of your PRs approved`),d.threadsAwaiting>0&&p.push(`${d.threadsAwaiting} thread${d.threadsAwaiting===1?"":"s"} awaiting you`),d.watchedRepoPrs>0&&p.push(`${d.watchedRepoPrs} new PR${d.watchedRepoPrs===1?"":"s"} in watched repos`),d.claudeReviewsToAction>0&&p.push(`${d.claudeReviewsToAction} Claude review${d.claudeReviewsToAction===1?"":"s"} to action`);const v=()=>{a("feed"),s(!0),r(),l(!0)};return m.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:[m.jsxs("button",{type:"button",onClick:v,title:"Show My Turn",className:"flex min-w-0 flex-1 items-center gap-2 text-left hover:underline",children:[m.jsx("span",{className:"font-medium",children:"Welcome back"}),m.jsxs("span",{className:"min-w-0 truncate text-amber-700/80 dark:text-amber-300/80",children:["· last here ",ra(e)," · ",p.join(" · ")]})]}),m.jsx("button",{type:"button",onClick:v,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 My Turn"}),m.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 nNe({onClose:e}){return L.useEffect(()=>{const t=n=>{n.key==="Escape"&&(n.stopImmediatePropagation(),e())};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[e]),m.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:e,role:"presentation",children:m.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:[m.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[m.jsx("h2",{className:"brand-title",children:"Pierre"}),m.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:"✕"})]}),m.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:[m.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."}),m.jsxs(zl,{title:"Track repositories",children:["Add repos in the filter bar’s ",m.jsx("em",{children:"add repo"})," box as ",m.jsx(rNe,{children:"owner/name"}),". Pierre syncs their PR activity every few minutes into a local file — nothing leaves your machine."]}),m.jsxs(zl,{title:"Read the timeline",children:["Rows are grouped ",m.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."]}),m.jsxs(zl,{title:"Focus mode",children:["To isolate one PR and just its contributors: double-click its bar, click"," ",m.jsx("strong",{children:"Focus"})," in the detail pane, or click a cross-person marker. Leave focus with the ",m.jsx("strong",{children:"✕"})," on the header"," ",m.jsx("strong",{children:"Focus mode"})," badge, ",m.jsx(Vd,{children:"Esc"}),", or the browser"," ",m.jsx("strong",{children:"Back"})," button."]}),m.jsxs(zl,{title:"Detail pane",children:["Selecting a PR opens the bottom pane with ",m.jsx("strong",{children:"Overview"})," (checks, summary, comments), ",m.jsx("strong",{children:"Threads"}),", and ",m.jsx("strong",{children:"Activity"}),". The ",m.jsx("em",{children:"Show"})," links jump back to that moment on the timeline; drag the divider to resize the pane."]}),m.jsxs(zl,{title:"Filter",children:["Narrow by date range, members (auto-scoped to who’s active in view), event categories, and thread states. ",m.jsx("em",{children:"Exclude bots"})," hides renovate / dependabot / CI noise."]}),m.jsxs(zl,{title:"Open-PRs strip",children:["The collapsible strip up top lists currently-open PRs — toggle between"," ",m.jsx("strong",{children:"all"}),", ",m.jsx("strong",{children:"my turn"}),", and"," ",m.jsx("strong",{children:"needs attention"}),"."]}),m.jsxs(zl,{title:"Activity & Insights",children:["Clicking an item in the ",m.jsx("strong",{children:"Activity Feed"})," opens that PR's detail tab, where ",m.jsx("strong",{children:"Show"})," / ",m.jsx("strong",{children:"Focus"})," drive the timeline; the feed's ",m.jsx("strong",{children:"My Turn only"})," toggle narrows it to what needs you."," ",m.jsx("strong",{children:"Insights"})," opens a per-repo snapshot (open / merged / stalled, time-to-first-review, review load). Save filter combinations as named ",m.jsx("strong",{children:"Views"}),", and use the bell to get notified when something new lands in your queue."]}),m.jsxs(zl,{title:"Keyboard",children:[m.jsx(Vd,{children:"/"})," focus the filter · ",m.jsx(Vd,{children:"j"}),"/",m.jsx(Vd,{children:"k"})," cycle PRs ·"," ",m.jsx(Vd,{children:"i"})," Insights · ",m.jsx(Vd,{children:"Esc"})," exit focus, else clear the selection."]})]})]})})}function zl({title:e,children:t}){return m.jsxs("section",{children:[m.jsx("h3",{className:"mb-1 font-semibold text-gray-800 dark:text-gray-100",children:e}),m.jsx("p",{children:t})]})}function rNe({children:e}){return m.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 Vd({children:e}){return m.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})}const iNe={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 aNe(){const[e]=L.useState(()=>{const t=new URLSearchParams(window.location.search).get("auth");return t?iNe[t]??"We couldn’t complete sign-in. Please try again.":null});return L.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]),m.jsx("div",{className:"flex h-full min-h-screen w-full items-center justify-center bg-gray-950 px-4 text-gray-100",children:m.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:[m.jsx("span",{className:"brand-title text-4xl",title:"Pierre — a play on “PR”",children:"Pierre"}),m.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&&m.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}),m.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:[m.jsx("svg",{viewBox:"0 0 16 16",width:"18",height:"18",fill:"currentColor","aria-hidden":"true",children:m.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"]}),m.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 sNe({user:e,canSignOut:t,onSignOut:n}){const[r,a]=L.useState(!1),s=L.useRef(null),o=e.displayName??e.login;sl(s,()=>a(!1),r),L.useEffect(()=>{if(!r)return;const c=d=>{d.key==="Escape"&&(d.stopPropagation(),a(!1))};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[r]);const l=e.avatarUrl!=null?m.jsx("img",{src:e.avatarUrl,alt:o,width:20,height:20,className:"shrink-0 rounded-full",style:{width:20,height:20}}):m.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:o.slice(0,2).toUpperCase()});return m.jsxs("div",{ref:s,className:"relative",children:[m.jsxs("button",{type:"button",onClick:()=>a(c=>!c),"aria-haspopup":"menu","aria-expanded":r,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 ${r?"bg-gray-100 dark:bg-gray-800":""}`,title:e.displayName!=null?`Signed in as ${e.displayName} (@${e.login})`:`Signed in as ${e.login}`,children:[l,m.jsx("span",{className:"max-w-[10rem] truncate",children:o}),m.jsx("span",{"aria-hidden":"true",className:"text-[9px] text-gray-400",children:"▾"})]}),r&&m.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:[m.jsxs("a",{role:"menuitem",href:Yw(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:[m.jsx(CM,{size:13}),"Open Profile on GitHub"]}),t&&m.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:[m.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:[m.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),m.jsx("polyline",{points:"16 17 21 12 16 7"}),m.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]}),"Sign Out"]})]})]})}const oNe=["7d","14d","30d","90d","custom"];function U1(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(r=>n.has(r))}function H1(e){if(!e)return null;const t=e.split(",").map(n=>Number.parseInt(n,10)).filter(Number.isFinite);return t.length?t:null}function lNe(){const e=new URLSearchParams(window.location.search),t={},n=e.get("preset");n&&oNe.includes(n)&&(t.preset=n),t.repoIds=H1(e.get("repos")),t.userIds=H1(e.get("users")),e.get("bots")!==null&&(t.excludeBots=e.get("bots")==="1");const r=H1(e.get("allowBots"));r&&(t.allowedBotIds=r);const a=e.get("stale");a==="0"?t.excludeStale=!1:a==="1"&&(t.excludeStale=!0),t.customFrom=e.get("from"),t.customTo=e.get("to");const s=e.get("cats");if(s){const y=new Set(Wp);t.categories=s.split(",").filter(_=>y.has(_))}const o=e.get("status");if(o!==null){const y=new Set(Gp);t.prStatuses=o.split(",").filter(_=>y.has(_))}const l=e.get("reviews");if(l!==null){const y=new Set(Vp);t.reviewStates=l.split(",").filter(_=>y.has(_))}const c=e.get("states");if(c){const y=new Set(Mw);t.derivedStates=c.split(",").filter(_=>y.has(_))}const d=e.get("pr");d&&(t.selectedPrId=Number.parseInt(d,10));const h=e.get("thread");h&&(t.selectedThreadId=Number.parseInt(h,10));const p=e.get("strip");(p==="my_turn"||p==="needs_attention"||p==="all")&&(t.stripFilter=p);const v=e.get("activityRepo");if(v){const y=Number.parseInt(v,10);Number.isFinite(y)&&(t.activityRepoId=y)}return e.get("open")==="1"&&(t.stripCollapsed=!1),t}function TO(e){var a,s;const t=new URLSearchParams;e.preset!=="14d"&&t.set("preset",e.preset),(a=e.repoIds)!=null&&a.length&&t.set("repos",e.repoIds.join(",")),(s=e.userIds)!=null&&s.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),U1(e.categories,bv)||t.set("cats",e.categories.join(",")),U1(e.prStatuses,_v)||t.set("status",e.prStatuses.join(",")),U1(e.reviewStates,xv)||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"),ln.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 XF="pierre:filterBarState";function uNe(){try{const e=localStorage.getItem(XF);if(!e)return null;const t=JSON.parse(e);return t&&typeof t=="object"?dy(t):null}catch{return null}}function cNe(e){try{localStorage.setItem(XF,JSON.stringify(oE(e)))}catch{}}function dNe(){const e=L.useRef(!1);L.useEffect(()=>{if(!e.current){if(window.location.search.length>1)$e.getState().hydrate(lNe()),new URLSearchParams(window.location.search).get("view")==="activity"&&ln.getState().setActiveTab("activity");else{const a=yj(),s=a?dy(a.state):uNe();s&&$e.getState().hydrate(s),ln.getState().setActiveTab("activity")}e.current=!0}const t=$e.subscribe(r=>{TO(r),cNe(r)}),n=ln.subscribe(()=>{TO($e.getState())});return()=>{t(),n()}},[])}function SO(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable}function fNe(){const{data:e}=Bw();L.useEffect(()=>{const t=n=>{var c;const{selectedPrId:r,selectPr:a,clearSelection:s}=$e.getState(),o=ln.getState(),l=o.activeTab==="timeline";if(n.key==="Escape"){SO(n.target)?n.target.blur():l?s():o.showTimeline();return}if(!SO(n.target)){if(n.key==="/"){n.preventDefault(),(c=document.getElementById("add-repo-input"))==null||c.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 h=d.findIndex(y=>y.id===r);let p;h===-1?p=0:p=n.key==="j"?h+1:h-1,p=Math.max(0,Math.min(d.length-1,p));const v=d[p];v&&a(v.id)}}};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e])}function hNe(){const e=lr();L.useEffect(()=>{let t=null;const n=()=>{const s=new Map,o=(l,c)=>{const d=s.get(l);(!d||c>d)&&s.set(l,c)};for(const[,l]of e.getQueriesData({queryKey:["timeline"]}))for(const c of(l==null?void 0:l.prs)??[])o(c.id,c.updatedAt);for(const[,l]of e.getQueriesData({queryKey:["open-prs"]}))for(const c of(l==null?void 0:l.prs)??[])o(c.id,c.updatedAt);for(const[l,c]of s){const d=e.getQueryData(["pr",l]);if(!d||d.updatedAt>=c)continue;const h=e.getQueryState(["pr",l]);if(!(h&&h.fetchStatus!=="idle")){e.invalidateQueries({queryKey:["pr",l]});for(const p of d.threads??[])e.invalidateQueries({queryKey:["thread",p.id]})}}},r=()=>{t||(t=setTimeout(()=>{t=null,n()},300))};r();const a=e.getQueryCache().subscribe(s=>{const o=s.query.queryKey[0];(o==="timeline"||o==="open-prs")&&r()});return()=>{t&&clearTimeout(t),a()}},[e])}function pNe(e){const{data:t}=oD(),n=L.useRef(null);L.useEffect(()=>{if(!t)return;const r=new Set;for(const v of t.awaitingReview)r.add(`r:${v.prId}`);for(const v of t.yourPrs)r.add(`p:${v.prId}`);for(const v of t.approvedPrs??[])r.add(`a:${v.prId}`);for(const v of t.threadsAwaiting)r.add(`t:${v.threadId}`);for(const v of t.watchedRepoPrs)r.add(`w:${v.prId}`);const a=n.current;if(n.current=r,a==null||!e||typeof Notification>"u"||Notification.permission!=="granted")return;const s=[...r].filter(v=>!a.has(v));if(s.length===0)return;const o=s.filter(v=>v.startsWith("r:")).length,l=s.filter(v=>v.startsWith("t:")).length,c=s.filter(v=>v.startsWith("p:")).length,d=s.filter(v=>v.startsWith("a:")).length,h=s.filter(v=>v.startsWith("w:")).length,p=[];o&&p.push(`${o} review${o===1?"":"s"} requested`),l&&p.push(`${l} thread${l===1?"":"s"} awaiting you`),c&&p.push(`${c} of your PRs active`),d&&p.push(`${d} of your PRs approved`),h&&p.push(`${h} new in watched repos`);try{const v=new Notification(`Pierre — ${s.length} new in My Turn`,{body:p.join(" · "),tag:"pierre-my-turn"});v.onclick=()=>{window.focus(),v.close()}}catch{}},[t,e])}const z1="";function mNe(e){return/^G-[A-Z0-9]{6,}$/i.test(e)&&e!=="G-XXXXXXXXXX"}let Sw=!1;function gNe(){if(Sw||typeof window>"u"||!mNe(z1))return;Sw=!0;const e=document.createElement("script");e.async=!0,e.src=`https://www.googletagmanager.com/gtag/js?id=${z1}`,document.head.appendChild(e),window.dataLayer=window.dataLayer||[],window.gtag=function(...n){window.dataLayer.push(n)},window.gtag("js",new Date),window.gtag("config",z1,{send_page_view:!1})}function vNe(e=window.location.pathname){!Sw||!window.gtag||window.gtag("event","page_view",{page_path:e,page_location:`${window.location.origin}${e}`,page_title:document.title})}function yNe(){const[e,t]=L.useState(()=>(localStorage.getItem("theme")??"dark")!=="light");return L.useEffect(()=>{document.documentElement.classList.toggle("dark",e),localStorage.setItem("theme",e?"dark":"light")},[e]),[e,()=>t(n=>!n)]}function bNe(){var G,X;const e=$f();dNe(),fNe(),hNe();const[t,n]=yNe(),[r,a]=L.useState(!1),[s,o]=KF(),l=typeof window<"u"&&"Notification"in window;pNe(s&&l);const c=()=>{if(l){if(s){o(!1);return}Notification.permission==="granted"?o(!0):Notification.permission!=="denied"&&Notification.requestPermission().then(de=>o(de==="granted"))}},d=((G=e.data)==null?void 0:G.deploymentMode)==="cloud",h=((X=e.data)==null?void 0:X.user)??null,p=()=>{ln.getState().clear(),Lt.logout().finally(()=>window.location.assign("/"))},v=$e(de=>de.selectedPrId),y=$e(de=>de.selectedThreadId),_=ln(de=>de.activeTab),S=ln(de=>de.tabs),w=_!=="timeline"&&_!=="activity"?S.find(de=>de.key===_)??null:null,C=_==="activity",O=(w==null?void 0:w.kind)==="pr-detail"?w.prId:null,A=(w==null?void 0:w.kind)==="pr-focus"?{kind:"isolate",prId:w.prId}:null,R=O!=null||C,F=v!=null&&!R,[M,Y]=zF("pierre:detailPaneHeight",384),B=L.useRef(null),J=L.useRef(null),P=L.useRef(null);L.useEffect(()=>{for(const de of[J.current,B.current])de&&(R?de.setAttribute("inert",""):de.removeAttribute("inert"))},[R]),L.useEffect(()=>{const de=()=>ln.getState().navigateBack();return window.addEventListener("popstate",de),()=>window.removeEventListener("popstate",de)},[]),L.useEffect(()=>{window.dispatchEvent(new Event("resize"))},[F]);const q=de=>{var ue;P.current={startY:de.clientY,startH:((ue=B.current)==null?void 0:ue.offsetHeight)??M},de.currentTarget.setPointerCapture(de.pointerId)},z=de=>{const ue=P.current;if(!ue||!B.current)return;const H=window.innerHeight*.7,oe=Math.min(Math.max(ue.startH+(ue.startY-de.clientY),160),H);B.current.style.height=`${oe}px`,window.dispatchEvent(new Event("resize"))},W=de=>{!P.current||!B.current||(P.current=null,de.currentTarget.releasePointerCapture(de.pointerId),Y(B.current.offsetHeight))};return L.useEffect(()=>{if(!d)return;const de=()=>{Lt.me().catch(()=>{})},ue=window.setInterval(de,180*1e3);return()=>window.clearInterval(ue)},[d]),L.useEffect(()=>{d&&(gNe(),vNe())},[d]),e.error instanceof To&&e.error.status===401?m.jsx(aNe,{}):e.isLoading&&!e.data?m.jsx("div",{className:"flex h-full min-h-screen items-center justify-center bg-gray-950",children:m.jsx("span",{className:"brand-title text-4xl text-gray-100",children:"Pierre"})}):m.jsxs("div",{className:"flex h-full flex-col",children:[m.jsxs("header",{className:"flex items-center gap-3 border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[m.jsx("h1",{className:"brand-title",title:"Pierre — a play on “PR”",children:"Pierre"}),m.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[m.jsx(XCe,{}),m.jsx(QCe,{}),l&&m.jsx("button",{type:"button",onClick:c,"aria-pressed":s,className:`rounded border px-2 py-0.5 text-xs hover:border-gray-400 dark:hover:border-gray-500 ${s?"border-blue-400 text-blue-600 dark:border-blue-600 dark:text-blue-400":"border-gray-300 dark:border-gray-700"}`,title:s?"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:m.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:s?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[m.jsx("path",{d:"M18 8a6 6 0 0 0-12 0c0 7-3 9-3 9h18s-3-2-3-9"}),m.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}),m.jsx("button",{type:"button",onClick:()=>a(!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:"?"}),m.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?"☀":"☾"}),h!=null&&m.jsx(sNe,{user:h,canSignOut:d,onSignOut:p})]})]}),r&&m.jsx(nNe,{onClose:()=>a(!1)}),m.jsx(tNe,{}),m.jsx(lq,{}),m.jsx(hq,{}),m.jsx(vq,{}),m.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[m.jsx("section",{ref:J,className:"min-h-0 flex-1 overflow-hidden",children:A==null?m.jsx(yO,{},"board"):m.jsx(yO,{mode:A},`focus:${A.prId}`)}),F&&m.jsxs(m.Fragment,{children:[m.jsx("div",{role:"separator","aria-orientation":"horizontal","aria-label":"Resize detail pane",onPointerDown:q,onPointerMove:z,onPointerUp:W,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"}),m.jsx("section",{ref:B,style:{height:M},className:"shrink-0 overflow-auto",children:m.jsx(HCe,{})})]}),O!=null&&m.jsx("div",{"data-testid":"pinned-pr-overlay",className:"absolute inset-0 z-20 bg-white dark:bg-gray-950",children:m.jsx(MM,{prId:O,selectedThreadId:v===O?y:null},O)}),C&&m.jsx("div",{"data-testid":"activity-overlay",className:"absolute inset-0 z-20 overflow-hidden bg-white dark:bg-gray-950",children:m.jsx(UCe,{})})]}),m.jsx(WCe,{})]})}function Cw(){}function xNe(e,{interval:t=1e3,onError:n=Cw}={}){if(typeof e!="function")throw new Error("argument is not function.");let r=0,a=null,s=!1,o=!1;return async(...l)=>{if(a=l,!o){for(o=!0;s;)await new Promise(c=>qo.setTimeout(c,t));for(;Date.now()<r;)await new Promise(c=>qo.setTimeout(c,r-Date.now()));o=!1,s=!0;try{await e(...a)}catch(c){try{n(c)}catch{}}r=Date.now()+t,s=!1}}}var _Ne=({storage:e,key:t="REACT_QUERY_OFFLINE_CACHE",throttleTime:n=1e3,serialize:r=JSON.stringify,deserialize:a=JSON.parse,retry:s})=>{if(e){const o=async l=>{try{const c=await r(l);await e.setItem(t,c);return}catch(c){return c}};return{persistClient:xNe(async l=>{let c=l,d=await o(c),h=0;for(;d&&c;)h++,c=await(s==null?void 0:s({persistedClient:c,error:d,errorCount:h})),c&&(d=await o(c))},{interval:n}),restoreClient:async()=>{const l=await e.getItem(t);if(l)return await a(l)},removeClient:()=>e.removeItem(t)}}return{persistClient:Cw,restoreClient:()=>Promise.resolve(void 0),removeClient:Cw}};function sb(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function ENe(e,t){let n;const r=()=>{if(n)return n;const a=indexedDB.open(e);return a.onupgradeneeded=()=>a.result.createObjectStore(t),n=sb(a),n.then(s=>{s.onclose=()=>n=void 0},()=>{}),n};return(a,s)=>r().then(o=>s(o.transaction(t,a).objectStore(t)))}let Y1;function OT(){return Y1||(Y1=ENe("keyval-store","keyval")),Y1}function wNe(e,t=OT()){return t("readonly",n=>sb(n.get(e)))}function kNe(e,t,n=OT()){return n("readwrite",r=>(r.put(t,e),sb(r.transaction)))}function TNe(e,t=OT()){return t("readwrite",n=>(n.delete(e),sb(n.transaction)))}const SNe=_Ne({storage:{getItem:e=>wNe(e).then(t=>t??null),setItem:(e,t)=>kNe(e,t),removeItem:e=>TNe(e)},key:"pierre-query-cache",throttleTime:1e3}),CNe=new k$({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1,retry:1}}});var J0,$O;($O=(J0=navigator.storage)==null?void 0:J0.persist)==null||$O.call(J0);new URLSearchParams(window.location.search).has("perf")&&M6(()=>import("./perfProbe-Da13EhTE.js"),[]).then(e=>e.startPerfProbe());const ZF=document.getElementById("root");if(!ZF)throw new Error("#root not found");const NNe=1e3*60*60*24*7;z6.createRoot(ZF).render(m.jsx(L.StrictMode,{children:m.jsx(U$,{client:CNe,persistOptions:{persister:SNe,maxAge:NNe,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:m.jsx(bNe,{})})}));
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-CnyfDi9-.js"></script>
23
+ <script type="module" crossorigin src="/app/assets/index-CDm-wJvA.js"></script>
24
24
  <link rel="stylesheet" crossorigin href="/app/assets/index-B1A5MHB0.css">
25
25
  </head>
26
26
  <body>